@gajae-code/coding-agent 0.17.2 → 0.17.5

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 (390) hide show
  1. package/CHANGELOG.md +267 -0
  2. package/dist/types/cli/daemon-cli.d.ts +3 -1
  3. package/dist/types/cli/github-release.d.ts +17 -0
  4. package/dist/types/cli/public-command-entry.d.ts +56 -0
  5. package/dist/types/cli/public-command-errors.d.ts +126 -0
  6. package/dist/types/cli/public-command-evidence.d.ts +99 -0
  7. package/dist/types/cli/public-command-help.d.ts +65 -0
  8. package/dist/types/cli/public-command-registry.d.ts +69 -0
  9. package/dist/types/cli/session-picker.d.ts +1 -1
  10. package/dist/types/cli/setup-cli.d.ts +1 -0
  11. package/dist/types/cli/skills-cli.d.ts +5 -0
  12. package/dist/types/cli.d.ts +3 -0
  13. package/dist/types/commands/daemon.d.ts +4 -50
  14. package/dist/types/commands/sdk.d.ts +20 -37
  15. package/dist/types/commands/setup.d.ts +3 -0
  16. package/dist/types/commands/skills.d.ts +9 -0
  17. package/dist/types/config/autorouting-tier-map.d.ts +1049 -3
  18. package/dist/types/config/file-lock.d.ts +13 -3
  19. package/dist/types/config/model-profile-activation.d.ts +45 -1
  20. package/dist/types/config/model-registry.d.ts +14 -3
  21. package/dist/types/config/model-resolver.d.ts +1 -1
  22. package/dist/types/config/settings-schema.d.ts +11 -0
  23. package/dist/types/coordinator-mcp/question-state.d.ts +6 -1
  24. package/dist/types/daemon/operator-contract.d.ts +5 -1
  25. package/dist/types/eval/js/worker-protocol.d.ts +2 -0
  26. package/dist/types/exec/bash-executor.d.ts +2 -0
  27. package/dist/types/extensibility/extensions/types.d.ts +12 -0
  28. package/dist/types/extensibility/gjc-plugins/registry.d.ts +4 -0
  29. package/dist/types/extensibility/gjc-plugins/runtime-adapters.d.ts +11 -2
  30. package/dist/types/extensibility/runtime-skill-discovery.d.ts +18 -0
  31. package/dist/types/extensibility/shared-events.d.ts +3 -1
  32. package/dist/types/gjc-runtime/session-state-lock.d.ts +61 -0
  33. package/dist/types/gjc-runtime/state-writer.d.ts +14 -1
  34. package/dist/types/harness-control-plane/control-endpoint.d.ts +4 -1
  35. package/dist/types/harness-control-plane/finalize.d.ts +14 -3
  36. package/dist/types/internal-urls/embedded-protocol.d.ts +9 -0
  37. package/dist/types/internal-urls/index.d.ts +1 -0
  38. package/dist/types/internal-urls/parse.d.ts +9 -1
  39. package/dist/types/main.d.ts +23 -1
  40. package/dist/types/modes/acp/acp-agent.d.ts +55 -1
  41. package/dist/types/modes/acp/startup-provenance.d.ts +16 -0
  42. package/dist/types/modes/components/custom-provider-wizard.d.ts +19 -1
  43. package/dist/types/modes/components/session-selector.d.ts +5 -2
  44. package/dist/types/modes/components/user-message-selector.d.ts +5 -2
  45. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  46. package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
  47. package/dist/types/modes/interactive-mode.d.ts +1 -1
  48. package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +11 -1
  49. package/dist/types/modes/shared/agent-wire/workflow-gate-types.d.ts +14 -1
  50. package/dist/types/modes/types.d.ts +2 -2
  51. package/dist/types/runtime/process-lifecycle.d.ts +2 -0
  52. package/dist/types/runtime-mcp/loader.d.ts +2 -0
  53. package/dist/types/runtime-mcp/manager.d.ts +69 -6
  54. package/dist/types/runtime-mcp/pool.d.ts +17 -0
  55. package/dist/types/runtime-mcp/redaction.d.ts +20 -0
  56. package/dist/types/runtime-mcp/startup-policy.d.ts +6 -0
  57. package/dist/types/runtime-mcp/tool-bridge.d.ts +9 -0
  58. package/dist/types/runtime-mcp/transports/http.d.ts +11 -0
  59. package/dist/types/sdk/broker/broker.d.ts +17 -4
  60. package/dist/types/sdk/broker/ensure.d.ts +3 -0
  61. package/dist/types/sdk/broker/identity.d.ts +5 -1
  62. package/dist/types/sdk/broker/lifecycle-ledger.d.ts +23 -3
  63. package/dist/types/sdk/broker/lifecycle.d.ts +15 -8
  64. package/dist/types/sdk/broker/managed-task-dag.d.ts +1335 -0
  65. package/dist/types/sdk/broker/managed-task-verification.d.ts +37 -0
  66. package/dist/types/sdk/broker/runtime.d.ts +1 -1
  67. package/dist/types/sdk/broker/session-index.d.ts +22 -3
  68. package/dist/types/sdk/broker/spawn-authority.d.ts +12 -0
  69. package/dist/types/sdk/broker/startup-failure.d.ts +4 -0
  70. package/dist/types/sdk/broker/stderr-drainer.d.ts +13 -0
  71. package/dist/types/sdk/bus/index.d.ts +19 -0
  72. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +7 -1
  73. package/dist/types/sdk/bus/telegram-daemon.d.ts +5 -0
  74. package/dist/types/sdk/cli/master-cli.d.ts +6 -10
  75. package/dist/types/sdk/cli/rows.d.ts +19 -1
  76. package/dist/types/sdk/cli/session-cli.d.ts +22 -5
  77. package/dist/types/sdk/client/client.d.ts +2 -0
  78. package/dist/types/sdk/guides/cli.d.ts +3 -4
  79. package/dist/types/sdk/guides/verify.d.ts +2 -0
  80. package/dist/types/sdk/host/host.d.ts +9 -0
  81. package/dist/types/sdk/host/session-runtime.d.ts +31 -0
  82. package/dist/types/sdk/host/types.d.ts +10 -0
  83. package/dist/types/sdk/index.d.ts +1 -0
  84. package/dist/types/sdk/prompt-deadline-flush.d.ts +85 -0
  85. package/dist/types/sdk/prompt-deadline-manager.d.ts +37 -0
  86. package/dist/types/sdk/prompt-tool-boundary.d.ts +73 -0
  87. package/dist/types/sdk/router/session-router.d.ts +2 -0
  88. package/dist/types/sdk/session.d.ts +3 -3
  89. package/dist/types/sdk/startup-capability.d.ts +2 -0
  90. package/dist/types/sdk/transport/relay.d.ts +1 -0
  91. package/dist/types/sdk/transport/serve-cli.d.ts +48 -4
  92. package/dist/types/sdk/transport/stdio.d.ts +5 -1
  93. package/dist/types/session/agent-session.d.ts +175 -23
  94. package/dist/types/session/fallback-chain-controller.d.ts +6 -6
  95. package/dist/types/session/fold-coordinator.d.ts +17 -3
  96. package/dist/types/session/internal/managed-session-storage.d.ts +7 -1
  97. package/dist/types/session/session-manager.d.ts +64 -1
  98. package/dist/types/session/session-work-lease.d.ts +14 -0
  99. package/dist/types/setup/model-onboarding-guidance.d.ts +1 -1
  100. package/dist/types/setup/provider-onboarding.d.ts +81 -1
  101. package/dist/types/task/types.d.ts +2 -0
  102. package/dist/types/tools/bash-interactive.d.ts +1 -0
  103. package/dist/types/tools/bash.d.ts +37 -11
  104. package/dist/types/tools/fetch.d.ts +10 -1
  105. package/dist/types/tools/job.d.ts +1 -1
  106. package/dist/types/tools/steer-fold.d.ts +31 -0
  107. package/dist/types/tools/subagent.d.ts +8 -1
  108. package/dist/types/utils/git.d.ts +28 -2
  109. package/dist/types/utils/mupdf-embedded.d.ts +2 -0
  110. package/dist/types/utils/mupdf.d.ts +4 -0
  111. package/dist/types/utils/session-title-generation.d.ts +6 -0
  112. package/dist/types/utils/title-generator.d.ts +11 -2
  113. package/dist/types/web/scrapers/types.d.ts +3 -0
  114. package/package.json +18 -10
  115. package/scripts/build-binary.ts +9 -3
  116. package/scripts/compile-args.ts +0 -9
  117. package/scripts/embed-mupdf.ts +52 -0
  118. package/scripts/generate-sdk-operation-inventory.ts +31 -1
  119. package/scripts/vendor-markit.ts +196 -0
  120. package/src/async/job-manager.ts +22 -1
  121. package/src/cli/daemon-cli.ts +53 -18
  122. package/src/cli/github-release.ts +87 -5
  123. package/src/cli/mcp-cli.ts +38 -4
  124. package/src/cli/public-command-entry.ts +450 -0
  125. package/src/cli/public-command-errors.ts +581 -0
  126. package/src/cli/public-command-evidence.ts +717 -0
  127. package/src/cli/public-command-help.ts +360 -0
  128. package/src/cli/public-command-registry.ts +541 -0
  129. package/src/cli/session-picker.ts +2 -1
  130. package/src/cli/setup-cli.ts +10 -1
  131. package/src/cli/skills-cli.ts +46 -2
  132. package/src/cli/stats-cli.ts +11 -1
  133. package/src/cli.ts +61 -1
  134. package/src/commands/daemon.ts +65 -69
  135. package/src/commands/sdk.ts +175 -117
  136. package/src/commands/setup.ts +2 -0
  137. package/src/commands/skills.ts +11 -0
  138. package/src/config/autorouting-tier-map.ts +543 -3
  139. package/src/config/file-lock.ts +206 -65
  140. package/src/config/model-discovery-manager.ts +4 -4
  141. package/src/config/model-profile-activation.ts +417 -66
  142. package/src/config/model-registry.ts +254 -36
  143. package/src/config/model-resolver.ts +6 -1
  144. package/src/config/settings-schema.ts +26 -2
  145. package/src/coordinator-mcp/policy.ts +10 -5
  146. package/src/coordinator-mcp/question-gate-codec.ts +17 -0
  147. package/src/coordinator-mcp/question-state.ts +179 -9
  148. package/src/coordinator-mcp/server.ts +521 -87
  149. package/src/coordinator-mcp/session-reaper.ts +6 -4
  150. package/src/crash/record-loader.ts +6 -2
  151. package/src/daemon/operator-contract.ts +26 -12
  152. package/src/defaults/gjc/skills/ultragoal/SKILL.md +1 -1
  153. package/src/eval/js/context-manager.ts +8 -8
  154. package/src/eval/js/worker-core.ts +9 -4
  155. package/src/eval/js/worker-protocol.ts +2 -0
  156. package/src/exec/bash-executor.ts +3 -0
  157. package/src/extensibility/extensions/runner.ts +52 -4
  158. package/src/extensibility/extensions/types.ts +10 -0
  159. package/src/extensibility/gjc-plugins/registry.ts +196 -37
  160. package/src/extensibility/gjc-plugins/runtime-adapters.ts +46 -8
  161. package/src/extensibility/runtime-skill-discovery.ts +61 -3
  162. package/src/extensibility/shared-events.ts +3 -1
  163. package/src/gjc-runtime/session-state-lock.ts +165 -24
  164. package/src/gjc-runtime/state-writer.ts +317 -6
  165. package/src/gjc-runtime/ultragoal-succession.ts +31 -3
  166. package/src/harness-control-plane/control-endpoint.ts +24 -6
  167. package/src/harness-control-plane/finalize.ts +312 -25
  168. package/src/harness-control-plane/owner.ts +323 -89
  169. package/src/internal-urls/docs-index.generated.ts +23 -20
  170. package/src/internal-urls/embedded-protocol.ts +83 -0
  171. package/src/internal-urls/index.ts +1 -0
  172. package/src/internal-urls/parse.ts +21 -1
  173. package/src/internal-urls/router.ts +4 -2
  174. package/src/main.ts +192 -74
  175. package/src/modes/acp/acp-agent.ts +973 -56
  176. package/src/modes/acp/startup-provenance.ts +59 -0
  177. package/src/modes/components/custom-provider-wizard.ts +308 -7
  178. package/src/modes/components/gjc-bundle-settings.ts +21 -1
  179. package/src/modes/components/oauth-selector.ts +9 -0
  180. package/src/modes/components/session-selector.ts +47 -4
  181. package/src/modes/components/tool-status-header.ts +72 -6
  182. package/src/modes/components/user-message-selector.ts +57 -15
  183. package/src/modes/controllers/command-controller.ts +58 -32
  184. package/src/modes/controllers/extension-ui-controller.ts +33 -7
  185. package/src/modes/controllers/input-controller.ts +4 -0
  186. package/src/modes/controllers/runtime-mcp-command-controller.ts +1 -1
  187. package/src/modes/controllers/selector-controller.ts +161 -15
  188. package/src/modes/interactive-mode.ts +21 -7
  189. package/src/modes/runtime-init.ts +1 -0
  190. package/src/modes/shared/agent-wire/workflow-gate-broker.ts +124 -7
  191. package/src/modes/shared/agent-wire/workflow-gate-types.ts +16 -2
  192. package/src/modes/types.ts +2 -2
  193. package/src/prompts/agent-fragments/browser-aside.md +1 -0
  194. package/src/prompts/system/title-system.md +1 -1
  195. package/src/prompts/tools/bash.md +1 -1
  196. package/src/prompts/tools/job.md +1 -1
  197. package/src/prompts/tools/read.md +2 -0
  198. package/src/runtime/network-prewarm-service.test.ts +36 -1
  199. package/src/runtime/network-prewarm-service.ts +28 -3
  200. package/src/runtime/process-lifecycle.ts +22 -11
  201. package/src/runtime-mcp/config.ts +16 -1
  202. package/src/runtime-mcp/loader.ts +6 -3
  203. package/src/runtime-mcp/manager.ts +845 -109
  204. package/src/runtime-mcp/pool.test.ts +31 -0
  205. package/src/runtime-mcp/pool.ts +304 -28
  206. package/src/runtime-mcp/redaction.ts +42 -0
  207. package/src/runtime-mcp/startup-policy.ts +7 -0
  208. package/src/runtime-mcp/tool-bridge.ts +71 -0
  209. package/src/runtime-mcp/transports/http.ts +108 -25
  210. package/src/sdk/acp/adapter.ts +27 -8
  211. package/src/sdk/broker/broker.ts +1431 -198
  212. package/src/sdk/broker/ensure.ts +21 -3
  213. package/src/sdk/broker/identity.ts +22 -1
  214. package/src/sdk/broker/lifecycle-ledger.ts +95 -31
  215. package/src/sdk/broker/lifecycle.ts +690 -141
  216. package/src/sdk/broker/managed-task-dag.ts +1927 -0
  217. package/src/sdk/broker/managed-task-verification.ts +642 -0
  218. package/src/sdk/broker/runtime.ts +1 -1
  219. package/src/sdk/broker/session-index.ts +97 -4
  220. package/src/sdk/broker/spawn-authority.ts +175 -14
  221. package/src/sdk/broker/startup-failure.ts +80 -1
  222. package/src/sdk/broker/stderr-drainer.ts +59 -0
  223. package/src/sdk/broker/transport.ts +1 -0
  224. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  225. package/src/sdk/bus/chat-daemon-runtime.ts +1 -0
  226. package/src/sdk/bus/index.ts +707 -81
  227. package/src/sdk/bus/telegram-daemon-cli.ts +31 -2
  228. package/src/sdk/bus/telegram-daemon-contract.ts +7 -1
  229. package/src/sdk/bus/telegram-daemon.ts +10 -3
  230. package/src/sdk/cli/master-cli.ts +47 -36
  231. package/src/sdk/cli/rows.ts +30 -7
  232. package/src/sdk/cli/session-cli.ts +705 -184
  233. package/src/sdk/client/client.ts +18 -0
  234. package/src/sdk/guides/catalog.ts +2 -2
  235. package/src/sdk/guides/cli.ts +20 -62
  236. package/src/sdk/guides/verify.ts +14 -0
  237. package/src/sdk/host/host.ts +49 -5
  238. package/src/sdk/host/session-runtime.test.ts +184 -2
  239. package/src/sdk/host/session-runtime.ts +322 -101
  240. package/src/sdk/host/types.ts +12 -1
  241. package/src/sdk/host/websocket-transport.lifecycle.test.ts +84 -0
  242. package/src/sdk/host/websocket-transport.ts +40 -6
  243. package/src/sdk/index.ts +11 -0
  244. package/src/sdk/lifecycle/service.ts +2 -0
  245. package/src/sdk/prompt-deadline-flush.ts +356 -0
  246. package/src/sdk/prompt-deadline-manager.ts +133 -1
  247. package/src/sdk/prompt-tool-boundary.ts +121 -0
  248. package/src/sdk/protocol/operation-inventory.generated.json +106 -0
  249. package/src/sdk/router/session-router.ts +9 -1
  250. package/src/sdk/session.ts +763 -116
  251. package/src/sdk/startup-capability.ts +1 -1
  252. package/src/sdk/transport/relay.ts +71 -6
  253. package/src/sdk/transport/serve-cli.ts +397 -42
  254. package/src/sdk/transport/socket.ts +12 -11
  255. package/src/sdk/transport/stdio.ts +7 -3
  256. package/src/session/agent-session.ts +2472 -407
  257. package/src/session/fallback-chain-controller.ts +6 -7
  258. package/src/session/fold-coordinator.ts +24 -5
  259. package/src/session/internal/managed-session-scope.ts +68 -18
  260. package/src/session/internal/managed-session-storage.ts +334 -12
  261. package/src/session/session-manager.ts +382 -44
  262. package/src/session/session-work-lease.ts +34 -0
  263. package/src/setup/model-onboarding-guidance.ts +1 -1
  264. package/src/setup/provider-onboarding.ts +397 -24
  265. package/src/setup/provider-presets.json +2 -1
  266. package/src/slash-commands/builtin-registry.ts +259 -15
  267. package/src/task/executor.ts +46 -17
  268. package/src/task/index.ts +14 -2
  269. package/src/task/types.ts +2 -0
  270. package/src/tools/bash-interactive.ts +2 -0
  271. package/src/tools/bash.ts +118 -78
  272. package/src/tools/fetch.ts +140 -25
  273. package/src/tools/job.ts +151 -25
  274. package/src/tools/output-meta.ts +15 -2
  275. package/src/tools/path-utils.ts +27 -3
  276. package/src/tools/read.ts +3 -3
  277. package/src/tools/steer-fold.ts +107 -0
  278. package/src/tools/subagent-render.ts +24 -1
  279. package/src/tools/subagent.ts +27 -1
  280. package/src/tools/tool-catalog.generated.ts +29 -2
  281. package/src/tools/tool-errors.ts +4 -0
  282. package/src/utils/git.ts +53 -3
  283. package/src/utils/markit.ts +55 -41
  284. package/src/utils/mupdf-assets.d.ts +4 -0
  285. package/src/utils/mupdf-embedded.ts +4 -0
  286. package/src/utils/mupdf.ts +136 -0
  287. package/src/utils/session-title-generation.ts +29 -0
  288. package/src/utils/title-generator.ts +46 -2
  289. package/src/web/scrapers/types.ts +24 -3
  290. package/vendor/markit-ai/LICENSE +21 -0
  291. package/vendor/markit-ai/MANIFEST.json +412 -0
  292. package/vendor/markit-ai/dist/commands/config.d.ts +4 -0
  293. package/vendor/markit-ai/dist/commands/config.js +139 -0
  294. package/vendor/markit-ai/dist/commands/convert.d.ts +6 -0
  295. package/vendor/markit-ai/dist/commands/convert.js +113 -0
  296. package/vendor/markit-ai/dist/commands/formats.d.ts +2 -0
  297. package/vendor/markit-ai/dist/commands/formats.js +92 -0
  298. package/vendor/markit-ai/dist/commands/init.d.ts +2 -0
  299. package/vendor/markit-ai/dist/commands/init.js +29 -0
  300. package/vendor/markit-ai/dist/commands/onboard.d.ts +2 -0
  301. package/vendor/markit-ai/dist/commands/onboard.js +61 -0
  302. package/vendor/markit-ai/dist/commands/plugin.d.ts +4 -0
  303. package/vendor/markit-ai/dist/commands/plugin.js +58 -0
  304. package/vendor/markit-ai/dist/config.d.ts +26 -0
  305. package/vendor/markit-ai/dist/config.js +42 -0
  306. package/vendor/markit-ai/dist/converters/audio.d.ts +7 -0
  307. package/vendor/markit-ai/dist/converters/audio.js +104 -0
  308. package/vendor/markit-ai/dist/converters/csv.d.ts +7 -0
  309. package/vendor/markit-ai/dist/converters/csv.js +83 -0
  310. package/vendor/markit-ai/dist/converters/docx.d.ts +6 -0
  311. package/vendor/markit-ai/dist/converters/docx.js +57 -0
  312. package/vendor/markit-ai/dist/converters/epub.d.ts +8 -0
  313. package/vendor/markit-ai/dist/converters/epub.js +128 -0
  314. package/vendor/markit-ai/dist/converters/github.d.ts +18 -0
  315. package/vendor/markit-ai/dist/converters/github.js +148 -0
  316. package/vendor/markit-ai/dist/converters/html.d.ts +6 -0
  317. package/vendor/markit-ai/dist/converters/html.js +30 -0
  318. package/vendor/markit-ai/dist/converters/image.d.ts +6 -0
  319. package/vendor/markit-ai/dist/converters/image.js +124 -0
  320. package/vendor/markit-ai/dist/converters/ipynb.d.ts +6 -0
  321. package/vendor/markit-ai/dist/converters/ipynb.js +75 -0
  322. package/vendor/markit-ai/dist/converters/iwork.d.ts +20 -0
  323. package/vendor/markit-ai/dist/converters/iwork.js +391 -0
  324. package/vendor/markit-ai/dist/converters/json.d.ts +6 -0
  325. package/vendor/markit-ai/dist/converters/json.js +21 -0
  326. package/vendor/markit-ai/dist/converters/pdf/columns.d.ts +35 -0
  327. package/vendor/markit-ai/dist/converters/pdf/columns.js +93 -0
  328. package/vendor/markit-ai/dist/converters/pdf/extract.d.ts +19 -0
  329. package/vendor/markit-ai/dist/converters/pdf/extract.js +514 -0
  330. package/vendor/markit-ai/dist/converters/pdf/grid.d.ts +25 -0
  331. package/vendor/markit-ai/dist/converters/pdf/grid.js +795 -0
  332. package/vendor/markit-ai/dist/converters/pdf/headers.d.ts +24 -0
  333. package/vendor/markit-ai/dist/converters/pdf/headers.js +108 -0
  334. package/vendor/markit-ai/dist/converters/pdf/index.d.ts +19 -0
  335. package/vendor/markit-ai/dist/converters/pdf/index.js +136 -0
  336. package/vendor/markit-ai/dist/converters/pdf/mupdf-loader.js +9 -0
  337. package/vendor/markit-ai/dist/converters/pdf/render.d.ts +24 -0
  338. package/vendor/markit-ai/dist/converters/pdf/render.js +513 -0
  339. package/vendor/markit-ai/dist/converters/pdf/types.d.ts +75 -0
  340. package/vendor/markit-ai/dist/converters/pdf/types.js +1 -0
  341. package/vendor/markit-ai/dist/converters/plain-text.d.ts +6 -0
  342. package/vendor/markit-ai/dist/converters/plain-text.js +87 -0
  343. package/vendor/markit-ai/dist/converters/pptx.d.ts +8 -0
  344. package/vendor/markit-ai/dist/converters/pptx.js +289 -0
  345. package/vendor/markit-ai/dist/converters/rss.d.ts +11 -0
  346. package/vendor/markit-ai/dist/converters/rss.js +138 -0
  347. package/vendor/markit-ai/dist/converters/wikipedia.d.ts +6 -0
  348. package/vendor/markit-ai/dist/converters/wikipedia.js +33 -0
  349. package/vendor/markit-ai/dist/converters/xlsx.d.ts +8 -0
  350. package/vendor/markit-ai/dist/converters/xlsx.js +147 -0
  351. package/vendor/markit-ai/dist/converters/xml.d.ts +6 -0
  352. package/vendor/markit-ai/dist/converters/xml.js +18 -0
  353. package/vendor/markit-ai/dist/converters/yaml.d.ts +6 -0
  354. package/vendor/markit-ai/dist/converters/yaml.js +17 -0
  355. package/vendor/markit-ai/dist/converters/zip.d.ts +8 -0
  356. package/vendor/markit-ai/dist/converters/zip.js +57 -0
  357. package/vendor/markit-ai/dist/index.d.ts +30 -0
  358. package/vendor/markit-ai/dist/index.js +26 -0
  359. package/vendor/markit-ai/dist/main.d.ts +2 -0
  360. package/vendor/markit-ai/dist/main.js +191 -0
  361. package/vendor/markit-ai/dist/markit.d.ts +45 -0
  362. package/vendor/markit-ai/dist/markit.js +267 -0
  363. package/vendor/markit-ai/dist/plugins/api.d.ts +7 -0
  364. package/vendor/markit-ai/dist/plugins/api.js +42 -0
  365. package/vendor/markit-ai/dist/plugins/index.d.ts +4 -0
  366. package/vendor/markit-ai/dist/plugins/index.js +3 -0
  367. package/vendor/markit-ai/dist/plugins/installer.d.ts +25 -0
  368. package/vendor/markit-ai/dist/plugins/installer.js +176 -0
  369. package/vendor/markit-ai/dist/plugins/loader.d.ts +6 -0
  370. package/vendor/markit-ai/dist/plugins/loader.js +61 -0
  371. package/vendor/markit-ai/dist/plugins/types.d.ts +25 -0
  372. package/vendor/markit-ai/dist/plugins/types.js +1 -0
  373. package/vendor/markit-ai/dist/providers/anthropic.d.ts +2 -0
  374. package/vendor/markit-ai/dist/providers/anthropic.js +47 -0
  375. package/vendor/markit-ai/dist/providers/index.d.ts +21 -0
  376. package/vendor/markit-ai/dist/providers/index.js +56 -0
  377. package/vendor/markit-ai/dist/providers/openai.d.ts +2 -0
  378. package/vendor/markit-ai/dist/providers/openai.js +76 -0
  379. package/vendor/markit-ai/dist/providers/types.d.ts +26 -0
  380. package/vendor/markit-ai/dist/providers/types.js +1 -0
  381. package/vendor/markit-ai/dist/types.d.ts +36 -0
  382. package/vendor/markit-ai/dist/types.js +1 -0
  383. package/vendor/markit-ai/dist/utils/exit-codes.d.ts +4 -0
  384. package/vendor/markit-ai/dist/utils/exit-codes.js +4 -0
  385. package/vendor/markit-ai/dist/utils/output.d.ts +22 -0
  386. package/vendor/markit-ai/dist/utils/output.js +31 -0
  387. package/vendor/markit-ai/dist/utils/turndown.d.ts +8 -0
  388. package/vendor/markit-ai/dist/utils/turndown.js +70 -0
  389. package/vendor/markit-ai/package.json +74 -0
  390. package/vendor/markit-ai.patch +49 -0
@@ -2,6 +2,25 @@ import type { KindAwareReconciliation } from "./bus/kind-aware-reconciliation";
2
2
  import type { InvocationCorrelation, InvocationReconciliation } from "./host/session-runtime";
3
3
  import type { SdkPromptTerminalOutcome } from "./prompt-status";
4
4
  import type { TurnResultContent } from "./turn-result";
5
+ /**
6
+ * Hard real-time bound on the best-effort durability hook, shared with
7
+ * `prompt-deadline-flush` so the manager's race and the flush's own abort
8
+ * signal cannot drift apart.
9
+ */
10
+ export declare const DEADLINE_FLUSH_TIMEOUT_MS = 10000;
11
+ /**
12
+ * Run a best-effort durability flush under a hard real-time bound that ALWAYS
13
+ * settles, and never let its result reach the caller.
14
+ *
15
+ * Shared by both expiry paths — this manager and the notification bus's own
16
+ * terminalization (#5583) — so there is one bound, one abort, and one warning,
17
+ * with no drift between them. A rejection is swallowed; a `run` that never
18
+ * settles is abandoned after `timeoutMs` with its signal aborted so any git
19
+ * subprocess dies. The signal alone is not sufficient: `git.withRepoLock`
20
+ * awaits its predecessor before honouring it, so a hung predecessor in the
21
+ * per-repo write chain is cut only by this outer race.
22
+ */
23
+ export declare function runBoundedDeadlineFlush(run: (signal: AbortSignal) => unknown, timeoutMs?: number): Promise<void>;
5
24
  type DeadlineReconciliation = InvocationReconciliation | KindAwareReconciliation;
6
25
  export type PromptDeadlineOutcome = Extract<SdkPromptTerminalOutcome, {
7
26
  kind: "failed";
@@ -22,6 +41,24 @@ export declare class PromptDeadlineManager {
22
41
  getMaxMs: () => number;
23
42
  now?: () => number;
24
43
  onExpired?: (correlation: InvocationCorrelation, outcome?: PromptDeadlineOutcome) => void;
44
+ /**
45
+ * Best-effort durability hook for the single path that genuinely retires a
46
+ * prompt as `prompt_deadline_exceeded` (#5583). Awaited after the durable
47
+ * pending claim but BEFORE the durable terminal, so a crash in that window
48
+ * leaves the record pending and recovery retries the prompt; a
49
+ * rejection is swallowed and never changes the deadline outcome. Not called
50
+ * when a real terminal transition or a real failure won the race, nor when
51
+ * renewed progress supersedes this expiry instance. The hook receives an
52
+ * abort signal that fires when it outruns `deadlineFlushTimeoutMs`, plus a
53
+ * generation fence for irreversible worktree adoption.
54
+ */
55
+ onDeadlineExceeded?: (correlation: InvocationCorrelation, signal: AbortSignal, isCurrent?: () => boolean) => void | Promise<void>;
56
+ /**
57
+ * Hard bound on `onDeadlineExceeded`. Measured with a real timer, not
58
+ * `now`, because it guards real subprocesses — which is also why it is a
59
+ * constructor option: a fake clock cannot shorten it for tests.
60
+ */
61
+ deadlineFlushTimeoutMs?: number;
25
62
  });
26
63
  onAccepted(correlation: InvocationCorrelation): void;
27
64
  /** Re-arm a durable uncertainty-recovery record after process startup without
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Bounded wait for an in-flight dispatched tool call to reach its boundary
3
+ * before an expired prompt deadline force-terminates the run (#5637).
4
+ *
5
+ * Terminal fencing aborts the run's cancellation domain FIRST and only proves
6
+ * settlement afterwards (`RunResourceLedger.waitForSettlement` resolves once the
7
+ * run is sealed and its tracked `kind: "tool"` resources have settled), so a
8
+ * tool that was mid-write when the deadline expired observes the aborted signal
9
+ * DURING its write and leaves a torn artifact behind. Waiting for that call's
10
+ * own `tool_execution_end` — under a short, finite grace — turns the kill into a
11
+ * boundary abort. When the grace is exhausted the run is force-terminated
12
+ * exactly as before, and the fact that a tool was still executing is returned as
13
+ * structured evidence rather than dropped.
14
+ *
15
+ * Deliberately dependency-light and clock-injectable: the contended bus module
16
+ * takes only a call, and the behaviour is testable without a live transport.
17
+ */
18
+ /**
19
+ * Hard bound on how long deadline expiry will wait for an in-flight tool call to
20
+ * reach its boundary before force-terminating. This guards a real subprocess, so
21
+ * it is a real timer rather than the lease clock — and a parameter rather than a
22
+ * bare module constant, so a test may shorten it explicitly instead of a fake
23
+ * clock silently shortening it for production code too.
24
+ */
25
+ export declare const TOOL_CALL_BOUNDARY_GRACE_MS = 5000;
26
+ /**
27
+ * Re-check interval for the pending set while the grace runs.
28
+ *
29
+ * The authoritative source of "is a tool running?" is the run resource ledger,
30
+ * a SYNCHRONOUS snapshot with no completion signal of its own, so the wait has
31
+ * to look again rather than being told. `whenIdle` only wakes the check early
32
+ * when the event-derived view happens to drain first. Bounded by the grace, so
33
+ * this costs at most `graceMs / pollMs` array reads on the rare expiry-with-a-
34
+ * tool-running path and nothing at all on the idle path.
35
+ */
36
+ export declare const TOOL_CALL_BOUNDARY_POLL_MS = 25;
37
+ export type ToolBoundaryOutcome = "idle" | "settled" | "forced";
38
+ export interface ToolBoundaryWaitResult {
39
+ outcome: ToolBoundaryOutcome;
40
+ waitedMs: number;
41
+ /**
42
+ * Non-empty ONLY for "forced": the dispatched tool calls still running when
43
+ * the grace expired. Ids only — never tool arguments, output or paths.
44
+ */
45
+ pendingToolCallIds: string[];
46
+ }
47
+ /**
48
+ * Shared result for the common case of no dispatched tool running at expiry.
49
+ * Frozen because it is handed to every idle caller: the deadline path must stay
50
+ * byte-identical to its pre-#5637 behaviour, which includes allocating nothing
51
+ * and arming no timer.
52
+ */
53
+ export declare const IDLE_TOOL_BOUNDARY_RESULT: ToolBoundaryWaitResult;
54
+ /**
55
+ * Wait for the pending dispatched tool calls to drain, bounded by `graceMs`.
56
+ *
57
+ * Never composed with an abort signal: at the only call site nothing has been
58
+ * aborted yet, and a signal that was already aborted would make this wait
59
+ * unreachable — which is precisely the mid-tool kill being fixed.
60
+ */
61
+ export declare function waitForToolCallBoundary(input: {
62
+ pending: () => readonly string[];
63
+ /**
64
+ * Resolves when the event-derived view of the pending set drains. A wake-up
65
+ * HINT only: `pending()` is re-read before the wait is allowed to settle,
66
+ * because the authoritative source may still hold a call this signal knows
67
+ * nothing about. Expected never to reject.
68
+ */
69
+ whenIdle: () => Promise<void>;
70
+ graceMs?: number;
71
+ pollMs?: number;
72
+ now?: () => number;
73
+ }): Promise<ToolBoundaryWaitResult>;
@@ -177,6 +177,8 @@ export interface SessionRouterOptions {
177
177
  agentDir: string;
178
178
  /** Limits attachment to exact ids selected by a Broker-scoped operation. */
179
179
  sessionIds?: readonly string[];
180
+ /** Marks default SDK clients as notification-only observers; demanding by default. */
181
+ observer?: boolean;
180
182
  deps?: SessionRouterDeps;
181
183
  /** Runtime-specific identity validation; Router supplies a conservative fallback. */
182
184
  correlateFrame?: SessionRouterFrameCorrelator;
@@ -233,9 +233,9 @@ export interface CreateAgentSessionOptions {
233
233
  inheritedAsyncJobManager?: AsyncJobManager;
234
234
  /**
235
235
  * W6b: the parent's scope-held MCP facade, handed to a canonical sub-session so
236
- * it can inherit always-on MCP tools without owning the manager. Replaces the
237
- * removed `MCPManager.instance()` inheritance path; the sub-session never
238
- * connects, registers callbacks, or disposes this manager.
236
+ * it can inherit MCP tools without owning the manager. Replaces the removed
237
+ * `MCPManager.instance()` inheritance path; the sub-session subscribes to catalog
238
+ * changes but never connects or disposes this manager.
239
239
  */
240
240
  inheritedMcpManager?: import("../runtime-mcp/manager").MCPManager;
241
241
  /** Session manager. Default: session stored under the configured agentDir sessions root */
@@ -44,6 +44,8 @@ export declare class SdkStartupRollbackTracker {
44
44
  export declare function sanitizeSdkStartupMessage(value: unknown, knownSecrets?: Iterable<unknown>): string;
45
45
  /** Convert every lifecycle bootstrap outcome to the public, bounded failure shape. */
46
46
  export declare function normalizeSdkStartupFailure(phase: SdkStartupPhase, reason: SdkStartupReason, error?: unknown, knownSecrets?: Iterable<unknown>): SdkStartupFailure;
47
+ /** Collect process-scoped credentials without exposing a raw-secret API. */
48
+ export declare function lifecycleKnownSecrets(): string[];
47
49
  /** Session-owned, exactly-once lifecycle bootstrap completion. */
48
50
  export declare class SdkStartupCapability {
49
51
  #private;
@@ -2,6 +2,7 @@ import type { Readable, Writable } from "node:stream";
2
2
  export declare const REQUEST_FRAME_BYTES: number;
3
3
  export declare const DEFAULT_PENDING_CEILING_BYTES: number;
4
4
  export declare const MIN_PENDING_CEILING_BYTES: number;
5
+ export declare const DEFAULT_UPSTREAM_HELLO_TIMEOUT_MS = 10000;
5
6
  export type RelayDirection = "downstream->ws" | "ws->downstream";
6
7
  export type TransportError = {
7
8
  type: "transport_error";
@@ -1,10 +1,13 @@
1
+ import { PublicCommandFailure } from "../../cli/public-command-errors";
1
2
  import { SdkClient } from "../client";
3
+ import type { ServeHandle } from "./index";
4
+ import { startSocketServe, startStdioServe } from "./index";
2
5
  /**
3
6
  * A `gjc sdk serve` operational failure with a stable machine-readable code and a
4
7
  * documented exit code, mirroring `SdkSessionCliError`. Usage errors keep their own
5
- * `CliParseError` path; this type covers only failures an embedder must branch on.
8
+ * public failure envelope; this type covers only failures an embedder must branch on.
6
9
  */
7
- export declare class SdkServeError extends Error {
10
+ export declare class SdkServeError extends PublicCommandFailure {
8
11
  readonly code: string;
9
12
  readonly exitCode: 1;
10
13
  readonly details?: unknown;
@@ -28,20 +31,61 @@ export declare class SdkServeError extends Error {
28
31
  export declare function resolveServeOutcome(primary: Error | undefined, cleanup: Error | undefined): Error | undefined;
29
32
  /** Resolves the pending ceiling with flag > env > default precedence; exported for tests. */
30
33
  export declare function resolveServePendingCeiling(flagValue: string | undefined, envValue: string | undefined): number;
34
+ type BrokerTranscriptIdentity = {
35
+ dev: string;
36
+ ino: string;
37
+ size: number;
38
+ mtimeMs: number;
39
+ mtimeNs: string;
40
+ sha256: string;
41
+ };
42
+ type BrokerSavedSession = {
43
+ id: string;
44
+ path: string;
45
+ identity: BrokerTranscriptIdentity;
46
+ };
47
+ type BrokerSessionLocator = {
48
+ cwd: string;
49
+ worktreeRoot: string | null;
50
+ stateRoot: string;
51
+ };
31
52
  type BrokerSessionRow = {
32
53
  sessionId: string;
33
54
  live: boolean;
34
55
  ambiguous: boolean;
56
+ terminal?: boolean;
57
+ hostUnregisteredReason?: "process_exited" | "detached_idle";
58
+ terminalUncertain?: boolean;
59
+ locator?: BrokerSessionLocator;
60
+ savedSession?: BrokerSavedSession;
35
61
  };
36
62
  /** Exhausts strict broker `session.list` pages into one full session snapshot. */
37
- export declare function listBrokerSessions(broker: SdkClient, explicitSessionId?: string): Promise<BrokerSessionRow[]>;
63
+ export declare function listBrokerSessions(broker: Pick<SdkClient, "global">, explicitSessionId?: string, cwd?: string): Promise<BrokerSessionRow[]>;
64
+ /** Resolves an explicit or automatic serve target, reattaching one stale explicit session at most once. */
65
+ export declare function resolveServeSession(broker: SdkClient, explicitSessionId?: string): Promise<string>;
38
66
  /** Selects the session to serve through broker `session.list` truth (C10); exported for tests. */
39
67
  export declare function selectBrokerSession(sessions: BrokerSessionRow[], explicitSessionId: string | undefined): string;
68
+ /** Bounded dependency seam for preflight tests; production keeps the same transport factories. */
69
+ export interface SdkServeDependencies {
70
+ readDiscovery: (agentDir: string) => Promise<{
71
+ url: string;
72
+ token: string;
73
+ } | null>;
74
+ connect: (url: string, token: string) => Promise<Pick<SdkClient, "global" | "close">>;
75
+ startStdio: typeof startStdioServe;
76
+ startSocket: typeof startSocketServe;
77
+ }
40
78
  /**
41
79
  * Attaches a stdio or Unix-socket relay to one live SDK session endpoint.
42
80
  * Session targeting is broker-bound (C10): `session.list` resolves the session
43
81
  * and `session.get_endpoint` mints the exact credential — never a direct
44
82
  * endpoint-file read. A missing or unreachable broker fails closed.
45
83
  */
46
- export declare function runSdkServe(argv: string[]): Promise<void>;
84
+ export declare function runSdkServe(argv: string[], dependencies?: SdkServeDependencies): Promise<void>;
85
+ /**
86
+ * Acquiring a ServeHandle transfers output/termination ownership to transport.
87
+ * This boundary never rejects into the ordinary public command writer, even
88
+ * when no frame has been written. Raw relay framing remains transport-owned.
89
+ */
90
+ export declare function ownSdkServeTransport(handle: ServeHandle, closeBroker: () => Promise<void>): Promise<void>;
47
91
  export {};
@@ -1,3 +1,7 @@
1
+ import type { Readable, Writable } from "node:stream";
1
2
  import type { ServeHandle, ServeOptions } from "./index";
2
3
  /** Serves one parent-owned JSONL connection over the process standard streams. */
3
- export declare function startStdioServe(options: ServeOptions): Promise<ServeHandle>;
4
+ export declare function startStdioServe(options: ServeOptions, streams?: {
5
+ readonly input?: Readable;
6
+ readonly output?: Writable;
7
+ }): Promise<ServeHandle>;
@@ -17,6 +17,7 @@ import type { AttemptScope } from "@gajae-code/agent-core/attempt-scope";
17
17
  import { type CompactionResult, type EmergencyCompactionSample } from "@gajae-code/agent-core/compaction";
18
18
  import type { AssistantMessage, AttemptScopeRef, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolCall, ToolChoice, Usage, UsageReport } from "@gajae-code/ai/core";
19
19
  import { type BtwTextExchange } from "./btw-contract";
20
+ import { type SessionWorkLease } from "./session-work-lease";
20
21
  export interface ForkContextSeedMetadata {
21
22
  sourceSessionId: string;
22
23
  parentMessageCount: number;
@@ -96,7 +97,7 @@ import { type AgentRegistry } from "../registry/agent-registry";
96
97
  import type { LazyService } from "../runtime/lazy-service";
97
98
  import type { NetworkPrewarmRuntime } from "../runtime/network-prewarm-service";
98
99
  import type { WorkspaceTreeRuntime } from "../runtime/workspace-tree-service";
99
- import { MCPManager } from "../runtime-mcp/manager";
100
+ import { type ExactMcpServerControlResult, MCPManager } from "../runtime-mcp/manager";
100
101
  import type { NotificationSessionController } from "../sdk/bus/session-control";
101
102
  import type { SecretObfuscator } from "../secrets/obfuscator";
102
103
  import { type DiscoverableTool, type DiscoverableToolSearchIndex } from "../tool-discovery/tool-index";
@@ -196,6 +197,47 @@ export type AgentSessionEvent = AgentEvent | {
196
197
  goal: Goal | null;
197
198
  state?: GoalModeState;
198
199
  };
200
+ export type QueuedInputDelivery = "steer" | "followUp";
201
+ export type QueuedInputQueuePolicy = "respect-mode" | "sequential";
202
+ export type QueuedInputRemovalReason = "cancelled" | "removed";
203
+ export interface QueuedInputAdmission {
204
+ submissionId: string;
205
+ delivery: QueuedInputDelivery;
206
+ queuePolicy: QueuedInputQueuePolicy;
207
+ }
208
+ export type QueuedInputExecution = {
209
+ submissionId: string;
210
+ delivery: QueuedInputDelivery;
211
+ disposition: "joined-current-run" | "promoted-to-run";
212
+ attemptScope: AttemptScopeRef;
213
+ } | {
214
+ submissionId: string;
215
+ delivery: QueuedInputDelivery;
216
+ disposition: "removed";
217
+ reason: QueuedInputRemovalReason;
218
+ };
219
+ export type QueuedInputTerminal = {
220
+ submissionId: string;
221
+ delivery: QueuedInputDelivery;
222
+ disposition: "completed";
223
+ attemptScope: AttemptScopeRef;
224
+ } | {
225
+ submissionId: string;
226
+ delivery: QueuedInputDelivery;
227
+ disposition: "removed";
228
+ reason: QueuedInputRemovalReason;
229
+ };
230
+ /**
231
+ * Lifecycle receipt for one explicitly queued `submitUserMessage` submission.
232
+ */
233
+ export interface QueuedInputSubmission {
234
+ readonly submissionId: string;
235
+ readonly admitted: Promise<QueuedInputAdmission>;
236
+ readonly execution: Promise<QueuedInputExecution>;
237
+ readonly terminal: Promise<QueuedInputTerminal>;
238
+ /** Remove the submission if it is still queued. Returns false after execution or removal. */
239
+ readonly cancel: () => boolean;
240
+ }
199
241
  /** Listener function for agent session events */
200
242
  export type AgentSessionEventListener = (event: AgentSessionEvent) => void;
201
243
  export type AsyncJobSnapshotItem = Pick<AsyncJob, "id" | "type" | "status" | "label" | "startTime" | "endTime" | "metadata">;
@@ -439,6 +481,30 @@ export interface PromptOptions {
439
481
  /** Internal host capability; ordinary package callers cannot construct the branded value. */
440
482
  sdkRunCapability?: unknown;
441
483
  }
484
+ export interface SendUserMessageOptions {
485
+ deliverAs?: QueuedInputDelivery;
486
+ /** Preserve a busy SDK dispatch as queued work across an admission fence. */
487
+ queuedAtDispatch?: boolean;
488
+ /** Delivery ordering for a tracked or SDK-queued submission. */
489
+ queuePolicy?: QueuedInputQueuePolicy;
490
+ onPreflightAccepted?: () => void;
491
+ onPreflightAcceptCommit?: () => void | Promise<void>;
492
+ /** Internal SDK ownership callback. */
493
+ onQueuedPromoted?: (promotion: {
494
+ startsOwnRun?: boolean;
495
+ removed?: boolean;
496
+ }) => void;
497
+ /** Internal dispatch disposition used before actual queue consumption. */
498
+ onDispatchDisposition?: (promotion: {
499
+ startsOwnRun: boolean;
500
+ }) => void;
501
+ preflightSignal?: AbortSignal;
502
+ sdkRunCapability?: unknown;
503
+ }
504
+ export interface TrackedSendUserMessageOptions extends SendUserMessageOptions {
505
+ deliverAs: QueuedInputDelivery;
506
+ trackSubmission: true;
507
+ }
442
508
  /** Result from a handoff operation. */
443
509
  export interface HandoffResult {
444
510
  document: string;
@@ -614,11 +680,58 @@ export declare class StreamingEditFileCache {
614
680
  has(path: string): boolean;
615
681
  get totalBytes(): number;
616
682
  }
683
+ /**
684
+ * Startup phase of the session-owned exact-config MCP manager.
685
+ *
686
+ * `not-started` and `no-servers-declared` are distinguishable only because the
687
+ * snapshot reads the declared server list from the exact config; the manager
688
+ * alone reports an empty name list in both cases.
689
+ */
690
+ export type ExactMcpStartupState = "not-started" | "no-servers-declared" | "in-flight" | "settled";
691
+ /**
692
+ * Per-server state.
693
+ *
694
+ * `unavailable` covers a server the config declares that the manager has no
695
+ * live record of. A tools-only manager erases a server from its own bookkeeping
696
+ * when the connection fails, so a failed server and one whose startup has not
697
+ * reached it are indistinguishable from here; both surface as `unavailable`
698
+ * rather than being dropped from the table.
699
+ */
700
+ export type ExactMcpServerState = "connecting" | "connected" | "disconnected" | "unavailable";
701
+ export type ExactMcpServerDisplayState = ExactMcpServerState | "suspended";
702
+ /**
703
+ * Transport a server is declared with. Taken from the config's own
704
+ * discriminator, never from a live connection: `getConnection` throws on a
705
+ * tools-only manager, so the declaration is the only source available here.
706
+ */
707
+ export type ExactMcpTransport = "stdio" | "http" | "sse" | "unknown";
708
+ export interface ExactMcpServerStatus {
709
+ readonly name: string;
710
+ readonly transport: ExactMcpTransport;
711
+ readonly state: ExactMcpServerDisplayState;
712
+ readonly toolCount: number;
713
+ }
714
+ /**
715
+ * Whitelisted status shape for the TUI `/mcp` command. Every field here is
716
+ * either a server name the operator already supplied or a derived enum/count;
717
+ * pool keys, endpoints, commands, env, headers, tokens, and raw exception text
718
+ * have no field to travel in.
719
+ */
720
+ export interface ExactMcpStatusSnapshot {
721
+ readonly startup: ExactMcpStartupState;
722
+ readonly servers: readonly ExactMcpServerStatus[];
723
+ }
724
+ export type ExactMcpControlAction = "suspend" | "resume" | "reconnect";
725
+ export interface ExactMcpControlResult extends ExactMcpServerControlResult {
726
+ readonly action: ExactMcpControlAction;
727
+ }
617
728
  export interface DefaultFallbackRuntimeState {
618
729
  chain: ConfiguredFallbackChain;
619
730
  controller: FallbackChainRuntimeState;
620
731
  exhaustedLastTurn: boolean;
621
732
  }
733
+ /** A lost continuation may only settle the emitter/session pair that opened it. */
734
+ export declare function isCurrentWorkflowGateContinuation(currentSessionId: string, expectedSessionId: string, currentEmitter: WorkflowGateEmitter | undefined, expectedEmitter: WorkflowGateEmitter): boolean;
622
735
  export declare class AgentSession {
623
736
  #private;
624
737
  readonly agent: Agent;
@@ -679,8 +792,11 @@ export declare class AgentSession {
679
792
  } | undefined;
680
793
  /** Replace the session-owned MCP manager after a cwd rescope. */
681
794
  replaceOwnedMcpManager(next: MCPManager | undefined): Promise<void>;
682
- /** Swap named custom/project tools after a cwd rescope. */
683
- replaceNamedCustomTools(previousNames: readonly string[], nextTools: CustomTool[]): Promise<void>;
795
+ /** Swap named custom tools and their optional mandatory MCP selection. */
796
+ replaceNamedCustomTools(previousNames: readonly string[], nextTools: readonly CustomTool[], options?: {
797
+ mandatoryMCPToolNames?: readonly string[];
798
+ activateNewTools?: boolean;
799
+ }): Promise<void>;
684
800
  /** Best-effort accessor for the active skill's `current_phase` field from
685
801
  * its persisted mode-state file. Used by the `skill` tool to enforce the
686
802
  * terminal-phase chain guard. Returns undefined when no active skill is
@@ -760,7 +876,9 @@ export declare class AgentSession {
760
876
  * Remove all listeners, flush pending writes, and disconnect from agent.
761
877
  * Call this when completely done with the session.
762
878
  */
763
- dispose(): Promise<void>;
879
+ dispose(options?: {
880
+ sessionShutdownReason?: "detached_idle";
881
+ }): Promise<void>;
764
882
  /** Join the retained teardown owner without allocating another public deadline. */
765
883
  awaitDisposeCompletion(): Promise<void>;
766
884
  setDisposeTimeoutForTests(timeoutMs: number): void;
@@ -919,6 +1037,21 @@ export declare class AgentSession {
919
1037
  * Get all configured tool names (built-in via --tools or default, plus custom tools).
920
1038
  */
921
1039
  getAllToolNames(): string[];
1040
+ get hasExactMcpControls(): boolean;
1041
+ /**
1042
+ * Exact-config MCP status for the TUI `/mcp` command.
1043
+ *
1044
+ * Returns `undefined` unless this session holds the exact-config capability,
1045
+ * so a session built outside the root interactive entry point cannot read MCP
1046
+ * state through it. Data comes only from the session-owned tools-only manager
1047
+ * and the call never starts a deferred MCP startup or mutates connections.
1048
+ */
1049
+ getExactMcpStatusSnapshot(): Promise<ExactMcpStatusSnapshot | undefined>;
1050
+ /**
1051
+ * Apply one session-local exact-config control. Selection persistence is
1052
+ * deliberately bypassed: suppression is runtime state, not user authority.
1053
+ */
1054
+ controlExactMcpServer(action: ExactMcpControlAction, name: string): Promise<ExactMcpControlResult | undefined>;
922
1055
  getSelectedMCPToolNames(): string[];
923
1056
  isToolDiscoveryEnabled(): boolean;
924
1057
  getDiscoverableTools(filter?: {
@@ -947,7 +1080,12 @@ export declare class AgentSession {
947
1080
  * Replace MCP tools in the registry and recompute the visible MCP tool set immediately.
948
1081
  * This allows /mcp add/remove/reauth to take effect without restarting the session.
949
1082
  */
950
- refreshMCPTools(mcpTools: CustomTool[]): Promise<void>;
1083
+ refreshMCPTools(mcpTools: CustomTool[], options?: {
1084
+ selectedMCPToolNames?: string[];
1085
+ activeMCPToolNames?: string[];
1086
+ mandatoryMCPToolNames?: string[];
1087
+ persistMCPSelection?: boolean;
1088
+ }): Promise<void>;
951
1089
  /**
952
1090
  * Refresh plugin sub-skill tools after workflow/sub-skill activation or phase changes.
953
1091
  */
@@ -963,6 +1101,8 @@ export declare class AgentSession {
963
1101
  * to avoid racing against the delivery turn.
964
1102
  */
965
1103
  get hasPostPromptWork(): boolean;
1104
+ /** The host-liveness lease shared by admission, execution, and recovery work. */
1105
+ get sessionWorkLease(): SessionWorkLease;
966
1106
  /** Stable resource ownership identifier for the active prompt run. */
967
1107
  get activePromptHandle(): string | undefined;
968
1108
  /** All messages including custom types like BashExecutionMessage */
@@ -1107,24 +1247,14 @@ export declare class AgentSession {
1107
1247
  * @param content User message content (string or content array)
1108
1248
  * @param options.deliverAs Delivery mode: "steer" or "followUp"
1109
1249
  */
1110
- sendUserMessage(content: string | (TextContent | ImageContent)[], options?: {
1111
- deliverAs?: "steer" | "followUp";
1112
- /** Preserve a busy SDK dispatch as queued work across an admission fence. */
1113
- queuedAtDispatch?: boolean;
1114
- onPreflightAccepted?: () => void;
1115
- onPreflightAcceptCommit?: () => void | Promise<void>;
1116
- /** Fired when a queued submission (steering or follow-up) is promoted to its own run (SDK ownership correlation). */
1117
- onQueuedPromoted?: (promotion: {
1118
- startsOwnRun?: boolean;
1119
- removed?: boolean;
1120
- }) => void;
1121
- /** Internal dispatch disposition used before actual queue consumption. */
1122
- onDispatchDisposition?: (promotion: {
1123
- startsOwnRun: boolean;
1124
- }) => void;
1125
- preflightSignal?: AbortSignal;
1126
- sdkRunCapability?: unknown;
1127
- }): Promise<void>;
1250
+ sendUserMessage(content: string | (TextContent | ImageContent)[], options?: SendUserMessageOptions): Promise<void>;
1251
+ /**
1252
+ * Queue one steer or follow-up and return a stable lifecycle handle for that
1253
+ * exact submission. Unlike `sendUserMessage`, this method resolves when the
1254
+ * queue admission receipt is available; use the returned promises to await
1255
+ * execution and the owning terminal boundary.
1256
+ */
1257
+ submitUserMessage(content: string | (TextContent | ImageContent)[], options: TrackedSendUserMessageOptions): Promise<QueuedInputSubmission>;
1128
1258
  /**
1129
1259
  * Clear queued messages and return them.
1130
1260
  * Useful for restoring to editor when user aborts.
@@ -1257,6 +1387,18 @@ export declare class AgentSession {
1257
1387
  rebindTerminalAbortSteeringSnapshot(token: number): void;
1258
1388
  discardTerminalAbortSteeringSnapshot(token: number): void;
1259
1389
  getTerminalTurnEpoch(): number | undefined;
1390
+ /**
1391
+ * Tool call ids the run resource ledger currently holds for `handle` (#5637).
1392
+ *
1393
+ * The authoritative answer to "is a tool running?": AgentLoop reserves the
1394
+ * `kind: "tool"` lease SYNCHRONOUSLY inside its dispatch loop, before the
1395
+ * tool's `execute` is invoked, and the lease settles when the call really
1396
+ * ends — whereas `tool_execution_start` only reaches an extension after an
1397
+ * asynchronous fanout. Strictly read-only: it takes a snapshot and never
1398
+ * claims, reserves, seals or quarantines. An unknown run reads as empty,
1399
+ * matching `RunResourceLedger.pending`.
1400
+ */
1401
+ pendingToolExecutions(handle: string): readonly string[];
1260
1402
  abortPromptAndWait(handle: string, options: {
1261
1403
  graceMs: number;
1262
1404
  terminal?: {
@@ -1386,6 +1528,15 @@ export declare class AgentSession {
1386
1528
  * must not mutate the persisted configured intent.
1387
1529
  */
1388
1530
  setDefaultFallbackRuntimeModel(selector: string): void;
1531
+ /** Install a runtime-only durable fallback without changing saved session intent. */
1532
+ installRecoveredDefaultFallbackChain(entries: readonly string[], identity: string | undefined, activeIndex: number, skips: Array<{
1533
+ selector: string;
1534
+ reason: string;
1535
+ }>, options?: {
1536
+ emitResolutionEvent?: boolean;
1537
+ }): void;
1538
+ markStartupRecoveryBindingsRequired(): void;
1539
+ hasRecoveredDefaultFallbackChain(): boolean;
1389
1540
  /**
1390
1541
  * Seed default fallback state after guarded auth-aware model resolution skips chain entries.
1391
1542
  * The configured chain's role, origin, and identity are retained by the controller.
@@ -1436,6 +1587,7 @@ export declare class AgentSession {
1436
1587
  reason?: TemporaryModelReason;
1437
1588
  providerSessionScope?: TemporaryProviderSessionScope;
1438
1589
  signal?: AbortSignal;
1590
+ onMutationStarted?: () => void;
1439
1591
  }): Promise<TemporaryProviderSessionScope | void>;
1440
1592
  /** Restore the exact live-model state captured before a failed selector transaction. */
1441
1593
  restoreModelSelectionForRollback(model: Model | undefined, thinkingLevel: ThinkingLevel | undefined): Promise<void>;
@@ -97,15 +97,15 @@ export interface CompactionCandidateFailure {
97
97
  readonly model: string;
98
98
  readonly message: string;
99
99
  }
100
+ export declare function sanitizeCompactionCandidateFailureMessage(message: string): string;
100
101
  /**
101
102
  * Error for an auto-compaction run whose every candidate failed.
102
103
  *
103
- * The candidate chain starts at the session model and ends on a same-provider
104
- * largest-context fallback, so surfacing only the final error named a model
105
- * the user never chose and hid that their own model had already failed the
106
- * same way. The message leads with the first failure (the one the user can act
107
- * on), then lists every candidate that was tried with its own error. `cause`
108
- * is the final error so callers that classify by type keep the same object.
104
+ * The candidate chain starts at the session model and includes only explicitly
105
+ * configured role candidates. The message leads with the first failure (the
106
+ * one the user can act on), then lists every candidate that was tried with its
107
+ * own error. `cause` is the final error so callers that classify by type keep
108
+ * the same object.
109
109
  */
110
110
  export declare function describeCompactionCandidateFailures(failures: readonly CompactionCandidateFailure[], lastError: unknown): Error;
111
111
  export declare function effectiveFallbackDelay(baseDelayMs: number, maxDelayMs: number, attemptK: number, random?: () => number): number;
@@ -35,7 +35,17 @@ import type { AsyncJob, FoldReason } from "../async/job-manager";
35
35
  */
36
36
  export declare const FOLD_WAKE_MERGE_WINDOW_MS = 800;
37
37
  /** The wait kinds that can be folded. `task`/`subagent` awaits are a non-goal. */
38
- export type FoldWaitKind = "bash-managed" | "client-terminal" | "bash-pty";
38
+ export type FoldWaitKind = "bash-managed" | "client-terminal" | "bash-pty" | "job-await";
39
+ /**
40
+ * Whether a wait may be picked as the implicit fold target by the chord and
41
+ * the SDK `bash.background` control. A `job-await` watches jobs that are
42
+ * already in the background, so "move the foreground bash into a background
43
+ * job" has nothing to move; it folds only when the `job` tool's own steer
44
+ * watcher names it explicitly. Keeping it out of implicit targeting also stops
45
+ * a `job poll` registered after a foreground bash from taking the chord away
46
+ * from the command the user is actually watching.
47
+ */
48
+ export declare function isImplicitFoldTarget(adapter: FoldAdapter): boolean;
39
49
  /** Outcome of settling the foreground caller. Exactly one party may settle it. */
40
50
  export type ForegroundSettleOutcome = "resolved" | "already-settled";
41
51
  /**
@@ -178,9 +188,13 @@ export declare class FoldCoordinator {
178
188
  constructor(deps: FoldCoordinatorDeps);
179
189
  /** Register a foldable wait. The most recently registered wait is the default target. */
180
190
  registerParticipant(adapter: FoldAdapter): () => void;
181
- /** Whether any wait is currently foldable, for the key-availability gate. */
191
+ /** Whether any implicitly targetable wait is currently foldable, for the key-availability gate. */
182
192
  hasFoldableParticipant(): boolean;
183
- /** Deterministic target: newest registration wins, so the chord folds what the user is watching. */
193
+ /**
194
+ * Deterministic implicit target: newest implicitly targetable registration
195
+ * wins, so the chord folds what the user is watching. `job-await` waits are
196
+ * skipped; they fold only through an explicit adapter.
197
+ */
184
198
  resolveTarget(): FoldAdapter | undefined;
185
199
  /**
186
200
  * T1. Synchronous prologue then async durability tail.
@@ -117,12 +117,18 @@ export interface ScrubbedProtocolRemnantReapResult {
117
117
  * or detached receipts retained as evidence) are never touched. A proven
118
118
  * concurrent disappearance (ENOENT) is benign; all other I/O failures are
119
119
  * returned and logged once without aborting scope preparation.
120
+ *
121
+ * Stranded replacement staging that aliases its own published destination is
122
+ * reaped by the same pass. That entry is neither zero-length nor single-link,
123
+ * so the terminal-remnant filters above can never reach it, yet leaving it in
124
+ * place bricks resume for the session it aliases.
120
125
  */
121
126
  export declare function reapScrubbedProtocolRemnantsSync(directory: string, minAgeMs?: number): ScrubbedProtocolRemnantReapResult;
122
127
  /**
123
128
  * Async twin of {@link reapScrubbedProtocolRemnantsSync} with the same safety
124
129
  * filters (terminal remnant prefix, zero-length, single-link, non-symlink,
125
- * older than the age gate), yielding between bounded batches. Long-lived
130
+ * older than the age gate, plus stranded staging that aliases its own
131
+ * published destination), yielding between bounded batches. Long-lived
126
132
  * processes reap per-session descendant directories through this path so a
127
133
  * legacy oversized directory cannot starve timers or sibling subagents while
128
134
  * it is being drained (issue #4394).