@sayknow-cli/agent-core 0.2.2

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 (55) hide show
  1. package/CHANGELOG.md +588 -0
  2. package/README.md +473 -0
  3. package/dist/types/agent-loop.d.ts +56 -0
  4. package/dist/types/agent.d.ts +381 -0
  5. package/dist/types/append-only-context.d.ts +124 -0
  6. package/dist/types/compaction/branch-summarization.d.ts +103 -0
  7. package/dist/types/compaction/compaction.d.ts +253 -0
  8. package/dist/types/compaction/entries.d.ts +109 -0
  9. package/dist/types/compaction/errors.d.ts +26 -0
  10. package/dist/types/compaction/index.d.ts +11 -0
  11. package/dist/types/compaction/messages.d.ts +61 -0
  12. package/dist/types/compaction/openai.d.ts +62 -0
  13. package/dist/types/compaction/pruning.d.ts +37 -0
  14. package/dist/types/compaction/utils.d.ts +32 -0
  15. package/dist/types/compaction.d.ts +1 -0
  16. package/dist/types/harmony-leak.d.ts +99 -0
  17. package/dist/types/index.d.ts +10 -0
  18. package/dist/types/proxy.d.ts +84 -0
  19. package/dist/types/run-collector.d.ts +196 -0
  20. package/dist/types/telemetry.d.ts +596 -0
  21. package/dist/types/thinking.d.ts +18 -0
  22. package/dist/types/types.d.ts +430 -0
  23. package/package.json +75 -0
  24. package/src/agent-loop.ts +1302 -0
  25. package/src/agent.ts +1531 -0
  26. package/src/append-only-context.ts +460 -0
  27. package/src/compaction/branch-summarization.ts +358 -0
  28. package/src/compaction/compaction.ts +1342 -0
  29. package/src/compaction/entries.ts +139 -0
  30. package/src/compaction/errors.ts +31 -0
  31. package/src/compaction/index.ts +12 -0
  32. package/src/compaction/messages.ts +212 -0
  33. package/src/compaction/openai.ts +570 -0
  34. package/src/compaction/prompts/auto-handoff-threshold-focus.md +1 -0
  35. package/src/compaction/prompts/branch-summary-context.md +5 -0
  36. package/src/compaction/prompts/branch-summary-preamble.md +2 -0
  37. package/src/compaction/prompts/branch-summary.md +30 -0
  38. package/src/compaction/prompts/compaction-short-summary.md +9 -0
  39. package/src/compaction/prompts/compaction-summary-context.md +5 -0
  40. package/src/compaction/prompts/compaction-summary.md +38 -0
  41. package/src/compaction/prompts/compaction-turn-prefix.md +17 -0
  42. package/src/compaction/prompts/compaction-update-summary.md +45 -0
  43. package/src/compaction/prompts/file-operations.md +10 -0
  44. package/src/compaction/prompts/handoff-document.md +49 -0
  45. package/src/compaction/prompts/summarization-system.md +3 -0
  46. package/src/compaction/pruning.ts +431 -0
  47. package/src/compaction/utils.ts +185 -0
  48. package/src/compaction.ts +1 -0
  49. package/src/harmony-leak.ts +428 -0
  50. package/src/index.ts +19 -0
  51. package/src/proxy.ts +326 -0
  52. package/src/run-collector.ts +631 -0
  53. package/src/telemetry.ts +2049 -0
  54. package/src/thinking.ts +20 -0
  55. package/src/types.ts +490 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,588 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.5.4] - 2026-06-17
6
+
7
+ ### Fixed
8
+
9
+ - Maintenance one-shot LLM calls now preserve active provider session state and the configured WebSocket transport preference. `SummaryOptions`, `HandoffOptions`, and `GenerateBranchSummaryOptions` accept `sessionId`, `providerSessionState`, and `preferWebsockets`, and `generateSummary`, `generateShortSummary`, `generateTurnPrefixSummary`, `generateHandoff`, `generateBranchSummary`, and `compact()` forward them through to `completeSimple` — previously these fields were dropped, so Codex/OpenAI-compatible compaction summaries, handoff generation, and branch summaries fell back to HTTP/SSE and lost `session_id` affinity even with `providers.openaiWebsockets: "on"`. Split-turn compaction now runs its history and turn-prefix summaries sequentially when they share a single provider WebSocket session, avoiding `websocket request already in progress`; non-WebSocket sessions still run them in parallel. `Agent` exposes a `preferWebsockets` getter so callers can forward the live transport preference (#736).
10
+
11
+ ## [0.5.3] - 2026-06-16
12
+
13
+ ### Fixed
14
+
15
+ - Bounded agent context growth, compaction, and token accounting for long-running sessions: `appendMessage` pushes in place instead of rebuilding the array; the append-only context keeps rolling per-message hashes instead of rescanning the full digest; an emergency-compaction floor that cannot be disabled now surfaces its reason; `getSessionStats` is single-pass; and `nativeCountTokens` skips the synchronous ~39 MB BPE tokenizer above a 2 MiB input cap, falling back to the cheap heuristic (#717).
16
+
17
+ ## [0.5.2] - 2026-06-15
18
+
19
+ ### Fixed
20
+
21
+ - Fixed compaction token estimation in Bun standalone binaries by loading the native tokenizer through the sibling native entrypoint instead of package-name dynamic resolution.
22
+
23
+ ## [0.5.1] - 2026-06-14
24
+
25
+ - Version aligned with the 0.5.1 monorepo release; no functional changes in this package.
26
+
27
+ ## [0.5.0] - 2026-06-13
28
+
29
+ ### Fixed
30
+
31
+ - Fixed compaction cut-point selection when the newest retained context ends in an uncuttable tool result, so automatic compaction can keep the latest assistant/tool-result pair instead of falling back to a no-op cut.
32
+
33
+ ### Changed
34
+
35
+ - Optimization Suite v3 Lane 2 (context cost): compaction token estimates now use a shared per-entry cache (`estimateEntryTokens`) keyed by a boundary-lossless fingerprint of the exact estimator fragments, covering `estimateEntriesTokens`, the `findCutPoint` reverse walk, and pruning candidate scoring — repeated full-session estimate p95 −97%, token totals exactly equal to fresh estimates and never stale after prune mutation. Pruned bash/search/grep tool results now carry a one-line digest notice (exit code, match/file count, first error line; capped at 1.25× the generic notice cost) instead of a bare truncation notice, with savings computed from the exact notice string; reads and other tools keep the generic notice. `trimOpenAiCompactInput` is O(n) via per-item serialized lengths and a running character sum (5k-item trim −99.9%) and is now exported.
36
+ - Optimization Suite v3 Lane 3 (serialization): `cloneJson` in the append-only context now uses a typed JSON-semantic recursive clone instead of a `JSON.parse(JSON.stringify())` round-trip (−36% median on clone-heavy paths), with exact JSON.stringify byte parity including the toJSON holder-key protocol (single get, no re-dispatch on replacement values), function/symbol dropping, sparse arrays, Dates, and prototype-bearing objects; the helper is now exported.
37
+
38
+ ## [0.4.5] - 2026-06-12
39
+
40
+ ### Changed
41
+
42
+ - Made tool-output pruning staleness-aware: results superseded by a later same-target result (re-read file, re-run search) or invalidated by a later successful edit/write are pruned before merely-old ones, including inside the recency protect window. New optional `PruneConfig.staleOverridableTools` (default `["read"]`) waives protected-tool immunity for superseded results while the most recent result per target stays protected. Target identity uses collision-proof canonical JSON tuple keys.
43
+ - `PruneResult` now returns `prunedEntries` so callers whose entry source materializes copies (e.g. blob-externalized session entries) can write mutations back into their canonical store.
44
+
45
+ ### Fixed
46
+
47
+ - Preserved Cursor-native tool call rendering and execution through the agent tool-call path, including runtime tool details.
48
+
49
+ ## [0.4.4] - 2026-06-10
50
+
51
+ - Version aligned with the 0.4.4 monorepo release; no functional changes in this package.
52
+
53
+ ## [0.4.3] - 2026-06-10
54
+
55
+ ### Fixed
56
+
57
+ - Separated a model's total context window from its safe input/prompt-packing budget in the compaction threshold. `effectiveReserveTokens`, `resolveThresholdTokens`, and `shouldCompact` now accept an optional `maxOutputTokens` and reserve at least that completion budget, so a large-output model (e.g. 400K context / 128K max output) caps input near 272K instead of 340K and cannot overflow the total window with reserved output ([#442](https://github.com/jaybeyond/sayknow-cli/issues/442)).
58
+
59
+ ## [0.4.0] - 2026-06-06
60
+
61
+ ### Changed
62
+
63
+ - Refreshed agent-core package metadata for the SKC 0.4.0 release.
64
+
65
+ ## [0.3.1] - 2026-06-05
66
+
67
+ ### Fixed
68
+
69
+ - Moved the env-driven full message content capture warning into agent-core telemetry resolution so direct `@sayknow-cli/agent-core` consumers receive `full_content_capture_env_active` when `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=full` is used without an explicit `captureMessageContent` override.
70
+
71
+ ### Changed
72
+
73
+ - Clarified that telemetry `summary` content capture emits bounded real-content snippets in `pi.gen_ai.*` attributes and is not redacted or PII-free.
74
+
75
+ ## [0.2.4] - 2026-06-02
76
+
77
+ ### Added
78
+
79
+ - Added agent options for provider request and stream retry budgets and thread them through streaming calls.
80
+
81
+ ## [0.2.2] - 2026-05-31
82
+
83
+ ### Changed
84
+
85
+ - Refreshed agent-core package metadata for the SKC 0.2.2 release.
86
+
87
+ ## [0.2.1] - 2026-05-30
88
+
89
+ ### Changed
90
+
91
+ - Refreshed agent-core package metadata for the SKC 0.2.1 release.
92
+
93
+ ## [0.2.0] - 2026-05-28
94
+
95
+ ### Changed
96
+
97
+ - Refreshed agent-core package metadata for the SKC 0.2.0 release.
98
+
99
+ ## [0.1.3] - 2026-05-28
100
+
101
+ ### Changed
102
+
103
+ - Released the current dev branch fixes with refreshed 0.1.3 package metadata.
104
+
105
+ ## [0.1.2] - 2026-05-28
106
+
107
+ ### Changed
108
+
109
+ - Updated package metadata for the Sayknow-CLI npm publication.
110
+
111
+ ## [0.1.1] - 2026-05-28
112
+
113
+ ### Added
114
+
115
+ - Added `Agent.forceAbort()` so hosts can recover from provider/tool aborts that ignore cooperative cancellation without clearing conversation history.
116
+
117
+ ## [15.3.0] - 2026-05-25
118
+ ### Fixed
119
+
120
+ - Fixed `transformContext` receiving the loop config object as the `signal` argument instead of the actual `AbortSignal`, so hooks that check `signal.aborted` or call `signal.addEventListener` now work correctly under abort/timeout conditions
121
+ - Fixed `appendOnlyContext` not being re-evaluated after `setModel()` — the mode was decided once at session construction based on the initial model's provider, so switching from/to DeepSeek (or changing `provider.appendOnlyContext`) mid-session produced incorrect mode behavior
122
+
123
+ ## [15.2.3] - 2026-05-22
124
+ ### Added
125
+
126
+ - Added `onBeforeYield` hook support so user code can run right before the agent loop checks for follow-up messages
127
+
128
+ ## [15.1.3] - 2026-05-17
129
+ ### Added
130
+
131
+ - Added optional `telemetry` support to `generateSummary`, `generateHandoff`, `generateBranchSummary`, and `compact` options so compaction, handoff, and branch summary one-shot LLM calls can emit OpenTelemetry chat telemetry when enabled
132
+ - Added shared oneshot telemetry instrumentation for compaction, handoff, and branch summary calls, tagging spans with `pi.gen_ai.oneshot.kind` values such as `compaction_summary`, `compaction_short_summary`, `compaction_turn_prefix`, `handoff`, and `branch_summary`
133
+
134
+ ## [15.1.2] - 2026-05-15
135
+ ### Added
136
+
137
+ - Added `responseHeaders` to `ChatUsageEvent` and `ManualChatTelemetryOptions` so telemetry hooks receive captured lowercase upstream response headers for each chat span
138
+ - Added automatic gateway/proxy detection from response headers (`litellm`, `helicone`, `portkey`, `openrouter`) and stamped `pi.gen_ai.gateway.*` span attributes for detected routing metadata
139
+ - Added exported `detectGatewayFromHeaders` API for header-based gateway detection
140
+
141
+ ## [15.1.0] - 2026-05-15
142
+ ### Breaking Changes
143
+
144
+ - Removed the `@sayknow-cli/agent-core/compaction/handoff` exports from the package surface, including `extractHandoffDocument`, `createHandoffContext`, and `createHandoffFileName`
145
+ - Removed legacy telemetry constants from the public enum surface (including `AGGREGATE_ATTR`, `GenAIAttr.System`, and old `gen_ai.*` extension keys such as `gen_ai.request.service_tier`/cost/tool status/handoff fields) and replaced them with `OpenAIAttr`, `PiGenAIAttr`, and `PiGenAIAggregateAttr`
146
+
147
+ ### Added
148
+
149
+ - Added `generateHandoff(messages, model, apiKey, options)` to `@sayknow-cli/agent-core/compaction` to generate a handoff document by calling the model directly, using live system/tool context and optional metadata
150
+ - Added generation filtering so the returned handoff document now includes only text content blocks from the model output
151
+ - Added support for defining `AgentTool` schemas with Zod, with legacy TypeBox schemas still supported when generating tool schemas for model calls
152
+ - Added `OpenAIAttr`, `PiGenAIAttr`, and `PiGenAIAggregateAttr` exports so consumers can reference the new `openai.*` and `pi.gen_ai.*` telemetry attribute keys directly
153
+ - Added `onChatUsage` to `AgentTelemetryConfig`, an always-fired hook receiving a `ChatUsageEvent` for every chat step that produced usage. The event carries the chat `span`, `agent`, `conversationId`, `stepNumber`, `model`, `provider`, `serviceTier`, `usage`, optional `cost`, and resolved dynamic `attributes` — independent of whether a `costEstimator` is configured.
154
+ - Added `agentLoopDetailed(...)` and `agentLoopContinueDetailed(...)` helpers that return the same event stream plus a `detailed()` result with run `telemetry` and `coverage`
155
+ - Added `onRunEnd` to `AgentTelemetryConfig` to receive `AgentRunSummary` and `AgentRunCoverage` at the end of each invocation
156
+ - Added run-level telemetry and coverage types/helpers (for example `AgentRunSummary`, `AgentRunCoverage`, `aggregateAgentRunSummaries`, and `aggregateAgentRunCoverage`) to package exports
157
+ - Added generic telemetry extension hooks for dynamic span attributes, provider/agent-name normalization, per-step cost deltas, warning callbacks, bounded summary content capture, and manual chat telemetry for non-loop model calls.
158
+ - Added opt-in OpenTelemetry instrumentation on the agent loop. Pass `telemetry: {}` (or a richer `AgentTelemetryConfig`) on `AgentLoopConfig` / `AgentOptions` / `createAgentSession({ telemetry })` to emit GenAI-semantic-convention spans plus `pi.gen_ai.*` extension attributes:
159
+ - `invoke_agent {agent.name}` wraps each `agentLoop` invocation with `gen_ai.operation.name=invoke_agent`, agent identity, conversation id, and `pi.gen_ai.agent.step.count`.
160
+ - `chat {model}` per provider call, parented under `invoke_agent`, with OTEL request/response/usage attributes (`gen_ai.request.{model,stream,temperature,top_p,top_k,max_tokens,presence_penalty,stop_sequences}`, `gen_ai.response.{model,id,finish_reasons,time_to_first_chunk}`, `gen_ai.usage.{input_tokens,output_tokens,cache_read.input_tokens,cache_creation.input_tokens,reasoning.output_tokens}`) and project extensions for reasoning effort, tool choice, available tools, usage totals, and cost.
161
+ - `execute_tool {tool.name}` per tool call, parented under `invoke_agent`, with `gen_ai.tool.{name,call.id,description,type}` plus the active context so user/MCP/provider spans created inside `tool.execute()` attach as children.
162
+ - One-shot `handoff` span available via the public `recordHandoff(...)` helper for agent-to-agent transitions.
163
+ - Added `AgentTelemetryConfig` hooks (`onSpanStart`, `onSpanEnd`, `costEstimator`), `agent` identity, `attributes` envelope merged onto every span, `captureMessageContent` toggle (defaults to the `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` env var) emitting OTEL-shaped `gen_ai.input.messages` / `gen_ai.output.messages` / `gen_ai.system_instructions` / `gen_ai.tool.call.arguments` / `gen_ai.tool.call.result`, and tracer/tracerName override surfaces.
164
+ - Added `Agent#setTelemetry(config)` so consumers can swap or disable instrumentation between invocations.
165
+ - Added `@opentelemetry/api` as a runtime dependency; SDK setup (exporters, samplers, processors) remains the host's responsibility per standard OTEL conventions. When no SDK is registered, helpers fall through to no-op spans with zero overhead.
166
+ - Added compaction APIs under `@sayknow-cli/agent-core/compaction`, including context compaction, branch summarization, handoff prompt/context helpers, pruning, token budgeting, prompt templates, and OpenAI `/responses/compact` helpers.
167
+
168
+ ### Changed
169
+
170
+ - Changed handoff document generation to force `toolChoice: "none"` when calling the model so tool invocation is disabled during generation
171
+ - Changed `chat` spans to emit normalized provider identifiers in `gen_ai.provider.name` via OTEL-style values (for example `google` to `gcp.gemini`) instead of the legacy `gen_ai.system` label
172
+ - Changed service-tier telemetry to emit `openai.request.service_tier`/`openai.response.service_tier` only when supported by provider via `shouldSendServiceTier`, rather than always using `gen_ai.request.service_tier`
173
+ - Changed captured message payloads so full capture now records OTEL-structured message parts with `pi.gen_ai.request.messages`, `pi.gen_ai.system_instructions`, and `gen_ai.output.messages` including assistant `finish_reason`
174
+ - Changed the `agent_end` event payload to include optional `telemetry` and `coverage` fields when telemetry is enabled, while keeping the legacy payload shape when disabled
175
+ - Changed `invoke_agent` spans to include aggregate `pi.gen_ai.agent.*` attributes for chat/tool counts, latency, usage, cost, errors, and tool coverage
176
+
177
+ ### Fixed
178
+
179
+ - Fixed intent-field injection for tool schemas defined with Zod by converting them to wire schema before mutation
180
+ - Fixed token accounting in `ChatUsageEvent` and usage summaries so `inputTokens` and `totalTokens` now include cached read/write input tokens
181
+ - Fixed `execute_tool` span attributes so `pi.gen_ai.tool.status` and `error.type` now reflect run-level tool outcomes (`ok`, `error`, `skipped`, `blocked`, `timeout`, `aborted`) instead of mapping all non-ok cases the same way
182
+ - Fixed `onRunEnd` callbacks to be safe and idempotent by invoking them once per run and swallowing thrown callback errors so they cannot fail or duplicate successful runs
183
+ - Fixed run telemetry to count interrupted, blocked, or otherwise skipped tool calls so run coverage and tool counters now include those paths
184
+ - Fixed chat failure handling so failed chat steps are still represented in run summaries when provider streaming throws before yielding an assistant message
185
+ - Fixed double-counting of interrupted tool calls in run summaries: the `runTool` early-return on a queued steering interrupt now defers to the post-batch tail sweep so each call is recorded exactly once
186
+ - Fixed `coverage.toolsInvoked` and run-summary tool counters under-reporting tool calls embedded in an aborted/errored assistant message — those calls now record a collector orphan with status `aborted` or `error`
187
+ - Fixed `AgentRunSummary.usage.inputTokens` so it now includes `cache_read` and `cache_write` input tokens, matching `ChatUsageEvent.inputTokens`
188
+ - Fixed span lifecycle hooks (`onSpanStart`, `onSpanEnd`) so a thrown user callback is caught and surfaced via `onTelemetryWarning` (`on_span_start_failed` / `on_span_end_failed`) instead of leaking and aborting the surrounding span
189
+ - Fixed unbounded recursion in summary content capture when a captured value contains a cyclic or deeply nested array — array recursion now respects the same depth cap as plain-object recursion and replaces back-references with `"[Circular]"`
190
+
191
+ ## [15.0.1] - 2026-05-14
192
+ ### Breaking Changes
193
+
194
+ - Raised the minimum required Bun version from >=1.3.7 to >=1.3.14
195
+
196
+ ## [14.9.5] - 2026-05-12
197
+
198
+ ### Added
199
+
200
+ - Added an `isError?: boolean` field on `AgentToolResult` so tools can flag a non-throwing failure (e.g. an aggregator that catches per-entry errors). `coerceToolResult` preserves the flag and the agent loop surfaces it as a tool error on the wire.
201
+
202
+ ## [14.9.3] - 2026-05-10
203
+ ### Added
204
+
205
+ - Added `onHarmonyLeak` option on `Agent`/loop config to receive GPT-5 Harmony leak audit callbacks
206
+ - Added harmony-leak detection and audit exports to the package index for programmatic leak detection and recovery hooks
207
+
208
+ ### Changed
209
+
210
+ - Changed OpenAI code provider model runs to detect GPT-5 Harmony protocol leakage during streaming and automatically retry or recover tool calls instead of sending contaminated arguments downstream
211
+
212
+ ### Security
213
+
214
+ - Hardened tool-call handling against leaked `to=functions.*` protocol tails by truncating or retrying before execution
215
+ - Hardened failure handling so repeated GPT-5 Harmony leak mitigation is retried only up to two times before escalating to an explicit error
216
+
217
+ ## [14.9.0] - 2026-05-10
218
+ ### Added
219
+
220
+ - Added `Agent#metadata` field forwarded to every API request; callers can set arbitrary provider metadata (e.g. `metadata.user_id`) once and have it applied to all subsequent stream calls without modifying per-call options
221
+ - Added `Agent#setMetadataResolver(fn)` for installing a function that resolves request metadata at call time. The `metadata` getter dispatches through the resolver on every read (including the snapshot taken per `prompt()`), so callers reflect mutable external state (e.g. live OAuth account UUID after a token refresh) without manual re-syncs. Plain `agent.metadata = …` continues to set a static value and clears any installed resolver.
222
+
223
+ ### Added
224
+
225
+ - Added an `onSseEvent` agent option and loop config forwarding path for raw provider SSE diagnostics.
226
+
227
+ ## [14.7.6] - 2026-05-07
228
+
229
+ ### Added
230
+
231
+ - Added `hideThinkingSummary` option/getter/setter on `Agent` and `AgentLoopConfig`. Forwarded to the underlying stream call so providers can omit reasoning/thinking summaries on demand.
232
+ ## [14.7.2] - 2026-05-06
233
+ ### Added
234
+
235
+ - Added `loadMode` option to `AgentTool` to mark built-in tools as `essential` for initial loading or `discoverable` for search activation
236
+ - Added optional `summary` field to `AgentTool` definitions for one-line text used in tool discovery indexes
237
+
238
+ ## [14.7.0] - 2026-05-04
239
+ ### Breaking Changes
240
+
241
+ - Changed `Agent` API types so `systemPrompt` is now a list of prompt strings, requiring callers to pass and update system prompts via string arrays
242
+
243
+ ### Changed
244
+
245
+ - Removed automatic project-context injection into each model call from loop logic
246
+
247
+ ### Removed
248
+
249
+ - Removed the `projectPrompt` field from agent state/context and the `setProjectPrompt` mutator
250
+
251
+ ## [14.6.2] - 2026-05-03
252
+
253
+ ### Fixed
254
+
255
+ - Fixed unhandled promise rejection when `getApiKey` or any other async error occurs during `streamAssistantResponse`: agent loop IIFEs now catch and route errors through `EventStream.fail()`, which terminates the `for await` loop and lets `Agent#runLoop`'s catch block create a proper error assistant message instead of crashing
256
+
257
+ ## [14.6.0] - 2026-05-02
258
+ ### Fixed
259
+
260
+ - Fixed request cancellation before provider events by emitting an aborted assistant message and ending the stream with `stopReason: "aborted"`
261
+
262
+ ## [14.5.10] - 2026-04-30
263
+
264
+ ### Added
265
+
266
+ - Added an `onResponse` stream option for observing provider response metadata after response headers arrive.
267
+
268
+ ## [14.2.0] - 2026-04-23
269
+
270
+ ### Changed
271
+
272
+ - Changed tool dispatch to match model-returned tool calls by either internal tool name or custom wire name, enabling custom OpenAI tool names such as `apply_patch`.
273
+
274
+ ## [14.0.1] - 2026-04-08
275
+ ### Added
276
+
277
+ - Added `onAssistantMessageEvent` callback option to inspect assistant streaming events before they are emitted, enabling abort decisions before buffered events continue flowing
278
+ - Added `setAssistantMessageEventInterceptor()` method to dynamically set or update the assistant message event interceptor
279
+
280
+ ## [13.13.0] - 2026-03-18
281
+
282
+ ### Added
283
+
284
+ - Added `startup.checkUpdate` setting, set to `true` by default, can be disabled to skip the update check on agent initialization
285
+
286
+ ## [13.12.7] - 2026-03-16
287
+
288
+ ### Added
289
+
290
+ - Added overload for `prompt()` method accepting a string input with optional options parameter
291
+
292
+ ### Fixed
293
+
294
+ - Fixed stale forced toolChoice being passed to provider after tools are refreshed mid-turn
295
+
296
+ ## [13.9.16] - 2026-03-10
297
+ ### Added
298
+
299
+ - Added `onPayload` option to `AgentOptions` to inspect or replace provider payloads before they are sent
300
+
301
+ ## [13.9.3] - 2026-03-07
302
+
303
+ ### Added
304
+
305
+ - Exported `ThinkingLevel` selector constants and types for configuring agent reasoning behavior
306
+ - Added `inherit` thinking level option to defer reasoning configuration to higher-level selectors
307
+ - Added `serviceTier` option to configure service tier for agent requests
308
+
309
+ ### Changed
310
+
311
+ - Changed `thinkingLevel` from required string to optional `Effort` type, allowing undefined state
312
+ - Updated `setThinkingLevel()` method to accept `Effort | undefined` instead of `ThinkingLevel` string
313
+
314
+ ## [13.4.0] - 2026-03-01
315
+ ### Added
316
+
317
+ - Added `getToolChoice` option to dynamically override tool choice per LLM call
318
+
319
+ ## [13.3.8] - 2026-02-28
320
+ ### Changed
321
+
322
+ - Changed intent field name from `agent__intent` to `_i` in tool schemas
323
+
324
+ ### Fixed
325
+
326
+ - Fixed synthetic tool result text formatting so aborted/error tool results no longer emit `Tool execution was aborted.: Request was aborted` style punctuation.
327
+ ## [13.3.7] - 2026-02-27
328
+ ### Added
329
+
330
+ - Added `lenientArgValidation` option to tools to allow graceful handling of argument validation errors by passing raw arguments to execute() instead of returning an error to the LLM
331
+
332
+ ## [13.3.1] - 2026-02-26
333
+ ### Added
334
+
335
+ - Added `topP`, `topK`, `minP`, `presencePenalty`, and `repetitionPenalty` options to `AgentOptions` for fine-grained sampling control
336
+ - Added getter and setter properties for sampling parameters on the `Agent` class to allow runtime configuration
337
+
338
+ ## [13.1.0] - 2026-02-23
339
+
340
+ ### Changed
341
+
342
+ - Removed per-tool `agent__intent` field description from injected schema to reduce token usage; intent format is now documented once in the system prompt instead of repeated in every tool definition
343
+ ## [12.19.0] - 2026-02-22
344
+ ### Changed
345
+
346
+ - Updated tool result messages to include error details when tool execution fails
347
+
348
+ ## [12.14.0] - 2026-02-19
349
+
350
+ ### Added
351
+
352
+ - Added `intentTracing` option to enable intent goal extraction from tool calls, allowing models to specify high-level goals via a required `_intent` field that is automatically injected into tool schemas and stripped from arguments before execution
353
+
354
+ ## [12.11.0] - 2026-02-19
355
+
356
+ ### Added
357
+
358
+ - Exported `AgentBusyError` exception class for handling concurrent agent operations
359
+
360
+ ### Changed
361
+
362
+ - Agent now throws `AgentBusyError` instead of generic `Error` when attempting concurrent operations
363
+
364
+ ## [12.8.0] - 2026-02-16
365
+
366
+ ### Added
367
+
368
+ - Added `transformToolCallArguments` option to `AgentOptions` and `AgentLoopConfig` for transforming tool call arguments before execution (e.g. secret deobfuscation)
369
+
370
+ ## [12.2.0] - 2026-02-13
371
+
372
+ ### Added
373
+
374
+ - Added `providerSessionState` option to share provider state map for session-scoped transport and session caches
375
+ - Added `preferWebsockets` option to hint that websocket transport should be preferred when supported by the provider implementation
376
+
377
+ ## [11.10.0] - 2026-02-10
378
+
379
+ ### Added
380
+
381
+ - Added `temperature` option to `AgentOptions` to control LLM sampling temperature
382
+ - Added `temperature` getter and setter to `Agent` class for runtime configuration
383
+
384
+ ## [11.6.0] - 2026-02-07
385
+
386
+ ### Added
387
+
388
+ - Added `hasQueuedMessages()` method to check for pending steering/follow-up messages
389
+ - Resume queued steering and follow-up messages from `continue()` after auto-compaction
390
+
391
+ ### Changed
392
+
393
+ - Extracted `dequeueSteeringMessages()` and `dequeueFollowUpMessages()` from inline config callbacks
394
+ - Added `skipInitialSteeringPoll` option to `_runLoop()` for correct queue resume ordering
395
+
396
+ ## [11.3.0] - 2026-02-06
397
+
398
+ ### Added
399
+
400
+ - Added `maxRetryDelayMs` option to AgentOptions to cap server-requested retry delays, allowing higher-level retry logic to handle long waits with user visibility
401
+
402
+ ### Changed
403
+
404
+ - Updated ThinkingLevel documentation to include support for gpt-5.3 and gpt-5.3-openai-code models with 'xhigh' thinking level
405
+
406
+ ## [11.2.0] - 2026-02-05
407
+
408
+ ### Fixed
409
+
410
+ - Fixed handling of aborted requests to properly throw abort errors when stream terminates without a terminal event
411
+
412
+ ## [10.5.0] - 2026-02-04
413
+
414
+ ### Added
415
+
416
+ - Added `concurrency` option to `AgentTool` to control tool scheduling: "shared" (default, runs in parallel) or "exclusive" (runs alone)
417
+ - Implemented parallel execution of shared tools within a single agent turn for improved performance
418
+
419
+ ### Changed
420
+
421
+ - Refactored tool execution to support concurrent scheduling with proper interrupt handling and steering message checks
422
+
423
+ ## [9.2.2] - 2026-01-31
424
+
425
+ ### Added
426
+
427
+ - Added toolChoice option to AgentPromptOptions for controlling tool selection
428
+
429
+ ## [8.2.0] - 2026-01-24
430
+
431
+ ### Changed
432
+
433
+ - Updated TypeScript configuration for better publish-time configuration handling with tsconfig.publish.json
434
+
435
+ ## [8.0.0] - 2026-01-23
436
+
437
+ ### Added
438
+
439
+ - Added `nonAbortable` option to tools to ignore abort signals during execution
440
+
441
+ ## [6.8.0] - 2026-01-20
442
+
443
+ ### Changed
444
+
445
+ - Updated proxy stream processing to use utility function for reading lines
446
+
447
+ ## [6.2.0] - 2026-01-19
448
+
449
+ ### Added
450
+
451
+ - Enhanced getToolContext to receive tool call batch information including batchId, index, total count, and tool call details
452
+
453
+ ## [5.6.7] - 2026-01-18
454
+
455
+ ### Fixed
456
+
457
+ - Added proper tool result messages for tool calls that are aborted or error out
458
+ - Ensured tool_use/tool_result pairing is maintained when tool execution fails
459
+
460
+ ## [4.6.0] - 2026-01-12
461
+
462
+ ### Changed
463
+
464
+ - Modified assistant message handling to split messages around tool results for improved readability when using Cursor tools
465
+
466
+ ### Fixed
467
+
468
+ - Fixed tool result ordering in Cursor mode by buffering results and emitting them at the correct position within assistant messages
469
+
470
+ ## [4.3.0] - 2026-01-11
471
+
472
+ ### Added
473
+
474
+ - Added `cursorExecHandlers` and `cursorOnToolResult` options for local tool execution with cursor-based streaming
475
+ - Added `emitExternalEvent` method to allow external event injection into the agent state
476
+
477
+ ## [4.0.0] - 2026-01-10
478
+
479
+ ### Added
480
+
481
+ - Added `popLastSteer()` and `popLastFollowUp()` methods to remove and return the last queued message (LIFO) for dequeue operations
482
+ - `thinkingBudgets` option on `Agent` and `AgentOptions` to customize token budgets per thinking level
483
+ - `sessionId` option on `Agent` to forward session identifiers to LLM providers for session-based caching
484
+
485
+ ### Fixed
486
+
487
+ - `minimal` thinking level now maps to `minimal` reasoning effort instead of being treated as `low`
488
+
489
+ ## [3.33.0] - 2026-01-08
490
+
491
+ ### Fixed
492
+
493
+ - Ensured aborted assistant responses always include an error message for callers.
494
+ - Filtered thinking blocks from Cerebras request context to keep multi-turn prompts compatible.
495
+
496
+ ## [3.21.0] - 2026-01-06
497
+
498
+ ### Changed
499
+
500
+ - Switched from local `@sayknow-cli/ai` to upstream `@sayknow-cli/ai` package
501
+
502
+ ### Added
503
+
504
+ - Added `sessionId` option for provider caching (e.g., OpenAI code provider session-based prompt caching)
505
+ - Added `sessionId` getter/setter on Agent class for runtime session switching
506
+
507
+ ## [3.20.0] - 2026-01-06
508
+
509
+ ### Breaking Changes
510
+
511
+ - Replaced `queueMessage`/`queueMode` with steering + follow-up queues: use `steer`, `setSteeringMode`, and `getSteeringMode` for mid-run interruptions, and `followUp`, `setFollowUpMode`, and `getFollowUpMode` for post-turn messages
512
+ - Agent loop callbacks now use `getSteeringMessages` and `getFollowUpMessages` instead of `getQueuedMessages`
513
+
514
+ ### Added
515
+
516
+ - Added follow-up message queue support so new user messages can continue a run after the agent would otherwise stop
517
+ - Added `RenderResultOptions.spinnerFrame` for animated tool-result rendering
518
+
519
+ ### Changed
520
+
521
+ - `prompt()` and `continue()` now throw when the agent is already streaming; use steering or follow-up queues instead
522
+
523
+ ## [3.4.1337] - 2026-01-03
524
+
525
+ ### Added
526
+
527
+ - Added `popMessage()` method to Agent class for removing and retrieving the last message
528
+ - Added abort signal checks during response streaming for faster interruption handling
529
+
530
+ ### Fixed
531
+
532
+ - Fixed abort handling to properly return aborted message state when stream is interrupted mid-response
533
+
534
+ ## [1.341.0] - 2026-01-03
535
+
536
+ ### Added
537
+
538
+ - Added `interruptMode` option to control when queued messages interrupt tool execution.
539
+ - Implemented "immediate" mode (default) to check queue after each tool and interrupt remaining tools.
540
+ - Implemented "wait" mode to defer queue processing until the entire turn completes.
541
+ - Added getter and setter methods for `interruptMode` on Agent class.
542
+
543
+ ## [1.337.1] - 2026-01-02
544
+
545
+ ### Changed
546
+
547
+ - Forked to @sayknow-cli scope with unified versioning across all packages
548
+
549
+ ## [1.337.0] - 2026-01-02
550
+
551
+ Initial release under @sayknow-cli scope. See previous releases at [badlogic/pi-mono](https://github.com/badlogic/pi-mono).
552
+
553
+ ## [0.31.0] - 2026-01-02
554
+
555
+ ### Breaking Changes
556
+
557
+ - **Transport abstraction removed**: `ProviderTransport`, `AppTransport`, and `AgentTransport` interface have been removed. Use the `streamFn` option directly for custom streaming implementations.
558
+
559
+ - **Agent options renamed**:
560
+ - `transport` → removed (use `streamFn` instead)
561
+ - `messageTransformer` → `convertToLlm`
562
+ - `preprocessor` → `transformContext`
563
+
564
+ - **`AppMessage` renamed to `AgentMessage`**: All references to `AppMessage` have been renamed to `AgentMessage` for consistency.
565
+
566
+ - **`CustomMessages` renamed to `CustomAgentMessages`**: The declaration merging interface has been renamed.
567
+
568
+ - **`UserMessageWithAttachments` and `Attachment` types removed**: Attachment handling is now the responsibility of the `convertToLlm` function.
569
+
570
+ - **Agent loop moved from `@sayknow-cli/ai`**: The `agentLoop`, `agentLoopContinue`, and related types have moved to this package. Import from `@sayknow-cli/pi-agent` instead.
571
+
572
+ ### Added
573
+
574
+ - `streamFn` option on `Agent` for custom stream implementations. Default uses `streamSimple` from pi-ai.
575
+
576
+ - `streamProxy()` utility function for browser apps that need to proxy LLM calls through a backend server. Replaces the removed `AppTransport`.
577
+
578
+ - `getApiKey` option for dynamic API key resolution (useful for expiring OAuth tokens like GitHub Copilot).
579
+
580
+ - `agentLoop()` and `agentLoopContinue()` low-level functions for running the agent loop without the `Agent` class wrapper.
581
+
582
+ - New exported types: `AgentLoopConfig`, `AgentContext`, `AgentTool`, `AgentToolResult`, `AgentToolUpdateCallback`, `StreamFn`.
583
+
584
+ ### Changed
585
+
586
+ - `Agent` constructor now has all options optional (empty options use defaults).
587
+
588
+ - `queueMessage()` is now synchronous (no longer returns a Promise).