@gajae-code/coding-agent 0.19.3-nightly.20261030094347.41301593972.gf536b1010d4e → 0.19.3

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 (273) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/dist/types/async/job-manager.d.ts +56 -18
  3. package/dist/types/cli/auth-token-file.d.ts +9 -0
  4. package/dist/types/cli/doctor/install-repairs.d.ts +1 -0
  5. package/dist/types/cli/doctor/types.d.ts +1 -0
  6. package/dist/types/cli/install-activation.d.ts +10 -1
  7. package/dist/types/cli/malloc-env-guard.d.ts +8 -0
  8. package/dist/types/cli/update-cli.d.ts +4 -1
  9. package/dist/types/config/atomic-yaml-patch.d.ts +34 -1
  10. package/dist/types/config/model-profile-activation.d.ts +40 -13
  11. package/dist/types/config/model-registry.d.ts +3 -0
  12. package/dist/types/config/models-config-schema.d.ts +4 -0
  13. package/dist/types/config/settings-schema.d.ts +49 -8
  14. package/dist/types/config/settings.d.ts +39 -5
  15. package/dist/types/config/task-delegation.d.ts +2 -0
  16. package/dist/types/extensibility/extensions/runner.d.ts +2 -0
  17. package/dist/types/extensibility/slash-commands.d.ts +14 -1
  18. package/dist/types/gjc-runtime/managed-owner-admission.d.ts +4 -12
  19. package/dist/types/gjc-runtime/managed-owner-binding.d.ts +164 -0
  20. package/dist/types/gjc-runtime/managed-owner-supervisor.d.ts +26 -33
  21. package/dist/types/gjc-runtime/owner-lifecycle-path.d.ts +21 -0
  22. package/dist/types/gjc-runtime/owner-lifecycle-root.d.ts +7 -0
  23. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +8 -1
  24. package/dist/types/gjc-runtime/tmux-common.d.ts +10 -0
  25. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +131 -5
  26. package/dist/types/gjc-runtime/tmux-sessions.d.ts +46 -0
  27. package/dist/types/gjc-runtime/ultragoal-owner-loss-recovery.d.ts +1 -1
  28. package/dist/types/harness-control-plane/session-lease.d.ts +29 -2
  29. package/dist/types/harness-control-plane/storage.d.ts +8 -0
  30. package/dist/types/main.d.ts +12 -0
  31. package/dist/types/memories/index.d.ts +7 -1
  32. package/dist/types/memories/storage.d.ts +1 -0
  33. package/dist/types/memory-backend/types.d.ts +6 -1
  34. package/dist/types/modes/components/model-selector.d.ts +11 -4
  35. package/dist/types/modes/components/notifications-settings-editor.d.ts +2 -166
  36. package/dist/types/modes/components/settings-defs.d.ts +2 -1
  37. package/dist/types/modes/components/settings-selector.d.ts +5 -2
  38. package/dist/types/modes/components/smart-routing-panel.d.ts +19 -14
  39. package/dist/types/modes/components/tool-execution.d.ts +6 -0
  40. package/dist/types/modes/controllers/goal-mode-controller.d.ts +5 -0
  41. package/dist/types/modes/controllers/selector-controller.d.ts +7 -59
  42. package/dist/types/plan-mode/state.d.ts +7 -0
  43. package/dist/types/runtime-mcp/config.d.ts +8 -0
  44. package/dist/types/runtime-mcp/manager.d.ts +43 -0
  45. package/dist/types/runtime-mcp/session-controls-grant.d.ts +7 -0
  46. package/dist/types/sdk/broker/broker.d.ts +33 -7
  47. package/dist/types/sdk/broker/lifecycle.d.ts +1 -0
  48. package/dist/types/sdk/broker/session-index.d.ts +2 -0
  49. package/dist/types/sdk/broker/session-scope.d.ts +31 -1
  50. package/dist/types/sdk/broker/spawn-authority.d.ts +19 -0
  51. package/dist/types/sdk/broker/spawn-substrate.d.ts +12 -1
  52. package/dist/types/sdk/bus/index.d.ts +5 -0
  53. package/dist/types/sdk/bus/notification-orchestration.d.ts +21 -3
  54. package/dist/types/sdk/bus/notification-service.d.ts +2 -1
  55. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
  56. package/dist/types/sdk/cli/rows.d.ts +7 -0
  57. package/dist/types/sdk/extension-interaction.d.ts +108 -0
  58. package/dist/types/sdk/host/control/btw-ask.d.ts +19 -0
  59. package/dist/types/sdk/host/control/dispatch.d.ts +2 -0
  60. package/dist/types/sdk/host/control/index.d.ts +1 -0
  61. package/dist/types/sdk/host/control/operations.d.ts +7 -0
  62. package/dist/types/sdk/host/external-permissions.d.ts +47 -0
  63. package/dist/types/sdk/host/host.d.ts +8 -2
  64. package/dist/types/sdk/host/query/handlers.d.ts +1 -0
  65. package/dist/types/sdk/host/session-runtime.d.ts +13 -1
  66. package/dist/types/sdk/host/surface-policy.d.ts +2 -1
  67. package/dist/types/sdk/index.d.ts +11 -0
  68. package/dist/types/sdk/job-observation.d.ts +51 -0
  69. package/dist/types/sdk/lifecycle/service.d.ts +6 -1
  70. package/dist/types/sdk/notification-setup-contract.d.ts +169 -0
  71. package/dist/types/sdk/notification-setup.d.ts +54 -0
  72. package/dist/types/sdk/protocol/adapter-validation.d.ts +2 -0
  73. package/dist/types/sdk/router/session-router.d.ts +5 -0
  74. package/dist/types/sdk/routing-settings.d.ts +57 -0
  75. package/dist/types/sdk/session-list.d.ts +5 -0
  76. package/dist/types/sdk/session-recap.d.ts +50 -0
  77. package/dist/types/sdk/session.d.ts +14 -0
  78. package/dist/types/sdk/settings-catalog.d.ts +52 -0
  79. package/dist/types/sdk/workflow-gates.d.ts +9 -0
  80. package/dist/types/session/agent-session.d.ts +129 -15
  81. package/dist/types/session/client-bridge.d.ts +1 -0
  82. package/dist/types/session/internal/managed-session-storage.d.ts +6 -0
  83. package/dist/types/session/recap.d.ts +104 -0
  84. package/dist/types/session/session-manager.d.ts +51 -1
  85. package/dist/types/session/streaming-output.d.ts +9 -1
  86. package/dist/types/session/workflow-recovery-field-fence.d.ts +4 -0
  87. package/dist/types/session/yield-queue.d.ts +16 -0
  88. package/dist/types/task/executor.d.ts +2 -0
  89. package/dist/types/tools/auto-generated-guard.d.ts +8 -1
  90. package/dist/types/tools/bash.d.ts +1 -1
  91. package/dist/types/tools/grouped-file-tree.d.ts +21 -0
  92. package/dist/types/tools/image-gen.d.ts +6 -1
  93. package/dist/types/tools/index.d.ts +7 -0
  94. package/dist/types/tui/file-list.d.ts +0 -3
  95. package/dist/types/utils/gh.d.ts +5 -0
  96. package/dist/types/utils/herdr-core-status.d.ts +31 -0
  97. package/dist/types/utils/herdr-pane.d.ts +7 -0
  98. package/dist/types/utils/recap-generator.d.ts +41 -0
  99. package/dist/types/web/hardened-http.d.ts +41 -0
  100. package/dist/types/web/insane/url-guard.d.ts +2 -0
  101. package/package.json +7 -7
  102. package/scripts/generate-sdk-operation-inventory.ts +28 -1
  103. package/src/async/job-manager.ts +381 -41
  104. package/src/cli/auth-broker-cli.ts +11 -53
  105. package/src/cli/auth-gateway-cli.ts +13 -56
  106. package/src/cli/auth-token-file.ts +56 -0
  107. package/src/cli/customize-doctor.ts +40 -27
  108. package/src/cli/doctor/install-repairs.ts +36 -2
  109. package/src/cli/doctor/repairs.ts +1 -0
  110. package/src/cli/doctor/report.ts +2 -0
  111. package/src/cli/doctor/types.ts +1 -0
  112. package/src/cli/install-activation.ts +58 -1
  113. package/src/cli/malloc-env-guard.ts +11 -0
  114. package/src/cli/session-picker.ts +8 -2
  115. package/src/cli/setup-cli.ts +2 -0
  116. package/src/cli/update-cli.ts +48 -3
  117. package/src/cli-main.ts +2 -2
  118. package/src/cli-ordinary.ts +2 -2
  119. package/src/commands/harness.ts +16 -3
  120. package/src/config/atomic-yaml-patch.ts +439 -141
  121. package/src/config/machine-identity.ts +6 -2
  122. package/src/config/mcp-schema.json +1 -1
  123. package/src/config/model-profile-activation.ts +505 -248
  124. package/src/config/model-registry.ts +54 -2
  125. package/src/config/models-config-schema.ts +2 -0
  126. package/src/config/settings-schema.ts +52 -8
  127. package/src/config/settings.ts +640 -237
  128. package/src/config/task-delegation.ts +4 -1
  129. package/src/coordinator-mcp/question-gate-codec.ts +17 -5
  130. package/src/coordinator-mcp/server.ts +2 -0
  131. package/src/extensibility/extensions/runner.ts +6 -0
  132. package/src/extensibility/gjc-plugins/installer.ts +2 -1
  133. package/src/extensibility/plugins/marketplace/fetcher.ts +28 -119
  134. package/src/extensibility/slash-commands.ts +90 -16
  135. package/src/gjc-runtime/launch-tmux.ts +79 -23
  136. package/src/gjc-runtime/launch-worktree.ts +15 -3
  137. package/src/gjc-runtime/managed-owner-admission.ts +298 -212
  138. package/src/gjc-runtime/managed-owner-binding.ts +410 -0
  139. package/src/gjc-runtime/managed-owner-supervisor.ts +265 -112
  140. package/src/gjc-runtime/owner-lifecycle-path.ts +82 -0
  141. package/src/gjc-runtime/owner-lifecycle-root.ts +26 -0
  142. package/src/gjc-runtime/ralplan-current-final.ts +35 -15
  143. package/src/gjc-runtime/ralplan-runtime.ts +3 -0
  144. package/src/gjc-runtime/session-state-sidecar.ts +61 -28
  145. package/src/gjc-runtime/tmux-common.ts +28 -0
  146. package/src/gjc-runtime/tmux-owner-isolation.ts +1100 -111
  147. package/src/gjc-runtime/tmux-sessions.ts +293 -58
  148. package/src/gjc-runtime/ultragoal-change-set.ts +8 -1
  149. package/src/gjc-runtime/ultragoal-owner-loss-recovery.ts +1 -1
  150. package/src/harness-control-plane/finalize.ts +2 -0
  151. package/src/harness-control-plane/owner.ts +23 -1
  152. package/src/harness-control-plane/preserve.ts +7 -1
  153. package/src/harness-control-plane/session-lease.ts +357 -3
  154. package/src/harness-control-plane/storage.ts +61 -10
  155. package/src/hashline/execute.ts +13 -1
  156. package/src/internal-urls/docs-index.generated.ts +12 -12
  157. package/src/lsp/lspmux.ts +4 -0
  158. package/src/main.ts +44 -3
  159. package/src/master-mode/snapshot.ts +13 -1
  160. package/src/memories/index.ts +8 -1
  161. package/src/memories/storage.ts +1 -0
  162. package/src/memory-backend/types.ts +6 -1
  163. package/src/modes/acp/acp-agent.ts +28 -4
  164. package/src/modes/components/gjc-bundle-settings.ts +56 -14
  165. package/src/modes/components/model-selector.ts +98 -18
  166. package/src/modes/components/notifications-settings-editor.ts +68 -188
  167. package/src/modes/components/session-selector.ts +27 -5
  168. package/src/modes/components/settings-defs.ts +4 -10
  169. package/src/modes/components/settings-selector.ts +93 -66
  170. package/src/modes/components/smart-routing-panel.ts +363 -48
  171. package/src/modes/components/tool-execution.ts +388 -9
  172. package/src/modes/controllers/event-controller.ts +2 -1
  173. package/src/modes/controllers/extension-ui-controller.ts +2 -1
  174. package/src/modes/controllers/goal-mode-controller.ts +24 -0
  175. package/src/modes/controllers/plan-mode-controller.ts +11 -3
  176. package/src/modes/controllers/selector-controller.ts +127 -1242
  177. package/src/modes/interactive-mode.ts +44 -3
  178. package/src/modes/runtime-init.ts +2 -1
  179. package/src/modes/shared/agent-wire/approval-gate.ts +13 -2
  180. package/src/modes/shared/agent-wire/deep-interview-gate.ts +2 -4
  181. package/src/plan-mode/state.ts +17 -0
  182. package/src/prompts/system/master-mode.md +2 -0
  183. package/src/prompts/system/recap-system.md +5 -0
  184. package/src/prompts/system/system-prompt.md +5 -1
  185. package/src/prompts/tools/ask.md +4 -3
  186. package/src/runtime-mcp/config.ts +20 -1
  187. package/src/runtime-mcp/manager.ts +588 -45
  188. package/src/runtime-mcp/session-controls-grant.ts +24 -0
  189. package/src/sdk/acp/adapter.ts +14 -3
  190. package/src/sdk/broker/broker.ts +237 -23
  191. package/src/sdk/broker/lifecycle.ts +2 -0
  192. package/src/sdk/broker/session-index.ts +93 -19
  193. package/src/sdk/broker/session-scope.ts +81 -2
  194. package/src/sdk/broker/spawn-authority.ts +34 -5
  195. package/src/sdk/broker/spawn-substrate.ts +117 -18
  196. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  197. package/src/sdk/bus/index.ts +77 -11
  198. package/src/sdk/bus/notification-orchestration.ts +141 -59
  199. package/src/sdk/bus/notification-service.ts +25 -23
  200. package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
  201. package/src/sdk/cli/master-cli.ts +2 -2
  202. package/src/sdk/cli/rows.ts +9 -0
  203. package/src/sdk/cli/session-cli.ts +29 -4
  204. package/src/sdk/extension-interaction.ts +533 -0
  205. package/src/sdk/host/control/btw-ask.ts +49 -0
  206. package/src/sdk/host/control/dispatch.ts +12 -0
  207. package/src/sdk/host/control/index.ts +1 -0
  208. package/src/sdk/host/control/operations.ts +7 -0
  209. package/src/sdk/host/external-permissions.ts +332 -0
  210. package/src/sdk/host/host.ts +8 -2
  211. package/src/sdk/host/query/handlers.ts +9 -0
  212. package/src/sdk/host/sdk-surface-parity.test.ts +55 -1
  213. package/src/sdk/host/session-runtime.test.ts +142 -1
  214. package/src/sdk/host/session-runtime.ts +108 -28
  215. package/src/sdk/host/surface-policy.ts +11 -0
  216. package/src/sdk/index.ts +15 -0
  217. package/src/sdk/job-observation.ts +157 -0
  218. package/src/sdk/lifecycle/service.ts +15 -2
  219. package/src/sdk/notification-setup-contract.ts +181 -0
  220. package/src/sdk/notification-setup.ts +1151 -0
  221. package/src/sdk/protocol/adapter-validation.ts +6 -1
  222. package/src/sdk/protocol/operation-inventory.generated.json +239 -6
  223. package/src/sdk/protocol/operation-registry.ts +21 -3
  224. package/src/sdk/router/session-router.ts +12 -1
  225. package/src/sdk/routing-settings.ts +395 -0
  226. package/src/sdk/session-list.ts +37 -0
  227. package/src/sdk/session-recap.ts +121 -0
  228. package/src/sdk/session.ts +335 -23
  229. package/src/sdk/settings-catalog.ts +119 -0
  230. package/src/sdk/workflow-gates.ts +30 -0
  231. package/src/session/agent-session.ts +1880 -238
  232. package/src/session/client-bridge.ts +1 -1
  233. package/src/session/contribution-prep.ts +8 -1
  234. package/src/session/internal/managed-session-storage.ts +17 -3
  235. package/src/session/recap.ts +298 -0
  236. package/src/session/session-manager.ts +776 -121
  237. package/src/session/streaming-output.ts +69 -9
  238. package/src/session/workflow-recovery-field-fence.ts +27 -0
  239. package/src/session/yield-queue.ts +52 -1
  240. package/src/setup/provider-presets.json +3 -1
  241. package/src/slash-commands/builtin-registry.ts +124 -4
  242. package/src/ssh/connection-manager.ts +3 -2
  243. package/src/ssh/ssh-executor.ts +3 -0
  244. package/src/ssh/sshfs-mount.ts +5 -4
  245. package/src/task/executor.ts +3 -0
  246. package/src/task/index.ts +48 -19
  247. package/src/tools/ast-edit.ts +10 -47
  248. package/src/tools/ast-grep.ts +10 -45
  249. package/src/tools/auto-generated-guard.ts +21 -1
  250. package/src/tools/bash-allowed-prefixes.ts +2 -0
  251. package/src/tools/bash.ts +10 -4
  252. package/src/tools/bisect.ts +5 -0
  253. package/src/tools/browser/launch.ts +7 -2
  254. package/src/tools/browser/registry.ts +5 -0
  255. package/src/tools/grouped-file-tree.ts +86 -0
  256. package/src/tools/image-gen.ts +180 -174
  257. package/src/tools/index.ts +7 -0
  258. package/src/tools/json-tree.ts +2 -2
  259. package/src/tools/recipe/runners/cargo.ts +3 -0
  260. package/src/tools/recipe/runners/just.ts +3 -0
  261. package/src/tools/recipe/runners/task.ts +3 -0
  262. package/src/tools/search.ts +9 -48
  263. package/src/tools/tool-catalog.generated.ts +1 -1
  264. package/src/tui/file-list.ts +14 -3
  265. package/src/utils/gh.ts +14 -1
  266. package/src/utils/git.ts +1 -8
  267. package/src/utils/herdr-core-status.ts +156 -0
  268. package/src/utils/herdr-pane.ts +38 -26
  269. package/src/utils/recap-generator.ts +191 -0
  270. package/src/web/hardened-http.ts +183 -0
  271. package/src/web/insane/bridge.ts +2 -1
  272. package/src/web/insane/url-guard.ts +7 -2
  273. package/src/web/scrapers/youtube.ts +3 -0
@@ -13,7 +13,7 @@
13
13
  * Modes use this class and add their own I/O layer on top.
14
14
  */
15
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
- import type { AttemptScope } from "@gajae-code/agent-core/attempt-scope";
16
+ import type { AttemptRunHandle, AttemptScope } from "@gajae-code/agent-core/attempt-scope";
17
17
  import { type CompactionResult, type EmergencyCompactionSample } from "@gajae-code/agent-core/compaction";
18
18
  import type { AssistantMessage, AttemptScopeRef, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolCall, ToolChoice, Usage, UsageReport } from "@gajae-code/ai/core";
19
19
  import { type BtwTextExchange } from "./btw-contract";
@@ -70,6 +70,7 @@ export interface ForkContextSeedOptions {
70
70
  import type { AuthCredentialSelector } from "@gajae-code/ai/core";
71
71
  import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager, type FoldReason, type JobFoldEvent, type SubagentLifecycle } from "../async";
72
72
  import type { Rule } from "../capability/rule";
73
+ import type { SourceMeta } from "../capability/types";
73
74
  import type { ConfigHotReloadCandidate, ConfigHotReloadPaths } from "../config/config-hot-reload";
74
75
  import { type ModelRegistry } from "../config/model-registry";
75
76
  import { type ResolvedModelRoleValue, type ScopedModelSelection } from "../config/model-resolver";
@@ -91,16 +92,17 @@ import { type ParsedSkillInvocation, type Skill, type SkillWarning } from "../ex
91
92
  import { type FileSlashCommand } from "../extensibility/slash-commands";
92
93
  import { type MemoryGuardClaimsLease } from "../gjc-runtime/memory-guard-owner-claims";
93
94
  import { GoalRuntime } from "../goals/runtime";
94
- import type { Goal, GoalModeState } from "../goals/state";
95
+ import { type Goal, type GoalModeState } from "../goals/state";
95
96
  import type { HindsightSessionState } from "../hindsight/state";
96
97
  import type { MemoryBackend } from "../memory-backend/types";
97
98
  import { type WorkflowGateEmitter } from "../modes/shared/agent-wire/workflow-gate-broker";
98
- import type { PlanModeState } from "../plan-mode/state";
99
+ import { type PlanModeState } from "../plan-mode/state";
99
100
  import { type AgentRegistry } from "../registry/agent-registry";
100
101
  import type { LazyService } from "../runtime/lazy-service";
101
102
  import type { NetworkPrewarmRuntime } from "../runtime/network-prewarm-service";
102
103
  import type { WorkspaceTreeRuntime } from "../runtime/workspace-tree-service";
103
104
  import { type ExactMcpServerControlResult, MCPManager } from "../runtime-mcp/manager";
105
+ import type { MCPServerConfig } from "../runtime-mcp/types";
104
106
  import type { NotificationSessionController } from "../sdk/bus/session-control";
105
107
  import { type SecretObfuscator } from "../secrets/obfuscator";
106
108
  import { type DiscoverableTool, type DiscoverableToolSearchIndex } from "../tool-discovery/tool-index";
@@ -117,7 +119,7 @@ import { type ContributionPrepOptions, type ContributionPrepResult } from "./con
117
119
  import { type FoldAdapter, FoldCoordinator, type ForegroundFoldOutcome } from "./fold-coordinator";
118
120
  import type { MemoryGuardRestoreResult } from "./memory-guard-checkpoint-participant";
119
121
  import { type CustomMessage } from "./messages";
120
- import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, PreparedNewSession, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionContext, SessionManagerCloseOutcome, SessionMemoryStats, SessionArtifactPublication } from "./session-manager";
122
+ import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, PreparedNewSession, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionArtifactPublication, SessionContext, SessionManagerCloseOutcome, SessionMemoryStats } from "./session-manager";
121
123
  import { SessionManager } from "./session-manager";
122
124
  import { ToolChoiceQueue } from "./tool-choice-queue";
123
125
  import { YieldQueue } from "./yield-queue";
@@ -254,6 +256,15 @@ export interface RetainedMemorySample {
254
256
  tuiChatChildren?: number;
255
257
  tuiCachedRenderBytes?: number;
256
258
  }
259
+ /** Read-only lifecycle authority, independent of UI identity notifications. */
260
+ export interface AgentSessionLifecycleState {
261
+ /** Committed session-transition generation; catalog-preserving compaction leaves it unchanged. */
262
+ readonly generation: number;
263
+ /** True throughout transition preparation and cleanup, including handoff. */
264
+ readonly transitioning: boolean;
265
+ /** True as soon as disposal starts, including incomplete or failed teardown. */
266
+ readonly disposed: boolean;
267
+ }
257
268
  export interface AgentSessionConfig {
258
269
  agent: Agent;
259
270
  sessionManager: SessionManager;
@@ -401,6 +412,8 @@ export interface AgentSessionConfig {
401
412
  * process-global manager **MUST NOT** dispose it on their own teardown.
402
413
  */
403
414
  ownedMcpManager?: MCPManager;
415
+ /** Session-local MCP control authority granted only to root interactive sessions. */
416
+ sessionMcpControls?: SessionMcpControlPort;
404
417
  /** Optional startup dependency that must settle before the first provider turn. */
405
418
  startupTurnBarrier?: Promise<void>;
406
419
  /** Optional fork-context seed used to initialize a child session before its first prompt. */
@@ -477,6 +490,10 @@ export interface PromptOptions {
477
490
  * agent execution begins. SDK bus installs a closure that fsyncs acceptance.
478
491
  */
479
492
  onPreflightAcceptCommit?: () => void | Promise<void>;
493
+ /** Ordinary model prompt's core acceptance observer, initially before agent_start, then for replacement
494
+ * handles of that exact logical run until prompt settles. Observer errors are contained.
495
+ * Does not fire for locally handled commands or skill invocations. Not a persistence fence. */
496
+ onRunAccepted?: (handle: AttemptRunHandle) => void | Promise<void>;
480
497
  /** Skill-only: prepared metadata before the durable fence (path/lineCount/cleanedArgs). */
481
498
  onSkillPrepared?: (meta: {
482
499
  name: string;
@@ -737,6 +754,55 @@ export interface ExactMcpStatusSnapshot {
737
754
  readonly servers: readonly ExactMcpServerStatus[];
738
755
  }
739
756
  export type ExactMcpControlAction = "suspend" | "resume" | "reconnect";
757
+ export type SessionMcpScope = "global" | "project";
758
+ export type SessionMcpServerState = "connected" | "connecting" | "disconnected" | "disabled" | "failed";
759
+ export type SessionMcpDisabledReason = "enabled-false" | "disabled-servers" | "project-stdio-unapproved";
760
+ export interface SessionMcpDeclaredServer {
761
+ readonly name: string;
762
+ readonly scope: SessionMcpScope;
763
+ readonly autoload: boolean;
764
+ readonly disabled?: SessionMcpDisabledReason;
765
+ readonly config?: MCPServerConfig;
766
+ readonly source?: SourceMeta;
767
+ }
768
+ export type SessionMcpControlAction = "connect" | "disconnect" | "reconnect";
769
+ export type SessionMcpControlStatus = "connected" | "disconnected" | "reconnected" | "already-connected" | "still-connecting" | "not-connected" | "unknown-server" | "undeclared" | "disabled" | "failed" | "unavailable";
770
+ export interface SessionMcpControlResult {
771
+ readonly action: SessionMcpControlAction;
772
+ readonly name: string;
773
+ readonly status: SessionMcpControlStatus;
774
+ readonly toolCount: number;
775
+ readonly disabledReason?: SessionMcpDisabledReason;
776
+ readonly unavailableReason?: "shared-pool";
777
+ }
778
+ export interface SessionMcpControlPort {
779
+ listDeclaredServers(): Promise<SessionMcpDeclaredServer[]>;
780
+ isSettled(): boolean;
781
+ getFailedServers(): ReadonlySet<string>;
782
+ markFailed(name: string): void;
783
+ clearFailed(name: string): void;
784
+ /** Reconnect autoload servers in the background; settles after their tools are published. */
785
+ restoreAutoload(names: readonly string[]): Promise<void>;
786
+ }
787
+ export interface SessionMcpStatusSnapshot {
788
+ readonly available: boolean;
789
+ readonly servers: readonly (SessionMcpDeclaredServer & {
790
+ readonly declared: boolean;
791
+ readonly state: SessionMcpServerState;
792
+ readonly toolCount: number;
793
+ })[];
794
+ }
795
+ export interface SessionMcpCompletionCandidates {
796
+ readonly connectable: readonly (SessionMcpDeclaredServer & {
797
+ state: SessionMcpServerState;
798
+ })[];
799
+ readonly connected: readonly (SessionMcpDeclaredServer & {
800
+ state: SessionMcpServerState;
801
+ })[];
802
+ readonly reconnectable: readonly (SessionMcpDeclaredServer & {
803
+ state: SessionMcpServerState;
804
+ })[];
805
+ }
740
806
  export interface ExactMcpControlResult extends ExactMcpServerControlResult {
741
807
  readonly action: ExactMcpControlAction;
742
808
  }
@@ -745,6 +811,15 @@ export interface DefaultFallbackRuntimeState {
745
811
  controller: FallbackChainRuntimeState;
746
812
  exhaustedLastTurn: boolean;
747
813
  }
814
+ export type SessionAgentModelRole = "executor" | "planner" | "critic" | "architect";
815
+ export interface SessionAgentModelOverrideState {
816
+ manager: SessionManager;
817
+ selections: Readonly<Record<string, string>>;
818
+ revision: number;
819
+ identityGeneration: number;
820
+ managerId: string;
821
+ file: string | undefined;
822
+ }
748
823
  export interface AgentSessionProfileInstalledOverrideState {
749
824
  modelRoles: ReadonlyMap<string, ModelSelectorValue | undefined>;
750
825
  agentModelOverrides: ReadonlyMap<string, ModelSelectorValue | undefined>;
@@ -763,6 +838,7 @@ export interface PreparedProfileModelSelection {
763
838
  readonly committedThinkingLevel: ThinkingLevel | undefined;
764
839
  readonly previousModel: Model | undefined;
765
840
  readonly previousThinkingLevel: ThinkingLevel | undefined;
841
+ readonly previousThinkingLevelMutationRevision: number;
766
842
  readonly previousEditMode: EditMode;
767
843
  readonly signal: AbortSignal | undefined;
768
844
  }
@@ -845,15 +921,20 @@ export declare class AgentSession {
845
921
  skill: string;
846
922
  sessionId: string;
847
923
  } | undefined>;
848
- /** Replace the session-owned MCP manager after a cwd rescope. */
924
+ /** Replace the session-owned MCP manager after a cwd rescope, transferring ownership of next. */
849
925
  replaceOwnedMcpManager(next: MCPManager | undefined): Promise<void>;
850
- /** Swap named custom tools and restore authoritative MCP selections as late tools arrive. */
926
+ /**
927
+ * Swap named custom tools and restore authoritative MCP selections as late tools arrive.
928
+ * A previous name whose registry entry is a non-MCP tool keeps that tool unless it is the
929
+ * object the caller lists in `retiringTools`; another owner of the name is never removed.
930
+ */
851
931
  replaceNamedCustomTools(previousNames: readonly string[], nextTools: readonly CustomTool[], options?: {
852
932
  mandatoryMCPToolNames?: readonly string[];
853
933
  defaultSelectedConventionalMCPToolNames?: readonly string[];
854
934
  activateNewTools?: boolean;
855
935
  inactiveNewToolNames?: readonly string[];
856
936
  persistMCPSelection?: boolean;
937
+ retiringTools?: ReadonlyMap<string, AgentTool>;
857
938
  }): Promise<void>;
858
939
  /** Best-effort accessor for the active skill's `current_phase` field from
859
940
  * its persisted mode-state file. Used by the `skill` tool to enforce the
@@ -942,6 +1023,8 @@ export declare class AgentSession {
942
1023
  }): () => void;
943
1024
  /** Subscribe to committed session identity changes that affect UI projections. */
944
1025
  subscribeSessionIdentityChanges(listener: () => void | Promise<void>): () => void;
1026
+ /** Fires after a different-file switch commits, including when later cleanup throws. */
1027
+ subscribeCommittedSessionSwitch(listener: () => void | Promise<void>): () => void;
945
1028
  /**
946
1029
  * Remove all listeners, flush pending writes, and disconnect from agent.
947
1030
  * Call this when completely done with the session.
@@ -989,6 +1072,13 @@ export declare class AgentSession {
989
1072
  get serviceTier(): ServiceTier | undefined;
990
1073
  /** Whether agent is currently streaming a response */
991
1074
  get isStreaming(): boolean;
1075
+ /**
1076
+ * Whether `waitForIdle()` would block right now: a streaming turn, a retry or
1077
+ * TTSR resume, post-prompt work (idle-flush deliveries, auto-continuations), or
1078
+ * pending session settlement. Unlike `isStreaming`, this stays true in the gap
1079
+ * after a turn ends while a scheduled background delivery is still pending.
1080
+ */
1081
+ get isAwaitingIdle(): boolean;
992
1082
  /** Wait until streaming and session settlement work are fully settled. */
993
1083
  /**
994
1084
  * Wait until streaming and session settlement work are fully settled.
@@ -1083,6 +1173,8 @@ export declare class AgentSession {
1083
1173
  setSdkPermissionMode(mode: "prompt" | "allow" | "deny"): void;
1084
1174
  /** Current SDK permission policy for guarded ACP tool execution. */
1085
1175
  get sdkPermissionMode(): "prompt" | "allow" | "deny";
1176
+ /** Permission-only provider for descendants, fenced by the parent's current policy epoch. */
1177
+ getSdkPermissionProvider(): ClientBridge["requestPermission"];
1086
1178
  /** Register or clear the SDK reverse permission provider for this session. */
1087
1179
  setSdkPermissionProvider(provider: ((toolCall: ClientBridgePermissionToolCall, options: ClientBridgePermissionOption[], signal?: AbortSignal) => Promise<ClientBridgePermissionOutcome>) | undefined): void;
1088
1180
  /**
@@ -1114,7 +1206,17 @@ export declare class AgentSession {
1114
1206
  * Get all configured tool names (built-in via --tools or default, plus custom tools).
1115
1207
  */
1116
1208
  getAllToolNames(): string[];
1209
+ /**
1210
+ * Run a trusted Host-JS MCP mutation under the existing control admission and
1211
+ * transition exclusion. This grants neither renderer authority nor resource
1212
+ * settlement proof; the callback must validate its manager's exact target.
1213
+ */
1214
+ withMcpControlAdmission<T>(expectedGeneration: number, body: (signal: AbortSignal) => Promise<T>): Promise<T>;
1117
1215
  get hasExactMcpControls(): boolean;
1216
+ get hasSessionMcpControls(): boolean;
1217
+ getSessionMcpStatusSnapshot(): Promise<SessionMcpStatusSnapshot | undefined>;
1218
+ getSessionMcpCompletionCandidates(): Promise<SessionMcpCompletionCandidates>;
1219
+ controlSessionMcpServer(action: SessionMcpControlAction, name: string): Promise<SessionMcpControlResult | undefined>;
1118
1220
  /**
1119
1221
  * Exact-config MCP status for the TUI `/mcp` command.
1120
1222
  *
@@ -1176,6 +1278,11 @@ export declare class AgentSession {
1176
1278
  activeMCPToolNames?: string[];
1177
1279
  mandatoryMCPToolNames?: string[];
1178
1280
  persistMCPSelection?: boolean;
1281
+ /**
1282
+ * Registry objects, by name, that the caller installed and is retiring. An incoming MCP
1283
+ * tool replaces one only while it is still the registered object for that name.
1284
+ */
1285
+ retiringTools?: ReadonlyMap<string, AgentTool>;
1179
1286
  }): Promise<void>;
1180
1287
  /**
1181
1288
  * Refresh plugin sub-skill tools after workflow/sub-skill activation or phase changes.
@@ -1227,6 +1334,8 @@ export declare class AgentSession {
1227
1334
  get sessionFile(): string | undefined;
1228
1335
  /** Current session ID */
1229
1336
  get sessionId(): string;
1337
+ /** Frozen snapshot of existing session-transition and disposal state. */
1338
+ get sessionLifecycle(): AgentSessionLifecycleState;
1230
1339
  /** Credential selection identity; defaults to the provider-facing session identity. */
1231
1340
  get credentialSessionId(): string;
1232
1341
  /** Pin one OAuth credential for this session scope and persist the minimal intent. */
@@ -1242,6 +1351,8 @@ export declare class AgentSession {
1242
1351
  /** Live SDK configuration values exposed through the session query surface. */
1243
1352
  getSdkConfigItems(): Record<string, string>;
1244
1353
  setPlanModeState(state: PlanModeState | undefined): void;
1354
+ /** Drop plan mode and its reference when plan tool activation does not finish. */
1355
+ clearPlanModeBinding(): void;
1245
1356
  invokeSkill(name: string, args?: string, options?: Pick<PromptOptions, "onPreflightAccepted" | "onPreflightAcceptCommit" | "onSkillPrepared" | "preflightSignal" | "sdkRunCapability">): Promise<{
1246
1357
  name: string;
1247
1358
  path: string;
@@ -1273,6 +1384,13 @@ export declare class AgentSession {
1273
1384
  sendGoalModeContext(options?: {
1274
1385
  deliverAs?: "steer" | "followUp" | "nextTurn";
1275
1386
  }): Promise<void>;
1387
+ /** Effective task-role selectors, detached from both Settings and this session. */
1388
+ getAgentModelOverrides(): Record<string, ModelSelectorValue>;
1389
+ hasSessionAgentModelOverride(role: string): boolean;
1390
+ getSessionAgentModelOverrideState(): SessionAgentModelOverrideState;
1391
+ retireSessionAgentModelOverrides(): void;
1392
+ restoreSessionAgentModelOverrides(state: SessionAgentModelOverrideState, expectedRevision: number): void;
1393
+ setSessionAgentModelSelection(role: SessionAgentModelRole, model: Model | null): Promise<void>;
1276
1394
  resolveRoleModel(role: string): Model | undefined;
1277
1395
  /**
1278
1396
  * Resolve a role to its model AND thinking level.
@@ -1579,6 +1697,8 @@ export declare class AgentSession {
1579
1697
  getUnavailableModelProfile(): string | undefined;
1580
1698
  /** Revision fence for deferred activation after a user model selection. */
1581
1699
  getUserModelSelectionRevision(): number;
1700
+ /** Revision fence that distinguishes even same-value thinking intent during profile rollback. */
1701
+ getThinkingLevelMutationRevision(): number;
1582
1702
  /** Latest concrete user choice that seeded or cleared the session's sticky canonical variant. */
1583
1703
  getUserCanonicalVariantSelection(): {
1584
1704
  revision: number;
@@ -1589,14 +1709,6 @@ export declare class AgentSession {
1589
1709
  getConfigurationPaths(): ConfigHotReloadPaths | undefined;
1590
1710
  validateConfiguration(candidate: ConfigHotReloadCandidate): Promise<void>;
1591
1711
  reloadConfiguration(candidate: ConfigHotReloadCandidate, signal: AbortSignal): Promise<ConfigurationReloadResult>;
1592
- /**
1593
- * Re-apply vendor-separated delegation after a profile activation changed the
1594
- * role layer. `eagerTasks` is resolved at prompt build time, but under
1595
- * `tools.discoveryMode: all` the `task` tool is hidden until something
1596
- * activates it, and the delegation directive stays behind its
1597
- * `has tools "task"` guard. Activating a vendor-separated profile mid-session
1598
- * must therefore reach the live tool set, not just the next session.
1599
- */
1600
1712
  syncEagerDelegation(): Promise<void>;
1601
1713
  /** Record runtime override keys installed by a profile activation. */
1602
1714
  noteProfileInstalledOverrides(modelRoles: readonly string[], agentModelOverrides: readonly string[], preProfileModel: Model | undefined, baseline?: {
@@ -1736,7 +1848,9 @@ export declare class AgentSession {
1736
1848
  shouldMutate?: () => boolean;
1737
1849
  onMutationStarted?: () => void;
1738
1850
  }): Promise<TemporaryProviderSessionScope | void>;
1739
- prepareModelSelectionForProfileActivation(model: Model, thinkingLevel: ThinkingLevel | undefined, signal?: AbortSignal): Promise<PreparedProfileModelSelection>;
1851
+ prepareModelSelectionForProfileActivation(model: Model, thinkingLevel: ThinkingLevel | undefined, signal?: AbortSignal, options?: {
1852
+ validateCredentials: boolean;
1853
+ }): Promise<PreparedProfileModelSelection>;
1740
1854
  commitPreparedProfileModelSelection(prepared: PreparedProfileModelSelection, onThinkingLevelApplied?: (mutationRevision: number) => void): void;
1741
1855
  finishPreparedProfileModelSelection(prepared: PreparedProfileModelSelection): Promise<void>;
1742
1856
  /**
@@ -43,6 +43,7 @@ export type ClientBridgePermissionOutcome = {
43
43
  outcome: "selected";
44
44
  optionId: string;
45
45
  kind?: ClientBridgePermissionOptionKind;
46
+ comment?: string;
46
47
  };
47
48
  export interface ClientBridgeTerminalExitStatus {
48
49
  exitCode?: number | null;
@@ -30,6 +30,12 @@ export declare class ManagedReplaceError extends Error {
30
30
  /** Path-free Windows NTSTATUS of the underlying pre-mutation failure, when
31
31
  * the native layer preserved one (e.g. `0xC0000043` for a sharing violation). */
32
32
  readonly windowsErrorCode: string | undefined;
33
+ /** ACL failure detail: offending principal (account name or SID string).
34
+ * Present only when code is "acl_present" on Windows exact-replace pre-mutation failures. */
35
+ readonly aclFailurePrincipal: string | undefined;
36
+ /** ACL failure detail: whether the offending ACE is inherited from a parent directory.
37
+ * Present only when code is "acl_present" on Windows exact-replace pre-mutation failures. */
38
+ readonly aclFailureInherited: boolean | undefined;
33
39
  readonly replacementCause: unknown;
34
40
  constructor(result: NativeExactUnlinkResult, cleanupReceiptPath: string, replacementCause?: unknown);
35
41
  }
@@ -0,0 +1,104 @@
1
+ import { type SessionRecap, type SessionRecapRecord } from "../sdk/session-recap";
2
+ import type { SessionEntry } from "./session-manager";
3
+ /** `customType` of the session custom entry that persists one model-generated recap. */
4
+ export declare const SESSION_RECAP_ENTRY = "session_recap";
5
+ /** Bound retained candidates in transcripts containing forged or repeated recap entries. */
6
+ export declare const SESSION_RECAP_MAX_CANDIDATES = 256;
7
+ /** Caller-supplied recap fields; the schema version is stamped by the store. */
8
+ export type SessionRecapInput = Omit<SessionRecap, "schemaVersion">;
9
+ export type SessionRecapRejection =
10
+ /** Payload failed strict validation (shape, text bounds, control characters, timestamp). */
11
+ "invalid_payload"
12
+ /** Source entry is the active-branch turn end but is not a final (`stop`) assistant message. */
13
+ | "invalid_source"
14
+ /** Request entry is not a user message that precedes the source on the active branch. */
15
+ | "invalid_request"
16
+ /** Source entry is not the last conversation entry of the active branch (turn moved on, branch changed, or unknown id). */
17
+ | "source_not_current"
18
+ /** The active branch already carries a recap for this source entry. */
19
+ | "duplicate";
20
+ export type SessionRecapAppendPlan = {
21
+ ok: true;
22
+ data: SessionRecap;
23
+ } | {
24
+ ok: false;
25
+ reason: SessionRecapRejection;
26
+ };
27
+ export type SessionRecapAppendResult = {
28
+ status: "appended";
29
+ entryId: string;
30
+ } | {
31
+ status: "rejected";
32
+ reason: SessionRecapRejection;
33
+ };
34
+ /**
35
+ * The facts of one session entry that recap freshness depends on. Both the in-memory
36
+ * branch (`toRecapLineageEntry`) and the readonly list reader (`classifyRecapRecord`)
37
+ * reduce entries to this shape so a single walker decides what is current.
38
+ */
39
+ export interface RecapLineageEntry {
40
+ id: string;
41
+ type: string;
42
+ /** Present for `custom` entries. */
43
+ customType?: string;
44
+ /** Present for `custom` entries; unvalidated. */
45
+ data?: unknown;
46
+ /** Present for `message` entries. */
47
+ role?: string;
48
+ /** Present for assistant `message` entries. */
49
+ stopReason?: string;
50
+ }
51
+ export declare function toRecapLineageEntry(entry: SessionEntry): RecapLineageEntry;
52
+ /**
53
+ * Outcome of reading one raw transcript record for recap purposes.
54
+ * `invalid` means the record is not something the canonical loader accepts; a
55
+ * reader that meets one on the branch it is walking must fail closed (no recap),
56
+ * never skip it, or an earlier entry would be mistaken for the leaf.
57
+ */
58
+ export type RecapRecordClassification = {
59
+ kind: "entry";
60
+ entry: RecapLineageEntry;
61
+ parentId: string | null;
62
+ } | {
63
+ kind: "skip";
64
+ } | {
65
+ kind: "invalid";
66
+ };
67
+ /**
68
+ * Classify one parsed JSONL record. Mirrors the canonical resume gate's envelope (known entry
69
+ * type, string `id`, `parentId` of `null` or string, string `timestamp`) plus the body fields
70
+ * recap reads (`customType`, `message.role`), so a record the loader would reject is never
71
+ * trusted here. Per-type bodies recap does not read are left to the loader.
72
+ */
73
+ export declare function classifyRecapRecord(record: unknown): RecapRecordClassification;
74
+ /**
75
+ * Decide whether `input` may be committed to the active branch, given its entries
76
+ * newest first (leaf first). Pure: the caller appends the returned payload.
77
+ * Walk cost is bounded by the trailing non-conversation entries unless the request
78
+ * id has to be located, which only continues through the summarized turn.
79
+ */
80
+ export declare function planSessionRecapAppend(newestFirst: Iterator<RecapLineageEntry>, input: unknown): SessionRecapAppendPlan;
81
+ /**
82
+ * Push-style decision of which recap, if any, still describes a branch's last turn.
83
+ * Feed it the branch newest first (leaf first) and stop once `done`; call `finish()`
84
+ * when the branch ends first. Push-style so synchronous in-memory iteration and the
85
+ * asynchronous readonly file reader share one implementation.
86
+ *
87
+ * A recap is current only while its source is the last conversation entry: any later
88
+ * message, custom message, or branch summary makes it stale, and a recap on another
89
+ * branch is never seen. Non-conversation entries (cost/status custom entries, the
90
+ * recap entry itself) do not. Its request entry must be a user message ancestor of
91
+ * the source. Results are detached copies of validated data.
92
+ */
93
+ export declare class CurrentSessionRecapWalker {
94
+ #private;
95
+ get done(): boolean;
96
+ push(entry: RecapLineageEntry): void;
97
+ /** Conclude after the branch ended; returns the current recap or `undefined`. */
98
+ finish(): SessionRecapRecord | undefined;
99
+ }
100
+ /**
101
+ * Newest recap on the branch that still describes its last turn, given its entries
102
+ * newest first (leaf first). See {@link CurrentSessionRecapWalker} for the contract.
103
+ */
104
+ export declare function findCurrentSessionRecap(newestFirst: Iterator<RecapLineageEntry>): SessionRecapRecord | undefined;
@@ -7,6 +7,7 @@ import type * as native from "@gajae-code/natives";
7
7
  import { type ModelProfileOwnershipMarker } from "../config/model-profile-ownership";
8
8
  import type { TtsrInjectionRecord } from "../export/ttsr";
9
9
  import type { ManagedLegacyLocalMigrationSource } from "../internal-urls/local-protocol";
10
+ import type { SessionRecapRecord } from "../sdk/session-recap";
10
11
  import { ArtifactManager } from "./artifacts";
11
12
  import { type BlobPutResult, BlobStore } from "./blob-store";
12
13
  import { type ManagedMigrationPolicy } from "./internal/managed-session-scope";
@@ -14,6 +15,7 @@ import { ManagedAppendIdentityMismatchError, type ManagedBoundedAppendExpectatio
14
15
  import { type BaseAnchor, BoundedLabelsPinsStore, type CommittedTail, type DescriptorSnapshot, type DictionaryPartitionCommit, FixedCacheAccount, type MetadataDeltaValue, type ParentBucketCommit, type ReducerState, type ReopenClassification, SessionMemoryAccountant } from "./internal/session-memory-sidecar";
15
16
  import { type MemoryGuardCreateCheckpointInput, type MemoryGuardParticipantIngressLease, type MemoryGuardRestoreInput, type MemoryGuardRestoreResult, type MemoryGuardSessionManagerCheckpointV1 } from "./memory-guard-checkpoint-participant";
16
17
  import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
18
+ import { type SessionRecapAppendResult, type SessionRecapInput } from "./recap";
17
19
  import { type SessionManagerReadAccess, sessionManagerReadCapability } from "./session-manager-internal";
18
20
  import type { ManagedSessionSecurityContext, SessionStorage, SessionStorageStat, VerifiedSessionDeleteResult, VerifiedSessionDeleteTarget } from "./session-storage";
19
21
  export declare const CURRENT_SESSION_VERSION = 5;
@@ -72,6 +74,8 @@ export interface EvictedContentMarker {
72
74
  compactionEntryId: string;
73
75
  firstKeptEntryId: string;
74
76
  payloads: Record<string, ColdSpillRef>;
77
+ /** "v1": payload keys escape `\\` and `.` inside segments. Omitted: legacy raw dot-join (v0.19.2 and earlier). */
78
+ pathEncoding?: "v1";
75
79
  }
76
80
  export interface EvictCompactedContentResult {
77
81
  evictedEntries: number;
@@ -914,6 +918,13 @@ export interface SessionInfo {
914
918
  size: number;
915
919
  firstMessage: string;
916
920
  allMessagesText: string;
921
+ /**
922
+ * Model-generated recap of the last turn on the transcript's leaf branch, read
923
+ * from the persisted `session_recap` entry. Present only while it is current:
924
+ * absent when no recap exists, the conversation moved past its source, or the
925
+ * record failed validation. Never derived from `firstMessage`/`allMessagesText`.
926
+ */
927
+ recap?: SessionRecapRecord;
917
928
  }
918
929
  /** Kind of failure surfaced by strict scoped inventory. Any failure grants zero authority. */
919
930
  export type StrictInventoryFailureKind = "root" | "scan" | "lstat" | "read" | "parse" | "stat" | "header" | "cwd" | "containment" | "identity";
@@ -1099,6 +1110,14 @@ export interface UsageStatistics {
1099
1110
  premiumRequests: number;
1100
1111
  cost: number;
1101
1112
  }
1113
+ interface SessionRecapFileIdentity {
1114
+ dev: bigint;
1115
+ ino: bigint;
1116
+ nlink: bigint;
1117
+ size: number;
1118
+ mtimeNs: bigint;
1119
+ ctimeNs: bigint;
1120
+ }
1102
1121
  export interface ResolvedSessionMatch {
1103
1122
  session: SessionInfo;
1104
1123
  scope: "local" | "global";
@@ -1127,6 +1146,9 @@ interface SessionManagerStateSnapshot {
1127
1146
  }
1128
1147
  /** Benchmark-derived cap for strong materialized session snapshots. */
1129
1148
  export declare const MATERIALIZED_CACHE_MAX_BYTES: number;
1149
+ export declare class SessionTitlePersistenceStaleError extends Error {
1150
+ constructor();
1151
+ }
1130
1152
  /** Test-only cache retention and transition seams; these are intentionally not user settings. */
1131
1153
  export declare const SessionManagerTestHooks: {
1132
1154
  materializedCacheMaxBytesOverride?: number;
@@ -1135,6 +1157,8 @@ export declare const SessionManagerTestHooks: {
1135
1157
  afterForkTranscriptPublished?: () => void | Promise<void>;
1136
1158
  beforeEphemeralArtifactManagerInstall?: (dir: string) => void | Promise<void>;
1137
1159
  beforePersistPatchFence?: (attempt: number) => void;
1160
+ beforeTitlePatchPersistence?: () => Promise<void>;
1161
+ beforeTitleRewriteFence?: () => Promise<void>;
1138
1162
  beforeLivePickerStarFence?: () => void;
1139
1163
  beforeStrictMissingCheck?: (filePath: string, storage: SessionStorage) => void;
1140
1164
  beforeManagedResumeAcceptance?: (filePath: string, storage: SessionStorage) => void;
@@ -1433,6 +1457,8 @@ export declare class SessionManager {
1433
1457
  getSessionDir(): string;
1434
1458
  /** Lists picker candidates within this manager's captured destination authority. */
1435
1459
  listForResumePickerReadOnly(): Promise<SessionInfo[]>;
1460
+ /** Changes only when a different session identity or transcript is adopted. */
1461
+ getSessionIdentityGeneration(): number;
1436
1462
  getSessionId(): string;
1437
1463
  getSessionFile(): string | undefined;
1438
1464
  /**
@@ -1539,7 +1565,11 @@ export declare class SessionManager {
1539
1565
  setSessionStarredForPicker(session: SessionInfo, starred: boolean): Promise<void>;
1540
1566
  /** Update only a picker candidate's metadata, without opening a runtime or publishing a resume breadcrumb. */
1541
1567
  static setSessionStarredForPicker(session: SessionInfo, starred: boolean, explicitSessionDir?: string): Promise<void>;
1542
- setSessionName(name: string, source?: "auto" | "user"): Promise<boolean>;
1568
+ setSessionName(name: string, source?: "auto" | "user", options?: {
1569
+ isCurrent?: () => boolean;
1570
+ onlyIfUnnamed?: boolean;
1571
+ onApplied?: (name: string) => void;
1572
+ }): Promise<boolean>;
1543
1573
  _persist(entry: SessionEntry): void;
1544
1574
  /** Append a configured fallback chain as child of current leaf, then advance leaf. Returns entry id. */
1545
1575
  appendConfiguredModelChain(chain: ConfiguredModelChain): string;
@@ -1581,6 +1611,24 @@ export declare class SessionManager {
1581
1611
  appendCustomEntry(customType: string, data?: unknown): string;
1582
1612
  appendPreparedModelProfileOwnershipMarker(prepared: PreparedNewSession, marker: ModelProfileOwnershipMarker): string;
1583
1613
  appendModelProfileOwnershipMarker(marker: ModelProfileOwnershipMarker): string;
1614
+ /**
1615
+ * Persist a model-generated recap as a `session_recap` custom entry on the active
1616
+ * branch. Commits only when `input.sourceEntryId` is still the last conversation
1617
+ * entry of the active branch (non-conversation entries such as cost/status custom
1618
+ * entries, model changes, and compaction do not count), is a final assistant
1619
+ * message, has `input.requestEntryId` as a user-message ancestor, and has no recap
1620
+ * yet. Everything else resolves to a `rejected` result without touching the
1621
+ * session; persistence failures throw like any other append. Validation and append
1622
+ * happen in one synchronous step, so no turn can interleave.
1623
+ */
1624
+ appendSessionRecap(input: SessionRecapInput): SessionRecapAppendResult;
1625
+ /**
1626
+ * Recap of the active branch's last turn, or undefined when there is none or it
1627
+ * is stale (the conversation advanced past its source entry, the leaf moved to a
1628
+ * branch that does not contain it, or the payload/provenance is invalid). Never
1629
+ * falls back to an older recap and never generates one.
1630
+ */
1631
+ getSessionRecap(): SessionRecapRecord | undefined;
1584
1632
  getModelProfileOwnershipMarker(): ModelProfileOwnershipMarker | undefined;
1585
1633
  /**
1586
1634
  * Append a root marker that starts a fresh active branch without changing the
@@ -1816,6 +1864,8 @@ export declare class SessionManager {
1816
1864
  * legacy sibling directories.
1817
1865
  */
1818
1866
  static listForResumePickerReadOnly(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
1867
+ /** Read a recap only from the exact, unchanged transcript authorized by an SDK lookup. */
1868
+ static readSessionRecapReadOnly(file: string, identity: SessionRecapFileIdentity): Promise<SessionRecapRecord | undefined>;
1819
1869
  /** Delete an authorized managed or project-local picker candidate. */
1820
1870
  static deleteManagedCandidate(sessionPath: string): Promise<void>;
1821
1871
  /** Capture exact source content for a strict fork without granting write ownership. */
@@ -80,8 +80,16 @@ export interface OutputSinkOptions {
80
80
  maxColumns?: number;
81
81
  /** Hard cap for artifact writes/pending replay. Default DEFAULT_ARTIFACT_MAX_BYTES. */
82
82
  artifactMaxBytes?: number;
83
+ /**
84
+ * Receives the complete sanitized, uncapped stream, optionally in batches.
85
+ * Callback failures are sticky: push/replace/dump propagate them, with dump
86
+ * completing artifact cleanup before rejecting, including timer-originated failures.
87
+ */
83
88
  onChunk?: (chunk: string) => void;
84
- /** Minimum ms between onChunk calls. 0 = every chunk (default). */
89
+ /**
90
+ * Coalesce onChunk calls over this many ms. 0 = every chunk (default).
91
+ * Pending output is flushed sooner at dump() or under buffer pressure.
92
+ */
85
93
  chunkThrottleMs?: number;
86
94
  /**
87
95
  * Unthrottled per-chunk callback fired *after* sanitization but *before*
@@ -0,0 +1,4 @@
1
+ export declare const RECOVERY_GOAL_ID_MAX = 240;
2
+ export declare const RECOVERY_SOURCE_HASH_MAX = 240;
3
+ /** Clip the raw text, then escape. The fence is applied after that cut and the escaped text is not clipped again. */
4
+ export declare function fenceClippedCompactionText(value: string, maxLength: number): string;
@@ -16,8 +16,24 @@ export interface YieldQueueOptions {
16
16
  isStreaming: () => boolean;
17
17
  injectStreaming(msg: AgentMessage): void;
18
18
  injectIdle(messages: AgentMessage[], signal?: AbortSignal): Promise<void>;
19
+ /** Hold delivery admission across draining, message construction and injection. */
20
+ withIdleAdmission?(body: () => Promise<void>, signal?: AbortSignal): Promise<void>;
19
21
  scheduleIdleFlush(run: (signal?: AbortSignal) => Promise<void>, onSkip: () => void): void;
20
22
  getIdleFlushSignal?(): AbortSignal | undefined;
23
+ /**
24
+ * Release per-entry delivery claims after idle entries are dropped without
25
+ * delivery. Called once per kind while dropping a terminal admission failure.
26
+ */
27
+ onIdleEntriesDropped?(kind: string, entries: readonly unknown[]): void;
28
+ }
29
+ /**
30
+ * Thrown when idle delivery admission failed in a way the session can never
31
+ * retry (startup readiness rejected or the session was disposed). Retaining
32
+ * entries past that point strands them forever, so the queue drops them.
33
+ */
34
+ export declare class TerminalIdleAdmissionError extends Error {
35
+ readonly admissionError: unknown;
36
+ constructor(admissionError: unknown);
21
37
  }
22
38
  type YieldFlushMode = "streaming" | "idle";
23
39
  export declare class YieldQueue {
@@ -135,6 +135,8 @@ export interface ExecutorOptions {
135
135
  * default (`allow`) before the first prompt. `allow` is that default.
136
136
  */
137
137
  sdkPermissionMode?: "prompt" | "allow" | "deny";
138
+ /** Parent SDK approval provider, without terminal or filesystem capabilities. */
139
+ sdkPermissionProvider?: ClientBridge["requestPermission"];
138
140
  /**
139
141
  * Parent plan-mode state. Copied onto the child before the first prompt so
140
142
  * `enforcePlanModeWrite` still refuses product-file writes.
@@ -1,7 +1,14 @@
1
1
  import { type Settings as SettingsType } from "../config/settings";
2
2
  type SettingsReader = Pick<SettingsType, "get">;
3
3
  /**
4
- * Check if a file is auto-generated by examining its content.
4
+ * Refuse a basename that matches the auto-generated filename patterns.
5
+ * The match is the lexical basename only: a symlink is not resolved, so a
6
+ * handwritten link name can still point at a generated target.
7
+ * This does not read the file and does not use the content-marker cache.
8
+ */
9
+ export declare function assertEditableFileName(absolutePath: string, displayPath: string | undefined, settings?: SettingsReader): void;
10
+ /**
11
+ * Check if a file is auto-generated by examining its name and content.
5
12
  * Throws ToolError if the file appears to be auto-generated.
6
13
  *
7
14
  * @param absolutePath - Absolute path to the file
@@ -11,7 +11,7 @@ import { type AwaitingInputSignal } from "./awaiting-input";
11
11
  import { type OutputMeta } from "./output-meta";
12
12
  export { STEER_FOLD_GRACE_MS, steerFoldReasonLine } from "./steer-fold";
13
13
  export declare const BASH_DEFAULT_PREVIEW_LINES = 10;
14
- export declare const MANAGED_OWNER_BASH_ENV: readonly ["GJC_TMUX_OWNER_STATE_DIR", "GJC_TMUX_OWNER_GENERATION", "GJC_MANAGED_OWNER_RUN_ID", "GJC_MANAGED_OWNER_INCARNATION", "GJC_MANAGED_OWNER_CHILD_TOKEN", "GJC_MANAGED_OWNER_COMMAND_JSON", "GJC_MANAGED_OWNER_REDACT_COMMAND", "GJC_MANAGED_OWNER_PREDECESSOR_TOKEN", "GJC_MANAGED_OWNER_PREDECESSOR_GENERATION", "GJC_MANAGED_OWNER_PREDECESSOR_RUN_ID", "GJC_MANAGED_OWNER_PREDECESSOR_INCARNATION", "GJC_MANAGED_OWNER_TRANSCRIPT_PATH", "GJC_TMUX_OWNER_SERVER_KEY", "GJC_TMUX_LAUNCHED"];
14
+ export declare const MANAGED_OWNER_BASH_ENV: readonly ["GJC_TMUX_OWNER_STATE_DIR", "GJC_TMUX_OWNER_GENERATION", "GJC_MANAGED_OWNER_RUN_ID", "GJC_MANAGED_OWNER_INCARNATION", "GJC_MANAGED_OWNER_LAUNCH_BASELINE", "GJC_MANAGED_OWNER_CHILD_TOKEN", "GJC_MANAGED_OWNER_REDACT_COMMAND", "GJC_MANAGED_OWNER_PREDECESSOR_TOKEN", "GJC_MANAGED_OWNER_PREDECESSOR_GENERATION", "GJC_MANAGED_OWNER_PREDECESSOR_RUN_ID", "GJC_MANAGED_OWNER_PREDECESSOR_INCARNATION", "GJC_MANAGED_OWNER_TRANSCRIPT_PATH", "GJC_TMUX_OWNER_SERVER_KEY", "GJC_TMUX_LAUNCHED"];
15
15
  export type BashOriginalArtifactSaveResult = BashArtifactSaveResult;
16
16
  /**
17
17
  * Lift a leading `cd <dir> &&` into the tool cwd only when `<dir>` is exactly