@namzu/sdk 68.0.0 → 69.0.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 (281) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/bridge/acp/server.d.ts +12 -0
  3. package/dist/bridge/acp/server.d.ts.map +1 -1
  4. package/dist/bridge/acp/server.js +20 -0
  5. package/dist/bridge/acp/server.js.map +1 -1
  6. package/dist/compaction/context-window.d.ts +8 -0
  7. package/dist/compaction/context-window.d.ts.map +1 -1
  8. package/dist/compaction/context-window.js +14 -0
  9. package/dist/compaction/context-window.js.map +1 -1
  10. package/dist/compaction/loaded-skills.d.ts +10 -0
  11. package/dist/compaction/loaded-skills.d.ts.map +1 -1
  12. package/dist/compaction/loaded-skills.js +45 -1
  13. package/dist/compaction/loaded-skills.js.map +1 -1
  14. package/dist/compaction/manager.d.ts +8 -0
  15. package/dist/compaction/manager.d.ts.map +1 -1
  16. package/dist/compaction/manager.js +31 -0
  17. package/dist/compaction/manager.js.map +1 -1
  18. package/dist/compaction/manual.d.ts.map +1 -1
  19. package/dist/compaction/manual.js +7 -1
  20. package/dist/compaction/manual.js.map +1 -1
  21. package/dist/compaction/model-summary.js +2 -2
  22. package/dist/compaction/model-summary.js.map +1 -1
  23. package/dist/compaction/restore.d.ts +8 -0
  24. package/dist/compaction/restore.d.ts.map +1 -1
  25. package/dist/compaction/restore.js +65 -0
  26. package/dist/compaction/restore.js.map +1 -1
  27. package/dist/compaction/salience/working-set.d.ts.map +1 -1
  28. package/dist/compaction/salience/working-set.js +2 -2
  29. package/dist/compaction/salience/working-set.js.map +1 -1
  30. package/dist/compaction/tool-result-editing.d.ts +6 -0
  31. package/dist/compaction/tool-result-editing.d.ts.map +1 -1
  32. package/dist/compaction/tool-result-editing.js +7 -1
  33. package/dist/compaction/tool-result-editing.js.map +1 -1
  34. package/dist/compaction/types.d.ts +2 -0
  35. package/dist/compaction/types.d.ts.map +1 -1
  36. package/dist/compaction/wire.d.ts.map +1 -1
  37. package/dist/compaction/wire.js +4 -0
  38. package/dist/compaction/wire.js.map +1 -1
  39. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  40. package/dist/manager/session/turn-recorder.js +23 -1
  41. package/dist/manager/session/turn-recorder.js.map +1 -1
  42. package/dist/network/join.d.ts +10 -0
  43. package/dist/network/join.d.ts.map +1 -1
  44. package/dist/network/join.js +15 -0
  45. package/dist/network/join.js.map +1 -1
  46. package/dist/network/service.d.ts.map +1 -1
  47. package/dist/network/service.js +166 -12
  48. package/dist/network/service.js.map +1 -1
  49. package/dist/network/store.d.ts +23 -1
  50. package/dist/network/store.d.ts.map +1 -1
  51. package/dist/network/store.js +23 -1
  52. package/dist/network/store.js.map +1 -1
  53. package/dist/network/transport.d.ts +1 -1
  54. package/dist/network/transport.js +1 -1
  55. package/dist/network/wire.d.ts +12 -0
  56. package/dist/network/wire.d.ts.map +1 -1
  57. package/dist/network/wire.js +12 -1
  58. package/dist/network/wire.js.map +1 -1
  59. package/dist/prompt/coding-agent-doctrine.d.ts +4 -4
  60. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  61. package/dist/prompt/coding-agent-doctrine.js +7 -2
  62. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  63. package/dist/provider/fallback.d.ts.map +1 -1
  64. package/dist/provider/fallback.js +5 -0
  65. package/dist/provider/fallback.js.map +1 -1
  66. package/dist/provider/idle-timeout.d.ts.map +1 -1
  67. package/dist/provider/idle-timeout.js +5 -0
  68. package/dist/provider/idle-timeout.js.map +1 -1
  69. package/dist/provider/instrumentation.d.ts.map +1 -1
  70. package/dist/provider/instrumentation.js +10 -0
  71. package/dist/provider/instrumentation.js.map +1 -1
  72. package/dist/provider/model-window-suffix.d.ts.map +1 -1
  73. package/dist/provider/model-window-suffix.js +1 -0
  74. package/dist/provider/model-window-suffix.js.map +1 -1
  75. package/dist/provider/retry.d.ts.map +1 -1
  76. package/dist/provider/retry.js +5 -0
  77. package/dist/provider/retry.js.map +1 -1
  78. package/dist/public-runtime.d.ts +1 -1
  79. package/dist/public-runtime.d.ts.map +1 -1
  80. package/dist/public-runtime.js +1 -1
  81. package/dist/public-runtime.js.map +1 -1
  82. package/dist/public-tools.d.ts +2 -0
  83. package/dist/public-tools.d.ts.map +1 -1
  84. package/dist/public-tools.js +4 -0
  85. package/dist/public-tools.js.map +1 -1
  86. package/dist/public-types.d.ts +1 -0
  87. package/dist/public-types.d.ts.map +1 -1
  88. package/dist/registry/tool/presentation.d.ts +8 -1
  89. package/dist/registry/tool/presentation.d.ts.map +1 -1
  90. package/dist/registry/tool/presentation.js +14 -5
  91. package/dist/registry/tool/presentation.js.map +1 -1
  92. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  93. package/dist/runtime/jobs/registry.js +2 -1
  94. package/dist/runtime/jobs/registry.js.map +1 -1
  95. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  96. package/dist/runtime/query/auto-review/classifier.js +19 -3
  97. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  98. package/dist/runtime/query/auto-review/failure.d.ts +12 -0
  99. package/dist/runtime/query/auto-review/failure.d.ts.map +1 -0
  100. package/dist/runtime/query/auto-review/failure.js +46 -0
  101. package/dist/runtime/query/auto-review/failure.js.map +1 -0
  102. package/dist/runtime/query/auto-review/index.d.ts +1 -0
  103. package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
  104. package/dist/runtime/query/auto-review/index.js +1 -0
  105. package/dist/runtime/query/auto-review/index.js.map +1 -1
  106. package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
  107. package/dist/runtime/query/file-evidence-replay.js +6 -6
  108. package/dist/runtime/query/file-evidence-replay.js.map +1 -1
  109. package/dist/runtime/query/index.d.ts.map +1 -1
  110. package/dist/runtime/query/index.js +8 -1
  111. package/dist/runtime/query/index.js.map +1 -1
  112. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  113. package/dist/runtime/query/iteration/index.js +2 -0
  114. package/dist/runtime/query/iteration/index.js.map +1 -1
  115. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  116. package/dist/runtime/query/iteration/phases/compaction.js +21 -3
  117. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  118. package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
  119. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  120. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  121. package/dist/runtime/query/iteration/phases/per-call-review.d.ts +6 -2
  122. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  123. package/dist/runtime/query/iteration/phases/per-call-review.js +24 -9
  124. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  125. package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
  126. package/dist/runtime/query/iteration/step-shaping.js +4 -0
  127. package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
  128. package/dist/runtime/query/prepare-turn.d.ts +5 -1
  129. package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
  130. package/dist/runtime/query/prepare-turn.js +13 -3
  131. package/dist/runtime/query/prepare-turn.js.map +1 -1
  132. package/dist/runtime/query/review-policy.d.ts +13 -2
  133. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  134. package/dist/runtime/query/review-policy.js +13 -2
  135. package/dist/runtime/query/review-policy.js.map +1 -1
  136. package/dist/runtime/query/turn/outcome-ledger.d.ts +4 -0
  137. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  138. package/dist/runtime/query/turn/outcome-ledger.js +36 -1
  139. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  140. package/dist/sandbox/provider/local.d.ts.map +1 -1
  141. package/dist/sandbox/provider/local.js +3 -1
  142. package/dist/sandbox/provider/local.js.map +1 -1
  143. package/dist/tools/admit-facts.d.ts.map +1 -1
  144. package/dist/tools/admit-facts.js +20 -0
  145. package/dist/tools/admit-facts.js.map +1 -1
  146. package/dist/tools/builtins/bash.d.ts.map +1 -1
  147. package/dist/tools/builtins/bash.js +5 -2
  148. package/dist/tools/builtins/bash.js.map +1 -1
  149. package/dist/tools/builtins/browser.js +2 -2
  150. package/dist/tools/builtins/browser.js.map +1 -1
  151. package/dist/tools/builtins/computer-use.d.ts +4 -0
  152. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  153. package/dist/tools/builtins/computer-use.js +106 -5
  154. package/dist/tools/builtins/computer-use.js.map +1 -1
  155. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  156. package/dist/tools/builtins/content-fingerprint.js +2 -1
  157. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  158. package/dist/tools/builtins/edit-apply.d.ts +1 -0
  159. package/dist/tools/builtins/edit-apply.d.ts.map +1 -1
  160. package/dist/tools/builtins/edit-apply.js +108 -21
  161. package/dist/tools/builtins/edit-apply.js.map +1 -1
  162. package/dist/tools/builtins/edit-match.d.ts +37 -0
  163. package/dist/tools/builtins/edit-match.d.ts.map +1 -1
  164. package/dist/tools/builtins/edit-match.js +193 -0
  165. package/dist/tools/builtins/edit-match.js.map +1 -1
  166. package/dist/tools/builtins/edit.d.ts.map +1 -1
  167. package/dist/tools/builtins/edit.js +14 -7
  168. package/dist/tools/builtins/edit.js.map +1 -1
  169. package/dist/tools/builtins/exit-semantics.d.ts +8 -0
  170. package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
  171. package/dist/tools/builtins/exit-semantics.js +19 -0
  172. package/dist/tools/builtins/exit-semantics.js.map +1 -1
  173. package/dist/tools/builtins/index.d.ts +2 -0
  174. package/dist/tools/builtins/index.d.ts.map +1 -1
  175. package/dist/tools/builtins/index.js +1 -0
  176. package/dist/tools/builtins/index.js.map +1 -1
  177. package/dist/tools/builtins/present-file.d.ts +24 -0
  178. package/dist/tools/builtins/present-file.d.ts.map +1 -0
  179. package/dist/tools/builtins/present-file.js +116 -0
  180. package/dist/tools/builtins/present-file.js.map +1 -0
  181. package/dist/tools/builtins/read-file.js +1 -1
  182. package/dist/tools/builtins/read-file.js.map +1 -1
  183. package/dist/tools/builtins/read-render.d.ts +12 -1
  184. package/dist/tools/builtins/read-render.d.ts.map +1 -1
  185. package/dist/tools/builtins/read-render.js +16 -3
  186. package/dist/tools/builtins/read-render.js.map +1 -1
  187. package/dist/tools/builtins/search-tools.d.ts +10 -0
  188. package/dist/tools/builtins/search-tools.d.ts.map +1 -1
  189. package/dist/tools/builtins/search-tools.js +36 -2
  190. package/dist/tools/builtins/search-tools.js.map +1 -1
  191. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  192. package/dist/tools/builtins/wait-for-job.js +5 -0
  193. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  194. package/dist/tools/builtins/web.d.ts.map +1 -1
  195. package/dist/tools/builtins/web.js +13 -2
  196. package/dist/tools/builtins/web.js.map +1 -1
  197. package/dist/tools/task/create.js +2 -2
  198. package/dist/tools/task/create.js.map +1 -1
  199. package/dist/tools/task/update.js +1 -1
  200. package/dist/tools/task/update.js.map +1 -1
  201. package/dist/types/provider/chat.d.ts +8 -0
  202. package/dist/types/provider/chat.d.ts.map +1 -1
  203. package/dist/types/provider/interface.d.ts +10 -0
  204. package/dist/types/provider/interface.d.ts.map +1 -1
  205. package/dist/types/provider/model.d.ts +6 -0
  206. package/dist/types/provider/model.d.ts.map +1 -1
  207. package/dist/types/provider/stream.d.ts +2 -0
  208. package/dist/types/provider/stream.d.ts.map +1 -1
  209. package/dist/types/tool/presentation.d.ts +11 -0
  210. package/dist/types/tool/presentation.d.ts.map +1 -1
  211. package/dist/utils/node-on-path.d.ts +27 -0
  212. package/dist/utils/node-on-path.d.ts.map +1 -0
  213. package/dist/utils/node-on-path.js +70 -0
  214. package/dist/utils/node-on-path.js.map +1 -0
  215. package/package.json +1 -1
  216. package/src/bridge/acp/server.ts +25 -0
  217. package/src/compaction/context-window.ts +18 -0
  218. package/src/compaction/loaded-skills.ts +42 -1
  219. package/src/compaction/manager.ts +28 -0
  220. package/src/compaction/manual.ts +9 -1
  221. package/src/compaction/model-summary.ts +2 -2
  222. package/src/compaction/restore.ts +69 -0
  223. package/src/compaction/salience/working-set.ts +6 -2
  224. package/src/compaction/tool-result-editing.ts +8 -1
  225. package/src/compaction/types.ts +2 -0
  226. package/src/compaction/wire.ts +4 -0
  227. package/src/manager/session/turn-recorder.ts +24 -1
  228. package/src/network/join.ts +17 -0
  229. package/src/network/service.ts +185 -12
  230. package/src/network/store.ts +28 -1
  231. package/src/network/transport.ts +1 -1
  232. package/src/network/wire.ts +13 -1
  233. package/src/prompt/coding-agent-doctrine.ts +7 -2
  234. package/src/provider/fallback.ts +6 -0
  235. package/src/provider/idle-timeout.ts +6 -0
  236. package/src/provider/instrumentation.ts +12 -0
  237. package/src/provider/model-window-suffix.ts +1 -0
  238. package/src/provider/retry.ts +6 -0
  239. package/src/public-runtime.ts +1 -0
  240. package/src/public-tools.ts +9 -0
  241. package/src/public-types.ts +1 -0
  242. package/src/registry/tool/presentation.ts +14 -4
  243. package/src/runtime/jobs/registry.ts +2 -1
  244. package/src/runtime/query/auto-review/classifier.ts +19 -3
  245. package/src/runtime/query/auto-review/failure.ts +50 -0
  246. package/src/runtime/query/auto-review/index.ts +1 -0
  247. package/src/runtime/query/file-evidence-replay.ts +6 -5
  248. package/src/runtime/query/index.ts +19 -0
  249. package/src/runtime/query/iteration/index.ts +2 -0
  250. package/src/runtime/query/iteration/phases/compaction.ts +25 -2
  251. package/src/runtime/query/iteration/phases/context.ts +4 -0
  252. package/src/runtime/query/iteration/phases/per-call-review.ts +24 -7
  253. package/src/runtime/query/iteration/step-shaping.ts +4 -0
  254. package/src/runtime/query/prepare-turn.ts +20 -2
  255. package/src/runtime/query/review-policy.ts +24 -4
  256. package/src/runtime/query/turn/outcome-ledger.ts +45 -1
  257. package/src/sandbox/provider/local.ts +3 -1
  258. package/src/tools/admit-facts.ts +18 -0
  259. package/src/tools/builtins/bash.ts +5 -2
  260. package/src/tools/builtins/browser.ts +2 -2
  261. package/src/tools/builtins/computer-use.ts +123 -4
  262. package/src/tools/builtins/content-fingerprint.ts +2 -1
  263. package/src/tools/builtins/edit-apply.ts +124 -24
  264. package/src/tools/builtins/edit-match.ts +200 -0
  265. package/src/tools/builtins/edit.ts +16 -7
  266. package/src/tools/builtins/exit-semantics.ts +23 -0
  267. package/src/tools/builtins/index.ts +2 -0
  268. package/src/tools/builtins/present-file.ts +127 -0
  269. package/src/tools/builtins/read-file.ts +1 -1
  270. package/src/tools/builtins/read-render.ts +18 -3
  271. package/src/tools/builtins/search-tools.ts +36 -2
  272. package/src/tools/builtins/wait-for-job.ts +5 -0
  273. package/src/tools/builtins/web.ts +15 -2
  274. package/src/tools/task/create.ts +2 -2
  275. package/src/tools/task/update.ts +1 -1
  276. package/src/types/provider/chat.ts +9 -0
  277. package/src/types/provider/interface.ts +11 -0
  278. package/src/types/provider/model.ts +6 -0
  279. package/src/types/provider/stream.ts +2 -0
  280. package/src/types/tool/presentation.ts +12 -0
  281. package/src/utils/node-on-path.ts +81 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-on-path.js","sourceRoot":"","sources":["../../src/utils/node-on-path.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/sdk",
3
- "version": "68.0.0",
3
+ "version": "69.0.0",
4
4
  "description": "Open-source AI kernel for TypeScript: runs an agent the way an operating system runs a process, with an identity and a budget, scheduled tool calls and checkpointed turns.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "engines": {
@@ -319,6 +319,31 @@ export class ACPServer {
319
319
  )
320
320
  }
321
321
 
322
+ /**
323
+ * Whether the client named `capability` when it initialized. False before `initialize`. A host
324
+ * that offers something only to a client that asked for it (an extension request it sends the
325
+ * client) reads this before relying on it.
326
+ */
327
+ clientOffers(capability: string): boolean {
328
+ return this.initialized && this.clientCapabilities.includes(capability)
329
+ }
330
+
331
+ /**
332
+ * Ask the client something over the connection and wait for its answer. For a host extension that
333
+ * needs the client to do work (a request under `namzu/`), after `clientOffers` said it may.
334
+ * Rejects with the client's error message, and when the connection closes before it answers.
335
+ */
336
+ askClient<T = unknown>(
337
+ method: string,
338
+ params: Record<string, unknown>,
339
+ signal?: AbortSignal,
340
+ ): Promise<T> {
341
+ if (this.stopped) return Promise.reject(new Error('The ACP server is stopped.'))
342
+ if (!/^namzu\/[a-z][a-z0-9_/-]*$/.test(method))
343
+ return Promise.reject(new Error(`Invalid ACP client request name: ${method}`))
344
+ return this.request<T>(method, params, signal)
345
+ }
346
+
322
347
  async start(): Promise<void> {
323
348
  if (this.stopped) throw new Error('An ACP server cannot be restarted after it has stopped.')
324
349
  this.options.transport.onMessage((message) => {
@@ -253,6 +253,24 @@ function lookupBareContextWindow(model: string | undefined): number | undefined
253
253
  return undefined
254
254
  }
255
255
 
256
+ /** The share of the window a provider's own compaction limit is held to. */
257
+ export const PROVIDER_COMPACT_LIMIT_MAX_FRACTION = 0.9
258
+
259
+ /**
260
+ * The trigger fraction a provider's own compaction limit asks for: `min(limit, 90% of the
261
+ * window)` as a share of the window. `undefined` when the provider stated no usable limit or
262
+ * the window is unknown, which leaves Namzu's derived rule to answer.
263
+ */
264
+ export function providerTriggerFraction(
265
+ limitTokens: number | undefined,
266
+ windowTokens: number,
267
+ ): number | undefined {
268
+ if (limitTokens === undefined || !Number.isFinite(limitTokens) || limitTokens <= 0)
269
+ return undefined
270
+ if (!(windowTokens > 0)) return undefined
271
+ return Math.min(limitTokens, windowTokens * PROVIDER_COMPACT_LIMIT_MAX_FRACTION) / windowTokens
272
+ }
273
+
256
274
  /** Output room the trigger keeps free: the model's output cap, at most this many tokens. */
257
275
  export const TRIGGER_OUTPUT_RESERVE_CAP_TOKENS = 20_000
258
276
  /** Extra headroom below the reserved window before a summary is due. */
@@ -195,6 +195,40 @@ function cutNote(name: string): string {
195
195
  return `… [cut here to save space; call the skill tool with name "${name}" to read all of it]`
196
196
  }
197
197
 
198
+ /**
199
+ * A skill's instructions without its worked examples. A section headed
200
+ * `Example...` (a sample report, a sample call) shows what a result looks like;
201
+ * the steps around it say what to do, and only those need to survive a pass.
202
+ * Returns the text unchanged when there is no such section.
203
+ */
204
+ export function withoutExampleSections(body: string): { text: string; dropped: boolean } {
205
+ const lines = body.split('\n')
206
+ const kept: string[] = []
207
+ let skipping: number | undefined
208
+ let dropped = false
209
+ // A `# comment` inside a code fence is not a heading.
210
+ let fence: string | undefined
211
+ for (const line of lines) {
212
+ const fenceMark = /^\s*(`{3,}|~{3,})/.exec(line)
213
+ if (fenceMark) {
214
+ const mark = (fenceMark[1] as string)[0] as string
215
+ if (fence === undefined) fence = mark
216
+ else if (fence === mark) fence = undefined
217
+ }
218
+ const heading = fence === undefined && !fenceMark ? /^(#{1,6})\s+(.*)$/.exec(line) : null
219
+ if (heading) {
220
+ const level = (heading[1] as string).length
221
+ if (skipping !== undefined && level <= skipping) skipping = undefined
222
+ if (skipping === undefined && /^examples?\b/i.test((heading[2] as string).trim())) {
223
+ skipping = level
224
+ dropped = true
225
+ }
226
+ }
227
+ if (skipping === undefined) kept.push(line)
228
+ }
229
+ return dropped ? { text: kept.join('\n').trimEnd(), dropped } : { text: body, dropped }
230
+ }
231
+
198
232
  /**
199
233
  * Render skills (oldest first in, newest chosen first) inside the caps: a
200
234
  * count, a share of the window and a total of tokens, and a cap for each
@@ -214,7 +248,14 @@ export function renderLoadedSkills(
214
248
  const carried: string[] = []
215
249
  const cut: string[] = []
216
250
  const left: string[] = []
217
- for (const skill of [...skills].reverse()) {
251
+ for (const full of [...skills].reverse()) {
252
+ const trimmed = withoutExampleSections(full.body)
253
+ const skill = trimmed.dropped
254
+ ? {
255
+ name: full.name,
256
+ body: `${trimmed.text}\n\n[Example sections left out; call the skill tool with name "${full.name}" to read all of it]`,
257
+ }
258
+ : full
218
259
  if (carried.length >= CARRY_MAX_SKILLS || budget < MIN_CARRY_TOKENS) {
219
260
  left.push(skill.name)
220
261
  continue
@@ -15,6 +15,10 @@ export const MAX_RESTORABLE_SKILLS = 8
15
15
  export const MAX_RESTORABLE_FILES = 12
16
16
  /** Characters of one skill or file kept for restoring (a little over the 5,000 tokens a restore shows, so the cut is visible). */
17
17
  export const MAX_RESTORABLE_CHARS = 24_000
18
+ /** Working commands kept for a compaction to put back. */
19
+ export const MAX_WORKING_COMMANDS = 8
20
+ /** Characters kept of one working command. */
21
+ export const MAX_WORKING_COMMAND_CHARS = 240
18
22
 
19
23
  /** Pins kept at most; the oldest is dropped past this, and the drop is counted. */
20
24
  export const MAX_PINS = 40
@@ -158,6 +162,30 @@ export class WorkingStateManager {
158
162
  while (restorable.files.length > MAX_RESTORABLE_FILES) restorable.files.shift()
159
163
  }
160
164
 
165
+ /** Remember a command that worked (a test run, a build, a runtime call) so a compaction keeps its form. */
166
+ recordWorkingCommand(command: string): void {
167
+ const key = command.replace(/\s+/g, ' ').trim().slice(0, MAX_WORKING_COMMAND_CHARS)
168
+ if (key.length === 0) return
169
+ const restorable = this.restorableState()
170
+ const commands = restorable.commands ?? []
171
+ const index = commands.indexOf(key)
172
+ if (index >= 0) commands.splice(index, 1)
173
+ commands.push(key)
174
+ while (commands.length > MAX_WORKING_COMMANDS) commands.shift()
175
+ restorable.commands = commands
176
+ }
177
+
178
+ /** Take in commands an earlier summary carried; they count as older than any recorded here. */
179
+ adoptWorkingCommands(commands: readonly string[]): void {
180
+ const held = this.state.restorable?.commands ?? []
181
+ const missing = commands.filter((command) => command.length > 0 && !held.includes(command))
182
+ if (missing.length === 0) return
183
+ const restorable = this.restorableState()
184
+ const next = [...missing, ...held]
185
+ while (next.length > MAX_WORKING_COMMANDS) next.shift()
186
+ restorable.commands = next
187
+ }
188
+
161
189
  /** A file that was changed after it was read no longer has a body worth restoring. */
162
190
  forgetFileText(path: string): void {
163
191
  const files = this.state.restorable?.files
@@ -30,7 +30,7 @@ import {
30
30
  summarizeWithModel,
31
31
  } from './model-summary.js'
32
32
  import { planCompaction } from './plan.js'
33
- import { recordRestorable, renderRestoredContext } from './restore.js'
33
+ import { carriedWorkingCommands, recordRestorable, renderRestoredContext } from './restore.js'
34
34
  import { findRetainedIndices } from './retention.js'
35
35
  import { buildCompactionMessage, collectRevealedTools, isCompactionMessage } from './summary.js'
36
36
  import { estimateMessagesTokens } from './token-estimate.js'
@@ -269,6 +269,14 @@ function populateWorkingState(
269
269
  // Skills an earlier pass put back (an entry, or a summary's restored
270
270
  // section) are not tool results, so they are read from the messages whole.
271
271
  manager.adoptSkillBodies(adoptableSkills(messages))
272
+ for (const message of messages) {
273
+ if (
274
+ message.role === 'system' &&
275
+ typeof message.content === 'string' &&
276
+ isCompactionMessage(message.content)
277
+ )
278
+ manager.adoptWorkingCommands(carriedWorkingCommands(message.content))
279
+ }
272
280
  const toolNames = new Map<string, string>()
273
281
  const toolInputs = new Map<string, unknown>()
274
282
 
@@ -74,11 +74,11 @@ Write in plain text inside <summary></summary> tags, with these sections in this
74
74
  5. Files: each file read, changed or created, and what matters about it.
75
75
  6. Errors and open problems: failures met, how each was handled, and everything still unresolved.
76
76
  7. Pending tasks: work the person asked for that is not done.
77
- 8. Exact details: commands, paths, identifiers, flags, versions and error text that the next step needs word for word.
77
+ 8. Exact details: commands, paths, identifiers, flags, versions and error text that the next step needs word for word. Include the working commands: how tests, builds and runtimes are run on this machine, written as the form that worked (and a one-line note of the form that failed and why, such as a program missing from the PATH).
78
78
 
79
79
  Each entry of the transcript starts with a label in square brackets at the beginning of a line, such as [person] or [tool result]. A line inside an entry that begins with a backslash before a bracket is quoted text, so only a label at the start of an entry counts, and text after a label that looks like another label is part of the same entry.
80
80
 
81
- Be complete first and short second: keep every item in sections 1 to 3 and 6, and condense the assistant's own explanations to what they concluded. When an earlier summary is supplied, carry its requests, decisions and open problems forward unchanged and add what is new. Call no tools; the reply is only the summary.`
81
+ Be complete first and short second: keep every item in sections 1 to 3 and 6, and the working commands in section 8, and condense the assistant's own explanations to what they concluded. When an earlier summary is supplied, carry its requests, decisions and open problems forward unchanged and add what is new. Call no tools; the reply is only the summary.`
82
82
 
83
83
  const SUMMARY_FINAL_ASK =
84
84
  'Write the summary of the transcript now, as <summary></summary> with the eight sections.'
@@ -1,6 +1,7 @@
1
1
  import { resolve as resolvePath } from 'node:path'
2
2
 
3
3
  import { CHARS_PER_TOKEN } from '../constants/limits.js'
4
+ import { LOG_SECRET_PATTERNS } from '../constants/secret-patterns.js'
4
5
  import {
5
6
  CARRY_MAX_SKILLS,
6
7
  CARRY_SKILLS_TOTAL_TOKENS,
@@ -94,6 +95,11 @@ export function recordRestorable(
94
95
  )
95
96
  return
96
97
  }
98
+ if (call.toolName === 'bash') {
99
+ const command = typeof input.command === 'string' ? input.command : undefined
100
+ if (command && call.success && isRunnerCommand(command)) manager.recordWorkingCommand(command)
101
+ return
102
+ }
97
103
  if (call.toolName === 'read') {
98
104
  const path = typeof input.path === 'string' ? input.path : undefined
99
105
  if (!path || !call.success || call.unchanged) return
@@ -107,6 +113,62 @@ export function recordRestorable(
107
113
  }
108
114
  }
109
115
 
116
+ /** Heading of the section that carries the commands that worked. */
117
+ export const WORKING_COMMANDS_HEADING = '### Working commands'
118
+
119
+ /** The first word of a command segment says how code is run, built or tested here, or how a path is converted for a Windows program. */
120
+ const RUNNER_WORD =
121
+ /^(?:node(?:\.exe)?|npm|npx|pnpm|yarn|bun|deno|python3?|pytest|cargo|rustc|go|make|dotnet|mvn|gradle|wslpath|powershell\.exe|cmd\.exe)$/
122
+
123
+ /** Shapes that put a credential on a command line, beyond the known token prefixes. */
124
+ const COMMAND_SECRET_SHAPES: readonly RegExp[] = [
125
+ // An inline VAR=value assignment at the start of a segment.
126
+ /(?:^|[;&|(]\s*)[A-Za-z_][A-Za-z0-9_]*=/,
127
+ // Header, auth and credential flags.
128
+ /(?:^|\s)(?:-H|--header|-u|--user|--proxy-user)(?:\s|=|$)/,
129
+ /(?:^|\s)--?(?:[\w-]*(?:token|password|passwd|secret|api-?key|auth|credential)[\w-]*)(?:\s|=|$)/i,
130
+ /\b(?:authorization|bearer|x-api-key)\b/i,
131
+ // A URL with userinfo, or a token in its query string.
132
+ /:\/\/[^\s/:@]+:[^\s/@]+@/,
133
+ /[?&](?:[\w-]*(?:token|key|secret|password|sig|signature)[\w-]*)=/i,
134
+ ]
135
+
136
+ /** True when a command line may carry a credential and so must not be kept. */
137
+ export function commandMayCarrySecret(command: string): boolean {
138
+ if (COMMAND_SECRET_SHAPES.some((shape) => shape.test(command))) return true
139
+ return LOG_SECRET_PATTERNS.some(([, pattern]) => {
140
+ pattern.lastIndex = 0
141
+ const hit = pattern.test(command)
142
+ pattern.lastIndex = 0
143
+ return hit
144
+ })
145
+ }
146
+
147
+ /** True for a shell command worth keeping the form of, and safe to carry in a summary. */
148
+ export function isRunnerCommand(command: string): boolean {
149
+ if (commandMayCarrySecret(command)) return false
150
+ return command.split(/&&|\|\||[;|\n]/).some((segment) => {
151
+ const first = segment.trim().replace(/^\(+/, '').split(/\s+/)[0] ?? ''
152
+ return RUNNER_WORD.test(first)
153
+ })
154
+ }
155
+
156
+ /** The commands an earlier summary carried, read back from its restored section. */
157
+ export function carriedWorkingCommands(summary: string): string[] {
158
+ const start = summary.indexOf(WORKING_COMMANDS_HEADING)
159
+ if (start < 0) return []
160
+ const commands: string[] = []
161
+ for (const line of summary
162
+ .slice(start + WORKING_COMMANDS_HEADING.length)
163
+ .split('\n')
164
+ .slice(1)) {
165
+ const match = /^- `(.+)`$/.exec(line)
166
+ if (match?.[1]) commands.push(match[1])
167
+ else if (line.startsWith('#') || (commands.length > 0 && line.trim() === '')) break
168
+ }
169
+ return commands
170
+ }
171
+
110
172
  function fit(text: string, tokens: number): string {
111
173
  const room = tokens * CHARS_PER_TOKEN
112
174
  return text.length <= room
@@ -160,6 +222,13 @@ export function renderRestoredContext(
160
222
  sections.push(`### File: ${file.path}\n\n${text}`)
161
223
  }
162
224
 
225
+ const commands = state.restorable?.commands ?? []
226
+ if (commands.length > 0) {
227
+ sections.push(
228
+ `${WORKING_COMMANDS_HEADING}\n\nThese commands ran successfully in this conversation. Run work the same way instead of searching the machine again.\n\n${commands.map((command) => `- \`${command}\``).join('\n')}`,
229
+ )
230
+ }
231
+
163
232
  const note = options.hostNote?.trim()
164
233
  if (note) sections.push(note)
165
234
  if (sections.length === 0) return undefined
@@ -22,7 +22,11 @@
22
22
  import { CHARS_PER_TOKEN } from '../../constants/limits.js'
23
23
  import type { AssistantMessage, Message, ToolMessage } from '../../types/message/index.js'
24
24
  import { estimateMessageTokens } from '../token-estimate.js'
25
- import { clearToolResult, isClearedToolResult } from '../tool-result-editing.js'
25
+ import {
26
+ ALWAYS_KEPT_TOOL_RESULTS,
27
+ clearToolResult,
28
+ isClearedToolResult,
29
+ } from '../tool-result-editing.js'
26
30
  import type { ScoredMessage } from './score.js'
27
31
 
28
32
  export interface WorkingSetAction {
@@ -95,7 +99,7 @@ function evictionRules(
95
99
  return {
96
100
  minTool: options.minToolResultChars ?? 1_000,
97
101
  minNarration: options.minNarrationChars ?? 240,
98
- preserve: new Set(options.preserveTools ?? []),
102
+ preserve: new Set([...ALWAYS_KEPT_TOOL_RESULTS, ...(options.preserveTools ?? [])]),
99
103
  toolNameByCallId,
100
104
  }
101
105
  }
@@ -47,6 +47,13 @@ export interface ToolResultEditConfig {
47
47
  export const DEFAULT_KEEP_RECENT_TOOL_RESULTS = 3
48
48
  export const DEFAULT_MIN_CHARS_TO_CLEAR = 1_000
49
49
 
50
+ /**
51
+ * Tools whose result is never cleared, whatever a host's own list says. A
52
+ * `search_tools` result is what tells the model which tools it has loaded;
53
+ * with it gone the model searches again for a tool it already holds.
54
+ */
55
+ export const ALWAYS_KEPT_TOOL_RESULTS: readonly string[] = ['search_tools']
56
+
50
57
  /** Marks a cleared result, and is how a second pass recognizes its own work. */
51
58
  const CLEARED_PREFIX = '[tool output cleared]'
52
59
 
@@ -157,7 +164,7 @@ export function clearStaleToolResults(
157
164
  ): ToolResultEditOutcome {
158
165
  const keepRecent = Math.max(0, config.keepRecentToolResults ?? DEFAULT_KEEP_RECENT_TOOL_RESULTS)
159
166
  const minChars = Math.max(0, config.minCharsToClear ?? DEFAULT_MIN_CHARS_TO_CLEAR)
160
- const preserve = new Set(config.preserveTools ?? [])
167
+ const preserve = new Set([...ALWAYS_KEPT_TOOL_RESULTS, ...(config.preserveTools ?? [])])
161
168
 
162
169
  // Which tool call produced which result, so a preserve-list can be
163
170
  // written in terms of TOOL NAMES — the only handle a host actually has.
@@ -53,6 +53,8 @@ export interface RestorableFile {
53
53
  export interface RestorableState {
54
54
  skills: RestorableSkill[]
55
55
  files: RestorableFile[]
56
+ /** Shell commands that ran successfully and say how work is run here, oldest first. */
57
+ commands?: string[]
56
58
  }
57
59
 
58
60
  export interface PinSlot {
@@ -73,6 +73,7 @@ export function snapshotWorkingState(manager: WorkingStateManager): WorkingState
73
73
  restorable: {
74
74
  skills: state.restorable.skills.map((skill) => ({ ...skill })),
75
75
  files: state.restorable.files.map((file) => ({ ...file })),
76
+ ...(state.restorable.commands ? { commands: [...state.restorable.commands] } : {}),
76
77
  },
77
78
  }
78
79
  : {}),
@@ -111,6 +112,9 @@ export function restoreWorkingState(
111
112
  restorable: {
112
113
  skills: snapshot.restorable.skills.map((skill) => ({ ...skill })),
113
114
  files: snapshot.restorable.files.map((file) => ({ ...file })),
115
+ ...(snapshot.restorable.commands
116
+ ? { commands: [...snapshot.restorable.commands] }
117
+ : {}),
114
118
  },
115
119
  }
116
120
  : {}),
@@ -266,6 +266,8 @@ export class TurnRecorder {
266
266
  #turnSystemPrompt: string | undefined
267
267
  /** Set by {@link resume}: the next reconciliation re-bases the fold on the restored context. */
268
268
  #rebasePending = false
269
+ /** The summary the log already folds to, read when the recorder opened. */
270
+ #foldSummary: readonly Message[] = []
269
271
  /**
270
272
  * The message ids of the log's fold when the turn resumed, oldest first;
271
273
  * `undefined` when the fold holds a message with no record of its own (a
@@ -730,7 +732,10 @@ export class TurnRecorder {
730
732
  this.#turn.forkedFrom = options.session.forkedFrom
731
733
  }
732
734
  this.#phase = 'open'
733
- return await readFoldedHistory(this.log)
735
+ const history = await readFoldedHistory(this.log)
736
+ // What the fold already holds as its summary: the entries with no id.
737
+ this.#foldSummary = history.filter((entry) => !entry.messageId).map((entry) => entry.message)
738
+ return history
734
739
  } catch (error) {
735
740
  await this.release()
736
741
  throw error
@@ -1210,9 +1215,27 @@ export class TurnRecorder {
1210
1215
  this.#view.push({ message })
1211
1216
  return
1212
1217
  }
1218
+ if (options.restored && this.#phase === 'open' && this.#isHeldSummary(message)) {
1219
+ // The log's fold already ends this summary in its own record. Writing it
1220
+ // again at the turn's start would copy a large text for nothing.
1221
+ this.#view.push({ message })
1222
+ return
1223
+ }
1213
1224
  this.#syncMessages()
1214
1225
  }
1215
1226
 
1227
+ /**
1228
+ * A restored message with no id that is the summary the log already folds to,
1229
+ * pushed before any recorded message (the place the fold puts it).
1230
+ */
1231
+ #isHeldSummary(message: Message): boolean {
1232
+ if (this.#foldSummary.length === 0) return false
1233
+ if (this.#view.some((entry) => !entry.transient && entry.id !== undefined)) return false
1234
+ return this.#foldSummary.some(
1235
+ (held) => held.role === message.role && isDeepStrictEqual(held.content, message.content),
1236
+ )
1237
+ }
1238
+
1216
1239
  /** Replace the context without replacing the turn; recorded as one `compaction`. */
1217
1240
  replaceMessages(messages: readonly Message[]): void {
1218
1241
  this.#turn.messages.splice(0, this.#turn.messages.length, ...messages)
@@ -39,7 +39,13 @@ export function formatJoinCode(code: string): string {
39
39
 
40
40
  export const JOIN_EXPIRY_MS = 10 * 60 * 1000
41
41
  export const MAX_PENDING_JOINS = 8
42
+ /** A request whose connection is gone is kept this long for another terminal of the machine to take over. */
43
+ export const JOIN_ORPHAN_MS = 60 * 1000
42
44
  export const JOIN_ADDRESS_WINDOW_MS = 60 * 1000
45
+ /** After a person denied the ask, this machine does not ask that network again on its own for this long. */
46
+ export const JOIN_BACKOFF_DENIED_MS = 60 * 60 * 1000
47
+ /** After the ask expired unanswered or was refused: shorter, because nobody said no. */
48
+ export const JOIN_BACKOFF_OTHER_MS = 10 * 60 * 1000
43
49
 
44
50
  export interface PendingJoin {
45
51
  readonly requestId: string
@@ -71,6 +77,12 @@ export class JoinTable {
71
77
  private readonly lastByAddress = new Map<string, number>()
72
78
  constructor(private readonly options: JoinTableOptions) {}
73
79
 
80
+ /** Whether this address asked less than a minute ago. */
81
+ tooSoon(sourceAddr: string): boolean {
82
+ const last = this.lastByAddress.get(sourceAddr)
83
+ return last !== undefined && this.options.clock.now() - last < JOIN_ADDRESS_WINDOW_MS
84
+ }
85
+
74
86
  /** A request that arrived on this machine. Refused when the address asked too recently or the table is full. */
75
87
  addLocal(
76
88
  input: Omit<PendingJoin, 'local' | 'expiresAt' | 'createdAt'>,
@@ -121,6 +133,11 @@ export class JoinTable {
121
133
  return n
122
134
  }
123
135
 
136
+ /** The request waiting from this machine, if any: a machine has at most one. */
137
+ findByJoiner(joinerMachineId: string): PendingJoin | undefined {
138
+ return this.list().find((e) => e.joinerMachineId === joinerMachineId)
139
+ }
140
+
124
141
  get(requestId: string): PendingJoin | undefined {
125
142
  return this.entries.get(requestId)
126
143
  }