stitchkit 0.85.2 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +243 -0
  2. package/README.md +3 -0
  3. package/dist/agent-runtime/agent-tool.d.ts +25 -0
  4. package/dist/agent-runtime/agent-tool.d.ts.map +1 -0
  5. package/dist/agent-runtime/child-tools.d.ts +69 -0
  6. package/dist/agent-runtime/child-tools.d.ts.map +1 -0
  7. package/dist/agent-runtime/children.d.ts +113 -0
  8. package/dist/agent-runtime/children.d.ts.map +1 -0
  9. package/dist/agent-runtime/coding-tool-contract.d.ts +29 -0
  10. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  11. package/dist/agent-runtime/coding-tool-refusals.d.ts +2 -0
  12. package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
  13. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
  14. package/dist/agent-runtime/coding-tools.d.ts +1 -0
  15. package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
  16. package/dist/agent-runtime/control-schema.d.ts +17 -0
  17. package/dist/agent-runtime/control-schema.d.ts.map +1 -1
  18. package/dist/agent-runtime/conversations.d.ts +11 -0
  19. package/dist/agent-runtime/conversations.d.ts.map +1 -1
  20. package/dist/agent-runtime/event-schema.d.ts +34 -0
  21. package/dist/agent-runtime/event-schema.d.ts.map +1 -1
  22. package/dist/agent-runtime/event-search-tools.d.ts +53 -0
  23. package/dist/agent-runtime/event-search-tools.d.ts.map +1 -0
  24. package/dist/agent-runtime/event-search.d.ts +23 -0
  25. package/dist/agent-runtime/event-search.d.ts.map +1 -0
  26. package/dist/agent-runtime/fault-bench.d.ts +45 -0
  27. package/dist/agent-runtime/fault-bench.d.ts.map +1 -0
  28. package/dist/agent-runtime/observability.d.ts +6 -0
  29. package/dist/agent-runtime/observability.d.ts.map +1 -1
  30. package/dist/agent-runtime/projections.d.ts +69 -0
  31. package/dist/agent-runtime/projections.d.ts.map +1 -0
  32. package/dist/agent-runtime/provider-failure.d.ts +5 -1
  33. package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
  34. package/dist/agent-runtime/provider-origin.d.ts +12 -0
  35. package/dist/agent-runtime/provider-origin.d.ts.map +1 -0
  36. package/dist/agent-runtime/retry-policy.d.ts +27 -0
  37. package/dist/agent-runtime/retry-policy.d.ts.map +1 -0
  38. package/dist/agent-runtime/run-execution.d.ts +0 -9
  39. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  40. package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
  41. package/dist/agent-runtime/runtime.d.ts +15 -0
  42. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  43. package/dist/agent-runtime/sandbox.d.ts +66 -0
  44. package/dist/agent-runtime/sandbox.d.ts.map +1 -0
  45. package/dist/agent-runtime/schedule-tools.d.ts +35 -0
  46. package/dist/agent-runtime/schedule-tools.d.ts.map +1 -0
  47. package/dist/agent-runtime/schedules.d.ts +63 -0
  48. package/dist/agent-runtime/schedules.d.ts.map +1 -0
  49. package/dist/agent-runtime/schemas.d.ts +9 -0
  50. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  51. package/dist/agent-runtime/spill.d.ts +24 -0
  52. package/dist/agent-runtime/spill.d.ts.map +1 -0
  53. package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
  54. package/dist/agent-runtime/sqlite.d.ts +26 -0
  55. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  56. package/dist/agent-runtime/state-slots.d.ts +48 -0
  57. package/dist/agent-runtime/state-slots.d.ts.map +1 -0
  58. package/dist/agent-runtime/state-tools.d.ts +58 -0
  59. package/dist/agent-runtime/state-tools.d.ts.map +1 -0
  60. package/dist/agent-runtime/store-driver.d.ts +13 -0
  61. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  62. package/dist/agent-runtime/store-events.d.ts +829 -0
  63. package/dist/agent-runtime/store-events.d.ts.map +1 -0
  64. package/dist/agent-runtime/store-migrations/v1-to-v2.d.ts +6 -0
  65. package/dist/agent-runtime/store-migrations/v1-to-v2.d.ts.map +1 -0
  66. package/dist/agent-runtime/store.d.ts +45 -0
  67. package/dist/agent-runtime/store.d.ts.map +1 -1
  68. package/dist/agent-runtime/terminal-commit.d.ts +1 -1
  69. package/dist/agent-runtime-browser.js +5 -3
  70. package/dist/agent-runtime-coding-tools.js +144 -15
  71. package/dist/agent-runtime-harness.js +12 -11
  72. package/dist/agent-runtime-sqlite-bun.d.ts +1 -1
  73. package/dist/agent-runtime-sqlite-bun.d.ts.map +1 -1
  74. package/dist/agent-runtime-sqlite-bun.js +5 -4
  75. package/dist/agent-runtime-sqlite-node.d.ts +1 -1
  76. package/dist/agent-runtime-sqlite-node.d.ts.map +1 -1
  77. package/dist/agent-runtime-sqlite-node.js +5 -4
  78. package/dist/agent-runtime-testing.d.ts +3 -0
  79. package/dist/agent-runtime-testing.d.ts.map +1 -0
  80. package/dist/agent-runtime-testing.js +156 -0
  81. package/dist/agent-runtime.d.ts +16 -2
  82. package/dist/agent-runtime.d.ts.map +1 -1
  83. package/dist/agent-runtime.js +1632 -156
  84. package/dist/application.js +14 -14
  85. package/dist/cli.js +6 -6
  86. package/dist/{index-fwbkp2jn.js → index-0vfdh685.js} +2 -2
  87. package/dist/{index-5z8tezpx.js → index-0ydchz76.js} +3 -3
  88. package/dist/{index-3ds42w1w.js → index-1szetq6f.js} +33 -4
  89. package/dist/{index-2jg7b11j.js → index-35aefxby.js} +879 -424
  90. package/dist/index-3yrqvza8.js +964 -0
  91. package/dist/{index-fq492hg0.js → index-5wezxcxx.js} +238 -161
  92. package/dist/index-9553432s.js +26 -0
  93. package/dist/{index-27487ay5.js → index-9hw9eq48.js} +4 -4
  94. package/dist/index-cnyk6te3.js +77 -0
  95. package/dist/index-gskm1k5a.js +50 -0
  96. package/dist/{index-4hk633vz.js → index-hkm6wysp.js} +9 -2
  97. package/dist/{index-dx9xehwt.js → index-kc6h6hg0.js} +1 -1
  98. package/dist/{index-x15ss2dx.js → index-p1b1y93x.js} +3 -0
  99. package/dist/{index-mgtxfe6b.js → index-r159gjwy.js} +8 -1
  100. package/dist/{index-s4ckmrac.js → index-rcgsnrr6.js} +3 -3
  101. package/dist/{index-dggwnnjv.js → index-wn9cb82y.js} +1 -1
  102. package/dist/index-z1m86vc8.js +334 -0
  103. package/dist/{index-ff0kcqvp.js → index-z2452tsw.js} +3 -3
  104. package/dist/internal/sqlite.d.ts +13 -0
  105. package/dist/internal/sqlite.d.ts.map +1 -1
  106. package/dist/testing/agent-store-conformance.d.ts.map +1 -1
  107. package/dist/testing.js +89 -80
  108. package/dist/tool-invoker.js +4 -4
  109. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  110. package/dist/tools/manifest.d.ts +16 -0
  111. package/dist/tools/manifest.d.ts.map +1 -1
  112. package/dist/tools.d.ts +1 -1
  113. package/dist/tools.d.ts.map +1 -1
  114. package/dist/tools.js +10 -8
  115. package/llms-full.txt +373 -16
  116. package/package.json +6 -1
  117. package/dist/index-66nxrgy0.js +0 -554
  118. package/dist/index-y2s6h5bf.js +0 -83
package/CHANGELOG.md CHANGED
@@ -15,6 +15,249 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.87.0] — 2026-09-08
19
+
20
+ ### ⚠️ Breaking changes
21
+
22
+ **Who must act:** applications that implement `AgentConversationReader`
23
+ themselves. Applications that only call the reader returned by the SQLite store
24
+ need no change.
25
+
26
+ - **A message page says which of its messages compaction removed.**
27
+ `AgentConversationMessagePage` gains a required `compacted: string[]`, so a
28
+ reader that builds the page itself now names the ids in `items` that are no
29
+ longer part of the model's history — an empty array when it does not page
30
+ them at all.
31
+
32
+ ```ts
33
+ // before
34
+ return { items, ...(nextCursor && { nextCursor }) }
35
+
36
+ // after
37
+ return { items, compacted: [], ...(nextCursor && { nextCursor }) }
38
+ ```
39
+
40
+ ### Added
41
+
42
+ - **The history compaction removed can be read.** `conversations.messages`
43
+ takes `includeCompacted`, off by default. With it the page carries the whole
44
+ conversation in the order it happened, and `compacted` names the ids the
45
+ model no longer sees. Those rows were always in the store and no public read
46
+ reached them — every path filtered the active history — so an application
47
+ that shows a person their own long conversation had to keep a second copy of
48
+ it beside the store, which is the copy the event ledger exists to make
49
+ unnecessary. Paging is exact across a compaction boundary: a summary is
50
+ written at the position of the first message it replaced, so position alone
51
+ stopped identifying a row, and the page cursor now carries the row identity
52
+ beside it. A cursor issued by an earlier version still means what it meant.
53
+
54
+ ### Fixed
55
+
56
+ - **The v1 → v2 baseline carries the compacted history.** The migration built
57
+ each conversation's `runtime/baseline` from the active messages only, so for
58
+ exactly the conversations long enough to have been compacted the ledger could
59
+ not reconstruct what the person had said, while the normalized table still
60
+ held it. The baseline now records the whole sequence with `compacted` naming
61
+ what had been folded away. A file already migrated by 0.86.0 keeps the
62
+ baseline it got — one event cannot be rewritten after the fact — and its
63
+ compacted messages remain readable through `includeCompacted`.
64
+ - **A conversation that has a turn in it can be imported again.**
65
+ `importConversation` refused every archive whose snapshot carried a run —
66
+ that is, every conversation anyone actually had — with `Conversation archive
67
+ snapshot target is not empty`, into a target it had just reported empty. The
68
+ SQLite head compare-and-swap read its outcome from the driver's `changes`
69
+ count, and `bun:sqlite` counts what the event table's `AFTER INSERT` trigger
70
+ and FTS5's deferred index flush wrote during the same statement: an import
71
+ appends the whole archived ledger before it writes the head, so a swap that
72
+ moved one row reported five and was read as a conflict. The swap now reads
73
+ the version, compares it, and writes unconditionally inside the store's
74
+ `BEGIN IMMEDIATE` transaction. Export was never affected, and the memory
75
+ store never had the defect. Reported from a real consumer against published
76
+ 0.86.0.
77
+ - **A first head write is a compare-and-swap.** The same conditional upsert
78
+ guarded only its update branch, so a swap against a conversation with no head
79
+ row applied whatever `expectedVersion` it was given instead of conflicting.
80
+ No path in the runtime reaches it — a version above zero implies the row —
81
+ but the shipped Prisma example adapter carried the same shape and is fixed
82
+ with it.
83
+
84
+ ### Changed
85
+
86
+ - **`SqliteStatement.run`'s `changes` is documented as advisory.** The boundary
87
+ is satisfied structurally by a raw driver handle, so the number is that
88
+ driver's, and it may count trigger and virtual-table writes. Nothing in the
89
+ runtime decides correctness by it any more: the schedule claim, the firing
90
+ finalize and the cancellation each read their row and then write, the way the
91
+ head swap does. No input reached those three — each wrote before it appended
92
+ its event — and their observable behaviour is unchanged.
93
+ - **`runAgentStoreConformance` imports a conversation that has a run.** The kit
94
+ now announces an eighth conversation identity and carries a reference archive
95
+ with one accepted turn into the adapter under test, then compares the
96
+ restored snapshot and ledger against it. Adapters that provision from
97
+ `context.conversationIds`, as the kit has always required, need no change; an
98
+ adapter that cannot import a run-bearing archive now fails the kit instead of
99
+ passing it.
100
+
101
+ ## [0.86.0] — 2026-09-08
102
+
103
+ ### ⚠️ Breaking changes
104
+
105
+ **Who must act:** applications that branch on `AgentTerminalReason` or show it
106
+ to a person; applications implementing `AgentRuntimeStore` or an
107
+ `AgentRuntimeStoreDriver` (Prisma, Postgres, anything not built in); operators
108
+ of SQLite store files; subscribers that switch exhaustively over
109
+ `AgentRuntimeEvent` (including browser reducers).
110
+
111
+ - **A failure this runtime owns no longer reports `provider_failure`.** Three
112
+ values join the enum — `storage_conflict` (an owned mutation lost its
113
+ compare-and-set or the store refused it), `output_rejected` (the
114
+ application's own `protocol.acceptTerminal` refused the finished message) and
115
+ `runtime_failure` (this runtime, or a check the SDK runs on what this runtime
116
+ handed it, failed). Runs that ended `provider_failure` for these reasons now
117
+ end with the matching one, so a branch keyed on `provider_failure` stops
118
+ seeing them. `// before: reason === 'provider_failure'` → `// after:
119
+ reason === 'provider_failure' || reason === 'storage_conflict' ||
120
+ reason === 'output_rejected' || reason === 'runtime_failure'` for "did it
121
+ fail", and the specific value for what to tell a person. See the 0.86.0
122
+ migration in the upgrading guide.
123
+ - **Direct stores add the canonical event-ledger methods, and drivers add the
124
+ table behind them.** `AgentRuntimeStore` gains `appendEvent`, bounded
125
+ `readEvents`, `exportConversation` and `importConversation`.
126
+ `AgentRuntimeStoreDriver` gains a **required** `events: { append, list }` —
127
+ a driver passed to `createAgentRuntimeStore` implements the ledger table
128
+ itself; the store composes the methods over it. The Prisma example shows the
129
+ table and both operations
130
+ (`examples/agent-store-prisma/schema.prisma`, `adapter.ts`). See the 0.86.0
131
+ migration in the upgrading guide for the driver section.
132
+ - **The built-in SQLite stores migrate schema 1 → 2 on open, once, forward
133
+ only.** The first open of a version-1 file writes one `runtime/baseline`
134
+ event per conversation and sets the version to 2 in one transaction; a
135
+ 0.85.x package then refuses the file (`Unsupported … schema version 2`).
136
+ Back the file up before upgrading. Version 2 requires SQLite built with FTS5
137
+ (`SELECT sqlite_compileoption_used('ENABLE_FTS5')`); a build without it is
138
+ refused at open with `requires FTS5 support`.
139
+ - **Every run operation and every provider request now write to the ledger.**
140
+ Each store mutation appends a `runtime/transition`, and each model step
141
+ appends a `provider/request` before the provider is called. Bodies are
142
+ content-addressed: a message is written once per conversation as
143
+ `provider/message` (`{ sha256, message }`, binary parts as
144
+ `{ binary: true, sha256, bytes }` references) and a request names its instructions and messages by hash
145
+ (`{ runId, attempt, stepNumber, modelId, instructionsSha256, messageShas,
146
+ bodySha256 }`), so the ledger grows with new messages rather than with every
147
+ step's copy of the history. A checkpoint transition carries the draft's hash
148
+ and size, not the draft; the terminal commit carries the message. For an
149
+ external driver that is one more row per operation and per step, plus one
150
+ per new message, on the hot path; there is no opt-out, because the ledger is
151
+ the history.- **`AgentRuntimeEvent` gains the transient `attempt-reset` event.** Published
152
+ before a retried attempt's first delta, with `runtimeEpoch`, `sequence` and
153
+ `attempt`; `reduceAgentControlEvent` drops the run's transient text on it.
154
+ A reducer that switches exhaustively over `event.type` stops compiling until
155
+ it handles the case; a reducer that ignores unknown events keeps the failed
156
+ attempt's partial text on screen. `// before: switch (event.type) { … }` →
157
+ `// after: case 'attempt-reset': transient = { text: '', reasoning: '' }`.
158
+ Exported as `AgentAttemptResetEventSchema` from `stitchkit/agent-runtime` and
159
+ `stitchkit/agent-runtime/browser`.
160
+
161
+ ### Added
162
+
163
+ - **Agent runtime history is reconstructable from one versioned event ledger.**
164
+ SQLite schema 2 migrates version 1 conversations through a baseline event,
165
+ keeps normalized operational tables, adds deterministic projection
166
+ checkpoints and FTS5 event search, and supports canonical byte-stable
167
+ conversation export/import. Unknown event versions are skippable only when
168
+ their envelope explicitly opts in. Direct `AgentRuntimeStore`
169
+ implementations add `appendEvent`, `readEvents`, `exportConversation` and
170
+ `importConversation`. → ADR 0175. A conversation export is one read transaction over events, companions and the snapshot. The store conformance suite appends twenty events concurrently and reads them back; the Prisma example passes it by re-running a transaction on a ledger key collision — under `SERIALIZABLE` a unique violation is a serialization conflict — and maps `ignorable` only when set.
171
+ - **Projections fold events with a persisted checkpoint.**
172
+ `defineAgentProjection`, `createAgentProjectionRegistry` and
173
+ `createSqliteAgentProjectionStore` keep one row per conversation and
174
+ projection with the `uptoSeq` it was folded to — stale is possible, wrong is
175
+ not, and a reader always sees how far behind it is. Built-in:
176
+ `agentConversationCardProjection`, `agentSummaryProjection`,
177
+ `agentUsageProjection`, `agentOutlineProjection`, `agentStateSlotsProjection`,
178
+ `agentScheduleSummaryProjection`.
179
+ - **Typed state slots survive compaction.** `defineStateSlot`,
180
+ `createAgentStateSlotStore` and `renderAgentStateSlots` keep goal, plan and
181
+ choices as `state/set` events and render them into every provider request
182
+ from the ledger, not from the history compaction rewrites; `agentGoalStateSlot`
183
+ and `agentTodoStateSlot` ship with `createAgentStateTools`.
184
+ - **Events are searchable in the SQLite store.** `createSqliteAgentEventSearch`
185
+ over an FTS5 index answers with the exact `conversationId` and `seq`, denies
186
+ another conversation's events unless `authorizeConversation` says otherwise,
187
+ and `createAgentEventSearchTools` exposes `session_search`, `session_trace`
188
+ and `session_event`. Without an authorizer the query is bound to the requester's conversation in SQL; with one, foreign candidates are refused page by page until the requester's limit is met, so a louder neighbour cannot starve a match.
189
+ - **Oversized tool output spills whole instead of being cut.**
190
+ `createSqliteAgentSpillStore` is an `AgentCodingArtifactStore`: a shell
191
+ result over `limits.maxShellOutputBytes` is kept in full as a conversation
192
+ artifact, the model receives head, tail, omitted byte count and an
193
+ `artifact.reference`, and `read_output`/`search_output` re-check the
194
+ originating authorization before returning any of it. Retention cleanup
195
+ writes `spill/deleted` with the size; export carries the bytes.
196
+ - **A conversation can schedule its own input.** `createAgentScheduleService`
197
+ keeps `after`, `at` and `every` durably, delivers through the caller's
198
+ `dispatch` with `idempotencyKey: schedule:<id>:<occurrence>`, marks a firing missed across a
199
+ restart `late` with `lateByMs`, and requires an explicit IANA `timeZone` for
200
+ `every`; `schedule_*` tools for the agent. A row is claimed under compare-and-set before `dispatch`, one tick runs at a time, a `dispatch` that throws is recorded as `schedule/failed` with the row left due and the timer armed, and `every` fires once after an idle stretch. Delivery identity is `idempotencyKey: schedule:<id>:<occurrence>`.
201
+ - **Child runs inherit a bounded seed and a budget.**
202
+ `createSqliteAgentChildManager` spawns a child from the parent's ledger up to
203
+ `seedUptoSeq`, stops it at the next step boundary when `usd`, `tokens` or
204
+ `milliseconds` run out (`child-budget` policy, overrun recorded), records
205
+ `spawned → running → finished | stopped | lost`, and — given to
206
+ `createAgentRuntime` as `children` — stops the parent's children after the
207
+ parent's terminal is durable. `createAgentChildTools` exposes `subagent`,
208
+ `subagent_fork`, `list_agents`. `agentChildBudgetStopPolicy` is the child
209
+ runtime's own stop policy — `recordStepUsage` at every step boundary,
210
+ `policy_stop` as `child-budget` when the budget is spent; `recordStepUsage`
211
+ reports `enforced: false` when the deciding process holds no handle. The cascade runs once, from the executor that committed the parent's terminal, on an explicit stop — interrupted, cancelled, timed out, shut down — and not on success, supersession or failure, where the conversation goes on and the children with it; a child this process holds no handle for is `lost`, not `stopped`; a late result never rewrites `stopped` or `lost`; a spawn that throws leaves no row; the host's stop and reachability calls are bounded.
212
+ - **The shell tool reports its sandbox grade.** `probeAgentProcessSandbox`
213
+ probes once per process, `recordAgentSandboxProbe` writes `sandbox/probed`
214
+ with the grade and the required restrictions it lacks, and a missing required
215
+ restriction refuses `run_command` with `SANDBOX_UNAVAILABLE` — a different
216
+ code from a policy refusal — without running anything.
217
+ - **Provider stream failures retry only at a durable step boundary.**
218
+ `loop.retry` (`AgentRetryPolicy`) retries a `stream-cut` or other retryable
219
+ provider failure before any tool call in that attempt, drops the attempt's
220
+ partial output, and records `retry/scheduled` then `retry/started`; a failure
221
+ after a tool has executed is never retried. Off unless configured. The runtime publishes `attempt-reset` before the next attempt's first delta, checkpoints the draft after the partial output is discarded, hands an input injected into the failed attempt back so the retry sees it and the terminal absorbs only what was answered, and keeps the failed attempt's `finish-step` usage in the run's spend.
222
+ - **The tool catalog is inspectable and collision-checked.** `describeToolCatalog`
223
+ lists every tool with its origin, final name and schema size; two sources
224
+ producing one final name refuse at start naming both, and a schema-byte
225
+ budget is a warning unless made a refusal.
226
+ - **The SQLite handle shares its connection and its transaction.**
227
+ `createBunSqliteAgentRuntimeStore` / `createNodeSqliteAgentRuntimeStore`
228
+ return `{ store, conversations, database, transaction, close }`. The SQLite
229
+ companions — `createSqliteAgentProjectionStore`, `createSqliteAgentSpillStore`,
230
+ `createSqliteAgentChildManager`, `createAgentScheduleService` — take
231
+ `{ sqlite }` and write their rows and events through `transaction`
232
+ (`SqliteStoreTransaction`), in the store's own serialization, so a row and its
233
+ event land together or not at all. A store call from inside a scope is refused
234
+ with an error rather than queued behind the transaction it is in.
235
+ - **Provider failure fixtures have their own packed test entrypoint.**
236
+ `stitchkit/agent-runtime/testing` exposes a credential-free OpenAI-compatible
237
+ fault server, replay provider and deterministic race controls. Runtime
238
+ `loop.retry` records scheduled/started attempts and never automatically
239
+ repeats an attempt that already invoked a tool.
240
+
241
+ ### Fixed
242
+
243
+ - **A subscriber can accumulate a run's text again.** The transient
244
+ `sequence` advanced on every stream part, published or not, so a run's first
245
+ delta reached subscribers as sequence 4 behind an unpublished `text-start`:
246
+ every cursor saw a gap on the first delta of every run, the control view
247
+ flagged a resync and never accumulated the text it exists for. The sequence
248
+ now counts published transient events only. Older than this release.
249
+ - **A durable record no longer blames an upstream that was never contacted.**
250
+ `context_overflow` was carved out of `provider_failure` for exactly this
251
+ reason in an earlier release; the same misclassification remained at three
252
+ other sites. A store conflict — including the one 0.85.2 fixed, which ended
253
+ runs with zero provider calls — an acceptance refusal after a perfectly good
254
+ answer, and this runtime's own callback failing before any provider call all
255
+ said the provider failed. Provider origin is now marked where it is known,
256
+ at the `doStream` boundary, rather than assumed by elimination. The runtime
257
+ claims only failures it can identify as its own: an error part it cannot
258
+ identify is still the provider's, which is what an error part overwhelmingly
259
+ is.
260
+
18
261
  ## [0.85.2] — 2026-09-08
19
262
 
20
263
  ### Fixed
package/README.md CHANGED
@@ -109,6 +109,8 @@ continuations and reconnectable control compose there. Bounded direct file, sear
109
109
  shell and opaque-artifact tools live in the peer-free
110
110
  `stitchkit/agent-runtime/coding-tools` leaf. Neither surface owns process placement,
111
111
  restart, credentials, model catalogs or OS isolation.
112
+ Credential-free replay, scripted provider failures and deterministic race
113
+ controls live in `stitchkit/agent-runtime/testing` for Bun and Node tests.
112
114
  The separately installed `stitchkit-tui` package adds a maintained Bun/OpenTUI host over those
113
115
  headless contracts; its `stitchkit-tui/core` entrypoint exposes renderer-neutral terminal state
114
116
  without React, OpenTUI or agent-runtime imports. Neither enters the core dependency graph.
@@ -437,6 +439,7 @@ peer — an install pulls in only what the project actually uses.
437
439
  | `ai` | peer, optional | `stitchkit/tools` agent tools and the optional server-only `stitchkit/agent-runtime`. |
438
440
  | Headless harness | optional surface | `stitchkit/agent-runtime/harness`; uses the same optional `ai` peer and canonical runtime. |
439
441
  | Agent coding tools | optional surface | `stitchkit/agent-runtime/coding-tools`; peer-free, host-authorized direct file and shell tools. |
442
+ | Agent runtime testing | optional test surface | `stitchkit/agent-runtime/testing`; peer-free local fault server, replay and race fixtures. |
440
443
  | `stitchkit-tui` | separate optional package | Renderer-neutral `./core` state plus a Bun/OpenTUI terminal controller, commands, model/session pickers and authenticated local attachment over a caller-composed harness. |
441
444
  | `@openrouter/ai-sdk-provider` | peer, optional | Only `stitchkit/agent-runtime/openrouter`; neutral runtime imports do not resolve it. |
442
445
  | SQLite | runtime built-in, optional | `bun:sqlite` through `stitchkit/agent-runtime/sqlite/bun`, or `node:sqlite` on Node ≥ 22.5 through the Node leaf. |
@@ -0,0 +1,25 @@
1
+ import type { ZodObject, ZodType, z } from 'zod';
2
+ /** Peer-neutral tool definition for surfaces exposed only to an agent model. */
3
+ export interface AgentToolDefinition<TInput extends ZodObject, TOutput extends ZodType> {
4
+ name: string;
5
+ description: string;
6
+ identity: {
7
+ serviceName: string;
8
+ action: string;
9
+ scope?: string;
10
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
11
+ meta?: Record<string, unknown>;
12
+ };
13
+ input: TInput;
14
+ output: TOutput;
15
+ transports: readonly ['AGENT'];
16
+ handler(context: unknown): unknown;
17
+ }
18
+ interface AgentToolSourceDefinition<TInput extends ZodObject, TOutput extends ZodType> extends Omit<AgentToolDefinition<TInput, TOutput>, 'handler'> {
19
+ handler(context: {
20
+ input: z.output<TInput>;
21
+ }): z.output<TOutput> | Promise<z.output<TOutput>>;
22
+ }
23
+ export declare function defineAgentTool<TInput extends ZodObject, TOutput extends ZodType>(definition: AgentToolSourceDefinition<TInput, TOutput>): AgentToolDefinition<TInput, TOutput>;
24
+ export {};
25
+ //# sourceMappingURL=agent-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-tool.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/agent-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEjD,gFAAgF;AAChF,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,OAAO;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;QACpD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;CACpC;AAED,UAAU,yBAAyB,CAAC,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,OAAO,CACnF,SAAQ,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7D,OAAO,CAAC,OAAO,EAAE;QACf,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACzB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;CACpD;AAED,wBAAgB,eAAe,CAAC,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,OAAO,EAC/E,UAAU,EAAE,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,GACrD,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAKtC"}
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ import { type AgentChildManager } from './children.js';
3
+ export declare function createAgentChildTools(manager: AgentChildManager): readonly [import("./agent-tool.js").AgentToolDefinition<z.ZodObject<{
4
+ parentConversationId: z.ZodString;
5
+ childInput: z.ZodJSONSchema;
6
+ budget: z.ZodObject<{
7
+ usd: z.ZodOptional<z.ZodNumber>;
8
+ tokens: z.ZodOptional<z.ZodInt>;
9
+ milliseconds: z.ZodOptional<z.ZodInt>;
10
+ }, z.core.$strict>;
11
+ seedUptoSeq: z.ZodOptional<z.ZodInt>;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ childConversationId: z.ZodString;
14
+ state: z.ZodString;
15
+ resultReference: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>>, import("./agent-tool.js").AgentToolDefinition<z.ZodObject<{
17
+ parentConversationId: z.ZodString;
18
+ childInput: z.ZodJSONSchema;
19
+ budget: z.ZodObject<{
20
+ usd: z.ZodOptional<z.ZodNumber>;
21
+ tokens: z.ZodOptional<z.ZodInt>;
22
+ milliseconds: z.ZodOptional<z.ZodInt>;
23
+ }, z.core.$strict>;
24
+ seedUptoSeq: z.ZodOptional<z.ZodInt>;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ childConversationId: z.ZodString;
27
+ state: z.ZodString;
28
+ resultReference: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strip>>, import("./agent-tool.js").AgentToolDefinition<z.ZodObject<{
30
+ parentConversationId: z.ZodString;
31
+ }, z.core.$strict>, z.ZodObject<{
32
+ children: z.ZodArray<z.ZodObject<{
33
+ parentConversationId: z.ZodString;
34
+ childConversationId: z.ZodString;
35
+ seedUptoSeq: z.ZodInt;
36
+ state: z.ZodEnum<{
37
+ finished: "finished";
38
+ lost: "lost";
39
+ running: "running";
40
+ spawned: "spawned";
41
+ stopped: "stopped";
42
+ }>;
43
+ budget: z.ZodObject<{
44
+ usd: z.ZodOptional<z.ZodNumber>;
45
+ tokens: z.ZodOptional<z.ZodInt>;
46
+ milliseconds: z.ZodOptional<z.ZodInt>;
47
+ }, z.core.$strict>;
48
+ usage: z.ZodObject<{
49
+ tokens: z.ZodInt;
50
+ usd: z.ZodNumber;
51
+ milliseconds: z.ZodInt;
52
+ }, z.core.$strict>;
53
+ resultReference: z.ZodOptional<z.ZodString>;
54
+ createdAt: z.ZodString;
55
+ updatedAt: z.ZodString;
56
+ }, z.core.$strict>>;
57
+ }, z.core.$strip>>, import("./agent-tool.js").AgentToolDefinition<z.ZodObject<{
58
+ parentConversationId: z.ZodString;
59
+ childConversationId: z.ZodString;
60
+ input: z.ZodJSONSchema;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ sent: z.ZodLiteral<true>;
63
+ }, z.core.$strip>>, import("./agent-tool.js").AgentToolDefinition<z.ZodObject<{
64
+ parentConversationId: z.ZodString;
65
+ childConversationId: z.ZodString;
66
+ }, z.core.$strict>, z.ZodObject<{
67
+ interrupted: z.ZodLiteral<true>;
68
+ }, z.core.$strip>>];
69
+ //# sourceMappingURL=child-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child-tools.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/child-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,YAAY,CAAC;AAmDpB,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuD/D"}
@@ -0,0 +1,113 @@
1
+ import type { LanguageModelUsage } from 'ai';
2
+ import { z } from 'zod';
3
+ import type { AgentRuntimeStopPolicy } from './runtime.js';
4
+ import type { AgentUsage } from './schemas.js';
5
+ import type { SqliteAgentRuntimeStore } from './sqlite.js';
6
+ export declare const AgentChildBudgetSchema: z.ZodObject<{
7
+ usd: z.ZodOptional<z.ZodNumber>;
8
+ tokens: z.ZodOptional<z.ZodInt>;
9
+ milliseconds: z.ZodOptional<z.ZodInt>;
10
+ }, z.core.$strict>;
11
+ export type AgentChildBudget = z.infer<typeof AgentChildBudgetSchema>;
12
+ export declare const AgentChildStateSchema: z.ZodEnum<{
13
+ finished: "finished";
14
+ lost: "lost";
15
+ running: "running";
16
+ spawned: "spawned";
17
+ stopped: "stopped";
18
+ }>;
19
+ export type AgentChildState = z.infer<typeof AgentChildStateSchema>;
20
+ export declare const AgentChildRecordSchema: z.ZodObject<{
21
+ parentConversationId: z.ZodString;
22
+ childConversationId: z.ZodString;
23
+ seedUptoSeq: z.ZodInt;
24
+ state: z.ZodEnum<{
25
+ finished: "finished";
26
+ lost: "lost";
27
+ running: "running";
28
+ spawned: "spawned";
29
+ stopped: "stopped";
30
+ }>;
31
+ budget: z.ZodObject<{
32
+ usd: z.ZodOptional<z.ZodNumber>;
33
+ tokens: z.ZodOptional<z.ZodInt>;
34
+ milliseconds: z.ZodOptional<z.ZodInt>;
35
+ }, z.core.$strict>;
36
+ usage: z.ZodObject<{
37
+ tokens: z.ZodInt;
38
+ usd: z.ZodNumber;
39
+ milliseconds: z.ZodInt;
40
+ }, z.core.$strict>;
41
+ resultReference: z.ZodOptional<z.ZodString>;
42
+ createdAt: z.ZodString;
43
+ updatedAt: z.ZodString;
44
+ }, z.core.$strict>;
45
+ export type AgentChildRecord = z.infer<typeof AgentChildRecordSchema>;
46
+ export interface AgentChildHandle {
47
+ result: Promise<{
48
+ resultReference?: string;
49
+ }>;
50
+ stopPolicy(name: string): void | Promise<void>;
51
+ sendMessage?(input: unknown): void | Promise<void>;
52
+ reachable?(): boolean | Promise<boolean>;
53
+ }
54
+ export interface AgentChildManager {
55
+ spawnChild(request: {
56
+ parentConversationId: string;
57
+ childConversationId?: string;
58
+ seedUptoSeq?: number;
59
+ childInput: unknown;
60
+ budget: AgentChildBudget;
61
+ }): Promise<AgentChildRecord>;
62
+ listChildren(parentConversationId: string): readonly AgentChildRecord[];
63
+ recordStepUsage(request: {
64
+ childConversationId: string;
65
+ usage: AgentUsage;
66
+ elapsedMs: number;
67
+ }): Promise<{
68
+ stop: boolean;
69
+ /** Whether a stop was delivered to the child's host from this process. */
70
+ enforced: boolean;
71
+ policyName?: string;
72
+ overrun: {
73
+ tokens: number;
74
+ usd: number;
75
+ milliseconds: number;
76
+ };
77
+ }>;
78
+ stopChildren(parentConversationId: string): Promise<void>;
79
+ sendMessage(parentConversationId: string, childConversationId: string, input: unknown): Promise<void>;
80
+ interruptChild(parentConversationId: string, childConversationId: string): Promise<void>;
81
+ waitChild(childConversationId: string): Promise<void>;
82
+ }
83
+ export declare function createSqliteAgentChildManager(input: {
84
+ sqlite: SqliteAgentRuntimeStore;
85
+ spawn(request: {
86
+ parentConversationId: string;
87
+ childConversationId: string;
88
+ seedArchive: Uint8Array;
89
+ childInput: unknown;
90
+ budget: AgentChildBudget;
91
+ }): AgentChildHandle | Promise<AgentChildHandle>;
92
+ remainingBudget?(parentConversationId: string): AgentChildBudget | Promise<AgentChildBudget>;
93
+ now?: () => Date;
94
+ }): AgentChildManager;
95
+ /**
96
+ * The child runtime's own budget policy.
97
+ *
98
+ * `recordStepUsage` measures and decides; something has to call it at every
99
+ * step boundary of the child's run, and that is the child's runtime. Given to
100
+ * `createAgentRuntime({ loop: { stopPolicies: [agentChildBudgetStopPolicy(…)] } })`
101
+ * in the host that runs the child, it records the last step's usage and stops
102
+ * the run as `policy_stop` (`child-budget`) when the budget is spent — the
103
+ * enforcement the guide promises, in the package rather than in every host.
104
+ */
105
+ export declare function agentChildBudgetStopPolicy(input: {
106
+ manager: Pick<AgentChildManager, 'recordStepUsage'>;
107
+ childConversationId: string;
108
+ /** Cost of a step, when a USD budget is set; tokens come from the step itself. */
109
+ cost?: (step: {
110
+ usage: LanguageModelUsage;
111
+ }) => AgentUsage['cost'];
112
+ }): AgentRuntimeStopPolicy;
113
+ //# sourceMappingURL=children.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/children.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,W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;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kFAAkF;IAClF,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,KAAK,UAAU,CAAC,MAAM,CAAC,CAAC;CACpE,GAAG,sBAAsB,CAqBzB"}
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import type { AgentProcessSandbox, AgentSandboxRestriction } from './sandbox.js';
2
3
  export declare const AgentCodingToolLimitsSchema: z.ZodObject<{
3
4
  maxPathBytes: z.ZodInt;
4
5
  maxReadBytes: z.ZodInt;
@@ -50,6 +51,11 @@ export declare const AgentCodingToolAuthorizationSchema: z.ZodDiscriminatedUnion
50
51
  reference: z.ZodString;
51
52
  offset: z.ZodInt;
52
53
  maxBytes: z.ZodInt;
54
+ }, z.core.$strict>, z.ZodObject<{
55
+ operation: z.ZodLiteral<"artifact-search">;
56
+ reference: z.ZodString;
57
+ query: z.ZodString;
58
+ maxMatches: z.ZodInt;
53
59
  }, z.core.$strict>, z.ZodObject<{
54
60
  operation: z.ZodLiteral<"shell">;
55
61
  executable: z.ZodString;
@@ -75,6 +81,10 @@ export interface AgentCodingToolConfig {
75
81
  executables?: Readonly<Record<string, string>>;
76
82
  environment?: Readonly<Record<string, string>>;
77
83
  artifacts?: AgentCodingArtifactStore;
84
+ sandbox?: {
85
+ adapter: AgentProcessSandbox;
86
+ required: readonly AgentSandboxRestriction[];
87
+ };
78
88
  search?: {
79
89
  /** Directory basenames omitted from workspace search at every depth. */
80
90
  excludeDirectories?: readonly string[];
@@ -82,9 +92,12 @@ export interface AgentCodingToolConfig {
82
92
  limits?: Partial<AgentCodingToolLimits>;
83
93
  }
84
94
  export interface AgentCodingArtifactStore {
95
+ /** Original admission checked before artifact bytes are read. */
96
+ authorization?(reference: string): AgentCodingToolAuthorization | undefined | Promise<AgentCodingToolAuthorization | undefined>;
85
97
  write(input: {
86
98
  mediaType: string;
87
99
  data: Uint8Array;
100
+ authorization?: AgentCodingToolAuthorization;
88
101
  }): {
89
102
  reference: string;
90
103
  } | Promise<{
@@ -97,10 +110,23 @@ export interface AgentCodingArtifactStore {
97
110
  }): {
98
111
  data: Uint8Array;
99
112
  totalBytes?: number;
113
+ authorization?: AgentCodingToolAuthorization;
100
114
  } | Promise<{
101
115
  data: Uint8Array;
102
116
  totalBytes?: number;
117
+ authorization?: AgentCodingToolAuthorization;
103
118
  }>;
119
+ search?(input: {
120
+ reference: string;
121
+ query: string;
122
+ maxMatches: number;
123
+ }): readonly {
124
+ line: number;
125
+ text: string;
126
+ }[] | Promise<readonly {
127
+ line: number;
128
+ text: string;
129
+ }[]>;
104
130
  }
105
131
  export interface AgentCodingToolDefinition {
106
132
  name: string;
@@ -171,6 +197,9 @@ export declare const ShellOutputSchema: z.ZodObject<{
171
197
  reference: z.ZodString;
172
198
  bytes: z.ZodInt;
173
199
  truncated: z.ZodBoolean;
200
+ headBytes: z.ZodInt;
201
+ tailBytes: z.ZodInt;
202
+ omittedBytes: z.ZodInt;
174
203
  }, z.core.$strict>>;
175
204
  }, z.core.$strict>;
176
205
  export declare function resolveCodingToolLimits(input: Partial<AgentCodingToolLimits> | undefined): AgentCodingToolLimits;
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-contract.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;kBAgB7B,CAAC;AAEZ,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAsD7C,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2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ChD,qBAAqB,CAEvB"}
@@ -22,6 +22,8 @@ declare const REFUSAL_STATUS: {
22
22
  readonly FORBIDDEN: 403;
23
23
  readonly NOT_FOUND: 404;
24
24
  readonly CONFLICT: 409;
25
+ readonly SANDBOX_UNAVAILABLE: 503;
26
+ readonly SANDBOX_INSUFFICIENT: 503;
25
27
  };
26
28
  export type CodingRefusalCode = keyof typeof REFUSAL_STATUS;
27
29
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-refusals.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-refusals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,8EAA8E;AAC9E,QAAA,MAAM,cAAc;aAClB,WAAW,EAAE,GAAG;aAChB,SAAS,EAAE,GAAG;aACd,SAAS,EAAE,GAAG;aACd,QAAQ,EAAE,GAAG;CACL,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,cAAc,CAAC;AAE5D;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACjE,KAAK,CAQP;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACjE,KAAK,CAKP;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAiC/E"}
1
+ {"version":3,"file":"coding-tool-refusals.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-refusals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,8EAA8E;AAC9E,QAAA,MAAM,cAAc;aAClB,WAAW,EAAE,GAAG;aAChB,SAAS,EAAE,GAAG;aACd,SAAS,EAAE,GAAG;aACd,QAAQ,EAAE,GAAG;aACb,mBAAmB,EAAE,GAAG;aACxB,oBAAoB,EAAE,GAAG;CACjB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,cAAc,CAAC;AAE5D;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACjE,KAAK,CAQP;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACjE,KAAK,CAKP;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAiC/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-shell.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-shell.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAG3B,MAAM,wBAAwB,CAAC;AAoKhC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,yBAAyB,CA4D3B"}
1
+ {"version":3,"file":"coding-tool-shell.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-shell.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAG3B,MAAM,wBAAwB,CAAC;AAgNhC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,yBAAyB,CAgH3B"}
@@ -6,6 +6,7 @@ export declare const AGENT_CODING_TOOL_NAMES: {
6
6
  listDirectory: string;
7
7
  readFile: string;
8
8
  readOutput: string;
9
+ searchOutput: string;
9
10
  runCommand: string;
10
11
  searchFiles: string;
11
12
  writeFile: string;
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tools.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE/B,MAAM,wBAAwB,CAAC;AAOhC,cAAc,wBAAwB,CAAC;AAEvC,eAAO,MAAM,uBAAuB;;;;;;;;;CASQ,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CA8EtC"}
1
+ {"version":3,"file":"coding-tools.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE/B,MAAM,wBAAwB,CAAC;AAOhC,cAAc,wBAAwB,CAAC;AAEvC,eAAO,MAAM,uBAAuB;;;;;;;;;;CAUQ,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CA4HtC"}