@gajae-code/coding-agent 0.14.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/CHANGELOG.md +120 -1
  2. package/dist/types/async/job-manager.d.ts +4 -1
  3. package/dist/types/autoresearch/dashboard.d.ts +29 -4
  4. package/dist/types/autoresearch/data-context.d.ts +25 -0
  5. package/dist/types/autoresearch/git.d.ts +65 -7
  6. package/dist/types/autoresearch/harness.d.ts +58 -0
  7. package/dist/types/autoresearch/prompts.d.ts +51 -0
  8. package/dist/types/autoresearch/runs.d.ts +173 -0
  9. package/dist/types/autoresearch/types.d.ts +9 -139
  10. package/dist/types/capability/types.d.ts +20 -0
  11. package/dist/types/cli/accounts-cli.d.ts +1 -0
  12. package/dist/types/commands/{rlm.d.ts → autoresearch.d.ts} +2 -4
  13. package/dist/types/config/autorouting-contract.d.ts +146 -0
  14. package/dist/types/config/autorouting-generator.d.ts +40 -0
  15. package/dist/types/config/autorouting-tier-map.d.ts +16844 -0
  16. package/dist/types/config/autorouting.d.ts +35 -0
  17. package/dist/types/config/model-discovery-manager.d.ts +8 -1
  18. package/dist/types/config/model-registry.d.ts +30 -1
  19. package/dist/types/config/provider-selection-policy.d.ts +23 -0
  20. package/dist/types/config/settings-schema.d.ts +61 -3
  21. package/dist/types/config/settings.d.ts +3 -0
  22. package/dist/types/coordinator/contract.d.ts +1 -1
  23. package/dist/types/coordinator-mcp/durability.d.ts +29 -0
  24. package/dist/types/coordinator-mcp/event-webhook.d.ts +50 -0
  25. package/dist/types/coordinator-mcp/question-state.d.ts +1 -1
  26. package/dist/types/coordinator-mcp/server.d.ts +14 -0
  27. package/dist/types/crash/index-store.d.ts +3 -0
  28. package/dist/types/crash/record-loader.d.ts +2 -0
  29. package/dist/types/crash/upstream/relay.d.ts +5 -3
  30. package/dist/types/cursor.d.ts +12 -0
  31. package/dist/types/defaults/gjc-defaults.d.ts +35 -1
  32. package/dist/types/defaults/gjc-skills.generated.d.ts +1 -1
  33. package/dist/types/discovery/helpers.d.ts +1 -1
  34. package/dist/types/edit/index.d.ts +2 -1
  35. package/dist/types/eval/py/executor.d.ts +2 -0
  36. package/dist/types/extensibility/extensions/loader.d.ts +32 -0
  37. package/dist/types/extensibility/gjc-plugins/types.d.ts +1 -1
  38. package/dist/types/extensibility/skills.d.ts +2 -0
  39. package/dist/types/gjc-runtime/autoresearch-runtime.d.ts +194 -0
  40. package/dist/types/gjc-runtime/gc-runtime.d.ts +1 -1
  41. package/dist/types/gjc-runtime/psmux-detect.d.ts +1 -1
  42. package/dist/types/gjc-runtime/python-transcript.d.ts +19 -0
  43. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +2 -8
  44. package/dist/types/gjc-runtime/session-layout.d.ts +6 -3
  45. package/dist/types/gjc-runtime/state-renderer.d.ts +0 -22
  46. package/dist/types/gjc-runtime/state-schema.d.ts +7 -7
  47. package/dist/types/gjc-runtime/tmux-common.d.ts +2 -2
  48. package/dist/types/gjc-runtime/ultragoal-change-set.d.ts +38 -1
  49. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +2 -24
  50. package/dist/types/gjc-runtime/ultragoal-validation-policy.d.ts +73 -0
  51. package/dist/types/gjc-runtime/workflow-recovery-projection.d.ts +100 -0
  52. package/dist/types/hooks/skill-keywords.d.ts +1 -1
  53. package/dist/types/main.d.ts +0 -10
  54. package/dist/types/modes/acp/acp-agent.d.ts +13 -6
  55. package/dist/types/modes/components/model-selector.d.ts +14 -0
  56. package/dist/types/modes/components/skill-hud/render.d.ts +6 -1
  57. package/dist/types/modes/components/smart-routing-panel.d.ts +82 -0
  58. package/dist/types/modes/controllers/selector-controller.d.ts +14 -0
  59. package/dist/types/modes/interactive-mode.d.ts +3 -0
  60. package/dist/types/modes/types.d.ts +9 -0
  61. package/dist/types/rlm/artifacts.d.ts +4 -4
  62. package/dist/types/runtime/optional-runtime-services.d.ts +2 -1
  63. package/dist/types/runtime/workspace-tree-service.d.ts +5 -1
  64. package/dist/types/runtime-mcp/config.d.ts +6 -0
  65. package/dist/types/runtime-mcp/manager.d.ts +10 -0
  66. package/dist/types/sdk/acp/adapter.d.ts +0 -4
  67. package/dist/types/sdk/broker/broker.d.ts +1 -1
  68. package/dist/types/sdk/broker/lifecycle.d.ts +57 -2
  69. package/dist/types/sdk/broker/session-index.d.ts +15 -0
  70. package/dist/types/sdk/bus/chat-daemon-control.d.ts +6 -0
  71. package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +4 -0
  72. package/dist/types/sdk/bus/index.d.ts +8 -0
  73. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +2 -0
  74. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +12 -2
  75. package/dist/types/sdk/client/client.d.ts +39 -4
  76. package/dist/types/sdk/host/host.d.ts +1 -0
  77. package/dist/types/sdk/host/internal-autorouting-state.d.ts +3 -0
  78. package/dist/types/sdk/host/model-pin.d.ts +29 -0
  79. package/dist/types/sdk/host/session-runtime.d.ts +2 -1
  80. package/dist/types/sdk/lifecycle-session.d.ts +13 -0
  81. package/dist/types/sdk/router/session-router.d.ts +27 -1
  82. package/dist/types/sdk/session.d.ts +11 -1
  83. package/dist/types/session/agent-session.d.ts +36 -6
  84. package/dist/types/session/artifacts.d.ts +16 -1
  85. package/dist/types/session/internal/managed-session-storage.d.ts +7 -0
  86. package/dist/types/session/session-manager.d.ts +84 -2
  87. package/dist/types/session/session-staging-paths.d.ts +3 -0
  88. package/dist/types/skill-state/canonical-skills.d.ts +1 -1
  89. package/dist/types/skill-state/workflow-hud.d.ts +12 -21
  90. package/dist/types/skill-state/workflow-mutation-guard.d.ts +1 -0
  91. package/dist/types/slash-commands/helpers/autorouting-status.d.ts +8 -0
  92. package/dist/types/system-prompt.d.ts +23 -0
  93. package/dist/types/task/executor.d.ts +35 -4
  94. package/dist/types/task/index.d.ts +17 -3
  95. package/dist/types/task/receipt.d.ts +3 -1
  96. package/dist/types/task/types.d.ts +144 -0
  97. package/dist/types/tools/atomic-file-write.d.ts +72 -0
  98. package/dist/types/tools/descriptors.d.ts +1 -0
  99. package/dist/types/tools/index.d.ts +36 -1
  100. package/dist/types/tools/move-session.d.ts +40 -0
  101. package/dist/types/tools/python.d.ts +12 -0
  102. package/dist/types/tools/resource-gc.d.ts +0 -3
  103. package/dist/types/tools/search.d.ts +8 -1
  104. package/dist/types/tools/skill.d.ts +9 -4
  105. package/dist/types/tools/subagent.d.ts +33 -3
  106. package/dist/types/utils/xml-escape.d.ts +2 -0
  107. package/dist/types/workflow/workflow-intent-diff.d.ts +2 -2
  108. package/dist/types/workflow/workflow-intent-report-consumer.d.ts +1 -1
  109. package/package.json +11 -12
  110. package/scripts/build-sdk-package-smoke.ts +7 -5
  111. package/scripts/check-autorouting-tier-map.ts +183 -0
  112. package/scripts/generate-sdk-operation-inventory.ts +12 -0
  113. package/scripts/generate-tool-catalog.ts +40 -5
  114. package/src/async/job-manager.ts +5 -2
  115. package/src/autoresearch/dashboard.ts +134 -314
  116. package/src/autoresearch/data-context.ts +35 -0
  117. package/src/autoresearch/git.ts +186 -26
  118. package/src/autoresearch/{helpers.ts → harness.ts} +65 -40
  119. package/src/autoresearch/{prompt-setup.md → prompts/prompt-setup.md} +7 -7
  120. package/src/autoresearch/prompts/prompt.md +103 -0
  121. package/src/autoresearch/prompts.ts +126 -0
  122. package/src/autoresearch/runs.ts +708 -0
  123. package/src/autoresearch/types.ts +9 -150
  124. package/src/capability/index.ts +4 -4
  125. package/src/capability/types.ts +20 -0
  126. package/src/cli/accounts-cli.ts +21 -5
  127. package/src/cli/config-cli.ts +25 -1
  128. package/src/cli/fast-help.ts +1 -2
  129. package/src/cli/list-models.ts +5 -8
  130. package/src/cli/setup-cli.ts +8 -0
  131. package/src/cli.ts +2 -21
  132. package/src/commands/autoresearch.ts +33 -0
  133. package/src/commands/coordinator.ts +15 -0
  134. package/src/commands/launch.ts +2 -4
  135. package/src/commands/quick-lane.ts +1 -1
  136. package/src/commands/sdk.ts +24 -0
  137. package/src/commands/state.ts +1 -1
  138. package/src/config/autorouting-contract.ts +474 -0
  139. package/src/config/autorouting-generator.ts +238 -0
  140. package/src/config/autorouting-tier-map.ts +6108 -0
  141. package/src/config/autorouting.ts +120 -0
  142. package/src/config/model-discovery-manager.ts +42 -11
  143. package/src/config/model-registry.ts +348 -68
  144. package/src/config/provider-selection-policy.ts +60 -9
  145. package/src/config/settings-schema.ts +195 -6
  146. package/src/config/settings.ts +62 -1
  147. package/src/config.ts +2 -3
  148. package/src/coordinator/contract.ts +0 -1
  149. package/src/coordinator-mcp/codex-handoff.ts +68 -42
  150. package/src/coordinator-mcp/durability.ts +200 -0
  151. package/src/coordinator-mcp/event-webhook.ts +278 -0
  152. package/src/coordinator-mcp/question-state.ts +109 -46
  153. package/src/coordinator-mcp/server.ts +932 -504
  154. package/src/crash/index-store.ts +126 -22
  155. package/src/crash/record-loader.ts +7 -0
  156. package/src/crash/upstream/relay.ts +82 -34
  157. package/src/cursor.ts +84 -1
  158. package/src/debug/index.ts +26 -0
  159. package/src/defaults/gjc/skills/autoresearch/SKILL.md +116 -0
  160. package/src/defaults/gjc/skills/autoresearch/auto-critic.md +46 -0
  161. package/src/defaults/gjc/skills/autoresearch/auto-iterate.md +42 -0
  162. package/src/defaults/gjc/skills/deep-interview/SKILL.md +17 -37
  163. package/src/defaults/gjc/skills/ralplan/SKILL.md +21 -18
  164. package/src/defaults/gjc/skills/ultragoal/SKILL.md +6 -17
  165. package/src/defaults/gjc/skills/ultragoal/ai-slop-cleaner.md +2 -2
  166. package/src/defaults/gjc-defaults.ts +89 -2
  167. package/src/defaults/gjc-skills.generated.ts +24 -17
  168. package/src/discovery/builtin.ts +18 -5
  169. package/src/discovery/helpers.ts +6 -6
  170. package/src/edit/index.ts +5 -2
  171. package/src/eval/py/executor.ts +8 -0
  172. package/src/extensibility/extensions/loader.ts +135 -13
  173. package/src/extensibility/extensions/wrapper.ts +1 -2
  174. package/src/extensibility/gjc-plugins/schema.ts +1 -1
  175. package/src/extensibility/runtime-skill-discovery.ts +2 -2
  176. package/src/extensibility/skill-management.ts +2 -3
  177. package/src/extensibility/skills.ts +16 -8
  178. package/src/gjc-runtime/autoresearch-runtime.ts +1509 -0
  179. package/src/gjc-runtime/gc-render.ts +0 -1
  180. package/src/gjc-runtime/gc-runtime.ts +1 -11
  181. package/src/gjc-runtime/launch-tmux.ts +3 -3
  182. package/src/gjc-runtime/psmux-detect.ts +2 -2
  183. package/src/gjc-runtime/python-transcript.ts +58 -0
  184. package/src/gjc-runtime/ralplan-runtime.ts +6 -18
  185. package/src/gjc-runtime/session-layout.ts +18 -7
  186. package/src/gjc-runtime/session-state-sidecar.ts +58 -9
  187. package/src/gjc-runtime/state-renderer.ts +0 -38
  188. package/src/gjc-runtime/state-runtime.ts +43 -22
  189. package/src/gjc-runtime/state-schema.ts +1 -1
  190. package/src/gjc-runtime/tmux-common.ts +7 -7
  191. package/src/gjc-runtime/ultragoal-change-set.ts +232 -11
  192. package/src/gjc-runtime/ultragoal-runtime.ts +309 -114
  193. package/src/gjc-runtime/ultragoal-validation-policy.ts +247 -0
  194. package/src/gjc-runtime/workflow-command-ref.ts +15 -11
  195. package/src/gjc-runtime/workflow-manifest.generated.json +413 -532
  196. package/src/gjc-runtime/workflow-manifest.ts +43 -83
  197. package/src/gjc-runtime/workflow-recovery-projection.ts +616 -0
  198. package/src/hooks/skill-keywords.ts +3 -3
  199. package/src/hooks/skill-state.ts +2 -2
  200. package/src/internal-urls/docs-index.generated.ts +26 -24
  201. package/src/lsp/index.ts +25 -5
  202. package/src/main.ts +2 -27
  203. package/src/modes/acp/acp-agent.ts +200 -75
  204. package/src/modes/components/model-selector.ts +216 -13
  205. package/src/modes/components/oauth-selector.ts +5 -5
  206. package/src/modes/components/skill-hud/render.ts +173 -35
  207. package/src/modes/components/smart-routing-panel.ts +531 -0
  208. package/src/modes/components/tool-status-header.ts +6 -3
  209. package/src/modes/controllers/command-controller.ts +17 -7
  210. package/src/modes/controllers/input-controller.ts +44 -9
  211. package/src/modes/controllers/runtime-mcp-command-controller.ts +4 -0
  212. package/src/modes/controllers/selector-controller.ts +298 -65
  213. package/src/modes/interactive-mode.ts +8 -1
  214. package/src/modes/shared/agent-wire/workflow-gate-types.ts +1 -1
  215. package/src/modes/types.ts +9 -1
  216. package/src/prompts/agents/planner.md +1 -1
  217. package/src/prompts/system/system-prompt.md +1 -1
  218. package/src/prompts/system/volatile-project-context.md +2 -1
  219. package/src/prompts/tools/move-session.md +15 -0
  220. package/src/prompts/tools/python.md +12 -0
  221. package/src/prompts/tools/skill-discovery.md +1 -1
  222. package/src/prompts/tools/skill.md +2 -2
  223. package/src/prompts/tools/task-summary.md +1 -0
  224. package/src/prompts/tools/task.md +6 -0
  225. package/src/rlm/artifacts.ts +12 -10
  226. package/src/runtime/optional-runtime-services.ts +3 -2
  227. package/src/runtime/workspace-tree-service.ts +11 -3
  228. package/src/runtime-mcp/config.ts +8 -1
  229. package/src/runtime-mcp/manager.ts +33 -0
  230. package/src/sdk/acp/adapter.ts +48 -1
  231. package/src/sdk/broker/broker.ts +30 -2
  232. package/src/sdk/broker/discovery.ts +217 -2
  233. package/src/sdk/broker/lifecycle.ts +385 -59
  234. package/src/sdk/broker/session-index.ts +243 -48
  235. package/src/sdk/broker/transport.ts +1 -0
  236. package/src/sdk/bus/chat-daemon-control.ts +8 -2
  237. package/src/sdk/bus/chat-daemon-runtime.ts +5 -0
  238. package/src/sdk/bus/index.ts +208 -11
  239. package/src/sdk/bus/kind-aware-reconciliation.ts +16 -0
  240. package/src/sdk/bus/reconciliation-store.ts +27 -5
  241. package/src/sdk/bus/telegram-daemon-contract.ts +12 -2
  242. package/src/sdk/client/client.ts +204 -22
  243. package/src/sdk/host/host.ts +16 -0
  244. package/src/sdk/host/internal-autorouting-state.ts +13 -0
  245. package/src/sdk/host/model-pin.ts +101 -0
  246. package/src/sdk/host/reverse-leases.ts +2 -1
  247. package/src/sdk/host/session-runtime.test.ts +224 -1
  248. package/src/sdk/host/session-runtime.ts +125 -37
  249. package/src/sdk/lifecycle/service.ts +3 -1
  250. package/src/sdk/lifecycle-session.ts +42 -1
  251. package/src/sdk/protocol/operation-inventory.generated.json +66 -0
  252. package/src/sdk/router/session-router.ts +375 -36
  253. package/src/sdk/session.ts +547 -47
  254. package/src/session/account-inventory.ts +1 -1
  255. package/src/session/agent-session.ts +765 -189
  256. package/src/session/artifacts.ts +234 -4
  257. package/src/session/internal/managed-session-storage.ts +91 -4
  258. package/src/session/provider-safety-stop-hint.ts +3 -2
  259. package/src/session/session-manager.ts +775 -16
  260. package/src/session/session-staging-paths.ts +8 -0
  261. package/src/setup/hermes/templates/operator-instructions.v1.md +0 -1
  262. package/src/setup/host-plugin-setup.ts +2 -2
  263. package/src/skill-state/active-state.ts +2 -2
  264. package/src/skill-state/canonical-skills.ts +1 -1
  265. package/src/skill-state/initial-phase.ts +1 -1
  266. package/src/skill-state/workflow-hud.ts +41 -41
  267. package/src/skill-state/workflow-mutation-guard.ts +26 -7
  268. package/src/slash-commands/builtin-registry.ts +77 -0
  269. package/src/slash-commands/helpers/autorouting-status.ts +55 -0
  270. package/src/system-prompt.ts +102 -5
  271. package/src/task/discovery.ts +2 -3
  272. package/src/task/executor.ts +617 -43
  273. package/src/task/index.ts +262 -15
  274. package/src/task/receipt.ts +30 -0
  275. package/src/task/render.ts +11 -1
  276. package/src/task/types.ts +316 -0
  277. package/src/tools/atomic-file-write.ts +594 -0
  278. package/src/tools/bisect.ts +3 -2
  279. package/src/tools/descriptors.test.ts +3 -0
  280. package/src/tools/descriptors.ts +24 -0
  281. package/src/tools/image-gen.ts +5 -1
  282. package/src/tools/index.ts +62 -5
  283. package/src/tools/move-session.ts +107 -0
  284. package/src/tools/python.ts +205 -0
  285. package/src/tools/read.ts +88 -15
  286. package/src/tools/renderers.ts +2 -0
  287. package/src/tools/resource-gc.ts +8 -177
  288. package/src/tools/search.ts +30 -6
  289. package/src/tools/skill-discovery.ts +1 -0
  290. package/src/tools/skill.ts +37 -7
  291. package/src/tools/subagent-render.ts +119 -13
  292. package/src/tools/subagent.ts +91 -74
  293. package/src/tools/tool-catalog.generated.ts +64 -2
  294. package/src/tools/write.ts +16 -12
  295. package/src/utils/xml-escape.ts +14 -0
  296. package/src/web/search/providers/codex.ts +2 -2
  297. package/src/workflow/workflow-intent-diff.ts +13 -12
  298. package/src/workflow/workflow-intent-report-consumer.ts +6 -6
  299. package/dist/types/autoresearch/helpers.d.ts +0 -24
  300. package/dist/types/autoresearch/index.d.ts +0 -2
  301. package/dist/types/autoresearch/state.d.ts +0 -17
  302. package/dist/types/autoresearch/storage.d.ts +0 -142
  303. package/dist/types/autoresearch/tools/init-experiment.d.ts +0 -31
  304. package/dist/types/autoresearch/tools/log-experiment.d.ts +0 -23
  305. package/dist/types/autoresearch/tools/run-experiment.d.ts +0 -8
  306. package/dist/types/autoresearch/tools/update-notes.d.ts +0 -12
  307. package/dist/types/commands/team.d.ts +0 -24
  308. package/dist/types/gjc-runtime/team-gc.d.ts +0 -7
  309. package/dist/types/gjc-runtime/team-launch.d.ts +0 -61
  310. package/dist/types/gjc-runtime/team-notify.d.ts +0 -45
  311. package/dist/types/gjc-runtime/team-runtime.d.ts +0 -336
  312. package/dist/types/gjc-runtime/team-store.d.ts +0 -168
  313. package/dist/types/gjc-runtime/team-worker-heartbeat.d.ts +0 -43
  314. package/dist/types/gjc-runtime/team-worker-memory-guard.d.ts +0 -92
  315. package/dist/types/gjc-runtime/team-workers.d.ts +0 -83
  316. package/dist/types/rlm/index.d.ts +0 -47
  317. package/dist/types/rlm/preset.d.ts +0 -23
  318. package/dist/types/rlm/python-tool.d.ts +0 -16
  319. package/src/autoresearch/command-resume.md +0 -14
  320. package/src/autoresearch/index.ts +0 -536
  321. package/src/autoresearch/prompt.md +0 -103
  322. package/src/autoresearch/resume-message.md +0 -10
  323. package/src/autoresearch/state.ts +0 -273
  324. package/src/autoresearch/storage.ts +0 -699
  325. package/src/autoresearch/tools/init-experiment.ts +0 -272
  326. package/src/autoresearch/tools/log-experiment.ts +0 -524
  327. package/src/autoresearch/tools/run-experiment.ts +0 -475
  328. package/src/autoresearch/tools/update-notes.ts +0 -109
  329. package/src/commands/rlm.ts +0 -19
  330. package/src/commands/team.ts +0 -238
  331. package/src/defaults/gjc/skills/deep-interview/auto-research-greenfield.md +0 -42
  332. package/src/defaults/gjc/skills/team/SKILL.md +0 -467
  333. package/src/gjc-runtime/team-gc.ts +0 -49
  334. package/src/gjc-runtime/team-launch.ts +0 -404
  335. package/src/gjc-runtime/team-notify.ts +0 -326
  336. package/src/gjc-runtime/team-runtime.ts +0 -5923
  337. package/src/gjc-runtime/team-store.ts +0 -878
  338. package/src/gjc-runtime/team-worker-heartbeat.ts +0 -149
  339. package/src/gjc-runtime/team-worker-memory-guard.ts +0 -363
  340. package/src/gjc-runtime/team-workers.ts +0 -1123
  341. package/src/prompts/system/rlm-report-command.md +0 -1
  342. package/src/prompts/system/rlm-research.md +0 -23
  343. package/src/rlm/index.ts +0 -365
  344. package/src/rlm/preset.ts +0 -76
  345. package/src/rlm/python-tool.ts +0 -68
@@ -109,9 +109,32 @@ export interface BuildSystemPromptResult {
109
109
  /** Context-file discovery warnings visible to SDK and session callers. */
110
110
  warnings: string[];
111
111
  }
112
+ /** Host wall-clock facts injected with every turn. */
113
+ export interface LocalTimeContext {
114
+ /** Local calendar date with weekday, e.g. `2026-08-19 (Wed)`. */
115
+ date: string;
116
+ /** Local clock time with UTC offset and IANA zone, e.g. `21:04 UTC+09:00 (Asia/Seoul)`. */
117
+ time: string;
118
+ }
119
+ /**
120
+ * Render the host's local date and clock time for the volatile turn context.
121
+ *
122
+ * Every field is derived from a single `Intl.DateTimeFormat` pass over one
123
+ * resolved zone, so the date, clock, offset, and zone name can never disagree
124
+ * with each other the way `Date`'s local getters can. Falls back to UTC only
125
+ * when the runtime has no usable ICU zone.
126
+ *
127
+ * @param timeZone IANA zone override. Default: the host zone.
128
+ */
129
+ export declare function getLocalTimeContext(now?: Date, timeZone?: string): LocalTimeContext;
112
130
  export interface BuildVolatileProjectContextOptions {
113
131
  cwd?: string;
132
+ /** Clock source for the rendered local date/time. Default: `new Date()`. */
133
+ now?: Date;
134
+ /** Trusted/test-only override in the derived `YYYY-MM-DD (Www)` or `YYYY-MM-DD` format. */
114
135
  date?: string;
136
+ /** Trusted/test-only override in the derived `HH:MM UTC±HH:MM (IANA/Zone)` format. */
137
+ localTime?: string;
115
138
  workspaceTree?: WorkspaceTree;
116
139
  }
117
140
  export declare function buildVolatileProjectContext(options?: BuildVolatileProjectContextOptions): string;
@@ -6,6 +6,7 @@
6
6
  import type { AgentTelemetryConfig, ThinkingLevel } from "@gajae-code/agent-core";
7
7
  import { type Model, type ServiceTier } from "@gajae-code/ai/core";
8
8
  import { AsyncJobManager } from "../async";
9
+ import { type AutoroutingReasonCode } from "../config/autorouting-contract";
9
10
  import { ModelRegistry } from "../config/model-registry";
10
11
  import type { PromptTemplate } from "../config/prompt-templates";
11
12
  import { Settings } from "../config/settings";
@@ -14,14 +15,15 @@ import type { HindsightSessionState } from "../hindsight/state";
14
15
  import type { LocalProtocolOptions } from "../internal-urls";
15
16
  import { AgentRegistry } from "../registry/agent-registry";
16
17
  import type { ForkContextSeed } from "../session/agent-session";
17
- import type { ArtifactManager } from "../session/artifacts";
18
+ import { ArtifactManager } from "../session/artifacts";
18
19
  import type { AuthStorage } from "../session/auth-storage";
19
20
  import { SessionManager, type SessionMemoryMode } from "../session/session-manager";
20
21
  import "../tools/yield";
21
22
  import type { ContextFileEntry } from "../tools";
22
23
  import type { EventBus } from "../utils/event-bus";
23
24
  import type { WorkspaceTree } from "../workspace-tree";
24
- import { type AgentDefinition, type AgentProgress, type SingleResult } from "./types";
25
+ import { type AgentDefinition, type AgentProgress, type AutoroutingPreflightFailure, type SingleResult, type TaskRoutingEvidence } from "./types";
26
+ export type { AutoroutingPreflightFailure } from "./types";
25
27
  import { type ExecutorExecutionMode } from "./ultragoal-redteam-activation";
26
28
  export declare function trimForkContextSeedForModel(seed: ForkContextSeed, model: Model | undefined): ForkContextSeed;
27
29
  /** Options for subagent execution */
@@ -38,6 +40,19 @@ export interface ExecutorOptions {
38
40
  executionMode?: ExecutorExecutionMode;
39
41
  context?: string;
40
42
  description?: string;
43
+ routing?: TaskRoutingEvidence;
44
+ /** Ordered, normalized autorouting candidates for the cross-phase preflight ledger. */
45
+ autoroutingCandidates?: string[];
46
+ autoroutingSkips?: Array<{
47
+ selector: string;
48
+ code: AutoroutingReasonCode;
49
+ }>;
50
+ autoroutingPreflightErrors?: Map<string, unknown>;
51
+ autoroutingPreflight?: boolean;
52
+ autoroutingAttemptId?: string;
53
+ preflightProbe?: boolean;
54
+ preflightDurable?: boolean;
55
+ preflightFenceCallback?: () => void;
41
56
  index: number;
42
57
  id: string;
43
58
  modelOverride?: string | string[];
@@ -129,6 +144,7 @@ export declare class ManagedTaskPersistence {
129
144
  #private;
130
145
  constructor(artifacts: ArtifactManager, taskId: string);
131
146
  openSession(cwd: string, sessionMemoryMode?: SessionMemoryMode): Promise<SessionManager>;
147
+ openStagedSession(attemptId?: string): Promise<SessionManager>;
132
148
  publishOutput(rawOutput: string, metadata: Uint8Array): Promise<void>;
133
149
  }
134
150
  export declare function createManagedTaskPersistence(artifacts: ArtifactManager, taskId: string): ManagedTaskPersistence;
@@ -142,6 +158,7 @@ interface FinalizeSubprocessOutputArgs {
142
158
  rawOutput: string;
143
159
  exitCode: number;
144
160
  stderr: string;
161
+ terminalFailure?: boolean;
145
162
  doneAborted: boolean;
146
163
  signalAborted: boolean;
147
164
  yieldItems?: YieldItem[];
@@ -160,7 +177,21 @@ export declare const SUBAGENT_WARNING_PLACEHOLDER_YIELD = "SYSTEM WARNING: Subag
160
177
  export declare function finalizeSubprocessOutput(args: FinalizeSubprocessOutputArgs): FinalizeSubprocessOutputResult;
161
178
  export declare function createSubagentSettings(baseSettings: Settings, inheritedServiceTier?: ServiceTier): Settings;
162
179
  /**
163
- * Run a single agent in-process.
180
+ * Finalize routing evidence at the executor return boundary: the effective
181
+ * model is the terminal provider-reported model when present, otherwise the
182
+ * auth-resolved model; substitution causes are appended in order.
164
183
  */
184
+ export declare function finalizeRoutingEvidence(routing: TaskRoutingEvidence | undefined, state: {
185
+ resolvedModelString: string | undefined;
186
+ lastAssistantModelString: string | undefined;
187
+ authFallbackUsed: boolean;
188
+ assistantModelMismatch: boolean;
189
+ }): TaskRoutingEvidence | undefined;
190
+ export declare function classifyAutoroutingPreflightFailure(error: unknown, op: Extract<AutoroutingPreflightFailure, {
191
+ kind: "local";
192
+ }>["op"]): AutoroutingPreflightFailure;
193
+ export declare function runSubprocessOnce(options: ExecutorOptions): Promise<SingleResult>;
194
+ export declare function boundedSelector(value: string): string;
195
+ export declare function buildBoundedRoutingSkips(skips: ExecutorOptions["autoroutingSkips"]): Pick<TaskRoutingEvidence, "skips" | "omittedSkipCount" | "omittedByCode">;
196
+ /** Run routed initial tasks through the bounded probe/durable candidate ledger. */
165
197
  export declare function runSubprocess(options: ExecutorOptions): Promise<SingleResult>;
166
- export {};
@@ -3,11 +3,12 @@ import type { Model } from "@gajae-code/ai/core";
3
3
  import { type SubagentRunOutcome } from "@gajae-code/coding-agent/async";
4
4
  import type { ToolSession } from "..";
5
5
  import type { Theme } from "../modes/theme/theme";
6
- import { type SingleResult, type TaskToolDetails, type TaskToolSchemaInstance } from "./types";
6
+ import { type SingleResult, type TaskRoutingEvidence, type TaskToolDetails, type TaskToolSchemaInstance } from "./types";
7
7
  import "../tools/review";
8
+ import { runSubprocess } from "./executor";
8
9
  import { type TaskResultReceipt } from "./receipt";
9
10
  import { renderResult, renderCall as renderTaskCall } from "./render";
10
- export declare function subagentRunOutcomeFromSingleResult(finalText: string, singleResult: (Pick<SingleResult, "aborted" | "exitCode" | "paused" | "setupFailure"> & Partial<Pick<TaskResultReceipt, "status">>) | undefined): string | SubagentRunOutcome;
11
+ export declare function subagentRunOutcomeFromSingleResult(finalText: string, singleResult: (Pick<SingleResult, "aborted" | "exitCode" | "paused" | "setupFailure" | "localErrorSummary"> & Partial<Pick<TaskResultReceipt, "status">>) | undefined): string | SubagentRunOutcome;
11
12
  export { loadBundledAgents as BUNDLED_AGENTS } from "./agents";
12
13
  export { discoverCommands, expandCommand, getCommand } from "./commands";
13
14
  export { discoverAgents, getAgent } from "./discovery";
@@ -18,6 +19,17 @@ export { assertNoRawTaskFields, buildTaskReceipt, buildTaskRoi, buildTaskRoiSumm
18
19
  export type { AgentDefinition, AgentProgress, SingleResult, SubagentLifecyclePayload, SubagentProgressPayload, TaskParams, TaskToolDetails, } from "./types";
19
20
  export { TASK_SUBAGENT_EVENT_CHANNEL, TASK_SUBAGENT_LIFECYCLE_CHANNEL, TASK_SUBAGENT_PROGRESS_CHANNEL, taskSchema, } from "./types";
20
21
  export declare function resolveForkContextMaxTokens(configured: number, model: Model | undefined): number;
22
+ export declare function findRoutingSnapshotModel(selector: string, routingSnapshot: readonly Model[]): Model | undefined;
23
+ /**
24
+ * Project routing evidence into the XML-attribute-safe display view consumed by
25
+ * the task-summary template. The template runtime uses noEscape, so every
26
+ * interpolated attribute value must be escaped here.
27
+ */
28
+ export declare function projectRoutingForSummary(routing: TaskRoutingEvidence | undefined): {
29
+ tier: string;
30
+ effectiveModel: string;
31
+ note: string;
32
+ } | undefined;
21
33
  /**
22
34
  * Task tool - Delegate tasks to specialized agents.
23
35
  *
@@ -47,7 +59,9 @@ export declare class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskT
47
59
  * Repository authority is captured from session cwd *before* agent discovery so
48
60
  * multi-repo workspaces fail closed prior to context/discovery (#2901).
49
61
  */
50
- static create(session: ToolSession): Promise<TaskTool>;
62
+ static create(session: ToolSession, options?: {
63
+ runSubprocess?: typeof runSubprocess;
64
+ }): Promise<TaskTool>;
51
65
  /** Create catalog metadata from bundled agents only, without ambient filesystem discovery. */
52
66
  static createForToolCatalog(session: ToolSession): Promise<TaskTool>;
53
67
  execute(_toolCallId: string, rawParams: unknown, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<TaskToolDetails>): Promise<AgentToolResult<TaskToolDetails>>;
@@ -1,4 +1,4 @@
1
- import { type ReviewFindingsArtifactRef, type SingleResult, type TaskToolDetails } from "./types";
1
+ import { type ReviewFindingsArtifactRef, type SingleResult, type TaskRoutingEvidence, type TaskToolDetails } from "./types";
2
2
  export interface TaskRoi {
3
3
  tokens: number;
4
4
  contextTokens?: number;
@@ -28,6 +28,7 @@ export interface TaskResultReceipt {
28
28
  contextTokens?: number;
29
29
  contextWindow?: number;
30
30
  modelOverride?: string | string[];
31
+ routing?: TaskRoutingEvidence;
31
32
  modelSubstitutionWarning?: SingleResult["modelSubstitutionWarning"];
32
33
  fastMode?: boolean;
33
34
  usage?: SingleResult["usage"];
@@ -42,6 +43,7 @@ export interface TaskResultReceipt {
42
43
  setupFailure?: {
43
44
  summary: string;
44
45
  };
46
+ localErrorSummary?: SingleResult["localErrorSummary"];
45
47
  errorSummary?: string;
46
48
  duplicateDisposition?: SingleResult["duplicateDisposition"];
47
49
  abortSummary?: string;
@@ -1,6 +1,8 @@
1
1
  import type { ThinkingLevel } from "@gajae-code/agent-core";
2
2
  import type { Usage } from "@gajae-code/ai/core";
3
+ import type { FallbackTriggerClass } from "@gajae-code/ai/utils/fallback-transport";
3
4
  import * as z from "zod/v4";
5
+ import { type AutoroutingReasonCode } from "../config/autorouting-contract";
4
6
  import type { TaskResultReceipt } from "./receipt";
5
7
  import type { SpawnRoiReconciliation } from "./roi-reconciliation";
6
8
  import { type TaskSimpleMode } from "./simple-mode";
@@ -45,6 +47,11 @@ export declare const taskItemSchema: z.ZodObject<{
45
47
  id: z.ZodString;
46
48
  description: z.ZodString;
47
49
  assignment: z.ZodString;
50
+ tier: z.ZodOptional<z.ZodEnum<{
51
+ balanced: "balanced";
52
+ fast: "fast";
53
+ strong: "strong";
54
+ }>>;
48
55
  executionMode: z.ZodOptional<z.ZodEnum<{
49
56
  default: "default";
50
57
  "ultragoal-red-team": "ultragoal-red-team";
@@ -77,6 +84,11 @@ export declare const taskSchema: z.ZodObject<{
77
84
  id: z.ZodString;
78
85
  description: z.ZodString;
79
86
  assignment: z.ZodString;
87
+ tier: z.ZodOptional<z.ZodEnum<{
88
+ balanced: "balanced";
89
+ fast: "fast";
90
+ strong: "strong";
91
+ }>>;
80
92
  executionMode: z.ZodOptional<z.ZodEnum<{
81
93
  default: "default";
82
94
  "ultragoal-red-team": "ultragoal-red-team";
@@ -116,6 +128,11 @@ export declare const taskSchemaNoIsolation: z.ZodObject<{
116
128
  id: z.ZodString;
117
129
  description: z.ZodString;
118
130
  assignment: z.ZodString;
131
+ tier: z.ZodOptional<z.ZodEnum<{
132
+ balanced: "balanced";
133
+ fast: "fast";
134
+ strong: "strong";
135
+ }>>;
119
136
  executionMode: z.ZodOptional<z.ZodEnum<{
120
137
  default: "default";
121
138
  "ultragoal-red-team": "ultragoal-red-team";
@@ -155,6 +172,11 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
155
172
  id: z.ZodString;
156
173
  description: z.ZodString;
157
174
  assignment: z.ZodString;
175
+ tier: z.ZodOptional<z.ZodEnum<{
176
+ balanced: "balanced";
177
+ fast: "fast";
178
+ strong: "strong";
179
+ }>>;
158
180
  executionMode: z.ZodOptional<z.ZodEnum<{
159
181
  default: "default";
160
182
  "ultragoal-red-team": "ultragoal-red-team";
@@ -193,6 +215,11 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
193
215
  id: z.ZodString;
194
216
  description: z.ZodString;
195
217
  assignment: z.ZodString;
218
+ tier: z.ZodOptional<z.ZodEnum<{
219
+ balanced: "balanced";
220
+ fast: "fast";
221
+ strong: "strong";
222
+ }>>;
196
223
  executionMode: z.ZodOptional<z.ZodEnum<{
197
224
  default: "default";
198
225
  "ultragoal-red-team": "ultragoal-red-team";
@@ -231,6 +258,11 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
231
258
  id: z.ZodString;
232
259
  description: z.ZodString;
233
260
  assignment: z.ZodString;
261
+ tier: z.ZodOptional<z.ZodEnum<{
262
+ balanced: "balanced";
263
+ fast: "fast";
264
+ strong: "strong";
265
+ }>>;
234
266
  executionMode: z.ZodOptional<z.ZodEnum<{
235
267
  default: "default";
236
268
  "ultragoal-red-team": "ultragoal-red-team";
@@ -269,6 +301,11 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
269
301
  id: z.ZodString;
270
302
  description: z.ZodString;
271
303
  assignment: z.ZodString;
304
+ tier: z.ZodOptional<z.ZodEnum<{
305
+ balanced: "balanced";
306
+ fast: "fast";
307
+ strong: "strong";
308
+ }>>;
272
309
  executionMode: z.ZodOptional<z.ZodEnum<{
273
310
  default: "default";
274
311
  "ultragoal-red-team": "ultragoal-red-team";
@@ -307,6 +344,11 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
307
344
  id: z.ZodString;
308
345
  description: z.ZodString;
309
346
  assignment: z.ZodString;
347
+ tier: z.ZodOptional<z.ZodEnum<{
348
+ balanced: "balanced";
349
+ fast: "fast";
350
+ strong: "strong";
351
+ }>>;
310
352
  executionMode: z.ZodOptional<z.ZodEnum<{
311
353
  default: "default";
312
354
  "ultragoal-red-team": "ultragoal-red-team";
@@ -345,6 +387,11 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
345
387
  id: z.ZodString;
346
388
  description: z.ZodString;
347
389
  assignment: z.ZodString;
390
+ tier: z.ZodOptional<z.ZodEnum<{
391
+ balanced: "balanced";
392
+ fast: "fast";
393
+ strong: "strong";
394
+ }>>;
348
395
  executionMode: z.ZodOptional<z.ZodEnum<{
349
396
  default: "default";
350
397
  "ultragoal-red-team": "ultragoal-red-team";
@@ -532,6 +579,56 @@ export interface SetupFailureSummary {
532
579
  }
533
580
  /** Create a bounded diagnostic that preserves a setup failure's cause without exposing credentials or local paths. */
534
581
  export declare function createSetupFailureSummary(error: unknown): SetupFailureSummary;
582
+ /** Bounded, redaction-safe summary of a terminal local (non-provider) subagent failure. */
583
+ export interface LocalErrorSummary {
584
+ kind: string;
585
+ summary: string;
586
+ }
587
+ /**
588
+ * Runtime-validate a structured overflow diagnostic at the consuming trust
589
+ * boundary. Presence on an `AssistantMessage` is NOT authenticity: a foreign
590
+ * provider/stream payload could set the field, so every value is checked —
591
+ * closed `stage`/`exceeded` literals and finite non-negative integer counters.
592
+ * Returns `undefined` for anything that fails, and the caller then degrades to
593
+ * a fixed neutral sentence instead of interpolating untrusted values (#4618).
594
+ */
595
+ export declare function validateLocalOverflowShape(overflow: unknown): {
596
+ stage: string;
597
+ exceeded: "events" | "bytes" | "both";
598
+ stagedEventCount: number;
599
+ stagedBytes: number;
600
+ incomingEventBytes: number;
601
+ maxStagedEvents: number;
602
+ maxStagedBytes: number;
603
+ } | undefined;
604
+ /**
605
+ * Render the parent-facing summary of a validated overflow diagnostic. Built
606
+ * ONLY from the closed-vocabulary stage/exceeded literals and the numeric
607
+ * counters — no producer-controlled text participates, so a hostile or buggy
608
+ * child can inject nothing through this path (#4618).
609
+ */
610
+ export declare function formatBufferOverflowSummary(overflow: {
611
+ stage: string;
612
+ exceeded: "events" | "bytes" | "both";
613
+ stagedEventCount: number;
614
+ stagedBytes: number;
615
+ incomingEventBytes: number;
616
+ maxStagedEvents: number;
617
+ maxStagedBytes: number;
618
+ }): string;
619
+ /**
620
+ * Build the safe parent-facing summary for a terminal local failure.
621
+ *
622
+ * Trust boundary: the structured `bufferOverflow` shape is runtime-validated
623
+ * (`validateLocalOverflowShape`) before any value is interpolated — closed
624
+ * literals and checked integers only. A shape that fails validation, or an
625
+ * overflow kind with no shape at all, degrades to a fixed neutral sentence.
626
+ * `local_snapshot_failure` uses a fixed sentence too: regex redaction cannot
627
+ * make arbitrary child message text safe to embed in a parent receipt.
628
+ */
629
+ export declare function createLocalErrorSummary(kind: unknown, _message: string | undefined, overflow?: unknown): LocalErrorSummary;
630
+ /** Whether an assistant terminal message carries a known local (non-provider) failure kind. */
631
+ export declare function isAssistantLocalErrorKind(kind: unknown): kind is "local_buffer_overflow" | "local_snapshot_failure";
535
632
  export interface TaskRecoveryArtifactRef {
536
633
  uri: string;
537
634
  sizeBytes: number;
@@ -549,6 +646,45 @@ export interface TaskPersistenceResult {
549
646
  ownerWorktreeApplied: boolean;
550
647
  recoveryRef?: TaskRecoveryArtifactRef;
551
648
  }
649
+ export type RoutingSubstitution = "auth_substituted" | "assistant_model_mismatch";
650
+ /** A typed failure observed while an autorouting candidate is still before the real provider fence. */
651
+ export type AutoroutingPreflightFailure = {
652
+ kind: "local";
653
+ op: "auth_resolve" | "session_open" | "tool_bootstrap" | "preflight_validation";
654
+ transient: boolean;
655
+ } | {
656
+ kind: "transport";
657
+ class: FallbackTriggerClass;
658
+ };
659
+ export type AutoroutingAttemptCode = "probe_passed" | "accepted" | "spawn_transient_retry" | "credential_unavailable" | "config_invalid_terminal" | "post_acceptance_failure" | "unclassified_terminal";
660
+ export type AutoroutingAttempt = {
661
+ selector: string;
662
+ phase: "probe" | "durable";
663
+ code: AutoroutingAttemptCode;
664
+ };
665
+ export type AutoroutingSkip = {
666
+ selector: string;
667
+ code: AutoroutingReasonCode;
668
+ };
669
+ export interface TaskRoutingEvidence {
670
+ tier: "fast" | "balanced" | "strong";
671
+ requestedTier?: "fast" | "balanced" | "strong";
672
+ defaultTierApplied?: true;
673
+ requestedSelector: string;
674
+ authResolvedModel?: string;
675
+ effectiveModel?: string;
676
+ notExecuted?: true;
677
+ substitutions: RoutingSubstitution[];
678
+ manualFallbackReason?: "tier_unmatched" | "tier_missing_in_map";
679
+ freshOnResume?: true;
680
+ note?: string;
681
+ skips?: AutoroutingSkip[];
682
+ omittedSkipCount?: number;
683
+ omittedByCode?: Partial<Record<AutoroutingSkip["code"], number>>;
684
+ attempts?: AutoroutingAttempt[];
685
+ terminal?: "preflight_exhausted" | "all_candidates_skipped";
686
+ }
687
+ export declare function assertRoutingEvidenceInvariant(evidence: TaskRoutingEvidence): void;
552
688
  /** Result from a single agent execution */
553
689
  export interface SingleResult {
554
690
  index: number;
@@ -570,13 +706,21 @@ export interface SingleResult {
570
706
  contextTokens?: number;
571
707
  /** Model's context window in tokens, when known. */
572
708
  contextWindow?: number;
709
+ routing?: TaskRoutingEvidence;
573
710
  modelOverride?: string | string[];
574
711
  modelSubstitutionWarning?: ModelSubstitutionWarning;
575
712
  /** Whether the resolved subagent model ran under the effective fast service tier. */
576
713
  fastMode?: boolean;
577
714
  error?: string;
715
+ /** Safe summary of a terminal local (non-provider) failure kind, e.g. `local_buffer_overflow`. */
716
+ localErrorSummary?: LocalErrorSummary;
578
717
  /** Safe diagnostic for a failure before the subagent sent its first LLM request. */
579
718
  setupFailure?: SetupFailureSummary;
719
+ /** Internal typed autorouting preflight outcome; receipt sanitization omits this field. */
720
+ preflightFailure?: AutoroutingPreflightFailure;
721
+ preflightFenceCrossed?: boolean;
722
+ preflightProbeAccepted?: boolean;
723
+ preflightCommitFailure?: boolean;
580
724
  aborted?: boolean;
581
725
  abortReason?: string;
582
726
  duplicateDisposition?: DuplicateDisposition;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Fail-atomic user-file writes for the write/edit/LSP writethrough path.
3
+ *
4
+ * The guarantee is visibility, not crash durability: a failed write never
5
+ * publishes partial or truncated bytes, and the destination is left byte-
6
+ * identical. It is deliberately NOT crash-atomic -- the parent directory is
7
+ * never fsynced, so a rename can be lost across a system crash.
8
+ *
9
+ * Publication is last-writer-wins, not conditional. Identity is revalidated
10
+ * immediately before the rename, which rejects a destination that was replaced
11
+ * or retargeted while staging, but `rename(2)` commits against the pathname:
12
+ * a writer that publishes a successor inside the window between that check and
13
+ * the rename is overwritten. Closing that window needs an OS conditional-
14
+ * replace primitive; the exchange-based one available here was removed because
15
+ * it validated only after committing and leaked protocol debris into user
16
+ * directories on every successful write. `write` is a last-writer-wins tool by
17
+ * contract, so this is the documented behavior rather than a silent race.
18
+ *
19
+ * `Bun.write` truncates the destination then copies bytes. A permission or IO
20
+ * failure after that truncate leaves a 0-byte target even though the tool
21
+ * reported an error. Stage to a sibling temp, then rename over the destination
22
+ * so a failed attempt never publishes a truncated file. Directory fsync is
23
+ * intentionally omitted: Windows reports `EPERM` for it (#4457) and user-file
24
+ * publication does not need that durability barrier.
25
+ *
26
+ * Destination symlinks are followed: the referent is replaced, the link stays.
27
+ * The referent is re-resolved immediately before publication so a retargeted
28
+ * link cannot silently repoint the write, and when the lexical destination
29
+ * sits inside a session-scoped `gjc-local` root the resolved referent and its
30
+ * parent must remain inside that root (a link there must not redirect the
31
+ * write out of the trust boundary).
32
+ *
33
+ * Staging uses exclusive create (`wx`) so a colliding leftover temp is never
34
+ * truncated or unlinked; only the temp this call created is cleaned on failure.
35
+ * Existing-file mode and ownership are re-applied after staging so a process
36
+ * umask or replacement inode never changes the target's identity. Hard-linked
37
+ * targets are rejected because replacement would split their link group, and
38
+ * target identity is revalidated before the final same-directory rename. The
39
+ * staged bytes are synced before publication; directory fsync is intentionally not
40
+ * promised because Windows reports EPERM for it (#4457).
41
+ */
42
+ export type FileWritePublicationState = "not_published" | "published" | "unknown";
43
+ export declare class FileWriteNotPublishedError extends Error {
44
+ readonly dest: string;
45
+ readonly destUnchanged: boolean;
46
+ readonly publicationState: FileWritePublicationState;
47
+ readonly cause: unknown;
48
+ constructor(dest: string, cause: unknown, options?: {
49
+ destUnchanged?: boolean;
50
+ publicationState?: FileWritePublicationState;
51
+ });
52
+ }
53
+ export declare function isFileWritePermissionError(error: unknown): boolean;
54
+ export declare function formatFileWriteError(error: unknown, dest: string, options?: {
55
+ destUnchanged?: boolean;
56
+ }): string;
57
+ export interface WriteFileAtomicallyOptions {
58
+ /**
59
+ * Trusted root that a resolved symlink referent and its parent must not
60
+ * leave. When omitted, the helper still enforces the session-scoped
61
+ * `gjc-local` boundary implied by a lexical destination under
62
+ * `<tmpdir>/gjc-local/<session-id>`.
63
+ */
64
+ trustBoundary?: string;
65
+ /** Platform override used by deterministic retry tests. */
66
+ platform?: NodeJS.Platform;
67
+ /** Sleep seam used by deterministic retry tests. */
68
+ sleep?: (delayMs: number) => Promise<void>;
69
+ /** Test seam invoked after the fallback handle is opened and before mutation. */
70
+ beforeInPlaceMutation?: () => Promise<void>;
71
+ }
72
+ export declare function writeFileAtomically(dest: string, content: string | Uint8Array, options?: WriteFileAtomicallyOptions): Promise<void>;
@@ -88,6 +88,7 @@ export interface ToolDiscoverySettingsSource {
88
88
  get(key: string): unknown;
89
89
  }
90
90
  export declare function resolveEffectiveDiscoveryMode(settings: ToolDiscoverySettingsSource, explicitMcpConfigPath?: string): EffectiveToolDiscoveryMode;
91
+ export declare function evictCachedTool(key: string): void;
91
92
  export declare const PLATFORM_EXCLUDED_TOOL_DESCRIPTORS: Record<string, ToolDescriptor>;
92
93
  export declare const BUILTIN_TOOL_DESCRIPTORS: Record<string, ToolDescriptor>;
93
94
  export declare const HIDDEN_TOOL_DESCRIPTORS: Record<string, ToolDescriptor>;
@@ -33,6 +33,16 @@ export { TOOL_CATALOG } from "./tool-catalog.generated";
33
33
  export type { WriteToolDetails, WriteToolInput } from "./write";
34
34
  /** Tool type (AgentTool from pi-ai) */
35
35
  export type Tool = AgentTool<any, any, any>;
36
+ /** Built-in automation surfaces that an SDK host may back with its own transport. */
37
+ export type AutomationToolName = "browser" | "computer";
38
+ /**
39
+ * Host-owned implementations for the built-in automation surfaces.
40
+ *
41
+ * Each implementation must use the matching built-in name. The normal
42
+ * AgentTool execute signature carries cancellation through its AbortSignal,
43
+ * while the implementation owns the model-facing schema and description.
44
+ */
45
+ export type AutomationTools = Partial<Record<AutomationToolName, Tool>>;
36
46
  export type ContextFileEntry = {
37
47
  path: string;
38
48
  content: string;
@@ -131,6 +141,16 @@ export interface ToolSession {
131
141
  /** Pre-loaded workspace tree (forwarded to subagents to skip re-scanning) */
132
142
  workspaceTree?: WorkspaceTree;
133
143
  /** Pre-loaded skills */
144
+ /**
145
+ * Explicit user home for runtime skill discovery. Tests construct sessions
146
+ * against an isolated home because the trusted-home resolver deliberately
147
+ * ignores `$HOME` on Linux (it reads the NSS account database instead), so a
148
+ * `process.env.HOME` override cannot steer user-scope discovery there.
149
+ *
150
+ * Production sessions leave this unset and the trusted OS home governs.
151
+ * Runtime discovery only; never threaded into capability loading.
152
+ */
153
+ home?: string;
134
154
  skills?: Skill[];
135
155
  /** Currently executing skill prompt, when this tool session is inside one. */
136
156
  getActiveSkillState?: () => Pick<SkillActiveEntry, "skill" | "session_id"> | undefined;
@@ -264,6 +284,21 @@ export interface ToolSession {
264
284
  goalToolAllowedOps?: readonly ("create" | "get" | "complete" | "resume" | "drop" | "pause")[];
265
285
  /** Goal runtime for the active agent session. */
266
286
  getGoalRuntime?: () => GoalRuntime | undefined;
287
+ /**
288
+ * Agent-invokable session rescope (issue #4629): move the whole session to
289
+ * an existing directory, running the same sequence as the `/move` handler
290
+ * (flush → moveTo → setProjectDir → plugin/capability cache reset). Absent
291
+ * in contexts where relocation must not happen: subagent sessions
292
+ * (taskDepth > 0) and read-only/restricted bash profiles. Bound to one
293
+ * successful move per session, rejects re-entrant calls, and only narrows:
294
+ * the canonical (realpath) target must be a strict descendant of the
295
+ * canonical current cwd. Throws when the target does not exist, is not a
296
+ * directory, or escapes the current scope.
297
+ */
298
+ rescopeSessionCwd?: (path: string) => Promise<{
299
+ from: string;
300
+ to: string;
301
+ }>;
267
302
  /** Bridge to the connected client (e.g. ACP editor host). Tools should route fs/terminal/permission requests through this when available. */
268
303
  getClientBridge?: () => ClientBridge | undefined;
269
304
  /** Get compact conversation context for subagents (excludes tool results, system prompts) */
@@ -400,4 +435,4 @@ export declare function resolveEvalBackends(session: ToolSession): EvalBackendsA
400
435
  /**
401
436
  * Create tools from the descriptor registry.
402
437
  */
403
- export declare function createTools(session: ToolSession, toolNames?: string[]): Promise<Tool[]>;
438
+ export declare function createTools(session: ToolSession, toolNames?: string[], automationTools?: AutomationTools): Promise<Tool[]>;
@@ -0,0 +1,40 @@
1
+ import type { AgentTool, AgentToolResult } from "@gajae-code/agent-core";
2
+ import type { Component } from "@gajae-code/tui";
3
+ import * as z from "zod/v4";
4
+ import type { RenderResultOptions } from "../extensibility/custom-tools/types";
5
+ import type { Theme } from "../modes/theme/theme";
6
+ import type { ToolSession } from "./index";
7
+ declare const moveSessionSchema: z.ZodObject<{
8
+ path: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export type MoveSessionToolInput = z.infer<typeof moveSessionSchema>;
11
+ export interface MoveSessionToolDetails {
12
+ from: string;
13
+ to: string;
14
+ }
15
+ export declare class MoveSessionTool implements AgentTool<typeof moveSessionSchema, MoveSessionToolDetails> {
16
+ #private;
17
+ readonly name = "move_session";
18
+ readonly label = "Move Session";
19
+ readonly loadMode: "essential";
20
+ readonly description: string;
21
+ readonly parameters: z.ZodObject<{
22
+ path: z.ZodString;
23
+ }, z.core.$strip>;
24
+ readonly strict = true;
25
+ readonly intent: "omit";
26
+ readonly concurrency: "exclusive";
27
+ readonly nonAbortable = true;
28
+ constructor(session: ToolSession);
29
+ execute(_toolCallId: string, params: MoveSessionToolInput): Promise<AgentToolResult<MoveSessionToolDetails>>;
30
+ }
31
+ export declare const moveSessionToolRenderer: {
32
+ renderCall: (args: unknown) => Component;
33
+ renderResult: (result: {
34
+ details?: unknown;
35
+ isError?: boolean;
36
+ }, _options: RenderResultOptions & {
37
+ renderContext?: Record<string, unknown>;
38
+ }, theme: Theme) => Component;
39
+ };
40
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { AgentTool } from "@gajae-code/agent-core";
2
+ export declare const PYTHON_TOOL_NAME = "python";
3
+ export declare function pythonKernelOwnerId(sessionId: string): string;
4
+ export interface SessionPythonToolInput {
5
+ /** Working directory for kernel execution (session cwd). */
6
+ cwd: string;
7
+ /** Resolve the GJC session id used for the kernel owner and transcript paths. */
8
+ getSessionId: () => string | null;
9
+ /** Register cleanup with the current logical session lifecycle. */
10
+ registerSessionCleanup: (cleanup: () => Promise<void> | void) => void;
11
+ }
12
+ export declare function createSessionPythonTool(input: SessionPythonToolInput): AgentTool;
@@ -1,6 +1,5 @@
1
1
  import type { WindowsJobMemoryProbeResult } from "@gajae-code/natives";
2
2
  import type { Settings } from "../config/settings";
3
- import type { MemoryGuardWorkerSample } from "../runtime/memory-guard-contract";
4
3
  import { type TabGcSnapshot } from "./browser/tab-supervisor";
5
4
  export interface BrowserGcPolicy {
6
5
  enabled: boolean;
@@ -36,8 +35,6 @@ export interface ResourceGcDeps {
36
35
  removed: number;
37
36
  }>;
38
37
  screenshotArmed: () => boolean;
39
- listTeamWorkers?: (cwd: string, sessionId: string) => Promise<MemoryGuardWorkerSample[]>;
40
- applyTeamWorkerGuard?: (cwd: string, sessionId: string, workerId: string, excessBytes: number, incidentId: string) => Promise<void>;
41
38
  }
42
39
  /** Request collection without synchronously stopping the main event loop. */
43
40
  export declare function requestMemoryPressureGc(): void;
@@ -51,9 +51,16 @@ export interface SearchToolDetails {
51
51
  * non-fatal warning in the renderer and in the model-facing text. */
52
52
  missingPaths?: string[];
53
53
  }
54
+ export interface SearchToolOptions {
55
+ /** Per-call symmetric context width used by Cursor's native Pi grep frame. */
56
+ context?: number;
57
+ /** Per-call total match cap used by Cursor's native Pi grep frame. */
58
+ totalMatchLimit?: number;
59
+ }
54
60
  type SearchParams = z.infer<typeof searchSchema>;
55
61
  export declare class SearchTool implements AgentTool<typeof searchSchema, SearchToolDetails> {
56
62
  private readonly session;
63
+ private readonly options;
57
64
  readonly name = "search";
58
65
  readonly label = "Search";
59
66
  readonly loadMode = "discoverable";
@@ -67,7 +74,7 @@ export declare class SearchTool implements AgentTool<typeof searchSchema, Search
67
74
  skip: z.ZodOptional<z.ZodNumber>;
68
75
  }, z.core.$strict>;
69
76
  readonly strict = true;
70
- constructor(session: ToolSession);
77
+ constructor(session: ToolSession, options?: SearchToolOptions);
71
78
  execute(_toolCallId: string, params: SearchParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<SearchToolDetails>, _toolContext?: AgentToolContext): Promise<AgentToolResult<SearchToolDetails>>;
72
79
  }
73
80
  interface SearchRenderArgs {