@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
@@ -1,43 +1,36 @@
1
1
  export declare const MANAGED_OWNER_SUPERVISOR_ARG = "--internal-managed-owner-supervisor";
2
2
  export declare const MANAGED_OWNER_CHILD_TOKEN_ENV = "GJC_MANAGED_OWNER_CHILD_TOKEN";
3
- export declare const MANAGED_OWNER_COMMAND_ENV = "GJC_MANAGED_OWNER_COMMAND_JSON";
4
3
  export declare const MANAGED_OWNER_SESSION_ID_ENV = "GJC_COORDINATOR_SESSION_ID";
5
4
  export declare const MANAGED_OWNER_GENERATION_ENV = "GJC_TMUX_OWNER_GENERATION";
6
5
  export declare const MANAGED_OWNER_STATE_DIR_ENV = "GJC_TMUX_OWNER_STATE_DIR";
7
6
  export declare const MANAGED_OWNER_RUN_ID_ENV = "GJC_MANAGED_OWNER_RUN_ID";
8
7
  export declare const MANAGED_OWNER_INCARNATION_ENV = "GJC_MANAGED_OWNER_INCARNATION";
8
+ /**
9
+ * The generation baseline the launcher captured before creating the session
10
+ * (`launchBaselineToken`). Off Linux a child of a not yet published generation is
11
+ * admitted only while that baseline is still current.
12
+ */
13
+ export declare const MANAGED_OWNER_LAUNCH_BASELINE_ENV = "GJC_MANAGED_OWNER_LAUNCH_BASELINE";
14
+ /**
15
+ * Serialized child argv budget inside a recoverable binding. The binding's other
16
+ * fields stay under 1 KiB, so the whole record fits the 64 KiB owner-only reader.
17
+ */
18
+ export declare const MANAGED_OWNER_RECOVERABLE_COMMAND_MAX_BYTES: number;
9
19
  /** Suppresses command-derived durable artifacts for Broker-owned opaque spawn children. */
10
20
  export declare const MANAGED_OWNER_REDACT_COMMAND_ENV = "GJC_MANAGED_OWNER_REDACT_COMMAND";
11
- export interface ManagedOwnerBinding {
12
- schema_version: 2;
13
- generation: string;
14
- session_id: string;
15
- run_id: string;
16
- endpoint_incarnation: string;
17
- child_token: string;
18
- command: string[];
19
- command_sha256: string;
20
- supervisor_pid: number;
21
- supervisor_start_time: string;
22
- created_at: string;
23
- }
24
- export interface ManagedOwnerSigabrtReceipt {
25
- schema_version: 2;
26
- generation: string;
27
- session_id: string;
28
- run_id: string;
29
- endpoint_incarnation: string;
30
- child_token: string;
31
- command_sha256: string;
32
- supervisor_pid: number;
33
- supervisor_start_time: string;
34
- child_pid: number;
35
- child_start_time: string;
36
- signal: "SIGABRT";
37
- signal_number: 6;
38
- exit_code: number | null;
39
- received_at: string;
40
- }
41
- export declare function isManagedOwnerSupervisorArgv(args: readonly string[]): boolean;
21
+ /**
22
+ * Whether the supervisor accepts a lifecycle state directory exactly as given: absolute,
23
+ * unchanged by the trimming its environment read applies, without NUL, and without a `..` component.
24
+ */
25
+ export declare function managedOwnerStateDirAccepted(stateDir: string): boolean;
26
+ /**
27
+ * Supervisor invocation: `<gjc> --internal-managed-owner-supervisor -- <child argv...>`.
28
+ *
29
+ * The child argv travels as ordinary shell-quoted arguments, never re-encoded (JSON
30
+ * escaping would double backslashes and quotes inside tmux's ~16 KiB command limit).
31
+ */
32
+ export declare function managedOwnerSupervisorInvocation(supervisorArgv: readonly string[], childArgv: readonly string[]): string[];
33
+ /** Child argv from the supervisor's CLI arguments (after the program entry). */
34
+ export declare function managedOwnerSupervisorChildArgv(args: readonly string[]): string[];
42
35
  /** Runs one exact child and publishes authority only for a directly observed Linux signal 6. */
43
- export declare function runManagedOwnerSupervisor(): Promise<void>;
36
+ export declare function runManagedOwnerSupervisor(args: readonly string[]): Promise<void>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Refuse a path whose existing components are not all real directories, checked
3
+ * from the filesystem root with `lstat`. The walk stops at the first missing
4
+ * component, which the caller may then create. This is a pathname check: a
5
+ * component swapped after it was inspected is not detected.
6
+ */
7
+ export declare function assertNoLinkedComponent(target: string): void;
8
+ /**
9
+ * Create or accept a lifecycle root for a writer that is about to put files in
10
+ * it. Returns false, before anything is created, when an existing component of
11
+ * the path is a link or not a directory. A missing root and its missing
12
+ * ancestors are created owner-only. An existing root's mode is left as it is:
13
+ * owner-only verification belongs to the callers that already require it.
14
+ */
15
+ export declare function ensureOwnerLifecycleDirectorySync(root: string): boolean;
16
+ /**
17
+ * Whether an existing lifecycle file may be opened by pathname: a regular file
18
+ * with a single link, so neither a symlink nor a hardlink redirects the open.
19
+ * Like the walk, this is a pathname check and does not open the file.
20
+ */
21
+ export declare function isPlainOwnerLifecycleFile(file: string): boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Create or accept a managed owner lifecycle root for a launch. An existing root
3
+ * must already be private: it is verified, never repaired. A missing root and its
4
+ * missing ancestors are created owner-only, and the result is verified natively.
5
+ * Throws without naming the path; callers report their own refusal code.
6
+ */
7
+ export declare function prepareOwnerLifecycleRootSync(root: string): void;
@@ -1,4 +1,5 @@
1
1
  import { postmortem } from "@gajae-code/utils";
2
+ import { type ObserveTerminalRequest } from "./tmux-owner-isolation";
2
3
  /** Managed tmux owner provenance propagated only to the launched child process. */
3
4
  export declare const GJC_TMUX_OWNER_GENERATION_ENV = "GJC_TMUX_OWNER_GENERATION";
4
5
  export declare const GJC_TMUX_OWNER_STATE_DIR_ENV = "GJC_TMUX_OWNER_STATE_DIR";
@@ -281,6 +282,12 @@ export declare function recoverCoordinatorRuntimeStateRescope(context: RuntimeSt
281
282
  */
282
283
  export declare function relocateCoordinatorRuntimeStateForRescope(context: RuntimeStateContext, previousCwd: string): Promise<boolean>;
283
284
  export declare function ownerTerminalContextFromEnvironment(): OwnerTerminalContext | "invalid" | null;
284
- export declare function persistCoordinatorRuntimeStateFromPostmortem(reason: postmortem.Reason, context: RuntimeStateContext): Promise<void>;
285
+ /**
286
+ * Captures the owner-terminal observation synchronously, before any other postmortem
287
+ * work can yield, so relay visibility and `observed_at` describe the moment the
288
+ * postmortem began.
289
+ */
290
+ export declare function captureOwnerTerminalObservation(reason: postmortem.Reason, context: RuntimeStateContext): ObserveTerminalRequest | null;
291
+ export declare function persistCoordinatorRuntimeStateFromPostmortem(reason: postmortem.Reason, context: RuntimeStateContext, ownerTerminalObservation?: ObserveTerminalRequest | null): Promise<void>;
285
292
  export declare function registerCoordinatorRuntimeStateFinalizer(context: RuntimeStateContext, resolveContext?: () => RuntimeStateContext): () => void;
286
293
  export {};
@@ -113,3 +113,13 @@ export declare function buildGjcTmuxProfileCommands(target: string, env?: NodeJS
113
113
  tmuxCommand?: string;
114
114
  }): GjcTmuxProfileCommand[];
115
115
  export declare function normalizeTmuxCreatedAt(raw: string): string;
116
+ /**
117
+ * A derived managed state file named through its canonical trusted anchor: the
118
+ * workspace, or its `.gjc` directory when that exists, is resolved once so a
119
+ * workspace or `.gjc` reached through a symlink has one spelling that lifecycle
120
+ * preparation, verification, supervision and admission all share. The private
121
+ * `_session-*` tail below `.gjc` stays lexical, so a link inside managed storage
122
+ * still fails the no-follow verification. A path outside `<cwd>/.gjc` or an
123
+ * unresolvable anchor is returned unchanged and fails closed later.
124
+ */
125
+ export declare function canonicalManagedStateFile(cwd: string, file: string): string;
@@ -3,6 +3,9 @@
3
3
  * This module intentionally accepts and stores only opaque identifiers and
4
4
  * process/cgroup metadata; it never reads panes, prompts, environment, or logs.
5
5
  */
6
+ import { type NativeOwnerOnlyFileReadResult } from "@gajae-code/natives";
7
+ import { type ProcessIncarnationObservation } from "../sdk/broker/process-incarnation";
8
+ import { type ManagedOwnerBinding, type ManagedOwnerChildExit, type ManagedOwnerRelayRecord } from "./managed-owner-binding";
6
9
  export declare const TMUX_OWNER_ISOLATION_SCHEMA_VERSION = 1;
7
10
  export declare const TMUX_OWNER_ISOLATION_MAX_LINE_BYTES: number;
8
11
  export declare const TMUX_OWNER_ISOLATION_MAX_DIAGNOSTIC_CHARS = 512;
@@ -276,6 +279,20 @@ export interface LifecyclePaths {
276
279
  incidentFile: string;
277
280
  lockDatabaseFile: string;
278
281
  journalFile: string;
282
+ /** Darwin: names the one supervisor binding of this generation (no directory scan). */
283
+ supervisorIndexFile: string;
284
+ /** Darwin: durable proof that the exact supervisor delivered its cooperative signal for one intent. */
285
+ relayFile: string;
286
+ /** Darwin: published before delivery; removed once a confirmed delivery publishes `relayFile`. */
287
+ relayPendingFile: string;
288
+ /** Darwin: SQLite lock its closer holds for as long as it waits on the intent. */
289
+ closerLockFile: string;
290
+ /** Darwin: the admitted child installed its cooperative signal handler. */
291
+ cooperativeReadyFile: string;
292
+ /** Darwin: the child's first handled termination cause, created exclusively. */
293
+ shutdownCauseFile: string;
294
+ /** Darwin: the supervisor's reconciliation of the relayed child's actual exit. */
295
+ childExitFile: string;
279
296
  }
280
297
  export declare function lifecyclePaths(stateDir: string, sessionId: string, generation: string): LifecyclePaths;
281
298
  export interface MemoryGuardClaimPaths {
@@ -285,7 +302,9 @@ export interface MemoryGuardClaimPaths {
285
302
  shmFile: string;
286
303
  }
287
304
  export declare function memoryGuardClaimPaths(stateDir: string, sessionId: string): MemoryGuardClaimPaths;
288
- export declare function replaceOwnerGeneration(stateDir: string, sessionId: string, generation?: string, expectedBaseline?: OwnerGenerationBaseline): Promise<string>;
305
+ /** Names a generation baseline for `MANAGED_OWNER_LAUNCH_BASELINE_ENV`. */
306
+ export declare function launchBaselineToken(baseline: OwnerGenerationBaseline): string;
307
+ export declare function replaceOwnerGeneration(stateDir: string, sessionId: string, generation?: string, expectedBaseline?: OwnerGenerationBaseline, observe?: (pid: number) => ProcessIncarnationObservation): Promise<string>;
289
308
  export type OwnerGenerationBaseline = {
290
309
  state: "absent";
291
310
  } | {
@@ -303,13 +322,29 @@ export interface ManagedOwnerPredecessorEvidence {
303
322
  predecessorToken: string;
304
323
  }
305
324
  /** Resolve one SIGABRT predecessor from the retained exact prior-generation root. */
306
- export declare function resolveManagedOwnerPredecessorSync(stateDir: string, sessionId: string, baseline: OwnerGenerationBaseline): ManagedOwnerPredecessorEvidence | undefined;
325
+ export declare function resolveManagedOwnerPredecessorSync(stateDir: string, sessionId: string, baseline: OwnerGenerationBaseline, observe?: (pid: number) => ProcessIncarnationObservation): ManagedOwnerPredecessorEvidence | undefined;
307
326
  export declare function captureOwnerGenerationBaseline(stateDir: string, sessionId: string): Promise<OwnerGenerationBaseline>;
308
327
  /** Captures the full immutable generation record for a planned owner launch. */
309
328
  export declare function captureOwnerGenerationBaselineSync(stateDir: string, sessionId: string): OwnerGenerationBaseline;
310
329
  export declare function isOwnerGenerationBaselineCurrentSync(stateDir: string, sessionId: string, baseline: OwnerGenerationBaseline): boolean;
311
330
  /** Synchronous publication for managed launch paths, serialized by a SQLite write transaction. */
312
- export declare function replaceOwnerGenerationSync(stateDir: string, sessionId: string, generation: string, expectedBaseline: OwnerGenerationBaseline): string;
331
+ export declare function replaceOwnerGenerationSync(stateDir: string, sessionId: string, generation: string, expectedBaseline: OwnerGenerationBaseline, observe?: (pid: number) => ProcessIncarnationObservation): string;
332
+ /**
333
+ * Child admission fence. Once a generation is published (its immutable marker
334
+ * exists), its child is admitted only while that generation is still current,
335
+ * read under the generation lock that also holds a relaunch's predecessor check
336
+ * and publication. So either the relaunch saw this child's binding and refused a
337
+ * live predecessor, or it replaced the generation first and this child is
338
+ * refused: no admitted child is left behind a generation that close no longer
339
+ * reaches. On Linux a child of a generation not yet published is admitted; its
340
+ * launcher's publication then fails the baseline check against any replacement and
341
+ * removes the session. Off Linux that cleanup is not relied on, because the
342
+ * launcher may have died: such a child, which recorded itself before this fence,
343
+ * is admitted only while `launchBaseline` (`launchBaselineToken` of the baseline
344
+ * its launcher captured) is still current under the lock. A relaunch that
345
+ * publishes later scans under that lock and finds the child's record.
346
+ */
347
+ export declare function assertManagedOwnerGenerationNotReplaced(stateDir: string, sessionId: string, generation: string, launchBaseline: string | undefined): void;
313
348
  /** Publishes a raw-owner generation through the canonical SQLite-serialized CAS path. */
314
349
  export declare function publishOwnerGenerationSync(request: PublishGenerationRequest): PublishGenerationResult;
315
350
  export declare function createOwnerIntent(stateDir: string, input: Omit<OwnerIntent, "schema_version" | "intent_id" | "state">): Promise<OwnerIntent>;
@@ -317,6 +352,15 @@ export declare function createOwnerIntent(stateDir: string, input: Omit<OwnerInt
317
352
  export declare function observeOwnerTerminal(request: ObserveTerminalRequest): Promise<OwnerVerdict>;
318
353
  /** Strictly validate the persisted authorization, optionally against its terminal observation. */
319
354
  export declare function isValidOwnerIntent(intent: unknown, request?: ObserveTerminalRequest): intent is OwnerIntent;
355
+ /**
356
+ * Whether the supervisor has already published a pending or confirmed relay record
357
+ * for this exact intent. Where a supervisor relays (Darwin, or any generation with a
358
+ * supervisor index) it publishes the pending record durably before signaling, so a
359
+ * terminal captured while neither record exists cannot be that relay's signal,
360
+ * whatever the wall clock says. A Linux generation without an index has no relay:
361
+ * its closer signals directly.
362
+ */
363
+ export declare function cooperativeRelayVisible(paths: LifecyclePaths, intent: OwnerIntent): boolean;
320
364
  /** Accept only real UTC timestamps in the canonical evidence serialization. */
321
365
  export declare function isCanonicalUtcTimestamp(value: unknown): value is string;
322
366
  /** Strictly validate a complete persisted verdict, optionally against its observation. */
@@ -334,10 +378,92 @@ export interface ExactOwnerCloseRequest {
334
378
  }
335
379
  export interface ExactOwnerCloseDependencies {
336
380
  readStartTime(pid: number): Promise<string | null>;
337
- sendSigterm(pid: number): Promise<void>;
338
- waitForVerdict(): Promise<OwnerVerdict | null>;
381
+ shutdown: {
382
+ kind: "kernel_signal";
383
+ sendSigterm(pid: number): Promise<void>;
384
+ } | {
385
+ kind: "cooperative_intent";
386
+ assertCooperativeOwner(): void;
387
+ /**
388
+ * Publishes `file` under the private lifecycle `root` without replacement, running
389
+ * `assertOwned` immediately before the commit. Injected so this module, reachable from
390
+ * machine entrypoints, does not depend on session storage.
391
+ */
392
+ publishNoReplace(root: string, file: string, bytes: Uint8Array, assertOwned: () => void): Promise<void>;
393
+ };
394
+ waitForVerdict(intent: OwnerIntent): Promise<OwnerVerdict | null>;
339
395
  cleanupSession(): Promise<void>;
340
396
  }
397
+ /** Bounded native evidence reads; never reopen through a pathname fallback. */
398
+ export declare function readSecureOwnerJson(file: string): unknown;
399
+ /**
400
+ * The native reader requires the file and its private parent directory to keep
401
+ * identical metadata across the whole read window. Launcher and supervisor
402
+ * legitimately publish sibling evidence in the same lifecycle root (generation
403
+ * marker, SQLite lock journal, bindings), which changes the parent's mtime and
404
+ * fails an otherwise exact read with `metadata_changed`. Only that transient code
405
+ * is retried, a bounded number of times; every attempt re-acquires the complete
406
+ * descriptor authority, so identity, ownership, link-count and security failures
407
+ * still fail closed on the first observation.
408
+ */
409
+ export declare function readOwnerOnlyFileSettled(file: string, maxBytes: number): NativeOwnerOnlyFileReadResult;
410
+ export declare function parseExactOwnerJson(data: Uint8Array, framingError: "owner_evidence_framing_invalid" | "managed_owner_json_framing_invalid"): unknown;
411
+ /**
412
+ * Darwin, in an admitted managed child, before the CLI starts: record the first
413
+ * termination cause this process handles, and accept the supervisor's cooperative
414
+ * signal only as that first cause. The cooperative signal then starts the ordinary
415
+ * SIGTERM shutdown. Signals carry no sender identity, so this ordering, not a
416
+ * timestamp, is what lets a verdict attribute the shutdown to the relay: a SIGTERM,
417
+ * SIGHUP or SIGINT handled first wins the exclusive record, and the relay is ignored.
418
+ * The readiness record is published only after the handlers are installed; without
419
+ * it the supervisor never relays. Returns whether readiness was published.
420
+ */
421
+ export declare function installManagedOwnerCooperativeShutdown(input: {
422
+ stateDir: string;
423
+ sessionId: string;
424
+ generation: string;
425
+ childToken: string;
426
+ /**
427
+ * Whether this process already began shutting down. A termination signal handled
428
+ * before the recorders existed left no cause record, so such a child never
429
+ * announces readiness and is never relayed to.
430
+ */
431
+ shutdownStarted(): boolean;
432
+ }): boolean;
433
+ /** Darwin: whether this exact child published readiness for the cooperative signal. */
434
+ export declare function managedOwnerCooperativeReady(paths: LifecyclePaths, binding: Pick<ManagedOwnerBinding, "session_id" | "generation" | "child_token">, childPid: number): boolean;
435
+ /** Darwin: the generation's exact child recorded the cooperative signal as its first cause. */
436
+ export declare function managedOwnerCooperativeCause(paths: LifecyclePaths, binding: Pick<ManagedOwnerBinding, "session_id" | "generation" | "child_token">, childPid?: number): boolean;
437
+ /**
438
+ * Darwin: the supervisor's reconciliation of the relayed child's exit, recorded
439
+ * after its own terminal observation. Written exclusively; an unexplained exit also
440
+ * publishes the generation's owner-loss incident, because an expected verdict the
441
+ * child published before it died stays history and never makes the close successful.
442
+ */
443
+ export declare function recordManagedOwnerChildExit(stateDir: string, record: ManagedOwnerChildExit): Promise<void>;
444
+ /**
445
+ * Darwin relay evidence for exactly this intent, or null when none exists.
446
+ * An unreadable or mismatched record is never treated as absent.
447
+ */
448
+ export declare function readCooperativeRelayRecord(paths: LifecyclePaths, intent: OwnerIntent): ManagedOwnerRelayRecord | null;
449
+ /** One short critical section on the existing generation lock, including relay. */
450
+ export declare function consumeCooperativeOwnerIntent(input: {
451
+ stateDir: string;
452
+ binding: ManagedOwnerBinding;
453
+ serverKey: string;
454
+ /** The supervisor's direct child; it must have published cooperative readiness. */
455
+ childPid: number;
456
+ /** Whether the exact child can still receive a relay right now. */
457
+ canRelay(): boolean;
458
+ /** Delivers the cooperative signal; returns true only when it was actually sent. */
459
+ relay(intent: OwnerIntent, observedAt: string): boolean;
460
+ /**
461
+ * Durable no-replace publication inside the private lifecycle root. Injected by
462
+ * the supervisor so managed session storage stays out of this module's graph
463
+ * (it is reachable from the MCP machine entrypoint).
464
+ */
465
+ publishNoReplace(file: string, bytes: Uint8Array): void;
466
+ }): void;
341
467
  /** Authorizes only an exact, start-time-validated SIGTERM before compatibility cleanup. */
342
468
  export declare function closeExactTmuxOwner(request: ExactOwnerCloseRequest, deps: ExactOwnerCloseDependencies): Promise<OwnerVerdict>;
343
469
  export declare function parseOwnerIsolationRequest(line: string): PlanRequest | BootstrapRequest | PublishGenerationRequest | ObserveTerminalRequest | null;
@@ -1,4 +1,6 @@
1
1
  import { type ProjectEnvSnapshot } from "@gajae-code/utils/env-file";
2
+ import { type ProcessIncarnationObservation } from "../sdk/broker/process-incarnation";
3
+ import { type ManagedOwnerBinding } from "./managed-owner-binding";
2
4
  import { type ProviderAuthority } from "./tmux-common";
3
5
  import { type OwnerIsolationProbeSync, type OwnerVerdict, type PlanResponse, type TmuxOwnerIsolationExecutionDependencies, type TmuxOwnerIsolationExecutionResult } from "./tmux-owner-isolation";
4
6
  export interface ManagedTmuxLaunchSpec {
@@ -94,10 +96,30 @@ export interface ForceCloseOwnerDependencies {
94
96
  waitForOwnerExitVerdict?(): Promise<OwnerVerdict>;
95
97
  /** Broker close pin; production callers use this to reject reused session identity. */
96
98
  expectedManagedProof?: ManagedTmuxLaunchProof;
99
+ /** @internal Exercise the kernel delivery branch with synthetic test dependencies. */
100
+ shutdownModeForTest?: "kernel_signal";
101
+ /** @internal Process-table observation of the pinned cooperative supervisor. */
102
+ observeProcess?(pid: number): ProcessIncarnationObservation;
97
103
  }
104
+ /**
105
+ * Waits for positive evidence that one pinned process incarnation is gone: the
106
+ * OS reports the PID absent, or the PID now names a different incarnation.
107
+ * `unknown` observations (for example a transient Darwin sysctl failure, which
108
+ * `Process.status` would report as exited) are never treated as exit.
109
+ */
110
+ export declare function waitForPinnedProcessExit(pid: number, incarnation: string, deadline: number, deps: {
111
+ observe(pid: number): ProcessIncarnationObservation;
112
+ now(): Date;
113
+ sleep(ms: number): Promise<void>;
114
+ }): Promise<boolean>;
98
115
  export interface CreateGjcTmuxSessionOptions {
99
116
  platform?: NodeJS.Platform;
100
117
  launch?: ManagedTmuxLaunchSpec;
118
+ /**
119
+ * @internal Program prefix (executable and entrypoint) of the supervisor in isolated
120
+ * managed-launch tests; the supervisor flag is appended as in production.
121
+ */
122
+ supervisorArgvForTest?: readonly string[];
101
123
  }
102
124
  export type CreateOwnerIsolationTestDependencies = {
103
125
  probe?: Partial<OwnerIsolationProbeSync>;
@@ -149,9 +171,33 @@ export declare function proveGjcTmuxSessionMutationTarget(sessionName: string, e
149
171
  /** @internal */
150
172
  export declare function readTmuxSessionTagsForGc(sessionName: string, env?: NodeJS.ProcessEnv): GjcTmuxSessionTagsForGc;
151
173
  export declare function removeGjcTmuxSession(sessionName: string, env?: NodeJS.ProcessEnv, expectedIdentity?: ExpectedGjcTmuxSessionIdentity): GjcTmuxSessionStatus;
174
+ /**
175
+ * @internal Bounded discovery of the exact supervisor's binding.
176
+ *
177
+ * The launch proof can return before the supervisor durably publishes its binding.
178
+ * Only an absent binding is retried, and only while the same exact supervisor stays
179
+ * live; untrusted, ambiguous, or changed evidence still fails closed immediately. The
180
+ * binding's wall-clock `created_at` is not a gate, so a clock rollback after launch
181
+ * never blocks closing a live owner.
182
+ */
183
+ export declare function awaitCooperativeSupervisorBinding(identity: ExactOwnerIdentity, deps: {
184
+ assertSameSupervisor: () => void;
185
+ sleep: (ms: number) => Promise<void>;
186
+ now: () => Date;
187
+ deadline: number;
188
+ }): Promise<ManagedOwnerBinding>;
152
189
  /**
153
190
  * Requests an exact tagged owner shutdown. Session cleanup is compatibility-only
154
191
  * and follows a validated SIGTERM verdict; it never authorizes the close.
155
192
  */
193
+ /** No-replace owner-intent publication under the exact private lifecycle root. */
194
+ export declare function publishOwnerIntentNoReplace(root: string, file: string, bytes: Uint8Array, assertOwned: () => void): Promise<void>;
195
+ /**
196
+ * @internal The force-close clock: one wall-clock anchor advanced by monotonic elapsed
197
+ * time, so a wall-clock step during a close neither extends nor shortens its deadline.
198
+ * After a backward step the published intent reads as created in the future and the
199
+ * supervisor refuses it until the closer has given up and retired it.
200
+ */
201
+ export declare function monotonicCloseClock(): () => Date;
156
202
  export declare function forceCloseGjcTmuxSession(sessionName: string, env?: NodeJS.ProcessEnv, expectedSessionId?: string, expectedStateFile?: string, deps?: Partial<ForceCloseOwnerDependencies>): Promise<GjcTmuxSessionStatus>;
157
203
  export declare function attachGjcTmuxSession(sessionName: string, env?: NodeJS.ProcessEnv): never;
@@ -1,4 +1,4 @@
1
- import type { ManagedOwnerSigabrtReceipt } from "./managed-owner-supervisor";
1
+ import type { ManagedOwnerSigabrtReceipt } from "./managed-owner-binding";
2
2
  /** Immutable identity supplied by the owner-loss monitor and coordinator admission. */
3
3
  export interface UltragoalRecoveryBinding {
4
4
  sessionId: string;
@@ -22,7 +22,33 @@ export declare class LeaseError extends Error {
22
22
  }
23
23
  export type LeaseStatus = "missing" | "live" | "expiredAlive" | "dead" | "epermAlive";
24
24
  type PidStatus = "alive" | "dead" | "eperm";
25
+ /** Lexical identity of two socket paths. Blank, padded, and NUL paths do not match. */
26
+ export declare function classifyOwnerSocketLexical(candidate: string, canonical: string): "match" | "mismatch";
27
+ export interface OwnerSocketRecordIdentity {
28
+ ownerId: string;
29
+ leaseEpoch: number;
30
+ nonce: string;
31
+ }
32
+ interface OwnerSocketRecord extends OwnerSocketRecordIdentity {
33
+ socketPath: string;
34
+ pid: number;
35
+ }
36
+ /** Private record path for this session. Null when the store root cannot be named. */
37
+ export declare function ownerSocketRecordPath(root: string, sessionId: string): string | null;
38
+ export declare function setOwnerSocketRecordAfterDirCheck(hook: (() => void) | null): void;
39
+ export declare function recordFromText(text: string): OwnerSocketRecord | null;
40
+ /**
41
+ * Path the CLI may dial for this lease endpoint.
42
+ * Returns the private socket, never an unmatched lease string.
43
+ * A missing file still returns that path so a manual owner stays addressable before listen.
44
+ * A symlink or a non-socket does not. A record is used only when its lease identity matches.
45
+ */
46
+ export declare function canonicalLeaseSocket(root: string, sessionId: string, endpointPath: string, lease?: SessionLease | null): string | null;
25
47
  export declare function readLease(root: string, sessionId: string): Promise<SessionLease | null>;
48
+ /** Publish the socket record only while this identity still holds the lease. */
49
+ export declare function publishOwnerSocketRecord(root: string, sessionId: string, socketPath: string, identity: OwnerSocketRecordIdentity): Promise<void>;
50
+ /** Remove the record only when it still names this lease identity. */
51
+ export declare function clearOwnerSocketRecord(root: string, sessionId: string, identity: OwnerSocketRecordIdentity): Promise<void>;
26
52
  export declare function isExpired(lease: SessionLease, clock?: () => number): boolean;
27
53
  export declare function classifyLeaseStatus(lease: SessionLease | null, opts?: {
28
54
  clock?: () => number;
@@ -48,8 +74,9 @@ export interface AcquiredLease {
48
74
  token: string;
49
75
  }
50
76
  /**
51
- * Acquire (or take over a stale) lease. Fails closed with `lease_held` when a live,
52
- * unexpired lease is held by a different owner. Re-acquiring as the current owner refreshes.
77
+ * Acquire (or take over a stale) lease. Fails closed with `lease_held` when another
78
+ * owner is not dead. A missing socket record, or an endpoint outside the computed
79
+ * socket, does not authorize replacement. Re-acquiring as the current owner refreshes.
53
80
  */
54
81
  export declare function acquireLease(root: string, sessionId: string, opts: AcquireOptions): Promise<AcquiredLease>;
55
82
  /** Refresh the lease expiry. Only the recorded owner may heartbeat (single-writer). */
@@ -24,7 +24,15 @@ export declare function rewriteHarnessRootRegistryForGc(file: string, registry:
24
24
  /** @internal */
25
25
  export declare function removeHarnessRootRegistryFileForGc(file: string): Promise<void>;
26
26
  export declare const MAX_UNIX_SOCKET_PATH_BYTES = 100;
27
+ /** One key per state root, so a symlinked and a real spelling share socket and record paths. */
28
+ export declare function stableRootKey(root: string): string;
29
+ /** Owner setup: creates the private socket directory and its metadata. */
27
30
  export declare function controlSocketPath(root: string, sessionId: string, env?: NodeJS.ProcessEnv): string;
31
+ /**
32
+ * Lookup-only twin of `controlSocketPath`: no mkdir, chmod, or metadata write.
33
+ * Null when the socket directory is a symlink, missing, or not private to this uid.
34
+ */
35
+ export declare function controlSocketPathFor(root: string, sessionId: string, env?: NodeJS.ProcessEnv): string | null;
28
36
  export declare class StorageError extends Error {
29
37
  readonly code: string;
30
38
  constructor(message: string, code: string);
@@ -205,6 +205,18 @@ export declare function registerDirectSession(sessionManager: DirectSessionManag
205
205
  * `PI_*` name for backward compatibility. `--acp` mode implies `--no-title`.
206
206
  */
207
207
  export declare function applyTerminalControlFlagsToEnv(parsed: Pick<Args, "noPty" | "noTitle" | "mode">, env?: NodeJS.ProcessEnv): void;
208
+ /**
209
+ * Whether the live `HERDR_BIN_PATH` must not be used as Herdr's executable.
210
+ *
211
+ * A static project declaration is rejected when the live value is that
212
+ * declaration, including surrounding whitespace. A dynamic declaration is
213
+ * ambiguous with Bun's preload, so any live value is rejected and Herdr falls
214
+ * back to `PATH`. A shell export is kept when the project declaration is
215
+ * absent or is a different static string.
216
+ */
217
+ export declare function rejectProjectHerdrBinPath(runtime: string | undefined, declared: string | undefined, dynamic: boolean): boolean;
218
+ /** Drop a project-supplied Herdr executable before this command spawns anything. */
219
+ export declare function dropProjectSuppliedHerdrBinPath(env: NodeJS.ProcessEnv): void;
208
220
  export declare function runRootCommand(parsed: Args, rawArgs: string[], deps?: RunRootCommandDependencies): Promise<void>;
209
221
  export declare function main(args: string[]): Promise<void>;
210
222
  export {};
@@ -18,7 +18,13 @@ export declare function startMemoryStartupTask(options: {
18
18
  */
19
19
  export declare function buildMemoryToolDeveloperInstructions(agentDir: string, settings: Settings, session?: AgentSession): Promise<string | undefined>;
20
20
  /**
21
- * Clear all persisted memory state and generated artifacts.
21
+ * Delete every memory row and memory job in the shared local database, then remove
22
+ * only the current project's memory directory.
23
+ *
24
+ * Database deletion is not scoped to `cwd`. Filesystem cleanup removes the
25
+ * directory that `getMemoryRoot(agentDir, cwd)` returns. Project paths that
26
+ * differ only in `/`, `\`, or `:` versus `-` map to the same directory, so that
27
+ * shared directory is removed too.
22
28
  */
23
29
  export declare function clearMemoryData(agentDir: string, cwd: string): Promise<void>;
24
30
  /**
@@ -29,6 +29,7 @@ export interface GlobalClaim {
29
29
  }
30
30
  export declare function openMemoryDb(dbPath: string): Database;
31
31
  export declare function closeMemoryDb(db: Database): void;
32
+ /** Delete every memory row and memory pipeline job. Not filtered by project cwd. */
32
33
  export declare function clearMemoryData(db: Database): void;
33
34
  export declare function upsertThreads(db: Database, threads: MemoryThread[]): void;
34
35
  export declare function claimStage1Jobs(db: Database, params: {
@@ -35,7 +35,12 @@ export interface MemoryBackend {
35
35
  * Returned on every prompt rebuild via `refreshBaseSystemPrompt()`.
36
36
  */
37
37
  buildDeveloperInstructions(agentDir: string, settings: Settings, session?: AgentSession): Promise<string | undefined>;
38
- /** Wipe all persisted state for this backend (slash `/memory clear`). */
38
+ /**
39
+ * Clear stored memory (`/memory clear`).
40
+ * For the local backend, memory rows and memory jobs are deleted from the shared
41
+ * database with no project filter, and filesystem cleanup removes only the
42
+ * current project's directory.
43
+ */
39
44
  clear(agentDir: string, cwd: string, session?: AgentSession): Promise<void>;
40
45
  /** Force consolidation/retain to happen now (slash `/memory enqueue`). */
41
46
  enqueue(agentDir: string, cwd: string, session?: AgentSession): Promise<void>;
@@ -7,7 +7,8 @@ import { type ScopedModelSelection } from "../../config/model-resolver";
7
7
  import type { ModelProfileConfig } from "../../config/models-config-schema";
8
8
  import { type ProviderAuthState } from "../../config/provider-ranking";
9
9
  import type { Settings } from "../../config/settings";
10
- import type { SmartRoutingIntent, SmartRoutingPreview } from "./smart-routing-panel";
10
+ import type { RoutingSettingsPreview } from "../../sdk/routing-settings";
11
+ import type { SmartRoutingIntent } from "./smart-routing-panel";
11
12
  import { SmartRoutingPanelComponent } from "./smart-routing-panel";
12
13
  export declare function assignFuzzyScoresToModels(items: ModelItem[], query: string): void;
13
14
  /**
@@ -76,7 +77,7 @@ export type ModelSelectorSelection = {
76
77
  kind: "smartRouting";
77
78
  intent: SmartRoutingIntent;
78
79
  };
79
- type RoleSelectCallback = (selection: ModelSelectorSelection) => void | Promise<void>;
80
+ type RoleSelectCallback = ((selection: ModelSelectorSelection) => void) | ((selection: ModelSelectorSelection) => Promise<void>) | ((selection: ModelSelectorSelection) => Promise<RoutingSettingsPreview | undefined>);
80
81
  type ModelSelectorViewMode = "presets" | "models" | "smart-routing";
81
82
  /**
82
83
  * Component that renders a canonical model selector with provider tabs.
@@ -100,7 +101,9 @@ export declare class ModelSelectorComponent extends Container {
100
101
  currentThinkingLevel?: ThinkingLevel;
101
102
  activeModelProfile?: string;
102
103
  configuredDefaultChain?: readonly string[];
103
- smartRoutingPreview?: (draft: AutoroutingSetup) => SmartRoutingPreview;
104
+ smartRoutingPreview?: (draft: AutoroutingSetup) => RoutingSettingsPreview;
105
+ smartRoutingDiscardPreview?: (preview: RoutingSettingsPreview) => void;
106
+ smartRoutingStateUnknown?: () => boolean;
104
107
  /** Open the smart-routing panel directly instead of the preset landing. */
105
108
  smartRoutingOnly?: boolean;
106
109
  /** Test seam: synchronous persisted-dismissal check to avoid async render churn. */
@@ -114,7 +117,11 @@ export declare class ModelSelectorComponent extends Container {
114
117
  currentThinkingLevel?: ThinkingLevel;
115
118
  activeModelProfile?: string;
116
119
  }): void;
117
- refreshSmartRoutingState(): void;
120
+ /** The Settings snapshot cannot be trusted after an unresolved durable rollback. */
121
+ invalidateSmartRoutingState(): void;
122
+ markSmartRoutingEffectiveStateUnknown(): void;
123
+ refreshSmartRoutingState(committedPreview?: RoutingSettingsPreview): void;
124
+ render(width: number): string[];
118
125
  handleInput(keyData: string): void;
119
126
  refreshPresetProfiles(profileName?: string): void;
120
127
  getSearchInput(): Input;