@agenticprimitives/a2a 0.0.0-alpha.2 → 0.0.0-alpha.20
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.
- package/CLAUDE.md +58 -21
- package/bin/a2a-conform.mjs +17 -0
- package/dist/agent.d.ts +171 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +346 -62
- package/dist/agent.js.map +1 -1
- package/dist/auth.d.ts +72 -9
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +62 -19
- package/dist/auth.js.map +1 -1
- package/dist/authority-extension.d.ts +58 -0
- package/dist/authority-extension.d.ts.map +1 -0
- package/dist/authority-extension.js +70 -0
- package/dist/authority-extension.js.map +1 -0
- package/dist/card-audience.d.ts +87 -0
- package/dist/card-audience.d.ts.map +1 -0
- package/dist/card-audience.js +135 -0
- package/dist/card-audience.js.map +1 -0
- package/dist/client.d.ts +20 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +69 -14
- package/dist/client.js.map +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +10 -2
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/conform/index.d.ts +36 -0
- package/dist/conform/index.d.ts.map +1 -0
- package/dist/conform/index.js +232 -0
- package/dist/conform/index.js.map +1 -0
- package/dist/discovery.d.ts +4 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +6 -2
- package/dist/discovery.js.map +1 -1
- package/dist/engagement.d.ts +37 -0
- package/dist/engagement.d.ts.map +1 -0
- package/dist/engagement.js +83 -0
- package/dist/engagement.js.map +1 -0
- package/dist/grant.d.ts +4 -2
- package/dist/grant.d.ts.map +1 -1
- package/dist/grant.js +21 -13
- package/dist/grant.js.map +1 -1
- package/dist/handoff.d.ts +42 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +28 -0
- package/dist/handoff.js.map +1 -0
- package/dist/index.d.ts +24 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/payment-gate.d.ts +88 -0
- package/dist/payment-gate.d.ts.map +1 -0
- package/dist/payment-gate.js +47 -0
- package/dist/payment-gate.js.map +1 -0
- package/dist/runtime.d.ts +13 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +35 -10
- package/dist/runtime.js.map +1 -1
- package/dist/session-wire.d.ts +69 -0
- package/dist/session-wire.d.ts.map +1 -0
- package/dist/session-wire.js +170 -0
- package/dist/session-wire.js.map +1 -0
- package/dist/skill-handler.d.ts +26 -1
- package/dist/skill-handler.d.ts.map +1 -1
- package/dist/skill-handler.js.map +1 -1
- package/dist/standard/caller.d.ts +86 -0
- package/dist/standard/caller.d.ts.map +1 -0
- package/dist/standard/caller.js +159 -0
- package/dist/standard/caller.js.map +1 -0
- package/dist/standard/client.d.ts +50 -0
- package/dist/standard/client.d.ts.map +1 -0
- package/dist/standard/client.js +86 -0
- package/dist/standard/client.js.map +1 -0
- package/dist/standard/delegated.d.ts +119 -0
- package/dist/standard/delegated.d.ts.map +1 -0
- package/dist/standard/delegated.js +168 -0
- package/dist/standard/delegated.js.map +1 -0
- package/dist/standard/errors.d.ts +31 -0
- package/dist/standard/errors.d.ts.map +1 -0
- package/dist/standard/errors.js +75 -0
- package/dist/standard/errors.js.map +1 -0
- package/dist/standard/from-agent.d.ts +38 -0
- package/dist/standard/from-agent.d.ts.map +1 -0
- package/dist/standard/from-agent.js +109 -0
- package/dist/standard/from-agent.js.map +1 -0
- package/dist/standard/index.d.ts +9 -0
- package/dist/standard/index.d.ts.map +1 -0
- package/dist/standard/index.js +13 -0
- package/dist/standard/index.js.map +1 -0
- package/dist/standard/mount.d.ts +91 -0
- package/dist/standard/mount.d.ts.map +1 -0
- package/dist/standard/mount.js +181 -0
- package/dist/standard/mount.js.map +1 -0
- package/dist/standard/server.d.ts +105 -0
- package/dist/standard/server.d.ts.map +1 -0
- package/dist/standard/server.js +454 -0
- package/dist/standard/server.js.map +1 -0
- package/dist/standard/types.d.ts +186 -0
- package/dist/standard/types.d.ts.map +1 -0
- package/dist/standard/types.js +14 -0
- package/dist/standard/types.js.map +1 -0
- package/dist/subject-ask.d.ts +96 -0
- package/dist/subject-ask.d.ts.map +1 -0
- package/dist/subject-ask.js +45 -0
- package/dist/subject-ask.js.map +1 -0
- package/dist/subject-hop.d.ts +75 -0
- package/dist/subject-hop.d.ts.map +1 -0
- package/dist/subject-hop.js +170 -0
- package/dist/subject-hop.js.map +1 -0
- package/dist/task-store.d.ts +9 -3
- package/dist/task-store.d.ts.map +1 -1
- package/dist/task-store.js +12 -6
- package/dist/task-store.js.map +1 -1
- package/dist/wire-verify.d.ts +35 -0
- package/dist/wire-verify.d.ts.map +1 -0
- package/dist/wire-verify.js +51 -0
- package/dist/wire-verify.js.map +1 -0
- package/package.json +20 -6
- package/dist/jsonrpc.d.ts +0 -25
- package/dist/jsonrpc.d.ts.map +0 -1
- package/dist/jsonrpc.js +0 -52
- package/dist/jsonrpc.js.map +0 -1
package/dist/task-store.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { Hex } from '@agenticprimitives/types';
|
|
2
2
|
import type { TaskRecord } from './types.js';
|
|
3
|
-
|
|
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
|
-
/**
|
|
11
|
-
|
|
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. */
|
package/dist/task-store.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEzE,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IAClD,iDAAiD;IACjD,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,8CAA8C;IAC9C,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC7C,4FAA4F;IAC5F,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC;;mEAE+D;IAC/D,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7C;0GACsG;IACtG,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;CACxF;AAED;8FAC8F;AAC9F,wBAAgB,uBAAuB,IAAI,SAAS,CAiCnD"}
|
package/dist/task-store.js
CHANGED
|
@@ -19,15 +19,21 @@ 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
|
-
|
|
25
|
-
// `now
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
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
|
}
|
package/dist/task-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-store.js","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task-store.js","sourceRoot":"","sources":["../src/task-store.ts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AC,GAAG,CAAC;QAC3C,CAAC;QACD,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM;YACtC,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACpC,sGAAsG;YACtG,qGAAqG;YACrG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACtB,OAAO;gBACL,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,uCAAuC;gBAClF,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,MAAM,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","sourceRoot":"","sources":["../src/wire-verify.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,4GAA4G;AAC5G,8GAA8G;AAC9G,EAAE;AACF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AK,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticprimitives/a2a",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.20",
|
|
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
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,6 +23,14 @@
|
|
|
23
23
|
"./cloudflare": {
|
|
24
24
|
"types": "./dist/cloudflare/index.d.ts",
|
|
25
25
|
"import": "./dist/cloudflare/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./standard": {
|
|
28
|
+
"types": "./dist/standard/index.d.ts",
|
|
29
|
+
"import": "./dist/standard/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./conform": {
|
|
32
|
+
"types": "./dist/conform/index.d.ts",
|
|
33
|
+
"import": "./dist/conform/index.js"
|
|
26
34
|
}
|
|
27
35
|
},
|
|
28
36
|
"files": [
|
|
@@ -30,7 +38,8 @@
|
|
|
30
38
|
"dist",
|
|
31
39
|
"spec.md",
|
|
32
40
|
"README.md",
|
|
33
|
-
"CLAUDE.md"
|
|
41
|
+
"CLAUDE.md",
|
|
42
|
+
"bin"
|
|
34
43
|
],
|
|
35
44
|
"publishConfig": {
|
|
36
45
|
"access": "public"
|
|
@@ -52,9 +61,13 @@
|
|
|
52
61
|
"agentic"
|
|
53
62
|
],
|
|
54
63
|
"dependencies": {
|
|
55
|
-
"@agenticprimitives/
|
|
56
|
-
"@agenticprimitives/
|
|
57
|
-
"@agenticprimitives/
|
|
64
|
+
"@agenticprimitives/delegation": "1.0.0-alpha.23",
|
|
65
|
+
"@agenticprimitives/fulfillment": "0.0.0-alpha.20",
|
|
66
|
+
"@agenticprimitives/types": "1.0.0-alpha.23",
|
|
67
|
+
"@agenticprimitives/verification-receipts": "0.0.0-alpha.4"
|
|
68
|
+
},
|
|
69
|
+
"bin": {
|
|
70
|
+
"a2a-conform": "./bin/a2a-conform.mjs"
|
|
58
71
|
},
|
|
59
72
|
"scripts": {
|
|
60
73
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -62,6 +75,7 @@
|
|
|
62
75
|
"test": "vitest run",
|
|
63
76
|
"test:unit": "vitest run --passWithNoTests",
|
|
64
77
|
"test:watch": "vitest",
|
|
65
|
-
"clean": "rm -rf dist"
|
|
78
|
+
"clean": "rm -rf dist",
|
|
79
|
+
"tck:sut": "tsx tck/sut.mts"
|
|
66
80
|
}
|
|
67
81
|
}
|
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
|
package/dist/jsonrpc.d.ts.map
DELETED
|
@@ -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
|
package/dist/jsonrpc.js.map
DELETED
|
@@ -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,CAA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