@namzu/sdk 59.0.0 → 60.1.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 (370) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +1 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  6. package/dist/bridge/a2a/mapper.js +16 -0
  7. package/dist/bridge/a2a/mapper.js.map +1 -1
  8. package/dist/bridge/acp/update.d.ts.map +1 -1
  9. package/dist/bridge/acp/update.js +1 -0
  10. package/dist/bridge/acp/update.js.map +1 -1
  11. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  12. package/dist/bridge/sse/mapper.js +12 -0
  13. package/dist/bridge/sse/mapper.js.map +1 -1
  14. package/dist/compaction/context-window.d.ts +53 -0
  15. package/dist/compaction/context-window.d.ts.map +1 -1
  16. package/dist/compaction/context-window.js +141 -2
  17. package/dist/compaction/context-window.js.map +1 -1
  18. package/dist/constants/continuation.d.ts +9 -0
  19. package/dist/constants/continuation.d.ts.map +1 -1
  20. package/dist/constants/continuation.js +9 -0
  21. package/dist/constants/continuation.js.map +1 -1
  22. package/dist/contracts/session/api.d.ts +7 -1
  23. package/dist/contracts/session/api.d.ts.map +1 -1
  24. package/dist/execution/workflow/index.d.ts +3 -1
  25. package/dist/execution/workflow/index.d.ts.map +1 -1
  26. package/dist/execution/workflow/index.js +2 -1
  27. package/dist/execution/workflow/index.js.map +1 -1
  28. package/dist/execution/workflow/journal.d.ts +24 -4
  29. package/dist/execution/workflow/journal.d.ts.map +1 -1
  30. package/dist/execution/workflow/journal.js +131 -9
  31. package/dist/execution/workflow/journal.js.map +1 -1
  32. package/dist/execution/workflow/prelude.d.ts +2 -0
  33. package/dist/execution/workflow/prelude.d.ts.map +1 -1
  34. package/dist/execution/workflow/prelude.js +49 -8
  35. package/dist/execution/workflow/prelude.js.map +1 -1
  36. package/dist/execution/workflow/resume.d.ts +59 -0
  37. package/dist/execution/workflow/resume.d.ts.map +1 -0
  38. package/dist/execution/workflow/resume.js +273 -0
  39. package/dist/execution/workflow/resume.js.map +1 -0
  40. package/dist/execution/workflow/runtime.d.ts.map +1 -1
  41. package/dist/execution/workflow/runtime.js +112 -8
  42. package/dist/execution/workflow/runtime.js.map +1 -1
  43. package/dist/execution/workflow/types.d.ts +105 -1
  44. package/dist/execution/workflow/types.d.ts.map +1 -1
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +4 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  50. package/dist/manager/session/turn-recorder.js +1 -0
  51. package/dist/manager/session/turn-recorder.js.map +1 -1
  52. package/dist/plugin/compat.d.ts +24 -0
  53. package/dist/plugin/compat.d.ts.map +1 -0
  54. package/dist/plugin/compat.js +149 -0
  55. package/dist/plugin/compat.js.map +1 -0
  56. package/dist/plugin/loader.d.ts +2 -1
  57. package/dist/plugin/loader.d.ts.map +1 -1
  58. package/dist/plugin/loader.js +6 -0
  59. package/dist/plugin/loader.js.map +1 -1
  60. package/dist/pricing/index.d.ts.map +1 -1
  61. package/dist/pricing/index.js +2 -1
  62. package/dist/pricing/index.js.map +1 -1
  63. package/dist/process/kill-tree.d.ts +44 -0
  64. package/dist/process/kill-tree.d.ts.map +1 -1
  65. package/dist/process/kill-tree.js +102 -4
  66. package/dist/process/kill-tree.js.map +1 -1
  67. package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
  68. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  69. package/dist/prompt/coding-agent-doctrine.js +9 -1
  70. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  71. package/dist/provider/collect-chat-completion.d.ts.map +1 -1
  72. package/dist/provider/collect-chat-completion.js +4 -0
  73. package/dist/provider/collect-chat-completion.js.map +1 -1
  74. package/dist/provider/fallback.d.ts.map +1 -1
  75. package/dist/provider/fallback.js +11 -0
  76. package/dist/provider/fallback.js.map +1 -1
  77. package/dist/provider/idle-timeout.d.ts.map +1 -1
  78. package/dist/provider/idle-timeout.js +5 -0
  79. package/dist/provider/idle-timeout.js.map +1 -1
  80. package/dist/provider/mock.d.ts +2 -0
  81. package/dist/provider/mock.d.ts.map +1 -1
  82. package/dist/provider/mock.js +16 -8
  83. package/dist/provider/mock.js.map +1 -1
  84. package/dist/provider/model-window-suffix.d.ts +18 -0
  85. package/dist/provider/model-window-suffix.d.ts.map +1 -0
  86. package/dist/provider/model-window-suffix.js +78 -0
  87. package/dist/provider/model-window-suffix.js.map +1 -0
  88. package/dist/provider/retry.d.ts.map +1 -1
  89. package/dist/provider/retry.js +5 -0
  90. package/dist/provider/retry.js.map +1 -1
  91. package/dist/public-runtime.d.ts +5 -3
  92. package/dist/public-runtime.d.ts.map +1 -1
  93. package/dist/public-runtime.js +5 -4
  94. package/dist/public-runtime.js.map +1 -1
  95. package/dist/public-types.d.ts +1 -0
  96. package/dist/public-types.d.ts.map +1 -1
  97. package/dist/registry/command/kernel-commands.d.ts +1 -4
  98. package/dist/registry/command/kernel-commands.d.ts.map +1 -1
  99. package/dist/registry/command/kernel-commands.js +0 -28
  100. package/dist/registry/command/kernel-commands.js.map +1 -1
  101. package/dist/runtime/jobs/awaited-jobs.d.ts +6 -0
  102. package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
  103. package/dist/runtime/jobs/awaited-jobs.js +11 -0
  104. package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
  105. package/dist/runtime/jobs/host-exit-finalizer.d.ts +20 -0
  106. package/dist/runtime/jobs/host-exit-finalizer.d.ts.map +1 -0
  107. package/dist/runtime/jobs/host-exit-finalizer.js +57 -0
  108. package/dist/runtime/jobs/host-exit-finalizer.js.map +1 -0
  109. package/dist/runtime/jobs/liveness.d.ts +67 -0
  110. package/dist/runtime/jobs/liveness.d.ts.map +1 -0
  111. package/dist/runtime/jobs/liveness.js +94 -0
  112. package/dist/runtime/jobs/liveness.js.map +1 -0
  113. package/dist/runtime/jobs/registry.d.ts +21 -0
  114. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  115. package/dist/runtime/jobs/registry.js +104 -2
  116. package/dist/runtime/jobs/registry.js.map +1 -1
  117. package/dist/runtime/jobs/wake-budget.d.ts +35 -0
  118. package/dist/runtime/jobs/wake-budget.d.ts.map +1 -0
  119. package/dist/runtime/jobs/wake-budget.js +48 -0
  120. package/dist/runtime/jobs/wake-budget.js.map +1 -0
  121. package/dist/runtime/query/detached-calls.d.ts +65 -0
  122. package/dist/runtime/query/detached-calls.d.ts.map +1 -0
  123. package/dist/runtime/query/detached-calls.js +116 -0
  124. package/dist/runtime/query/detached-calls.js.map +1 -0
  125. package/dist/runtime/query/executor.d.ts +4 -1
  126. package/dist/runtime/query/executor.d.ts.map +1 -1
  127. package/dist/runtime/query/executor.js +90 -6
  128. package/dist/runtime/query/executor.js.map +1 -1
  129. package/dist/runtime/query/index.d.ts +34 -0
  130. package/dist/runtime/query/index.d.ts.map +1 -1
  131. package/dist/runtime/query/index.js +32 -5
  132. package/dist/runtime/query/index.js.map +1 -1
  133. package/dist/runtime/query/iteration/effort-clamp.d.ts +13 -0
  134. package/dist/runtime/query/iteration/effort-clamp.d.ts.map +1 -0
  135. package/dist/runtime/query/iteration/effort-clamp.js +42 -0
  136. package/dist/runtime/query/iteration/effort-clamp.js.map +1 -0
  137. package/dist/runtime/query/iteration/index.d.ts +34 -0
  138. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  139. package/dist/runtime/query/iteration/index.js +199 -6
  140. package/dist/runtime/query/iteration/index.js.map +1 -1
  141. package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
  142. package/dist/runtime/query/iteration/outstanding-work.js +11 -3
  143. package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
  144. package/dist/runtime/query/iteration/phases/context.d.ts +9 -0
  145. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  146. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  147. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  148. package/dist/runtime/query/iteration/phases/tool-review.js +63 -1
  149. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  150. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  151. package/dist/runtime/query/iteration/stream-turn.js +6 -0
  152. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  153. package/dist/runtime/query/session-storage.d.ts.map +1 -1
  154. package/dist/runtime/query/session-storage.js +8 -3
  155. package/dist/runtime/query/session-storage.js.map +1 -1
  156. package/dist/runtime/query/steering.d.ts +29 -3
  157. package/dist/runtime/query/steering.d.ts.map +1 -1
  158. package/dist/runtime/query/steering.js +58 -3
  159. package/dist/runtime/query/steering.js.map +1 -1
  160. package/dist/runtime/query/tooling.d.ts +1 -0
  161. package/dist/runtime/query/tooling.d.ts.map +1 -1
  162. package/dist/runtime/query/tooling.js +1 -0
  163. package/dist/runtime/query/tooling.js.map +1 -1
  164. package/dist/runtime/system-events.d.ts +5 -0
  165. package/dist/runtime/system-events.d.ts.map +1 -1
  166. package/dist/runtime/system-events.js +7 -1
  167. package/dist/runtime/system-events.js.map +1 -1
  168. package/dist/sandbox/denial.d.ts +11 -0
  169. package/dist/sandbox/denial.d.ts.map +1 -0
  170. package/dist/sandbox/denial.js +61 -0
  171. package/dist/sandbox/denial.js.map +1 -0
  172. package/dist/sandbox/file-walk-program.d.ts.map +1 -1
  173. package/dist/sandbox/file-walk-program.js +31 -13
  174. package/dist/sandbox/file-walk-program.js.map +1 -1
  175. package/dist/sandbox/file-walk.d.ts +2 -0
  176. package/dist/sandbox/file-walk.d.ts.map +1 -1
  177. package/dist/sandbox/file-walk.js +64 -13
  178. package/dist/sandbox/file-walk.js.map +1 -1
  179. package/dist/sandbox/ignore-matcher.d.ts +30 -0
  180. package/dist/sandbox/ignore-matcher.d.ts.map +1 -0
  181. package/dist/sandbox/ignore-matcher.js +11 -0
  182. package/dist/sandbox/ignore-matcher.js.map +1 -0
  183. package/dist/sandbox/ignore-source.d.ts +26 -0
  184. package/dist/sandbox/ignore-source.d.ts.map +1 -0
  185. package/dist/sandbox/ignore-source.js +221 -0
  186. package/dist/sandbox/ignore-source.js.map +1 -0
  187. package/dist/sandbox/provider/local.d.ts.map +1 -1
  188. package/dist/sandbox/provider/local.js +11 -1
  189. package/dist/sandbox/provider/local.js.map +1 -1
  190. package/dist/scheduler/completion-inbox.d.ts.map +1 -1
  191. package/dist/scheduler/completion-inbox.js +1 -0
  192. package/dist/scheduler/completion-inbox.js.map +1 -1
  193. package/dist/session/log-hash.d.ts.map +1 -1
  194. package/dist/session/log-hash.js +18 -1
  195. package/dist/session/log-hash.js.map +1 -1
  196. package/dist/store/memory/disk.d.ts.map +1 -1
  197. package/dist/store/memory/disk.js +1 -1
  198. package/dist/store/memory/disk.js.map +1 -1
  199. package/dist/store/memory/markdown.d.ts.map +1 -1
  200. package/dist/store/memory/markdown.js +1 -1
  201. package/dist/store/memory/markdown.js.map +1 -1
  202. package/dist/store/memory/operation-lock.d.ts +20 -4
  203. package/dist/store/memory/operation-lock.d.ts.map +1 -1
  204. package/dist/store/memory/operation-lock.js +235 -58
  205. package/dist/store/memory/operation-lock.js.map +1 -1
  206. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  207. package/dist/store/session-index/sqlite.js +169 -16
  208. package/dist/store/session-index/sqlite.js.map +1 -1
  209. package/dist/tools/builtins/bash.d.ts.map +1 -1
  210. package/dist/tools/builtins/bash.js +10 -4
  211. package/dist/tools/builtins/bash.js.map +1 -1
  212. package/dist/tools/builtins/computer-use.d.ts +35 -0
  213. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  214. package/dist/tools/builtins/computer-use.js +512 -67
  215. package/dist/tools/builtins/computer-use.js.map +1 -1
  216. package/dist/tools/builtins/glob.d.ts +1 -0
  217. package/dist/tools/builtins/glob.d.ts.map +1 -1
  218. package/dist/tools/builtins/glob.js +65 -28
  219. package/dist/tools/builtins/glob.js.map +1 -1
  220. package/dist/tools/builtins/grep.d.ts +2 -0
  221. package/dist/tools/builtins/grep.d.ts.map +1 -1
  222. package/dist/tools/builtins/grep.js +94 -40
  223. package/dist/tools/builtins/grep.js.map +1 -1
  224. package/dist/tools/builtins/job.d.ts +1 -1
  225. package/dist/tools/builtins/job.d.ts.map +1 -1
  226. package/dist/tools/builtins/job.js +34 -7
  227. package/dist/tools/builtins/job.js.map +1 -1
  228. package/dist/tools/builtins/search-support.d.ts +44 -0
  229. package/dist/tools/builtins/search-support.d.ts.map +1 -0
  230. package/dist/tools/builtins/search-support.js +89 -0
  231. package/dist/tools/builtins/search-support.js.map +1 -0
  232. package/dist/tools/builtins/wait-for-job-bounds.d.ts +2 -0
  233. package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
  234. package/dist/tools/builtins/wait-for-job-bounds.js +3 -1
  235. package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
  236. package/dist/tools/builtins/wait-for-job.d.ts +1 -1
  237. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  238. package/dist/tools/builtins/wait-for-job.js +13 -2
  239. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  240. package/dist/tools/command-shell.d.ts.map +1 -1
  241. package/dist/tools/command-shell.js +14 -5
  242. package/dist/tools/command-shell.js.map +1 -1
  243. package/dist/turn/reporter.d.ts.map +1 -1
  244. package/dist/turn/reporter.js +11 -0
  245. package/dist/turn/reporter.js.map +1 -1
  246. package/dist/types/agent/query.d.ts +2 -0
  247. package/dist/types/agent/query.d.ts.map +1 -1
  248. package/dist/types/computer-use/index.d.ts +129 -13
  249. package/dist/types/computer-use/index.d.ts.map +1 -1
  250. package/dist/types/computer-use/index.js.map +1 -1
  251. package/dist/types/message/index.d.ts +1 -1
  252. package/dist/types/message/index.d.ts.map +1 -1
  253. package/dist/types/message/index.js +1 -0
  254. package/dist/types/message/index.js.map +1 -1
  255. package/dist/types/plugin/index.d.ts +24 -0
  256. package/dist/types/plugin/index.d.ts.map +1 -1
  257. package/dist/types/plugin/index.js +4 -0
  258. package/dist/types/plugin/index.js.map +1 -1
  259. package/dist/types/provider/chat.d.ts +19 -0
  260. package/dist/types/provider/chat.d.ts.map +1 -1
  261. package/dist/types/provider/config.d.ts +7 -0
  262. package/dist/types/provider/config.d.ts.map +1 -1
  263. package/dist/types/provider/index.d.ts +1 -1
  264. package/dist/types/provider/index.d.ts.map +1 -1
  265. package/dist/types/provider/interface.d.ts +15 -0
  266. package/dist/types/provider/interface.d.ts.map +1 -1
  267. package/dist/types/provider/stream.d.ts +6 -0
  268. package/dist/types/provider/stream.d.ts.map +1 -1
  269. package/dist/types/sandbox/index.d.ts +38 -1
  270. package/dist/types/sandbox/index.d.ts.map +1 -1
  271. package/dist/types/sandbox/index.js.map +1 -1
  272. package/dist/types/session/events.d.ts +34 -0
  273. package/dist/types/session/events.d.ts.map +1 -1
  274. package/dist/types/session/events.js.map +1 -1
  275. package/dist/types/session/records.d.ts +298 -34
  276. package/dist/types/session/records.d.ts.map +1 -1
  277. package/dist/types/session/records.js +35 -1
  278. package/dist/types/session/records.js.map +1 -1
  279. package/dist/types/session/stop-reason.d.ts +11 -0
  280. package/dist/types/session/stop-reason.d.ts.map +1 -1
  281. package/dist/types/tool/index.d.ts +30 -0
  282. package/dist/types/tool/index.d.ts.map +1 -1
  283. package/dist/types/tool/index.js.map +1 -1
  284. package/dist/types/tool/presentation.d.ts +8 -0
  285. package/dist/types/tool/presentation.d.ts.map +1 -1
  286. package/package.json +1 -1
  287. package/src/agents/QueryAgent.ts +1 -0
  288. package/src/bridge/a2a/mapper.ts +19 -0
  289. package/src/bridge/acp/update.ts +6 -1
  290. package/src/bridge/sse/mapper.ts +13 -0
  291. package/src/compaction/context-window.ts +163 -2
  292. package/src/constants/continuation.ts +13 -0
  293. package/src/contracts/session/api.ts +6 -0
  294. package/src/execution/workflow/index.ts +14 -1
  295. package/src/execution/workflow/journal.ts +161 -11
  296. package/src/execution/workflow/prelude.ts +51 -8
  297. package/src/execution/workflow/resume.ts +313 -0
  298. package/src/execution/workflow/runtime.ts +127 -9
  299. package/src/execution/workflow/types.ts +109 -1
  300. package/src/index.ts +17 -0
  301. package/src/manager/session/turn-recorder.ts +1 -0
  302. package/src/plugin/compat.ts +173 -0
  303. package/src/plugin/loader.ts +7 -1
  304. package/src/pricing/index.ts +2 -1
  305. package/src/process/kill-tree.ts +106 -4
  306. package/src/prompt/coding-agent-doctrine.ts +9 -1
  307. package/src/provider/collect-chat-completion.ts +3 -0
  308. package/src/provider/fallback.ts +17 -0
  309. package/src/provider/idle-timeout.ts +9 -0
  310. package/src/provider/mock.ts +19 -9
  311. package/src/provider/model-window-suffix.ts +85 -0
  312. package/src/provider/retry.ts +9 -0
  313. package/src/public-runtime.ts +21 -2
  314. package/src/public-types.ts +1 -0
  315. package/src/registry/command/kernel-commands.ts +1 -32
  316. package/src/runtime/jobs/awaited-jobs.ts +11 -0
  317. package/src/runtime/jobs/host-exit-finalizer.ts +67 -0
  318. package/src/runtime/jobs/liveness.ts +144 -0
  319. package/src/runtime/jobs/registry.ts +114 -2
  320. package/src/runtime/jobs/wake-budget.ts +55 -0
  321. package/src/runtime/query/detached-calls.ts +135 -0
  322. package/src/runtime/query/executor.ts +92 -10
  323. package/src/runtime/query/index.ts +65 -7
  324. package/src/runtime/query/iteration/effort-clamp.ts +46 -0
  325. package/src/runtime/query/iteration/index.ts +260 -6
  326. package/src/runtime/query/iteration/outstanding-work.ts +12 -3
  327. package/src/runtime/query/iteration/phases/context.ts +9 -0
  328. package/src/runtime/query/iteration/phases/tool-review.ts +73 -8
  329. package/src/runtime/query/iteration/stream-turn.ts +5 -0
  330. package/src/runtime/query/session-storage.ts +8 -3
  331. package/src/runtime/query/steering.ts +77 -6
  332. package/src/runtime/query/tooling.ts +2 -0
  333. package/src/runtime/system-events.ts +12 -1
  334. package/src/sandbox/denial.ts +79 -0
  335. package/src/sandbox/file-walk-program.ts +32 -13
  336. package/src/sandbox/file-walk.ts +75 -12
  337. package/src/sandbox/ignore-matcher.ts +46 -0
  338. package/src/sandbox/ignore-source.ts +220 -0
  339. package/src/sandbox/provider/local.ts +11 -1
  340. package/src/scheduler/completion-inbox.ts +1 -0
  341. package/src/session/log-hash.ts +21 -0
  342. package/src/store/memory/disk.ts +1 -0
  343. package/src/store/memory/markdown.ts +1 -0
  344. package/src/store/memory/operation-lock.ts +288 -57
  345. package/src/store/session-index/sqlite.ts +171 -16
  346. package/src/tools/builtins/bash.ts +11 -4
  347. package/src/tools/builtins/computer-use.ts +593 -68
  348. package/src/tools/builtins/glob.ts +79 -32
  349. package/src/tools/builtins/grep.ts +107 -43
  350. package/src/tools/builtins/job.ts +42 -12
  351. package/src/tools/builtins/search-support.ts +107 -0
  352. package/src/tools/builtins/wait-for-job-bounds.ts +5 -1
  353. package/src/tools/builtins/wait-for-job.ts +14 -2
  354. package/src/tools/command-shell.ts +13 -5
  355. package/src/turn/reporter.ts +12 -0
  356. package/src/types/agent/query.ts +2 -0
  357. package/src/types/computer-use/index.ts +157 -15
  358. package/src/types/message/index.ts +5 -3
  359. package/src/types/plugin/index.ts +8 -0
  360. package/src/types/provider/chat.ts +20 -0
  361. package/src/types/provider/config.ts +7 -0
  362. package/src/types/provider/index.ts +1 -0
  363. package/src/types/provider/interface.ts +20 -0
  364. package/src/types/provider/stream.ts +6 -0
  365. package/src/types/sandbox/index.ts +40 -1
  366. package/src/types/session/events.ts +65 -5
  367. package/src/types/session/records.ts +39 -2
  368. package/src/types/session/stop-reason.ts +11 -0
  369. package/src/types/tool/index.ts +30 -0
  370. package/src/types/tool/presentation.ts +8 -0
@@ -0,0 +1,220 @@
1
+ /**
2
+ * The ignore-file matcher, as plain JavaScript source text.
3
+ *
4
+ * One implementation serves two runtimes. The host walker evaluates this text
5
+ * once (see `ignore-matcher.ts`); the guest program (`file-walk-program.ts`)
6
+ * embeds the same text, because that program travels as a single `node -e`
7
+ * argument with stdin closed and cannot import a package. Keeping it as
8
+ * source text, not a serialised function, means a host bundler cannot rewrite
9
+ * it, and the two walks cannot drift apart.
10
+ *
11
+ * Rules follow the gitignore format: `#` comments, `\#` and `\!` escapes,
12
+ * unescaped trailing spaces dropped, `!` negation, a leading or inner `/`
13
+ * anchors a rule to the file that holds it, a trailing `/` matches
14
+ * directories only, and `*`, `?`, `[...]`, `**` as git defines them. A deeper
15
+ * file beats a shallower one, `.ignore` beats `.gitignore` in the same
16
+ * directory, and the last matching line of a file wins. A rule this matcher
17
+ * does not understand is dropped (an unclosed `[`, or more than three
18
+ * separate `*` in one rule, which could backtrack for seconds), so a visible
19
+ * file is never hidden by one.
20
+ *
21
+ * Nothing here is allowed to contain a backtick or a `${`: it lives inside a
22
+ * template literal. Every helper is prefixed `ign` so that, inlined into the
23
+ * guest program, it cannot collide with that program's own names.
24
+ */
25
+ export const IGNORE_SOURCE = String.raw`
26
+ const IGN_MAX_BYTES = 262144;
27
+ const IGN_MAX_RULES = 10000;
28
+ const IGN_MAX_PATTERN = 1024;
29
+ const IGN_MAX_STARS = 3;
30
+ const IGN_VCS = ['.git', '.svn', '.hg', '.bzr', '.jj', '.sl'];
31
+ const IGN_POSIX_CLASSES = {
32
+ alpha: 'a-zA-Z', digit: '0-9', alnum: 'a-zA-Z0-9', upper: 'A-Z', lower: 'a-z',
33
+ space: ' \\t\\n\\r\\f\\v', punct: '!-\\/:-@\\[-\`{-~', xdigit: '0-9A-Fa-f',
34
+ };
35
+ function ignEscape(c) { return /[\\^$.*+?()[\]{}|\/-]/.test(c) ? '\\' + c : c; }
36
+ function ignClass(body) {
37
+ let negate = false;
38
+ if (body[0] === '!' || body[0] === '^') { negate = true; body = body.slice(1); }
39
+ let out = '';
40
+ for (let i = 0; i < body.length; i++) {
41
+ const c = body[i];
42
+ if (c === '[' && body[i + 1] === ':') {
43
+ const end = body.indexOf(':]', i + 2);
44
+ const name = end < 0 ? '' : body.slice(i + 2, end);
45
+ if (IGN_POSIX_CLASSES[name]) { out += IGN_POSIX_CLASSES[name]; i = end + 1; continue; }
46
+ }
47
+ if (c === '\\') { i++; if (i < body.length) out += ignEscape(body[i]); continue; }
48
+ if (c === '-') { out += (out === '' || i === body.length - 1) ? '\\-' : '-'; continue; }
49
+ out += (c === '[' || c === ']' || c === '^') ? '\\' + c : c;
50
+ }
51
+ if (out === '') return null;
52
+ return '[' + (negate ? '^/' : '') + out + ']';
53
+ }
54
+ function ignTranslate(p) {
55
+ let out = '';
56
+ let i = 0;
57
+ let stars = 0;
58
+ while (i < p.length) {
59
+ const c = p[i];
60
+ if (c === '\\') {
61
+ if (i + 1 >= p.length) return null;
62
+ out += ignEscape(p[i + 1]); i += 2; continue;
63
+ }
64
+ if (c === '*') {
65
+ let j = i;
66
+ while (p[j] === '*') j++;
67
+ if (j - i >= 2 && (i === 0 || p[i - 1] === '/') && (j === p.length || p[j] === '/')) {
68
+ if (j === p.length) out += '.*';
69
+ else { out += '(?:.*/)?'; j++; }
70
+ i = j; continue;
71
+ }
72
+ stars++;
73
+ out += '[^/]*'; i = j; continue;
74
+ }
75
+ if (c === '?') { out += '[^/]'; i++; continue; }
76
+ if (c === '[') {
77
+ let j = i + 1;
78
+ if (p[j] === '!' || p[j] === '^') j++;
79
+ if (p[j] === ']') j++;
80
+ while (j < p.length && p[j] !== ']') { if (p[j] === '\\') j++; j++; }
81
+ if (j >= p.length) return null;
82
+ const cls = ignClass(p.slice(i + 1, j));
83
+ if (cls === null) return null;
84
+ out += cls; i = j + 1; continue;
85
+ }
86
+ out += ignEscape(c); i++;
87
+ }
88
+ // Each separate star can backtrack against the others: a rule with many of
89
+ // them takes time exponential in their number on one long name. Real rules
90
+ // use one or two; a rule past the cap is dropped, like any rule not understood.
91
+ if (stars > IGN_MAX_STARS) return null;
92
+ return out;
93
+ }
94
+ /** One line to one rule, or null when the line holds none. */
95
+ function ignRule(raw) {
96
+ let line = raw.endsWith('\r') ? raw.slice(0, -1) : raw;
97
+ while (line.endsWith(' ') && !line.endsWith('\\ ')) line = line.slice(0, -1);
98
+ if (line === '' || line[0] === '#' || line.length > IGN_MAX_PATTERN) return null;
99
+ let negate = false;
100
+ if (line[0] === '!') { negate = true; line = line.slice(1); }
101
+ let dirOnly = false;
102
+ while (line.length > 1 && line.endsWith('/')) { dirOnly = true; line = line.slice(0, -1); }
103
+ if (line === '/' || line === '') return null;
104
+ const anchored = line.indexOf('/') >= 0;
105
+ if (line[0] === '/') line = line.slice(1);
106
+ line = line.replace(/(\*\*\/)+/g, '**/');
107
+ if ((line.match(/\*\*/g) || []).length > 4) return null;
108
+ let body;
109
+ try { body = ignTranslate(line); } catch (error) { return null; }
110
+ if (body === null) return null;
111
+ try {
112
+ return { negate, dirOnly, re: new RegExp((anchored ? '^' : '^(?:.*/)?') + body + '$') };
113
+ } catch (error) { return null; }
114
+ }
115
+ function ignParse(text) {
116
+ if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);
117
+ if (text.length > IGN_MAX_BYTES) text = text.slice(0, text.lastIndexOf('\n', IGN_MAX_BYTES) + 1);
118
+ const rules = [];
119
+ for (const line of text.split('\n')) {
120
+ const rule = ignRule(line);
121
+ if (rule) rules.push(rule);
122
+ if (rules.length >= IGN_MAX_RULES) break;
123
+ }
124
+ return rules;
125
+ }
126
+ /** 0: no rule matches. 1: ignored. 2: re-included. The last matching rule wins. */
127
+ function ignDecide(rules, relative, isDirectory) {
128
+ for (let i = rules.length - 1; i >= 0; i--) {
129
+ const rule = rules[i];
130
+ if (rule.dirOnly && !isDirectory) continue;
131
+ if (rule.re.test(relative)) return rule.negate ? 2 : 1;
132
+ }
133
+ return 0;
134
+ }
135
+ /**
136
+ * The layered rules for one walk. The caller enters a directory before it
137
+ * reads it and leaves it after, so the layers follow the depth-first stack.
138
+ * deps: fs (promises), path, extraFiles (global exclude files, host only).
139
+ */
140
+ function ignCreate(deps) {
141
+ const fs = deps.fs;
142
+ const path = deps.path;
143
+ const layers = [];
144
+ const frames = [];
145
+ let ancestorsInRepo = false;
146
+ const posix = value => path.sep === '/' ? value : value.split(path.sep).join('/');
147
+ const lstat = async file => { try { return await fs.lstat(file); } catch (error) { return null; } };
148
+ const load = async file => {
149
+ const info = await lstat(file);
150
+ if (!info || !info.isFile() || info.size > IGN_MAX_BYTES * 4) return [];
151
+ try { return ignParse(await fs.readFile(file, 'utf8')); } catch (error) { return []; }
152
+ };
153
+ const loadDirectory = async (directory, inRepo) => {
154
+ const rules = [];
155
+ if (inRepo) rules.push(...await load(path.join(directory, '.gitignore')));
156
+ rules.push(...await load(path.join(directory, '.ignore')));
157
+ return rules;
158
+ };
159
+ const push = (directory, rules) => {
160
+ layers.push({ base: posix(directory).replace(/\/$/, ''), rules });
161
+ };
162
+ return {
163
+ /** Find the enclosing repository and load the layers above the root. */
164
+ async init(root) {
165
+ let directory = root;
166
+ let repo = null;
167
+ for (;;) {
168
+ const info = await lstat(path.join(directory, '.git'));
169
+ if (info) { repo = { directory, isDirectory: info.isDirectory() }; break; }
170
+ const parent = path.dirname(directory);
171
+ if (parent === directory) break;
172
+ directory = parent;
173
+ }
174
+ if (!repo || repo.directory === root) return;
175
+ ancestorsInRepo = true;
176
+ const chain = [];
177
+ for (let up = path.dirname(root); ; up = path.dirname(up)) {
178
+ chain.unshift(up);
179
+ if (up === repo.directory || path.dirname(up) === up) break;
180
+ }
181
+ for (const [index, directory] of chain.entries()) {
182
+ const rules = [];
183
+ if (index === 0) {
184
+ for (const file of deps.extraFiles || []) rules.push(...await load(file));
185
+ if (repo.isDirectory) rules.push(...await load(path.join(directory, '.git', 'info', 'exclude')));
186
+ }
187
+ rules.push(...await loadDirectory(directory, true));
188
+ push(directory, rules);
189
+ }
190
+ },
191
+ async enter(directory) {
192
+ const parentInRepo = frames.length ? frames[frames.length - 1] : ancestorsInRepo;
193
+ let inRepo = parentInRepo;
194
+ const rules = [];
195
+ if (!parentInRepo) {
196
+ const info = await lstat(path.join(directory, '.git'));
197
+ if (info) {
198
+ inRepo = true;
199
+ for (const file of deps.extraFiles || []) rules.push(...await load(file));
200
+ if (info.isDirectory()) rules.push(...await load(path.join(directory, '.git', 'info', 'exclude')));
201
+ }
202
+ }
203
+ rules.push(...await loadDirectory(directory, inRepo));
204
+ frames.push(inRepo);
205
+ push(directory, rules);
206
+ },
207
+ leave() { frames.pop(); layers.pop(); },
208
+ isIgnored(absolute, isDirectory) {
209
+ const target = posix(absolute);
210
+ for (let i = layers.length - 1; i >= 0; i--) {
211
+ const layer = layers[i];
212
+ if (layer.rules.length === 0 || !target.startsWith(layer.base + '/')) continue;
213
+ const decision = ignDecide(layer.rules, target.slice(layer.base.length + 1), isDirectory);
214
+ if (decision) return decision === 1;
215
+ }
216
+ return false;
217
+ },
218
+ };
219
+ }
220
+ `
@@ -14,6 +14,7 @@ import { tmpdir } from 'node:os'
14
14
  import { dirname, isAbsolute, join, parse, resolve } from 'node:path'
15
15
  import { NAMZU } from '../../constants/telemetry/index.js'
16
16
  import { SCOPE_ATTRIBUTE } from '../../utils/log/types.js'
17
+ import { attributeSandboxFailure } from '../denial.js'
17
18
 
18
19
  import {
19
20
  SANDBOX_DEFAULT_TIMEOUT_MS,
@@ -1084,8 +1085,16 @@ class LocalSandbox implements Sandbox {
1084
1085
  terminate('SIGKILL')
1085
1086
  }
1086
1087
  const timedOut = cancellation === 'deadline'
1088
+ const exitCode = code ?? (timedOut ? 124 : 1)
1089
+ const attribution = attributeSandboxFailure({
1090
+ environment: this.environment,
1091
+ exitCode,
1092
+ stderr: stderr.text,
1093
+ timedOut,
1094
+ allowedRoots: [...this.roots, tmpdir(), '/tmp', '/var/tmp', '/dev'],
1095
+ })
1087
1096
  resolvePromise({
1088
- exitCode: code ?? (timedOut ? 124 : 1),
1097
+ exitCode,
1089
1098
  stdout: stdout.text,
1090
1099
  stderr: stderr.text,
1091
1100
  signal: signal ?? undefined,
@@ -1096,6 +1105,7 @@ class LocalSandbox implements Sandbox {
1096
1105
  // gone. The tool layer already renders the flag.
1097
1106
  stdoutTruncated: stdout.truncated,
1098
1107
  stderrTruncated: stderr.truncated,
1108
+ ...(attribution !== undefined ? { attribution } : {}),
1099
1109
  })
1100
1110
  })
1101
1111
 
@@ -789,6 +789,7 @@ export function formatCompletionNotification(handles: readonly TaskHandle[]): st
789
789
  : []),
790
790
  ...(handle.result?.stopReason ? [`stop_reason: ${handle.result.stopReason}`] : []),
791
791
  ...(durationMs !== undefined ? [`duration_ms: ${durationMs}`] : []),
792
+ ...(handle.completedAt ? [`finished_at: ${new Date(handle.completedAt).toISOString()}`] : []),
792
793
  '',
793
794
  body,
794
795
  // Outside the envelope, deliberately: this sentence is an
@@ -1,5 +1,6 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import {
3
+ IgnorableRecordSchema,
3
4
  SESSION_RECORD_MAX_BYTES,
4
5
  type SessionRecord,
5
6
  SessionRecordSchema,
@@ -99,6 +100,18 @@ export function parseSessionLogLine(line: string | Uint8Array): ParsedSessionLog
99
100
  )
100
101
  }
101
102
  const parsed = SessionRecordSchema.safeParse(value)
103
+ if (!parsed.success && isFlaggedIgnorable(value)) {
104
+ const ignorable = IgnorableRecordSchema.safeParse(value)
105
+ if (ignorable.success) {
106
+ // Typed as a record so the chain can carry it; its `type` is one no
107
+ // consumer matches, so it never moves a fold.
108
+ return {
109
+ record: ignorable.data as unknown as SessionRecord,
110
+ length: bytes.byteLength,
111
+ sha256: recordSha256(bytes),
112
+ }
113
+ }
114
+ }
102
115
  if (!parsed.success) {
103
116
  throw new SessionLogLineError(
104
117
  'not-a-record',
@@ -113,3 +126,11 @@ export function parseSessionLogLine(line: string | Uint8Array): ParsedSessionLog
113
126
  sha256: recordSha256(bytes),
114
127
  }
115
128
  }
129
+
130
+ function isFlaggedIgnorable(value: unknown): boolean {
131
+ return (
132
+ typeof value === 'object' &&
133
+ value !== null &&
134
+ (value as { ignorable?: unknown }).ignorable === true
135
+ )
136
+ }
@@ -261,6 +261,7 @@ export class DiskMemoryStore implements ConditionalMemoryStore {
261
261
  const release = await acquireMemoryOperationLock(
262
262
  join(dirname(location.indexPath), 'operation.lock'),
263
263
  this.lockTimeoutMs,
264
+ { logger: this.log },
264
265
  )
265
266
  try {
266
267
  await this.reloadIndex(location)
@@ -418,6 +418,7 @@ export class MarkdownMemoryStore implements ConditionalMemoryStore {
418
418
  const release = await acquireMemoryOperationLock(
419
419
  join(dir, 'operation.lock'),
420
420
  this.lockTimeoutMs,
421
+ { logger: this.log },
421
422
  )
422
423
  try {
423
424
  const { loaded, superseded } = await this.load(dir, mode.importing ?? false)