@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-handler.d.ts","sourceRoot":"","sources":["../src/skill-handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;2GAG2G;AAC3G,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1E,KAAK,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChH;AAED
|
|
1
|
+
{"version":3,"file":"skill-handler.d.ts","sourceRoot":"","sources":["../src/skill-handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;2GAG2G;AAC3G,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CA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|
|
1
|
-
{"version":3,"file":"skill-handler.js","sourceRoot":"","sources":["../src/skill-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skill-handler.js","sourceRoot":"","sources":["../src/skill-handler.ts"],"names":[],"mappings":"AA2BA;yEACyE;AACzE,MAAM,OAAO,YAAa,SAAQ,KAAK;IACT;IAA5B,YAA4B,UAAkB;QAC5C,KAAK,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;QADZ,eAAU,GAAV,UAAU,CAAQ;QAE5C,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAcD;;mFAEmF;AACnF,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACb;IAA5B,YAA4B,OAAuB;QACjD,KAAK,CAAC,sBAAsB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QADpB,YAAO,GAAP,OAAO,CAAgB;QAEjD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AA6DD,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CAAC,QAAwB;IACzD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7E,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Hex } from '@agenticprimitives/types';
|
|
2
|
+
import type { DelegationWireV1 } from '../session-wire.js';
|
|
3
|
+
/** The capability the person's agent runs for an engagement — one message to another agent, sent as the asker. */
|
|
4
|
+
export declare const ENGAGEMENT_INVOKE_CAPABILITY = "engagement.agent.invoke";
|
|
5
|
+
export interface AppDelegationAskInput {
|
|
6
|
+
/** The person's ask-as-me wire: delegator = the person, delegate = this app's ask key, caveat `harness.ask`. */
|
|
7
|
+
wire: DelegationWireV1;
|
|
8
|
+
/** The person's words, verbatim. */
|
|
9
|
+
question: string;
|
|
10
|
+
/** The service the person's agent engages (a registry name: `catalog.svc`). */
|
|
11
|
+
service: string;
|
|
12
|
+
/** A fresh nonce per ask (the runtime's assertion ledger spends it once). Default: 16 hex chars from `crypto`. */
|
|
13
|
+
nonce?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The `/harness/ask` body, as a stable string — the assertion's `bodyHash` is over THESE bytes, so the caller posts
|
|
16
|
+
* this string unchanged. */
|
|
17
|
+
export declare function appDelegationAskBody(input: AppDelegationAskInput): string;
|
|
18
|
+
/**
|
|
19
|
+
* ONE signed ask: the body plus the `A2A-Session` headers — a caller assertion by the app's ask key (the wire's
|
|
20
|
+
* delegate), wrapped with the wire so the runtime can verify the delegation it rides. `signDigest` is the app's
|
|
21
|
+
* signer for that key (an AKCS delegate, a KMS key — never a person's key); `audience` is the person agent's origin.
|
|
22
|
+
*/
|
|
23
|
+
export declare function appDelegationAsk(input: AppDelegationAskInput & {
|
|
24
|
+
audience: string;
|
|
25
|
+
signDigest: (digest: Hex) => Promise<Hex>;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
raw: string;
|
|
29
|
+
headers: Record<string, string>;
|
|
30
|
+
}>;
|
|
31
|
+
/** The reply shape `/harness/ask` answers with, as far as an engaging client reads it. */
|
|
32
|
+
export interface AppDelegationReplyV1 {
|
|
33
|
+
ok?: boolean;
|
|
34
|
+
error?: string;
|
|
35
|
+
runRef?: string;
|
|
36
|
+
hasProvenance?: unknown;
|
|
37
|
+
reply?: {
|
|
38
|
+
kind?: string;
|
|
39
|
+
runRef?: string;
|
|
40
|
+
text?: string;
|
|
41
|
+
summary?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
results?: Array<{
|
|
44
|
+
toolId: string;
|
|
45
|
+
result: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What the engaged service answered, as the person's agent recorded it: the result of the `engagement.agent.invoke`
|
|
51
|
+
* step (the service's own answer, an observation of the person's agent — never authority), the agent's words, and
|
|
52
|
+
* the run that did it. `null` when the reply carries no engagement.
|
|
53
|
+
*/
|
|
54
|
+
export declare function engagementHopOf(out: AppDelegationReplyV1 | null | undefined): {
|
|
55
|
+
said: string;
|
|
56
|
+
runRef?: string;
|
|
57
|
+
hop: Record<string, unknown> | null;
|
|
58
|
+
hasProvenance?: unknown;
|
|
59
|
+
} | null;
|
|
60
|
+
//# sourceMappingURL=app-delegation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-delegation.d.ts","sourceRoot":"","sources":["../../src/standard/app-delegation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,kHAAkH;AAClH,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IACpC,gHAAgH;IAChH,IAAI,EAAE,gBAAgB,CAAC;IACvB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,kHAAkH;IAClH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;6BAC6B;AAC7B,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CASzE;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,qBAAqB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,GACjH,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAQ3D;AAED,0FAA0F;AAC1F,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,OAAO,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CACnJ;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAMpL"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { STANDARD_SURFACE_SKILL, sessionWireSigner } from './caller.js';
|
|
2
|
+
/** The capability the person's agent runs for an engagement — one message to another agent, sent as the asker. */
|
|
3
|
+
export const ENGAGEMENT_INVOKE_CAPABILITY = 'engagement.agent.invoke';
|
|
4
|
+
/** The `/harness/ask` body, as a stable string — the assertion's `bodyHash` is over THESE bytes, so the caller posts
|
|
5
|
+
* this string unchanged. */
|
|
6
|
+
export function appDelegationAskBody(input) {
|
|
7
|
+
const nonce = input.nonce ?? [...crypto.getRandomValues(new Uint8Array(8))].map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
8
|
+
return JSON.stringify({
|
|
9
|
+
method: STANDARD_SURFACE_SKILL,
|
|
10
|
+
nonce,
|
|
11
|
+
addressee: input.wire.delegator,
|
|
12
|
+
message: `ask ${input.service}: ${input.question}`,
|
|
13
|
+
plan: { steps: [{ toolId: ENGAGEMENT_INVOKE_CAPABILITY, args: { agent: input.service, message: input.question } }] },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ONE signed ask: the body plus the `A2A-Session` headers — a caller assertion by the app's ask key (the wire's
|
|
18
|
+
* delegate), wrapped with the wire so the runtime can verify the delegation it rides. `signDigest` is the app's
|
|
19
|
+
* signer for that key (an AKCS delegate, a KMS key — never a person's key); `audience` is the person agent's origin.
|
|
20
|
+
*/
|
|
21
|
+
export async function appDelegationAsk(input) {
|
|
22
|
+
const raw = appDelegationAskBody(input);
|
|
23
|
+
// The agent CLAIMED is the wire's DELEGATOR — the person asked as; the receiver's session-wire principal checks
|
|
24
|
+
// `wire.delegator === agent` and recovers the signature to the wire's delegate. Claiming the delegate (the app's key)
|
|
25
|
+
// was the promoted client's bug: every ask-as-me it sent was refused (2026-10-09).
|
|
26
|
+
const sign = sessionWireSigner({ agent: input.wire.delegator, wire: input.wire, signDigest: input.signDigest, audience: input.audience, ...(input.now ? { now: input.now } : {}) });
|
|
27
|
+
const headers = await sign(raw, STANDARD_SURFACE_SKILL);
|
|
28
|
+
return { raw, headers: { 'content-type': 'application/json', accept: 'application/json', ...headers } };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What the engaged service answered, as the person's agent recorded it: the result of the `engagement.agent.invoke`
|
|
32
|
+
* step (the service's own answer, an observation of the person's agent — never authority), the agent's words, and
|
|
33
|
+
* the run that did it. `null` when the reply carries no engagement.
|
|
34
|
+
*/
|
|
35
|
+
export function engagementHopOf(out) {
|
|
36
|
+
if (!out?.ok || !out.reply)
|
|
37
|
+
return null;
|
|
38
|
+
const hop = (out.reply.results ?? []).find((r) => r.toolId === ENGAGEMENT_INVOKE_CAPABILITY)?.result;
|
|
39
|
+
const said = (out.reply.text ?? out.reply.summary ?? '').trim();
|
|
40
|
+
const runRef = out.reply.runRef ?? out.runRef;
|
|
41
|
+
return { said, ...(runRef ? { runRef } : {}), hop: hop && typeof hop === 'object' ? hop : null, ...(out.hasProvenance !== undefined ? { hasProvenance: out.hasProvenance } : {}) };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=app-delegation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-delegation.js","sourceRoot":"","sources":["../../src/standard/app-delegation.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAExE,kHAAkH;AAClH,MAAM,CAAC,MAAM,4BAA4B,GAAG,yBAAyB,CAAC;AAatE;6BAC6B;AAC7B,MAAM,UAAU,oBAAoB,CAAC,KAA4B;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjI,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,MAAM,EAAE,sBAAsB;QAC9B,KAAK;QACL,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS;QAC/B,OAAO,EAAE,OAAO,KAAK,CAA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AAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACrG,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAE,GAA+B,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAClN,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
import type { Delegation } from '@agenticprimitives/delegation';
|
|
3
|
+
import { type DelegationWireV1, type SessionWireCaveatCheck } from '../session-wire.js';
|
|
4
|
+
import type { Principal } from './server.js';
|
|
5
|
+
/** The Authorization scheme an agent presents its session wire under. */
|
|
6
|
+
export declare const SESSION_AUTH_SCHEME = "A2A-Session";
|
|
7
|
+
/** The skill a session wire must pin to reach the standard surface: asking this agent, and nothing else.
|
|
8
|
+
* A wire that names other selectors and not this one is refused — pinning is the point. */
|
|
9
|
+
export declare const STANDARD_SURFACE_SKILL = "harness.ask";
|
|
10
|
+
/** What a caller signs. Every field is bound: a captured assertion cannot be replayed onto another method,
|
|
11
|
+
* another body, another host, or a later moment. `issuedAt` is IN the digest and checked (stale / ahead refused,
|
|
12
|
+
* the digest claimed once) — the wire path's freshness field that the deleted JSON-RPC dispatcher once dropped
|
|
13
|
+
* (audit a2a-issuedat-dropped-in-dispatch; the folded wire of spec 372 S4 is where the check lives now). */
|
|
14
|
+
export interface CallerAssertionV1 {
|
|
15
|
+
/** The Smart Agent the caller acts AS — must equal the wire's delegator. */
|
|
16
|
+
agent: string;
|
|
17
|
+
/** The A2A method this assertion is for. */
|
|
18
|
+
method: string;
|
|
19
|
+
/** keccak256 over the raw JSON-RPC request body. */
|
|
20
|
+
bodyHash: Hex;
|
|
21
|
+
/** Seconds since the epoch. */
|
|
22
|
+
issuedAt: number;
|
|
23
|
+
/** The origin the request is addressed to (`https://host`), so an assertion for one agent's host is not
|
|
24
|
+
* usable at another's. */
|
|
25
|
+
audience: string;
|
|
26
|
+
/** The `0x51`-wrapped session signature over `callerAssertionDigest(...)`. */
|
|
27
|
+
signature: string;
|
|
28
|
+
}
|
|
29
|
+
/** The digest a caller signs — keccak over stable JSON, the a2a body-hash convention. */
|
|
30
|
+
export declare function callerAssertionDigest(a: Omit<CallerAssertionV1, 'signature'>): Hex;
|
|
31
|
+
/** keccak over the raw request body, exactly as it arrived — never over a re-serialized parse. */
|
|
32
|
+
export declare const requestBodyHash: (raw: string) => Hex;
|
|
33
|
+
/** Build the `Authorization` header value a runtime sends. */
|
|
34
|
+
export declare function sessionAuthorizationHeader(a: CallerAssertionV1): string;
|
|
35
|
+
/** Read an `A2A-Session` header. Returns null for any other scheme (a `Bearer` is a person's, not ours) and
|
|
36
|
+
* for anything malformed — never a partial assertion. */
|
|
37
|
+
export declare function parseSessionAuthorization(header: string | null | undefined): CallerAssertionV1 | null;
|
|
38
|
+
export interface SessionWirePrincipalDeps {
|
|
39
|
+
/** The enforcer addresses the wire's caveats must carry (this deployment's). */
|
|
40
|
+
enforcers: {
|
|
41
|
+
timestamp: string;
|
|
42
|
+
allowedMethods: string;
|
|
43
|
+
allowedTargets: string;
|
|
44
|
+
};
|
|
45
|
+
/** THIS host's own agent — the address a presented wire's allowedTargets caveat must name (RUN-9). A host
|
|
46
|
+
* that serves several agents answers per request (from its OWN routing, never from the assertion); `null`
|
|
47
|
+
* refuses. A wire minted for another host, or carrying no target, is not a credential here. */
|
|
48
|
+
target: Address | ((request: Request) => Address | null);
|
|
49
|
+
/** ERC-1271 / ECDSA verification of the wire against its delegator. */
|
|
50
|
+
verifyDelegationSig: (d: Delegation) => Promise<boolean>;
|
|
51
|
+
/** On-chain revocation — a custodian's revoke kills the caller at the next request. */
|
|
52
|
+
isRevoked: (d: Delegation) => Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Verify an assertion the agent signed DIRECTLY — ERC-1271 against its own account, no session key in
|
|
55
|
+
* between. Some agents can do that (a relayer holding the SA's credential, a persona in this estate) and
|
|
56
|
+
* before the fold they proved themselves exactly this way, with `caller` + `signature` on the wire.
|
|
57
|
+
*
|
|
58
|
+
* NOT A FALLBACK (ADR-0013). The signature's own type byte chooses: `0x51` is session-wrapped and takes
|
|
59
|
+
* the wire path; anything else takes this one. Neither runs because the other failed, and omitting this
|
|
60
|
+
* means a direct signature is simply not admitted.
|
|
61
|
+
*/
|
|
62
|
+
verifyAgentSignature?: (agent: Address, digest: Hex, signature: Hex) => Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* The skill the wire must pin for this request (default `STANDARD_SURFACE_SKILL`). A function is asked per
|
|
65
|
+
* request with the assertion's `method` and answers the selector to require, or `null` to refuse that method
|
|
66
|
+
* outright — so one principal can admit `harness.ask` under an ask wire and `harness.read` under a read-only
|
|
67
|
+
* wire, and a wire pinned to one never opens the other (spec 433 W2: the Home's runtime reads a self-hosted
|
|
68
|
+
* agent's runs under a wire that can read and cannot ask).
|
|
69
|
+
*/
|
|
70
|
+
skill?: string | ((method: string) => string | null);
|
|
71
|
+
/** RUNB-17 (spec 445 decision 8) — caveats beyond timestamp / allowedMethods / allowedTargets that this host ENFORCES
|
|
72
|
+
* (each with its check). A wire carrying any other caveat is refused. */
|
|
73
|
+
recognisedCaveats?: readonly SessionWireCaveatCheck[];
|
|
74
|
+
/** How old an assertion may be (default 120 s). */
|
|
75
|
+
maxAgeSec?: number;
|
|
76
|
+
/** Tolerated clock skew for an assertion dated ahead (default 30 s). */
|
|
77
|
+
skewSec?: number;
|
|
78
|
+
now?: () => number;
|
|
79
|
+
/**
|
|
80
|
+
* Spend an assertion, once. Returns true when THIS call claimed it and false when it was already spent.
|
|
81
|
+
* The default is an in-isolate map, which is not replay protection where requests fan out across
|
|
82
|
+
* isolates — bind the estate's single writer (the agent's own object) in production.
|
|
83
|
+
*/
|
|
84
|
+
claim?: (digest: Hex, expiresAtMs: number) => Promise<boolean>;
|
|
85
|
+
/** Told why a caller was refused — for the operator's log, never for the caller (a refusal says only
|
|
86
|
+
* that it was refused; which leg failed is not a fact an unauthenticated caller is owed). */
|
|
87
|
+
onRefused?: (reason: string, agent?: string) => void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The `principal` implementation for agents. Returns `{ agent, kind: 'agent' }` on every leg passing, and
|
|
91
|
+
* `null` otherwise — the server answers 401 and no method runs.
|
|
92
|
+
*
|
|
93
|
+
* SINGLE-USE. An accepted assertion's digest is SPENT: a captured request cannot be replayed while it is
|
|
94
|
+
* still fresh. With `claim` bound to the estate's single writer this holds everywhere; without it, only
|
|
95
|
+
* within this isolate — which on a fanned-out edge is no protection at all, and was observed live before
|
|
96
|
+
* the ledger existed. The claim happens AFTER the signature verifies, so an unauthenticated caller can
|
|
97
|
+
* spend nothing and write nothing.
|
|
98
|
+
*/
|
|
99
|
+
export declare function sessionWirePrincipal(deps: SessionWirePrincipalDeps): (request: Request) => Promise<Principal | null>;
|
|
100
|
+
/** Re-export so a client can build a wire-signed call without reaching past the standard surface. */
|
|
101
|
+
export type { DelegationWireV1 };
|
|
102
|
+
/** THE CLIENT HALF — what a runtime holds to speak as itself: its agent, its session wire, and a signer over the
|
|
103
|
+
* runtime's OWN key (a port: the private key never enters this package). Returns the per-request header builder
|
|
104
|
+
* `createStandardA2aClient({ signRequest })` takes; each request's assertion binds the method, the body hash, the
|
|
105
|
+
* audience and the moment, and is spent once at the addressed agent (S3c). The same code path the S3c gate drove. */
|
|
106
|
+
export declare function sessionWireSigner(o: {
|
|
107
|
+
agent: Address;
|
|
108
|
+
wire: DelegationWireV1;
|
|
109
|
+
/** Signs a 32-byte digest with the runtime's key; returns the raw 65-byte signature. */
|
|
110
|
+
signDigest: (digest: Hex) => Promise<Hex>;
|
|
111
|
+
/** The origin the requests are addressed to (`https://host`); defaults from the endpoint's origin. */
|
|
112
|
+
audience: string;
|
|
113
|
+
now?: () => number;
|
|
114
|
+
}): (raw: string, method: string) => Promise<Record<string, string>>;
|
|
115
|
+
//# sourceMappingURL=caller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caller.d.ts","sourceRoot":"","sources":["../../src/standard/caller.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAsB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAqF,KAAK,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3K,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAEjD;4FAC4F;AAC5F,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD;;;6GAG6G;AAC7G,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,QAAQ,EAAE,GAAG,CAAC;IACd,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB;+BAC2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA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,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D;kGAC8F;IAC9F,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAuEpH;AAED,qGAAqG;AACrG,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC;;;sHAGsH;AACtH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,gBAAgB,CAAC;IACvB,wFAAwF;IACxF,UAAU,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1C,sGAAsG;IACtG,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CASnE"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// THE RUNTIME AS ITS OWN CALLER — spec 372 S3c.
|
|
2
|
+
//
|
|
3
|
+
// A person reaches the standard surface with a Home session bearer. An outside runtime — Claude Code, Goose,
|
|
4
|
+
// a deploy bot — has no Home session and must never be given one: it is not a person, and a bearer minted for
|
|
5
|
+
// a person is exactly the credential-sharing this estate exists to avoid. What it holds instead is what every
|
|
6
|
+
// agent here holds: a SESSION WIRE (spec 350 §8) — a narrow delegation from its own Smart Agent to a key it
|
|
7
|
+
// controls, timestamp-bounded, pinning the one skill it may exercise, signed by the agent's custody credential
|
|
8
|
+
// and revocable on chain by that custodian at any moment.
|
|
9
|
+
//
|
|
10
|
+
// So the runtime signs each request with that key and presents the wire beside it. The server verifies, per
|
|
11
|
+
// request and fail-closed: the wire's delegator IS the agent claimed; the wire's shape is sound (bounded,
|
|
12
|
+
// pinned, never the any-skill sentinel); the raw signature recovers to the wire's delegate; the wire itself
|
|
13
|
+
// verifies against the delegator on chain (ERC-1271) and is NOT revoked. Revoking the wire kills the caller
|
|
14
|
+
// at the next request, everywhere, with no list to update.
|
|
15
|
+
//
|
|
16
|
+
// TWO SCHEMES, NOT A FALLBACK (ADR-0013). `Bearer` is a person's Home session; `A2A-Session` is an agent's
|
|
17
|
+
// wire. The scheme token in the header selects ONE mechanism, and it fails closed on its own terms — neither
|
|
18
|
+
// is ever tried after the other fails. Which one arrived says WHO is asking. Neither says what they may do.
|
|
19
|
+
import { keccak256, toBytes } from 'viem';
|
|
20
|
+
import { parseSessionWrappedSignature, verifySessionWrappedSignature, wrapSessionSignature } from '../session-wire.js';
|
|
21
|
+
/** The Authorization scheme an agent presents its session wire under. */
|
|
22
|
+
export const SESSION_AUTH_SCHEME = 'A2A-Session';
|
|
23
|
+
/** The skill a session wire must pin to reach the standard surface: asking this agent, and nothing else.
|
|
24
|
+
* A wire that names other selectors and not this one is refused — pinning is the point. */
|
|
25
|
+
export const STANDARD_SURFACE_SKILL = 'harness.ask';
|
|
26
|
+
/** The digest a caller signs — keccak over stable JSON, the a2a body-hash convention. */
|
|
27
|
+
export function callerAssertionDigest(a) {
|
|
28
|
+
return keccak256(toBytes(JSON.stringify({
|
|
29
|
+
v: 'ap.a2a.caller-assertion.v1',
|
|
30
|
+
agent: a.agent.toLowerCase(),
|
|
31
|
+
method: a.method,
|
|
32
|
+
bodyHash: a.bodyHash.toLowerCase(),
|
|
33
|
+
issuedAt: a.issuedAt,
|
|
34
|
+
audience: a.audience.replace(/\/$/, '').toLowerCase(),
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
37
|
+
/** keccak over the raw request body, exactly as it arrived — never over a re-serialized parse. */
|
|
38
|
+
export const requestBodyHash = (raw) => keccak256(toBytes(raw));
|
|
39
|
+
const b64urlDecode = (s) => {
|
|
40
|
+
const padded = s.replace(/-/g, '+').replace(/_/g, '/') + '='.repeat((4 - (s.length % 4)) % 4);
|
|
41
|
+
return atob(padded);
|
|
42
|
+
};
|
|
43
|
+
const b64urlEncode = (s) => btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
44
|
+
/** Build the `Authorization` header value a runtime sends. */
|
|
45
|
+
export function sessionAuthorizationHeader(a) {
|
|
46
|
+
return `${SESSION_AUTH_SCHEME} ${b64urlEncode(JSON.stringify(a))}`;
|
|
47
|
+
}
|
|
48
|
+
/** Read an `A2A-Session` header. Returns null for any other scheme (a `Bearer` is a person's, not ours) and
|
|
49
|
+
* for anything malformed — never a partial assertion. */
|
|
50
|
+
export function parseSessionAuthorization(header) {
|
|
51
|
+
const m = new RegExp(`^${SESSION_AUTH_SCHEME}\\s+(.+)$`, 'i').exec((header ?? '').trim());
|
|
52
|
+
if (!m)
|
|
53
|
+
return null;
|
|
54
|
+
try {
|
|
55
|
+
const a = JSON.parse(b64urlDecode(m[1].trim()));
|
|
56
|
+
if (typeof a.agent !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(a.agent))
|
|
57
|
+
return null;
|
|
58
|
+
if (typeof a.method !== 'string' || !a.method)
|
|
59
|
+
return null;
|
|
60
|
+
if (typeof a.bodyHash !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(a.bodyHash))
|
|
61
|
+
return null;
|
|
62
|
+
if (typeof a.issuedAt !== 'number' || !Number.isFinite(a.issuedAt))
|
|
63
|
+
return null;
|
|
64
|
+
if (typeof a.audience !== 'string' || !a.audience)
|
|
65
|
+
return null;
|
|
66
|
+
if (typeof a.signature !== 'string' || !a.signature.startsWith('0x'))
|
|
67
|
+
return null;
|
|
68
|
+
return a;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The `principal` implementation for agents. Returns `{ agent, kind: 'agent' }` on every leg passing, and
|
|
76
|
+
* `null` otherwise — the server answers 401 and no method runs.
|
|
77
|
+
*
|
|
78
|
+
* SINGLE-USE. An accepted assertion's digest is SPENT: a captured request cannot be replayed while it is
|
|
79
|
+
* still fresh. With `claim` bound to the estate's single writer this holds everywhere; without it, only
|
|
80
|
+
* within this isolate — which on a fanned-out edge is no protection at all, and was observed live before
|
|
81
|
+
* the ledger existed. The claim happens AFTER the signature verifies, so an unauthenticated caller can
|
|
82
|
+
* spend nothing and write nothing.
|
|
83
|
+
*/
|
|
84
|
+
export function sessionWirePrincipal(deps) {
|
|
85
|
+
const maxAgeSec = deps.maxAgeSec ?? 120;
|
|
86
|
+
const skewSec = deps.skewSec ?? 30;
|
|
87
|
+
const now = deps.now ?? (() => Date.now());
|
|
88
|
+
const seen = new Map();
|
|
89
|
+
const refuse = (reason, agent) => { deps.onRefused?.(reason, agent); return null; };
|
|
90
|
+
return async (request) => {
|
|
91
|
+
const a = parseSessionAuthorization(request.headers.get('authorization'));
|
|
92
|
+
if (!a)
|
|
93
|
+
return null; // not our scheme — say nothing; another principal may own it
|
|
94
|
+
const nowSec = Math.floor(now() / 1000);
|
|
95
|
+
if (a.issuedAt > nowSec + skewSec)
|
|
96
|
+
return refuse('assertion is dated ahead', a.agent);
|
|
97
|
+
if (a.issuedAt < nowSec - maxAgeSec)
|
|
98
|
+
return refuse('assertion is stale', a.agent);
|
|
99
|
+
const audience = new URL(request.url).origin;
|
|
100
|
+
if (a.audience.replace(/\/$/, '').toLowerCase() !== audience.toLowerCase())
|
|
101
|
+
return refuse(`assertion is for ${a.audience}, not ${audience}`, a.agent);
|
|
102
|
+
let raw;
|
|
103
|
+
try {
|
|
104
|
+
raw = await request.clone().text();
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return refuse('request body unreadable', a.agent);
|
|
108
|
+
}
|
|
109
|
+
if (requestBodyHash(raw).toLowerCase() !== a.bodyHash.toLowerCase())
|
|
110
|
+
return refuse('assertion does not bind this body', a.agent);
|
|
111
|
+
let method;
|
|
112
|
+
try {
|
|
113
|
+
method = JSON.parse(raw).method;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return refuse('body is not JSON', a.agent);
|
|
117
|
+
}
|
|
118
|
+
if (method !== a.method)
|
|
119
|
+
return refuse(`assertion is for ${a.method}, body calls ${String(method)}`, a.agent);
|
|
120
|
+
const digest = callerAssertionDigest(a);
|
|
121
|
+
// A cheap local reject first, so a replay landing on the isolate that served the original costs no
|
|
122
|
+
// chain read; the authoritative claim is below, after the signature verifies.
|
|
123
|
+
for (const [k, at] of seen)
|
|
124
|
+
if (at < nowSec - maxAgeSec - skewSec)
|
|
125
|
+
seen.delete(k);
|
|
126
|
+
if (seen.has(digest))
|
|
127
|
+
return refuse('assertion already used', a.agent);
|
|
128
|
+
// RUN-20 (spec 445 W0) — RESERVED NOW, synchronously, before any await below. The map used to be written only
|
|
129
|
+
// after the chain reads, so two copies of one assertion arriving together both passed this check and both
|
|
130
|
+
// verified. The first to reach this line holds the digest; it is released only if THIS request is refused.
|
|
131
|
+
seen.set(digest, nowSec);
|
|
132
|
+
const refuseHeld = (reason) => { seen.delete(digest); return refuse(reason, a.agent); };
|
|
133
|
+
const skill = typeof deps.skill === 'function' ? deps.skill(a.method) : (deps.skill ?? STANDARD_SURFACE_SKILL);
|
|
134
|
+
if (!skill)
|
|
135
|
+
return refuseHeld(`no wire admits the method ${a.method} here`);
|
|
136
|
+
const wrapped = parseSessionWrappedSignature(a.signature) !== null;
|
|
137
|
+
const target = typeof deps.target === 'function' ? deps.target(request) : deps.target;
|
|
138
|
+
if (wrapped && !target)
|
|
139
|
+
return refuseHeld('this host named no target for the wire to be checked against');
|
|
140
|
+
const ok = wrapped
|
|
141
|
+
? await verifySessionWrappedSignature({
|
|
142
|
+
target: target,
|
|
143
|
+
signer: a.agent.toLowerCase(),
|
|
144
|
+
digest,
|
|
145
|
+
signature: a.signature,
|
|
146
|
+
enforcers: deps.enforcers,
|
|
147
|
+
verifyDelegationSig: deps.verifyDelegationSig,
|
|
148
|
+
isRevoked: deps.isRevoked,
|
|
149
|
+
skill,
|
|
150
|
+
now: now(),
|
|
151
|
+
...(deps.recognisedCaveats ? { recognisedCaveats: deps.recognisedCaveats } : {}),
|
|
152
|
+
}).catch(() => false)
|
|
153
|
+
: deps.verifyAgentSignature
|
|
154
|
+
? await deps.verifyAgentSignature(a.agent.toLowerCase(), digest, a.signature).catch(() => false)
|
|
155
|
+
: false;
|
|
156
|
+
if (!ok) {
|
|
157
|
+
return refuseHeld(wrapped
|
|
158
|
+
? 'session wire did not verify (shape, signature, delegator or revocation)'
|
|
159
|
+
: deps.verifyAgentSignature ? 'the agent\'s own signature did not verify' : 'a direct agent signature is not admitted here');
|
|
160
|
+
}
|
|
161
|
+
// SPENT, now that it is known to be genuine: the single writer decides who was first. A ledger that
|
|
162
|
+
// cannot be reached refuses the call — a replay window is not something to fail open into (ADR-0013).
|
|
163
|
+
if (deps.claim) {
|
|
164
|
+
const claimed = await deps.claim(digest, (a.issuedAt + maxAgeSec + skewSec) * 1000).catch(() => false);
|
|
165
|
+
// A refused claim KEEPS the local reservation: the ledger says this assertion is spent.
|
|
166
|
+
if (!claimed)
|
|
167
|
+
return refuse('assertion already used', a.agent);
|
|
168
|
+
}
|
|
169
|
+
return { agent: a.agent.toLowerCase(), kind: 'agent' };
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** THE CLIENT HALF — what a runtime holds to speak as itself: its agent, its session wire, and a signer over the
|
|
173
|
+
* runtime's OWN key (a port: the private key never enters this package). Returns the per-request header builder
|
|
174
|
+
* `createStandardA2aClient({ signRequest })` takes; each request's assertion binds the method, the body hash, the
|
|
175
|
+
* audience and the moment, and is spent once at the addressed agent (S3c). The same code path the S3c gate drove. */
|
|
176
|
+
export function sessionWireSigner(o) {
|
|
177
|
+
return async (raw, method) => {
|
|
178
|
+
const base = {
|
|
179
|
+
agent: o.agent.toLowerCase(), method, bodyHash: requestBodyHash(raw),
|
|
180
|
+
issuedAt: Math.floor((o.now ?? Date.now)() / 1000), audience: o.audience,
|
|
181
|
+
};
|
|
182
|
+
const sig = await o.signDigest(callerAssertionDigest(base));
|
|
183
|
+
return { authorization: sessionAuthorizationHeader({ ...base, signature: wrapSessionSignature(o.wire, sig) }) };
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=caller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caller.js","sourceRoot":"","sources":["../../src/standard/caller.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,6GAA6G;AAC7G,8GAA8G;AAC9G,8GAA8G;AAC9G,4GAA4G;AAC5G,+GAA+G;AAC/G,0DAA0D;AAC1D,EAAE;AACF,4GAA4G;AAC5G,0GAA0G;AAC1G,4GAA4G;AAC5G,4GAA4G;AAC5G,2DAA2D;AAC3D,EAAE;AACF,2GAA2G;AAC3G,6GAA6G;AAC7G,4GAA4G;AAC5G,OAAO,EAAE,SAAS,EAAE,OAAO,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,oBAAoB,EAAsD,MAAM,oBAAoB,CAAC;AAG3K,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAEjD;4FAC4F;AAC5F,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAsBpD,yFAAyF;AACzF,MAAM,UAAU,qBAAqB,CAAC,CAAuC;IAC3E,O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,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC;AAKD;;;sHAGsH;AACtH,MAAM,UAAU,iBAAiB,CAAC,CAQjC;IACC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;QAC3B,MAAM,IAAI,GAAyC;YACjD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC;YACpE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ;SACzE,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,OAAO,EAAE,aAAa,EAAE,0BAA0B,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAa,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3H,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AgentCardV1, MessageV1, PartV1, TaskV1 } from './types.js';
|
|
2
|
+
import { type OutboundFetchLimits, type CardTrustOptions } from './outbound-fetch.js';
|
|
3
|
+
export interface ResolvedAgentCard {
|
|
4
|
+
card: AgentCardV1;
|
|
5
|
+
/** SHA-256 over the card's bytes as served, hex — what a record pins and a later fetch is compared to. */
|
|
6
|
+
cardDigest: string;
|
|
7
|
+
/** The JSON-RPC 1.x interface the card publishes. */
|
|
8
|
+
endpoint: string;
|
|
9
|
+
cardUrl: string;
|
|
10
|
+
}
|
|
11
|
+
/** The A2A 1.0 JSON-RPC endpoint a card publishes (top-level `protocolVersion` covers a released card's interfaces). */
|
|
12
|
+
export declare function jsonRpcEndpointOf(card: AgentCardV1 & {
|
|
13
|
+
protocolVersion?: string;
|
|
14
|
+
}): string | null;
|
|
15
|
+
/** Fetch a card, digest its bytes, read its endpoint. A card without a 1.x JSON-RPC interface is refused.
|
|
16
|
+
* RUN-16 (spec 445 W0): the URL — and the endpoint the card names — must be public https; the fetch follows no
|
|
17
|
+
* redirect, is bounded in time and reads at most `OUTBOUND_CARD_MAX_BYTES`. */
|
|
18
|
+
export declare function resolveAgentCard(cardUrl: string, fetchImpl?: typeof fetch, expectDigest?: string, limits?: OutboundFetchLimits, trust?: CardTrustOptions): Promise<ResolvedAgentCard>;
|
|
19
|
+
export interface StandardA2aClientOptions {
|
|
20
|
+
endpoint: string;
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
/** Extra headers on every call — a bearer, a session wire. Never a mandate. */
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
/** Headers computed PER REQUEST from the raw body — the runtime's `A2A-Session` assertion (`sessionWireSigner`),
|
|
25
|
+
* which binds the method, the body hash, the audience and the moment. Static `headers` cannot express that. */
|
|
26
|
+
signRequest?: (raw: string, method: string) => Promise<Record<string, string>>;
|
|
27
|
+
/** RUN-16 — per-call deadline, reply size cap and URL policy (defaults: 15 s, 4 MiB, public https only). */
|
|
28
|
+
limits?: OutboundFetchLimits;
|
|
29
|
+
/** RUNB-9 — where the endpoint came from, when it came from a card: with `headers` or `signRequest` (a credential
|
|
30
|
+
* leaves) the endpoint must be on the card's own origin unless `pinned`. Omit for an endpoint you configured. */
|
|
31
|
+
card?: {
|
|
32
|
+
url: string;
|
|
33
|
+
pinned: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface SendResult {
|
|
37
|
+
task?: TaskV1;
|
|
38
|
+
message?: MessageV1;
|
|
39
|
+
}
|
|
40
|
+
export interface StandardA2aClient {
|
|
41
|
+
sendMessage(parts: PartV1[], opts?: {
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
extensions?: string[];
|
|
44
|
+
contextId?: string;
|
|
45
|
+
taskId?: string;
|
|
46
|
+
}): Promise<SendResult>;
|
|
47
|
+
getTask(id: string): Promise<TaskV1>;
|
|
48
|
+
/** Poll until the task is terminal or the deadline passes; the last task seen is returned either way. */
|
|
49
|
+
awaitTask(id: string, opts?: {
|
|
50
|
+
timeoutMs?: number;
|
|
51
|
+
everyMs?: number;
|
|
52
|
+
}): Promise<TaskV1>;
|
|
53
|
+
/** Send one text message and wait: the reply's text (status message + text artifacts) and the task. */
|
|
54
|
+
ask(text: string, opts?: {
|
|
55
|
+
metadata?: Record<string, unknown>;
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
text: string;
|
|
59
|
+
task?: TaskV1;
|
|
60
|
+
message?: MessageV1;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
export declare function createStandardA2aClient(o: StandardA2aClientOptions): StandardA2aClient;
|
|
64
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/standard/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAmB,MAAM,YAAY,CAAC;AAE1F,OAAO,EAAmJ,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvO,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,0GAA0G;IAC1G,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAOD,wHAAwH;AACxH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAIjG;A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