@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
@@ -0,0 +1,89 @@
1
+ import type { LocalRestorePlanV1 } from "../../extensibility/gjc-plugins/types";
2
+ import type { MarketplaceRestorePlanV1 } from "../../extensibility/plugins/marketplace/manager";
3
+ import type { DoctorOptions } from "./args";
4
+ import type { DoctorFileObservation } from "./files";
5
+ import { type ResolvedRoot } from "./ids";
6
+ import type { InstallRestoreDescriptorV1 } from "./install-repairs";
7
+ import type { ManagedLinkDescriptor } from "./managed-link";
8
+ import type { PluginQuarantinePlan } from "./plugin-quarantine";
9
+ import type { DoctorServiceObservation } from "./service-targets";
10
+ import type { DoctorScope } from "./types";
11
+ export interface DoctorConfigSource {
12
+ readonly scope: DoctorScope;
13
+ readonly root: ResolvedRoot;
14
+ readonly configPath: string;
15
+ readonly mcpPath: string;
16
+ }
17
+ export interface DoctorSettingTarget {
18
+ readonly kind: "config";
19
+ readonly targetId: string;
20
+ readonly source: DoctorConfigSource;
21
+ readonly schemaKey: "skills.enabled" | "skills.enableSkillCommands";
22
+ readonly observation: DoctorFileObservation;
23
+ readonly beforeValue: unknown;
24
+ }
25
+ export interface DoctorMcpTarget {
26
+ readonly kind: "mcp";
27
+ readonly targetId: string;
28
+ readonly source: DoctorConfigSource;
29
+ readonly serverName: string;
30
+ readonly field: "autoload" | "enabled";
31
+ readonly definitionIsMapping: boolean;
32
+ readonly observation: DoctorFileObservation;
33
+ readonly beforeValue: unknown;
34
+ }
35
+ export interface DoctorPermissionTarget {
36
+ readonly kind: "permission";
37
+ readonly targetId: string;
38
+ readonly source: DoctorConfigSource;
39
+ readonly observation: DoctorFileObservation;
40
+ }
41
+ export interface DoctorInstallTarget {
42
+ readonly kind: "binary" | "link";
43
+ readonly targetId: string;
44
+ readonly filePath: string;
45
+ readonly root: ResolvedRoot;
46
+ readonly installDescriptor?: InstallRestoreDescriptorV1;
47
+ readonly linkDescriptor?: ManagedLinkDescriptor;
48
+ }
49
+ export interface DoctorPluginTarget {
50
+ readonly kind: "plugin";
51
+ readonly targetId: string;
52
+ readonly family: "gjc" | "npm" | "marketplace";
53
+ readonly scope: DoctorScope;
54
+ readonly name: string;
55
+ readonly root: ResolvedRoot;
56
+ readonly quarantinePlan?: PluginQuarantinePlan;
57
+ /** Original read-only restore observation; apply is authorized against this exact plan, never a fresh one. */
58
+ readonly restorePlan?: LocalRestorePlanV1;
59
+ /** Original read-only private-marketplace restore observation; apply authorizes against this exact plan. */
60
+ readonly marketplaceRestorePlan?: MarketplaceRestorePlanV1;
61
+ /** Immutable stored-source identity a restore `--ref` must equal; absent means the source is unpinnable. */
62
+ readonly restoreRef?: string;
63
+ /** Stable artifact-tree digest the restore `--sha256` must equal; recomputed by the lifecycle from the resolved source. */
64
+ readonly restoreArtifactDigest?: string;
65
+ readonly registryPath?: string;
66
+ }
67
+ export interface DoctorServiceTarget {
68
+ readonly kind: "service" | "artifact";
69
+ readonly targetId: string;
70
+ readonly service: "broker" | "telegram" | "discord" | "slack";
71
+ readonly root: ResolvedRoot;
72
+ readonly slot?: "discovery" | "owner-lock" | "startup-marker";
73
+ readonly observation: DoctorServiceObservation;
74
+ }
75
+ export type DoctorTarget = DoctorSettingTarget | DoctorMcpTarget | DoctorPermissionTarget | DoctorInstallTarget | DoctorPluginTarget | DoctorServiceTarget;
76
+ export interface DoctorContext {
77
+ readonly options: DoctorOptions;
78
+ readonly cwd: string;
79
+ readonly agentRoot: ResolvedRoot;
80
+ readonly installRoot: ResolvedRoot;
81
+ readonly sources: readonly DoctorConfigSource[];
82
+ readonly targets: Map<string, DoctorTarget>;
83
+ readonly compiled: boolean;
84
+ readonly executable: string;
85
+ readonly cliPath?: string;
86
+ readonly deadline: number;
87
+ }
88
+ /** Resolve only existing product directory conventions; this never initializes settings. */
89
+ export declare function createDoctorContext(options: DoctorOptions): DoctorContext;
@@ -0,0 +1,27 @@
1
+ import type { NativeExactFileIdentity } from "@gajae-code/natives";
2
+ export declare const DOCTOR_FILE_LIMIT: number;
3
+ export interface DoctorFileIdentity {
4
+ readonly device: number;
5
+ readonly inode: number;
6
+ readonly size: number;
7
+ readonly modifiedMs: number;
8
+ readonly changedMs: number;
9
+ readonly mode: number;
10
+ readonly owner: number;
11
+ readonly links: number;
12
+ }
13
+ export type DoctorFileObservation = {
14
+ readonly status: "read";
15
+ readonly text: string;
16
+ readonly identity: DoctorFileIdentity;
17
+ /** Private commit authority, never serialized into the public diagnostic report. */
18
+ readonly exactIdentity: NativeExactFileIdentity;
19
+ } | {
20
+ readonly status: "missing" | "unreadable" | "symlink" | "not_regular" | "limit_exceeded" | "changed";
21
+ readonly errno?: string;
22
+ };
23
+ export declare function doctorErrno(error: unknown): string;
24
+ export declare function sameDoctorFile(left: DoctorFileIdentity, right: DoctorFileIdentity): boolean;
25
+ /** Read one bounded regular file; absence is never inferred from access failure. */
26
+ export declare function readDoctorFile(filePath: string, limit?: number): Promise<DoctorFileObservation>;
27
+ export declare function doctorMapping(value: unknown): Record<string, unknown> | undefined;
@@ -0,0 +1,20 @@
1
+ import type { DoctorScope } from "./types";
2
+ export type RootKind = "config-user" | "config-project" | "agent" | "install";
3
+ export interface ResolvedRoot {
4
+ readonly kind: RootKind;
5
+ readonly locator: string;
6
+ readonly rootId: string;
7
+ readonly resolution: "resolved" | "resolution_unknown";
8
+ }
9
+ export declare function canonicalDigest(parts: readonly string[]): string;
10
+ export declare function resolveDoctorRoot(kind: RootKind, locator: string): ResolvedRoot;
11
+ export declare function configTargetId(rootId: string, scope: DoctorScope, schemaKey: string): string;
12
+ export declare function mcpTargetId(rootId: string, scope: DoctorScope, serverLogicalName: string, field: "autoload" | "enabled"): string;
13
+ export declare function permissionTargetId(rootId: string): string;
14
+ export declare function binaryTargetId(rootId: string, locator: string): string;
15
+ export declare function linkTargetId(rootId: string, linkName: string): string;
16
+ export declare function pluginTargetId(rootId: string, family: "gjc" | "npm" | "marketplace", scope: DoctorScope, name: string): string;
17
+ export declare function serviceTargetId(rootId: string, service: "broker" | "telegram" | "discord" | "slack"): string;
18
+ export declare function artifactTargetId(rootId: string, service: "broker" | "telegram" | "discord" | "slack", slot: "discovery" | "owner-lock" | "startup-marker"): string;
19
+ export declare function candidateLinkId(rootId: string, kind: "source" | "wrapper" | "binary", locator: string): string;
20
+ export declare function isDoctorTargetId(value: string): boolean;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `install.restore-binary` (D4) domain logic: read-only descriptor plus the
3
+ * bounded standalone-binary restore transaction.
4
+ *
5
+ * All mutation flows through the shared `install-activation.ts` authority so
6
+ * `gjc doctor` and `gjc update` never maintain competing activation state:
7
+ * this module never calls the native `exactReplaceRetained` primitive
8
+ * directly, it only builds/writes the v1 record and then delegates the
9
+ * actual promotion (and every retry of an interrupted one) to
10
+ * `reconcileActivationRecord`.
11
+ */
12
+ import { type DirectoryIdentity, type FileIdentity } from "../install-activation";
13
+ export type InstallSourceKind = "standalone" | "source" | "npm-wrapper" | "unknown";
14
+ /**
15
+ * The trust anchor for "this target is the exact binary the current process
16
+ * was dispatched from": a real ELF/PE/Mach-O header on disk proves nothing
17
+ * about ownership by itself. Only the currently-running compiled image's own
18
+ * resolved path counts. Injectable so tests can simulate a compiled dispatch
19
+ * without spawning a real binary.
20
+ */
21
+ export interface InstallDispatchAuthority {
22
+ readonly compiled: boolean;
23
+ /** Realpath of the currently dispatched compiled image (process.execPath). */
24
+ readonly selfPath: string;
25
+ readonly version: string;
26
+ }
27
+ export declare function currentInstallDispatchAuthority(): InstallDispatchAuthority;
28
+ export interface InstallRestoreDescriptorV1 {
29
+ readonly schemaVersion: 1;
30
+ readonly kind: "install.restore-binary";
31
+ readonly targetPath: string;
32
+ readonly channel: string;
33
+ readonly version: string;
34
+ readonly ref?: string;
35
+ readonly owned: boolean;
36
+ readonly sourceKind: InstallSourceKind;
37
+ readonly targetIdentity?: FileIdentity;
38
+ readonly parentIdentity?: DirectoryIdentity;
39
+ readonly targetDigest?: string;
40
+ readonly platform: NodeJS.Platform;
41
+ readonly arch: string;
42
+ readonly writes: false;
43
+ readonly fetch: false;
44
+ readonly execute: false;
45
+ }
46
+ export interface RestoreCandidate {
47
+ readonly ref: string;
48
+ readonly channel: string;
49
+ readonly sha256: string;
50
+ readonly version: string;
51
+ readonly os: NodeJS.Platform;
52
+ readonly arch: string;
53
+ }
54
+ export interface InstallRepairDependencies {
55
+ readonly fetchCandidate: (candidate: RestoreCandidate, stagingPath: string) => Promise<void>;
56
+ readonly verifyCandidate: (stagingPath: string, candidate: RestoreCandidate) => Promise<void>;
57
+ readonly smokeCandidate: (stagingPath: string, candidate: RestoreCandidate) => Promise<void>;
58
+ }
59
+ export type InstallRepairState = "verified" | "not_needed" | "pending_activation" | "blocked" | "conflict" | "failed";
60
+ export interface InstallRepairResult {
61
+ readonly state: InstallRepairState;
62
+ readonly reason?: string;
63
+ readonly recordPath?: string;
64
+ readonly sideEffectStarted: boolean;
65
+ /** Present only for a pre-mutation Windows sharing violation (nothing was renamed). */
66
+ readonly windowsErrorCode?: string;
67
+ readonly before?: {
68
+ readonly identity?: FileIdentity;
69
+ readonly digest?: string;
70
+ };
71
+ readonly after?: {
72
+ readonly identity?: FileIdentity;
73
+ readonly digest?: string;
74
+ readonly version?: string;
75
+ };
76
+ }
77
+ /**
78
+ * Read-only restore preview. Never writes, fetches, or executes anything.
79
+ * Tolerant of any on-disk state: a missing/symlinked/foreign target reports
80
+ * `sourceKind: "unknown"` with `owned: false` rather than throwing, since a
81
+ * dry-run/diagnostic descriptor must never fail on account of the very
82
+ * conditions it exists to report.
83
+ */
84
+ export declare function describeInstallRestore(targetPath: string, authority?: InstallDispatchAuthority, channel?: string, ref?: string): Promise<InstallRestoreDescriptorV1>;
85
+ /**
86
+ * Repair a proven-standalone target by staging, verifying, and promoting a
87
+ * pinned candidate through the shared activation authority.
88
+ *
89
+ * An unresolved transaction is resumed only for the identical explicit pin.
90
+ * Both fresh and resumed publication use the normal updater's mandatory
91
+ * installed verification and identity-bound compensation; no second candidate
92
+ * is activated implicitly.
93
+ */
94
+ export declare function repairStandaloneBinary(targetPath: string, descriptor: InstallRestoreDescriptorV1, candidate: RestoreCandidate, authorizations: readonly string[], deps?: InstallRepairDependencies): Promise<InstallRepairResult>;
@@ -0,0 +1,43 @@
1
+ import type { DoctorJournalAuthority } from "@gajae-code/natives";
2
+ import type { DoctorCheck } from "./types";
3
+ export type DoctorJournalPhase = "created" | "before" | "prepared" | "applying" | "applied_unverified" | "verified" | "failed" | "uncertain";
4
+ export interface DoctorJournalRecord {
5
+ readonly runId: string;
6
+ readonly repairId: string;
7
+ readonly phase: DoctorJournalPhase;
8
+ readonly targetId: string;
9
+ readonly before?: Record<string, unknown>;
10
+ readonly after?: Record<string, unknown>;
11
+ readonly outcome?: string;
12
+ readonly at: string;
13
+ }
14
+ export type DoctorJournalReadStatus = "ok" | "missing" | "malformed" | "unreadable" | "unsupported" | "changed";
15
+ export interface DoctorJournalReadResult {
16
+ readonly status: DoctorJournalReadStatus;
17
+ readonly records: readonly DoctorJournalRecord[];
18
+ readonly malformedLines: readonly number[];
19
+ readonly error?: string;
20
+ }
21
+ export type DoctorReconcileOutcome = "not_applied" | "applied_unverified" | "conflict" | "verified" | "unknown";
22
+ export interface DoctorReconcileEvidence {
23
+ readonly check: DoctorCheck;
24
+ readonly current: Record<string, unknown>;
25
+ }
26
+ export declare class DoctorJournalCreateError extends Error {
27
+ readonly reasonCode: string;
28
+ readonly sideEffectStarted: boolean;
29
+ constructor(reasonCode: string, sideEffectStarted: boolean);
30
+ }
31
+ export declare class DoctorJournal {
32
+ #private;
33
+ readonly path: string;
34
+ constructor(pathname: string, runId: string, native: DoctorJournalAuthority);
35
+ static create(root: string, runId: string): Promise<DoctorJournal>;
36
+ append(input: Omit<DoctorJournalRecord, "runId" | "at">): Promise<void>;
37
+ close(): void;
38
+ static read(pathname: string): Promise<DoctorJournalRecord[]>;
39
+ static readDetailed(pathname: string): Promise<DoctorJournalReadResult>;
40
+ }
41
+ /** Classifies fresh selected-target evidence, never the historical phase by itself. */
42
+ export declare function reconcileDoctorEvidence(record: DoctorJournalRecord, evidence?: DoctorReconcileEvidence): DoctorReconcileOutcome;
43
+ export declare function reconcileDoctorJournal(pathname: string, evidence?: DoctorReconcileEvidence): Promise<DoctorJournalRecord | undefined>;
@@ -0,0 +1,39 @@
1
+ export type ManagedLinkKind = "source" | "wrapper" | "binary";
2
+ export interface ManagedLinkCandidate {
3
+ readonly id: string;
4
+ readonly kind: ManagedLinkKind;
5
+ readonly path: string;
6
+ readonly exists: boolean;
7
+ readonly provenance: "workspace" | "unknown";
8
+ }
9
+ export interface ManagedLinkDescriptor {
10
+ readonly schemaVersion: 1;
11
+ readonly targetId: string;
12
+ readonly alias: string;
13
+ readonly targetPath: string;
14
+ readonly parentPath: string;
15
+ readonly status: "healthy" | "broken" | "foreign" | "unknown";
16
+ readonly receiptTrusted: boolean;
17
+ readonly candidates: readonly ManagedLinkCandidate[];
18
+ readonly reasonCode?: string;
19
+ }
20
+ export interface ManagedLinkRepairRequest {
21
+ readonly targetPath: string;
22
+ readonly alias: string;
23
+ readonly root: string;
24
+ readonly ref: string;
25
+ readonly mode: "dry-run" | "fix";
26
+ readonly allowRisks: readonly string[];
27
+ readonly yes: boolean;
28
+ readonly journalRoot?: string;
29
+ readonly runId?: string;
30
+ }
31
+ export interface ManagedLinkRepairResult {
32
+ readonly state: "planned" | "verified" | "not_needed" | "blocked" | "rolled_back" | "rollback_conflict" | "unsupported" | "failed" | "uncertain";
33
+ readonly changed: boolean;
34
+ readonly sideEffectStarted: boolean;
35
+ readonly reasonCode?: string;
36
+ }
37
+ /** Public values describe candidates; the private map retains the original filesystem authority. */
38
+ export declare function describeManagedLink(targetPath: string, root: string, alias?: string): Promise<ManagedLinkDescriptor>;
39
+ export declare function repairManagedLink(request: ManagedLinkRepairRequest, descriptor: ManagedLinkDescriptor): Promise<ManagedLinkRepairResult>;
@@ -0,0 +1,2 @@
1
+ import type { DoctorProbeReceipt } from "./probe-types";
2
+ export declare function collectNativeProbe(): Promise<DoctorProbeReceipt>;
@@ -0,0 +1,25 @@
1
+ import { type NativeExactFileIdentity, type NativePermissionRepairResult } from "@gajae-code/natives";
2
+ import type { DoctorCheck, DoctorRepair, DoctorScope } from "./types";
3
+ export interface DoctorPermissionRepairRequest {
4
+ readonly filePath: string;
5
+ readonly rootPath: string;
6
+ readonly scope: DoctorScope;
7
+ readonly targetId: string;
8
+ readonly repairId: string;
9
+ readonly runId: string;
10
+ readonly mode: "dry-run" | "fix";
11
+ readonly authorization?: readonly string[];
12
+ readonly journalRoot: string;
13
+ readonly expected: {
14
+ readonly identity: NativeExactFileIdentity;
15
+ readonly mode: number;
16
+ };
17
+ readonly collectAfterChecks: () => Promise<readonly DoctorCheck[]>;
18
+ }
19
+ export interface DoctorPermissionRepairResult {
20
+ readonly repair: DoctorRepair;
21
+ readonly native: NativePermissionRepairResult;
22
+ readonly journalPath?: string;
23
+ readonly afterChecks?: readonly DoctorCheck[];
24
+ }
25
+ export declare function applyDoctorPermissionRepair(r: DoctorPermissionRepairRequest): Promise<DoctorPermissionRepairResult>;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * D7 plugin.quarantine-selected — core-owned durable disable/quarantine writer
3
+ * for exactly one selected (family, scope, name) target, across all three
4
+ * plugin families (GJC bundles, npm packages, marketplace-installed plugins).
5
+ *
6
+ * This module NEVER installs, fetches, reinstalls, imports, or executes
7
+ * plugin code. It only flips the durable "enabled" bit each family's real
8
+ * session-startup consumer already honors:
9
+ * - gjc: GjcPluginRegistryEntry.enabled (readEffectiveRegistryUnpersisted /
10
+ * loadEffectiveGjcPluginRegistry -> session-validation -> activation).
11
+ * - npm (user): gjc-plugins.lock.json PluginRuntimeState.enabled, consumed by
12
+ * getEnabledPlugins() (extensibility/plugins/loader.ts).
13
+ * - npm (project): .gjc/plugin-overrides.json `disabled` list, consumed by the
14
+ * same getEnabledPlugins().
15
+ * - marketplace: installed_plugins.json InstalledPluginEntry.enabled, consumed
16
+ * by listClaudePluginRoots() (discovery/helpers.ts) via
17
+ * `entry.enabled === false` skip.
18
+ *
19
+ * Disable-only: this action never re-enables (D7 has no enable path; an
20
+ * unsafe target requires only plugin-change authorization to quarantine, but
21
+ * re-enabling it is a deliberate separate decision outside this module).
22
+ */
23
+ export type PluginQuarantineFamily = "gjc" | "npm" | "marketplace";
24
+ export interface PluginQuarantineTarget {
25
+ family: PluginQuarantineFamily;
26
+ scope: "user" | "project";
27
+ name: string;
28
+ }
29
+ export interface PluginQuarantineRequest extends PluginQuarantineTarget {
30
+ /** Absolute project cwd; required for gjc/npm project-scope targets. */
31
+ cwd: string;
32
+ /** Home identity used for the marketplace startup-filter reread. */
33
+ home: string;
34
+ /** Explicit override for the marketplace installed_plugins.json path (tests). */
35
+ registryPath?: string;
36
+ /** Journal identity — required by applyPluginQuarantine, ignored by preview. */
37
+ journalRoot?: string;
38
+ runId?: string;
39
+ rootId: string;
40
+ }
41
+ export type PluginQuarantineBlockReason = "invalid_target" | "not_installed" | "unsafe_link" | "registry_unreadable" | "malformed_registry" | "identity_mismatch";
42
+ export interface PluginQuarantinePlan {
43
+ target: PluginQuarantineTarget;
44
+ targetId?: string;
45
+ enabled: boolean;
46
+ baseline: string;
47
+ status: "ready" | "not_needed" | "blocked";
48
+ reason?: PluginQuarantineBlockReason;
49
+ }
50
+ export type PluginQuarantineApplyStatus = "verified" | "not_needed" | "conflict" | "blocked" | "uncertain";
51
+ export interface PluginQuarantineApplyResult {
52
+ status: PluginQuarantineApplyStatus;
53
+ reason?: string;
54
+ /** True once any durable mutation attempt started (journal `applying` appended). */
55
+ sideEffectStarted: boolean;
56
+ /** Fresh post-commit startup-filter observation for the selected target only. */
57
+ targetExcludedFromStartup?: boolean;
58
+ journalPath?: string;
59
+ }
60
+ /**
61
+ * Read-only preview: resolves the exact family writer's current durable
62
+ * enablement state and CAS baseline for one (family, scope, name) target.
63
+ * Never imports, fetches, or executes plugin code, and performs no writes.
64
+ */
65
+ export declare function previewPluginQuarantine(input: PluginQuarantineRequest): Promise<PluginQuarantinePlan>;
66
+ /**
67
+ * Mutating action. Authorization is checked before any risk evaluation, lock
68
+ * acquisition, or journal access — an unauthorized caller learns nothing
69
+ * beyond "authorization required" and causes zero side effects. D7 is
70
+ * disable-only: `enabled: true` is never accepted here.
71
+ *
72
+ * Runs the canonical create -> before -> applying -> verified|failed -> close
73
+ * journal cycle (one journal per run, `plugin.quarantine-selected` selection),
74
+ * then independently re-reads the real startup consumer for the selected
75
+ * target only before reporting `verified` (never a fabricated generic ready).
76
+ */
77
+ export declare function applyPluginQuarantine(input: PluginQuarantineRequest, authorizations: readonly string[], expected: PluginQuarantinePlan): Promise<PluginQuarantineApplyResult>;
@@ -0,0 +1,40 @@
1
+ import type { GjcBundleIdentity, GjcLifecycleResult, GjcUpdateApplyResult, LocalRestorePlanV1, ReviewedRestoreTokenV1 } from "../../extensibility/gjc-plugins/types";
2
+ import type { MarketplaceManager, MarketplaceRestoreApplyResult, MarketplaceRestorePlanV1, MarketplaceReviewedRestoreTokenV1 } from "../../extensibility/plugins/marketplace/manager";
3
+ export interface PluginRestoreTargetV1 {
4
+ identity: GjcBundleIdentity;
5
+ cwd: string;
6
+ }
7
+ export type PluginRestoreActionV1 = {
8
+ kind: "preview";
9
+ target: PluginRestoreTargetV1;
10
+ } | {
11
+ kind: "authorize";
12
+ target: PluginRestoreTargetV1;
13
+ plan: LocalRestorePlanV1;
14
+ authorizations: readonly string[];
15
+ } | {
16
+ kind: "apply";
17
+ target: PluginRestoreTargetV1;
18
+ token: ReviewedRestoreTokenV1;
19
+ } | {
20
+ kind: "marketplace-preview";
21
+ manager: MarketplaceManager;
22
+ pluginId: string;
23
+ scope: "user" | "project";
24
+ } | {
25
+ kind: "marketplace-authorize";
26
+ manager: MarketplaceManager;
27
+ plan: MarketplaceRestorePlanV1;
28
+ authorizations: readonly string[];
29
+ } | {
30
+ kind: "marketplace-apply";
31
+ manager: MarketplaceManager;
32
+ token: MarketplaceReviewedRestoreTokenV1;
33
+ };
34
+ /**
35
+ * Typed doctor dispatch surface for both restore lanes (GJC bundles and
36
+ * proven-private marketplace plugins). Every branch is action + explicit
37
+ * authorization before any effect; `action` alone never authorizes a write.
38
+ */
39
+ export type PluginRestoreActionResultV1 = GjcLifecycleResult<LocalRestorePlanV1 | ReviewedRestoreTokenV1 | GjcUpdateApplyResult> | MarketplaceRestorePlanV1 | MarketplaceReviewedRestoreTokenV1 | MarketplaceRestoreApplyResult;
40
+ export declare function runPluginRestoreAction(action: PluginRestoreActionV1): Promise<PluginRestoreActionResultV1>;
@@ -0,0 +1,11 @@
1
+ import { MarketplaceManager } from "../../extensibility/plugins/marketplace/index.js";
2
+ import type { DoctorContext } from "./context";
3
+ import type { DoctorCheck } from "./types";
4
+ /**
5
+ * Construct the marketplace manager exactly as the ordinary plugin CLI does, so
6
+ * doctor reads and repairs the same canonical registries and cache roots the
7
+ * product itself owns. Never a doctor-private layout.
8
+ */
9
+ export declare function createDoctorMarketplaceManager(cwd: string): Promise<MarketplaceManager>;
10
+ /** Inventory only: registry data is read, never source-resolved or executed. */
11
+ export declare function collectPluginTargets(context: DoctorContext): Promise<DoctorCheck[]>;
@@ -0,0 +1,9 @@
1
+ import type { DoctorContext } from "./context";
2
+ import type { DoctorProbeKind, DoctorProbeReceipt } from "./probe-types";
3
+ export interface DoctorProbeResult {
4
+ readonly status: "completed" | "failed" | "timeout" | "cancelled";
5
+ readonly reasonCode: string;
6
+ readonly receipt?: DoctorProbeReceipt;
7
+ }
8
+ /** Run a bounded child of the current product runtime, never a PATH-discovered executable. */
9
+ export declare function collectDoctorProbe(context: DoctorContext, kind: DoctorProbeKind): Promise<DoctorProbeResult>;
@@ -0,0 +1,18 @@
1
+ import type { DoctorCheck } from "./types";
2
+ /** Maximum UTF-8 payload accepted by the doctor probe transport. */
3
+ export declare const PROBE_OUTPUT_LIMIT_BYTES: number;
4
+ /**
5
+ * Producer-side budget for a projection receipt. Kept below the transport limit
6
+ * so the probe never has to discard a whole surface: the producer sheds its own
7
+ * lowest-value item checks instead. The headroom covers the trailing newline
8
+ * and transport framing.
9
+ */
10
+ export declare const PROJECTION_RECEIPT_BUDGET_BYTES: number;
11
+ export type DoctorProbeKind = "native" | "projection";
12
+ export interface DoctorProbeReceipt {
13
+ readonly schemaVersion: 1;
14
+ readonly kind: DoctorProbeKind;
15
+ readonly status: "completed" | "failed";
16
+ readonly reasonCode: string;
17
+ readonly checks: readonly DoctorCheck[];
18
+ }
@@ -0,0 +1,3 @@
1
+ import type { DoctorProbeKind } from "./probe-types";
2
+ /** Only the fixed product probes are executable; no caller-provided program or module path. */
3
+ export declare function runDoctorProbe(kind: DoctorProbeKind): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { DoctorProbeReceipt } from "./probe-types";
2
+ export declare function collectProjectionProbe(): Promise<DoctorProbeReceipt>;
@@ -0,0 +1,28 @@
1
+ import { type DoctorAction } from "./args";
2
+ import type { DoctorContext } from "./context";
3
+ import type { DoctorCheck, DoctorRepair } from "./types";
4
+ export interface DoctorSelectedRepairResult {
5
+ readonly repair: DoctorRepair;
6
+ readonly invocationError?: string;
7
+ readonly afterChecks?: readonly DoctorCheck[];
8
+ }
9
+ /**
10
+ * Whether this host can run the journal-fenced repair lanes at all. Only Linux
11
+ * and macOS carry the native journal implementation, so a journal-backed action
12
+ * is refused before planning/effect on every other platform.
13
+ */
14
+ export declare function journalRepairSupported(action: DoctorAction, platform?: NodeJS.Platform): boolean;
15
+ /**
16
+ * Refuse the selected action because the diagnosis it would be planned against
17
+ * never settled.
18
+ *
19
+ * A collector that lost its timeout race is not stopped — it keeps running and
20
+ * keeps writing into the shared {@link DoctorContext}. Planning there would read
21
+ * a half-populated target map, so the action is refused before
22
+ * {@link planSelectedDoctorRepair} ever touches that state. Diagnosis output is
23
+ * unaffected: it still reports everything that was collected.
24
+ */
25
+ export declare function refuseUnsettledDoctorRepair(context: DoctorContext, before: readonly DoctorCheck[]): DoctorRepair | undefined;
26
+ /** Plan data is descriptive only; no domain module, lock, journal, or candidate is materialized here. */
27
+ export declare function planSelectedDoctorRepair(context: DoctorContext, before: readonly DoctorCheck[]): DoctorRepair | undefined;
28
+ export declare function executeSelectedDoctorRepair(context: DoctorContext, runId: string, plan: DoctorRepair, collectAfterChecks: () => Promise<readonly DoctorCheck[]>): Promise<DoctorSelectedRepairResult>;
@@ -0,0 +1,27 @@
1
+ import type { DoctorCheck, DoctorMode, DoctorRepair, DoctorReport } from "./types";
2
+ export declare const DOCTOR_EXIT_CODES: {
3
+ readonly ok: 0;
4
+ readonly findings: 1;
5
+ readonly usage: 2;
6
+ readonly incomplete: 3;
7
+ readonly mutationFailure: 4;
8
+ readonly interrupted: 130;
9
+ };
10
+ export interface FinalizeInput {
11
+ readonly schemaVersion?: 1;
12
+ readonly runId: string;
13
+ readonly mode: DoctorMode;
14
+ readonly generatedAt: string;
15
+ readonly durationMs: number;
16
+ readonly subject: DoctorReport["subject"];
17
+ readonly selection: DoctorReport["selection"];
18
+ readonly coverage: DoctorReport["coverage"];
19
+ readonly checks: readonly DoctorCheck[];
20
+ readonly repairs?: readonly DoctorRepair[];
21
+ readonly limits?: DoctorReport["limits"];
22
+ readonly invocationError?: string;
23
+ readonly interrupted?: boolean;
24
+ }
25
+ export declare function finalizeReport(input: FinalizeInput): DoctorReport;
26
+ export declare function renderDoctorJson(report: DoctorReport): string;
27
+ export declare function renderDoctorText(report: DoctorReport): string;
@@ -0,0 +1,4 @@
1
+ import type { DoctorOptions } from "./args";
2
+ import type { DoctorReport } from "./types";
3
+ /** Diagnose first; only a resolved, authorized single action can enter its domain transaction. */
4
+ export declare function collectDoctorReport(options: DoctorOptions): Promise<DoctorReport>;
@@ -0,0 +1,10 @@
1
+ export interface DoctorSafetyResult {
2
+ readonly safe: boolean;
3
+ readonly reasonCode?: string;
4
+ readonly platform?: string;
5
+ }
6
+ export interface DoctorExpectedIdentity {
7
+ readonly dev: bigint;
8
+ readonly ino: bigint;
9
+ }
10
+ export declare function authorizePosixConfigPermission(filePath: string, expected?: DoctorExpectedIdentity): Promise<DoctorSafetyResult>;
@@ -0,0 +1,8 @@
1
+ import type { DoctorContext, DoctorServiceTarget } from "./context";
2
+ import type { DoctorCheck, DoctorRepair } from "./types";
3
+ export interface DoctorStaleArtifactResult {
4
+ readonly repair: DoctorRepair;
5
+ readonly afterChecks?: readonly DoctorCheck[];
6
+ }
7
+ /** One canonical stale slot, retained in quarantine; never starts or signals a service. */
8
+ export declare function applyDoctorStaleArtifact(context: DoctorContext, runId: string, target: DoctorServiceTarget, collectAfterChecks: () => Promise<readonly DoctorCheck[]>): Promise<DoctorStaleArtifactResult>;
@@ -0,0 +1,41 @@
1
+ import type { NativeExactFileIdentity } from "@gajae-code/natives";
2
+ import type { DoctorContext } from "./context";
3
+ import { type DoctorFileObservation } from "./files";
4
+ import type { DoctorCheck } from "./types";
5
+ export declare const DOCTOR_SERVICES: readonly ["broker", "telegram", "discord", "slack"];
6
+ export type DoctorServiceKind = (typeof DOCTOR_SERVICES)[number];
7
+ export type DoctorArtifactSlot = "discovery" | "owner-lock" | "startup-marker";
8
+ export interface DoctorServicePaths {
9
+ readonly state: string;
10
+ readonly owner: string;
11
+ readonly restartIntent: string;
12
+ readonly directoryOwner?: string;
13
+ readonly startupMarker?: string;
14
+ }
15
+ export interface DoctorDirectoryObservation {
16
+ readonly status: "directory";
17
+ readonly mode: number;
18
+ readonly owner: number;
19
+ readonly exactIdentity: NativeExactFileIdentity;
20
+ }
21
+ export type DoctorArtifactObservation = DoctorFileObservation | DoctorDirectoryObservation;
22
+ export interface DoctorServiceObservation {
23
+ readonly service: DoctorServiceKind;
24
+ readonly paths: DoctorServicePaths;
25
+ readonly state: DoctorFileObservation;
26
+ readonly owner: DoctorFileObservation;
27
+ readonly restartIntent: DoctorFileObservation;
28
+ readonly directoryOwner?: DoctorArtifactObservation;
29
+ readonly startupMarker?: DoctorFileObservation;
30
+ readonly ownerMarker?: {
31
+ readonly path: string;
32
+ readonly observation: DoctorFileObservation;
33
+ };
34
+ }
35
+ /** Only product-defined paths are addressable; record content never supplies a path. */
36
+ export declare function doctorServicePaths(agentDir: string, service: DoctorServiceKind): DoctorServicePaths;
37
+ export declare function parseServiceRecord(observation: DoctorFileObservation): Record<string, unknown> | undefined;
38
+ export declare function readDoctorService(root: string, service: DoctorServiceKind): Promise<DoctorServiceObservation>;
39
+ export declare function serviceArtifactObservation(service: DoctorServiceObservation, slot: DoctorArtifactSlot): DoctorArtifactObservation | undefined;
40
+ /** Metadata only: no service import, connection, process probe, or ownership acquisition. */
41
+ export declare function collectServiceTargets(context: DoctorContext): Promise<DoctorCheck[]>;