@sayknow-cli/coding-agent 0.4.7 → 0.5.1

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 (428) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/dist/types/capability/index.d.ts +10 -20
  3. package/dist/types/capability/types.d.ts +3 -0
  4. package/dist/types/cli/args.d.ts +0 -2
  5. package/dist/types/cli/read-cli.d.ts +1 -0
  6. package/dist/types/cli.d.ts +9 -1
  7. package/dist/types/commands/daemon.d.ts +2 -2
  8. package/dist/types/commands/deep-interview.d.ts +9 -0
  9. package/dist/types/commands/harness.d.ts +22 -0
  10. package/dist/types/commands/read.d.ts +6 -0
  11. package/dist/types/commands/sdk.d.ts +20 -2
  12. package/dist/types/config/keybindings.d.ts +34 -4
  13. package/dist/types/config/model-profile-contract.d.ts +40 -0
  14. package/dist/types/config/model-profiles.d.ts +2 -3
  15. package/dist/types/config/model-registry.d.ts +5 -0
  16. package/dist/types/config/provider-auth-health.d.ts +14 -0
  17. package/dist/types/config/provider-ranking.d.ts +59 -0
  18. package/dist/types/config/settings-schema.d.ts +156 -10
  19. package/dist/types/config/settings.d.ts +3 -0
  20. package/dist/types/edit/modes/patch.d.ts +13 -0
  21. package/dist/types/edit/path-mutation-lock.d.ts +15 -0
  22. package/dist/types/eval/py/executor.d.ts +1 -1
  23. package/dist/types/eval/py/runner-artifact.d.ts +8 -0
  24. package/dist/types/eval/py/tool-bridge.d.ts +1 -2
  25. package/dist/types/extensibility/extensions/types.d.ts +43 -2
  26. package/dist/types/extensibility/shared-events.d.ts +6 -0
  27. package/dist/types/internal-urls/local-root-gc.d.ts +2 -0
  28. package/dist/types/main.d.ts +33 -2
  29. package/dist/types/memories/index.d.ts +2 -0
  30. package/dist/types/modes/acp/acp-agent.d.ts +22 -9
  31. package/dist/types/modes/components/assistant-message.d.ts +3 -1
  32. package/dist/types/modes/components/btw-panel.d.ts +1 -0
  33. package/dist/types/modes/components/irc-sidebar.d.ts +41 -0
  34. package/dist/types/modes/components/queue-pane.d.ts +8 -0
  35. package/dist/types/modes/components/queued-message-selector.d.ts +6 -0
  36. package/dist/types/modes/components/read-tool-group.d.ts +4 -4
  37. package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +2 -1
  38. package/dist/types/modes/components/session-observer-overlay.d.ts +4 -0
  39. package/dist/types/modes/components/settings-selector.d.ts +2 -0
  40. package/dist/types/modes/components/tool-execution.d.ts +8 -0
  41. package/dist/types/modes/components/tool-status-header.d.ts +4 -2
  42. package/dist/types/modes/components/welcome.d.ts +5 -0
  43. package/dist/types/modes/controllers/btw-controller.d.ts +5 -0
  44. package/dist/types/modes/controllers/command-controller.d.ts +2 -0
  45. package/dist/types/modes/controllers/event-controller.d.ts +3 -0
  46. package/dist/types/modes/interactive-mode.d.ts +13 -2
  47. package/dist/types/modes/irc-observation-ledger.d.ts +17 -1
  48. package/dist/types/modes/prompt-action-autocomplete.d.ts +6 -1
  49. package/dist/types/modes/prompt-suggestion-controller.d.ts +35 -0
  50. package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +2 -2
  51. package/dist/types/modes/types.d.ts +6 -0
  52. package/dist/types/modes/utils/hotkeys-markdown.d.ts +2 -1
  53. package/dist/types/modes/utils/ui-helpers.d.ts +16 -0
  54. package/dist/types/runtime/memory-domain.d.ts +9 -0
  55. package/dist/types/runtime/memory-guard-contract.d.ts +71 -0
  56. package/dist/types/runtime/memory-guard.d.ts +39 -0
  57. package/dist/types/runtime/memory-limit.d.ts +11 -0
  58. package/dist/types/runtime-mcp/content-limits.d.ts +7 -0
  59. package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +1 -1
  60. package/dist/types/runtime-mcp/manager.d.ts +9 -1
  61. package/dist/types/runtime-mcp/oauth-flow.d.ts +0 -5
  62. package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +14 -0
  63. package/dist/types/runtime-mcp/redaction.d.ts +2 -0
  64. package/dist/types/runtime-mcp/smithery-auth.d.ts +5 -0
  65. package/dist/types/sdk/acp/final-text.d.ts +19 -0
  66. package/dist/types/sdk/acp/mcp.d.ts +23 -0
  67. package/dist/types/sdk/broker/broker.d.ts +2 -0
  68. package/dist/types/sdk/broker/lifecycle.d.ts +13 -0
  69. package/dist/types/sdk/bus/chat-daemon-control.d.ts +9 -1
  70. package/dist/types/sdk/bus/config-commands.d.ts +2 -2
  71. package/dist/types/sdk/bus/config.d.ts +2 -0
  72. package/dist/types/sdk/bus/control-drain-lease.d.ts +52 -0
  73. package/dist/types/sdk/bus/conversation-store.d.ts +1 -0
  74. package/dist/types/sdk/bus/daemon-paths.d.ts +1 -0
  75. package/dist/types/sdk/bus/index.d.ts +52 -4
  76. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +37 -0
  77. package/dist/types/sdk/bus/lifecycle-commands.d.ts +5 -4
  78. package/dist/types/sdk/bus/notification-orchestration.d.ts +1 -0
  79. package/dist/types/sdk/bus/notification-service.d.ts +34 -0
  80. package/dist/types/sdk/bus/operator-runtime.d.ts +1 -0
  81. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +106 -0
  82. package/dist/types/sdk/bus/rate-limit-pool.d.ts +2 -0
  83. package/dist/types/sdk/bus/reconciliation-store.d.ts +65 -0
  84. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +33 -9
  85. package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -1
  86. package/dist/types/sdk/bus/telegram-daemon.d.ts +286 -12
  87. package/dist/types/sdk/bus/telegram-reference.d.ts +2 -0
  88. package/dist/types/sdk/bus/topic-registry.d.ts +88 -2
  89. package/dist/types/sdk/client/discovery.d.ts +2 -0
  90. package/dist/types/sdk/client/liveness.d.ts +7 -0
  91. package/dist/types/sdk/host/control/operations.d.ts +3 -2
  92. package/dist/types/sdk/host/host.d.ts +3 -1
  93. package/dist/types/sdk/host/query/handlers.d.ts +14 -0
  94. package/dist/types/sdk/index.d.ts +2 -0
  95. package/dist/types/sdk/lifecycle-session.d.ts +10 -1
  96. package/dist/types/sdk/prompt-status.d.ts +88 -0
  97. package/dist/types/sdk/session-directory.d.ts +1 -1
  98. package/dist/types/sdk/session.d.ts +7 -0
  99. package/dist/types/sdk/startup-capability.d.ts +9 -0
  100. package/dist/types/sdk/transport/auth-preface.d.ts +9 -0
  101. package/dist/types/sdk/transport/index.d.ts +12 -0
  102. package/dist/types/sdk/transport/relay.d.ts +43 -0
  103. package/dist/types/sdk/transport/serve-cli.d.ts +4 -0
  104. package/dist/types/sdk/transport/socket.d.ts +7 -0
  105. package/dist/types/sdk/transport/stdio.d.ts +3 -0
  106. package/dist/types/session/agent-session.d.ts +83 -24
  107. package/dist/types/session/btw-contract.d.ts +16 -0
  108. package/dist/types/session/fallback-chain-controller.d.ts +18 -2
  109. package/dist/types/session/internal/managed-session-scope.d.ts +70 -10
  110. package/dist/types/session/internal/managed-session-storage.d.ts +34 -12
  111. package/dist/types/session/internal/native-publish-outcome.d.ts +48 -0
  112. package/dist/types/session/memory-guard-checkpoint-participant.d.ts +69 -0
  113. package/dist/types/session/session-manager.d.ts +89 -18
  114. package/dist/types/session/session-storage.d.ts +31 -0
  115. package/dist/types/session/streaming-output.d.ts +60 -5
  116. package/dist/types/setup/credential-import.d.ts +5 -1
  117. package/dist/types/setup/provider-onboarding.d.ts +2 -0
  118. package/dist/types/skc-runtime/deep-interview-runtime.d.ts +1 -1
  119. package/dist/types/skc-runtime/deep-interview-stage.d.ts +37 -0
  120. package/dist/types/skc-runtime/gc-runtime.d.ts +1 -1
  121. package/dist/types/skc-runtime/linux-proc.d.ts +22 -14
  122. package/dist/types/skc-runtime/memory-guard-owner-claims.d.ts +47 -0
  123. package/dist/types/skc-runtime/ralplan-runtime.d.ts +112 -1
  124. package/dist/types/skc-runtime/repository-binding.d.ts +63 -0
  125. package/dist/types/skc-runtime/state-runtime.d.ts +3 -1
  126. package/dist/types/skc-runtime/state-writer.d.ts +5 -1
  127. package/dist/types/skc-runtime/team-launch.d.ts +1 -1
  128. package/dist/types/skc-runtime/team-runtime.d.ts +9 -2
  129. package/dist/types/skc-runtime/team-store.d.ts +12 -0
  130. package/dist/types/skc-runtime/team-worker-memory-guard.d.ts +92 -0
  131. package/dist/types/skc-runtime/tmux-owner-isolation.d.ts +7 -0
  132. package/dist/types/skc-runtime/ultragoal-guard.d.ts +6 -5
  133. package/dist/types/skc-runtime/ultragoal-receipt-freshness.d.ts +28 -0
  134. package/dist/types/skc-runtime/ultragoal-runtime.d.ts +43 -5
  135. package/dist/types/skill-state/workflow-hud.d.ts +3 -0
  136. package/dist/types/ssh/utils.d.ts +1 -0
  137. package/dist/types/task/discovery.d.ts +3 -1
  138. package/dist/types/task/executor.d.ts +6 -0
  139. package/dist/types/task/index.d.ts +3 -1
  140. package/dist/types/task/provider-retry-status.d.ts +13 -0
  141. package/dist/types/task/receipt.d.ts +2 -0
  142. package/dist/types/task/types.d.ts +133 -0
  143. package/dist/types/task/ultragoal-redteam-activation.d.ts +33 -0
  144. package/dist/types/tools/browser/launch.d.ts +7 -0
  145. package/dist/types/tools/fetch.d.ts +22 -9
  146. package/dist/types/tools/image-gen.d.ts +63 -1
  147. package/dist/types/tools/index.d.ts +7 -1
  148. package/dist/types/tools/output-meta.d.ts +21 -1
  149. package/dist/types/tools/read-internals.d.ts +12 -0
  150. package/dist/types/tools/read.d.ts +45 -1
  151. package/dist/types/tools/resource-gc.d.ts +23 -0
  152. package/dist/types/tools/skill-discovery.d.ts +7 -0
  153. package/dist/types/tools/sqlite-reader.d.ts +7 -0
  154. package/dist/types/tools/tool-result.d.ts +7 -1
  155. package/dist/types/utils/prompt-suggestion.d.ts +33 -0
  156. package/dist/types/utils/shell-snapshot.d.ts +12 -0
  157. package/dist/types/web/insane/bridge.d.ts +1 -0
  158. package/dist/types/web/insane/url-guard.d.ts +17 -0
  159. package/package.json +8 -12
  160. package/scripts/benchmark-sticky-viewport-pr1.ts +239 -0
  161. package/scripts/capture-platform-shortcut-labels-showcase.ts +342 -0
  162. package/scripts/capture-sticky-viewport-showcase.ts +292 -0
  163. package/scripts/compile-args.ts +0 -1
  164. package/scripts/dogfood-repository-binding.ts +209 -0
  165. package/scripts/generate-docs-index.ts +4 -1
  166. package/scripts/generate-sdk-operation-inventory.ts +9 -0
  167. package/scripts/run-test-manifest.ts +6 -4
  168. package/scripts/verify-skc-sdk-canonicalization.ts +122 -18
  169. package/scripts/verify-sticky-viewport-showcase.ts +611 -0
  170. package/src/capability/index.ts +58 -42
  171. package/src/capability/types.ts +3 -0
  172. package/src/cli/args.ts +16 -100
  173. package/src/cli/fast-help.ts +1 -1
  174. package/src/cli/mcp-cli.ts +4 -21
  175. package/src/cli/notify-cli.ts +6 -38
  176. package/src/cli/read-cli.ts +2 -1
  177. package/src/cli/setup-cli.ts +10 -4
  178. package/src/cli.ts +133 -11
  179. package/src/commands/daemon.ts +22 -5
  180. package/src/commands/deep-interview.ts +26 -1
  181. package/src/commands/harness.ts +35 -12
  182. package/src/commands/read.ts +11 -2
  183. package/src/commands/sdk.ts +134 -17
  184. package/src/commands/team.ts +1 -1
  185. package/src/commit/agentic/index.ts +3 -3
  186. package/src/commit/map-reduce/index.ts +2 -2
  187. package/src/config/keybindings.ts +158 -25
  188. package/src/config/model-profile-contract.ts +174 -0
  189. package/src/config/model-profiles.ts +51 -10
  190. package/src/config/model-registry.ts +24 -4
  191. package/src/config/model-resolver.ts +2 -2
  192. package/src/config/provider-auth-health.ts +42 -0
  193. package/src/config/provider-ranking.ts +119 -0
  194. package/src/config/settings-schema.ts +157 -10
  195. package/src/config/settings.ts +254 -108
  196. package/src/coordinator-mcp/model-preset.ts +21 -74
  197. package/src/defaults/skc/skills/deep-interview/SKILL.md +147 -24
  198. package/src/defaults/skc/skills/ralplan/SKILL.md +91 -34
  199. package/src/defaults/skc/skills/team/SKILL.md +1 -1
  200. package/src/defaults/skc/skills/ultragoal/SKILL.md +68 -17
  201. package/src/discovery/ssh.ts +12 -1
  202. package/src/edit/index.ts +3 -6
  203. package/src/edit/modes/patch.ts +38 -1
  204. package/src/edit/modes/replace.ts +42 -0
  205. package/src/edit/path-mutation-lock.ts +112 -0
  206. package/src/eval/js/tool-bridge.ts +1 -1
  207. package/src/eval/py/executor.ts +37 -13
  208. package/src/eval/py/kernel.ts +1 -21
  209. package/src/eval/py/prelude.py +2 -2
  210. package/src/eval/py/runner-artifact.ts +84 -0
  211. package/src/eval/py/tool-bridge.ts +34 -18
  212. package/src/extensibility/extensions/runner.ts +4 -0
  213. package/src/extensibility/extensions/types.ts +42 -4
  214. package/src/extensibility/plugins/marketplace/fetcher.ts +191 -7
  215. package/src/extensibility/shared-events.ts +5 -0
  216. package/src/extensibility/skc-plugins/runtime-adapters.ts +2 -1
  217. package/src/hooks/native-skill-hook.ts +17 -4
  218. package/src/internal-urls/docs-index.generated.ts +17 -16
  219. package/src/internal-urls/local-protocol.ts +87 -25
  220. package/src/internal-urls/local-root-gc.ts +127 -0
  221. package/src/internal-urls/mcp-protocol.ts +73 -11
  222. package/src/main.ts +120 -42
  223. package/src/memories/index.ts +10 -0
  224. package/src/modes/DESIGN.md +52 -0
  225. package/src/modes/acp/acp-agent.ts +647 -83
  226. package/src/modes/acp/acp-event-mapper.ts +106 -12
  227. package/src/modes/acp/acp-mode.ts +39 -3
  228. package/src/modes/action-registry.ts +1 -1
  229. package/src/modes/components/assistant-message.ts +123 -22
  230. package/src/modes/components/btw-panel.ts +82 -16
  231. package/src/modes/components/irc-sidebar.ts +176 -62
  232. package/src/modes/components/model-selector.ts +61 -4
  233. package/src/modes/components/notifications-settings-editor.ts +1 -1
  234. package/src/modes/components/oauth-selector.ts +42 -12
  235. package/src/modes/components/plan-preview-overlay.ts +1 -1
  236. package/src/modes/components/queue-pane.ts +55 -9
  237. package/src/modes/components/queued-message-selector.ts +53 -10
  238. package/src/modes/components/read-tool-group.ts +82 -14
  239. package/src/modes/components/runtime-mcp-add-wizard.ts +5 -0
  240. package/src/modes/components/sayknow-pet-widget.ts +20 -8
  241. package/src/modes/components/session-observer-overlay.ts +187 -32
  242. package/src/modes/components/settings-selector.ts +60 -18
  243. package/src/modes/components/tool-execution.ts +138 -27
  244. package/src/modes/components/tool-status-header.ts +26 -8
  245. package/src/modes/components/welcome.ts +50 -23
  246. package/src/modes/controllers/btw-controller.ts +119 -36
  247. package/src/modes/controllers/command-controller.ts +101 -54
  248. package/src/modes/controllers/event-controller.ts +119 -27
  249. package/src/modes/controllers/extension-ui-controller.ts +23 -12
  250. package/src/modes/controllers/input-controller.ts +100 -8
  251. package/src/modes/controllers/runtime-mcp-command-controller.ts +29 -6
  252. package/src/modes/controllers/selector-controller.ts +4 -1
  253. package/src/modes/interactive-mode.ts +201 -60
  254. package/src/modes/irc-observation-ledger.ts +71 -15
  255. package/src/modes/prompt-action-autocomplete.ts +32 -13
  256. package/src/modes/prompt-suggestion-controller.ts +96 -0
  257. package/src/modes/runtime-init.ts +20 -2
  258. package/src/modes/shared/agent-wire/command-dispatch.ts +3 -3
  259. package/src/modes/shared/agent-wire/workflow-gate-broker.ts +2 -2
  260. package/src/modes/types.ts +6 -0
  261. package/src/modes/utils/hotkeys-markdown.ts +64 -36
  262. package/src/modes/utils/ui-helpers.ts +99 -4
  263. package/src/prompts/agent-fragments/restricted-bash.md +1 -1
  264. package/src/prompts/agents/architect.md +17 -3
  265. package/src/prompts/agents/critic.md +17 -2
  266. package/src/prompts/agents/executor.md +1 -1
  267. package/src/prompts/agents/planner.md +8 -1
  268. package/src/prompts/system/btw-user.md +3 -8
  269. package/src/prompts/system/prompt-suggestion-system.md +32 -0
  270. package/src/prompts/system/system-prompt.md +6 -3
  271. package/src/prompts/tools/cron.md +3 -1
  272. package/src/prompts/tools/read.md +4 -2
  273. package/src/prompts/tools/skill-discovery.md +1 -0
  274. package/src/runtime/memory-domain.ts +66 -0
  275. package/src/runtime/memory-guard-contract.ts +73 -0
  276. package/src/runtime/memory-guard.ts +292 -0
  277. package/src/runtime/memory-limit.ts +50 -0
  278. package/src/runtime-mcp/client.ts +41 -55
  279. package/src/runtime-mcp/content-limits.ts +71 -0
  280. package/src/runtime-mcp/discoverable-tool-metadata.ts +1 -1
  281. package/src/runtime-mcp/json-rpc.ts +28 -11
  282. package/src/runtime-mcp/manager.ts +77 -59
  283. package/src/runtime-mcp/oauth-flow.ts +0 -72
  284. package/src/runtime-mcp/plugin-network-boundary.ts +101 -0
  285. package/src/runtime-mcp/redaction.ts +30 -0
  286. package/src/runtime-mcp/smithery-auth.ts +17 -2
  287. package/src/runtime-mcp/smithery-connect.ts +11 -1
  288. package/src/runtime-mcp/transports/http.ts +63 -22
  289. package/src/sdk/acp/adapter.ts +8 -1
  290. package/src/sdk/acp/final-text.ts +40 -0
  291. package/src/sdk/acp/mcp.ts +26 -0
  292. package/src/sdk/broker/broker.ts +34 -20
  293. package/src/sdk/broker/identity.ts +22 -12
  294. package/src/sdk/broker/lifecycle.ts +293 -43
  295. package/src/sdk/broker/session-index.ts +11 -1
  296. package/src/sdk/bus/chat-daemon-cli.ts +2 -2
  297. package/src/sdk/bus/chat-daemon-control.ts +22 -5
  298. package/src/sdk/bus/config-commands.ts +2 -2
  299. package/src/sdk/bus/config.ts +10 -2
  300. package/src/sdk/bus/control-drain-lease.ts +104 -0
  301. package/src/sdk/bus/conversation-store.ts +40 -6
  302. package/src/sdk/bus/daemon-paths.ts +2 -0
  303. package/src/sdk/bus/index.ts +793 -121
  304. package/src/sdk/bus/kind-aware-reconciliation.ts +242 -0
  305. package/src/sdk/bus/lifecycle-commands.ts +63 -10
  306. package/src/sdk/bus/lifecycle-control-runtime.ts +11 -2
  307. package/src/sdk/bus/lifecycle-orchestrator.ts +32 -1
  308. package/src/sdk/bus/notification-orchestration.ts +12 -0
  309. package/src/sdk/bus/notification-service.ts +87 -25
  310. package/src/sdk/bus/operator-runtime.ts +31 -5
  311. package/src/sdk/bus/prompt-reconciliation.ts +240 -0
  312. package/src/sdk/bus/rate-limit-pool.ts +8 -0
  313. package/src/sdk/bus/recent-activity.ts +90 -26
  314. package/src/sdk/bus/reconciliation-store.ts +224 -0
  315. package/src/sdk/bus/telegram-cli.ts +6 -13
  316. package/src/sdk/bus/telegram-daemon-cli.ts +8 -3
  317. package/src/sdk/bus/telegram-daemon-contract.ts +34 -9
  318. package/src/sdk/bus/telegram-daemon-control.ts +161 -40
  319. package/src/sdk/bus/telegram-daemon.ts +3649 -593
  320. package/src/sdk/bus/telegram-reference.ts +20 -2
  321. package/src/sdk/bus/topic-registry.ts +451 -12
  322. package/src/sdk/cli/session-cli.ts +15 -2
  323. package/src/sdk/client/discovery.ts +19 -3
  324. package/src/sdk/client/liveness.ts +49 -0
  325. package/src/sdk/host/control/dispatch.ts +8 -2
  326. package/src/sdk/host/control/operations.ts +3 -2
  327. package/src/sdk/host/host.ts +27 -9
  328. package/src/sdk/host/query/handlers.ts +125 -5
  329. package/src/sdk/index.ts +12 -0
  330. package/src/sdk/lifecycle-session.ts +19 -3
  331. package/src/sdk/mcp/server.ts +46 -18
  332. package/src/sdk/prompt-status.ts +97 -0
  333. package/src/sdk/protocol/operation-inventory.generated.json +145 -0
  334. package/src/sdk/protocol/operation-registry.ts +24 -4
  335. package/src/sdk/session-directory.ts +5 -1
  336. package/src/sdk/session.ts +69 -8
  337. package/src/sdk/startup-capability.ts +15 -1
  338. package/src/sdk/transport/auth-preface.ts +82 -0
  339. package/src/sdk/transport/index.ts +18 -0
  340. package/src/sdk/transport/relay.ts +252 -0
  341. package/src/sdk/transport/serve-cli.ts +105 -0
  342. package/src/sdk/transport/socket.ts +197 -0
  343. package/src/sdk/transport/stdio.ts +17 -0
  344. package/src/session/agent-session.ts +1112 -314
  345. package/src/session/blob-store.ts +25 -7
  346. package/src/session/btw-contract.ts +59 -0
  347. package/src/session/fallback-chain-controller.ts +47 -8
  348. package/src/session/internal/managed-session-scope.ts +1426 -259
  349. package/src/session/internal/managed-session-storage.ts +414 -238
  350. package/src/session/internal/native-publish-outcome.ts +271 -0
  351. package/src/session/memory-guard-checkpoint-participant.ts +131 -0
  352. package/src/session/session-manager.ts +2079 -469
  353. package/src/session/session-storage.ts +151 -11
  354. package/src/session/streaming-output.ts +262 -43
  355. package/src/setup/credential-import.ts +28 -3
  356. package/src/setup/provider-onboarding.ts +49 -5
  357. package/src/setup/provider-presets.json +2 -1
  358. package/src/skc-runtime/deep-interview-runtime.ts +303 -36
  359. package/src/skc-runtime/deep-interview-stage.ts +1016 -0
  360. package/src/skc-runtime/deep-interview-state.ts +8 -5
  361. package/src/skc-runtime/gc-render.ts +1 -0
  362. package/src/skc-runtime/gc-runtime.ts +11 -1
  363. package/src/skc-runtime/linux-proc.ts +70 -36
  364. package/src/skc-runtime/managed-owner-supervisor.ts +83 -4
  365. package/src/skc-runtime/memory-guard-owner-claims.ts +389 -0
  366. package/src/skc-runtime/ralplan-runtime.ts +1057 -75
  367. package/src/skc-runtime/repository-binding.ts +267 -0
  368. package/src/skc-runtime/session-state-sidecar.ts +25 -9
  369. package/src/skc-runtime/state-runtime.ts +50 -12
  370. package/src/skc-runtime/state-writer.ts +68 -56
  371. package/src/skc-runtime/team-launch.ts +34 -5
  372. package/src/skc-runtime/team-runtime.ts +41 -1
  373. package/src/skc-runtime/team-store.ts +32 -0
  374. package/src/skc-runtime/team-worker-memory-guard.ts +363 -0
  375. package/src/skc-runtime/team-workers.ts +1 -0
  376. package/src/skc-runtime/tmux-common.ts +13 -2
  377. package/src/skc-runtime/tmux-owner-isolation.ts +20 -1
  378. package/src/skc-runtime/tmux-sessions.ts +45 -6
  379. package/src/skc-runtime/ultragoal-guard.ts +93 -15
  380. package/src/skc-runtime/ultragoal-receipt-freshness.ts +123 -0
  381. package/src/skc-runtime/ultragoal-runtime.ts +469 -38
  382. package/src/skc-runtime/workflow-manifest.generated.json +195 -5
  383. package/src/skc-runtime/workflow-manifest.ts +67 -3
  384. package/src/skill-state/workflow-hud.ts +25 -2
  385. package/src/skill-state/workflow-mutation-guard.ts +104 -12
  386. package/src/slash-commands/builtin-registry.ts +1 -1
  387. package/src/ssh/utils.ts +14 -0
  388. package/src/task/discovery.ts +8 -2
  389. package/src/task/executor.ts +165 -47
  390. package/src/task/index.ts +123 -15
  391. package/src/task/provider-retry-status.ts +88 -0
  392. package/src/task/receipt.ts +3 -0
  393. package/src/task/render.ts +45 -26
  394. package/src/task/skc-command.ts +2 -2
  395. package/src/task/types.ts +55 -10
  396. package/src/task/ultragoal-redteam-activation.ts +75 -0
  397. package/src/tools/ask.ts +1 -1
  398. package/src/tools/ast-edit.ts +2 -2
  399. package/src/tools/bash-allowed-prefixes.ts +45 -1
  400. package/src/tools/bash-pty-selection.ts +2 -2
  401. package/src/tools/browser/launch.ts +41 -6
  402. package/src/tools/browser/screenshot-format.ts +6 -1
  403. package/src/tools/cron.ts +1 -1
  404. package/src/tools/fetch.ts +127 -154
  405. package/src/tools/image-gen.ts +476 -23
  406. package/src/tools/index.ts +7 -1
  407. package/src/tools/output-meta.ts +176 -9
  408. package/src/tools/path-utils.ts +5 -1
  409. package/src/tools/read-internals.ts +44 -0
  410. package/src/tools/read.ts +1544 -310
  411. package/src/tools/resource-gc.ts +665 -125
  412. package/src/tools/skill-discovery.ts +39 -3
  413. package/src/tools/sqlite-reader.ts +63 -5
  414. package/src/tools/subagent-render.ts +74 -16
  415. package/src/tools/subagent.ts +2 -0
  416. package/src/tools/tool-result.ts +14 -1
  417. package/src/utils/edit-mode.ts +2 -2
  418. package/src/utils/pasted-image-path.ts +15 -6
  419. package/src/utils/prompt-suggestion.ts +265 -0
  420. package/src/utils/shell-snapshot.ts +173 -63
  421. package/src/utils/sixel.ts +3 -3
  422. package/src/web/insane/bridge.ts +5 -1
  423. package/src/web/insane/url-guard.ts +140 -27
  424. package/src/web/scrapers/docs-rs.ts +30 -5
  425. package/src/web/scrapers/types.ts +19 -49
  426. package/src/web/scrapers/utils.ts +12 -26
  427. package/src/web/search/providers/codex.ts +1 -1
  428. package/src/workflow/workflow-intent-diff.ts +4 -1
@@ -0,0 +1,39 @@
1
+ import type { Settings } from "../config/settings";
2
+ import type { MemoryGuardDecision, MemoryGuardDomainSnapshot, MemoryGuardPolicy, MemoryGuardSchedulerState } from "./memory-guard-contract";
3
+ type WorkOwner = {
4
+ generation: number;
5
+ source: "timer" | "external";
6
+ };
7
+ export interface MemoryGuardHostRegistration {
8
+ ownerId: string;
9
+ intervalMs: number;
10
+ }
11
+ export interface MemoryGuardHostOptions {
12
+ run: () => Promise<void>;
13
+ logDebug?: (message: string, meta?: Record<string, unknown>) => void;
14
+ schedulerNow?: () => number;
15
+ }
16
+ export declare function resolveMemoryGuardPolicy(settings: Settings): MemoryGuardPolicy;
17
+ export declare function chooseMemoryGuardAction(input: {
18
+ domain: MemoryGuardDomainSnapshot;
19
+ hostSupported: boolean;
20
+ workerSupported: (workerId: string) => boolean;
21
+ }): MemoryGuardDecision;
22
+ export declare function revalidateMemoryGuardAction(previous: Extract<MemoryGuardDecision, {
23
+ kind: "execute";
24
+ }>, revalidated: MemoryGuardDecision): MemoryGuardDecision;
25
+ export declare class MemoryGuardHost {
26
+ #private;
27
+ constructor(options: MemoryGuardHostOptions);
28
+ register(registration: MemoryGuardHostRegistration): () => void;
29
+ updateInterval(ownerId: string, intervalMs: number): void;
30
+ runTick(generation?: number, source?: WorkOwner["source"]): Promise<void>;
31
+ runTimerCallbackForTest(owner: {
32
+ generation: number;
33
+ token: number;
34
+ }, deadline: number): Promise<void>;
35
+ setSchedulerNowForTest(now: () => number): void;
36
+ getStateForTest(): MemoryGuardSchedulerState;
37
+ resetForTest(): void;
38
+ }
39
+ export {};
@@ -0,0 +1,11 @@
1
+ export interface EffectiveMemoryLimitInput {
2
+ hardCapBytes?: number | null;
3
+ policyLimitBytes?: number | null;
4
+ }
5
+ export interface EffectiveMemoryLimit {
6
+ hardCapBytes: number | null;
7
+ policyLimitBytes: number | null;
8
+ effectiveBytes: number | null;
9
+ source: "none" | "hard_cap" | "policy_limit" | "hard_cap_and_policy_limit";
10
+ }
11
+ export declare function resolveEffectiveMemoryLimit(input: EffectiveMemoryLimitInput): EffectiveMemoryLimit;
@@ -0,0 +1,7 @@
1
+ export declare const MCP_MAX_CONTENT_BYTES: number;
2
+ export declare const MCP_MAX_ERROR_BYTES: number;
3
+ export declare const MCP_MAX_SSE_REQUEST_MESSAGES = 1024;
4
+ export declare const MCP_MAX_SSE_BATCH_MESSAGES = 1024;
5
+ export declare const MCP_HTTP_TIMEOUT_MS = 30000;
6
+ export declare function cancelMCPStream(stream: ReadableStream<Uint8Array> | null): void;
7
+ export declare function readMCPResponseText(response: Response, limit: number, truncate?: boolean, signal?: AbortSignal): Promise<string>;
@@ -6,5 +6,5 @@
6
6
  * Upstream v0.11.x renamed `DiscoverableMCP*` → `DiscoverableTool*`; we re-export
7
7
  * the new symbols under the legacy names so existing call sites still compile.
8
8
  */
9
- export type { DiscoverableToolSearchDocument as DiscoverableMCPSearchDocument, DiscoverableToolSearchIndex as DiscoverableMCPSearchIndex, DiscoverableToolSearchResult as DiscoverableMCPSearchResult, DiscoverableTool as DiscoverableMCPTool, DiscoverableToolServerSummary as DiscoverableMCPToolServerSummary, DiscoverableToolSummary as DiscoverableMCPToolSummary, } from "../tool-discovery/tool-index";
9
+ export type { DiscoverableTool as DiscoverableMCPTool, DiscoverableToolSearchDocument as DiscoverableMCPSearchDocument, DiscoverableToolSearchIndex as DiscoverableMCPSearchIndex, DiscoverableToolSearchResult as DiscoverableMCPSearchResult, DiscoverableToolServerSummary as DiscoverableMCPToolServerSummary, DiscoverableToolSummary as DiscoverableMCPToolSummary, } from "../tool-discovery/tool-index";
10
10
  export { buildDiscoverableToolSearchIndex as buildDiscoverableMCPSearchIndex, collectDiscoverableTools as collectDiscoverableMCPTools, formatDiscoverableToolServerSummary as formatDiscoverableMCPToolServerSummary, getDiscoverableTool as getDiscoverableMCPTool, isMCPBridgeTool, isMCPToolName, searchDiscoverableTools as searchDiscoverableMCPTools, selectDiscoverableToolNamesByServer as selectDiscoverableMCPToolNamesByServer, summarizeDiscoverableTools as summarizeDiscoverableMCPTools, } from "../tool-discovery/tool-index";
@@ -1,10 +1,11 @@
1
- import type { TSchema } from "@sayknow-cli/ai";
1
+ import { type TSchema } from "@sayknow-cli/ai";
2
2
  import type { SourceMeta } from "../capability/types";
3
3
  import type { CustomTool } from "../extensibility/custom-tools/types";
4
4
  import type { AuthStorage } from "../session/auth-storage";
5
5
  import type { MCPToolDetails } from "./tool-bridge";
6
6
  import type { MCPToolCache } from "./tool-cache";
7
7
  import type { MCPGetPromptResult, MCPPrompt, MCPRequestOptions, MCPResource, MCPResourceReadResult, MCPResourceTemplate, MCPServerConfig, MCPServerConnection } from "./types";
8
+ export declare function resolveStartupTimeoutMs(configs: MCPServerConfig[], maxStartupTimeoutMs?: number): number;
8
9
  /**
9
10
  * Stable, total ordering on MCP tools by name.
10
11
  *
@@ -48,6 +49,13 @@ export interface MCPDiscoverOptions {
48
49
  export interface MCPManagerOptions {
49
50
  /** Restrict this instance to tools from an explicit MCP config. */
50
51
  toolsOnly?: boolean;
52
+ /**
53
+ * Ceiling for the startup wait, in milliseconds. Only ACP lifecycle launches
54
+ * set this, so a slow ACP MCP handshake gets the readiness budget while every
55
+ * other consumer keeps the short default. Non-positive or non-finite values
56
+ * are ignored and the default applies.
57
+ */
58
+ maxStartupTimeoutMs?: number;
51
59
  }
52
60
  /**
53
61
  * MCP Server Manager.
@@ -52,8 +52,3 @@ export declare class MCPOAuthFlow extends OAuthCallbackFlow {
52
52
  }>;
53
53
  exchangeToken(code: string, _state: string, redirectUri: string): Promise<OAuthCredentials>;
54
54
  }
55
- /**
56
- * Refresh an MCP OAuth token using the standard refresh_token grant.
57
- * Returns updated credentials; preserves the old refresh token if the server doesn't rotate it.
58
- */
59
- export declare function refreshMCPOAuthToken(tokenUrl: string, refreshToken: string, clientId?: string, clientSecret?: string): Promise<OAuthCredentials>;
@@ -0,0 +1,14 @@
1
+ import { type AddressResolver } from "../web/insane/url-guard";
2
+ import type { MCPHttpServerConfig, MCPSseServerConfig } from "./types";
3
+ /** Mark an in-memory plugin-bundle remote MCP config for connection-bound public-network enforcement. */
4
+ export declare function bindPluginMcpToPublicNetwork<T extends MCPHttpServerConfig | MCPSseServerConfig>(config: T): T;
5
+ /** The marker is an internal symbol, so persisted user MCP configs cannot opt into or forge this path. */
6
+ export declare function isPluginMcpPublicNetworkBound(config: MCPHttpServerConfig | MCPSseServerConfig): boolean;
7
+ /**
8
+ * Fetch a plugin-bundle MCP request through a DNS-pinned public address. Every
9
+ * redirect is handled manually and revalidated before the next connection.
10
+ */
11
+ export declare function fetchPluginMcpRequest(rawUrl: string, init: BunFetchRequestInit, options?: {
12
+ resolver?: AddressResolver;
13
+ maxRedirects?: number;
14
+ }): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ export declare function redactMCPEndpoint(value: string | undefined): string | undefined;
2
+ export declare function redactMCPDiagnosticValue(value: unknown): unknown;
@@ -7,6 +7,11 @@ type SmitheryCliPollResponse = {
7
7
  apiKey?: string;
8
8
  message?: string;
9
9
  };
10
+ /** Test seam: the Smithery origin and env API key as resolved from trusted env. */
11
+ export declare function resolveSmitheryEnvForTest(): {
12
+ url: string;
13
+ apiKey: string | undefined;
14
+ };
10
15
  export declare function getSmitheryLoginUrl(): string;
11
16
  export declare function createSmitheryCliAuthSession(): Promise<SmitheryCliAuthSession>;
12
17
  export declare function pollSmitheryCliAuthSession(sessionId: string, signal?: AbortSignal): Promise<SmitheryCliPollResponse>;
@@ -0,0 +1,19 @@
1
+ export declare const ACP_FINAL_TEXT_LIMIT = 100000;
2
+ export interface BoundedAcpFinalText {
3
+ text: string;
4
+ truncated: boolean;
5
+ }
6
+ export type AcpFinalTextResolution = {
7
+ kind: "none";
8
+ final: BoundedAcpFinalText;
9
+ } | {
10
+ kind: "emit";
11
+ final: BoundedAcpFinalText;
12
+ text: string;
13
+ } | {
14
+ kind: "divergent";
15
+ final: BoundedAcpFinalText;
16
+ };
17
+ export declare function boundAcpFinalText(value: string): BoundedAcpFinalText;
18
+ export declare function acpFinalTextFromMessage(message: unknown): BoundedAcpFinalText;
19
+ export declare function resolveAcpFinalText(streamed: string, finalText: string): AcpFinalTextResolution;
@@ -0,0 +1,23 @@
1
+ export declare const ACP_MCP_REQUEST_TIMEOUT_MS = 30000;
2
+ export declare const ACP_MCP_LIFECYCLE_TIMEOUT_MS: number;
3
+ /**
4
+ * Slice of the readiness budget reserved for the work that follows MCP startup
5
+ * (session wiring, marker publication). The ACP MCP startup ceiling is the
6
+ * remaining time to `semanticReadyDeadlineAt` minus this headroom, so a slow
7
+ * MCP handshake cannot consume the whole readiness window.
8
+ */
9
+ export declare const ACP_MCP_STARTUP_HEADROOM_MS = 250;
10
+ export interface SessionLifecycleMcpStdioServer {
11
+ type?: "stdio";
12
+ name: string;
13
+ command: string;
14
+ args: string[];
15
+ env?: Record<string, string>;
16
+ }
17
+ export interface SessionLifecycleMcpRemoteServer {
18
+ type: "http" | "sse";
19
+ name: string;
20
+ url: string;
21
+ headers?: Record<string, string>;
22
+ }
23
+ export type SessionLifecycleMcpServer = SessionLifecycleMcpStdioServer | SessionLifecycleMcpRemoteServer;
@@ -1,4 +1,5 @@
1
1
  import type { NativeDirectoryTreeSnapshot } from "@sayknow-cli/natives";
2
+ import type { ModelProfileErrorDetails } from "../../config/model-profile-contract";
2
3
  import { type DirectoryMigrationPolicy } from "../session-directory";
3
4
  import { type BrokerDiscovery, type RedactedBrokerDiscovery } from "./discovery";
4
5
  import { type LifecycleDurableEffectsReceipt, LifecycleLedger, type LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
@@ -93,6 +94,7 @@ export type BrokerResponse = {
93
94
  error: {
94
95
  code: BrokerErrorCode;
95
96
  message: string;
97
+ details?: ModelProfileErrorDetails;
96
98
  endpoint?: "unavailable";
97
99
  cleanup?: BrokerCleanupEvidence;
98
100
  };
@@ -1,3 +1,4 @@
1
+ import type { SessionLifecycleMcpServer } from "../acp/mcp";
1
2
  import type { SdkStartupFailure, SdkStartupRollbackResult } from "../startup-capability";
2
3
  import type { Broker, BrokerCleanupEvidence, BrokerResponse } from "./broker";
3
4
  import type { LifecycleDurableEffectsReceipt, LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
@@ -61,6 +62,7 @@ export interface SessionLifecycleLaunchRequest {
61
62
  /** Broker-issued effect marker which the child echoes only after host readiness. */
62
63
  effectMarker?: string;
63
64
  modelPreset?: string;
65
+ mcpServers?: SessionLifecycleMcpServer[];
64
66
  worktree?: SessionLifecycleWorktreeTarget;
65
67
  receivedAt: number;
66
68
  requestedReadinessTimeoutMs: number;
@@ -70,6 +72,12 @@ export interface SessionLifecycleLaunchRequest {
70
72
  }
71
73
  export declare function readSessionLifecycleLaunchRequest(value: string | undefined, now?: number): SessionLifecycleLaunchRequest;
72
74
  type CleanupEvidence = BrokerCleanupEvidence;
75
+ export declare function validateBrokerModelPresetForTest(agentDir: string, requestedProfile: string): string | BrokerResponse;
76
+ /** Test seam: the session-host command override as resolved from trusted env. */
77
+ export declare function sdkSessionCommandOverrideForTest(): {
78
+ file: string;
79
+ args: string[];
80
+ } | undefined;
73
81
  export declare function setProcessIncarnationForTest(broker: Broker, value: ((pid: number) => string | undefined) | undefined): void;
74
82
  /** The child writes this only after its endpoint and semantic ready event are both live. */
75
83
  export declare function writeSessionLifecycleReady(root: string, id: string, effectMarker: string): Promise<void>;
@@ -79,6 +87,11 @@ export interface LifecycleTranscriptEvidence {
79
87
  }
80
88
  /** The child writes bounded startup diagnostics before exiting without readiness. */
81
89
  export declare function writeSessionLifecycleFailure(root: string, id: string, effectMarker: string, failure: SdkStartupFailure, rollback: SdkStartupRollbackResult, transcript?: LifecycleTranscriptEvidence, ownerIncarnation?: string): Promise<void>;
90
+ export declare function readSessionLifecycleFailureForTest(root: string, id: string, expected: {
91
+ pid: number;
92
+ effectMarker: string;
93
+ incarnation: string;
94
+ }): Promise<SdkStartupFailure | undefined>;
82
95
  export interface LifecycleExecutionOutcome {
83
96
  response: BrokerResponse;
84
97
  durableEffects?: LifecycleDurableEffectsReceipt;
@@ -8,7 +8,15 @@ export type ChatDaemonAction = "stop" | "reload";
8
8
  * Generation 6 carries the retained managed filesystem authority boundary.
9
9
  * Generation 7 restores macOS daemon signaling (kill(2) with a start-time
10
10
  * incarnation recheck) so a live/hung owner can be replaced without an external
11
- * `kill -9`.
11
+ * `kill -9`. Generation 8 adopts Windows expected-identity ACL verification and
12
+ * repair for shared native authority. Generation 9 refreshes the shared native
13
+ * authority declaration contract with bounded frame-delivery acknowledgement.
14
+ * Generation 11 accepts typed retained exact-unlink cleanup authority — a
15
+ * concrete detached quarantine plus a proven-absent canonical lock pathname —
16
+ * when deleting an observed owner-lock lease. Generation 12 refreshes retained
17
+ * native path and process authority semantics. Generation 13 rejects special
18
+ * files before retained native authority opens. Generation 14 reloads shared
19
+ * chat daemons after notification configuration parsing changes.
12
20
  */
13
21
  export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
14
22
  export declare function chatDaemonGeneration(kind: ChatDaemonKind): number;
@@ -5,8 +5,8 @@
5
5
  * removed), but the user can still adjust per-surface behaviour from inside a
6
6
  * session thread with small slash commands:
7
7
  *
8
- * - `/verbose` switch the mirror to bounded tool-owned summaries + provider-displayable reasoning summaries
9
- * - `/lean` switch back to lean (assistant text + tool names)
8
+ * - `/verbose` switch the mirror to per-turn assistant text + tool summaries + reasoning summaries
9
+ * - `/lean` settled assistant answer at idle + immediate ask lead-ins (no intermediate tool-turn flood)
10
10
  * - `/verbosity lean|verbose`
11
11
  * - `/redact on|off` toggle redaction of streamed content
12
12
  *
@@ -287,6 +287,8 @@ export interface RedactableAction {
287
287
  question?: string;
288
288
  options?: string[];
289
289
  summary?: string;
290
+ /** Optional zero-based recommendation into the authoritative raw options. */
291
+ recommendedIndex?: number;
290
292
  }
291
293
  /**
292
294
  * When redact is true, strip sensitive content for remote delivery:
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Ordering seam for an in-band SDK identity transition.
3
+ *
4
+ * A request arrives through predecessor A, so a successful terminal response cannot
5
+ * be published until successor B is ready. Native builds may provide a true
6
+ * send-only connection lease; source/dev builds use the conservative fallback in
7
+ * which the predecessor server remains alive until the terminal write completes.
8
+ */
9
+ export type TerminalSendOutcome = "written" | "disconnected" | "write_failed";
10
+ /** Fence/capability hooks may return false to reject; undefined means ok. */
11
+ export type IdentityControlGateResult = boolean | undefined;
12
+ export type IdentityControlGate = () => IdentityControlGateResult | Promise<IdentityControlGateResult>;
13
+ export interface IdentityControlSuccessPathInput {
14
+ /** Fence predecessor inbound work. The fence must not close its response writer. */
15
+ fence: IdentityControlGate;
16
+ /** Optional explicit proof that the predecessor writer is still usable. */
17
+ ensurePredecessorSendCapable?: IdentityControlGate;
18
+ /** Start successor B and resolve only after its public endpoint is ready. */
19
+ startSuccessor: () => Promise<void>;
20
+ /** Write and flush either the success or non-success terminal response. */
21
+ sendTerminal: () => Promise<TerminalSendOutcome>;
22
+ /** Release predecessor A after the terminal response has settled. */
23
+ stopPredecessor: () => Promise<void>;
24
+ /** Set only when a caller cannot use the retained-writer fallback. */
25
+ requireNativeControlDrain?: boolean;
26
+ }
27
+ export interface IdentityControlTerminalPathInput {
28
+ fenceInbound: IdentityControlGate;
29
+ ensurePredecessorSendCapable?: IdentityControlGate;
30
+ startSuccessorReady: () => Promise<void>;
31
+ sendTerminal: () => Promise<TerminalSendOutcome>;
32
+ stopPredecessor: () => Promise<void>;
33
+ requireNativeControlDrain?: boolean;
34
+ }
35
+ /**
36
+ * Probe the loaded native addon, never an environment flag or a TypeScript shim.
37
+ * Older/source installs intentionally report false so callers can select the
38
+ * retained-writer fallback or fail closed when detach is mandatory.
39
+ */
40
+ export declare function isNativeControlDrainAvailable(): boolean;
41
+ /**
42
+ * Run the only safe ordering for a successful identity-control response.
43
+ *
44
+ * The `finally` is deliberately around both successor startup and terminal
45
+ * delivery: a failed startup must not leave the fenced predecessor alive, and a
46
+ * failed/disconnected terminal write must still release it. When native detach
47
+ * is unavailable the caller is expected to keep A's server up (not call
48
+ * `stopAndWait`) until `sendTerminal` settles.
49
+ */
50
+ export declare function runIdentityControlSuccessPath(input: IdentityControlSuccessPathInput): Promise<TerminalSendOutcome>;
51
+ /** Compatibility spelling used by the host wiring design notes. */
52
+ export declare function runIdentityControlTerminalPath(input: IdentityControlTerminalPathInput): Promise<TerminalSendOutcome>;
@@ -56,6 +56,7 @@ export declare class ConversationStore<T extends ConversationRecord> {
56
56
  pidAlive?: (pid: number) => boolean;
57
57
  sleep?: (ms: number) => Promise<void>;
58
58
  lockTimeoutMs?: number;
59
+ platform?: NodeJS.Platform;
59
60
  });
60
61
  get filePath(): string;
61
62
  load(): Promise<ConversationStoreDocument<T>>;
@@ -9,6 +9,7 @@ export interface DaemonPaths {
9
9
  dir: string;
10
10
  lock: string;
11
11
  state: string;
12
+ heartbeat: string;
12
13
  ownership: string;
13
14
  roots: string;
14
15
  steal: string;
@@ -29,7 +29,9 @@ import { CursorRegistry, RevisionStore } from "../host/query";
29
29
  import { type SdkStartupFailure } from "../startup-capability";
30
30
  import { type NotificationConfig } from "./config";
31
31
  import { NotificationSessionController } from "./session-control";
32
- import { type EnsureDaemonResult } from "./telegram-daemon";
32
+ import { type EnsureDaemonResult, type RegisterNotificationRootResult } from "./telegram-daemon";
33
+ export type { IdentityControlSuccessPathInput, IdentityControlTerminalPathInput, TerminalSendOutcome, } from "./control-drain-lease";
34
+ export { isNativeControlDrainAvailable, runIdentityControlSuccessPath, runIdentityControlTerminalPath, } from "./control-drain-lease";
33
35
  /** Where a `session_create` should run. Discriminated by `kind`. */
34
36
  export type SessionCreateTarget = {
35
37
  kind: "existing_path";
@@ -204,6 +206,7 @@ interface UnattendedGatePresentation {
204
206
  question: string;
205
207
  options: string[];
206
208
  controls: readonly AskRemoteControl[];
209
+ recommendedIndex?: number;
207
210
  multi: boolean;
208
211
  allowEmpty: boolean;
209
212
  navigationLabel?: "Next" | "Done";
@@ -296,6 +299,8 @@ interface SessionRuntime {
296
299
  disposeGateListener: () => void;
297
300
  /** Whether notification-only delivery and answer resources are active. */
298
301
  notificationsActive: boolean;
302
+ /** Rejects new SDK frames while a leased terminal response drains. */
303
+ inboundFenced: boolean;
299
304
  /** Set as soon as terminal teardown is requested, before startup settles. */
300
305
  stopping: boolean;
301
306
  /** Recreates notification-only resources after `/notify on`. */
@@ -323,6 +328,12 @@ interface SessionRuntime {
323
328
  hostStopped: boolean;
324
329
  serverStopped: boolean;
325
330
  brokerRegistrationReleased: boolean;
331
+ /** Managed Telegram root registration released during terminal teardown. */
332
+ notificationRootRegistration?: {
333
+ settings: Settings;
334
+ cwd: string;
335
+ registrationToken?: string;
336
+ };
326
337
  verbosity: "lean" | "verbose";
327
338
  sessionTag: string;
328
339
  /** Whether the agent loop is currently running (drives the typing indicator). */
@@ -343,6 +354,21 @@ interface SessionRuntime {
343
354
  commandId: string;
344
355
  turnId: string;
345
356
  } | undefined) => boolean;
357
+ /** Transitions the authoritative reconciliation record at lifecycle ingress; terminal outcomes settle once. */
358
+ notePromptReconciliation: (correlation: {
359
+ commandId: string;
360
+ turnId: string;
361
+ } | undefined, frame: {
362
+ type: "agent_start" | "agent_end";
363
+ } | {
364
+ type: "agent_failed";
365
+ error: unknown;
366
+ }) => void;
367
+ /** Settles and emits one sanitized correlated prompt failure. */
368
+ emitPromptFailure: (correlation: {
369
+ commandId: string;
370
+ turnId: string;
371
+ }, error: unknown) => void;
346
372
  /** Records correlated lifecycle frames for replay and delivers them only to the accepted requester after acknowledgement. */
347
373
  emitPromptLifecycle: (correlation: {
348
374
  commandId: string;
@@ -352,6 +378,7 @@ interface SessionRuntime {
352
378
  sessionId: string;
353
379
  commandId?: string;
354
380
  turnId?: string;
381
+ finalText?: string;
355
382
  } | {
356
383
  type: "agent_failed";
357
384
  sessionId: string;
@@ -385,6 +412,15 @@ interface SessionRuntime {
385
412
  text?: string;
386
413
  messageRef?: string;
387
414
  };
415
+ /**
416
+ * Lean-mode deferred final answer: latest assistant text observed at `turn_end`,
417
+ * emitted once at `agent_end` so intermediate tool-turn narration does not flood
418
+ * remote clients. Cleared after flush or when replaced by a newer turn.
419
+ */
420
+ pendingSettled?: {
421
+ text: string;
422
+ messageRef?: string;
423
+ };
388
424
  /** Durable gates emitted while ownership is provisional; presented only after stable activation. */
389
425
  deferredGatePresentations: Array<() => void>;
390
426
  /** SDK control frames received during provisional ownership; replayed only after stable activation. */
@@ -392,7 +428,8 @@ interface SessionRuntime {
392
428
  /** Started tool calls awaiting a terminal activity frame, keyed by tool call id. */
393
429
  inFlightTools: Map<string, {
394
430
  toolName: string;
395
- args: unknown;
431
+ args?: unknown;
432
+ pendingPhase?: "completed" | "failed" | "cancelled";
396
433
  }>;
397
434
  /** Cancels the postmortem cleanup that emits `session_closed` on process teardown. */
398
435
  cancelPostmortemCleanup: () => void;
@@ -480,12 +517,24 @@ export declare class EphemeralTurnHost {
480
517
  * an identity for a transport that never became available is false success.
481
518
  */
482
519
  export declare function ensureConfiguredProviderDaemons(settings: Settings, cfg: NotificationConfig, ensureProviderDaemon?: (provider: "discord" | "slack", settings: Settings) => Promise<unknown>): Promise<void>;
520
+ /**
521
+ * Classify whether a session identity event must await notification endpoint startup.
522
+ * Only an interactive selector resume may defer this ancillary startup; all other
523
+ * events, including branches and unknown origins, fail closed to awaiting it.
524
+ */
525
+ export declare function shouldAwaitNotificationStartup(event: {
526
+ type: "session_switch" | "session_branch";
527
+ transition?: {
528
+ origin: string;
529
+ };
530
+ }): boolean;
483
531
  export declare function createNotificationsExtension(api: ExtensionAPI, options?: {
484
532
  settings?: Settings;
485
533
  ensureTelegramDaemon?: (input: {
486
534
  settings: Settings;
487
535
  cwd: string;
488
536
  sessionId: string;
537
+ onRegistered?: (registration: RegisterNotificationRootResult) => void;
489
538
  }) => Promise<EnsureDaemonResult>;
490
539
  ensureProviderDaemon?: (provider: "discord" | "slack", settings: Settings) => Promise<unknown>;
491
540
  /** Suppress auto-delivery for a SKC-spawned child under `sessionScope=primary`. */
@@ -494,7 +543,7 @@ export declare function createNotificationsExtension(api: ExtensionAPI, options?
494
543
  /** Whether this host mode can own the root SDK endpoint. Default: true. */
495
544
  sdkHostModeSupported?: boolean;
496
545
  onSdkRequest?: (kind: "control" | "query", connectionId: string, frame: Record<string, unknown>) => void;
497
- runEphemeralTurn?: (promptText: string, signal: AbortSignal) => Promise<{
546
+ runBtwTurn?: (question: string, signal: AbortSignal) => Promise<{
498
547
  replyText: string;
499
548
  }>;
500
549
  /** Observes settlement of optional session-branch startup after reconciliation completes. */
@@ -505,4 +554,3 @@ export declare function createNotificationsExtension(api: ExtensionAPI, options?
505
554
  readNotificationFile?: (path: string) => Promise<Buffer>;
506
555
  readNotificationDiffStat?: (cwd: string) => Promise<string | undefined>;
507
556
  }): void;
508
- export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Kind-aware invocation reconciliation (prompt | skill) with optional durable store.
3
+ * Preserves Q26 admit/first-terminal/capacity/TTL semantics; indexes and caps are per-kind.
4
+ */
5
+ import { type PromptCorrelation, type PromptReconciliationStatus, type TurnPromptReconciliation } from "./prompt-reconciliation";
6
+ import type { ReconciliationKind, ReconciliationStore } from "./reconciliation-store";
7
+ export type { ReconciliationKind };
8
+ export interface KindCorrelation extends PromptCorrelation {
9
+ kind: ReconciliationKind;
10
+ }
11
+ export interface KindAwareReconciliation {
12
+ admit(kind: ReconciliationKind, clientRef?: string): void;
13
+ releaseAdmission(kind: ReconciliationKind, clientRef?: string): void;
14
+ noteAccepted(kind: ReconciliationKind, correlation: PromptCorrelation, clientRef?: string, extra?: {
15
+ skillName?: string;
16
+ }): Promise<void>;
17
+ noteTransition(kind: ReconciliationKind, correlation: PromptCorrelation | undefined, frame: {
18
+ type: "agent_start" | "agent_end";
19
+ } | {
20
+ type: "agent_failed";
21
+ error: unknown;
22
+ }): Promise<void>;
23
+ lookup(kind: ReconciliationKind, selector: {
24
+ commandId?: string;
25
+ turnId?: string;
26
+ clientRef?: string;
27
+ }): TurnPromptReconciliation;
28
+ cleanup(): void;
29
+ activeCount(kind: ReconciliationKind): number;
30
+ /** Hydrate from durable store (call once at session host start). */
31
+ hydrateFromStore(): Promise<void>;
32
+ }
33
+ export declare function createKindAwareReconciliation(options?: {
34
+ now?: () => number;
35
+ store?: ReconciliationStore | null;
36
+ }): KindAwareReconciliation;
37
+ export type { PromptReconciliationStatus };
@@ -62,8 +62,9 @@ export declare function normalizeLifecyclePath(value: string): string | undefine
62
62
  /**
63
63
  * Map a lifecycle response/error to a user-facing Telegram message (G010).
64
64
  *
65
- * Only derives text from sessionId, mode, reason, a safe message, and candidate
66
- * {sessionId,path} — never a token or prompt. Each error reason gets tailored,
67
- * actionable copy; an "in progress" pending response is surfaced distinctly.
65
+ * Only derives text from sessionId, mode, reason, a safe message, the originating
66
+ * lifecycle verb, and candidate {sessionId,path} — never a token or prompt. Each
67
+ * error reason gets tailored, actionable copy; an "in progress" pending response
68
+ * is surfaced distinctly.
68
69
  */
69
- export declare function formatLifecycleOutcome(r: SessionLifecycleResponse): string;
70
+ export declare function formatLifecycleOutcome(r: SessionLifecycleResponse, verb?: LifecycleCommandVerb): string;
@@ -30,6 +30,7 @@ export interface ProposedTelegramIdentityPreflightInput {
30
30
  deps?: {
31
31
  fs?: TelegramDaemonFs;
32
32
  pidAlive?: (pid: number) => boolean;
33
+ pidIncarnation?: (pid: number) => string | undefined;
33
34
  };
34
35
  }
35
36
  /**
@@ -74,6 +74,40 @@ export interface NotificationStatusReport {
74
74
  export declare function buildNotificationStatusReport(settings: Settings): NotificationStatusReport;
75
75
  /** Render a status report as human-readable lines (no secrets). */
76
76
  export declare function formatNotificationStatusReport(report: NotificationStatusReport): string;
77
+ export interface NotificationEndpointView {
78
+ sessionId: string;
79
+ pid: number | undefined;
80
+ stale: boolean;
81
+ }
82
+ export type NotificationEndpointLiveness = "live" | "dead" | "unknown";
83
+ /**
84
+ * Classification used by recovery and startup takeover. A file is an endpoint
85
+ * only when it has endpoint authority fields; lifecycle/audit records are never
86
+ * candidates for endpoint cleanup.
87
+ */
88
+ export type NotificationEndpointClassification = {
89
+ kind: "endpoint";
90
+ view: NotificationEndpointView;
91
+ liveness: NotificationEndpointLiveness;
92
+ identity: NotificationEndpointFileIdentity;
93
+ } | {
94
+ kind: "non-endpoint";
95
+ } | {
96
+ kind: "unreadable";
97
+ };
98
+ /**
99
+ * Classify an endpoint using owner-proof semantics. An endpoint is only `dead`
100
+ * with positive proof: an explicit `stale` tombstone, or a recorded pid that is
101
+ * confirmed not alive. A PID-less endpoint is `unknown` (not provably dead) and
102
+ * must never be treated as dead — removing it could delete a live session's
103
+ * discovery file that simply omitted a pid.
104
+ */
105
+ export declare function notificationEndpointLiveness(view: NotificationEndpointView, pidAlive: (pid: number) => boolean): NotificationEndpointLiveness;
106
+ /**
107
+ * Read and classify one endpoint candidate. The returned identity belongs to
108
+ * exactly the bytes inspected and is required for any later deletion.
109
+ */
110
+ export declare function classifyNotificationEndpoint(fs: Pick<NotificationServiceFs, "readEndpointFile">, file: string, pidAlive: (pid: number) => boolean): Promise<NotificationEndpointClassification>;
77
111
  export type HealthLevel = "ok" | "warn" | "error";
78
112
  export interface HealthCheck {
79
113
  name: string;
@@ -47,6 +47,7 @@ export declare class NotificationOperatorRuntime {
47
47
  stopInterval(name: string): void;
48
48
  stopAllIntervals(): void;
49
49
  runExclusive(name: string, fn: () => Promise<void>): Promise<void>;
50
+ joinExclusive(name: string, timeoutMs: number): Promise<boolean>;
50
51
  sleep(ms: number, signal?: AbortSignal): Promise<void>;
51
52
  now(): number;
52
53
  }