@buoy-gg/agent-core 7.0.35 → 7.0.38

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 (208) hide show
  1. package/README.md +21 -14
  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 +213 -48
  9. package/lib/commonjs/catalog/catalog.g.js.map +1 -1
  10. package/lib/commonjs/catalog/catalog.source.json +226 -48
  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 +44 -6
  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 +98 -2
  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/evidence.js +113 -0
  32. package/lib/commonjs/engine/evidence.js.map +1 -0
  33. package/lib/commonjs/engine/historyBudget.js +363 -0
  34. package/lib/commonjs/engine/historyBudget.js.map +1 -0
  35. package/lib/commonjs/engine/retrieve.js +214 -0
  36. package/lib/commonjs/engine/retrieve.js.map +1 -0
  37. package/lib/commonjs/engine/runAgentTurn.js +1231 -120
  38. package/lib/commonjs/engine/runAgentTurn.js.map +1 -1
  39. package/lib/commonjs/engine/systemPrompt.js +103 -9
  40. package/lib/commonjs/engine/systemPrompt.js.map +1 -1
  41. package/lib/commonjs/engine/textToolCalls.js +276 -0
  42. package/lib/commonjs/engine/textToolCalls.js.map +1 -0
  43. package/lib/commonjs/engine/tokenCalibration.js +81 -0
  44. package/lib/commonjs/engine/tokenCalibration.js.map +1 -0
  45. package/lib/commonjs/engine/verify.js +300 -0
  46. package/lib/commonjs/engine/verify.js.map +1 -0
  47. package/lib/commonjs/index.js +74 -0
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/policy/labels.js +19 -3
  50. package/lib/commonjs/policy/labels.js.map +1 -1
  51. package/lib/commonjs/policy/policy.js +6 -1
  52. package/lib/commonjs/policy/policy.js.map +1 -1
  53. package/lib/commonjs/policy/redact.js +42 -5
  54. package/lib/commonjs/policy/redact.js.map +1 -1
  55. package/lib/commonjs/providers/anthropic.js +340 -208
  56. package/lib/commonjs/providers/anthropic.js.map +1 -1
  57. package/lib/commonjs/providers/openai.js +237 -103
  58. package/lib/commonjs/providers/openai.js.map +1 -1
  59. package/lib/commonjs/providers/problem.js +98 -0
  60. package/lib/commonjs/providers/problem.js.map +1 -0
  61. package/lib/commonjs/providers/sse.js +170 -34
  62. package/lib/commonjs/providers/sse.js.map +1 -1
  63. package/lib/commonjs/providers/streamTimer.js +123 -0
  64. package/lib/commonjs/providers/streamTimer.js.map +1 -0
  65. package/lib/commonjs/providers/transport.js +123 -0
  66. package/lib/commonjs/providers/transport.js.map +1 -0
  67. package/lib/commonjs/providers/xhrStream.js +212 -0
  68. package/lib/commonjs/providers/xhrStream.js.map +1 -0
  69. package/lib/commonjs/session.js +242 -58
  70. package/lib/commonjs/session.js.map +1 -1
  71. package/lib/module/blocks/receipts.js +57 -1
  72. package/lib/module/blocks/receipts.js.map +1 -1
  73. package/lib/module/blocks/types.js +23 -2
  74. package/lib/module/blocks/types.js.map +1 -1
  75. package/lib/module/blocks/uiTool.js +421 -10
  76. package/lib/module/blocks/uiTool.js.map +1 -1
  77. package/lib/module/catalog/catalog.g.js +213 -48
  78. package/lib/module/catalog/catalog.g.js.map +1 -1
  79. package/lib/module/catalog/catalog.source.json +226 -48
  80. package/lib/module/catalog/catalog.types.g.js +40 -0
  81. package/lib/module/catalog/catalog.types.g.js.map +1 -0
  82. package/lib/module/catalog/normalizeParams.js +327 -0
  83. package/lib/module/catalog/normalizeParams.js.map +1 -0
  84. package/lib/module/catalog/signature.js +63 -0
  85. package/lib/module/catalog/signature.js.map +1 -0
  86. package/lib/module/catalog/snapshotReads.js +13 -6
  87. package/lib/module/catalog/snapshotReads.js.map +1 -1
  88. package/lib/module/catalog/toProviderTools.js +44 -6
  89. package/lib/module/catalog/toProviderTools.js.map +1 -1
  90. package/lib/module/context/buildContextPack.js +366 -19
  91. package/lib/module/context/buildContextPack.js.map +1 -1
  92. package/lib/module/effects/digest.js +29 -0
  93. package/lib/module/effects/digest.js.map +1 -0
  94. package/lib/module/effects/ledger.js +98 -2
  95. package/lib/module/effects/ledger.js.map +1 -1
  96. package/lib/module/engine/askGate.js +280 -0
  97. package/lib/module/engine/askGate.js.map +1 -0
  98. package/lib/module/engine/effectFor.js +83 -1
  99. package/lib/module/engine/effectFor.js.map +1 -1
  100. package/lib/module/engine/evidence.js +107 -0
  101. package/lib/module/engine/evidence.js.map +1 -0
  102. package/lib/module/engine/historyBudget.js +355 -0
  103. package/lib/module/engine/historyBudget.js.map +1 -0
  104. package/lib/module/engine/retrieve.js +210 -0
  105. package/lib/module/engine/retrieve.js.map +1 -0
  106. package/lib/module/engine/runAgentTurn.js +1227 -121
  107. package/lib/module/engine/runAgentTurn.js.map +1 -1
  108. package/lib/module/engine/systemPrompt.js +101 -9
  109. package/lib/module/engine/systemPrompt.js.map +1 -1
  110. package/lib/module/engine/textToolCalls.js +270 -0
  111. package/lib/module/engine/textToolCalls.js.map +1 -0
  112. package/lib/module/engine/tokenCalibration.js +75 -0
  113. package/lib/module/engine/tokenCalibration.js.map +1 -0
  114. package/lib/module/engine/verify.js +292 -0
  115. package/lib/module/engine/verify.js.map +1 -0
  116. package/lib/module/index.js +7 -3
  117. package/lib/module/index.js.map +1 -1
  118. package/lib/module/policy/labels.js +19 -3
  119. package/lib/module/policy/labels.js.map +1 -1
  120. package/lib/module/policy/policy.js +6 -1
  121. package/lib/module/policy/policy.js.map +1 -1
  122. package/lib/module/policy/redact.js +42 -5
  123. package/lib/module/policy/redact.js.map +1 -1
  124. package/lib/module/providers/anthropic.js +341 -209
  125. package/lib/module/providers/anthropic.js.map +1 -1
  126. package/lib/module/providers/openai.js +238 -104
  127. package/lib/module/providers/openai.js.map +1 -1
  128. package/lib/module/providers/problem.js +92 -0
  129. package/lib/module/providers/problem.js.map +1 -0
  130. package/lib/module/providers/sse.js +166 -34
  131. package/lib/module/providers/sse.js.map +1 -1
  132. package/lib/module/providers/streamTimer.js +118 -0
  133. package/lib/module/providers/streamTimer.js.map +1 -0
  134. package/lib/module/providers/transport.js +119 -0
  135. package/lib/module/providers/transport.js.map +1 -0
  136. package/lib/module/providers/xhrStream.js +207 -0
  137. package/lib/module/providers/xhrStream.js.map +1 -0
  138. package/lib/module/session.js +226 -60
  139. package/lib/module/session.js.map +1 -1
  140. package/lib/typescript/blocks/receipts.d.ts +5 -0
  141. package/lib/typescript/blocks/receipts.d.ts.map +1 -1
  142. package/lib/typescript/blocks/types.d.ts +23 -2
  143. package/lib/typescript/blocks/types.d.ts.map +1 -1
  144. package/lib/typescript/blocks/uiTool.d.ts +11 -2
  145. package/lib/typescript/blocks/uiTool.d.ts.map +1 -1
  146. package/lib/typescript/catalog/catalog.g.d.ts +2 -2
  147. package/lib/typescript/catalog/catalog.g.d.ts.map +1 -1
  148. package/lib/typescript/catalog/catalog.types.g.d.ts +40 -0
  149. package/lib/typescript/catalog/catalog.types.g.d.ts.map +1 -0
  150. package/lib/typescript/catalog/normalizeParams.d.ts +43 -0
  151. package/lib/typescript/catalog/normalizeParams.d.ts.map +1 -0
  152. package/lib/typescript/catalog/signature.d.ts +29 -0
  153. package/lib/typescript/catalog/signature.d.ts.map +1 -0
  154. package/lib/typescript/catalog/snapshotReads.d.ts.map +1 -1
  155. package/lib/typescript/catalog/toProviderTools.d.ts +28 -15
  156. package/lib/typescript/catalog/toProviderTools.d.ts.map +1 -1
  157. package/lib/typescript/context/buildContextPack.d.ts +24 -2
  158. package/lib/typescript/context/buildContextPack.d.ts.map +1 -1
  159. package/lib/typescript/effects/digest.d.ts +10 -0
  160. package/lib/typescript/effects/digest.d.ts.map +1 -0
  161. package/lib/typescript/effects/ledger.d.ts +73 -0
  162. package/lib/typescript/effects/ledger.d.ts.map +1 -1
  163. package/lib/typescript/engine/askGate.d.ts +29 -0
  164. package/lib/typescript/engine/askGate.d.ts.map +1 -0
  165. package/lib/typescript/engine/effectFor.d.ts +6 -1
  166. package/lib/typescript/engine/effectFor.d.ts.map +1 -1
  167. package/lib/typescript/engine/evidence.d.ts +67 -0
  168. package/lib/typescript/engine/evidence.d.ts.map +1 -0
  169. package/lib/typescript/engine/historyBudget.d.ts +115 -0
  170. package/lib/typescript/engine/historyBudget.d.ts.map +1 -0
  171. package/lib/typescript/engine/retrieve.d.ts +32 -0
  172. package/lib/typescript/engine/retrieve.d.ts.map +1 -0
  173. package/lib/typescript/engine/runAgentTurn.d.ts +179 -3
  174. package/lib/typescript/engine/runAgentTurn.d.ts.map +1 -1
  175. package/lib/typescript/engine/systemPrompt.d.ts +80 -0
  176. package/lib/typescript/engine/systemPrompt.d.ts.map +1 -1
  177. package/lib/typescript/engine/textToolCalls.d.ts +58 -0
  178. package/lib/typescript/engine/textToolCalls.d.ts.map +1 -0
  179. package/lib/typescript/engine/tokenCalibration.d.ts +46 -0
  180. package/lib/typescript/engine/tokenCalibration.d.ts.map +1 -0
  181. package/lib/typescript/engine/verify.d.ts +67 -0
  182. package/lib/typescript/engine/verify.d.ts.map +1 -0
  183. package/lib/typescript/index.d.ts +7 -3
  184. package/lib/typescript/index.d.ts.map +1 -1
  185. package/lib/typescript/policy/labels.d.ts.map +1 -1
  186. package/lib/typescript/policy/policy.d.ts.map +1 -1
  187. package/lib/typescript/policy/redact.d.ts.map +1 -1
  188. package/lib/typescript/providers/anthropic.d.ts.map +1 -1
  189. package/lib/typescript/providers/openai.d.ts +0 -16
  190. package/lib/typescript/providers/openai.d.ts.map +1 -1
  191. package/lib/typescript/providers/problem.d.ts +50 -0
  192. package/lib/typescript/providers/problem.d.ts.map +1 -0
  193. package/lib/typescript/providers/sse.d.ts +86 -2
  194. package/lib/typescript/providers/sse.d.ts.map +1 -1
  195. package/lib/typescript/providers/streamTimer.d.ts +59 -0
  196. package/lib/typescript/providers/streamTimer.d.ts.map +1 -0
  197. package/lib/typescript/providers/transport.d.ts +48 -0
  198. package/lib/typescript/providers/transport.d.ts.map +1 -0
  199. package/lib/typescript/providers/types.d.ts +105 -3
  200. package/lib/typescript/providers/types.d.ts.map +1 -1
  201. package/lib/typescript/providers/xhrStream.d.ts +45 -0
  202. package/lib/typescript/providers/xhrStream.d.ts.map +1 -0
  203. package/lib/typescript/session.d.ts +55 -4
  204. package/lib/typescript/session.d.ts.map +1 -1
  205. package/lib/typescript/types.d.ts +6 -0
  206. package/lib/typescript/types.d.ts.map +1 -1
  207. package/package.json +10 -10
  208. package/LICENSE +0 -58
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createAnthropicProvider = createAnthropicProvider;
7
7
  var _sse = require("./sse");
8
+ var _streamTimer = require("./streamTimer");
9
+ var _transport = require("./transport");
10
+ var _problem = require("./problem");
8
11
  /**
9
12
  * Anthropic Messages protocol.
10
13
  *
@@ -31,6 +34,38 @@ var _sse = require("./sse");
31
34
  */
32
35
 
33
36
  const DEFAULT_VERSION = "2023-06-01";
37
+ /**
38
+ * Mark the last content block of the last message as a cache breakpoint.
39
+ *
40
+ * WHY THERE IS A SECOND BREAKPOINT AT ALL. The first one, at the end of
41
+ * `system`, caches the tools and the system prompt — the big fixed prefix. It
42
+ * does nothing for the messages, which were left uncached on the reasoning
43
+ * that they grow every turn and so would pay the write multiplier for a prefix
44
+ * never read back. That is true of a turn with ONE request. It is false of the
45
+ * turns this tool actually makes: a turn runs 3 to 8 model requests, each
46
+ * re-sending the whole conversation plus everything the previous steps read,
47
+ * and steps 2..N are exactly a re-read of what step 1 already sent.
48
+ *
49
+ * So the breakpoint MOVES: each request marks its own last block, and the next
50
+ * request hits it (Anthropic looks back ~20 blocks for a match). Step 1 writes
51
+ * the messages at 1.25x, every later step reads them at 0.1x and writes only
52
+ * its own delta.
53
+ *
54
+ * What it does NOT buy is cross-TURN caching, because the volatile "right now"
55
+ * block sits at the end of `system` and changes every turn, invalidating
56
+ * anything after it. Within a turn is where the multiplier lives, and that is
57
+ * what this collects.
58
+ */
59
+ function markLastBlock(out) {
60
+ const lastMessage = out[out.length - 1];
61
+ const lastBlock = lastMessage?.content[lastMessage.content.length - 1];
62
+ if (lastBlock) {
63
+ lastBlock.cache_control = {
64
+ type: "ephemeral"
65
+ };
66
+ }
67
+ return out;
68
+ }
34
69
  function toWireMessages(messages) {
35
70
  const out = [];
36
71
  for (const m of messages) {
@@ -80,235 +115,332 @@ function toWireMessages(messages) {
80
115
  return out;
81
116
  }
82
117
  function createAnthropicProvider(config) {
118
+ // One per provider, so the `auto` transport decision is made once and not
119
+ // re-learned (and re-buffered) at the start of every turn.
120
+ const transport = (0, _transport.createTransport)(config);
83
121
  return {
84
122
  protocol: "anthropic",
85
123
  async *send(req) {
86
- const headers = {
87
- "content-type": "application/json",
88
- "anthropic-version": config.anthropicVersion ?? DEFAULT_VERSION,
89
- ...(await (config.headers?.() ?? {}))
124
+ const timer = (0, _streamTimer.createStreamTimer)(req.signal, config);
125
+ const status = {
126
+ truncated: false
90
127
  };
91
- // Dev-only direct mode. A distributed build uses `headers` against the
92
- // org's own gateway and never carries a provider key at all.
93
- if (config.apiKey && !headers["x-api-key"] && !headers.Authorization) {
94
- headers["x-api-key"] = config.apiKey;
95
- // Without this the POST comes back with no access-control-allow-origin
96
- // and a browser/Electron renderer silently discards an otherwise fine
97
- // response — a 200 in the network log and "Failed to fetch" in JS.
98
- headers["anthropic-dangerous-direct-browser-access"] = "true";
99
- }
100
- const response = await fetch(config.endpoint, {
101
- method: "POST",
102
- headers,
103
- signal: req.signal,
104
- body: JSON.stringify({
105
- model: req.model,
106
- max_tokens: req.maxTokens,
107
- stream: true,
108
- // ONE cache breakpoint, at the end of `system`.
109
- //
110
- // Anthropic caches the prefix in a fixed order — tools, then system,
111
- // then messages — up to and including the block carrying
112
- // `cache_control`. So marking the end of the system prompt caches
113
- // the tool definitions with it, which is the point: the tools are
114
- // ~20k tokens and by far the larger half. A second breakpoint on the
115
- // last tool would buy nothing and spend one of the four available.
116
- //
117
- // Messages stay uncached on purpose. They grow every turn, so they
118
- // would invalidate on each request and pay the write multiplier for
119
- // a prefix that is never read back.
120
- system: config.cache === false ? req.system : [{
121
- type: "text",
122
- text: req.system,
123
- cache_control: {
124
- type: "ephemeral"
125
- }
126
- }],
127
- tools: req.tools.map(t => ({
128
- name: t.name,
129
- description: t.description,
130
- input_schema: t.inputSchema
131
- })),
132
- messages: toWireMessages(req.messages),
133
- ...config.requestOverrides
134
- })
135
- });
136
- if (!response.ok) {
137
- yield {
138
- type: "error",
139
- message: await (0, _sse.errorBody)(response)
128
+ try {
129
+ const headers = {
130
+ "content-type": "application/json",
131
+ "anthropic-version": config.anthropicVersion ?? DEFAULT_VERSION,
132
+ ...(await (config.headers?.() ?? {}))
140
133
  };
141
- return;
142
- }
134
+ // Dev-only direct mode. A distributed build uses `headers` against the
135
+ // org's own gateway and never carries a provider key at all.
136
+ if (config.apiKey && !headers["x-api-key"] && !headers.Authorization) {
137
+ headers["x-api-key"] = config.apiKey;
138
+ // Without this the POST comes back with no access-control-allow-origin
139
+ // and a browser/Electron renderer silently discards an otherwise fine
140
+ // response — a 200 in the network log and "Failed to fetch" in JS.
141
+ headers["anthropic-dangerous-direct-browser-access"] = "true";
142
+ }
143
+ const stream = await transport.open({
144
+ headers,
145
+ // The timer's signal, not the caller's: it aborts on the user's Stop
146
+ // AND on either clock running out. See providers/streamTimer.ts.
147
+ signal: timer.signal,
148
+ body: JSON.stringify({
149
+ model: req.model,
150
+ max_tokens: req.maxTokens,
151
+ stream: true,
152
+ // ONE cache breakpoint, at the end of `system`.
153
+ //
154
+ // Anthropic caches the prefix in a fixed order — tools, then system,
155
+ // then messages — up to and including the block carrying
156
+ // `cache_control`. So marking the end of the system prompt caches
157
+ // the tool definitions with it, which is the point: the tools are
158
+ // ~20k tokens and by far the larger half. A second breakpoint on the
159
+ // last tool would buy nothing and spend one of the four available.
160
+ //
161
+ // Messages stay uncached on purpose. They grow every turn, so they
162
+ // would invalidate on each request and pay the write multiplier for
163
+ // a prefix that is never read back.
164
+ //
165
+ // The volatile block (what is on screen right now) goes in a SECOND
166
+ // text block after the breakpoint. It changes every turn; inside the
167
+ // cached block it would invalidate the whole prefix each time.
168
+ system: config.cache === false ? req.systemVolatile ? `${req.system}\n\n---\n\n${req.systemVolatile}` : req.system : [{
169
+ type: "text",
170
+ text: req.system,
171
+ cache_control: {
172
+ type: "ephemeral"
173
+ }
174
+ }, ...(req.systemVolatile ? [{
175
+ type: "text",
176
+ text: req.systemVolatile
177
+ }] : [])],
178
+ tools: req.tools.map(t => ({
179
+ name: t.name,
180
+ description: t.description,
181
+ input_schema: t.inputSchema,
182
+ // Anthropic-only. Each example must validate against input_schema
183
+ // or the API 400s, so these are generated from the catalog rather
184
+ // than written by hand.
185
+ ...(t.inputExamples?.length ? {
186
+ input_examples: t.inputExamples
187
+ } : {})
188
+ })),
189
+ messages: config.cache === false ? toWireMessages(req.messages) : markLastBlock(toWireMessages(req.messages)),
190
+ ...config.requestOverrides
191
+ })
192
+ });
143
193
 
144
- // Partial tool_use args accumulate here, keyed by content-block index.
145
- const pending = new Map();
146
- // Partial thinking blocks, same keying. `thinking_delta` carries the
147
- // text and `signature_delta` the signature, and the signature usually
148
- // arrives in ONE delta right at the end — a reader that stops at
149
- // thinking_delta replays an unsigned block, which the API rejects.
150
- const thinking = new Map();
151
- let stopReason;
152
- let usage;
153
- for await (const ev of (0, _sse.readSse)(response)) {
154
- let payload;
155
- try {
156
- payload = JSON.parse(ev.data);
157
- } catch {
158
- continue;
194
+ // Headers are in: the connect clock stops here and the idle one starts.
195
+ timer.connected();
196
+ if (stream.problem) {
197
+ yield {
198
+ type: "error",
199
+ message: stream.problem,
200
+ kind: "provider",
201
+ problem: stream.problemInfo
202
+ };
203
+ return;
159
204
  }
160
- const kind = payload.type ?? ev.event;
161
- switch (kind) {
162
- case "content_block_start":
163
- {
164
- const block = payload.content_block;
165
- if (block?.type === "thinking") {
166
- thinking.set(payload.index, {
167
- thinking: block.thinking ?? "",
168
- signature: block.signature ?? ""
169
- });
170
- } else if (block?.type === "redacted_thinking") {
171
- // No deltas for these — the whole (encrypted) payload is here.
172
- yield {
173
- type: "thinking",
174
- block: {
175
- type: "redacted_thinking",
176
- data: block.data
177
- }
178
- };
179
- } else if (block?.type === "tool_use") {
180
- // NOT block.input — see note 1.
181
- pending.set(payload.index, {
182
- id: block.id,
183
- name: block.name,
184
- json: ""
185
- });
205
+
206
+ // Partial tool_use args accumulate here, keyed by content-block index.
207
+ const pending = new Map();
208
+ // Partial thinking blocks, same keying. `thinking_delta` carries the
209
+ // text and `signature_delta` the signature, and the signature usually
210
+ // arrives in ONE delta right at the end — a reader that stops at
211
+ // thinking_delta replays an unsigned block, which the API rejects.
212
+ const thinking = new Map();
213
+ let stopReason;
214
+ let usage;
215
+ let model;
216
+ /** The protocol's end marker; ends the read. See `sawTerminal` below. */
217
+ let sawStop = false;
218
+ for await (const ev of stream.frames({
219
+ status,
220
+ onFrame: timer.activity,
221
+ signal: timer.signal
222
+ })) {
223
+ let payload;
224
+ try {
225
+ payload = JSON.parse(ev.data);
226
+ } catch {
227
+ continue;
228
+ }
229
+ const kind = payload.type ?? ev.event;
230
+ switch (kind) {
231
+ case "content_block_start":
232
+ {
233
+ const block = payload.content_block;
234
+ if (block?.type === "thinking") {
235
+ thinking.set(payload.index, {
236
+ thinking: block.thinking ?? "",
237
+ signature: block.signature ?? ""
238
+ });
239
+ } else if (block?.type === "redacted_thinking") {
240
+ // No deltas for these — the whole (encrypted) payload is here.
241
+ yield {
242
+ type: "thinking",
243
+ block: {
244
+ type: "redacted_thinking",
245
+ data: block.data
246
+ }
247
+ };
248
+ } else if (block?.type === "tool_use") {
249
+ // NOT block.input — see note 1.
250
+ pending.set(payload.index, {
251
+ id: block.id,
252
+ name: block.name,
253
+ json: ""
254
+ });
255
+ }
256
+ break;
186
257
  }
187
- break;
188
- }
189
- case "content_block_delta":
190
- {
191
- const delta = payload.delta;
192
- if (delta?.type === "text_delta") {
193
- yield {
194
- type: "text",
195
- delta: delta.text
196
- };
197
- } else if (delta?.type === "input_json_delta") {
198
- const slot = pending.get(payload.index);
199
- if (slot) slot.json += delta.partial_json ?? "";
200
- } else if (delta?.type === "thinking_delta") {
201
- const slot = thinking.get(payload.index);
202
- if (slot) slot.thinking += delta.thinking ?? "";
203
- } else if (delta?.type === "signature_delta") {
204
- const slot = thinking.get(payload.index);
205
- if (slot) slot.signature += delta.signature ?? "";
258
+ case "content_block_delta":
259
+ {
260
+ const delta = payload.delta;
261
+ if (delta?.type === "text_delta") {
262
+ yield {
263
+ type: "text",
264
+ delta: delta.text
265
+ };
266
+ } else if (delta?.type === "input_json_delta") {
267
+ const slot = pending.get(payload.index);
268
+ if (slot) slot.json += delta.partial_json ?? "";
269
+ } else if (delta?.type === "thinking_delta") {
270
+ const slot = thinking.get(payload.index);
271
+ if (slot) slot.thinking += delta.thinking ?? "";
272
+ } else if (delta?.type === "signature_delta") {
273
+ const slot = thinking.get(payload.index);
274
+ if (slot) slot.signature += delta.signature ?? "";
275
+ }
276
+ break;
206
277
  }
207
- break;
208
- }
209
- case "content_block_stop":
210
- {
211
- const thought = thinking.get(payload.index);
212
- if (thought) {
213
- thinking.delete(payload.index);
214
- yield {
215
- type: "thinking",
216
- block: {
278
+ case "content_block_stop":
279
+ {
280
+ const thought = thinking.get(payload.index);
281
+ if (thought) {
282
+ thinking.delete(payload.index);
283
+ yield {
217
284
  type: "thinking",
218
- ...thought
285
+ block: {
286
+ type: "thinking",
287
+ ...thought
288
+ }
289
+ };
290
+ }
291
+ const slot = pending.get(payload.index);
292
+ if (slot) {
293
+ pending.delete(payload.index);
294
+ let input = {};
295
+ try {
296
+ input = slot.json ? JSON.parse(slot.json) : {};
297
+ } catch {
298
+ yield {
299
+ type: "error",
300
+ kind: "provider",
301
+ // Same evidence as the OpenAI path. The stop reason is not
302
+ // known yet here — it rides on `message_delta`, which comes
303
+ // after this block closes — so only the raw tail is carried.
304
+ message: (0, _sse.unparseableMessage)(slot.name, slot.json)
305
+ };
306
+ break;
219
307
  }
220
- };
221
- }
222
- const slot = pending.get(payload.index);
223
- if (slot) {
224
- pending.delete(payload.index);
225
- let input = {};
226
- try {
227
- input = slot.json ? JSON.parse(slot.json) : {};
228
- } catch {
308
+ const call = {
309
+ id: slot.id,
310
+ name: slot.name,
311
+ input
312
+ };
229
313
  yield {
230
- type: "error",
231
- message: `Model sent unparseable arguments for ${slot.name}`
314
+ type: "tool-call",
315
+ call
232
316
  };
233
- break;
234
317
  }
235
- const call = {
236
- id: slot.id,
237
- name: slot.name,
238
- input
239
- };
240
- yield {
241
- type: "tool-call",
242
- call
243
- };
318
+ break;
244
319
  }
245
- break;
246
- }
247
- case "message_start":
248
- {
249
- // The cache counters arrive HERE, not on message_delta — the
250
- // prefix is accounted for before a single token is generated. A
251
- // reader that only watches message_delta sees cacheRead 0 on
252
- // every request and concludes caching is not working.
253
- const m = payload.message;
254
- const u = m?.usage;
255
- if (u) {
256
- usage = {
257
- input: u.input_tokens ?? 0,
258
- output: u.output_tokens ?? 0,
259
- ...(u.cache_read_input_tokens !== undefined ? {
260
- cacheRead: u.cache_read_input_tokens
261
- } : {}),
262
- ...(u.cache_creation_input_tokens !== undefined ? {
263
- cacheWrite: u.cache_creation_input_tokens
264
- } : {})
265
- };
320
+ case "message_start":
321
+ {
322
+ // The cache counters arrive HERE, not on message_delta — the
323
+ // prefix is accounted for before a single token is generated. A
324
+ // reader that only watches message_delta sees cacheRead 0 on
325
+ // every request and concludes caching is not working.
326
+ const m = payload.message;
327
+ // The served model id is named here and nowhere else — a gateway
328
+ // resolves an alias to a dated snapshot, and this is that id.
329
+ if (typeof m?.model === "string" && m.model) model = m.model;
330
+ const u = m?.usage;
331
+ if (u) {
332
+ usage = {
333
+ input: u.input_tokens ?? 0,
334
+ output: u.output_tokens ?? 0,
335
+ ...(u.cache_read_input_tokens !== undefined ? {
336
+ cacheRead: u.cache_read_input_tokens
337
+ } : {}),
338
+ ...(u.cache_creation_input_tokens !== undefined ? {
339
+ cacheWrite: u.cache_creation_input_tokens
340
+ } : {})
341
+ };
342
+ }
343
+ break;
266
344
  }
267
- break;
268
- }
269
- case "message_delta":
270
- {
271
- const delta = payload.delta;
272
- if (delta?.stop_reason) stopReason = delta.stop_reason;
273
- // Cumulative, not incremental — assign, never add. Output tokens
274
- // are only final here, so keep whatever message_start reported
275
- // about the cache rather than replacing the whole record.
276
- const u = payload.usage;
277
- if (u) {
278
- usage = {
279
- ...usage,
280
- input: u.input_tokens ?? usage?.input ?? 0,
281
- output: u.output_tokens ?? 0
345
+ case "message_delta":
346
+ {
347
+ const delta = payload.delta;
348
+ // `stop_reason` is the model's own statement that it finished,
349
+ // and counts as terminal on its own (see `sawTerminal`). It does
350
+ // NOT end the read: `message_stop` is one frame away and there is
351
+ // no reason to cancel a stream that is about to close itself.
352
+ if (delta?.stop_reason) stopReason = delta.stop_reason;
353
+ // Cumulative, not incremental — assign, never add. Output tokens
354
+ // are only final here, so keep whatever message_start reported
355
+ // about the cache rather than replacing the whole record.
356
+ const u = payload.usage;
357
+ if (u) {
358
+ usage = {
359
+ ...usage,
360
+ input: u.input_tokens ?? usage?.input ?? 0,
361
+ output: u.output_tokens ?? 0
362
+ };
363
+ }
364
+ break;
365
+ }
366
+ case "error":
367
+ {
368
+ const err = payload.error;
369
+ const message = err?.message ?? "Provider error";
370
+ yield {
371
+ type: "error",
372
+ message,
373
+ kind: "provider",
374
+ // `overloaded_error` on a committed 200 is the common shape —
375
+ // classified so the engine can retry it when nothing came first.
376
+ problem: (0, _problem.classifyProblem)({
377
+ type: typeof err?.type === "string" ? err.type : undefined,
378
+ message
379
+ })
282
380
  };
381
+ return;
283
382
  }
383
+ case "message_stop":
384
+ // The end. There is no [DONE] — see note 2.
385
+ sawStop = true;
284
386
  break;
285
- }
286
- case "error":
287
- {
288
- const err = payload.error;
289
- yield {
290
- type: "error",
291
- message: err?.message ?? "Provider error"
292
- };
293
- return;
294
- }
295
- case "message_stop":
296
- // The end. There is no [DONE] — see note 2.
297
- yield {
298
- type: "done",
299
- stopReason,
300
- usage
301
- };
302
- return;
303
- default:
304
- break;
387
+ default:
388
+ break;
389
+ }
390
+ // `break` inside the switch leaves the switch, not the loop.
391
+ if (sawStop) break;
392
+ }
393
+
394
+ /**
395
+ * Did the provider actually say it was finished?
396
+ *
397
+ * `message_stop` is the protocol's end marker. `stop_reason` counts
398
+ * too: it is the model's own statement of why it stopped, which is the
399
+ * stronger claim — `message_stop` only says the SSE stream closed. A
400
+ * proxy that forwards the delta and drops the final frame has still
401
+ * delivered a whole answer, and refusing it would break working
402
+ * gateways for no safety gain. NEITHER arriving is the case that
403
+ * matters: bare EOF, which used to be read as success.
404
+ */
405
+ const sawTerminal = sawStop || stopReason !== undefined;
406
+ if (!sawTerminal) {
407
+ // Bare EOF. Whatever text arrived is real and the engine will show it,
408
+ // but the plan behind it is half-written: a connection cut after
409
+ // `{"key":"cart","value":[]}` leaves valid JSON that reads exactly like
410
+ // a finished thought. Nothing here is admitted for execution.
411
+ yield {
412
+ type: "error",
413
+ message: (0, _sse.truncatedMessage)(status.truncated),
414
+ kind: "truncated"
415
+ };
416
+ return;
305
417
  }
418
+ yield {
419
+ type: "done",
420
+ outcome: stopReason === "max_tokens" ? "output-limited" : "completed",
421
+ stopReason,
422
+ usage,
423
+ model
424
+ };
425
+ } catch (err) {
426
+ // The user's Stop wins the label even if a clock fired in the same
427
+ // tick: they know why the turn ended, and "timed out" would be a lie.
428
+ if (req.signal?.aborted) throw err;
429
+ const message = timer.message();
430
+ if (message) {
431
+ yield {
432
+ type: "error",
433
+ message,
434
+ kind: "timeout"
435
+ };
436
+ return;
437
+ }
438
+ // A genuine transport failure — DNS, refused connection, TLS. It has
439
+ // always propagated to the failed-turn card, and still does.
440
+ throw err;
441
+ } finally {
442
+ timer.dispose();
306
443
  }
307
- yield {
308
- type: "done",
309
- stopReason,
310
- usage
311
- };
312
444
  }
313
445
  };
314
446
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_sse","require","DEFAULT_VERSION","toWireMessages","messages","out","m","role","push","content","type","text","t","thinking","c","toolCalls","id","name","input","length","results","map","r","tool_use_id","toolCallId","isError","is_error","createAnthropicProvider","config","protocol","send","req","headers","anthropicVersion","apiKey","Authorization","response","fetch","endpoint","method","signal","body","JSON","stringify","model","max_tokens","maxTokens","stream","system","cache","cache_control","tools","description","input_schema","inputSchema","requestOverrides","ok","message","errorBody","pending","Map","stopReason","usage","ev","readSse","payload","parse","data","kind","event","block","content_block","set","index","signature","json","delta","slot","get","partial_json","thought","delete","call","u","input_tokens","output","output_tokens","cache_read_input_tokens","undefined","cacheRead","cache_creation_input_tokens","cacheWrite","stop_reason","err","error"],"sourceRoot":"../../../src","sources":["providers/anthropic.ts"],"mappings":";;;;;;AAkCA,IAAAA,IAAA,GAAAC,OAAA;AAlCA;AACA;AACA;AACA;AACA;AACA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aAAa,IAAI;gBAC7B,CAAC;cACH;cACA;YACF;UACA,KAAK,OAAO;YAAE;cACZ,MAAMO,GAAG,GAAG5B,OAAO,CAAC6B,KAA4C;cAChE,MAAM;gBACJpF,IAAI,EAAE,OAAO;gBACb+C,OAAO,EAAGoC,GAAG,EAAEpC,OAAO,IAAe;cACvC,CAAC;cACD;YACF;UACA,KAAK,cAAc;YACjB;YACA,MAAM;cAAE/C,IAAI,EAAE,MAAM;cAAEmD,UAAU;cAAEC;YAAM,CAAC;YACzC;UACF;YACE;QACJ;MACF;MAEA,MAAM;QAAEpD,IAAI,EAAE,MAAM;QAAEmD,UAAU;QAAEC;MAAM,CAAC;IAC3C;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_sse","require","_streamTimer","_transport","_problem","DEFAULT_VERSION","markLastBlock","out","lastMessage","length","lastBlock","content","cache_control","type","toWireMessages","messages","m","role","push","text","t","thinking","c","toolCalls","id","name","input","results","map","r","tool_use_id","toolCallId","isError","is_error","createAnthropicProvider","config","transport","createTransport","protocol","send","req","timer","createStreamTimer","signal","status","truncated","headers","anthropicVersion","apiKey","Authorization","stream","open","body","JSON","stringify","model","max_tokens","maxTokens","system","cache","systemVolatile","tools","description","input_schema","inputSchema","inputExamples","input_examples","requestOverrides","connected","problem","message","kind","problemInfo","pending","Map","stopReason","usage","sawStop","ev","frames","onFrame","activity","payload","parse","data","event","block","content_block","set","index","signature","json","delta","slot","get","partial_json","thought","delete","unparseableMessage","call","u","input_tokens","output","output_tokens","cache_read_input_tokens","undefined","cacheRead","cache_creation_input_tokens","cacheWrite","stop_reason","err","error","classifyProblem","sawTerminal","truncatedMessage","outcome","aborted","dispose"],"sourceRoot":"../../../src","sources":["providers/anthropic.ts"],"mappings":";;;;;;AAkCA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AArCA;AACA;AAC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