@loopingai/core 0.3.0 → 0.4.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 +83 -28
- package/dist/a2a/caller.d.ts +24 -0
- package/dist/a2a/caller.d.ts.map +1 -0
- package/dist/a2a/caller.js +34 -0
- package/dist/a2a/caller.js.map +1 -0
- package/dist/a2a/card.d.ts +7 -2
- package/dist/a2a/card.d.ts.map +1 -1
- package/dist/a2a/card.js +16 -7
- package/dist/a2a/card.js.map +1 -1
- package/dist/a2a/index.d.ts +15 -0
- package/dist/a2a/index.d.ts.map +1 -1
- package/dist/a2a/index.js +15 -0
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/notify.d.ts +27 -5
- package/dist/a2a/notify.d.ts.map +1 -1
- package/dist/a2a/notify.js +18 -8
- package/dist/a2a/notify.js.map +1 -1
- package/dist/a2a/push.d.ts +71 -0
- package/dist/a2a/push.d.ts.map +1 -0
- package/dist/a2a/push.js +54 -0
- package/dist/a2a/push.js.map +1 -0
- package/dist/a2a/verify.d.ts +28 -36
- package/dist/a2a/verify.d.ts.map +1 -1
- package/dist/a2a/verify.js +20 -25
- package/dist/a2a/verify.js.map +1 -1
- package/dist/agent/index.d.ts +16 -5
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +16 -5
- package/dist/agent/index.js.map +1 -1
- package/dist/config.d.ts +49 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -3
- package/dist/config.js.map +1 -1
- package/dist/db/models/tasks.d.ts +19 -5
- package/dist/db/models/tasks.d.ts.map +1 -1
- package/dist/db/models/tasks.js +38 -8
- package/dist/db/models/tasks.js.map +1 -1
- package/dist/host/agent.d.ts +217 -0
- package/dist/host/agent.d.ts.map +1 -0
- package/dist/host/agent.js +306 -0
- package/dist/host/agent.js.map +1 -0
- package/dist/host/index.d.ts +21 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +20 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/plugin-host.d.ts +47 -0
- package/dist/host/plugin-host.d.ts.map +1 -0
- package/dist/host/plugin-host.js +2 -0
- package/dist/host/plugin-host.js.map +1 -0
- package/dist/round/agent.d.ts +267 -0
- package/dist/round/agent.d.ts.map +1 -0
- package/dist/round/agent.js +691 -0
- package/dist/round/agent.js.map +1 -0
- package/dist/round/index.d.ts +25 -0
- package/dist/round/index.d.ts.map +1 -0
- package/dist/round/index.js +24 -0
- package/dist/round/index.js.map +1 -0
- package/dist/round/policy.d.ts +99 -0
- package/dist/round/policy.d.ts.map +1 -0
- package/dist/round/policy.js +2 -0
- package/dist/round/policy.js.map +1 -0
- package/dist/round/subagent.d.ts +67 -0
- package/dist/round/subagent.d.ts.map +1 -0
- package/dist/round/subagent.js +91 -0
- package/dist/round/subagent.js.map +1 -0
- package/dist/round/turn.d.ts +231 -0
- package/dist/round/turn.d.ts.map +1 -0
- package/dist/round/turn.js +497 -0
- package/dist/round/turn.js.map +1 -0
- package/dist/round/workflow.d.ts +109 -0
- package/dist/round/workflow.d.ts.map +1 -0
- package/dist/round/workflow.js +316 -0
- package/dist/round/workflow.js.map +1 -0
- package/dist/runtime/index.d.ts +5 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/testing/auth.d.ts.map +1 -1
- package/dist/testing/auth.js +10 -7
- package/dist/testing/auth.js.map +1 -1
- package/dist/testing/fixtures.d.ts +17 -0
- package/dist/testing/fixtures.d.ts.map +1 -1
- package/dist/testing/fixtures.js +17 -0
- package/dist/testing/fixtures.js.map +1 -1
- package/dist/testing/harness.d.ts +98 -0
- package/dist/testing/harness.d.ts.map +1 -0
- package/dist/testing/harness.js +139 -0
- package/dist/testing/harness.js.map +1 -0
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/vcr-store.d.ts +14 -18
- package/dist/testing/vcr-store.d.ts.map +1 -1
- package/dist/testing/vcr-store.js +30 -30
- package/dist/testing/vcr-store.js.map +1 -1
- package/dist/worker/define-agent.d.ts +124 -0
- package/dist/worker/define-agent.d.ts.map +1 -0
- package/dist/worker/define-agent.js +21 -0
- package/dist/worker/define-agent.js.map +1 -0
- package/dist/worker/index.d.ts +29 -4
- package/dist/worker/index.d.ts.map +1 -1
- package/dist/worker/index.js +70 -12
- package/dist/worker/index.js.map +1 -1
- package/package.json +20 -6
package/dist/a2a/verify.d.ts
CHANGED
|
@@ -1,47 +1,39 @@
|
|
|
1
1
|
import { type JWTPayload } from "jose";
|
|
2
|
+
import { type GatewayIdentity } from "@loopingai/a2a-protocol";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Verify the gateway identity JWT (the "B authenticates A" half of zero-trust).
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* The gateway signs a short-lived EdDSA JWT and sends it as a Bearer token on
|
|
7
|
+
* every A2A call. Per RFC 7515 §4.1.2 it embeds a `jku` header pointing at its
|
|
8
|
+
* public JWKS, so remote agents don't need a separately configured JWKS URL —
|
|
9
|
+
* they read `jku` straight from the token and verify the key from there.
|
|
10
|
+
*
|
|
11
|
+
* Security: the `jku` origin is validated against the allowed origins before
|
|
12
|
+
* fetching, preventing key-injection attacks (an attacker cannot point `jku` at
|
|
13
|
+
* their own JWKS and have it accepted).
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* of its siblings.
|
|
15
|
+
* **This file is a guardian.** The four checks below — `jku` present → origin
|
|
16
|
+
* allowlist → `iss` origin equals `jku` origin → `jwtVerify` pinned to EdDSA —
|
|
17
|
+
* are the whole zero-trust contract, and they arrived here byte-identical from
|
|
18
|
+
* two independently-evolved agents. Do not weaken any of them, do not make any
|
|
19
|
+
* of them optional, and do not add a bypass for local development: run a local
|
|
20
|
+
* gateway instead.
|
|
21
21
|
*/
|
|
22
|
-
export declare const TENANT_CLAIM = "https://loopingai.org/tenant";
|
|
23
22
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* Mirrors `RemoteIdentity` in looping-gateway's `src/auth/agent-jwt.ts`.
|
|
23
|
+
* The wire contract — claim names, algorithm, identity shape — comes from
|
|
24
|
+
* `@loopingai/a2a-protocol`, which the gateway also depends on directly.
|
|
27
25
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
26
|
+
* It used to be declared here and again in the gateway, each with a comment
|
|
27
|
+
* saying it must match the other, because the gateway is not an agent and must
|
|
28
|
+
* not import this package. That failed exactly as it always does: one side
|
|
29
|
+
* moved to the `loopingai.org` namespace while the other still minted
|
|
30
|
+
* `https://looping.ai/tenant`, verification read an empty tenant, and every
|
|
31
|
+
* request 401'd with both builds green.
|
|
32
|
+
*
|
|
33
|
+
* Re-exported below so nothing downstream of `@loopingai/core/a2a` has to know
|
|
34
|
+
* the split happened — an agent still imports these from here.
|
|
34
35
|
*/
|
|
35
|
-
export
|
|
36
|
-
/** Canonical instance key, e.g. `custom:7:analytics`. */
|
|
37
|
-
key?: string;
|
|
38
|
-
/** Registry name of the logical agent instance. */
|
|
39
|
-
name?: string;
|
|
40
|
-
/** Dispatch kind of the caller (`"custom"` for remote agents). */
|
|
41
|
-
kind?: string;
|
|
42
|
-
/** Workspace the calling agent instance belongs to. */
|
|
43
|
-
workspaceId?: number | null;
|
|
44
|
-
}
|
|
36
|
+
export { IDENTITY_CLAIM, TENANT_CLAIM, type GatewayIdentity } from "@loopingai/a2a-protocol";
|
|
45
37
|
/** Thrown when a gateway token is missing or fails verification. */
|
|
46
38
|
export declare class GatewayAuthError extends Error {
|
|
47
39
|
constructor(message: string);
|
package/dist/a2a/verify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/a2a/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/a2a/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,MAAM,CAAC;AACd,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,cAAc,EACd,YAAY,EACZ,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAEjC,oEAAoE;AACpE,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAcD,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI3D;AAED,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAenE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC;IACT,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAgDD"}
|
package/dist/a2a/verify.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify } from "jose";
|
|
2
|
+
import { A2A_JWS_ALG, readIdentityClaim, readTenantClaim } from "@loopingai/a2a-protocol";
|
|
2
3
|
/**
|
|
3
4
|
* Verify the gateway identity JWT (the "B authenticates A" half of zero-trust).
|
|
4
5
|
*
|
|
@@ -18,29 +19,21 @@ import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify } from
|
|
|
18
19
|
* of them optional, and do not add a bypass for local development: run a local
|
|
19
20
|
* gateway instead.
|
|
20
21
|
*/
|
|
21
|
-
/** Algorithm the gateway signs with — reject anything else. */
|
|
22
|
-
const ALG = "EdDSA";
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* The wire contract — claim names, algorithm, identity shape — comes from
|
|
24
|
+
* `@loopingai/a2a-protocol`, which the gateway also depends on directly.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* Default namespaced claim naming the **tenant** the gateway minted this token
|
|
33
|
-
* for — which of the agents on this origin it authorizes the call to reach.
|
|
26
|
+
* It used to be declared here and again in the gateway, each with a comment
|
|
27
|
+
* saying it must match the other, because the gateway is not an agent and must
|
|
28
|
+
* not import this package. That failed exactly as it always does: one side
|
|
29
|
+
* moved to the `loopingai.org` namespace while the other still minted
|
|
30
|
+
* `https://looping.ai/tenant`, verification read an empty tenant, and every
|
|
31
|
+
* request 401'd with both builds green.
|
|
34
32
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* which agent on it. This claim is the only thing that can, which is why the
|
|
38
|
-
* Worker refuses a token that omits it rather than falling back to a default.
|
|
39
|
-
* Without it `tenant` would be an unauthenticated field in the request body,
|
|
40
|
-
* and a token legitimately issued for one agent could be replayed against any
|
|
41
|
-
* of its siblings.
|
|
33
|
+
* Re-exported below so nothing downstream of `@loopingai/core/a2a` has to know
|
|
34
|
+
* the split happened — an agent still imports these from here.
|
|
42
35
|
*/
|
|
43
|
-
export
|
|
36
|
+
export { IDENTITY_CLAIM, TENANT_CLAIM } from "@loopingai/a2a-protocol";
|
|
44
37
|
/** Thrown when a gateway token is missing or fails verification. */
|
|
45
38
|
export class GatewayAuthError extends Error {
|
|
46
39
|
constructor(message) {
|
|
@@ -125,15 +118,17 @@ export async function verifyGatewayToken(token, opts) {
|
|
|
125
118
|
const { payload } = await jwtVerify(token, jwksFor(jku), {
|
|
126
119
|
issuer: allowedOrigins,
|
|
127
120
|
audience: opts.audience,
|
|
128
|
-
algorithms: [
|
|
121
|
+
algorithms: [A2A_JWS_ALG]
|
|
129
122
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
// Read through the protocol package's readers rather than indexing the
|
|
124
|
+
// payload here: they are where "an absent or malformed claim yields an
|
|
125
|
+
// empty value, never a default" has its single implementation, and the
|
|
126
|
+
// emptiness is load-bearing — `createA2AWorker` compares the tenant against
|
|
127
|
+
// the one the request body addressed, and `""` matches none of them.
|
|
133
128
|
return {
|
|
134
129
|
payload,
|
|
135
|
-
identity,
|
|
136
|
-
tenant:
|
|
130
|
+
identity: readIdentityClaim(payload, opts.identityClaim),
|
|
131
|
+
tenant: readTenantClaim(payload, opts.tenantClaim)
|
|
137
132
|
};
|
|
138
133
|
}
|
|
139
134
|
catch (err) {
|
package/dist/a2a/verify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/a2a/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,qBAAqB,EACrB,SAAS,EAEV,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/a2a/verify.ts"],"names":[],"mappings":"AAAA,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,CACxB,eAAe,SAAS,yCAAyC,CAClE,CAAC;QACJ,CAAC;QACD,0EAA0E;QAC1E,gEAAgE;QAChE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QACzC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,gBAAgB,CACxB,eAAe,SAAS,gCAAgC,SAAS,GAAG,CACrE,CAAC;QACJ,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;YACvD,MAAM,EAAE,cAAc;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,CAAC,WAAW,CAAC;SAC1B,CAAC,CAAC;QACH,uEAAuE;QACvE,uEAAuE;QACvE,uEAAuE;QACvE,4EAA4E;QAC5E,qEAAqE;QACrE,OAAO;YACL,OAAO;YACP,QAAQ,EAAE,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC;YACxD,MAAM,EAAE,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC;SACnD,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,gBAAgB;YAAE,MAAM,GAAG,CAAC;QAC/C,MAAM,IAAI,gBAAgB,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@loopingai/core/agent` — the primitives a loop is built from.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* The session, the model pair with its fallback, the budget, and the
|
|
5
|
+
* control-tool abstraction that turns "the model called something that ends the
|
|
6
|
+
* round" into a checked value. Everything both predecessor loops needed
|
|
7
|
+
* identically, and nothing about how a round is shaped.
|
|
8
|
+
*
|
|
9
|
+
* This subpath ships **no loop** — that is what makes it importable by one. A
|
|
10
|
+
* loop module needs these primitives without also pulling in a Durable Object
|
|
11
|
+
* base class and drizzle, which is why `LoopingAgent` lives in
|
|
12
|
+
* `@loopingai/core/host` and the delegating round loop in
|
|
13
|
+
* `@loopingai/core/round`.
|
|
14
|
+
*
|
|
15
|
+
* Core as a whole *does* now ship a loop, opt-in, in `/round`. The rule it
|
|
16
|
+
* still keeps is narrower and better: **core ships no prompt copy and no
|
|
17
|
+
* policy** — see `AGENTS.md`, "The line core does not cross". An agent that
|
|
18
|
+
* wants a different round shape imports none of `/round` and builds it from
|
|
19
|
+
* exactly what is here.
|
|
9
20
|
*/
|
|
10
21
|
export { newTurnBudget, stepAllowance, type TurnBudget } from "./budget.js";
|
|
11
22
|
export { createModelRuntime, type GatewayMetadata, type ModelOverrides, type ModelPair, type ModelRuntime, type ModelRuntimeDeps } from "./model.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;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
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@loopingai/core/agent` — the primitives a loop is built from.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* The session, the model pair with its fallback, the budget, and the
|
|
5
|
+
* control-tool abstraction that turns "the model called something that ends the
|
|
6
|
+
* round" into a checked value. Everything both predecessor loops needed
|
|
7
|
+
* identically, and nothing about how a round is shaped.
|
|
8
|
+
*
|
|
9
|
+
* This subpath ships **no loop** — that is what makes it importable by one. A
|
|
10
|
+
* loop module needs these primitives without also pulling in a Durable Object
|
|
11
|
+
* base class and drizzle, which is why `LoopingAgent` lives in
|
|
12
|
+
* `@loopingai/core/host` and the delegating round loop in
|
|
13
|
+
* `@loopingai/core/round`.
|
|
14
|
+
*
|
|
15
|
+
* Core as a whole *does* now ship a loop, opt-in, in `/round`. The rule it
|
|
16
|
+
* still keeps is narrower and better: **core ships no prompt copy and no
|
|
17
|
+
* policy** — see `AGENTS.md`, "The line core does not cross". An agent that
|
|
18
|
+
* wants a different round shape imports none of `/round` and builds it from
|
|
19
|
+
* exactly what is here.
|
|
9
20
|
*/
|
|
10
21
|
export { newTurnBudget, stepAllowance } from "./budget.js";
|
|
11
22
|
export { createModelRuntime } from "./model.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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;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/config.d.ts
CHANGED
|
@@ -13,11 +13,29 @@
|
|
|
13
13
|
*/
|
|
14
14
|
/** Model ids and per-call generation settings. */
|
|
15
15
|
export interface ModelConfig {
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Workers AI model for the tool loop. Must support function calling.
|
|
18
|
+
*
|
|
19
|
+
* **Required — core ships no default.** Which model an agent runs on is the
|
|
20
|
+
* single most consequential thing about it: it sets the cost of every turn,
|
|
21
|
+
* the tool-calling reliability the whole control-tool design rests on, and the
|
|
22
|
+
* failure modes the fallback exists to escape. A default here would be core
|
|
23
|
+
* making that choice on a consumer's behalf, silently, and being wrong for
|
|
24
|
+
* most of them — the same reason core ships no prompt copy.
|
|
25
|
+
*
|
|
26
|
+
* It is also the value most likely to age badly. A model id baked into a
|
|
27
|
+
* published package survives every deprecation until someone bumps the
|
|
28
|
+
* package; one written in the agent that uses it is read by whoever owns the
|
|
29
|
+
* bill.
|
|
30
|
+
*/
|
|
17
31
|
chatModelId: string;
|
|
18
32
|
/**
|
|
19
|
-
* Tried when the primary throws.
|
|
20
|
-
*
|
|
33
|
+
* Tried when the primary throws. **Required — core ships no default.**
|
|
34
|
+
*
|
|
35
|
+
* Should be a *different vendor and family* — a same-family fallback shares
|
|
36
|
+
* the failure mode you are falling back from, which makes it a retry wearing
|
|
37
|
+
* a costume. Core cannot pick this for you precisely because it depends on
|
|
38
|
+
* what you chose as primary.
|
|
21
39
|
*/
|
|
22
40
|
fallbackChatModelId: string;
|
|
23
41
|
/** AI Gateway slug; `"default"` auto-provisions on first request. */
|
|
@@ -117,15 +135,39 @@ export interface CoreConfig {
|
|
|
117
135
|
maxSubtasks: number;
|
|
118
136
|
session: SessionConfig;
|
|
119
137
|
}
|
|
138
|
+
/** The two ids an agent must choose for itself. Core has no opinion. */
|
|
139
|
+
export type RequiredModelIds = Pick<ModelConfig, "chatModelId" | "fallbackChatModelId">;
|
|
140
|
+
/**
|
|
141
|
+
* The baseline, which is everything core *does* still have an opinion about.
|
|
142
|
+
*
|
|
143
|
+
* Note what is missing: the model pair. This type is `CoreConfig` minus those
|
|
144
|
+
* two ids precisely so that no value of it can supply them — a default nobody
|
|
145
|
+
* declared is how an agent ends up billing a model its author never chose.
|
|
146
|
+
*/
|
|
147
|
+
export type CoreConfigBaseline = Omit<CoreConfig, "model"> & {
|
|
148
|
+
model: Omit<ModelConfig, keyof RequiredModelIds>;
|
|
149
|
+
};
|
|
120
150
|
/**
|
|
121
151
|
* A working baseline. Every value is overridable; none is a ceiling. These are
|
|
122
152
|
* the values both predecessor agents converged on in production, so they are a
|
|
123
153
|
* reasonable place to start rather than an opinion about your domain.
|
|
154
|
+
*
|
|
155
|
+
* **It carries no model ids.** See {@link ModelConfig.chatModelId}.
|
|
156
|
+
*/
|
|
157
|
+
export declare const DEFAULT_CORE_CONFIG: CoreConfigBaseline;
|
|
158
|
+
/**
|
|
159
|
+
* One level of optionality per nested group — enough for a config this shallow.
|
|
160
|
+
*
|
|
161
|
+
* `model` is the exception, and deliberately not optional: an agent must name
|
|
162
|
+
* its own primary and fallback. That is a compile error rather than a runtime
|
|
163
|
+
* one, so the omission is found while writing the agent rather than on the first
|
|
164
|
+
* request it serves.
|
|
124
165
|
*/
|
|
125
|
-
export declare const DEFAULT_CORE_CONFIG: CoreConfig;
|
|
126
|
-
/** One level of optionality per nested group — enough for a config this shallow. */
|
|
127
166
|
export type CoreConfigOverrides = {
|
|
128
|
-
[K in keyof CoreConfig]?: CoreConfig[K] extends object ? Partial<CoreConfig[K]> : CoreConfig[K];
|
|
167
|
+
[K in Exclude<keyof CoreConfig, "model">]?: CoreConfig[K] extends object ? Partial<CoreConfig[K]> : CoreConfig[K];
|
|
168
|
+
} & {
|
|
169
|
+
/** Required: the two model ids, plus any generation setting you want changed. */
|
|
170
|
+
model: RequiredModelIds & Partial<Omit<ModelConfig, keyof RequiredModelIds>>;
|
|
129
171
|
};
|
|
130
172
|
export declare class ConfigError extends Error {
|
|
131
173
|
constructor(message: string);
|
|
@@ -138,5 +180,5 @@ export declare class ConfigError extends Error {
|
|
|
138
180
|
* not call it per-request: the point of resolving is that every module downstream
|
|
139
181
|
* reads the same object.
|
|
140
182
|
*/
|
|
141
|
-
export declare function resolveConfig(overrides
|
|
183
|
+
export declare function resolveConfig(overrides: CoreConfigOverrides): CoreConfig;
|
|
142
184
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;OAcG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,eAAe,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;;;;OAaG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,iEAAiE;IACjE,eAAe,EAAE,WAAW,CAAC;IAC7B;;;;OAIG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,WAAW,EACX,aAAa,GAAG,qBAAqB,CACtC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG;IAC3D,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,gBAAgB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAoBjC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG;KAC/B,CAAC,IAAI,OAAO,CAAC,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,MAAM,GACpE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GACtB,UAAU,CAAC,CAAC,CAAC;CAClB,GAAG;IACF,iFAAiF;IACjF,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,gBAAgB,CAAC,CAAC,CAAC;CAC9E,CAAC;AAEF,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,mBAAmB,GAAG,UAAU,CAsExE"}
|
package/dist/config.js
CHANGED
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
* A working baseline. Every value is overridable; none is a ceiling. These are
|
|
16
16
|
* the values both predecessor agents converged on in production, so they are a
|
|
17
17
|
* reasonable place to start rather than an opinion about your domain.
|
|
18
|
+
*
|
|
19
|
+
* **It carries no model ids.** See {@link ModelConfig.chatModelId}.
|
|
18
20
|
*/
|
|
19
21
|
export const DEFAULT_CORE_CONFIG = {
|
|
20
22
|
model: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
// Not a model: an AI Gateway slug, and `"default"` is Cloudflare's own
|
|
24
|
+
// auto-provision behaviour rather than a choice core is making for anyone.
|
|
23
25
|
aiGatewayId: "default",
|
|
24
26
|
maxOutputTokens: 16_384,
|
|
25
27
|
reasoningEffort: "medium"
|
|
@@ -50,7 +52,7 @@ export class ConfigError extends Error {
|
|
|
50
52
|
* not call it per-request: the point of resolving is that every module downstream
|
|
51
53
|
* reads the same object.
|
|
52
54
|
*/
|
|
53
|
-
export function resolveConfig(overrides
|
|
55
|
+
export function resolveConfig(overrides) {
|
|
54
56
|
const config = {
|
|
55
57
|
model: { ...DEFAULT_CORE_CONFIG.model, ...overrides.model },
|
|
56
58
|
mainAgentLimits: {
|
|
@@ -70,6 +72,26 @@ export function resolveConfig(overrides = {}) {
|
|
|
70
72
|
throw new ConfigError(`${name} must be a positive number, got ${value}`);
|
|
71
73
|
}
|
|
72
74
|
};
|
|
75
|
+
// The type already requires both ids; this catches the JavaScript consumer,
|
|
76
|
+
// the `as CoreConfigOverrides` cast, and the empty string — which typechecks
|
|
77
|
+
// and then reaches Workers AI as a model that does not exist, failing on the
|
|
78
|
+
// first generation with a binding error that names nothing useful.
|
|
79
|
+
const modelId = (value, name) => {
|
|
80
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
81
|
+
throw new ConfigError(`model.${name} is required and must be a non-empty model id — core ` +
|
|
82
|
+
`ships no default, because which model an agent runs on is the agent's ` +
|
|
83
|
+
`most consequential choice and cannot be made on its behalf`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
modelId(config.model.chatModelId, "chatModelId");
|
|
87
|
+
modelId(config.model.fallbackChatModelId, "fallbackChatModelId");
|
|
88
|
+
// A fallback identical to the primary is a retry wearing a costume: it shares
|
|
89
|
+
// the outage, the rate limit and the deprecation you are falling back from.
|
|
90
|
+
if (config.model.chatModelId === config.model.fallbackChatModelId) {
|
|
91
|
+
throw new ConfigError(`model.fallbackChatModelId must differ from model.chatModelId (both are ` +
|
|
92
|
+
`'${config.model.chatModelId}') — a same-model fallback shares every ` +
|
|
93
|
+
`failure mode you are falling back from`);
|
|
94
|
+
}
|
|
73
95
|
positive(config.mainAgentLimits.maxTurns, "mainAgentLimits.maxTurns");
|
|
74
96
|
positive(config.mainAgentLimits.maxWallMs, "mainAgentLimits.maxWallMs");
|
|
75
97
|
positive(config.subagentLimits.maxTurns, "subagentLimits.maxTurns");
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmJH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAuB;IACrD,KAAK,EAAE;QACL,uEAAuE;QACvE,2EAA2E;QAC3E,WAAW,EAAE,SAAS;QACtB,eAAe,EAAE,MAAM;QACvB,eAAe,EAAE,QAAQ;KAC1B;IACD,eAAe,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE;IACzD,cAAc,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,MAAM,EAAE;IACxD,gBAAgB,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC;IACd,OAAO,EAAE;QACP,eAAe,EAAE,IAAI;QACrB,kBAAkB,EAAE,MAAM;QAC1B,iBAAiB,EAAE,KAAK;QACxB,iBAAiB,EACf,8EAA8E;YAC9E,sEAAsE;KACzE;CACF,CAAC;AAmBF,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,SAA8B;IAC1D,MAAM,MAAM,GAAe;QACzB,KAAK,EAAE,EAA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C9E,4EAA4E;IAC5E,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAClE,MAAM,IAAI,WAAW,CACnB,yEAAyE;YACvE,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,0CAA0C;YACtE,wCAAwC,CAC3C,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACtE,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;IACxE,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,yBAAyB,CAAC,CAAC;IACpE,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC;IACtE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IACtD,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAEhE,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM,QAAQ,GACZ,MAAM,CAAC,OAAO,CAAC,kBAAkB,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACvE,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,IAAI,WAAW,CACnB,gFAAgF,QAAQ,IAAI;YAC1F,wDAAwD,CAC3D,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -68,8 +68,16 @@ export declare function makeTasks(db: DB): {
|
|
|
68
68
|
* it. That closes the window between a workflow's terminal build and its
|
|
69
69
|
* callback — the read-check-write is synchronous here, so a `CancelTask`
|
|
70
70
|
* landing mid-delivery makes this return `false` and the notify never fires.
|
|
71
|
-
*
|
|
72
|
-
*
|
|
71
|
+
*
|
|
72
|
+
* The reverse direction is guarded too: writing `canceled` over an already
|
|
73
|
+
* `completed`/`failed` row is refused, mirroring {@link cancel}'s own source
|
|
74
|
+
* guard. Without it, a cancellation landing between the Workflow's `complete`
|
|
75
|
+
* and `notify` steps — separate, independently-retried steps — could flip
|
|
76
|
+
* storage to canceled while `deliver()` still posts the cached completed
|
|
77
|
+
* task it already built, the exact race this guard exists to close. Writing
|
|
78
|
+
* `canceled` onto a `submitted`/`working` row, or re-writing it onto an
|
|
79
|
+
* already-`canceled` one, stays allowed: that is how the a2a-js handler's own
|
|
80
|
+
* cancel branch records the cancellation.
|
|
73
81
|
*/
|
|
74
82
|
save(task: Task): boolean;
|
|
75
83
|
/**
|
|
@@ -81,9 +89,15 @@ export declare function makeTasks(db: DB): {
|
|
|
81
89
|
*/
|
|
82
90
|
markWorking(taskId: string): "ok" | "canceled";
|
|
83
91
|
/**
|
|
84
|
-
* Flip the task to `canceled` and return it
|
|
85
|
-
*
|
|
86
|
-
*
|
|
92
|
+
* Flip the task to `canceled` and return it, or `null` if the row is not
|
|
93
|
+
* eligible — unknown, or already past `submitted`/`working`. Guarding the
|
|
94
|
+
* source state (not just the destination, as {@link save} does) matters
|
|
95
|
+
* because `complete`/`notify` are separate Workflow steps: without this, a
|
|
96
|
+
* cancellation landing between them would flip an already-`completed` or
|
|
97
|
+
* `failed` row to `canceled` right as `deliver()` posts the terminal
|
|
98
|
+
* callback it had already built, silently rewriting a delivered result.
|
|
99
|
+
* Terminal: once this lands, {@link save} refuses every non-canceled write,
|
|
100
|
+
* so no completed or failed callback can be built from this row afterwards.
|
|
87
101
|
*/
|
|
88
102
|
cancel(taskId: string): PlainTask | null;
|
|
89
103
|
/** Delete all tasks older than 30 days (called by the maintenance cron). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../src/db/models/tasks.ts"],"names":[],"mappings":"AAAA,OA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MnC,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,gBAAgB,EAAE,OAAO,CAAC;IAC1B,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAE7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,EAAE;IAiC5B;;;;OAIG;iBACU;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,SAAS;IAwBb,6EAA6E;gBACjE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIrC;;;OAGG;gBACS,aAAa,GAAG;QAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAiCrE;;;;;;;;;;;;;;;;;;;OAmBG;eACQ,IAAI,GAAG,OAAO;IA0BzB;;;;;;OAMG;wBACiB,MAAM,GAAG,IAAI,GAAG,UAAU;IAe9C;;;;;;;;;;OAUG;mBACY,MAAM,GAAG,SAAS,GAAG,IAAI;IAoBxC,4EAA4E;eACjE,IAAI;EAKlB"}
|
package/dist/db/models/tasks.js
CHANGED
|
@@ -133,14 +133,33 @@ export function makeTasks(db) {
|
|
|
133
133
|
* it. That closes the window between a workflow's terminal build and its
|
|
134
134
|
* callback — the read-check-write is synchronous here, so a `CancelTask`
|
|
135
135
|
* landing mid-delivery makes this return `false` and the notify never fires.
|
|
136
|
-
*
|
|
137
|
-
*
|
|
136
|
+
*
|
|
137
|
+
* The reverse direction is guarded too: writing `canceled` over an already
|
|
138
|
+
* `completed`/`failed` row is refused, mirroring {@link cancel}'s own source
|
|
139
|
+
* guard. Without it, a cancellation landing between the Workflow's `complete`
|
|
140
|
+
* and `notify` steps — separate, independently-retried steps — could flip
|
|
141
|
+
* storage to canceled while `deliver()` still posts the cached completed
|
|
142
|
+
* task it already built, the exact race this guard exists to close. Writing
|
|
143
|
+
* `canceled` onto a `submitted`/`working` row, or re-writing it onto an
|
|
144
|
+
* already-`canceled` one, stays allowed: that is how the a2a-js handler's own
|
|
145
|
+
* cancel branch records the cancellation.
|
|
138
146
|
*/
|
|
139
147
|
save(task) {
|
|
140
148
|
const existing = readOne(task.id);
|
|
141
|
-
if (existing
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
if (existing === null) {
|
|
150
|
+
upsert(task);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
const existingState = stateOf(existing);
|
|
154
|
+
const incomingState = stateOf(task);
|
|
155
|
+
if (existingState === TaskState.TASK_STATE_CANCELED &&
|
|
156
|
+
incomingState !== TaskState.TASK_STATE_CANCELED) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if (incomingState === TaskState.TASK_STATE_CANCELED &&
|
|
160
|
+
existingState !== TaskState.TASK_STATE_SUBMITTED &&
|
|
161
|
+
existingState !== TaskState.TASK_STATE_WORKING &&
|
|
162
|
+
existingState !== TaskState.TASK_STATE_CANCELED) {
|
|
144
163
|
return false;
|
|
145
164
|
}
|
|
146
165
|
upsert(task);
|
|
@@ -171,14 +190,25 @@ export function makeTasks(db) {
|
|
|
171
190
|
return "ok";
|
|
172
191
|
},
|
|
173
192
|
/**
|
|
174
|
-
* Flip the task to `canceled` and return it
|
|
175
|
-
*
|
|
176
|
-
*
|
|
193
|
+
* Flip the task to `canceled` and return it, or `null` if the row is not
|
|
194
|
+
* eligible — unknown, or already past `submitted`/`working`. Guarding the
|
|
195
|
+
* source state (not just the destination, as {@link save} does) matters
|
|
196
|
+
* because `complete`/`notify` are separate Workflow steps: without this, a
|
|
197
|
+
* cancellation landing between them would flip an already-`completed` or
|
|
198
|
+
* `failed` row to `canceled` right as `deliver()` posts the terminal
|
|
199
|
+
* callback it had already built, silently rewriting a delivered result.
|
|
200
|
+
* Terminal: once this lands, {@link save} refuses every non-canceled write,
|
|
201
|
+
* so no completed or failed callback can be built from this row afterwards.
|
|
177
202
|
*/
|
|
178
203
|
cancel(taskId) {
|
|
179
204
|
const task = readOne(taskId);
|
|
180
205
|
if (!task)
|
|
181
206
|
return null;
|
|
207
|
+
const state = stateOf(task);
|
|
208
|
+
if (state !== TaskState.TASK_STATE_SUBMITTED &&
|
|
209
|
+
state !== TaskState.TASK_STATE_WORKING) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
182
212
|
task.status = {
|
|
183
213
|
...task.status,
|
|
184
214
|
state: TaskState.TASK_STATE_CANCELED,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/db/models/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAY,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,SAAS,MAAM;IACb,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAkBD;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,IAAU;IAChC,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,SAAS,CAAC,sBAAsB,CAAC;AAChE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