@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,187 @@
1
+ // A ROUTED ASK ACROSS DEPLOYMENTS — spec 366 R4 / 374 §4 / 376. Promoted from the runtime app in spec 399 W0
2
+ // (§4): the HOP is protocol, every A2A service that routes a step to another agent makes it the same way.
3
+ //
4
+ // Inside one deployment a routed step (spec 366 R1) is made in-process. To an agent served ELSEWHERE the hop
5
+ // is a network call, and it rides the one wire there is (spec 372 S4): an A2A 1.0 `SendMessage` whose
6
+ // `message.metadata` carries the SUBJECT-ASK PROFILE (`SubjectAskV1`), and whose reply comes back as the
7
+ // task's `subject-answer` artifact — the receiver's own ask envelope, verbatim.
8
+ //
9
+ // Resolved through the card, not assumed: the caller says where the card is served, and the CARD says where
10
+ // the agent takes A2A 1.0 requests. A card that publishes no such interface is an agent that cannot be asked
11
+ // this way, and the sender says so — it never reads the subject's records locally instead (R3), and it never
12
+ // guesses a path (ADR-0013).
13
+ //
14
+ // Everything here is pure: the caller supplies `fetch`; nothing reads a store or a chain.
15
+ import { AP_SUBJECT_ASK_EXTENSION_URI, validateSubjectAsk } from './subject-ask.js';
16
+ import { AP_HANDOFF_EXTENSION_URI, validateHandoff } from './handoff.js';
17
+ /** The A2A 1.0 JSON-RPC endpoint a card publishes, or null when it publishes none. */
18
+ export function a2aEndpointOf(card) {
19
+ // A RELEASED card (the Studio's, signed) states the protocol version ONCE at the top; the live card
20
+ // states it per interface. Either says 1.x or the interface is not one this hop can use.
21
+ const top = /^1\./.test(String(card?.protocolVersion ?? ''));
22
+ const hit = (card?.supportedInterfaces ?? []).find((i) => i.protocolBinding === 'JSONRPC' && (/^1\./.test(String(i.protocolVersion ?? '')) || (i.protocolVersion === undefined && top)) && typeof i.url === 'string' && /^https:\/\//.test(i.url));
23
+ return hit?.url ?? null;
24
+ }
25
+ const hex32 = () => `0x${[...crypto.getRandomValues(new Uint8Array(32))].map((b) => b.toString(16).padStart(2, '0')).join('')}`;
26
+ /** The message that carries a subject-ask over the wire: the goal as text, the profile as metadata. */
27
+ export function subjectAskMessage(profile) {
28
+ return {
29
+ messageId: hex32(),
30
+ role: 'ROLE_USER',
31
+ parts: [{ text: profile.request.goal }],
32
+ extensions: [AP_SUBJECT_ASK_EXTENSION_URI],
33
+ metadata: { [AP_SUBJECT_ASK_EXTENSION_URI]: profile },
34
+ };
35
+ }
36
+ /** The subject-ask a received message carries, validated; null when it carries none. */
37
+ export function subjectAskOf(message) {
38
+ const raw = message.metadata?.[AP_SUBJECT_ASK_EXTENSION_URI];
39
+ if (raw === undefined)
40
+ return null;
41
+ const v = validateSubjectAsk(raw);
42
+ return v.ok ? { ask: v.ask } : { errors: v.errors };
43
+ }
44
+ export const SUBJECT_ANSWER_ARTIFACT = 'subject-answer';
45
+ /**
46
+ * Appendix M8 — THE RECEIVER'S RUN, NAMED BY THE SENDER. A routed step's run at the subject's agent is
47
+ * addressable before it answers, so the sender can read its progress while it runs and its record can
48
+ * cite it by reference. Derived from the correlation the sender minted; the receiver adopts it for a
49
+ * fresh ask (a resume names the run it continues instead).
50
+ */
51
+ export function routedRunRefFor(correlation) {
52
+ return `routed-${correlation.runRef}-${correlation.stepRef}`.replace(/[^A-Za-z0-9._:-]/g, '_');
53
+ }
54
+ /** The receiver's `/harness/ask` envelope, as the task's `subject-answer` artifact carries it. */
55
+ export function subjectEnvelopeOf(task) {
56
+ const art = (task?.artifacts ?? []).find((a) => a.name === SUBJECT_ANSWER_ARTIFACT);
57
+ const part = art?.parts.find((p) => p.data && typeof p.data === 'object' && !Array.isArray(p.data));
58
+ return part ? part.data : null;
59
+ }
60
+ /**
61
+ * The hop: fetch the card, take its 1.0 endpoint, send ONE message, read the artifact. A task that ended
62
+ * without the artifact is relayed in the receiver's status words (a rejection, a need), never retried.
63
+ */
64
+ export async function sendSubjectAskOverWire(input) {
65
+ let card = null;
66
+ try {
67
+ const res = await input.fetch(input.cardUrl, { method: 'GET', headers: { accept: 'application/json' } });
68
+ if (!res.ok)
69
+ return { ok: false, refused: `its card at ${input.cardUrl} answered ${res.status}`, status: res.status };
70
+ const text = await res.text();
71
+ if (input.pinnedDigest) {
72
+ const served = `0x${[...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)))].map((b) => b.toString(16).padStart(2, '0')).join('')}`;
73
+ if (served !== input.pinnedDigest.toLowerCase())
74
+ return { ok: false, refused: `the card served at ${input.cardUrl} is not the one its name pins (atl:cardDigest ${input.pinnedDigest.slice(0, 12)}…, served ${served.slice(0, 12)}…)` };
75
+ }
76
+ card = JSON.parse(text);
77
+ }
78
+ catch (e) {
79
+ return { ok: false, refused: `its card at ${input.cardUrl} could not be read: ${e instanceof Error ? e.message : String(e)}` };
80
+ }
81
+ const endpoint = a2aEndpointOf(card);
82
+ if (!endpoint)
83
+ return { ok: false, refused: 'its card publishes no A2A 1.0 endpoint this agent can ask' };
84
+ const rpc = { jsonrpc: '2.0', id: 1, method: 'SendMessage', params: { message: subjectAskMessage(input.profile) } };
85
+ let res;
86
+ try {
87
+ res = await input.fetch(endpoint, {
88
+ method: 'POST',
89
+ headers: { 'content-type': 'application/json', accept: 'application/json', 'a2a-version': '1.0', ...(input.session ? { authorization: `Bearer ${input.session}` } : {}), ...(input.traceparent ? { traceparent: input.traceparent } : {}), ...(input.tracestate ? { tracestate: input.tracestate } : {}) },
90
+ body: JSON.stringify(rpc),
91
+ });
92
+ }
93
+ catch (e) {
94
+ return { ok: false, endpoint, refused: `could not reach ${endpoint}: ${e instanceof Error ? e.message : String(e)}` };
95
+ }
96
+ const body = (await res.json().catch(() => null));
97
+ if (!body)
98
+ return { ok: false, endpoint, refused: `${endpoint} answered ${res.status} with no JSON-RPC body`, status: res.status };
99
+ if (body.error)
100
+ return { ok: false, endpoint, refused: `${endpoint} answered ${body.error.code}: ${body.error.message}`, status: res.status };
101
+ const task = body.result?.task;
102
+ if (!task)
103
+ return { ok: false, endpoint, refused: `${endpoint} answered with a message, not a task`, status: res.status };
104
+ const envelope = subjectEnvelopeOf(task);
105
+ if (envelope)
106
+ return { ok: true, endpoint, task, envelope };
107
+ const said = (task.status?.message?.parts ?? []).map((p) => (typeof p.text === 'string' ? p.text : '')).filter(Boolean).join(' ');
108
+ return { ok: false, endpoint, task, refused: `${task.status?.state ?? 'unknown state'}${said ? `: ${said}` : ''}`, status: res.status };
109
+ }
110
+ // ── The answer, delivered (spec 374 §4) ──────────────────────────────────────────────────────────────
111
+ //
112
+ // When a routed ACT finishes at the subject's agent — its steward signed, or refused — the outcome is
113
+ // DELIVERED to the creditor's agent as a message under the same extension URI: a `SubjectAnswerV1` whose
114
+ // `inResponseTo` names the creditor's own correlation. The two payloads share a URI and are told apart
115
+ // by shape (an ask has `request`; an answer has `inResponseTo`), so one metadata key carries both halves
116
+ // of one conversation.
117
+ const isAddr = (v) => typeof v === 'string' && /^0x[0-9a-fA-F]{40}$/.test(v);
118
+ /** The message that delivers a finished routed act's outcome to the creditor's agent. */
119
+ export function subjectAnswerMessage(answer) {
120
+ return {
121
+ messageId: hex32(),
122
+ role: 'ROLE_AGENT',
123
+ parts: [{ text: answer.said ?? (answer.outcome === 'answer' ? 'Done.' : answer.outcome) }],
124
+ extensions: [AP_SUBJECT_ASK_EXTENSION_URI],
125
+ metadata: { [AP_SUBJECT_ASK_EXTENSION_URI]: answer },
126
+ };
127
+ }
128
+ /** The delivered answer a received message carries, structurally checked; null when it carries none. */
129
+ export function subjectAnswerOf(message) {
130
+ const raw = message.metadata?.[AP_SUBJECT_ASK_EXTENSION_URI];
131
+ if (raw === undefined || raw === null || typeof raw !== 'object' || !('inResponseTo' in raw))
132
+ return null;
133
+ const errors = [];
134
+ if (raw.extension !== AP_SUBJECT_ASK_EXTENSION_URI)
135
+ errors.push(`extension: expected ${AP_SUBJECT_ASK_EXTENSION_URI}`);
136
+ if (raw.version !== 1)
137
+ errors.push('version: expected 1');
138
+ if (!isAddr(raw.agent))
139
+ errors.push('agent: an address');
140
+ const r = raw.inResponseTo;
141
+ if (!r || !['operationId', 'runRef', 'stepRef'].every((k) => typeof r[k] === 'string' && r[k]))
142
+ errors.push('inResponseTo: { operationId, runRef, stepRef }');
143
+ if (!['answer', 'refused', 'needs', 'error'].includes(String(raw.outcome)))
144
+ errors.push('outcome: answer | refused | needs | error');
145
+ if (!raw.run || typeof raw.run.runRef !== 'string')
146
+ errors.push('run.runRef: required');
147
+ return errors.length ? { errors } : { answer: raw };
148
+ }
149
+ // ── The hand-off (spec 376) ───────────────────────────────────────────────────────────────────────────
150
+ //
151
+ // One step, run elsewhere under a child mandate. Rides the one wire as a `SendMessage` whose metadata
152
+ // carries the hand-off profile; the specialist answers with the same `subject-answer` artifact a routed
153
+ // ask does, so the parent reads it with the same reader.
154
+ export function handoffMessage(h) {
155
+ return {
156
+ messageId: hex32(),
157
+ role: 'ROLE_USER',
158
+ parts: [{ text: h.intent.goal }],
159
+ extensions: [AP_HANDOFF_EXTENSION_URI],
160
+ metadata: { [AP_HANDOFF_EXTENSION_URI]: h },
161
+ };
162
+ }
163
+ export function handoffOf(message) {
164
+ const raw = message.metadata?.[AP_HANDOFF_EXTENSION_URI];
165
+ if (raw === undefined)
166
+ return null;
167
+ const v = validateHandoff(raw);
168
+ return v.ok ? { handoff: v.handoff } : { errors: v.errors };
169
+ }
170
+ /**
171
+ * Shape a skill's result as the envelope the asker's runtime reads. The `toolId` is the capability the ask named (the
172
+ * asker finds its result by it), else the standard surface's own; the `runRef` is the receiver's run — the one the
173
+ * sender named (`routedRunRefFor`) unless the receiver had its own.
174
+ */
175
+ export function subjectAnswerEnvelope(ask, outcome, opts = {}) {
176
+ const runRef = opts.runRef ?? routedRunRefFor(ask.correlation);
177
+ if (!outcome.ok)
178
+ return { ok: false, runRef, error: outcome.error };
179
+ const toolId = opts.toolId ?? ask.request.capability ?? 'harness.ask';
180
+ return { ok: true, runRef, reply: { kind: 'answer', runRef, text: outcome.text, results: [{ toolId, result: outcome.result }] } };
181
+ }
182
+ /** The artifact a receiver attaches: `subjectEnvelopeOf(task)` on the asker's side reads exactly this back. */
183
+ /** Any `/harness/ask`-shaped envelope rides here unchanged — a harness's own reply (the runtime) or `subjectAnswerEnvelope`'s. */
184
+ export function subjectAnswerArtifact(envelope) {
185
+ return { name: SUBJECT_ANSWER_ARTIFACT, parts: [{ data: envelope }] };
186
+ }
187
+ //# sourceMappingURL=subject-hop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-hop.js","sourceRoot":"","sources":["../src/subject-hop.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,0GAA0G;AAC1G,EAAE;AACF,6GAA6G;AAC7G,sGAAsG;AACtG,yGAAyG;AACzG,gFAAgF;AAChF,EAAE;AACF,4GAA4G;AAC5G,6GAA6G;AAC7G,6GAA6G;AAC7G,6BAA6B;AAC7B,EAAE;AACF,0FAA0F;AAC1F,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAA2C,MAAM,kBAAkB,CAAC;AAC7H,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAkB,MAAM,cAAc,CAAC;AAEzF,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,IAAkG;IAC9H,oGAAoG;IACpG,yFAAyF;IACzF,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,mBAAmB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,KAAK,SAAS,IAAI,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACnP,OAAO,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC;AAC1B,CA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,CAAC"}
@@ -1,14 +1,20 @@
1
1
  import type { Hex } from '@agenticprimitives/types';
2
2
  import type { TaskRecord } from './types.js';
3
- export interface TaskStore {
3
+ import type { MessageIdReservation, MessageIdReserver } from './auth.js';
4
+ export interface TaskStore extends MessageIdReserver {
4
5
  /** Persist (insert or replace) a task record. */
5
6
  put(record: TaskRecord): Promise<void>;
6
7
  /** Load a task record, or null if unknown. */
7
8
  get(taskId: Hex): Promise<TaskRecord | null>;
8
9
  /** Task ids in a non-terminal state that are due for processing (drives the alarm loop). */
9
10
  listDue(now: number): Promise<Hex[]>;
10
- /** Single-use message-id reservation (FR-4.3 inbound replay guard). Returns false if already seen. */
11
- reserveMessageId(messageId: Hex, ttlSec: number): Promise<boolean>;
11
+ /** Every record this store holds, newest first, for enumerating tasks (spec 372 S4 — A2A 1.0's
12
+ * `ListTasks`). Optional: a store that cannot enumerate says so by omitting it, and a caller that
13
+ * needs a list must not pretend an empty one is an answer. */
14
+ list?(limit?: number): Promise<TaskRecord[]>;
15
+ /** Single-use message-id reservation (FR-4.3 inbound replay guard); two-phase per spec 290 §3.
16
+ * Returns `null` if already in-flight/consumed, else a reservation to commit (durable) / release. */
17
+ reserveMessageId(messageId: Hex, ttlSec: number): Promise<MessageIdReservation | null>;
12
18
  }
13
19
  /** Reference in-memory TaskStore — used by the test harness + non-Worker consumers. NOT for production
14
20
  * (no cross-isolate durability); the Cloudflare DO adapter is the durable implementation. */
@@ -1 +1 @@
1
- {"version":3,"file":"task-store.d.ts","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,8CAA8C;IAC9C,GAAG,CAAC,MAA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export function createInMemoryTaskStore() {
19
19
  async listDue() {
20
20
  return [...due];
21
21
  },
22
+ async list(limit) {
23
+ const all = [...tasks.values()].sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
24
+ return limit ? all.slice(0, limit) : all;
25
+ },
22
26
  async reserveMessageId(messageId, ttlSec) {
23
27
  const key = messageId.toLowerCase();
24
- const exp = seen.get(key);
25
- // `now` is injected by callers in tests; here we approximate with a monotonic-free check: a present
26
- // entry means used. (The durable adapter uses KV TTL.)
27
- if (exp !== undefined)
28
- return false;
28
+ // A present entry means in-flight OR consumed — either way a replay (deny). Otherwise mark in-flight.
29
+ // (`now`/TTL is approximate in-memory; the durable adapter uses real storage. Two-phase per §290.3:)
30
+ if (seen.has(key))
31
+ return null;
29
32
  seen.set(key, ttlSec);
30
- return true;
33
+ return {
34
+ async commit() { seen.set(key, ttlSec); }, // stays present → permanently consumed
35
+ async release() { seen.delete(key); }, // free the in-flight slot so a legit retry can re-reserve
36
+ };
31
37
  },
32
38
  };
33
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-store.js","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AAiBA;8FAC8F;AAC9F,MAAM,UAAU,uBAAuB;IACrC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,4BAA4B;IACpE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,MAAM;YACd,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC;YACpD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,C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AM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAM,0DAA0D;aACtG,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { type Delegation, type EnforcerAddressMap } from '@agenticprimitives/delegation';
2
+ import type { Address, Hex } from '@agenticprimitives/types';
3
+ /** A delegation as it arrives over JSON: addresses as strings, the bigint salt as a decimal string. The
4
+ * typed `DelegationWireV1` is assignable to it; an untrusted body is checked here before it becomes one. */
5
+ export interface DelegationWireLike {
6
+ delegator: string;
7
+ delegate: string;
8
+ authority: Hex;
9
+ caveats: {
10
+ enforcer: string;
11
+ terms: Hex;
12
+ args?: Hex;
13
+ }[];
14
+ salt: string;
15
+ signature: Hex;
16
+ }
17
+ export interface WireChecks {
18
+ /** EIP-712 delegation digest. */
19
+ digest: (d: Delegation) => Hex;
20
+ /** ERC-1271 / 6492 / ECDSA against the delegator. */
21
+ erc1271: (signer: Address, digest: Hex, sig: Hex) => Promise<boolean>;
22
+ /** `DelegationManager.isRevoked`. */
23
+ isRevoked: (digest: Hex) => Promise<boolean>;
24
+ }
25
+ /** Wire → `Delegation`. Throws on a salt that is not a number; callers that must not throw catch it. */
26
+ export declare function delegationOfWire(wire: DelegationWireLike): Delegation;
27
+ export declare function verifyDelegationWire(input: {
28
+ wire: DelegationWireLike | undefined;
29
+ expectedDelegator: string;
30
+ expectedDelegate: Address;
31
+ enforcers: EnforcerAddressMap;
32
+ checks: WireChecks;
33
+ now?: number;
34
+ }): Promise<boolean>;
35
+ //# sourceMappingURL=wire-verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-verify.d.ts","sourceRoot":"","sources":["../src/wire-verify.ts"],"names":[],"mappings":"AAaA,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC/G,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE7D;6GAC6G;AAC7G,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,GAAG,CAAC;IAC/B,qDAAqD;IACrD,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,qCAAqC;IACrC,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C;AAED,wGAAwG;AACxG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,UAAU,CASrE;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,OAAO,CAAC,CAwBnB"}
@@ -0,0 +1,51 @@
1
+ // A DELEGATION WIRE, VERIFIED LIVE — the tail every A2A service repeats when a grant arrives over the wire
2
+ // (spec 350 §8; the `service-agent-signing` rule). Promoted from the runtime app in spec 399 W0 (§4), where
3
+ // four call sites had each written it: delegator/delegate identity, caveat evaluation, revocation, signature.
4
+ //
5
+ // WHAT THIS DECIDES AND WHAT IT DOES NOT. `delegation.verifyLiveDelegation` decides all of it — this is the
6
+ // wire-shaped door to that one decision. It says the wire is live and authentic FROM `expectedDelegator` TO
7
+ // `expectedDelegate`; it says nothing about whether the caveat SHAPE is the one the caller's policy wants
8
+ // (member access vs stewardship, which contracts a wire must pin). That is the product's authorization
9
+ // policy — a positive identity test no generic "required enforcers" list can express. Call this AFTER the
10
+ // shape test, never instead of it.
11
+ //
12
+ // Returns false on every failure path — the callers are boolean gates and must not learn why (the reason
13
+ // would tell a prober which of several wires it is missing).
14
+ import { verifyLiveDelegation } from '@agenticprimitives/delegation';
15
+ /** Wire → `Delegation`. Throws on a salt that is not a number; callers that must not throw catch it. */
16
+ export function delegationOfWire(wire) {
17
+ return {
18
+ delegator: wire.delegator,
19
+ delegate: wire.delegate,
20
+ authority: wire.authority,
21
+ caveats: wire.caveats.map((c) => ({ enforcer: c.enforcer, terms: c.terms, args: (c.args ?? '0x') })),
22
+ salt: BigInt(wire.salt),
23
+ signature: wire.signature,
24
+ };
25
+ }
26
+ export async function verifyDelegationWire(input) {
27
+ const w = input.wire;
28
+ if (!w?.signature || !w.delegator || !w.delegate)
29
+ return false;
30
+ let delegation;
31
+ try {
32
+ delegation = delegationOfWire(w);
33
+ }
34
+ catch {
35
+ return false; // BigInt(salt) on garbage
36
+ }
37
+ const r = await verifyLiveDelegation({
38
+ delegation,
39
+ expectedDelegator: input.expectedDelegator,
40
+ expectedDelegate: input.expectedDelegate,
41
+ enforcers: input.enforcers,
42
+ now: input.now ?? Math.floor(Date.now() / 1000),
43
+ checks: {
44
+ delegationDigest: input.checks.digest,
45
+ isRevoked: async (d) => input.checks.isRevoked(input.checks.digest(d)),
46
+ verifySignature: async ({ signer, digest, signature }) => input.checks.erc1271(signer, digest, signature),
47
+ },
48
+ });
49
+ return r.ok;
50
+ }
51
+ //# sourceMappingURL=wire-verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-verify.js","source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C,GAAG,MAAM,oBAAoB,CAAC;QACnC,UAAU;QACV,iBAAiB,EAAE,KAAK,CAAC,iBAA4B;QACrD,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAC/C,MAAM,EAAE;YACN,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;YACrC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACtE,eAAe,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;SAC1G;KACF,CAAC,CAAC;IACH,OAAO,CAAC,CAAC,EAAE,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@agenticprimitives/a2a",
3
- "version": "0.0.0-alpha.4",
3
+ "version": "0.0.0-alpha.40",
4
4
  "description": "Async, delegation-authorized Agent-to-Agent (A2A) task transport: Task/Message/Artifact runtime over a TaskStore port, JSON-RPC method handlers, SkillHandler dispatch, the A2aWireAdapter client, and scoped-grant caveat builders. Transport-agnostic core (spec 269 / ADR-0034); the Cloudflare TaskStoreDO ships as the ./cloudflare adapter subpath.",
5
+ "homepage": "https://agenticprimitives.dev",
6
+ "bugs": {
7
+ "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
8
+ },
9
+ "author": {
10
+ "name": "Agentic Trust Labs",
11
+ "url": "https://agenticprimitives.dev"
12
+ },
5
13
  "license": "MIT",
6
14
  "repository": {
7
15
  "type": "git",
8
16
  "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
9
17
  "directory": "packages/a2a"
10
18
  },
11
- "homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/a2a",
12
- "bugs": {
13
- "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
14
- },
15
19
  "type": "module",
16
20
  "main": "./dist/index.js",
17
21
  "types": "./dist/index.d.ts",
@@ -23,6 +27,14 @@
23
27
  "./cloudflare": {
24
28
  "types": "./dist/cloudflare/index.d.ts",
25
29
  "import": "./dist/cloudflare/index.js"
30
+ },
31
+ "./standard": {
32
+ "types": "./dist/standard/index.d.ts",
33
+ "import": "./dist/standard/index.js"
34
+ },
35
+ "./conform": {
36
+ "types": "./dist/conform/index.d.ts",
37
+ "import": "./dist/conform/index.js"
26
38
  }
27
39
  },
28
40
  "files": [
@@ -30,7 +42,8 @@
30
42
  "dist",
31
43
  "spec.md",
32
44
  "README.md",
33
- "CLAUDE.md"
45
+ "CLAUDE.md",
46
+ "bin"
34
47
  ],
35
48
  "publishConfig": {
36
49
  "access": "public"
@@ -41,7 +54,7 @@
41
54
  "devDependencies": {
42
55
  "@cloudflare/workers-types": "^4.20240117.0",
43
56
  "@types/node": "^22.7.0",
44
- "vitest": "^4.1.8"
57
+ "vitest": "^4.1.11"
45
58
  },
46
59
  "keywords": [
47
60
  "a2a",
@@ -49,12 +62,21 @@
49
62
  "task",
50
63
  "delegation",
51
64
  "jsonrpc",
52
- "agentic"
65
+ "agentic",
66
+ "agentic-primitives",
67
+ "agenticprimitives",
68
+ "ai-agents",
69
+ "agent-authority",
70
+ "agentic-trust"
53
71
  ],
54
72
  "dependencies": {
55
- "@agenticprimitives/fulfillment": "0.0.0-alpha.5",
56
- "@agenticprimitives/delegation": "1.0.0-alpha.8",
57
- "@agenticprimitives/types": "1.0.0-alpha.8"
73
+ "@agenticprimitives/delegation": "1.0.0-alpha.39",
74
+ "@agenticprimitives/fulfillment": "0.0.0-alpha.36",
75
+ "@agenticprimitives/types": "1.0.0-alpha.39",
76
+ "@agenticprimitives/verification-receipts": "0.0.0-alpha.16"
77
+ },
78
+ "bin": {
79
+ "a2a-conform": "./bin/a2a-conform.mjs"
58
80
  },
59
81
  "scripts": {
60
82
  "build": "tsc -p tsconfig.build.json",
@@ -62,6 +84,7 @@
62
84
  "test": "vitest run",
63
85
  "test:unit": "vitest run --passWithNoTests",
64
86
  "test:watch": "vitest",
65
- "clean": "rm -rf dist"
87
+ "clean": "rm -rf dist",
88
+ "tck:sut": "tsx tck/sut.mts"
66
89
  }
67
90
  }
package/dist/jsonrpc.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import type { A2aAgent } from './agent.js';
2
- export interface JsonRpcRequest {
3
- jsonrpc?: string;
4
- id?: string | number | null;
5
- method?: string;
6
- params?: unknown;
7
- }
8
- export type JsonRpcResponse = {
9
- jsonrpc: '2.0';
10
- id: string | number | null;
11
- result: unknown;
12
- } | {
13
- jsonrpc: '2.0';
14
- id: string | number | null;
15
- error: {
16
- code: number;
17
- message: string;
18
- };
19
- };
20
- /** Dispatch a single JSON-RPC request to the agent. `message/stream` is rejected here (handled by the
21
- * SSE transport). The `caller` for tasks/get|cancel is taken from `params.caller`. */
22
- export declare function dispatchA2aRpc(agent: A2aAgent, req: JsonRpcRequest): Promise<JsonRpcResponse>;
23
- /** Parse a raw JSON body + dispatch. Used by the HTTP/Cloudflare transport. */
24
- export declare function handleA2aRpcBody(agent: A2aAgent, rawBody: string): Promise<JsonRpcResponse>;
25
- //# sourceMappingURL=jsonrpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAqC,MAAM,YAAY,CAAC;AAE9E,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AACD,MAAM,MAAM,eAAe,GACvB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC/D;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAS7F;uFACuF;AACvF,wBAAsB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAiCnG;AAED,+EAA+E;AAC/E,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAIjG"}
package/dist/jsonrpc.js DELETED
@@ -1,52 +0,0 @@
1
- const PARSE_ERROR = -32700;
2
- const INVALID_REQUEST = -32600;
3
- const METHOD_NOT_FOUND = -32601;
4
- const err = (id, code, message) => ({ jsonrpc: '2.0', id, error: { code, message } });
5
- const ok = (id, result) => ({ jsonrpc: '2.0', id, result });
6
- /** Dispatch a single JSON-RPC request to the agent. `message/stream` is rejected here (handled by the
7
- * SSE transport). The `caller` for tasks/get|cancel is taken from `params.caller`. */
8
- export async function dispatchA2aRpc(agent, req) {
9
- const id = req.id ?? null;
10
- if (req.jsonrpc !== '2.0' || typeof req.method !== 'string') {
11
- return err(id, INVALID_REQUEST, 'not a JSON-RPC 2.0 request');
12
- }
13
- const p = (req.params ?? {});
14
- switch (req.method) {
15
- case 'message/send': {
16
- const r = await agent.messageSend(p);
17
- return r.ok ? ok(id, r.result) : err(id, r.code, r.message);
18
- }
19
- case 'tasks/resubmit': {
20
- const r = await agent.resubmit(p);
21
- return r.ok ? ok(id, r.result) : err(id, r.code, r.message);
22
- }
23
- case 'tasks/get': {
24
- const r = await agent.tasksGet({ taskId: p.taskId, caller: p.caller });
25
- return r.ok ? ok(id, r.result) : err(id, r.code, r.message);
26
- }
27
- case 'tasks/cancel': {
28
- const r = await agent.tasksCancel({ taskId: p.taskId, caller: p.caller });
29
- return r.ok ? ok(id, r.result) : err(id, r.code, r.message);
30
- }
31
- case 'tasks/pushNotificationConfig/set': {
32
- const r = await agent.pushConfigSet({ taskId: p.taskId, caller: p.caller, url: p.url, token: p.token });
33
- return r.ok ? ok(id, r.result) : err(id, r.code, r.message);
34
- }
35
- case 'message/stream':
36
- return err(id, INVALID_REQUEST, 'message/stream must use the SSE transport, not the JSON-RPC body');
37
- default:
38
- return err(id, METHOD_NOT_FOUND, `unknown method: ${req.method}`);
39
- }
40
- }
41
- /** Parse a raw JSON body + dispatch. Used by the HTTP/Cloudflare transport. */
42
- export async function handleA2aRpcBody(agent, rawBody) {
43
- let req;
44
- try {
45
- req = JSON.parse(rawBody);
46
- }
47
- catch {
48
- return err(null, PARSE_ERROR, 'invalid JSON');
49
- }
50
- return dispatchA2aRpc(agent, req);
51
- }
52
- //# sourceMappingURL=jsonrpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,KAAK,CAAC;AAC/B,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC;AAEhC,MAAM,GAAG,GAAG,CAAC,EAA0B,EAAE,IAAY,EAAE,OAAe,EAAmB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC/I,MAAM,EAAE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