@buoy-gg/agent-core 7.0.35 → 7.0.36

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 (174) hide show
  1. package/README.md +10 -7
  2. package/lib/commonjs/blocks/receipts.js +57 -1
  3. package/lib/commonjs/blocks/receipts.js.map +1 -1
  4. package/lib/commonjs/blocks/types.js +23 -2
  5. package/lib/commonjs/blocks/types.js.map +1 -1
  6. package/lib/commonjs/blocks/uiTool.js +423 -10
  7. package/lib/commonjs/blocks/uiTool.js.map +1 -1
  8. package/lib/commonjs/catalog/catalog.g.js +121 -43
  9. package/lib/commonjs/catalog/catalog.g.js.map +1 -1
  10. package/lib/commonjs/catalog/catalog.source.json +121 -45
  11. package/lib/commonjs/catalog/catalog.types.g.js +44 -0
  12. package/lib/commonjs/catalog/catalog.types.g.js.map +1 -0
  13. package/lib/commonjs/catalog/normalizeParams.js +333 -0
  14. package/lib/commonjs/catalog/normalizeParams.js.map +1 -0
  15. package/lib/commonjs/catalog/signature.js +68 -0
  16. package/lib/commonjs/catalog/signature.js.map +1 -0
  17. package/lib/commonjs/catalog/snapshotReads.js +13 -6
  18. package/lib/commonjs/catalog/snapshotReads.js.map +1 -1
  19. package/lib/commonjs/catalog/toProviderTools.js +41 -5
  20. package/lib/commonjs/catalog/toProviderTools.js.map +1 -1
  21. package/lib/commonjs/context/buildContextPack.js +367 -19
  22. package/lib/commonjs/context/buildContextPack.js.map +1 -1
  23. package/lib/commonjs/effects/digest.js +34 -0
  24. package/lib/commonjs/effects/digest.js.map +1 -0
  25. package/lib/commonjs/effects/ledger.js +85 -1
  26. package/lib/commonjs/effects/ledger.js.map +1 -1
  27. package/lib/commonjs/engine/askGate.js +287 -0
  28. package/lib/commonjs/engine/askGate.js.map +1 -0
  29. package/lib/commonjs/engine/effectFor.js +82 -1
  30. package/lib/commonjs/engine/effectFor.js.map +1 -1
  31. package/lib/commonjs/engine/historyBudget.js +260 -0
  32. package/lib/commonjs/engine/historyBudget.js.map +1 -0
  33. package/lib/commonjs/engine/runAgentTurn.js +924 -83
  34. package/lib/commonjs/engine/runAgentTurn.js.map +1 -1
  35. package/lib/commonjs/engine/systemPrompt.js +72 -8
  36. package/lib/commonjs/engine/systemPrompt.js.map +1 -1
  37. package/lib/commonjs/engine/textToolCalls.js +276 -0
  38. package/lib/commonjs/engine/textToolCalls.js.map +1 -0
  39. package/lib/commonjs/index.js +58 -0
  40. package/lib/commonjs/index.js.map +1 -1
  41. package/lib/commonjs/policy/labels.js +19 -3
  42. package/lib/commonjs/policy/labels.js.map +1 -1
  43. package/lib/commonjs/policy/policy.js +6 -1
  44. package/lib/commonjs/policy/policy.js.map +1 -1
  45. package/lib/commonjs/policy/redact.js +42 -5
  46. package/lib/commonjs/policy/redact.js.map +1 -1
  47. package/lib/commonjs/providers/anthropic.js +331 -208
  48. package/lib/commonjs/providers/anthropic.js.map +1 -1
  49. package/lib/commonjs/providers/openai.js +229 -103
  50. package/lib/commonjs/providers/openai.js.map +1 -1
  51. package/lib/commonjs/providers/sse.js +164 -29
  52. package/lib/commonjs/providers/sse.js.map +1 -1
  53. package/lib/commonjs/providers/streamTimer.js +123 -0
  54. package/lib/commonjs/providers/streamTimer.js.map +1 -0
  55. package/lib/commonjs/providers/transport.js +107 -0
  56. package/lib/commonjs/providers/transport.js.map +1 -0
  57. package/lib/commonjs/providers/xhrStream.js +209 -0
  58. package/lib/commonjs/providers/xhrStream.js.map +1 -0
  59. package/lib/commonjs/session.js +215 -58
  60. package/lib/commonjs/session.js.map +1 -1
  61. package/lib/module/blocks/receipts.js +57 -1
  62. package/lib/module/blocks/receipts.js.map +1 -1
  63. package/lib/module/blocks/types.js +23 -2
  64. package/lib/module/blocks/types.js.map +1 -1
  65. package/lib/module/blocks/uiTool.js +421 -10
  66. package/lib/module/blocks/uiTool.js.map +1 -1
  67. package/lib/module/catalog/catalog.g.js +121 -43
  68. package/lib/module/catalog/catalog.g.js.map +1 -1
  69. package/lib/module/catalog/catalog.source.json +121 -45
  70. package/lib/module/catalog/catalog.types.g.js +40 -0
  71. package/lib/module/catalog/catalog.types.g.js.map +1 -0
  72. package/lib/module/catalog/normalizeParams.js +327 -0
  73. package/lib/module/catalog/normalizeParams.js.map +1 -0
  74. package/lib/module/catalog/signature.js +63 -0
  75. package/lib/module/catalog/signature.js.map +1 -0
  76. package/lib/module/catalog/snapshotReads.js +13 -6
  77. package/lib/module/catalog/snapshotReads.js.map +1 -1
  78. package/lib/module/catalog/toProviderTools.js +41 -5
  79. package/lib/module/catalog/toProviderTools.js.map +1 -1
  80. package/lib/module/context/buildContextPack.js +366 -19
  81. package/lib/module/context/buildContextPack.js.map +1 -1
  82. package/lib/module/effects/digest.js +29 -0
  83. package/lib/module/effects/digest.js.map +1 -0
  84. package/lib/module/effects/ledger.js +85 -1
  85. package/lib/module/effects/ledger.js.map +1 -1
  86. package/lib/module/engine/askGate.js +280 -0
  87. package/lib/module/engine/askGate.js.map +1 -0
  88. package/lib/module/engine/effectFor.js +83 -1
  89. package/lib/module/engine/effectFor.js.map +1 -1
  90. package/lib/module/engine/historyBudget.js +251 -0
  91. package/lib/module/engine/historyBudget.js.map +1 -0
  92. package/lib/module/engine/runAgentTurn.js +920 -83
  93. package/lib/module/engine/runAgentTurn.js.map +1 -1
  94. package/lib/module/engine/systemPrompt.js +71 -8
  95. package/lib/module/engine/systemPrompt.js.map +1 -1
  96. package/lib/module/engine/textToolCalls.js +270 -0
  97. package/lib/module/engine/textToolCalls.js.map +1 -0
  98. package/lib/module/index.js +5 -3
  99. package/lib/module/index.js.map +1 -1
  100. package/lib/module/policy/labels.js +19 -3
  101. package/lib/module/policy/labels.js.map +1 -1
  102. package/lib/module/policy/policy.js +6 -1
  103. package/lib/module/policy/policy.js.map +1 -1
  104. package/lib/module/policy/redact.js +42 -5
  105. package/lib/module/policy/redact.js.map +1 -1
  106. package/lib/module/providers/anthropic.js +332 -209
  107. package/lib/module/providers/anthropic.js.map +1 -1
  108. package/lib/module/providers/openai.js +230 -104
  109. package/lib/module/providers/openai.js.map +1 -1
  110. package/lib/module/providers/sse.js +160 -29
  111. package/lib/module/providers/sse.js.map +1 -1
  112. package/lib/module/providers/streamTimer.js +118 -0
  113. package/lib/module/providers/streamTimer.js.map +1 -0
  114. package/lib/module/providers/transport.js +103 -0
  115. package/lib/module/providers/transport.js.map +1 -0
  116. package/lib/module/providers/xhrStream.js +204 -0
  117. package/lib/module/providers/xhrStream.js.map +1 -0
  118. package/lib/module/session.js +199 -60
  119. package/lib/module/session.js.map +1 -1
  120. package/lib/typescript/blocks/receipts.d.ts +5 -0
  121. package/lib/typescript/blocks/receipts.d.ts.map +1 -1
  122. package/lib/typescript/blocks/types.d.ts +23 -2
  123. package/lib/typescript/blocks/types.d.ts.map +1 -1
  124. package/lib/typescript/blocks/uiTool.d.ts +11 -2
  125. package/lib/typescript/blocks/uiTool.d.ts.map +1 -1
  126. package/lib/typescript/catalog/catalog.g.d.ts.map +1 -1
  127. package/lib/typescript/catalog/catalog.types.g.d.ts +40 -0
  128. package/lib/typescript/catalog/catalog.types.g.d.ts.map +1 -0
  129. package/lib/typescript/catalog/normalizeParams.d.ts +43 -0
  130. package/lib/typescript/catalog/normalizeParams.d.ts.map +1 -0
  131. package/lib/typescript/catalog/signature.d.ts +29 -0
  132. package/lib/typescript/catalog/signature.d.ts.map +1 -0
  133. package/lib/typescript/catalog/snapshotReads.d.ts.map +1 -1
  134. package/lib/typescript/catalog/toProviderTools.d.ts +28 -15
  135. package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -1
  136. package/lib/typescript/context/buildContextPack.d.ts +24 -2
  137. package/lib/typescript/context/buildContextPack.d.ts.map +1 -1
  138. package/lib/typescript/effects/digest.d.ts +10 -0
  139. package/lib/typescript/effects/digest.d.ts.map +1 -0
  140. package/lib/typescript/effects/ledger.d.ts +55 -0
  141. package/lib/typescript/effects/ledger.d.ts.map +1 -1
  142. package/lib/typescript/engine/askGate.d.ts +29 -0
  143. package/lib/typescript/engine/askGate.d.ts.map +1 -0
  144. package/lib/typescript/engine/effectFor.d.ts +6 -1
  145. package/lib/typescript/engine/effectFor.d.ts.map +1 -1
  146. package/lib/typescript/engine/historyBudget.d.ts +92 -0
  147. package/lib/typescript/engine/historyBudget.d.ts.map +1 -0
  148. package/lib/typescript/engine/runAgentTurn.d.ts +83 -1
  149. package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -1
  150. package/lib/typescript/engine/systemPrompt.d.ts +41 -0
  151. package/lib/typescript/engine/systemPrompt.d.ts.map +1 -1
  152. package/lib/typescript/engine/textToolCalls.d.ts +58 -0
  153. package/lib/typescript/engine/textToolCalls.d.ts.map +1 -0
  154. package/lib/typescript/index.d.ts +5 -3
  155. package/lib/typescript/index.d.ts.map +1 -1
  156. package/lib/typescript/policy/labels.d.ts.map +1 -1
  157. package/lib/typescript/policy/policy.d.ts.map +1 -1
  158. package/lib/typescript/policy/redact.d.ts.map +1 -1
  159. package/lib/typescript/providers/anthropic.d.ts.map +1 -1
  160. package/lib/typescript/providers/openai.d.ts +0 -16
  161. package/lib/typescript/providers/openai.d.ts.map +1 -1
  162. package/lib/typescript/providers/sse.d.ts +82 -1
  163. package/lib/typescript/providers/sse.d.ts.map +1 -1
  164. package/lib/typescript/providers/streamTimer.d.ts +59 -0
  165. package/lib/typescript/providers/streamTimer.d.ts.map +1 -0
  166. package/lib/typescript/providers/transport.d.ts +40 -0
  167. package/lib/typescript/providers/transport.d.ts.map +1 -0
  168. package/lib/typescript/providers/types.d.ts +91 -3
  169. package/lib/typescript/providers/types.d.ts.map +1 -1
  170. package/lib/typescript/providers/xhrStream.d.ts +43 -0
  171. package/lib/typescript/providers/xhrStream.d.ts.map +1 -0
  172. package/lib/typescript/session.d.ts +40 -2
  173. package/lib/typescript/session.d.ts.map +1 -1
  174. package/package.json +2 -2
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Parameter aliases — accept what models actually send.
3
+ *
4
+ * The provider sees ONE tool per Buoy tool with `params` as an open object
5
+ * (see toProviderTools.ts), so the per-action parameter names live in prose
6
+ * and every model has to reproduce them from memory. A sweep of 18 models
7
+ * against the live app showed the same handful of misses over and over, on
8
+ * cheap models AND on gpt-5 and Gemini 2.5 Pro:
9
+ *
10
+ * queryKey: [...] where the action wants queryHash (by far the #1 miss —
11
+ * the RIGHT NOW block shows keys as arrays, and
12
+ * setQueryData takes queryKey, so the model reuses it)
13
+ * requestId where network.getEventBody wants id
14
+ * newState/patch where zustand.setState wants state
15
+ * name where zustand wants storeName
16
+ * bodyPatch/body/… at the top level of upsertOverrideRule instead of inside `rule`
17
+ *
18
+ * A validation error names the right field, but a cheap model repeats the same
19
+ * wrong call or gives up, and the user sees "nothing happened". Every one of
20
+ * these is mechanically unambiguous, so it is fixed HERE, before validation,
21
+ * and the result carries a one-line note so the model learns the real name
22
+ * without failing the call. Nothing here guesses: an alias only fires when the
23
+ * canonical field is absent and the alias is present.
24
+ */
25
+ export interface NormalizedParams {
26
+ params: Record<string, unknown>;
27
+ /** Human-readable notes about what was accepted, for the tool result. */
28
+ notes: string[];
29
+ }
30
+ /**
31
+ * TanStack's default `hashKey`: JSON.stringify with plain-object keys sorted,
32
+ * so `["todos", {page:1, sort:"a"}]` hashes the same whatever order the model
33
+ * wrote the object in.
34
+ */
35
+ export declare function hashQueryKey(key: unknown[]): string;
36
+ /**
37
+ * Fix the unambiguous parameter-name misses before validation. Returns the
38
+ * same object shape validation expects plus the notes to append to the result.
39
+ */
40
+ export declare function normalizeParams(toolId: string, action: string, raw: Record<string, unknown>): NormalizedParams;
41
+ /** The one-line trailer appended to a tool result when aliases fired. */
42
+ export declare function aliasNote(notes: string[]): string;
43
+ //# sourceMappingURL=normalizeParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeParams.d.ts","sourceRoot":"","sources":["../../../src/catalog/normalizeParams.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,yEAAyE;IACzE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAKD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,CAWnD;AA4TD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,gBAAgB,CAoBlB;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEjD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Rendering a JSON Schema as the one-line signature a model reads.
3
+ *
4
+ * Lifted out of `blocks/uiTool.ts`, where it was written for `buoy_ui` and
5
+ * where its own comment records the result that justifies using it everywhere:
6
+ *
7
+ * > `uiProviderTool` used to send `params: { type: "object" }` and 26 lines
8
+ * > of prose about what each kind is FOR — and not one field name. The model
9
+ * > was being asked to guess `images` vs `items` and `chips` vs `options`,
10
+ * > and it guessed wrong three rounds running.
11
+ *
12
+ * The other 24 tools still send exactly that: an open `params` object and a
13
+ * sentence promising the error will explain the shape. `normalizeParams.ts`
14
+ * exists to catch the five misses that produced most often. This renders the
15
+ * field names instead, from the SAME schema `validateParams` enforces, so what
16
+ * the model reads can never drift from what the validator accepts.
17
+ */
18
+ import type { JsonSchema } from "../types";
19
+ /** `{ url*, alt?, caption? }` — `*` marks required. */
20
+ export declare function signature(schema: JsonSchema | undefined, depth?: number): string;
21
+ /**
22
+ * The `params:` line under an action, or "" when the action takes none.
23
+ *
24
+ * Actions with no declared properties (71 of 192) get nothing rather than an
25
+ * empty `{}` — a line that says the action takes no arguments is already said
26
+ * by its absence, and 71 of them would be pure noise.
27
+ */
28
+ export declare function paramsLine(schema: JsonSchema | undefined): string;
29
+ //# sourceMappingURL=signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/catalog/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,SAAI,GAAG,MAAM,CA+B3E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAIjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotReads.d.ts","sourceRoot":"","sources":["../../../src/catalog/snapshotReads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,gEAAgE;AAChE,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAyM7C;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,OAAO,CAeT"}
1
+ {"version":3,"file":"snapshotReads.d.ts","sourceRoot":"","sources":["../../../src/catalog/snapshotReads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,gEAAgE;AAChE,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAgN7C;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,OAAO,CAeT"}
@@ -1,24 +1,37 @@
1
+ import type { ToolDescriptor } from "../types";
1
2
  /**
2
- * Catalog -> provider tool definitions.
3
- *
4
- * WHY ONE TOOL PER BUOY TOOL, NOT ONE PER ACTION: tool-selection accuracy
5
- * degrades past roughly 30-50 tools. Buoy has ~179 actions across 22 tools, so
6
- * a 1:1 mapping is far past the point where the model starts picking wrong.
7
- * Each Buoy tool therefore becomes ONE provider tool whose `action` property is
8
- * an enum, with the per-action summaries folded into that enum's description.
3
+ * Provider-agnostic tool definition; the adapters reshape it per protocol.
9
4
  *
10
- * `params` stays an open object at the provider boundary — a discriminated
11
- * union across 179 branches is unusable by any model and unreadable by a human.
12
- * The real per-action schema is enforced one layer in, by `validateParams`,
13
- * which returns a structured error the model can correct on the next turn.
14
- * That is strictly stronger than the MCP server's `z.record(z.unknown())`,
15
- * which validates nothing.
5
+ * The description comes in three forms because the two protocols cap it
6
+ * differently. Anthropic takes `description` whole. OpenAI (and Azure, and
7
+ * every OpenAI-compatible gateway) caps a function description at 1024
8
+ * chars, and the catalog renders the summary first and the `Actions:` list
9
+ * LAST — so trimming `description` to fit dropped every action line for 23
10
+ * of 24 tools (the 24th kept one line of sixteen), and a model on that
11
+ * protocol saw a summary cut mid-sentence plus a bare `action` enum. Hence
12
+ * the split: `summaryDescription` is the part that fits the cap,
13
+ * `actionsBlock` goes into the `action` property's description, which
14
+ * nothing caps. `description` stays their concatenation
15
+ * so the Anthropic request is byte-identical to what it was.
16
16
  */
17
- import type { ToolDescriptor } from "../types";
18
- /** Provider-agnostic tool definition; the adapters reshape it per protocol. */
19
17
  export interface ProviderTool {
20
18
  name: string;
19
+ /** `summaryDescription` + `actionsBlock` — the whole thing. */
21
20
  description: string;
21
+ /** The tool's summary alone — the part that fits OpenAI's 1024-char cap. */
22
+ summaryDescription: string;
23
+ /** `Unavailable when: …` (if any) then `Actions:` and one `- <action> — <summary> [tags]` line each. */
24
+ actionsBlock: string;
25
+ /**
26
+ * Worked example inputs, sent as Anthropic's `input_examples`.
27
+ *
28
+ * Anthropic report 72% -> 90% on complex parameter handling. Their own
29
+ * framing is that JSON Schema "can't express usage patterns: when to include
30
+ * optional parameters, which combinations make sense, or what conventions
31
+ * your API expects" — which is the gap between knowing a field's NAME and
32
+ * knowing its SHAPE, and the gap the params signatures did not close.
33
+ */
34
+ inputExamples?: Record<string, unknown>[];
22
35
  inputSchema: {
23
36
  type: "object";
24
37
  properties: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"toProviderTools.d.ts","sourceRoot":"","sources":["../../../src/catalog/toProviderTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,UAAU,CAAC;AAEjE,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,oBAAoB,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH;AASD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EAAE,GACxB,MAAM,GAAG,SAAS,CAEpB;AAmBD,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,EAAE,EACzB,IAAI,GAAE,sBAA2B,GAChC,YAAY,EAAE,CAiEhB"}
1
+ {"version":3,"file":"toProviderTools.d.ts","sourceRoot":"","sources":["../../../src/catalog/to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ux slices,
9
9
  * zustand stores, jotai atoms, storage keys and API hosts.
10
10
  *
11
+ * TWO HALVES, READ ON TWO SCHEDULES.
12
+ *
13
+ * The STABLE half (routes, slices, stores, atoms, storage keys, env names) is
14
+ * read once when the chat opens and rendered inside the cached system block.
15
+ * It changes rarely, and when it does the cache re-warms once.
16
+ *
17
+ * The LIVE half — the current route, which queries are MOUNTED right now, the
18
+ * last few requests — is read again before EVERY turn and rendered as a
19
+ * separate, uncached block. This exists because of one failure: asked to
20
+ * "rename the Pokémon I'm looking at", the model went to an empty zustand cart
21
+ * because the once-at-open digest had been built before any query was cached,
22
+ * so React Query never appeared in its prompt at all. A query with
23
+ * `observers > 0` IS what the screen is rendering; that fact has to be in
24
+ * front of the model at the moment it decides which tool to reach for.
25
+ *
11
26
  * What this does NOT do, and why:
12
27
  * - No `getSnapshot('query')`. It returns the full dehydrated cache — 8.3KB for
13
28
  * ten queries in that same measurement, growing with every cached payload.
@@ -22,11 +37,18 @@
22
37
  import type { DispatchFn, SnapshotFn } from "../types";
23
38
  export interface BuildContextInput {
24
39
  dispatch: DispatchFn;
25
- /** Needed by the snapshot-only probes (routes, env). */
40
+ /** Needed by the snapshot-only probes (routes, env, network). */
26
41
  readSnapshot?: SnapshotFn;
27
42
  /** Tool ids actually present, so we do not probe what cannot answer. */
28
43
  availableToolIds: string[];
29
44
  availableActions?: Record<string, string[]>;
30
45
  }
31
- export declare function buildContextDigest({ dispatch, readSnapshot, availableToolIds, availableActions, }: BuildContextInput): Promise<Record<string, unknown>>;
46
+ /** The stable half: read once at open, rendered inside the cached prompt. */
47
+ export declare function buildContextDigest(input: BuildContextInput): Promise<Record<string, unknown>>;
48
+ /**
49
+ * The live half: read before every turn. Current route, mounted queries,
50
+ * recent requests, armed overrides. Rendered as the uncached "RIGHT NOW"
51
+ * block — see `buildLiveBlock` in systemPrompt.ts.
52
+ */
53
+ export declare function buildLiveContext(input: BuildContextInput): Promise<Record<string, unknown>>;
32
54
  //# sourceMappingURL=buildContextPack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildContextPack.d.ts","sourceRoot":"","sources":["../../../src/context/buildContextPack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAiHvD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,UAAU,CAAC;IACrB,wDAAwD;IACxD,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC7C;AAED,wBAAsB,kBAAkB,CAAC,EACvC,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsCtD"}
1
+ {"version":3,"file":"buildContextPack.d.ts","sourceRoot":"","sources":["../../../src/context/buildContextPack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsVvD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,UAAU,CAAC;IACrB,iEAAiE;IACjE,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC7C;AA6CD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE7F;AAsFD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAIjG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A short, stable fingerprint of any JSON-able value. Not cryptographic —
3
+ * it only has to answer "is this the same as what I saw?" — and deliberately
4
+ * lossy so the thing persisted beside an unanswered approval or a ledger
5
+ * entry is a hash of a store's state, never the state itself.
6
+ */
7
+ export declare function digestOf(value: unknown): string | undefined;
8
+ /** Byte-ish size of a value once serialised; Infinity when it cannot be. */
9
+ export declare function jsonLength(value: unknown): number;
10
+ //# sourceMappingURL=digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../src/effects/digest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU3D;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMjD"}
@@ -49,6 +49,26 @@ export type AppliedEffect = {
49
49
  /** The action that removes the key, for the did-not-exist case. */
50
50
  removeAction?: string;
51
51
  label: string;
52
+ } | {
53
+ /**
54
+ * A React Query cache edit, reversible because the engine reads the
55
+ * query's data before `setQueryData` runs (see captureStoreState). This
56
+ * was the most common write in a real QA session — nine of eleven —
57
+ * and it was filed as a permanent `state-write`, so the changes bar
58
+ * promised undo and then said "can't be undone automatically" for the
59
+ * one thing the tester had actually changed.
60
+ */
61
+ kind: "query-write";
62
+ queryHash: string;
63
+ /** The cached data before this write; undefined when the query held none. */
64
+ before?: unknown;
65
+ /**
66
+ * Fingerprint of the data as this write left it. A refetch replaces the
67
+ * cache underneath us; restoring `before` over fresh server data would
68
+ * be a second unwanted edit, so undo compares first.
69
+ */
70
+ wroteDigest?: string;
71
+ label: string;
52
72
  } | {
53
73
  kind: "state-write";
54
74
  toolId: string;
@@ -89,8 +109,43 @@ export interface RevertOutcome {
89
109
  export declare class EffectLedger {
90
110
  private entries;
91
111
  private listeners;
112
+ private gen;
113
+ /**
114
+ * Which conversation this ledger is holding, bumped by `clear`.
115
+ *
116
+ * A turn captures it when it starts and hands it back on every `record`.
117
+ * Nothing about a dispatch can be pulled back once it is in flight, so a
118
+ * write that settles after the user has already tapped "New conversation"
119
+ * still lands in the app — but it must not land in the NEW conversation's
120
+ * undo bar, which is what happened: reset cleared the ledger, the old
121
+ * write finished a moment later, and an empty chat came up owning a change
122
+ * nobody in it had made. Recording it here would be worse than dropping it,
123
+ * because Undo would then offer to reverse something the user cannot see.
124
+ */
125
+ get generation(): number;
126
+ /**
127
+ * @param generation The value of `generation` when the turn began. Omit for
128
+ * a human-initiated action, which is by definition happening now — and which
129
+ * therefore always returns an entry.
130
+ */
92
131
  record(toolId: string, action: string, effect: AppliedEffect): LedgerEntry;
132
+ record(toolId: string, action: string, effect: AppliedEffect, generation: number): LedgerEntry | undefined;
93
133
  list(): LedgerEntry[];
134
+ /**
135
+ * Put back the entries of a conversation that outlived the app.
136
+ *
137
+ * The ledger is the ONLY undo surface, and it used to die with the JS
138
+ * context: after a reload the transcript came back — receipt cards, "saved"
139
+ * lines and all — while the changes bar quietly vanished and the changes
140
+ * themselves stayed applied. "New conversation" warns before losing that
141
+ * ("Clearing the conversation loses the only automatic undo for it"); a
142
+ * reload took the same thing without asking.
143
+ *
144
+ * Refuses once anything has been recorded, for the same reason `hydrate`
145
+ * refuses a live transcript: a late disk read must not shuffle old entries
146
+ * in among changes made since.
147
+ */
148
+ restore(entries: LedgerEntry[]): boolean;
94
149
  /** New array identity for the snapshot after entries were mutated in place. */
95
150
  private touch;
96
151
  /** Not-yet-undone entries that Undo can actually deliver on. Agrees with
@@ -1 +1 @@
1
- {"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/effects/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;A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AE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAsGtF,uDAAuD;IACjD,SAAS,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;CAgB9D"}
@@ -0,0 +1,29 @@
1
+ import type { ActionsBlock, ChoiceBlock } from "../blocks/types";
2
+ /**
3
+ * The block a turn should have ended with, or null to leave the prose alone.
4
+ *
5
+ * `text` is everything the model said this turn, rounds joined in order.
6
+ */
7
+ export declare function synthesizeAskBlock(text: string): ChoiceBlock | null;
8
+ /**
9
+ * `attempted` — did this turn call anything that GOES AND GETS data?
10
+ * Keyed on the actions the prompt's ladder names, so the two move together.
11
+ */
12
+ export declare const ACQUISITION_CALLS: Set<string>;
13
+ export interface ShortfallInput {
14
+ /** Everything the model said this turn, rounds joined in order. */
15
+ text: string;
16
+ /** Whether any ACQUISITION_CALLS ran this turn. */
17
+ attempted: boolean;
18
+ }
19
+ /**
20
+ * The block a turn should have ended with when it conceded a gap and never
21
+ * tried to close it, or null to leave the prose alone.
22
+ *
23
+ * An `actions` block, not a `choice`: nothing is being ASKED here. The turn is
24
+ * over and the answer stands; this is one button that says the gap is closable
25
+ * and closes it. So it must not end the turn or set `awaiting-user` — a
26
+ * synthesized card must never look like it is blocking on a reply.
27
+ */
28
+ export declare function synthesizeShortfallBlock({ text, attempted }: ShortfallInput): ActionsBlock | null;
29
+ //# sourceMappingURL=askGate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"askGate.d.ts","sourceRoot":"","sources":["../../../src/engine/askGate.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAgB,MAAM,iBAAiB,CAAC;AAuD/E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAwBnE;AA0FD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAS5B,CAAC;AAEH,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAuBjG"}
@@ -17,5 +17,10 @@ import type { AppliedEffect } from "../effects/ledger";
17
17
  export declare function effectFor(toolId: string, descriptor: ActionDescriptor, params: Record<string, unknown>, result: unknown, before: {
18
18
  had: boolean;
19
19
  value?: string;
20
- } | undefined): AppliedEffect | undefined;
20
+ } | undefined,
21
+ /** The query cache read before and after a `setQueryData` — see runAgentTurn. */
22
+ cache?: {
23
+ before?: unknown;
24
+ after?: unknown;
25
+ }): AppliedEffect | undefined;
21
26
  //# sourceMappingURL=effectFor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effectFor.d.ts","sourceRoot":"","sources":["../../../src/engine/effectFor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,OAAO,EACf,MAAM,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GACnD,aAAa,GAAG,SAAS,CAwD3B"}
1
+ {"version":3,"file":"effectFor.d.ts","sourceRoot":"","sources":["../../../src/engine/effectFor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAmCvD,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,OAAO,EACf,MAAM,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS;AACpD,iFAAiF;AACjF,KAAK,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5C,aAAa,GAAG,SAAS,CA6G3B"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * How much conversation the model is allowed to be sent, and what gets cut.
3
+ *
4
+ * Lives here, not in `session.ts`, because it is needed in TWO places and used
5
+ * to run in only one. The session trims once per turn, before the loop starts
6
+ * — and a turn is not one request. A twelve-step investigation appends an
7
+ * assistant message and a tool-results message per step, each result capped at
8
+ * 24,000 characters, so a long read chain could add well over a hundred
9
+ * thousand characters AFTER the only check had already happened and walk
10
+ * straight into the provider's context limit. The engine now applies the same
11
+ * budget before every request; the session still applies it when a turn opens.
12
+ */
13
+ import type { AgentMessage } from "../providers/types";
14
+ /**
15
+ * A long QA session must not die on the provider's context limit with an
16
+ * opaque error, so the history is kept under a budget.
17
+ *
18
+ * TWO STAGES, AND THE ORDER IS THE POINT. Dropping the oldest rounds was the
19
+ * only stage, and in a QA session the oldest round is usually the SETUP — the
20
+ * override that was armed, the store that was written, the user someone is
21
+ * impersonating. Drop it and the model can no longer explain the screen it is
22
+ * looking at, or that a "wrong" response is its own mock. The reply gets worse
23
+ * in exactly the sessions long enough to need trimming.
24
+ *
25
+ * So: COMPRESS first, DROP only if that was not enough.
26
+ *
27
+ * A tool result is "consumed" once the model has produced an assistant message
28
+ * after seeing it — it has already been reasoned over, and what remains is
29
+ * bulk. Replacing it with a marker keeps the round, its decision and its
30
+ * ordering while giving back nearly all the bytes. Three exemptions carry
31
+ * their weight:
32
+ *
33
+ * - Errors are never compressed. A failure is the diagnostic value.
34
+ * - The newest tool-results message is never compressed. The model is about
35
+ * to answer from it.
36
+ * - The last read before a WRITE is never compressed: that is the shape the
37
+ * model matched its edit to, and it is the thing it re-reads when the write
38
+ * is refused and it has to correct itself.
39
+ *
40
+ * Only if the history is still over budget do whole rounds get dropped, as
41
+ * before — a round starts at a user message, so the assistant/tool-result
42
+ * pairing every provider requires stays intact.
43
+ */
44
+ export declare const MAX_HISTORY_CHARS = 150000;
45
+ /**
46
+ * The ceiling on a WHOLE request: tools, system prompt, messages and the room
47
+ * reserved for the reply. ~100k tokens, which fits the smallest context Ask
48
+ * Buoy is pointed at in practice (a 128k-token gateway) with headroom, and
49
+ * leaves Anthropic's 200k far from the limit.
50
+ */
51
+ export declare const MAX_REQUEST_CHARS = 400000;
52
+ export declare function messageSize(m: AgentMessage): number;
53
+ /**
54
+ * Replace consumed tool results with a marker. See the note above
55
+ * MAX_HISTORY_CHARS for what "consumed" means and why the exemptions exist.
56
+ */
57
+ export declare function compressConsumed(messages: AgentMessage[]): AgentMessage[];
58
+ /**
59
+ * Trim, and say how many whole rounds were dropped — the number the UI turns
60
+ * into "older messages were trimmed from the agent's memory".
61
+ *
62
+ * A round is a user message and everything up to the next one. Once a drop
63
+ * starts it ALWAYS runs to the next user boundary: the inner loop used to stop
64
+ * at `MIN_KEEP_MESSAGES` as well, so a history could come out starting with an
65
+ * assistant or tool-results message — which every provider rejects. The
66
+ * minimum-keep guard belongs on STARTING a drop, not on finishing one.
67
+ */
68
+ export declare function trimHistoryReport(messages: AgentMessage[]): {
69
+ messages: AgentMessage[];
70
+ droppedRounds: number;
71
+ };
72
+ /** Exported for the history tests; not part of the package surface. */
73
+ export declare function trimHistory(messages: AgentMessage[]): AgentMessage[];
74
+ /**
75
+ * Trim the working history of a turn that is still running.
76
+ *
77
+ * Differs from `trimHistoryReport` in one way that matters: the CURRENT round
78
+ * is never touched. A turn's own user message and the reads it has taken since
79
+ * are the thing being answered, so compressing or dropping them would make the
80
+ * request cheaper and the answer wrong. Everything before the last user
81
+ * message is fair game, in the same order as always — compress, then drop.
82
+ *
83
+ * `reserve` is what the request costs BEFORE any messages: the tool
84
+ * definitions (~8k tokens for a typical install, ~23k with everything
85
+ * installed), the system prompt, and the reply the model is allowed to write.
86
+ * Budgeting messages alone would leave the biggest fixed cost out of the sum.
87
+ */
88
+ export declare function budgetForRequest(messages: AgentMessage[], reserve: number): {
89
+ messages: AgentMessage[];
90
+ droppedRounds: number;
91
+ };
92
+ //# sourceMappingURL=historyBudget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"historyBudget.d.ts","sourceRoot":"","sources":["../../../src/engine/historyBudget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,iBAAiB,SAAU,CAAC;AACzC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,SAAU,CAAC;AAKzC,wBAAgB,WAAW,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAMnD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CA6CzE;AASD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG;IAC3D,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB,CAwBA;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAEpE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EAAE,EACxB,OAAO,EAAE,MAAM,GACd;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAqDrD"}
@@ -20,10 +20,22 @@ import type { DispatchFn, SnapshotFn, ToolDescriptor } from "../types";
20
20
  import type { AgentMessage, Provider } from "../providers/types";
21
21
  import { EffectLedger } from "../effects/ledger";
22
22
  import { type AskBuoyPolicy } from "../policy/policy";
23
+ import { digestOf } from "../effects/digest";
23
24
  import { type Block } from "../blocks/types";
24
25
  export type TurnEvent = {
25
26
  type: "text";
26
27
  delta: string;
28
+ /**
29
+ * This delta opens a new round of the same answer.
30
+ *
31
+ * One assistant bubble spans every round of a multi-step run, so without
32
+ * a marker the last sentence of one round and the first of the next are
33
+ * concatenated — "…resets every launch.Here's the full picture…". The
34
+ * ENGINE is the only layer that knows where a round ends: the UI sees a
35
+ * flat stream of deltas, and the tool events it used to infer the
36
+ * boundary from are not always there (a declined approval runs no tool).
37
+ */
38
+ breakBefore?: boolean;
27
39
  }
28
40
  /**
29
41
  * The model's own reasoning for this turn, when the provider reports any.
@@ -36,6 +48,18 @@ export type TurnEvent = {
36
48
  | {
37
49
  type: "reasoning";
38
50
  text: string;
51
+ }
52
+ /**
53
+ * Whole rounds were dropped from the model's memory before this turn.
54
+ *
55
+ * Yielded by the SESSION (which owns trimming), never by the engine. The
56
+ * screen still shows those rounds, so without this the transcript and the
57
+ * model silently disagree — the user asks "turn off that override" and the
58
+ * model, having lost the round that armed it, asks which one.
59
+ */
60
+ | {
61
+ type: "history-trimmed";
62
+ droppedRounds: number;
39
63
  } | {
40
64
  type: "tool-start";
41
65
  id: string;
@@ -93,11 +117,20 @@ export type TurnEvent = {
93
117
  type: "error";
94
118
  message: string;
95
119
  }
96
- /** Token usage for one provider request, when the provider reports it. */
120
+ /**
121
+ * Token usage for one provider request, when the provider reports it.
122
+ * `cacheRead`/`cacheWrite` are the prompt-cache counters (see TokenUsage —
123
+ * without them a cached Claude request looks nearly free) and `model` is
124
+ * the id the provider actually SERVED, which is what a cost table or a
125
+ * benchmark needs when a gateway alias drifts to a new snapshot.
126
+ */
97
127
  | {
98
128
  type: "usage";
99
129
  input: number;
100
130
  output: number;
131
+ cacheRead?: number;
132
+ cacheWrite?: number;
133
+ model?: string;
101
134
  } | {
102
135
  type: "done";
103
136
  };
@@ -106,6 +139,8 @@ export interface RunTurnInput {
106
139
  catalog: ToolDescriptor[];
107
140
  messages: AgentMessage[];
108
141
  system: string;
142
+ /** Per-turn "right now" block. See ProviderRequest.systemVolatile. */
143
+ systemVolatile?: string;
109
144
  model: string;
110
145
  maxTokens: number;
111
146
  dispatch: DispatchFn;
@@ -131,10 +166,57 @@ export interface RunTurnInput {
131
166
  label: string;
132
167
  description: string;
133
168
  reason: string;
169
+ /**
170
+ * The exact call being asked about.
171
+ *
172
+ * The UI does not render it — an approval prompt shows the effect, not the
173
+ * payload. It travels so a card that OUTLIVES this turn can still run it:
174
+ * the sheet persists an unanswered approval, and after a reload the
175
+ * generator holding this promise no longer exists, so Allow has to
176
+ * re-dispatch the call itself.
177
+ */
178
+ params: Record<string, unknown>;
179
+ /**
180
+ * A fingerprint of the value this call is about to overwrite, read at the
181
+ * moment the question was asked — see `readTargetDigest`. A card that comes
182
+ * back after a restart re-reads and compares before it writes; a card
183
+ * answered live never needs it. Absent when the target cannot be read.
184
+ */
185
+ targetDigest?: string;
134
186
  }) => Promise<boolean>;
135
187
  signal?: AbortSignal;
188
+ /**
189
+ * Every http(s) URL this CONVERSATION has read out of a tool result. Owned
190
+ * by the session so it outlives one turn: "now show me those as pictures"
191
+ * is a normal second message, and a per-turn set answered it by silently
192
+ * stripping every image — the model then described artwork the user could
193
+ * not see. Provenance is still enforced, just over the whole conversation
194
+ * rather than one turn of it. Omitted (tests, one-shot callers) means a
195
+ * fresh per-turn set.
196
+ */
197
+ seenUrls?: Set<string>;
136
198
  }
137
199
  export declare function runAgentTurn(input: RunTurnInput): AsyncGenerator<TurnEvent, AgentMessage[], void>;
200
+ export { digestOf };
201
+ /**
202
+ * Fingerprint the value a write is about to replace.
203
+ *
204
+ * Built for the approval card that outlives its turn: the app crashed with
205
+ * "Set bag line L-01 qty to 14" still asking, relaunched, and the card came
206
+ * back — and Allow wrote qty 14 against whatever the bag was NOW, maybe a
207
+ * different account, maybe a line that no longer existed. A hash of the
208
+ * params alone would not catch that (same label, same params, different
209
+ * world). So the card carries a digest of the TARGET at ask time, and a
210
+ * restored Allow re-reads and compares before it writes. Undefined when the
211
+ * target cannot be read — then the card can only warn, not check.
212
+ */
213
+ export declare function readTargetDigest(input: {
214
+ toolId: string;
215
+ action: string;
216
+ params: Record<string, unknown>;
217
+ dispatch: DispatchFn;
218
+ catalog?: ToolDescriptor[];
219
+ }): Promise<string | undefined>;
138
220
  export interface GatedActionInput {
139
221
  toolId: string;
140
222
  action: string;
@@ -1 +1 @@
1
- {"version":3,"file":"runAgentTurn.d.ts","sourceRoot":"","sources":["../../../src/engine/runAgentTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAoB,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAKzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EAIT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAK5E,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAazD,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACjC;;;;;;;GAOG;GACD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MA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