@gajae-code/coding-agent 0.16.7 → 0.17.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 (321) hide show
  1. package/CHANGELOG.md +180 -1
  2. package/dist/types/capability/fs.d.ts +37 -4
  3. package/dist/types/capability/index.d.ts +19 -0
  4. package/dist/types/capability/types.d.ts +9 -0
  5. package/dist/types/cli/doctor/args.d.ts +36 -0
  6. package/dist/types/cli/doctor/checks.d.ts +18 -0
  7. package/dist/types/cli/doctor/config-repairs.d.ts +38 -0
  8. package/dist/types/cli/doctor/context.d.ts +89 -0
  9. package/dist/types/cli/doctor/files.d.ts +27 -0
  10. package/dist/types/cli/doctor/ids.d.ts +20 -0
  11. package/dist/types/cli/doctor/install-repairs.d.ts +94 -0
  12. package/dist/types/cli/doctor/journal.d.ts +43 -0
  13. package/dist/types/cli/doctor/managed-link.d.ts +39 -0
  14. package/dist/types/cli/doctor/native-probe.d.ts +2 -0
  15. package/dist/types/cli/doctor/permission-repairs.d.ts +25 -0
  16. package/dist/types/cli/doctor/plugin-quarantine.d.ts +77 -0
  17. package/dist/types/cli/doctor/plugin-restore.d.ts +40 -0
  18. package/dist/types/cli/doctor/plugin-targets.d.ts +11 -0
  19. package/dist/types/cli/doctor/probe-client.d.ts +9 -0
  20. package/dist/types/cli/doctor/probe-types.d.ts +18 -0
  21. package/dist/types/cli/doctor/probe.d.ts +3 -0
  22. package/dist/types/cli/doctor/projection-probe.d.ts +2 -0
  23. package/dist/types/cli/doctor/repairs.d.ts +28 -0
  24. package/dist/types/cli/doctor/report.d.ts +27 -0
  25. package/dist/types/cli/doctor/runner.d.ts +4 -0
  26. package/dist/types/cli/doctor/safety.d.ts +10 -0
  27. package/dist/types/cli/doctor/service-repairs.d.ts +8 -0
  28. package/dist/types/cli/doctor/service-targets.d.ts +41 -0
  29. package/dist/types/cli/doctor/types.d.ts +145 -0
  30. package/dist/types/cli/doctor-cli.d.ts +7 -0
  31. package/dist/types/cli/doctor-supervisor.d.ts +121 -0
  32. package/dist/types/cli/doctor-worker.d.ts +29 -0
  33. package/dist/types/cli/install-activation.d.ts +158 -0
  34. package/dist/types/cli/macos-community-app.d.ts +41 -0
  35. package/dist/types/cli/mcp-cli.d.ts +0 -11
  36. package/dist/types/cli/update-cli.d.ts +41 -4
  37. package/dist/types/cli-main.d.ts +174 -0
  38. package/dist/types/cli.d.ts +1 -171
  39. package/dist/types/commands/doctor.d.ts +7 -0
  40. package/dist/types/commands/sdk.d.ts +17 -8
  41. package/dist/types/config/autorouting-tier-map.d.ts +19 -0
  42. package/dist/types/config/file-lock.d.ts +27 -3
  43. package/dist/types/config/model-preset-registry.d.ts +1 -0
  44. package/dist/types/config/model-registry.d.ts +12 -5
  45. package/dist/types/config/model-resolver.d.ts +16 -3
  46. package/dist/types/config/models-config-schema.d.ts +2 -0
  47. package/dist/types/config/settings-schema.d.ts +1 -1
  48. package/dist/types/coordinator-mcp/question-gate-codec.d.ts +1 -1
  49. package/dist/types/coordinator-mcp/session-reaper.d.ts +15 -5
  50. package/dist/types/cursor.d.ts +9 -9
  51. package/dist/types/discovery/agents-md.d.ts +6 -1
  52. package/dist/types/discovery/helpers.d.ts +36 -7
  53. package/dist/types/discovery/index.d.ts +1 -1
  54. package/dist/types/discovery/mcp-json.d.ts +2 -0
  55. package/dist/types/extensibility/extensions/loader.d.ts +22 -1
  56. package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +14 -1
  57. package/dist/types/extensibility/gjc-plugins/paths.d.ts +2 -1
  58. package/dist/types/extensibility/gjc-plugins/types.d.ts +25 -0
  59. package/dist/types/extensibility/plugins/manager.d.ts +33 -4
  60. package/dist/types/extensibility/plugins/marketplace/cache.d.ts +6 -0
  61. package/dist/types/extensibility/plugins/marketplace/manager.d.ts +186 -0
  62. package/dist/types/extensibility/plugins/marketplace/registry.d.ts +27 -0
  63. package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +16 -1
  64. package/dist/types/extensibility/runtime-skill-discovery.d.ts +16 -3
  65. package/dist/types/gjc-runtime/autoresearch-runtime.d.ts +6 -0
  66. package/dist/types/gjc-runtime/launch-worktree.d.ts +53 -0
  67. package/dist/types/gjc-runtime/session-layout.d.ts +8 -0
  68. package/dist/types/gjc-runtime/session-state-lock.d.ts +15 -0
  69. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +13 -0
  70. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +6 -0
  71. package/dist/types/main.d.ts +19 -1
  72. package/dist/types/modes/acp/acp-agent.d.ts +40 -0
  73. package/dist/types/modes/components/agent-dashboard.d.ts +1 -0
  74. package/dist/types/modes/components/model-selector.d.ts +2 -0
  75. package/dist/types/modes/interactive-mode.d.ts +1 -1
  76. package/dist/types/runtime-mcp/config-writer.d.ts +47 -0
  77. package/dist/types/runtime-mcp/policy-json-edit.d.ts +60 -0
  78. package/dist/types/runtime-mcp/startup-policy.d.ts +4 -0
  79. package/dist/types/runtime-mcp/types.d.ts +2 -2
  80. package/dist/types/sdk/acp/adapter.d.ts +5 -1
  81. package/dist/types/sdk/broker/broker.d.ts +51 -0
  82. package/dist/types/sdk/broker/daemon-entry.d.ts +39 -0
  83. package/dist/types/sdk/broker/discovery.d.ts +38 -0
  84. package/dist/types/sdk/broker/doctor-restart.d.ts +79 -0
  85. package/dist/types/sdk/broker/endpoint-authority.d.ts +7 -0
  86. package/dist/types/sdk/broker/ensure.d.ts +14 -0
  87. package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
  88. package/dist/types/sdk/broker/process-incarnation.d.ts +50 -0
  89. package/dist/types/sdk/broker/runtime.d.ts +26 -0
  90. package/dist/types/sdk/broker/session-index.d.ts +13 -4
  91. package/dist/types/sdk/broker/worktree-occupancy.d.ts +14 -0
  92. package/dist/types/sdk/bus/chat-daemon-cli.d.ts +16 -0
  93. package/dist/types/sdk/bus/chat-daemon-control.d.ts +101 -6
  94. package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +16 -0
  95. package/dist/types/sdk/bus/daemon-startup-exclusion.d.ts +43 -0
  96. package/dist/types/sdk/bus/doctor-daemon-restart-client.d.ts +51 -0
  97. package/dist/types/sdk/bus/doctor-daemon-restart.d.ts +39 -0
  98. package/dist/types/sdk/bus/index.d.ts +2 -0
  99. package/dist/types/sdk/bus/notification-service.d.ts +3 -0
  100. package/dist/types/sdk/bus/telegram-daemon-cli.d.ts +11 -0
  101. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
  102. package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -0
  103. package/dist/types/sdk/bus/telegram-daemon-owner-registry.d.ts +1 -0
  104. package/dist/types/sdk/bus/telegram-daemon.d.ts +36 -5
  105. package/dist/types/sdk/cli/session-cli.d.ts +1 -0
  106. package/dist/types/sdk/host/session-runtime.d.ts +4 -0
  107. package/dist/types/sdk/host/surface-policy.d.ts +3 -1
  108. package/dist/types/sdk/lifecycle/service.d.ts +44 -10
  109. package/dist/types/sdk/prompt-deadline-lease.d.ts +6 -3
  110. package/dist/types/sdk/prompt-deadline-manager.d.ts +2 -2
  111. package/dist/types/sdk/prompt-failure.d.ts +47 -0
  112. package/dist/types/sdk/prompt-status.d.ts +19 -0
  113. package/dist/types/sdk/router/session-router.d.ts +3 -4
  114. package/dist/types/sdk/service-artifact-paths.d.ts +16 -0
  115. package/dist/types/sdk/session-authority.d.ts +9 -0
  116. package/dist/types/sdk/session.d.ts +3 -1
  117. package/dist/types/session/agent-session.d.ts +1 -1
  118. package/dist/types/session/blob-store.d.ts +1 -1
  119. package/dist/types/session/fallback-chain-controller.d.ts +3 -6
  120. package/dist/types/session/internal/managed-session-scope.d.ts +44 -0
  121. package/dist/types/session/primary-control-surface.d.ts +4 -0
  122. package/dist/types/session/session-manager.d.ts +6 -0
  123. package/dist/types/system-prompt.d.ts +6 -0
  124. package/dist/types/tools/ask.d.ts +25 -0
  125. package/dist/types/tools/image-gen.d.ts +0 -4
  126. package/dist/types/tools/skill-discovery.d.ts +7 -5
  127. package/dist/types/tools/ultragoal-ask-guard.d.ts +7 -4
  128. package/dist/types/utils/changelog.d.ts +0 -9
  129. package/dist/types/utils/mupdf-wasm.d.ts +1 -0
  130. package/package.json +9 -8
  131. package/scripts/compile-args.ts +8 -4
  132. package/src/capability/fs.ts +395 -17
  133. package/src/capability/index.ts +273 -10
  134. package/src/capability/types.ts +9 -0
  135. package/src/cli/customize-doctor.ts +18 -12
  136. package/src/cli/doctor/args.ts +236 -0
  137. package/src/cli/doctor/checks.ts +431 -0
  138. package/src/cli/doctor/config-repairs.ts +517 -0
  139. package/src/cli/doctor/context.ts +149 -0
  140. package/src/cli/doctor/files.ts +149 -0
  141. package/src/cli/doctor/ids.ts +115 -0
  142. package/src/cli/doctor/install-repairs.ts +335 -0
  143. package/src/cli/doctor/journal.ts +423 -0
  144. package/src/cli/doctor/managed-link.ts +514 -0
  145. package/src/cli/doctor/native-probe.ts +13 -0
  146. package/src/cli/doctor/permission-repairs.ts +242 -0
  147. package/src/cli/doctor/plugin-quarantine.ts +377 -0
  148. package/src/cli/doctor/plugin-restore.ts +59 -0
  149. package/src/cli/doctor/plugin-targets.ts +373 -0
  150. package/src/cli/doctor/probe-client.ts +195 -0
  151. package/src/cli/doctor/probe-types.ts +21 -0
  152. package/src/cli/doctor/probe.ts +42 -0
  153. package/src/cli/doctor/projection-probe.ts +249 -0
  154. package/src/cli/doctor/repairs.ts +1157 -0
  155. package/src/cli/doctor/report.ts +176 -0
  156. package/src/cli/doctor/runner.ts +342 -0
  157. package/src/cli/doctor/safety.ts +40 -0
  158. package/src/cli/doctor/service-repairs.ts +452 -0
  159. package/src/cli/doctor/service-targets.ts +274 -0
  160. package/src/cli/doctor/types.ts +164 -0
  161. package/src/cli/doctor-cli.ts +62 -0
  162. package/src/cli/doctor-supervisor.ts +571 -0
  163. package/src/cli/doctor-worker.ts +181 -0
  164. package/src/cli/install-activation.ts +666 -0
  165. package/src/cli/macos-community-app.ts +1449 -0
  166. package/src/cli/mcp-cli.ts +11 -21
  167. package/src/cli/nofile-limit.ts +5 -1
  168. package/src/cli/plugin-cli.ts +6 -1
  169. package/src/cli/update-cli.ts +362 -264
  170. package/src/cli-main.ts +517 -0
  171. package/src/cli.ts +64 -433
  172. package/src/commands/autoresearch.ts +11 -5
  173. package/src/commands/completion.ts +1 -1
  174. package/src/commands/doctor.ts +13 -0
  175. package/src/commands/sdk.ts +58 -10
  176. package/src/commands/ultragoal.ts +11 -5
  177. package/src/config/autorouting-tier-map.ts +7 -0
  178. package/src/config/file-lock.ts +736 -71
  179. package/src/config/mcp-schema.json +3 -3
  180. package/src/config/model-preset-registry.ts +1 -0
  181. package/src/config/model-registry.ts +80 -27
  182. package/src/config/model-resolver.ts +33 -4
  183. package/src/config/models-config-schema.ts +2 -0
  184. package/src/config/settings-schema.ts +6 -2
  185. package/src/coordinator-mcp/question-gate-codec.ts +1 -0
  186. package/src/coordinator-mcp/server.ts +534 -51
  187. package/src/coordinator-mcp/session-reaper.ts +64 -8
  188. package/src/cursor.ts +223 -53
  189. package/src/discovery/agents-md.ts +74 -8
  190. package/src/discovery/agents.ts +32 -7
  191. package/src/discovery/builtin.ts +184 -75
  192. package/src/discovery/claude-plugins.ts +85 -17
  193. package/src/discovery/cline.ts +38 -10
  194. package/src/discovery/cursor.ts +19 -6
  195. package/src/discovery/gemini.ts +62 -22
  196. package/src/discovery/github.ts +13 -3
  197. package/src/discovery/helpers.ts +483 -89
  198. package/src/discovery/index.ts +1 -0
  199. package/src/discovery/mcp-json.ts +36 -10
  200. package/src/discovery/opencode.ts +36 -19
  201. package/src/discovery/ssh.ts +11 -8
  202. package/src/discovery/windsurf.ts +12 -3
  203. package/src/exec/bash-executor.ts +10 -3
  204. package/src/exec/isolated-shell.ts +15 -2
  205. package/src/extensibility/extensions/loader.ts +88 -26
  206. package/src/extensibility/gjc-plugins/lifecycle.ts +189 -0
  207. package/src/extensibility/gjc-plugins/paths.ts +4 -1
  208. package/src/extensibility/gjc-plugins/types.ts +27 -0
  209. package/src/extensibility/plugins/manager.ts +200 -22
  210. package/src/extensibility/plugins/marketplace/cache.ts +55 -2
  211. package/src/extensibility/plugins/marketplace/manager.ts +1262 -162
  212. package/src/extensibility/plugins/marketplace/registry.ts +153 -0
  213. package/src/extensibility/plugins/marketplace/source-resolver.ts +116 -10
  214. package/src/extensibility/runtime-skill-discovery.ts +61 -9
  215. package/src/extensibility/skill-management.ts +7 -1
  216. package/src/gjc-runtime/autoresearch-runtime.ts +10 -1
  217. package/src/gjc-runtime/launch-worktree.test.ts +248 -0
  218. package/src/gjc-runtime/launch-worktree.ts +275 -38
  219. package/src/gjc-runtime/repository-binding.ts +26 -1
  220. package/src/gjc-runtime/session-layout.ts +10 -0
  221. package/src/gjc-runtime/session-state-lock.ts +330 -23
  222. package/src/gjc-runtime/session-state-sidecar.ts +328 -80
  223. package/src/gjc-runtime/ultragoal-runtime.ts +10 -1
  224. package/src/harness-control-plane/session-lease.ts +2 -2
  225. package/src/internal-urls/docs-index.generated.ts +28 -26
  226. package/src/main.ts +150 -29
  227. package/src/memories/index.ts +24 -2
  228. package/src/modes/acp/acp-agent.ts +522 -68
  229. package/src/modes/components/agent-dashboard.ts +3 -1
  230. package/src/modes/components/model-selector.ts +28 -19
  231. package/src/modes/components/plugin-settings.ts +2 -1
  232. package/src/modes/controllers/selector-controller.ts +15 -9
  233. package/src/modes/interactive-mode.ts +21 -3
  234. package/src/prompts/system/system-prompt.md +5 -1
  235. package/src/prompts/tools/browser.md +1 -1
  236. package/src/prompts/tools/move-session.md +4 -0
  237. package/src/prompts/tools/read.md +2 -1
  238. package/src/prompts/tools/skill-discovery.md +6 -5
  239. package/src/prompts/tools/task.md +1 -0
  240. package/src/runtime-mcp/config-writer.ts +228 -0
  241. package/src/runtime-mcp/oauth-discovery.ts +114 -14
  242. package/src/runtime-mcp/policy-json-edit.ts +129 -0
  243. package/src/runtime-mcp/startup-policy.ts +14 -0
  244. package/src/runtime-mcp/types.ts +2 -2
  245. package/src/sdk/acp/adapter.ts +27 -12
  246. package/src/sdk/broker/broker.ts +273 -44
  247. package/src/sdk/broker/daemon-entry.ts +119 -0
  248. package/src/sdk/broker/discovery.ts +173 -20
  249. package/src/sdk/broker/doctor-restart.ts +206 -0
  250. package/src/sdk/broker/endpoint-authority.ts +36 -0
  251. package/src/sdk/broker/ensure.ts +49 -14
  252. package/src/sdk/broker/lifecycle.ts +174 -42
  253. package/src/sdk/broker/process-incarnation.ts +86 -2
  254. package/src/sdk/broker/runtime.ts +145 -21
  255. package/src/sdk/broker/session-index.ts +136 -22
  256. package/src/sdk/broker/spawn-substrate.ts +4 -1
  257. package/src/sdk/broker/transport.ts +5 -0
  258. package/src/sdk/broker/worktree-occupancy.ts +21 -1
  259. package/src/sdk/bus/chat-daemon-cli.ts +63 -0
  260. package/src/sdk/bus/chat-daemon-control.ts +260 -64
  261. package/src/sdk/bus/chat-daemon-runtime.ts +141 -25
  262. package/src/sdk/bus/daemon-startup-exclusion.ts +119 -0
  263. package/src/sdk/bus/doctor-daemon-restart-client.ts +291 -0
  264. package/src/sdk/bus/doctor-daemon-restart.ts +92 -0
  265. package/src/sdk/bus/index.ts +252 -51
  266. package/src/sdk/bus/kind-aware-reconciliation.ts +76 -41
  267. package/src/sdk/bus/notification-service.ts +21 -3
  268. package/src/sdk/bus/reconciliation-store.ts +17 -11
  269. package/src/sdk/bus/telegram-daemon-cli.ts +91 -5
  270. package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
  271. package/src/sdk/bus/telegram-daemon-control.ts +47 -0
  272. package/src/sdk/bus/telegram-daemon-owner-registry.ts +1 -1
  273. package/src/sdk/bus/telegram-daemon.ts +178 -13
  274. package/src/sdk/cli/session-cli.ts +100 -12
  275. package/src/sdk/host/host.ts +2 -7
  276. package/src/sdk/host/session-runtime.test.ts +329 -8
  277. package/src/sdk/host/session-runtime.ts +202 -50
  278. package/src/sdk/host/surface-policy.ts +8 -1
  279. package/src/sdk/lifecycle/service.ts +199 -22
  280. package/src/sdk/mcp/server.ts +1 -1
  281. package/src/sdk/prompt-deadline-lease.ts +12 -4
  282. package/src/sdk/prompt-deadline-manager.ts +5 -7
  283. package/src/sdk/prompt-failure.ts +148 -0
  284. package/src/sdk/prompt-status.ts +30 -1
  285. package/src/sdk/prompt-watchdog.ts +11 -3
  286. package/src/sdk/protocol/operation-inventory.generated.json +18 -0
  287. package/src/sdk/protocol/operation-registry.ts +20 -8
  288. package/src/sdk/router/session-router.ts +8 -3
  289. package/src/sdk/service-artifact-paths.ts +26 -0
  290. package/src/sdk/session-authority.ts +10 -0
  291. package/src/sdk/session.ts +361 -194
  292. package/src/session/agent-session.ts +398 -93
  293. package/src/session/blob-store.ts +9 -9
  294. package/src/session/fallback-chain-controller.ts +3 -7
  295. package/src/session/internal/managed-session-scope.ts +445 -29
  296. package/src/session/internal/managed-session-storage.ts +38 -6
  297. package/src/session/primary-control-surface.ts +12 -0
  298. package/src/session/session-manager.ts +11 -3
  299. package/src/session/session-storage.ts +1 -1
  300. package/src/session-import/codex.ts +6 -1
  301. package/src/session-import/redact.ts +7 -0
  302. package/src/skill-state/workflow-mutation-guard.ts +645 -39
  303. package/src/slash-commands/builtin-registry.ts +7 -3
  304. package/src/system-prompt.ts +8 -0
  305. package/src/task/executor.ts +36 -3
  306. package/src/task/types.ts +27 -5
  307. package/src/tools/ask.ts +114 -34
  308. package/src/tools/browser/actions.ts +2 -2
  309. package/src/tools/browser/tab-worker.ts +11 -8
  310. package/src/tools/descriptors.ts +6 -1
  311. package/src/tools/fetch.ts +7 -2
  312. package/src/tools/image-gen.ts +33 -34
  313. package/src/tools/read.ts +78 -32
  314. package/src/tools/skill-discovery.ts +17 -7
  315. package/src/tools/tool-catalog.generated.ts +8 -8
  316. package/src/tools/ultragoal-ask-guard.ts +16 -26
  317. package/src/utils/changelog.ts +7 -1
  318. package/src/utils/git.ts +3 -1
  319. package/src/utils/markit.ts +24 -2
  320. package/src/utils/mupdf-wasm.ts +26 -0
  321. package/src/web/search/providers/openai-compatible.ts +191 -14
@@ -8,7 +8,7 @@
8
8
  * - { source: "git-subdir", url: "...", path: "sub/dir" } → git clone + subdir
9
9
  * - { source: "npm", ... } → not yet supported
10
10
  */
11
- import type { MarketplaceCatalogMetadata, MarketplacePluginEntry } from "./types";
11
+ import type { MarketplaceCatalogMetadata, MarketplacePluginEntry, PluginSource } from "./types";
12
12
  export interface ResolveContext {
13
13
  /** Absolute path to the cloned/local marketplace directory. Required for relative sources. */
14
14
  marketplaceClonePath?: string;
@@ -17,6 +17,21 @@ export interface ResolveContext {
17
17
  /** Scratch directory for sources that require cloning or extraction. */
18
18
  tmpDir: string;
19
19
  }
20
+ export declare function sourcePin(source: PluginSource): {
21
+ ref?: string;
22
+ sha?: string;
23
+ immutable: boolean;
24
+ };
25
+ export declare function assertPinnedSource(source: PluginSource): void;
26
+ /**
27
+ * Independently verify that a resolved git checkout's HEAD matches the pinned
28
+ * SHA the plan/token claims to restore. `git.clone` already checks out the
29
+ * exact SHA, but this re-derives the fact from the checkout itself (a fresh
30
+ * `rev-parse HEAD` in the resolved directory) rather than trusting whatever
31
+ * the resolver returned, so a resolver bug or a swapped working tree cannot
32
+ * silently mismatch source and to-be-published bytes.
33
+ */
34
+ export declare function verifyResolvedProvenance(resolvedDir: string, expectedSha: string): Promise<boolean>;
20
35
  /**
21
36
  * Resolve a plugin source to an absolute local directory path.
22
37
  *
@@ -1,6 +1,8 @@
1
1
  import type { SkillsSettings } from "../config/settings-schema";
2
2
  import { type Skill } from "./skills";
3
- export type RuntimeSkillDiscoverySource = "project" | "user";
3
+ export type RuntimeSkillDiscoverySource = "project" | "user" | "bundled";
4
+ /** Search requests cover filesystem scopes; bundled is only a candidate source. */
5
+ type RuntimeSkillDiscoveryScope = Exclude<RuntimeSkillDiscoverySource, "bundled">;
4
6
  export interface RuntimeSkillDiscoveryCandidate {
5
7
  name: string;
6
8
  description: string;
@@ -19,6 +21,8 @@ export interface RuntimeSkillDiscoveryDiagnostics {
19
21
  }
20
22
  export interface RuntimeSkillDiscoveryResult {
21
23
  candidates: RuntimeSkillDiscoveryCandidate[];
24
+ /** Deduped skill metadata the query filter ran against, including bundled entries; candidates.length <= scanned. */
25
+ scanned: number;
22
26
  diagnostics: RuntimeSkillDiscoveryDiagnostics;
23
27
  }
24
28
  export interface DiscoverRuntimeSkillsOptions {
@@ -29,7 +33,7 @@ export interface DiscoverRuntimeSkillsOptions {
29
33
  profileAuthority?: "default" | "custom";
30
34
  query?: string;
31
35
  limit?: number;
32
- source?: RuntimeSkillDiscoverySource | "all";
36
+ source?: RuntimeSkillDiscoveryScope | "all";
33
37
  policy?: SkillsSettings;
34
38
  }
35
39
  /**
@@ -39,6 +43,15 @@ export interface DiscoverRuntimeSkillsOptions {
39
43
  * aliases map onto the same effective values. Shared by the skill_discovery
40
44
  * tool and `gjc skills discover`.
41
45
  */
42
- export declare function describeDisabledSkillScopes(source: RuntimeSkillDiscoverySource | "all", policy: SkillsSettings | undefined): string | undefined;
46
+ export declare function describeDisabledSkillScopes(source: RuntimeSkillDiscoveryScope | "all", policy: SkillsSettings | undefined): string | undefined;
47
+ /**
48
+ * Explain a zero-candidate result caused by the conjunctive query filter rather
49
+ * than by an empty catalog or disabled scopes: every whitespace-separated term
50
+ * must appear in a candidate's name, description, source, or use conditions (or
51
+ * one term must equal the exact skill name), so a single keyword that appears
52
+ * nowhere drops every skill. Shared by the skill_discovery tool.
53
+ */
54
+ export declare function describeNoSkillMatch(query: string | undefined, scanned: number): string | undefined;
43
55
  export declare function discoverRuntimeSkills(options: DiscoverRuntimeSkillsOptions): Promise<RuntimeSkillDiscoveryResult>;
44
56
  export declare function findRuntimeSkillByName(cwd: string, name: string, policy?: SkillsSettings, home?: string, agentDir?: string, profileAuthority?: "default" | "custom"): Promise<Skill | undefined>;
57
+ export {};
@@ -169,6 +169,12 @@ export declare function autoresearchIssueVerdict(input: {
169
169
  slug?: string;
170
170
  sessionId?: string | null;
171
171
  }): Promise<AutoresearchVerdictReceipt>;
172
+ /**
173
+ * A help request is `--help`/`-h` anywhere in the argv, or a leading `help`
174
+ * verb. Exported so the CLI command class routes help back through this
175
+ * runtime instead of a generic command-level fallback.
176
+ */
177
+ export declare function isAutoresearchHelpInvocation(args: readonly string[]): boolean;
172
178
  export declare function runNativeAutoresearchCommand(args: string[], cwd?: string): Promise<AutoresearchCommandResult>;
173
179
  /**
174
180
  * Rebuilt autoresearch capability surface. Each capability is reachable from
@@ -52,6 +52,59 @@ export declare function parseLaunchWorktreeMode(args: string[]): ParsedLaunchWor
52
52
  export declare function planLaunchWorktree(cwd: string, mode: GjcLaunchWorktreeMode): GjcLaunchWorktreePlan | {
53
53
  enabled: false;
54
54
  };
55
+ /**
56
+ * Whether an existing worktree target can be materialized in place. An empty directory,
57
+ * or one holding nothing but a pre-seeded {@link PRE_WORKTREE_GJC_DIR}, is safe to replace;
58
+ * anything else is a genuine `worktree_path_conflict`. A missing path is trivially usable.
59
+ *
60
+ * A symlinked target is never replaceable: evacuation and overlay writes would follow the
61
+ * link out of the worktree bucket, so it is reported as a conflict instead.
62
+ */
63
+ export declare function isReplaceableWorktreeTarget(worktreePath: string): boolean;
64
+ /**
65
+ * Restore a stashed pre-seeded `.gjc/` into `worktreePath`.
66
+ *
67
+ * `git worktree add` materializes any tracked `.gjc/**` content (e.g. `.gjc/qa/**`) into the
68
+ * fresh worktree before this runs, so a bare rename would collide with EEXIST. When the target
69
+ * already exists, the stashed launcher config is overlaid onto it — stash entries win on name
70
+ * collision, tracked-only entries survive — and the stash is removed. When it does not exist
71
+ * (the untracked case, or a rolled-back add that never checked out), the stash is renamed in.
72
+ */
73
+ export declare function restorePreWorktreeGjc(gjcStash: string, worktreePath: string): void;
74
+ /**
75
+ * Handle returned by {@link evacuatePreWorktreeTarget}: a hook that restores the pre-seeded
76
+ * `.gjc/` into the freshly created worktree, plus the sibling stash path it was moved to
77
+ * (`null` when there was nothing to preserve). The stash path lets a failed restore report
78
+ * where the pre-seeded config can be recovered by hand.
79
+ */
80
+ export interface EvacuationHandle {
81
+ restore: () => void;
82
+ stashPath: string | null;
83
+ }
84
+ /**
85
+ * Clear a {@link isReplaceableWorktreeTarget replaceable} target so `git worktree add` can
86
+ * create it, moving any pre-seeded `.gjc/` to a sibling stash. Returns a hook that restores
87
+ * `.gjc/` into the freshly created worktree; a no-op when there was nothing to preserve.
88
+ */
89
+ export declare function evacuatePreWorktreeTarget(worktreePath: string): EvacuationHandle;
90
+ /**
91
+ * Finalize the pre-seeded `.gjc/` overlay after a successful `git worktree add`, transactionally.
92
+ *
93
+ * `git worktree add` has already registered and materialized the worktree by the time this runs,
94
+ * so a restore/overlay failure cannot simply propagate: the half-prepared worktree would be
95
+ * reused verbatim on the next launch (never restored, stash stranded). On failure this rolls the
96
+ * newly created worktree back so a retry starts clean, preserves the stash for manual recovery,
97
+ * and throws — success is never reported when restoration did not complete.
98
+ */
99
+ export declare function commitPreWorktreeRestore(handle: EvacuationHandle, plan: GjcLaunchWorktreePlan): void;
100
+ /**
101
+ * Acquire a per-target filesystem lock so the replaceability check, evacuation, `git worktree
102
+ * add`, and restore run as one critical section. Without it a second launcher racing on the same
103
+ * target could add files between the scan and the evacuation, or move `.gjc` first and strand the
104
+ * partially modified target. The lock is an atomic `O_EXCL` lockfile beside the target (inside the
105
+ * git-ignored bucket); a concurrent holder fails fast with `worktree_target_locked`.
106
+ */
107
+ export declare function acquireTargetLock(worktreePath: string): () => void;
55
108
  export declare function ensureLaunchWorktree(plan: GjcLaunchWorktreePlan | {
56
109
  enabled: false;
57
110
  }, options?: LaunchWorktreeAbortOptions): GjcLaunchWorktreeResult | {
@@ -44,6 +44,14 @@ export declare function sessionAuditDir(cwd: string, gjcSessionId: string): stri
44
44
  export declare function sessionReportsDir(cwd: string, gjcSessionId: string): string;
45
45
  export declare function sessionLogsDir(cwd: string, gjcSessionId: string): string;
46
46
  export declare function sessionRuntimeDir(cwd: string, gjcSessionId: string): string;
47
+ /**
48
+ * The session-derived runtime-state marker owned by `gjcSessionId` — the marker a session
49
+ * writes when the process carries no coordinator pin for it, and the one a committed cwd move
50
+ * relocates. The coordinator pin is a separate path resolved from
51
+ * `GJC_COORDINATOR_SESSION_STATE_FILE`, so only the sidecar may decide which of the two a
52
+ * session owns; callers use this for the derived half of that decision.
53
+ */
54
+ export declare function sessionRuntimeStatePath(cwd: string, gjcSessionId: string): string;
47
55
  export declare function sessionIpykernelsDir(cwd: string, gjcSessionId: string): string;
48
56
  export declare function sessionIpykernelsArtifactsDir(cwd: string, gjcSessionId: string): string;
49
57
  export declare function pythonKernelTranscriptPath(cwd: string, gjcSessionId: string, dirName: string): string;
@@ -115,6 +115,16 @@ export declare function sessionStateLockFailureFields(error: unknown): {
115
115
  reason?: SessionStateLockUnavailableReason;
116
116
  lockPath?: string;
117
117
  };
118
+ /**
119
+ * Whether a failed persist lost only a race and is worth attempting again.
120
+ *
121
+ * A coordinator runtime-state update that is dropped on contention is not recoverable by
122
+ * any later write: the coordinator keeps reporting a stale lifecycle/activity snapshot for
123
+ * that session until some unrelated event happens to win the lock. Retrying a contention
124
+ * refusal is therefore repairing a dropped update, not masking a fault — and it is
125
+ * deliberately limited to the reasons that carry no information about the document.
126
+ */
127
+ export declare function isRetryableSessionStateLockContention(error: unknown): boolean;
118
128
  export declare const PERSIST_FAILURE_WARN_WINDOW_MS = 30000;
119
129
  /**
120
130
  * Whether a persist failure should be logged at warn level. The first failure for each
@@ -168,6 +178,11 @@ export declare function reclaimStaleSessionStateLock(lockFile: string, quarantin
168
178
  * Taking the path, cleaning up a failed write, and releasing are all pathname transitions,
169
179
  * so each runs under the transition claim — never the caller's operation, which holds the
170
180
  * lock file itself and may run for as long as it needs.
181
+ *
182
+ * The acquisition deadline measures LACK OF PROGRESS, not total waiting: see
183
+ * {@link creditLockHandoffProgress}. A contender behind a queue of peers that are each
184
+ * taking and releasing the lock normally keeps waiting; one behind a lock that never moves
185
+ * still refuses promptly.
171
186
  */
172
187
  export declare function withSessionStateFileLock<T>(stateFile: string, operation: () => Promise<T>): Promise<T>;
173
188
  /**
@@ -168,6 +168,17 @@ export interface RuntimeStateContext {
168
168
  sessionId: string;
169
169
  cwd: string;
170
170
  sessionFile?: string | null;
171
+ /**
172
+ * The marker file THIS context owns.
173
+ *
174
+ * `undefined` keeps the process-wide coordinator pin authoritative (falling back to the
175
+ * session-derived path when this process carries no pin), which is what a top-level
176
+ * session wants. Naming a path is how a session that is NOT the pinned one — an
177
+ * in-process role-agent/subagent session sharing the parent's environment — takes
178
+ * ownership of its own marker instead of reading and writing the parent's (#5473).
179
+ * `null` means this context has no marker at all and every write is skipped.
180
+ */
181
+ stateFile?: string | null;
171
182
  /** Optional platform seam for deterministic cross-platform path identity checks. */
172
183
  platform?: NodeJS.Platform;
173
184
  branch?: string | null;
@@ -229,6 +240,8 @@ export declare function prepareCoordinatorRuntimeStateRescope(input: {
229
240
  };
230
241
  previousSessionFile?: string | null;
231
242
  newSessionFile?: string | null;
243
+ /** The marker this session owns; `undefined` lets the process pin answer for it. */
244
+ stateFile?: string | null;
232
245
  }): Promise<string>;
233
246
  export declare function markCoordinatorRuntimeStateRescopePublishing(context: RuntimeStateContext, previousCwd: string, moveId: string): Promise<void>;
234
247
  export declare function clearCoordinatorRuntimeStateRescope(context: RuntimeStateContext, expectedMoveId?: string, previousCwd?: string): Promise<void>;
@@ -458,6 +458,12 @@ export declare class UltragoalReviewBlockerRecursionCapError extends Error {
458
458
  constructor(blockedGoalId: string, unresolvedDescents: number, cap?: number);
459
459
  }
460
460
  export declare function runUltragoalReview(cwd: string, args: readonly string[]): Promise<UltragoalReviewResult>;
461
+ /**
462
+ * A help request is `--help`/`-h` anywhere in the argv, or a leading `help`
463
+ * verb. Exported so the CLI command class routes help back through the
464
+ * verb-aware renderer instead of a generic command-level fallback.
465
+ */
466
+ export declare function isUltragoalHelpInvocation(args: readonly string[]): boolean;
461
467
  export declare function runNativeUltragoalCommand(args: string[], cwd?: string, options?: {
462
468
  agentDir?: string;
463
469
  }): Promise<UltragoalCommandResult>;
@@ -19,6 +19,7 @@ import type { MCPManager } from "./runtime-mcp";
19
19
  import { type CreateAgentSessionOptions, type CreateAgentSessionResult, createAgentSession, discoverAuthStorage } from "./sdk";
20
20
  import type { AgentSession } from "./session/agent-session";
21
21
  import { type ResumeSessionIdentity, type SessionDestination, type SessionDirectoryMigrationPolicy, type SessionInfo, SessionManager, type StrictSessionOpenResult } from "./session/session-manager";
22
+ import { resolveStartupAuthConfig } from "./session/startup-auth-config";
22
23
  import { runStartupCredentialAutoImportIfNeeded } from "./setup/credential-auto-import";
23
24
  import type { LspStartupServerInfo } from "./tools";
24
25
  import type { EventBus } from "./utils/event-bus";
@@ -102,7 +103,23 @@ export declare const BARE_RESUME_INTERACTIVE_ERROR = "--resume requires an inter
102
103
  /** Resolves only the managed agent root needed for pre-consent picker inventory. */
103
104
  export declare function resolveManagedAgentDirForScope(_cwd: string): string;
104
105
  export declare const BARE_RESUME_OPEN_ERROR = "Could not open the selected session. Use --resume <id>.";
105
- export declare function runInteractiveMode(session: AgentSession, version: string, changelogMarkdown: string | undefined, notifs: (InteractiveModeNotify | null)[], startupUpdate: StartupUpdateOrchestrator, initialMessages: string[], setExtensionUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void, lspServers: LspStartupServerInfo[] | undefined, mcpManager: MCPManager | undefined, eventBus?: EventBus, initialMessage?: string, initialImages?: ImageContent[], createInteractiveMode?: CreateInteractiveMode, resumeAction?: "continue-tail" | "open-idle", startDeferredMcpConfig?: CreateAgentSessionResult["startDeferredMcpConfig"], startDeferredModelProfiles?: DeferredModelProfileStartup): Promise<void>;
106
+ export declare class SessionForkDeclinedError extends Error {
107
+ #private;
108
+ readonly code: "session_fork_declined";
109
+ constructor(sessionId: string, projectDirectory: string);
110
+ get sessionId(): string;
111
+ get projectDirectory(): string;
112
+ }
113
+ export declare class SessionNotFoundError extends Error {
114
+ #private;
115
+ readonly code: "session_not_found";
116
+ constructor(sessionId: string);
117
+ get sessionId(): string;
118
+ }
119
+ export declare function operatorFacingSessionOpenMessage(value: unknown): string | undefined;
120
+ export declare function runInteractiveMode(session: AgentSession, version: string, changelogMarkdown: string | undefined, notifs: (InteractiveModeNotify | null)[], startupUpdate: StartupUpdateOrchestrator, initialMessages: string[], setExtensionUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void, lspServers: LspStartupServerInfo[] | undefined, mcpManager: MCPManager | undefined, eventBus?: EventBus, initialMessage?: string, initialImages?: ImageContent[], createInteractiveMode?: CreateInteractiveMode, resumeAction?: "continue-tail" | "open-idle", startDeferredMcpConfig?: CreateAgentSessionResult["startDeferredMcpConfig"], startDeferredModelProfiles?: DeferredModelProfileStartup, options?: {
121
+ stopAfterFirstPaint?: boolean;
122
+ }): Promise<void>;
106
123
  export declare function getChangelogForDisplay(parsed: Args): Promise<string | undefined>;
107
124
  export declare function createSessionManager(parsed: Args, cwd: string, activeSettings?: Settings): Promise<SessionManager | undefined>;
108
125
  type RunPrintMode = (session: AgentSession, options: PrintModeOptions) => Promise<void>;
@@ -110,6 +127,7 @@ export interface RunRootCommandDependencies {
110
127
  createAgentSession?: typeof createAgentSession;
111
128
  createSessionManager?: typeof createSessionManager;
112
129
  discoverAuthStorage?: typeof discoverAuthStorage;
130
+ resolveStartupAuthConfig?: typeof resolveStartupAuthConfig;
113
131
  runAcpMode?: (options?: {
114
132
  agentDir?: string;
115
133
  }) => Promise<void>;
@@ -2,6 +2,39 @@ import { type Agent, type AgentSideConnection, type AuthenticateRequest, type Au
2
2
  import { type AcpProviderRegistration, type AcpReverseConnection, AcpSdkAdapter } from "../../sdk/acp";
3
3
  import { type PromptWatchdogClock } from "../../sdk/prompt-watchdog";
4
4
  import type { AcpStartupOptions } from "./startup-options";
5
+ /**
6
+ * Wall-clock ceiling an external ACP client grants a `session/new` before it
7
+ * abandons the connection (paseo's daemon uses 60s). gjc must return a
8
+ * `session.create` response — a launched session or a terminal launch error —
9
+ * inside this window, or the client reports a dead provider while gjc is still
10
+ * healthily spawning the host. See issue #5565.
11
+ */
12
+ export declare const ACP_EXTERNAL_CONNECT_TIMEOUT_MS = 60000;
13
+ /**
14
+ * Readiness budget every ACP session launch requests, independent of MCP.
15
+ *
16
+ * Two constraints bound this value:
17
+ *
18
+ * 1. Floor — host cold start costs the same whether or not the client declared
19
+ * MCP servers, so leaving the MCP-less path on the broker's 10s default made
20
+ * it the only ACP launch that failed under ordinary concurrency: a second
21
+ * host starting beside the first measurably crosses that deadline, the broker
22
+ * reports the launch as `terminal_uncertain`, and an external client surfaces
23
+ * a dead provider.
24
+ * 2. Ceiling — the broker may park a startup in its admission queue for a whole
25
+ * readiness budget before the readiness clock even starts, so the ACP adapter
26
+ * sizes its client-side wait at `lifecycleStartupBudgetMs(R)` = queue wait +
27
+ * readiness = `2·R`, plus caller slack. With R = 30.5s that wait reached ~62s
28
+ * — past paseo's 60s connect timeout — so a queued or slow-cold-start launch
29
+ * let paseo abandon the connection before gjc could answer `session/new` at
30
+ * all (#5565). R must keep `2·R + slack` safely under
31
+ * {@link ACP_EXTERNAL_CONNECT_TIMEOUT_MS}.
32
+ *
33
+ * 22s satisfies both: comfortably above the ~16s cold starts observed on slow
34
+ * hosts (and the 10s concurrency floor) while holding the client-side lifecycle
35
+ * budget near 45s — a ~15s margin under the 60s ceiling.
36
+ */
37
+ export declare const ACP_SESSION_READINESS_TIMEOUT_MS = 22000;
5
38
  type JsonObject = Record<string, unknown>;
6
39
  /** Applies ACP's offset cursor after narrowing the broker listing to the requested cwd. */
7
40
  export declare function paginateAcpSessions(listed: unknown[], cwd: string | undefined, offset: number, sessionMetadata?: ReadonlyMap<string, {
@@ -62,6 +95,13 @@ export interface TranscriptContinuation {
62
95
  field: string;
63
96
  }
64
97
  export declare function transcriptContinuations(entry: unknown): TranscriptContinuation[];
98
+ /**
99
+ * Recover a session-scoped preset only when the host's current model carries
100
+ * the synthetic profile namespace. A plain `modelPreset` value may be the
101
+ * persisted default and is therefore insufficient to identify an active
102
+ * profile, especially when attaching through the base ACP provider.
103
+ */
104
+ export declare function activeModelPresetFromConfig(query: unknown): string | undefined;
65
105
  /**
66
106
  * Collect every page of `providers.list/active` (Q29, GJC >= 0.12.8) and
67
107
  * return the providers with usable stored credentials or credentialless
@@ -6,6 +6,7 @@ interface AgentDashboardModelContext {
6
6
  modelRegistry?: ModelRegistry;
7
7
  activeModelPattern?: string;
8
8
  defaultModelPattern?: string;
9
+ credentialSessionId?: string;
9
10
  }
10
11
  export declare function resolveAgentCreationModel(modelPatterns: string[], modelRegistry: ModelRegistry, settings: Settings | undefined): import("@gajae-code/ai").Model<import("@gajae-code/ai").Api>;
11
12
  export declare function updateAgentModelOverride(overrides: Record<string, ModelSelectorValue>, agentName: string, rawValue: string): Record<string, ModelSelectorValue>;
@@ -46,6 +46,8 @@ type ModelSelectorViewMode = "presets" | "models" | "smart-routing";
46
46
  export declare class ModelSelectorComponent extends Container {
47
47
  #private;
48
48
  constructor(tui: TUI, _currentModel: Model | undefined, settings: Settings, modelRegistry: ModelRegistry, scopedModels: ReadonlyArray<ScopedModelItem>, onSelect: RoleSelectCallback, onCancel: () => void, options?: {
49
+ /** Use layout only when mounted outside the viewport-anchor transcript subtree. */
50
+ renderScope?: "full" | "layout";
49
51
  temporaryOnly?: boolean;
50
52
  initialSearchInput?: string;
51
53
  sessionId?: string;
@@ -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, AsyncJobSnapshotItem } from "../session/agent-session";
12
+ import { type AgentSession, type AgentSessionEvent, type 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";
@@ -1,3 +1,9 @@
1
+ /**
2
+ * MCP Configuration File Writer
3
+ *
4
+ * Utilities for reading/writing .gjc/mcp.json files at user or project level.
5
+ */
6
+ import { type NativeExactFileIdentity } from "@gajae-code/natives";
1
7
  import { type MCPConfigFile, type MCPServerConfig } from "./types";
2
8
  /**
3
9
  * Read an MCP config file.
@@ -87,3 +93,44 @@ export declare function readDisabledServers(filePath: string): Promise<string[]>
87
93
  * Add or remove a server name from the disabled servers list.
88
94
  */
89
95
  export declare function setServerDisabled(filePath: string, name: string, disabled: boolean): Promise<void>;
96
+ export interface ExactMcpBooleanUpdate {
97
+ readonly beforeRaw?: string;
98
+ readonly beforeIdentity?: NativeExactFileIdentity;
99
+ readonly beforeValue?: unknown;
100
+ readonly afterValue: boolean;
101
+ }
102
+ /** Exact-field JSON CAS used by doctor; server names are object keys and may contain dots. */
103
+ export declare function updateMCPBooleanExact(filePath: string, name: string, field: "autoload" | "enabled", value: boolean, expected: {
104
+ readonly raw: string;
105
+ readonly identity: NativeExactFileIdentity;
106
+ }): Promise<{
107
+ beforeValue: unknown;
108
+ afterValue: boolean;
109
+ changed: boolean;
110
+ afterIdentity?: NativeExactFileIdentity;
111
+ }>;
112
+ export type RestoreMCPBooleanResult = {
113
+ readonly status: "restored";
114
+ } | {
115
+ readonly status: "conflict";
116
+ } | {
117
+ readonly status: "failed";
118
+ readonly reason: string;
119
+ };
120
+ /**
121
+ * Roll back exactly one `mcpServers.<name>.<field>` token to its captured
122
+ * `value` (which may be `undefined` to restore an originally-absent field, or
123
+ * an originally-invalid non-boolean scalar). Binds to the PUBLISHED file's
124
+ * dev/ino/parent identity captured right after the mutating replace — not the
125
+ * pre-mutation identity — and to the field's known current (post-mutation)
126
+ * value, so an unrelated in-place sibling edit made after publication is
127
+ * preserved rather than reverted by a stale whole-file snapshot. A CAS
128
+ * precondition mismatch (identity or field drifted) is a `conflict`; any
129
+ * other unexpected error is reported as `failed` and must never be silently
130
+ * folded into `conflict`, since only `conflict` means "an independent editor
131
+ * already resolved this and no action is required".
132
+ */
133
+ export declare function restoreMCPBooleanExact(filePath: string, name: string, field: "autoload" | "enabled", originalRaw: string, expected: {
134
+ readonly identity: NativeExactFileIdentity;
135
+ readonly currentValue: boolean;
136
+ }): Promise<RestoreMCPBooleanResult>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Lossless JSON policy-field editing for `.gjc/mcp.json`.
3
+ *
4
+ * Uses `jsonc-parser`'s AST/edit API instead of `JSON.parse`/`JSON.stringify`
5
+ * so only the selected `mcpServers.<name>.<field>` token is rewritten. Every
6
+ * other token in the document (unrelated fields, large
7
+ * integer literals, `-0`, secrets) survives untouched. `JSON.parse` would
8
+ * silently normalize those values and collapse duplicate keys to "last one
9
+ * wins", hiding a real authoring bug — so duplicate keys along the selected
10
+ * path are rejected instead of being silently resolved.
11
+ */
12
+ import { type Node } from "jsonc-parser";
13
+ export type McpBooleanField = "autoload" | "enabled";
14
+ export type McpFieldReadResult = {
15
+ readonly status: "ok";
16
+ readonly exists: boolean;
17
+ readonly value: unknown;
18
+ } | {
19
+ readonly status: "duplicate_key";
20
+ readonly path: string;
21
+ } | {
22
+ readonly status: "malformed";
23
+ } | {
24
+ readonly status: "not_found";
25
+ };
26
+ export type McpFieldWriteResult = {
27
+ readonly status: "ok";
28
+ readonly text: string;
29
+ readonly beforeValue: unknown;
30
+ } | {
31
+ readonly status: "duplicate_key";
32
+ readonly path: string;
33
+ } | {
34
+ readonly status: "malformed";
35
+ } | {
36
+ readonly status: "not_found";
37
+ };
38
+ /**
39
+ * Detect a duplicate property name at each level while descending the given
40
+ * path. Scoped to the selected policy path only — this is not a whole-document
41
+ * scan; it visits only the objects on the selected path.
42
+ */
43
+ export declare function findDuplicateKeyAlongPath(root: Node, path: readonly string[]): string | undefined;
44
+ /** Read one selected `mcpServers.<name>.<field>` boolean without collapsing duplicate keys. */
45
+ export declare function readMcpBooleanField(raw: string, serverName: string, field: McpBooleanField): McpFieldReadResult;
46
+ /**
47
+ * Compute the lossless text after setting `mcpServers.<name>.<field>` to
48
+ * `value`, or removing it when `value` is `undefined` (used to restore an
49
+ * originally-absent field). Only the selected token's edit range changes.
50
+ */
51
+ export declare function writeMcpBooleanField(raw: string, serverName: string, field: McpBooleanField,
52
+ /**
53
+ * The new field value. `undefined` removes the key, restoring an
54
+ * originally-absent field on rollback. A rollback may also need to restore
55
+ * an originally-invalid non-boolean scalar, so this intentionally accepts
56
+ * any JSON value rather than only `boolean`.
57
+ */
58
+ value: unknown): McpFieldWriteResult;
59
+ /** Restore the original token, rather than reserializing its possibly-invalid value. */
60
+ export declare function restoreMcpBooleanField(raw: string, original: string, serverName: string, field: McpBooleanField): McpFieldWriteResult;
@@ -0,0 +1,4 @@
1
+ import type { MCPServerConfig } from "./types";
2
+ export type AutoloadStatus = "autoload" | "autoload-off" | "disabled";
3
+ /** Pure startup policy shared by runtime-facing CLI inspection and doctor. */
4
+ export declare function computeAutoloadStatus(name: string, config: Pick<MCPServerConfig, "enabled" | "autoload">, disabledServers: ReadonlySet<string>): AutoloadStatus;
@@ -51,8 +51,8 @@ export interface MCPServerConfigBase {
51
51
  * Whether an explicit runtime MCP consumer should connect this server
52
52
  * automatically when that consumer starts (default: true). Ordinary
53
53
  * standalone `gjc`, `gjc --tmux`, and print-mode sessions honor autoload for
54
- * conventional registrations; `autoload: false` keeps a server configured
55
- * for on-demand `/mcp` connection. `--no-mcp` opts a session out entirely.
54
+ * conventional registrations; `autoload: false` keeps a server stored but
55
+ * unloaded at startup. `--no-mcp` opts a session out entirely.
56
56
  */
57
57
  autoload?: boolean;
58
58
  /** Connection timeout in milliseconds (default: 30000) */
@@ -44,6 +44,8 @@ export declare class AcpSdkAdapter {
44
44
  #private;
45
45
  constructor(options: AcpSdkAdapterOptions);
46
46
  static connect(options: AcpSdkAdapterOptions): Promise<AcpSdkAdapter>;
47
+ /** Authorize provider registration after the host startup origin is known. */
48
+ authorizeProviderActivation(): void;
47
49
  acceptAttachment(attachment: SessionAttachment): void;
48
50
  revokeAttachment(attachment: SessionAttachment): void;
49
51
  attachmentReady(attachment: SessionAttachment): Promise<void>;
@@ -59,7 +61,9 @@ export declare class AcpSdkAdapter {
59
61
  get connectionId(): string | undefined;
60
62
  onReconnectFailed(handler: AcpReconnectFailedHandler): () => void;
61
63
  onFrame(handler: AcpFrameHandler): () => void;
62
- start(): Promise<void>;
64
+ start(options?: {
65
+ activateProviders?: boolean;
66
+ }): Promise<void>;
63
67
  close(): Promise<void>;
64
68
  prompt(params: JsonObject | string): Promise<unknown>;
65
69
  /**
@@ -9,6 +9,8 @@ import { type MasterCapabilityVerifier, type SpawnSubstrateFailure, type SpawnSu
9
9
  export interface BrokerSettings {
10
10
  agentDir: string;
11
11
  packageGeneration?: string;
12
+ /** Published runtime image; tests inject one to model a vanished executable. */
13
+ runtime?: string;
12
14
  port?: number;
13
15
  heartbeatTtlMs?: number;
14
16
  /** Broker-owned migration policy. Client lifecycle frames cannot select it. */
@@ -23,10 +25,19 @@ export interface BrokerSettings {
23
25
  masterOrphanGraceMs?: number;
24
26
  /** Host model resolver override for lifecycle tests and embedders. */
25
27
  resolveModelPin?: SdkHostModelResolver;
28
+ /**
29
+ * Exact restart request this process instance is the authorized successor
30
+ * for. Set only by the real `broker-internal` entry point from its own
31
+ * `GJC_BROKER_RESTART_REQUEST` environment read — never inferred here from
32
+ * `process.env` directly, so the value this broker publishes is exactly the
33
+ * value its launcher decided, with no cast/assumed tag in between.
34
+ */
35
+ restartRequestId?: string;
26
36
  }
27
37
  type ResolvedBrokerSettings = {
28
38
  agentDir: string;
29
39
  packageGeneration: string;
40
+ runtime?: string;
30
41
  port: number;
31
42
  heartbeatTtlMs: number;
32
43
  resolveDirectoryMigration: (_cwd: string) => Promise<DirectoryMigrationPolicy>;
@@ -34,6 +45,7 @@ type ResolvedBrokerSettings = {
34
45
  spawnSubstrateProvider?: SpawnSubstrateProvider;
35
46
  spawnPromptLayer?: SpawnPromptLayer;
36
47
  masterOrphanGraceMs: number;
48
+ restartRequestId?: string;
37
49
  };
38
50
  export declare function resolveBrokerPackageGeneration(): string;
39
51
  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 & {});
@@ -235,6 +247,42 @@ export interface StartupAdmissionTiming {
235
247
  now(): number;
236
248
  sleep(ms: number, signal?: AbortSignal): Promise<void>;
237
249
  }
250
+ export interface BrokerRestartOwnerIdentity {
251
+ ownerId: string;
252
+ generation: string;
253
+ pid: number;
254
+ incarnation: string;
255
+ }
256
+ export interface BrokerRestartPrepareOptions extends BrokerRestartOwnerIdentity {
257
+ requestId: string;
258
+ deadlineAt: number;
259
+ drain?: boolean;
260
+ }
261
+ export interface BrokerRestartPrepareResult {
262
+ lease: string;
263
+ occupancyEpoch: number;
264
+ expiresAt: number;
265
+ requestId: string;
266
+ owner: BrokerRestartOwnerIdentity;
267
+ }
268
+ export interface BrokerRestartCommitOptions extends BrokerRestartPrepareOptions {
269
+ lease: string;
270
+ occupancyEpoch: number;
271
+ }
272
+ export type BrokerRestartResult = {
273
+ ok: true;
274
+ result: BrokerRestartPrepareResult | {
275
+ committed: true;
276
+ } | {
277
+ cancelled: true;
278
+ };
279
+ } | {
280
+ ok: false;
281
+ error: {
282
+ code: string;
283
+ message: string;
284
+ };
285
+ };
238
286
  export type StartupAdmissionResult<T> = {
239
287
  status: "completed";
240
288
  admittedAt: number;
@@ -284,6 +332,9 @@ export declare class Broker {
284
332
  start(): Promise<BrokerDiscovery>;
285
333
  get ownsDiscovery(): boolean;
286
334
  get completion(): Promise<void>;
335
+ prepareRestart(options: BrokerRestartPrepareOptions): Promise<BrokerRestartResult>;
336
+ commitRestart(options: BrokerRestartCommitOptions): Promise<BrokerRestartResult>;
337
+ cancelRestart(requestId: string): Promise<BrokerRestartResult>;
287
338
  status(): RedactedBrokerDiscovery | null;
288
339
  heartbeat(): Promise<void>;
289
340
  /** Re-observes provably live session hosts and checkpoints their liveness. */
@@ -0,0 +1,39 @@
1
+ import { type BrokerDiscovery } from "./discovery";
2
+ export interface AuthorizedBrokerSuccessorOptions {
3
+ agentDir: string;
4
+ requestId: string;
5
+ deadlineAt: number;
6
+ packageGeneration: string;
7
+ }
8
+ /** Typed outcome of a successor-launch attempt; never an opaque thrown message. */
9
+ export type AuthorizedBrokerSuccessorResult = {
10
+ kind: "adopted";
11
+ discovery: BrokerDiscovery;
12
+ } | {
13
+ kind: "spawned";
14
+ discovery: BrokerDiscovery;
15
+ } | {
16
+ kind: "refused";
17
+ reason: "deadline_elapsed" | "intent_not_committed" | "spawn_failed" | "spawn_exited_before_publication" | "publication_timeout";
18
+ detail?: string;
19
+ };
20
+ /**
21
+ * Launches (or adopts) exactly one authorized successor for `requestId`.
22
+ *
23
+ * Holds `withBrokerStartupLock` only around the decision to spawn and the
24
+ * detached `spawn()` call itself -- never across the successor's own
25
+ * publication wait. The successor process (`commands/sdk.ts`'s
26
+ * `broker-internal` branch) acquires that SAME lock during its own startup to
27
+ * serialize against ordinary concurrent starts; holding it here while
28
+ * blocking on that child's publication would deadlock the parent against its
29
+ * own child. The unguarded polling loop below runs strictly after the lock
30
+ * has been released.
31
+ */
32
+ export declare function launchAuthorizedBrokerSuccessor(options: AuthorizedBrokerSuccessorOptions): Promise<AuthorizedBrokerSuccessorResult>;
33
+ /**
34
+ * Positive OS-confirmed absence of the exact prior owner, distinguished from
35
+ * every merely-inconclusive outcome (permission denial, PID reuse ambiguity,
36
+ * missing native addon). Never treats a null/changed incarnation read alone as
37
+ * death proof; only `observeProcessIncarnation`'s `"absent"` status counts.
38
+ */
39
+ export declare function oldOwnerConfirmedExited(pid: number): boolean;