@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,182 @@
1
+ import path from 'node:path';
2
+ import { patchedPaths } from './apply-patch.js';
3
+ import { isOutsideRel } from './shared.js';
4
+ const ACTIONS = new Set(['allow', 'ask', 'deny']);
5
+ /** Flatten a config object into ordered rules; entries with an unknown action are dropped. */
6
+ export function compilePermissionRules(config) {
7
+ const rules = [];
8
+ if (!config || typeof config !== 'object')
9
+ return rules;
10
+ for (const [permission, value] of Object.entries(config)) {
11
+ if (typeof value === 'string') {
12
+ if (ACTIONS.has(value))
13
+ rules.push({ permission, pattern: '*', action: value });
14
+ }
15
+ else if (value && typeof value === 'object') {
16
+ for (const [pattern, action] of Object.entries(value)) {
17
+ if (ACTIONS.has(action))
18
+ rules.push({ permission, pattern, action: action });
19
+ }
20
+ }
21
+ }
22
+ return rules;
23
+ }
24
+ const ci = process.platform === 'win32' ? 'i' : '';
25
+ /**
26
+ * Wildcard match used by permission patterns: `*` and `**` match any run of characters (separators included),
27
+ * `?` one character, `{a,b}` alternatives. A trailing ` *` is optional so `git status *` also matches `git status`.
28
+ */
29
+ function patternToRegex(pattern) {
30
+ let p = pattern;
31
+ let optionalTail = false;
32
+ if (p.endsWith(' *')) {
33
+ p = p.slice(0, -2);
34
+ optionalTail = true;
35
+ }
36
+ let re = '';
37
+ for (let i = 0; i < p.length; i++) {
38
+ const c = p[i];
39
+ if (c === '*') {
40
+ while (p[i + 1] === '*')
41
+ i++;
42
+ re += '.*';
43
+ }
44
+ else if (c === '?')
45
+ re += '.';
46
+ else if (c === '{') {
47
+ const close = p.indexOf('}', i);
48
+ if (close > i) {
49
+ re += '(?:' + p.slice(i + 1, close).split(',').map(escapeRegex).join('|') + ')';
50
+ i = close;
51
+ }
52
+ else
53
+ re += '\\{';
54
+ }
55
+ else
56
+ re += escapeRegex(c);
57
+ }
58
+ return new RegExp('^' + re + (optionalTail ? '(?: .*)?' : '') + '$', ci + 's');
59
+ }
60
+ function escapeRegex(s) {
61
+ return s.replace(/[.+^${}()|[\]\\]/g, '\\$&');
62
+ }
63
+ /** The action of the last rule matching `permission` and `target`, or undefined when none does. */
64
+ export function evaluatePermission(rules, permission, target) {
65
+ const norm = target.replace(/\\/g, '/');
66
+ let result;
67
+ for (const rule of rules) {
68
+ if (rule.permission !== '*' && rule.permission !== permission)
69
+ continue;
70
+ if (patternToRegex(rule.pattern.replace(/\\/g, '/')).test(norm))
71
+ result = rule.action;
72
+ }
73
+ return result;
74
+ }
75
+ /**
76
+ * Split a shell command into the commands a permission rule must each allow: `&&`, `||`, `;`, `|` and newlines
77
+ * outside quotes separate commands; the inside of `$(...)` and backticks is added as extra commands, and an
78
+ * unquoted `>` redirect adds a `redirect:` entry, so an allow rule for `git status *` cannot cover
79
+ * `git status $(rm -rf x)` or `git status > file`.
80
+ */
81
+ export function splitShellCommands(command) {
82
+ const out = [];
83
+ let cur = '';
84
+ let quote = null;
85
+ const push = () => {
86
+ const t = cur.trim();
87
+ if (t)
88
+ out.push(t);
89
+ cur = '';
90
+ };
91
+ for (let i = 0; i < command.length; i++) {
92
+ const c = command[i];
93
+ if (quote) {
94
+ cur += c;
95
+ if (c === quote)
96
+ quote = null;
97
+ continue;
98
+ }
99
+ if (c === '"' || c === "'") {
100
+ quote = c;
101
+ cur += c;
102
+ continue;
103
+ }
104
+ if ((c === '&' && command[i + 1] === '&') || (c === '|' && command[i + 1] === '|')) {
105
+ push();
106
+ i++;
107
+ continue;
108
+ }
109
+ if (c === ';' || c === '|' || c === '\n') {
110
+ push();
111
+ continue;
112
+ }
113
+ cur += c;
114
+ }
115
+ push();
116
+ const extra = [];
117
+ for (const m of command.matchAll(/\$\(([^()]*)\)|`([^`]*)`/g)) {
118
+ for (const inner of splitShellCommands(m[1] ?? m[2] ?? ''))
119
+ extra.push(inner);
120
+ }
121
+ if (/(^|[^>&0-9])>{1,2}(?!&)/.test(stripQuoted(command)))
122
+ extra.push(`redirect: ${command.trim()}`);
123
+ return [...out, ...extra];
124
+ }
125
+ function stripQuoted(s) {
126
+ return s.replace(/"[^"]*"|'[^']*'/g, '""');
127
+ }
128
+ /** `.env` and `.env.*` hold secrets; `.env.example` and `.env.sample` are documentation. */
129
+ export function isSensitiveFile(relPath) {
130
+ const base = relPath.replace(/\\/g, '/').split('/').pop() ?? '';
131
+ if (base === '.env.example' || base === '.env.sample')
132
+ return false;
133
+ return base === '.env' || base.startsWith('.env.');
134
+ }
135
+ /** True when a token of the command points outside `cwd`: `~`, a `..` escape, or an absolute path elsewhere. */
136
+ export function touchesOutsideCwd(command, cwd) {
137
+ const root = path.resolve(cwd);
138
+ for (const raw of command.split(/\s+/)) {
139
+ const tok = raw.replace(/^["']|["']$/g, '');
140
+ if (!tok || tok.startsWith('-') || tok === '/dev/null')
141
+ continue;
142
+ if (tok === '~' || tok.startsWith('~/') || tok.startsWith('~\\'))
143
+ return true;
144
+ const absolute = tok.startsWith('/') || /^[A-Za-z]:[\\/]/.test(tok);
145
+ const escapes = tok.split(/[\\/]/).includes('..');
146
+ if (!absolute && !escapes)
147
+ continue;
148
+ const rel = path.relative(root, path.resolve(root, tok));
149
+ if (isOutsideRel(rel))
150
+ return true;
151
+ }
152
+ return false;
153
+ }
154
+ const READ_TOOLS = new Set(['read_file', 'read_image', 'list_files', 'search_files', 'list_symbols']);
155
+ const EDIT_TOOLS = new Set(['write_file', 'edit_file', 'edit_notebook', 'apply_patch']);
156
+ function relTarget(p, cwd) {
157
+ const raw = typeof p === 'string' && p ? p : '.';
158
+ const abs = path.resolve(cwd, raw);
159
+ const rel = path.relative(path.resolve(cwd), abs).replace(/\\/g, '/');
160
+ return rel === '' ? '.' : isOutsideRel(rel) ? abs.replace(/\\/g, '/') : rel;
161
+ }
162
+ /** Which permission a tool call falls under and the strings the rules are matched against; undefined = no rule applies. */
163
+ export function permissionFor(toolName, args, cwd) {
164
+ const a = (args && typeof args === 'object' ? args : {});
165
+ if (READ_TOOLS.has(toolName))
166
+ return { permission: 'read', targets: [relTarget(a.path, cwd)] };
167
+ if (toolName === 'apply_patch') {
168
+ const paths = patchedPaths(typeof a.patch === 'string' ? a.patch : '');
169
+ return { permission: 'edit', targets: (paths.length ? paths : ['.']).map((p) => relTarget(p, cwd)) };
170
+ }
171
+ if (EDIT_TOOLS.has(toolName))
172
+ return { permission: 'edit', targets: [relTarget(a.path, cwd)] };
173
+ if (toolName === 'run_command')
174
+ return { permission: 'bash', targets: splitShellCommands(typeof a.command === 'string' ? a.command : '') };
175
+ if (toolName === 'fetch_url')
176
+ return { permission: 'webfetch', targets: [typeof a.url === 'string' ? a.url : ''] };
177
+ if (toolName === 'web_search')
178
+ return { permission: 'websearch', targets: [typeof a.query === 'string' ? a.query : ''] };
179
+ if (toolName === 'sub_agent')
180
+ return { permission: 'task', targets: ['sub_agent'] };
181
+ return undefined;
182
+ }
@@ -66,4 +66,3 @@ export declare function normalizePathPattern(pattern: string, _cwd: string): str
66
66
  * project settings files, which concatenate (see sandbox-loader.ts).
67
67
  */
68
68
  export declare function mergeToolSandbox(base: ToolSandbox, override: ToolSandbox): ToolSandbox;
69
- //# sourceMappingURL=policy.d.ts.map
@@ -188,4 +188,3 @@ export function mergeToolSandbox(base, override) {
188
188
  }
189
189
  return merged;
190
190
  }
191
- //# sourceMappingURL=policy.js.map
@@ -21,6 +21,11 @@ export interface ReadFileResult {
21
21
  offset: number;
22
22
  content: string;
23
23
  truncated: boolean;
24
+ /** `AGENTS.md` files of the folders this file sits in, shown the first time a file there is read. */
25
+ folderInstructions?: Array<{
26
+ file: string;
27
+ text: string;
28
+ }>;
24
29
  }
25
30
  /** A PDF comes back whole; the agent attaches it so document-capable models read it natively. */
26
31
  export interface ReadPdfResult {
@@ -31,4 +36,3 @@ export interface ReadPdfResult {
31
36
  }
32
37
  export declare const readFileTool: ToolDefinition<z.infer<typeof params>, ReadFileResult | ReadPdfResult>;
33
38
  export {};
34
- //# sourceMappingURL=read-file.d.ts.map
@@ -2,7 +2,9 @@ import { readFile } from 'node:fs/promises';
2
2
  import { z } from 'zod';
3
3
  import { isNotebookPath, parseNotebook, renderNotebook } from './notebook.js';
4
4
  import { isPdf, MAX_ATTACHMENT_BYTES } from '../attachments.js';
5
+ import { folderInstructionsFor } from '../steering/folder-instructions.js';
5
6
  import { resolveAndCheckPath, truncateByLines } from './shared.js';
7
+ import { decodeText } from './text-encoding.js';
6
8
  const params = z.object({
7
9
  path: z.string().describe('Path to the file to read, relative to the working directory or absolute.'),
8
10
  /** 1-based line number to start reading from. Omit to start at the beginning. */
@@ -47,22 +49,25 @@ export const readFileTool = {
47
49
  return { path: resolved, mime: 'application/pdf', bytes: raw.length, dataUrl: `data:application/pdf;base64,${raw.toString('base64')}` };
48
50
  }
49
51
  // Reject obvious binary content.
50
- if (looksBinary(raw)) {
52
+ const decoded = decodeText(raw);
53
+ if (decoded.encoding === 'utf8' && looksBinary(raw)) {
51
54
  throw new Error(`Refusing to read binary file: ${args.path} (${raw.length} bytes)`);
52
55
  }
53
- const text = raw.toString('utf8');
56
+ const text = decoded.text;
54
57
  const lines = text.split(/\r?\n/);
55
58
  const offset = args.offset ?? 1;
56
59
  const maxLines = args.max_lines ?? 2000;
57
60
  const slice = lines.slice(offset - 1, offset - 1 + maxLines);
58
61
  const endIdx = offset - 1 + maxLines;
59
62
  const truncated = endIdx < lines.length;
63
+ const folderInstructions = ctx.shownFolderInstructions ? await folderInstructionsFor(resolved, ctx.cwd, ctx.shownFolderInstructions) : undefined;
60
64
  return {
61
65
  path: resolved,
62
66
  totalLines: lines.length,
63
67
  offset,
64
68
  content: truncateByLines(slice.map((l, i) => `${String(offset + i).padStart(6)}\t${l}`).join('\n'), maxLines),
65
69
  truncated,
70
+ ...(folderInstructions ? { folderInstructions } : {}),
66
71
  };
67
72
  },
68
73
  };
@@ -75,4 +80,3 @@ function looksBinary(buf) {
75
80
  }
76
81
  return false;
77
82
  }
78
- //# sourceMappingURL=read-file.js.map
@@ -59,4 +59,3 @@ export declare const readImageTool: ToolDefinition<z.infer<typeof params>, ReadI
59
59
  */
60
60
  export declare function sniffMime(buf: Buffer, filePath: string): string | undefined;
61
61
  export {};
62
- //# sourceMappingURL=read-image.d.ts.map
@@ -119,4 +119,3 @@ export function sniffMime(buf, filePath) {
119
119
  default: return undefined;
120
120
  }
121
121
  }
122
- //# sourceMappingURL=read-image.js.map
@@ -3,7 +3,6 @@
3
3
  * anything. Asking before each of them is noise, so they are approved without a prompt by default;
4
4
  * edits, commands, web access and sub-agents still ask.
5
5
  */
6
- export declare const READ_ONLY_TOOLS: readonly ["read_file", "list_files", "search_files", "find_symbol", "list_symbols", "find_references", "codebase_search", "memory_read"];
6
+ export declare const READ_ONLY_TOOLS: readonly ["read_file", "list_files", "search_files", "find_symbol", "list_symbols", "find_references", "codebase_search", "memory_read", "sub_agent_wait"];
7
7
  /** The tools that run without a prompt: the user's list, or the read-only tools when none is set. */
8
8
  export declare function resolveAutoApprove(configured?: readonly string[]): string[];
9
- //# sourceMappingURL=read-only.d.ts.map
@@ -12,9 +12,10 @@ export const READ_ONLY_TOOLS = [
12
12
  'find_references',
13
13
  'codebase_search',
14
14
  'memory_read',
15
+ // Only observes the sub-agents the person already let start.
16
+ 'sub_agent_wait',
15
17
  ];
16
18
  /** The tools that run without a prompt: the user's list, or the read-only tools when none is set. */
17
19
  export function resolveAutoApprove(configured) {
18
20
  return configured ? [...configured] : [...READ_ONLY_TOOLS];
19
21
  }
20
- //# sourceMappingURL=read-only.js.map
@@ -59,4 +59,3 @@ export declare function redact(text: string, options?: RedactOptions): Redaction
59
59
  * the text and just wants the metric.
60
60
  */
61
61
  export declare function countRedactions(text: string, options?: RedactOptions): number;
62
- //# sourceMappingURL=redact.d.ts.map
@@ -106,4 +106,3 @@ export function redact(text, options) {
106
106
  export function countRedactions(text, options) {
107
107
  return redact(text, options).total;
108
108
  }
109
- //# sourceMappingURL=redact.js.map
@@ -66,4 +66,3 @@ export declare class ToolResultCache {
66
66
  * intentionally don't cache destructive tools by default.
67
67
  */
68
68
  export declare function cachedExecute<TArgs, TResult>(toolName: string, execute: (args: TArgs, ctx: ToolContext) => Promise<TResult>, cache: ToolResultCache, ctx: ToolContext): (args: TArgs, ctx: ToolContext) => Promise<TResult>;
69
- //# sourceMappingURL=result-cache.d.ts.map
@@ -133,4 +133,3 @@ export function cachedExecute(toolName, execute, cache, ctx) {
133
133
  return value;
134
134
  };
135
135
  }
136
- //# sourceMappingURL=result-cache.js.map
@@ -14,12 +14,12 @@ declare const params: z.ZodObject<{
14
14
  cwd: z.ZodOptional<z.ZodString>;
15
15
  }, "strip", z.ZodTypeAny, {
16
16
  command: string;
17
- cwd?: string | undefined;
18
17
  timeout_ms?: number | undefined;
18
+ cwd?: string | undefined;
19
19
  }, {
20
20
  command: string;
21
- cwd?: string | undefined;
22
21
  timeout_ms?: number | undefined;
22
+ cwd?: string | undefined;
23
23
  }>;
24
24
  export interface RunCommandResult {
25
25
  command: string;
@@ -31,5 +31,6 @@ export interface RunCommandResult {
31
31
  timedOut: boolean;
32
32
  }
33
33
  export declare const runCommandTool: ToolDefinition<z.infer<typeof params>, RunCommandResult>;
34
+ /** Cut a command's output to `max` characters, keeping the head and the tail. */
35
+ export declare function clampOutput(text: string, max?: number): string;
34
36
  export {};
35
- //# sourceMappingURL=run-command.d.ts.map
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import { z } from 'zod';
3
3
  import { checkPolicyViolation } from './policy.js';
4
4
  import { resolveAndCheckPath } from './shared.js';
5
+ import { shellEnv } from './shell-env.js';
5
6
  /**
6
7
  * Kill a child process and its whole tree. Windows: `taskkill /T`. POSIX: the child is started as the leader of its
7
8
  * own process group (`detached`), and the signal goes to the group (`-pid`); signalling only the shell left whatever
@@ -77,8 +78,8 @@ export const runCommandTool = {
77
78
  command: args.command,
78
79
  exitCode: out.exitCode,
79
80
  signal: out.signal ?? null,
80
- stdout: clampOutput(out.stdout),
81
- stderr: clampOutput(out.stderr),
81
+ stdout: clampOutput(out.stdout, ctx.maxOutputChars),
82
+ stderr: clampOutput(out.stderr, ctx.maxOutputChars),
82
83
  durationMs: Date.now() - started,
83
84
  timedOut: out.timedOut ?? false,
84
85
  };
@@ -93,6 +94,8 @@ export const runCommandTool = {
93
94
  const child = spawn(args.command, {
94
95
  shell: true,
95
96
  cwd,
97
+ // Windows: never run a same-named program the repository ships in its root (see shell-env.ts).
98
+ env: shellEnv(process.env),
96
99
  stdio: ['ignore', 'pipe', 'pipe'],
97
100
  windowsHide: true,
98
101
  // POSIX: own process group, so a kill reaches everything the shell started (see killTree).
@@ -128,8 +131,8 @@ export const runCommandTool = {
128
131
  command: args.command,
129
132
  exitCode: code,
130
133
  signal: signal,
131
- stdout: clampOutput(stdout),
132
- stderr: clampOutput(stderr),
134
+ stdout: clampOutput(stdout, ctx.maxOutputChars),
135
+ stderr: clampOutput(stderr, ctx.maxOutputChars),
133
136
  durationMs: Date.now() - started,
134
137
  timedOut,
135
138
  });
@@ -137,12 +140,12 @@ export const runCommandTool = {
137
140
  });
138
141
  },
139
142
  };
140
- function clampOutput(text) {
141
- if (text.length <= MAX_OUTPUT_CHARS)
143
+ /** Cut a command's output to `max` characters, keeping the head and the tail. */
144
+ export function clampOutput(text, max = MAX_OUTPUT_CHARS) {
145
+ if (text.length <= max)
142
146
  return text;
143
- const half = Math.floor(MAX_OUTPUT_CHARS / 2);
147
+ const half = Math.floor(max / 2);
144
148
  return (text.slice(0, half) +
145
- `\n\n... (${text.length - MAX_OUTPUT_CHARS} characters truncated) ...\n\n` +
149
+ `\n\n... (${text.length - max} characters truncated) ...\n\n` +
146
150
  text.slice(text.length - half));
147
151
  }
148
- //# sourceMappingURL=run-command.js.map
@@ -21,4 +21,3 @@ export declare function loadToolSandboxConfig(cwd: string, opts: {
21
21
  * this function, matching its manually-edited, untrusted-by-default role.
22
22
  */
23
23
  export declare function saveToolSandboxConfig(sandbox: SerializedToolSandbox, settingsPath?: string): Promise<void>;
24
- //# sourceMappingURL=sandbox-loader.d.ts.map
@@ -1,7 +1,6 @@
1
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
1
  import { globalSettingsPath, projectSettingsPath, readSettings } from '../hooks/loader.js';
4
2
  import { validateToolSandboxConfig } from '../hooks/config.js';
3
+ import { updateJsonFile } from '../config-file.js';
5
4
  const REGEX_FIELDS = ['allowedCommands', 'deniedCommands', 'allowedUrls', 'deniedUrls'];
6
5
  const PATH_FIELDS = ['allowedPaths', 'deniedPaths'];
7
6
  /** Compile a single policy's regex-string fields to RegExp, dropping any pattern that fails to compile. */
@@ -118,16 +117,6 @@ export async function loadToolSandboxConfig(cwd, opts, globalPathOverride) {
118
117
  */
119
118
  export async function saveToolSandboxConfig(sandbox, settingsPath) {
120
119
  const filePath = settingsPath ?? globalSettingsPath();
121
- let existing = {};
122
- try {
123
- const raw = await readFile(filePath, 'utf8');
124
- existing = JSON.parse(raw);
125
- }
126
- catch {
127
- // Missing or malformed: start fresh rather than failing the save.
128
- }
129
- const merged = { ...existing, toolSandbox: sandbox };
130
- await mkdir(path.dirname(filePath), { recursive: true });
131
- await writeFile(filePath, JSON.stringify(merged, null, 2) + '\n', 'utf8');
120
+ // A malformed file is refused, not replaced: it holds hooks and other settings this save does not own.
121
+ await updateJsonFile(filePath, (existing) => ({ ...existing, toolSandbox: sandbox }));
132
122
  }
133
- //# sourceMappingURL=sandbox-loader.js.map
@@ -12,15 +12,15 @@ declare const params: z.ZodObject<{
12
12
  }, "strip", z.ZodTypeAny, {
13
13
  pattern: string;
14
14
  path?: string | undefined;
15
- max_results?: number | undefined;
16
15
  include?: string | undefined;
16
+ max_results?: number | undefined;
17
17
  include_ignored?: boolean | undefined;
18
18
  context_lines?: number | undefined;
19
19
  }, {
20
20
  pattern: string;
21
21
  path?: string | undefined;
22
- max_results?: number | undefined;
23
22
  include?: string | undefined;
23
+ max_results?: number | undefined;
24
24
  include_ignored?: boolean | undefined;
25
25
  context_lines?: number | undefined;
26
26
  }>;
@@ -36,5 +36,10 @@ export interface SearchFilesResult {
36
36
  filesScanned: number;
37
37
  }
38
38
  export declare const searchFilesTool: ToolDefinition<z.infer<typeof params>, SearchFilesResult>;
39
+ /**
40
+ * True for a group that contains a repetition and is itself repeated (`(a+)+`, `(\w+\s?)*`, `(x*){2,}`): the shape that
41
+ * makes a backtracking engine take exponential time on a line that almost matches. JavaScript cannot stop a running
42
+ * regex, so such a pattern would freeze the editor; it is refused before it runs.
43
+ */
44
+ export declare function hasNestedRepetition(source: string): boolean;
39
45
  export {};
40
- //# sourceMappingURL=search-files.d.ts.map
@@ -121,7 +121,50 @@ export const searchFilesTool = {
121
121
  return { pattern: args.pattern, matches, truncated, filesScanned };
122
122
  },
123
123
  };
124
+ /**
125
+ * True for a group that contains a repetition and is itself repeated (`(a+)+`, `(\w+\s?)*`, `(x*){2,}`): the shape that
126
+ * makes a backtracking engine take exponential time on a line that almost matches. JavaScript cannot stop a running
127
+ * regex, so such a pattern would freeze the editor; it is refused before it runs.
128
+ */
129
+ export function hasNestedRepetition(source) {
130
+ const groups = []; // per open group: does it contain a repetition?
131
+ let inClass = false;
132
+ const isRepeat = (i) => source[i] === '+' || source[i] === '*' || (source[i] === '{' && /^\{\d*,?\d*\}/.test(source.slice(i)) && !/^\{\d+\}/.test(source.slice(i)));
133
+ for (let i = 0; i < source.length; i++) {
134
+ const c = source[i];
135
+ if (c === '\\') {
136
+ i++;
137
+ continue;
138
+ }
139
+ if (inClass) {
140
+ if (c === ']')
141
+ inClass = false;
142
+ continue;
143
+ }
144
+ if (c === '[') {
145
+ inClass = true;
146
+ }
147
+ else if (c === '(') {
148
+ groups.push(false);
149
+ }
150
+ else if (c === ')') {
151
+ const inner = groups.pop() ?? false;
152
+ if (inner && isRepeat(i + 1))
153
+ return true;
154
+ // A repeated group counts as a repetition inside the group around it.
155
+ if ((inner || isRepeat(i + 1)) && groups.length)
156
+ groups[groups.length - 1] = true;
157
+ }
158
+ else if (isRepeat(i) && groups.length) {
159
+ groups[groups.length - 1] = true;
160
+ }
161
+ }
162
+ return false;
163
+ }
124
164
  function safeRegex(source) {
165
+ if (hasNestedRepetition(source)) {
166
+ throw new Error('Pattern has a repeated group that repeats again (like (a+)+), which can take exponential time on some lines. Simplify it, e.g. a+ instead of (a+)+.');
167
+ }
125
168
  try {
126
169
  return new RegExp(source, 'gm');
127
170
  }
@@ -129,4 +172,3 @@ function safeRegex(source) {
129
172
  throw new Error(`Invalid regex pattern: ${err.message}`);
130
173
  }
131
174
  }
132
- //# sourceMappingURL=search-files.js.map
@@ -9,6 +9,11 @@ import type { ToolContext } from '../types.js';
9
9
  export declare function resolveSafePath(inputPath: string, ctx: ToolContext, options?: {
10
10
  allowOutside?: boolean;
11
11
  }): string;
12
+ /**
13
+ * For a `path.relative(root, target)` result: does it lead out of `root`? `..` itself or `../…` does; a name that merely
14
+ * starts with two dots (`..notes.md`) does not. Use this instead of `rel.startsWith('..')`.
15
+ */
16
+ export declare function isOutsideRel(rel: string): boolean;
12
17
  /**
13
18
  * Convenience: run `resolveSafePath` then enforce the per-tool path policy
14
19
  * (allowedPaths / deniedPaths). Throws on either kind of violation. File
@@ -34,4 +39,3 @@ export declare const DEFAULT_MAX_CHARS = 200000;
34
39
  * silently drift apart.
35
40
  */
36
41
  export declare const DEFAULT_IGNORED_DIRS: Set<string>;
37
- //# sourceMappingURL=shared.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { realpathSync } from 'node:fs';
1
2
  import path from 'node:path';
2
3
  import { checkPolicyViolation } from './policy.js';
3
4
  /**
@@ -12,13 +13,40 @@ export function resolveSafePath(inputPath, ctx, options = {}) {
12
13
  ? path.normalize(inputPath)
13
14
  : path.resolve(ctx.cwd, inputPath);
14
15
  if (!options.allowOutside) {
15
- const rel = path.relative(ctx.cwd, resolved);
16
- if (rel.startsWith('..') || path.isAbsolute(rel)) {
16
+ // Lexically, then for real: a symlink or junction inside the workspace can point anywhere on disk.
17
+ if (escapes(ctx.cwd, resolved) || escapes(realPath(ctx.cwd), realPath(resolved))) {
17
18
  throw new Error(`Path "${inputPath}" resolves outside of the working directory (${ctx.cwd}).`);
18
19
  }
19
20
  }
20
21
  return resolved;
21
22
  }
23
+ /**
24
+ * For a `path.relative(root, target)` result: does it lead out of `root`? `..` itself or `../…` does; a name that merely
25
+ * starts with two dots (`..notes.md`) does not. Use this instead of `rel.startsWith('..')`.
26
+ */
27
+ export function isOutsideRel(rel) {
28
+ return rel === '..' || rel.startsWith(`..${path.sep}`) || rel.startsWith('../') || path.isAbsolute(rel);
29
+ }
30
+ function escapes(root, target) {
31
+ return isOutsideRel(path.relative(root, target));
32
+ }
33
+ /** The real location of `p`: links resolved on the longest part that exists, the rest (a file not yet written) appended. */
34
+ function realPath(p) {
35
+ let existing = p;
36
+ const rest = [];
37
+ for (;;) {
38
+ try {
39
+ return path.join(realpathSync.native(existing), ...rest);
40
+ }
41
+ catch {
42
+ const parent = path.dirname(existing);
43
+ if (parent === existing)
44
+ return p;
45
+ rest.unshift(path.basename(existing));
46
+ existing = parent;
47
+ }
48
+ }
49
+ }
22
50
  /**
23
51
  * Convenience: run `resolveSafePath` then enforce the per-tool path policy
24
52
  * (allowedPaths / deniedPaths). Throws on either kind of violation. File
@@ -61,4 +89,3 @@ export const DEFAULT_MAX_CHARS = 200_000;
61
89
  * silently drift apart.
62
90
  */
63
91
  export const DEFAULT_IGNORED_DIRS = new Set(['node_modules', '.git', 'dist', 'build', 'coverage', '.next', '.cache']);
64
- //# sourceMappingURL=shared.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Environment for a command run through a shell. On Windows, cmd.exe looks for a bare program name in the current
3
+ * directory before PATH, and Forge runs commands in the workspace: a repository could ship `npm.cmd` or `node.cmd`
4
+ * and have it run instead of the real one when the person approves "npm test". `NoDefaultCurrentDirectoryInExePath`
5
+ * tells cmd.exe to skip the current directory; an explicit `.\script.cmd` still works.
6
+ */
7
+ export declare function shellEnv(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Environment for a command run through a shell. On Windows, cmd.exe looks for a bare program name in the current
3
+ * directory before PATH, and Forge runs commands in the workspace: a repository could ship `npm.cmd` or `node.cmd`
4
+ * and have it run instead of the real one when the person approves "npm test". `NoDefaultCurrentDirectoryInExePath`
5
+ * tells cmd.exe to skip the current directory; an explicit `.\script.cmd` still works.
6
+ */
7
+ export function shellEnv(env, platform = process.platform) {
8
+ return platform === 'win32' ? { ...env, NoDefaultCurrentDirectoryInExePath: '1' } : { ...env };
9
+ }
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types.js';
3
+ declare const params: z.ZodObject<{
4
+ ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
5
+ timeout_seconds: z.ZodOptional<z.ZodNumber>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ ids?: string[] | undefined;
8
+ timeout_seconds?: number | undefined;
9
+ }, {
10
+ ids?: string[] | undefined;
11
+ timeout_seconds?: number | undefined;
12
+ }>;
13
+ export interface SubAgentWaitResult {
14
+ agents: Array<{
15
+ id: string;
16
+ task: string;
17
+ state: string;
18
+ finalText?: string;
19
+ error?: string;
20
+ }>;
21
+ stillRunning: number;
22
+ message?: string;
23
+ }
24
+ /**
25
+ * Collect the answers of sub-agents started with `sub_agent { background: true }`. Waits until they finish or the
26
+ * timeout passes, whichever is first; a run that is still going is reported as running and can be waited for again.
27
+ */
28
+ export declare const subAgentWaitTool: ToolDefinition<z.infer<typeof params>, SubAgentWaitResult>;
29
+ export {};