@gajae-code/coding-agent 0.18.7 → 0.18.8

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 (279) hide show
  1. package/CHANGELOG.md +279 -1
  2. package/dist/types/async/job-manager.d.ts +1 -1
  3. package/dist/types/capability/mcp.d.ts +2 -0
  4. package/dist/types/capability/skill.d.ts +2 -0
  5. package/dist/types/capability/types.d.ts +2 -0
  6. package/dist/types/cli/public-command-errors.d.ts +3 -1
  7. package/dist/types/cli/setup-cli.d.ts +1 -1
  8. package/dist/types/commands/deep-interview.d.ts +3 -0
  9. package/dist/types/config/autorouting-tier-map.d.ts +348 -9
  10. package/dist/types/config/file-lock.d.ts +1 -0
  11. package/dist/types/config/model-bindings-applier.d.ts +2 -0
  12. package/dist/types/config/model-profile-activation.d.ts +11 -3
  13. package/dist/types/config/model-registry.d.ts +4 -9
  14. package/dist/types/config/skill-settings-defaults.d.ts +2 -0
  15. package/dist/types/cursor-delete-path.d.ts +1 -0
  16. package/dist/types/cursor-mcp-name.d.ts +8 -0
  17. package/dist/types/customization/inventory.d.ts +2 -0
  18. package/dist/types/debug/report-bundle-parent.d.ts +2 -0
  19. package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/provider/stream.d.ts +1 -0
  20. package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/provider/version-manager.d.ts +31 -0
  21. package/dist/types/defaults/gjc-skills.generated.d.ts +5 -6
  22. package/dist/types/discovery/helpers.d.ts +6 -1
  23. package/dist/types/export/html/css-color.d.ts +2 -0
  24. package/dist/types/export/html/template.generated.d.ts +1 -1
  25. package/dist/types/extensibility/extensions/types.d.ts +7 -0
  26. package/dist/types/extensibility/gjc-plugins/runtime-adapters.d.ts +14 -1
  27. package/dist/types/extensibility/plugins/marketplace/cache.d.ts +2 -0
  28. package/dist/types/extensibility/plugins/plugin-link-path.d.ts +2 -0
  29. package/dist/types/extensibility/runtime-skill-discovery.d.ts +3 -1
  30. package/dist/types/extensibility/skill-management.d.ts +3 -1
  31. package/dist/types/extensibility/skills.d.ts +2 -0
  32. package/dist/types/gjc-runtime/deep-interview-crystallize.d.ts +74 -0
  33. package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +11 -0
  34. package/dist/types/gjc-runtime/gc-runtime.d.ts +5 -0
  35. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +0 -5
  36. package/dist/types/gjc-runtime/state-argv.d.ts +1 -1
  37. package/dist/types/gjc-runtime/state-migrations.d.ts +8 -0
  38. package/dist/types/gjc-runtime/state-runtime.d.ts +95 -0
  39. package/dist/types/gjc-runtime/state-writer.d.ts +11 -1
  40. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +8 -0
  41. package/dist/types/internal-urls/skill-path.d.ts +1 -0
  42. package/dist/types/lsp/workspace-path.d.ts +1 -0
  43. package/dist/types/modes/acp/acp-agent.d.ts +7 -0
  44. package/dist/types/modes/components/custom-editor.d.ts +6 -0
  45. package/dist/types/modes/components/customization/customization-dashboard.d.ts +1 -0
  46. package/dist/types/modes/components/extensions/state-manager.d.ts +4 -3
  47. package/dist/types/modes/controllers/input-controller.d.ts +9 -0
  48. package/dist/types/modes/interactive-mode.d.ts +1 -0
  49. package/dist/types/modes/utils/interrupt-ownership.d.ts +3 -0
  50. package/dist/types/modes/utils/keybinding-matchers.d.ts +1 -0
  51. package/dist/types/modes/utils/macos-option-forwarding.d.ts +17 -0
  52. package/dist/types/progress/collect-project-progress.d.ts +38 -0
  53. package/dist/types/progress/progress-contract.d.ts +154 -0
  54. package/dist/types/progress/progress-snapshot.d.ts +11 -0
  55. package/dist/types/progress/project-progress.d.ts +141 -0
  56. package/dist/types/progress/render-progress.d.ts +28 -0
  57. package/dist/types/runtime-mcp/oauth-public-url.d.ts +1 -0
  58. package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +1 -0
  59. package/dist/types/runtime-mcp/smithery-registry.d.ts +24 -0
  60. package/dist/types/runtime-mcp/types.d.ts +6 -0
  61. package/dist/types/sdk/acp/adapter.d.ts +1 -1
  62. package/dist/types/sdk/broker/broker-exit.d.ts +6 -2
  63. package/dist/types/sdk/broker/broker.d.ts +18 -1
  64. package/dist/types/sdk/broker/session-index.d.ts +12 -6
  65. package/dist/types/sdk/bus/index.d.ts +12 -1
  66. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +6 -1
  67. package/dist/types/sdk/client/client.d.ts +2 -0
  68. package/dist/types/sdk/host/query/handlers.d.ts +3 -0
  69. package/dist/types/sdk/index.d.ts +1 -0
  70. package/dist/types/sdk/router/session-router.d.ts +2 -0
  71. package/dist/types/sdk/session-list.d.ts +1 -1
  72. package/dist/types/sdk/session.d.ts +8 -0
  73. package/dist/types/session/agent-session.d.ts +38 -9
  74. package/dist/types/session/artifacts.d.ts +2 -2
  75. package/dist/types/session/internal/managed-gc-retirement-codec.d.ts +32 -0
  76. package/dist/types/session/internal/managed-session-scope.d.ts +79 -2
  77. package/dist/types/session/internal/managed-session-storage.d.ts +26 -1
  78. package/dist/types/session/internal/managed-task-owner-cleanup.d.ts +62 -0
  79. package/dist/types/session/internal/task-artifact-owner-access.d.ts +2 -0
  80. package/dist/types/session/internal/task-artifact-owner-transcript.d.ts +9 -1
  81. package/dist/types/session/session-manager.d.ts +31 -5
  82. package/dist/types/session/session-retirement.d.ts +31 -7
  83. package/dist/types/session/session-storage.d.ts +62 -2
  84. package/dist/types/session/task-artifact-owner-codec.d.ts +2 -0
  85. package/dist/types/setup/credential-auto-import.d.ts +1 -1
  86. package/dist/types/setup/credential-import.d.ts +6 -4
  87. package/dist/types/skill-state/active-state.d.ts +38 -0
  88. package/dist/types/slash-commands/helpers/progress-report.d.ts +8 -0
  89. package/dist/types/task/executor.d.ts +3 -0
  90. package/dist/types/tools/bash-skill-urls.d.ts +1 -1
  91. package/dist/types/tools/index.d.ts +3 -0
  92. package/dist/types/tools/python.d.ts +9 -1
  93. package/dist/types/tools/recipe/recipe-guard.d.ts +7 -0
  94. package/dist/types/tools/restricted-cwd.d.ts +1 -0
  95. package/dist/types/tools/todo-write.d.ts +6 -0
  96. package/dist/types/utils/tools-checksum.d.ts +7 -0
  97. package/package.json +7 -7
  98. package/scripts/generate-sdk-operation-inventory.ts +21 -0
  99. package/scripts/verify-managed-empty-stop.ts +28 -0
  100. package/src/async/job-manager.ts +228 -122
  101. package/src/capability/index.ts +17 -0
  102. package/src/capability/mcp.ts +2 -0
  103. package/src/capability/skill.ts +2 -0
  104. package/src/capability/types.ts +2 -0
  105. package/src/cli/auth-broker-cli.ts +1 -1
  106. package/src/cli/customize-doctor.ts +15 -2
  107. package/src/cli/public-command-errors.ts +21 -1
  108. package/src/cli/setup-cli.ts +4 -4
  109. package/src/cli/skills-cli.ts +5 -0
  110. package/src/commands/deep-interview.ts +47 -8
  111. package/src/commands/sdk.ts +28 -8
  112. package/src/config/autorouting-tier-map.ts +117 -7
  113. package/src/config/file-lock.ts +307 -68
  114. package/src/config/mcp-schema.json +4 -0
  115. package/src/config/model-bindings-applier.ts +20 -0
  116. package/src/config/model-profile-activation.ts +240 -46
  117. package/src/config/model-registry.ts +47 -153
  118. package/src/config/skill-settings-defaults.ts +7 -0
  119. package/src/coordinator-mcp/policy.ts +3 -2
  120. package/src/cursor-delete-path.ts +10 -0
  121. package/src/cursor-mcp-name.ts +15 -0
  122. package/src/cursor.ts +13 -2
  123. package/src/customization/inventory.ts +3 -0
  124. package/src/debug/report-bundle-parent.ts +22 -0
  125. package/src/debug/report-bundle.ts +3 -0
  126. package/src/debug/system-info.ts +13 -1
  127. package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/stream.ts +67 -4
  128. package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/version-manager.ts +80 -0
  129. package/src/defaults/gjc/skills/deep-interview/SKILL.md +105 -10
  130. package/src/defaults/gjc/skills/ralplan/SKILL.md +6 -4
  131. package/src/defaults/gjc-defaults.test.ts +18 -1
  132. package/src/defaults/gjc-defaults.ts +3 -0
  133. package/src/defaults/gjc-skills.generated.ts +58 -36
  134. package/src/discovery/agents.ts +6 -1
  135. package/src/discovery/builtin.ts +10 -0
  136. package/src/discovery/helpers.ts +159 -20
  137. package/src/discovery/mcp-json.ts +6 -0
  138. package/src/discovery/ssh.ts +1 -1
  139. package/src/discovery/substitute-plugin-root.ts +3 -1
  140. package/src/edit/file-read-cache.ts +1 -1
  141. package/src/eval/py/executor.ts +380 -120
  142. package/src/export/html/css-color.ts +9 -0
  143. package/src/export/html/index.ts +5 -4
  144. package/src/export/html/template.generated.ts +1 -1
  145. package/src/extensibility/extensions/runner.ts +4 -0
  146. package/src/extensibility/extensions/types.ts +7 -0
  147. package/src/extensibility/gjc-plugins/runtime-adapters.ts +73 -8
  148. package/src/extensibility/plugins/manager.ts +3 -2
  149. package/src/extensibility/plugins/marketplace/cache.ts +15 -0
  150. package/src/extensibility/plugins/marketplace/manager.ts +11 -3
  151. package/src/extensibility/plugins/plugin-link-path.ts +12 -0
  152. package/src/extensibility/runtime-skill-discovery.ts +20 -2
  153. package/src/extensibility/skill-management.ts +6 -2
  154. package/src/extensibility/skills.ts +6 -1
  155. package/src/gjc-runtime/deep-interview-crystallize.ts +1814 -0
  156. package/src/gjc-runtime/deep-interview-recorder.ts +20 -2
  157. package/src/gjc-runtime/deep-interview-runtime.ts +1415 -13
  158. package/src/gjc-runtime/deep-interview-stage.ts +98 -21
  159. package/src/gjc-runtime/gc-runtime.ts +206 -9
  160. package/src/gjc-runtime/launch-worktree.ts +14 -4
  161. package/src/gjc-runtime/ralplan-runtime.ts +447 -52
  162. package/src/gjc-runtime/state-argv.ts +2 -0
  163. package/src/gjc-runtime/state-migrations.ts +91 -29
  164. package/src/gjc-runtime/state-runtime.ts +3716 -135
  165. package/src/gjc-runtime/state-writer.ts +83 -8
  166. package/src/gjc-runtime/ultragoal-runtime.ts +16 -4
  167. package/src/gjc-runtime/workflow-manifest.generated.json +70 -42
  168. package/src/gjc-runtime/workflow-manifest.ts +54 -21
  169. package/src/harness-control-plane/operate.ts +12 -4
  170. package/src/harness-control-plane/owner.ts +5 -1
  171. package/src/hashline/parser.ts +48 -9
  172. package/src/hashline/recovery.ts +13 -4
  173. package/src/internal-urls/docs-index.generated.ts +18 -17
  174. package/src/internal-urls/skill-path.ts +19 -0
  175. package/src/internal-urls/skill-protocol.ts +2 -0
  176. package/src/lsp/edits.ts +6 -0
  177. package/src/lsp/workspace-path.ts +51 -0
  178. package/src/main.ts +195 -31
  179. package/src/modes/acp/acp-agent.ts +88 -4
  180. package/src/modes/components/custom-editor.ts +14 -0
  181. package/src/modes/components/customization/customization-dashboard.ts +12 -0
  182. package/src/modes/components/extensions/extension-dashboard.ts +2 -2
  183. package/src/modes/components/extensions/state-manager.ts +15 -5
  184. package/src/modes/components/model-selector.ts +1 -4
  185. package/src/modes/components/provider-onboarding-selector.ts +1 -1
  186. package/src/modes/components/status-line/segments.ts +4 -0
  187. package/src/modes/controllers/event-controller.ts +11 -4
  188. package/src/modes/controllers/input-controller.ts +74 -29
  189. package/src/modes/controllers/runtime-mcp-command-controller.ts +8 -3
  190. package/src/modes/controllers/selector-controller.ts +28 -15
  191. package/src/modes/interactive-mode.ts +4 -0
  192. package/src/modes/runtime-init.ts +4 -0
  193. package/src/modes/utils/abort-message.ts +3 -1
  194. package/src/modes/utils/interrupt-ownership.ts +12 -0
  195. package/src/modes/utils/keybinding-matchers.ts +4 -0
  196. package/src/modes/utils/macos-option-forwarding.ts +80 -0
  197. package/src/progress/collect-project-progress.ts +153 -0
  198. package/src/progress/progress-contract.ts +172 -0
  199. package/src/progress/progress-snapshot.ts +140 -0
  200. package/src/progress/project-progress.ts +446 -0
  201. package/src/progress/render-progress.ts +209 -0
  202. package/src/prompts/system/master-mode.md +1 -0
  203. package/src/prompts/tools/skill-discovery.md +1 -1
  204. package/src/runtime-mcp/config-writer.ts +10 -6
  205. package/src/runtime-mcp/config.ts +1 -0
  206. package/src/runtime-mcp/oauth-flow.ts +5 -0
  207. package/src/runtime-mcp/oauth-public-url.ts +8 -0
  208. package/src/runtime-mcp/plugin-network-boundary.ts +4 -0
  209. package/src/runtime-mcp/smithery-registry.ts +22 -3
  210. package/src/runtime-mcp/transports/http.ts +2 -2
  211. package/src/runtime-mcp/types.ts +6 -0
  212. package/src/sdk/acp/adapter.ts +93 -8
  213. package/src/sdk/broker/broker-exit.ts +52 -23
  214. package/src/sdk/broker/broker.ts +75 -6
  215. package/src/sdk/broker/ensure.ts +2 -0
  216. package/src/sdk/broker/lifecycle.ts +711 -66
  217. package/src/sdk/broker/session-index.ts +191 -81
  218. package/src/sdk/bus/chat-daemon-cli.ts +38 -1
  219. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  220. package/src/sdk/bus/index.ts +238 -43
  221. package/src/sdk/bus/telegram-daemon-contract.ts +6 -1
  222. package/src/sdk/cli/session-cli.ts +17 -3
  223. package/src/sdk/client/client.ts +28 -8
  224. package/src/sdk/host/query/handlers.ts +9 -1
  225. package/src/sdk/host/session-runtime.test.ts +2647 -294
  226. package/src/sdk/host/session-runtime.ts +426 -109
  227. package/src/sdk/host/surface-policy.ts +1 -0
  228. package/src/sdk/index.ts +8 -0
  229. package/src/sdk/lifecycle-session.ts +3 -1
  230. package/src/sdk/prompt-deadline-manager.ts +15 -0
  231. package/src/sdk/protocol/operation-inventory.generated.json +146 -0
  232. package/src/sdk/protocol/operation-registry.ts +9 -2
  233. package/src/sdk/router/session-router.ts +75 -12
  234. package/src/sdk/session-list.ts +1 -0
  235. package/src/sdk/session.ts +67 -38
  236. package/src/session/agent-session.ts +623 -224
  237. package/src/session/artifacts.ts +174 -70
  238. package/src/session/internal/managed-gc-retirement-codec.ts +319 -0
  239. package/src/session/internal/managed-session-scope.ts +3457 -462
  240. package/src/session/internal/managed-session-storage.ts +376 -61
  241. package/src/session/internal/managed-task-owner-cleanup.ts +473 -0
  242. package/src/session/internal/task-artifact-owner-access.ts +19 -3
  243. package/src/session/internal/task-artifact-owner-transcript.ts +547 -1
  244. package/src/session/session-manager.ts +939 -133
  245. package/src/session/session-retirement.ts +573 -14
  246. package/src/session/session-storage.ts +417 -14
  247. package/src/session/task-artifact-owner-codec.ts +71 -8
  248. package/src/session/task-artifact-owner-retirement.ts +21 -19
  249. package/src/setup/credential-auto-import.ts +12 -3
  250. package/src/setup/credential-import.ts +176 -5
  251. package/src/setup/paseo/announce.ts +6 -1
  252. package/src/skill-state/active-state.ts +132 -2
  253. package/src/slash-commands/builtin-registry.ts +39 -9
  254. package/src/slash-commands/helpers/progress-report.ts +23 -0
  255. package/src/stt/setup.ts +3 -5
  256. package/src/task/commands.ts +3 -1
  257. package/src/task/executor.ts +4 -0
  258. package/src/task/index.ts +6 -0
  259. package/src/tools/ask.ts +205 -6
  260. package/src/tools/ast-edit.ts +4 -0
  261. package/src/tools/bash-allowed-prefixes.ts +15 -0
  262. package/src/tools/bash-skill-urls.ts +56 -3
  263. package/src/tools/bash.ts +48 -79
  264. package/src/tools/descriptors.ts +5 -1
  265. package/src/tools/eval.ts +56 -36
  266. package/src/tools/image-gen.ts +1 -1
  267. package/src/tools/index.ts +3 -0
  268. package/src/tools/python.ts +187 -66
  269. package/src/tools/recipe/index.ts +9 -0
  270. package/src/tools/recipe/recipe-guard.ts +19 -0
  271. package/src/tools/restricted-cwd.ts +10 -0
  272. package/src/tools/skill-discovery.ts +5 -0
  273. package/src/tools/skill.ts +28 -1
  274. package/src/tools/todo-write.ts +10 -1
  275. package/src/tools/tool-catalog.generated.ts +1 -1
  276. package/src/tools/write.ts +1 -0
  277. package/src/utils/tools-checksum.ts +34 -0
  278. package/src/utils/tools-manager.ts +24 -6
  279. package/src/web/search/providers/codex.ts +3 -2
@@ -3,6 +3,7 @@ import { type AuthCredentialSelector, type Model, type ProviderSessionState } fr
3
3
  import { createAppendOnlyContextManager, providerSupportsAppendOnlyAuto, resolveAppendOnlyMode } from "../append-only-mode";
4
4
  import { AsyncJobManager } from "../async";
5
5
  import { type Rule } from "../capability/rule";
6
+ import type { ModelProfileOwnershipMarker } from "../config/model-profile-ownership";
6
7
  import { ModelRegistry } from "../config/model-registry";
7
8
  import { type ScopedModelSelection } from "../config/model-resolver";
8
9
  import { type PromptTemplate } from "../config/prompt-templates";
@@ -82,6 +83,8 @@ export interface CreateAgentSessionOptions {
82
83
  modelPattern?: string;
83
84
  /** Active profile inherited by a nested SDK/subagent session. */
84
85
  activeModelProfile?: string;
86
+ /** Model profile ownership marker for propagating parent profile ownership to subagent sessions. */
87
+ modelProfileOwnershipMarker?: ModelProfileOwnershipMarker;
85
88
  /** Thinking selector. Default: from settings, else unset */
86
89
  thinkingLevel?: ThinkingLevel;
87
90
  /** Runtime substitution metadata for the initial model_change session event. */
@@ -194,6 +197,11 @@ export interface CreateAgentSessionOptions {
194
197
  * @internal lifecycle-only startup guard.
195
198
  */
196
199
  deferOptionalModelRefresh?: boolean;
200
+ /**
201
+ * Defer model profile activation until explicit model pin validation occurs.
202
+ * @internal Lifecycle-only: prevents default profile activation before pin resolution.
203
+ */
204
+ deferModelProfileActivation?: boolean;
197
205
  /** Enable LSP integration (tool, formatting, diagnostics, warmup). Default: true */
198
206
  enableLsp?: boolean;
199
207
  /** Skip Python kernel availability check and prelude warmup */
@@ -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 RunSettlementProof, type StablePrefixSnapshot, ThinkingLevel } from "@gajae-code/agent-core";
15
+ import { type Agent, type AgentContext, type AgentEvent, type AgentLoopConfig, type AgentMessage, type AgentState, type AgentTerminalOwnerContext, type AgentTool, type MidRunMaintenanceOutcome, type RunCancellationDomain, type RunSettlementProof, type StablePrefixSnapshot, ThinkingLevel } from "@gajae-code/agent-core";
16
16
  import type { AttemptScope } from "@gajae-code/agent-core/attempt-scope";
17
17
  import { type CompactionResult, type EmergencyCompactionSample } from "@gajae-code/agent-core/compaction";
18
18
  import type { AssistantMessage, AttemptScopeRef, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolCall, ToolChoice, Usage, UsageReport } from "@gajae-code/ai/core";
@@ -68,7 +68,7 @@ export interface ForkContextSeedOptions {
68
68
  signal?: AbortSignal;
69
69
  }
70
70
  import type { AuthCredentialSelector } from "@gajae-code/ai/core";
71
- import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager, type FoldReason, type JobFoldEvent } from "../async";
71
+ import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager, type FoldReason, type JobFoldEvent, type SubagentLifecycle } from "../async";
72
72
  import type { Rule } from "../capability/rule";
73
73
  import { type ModelRegistry } from "../config/model-registry";
74
74
  import { type ResolvedModelRoleValue, type ScopedModelSelection } from "../config/model-resolver";
@@ -84,7 +84,7 @@ import type { ExtensionRunner } from "../extensibility/extensions";
84
84
  import { type CompactOptions, type ContextUsage, type ExtensionTranscriptEntry } from "../extensibility/extensions/types";
85
85
  import type { GjcRuntimeSnapshotProvider } from "../extensibility/gjc-plugins/runtime-quarantine";
86
86
  import type { SessionSwitchEvent } from "../extensibility/shared-events";
87
- import { type Skill, type SkillWarning } from "../extensibility/skills";
87
+ import { type ParsedSkillInvocation, type Skill, type SkillWarning } from "../extensibility/skills";
88
88
  import { type FileSlashCommand } from "../extensibility/slash-commands";
89
89
  import { type MemoryGuardClaimsLease } from "../gjc-runtime/memory-guard-owner-claims";
90
90
  import { GoalRuntime } from "../goals/runtime";
@@ -113,7 +113,7 @@ import { type ContributionPrepOptions, type ContributionPrepResult } from "./con
113
113
  import { type FoldAdapter, FoldCoordinator, type ForegroundFoldOutcome } from "./fold-coordinator";
114
114
  import type { MemoryGuardRestoreResult } from "./memory-guard-checkpoint-participant";
115
115
  import { type CustomMessage } from "./messages";
116
- import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, PreparedNewSession, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionContext, SessionManagerCloseOutcome, SessionMemoryStats } from "./session-manager";
116
+ import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, PreparedNewSession, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionContext, SessionManagerCloseOutcome, SessionMemoryStats, SessionArtifactPublication } from "./session-manager";
117
117
  import { SessionManager } from "./session-manager";
118
118
  import { ToolChoiceQueue } from "./tool-choice-queue";
119
119
  import { YieldQueue } from "./yield-queue";
@@ -603,11 +603,7 @@ export declare class SessionDisposalIncompleteError extends Error {
603
603
  constructor(label?: string);
604
604
  }
605
605
  export declare function isSessionDisposalIncompleteError(error: unknown): error is SessionDisposalIncompleteError;
606
- export interface AgentBashArtifactStore {
607
- saveArtifact(content: string, toolType: string): Promise<string | undefined>;
608
- getArtifactPath(id: string): Promise<string | null>;
609
- }
610
- export declare function saveAgentBashOriginalArtifact(store: AgentBashArtifactStore, originalText: string): Promise<BashArtifactSaveResult>;
606
+ export declare function saveAgentBashOriginalArtifact(publication: SessionArtifactPublication, originalText: string): Promise<BashArtifactSaveResult>;
611
607
  type IrcRosterClaim = {
612
608
  token: symbol;
613
609
  signature: string;
@@ -854,6 +850,11 @@ export declare class AgentSession {
854
850
  getAsyncJobSnapshot(options?: {
855
851
  recentLimit?: number;
856
852
  }): AsyncJobSnapshot | null;
853
+ /**
854
+ * Lifecycle status of every subagent owned by this session, read from the
855
+ * manager's stable control-plane records (they outlive AsyncJob eviction).
856
+ */
857
+ getSubagentLifecycleStatuses(): SubagentLifecycle[];
857
858
  /**
858
859
  * Emit a UI-only notice to the session. Surfaces in interactive mode as a
859
860
  * `showWarning` / `showError` / `showStatus` line; non-interactive modes
@@ -1212,6 +1213,20 @@ export declare class AgentSession {
1212
1213
  * @throws Error if no model selected or no API key available (when not streaming)
1213
1214
  */
1214
1215
  prompt(text: string, options?: PromptOptions): Promise<void>;
1216
+ /**
1217
+ * The loaded skill a prompt's text dispatches to, or undefined when `prompt`
1218
+ * would submit it as ordinary text (unknown or disabled `/skill:` names,
1219
+ * chains, or attached images). Single source for dispatch and for callers
1220
+ * that must mirror it, such as startup title seeding.
1221
+ */
1222
+ resolvePromptSkillInvocation(text: string, images?: readonly unknown[]): ParsedSkillInvocation | undefined;
1223
+ /**
1224
+ * Whether `prompt` intercepts this slash text as an extension or custom/MCP
1225
+ * command. Used to keep command arguments away from the title model. Mirrors the
1226
+ * command lookup in `#tryExecuteExtensionCommand` / `#tryExecuteCustomCommand`
1227
+ * without executing anything.
1228
+ */
1229
+ isLocallyHandledSlashCommand(text: string): boolean;
1215
1230
  promptCustomMessage<T = unknown>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details" | "attribution">, options?: Pick<PromptOptions, "streamingBehavior" | "toolChoice" | "followUpQueuePolicy" | "steerQueuePolicy" | "onPreflightAccepted" | "onPreflightAcceptCommit" | "preflightSignal" | "sdkRunCapability">): Promise<void>;
1216
1231
  /**
1217
1232
  * Queue a steering message to interrupt the agent mid-run.
@@ -1397,6 +1412,8 @@ export declare class AgentSession {
1397
1412
  rebindTerminalAbortSteeringSnapshot(token: number): void;
1398
1413
  discardTerminalAbortSteeringSnapshot(token: number): void;
1399
1414
  getTerminalTurnEpoch(): number | undefined;
1415
+ getTerminalRunOwnerForEvent(event: object): AgentTerminalOwnerContext | undefined;
1416
+ getRunOwnerDomain(handle: string): RunCancellationDomain | undefined;
1400
1417
  /**
1401
1418
  * Tool call ids the run resource ledger currently holds for `handle` (#5637).
1402
1419
  *
@@ -1464,6 +1481,17 @@ export declare class AgentSession {
1464
1481
  }): Promise<void>;
1465
1482
  setActiveModelProfile(name: string | undefined): void;
1466
1483
  getActiveModelProfile(): string | undefined;
1484
+ setUnavailableModelProfile(name: string | undefined): void;
1485
+ getUnavailableModelProfile(): string | undefined;
1486
+ /** Revision fence for deferred activation after a user model selection. */
1487
+ getUserModelSelectionRevision(): number;
1488
+ /** Latest concrete user choice that seeded or cleared the session's sticky canonical variant. */
1489
+ getUserCanonicalVariantSelection(): {
1490
+ revision: number;
1491
+ canonicalVariant: string | undefined;
1492
+ };
1493
+ /** Fence deferred startup profile recovery before an explicit control-surface selection. */
1494
+ markUserModelSelection(): void;
1467
1495
  /**
1468
1496
  * Re-apply vendor-separated delegation after a profile activation changed the
1469
1497
  * role layer. `eagerTasks` is resolved at prompt build time, but under
@@ -1597,6 +1625,7 @@ export declare class AgentSession {
1597
1625
  reason?: TemporaryModelReason;
1598
1626
  providerSessionScope?: TemporaryProviderSessionScope;
1599
1627
  signal?: AbortSignal;
1628
+ shouldMutate?: () => boolean;
1600
1629
  onMutationStarted?: () => void;
1601
1630
  }): Promise<TemporaryProviderSessionScope | void>;
1602
1631
  /** Restore the exact live-model state captured before a failed selector transaction. */
@@ -77,8 +77,8 @@ export declare class ArtifactManager {
77
77
  * Best-effort removal of a previously published named artifact. Used to roll
78
78
  * back staged publications when a transactional operation (e.g. gated
79
79
  * maintenance pruning) is rejected after publication succeeded. Returns false
80
- * when the artifact could not be removed so callers can log the failure
81
- * instead of silently treating the rollback as complete.
80
+ * when the exact named artifact is absent or could not be removed; success does
81
+ * not claim that unrelated native cleanup residue was reclaimed.
82
82
  */
83
83
  removeNamedBestEffort(filename: string): Promise<boolean>;
84
84
  /**
@@ -0,0 +1,32 @@
1
+ import type { SessionStorageFileIdentity } from "../session-storage";
2
+ import { type TaskArtifactOwnerDeletionEvidence, type TaskArtifactOwnerLocator, type TaskArtifactOwnerRetirementContinuation, type TaskArtifactOwnerRetirementOutcome, type TaskArtifactOwnerStorageContext } from "../task-artifact-owner-codec";
3
+ export type ManagedGcSessionRetirementState = "prepared" | "artifacts_removed" | "owner_pending" | "owner_retired";
4
+ export interface ManagedGcSessionRetirementTarget {
5
+ readonly transcriptPath: string;
6
+ readonly sessionId: string;
7
+ readonly cwd: string;
8
+ readonly transcriptIdentity: SessionStorageFileIdentity;
9
+ readonly taskArtifactOwnerLocator: TaskArtifactOwnerLocator;
10
+ }
11
+ export interface ManagedGcSessionRetirementReceipt extends ManagedGcSessionRetirementTarget {
12
+ readonly state: ManagedGcSessionRetirementState;
13
+ readonly taskArtifactOwnerDeletionEvidence: TaskArtifactOwnerDeletionEvidence;
14
+ readonly artifactsRemoved?: true;
15
+ readonly ownerRetirementAttempt?: number;
16
+ readonly taskArtifactOwnerRetirementOutcome?: TaskArtifactOwnerRetirementOutcome;
17
+ readonly taskArtifactOwnerRetirementContinuation?: TaskArtifactOwnerRetirementContinuation;
18
+ readonly taskArtifactOwnerPayloadRetired?: true;
19
+ readonly taskArtifactOwnerNamespaceRetained?: true;
20
+ readonly taskArtifactOwnerRetired?: true;
21
+ }
22
+ export declare function managedGcRetirementIdentityRecord(identity: SessionStorageFileIdentity): Record<string, unknown>;
23
+ export declare function sameIdentity(left: SessionStorageFileIdentity, right: SessionStorageFileIdentity): boolean;
24
+ export declare function managedGcRetirementIdentityValue(value: unknown): SessionStorageFileIdentity;
25
+ /**
26
+ * Strictly decode one persisted managed-GC receipt. A decoded `owner_retired` outcome is persisted DTO data only;
27
+ * this pure parser does not verify current filesystem state, payload destruction, or writer quiescence. A future
28
+ * journal reader must perform the live physical-retirement proof for the relevant state before treating it as done.
29
+ */
30
+ export declare function parseManagedGcRetirementReceipt(value: unknown, scopeDigest: string, ownerContext: TaskArtifactOwnerStorageContext, target: ManagedGcSessionRetirementTarget): ManagedGcSessionRetirementReceipt;
31
+ /** Check only monotone DTO history; this does not establish physical cleanup or current authority. */
32
+ export declare function continuationExtendsPrevious(previous: TaskArtifactOwnerRetirementContinuation, next: TaskArtifactOwnerRetirementContinuation): boolean;
@@ -1,6 +1,8 @@
1
1
  import type { RecoveryFsRoot } from "@gajae-code/natives";
2
2
  import type { ResumeSessionIdentity } from "../session-manager";
3
3
  import { type NativeDirectoryTreeSnapshot } from "../session-storage";
4
+ import { type TaskArtifactOwnerStorageContext } from "../task-artifact-owner-codec";
5
+ import { type ManagedGcSessionRetirementReceipt, type ManagedGcSessionRetirementTarget } from "./managed-gc-retirement-codec";
4
6
  import { type ManagedDirectoryRoot, type ManagedSessionSecurityPolicy, type ManagedStorageLock } from "./managed-session-storage";
5
7
  export declare const MANAGED_SESSION_LAYOUT_VERSION: 2;
6
8
  export declare const MANAGED_SESSION_IDENTITY_VERSION: 1;
@@ -17,6 +19,57 @@ export interface ManagedScope {
17
19
  directoryPath: string;
18
20
  platform: "posix" | "win32";
19
21
  }
22
+ export interface ManagedGcProtocolPathIdentity {
23
+ readonly path: string;
24
+ readonly dev: string;
25
+ readonly ino: string;
26
+ }
27
+ export interface ManagedGcProtocolFileSnapshot {
28
+ readonly name: string;
29
+ readonly dev: string;
30
+ readonly ino: string;
31
+ readonly nlink: string;
32
+ readonly size: number;
33
+ readonly mtimeNs: string;
34
+ readonly ctimeNs: string;
35
+ readonly mode: number;
36
+ readonly sha256: string;
37
+ }
38
+ export type ManagedGcProtocolRole = "locks" | "receipts" | "tombstones";
39
+ export interface ManagedGcProtocolDirectorySnapshot {
40
+ readonly role: ManagedGcProtocolRole;
41
+ readonly path: string;
42
+ readonly dev: string;
43
+ readonly ino: string;
44
+ readonly mtimeNs: string;
45
+ readonly ctimeNs: string;
46
+ readonly mode: number;
47
+ readonly files: readonly ManagedGcProtocolFileSnapshot[];
48
+ }
49
+ /** Read-only protocol data; never a deletion capability. */
50
+ export interface ManagedGcProtocolScopeSnapshot {
51
+ readonly configuredRoot: ManagedGcProtocolPathIdentity;
52
+ readonly profile: ManagedGcProtocolPathIdentity;
53
+ readonly sessionsRoot: ManagedGcProtocolPathIdentity;
54
+ readonly scope: ManagedGcProtocolPathIdentity;
55
+ readonly binding: ManagedGcProtocolFileSnapshot;
56
+ readonly protocol: ManagedGcProtocolPathIdentity;
57
+ readonly protocolMtimeNs: string;
58
+ readonly protocolCtimeNs: string;
59
+ readonly protocolMode: number;
60
+ readonly directories: readonly ManagedGcProtocolDirectorySnapshot[];
61
+ }
62
+ export interface ManagedGcProtocolScopeInput {
63
+ readonly scopePath: string;
64
+ readonly scopeIdentity: ManagedGcProtocolPathIdentity;
65
+ readonly bindingIdentity: ManagedGcProtocolFileSnapshot;
66
+ readonly protocolIdentity: ManagedGcProtocolScopeSnapshot["protocol"] & {
67
+ readonly mtimeNs: string;
68
+ readonly ctimeNs: string;
69
+ readonly mode: number;
70
+ };
71
+ }
72
+ export type ManagedGcProtocolScopeInspector = (inputs: readonly ManagedGcProtocolScopeInput[]) => Promise<readonly ManagedGcProtocolScopeSnapshot[]>;
20
73
  /**
21
74
  * Opaque managed writer authority captured by a trusted destination. The open
22
75
  * transaction must use this authority rather than reacquiring its root from a
@@ -34,7 +87,7 @@ export declare function managedDirectoryIdentityForScope(scope: ManagedScope): {
34
87
  };
35
88
  export declare function managedRootForScope(scope: ManagedScope): ManagedDirectoryRoot;
36
89
  export type ManagedMigrationPolicy = "copy-retain" | "disabled";
37
- export type ManagedScopeErrorCode = "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid" | "migration_busy" | "atomic_unavailable" | "invalid_request" | "durability_failed" | "durability_not_provable" | "capacity_exceeded";
90
+ export type ManagedScopeErrorCode = "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid" | "migration_busy" | "managed_gc_journal_capacity_exceeded" | "atomic_unavailable" | "invalid_request" | "durability_failed" | "durability_not_provable" | "capacity_exceeded";
38
91
  export type ManagedScopeResolution = {
39
92
  kind: "resolved";
40
93
  scope: ManagedScope;
@@ -69,7 +122,7 @@ export type ManagedCandidateListing = {
69
122
  code: "scan_failed" | "unsafe_root" | "invalid_candidate";
70
123
  message: string;
71
124
  };
72
- export type ManagedOpenFailure = "migration_busy" | "binding_conflict" | "binding_invalid" | "destination_conflict" | "source_changed" | "unsafe_artifacts" | "artifact_capacity_exceeded" | "durability_failed" | "atomic_unavailable" | "invalid_request" | "durability_not_provable" | "migration_retired" | "legacy_migration_disabled" | "managed_storage_unsupported";
125
+ export type ManagedOpenFailure = "migration_busy" | "binding_conflict" | "binding_invalid" | "destination_conflict" | "source_changed" | "unsafe_artifacts" | "artifact_capacity_exceeded" | "managed_gc_journal_capacity_exceeded" | "durability_failed" | "atomic_unavailable" | "invalid_request" | "durability_not_provable" | "migration_retired" | "legacy_migration_disabled" | "managed_storage_unsupported";
73
126
  export type ManagedOpenCandidateResult = {
74
127
  kind: "opened";
75
128
  path: string;
@@ -132,6 +185,8 @@ interface ManagedScopeInput {
132
185
  export declare function resolveManagedScope(input: ManagedScopeInput): ManagedScopeResolution;
133
186
  /** Resolve a scope for a synchronous write without mutating an existing ACL mismatch. */
134
187
  export declare function resolveManagedScopeForWrite(input: ManagedScopeInput): ManagedScopeResolution;
188
+ /** Resolve only an existing, authenticated v2 scope; this path never initializes or repairs storage. */
189
+ export declare function resolveManagedGcScopeForRead(input: ManagedScopeInput): ManagedScopeResolution;
135
190
  export declare function canonicalBindingOpenFlags(platform?: NodeJS.Platform): number;
136
191
  export declare function fsyncCanonicalBinding(bindingPath: string, expected: string): void;
137
192
  export declare function ensureManagedScope(scope: ManagedScope, policy?: ManagedSessionSecurityPolicy): Promise<ManagedScopeResolution>;
@@ -201,6 +256,28 @@ export declare function isRecoverableOwnerOnlyModeDrift(error: unknown): boolean
201
256
  /** Synchronously create and validate the v2 binding before a default session writer exists. */
202
257
  export declare function prepareManagedSessionScopeForWriteSync(scope: ManagedScope, policy?: ManagedSessionSecurityPolicy, authority?: ManagedCandidateWriteAuthority): ManagedScopeResolution;
203
258
  export declare function listManagedCandidates(scope: ManagedScope): ManagedCandidateListing;
259
+ /** Build owner-storage authority only from a previously prepared trusted managed scope. */
260
+ export declare function taskArtifactOwnerStorageContextForScope(scope: ManagedScope): TaskArtifactOwnerStorageContext;
261
+ /** Bind the first transcript header through FileSessionStorage's descriptor-bound, no-follow snapshot. */
262
+ export declare function bindManagedGcSessionRetirementTarget(scope: ManagedScope, transcriptPathValue: string): ManagedGcSessionRetirementTarget;
263
+ /** Read the prepared authority first, then strictly validate every later receipt against it. */
264
+ export declare function readManagedGcSessionRetirementReceipt(scope: ManagedScope, transcriptPath: string): Promise<ManagedGcSessionRetirementReceipt | undefined>;
265
+ /** Read an authenticated journal without creating lock/receipt directories or repairing security state. */
266
+ export declare function readManagedGcSessionRetirementReceiptReadOnly(scope: ManagedScope, transcriptPath: string): Promise<ManagedGcSessionRetirementReceipt | undefined>;
267
+ /** Discover complete owner journals under authenticated existing v2 scopes without initializing storage. */
268
+ export declare function discoverManagedGcSessionRetirementReceipts(input: {
269
+ agentDir: string;
270
+ sessionsRoot: string;
271
+ }): Promise<readonly {
272
+ readonly scope: ManagedScope;
273
+ readonly receipt: ManagedGcSessionRetirementReceipt;
274
+ }[]>;
275
+ /** Inspect under a live operation lease; returned snapshots never authorize effects. */
276
+ export declare function managedGcProtocolInspectorForLock(scope: ManagedScope, lock: ManagedStorageLock): ManagedGcProtocolScopeInspector;
277
+ /** Bind a read-only protocol inventory to an already prepared scope's root/profile/session identities. */
278
+ export declare function managedGcProtocolScopeInspectorForScope(scope: ManagedScope): ManagedGcProtocolScopeInspector;
279
+ /** Atomically publish one journal state under the managed scope lock; no GC effects are activated here. */
280
+ export declare function publishManagedGcSessionRetirementReceipt(scope: ManagedScope, receipt: ManagedGcSessionRetirementReceipt): Promise<ManagedGcSessionRetirementReceipt>;
204
281
  export declare function artifactTreeReplayCompatible(observed: NativeDirectoryTreeSnapshot, expected: NativeDirectoryTreeSnapshot): boolean;
205
282
  type DetachedArtifactRoot = {
206
283
  originalPath: string;
@@ -5,6 +5,7 @@ export declare const MANAGED_ARTIFACT_MAX_DEPTH = 32;
5
5
  export declare const MANAGED_ARTIFACT_MAX_FILES = 50000;
6
6
  export declare const MANAGED_ARTIFACT_MAX_FILE_BYTES: number;
7
7
  export declare const MANAGED_ARTIFACT_MAX_TOTAL_BYTES: number;
8
+ export declare const MANAGED_SESSION_READ_RANGE_MAX_BYTES: number;
8
9
  export declare const MANAGED_ARTIFACT_COPY_BATCH_SIZE = 256;
9
10
  /** A pre-mutation append fence rejection: no bytes from this append were written. */
10
11
  export declare class ManagedAppendIdentityMismatchError extends Error {
@@ -104,6 +105,8 @@ export interface ManagedBoundedAppendExpectation {
104
105
  readonly ctimeNs: string;
105
106
  readonly sha256: string;
106
107
  }
108
+ /** Exact quarantine names used when native exact-unlink leaves a scrubbed lock inode. */
109
+ export declare function isManagedLockQuarantineName(name: string): boolean;
107
110
  export interface ScrubbedProtocolRemnantReapResult {
108
111
  readonly reaped: number;
109
112
  readonly failures: number;
@@ -135,6 +138,16 @@ export declare function reapScrubbedProtocolRemnantsSync(directory: string, minA
135
138
  */
136
139
  export declare function reapScrubbedProtocolRemnants(directory: string, minAgeMs?: number): Promise<ScrubbedProtocolRemnantReapResult>;
137
140
  export declare function validateNativeSecurityResult(value: unknown, operation: "apply" | "verify", kind: "directory" | "file"): NativeOwnerOnlySecurityResult;
141
+ export type LockRecord = {
142
+ attemptId: string;
143
+ pid: number;
144
+ bootId?: string;
145
+ processStartId: string;
146
+ createdAt: number;
147
+ heartbeatAt: number;
148
+ leaseExpiresAt: number;
149
+ released?: boolean;
150
+ };
138
151
  export interface ManagedLockRetirementTestEvent {
139
152
  readonly path: string;
140
153
  readonly attemptId: string;
@@ -168,13 +181,18 @@ export declare function retainManagedDirectoryAuthority(root: ManagedDirectoryRo
168
181
  }): RecoveryFsRoot | undefined;
169
182
  export declare function assertManagedDirectoryRoot(root: ManagedDirectoryRoot): void;
170
183
  export declare function managedSecurityFailureClassification(error: unknown): string | undefined;
184
+ /** Exact, identity-bound read access retained for the lifetime of one managed stream. */
185
+ export interface ManagedSessionReadLease {
186
+ readRange(start: number, length: number): Uint8Array;
187
+ close(): void;
188
+ }
171
189
  /** Internal retained-root capability for one managed descendant subtree. */
172
190
  export declare class ManagedSessionDescendantStore {
173
191
  #private;
174
192
  constructor(root: ManagedDirectoryRoot, baseDir: string, retained?: {
175
193
  authority: RecoveryFsRoot;
176
194
  authorityBaseDir: string;
177
- }, policy?: ManagedSessionSecurityPolicy, profileAgentDir?: string, expectedSubtreeRoot?: ManagedDirectoryRoot);
195
+ }, policy?: ManagedSessionSecurityPolicy, profileAgentDir?: string, expectedSubtreeRoot?: ManagedDirectoryRoot, access?: "read-only" | "read-write");
178
196
  get dir(): string;
179
197
  get rootAuthority(): ManagedDirectoryRoot;
180
198
  get subtreeRootAuthority(): ManagedDirectoryRoot;
@@ -223,8 +241,12 @@ export declare class ManagedSessionDescendantStore {
223
241
  * managed-session indexing without weakening pathname authority.
224
242
  */
225
243
  readRangeExpectedSync(relativePath: string, start: number, length: number, expectedDescriptor?: Pick<SessionStorageStat, "dev" | "ino" | "nlink" | "size" | "mtimeNs" | "ctimeNs">): SessionStorageRangeSnapshot;
244
+ /** Open an identity-bound stream lease; Darwin uses exact bounded range reads per chunk. */
245
+ openReadLease(relativePath: string, expectedDescriptor: Pick<SessionStorageStat, "dev" | "ino" | "nlink" | "size" | "mtimeNs" | "ctimeNs">): ManagedSessionReadLease;
226
246
  /** Read an exact managed file without exposing its pathname as authority. */
227
247
  readExpected(relativePath: string): ManagedFileSnapshot | null;
248
+ /** Read one complete managed file through retained authority after descriptor-size admission. */
249
+ readExpectedBounded(relativePath: string, maxBytes: number, admitSize?: (size: number, descriptor: ManagedFileIdentity) => void): ManagedFileSnapshot | null;
228
250
  /** Remove an exact captured file without reopening its pathname as authority. */
229
251
  removeExpected(relativePath: string, expected: ManagedFileSnapshot): void;
230
252
  /** Remove one exact file without allocating its contents. */
@@ -253,10 +275,13 @@ export declare class ManagedSessionDescendantStore {
253
275
  fsyncTree(): NativeDirectoryTreeSnapshot;
254
276
  }
255
277
  export declare function shouldFsyncManagedDirectory(platform?: NodeJS.Platform): boolean;
278
+ export declare function parseManagedLockRecord(bytes: Uint8Array): LockRecord | undefined;
256
279
  /** Create a managed directory and fail closed unless its owner-only mode/ACL verifies. */
257
280
  export declare function ensureManagedDirectory(pathname: string, root?: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): void;
258
281
  /** Captures a bounded prefix from one no-follow descriptor and rechecks the pathname before use. */
259
282
  export declare function captureManagedFilePrefixNoFollow(pathname: string, maxBytes: number): ManagedFileSnapshot;
283
+ /** Captures a complete no-follow file only after descriptor-size admission and before allocating its bytes. */
284
+ export declare function captureManagedFileNoFollowBounded(pathname: string, maxBytes: number, admitSize?: (size: number, descriptor: ManagedFileIdentity) => void): ManagedFileSnapshot;
260
285
  /** Captures header/hash/copy input from one no-follow descriptor and rechecks the pathname before use. */
261
286
  export declare function captureManagedFileNoFollow(pathname: string): ManagedFileSnapshot;
262
287
  /** Streams a managed file once while retaining only a bounded header prefix and the full descriptor-bound digest. */
@@ -0,0 +1,62 @@
1
+ import type { ResumeSessionIdentity } from "../session-manager";
2
+ import { type VerifiedSessionDeleteResult, type VerifiedSessionDeleteTarget } from "../session-storage";
3
+ import type { TaskArtifactOwnerDeletionEvidence, TaskArtifactOwnerStorageContext } from "../task-artifact-owner-codec";
4
+ import type { ManagedGcSessionRetirementReceipt, ManagedGcSessionRetirementTarget } from "./managed-gc-retirement-codec";
5
+ import type { ManagedGcProtocolScopeInspector } from "./managed-session-scope";
6
+ export interface ManagedGcOwnerCleanupTarget {
7
+ readonly path: string;
8
+ readonly sessionId: string;
9
+ readonly cwd: string;
10
+ readonly identity: ResumeSessionIdentity;
11
+ readonly taskArtifactOwnerDeletionEvidence?: TaskArtifactOwnerDeletionEvidence;
12
+ }
13
+ /** Authenticated receipt operations and fencing supplied by the prepared managed scope. */
14
+ export interface ManagedGcOwnerCleanupAuthority {
15
+ readonly agentDir: string;
16
+ readonly sessionsRoot: string;
17
+ readonly directoryPath: string;
18
+ readonly storageContext: TaskArtifactOwnerStorageContext;
19
+ readonly inspectProtocol: ManagedGcProtocolScopeInspector;
20
+ readonly assertOwned: () => void;
21
+ readonly bindTarget: (transcriptPath: string) => ManagedGcSessionRetirementTarget;
22
+ readonly readReceipt: (transcriptPath: string) => Promise<ManagedGcSessionRetirementReceipt | undefined>;
23
+ readonly publishReceipt: (receipt: ManagedGcSessionRetirementReceipt) => Promise<ManagedGcSessionRetirementReceipt>;
24
+ readonly findCompletedRetirement: (evidence: TaskArtifactOwnerDeletionEvidence, exceptTranscriptPath: string) => Promise<{
25
+ scope: {
26
+ readonly agentDir: string;
27
+ readonly sessionsRoot: string;
28
+ readonly directoryPath: string;
29
+ };
30
+ receipt: ManagedGcSessionRetirementReceipt;
31
+ } | undefined>;
32
+ }
33
+ export type ManagedGcOwnerProgress = {
34
+ readonly state: "none" | "owner_retired" | "payload_retired" | "pending";
35
+ readonly message?: string;
36
+ };
37
+ export type ManagedGcOwnerDeleteFields = Pick<VerifiedSessionDeleteTarget, "taskArtifactOwnerStorageContext" | "taskArtifactOwnerDeletionEvidence" | "taskArtifactOwnerRetirementOutcome" | "taskArtifactOwnerRetirementContinuation" | "taskArtifactOwnerPayloadRetired" | "taskArtifactOwnerNamespaceRetained" | "deferTaskArtifactOwnerRetirement" | "taskArtifactOwnerRetired">;
38
+ export declare function hasUnsupportedLegacyOwnerTarget(scopeDirectory: string, target: ManagedGcOwnerCleanupTarget): boolean;
39
+ export declare function prepareManagedGcOwnerTarget<T extends ManagedGcOwnerCleanupTarget>(authority: ManagedGcOwnerCleanupAuthority, target: T): Promise<T & ManagedGcOwnerCleanupTarget>;
40
+ export declare function prepareManagedGcOwnerTargets<T extends ManagedGcOwnerCleanupTarget>(authority: ManagedGcOwnerCleanupAuthority, targets: readonly T[]): Promise<(T & ManagedGcOwnerCleanupTarget)[]>;
41
+ export declare function managedGcOwnerDeleteFields(authority: ManagedGcOwnerCleanupAuthority, target: ManagedGcOwnerCleanupTarget): Promise<ManagedGcOwnerDeleteFields>;
42
+ export declare function publishManagedGcArtifactsRemoved(authority: ManagedGcOwnerCleanupAuthority, target: ManagedGcOwnerCleanupTarget): Promise<ManagedGcSessionRetirementReceipt | undefined>;
43
+ export declare function retireManagedGcOwnerAfterArtifacts(authority: ManagedGcOwnerCleanupAuthority, target: ManagedGcOwnerCleanupTarget, tombstoneTargets: readonly ManagedGcOwnerCleanupTarget[]): Promise<ManagedGcOwnerProgress>;
44
+ export declare function persistManagedGcStorageOwnerDisposition(authority: ManagedGcOwnerCleanupAuthority, target: ManagedGcOwnerCleanupTarget, deletion: Extract<VerifiedSessionDeleteResult, {
45
+ kind: "cleanup_pending";
46
+ phase: "task_artifact_owner";
47
+ }>): Promise<ManagedGcOwnerProgress>;
48
+ export declare function managedGcOwnerProgressBeforeDelete(authority: ManagedGcOwnerCleanupAuthority, target: ManagedGcOwnerCleanupTarget, tombstoneTargets: readonly ManagedGcOwnerCleanupTarget[], artifactsRemoved: boolean): Promise<ManagedGcOwnerProgress>;
49
+ export declare function taskArtifactOwnerTranscriptResult(authority: ManagedGcOwnerCleanupAuthority, target: ManagedGcOwnerCleanupTarget): Promise<"none" | "retired" | "payload_retired">;
50
+ export interface ManagedGcOwnerTranscriptDeleteReceipt {
51
+ readonly taskArtifactOwnerTranscriptDeleted?: true;
52
+ }
53
+ export declare function persistManagedGcOwnerTranscriptDeletion<T extends ManagedGcOwnerTranscriptDeleteReceipt>(input: {
54
+ target: ManagedGcOwnerCleanupTarget;
55
+ fallback: T;
56
+ deletion: Extract<VerifiedSessionDeleteResult, {
57
+ kind: "deleted";
58
+ }>;
59
+ readLatest: () => T | undefined;
60
+ nextReceipt: (latest: T) => T;
61
+ publishPending: (receipt: T) => Promise<void>;
62
+ }): Promise<void>;
@@ -5,6 +5,8 @@ export interface OwnerManifest extends TaskArtifactOwnerLocator {
5
5
  readonly sessionId: string;
6
6
  }
7
7
  export declare function newSessionRootStore(context: TaskArtifactOwnerStorageContext): ManagedSessionDescendantStore;
8
+ /** Path-backed reader with no retained or recovery-mutable native authority. */
9
+ export declare function newSessionRootReaderStore(context: TaskArtifactOwnerStorageContext): ManagedSessionDescendantStore;
8
10
  export declare function readOwnerManifest(store: ManagedSessionDescendantStore, locator: TaskArtifactOwnerLocator, relativePath?: string): OwnerManifest;
9
11
  export declare function assertOwnerDirectoryExists(context: TaskArtifactOwnerStorageContext, ownerId: string): void;
10
12
  export declare function assertOwnerIdentity(store: ManagedSessionDescendantStore, locator: TaskArtifactOwnerLocator): void;
@@ -1,3 +1,11 @@
1
- import { type TaskArtifactOwnerLocator } from "../task-artifact-owner-codec";
1
+ import type { FileSessionStorage } from "../session-storage";
2
+ import { type TaskArtifactOwnerLocator, type TaskArtifactOwnerStorageContext } from "../task-artifact-owner-codec";
3
+ import type { ManagedGcProtocolScopeInspector } from "./managed-session-scope";
2
4
  /** Resolve the path-free owner locator using transcript replay's header-patch semantics. */
3
5
  export declare function taskArtifactOwnerLocatorFromTranscriptBytes(bytes: Uint8Array, expectedSessionId: string): TaskArtifactOwnerLocator | undefined;
6
+ /**
7
+ * Read-only inventory of every authenticated managed cwd directory under one profile's
8
+ * sessions root. Any incomplete, replaced, or unrecognized inventory conservatively
9
+ * blocks owner retirement.
10
+ */
11
+ export declare function hasSiblingTaskArtifactOwnerTranscript(storage: Pick<FileSessionStorage, "readSnapshotSync">, transcriptPath: string, locator: TaskArtifactOwnerLocator, context: TaskArtifactOwnerStorageContext, inspectProtocol?: ManagedGcProtocolScopeInspector): Promise<boolean>;
@@ -638,6 +638,21 @@ export interface ResumeSessionIdentity {
638
638
  ctimeNs?: bigint;
639
639
  sha256: string;
640
640
  }
641
+ /** Descriptor-bound bounded fingerprint for private explicit-session rollback authority.
642
+ * JSON-safe: all bigint fields are stored as strings to survive JSON serialization,
643
+ * spread, structuredClone, and JSON round-trip. */
644
+ export type ExplicitPersistIdentity = {
645
+ dev: string;
646
+ ino: string;
647
+ nlink?: string;
648
+ size: number;
649
+ mtimeMs: number;
650
+ mtimeNs: string;
651
+ ctimeNs?: string;
652
+ canonicalPath: string;
653
+ sessionId: string;
654
+ fingerprintSha256: string;
655
+ };
641
656
  export interface ResumeTailResumable {
642
657
  kind: "resumable";
643
658
  identity: ResumeSessionIdentity;
@@ -953,7 +968,8 @@ export interface ReadonlySessionManager {
953
968
  /** Creates an immutable facade that never exposes SessionManager mutation authority. */
954
969
  export declare function createReadonlySessionManager(manager: SessionManager): ReadonlySessionManager;
955
970
  /** Internal artifact-writing capability. Read-only facades expose it only through a private weak-map lookup. */
956
- export type SessionArtifactCapability = Readonly<Pick<SessionManager, "allocateArtifactPath" | "saveArtifact" | "putBlob">>;
971
+ export type SessionArtifactPublication = (content: string, toolType: string) => Promise<string | undefined>;
972
+ export type SessionArtifactCapability = Readonly<Pick<SessionManager, "allocateArtifactPath" | "saveArtifact" | "putBlob" | "captureArtifactPublication">>;
957
973
  /**
958
974
  * Returns the artifact capability for a concrete persistence owner or one of its
959
975
  * immutable read-only facades. Structural lookalikes remain unauthorized.
@@ -1038,6 +1054,8 @@ export declare function materializeResidentEntriesThrowingForTests<T>(entries: T
1038
1054
  sessionFile?: string;
1039
1055
  }): T[];
1040
1056
  export declare function materializeResidentEntriesForPersistenceForTests<T>(entries: T[], textStore: BlobStore, imageStore?: BlobStore): T[];
1057
+ export declare function isProjectSessionTranscriptPath(projectGjcDir: string, filePath: string): boolean;
1058
+ export declare function readAuthorizedProjectSessionTranscript(projectGjcDir: string, filePath: string, maxBytes: number): Buffer | undefined;
1041
1059
  /**
1042
1060
  * Discover resumable transcripts intentionally stored inside a project's `.gjc`.
1043
1061
  * Runtime token/audit JSONL files are excluded by requiring a known transcript
@@ -1084,10 +1102,12 @@ interface SessionManagerStateSnapshot {
1084
1102
  flushed: boolean;
1085
1103
  ensuredOnDisk: boolean;
1086
1104
  needsFullRewriteOnNextPersist: boolean;
1087
- fileEntries: FileEntry[];
1088
- materializedFileEntries: FileEntry[];
1105
+ fileEntries: readonly FileEntry[];
1106
+ materializedFileEntries: readonly FileEntry[];
1089
1107
  adoptedArtifactManager: ArtifactManager | null;
1090
1108
  coldRestoreFile?: string;
1109
+ /** Explicit persistence identity for snapshot serialization safety. Preserved across cross-manager adoptions. */
1110
+ readonly explicitPersistIdentity?: ExplicitPersistIdentity;
1091
1111
  }
1092
1112
  /** Benchmark-derived cap for strong materialized session snapshots. */
1093
1113
  export declare const MATERIALIZED_CACHE_MAX_BYTES: number;
@@ -1109,6 +1129,7 @@ export declare const SessionManagerTestHooks: {
1109
1129
  beforeManagedMissingReturn?: (filePath: string, storage: SessionStorage) => void | Promise<void>;
1110
1130
  afterManagedMissingAssertion?: (filePath: string, storage: SessionStorage) => void | Promise<void>;
1111
1131
  beforeManagedSwitchIdentity?: (filePath: string, storage: SessionStorage) => void | Promise<void>;
1132
+ beforeColdRollbackCommit?: (filePath: string, storage: SessionStorage) => void | Promise<void>;
1112
1133
  /** Internal first-open GC strategy override; omitted means current. */
1113
1134
  firstOpenGcStrategy?: SessionMemoryGcStrategy;
1114
1135
  /** Internal first-open secondary-artifact mode override; omitted means auto. */
@@ -1428,8 +1449,11 @@ export declare class SessionManager {
1428
1449
  * one bound to the current session file unless an external manager was
1429
1450
  * adopted via `adoptArtifactManager`. Falls back to the lazily created
1430
1451
  * ephemeral filesystem store once a non-persistent session has saved an
1431
- * artifact, so `artifact://` stays resolvable. Returns null only when no
1432
- * store has been established yet.
1452
+ * artifact, so `artifact://` stays resolvable. Returns null when no store has
1453
+ * been established yet and once the manager has released its artifact
1454
+ * authority while closing — released authority stays observable as absence
1455
+ * (matching `isArtifactManagerAuthorized`), while artifact *operations* are
1456
+ * fenced by `#assertArtifactOpen()` and keep throwing.
1433
1457
  */
1434
1458
  getArtifactManager(): ArtifactManager | null;
1435
1459
  /** Linearizably establish this session's persistent or ephemeral artifact manager. */
@@ -1449,6 +1473,8 @@ export declare class SessionManager {
1449
1473
  * read back from the filesystem instead of being retained in memory.
1450
1474
  */
1451
1475
  saveArtifact(content: string, toolType: string): Promise<string | undefined>;
1476
+ /** Capture artifact publication authority for one session lifecycle. */
1477
+ captureArtifactPublication(): SessionArtifactPublication;
1452
1478
  /** Inspect an evicted artifact using a bounded range read; never rehydrates by default. */
1453
1479
  inspectEvictedToolOutput(handle: unknown, range?: {
1454
1480
  start?: number;
@@ -1,4 +1,10 @@
1
+ import type { ManagedGcSessionRetirementReceipt } from "./internal/managed-gc-retirement-codec";
2
+ import { type ManagedScope } from "./internal/managed-session-scope";
1
3
  import { type FileSessionStorage } from "./session-storage";
4
+ import type { TaskArtifactOwnerDeletionEvidence, TaskArtifactOwnerRetirementContinuation, TaskArtifactOwnerRetirementOutcome } from "./task-artifact-owner-codec";
5
+ export interface SessionRetirementContinuation {
6
+ readonly managedScope: ManagedScope;
7
+ }
2
8
  /**
3
9
  * Outcome of a disk-retention retirement attempt.
4
10
  *
@@ -11,12 +17,34 @@ import { type FileSessionStorage } from "./session-storage";
11
17
  */
12
18
  export type SessionRetirementOutcome = {
13
19
  kind: "retired";
20
+ taskArtifactOwnerRetired?: true;
14
21
  } | {
15
22
  kind: "kept";
16
23
  reason: string;
17
24
  } | {
18
25
  kind: "cleanup_pending";
19
26
  reason: string;
27
+ phase?: "artifacts" | "transcript";
28
+ taskArtifactOwnerDeletionEvidence?: TaskArtifactOwnerDeletionEvidence;
29
+ taskArtifactOwnerRetirementOutcome?: TaskArtifactOwnerRetirementOutcome;
30
+ taskArtifactOwnerRetirementContinuation?: TaskArtifactOwnerRetirementContinuation;
31
+ taskArtifactOwnerPayloadRetired?: true;
32
+ taskArtifactOwnerNamespaceRetained?: true;
33
+ taskArtifactOwnerRetired?: true;
34
+ };
35
+ export type SessionRetirementProbeOutcome = Extract<SessionRetirementOutcome, {
36
+ kind: "cleanup_pending";
37
+ }> | {
38
+ kind: "retirable";
39
+ taskArtifactOwnerDeletionEvidence?: TaskArtifactOwnerDeletionEvidence;
40
+ taskArtifactOwnerRetirementOutcome?: TaskArtifactOwnerRetirementOutcome;
41
+ taskArtifactOwnerRetired?: true;
42
+ taskArtifactOwnerRetirementContinuation?: TaskArtifactOwnerRetirementContinuation;
43
+ taskArtifactOwnerPayloadRetired?: true;
44
+ taskArtifactOwnerNamespaceRetained?: true;
45
+ } | {
46
+ kind: "kept";
47
+ reason: string;
20
48
  };
21
49
  /**
22
50
  * Non-mutating projection of {@link retireSessionTranscript}: would the
@@ -27,12 +55,8 @@ export type SessionRetirementOutcome = {
27
55
  * authority's verdict (containment, identity, artifact tree) is deliberately
28
56
  * not predicted here — it is re-derived against live state at delete time.
29
57
  */
30
- export declare function probeSessionRetirement(storage: FileSessionStorage, sessionsRoot: string, transcriptPath: string): {
31
- kind: "retirable";
32
- } | {
33
- kind: "kept";
34
- reason: string;
35
- };
58
+ export declare function probeSessionRetirement(storage: FileSessionStorage, sessionsRoot: string, transcriptPath: string, continuation?: SessionRetirementContinuation): Promise<SessionRetirementProbeOutcome>;
59
+ export declare function retireOrphanSessionTranscript(storage: FileSessionStorage, sessionsRoot: string, continuation: SessionRetirementContinuation, receipt: ManagedGcSessionRetirementReceipt): Promise<SessionRetirementOutcome>;
36
60
  /**
37
61
  * Retire one managed session transcript through the verified hard-delete
38
62
  * authority.
@@ -44,4 +68,4 @@ export declare function probeSessionRetirement(storage: FileSessionStorage, sess
44
68
  * caller owns the retention policy; this function owns nothing but the delete
45
69
  * authority.
46
70
  */
47
- export declare function retireSessionTranscript(storage: FileSessionStorage, sessionsRoot: string, transcriptPath: string): Promise<SessionRetirementOutcome>;
71
+ export declare function retireSessionTranscript(storage: FileSessionStorage, sessionsRoot: string, transcriptPath: string, continuation?: SessionRetirementContinuation): Promise<SessionRetirementOutcome>;