@ agenticprimitives/ service-agent( 服务代理)
部分 代理先导 ——代理应用程序的开源信任底板:可以签名的身份,行为时间检查权限,所有者携带的证据. 开发者工具包 • 妇女 所有软件包
状态 : 实验(Spec 283 PR1).
建筑通用框架 服务代理商 - 暴露能力目录的特工
(技能),并在分层的权力下执行。 它不偏重任何供货商,而纯于环0:仅取决于
打开 @agenticprimitives/types 并且不进口钱包、交换、RPC、MCP、授权或政策代码。 这个
具体提供者和主管部门评价员 已注射 以主妇盟誓.
域目录——如. @agenticprimitives/treasury ——是分别提供技能定义的包
- 供货商中立的计划; 此套件运行生命周期.
生命周期
define → assert → entitle / delegate → primitive-plan → execute → receipt
- 定义 a 包括:
SkillDefinition说明一种技能的含义: id, version,effect(单位:千美元)read|sign|spend|trade|admin),默认exposure逻辑能力requires选项 我/O计划,和acompile()发出一个 原始计划定义并不声称主机可以 运行它. - 主张 —— 说
assertSkills解决每个定义的requires反对:PrimitiveRegistryA级 技能要求只当每个非可选要求与安装的Primitive谁 约束 覆盖 要求(模拟)。 结果是AssertionReport(单位:千美元)asserted编号 :unavailable编号 :rejected) (中文(简体) ). 可选publishAssertion钩子是公用的接缝 (第282项:金库索赔)atl:skills—发现+A2A卡. - 授权/代表/警卫 - 计划
.authorize('entitlement', …), (中文(简体) ),.authorize('delegation', …)财务报告和审定财务报表.guard(…)步骤 已注射 评估员(制图员)tool-policy编号 :entitlements, (中文(简体) ),delegation,以及tool-policy(掌声) 每道门必须ALLOW;第一次拒绝投出键入 错误和无进一步运行( 未关闭) . - 原始计划/ 执行 —— 说
runPlan决定ref()s, 呼叫注册原始人.step编号 (加内置)ledger.reserve编号 :ledger.finalize),并收取.output。 。 。 . - 收据 —— 说
invoke返回已规范ExecutionReceipt(权威决定+原始约束)- 输出);主汇/通过
audit。 。 。 .
- 输出);主汇/通过
示例
import { ServiceAgent, defineSkill, createPrimitiveRegistry, primitivePlan, ref } from '@agenticprimitives/service-agent';
const balance = defineSkill<{ accountId: string }, { balance: string }>({
id: 'treasury.account.balance', version: '1.0.0', name: 'Read balance',
effect: 'read', defaultExposure: 'authenticated',
requires: [{ capability: 'account.balance' }],
compile: ({ input }) =>
primitivePlan('plan.balance')
.step('bal', 'account.balance', { accountId: input.accountId })
.output({ balance: ref('bal', 'balance') }),
});
const registry = createPrimitiveRegistry();
registry.register(myAccountProvider); // advertises { id: 'account.balance', version, constraints }
const agent = new ServiceAgent({ descriptor: { id: '0x…', name: 'Treasury', version: '1.0.0' }, primitives: registry });
agent.define(balance);
await agent.assert();
const receipt = await agent.invoke({ skillId: 'treasury.account.balance', input: { accountId: 'acct-1' } });
花的技巧,加点 .authorize('entitlement', …), (中文(简体) ), .authorize('delegation', …), (中文(简体) ), .guard(…),则
分类账储备/最后敲定步骤;电线 entitlements 编号 : delegations 编号 : policies 编号 : ledger 输入
ServiceAgentOptions。见 test/conformance.test.ts 整个生命周期都有假货.
住在别的地方
- 供应商 (EVM转让、互换地点、RPC、KMS签名)——EXTERNAL(ADR-0037);它们登记为
Primitives. 德摩斯船伪造. - 权威逻辑 —— 说
delegation, (中文(简体) ),tool-policy, (中文(简体) ),entitlements;作为评价员注入. - 国库目录 —— 说
@agenticprimitives/treasury。 。 。 . 公开披露 - 应用程序,通过publishAssertion(第282页).