@agenticprimitives/a2a 0.0.0-alpha.5 → 0.0.0-alpha.50
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 +39 -55
- package/README.md +44 -1
- package/bin/a2a-conform.mjs +17 -0
- package/dist/agent.d.ts +203 -7
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +586 -76
- package/dist/agent.js.map +1 -1
- package/dist/auth.d.ts +84 -11
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +94 -20
- 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 +23 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +76 -13
- 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 +247 -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 +30 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -5
- package/dist/index.js.map +1 -1
- package/dist/payment-gate.d.ts +69 -3
- package/dist/payment-gate.d.ts.map +1 -1
- package/dist/payment-gate.js +36 -5
- package/dist/payment-gate.js.map +1 -1
- package/dist/placeholder.d.ts +5 -0
- package/dist/placeholder.d.ts.map +1 -0
- package/dist/placeholder.js +10 -0
- package/dist/placeholder.js.map +1 -0
- package/dist/run-provenance-extension.d.ts +22 -0
- package/dist/run-provenance-extension.d.ts.map +1 -0
- package/dist/run-provenance-extension.js +23 -0
- package/dist/run-provenance-extension.js.map +1 -0
- package/dist/runtime.d.ts +13 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +62 -16
- package/dist/runtime.js.map +1 -1
- package/dist/session-wire.d.ts +114 -0
- package/dist/session-wire.d.ts.map +1 -0
- package/dist/session-wire.js +292 -0
- package/dist/session-wire.js.map +1 -0
- package/dist/skill-handler.d.ts +21 -1
- package/dist/skill-handler.d.ts.map +1 -1
- package/dist/skill-handler.js.map +1 -1
- package/dist/standard/app-delegation.d.ts +60 -0
- package/dist/standard/app-delegation.d.ts.map +1 -0
- package/dist/standard/app-delegation.js +43 -0
- package/dist/standard/app-delegation.js.map +1 -0
- package/dist/standard/caller.d.ts +115 -0
- package/dist/standard/caller.d.ts.map +1 -0
- package/dist/standard/caller.js +186 -0
- package/dist/standard/caller.js.map +1 -0
- package/dist/standard/client.d.ts +64 -0
- package/dist/standard/client.d.ts.map +1 -0
- package/dist/standard/client.js +109 -0
- package/dist/standard/client.js.map +1 -0
- package/dist/standard/delegated.d.ts +127 -0
- package/dist/standard/delegated.d.ts.map +1 -0
- package/dist/standard/delegated.js +179 -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 +43 -0
- package/dist/standard/from-agent.d.ts.map +1 -0
- package/dist/standard/from-agent.js +149 -0
- package/dist/standard/from-agent.js.map +1 -0
- package/dist/standard/index.d.ts +12 -0
- package/dist/standard/index.d.ts.map +1 -0
- package/dist/standard/index.js +18 -0
- package/dist/standard/index.js.map +1 -0
- package/dist/standard/mount.d.ts +101 -0
- package/dist/standard/mount.d.ts.map +1 -0
- package/dist/standard/mount.js +186 -0
- package/dist/standard/mount.js.map +1 -0
- package/dist/standard/outbound-fetch.d.ts +51 -0
- package/dist/standard/outbound-fetch.d.ts.map +1 -0
- package/dist/standard/outbound-fetch.js +152 -0
- package/dist/standard/outbound-fetch.js.map +1 -0
- package/dist/standard/push-url-policy.d.ts +34 -0
- package/dist/standard/push-url-policy.d.ts.map +1 -0
- package/dist/standard/push-url-policy.js +218 -0
- package/dist/standard/push-url-policy.js.map +1 -0
- package/dist/standard/server.d.ts +150 -0
- package/dist/standard/server.d.ts.map +1 -0
- package/dist/standard/server.js +575 -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 +142 -0
- package/dist/subject-ask.d.ts.map +1 -0
- package/dist/subject-ask.js +137 -0
- package/dist/subject-ask.js.map +1 -0
- package/dist/subject-hop.d.ts +156 -0
- package/dist/subject-hop.d.ts.map +1 -0
- package/dist/subject-hop.js +276 -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/types.d.ts +27 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.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 +55 -0
- package/dist/wire-verify.js.map +1 -0
- package/package.json +35 -12
- 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/runtime.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { canTaskTransition, isHandoffAllowed } from '@agenticprimitives/fulfillment';
|
|
7
7
|
import { isTerminal } from './types.js';
|
|
8
8
|
import { AuthRequired, HandoffRequested } from './skill-handler.js';
|
|
9
|
+
import { gateSkillPayment, samePaymentTerms } from './payment-gate.js';
|
|
9
10
|
/** Build a fresh `submitted` task record from a verified inbound message + grant. */
|
|
10
11
|
export function newTaskRecord(args) {
|
|
11
12
|
return {
|
|
@@ -49,15 +50,12 @@ export function applyTransition(record, to, opts = { now: 0 }) {
|
|
|
49
50
|
};
|
|
50
51
|
return { ok: true, record: next, event: { kind: 'task.status', taskId: record.task.taskId, state: to, rev } };
|
|
51
52
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Dispatch a `submitted` task: reject if the skill is unknown; otherwise move it to `working`, run the
|
|
54
|
-
* handler, and map the outcome to the next state. Returns the final record + the ordered events. The
|
|
55
|
-
* caller (alarm loop) persists the record and fans the events to streams/push. `makeContext` wires the
|
|
56
|
-
* per-task vault / mcp / emitArtifact (W4) — the runtime stays transport-agnostic.
|
|
57
|
-
*/
|
|
58
53
|
export async function dispatchTask(record, registry, makeContext, now, opts) {
|
|
59
54
|
const events = [];
|
|
60
|
-
|
|
55
|
+
// Spec 445 decision 8 — a payment-parked task RESUMES here: `settlePayment` moved it input-required → working with a
|
|
56
|
+
// verified settlement for exactly what it awaited. Any other `working` record is not ours to run.
|
|
57
|
+
const resumingPaid = record.task.state === 'working' && isSettledForPark(record);
|
|
58
|
+
if (record.task.state !== 'submitted' && !resumingPaid) {
|
|
61
59
|
return { record, events };
|
|
62
60
|
}
|
|
63
61
|
const handler = registry.get(record.skill);
|
|
@@ -69,12 +67,49 @@ export async function dispatchTask(record, registry, makeContext, now, opts) {
|
|
|
69
67
|
}
|
|
70
68
|
return { record, events };
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
let cur;
|
|
71
|
+
if (resumingPaid) {
|
|
72
|
+
cur = record;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const working = applyTransition(record, 'working', { now });
|
|
76
|
+
if (!working.ok)
|
|
77
|
+
return { record, events };
|
|
78
|
+
cur = working.record;
|
|
79
|
+
events.push(working.event);
|
|
80
|
+
}
|
|
77
81
|
const base = makeContext(cur);
|
|
82
|
+
// A2A-5 (seam audit): a PRICED skill is gated BEFORE its handler runs. Previously the gate was declared
|
|
83
|
+
// + exported but NEVER invoked, so priced skills executed for free. gateSkillPayment now runs here; on
|
|
84
|
+
// not-satisfied the task parks `input-required` (a legal working→input-required transition) and the
|
|
85
|
+
// handler is NOT run (fail-closed). A free skill (no `payment`) proceeds unchanged. The construction
|
|
86
|
+
// guard in createA2aAgent additionally forbids registering a priced handler with no gate wired.
|
|
87
|
+
// Spec 445 decision 8 — PAID ALREADY: the task carries a verified settlement for its own park whose terms are the
|
|
88
|
+
// skill's price now. It runs ungated (the settlement was consumed once, in `settlePayment`). A price that changed
|
|
89
|
+
// since the park is gated afresh — the settlement paid for the old terms, not these.
|
|
90
|
+
const paidForThisPrice = !!handler.payment && isSettledForPark(cur) && samePaymentTerms({ amount: handler.payment.price.amount, asset: handler.payment.price.asset, payee: handler.payment.payee }, cur.awaitingPayment, { reference: false }) && handler.payment.rail === cur.awaitingPayment.rail;
|
|
91
|
+
if (handler.payment && !paidForThisPrice) {
|
|
92
|
+
const gated = await gateSkillPayment({
|
|
93
|
+
payment: handler.payment,
|
|
94
|
+
gate: opts?.paymentGate,
|
|
95
|
+
skill: cur.skill,
|
|
96
|
+
message: cur.inbound[cur.inbound.length - 1],
|
|
97
|
+
payload: base.input,
|
|
98
|
+
entitlementRef: opts?.entitlementRef,
|
|
99
|
+
});
|
|
100
|
+
if (!gated.proceed) {
|
|
101
|
+
const parked = applyTransition(cur, 'input-required', { now });
|
|
102
|
+
if (parked.ok) {
|
|
103
|
+
events.push(parked.event);
|
|
104
|
+
// RUNB-6 — what to pay is KEPT on the record (it was computed and dropped, so a parked client could
|
|
105
|
+
// not learn the price).
|
|
106
|
+
// Spec 445 decision 8 — and EXACTLY what it waits for, under a fresh reference; an older settlement is void.
|
|
107
|
+
const { paymentSettlement: _void, ...rest } = parked.record;
|
|
108
|
+
return { record: { ...rest, payment: gated.parkMetadata, awaitingPayment: gated.awaited }, events };
|
|
109
|
+
}
|
|
110
|
+
return { record: cur, events };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
78
113
|
const ctx = {
|
|
79
114
|
...base,
|
|
80
115
|
taskId: cur.task.taskId,
|
|
@@ -104,10 +139,16 @@ export async function dispatchTask(record, registry, makeContext, now, opts) {
|
|
|
104
139
|
// FR-3.6 / FLF-INV-09 — gate the reassignment on the agent's HandoffPolicy + the hop budget;
|
|
105
140
|
// fail-closed: no policy, a disallowed target, or an exhausted hop budget rejects the task.
|
|
106
141
|
const req = e.request;
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
142
|
+
const priorHops = cur.hopCount ?? 0;
|
|
143
|
+
const hops = priorHops + 1;
|
|
144
|
+
// NEW-FLF-1: isHandoffAllowed now enforces the full HandoffPolicy (target/class, scopes, hop
|
|
145
|
+
// budget, approval, privacy tier). We pass the current (pre-handoff) hop count so it gates the
|
|
146
|
+
// maxHopCount cap itself; the external hop comparison is gone.
|
|
147
|
+
const ok = !!opts?.handoffPolicy
|
|
148
|
+
&& isHandoffAllowed(opts.handoffPolicy, req.target, {
|
|
149
|
+
targetClass: req.targetClass,
|
|
150
|
+
hopCount: priorHops,
|
|
151
|
+
});
|
|
111
152
|
if (!ok) {
|
|
112
153
|
// The handler is mid-processing (`working`), so the illegal handoff fails the task (working→failed;
|
|
113
154
|
// working→rejected is not a legal transition). Fail-closed.
|
|
@@ -150,5 +191,10 @@ export async function dispatchTask(record, registry, makeContext, now, opts) {
|
|
|
150
191
|
events.push(t.event);
|
|
151
192
|
return { record: cur, events };
|
|
152
193
|
}
|
|
194
|
+
/** The task carries a settlement for its own (latest) park. */
|
|
195
|
+
function isSettledForPark(r) {
|
|
196
|
+
return !!r.paymentSettlement && !!r.awaitingPayment
|
|
197
|
+
&& r.paymentSettlement.reference.toLowerCase() === r.awaitingPayment.reference.toLowerCase();
|
|
198
|
+
}
|
|
153
199
|
export { isTerminal };
|
|
154
200
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,wGAAwG;AACxG,wGAAwG;AACxG,0GAA0G;AAC1G,4GAA4G;AAC5G,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAsB,MAAM,gCAAgC,CAAC;AAIzG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAA0D,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,wGAAwG;AACxG,wGAAwG;AACxG,0GAA0G;AAC1G,4GAA4G;AAC5G,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAsB,MAAM,gCAAgC,CAAC;AAIzG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAA0D,MAAM,oBAAoB,CAAC;AAC5H,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAEzF,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,IAc7B;IACC,OAAO;QACL,IAAI,EAAE;YACJ,MAAM,EAAE,IAAI,CAAC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DAA+D;AAC/D,SAAS,gBAAgB,CAAC,CAAa;IACrC,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe;WAC9C,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;AACjG,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import { type Delegation } from '@agenticprimitives/delegation';
|
|
3
|
+
/** The JSON-safe form of a delegation as it travels (bigint salt as a string). */
|
|
4
|
+
export interface DelegationWireV1 {
|
|
5
|
+
delegator: Address;
|
|
6
|
+
delegate: Address;
|
|
7
|
+
authority: Hex;
|
|
8
|
+
caveats: Array<{
|
|
9
|
+
enforcer: Address;
|
|
10
|
+
terms: Hex;
|
|
11
|
+
args?: Hex;
|
|
12
|
+
}>;
|
|
13
|
+
salt: string;
|
|
14
|
+
signature: Hex;
|
|
15
|
+
}
|
|
16
|
+
/** Signature type byte for the session-wrapped form. Unknown to AgentAccount `_validateSig` (fails closed
|
|
17
|
+
* on chain) and to every other verifier — only a gate that calls `verifySessionWrappedSignature` accepts
|
|
18
|
+
* it, and only after full verification. */
|
|
19
|
+
export declare const SESSION_WRAPPED_SIG_TYPE = "0x51";
|
|
20
|
+
/** Wrap a raw session-key ECDSA signature with the wire that authorizes it. */
|
|
21
|
+
export declare function wrapSessionSignature(wire: DelegationWireV1, sig: Hex): Hex;
|
|
22
|
+
/** Parse the session-wrapped form; null for any other signature shape (callers then use the standard
|
|
23
|
+
* ERC-1271 path — one detector, no ambiguity). */
|
|
24
|
+
export declare function parseSessionWrappedSignature(signature: string): {
|
|
25
|
+
wire: DelegationWireV1;
|
|
26
|
+
sig: Hex;
|
|
27
|
+
} | null;
|
|
28
|
+
export declare function wireToDelegation(w: DelegationWireV1): Delegation;
|
|
29
|
+
export declare function delegationToWire(d: Delegation): DelegationWireV1;
|
|
30
|
+
/** The enforcer addresses a session wire's caveats are read by (this deployment's). All three are required:
|
|
31
|
+
* a verifier that cannot read the target caveat cannot tell which host the wire was minted for. */
|
|
32
|
+
export interface SessionWireEnforcers {
|
|
33
|
+
timestamp: string;
|
|
34
|
+
allowedMethods: string;
|
|
35
|
+
allowedTargets: string;
|
|
36
|
+
}
|
|
37
|
+
/** RUNB-17 (spec 445 §9 decision 8) — a caveat beyond the three this verifier reads, which the verifier RECOGNISES
|
|
38
|
+
* because it enforces it: `check` runs on the caveat's terms and returns null when it holds, else why not. A caveat
|
|
39
|
+
* whose enforcer is neither one of the three nor listed here is refused — never "permissive by omission". */
|
|
40
|
+
export interface SessionWireCaveatCheck {
|
|
41
|
+
enforcer: string;
|
|
42
|
+
check: (terms: Hex, ctx: {
|
|
43
|
+
nowSec: number;
|
|
44
|
+
target: string;
|
|
45
|
+
skill?: string;
|
|
46
|
+
}) => string | null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Shape check for a session wire (at ceremony store time AND at every gate hit): timestamp-bounded, an
|
|
50
|
+
* allowedTargets caveat that names `target` — THIS host's own agent — and a pinned allowedMethods set that
|
|
51
|
+
* never carries the any-skill sentinel and, when `skill` is given, names that skill's selector.
|
|
52
|
+
*
|
|
53
|
+
* `target` is REQUIRED (RUN-9, audit 2026-11-10). The custodian signs a wire for one receiving agent; the
|
|
54
|
+
* verifier is the only party that knows which agent it is, so it says so, and the wire must agree. A wire
|
|
55
|
+
* with no allowedTargets caveat is refused: "minted for nowhere in particular" was being read as "valid
|
|
56
|
+
* everywhere". There is no default and no wildcard — a verifier with no identity to offer refuses every wire.
|
|
57
|
+
*
|
|
58
|
+
* `skill` should be passed wherever the request names one: a wire minted for one rail must not authorize
|
|
59
|
+
* another. It is omitted only on the read/control path (`tasks/get`, `tasks/cancel`,
|
|
60
|
+
* `pushNotificationConfig/set`), whose digest binds a method and a taskId, not a skill. That omission is
|
|
61
|
+
* narrow rather than lax — the wire must still be pinned, live, ERC-1271-valid and unrevoked, and the task
|
|
62
|
+
* runtime independently requires the caller to BE a party to the task.
|
|
63
|
+
*/
|
|
64
|
+
export declare function checkSessionWireShape(wire: DelegationWireV1, enforcers: SessionWireEnforcers, nowSec: number, opts: {
|
|
65
|
+
target: string;
|
|
66
|
+
skill?: string;
|
|
67
|
+
recognisedCaveats?: readonly SessionWireCaveatCheck[];
|
|
68
|
+
}): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Verify a session-wrapped signature for `signer` over `digest`, fail-closed on every leg. The on-chain
|
|
71
|
+
* checks are the SAME injected ones the standard gate uses (`OnChainChecks`) — revocation is immediate.
|
|
72
|
+
* Pass `skill` whenever the request names one.
|
|
73
|
+
*/
|
|
74
|
+
export declare function verifySessionWrappedSignature(args: {
|
|
75
|
+
signer: Address;
|
|
76
|
+
digest: Hex;
|
|
77
|
+
signature: string;
|
|
78
|
+
enforcers: SessionWireEnforcers;
|
|
79
|
+
/** THIS host's own agent — the address the wire's allowedTargets caveat must name (RUN-9). Required: a
|
|
80
|
+
* wire minted for another host, or for no host, is refused. Never taken from the request's own claims. */
|
|
81
|
+
target: Address;
|
|
82
|
+
verifyDelegationSig: (d: Delegation) => Promise<boolean>;
|
|
83
|
+
isRevoked: (d: Delegation) => Promise<boolean>;
|
|
84
|
+
/** The skill the inbound message requests. Omit ONLY on the read/control path. */
|
|
85
|
+
skill?: string;
|
|
86
|
+
/** Milliseconds (Date.now() shape); injected for determinism. */
|
|
87
|
+
now?: number;
|
|
88
|
+
/** RUNB-17 — caveats beyond timestamp / allowedMethods / allowedTargets this verifier enforces. Any other is refused. */
|
|
89
|
+
recognisedCaveats?: readonly SessionWireCaveatCheck[];
|
|
90
|
+
}): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Verify a session-wrapped signature over a digest THAT WAS SIGNED AT A KNOWN TIME — a release, an attestation, anything
|
|
93
|
+
* that must keep verifying for as long as it is served, long after the time-boxed leaf that signed it expired (spec 412
|
|
94
|
+
* W5 / spec 413). Every leg of `verifySessionWrappedSignature` except two:
|
|
95
|
+
* • the timestamp window is judged AT `at` (when the thing was signed), not now — back-dating widens nothing, because
|
|
96
|
+
* the leaf must still verify ERC-1271 against the signer and the key must still recover;
|
|
97
|
+
* • no skill selector and no target is required: a message gate asks "may this key send THIS skill, HERE"; a signed
|
|
98
|
+
* artifact is not presented at a host — it asks only "did the signer's agent sign it while its leaf was live".
|
|
99
|
+
* Revocation is read NOW: a leaf the custodian revoked stops vouching for anything it ever signed.
|
|
100
|
+
* Returns null when every leg holds, else the leg that failed, in words. Fail-closed on a chain-read failure.
|
|
101
|
+
*/
|
|
102
|
+
export declare function verifySessionLeafSignatureAt(args: {
|
|
103
|
+
signer: Address;
|
|
104
|
+
digest: Hex;
|
|
105
|
+
signature: string;
|
|
106
|
+
timestampEnforcer: string;
|
|
107
|
+
/** When the digest was signed, in milliseconds (Date.now() shape). */
|
|
108
|
+
at: number;
|
|
109
|
+
verifyDelegationSig: (d: Delegation) => Promise<boolean>;
|
|
110
|
+
isRevoked: (d: Delegation) => Promise<boolean>;
|
|
111
|
+
}): Promise<string | null>;
|
|
112
|
+
/** keccak over stable-JSON — the a2a body-hash convention (equals the task runtime's `hashBody`). */
|
|
113
|
+
export declare const sessionBodyHash: (data: unknown) => Hex;
|
|
114
|
+
//# sourceMappingURL=session-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-wire.d.ts","sourceRoot":"","sources":["../src/session-wire.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAmD,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAC/F,OAAO,EAA8E,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI5I,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,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,eAAO,MAAM,eAAe,SAAU,OAAO,KAAG,GAAuD,CAAC"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// SESSION WIRES — how an agent signs as an identity whose key it does not hold. Spec 350 §8 / spec 326.
|
|
2
|
+
//
|
|
3
|
+
// THE CALLER-SIGNATURE GAP, RESOLVED (spec 329 §3.1, generalized). A runtime holds no key for the identity
|
|
4
|
+
// it acts as — an org's DO holds no org key, a relying service must never custody the service agent it
|
|
5
|
+
// acts as (ADR-0019: a relying key is always a DELEGATE, never a custodian), a skills worker signs as
|
|
6
|
+
// `skills-agent` without holding it. Yet A2A needs per-message sender signatures and per-poll caller
|
|
7
|
+
// signatures that verify against THAT identity. A ceremony therefore mints a NARROW delegation —
|
|
8
|
+
// delegator = the identity, delegate = a KMS session key, allowedMethods = a pinned set of skill
|
|
9
|
+
// selectors (never the any-skill sentinel), allowedTargets pinned, timestamp-bounded — signed by the
|
|
10
|
+
// identity's own custody credential. The runtime stores the wire; NO raw key ever rests there; the KMS
|
|
11
|
+
// key signs each digest on demand.
|
|
12
|
+
//
|
|
13
|
+
// ON THE WIRE such a signature is the SESSION-WRAPPED form: `0x51` (a type byte no on-chain validator
|
|
14
|
+
// accepts — it fails closed anywhere but a gate that understands it) followed by hex(utf8(JSON({ wire,
|
|
15
|
+
// sig }))). A gate verifies it fail-closed PER MESSAGE: delegator === the claimed signer; timestamp window
|
|
16
|
+
// live; an allowedTargets caveat that names THIS host's agent (RUN-9 — a wire minted for one host is not a
|
|
17
|
+
// credential at another, and a wire that names no target is a credential nowhere);
|
|
18
|
+
// a pinned selector set that names the requested skill and never A2A_ANY_SKILL; the raw ECDSA sig
|
|
19
|
+
// recovers to the wire's delegate; the wire's own signature ERC-1271-verifies against the delegator; AND
|
|
20
|
+
// the wire is unrevoked on chain — so a custodian's revocation kills the authority at every gate, now.
|
|
21
|
+
//
|
|
22
|
+
// WHY THIS IS HERE. Four copies of this file existed across two repos (demo-a2a's session-wire.ts and
|
|
23
|
+
// org-wire.ts, skills-a2a's service-wire.ts, and a sibling worker's). "Copy the wire implementation, do not
|
|
24
|
+
// invent a third" was the instruction, and the count had already reached four. It is an A2A signature
|
|
25
|
+
// format that consumes this package's own `skillSelector`; it belongs here, and the apps now consume it.
|
|
26
|
+
// What STAYS in the apps is policy — which caveat SHAPE counts as stewardship vs member access, which
|
|
27
|
+
// contracts a stewardship wire must pin. `org-wire.ts`'s `hasStewardshipShape` is a positive identity
|
|
28
|
+
// test no generic layer can express, and it does not move.
|
|
29
|
+
import { hashMessage, keccak256, recoverAddress, toBytes } from 'viem';
|
|
30
|
+
import { decodeAllowedMethodsTerms, decodeAllowedTargetsTerms, decodeTimestampTerms } from '@agenticprimitives/delegation';
|
|
31
|
+
import { A2A_ANY_SKILL, skillSelector } from './grant.js';
|
|
32
|
+
import { isPlaceholderAddress } from './placeholder.js';
|
|
33
|
+
/** Signature type byte for the session-wrapped form. Unknown to AgentAccount `_validateSig` (fails closed
|
|
34
|
+
* on chain) and to every other verifier — only a gate that calls `verifySessionWrappedSignature` accepts
|
|
35
|
+
* it, and only after full verification. */
|
|
36
|
+
export const SESSION_WRAPPED_SIG_TYPE = '0x51';
|
|
37
|
+
const utf8ToHex = (s) => `0x${Array.from(new TextEncoder().encode(s), (b) => b.toString(16).padStart(2, '0')).join('')}`;
|
|
38
|
+
const hexToUtf8 = (h) => {
|
|
39
|
+
const clean = h.startsWith('0x') ? h.slice(2) : h;
|
|
40
|
+
const bytes = new Uint8Array(clean.length / 2);
|
|
41
|
+
for (let i = 0; i < bytes.length; i++)
|
|
42
|
+
bytes[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
43
|
+
return new TextDecoder().decode(bytes);
|
|
44
|
+
};
|
|
45
|
+
/** Wrap a raw session-key ECDSA signature with the wire that authorizes it. */
|
|
46
|
+
export function wrapSessionSignature(wire, sig) {
|
|
47
|
+
return (SESSION_WRAPPED_SIG_TYPE + utf8ToHex(JSON.stringify({ wire, sig })).slice(2));
|
|
48
|
+
}
|
|
49
|
+
/** Parse the session-wrapped form; null for any other signature shape (callers then use the standard
|
|
50
|
+
* ERC-1271 path — one detector, no ambiguity). */
|
|
51
|
+
export function parseSessionWrappedSignature(signature) {
|
|
52
|
+
if (!signature?.startsWith(SESSION_WRAPPED_SIG_TYPE) || signature.length <= SESSION_WRAPPED_SIG_TYPE.length)
|
|
53
|
+
return null;
|
|
54
|
+
try {
|
|
55
|
+
const parsed = JSON.parse(hexToUtf8(`0x${signature.slice(SESSION_WRAPPED_SIG_TYPE.length)}`));
|
|
56
|
+
if (!parsed?.wire?.delegator || !parsed.wire.delegate || !parsed.wire.signature || !parsed.sig)
|
|
57
|
+
return null;
|
|
58
|
+
return { wire: parsed.wire, sig: parsed.sig };
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function wireToDelegation(w) {
|
|
65
|
+
return {
|
|
66
|
+
delegator: w.delegator,
|
|
67
|
+
delegate: w.delegate,
|
|
68
|
+
authority: w.authority,
|
|
69
|
+
caveats: w.caveats.map((c) => ({ enforcer: c.enforcer, terms: c.terms, args: (c.args ?? '0x') })),
|
|
70
|
+
salt: BigInt(w.salt),
|
|
71
|
+
signature: w.signature,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function delegationToWire(d) {
|
|
75
|
+
return {
|
|
76
|
+
delegator: d.delegator, delegate: d.delegate, authority: d.authority,
|
|
77
|
+
caveats: d.caveats.map((c) => ({ enforcer: c.enforcer, terms: c.terms, ...(c.args && c.args !== '0x' ? { args: c.args } : {}) })),
|
|
78
|
+
salt: d.salt.toString(), signature: d.signature,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
82
|
+
/**
|
|
83
|
+
* Shape check for a session wire (at ceremony store time AND at every gate hit): timestamp-bounded, an
|
|
84
|
+
* allowedTargets caveat that names `target` — THIS host's own agent — and a pinned allowedMethods set that
|
|
85
|
+
* never carries the any-skill sentinel and, when `skill` is given, names that skill's selector.
|
|
86
|
+
*
|
|
87
|
+
* `target` is REQUIRED (RUN-9, audit 2026-11-10). The custodian signs a wire for one receiving agent; the
|
|
88
|
+
* verifier is the only party that knows which agent it is, so it says so, and the wire must agree. A wire
|
|
89
|
+
* with no allowedTargets caveat is refused: "minted for nowhere in particular" was being read as "valid
|
|
90
|
+
* everywhere". There is no default and no wildcard — a verifier with no identity to offer refuses every wire.
|
|
91
|
+
*
|
|
92
|
+
* `skill` should be passed wherever the request names one: a wire minted for one rail must not authorize
|
|
93
|
+
* another. It is omitted only on the read/control path (`tasks/get`, `tasks/cancel`,
|
|
94
|
+
* `pushNotificationConfig/set`), whose digest binds a method and a taskId, not a skill. That omission is
|
|
95
|
+
* narrow rather than lax — the wire must still be pinned, live, ERC-1271-valid and unrevoked, and the task
|
|
96
|
+
* runtime independently requires the caller to BE a party to the task.
|
|
97
|
+
*/
|
|
98
|
+
export function checkSessionWireShape(wire, enforcers, nowSec, opts) {
|
|
99
|
+
const byEnforcer = (addr) => (wire.caveats ?? []).find((c) => (c.enforcer ?? '').toLowerCase() === addr.toLowerCase());
|
|
100
|
+
// Spec 445 decision 8 — the delegate is a real key, never a placeholder (`0x…01`, the zero address).
|
|
101
|
+
if (isPlaceholderAddress(wire.delegate))
|
|
102
|
+
return 'session wire delegate is a placeholder address';
|
|
103
|
+
// RUNB-17 (spec 445 §9 decision 8) — EVERY caveat is read, or the wire is refused. A restriction the delegator signed
|
|
104
|
+
// in (a value limit, a digest binding, a vault-key scope…) that this verifier does not enforce would otherwise be
|
|
105
|
+
// ignored, and a delegation written for a narrower purpose would pass as a session wire. Each enforcer appears once:
|
|
106
|
+
// a second caveat of one kind would be a restriction the lookup below never reads.
|
|
107
|
+
if (!Array.isArray(wire.caveats))
|
|
108
|
+
return 'session wire carries no caveats';
|
|
109
|
+
const known = new Map([
|
|
110
|
+
[String(enforcers.timestamp ?? '').toLowerCase(), null],
|
|
111
|
+
[String(enforcers.allowedMethods ?? '').toLowerCase(), null],
|
|
112
|
+
[String(enforcers.allowedTargets ?? '').toLowerCase(), null],
|
|
113
|
+
]);
|
|
114
|
+
for (const r of opts?.recognisedCaveats ?? [])
|
|
115
|
+
if (typeof r?.enforcer === 'string' && ADDRESS.test(r.enforcer))
|
|
116
|
+
known.set(r.enforcer.toLowerCase(), r);
|
|
117
|
+
const seenEnforcers = new Set();
|
|
118
|
+
for (const c of wire.caveats) {
|
|
119
|
+
const e = String(c?.enforcer ?? '').toLowerCase();
|
|
120
|
+
if (!ADDRESS.test(e) || !known.has(e))
|
|
121
|
+
return `session wire carries a caveat this verifier does not recognise (${e || 'no enforcer'}) — refused, never ignored`;
|
|
122
|
+
if (seenEnforcers.has(e))
|
|
123
|
+
return `session wire carries two caveats for one enforcer (${e})`;
|
|
124
|
+
seenEnforcers.add(e);
|
|
125
|
+
}
|
|
126
|
+
const tsCav = byEnforcer(enforcers.timestamp);
|
|
127
|
+
if (!tsCav?.terms)
|
|
128
|
+
return 'session wire must be timestamp-bounded';
|
|
129
|
+
try {
|
|
130
|
+
const win = decodeTimestampTerms(tsCav.terms);
|
|
131
|
+
const now = BigInt(nowSec);
|
|
132
|
+
if (now < win.validAfter || now >= win.validUntil)
|
|
133
|
+
return 'session wire outside its timestamp window';
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return 'session wire timestamp terms undecodable';
|
|
137
|
+
}
|
|
138
|
+
// THE TARGET (RUN-9) — checked here, at the point of use, against the identity the verifier supplied.
|
|
139
|
+
if (typeof opts?.target !== 'string' || !ADDRESS.test(opts.target))
|
|
140
|
+
return 'the verifier named no target — a session wire is checked against this host\'s own agent';
|
|
141
|
+
if (typeof enforcers.allowedTargets !== 'string' || !ADDRESS.test(enforcers.allowedTargets))
|
|
142
|
+
return 'the verifier has no allowedTargets enforcer — the wire\'s target cannot be read';
|
|
143
|
+
const atCav = byEnforcer(enforcers.allowedTargets);
|
|
144
|
+
if (!atCav?.terms)
|
|
145
|
+
return 'session wire must carry an allowedTargets caveat naming this host';
|
|
146
|
+
try {
|
|
147
|
+
const targets = decodeAllowedTargetsTerms(atCav.terms).map((t) => t.toLowerCase());
|
|
148
|
+
if (!targets.includes(opts.target.toLowerCase()))
|
|
149
|
+
return 'session wire was minted for another target, not this host';
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return 'session wire allowedTargets terms undecodable';
|
|
153
|
+
}
|
|
154
|
+
const amCav = byEnforcer(enforcers.allowedMethods);
|
|
155
|
+
if (!amCav?.terms)
|
|
156
|
+
return 'session wire must carry an allowedMethods caveat';
|
|
157
|
+
try {
|
|
158
|
+
const selectors = decodeAllowedMethodsTerms(amCav.terms).map((s) => s.toLowerCase());
|
|
159
|
+
// A PINNED SET, never the any-skill sentinel. A leaked delegate key can send only what the custodian
|
|
160
|
+
// enumerated; `A2A_ANY_SKILL` is the line between "these operations" and "anything this agent can do".
|
|
161
|
+
if (selectors.some((s) => s === A2A_ANY_SKILL.toLowerCase()))
|
|
162
|
+
return 'session wire must never carry the any-skill sentinel';
|
|
163
|
+
if (selectors.length === 0)
|
|
164
|
+
return 'session wire allowedMethods must name at least one selector';
|
|
165
|
+
if (opts?.skill) {
|
|
166
|
+
const want = skillSelector(opts.skill).toLowerCase();
|
|
167
|
+
if (!selectors.includes(want))
|
|
168
|
+
return `session wire allowedMethods does not name the ${opts.skill} selector`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return 'session wire allowedMethods terms undecodable';
|
|
173
|
+
}
|
|
174
|
+
// RUNB-17 — every recognised further caveat is ENFORCED, not merely allowed.
|
|
175
|
+
for (const c of wire.caveats) {
|
|
176
|
+
const r = known.get(String(c.enforcer).toLowerCase());
|
|
177
|
+
if (!r)
|
|
178
|
+
continue;
|
|
179
|
+
let why;
|
|
180
|
+
try {
|
|
181
|
+
why = r.check(c.terms, { nowSec, target: opts.target, ...(opts.skill ? { skill: opts.skill } : {}) });
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
why = `caveat ${r.enforcer} could not be checked: ${e instanceof Error ? e.message : String(e)}`;
|
|
185
|
+
}
|
|
186
|
+
if (why !== null)
|
|
187
|
+
return `session wire caveat ${r.enforcer} does not hold: ${why}`;
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Verify a session-wrapped signature for `signer` over `digest`, fail-closed on every leg. The on-chain
|
|
193
|
+
* checks are the SAME injected ones the standard gate uses (`OnChainChecks`) — revocation is immediate.
|
|
194
|
+
* Pass `skill` whenever the request names one.
|
|
195
|
+
*/
|
|
196
|
+
export async function verifySessionWrappedSignature(args) {
|
|
197
|
+
const parsed = parseSessionWrappedSignature(args.signature);
|
|
198
|
+
if (!parsed)
|
|
199
|
+
return false;
|
|
200
|
+
const { wire, sig } = parsed;
|
|
201
|
+
if (wire.delegator.toLowerCase() !== args.signer.toLowerCase())
|
|
202
|
+
return false;
|
|
203
|
+
const shapeOpts = { target: args.target, ...(args.skill ? { skill: args.skill } : {}), ...(args.recognisedCaveats ? { recognisedCaveats: args.recognisedCaveats } : {}) };
|
|
204
|
+
if (checkSessionWireShape(wire, args.enforcers, Math.floor((args.now ?? Date.now()) / 1000), shapeOpts) !== null)
|
|
205
|
+
return false;
|
|
206
|
+
// The raw sig must recover to the wire's delegate (the KMS session key). Accept both raw-digest and
|
|
207
|
+
// eth-signed-message recovery, mirroring AgentAccount._verifyEcdsa.
|
|
208
|
+
const delegate = wire.delegate.toLowerCase();
|
|
209
|
+
let recovered = false;
|
|
210
|
+
try {
|
|
211
|
+
recovered = (await recoverAddress({ hash: args.digest, signature: sig })).toLowerCase() === delegate;
|
|
212
|
+
}
|
|
213
|
+
catch { /* try wrapped */ }
|
|
214
|
+
if (!recovered) {
|
|
215
|
+
try {
|
|
216
|
+
recovered = (await recoverAddress({ hash: hashMessage({ raw: toBytes(args.digest) }), signature: sig })).toLowerCase() === delegate;
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (!recovered)
|
|
223
|
+
return false;
|
|
224
|
+
const d = wireToDelegation(wire);
|
|
225
|
+
try {
|
|
226
|
+
if (await args.isRevoked(d))
|
|
227
|
+
return false; // custodian revoke ⇒ immediate kill at every gate
|
|
228
|
+
return await args.verifyDelegationSig(d);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return false; // fail-closed on chain-read failure (ADR-0013)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Verify a session-wrapped signature over a digest THAT WAS SIGNED AT A KNOWN TIME — a release, an attestation, anything
|
|
236
|
+
* that must keep verifying for as long as it is served, long after the time-boxed leaf that signed it expired (spec 412
|
|
237
|
+
* W5 / spec 413). Every leg of `verifySessionWrappedSignature` except two:
|
|
238
|
+
* • the timestamp window is judged AT `at` (when the thing was signed), not now — back-dating widens nothing, because
|
|
239
|
+
* the leaf must still verify ERC-1271 against the signer and the key must still recover;
|
|
240
|
+
* • no skill selector and no target is required: a message gate asks "may this key send THIS skill, HERE"; a signed
|
|
241
|
+
* artifact is not presented at a host — it asks only "did the signer's agent sign it while its leaf was live".
|
|
242
|
+
* Revocation is read NOW: a leaf the custodian revoked stops vouching for anything it ever signed.
|
|
243
|
+
* Returns null when every leg holds, else the leg that failed, in words. Fail-closed on a chain-read failure.
|
|
244
|
+
*/
|
|
245
|
+
export async function verifySessionLeafSignatureAt(args) {
|
|
246
|
+
const parsed = parseSessionWrappedSignature(args.signature);
|
|
247
|
+
if (!parsed)
|
|
248
|
+
return 'not a session-wrapped signature';
|
|
249
|
+
const { wire, sig } = parsed;
|
|
250
|
+
if (wire.delegator.toLowerCase() !== args.signer.toLowerCase())
|
|
251
|
+
return 'the leaf is not the signer\'s';
|
|
252
|
+
const delegate = wire.delegate.toLowerCase();
|
|
253
|
+
let recovered = false;
|
|
254
|
+
try {
|
|
255
|
+
recovered = (await recoverAddress({ hash: args.digest, signature: sig })).toLowerCase() === delegate;
|
|
256
|
+
}
|
|
257
|
+
catch { /* try the eth-signed form */ }
|
|
258
|
+
if (!recovered) {
|
|
259
|
+
try {
|
|
260
|
+
recovered = (await recoverAddress({ hash: hashMessage({ raw: toBytes(args.digest) }), signature: sig })).toLowerCase() === delegate;
|
|
261
|
+
}
|
|
262
|
+
catch { /* no */ }
|
|
263
|
+
}
|
|
264
|
+
if (!recovered)
|
|
265
|
+
return 'the signature does not recover to the leaf\'s session key';
|
|
266
|
+
const tsCav = (wire.caveats ?? []).find((c) => (c.enforcer ?? '').toLowerCase() === args.timestampEnforcer.toLowerCase());
|
|
267
|
+
if (!tsCav?.terms)
|
|
268
|
+
return 'the leaf carries no timestamp caveat';
|
|
269
|
+
try {
|
|
270
|
+
const win = decodeTimestampTerms(tsCav.terms);
|
|
271
|
+
const at = BigInt(Math.floor(args.at / 1000));
|
|
272
|
+
if (at < win.validAfter || at >= win.validUntil)
|
|
273
|
+
return 'the leaf was not live when the digest was signed';
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return 'the leaf\'s timestamp terms are undecodable';
|
|
277
|
+
}
|
|
278
|
+
const d = wireToDelegation(wire);
|
|
279
|
+
try {
|
|
280
|
+
if (await args.isRevoked(d))
|
|
281
|
+
return 'the leaf was revoked on chain';
|
|
282
|
+
if (!(await args.verifyDelegationSig(d)))
|
|
283
|
+
return 'the leaf does not verify ERC-1271 against the signer';
|
|
284
|
+
}
|
|
285
|
+
catch (e) {
|
|
286
|
+
return `the chain could not be read (${e instanceof Error ? e.message : 'unknown'})`;
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
/** keccak over stable-JSON — the a2a body-hash convention (equals the task runtime's `hashBody`). */
|
|
291
|
+
export const sessionBodyHash = (data) => keccak256(toBytes(JSON.stringify(data ?? null)));
|
|
292
|
+
//# sourceMapp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MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC;QACH,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAAE,OAAO,+BAA+B,CAAC;QACpE,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,sDAAsD,CAAC;IAC1G,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,gCAAgC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC;IACvF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,qGAAqG;AACrG,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAO,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/skill-handler.d.ts
CHANGED
|
@@ -17,11 +17,16 @@ export interface VaultClient {
|
|
|
17
17
|
delegation?: Delegation;
|
|
18
18
|
}): Promise<VaultRef>;
|
|
19
19
|
}
|
|
20
|
-
/** Minimal MCP seam — call a tool via the delegation token (reuses the a2a→mcp leg, W4).
|
|
20
|
+
/** Minimal MCP seam — call a tool via the delegation token (reuses the a2a→mcp leg, W4). Symmetric with
|
|
21
|
+
* `VaultClient`: pass the task's `delegation` (the grant THAT principal signed) so the composed MCP call
|
|
22
|
+
* rides the on-chain authority (ADR-0041); the consumer routes it through `callMcpToolViaDelegation`. Omit
|
|
23
|
+
* `delegation` only for an agent-self call that needs no principal grant. This is the port the Ring-0
|
|
24
|
+
* orchestration loop's `ToolInvoker` wraps (ADR-0044). */
|
|
21
25
|
export interface McpClient {
|
|
22
26
|
callTool(args: {
|
|
23
27
|
tool: string;
|
|
24
28
|
toolArgs?: Record<string, unknown>;
|
|
29
|
+
delegation?: Delegation;
|
|
25
30
|
}): Promise<unknown>;
|
|
26
31
|
}
|
|
27
32
|
/** Thrown by `requestAuth` to suspend a task pending a fresh/again-scoped delegation (FR-3.5). The
|
|
@@ -68,6 +73,8 @@ export interface SkillContext {
|
|
|
68
73
|
bodyContentType?: string;
|
|
69
74
|
disclosurePolicy?: string;
|
|
70
75
|
caseId?: Hex;
|
|
76
|
+
/** URI-keyed A2A extension metadata to record on the artifact (e.g. skill-provenance). */
|
|
77
|
+
metadata?: Record<string, unknown>;
|
|
71
78
|
}): Promise<Hex>;
|
|
72
79
|
/** Suspend pending a fresh grant — throws `AuthRequired`. */
|
|
73
80
|
requestAuth(reason: string): never;
|
|
@@ -80,8 +87,21 @@ export interface SkillResult {
|
|
|
80
87
|
artifactIds?: Hex[];
|
|
81
88
|
error?: string;
|
|
82
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Who may SEE a skill on an agent card (spec 338 §8, ADR-0056 §6). Mirrors `surface-catalog`'s
|
|
92
|
+
* `SurfaceExposure` structurally — not imported, so `a2a` stays dependency-light.
|
|
93
|
+
*
|
|
94
|
+
* Absent ⇒ `public`, preserving pre-spec-338 behaviour. Visibility is NOT authorization: a skill
|
|
95
|
+
* hidden from a card is still gated by delegation + policy if someone guesses its name, and a skill
|
|
96
|
+
* shown on a card grants nothing.
|
|
97
|
+
*/
|
|
98
|
+
export type SkillExposure = 'public' | 'authenticated' | 'private' | 'service-only';
|
|
83
99
|
export interface SkillHandler {
|
|
84
100
|
skill: string;
|
|
101
|
+
/** Card visibility. Omit ⇒ `public`. See `SkillExposure`. */
|
|
102
|
+
exposure?: SkillExposure;
|
|
103
|
+
/** For `exposure: 'private'` — canonical ids permitted to see it. Empty/absent ⇒ nobody. */
|
|
104
|
+
audience?: readonly string[];
|
|
85
105
|
/** PAY-A2A-1 — optional price. A priced skill is gated by the injected `PaymentGate` BEFORE `handle`
|
|
86
106
|
* runs; an unpaid request parks `input-required` with `x402.payment.*` metadata (the handler is never
|
|
87
107
|
* reached). Free skills omit this. */
|