@loopingai/core 0.1.2 → 0.2.0
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/README.md +73 -11
- package/dist/a2a/card.d.ts +35 -0
- package/dist/a2a/card.d.ts.map +1 -1
- package/dist/a2a/card.js +41 -3
- package/dist/a2a/card.js.map +1 -1
- package/dist/a2a/context.d.ts +9 -3
- package/dist/a2a/context.d.ts.map +1 -1
- package/dist/a2a/context.js +11 -4
- package/dist/a2a/context.js.map +1 -1
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a/index.d.ts.map +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/notify.d.ts +11 -2
- package/dist/a2a/notify.d.ts.map +1 -1
- package/dist/a2a/notify.js +12 -3
- package/dist/a2a/notify.js.map +1 -1
- package/dist/a2a/verify.d.ts +23 -2
- package/dist/a2a/verify.d.ts.map +1 -1
- package/dist/a2a/verify.js +26 -3
- package/dist/a2a/verify.js.map +1 -1
- package/dist/agent/history.d.ts +15 -0
- package/dist/agent/history.d.ts.map +1 -1
- package/dist/agent/history.js +17 -0
- package/dist/agent/history.js.map +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/env.d.ts +10 -2
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +10 -2
- package/dist/env.js.map +1 -1
- package/dist/runtime/index.d.ts +8 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/testing/auth.d.ts +23 -0
- package/dist/testing/auth.d.ts.map +1 -1
- package/dist/testing/auth.js +11 -3
- package/dist/testing/auth.js.map +1 -1
- package/dist/testing/fixtures.d.ts +21 -0
- package/dist/testing/fixtures.d.ts.map +1 -1
- package/dist/testing/fixtures.js +21 -0
- package/dist/testing/fixtures.js.map +1 -1
- package/dist/worker/index.d.ts +142 -3
- package/dist/worker/index.d.ts.map +1 -1
- package/dist/worker/index.js +152 -29
- package/dist/worker/index.js.map +1 -1
- package/package.json +5 -1
package/dist/agent/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export { newTurnBudget, stepAllowance, type TurnBudget } from "./budget.js";
|
|
11
11
|
export { createModelRuntime, type GatewayMetadata, type ModelOverrides, type ModelPair, type ModelRuntime, type ModelRuntimeDeps } from "./model.js";
|
|
12
12
|
export { appendOnce, buildAgentSession, notifyingCompaction, type AgentSessionOptions, type SessionHost, type SessionLike } from "./session.js";
|
|
13
|
-
export { deterministicSessionMessage, finalReplyMessageId, parseRoundAckMessageId, parseTurn, roundAckMessageId, sessionText, taskUserMessageId, toModelMessages, type ParsedTurn } from "./history.js";
|
|
13
|
+
export { deterministicSessionMessage, finalReplyMessageId, parseRoundAckMessageId, parseTurn, roundAckMessageId, sessionMessage, sessionText, taskUserMessageId, toModelMessages, type ParsedTurn } from "./history.js";
|
|
14
14
|
export { buildIntermediateContentHandler, isTransientAiError, type OnContent } from "./inference.js";
|
|
15
15
|
export { ControlCallError, controlTools, controlToolSet, type ControlTool, type TurnDecision } from "./control.js";
|
|
16
16
|
export { FINAL_REPLY_TOOL_NAME, finalReplyInputSchema, finalReplyTool } from "./final-reply.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAClB,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACf,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAClB,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACf,MAAM,kBAAkB,CAAC"}
|
package/dist/agent/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export { newTurnBudget, stepAllowance } from "./budget.js";
|
|
11
11
|
export { createModelRuntime } from "./model.js";
|
|
12
12
|
export { appendOnce, buildAgentSession, notifyingCompaction } from "./session.js";
|
|
13
|
-
export { deterministicSessionMessage, finalReplyMessageId, parseRoundAckMessageId, parseTurn, roundAckMessageId, sessionText, taskUserMessageId, toModelMessages } from "./history.js";
|
|
13
|
+
export { deterministicSessionMessage, finalReplyMessageId, parseRoundAckMessageId, parseTurn, roundAckMessageId, sessionMessage, sessionText, taskUserMessageId, toModelMessages } from "./history.js";
|
|
14
14
|
export { buildIntermediateContentHandler, isTransientAiError } from "./inference.js";
|
|
15
15
|
export { ControlCallError, controlTools, controlToolSet } from "./control.js";
|
|
16
16
|
export { FINAL_REPLY_TOOL_NAME, finalReplyInputSchema, finalReplyTool } from "./final-reply.js";
|
package/dist/agent/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAMnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EAIpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EAGf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACf,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAMnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EAIpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,cAAc,EAGf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACf,MAAM,kBAAkB,CAAC"}
|
package/dist/env.d.ts
CHANGED
|
@@ -9,8 +9,16 @@
|
|
|
9
9
|
* with no cast.
|
|
10
10
|
*
|
|
11
11
|
* The two secrets are the zero-trust contract and are the only names core
|
|
12
|
-
* insists on; everything else is passed in.
|
|
13
|
-
*
|
|
12
|
+
* insists on; everything else is passed in. Even these are only a *default*:
|
|
13
|
+
* `createA2AWorker`'s `secrets` option reads them from wherever a consumer keeps
|
|
14
|
+
* them, so a Worker whose bindings are already named something else does not
|
|
15
|
+
* have to rename them.
|
|
16
|
+
*
|
|
17
|
+
* That is *all* it does. The secrets are read once per request and belong to the
|
|
18
|
+
* deployment, not to an agent: several agents share one Worker as tenants of one
|
|
19
|
+
* origin, and they share this one signing identity with it. What separates them
|
|
20
|
+
* is the tenant claim on the gateway token, not a key apiece. See
|
|
21
|
+
* {@link file://./worker/index.ts}.
|
|
14
22
|
*/
|
|
15
23
|
/** Workers AI, backing the chat loop (and whatever a plugin runs on it). */
|
|
16
24
|
export interface AiEnv {
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,EAAE,CAAC;CACR;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,kEAAkE;AAClE,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,aAAa,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBzD"}
|
package/dist/env.js
CHANGED
|
@@ -9,8 +9,16 @@
|
|
|
9
9
|
* with no cast.
|
|
10
10
|
*
|
|
11
11
|
* The two secrets are the zero-trust contract and are the only names core
|
|
12
|
-
* insists on; everything else is passed in.
|
|
13
|
-
*
|
|
12
|
+
* insists on; everything else is passed in. Even these are only a *default*:
|
|
13
|
+
* `createA2AWorker`'s `secrets` option reads them from wherever a consumer keeps
|
|
14
|
+
* them, so a Worker whose bindings are already named something else does not
|
|
15
|
+
* have to rename them.
|
|
16
|
+
*
|
|
17
|
+
* That is *all* it does. The secrets are read once per request and belong to the
|
|
18
|
+
* deployment, not to an agent: several agents share one Worker as tenants of one
|
|
19
|
+
* origin, and they share this one signing identity with it. What separates them
|
|
20
|
+
* is the tenant claim on the gateway token, not a key apiece. See
|
|
21
|
+
* {@link file://./worker/index.ts}.
|
|
14
22
|
*/
|
|
15
23
|
/**
|
|
16
24
|
* Parse `GATEWAY_ORIGINS`. Accepts a JSON array (the documented form) or a
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA8BH;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC1D,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,sCAAuC,GAAa,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACrE,OAAO,MAAkB,CAAC;AAC5B,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -101,8 +101,15 @@ export interface CreateAgentRuntimeOptions {
|
|
|
101
101
|
* Verify that every secret and binding the plugins declared is actually
|
|
102
102
|
* present, given the Worker `env`. Off by default because core cannot know
|
|
103
103
|
* which of a consumer's bindings are optional; pass `env` to switch it on.
|
|
104
|
+
*
|
|
105
|
+
* Typed `object`, not `Record<string, unknown>`, and that is not looseness.
|
|
106
|
+
* `Env` is the ambient interface `wrangler types` generates into a consumer's
|
|
107
|
+
* `worker-configuration.d.ts`; an interface has no index signature, so it does
|
|
108
|
+
* not satisfy `Record<string, unknown>` and every consumer would have to cast
|
|
109
|
+
* their own `this.env` to pass it. Requiring a cast to opt into a *check* is
|
|
110
|
+
* how the check goes unused.
|
|
104
111
|
*/
|
|
105
|
-
env?:
|
|
112
|
+
env?: object;
|
|
106
113
|
}
|
|
107
114
|
/**
|
|
108
115
|
* Thrown when the installed plugins and the host disagree — a contract-version
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;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AqB,CAAC,CAAC;IAClC,wEAAwE;IACxE,OAAO,CAAC,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,YAAY,CAoNd"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -59,13 +59,14 @@ export function createAgentRuntime(options) {
|
|
|
59
59
|
...new Set(plugins.flatMap((p) => [...(p.requires?.bindings ?? [])]))
|
|
60
60
|
];
|
|
61
61
|
if (options.env) {
|
|
62
|
+
const env = options.env;
|
|
62
63
|
const missing = [];
|
|
63
64
|
for (const plugin of plugins) {
|
|
64
65
|
for (const name of [
|
|
65
66
|
...(plugin.requires?.secrets ?? []),
|
|
66
67
|
...(plugin.requires?.bindings ?? [])
|
|
67
68
|
]) {
|
|
68
|
-
const value =
|
|
69
|
+
const value = env[name];
|
|
69
70
|
if (value === undefined || value === null || value === "") {
|
|
70
71
|
missing.push(`${name} (required by "${plugin.key}")`);
|
|
71
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uBAAuB,EAOxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,sBAAsB,EAEvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,gBAAgB,EAEjB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EAAE,mBAAmB,EAA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G,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,MAAM,EAAE,cAAc;gBAAE,OAAO,EAAE,CAAC;YACvC,OAAO,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAmB,CAAC;QAC9D,CAAC;QAED,KAAK,CAAC,YAAY,CAChB,GAAwB,EACxB,MAA6B;YAE7B,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,EAAE,YAAY;gBAAE,OAAO,MAAM,CAAC;YACzC,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,GAA0B;YACtC,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,MAAM,EAAE,OAAO;gBAAE,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/testing/auth.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export interface GatewayTokenOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Who the token is for. Defaults to an agent at the default RPC path
|
|
4
|
+
* (`${AGENT_ORIGIN}${A2A_RPC_PATH}`), which is what a gateway mints: the
|
|
5
|
+
* agent's **endpoint**, not its origin.
|
|
6
|
+
*
|
|
7
|
+
* Pass this explicitly when a spec mounts an agent somewhere else — an agent
|
|
8
|
+
* at `/proactive/a2a` expects that string and refuses this default, which is
|
|
9
|
+
* the whole point of scoping the audience to the endpoint.
|
|
10
|
+
*/
|
|
2
11
|
audience?: string;
|
|
3
12
|
issuer?: string;
|
|
4
13
|
/** Relative string ("5m"), absolute epoch seconds, or Date. Past values expire the token. */
|
|
@@ -6,7 +15,21 @@ export interface GatewayTokenOptions {
|
|
|
6
15
|
identity?: Record<string, unknown>;
|
|
7
16
|
/** Claim the identity is carried in. Defaults to core's `IDENTITY_CLAIM`. */
|
|
8
17
|
identityClaim?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Which agent on the target origin this token authorizes, defaulting to
|
|
20
|
+
* `"main"`.
|
|
21
|
+
*
|
|
22
|
+
* The tenants of one deployment share an endpoint and therefore an audience,
|
|
23
|
+
* so this claim is the only thing distinguishing them. Set it to a *different*
|
|
24
|
+
* tenant than the request addresses to exercise the replay case; set it to
|
|
25
|
+
* `""` to mint a token carrying no tenant at all, which is rejected.
|
|
26
|
+
*/
|
|
27
|
+
tenant?: string;
|
|
28
|
+
/** Claim the tenant is carried in. Defaults to core's `TENANT_CLAIM`. */
|
|
29
|
+
tenantClaim?: string;
|
|
9
30
|
}
|
|
31
|
+
/** The tenant `makeGatewayToken` authorizes unless a spec says otherwise. */
|
|
32
|
+
export declare const TEST_TENANT = "main";
|
|
10
33
|
/** Sign a short-lived EdDSA gateway JWT using the test gateway key. */
|
|
11
34
|
export declare function makeGatewayToken(options?: GatewayTokenOptions): Promise<string>;
|
|
12
35
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/testing/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/testing/auth.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,6EAA6E;AAC7E,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC,uEAAuE;AACvE,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
|
package/dist/testing/auth.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { importJWK, SignJWT } from "jose";
|
|
2
|
-
import { IDENTITY_CLAIM } from "../a2a/verify.js";
|
|
2
|
+
import { IDENTITY_CLAIM, TENANT_CLAIM } from "../a2a/verify.js";
|
|
3
|
+
import { A2A_RPC_PATH } from "../a2a/card.js";
|
|
3
4
|
import { TEST_GATEWAY_PRIVATE_JWK, GATEWAY_ORIGIN, AGENT_ORIGIN } from "./fixtures.js";
|
|
5
|
+
/** The tenant `makeGatewayToken` authorizes unless a spec says otherwise. */
|
|
6
|
+
export const TEST_TENANT = "main";
|
|
4
7
|
/** Sign a short-lived EdDSA gateway JWT using the test gateway key. */
|
|
5
8
|
export async function makeGatewayToken(options = {}) {
|
|
6
9
|
const privateKey = await importJWK(TEST_GATEWAY_PRIVATE_JWK, "EdDSA");
|
|
10
|
+
const tenant = options.tenant ?? TEST_TENANT;
|
|
7
11
|
return new SignJWT({
|
|
8
12
|
[options.identityClaim ?? IDENTITY_CLAIM]: options.identity ?? {
|
|
9
13
|
key: "custom:1:test-agent",
|
|
10
14
|
name: "Test Agent",
|
|
11
15
|
kind: "custom",
|
|
12
16
|
workspaceId: 1
|
|
13
|
-
}
|
|
17
|
+
},
|
|
18
|
+
// An empty tenant omits the claim entirely rather than signing `""` — that
|
|
19
|
+
// is the "gateway too old to scope its tokens" case, and it must be
|
|
20
|
+
// rejected rather than treated as a wildcard.
|
|
21
|
+
...(tenant ? { [options.tenantClaim ?? TENANT_CLAIM]: tenant } : {})
|
|
14
22
|
})
|
|
15
23
|
.setProtectedHeader({
|
|
16
24
|
alg: "EdDSA",
|
|
@@ -18,7 +26,7 @@ export async function makeGatewayToken(options = {}) {
|
|
|
18
26
|
jku: `${GATEWAY_ORIGIN}/.well-known/jwks.json`
|
|
19
27
|
})
|
|
20
28
|
.setIssuer(options.issuer ?? GATEWAY_ORIGIN)
|
|
21
|
-
.setAudience(options.audience ?? AGENT_ORIGIN)
|
|
29
|
+
.setAudience(options.audience ?? `${AGENT_ORIGIN}${A2A_RPC_PATH}`)
|
|
22
30
|
.setExpirationTime(options.expiresIn ?? "5m")
|
|
23
31
|
.sign(privateKey);
|
|
24
32
|
}
|
package/dist/testing/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/testing/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/testing/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,YAAY,EACb,MAAM,eAAe,CAAC;AAiCvB,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAElC,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAA+B,EAAE;IAEjC,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC;IAC7C,OAAO,IAAI,OAAO,CAAC;QACjB,CAAC,OAAO,CAAC,aAAa,IAAI,cAAc,CAAC,EAAE,OAAO,CAAC,QAAQ,IAAI;YAC7D,GAAG,EAAE,qBAAqB;YAC1B,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,CAAC;SACf;QACD,2EAA2E;QAC3E,oEAAoE;QACpE,8CAA8C;QAC9C,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrE,CAAC;SACC,kBAAkB,CAAC;QAClB,GAAG,EAAE,OAAO;QACZ,GAAG,EAAE,wBAAwB,CAAC,GAAG;QACjC,GAAG,EAAE,GAAG,cAAc,wBAAwB;KAC/C,CAAC;SACD,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,cAAc,CAAC;SAC3C,WAAW,CAAC,OAAO,CAAC,QAAQ,IAAI,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC;SACjE,iBAAiB,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;SAC5C,IAAI,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@loopingai/core/testing/fixtures` — the **realm-neutral** slice of the
|
|
3
|
+
* harness: fixed keys, origins, and task/message builders.
|
|
4
|
+
*
|
|
5
|
+
* Its own subpath because it is the one part a consumer's `vitest.config.ts`
|
|
6
|
+
* needs, and that file runs in **Node**. The `/testing` barrel pulls in
|
|
7
|
+
* `cloudflare:test` (DO helpers) and `vitest` (the VCR spec hooks), so importing
|
|
8
|
+
* it from a config fails at load with `ERR_UNSUPPORTED_ESM_URL_SCHEME` before a
|
|
9
|
+
* single test runs. Nothing here imports either, so it is safe from a config, a
|
|
10
|
+
* spec, or a plain Node script.
|
|
11
|
+
*
|
|
12
|
+
* Seeding the required secrets from these values is the intended use:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* // vitest.config.ts
|
|
16
|
+
* import { GATEWAY_ORIGIN, TEST_AGENT_PRIVATE_JWK } from "@loopingai/core/testing/fixtures";
|
|
17
|
+
*
|
|
18
|
+
* process.env.A2A_SIGNING_KEY ??= JSON.stringify(TEST_AGENT_PRIVATE_JWK);
|
|
19
|
+
* process.env.GATEWAY_ORIGINS ??= JSON.stringify([GATEWAY_ORIGIN]);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
import { type JWK } from "jose";
|
|
2
23
|
import { type Message, type Task, type TaskState } from "@a2a-js/sdk";
|
|
3
24
|
/** The gateway origin used in all tests. Must match vitest.config.ts and the MockAgent setup. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/testing/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAQ,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5E,iGAAiG;AACjG,eAAO,MAAM,cAAc,yBAAyB,CAAC;AAErD,6EAA6E;AAC7E,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAE/C,kEAAkE;AAClE,eAAO,MAAM,sBAAsB,EAAE,GAAG,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAMvD,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,wBAAwB,EAAE,GAAG,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAMzD,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,OAAO,GAChB,WAAW,CAAC,IAAI,CAAC,QAAQ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AAED,iDAAiD;AACjD,wBAAgB,QAAQ,CACtB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,OAAO,GAChB,IAAI,CASN"}
|
package/dist/testing/fixtures.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@loopingai/core/testing/fixtures` — the **realm-neutral** slice of the
|
|
3
|
+
* harness: fixed keys, origins, and task/message builders.
|
|
4
|
+
*
|
|
5
|
+
* Its own subpath because it is the one part a consumer's `vitest.config.ts`
|
|
6
|
+
* needs, and that file runs in **Node**. The `/testing` barrel pulls in
|
|
7
|
+
* `cloudflare:test` (DO helpers) and `vitest` (the VCR spec hooks), so importing
|
|
8
|
+
* it from a config fails at load with `ERR_UNSUPPORTED_ESM_URL_SCHEME` before a
|
|
9
|
+
* single test runs. Nothing here imports either, so it is safe from a config, a
|
|
10
|
+
* spec, or a plain Node script.
|
|
11
|
+
*
|
|
12
|
+
* Seeding the required secrets from these values is the intended use:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* // vitest.config.ts
|
|
16
|
+
* import { GATEWAY_ORIGIN, TEST_AGENT_PRIVATE_JWK } from "@loopingai/core/testing/fixtures";
|
|
17
|
+
*
|
|
18
|
+
* process.env.A2A_SIGNING_KEY ??= JSON.stringify(TEST_AGENT_PRIVATE_JWK);
|
|
19
|
+
* process.env.GATEWAY_ORIGINS ??= JSON.stringify([GATEWAY_ORIGIN]);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
import {} from "jose";
|
|
2
23
|
import { Role } from "@a2a-js/sdk";
|
|
3
24
|
/** The gateway origin used in all tests. Must match vitest.config.ts and the MockAgent setup. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/testing/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,MAAM,C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AAS;KACpB,CAAC;AACJ,CAAC"}
|
package/dist/worker/index.d.ts
CHANGED
|
@@ -18,20 +18,134 @@ import { type A2ASecretsEnv } from "../env.js";
|
|
|
18
18
|
*
|
|
19
19
|
* No secret is ever shared in either direction: trust flows entirely on domains
|
|
20
20
|
* and asymmetric (Ed25519) signatures over public JWKS.
|
|
21
|
+
*
|
|
22
|
+
* **Several agents share one Worker, addressed by `tenant`.** They share one
|
|
23
|
+
* origin, one endpoint, one signing key and one card at the well-known path;
|
|
24
|
+
* what differs is the tenant id on every request. That is the A2A mechanism for
|
|
25
|
+
* exactly this — `AgentInterface.tenant` is "an opaque string used for routing
|
|
26
|
+
* requests to a specific agent or tenant when multiple agents are served behind
|
|
27
|
+
* a single A2A endpoint", and §8.3.2 requires a client to send the value the
|
|
28
|
+
* selected interface declared.
|
|
29
|
+
*
|
|
30
|
+
* A tenant is **required on every request**. There is no default and no
|
|
31
|
+
* implicit routing: an absent tenant is an error, because guessing one would
|
|
32
|
+
* mean picking an agent the caller never named.
|
|
33
|
+
*
|
|
34
|
+
* This replaces mounting a handler per path prefix. That could not work: the
|
|
35
|
+
* card is a **well-known URI**, which RFC 8615 defines per-authority, so only
|
|
36
|
+
* one card per origin is discoverable at the registered path — a gateway
|
|
37
|
+
* resolving `…/.well-known/agent-card.json` against the origin found whichever
|
|
38
|
+
* agent owned the bare path and pinned *its* key for all of them.
|
|
39
|
+
*
|
|
40
|
+
* Three routes:
|
|
41
|
+
*
|
|
42
|
+
* 1. `GET jwksPath` — the card-signing public JWKS, resolving every card's
|
|
43
|
+
* `jku`.
|
|
44
|
+
* 2. `GET …/.well-known/agent-card.json` — the signed **stub** card for the
|
|
45
|
+
* origin. Matched by suffix, since that path is fixed by the spec.
|
|
46
|
+
* 3. `POST rpcPath` — gateway-authenticated JSON-RPC, routed to the named
|
|
47
|
+
* tenant. `GetExtendedAgentCard` returns that tenant's own signed card;
|
|
48
|
+
* everything else runs a turn against its Durable Object.
|
|
49
|
+
*
|
|
50
|
+
* Two independent checks keep one tenant's traffic out of another's:
|
|
51
|
+
* `audience` proves the token was minted for this deployment, and
|
|
52
|
+
* {@link file://../a2a/verify.ts TENANT_CLAIM} proves it was minted for *this
|
|
53
|
+
* agent on it*. The second is what makes `tenant` more than an unauthenticated
|
|
54
|
+
* routing hint in the request body.
|
|
21
55
|
*/
|
|
22
56
|
/** Default path serving the card-signing public JWKS (the card's `jku`). */
|
|
23
57
|
export declare const JWKS_PATH = "/.well-known/jwks.json";
|
|
24
|
-
|
|
58
|
+
/** The two secrets a mount signs and verifies with, already read off `env`. */
|
|
59
|
+
export interface A2ASecrets {
|
|
60
|
+
/** Ed25519 private JWK, as JSON. See {@link A2ASecretsEnv.A2A_SIGNING_KEY}. */
|
|
61
|
+
signingKey: string;
|
|
62
|
+
/** Origin allowlist. See {@link A2ASecretsEnv.GATEWAY_ORIGINS}. */
|
|
63
|
+
gatewayOrigins: string;
|
|
64
|
+
}
|
|
65
|
+
/** One agent served on this origin — everything that differs between tenants. */
|
|
66
|
+
export interface TenantAgent {
|
|
25
67
|
/** The transport-independent half of this agent's card. */
|
|
26
68
|
manifest: AgentManifest;
|
|
27
69
|
/** Resolve the agent DO stub for a verified caller. */
|
|
28
70
|
resolveAgent: AgentResolver;
|
|
29
71
|
/** Start the durable turn. Must be idempotent — see {@link TurnStarter}. */
|
|
30
72
|
startTurn: TurnStarter;
|
|
73
|
+
}
|
|
74
|
+
export interface A2AWorkerOptions<TEnv = A2ASecretsEnv> {
|
|
75
|
+
/**
|
|
76
|
+
* The **stub** card served at the well-known path.
|
|
77
|
+
*
|
|
78
|
+
* It describes the origin, not an agent. Every agent here is a tenant and its
|
|
79
|
+
* card is reached through `GetExtendedAgentCard`, so this card exists to be
|
|
80
|
+
* the one conformant, signed AgentCard at the URI RFC 8615 and the A2A IANA
|
|
81
|
+
* registration reserve — advertising the endpoint, the protocol binding and
|
|
82
|
+
* `extendedAgentCard`.
|
|
83
|
+
*
|
|
84
|
+
* It cannot enumerate the tenants: a card carries one interface entry and
|
|
85
|
+
* spec §8.3.2 has clients take the first, so listing siblings there would
|
|
86
|
+
* just make every client address the same one. Put their names in
|
|
87
|
+
* `description` for a human, and register them out of band.
|
|
88
|
+
*/
|
|
89
|
+
manifest: AgentManifest;
|
|
90
|
+
/**
|
|
91
|
+
* The agents on this origin, keyed by tenant id. At least one.
|
|
92
|
+
*
|
|
93
|
+
* The id is opaque to the protocol — "an opaque string used for routing
|
|
94
|
+
* requests to a specific agent or tenant when multiple agents are served
|
|
95
|
+
* behind a single A2A endpoint". A caller names one on every request and this
|
|
96
|
+
* Worker refuses a request that does not.
|
|
97
|
+
*
|
|
98
|
+
* The tenant chooses *which agent*; the verified `identity.key` still chooses
|
|
99
|
+
* *which instance of it*, so two callers of one tenant stay in separate
|
|
100
|
+
* Durable Objects exactly as before.
|
|
101
|
+
*/
|
|
102
|
+
tenants: Record<string, TenantAgent>;
|
|
31
103
|
/** Path serving the public JWKS. Defaults to {@link JWKS_PATH}. */
|
|
32
104
|
jwksPath?: string;
|
|
33
105
|
/** Path this agent answers JSON-RPC on. Defaults to `/a2a`. */
|
|
34
106
|
rpcPath?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Where to read this deployment's two secrets. Defaults to the documented
|
|
109
|
+
* names, `env.A2A_SIGNING_KEY` and `env.GATEWAY_ORIGINS`.
|
|
110
|
+
*
|
|
111
|
+
* There is **one signing key per origin**, not one per tenant: the card is
|
|
112
|
+
* per-origin now, so the key the gateway pins is too. Nothing was lost — the
|
|
113
|
+
* tenants share a Worker and an `env`, so they could always read each other's
|
|
114
|
+
* secrets, and separate keys never expressed a boundary that existed.
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* secrets: (env) => ({
|
|
118
|
+
* signingKey: env.AGENT_KEY,
|
|
119
|
+
* gatewayOrigins: env.ALLOWED_GATEWAYS
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* Renaming does not weaken anything: the same key is still Ed25519, still
|
|
124
|
+
* signs the cards and every callback JWT, and its public half is still what
|
|
125
|
+
* the gateway pins. Only where it is read from changes.
|
|
126
|
+
*/
|
|
127
|
+
secrets?: (env: TEnv) => A2ASecrets;
|
|
128
|
+
/**
|
|
129
|
+
* The audience a gateway JWT must carry.
|
|
130
|
+
*
|
|
131
|
+
* Defaults to this deployment's **own endpoint** — `${origin}${rpcPath}`, the
|
|
132
|
+
* same URL its cards advertise as their interface — and that default is
|
|
133
|
+
* almost certainly what you want. Setting this is for a gateway that mints
|
|
134
|
+
* something else.
|
|
135
|
+
*
|
|
136
|
+
* The audience is one half of a two-sided contract: whatever is required here
|
|
137
|
+
* has to be exactly what the calling gateway *mints*, and a mismatch is a 401
|
|
138
|
+
* on every request. looping-gateway mints
|
|
139
|
+
* `new URL(agent.a2aEndpoint).origin + pathname`, which is what this default
|
|
140
|
+
* matches.
|
|
141
|
+
*
|
|
142
|
+
* It proves the token was minted for **this deployment**, and deliberately
|
|
143
|
+
* says nothing about which agent on it — every tenant shares one endpoint and
|
|
144
|
+
* therefore one audience. {@link file://../a2a/verify.ts TENANT_CLAIM} is what
|
|
145
|
+
* separates them, and is the check to look at when reasoning about one agent
|
|
146
|
+
* spending another's token.
|
|
147
|
+
*/
|
|
148
|
+
audience?: string | ((url: URL) => string);
|
|
35
149
|
/**
|
|
36
150
|
* Advertise `securitySchemes` on the card. **Defaults to `false`** — see
|
|
37
151
|
* `BuildCardOptions.advertiseSecuritySchemes` for why, and read that note
|
|
@@ -40,6 +154,17 @@ export interface A2AWorkerOptions {
|
|
|
40
154
|
advertiseSecuritySchemes?: boolean;
|
|
41
155
|
/** Claim carrying the caller identity. Defaults to the Looping namespace. */
|
|
42
156
|
identityClaim?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Claim carrying the authorized tenant. Defaults to the Looping namespace.
|
|
159
|
+
*
|
|
160
|
+
* Both claim names are one side of the same contract as `audience`: whatever
|
|
161
|
+
* is named here has to be exactly what the calling gateway *mints*. Override
|
|
162
|
+
* them together, or not at all — a deployment fronted by something other than
|
|
163
|
+
* looping-gateway that renames only the identity claim keeps reading the
|
|
164
|
+
* tenant from a key its gateway never sets, and every request 401s on the
|
|
165
|
+
* empty-tenant comparison below.
|
|
166
|
+
*/
|
|
167
|
+
tenantClaim?: string;
|
|
43
168
|
/**
|
|
44
169
|
* Require a `taskPushNotificationConfig` on every `SendMessage`.
|
|
45
170
|
*
|
|
@@ -54,9 +179,23 @@ export interface A2AWorkerOptions {
|
|
|
54
179
|
* Build the Worker `fetch` handler.
|
|
55
180
|
*
|
|
56
181
|
* ```ts
|
|
57
|
-
* const handler = createA2AWorker({
|
|
182
|
+
* const handler = createA2AWorker({
|
|
183
|
+
* manifest: hostManifest,
|
|
184
|
+
* tenants: {
|
|
185
|
+
* reactive: { manifest, resolveAgent: getAgent, startTurn }
|
|
186
|
+
* }
|
|
187
|
+
* });
|
|
58
188
|
* export default { fetch: handler } satisfies ExportedHandler<Env>;
|
|
59
189
|
* ```
|
|
190
|
+
*
|
|
191
|
+
* Two overloads, because `secrets` is optional for exactly one shape of `env`.
|
|
192
|
+
* An `env` carrying the two documented names needs no reader; anything else has
|
|
193
|
+
* to say where its keys live, and the type system is where that gets enforced —
|
|
194
|
+
* the alternative is a `parsePrivateJwk` failure on the first request, which is
|
|
195
|
+
* both later and much harder to read.
|
|
60
196
|
*/
|
|
61
|
-
export declare function createA2AWorker<TEnv extends A2ASecretsEnv>(options: A2AWorkerOptions): (request: Request, env: TEnv) => Promise<Response>;
|
|
197
|
+
export declare function createA2AWorker<TEnv extends A2ASecretsEnv>(options: A2AWorkerOptions<TEnv>): (request: Request, env: TEnv) => Promise<Response>;
|
|
198
|
+
export declare function createA2AWorker<TEnv extends object>(options: A2AWorkerOptions<TEnv> & {
|
|
199
|
+
secrets: (env: TEnv) => A2ASecrets;
|
|
200
|
+
}): (request: Request, env: TEnv) => Promise<Response>;
|
|
62
201
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,SAAS,2BAA2B,CAAC;AAKlD,+EAA+E;AAC/E,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,QAAQ,EAAE,aAAa,CAAC;IACxB,uDAAuD;IACvD,YAAY,EAAE,aAAa,CAAC;IAC5B,4EAA4E;IAC5E,SAAS,EAAE,WAAW,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,aAAa;IACpD;;;;;;;;;;;;;OAaG;IACH,QAAQ,EAAE,aAAa,CAAC;IACxB;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,U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