@ikarmic/forge-core 4.5.0 → 5.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 (643) hide show
  1. package/LICENSE +44 -21
  2. package/README.md +1 -1
  3. package/dist/agent/agent.d.ts +8 -1
  4. package/dist/agent/agent.js +143 -23
  5. package/dist/agent/architect.d.ts +0 -1
  6. package/dist/agent/architect.js +0 -1
  7. package/dist/agent/background.d.ts +58 -0
  8. package/dist/agent/background.js +139 -0
  9. package/dist/agent/cache-hints.d.ts +0 -1
  10. package/dist/agent/cache-hints.js +0 -1
  11. package/dist/agent/cost-router.d.ts +0 -1
  12. package/dist/agent/cost-router.js +0 -1
  13. package/dist/agent/enhance-prompt.d.ts +9 -0
  14. package/dist/agent/enhance-prompt.js +34 -0
  15. package/dist/agent/goal.d.ts +54 -0
  16. package/dist/agent/goal.js +65 -0
  17. package/dist/agent/index.d.ts +0 -1
  18. package/dist/agent/index.js +0 -1
  19. package/dist/agent/loop-guard.d.ts +21 -0
  20. package/dist/agent/loop-guard.js +41 -0
  21. package/dist/agent/prompts.d.ts +0 -1
  22. package/dist/agent/prompts.js +0 -1
  23. package/dist/agent/think-tags.d.ts +0 -1
  24. package/dist/agent/think-tags.js +0 -1
  25. package/dist/agent/verify.d.ts +0 -1
  26. package/dist/agent/verify.js +0 -1
  27. package/dist/agents/agent-files.d.ts +43 -0
  28. package/dist/agents/agent-files.js +109 -0
  29. package/dist/ai-comments/index.d.ts +0 -1
  30. package/dist/ai-comments/index.js +0 -1
  31. package/dist/attachments.d.ts +0 -1
  32. package/dist/attachments.js +0 -1
  33. package/dist/browser/cdp.d.ts +0 -1
  34. package/dist/browser/cdp.js +0 -1
  35. package/dist/browser/chrome.d.ts +0 -1
  36. package/dist/browser/chrome.js +0 -1
  37. package/dist/browser/session.d.ts +0 -1
  38. package/dist/browser/session.js +0 -1
  39. package/dist/checkpoints/index.d.ts +0 -1
  40. package/dist/checkpoints/index.js +0 -1
  41. package/dist/checkpoints/store.d.ts +0 -1
  42. package/dist/checkpoints/store.js +5 -2
  43. package/dist/checkpoints/types.d.ts +0 -1
  44. package/dist/checkpoints/types.js +0 -1
  45. package/dist/code-index/builder.d.ts +0 -1
  46. package/dist/code-index/builder.js +0 -1
  47. package/dist/code-index/index-store.d.ts +0 -1
  48. package/dist/code-index/index-store.js +0 -1
  49. package/dist/code-index/parser.d.ts +0 -1
  50. package/dist/code-index/parser.js +0 -1
  51. package/dist/code-index/types.d.ts +0 -1
  52. package/dist/code-index/types.js +0 -1
  53. package/dist/commands/custom-commands.d.ts +9 -5
  54. package/dist/commands/custom-commands.js +13 -3
  55. package/dist/config-file.d.ts +47 -1
  56. package/dist/config-file.js +249 -6
  57. package/dist/config-merge.d.ts +13 -0
  58. package/dist/config-merge.js +67 -0
  59. package/dist/config-schema.d.ts +340 -0
  60. package/dist/config-schema.js +126 -0
  61. package/dist/config.d.ts +0 -1
  62. package/dist/config.js +2 -2
  63. package/dist/context/compaction.d.ts +0 -1
  64. package/dist/context/compaction.js +10 -2
  65. package/dist/context/mask.d.ts +0 -1
  66. package/dist/context/mask.js +1 -2
  67. package/dist/credentials/index.d.ts +0 -1
  68. package/dist/credentials/index.js +0 -1
  69. package/dist/credentials/types.d.ts +0 -1
  70. package/dist/credentials/types.js +0 -1
  71. package/dist/custom-providers.d.ts +95 -0
  72. package/dist/custom-providers.js +120 -0
  73. package/dist/diff/index.d.ts +0 -1
  74. package/dist/diff/index.js +0 -1
  75. package/dist/diff/unified-diff.d.ts +0 -1
  76. package/dist/diff/unified-diff.js +0 -1
  77. package/dist/git/auto-commit.d.ts +3 -4
  78. package/dist/git/auto-commit.js +8 -7
  79. package/dist/git/index.d.ts +0 -1
  80. package/dist/git/index.js +0 -1
  81. package/dist/github/github-tools.d.ts +2 -3
  82. package/dist/github/github-tools.js +0 -1
  83. package/dist/hooks/agent-runner.d.ts +0 -1
  84. package/dist/hooks/agent-runner.js +0 -1
  85. package/dist/hooks/bus.d.ts +0 -1
  86. package/dist/hooks/bus.js +0 -1
  87. package/dist/hooks/config.d.ts +0 -1
  88. package/dist/hooks/config.js +0 -1
  89. package/dist/hooks/events.d.ts +0 -1
  90. package/dist/hooks/events.js +0 -1
  91. package/dist/hooks/index.d.ts +0 -1
  92. package/dist/hooks/index.js +0 -1
  93. package/dist/hooks/loader.d.ts +0 -1
  94. package/dist/hooks/loader.js +0 -1
  95. package/dist/hooks/runner.d.ts +0 -1
  96. package/dist/hooks/runner.js +3 -3
  97. package/dist/hooks/watch-coalescer.d.ts +0 -1
  98. package/dist/hooks/watch-coalescer.js +0 -1
  99. package/dist/hooks/watch-ignore.d.ts +0 -1
  100. package/dist/hooks/watch-ignore.js +0 -1
  101. package/dist/hooks/watcher.d.ts +0 -1
  102. package/dist/hooks/watcher.js +0 -1
  103. package/dist/import/claude-code.d.ts +39 -0
  104. package/dist/import/claude-code.js +254 -0
  105. package/dist/index.d.ts +37 -7
  106. package/dist/index.js +28 -5
  107. package/dist/lazy-model.d.ts +0 -1
  108. package/dist/lazy-model.js +0 -1
  109. package/dist/lint/auto-lint.d.ts +0 -1
  110. package/dist/lint/auto-lint.js +0 -1
  111. package/dist/lint/index.d.ts +0 -1
  112. package/dist/lint/index.js +0 -1
  113. package/dist/lsp/client.d.ts +5 -1
  114. package/dist/lsp/client.js +39 -4
  115. package/dist/lsp/diagnostics.d.ts +0 -1
  116. package/dist/lsp/diagnostics.js +0 -1
  117. package/dist/lsp/index.d.ts +0 -1
  118. package/dist/lsp/index.js +0 -1
  119. package/dist/mcp/catalog.d.ts +0 -1
  120. package/dist/mcp/catalog.js +0 -1
  121. package/dist/mcp/index.d.ts +5 -2
  122. package/dist/mcp/index.js +3 -2
  123. package/dist/mcp/json-schema-to-zod.d.ts +0 -1
  124. package/dist/mcp/json-schema-to-zod.js +0 -1
  125. package/dist/mcp/manager.d.ts +17 -4
  126. package/dist/mcp/manager.js +27 -3
  127. package/dist/mcp/marketplace-types.d.ts +0 -1
  128. package/dist/mcp/marketplace-types.js +0 -1
  129. package/dist/mcp/marketplace.d.ts +2 -1
  130. package/dist/mcp/marketplace.js +10 -5
  131. package/dist/mcp/mcp-client.d.ts +12 -3
  132. package/dist/mcp/mcp-client.js +74 -18
  133. package/dist/mcp/mcp-config.d.ts +2 -1
  134. package/dist/mcp/mcp-config.js +1 -1
  135. package/dist/mcp/oauth.d.ts +55 -0
  136. package/dist/mcp/oauth.js +197 -0
  137. package/dist/mcp/registry.d.ts +0 -1
  138. package/dist/mcp/registry.js +0 -1
  139. package/dist/mcp/resource-tools.d.ts +8 -0
  140. package/dist/mcp/resource-tools.js +56 -0
  141. package/dist/memory/memory-store.d.ts +0 -1
  142. package/dist/memory/memory-store.js +0 -1
  143. package/dist/memory/rank.d.ts +0 -1
  144. package/dist/memory/rank.js +0 -1
  145. package/dist/memory/session-digest.d.ts +12 -0
  146. package/dist/memory/session-digest.js +47 -0
  147. package/dist/memory/stale.d.ts +0 -1
  148. package/dist/memory/stale.js +2 -2
  149. package/dist/model-alias.d.ts +18 -3
  150. package/dist/model-alias.js +27 -4
  151. package/dist/model-catalog.d.ts +0 -1
  152. package/dist/model-catalog.js +0 -2
  153. package/dist/model-list.d.ts +0 -1
  154. package/dist/model-list.js +2 -2
  155. package/dist/model-overrides.d.ts +30 -0
  156. package/dist/model-overrides.js +48 -0
  157. package/dist/orchestrator/board-tools.d.ts +0 -1
  158. package/dist/orchestrator/board-tools.js +0 -1
  159. package/dist/orchestrator/board.d.ts +0 -1
  160. package/dist/orchestrator/board.js +0 -1
  161. package/dist/orchestrator/index.d.ts +0 -1
  162. package/dist/orchestrator/index.js +0 -1
  163. package/dist/orchestrator/orchestrator.d.ts +0 -1
  164. package/dist/orchestrator/orchestrator.js +0 -1
  165. package/dist/orchestrator/router.d.ts +0 -1
  166. package/dist/orchestrator/router.js +0 -1
  167. package/dist/orchestrator/specialists-registry.d.ts +0 -1
  168. package/dist/orchestrator/specialists-registry.js +2 -4
  169. package/dist/orchestrator/specialists.d.ts +0 -1
  170. package/dist/orchestrator/specialists.js +4 -5
  171. package/dist/orchestrator/types.d.ts +0 -1
  172. package/dist/orchestrator/types.js +0 -1
  173. package/dist/plugins/index.d.ts +0 -1
  174. package/dist/plugins/index.js +0 -1
  175. package/dist/plugins/install.d.ts +0 -1
  176. package/dist/plugins/install.js +0 -1
  177. package/dist/plugins/loader.d.ts +0 -1
  178. package/dist/plugins/loader.js +0 -1
  179. package/dist/policy/audit.d.ts +0 -1
  180. package/dist/policy/audit.js +0 -1
  181. package/dist/policy/ca-certs.d.ts +8 -0
  182. package/dist/policy/ca-certs.js +30 -0
  183. package/dist/policy/policy.d.ts +0 -1
  184. package/dist/policy/policy.js +0 -1
  185. package/dist/policy/proxy.d.ts +10 -4
  186. package/dist/policy/proxy.js +33 -7
  187. package/dist/pricing.d.ts +0 -1
  188. package/dist/pricing.js +4 -1
  189. package/dist/providers.d.ts +7 -1
  190. package/dist/providers.js +39 -6
  191. package/dist/repomap/index.d.ts +0 -1
  192. package/dist/repomap/index.js +0 -1
  193. package/dist/repomap/repo-map.d.ts +0 -1
  194. package/dist/repomap/repo-map.js +0 -1
  195. package/dist/semantic/chunker.d.ts +0 -1
  196. package/dist/semantic/chunker.js +0 -1
  197. package/dist/semantic/embedder.d.ts +15 -1
  198. package/dist/semantic/embedder.js +25 -1
  199. package/dist/semantic/semantic-index.d.ts +10 -3
  200. package/dist/semantic/semantic-index.js +16 -8
  201. package/dist/semantic/vector-store.d.ts +0 -1
  202. package/dist/semantic/vector-store.js +0 -1
  203. package/dist/sessions/index.d.ts +1 -1
  204. package/dist/sessions/index.js +1 -1
  205. package/dist/sessions/prune.d.ts +23 -0
  206. package/dist/sessions/prune.js +35 -0
  207. package/dist/sessions/search.d.ts +0 -1
  208. package/dist/sessions/search.js +0 -1
  209. package/dist/sessions/session-export.d.ts +0 -1
  210. package/dist/sessions/session-export.js +0 -1
  211. package/dist/sessions/session-store.d.ts +0 -1
  212. package/dist/sessions/session-store.js +2 -2
  213. package/dist/sessions/watch.d.ts +0 -1
  214. package/dist/sessions/watch.js +0 -1
  215. package/dist/settings-export.d.ts +0 -1
  216. package/dist/settings-export.js +0 -1
  217. package/dist/skills/activator.d.ts +0 -1
  218. package/dist/skills/activator.js +0 -1
  219. package/dist/skills/builtin.d.ts +2 -0
  220. package/dist/skills/builtin.js +68 -0
  221. package/dist/skills/index.d.ts +2 -1
  222. package/dist/skills/index.js +2 -1
  223. package/dist/skills/loader.d.ts +10 -4
  224. package/dist/skills/loader.js +20 -8
  225. package/dist/skills/marketplace-types.d.ts +0 -1
  226. package/dist/skills/marketplace-types.js +0 -1
  227. package/dist/skills/marketplace.d.ts +0 -1
  228. package/dist/skills/marketplace.js +2 -2
  229. package/dist/skills/parser.d.ts +0 -1
  230. package/dist/skills/parser.js +0 -1
  231. package/dist/skills/remote.d.ts +14 -0
  232. package/dist/skills/remote.js +131 -0
  233. package/dist/skills/types.d.ts +10 -1
  234. package/dist/skills/types.js +0 -1
  235. package/dist/specs/generate.d.ts +0 -1
  236. package/dist/specs/generate.js +0 -1
  237. package/dist/specs/index.d.ts +0 -1
  238. package/dist/specs/index.js +0 -1
  239. package/dist/specs/store.d.ts +0 -1
  240. package/dist/specs/store.js +0 -1
  241. package/dist/specs/sync.d.ts +0 -1
  242. package/dist/specs/sync.js +0 -1
  243. package/dist/specs/tasks-parser.d.ts +0 -1
  244. package/dist/specs/tasks-parser.js +0 -1
  245. package/dist/specs/types.d.ts +0 -1
  246. package/dist/specs/types.js +0 -1
  247. package/dist/steering/extra-instructions.d.ts +8 -0
  248. package/dist/steering/extra-instructions.js +104 -0
  249. package/dist/steering/folder-instructions.d.ts +8 -0
  250. package/dist/steering/folder-instructions.js +28 -0
  251. package/dist/steering/glob.d.ts +0 -1
  252. package/dist/steering/glob.js +0 -1
  253. package/dist/steering/index.d.ts +0 -1
  254. package/dist/steering/index.js +0 -1
  255. package/dist/steering/loader.d.ts +0 -1
  256. package/dist/steering/loader.js +0 -1
  257. package/dist/steering/project-instructions.d.ts +0 -1
  258. package/dist/steering/project-instructions.js +0 -1
  259. package/dist/steering/select.d.ts +0 -1
  260. package/dist/steering/select.js +2 -2
  261. package/dist/steering/types.d.ts +0 -1
  262. package/dist/steering/types.js +0 -1
  263. package/dist/structured/index.d.ts +0 -1
  264. package/dist/structured/index.js +0 -1
  265. package/dist/structured/retry.d.ts +0 -1
  266. package/dist/structured/retry.js +0 -1
  267. package/dist/structured/schema.d.ts +0 -1
  268. package/dist/structured/schema.js +0 -1
  269. package/dist/timed-fetch.d.ts +12 -0
  270. package/dist/timed-fetch.js +83 -0
  271. package/dist/tools/apply-patch.d.ts +52 -0
  272. package/dist/tools/apply-patch.js +197 -0
  273. package/dist/tools/ask-user.d.ts +27 -0
  274. package/dist/tools/ask-user.js +32 -0
  275. package/dist/tools/browser-tools.d.ts +6 -7
  276. package/dist/tools/browser-tools.js +3 -14
  277. package/dist/tools/codebase-search.d.ts +4 -3
  278. package/dist/tools/codebase-search.js +2 -3
  279. package/dist/tools/command-allow.d.ts +0 -1
  280. package/dist/tools/command-allow.js +0 -1
  281. package/dist/tools/edit-file.d.ts +0 -1
  282. package/dist/tools/edit-file.js +5 -4
  283. package/dist/tools/fetch-url.d.ts +7 -1
  284. package/dist/tools/fetch-url.js +52 -20
  285. package/dist/tools/find-references.d.ts +0 -1
  286. package/dist/tools/find-references.js +0 -1
  287. package/dist/tools/find-symbol.d.ts +2 -3
  288. package/dist/tools/find-symbol.js +0 -1
  289. package/dist/tools/ignore-rules.d.ts +0 -1
  290. package/dist/tools/ignore-rules.js +2 -2
  291. package/dist/tools/index.d.ts +5 -2
  292. package/dist/tools/index.js +10 -2
  293. package/dist/tools/list-files.d.ts +0 -1
  294. package/dist/tools/list-files.js +0 -1
  295. package/dist/tools/list-symbols.d.ts +0 -1
  296. package/dist/tools/list-symbols.js +0 -1
  297. package/dist/tools/memory.d.ts +6 -7
  298. package/dist/tools/memory.js +0 -1
  299. package/dist/tools/notebook.d.ts +2 -3
  300. package/dist/tools/notebook.js +0 -1
  301. package/dist/tools/permission-rules.d.ts +32 -0
  302. package/dist/tools/permission-rules.js +182 -0
  303. package/dist/tools/policy.d.ts +0 -1
  304. package/dist/tools/policy.js +0 -1
  305. package/dist/tools/read-file.d.ts +5 -1
  306. package/dist/tools/read-file.js +7 -3
  307. package/dist/tools/read-image.d.ts +0 -1
  308. package/dist/tools/read-image.js +0 -1
  309. package/dist/tools/read-only.d.ts +1 -2
  310. package/dist/tools/read-only.js +2 -1
  311. package/dist/tools/redact.d.ts +0 -1
  312. package/dist/tools/redact.js +0 -1
  313. package/dist/tools/result-cache.d.ts +0 -1
  314. package/dist/tools/result-cache.js +0 -1
  315. package/dist/tools/run-command.d.ts +4 -3
  316. package/dist/tools/run-command.js +12 -9
  317. package/dist/tools/sandbox-loader.d.ts +0 -1
  318. package/dist/tools/sandbox-loader.js +3 -14
  319. package/dist/tools/search-files.d.ts +8 -3
  320. package/dist/tools/search-files.js +43 -1
  321. package/dist/tools/shared.d.ts +5 -1
  322. package/dist/tools/shared.js +30 -3
  323. package/dist/tools/shell-env.d.ts +7 -0
  324. package/dist/tools/shell-env.js +9 -0
  325. package/dist/tools/sub-agent-wait.d.ts +29 -0
  326. package/dist/tools/sub-agent-wait.js +60 -0
  327. package/dist/tools/sub-agent.d.ts +50 -5
  328. package/dist/tools/sub-agent.js +210 -126
  329. package/dist/tools/text-encoding.d.ts +10 -0
  330. package/dist/tools/text-encoding.js +40 -0
  331. package/dist/tools/todo.d.ts +36 -0
  332. package/dist/tools/todo.js +42 -0
  333. package/dist/tools/web-search.d.ts +0 -1
  334. package/dist/tools/web-search.js +0 -1
  335. package/dist/tools/write-file.d.ts +0 -1
  336. package/dist/tools/write-file.js +15 -10
  337. package/dist/tools/write-tools.d.ts +12 -0
  338. package/dist/tools/write-tools.js +18 -0
  339. package/dist/types.d.ts +85 -2
  340. package/dist/types.js +0 -1
  341. package/dist/verify/detect.d.ts +0 -1
  342. package/dist/verify/detect.js +0 -1
  343. package/dist/verify/index.d.ts +0 -1
  344. package/dist/verify/index.js +0 -1
  345. package/dist/worktree/branch-ops.d.ts +0 -1
  346. package/dist/worktree/branch-ops.js +0 -1
  347. package/dist/worktree/index.d.ts +0 -1
  348. package/dist/worktree/index.js +0 -1
  349. package/dist/worktree/worktree.d.ts +3 -1
  350. package/dist/worktree/worktree.js +22 -1
  351. package/package.json +3 -2
  352. package/dist/agent/agent.d.ts.map +0 -1
  353. package/dist/agent/agent.js.map +0 -1
  354. package/dist/agent/architect.d.ts.map +0 -1
  355. package/dist/agent/architect.js.map +0 -1
  356. package/dist/agent/cache-hints.d.ts.map +0 -1
  357. package/dist/agent/cache-hints.js.map +0 -1
  358. package/dist/agent/cost-router.d.ts.map +0 -1
  359. package/dist/agent/cost-router.js.map +0 -1
  360. package/dist/agent/index.d.ts.map +0 -1
  361. package/dist/agent/index.js.map +0 -1
  362. package/dist/agent/prompts.d.ts.map +0 -1
  363. package/dist/agent/prompts.js.map +0 -1
  364. package/dist/agent/think-tags.d.ts.map +0 -1
  365. package/dist/agent/think-tags.js.map +0 -1
  366. package/dist/agent/verify.d.ts.map +0 -1
  367. package/dist/agent/verify.js.map +0 -1
  368. package/dist/ai-comments/index.d.ts.map +0 -1
  369. package/dist/ai-comments/index.js.map +0 -1
  370. package/dist/attachments.d.ts.map +0 -1
  371. package/dist/attachments.js.map +0 -1
  372. package/dist/browser/cdp.d.ts.map +0 -1
  373. package/dist/browser/cdp.js.map +0 -1
  374. package/dist/browser/chrome.d.ts.map +0 -1
  375. package/dist/browser/chrome.js.map +0 -1
  376. package/dist/browser/session.d.ts.map +0 -1
  377. package/dist/browser/session.js.map +0 -1
  378. package/dist/checkpoints/index.d.ts.map +0 -1
  379. package/dist/checkpoints/index.js.map +0 -1
  380. package/dist/checkpoints/store.d.ts.map +0 -1
  381. package/dist/checkpoints/store.js.map +0 -1
  382. package/dist/checkpoints/types.d.ts.map +0 -1
  383. package/dist/checkpoints/types.js.map +0 -1
  384. package/dist/code-index/builder.d.ts.map +0 -1
  385. package/dist/code-index/builder.js.map +0 -1
  386. package/dist/code-index/index-store.d.ts.map +0 -1
  387. package/dist/code-index/index-store.js.map +0 -1
  388. package/dist/code-index/parser.d.ts.map +0 -1
  389. package/dist/code-index/parser.js.map +0 -1
  390. package/dist/code-index/types.d.ts.map +0 -1
  391. package/dist/code-index/types.js.map +0 -1
  392. package/dist/commands/custom-commands.d.ts.map +0 -1
  393. package/dist/commands/custom-commands.js.map +0 -1
  394. package/dist/config-file.d.ts.map +0 -1
  395. package/dist/config-file.js.map +0 -1
  396. package/dist/config.d.ts.map +0 -1
  397. package/dist/config.js.map +0 -1
  398. package/dist/context/compaction.d.ts.map +0 -1
  399. package/dist/context/compaction.js.map +0 -1
  400. package/dist/context/mask.d.ts.map +0 -1
  401. package/dist/context/mask.js.map +0 -1
  402. package/dist/credentials/index.d.ts.map +0 -1
  403. package/dist/credentials/index.js.map +0 -1
  404. package/dist/credentials/types.d.ts.map +0 -1
  405. package/dist/credentials/types.js.map +0 -1
  406. package/dist/diff/index.d.ts.map +0 -1
  407. package/dist/diff/index.js.map +0 -1
  408. package/dist/diff/unified-diff.d.ts.map +0 -1
  409. package/dist/diff/unified-diff.js.map +0 -1
  410. package/dist/git/auto-commit.d.ts.map +0 -1
  411. package/dist/git/auto-commit.js.map +0 -1
  412. package/dist/git/index.d.ts.map +0 -1
  413. package/dist/git/index.js.map +0 -1
  414. package/dist/github/github-tools.d.ts.map +0 -1
  415. package/dist/github/github-tools.js.map +0 -1
  416. package/dist/hooks/agent-runner.d.ts.map +0 -1
  417. package/dist/hooks/agent-runner.js.map +0 -1
  418. package/dist/hooks/bus.d.ts.map +0 -1
  419. package/dist/hooks/bus.js.map +0 -1
  420. package/dist/hooks/config.d.ts.map +0 -1
  421. package/dist/hooks/config.js.map +0 -1
  422. package/dist/hooks/events.d.ts.map +0 -1
  423. package/dist/hooks/events.js.map +0 -1
  424. package/dist/hooks/index.d.ts.map +0 -1
  425. package/dist/hooks/index.js.map +0 -1
  426. package/dist/hooks/loader.d.ts.map +0 -1
  427. package/dist/hooks/loader.js.map +0 -1
  428. package/dist/hooks/runner.d.ts.map +0 -1
  429. package/dist/hooks/runner.js.map +0 -1
  430. package/dist/hooks/watch-coalescer.d.ts.map +0 -1
  431. package/dist/hooks/watch-coalescer.js.map +0 -1
  432. package/dist/hooks/watch-ignore.d.ts.map +0 -1
  433. package/dist/hooks/watch-ignore.js.map +0 -1
  434. package/dist/hooks/watcher.d.ts.map +0 -1
  435. package/dist/hooks/watcher.js.map +0 -1
  436. package/dist/index.d.ts.map +0 -1
  437. package/dist/index.js.map +0 -1
  438. package/dist/lazy-model.d.ts.map +0 -1
  439. package/dist/lazy-model.js.map +0 -1
  440. package/dist/lint/auto-lint.d.ts.map +0 -1
  441. package/dist/lint/auto-lint.js.map +0 -1
  442. package/dist/lint/index.d.ts.map +0 -1
  443. package/dist/lint/index.js.map +0 -1
  444. package/dist/lsp/client.d.ts.map +0 -1
  445. package/dist/lsp/client.js.map +0 -1
  446. package/dist/lsp/diagnostics.d.ts.map +0 -1
  447. package/dist/lsp/diagnostics.js.map +0 -1
  448. package/dist/lsp/index.d.ts.map +0 -1
  449. package/dist/lsp/index.js.map +0 -1
  450. package/dist/mcp/catalog.d.ts.map +0 -1
  451. package/dist/mcp/catalog.js.map +0 -1
  452. package/dist/mcp/index.d.ts.map +0 -1
  453. package/dist/mcp/index.js.map +0 -1
  454. package/dist/mcp/json-schema-to-zod.d.ts.map +0 -1
  455. package/dist/mcp/json-schema-to-zod.js.map +0 -1
  456. package/dist/mcp/manager.d.ts.map +0 -1
  457. package/dist/mcp/manager.js.map +0 -1
  458. package/dist/mcp/marketplace-types.d.ts.map +0 -1
  459. package/dist/mcp/marketplace-types.js.map +0 -1
  460. package/dist/mcp/marketplace.d.ts.map +0 -1
  461. package/dist/mcp/marketplace.js.map +0 -1
  462. package/dist/mcp/mcp-client.d.ts.map +0 -1
  463. package/dist/mcp/mcp-client.js.map +0 -1
  464. package/dist/mcp/mcp-config.d.ts.map +0 -1
  465. package/dist/mcp/mcp-config.js.map +0 -1
  466. package/dist/mcp/registry.d.ts.map +0 -1
  467. package/dist/mcp/registry.js.map +0 -1
  468. package/dist/memory/memory-store.d.ts.map +0 -1
  469. package/dist/memory/memory-store.js.map +0 -1
  470. package/dist/memory/rank.d.ts.map +0 -1
  471. package/dist/memory/rank.js.map +0 -1
  472. package/dist/memory/stale.d.ts.map +0 -1
  473. package/dist/memory/stale.js.map +0 -1
  474. package/dist/model-alias.d.ts.map +0 -1
  475. package/dist/model-alias.js.map +0 -1
  476. package/dist/model-catalog.d.ts.map +0 -1
  477. package/dist/model-catalog.js.map +0 -1
  478. package/dist/model-list.d.ts.map +0 -1
  479. package/dist/model-list.js.map +0 -1
  480. package/dist/orchestrator/board-tools.d.ts.map +0 -1
  481. package/dist/orchestrator/board-tools.js.map +0 -1
  482. package/dist/orchestrator/board.d.ts.map +0 -1
  483. package/dist/orchestrator/board.js.map +0 -1
  484. package/dist/orchestrator/index.d.ts.map +0 -1
  485. package/dist/orchestrator/index.js.map +0 -1
  486. package/dist/orchestrator/orchestrator.d.ts.map +0 -1
  487. package/dist/orchestrator/orchestrator.js.map +0 -1
  488. package/dist/orchestrator/router.d.ts.map +0 -1
  489. package/dist/orchestrator/router.js.map +0 -1
  490. package/dist/orchestrator/specialists-registry.d.ts.map +0 -1
  491. package/dist/orchestrator/specialists-registry.js.map +0 -1
  492. package/dist/orchestrator/specialists.d.ts.map +0 -1
  493. package/dist/orchestrator/specialists.js.map +0 -1
  494. package/dist/orchestrator/types.d.ts.map +0 -1
  495. package/dist/orchestrator/types.js.map +0 -1
  496. package/dist/plugins/index.d.ts.map +0 -1
  497. package/dist/plugins/index.js.map +0 -1
  498. package/dist/plugins/install.d.ts.map +0 -1
  499. package/dist/plugins/install.js.map +0 -1
  500. package/dist/plugins/loader.d.ts.map +0 -1
  501. package/dist/plugins/loader.js.map +0 -1
  502. package/dist/policy/audit.d.ts.map +0 -1
  503. package/dist/policy/audit.js.map +0 -1
  504. package/dist/policy/policy.d.ts.map +0 -1
  505. package/dist/policy/policy.js.map +0 -1
  506. package/dist/policy/proxy.d.ts.map +0 -1
  507. package/dist/policy/proxy.js.map +0 -1
  508. package/dist/pricing.d.ts.map +0 -1
  509. package/dist/pricing.js.map +0 -1
  510. package/dist/providers.d.ts.map +0 -1
  511. package/dist/providers.js.map +0 -1
  512. package/dist/repomap/index.d.ts.map +0 -1
  513. package/dist/repomap/index.js.map +0 -1
  514. package/dist/repomap/repo-map.d.ts.map +0 -1
  515. package/dist/repomap/repo-map.js.map +0 -1
  516. package/dist/semantic/chunker.d.ts.map +0 -1
  517. package/dist/semantic/chunker.js.map +0 -1
  518. package/dist/semantic/embedder.d.ts.map +0 -1
  519. package/dist/semantic/embedder.js.map +0 -1
  520. package/dist/semantic/semantic-index.d.ts.map +0 -1
  521. package/dist/semantic/semantic-index.js.map +0 -1
  522. package/dist/semantic/vector-store.d.ts.map +0 -1
  523. package/dist/semantic/vector-store.js.map +0 -1
  524. package/dist/sessions/index.d.ts.map +0 -1
  525. package/dist/sessions/index.js.map +0 -1
  526. package/dist/sessions/search.d.ts.map +0 -1
  527. package/dist/sessions/search.js.map +0 -1
  528. package/dist/sessions/session-export.d.ts.map +0 -1
  529. package/dist/sessions/session-export.js.map +0 -1
  530. package/dist/sessions/session-store.d.ts.map +0 -1
  531. package/dist/sessions/session-store.js.map +0 -1
  532. package/dist/sessions/watch.d.ts.map +0 -1
  533. package/dist/sessions/watch.js.map +0 -1
  534. package/dist/settings-export.d.ts.map +0 -1
  535. package/dist/settings-export.js.map +0 -1
  536. package/dist/skills/activator.d.ts.map +0 -1
  537. package/dist/skills/activator.js.map +0 -1
  538. package/dist/skills/index.d.ts.map +0 -1
  539. package/dist/skills/index.js.map +0 -1
  540. package/dist/skills/loader.d.ts.map +0 -1
  541. package/dist/skills/loader.js.map +0 -1
  542. package/dist/skills/marketplace-types.d.ts.map +0 -1
  543. package/dist/skills/marketplace-types.js.map +0 -1
  544. package/dist/skills/marketplace.d.ts.map +0 -1
  545. package/dist/skills/marketplace.js.map +0 -1
  546. package/dist/skills/parser.d.ts.map +0 -1
  547. package/dist/skills/parser.js.map +0 -1
  548. package/dist/skills/types.d.ts.map +0 -1
  549. package/dist/skills/types.js.map +0 -1
  550. package/dist/specs/generate.d.ts.map +0 -1
  551. package/dist/specs/generate.js.map +0 -1
  552. package/dist/specs/index.d.ts.map +0 -1
  553. package/dist/specs/index.js.map +0 -1
  554. package/dist/specs/store.d.ts.map +0 -1
  555. package/dist/specs/store.js.map +0 -1
  556. package/dist/specs/sync.d.ts.map +0 -1
  557. package/dist/specs/sync.js.map +0 -1
  558. package/dist/specs/tasks-parser.d.ts.map +0 -1
  559. package/dist/specs/tasks-parser.js.map +0 -1
  560. package/dist/specs/types.d.ts.map +0 -1
  561. package/dist/specs/types.js.map +0 -1
  562. package/dist/steering/glob.d.ts.map +0 -1
  563. package/dist/steering/glob.js.map +0 -1
  564. package/dist/steering/index.d.ts.map +0 -1
  565. package/dist/steering/index.js.map +0 -1
  566. package/dist/steering/loader.d.ts.map +0 -1
  567. package/dist/steering/loader.js.map +0 -1
  568. package/dist/steering/project-instructions.d.ts.map +0 -1
  569. package/dist/steering/project-instructions.js.map +0 -1
  570. package/dist/steering/select.d.ts.map +0 -1
  571. package/dist/steering/select.js.map +0 -1
  572. package/dist/steering/types.d.ts.map +0 -1
  573. package/dist/steering/types.js.map +0 -1
  574. package/dist/structured/index.d.ts.map +0 -1
  575. package/dist/structured/index.js.map +0 -1
  576. package/dist/structured/retry.d.ts.map +0 -1
  577. package/dist/structured/retry.js.map +0 -1
  578. package/dist/structured/schema.d.ts.map +0 -1
  579. package/dist/structured/schema.js.map +0 -1
  580. package/dist/tools/browser-tools.d.ts.map +0 -1
  581. package/dist/tools/browser-tools.js.map +0 -1
  582. package/dist/tools/codebase-search.d.ts.map +0 -1
  583. package/dist/tools/codebase-search.js.map +0 -1
  584. package/dist/tools/command-allow.d.ts.map +0 -1
  585. package/dist/tools/command-allow.js.map +0 -1
  586. package/dist/tools/edit-file.d.ts.map +0 -1
  587. package/dist/tools/edit-file.js.map +0 -1
  588. package/dist/tools/fetch-url.d.ts.map +0 -1
  589. package/dist/tools/fetch-url.js.map +0 -1
  590. package/dist/tools/find-references.d.ts.map +0 -1
  591. package/dist/tools/find-references.js.map +0 -1
  592. package/dist/tools/find-symbol.d.ts.map +0 -1
  593. package/dist/tools/find-symbol.js.map +0 -1
  594. package/dist/tools/ignore-rules.d.ts.map +0 -1
  595. package/dist/tools/ignore-rules.js.map +0 -1
  596. package/dist/tools/index.d.ts.map +0 -1
  597. package/dist/tools/index.js.map +0 -1
  598. package/dist/tools/list-files.d.ts.map +0 -1
  599. package/dist/tools/list-files.js.map +0 -1
  600. package/dist/tools/list-symbols.d.ts.map +0 -1
  601. package/dist/tools/list-symbols.js.map +0 -1
  602. package/dist/tools/memory.d.ts.map +0 -1
  603. package/dist/tools/memory.js.map +0 -1
  604. package/dist/tools/notebook.d.ts.map +0 -1
  605. package/dist/tools/notebook.js.map +0 -1
  606. package/dist/tools/policy.d.ts.map +0 -1
  607. package/dist/tools/policy.js.map +0 -1
  608. package/dist/tools/read-file.d.ts.map +0 -1
  609. package/dist/tools/read-file.js.map +0 -1
  610. package/dist/tools/read-image.d.ts.map +0 -1
  611. package/dist/tools/read-image.js.map +0 -1
  612. package/dist/tools/read-only.d.ts.map +0 -1
  613. package/dist/tools/read-only.js.map +0 -1
  614. package/dist/tools/redact.d.ts.map +0 -1
  615. package/dist/tools/redact.js.map +0 -1
  616. package/dist/tools/result-cache.d.ts.map +0 -1
  617. package/dist/tools/result-cache.js.map +0 -1
  618. package/dist/tools/run-command.d.ts.map +0 -1
  619. package/dist/tools/run-command.js.map +0 -1
  620. package/dist/tools/sandbox-loader.d.ts.map +0 -1
  621. package/dist/tools/sandbox-loader.js.map +0 -1
  622. package/dist/tools/search-files.d.ts.map +0 -1
  623. package/dist/tools/search-files.js.map +0 -1
  624. package/dist/tools/shared.d.ts.map +0 -1
  625. package/dist/tools/shared.js.map +0 -1
  626. package/dist/tools/sub-agent.d.ts.map +0 -1
  627. package/dist/tools/sub-agent.js.map +0 -1
  628. package/dist/tools/web-search.d.ts.map +0 -1
  629. package/dist/tools/web-search.js.map +0 -1
  630. package/dist/tools/write-file.d.ts.map +0 -1
  631. package/dist/tools/write-file.js.map +0 -1
  632. package/dist/types.d.ts.map +0 -1
  633. package/dist/types.js.map +0 -1
  634. package/dist/verify/detect.d.ts.map +0 -1
  635. package/dist/verify/detect.js.map +0 -1
  636. package/dist/verify/index.d.ts.map +0 -1
  637. package/dist/verify/index.js.map +0 -1
  638. package/dist/worktree/branch-ops.d.ts.map +0 -1
  639. package/dist/worktree/branch-ops.js.map +0 -1
  640. package/dist/worktree/index.d.ts.map +0 -1
  641. package/dist/worktree/index.js.map +0 -1
  642. package/dist/worktree/worktree.d.ts.map +0 -1
  643. package/dist/worktree/worktree.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The `AGENTS.md` of every folder between the workspace root and the file just read (nearest first), each shown
3
+ * once per run. The root one is already in the system prompt, so it is never repeated here.
4
+ */
5
+ export declare function folderInstructionsFor(filePath: string, cwd: string, shown: Set<string>): Promise<Array<{
6
+ file: string;
7
+ text: string;
8
+ }> | undefined>;
@@ -0,0 +1,28 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ const MAX_BYTES = 8_000;
4
+ /**
5
+ * The `AGENTS.md` of every folder between the workspace root and the file just read (nearest first), each shown
6
+ * once per run. The root one is already in the system prompt, so it is never repeated here.
7
+ */
8
+ export async function folderInstructionsFor(filePath, cwd, shown) {
9
+ const root = path.resolve(cwd);
10
+ let dir = path.dirname(path.resolve(filePath));
11
+ const out = [];
12
+ while (dir !== root && dir.startsWith(root + path.sep)) {
13
+ const abs = path.join(dir, 'AGENTS.md');
14
+ if (!shown.has(abs)) {
15
+ try {
16
+ const text = (await readFile(abs, 'utf8')).trim();
17
+ shown.add(abs);
18
+ if (text)
19
+ out.push({ file: path.relative(root, abs), text: text.length > MAX_BYTES ? `${text.slice(0, MAX_BYTES)}\n…(truncated)` : text });
20
+ }
21
+ catch {
22
+ shown.add(abs);
23
+ }
24
+ }
25
+ dir = path.dirname(dir);
26
+ }
27
+ return out.length ? out : undefined;
28
+ }
@@ -12,4 +12,3 @@
12
12
  * Spec: docs/superpowers/specs/2026-09-29-steering-files-design.md §5.1
13
13
  */
14
14
  export declare function pathMatchesGlob(rawPattern: string, relPath: string): boolean;
15
- //# sourceMappingURL=glob.d.ts.map
@@ -88,4 +88,3 @@ export function pathMatchesGlob(rawPattern, relPath) {
88
88
  const subject = pattern.includes('/') ? relPath : relPath.slice(relPath.lastIndexOf('/') + 1);
89
89
  return matchTokens(tokenize(pattern), subject);
90
90
  }
91
- //# sourceMappingURL=glob.js.map
@@ -4,4 +4,3 @@ export { isSafeSteeringName, loadSteering, overrideFilePath, parseSteering, read
4
4
  export { MAX_TOOL_INJECTIONS, START_BUDGET_BYTES, TOOL_DOC_BYTES, formatSteeringLine, selectAtStart, selectOnToolTouch, stripSteering, toWorkspaceRelative, wrapSteering, } from './select.js';
5
5
  export type { StartSelection } from './select.js';
6
6
  export type { SteeringConfig, SteeringDoc, SteeringInclusion, SteeringLoadResult, SteeringSkip } from './types.js';
7
- //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,3 @@
2
2
  export { pathMatchesGlob } from './glob.js';
3
3
  export { isSafeSteeringName, loadSteering, overrideFilePath, parseSteering, readOverride, setSteeringDisabled, } from './loader.js';
4
4
  export { MAX_TOOL_INJECTIONS, START_BUDGET_BYTES, TOOL_DOC_BYTES, formatSteeringLine, selectAtStart, selectOnToolTouch, stripSteering, toWorkspaceRelative, wrapSteering, } from './select.js';
5
- //# sourceMappingURL=index.js.map
@@ -12,4 +12,3 @@ export declare function loadSteering(cwd: string, opts?: {
12
12
  includeProject?: boolean;
13
13
  homeDir?: string;
14
14
  }): Promise<SteeringLoadResult>;
15
- //# sourceMappingURL=loader.d.ts.map
@@ -150,4 +150,3 @@ export async function loadSteering(cwd, opts = {}) {
150
150
  .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
151
151
  return { docs, warnings };
152
152
  }
153
- //# sourceMappingURL=loader.js.map
@@ -1,4 +1,3 @@
1
1
  export declare const PROJECT_INSTRUCTION_FILES: readonly ["AGENTS.md", "CLAUDE.md", "CONVENTIONS.md"];
2
2
  export declare const MAX_INSTRUCTION_BYTES = 16000;
3
3
  export declare function buildProjectInstructionsBlock(cwd: string): Promise<string>;
4
- //# sourceMappingURL=project-instructions.d.ts.map
@@ -25,4 +25,3 @@ export async function buildProjectInstructionsBlock(cwd) {
25
25
  }
26
26
  return blocks.join('\n\n');
27
27
  }
28
- //# sourceMappingURL=project-instructions.js.map
@@ -26,4 +26,3 @@ export declare function formatSteeringLine(e: {
26
26
  skipped: SteeringSkip[];
27
27
  path?: string;
28
28
  }): string;
29
- //# sourceMappingURL=select.d.ts.map
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import path from 'node:path';
6
6
  import { pathMatchesGlob } from './glob.js';
7
+ import { isOutsideRel } from '../tools/shared.js';
7
8
  export const START_BUDGET_BYTES = 12_000;
8
9
  export const TOOL_DOC_BYTES = 8_000;
9
10
  export const MAX_TOOL_INJECTIONS = 3;
@@ -19,7 +20,7 @@ export function stripSteering(text) {
19
20
  export function toWorkspaceRelative(cwd, p) {
20
21
  const abs = path.resolve(cwd, p);
21
22
  const rel = path.relative(cwd, abs);
22
- if (!rel || rel.startsWith('..') || path.isAbsolute(rel))
23
+ if (!rel || isOutsideRel(rel))
23
24
  return null;
24
25
  return rel.split(path.sep).join('/');
25
26
  }
@@ -94,4 +95,3 @@ export function formatSteeringLine(e) {
94
95
  const skipped = e.skipped.length > 0 ? ` · skipped: ${e.skipped.map((s) => `${s.name} (${s.reason})`).join(', ')}` : '';
95
96
  return `${head}: ${applied}${skipped}`;
96
97
  }
97
- //# sourceMappingURL=select.js.map
@@ -32,4 +32,3 @@ export interface SteeringSkip {
32
32
  name: string;
33
33
  reason: 'budget' | 'cap';
34
34
  }
35
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,2 @@
1
1
  /** Steering files (SP3a). Spec: docs/superpowers/specs/2026-09-29-steering-files-design.md §5.1 */
2
2
  export {};
3
- //# sourceMappingURL=types.js.map
@@ -16,4 +16,3 @@ export type { ZodTypeAny } from 'zod';
16
16
  export { formatZodError, jsonSchemaToZod, loadSchemaFile, } from './schema.js';
17
17
  export { defaultRetryPrompt, isStructuredOutputError, runStructuredAgent, StructuredOutputError, validateFinalText, } from './retry.js';
18
18
  export type { StructuredRunOptions, StructuredRunResult } from './retry.js';
19
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export { formatZodError, jsonSchemaToZod, loadSchemaFile, } from './schema.js';
2
2
  export { defaultRetryPrompt, isStructuredOutputError, runStructuredAgent, StructuredOutputError, validateFinalText, } from './retry.js';
3
- //# sourceMappingURL=index.js.map
@@ -131,4 +131,3 @@ export declare class StructuredOutputError extends Error {
131
131
  */
132
132
  export declare function isStructuredOutputError(err: unknown): err is StructuredOutputError;
133
133
  export { z };
134
- //# sourceMappingURL=retry.d.ts.map
@@ -200,4 +200,3 @@ export function isStructuredOutputError(err) {
200
200
  }
201
201
  // Re-export so callers don't need a second import.
202
202
  export { z };
203
- //# sourceMappingURL=retry.js.map
@@ -60,4 +60,3 @@ export declare function jsonSchemaToZod(schema: Record<string, unknown>): ZodTyp
60
60
  * Paths use JSON Pointer-ish dotted notation; values are quoted.
61
61
  */
62
62
  export declare function formatZodError(err: ZodError): string;
63
- //# sourceMappingURL=schema.d.ts.map
@@ -291,4 +291,3 @@ function describeReceived(issue) {
291
291
  return '';
292
292
  return JSON.stringify(issue.received);
293
293
  }
294
- //# sourceMappingURL=schema.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Wraps `fetch` with the two timeouts Kilo calls `timeout` and `chunkTimeout`:
3
+ * - `timeoutMs`: how long to wait for the response to start (headers). It stops counting once the answer begins,
4
+ * so a slow stream is never cut short by it.
5
+ * - `chunkTimeoutMs`: how long a streamed answer may stay silent. A stalled stream is aborted with a clear error
6
+ * instead of hanging forever (a connection can stay open while the provider has stopped sending).
7
+ */
8
+ export interface FetchTimeouts {
9
+ timeoutMs?: number;
10
+ chunkTimeoutMs?: number;
11
+ }
12
+ export declare function withTimeouts(base: typeof fetch, opts: FetchTimeouts): typeof fetch;
@@ -0,0 +1,83 @@
1
+ export function withTimeouts(base, opts) {
2
+ const { timeoutMs, chunkTimeoutMs } = opts;
3
+ if (!timeoutMs && !chunkTimeoutMs)
4
+ return base;
5
+ return (async (input, init) => {
6
+ const controller = new AbortController();
7
+ const outer = init?.signal;
8
+ if (outer?.aborted)
9
+ controller.abort();
10
+ else
11
+ outer?.addEventListener('abort', () => controller.abort(), { once: true });
12
+ let reason;
13
+ const host = (() => {
14
+ try {
15
+ return new URL(typeof input === 'string' ? input : input instanceof URL ? input.href : input.url).host;
16
+ }
17
+ catch {
18
+ return 'the provider';
19
+ }
20
+ })();
21
+ const fail = (message) => {
22
+ reason = new Error(message);
23
+ controller.abort();
24
+ };
25
+ const headerTimer = timeoutMs ? setTimeout(() => fail(`The request to ${host} timed out after ${timeoutMs} ms.`), timeoutMs) : undefined;
26
+ let res;
27
+ try {
28
+ res = await base(input, { ...init, signal: controller.signal });
29
+ }
30
+ catch (err) {
31
+ throw reason ?? err;
32
+ }
33
+ finally {
34
+ if (headerTimer)
35
+ clearTimeout(headerTimer);
36
+ }
37
+ if (!chunkTimeoutMs || !res.body)
38
+ return res;
39
+ const reader = res.body.getReader();
40
+ let idle;
41
+ const arm = (onIdle) => {
42
+ if (idle)
43
+ clearTimeout(idle);
44
+ idle = setTimeout(onIdle, chunkTimeoutMs);
45
+ };
46
+ const body = new ReadableStream({
47
+ start(stream) {
48
+ arm(() => {
49
+ fail(`No data for ${chunkTimeoutMs} ms from ${host}.`);
50
+ stream.error(reason);
51
+ });
52
+ },
53
+ async pull(stream) {
54
+ try {
55
+ const { done, value } = await reader.read();
56
+ if (done) {
57
+ if (idle)
58
+ clearTimeout(idle);
59
+ stream.close();
60
+ return;
61
+ }
62
+ arm(() => {
63
+ fail(`No data for ${chunkTimeoutMs} ms from ${host}.`);
64
+ stream.error(reason);
65
+ void reader.cancel().catch(() => undefined);
66
+ });
67
+ stream.enqueue(value);
68
+ }
69
+ catch (err) {
70
+ if (idle)
71
+ clearTimeout(idle);
72
+ stream.error(reason ?? err);
73
+ }
74
+ },
75
+ cancel(why) {
76
+ if (idle)
77
+ clearTimeout(idle);
78
+ return reader.cancel(why);
79
+ },
80
+ });
81
+ return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers });
82
+ });
83
+ }
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types.js';
3
+ declare const params: z.ZodObject<{
4
+ patch: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ patch: string;
7
+ }, {
8
+ patch: string;
9
+ }>;
10
+ export type PatchOp = {
11
+ kind: 'add';
12
+ path: string;
13
+ content: string;
14
+ } | {
15
+ kind: 'delete';
16
+ path: string;
17
+ } | {
18
+ kind: 'update';
19
+ path: string;
20
+ hunks: Array<{
21
+ lines: Array<{
22
+ tag: ' ' | '-' | '+';
23
+ text: string;
24
+ }>;
25
+ }>;
26
+ };
27
+ /** Parse the patch text into operations. Throws on a malformed patch. */
28
+ export declare function parsePatch(text: string): PatchOp[];
29
+ /** Every path a patch touches, once each; empty when the text is not a valid patch (callers then fall back to the broadest target). */
30
+ export declare function patchedPaths(patch: string): string[];
31
+ export interface PatchPreview {
32
+ path: string;
33
+ /** Text before the patch; null when the file does not exist yet. */
34
+ before: string | null;
35
+ /** Text after the patch; null when the patch deletes the file. */
36
+ after: string | null;
37
+ /** Why this file's change could not be worked out (a hunk that does not match). */
38
+ error?: string;
39
+ }
40
+ /**
41
+ * What an `apply_patch` call would leave in each file, worked out in memory so it can be shown before it is approved.
42
+ * Never writes. Throws only for a patch that cannot be parsed at all.
43
+ */
44
+ export declare function previewPatch(patch: string, read: (path: string) => Promise<string | null>): Promise<PatchPreview[]>;
45
+ export interface ApplyPatchResult {
46
+ files: Array<{
47
+ action: 'add' | 'update' | 'delete';
48
+ path: string;
49
+ }>;
50
+ }
51
+ export declare const applyPatchTool: ToolDefinition<z.infer<typeof params>, ApplyPatchResult>;
52
+ export {};
@@ -0,0 +1,197 @@
1
+ import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { z } from 'zod';
4
+ import { resolveAndCheckPath } from './shared.js';
5
+ import { decodeText, encodeText } from './text-encoding.js';
6
+ const params = z.object({
7
+ patch: z
8
+ .string()
9
+ .min(1)
10
+ .describe('The patch. Starts with "*** Begin Patch", ends with "*** End Patch". Between them, per file: "*** Add File: path" followed by lines starting with +; "*** Delete File: path"; or "*** Update File: path" followed by hunks that begin with "@@" and whose lines start with a space (kept), - (removed) or + (added).'),
11
+ });
12
+ /** Parse the patch text into operations. Throws on a malformed patch. */
13
+ export function parsePatch(text) {
14
+ const lines = text.replace(/\r\n/g, '\n').split('\n');
15
+ while (lines.length && lines[0].trim() === '')
16
+ lines.shift();
17
+ while (lines.length && lines[lines.length - 1].trim() === '')
18
+ lines.pop();
19
+ if (lines[0]?.trim() !== '*** Begin Patch' || lines[lines.length - 1]?.trim() !== '*** End Patch') {
20
+ throw new Error('A patch must start with "*** Begin Patch" and end with "*** End Patch".');
21
+ }
22
+ const body = lines.slice(1, -1);
23
+ const ops = [];
24
+ let i = 0;
25
+ while (i < body.length) {
26
+ const line = body[i];
27
+ if (line.trim() === '') {
28
+ i++;
29
+ continue;
30
+ }
31
+ const add = /^\*\*\* Add File: (.+)$/.exec(line);
32
+ const del = /^\*\*\* Delete File: (.+)$/.exec(line);
33
+ const upd = /^\*\*\* Update File: (.+)$/.exec(line);
34
+ if (add) {
35
+ const content = [];
36
+ i++;
37
+ while (i < body.length && !body[i].startsWith('*** ')) {
38
+ const l = body[i];
39
+ if (!l.startsWith('+'))
40
+ throw new Error(`Add File ${add[1]}: every line must start with + (got "${l.slice(0, 40)}").`);
41
+ content.push(l.slice(1));
42
+ i++;
43
+ }
44
+ ops.push({ kind: 'add', path: add[1].trim(), content: content.length ? `${content.join('\n')}\n` : '' });
45
+ }
46
+ else if (del) {
47
+ ops.push({ kind: 'delete', path: del[1].trim() });
48
+ i++;
49
+ }
50
+ else if (upd) {
51
+ const hunks = [];
52
+ i++;
53
+ while (i < body.length && !body[i].startsWith('*** ')) {
54
+ if (body[i].startsWith('@@')) {
55
+ hunks.push({ lines: [] });
56
+ i++;
57
+ continue;
58
+ }
59
+ const l = body[i];
60
+ const tag = l[0];
61
+ if (tag !== ' ' && tag !== '-' && tag !== '+')
62
+ throw new Error(`Update File ${upd[1]}: bad hunk line "${l.slice(0, 40)}" (start with space, - or +).`);
63
+ if (hunks.length === 0)
64
+ hunks.push({ lines: [] });
65
+ hunks[hunks.length - 1].lines.push({ tag, text: l.slice(1) });
66
+ i++;
67
+ }
68
+ if (hunks.length === 0)
69
+ throw new Error(`Update File ${upd[1]} has no hunks.`);
70
+ ops.push({ kind: 'update', path: upd[1].trim(), hunks });
71
+ }
72
+ else {
73
+ throw new Error(`Unknown patch directive: "${line.slice(0, 60)}"`);
74
+ }
75
+ }
76
+ if (ops.length === 0)
77
+ throw new Error('The patch has no operations.');
78
+ return ops;
79
+ }
80
+ /** Every path a patch touches, once each; empty when the text is not a valid patch (callers then fall back to the broadest target). */
81
+ export function patchedPaths(patch) {
82
+ try {
83
+ return [...new Set(parsePatch(patch).map((o) => o.path))];
84
+ }
85
+ catch {
86
+ return [];
87
+ }
88
+ }
89
+ function indexOfSeq(hay, needle, from, norm) {
90
+ if (needle.length === 0)
91
+ return from;
92
+ outer: for (let s = from; s <= hay.length - needle.length; s++) {
93
+ for (let k = 0; k < needle.length; k++)
94
+ if (norm(hay[s + k]) !== norm(needle[k]))
95
+ continue outer;
96
+ return s;
97
+ }
98
+ return -1;
99
+ }
100
+ /** Apply update hunks to file text, in order, each searching after the previous one. Exact match first, then ignoring trailing whitespace. */
101
+ function applyHunks(file, original, hunks) {
102
+ const eol = original.includes('\r\n') ? '\r\n' : '\n';
103
+ const endsWithNewline = original.endsWith('\n');
104
+ const lines = original.replace(/\r\n/g, '\n').split('\n');
105
+ if (endsWithNewline)
106
+ lines.pop();
107
+ let cursor = 0;
108
+ for (const [n, hunk] of hunks.entries()) {
109
+ const oldSeq = hunk.lines.filter((l) => l.tag !== '+').map((l) => l.text);
110
+ const newSeq = hunk.lines.filter((l) => l.tag !== '-').map((l) => l.text);
111
+ let at = indexOfSeq(lines, oldSeq, cursor, (s) => s);
112
+ if (at === -1)
113
+ at = indexOfSeq(lines, oldSeq, cursor, (s) => s.trimEnd());
114
+ if (at === -1)
115
+ throw new Error(`Hunk ${n + 1} of ${file} did not match the file. Re-read it and make the context lines exact.`);
116
+ lines.splice(at, oldSeq.length, ...newSeq);
117
+ cursor = at + newSeq.length;
118
+ }
119
+ return lines.join(eol) + (endsWithNewline ? eol : '');
120
+ }
121
+ /**
122
+ * What an `apply_patch` call would leave in each file, worked out in memory so it can be shown before it is approved.
123
+ * Never writes. Throws only for a patch that cannot be parsed at all.
124
+ */
125
+ export async function previewPatch(patch, read) {
126
+ const out = [];
127
+ for (const op of parsePatch(patch)) {
128
+ const before = await read(op.path);
129
+ if (op.kind === 'add')
130
+ out.push({ path: op.path, before, after: op.content });
131
+ else if (op.kind === 'delete')
132
+ out.push({ path: op.path, before, after: null });
133
+ else if (before === null)
134
+ out.push({ path: op.path, before, after: null, error: `File not found: ${op.path}` });
135
+ else {
136
+ try {
137
+ out.push({ path: op.path, before, after: applyHunks(op.path, before, op.hunks) });
138
+ }
139
+ catch (err) {
140
+ out.push({ path: op.path, before, after: null, error: err.message });
141
+ }
142
+ }
143
+ }
144
+ return out;
145
+ }
146
+ export const applyPatchTool = {
147
+ name: 'apply_patch',
148
+ description: 'Change several files in one step with a patch: add files, delete files, or update files by hunks of context and changed lines. All or nothing: if one hunk does not match, no file is touched. Prefer edit_file for a single small change.',
149
+ parameters: params,
150
+ destructive: false,
151
+ execute: async (args, ctx) => {
152
+ const ops = parsePatch(args.patch);
153
+ // Plan every change in memory first, so a bad hunk leaves the workspace as it was.
154
+ const writes = new Map();
155
+ const encodings = new Map();
156
+ const deletes = new Set();
157
+ const files = [];
158
+ for (const op of ops) {
159
+ const abs = resolveAndCheckPath(op.path, ctx);
160
+ const rel = op.path.split(String.fromCharCode(92)).join('/');
161
+ if (op.kind === 'add') {
162
+ const exists = await readFile(abs, 'utf8').then(() => true, () => false);
163
+ if ((exists && !deletes.has(abs)) || writes.has(abs))
164
+ throw new Error(`Cannot add ${op.path}: it already exists.`);
165
+ writes.set(abs, op.content);
166
+ files.push({ action: 'add', path: rel });
167
+ }
168
+ else if (op.kind === 'delete') {
169
+ await readFile(abs, 'utf8').catch(() => {
170
+ throw new Error(`Cannot delete ${op.path}: file not found.`);
171
+ });
172
+ deletes.add(abs);
173
+ writes.delete(abs);
174
+ files.push({ action: 'delete', path: rel });
175
+ }
176
+ else {
177
+ let current = writes.get(abs);
178
+ if (current === undefined) {
179
+ const decoded = await readFile(abs).then(decodeText, () => {
180
+ throw new Error(`Cannot update ${op.path}: file not found.`);
181
+ });
182
+ current = decoded.text;
183
+ encodings.set(abs, decoded.encoding);
184
+ }
185
+ writes.set(abs, applyHunks(op.path, current, op.hunks));
186
+ files.push({ action: 'update', path: rel });
187
+ }
188
+ }
189
+ for (const abs of deletes)
190
+ await rm(abs);
191
+ for (const [abs, content] of writes) {
192
+ await mkdir(path.dirname(abs), { recursive: true });
193
+ await writeFile(abs, encodeText(content, encodings.get(abs) ?? 'utf8'));
194
+ }
195
+ return { files };
196
+ },
197
+ };
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types.js';
3
+ /**
4
+ * Ask the person a question with optional choices. The agent only offers this tool when a surface can answer
5
+ * (AgentConfig.askUser) and the run is not autonomous; if it is called anyway, or the run is stopped while the
6
+ * question is open, it returns a result that tells the model to carry on with the safest option.
7
+ */
8
+ declare const params: z.ZodObject<{
9
+ question: z.ZodString;
10
+ options: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
+ allowCustom: z.ZodOptional<z.ZodBoolean>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ question: string;
14
+ options?: string[] | undefined;
15
+ allowCustom?: boolean | undefined;
16
+ }, {
17
+ question: string;
18
+ options?: string[] | undefined;
19
+ allowCustom?: boolean | undefined;
20
+ }>;
21
+ export interface AskUserResult {
22
+ answer: string;
23
+ unavailable?: boolean;
24
+ note?: string;
25
+ }
26
+ export declare const askUserTool: ToolDefinition<z.infer<typeof params>, AskUserResult>;
27
+ export {};
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Ask the person a question with optional choices. The agent only offers this tool when a surface can answer
4
+ * (AgentConfig.askUser) and the run is not autonomous; if it is called anyway, or the run is stopped while the
5
+ * question is open, it returns a result that tells the model to carry on with the safest option.
6
+ */
7
+ const params = z.object({
8
+ question: z.string().min(1).max(1000).describe('One clear question.'),
9
+ options: z.array(z.string().min(1).max(200)).max(8).optional().describe('Suggested answers to pick from.'),
10
+ allowCustom: z.boolean().optional().describe('Let the person type their own answer. Default true.'),
11
+ });
12
+ const UNAVAILABLE = {
13
+ answer: '',
14
+ unavailable: true,
15
+ note: 'No user is available. Choose the safest reasonable option and say what you assumed.',
16
+ };
17
+ export const askUserTool = {
18
+ name: 'ask_user',
19
+ description: 'Ask the user a clarifying question when you cannot proceed safely without their answer. Give a few options when you can. Do not ask for permission to run tools; approvals are handled separately.',
20
+ parameters: params,
21
+ noApproval: true,
22
+ execute: async (args, ctx) => {
23
+ if (!ctx.askUser || ctx.auto)
24
+ return UNAVAILABLE;
25
+ const signal = ctx.abortSignal;
26
+ if (signal?.aborted)
27
+ return UNAVAILABLE;
28
+ const answered = ctx.askUser(args, signal).then((answer) => ({ answer }));
29
+ const aborted = new Promise((resolve) => signal?.addEventListener('abort', () => resolve(UNAVAILABLE), { once: true }));
30
+ return Promise.race([answered, aborted]);
31
+ },
32
+ };
@@ -7,10 +7,10 @@ declare const observeParams: z.ZodObject<{
7
7
  action: z.ZodEnum<["open", "screenshot", "text", "console", "close"]>;
8
8
  url: z.ZodOptional<z.ZodString>;
9
9
  }, "strip", z.ZodTypeAny, {
10
- action: "close" | "open" | "text" | "screenshot" | "console";
10
+ action: "close" | "text" | "open" | "screenshot" | "console";
11
11
  url?: string | undefined;
12
12
  }, {
13
- action: "close" | "open" | "text" | "screenshot" | "console";
13
+ action: "close" | "text" | "open" | "screenshot" | "console";
14
14
  url?: string | undefined;
15
15
  }>;
16
16
  export type BrowserResult = {
@@ -55,24 +55,23 @@ declare const actParams: z.ZodEffects<z.ZodObject<{
55
55
  expression: z.ZodOptional<z.ZodString>;
56
56
  }, "strip", z.ZodTypeAny, {
57
57
  action: "type" | "click" | "evaluate";
58
- expression?: string | undefined;
59
58
  text?: string | undefined;
59
+ expression?: string | undefined;
60
60
  selector?: string | undefined;
61
61
  }, {
62
62
  action: "type" | "click" | "evaluate";
63
- expression?: string | undefined;
64
63
  text?: string | undefined;
64
+ expression?: string | undefined;
65
65
  selector?: string | undefined;
66
66
  }>, {
67
67
  action: "type" | "click" | "evaluate";
68
- expression?: string | undefined;
69
68
  text?: string | undefined;
69
+ expression?: string | undefined;
70
70
  selector?: string | undefined;
71
71
  }, {
72
72
  action: "type" | "click" | "evaluate";
73
- expression?: string | undefined;
74
73
  text?: string | undefined;
74
+ expression?: string | undefined;
75
75
  selector?: string | undefined;
76
76
  }>;
77
77
  export {};
78
- //# sourceMappingURL=browser-tools.d.ts.map
@@ -13,6 +13,7 @@ import { lookup } from 'node:dns/promises';
13
13
  import net from 'node:net';
14
14
  import { z } from 'zod';
15
15
  import { redact } from './redact.js';
16
+ import { isBlockedAddress } from './fetch-url.js';
16
17
  import { checkPolicyViolation } from './policy.js';
17
18
  function isLoopback(ip) {
18
19
  if (net.isIPv4(ip))
@@ -20,20 +21,9 @@ function isLoopback(ip) {
20
21
  const lower = ip.toLowerCase();
21
22
  return lower === '::1' || lower === '::ffff:127.0.0.1';
22
23
  }
24
+ /** Private, link-local or otherwise internal: the same list as `fetch_url`, minus loopback (a local dev server is the point here). */
23
25
  function isPrivateOrLinkLocal(ip) {
24
- if (net.isIPv4(ip)) {
25
- const [a, b] = ip.split('.').map(Number);
26
- return a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 169 && b === 254) || a === 0;
27
- }
28
- if (net.isIPv6(ip)) {
29
- const lower = ip.toLowerCase();
30
- const mapped = lower.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
31
- if (mapped)
32
- return isPrivateOrLinkLocal(mapped[1]);
33
- const first = parseInt(lower.split(':')[0] ?? '', 16);
34
- return (!Number.isNaN(first) && first >= 0xfe80 && first <= 0xfebf) || lower.startsWith('fc') || lower.startsWith('fd');
35
- }
36
- return false;
26
+ return isBlockedAddress(ip) && !isLoopback(ip);
37
27
  }
38
28
  /** Throws unless `rawUrl` is an http(s) URL the browser may visit. */
39
29
  export async function assertBrowsableUrl(rawUrl, policy) {
@@ -136,4 +126,3 @@ const actParams = z
136
126
  if (v.action === 'evaluate' && !v.expression)
137
127
  ctx.addIssue({ code: 'custom', message: 'expression is required' });
138
128
  });
139
- //# sourceMappingURL=browser-tools.js.map