@gajae-code/coding-agent 0.11.11 → 0.12.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 (344) hide show
  1. package/CHANGELOG.md +131 -4
  2. package/dist/types/async/job-manager.d.ts +17 -3
  3. package/dist/types/cli/read-cli.d.ts +1 -0
  4. package/dist/types/commands/deep-interview.d.ts +9 -0
  5. package/dist/types/commands/harness.d.ts +22 -0
  6. package/dist/types/commands/read.d.ts +6 -0
  7. package/dist/types/config/model-registry.d.ts +4 -0
  8. package/dist/types/config/provider-auth-health.d.ts +14 -0
  9. package/dist/types/config/provider-ranking.d.ts +59 -0
  10. package/dist/types/config/settings-schema.d.ts +83 -1
  11. package/dist/types/config/settings.d.ts +2 -0
  12. package/dist/types/exa/mcp-client.d.ts +10 -1
  13. package/dist/types/exec/bash-executor.d.ts +45 -12
  14. package/dist/types/extensibility/extensions/types.d.ts +38 -4
  15. package/dist/types/extensibility/gjc-plugins/index.d.ts +12 -2
  16. package/dist/types/extensibility/gjc-plugins/installer.d.ts +63 -7
  17. package/dist/types/extensibility/gjc-plugins/lifecycle-reconciliation.d.ts +55 -0
  18. package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +64 -0
  19. package/dist/types/extensibility/gjc-plugins/runtime-quarantine.d.ts +67 -0
  20. package/dist/types/extensibility/gjc-plugins/session-validation.d.ts +3 -1
  21. package/dist/types/extensibility/gjc-plugins/types.d.ts +124 -0
  22. package/dist/types/extensibility/shared-events.d.ts +6 -0
  23. package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +5 -12
  24. package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +17 -32
  25. package/dist/types/gjc-runtime/deep-interview-stage.d.ts +37 -0
  26. package/dist/types/gjc-runtime/deep-interview-state.d.ts +4 -135
  27. package/dist/types/gjc-runtime/gc-runtime.d.ts +1 -1
  28. package/dist/types/gjc-runtime/launch-tmux.d.ts +1 -0
  29. package/dist/types/gjc-runtime/memory-guard-owner-claims.d.ts +47 -0
  30. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +70 -1
  31. package/dist/types/gjc-runtime/state-writer.d.ts +5 -46
  32. package/dist/types/gjc-runtime/team-launch.d.ts +1 -1
  33. package/dist/types/gjc-runtime/team-runtime.d.ts +27 -1
  34. package/dist/types/gjc-runtime/team-store.d.ts +12 -0
  35. package/dist/types/gjc-runtime/team-worker-heartbeat.d.ts +43 -0
  36. package/dist/types/gjc-runtime/team-worker-memory-guard.d.ts +92 -0
  37. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +17 -0
  38. package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +8 -0
  39. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +31 -80
  40. package/dist/types/gjc-runtime/workflow-manifest.d.ts +3 -5
  41. package/dist/types/internal-urls/local-root-gc.d.ts +2 -0
  42. package/dist/types/main.d.ts +1 -1
  43. package/dist/types/memories/index.d.ts +2 -0
  44. package/dist/types/modes/acp/acp-agent.d.ts +10 -19
  45. package/dist/types/modes/components/assistant-message.d.ts +3 -1
  46. package/dist/types/modes/components/gjc-bundle-settings.d.ts +34 -0
  47. package/dist/types/modes/components/irc-sidebar.d.ts +41 -0
  48. package/dist/types/modes/components/notifications-settings-editor.d.ts +1 -0
  49. package/dist/types/modes/components/read-tool-group.d.ts +4 -4
  50. package/dist/types/modes/components/session-observer-overlay.d.ts +22 -0
  51. package/dist/types/modes/components/settings-selector.d.ts +11 -0
  52. package/dist/types/modes/components/status-line/gh.d.ts +5 -0
  53. package/dist/types/modes/components/tool-execution.d.ts +8 -0
  54. package/dist/types/modes/components/transcript-viewer-overlay.d.ts +18 -1
  55. package/dist/types/modes/controllers/event-controller.d.ts +3 -0
  56. package/dist/types/modes/interactive-mode.d.ts +2 -0
  57. package/dist/types/modes/irc-observation-ledger.d.ts +17 -1
  58. package/dist/types/modes/types.d.ts +2 -0
  59. package/dist/types/modes/utils/ui-helpers.d.ts +16 -0
  60. package/dist/types/reminders/star-reminder.d.ts +3 -13
  61. package/dist/types/runtime-mcp/manager.d.ts +1 -0
  62. package/dist/types/runtime-mcp/smithery-auth.d.ts +5 -0
  63. package/dist/types/sdk/acp/adapter.d.ts +3 -1
  64. package/dist/types/sdk/broker/lifecycle.d.ts +5 -0
  65. package/dist/types/sdk/broker/transport.d.ts +2 -0
  66. package/dist/types/sdk/bus/attachment-registry.d.ts +1 -0
  67. package/dist/types/sdk/bus/chat-daemon-control.d.ts +4 -1
  68. package/dist/types/sdk/bus/config.d.ts +6 -2
  69. package/dist/types/sdk/bus/control-drain-lease.d.ts +52 -0
  70. package/dist/types/sdk/bus/index.d.ts +44 -1
  71. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +44 -0
  72. package/dist/types/sdk/bus/lifecycle-control-runtime.d.ts +4 -0
  73. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +2 -1
  74. package/dist/types/sdk/bus/reconciliation-store.d.ts +69 -0
  75. package/dist/types/sdk/bus/rich-draft.d.ts +1 -0
  76. package/dist/types/sdk/bus/rich-render.d.ts +2 -0
  77. package/dist/types/sdk/bus/telegram-adoption-intent.d.ts +165 -0
  78. package/dist/types/sdk/bus/telegram-cli.d.ts +12 -0
  79. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +11 -4
  80. package/dist/types/sdk/bus/telegram-daemon.d.ts +25 -1
  81. package/dist/types/sdk/bus/telegram-reference.d.ts +11 -1
  82. package/dist/types/sdk/bus/threaded-render.d.ts +3 -2
  83. package/dist/types/sdk/bus/topic-registry.d.ts +11 -1
  84. package/dist/types/sdk/host/control/operations.d.ts +1 -1
  85. package/dist/types/sdk/host/host.d.ts +2 -0
  86. package/dist/types/sdk/host/query/handlers.d.ts +5 -0
  87. package/dist/types/sdk/host/query/revision-store.d.ts +2 -0
  88. package/dist/types/sdk/host/reverse-leases.d.ts +1 -1
  89. package/dist/types/sdk/prompt-status.d.ts +23 -3
  90. package/dist/types/sdk/session.d.ts +6 -0
  91. package/dist/types/session/agent-session.d.ts +82 -12
  92. package/dist/types/session/artifacts.d.ts +8 -0
  93. package/dist/types/session/blob-store.d.ts +57 -4
  94. package/dist/types/session/internal/managed-session-storage.d.ts +8 -1
  95. package/dist/types/session/memory-guard-checkpoint-participant.d.ts +69 -0
  96. package/dist/types/session/session-manager.d.ts +48 -19
  97. package/dist/types/session/session-storage.d.ts +4 -0
  98. package/dist/types/session/streaming-output.d.ts +96 -12
  99. package/dist/types/setup/credential-import.d.ts +12 -0
  100. package/dist/types/skill-state/active-state.d.ts +12 -4
  101. package/dist/types/skill-state/workflow-hud.d.ts +9 -0
  102. package/dist/types/task/executor.d.ts +3 -2
  103. package/dist/types/task/index.d.ts +3 -1
  104. package/dist/types/task/provider-retry-status.d.ts +8 -0
  105. package/dist/types/task/receipt.d.ts +7 -1
  106. package/dist/types/task/types.d.ts +23 -0
  107. package/dist/types/tools/ask-answer-registry.d.ts +2 -2
  108. package/dist/types/tools/bash-interactive.d.ts +4 -1
  109. package/dist/types/tools/bash.d.ts +3 -1
  110. package/dist/types/tools/browser/launch.d.ts +7 -0
  111. package/dist/types/tools/fetch.d.ts +17 -1
  112. package/dist/types/tools/image-gen.d.ts +4 -0
  113. package/dist/types/tools/index.d.ts +4 -0
  114. package/dist/types/tools/output-meta.d.ts +44 -3
  115. package/dist/types/tools/path-utils.d.ts +1 -0
  116. package/dist/types/tools/read-internals.d.ts +12 -0
  117. package/dist/types/tools/read.d.ts +45 -7
  118. package/dist/types/tools/resource-gc.d.ts +4 -0
  119. package/dist/types/tools/review.d.ts +5 -7
  120. package/dist/types/tools/subagent.d.ts +2 -0
  121. package/dist/types/tools/tool-result.d.ts +7 -1
  122. package/dist/types/utils/gh.d.ts +13 -0
  123. package/dist/types/utils/image-resize.d.ts +1 -0
  124. package/dist/types/web/search/providers/kimi.d.ts +2 -0
  125. package/dist/types/web/search/providers/searxng.d.ts +7 -0
  126. package/dist/types/web/search/providers/xai.d.ts +2 -0
  127. package/package.json +11 -13
  128. package/scripts/acp-conformance-agent.ts +218 -0
  129. package/scripts/benchmark-sticky-viewport-pr1.ts +239 -0
  130. package/scripts/capture-gjc-bundle-settings.ts +306 -0
  131. package/scripts/capture-sticky-viewport-showcase.ts +292 -0
  132. package/scripts/generate-sdk-operation-inventory.ts +5 -0
  133. package/scripts/resident-memory-bench.ts +1341 -0
  134. package/scripts/run-acp-conformance.ts +285 -0
  135. package/scripts/verify-gjc-sdk-canonicalization.ts +122 -18
  136. package/scripts/verify-sticky-viewport-showcase.ts +611 -0
  137. package/src/async/job-manager.ts +78 -20
  138. package/src/capability/index.ts +8 -0
  139. package/src/cli/fast-help.ts +1 -1
  140. package/src/cli/plugin-cli.ts +176 -18
  141. package/src/cli/read-cli.ts +2 -1
  142. package/src/cli.ts +1 -0
  143. package/src/commands/deep-interview.ts +29 -9
  144. package/src/commands/harness.ts +35 -12
  145. package/src/commands/read.ts +11 -2
  146. package/src/commands/team.ts +20 -2
  147. package/src/config/file-lock.ts +11 -2
  148. package/src/config/model-registry.ts +21 -2
  149. package/src/config/provider-auth-health.ts +42 -0
  150. package/src/config/provider-ranking.ts +119 -0
  151. package/src/config/settings-schema.ts +74 -1
  152. package/src/config/settings.ts +246 -108
  153. package/src/coordinator-mcp/question-gate-codec.ts +1 -1
  154. package/src/coordinator-mcp/server.ts +5 -12
  155. package/src/defaults/gjc/skills/deep-interview/SKILL.md +230 -82
  156. package/src/defaults/gjc/skills/ralplan/SKILL.md +77 -41
  157. package/src/defaults/gjc/skills/team/SKILL.md +3 -1
  158. package/src/defaults/gjc/skills/ultragoal/SKILL.md +62 -39
  159. package/src/defaults/gjc/skills/ultragoal/validation-batch-contracts.md +12 -0
  160. package/src/defaults/gjc-defaults.ts +4 -4
  161. package/src/eval/py/executor.ts +7 -2
  162. package/src/exa/mcp-client.ts +12 -3
  163. package/src/exec/bash-executor.ts +144 -27
  164. package/src/extensibility/extensions/runner.ts +15 -0
  165. package/src/extensibility/extensions/types.ts +46 -5
  166. package/src/extensibility/gjc-plugins/constrained-hooks.ts +8 -2
  167. package/src/extensibility/gjc-plugins/index.ts +19 -2
  168. package/src/extensibility/gjc-plugins/installer.ts +189 -50
  169. package/src/extensibility/gjc-plugins/lifecycle-reconciliation.ts +199 -0
  170. package/src/extensibility/gjc-plugins/lifecycle.ts +626 -0
  171. package/src/extensibility/gjc-plugins/observability.ts +3 -3
  172. package/src/extensibility/gjc-plugins/prompt-appendix.ts +5 -1
  173. package/src/extensibility/gjc-plugins/runtime-adapters.ts +12 -2
  174. package/src/extensibility/gjc-plugins/runtime-quarantine.ts +121 -0
  175. package/src/extensibility/gjc-plugins/schema.ts +84 -12
  176. package/src/extensibility/gjc-plugins/session-validation.ts +9 -3
  177. package/src/extensibility/gjc-plugins/types.ts +141 -0
  178. package/src/extensibility/gjc-plugins/validation.ts +9 -0
  179. package/src/extensibility/shared-events.ts +5 -0
  180. package/src/gjc-runtime/deep-interview-ambiguity.ts +47 -82
  181. package/src/gjc-runtime/deep-interview-recorder.ts +227 -310
  182. package/src/gjc-runtime/deep-interview-runtime.ts +109 -270
  183. package/src/gjc-runtime/deep-interview-stage.ts +1016 -0
  184. package/src/gjc-runtime/deep-interview-state.ts +12 -943
  185. package/src/gjc-runtime/gc-render.ts +1 -0
  186. package/src/gjc-runtime/gc-runtime.ts +11 -1
  187. package/src/gjc-runtime/launch-tmux.ts +25 -6
  188. package/src/gjc-runtime/managed-owner-admission.ts +1 -1
  189. package/src/gjc-runtime/memory-guard-owner-claims.ts +389 -0
  190. package/src/gjc-runtime/ralplan-runtime.ts +1149 -98
  191. package/src/gjc-runtime/state-runtime.ts +2 -1
  192. package/src/gjc-runtime/state-writer.ts +70 -222
  193. package/src/gjc-runtime/team-launch.ts +42 -5
  194. package/src/gjc-runtime/team-runtime.ts +1085 -40
  195. package/src/gjc-runtime/team-store.ts +32 -0
  196. package/src/gjc-runtime/team-worker-heartbeat.ts +149 -0
  197. package/src/gjc-runtime/team-worker-memory-guard.ts +363 -0
  198. package/src/gjc-runtime/team-workers.ts +1 -0
  199. package/src/gjc-runtime/tmux-owner-isolation.ts +28 -0
  200. package/src/gjc-runtime/tmux-sessions.ts +58 -13
  201. package/src/gjc-runtime/ultragoal-receipt-freshness.ts +20 -0
  202. package/src/gjc-runtime/ultragoal-runtime.ts +414 -618
  203. package/src/gjc-runtime/workflow-manifest.generated.json +105 -449
  204. package/src/gjc-runtime/workflow-manifest.ts +38 -247
  205. package/src/hooks/native-skill-hook.ts +17 -4
  206. package/src/hooks/skill-state.ts +1 -23
  207. package/src/internal-urls/docs-index.generated.ts +21 -22
  208. package/src/internal-urls/local-root-gc.ts +127 -0
  209. package/src/main.ts +9 -5
  210. package/src/memories/index.ts +10 -0
  211. package/src/modes/DESIGN.md +98 -0
  212. package/src/modes/acp/acp-agent.ts +339 -191
  213. package/src/modes/acp/acp-event-mapper.ts +14 -7
  214. package/src/modes/acp/acp-mode.ts +39 -3
  215. package/src/modes/components/assistant-message.ts +123 -22
  216. package/src/modes/components/gjc-bundle-settings.ts +508 -0
  217. package/src/modes/components/irc-sidebar.ts +176 -62
  218. package/src/modes/components/model-selector.ts +61 -4
  219. package/src/modes/components/notifications-settings-editor.ts +12 -1
  220. package/src/modes/components/oauth-selector.ts +96 -28
  221. package/src/modes/components/read-tool-group.ts +82 -14
  222. package/src/modes/components/session-observer-overlay.ts +457 -83
  223. package/src/modes/components/settings-selector.ts +116 -23
  224. package/src/modes/components/status-line/gh.ts +16 -0
  225. package/src/modes/components/tool-execution.ts +138 -27
  226. package/src/modes/components/tool-status-header.ts +3 -14
  227. package/src/modes/components/transcript-viewer-overlay.ts +99 -24
  228. package/src/modes/controllers/command-controller.ts +4 -0
  229. package/src/modes/controllers/event-controller.ts +109 -27
  230. package/src/modes/controllers/extension-ui-controller.ts +26 -2
  231. package/src/modes/controllers/input-controller.ts +18 -3
  232. package/src/modes/controllers/selector-controller.ts +127 -36
  233. package/src/modes/interactive-mode.ts +62 -3
  234. package/src/modes/irc-observation-ledger.ts +71 -15
  235. package/src/modes/runtime-init.ts +22 -2
  236. package/src/modes/types.ts +2 -0
  237. package/src/modes/utils/ui-helpers.ts +94 -1
  238. package/src/prompts/agent-fragments/ralplan-persistence.md +4 -3
  239. package/src/prompts/agents/architect.md +9 -1
  240. package/src/prompts/agents/critic.md +9 -0
  241. package/src/prompts/system/eager-todo.md +8 -4
  242. package/src/prompts/system/system-prompt.md +11 -5
  243. package/src/prompts/tools/bash.md +5 -5
  244. package/src/prompts/tools/read.md +4 -2
  245. package/src/prompts/tools/search-tool-bm25.md +5 -0
  246. package/src/prompts/tools/task.md +1 -1
  247. package/src/reminders/star-reminder.ts +4 -42
  248. package/src/runtime-mcp/manager.ts +19 -4
  249. package/src/runtime-mcp/smithery-auth.ts +17 -2
  250. package/src/runtime-mcp/smithery-connect.ts +11 -1
  251. package/src/sdk/acp/adapter.ts +22 -6
  252. package/src/sdk/broker/lifecycle.ts +25 -6
  253. package/src/sdk/broker/transport.ts +35 -3
  254. package/src/sdk/bus/attachment-registry.ts +5 -1
  255. package/src/sdk/bus/chat-daemon-cli.ts +4 -39
  256. package/src/sdk/bus/chat-daemon-control.ts +6 -3
  257. package/src/sdk/bus/config.ts +18 -2
  258. package/src/sdk/bus/control-drain-lease.ts +104 -0
  259. package/src/sdk/bus/index.ts +984 -146
  260. package/src/sdk/bus/kind-aware-reconciliation.ts +317 -0
  261. package/src/sdk/bus/lifecycle-commands.ts +4 -1
  262. package/src/sdk/bus/lifecycle-control-runtime.ts +403 -88
  263. package/src/sdk/bus/prompt-reconciliation.ts +2 -1
  264. package/src/sdk/bus/reconciliation-store.ts +303 -0
  265. package/src/sdk/bus/rich-draft.ts +1 -1
  266. package/src/sdk/bus/rich-render.ts +2 -2
  267. package/src/sdk/bus/telegram-adoption-intent.ts +574 -0
  268. package/src/sdk/bus/telegram-cli.ts +33 -8
  269. package/src/sdk/bus/telegram-daemon-cli.ts +1 -0
  270. package/src/sdk/bus/telegram-daemon-contract.ts +11 -4
  271. package/src/sdk/bus/telegram-daemon.ts +916 -23
  272. package/src/sdk/bus/telegram-reference.ts +40 -3
  273. package/src/sdk/bus/threaded-render.ts +48 -3
  274. package/src/sdk/bus/topic-registry.ts +20 -0
  275. package/src/sdk/host/control/dispatch.ts +5 -1
  276. package/src/sdk/host/control/operations.ts +1 -1
  277. package/src/sdk/host/host.ts +23 -1
  278. package/src/sdk/host/query/handlers.ts +55 -0
  279. package/src/sdk/host/query/revision-store.ts +36 -2
  280. package/src/sdk/host/reverse-leases.ts +44 -7
  281. package/src/sdk/mcp/server.ts +46 -18
  282. package/src/sdk/prompt-status.ts +16 -3
  283. package/src/sdk/protocol/operation-inventory.generated.json +51 -0
  284. package/src/sdk/protocol/operation-registry.ts +7 -2
  285. package/src/sdk/session.ts +101 -10
  286. package/src/session/agent-session.ts +1286 -220
  287. package/src/session/artifacts.ts +22 -0
  288. package/src/session/auth-broker-config.ts +10 -3
  289. package/src/session/blob-store.ts +915 -24
  290. package/src/session/internal/managed-session-scope.ts +44 -6
  291. package/src/session/internal/managed-session-storage.ts +48 -6
  292. package/src/session/memory-guard-checkpoint-participant.ts +131 -0
  293. package/src/session/session-manager.ts +2364 -438
  294. package/src/session/session-storage.ts +9 -1
  295. package/src/session/streaming-output.ts +500 -111
  296. package/src/setup/credential-import.ts +75 -13
  297. package/src/setup/provider-onboarding.ts +19 -4
  298. package/src/skill-state/active-state.ts +32 -10
  299. package/src/skill-state/workflow-hud.ts +42 -2
  300. package/src/skill-state/workflow-mutation-guard.ts +560 -8
  301. package/src/task/executor.ts +122 -39
  302. package/src/task/index.ts +23 -14
  303. package/src/task/provider-retry-status.ts +16 -0
  304. package/src/task/receipt.ts +23 -7
  305. package/src/task/render.ts +6 -2
  306. package/src/task/types.ts +108 -0
  307. package/src/tools/ask-answer-registry.ts +12 -6
  308. package/src/tools/ask.ts +169 -118
  309. package/src/tools/ast-edit.ts +1 -0
  310. package/src/tools/ast-grep.ts +1 -0
  311. package/src/tools/bash-interactive.ts +8 -3
  312. package/src/tools/bash.ts +503 -60
  313. package/src/tools/browser/launch.ts +41 -6
  314. package/src/tools/fetch.ts +114 -23
  315. package/src/tools/find.ts +1 -0
  316. package/src/tools/image-gen.ts +29 -5
  317. package/src/tools/index.ts +4 -0
  318. package/src/tools/output-meta.ts +281 -20
  319. package/src/tools/path-utils.ts +8 -3
  320. package/src/tools/read-internals.ts +44 -0
  321. package/src/tools/read.ts +1560 -310
  322. package/src/tools/resource-gc.ts +182 -18
  323. package/src/tools/review.ts +5 -7
  324. package/src/tools/search.ts +1 -0
  325. package/src/tools/subagent-render.ts +6 -2
  326. package/src/tools/subagent.ts +6 -0
  327. package/src/tools/telegram-send.ts +6 -3
  328. package/src/tools/tool-result.ts +14 -1
  329. package/src/utils/gh.ts +39 -0
  330. package/src/utils/image-resize.ts +3 -0
  331. package/src/web/search/providers/anthropic.ts +4 -4
  332. package/src/web/search/providers/codex.ts +1 -1
  333. package/src/web/search/providers/kimi.ts +15 -5
  334. package/src/web/search/providers/searxng.ts +47 -4
  335. package/src/web/search/providers/xai.ts +7 -2
  336. package/dist/types/gjc-runtime/deep-interview-draft.d.ts +0 -8
  337. package/dist/types/gjc-runtime/deep-interview-payload.d.ts +0 -41
  338. package/dist/types/gjc-runtime/deep-interview-repair.d.ts +0 -17
  339. package/dist/types/gjc-runtime/ultragoal-pipeline.d.ts +0 -23
  340. package/src/defaults/gjc/skills/ultragoal/pipeline-validation-contracts.md +0 -30
  341. package/src/gjc-runtime/deep-interview-draft.ts +0 -843
  342. package/src/gjc-runtime/deep-interview-payload.ts +0 -262
  343. package/src/gjc-runtime/deep-interview-repair.ts +0 -1674
  344. package/src/gjc-runtime/ultragoal-pipeline.ts +0 -306
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * Modes use this class and add their own I/O layer on top.
14
14
  */
15
- import { type Agent, type AgentContext, type AgentEvent, type AgentLoopConfig, type AgentMessage, type AgentState, type AgentTool, type MidRunMaintenanceOutcome, type StablePrefixSnapshot, ThinkingLevel } from "@gajae-code/agent-core";
15
+ import { type Agent, type AgentContext, type AgentEvent, type AgentLoopConfig, type AgentMessage, type AgentState, type AgentTool, type MidRunMaintenanceOutcome, type RunSettlementProof, type StablePrefixSnapshot, ThinkingLevel } from "@gajae-code/agent-core";
16
16
  import { type CompactionResult, type EmergencyCompactionSample } from "@gajae-code/agent-core/compaction";
17
17
  import type { AssistantMessage, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolCall, ToolChoice, Usage, UsageReport } from "@gajae-code/ai";
18
18
  import { type BtwTextExchange } from "./btw-contract";
@@ -75,14 +75,18 @@ import { type PromptTemplate } from "../config/prompt-templates";
75
75
  import type { Settings, SkillsSettings } from "../config/settings";
76
76
  import { RawSseDebugBuffer } from "../debug/raw-sse-buffer";
77
77
  import { type PythonResult } from "../eval/py/executor";
78
- import { type BashResult } from "../exec/bash-executor";
78
+ import { type BashArtifactSaveResult, type BashResult } from "../exec/bash-executor";
79
79
  import type { TtsrManager } from "../export/ttsr";
80
80
  import type { LoadedCustomCommand } from "../extensibility/custom-commands";
81
81
  import type { CustomTool } from "../extensibility/custom-tools/types";
82
82
  import type { ExtensionRunner } from "../extensibility/extensions";
83
83
  import type { CompactOptions, ContextUsage, ExtensionTranscriptEntry } from "../extensibility/extensions/types";
84
+ import type { GjcRuntimeSnapshotProvider } from "../extensibility/gjc-plugins/runtime-quarantine";
85
+ import type { SessionSwitchEvent } from "../extensibility/shared-events";
84
86
  import { type Skill, type SkillWarning } from "../extensibility/skills";
85
87
  import { type FileSlashCommand } from "../extensibility/slash-commands";
88
+ import { type MemoryGuardClaimsLease } from "../gjc-runtime/memory-guard-owner-claims";
89
+ import { GjcTeamWorkerHeartbeatReporter } from "../gjc-runtime/team-worker-heartbeat";
86
90
  import { GoalRuntime } from "../goals/runtime";
87
91
  import type { Goal, GoalModeState } from "../goals/state";
88
92
  import type { HindsightSessionState } from "../hindsight/state";
@@ -101,6 +105,7 @@ import { type DefaultModelSelectionResult } from "./default-model-selection";
101
105
  export { DefaultModelSelectionRecoveryError } from "./default-model-selection";
102
106
  import type { ClientBridge, ClientBridgePermissionOption, ClientBridgePermissionOutcome, ClientBridgePermissionToolCall } from "./client-bridge";
103
107
  import { type ContributionPrepOptions, type ContributionPrepResult } from "./contribution-prep";
108
+ import type { MemoryGuardRestoreResult } from "./memory-guard-checkpoint-participant";
104
109
  import { type CustomMessage } from "./messages";
105
110
  import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, PreparedNewSession, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionContext, SessionManager, SessionManagerCloseOutcome } from "./session-manager";
106
111
  import { ToolChoiceQueue } from "./tool-choice-queue";
@@ -205,6 +210,11 @@ export interface AgentSessionConfig {
205
210
  workerIntegrationRequest?: (signal: AbortSignal) => Promise<void>;
206
211
  /** Bound terminal worker-integration settlement for embedded hosts and deterministic lifecycle tests. */
207
212
  workerIntegrationTimeoutMs?: number;
213
+ /**
214
+ * Override the runtime-owned `gjc team` worker heartbeat reporter. Defaults to a
215
+ * reporter derived from the team worker environment, or none outside a worker pane.
216
+ */
217
+ teamWorkerHeartbeatReporter?: GjcTeamWorkerHeartbeatReporter;
208
218
  /** Loaded skills (already discovered by SDK) */
209
219
  skills?: Skill[];
210
220
  /** Skill loading warnings (already captured by SDK) */
@@ -314,6 +324,24 @@ export interface AgentSessionConfig {
314
324
  /** Optional provider-facing cache identity, distinct from logical session identity. */
315
325
  providerCacheSessionId?: string;
316
326
  }
327
+ export interface AgentSessionMemoryGuardRestoreInput extends Omit<AgentSessionConfig, "sessionManager" | "recoveryHydrationContext"> {
328
+ staged: Extract<MemoryGuardRestoreResult, {
329
+ kind: "staged";
330
+ }>;
331
+ claimsLease: MemoryGuardClaimsLease;
332
+ claimsStateDir: string;
333
+ }
334
+ export interface AgentMemoryGuardPromotionFence extends RecoveryHydrationPromotionFence {
335
+ readonly claimsLease: MemoryGuardClaimsLease;
336
+ }
337
+ export type AgentMemoryGuardRestoreResult = {
338
+ kind: "staged";
339
+ session: AgentSession;
340
+ promotionFence: AgentMemoryGuardPromotionFence;
341
+ } | {
342
+ kind: "blocked";
343
+ reason: "transcript-mismatch" | "hydration-context-mismatch" | "claim-mismatch" | "agent-messages-mismatch";
344
+ };
317
345
  type MidRunMaintenanceLifecycle = Parameters<NonNullable<AgentLoopConfig["maintainContext"]>>[1];
318
346
  /** Options for AgentSession.prompt() */
319
347
  export interface PromptOptions {
@@ -336,8 +364,21 @@ export interface PromptOptions {
336
364
  /**
337
365
  * Invoked after all prompt preflight checks pass and immediately before agent execution begins.
338
366
  * Cancellation before this callback rejects the prompt.
367
+ * Prefer `onPreflightAcceptCommit` for async durable acceptance (#3031/#3032).
339
368
  */
340
369
  onPreflightAccepted?: () => void;
370
+ /**
371
+ * Awaitable durable-accept fence. Called after preflight and before queue mutation
372
+ * or `#promptAgentWithIdleRetry`. SDK bus installs a closure that fsyncs acceptance.
373
+ */
374
+ onPreflightAcceptCommit?: () => void | Promise<void>;
375
+ /** Skill-only: prepared metadata before the durable fence (path/lineCount/cleanedArgs). */
376
+ onSkillPrepared?: (meta: {
377
+ name: string;
378
+ path: string;
379
+ lineCount?: number;
380
+ cleanedArgs?: string;
381
+ }) => void;
341
382
  }
342
383
  /** Result from a handoff operation. */
343
384
  export interface HandoffResult {
@@ -432,6 +473,11 @@ interface EphemeralTurnResult {
432
473
  replyText: string;
433
474
  assistantMessage: AssistantMessage;
434
475
  }
476
+ export interface AgentBashArtifactStore {
477
+ saveArtifact(content: string, toolType: string): Promise<string | undefined>;
478
+ getArtifactPath(id: string): Promise<string | null>;
479
+ }
480
+ export declare function saveAgentBashOriginalArtifact(store: AgentBashArtifactStore, originalText: string): Promise<BashArtifactSaveResult>;
435
481
  type IrcRosterClaim = {
436
482
  token: symbol;
437
483
  signature: string;
@@ -752,13 +798,16 @@ export declare class AgentSession {
752
798
  * to avoid racing against the delivery turn.
753
799
  */
754
800
  get hasPostPromptWork(): boolean;
801
+ /** Stable resource ownership identifier for the active prompt run. */
802
+ get activePromptHandle(): string | undefined;
755
803
  /** All messages including custom types like BashExecutionMessage */
756
804
  get messages(): AgentMessage[];
757
805
  get transcriptPromptGeneration(): number;
806
+ static restoreFromMemoryGuardCheckpoint(input: AgentSessionMemoryGuardRestoreInput): Promise<AgentMemoryGuardRestoreResult>;
758
807
  /** The immutable recovery authority, present only before external ownership promotion. */
759
808
  get recoveryHydrationContext(): RecoveryHydrationContext | undefined;
760
809
  /** Enables normal session mutations after the owner has published its durable fence and writer lease. */
761
- promoteRecoveryHydrationAfterOwnershipReadyFence(fence: RecoveryHydrationPromotionFence): Promise<void>;
810
+ promoteRecoveryHydrationAfterOwnershipReadyFence(fence: AgentMemoryGuardPromotionFence): Promise<void>;
762
811
  /** Main startup calls this exactly once, after a strict open returned `kind: "opened"`. */
763
812
  continuePersistedHistory(): Promise<void>;
764
813
  buildDisplaySessionContext(): SessionContext;
@@ -787,7 +836,7 @@ export declare class AgentSession {
787
836
  /** Live SDK configuration values exposed through the session query surface. */
788
837
  getSdkConfigItems(): Record<string, string>;
789
838
  setPlanModeState(state: PlanModeState | undefined): void;
790
- invokeSkill(name: string, args?: string, options?: Pick<PromptOptions, "onPreflightAccepted">): Promise<{
839
+ invokeSkill(name: string, args?: string, options?: Pick<PromptOptions, "onPreflightAccepted" | "onPreflightAcceptCommit" | "onSkillPrepared">): Promise<{
791
840
  name: string;
792
841
  path: string;
793
842
  args?: string;
@@ -842,7 +891,7 @@ export declare class AgentSession {
842
891
  * @throws Error if no model selected or no API key available (when not streaming)
843
892
  */
844
893
  prompt(text: string, options?: PromptOptions): Promise<void>;
845
- promptCustomMessage<T = unknown>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details" | "attribution">, options?: Pick<PromptOptions, "streamingBehavior" | "toolChoice" | "followUpQueuePolicy" | "onPreflightAccepted">): Promise<void>;
894
+ promptCustomMessage<T = unknown>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details" | "attribution">, options?: Pick<PromptOptions, "streamingBehavior" | "toolChoice" | "followUpQueuePolicy" | "onPreflightAccepted" | "onPreflightAcceptCommit">): Promise<void>;
846
895
  /**
847
896
  * Queue a steering message to interrupt the agent mid-run.
848
897
  */
@@ -882,6 +931,7 @@ export declare class AgentSession {
882
931
  sendUserMessage(content: string | (TextContent | ImageContent)[], options?: {
883
932
  deliverAs?: "steer" | "followUp";
884
933
  onPreflightAccepted?: () => void;
934
+ onPreflightAcceptCommit?: () => void | Promise<void>;
885
935
  }): Promise<void>;
886
936
  /**
887
937
  * Clear queued messages and return them.
@@ -944,6 +994,12 @@ export declare class AgentSession {
944
994
  cause?: "user_interrupt" | "new_session" | "session_switch" | "compaction" | "handoff" | "tool_abort" | "internal";
945
995
  silent?: boolean;
946
996
  }): Promise<void>;
997
+ /**
998
+ * Abort a specific active prompt and prove whether its tracked resources settled.
999
+ */
1000
+ abortPromptAndWait(handle: string, options: {
1001
+ graceMs: number;
1002
+ }): Promise<RunSettlementProof>;
947
1003
  /** Atomically interrupt the active run and make text the next prompt. */
948
1004
  cancelAndSubmit(text: string, options?: {
949
1005
  queuedEntryId?: string;
@@ -1012,6 +1068,13 @@ export declare class AgentSession {
1012
1068
  * instead of promoting a transient runtime model to the resume default.
1013
1069
  */
1014
1070
  getSessionDefaultModelSelector(): string | undefined;
1071
+ /**
1072
+ * Resolve the model that `modelRoles.default` currently points to, independent
1073
+ * of whatever model this session's log last recorded. Used by the TUI resume
1074
+ * flow's `session.resumeModelBehavior: "ask"` prompt to offer the currently
1075
+ * configured default as an alternative to the session's saved model.
1076
+ */
1077
+ resolveConfiguredDefaultModel(): Model | undefined;
1015
1078
  /**
1016
1079
  * Re-assert the session resume default ("provider/id") in the session log
1017
1080
  * WITHOUT touching the live runtime model. Appends a `model_change` with
@@ -1065,20 +1128,16 @@ export declare class AgentSession {
1065
1128
  * Get all available models with valid API keys.
1066
1129
  */
1067
1130
  getAvailableModels(): Model[];
1068
- /**
1069
- * Set thinking level.
1070
- * Saves the effective metadata-clamped level to the session, and to settings when requested.
1071
- */
1072
1131
  setThinkingLevel(level: ThinkingLevel | undefined, persist?: boolean): void;
1073
1132
  /**
1074
- * Set thinking level from a control surface. Global changes are durable or rolled back.
1133
+ * Set thinking level from a control surface. Global changes commit before affecting live state.
1075
1134
  */
1076
1135
  setThinkingLevelForControl(level: ThinkingLevel, persist: boolean): Promise<void>;
1077
1136
  getThinkingScopeForControl(): "session" | "global config";
1078
1137
  getThinkingVisibility(): "visible" | "hidden";
1079
1138
  setThinkingVisibility(visibility: "visible" | "hidden", persist?: boolean): void;
1080
1139
  /**
1081
- * Set thinking visibility from a control surface. Global changes are durable or rolled back.
1140
+ * Set thinking visibility from a control surface. Global changes commit before affecting live state.
1082
1141
  */
1083
1142
  setThinkingVisibilityForControl(visibility: "visible" | "hidden", persist: boolean): Promise<void>;
1084
1143
  /**
@@ -1125,6 +1184,15 @@ export declare class AgentSession {
1125
1184
  * Get available thinking levels for current model.
1126
1185
  */
1127
1186
  getAvailableThinkingLevels(): ReadonlyArray<Effort>;
1187
+ /**
1188
+ * Runtime evidence published for the current GJC bundle activation
1189
+ * generation, set once by `createAgentSession` after every producer has run.
1190
+ * Undefined until that publication happens, so consumers report runtime
1191
+ * status as unavailable rather than falsely clear.
1192
+ */
1193
+ gjcRuntimeSnapshot?: GjcRuntimeSnapshotProvider;
1194
+ /** Activation generation a published snapshot must match to be merged. */
1195
+ gjcActivationGeneration?: number;
1128
1196
  /**
1129
1197
  * Set steering mode.
1130
1198
  * Saves to settings.
@@ -1316,7 +1384,9 @@ export declare class AgentSession {
1316
1384
  * Listeners are preserved and will continue receiving events.
1317
1385
  * @returns true if switch completed, false if cancelled by hook
1318
1386
  */
1319
- switchSession(sessionPath: string): Promise<boolean>;
1387
+ switchSession(sessionPath: string, options?: {
1388
+ transition?: SessionSwitchEvent["transition"];
1389
+ }): Promise<boolean>;
1320
1390
  /**
1321
1391
  * Create a branch from a specific entry.
1322
1392
  * Emits before_branch/branch session events to hooks.
@@ -45,6 +45,14 @@ export declare class ArtifactManager {
45
45
  replaceNamedBytes(filename: string, bytes: Uint8Array): Promise<void>;
46
46
  publishManagedOutputGeneration(selectorFilename: string, outputFilenamePrefix: string, outputBytes: Uint8Array, metadataBytes: Uint8Array): Promise<void>;
47
47
  publishNamedNoReplace(filename: string, bytes: Uint8Array): Promise<void>;
48
+ /**
49
+ * Best-effort removal of a previously published named artifact. Used to roll
50
+ * back staged publications when a transactional operation (e.g. gated
51
+ * maintenance pruning) is rejected after publication succeeded. Returns false
52
+ * when the artifact could not be removed so callers can log the failure
53
+ * instead of silently treating the rollback as complete.
54
+ */
55
+ removeNamedBestEffort(filename: string): Promise<boolean>;
48
56
  /**
49
57
  * Atomically allocate next artifact ID.
50
58
  * IDs are sequential within the session.
@@ -1,3 +1,9 @@
1
+ declare const TAKE_BLOB_BUFFER_OWNERSHIP: unique symbol;
2
+ /** Limits for a single best-effort resident-cache garbage-collection pass. */
3
+ export interface ResidentCacheGcSweepOptions {
4
+ readonly maxDirectories?: number;
5
+ readonly maxDurationMs?: number;
6
+ }
1
7
  export interface BlobPutResult {
2
8
  hash: string;
3
9
  path: string;
@@ -11,6 +17,28 @@ export declare class BlobCorruptError extends Error {
11
17
  readonly path: string;
12
18
  constructor(hash: string, path: string);
13
19
  }
20
+ /**
21
+ * A resident-cache path or blob failed the owner-only verification contract.
22
+ * SessionManager catches this error to demote the entire resident store to
23
+ * memory before retrying the triggering write.
24
+ */
25
+ export declare class ResidentCacheTrustError extends Error {
26
+ readonly reason: string;
27
+ readonly path: string;
28
+ constructor(reason: string, path: string, options?: ErrorOptions);
29
+ }
30
+ /**
31
+ * Best-effort cleanup of abandoned resident-cache instances. The root is
32
+ * re-verified before scanning, work is bounded, and all failures fail closed.
33
+ */
34
+ export declare function sweepResidentCacheRoot(root: string, options?: ResidentCacheGcSweepOptions): Promise<void>;
35
+ /**
36
+ * Create a private resident-cache instance directory beneath a trusted profile
37
+ * root. The cache-owned root and nonce instance are both verified owner-only
38
+ * directories; callers must use {@link EphemeralBlobStore.adoptVerifiedDir}
39
+ * rather than the destructive EphemeralBlobStore constructor.
40
+ */
41
+ export declare function openVerifiedResidentCacheInstanceDir(root: string): string;
14
42
  /**
15
43
  * Content-addressed blob store for externalizing large binary data (images) from session JSONL files.
16
44
  *
@@ -31,7 +59,13 @@ export declare class BlobStore {
31
59
  * cannot afford the microtask hops of the async version (e.g. OOM-safe session writes).
32
60
  * Returns once the bytes are in the kernel page cache.
33
61
  */
34
- putSync(data: Buffer): BlobPutResult;
62
+ putSync(data: Buffer, _ownership?: typeof TAKE_BLOB_BUFFER_OWNERSHIP): BlobPutResult;
63
+ /**
64
+ * Store a buffer that the caller will not mutate after this call returns.
65
+ * Resident-cache implementations may retain that private buffer without an
66
+ * additional defensive copy.
67
+ */
68
+ putOwnedSync(data: Buffer): BlobPutResult;
35
69
  /**
36
70
  * Durably install binary data as an immutable content-addressed blob.
37
71
  *
@@ -51,19 +85,37 @@ export declare class BlobStore {
51
85
  /** Check if a blob exists. */
52
86
  has(hash: string): Promise<boolean>;
53
87
  }
88
+ interface EphemeralBlobStoreOptions {
89
+ readonly adoptVerifiedDir?: boolean;
90
+ }
91
+ /** Resident-cache directories still tracked by this process. Test seam. */
92
+ export declare function trackedResidentCacheDirsForTest(): string[];
54
93
  export declare class EphemeralBlobStore extends BlobStore {
55
94
  #private;
56
- constructor(dir: string);
57
- putSync(data: Buffer): BlobPutResult;
95
+ constructor(dir: string, options?: EphemeralBlobStoreOptions);
96
+ /**
97
+ * Adopt a directory returned by {@link openVerifiedResidentCacheInstanceDir}
98
+ * without the ordinary constructor's destructive remove-and-recreate path.
99
+ */
100
+ static adoptVerifiedDir(dir: string): EphemeralBlobStore;
101
+ put(data: Buffer): Promise<BlobPutResult>;
102
+ putSync(data: Buffer, ownership?: typeof TAKE_BLOB_BUFFER_OWNERSHIP): BlobPutResult;
58
103
  putImmutableSync(data: Buffer): CheckedBlobPutResult;
104
+ get(hash: string): Promise<Buffer | null>;
59
105
  getSync(hash: string): Buffer | null;
106
+ /** Return a trusted in-memory copy without reopening an invalidated cache path. */
107
+ getBufferedSync(hash: string): Buffer | null;
60
108
  getCheckedSync(hash: string): Buffer | null;
61
109
  clear(): void;
62
110
  dispose(): void;
63
111
  }
112
+ export interface MemoryBlobStoreOptions {
113
+ /** A canonical store owns every reference in its session's resident entries. */
114
+ readonly ownership?: "cache" | "canonical";
115
+ }
64
116
  export declare class MemoryBlobStore extends BlobStore {
65
117
  #private;
66
- constructor();
118
+ constructor(options?: MemoryBlobStoreOptions);
67
119
  put(data: Buffer): Promise<BlobPutResult>;
68
120
  putSync(data: Buffer): BlobPutResult;
69
121
  putImmutableSync(data: Buffer): CheckedBlobPutResult;
@@ -158,3 +210,4 @@ export declare function resolveResidentImageDataSync(blobStore: BlobStore, data:
158
210
  sessionId?: string;
159
211
  sessionFile?: string;
160
212
  }): string;
213
+ export {};
@@ -51,19 +51,26 @@ export declare function retainManagedDirectoryAuthority(root: ManagedDirectoryRo
51
51
  ino: bigint;
52
52
  }): RecoveryFsRoot | undefined;
53
53
  export declare function assertManagedDirectoryRoot(root: ManagedDirectoryRoot): void;
54
+ export declare function managedSecurityFailureClassification(error: unknown): string | undefined;
54
55
  /** Internal retained-root capability for one managed descendant subtree. */
55
56
  export declare class ManagedSessionDescendantStore {
56
57
  #private;
57
58
  constructor(root: ManagedDirectoryRoot, baseDir: string, retained?: {
58
59
  authority: RecoveryFsRoot;
59
60
  authorityBaseDir: string;
60
- }, policy?: ManagedSessionSecurityPolicy);
61
+ }, policy?: ManagedSessionSecurityPolicy, profileAgentDir?: string);
61
62
  get dir(): string;
62
63
  get rootAuthority(): ManagedDirectoryRoot;
63
64
  get subtreeRootAuthority(): ManagedDirectoryRoot;
64
65
  get securityPolicy(): ManagedSessionSecurityPolicy;
66
+ get profileAgentDir(): string;
65
67
  deriveSubtree(relativePath: string): ManagedSessionDescendantStore;
66
68
  retainAuthority(): RecoveryFsRoot | undefined;
69
+ /**
70
+ * Release an authority this store opened itself. Retained authorities are owned by
71
+ * the security context that supplied them and are never closed here. Idempotent.
72
+ */
73
+ close(): void;
67
74
  assertBound(): void;
68
75
  verifyRootSecurity(): void;
69
76
  ensureDirectory(relativePath?: string): ManagedDirectoryRoot;
@@ -0,0 +1,69 @@
1
+ import type { RecoveryFsRoot } from "@gajae-code/natives";
2
+ import type { RecoveryHydrationContext, ResumeSessionIdentity, SessionDestinationInput, SessionManager, SessionManagerCheckpointRevisionStrings, StrictSessionOpenFailure } from "./session-manager";
3
+ export interface MemoryGuardTranscriptDescriptorV1 {
4
+ bytes: string;
5
+ relative_path: string;
6
+ sha256: string;
7
+ }
8
+ export interface MemoryGuardCheckpointBlobAuthorityV1 {
9
+ kind: "checkpoint_blob_tree_v1";
10
+ manifest_relative_path: string;
11
+ manifest_sha256: string;
12
+ root_relative_path: string;
13
+ }
14
+ export interface MemoryGuardCheckpointBlobManifestEntryV1 {
15
+ bytes: string;
16
+ relative_path: string;
17
+ sha256: string;
18
+ }
19
+ export interface MemoryGuardCheckpointBlobManifestV1 {
20
+ entries: MemoryGuardCheckpointBlobManifestEntryV1[];
21
+ schema_version: 1;
22
+ }
23
+ export interface MemoryGuardSessionManagerCheckpointV1 {
24
+ blob_authority: MemoryGuardCheckpointBlobAuthorityV1;
25
+ revisions: SessionManagerCheckpointRevisionStrings;
26
+ schema_version: 1;
27
+ session_id: string;
28
+ session_name: string | null;
29
+ transcript: MemoryGuardTranscriptDescriptorV1;
30
+ }
31
+ export interface MemoryGuardParticipantDescriptorV1 {
32
+ ordinal: number;
33
+ checkpoint: MemoryGuardCheckpointBlobAuthorityV1;
34
+ revisions: SessionManagerCheckpointRevisionStrings;
35
+ session_id: string;
36
+ session_name: string | null;
37
+ transcript: MemoryGuardTranscriptDescriptorV1;
38
+ }
39
+ export interface MemoryGuardParticipantIngressLease {
40
+ readonly token: symbol;
41
+ release(): void;
42
+ }
43
+ export interface MemoryGuardCreateCheckpointInput {
44
+ ingressLease: MemoryGuardParticipantIngressLease;
45
+ checkpointRoot: string;
46
+ }
47
+ export type MemoryGuardRestoreBlockedReason = StrictSessionOpenFailure["reason"] | "checkpoint-mismatch" | "participant-mismatch" | "transcript-mismatch" | "blob-manifest-mismatch" | "blob-missing" | "blob-hash-mismatch" | "blob-authority-mismatch" | "destination-unavailable";
48
+ export interface MemoryGuardRestoreInput {
49
+ incidentAuthority: RecoveryFsRoot;
50
+ participant: MemoryGuardParticipantDescriptorV1;
51
+ checkpoint: MemoryGuardSessionManagerCheckpointV1;
52
+ destination: SessionDestinationInput;
53
+ }
54
+ export type MemoryGuardRestoreResult = {
55
+ kind: "staged";
56
+ manager: SessionManager;
57
+ hydrationContext: RecoveryHydrationContext;
58
+ transcriptIdentity: ResumeSessionIdentity;
59
+ cleanup: () => Promise<void>;
60
+ } | {
61
+ kind: "blocked";
62
+ reason: MemoryGuardRestoreBlockedReason;
63
+ };
64
+ export declare function memoryGuardCanonicalJson(value: unknown): string;
65
+ export declare function memoryGuardSha256Hex(value: Uint8Array | string): string;
66
+ export declare function isMemoryGuardDecimalString(value: unknown): value is string;
67
+ export declare function isMemoryGuardSha256Hex(value: unknown): value is string;
68
+ export declare function isMemoryGuardRelativePath(value: unknown): value is string;
69
+ export declare function hasOnlyKeys(value: Record<string, unknown>, allowed: readonly string[]): boolean;
@@ -8,6 +8,7 @@ import { ArtifactManager } from "./artifacts";
8
8
  import { type BlobPutResult, BlobStore } from "./blob-store";
9
9
  import { type ManagedMigrationPolicy } from "./internal/managed-session-scope";
10
10
  import { type ManagedDirectoryRoot, ManagedSessionDescendantStore } from "./internal/managed-session-storage";
11
+ import { type MemoryGuardCreateCheckpointInput, type MemoryGuardParticipantIngressLease, type MemoryGuardRestoreInput, type MemoryGuardRestoreResult, type MemoryGuardSessionManagerCheckpointV1 } from "./memory-guard-checkpoint-participant";
11
12
  import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
12
13
  import { type SessionManagerReadAccess, sessionManagerReadCapability } from "./session-manager-internal";
13
14
  import type { ManagedSessionSecurityContext, SessionStorage, SessionStorageStat, VerifiedSessionDeleteResult, VerifiedSessionDeleteTarget } from "./session-storage";
@@ -71,11 +72,16 @@ export interface SessionManagerObservabilityStats {
71
72
  coldSpillReadCount: number;
72
73
  residentTextReadCount: number;
73
74
  residentImageReadCount: number;
75
+ residentCacheAdoptFallbackCount: number;
76
+ residentCacheTrustRejectCount: number;
77
+ residentCacheWin32FallbackCount: number;
78
+ residentCacheDegradedReason?: string;
74
79
  publicMaterializerCallCount: number;
75
80
  getEntryMaterializerCallCount: number;
76
81
  getBranchMaterializerCallCount: number;
77
82
  getEntriesMaterializerCallCount: number;
78
83
  materializedEntriesCachePopulateCount: number;
84
+ materializedCacheDemotedCount: number;
79
85
  pathOnlyContextBuildCount: number;
80
86
  }
81
87
  export interface SessionMessageEntry extends SessionEntryBase {
@@ -259,6 +265,21 @@ export type DefaultModelSelectionStage = {
259
265
  readonly tempPath: string | undefined;
260
266
  readonly persistsToExistingFile: boolean;
261
267
  };
268
+ export interface SessionManagerRevisionSnapshot {
269
+ entry: number;
270
+ leaf: number;
271
+ headerExport: number;
272
+ label: number;
273
+ replayMetadata: number;
274
+ }
275
+ export interface SessionManagerCheckpointRevisionStrings {
276
+ entry: string;
277
+ leaf: string;
278
+ headerExport: string;
279
+ label: string;
280
+ replayMetadata: string;
281
+ }
282
+ export declare function toSessionManagerCheckpointRevisionStrings(snapshot: SessionManagerRevisionSnapshot): SessionManagerCheckpointRevisionStrings;
262
283
  export type DefaultModelSelectionPromotion = {
263
284
  readonly kind: "promoted";
264
285
  } | {
@@ -490,12 +511,17 @@ export type SessionDestination = {
490
511
  readonly directory: string;
491
512
  };
492
513
  export type SessionDestinationInput = string | SessionDestination | undefined;
493
- interface ForkArtifactPublication {
514
+ type ForkArtifactPublication = {
515
+ readonly kind: "managed";
494
516
  readonly snapshot: native.NativeDirectoryTreeSnapshot;
495
517
  readonly store: ManagedSessionDescendantStore;
496
518
  readonly cleanupStore: ManagedSessionDescendantStore;
497
519
  readonly cleanupRelativePath: string;
498
- }
520
+ } | {
521
+ readonly kind: "explicit";
522
+ readonly artifactsDir: string;
523
+ readonly snapshot: native.NativeDirectoryTreeSnapshot;
524
+ };
499
525
  /** Exported for testing */
500
526
  export declare function loadEntriesFromFile(filePath: string, storage?: SessionStorage): Promise<FileEntry[]>;
501
527
  declare class RecentSessionInfo {
@@ -541,6 +567,10 @@ export declare function residentBlobSentinelForTests(kind: ResidentBlobKind, ref
541
567
  export declare function materializeResidentEntriesForPersistenceForTests<T>(entries: T[], textStore: BlobStore, imageStore?: BlobStore): T[];
542
568
  /** Get recent sessions for display in welcome screen */
543
569
  export declare function getRecentSessions(sessionDir: string, limit?: number, storage?: SessionStorage): Promise<RecentSessionInfo[]>;
570
+ export declare function getRecentSessionDisplay(sessions: readonly SessionInfo[], limit?: number): Array<{
571
+ name: string;
572
+ timeAgo: string;
573
+ }>;
544
574
  /**
545
575
  * Manages conversation sessions as append-only trees stored in JSONL files.
546
576
  *
@@ -576,6 +606,13 @@ interface SessionManagerStateSnapshot {
576
606
  fileEntries: FileEntry[];
577
607
  materializedFileEntries: FileEntry[];
578
608
  }
609
+ /** Benchmark-derived cap for strong materialized session snapshots. */
610
+ export declare const MATERIALIZED_CACHE_MAX_BYTES: number;
611
+ /** Test-only cache retention and transition seams; these are intentionally not user settings. */
612
+ export declare const SessionManagerTestHooks: {
613
+ materializedCacheMaxBytesOverride?: number;
614
+ beforeResidentTransitionIndexBuild?: () => void;
615
+ };
579
616
  export declare class SessionManager {
580
617
  #private;
581
618
  private cwd;
@@ -589,18 +626,12 @@ export declare class SessionManager {
589
626
  * revision contract). Tests assert the invalidation mapping through this;
590
627
  * future export/label-view caches key off their respective domains.
591
628
  */
592
- revisionSnapshot(): {
593
- entry: number;
594
- leaf: number;
595
- headerExport: number;
596
- label: number;
597
- replayMetadata: number;
598
- };
629
+ revisionSnapshot(): SessionManagerRevisionSnapshot;
599
630
  /** Puts a binary blob into the blob store and returns the blob reference */
600
631
  putBlob(data: Buffer): Promise<BlobPutResult>;
601
632
  captureState(): SessionManagerStateSnapshot;
602
633
  restoreState(snapshot: SessionManagerStateSnapshot): void;
603
- /** Switch to a different session file (used for resume and branching) */
634
+ /** Switch to a different session file (used for resume and branching). */
604
635
  setSessionFile(sessionFile: string): Promise<void>;
605
636
  /** Start a new session. Closes any existing writer first. */
606
637
  newSession(options?: NewSessionOptions): Promise<string | undefined>;
@@ -638,9 +669,9 @@ export declare class SessionManager {
638
669
  * managed logical authorization. This is only for discarding an UNCOMMITTED
639
670
  * successor that a transaction (e.g. handoff) created via `newSession()` but
640
671
  * never durably authorized — such a session has no managed candidate listing
641
- * yet, so `dropSession` would refuse it and leak its resident-cache/artifact
642
- * root. Bounded to this manager's configured session root and refuses to touch
643
- * the active session; tolerates missing files.
672
+ * yet, so `dropSession` would refuse it and leak its artifact root. Bounded to
673
+ * this manager's configured session root and refuses to touch the active session;
674
+ * tolerates missing files.
644
675
  */
645
676
  discardUncommittedSession(sessionPath: string): Promise<void>;
646
677
  /**
@@ -691,6 +722,8 @@ export declare class SessionManager {
691
722
  listForResumePickerReadOnly(): Promise<SessionInfo[]>;
692
723
  getSessionId(): string;
693
724
  getSessionFile(): string | undefined;
725
+ acquireMemoryGuardParticipantIngressLease(): MemoryGuardParticipantIngressLease;
726
+ createMemoryGuardCheckpoint(input: MemoryGuardCreateCheckpointInput): Promise<MemoryGuardSessionManagerCheckpointV1>;
694
727
  /**
695
728
  * Returns the session artifacts directory path (session file path without .jsonl).
696
729
  * Returns null when the session is not persisted to a file.
@@ -747,11 +780,6 @@ export declare class SessionManager {
747
780
  /** The source that set the session name: "user" (manual /rename or RPC) or "auto" (generated title). */
748
781
  get titleSource(): "auto" | "user" | undefined;
749
782
  getSessionName(): string | undefined;
750
- /**
751
- * Set the session display name.
752
- * @param source - "user" for explicit renames (/rename command, RPC); "auto" for generated titles.
753
- * Auto-generated titles are silently ignored when the user has already set a name.
754
- */
755
783
  setSessionName(name: string, source?: "auto" | "user"): Promise<boolean>;
756
784
  _persist(entry: SessionEntry): void;
757
785
  /** Append a configured fallback chain as child of current leaf, then advance leaf. Returns entry id. */
@@ -971,7 +999,7 @@ export declare class SessionManager {
971
999
  * legacy sibling directories.
972
1000
  */
973
1001
  static listForResumePickerReadOnly(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
974
- /** Tombstone and exact-delete a default-managed candidate. */
1002
+ /** Delete an authorized managed or project-local picker candidate. */
975
1003
  static deleteManagedCandidate(sessionPath: string): Promise<void>;
976
1004
  /** Capture exact source content for a strict fork without granting write ownership. */
977
1005
  static captureTranscriptStrict(filePath: string, storage?: SessionStorage): StrictSessionCaptureResult;
@@ -981,6 +1009,7 @@ export declare class SessionManager {
981
1009
  * persistence; destination history always comes from the captured bytes.
982
1010
  */
983
1011
  static forkFromCaptured(snapshot: CapturedSessionTranscriptSnapshot, cwd: string, destinationInput?: SessionDestinationInput, _migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<StrictSessionForkResult>;
1012
+ static restoreMemoryGuardCheckpoint(input: MemoryGuardRestoreInput): Promise<MemoryGuardRestoreResult>;
984
1013
  /** Inspect a selected session without acquiring write-capable ownership. */
985
1014
  static inspectSessionTailReadOnly(filePath: string, storage?: SessionStorage): Promise<ResumeTailInspection>;
986
1015
  /**
@@ -61,6 +61,8 @@ export interface SessionStorageWriterOpenOptions {
61
61
  export interface ManagedSessionSecurityContext {
62
62
  readonly kind: "managed";
63
63
  readonly agentDir: string;
64
+ /** Logical profile root for process-local caches; distinct from managed pathname authority. */
65
+ readonly profileAgentDir: string;
64
66
  readonly sessionsRoot: string;
65
67
  readonly sessionDir: string;
66
68
  readonly rootAuthority: ManagedDirectoryRoot;
@@ -69,6 +71,8 @@ export interface ManagedSessionSecurityContext {
69
71
  /** @internal Create the only accepted managed writer authority object. */
70
72
  export declare function createManagedSessionSecurityContext(input: {
71
73
  agentDir: string;
74
+ /** Optional for compatibility with existing authority-only callers. */
75
+ profileAgentDir?: string;
72
76
  sessionsRoot: string;
73
77
  sessionDir: string;
74
78
  rootAuthority: ManagedDirectoryRoot;