@gajae-code/coding-agent 0.15.5 → 0.16.0

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 (272) hide show
  1. package/CHANGELOG.md +85 -1
  2. package/dist/types/async/job-manager.d.ts +83 -0
  3. package/dist/types/cli/args.d.ts +2 -0
  4. package/dist/types/cli/auth-gateway-cli.d.ts +17 -0
  5. package/dist/types/cli/model-presets-cli.d.ts +9 -0
  6. package/dist/types/cli/root-flags.d.ts +14 -0
  7. package/dist/types/cli/update-cli.d.ts +15 -0
  8. package/dist/types/cli.d.ts +7 -0
  9. package/dist/types/commands/auth-gateway.d.ts +3 -0
  10. package/dist/types/commands/gc.d.ts +13 -0
  11. package/dist/types/commands/launch.d.ts +10 -0
  12. package/dist/types/commands/model-presets.d.ts +21 -0
  13. package/dist/types/config/autorouting-tier-map.d.ts +120 -0
  14. package/dist/types/config/file-lock.d.ts +54 -2
  15. package/dist/types/config/internal/model-preset-registry-test-state.d.ts +4 -0
  16. package/dist/types/config/internal/model-preset-registry-test-support.d.ts +3 -0
  17. package/dist/types/config/keybindings.d.ts +3 -2
  18. package/dist/types/config/model-preset-registry.d.ts +368 -0
  19. package/dist/types/config/model-profile-activation.d.ts +39 -0
  20. package/dist/types/config/model-profiles.d.ts +5 -3
  21. package/dist/types/config/model-registry.d.ts +17 -5
  22. package/dist/types/config/settings-schema.d.ts +19 -1
  23. package/dist/types/config/settings.d.ts +2 -0
  24. package/dist/types/coordinator-mcp/model-preset.d.ts +7 -5
  25. package/dist/types/coordinator-mcp/projection-scan.d.ts +54 -0
  26. package/dist/types/crash/record-loader.d.ts +15 -0
  27. package/dist/types/extensibility/extensions/types.d.ts +2 -5
  28. package/dist/types/gjc-runtime/empty-delete-gc.d.ts +58 -0
  29. package/dist/types/gjc-runtime/gc-runtime.d.ts +2 -0
  30. package/dist/types/gjc-runtime/launch-worktree-reservation.d.ts +21 -0
  31. package/dist/types/gjc-runtime/managed-owner-supervisor.d.ts +2 -0
  32. package/dist/types/gjc-runtime/session-state-lock.d.ts +35 -6
  33. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +72 -1
  34. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +1 -0
  35. package/dist/types/gjc-runtime/tmux-sessions.d.ts +27 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/main.d.ts +3 -1
  38. package/dist/types/master-mode/context.d.ts +21 -0
  39. package/dist/types/master-mode/first-request.d.ts +34 -0
  40. package/dist/types/master-mode/snapshot.d.ts +32 -0
  41. package/dist/types/modes/components/frictionless-onboarding-selector.d.ts +10 -0
  42. package/dist/types/modes/components/jobs-overlay-model.d.ts +4 -2
  43. package/dist/types/modes/components/oauth-selector.d.ts +1 -0
  44. package/dist/types/modes/components/status-line/model-name.d.ts +18 -0
  45. package/dist/types/modes/components/status-line/priority-row.d.ts +34 -0
  46. package/dist/types/modes/components/status-line/segments.d.ts +10 -0
  47. package/dist/types/modes/jobs-observer.d.ts +36 -0
  48. package/dist/types/modes/print-mode.d.ts +17 -0
  49. package/dist/types/modes/ui-language.d.ts +7 -1
  50. package/dist/types/sdk/broker/broker.d.ts +80 -1
  51. package/dist/types/sdk/broker/endpoint-authority.d.ts +24 -0
  52. package/dist/types/sdk/broker/index.d.ts +3 -0
  53. package/dist/types/sdk/broker/lifecycle.d.ts +26 -0
  54. package/dist/types/sdk/broker/master-capability.d.ts +10 -0
  55. package/dist/types/sdk/broker/session-index.d.ts +40 -11
  56. package/dist/types/sdk/broker/session-scope.d.ts +72 -0
  57. package/dist/types/sdk/broker/spawn-authority.d.ts +201 -0
  58. package/dist/types/sdk/broker/spawn-substrate.d.ts +30 -0
  59. package/dist/types/sdk/broker/state-version.d.ts +4 -1
  60. package/dist/types/sdk/broker/worktree-occupancy.d.ts +28 -0
  61. package/dist/types/sdk/bus/chat-daemon-control.d.ts +3 -0
  62. package/dist/types/sdk/bus/index.d.ts +6 -0
  63. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +3 -0
  64. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +4 -0
  65. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
  66. package/dist/types/sdk/cli/index.d.ts +1 -0
  67. package/dist/types/sdk/cli/master-cli.d.ts +63 -0
  68. package/dist/types/sdk/cli/rows.d.ts +4 -3
  69. package/dist/types/sdk/cli/session-cli.d.ts +18 -2
  70. package/dist/types/sdk/client/client.d.ts +3 -2
  71. package/dist/types/sdk/client/discovery.d.ts +1 -0
  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/host.d.ts +10 -0
  77. package/dist/types/sdk/host/model-pin.d.ts +7 -2
  78. package/dist/types/sdk/host/sdk-run-capability.d.ts +1 -0
  79. package/dist/types/sdk/host/session-runtime.d.ts +67 -1
  80. package/dist/types/sdk/lifecycle/broker-client.d.ts +6 -0
  81. package/dist/types/sdk/lifecycle/service.d.ts +15 -3
  82. package/dist/types/sdk/lifecycle-session.d.ts +2 -0
  83. package/dist/types/sdk/prompt-deadline-manager.d.ts +11 -1
  84. package/dist/types/sdk/protocol/adapter-validation.d.ts +2 -0
  85. package/dist/types/sdk/router/session-router.d.ts +11 -0
  86. package/dist/types/sdk/session.d.ts +16 -0
  87. package/dist/types/sdk/startup-capability.d.ts +2 -1
  88. package/dist/types/session/account-inventory.d.ts +1 -0
  89. package/dist/types/session/agent-session.d.ts +24 -7
  90. package/dist/types/session/credential-store-errors.d.ts +1 -0
  91. package/dist/types/session/fold-coordinator.d.ts +201 -0
  92. package/dist/types/session/sdk-run-capability-internal.d.ts +7 -0
  93. package/dist/types/session/sdk-run-capability.d.ts +2 -0
  94. package/dist/types/session/session-manager.d.ts +65 -0
  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/telemetry/control.d.ts +11 -0
  98. package/dist/types/telemetry/events.d.ts +20 -0
  99. package/dist/types/telemetry/index.d.ts +3 -0
  100. package/dist/types/telemetry/transport.d.ts +22 -0
  101. package/dist/types/tools/bash-interactive.d.ts +23 -0
  102. package/dist/types/tools/bash.d.ts +4 -0
  103. package/dist/types/tools/gh.d.ts +8 -0
  104. package/dist/types/tools/index.d.ts +10 -5
  105. package/dist/types/web/search/providers/base.d.ts +9 -4
  106. package/dist/types/web/search/providers/xai.d.ts +2 -1
  107. package/dist/types/web/search/types.d.ts +14 -0
  108. package/package.json +10 -7
  109. package/scripts/generate-hotkeys-docs.ts +4 -0
  110. package/scripts/generate-sdk-operation-inventory.ts +9 -3
  111. package/scripts/verify-gjc-sdk-canonicalization.ts +35 -1
  112. package/src/async/job-manager.ts +671 -39
  113. package/src/cli/accounts-cli.ts +9 -5
  114. package/src/cli/args.ts +17 -0
  115. package/src/cli/auth-broker-cli.ts +40 -12
  116. package/src/cli/auth-gateway-cli.ts +273 -97
  117. package/src/cli/config-cli.ts +2 -2
  118. package/src/cli/fast-help.ts +4 -0
  119. package/src/cli/model-presets-cli.ts +100 -0
  120. package/src/cli/root-flags.ts +5 -0
  121. package/src/cli/update-cli.ts +117 -16
  122. package/src/cli.ts +6 -2
  123. package/src/commands/auth-gateway.ts +12 -8
  124. package/src/commands/gc.ts +19 -0
  125. package/src/commands/launch.ts +86 -18
  126. package/src/commands/model-presets.ts +24 -0
  127. package/src/commands/sdk.ts +113 -21
  128. package/src/config/autorouting-tier-map.ts +44 -0
  129. package/src/config/file-lock-gc.ts +9 -4
  130. package/src/config/file-lock.ts +890 -99
  131. package/src/config/internal/model-preset-registry-test-state.ts +28 -0
  132. package/src/config/internal/model-preset-registry-test-support.ts +11 -0
  133. package/src/config/keybindings.ts +6 -2
  134. package/src/config/model-preset-registry.ts +2795 -0
  135. package/src/config/model-profile-activation.ts +115 -28
  136. package/src/config/model-profile-contract.ts +4 -1
  137. package/src/config/model-profiles.ts +56 -14
  138. package/src/config/model-registry.ts +1044 -122
  139. package/src/config/model-resolver.ts +5 -0
  140. package/src/config/settings-schema.ts +19 -1
  141. package/src/config/settings.ts +11 -1
  142. package/src/coordinator-mcp/model-preset.ts +32 -17
  143. package/src/coordinator-mcp/projection-scan.ts +592 -0
  144. package/src/coordinator-mcp/question-state.ts +9 -11
  145. package/src/coordinator-mcp/server.ts +111 -42
  146. package/src/coordinator-mcp/session-reaper.ts +9 -3
  147. package/src/crash/index-store.ts +2 -0
  148. package/src/crash/record-loader.ts +10 -0
  149. package/src/extensibility/extensions/loader.ts +0 -1
  150. package/src/extensibility/extensions/types.ts +2 -3
  151. package/src/extensibility/gjc-plugins/runtime-adapters.ts +1 -0
  152. package/src/gjc-runtime/empty-delete-gc.ts +301 -0
  153. package/src/gjc-runtime/gc-render.ts +29 -0
  154. package/src/gjc-runtime/gc-runtime.ts +174 -11
  155. package/src/gjc-runtime/launch-worktree-reservation.ts +242 -0
  156. package/src/gjc-runtime/managed-owner-supervisor.ts +63 -51
  157. package/src/gjc-runtime/session-state-lock.ts +1321 -147
  158. package/src/gjc-runtime/session-state-sidecar.ts +1004 -25
  159. package/src/gjc-runtime/tmux-owner-isolation-cli.ts +4 -7
  160. package/src/gjc-runtime/tmux-owner-isolation.ts +2 -2
  161. package/src/gjc-runtime/tmux-sessions.ts +252 -13
  162. package/src/hooks/skill-state.ts +6 -0
  163. package/src/index.ts +1 -0
  164. package/src/internal-urls/docs-index.generated.ts +14 -13
  165. package/src/internal-urls/issue-pr-protocol.ts +4 -2
  166. package/src/lsp/config.ts +4 -3
  167. package/src/lsp/path-trust.ts +12 -6
  168. package/src/main.ts +66 -4
  169. package/src/master-mode/context.ts +50 -0
  170. package/src/master-mode/first-request.ts +65 -0
  171. package/src/master-mode/snapshot.ts +205 -0
  172. package/src/modes/acp/acp-agent.ts +616 -161
  173. package/src/modes/components/footer.ts +4 -2
  174. package/src/modes/components/frictionless-onboarding-selector.ts +48 -2
  175. package/src/modes/components/jobs-overlay-model.ts +99 -16
  176. package/src/modes/components/model-selector.ts +158 -18
  177. package/src/modes/components/oauth-selector.ts +6 -1
  178. package/src/modes/components/settings-selector.ts +1 -0
  179. package/src/modes/components/status-line/model-name.ts +53 -0
  180. package/src/modes/components/status-line/priority-row.ts +107 -0
  181. package/src/modes/components/status-line/segments.ts +29 -10
  182. package/src/modes/components/tool-status-header.ts +151 -15
  183. package/src/modes/controllers/extension-ui-controller.ts +1 -1
  184. package/src/modes/controllers/input-controller.ts +51 -6
  185. package/src/modes/controllers/selector-controller.ts +191 -96
  186. package/src/modes/interactive-mode.ts +14 -1
  187. package/src/modes/jobs-observer.ts +149 -16
  188. package/src/modes/print-mode.ts +64 -0
  189. package/src/modes/runtime-init.ts +1 -1
  190. package/src/modes/ui-language.ts +49 -2
  191. package/src/modes/utils/injected-user-submission.ts +15 -1
  192. package/src/prompts/system/master-mode.md +28 -0
  193. package/src/prompts/tools/bash.md +2 -2
  194. package/src/prompts/tools/fold-receipt.md +3 -0
  195. package/src/prompts/tools/job.md +1 -1
  196. package/src/sdk/acp/adapter.ts +17 -2
  197. package/src/sdk/broker/broker.ts +1671 -34
  198. package/src/sdk/broker/endpoint-authority.ts +86 -0
  199. package/src/sdk/broker/ensure.ts +5 -0
  200. package/src/sdk/broker/index.ts +3 -0
  201. package/src/sdk/broker/lifecycle.ts +217 -46
  202. package/src/sdk/broker/master-capability.ts +232 -0
  203. package/src/sdk/broker/session-index.ts +121 -17
  204. package/src/sdk/broker/session-scope.ts +272 -0
  205. package/src/sdk/broker/spawn-authority.ts +1031 -0
  206. package/src/sdk/broker/spawn-substrate.ts +548 -0
  207. package/src/sdk/broker/state-version.ts +26 -14
  208. package/src/sdk/broker/transport.ts +1 -0
  209. package/src/sdk/broker/worktree-occupancy.ts +90 -0
  210. package/src/sdk/bus/chat-daemon-control.ts +5 -2
  211. package/src/sdk/bus/chat-daemon-runtime.ts +46 -5
  212. package/src/sdk/bus/index.ts +51 -4
  213. package/src/sdk/bus/kind-aware-reconciliation.ts +36 -6
  214. package/src/sdk/bus/prompt-reconciliation.ts +28 -4
  215. package/src/sdk/bus/slack-conversation.ts +5 -1
  216. package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
  217. package/src/sdk/cli/index.ts +1 -0
  218. package/src/sdk/cli/master-cli.ts +259 -0
  219. package/src/sdk/cli/rows.ts +11 -8
  220. package/src/sdk/cli/session-cli.ts +276 -6
  221. package/src/sdk/client/client.ts +14 -8
  222. package/src/sdk/client/discovery.ts +3 -1
  223. package/src/sdk/host/control/dispatch.ts +101 -37
  224. package/src/sdk/host/control/index.ts +2 -0
  225. package/src/sdk/host/control/operations.ts +2 -0
  226. package/src/sdk/host/control/runtime-gate.ts +203 -11
  227. package/src/sdk/host/host.ts +27 -2
  228. package/src/sdk/host/model-pin.ts +185 -25
  229. package/src/sdk/host/sdk-run-capability.ts +1 -0
  230. package/src/sdk/host/session-runtime.test.ts +581 -43
  231. package/src/sdk/host/session-runtime.ts +655 -101
  232. package/src/sdk/lifecycle/broker-client.ts +28 -0
  233. package/src/sdk/lifecycle/service.ts +279 -20
  234. package/src/sdk/lifecycle-session.ts +10 -2
  235. package/src/sdk/prompt-deadline-manager.ts +16 -1
  236. package/src/sdk/protocol/adapter-validation.ts +27 -0
  237. package/src/sdk/protocol/operation-inventory.generated.json +53 -2
  238. package/src/sdk/protocol/operation-registry.ts +17 -4
  239. package/src/sdk/router/session-router.ts +294 -154
  240. package/src/sdk/session.ts +440 -167
  241. package/src/sdk/startup-capability.ts +1 -0
  242. package/src/session/account-inventory.ts +27 -11
  243. package/src/session/agent-session.ts +1292 -180
  244. package/src/session/blob-store.ts +15 -5
  245. package/src/session/credential-store-errors.ts +2 -0
  246. package/src/session/fold-coordinator.ts +433 -0
  247. package/src/session/internal/managed-session-storage.ts +153 -78
  248. package/src/session/sdk-run-capability-internal.ts +15 -0
  249. package/src/session/sdk-run-capability.ts +2 -0
  250. package/src/session/session-manager.ts +342 -28
  251. package/src/session/yield-queue.ts +24 -10
  252. package/src/setup/frictionless-onboarding.ts +2 -0
  253. package/src/setup/provider-presets.json +1 -1
  254. package/src/slash-commands/helpers/credential-switch.ts +6 -1
  255. package/src/task/executor.ts +19 -3
  256. package/src/telemetry/control.ts +26 -0
  257. package/src/telemetry/events.ts +1268 -0
  258. package/src/telemetry/index.ts +3 -0
  259. package/src/telemetry/transport.ts +87 -0
  260. package/src/tools/bash-interactive.ts +182 -85
  261. package/src/tools/bash.ts +1028 -109
  262. package/src/tools/gh.ts +104 -48
  263. package/src/tools/github-cache.ts +2 -2
  264. package/src/tools/index.ts +11 -5
  265. package/src/tools/tool-catalog.generated.ts +1 -1
  266. package/src/web/search/provider.ts +120 -11
  267. package/src/web/search/providers/anthropic.ts +89 -17
  268. package/src/web/search/providers/base.ts +9 -4
  269. package/src/web/search/providers/gemini.ts +87 -15
  270. package/src/web/search/providers/openai-compatible.ts +23 -8
  271. package/src/web/search/providers/xai.ts +98 -12
  272. package/src/web/search/types.ts +16 -0
@@ -0,0 +1,201 @@
1
+ export type SpawnClaimV2 = {
2
+ version: 2;
3
+ claimId: string;
4
+ lifecycleIdentity: string;
5
+ /** Opaque binding of the raw selector request, retained for catalog-independent replay. */
6
+ requestBindingMac?: string;
7
+ bindingMac: string;
8
+ state: "prepared" | "substrate_starting" | "authority_active" | "seed_prepared" | "dispatching" | "accepted" | "pre_send_rejected" | "uncertain" | "closed";
9
+ failure?: SpawnSubstrateFailure;
10
+ preSendLease?: {
11
+ epoch: string;
12
+ status: "owned" | "consumed";
13
+ };
14
+ childId?: string;
15
+ seed?: SeedDeliveryV2;
16
+ authorityRef?: string;
17
+ createdAt: number;
18
+ updatedAt: number;
19
+ };
20
+ export type SpawnSubstrateFailure = {
21
+ substrateKind: "tmux" | "psmux" | "headless";
22
+ code: string;
23
+ message: string;
24
+ };
25
+ export type SeedDeliveryV2 = {
26
+ version: 2;
27
+ phase: "prepared" | "dispatching" | "accepted" | "pre_send_rejected" | "uncertain";
28
+ clientRef: string;
29
+ commandId?: string;
30
+ turnId?: string;
31
+ acceptedAt?: number;
32
+ lastQ26Status?: "accepted" | "in_flight" | "terminal_ok" | "failed" | "unknown";
33
+ observedAt?: number;
34
+ };
35
+ /** Live-only capability check. Implementations must not retain either argument. */
36
+ export interface MasterCapabilityVerifier {
37
+ verifyMasterCapability(ownerSessionId: string, rawCapability: string, attestationEpoch: string): Promise<{
38
+ allowed: boolean;
39
+ }>;
40
+ }
41
+ /** Structured, shell-free child launch contract owned by the Broker. */
42
+ export interface SpawnSubstrateLaunchSpec {
43
+ childSessionId: string;
44
+ cwd: string;
45
+ argv: readonly string[];
46
+ /** Broker-inherited values are filtered to the portable launch subset. */
47
+ inheritedEnv?: Readonly<Record<string, string>>;
48
+ /** Child-specific values are part of this spec and must be shell-safe. */
49
+ env?: Readonly<Record<string, string>>;
50
+ }
51
+ /** Durable facts required to re-prove one spawned substrate without task material. */
52
+ export type SpawnSubstrateProof = {
53
+ substrateKind: "tmux" | "psmux" | "headless";
54
+ providerIdentity: string;
55
+ nativeSessionId?: string;
56
+ pid?: number;
57
+ processIncarnation?: string;
58
+ ownerGeneration?: number;
59
+ stateFileProof?: Readonly<Record<string, string | number>>;
60
+ };
61
+ export interface SpawnSubstrateProvider {
62
+ launch(spec: SpawnSubstrateLaunchSpec): Promise<{
63
+ ok: true;
64
+ proof: SpawnSubstrateProof;
65
+ } | {
66
+ ok: false;
67
+ code: "substrate_unavailable" | "substrate_proof_failed";
68
+ message: string;
69
+ }>;
70
+ verify(proof: SpawnSubstrateProof): Promise<"verified" | "mismatch" | "gone">;
71
+ close(proof: SpawnSubstrateProof): Promise<{
72
+ ok: boolean;
73
+ code?: string;
74
+ }>;
75
+ }
76
+ export type SpawnAuthorityCloseState = "active" | "close_requested" | "closed" | "uncertain";
77
+ /**
78
+ * Exact, durable ownership evidence for a child substrate. It is deliberately
79
+ * structural: request text, capability material, and their derivatives never
80
+ * belong in this record.
81
+ */
82
+ export type SpawnAuthorityV1 = {
83
+ version: 1;
84
+ authorityId: string;
85
+ claimId: string;
86
+ childId: string;
87
+ ownerSessionId: string;
88
+ lifecycleIdentity: string;
89
+ substrateKind: SpawnSubstrateProof["substrateKind"];
90
+ providerIdentity: string;
91
+ nativeSessionId?: string;
92
+ pid?: number;
93
+ processIncarnation?: string;
94
+ ownerGeneration?: number;
95
+ stateFileProof?: Readonly<Record<string, string | number>>;
96
+ /**
97
+ * Identity of the child HOST endpoint proven at registration. Distinct from
98
+ * the substrate `pid`/`processIncarnation` above: proving the multiplexer
99
+ * substrate is intact says nothing about which host answers on that session
100
+ * id. Optional so pre-pin v1 rows still reopen; recovery treats an absent
101
+ * pin as missing authority and fails closed rather than matching by id.
102
+ */
103
+ endpointGeneration?: number;
104
+ endpointPid?: number;
105
+ endpointIncarnation?: string;
106
+ /** Launch locator, so a colliding generation/pid in another workspace cannot pass. */
107
+ endpointCwd?: string;
108
+ endpointStateRoot?: string;
109
+ closeState: SpawnAuthorityCloseState;
110
+ orphanedAt?: number;
111
+ orphanRecoveredAt?: number;
112
+ closeRequestedAt?: number;
113
+ closedAt?: number;
114
+ createdAt: number;
115
+ updatedAt: number;
116
+ };
117
+ export type SpawnClaimTransition = {
118
+ claimId: string;
119
+ from: SpawnClaimV2["state"];
120
+ to: SpawnClaimV2["state"];
121
+ /** Required when the transition consumes the one pre-send lease. */
122
+ leaseEpoch?: string;
123
+ /** The fresh child ID is committed before substrate launch. */
124
+ childId?: string;
125
+ /** Required for seed and terminal state transitions that carry Q26 facts. */
126
+ seed?: SeedDeliveryV2;
127
+ failure?: SpawnSubstrateFailure;
128
+ /** Required when exact substrate authority becomes active or closes. */
129
+ authority?: SpawnAuthorityV1;
130
+ /** Required to downgrade dispatching only when no frame was handed off. */
131
+ provenNoHandoff?: true;
132
+ };
133
+ export type SpawnAuthorityTransitionResult = {
134
+ claim: SpawnClaimV2;
135
+ authority?: SpawnAuthorityV1;
136
+ };
137
+ export declare class SpawnAuthorityTransitionError extends Error {
138
+ readonly code: "claim_not_found" | "stale_transition" | "illegal_transition" | "invalid_transition";
139
+ constructor(code: "claim_not_found" | "stale_transition" | "illegal_transition" | "invalid_transition");
140
+ }
141
+ export type SpawnClaimDecision = {
142
+ kind: "owner";
143
+ claim: SpawnClaimV2;
144
+ recovery: boolean;
145
+ } | {
146
+ kind: "in_progress";
147
+ claim: SpawnClaimV2;
148
+ } | {
149
+ kind: "replay";
150
+ claim: SpawnClaimV2;
151
+ } | {
152
+ kind: "terminal";
153
+ claim: SpawnClaimV2;
154
+ } | {
155
+ kind: "terminal_uncertain";
156
+ claim: SpawnClaimV2;
157
+ } | {
158
+ kind: "idempotency_conflict";
159
+ claim: SpawnClaimV2;
160
+ };
161
+ type SpawnAuthorityDurableWrite = {
162
+ claim: SpawnClaimV2;
163
+ authority?: SpawnAuthorityV1;
164
+ };
165
+ export interface SpawnAuthorityStoreOptions {
166
+ /** Test-only hook that runs before the journal record becomes durable. */
167
+ beforeSyncForTest?: (write: SpawnAuthorityDurableWrite) => Promise<void> | void;
168
+ /** Test-only hook after both file and parent-directory fsync complete. */
169
+ afterSyncForTest?: (write: SpawnAuthorityDurableWrite) => Promise<void> | void;
170
+ /** Test-only hook between the file barrier and the parent-directory barrier. */
171
+ beforeDirectorySyncForTest?: (write: SpawnAuthorityDurableWrite) => Promise<void> | void;
172
+ }
173
+ export declare function isSpawnSubstrateProof(value: unknown): value is SpawnSubstrateProof;
174
+ export declare function isSpawnAuthorityV1(value: unknown): value is SpawnAuthorityV1;
175
+ export declare function isSpawnClaimV2(value: unknown): value is SpawnClaimV2;
176
+ /**
177
+ * Append-only source of spawn-effect authority. It deliberately records no request
178
+ * input: the opaque identity and raw/canonical structural binding MACs are its
179
+ * only correlators.
180
+ */
181
+ export declare class SpawnAuthorityStore {
182
+ #private;
183
+ constructor(agentDir: string, brokerIdentityKey: string, options?: SpawnAuthorityStoreOptions);
184
+ get file(): string;
185
+ claims(): readonly SpawnClaimV2[];
186
+ claim(lifecycleIdentity: string): SpawnClaimV2 | undefined;
187
+ authority(lifecycleIdentity: string): SpawnAuthorityV1 | undefined;
188
+ open(): Promise<void>;
189
+ claimOrJoin(lifecycleIdentity: string, bindingMac: string | undefined, requestBindingMac?: string | undefined): Promise<SpawnClaimDecision>;
190
+ /**
191
+ * Fsyncs one allowlisted state edge. Callers cannot patch claims in place,
192
+ * which prevents a retry from downgrading a handoff-capable state.
193
+ */
194
+ persistTransition(lifecycleIdentity: string, transition: SpawnClaimTransition): Promise<SpawnAuthorityTransitionResult>;
195
+ /** Persists only an exact authority lifecycle update, never a proof replacement. */
196
+ persistAuthority(lifecycleIdentity: string, authority: SpawnAuthorityV1): Promise<SpawnAuthorityTransitionResult>;
197
+ /** Records an observed Q26 status without reopening or changing a state edge. */
198
+ persistSeedObservation(lifecycleIdentity: string, seed: SeedDeliveryV2): Promise<SpawnAuthorityTransitionResult>;
199
+ releaseOwner(lifecycleIdentity: string): Promise<void>;
200
+ }
201
+ export {};
@@ -0,0 +1,30 @@
1
+ import { type ManagedTmuxLaunchProof } from "../../gjc-runtime/tmux-sessions";
2
+ import type { SpawnSubstrateLaunchSpec, SpawnSubstrateProvider } from "./spawn-authority";
3
+ export type SpawnMultiplexerSelection = "none" | "tmux" | "psmux" | "proof_failed";
4
+ export interface SpawnHeadlessProcess {
5
+ pid: number;
6
+ terminate(): void;
7
+ }
8
+ export interface SpawnSubstrateProviderDependencies {
9
+ platform?: NodeJS.Platform;
10
+ env?: NodeJS.ProcessEnv;
11
+ /** @internal Test seam for deterministic provider selection. */
12
+ selectMultiplexer?: () => SpawnMultiplexerSelection;
13
+ /** @internal Test seam for the managed multiplexer command layer. */
14
+ launchManaged?: (spec: SpawnSubstrateLaunchSpec, env: NodeJS.ProcessEnv, platform: NodeJS.Platform) => ManagedTmuxLaunchProof;
15
+ verifyManaged?: (proof: ManagedTmuxLaunchProof, env: NodeJS.ProcessEnv) => "verified" | "mismatch" | "gone";
16
+ closeManaged?: (proof: ManagedTmuxLaunchProof, env: NodeJS.ProcessEnv) => Promise<void>;
17
+ processIncarnation?: (pid: number) => string | undefined;
18
+ startHeadless?: (spec: SpawnSubstrateLaunchSpec, env: NodeJS.ProcessEnv) => SpawnHeadlessProcess;
19
+ signalHeadless?: (pid: number, incarnation: string, platform: NodeJS.Platform, signal: "SIGTERM" | "SIGKILL") => boolean;
20
+ isProcessGone?: (pid: number) => boolean;
21
+ /** @internal Test seam for bounded close polling. */
22
+ sleep?: (milliseconds: number) => Promise<void>;
23
+ /** @internal Test seam for non-secret inherited-environment launch diagnostics. */
24
+ onInheritedEnvironmentDrop?: (names: readonly string[]) => void;
25
+ }
26
+ /**
27
+ * Provides the Broker's only substrate authority. Every close and replay starts
28
+ * from its durable opaque proof; no PID/name-only operation is exposed.
29
+ */
30
+ export declare function createSpawnSubstrateProvider(dependencies?: SpawnSubstrateProviderDependencies): SpawnSubstrateProvider;
@@ -1,5 +1,6 @@
1
1
  export declare const SDK_STATE_VERSION = 1;
2
- export declare const SESSION_INDEX_SNAPSHOT_VERSION = 3;
2
+ export declare const SESSION_INDEX_SNAPSHOT_VERSION = 4;
3
+ export declare const SESSION_INDEX_EVENT_VERSION = 4;
3
4
  export declare class UnsupportedStateVersionError extends Error {
4
5
  readonly file: string;
5
6
  readonly version: number;
@@ -8,4 +9,6 @@ export declare class UnsupportedStateVersionError extends Error {
8
9
  constructor(file: string, version: number, maximumSupportedVersion?: number);
9
10
  }
10
11
  export declare function assertSupportedStateVersion(file: string, value: unknown): void;
12
+ /** Rejects session-index events outside the known legacy and current formats. */
13
+ export declare function assertSupportedSessionIndexEventVersion(file: string, value: unknown): void;
11
14
  export declare function assertSupportedSnapshotVersion(file: string, value: unknown): void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Which session currently holds a GJC-managed worktree.
3
+ *
4
+ * Both launch paths need this answer and must not disagree about it: the broker
5
+ * refuses a lifecycle launch into an occupied worktree, and the interactive
6
+ * `gjc --worktree` launch refuses for the same reason. Keeping one predicate —
7
+ * and one definition of "still running" — here prevents the two from drifting
8
+ * into different notions of liveness.
9
+ */
10
+ import type { IndexedSession } from "./session-index";
11
+ export type ProcessObservation = "alive" | "exited" | "uncertain";
12
+ /** Only ESRCH or a changed, readable incarnation proves the owned process exited. */
13
+ export declare function observeProcess(pid: number, expectedIncarnation: string | undefined, readIncarnation?: (pid: number) => string | undefined): ProcessObservation;
14
+ /**
15
+ * The id of a session still occupying `worktreePath`, or null when it is free.
16
+ *
17
+ * `ensureLaunchWorktree` reuses an existing worktree without asking whether
18
+ * anyone is in it, and an unnamed launch derives its directory deterministically
19
+ * from the repository's current branch. Two concurrent sessions in one
20
+ * repository therefore land in the same checkout and overwrite each other's
21
+ * files with no error.
22
+ *
23
+ * Only a process observed as definitively exited releases the worktree.
24
+ * `uncertain` counts as occupied: refusing a launch is recoverable by picking
25
+ * another worktree name, whereas two live sessions sharing a checkout corrupts
26
+ * work already done.
27
+ */
28
+ export declare function worktreeOccupant(sessions: readonly IndexedSession[], worktreePath: string, observe?: (pid: number, expectedIncarnation: string | undefined) => ProcessObservation): string | null;
@@ -102,6 +102,9 @@ export type ChatDaemonAction = "stop" | "reload";
102
102
  * session-index lock every 2s; staleness retirement moved to a 30s sweep and
103
103
  * lease heartbeats no longer force an authority reconcile. A pre-upgrade owner
104
104
  * would retain the old hot polling loop, so replacement is required.
105
+ * Discord generation 72 / Slack generation 75 serialize same-generation
106
+ * successor attachment admission behind predecessor provider retirement, so a
107
+ * pre-upgrade owner cannot retain the queue race fixed by #5120.
105
108
  */
106
109
  export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
107
110
  export declare function chatDaemonGeneration(kind: ChatDaemonKind): number;
@@ -599,6 +599,12 @@ export declare function createNotificationsExtension(api: ExtensionAPI, options?
599
599
  controller?: NotificationSessionController;
600
600
  /** Whether this host mode can own the root SDK endpoint. Default: true. */
601
601
  sdkHostModeSupported?: boolean;
602
+ /** In-memory master capability for private broker verification only. */
603
+ masterCapability?: string;
604
+ /** Opaque direct-role epoch this effective host may adopt. */
605
+ masterAttestationEpoch?: string;
606
+ /** Stable master lineage identity retained across session switches/branches. */
607
+ masterOwnerSessionId?: string;
602
608
  onSdkRequest?: (kind: "control" | "query", connectionId: string, frame: Record<string, unknown>) => void;
603
609
  runBtwTurn?: (question: string, signal: AbortSignal) => Promise<{
604
610
  replyText: string;
@@ -29,10 +29,13 @@ export interface KindAwareReconciliation {
29
29
  noteTransition(kind: ReconciliationKind, correlation: PromptCorrelation | undefined, frame: {
30
30
  type: "agent_start" | "agent_end";
31
31
  content?: TurnResultContent;
32
+ hasActivity?: boolean;
33
+ outcome?: SdkPromptTerminalOutcome;
32
34
  } | {
33
35
  type: "agent_failed";
34
36
  error: unknown;
35
37
  content?: TurnResultContent;
38
+ hasActivity?: boolean;
36
39
  }): Promise<void>;
37
40
  claimPendingOutcome(kind: ReconciliationKind, correlation: PromptCorrelation, outcome: SdkPromptTerminalOutcome, receiptState?: Extract<ReceiptState, "present" | "missing">): Promise<SdkPromptTerminalOutcome>;
38
41
  finalizeOutcome(kind: ReconciliationKind, correlation: PromptCorrelation, outcome?: SdkPromptTerminalOutcome, recordError?: {
@@ -22,6 +22,7 @@
22
22
  * record that has none, but never changes status, terminalAt, or retention.
23
23
  */
24
24
  import { PROMPT_FAILURE_CODE_MAX, sanitizePromptFailure } from "../prompt-failure";
25
+ import type { SdkPromptTerminalOutcome } from "../prompt-status";
25
26
  import type { ReceiptState } from "../receipt-state";
26
27
  export { PROMPT_FAILURE_CODE_MAX, sanitizePromptFailure };
27
28
  export declare const PROMPT_RECONCILIATION_ACTIVE_CAPACITY = 128;
@@ -102,10 +103,13 @@ export interface PromptReconciliation {
102
103
  } | {
103
104
  type: "agent_end";
104
105
  finalText?: string;
106
+ hasActivity?: boolean;
107
+ outcome?: SdkPromptTerminalOutcome;
105
108
  } | {
106
109
  type: "agent_failed";
107
110
  error: unknown;
108
111
  finalText?: string;
112
+ hasActivity?: boolean;
109
113
  }): void;
110
114
  lookup(selector: {
111
115
  commandId?: string;
@@ -286,7 +286,7 @@ export declare const SDK_LIFECYCLE_ROUTER_PROTOCOL_VERSION = 1;
286
286
  * killing a session's mirroring after one transient rejection and must be
287
287
  * replaced across this upgrade.
288
288
  */
289
- export declare const DAEMON_GENERATION = 179;
289
+ export declare const DAEMON_GENERATION = 180;
290
290
  /**
291
291
  * Serving-compatibility boundary for daemon lifecycle requests. Epoch 7
292
292
  * requires durable publication receipts and acknowledged attachment dispatch,
@@ -1 +1,2 @@
1
+ export * from "./master-cli";
1
2
  export * from "./session-cli";
@@ -0,0 +1,63 @@
1
+ import { type IndexedSession } from "../broker/session-index";
2
+ export declare class SdkMasterCliError extends Error {
3
+ readonly code: string;
4
+ readonly exitCode: 1 | 2;
5
+ constructor(code: string, message: string, exitCode?: 1 | 2);
6
+ }
7
+ export interface SdkSpawnArgs {
8
+ cwd?: string;
9
+ prompt?: string;
10
+ model?: string;
11
+ profile?: string;
12
+ agentDir?: string;
13
+ idempotencyKey?: string;
14
+ json?: boolean;
15
+ }
16
+ /** The allowlisted spawn result projection rendered to the operator. */
17
+ export interface SdkSpawnRendered {
18
+ code: string;
19
+ claimId?: string;
20
+ sessionId?: string;
21
+ substrateKind?: string;
22
+ seed?: {
23
+ phase?: string;
24
+ clientRef?: string;
25
+ commandId?: string;
26
+ turnId?: string;
27
+ status?: string;
28
+ };
29
+ idempotencyKey?: string;
30
+ error?: {
31
+ code: string;
32
+ message: string;
33
+ };
34
+ }
35
+ export interface SdkSpawnDependencies {
36
+ env: Record<string, string | undefined>;
37
+ dispatch: (agentDir: string, input: Record<string, unknown>, idempotencyKey: string) => Promise<unknown>;
38
+ resolveAttestationEpoch: (agentDir: string, ownerSessionId: string) => Promise<string | undefined>;
39
+ }
40
+ /**
41
+ * Select the newest retained master attestation for an owner session.
42
+ *
43
+ * `listSessionIdentities()` can retain both the direct-role row and one or
44
+ * more endpoint generations. Its iteration order is a projection detail, not
45
+ * authority ordering, so selecting the first matching row can resurrect an
46
+ * older epoch after a master relaunch. The broker's monotonically increasing
47
+ * `indexSeq` is the authoritative retained ordering.
48
+ */
49
+ export declare function selectNewestMasterAttestationEpoch(rows: readonly IndexedSession[], ownerSessionId: string): string | undefined;
50
+ /** Projects an arbitrary Broker response onto the allowlisted render shape. */
51
+ export declare function safeSpawnRender(response: unknown): {
52
+ rendered: SdkSpawnRendered;
53
+ exitCode: 0 | 1;
54
+ };
55
+ export declare function renderSpawnTable(rendered: SdkSpawnRendered): string;
56
+ /**
57
+ * Runs one local master spawn. A caller-provided idempotency key replays the
58
+ * matching durable claim; otherwise each invocation receives a fresh key.
59
+ */
60
+ export declare function runSdkSpawn(args: SdkSpawnArgs, dependencies?: Partial<SdkSpawnDependencies>): Promise<{
61
+ rendered: SdkSpawnRendered;
62
+ exitCode: 0 | 1;
63
+ }>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Versioned DTO rows for `gjc sdk session` semantic verbs (row DTO v1, DR-12).
2
+ * Versioned DTO rows for `gjc sdk session` semantic verbs (row DTO v2, DR-12).
3
3
  *
4
4
  * Every semantic verb renders its output through these rows so machine
5
5
  * consumers get one deterministic, versioned envelope per verb. Credentials
@@ -7,7 +7,7 @@
7
7
  * credentials, and pass-through host payloads are redacted recursively before
8
8
  * rendering.
9
9
  */
10
- export declare const SESSION_ROWS_VERSION = 1;
10
+ export declare const SESSION_ROWS_VERSION = 2;
11
11
  export type SdkSessionActivityState = "active" | "idle";
12
12
  export interface SdkSessionActivityV1 {
13
13
  state: SdkSessionActivityState;
@@ -16,7 +16,8 @@ export interface SdkSessionActivityV1 {
16
16
  export interface SdkSessionRowV1 {
17
17
  sessionId: string;
18
18
  locator: {
19
- repo: string;
19
+ cwd: string;
20
+ worktreeRoot: string | null;
20
21
  stateRoot: string;
21
22
  };
22
23
  endpointGeneration: number;
@@ -1,6 +1,8 @@
1
+ import { type SdkSearchResultV1, type SdkSearchRowV1 } from "../broker/session-scope";
2
+ import type { SessionLifecycleService } from "../lifecycle/service";
1
3
  import { SessionRouter } from "../router";
2
4
  import { type SdkSessionRowV1 } from "./rows";
3
- export type SdkSessionCliAction = "list" | "inspect" | "send" | "status" | "tail" | "retire" | "global" | "raw" | "control" | "query" | "global";
5
+ export type SdkSessionCliAction = "list" | "search" | "inspect" | "send" | "status" | "tail" | "retire" | "global" | "raw" | "control" | "query" | "global";
4
6
  export type SdkSessionListScope = "repo" | "cwd" | "worktree" | "all";
5
7
  export type SdkSessionCliRawKind = "control" | "query" | "global";
6
8
  export interface SdkSessionCliArgs {
@@ -15,7 +17,6 @@ export interface SdkSessionCliArgs {
15
17
  jsonInputFile?: string;
16
18
  jsonInputStdin?: boolean;
17
19
  idempotencyKey?: string;
18
- scope?: string;
19
20
  confirm?: boolean;
20
21
  cursor?: string;
21
22
  wait?: boolean;
@@ -24,12 +25,24 @@ export interface SdkSessionCliArgs {
24
25
  untilIdle?: boolean;
25
26
  allEvents?: boolean;
26
27
  repo?: string;
28
+ scope?: string;
29
+ limit?: number;
30
+ json?: boolean;
27
31
  agentDir?: string;
28
32
  }
33
+ type JsonRecord = Record<string, unknown>;
29
34
  export interface RetainedTranscriptTailReader {
30
35
  readonly size: number;
31
36
  readRange(start: number, end: number): Promise<Uint8Array>;
32
37
  }
38
+ export declare function mergeProbedSearchRows(rows: readonly SdkSearchRowV1[], probedRows: readonly SdkSearchRowV1[]): readonly SdkSearchRowV1[];
39
+ /** Resolves, lists, and probes only the exact rows selected by the Broker-scoped search. */
40
+ export declare function runSdkSearch(args: Pick<SdkSessionCliArgs, "agentDir" | "repo" | "scope" | "limit" | "cursor">, createService?: (agentDir: string) => SessionLifecycleService, probe?: (agentDir: string, result: SdkSearchResultV1) => Promise<SdkSearchResultV1>): Promise<{
41
+ result: SdkSearchResultV1;
42
+ exitCode: 0 | 1;
43
+ }>;
44
+ /** Renders a credential-free scope/status preamble and bounded search table. */
45
+ export declare function renderSdkSearchTable(result: SdkSearchResultV1): string;
33
46
  interface WorkspaceIdentity {
34
47
  /** Canonical workspace path (realpath when it exists, lexical resolve otherwise). */
35
48
  canonicalPath: string;
@@ -69,6 +82,9 @@ export declare function filterSessionRowsByScope(rows: readonly SdkSessionRowV1[
69
82
  }>;
70
83
  /** Creates a lowercase ULID operation reference for prompt reconciliation. */
71
84
  export declare function createOperationRef(now?: number): string;
85
+ /** Builds the public CLI control envelope without leaking envelope fields into operation input. */
86
+ export declare function controlRequestFrame(operation: string, input: JsonRecord, args: Pick<SdkSessionCliArgs, "confirm" | "idempotencyKey">): JsonRecord;
87
+ export declare function operatorAbortBrokerRequest(sessionId: string, operation: string, input: JsonRecord, args: Pick<SdkSessionCliArgs, "confirm" | "idempotencyKey">): JsonRecord | undefined;
72
88
  /** Exported for tests: each status poll must stay inside the caller's wait window. */
73
89
  export declare function waitForTerminalStatus(router: SessionRouter, sessionId: string, clientRef: string, timeoutMs: number | undefined): Promise<{
74
90
  terminal: boolean;
@@ -90,12 +90,13 @@ export interface SdkDispatchContext {
90
90
  readonly connectionId: string | undefined;
91
91
  readonly generation: number;
92
92
  }
93
- /** Request identity retained after an uncertain send for lifecycle reconciliation. */
93
+ /** Request identity retained after an uncertain send. */
94
94
  export interface SdkSentRecord {
95
95
  readonly id: string;
96
96
  readonly operation?: string;
97
97
  readonly idempotencyKey?: string;
98
- readonly fingerprint: string;
98
+ /** Present for lifecycle lookups; `session.spawn` replays through its idempotency key. */
99
+ readonly fingerprint?: string;
99
100
  }
100
101
  export type SdkFrameHandler = (frame: SdkFrame) => void;
101
102
  export type SdkReconnectHandler = () => void;
@@ -22,6 +22,7 @@ export declare class SdkDiscoveryError extends Error {
22
22
  constructor(path: string, message: string);
23
23
  }
24
24
  export type SdkSessionEndpointScope = "default" | "chat";
25
+ export declare function endpointDirectory(repo: string, scope?: SdkSessionEndpointScope): string;
25
26
  /** Lists endpoint files and returns individual malformed or unreadable records as warnings. */
26
27
  export declare function listSdkSessionEndpoints(repo: string): Promise<SdkSessionEndpointList>;
27
28
  /** Resolves one per-session SDK endpoint discovery file. */
@@ -31,5 +31,15 @@ export declare class BusyError extends TypedControlError {
31
31
  constructor(message?: string);
32
32
  }
33
33
  export declare function controlRequestFromFrame(frame: Record<string, unknown>): ControlRequest;
34
+ export interface TerminalAbortIdentity {
35
+ input: {
36
+ mode: "terminal";
37
+ scope: "turn" | "owned";
38
+ operator?: true;
39
+ };
40
+ inputHash: string;
41
+ }
42
+ /** One strict, capability-free identity shared by dispatch, durable admission, and delivery observation. */
43
+ export declare function terminalAbortIdentity(input: unknown, operatorAuthorized: boolean): TerminalAbortIdentity | undefined;
34
44
  /** Dispatches a registry-defined per-session control operation. */
35
45
  export declare function dispatchControl(surface: ControlSurface, registryRow: Operation | undefined, request: ControlRequest): Promise<ControlResponse>;
@@ -1,2 +1,2 @@
1
- export { BusyError, type ControlError, type ControlErrorCode, type ControlRequest, type ControlResponse, controlRequestFromFrame, dispatchControl, TypedControlError, } from "./dispatch";
1
+ export { BusyError, type ControlError, type ControlErrorCode, type ControlRequest, type ControlResponse, controlRequestFromFrame, dispatchControl, type TerminalAbortIdentity, TypedControlError, terminalAbortIdentity, } from "./dispatch";
2
2
  export type { AbortScope, ControlInput, ControlSurface, ControlValue } from "./operations";
@@ -10,6 +10,8 @@ export type AbortScope = "turn" | "owned";
10
10
  export interface TerminalAbortInput {
11
11
  mode: "terminal";
12
12
  scope?: AbortScope;
13
+ /** Broker-authorized local override; public SDK callers cannot grant this authority. */
14
+ operator?: boolean;
13
15
  }
14
16
  export type ControlInput = Record<string, unknown>;
15
17
  /**
@@ -1,15 +1,26 @@
1
1
  /**
2
- * Private field carried only on the Broker's endpoint close request.
2
+ * Private fields carried only on Broker-authorized endpoint controls.
3
3
  *
4
- * The value is the lifecycle effect marker bound to the serving process. It is
5
- * never published in endpoint discovery or lifecycle service results; callers
6
- * that do not hold the Broker's indexed lifecycle record cannot satisfy this
7
- * gate.
4
+ * Their values are lifecycle effect markers bound to the serving process. They
5
+ * are never published in endpoint discovery or lifecycle service results;
6
+ * callers that do not hold the Broker's indexed lifecycle record cannot satisfy
7
+ * either gate.
8
8
  */
9
9
  export declare const BROKER_RUNTIME_CLOSE_CAPABILITY_FIELD = "__gjcBrokerCloseCapability";
10
+ /** Private field carried only on the Broker-authorized terminal-abort request. */
11
+ export declare const BROKER_RUNTIME_ABORT_CAPABILITY_FIELD = "__gjcBrokerAbortCapability";
10
12
  export declare function brokerRuntimeCloseCapability(input: unknown): string | undefined;
11
- /** Remove the private close capability before a request is exposed to diagnostics. */
12
- export declare function redactBrokerRuntimeCloseCapability(frame: Record<string, unknown>): Record<string, unknown>;
13
+ export declare function brokerRuntimeAbortCapability(input: unknown): string | undefined;
14
+ /** Remove private Broker capabilities before a request is exposed to diagnostics. */
15
+ export declare function redactBrokerRuntimeCapabilities(frame: Record<string, unknown>): Record<string, unknown>;
16
+ /**
17
+ * Strips caller content from a request frame before it reaches a diagnostic
18
+ * observer. Known protocol operation names and finite enum values survive so
19
+ * instrumentation stays useful; caller-chosen ids and all other values are
20
+ * redacted, including nested objects, so a field this module has never heard
21
+ * of cannot leak.
22
+ */
23
+ export declare function redactObservedRequestContent(frame: Record<string, unknown>): Record<string, unknown>;
13
24
  /**
14
25
  * Runtime-local authority check for the Broker-only graceful close executor.
15
26
  *
@@ -17,3 +28,6 @@ export declare function redactBrokerRuntimeCloseCapability(frame: Record<string,
17
28
  * environment. Generic SDK requests never receive that private marker.
18
29
  */
19
30
  export declare function hasBrokerRuntimeCloseCapability(input: unknown): boolean;
31
+ /** Test-only override for the abort gate; production authority remains process-local. */
32
+ export declare function setBrokerRuntimeAbortCapabilityForTest(capability: string | undefined): void;
33
+ export declare function hasBrokerRuntimeAbortCapability(input: unknown): boolean;
@@ -64,6 +64,16 @@ export interface SessionSdkHostOptions extends HostEndpointAdapters {
64
64
  * that fails is never read as authorization.
65
65
  */
66
66
  activationGate?: SessionActivationGate;
67
+ /** Private one-shot master-capability verification; never durable or public SDK surface. */
68
+ masterCapabilityVerify?: (frame: {
69
+ nonce: unknown;
70
+ attestationEpoch: unknown;
71
+ capability: unknown;
72
+ }) => {
73
+ ok: boolean;
74
+ nonce: string;
75
+ attestationEpoch: string;
76
+ };
67
77
  }
68
78
  /** Shared by the replay filter and transport live broadcasts: a connection
69
79
  * must see the same capability-gated event kinds on both legs, or live and
@@ -5,7 +5,10 @@ export interface SdkHostModelResolveContext {
5
5
  cwd?: string;
6
6
  }
7
7
  /** Registry loader owned by the SDK host, not by machine-facing adapters. */
8
- export type SdkHostModelRegistryLoader = (context?: SdkHostModelResolveContext) => ModelRegistry | Promise<ModelRegistry>;
8
+ export type SdkHostModelRegistryLoader = ((context?: SdkHostModelResolveContext) => ModelRegistry | Promise<ModelRegistry>) & {
9
+ acquire?: (context?: SdkHostModelResolveContext) => () => void;
10
+ dispose?: () => Promise<void>;
11
+ };
9
12
  /**
10
13
  * Builds an offline model resolver for a single SDK host process.
11
14
  *
@@ -22,7 +25,9 @@ export type SdkHostModelResolution = {
22
25
  model: string;
23
26
  error: string;
24
27
  };
25
- export type SdkHostModelResolver = (raw: unknown, context?: SdkHostModelResolveContext) => Promise<SdkHostModelResolution>;
28
+ export type SdkHostModelResolver = ((raw: unknown, context?: SdkHostModelResolveContext) => Promise<SdkHostModelResolution>) & {
29
+ dispose?: () => Promise<void>;
30
+ };
26
31
  /** Resolve the explicit model pin at the SDK host boundary. */
27
32
  export declare function resolveSdkHostModel(raw: unknown, loadRegistry: SdkHostModelRegistryLoader, context?: SdkHostModelResolveContext): Promise<SdkHostModelResolution>;
28
33
  /** Default resolver used by the SDK broker host. */
@@ -0,0 +1 @@
1
+ export { createSdkRunCapability } from "../../session/sdk-run-capability-internal";