@bastani/atomic 0.9.8 → 0.9.9-alpha.2

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 (814) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +12 -0
  3. package/dist/builtin/cursor/package.json +3 -3
  4. package/dist/builtin/intercom/CHANGELOG.md +13 -0
  5. package/dist/builtin/intercom/package.json +3 -3
  6. package/dist/builtin/mcp/CHANGELOG.md +13 -0
  7. package/dist/builtin/mcp/package.json +4 -4
  8. package/dist/builtin/subagents/CHANGELOG.md +13 -0
  9. package/dist/builtin/subagents/package.json +5 -5
  10. package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +2 -0
  11. package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +7 -1
  12. package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
  13. package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +8 -2
  14. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +2 -0
  15. package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +2 -0
  16. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +2 -1
  17. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +2 -0
  18. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
  19. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
  20. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
  21. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +6 -0
  22. package/dist/builtin/subagents/src/shared/types-config.ts +4 -0
  23. package/dist/builtin/subagents/src/shared/types-depth.ts +29 -2
  24. package/dist/builtin/web-access/CHANGELOG.md +13 -0
  25. package/dist/builtin/web-access/package.json +3 -3
  26. package/dist/builtin/web-access/web-search-tool.ts +1 -2
  27. package/dist/builtin/workflows/CHANGELOG.md +29 -0
  28. package/dist/builtin/workflows/README.md +17 -8
  29. package/dist/builtin/workflows/builtin/goal-prompts.ts +8 -2
  30. package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +26 -9
  31. package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +1 -1
  32. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +8 -3
  33. package/dist/builtin/workflows/builtin/ralph-runner.ts +2 -0
  34. package/dist/builtin/workflows/builtin/shared-prompts.ts +24 -1
  35. package/dist/builtin/workflows/package.json +3 -3
  36. package/dist/builtin/workflows/src/durable/backend.ts +53 -15
  37. package/dist/builtin/workflows/src/durable/completed-catalog.ts +245 -0
  38. package/dist/builtin/workflows/src/durable/completed-inspection.ts +213 -0
  39. package/dist/builtin/workflows/src/durable/dbos-backend.ts +120 -170
  40. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +84 -8
  41. package/dist/builtin/workflows/src/durable/dbos-metadata.ts +98 -0
  42. package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +27 -0
  43. package/dist/builtin/workflows/src/durable/factory.ts +1 -1
  44. package/dist/builtin/workflows/src/durable/file-backend.ts +247 -241
  45. package/dist/builtin/workflows/src/durable/file-lock.ts +153 -0
  46. package/dist/builtin/workflows/src/durable/file-state.ts +104 -0
  47. package/dist/builtin/workflows/src/durable/format-version.ts +12 -0
  48. package/dist/builtin/workflows/src/durable/index.ts +12 -0
  49. package/dist/builtin/workflows/src/durable/resume-catalog.ts +16 -27
  50. package/dist/builtin/workflows/src/durable/resume-eligibility.ts +20 -0
  51. package/dist/builtin/workflows/src/durable/resume-runtime.ts +29 -29
  52. package/dist/builtin/workflows/src/durable/scoped-backend.ts +20 -3
  53. package/dist/builtin/workflows/src/durable/stage-primitive.ts +29 -8
  54. package/dist/builtin/workflows/src/durable/types.ts +3 -0
  55. package/dist/builtin/workflows/src/engine/primitives/task.ts +1 -0
  56. package/dist/builtin/workflows/src/engine/run.ts +14 -14
  57. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +39 -9
  58. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +10 -0
  59. package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +133 -0
  60. package/dist/builtin/workflows/src/extension/runtime.ts +15 -40
  61. package/dist/builtin/workflows/src/extension/wiring.ts +9 -6
  62. package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +226 -0
  63. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +1 -0
  64. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +66 -112
  65. package/dist/builtin/workflows/src/extension/workflow-schema.ts +5 -5
  66. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +16 -1
  67. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +50 -43
  68. package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +91 -0
  69. package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +95 -46
  70. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +3 -1
  71. package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +1 -1
  72. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +3 -0
  73. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +1 -1
  74. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +36 -7
  75. package/dist/builtin/workflows/src/runs/shared/worktree-cache-lifecycle.ts +25 -0
  76. package/dist/builtin/workflows/src/runs/shared/worktree-cwd.ts +103 -0
  77. package/dist/builtin/workflows/src/runs/shared/worktree-generation.ts +57 -0
  78. package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +134 -8
  79. package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -0
  80. package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +43 -0
  81. package/dist/builtin/workflows/src/shared/serializable.ts +1 -1
  82. package/dist/builtin/workflows/src/shared/timing.ts +4 -0
  83. package/dist/builtin/workflows/src/shared/types.ts +5 -3
  84. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -0
  85. package/dist/builtin/workflows/src/tui/graph-view-input.ts +24 -14
  86. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +43 -13
  87. package/dist/bun/cli.d.ts.map +1 -1
  88. package/dist/bun/internal-intercom-broker.d.ts.map +1 -1
  89. package/dist/bun/register-bedrock.d.ts.map +1 -1
  90. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  91. package/dist/bun/split-loader.d.ts.map +1 -1
  92. package/dist/cli/args.d.ts.map +1 -1
  93. package/dist/cli/config-selector.d.ts.map +1 -1
  94. package/dist/cli/file-processor.d.ts.map +1 -1
  95. package/dist/cli/initial-message.d.ts.map +1 -1
  96. package/dist/cli/list-models.d.ts.map +1 -1
  97. package/dist/cli/project-trust.d.ts.map +1 -1
  98. package/dist/cli/session-picker.d.ts.map +1 -1
  99. package/dist/cli/startup-ui.d.ts.map +1 -1
  100. package/dist/cli.d.ts.map +1 -1
  101. package/dist/config-self-update.d.ts.map +1 -1
  102. package/dist/config.d.ts.map +1 -1
  103. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  104. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  105. package/dist/core/agent-session-auto-compaction.js +5 -7
  106. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  107. package/dist/core/agent-session-bash.d.ts.map +1 -1
  108. package/dist/core/agent-session-compaction.d.ts +6 -34
  109. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  110. package/dist/core/agent-session-compaction.js +95 -233
  111. package/dist/core/agent-session-compaction.js.map +1 -1
  112. package/dist/core/agent-session-events.d.ts.map +1 -1
  113. package/dist/core/agent-session-export.d.ts.map +1 -1
  114. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  115. package/dist/core/agent-session-message-queue.d.ts +0 -4
  116. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  117. package/dist/core/agent-session-message-queue.js +1 -5
  118. package/dist/core/agent-session-message-queue.js.map +1 -1
  119. package/dist/core/agent-session-methods.d.ts +5 -6
  120. package/dist/core/agent-session-methods.d.ts.map +1 -1
  121. package/dist/core/agent-session-methods.js.map +1 -1
  122. package/dist/core/agent-session-models.d.ts.map +1 -1
  123. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  124. package/dist/core/agent-session-retry.d.ts.map +1 -1
  125. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  126. package/dist/core/agent-session-services.d.ts.map +1 -1
  127. package/dist/core/agent-session-skill-block.d.ts.map +1 -1
  128. package/dist/core/agent-session-state.d.ts.map +1 -1
  129. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  130. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  131. package/dist/core/agent-session-tree.d.ts.map +1 -1
  132. package/dist/core/agent-session-types.d.ts +2 -12
  133. package/dist/core/agent-session-types.d.ts.map +1 -1
  134. package/dist/core/agent-session-types.js.map +1 -1
  135. package/dist/core/agent-session.d.ts.map +1 -1
  136. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  137. package/dist/core/async/format.d.ts.map +1 -1
  138. package/dist/core/async/job-manager.d.ts.map +1 -1
  139. package/dist/core/async/session-manager.d.ts.map +1 -1
  140. package/dist/core/async/types.d.ts.map +1 -1
  141. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  142. package/dist/core/auth-guidance.d.ts.map +1 -1
  143. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  144. package/dist/core/auth-storage.d.ts +4 -0
  145. package/dist/core/auth-storage.d.ts.map +1 -1
  146. package/dist/core/bash-executor.d.ts.map +1 -1
  147. package/dist/core/builtin-packages.d.ts.map +1 -1
  148. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  149. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  150. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  151. package/dist/core/compaction/branch-summarization.js +1 -2
  152. package/dist/core/compaction/branch-summarization.js.map +1 -1
  153. package/dist/core/compaction/compaction-boundary.d.ts +9 -0
  154. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -0
  155. package/dist/core/compaction/compaction-boundary.js +115 -0
  156. package/dist/core/compaction/compaction-boundary.js.map +1 -0
  157. package/dist/core/compaction/compaction-parameters.d.ts +5 -0
  158. package/dist/core/compaction/compaction-parameters.d.ts.map +1 -0
  159. package/dist/core/compaction/compaction-parameters.js +27 -0
  160. package/dist/core/compaction/compaction-parameters.js.map +1 -0
  161. package/dist/core/compaction/compaction-runner.d.ts +14 -0
  162. package/dist/core/compaction/compaction-runner.d.ts.map +1 -0
  163. package/dist/core/compaction/compaction-runner.js +29 -0
  164. package/dist/core/compaction/compaction-runner.js.map +1 -0
  165. package/dist/core/compaction/compaction-types.d.ts +79 -0
  166. package/dist/core/compaction/compaction-types.d.ts.map +1 -0
  167. package/dist/core/compaction/compaction-types.js +6 -0
  168. package/dist/core/compaction/compaction-types.js.map +1 -0
  169. package/dist/core/compaction/compaction.d.ts.map +1 -1
  170. package/dist/core/compaction/deleted-ranges.d.ts +6 -0
  171. package/dist/core/compaction/deleted-ranges.d.ts.map +1 -0
  172. package/dist/core/compaction/deleted-ranges.js +134 -0
  173. package/dist/core/compaction/deleted-ranges.js.map +1 -0
  174. package/dist/core/compaction/index.d.ts +7 -1
  175. package/dist/core/compaction/index.d.ts.map +1 -1
  176. package/dist/core/compaction/index.js +7 -1
  177. package/dist/core/compaction/index.js.map +1 -1
  178. package/dist/core/compaction/range-planner.d.ts +21 -0
  179. package/dist/core/compaction/range-planner.d.ts.map +1 -0
  180. package/dist/core/compaction/range-planner.js +145 -0
  181. package/dist/core/compaction/range-planner.js.map +1 -0
  182. package/dist/core/compaction/transcript-serialization.d.ts +11 -0
  183. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -0
  184. package/dist/core/compaction/transcript-serialization.js +104 -0
  185. package/dist/core/compaction/transcript-serialization.js.map +1 -0
  186. package/dist/core/compaction/utils.d.ts.map +1 -1
  187. package/dist/core/context-window.d.ts.map +1 -1
  188. package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -1
  189. package/dist/core/copilot-errors.d.ts.map +1 -1
  190. package/dist/core/copilot-gemini-payload-sanitizer.d.ts.map +1 -1
  191. package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
  192. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
  193. package/dist/core/copilot-hosts.d.ts.map +1 -1
  194. package/dist/core/copilot-model-catalog.d.ts.map +1 -1
  195. package/dist/core/copilot-model-static-fallbacks.d.ts.map +1 -1
  196. package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
  197. package/dist/core/defaults.d.ts.map +1 -1
  198. package/dist/core/diagnostics.d.ts.map +1 -1
  199. package/dist/core/event-bus.d.ts.map +1 -1
  200. package/dist/core/exec.d.ts.map +1 -1
  201. package/dist/core/experimental.d.ts.map +1 -1
  202. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  203. package/dist/core/export-html/index.d.ts.map +1 -1
  204. package/dist/core/export-html/template-script.d.ts.map +1 -1
  205. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  206. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  207. package/dist/core/extensions/api-types.d.ts.map +1 -1
  208. package/dist/core/extensions/command-types.d.ts.map +1 -1
  209. package/dist/core/extensions/context-types.d.ts +2 -2
  210. package/dist/core/extensions/context-types.d.ts.map +1 -1
  211. package/dist/core/extensions/context-types.js.map +1 -1
  212. package/dist/core/extensions/event-results.d.ts +2 -2
  213. package/dist/core/extensions/event-results.d.ts.map +1 -1
  214. package/dist/core/extensions/event-results.js.map +1 -1
  215. package/dist/core/extensions/event-types.d.ts.map +1 -1
  216. package/dist/core/extensions/index.d.ts.map +1 -1
  217. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  218. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  219. package/dist/core/extensions/loader-discovery.d.ts.map +1 -1
  220. package/dist/core/extensions/loader-resources.d.ts.map +1 -1
  221. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  222. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  223. package/dist/core/extensions/loader.d.ts.map +1 -1
  224. package/dist/core/extensions/message-types.d.ts.map +1 -1
  225. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  226. package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
  227. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  228. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  229. package/dist/core/extensions/runner-handlers.d.ts.map +1 -1
  230. package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
  231. package/dist/core/extensions/runner-registries.d.ts.map +1 -1
  232. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  233. package/dist/core/extensions/runner-ui.d.ts.map +1 -1
  234. package/dist/core/extensions/runner.d.ts.map +1 -1
  235. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  236. package/dist/core/extensions/session-events.d.ts +7 -7
  237. package/dist/core/extensions/session-events.d.ts.map +1 -1
  238. package/dist/core/extensions/session-events.js.map +1 -1
  239. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  240. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  241. package/dist/core/extensions/types.d.ts.map +1 -1
  242. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  243. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  244. package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
  245. package/dist/core/footer-data-provider.d.ts.map +1 -1
  246. package/dist/core/http-dispatcher.d.ts.map +1 -1
  247. package/dist/core/index.d.ts +1 -1
  248. package/dist/core/index.d.ts.map +1 -1
  249. package/dist/core/index.js.map +1 -1
  250. package/dist/core/keybindings.d.ts.map +1 -1
  251. package/dist/core/messages.d.ts +4 -0
  252. package/dist/core/messages.d.ts.map +1 -1
  253. package/dist/core/messages.js +11 -0
  254. package/dist/core/messages.js.map +1 -1
  255. package/dist/core/model-registry-auth.d.ts.map +1 -1
  256. package/dist/core/model-registry-builtins.d.ts.map +1 -1
  257. package/dist/core/model-registry-builtins.js.map +1 -1
  258. package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
  259. package/dist/core/model-registry-custom-loader.js.map +1 -1
  260. package/dist/core/model-registry-dynamic.d.ts.map +1 -1
  261. package/dist/core/model-registry-loader.d.ts.map +1 -1
  262. package/dist/core/model-registry-schemas.d.ts +65 -13
  263. package/dist/core/model-registry-schemas.d.ts.map +1 -1
  264. package/dist/core/model-registry-schemas.js +5 -1
  265. package/dist/core/model-registry-schemas.js.map +1 -1
  266. package/dist/core/model-registry-types.d.ts.map +1 -1
  267. package/dist/core/model-registry.d.ts.map +1 -1
  268. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  269. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  270. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  271. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  272. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  273. package/dist/core/model-resolver-types.d.ts.map +1 -1
  274. package/dist/core/model-resolver.d.ts.map +1 -1
  275. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
  276. package/dist/core/output-guard.d.ts.map +1 -1
  277. package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
  278. package/dist/core/package-manager-command.d.ts.map +1 -1
  279. package/dist/core/package-manager-constants.d.ts.map +1 -1
  280. package/dist/core/package-manager-env.d.ts.map +1 -1
  281. package/dist/core/package-manager-git.d.ts.map +1 -1
  282. package/dist/core/package-manager-manifest.d.ts.map +1 -1
  283. package/dist/core/package-manager-npm.d.ts.map +1 -1
  284. package/dist/core/package-manager-operations.d.ts.map +1 -1
  285. package/dist/core/package-manager-paths.d.ts.map +1 -1
  286. package/dist/core/package-manager-progress.d.ts.map +1 -1
  287. package/dist/core/package-manager-resolver.d.ts.map +1 -1
  288. package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -1
  289. package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
  290. package/dist/core/package-manager-resource-files.d.ts.map +1 -1
  291. package/dist/core/package-manager-resource-patterns.d.ts.map +1 -1
  292. package/dist/core/package-manager-settings.d.ts.map +1 -1
  293. package/dist/core/package-manager-source.d.ts.map +1 -1
  294. package/dist/core/package-manager-types.d.ts.map +1 -1
  295. package/dist/core/package-manager.d.ts.map +1 -1
  296. package/dist/core/project-trust.d.ts.map +1 -1
  297. package/dist/core/prompt-templates-async.d.ts.map +1 -1
  298. package/dist/core/prompt-templates.d.ts.map +1 -1
  299. package/dist/core/provider-attribution.d.ts.map +1 -1
  300. package/dist/core/provider-context-usage.d.ts.map +1 -1
  301. package/dist/core/provider-context-usage.js +1 -2
  302. package/dist/core/provider-context-usage.js.map +1 -1
  303. package/dist/core/provider-display-names.d.ts.map +1 -1
  304. package/dist/core/resolve-config-value.d.ts.map +1 -1
  305. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  306. package/dist/core/resource-loader-context-files.d.ts.map +1 -1
  307. package/dist/core/resource-loader-core.d.ts.map +1 -1
  308. package/dist/core/resource-loader-discovery.d.ts.map +1 -1
  309. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  310. package/dist/core/resource-loader-helpers.d.ts.map +1 -1
  311. package/dist/core/resource-loader-internals.d.ts.map +1 -1
  312. package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
  313. package/dist/core/resource-loader-paths.d.ts.map +1 -1
  314. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  315. package/dist/core/resource-loader-source-info.d.ts.map +1 -1
  316. package/dist/core/resource-loader-types.d.ts.map +1 -1
  317. package/dist/core/resource-loader.d.ts.map +1 -1
  318. package/dist/core/sdk-exports.d.ts.map +1 -1
  319. package/dist/core/sdk-types.d.ts.map +1 -1
  320. package/dist/core/sdk.d.ts.map +1 -1
  321. package/dist/core/session-cwd.d.ts.map +1 -1
  322. package/dist/core/session-entry-normalization.d.ts.map +1 -1
  323. package/dist/core/session-manager-archive.d.ts +2 -1
  324. package/dist/core/session-manager-archive.d.ts.map +1 -1
  325. package/dist/core/session-manager-archive.js +2 -2
  326. package/dist/core/session-manager-archive.js.map +1 -1
  327. package/dist/core/session-manager-classification.d.ts +9 -0
  328. package/dist/core/session-manager-classification.d.ts.map +1 -0
  329. package/dist/core/session-manager-classification.js +37 -0
  330. package/dist/core/session-manager-classification.js.map +1 -0
  331. package/dist/core/session-manager-core.d.ts +4 -4
  332. package/dist/core/session-manager-core.d.ts.map +1 -1
  333. package/dist/core/session-manager-core.js +13 -8
  334. package/dist/core/session-manager-core.js.map +1 -1
  335. package/dist/core/session-manager-entries.d.ts +4 -3
  336. package/dist/core/session-manager-entries.d.ts.map +1 -1
  337. package/dist/core/session-manager-entries.js +12 -10
  338. package/dist/core/session-manager-entries.js.map +1 -1
  339. package/dist/core/session-manager-history.d.ts +6 -23
  340. package/dist/core/session-manager-history.d.ts.map +1 -1
  341. package/dist/core/session-manager-history.js +23 -256
  342. package/dist/core/session-manager-history.js.map +1 -1
  343. package/dist/core/session-manager-list.d.ts.map +1 -1
  344. package/dist/core/session-manager-list.js +3 -3
  345. package/dist/core/session-manager-list.js.map +1 -1
  346. package/dist/core/session-manager-migrations.d.ts.map +1 -1
  347. package/dist/core/session-manager-paths.d.ts.map +1 -1
  348. package/dist/core/session-manager-storage.d.ts +1 -1
  349. package/dist/core/session-manager-storage.d.ts.map +1 -1
  350. package/dist/core/session-manager-storage.js +3 -2
  351. package/dist/core/session-manager-storage.js.map +1 -1
  352. package/dist/core/session-manager-types.d.ts +14 -15
  353. package/dist/core/session-manager-types.d.ts.map +1 -1
  354. package/dist/core/session-manager-types.js.map +1 -1
  355. package/dist/core/session-manager-validation.d.ts.map +1 -1
  356. package/dist/core/session-manager.d.ts +3 -2
  357. package/dist/core/session-manager.d.ts.map +1 -1
  358. package/dist/core/session-manager.js +1 -1
  359. package/dist/core/session-manager.js.map +1 -1
  360. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  361. package/dist/core/settings-manager-core.d.ts.map +1 -1
  362. package/dist/core/settings-manager-internals.d.ts.map +1 -1
  363. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  364. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  365. package/dist/core/settings-manager.d.ts.map +1 -1
  366. package/dist/core/settings-merge.d.ts.map +1 -1
  367. package/dist/core/settings-storage.d.ts.map +1 -1
  368. package/dist/core/settings-types.d.ts.map +1 -1
  369. package/dist/core/skills-async.d.ts.map +1 -1
  370. package/dist/core/skills.d.ts.map +1 -1
  371. package/dist/core/slash-commands.d.ts.map +1 -1
  372. package/dist/core/slash-commands.js +1 -1
  373. package/dist/core/slash-commands.js.map +1 -1
  374. package/dist/core/source-info.d.ts.map +1 -1
  375. package/dist/core/system-prompt.d.ts.map +1 -1
  376. package/dist/core/telemetry.d.ts.map +1 -1
  377. package/dist/core/thinking-blocks.d.ts.map +1 -1
  378. package/dist/core/timings.d.ts.map +1 -1
  379. package/dist/core/tools/artifact-protocol.d.ts.map +1 -1
  380. package/dist/core/tools/artifacts.d.ts.map +1 -1
  381. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  382. package/dist/core/tools/ask-user-question/config.d.ts.map +1 -1
  383. package/dist/core/tools/ask-user-question/index.d.ts.map +1 -1
  384. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  385. package/dist/core/tools/ask-user-question/state/inline-input.d.ts.map +1 -1
  386. package/dist/core/tools/ask-user-question/state/key-router.d.ts.map +1 -1
  387. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  388. package/dist/core/tools/ask-user-question/state/row-intent.d.ts.map +1 -1
  389. package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts.map +1 -1
  390. package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts.map +1 -1
  391. package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts.map +1 -1
  392. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  393. package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -1
  394. package/dist/core/tools/ask-user-question/state/state.d.ts.map +1 -1
  395. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
  396. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
  397. package/dist/core/tools/ask-user-question/tool/types.d.ts.map +1 -1
  398. package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts.map +1 -1
  399. package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts.map +1 -1
  400. package/dist/core/tools/ask-user-question/view/component-binding.d.ts.map +1 -1
  401. package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts.map +1 -1
  402. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  403. package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts.map +1 -1
  404. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts.map +1 -1
  405. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  406. package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.d.ts.map +1 -1
  407. package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts.map +1 -1
  408. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
  409. package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
  410. package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts.map +1 -1
  411. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  412. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
  413. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -1
  414. package/dist/core/tools/ask-user-question/view/stateful-view.d.ts.map +1 -1
  415. package/dist/core/tools/ask-user-question/view/tab-components.d.ts.map +1 -1
  416. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  417. package/dist/core/tools/bash-async-execution.d.ts.map +1 -1
  418. package/dist/core/tools/bash-async-jobs.d.ts.map +1 -1
  419. package/dist/core/tools/bash-async-output.d.ts.map +1 -1
  420. package/dist/core/tools/bash-interceptor.d.ts.map +1 -1
  421. package/dist/core/tools/bash-leading-cd.d.ts.map +1 -1
  422. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  423. package/dist/core/tools/bash.d.ts.map +1 -1
  424. package/dist/core/tools/block-resolver.d.ts.map +1 -1
  425. package/dist/core/tools/conflict-registry.d.ts.map +1 -1
  426. package/dist/core/tools/directory-tree.d.ts.map +1 -1
  427. package/dist/core/tools/edit-diff-preserve.d.ts.map +1 -1
  428. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  429. package/dist/core/tools/edit.d.ts.map +1 -1
  430. package/dist/core/tools/fetch-url.d.ts.map +1 -1
  431. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  432. package/dist/core/tools/find.d.ts.map +1 -1
  433. package/dist/core/tools/glob-path-utils.d.ts.map +1 -1
  434. package/dist/core/tools/grep.d.ts.map +1 -1
  435. package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -1
  436. package/dist/core/tools/hashline-engine/block.d.ts.map +1 -1
  437. package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -1
  438. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -1
  439. package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -1
  440. package/dist/core/tools/hashline-engine/index.d.ts.map +1 -1
  441. package/dist/core/tools/hashline-engine/input.d.ts.map +1 -1
  442. package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -1
  443. package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -1
  444. package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -1
  445. package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -1
  446. package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -1
  447. package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -1
  448. package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -1
  449. package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -1
  450. package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -1
  451. package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -1
  452. package/dist/core/tools/hashline-engine/types.d.ts.map +1 -1
  453. package/dist/core/tools/hashline.d.ts.map +1 -1
  454. package/dist/core/tools/index.d.ts.map +1 -1
  455. package/dist/core/tools/ls.d.ts.map +1 -1
  456. package/dist/core/tools/notebook.d.ts.map +1 -1
  457. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  458. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
  459. package/dist/core/tools/path-utils.d.ts.map +1 -1
  460. package/dist/core/tools/read-document-extract.d.ts.map +1 -1
  461. package/dist/core/tools/read-selectors.d.ts.map +1 -1
  462. package/dist/core/tools/read-url.d.ts.map +1 -1
  463. package/dist/core/tools/read.d.ts.map +1 -1
  464. package/dist/core/tools/render-utils.d.ts.map +1 -1
  465. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  466. package/dist/core/tools/search-details.d.ts.map +1 -1
  467. package/dist/core/tools/search-line-ranges.d.ts.map +1 -1
  468. package/dist/core/tools/search-native.d.ts.map +1 -1
  469. package/dist/core/tools/search.d.ts.map +1 -1
  470. package/dist/core/tools/structured-output.d.ts.map +1 -1
  471. package/dist/core/tools/todos-execute.d.ts.map +1 -1
  472. package/dist/core/tools/todos-locks.d.ts.map +1 -1
  473. package/dist/core/tools/todos-model.d.ts.map +1 -1
  474. package/dist/core/tools/todos-mutations.d.ts.map +1 -1
  475. package/dist/core/tools/todos-paths.d.ts.map +1 -1
  476. package/dist/core/tools/todos-render.d.ts.map +1 -1
  477. package/dist/core/tools/todos-storage.d.ts.map +1 -1
  478. package/dist/core/tools/todos-types.d.ts.map +1 -1
  479. package/dist/core/tools/todos-types.js +1 -1
  480. package/dist/core/tools/todos-types.js.map +1 -1
  481. package/dist/core/tools/todos.d.ts.map +1 -1
  482. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  483. package/dist/core/tools/tool-definition-wrapper.js +6 -2
  484. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  485. package/dist/core/tools/tool-limits.d.ts.map +1 -1
  486. package/dist/core/tools/truncate.d.ts.map +1 -1
  487. package/dist/core/tools/url-ip-guards.d.ts.map +1 -1
  488. package/dist/core/tools/write.d.ts.map +1 -1
  489. package/dist/core/trust-manager.d.ts.map +1 -1
  490. package/dist/core/typebox-compat.d.ts +12 -0
  491. package/dist/core/typebox-compat.d.ts.map +1 -0
  492. package/dist/core/typebox-compat.js +10 -0
  493. package/dist/core/typebox-compat.js.map +1 -0
  494. package/dist/index-extensions.d.ts.map +1 -1
  495. package/dist/index.d.ts +4 -2
  496. package/dist/index.d.ts.map +1 -1
  497. package/dist/index.js +3 -1
  498. package/dist/index.js.map +1 -1
  499. package/dist/main-app-mode.d.ts.map +1 -1
  500. package/dist/main-deferred-startup.d.ts.map +1 -1
  501. package/dist/main-early-input.d.ts.map +1 -1
  502. package/dist/main-session-options.d.ts.map +1 -1
  503. package/dist/main-session.d.ts +1 -0
  504. package/dist/main-session.d.ts.map +1 -1
  505. package/dist/main-session.js +7 -0
  506. package/dist/main-session.js.map +1 -1
  507. package/dist/main-stdio.d.ts.map +1 -1
  508. package/dist/main.d.ts.map +1 -1
  509. package/dist/main.js +2 -2
  510. package/dist/main.js.map +1 -1
  511. package/dist/migrations-config-values.d.ts.map +1 -1
  512. package/dist/migrations.d.ts.map +1 -1
  513. package/dist/modes/index.d.ts.map +1 -1
  514. package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -1
  515. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  516. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  517. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  518. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  519. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  520. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  521. package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -1
  522. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/chat-message-renderer.js +12 -22
  524. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  525. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  526. package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -1
  527. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  528. package/dist/modes/interactive/components/chat-session-host-events.js +5 -11
  529. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  530. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  531. package/dist/modes/interactive/components/chat-session-host-rendering.js +3 -0
  532. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  533. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
  535. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  536. package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
  537. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  538. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -1
  539. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  540. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  541. package/dist/modes/interactive/components/chat-session-host-utils.js +1 -1
  542. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  543. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  544. package/dist/modes/interactive/components/chat-session-host.js +1 -0
  545. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  546. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  547. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +20 -0
  548. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -0
  549. package/dist/modes/interactive/components/compaction-boundary-message.js +48 -0
  550. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -0
  551. package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
  552. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  553. package/dist/modes/interactive/components/context-window-selector.d.ts.map +1 -1
  554. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  555. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  556. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  557. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  558. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  559. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  560. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  561. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  562. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  563. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  564. package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +1 -1
  565. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  566. package/dist/modes/interactive/components/index.d.ts +1 -1
  567. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  568. package/dist/modes/interactive/components/index.js +1 -1
  569. package/dist/modes/interactive/components/index.js.map +1 -1
  570. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  571. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  572. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  573. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  574. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  575. package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
  576. package/dist/modes/interactive/components/session-selector-header.d.ts.map +1 -1
  577. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  578. package/dist/modes/interactive/components/session-selector-list.js +3 -0
  579. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  580. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  581. package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -1
  582. package/dist/modes/interactive/components/session-selector-types.d.ts.map +1 -1
  583. package/dist/modes/interactive/components/session-selector-utils.d.ts.map +1 -1
  584. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  585. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  586. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  587. package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
  588. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  589. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  590. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  591. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  592. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  593. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  594. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  595. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  596. package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
  597. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  598. package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
  599. package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -1
  600. package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
  601. package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
  602. package/dist/modes/interactive/components/tree-selector-types.d.ts.map +1 -1
  603. package/dist/modes/interactive/components/tree-selector-viewport.d.ts.map +1 -1
  604. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  605. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  606. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  607. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  608. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  609. package/dist/modes/interactive/components/working-status.d.ts.map +1 -1
  610. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  611. package/dist/modes/interactive/interactive-agent-events.js +3 -47
  612. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  613. package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
  614. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  615. package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
  616. package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
  617. package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -1
  618. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  619. package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
  620. package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -1
  621. package/dist/modes/interactive/interactive-extension-custom-ui.d.ts.map +1 -1
  622. package/dist/modes/interactive/interactive-extension-dialogs.d.ts.map +1 -1
  623. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  624. package/dist/modes/interactive/interactive-extension-widgets.d.ts.map +1 -1
  625. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  626. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  627. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  628. package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
  629. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  630. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  631. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  632. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  633. package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -3
  634. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  635. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  636. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  637. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  638. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  639. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
  640. package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
  641. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  642. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  643. package/dist/modes/interactive/interactive-render-chat.js +21 -12
  644. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  645. package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
  646. package/dist/modes/interactive/interactive-resource-paths.d.ts.map +1 -1
  647. package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
  648. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  649. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  650. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  651. package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
  652. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  653. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  654. package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
  655. package/dist/modes/interactive/theme/export-colors.d.ts.map +1 -1
  656. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  657. package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -1
  658. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  659. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  660. package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
  661. package/dist/modes/interactive/theme/theme-parse.d.ts.map +1 -1
  662. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
  663. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  664. package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
  665. package/dist/modes/interactive/whimsical-messages.d.ts.map +1 -1
  666. package/dist/modes/print-mode.d.ts.map +1 -1
  667. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  668. package/dist/modes/rpc/rpc-client.d.ts +3 -5
  669. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  670. package/dist/modes/rpc/rpc-client.js +1 -6
  671. package/dist/modes/rpc/rpc-client.js.map +1 -1
  672. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  673. package/dist/modes/rpc/rpc-command-handler.js +0 -4
  674. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  675. package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
  676. package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
  677. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  678. package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
  679. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  680. package/dist/modes/rpc/rpc-types.d.ts +2 -11
  681. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  682. package/dist/modes/rpc/rpc-types.js.map +1 -1
  683. package/dist/package-manager-cli-parser.d.ts.map +1 -1
  684. package/dist/package-manager-cli.d.ts.map +1 -1
  685. package/dist/rpc-entry.d.ts.map +1 -1
  686. package/dist/utils/ansi.d.ts.map +1 -1
  687. package/dist/utils/changelog.d.ts.map +1 -1
  688. package/dist/utils/child-process.d.ts.map +1 -1
  689. package/dist/utils/clipboard-image.d.ts.map +1 -1
  690. package/dist/utils/clipboard-native.d.ts.map +1 -1
  691. package/dist/utils/clipboard.d.ts.map +1 -1
  692. package/dist/utils/deprecation.d.ts.map +1 -1
  693. package/dist/utils/event-loop.d.ts.map +1 -1
  694. package/dist/utils/exif-orientation.d.ts.map +1 -1
  695. package/dist/utils/frontmatter.d.ts.map +1 -1
  696. package/dist/utils/fs-watch.d.ts.map +1 -1
  697. package/dist/utils/git-env.d.ts.map +1 -1
  698. package/dist/utils/git.d.ts.map +1 -1
  699. package/dist/utils/html.d.ts.map +1 -1
  700. package/dist/utils/image-convert.d.ts.map +1 -1
  701. package/dist/utils/image-process.d.ts.map +1 -1
  702. package/dist/utils/image-resize-core.d.ts.map +1 -1
  703. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  704. package/dist/utils/image-resize.d.ts.map +1 -1
  705. package/dist/utils/json.d.ts.map +1 -1
  706. package/dist/utils/markit.d.ts.map +1 -1
  707. package/dist/utils/mime.d.ts.map +1 -1
  708. package/dist/utils/module-require.d.ts.map +1 -1
  709. package/dist/utils/open-browser.d.ts.map +1 -1
  710. package/dist/utils/paths.d.ts.map +1 -1
  711. package/dist/utils/photon.d.ts.map +1 -1
  712. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  713. package/dist/utils/shell.d.ts.map +1 -1
  714. package/dist/utils/sleep.d.ts.map +1 -1
  715. package/dist/utils/split-launcher.d.ts.map +1 -1
  716. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  717. package/dist/utils/tools-manager.d.ts.map +1 -1
  718. package/dist/utils/version-check.d.ts.map +1 -1
  719. package/dist/utils/windows-self-update.d.ts.map +1 -1
  720. package/docs/compaction.md +97 -772
  721. package/docs/custom-provider.md +7 -1
  722. package/docs/extensions.md +31 -33
  723. package/docs/json.md +2 -2
  724. package/docs/rpc.md +32 -24
  725. package/docs/sdk.md +3 -3
  726. package/docs/session-format.md +49 -30
  727. package/docs/sessions.md +5 -3
  728. package/docs/settings.md +14 -4
  729. package/docs/usage.md +1 -1
  730. package/docs/workflows.md +30 -15
  731. package/examples/extensions/README.md +3 -1
  732. package/examples/extensions/custom-compaction.ts +14 -58
  733. package/examples/extensions/handoff.ts +2 -3
  734. package/examples/extensions/subagent/schemas.ts +1 -1
  735. package/examples/extensions/tic-tac-toe.ts +1 -2
  736. package/examples/extensions/todo.ts +1 -2
  737. package/npm-shrinkwrap.json +214 -98
  738. package/package.json +12 -12
  739. package/dist/core/compaction/context-assistant-turns.d.ts +0 -42
  740. package/dist/core/compaction/context-assistant-turns.d.ts.map +0 -1
  741. package/dist/core/compaction/context-assistant-turns.js +0 -87
  742. package/dist/core/compaction/context-assistant-turns.js.map +0 -1
  743. package/dist/core/compaction/context-compaction-critical.d.ts +0 -15
  744. package/dist/core/compaction/context-compaction-critical.d.ts.map +0 -1
  745. package/dist/core/compaction/context-compaction-critical.js +0 -57
  746. package/dist/core/compaction/context-compaction-critical.js.map +0 -1
  747. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +0 -18
  748. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +0 -1
  749. package/dist/core/compaction/context-compaction-eviction-alternates.js +0 -186
  750. package/dist/core/compaction/context-compaction-eviction-alternates.js.map +0 -1
  751. package/dist/core/compaction/context-compaction-eviction.d.ts +0 -12
  752. package/dist/core/compaction/context-compaction-eviction.d.ts.map +0 -1
  753. package/dist/core/compaction/context-compaction-eviction.js +0 -222
  754. package/dist/core/compaction/context-compaction-eviction.js.map +0 -1
  755. package/dist/core/compaction/context-compaction-metrics.d.ts +0 -28
  756. package/dist/core/compaction/context-compaction-metrics.d.ts.map +0 -1
  757. package/dist/core/compaction/context-compaction-metrics.js +0 -107
  758. package/dist/core/compaction/context-compaction-metrics.js.map +0 -1
  759. package/dist/core/compaction/context-compaction-prompt.d.ts +0 -9
  760. package/dist/core/compaction/context-compaction-prompt.d.ts.map +0 -1
  761. package/dist/core/compaction/context-compaction-prompt.js +0 -163
  762. package/dist/core/compaction/context-compaction-prompt.js.map +0 -1
  763. package/dist/core/compaction/context-compaction-runner.d.ts +0 -11
  764. package/dist/core/compaction/context-compaction-runner.d.ts.map +0 -1
  765. package/dist/core/compaction/context-compaction-runner.js +0 -273
  766. package/dist/core/compaction/context-compaction-runner.js.map +0 -1
  767. package/dist/core/compaction/context-compaction-strategy.d.ts +0 -5
  768. package/dist/core/compaction/context-compaction-strategy.d.ts.map +0 -1
  769. package/dist/core/compaction/context-compaction-strategy.js +0 -27
  770. package/dist/core/compaction/context-compaction-strategy.js.map +0 -1
  771. package/dist/core/compaction/context-compaction-types.d.ts +0 -75
  772. package/dist/core/compaction/context-compaction-types.d.ts.map +0 -1
  773. package/dist/core/compaction/context-compaction-types.js +0 -6
  774. package/dist/core/compaction/context-compaction-types.js.map +0 -1
  775. package/dist/core/compaction/context-compaction.d.ts +0 -10
  776. package/dist/core/compaction/context-compaction.d.ts.map +0 -1
  777. package/dist/core/compaction/context-compaction.js +0 -8
  778. package/dist/core/compaction/context-compaction.js.map +0 -1
  779. package/dist/core/compaction/context-deletion-application.d.ts +0 -14
  780. package/dist/core/compaction/context-deletion-application.d.ts.map +0 -1
  781. package/dist/core/compaction/context-deletion-application.js +0 -261
  782. package/dist/core/compaction/context-deletion-application.js.map +0 -1
  783. package/dist/core/compaction/context-deletion-store.d.ts +0 -78
  784. package/dist/core/compaction/context-deletion-store.d.ts.map +0 -1
  785. package/dist/core/compaction/context-deletion-store.js +0 -162
  786. package/dist/core/compaction/context-deletion-store.js.map +0 -1
  787. package/dist/core/compaction/context-deletion-targets.d.ts +0 -43
  788. package/dist/core/compaction/context-deletion-targets.d.ts.map +0 -1
  789. package/dist/core/compaction/context-deletion-targets.js +0 -292
  790. package/dist/core/compaction/context-deletion-targets.js.map +0 -1
  791. package/dist/core/compaction/context-deletion-tool-definitions.d.ts +0 -193
  792. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +0 -1
  793. package/dist/core/compaction/context-deletion-tool-definitions.js +0 -98
  794. package/dist/core/compaction/context-deletion-tool-definitions.js.map +0 -1
  795. package/dist/core/compaction/context-deletion-tool-helpers.d.ts +0 -19
  796. package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +0 -1
  797. package/dist/core/compaction/context-deletion-tool-helpers.js +0 -210
  798. package/dist/core/compaction/context-deletion-tool-helpers.js.map +0 -1
  799. package/dist/core/compaction/context-deletion-tools.d.ts +0 -4
  800. package/dist/core/compaction/context-deletion-tools.d.ts.map +0 -1
  801. package/dist/core/compaction/context-deletion-tools.js +0 -403
  802. package/dist/core/compaction/context-deletion-tools.js.map +0 -1
  803. package/dist/core/compaction/context-transcript-analysis.d.ts +0 -11
  804. package/dist/core/compaction/context-transcript-analysis.d.ts.map +0 -1
  805. package/dist/core/compaction/context-transcript-analysis.js +0 -228
  806. package/dist/core/compaction/context-transcript-analysis.js.map +0 -1
  807. package/dist/core/session-manager-tool-dependencies.d.ts +0 -10
  808. package/dist/core/session-manager-tool-dependencies.d.ts.map +0 -1
  809. package/dist/core/session-manager-tool-dependencies.js +0 -133
  810. package/dist/core/session-manager-tool-dependencies.js.map +0 -1
  811. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +0 -17
  812. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +0 -1
  813. package/dist/modes/interactive/components/context-compaction-summary-message.js +0 -83
  814. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAa5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAA8E,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAMvI,OAAO,EAAoD,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AACtH,QAAA,MAAM,UAAU;;EAEmB,CAAC;AACpC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAA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AgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, stat as fsStat } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { parseConflictBlocks, registerConflictBlocks } from \"./conflict-registry.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport { buildDirectoryTree } from \"./directory-tree.ts\";\nimport { applyReadLineSelection, extractDocumentMarkdown, isDocumentPath } from \"./read-document-extract.ts\";\nimport { isReadableUrlPath } from \"./fetch-url.ts\";\nimport { readUrlBranch } from \"./read-url.ts\";\nimport { isNotebookPath, readEditableNotebookText } from \"./notebook.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { createHashlineSnapshotStore, formatHashlineContent, recordHashlineSnapshot, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport { formatHashlineSelectedLines, isReadResourceSelector, selectExactReadRanges, selectReadRanges, splitReadLineSelector, type ReadLineSelector } from \"./read-selectors.ts\";\nimport { parseArchiveSelector, readArchiveSelector, readInternalSelector, readSqliteSelector, resolveArchiveSelector, resolveInternalSelector, sqliteSelectorForPath, type InternalResourceContext } from \"./resource-selectors.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"File, directory, archive member, SQLite selector, internal resource, image, document, or URL to read. Append selectors such as :raw, :conflicts, :N, :A-B, :A+C, or :A-B,C-D to scope output.\" }),\n}, { additionalProperties: false });\nexport type ReadToolInput = Static<typeof readSchema>;\nconst READ_TOOL_MAX_RESULT_CHARS = 50_000;\nexport interface OversizedReadDetails {\n\tblocked: true;\n\tpath: string;\n\tchars: number;\n\tmaxChars: number;\n\tstartLine: number;\n\trequestedLimit?: number;\n\ttotalFileLines: number;\n\tfirstLineBytes: number;\n\tbyteGuidance: boolean;\n}\nexport interface ReadToolDetails {\n\tisDirectory?: boolean;\n\tresolvedPath?: string;\n\ttruncation?: TruncationResult;\n\toversizedRead?: OversizedReadDetails;\n\tmeta?: { source?: string; sourcePath?: string; artifactId?: string; truncation?: TruncationResult; limits?: Record<string, number> };\n}\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\nexport interface ReadOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\taccess: (absolutePath: string) => Promise<void>;\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n}\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\nexport interface ReadToolOptions {\n\tautoResizeImages?: boolean;\n\toperations?: ReadOperations;\n\thashlineStore?: HashlineSnapshotStore;\n}\ntype ReadRenderArgs = { path?: string };\nfunction formatReadLineRange(_args: ReadRenderArgs | undefined, _theme: Theme): string {\n\treturn \"\";\n}\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tconst pathDisplay = path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\");\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\nfunction trimTrailingEmptyLines(lines: string[]): string[] { let end = lines.length; while (end > 0 && lines[end - 1] === \"\") end--; return lines.slice(0, end); }\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined { return !model || model.input.includes(\"image\") ? undefined : \"[Current model does not support images. The image will be omitted from this request.]\"; }\nfunction toPosixPath(filePath: string): string { return filePath.split(sep).join(\"/\"); }\nfunction formatCount(count: number): string { return count.toLocaleString(\"en-US\"); }\nfunction shellQuote(value: string): string {\n\treturn `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\nfunction buildOversizedReadMessage(details: OversizedReadDetails): string {\n\tconst pathForExample = JSON.stringify(details.path);\n\tconst rangePathForExample = JSON.stringify(`${details.path}:${details.startLine}+200`);\n\tconst shellPathForExample = shellQuote(details.path);\n\tconst requestedLimitLine =\n\t\tdetails.requestedLimit !== undefined ? [`Requested line limit: ${formatCount(details.requestedLimit)}`] : [];\n\tif (details.byteGuidance) {\n\t\treturn [\n\t\t\t`File read blocked: requested selected range is too large (${formatCount(details.chars)} chars; threshold: ${formatCount(details.maxChars)} chars).`,\n\t\t\t`Path: ${details.path}`,\n\t\t\t...requestedLimitLine,\n\t\t\t\"\",\n\t\t\t\"The selected content starts with a single oversized line, so line pagination is not useful. Read byte slices instead. Examples:\",\n\t\t\t`- Inspect the start of line ${details.startLine}: sed -n '${details.startLine}p' ${shellPathForExample} | head -c ${DEFAULT_MAX_BYTES}`,\n\t\t\t`- Inspect a later byte window: sed -n '${details.startLine}p' ${shellPathForExample} | tail -c +${DEFAULT_MAX_BYTES + 1} | head -c ${DEFAULT_MAX_BYTES}`,\n\t\t\t`- Search for relevant text first: search({ \"pattern\": \"functionName\", \"paths\": ${pathForExample} })`,\n\t\t].join(\"\\n\");\n\t}\n\tconst targetedSnippetOffset = Math.max(details.startLine, 120);\n\tconst snippetPathForExample = JSON.stringify(`${details.path}:${targetedSnippetOffset}+80`);\n\treturn [\n\t\t`File read blocked: requested selected range is too large (${formatCount(details.chars)} chars; threshold: ${formatCount(details.maxChars)} chars).`,\n\t\t`Path: ${details.path}`,\n\t\t...requestedLimitLine,\n\t\t\"\",\n\t\t\"Read only the needed context incrementally. Examples:\",\n\t\t`- Search for relevant symbols first: search({ \"pattern\": \"functionName\", \"paths\": ${pathForExample} })`,\n\t\t`- Read a smaller line range: read({ \"path\": ${rangePathForExample} })`,\n\t\t`- Read a targeted snippet around a match: read({ \"path\": ${snippetPathForExample} })`,\n\t].join(\"\\n\");\n}\nfunction readSourceMeta(source: string): ReadToolDetails { return { meta: { source, sourcePath: source } }; }\nfunction oversizedReadResult(details: OversizedReadDetails): { content: TextContent[]; details: ReadToolDetails } { return { content: [{ type: \"text\", text: buildOversizedReadMessage(details) }], details: { oversizedRead: details, meta: { source: details.path, sourcePath: details.path, limits: { maxChars: details.maxChars }, } } }; }\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.path);\n\tif (!rawPath) return undefined;\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\treturn undefined;\n}\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} Expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tconst oversizedRead = result.details?.oversizedRead;\n\tconst oversizedReadBlocked = oversizedRead?.blocked === true;\n\tif (!options.expanded && !isError && !oversizedReadBlocked) {\n\t\treturn \"\";\n\t}\n\tconst rawPath = str(args?.path);\n\tconst output = oversizedRead ? buildOversizedReadMessage(oversizedRead) : getTextOutput(result, showImages);\n\tconst lang = rawPath && !oversizedReadBlocked ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"Expand\")}${theme.fg(\"muted\", \")\")}`;\n\t}\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\nfunction archiveSelectorMemberExists(pathValue: string, cwd: string): boolean { const archive = parseArchiveSelector(pathValue); if (!archive || !archive.memberPath) return false; try { readArchiveSelector(resolveArchiveSelector(archive, cwd)); return true; } catch { return false; } }\nfunction appendReadSelectors(pathValue: string, selector: ReadLineSelector): string {\n\tconst range = selector.ranges?.map((item) => item.end === undefined ? `${item.start}` : `${item.start}-${item.end}`).join(\",\") ?? (selector.offset ? `${selector.offset}` : \"\");\n\treturn `${pathValue}${range ? `:${range}` : \"\"}${selector.conflicts ? \":conflicts\" : \"\"}${selector.raw ? \":raw\" : \"\"}`;\n}\nexport function createReadToolDefinition(cwd: string, options?: ReadToolOptions): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: \"Read files, directories, archives, SQLite databases, internal resources, images, documents, and URLs through one path string.\",\n\t\tpromptSnippet: \"Read a path selector.\",\n\t\tpromptGuidelines: [\"Use read to inspect file and resource contents; use path selectors for line ranges, raw output, and conflict views.\"],\n\t\tparameters: readSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path }: ReadToolInput,\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst splitSelector = splitReadLineSelector(path), markerless = path.replace(/:raw(?=(:|$))/g, \"\").replace(/:conflicts(?=(:|$))/g, \"\"), sqliteOriginal = sqliteSelectorForPath(markerless, cwd), sqliteDirect = sqliteSelectorForPath(path, cwd);\n\t\t\tconst selector = archiveSelectorMemberExists(path, cwd) ? { path } : sqliteDirect && (sqliteDirect.table === \"raw\" || sqliteDirect.table === \"conflicts\") ? { path } : sqliteOriginal?.rowId && splitSelector.path !== markerless ? { path: markerless, raw: splitSelector.raw, conflicts: splitSelector.conflicts } : sqliteOriginal && splitSelector.path === markerless && markerless !== path ? { path: markerless, raw: splitSelector.raw, conflicts: splitSelector.conflicts } : splitSelector.path === path && sqliteDirect ? { path } : splitSelector;\n\t\t\tconst effectivePath = selector.path;\n\t\t\tconst effectiveOffset = selector.offset;\n\t\t\tconst effectiveLimit = selector.limit;\n\t\t\tconst effectiveRanges = selector.ranges;\n\t\t\tconst rawOutput = selector.raw;\n\t\t\tconst conflictsOnly = selector.conflicts;\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst archive = parseArchiveSelector(effectivePath);\n\t\t\t\t\t\t\tconst sqlite = sqliteSelectorForPath(effectivePath, cwd);\n\t\t\t\t\t\t\tif (isReadableUrlPath(effectivePath)) {\n\t\t\t\t\t\t\t\tresolve(await readUrlBranch({ effectivePath, rawOutput: rawOutput === true, effectiveRanges, effectiveOffset, effectiveLimit, cwd, ctx, signal, maxChars: READ_TOOL_MAX_RESULT_CHARS, maxBytes: DEFAULT_MAX_BYTES, oversized: oversizedReadResult, sourceMeta: readSourceMeta }));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (sqlite) {\n\t\t\t\t\t\t\t\tconst textContent = readSqliteSelector(sqlite), selection = applyReadLineSelection(textContent.split(\"\\n\"), effectiveRanges, effectiveOffset, effectiveLimit, rawOutput), selectedText = selection.lines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif ((effectiveRanges || effectiveOffset) && selection.lines.length === 0) { const requested = effectiveRanges?.[0]?.start ?? effectiveOffset ?? 1; resolve({ content: [{ type: \"text\", text: `Requested line ${requested} is beyond end of resource (${textContent.split(\"\\n\").length} lines total).` }], details: undefined }); return; }\n\t\t\t\t\t\t\t\tif (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES) { resolve(oversizedReadResult({ blocked: true, path: effectivePath, chars: selectedText.length, maxChars: READ_TOOL_MAX_RESULT_CHARS, startLine: selection.firstLine, totalFileLines: textContent.split(\"\\n\").length, firstLineBytes: Buffer.byteLength(selection.lines[0] ?? \"\", \"utf8\"), byteGuidance: false })); return; }\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: selectedText }], details: readSourceMeta(effectivePath) }); return;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (archive) {\n\t\t\t\t\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, cwd);\n\t\t\t\t\t\t\t\tconst textContent = readArchiveSelector(resolvedArchive);\n\t\t\t\t\t\t\t\tlet allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tif (conflictsOnly) {\n\t\t\t\t\t\t\t\t\tlet inConflict = false;\n\t\t\t\t\t\t\t\t\tconst conflictLines = allLines.filter((line) => { if (line.startsWith(\"<<<<<<<\")) inConflict = true; const keep = inConflict; if (line.startsWith(\">>>>>>>\")) inConflict = false; return keep; });\n\t\t\t\t\t\t\t\t\tif (conflictLines.length === 0) { resolve({ content: [{ type: \"text\", text: \"No conflict markers found\" }], details: undefined }); return; }\n\t\t\t\t\t\t\t\t\tallLines = conflictLines;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length || (effectiveRanges && rangeSelection?.selectedLines.length === 0)) {\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).` }], details: undefined });\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst endLine = effectiveLimit !== undefined ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;\n\t\t\t\t\t\t\t\tconst selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tconst selectedText = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES) { resolve(oversizedReadResult({ blocked: true, path: `${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`, chars: selectedText.length, maxChars: READ_TOOL_MAX_RESULT_CHARS, startLine: startLine + 1, totalFileLines: allLines.length, firstLineBytes: Buffer.byteLength(selectedLines[0] ?? \"\", \"utf8\"), byteGuidance: false })); return; }\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: selectedText }], details: readSourceMeta(`${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`) });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (/^(?:skill|agent|artifact|history|issue|local|memory|pr|conflict|omp|rule|mcp|vault):\\/\\//.test(effectivePath)) {\n\t\t\t\t\t\t\t\tconst sourcePath = effectivePath.startsWith(\"local://\") ? resolveInternalSelector(effectivePath, cwd) : undefined;\n\t\t\t\t\t\t\t\tif (sourcePath) { resolve(await createReadToolDefinition(cwd, options).execute(_toolCallId, { path: appendReadSelectors(sourcePath, selector) }, signal, _onUpdate, ctx as never)); return; }\n\t\t\t\t\t\t\t\tconst allLines = (await readInternalSelector(effectivePath, cwd, resourceCtx)).split(\"\\n\");\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length || (effectiveRanges && rangeSelection?.selectedLines.length === 0)) {\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).` }], details: undefined });\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst endLine = effectiveLimit !== undefined ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;\n\t\t\t\t\t\t\t\tconst selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tconst selectedText = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES) { resolve(oversizedReadResult({ blocked: true, path: effectivePath, chars: selectedText.length, maxChars: READ_TOOL_MAX_RESULT_CHARS, startLine: startLine + 1, totalFileLines: allLines.length, firstLineBytes: Buffer.byteLength(selectedLines[0] ?? \"\", \"utf8\"), byteGuidance: false })); return; }\n\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: selectedText }], details: readSourceMeta(effectivePath) });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isReadResourceSelector(effectivePath)) throw new Error(`Read resource selectors are not supported by this filesystem backend: ${path}`);\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(effectivePath, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tif (isDocumentPath(absolutePath) && !rawOutput && !isNotebookPath(absolutePath)) {\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = await extractDocumentMarkdown(buffer, absolutePath);\n\t\t\t\t\t\t\t\tconst selection = applyReadLineSelection(textContent.split(\"\\n\"), effectiveRanges, effectiveOffset, effectiveLimit, rawOutput);\n\t\t\t\t\t\t\t\tif (selection.lines.length === 0) { resolve({ content: [{ type: \"text\", text: `Requested line ${selection.firstLine} is beyond end of document (${textContent.split(\"\\n\").length} lines total).` }], details: undefined }); return; }\n\t\t\t\t\t\t\t\tconst selectedText = selection.lines.join(\"\\n\");\n\t\t\t\t\t\t\tif (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES) { resolve(oversizedReadResult({ blocked: true, path: absolutePath, chars: selectedText.length, maxChars: READ_TOOL_MAX_RESULT_CHARS, startLine: selection.firstLine, totalFileLines: textContent.split(\"\\n\").length, firstLineBytes: Buffer.byteLength(selection.lines[0] ?? \"\", \"utf8\"), byteGuidance: false })); return; }\n\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: selectedText }]; resolve({ content, details: readSourceMeta(absolutePath) }); return;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!options?.operations && (await fsStat(absolutePath)).isDirectory()) {\n\t\t\t\t\t\t\t\tconst tree = await buildDirectoryTree(absolutePath, { maxDepth: 2, perDirLimit: 12, rootLimit: null });\n\t\t\t\t\t\t\t\tconst allLines = tree.rendered.split(\"\\n\"), rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges), startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length || (effectiveRanges && rangeSelection?.selectedLines.length === 0)) { resolve({ content: [{ type: \"text\", text: `Requested line ${startLine + 1} is beyond end of directory (${allLines.length} lines total).` }], details: undefined }); return; }\n\t\t\t\t\t\t\t\tconst endLine = effectiveLimit !== undefined ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length, selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: selectedLines.join(\"\\n\") }];\n\t\t\t\t\t\t\t\tconst meta = { ...readSourceMeta(absolutePath).meta, ...(tree.truncated ? { limits: { perDirLimit: 12, totalLines: tree.totalLines } } : {}) };\n\t\t\t\t\t\t\t\tresolve({ content, details: { isDirectory: true, resolvedPath: absolutePath, meta } });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, { autoResizeImages });\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = (isNotebookPath(absolutePath) && !rawOutput) ? readEditableNotebookText(absolutePath, effectivePath) : buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\tlet allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tlet conflictLineNumbers: number[] | undefined;\n\t\t\t\t\t\t\t\tif (conflictsOnly) {\n\t\t\t\t\t\t\t\t\tregisterConflictBlocks(cwd, parseConflictBlocks(absolutePath, textContent));\n\t\t\t\t\t\t\t\t\tconst conflictLines: string[] = [];\n\t\t\t\t\t\t\t\t\tconflictLineNumbers = [];\n\t\t\t\t\t\t\t\t\tlet inConflict = false;\n\t\t\t\t\t\t\t\t\tallLines.forEach((line, index) => {\n\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\"<<<<<<<\")) inConflict = true;\n\t\t\t\t\t\t\t\t\t\tif (inConflict) { conflictLines.push(line); conflictLineNumbers!.push(index + 1); }\n\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\">>>>>>>\")) inConflict = false;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (conflictLines.length > 0) allLines = conflictLines;\n\t\t\t\t\t\t\t\t\telse { signal?.removeEventListener(\"abort\", onAbort); resolve({ content: [{ type: \"text\", text: \"No conflict markers found\" }], details: undefined }); return; }\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst totalFileLines = allLines.length;\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length || (effectiveRanges && rangeSelection?.selectedLines.length === 0)) {\n\t\t\t\t\t\t\t\t\tconst requested = effectiveRanges?.[0]?.start ?? startLineDisplay;\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: `Requested line ${requested} is beyond end of file (${allLines.length} lines total). Use ${effectivePath}:${Math.max(1, allLines.length)} to read the final line.` }], details: undefined });\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlet selectedContent: string;\n\t\t\t\t\t\t\t\tlet selectedLines: string[];\n\t\t\t\t\t\t\t\tlet userLimitedLines: number | undefined;\n\t\t\t\t\t\t\t\tif (rangeSelection) {\n\t\t\t\t\t\t\t\t\tselectedLines = rangeSelection.selectedLines;\n\t\t\t\t\t\t\t\t\tselectedContent = rangeSelection.selectedContent;\n\t\t\t\t\t\t\t\t\tuserLimitedLines = rangeSelection.userLimitedLines;\n\t\t\t\t\t\t\t\t} else if (effectiveLimit !== undefined) {\n\t\t\t\t\t\t\t\t\tconst endLine = Math.min(startLine + effectiveLimit, allLines.length);\n\t\t\t\t\t\t\t\t\tselectedLines = allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\t\tselectedContent = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\t\tuserLimitedLines = endLine - startLine;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectedLines = allLines.slice(startLine);\n\t\t\t\t\t\t\t\t\tselectedContent = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (selectedContent.length > READ_TOOL_MAX_RESULT_CHARS) {\n\t\t\t\t\t\t\t\t\tconst firstSelectedLine = allLines[startLine] ?? \"\";\n\t\t\t\t\t\t\t\t\tconst firstLineBytes = Buffer.byteLength(firstSelectedLine, \"utf-8\");\n\t\t\t\t\t\t\t\t\tconst selectedLineCount = trimTrailingEmptyLines(selectedLines).length;\n\t\t\t\t\t\t\t\t\tconst byteGuidance = selectedLineCount <= 1 || firstLineBytes > DEFAULT_MAX_BYTES;\n\t\t\t\t\t\t\t\t\tconst oversizedRead: OversizedReadDetails = { blocked: true, path: absolutePath, chars: selectedContent.length, maxChars: READ_TOOL_MAX_RESULT_CHARS, startLine: startLineDisplay, ...(effectiveLimit !== undefined ? { requestedLimit: effectiveLimit } : {}), totalFileLines, firstLineBytes, byteGuidance };\n\t\t\t\t\t\t\t\tdetails = { oversizedRead, meta: readSourceMeta(absolutePath).meta };\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: buildOversizedReadMessage(oversizedRead) }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\t\tlet outputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], \"utf-8\"));\n\t\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${effectivePath} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\tdetails = { truncation, meta: { source: absolutePath, sourcePath: absolutePath, truncation } };\n\t\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\t\toutputText += truncation.truncatedBy === \"lines\" ? `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Continue with path selector :${nextOffset}.]` : `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Continue with path selector :${nextOffset}.]`;\n\t\t\t\t\t\tdetails = { truncation, meta: { source: absolutePath, sourcePath: absolutePath, truncation } };\n\t\t\t\t\t\t\t\t\t} else if (!rawOutput && userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\t\t\t\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Continue with path selector :${nextOffset}.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) content = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tconst snapshot = recordHashlineSnapshot(absolutePath, cwd, textContent, hashlineStore);\n\t\t\t\t\t\t\t\t\t\tconst visibleContent = truncation.truncated ? truncation.content : selectedContent;\n\t\t\t\t\t\t\t\t\t\tconst header = `[${snapshot.displayPath}#${snapshot.tag}]`;\n\t\t\t\t\t\t\t\t\t\tconst selectedConflictLineNumbers = conflictLineNumbers && rangeSelection?.lineNumbers ? rangeSelection.lineNumbers.map((line) => conflictLineNumbers![line - 1]).filter((line): line is number => typeof line === \"number\") : conflictLineNumbers ? conflictLineNumbers.slice(startLine, startLine + selectedLines.length) : undefined;\n\t\t\t\t\t\t\t\t\t\tlet hashlineOutput = rawOutput ? visibleContent : selectedConflictLineNumbers && visibleContent === selectedContent ? formatHashlineSelectedLines(header, selectedLines, selectedConflictLineNumbers) : rangeSelection && visibleContent === selectedContent ? formatHashlineSelectedLines(header, selectedLines, rangeSelection.lineNumbers) : formatHashlineContent(snapshot, visibleContent, startLineDisplay);\n\t\t\t\t\t\t\t\t\t\tif (outputText.startsWith(truncation.content) && outputText.length > truncation.content.length) hashlineOutput += outputText.slice(truncation.content.length);\n\t\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: hashlineOutput }];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\tresolve({ content, details: details ?? readSourceMeta(absolutePath) });\n\t\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification ? formatCompactReadCall(classification, args, theme) : formatReadCall(args, theme),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAa5C,OAAO,KAAK,EAA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,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,SAAS,EACzG,UAAU,EAAE,OAAO,GACjB,MAAM,CAsBR;AAED,MAAM,MAAM,oBAAoB,CAAC,QAAQ,IAAI;IAC5C,OAAO,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,GAAG,MAAM,CAEhG","sourcesContent":["import * as os from \"node:os\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport { getCapabilities, getImageDimensions, hyperlink, imageFallback } from \"@earendil-works/pi-tui\";\nimport type { ThemeColor } from \"../../modes/interactive/theme/theme.ts\";\nimport { stripAnsi } from \"../../utils/ansi.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport { sanitizeBinaryOutput } from \"../../utils/shell.ts\";\n\nexport function shortenPath(path: unknown): string {\n\tif (typeof path !== \"string\") return \"\";\n\tconst home = os.homedir();\n\tif (path.startsWith(home)) {\n\t\treturn `~${path.slice(home.length)}`;\n\t}\n\treturn path;\n}\n\nexport function linkPath(styledText: string, rawPath: string, cwd: string): string {\n\tif (!getCapabilities().hyperlinks) return styledText;\n\tconst absolutePath = resolvePath(rawPath, cwd);\n\treturn hyperlink(styledText, pathToFileURL(absolutePath).href);\n}\n\nexport function renderToolPath(\n\trawPath: string | null,\n\ttheme: { fg: (name: ThemeColor, text: string) => string },\n\tcwd: string,\n\toptions?: { emptyFallback?: string },\n): string {\n\tif (rawPath === null) return invalidArgText(theme);\n\tconst value = rawPath || options?.emptyFallback;\n\tif (!value) return theme.fg(\"toolOutput\", \"...\");\n\treturn linkPath(theme.fg(\"accent\", shortenPath(value)), value, cwd);\n}\n\nexport function str(value: unknown): string | null {\n\tif (typeof value === \"string\") return value;\n\tif (value == null) return \"\";\n\treturn null;\n}\n\nexport function replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nexport function normalizeDisplayText(text: string): string {\n\treturn text.replace(/\\r/g, \"\");\n}\n\nexport function getTextOutput(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> } | undefined,\n\tshowImages: boolean,\n): string {\n\tif (!result) return \"\";\n\n\tconst textBlocks = result.content.filter((c) => c.type === \"text\");\n\tconst imageBlocks = result.content.filter((c) => c.type === \"image\");\n\n\tlet output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || \"\")).replace(/\\r/g, \"\")).join(\"\\n\");\n\n\tconst caps = getCapabilities();\n\tif (imageBlocks.length > 0 && (!caps.images || !showImages)) {\n\t\tconst imageIndicators = imageBlocks\n\t\t\t.map((img) => {\n\t\t\t\tconst mimeType = img.mimeType ?? \"image/unknown\";\n\t\t\t\tconst dims =\n\t\t\t\t\timg.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;\n\t\t\t\treturn imageFallback(mimeType, dims);\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t\toutput = output ? `${output}\\n${imageIndicators}` : imageIndicators;\n\t}\n\n\treturn output;\n}\n\nexport type ToolRenderResultLike<TDetails> = {\n\tcontent: (TextContent | ImageContent)[];\n\tdetails: TDetails;\n};\n\nexport function invalidArgText(theme: { fg: (name: ThemeColor, text: string) => string }): string {\n\treturn theme.fg(\"error\", \"[invalid arg]\");\n}\n"]}
1
+ {"version":3,"file":"render-utils.d.ts","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAKzE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAOjD;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,KAAK,EAAE;IAAE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,EACzD,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,MAAM,CAKR;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,SAAS,EACzG,UAAU,EAAE,OAAO,GACjB,MAAM,CAsBR;AAED,MAAM,MAAM,oBAAoB,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E,MAAM,GAAG,MAAM,GAAG,SAAS,CAA6C;AACpI,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzH;AACD,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzI;AACD,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,UAAQ,EAAE,OAAO,UAAQ,EAAE,OAAO,CAAC,EAAE,uBAAuB,EAAE,aAAa,SAAI,EAAE,YAAY,SAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtN;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAI1I;AAgDD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAsBnE;AAiBD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrF;AACD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,UAAQ,EAAE,aAAa,SAAI,EAAE,YAAY,SAAI,GAAG,MAAM,CAuB/I","sourcesContent":["import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, isAbsolute, relative, resolve } from \"node:path\";\nimport { deflateRawSync, gunzipSync, gzipSync, inflateRawSync } from \"node:zlib\";\nimport { loadNativeSearchBinding } from \"./search-native.ts\";\n\nexport interface ArchiveSelector { archivePath: string; memberPath: string }\nexport interface SqliteSelector { databasePath: string; table?: string; rowId?: string; query?: string; limit?: number; offset?: number; where?: string; order?: string; schema?: boolean; sampleRows?: number }\nexport interface InternalResourceRouter {\n\tread?: (url: string) => string | Buffer | undefined | Promise<string | Buffer | undefined>;\n\twrite?: (url: string, content: string) => void | Promise<void>;\n\tresolve?: (url: string) => string | undefined | Promise<string | undefined>;\n}\nexport interface InternalResourceContext { internalRouter?: InternalResourceRouter; internalResourceRouter?: InternalResourceRouter; resolveInternalUrl?: (url: string) => string | undefined | Promise<string | undefined> }\ntype SqliteValue = string | number | boolean | null;\ninterface SqliteQuery { all(...params: SqliteValue[]): Record<string, SqliteValue>[]; get?(...params: SqliteValue[]): Record<string, SqliteValue> | undefined; iterate?(): Iterable<Record<string, SqliteValue>>; run(...params: SqliteValue[]): { changes?: number; lastInsertRowid?: number | bigint } }\ninterface SqliteDatabase { query(sql: string): SqliteQuery; close(): void }\ntype SqliteDatabaseConstructor = new (path: string, options?: { readonly?: boolean }) => SqliteDatabase;\nfunction sqliteDatabase(): SqliteDatabaseConstructor {\n\ttry { return (createRequire(import.meta.url)(\"bun:sqlite\") as { Database: SqliteDatabaseConstructor }).Database; }\n\tcatch { throw new Error(\"SQLite selectors require Atomic's Bun runtime with bun:sqlite support.\"); }\n}\nfunction existingSqliteFile(path: string): boolean | undefined { if (!existsSync(path)) return undefined; return readFileSync(path).subarray(0, 16).toString(\"binary\") === \"SQLite format 3\\0\"; }\nexport function sqliteSelectorForPath(value: string, cwd: string): SqliteSelector | undefined { const selector = parseSqliteSelector(value); if (!selector) return undefined; const absolute = resolveContainedLocalPath(cwd, selector.databasePath, \"SQLite selector\"); if (existingSqliteFile(absolute) !== true) return undefined; return { ...selector, databasePath: absolute }; }\n\nconst MAX_TAR_ARCHIVE_BYTES = 256 * 1024 * 1024;\nconst MAX_ARCHIVE_MEMBER_BYTES = 64 * 1024 * 1024;\nconst MAX_ARCHIVE_DIRECTORY_ENTRIES = 500;\n\nexport function parseArchiveSelector(value: string): ArchiveSelector | undefined {\n\tconst match = value.match(/^(.+\\.(?:zip|jar|tar|tgz|tar\\.gz|gz)):(.*)$/i);\n\treturn match ? { archivePath: match[1] ?? \"\", memberPath: match[2] ?? \"\" } : undefined;\n}\nexport function resolveArchiveSelector(selector: ArchiveSelector, cwd: string): ArchiveSelector {\n\treturn { ...selector, archivePath: resolveContainedLocalPath(cwd, selector.archivePath, \"Archive selector\") };\n}\nexport function parseSqliteSelector(value: string): SqliteSelector | undefined {\n\tconst match = value.match(/^(.+\\.(?:sqlite3?|db3?))(?:\\?q=(.+)|:([^:?]+)(?:\\?(.+))?(?::([^:?]+))?)?$/i);\n\tif (!match) return undefined;\n\tconst params = new URLSearchParams(match[4] ?? \"\");\n\tconst limit = Number.parseInt(params.get(\"limit\") ?? \"\", 10);\n\tconst offset = Number.parseInt(params.get(\"offset\") ?? \"\", 10);\n\tconst sampleRows = Number.parseInt(params.get(\"sampleRows\") ?? params.get(\"sample_rows\") ?? \"\", 10);\n\treturn { databasePath: match[1] ?? \"\", query: match[2] ? decodeURIComponent(match[2]) : undefined, table: match[3], rowId: match[5] ?? params.get(\"id\") ?? undefined, limit: Number.isFinite(limit) ? Math.max(0, Math.min(500, limit)) : undefined, offset: Number.isFinite(offset) ? Math.max(0, offset) : undefined, where: params.get(\"where\") ?? undefined, order: params.get(\"order\") ?? undefined, schema: params.get(\"schema\") === \"true\" || params.get(\"schema\") === \"1\", sampleRows: Number.isFinite(sampleRows) ? Math.max(0, Math.min(100, sampleRows)) : undefined };\n}\n\nfunction isZipArchive(path: string): boolean { return /\\.(?:zip|jar)$/i.test(path); }\nfunction isGzipTar(path: string): boolean { return /\\.(?:tgz|tar\\.gz|gz)$/i.test(path); }\nfunction crc32(data: Buffer): number {\n\tlet crc = ~0;\n\tfor (const byte of data) { crc ^= byte; for (let i = 0; i < 8; i++) crc = (crc >>> 1) ^ (0xedb88320 & -(crc & 1)); }\n\treturn ~crc >>> 0;\n}\nfunction assertZipRange(buf: Buffer, offset: number, length: number, label: string): void {\n\tif (!Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 0 || offset > buf.length - length) throw new Error(`Invalid zip entry bounds: ${label}`);\n}\nfunction zipEntryPayload(buf: Buffer, label: string, name: string, localOffset: number, compressedSize: number): Buffer {\n\tif (compressedSize > MAX_ARCHIVE_MEMBER_BYTES) throw new Error(`Archive member compressed data too large: ${name}`);\n\tassertZipRange(buf, localOffset, 30, label);\n\tif (buf.readUInt32LE(localOffset) !== 0x04034b50) throw new Error(`Invalid zip local header: ${label}`);\n\tconst localNameLen = buf.readUInt16LE(localOffset + 26), localExtraLen = buf.readUInt16LE(localOffset + 28), start = localOffset + 30 + localNameLen + localExtraLen;\n\tassertZipRange(buf, start, compressedSize, label);\n\treturn buf.subarray(start, start + compressedSize);\n}\nexport function readZipEntriesFromBuffer(buf: Buffer, label: string): Map<string, Buffer> {\n\tconst entries = new Map<string, Buffer>();\n\tlet eocd = -1; for (let i = buf.length - 22; i >= 0; i--) if (buf.readUInt32LE(i) === 0x06054b50) { eocd = i; break; }\n\tif (eocd < 0) throw new Error(`Invalid zip archive: ${label}`);\n\tlet ptr = buf.readUInt32LE(eocd + 16); const total = buf.readUInt16LE(eocd + 10);\n\tfor (let n = 0; n < total; n++) {\n\t\tassertZipRange(buf, ptr, 46, label);\n\t\tif (buf.readUInt32LE(ptr) !== 0x02014b50) throw new Error(`Invalid zip central directory: ${label}`);\n\t\tconst method = buf.readUInt16LE(ptr + 10), compressedSize = buf.readUInt32LE(ptr + 20), size = buf.readUInt32LE(ptr + 24), nameLen = buf.readUInt16LE(ptr + 28), extraLen = buf.readUInt16LE(ptr + 30), commentLen = buf.readUInt16LE(ptr + 32), localOffset = buf.readUInt32LE(ptr + 42);\n\t\tassertZipRange(buf, ptr + 46, nameLen + extraLen + commentLen, label);\n\t\tconst name = buf.subarray(ptr + 46, ptr + 46 + nameLen).toString(); ptr += 46 + nameLen + extraLen + commentLen;\n\t\tif (name.endsWith(\"/\")) continue;\n\t\tif (size > MAX_ARCHIVE_MEMBER_BYTES) throw new Error(`Archive member too large: ${name}`);\n\t\tconst data = zipEntryPayload(buf, label, name, localOffset, compressedSize);\n\t\tentries.set(name, method === 0 ? Buffer.from(data) : method === 8 ? inflateRawSync(data, { maxOutputLength: MAX_ARCHIVE_MEMBER_BYTES }) : (() => { throw new Error(`Unsupported zip compression method ${method} for ${name}`); })());\n\t}\n\treturn entries;\n}\nexport function readZipEntries(path: string): Map<string, Buffer> { return readZipEntriesFromBuffer(readFileSync(path), path); }\nfunction writeZipEntries(path: string, entries: Map<string, Buffer>): void {\n\tconst locals: Buffer[] = [], centrals: Buffer[] = []; let offset = 0;\n\tfor (const [name, data] of entries) {\n\t\tconst nameBuf = Buffer.from(name), compressed = deflateRawSync(data), crc = crc32(data);\n\t\tconst local = Buffer.alloc(30); local.writeUInt32LE(0x04034b50, 0); local.writeUInt16LE(20, 4); local.writeUInt16LE(8, 8); local.writeUInt32LE(crc, 14); local.writeUInt32LE(compressed.length, 18); local.writeUInt32LE(data.length, 22); local.writeUInt16LE(nameBuf.length, 26);\n\t\tlocals.push(local, nameBuf, compressed);\n\t\tconst central = Buffer.alloc(46); central.writeUInt32LE(0x02014b50, 0); central.writeUInt16LE(20, 4); central.writeUInt16LE(20, 6); central.writeUInt16LE(8, 10); central.writeUInt32LE(crc, 16); central.writeUInt32LE(compressed.length, 20); central.writeUInt32LE(data.length, 24); central.writeUInt16LE(nameBuf.length, 28); central.writeUInt32LE(offset, 42);\n\t\tcentrals.push(central, nameBuf); offset += local.length + nameBuf.length + compressed.length;\n\t}\n\tconst centralSize = centrals.reduce((sum, part) => sum + part.length, 0); const eocd = Buffer.alloc(22);\n\teocd.writeUInt32LE(0x06054b50, 0); eocd.writeUInt16LE(entries.size, 8); eocd.writeUInt16LE(entries.size, 10); eocd.writeUInt32LE(centralSize, 12); eocd.writeUInt32LE(offset, 16);\n\twriteFileSync(path, Buffer.concat([...locals, ...centrals, eocd]));\n}\nfunction parseTar(path: string): Map<string, Buffer> {\n\tconst raw = readFileSync(path);\n\tif (raw.length > MAX_TAR_ARCHIVE_BYTES) throw new Error(`Archive too large: ${path}`);\n\tconst buf = isGzipTar(path) ? gunzipSync(raw, { maxOutputLength: MAX_TAR_ARCHIVE_BYTES }) : raw;\n\tif (buf.length > MAX_TAR_ARCHIVE_BYTES) throw new Error(`Archive too large: ${path}`);\n\tconst entries = new Map<string, Buffer>();\n\tfor (let offset = 0; offset + 512 <= buf.length;) {\n\t\tconst header = buf.subarray(offset, offset + 512);\n\t\tif (header.every((byte) => byte === 0)) break;\n\t\tconst name = header.subarray(0, 100).toString().replace(/\\0.*$/, \"\");\n\t\tconst prefix = header.subarray(345, 500).toString().replace(/\\0.*$/, \"\");\n\t\tconst fullName = prefix ? `${prefix}/${name}` : name;\n\t\tconst size = Number.parseInt(header.subarray(124, 136).toString().replace(/\\0.*$/, \"\").trim() || \"0\", 8);\n\t\tconst type = String.fromCharCode(header[156] ?? 48);\n\t\tconst dataStart = offset + 512;\n\t\tif (type !== \"5\" && fullName) {\n\t\t\tif (size > MAX_ARCHIVE_MEMBER_BYTES) throw new Error(`Archive member too large: ${fullName}`);\n\t\t\tentries.set(fullName, Buffer.from(buf.subarray(dataStart, dataStart + size)));\n\t\t}\n\t\toffset = dataStart + Math.ceil(size / 512) * 512;\n\t}\n\treturn entries;\n}\nfunction tarHeader(name: string, size: number): Buffer {\n\tconst header = Buffer.alloc(512); const nameBytes = Buffer.from(name); nameBytes.copy(header, 0, 0, Math.min(100, nameBytes.length));\n\theader.write(\"0000644\\0\", 100); header.write(\"0000000\\0\", 108); header.write(\"0000000\\0\", 116); header.write(size.toString(8).padStart(11, \"0\") + \"\\0\", 124); header.write(\"00000000000\\0\", 136); header.fill(0x20, 148, 156); header[156] = 48; header.write(\"ustar\\0\", 257); header.write(\"00\", 263);\n\tlet sum = 0; for (const byte of header) sum += byte; header.write(sum.toString(8).padStart(6, \"0\") + \"\\0 \", 148); return header;\n}\nfunction writeTar(path: string, entries: Map<string, Buffer>): void {\n\tconst parts: Buffer[] = []; for (const [name, data] of entries) { parts.push(tarHeader(name, data.length), data); const pad = (512 - (data.length % 512)) % 512; if (pad) parts.push(Buffer.alloc(pad)); }\n\tparts.push(Buffer.alloc(1024)); const out = Buffer.concat(parts); writeFileSync(path, isGzipTar(path) ? gzipSync(out) : out);\n}\nfunction listArchiveDirectory(names: Iterable<string>, memberPath: string): string {\n\tconst prefix = memberPath ? `${memberPath.replace(/\\/+$/g, \"\")}/` : \"\";\n\tconst children = new Set<string>();\n\tfor (const name of names) { if (!name.startsWith(prefix) || name === prefix) continue; const rest = name.slice(prefix.length); const [first, ...more] = rest.split(\"/\"); if (first) children.add(more.length > 0 ? `${first}/` : first); }\n\treturn [...children].sort().slice(0, MAX_ARCHIVE_DIRECTORY_ENTRIES).join(\"\\n\");\n}\n\nfunction readZipSelector(path: string, memberPath: string): string {\n\tconst buf = readFileSync(path); let eocd = -1; for (let i = buf.length - 22; i >= 0; i--) if (buf.readUInt32LE(i) === 0x06054b50) { eocd = i; break; }\n\tif (eocd < 0) throw new Error(`Invalid zip archive: ${path}`);\n\tlet ptr = buf.readUInt32LE(eocd + 16); const total = buf.readUInt16LE(eocd + 10), names: string[] = [];\n\tfor (let n = 0; n < total; n++) {\n\t\tassertZipRange(buf, ptr, 46, path);\n\t\tif (buf.readUInt32LE(ptr) !== 0x02014b50) throw new Error(`Invalid zip central directory: ${path}`);\n\t\tconst method = buf.readUInt16LE(ptr + 10), compressedSize = buf.readUInt32LE(ptr + 20), size = buf.readUInt32LE(ptr + 24), nameLen = buf.readUInt16LE(ptr + 28), extraLen = buf.readUInt16LE(ptr + 30), commentLen = buf.readUInt16LE(ptr + 32), localOffset = buf.readUInt32LE(ptr + 42);\n\t\tassertZipRange(buf, ptr + 46, nameLen + extraLen + commentLen, path);\n\t\tconst name = buf.subarray(ptr + 46, ptr + 46 + nameLen).toString(); ptr += 46 + nameLen + extraLen + commentLen; if (name.endsWith(\"/\")) continue; names.push(name); if (memberPath && name !== memberPath) continue;\n\t\tif (!memberPath) continue; if (size > MAX_ARCHIVE_MEMBER_BYTES) throw new Error(`Archive member too large: ${memberPath}`);\n\t\tconst data = zipEntryPayload(buf, path, name, localOffset, compressedSize);\n\t\treturn (method === 0 ? Buffer.from(data) : method === 8 ? inflateRawSync(data, { maxOutputLength: MAX_ARCHIVE_MEMBER_BYTES }) : (() => { throw new Error(`Unsupported zip compression method ${method} for ${name}`); })()).toString(\"utf8\");\n\t}\n\tconst listing = listArchiveDirectory(names, memberPath);\n\tif (listing) return listing;\n\tif (!memberPath) return \"\";\n\tthrow new Error(`Archive member not found: ${memberPath}`);\n}\n\nexport function readArchiveSelector(selector: ArchiveSelector): string {\n\tif (isZipArchive(selector.archivePath)) return readZipSelector(selector.archivePath, selector.memberPath);\n\tconst entries = parseTar(selector.archivePath);\n\tif (!selector.memberPath) return listArchiveDirectory(entries.keys(), \"\");\n\tconst data = entries.get(selector.memberPath); if (data) { if (data.length > MAX_ARCHIVE_MEMBER_BYTES) throw new Error(`Archive member too large: ${selector.memberPath}`); return data.toString(\"utf8\"); }\n\tconst listing = listArchiveDirectory(entries.keys(), selector.memberPath); if (listing) return listing;\n\tthrow new Error(`Archive member not found: ${selector.memberPath}`);\n}\nfunction validateArchiveMemberPath(memberPath: string): void { if (!memberPath || memberPath.startsWith(\"/\") || memberPath.endsWith(\"/\") || memberPath.split(\"/\").includes(\"..\")) throw new Error(`Invalid archive member path: ${memberPath}`); }\nfunction writeZipEntrySelective(path: string, memberPath: string, data: Buffer): void {\n\tconst source = existsSync(path) ? readFileSync(path) : Buffer.alloc(0); const locals: Buffer[] = [], centrals: Buffer[] = []; let offset = 0;\n\tif (source.length > 0) {\n\t\tlet eocd = -1; for (let i = source.length - 22; i >= 0; i--) if (source.readUInt32LE(i) === 0x06054b50) { eocd = i; break; }\n\t\tif (eocd < 0) throw new Error(`Invalid zip archive: ${path}`);\n\t\tlet ptr = source.readUInt32LE(eocd + 16); const total = source.readUInt16LE(eocd + 10);\n\t\tfor (let n = 0; n < total; n++) {\n\t\t\tassertZipRange(source, ptr, 46, path);\n\t\t\tconst start = ptr, flags = source.readUInt16LE(ptr + 8), nameLen = source.readUInt16LE(ptr + 28), extraLen = source.readUInt16LE(ptr + 30), commentLen = source.readUInt16LE(ptr + 32), localOffset = source.readUInt32LE(ptr + 42), compressedSize = source.readUInt32LE(ptr + 20);\n\t\t\tassertZipRange(source, ptr + 46, nameLen + extraLen + commentLen, path);\n\t\t\tconst name = source.subarray(ptr + 46, ptr + 46 + nameLen).toString(); ptr += 46 + nameLen + extraLen + commentLen; if (name === memberPath) continue;\n\t\t\tif ((flags & 0x0008) !== 0) throw new Error(`Unsupported zip data descriptor during selective write: ${name}`);\n\t\t\tassertZipRange(source, localOffset, 30, path);\n\t\t\tconst localNameLen = source.readUInt16LE(localOffset + 26), localExtraLen = source.readUInt16LE(localOffset + 28), localEnd = localOffset + 30 + localNameLen + localExtraLen + compressedSize;\n\t\t\tassertZipRange(source, localOffset, localEnd - localOffset, path);\n\t\t\tconst local = source.subarray(localOffset, localEnd), central = Buffer.from(source.subarray(start, ptr)); central.writeUInt32LE(offset, 42); locals.push(local); centrals.push(central); offset += local.length;\n\t\t}\n\t}\n\tconst tmp = `${path}.atomic-entry-${Date.now()}`; writeZipEntries(tmp, new Map([[memberPath, data]])); const built = readFileSync(tmp); rmSync(tmp, { force: true });\n\tconst eocdStart = built.length - 22, localLen = built.readUInt32LE(eocdStart + 16), centralSizeOne = built.readUInt32LE(eocdStart + 12); const central = Buffer.from(built.subarray(localLen, localLen + centralSizeOne)); central.writeUInt32LE(offset, 42); locals.push(built.subarray(0, localLen)); centrals.push(central); offset += localLen;\n\tconst centralSize = centrals.reduce((sum, part) => sum + part.length, 0), eocd = Buffer.alloc(22); eocd.writeUInt32LE(0x06054b50, 0); eocd.writeUInt16LE(centrals.length, 8); eocd.writeUInt16LE(centrals.length, 10); eocd.writeUInt32LE(centralSize, 12); eocd.writeUInt32LE(offset, 16); writeFileSync(path, Buffer.concat([...locals, ...centrals, eocd]));\n}\n\nexport function writeArchiveSelector(selector: ArchiveSelector, content: string): void {\n\tvalidateArchiveMemberPath(selector.memberPath); mkdirSync(dirname(selector.archivePath), { recursive: true });\n\tif (isZipArchive(selector.archivePath)) { writeZipEntrySelective(selector.archivePath, selector.memberPath, Buffer.from(content)); return; }\n\tconst entries = existsSync(selector.archivePath) ? parseTar(selector.archivePath) : new Map<string, Buffer>();\n\tentries.set(selector.memberPath, Buffer.from(content)); writeTar(selector.archivePath, entries);\n}\nconst SEARCH_LINE_LIMIT = 512;\nfunction truncateSearchLine(line: string): string {\n\treturn line.length > SEARCH_LINE_LIMIT ? `${line.slice(0, SEARCH_LINE_LIMIT)}… [truncated]` : line;\n}\nfunction stripExtendedRegexWhitespace(pattern: string): string {\n\tlet out = \"\", escaped = false, inClass = false, inComment = false;\n\tfor (const ch of pattern) {\n\t\tif (inComment) { if (ch === \"\\n\" || ch === \"\\r\") inComment = false; continue; }\n\t\tif (escaped) { out += ch; escaped = false; continue; }\n\t\tif (ch === \"\\\\\") { out += ch; escaped = true; continue; }\n\t\tif (ch === \"[\") inClass = true; else if (ch === \"]\") inClass = false;\n\t\tif (!inClass && ch === \"#\") { inComment = true; continue; }\n\t\tif (!inClass && /\\s/.test(ch)) continue;\n\t\tout += ch;\n\t}\n\treturn out;\n}\n\nfunction normalizeSearchPattern(pattern: string, ignoreCase: boolean): { pattern: string; flags: string } {\n\tconst match = pattern.match(/^\\(\\?([imsUx-]+)\\)([\\s\\S]*)$/);\n\tconst flags = new Set<string>(); if (ignoreCase) flags.add(\"i\");\n\tif (match) { const inline = match[1] ?? \"\"; for (const flag of inline) { if (flag === \"i\" || flag === \"m\" || flag === \"s\") flags.add(flag); } return { pattern: inline.includes(\"x\") ? stripExtendedRegexWhitespace(match[2] ?? \"\") : match[2] ?? \"\", flags: [...flags].join(\"\") }; }\n\treturn { pattern, flags: [...flags].join(\"\") };\n}\n\nfunction searchTextSelectorLines(label: string, text: string, pattern: string, ignoreCase: boolean, literal: boolean, contextBefore = 1, contextAfter = 3): string[] {\n\tconst normalized = normalizeSearchPattern(pattern, ignoreCase);\n\tif (!literal && !normalized.pattern.includes(\"\\n\") && !pattern.includes(\"\\\\n\")) try { const native = loadNativeSearchBinding()?.search?.(text, { pattern: normalized.pattern, ignoreCase: normalized.flags.includes(\"i\"), multiline: normalized.flags.includes(\"m\") || normalized.flags.includes(\"s\"), contextBefore, contextAfter }); if (native && !native.error) return native.matches.flatMap((match) => [...(match.contextBefore ?? []).map((line) => `${label}-${line.lineNumber}- ${truncateSearchLine(line.line)}`), `${label}:${match.lineNumber}: ${truncateSearchLine(match.line)}`, ...(match.contextAfter ?? []).map((line) => `${label}-${line.lineNumber}- ${truncateSearchLine(line.line)}`)]); } catch {}\n\tconst matcher = literal ? undefined : new RegExp(normalized.pattern, normalized.flags);\n\tconst needle = normalized.flags.includes(\"i\") ? normalized.pattern.toLowerCase() : normalized.pattern;\n\tconst lines = text.split(\"\\n\");\n\tconst matchLines = new Set<number>();\n\tlines.forEach((line, index) => { const haystack = normalized.flags.includes(\"i\") ? line.toLowerCase() : line; if (matcher ? matcher.test(line) : haystack.includes(needle)) matchLines.add(index + 1); });\n\tif (matchLines.size === 0 && matcher) { const match = new RegExp(normalized.pattern, normalized.flags).exec(text); if (match?.[0]) { const start = text.slice(0, match.index).split(\"\\n\").length; for (let line = start; line < start + match[0].split(\"\\n\").length; line++) matchLines.add(line); } }\n\tconst outputLines = new Set<number>();\n\tfor (const line of matchLines) for (let n = Math.max(1, line - contextBefore); n <= Math.min(lines.length, line + contextAfter); n++) outputLines.add(n);\n\treturn [...outputLines].sort((a, b) => a - b).map((line) => `${label}${matchLines.has(line) ? \":\" : \"-\"}${line}${matchLines.has(line) ? \":\" : \"-\"} ${truncateSearchLine(lines[line - 1] ?? \"\")}`);\n}\n\nexport function searchArchiveSelector(selector: ArchiveSelector, pattern: string, ignoreCase = false, literal = false, contextBefore = 1, contextAfter = 3): string {\n\tif (isZipArchive(selector.archivePath) && selector.memberPath) return searchTextSelectorLines(`${selector.archivePath}:${selector.memberPath}`, readArchiveSelector(selector), pattern, ignoreCase, literal, contextBefore, contextAfter).join(\"\\n\");\n\tconst entries = isZipArchive(selector.archivePath) ? readZipEntries(selector.archivePath) : parseTar(selector.archivePath); const out: string[] = [];\n\tfor (const [name, data] of entries) { if (selector.memberPath && name !== selector.memberPath) continue; out.push(...searchTextSelectorLines(`${selector.archivePath}:${name}`, data.toString(\"utf8\"), pattern, ignoreCase, literal, contextBefore, contextAfter)); }\n\treturn out.join(\"\\n\");\n}\n\nfunction routerFromContext(context?: InternalResourceContext): InternalResourceRouter | undefined { return context?.internalRouter ?? context?.internalResourceRouter; }\nasync function resolveViaRouter(value: string, cwd: string, context?: InternalResourceContext): Promise<string | undefined> {\n\tconst router = routerFromContext(context); const routed = await router?.resolve?.(value); if (routed) return routed;\n\tconst resolved = await context?.resolveInternalUrl?.(value); if (resolved) return resolved;\n\treturn resolveInternalSelector(value, cwd);\n}\nfunction isContained(root: string, candidate: string): boolean {\n\tconst rel = relative(root, candidate);\n\treturn rel === \"\" || (!rel.startsWith(\"..\") && !isAbsolute(rel));\n}\nfunction nearestExistingAncestor(pathValue: string): string {\n\tlet current = pathValue;\n\twhile (!existsSync(current)) { const parent = dirname(current); if (parent === current) return current; current = parent; }\n\treturn current;\n}\nfunction realpathExisting(pathValue: string): string { return realpathSync.native(nearestExistingAncestor(pathValue)); }\nfunction resolveContainedPath(root: string, pathValue: string, label: string): string {\n\tconst lexicalRoot = resolve(root), resolved = resolve(root, pathValue);\n\tif (!isContained(lexicalRoot, resolved)) throw new Error(`${label} escapes the workspace: ${pathValue}`);\n\tif (!isContained(realpathExisting(lexicalRoot), realpathExisting(resolved))) throw new Error(`${label} escapes the workspace: ${pathValue}`);\n\treturn resolved;\n}\nfunction resolveContainedLocalPath(cwd: string, pathValue: string, label = \"local:// resource\"): string { return resolveContainedPath(cwd, pathValue, label); }\n\nfunction fallbackInternalPath(value: string, cwd: string): string | undefined {\n\tconst skill = value.match(/^skill:\\/\\/([^/]+)\\/?(.*)$/); if (skill) { const name = skill[1] ?? \"\", rest = skill[2] || \"SKILL.md\"; return [\".agents/skills\", \"packages/subagents/skills\", \"packages/workflows/skills\"].map((base) => resolveContainedPath(resolveContainedLocalPath(cwd, base, \"skill:// resource\"), `${name}/${rest}`, \"skill:// resource\")).find((candidate) => existsSync(candidate)); }\n\tconst local = value.match(/^local:\\/\\/(.+)$/); if (local) return resolveContainedLocalPath(cwd, local[1] ?? \"\");\n\treturn undefined;\n}\nexport function resolveInternalSelector(value: string, cwd: string): string | undefined { return fallbackInternalPath(value, cwd); }\nexport async function readInternalSelector(value: string, cwd: string, context?: InternalResourceContext): Promise<string> {\n\tconst router = routerFromContext(context); const routed = await router?.read?.(value); if (typeof routed === \"string\") return routed; if (Buffer.isBuffer(routed)) return routed.toString(\"utf8\");\n\tconst resolved = await resolveViaRouter(value, cwd, context); if (!resolved || !existsSync(resolved)) throw new Error(`Internal resource not found or no session router supports it: ${value}`); return readFileSync(resolved, \"utf8\");\n}\nexport async function writeInternalSelector(value: string, cwd: string, content: string, context?: InternalResourceContext): Promise<void> {\n\tconst router = routerFromContext(context); if (router?.write) { await router.write(value, content); return; }\n\tconst resolved = await resolveViaRouter(value, cwd, context); if (!resolved) throw new Error(`Unsupported writable internal resource without a session router: ${value}`); mkdirSync(dirname(resolved), { recursive: true }); writeFileSync(resolved, content);\n}\nexport async function searchInternalSelector(value: string, cwd: string, pattern: string, ignoreCase = false, literal = false, context?: InternalResourceContext, contextBefore = 1, contextAfter = 3): Promise<string> {\n\treturn searchTextSelectorLines(value, await readInternalSelector(value, cwd, context), pattern, ignoreCase, literal, contextBefore, contextAfter).join(\"\\n\");\n}\nfunction shellQuote(value: string): string { return `'${value.replace(/'/g, `'\\\\''`)}'`; }\nexport async function expandShellInternalUrls(text: string, cwd: string, context?: InternalResourceContext, quote = false): Promise<string> {\n\tlet output = text; const matches = [...new Set(text.match(/[a-z][a-z0-9+.-]*:\\/\\/[^\\s'\"`$)]+/gi) ?? [])];\n\tfor (const match of matches) { const resolved = await resolveViaRouter(match, cwd, context); if (resolved) output = output.split(match).join(quote ? shellQuote(resolved) : resolved); }\n\treturn output;\n}\n\nconst ROW_COUNT_PROBE_CAP = 50_000;\nconst MAX_RAW_QUERY_ROWS = 1000;\n\nfunction quoteSqliteIdent(value: string): string { return `\"${value.replace(/\"/g, '\"\"')}\"`; }\nfunction formatSqliteOrder(order: string | undefined): string {\n\tif (!order) return \"\";\n\treturn order.split(\",\").map((part) => {\n\t\tconst [column, direction] = part.split(\":\");\n\t\tif (!column || !/^[A-Za-z_][\\w$]*$/.test(column)) throw new Error(`Invalid SQLite order column: ${part}`);\n\t\tconst dir = direction?.toLowerCase() === \"desc\" ? \"desc\" : \"asc\";\n\t\treturn `${quoteSqliteIdent(column)} ${dir}`;\n\t}).join(\", \");\n}\nconst FORBIDDEN_WHERE_KEYWORDS = new Set([\"limit\", \"offset\", \"union\", \"intersect\", \"except\", \"attach\", \"detach\", \"pragma\", \"select\", \"load_extension\"]);\nfunction validateSqliteWhere(where: string | undefined): string | undefined {\n\tconst trimmed = where?.trim(); if (!trimmed) return undefined;\n\tlet quote = \"\", token = \"\";\n\tconst flush = () => { const lower = token.toLowerCase(); if (token && (FORBIDDEN_WHERE_KEYWORDS.has(lower) || lower.startsWith(\"pragma_\") || lower.startsWith(\"sqlite_\"))) throw new Error(\"Invalid SQLite where filter\"); token = \"\"; };\n\tfor (let i = 0; i < trimmed.length; i++) { const ch = trimmed[i], next = trimmed[i + 1]; if (quote === \"'\") { if (ch === \"'\" && next === \"'\") { i++; continue; } if (ch === \"'\") quote = \"\"; continue; } if (quote === \"\\\"\") { if (ch === \"\\\"\" && next === \"\\\"\") { i++; continue; } if (ch === \"\\\"\") { quote = \"\"; flush(); continue; } if (ch && /[A-Za-z0-9_]/.test(ch)) { token += ch; continue; } flush(); token = ch; continue; } if (ch === \"'\" || ch === \"\\\"\") { flush(); quote = ch; continue; } if (ch === \";\" || ch === \"-\" && next === \"-\" || ch === \"/\" && next === \"*\" || ch === \"*\" && next === \"/\") throw new Error(\"Invalid SQLite where filter\"); if (ch && /[A-Za-z0-9_]/.test(ch)) { token += ch; continue; } flush(); }\n\tflush();\n\treturn trimmed;\n}\nfunction rowsToJsonLines(rows: Record<string, SqliteValue>[]): string { return rows.map((row) => JSON.stringify(row)).join(\"\\n\"); }\n\nconst FORBIDDEN_RAW_QUERY_KEYWORDS = new Set([\"attach\", \"detach\", \"pragma\", \"insert\", \"update\", \"delete\", \"drop\", \"alter\", \"create\", \"replace\", \"vacuum\", \"reindex\", \"load_extension\", \"union\", \"intersect\", \"except\"]);\nfunction validateRawSqliteQuery(query: string): string {\n\tconst trimmed = query.trim(); if (!trimmed) throw new Error(\"SQLite raw query must not be empty\"); if (!/^select\\b/i.test(trimmed)) throw new Error(\"Invalid raw SQLite query\");\n\tlet quote = \"\", token = \"\";\n\tconst flush = () => { const lower = token.toLowerCase(); if (lower && (FORBIDDEN_RAW_QUERY_KEYWORDS.has(lower) || lower.startsWith(\"sqlite_\") || lower.startsWith(\"pragma_\"))) throw new Error(\"Invalid raw SQLite query\"); token = \"\"; };\n\tfor (let i = 0; i < trimmed.length; i++) { const ch = trimmed[i], next = trimmed[i + 1]; if (quote === \"'\") { if (ch === \"'\" && next === \"'\") { i++; continue; } if (ch === \"'\") quote = \"\"; continue; } if (quote === \"\\\"\") { if (ch === \"\\\"\" && next === \"\\\"\") { i++; continue; } if (ch === \"\\\"\") { quote = \"\"; flush(); continue; } if (ch && /[A-Za-z0-9_]/.test(ch)) { token += ch; continue; } flush(); token = ch; continue; } if (ch === \"'\" || ch === \"\\\"\") { flush(); quote = ch; continue; } if (ch === \";\" || ch === \"-\" && next === \"-\" || ch === \"/\" && next === \"*\" || ch === \"*\" && next === \"/\") throw new Error(\"Invalid raw SQLite query\"); if (ch && /[A-Za-z0-9_]/.test(ch)) { token += ch; continue; } flush(); }\n\tflush();\n\tif (quote) throw new Error(\"Invalid raw SQLite query\");\n\treturn trimmed;\n}\n\nfunction readRawSqliteRows(query: SqliteQuery): Record<string, SqliteValue>[] { const rows: Record<string, SqliteValue>[] = []; const iterable = query.iterate?.(); if (!iterable) return query.all().slice(0, MAX_RAW_QUERY_ROWS); for (const row of iterable) { if (rows.length >= MAX_RAW_QUERY_ROWS) break; rows.push(row); } return rows; }\n\nfunction sqliteTableColumns(db: SqliteDatabase, table: string): string[] { return (db.query(`pragma table_info(${quoteSqliteIdent(table)})`).all() as Array<{ name?: string }>).map((row) => String(row.name ?? \"\")).filter(Boolean); }\n\nfunction boundedSqliteRowCount(db: SqliteDatabase, table: string): string | number { const row = db.query(`select count(*) as count from (select 1 from ${quoteSqliteIdent(table)} limit ${ROW_COUNT_PROBE_CAP + 1})`).all()[0]; const count = Number(row?.count ?? 0); return count > ROW_COUNT_PROBE_CAP ? `${ROW_COUNT_PROBE_CAP}+` : count; }\nfunction normalizeSqliteWriteValue(value: unknown, column: string): SqliteValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") return value;\n\tthrow new Error(`SQLite column '${column}' only accepts JSON scalar values or null`);\n}\n\nfunction sqlitePrimaryKey(db: SqliteDatabase, table: string): string { return (db.query(`pragma table_info(${quoteSqliteIdent(table)})`).all() as Array<{ name?: string; pk?: number }>).find((row) => row.pk === 1)?.name ?? \"rowid\"; }\nexport function readSqliteSelector(selector: SqliteSelector): string {\n\tconst Database = sqliteDatabase();\n\tconst db = new Database(selector.databasePath, { readonly: true });\n\ttry {\n\t\tif (selector.query) return rowsToJsonLines(readRawSqliteRows(db.query(validateRawSqliteQuery(selector.query))));\n\t\tif (!selector.table) {\n\t\t\tconst tables = db.query(\"select name from sqlite_master where type='table' and name not like 'sqlite_%' order by name\").all().slice(0, 500);\n\t\t\treturn tables.map((row) => { const name = String(row.name ?? \"\"); return JSON.stringify({ table: name, rows: boundedSqliteRowCount(db, name) }); }).join(\"\\n\");\n\t\t}\n\t\tconst schemaRows = db.query(`pragma table_info(${quoteSqliteIdent(selector.table)})`).all();\n\t\tif (selector.schema) return rowsToJsonLines(schemaRows);\n\t\tconst key = sqlitePrimaryKey(db, selector.table);\n\t\tconst where = selector.rowId ? `${quoteSqliteIdent(key)} = ?` : validateSqliteWhere(selector.where);\n\t\tconst order = formatSqliteOrder(selector.order);\n\t\tconst isQuery = selector.limit !== undefined || selector.offset !== undefined || selector.where || selector.order;\n\t\tconst limit = selector.sampleRows ?? selector.limit ?? (isQuery ? 20 : 5);\n\t\tconst offset = selector.offset ?? 0;\n\t\tconst sql = [`select * from ${quoteSqliteIdent(selector.table)}`, where ? `where ${where}` : \"\", order ? `order by ${order}` : \"\", \"limit ? offset ?\"].filter(Boolean).join(\" \");\n\t\tconst rows = selector.rowId ? db.query(sql).all(selector.rowId, limit, offset) : db.query(sql).all(limit, offset);\n\t\tif (selector.rowId || isQuery || selector.sampleRows !== undefined) return rowsToJsonLines(rows);\n\t\treturn [`# ${selector.table}`, \"Schema:\", rowsToJsonLines(schemaRows), \"Rows:\", rowsToJsonLines(rows)].join(\"\\n\");\n\t} finally { db.close(); }\n}\nfunction stripJson5Comments(input: string): string {\n\tlet out = \"\", quote = \"\", escaped = false;\n\tfor (let i = 0; i < input.length; i++) { const ch = input[i]!, next = input[i + 1]; if (escaped) { out += ch; escaped = false; continue; } if (quote) { out += ch; if (ch === \"\\\\\") escaped = true; else if (ch === quote) quote = \"\"; continue; } if (ch === '\"' || ch === \"'\") { quote = ch; out += ch; continue; } if (ch === \"/\" && next === \"/\") { while (i < input.length && input[i] !== \"\\n\") i++; out += \"\\n\"; continue; } if (ch === \"/\" && next === \"*\") { i += 2; while (i < input.length && !(input[i] === \"*\" && input[i + 1] === \"/\")) i++; i++; continue; } out += ch; }\n\treturn out;\n}\nfunction parseLooseJsonObject(content: string): Record<string, SqliteValue> {\n\tconst trimmed = stripJson5Comments(content.trim());\n\tif (!trimmed) throw new Error(\"SQLite write content must be a JSON object; empty content only deletes a row when a row id is present.\");\n\tlet parsed: unknown;\n\ttry { parsed = JSON.parse(trimmed); } catch {\n\t\tconst normalized = trimmed.replace(/([{,]\\s*)([A-Za-z_$][\\w$]*)\\s*:/g, '$1\"$2\":').replace(/:\\s*\\+(-?\\d+(?:\\.\\d+)?)/g, \":$1\").replace(/(:\\s*)0x[0-9a-fA-F]+/g, (match, prefix: string) => `${prefix}${Number.parseInt(match.slice(prefix.length + 2), 16)}`).replace(/'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'/g, (_match, body: string) => JSON.stringify(body.replace(/\\\\'/g, \"'\"))).replace(/,\\s*([}\\]])/g, \"$1\");\n\t\tparsed = JSON.parse(normalized);\n\t}\n\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) throw new Error(\"SQLite write content must be a JSON object.\");\n\treturn Object.fromEntries(Object.entries(parsed as Record<string, unknown>).map(([column, value]) => [column, normalizeSqliteWriteValue(value, column)]));\n}\nexport function writeSqliteSelector(selector: SqliteSelector, content: string): string {\n\tif (!selector.table) throw new Error(\"SQLite write target must include a table name\"); if (!existsSync(selector.databasePath)) throw new Error(`SQLite database does not exist: ${selector.databasePath}`); if (content.trim() === \"\") { if (!selector.rowId) throw new Error(\"SQLite empty content deletes a row only when a row id is present.\"); const Database = sqliteDatabase(); const db = new Database(selector.databasePath); try { const table = selector.table; const result = db.query(`delete from ${quoteSqliteIdent(table)} where ${quoteSqliteIdent(sqlitePrimaryKey(db, table))} = ?`).run(selector.rowId); return (result.changes ?? 0) > 0 ? `Deleted row '${selector.rowId}' in ${table}` : `No row deleted for '${selector.rowId}' in ${table}`; } finally { db.close(); } } const data = parseLooseJsonObject(content); const Database = sqliteDatabase(); const db = new Database(selector.databasePath);\n\ttry { const table = selector.table; const quotedTable = quoteSqliteIdent(table); const key = sqlitePrimaryKey(db, table); const quotedKey = quoteSqliteIdent(key); const validColumns = new Set(sqliteTableColumns(db, table)); if (!selector.rowId && key !== \"id\" && Object.hasOwn(data, \"id\") && !Object.hasOwn(data, key)) { data[key] = data.id; delete data.id; } const columns = Object.keys(data); for (const column of columns) if (!validColumns.has(column)) throw new Error(`SQLite table '${table}' has no column named '${column}'`); if (columns.length === 0) { if (!selector.rowId) { db.query(`insert into ${quotedTable} default values`).run(); return `Inserted row into ${table}`; } throw new Error(\"SQLite update content must include at least one column.\"); } if (!selector.rowId) { const quoted = columns.map(quoteSqliteIdent).join(\", \"); db.query(`insert into ${quotedTable} (${quoted}) values (${columns.map(() => \"?\").join(\", \")})`).run(...columns.map((column) => data[column])); return `Inserted row into ${table}`; } const assignments = columns.map((column) => `${quoteSqliteIdent(column)} = ?`).join(\", \"); const result = db.query(`update ${quotedTable} set ${assignments} where ${quotedKey} = ?`).run(...columns.map((column) => data[column]), selector.rowId); return (result.changes ?? 0) > 0 ? `Updated row '${selector.rowId}' in ${table}` : `No row updated for '${selector.rowId}' in ${table}`; } finally { db.close(); }\n}\nexport function searchSqliteSelector(selector: SqliteSelector, pattern: string, ignoreCase = false, contextBefore = 1, contextAfter = 3): string {\n\tconst normalized = normalizeSearchPattern(pattern, ignoreCase);\n\tconst matcher = new RegExp(normalized.pattern, normalized.flags);\n\tif (!selector.table || selector.query) return searchTextSelectorLines(`${selector.databasePath}:${selector.table ?? \"tables\"}`, readSqliteSelector(selector), pattern, ignoreCase, false, contextBefore, contextAfter).join(\"\\n\");\n\tconst Database = sqliteDatabase();\n\tconst db = new Database(selector.databasePath, { readonly: true });\n\ttry {\n\t\tconst key = sqlitePrimaryKey(db, selector.table);\n\t\tconst where = selector.rowId ? `${quoteSqliteIdent(key)} = ?` : validateSqliteWhere(selector.where);\n\t\tconst order = formatSqliteOrder(selector.order);\n\t\tconst limit = selector.sampleRows ?? selector.limit ?? 1000;\n\t\tconst offset = selector.offset ?? 0;\n\t\tconst rowIdAlias = \"__atomic_rowid__\";\n\t\tconst selectList = key === \"rowid\" ? `rowid as ${quoteSqliteIdent(rowIdAlias)}, *` : \"*\";\n\t\tconst sql = [`select ${selectList} from ${quoteSqliteIdent(selector.table)}`, where ? `where ${where}` : \"\", order ? `order by ${order}` : \"\", \"limit ? offset ?\"].filter(Boolean).join(\" \");\n\t\tconst rows = selector.rowId ? db.query(sql).all(selector.rowId, limit, offset) : db.query(sql).all(limit, offset);\n\t\treturn rows.map((rawRow, index) => {\n\t\t\tconst row = rawRow as Record<string, unknown>;\n\t\t\tconst rowKey = key === \"rowid\" ? row[rowIdAlias] : row[key];\n\t\t\tif (key === \"rowid\") delete row[rowIdAlias];\n\t\t\treturn { row, key: String(rowKey ?? offset + index + 1) };\n\t\t}).filter(({ row }) => matcher.test(JSON.stringify(row))).map(({ row, key }) => `${selector.databasePath}:${selector.table}:${key}: ${truncateSearchLine(JSON.stringify(row))}`).join(\"\\n\");\n\t} finally { db.close(); }\n}\n"]}
1
+ {"version":3,"file":"resource-selectors.d.ts","sourceRoot":"","sources":["../../../src/core/tools/resource-selectors.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAAG,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AAC5E,MAAM,WAAW,cAAc;IAAG,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AAChN,MAAM,WAAW,sBAAsB;IACtC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM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,CAQpK","sourcesContent":["import type { TruncationResult } from \"./truncate.ts\";\n\nexport interface SearchToolDetails {\n\tscopePath?: string;\n\tsearchPath?: string;\n\tcwd?: string;\n\tmatchCount?: number;\n\tfileCount?: number;\n\tfiles?: string[];\n\tfileMatches?: Record<string, number>;\n\tmissingPaths?: string[];\n\tdisplayContent?: string;\n\tfileLimitReached?: boolean;\n\tperFileLimitReached?: boolean;\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n\tmeta?: { source?: string; truncation?: TruncationResult; limits?: { fileLimit?: number } };\n}\n\nexport function buildSearchDetails(base: SearchToolDetails | undefined, text: string, cwd: string, scopePath: string, missingPaths: string[] = []): SearchToolDetails {\n\tconst files = new Set<string>(), fileMatches: Record<string, number> = {}; let currentPath = \"\", matchCount = 0;\n\tfor (const line of text.split(\"\\n\")) {\n\t\tconst header = line.match(/^\\[([^\\]#]+)#[0-9A-F]{4}\\]$/); if (header) { currentPath = header[1] ?? \"\"; files.add(currentPath); continue; }\n\t\tconst pathMatch = line.match(/^(.+?)(?::\\d+: |-\\d+- )/); if (pathMatch) { currentPath = pathMatch[1] ?? currentPath; files.add(currentPath); }\n\t\tconst isMatch = /^\\*\\d+:/.test(line) || /^.+?:\\d+: /.test(line); if (isMatch && currentPath) { matchCount++; fileMatches[currentPath] = (fileMatches[currentPath] ?? 0) + 1; }\n\t}\n\treturn { ...(base ?? {}), scopePath, searchPath: scopePath, cwd, matchCount, fileCount: files.size, files: [...files], fileMatches, ...(missingPaths.length ? { missingPaths } : {}), displayContent: text, meta: { ...(base?.meta ?? {}), source: scopePath, ...(base?.truncation ? { truncation: base.truncation } : {}) } };\n}\n"]}
1
+ {"version":3,"file":"search-details.d.ts","sourceRoot":"","sources":["../../../src/core/tools/search-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,EA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MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,eAAe,EAAE,CAAA;CAAE,CAMtG;AAQD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,EAAE,aAAa,SAAI,EAAE,YAAY,SAAI,GAAG,MAAM,CAevJ","sourcesContent":["export interface SearchLineRange {\n\tstart: number;\n\tend: number;\n}\n\nexport function parseLineRangeSpec(spec: string): SearchLineRange[] | undefined {\n\tconst ranges: SearchLineRange[] = [];\n\tfor (const part of spec.split(\",\")) {\n\t\tconst plus = part.match(/^(\\d+)\\+(\\d+)$/);\n\t\tconst dash = part.match(/^(\\d+)(?:-|\\.\\.)(\\d+)$/);\n\t\tconst single = part.match(/^(\\d+)$/);\n\t\tlet start = 0;\n\t\tlet end = 0;\n\t\tif (plus) {\n\t\t\tstart = Number.parseInt(plus[1] ?? \"0\", 10);\n\t\t\tconst count = Number.parseInt(plus[2] ?? \"0\", 10);\n\t\t\tif (count < 1) return undefined;\n\t\t\tend = start + count - 1;\n\t\t} else if (dash) {\n\t\t\tstart = Number.parseInt(dash[1] ?? \"0\", 10);\n\t\t\tend = Number.parseInt(dash[2] ?? \"0\", 10);\n\t\t} else if (single) {\n\t\t\tstart = end = Number.parseInt(single[1] ?? \"0\", 10);\n\t\t} else return undefined;\n\t\tif (start < 1 || end < start) return undefined;\n\t\tranges.push({ start, end });\n\t}\n\treturn ranges.length > 0 ? ranges : undefined;\n}\n\nexport function splitLineRangeSelector(value: string): { path: string; lineRanges?: SearchLineRange[] } {\n\tconst match = value.match(/^(.*):(\\d+(?:(?:-|\\.\\.|\\+)\\d*)?(?:,\\d+(?:(?:-|\\.\\.|\\+)\\d*)?)*)$/);\n\tif (!match) return { path: value };\n\tconst ranges = parseLineRangeSpec(match[2] ?? \"\");\n\tif (!ranges) throw new Error(`Invalid line-range selector: ${match[2] ?? \"\"}`);\n\treturn { path: match[1] ?? value, lineRanges: ranges };\n}\n\nfunction rowLineNumber(line: string): { lineNumber: number; isMatch: boolean } | undefined {\n\tconst match = line.match(/^.+?(?::(\\d+): |-(\\d+)- )/);\n\tif (!match) return undefined;\n\treturn { lineNumber: Number.parseInt(match[1] ?? match[2] ?? \"0\", 10), isMatch: match[1] !== undefined };\n}\n\nexport function filterSearchOutputByLineRange(text: string, ranges: readonly SearchLineRange[] | undefined, contextBefore = 1, contextAfter = 3): string {\n\tif (!ranges || ranges.length === 0) return text;\n\tconst inSelectedRange = (lineNumber: number): boolean => ranges.some((range) => lineNumber >= range.start && lineNumber <= range.end);\n\tconst acceptedMatches: number[] = [];\n\tfor (const line of text.split(\"\\n\")) {\n\t\tconst row = rowLineNumber(line);\n\t\tif (row?.isMatch && inSelectedRange(row.lineNumber)) acceptedMatches.push(row.lineNumber);\n\t}\n\tif (acceptedMatches.length === 0) return \"No matches found\";\n\tconst keepLine = (lineNumber: number): boolean => acceptedMatches.some((matchLine) => lineNumber >= matchLine - contextBefore && lineNumber <= matchLine + contextAfter);\n\tconst filtered = text.split(\"\\n\").filter((line) => {\n\t\tconst row = rowLineNumber(line);\n\t\treturn row !== undefined && keepLine(row.lineNumber);\n\t}).join(\"\\n\");\n\treturn filtered || \"No matches found\";\n}\n"]}
1
+ {"version":3,"file":"search-line-ranges.d.ts","sourceRoot":"","sources":["../../../src/core/tools/search-line-ranges.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,GAAG,SAAS,CAuB9E;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,eAAe,EAAE,CAAA;CAAE,CAMtG;AAQD,wBAAgB,6BAA6B,CAAC,IAA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,YAAY,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIlJ,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AAED,wBAAgB,uBAAuB,IAAI,aAAa,GAAG,IAAI,CAe9D;AAED,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAE/D","sourcesContent":["import { createModuleRequire } from \"../../utils/module-require.ts\";\n\ntype NativeBinding = {\n\tglob: (options: NativeGlobOptions) => Promise<NativeGlobResult>;\n\tgrep: (options: NativeGrepOptions) => Promise<NativeGrepResult>;\n\tsearch?: (content: string | Uint8Array, options: NativeTextSearchOptions) => NativeTextSearchResult;\n\thasMatch?: (content: string | Uint8Array, pattern: string | Uint8Array, ignoreCase?: boolean | null, multiline?: boolean | null) => boolean;\n\tinvalidateFsScanCache?: (path?: string | null) => void;\n\tblockRangeAt?: (options: { code: string; path: string; line: number }) => { startLine: number; endLine: number } | null;\n};\n\nexport type NativeGlobMatch = {\n\tpath: string;\n\tfileType: \"File\" | \"Dir\" | \"Symlink\" | number;\n\tmtime?: number;\n\tsize?: number;\n};\n\nexport type NativeGlobOptions = {\n\tpattern: string;\n\tpath: string;\n\tfileType?: \"File\" | \"Dir\" | \"Symlink\" | number;\n\trecursive?: boolean;\n\thidden?: boolean;\n\tmaxResults?: number;\n\tgitignore?: boolean;\n\tcache?: boolean;\n\tsortByMtime?: boolean;\n\tincludeNodeModules?: boolean;\n\tsignal?: AbortSignal;\n\ttimeoutMs?: number;\n};\n\nexport type NativeGlobResult = {\n\tmatches: NativeGlobMatch[];\n\ttotalMatches: number;\n};\n\nexport type NativeGrepMatch = {\n\tpath: string;\n\tlineNumber: number;\n\tline: string;\n\tcontextBefore?: Array<{ lineNumber: number; line: string }>;\n\tcontextAfter?: Array<{ lineNumber: number; line: string }>;\n\ttruncated?: boolean;\n\tmatchCount?: number;\n};\n\nexport type NativeGrepOptions = {\n\tpattern: string;\n\tpath: string;\n\tcwd?: string;\n\tglob?: string;\n\ttype?: string;\n\tignoreCase?: boolean;\n\tmultiline?: boolean;\n\thidden?: boolean;\n\tgitignore?: boolean;\n\tcache?: boolean;\n\tmaxCount?: number;\n\toffset?: number;\n\tcontextBefore?: number;\n\tcontextAfter?: number;\n\tcontext?: number;\n\tmaxColumns?: number;\n\tmode?: \"content\" | \"count\" | \"filesWithMatches\";\n\tmaxCountPerFile?: number;\n\tsignal?: AbortSignal;\n\ttimeoutMs?: number;\n};\n\nexport type NativeGrepResult = {\n\tmatches: NativeGrepMatch[];\n\ttotalMatches: number;\n\tfilesWithMatches: number;\n\tfilesSearched: number;\n\tlimitReached: boolean;\n\tskippedOversized?: number;\n\terror?: string;\n};\nexport type NativeTextSearchOptions = Omit<NativeGrepOptions, \"path\" | \"cwd\" | \"glob\" | \"type\" | \"hidden\" | \"gitignore\" | \"cache\" | \"maxCountPerFile\" | \"signal\" | \"timeoutMs\">;\nexport type NativeTextSearchResult = { matches: Array<Omit<NativeGrepMatch, \"path\">>; matchCount: number; limitReached: boolean; error?: string };\n\nlet cachedLoadResult: NativeBinding | null | false = null;\n\nexport function resetNativeSearchBindingCache(): void {\n\tcachedLoadResult = null;\n}\n\nexport function loadNativeSearchBinding(): NativeBinding | null {\n\tif (cachedLoadResult !== null) return cachedLoadResult || null;\n\ttry {\n\t\tconst require = createModuleRequire(import.meta.url);\n\t\tconst binding = require(\"@bastani/atomic-natives\") as Partial<NativeBinding>;\n\t\tif (typeof binding.glob !== \"function\" || typeof binding.grep !== \"function\") {\n\t\t\tcachedLoadResult = false;\n\t\t\treturn null;\n\t\t}\n\t\tcachedLoadResult = binding as NativeBinding;\n\t\treturn cachedLoadResult;\n\t} catch {\n\t\tcachedLoadResult = false;\n\t\treturn null;\n\t}\n}\n\nexport function invalidateNativeSearchCache(path?: string): void {\n\tloadNativeSearchBinding()?.invalidateFsScanCache?.(path ?? null);\n}\n"]}
1
+ {"version":3,"file":"search-native.d.ts","sourceRoot":"","sources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,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAE/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/core/tools/search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAuD,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAKhH,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGjF,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,QAAA,MAAM,YAAY;;;;;;;EAYiB,CAAC;AACpC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAAE,aAAa,CAAC,EAAE,qBAAqB,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA2N3I,wBAAgB,0BAA0B,CACzC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,iBAAiB,GACzB,cAAc,CAAC,OAAO,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC,CAyMpE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC,OAAO,YAAY,CAAC,CAEzG","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { dirname, join, resolve as resolvePath } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport {\n\tcreateGrepToolDefinition,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nimport { normalizePathLikeInput, splitPathLikeGlob } from \"./glob-path-utils.ts\";\nimport { createHashlineSnapshotStore, recordHashlineSnapshot, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { parseArchiveSelector, readArchiveSelector, resolveArchiveSelector, resolveInternalSelector, searchArchiveSelector, searchInternalSelector, searchSqliteSelector, sqliteSelectorForPath, type InternalResourceContext, type SqliteSelector } from \"./resource-selectors.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, truncateHead } from \"./truncate.ts\";\nimport { buildSearchDetails, type SearchToolDetails } from \"./search-details.ts\";\nimport { filterSearchOutputByLineRange, splitLineRangeSelector, type SearchLineRange } from \"./search-line-ranges.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nexport type { SearchToolDetails } from \"./search-details.ts\";\nconst searchSchema = Type.Object({\n\tpattern: Type.String({ description: \"Regex pattern. Whitespace-only patterns are rejected; otherwise the pattern is preserved verbatim.\" }),\n\tpaths: Type.Optional(\n\t\tType.Union([\n\t\t\tType.String({ description: \"File, directory, glob, internal URL, or <file>:<lines> selector to search. Omitted or empty searches the workspace root.\" }),\n\t\t\tType.Array(Type.String({ description: \"File, directory, glob, internal URL, or <file>:<lines> selector to search.\" })),\n\t\t]),\n\t),\n\ti: Type.Optional(Type.Boolean({ description: \"Case-insensitive search.\" })),\n\tgitignore: Type.Optional(Type.Boolean({ description: \"Respect gitignore.\" })),\n\tcase: Type.Optional(Type.Boolean({ description: \"Set false for case-insensitive search (oh-my-pi compatibility).\" })),\n\tskip: Type.Optional(Type.Union([Type.Number({ description: \"Files to skip before collecting results; use to paginate when the previous call hit the file limit.\" }), Type.Null()])),\n}, { additionalProperties: false });\nexport type SearchToolInput = Static<typeof searchSchema>;\nexport type SearchToolOptions = GrepToolOptions & { hashlineStore?: HashlineSnapshotStore; contextBefore?: number; contextAfter?: number };\nfunction delimiterInExistingSearchGlobRoot(value: string, cwd: string): boolean { const selector = splitLineRangeSelector(value); const parsed = splitPathLikeGlob(selector.path); return !!parsed.glob && /[;,\\s]/.test(parsed.basePath) && existsSync(resolveToCwd(parsed.basePath, cwd)); }\nfunction archiveSelectorExists(value: string, cwd: string): boolean { const archive = parseArchiveSelector(value); if (!archive) return false; const resolved = resolveArchiveSelector(archive, cwd); if (!existsSync(resolved.archivePath)) return false; if (!resolved.memberPath) return true; try { readArchiveSelector(resolved); return true; } catch { return false; } }\nfunction searchPathResolvable(value: string, cwd: string): boolean { const selector = splitLineRangeSelector(value), archive = parseArchiveSelector(selector.path); if (archive) return archiveSelectorExists(selector.path, cwd); const sqlite = sqliteSelectorForPath(selector.path, cwd); return !!sqlite || /^(?:skill|agent|artifact|history|issue|local|memory|pr|conflict|omp|rule|mcp|vault):\\/\\//.test(selector.path) || existsSync(resolveToCwd(splitPathLikeGlob(selector.path).basePath, cwd)); }\n\nfunction normalizePaths(pathsValue: string | string[] | undefined, cwd: string): string[] {\n\tconst inputs = Array.isArray(pathsValue) ? (pathsValue.length > 0 ? pathsValue : [\".\"]) : pathsValue === undefined ? [\".\"] : [pathsValue];\n\tconst expanded: string[] = [];\n\tfor (const input of inputs) {\n\t\tconst raw = normalizePathLikeInput(input);\n\t\tif (raw === \"\") { expanded.push(\".\"); continue; }\n\t\tconst resourceLike = /^[a-z]+:\\/\\//i.test(raw) || /^[^:]+\\.(?:zip|jar|tar|tgz|gz|sqlite|db):/i.test(raw);\n\t\tif (existsSync(resolveToCwd(splitLineRangeSelector(raw).path, cwd)) || delimiterInExistingSearchGlobRoot(raw, cwd) || archiveSelectorExists(raw, cwd)) { expanded.push(raw); continue; }\n\t\tconst chunks = raw.split(/[;\\s]+/).map(normalizePathLikeInput).filter(Boolean);\n\t\tconst parts = chunks.flatMap((chunk) => searchPathResolvable(chunk, cwd) ? [chunk] : chunk.split(\",\").map(normalizePathLikeInput).filter(Boolean));\n\t\tconst commaOrSemicolon = /[;,]/.test(raw), canSplit = commaOrSemicolon ? parts.some((part) => searchPathResolvable(part, cwd)) : parts.every((part) => searchPathResolvable(part, cwd));\n\t\tif (parts.length > 1 && canSplit) expanded.push(...parts);\n\t\telse if (resourceLike) expanded.push(raw);\n\t\telse expanded.push(raw);\n\t}\n\treturn expanded;\n}\n\ninterface SearchTarget {\n\tpath: string;\n\tglob?: string;\n\tlineRanges?: SearchLineRange[];\n\tarchive?: ReturnType<typeof parseArchiveSelector>;\n\tsqlite?: SqliteSelector;\n\tinternal?: string;\n}\n\ninterface SearchOutputGroup {\n\tpath: string;\n\tlines: string[];\n}\n\ninterface PagedSearchOutputGroup {\n\ttargetPath: string;\n\tvirtual: boolean;\n\tgroup: SearchOutputGroup;\n}\n\nconst DEFAULT_LIMIT = 20, INTERNAL_SKIP_LIMIT = 2000, MULTI_FILE_PER_FILE_MATCHES = 20, SINGLE_FILE_MATCHES = 200;\n\nfunction normalizeSkip(skip: number | null | undefined): number {\n\tif (skip === undefined || skip === null) return 0;\n\tif (!Number.isFinite(skip) || skip < 0) throw new Error(\"Skip must be a non-negative number\");\n\treturn Math.floor(skip);\n}\nfunction markFileLimit(details: SearchToolDetails, limit: number): void {\n\tdetails.fileLimitReached = true;\n\tdetails.meta = { ...(details.meta ?? {}), limits: { ...(details.meta?.limits ?? {}), fileLimit: limit } };\n}\nfunction fileLimitDetails(limit: number): SearchToolDetails { const details: SearchToolDetails = {}; markFileLimit(details, limit); return details; }\nfunction continuationHint(limit: number, skip: number): string { return `[${limit} matching files shown. Use skip=${skip + limit} to view more.]`; }\nfunction internalCapHint(): string { return `[Search collected the first ${INTERNAL_SKIP_LIMIT} matches before pagination; refine the pattern or path for later results.]`; }\nfunction hasFileLimit(details: unknown): boolean { return typeof details === \"object\" && details !== null && (details as { fileLimitReached?: unknown }).fileLimitReached === true; }\n\nfunction isResourceSelector(value: string): boolean {\n\treturn /^[^:]+\\.(zip|jar|tar|tgz|gz|sqlite|db):/i.test(value) || /^[a-z]+:\\/\\//i.test(value) || value.startsWith(\"skill://\");\n}\n\nfunction normalizeSearchTargets(pathsValue: string | string[] | undefined, cwd: string): SearchTarget[] {\n\treturn normalizePaths(pathsValue, cwd).map((searchPath) => {\n\t\tconst directSqlite = sqliteSelectorForPath(searchPath, cwd);\n\t\tif (directSqlite?.rowId) return { path: searchPath, sqlite: directSqlite };\n\t\tif (archiveSelectorExists(searchPath, cwd)) { const archive = parseArchiveSelector(searchPath)!; return { path: searchPath, archive }; }\n\t\tconst selector = splitLineRangeSelector(searchPath);\n\t\tconst sqliteDirect = sqliteSelectorForPath(selector.path, cwd);\n\t\tif (sqliteDirect) return { path: selector.path, lineRanges: selector.lineRanges, sqlite: sqliteDirect };\n\t\tconst archive = parseArchiveSelector(selector.path);\n\t\tif (archive) return { path: selector.path, lineRanges: selector.lineRanges, archive };\n\t\tif (selector.path.startsWith(\"local://\")) { const sourcePath = resolveInternalSelector(selector.path, cwd); if (sourcePath) { const parsed = splitPathLikeGlob(sourcePath); return { path: parsed.basePath, glob: parsed.glob, lineRanges: selector.lineRanges }; } }\n\t\tif (/^(?:skill|agent|artifact|history|issue|local|memory|pr|conflict|omp|rule|mcp|vault):\\/\\//.test(selector.path)) return { path: selector.path, lineRanges: selector.lineRanges, internal: selector.path };\n\t\tif (isResourceSelector(selector.path)) throw new Error(`Search resource selectors are not supported by this filesystem backend: ${searchPath}`);\n\t\tconst parsed = splitPathLikeGlob(selector.path);\n\t\treturn { path: parsed.basePath, glob: parsed.glob, lineRanges: selector.lineRanges };\n\t});\n}\n\n\nfunction stripExtendedRegexWhitespace(pattern: string): string { let out = \"\", escaped = false, inClass = false, inComment = false; for (const ch of pattern) { if (inComment) { if (ch === \"\\n\" || ch === \"\\r\") inComment = false; continue; } if (escaped) { out += ch; escaped = false; continue; } if (ch === \"\\\\\") { out += ch; escaped = true; continue; } if (ch === \"[\") inClass = true; else if (ch === \"]\") inClass = false; if (!inClass && ch === \"#\") { inComment = true; continue; } if (!inClass && /\\s/.test(ch)) continue; out += ch; } return out; }\nfunction normalizeInlineSearchPattern(pattern: string, ignoreCase: boolean): { pattern: string; flags: string } { const match = pattern.match(/^\\(\\?([imsUx-]+)\\)([\\s\\S]*)$/), flags = new Set<string>(); if (ignoreCase) flags.add(\"i\"); if (match) { const inline = match[1] ?? \"\"; for (const flag of inline) if (flag === \"i\" || flag === \"m\" || flag === \"s\") flags.add(flag); return { pattern: inline.includes(\"x\") ? stripExtendedRegexWhitespace(match[2] ?? \"\") : match[2] ?? \"\", flags: [...flags].join(\"\") }; } return { pattern, flags: [...flags].join(\"\") }; }\n\nasync function searchFileLineRanges(target: SearchTarget, cwd: string, pattern: string, ignoreCase: boolean, contextBefore = 1, contextAfter = 3): Promise<string | undefined> {\n\tif (!target.lineRanges?.length || target.glob || target.archive || target.sqlite || target.internal) return undefined;\n\tconst absolutePath = resolveToCwd(target.path, cwd);\n\tif (!await fsStat(absolutePath).then((stat) => stat.isFile()).catch(() => false)) return undefined;\n\tconst source = (await fsReadFile(absolutePath, \"utf8\")).split(\"\\n\");\n\tconst normalized = normalizeInlineSearchPattern(pattern, ignoreCase);\n\tlet regex: RegExp;\n\ttry { regex = new RegExp(normalized.pattern, normalized.flags); } catch { return undefined; }\n\tconst matchLines = new Set<number>();\n\tsource.forEach((line, index) => { regex.lastIndex = 0; if (regex.test(line)) matchLines.add(index + 1); });\n\tconst outputLines = new Set<number>();\n\tfor (const line of matchLines) for (let n = Math.max(1, line - contextBefore); n <= Math.min(source.length, line + contextAfter); n++) outputLines.add(n);\n\tconst text = [...outputLines].sort((a, b) => a - b).map((n) => `${target.path}${matchLines.has(n) ? \":\" : \"-\"}${n}${matchLines.has(n) ? \":\" : \"-\"} ${source[n - 1] ?? \"\"}`).join(\"\\n\") || \"No matches found\";\n\treturn filterSearchOutputByLineRange(text, target.lineRanges, contextBefore, contextAfter);\n}\n\nfunction groupSearchOutput(text: string): SearchOutputGroup[] {\n\tconst groups: SearchOutputGroup[] = [];\n\tconst byPath = new Map<string, SearchOutputGroup>();\n\tfor (const line of text.split(\"\\n\")) {\n\t\tconst match = line.match(/^(.+?)(?::[^:]+: |:\\d+: |-\\d+- )/);\n\t\tif (!match) continue;\n\t\tconst filePath = match[1]!;\n\t\tlet current = byPath.get(filePath);\n\t\tif (!current) { current = { path: filePath, lines: [] }; byPath.set(filePath, current); groups.push(current); }\n\t\tif (!current.lines.includes(line)) current.lines.push(line);\n\t}\n\treturn groups;\n}\nfunction isVirtualSearchTarget(target: SearchTarget | undefined): boolean { return !!(target?.archive || target?.sqlite || target?.internal); }\n\n\nasync function addHashlineHeadersToSearchOutput(text: string, cwd: string, targetPath: string, hashlineStore: HashlineSnapshotStore): Promise<string> {\n\tconst groups = groupSearchOutput(text);\n\tif (groups.length === 0) return text;\n\tconst searchRoot = resolveToCwd(targetPath, cwd);\n\tconst targetIsFile = await fsStat(searchRoot).then((stat) => stat.isFile()).catch(() => false);\n\tconst rendered: string[] = [];\n\tlet lastDir = \"\";\n\tfor (const group of groups) {\n\t\tlet absolutePath = targetIsFile ? searchRoot : join(searchRoot, group.path);\n\t\ttry {\n\t\t\tawait fsReadFile(absolutePath);\n\t\t} catch {\n\t\t\tabsolutePath = resolvePath(cwd, group.path);\n\t\t}\n\t\ttry {\n\t\t\tconst content = await fsReadFile(absolutePath, \"utf-8\");\n\t\t\tconst snapshot = recordHashlineSnapshot(absolutePath, cwd, content, hashlineStore);\n\t\t\tconst dir = dirname(snapshot.displayPath);\n\t\t\tif (dir !== \".\" && dir !== lastDir) {\n\t\t\t\trendered.push(`# ${dir}/`);\n\t\t\t\tlastDir = dir;\n\t\t\t}\n\t\t\trendered.push(`[${snapshot.displayPath}#${snapshot.tag}]`);\n\t\t\tfor (const line of group.lines) {\n\t\t\t\tconst match = line.match(/^.+?(?::(\\d+): |-(\\d+)- )(.*)$/);\n\t\t\t\tif (match) rendered.push(`${match[1] ? \"*\" : \" \"}${match[1] ?? match[2]}:${match[3] ?? \"\"}`);\n\t\t\t}\n\t\t} catch {\n\t\t\trendered.push(...group.lines);\n\t\t}\n\t}\n\treturn rendered.join(\"\\n\");\n}\n\nfunction applyDefaultSearchContext(text: string, before = 1, after = 3): string {\n\tconst groups = groupSearchOutput(text);\n\tif (groups.length === 0) return text;\n\tconst output: string[] = [];\n\tfor (const group of groups) {\n\t\tconst byLine = new Map<number, { line: string; isMatch: boolean }>();\n\t\tfor (const line of group.lines) {\n\t\t\tconst match = line.match(/^(.+?)(?::(\\d+): |-(\\d+)- )(.*)$/);\n\t\t\tif (!match) continue;\n\t\t\tconst number = Number.parseInt(match[2] ?? match[3] ?? \"0\", 10);\n\t\t\tconst isMatch = match[2] !== undefined;\n\t\t\tconst existing = byLine.get(number);\n\t\t\tif (!existing || (isMatch && !existing.isMatch)) byLine.set(number, { line, isMatch });\n\t\t}\n\t\tconst matchNumbers = [...byLine.values()].filter((item) => item.isMatch).map((item) => Number.parseInt(item.line.match(/(?::(\\d+): |-(\\d+)- )/)?.[1] ?? item.line.match(/-(\\d+)- /)?.[1] ?? \"0\", 10));\n\t\tfor (const [number, item] of [...byLine.entries()].sort((a, b) => a[0] - b[0])) {\n\t\t\tif (item.isMatch || matchNumbers.some((lineNumber) => number >= lineNumber - before && number <= lineNumber + after)) output.push(item.line);\n\t\t}\n\t}\n\treturn output.join(\"\\n\");\n}\n\nfunction isSearchMatchLine(line: string): boolean { return /:\\d+: /.test(line); }\nfunction sliceGroupLinesByMatchCount(lines: readonly string[], matchLimit: number): string[] {\n\tif (matchLimit <= 0) return [];\n\tlet matches = 0; const output: string[] = [];\n\tfor (const line of lines) {\n\t\tif (isSearchMatchLine(line)) { if (matches >= matchLimit) break; matches++; }\n\t\toutput.push(line);\n\t}\n\treturn output;\n}\nfunction formatSearchGroups(groups: SearchOutputGroup[], limit: number, perFileLimit = 20): string {\n\treturn groups.slice(0, Math.max(0, limit)).flatMap((group) => sliceGroupLinesByMatchCount(group.lines, perFileLimit)).join(\"\\n\");\n}\n\nfunction dedupeRenderedSearchOutput(content: string): string {\n\tconst out: string[] = [], seen = new Set<string>(); let header = \"\", sawContinuationHint = false, sawCapHint = false;\n\tfor (const line of content.split(\"\\n\")) {\n\t\tconst h = line.match(/^\\[([^\\]#]+)#[0-9A-F]{4}\\]$/); if (h) header = h[1]!;\n\t\tif (/^\\[\\d+ matching files shown\\. Use skip=\\d+ to view more\\.\\]$/.test(line)) { if (sawContinuationHint) continue; sawContinuationHint = true; }\n\t\tif (line.startsWith(\"[Search collected the first \")) { if (sawCapHint) continue; sawCapHint = true; }\n\t\tconst m = header ? line.match(/^[* ]?(\\d+):/) : undefined;\n\t\tconst key = m ? `${header}:${m[1]}` : \"\"; if (key && seen.has(key)) continue; if (key) seen.add(key); out.push(line);\n\t}\n\treturn out.join(\"\\n\");\n}\nfunction formatSearchCall(\n\targs: { pattern: string; path?: string; paths?: string | string[]; glob?: string; limit?: number } | undefined,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.ts\").theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPaths = Array.isArray(args?.paths) ? args.paths.join(\", \") : args?.paths;\n\tconst rawPath = str(args?.path ?? rawPaths);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"search\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nexport function createSearchToolDefinition(\n\tcwd: string,\n\toptions?: SearchToolOptions,\n): ToolDefinition<typeof searchSchema, SearchToolDetails | undefined> {\n\tconst grepDefinition = createGrepToolDefinition(cwd, { ...options, nativeCache: false });\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn {\n\t\t...grepDefinition,\n\t\tname: \"search\",\n\t\tlabel: \"search\",\n\t\tdescription: \"Search file contents with a regex across files, directories, globs, and internal URLs.\",\n\t\tpromptSnippet: \"Search file contents with regex patterns.\",\n\t\tparameters: searchSchema,\n\t\tasync execute(toolCallId, params, signal, onUpdate, ctx) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tif (params.pattern.trim() === \"\") throw new Error(\"Pattern must not be empty\");\n\t\t\tconst targets = normalizeSearchTargets(params.paths, cwd);\n\t\t\tconst ignoreCase = params.i === true || params.case === false;\n\t\t\tconst contextBefore = options?.contextBefore ?? 1, contextAfter = options?.contextAfter ?? 3, searchContext = Math.max(contextBefore, contextAfter);\n\t\t\tconst isSingleFileSearch = targets.length === 1 && await fsStat(resolveToCwd(targets[0]!.path, cwd)).then((stat) => stat.isFile()).catch(() => false);\n\t\t\tconst limit = isSingleFileSearch ? SINGLE_FILE_MATCHES : DEFAULT_LIMIT;\n\t\t\tlet skip = normalizeSkip(params.skip);\n\t\t\tconst singleFileSkipIgnored = skip > 0 && isSingleFileSearch;\n\t\t\tif (singleFileSkipIgnored) skip = 0;\n\t\t\tfor (const target of targets) {\n\t\t\t\tif (target.archive || target.sqlite || target.internal) continue;\n\t\t\t\tif (target.lineRanges && !await fsStat(resolveToCwd(target.path, cwd)).then((stat) => stat.isFile()).catch(() => false)) {\n\t\t\t\t\tthrow new Error(\"Line-range search selectors are only supported for single files\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst results: Awaited<ReturnType<typeof grepDefinition.execute>>[] = [];\n\t\t\tconst groups: PagedSearchOutputGroup[] = [];\n\t\t\tconst skippedMissingPaths: string[] = [];\n\t\t\tconst scopePath = targets.map((target) => target.path).join(\", \") || \".\";\n\t\t\tlet pageFullWithMore = false, internalSearchCapped = false;\n\t\t\tlet remaining = limit;\n\t\t\tconst targetHasMatch = async (target: SearchTarget): Promise<boolean> => {\n\t\t\t\tif (target.archive || target.sqlite || target.internal) {\n\t\t\t\t\tconst archive = target.archive ? resolveArchiveSelector(target.archive, cwd) : undefined;\n\t\t\t\t\tconst text = archive ? searchArchiveSelector(archive, params.pattern, ignoreCase, false, contextBefore, contextAfter) : target.sqlite ? searchSqliteSelector(target.sqlite, params.pattern, ignoreCase, contextBefore, contextAfter) : await searchInternalSelector(target.internal!, cwd, params.pattern, ignoreCase, false, resourceCtx, contextBefore, contextAfter);\n\t\t\t\t\treturn groupSearchOutput(filterSearchOutputByLineRange(text, target.lineRanges, contextBefore, contextAfter)).length > 0;\n\t\t\t\t}\n\t\t\t\tconst ranged = await searchFileLineRanges(target, cwd, params.pattern, ignoreCase, contextBefore, contextAfter);\n\t\t\t\tif (ranged !== undefined) return groupSearchOutput(ranged).length > 0;\n\t\t\t\tconst probe = await grepDefinition.execute(toolCallId, { pattern: params.pattern, path: target.path, glob: target.glob, ignoreCase, literal: false, context: 0, limit: 1, gitignore: params.gitignore }, signal, undefined, ctx);\n\t\t\t\treturn probe.content.some((item) => item.type === \"text\" && item.text && item.text !== \"No matches found\");\n\t\t\t};\n\t\t\tfor (const target of targets) {\n\t\t\t\tif (skip === 0 && remaining <= 0) { if (!target.archive && !target.sqlite && !target.internal && targets.length > 1 && await fsStat(resolveToCwd(target.path, cwd)).then(() => false).catch(() => true)) { skippedMissingPaths.push(target.path); continue; } if (await targetHasMatch(target)) { pageFullWithMore = true; break; } continue; }\n\t\t\t\tif (target.archive || target.sqlite || target.internal) {\n\t\t\t\t\tconst archive = target.archive ? resolveArchiveSelector(target.archive, cwd) : undefined;\n\t\t\t\t\tlet text = archive ? searchArchiveSelector(archive, params.pattern, ignoreCase, false, contextBefore, contextAfter) : target.sqlite ? searchSqliteSelector(target.sqlite, params.pattern, ignoreCase, contextBefore, contextAfter) : await searchInternalSelector(target.internal!, cwd, params.pattern, ignoreCase, false, resourceCtx, contextBefore, contextAfter);\n\t\t\t\t\tif (archive && target.archive) text = text.split(archive.archivePath).join(target.archive.archivePath); if (target.sqlite) text = text.split(target.sqlite.databasePath).join(target.path.match(/^(.+?\\.(?:sqlite3?|db3?))/i)?.[1] ?? target.sqlite.databasePath); text = text || \"No matches found\";\n\t\t\t\t\ttext = filterSearchOutputByLineRange(text, target.lineRanges, contextBefore, contextAfter);\n\t\t\t\t\tconst outputGroups = groupSearchOutput(text);\n\t\t\t\t\tif (skip > 0) groups.push(...outputGroups.map((group) => ({ targetPath: target.path, virtual: isVirtualSearchTarget(target), group })) );\n\t\t\t\t\telse if (outputGroups.length > 0) {\n\t\t\t\t\t\tconst hadMore = outputGroups.length > remaining;\n\t\t\t\t\t\ttext = formatSearchGroups(outputGroups, remaining);\n\t\t\t\t\t\tif (hadMore) { text += `\\n\\n${continuationHint(limit, skip)}`; pageFullWithMore = true; }\n\t\t\t\t\t\tremaining -= Math.min(remaining, outputGroups.length);\n\t\t\t\t\t} else if (text && text !== \"No matches found\") {\n\t\t\t\t\t\tremaining--;\n\t\t\t\t\t} else text = \"No matches found\";\n\t\t\t\t\tif (skip === 0) results.push({ content: [{ type: \"text\" as const, text }], details: undefined });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (targets.length > 1 && await fsStat(resolveToCwd(target.path, cwd)).then(() => false).catch(() => true)) {\n\t\t\t\t\tskippedMissingPaths.push(target.path);\n\t\t\t\t\tresults.push({ content: [{ type: \"text\" as const, text: \"No matches found\" }], details: undefined });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst rangedText = await searchFileLineRanges(target, cwd, params.pattern, ignoreCase, contextBefore, contextAfter);\n\t\t\t\tif (rangedText !== undefined) {\n\t\t\t\t\tlet text = applyDefaultSearchContext(rangedText, contextBefore, contextAfter) || \"No matches found\";\n\t\t\t\t\tconst result = { content: [{ type: \"text\" as const, text }], details: undefined as SearchToolDetails | undefined };\n\t\t\t\t\tresults.push(result);\n\t\t\t\t\tconst outputGroups = groupSearchOutput(text);\n\t\t\t\t\tif (skip > 0) groups.push(...outputGroups.map((group) => ({ targetPath: target.path, virtual: false, group })));\n\t\t\t\t\telse if (!isSingleFileSearch && outputGroups.length > 0) { const hadMore = outputGroups.length > remaining; text = formatSearchGroups(outputGroups, remaining); if (hadMore) { result.details = fileLimitDetails(limit); pageFullWithMore = true; } remaining -= Math.min(remaining, outputGroups.length); result.content = [{ type: \"text\", text }]; }\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst result = await grepDefinition.execute(\n\t\t\t\t\ttoolCallId,\n\t\t\t\t\t{\n\t\t\t\t\t\tpattern: params.pattern,\n\t\t\t\t\t\tpath: target.path,\n\t\t\t\t\t\tglob: target.glob,\n\t\t\t\t\t\tignoreCase,\n\t\t\t\t\t\tliteral: false,\n\t\t\t\t\t\tcontext: searchContext,\n\t\t\t\t\t\tmaxCountPerFile: isSingleFileSearch ? SINGLE_FILE_MATCHES : MULTI_FILE_PER_FILE_MATCHES,\n\t\t\t\t\t\tlimit: INTERNAL_SKIP_LIMIT,\n\t\t\t\t\t\tgitignore: params.gitignore,\n\t\t\t\t\t},\n\t\t\t\t\tsignal,\n\t\t\t\t\tonUpdate,\n\t\t\t\t\tctx,\n\t\t\t\t);\n\t\t\t\tresults.push(result);\n\t\t\t\tif (result.details?.matchLimitReached) internalSearchCapped = true;\n\t\t\t\tlet text = result.content\n\t\t\t\t\t.map((item) => (item.type === \"text\" ? item.text : undefined))\n\t\t\t\t\t.filter((text): text is string => typeof text === \"string\")\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t\ttext = filterSearchOutputByLineRange(text, target.lineRanges, contextBefore, contextAfter);\n\t\t\t\tif (text !== \"No matches found\") text = applyDefaultSearchContext(text, contextBefore, contextAfter) || \"No matches found\";\n\t\t\t\tconst outputGroups = groupSearchOutput(text);\n\t\t\t\tif (skip > 0) groups.push(...outputGroups.map((group) => ({ targetPath: target.path, virtual: false, group })) );\n\t\t\t\telse if (!isSingleFileSearch && outputGroups.length > 0) {\n\t\t\t\t\tconst hadMore = outputGroups.length > remaining;\n\t\t\t\t\ttext = formatSearchGroups(outputGroups, remaining);\n\t\t\t\t\tif (hadMore) { result.details = { ...(result.details ?? {}), ...fileLimitDetails(limit) }; pageFullWithMore = true; }\n\t\t\t\t\tremaining -= Math.min(remaining, outputGroups.length);\n\t\t\t\t}\n\t\t\t\tresult.content = [{ type: \"text\", text }];\n\t\t\t}\n\n\t\t\tconst details: SearchToolDetails = {};\n\t\t\tfor (const result of results) {\n\t\t\t\tif (result.details?.truncation) details.truncation = result.details.truncation;\n\t\t\t\tif (result.details?.matchLimitReached) details.matchLimitReached = result.details.matchLimitReached;\n\t\t\t\tif (hasFileLimit(result.details)) markFileLimit(details, limit);\n\t\t\t\tif (result.details?.linesTruncated) details.linesTruncated = true;\n\t\t\t}\n\n\t\t\tif (skip > 0) {\n\t\t\t\tconst renderedPages: string[] = [];\n\t\t\t\tlet remainingMatches = limit;\n\t\t\t\tfor (const item of groups.slice(skip)) {\n\t\t\t\t\tif (remainingMatches <= 0) break;\n\t\t\t\t\tconst raw = formatSearchGroups([item.group], 1);\n\t\t\t\t\tremainingMatches--;\n\t\t\t\t\tif (raw) renderedPages.push(item.virtual ? raw : await addHashlineHeadersToSearchOutput(raw, cwd, item.targetPath, hashlineStore));\n\t\t\t\t}\n\t\t\t\tconst hasMorePages = groups.slice(skip + limit).length > 0;\n\t\t\t\tconst cappedBeforeRequestedPage = internalSearchCapped && skip >= groups.length;\n\t\t\t\tconst capNotice = internalSearchCapped && !hasMorePages ? `\\n\\n${internalCapHint()}` : \"\";\n\t\t\t\tconst output = `${renderedPages.join(\"\\n\\n\") || `No more results (skip=${skip})`}${hasMorePages ? `\\n\\n${continuationHint(limit, skip)}` : \"\"}${capNotice}`;\n\t\t\t\tif (hasMorePages || cappedBeforeRequestedPage || capNotice) markFileLimit(details, limit);\n\t\t\t\tconst truncation = truncateHead(output, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\tlet content = truncation.content;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\tcontent += `\\n\\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: content }],\n\t\t\t\t\tdetails: buildSearchDetails(details, content, cwd, scopePath, skippedMissingPaths),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (results.length === 1) {\n\t\t\t\tconst result = results[0]!;\n\t\t\t\tlet text = result.content\n\t\t\t\t\t.map((item) => (item.type === \"text\" ? item.text : undefined))\n\t\t\t\t\t.filter((value): value is string => typeof value === \"string\")\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t\ttext = filterSearchOutputByLineRange(text, targets[0]?.lineRanges, contextBefore, contextAfter);\n\t\t\t\tif (!isVirtualSearchTarget(targets[0]) && text !== \"No matches found\") text = applyDefaultSearchContext(text, contextBefore, contextAfter) || \"No matches found\";\n\t\t\t\tconst skipNotice = singleFileSkipIgnored ? \"\\n\\n[skip is ignored for single-file search; refine the pattern/path or search a directory to page matching files.]\" : \"\";\n\t\t\t\tif (isSingleFileSearch && text !== \"No matches found\") text = formatSearchGroups(groupSearchOutput(text), limit, limit);\n\t\t\t\tif (text && text !== \"No matches found\") {\n\t\t\t\t\tconst renderedText = isVirtualSearchTarget(targets[0]) ? text : await addHashlineHeadersToSearchOutput(text, cwd, targets[0]?.path ?? \".\", hashlineStore);\n\t\t\t\t\tconst pagedText = `${hasFileLimit(result.details) ? `${renderedText}\\n\\n${continuationHint(limit, skip)}` : renderedText}${skipNotice}`;\n\t\t\t\t\tconst truncation = truncateHead(pagedText, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\tif (truncation.truncated) return { ...result, content: [{ type: \"text\", text: `${truncation.content}\\n\\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]` }], details: buildSearchDetails({ ...(result.details ?? {}), truncation }, truncation.content, cwd, scopePath, skippedMissingPaths) };\n\t\t\t\t\treturn { ...result, content: [{ type: \"text\", text: pagedText }], details: buildSearchDetails(result.details, pagedText, cwd, scopePath, skippedMissingPaths) };\n\t\t\t\t}\n\t\t\t\treturn { ...result, details: buildSearchDetails(result.details, text || \"No matches found\", cwd, scopePath, skippedMissingPaths) };\n\t\t\t}\n\n\t\t\tconst renderedResults = await Promise.all(results.map(async (result, index) => {\n\t\t\t\tlet text = result.content\n\t\t\t\t\t.map((item) => (item.type === \"text\" ? item.text : undefined))\n\t\t\t\t\t.filter((value): value is string => typeof value === \"string\" && value.length > 0)\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t\ttext = filterSearchOutputByLineRange(text, targets[index]?.lineRanges, contextBefore, contextAfter);\n\t\t\t\tif (!isVirtualSearchTarget(targets[index]) && text !== \"No matches found\") text = applyDefaultSearchContext(text, contextBefore, contextAfter);\n\t\t\t\tif (!text || text === \"No matches found\") return `# ${targets[index]?.path ?? \".\"}\\n${text}`;\n\t\t\t\treturn isVirtualSearchTarget(targets[index]) ? text : await addHashlineHeadersToSearchOutput(text, cwd, targets[index]?.path ?? \".\", hashlineStore);\n\t\t\t}));\n\t\t\tconst content = dedupeRenderedSearchOutput(`${renderedResults.join(\"\\n\\n\")}${skippedMissingPaths.length > 0 ? `\\n\\n[Skipped missing paths: ${skippedMissingPaths.join(\", \")}]` : \"\"}${pageFullWithMore ? `\\n\\n${continuationHint(limit, skip)}` : \"\"}${internalSearchCapped && !pageFullWithMore ? `\\n\\n${internalCapHint()}` : \"\"}`);\n\t\t\tif (pageFullWithMore || internalSearchCapped) markFileLimit(details, limit);\n\t\t\tconst truncation = truncateHead(content, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\tlet output = truncation.content;\n\t\t\tif (truncation.truncated) {\n\t\t\t\tdetails.truncation = truncation;\n\t\t\t\toutput += `\\n\\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\tdetails: buildSearchDetails(details, output, cwd, scopePath, skippedMissingPaths),\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatSearchCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options: ToolRenderResultOptions, theme, context) {\n\t\t\treturn grepDefinition.renderResult?.(result, options, theme, context) ?? new Text(\"\", 0, 0);\n\t\t},\n\t};\n}\n\nexport function createSearchTool(cwd: string, options?: SearchToolOptions): AgentTool<typeof searchSchema> {\n\treturn wrapToolDefinition(createSearchToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/core/tools/search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAuD,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAKhH,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGjF,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,QAAA,MAAM,YAAY;;;;;;;EAYiB,CAAC;AACpC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,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AM,EAAE,UAAU,CAAC;IACnB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACtD,6DAA6D;IAC7D,MAAM,CAAC,EAAE,2BAA2B,CAAC;IACrC,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAyBD,wBAAgB,6BAA6B,CAAC,MAAM,GAAG,OAAO,KAAK,uBAAuB,CAAC,MAAM,CAAC,CAEjG;AAED,wBAAgB,0BAA0B,CAAC,UAAU,SAAS,OAAO,EACpE,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAC9C,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAgChD","sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { type Static, type TSchema } from \"typebox\";\nimport { defineTool, type ToolDefinition } from \"../extensions/types.ts\";\n\nexport const STRUCTURED_OUTPUT_TOOL_NAME = \"structured_output\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = { readonly [key: string]: JsonValue };\n\nexport interface StructuredOutputCapture<TValue = unknown> {\n\tvalue: TValue | undefined;\n\tcalled: boolean;\n}\n\nexport interface StructuredOutputFileCapture {\n\toutputPath: string;\n}\n\nexport interface StructuredOutputToolOptions<TSchemaDef extends TSchema> {\n\t/** Tool parameter schema. */\n\tschema: TSchemaDef;\n\t/** In-process result sink for SDK and workflow callers. */\n\tcapture?: StructuredOutputCapture<Static<TSchemaDef>>;\n\t/** Cross-process result sink for subagent child runtimes. */\n\toutput?: StructuredOutputFileCapture;\n\t/** Tool name. Defaults to `structured_output`. */\n\tname?: string;\n}\n\nfunction stringifyParams<TSchemaDef extends TSchema>(params: Static<TSchemaDef>): string {\n\ttry {\n\t\treturn JSON.stringify(params, null, 2);\n\t} catch (error) {\n\t\tthrow new Error(`Structured output must be JSON-serializable: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n}\n\nasync function writePrivateJsonFile(filePath: string, serializedJson: string): Promise<void> {\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, serializedJson, { mode: 0o600 });\n\t// Re-apply the private mode after writing so pre-existing looser files are tightened too.\n\tawait fs.chmod(filePath, 0o600);\n}\n\nasync function writeCapturedOutput(output: StructuredOutputFileCapture, serializedParams: string): Promise<void> {\n\ttry {\n\t\tawait writePrivateJsonFile(output.outputPath, serializedParams);\n\t} catch (error) {\n\t\tthrow new Error(`Failed to write structured output capture: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n}\n\nexport function createStructuredOutputCapture<TValue = unknown>(): StructuredOutputCapture<TValue> {\n\treturn { value: undefined, called: false };\n}\n\nexport function createStructuredOutputTool<TSchemaDef extends TSchema>(\n\toptions: StructuredOutputToolOptions<TSchemaDef>,\n): ToolDefinition<TSchemaDef, Static<TSchemaDef>> {\n\tconst name = options.name ?? STRUCTURED_OUTPUT_TOOL_NAME;\n\n\treturn defineTool({\n\t\tname,\n\t\tlabel: \"Structured Output\",\n\t\tdescription: \"Return the final machine-readable result.\",\n\t\tpromptSnippet: \"Return final machine-readable output\",\n\t\tpromptGuidelines: [\n\t\t\t`${name} is the final machine-readable result channel; call ${name} exactly once when done.`,\n\t\t\t`Do not write a prose final answer after calling ${name}.`,\n\t\t],\n\t\tparameters: options.schema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tstructuredOutput: true,\n\t\tasync execute(_toolCallId, params): Promise<AgentToolResult<Static<TSchemaDef>>> {\n\t\t\tconst serializedParams = stringifyParams(params);\n\t\t\tif (options.output) {\n\t\t\t\tawait writeCapturedOutput(options.output, serializedParams);\n\t\t\t}\n\t\t\tif (options.capture) {\n\t\t\t\toptions.capture.value = params;\n\t\t\t\toptions.capture.called = true;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: serializedParams }],\n\t\t\t\tdetails: params,\n\t\t\t\tterminate: true,\n\t\t\t};\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"structured-output.d.ts","sourceRoot":"","sources":["../../../src/core/tools/structured-output.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEzE,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/D,MAAM,WAAW,uBAAuB,CAAC,MAAM,GAAG,OAAO;IACxD,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,2BAA2B;IAC3C,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,2BAA2B,CAAC,UAAU,SAAS,OAAO;IACtE,6BAA6B;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACtD,6DAA6D;IAC7D,MAAM,CAAC,EAAE,2BAA2B,CAAC;IACrC,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAyBD,wBAAgB,6BAA6B,CAAC,MAAM,GAAG,OAAO,KAAK,uBAAuB,CAAC,MAAM,CAAC,CAEjG;AAED,wBAAgB,0BAA0B,CAAC,UAAU,SAAS,OAAO,EACpE,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAC9C,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAgChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-execute.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkB/D,OAAO,EAKN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,kBAAkB,CAAC;AA8N1B,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,gBAAgB,GACnB,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAuB3C","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { existsSync } from \"node:fs\";\nimport type { ExtensionContext } from \"../extensions/types.ts\";\nimport {\n\tclearAssignmentIfClosed,\n\tformatTodoId,\n\tsplitTodosByAssignment,\n\tvalidateTodoId,\n} from \"./todos-model.ts\";\nimport { deleteTodo, claimTodoAssignment, releaseTodoAssignment } from \"./todos-mutations.ts\";\nimport { getTodoPath, getTodosDir } from \"./todos-paths.ts\";\nimport { serializeTodoForAgent, serializeTodoListForAgent } from \"./todos-render.ts\";\nimport {\n\tappendTodoBody,\n\tensureTodoExists,\n\tensureTodosDir,\n\tgenerateTodoId,\n\tlistTodos,\n\twriteTodoFile,\n} from \"./todos-storage.ts\";\nimport {\n\tisTodoOperationError,\n\ttype TodoFrontMatter,\n\ttype TodoRecord,\n\ttype TodoRecordAction,\n\ttype TodoToolDetails,\n\ttype TodoToolParams,\n} from \"./todos-types.ts\";\nimport { withTodoLock } from \"./todos-locks.ts\";\n\nfunction todoActionResult(\n\taction: TodoRecordAction,\n\ttext: string,\n\tdetailsError: string,\n): AgentToolResult<TodoToolDetails> {\n\treturn {\n\t\tcontent: [{ type: \"text\", text }],\n\t\tdetails: { action, error: detailsError },\n\t};\n}\n\nfunction idRequiredResult(action: TodoRecordAction): AgentToolResult<TodoToolDetails> {\n\treturn todoActionResult(action, \"Error: id required\", \"id required\");\n}\n\nfunction todoSuccessResult(\n\taction: TodoRecordAction,\n\ttodo: TodoRecord,\n): AgentToolResult<TodoToolDetails> {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(todo) }],\n\t\tdetails: { action, todo },\n\t};\n}\n\nfunction todoListResult(\n\taction: \"list\" | \"list-all\",\n\ttodos: TodoFrontMatter[],\n\tcurrentSessionId: string,\n): AgentToolResult<TodoToolDetails> {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: serializeTodoListForAgent(todos) }],\n\t\tdetails: { action, todos, currentSessionId },\n\t};\n}\n\nasync function executeListAction(\n\ttodosDir: string,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tconst todos = await listTodos(todosDir);\n\tconst { assignedTodos, openTodos } = splitTodosByAssignment(todos);\n\tconst listedTodos = [...assignedTodos, ...openTodos];\n\tconst currentSessionId = ctx.sessionManager.getSessionId();\n\treturn todoListResult(\"list\", listedTodos, currentSessionId);\n}\n\nasync function executeListAllAction(\n\ttodosDir: string,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tconst todos = await listTodos(todosDir);\n\tconst currentSessionId = ctx.sessionManager.getSessionId();\n\treturn todoListResult(\"list-all\", todos, currentSessionId);\n}\n\nasync function executeGetAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.id) return idRequiredResult(\"get\");\n\tconst validated = validateTodoId(params.id);\n\tif (\"error\" in validated) {\n\t\treturn todoActionResult(\"get\", validated.error, validated.error);\n\t}\n\tconst normalizedId = validated.id;\n\tconst displayId = formatTodoId(normalizedId);\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tconst todo = await ensureTodoExists(filePath, normalizedId);\n\tif (!todo) {\n\t\treturn todoActionResult(\"get\", `Todo ${displayId} not found`, \"not found\");\n\t}\n\treturn todoSuccessResult(\"get\", todo);\n}\n\nasync function executeCreateAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.title) {\n\t\treturn todoActionResult(\"create\", \"Error: title required\", \"title required\");\n\t}\n\tawait ensureTodosDir(todosDir);\n\tconst id = await generateTodoId(todosDir);\n\tconst filePath = getTodoPath(todosDir, id);\n\tconst todo: TodoRecord = {\n\t\tid,\n\t\ttitle: params.title,\n\t\ttags: params.tags ?? [],\n\t\tstatus: params.status ?? \"open\",\n\t\tcreated_at: new Date().toISOString(),\n\t\tbody: params.body ?? \"\",\n\t};\n\n\tconst result = await withTodoLock<TodoRecord>(todosDir, id, ctx, async () => {\n\t\tawait writeTodoFile(filePath, todo);\n\t\treturn todo;\n\t});\n\n\tif (isTodoOperationError(result)) {\n\t\treturn todoActionResult(\"create\", result.error, result.error);\n\t}\n\treturn todoSuccessResult(\"create\", todo);\n}\n\nasync function executeUpdateAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.id) return idRequiredResult(\"update\");\n\tconst validated = validateTodoId(params.id);\n\tif (\"error\" in validated) {\n\t\treturn todoActionResult(\"update\", validated.error, validated.error);\n\t}\n\tconst normalizedId = validated.id;\n\tconst displayId = formatTodoId(normalizedId);\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn todoActionResult(\"update\", `Todo ${displayId} not found`, \"not found\");\n\t}\n\tconst result = await withTodoLock<TodoRecord>(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayId} not found` };\n\n\t\texisting.id = normalizedId;\n\t\tif (params.title !== undefined) existing.title = params.title;\n\t\tif (params.status !== undefined) existing.status = params.status;\n\t\tif (params.tags !== undefined) existing.tags = params.tags;\n\t\tif (params.body !== undefined) existing.body = params.body;\n\t\tif (!existing.created_at) existing.created_at = new Date().toISOString();\n\t\tclearAssignmentIfClosed(existing);\n\n\t\tawait writeTodoFile(filePath, existing);\n\t\treturn existing;\n\t});\n\n\tif (isTodoOperationError(result)) {\n\t\treturn todoActionResult(\"update\", result.error, result.error);\n\t}\n\treturn todoSuccessResult(\"update\", result);\n}\n\nasync function executeAppendAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.id) return idRequiredResult(\"append\");\n\tconst validated = validateTodoId(params.id);\n\tif (\"error\" in validated) {\n\t\treturn todoActionResult(\"append\", validated.error, validated.error);\n\t}\n\tconst normalizedId = validated.id;\n\tconst displayId = formatTodoId(normalizedId);\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn todoActionResult(\"append\", `Todo ${displayId} not found`, \"not found\");\n\t}\n\tconst result = await withTodoLock<TodoRecord>(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayId} not found` };\n\t\tif (!params.body || !params.body.trim()) {\n\t\t\treturn existing;\n\t\t}\n\t\treturn appendTodoBody(filePath, existing, params.body);\n\t});\n\n\tif (isTodoOperationError(result)) {\n\t\treturn todoActionResult(\"append\", result.error, result.error);\n\t}\n\treturn todoSuccessResult(\"append\", result);\n}\n\nasync function executeClaimAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.id) return idRequiredResult(\"claim\");\n\tconst result = await claimTodoAssignment(todosDir, params.id, ctx, Boolean(params.force));\n\tif (isTodoOperationError(result)) {\n\t\treturn todoActionResult(\"claim\", result.error, result.error);\n\t}\n\treturn todoSuccessResult(\"claim\", result);\n}\n\nasync function executeReleaseAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.id) return idRequiredResult(\"release\");\n\tconst result = await releaseTodoAssignment(todosDir, params.id, ctx, Boolean(params.force));\n\tif (isTodoOperationError(result)) {\n\t\treturn todoActionResult(\"release\", result.error, result.error);\n\t}\n\treturn todoSuccessResult(\"release\", result);\n}\n\nasync function executeDeleteAction(\n\ttodosDir: string,\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tif (!params.id) return idRequiredResult(\"delete\");\n\n\tconst validated = validateTodoId(params.id);\n\tif (\"error\" in validated) {\n\t\treturn todoActionResult(\"delete\", validated.error, validated.error);\n\t}\n\tconst result = await deleteTodo(todosDir, validated.id, ctx);\n\tif (isTodoOperationError(result)) {\n\t\treturn todoActionResult(\"delete\", result.error, result.error);\n\t}\n\treturn todoSuccessResult(\"delete\", result);\n}\n\nexport async function executeTodoToolAction(\n\tparams: TodoToolParams,\n\tctx: ExtensionContext,\n): Promise<AgentToolResult<TodoToolDetails>> {\n\tconst todosDir = getTodosDir(ctx.cwd);\n\n\tswitch (params.action) {\n\t\tcase \"list\":\n\t\t\treturn executeListAction(todosDir, ctx);\n\t\tcase \"list-all\":\n\t\t\treturn executeListAllAction(todosDir, ctx);\n\t\tcase \"get\":\n\t\t\treturn executeGetAction(todosDir, params);\n\t\tcase \"create\":\n\t\t\treturn executeCreateAction(todosDir, params, ctx);\n\t\tcase \"update\":\n\t\t\treturn executeUpdateAction(todosDir, params, ctx);\n\t\tcase \"append\":\n\t\t\treturn executeAppendAction(todosDir, params, ctx);\n\t\tcase \"claim\":\n\t\t\treturn executeClaimAction(todosDir, params, ctx);\n\t\tcase \"release\":\n\t\t\treturn executeReleaseAction(todosDir, params, ctx);\n\t\tcase \"delete\":\n\t\t\treturn executeDeleteAction(todosDir, params, ctx);\n\t}\n}\n"]}
1
+ {"version":3,"file":"todos-execute.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkB/D,OAAO,EAKN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,kBAAkB,CAAC;AA8N1B,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,gBAAgB,GACnB,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAuB3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-locks.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-locks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAIN,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AA6E1B,wBAAsB,YAAY,CAAC,CAAC,EACnC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,EACrB,EAAE,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GACvC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAQjC","sourcesContent":["import fs from \"node:fs/promises\";\nimport type { ExtensionContext } from \"../extensions/types.ts\";\nimport { displayTodoId } from \"./todos-model.ts\";\nimport { getLockPath } from \"./todos-paths.ts\";\nimport {\n\tisTodoOperationError,\n\ttype LockInfo,\n\ttype TodoOperationError,\n\ttype TodoOperationResult,\n} from \"./todos-types.ts\";\n\nconst LOCK_TTL_MS = 30 * 60 * 1000;\n\ntype TodoLockRelease = () => Promise<void>;\n\nasync function readLockInfo(lockPath: string): Promise<LockInfo | null> {\n\ttry {\n\t\tconst raw = await fs.readFile(lockPath, \"utf8\");\n\t\treturn JSON.parse(raw) as LockInfo;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function acquireLock(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n): Promise<TodoLockRelease | TodoOperationError> {\n\tconst lockPath = getLockPath(todosDir, id);\n\tconst now = Date.now();\n\tconst session = ctx.sessionManager.getSessionFile();\n\n\tfor (let attempt = 0; attempt < 2; attempt += 1) {\n\t\ttry {\n\t\t\tconst handle = await fs.open(lockPath, \"wx\");\n\t\t\tconst info: LockInfo = {\n\t\t\t\tid,\n\t\t\t\tpid: process.pid,\n\t\t\t\tsession,\n\t\t\t\tcreated_at: new Date(now).toISOString(),\n\t\t\t};\n\t\t\tawait handle.writeFile(JSON.stringify(info, null, 2), \"utf8\");\n\t\t\tawait handle.close();\n\t\t\treturn async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.unlink(lockPath);\n\t\t\t\t} catch {\n\t\t\t\t\t// ignore\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst fsError = error as { code?: string; message?: string };\n\t\t\tif (fsError.code !== \"EEXIST\") {\n\t\t\t\treturn {\n\t\t\t\t\terror: `Failed to acquire lock: ${fsError.message ?? \"unknown error\"}`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst stats = await fs.stat(lockPath).catch(() => null);\n\t\t\tconst lockAge = stats ? now - stats.mtimeMs : LOCK_TTL_MS + 1;\n\t\t\tif (lockAge <= LOCK_TTL_MS) {\n\t\t\t\tconst info = await readLockInfo(lockPath);\n\t\t\t\tconst owner = info?.session ? ` (session ${info.session})` : \"\";\n\t\t\t\treturn {\n\t\t\t\t\terror: `Todo ${displayTodoId(id)} is locked${owner}. Try again later.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\treturn {\n\t\t\t\t\terror: `Todo ${displayTodoId(id)} lock is stale; rerun in interactive mode to steal it.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst ok = await ctx.ui.confirm(\n\t\t\t\t\"Todo locked\",\n\t\t\t\t`Todo ${displayTodoId(id)} appears locked. Steal the lock?`,\n\t\t\t);\n\t\t\tif (!ok) {\n\t\t\t\treturn { error: `Todo ${displayTodoId(id)} remains locked.` };\n\t\t\t}\n\t\t\tawait fs.unlink(lockPath).catch(() => undefined);\n\t\t}\n\t}\n\n\treturn { error: `Failed to acquire lock for todo ${displayTodoId(id)}.` };\n}\n\nexport async function withTodoLock<T>(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n\tfn: () => Promise<TodoOperationResult<T>>,\n): Promise<TodoOperationResult<T>> {\n\tconst lock = await acquireLock(todosDir, id, ctx);\n\tif (isTodoOperationError(lock)) return lock;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\tawait lock();\n\t}\n}\n"]}
1
+ {"version":3,"file":"todos-locks.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-locks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAIN,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AA6E1B,wBAAsB,YAAY,CAAC,CAAC,EACnC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,EACrB,EAAE,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GACvC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAQjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-model.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,cAAc,UAAU,CAAC;AAGtC,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CASlD;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAM7E;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE1D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE3D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAInE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAUrE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG;IACjE,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,WAAW,EAAE,eAAe,EAAE,CAAC;CAC/B,CAgBA","sourcesContent":["import type { TodoFrontMatter } from \"./todos-types.ts\";\n\nexport const TODO_ID_PREFIX = \"TODO-\";\nconst TODO_ID_PATTERN = /^[a-f0-9]{8}$/i;\n\nexport function formatTodoId(id: string): string {\n\treturn `${TODO_ID_PREFIX}${id}`;\n}\n\nexport function normalizeTodoId(id: string): string {\n\tlet trimmed = id.trim();\n\tif (trimmed.startsWith(\"#\")) {\n\t\ttrimmed = trimmed.slice(1);\n\t}\n\tif (trimmed.toUpperCase().startsWith(TODO_ID_PREFIX)) {\n\t\ttrimmed = trimmed.slice(TODO_ID_PREFIX.length);\n\t}\n\treturn trimmed;\n}\n\nexport function validateTodoId(id: string): { id: string } | { error: string } {\n\tconst normalized = normalizeTodoId(id);\n\tif (!normalized || !TODO_ID_PATTERN.test(normalized)) {\n\t\treturn { error: \"Invalid todo id. Expected TODO-<hex>.\" };\n\t}\n\treturn { id: normalized.toLowerCase() };\n}\n\nexport function displayTodoId(id: string): string {\n\treturn formatTodoId(normalizeTodoId(id));\n}\n\nexport function isTodoClosed(status: string): boolean {\n\treturn [\"closed\", \"done\"].includes(status.toLowerCase());\n}\n\nexport function getTodoTitle(todo: TodoFrontMatter): string {\n\treturn todo.title || \"(untitled)\";\n}\n\nexport function getTodoStatus(todo: TodoFrontMatter): string {\n\treturn todo.status || \"open\";\n}\n\nexport function clearAssignmentIfClosed(todo: TodoFrontMatter): void {\n\tif (isTodoClosed(getTodoStatus(todo))) {\n\t\ttodo.assigned_to_session = undefined;\n\t}\n}\n\nexport function sortTodos(todos: TodoFrontMatter[]): TodoFrontMatter[] {\n\treturn [...todos].sort((a, b) => {\n\t\tconst aClosed = isTodoClosed(a.status);\n\t\tconst bClosed = isTodoClosed(b.status);\n\t\tif (aClosed !== bClosed) return aClosed ? 1 : -1;\n\t\tconst aAssigned = !aClosed && Boolean(a.assigned_to_session);\n\t\tconst bAssigned = !bClosed && Boolean(b.assigned_to_session);\n\t\tif (aAssigned !== bAssigned) return aAssigned ? -1 : 1;\n\t\treturn (a.created_at || \"\").localeCompare(b.created_at || \"\");\n\t});\n}\n\nexport function splitTodosByAssignment(todos: TodoFrontMatter[]): {\n\tassignedTodos: TodoFrontMatter[];\n\topenTodos: TodoFrontMatter[];\n\tclosedTodos: TodoFrontMatter[];\n} {\n\tconst assignedTodos: TodoFrontMatter[] = [];\n\tconst openTodos: TodoFrontMatter[] = [];\n\tconst closedTodos: TodoFrontMatter[] = [];\n\tfor (const todo of todos) {\n\t\tif (isTodoClosed(getTodoStatus(todo))) {\n\t\t\tclosedTodos.push(todo);\n\t\t\tcontinue;\n\t\t}\n\t\tif (todo.assigned_to_session) {\n\t\t\tassignedTodos.push(todo);\n\t\t} else {\n\t\t\topenTodos.push(todo);\n\t\t}\n\t}\n\treturn { assignedTodos, openTodos, closedTodos };\n}\n"]}
1
+ {"version":3,"file":"todos-model.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,cAAc,UAAU,CAAC;AAGtC,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CASlD;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAM7E;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE1D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE3D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAInE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAUrE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG;IACjE,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,WAAW,EAAE,eAAe,EAAE,CAAC;CAC/B,CAgBA"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-mutations.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-mutations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAExE,wBAAsB,mBAAmB,CACxC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,EACrB,KAAK,UAAQ,GACX,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CA6B1C;AAED,wBAAsB,qBAAqB,CAC1C,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,EACrB,KAAK,UAAQ,GACX,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CA2B1C;AAED,wBAAsB,UAAU,CAC/B,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,GACnB,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAiB1C","sourcesContent":["import { existsSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport type { ExtensionContext } from \"../extensions/types.ts\";\nimport { displayTodoId, isTodoClosed, validateTodoId } from \"./todos-model.ts\";\nimport { getTodoPath } from \"./todos-paths.ts\";\nimport { withTodoLock } from \"./todos-locks.ts\";\nimport { ensureTodoExists, writeTodoFile } from \"./todos-storage.ts\";\nimport type { TodoOperationResult, TodoRecord } from \"./todos-types.ts\";\n\nexport async function claimTodoAssignment(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n\tforce = false,\n): Promise<TodoOperationResult<TodoRecord>> {\n\tconst validated = validateTodoId(id);\n\tif (\"error\" in validated) {\n\t\treturn { error: validated.error };\n\t}\n\tconst normalizedId = validated.id;\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn { error: `Todo ${displayTodoId(id)} not found` };\n\t}\n\tconst sessionId = ctx.sessionManager.getSessionId();\n\treturn withTodoLock<TodoRecord>(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayTodoId(id)} not found` };\n\t\tif (isTodoClosed(existing.status)) {\n\t\t\treturn { error: `Todo ${displayTodoId(id)} is closed` };\n\t\t}\n\t\tconst assigned = existing.assigned_to_session;\n\t\tif (assigned && assigned !== sessionId && !force) {\n\t\t\treturn {\n\t\t\t\terror: `Todo ${displayTodoId(id)} is already assigned to session ${assigned}. Use force to override.`,\n\t\t\t};\n\t\t}\n\t\tif (assigned !== sessionId) {\n\t\t\texisting.assigned_to_session = sessionId;\n\t\t\tawait writeTodoFile(filePath, existing);\n\t\t}\n\t\treturn existing;\n\t});\n}\n\nexport async function releaseTodoAssignment(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n\tforce = false,\n): Promise<TodoOperationResult<TodoRecord>> {\n\tconst validated = validateTodoId(id);\n\tif (\"error\" in validated) {\n\t\treturn { error: validated.error };\n\t}\n\tconst normalizedId = validated.id;\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn { error: `Todo ${displayTodoId(id)} not found` };\n\t}\n\tconst sessionId = ctx.sessionManager.getSessionId();\n\treturn withTodoLock<TodoRecord>(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayTodoId(id)} not found` };\n\t\tconst assigned = existing.assigned_to_session;\n\t\tif (!assigned) {\n\t\t\treturn existing;\n\t\t}\n\t\tif (assigned !== sessionId && !force) {\n\t\t\treturn {\n\t\t\t\terror: `Todo ${displayTodoId(id)} is assigned to session ${assigned}. Use force to release.`,\n\t\t\t};\n\t\t}\n\t\texisting.assigned_to_session = undefined;\n\t\tawait writeTodoFile(filePath, existing);\n\t\treturn existing;\n\t});\n}\n\nexport async function deleteTodo(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n): Promise<TodoOperationResult<TodoRecord>> {\n\tconst validated = validateTodoId(id);\n\tif (\"error\" in validated) {\n\t\treturn { error: validated.error };\n\t}\n\tconst normalizedId = validated.id;\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn { error: `Todo ${displayTodoId(id)} not found` };\n\t}\n\n\treturn withTodoLock<TodoRecord>(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayTodoId(id)} not found` };\n\t\tawait fs.unlink(filePath);\n\t\treturn existing;\n\t});\n}\n"]}
1
+ {"version":3,"file":"todos-mutations.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-mutations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAExE,wBAAsB,mBAAmB,CACxC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,EACrB,KAAK,UAAQ,GACX,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CA6B1C;AAED,wBAAsB,qBAAqB,CAC1C,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,EACrB,KAAK,UAAQ,GACX,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CA2B1C;AAED,wBAAsB,UAAU,CAC/B,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,GACnB,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAiB1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-paths.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-paths.ts"],"names":[],"mappings":"AAMA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhE","sourcesContent":["import path from \"node:path\";\nimport { APP_NAME, CONFIG_DIR_NAME, getEnvValue } from \"../../config.ts\";\n\nconst TODO_DIR_NAME = `${CONFIG_DIR_NAME}/todos`;\nconst TODO_PATH_ENV = `${APP_NAME.toUpperCase()}_TODO_PATH`;\n\nexport function getTodosDir(cwd: string): string {\n\tconst overridePath = getEnvValue(TODO_PATH_ENV);\n\tif (overridePath && overridePath.trim()) {\n\t\treturn path.resolve(cwd, overridePath.trim());\n\t}\n\treturn path.resolve(cwd, TODO_DIR_NAME);\n}\n\nexport function getTodosDirLabel(cwd: string): string {\n\tconst overridePath = getEnvValue(TODO_PATH_ENV);\n\tif (overridePath && overridePath.trim()) {\n\t\treturn path.resolve(cwd, overridePath.trim());\n\t}\n\treturn TODO_DIR_NAME;\n}\n\nexport function getTodoPath(todosDir: string, id: string): string {\n\treturn path.join(todosDir, `${id}.md`);\n}\n\nexport function getLockPath(todosDir: string, id: string): string {\n\treturn path.join(todosDir, `${id}.lock`);\n}\n"]}
1
+ {"version":3,"file":"todos-paths.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-paths.ts"],"names":[],"mappings":"AAMA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-render.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAStE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErG,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAG9D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,CAe1E;AAiHD,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAavE;AAED,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,EACxC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,uBAAuB,EAChD,KAAK,EAAE,KAAK,GACV,IAAI,CAyCN","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport {\n\tformatTodoId,\n\tgetTodoStatus,\n\tgetTodoTitle,\n\tisTodoClosed,\n\tnormalizeTodoId,\n\tsplitTodosByAssignment,\n} from \"./todos-model.ts\";\nimport type { TodoFrontMatter, TodoRecord, TodoToolDetails, TodoToolParams } from \"./todos-types.ts\";\n\nexport function serializeTodoForAgent(todo: TodoRecord): string {\n\tconst payload = { ...todo, id: formatTodoId(todo.id) };\n\treturn JSON.stringify(payload, null, 2);\n}\n\nexport function serializeTodoListForAgent(todos: TodoFrontMatter[]): string {\n\tconst { assignedTodos, openTodos, closedTodos } = splitTodosByAssignment(todos);\n\tconst mapTodo = (todo: TodoFrontMatter) => ({\n\t\t...todo,\n\t\tid: formatTodoId(todo.id),\n\t});\n\treturn JSON.stringify(\n\t\t{\n\t\t\tassigned: assignedTodos.map(mapTodo),\n\t\t\topen: openTodos.map(mapTodo),\n\t\t\tclosed: closedTodos.map(mapTodo),\n\t\t},\n\t\tnull,\n\t\t2,\n\t);\n}\n\nfunction renderAssignmentSuffix(\n\ttheme: Theme,\n\ttodo: TodoFrontMatter,\n\tcurrentSessionId?: string,\n): string {\n\tif (!todo.assigned_to_session) return \"\";\n\tconst isCurrent = todo.assigned_to_session === currentSessionId;\n\tconst color = isCurrent ? \"success\" : \"dim\";\n\tconst suffix = isCurrent ? \", current\" : \"\";\n\treturn theme.fg(color, ` (assigned: ${todo.assigned_to_session}${suffix})`);\n}\n\nfunction renderTodoHeading(\n\ttheme: Theme,\n\ttodo: TodoFrontMatter,\n\tcurrentSessionId?: string,\n): string {\n\tconst closed = isTodoClosed(getTodoStatus(todo));\n\tconst titleColor = closed ? \"dim\" : \"text\";\n\tconst tagText = todo.tags.length ? theme.fg(\"dim\", ` [${todo.tags.join(\", \")}]`) : \"\";\n\tconst assignmentText = renderAssignmentSuffix(theme, todo, currentSessionId);\n\treturn (\n\t\ttheme.fg(\"accent\", formatTodoId(todo.id)) +\n\t\t\" \" +\n\t\ttheme.fg(titleColor, getTodoTitle(todo)) +\n\t\ttagText +\n\t\tassignmentText\n\t);\n}\n\nfunction renderTodoList(\n\ttheme: Theme,\n\ttodos: TodoFrontMatter[],\n\texpanded: boolean,\n\tcurrentSessionId?: string,\n): string {\n\tif (!todos.length) return theme.fg(\"dim\", \"No todos\");\n\n\tconst { assignedTodos, openTodos, closedTodos } = splitTodosByAssignment(todos);\n\tconst lines: string[] = [];\n\tconst pushSection = (label: string, sectionTodos: TodoFrontMatter[]) => {\n\t\tlines.push(theme.fg(\"muted\", `${label} (${sectionTodos.length})`));\n\t\tif (!sectionTodos.length) {\n\t\t\tlines.push(theme.fg(\"dim\", \" none\"));\n\t\t\treturn;\n\t\t}\n\t\tconst maxItems = expanded ? sectionTodos.length : Math.min(sectionTodos.length, 3);\n\t\tfor (let i = 0; i < maxItems; i++) {\n\t\t\tlines.push(` ${renderTodoHeading(theme, sectionTodos[i], currentSessionId)}`);\n\t\t}\n\t\tif (!expanded && sectionTodos.length > maxItems) {\n\t\t\tlines.push(theme.fg(\"dim\", ` ... ${sectionTodos.length - maxItems} more`));\n\t\t}\n\t};\n\n\tconst sections: Array<{ label: string; todos: TodoFrontMatter[] }> = [\n\t\t{ label: \"Assigned todos\", todos: assignedTodos },\n\t\t{ label: \"Open todos\", todos: openTodos },\n\t\t{ label: \"Closed todos\", todos: closedTodos },\n\t];\n\n\tsections.forEach((section, index) => {\n\t\tif (index > 0) lines.push(\"\");\n\t\tpushSection(section.label, section.todos);\n\t});\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction renderTodoDetail(theme: Theme, todo: TodoRecord, expanded: boolean): string {\n\tconst summary = renderTodoHeading(theme, todo);\n\tif (!expanded) return summary;\n\n\tconst tags = todo.tags.length ? todo.tags.join(\", \") : \"none\";\n\tconst createdAt = todo.created_at || \"unknown\";\n\tconst bodyText = todo.body?.trim() ? todo.body.trim() : \"No details yet.\";\n\tconst bodyLines = bodyText.split(\"\\n\");\n\n\tconst lines = [\n\t\tsummary,\n\t\ttheme.fg(\"muted\", `Status: ${getTodoStatus(todo)}`),\n\t\ttheme.fg(\"muted\", `Tags: ${tags}`),\n\t\ttheme.fg(\"muted\", `Created: ${createdAt}`),\n\t\t\"\",\n\t\ttheme.fg(\"muted\", \"Body:\"),\n\t\t...bodyLines.map((line) => theme.fg(\"text\", ` ${line}`)),\n\t];\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction appendExpandHint(theme: Theme, text: string): string {\n\treturn `${text}\\n${theme.fg(\"dim\", `(${keyHint(\"app.tools.expand\", \"Expand\")})`)}`;\n}\n\nfunction getActionLabel(action: TodoToolDetails[\"action\"]): string | null {\n\treturn action === \"create\"\n\t\t? \"Created\"\n\t\t: action === \"update\"\n\t\t\t? \"Updated\"\n\t\t\t: action === \"append\"\n\t\t\t\t? \"Appended to\"\n\t\t\t\t: action === \"delete\"\n\t\t\t\t\t? \"Deleted\"\n\t\t\t\t\t: action === \"claim\"\n\t\t\t\t\t\t? \"Claimed\"\n\t\t\t\t\t\t: action === \"release\"\n\t\t\t\t\t\t\t? \"Released\"\n\t\t\t\t\t\t\t: null;\n}\n\nexport function renderTodoCall(args: TodoToolParams, theme: Theme): Text {\n\tconst action = typeof args.action === \"string\" ? args.action : \"\";\n\tconst id = typeof args.id === \"string\" ? args.id : \"\";\n\tconst normalizedId = id ? normalizeTodoId(id) : \"\";\n\tconst title = typeof args.title === \"string\" ? args.title : \"\";\n\tlet text = theme.fg(\"toolTitle\", theme.bold(\"todo \")) + theme.fg(\"muted\", action);\n\tif (normalizedId) {\n\t\ttext += \" \" + theme.fg(\"accent\", formatTodoId(normalizedId));\n\t}\n\tif (title) {\n\t\ttext += \" \" + theme.fg(\"dim\", `\"${title}\"`);\n\t}\n\treturn new Text(text, 0, 0);\n}\n\nexport function renderTodoResult(\n\tresult: AgentToolResult<TodoToolDetails>,\n\t{ expanded, isPartial }: ToolRenderResultOptions,\n\ttheme: Theme,\n): Text {\n\tconst details = result.details as TodoToolDetails | undefined;\n\tif (isPartial) {\n\t\treturn new Text(theme.fg(\"warning\", \"Processing...\"), 0, 0);\n\t}\n\tif (!details) {\n\t\tconst text = result.content[0];\n\t\treturn new Text(text?.type === \"text\" ? text.text : \"\", 0, 0);\n\t}\n\n\tif (details.error) {\n\t\treturn new Text(theme.fg(\"error\", `Error: ${details.error}`), 0, 0);\n\t}\n\n\tif (details.action === \"list\" || details.action === \"list-all\") {\n\t\tlet text = renderTodoList(theme, details.todos, expanded, details.currentSessionId);\n\t\tif (!expanded) {\n\t\t\tconst { closedTodos } = splitTodosByAssignment(details.todos);\n\t\t\tif (closedTodos.length) {\n\t\t\t\ttext = appendExpandHint(theme, text);\n\t\t\t}\n\t\t}\n\t\treturn new Text(text, 0, 0);\n\t}\n\n\tif (!(\"todo\" in details) || !details.todo) {\n\t\tconst text = result.content[0];\n\t\treturn new Text(text?.type === \"text\" ? text.text : \"\", 0, 0);\n\t}\n\n\tlet text = renderTodoDetail(theme, details.todo, expanded);\n\tconst actionLabel = getActionLabel(details.action);\n\tif (actionLabel) {\n\t\tconst lines = text.split(\"\\n\");\n\t\tlines[0] = theme.fg(\"success\", \"✓ \") + theme.fg(\"muted\", `${actionLabel} `) + lines[0];\n\t\ttext = lines.join(\"\\n\");\n\t}\n\tif (!expanded) {\n\t\ttext = appendExpandHint(theme, text);\n\t}\n\treturn new Text(text, 0, 0);\n}\n"]}
1
+ {"version":3,"file":"todos-render.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAStE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErG,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAG9D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,CAe1E;AAiHD,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAavE;AAED,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,eAAe,CAAC,eAAe,CAAC,EACxC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,uBAAuB,EAChD,KAAK,EAAE,KAAK,GACV,IAAI,CAyCN"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-storage.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-storage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiIpE,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,iBAEpD;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG5F;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAErE;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOtE;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA+B5E;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAG/F;AAED,wBAAsB,cAAc,CACnC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,UAAU,CAAC,CAKrB","sourcesContent":["import crypto from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { sortTodos } from \"./todos-model.ts\";\nimport { getTodoPath } from \"./todos-paths.ts\";\nimport type { TodoFrontMatter, TodoRecord } from \"./todos-types.ts\";\n\nfunction parseFrontMatter(text: string, idFallback: string): TodoFrontMatter {\n\tconst data: TodoFrontMatter = {\n\t\tid: idFallback,\n\t\ttitle: \"\",\n\t\ttags: [],\n\t\tstatus: \"open\",\n\t\tcreated_at: \"\",\n\t\tassigned_to_session: undefined,\n\t};\n\n\tconst trimmed = text.trim();\n\tif (!trimmed) return data;\n\n\ttry {\n\t\tconst parsed = JSON.parse(trimmed) as Partial<TodoFrontMatter> | null;\n\t\tif (!parsed || typeof parsed !== \"object\") return data;\n\t\tif (typeof parsed.id === \"string\" && parsed.id) data.id = parsed.id;\n\t\tif (typeof parsed.title === \"string\") data.title = parsed.title;\n\t\tif (typeof parsed.status === \"string\" && parsed.status) data.status = parsed.status;\n\t\tif (typeof parsed.created_at === \"string\") data.created_at = parsed.created_at;\n\t\tif (\n\t\t\ttypeof parsed.assigned_to_session === \"string\" &&\n\t\t\tparsed.assigned_to_session.trim()\n\t\t) {\n\t\t\tdata.assigned_to_session = parsed.assigned_to_session;\n\t\t}\n\t\tif (Array.isArray(parsed.tags)) {\n\t\t\tdata.tags = parsed.tags.filter((tag): tag is string => typeof tag === \"string\");\n\t\t}\n\t} catch {\n\t\treturn data;\n\t}\n\n\treturn data;\n}\n\nfunction findJsonObjectEnd(content: string): number {\n\tlet depth = 0;\n\tlet inString = false;\n\tlet escaped = false;\n\n\tfor (let i = 0; i < content.length; i += 1) {\n\t\tconst char = content[i];\n\n\t\tif (inString) {\n\t\t\tif (escaped) {\n\t\t\t\tescaped = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \"\\\\\") {\n\t\t\t\tescaped = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === '\"') {\n\t\t\t\tinString = false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"') {\n\t\t\tinString = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tdepth += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"}\") {\n\t\t\tdepth -= 1;\n\t\t\tif (depth === 0) return i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction splitFrontMatter(content: string): { frontMatter: string; body: string } {\n\tif (!content.startsWith(\"{\")) {\n\t\treturn { frontMatter: \"\", body: content };\n\t}\n\n\tconst endIndex = findJsonObjectEnd(content);\n\tif (endIndex === -1) {\n\t\treturn { frontMatter: \"\", body: content };\n\t}\n\n\tconst frontMatter = content.slice(0, endIndex + 1);\n\tconst body = content.slice(endIndex + 1).replace(/^\\r?\\n+/, \"\");\n\treturn { frontMatter, body };\n}\n\nfunction parseTodoContent(content: string, idFallback: string): TodoRecord {\n\tconst { frontMatter, body } = splitFrontMatter(content);\n\tconst parsed = parseFrontMatter(frontMatter, idFallback);\n\treturn {\n\t\tid: idFallback,\n\t\ttitle: parsed.title,\n\t\ttags: parsed.tags ?? [],\n\t\tstatus: parsed.status,\n\t\tcreated_at: parsed.created_at,\n\t\tassigned_to_session: parsed.assigned_to_session,\n\t\tbody: body ?? \"\",\n\t};\n}\n\nfunction serializeTodo(todo: TodoRecord): string {\n\tconst frontMatter = JSON.stringify(\n\t\t{\n\t\t\tid: todo.id,\n\t\t\ttitle: todo.title,\n\t\t\ttags: todo.tags ?? [],\n\t\t\tstatus: todo.status,\n\t\t\tcreated_at: todo.created_at,\n\t\t\tassigned_to_session: todo.assigned_to_session || undefined,\n\t\t},\n\t\tnull,\n\t\t2,\n\t);\n\n\tconst body = todo.body ?? \"\";\n\tconst trimmedBody = body.replace(/^\\n+/, \"\").replace(/\\s+$/, \"\");\n\tif (!trimmedBody) return `${frontMatter}\\n`;\n\treturn `${frontMatter}\\n\\n${trimmedBody}\\n`;\n}\n\nexport async function ensureTodosDir(todosDir: string) {\n\tawait fs.mkdir(todosDir, { recursive: true });\n}\n\nexport async function readTodoFile(filePath: string, idFallback: string): Promise<TodoRecord> {\n\tconst content = await fs.readFile(filePath, \"utf8\");\n\treturn parseTodoContent(content, idFallback);\n}\n\nexport async function writeTodoFile(filePath: string, todo: TodoRecord) {\n\tawait fs.writeFile(filePath, serializeTodo(todo), \"utf8\");\n}\n\nexport async function generateTodoId(todosDir: string): Promise<string> {\n\tfor (let attempt = 0; attempt < 10; attempt += 1) {\n\t\tconst id = crypto.randomBytes(4).toString(\"hex\");\n\t\tconst todoPath = getTodoPath(todosDir, id);\n\t\tif (!existsSync(todoPath)) return id;\n\t}\n\tthrow new Error(\"Failed to generate unique todo id\");\n}\n\nexport async function listTodos(todosDir: string): Promise<TodoFrontMatter[]> {\n\tlet entries: string[] = [];\n\ttry {\n\t\tentries = await fs.readdir(todosDir);\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst todos: TodoFrontMatter[] = [];\n\tfor (const entry of entries) {\n\t\tif (!entry.endsWith(\".md\")) continue;\n\t\tconst id = entry.slice(0, -3);\n\t\tconst filePath = path.join(todosDir, entry);\n\t\ttry {\n\t\t\tconst content = await fs.readFile(filePath, \"utf8\");\n\t\t\tconst { frontMatter } = splitFrontMatter(content);\n\t\t\tconst parsed = parseFrontMatter(frontMatter, id);\n\t\t\ttodos.push({\n\t\t\t\tid,\n\t\t\t\ttitle: parsed.title,\n\t\t\t\ttags: parsed.tags ?? [],\n\t\t\t\tstatus: parsed.status,\n\t\t\t\tcreated_at: parsed.created_at,\n\t\t\t\tassigned_to_session: parsed.assigned_to_session,\n\t\t\t});\n\t\t} catch {\n\t\t\t// ignore unreadable todo\n\t\t}\n\t}\n\n\treturn sortTodos(todos);\n}\n\nexport async function ensureTodoExists(filePath: string, id: string): Promise<TodoRecord | null> {\n\tif (!existsSync(filePath)) return null;\n\treturn readTodoFile(filePath, id);\n}\n\nexport async function appendTodoBody(\n\tfilePath: string,\n\ttodo: TodoRecord,\n\ttext: string,\n): Promise<TodoRecord> {\n\tconst spacer = todo.body.trim().length ? \"\\n\\n\" : \"\";\n\ttodo.body = `${todo.body.replace(/\\s+$/, \"\")}${spacer}${text.trim()}\\n`;\n\tawait writeTodoFile(filePath, todo);\n\treturn todo;\n}\n"]}
1
+ {"version":3,"file":"todos-storage.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-storage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiIpE,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,iBAEpD;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG5F;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAErE;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOtE;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA+B5E;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAG/F;AAED,wBAAsB,cAAc,CACnC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,UAAU,CAAC,CAKrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"todos-types.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,UAAW,SAAQ,eAAe;IAClD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU;;;;;;;;EAsBrB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEvD,MAAM,MAAM,UAAU,GACnB,MAAM,GACN,UAAU,GACV,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,SAAS,CAAC;AAEb,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;AAExE,MAAM,MAAM,eAAe,GACxB;IACA,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CACd,GACD;IACA,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEL,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC;AAE5D,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,kBAAkB,CAEpG","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai/compat\";\nimport { type Static, Type } from \"typebox\";\n\nexport interface TodoFrontMatter {\n\tid: string;\n\ttitle: string;\n\ttags: string[];\n\tstatus: string;\n\tcreated_at: string;\n\tassigned_to_session?: string;\n}\n\nexport interface TodoRecord extends TodoFrontMatter {\n\tbody: string;\n}\n\nexport interface LockInfo {\n\tid: string;\n\tpid: number;\n\tsession?: string | null;\n\tcreated_at: string;\n}\n\nexport const TodoParams = Type.Object({\n\taction: StringEnum([\n\t\t\"list\",\n\t\t\"list-all\",\n\t\t\"get\",\n\t\t\"create\",\n\t\t\"update\",\n\t\t\"append\",\n\t\t\"delete\",\n\t\t\"claim\",\n\t\t\"release\",\n\t] as const),\n\tid: Type.Optional(Type.String({ description: \"Todo id (TODO-<hex> or raw hex filename)\" })),\n\ttitle: Type.Optional(Type.String({ description: \"Short summary shown in lists\" })),\n\tstatus: Type.Optional(Type.String({ description: \"Todo status\" })),\n\ttags: Type.Optional(Type.Array(Type.String({ description: \"Todo tag\" }))),\n\tbody: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Long-form details (markdown). Update replaces; append adds.\",\n\t\t}),\n\t),\n\tforce: Type.Optional(Type.Boolean({ description: \"Override another session's assignment\" })),\n});\n\nexport type TodoToolParams = Static<typeof TodoParams>;\n\nexport type TodoAction =\n\t| \"list\"\n\t| \"list-all\"\n\t| \"get\"\n\t| \"create\"\n\t| \"update\"\n\t| \"append\"\n\t| \"delete\"\n\t| \"claim\"\n\t| \"release\";\n\nexport type TodoRecordAction = Exclude<TodoAction, \"list\" | \"list-all\">;\n\nexport type TodoToolDetails =\n\t| {\n\t\t\taction: \"list\" | \"list-all\";\n\t\t\ttodos: TodoFrontMatter[];\n\t\t\tcurrentSessionId?: string;\n\t\t\terror?: string;\n\t }\n\t| {\n\t\t\taction: TodoRecordAction;\n\t\t\ttodo?: TodoRecord;\n\t\t\terror?: string;\n\t };\n\nexport interface TodoOperationError {\n\terror: string;\n}\n\nexport type TodoOperationResult<T> = T | TodoOperationError;\n\nexport function isTodoOperationError<T>(result: TodoOperationResult<T>): result is TodoOperationError {\n\treturn typeof result === \"object\" && result !== null && \"error\" in result;\n}\n"]}
1
+ {"version":3,"file":"todos-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EL,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC;AAE5D,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,kBAAkB,CAEpG"}
@@ -1,5 +1,5 @@
1
- import { StringEnum } from "@earendil-works/pi-ai/compat";
2
1
  import { Type } from "typebox";
2
+ import { StringEnum } from "../typebox-compat.js";
3
3
  export const TodoParams = Type.Object({
4
4
  action: StringEnum([
5
5
  "list",
@@ -1 +1 @@
1
- {"version":3,"file":"todos-types.js","sourceRoot":"","sources":["../../../src/core/tools/todos-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAsB5C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,UAAU,CAAC;QAClB,MAAM;QACN,UAAU;QACV,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,SAAS;KACA,CAAC;IACX,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC,CAAC;IAC3F,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAClF,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;IAClE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IACzE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,6DAA6D;KAC1E,CAAC,CACF;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC,CAAC;CAC5F,CAAC,CAAC;AAoCH,MAAM,UAAU,oBAAoB,CAAI,MAA8B;IACrE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,IAAI,MAAM,CAAC;AAC3E,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai/compat\";\nimport { type Static, Type } from \"typebox\";\n\nexport interface TodoFrontMatter {\n\tid: string;\n\ttitle: string;\n\ttags: string[];\n\tstatus: string;\n\tcreated_at: string;\n\tassigned_to_session?: string;\n}\n\nexport interface TodoRecord extends TodoFrontMatter {\n\tbody: string;\n}\n\nexport interface LockInfo {\n\tid: string;\n\tpid: number;\n\tsession?: string | null;\n\tcreated_at: string;\n}\n\nexport const TodoParams = Type.Object({\n\taction: StringEnum([\n\t\t\"list\",\n\t\t\"list-all\",\n\t\t\"get\",\n\t\t\"create\",\n\t\t\"update\",\n\t\t\"append\",\n\t\t\"delete\",\n\t\t\"claim\",\n\t\t\"release\",\n\t] as const),\n\tid: Type.Optional(Type.String({ description: \"Todo id (TODO-<hex> or raw hex filename)\" })),\n\ttitle: Type.Optional(Type.String({ description: \"Short summary shown in lists\" })),\n\tstatus: Type.Optional(Type.String({ description: \"Todo status\" })),\n\ttags: Type.Optional(Type.Array(Type.String({ description: \"Todo tag\" }))),\n\tbody: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Long-form details (markdown). Update replaces; append adds.\",\n\t\t}),\n\t),\n\tforce: Type.Optional(Type.Boolean({ description: \"Override another session's assignment\" })),\n});\n\nexport type TodoToolParams = Static<typeof TodoParams>;\n\nexport type TodoAction =\n\t| \"list\"\n\t| \"list-all\"\n\t| \"get\"\n\t| \"create\"\n\t| \"update\"\n\t| \"append\"\n\t| \"delete\"\n\t| \"claim\"\n\t| \"release\";\n\nexport type TodoRecordAction = Exclude<TodoAction, \"list\" | \"list-all\">;\n\nexport type TodoToolDetails =\n\t| {\n\t\t\taction: \"list\" | \"list-all\";\n\t\t\ttodos: TodoFrontMatter[];\n\t\t\tcurrentSessionId?: string;\n\t\t\terror?: string;\n\t }\n\t| {\n\t\t\taction: TodoRecordAction;\n\t\t\ttodo?: TodoRecord;\n\t\t\terror?: string;\n\t };\n\nexport interface TodoOperationError {\n\terror: string;\n}\n\nexport type TodoOperationResult<T> = T | TodoOperationError;\n\nexport function isTodoOperationError<T>(result: TodoOperationResult<T>): result is TodoOperationError {\n\treturn typeof result === \"object\" && result !== null && \"error\" in result;\n}\n"]}
1
+ {"version":3,"file":"todos-types.js","sourceRoot":"","sources":["../../../src/core/tools/todos-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAsBlD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,UAAU,CAAC;QAClB,MAAM;QACN,UAAU;QACV,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,SAAS;KACA,CAAC;IACX,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC,CAAC;IAC3F,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAClF,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;IAClE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IACzE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,6DAA6D;KAC1E,CAAC,CACF;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC,CAAC;CAC5F,CAAC,CAAC;AAoCH,MAAM,UAAU,oBAAoB,CAAI,MAA8B;IACrE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,IAAI,MAAM,CAAC;AAC3E,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { StringEnum } from \"../typebox-compat.ts\";\n\nexport interface TodoFrontMatter {\n\tid: string;\n\ttitle: string;\n\ttags: string[];\n\tstatus: string;\n\tcreated_at: string;\n\tassigned_to_session?: string;\n}\n\nexport interface TodoRecord extends TodoFrontMatter {\n\tbody: string;\n}\n\nexport interface LockInfo {\n\tid: string;\n\tpid: number;\n\tsession?: string | null;\n\tcreated_at: string;\n}\n\nexport const TodoParams = Type.Object({\n\taction: StringEnum([\n\t\t\"list\",\n\t\t\"list-all\",\n\t\t\"get\",\n\t\t\"create\",\n\t\t\"update\",\n\t\t\"append\",\n\t\t\"delete\",\n\t\t\"claim\",\n\t\t\"release\",\n\t] as const),\n\tid: Type.Optional(Type.String({ description: \"Todo id (TODO-<hex> or raw hex filename)\" })),\n\ttitle: Type.Optional(Type.String({ description: \"Short summary shown in lists\" })),\n\tstatus: Type.Optional(Type.String({ description: \"Todo status\" })),\n\ttags: Type.Optional(Type.Array(Type.String({ description: \"Todo tag\" }))),\n\tbody: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Long-form details (markdown). Update replaces; append adds.\",\n\t\t}),\n\t),\n\tforce: Type.Optional(Type.Boolean({ description: \"Override another session's assignment\" })),\n});\n\nexport type TodoToolParams = Static<typeof TodoParams>;\n\nexport type TodoAction =\n\t| \"list\"\n\t| \"list-all\"\n\t| \"get\"\n\t| \"create\"\n\t| \"update\"\n\t| \"append\"\n\t| \"delete\"\n\t| \"claim\"\n\t| \"release\";\n\nexport type TodoRecordAction = Exclude<TodoAction, \"list\" | \"list-all\">;\n\nexport type TodoToolDetails =\n\t| {\n\t\t\taction: \"list\" | \"list-all\";\n\t\t\ttodos: TodoFrontMatter[];\n\t\t\tcurrentSessionId?: string;\n\t\t\terror?: string;\n\t }\n\t| {\n\t\t\taction: TodoRecordAction;\n\t\t\ttodo?: TodoRecord;\n\t\t\terror?: string;\n\t };\n\nexport interface TodoOperationError {\n\terror: string;\n}\n\nexport type TodoOperationResult<T> = T | TodoOperationError;\n\nexport function isTodoOperationError<T>(result: TodoOperationResult<T>): result is TodoOperationError {\n\treturn typeof result === \"object\" && result !== null && \"error\" in result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"todos.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE,eAAO,MAAM,uBAAuB,EAAE,MAAM,EAE3C,CAAC;AAEF,wBAAgB,wBAAwB,CACvC,GAAG,GAAE,MAAsB,GACzB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,CAAC,CAiBpD","sourcesContent":["/**\n * This tool stores todo items as files under <todo-dir> (defaults to\n * <CONFIG_DIR_NAME>/todos, or the path in <APP_NAME>_TODO_PATH). Each todo is\n * a standalone markdown file named <id>.md and an optional <id>.lock file is\n * used while a session is editing it.\n *\n * File format in <CONFIG_DIR_NAME>/todos:\n * - The file starts with a JSON object (not YAML) containing the front matter:\n * { id, title, tags, status, created_at, assigned_to_session }\n * - After the JSON block comes optional markdown body text separated by a blank line.\n */\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { executeTodoToolAction } from \"./todos-execute.ts\";\nimport { getTodosDirLabel } from \"./todos-paths.ts\";\nimport { renderTodoCall, renderTodoResult } from \"./todos-render.ts\";\nimport { TodoParams, type TodoToolDetails } from \"./todos-types.ts\";\n\nexport const DEFAULT_PROMPT_GUIDANCE: string[] = [\n\t\"**To-do management**: If the user has a complex task that can be broken down into actionable steps, use the `todo` tool to create a task list before proceeding. This ensures clarity and alignment with the user's goals and that you have a way to track your work and ensure you are meeting the user's expectations.\",\n];\n\nexport function createTodoToolDefinition(\n\tcwd: string = process.cwd(),\n): ToolDefinition<typeof TodoParams, TodoToolDetails> {\n\tconst todosDirLabel = getTodosDirLabel(cwd);\n\n\treturn {\n\t\tname: \"todo\",\n\t\tlabel: \"Todo\",\n\t\tdescription:\n\t\t\t`Manage file-based todos in ${todosDirLabel} (list, list-all, get, create, update, append, delete, claim, release). ` +\n\t\t\t\"Title is the short summary; body is long-form markdown notes (update replaces, append adds). \" +\n\t\t\t\"Todo ids are shown as TODO-<hex>; id parameters accept TODO-<hex> or the raw hex filename. \" +\n\t\t\t\"Claim tasks before working on them to avoid conflicts, and close them when complete.\",\n\t\tparameters: TodoParams,\n\t\tpromptGuidelines: DEFAULT_PROMPT_GUIDANCE,\n\t\texecute: (_toolCallId, params, _signal, _onUpdate, ctx) => executeTodoToolAction(params, ctx),\n\t\trenderCall: renderTodoCall,\n\t\trenderResult: renderTodoResult,\n\t};\n}\n"]}
1
+ {"version":3,"file":"todos.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE,eAAO,MAAM,uBAAuB,EAAE,MAAM,EAE3C,CAAC;AAEF,wBAAgB,wBAAwB,CACvC,GAAG,GAAE,MAAsB,GACzB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,CAAC,CAiBpD"}