@atlasauth/pca-openai-代理服务器
OpenAI代理SDK的警卫(@openai/agents使得每个代理工具都称为"证明携带". withPcaTool 将工具包成这样 execute 首先需要一个 PCActn( 从运行上下文读取) , 用 PPC 核心验证它, 然后只运行原始工具; 在任何失败时, 它都会抛出 PcaToolDenied 而工具不运行。 护栏和 needsApproval 帮助者覆盖跑道关口和人或监护人的升级.
包被鸭子打到SDK上:它没有运行时间依赖 @openai/agents 并使用任何兼容的版本.
安装
npm i @atlasauth/pca-openai-agents
取决于 @atlasauth/pca 财务报告和审定财务报表 @atlasauth/pca-ai-sdk。 。 。 .
使用量
import { tool, Agent, run } from '@openai/agents';
import { withPcaTool, pcaInputGuardrail } from '@atlasauth/pca-openai-agents';
const refund = tool({ name: 'refund', description: '...', parameters, execute: doRefund });
const guarded = withPcaTool(refund, {
verify: { grant }, // pcaAgent.grant: the signed Root Intent Grant the proof must chain to
audience: 'ins_my_server', // must equal the PCActn's signed aud (null = accept any)
verb: 'stripe.refund', // bind the proof to this tool
});
const agent = new Agent({
name: 'support',
tools: [guarded],
inputGuardrails: [pcaInputGuardrail({ verify: { grant }, audience: 'ins_my_server' })],
});
// The agent holding the grant produces the proof (see @atlasauth/pca); it rides on the run context.
const { encoded } = pcaAgent.act('stripe.refund', 'charge:ch_1', toolInput, { aud: 'ins_my_server' });
await run(agent, input, { context: { pca: encoded } });
默认情况下,该证明从 context.pca (或 context.pcaProof; 通过 require 从工具输入或其他地方读取. verify 也可以是一个函数 (pcactn) => VerifyResult。 。 。 .
API 密码
withPcaTool(tool, options)编号 :pcaTools(record, options)- 包裹一个工具/一组pcaInputGuardrail(options), (中文(简体) ),pcaToolGuard(options)- SDK警卫员,在没有有效证据的情况下pcaNeedsApproval(options), (中文(简体) ),withApproval(tool, options)- 将危险工具映射到SDK的needsApproval使用五氯苯甲醚分级reviewToolCall(...), (中文(简体) ),pendingStepUps(reviews)- 输入一个批准信箱PcaToolDenied(与kind数字 :missing | malformed | verify | binding, (中文(简体) ),proofFromRunContext, (中文(简体) ),proofFromInputHeaders
状态
部分 证明机构. 核查是真实的(签名、能力链、计划包容、受众、有效性窗口、计数器),但只有您配置的赠款和大门才强大。 它保护当地代理-执行边界;当一个工具呼叫远程服务时,该服务本身的核查员仍然是权威. PCA的密码学没有经过独立审计.
许可证
麻省理工学院 - 见LICENSE