@agenticprimitives/a2a 0.0.0-alpha.4 → 0.0.0-alpha.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CLAUDE.md +60 -21
  2. package/README.md +2 -0
  3. package/bin/a2a-conform.mjs +17 -0
  4. package/dist/agent.d.ts +170 -3
  5. package/dist/agent.d.ts.map +1 -1
  6. package/dist/agent.js +358 -66
  7. package/dist/agent.js.map +1 -1
  8. package/dist/auth.d.ts +72 -9
  9. package/dist/auth.d.ts.map +1 -1
  10. package/dist/auth.js +62 -19
  11. package/dist/auth.js.map +1 -1
  12. package/dist/authority-extension.d.ts +58 -0
  13. package/dist/authority-extension.d.ts.map +1 -0
  14. package/dist/authority-extension.js +70 -0
  15. package/dist/authority-extension.js.map +1 -0
  16. package/dist/card-audience.d.ts +87 -0
  17. package/dist/card-audience.d.ts.map +1 -0
  18. package/dist/card-audience.js +135 -0
  19. package/dist/card-audience.js.map +1 -0
  20. package/dist/client.d.ts +23 -8
  21. package/dist/client.d.ts.map +1 -1
  22. package/dist/client.js +74 -13
  23. package/dist/client.js.map +1 -1
  24. package/dist/cloudflare/index.d.ts.map +1 -1
  25. package/dist/cloudflare/index.js +10 -2
  26. package/dist/cloudflare/index.js.map +1 -1
  27. package/dist/conform/index.d.ts +36 -0
  28. package/dist/conform/index.d.ts.map +1 -0
  29. package/dist/conform/index.js +232 -0
  30. package/dist/conform/index.js.map +1 -0
  31. package/dist/discovery.d.ts +4 -0
  32. package/dist/discovery.d.ts.map +1 -1
  33. package/dist/discovery.js +6 -2
  34. package/dist/discovery.js.map +1 -1
  35. package/dist/engagement.d.ts +37 -0
  36. package/dist/engagement.d.ts.map +1 -0
  37. package/dist/engagement.js +83 -0
  38. package/dist/engagement.js.map +1 -0
  39. package/dist/grant.d.ts +4 -2
  40. package/dist/grant.d.ts.map +1 -1
  41. package/dist/grant.js +21 -13
  42. package/dist/grant.js.map +1 -1
  43. package/dist/handoff.d.ts +42 -0
  44. package/dist/handoff.d.ts.map +1 -0
  45. package/dist/handoff.js +28 -0
  46. package/dist/handoff.js.map +1 -0
  47. package/dist/index.d.ts +25 -8
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +23 -3
  50. package/dist/index.js.map +1 -1
  51. package/dist/payment-gate.d.ts +17 -2
  52. package/dist/payment-gate.d.ts.map +1 -1
  53. package/dist/payment-gate.js +4 -2
  54. package/dist/payment-gate.js.map +1 -1
  55. package/dist/run-provenance-extension.d.ts +22 -0
  56. package/dist/run-provenance-extension.d.ts.map +1 -0
  57. package/dist/run-provenance-extension.js +23 -0
  58. package/dist/run-provenance-extension.js.map +1 -0
  59. package/dist/runtime.d.ts +13 -1
  60. package/dist/runtime.d.ts.map +1 -1
  61. package/dist/runtime.js +35 -10
  62. package/dist/runtime.js.map +1 -1
  63. package/dist/session-wire.d.ts +90 -0
  64. package/dist/session-wire.d.ts.map +1 -0
  65. package/dist/session-wire.js +226 -0
  66. package/dist/session-wire.js.map +1 -0
  67. package/dist/skill-handler.d.ts +21 -1
  68. package/dist/skill-handler.d.ts.map +1 -1
  69. package/dist/skill-handler.js.map +1 -1
  70. package/dist/standard/app-delegation.d.ts +60 -0
  71. package/dist/standard/app-delegation.d.ts.map +1 -0
  72. package/dist/standard/app-delegation.js +43 -0
  73. package/dist/standard/app-delegation.js.map +1 -0
  74. package/dist/standard/caller.d.ts +107 -0
  75. package/dist/standard/caller.d.ts.map +1 -0
  76. package/dist/standard/caller.js +176 -0
  77. package/dist/standard/caller.js.map +1 -0
  78. package/dist/standard/client.d.ts +53 -0
  79. package/dist/standard/client.d.ts.map +1 -0
  80. package/dist/standard/client.js +88 -0
  81. package/dist/standard/client.js.map +1 -0
  82. package/dist/standard/delegated.d.ts +121 -0
  83. package/dist/standard/delegated.d.ts.map +1 -0
  84. package/dist/standard/delegated.js +170 -0
  85. package/dist/standard/delegated.js.map +1 -0
  86. package/dist/standard/errors.d.ts +31 -0
  87. package/dist/standard/errors.d.ts.map +1 -0
  88. package/dist/standard/errors.js +75 -0
  89. package/dist/standard/errors.js.map +1 -0
  90. package/dist/standard/from-agent.d.ts +41 -0
  91. package/dist/standard/from-agent.d.ts.map +1 -0
  92. package/dist/standard/from-agent.js +133 -0
  93. package/dist/standard/from-agent.js.map +1 -0
  94. package/dist/standard/index.d.ts +10 -0
  95. package/dist/standard/index.d.ts.map +1 -0
  96. package/dist/standard/index.js +14 -0
  97. package/dist/standard/index.js.map +1 -0
  98. package/dist/standard/mount.d.ts +94 -0
  99. package/dist/standard/mount.d.ts.map +1 -0
  100. package/dist/standard/mount.js +186 -0
  101. package/dist/standard/mount.js.map +1 -0
  102. package/dist/standard/server.d.ts +130 -0
  103. package/dist/standard/server.d.ts.map +1 -0
  104. package/dist/standard/server.js +497 -0
  105. package/dist/standard/server.js.map +1 -0
  106. package/dist/standard/types.d.ts +186 -0
  107. package/dist/standard/types.d.ts.map +1 -0
  108. package/dist/standard/types.js +14 -0
  109. package/dist/standard/types.js.map +1 -0
  110. package/dist/subject-ask.d.ts +96 -0
  111. package/dist/subject-ask.d.ts.map +1 -0
  112. package/dist/subject-ask.js +45 -0
  113. package/dist/subject-ask.js.map +1 -0
  114. package/dist/subject-hop.d.ts +117 -0
  115. package/dist/subject-hop.d.ts.map +1 -0
  116. package/dist/subject-hop.js +187 -0
  117. package/dist/subject-hop.js.map +1 -0
  118. package/dist/task-store.d.ts +9 -3
  119. package/dist/task-store.d.ts.map +1 -1
  120. package/dist/task-store.js +12 -6
  121. package/dist/task-store.js.map +1 -1
  122. package/dist/wire-verify.d.ts +35 -0
  123. package/dist/wire-verify.d.ts.map +1 -0
  124. package/dist/wire-verify.js +51 -0
  125. package/dist/wire-verify.js.map +1 -0
  126. package/package.json +35 -12
  127. package/dist/jsonrpc.d.ts +0 -25
  128. package/dist/jsonrpc.d.ts.map +0 -1
  129. package/dist/jsonrpc.js +0 -52
  130. package/dist/jsonrpc.js.map +0 -1
@@ -0,0 +1,170 @@
1
+ export const AP_DELEGATED_TASK_EXTENSION = 'https://agenticprimitives.org/a2a/delegated-task/v1';
2
+ /** Rebuild the signed envelope from what arrived on the 1.0 wire. */
3
+ export function toProfileMessage(message, ext) {
4
+ return {
5
+ messageId: message.messageId,
6
+ ...(message.contextId ? { threadId: message.contextId } : {}),
7
+ sender: ext.sender,
8
+ skill: ext.skill,
9
+ bodyRef: ext.bodyRef,
10
+ bodyHash: ext.bodyHash,
11
+ signature: ext.signature,
12
+ createdAt: ext.createdAt,
13
+ };
14
+ }
15
+ /** The declaration a card makes so a peer learns this agent takes delegated tasks before calling. */
16
+ export const DELEGATED_TASK_CARD_EXTENSION = {
17
+ uri: AP_DELEGATED_TASK_EXTENSION,
18
+ required: false,
19
+ description: 'A task authorized by an ERC-7710 delegation carried on the message; the caller is authenticated by the Authorization header and must be the delegation\'s delegate. Adds the method GetTaskArtifact { id, artifactId } — a party reads an artifact BODY, which the task projection carries only as a ref and a hash (A2A-INV-04).',
20
+ };
21
+ /** The extension's one method beyond the core set: the artifact-body read a party is entitled to. */
22
+ export const GET_TASK_ARTIFACT_METHOD = 'GetTaskArtifact';
23
+ const isWire = (d) => {
24
+ const w = d;
25
+ return !!w && typeof w === 'object'
26
+ && typeof w.delegator === 'string' && /^0x[0-9a-fA-F]{40}$/.test(w.delegator)
27
+ && typeof w.delegate === 'string' && /^0x[0-9a-fA-F]{40}$/.test(w.delegate)
28
+ && typeof w.authority === 'string' && Array.isArray(w.caveats)
29
+ && (typeof w.salt === 'string' || typeof w.salt === 'number')
30
+ && typeof w.signature === 'string';
31
+ };
32
+ /**
33
+ * Read the extension off a message. `null` when the message does not declare it — that is an ordinary
34
+ * conversational message, not an error. A message that DECLARES it and carries a malformed body is an
35
+ * error, and says which field: silently treating it as conversational would run the wrong executor under
36
+ * an authority the sender believed they had presented.
37
+ */
38
+ export function readDelegatedTask(message) {
39
+ // No message at all is not this extension's business: the server's own validation says what is missing.
40
+ if (!message || typeof message !== 'object')
41
+ return null;
42
+ const declared = (message.extensions ?? []).includes(AP_DELEGATED_TASK_EXTENSION);
43
+ const raw = message.metadata?.[AP_DELEGATED_TASK_EXTENSION];
44
+ if (!declared && raw === undefined)
45
+ return null;
46
+ if (raw === undefined)
47
+ return { error: `message declares ${AP_DELEGATED_TASK_EXTENSION} and carries no metadata under it` };
48
+ const d = raw;
49
+ if (!isWire(d.delegation))
50
+ return { error: 'delegated-task: `delegation` is not a delegation wire' };
51
+ if (typeof d.skill !== 'string' || !d.skill.trim())
52
+ return { error: 'delegated-task: `skill` is required' };
53
+ const addr = (v) => typeof v === 'string' && /^0x[0-9a-fA-F]{40}$/.test(v);
54
+ if (!addr(d.requester))
55
+ return { error: 'delegated-task: `requester` must be an address' };
56
+ if (!addr(d.sender))
57
+ return { error: 'delegated-task: `sender` must be an address' };
58
+ if (typeof d.bodyHash !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(d.bodyHash))
59
+ return { error: 'delegated-task: `bodyHash` must be a 32-byte hash' };
60
+ if (!d.bodyRef || typeof d.bodyRef !== 'object' || !addr(d.bodyRef.owner))
61
+ return { error: 'delegated-task: `bodyRef.owner` must be an address' };
62
+ if (typeof d.signature !== 'string' || !d.signature.startsWith('0x'))
63
+ return { error: 'delegated-task: `signature` is required — the runtime re-derives the digest and checks it' };
64
+ if (typeof d.createdAt !== 'number' || !Number.isFinite(d.createdAt))
65
+ return { error: 'delegated-task: `createdAt` must be a number of seconds' };
66
+ if (d.taskId !== undefined && !/^0x[0-9a-fA-F]{64}$/.test(String(d.taskId)))
67
+ return { error: 'delegated-task: `taskId` must be a 32-byte hex id' };
68
+ // 1.0 lets a messageId be any string; the signed envelope's is a 32-byte hex, because that is what
69
+ // `hashA2aMessage` encodes. Caught here so the sender is told, rather than the digest failing to build.
70
+ if (!/^0x[0-9a-fA-F]{64}$/.test(message.messageId ?? ''))
71
+ return { error: 'delegated-task: `message.messageId` must be a 32-byte hex id — it is part of the signed envelope' };
72
+ return {
73
+ extension: AP_DELEGATED_TASK_EXTENSION, version: 1,
74
+ delegation: d.delegation, requester: d.requester, skill: d.skill.trim(),
75
+ sender: d.sender, bodyHash: d.bodyHash,
76
+ bodyRef: d.bodyRef, signature: d.signature,
77
+ createdAt: d.createdAt, ...(d.taskId ? { taskId: d.taskId } : {}),
78
+ };
79
+ }
80
+ /** Attach the extension to a message a client is about to send. */
81
+ export function withDelegatedTask(message, req) {
82
+ return {
83
+ ...message,
84
+ extensions: [...new Set([...(message.extensions ?? []), AP_DELEGATED_TASK_EXTENSION])],
85
+ metadata: { ...(message.metadata ?? {}), [AP_DELEGATED_TASK_EXTENSION]: { extension: AP_DELEGATED_TASK_EXTENSION, version: 1, ...req } },
86
+ };
87
+ }
88
+ /** The input body a delegated task carries: one data part, so the raw body hash the caller signed binds it. */
89
+ export const delegatedInputPart = (input) => ({ data: input ?? null });
90
+ /** Read the input back off a delegated message. */
91
+ export function delegatedInput(message) {
92
+ const part = (message.parts ?? []).find((p) => p.data !== undefined);
93
+ return part ? part.data : null;
94
+ }
95
+ /** The profile's task states are the 1.0 states under other names — one for one, no remainder. */
96
+ export const TASK_STATE_V1 = {
97
+ submitted: 'TASK_STATE_SUBMITTED',
98
+ working: 'TASK_STATE_WORKING',
99
+ completed: 'TASK_STATE_COMPLETED',
100
+ failed: 'TASK_STATE_FAILED',
101
+ canceled: 'TASK_STATE_CANCELED',
102
+ 'input-required': 'TASK_STATE_INPUT_REQUIRED',
103
+ rejected: 'TASK_STATE_REJECTED',
104
+ 'auth-required': 'TASK_STATE_AUTH_REQUIRED',
105
+ };
106
+ const V1_TO_STATE = Object.fromEntries(Object.entries(TASK_STATE_V1).map(([k, v]) => [v, k]));
107
+ /** The runtime's name for a 1.0 state. `TASK_STATE_UNSPECIFIED` has no runtime name and is a `failed`
108
+ * reading — a task in no state is not a task anyone should act on. */
109
+ export function taskStateFromV1(state) {
110
+ return V1_TO_STATE[state] ?? 'failed';
111
+ }
112
+ /**
113
+ * Project a delegation-authorized task into the A2A 1.0 shape a client reads.
114
+ *
115
+ * BODIES DO NOT COME ALONG (A2A-INV-04). A message body and an artifact body live in the assignee's vault;
116
+ * what travels is the REF and the hash, in `metadata`, exactly as the profile's `tasks/get` returned refs
117
+ * only. A party reads a body with the artifact op it was already entitled to use — the projection widens
118
+ * nothing, and inlining here would have quietly turned a ref into a disclosure.
119
+ */
120
+ export function delegatedTaskAsV1(src) {
121
+ const at = new Date(src.updatedAt ?? Date.now()).toISOString();
122
+ const history = (src.inbound ?? []).map((m) => ({
123
+ messageId: m.messageId,
124
+ role: 'ROLE_USER',
125
+ parts: [{ data: { bodyRef: m.bodyRef ?? null, bodyHash: m.bodyHash ?? null } }],
126
+ contextId: m.threadId ?? src.task.taskId,
127
+ taskId: src.task.taskId,
128
+ metadata: { sender: m.sender, ...(m.createdAt ? { createdAt: m.createdAt } : {}) },
129
+ }));
130
+ const artifacts = (src.artifacts ?? []).map((a) => ({
131
+ artifactId: a.artifactId,
132
+ ...(a.artifactKind ? { name: a.artifactKind } : {}),
133
+ parts: [{ data: { bodyRef: a.bodyRef ?? null, bodyHash: a.bodyHash ?? null } }],
134
+ metadata: { residency: 'vault', note: 'the body lives in the assignee\'s vault; read it with the artifact op' },
135
+ }));
136
+ return {
137
+ id: src.task.taskId,
138
+ contextId: (src.inbound ?? [])[0]?.threadId ?? src.task.taskId,
139
+ status: {
140
+ state: TASK_STATE_V1[src.task.state],
141
+ timestamp: at,
142
+ ...(src.error ? { message: { messageId: `${src.task.taskId}:error`, role: 'ROLE_AGENT', parts: [{ text: src.error }], contextId: src.task.taskId, taskId: src.task.taskId } } : {}),
143
+ },
144
+ ...(artifacts.length ? { artifacts } : {}),
145
+ ...(history.length ? { history } : {}),
146
+ metadata: {
147
+ [AP_DELEGATED_TASK_EXTENSION]: {
148
+ skill: src.skill,
149
+ principal: src.principal,
150
+ sender: src.sender,
151
+ assignee: src.task.assignee,
152
+ ...(src.task.permissionGrantRef ? { permissionGrantRef: src.task.permissionGrantRef } : {}),
153
+ ...(src.rev !== undefined ? { rev: src.rev } : {}),
154
+ },
155
+ },
156
+ };
157
+ }
158
+ /** The parties to a delegated task: its sender, the principal they act for, and the assignee. A `GetTask`
159
+ * or `CancelTask` from anyone else is answered as though the task did not exist — telling a stranger that
160
+ * it does is itself a disclosure (the profile's own rule, kept). */
161
+ export function isPartyToDelegatedTask(task, agent) {
162
+ if (!agent)
163
+ return false;
164
+ const m = task.metadata?.[AP_DELEGATED_TASK_EXTENSION];
165
+ if (!m)
166
+ return false;
167
+ const who = agent.toLowerCase();
168
+ return [m.principal, m.sender, m.assignee].some((a) => typeof a === 'string' && a.toLowerCase() === who);
169
+ }
170
+ //# sourceMappingURL=delegated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegated.js","sourceRoot":"","sources":["../../src/standard/delegated.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,2BAA2B,GAAG,qDAAqD,CAAC;AAyCjG,qEAAqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,OAAkB,EAAE,GAAoB;IACvE,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;KACzB,CAAC;AACJ,CAAC;AAED,qGAAqG;AACrG,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,GAAG,EAAE,2BAA2B;IAChC,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,mUAAmU;CACxU,CAAC;AAEX,qGAAqG;AACrG,MAAM,CAA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CAAC,EAAE,kBAAkB,EAAE,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3F,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACnD;SACF;KACF,CAAC;AACJ,CAAC;AAED;;qEAEqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,KAAgC;IACnF,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,CAAC,GAAI,IAAI,CAAC,QAAgD,EAAE,CAAC,2BAA2B,CACtB,CAAC;IACzE,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACrB,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAChC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC;AAC3G,CAAC"}
@@ -0,0 +1,31 @@
1
+ export declare const A2A_ERROR: {
2
+ readonly TaskNotFound: -32001;
3
+ readonly TaskNotCancelable: -32002;
4
+ readonly PushNotificationNotSupported: -32003;
5
+ readonly UnsupportedOperation: -32004;
6
+ readonly ContentTypeNotSupported: -32005;
7
+ readonly InvalidAgentResponse: -32006;
8
+ readonly ExtendedAgentCardNotConfigured: -32007;
9
+ readonly ExtensionSupportRequired: -32008;
10
+ readonly VersionNotSupported: -32009;
11
+ };
12
+ export declare const JSONRPC_ERROR: {
13
+ readonly ParseError: -32700;
14
+ readonly InvalidRequest: -32600;
15
+ readonly MethodNotFound: -32601;
16
+ readonly InvalidParams: -32602;
17
+ readonly Internal: -32603;
18
+ };
19
+ export declare class A2aError extends Error {
20
+ readonly code: number;
21
+ readonly metadata?: Record<string, string> | undefined;
22
+ constructor(code: number, message?: string, metadata?: Record<string, string> | undefined);
23
+ }
24
+ export interface JsonRpcErrorObject {
25
+ code: number;
26
+ message: string;
27
+ data?: unknown;
28
+ }
29
+ /** The JSON-RPC error object for an error: A2A-specific codes carry ErrorInfo in a `data` array. */
30
+ export declare function toJsonRpcError(e: unknown): JsonRpcErrorObject;
31
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/standard/errors.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;CAUZ,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AA+BX,qBAAa,QAAS,SAAQ,KAAK;aACL,IAAI,EAAE,MAAM;aAAoC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;gBAAjF,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAkB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAA;CAI9G;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,oGAAoG;AACpG,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAY7D"}
@@ -0,0 +1,75 @@
1
+ // A2A 1.0 ERRORS ON THE JSON-RPC BINDING — spec 372 S1 (A2A spec §5.4 + §9.5).
2
+ //
3
+ // Every A2A-specific error carries a `google.rpc.ErrorInfo` in `error.data[]`: the reason in UPPER_SNAKE
4
+ // without the "Error" suffix, the domain `a2a-protocol.org`. A client that only reads the code still gets
5
+ // the standard number; one that reads the data learns which task, which version, which content type.
6
+ export const A2A_ERROR = {
7
+ TaskNotFound: -32001,
8
+ TaskNotCancelable: -32002,
9
+ PushNotificationNotSupported: -32003,
10
+ UnsupportedOperation: -32004,
11
+ ContentTypeNotSupported: -32005,
12
+ InvalidAgentResponse: -32006,
13
+ ExtendedAgentCardNotConfigured: -32007,
14
+ ExtensionSupportRequired: -32008,
15
+ VersionNotSupported: -32009,
16
+ };
17
+ export const JSONRPC_ERROR = {
18
+ ParseError: -32700,
19
+ InvalidRequest: -32600,
20
+ MethodNotFound: -32601,
21
+ InvalidParams: -32602,
22
+ Internal: -32603,
23
+ };
24
+ const REASON = {
25
+ [-32001]: 'TASK_NOT_FOUND',
26
+ [-32002]: 'TASK_NOT_CANCELABLE',
27
+ [-32003]: 'PUSH_NOTIFICATION_NOT_SUPPORTED',
28
+ [-32004]: 'UNSUPPORTED_OPERATION',
29
+ [-32005]: 'CONTENT_TYPE_NOT_SUPPORTED',
30
+ [-32006]: 'INVALID_AGENT_RESPONSE',
31
+ [-32007]: 'EXTENDED_AGENT_CARD_NOT_CONFIGURED',
32
+ [-32008]: 'EXTENSION_SUPPORT_REQUIRED',
33
+ [-32009]: 'VERSION_NOT_SUPPORTED',
34
+ };
35
+ const MESSAGE = {
36
+ [-32001]: 'Task not found',
37
+ [-32002]: 'Task cannot be canceled',
38
+ [-32003]: 'Push notifications are not supported',
39
+ [-32004]: 'This operation is not supported',
40
+ [-32005]: 'Incompatible content types',
41
+ [-32006]: 'Invalid agent response',
42
+ [-32007]: 'Extended agent card is not configured',
43
+ [-32008]: 'A required extension is not supported',
44
+ [-32009]: 'Unsupported A2A protocol version',
45
+ [-32700]: 'Invalid JSON payload',
46
+ [-32600]: 'Request payload validation error',
47
+ [-32601]: 'Method not found',
48
+ [-32602]: 'Invalid parameters',
49
+ [-32603]: 'Internal error',
50
+ };
51
+ export class A2aError extends Error {
52
+ code;
53
+ metadata;
54
+ constructor(code, message, metadata) {
55
+ super(message ?? MESSAGE[code] ?? 'A2A error');
56
+ this.code = code;
57
+ this.metadata = metadata;
58
+ this.name = 'A2aError';
59
+ }
60
+ }
61
+ /** The JSON-RPC error object for an error: A2A-specific codes carry ErrorInfo in a `data` array. */
62
+ export function toJsonRpcError(e) {
63
+ if (e instanceof A2aError) {
64
+ const reason = REASON[e.code];
65
+ if (reason) {
66
+ return {
67
+ code: e.code, message: e.message,
68
+ data: [{ '@type': 'type.googleapis.com/google.rpc.ErrorInfo', reason, domain: 'a2a-protocol.org', metadata: { ...(e.metadata ?? {}), timestamp: new Date().toISOString() } }],
69
+ };
70
+ }
71
+ return { code: e.code, message: e.message, ...(e.metadata ? { data: e.metadata } : {}) };
72
+ }
73
+ return { code: JSONRPC_ERROR.Internal, message: MESSAGE[-32603], data: { detail: e instanceof Error ? e.message : String(e) } };
74
+ }
75
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/standard/errors.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,yGAAyG;AACzG,0GAA0G;AAC1G,qGAAqG;AAErG,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,YAAY,EAAE,CAAC,KAAK;IACpB,iBAAiB,EAAE,CAAC,KAAK;IACzB,4BAA4B,EAAE,CAAC,KAAK;IACpC,oBAAoB,EAAE,CAAC,KAAK;IAC5B,uBAAuB,EAAE,CAAC,KAAK;IAC/B,oBAAoB,EAAE,CAAC,KAAK;IAC5B,8BAA8B,EAAE,CAAC,KAAK;IACtC,wBAAwB,EAAE,CAAC,KAAK;IAChC,mBAAmB,EAAE,CAAC,KAAK;CACnB,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,QAAQ,EAAE,CAAC,KAAK;CACR,CAAC;AAEX,MAAM,MAAM,GAA2B;IACrC,CAAC,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+ import type { TaskStore } from '../task-store.js';
3
+ import type { TaskRecord } from '../types.js';
4
+ import { type PushConfigStore, type Principal, type StandardExecutor, type StandardServer, type StandardServerConfig, type StandardTaskStore } from './server.js';
5
+ import type { AgentCardV1, MessageV1, TaskV1 } from './types.js';
6
+ /** Project a runtime record into the 1.0 shape. */
7
+ export declare const recordAsV1: (r: TaskRecord) => TaskV1;
8
+ /** A read-only `StandardTaskStore` over the runtime's own store, plus a writable side for tasks this
9
+ * server creates itself (a plain conversation). One `GetTask` answers from whichever holds the id. */
10
+ export declare function taskStoreOverAgent(runtime: TaskStore, own: StandardTaskStore): StandardTaskStore;
11
+ export interface AgentBackedServerOptions {
12
+ /** The delegation-authorized runtime this wire serves. */
13
+ agent: A2aAgent;
14
+ /** The runtime's task store — read for `GetTask` / `ListTasks`, never written here. */
15
+ runtimeStore: TaskStore;
16
+ card: AgentCardV1;
17
+ /** Where this server's own (non-delegated) tasks live. */
18
+ ownStore: StandardTaskStore;
19
+ push?: PushConfigStore;
20
+ /** What answers a message that carries no delegated-task extension — an ordinary conversation. Omit and
21
+ * such a message is refused, saying what this agent takes. */
22
+ executor?: StandardExecutor;
23
+ principal?: StandardServerConfig['principal'];
24
+ /** Visibility of a NON-delegated (conversational) task on top of the delegated-task party rule — normally
25
+ * its owner. Spec 408 §2.5: absent ⇒ such a task is NOBODY's unless `visibility: 'single-tenant'` is declared. */
26
+ canSeeOwnTask?: (task: TaskV1, principal: Principal | null) => Promise<boolean> | boolean;
27
+ /** Spec 408 §2.5 — every conversational task is the one caller's (a single-principal deployment). */
28
+ visibility?: 'single-tenant';
29
+ versions?: string[];
30
+ fetch?: typeof fetch;
31
+ now?: () => number;
32
+ }
33
+ /**
34
+ * Build the ONE server this agent serves: A2A 1.0 methods, the delegation-authorized runtime behind
35
+ * `SendMessage`-with-extension, and an ordinary conversation behind `SendMessage` without one.
36
+ */
37
+ export declare function createAgentBackedServer(opts: AgentBackedServerOptions): StandardServer;
38
+ /** The message a client sends to reach the runtime: what `A2aWireAdapter.submitTask` builds. Exported so a
39
+ * consumer can construct one without the adapter. */
40
+ export type { MessageV1 };
41
+ //# sourceMappingURL=from-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from-agent.d.ts","sourceRoot":"","sources":["../../src/standard/from-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,EAEL,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,iBAAiB,EACpI,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEjE,mDAAmD;AACnD,eAAO,MAAM,UAAU,MAAO,UAAU,KAAG,MAQzC,CAAC;AAEH;uGACuG;AACvG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,iBAAiB,GAAG,iBAAiB,CAchG;AAED,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,KAAK,EAAE,QAAQ,CAAC;IAChB,uFAAuF;IACvF,YAAY,EAAE,SAAS,CAAC;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,0DAA0D;IAC1D,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;mEAC+D;IAC/D,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC9C;uHACmH;IACnH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC1F,qGAAqG;IACrG,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,cAAc,CAyFtF;AAED;sDACsD;AACtD,YAAY,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { AP_DELEGATED_TASK_EXTENSION, DELEGATED_TASK_CARD_EXTENSION, GET_TASK_ARTIFACT_METHOD, delegatedInput, delegatedTaskAsV1, isPartyToDelegatedTask, readDelegatedTask, toProfileMessage, } from './delegated.js';
2
+ import { wireToDelegation } from '../session-wire.js';
3
+ import { A2A_ERROR, A2aError, JSONRPC_ERROR } from './errors.js';
4
+ import { createMemoryPushStore, createStandardA2aServer, } from './server.js';
5
+ /** Project a runtime record into the 1.0 shape. */
6
+ export const recordAsV1 = (r) => delegatedTaskAsV1({
7
+ task: { taskId: r.task.taskId, state: r.task.state, assignee: r.task.assignee, permissionGrantRef: r.task.permissionGrantRef },
8
+ principal: r.principal, sender: r.sender, skill: r.skill,
9
+ inbound: (r.inbound ?? []).map((m) => ({ messageId: m.messageId, sender: m.sender, threadId: m.threadId, createdAt: m.createdAt, bodyRef: m.bodyRef, bodyHash: m.bodyHash })),
10
+ artifacts: (r.artifacts ?? []).map((a) => ({ artifactId: a.artifactId, artifactKind: a.artifactKind, bodyRef: a.bodyRef, bodyHash: a.contentHash })),
11
+ ...(r.error ? { error: r.error } : {}),
12
+ ...(r.rev !== undefined ? { rev: r.rev } : {}),
13
+ ...(r.updatedAt !== undefined ? { updatedAt: r.updatedAt } : {}),
14
+ });
15
+ /** A read-only `StandardTaskStore` over the runtime's own store, plus a writable side for tasks this
16
+ * server creates itself (a plain conversation). One `GetTask` answers from whichever holds the id. */
17
+ export function taskStoreOverAgent(runtime, own) {
18
+ return {
19
+ async get(id) {
20
+ const rec = /^0x[0-9a-fA-F]{64}$/.test(id) ? await runtime.get(id).catch(() => null) : null;
21
+ return rec ? recordAsV1(rec) : own.get(id);
22
+ },
23
+ put: (t) => own.put(t),
24
+ async all() {
25
+ const mine = await own.all();
26
+ if (!runtime.list)
27
+ return mine;
28
+ const theirs = (await runtime.list(200).catch(() => [])).map(recordAsV1);
29
+ return [...theirs, ...mine];
30
+ },
31
+ };
32
+ }
33
+ const REFUSES_PLAIN = 'this agent takes delegation-authorized tasks; carry the delegated-task extension on the message';
34
+ /**
35
+ * Build the ONE server this agent serves: A2A 1.0 methods, the delegation-authorized runtime behind
36
+ * `SendMessage`-with-extension, and an ordinary conversation behind `SendMessage` without one.
37
+ */
38
+ export function createAgentBackedServer(opts) {
39
+ const tasks = taskStoreOverAgent(opts.runtimeStore, opts.ownStore);
40
+ const card = {
41
+ ...opts.card,
42
+ capabilities: {
43
+ ...opts.card.capabilities,
44
+ extensions: [
45
+ ...(opts.card.capabilities.extensions ?? []).filter((e) => e.uri !== AP_DELEGATED_TASK_EXTENSION),
46
+ { ...DELEGATED_TASK_CARD_EXTENSION },
47
+ ],
48
+ },
49
+ };
50
+ return createStandardA2aServer({
51
+ card,
52
+ tasks,
53
+ push: opts.push ?? createMemoryPushStore(),
54
+ ...(opts.principal ? { principal: opts.principal } : {}),
55
+ ...(opts.versions ? { versions: opts.versions } : {}),
56
+ ...(opts.fetch ? { fetch: opts.fetch } : {}),
57
+ ...(opts.now ? { now: opts.now } : {}),
58
+ executor: opts.executor ?? { execute: async (ctx) => ctx.reject([{ text: REFUSES_PLAIN }]) },
59
+ // A delegated task is the RUNTIME's: it keeps its id, its states and its gates.
60
+ beforeSend: async ({ message, configuration }, principal) => {
61
+ const ext = readDelegatedTask(message);
62
+ if (ext === null)
63
+ return null; // an ordinary conversation
64
+ if ('error' in ext)
65
+ throw new A2aError(JSONRPC_ERROR.InvalidParams, ext.error);
66
+ // The caller at the door and the party the grant names must be the same agent. The runtime checks
67
+ // this too (delegate === requester); doing it here as well means an impostor never reaches it.
68
+ if (principal && ext.requester.toLowerCase() !== principal.agent.toLowerCase()) {
69
+ throw new A2aError(JSONRPC_ERROR.InvalidParams, `the delegated task names ${ext.requester} as its requester; you are calling as ${principal.agent}`);
70
+ }
71
+ const profileMessage = toProfileMessage(message, ext);
72
+ const params = {
73
+ // The wire carries `salt` as a decimal string; the runtime hashes a bigint.
74
+ delegation: wireToDelegation(ext.delegation),
75
+ requester: ext.requester,
76
+ message: profileMessage,
77
+ input: delegatedInput(message),
78
+ ...(configuration?.taskPushNotificationConfig?.url ? { pushConfig: { url: configuration.taskPushNotificationConfig.url, ...(configuration.taskPushNotificationConfig.token ? { token: configuration.taskPushNotificationConfig.token } : {}) } } : {}),
79
+ };
80
+ const r = ext.taskId
81
+ ? await opts.agent.resubmit({ ...params, taskId: ext.taskId })
82
+ : await opts.agent.messageSend(params);
83
+ if (!r.ok)
84
+ throw new A2aError(r.code === -32001 ? JSONRPC_ERROR.InvalidParams : r.code, r.message);
85
+ const rec = await opts.runtimeStore.get(r.result.taskId);
86
+ // The projection is the answer; falling back to a synthetic task would report a state nothing holds.
87
+ if (!rec)
88
+ throw new A2aError(A2A_ERROR.InvalidAgentResponse, `the runtime accepted task ${r.result.taskId} and the store does not hold it`);
89
+ return { task: recordAsV1(rec) };
90
+ },
91
+ onCancel: async (task, principal) => {
92
+ if (!isPartyToDelegatedTask(task, principal?.agent))
93
+ return null; // not the runtime's — the ordinary path
94
+ // The door authenticated this caller; the runtime re-runs the party test and nothing else.
95
+ const r = await opts.agent.tasksCancelAs({ taskId: task.id, caller: principal.agent });
96
+ if (!r.ok)
97
+ throw new A2aError(r.code, r.message);
98
+ const rec = await opts.runtimeStore.get(task.id);
99
+ return rec ? recordAsV1(rec) : null;
100
+ },
101
+ canSeeTask: async (task, principal, op) => {
102
+ const delegated = task.metadata?.[AP_DELEGATED_TASK_EXTENSION] !== undefined;
103
+ if (delegated)
104
+ return isPartyToDelegatedTask(task, principal?.agent);
105
+ return opts.canSeeOwnTask ? (await opts.canSeeOwnTask(task, principal)) === true : opts.visibility === 'single-tenant';
106
+ },
107
+ // THE ARTIFACT BODY READ (the extension's one method). The profile's `tasks/artifact` was the only wire path
108
+ // to a body — the projection carries a ref and a hash, never the body (A2A-INV-04) — and the fold dropped it
109
+ // without a 1.0 successor; the skills corpus agent, which reads the documents its dispatched tasks produce,
110
+ // was the consumer that found out. The door's principal must be a PARTY (sender or assignee, the runtime's
111
+ // own test); an unauthenticated caller, a non-party, and an artifact of another task all read as not found.
112
+ methods: {
113
+ [GET_TASK_ARTIFACT_METHOD]: async (params, principal) => {
114
+ const id = String(params.id ?? params.taskId ?? '');
115
+ const artifactId = String(params.artifactId ?? '');
116
+ if (!/^0x[0-9a-fA-F]{64}$/.test(id) || !artifactId)
117
+ throw new A2aError(JSONRPC_ERROR.InvalidParams, 'GetTaskArtifact takes { id, artifactId }');
118
+ if (!principal?.agent)
119
+ throw new A2aError(A2A_ERROR.TaskNotFound, undefined, { id });
120
+ const r = await opts.agent.tasksArtifactAs({ taskId: id, artifactId: artifactId, caller: principal.agent });
121
+ if (!r.ok)
122
+ throw new A2aError(A2A_ERROR.TaskNotFound, undefined, { id });
123
+ return {
124
+ artifactId: r.result.artifactId,
125
+ ...(r.result.artifactKind ? { name: r.result.artifactKind } : {}),
126
+ parts: [{ data: r.result.body ?? null }],
127
+ metadata: { bodyRef: r.result.bodyRef, residency: 'vault' },
128
+ };
129
+ },
130
+ },
131
+ });
132
+ }
133
+ //# sourceMappingURL=from-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from-agent.js","sourceRoot":"","sources":["../../src/standard/from-agent.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,2BAA2B,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,cAAc,EAAE,iBAAiB,EACvH,sBAAsB,E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.js';
2
+ export * from './errors.js';
3
+ export * from './server.js';
4
+ export * from './caller.js';
5
+ export * from './delegated.js';
6
+ export * from './from-agent.js';
7
+ export * from './client.js';
8
+ export * from './mount.js';
9
+ export * from './app-delegation.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/standard/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ // @agenticprimitives/a2a/standard — the A2A 1.0 standard surface (spec 372 S1), beside the delegation
2
+ // profile at the package root. A door for every A2A 1.0 client and the official TCK; never a grant.
3
+ export * from './types.js';
4
+ export * from './errors.js';
5
+ export * from './server.js';
6
+ export * from './caller.js';
7
+ export * from './delegated.js';
8
+ export * from './from-agent.js';
9
+ export * from './client.js';
10
+ // Spec 372 S2/S4, spec 399 §4 — mounting this surface in front of a harness: card fields, task-id shape, the
11
+ // one task view, the two admission schemes, delegated/engagement dispatch, the reply-kind → state table.
12
+ export * from './mount.js';
13
+ export * from './app-delegation.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/standard/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,oGAAoG;AACpG,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,6GAA6G;AAC7G,yGAAyG;AACzG,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,94 @@
1
+ import type { Address } from 'viem';
2
+ import type { ExecutionContext, Principal, StandardServerConfig, StandardTaskStore } from './server.js';
3
+ import type { PartV1, TaskV1 } from './types.js';
4
+ /** The delegation runtime mints 32-byte hex task ids; a standard server's own conversational tasks are
5
+ * uuids. That is how a read knows which side holds a task — the shape is minted, not guessed. */
6
+ export declare const isRuntimeTaskId: (id: unknown) => boolean;
7
+ /** The text of a message's parts, joined; `data` parts that are strings count as text. */
8
+ export declare const partsText: (parts: PartV1[]) => string;
9
+ /** The first structured `data` part, or null. */
10
+ export declare const partsData: (parts: PartV1[]) => Record<string, unknown> | null;
11
+ /** Spec 390 W2 — the W3C Trace Context a request arrived with, as headers to forward on the next hop so the
12
+ * run's record keeps it. Ids only: nothing admits on these. */
13
+ export declare function traceHeadersOf(h: Headers): Record<string, string>;
14
+ export interface StandardCardFieldsOpts {
15
+ /** Where this surface takes A2A 1.0 JSON-RPC. */
16
+ messageUrl: string;
17
+ /** The card extensions this surface admits (default: the delegated-task and engagement extensions). */
18
+ extensions?: Array<{
19
+ uri: string;
20
+ [k: string]: unknown;
21
+ }>;
22
+ /** The bearer scheme a person presents (default: a Home session — it names the asking person and grants nothing). */
23
+ bearer?: {
24
+ name: string;
25
+ bearerFormat: string;
26
+ description: string;
27
+ };
28
+ }
29
+ /**
30
+ * The 1.0 fields a live card needs on top of what a runtime already builds: an interface with a protocol
31
+ * version, input/output modes, skills with names, the extensions this surface admits and the bearer scheme.
32
+ * Additive — every field the card carried stays; a released card (spec 347 §8) is served byte-for-byte and
33
+ * never passes through here.
34
+ */
35
+ export declare function withStandardCardFields(live: Record<string, unknown>, opts: StandardCardFieldsOpts): Record<string, unknown>;
36
+ /** A JSON-RPC call forwarded to the agent's own delegation runtime; the response comes back verbatim. */
37
+ export type DelegatedRpc = (agent: Address, rpc: unknown, principal: Principal | null) => Promise<{
38
+ result?: unknown;
39
+ error?: {
40
+ code: number;
41
+ message: string;
42
+ };
43
+ }>;
44
+ /**
45
+ * ONE TASK VIEW over two stores (spec 372 S4): a 32-byte hex id can only be the runtime's, so a read asks
46
+ * the object that owns it; anything else is a conversation this server made. A caller cannot tell, and
47
+ * must not have to. Writes go to the local store only — a delegated task is the runtime's to write.
48
+ */
49
+ export declare function runtimeBackedTaskStore(input: {
50
+ local: StandardTaskStore;
51
+ agent: Address;
52
+ rpc: DelegatedRpc;
53
+ }): StandardTaskStore;
54
+ /**
55
+ * What runs in front of `SendMessage` and `CancelTask` when the agent has a delegation runtime and/or answers
56
+ * engagement probes. A message carrying the DELEGATED-TASK extension is forwarded to the runtime, which keeps
57
+ * its own task id (two ids for one task would make `GetTask` a coin toss). An engagement PROBE is answered
58
+ * with a MESSAGE and no task (spec 336 §5) — the provider's own document — and only for a known caller who is
59
+ * the requester it names, addressed to this agent. A malformed engagement document is refused, never ignored.
60
+ */
61
+ export declare function delegatedDispatch(input: {
62
+ agent: Address;
63
+ rpc?: DelegatedRpc;
64
+ answerProbe?: (input: {
65
+ agent: Address;
66
+ probe: Record<string, unknown>;
67
+ caller: Principal | null;
68
+ }) => Promise<Record<string, unknown>>;
69
+ }): Pick<StandardServerConfig, 'beforeSend' | 'onCancel'>;
70
+ /** A delegated task is visible to its parties; a conversation, to whoever had it (its `asker`). A task
71
+ * nobody claimed is NOBODY'S (R917-P-6, spec 408 §2.6): the old "single-tenant shape" made every
72
+ * asker-less task world-readable, and a runtime with two tenants is not single-tenant. Compared
73
+ * lowercased on both sides — the caller assertion lowercases the agent (`caller.ts`), a task's
74
+ * metadata may not. */
75
+ export declare function canSeeDelegatedOrOwnTask(task: TaskV1, principal: Principal | null): boolean;
76
+ /**
77
+ * TWO SCHEMES, ONE MECHANISM EACH (ADR-0013). `Bearer` is a PERSON's session; `A2A-Session` is an AGENT's
78
+ * session wire, verified on chain per request (spec 372 S3c). The scheme token selects which runs — neither
79
+ * is ever tried because the other failed, and each fails closed on its own terms. `first` is the product's
80
+ * own door (an in-process marker, say): it answers a principal, `null` to refuse, or `undefined` to say the
81
+ * request is not its to judge.
82
+ */
83
+ export declare function principalBySchemes(input: {
84
+ bearer: (token: string) => Promise<Principal | null>;
85
+ wire?: ((request: Request) => Promise<Principal | null>) | null;
86
+ first?: (request: Request) => Principal | null | undefined;
87
+ }): (request: Request) => Promise<Principal | null>;
88
+ /** The task state a harness reply's KIND maps to (spec 372 S4): a question parks as INPUT_REQUIRED, an act
89
+ * that needs a mandate as AUTH_REQUIRED, an answer or a done act completes, a refusal rejects, an error fails. */
90
+ export type ReplySettlement = 'completed' | 'input-required' | 'auth-required' | 'rejected' | 'failed';
91
+ export declare function settlementForReplyKind(kind: string | undefined): ReplySettlement;
92
+ /** Move the task to a settlement with the given parts. */
93
+ export declare function settleTask(ctx: ExecutionContext, settlement: ReplySettlement, parts: PartV1[]): Promise<void>;
94
+ //# sourceMappingURL=mount.d.ts.map