@linxiraos/pi-agent-core 1.5.14 → 1.5.15

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 (46) hide show
  1. package/CHANGELOG.md +47 -49
  2. package/README.md +7 -9
  3. package/THIRD-PARTY-NOTICES.txt +1 -1
  4. package/dist/types/agent-loop.d.ts +22 -0
  5. package/dist/types/agent.d.ts +21 -10
  6. package/dist/types/compaction/anthropic.d.ts +5 -6
  7. package/dist/types/compaction/bedrock.d.ts +3 -2
  8. package/dist/types/compaction/compaction-v2-streaming.d.ts +7 -3
  9. package/dist/types/compaction/compaction.d.ts +14 -2
  10. package/dist/types/compaction/entries.d.ts +2 -0
  11. package/dist/types/compaction/messages.d.ts +5 -2
  12. package/dist/types/compaction/openai.d.ts +3 -0
  13. package/dist/types/compaction/tool-protection.d.ts +1 -1
  14. package/dist/types/output-budget.d.ts +13 -0
  15. package/dist/types/replay-policy.d.ts +15 -1
  16. package/dist/types/sent-tool-definitions.d.ts +6 -3
  17. package/dist/types/telemetry.d.ts +2 -2
  18. package/dist/types/tool-arguments.d.ts +2 -1
  19. package/dist/types/types.d.ts +55 -26
  20. package/package.json +43 -43
  21. package/src/agent-loop.ts +120 -47
  22. package/src/agent.ts +103 -55
  23. package/src/compaction/anthropic.ts +26 -8
  24. package/src/compaction/bedrock.ts +6 -13
  25. package/src/compaction/branch-summarization.ts +2 -0
  26. package/src/compaction/compaction-v2-streaming.ts +22 -12
  27. package/src/compaction/compaction.ts +83 -7
  28. package/src/compaction/entries.ts +2 -0
  29. package/src/compaction/messages.ts +8 -2
  30. package/src/compaction/openai.ts +28 -24
  31. package/src/compaction/prompts/branch-summary.md +6 -0
  32. package/src/compaction/prompts/compaction-summary.md +9 -0
  33. package/src/compaction/prompts/compaction-turn-prefix.md +2 -0
  34. package/src/compaction/prompts/compaction-update-summary.md +10 -0
  35. package/src/compaction/prompts/handoff-document.md +9 -0
  36. package/src/compaction/prompts/handoff-summary-context.md +2 -1
  37. package/src/compaction/tool-protection.ts +8 -4
  38. package/src/compaction/utils.ts +1 -1
  39. package/src/output-budget.ts +31 -2
  40. package/src/replay-policy.ts +38 -3
  41. package/src/sent-tool-definitions.ts +20 -10
  42. package/src/speculative-execution.ts +29 -5
  43. package/src/telemetry.ts +31 -23
  44. package/src/tokenizer.ts +8 -1
  45. package/src/tool-arguments.ts +2 -1
  46. package/src/types.ts +54 -22
package/CHANGELOG.md CHANGED
@@ -1,10 +1,26 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [1.5.14] - 2026-11-22
3
+ ## [1.5.15] - 2026-11-27
4
4
 
5
- ### Added
5
+ ### Breaking Changes
6
+
7
+ - Removed the Bun event-loop workaround utilities from `@linxiraos/pi-agent-core/utils/yield`; agent loops no longer insert cooperative sleeps while streaming or between tool calls.
8
+ - Removed `ApprovalDetailsOptions`; `formatApprovalDetails` takes only `args` again, since the compact approval prompt no longer shows tool details ([#15642](https://github.com/Linxira-OS/linxira-zeta/pull/15642) by [@H4vC](https://github.com/H4vC))
9
+
10
+ ### Changed
11
+
12
+ - Released as part of Zeta 1.5.11; no package-specific user-visible changes.
13
+
14
+ ### Fixed
6
15
 
7
- - `/team` now manages personas, identity, memory, TeamPlans and room attachments from the conversation.
16
+ - Fixed Claude context counts reading Opus 5.5 requests about 55% over their billed input: a replayed thinking turn now counts at the output size Claude billed for it, not its signature's bytes ([#15446](https://github.com/Linxira-OS/linxira-zeta/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
17
+ - Fixed screenshots and other non-frame images being counted at the OpenAI rate for every model instead of the reading model's own; Claude billed them about 16% higher ([#15446](https://github.com/Linxira-OS/linxira-zeta/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
18
+ - Fixed OpenAI Responses and Codex context estimates leaving out replayed reasoning: each turn whose encrypted reasoning actually replays now counts its reported reasoning tokens (its ciphertext when the backend reports none), and none while a cold session rebuilds it out of the request, so compaction and snapcompact sizing match billing; branch summaries no longer budget for encrypted reasoning they never send ([#15447](https://github.com/Linxira-OS/linxira-zeta/pull/15447) by [@will-bogusz](https://github.com/will-bogusz))
19
+ - Fixed a Claude compaction or branch summarizer receiving assistant reasoning from a snapcompact archive rendered under another model, which Claude refuses (`reasoning_extraction`) ([#15436](https://github.com/Linxira-OS/linxira-zeta/pull/15436) by [@will-bogusz](https://github.com/will-bogusz))
20
+ - Fixed native (OpenAI/Codex) remote compaction refusing or truncating sessions that fit the window: its preflight counted the JSON-escaped request, inflating quote-, backslash- and newline-heavy tool output such as disassembly by ~10–20%; it now counts text as the model reads it ([#15712](https://github.com/Linxira-OS/linxira-zeta/pull/15712) by [@H4vC](https://github.com/H4vC))
21
+ - Fixed OpenAI V1/V2 remote compaction failing outright when the history, kept tail included, exceeds the context window (a large final response or tool output after the last check); it retries on the history before the kept tail ([#15712](https://github.com/Linxira-OS/linxira-zeta/pull/15712) by [@H4vC](https://github.com/H4vC))
22
+ - Fixed fitted output caps overflowing the context window on strict hosts (llama.cpp-family) after turns with many parallel tool results; chat-template framing is now charged per locally counted message ([#15699](https://github.com/Linxira-OS/linxira-zeta/issues/15699))
23
+ - Fixed leaked DeepSeek DSML markup reaching saved history from reasoning blocks and from turns that also made a valid tool call ([#15485](https://github.com/Linxira-OS/linxira-zeta/issues/15485))
8
24
 
9
25
  ## [9.2.2] - 2026-01-31
10
26
 
@@ -126,29 +142,38 @@
126
142
 
127
143
  ### Changed
128
144
 
129
- - Forked to @oh-my-pi scope with unified versioning across all packages
145
+ - Forked to @linxiraos scope with unified versioning across all packages
130
146
 
131
147
  ## [1.337.0] - 2026-01-02
132
148
 
133
- Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mono](https://github.com/badlogic/pi-mono).
149
+ Initial release under @linxiraos scope. See previous releases at [badlogic/pi-mono](https://github.com/badlogic/pi-mono).
134
150
 
135
- ## [1.5.13] - 2026-11-21
151
+ ## [1.5.15] - 2026-11-27
136
152
 
137
153
  ### Changed
138
154
 
139
- - Included in Zeta 1.5.13; no package-specific user-visible changes.
155
+ - Aligned with the OMP 19.2 runtime merge and the Zeta 1.5.15 version line.
156
+ - Released as part of Zeta 1.5.2 asset review; no package-specific user-visible changes.
157
+ - `prepareCompaction()` runs as the `compaction.prepare` loop phase, so a `ui.loop-blocked` stall from a cold token walk over a long branch names compaction instead of "unknown" ([#15027](https://github.com/Linxira-OS/linxira-zeta/issues/15027), [#18867](https://github.com/Linxira-OS/linxira-zeta/pull/18867) by [@wolfiesch](https://github.com/wolfiesch))
158
+ - The failed-tool-call correction sent to DeepSeek models now also covers chat-template tool-call tokens written out as text, not only malformed DSML ([#16216](https://github.com/Linxira-OS/linxira-zeta/pull/16216) by [@H4vC](https://github.com/H4vC))
140
159
 
141
- ## [1.5.12] - 2026-11-20
160
+ ### Fixed
161
+
162
+ - Cancelling an `ask` after a background job finishes now reports the user cancellation instead of telling the model to retry a skipped tool ([#15985](https://github.com/Linxira-OS/linxira-zeta/issues/15985))
163
+ - Fixed a Cursor tool call re-sent by the server persisting two results under one id; the re-run's result replaces the first ([#15749](https://github.com/Linxira-OS/linxira-zeta/issues/15749))
164
+ - Fixed compaction keeping more recent history than `keepRecentTokens` when the latest Claude turn on the Anthropic Messages API ended its tool calls on `stop` or `length`: the replay keeps that turn's signed reasoning, but the cut point counted only its visible blocks ([#15791](https://github.com/Linxira-OS/linxira-zeta/pull/15791) by [@will-bogusz](https://github.com/will-bogusz))
165
+
166
+ ## [1.5.13] - 2026-11-21
142
167
 
143
168
  ### Changed
144
169
 
145
- - Included in Zeta 1.5.12; no package-specific user-visible changes.
170
+ - Included in Zeta 1.5.13; no package-specific user-visible changes.
146
171
 
147
- ## [1.5.11] - 2026-11-20
172
+ ## [1.5.12] - 2026-11-20
148
173
 
149
174
  ### Changed
150
175
 
151
- - Released as part of Zeta 1.5.11; no package-specific user-visible changes.
176
+ - Included in Zeta 1.5.12; no package-specific user-visible changes.
152
177
 
153
178
  ## [1.5.10] - 2026-11-19
154
179
 
@@ -156,13 +181,6 @@ Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mon
156
181
 
157
182
  - Corrected context cost estimates for requests that omit reasoning history, so billing estimates now include thinking text only when it is sent or reconstructed for a tool call.
158
183
 
159
- ## [1.5.2] - 2026-11-13
160
-
161
- ### Changed
162
-
163
- - Released as part of Zeta 1.5.2 asset review; no package-specific user-visible changes.
164
- - `prepareCompaction()` runs as the `compaction.prepare` loop phase, so a `ui.loop-blocked` stall from a cold token walk over a long branch names compaction instead of "unknown" ([#15027](https://github.com/can1357/oh-my-pi/issues/15027), [#18867](https://github.com/can1357/oh-my-pi/pull/18867) by [@wolfiesch](https://github.com/wolfiesch))
165
-
166
184
  ## [1.5.0] - 2026-11-09
167
185
 
168
186
  - Released as part of Zeta 1.5.0; no package-specific user-visible changes.
@@ -194,10 +212,6 @@ Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mon
194
212
 
195
213
  ## [1.4.6] - 2026-10-28
196
214
 
197
- ### Breaking Changes
198
-
199
- - Removed the Bun event-loop workaround utilities from `@oh-my-pi/pi-agent-core/utils/yield`; agent loops no longer insert cooperative sleeps while streaming or between tool calls.
200
-
201
215
  ### Added
202
216
 
203
217
  - Added `AgentTool.approvalRestrictionPaths` so tools can report the paths they read, allowing restricted-folder approvals to cover those paths without remembering approval separately for each path.
@@ -233,51 +247,35 @@ Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mon
233
247
 
234
248
  ## [1.3.1] - 2026-10-19
235
249
 
236
- ### Changed
237
-
238
- - The failed-tool-call correction sent to DeepSeek models now also covers chat-template tool-call tokens written out as text, not only malformed DSML ([#16216](https://github.com/can1357/oh-my-pi/pull/16216) by [@H4vC](https://github.com/H4vC))
239
-
240
250
  ### Fixed
241
251
 
242
- - Fixed Ollama chat history estimates counting stripped native thinking and missing foreign thinking replayed as text, which skewed compaction after model switches ([#16164](https://github.com/can1357/oh-my-pi/issues/16164))
252
+ - Fixed Ollama chat history estimates counting stripped native thinking and missing foreign thinking replayed as text, which skewed compaction after model switches ([#16164](https://github.com/Linxira-OS/linxira-zeta/issues/16164))
243
253
 
244
254
  ## [1.3.0] - 2026-10-18
245
255
 
246
256
  ### Fixed
247
257
 
248
- - Fixed Cursor turns failing with `PROVIDER_ERROR` when a follow-up (a finished background job, a late diagnostic, a reminder) arrived while the previous turn was still streaming ([#15821](https://github.com/can1357/oh-my-pi/pull/15821) by [@robfeldmann](https://github.com/robfeldmann))
249
- - Cancelling an `ask` after a background job finishes now reports the user cancellation instead of telling the model to retry a skipped tool ([#15985](https://github.com/can1357/oh-my-pi/issues/15985))
250
- - Fixed a Cursor tool call re-sent by the server persisting two results under one id; the re-run's result replaces the first ([#15749](https://github.com/can1357/oh-my-pi/issues/15749))
251
- - Fixed compaction keeping more recent history than `keepRecentTokens` when the latest Claude turn on the Anthropic Messages API ended its tool calls on `stop` or `length`: the replay keeps that turn's signed reasoning, but the cut point counted only its visible blocks ([#15791](https://github.com/can1357/oh-my-pi/pull/15791) by [@will-bogusz](https://github.com/will-bogusz))
252
- - Fixed Claude context counts reading Opus 5.5 requests about 55% over their billed input: a replayed thinking turn now counts at the output size Claude billed for it, not its signature's bytes ([#15446](https://github.com/can1357/oh-my-pi/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
253
- - Fixed screenshots and other non-frame images being counted at the OpenAI rate for every model instead of the reading model's own; Claude billed them about 16% higher ([#15446](https://github.com/can1357/oh-my-pi/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
254
- - Fixed OpenAI Responses and Codex context estimates leaving out replayed reasoning: each turn whose encrypted reasoning actually replays now counts its reported reasoning tokens (its ciphertext when the backend reports none), and none while a cold session rebuilds it out of the request, so compaction and snapcompact sizing match billing; branch summaries no longer budget for encrypted reasoning they never send ([#15447](https://github.com/can1357/oh-my-pi/pull/15447) by [@will-bogusz](https://github.com/will-bogusz))
255
- - Fixed a Claude compaction or branch summarizer receiving assistant reasoning from a snapcompact archive rendered under another model, which Claude refuses (`reasoning_extraction`) ([#15436](https://github.com/can1357/oh-my-pi/pull/15436) by [@will-bogusz](https://github.com/will-bogusz))
256
- - Fixed native (OpenAI/Codex) remote compaction refusing or truncating sessions that fit the window: its preflight counted the JSON-escaped request, inflating quote-, backslash- and newline-heavy tool output such as disassembly by ~10–20%; it now counts text as the model reads it ([#15712](https://github.com/can1357/oh-my-pi/pull/15712) by [@H4vC](https://github.com/H4vC))
257
- - Fixed OpenAI V1/V2 remote compaction failing outright when the history, kept tail included, exceeds the context window (a large final response or tool output after the last check); it retries on the history before the kept tail ([#15712](https://github.com/can1357/oh-my-pi/pull/15712) by [@H4vC](https://github.com/H4vC))
258
- - Fixed fitted output caps overflowing the context window on strict hosts (llama.cpp-family) after turns with many parallel tool results; chat-template framing is now charged per locally counted message ([#15699](https://github.com/can1357/oh-my-pi/issues/15699))
259
- - Fixed leaked DeepSeek DSML markup reaching saved history from reasoning blocks and from turns that also made a valid tool call ([#15485](https://github.com/can1357/oh-my-pi/issues/15485))
258
+ - Fixed Cursor turns failing with `PROVIDER_ERROR` when a follow-up (a finished background job, a late diagnostic, a reminder) arrived while the previous turn was still streaming ([#15821](https://github.com/Linxira-OS/linxira-zeta/pull/15821) by [@robfeldmann](https://github.com/robfeldmann))
260
259
 
261
260
  ### Added
262
261
 
263
- - `prepareQueuedMessages` receives which queue (`steering` or `followUp`) a batch came from ([#16026](https://github.com/can1357/oh-my-pi/pull/16026))
262
+ - `prepareQueuedMessages` receives which queue (`steering` or `followUp`) a batch came from ([#16026](https://github.com/Linxira-OS/linxira-zeta/pull/16026))
264
263
  - `agent_start` carries `resumedToolCallIds` when a continued run first executes the calls of an unpaired assistant tail
265
- - `Tokenizer.countLatestTurn`: counts a message as the transcript's latest assistant turn, which an Anthropic Messages replay keeps byte-for-byte ([#15791](https://github.com/can1357/oh-my-pi/pull/15791) by [@will-bogusz](https://github.com/will-bogusz))
266
- - `Agent.prioritizeSteering`: moves given pending steering messages ahead of older ones so one-at-a-time delivery takes them first ([#15642](https://github.com/can1357/oh-my-pi/pull/15642))
264
+ - `Tokenizer.countLatestTurn`: counts a message as the transcript's latest assistant turn, which an Anthropic Messages replay keeps byte-for-byte ([#15791](https://github.com/Linxira-OS/linxira-zeta/pull/15791) by [@will-bogusz](https://github.com/will-bogusz))
265
+ - `Agent.prioritizeSteering`: moves given pending steering messages ahead of older ones so one-at-a-time delivery takes them first ([#15642](https://github.com/Linxira-OS/linxira-zeta/pull/15642))
267
266
  - Added `AgentLoopConfig.onDetachedToolUpdate`: a tool's `onUpdate` frames that arrive after its run's event stream ended (a returned call whose background job keeps reporting) reach it instead of being dropped; `Agent` forwards them to its subscribers as `tool_execution_update` events
268
- - `AgentTool.formatApprovalDetails` receives `ApprovalDetailsOptions`; `compact: true` asks for untruncated bodies so a compact approval prompt can count their lines ([#15550](https://github.com/can1357/oh-my-pi/pull/15550) by [@H4vC](https://github.com/H4vC))
269
- - `AgentTool.delegationGuidance`: instructions a same-name extension replacement inherits in its description when it delegates to the native tool ([#15477](https://github.com/can1357/oh-my-pi/pull/15477) by [@iliaal](https://github.com/iliaal))
270
- - `CompactionPreparation.lastSummarizedEntryId` and `CompactionResult.providerReplayThroughEntryId`: a remote compaction that could only fit the history before the kept tail reports the last entry its native history covers; later entries replay normally ([#15712](https://github.com/can1357/oh-my-pi/pull/15712) by [@H4vC](https://github.com/H4vC))
267
+ - `AgentTool.formatApprovalDetails` receives `ApprovalDetailsOptions`; `compact: true` asks for untruncated bodies so a compact approval prompt can count their lines ([#15550](https://github.com/Linxira-OS/linxira-zeta/pull/15550) by [@H4vC](https://github.com/H4vC))
268
+ - `AgentTool.delegationGuidance`: instructions a same-name extension replacement inherits in its description when it delegates to the native tool ([#15477](https://github.com/Linxira-OS/linxira-zeta/pull/15477) by [@iliaal](https://github.com/iliaal))
269
+ - `CompactionPreparation.lastSummarizedEntryId` and `CompactionResult.providerReplayThroughEntryId`: a remote compaction that could only fit the history before the kept tail reports the last entry its native history covers; later entries replay normally ([#15712](https://github.com/Linxira-OS/linxira-zeta/pull/15712) by [@H4vC](https://github.com/H4vC))
271
270
 
272
271
  ### Breaking Changes
273
272
 
274
- - Removed `estimateImageContentTokens()` from `@linxiraos/pi-agent-core/image-tokens`; use `Tokenizer.imageTokens(size, detail)`, which prices with the reading model's catalog image rule ([#15446](https://github.com/can1357/oh-my-pi/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
275
- - `applyShakeRegion()` and `applyShakeRegions()` take the replacement's token count (`replacementTokens`); a block rewrite of an assistant turn adds the tokens it removes to `elidedOutputTokens`, so a replayed Claude turn's count stays lowered after a reload ([#15446](https://github.com/can1357/oh-my-pi/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
276
- - Removed `ApprovalDetailsOptions`; `formatApprovalDetails` takes only `args` again, since the compact approval prompt no longer shows tool details ([#15642](https://github.com/can1357/oh-my-pi/pull/15642) by [@H4vC](https://github.com/H4vC))
273
+ - Removed `estimateImageContentTokens()` from `@linxiraos/pi-agent-core/image-tokens`; use `Tokenizer.imageTokens(size, detail)`, which prices with the reading model's catalog image rule ([#15446](https://github.com/Linxira-OS/linxira-zeta/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
274
+ - `applyShakeRegion()` and `applyShakeRegions()` take the replacement's token count (`replacementTokens`); a block rewrite of an assistant turn adds the tokens it removes to `elidedOutputTokens`, so a replayed Claude turn's count stays lowered after a reload ([#15446](https://github.com/Linxira-OS/linxira-zeta/pull/15446) by [@will-bogusz](https://github.com/will-bogusz))
277
275
 
278
276
  ### Changed
279
277
 
280
- - Before-model-call hooks now receive the loop context as a second argument, and `buildProviderContext` receives the summarizer model ([#15436](https://github.com/can1357/oh-my-pi/pull/15436) by [@will-bogusz](https://github.com/will-bogusz))
278
+ - Before-model-call hooks now receive the loop context as a second argument, and `buildProviderContext` receives the summarizer model ([#15436](https://github.com/Linxira-OS/linxira-zeta/pull/15436) by [@will-bogusz](https://github.com/will-bogusz))
281
279
 
282
280
  ## [1.2.0] - 2026-10-12
283
281
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ const agent = new Agent({
21
21
  },
22
22
  });
23
23
 
24
- agent.subscribe((event) => {
24
+ agent.subscribe(event => {
25
25
  if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
26
26
  // Stream just the new text chunk
27
27
  process.stdout.write(event.assistantMessageEvent.delta);
@@ -219,7 +219,7 @@ await agent.waitForIdle(); // Wait for completion
219
219
  ### Events
220
220
 
221
221
  ```typescript
222
- const unsubscribe = agent.subscribe((event) => {
222
+ const unsubscribe = agent.subscribe(event => {
223
223
  console.log(event.type);
224
224
  });
225
225
  unsubscribe();
@@ -274,8 +274,8 @@ Handle custom types in `convertToLlm`:
274
274
 
275
275
  ```typescript
276
276
  const agent = new Agent({
277
- convertToLlm: (messages) =>
278
- messages.flatMap((m) => {
277
+ convertToLlm: messages =>
278
+ messages.flatMap(m => {
279
279
  if (m.role === "notification") return []; // Filter out
280
280
  return [m];
281
281
  }),
@@ -360,7 +360,7 @@ const context: AgentContext = {
360
360
 
361
361
  const config: AgentLoopConfig = {
362
362
  model: getModel("openai", "gpt-4o"),
363
- convertToLlm: (msgs) => msgs.filter((m) => ["user", "assistant", "toolResult"].includes(m.role)),
363
+ convertToLlm: msgs => msgs.filter(m => ["user", "assistant", "toolResult"].includes(m.role)),
364
364
  };
365
365
 
366
366
  const userMessage = { role: "user", content: "Hello", timestamp: Date.now() };
@@ -376,6 +376,7 @@ for await (const event of agentLoopContinue(context, config)) {
376
376
  ```
377
377
 
378
378
  ## Run-level telemetry
379
+
379
380
  Every `invoke_agent` produces two values alongside the OTEL spans:
380
381
 
381
382
  - **`AgentRunSummary`** — chat / tool / usage / cost / error counters bucketed
@@ -447,10 +448,7 @@ Callers that drive the loop multiple times (verify pass, benchmark harness)
447
448
  fold N summaries with `aggregateAgentRunSummaries` / `aggregateAgentRunCoverage`:
448
449
 
449
450
  ```typescript
450
- import {
451
- aggregateAgentRunSummaries,
452
- aggregateAgentRunCoverage,
453
- } from "@linxiraos/pi-agent-core";
451
+ import { aggregateAgentRunSummaries, aggregateAgentRunCoverage } from "@linxiraos/pi-agent-core";
454
452
 
455
453
  const summaries: AgentRunSummary[] = [];
456
454
  const coverages: AgentRunCoverage[] = [];
@@ -19,7 +19,7 @@ Forked application trees:
19
19
 
20
20
  | Path | Upstream | Snapshot | License | What Zeta changed |
21
21
  |---|---|---|---|---|
22
- | `packages/ main/ crates/ python/ lsp/ sdk/ types/ skills/` | oh-my-pi (OMP), https://github.com/can1357/oh-my-pi | integrated through tag `v18.22.0` (`document/upstream-sync.md`) | see upstream files | product name, paths, command names and env prefixes; branded assets; internal identifiers renamed to `__zeta*` |
22
+ | `packages/ main/ crates/ python/ lsp/ sdk/ types/ skills/` | oh-my-pi (OMP), https://github.com/Linxira-OS/linxira-zeta | integrated through tag `v18.22.0` (`document/upstream-sync.md`) | see upstream files | product name, paths, command names and env prefixes; branded assets; internal identifiers renamed to `__zeta*` |
23
23
  | `web-ui/` | OMP Web, https://github.com/17380936778/omp-web | frozen snapshot, **abandoned 2026-11-05** (`document/upstream-sync.md`) | see upstream files | third-party UI, not maintained by Zeta: frozen as received, no builds, no fixes; the product renderer is `web-app/` (`Differences from Upstream` in README) |
24
24
  | `web-app/` (`src/studio`, `src/vendor/*`) | OMP Studio, https://github.com/the-snowpear/omp-studio | official `v0.2.1` (`6d0b764bb9eac88c1671c0380229823c5630cc74`) integrated 2026-11-16; `web-ui/` is a separate frozen OMP Web snapshot | MIT | maintained by Zeta now: the host contract is reimplemented in `studio-host` (pair/CSRF/query/command/events), the renderer was rebranded (`zeta-studio` wire name, Zeta links/fixtures), and Zeta adds windowed transcripts, precompressed static serving, the plugin registry, and the usage dashboard |
25
25
  | `termide/` | TermIDE, https://github.com/termide/termide | tag `0.49.0` = `057eb55e0a7c4ee969982fab62dc83bde028e052` | MIT | deviations listed in `termide/VENDOR.md` |
@@ -14,6 +14,14 @@ import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, AgentTool
14
14
  export declare function resolveToolConcurrency(tool: AgentTool<any, any, any> | undefined, args: Record<string, unknown>): "shared" | "exclusive";
15
15
  /** Stop-details marker for a provider error after assistant content/tool args already streamed. */
16
16
  export declare const STREAM_INTERRUPTED_AFTER_CONTENT_STOP_DETAIL = "stream_interrupted_after_content";
17
+ /**
18
+ * The loop ended the turn itself, not a provider: the model kept missing a soft
19
+ * tool requirement. `Agent` marks the turn's error message `errorFromAgentLoop`
20
+ * so recovery does not report it as a failed request.
21
+ */
22
+ export declare class AgentLoopError extends Error {
23
+ constructor(message: string);
24
+ }
17
25
  /**
18
26
  * Cadence (ms) for polling queued steering while an `interruptible` tool is in
19
27
  * flight, so a steer cuts the wait short instead of sitting idle until the
@@ -50,6 +58,15 @@ export declare function resolveOwnedDialectFromEnv(value: string | undefined): D
50
58
  * The prompt is added to the context and events are emitted for it.
51
59
  */
52
60
  export declare function agentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, signal?: AbortSignal, streamFn?: StreamFn): EventStream<AgentEvent, AgentMessage[]>;
61
+ /**
62
+ * Whether `message` is kept out of model context: drawn and saved, never sent (a `!!` bash run, a
63
+ * custom row sent with `excludeFromContext`).
64
+ */
65
+ export declare function isExcludedFromContext(message: AgentMessage): boolean;
66
+ /** Index of the last message the model sees, or -1; rows kept out of context after it do not change the request tail. */
67
+ export declare function lastContextIndex(messages: readonly AgentMessage[]): number;
68
+ /** The last message the model sees (see {@link lastContextIndex}). */
69
+ export declare function lastContextMessage(messages: readonly AgentMessage[]): AgentMessage | undefined;
53
70
  /**
54
71
  * Trailing assistant message whose runnable tool calls have no results yet.
55
72
  *
@@ -114,6 +131,11 @@ export interface NormalizeToolsOptions {
114
131
  pruneDescriptions?: boolean;
115
132
  }
116
133
  export declare function normalizeTools(tools: AgentContext["tools"], options: NormalizeToolsOptions): Context["tools"];
134
+ /** Split a traced call's intent (`i`, trimmed, trailing periods dropped) from the arguments its tool reads. */
135
+ export declare function extractIntent(args: Record<string, unknown>): {
136
+ intent?: string;
137
+ strippedArgs: Record<string, unknown>;
138
+ };
117
139
  /**
118
140
  * Classify the first `count` steering messages for a tool-batch interrupt:
119
141
  * any user-authored message wins, then agent-attributed user messages, else
@@ -14,7 +14,7 @@ export interface AgentOptions {
14
14
  * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.
15
15
  * Default filters to user/assistant/toolResult and converts attachments.
16
16
  */
17
- convertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;
17
+ convertToLlm?: AgentLoopConfig["convertToLlm"];
18
18
  /**
19
19
  * Optional transform applied to context before convertToLlm.
20
20
  * Use for context pruning, injecting external context, etc.
@@ -24,7 +24,7 @@ export interface AgentOptions {
24
24
  * Optional transform applied after provider context assembly and before
25
25
  * telemetry capture/provider send.
26
26
  */
27
- transformProviderContext?: (context: Context, model: Model) => Context | Promise<Context>;
27
+ transformProviderContext?: (context: Context, model: Model, signal?: AbortSignal) => Context | Promise<Context>;
28
28
  /**
29
29
  * Steering mode: "all" = send all steering messages at once, "one-at-a-time" = one per turn
30
30
  */
@@ -145,14 +145,14 @@ export interface AgentOptions {
145
145
  speculativeToolExecution?: SpeculativeToolExecutionConfig;
146
146
  /**
147
147
  * Resolve a tool call whose name matched no advertised tool. Lets hosts
148
- * route calls to tools exposed through side transports (e.g. `xd://`
149
- * device mounts) instead of failing with "Tool not found".
148
+ * route calls to tools reached through a side transport (e.g. mounted
149
+ * tool commands run through `bash`) instead of failing with "Tool not found".
150
150
  */
151
151
  resolveFallbackTool?: (name: string, advertised: readonly AgentTool<any>[]) => AgentTool<any> | undefined;
152
152
  /**
153
153
  * Names routable by {@link resolveFallbackTool} that the advertised set
154
- * omits (e.g. `xd://` device mounts), used only to suggest a target when a
155
- * call misses.
154
+ * omits (e.g. mounted tool commands run through `bash`), used only to
155
+ * suggest a target when a call misses.
156
156
  */
157
157
  suggestFallbackToolNames?: () => Iterable<string>;
158
158
  /** Enable intent tracing schema injection/stripping in the harness. */
@@ -184,9 +184,10 @@ export interface AgentOptions {
184
184
  /** Reject a deferred hard choice when its named tool is no longer active. */
185
185
  onToolChoiceUnavailable?: () => void;
186
186
  /**
187
- * Cursor exec handlers for local tool execution.
187
+ * Cursor exec handlers for local tool execution, or a factory resolved on the first
188
+ * request dispatched to Cursor (including a mid-session model switch).
188
189
  */
189
- cursorExecHandlers?: CursorExecHandlers;
190
+ cursorExecHandlers?: CursorExecHandlers | (() => Promise<CursorExecHandlers>);
190
191
  /** Additional tools Cursor executes through its MCP request-context bridge, resolved before each provider call. */
191
192
  getCursorTools?: () => AgentTool[];
192
193
  /**
@@ -451,7 +452,7 @@ export declare class Agent {
451
452
  * (e.g. handoff generation, which uses the base prompt rather than a per-turn
452
453
  * `before_agent_start` hook override) pass it explicitly.
453
454
  */
454
- buildSideRequestContext(llmMessages: Message[], systemPrompt?: string[]): Promise<Context>;
455
+ buildSideRequestContext(llmMessages: Message[], systemPrompt?: string[], signal?: AbortSignal): Promise<Context>;
455
456
  subscribe(fn: (e: AgentEvent) => void): () => void;
456
457
  /** Register a listener notified after any steering/follow-up queue mutator
457
458
  * (enqueue, dequeue-on-delivery, clear, restore, live-steering adoption,
@@ -525,6 +526,8 @@ export declare class Agent {
525
526
  setInterruptMode(mode: "immediate" | "wait"): void;
526
527
  getInterruptMode(): "immediate" | "wait";
527
528
  setTools(t: AgentTool<any>[]): void;
529
+ /** Set the inactive tools that may become active later ({@link AgentContext.standbyTools}). */
530
+ setStandbyTools(tools: AgentTool[]): void;
528
531
  replaceMessages(ms: AgentMessage[]): void;
529
532
  replaceQueues(steering: AgentMessage[], followUp: AgentMessage[]): void;
530
533
  /**
@@ -606,7 +609,15 @@ export declare class Agent {
606
609
  */
607
610
  popLastFollowUp(): AgentMessage | undefined;
608
611
  clearMessages(): void;
609
- abort(reason?: unknown): void;
612
+ /**
613
+ * Abort the current run. `detachTools` first raises the running tool batch's
614
+ * cooperative `steeringSignal` (see {@link AgentLoopConfig.detachSignal}), so
615
+ * tools that can move their work into a background job do so instead of being
616
+ * killed; they observe it before the abort.
617
+ */
618
+ abort(reason?: unknown, options?: {
619
+ detachTools?: boolean;
620
+ }): void;
610
621
  waitForIdle(): Promise<void>;
611
622
  reset(): void;
612
623
  /** Send a prompt with an AgentMessage */
@@ -38,10 +38,10 @@ export interface AnthropicCompactionPreserveData {
38
38
  * provider routes requests, so a Foundry or `ANTHROPIC_BASE_URL` reroute of a
39
39
  * first-party model is excluded unless the route opted in with
40
40
  * `remoteCompaction.enabled`. Bedrock Converse models compact through a
41
- * Bedrock Runtime side request; their ordinary turns stay on Converse.
41
+ * Bedrock Runtime side request; their ordinary turns stay on Converse. A
42
+ * custom api qualifies through {@link declaresAnthropicCompaction}.
42
43
  */
43
- export declare function shouldUseAnthropicNativeCompaction(model: Model): model is Model<"anthropic-messages" | "bedrock-converse-stream">;
44
- type AnthropicNativeCompactionModel = Model<"anthropic-messages" | "bedrock-converse-stream">;
44
+ export declare function shouldUseAnthropicNativeCompaction(model: Model): boolean;
45
45
  export declare function getPreservedAnthropicCompactionData(preserveData: Record<string, unknown> | undefined): AnthropicCompactionPreserveData | undefined;
46
46
  /** Set or strip the Anthropic compaction slot; a new compaction never inherits a stale summary. */
47
47
  export declare function withAnthropicCompactionPreserveData(preserveData: Record<string, unknown> | undefined, compaction: AnthropicCompactionPreserveData | undefined): Record<string, unknown> | undefined;
@@ -75,7 +75,7 @@ export interface AnthropicNativeCompactionResponse {
75
75
  usage: Usage;
76
76
  model: string;
77
77
  }
78
- export interface AnthropicNativeCompactionOptions extends Pick<SimpleStreamOptions, "initiatorOverride" | "metadata" | "fetch" | "sessionId" | "promptCacheKey" | "providerSessionState" | "maxInFlightRequests">, Pick<InstrumentedChatSpanOptions, "completeImpl" | "telemetry" | "retry"> {
78
+ export interface AnthropicNativeCompactionOptions extends Pick<SimpleStreamOptions, "initiatorOverride" | "metadata" | "fetch" | "sessionId" | "promptCacheKey" | "providerSessionState" | "maxInFlightRequests" | "omitDemotedReasoning">, Pick<InstrumentedChatSpanOptions, "completeImpl" | "telemetry" | "retry"> {
79
79
  }
80
80
  /**
81
81
  * Run one compaction request and return the summary and signature the API wrote. `completeSimple`
@@ -86,5 +86,4 @@ export interface AnthropicNativeCompactionOptions extends Pick<SimpleStreamOptio
86
86
  * without a summary is a native failure, including tool use, refusals and
87
87
  * output limits; the configured method order can then choose a fallback.
88
88
  */
89
- export declare function requestAnthropicNativeCompaction(model: AnthropicNativeCompactionModel, apiKey: ApiKey, request: AnthropicNativeCompactionRequest, signal: AbortSignal | undefined, options: AnthropicNativeCompactionOptions): Promise<AnthropicNativeCompactionResponse>;
90
- export {};
89
+ export declare function requestAnthropicNativeCompaction(model: Model, apiKey: ApiKey, request: AnthropicNativeCompactionRequest, signal: AbortSignal | undefined, options: AnthropicNativeCompactionOptions): Promise<AnthropicNativeCompactionResponse>;
@@ -7,8 +7,9 @@ export interface BedrockCompactionRequest {
7
7
  /**
8
8
  * Shape a native compaction request for Amazon Bedrock's OpenAI routes
9
9
  * (`isBedrockOpenAIUrl`) the way stream dispatch shapes a normal Bedrock turn:
10
- * configured headers, transport fetch (proxy, CA, User-Agent, request
11
- * recording), then the provider's model and request hooks. The bundled
10
+ * transport fetch (proxy, CA, User-Agent, request recording), then the
11
+ * provider's model and request hooks, on a model whose configured headers
12
+ * the caller already resolved (`withResolvedHeaders`). The bundled
12
13
  * `bedrock-mantle` provider's hook fills in `{region}` and picks bearer or
13
14
  * SigV4 auth; without it compaction targets an unresolved host.
14
15
  *
@@ -15,12 +15,14 @@ export declare const V2_RETAINED_MESSAGE_TOKEN_BUDGET = 64000;
15
15
  export declare const V2_COMPACTION_MAX_RETRIES = 2;
16
16
  /** Timeout for V2 streaming compaction (5 minutes, same as V1). */
17
17
  export declare const V2_COMPACTION_TIMEOUT_MS = 300000;
18
- /** Token usage reported by the streamed V2 Responses completion. */
19
- export interface CompactionV2Usage {
18
+ /** Token usage a Responses compaction request reported: the V1 `/responses/compact` body, or the V2 stream's completed response. */
19
+ export interface ResponsesCompactionUsage {
20
20
  inputTokens: number;
21
21
  outputTokens: number;
22
22
  totalTokens: number;
23
23
  cachedInputTokens?: number;
24
+ /** Input tokens the request wrote to the prompt cache; part of `inputTokens`. */
25
+ cacheWriteTokens?: number;
24
26
  reasoningOutputTokens?: number;
25
27
  }
26
28
  /** Provider-ready Responses body and local state needed for V2 compaction. */
@@ -38,7 +40,7 @@ export interface CompactionV2Response {
38
40
  compactionItem: Record<string, unknown>;
39
41
  replacementHistory: Array<Record<string, unknown>>;
40
42
  usedTokens: number;
41
- usage?: CompactionV2Usage;
43
+ usage?: ResponsesCompactionUsage;
42
44
  retainedImageCount: number;
43
45
  }
44
46
  /** Resolve the streaming Responses endpoint for a V2-capable model. */
@@ -87,6 +89,8 @@ export declare function requestCompactionV2Streaming(model: Model, apiKey: strin
87
89
  preferWebsockets?: boolean;
88
90
  codexAccessPrograms?: boolean;
89
91
  }): Promise<CompactionV2Response>;
92
+ /** A Responses `usage` object; undefined when it is missing or lacks the token totals. */
93
+ export declare function parseResponsesCompactionUsage(usage: unknown): ResponsesCompactionUsage | undefined;
90
94
  /** Build Codex-style V2 replacement history from retention candidates plus compaction output. */
91
95
  export declare function buildCompactionV2ReplacementHistory(input: unknown[], compactionItem: Record<string, unknown>, retainedMessageBudget?: number): {
92
96
  replacementHistory: Array<Record<string, unknown>>;
@@ -230,7 +230,7 @@ export interface SummaryOptions {
230
230
  /**
231
231
  * Optional telemetry handle. When provided, every LLM call emitted during
232
232
  * compaction is wrapped in an OTEL chat span tagged with
233
- * `zeta.gen_ai.oneshot.kind` (`compaction_summary`, `compaction_short_summary`,
233
+ * `omp.gen_ai.oneshot.kind` (`compaction_summary`, `compaction_short_summary`,
234
234
  * or `compaction_turn_prefix`). `undefined` keeps the call paths zero-cost.
235
235
  */
236
236
  telemetry?: AgentTelemetry;
@@ -264,6 +264,11 @@ export interface SummaryOptions {
264
264
  codexCompaction?: CodexCompactionContext;
265
265
  /** Provider-visible tools for remote compaction transports that replay native tool history. */
266
266
  tools?: Tool[];
267
+ /**
268
+ * Leave other models' reasoning out of the native compaction request, as the
269
+ * live turns stopped replaying it after a `reasoning_extraction` refusal.
270
+ */
271
+ omitDemotedReasoning?: boolean;
267
272
  /** Optional fetch implementation threaded into remote compaction calls. */
268
273
  fetch?: FetchImpl;
269
274
  /** Inspect or replace a generic remote-compaction payload before it is sent. */
@@ -277,6 +282,13 @@ export interface SummaryOptions {
277
282
  * the live agent turn also bracket compaction HTTP requests.
278
283
  */
279
284
  completeImpl?: <TApi extends Api>(model: Model<TApi>, ctx: Context, options: SimpleStreamOptions) => Promise<AssistantMessage>;
285
+ /**
286
+ * Receives each OpenAI remote compaction request (V1 `/responses/compact`,
287
+ * V2 streaming) whose response reported usage. Those transports bypass
288
+ * {@link completeImpl}, so this is the only record of their spend: a
289
+ * content-less assistant message carrying the priced usage and duration.
290
+ */
291
+ onRemoteUsage?: (message: AssistantMessage) => void;
280
292
  /**
281
293
  * Transient-failure retry for the summarization oneshots (`generateSummary`,
282
294
  * `generateShortSummary`, `generateTurnPrefixSummary`).
@@ -304,7 +316,7 @@ export interface HandoffOptions {
304
316
  metadata?: Record<string, unknown>;
305
317
  /**
306
318
  * Optional telemetry handle. When provided, the handoff LLM call is
307
- * wrapped in an OTEL chat span tagged with `zeta.gen_ai.oneshot.kind = "handoff"`.
319
+ * wrapped in an OTEL chat span tagged with `omp.gen_ai.oneshot.kind = "handoff"`.
308
320
  */
309
321
  telemetry?: AgentTelemetry;
310
322
  /**
@@ -63,6 +63,8 @@ export interface CustomMessageEntry<T = unknown> extends SessionEntryBase {
63
63
  display: boolean;
64
64
  /** Who initiated this message for billing/attribution semantics. */
65
65
  attribution?: MessageAttribution;
66
+ /** Rendered and saved, never sent to the model (like `!!` bash rows). */
67
+ excludeFromContext?: boolean;
66
68
  }
67
69
  export interface CustomEntry<T = unknown> extends SessionEntryBase {
68
70
  type: "custom";
@@ -9,6 +9,8 @@ export interface CustomMessage<T = unknown> {
9
9
  details?: T;
10
10
  /** Who initiated this message for billing/attribution semantics. */
11
11
  attribution?: MessageAttribution;
12
+ /** Rendered and saved, never sent to the model (like `!!` bash rows). */
13
+ excludeFromContext?: boolean;
12
14
  timestamp: number;
13
15
  }
14
16
  /** Legacy hook message type (pre-extensions). Kept for session migration. */
@@ -91,7 +93,7 @@ export interface CompactionSummaryMessageOptions {
91
93
  historyRewriteAt?: number;
92
94
  }
93
95
  export declare function createCompactionSummaryMessage(summary: string, tokensBefore: number, timestamp: string, options?: CompactionSummaryMessageOptions): CompactionSummaryMessage;
94
- export declare function createCustomMessage(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details: unknown | undefined, timestamp: string, attribution?: MessageAttribution): CustomMessage;
96
+ export declare function createCustomMessage(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details: unknown | undefined, timestamp: string, attribution?: MessageAttribution, excludeFromContext?: boolean): CustomMessage;
95
97
  /**
96
98
  * Transform a single core-domain agent message to its LLM form; `undefined`
97
99
  * drops it from the provider request.
@@ -113,6 +115,7 @@ export declare function convertMessageToLlm(message: AgentMessage): Message | un
113
115
  export declare function defaultConvertToLlm(messages: AgentMessage[]): Message[];
114
116
  /**
115
117
  * The context message a session entry contributes, or `undefined` for entries
116
- * that don't reach the LLM (compaction markers, labels, model changes, ...).
118
+ * that don't reach the LLM (compaction markers, labels, model changes, rows
119
+ * kept out of context, ...).
117
120
  */
118
121
  export declare function getMessageFromEntry(entry: SessionEntry): AgentMessage | undefined;
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import type { CodexCompactionContext, FetchImpl, Message, Model, ProviderSessionState, SimpleStreamOptions } from "@linxiraos/pi-ai/types";
18
18
  import { Tokenizer } from "../tokenizer.js";
19
+ import { type ResponsesCompactionUsage } from "./compaction-v2-streaming.js";
19
20
  export * from "./compaction-v2-streaming.js";
20
21
  export declare const OPENAI_REMOTE_COMPACTION_PRESERVE_KEY = "openaiRemoteCompaction";
21
22
  /**
@@ -100,7 +101,9 @@ export interface OpenAiRemoteCompactionRequest {
100
101
  };
101
102
  include?: string[];
102
103
  }
104
+ /** A `/responses/compact` result: the history to preserve, plus the usage the body reported. */
103
105
  export interface OpenAiRemoteCompactionResponse extends OpenAiRemoteCompactionPreserveData {
106
+ usage?: ResponsesCompactionUsage;
104
107
  }
105
108
  export interface RemoteCompactionRequest {
106
109
  systemPrompt: string;
@@ -17,6 +17,6 @@ export declare function getToolResultMessage(entry: SessionEntry): ToolResultMes
17
17
  */
18
18
  export declare function getReadToolPath({ toolResult, toolCall }: ProtectedToolContext): string | undefined;
19
19
  export declare function isSkillReadToolResult(context: ProtectedToolContext): boolean;
20
- /** Recovery reads of session artifacts — eliding one only mints another artifact and can repeat indefinitely. */
20
+ /** Recovery reads of session spills — eliding one only mints another spill and can repeat indefinitely. */
21
21
  export declare function isArtifactRecoveryToolResult(context: ProtectedToolContext): boolean;
22
22
  export declare function isProtectedToolResult(toolResult: ToolResultMessage, toolCall: AgentToolCall | undefined, matchers: readonly ProtectedToolMatcher[]): boolean;
@@ -62,3 +62,16 @@ export declare const OUTPUT_FIT_HEADWAY_TOKENS = 64;
62
62
  * and the request can still exceed the window as before.
63
63
  */
64
64
  export declare function fitOutputTokensToContextWindow(model: Model, context: Context, maxTokens: number | undefined, tokenizer: Tokenizer): number | undefined;
65
+ /**
66
+ * Local prompt count of `context` when it leaves `model` no room for the
67
+ * smallest output the transport requests, else `undefined` (also when the
68
+ * window is unknown). Counting stops at the first message past the window, so
69
+ * the count is a floor.
70
+ *
71
+ * Unlike {@link fitOutputTokensToContextWindow}, no usage anchor is trusted:
72
+ * history re-expanded behind a native compaction the model cannot replay
73
+ * carries reports describing the compacted prefix. Nor is a tokenizer margin
74
+ * added: a caller refuses on this verdict, so only a clear overrun counts, and
75
+ * a near-full request is still left to the provider.
76
+ */
77
+ export declare function countContextOverrun(context: Context, model: Model, tokenizer: Tokenizer): number | undefined;
@@ -1,5 +1,19 @@
1
1
  import type { AssistantMessage, Message } from "@linxiraos/pi-ai";
2
+ /**
3
+ * Model-facing text of a tool call the provider stream ended before it could run.
4
+ * The provider's error (`details.upstreamError`) stays in the session for the UI.
5
+ */
6
+ export declare const PROVIDER_ERROR_NOT_EXECUTED_TEXT = "Tool call was not executed because the provider stream ended with an error before the tool could run.";
2
7
  /** Detects API-level provider refusals that are terminal errors, not dialogue to replay. */
3
8
  export declare function isProviderRefusalMessage(message: AssistantMessage): boolean;
4
- /** Removes API-level provider refusals from live provider replay while preserving other messages. */
9
+ /**
10
+ * The provider replay form of one converted message, or `undefined` when it is
11
+ * not replayed. API-level refusals are dropped. A provider-error placeholder
12
+ * keeps its "not executed" fact but loses the provider's error text: replaying a
13
+ * refusal explanation ("…reverse engineering or duplicating model outputs…")
14
+ * feeds the classifier its own verdict and makes every later turn of the
15
+ * session likelier to be refused.
16
+ */
17
+ export declare function toProviderReplayMessage(message: Message): Message | undefined;
18
+ /** Applies {@link toProviderReplayMessage} to live provider replay. */
5
19
  export declare function filterProviderReplayMessages(messages: readonly Message[]): Message[];
@@ -16,8 +16,11 @@ export declare class SentToolDefinitions {
16
16
  /**
17
17
  * `context` with {@link Context.inactiveTools} set to the definitions for names the latest
18
18
  * `requestControls.tools.declared` in its messages holds that are not in its `tools`; cleared when
19
- * there are none or the request declares no tools. Names never sent by this Agent are skipped: the
20
- * provider drops them from the declaration.
19
+ * there are none or the request declares no tools. A declared name this Agent never sent takes its
20
+ * `standby` definition (a resumed transcript declares standby tools a fresh process has not sent);
21
+ * names with neither are skipped, and the provider drops them from the declaration. Before any
22
+ * request declared tools, `standby` (minus active names) stands in, so the first declaration
23
+ * already holds tools that may activate later.
21
24
  */
22
- withInactiveTools(context: Context): Context;
25
+ withInactiveTools(context: Context, standby?: readonly Tool[]): Context;
23
26
  }