@gajae-code/coding-agent 0.15.6 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/dist/types/async/job-manager.d.ts +32 -1
  3. package/dist/types/browser-backend.d.ts +12 -0
  4. package/dist/types/cli/args.d.ts +2 -0
  5. package/dist/types/cli/root-flags.d.ts +14 -0
  6. package/dist/types/cli/update-cli.d.ts +14 -0
  7. package/dist/types/cli.d.ts +7 -0
  8. package/dist/types/commands/launch.d.ts +10 -0
  9. package/dist/types/commands/sdk.d.ts +2 -0
  10. package/dist/types/config/autorouting-tier-map.d.ts +24 -0
  11. package/dist/types/config/billing-path.d.ts +25 -0
  12. package/dist/types/config/config-schema-version.d.ts +13 -1
  13. package/dist/types/config/file-lock.d.ts +5 -0
  14. package/dist/types/config/model-registry.d.ts +22 -0
  15. package/dist/types/config/settings-schema.d.ts +27 -8
  16. package/dist/types/config/settings.d.ts +2 -0
  17. package/dist/types/coordinator-mcp/projection-scan.d.ts +8 -0
  18. package/dist/types/crash/record-loader.d.ts +15 -0
  19. package/dist/types/extensibility/extensions/types.d.ts +8 -3
  20. package/dist/types/gjc-runtime/launch-worktree-reservation.d.ts +21 -0
  21. package/dist/types/gjc-runtime/launch-worktree.d.ts +25 -1
  22. package/dist/types/gjc-runtime/managed-owner-supervisor.d.ts +2 -0
  23. package/dist/types/gjc-runtime/session-state-lock.d.ts +22 -0
  24. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +66 -1
  25. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +1 -0
  26. package/dist/types/gjc-runtime/tmux-sessions.d.ts +27 -0
  27. package/dist/types/main.d.ts +1 -0
  28. package/dist/types/master-mode/context.d.ts +21 -0
  29. package/dist/types/master-mode/first-request.d.ts +34 -0
  30. package/dist/types/master-mode/snapshot.d.ts +32 -0
  31. package/dist/types/modes/acp/acp-agent.d.ts +21 -21
  32. package/dist/types/modes/components/frictionless-onboarding-selector.d.ts +10 -0
  33. package/dist/types/modes/components/model-selector.d.ts +4 -0
  34. package/dist/types/modes/components/oauth-selector.d.ts +1 -0
  35. package/dist/types/modes/components/session-selector.d.ts +1 -1
  36. package/dist/types/modes/components/sessions-dashboard.d.ts +2 -1
  37. package/dist/types/modes/components/status-line/model-name.d.ts +18 -0
  38. package/dist/types/modes/components/status-line/priority-row.d.ts +34 -0
  39. package/dist/types/modes/components/status-line/segments.d.ts +10 -0
  40. package/dist/types/modes/interactive-mode.d.ts +16 -2
  41. package/dist/types/modes/print-mode.d.ts +17 -0
  42. package/dist/types/modes/theme/theme.d.ts +2 -1
  43. package/dist/types/modes/types.d.ts +2 -0
  44. package/dist/types/modes/ui-language.d.ts +7 -1
  45. package/dist/types/sdk/broker/broker.d.ts +79 -2
  46. package/dist/types/sdk/broker/endpoint-authority.d.ts +24 -0
  47. package/dist/types/sdk/broker/ensure.d.ts +3 -0
  48. package/dist/types/sdk/broker/index.d.ts +3 -0
  49. package/dist/types/sdk/broker/lifecycle-ledger.d.ts +6 -0
  50. package/dist/types/sdk/broker/lifecycle.d.ts +40 -0
  51. package/dist/types/sdk/broker/master-capability.d.ts +10 -0
  52. package/dist/types/sdk/broker/session-index.d.ts +40 -11
  53. package/dist/types/sdk/broker/session-scope.d.ts +72 -0
  54. package/dist/types/sdk/broker/spawn-authority.d.ts +201 -0
  55. package/dist/types/sdk/broker/spawn-substrate.d.ts +30 -0
  56. package/dist/types/sdk/broker/startup-budget.d.ts +52 -0
  57. package/dist/types/sdk/broker/state-version.d.ts +21 -1
  58. package/dist/types/sdk/broker/worktree-occupancy.d.ts +28 -0
  59. package/dist/types/sdk/bus/chat-daemon-control.d.ts +3 -0
  60. package/dist/types/sdk/bus/discord-daemon.d.ts +1 -1
  61. package/dist/types/sdk/bus/index.d.ts +9 -1
  62. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +1 -1
  63. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +1 -1
  64. package/dist/types/sdk/bus/slack-conversation.d.ts +1 -1
  65. package/dist/types/sdk/bus/slack-daemon.d.ts +1 -1
  66. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
  67. package/dist/types/sdk/cli/index.d.ts +1 -0
  68. package/dist/types/sdk/cli/master-cli.d.ts +63 -0
  69. package/dist/types/sdk/cli/rows.d.ts +12 -5
  70. package/dist/types/sdk/cli/session-cli.d.ts +20 -3
  71. package/dist/types/sdk/client/client.d.ts +3 -2
  72. package/dist/types/sdk/host/control/dispatch.d.ts +10 -0
  73. package/dist/types/sdk/host/control/index.d.ts +1 -1
  74. package/dist/types/sdk/host/control/operations.d.ts +2 -0
  75. package/dist/types/sdk/host/control/runtime-gate.d.ts +21 -7
  76. package/dist/types/sdk/host/events.d.ts +1 -0
  77. package/dist/types/sdk/host/host.d.ts +10 -0
  78. package/dist/types/sdk/host/query/cursor.d.ts +4 -2
  79. package/dist/types/sdk/host/query/handlers.d.ts +1 -0
  80. package/dist/types/sdk/host/query/revision-store.d.ts +1 -0
  81. package/dist/types/sdk/host/session-runtime.d.ts +70 -17
  82. package/dist/types/sdk/lifecycle/broker-client.d.ts +6 -0
  83. package/dist/types/sdk/lifecycle/service.d.ts +15 -3
  84. package/dist/types/sdk/lifecycle-session.d.ts +3 -1
  85. package/dist/types/sdk/prompt-deadline-manager.d.ts +2 -5
  86. package/dist/types/sdk/receipt-state.d.ts +2 -0
  87. package/dist/types/sdk/router/session-router.d.ts +6 -0
  88. package/dist/types/sdk/session.d.ts +16 -0
  89. package/dist/types/sdk/startup-capability.d.ts +2 -1
  90. package/dist/types/sdk/turn-result.d.ts +6 -0
  91. package/dist/types/session/agent-session.d.ts +52 -7
  92. package/dist/types/session/credential-store-errors.d.ts +1 -0
  93. package/dist/types/session/fold-coordinator.d.ts +29 -2
  94. package/dist/types/session/session-manager.d.ts +79 -2
  95. package/dist/types/session/yield-queue.d.ts +5 -4
  96. package/dist/types/setup/frictionless-onboarding.d.ts +1 -0
  97. package/dist/types/tools/ask.d.ts +1 -0
  98. package/dist/types/tools/bash.d.ts +16 -0
  99. package/dist/types/tools/browser/launch.d.ts +10 -0
  100. package/dist/types/tools/browser/registry.d.ts +8 -0
  101. package/dist/types/tools/gh.d.ts +8 -0
  102. package/dist/types/tools/index.d.ts +10 -10
  103. package/dist/types/tools/job.d.ts +3 -1
  104. package/dist/types/utils/external-editor.d.ts +7 -0
  105. package/examples/extensions/README.md +1 -1
  106. package/examples/extensions/pirate.ts +7 -4
  107. package/package.json +7 -7
  108. package/scripts/generate-sdk-operation-inventory.ts +13 -1
  109. package/scripts/verify-gjc-sdk-canonicalization.ts +35 -1
  110. package/src/async/job-manager.ts +107 -9
  111. package/src/browser-backend.ts +29 -0
  112. package/src/cli/accounts-cli.ts +9 -5
  113. package/src/cli/args.ts +17 -0
  114. package/src/cli/fast-help.ts +1 -0
  115. package/src/cli/plugin-cli.ts +29 -0
  116. package/src/cli/root-flags.ts +5 -0
  117. package/src/cli/update-cli.ts +140 -23
  118. package/src/commands/launch.ts +86 -18
  119. package/src/commands/sdk.ts +135 -28
  120. package/src/config/autorouting-tier-map.ts +12 -0
  121. package/src/config/billing-path.ts +42 -0
  122. package/src/config/config-schema-version.ts +18 -1
  123. package/src/config/file-lock.ts +158 -83
  124. package/src/config/model-preset-registry.ts +178 -23
  125. package/src/config/model-profiles.ts +5 -5
  126. package/src/config/model-registry.ts +291 -42
  127. package/src/config/model-resolver.ts +5 -0
  128. package/src/config/settings-schema.ts +27 -8
  129. package/src/config/settings.ts +51 -15
  130. package/src/coordinator-mcp/projection-scan.ts +27 -6
  131. package/src/coordinator-mcp/question-state.ts +9 -11
  132. package/src/coordinator-mcp/server.ts +115 -21
  133. package/src/crash/index-store.ts +2 -0
  134. package/src/crash/record-loader.ts +10 -0
  135. package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
  136. package/src/extensibility/extensions/runner.ts +27 -0
  137. package/src/extensibility/extensions/types.ts +8 -3
  138. package/src/extensibility/gjc-plugins/installer.ts +51 -11
  139. package/src/extensibility/runtime-skill-discovery.ts +110 -3
  140. package/src/extensibility/skills.ts +22 -12
  141. package/src/gjc-runtime/launch-worktree-reservation.ts +242 -0
  142. package/src/gjc-runtime/launch-worktree.ts +285 -4
  143. package/src/gjc-runtime/managed-owner-supervisor.ts +63 -51
  144. package/src/gjc-runtime/session-state-lock.ts +213 -14
  145. package/src/gjc-runtime/session-state-sidecar.ts +938 -39
  146. package/src/gjc-runtime/tmux-owner-isolation-cli.ts +4 -7
  147. package/src/gjc-runtime/tmux-owner-isolation.ts +18 -3
  148. package/src/gjc-runtime/tmux-sessions.ts +252 -13
  149. package/src/hooks/skill-state.ts +6 -0
  150. package/src/internal-urls/docs-index.generated.ts +15 -15
  151. package/src/internal-urls/issue-pr-protocol.ts +4 -2
  152. package/src/main.ts +61 -3
  153. package/src/master-mode/context.ts +50 -0
  154. package/src/master-mode/first-request.ts +65 -0
  155. package/src/master-mode/snapshot.ts +205 -0
  156. package/src/modes/acp/acp-agent.ts +610 -161
  157. package/src/modes/components/footer.ts +4 -2
  158. package/src/modes/components/frictionless-onboarding-selector.ts +48 -2
  159. package/src/modes/components/model-selector.ts +76 -8
  160. package/src/modes/components/oauth-selector.ts +6 -1
  161. package/src/modes/components/session-selector.ts +23 -15
  162. package/src/modes/components/sessions-dashboard.ts +8 -5
  163. package/src/modes/components/settings-selector.ts +1 -0
  164. package/src/modes/components/status-line/model-name.ts +53 -0
  165. package/src/modes/components/status-line/priority-row.ts +107 -0
  166. package/src/modes/components/status-line/segments.ts +23 -9
  167. package/src/modes/components/tool-status-header.ts +151 -15
  168. package/src/modes/controllers/command-controller.ts +1 -1
  169. package/src/modes/controllers/event-controller.ts +30 -4
  170. package/src/modes/controllers/extension-ui-controller.ts +13 -13
  171. package/src/modes/controllers/input-controller.ts +30 -2
  172. package/src/modes/controllers/selector-controller.ts +200 -98
  173. package/src/modes/interactive-mode.ts +36 -12
  174. package/src/modes/print-mode.ts +64 -0
  175. package/src/modes/prompt-action-autocomplete.ts +30 -4
  176. package/src/modes/runtime-init.ts +12 -9
  177. package/src/modes/theme/theme.ts +5 -0
  178. package/src/modes/types.ts +2 -0
  179. package/src/modes/ui-language.ts +49 -2
  180. package/src/modes/utils/ui-helpers.ts +22 -3
  181. package/src/prompts/agent-fragments/browser-aside.md +22 -0
  182. package/src/prompts/system/master-mode.md +28 -0
  183. package/src/prompts/tools/ask.md +1 -1
  184. package/src/prompts/tools/bash.md +1 -0
  185. package/src/prompts/tools/job.md +1 -1
  186. package/src/sdk/acp/adapter.ts +5 -0
  187. package/src/sdk/broker/broker.ts +1646 -27
  188. package/src/sdk/broker/endpoint-authority.ts +86 -0
  189. package/src/sdk/broker/ensure.ts +81 -3
  190. package/src/sdk/broker/index.ts +3 -0
  191. package/src/sdk/broker/lifecycle-ledger.ts +6 -0
  192. package/src/sdk/broker/lifecycle.ts +440 -75
  193. package/src/sdk/broker/master-capability.ts +232 -0
  194. package/src/sdk/broker/session-index.ts +121 -17
  195. package/src/sdk/broker/session-scope.ts +272 -0
  196. package/src/sdk/broker/spawn-authority.ts +1031 -0
  197. package/src/sdk/broker/spawn-substrate.ts +591 -0
  198. package/src/sdk/broker/startup-budget.ts +144 -2
  199. package/src/sdk/broker/state-version.ts +43 -14
  200. package/src/sdk/broker/transport.ts +1 -0
  201. package/src/sdk/broker/worktree-occupancy.ts +90 -0
  202. package/src/sdk/bus/chat-daemon-control.ts +5 -2
  203. package/src/sdk/bus/chat-daemon-runtime.ts +136 -18
  204. package/src/sdk/bus/discord-daemon.ts +50 -10
  205. package/src/sdk/bus/index.ts +84 -7
  206. package/src/sdk/bus/kind-aware-reconciliation.ts +296 -48
  207. package/src/sdk/bus/lifecycle-commands.ts +4 -0
  208. package/src/sdk/bus/notification-service.ts +22 -5
  209. package/src/sdk/bus/prompt-reconciliation.ts +7 -2
  210. package/src/sdk/bus/reconciliation-store.ts +55 -31
  211. package/src/sdk/bus/slack-conversation.ts +1 -1
  212. package/src/sdk/bus/slack-daemon.ts +72 -38
  213. package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
  214. package/src/sdk/cli/index.ts +1 -0
  215. package/src/sdk/cli/master-cli.ts +259 -0
  216. package/src/sdk/cli/rows.ts +41 -15
  217. package/src/sdk/cli/session-cli.ts +297 -26
  218. package/src/sdk/client/client.ts +14 -8
  219. package/src/sdk/host/control/dispatch.ts +101 -40
  220. package/src/sdk/host/control/index.ts +2 -0
  221. package/src/sdk/host/control/operations.ts +2 -0
  222. package/src/sdk/host/control/runtime-gate.ts +203 -11
  223. package/src/sdk/host/events.ts +1 -0
  224. package/src/sdk/host/host.ts +29 -2
  225. package/src/sdk/host/query/cursor.ts +52 -7
  226. package/src/sdk/host/query/handlers.ts +33 -12
  227. package/src/sdk/host/query/revision-store.ts +12 -0
  228. package/src/sdk/host/session-runtime.test.ts +673 -14
  229. package/src/sdk/host/session-runtime.ts +674 -103
  230. package/src/sdk/host/surface-policy.ts +3 -3
  231. package/src/sdk/lifecycle/broker-client.ts +28 -0
  232. package/src/sdk/lifecycle/service.ts +279 -20
  233. package/src/sdk/lifecycle-session.ts +17 -4
  234. package/src/sdk/prompt-deadline-manager.ts +2 -1
  235. package/src/sdk/protocol/operation-inventory.generated.json +105 -3
  236. package/src/sdk/protocol/operation-registry.ts +14 -4
  237. package/src/sdk/receipt-state.ts +10 -0
  238. package/src/sdk/router/session-router.ts +219 -118
  239. package/src/sdk/session.ts +416 -195
  240. package/src/sdk/startup-capability.ts +1 -0
  241. package/src/sdk/turn-result.ts +22 -0
  242. package/src/session/agent-session.ts +1628 -318
  243. package/src/session/blob-store.ts +15 -5
  244. package/src/session/credential-store-errors.ts +2 -0
  245. package/src/session/fold-coordinator.ts +40 -3
  246. package/src/session/internal/managed-session-storage.ts +153 -78
  247. package/src/session/session-manager.ts +850 -97
  248. package/src/session/yield-queue.ts +24 -10
  249. package/src/setup/frictionless-onboarding.ts +2 -0
  250. package/src/slash-commands/builtin-registry.ts +41 -0
  251. package/src/task/executor.ts +9 -4
  252. package/src/telemetry/events.ts +1138 -12
  253. package/src/tools/ask-contract.test.ts +64 -0
  254. package/src/tools/ask-contract.ts +36 -1
  255. package/src/tools/ask.ts +10 -8
  256. package/src/tools/bash-interactive.ts +11 -2
  257. package/src/tools/bash.ts +412 -75
  258. package/src/tools/browser/launch.ts +37 -0
  259. package/src/tools/browser/registry.ts +99 -9
  260. package/src/tools/cron.ts +6 -4
  261. package/src/tools/descriptors.test.ts +15 -0
  262. package/src/tools/descriptors.ts +5 -1
  263. package/src/tools/gh.ts +104 -48
  264. package/src/tools/github-cache.ts +2 -2
  265. package/src/tools/index.ts +10 -6
  266. package/src/tools/job.ts +4 -1
  267. package/src/tools/monitor.ts +12 -9
  268. package/src/tools/resolve.ts +30 -10
  269. package/src/tools/tool-catalog.generated.ts +2 -2
  270. package/src/utils/external-editor.ts +72 -1
@@ -1,5 +1,15 @@
1
+ import { type ThemeColor } from "../../../modes/theme/theme";
1
2
  import type { RenderedSegment, SegmentContext, StatusLineSegment, StatusLineSegmentId } from "./types";
2
3
  export type { SegmentContext } from "./types";
4
+ /**
5
+ * Icon and color for the active goal indicator, or null when goal mode is not
6
+ * showing. Shared with the narrow-width priority row so the compact glyph keeps
7
+ * the same status color as the full label.
8
+ */
9
+ export declare function goalStatusDisplay(ctx: SegmentContext): {
10
+ icon: string;
11
+ color: ThemeColor;
12
+ } | null;
3
13
  export declare const SEGMENTS: Record<StatusLineSegmentId, StatusLineSegment>;
4
14
  export declare function renderSegment(id: StatusLineSegmentId, ctx: SegmentContext): RenderedSegment;
5
15
  export declare const ALL_SEGMENT_IDS: StatusLineSegmentId[];
@@ -9,7 +9,7 @@ import type { ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetConte
9
9
  import type { CompactOptions } from "../extensibility/extensions/types";
10
10
  import { type Skill } from "../extensibility/skills";
11
11
  import type { NotificationSessionReconcileResult, NotificationSessionStatus } from "../sdk/bus/session-control";
12
- import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
12
+ import type { AgentSession, AgentSessionEvent, AsyncJobSnapshotItem } from "../session/agent-session";
13
13
  import type { HistoryStorage } from "../session/history-storage";
14
14
  import type { SessionContext, SessionManager } from "../session/session-manager";
15
15
  import type { LspStartupServerInfo } from "../tools";
@@ -42,7 +42,21 @@ export declare function getComposerPlaceholder(keybindings: Pick<KeybindingsMana
42
42
  readonly busyPromptMode: "steer" | "queue";
43
43
  readonly showActionHints: boolean;
44
44
  }): string;
45
- export declare function resolveActivityIndicatorMessage(foregroundActive: boolean, activeBackgroundTasks: number, foregroundMessage: string): string | undefined;
45
+ /** Running background work split into the three kinds the activity indicator names. */
46
+ export interface BackgroundActivityTally {
47
+ subagents: number;
48
+ backgroundBash: number;
49
+ monitors: number;
50
+ }
51
+ /**
52
+ * Classify running jobs for the activity indicator using the three locked
53
+ * predicates: subagents are `task` jobs carrying subagent metadata, monitors
54
+ * are flagged by `metadata.monitor`, and background bash is a `bash` job that
55
+ * is not a monitor. A running job matching none of them (a task job without
56
+ * subagent metadata) is outside this indicator and is not counted.
57
+ */
58
+ export declare function tallyBackgroundActivity(running: readonly AsyncJobSnapshotItem[]): BackgroundActivityTally;
59
+ export declare function resolveActivityIndicatorMessage(foregroundActive: boolean, activity: BackgroundActivityTally, foregroundMessage: string): string | undefined;
46
60
  export declare function getWelcomeTranscriptReservedRows(chatContainer: Container, width: number): number;
47
61
  export type WelcomeBannerSettingMode = "auto" | "unicode" | "square" | "ascii";
48
62
  export declare function resolveWelcomeLogoMode(mode: WelcomeBannerSettingMode, env?: Record<string, string | undefined>, platform?: NodeJS.Platform): WelcomeLogoMode;
@@ -5,6 +5,7 @@
5
5
  * - `gjc -p "prompt"` - text output
6
6
  * - `gjc --mode json "prompt"` - JSON event stream
7
7
  */
8
+ import type { AgentMessage } from "@gajae-code/agent-core";
8
9
  import { type ImageContent } from "@gajae-code/ai/core";
9
10
  import type { AgentSession } from "../session/agent-session";
10
11
  /**
@@ -37,8 +38,24 @@ export interface PrintModeOptions {
37
38
  * it is intentionally NOT covered by this exit code.
38
39
  */
39
40
  export declare const CONTEXT_OVERFLOW_EXIT_CODE = 78;
41
+ declare const EMPTY_TURN_ERROR: {
42
+ readonly code: "empty_response";
43
+ readonly message: "Turn completed without assistant text.";
44
+ };
45
+ export type PrintTerminalDisposition = {
46
+ status: "success";
47
+ assistantText: true;
48
+ } | {
49
+ status: "failure";
50
+ error: typeof EMPTY_TURN_ERROR | {
51
+ code: "assistant_error";
52
+ message: string;
53
+ };
54
+ };
55
+ export declare function resolvePrintTerminalDisposition(messages: readonly AgentMessage[], submittedPrompt: boolean, turnStartIndex?: number): PrintTerminalDisposition | undefined;
40
56
  /**
41
57
  * Run in print (single-shot) mode.
42
58
  * Sends prompts to the agent and outputs the result.
43
59
  */
44
60
  export declare function runPrintMode(session: AgentSession, options: PrintModeOptions): Promise<void>;
61
+ export {};
@@ -6,7 +6,7 @@ export type SymbolPreset = "unicode" | "nerd" | "ascii";
6
6
  /**
7
7
  * All available symbol keys organized by category.
8
8
  */
9
- export type SymbolKey = "status.success" | "status.error" | "status.warning" | "status.info" | "status.pending" | "status.disabled" | "status.enabled" | "status.running" | "status.shadowed" | "status.aborted" | "nav.cursor" | "nav.selected" | "nav.expand" | "nav.collapse" | "nav.back" | "tree.branch" | "tree.last" | "tree.vertical" | "tree.horizontal" | "tree.hook" | "boxRound.topLeft" | "boxRound.topRight" | "boxRound.bottomLeft" | "boxRound.bottomRight" | "boxRound.horizontal" | "boxRound.vertical" | "boxSharp.topLeft" | "boxSharp.topRight" | "boxSharp.bottomLeft" | "boxSharp.bottomRight" | "boxSharp.horizontal" | "boxSharp.vertical" | "boxSharp.cross" | "boxSharp.teeDown" | "boxSharp.teeUp" | "boxSharp.teeRight" | "boxSharp.teeLeft" | "sep.powerline" | "sep.powerlineThin" | "sep.powerlineLeft" | "sep.powerlineRight" | "sep.powerlineThinLeft" | "sep.powerlineThinRight" | "sep.block" | "sep.space" | "sep.asciiLeft" | "sep.asciiRight" | "sep.dot" | "sep.slash" | "sep.pipe" | "icon.model" | "icon.plan" | "icon.goal" | "icon.pause" | "icon.folder" | "icon.scratchFolder" | "icon.file" | "icon.git" | "icon.branch" | "icon.pr" | "icon.tokens" | "icon.context" | "icon.cost" | "icon.time" | "icon.pi" | "icon.agents" | "icon.cache" | "icon.input" | "icon.output" | "icon.host" | "icon.session" | "icon.package" | "icon.warning" | "icon.rewind" | "icon.auto" | "icon.fast" | "icon.extensionSkill" | "icon.extensionTool" | "icon.extensionSlashCommand" | "icon.extensionMcp" | "icon.extensionRule" | "icon.extensionHook" | "icon.extensionPrompt" | "icon.extensionContextFile" | "icon.extensionInstruction" | "icon.mic" | "thinking.minimal" | "thinking.low" | "thinking.medium" | "thinking.high" | "thinking.xhigh" | "thinking.max" | "checkbox.checked" | "checkbox.unchecked" | "format.bullet" | "format.dash" | "format.bracketLeft" | "format.bracketRight" | "md.quoteBorder" | "md.hrChar" | "md.bullet" | "lang.default" | "lang.typescript" | "lang.javascript" | "lang.python" | "lang.rust" | "lang.go" | "lang.java" | "lang.c" | "lang.cpp" | "lang.csharp" | "lang.ruby" | "lang.php" | "lang.swift" | "lang.kotlin" | "lang.shell" | "lang.html" | "lang.css" | "lang.json" | "lang.yaml" | "lang.markdown" | "lang.sql" | "lang.docker" | "lang.lua" | "lang.text" | "lang.env" | "lang.toml" | "lang.xml" | "lang.ini" | "lang.conf" | "lang.log" | "lang.csv" | "lang.tsv" | "lang.image" | "lang.pdf" | "lang.archive" | "lang.binary" | "tab.appearance" | "tab.model" | "tab.interaction" | "tab.context" | "tab.editing" | "tab.tools" | "tab.memory" | "tab.tasks" | "tab.providers";
9
+ export type SymbolKey = "status.success" | "status.error" | "status.warning" | "status.info" | "status.pending" | "status.disabled" | "status.enabled" | "status.running" | "status.shadowed" | "status.aborted" | "nav.cursor" | "nav.selected" | "nav.expand" | "nav.collapse" | "nav.back" | "tree.branch" | "tree.last" | "tree.vertical" | "tree.horizontal" | "tree.hook" | "boxRound.topLeft" | "boxRound.topRight" | "boxRound.bottomLeft" | "boxRound.bottomRight" | "boxRound.horizontal" | "boxRound.vertical" | "boxSharp.topLeft" | "boxSharp.topRight" | "boxSharp.bottomLeft" | "boxSharp.bottomRight" | "boxSharp.horizontal" | "boxSharp.vertical" | "boxSharp.cross" | "boxSharp.teeDown" | "boxSharp.teeUp" | "boxSharp.teeRight" | "boxSharp.teeLeft" | "sep.powerline" | "sep.powerlineThin" | "sep.powerlineLeft" | "sep.powerlineRight" | "sep.powerlineThinLeft" | "sep.powerlineThinRight" | "sep.block" | "sep.space" | "sep.asciiLeft" | "sep.asciiRight" | "sep.dot" | "sep.slash" | "sep.pipe" | "icon.model" | "icon.plan" | "icon.goal" | "icon.pause" | "icon.folder" | "icon.scratchFolder" | "icon.file" | "icon.git" | "icon.branch" | "icon.pr" | "icon.tokens" | "icon.context" | "icon.cost" | "icon.time" | "icon.pi" | "icon.agents" | "icon.cache" | "icon.input" | "icon.output" | "icon.host" | "icon.session" | "icon.star" | "icon.package" | "icon.warning" | "icon.rewind" | "icon.auto" | "icon.fast" | "icon.extensionSkill" | "icon.extensionTool" | "icon.extensionSlashCommand" | "icon.extensionMcp" | "icon.extensionRule" | "icon.extensionHook" | "icon.extensionPrompt" | "icon.extensionContextFile" | "icon.extensionInstruction" | "icon.mic" | "thinking.minimal" | "thinking.low" | "thinking.medium" | "thinking.high" | "thinking.xhigh" | "thinking.max" | "checkbox.checked" | "checkbox.unchecked" | "format.bullet" | "format.dash" | "format.bracketLeft" | "format.bracketRight" | "md.quoteBorder" | "md.hrChar" | "md.bullet" | "lang.default" | "lang.typescript" | "lang.javascript" | "lang.python" | "lang.rust" | "lang.go" | "lang.java" | "lang.c" | "lang.cpp" | "lang.csharp" | "lang.ruby" | "lang.php" | "lang.swift" | "lang.kotlin" | "lang.shell" | "lang.html" | "lang.css" | "lang.json" | "lang.yaml" | "lang.markdown" | "lang.sql" | "lang.docker" | "lang.lua" | "lang.text" | "lang.env" | "lang.toml" | "lang.xml" | "lang.ini" | "lang.conf" | "lang.log" | "lang.csv" | "lang.tsv" | "lang.image" | "lang.pdf" | "lang.archive" | "lang.binary" | "tab.appearance" | "tab.model" | "tab.interaction" | "tab.context" | "tab.editing" | "tab.tools" | "tab.memory" | "tab.tasks" | "tab.providers";
10
10
  export type SpinnerType = "status" | "activity";
11
11
  export declare const THEME_COLOR_KEYS: readonly ["accent", "border", "borderAccent", "borderMuted", "success", "error", "warning", "muted", "dim", "text", "thinkingText", "selectedBg", "userMessageBg", "userMessageText", "customMessageBg", "customMessageText", "customMessageLabel", "toolPendingBg", "toolSuccessBg", "toolErrorBg", "toolTitle", "toolOutput", "mdHeading", "mdLink", "mdLinkUrl", "mdCode", "mdCodeBlock", "mdCodeBlockBorder", "mdQuote", "mdQuoteBorder", "mdHr", "mdListBullet", "toolDiffAdded", "toolDiffRemoved", "toolDiffContext", "syntaxComment", "syntaxKeyword", "syntaxFunction", "syntaxVariable", "syntaxString", "syntaxNumber", "syntaxType", "syntaxOperator", "syntaxPunctuation", "thinkingOff", "thinkingMinimal", "thinkingLow", "thinkingMedium", "thinkingHigh", "thinkingXhigh", "bashMode", "pythonMode", "statusLineBg", "statusLineSep", "statusLineModel", "statusLinePath", "statusLineGitClean", "statusLineGitDirty", "statusLineContext", "statusLineSpend", "statusLineStaged", "statusLineDirty", "statusLineUntracked", "statusLineOutput", "statusLineCost", "statusLineSubagents"];
12
12
  export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "thinkingText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "bashMode" | "pythonMode" | "statusLineSep" | "statusLineModel" | "statusLinePath" | "statusLineGitClean" | "statusLineGitDirty" | "statusLineContext" | "statusLineSpend" | "statusLineStaged" | "statusLineDirty" | "statusLineUntracked" | "statusLineOutput" | "statusLineCost" | "statusLineSubagents";
@@ -128,6 +128,7 @@ export declare class Theme {
128
128
  output: string;
129
129
  host: string;
130
130
  session: string;
131
+ star: string;
131
132
  package: string;
132
133
  warning: string;
133
134
  rewind: string;
@@ -35,6 +35,8 @@ export type CompactionQueuedMessage = {
35
35
  text: string;
36
36
  mode: "steer" | "followUp";
37
37
  followUpQueuePolicy?: "sequential";
38
+ /** Composer steers stay one per poll even under `steeringMode: "all"`. */
39
+ steerQueuePolicy?: "sequential";
38
40
  };
39
41
  export type SubmittedUserInput = {
40
42
  text: string;
@@ -1,4 +1,4 @@
1
- export declare const UI_LANGUAGES: readonly ["en", "ko", "ja"];
1
+ export declare const UI_LANGUAGES: readonly ["en", "ko", "zh", "ja"];
2
2
  export type UiLanguage = (typeof UI_LANGUAGES)[number];
3
3
  declare const ENGLISH_STRINGS: {
4
4
  readonly "settings.title": "Settings";
@@ -21,6 +21,7 @@ declare const ENGLISH_STRINGS: {
21
21
  readonly "settings.language.description": "Language for human-facing interactive UI text";
22
22
  readonly "settings.language.english": "English";
23
23
  readonly "settings.language.korean": "Korean (한국어)";
24
+ readonly "settings.language.chinese": "Chinese (简体中文)";
24
25
  readonly "settings.language.japanese": "Japanese (日本語)";
25
26
  readonly "language.current": "Current UI language:";
26
27
  readonly "language.changed": "UI language changed to";
@@ -29,6 +30,11 @@ declare const ENGLISH_STRINGS: {
29
30
  export type UiStringKey = keyof typeof ENGLISH_STRINGS;
30
31
  /** User selection is authoritative; invalid or unavailable values deterministically fall back to English. */
31
32
  export declare function resolveUiLanguage(value: unknown): UiLanguage;
33
+ /** Resolve explicit startup preference without allowing an invalid value to block startup. */
34
+ export declare function resolveExplicitUiLanguage(configuredValue: unknown, environmentValue: string | undefined): {
35
+ language: UiLanguage;
36
+ hasPreference: boolean;
37
+ };
32
38
  export declare function uiString(language: unknown, key: UiStringKey): string;
33
39
  /** Endonym shown by `/language` and the language submenu. */
34
40
  export declare const UI_LANGUAGE_LABELS: Record<UiLanguage, string>;
@@ -5,6 +5,7 @@ import { type DirectoryMigrationPolicy } from "../session-directory";
5
5
  import { type BrokerDiscovery, type BrokerPublicationObservation, type RedactedBrokerDiscovery } from "./discovery";
6
6
  import { type LifecycleDurableEffectsReceipt, LifecycleLedger, type LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
7
7
  import { SessionIndex } from "./session-index";
8
+ import { type MasterCapabilityVerifier, type SpawnSubstrateFailure, type SpawnSubstrateProvider } from "./spawn-authority";
8
9
  export interface BrokerSettings {
9
10
  agentDir: string;
10
11
  packageGeneration?: string;
@@ -12,6 +13,14 @@ export interface BrokerSettings {
12
13
  heartbeatTtlMs?: number;
13
14
  /** Broker-owned migration policy. Client lifecycle frames cannot select it. */
14
15
  resolveDirectoryMigration?: (_cwd: string) => Promise<DirectoryMigrationPolicy>;
16
+ /** Exact managed-substrate authority. Tests inject an in-memory provider. */
17
+ spawnSubstrateProvider?: SpawnSubstrateProvider;
18
+ /** Ordered Q26 host control seam; production uses exact endpoint attachments. */
19
+ spawnPromptLayer?: SpawnPromptLayer;
20
+ /** Live-only, host-mediated capability verifier. It retains no request input. */
21
+ masterCapabilityVerifier?: MasterCapabilityVerifier;
22
+ /** Grace before an orphaned spawn child closes; schema-bounded in production. */
23
+ masterOrphanGraceMs?: number;
15
24
  /** Host model resolver override for lifecycle tests and embedders. */
16
25
  resolveModelPin?: SdkHostModelResolver;
17
26
  }
@@ -21,8 +30,13 @@ type ResolvedBrokerSettings = {
21
30
  port: number;
22
31
  heartbeatTtlMs: number;
23
32
  resolveDirectoryMigration: (_cwd: string) => Promise<DirectoryMigrationPolicy>;
33
+ masterCapabilityVerifier?: MasterCapabilityVerifier;
34
+ spawnSubstrateProvider?: SpawnSubstrateProvider;
35
+ spawnPromptLayer?: SpawnPromptLayer;
36
+ masterOrphanGraceMs: number;
24
37
  };
25
- export type BrokerErrorCode = "idempotency_conflict" | "terminal_uncertain" | "broker_restarting" | "unavailable" | "endpoint_stale" | "resource_gone" | "invalid_input" | "spawn_failed" | "ready_then_exited" | "endpoint_unreadable" | "startup_admission_timeout" | "startup_admission_refused" | "readiness_timeout" | "close_refused" | "not_found" | "live_session" | "cleanup_pending" | (string & {});
38
+ export declare function resolveBrokerPackageGeneration(): string;
39
+ export type BrokerErrorCode = "idempotency_conflict" | "terminal_uncertain" | "broker_restarting" | "unavailable" | "endpoint_stale" | "resource_gone" | "invalid_input" | "spawn_failed" | "ready_then_exited" | "endpoint_unreadable" | "startup_admission_timeout" | "startup_admission_refused" | "readiness_timeout" | "worktree_preparation_timeout" | "dependency_preparation_timeout" | "worktree_in_use" | "incarnation_unavailable" | "close_refused" | "not_found" | "live_session" | "cleanup_pending" | (string & {});
26
40
  export type BrokerCleanupIdentity = {
27
41
  dev: string;
28
42
  ino: string;
@@ -115,7 +129,7 @@ export type BrokerResponse = {
115
129
  error: {
116
130
  code: BrokerErrorCode;
117
131
  message: string;
118
- details?: ModelProfileErrorDetails;
132
+ details?: ModelProfileErrorDetails | SpawnSubstrateFailure;
119
133
  endpoint?: "unavailable";
120
134
  cleanup?: BrokerCleanupEvidence;
121
135
  };
@@ -123,6 +137,58 @@ export type BrokerResponse = {
123
137
  durableEffects?: LifecycleDurableEffectsReceipt;
124
138
  startupFailure?: LifecycleStartupFailureReceipt;
125
139
  };
140
+ /** Complete five-leg child endpoint pin captured at registration. */
141
+ export type SpawnHostRegistration = {
142
+ sessionId: string;
143
+ endpointGeneration: number;
144
+ pid: number;
145
+ processIncarnation: string;
146
+ /** Workspace the child was launched into; bound so a colliding pid elsewhere cannot pass. */
147
+ cwd: string;
148
+ stateRoot: string;
149
+ };
150
+ export type SpawnPromptDispatch = {
151
+ kind: "accepted";
152
+ commandId: string;
153
+ turnId: string;
154
+ acceptedAt: number;
155
+ } | {
156
+ kind: "pre_send_rejected";
157
+ } | {
158
+ kind: "uncertain";
159
+ };
160
+ export type SpawnQ26Reconciliation = {
161
+ status: "accepted" | "in_flight" | "terminal_ok" | "failed" | "unknown";
162
+ clientRef?: string;
163
+ commandId?: string;
164
+ turnId?: string;
165
+ acceptedAt?: number;
166
+ };
167
+ /** Q26-only host control seam. It never receives or returns durable request material. */
168
+ export interface SpawnPromptLayer {
169
+ awaitRegistration(input: {
170
+ childId: string;
171
+ cwd: string;
172
+ stateRoot: string;
173
+ }): Promise<{
174
+ ok: true;
175
+ registration: SpawnHostRegistration;
176
+ } | {
177
+ ok: false;
178
+ }>;
179
+ dispatch(input: {
180
+ sessionId: string;
181
+ task: string;
182
+ clientRef: string;
183
+ /** Endpoint identity proven at registration; implementations must not talk to another endpoint. */
184
+ pinned: SpawnHostRegistration;
185
+ }): Promise<SpawnPromptDispatch>;
186
+ reconcile(input: {
187
+ sessionId: string;
188
+ clientRef: string;
189
+ pinned: SpawnHostRegistration;
190
+ }): Promise<SpawnQ26Reconciliation>;
191
+ }
126
192
  /** Test seam for lifecycle serialization identity. */
127
193
  export declare function lifecycleTargetForTest(operation: string, input: Record<string, unknown>): unknown;
128
194
  /** Tombstone prefix used by {@link Broker.reclaimStaleLock} when a dead owner's lock is renamed aside. */
@@ -203,6 +269,17 @@ export declare class Broker {
203
269
  readonly ledger: LifecycleLedger;
204
270
  discovery: BrokerDiscovery | null;
205
271
  constructor(settings: BrokerSettings);
272
+ /** Host capability validation is live-only; no request material is retained. */
273
+ verifyMasterCapability(ownerSessionId: string, rawCapability: string, attestationEpoch: string): Promise<{
274
+ allowed: boolean;
275
+ }>;
276
+ /**
277
+ * Replays pending exact closes, then reaps children after confirmed master
278
+ * loss. Orphan clocks survive recovery and expiry converges through the same
279
+ * exact close path for only the matching owned child.
280
+ */
281
+ /** Deterministic single reap pass; used by maintenance paths and tests. */
282
+ reapSpawnOrphansOnce(): Promise<void>;
206
283
  runStartup<T>(queueWaitMs: number, timing: StartupAdmissionTiming, task: (admittedAt: number) => Promise<T>): Promise<StartupAdmissionResult<T>>;
207
284
  start(): Promise<BrokerDiscovery>;
208
285
  get ownsDiscovery(): boolean;
@@ -0,0 +1,24 @@
1
+ import * as fs from "node:fs/promises";
2
+ export type EndpointFileRead = {
3
+ source: string;
4
+ dev: bigint;
5
+ ino: bigint;
6
+ nlink: bigint;
7
+ size: bigint;
8
+ mtimeNs: bigint;
9
+ mtimeMs: number;
10
+ };
11
+ export type EndpointAuthorityFilesystem = Pick<typeof fs, "open">;
12
+ export type IndexedEndpointAuthority = {
13
+ endpointMtimeMs?: number;
14
+ endpointFileId?: string;
15
+ };
16
+ /**
17
+ * Reads one endpoint from the descriptor opened for its pathname. The opened
18
+ * object must remain a small, singly-linked regular file with stable identity
19
+ * and metadata for the whole read; a pathname replacement cannot affect the
20
+ * bytes returned by this function.
21
+ */
22
+ export declare function readEndpointFile(filePath: string, filesystem?: EndpointAuthorityFilesystem): Promise<EndpointFileRead | undefined>;
23
+ /** Match a descriptor-bound endpoint read to the index representation. */
24
+ export declare function matchesIndexedEndpointFile(file: Pick<EndpointFileRead, "dev" | "ino" | "mtimeMs">, authority: IndexedEndpointAuthority): boolean;
@@ -61,6 +61,7 @@ interface ReapTiming {
61
61
  gracefulMs: number;
62
62
  killVerifyMs: number;
63
63
  }
64
+ type BrokerOwnerIdentity = Pick<BrokerDiscovery, "ownerId" | "pid" | "incarnation">;
64
65
  /** Starts the detached broker entrypoint when discovery has no live owner. */
65
66
  export declare function ensureBroker(settings: EnsureBrokerSettings): Promise<BrokerDiscovery>;
66
67
  /** Starts one fresh fixture broker and returns its sole exact-child close lease. */
@@ -73,6 +74,8 @@ export declare function startFixtureBrokerWithLeaseForTest(settings: EnsureBroke
73
74
  export declare function startFixtureBrokerCommandWithLeaseForTest(command: FixtureBrokerCommand): StartedFixtureBrokerCommand;
74
75
  /** Test hook: returns a stop handle for the detached broker this process spawned. */
75
76
  export declare function brokerOwnerForTest(agentDir: string): BrokerOwner | undefined;
77
+ /** Test hook: verifies the complete broker owner identity used during stale retirement. */
78
+ export declare function brokerOwnerIdentityMatchesForTest(left: BrokerOwnerIdentity | null, right: BrokerOwnerIdentity): boolean;
76
79
  /** Test hook: drives the detached-broker reap on a controllable child surface. */
77
80
  export declare function reapSpawnedBrokerForTest(child: ChildProcess, timing?: ReapTiming): Promise<void>;
78
81
  /** Test hook: resolves the complete broker environment without spawning. */
@@ -4,6 +4,9 @@ export * from "./ensure";
4
4
  export * from "./identity";
5
5
  export * from "./lifecycle";
6
6
  export * from "./lifecycle-ledger";
7
+ export * from "./master-capability";
7
8
  export * from "./session-index";
9
+ export * from "./spawn-authority";
10
+ export * from "./spawn-substrate";
8
11
  export * from "./startup-budget";
9
12
  export * from "./transport";
@@ -43,6 +43,7 @@ export interface LifecycleDurableEffectsReceipt {
43
43
  cwdDigest: string;
44
44
  created: boolean;
45
45
  reused: boolean;
46
+ createdBranch: boolean;
46
47
  branchDigest?: string;
47
48
  };
48
49
  transcript?: {
@@ -50,6 +51,11 @@ export interface LifecycleDurableEffectsReceipt {
50
51
  contentDigest: string;
51
52
  };
52
53
  startup?: LifecycleStartupFailureReceipt;
54
+ timings?: {
55
+ worktreePreparationMs?: number;
56
+ dependencyPreparationMs?: number;
57
+ spawnAuthorizedAtOffsetMs?: number;
58
+ };
53
59
  digest?: string;
54
60
  }
55
61
  export interface LifecycleLedgerEntry {
@@ -1,10 +1,12 @@
1
1
  import { type ChildProcess } from "node:child_process";
2
+ import { type GjcLaunchWorktreePlan } from "../../gjc-runtime/launch-worktree";
2
3
  import type { SessionLifecycleMcpServer } from "../acp/mcp";
3
4
  import { type SdkStartupFailure, type SdkStartupRollbackResult } from "../startup-capability";
4
5
  import type { Broker, BrokerCleanupEvidence, BrokerResponse } from "./broker";
5
6
  import type { LifecycleDurableEffectsReceipt, LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
6
7
  import { type ProcessIncarnationCommandRunner, type ProcessIncarnationOptions, parseDarwinProcessIncarnation, processIncarnation } from "./process-incarnation";
7
8
  import { type SdkInternalSpawnCommand } from "./runtime";
9
+ import { type IndexedSession } from "./session-index";
8
10
  export { type ProcessIncarnationCommandRunner, type ProcessIncarnationOptions, parseDarwinProcessIncarnation, processIncarnation, };
9
11
  export declare function terminalUncertainStartupMessage(response: BrokerResponse): string;
10
12
  export declare function waitForChildSpawn(spawned: Pick<ChildProcess, "off" | "on" | "once">, onPostSpawnError?: (error: Error) => void): Promise<void>;
@@ -25,10 +27,22 @@ type LifecycleCommand = SdkInternalSpawnCommand | {
25
27
  args: string[];
26
28
  };
27
29
  type LifecycleCommandResolver = () => LifecycleCommand;
30
+ type EnsureLaunchWorktreeForTest = (plan: GjcLaunchWorktreePlan, opts: {
31
+ signal: AbortSignal;
32
+ deadlineAt: number;
33
+ }) => Promise<SessionLifecycleWorktreeReceipt & {
34
+ createdBranch: boolean;
35
+ }>;
36
+ type EnsureReusableNodeModulesForTest = (sourceRoot: string, worktreePath: string, opts: {
37
+ signal: AbortSignal;
38
+ deadlineAt: number;
39
+ }) => Promise<"symlink" | "present" | "missing">;
28
40
  /** Test-only hook for simulating a crash immediately after one exact lifecycle detach. */
29
41
  export declare function setLifecycleCleanupHookForTest(broker: Broker, hook: (() => void) | undefined): void;
30
42
  export declare function setLifecycleCommandResolverForTest(broker: Broker, resolver: LifecycleCommandResolver | undefined): void;
31
43
  export declare function setLifecycleTimingForTest(broker: Broker, timing: LifecycleTiming | undefined): void;
44
+ export declare function setEnsureLaunchWorktreeForTest(_broker: Broker | undefined, fn?: EnsureLaunchWorktreeForTest | undefined): void;
45
+ export declare function setEnsureReusableNodeModulesForTest(_broker: Broker | undefined, fn?: EnsureReusableNodeModulesForTest | undefined): void;
32
46
  /** Deterministic platform seam for Windows-only ready-then-exit tolerance. */
33
47
  export declare function setLifecycleHostPlatformForTest(platform: NodeJS.Platform | undefined): void;
34
48
  export declare function readyThenExitToleranceEnabledForTest(): boolean;
@@ -44,6 +58,7 @@ export interface SessionLifecycleWorktreeReceipt {
44
58
  cwd: string;
45
59
  created: boolean;
46
60
  reused: boolean;
61
+ createdBranch: boolean;
47
62
  branch?: string;
48
63
  }
49
64
  export interface SessionLifecycleTranscriptIdentity {
@@ -111,12 +126,35 @@ export type SessionLifecycleLaunchRequest = SessionLifecycleLaunchRequestBase &
111
126
  });
112
127
  export declare function readSessionLifecycleLaunchRequest(value: string | undefined, now?: number): SessionLifecycleLaunchRequest;
113
128
  type CleanupEvidence = BrokerCleanupEvidence;
129
+ export declare function validateBrokerModelPresetSync(agentDir: string, requestedProfile: string): string | BrokerResponse;
114
130
  export declare function validateBrokerModelPresetForTest(agentDir: string, requestedProfile: string): string | BrokerResponse;
115
131
  /** Test seam: the session-host command override as resolved from trusted env. */
116
132
  export declare function sdkSessionCommandOverrideForTest(): {
117
133
  file: string;
118
134
  args: string[];
119
135
  } | undefined;
136
+ /**
137
+ * Reuses the ordinary lifecycle host bootstrap without performing its direct
138
+ * process spawn. Broker-owned substrate providers receive this exact argv and
139
+ * split inherited/child-specific environment contract as their only launch
140
+ * authority for session.spawn.
141
+ */
142
+ export type SpawnChildHostLaunch = {
143
+ childId: string;
144
+ cwd: string;
145
+ stateRoot: string;
146
+ argv: readonly string[];
147
+ inheritedEnv: Readonly<Record<string, string>>;
148
+ env: Readonly<Record<string, string>>;
149
+ effectMarker: string;
150
+ };
151
+ export declare function prepareSpawnChildHostLaunch(broker: Broker, input: {
152
+ cwd: string;
153
+ modelId?: string;
154
+ modelPreset?: string;
155
+ childId?: string;
156
+ receivedAt?: number;
157
+ }): SpawnChildHostLaunch;
120
158
  type EffectMarker = {
121
159
  pid: number;
122
160
  effectMarker: string;
@@ -187,6 +225,8 @@ export declare function probePublishedReadyAuthorityForTest(root: string, id: st
187
225
  * by a reused pid (#4712 review).
188
226
  */
189
227
  export declare function removeOwnedLifecycleArtifactsForTest(root: string, id: string, expected: EffectMarker): Promise<boolean>;
228
+ /** Test seam for the worktree occupancy boundary. */
229
+ export declare function worktreeOccupantForTest(sessions: IndexedSession[], worktreePath: string, observe?: (pid: number, expectedIncarnation: string | undefined) => ProcessObservation): string | null;
190
230
  export declare function canonicalDeleteLocatorPath(pathname: string): string;
191
231
  export interface LifecycleExecutionOutcome {
192
232
  response: BrokerResponse;
@@ -0,0 +1,10 @@
1
+ import { type IndexedSession, type SessionIndex } from "./session-index";
2
+ import type { MasterCapabilityVerifier } from "./spawn-authority";
3
+ export type SessionEndpoint = {
4
+ url: string;
5
+ token: string;
6
+ };
7
+ /** Reads and validates a registered host's authenticated endpoint record. */
8
+ export declare function readEndpoint(record: IndexedSession): Promise<SessionEndpoint | undefined>;
9
+ /** Creates the ephemeral effective-host verifier used by broker spawn admission. */
10
+ export declare function createMasterCapabilityVerifier(index: SessionIndex): MasterCapabilityVerifier;
@@ -1,4 +1,4 @@
1
- import { SDK_STATE_VERSION } from "./state-version";
1
+ import { SDK_STATE_VERSION, SESSION_INDEX_EVENT_VERSION } from "./state-version";
2
2
  export type SessionIndexEventType = "host_registered" | "host_heartbeat" | "host_unregistered" | "lifecycle_started" | "lifecycle_terminal" | "session_closed" | "session_deleted" | "record_reconciled";
3
3
  export type SessionActivityState = "active" | "idle";
4
4
  /** Coalesced broker-owned heartbeat checkpoint (C2): state plus the observation time. */
@@ -28,15 +28,41 @@ export interface SessionIndexProcessObservation {
28
28
  readonly incarnation: string;
29
29
  readonly isRunning: () => boolean;
30
30
  }
31
+ /**
32
+ * Canonical location facts for one SDK session.
33
+ *
34
+ * `cwd` is always a realpath-canonicalized directory. `worktreeRoot` is the
35
+ * canonical Git worktree root when `cwd` is in a worktree, otherwise `null`.
36
+ * `stateRoot` retains its host-provided authority spelling and is never derived
37
+ * from either canonical path.
38
+ */
39
+ export type SessionLocatorV2 = {
40
+ cwd: string;
41
+ worktreeRoot: string | null;
42
+ stateRoot: string;
43
+ };
44
+ /** Durable master-role facts. `attestationEpoch` is opaque random broker state. */
45
+ export type MasterRoleAttestationV2 = {
46
+ version: 2;
47
+ ownerSessionId: string;
48
+ launchPid: number;
49
+ launchProcessIncarnation: string;
50
+ role: "master";
51
+ attestationEpoch: string;
52
+ };
53
+ export declare function newMasterAttestationEpoch(): string;
54
+ /** Canonicalize a cwd without making an unavailable path a launch failure. */
55
+ export declare function canonicalSessionCwd(cwd: string): Promise<string>;
56
+ /** Resolve the canonical worktree root; non-Git and probe failures are `null`. */
57
+ export declare function sessionWorktreeRoot(cwd: string): Promise<string | null>;
58
+ /** Build the only permitted locator shape for a newly registered session. */
59
+ export declare function resolveSessionLocator(cwd: string, stateRoot: string): Promise<SessionLocatorV2>;
31
60
  export interface SessionIndexEvent {
32
- version: typeof SDK_STATE_VERSION;
61
+ version: typeof SDK_STATE_VERSION | typeof SESSION_INDEX_EVENT_VERSION;
33
62
  indexSeq: number;
34
63
  type: SessionIndexEventType;
35
64
  sessionId: string;
36
- locator: {
37
- repo: string;
38
- stateRoot: string;
39
- };
65
+ locator: SessionLocatorV2;
40
66
  endpointGeneration: number;
41
67
  pid: number;
42
68
  /**
@@ -47,26 +73,28 @@ export interface SessionIndexEvent {
47
73
  */
48
74
  processIncarnation?: string;
49
75
  endpointMtimeMs?: number;
76
+ /** Immutable endpoint file identity captured by the broker at registration. */
77
+ endpointFileId?: string;
50
78
  lifecycleRequestId?: string;
51
79
  terminalUncertain?: boolean;
52
80
  /** OS process incarnation (C1); absent on legacy v1/v2 events. */
53
81
  hostIncarnation?: string;
54
82
  /** Present on host_heartbeat checkpoints (C2). */
55
83
  activity?: SessionActivity;
84
+ masterRole?: MasterRoleAttestationV2;
56
85
  ts: number;
57
86
  checksum: string;
58
87
  }
59
88
  export interface IndexedSession {
60
89
  sessionId: string;
61
- locator: {
62
- repo: string;
63
- stateRoot: string;
64
- };
90
+ locator: SessionLocatorV2;
65
91
  endpointGeneration: number;
66
92
  pid: number;
67
93
  /** OS start incarnation of `pid` as published by its own host at registration. */
68
94
  processIncarnation?: string;
69
95
  endpointMtimeMs?: number;
96
+ /** Immutable endpoint file identity captured by the broker at registration. */
97
+ endpointFileId?: string;
70
98
  live: boolean;
71
99
  indexSeq: number;
72
100
  lifecycleRequestId?: string;
@@ -76,6 +104,7 @@ export interface IndexedSession {
76
104
  activity?: SessionActivity;
77
105
  /** Wall-clock timestamp of the latest admitted heartbeat, when one exists. */
78
106
  lastHeartbeatAt?: number;
107
+ masterRole?: MasterRoleAttestationV2;
79
108
  /** True when more than one unresolved authority-fencing state-root identity claims this session id. */
80
109
  ambiguous: boolean;
81
110
  /** True when the identity's latest event is terminal (DR-1 retains stopped rows for inspection/offline tail). */
@@ -118,7 +147,7 @@ export interface SessionIndexRepairResult extends SessionIndexDiagnosis {
118
147
  quarantinePath?: string;
119
148
  }
120
149
  /** Admission-fence rejection codes recorded in the durable index audit (C5/C4). */
121
- export type SessionIndexAuditCode = "rejected_superseded_incarnation" | "rejected_after_tombstone";
150
+ export type SessionIndexAuditCode = "rejected_superseded_incarnation" | "rejected_after_tombstone" | "rejected_legacy_locator";
122
151
  export interface SessionIndexAuditRecord {
123
152
  version: typeof SDK_STATE_VERSION;
124
153
  code: SessionIndexAuditCode;
@@ -0,0 +1,72 @@
1
+ import { type SessionLocatorV2 } from "./session-index";
2
+ export type ScopeNameV1 = "repo" | "pwd" | "global";
3
+ export type ScopeRequestV1 = {
4
+ version: 1;
5
+ requested: ScopeNameV1;
6
+ requestAnchor: {
7
+ cwd: string;
8
+ worktreeRoot: string | null;
9
+ };
10
+ };
11
+ export type ResolvedScopeV1 = {
12
+ version: 1;
13
+ requested: ScopeNameV1;
14
+ requestAnchor: {
15
+ cwd: string;
16
+ worktreeRoot: string | null;
17
+ };
18
+ resolved: {
19
+ kind: "repo";
20
+ worktreeRoot: string;
21
+ } | {
22
+ kind: "pwd";
23
+ cwd: string;
24
+ } | {
25
+ kind: "global";
26
+ visibility: "current-broker";
27
+ } | null;
28
+ resolution: "resolved" | "not-in-git-worktree";
29
+ };
30
+ export type SdkSearchRowV1 = {
31
+ id: string;
32
+ locator: {
33
+ cwd: string;
34
+ worktreeRoot: string | null;
35
+ stateRoot: string;
36
+ };
37
+ live: boolean;
38
+ probe?: "reachable" | "unreachable" | "stale";
39
+ };
40
+ export type SdkSearchResultV1 = {
41
+ version: 1;
42
+ scope: ResolvedScopeV1;
43
+ status: "populated" | "empty" | "not-in-git-worktree" | "unavailable";
44
+ observedAt: string;
45
+ indexSeq?: number;
46
+ rows: readonly SdkSearchRowV1[];
47
+ cursor?: string;
48
+ warnings: readonly string[];
49
+ error?: {
50
+ code: string;
51
+ message: string;
52
+ };
53
+ };
54
+ export declare class ScopeRequestValidationError extends Error {
55
+ constructor(message: string);
56
+ }
57
+ /** Strictly validates the versioned request shape before canonical resolution. */
58
+ export declare function scopeRequestV1(value: unknown): ScopeRequestV1 | undefined;
59
+ /** Strictly validates a resolved descriptor returned by Broker pages. */
60
+ export declare function resolvedScopeV1(value: unknown): ResolvedScopeV1 | undefined;
61
+ /** Strictly validates a safe broker-search row. */
62
+ export declare function sdkSearchRowV1(value: unknown): SdkSearchRowV1 | undefined;
63
+ /** Strictly validates the aggregate credential-free search envelope. */
64
+ export declare function sdkSearchResultV1(value: unknown): SdkSearchResultV1 | undefined;
65
+ /** Resolves and validates an anchor against its canonical cwd worktree identity. */
66
+ export declare function resolveScopeRequest(request: ScopeRequestV1): Promise<ResolvedScopeV1>;
67
+ export declare function scopeMatchesLocator(scope: ResolvedScopeV1, locator: Pick<SessionLocatorV2, "cwd" | "worktreeRoot">): boolean;
68
+ export declare function searchRowV1(session: {
69
+ sessionId: string;
70
+ locator: SessionLocatorV2;
71
+ live: boolean;
72
+ }): SdkSearchRowV1;