@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.
Files changed (104) hide show
  1. package/README.md +83 -28
  2. package/dist/a2a/caller.d.ts +24 -0
  3. package/dist/a2a/caller.d.ts.map +1 -0
  4. package/dist/a2a/caller.js +34 -0
  5. package/dist/a2a/caller.js.map +1 -0
  6. package/dist/a2a/card.d.ts +7 -2
  7. package/dist/a2a/card.d.ts.map +1 -1
  8. package/dist/a2a/card.js +16 -7
  9. package/dist/a2a/card.js.map +1 -1
  10. package/dist/a2a/index.d.ts +15 -0
  11. package/dist/a2a/index.d.ts.map +1 -1
  12. package/dist/a2a/index.js +15 -0
  13. package/dist/a2a/index.js.map +1 -1
  14. package/dist/a2a/notify.d.ts +27 -5
  15. package/dist/a2a/notify.d.ts.map +1 -1
  16. package/dist/a2a/notify.js +18 -8
  17. package/dist/a2a/notify.js.map +1 -1
  18. package/dist/a2a/push.d.ts +71 -0
  19. package/dist/a2a/push.d.ts.map +1 -0
  20. package/dist/a2a/push.js +54 -0
  21. package/dist/a2a/push.js.map +1 -0
  22. package/dist/a2a/verify.d.ts +28 -36
  23. package/dist/a2a/verify.d.ts.map +1 -1
  24. package/dist/a2a/verify.js +20 -25
  25. package/dist/a2a/verify.js.map +1 -1
  26. package/dist/agent/index.d.ts +16 -5
  27. package/dist/agent/index.d.ts.map +1 -1
  28. package/dist/agent/index.js +16 -5
  29. package/dist/agent/index.js.map +1 -1
  30. package/dist/config.d.ts +49 -7
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +25 -3
  33. package/dist/config.js.map +1 -1
  34. package/dist/db/models/tasks.d.ts +19 -5
  35. package/dist/db/models/tasks.d.ts.map +1 -1
  36. package/dist/db/models/tasks.js +38 -8
  37. package/dist/db/models/tasks.js.map +1 -1
  38. package/dist/host/agent.d.ts +217 -0
  39. package/dist/host/agent.d.ts.map +1 -0
  40. package/dist/host/agent.js +306 -0
  41. package/dist/host/agent.js.map +1 -0
  42. package/dist/host/index.d.ts +21 -0
  43. package/dist/host/index.d.ts.map +1 -0
  44. package/dist/host/index.js +20 -0
  45. package/dist/host/index.js.map +1 -0
  46. package/dist/host/plugin-host.d.ts +47 -0
  47. package/dist/host/plugin-host.d.ts.map +1 -0
  48. package/dist/host/plugin-host.js +2 -0
  49. package/dist/host/plugin-host.js.map +1 -0
  50. package/dist/round/agent.d.ts +267 -0
  51. package/dist/round/agent.d.ts.map +1 -0
  52. package/dist/round/agent.js +691 -0
  53. package/dist/round/agent.js.map +1 -0
  54. package/dist/round/index.d.ts +25 -0
  55. package/dist/round/index.d.ts.map +1 -0
  56. package/dist/round/index.js +24 -0
  57. package/dist/round/index.js.map +1 -0
  58. package/dist/round/policy.d.ts +99 -0
  59. package/dist/round/policy.d.ts.map +1 -0
  60. package/dist/round/policy.js +2 -0
  61. package/dist/round/policy.js.map +1 -0
  62. package/dist/round/subagent.d.ts +67 -0
  63. package/dist/round/subagent.d.ts.map +1 -0
  64. package/dist/round/subagent.js +91 -0
  65. package/dist/round/subagent.js.map +1 -0
  66. package/dist/round/turn.d.ts +231 -0
  67. package/dist/round/turn.d.ts.map +1 -0
  68. package/dist/round/turn.js +497 -0
  69. package/dist/round/turn.js.map +1 -0
  70. package/dist/round/workflow.d.ts +109 -0
  71. package/dist/round/workflow.d.ts.map +1 -0
  72. package/dist/round/workflow.js +316 -0
  73. package/dist/round/workflow.js.map +1 -0
  74. package/dist/runtime/index.d.ts +5 -1
  75. package/dist/runtime/index.d.ts.map +1 -1
  76. package/dist/runtime/index.js.map +1 -1
  77. package/dist/testing/auth.d.ts.map +1 -1
  78. package/dist/testing/auth.js +10 -7
  79. package/dist/testing/auth.js.map +1 -1
  80. package/dist/testing/fixtures.d.ts +17 -0
  81. package/dist/testing/fixtures.d.ts.map +1 -1
  82. package/dist/testing/fixtures.js +17 -0
  83. package/dist/testing/fixtures.js.map +1 -1
  84. package/dist/testing/harness.d.ts +98 -0
  85. package/dist/testing/harness.d.ts.map +1 -0
  86. package/dist/testing/harness.js +139 -0
  87. package/dist/testing/harness.js.map +1 -0
  88. package/dist/testing/index.d.ts +2 -1
  89. package/dist/testing/index.d.ts.map +1 -1
  90. package/dist/testing/index.js +2 -1
  91. package/dist/testing/index.js.map +1 -1
  92. package/dist/testing/vcr-store.d.ts +14 -18
  93. package/dist/testing/vcr-store.d.ts.map +1 -1
  94. package/dist/testing/vcr-store.js +30 -30
  95. package/dist/testing/vcr-store.js.map +1 -1
  96. package/dist/worker/define-agent.d.ts +124 -0
  97. package/dist/worker/define-agent.d.ts.map +1 -0
  98. package/dist/worker/define-agent.js +21 -0
  99. package/dist/worker/define-agent.js.map +1 -0
  100. package/dist/worker/index.d.ts +29 -4
  101. package/dist/worker/index.d.ts.map +1 -1
  102. package/dist/worker/index.js +70 -12
  103. package/dist/worker/index.js.map +1 -1
  104. package/package.json +20 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/round/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAIzC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAmB,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAiB1E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EACL,qBAAqB,EACrB,OAAO,EAGR,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAgB,cAIpB,SAAQ,YAAkB;IAClB,aAAa,CAAoB;IAo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C,EAAE;QACR,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,SAAS,EAAE,CAAC,CAAC,SAAS;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `@loopingai/core/round` — the delegating round loop.
3
+ *
4
+ * A round agent answers the user or hands work to isolated subagents, waits for
5
+ * their durable results, and decides again. This subpath ships the whole
6
+ * mechanism of that: the round loop and its primary→fallback→repair ladder
7
+ * ({@link runTurn}), the durable Workflow orchestration with its DAG wave
8
+ * scheduler ({@link runHandleTask}), the Durable Object body ({@link
9
+ * RoundAgentBase}), and the subagent facet host ({@link RecipeSubagentHost}).
10
+ *
11
+ * **Opt-in, and its own subpath on purpose.** An agent whose turn is a single
12
+ * inference — one that never delegates — imports none of this and carries none of
13
+ * it in its bundle. Core's root barrel does not re-export it.
14
+ *
15
+ * **Core still ships no prompt copy.** Everything the model and the user read
16
+ * comes from the {@link RoundPolicy} an agent supplies: the round contract, the
17
+ * budget-spent note, and the three user-facing strings. That is the line — core
18
+ * owns the machine, you own the words.
19
+ */
20
+ export type { RoundPolicy } from "./policy.js";
21
+ export { RoundAgentBase } from "./agent.js";
22
+ export { RecipeSubagentHost, type SubagentClass } from "./subagent.js";
23
+ export { runHandleTask, type HandleTaskDeps, type HandleTaskParams } from "./workflow.js";
24
+ export { buildTurnInstructions, joinSuccessfulBranches, renderTurnMessages, runTurn, type RoundMode, type RunTurnArgs, type RunTurnOutcome, type TurnInstructions } from "./turn.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/round/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EACL,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,OAAO,EACP,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@loopingai/core/round` — the delegating round loop.
3
+ *
4
+ * A round agent answers the user or hands work to isolated subagents, waits for
5
+ * their durable results, and decides again. This subpath ships the whole
6
+ * mechanism of that: the round loop and its primary→fallback→repair ladder
7
+ * ({@link runTurn}), the durable Workflow orchestration with its DAG wave
8
+ * scheduler ({@link runHandleTask}), the Durable Object body ({@link
9
+ * RoundAgentBase}), and the subagent facet host ({@link RecipeSubagentHost}).
10
+ *
11
+ * **Opt-in, and its own subpath on purpose.** An agent whose turn is a single
12
+ * inference — one that never delegates — imports none of this and carries none of
13
+ * it in its bundle. Core's root barrel does not re-export it.
14
+ *
15
+ * **Core still ships no prompt copy.** Everything the model and the user read
16
+ * comes from the {@link RoundPolicy} an agent supplies: the round contract, the
17
+ * budget-spent note, and the three user-facing strings. That is the line — core
18
+ * owns the machine, you own the words.
19
+ */
20
+ export { RoundAgentBase } from "./agent.js";
21
+ export { RecipeSubagentHost } from "./subagent.js";
22
+ export { runHandleTask } from "./workflow.js";
23
+ export { buildTurnInstructions, joinSuccessfulBranches, renderTurnMessages, runTurn } from "./turn.js";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/round/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAsB,MAAM,eAAe,CAAC;AAEvE,OAAO,EACL,aAAa,EAGd,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,OAAO,EAKR,MAAM,WAAW,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { AgentLimits } from "../config.js";
2
+ /**
3
+ * Everything about a round loop that is **yours**, not core's.
4
+ *
5
+ * The round loop in this subpath is mechanism: the DAG wave scheduler, chunked
6
+ * subagent execution, cancellation ordering, idempotent recovery, the
7
+ * primary→fallback→repair ladder. None of it varies between agents, and every
8
+ * place it *did* vary between two agents in one repo turned out to be a bug.
9
+ *
10
+ * What genuinely varies is what the model is told and what the user reads — and
11
+ * core ships no prompt copy, deliberately, so that no run ever executes under an
12
+ * identity nobody chose. This interface is that boundary, made explicit: supply
13
+ * the words, get the machine.
14
+ *
15
+ * ```ts
16
+ * export const policy: RoundPolicy = {
17
+ * roundContract: ({ typeKeys, maxSubtasks }) => `…`,
18
+ * finalRoundNote: (limits) => `…`,
19
+ * copy: {
20
+ * taskFailed: "Sorry — something went wrong handling that request.",
21
+ * recoveredReply: "Working on your request.",
22
+ * partialNote: "Some parts of this request could not be completed…"
23
+ * }
24
+ * };
25
+ * ```
26
+ *
27
+ * Nothing here is optional and nothing has a default. A stub that returned an
28
+ * empty contract would produce a round the model has no way to end correctly,
29
+ * and a lending default would be exactly the house prompt copy core refuses to
30
+ * have.
31
+ *
32
+ * ## Each prompt string owns its own leading separator
33
+ *
34
+ * {@link roundContract} and {@link finalRoundNote} are concatenated directly
35
+ * onto text that came from somewhere else — the soul, the caller context, and
36
+ * for `finalRoundNote` the open contract itself. The composition adds nothing
37
+ * between them, so **start each with a blank line** (`\n\n`, or a template
38
+ * literal opening on an empty line, which is what the starter does):
39
+ *
40
+ * ```ts
41
+ * roundContract: () => `
42
+ *
43
+ * # Answering this request
44
+ * …`
45
+ * ```
46
+ *
47
+ * Return `"# Answering this request…"` with no leading newline and the model
48
+ * reads `Calling workspace: 1.# Answering this request` — a run-together line
49
+ * that costs nothing to produce and is invisible in every test that does not
50
+ * assert on the rendered prompt.
51
+ *
52
+ * Core does not insert the separator for you, because these are *your* sections
53
+ * and a section that cannot control its own spacing cannot control its shape —
54
+ * a policy that legitimately wants a single newline, or continues the previous
55
+ * paragraph, has no way to say so once core has decided.
56
+ */
57
+ export interface RoundPolicy {
58
+ /**
59
+ * The round contract: how a round ends, and what `delegate` takes. Appended to
60
+ * the soul and the caller context on every round.
61
+ *
62
+ * `typeKeys` is the installed subtask types — the only values `delegate` may
63
+ * name. Per-type guidance is *not* written here: each type declares its own
64
+ * via `SubtaskTypeSpec.delegationGuidance`, and the loop appends it, so this
65
+ * text names no domain.
66
+ */
67
+ roundContract(ctx: {
68
+ typeKeys: readonly string[];
69
+ maxSubtasks: number;
70
+ }): string;
71
+ /**
72
+ * Appended when the task has spent its budget. That round is handed no work
73
+ * tools and no `delegate`, so this explains a constraint the model can already
74
+ * see rather than imposing one.
75
+ */
76
+ finalRoundNote(limits: AgentLimits): string;
77
+ /** The strings a user can actually read. */
78
+ copy: {
79
+ /**
80
+ * User-facing text on a failed Task. The diagnostic is logged separately —
81
+ * this is what the person sees.
82
+ */
83
+ taskFailed: string;
84
+ /**
85
+ * Stand-in acknowledgement for the unreachable case where a round's subtasks
86
+ * are durable but its acknowledgement is not in the Session. Neutral by
87
+ * design: the work is valid and running, so the user gets an honest
88
+ * acknowledgement rather than a failed Task.
89
+ */
90
+ recoveredReply: string;
91
+ /**
92
+ * Appended when a deterministic join has to disclose gaps — both models
93
+ * failed, but earlier branches succeeded and their results are worth
94
+ * delivering.
95
+ */
96
+ partialNote: string;
97
+ };
98
+ }
99
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/round/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,aAAa,CAAC,GAAG,EAAE;QACjB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;QAC5B,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,MAAM,CAAC;IAEX;;;;OAIG;IACH,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IAE5C,4CAA4C;IAC5C,IAAI,EAAE;QACJ;;;WAGG;QACH,UAAU,EAAE,MAAM,CAAC;QACnB;;;;;WAKG;QACH,cAAc,EAAE,MAAM,CAAC;QACvB;;;;WAIG;QACH,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/round/policy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import type { AgentPlugin } from "../contract/plugin.js";
2
+ import type { CoreConfigOverrides } from "../config.js";
3
+ import type { AiEnv } from "../env.js";
4
+ import { RecipeSubagentBase, type SubagentRuntime } from "../subagent/index.js";
5
+ import type { PluginHost } from "../host/plugin-host.js";
6
+ /**
7
+ * The host half of a subagent facet: the same plugins as its parent, assembled
8
+ * into the {@link SubagentRuntime} the base class executes recipes with.
9
+ *
10
+ * `RecipeSubagentBase` already ships the whole body — resumable chunks, the
11
+ * terminal-result cache keyed by request fingerprint, workspace wiring,
12
+ * cancellation, the fingerprint-mismatch contract. All that was ever missing is
13
+ * this assembly, and a Durable Object class is constructed by the runtime, so it
14
+ * cannot take constructor arguments. The two abstract methods are that seam.
15
+ *
16
+ * ## Why the facet builds its own runtime instead of asking its parent
17
+ *
18
+ * The obvious move is to read it off the parent, which already has one. It does
19
+ * not work: the SDK reaches a parent through `this.parentAgent(Cls)`, which is an
20
+ * **RPC stub**, and a `SubagentRuntime` is mostly functions — `models`, the
21
+ * `toolFamilies` builder map, `workspaceBacking`. None of that survives
22
+ * serialization, so the call would return a shape that type-checks and is inert.
23
+ *
24
+ * So each agent gets its own facet class over this base, building the same
25
+ * runtime from the same `plugins.ts` its parent uses:
26
+ *
27
+ * ```ts
28
+ * export class MySubagent extends RecipeSubagentHost<Env> {
29
+ * protected agentConfig() { return MY_CONFIG; }
30
+ * protected agentPlugins(host: PluginHost<Env>) { return plugins(host); }
31
+ * }
32
+ * ```
33
+ *
34
+ * It must be a **named, exported** class, not one produced by a factory: the
35
+ * framework resolves a facet through `ctx.exports[this.constructor.name]`, so an
36
+ * anonymous class breaks the lookup, and so does a bundler that minifies class
37
+ * names.
38
+ *
39
+ * ## Not a bound Durable Object
40
+ *
41
+ * A facet is created beneath its calling agent, so it needs no wrangler binding
42
+ * and no `new_sqlite_classes` entry — only an export from the Worker entry so
43
+ * `ctx.exports` can resolve it. It *does* need a test-only binding, because the
44
+ * Vitest pool only marks bound classes as DO classes.
45
+ */
46
+ export declare abstract class RecipeSubagentHost<TEnv extends Cloudflare.Env & AiEnv = Cloudflare.Env & AiEnv> extends RecipeSubagentBase<TEnv> {
47
+ private _rt?;
48
+ /** This facet's agent config — the same object its parent DO passes. */
49
+ protected abstract agentConfig(): CoreConfigOverrides;
50
+ /** This facet's plugins — the same list its parent DO installs. */
51
+ protected abstract agentPlugins(host: PluginHost<TEnv>): AgentPlugin[];
52
+ /**
53
+ * Built once per facet instance. The base calls this per RPC and documents
54
+ * that an implementation building anything expensive should memoize its own.
55
+ */
56
+ protected subagentRuntime(): SubagentRuntime;
57
+ private buildRuntime;
58
+ }
59
+ /**
60
+ * A **concrete** facet constructor, as `subAgent()` requires one.
61
+ *
62
+ * {@link RecipeSubagentHost} is abstract, and `subAgent()` rightly refuses an
63
+ * abstract class — it is what constructs one. So the seam on the agent side is
64
+ * typed as this: any named subclass below it.
65
+ */
66
+ export type SubagentClass = new (...args: ConstructorParameters<typeof RecipeSubagentBase>) => RecipeSubagentBase;
67
+ //# sourceMappingURL=subagent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../src/round/subagent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8BAAsB,kBAAkB,CACtC,IAAI,SAAS,UAAU,CAAC,GAAG,GAAG,KAAK,GAAG,UAAU,CAAC,GAAG,GAAG,KAAK,CAC5D,SAAQ,kBAAkB,CAAC,IAAI,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,CAAkB;IAE9B,wEAAwE;IACxE,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,mBAAmB;IAErD,mEAAmE;IACnE,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,EAAE;IAEtE;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,eAAe;IAI5C,OAAO,CAAC,YAAY;CAwCrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,KAC1B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,kBAAkB,CAAC,KACtD,kBAAkB,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { createAgentRuntime } from "../runtime/index.js";
2
+ import { createModelRuntime } from "../agent/model.js";
3
+ import { RecipeSubagentBase } from "../subagent/index.js";
4
+ /**
5
+ * The host half of a subagent facet: the same plugins as its parent, assembled
6
+ * into the {@link SubagentRuntime} the base class executes recipes with.
7
+ *
8
+ * `RecipeSubagentBase` already ships the whole body — resumable chunks, the
9
+ * terminal-result cache keyed by request fingerprint, workspace wiring,
10
+ * cancellation, the fingerprint-mismatch contract. All that was ever missing is
11
+ * this assembly, and a Durable Object class is constructed by the runtime, so it
12
+ * cannot take constructor arguments. The two abstract methods are that seam.
13
+ *
14
+ * ## Why the facet builds its own runtime instead of asking its parent
15
+ *
16
+ * The obvious move is to read it off the parent, which already has one. It does
17
+ * not work: the SDK reaches a parent through `this.parentAgent(Cls)`, which is an
18
+ * **RPC stub**, and a `SubagentRuntime` is mostly functions — `models`, the
19
+ * `toolFamilies` builder map, `workspaceBacking`. None of that survives
20
+ * serialization, so the call would return a shape that type-checks and is inert.
21
+ *
22
+ * So each agent gets its own facet class over this base, building the same
23
+ * runtime from the same `plugins.ts` its parent uses:
24
+ *
25
+ * ```ts
26
+ * export class MySubagent extends RecipeSubagentHost<Env> {
27
+ * protected agentConfig() { return MY_CONFIG; }
28
+ * protected agentPlugins(host: PluginHost<Env>) { return plugins(host); }
29
+ * }
30
+ * ```
31
+ *
32
+ * It must be a **named, exported** class, not one produced by a factory: the
33
+ * framework resolves a facet through `ctx.exports[this.constructor.name]`, so an
34
+ * anonymous class breaks the lookup, and so does a bundler that minifies class
35
+ * names.
36
+ *
37
+ * ## Not a bound Durable Object
38
+ *
39
+ * A facet is created beneath its calling agent, so it needs no wrangler binding
40
+ * and no `new_sqlite_classes` entry — only an export from the Worker entry so
41
+ * `ctx.exports` can resolve it. It *does* need a test-only binding, because the
42
+ * Vitest pool only marks bound classes as DO classes.
43
+ */
44
+ export class RecipeSubagentHost extends RecipeSubagentBase {
45
+ _rt;
46
+ /**
47
+ * Built once per facet instance. The base calls this per RPC and documents
48
+ * that an implementation building anything expensive should memoize its own.
49
+ */
50
+ subagentRuntime() {
51
+ return (this._rt ??= this.buildRuntime());
52
+ }
53
+ buildRuntime() {
54
+ const config = this.agentConfig();
55
+ const runtime = createAgentRuntime({
56
+ config,
57
+ plugins: this.agentPlugins({
58
+ env: this.env,
59
+ storage: this.ctx.storage,
60
+ // No caller identity exists down here, and nothing reads one: the
61
+ // per-caller hooks are the parent's surface, never a subagent's. A
62
+ // throwing thunk is the honest encoding — it can only fire if a plugin
63
+ // starts reading caller state on the execution path, which is a design
64
+ // question, not a missing value.
65
+ callerKey: () => {
66
+ throw new Error("a subagent execution has no caller identity — this plugin reads " +
67
+ "per-caller state on a path where none exists");
68
+ },
69
+ primaryModelId: config.model?.chatModelId ?? "",
70
+ fallbackModelId: config.model?.fallbackChatModelId ?? "",
71
+ aiGatewayId: config.model?.aiGatewayId ?? ""
72
+ }),
73
+ env: this.env
74
+ });
75
+ return {
76
+ policy: runtime.policy,
77
+ types: runtime.types,
78
+ models: createModelRuntime({
79
+ ai: this.env.AI,
80
+ config: runtime.config.model
81
+ }),
82
+ toolFamilies: runtime.toolFamilies,
83
+ toolOutputWindow: runtime.config.toolOutputWindow,
84
+ maxOutputTokens: runtime.config.model.maxOutputTokens,
85
+ // Always defined: the plugin that declared a backend, or core's in-memory
86
+ // fallback. So this needs no null check.
87
+ workspaceBacking: runtime.workspaceBacking
88
+ };
89
+ }
90
+ }
91
+ //# sourceMappingURL=subagent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../src/round/subagent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAIzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAwB,MAAM,sBAAsB,CAAC;AAGhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,OAAgB,kBAEpB,SAAQ,kBAAwB;IACxB,GAAG,CAAmB;IAQ9B;;;OAGG;IACO,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,IA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type { ModelMessage, ToolSet } from "ai";
2
+ import type { SessionMessage } from "agents/experimental/memory/session";
3
+ import type { AgentLimits } from "../config.js";
4
+ import type { SubtaskTypeRegistry } from "../subtasks/subtask-types.js";
5
+ import { type SessionLike } from "../agent/session.js";
6
+ import { type OnContent } from "../agent/inference.js";
7
+ import { type TurnBudget } from "../agent/budget.js";
8
+ import type { ModelPair } from "../agent/model.js";
9
+ import { type ReferenceCatalogEntry } from "../subtasks/catalog.js";
10
+ import type { CompositionBranch, SubtaskDraft } from "../subtasks/types.js";
11
+ import type { RoundPolicy } from "./policy.js";
12
+ /**
13
+ * One **round** of the main agent: a single inference over the agent's continuous
14
+ * Session that ends in one of two decisions — answer the user, or delegate.
15
+ *
16
+ * This is the whole task pipeline's control point. The Workflow runs rounds in a
17
+ * loop: a round that delegates gets its Subtask DAG executed and is followed by
18
+ * another round; a round that answers ends the Task. So "compose" is not a
19
+ * separate phase with its own rules — it is simply the round in which the model
20
+ * decides it has enough to answer.
21
+ *
22
+ * Two layers of tools, and the difference is the design:
23
+ *
24
+ * - **Work tools** (whatever the installed plugins offer the main agent, plus the
25
+ * Session's own `set_context`) carry an `execute` and run *inside* the round's
26
+ * tool loop. They never end a round; the model keeps reasoning over their
27
+ * results. Every round gets them except the one the budget forced — looking
28
+ * something up before answering is ordinary work, not a special phase, right up
29
+ * until there is nothing left to spend on it (see {@link RoundMode}).
30
+ * - **Control tools** — `delegate` and `final_reply` — have no `execute`. The call
31
+ * *is* the round's output: the loop halts on it, and for `delegate` the Workflow
32
+ * performs it durably. Because the loop halts, the SDK never validates their
33
+ * input either, so each one checks its own and the round repairs what it rejects
34
+ * — see `agent/control.ts`. A future `escalate` (ask the human) is the same
35
+ * shape: another entry there, another variant of {@link TurnDecision}, another
36
+ * `case` in the Workflow's switch.
37
+ *
38
+ * Nothing forces the *choice*, and that is deliberate. An earlier design pinned
39
+ * `toolChoice` to a specific tool to force delegation in one phase and forbid it in
40
+ * another, which meant a request the main agent was best placed to answer got
41
+ * shipped to a memoryless subagent, and material that came back could only ever be
42
+ * turned into prose. That is still rejected: the model picks its own ending, and
43
+ * delegating twice is allowed.
44
+ *
45
+ * What *is* forced is that the round end in a control call at all —
46
+ * `toolChoice: "required"`, with both endings declared as tools. Plain text used to
47
+ * be an outcome, and it made narration indistinguishable from an answer: a model
48
+ * that wrote "I'll start the game" and emitted no call ended the Task successfully
49
+ * having done nothing. Two named tools is also a much easier discrimination for a
50
+ * small model than prose-versus-tool, which is what the weaker fallback models
51
+ * consistently got wrong.
52
+ *
53
+ * Narration survived that fix by moving house. A round whose results have just come
54
+ * back can still announce its next step *inside* a `final_reply` — "now sending the
55
+ * second one" — and that ends the Task as surely as prose did, having done nothing,
56
+ * while telling the user the opposite. No mechanism can catch it: `final_reply` is a
57
+ * legitimate ending for exactly this round, and only the model knows whether the
58
+ * request is finished. So it is the **round contract** that has to close it — which
59
+ * is why that text is a {@link RoundPolicy} the agent writes, not something core
60
+ * ships.
61
+ *
62
+ * The model reasons over the whole conversation but references it by **catalog
63
+ * index only** — see {@link renderTurnMessages}.
64
+ */
65
+ /**
66
+ * The prompt copy for one configured agent, built once per Durable Object
67
+ * instance.
68
+ *
69
+ * A builder rather than a module-level `const`, because the type enum is a
70
+ * function of the plugins this agent installed, which is a function of `env`,
71
+ * which does not exist at module scope on Workers. The DO memoizes the result.
72
+ */
73
+ export interface TurnInstructions {
74
+ /** Contract + per-type delegation guidance. Appended to soul + caller context. */
75
+ open: string;
76
+ /** Further appended when the budget is spent. */
77
+ final: string;
78
+ }
79
+ /**
80
+ * Build both prompt suffixes for one configured agent.
81
+ *
82
+ * The agent's contract, then whatever the delegable types have to say about being
83
+ * delegated — each declared by the type that owns it (`SubtaskTypeSpec`) and
84
+ * collected by the runtime's registry, so no domain is named by the policy. That
85
+ * is the rule the two prompt fields on a subtask type exist to hold: everything
86
+ * the main agent is told about a domain is declared by the plugin that owns it,
87
+ * never written inside the loop.
88
+ */
89
+ export declare function buildTurnInstructions(policy: RoundPolicy, types: SubtaskTypeRegistry, maxSubtasks: number, limits: AgentLimits): TurnInstructions;
90
+ /**
91
+ * Render the model's view for one round: the conversation, with every earlier
92
+ * round's delegation restored as the call-and-result it actually was, and every
93
+ * referenceable turn marked with the catalog index the model selects it by.
94
+ *
95
+ * One pass, two jobs, because they have to agree. The `[ref N]` markers use
96
+ * `isCatalogEligible` — the same predicate the catalog is numbered with — so a
97
+ * marker and its entry can never drift: compaction summaries (`assistant` role,
98
+ * generated) stay in the messages unmarked, readable for context but structurally
99
+ * uncitable as conversation evidence, which is exactly the intent.
100
+ *
101
+ * A round's acknowledgment is stored as plain assistant text (history is
102
+ * text-only, and stays that way — `sessionText`, the catalog, compaction, and
103
+ * recall all read text parts). So its `delegate` call is re-attached to that
104
+ * message here, and the result appended after it, for this one inference call. The
105
+ * pair is emitted together, anchored on the ack's deterministic id, so a `tool`
106
+ * message can never be orphaned from its call — and an ack that has been compacted
107
+ * away still gets its pair, appended at the end minus the acknowledgment text: a
108
+ * result the model cannot place beats a malformed history.
109
+ *
110
+ * Acks are deliberately **not** catalog-eligible: they are the agent's own
111
+ * scaffolding, and a subtask referencing "I'm on it" as verbatim conversation
112
+ * evidence would be noise. That holds for every ack in the Session, not only the
113
+ * ones this render can pair with branches — see `parseRoundAckMessageId`.
114
+ *
115
+ * Everything here is ephemeral — scaffolding for this call only. Reference text is
116
+ * snapshotted from the catalog, so no `[ref N]` prefix ever reaches a Subtask, and
117
+ * the Session never sees any of this markup.
118
+ */
119
+ export declare function renderTurnMessages(history: SessionMessage[], taskId: string, branches: CompositionBranch[]): {
120
+ messages: ModelMessage[];
121
+ catalog: ReferenceCatalogEntry[];
122
+ };
123
+ /**
124
+ * Deterministic fallback reply: the successful branches' text in ordinal order,
125
+ * plus the policy's short note when some branches did not succeed.
126
+ *
127
+ * Used when a round's inference is unavailable but its predecessors' work is
128
+ * durable. Failing the whole Task because the answering model is down would throw
129
+ * away good results the user asked for.
130
+ */
131
+ export declare function joinSuccessfulBranches(branches: CompositionBranch[], partialNote: string): string;
132
+ /**
133
+ * How much rope this round gets, decided by the Workflow from the Task's spent
134
+ * budget.
135
+ *
136
+ * - `open` — the normal round: `delegate`, `final_reply`, and every work tool.
137
+ * It may spend whatever is left of the turn budget.
138
+ * - `final` — the Task has spent its turns or its wall clock. **No work tools and
139
+ * no `delegate`**: the only thing on the table is the answer. This is not a
140
+ * punishment but the shape of the ceiling — a budget that ends in a forced
141
+ * answer returns the work, where one that simply stopped would discard it.
142
+ * Costs one turn, or two if the primary model fails and the fallback has to
143
+ * produce the answer instead; a fallback with no step to spend could not answer
144
+ * at all.
145
+ */
146
+ export type RoundMode = "open" | "final";
147
+ export interface RunTurnArgs {
148
+ /** The DO's one continuous Session. */
149
+ session: SessionLike;
150
+ /** Parent Task id — derives the deterministic Session message ids. */
151
+ taskId: string;
152
+ /** 0-based round within this Task. */
153
+ round: number;
154
+ /** The inbound user text (keeps its `<turn>` provenance wrapper verbatim). Appended on round 0 only. */
155
+ text: string;
156
+ /** What this round may do — see {@link RoundMode}. */
157
+ mode: RoundMode;
158
+ /**
159
+ * The Task's unspent turns, and the tally this round writes back into them.
160
+ * Mutated in place as the model works, so the primary and the fallback draw on
161
+ * one allowance rather than one each — see `TurnBudget`.
162
+ *
163
+ * There is no per-round allowance beyond what the Task has left: an early round
164
+ * that dithers spends what a later one would have had, and is then handed a
165
+ * `final` round to answer in. The caller reads `spent` when the round returns.
166
+ */
167
+ budget: TurnBudget;
168
+ /** Per-request system-prompt suffix (verified caller context). */
169
+ systemSuffix: string;
170
+ /** The main agent's gated **work** tools, merged over the session's own tools. */
171
+ tools: ToolSet;
172
+ /** Primary + fallback model pair. */
173
+ models: ModelPair;
174
+ /** Every earlier round's branches, all rounds, in stable ordinal order. */
175
+ branches: CompositionBranch[];
176
+ /** The installed subtask types — what `delegate` may name. */
177
+ types: SubtaskTypeRegistry;
178
+ /** `CoreConfig.maxSubtasks`, the per-round fan-out bound. */
179
+ maxSubtasks: number;
180
+ /** `CoreConfig.model.maxOutputTokens`. */
181
+ maxOutputTokens: number;
182
+ /** The prompt suffixes, memoized by the DO. See {@link buildTurnInstructions}. */
183
+ instructions: TurnInstructions;
184
+ /** The note a deterministic join appends when it has to disclose gaps. */
185
+ partialNote: string;
186
+ /** Streams intermediate content while the model reasons. Best-effort. */
187
+ onContent?: OnContent;
188
+ }
189
+ /**
190
+ * Terminal outcome of one round. `failed` means both models produced unusable
191
+ * output *and* there was no durable work to fall back on — the parent Task fails
192
+ * rather than running a synthesized subtask nobody asked for. Transient faults
193
+ * throw instead (the Workflow step retries).
194
+ *
195
+ * What the round cost is not here: it is in the caller's `TurnBudget`, which every
196
+ * exit has already charged — including the ones that failed. A round that burned
197
+ * the primary and recovered on the fallback spent both, and there is no variant
198
+ * that could quietly forgive the expensive half of a bad round.
199
+ */
200
+ export type RunTurnOutcome = {
201
+ status: "replied";
202
+ reply: string;
203
+ } | {
204
+ status: "delegated";
205
+ reply: string;
206
+ drafts: SubtaskDraft[];
207
+ } | {
208
+ status: "failed";
209
+ error: string;
210
+ };
211
+ /**
212
+ * Run one round against the continuous Session: append the user turn (round 0),
213
+ * let the model decide over the indexed history, validate any delegation against
214
+ * this round's catalog, and persist what the user will see.
215
+ *
216
+ * Every append uses a deterministic id, so a Workflow-step re-run neither
217
+ * duplicates the turn nor changes an already-delivered reply.
218
+ *
219
+ * Two nested recoveries, and they answer different failures. Within a slot, a
220
+ * decomposition the catalog rejects is handed back to the *same* model as a failed
221
+ * tool result, up to {@link MAX_REPAIR_ATTEMPTS} times — a shape error is the one
222
+ * thing a model can fix once it sees it. Across slots, an attempt that produced no
223
+ * decision at all moves to the fallback model, which is what that slot is for.
224
+ *
225
+ * Throws only on a transient platform fault (for the Workflow step to retry).
226
+ * A deterministic failure that outlasts every repair on both slots, with durable
227
+ * work behind it, degrades to {@link joinSuccessfulBranches} rather than discarding
228
+ * completed branches; with nothing behind it, it resolves to `{ status: "failed" }`.
229
+ */
230
+ export declare function runTurn(args: RunTurnArgs):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