@adhdev/daemon-core 0.9.82-rc.31 → 0.9.82-rc.310

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 (293) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +8 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/build-info.d.ts +37 -0
  4. package/dist/chat/source-machine.d.ts +166 -0
  5. package/dist/chat/source-resolver.d.ts +104 -0
  6. package/dist/chat/subscription-updates.d.ts +1 -0
  7. package/dist/cli-adapter-types.d.ts +23 -2
  8. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  9. package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
  10. package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
  11. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  12. package/dist/cli-adapters/provider-cli-shared.d.ts +38 -0
  13. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  14. package/dist/cli-adapters/resolve-executable.d.ts +14 -0
  15. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
  16. package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
  17. package/dist/cli-adapters/terminal-screen.d.ts +4 -11
  18. package/dist/commands/cli-manager.d.ts +2 -1
  19. package/dist/commands/handler.d.ts +110 -0
  20. package/dist/commands/mesh-coordinator.d.ts +85 -1
  21. package/dist/commands/router.d.ts +210 -1
  22. package/dist/config/chat-history.d.ts +9 -0
  23. package/dist/config/config.d.ts +5 -0
  24. package/dist/config/mesh-config.d.ts +72 -1
  25. package/dist/git/git-commands.d.ts +9 -1
  26. package/dist/git/git-diff.d.ts +6 -0
  27. package/dist/git/git-executor.d.ts +11 -0
  28. package/dist/git/git-status.d.ts +9 -0
  29. package/dist/git/git-types.d.ts +2 -50
  30. package/dist/index.d.ts +51 -12
  31. package/dist/index.js +38320 -16024
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +38009 -15817
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/installer.d.ts +1 -4
  36. package/dist/ipc/local-ipc-server.d.ts +91 -0
  37. package/dist/launch.d.ts +1 -1
  38. package/dist/logging/async-batch-writer.d.ts +10 -0
  39. package/dist/mesh/contracts.d.ts +164 -0
  40. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  41. package/dist/mesh/coordinator-registry.d.ts +59 -0
  42. package/dist/mesh/mesh-active-work.d.ts +108 -0
  43. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  44. package/dist/mesh/mesh-events-coordinator.d.ts +138 -0
  45. package/dist/mesh/mesh-events-pending.d.ts +45 -0
  46. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  47. package/dist/mesh/mesh-events-utils.d.ts +47 -0
  48. package/dist/mesh/mesh-events.d.ts +6 -49
  49. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  50. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  51. package/dist/mesh/mesh-init.d.ts +86 -0
  52. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  53. package/dist/mesh/mesh-ledger.d.ts +77 -1
  54. package/dist/mesh/mesh-missions.d.ts +116 -0
  55. package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
  56. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  57. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  58. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  59. package/dist/mesh/mesh-routing.d.ts +70 -0
  60. package/dist/mesh/mesh-runtime-store.d.ts +377 -0
  61. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  62. package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
  63. package/dist/mesh/mesh-work-queue.d.ts +181 -5
  64. package/dist/mesh/preview-freshness.d.ts +18 -0
  65. package/dist/mesh/refine-config.d.ts +215 -0
  66. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  67. package/dist/providers/acp-provider-instance.d.ts +2 -0
  68. package/dist/providers/approval-utils.d.ts +13 -0
  69. package/dist/providers/cli-provider-instance.d.ts +61 -3
  70. package/dist/providers/contracts.d.ts +130 -6
  71. package/dist/providers/external-sources.d.ts +71 -0
  72. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  73. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  74. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  75. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  76. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  77. package/dist/providers/native-history/index.d.ts +13 -0
  78. package/dist/providers/provider-instance-manager.d.ts +13 -0
  79. package/dist/providers/provider-instance.d.ts +13 -1
  80. package/dist/providers/provider-loader.d.ts +26 -4
  81. package/dist/providers/provider-trust.d.ts +31 -0
  82. package/dist/providers/read-chat-contract.d.ts +29 -0
  83. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  84. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  85. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  86. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  87. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  88. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  89. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  90. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  91. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  92. package/dist/providers/sdk/v1/index.d.ts +30 -0
  93. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  94. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  95. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  96. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  97. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  98. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  99. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  100. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  101. package/dist/providers/spec/adapter.d.ts +59 -0
  102. package/dist/providers/spec/cli-adapter.d.ts +186 -0
  103. package/dist/providers/spec/evaluator.d.ts +23 -0
  104. package/dist/providers/spec/fsm-driver.d.ts +278 -0
  105. package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
  106. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  107. package/dist/providers/spec/fsm-types.d.ts +128 -0
  108. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  109. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  110. package/dist/providers/spec/route.d.ts +4 -0
  111. package/dist/providers/spec/types.d.ts +144 -0
  112. package/dist/providers/transcript-v2.d.ts +176 -0
  113. package/dist/providers/types/interactive-prompt.d.ts +84 -0
  114. package/dist/repo-mesh-types.d.ts +203 -13
  115. package/dist/sessions/registry.d.ts +6 -0
  116. package/dist/shared-types-extra.d.ts +2 -4
  117. package/dist/shared-types.d.ts +42 -1
  118. package/dist/status/normalize.d.ts +1 -1
  119. package/dist/status/normalize.js +1 -0
  120. package/dist/status/normalize.js.map +1 -1
  121. package/dist/status/normalize.mjs +1 -0
  122. package/dist/status/normalize.mjs.map +1 -1
  123. package/dist/status/reporter.d.ts +2 -0
  124. package/dist/status/snapshot.d.ts +1 -0
  125. package/dist/types.d.ts +5 -0
  126. package/package.json +7 -3
  127. package/src/agent-stream/poller.ts +2 -3
  128. package/src/boot/daemon-lifecycle.ts +55 -12
  129. package/src/boot/process-hardening.ts +89 -0
  130. package/src/build-info.ts +73 -0
  131. package/src/chat/source-machine.ts +534 -0
  132. package/src/chat/source-resolver.ts +0 -0
  133. package/src/chat/subscription-updates.ts +20 -1
  134. package/src/cli-adapter-types.d.ts +1 -0
  135. package/src/cli-adapter-types.ts +22 -2
  136. package/src/cli-adapters/cli-script-runner.ts +421 -0
  137. package/src/cli-adapters/cli-state-engine.ts +1215 -0
  138. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  139. package/src/cli-adapters/provider-cli-adapter.ts +674 -1139
  140. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  141. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  142. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  143. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  144. package/src/cli-adapters/provider-cli-shared.ts +68 -11
  145. package/src/cli-adapters/pty-transport.ts +2 -1
  146. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  147. package/src/cli-adapters/resolve-executable.ts +45 -0
  148. package/src/cli-adapters/session-host-transport.ts +2 -1
  149. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -29
  150. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  151. package/src/cli-adapters/terminal-screen.ts +16 -81
  152. package/src/commands/chat-commands.ts +1813 -60
  153. package/src/commands/cli-manager.ts +286 -14
  154. package/src/commands/handler.ts +809 -2
  155. package/src/commands/mesh-coordinator.ts +332 -122
  156. package/src/commands/router.ts +5911 -595
  157. package/src/commands/upgrade-helper.ts +29 -0
  158. package/src/config/chat-history.ts +474 -24
  159. package/src/config/config.ts +12 -0
  160. package/src/config/mesh-config.ts +303 -3
  161. package/src/config/recent-activity.ts +8 -2
  162. package/src/daemon/dev-auto-implement.ts +3 -2
  163. package/src/daemon/dev-cli-debug.ts +10 -1
  164. package/src/detection/ide-detector.ts +26 -16
  165. package/src/git/git-commands.ts +42 -12
  166. package/src/git/git-diff.ts +53 -0
  167. package/src/git/git-executor.ts +12 -0
  168. package/src/git/git-status.ts +302 -18
  169. package/src/git/git-types.ts +14 -62
  170. package/src/git/git-worktree.ts +8 -1
  171. package/src/index.ts +131 -11
  172. package/src/installer.d.ts +1 -1
  173. package/src/installer.ts +8 -6
  174. package/src/ipc/local-ipc-server.ts +278 -0
  175. package/src/launch.d.ts +1 -1
  176. package/src/launch.ts +37 -28
  177. package/src/logging/async-batch-writer.ts +55 -0
  178. package/src/logging/logger.ts +2 -1
  179. package/src/mesh/contracts.ts +329 -0
  180. package/src/mesh/coordinator-prompt.ts +234 -31
  181. package/src/mesh/coordinator-registry.ts +121 -0
  182. package/src/mesh/mesh-active-work.ts +469 -0
  183. package/src/mesh/mesh-delivery-policy.ts +315 -0
  184. package/src/mesh/mesh-events-coordinator.ts +1786 -0
  185. package/src/mesh/mesh-events-pending.ts +508 -0
  186. package/src/mesh/mesh-events-stale.ts +290 -0
  187. package/src/mesh/mesh-events-utils.ts +254 -0
  188. package/src/mesh/mesh-events.ts +30 -1035
  189. package/src/mesh/mesh-fast-forward.ts +839 -0
  190. package/src/mesh/mesh-host-ownership.ts +73 -0
  191. package/src/mesh/mesh-init.ts +260 -0
  192. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  193. package/src/mesh/mesh-ledger.ts +589 -102
  194. package/src/mesh/mesh-missions.ts +248 -0
  195. package/src/mesh/mesh-reconcile-loop.ts +466 -0
  196. package/src/mesh/mesh-refine-batch.ts +197 -0
  197. package/src/mesh/mesh-refine-status.ts +231 -0
  198. package/src/mesh/mesh-review-inbox.ts +307 -0
  199. package/src/mesh/mesh-routing.ts +291 -0
  200. package/src/mesh/mesh-runtime-store.ts +1513 -0
  201. package/src/mesh/mesh-task-stats.ts +154 -0
  202. package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
  203. package/src/mesh/mesh-work-queue.ts +604 -145
  204. package/src/mesh/preview-freshness.ts +118 -0
  205. package/src/mesh/refine-config.ts +403 -0
  206. package/src/mesh/worktree-bootstrap-config.ts +326 -0
  207. package/src/providers/acp-provider-instance.ts +15 -1
  208. package/src/providers/approval-utils.d.ts +4 -0
  209. package/src/providers/approval-utils.ts +47 -5
  210. package/src/providers/chat-message-normalization.ts +4 -11
  211. package/src/providers/cli-provider-instance.ts +953 -87
  212. package/src/providers/contracts.d.ts +55 -0
  213. package/src/providers/contracts.ts +141 -6
  214. package/src/providers/extension-provider-instance.ts +5 -1
  215. package/src/providers/external-sources.ts +218 -0
  216. package/src/providers/ide-provider-instance.ts +25 -6
  217. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  218. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  219. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  220. package/src/providers/native-history/dispatcher.ts +340 -0
  221. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  222. package/src/providers/native-history/index.ts +30 -0
  223. package/src/providers/provider-instance-manager.ts +30 -0
  224. package/src/providers/provider-instance.ts +10 -1
  225. package/src/providers/provider-loader.ts +584 -50
  226. package/src/providers/provider-schema.ts +87 -14
  227. package/src/providers/provider-trust.ts +114 -0
  228. package/src/providers/read-chat-contract.ts +76 -16
  229. package/src/providers/sdk/README.md +49 -0
  230. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  231. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  232. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  233. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  234. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  235. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  236. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  237. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  238. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  239. package/src/providers/sdk/v1/index.ts +152 -0
  240. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  241. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  242. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  243. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  244. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  245. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  246. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  247. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  248. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  249. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  250. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  251. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  252. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  253. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  254. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  255. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  256. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  257. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  258. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  259. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  260. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  261. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  262. package/src/providers/sdk/v1/validators/index.ts +19 -0
  263. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  264. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  265. package/src/providers/spec/adapter.ts +155 -0
  266. package/src/providers/spec/cli-adapter.ts +838 -0
  267. package/src/providers/spec/evaluator.ts +345 -0
  268. package/src/providers/spec/fsm-driver.ts +875 -0
  269. package/src/providers/spec/fsm-evaluator.ts +255 -0
  270. package/src/providers/spec/fsm-loader.ts +112 -0
  271. package/src/providers/spec/fsm-types.ts +222 -0
  272. package/src/providers/spec/native-history-executor.ts +943 -0
  273. package/src/providers/spec/pre-launch-trust.ts +104 -0
  274. package/src/providers/spec/route.ts +51 -0
  275. package/src/providers/spec/types.ts +189 -0
  276. package/src/providers/transcript-v2.ts +567 -0
  277. package/src/providers/types/interactive-prompt.ts +536 -0
  278. package/src/providers/version-archive.ts +38 -20
  279. package/src/repo-mesh-types.ts +257 -13
  280. package/src/sessions/registry.ts +6 -0
  281. package/src/shared-types-extra.ts +2 -4
  282. package/src/shared-types.ts +45 -1
  283. package/src/status/builders.ts +26 -6
  284. package/src/status/normalize.ts +2 -0
  285. package/src/status/reporter.ts +15 -0
  286. package/src/status/snapshot.ts +84 -25
  287. package/src/system/host-memory.ts +29 -12
  288. package/src/types.ts +5 -0
  289. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  290. package/dist/mesh/mesh-sync.d.ts +0 -53
  291. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  292. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  293. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,536 @@
1
+ export interface InteractivePrompt {
2
+ promptId: string;
3
+ origin: 'cli' | 'mcp' | 'agent';
4
+ providerType: string;
5
+ createdAt: number;
6
+ questions: InteractiveQuestion[];
7
+ }
8
+
9
+ export interface InteractiveQuestion {
10
+ questionId: string;
11
+ question: string;
12
+ header?: string;
13
+ multiSelect: boolean;
14
+ options: InteractiveOption[];
15
+ allowFreeform?: boolean;
16
+ }
17
+
18
+ export interface InteractiveOption {
19
+ label: string;
20
+ description?: string;
21
+ preview?: string;
22
+ }
23
+
24
+ export interface InteractivePromptResponse {
25
+ promptId: string;
26
+ answers: Record<string, InteractiveAnswer>;
27
+ }
28
+
29
+ export interface InteractiveAnswer {
30
+ selectedLabels: string[];
31
+ freeformText?: string;
32
+ }
33
+
34
+ function readString(value: unknown): string | undefined {
35
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
36
+ }
37
+
38
+ function readStringArray(value: unknown): string[] {
39
+ return Array.isArray(value)
40
+ ? value.map((item) => readString(item)).filter((item): item is string => !!item)
41
+ : [];
42
+ }
43
+
44
+ function normalizeOption(raw: unknown): InteractiveOption | null {
45
+ if (typeof raw === 'string') {
46
+ const label = raw.trim();
47
+ return label ? { label } : null;
48
+ }
49
+ if (!raw || typeof raw !== 'object') return null;
50
+ const record = raw as Record<string, unknown>;
51
+ const label = readString(record.label);
52
+ if (!label) return null;
53
+ const description = readString(record.description);
54
+ const preview = readString(record.preview);
55
+ return {
56
+ label,
57
+ ...(description ? { description } : {}),
58
+ ...(preview ? { preview } : {}),
59
+ };
60
+ }
61
+
62
+ function normalizeQuestion(raw: unknown, index: number): InteractiveQuestion | null {
63
+ if (!raw || typeof raw !== 'object') return null;
64
+ const record = raw as Record<string, unknown>;
65
+ const question = readString(record.question);
66
+ if (!question) return null;
67
+ const questionId = readString(record.questionId) || readString(record.id) || `q${index + 1}`;
68
+ const options = Array.isArray(record.options)
69
+ ? record.options.map(normalizeOption).filter((item): item is InteractiveOption => !!item)
70
+ : [];
71
+ const header = readString(record.header);
72
+ return {
73
+ questionId,
74
+ question,
75
+ ...(header ? { header } : {}),
76
+ multiSelect: record.multiSelect === true,
77
+ options,
78
+ ...(record.allowFreeform === true ? { allowFreeform: true } : {}),
79
+ };
80
+ }
81
+
82
+ export function normalizeInteractivePrompt(raw: unknown): InteractivePrompt | null {
83
+ if (!raw || typeof raw !== 'object') return null;
84
+ const record = raw as Record<string, unknown>;
85
+ const promptId = readString(record.promptId);
86
+ const providerType = readString(record.providerType);
87
+ const origin = record.origin === 'mcp' || record.origin === 'agent' ? record.origin : 'cli';
88
+ const questions = Array.isArray(record.questions)
89
+ ? record.questions.map(normalizeQuestion).filter((item): item is InteractiveQuestion => !!item)
90
+ : [];
91
+ if (!promptId || !providerType || questions.length === 0) return null;
92
+ const createdAt = typeof record.createdAt === 'number' && Number.isFinite(record.createdAt)
93
+ ? record.createdAt
94
+ : Date.now();
95
+ return { promptId, origin, providerType, createdAt, questions };
96
+ }
97
+
98
+ export function normalizeInteractivePromptResponse(raw: unknown): InteractivePromptResponse {
99
+ if (!raw || typeof raw !== 'object') throw new Error('Interactive prompt response must be an object');
100
+ const record = raw as Record<string, unknown>;
101
+ const promptId = readString(record.promptId);
102
+ if (!promptId) throw new Error('promptId must be a non-empty string');
103
+ if (!record.answers || typeof record.answers !== 'object' || Array.isArray(record.answers)) {
104
+ throw new Error('answers must be an object');
105
+ }
106
+ const answers: Record<string, InteractiveAnswer> = {};
107
+ for (const [questionId, answerRaw] of Object.entries(record.answers as Record<string, unknown>)) {
108
+ if (!answerRaw || typeof answerRaw !== 'object' || Array.isArray(answerRaw)) continue;
109
+ const answer = answerRaw as Record<string, unknown>;
110
+ const selectedLabels = readStringArray(answer.selectedLabels);
111
+ const freeformText = readString(answer.freeformText);
112
+ answers[questionId] = {
113
+ selectedLabels,
114
+ ...(freeformText ? { freeformText } : {}),
115
+ };
116
+ }
117
+ return { promptId, answers };
118
+ }
119
+
120
+ export function buildClaudeInteractiveToolResult(response: InteractivePromptResponse): string {
121
+ return JSON.stringify({
122
+ type: 'user',
123
+ message: {
124
+ role: 'user',
125
+ content: [{
126
+ type: 'tool_result',
127
+ tool_use_id: response.promptId,
128
+ content: JSON.stringify({ answers: response.answers }),
129
+ is_error: false,
130
+ }],
131
+ },
132
+ });
133
+ }
134
+
135
+ export interface ClaudeInteractiveTuiPage {
136
+ screenText: string;
137
+ header?: string;
138
+ }
139
+
140
+ // Option rows look like "❯ 1. Label". The multi-select picker additionally
141
+ // draws a checkbox marker that can sit before or after the number
142
+ // ("❯ [ ] 1. Label" / "❯ 1. [x] Label" / "☐ 1. Label"); the optional,
143
+ // non-capturing checkbox groups absorb it so the captured label stays clean.
144
+ const CLAUDE_TUI_OPTION_CHECKBOX = '(?:\\[[ xX]\\]|[☐☒◻◼])';
145
+ const CLAUDE_TUI_OPTION_PATTERN = new RegExp(
146
+ `^\\s*(?:[❯›>]\\s*)?(?:${CLAUDE_TUI_OPTION_CHECKBOX}\\s*)?(\\d+)\\.\\s+(?:${CLAUDE_TUI_OPTION_CHECKBOX}\\s*)?(.+?)\\s*$`,
147
+ );
148
+
149
+ function claudeTuiQuestionHeaders(screenText: string): string[] {
150
+ const navLine = screenText.split(/\r?\n/).find(line => line.includes('✔ Submit') && /[☐☒]/.test(line));
151
+ if (!navLine) return [];
152
+ const headers: string[] = [];
153
+ const pattern = /[☐☒]\s+(.+?)(?=\s+[☐☒]|\s+✔\s+Submit)/g;
154
+ for (const match of navLine.matchAll(pattern)) {
155
+ const header = readString(match[1]);
156
+ if (header) headers.push(header);
157
+ }
158
+ return headers;
159
+ }
160
+
161
+ function isClaudeTuiSelectFooter(text: string): boolean {
162
+ return /Enter to select/i.test(text) && /Esc to cancel/i.test(text);
163
+ }
164
+
165
+ /**
166
+ * Decide whether a captured claude-cli AskUserQuestion TUI page is multi-select.
167
+ *
168
+ * The original heuristic only matched the footer hint `/Space to select|toggle
169
+ * selections/i`. That string drifts between claude-cli versions, so when it
170
+ * changed the dashboard silently fell back to multiSelect:false and rendered
171
+ * single-select (radio) controls even though the on-screen picker showed
172
+ * checkboxes — the user could not check more than one box. (The CLI's own
173
+ * terminal still rendered `[ ]` correctly because it never depends on this
174
+ * parse.)
175
+ *
176
+ * Make detection robust by ALSO recognising the actual checkbox markers the
177
+ * multi-select picker draws on its option rows (`[ ]` / `[x]` / `☐` / `☒` /
178
+ * `◻` / `◼`). Single-select rows are drawn with a `❯`/number cursor only and
179
+ * carry none of these box glyphs, so their presence is a reliable signal. The
180
+ * broadened footer patterns ("Space to", "toggle", "select multiple") are kept
181
+ * as a secondary signal for layouts that render markers differently.
182
+ */
183
+ export function detectClaudeTuiMultiSelect(screenText: string): boolean {
184
+ if (/Space to (?:select|toggle)|toggle selection|select multiple|select all that apply/i.test(screenText)) {
185
+ return true;
186
+ }
187
+ // A checkbox glyph on a NUMBERED option row only appears in the multi-select
188
+ // picker. The glyph sits EITHER before the number ("❯ [ ] 1. TypeScript" /
189
+ // "☐ 2. Python") OR after it ("❯ 1. [ ] 계란말이" — claude-cli >=2.1's layout).
190
+ // We require the numbered "N." option marker either way so we don't
191
+ // false-positive on the `✔ Submit` nav line (per-question answered-state
192
+ // ☐/☒) or on the headerless variant where the QUESTION line itself begins
193
+ // with `☐ ` (single-select).
194
+ const optionCheckbox = `(?:\\[[ xX]\\]|[☐☒◻◼])`;
195
+ const beforeNumber = new RegExp(`^\\s*(?:[❯›>]\\s*)?${optionCheckbox}\\s*\\d+\\.\\s+\\S`);
196
+ const afterNumber = new RegExp(`^\\s*(?:[❯›>]\\s*)?\\d+\\.\\s*${optionCheckbox}\\s+\\S`);
197
+ for (const line of screenText.split(/\r?\n/)) {
198
+ if (line.includes('✔ Submit')) continue; // header/nav line
199
+ if (beforeNumber.test(line) || afterNumber.test(line)) return true;
200
+ }
201
+ return false;
202
+ }
203
+
204
+ function readClaudeHeaderLine(lines: string[], beforeIndex: number): string | undefined {
205
+ for (let i = beforeIndex; i >= 0; i -= 1) {
206
+ const candidate = lines[i].trim();
207
+ if (!candidate) continue;
208
+ const match = candidate.match(/^[☐☒]\s+(.+?)\s*$/);
209
+ if (match?.[1]) return readString(match[1]);
210
+ if (/^─+$/.test(candidate)) break;
211
+ }
212
+ return undefined;
213
+ }
214
+
215
+ function readClaudeOptionDescription(lines: string[], optionLineIndex: number): string | undefined {
216
+ const nextLine = lines[optionLineIndex + 1];
217
+ const next = nextLine?.trim();
218
+ if (!next
219
+ || CLAUDE_TUI_OPTION_PATTERN.test(nextLine)
220
+ || /^─+$/.test(next)
221
+ || /^Enter to select\b/i.test(next)
222
+ || /^[☐☒]\s+/.test(next)) {
223
+ return undefined;
224
+ }
225
+ return next;
226
+ }
227
+
228
+ function parseClaudeHeaderlessInteractiveTuiQuestion(page: ClaudeInteractiveTuiPage, index: number): InteractiveQuestion | null {
229
+ if (!isClaudeTuiSelectFooter(page.screenText)) return null;
230
+ if (!/Type something\.?|Chat about this/i.test(page.screenText)) return null;
231
+
232
+ const lines = page.screenText.split(/\r?\n/);
233
+ let footerIndex = -1;
234
+ for (let i = lines.length - 1; i >= 0; i -= 1) {
235
+ if (/Enter to select/i.test(lines[i])) {
236
+ footerIndex = i;
237
+ break;
238
+ }
239
+ }
240
+ if (footerIndex < 0) return null;
241
+
242
+ let optionBlockEnd = footerIndex - 1;
243
+ for (let i = footerIndex - 1; i >= 0; i -= 1) {
244
+ if (/^─+$/.test(lines[i].trim())) {
245
+ optionBlockEnd = i - 1;
246
+ break;
247
+ }
248
+ }
249
+
250
+ const optionLineIndexes: number[] = [];
251
+ for (let i = optionBlockEnd; i >= 0; i -= 1) {
252
+ const line = lines[i];
253
+ if (CLAUDE_TUI_OPTION_PATTERN.test(line)) {
254
+ optionLineIndexes.push(i);
255
+ continue;
256
+ }
257
+ if (optionLineIndexes.length > 0 && (!line.trim() || /^─+$/.test(line.trim()))) break;
258
+ }
259
+ optionLineIndexes.reverse();
260
+ if (optionLineIndexes.length === 0) return null;
261
+
262
+ const firstOptionIndex = optionLineIndexes[0];
263
+ let question = '';
264
+ for (let i = firstOptionIndex - 1; i >= 0; i -= 1) {
265
+ const candidate = lines[i].trim();
266
+ if (!candidate || /^─+$/.test(candidate)) continue;
267
+ // Standalone ☐/☒ markers (decorative section dividers in the headered
268
+ // variant) are not the question — keep skipping them.
269
+ if (/^[☐☒]\s*$/.test(candidate)) continue;
270
+ // The headerless variant introduced in claude-cli >=2.1 prefixes the
271
+ // actual question with `☐ ` (e.g. "☐ RPS R1 1라운드 — …"). Previously
272
+ // we skipped any ☐/☒ line and returned null, never opening the picker.
273
+ // Strip the marker so the dashboard label matches the on-screen text.
274
+ const markerMatch = candidate.match(/^[☐☒]\s+(.+)$/);
275
+ if (markerMatch) {
276
+ question = markerMatch[1].trim();
277
+ break;
278
+ }
279
+ question = candidate;
280
+ break;
281
+ }
282
+ if (!question) return null;
283
+
284
+ const options: InteractiveOption[] = [];
285
+ let allowFreeform = false;
286
+ for (const optionLineIndex of optionLineIndexes) {
287
+ const match = lines[optionLineIndex].match(CLAUDE_TUI_OPTION_PATTERN);
288
+ if (!match) continue;
289
+ const label = match[2].trim();
290
+ if (/^Chat about this$/i.test(label)) continue;
291
+ if (/^Type something\.?$/i.test(label)) allowFreeform = true;
292
+
293
+ const description = readClaudeOptionDescription(lines, optionLineIndex);
294
+ options.push({ label, ...(description ? { description } : {}) });
295
+ }
296
+ if (options.length === 0) return null;
297
+
298
+ const header = readString(page.header) || readClaudeHeaderLine(lines, firstOptionIndex - 1);
299
+ return {
300
+ questionId: `q${index + 1}`,
301
+ question,
302
+ ...(header ? { header } : {}),
303
+ multiSelect: detectClaudeTuiMultiSelect(page.screenText),
304
+ options,
305
+ ...(allowFreeform ? { allowFreeform: true } : {}),
306
+ };
307
+ }
308
+
309
+ function parseClaudeInteractiveTuiQuestion(page: ClaudeInteractiveTuiPage, index: number): InteractiveQuestion | null {
310
+ const lines = page.screenText.split(/\r?\n/);
311
+ let navIndex = -1;
312
+ for (let i = lines.length - 1; i >= 0; i -= 1) {
313
+ if (lines[i].includes('✔ Submit') && /[☐☒]/.test(lines[i])) {
314
+ navIndex = i;
315
+ break;
316
+ }
317
+ }
318
+ if (navIndex < 0) return parseClaudeHeaderlessInteractiveTuiQuestion(page, index);
319
+ if (!page.screenText.includes('Enter to select')) return null;
320
+
321
+ let question = '';
322
+ let questionLineIndex = -1;
323
+ for (let i = navIndex + 1; i < lines.length; i += 1) {
324
+ const candidate = lines[i].trim();
325
+ if (!candidate || /^─+$/.test(candidate)) continue;
326
+ if (candidate === 'Review your answers' || candidate === 'Ready to submit your answers?') return null;
327
+ question = candidate;
328
+ questionLineIndex = i;
329
+ break;
330
+ }
331
+ if (!question) return null;
332
+
333
+ const options: InteractiveOption[] = [];
334
+ let allowFreeform = false;
335
+ for (let i = questionLineIndex + 1; i < lines.length; i += 1) {
336
+ const match = lines[i].match(CLAUDE_TUI_OPTION_PATTERN);
337
+ if (!match) continue;
338
+ const label = match[2].trim();
339
+ if (/^Type something\.?$/i.test(label)) {
340
+ allowFreeform = true;
341
+ continue;
342
+ }
343
+ if (/^Chat about this$/i.test(label)) continue;
344
+
345
+ let description: string | undefined;
346
+ const nextLine = lines[i + 1]?.trim();
347
+ if (nextLine
348
+ && !CLAUDE_TUI_OPTION_PATTERN.test(lines[i + 1])
349
+ && !/^─+$/.test(nextLine)
350
+ && !/^Enter to select\b/.test(nextLine)) {
351
+ description = nextLine;
352
+ }
353
+ options.push({ label, ...(description ? { description } : {}) });
354
+ }
355
+ if (options.length === 0) return null;
356
+
357
+ const header = readString(page.header);
358
+ return {
359
+ questionId: `q${index + 1}`,
360
+ question,
361
+ ...(header ? { header } : {}),
362
+ multiSelect: detectClaudeTuiMultiSelect(page.screenText),
363
+ options,
364
+ ...(allowFreeform ? { allowFreeform: true } : {}),
365
+ };
366
+ }
367
+
368
+ /**
369
+ * Read the question the live claude TUI picker is CURRENTLY focused on, plus
370
+ * whether that focused page renders multi-select checkbox markers.
371
+ *
372
+ * Used to repair a multi-question prompt after the fact: when the daemon
373
+ * Tab-captures pages 2..N it snapshots ~120ms after the Tab keypress, before
374
+ * the newly-focused page's option-row checkbox column has redrawn — so those
375
+ * questions get frozen as multiSelect:false even though the picker is
376
+ * multi-select. Re-reading the focused page on a later status tick (once it has
377
+ * settled) lets us attribute the now-visible glyphs to the matching question
378
+ * and upgrade just that one. Returns null when no picker question is on screen.
379
+ */
380
+ export function readFocusedClaudeTuiQuestion(
381
+ screenText: string,
382
+ ): { question: string; header?: string; multiSelect: boolean } | null {
383
+ if (!screenText.includes('Enter to select')) return null;
384
+ const parsed = parseClaudeInteractiveTuiQuestion({ screenText }, 0);
385
+ if (!parsed) return null;
386
+ return {
387
+ question: parsed.question,
388
+ ...(parsed.header ? { header: parsed.header } : {}),
389
+ multiSelect: parsed.multiSelect,
390
+ };
391
+ }
392
+
393
+ export function detectClaudeAskUserQuestionPromptFromTuiPages(
394
+ pages: ClaudeInteractiveTuiPage[],
395
+ options: { promptId: string; providerType?: string; createdAt?: number },
396
+ ): InteractivePrompt | null {
397
+ if (pages.length === 0) return null;
398
+ const headers = claudeTuiQuestionHeaders(pages[0].screenText);
399
+ const questions = pages.map((page, index) => parseClaudeInteractiveTuiQuestion({
400
+ ...page,
401
+ header: page.header || headers[index],
402
+ }, index)).filter((question): question is InteractiveQuestion => !!question);
403
+ if (questions.length !== pages.length) return null;
404
+ return {
405
+ promptId: options.promptId,
406
+ origin: 'cli',
407
+ providerType: options.providerType || 'claude-cli',
408
+ createdAt: options.createdAt || Date.now(),
409
+ questions,
410
+ };
411
+ }
412
+
413
+ export function buildClaudeInteractiveTuiAnswerSteps(
414
+ prompt: InteractivePrompt,
415
+ response: InteractivePromptResponse,
416
+ ): string[] {
417
+ if (response.promptId !== prompt.promptId) throw new Error('Interactive prompt response does not match active prompt');
418
+ const steps: string[] = [];
419
+ for (const question of prompt.questions) {
420
+ const answer = response.answers[question.questionId];
421
+ if (!answer) throw new Error(`Missing answer for ${question.questionId}`);
422
+ const freeformText = answer.freeformText?.trim() ?? '';
423
+
424
+ // Defensive multi-select fallback: a checkbox picker is the ONLY way an
425
+ // answer can carry more than one selected label, so treat any such answer
426
+ // as multi-select even when `question.multiSelect` was captured as false.
427
+ // This guards the multi-question capture race: pages 2..N can freeze as
428
+ // single-select (their glyph column hadn't redrawn at Tab-snapshot time),
429
+ // and the old single-select branch would then either throw on 2+ checked
430
+ // boxes or emit a bare digit (cursor move, no toggle) for 1 box — silently
431
+ // dropping that page's selection. Keying off the answer's label count makes
432
+ // the keystroke protocol correct regardless of the captured flag.
433
+ const treatAsMultiSelect = question.multiSelect || answer.selectedLabels.length > 1;
434
+
435
+ if (treatAsMultiSelect) {
436
+ // Multi-select: Claude TUI renders each option as a checkbox. The
437
+ // keystroke model here was reverse-engineered live against claude-cli
438
+ // v2.1.170 (do not "simplify" from the screen text — it lies):
439
+ //
440
+ // * A numeric digit key TOGGLES that option's checkbox directly and
441
+ // does NOT move the cursor. So a digit alone checks the option.
442
+ // * Space toggles whatever row the cursor is sitting on (the digit
443
+ // never moved it), so a trailing Space would spuriously toggle the
444
+ // cursor's row (usually option 1) — NEVER pair digit+Space here.
445
+ // * Enter does NOT advance the page; it toggles the cursor's row too.
446
+ // The ONLY key that commits this question and advances (to the next
447
+ // question, or to the final "Review your answers" screen for the
448
+ // last question) is Tab.
449
+ //
450
+ // So: one digit per selected label, then a single Tab to advance.
451
+ const labels = answer.selectedLabels;
452
+ if (labels.length === 0) {
453
+ throw new Error(`Expected at least one selected label for ${question.questionId}`);
454
+ }
455
+ for (const label of labels) {
456
+ const selectedIndex = question.options.findIndex(option => option.label === label);
457
+ if (selectedIndex < 0) throw new Error(`Unknown option for ${question.questionId}: ${label}`);
458
+ steps.push(String(selectedIndex + 1));
459
+ }
460
+ // Tab commits this question's checked set and advances. (Unlike
461
+ // single-select, where the digit auto-advances, a multi-select page
462
+ // stays put under digit input so the user can toggle multiple boxes.)
463
+ steps.push('\t');
464
+ } else if (freeformText) {
465
+ // Freeform: select the "Type something." option (always the last visible
466
+ // option before "Chat about this"), then type the text and confirm.
467
+ const typeOptionIndex = question.options.findIndex(o => /^Type something\.?$/i.test(o.label));
468
+ const optionNumber = typeOptionIndex >= 0 ? typeOptionIndex + 1 : question.options.length;
469
+ steps.push(String(optionNumber));
470
+ // Type the text character by character, then Enter to confirm.
471
+ for (const ch of freeformText) steps.push(ch);
472
+ steps.push('\r');
473
+ } else {
474
+ if (answer.selectedLabels.length !== 1) throw new Error(`Expected one selected label for ${question.questionId}`);
475
+ const selectedIndex = question.options.findIndex(option => option.label === answer.selectedLabels[0]);
476
+ if (selectedIndex < 0) throw new Error(`Unknown option for ${question.questionId}: ${answer.selectedLabels[0]}`);
477
+ // Use numeric key (1-based) to jump directly to the option. This avoids
478
+ // cursor-position drift between questions that arrow-key navigation suffers
479
+ // from — the TUI accepts a digit key to jump straight to that option index.
480
+ steps.push(String(selectedIndex + 1));
481
+ }
482
+ }
483
+ // After all questions are answered, Claude TUI shows a final confirm screen
484
+ // ("Submit answers" / "Cancel"). The first option is pre-selected, so a
485
+ // single Enter confirms and submits.
486
+ steps.push('\r');
487
+ return steps;
488
+ }
489
+
490
+ export function interactivePromptFromClaudeAskUserQuestion(input: unknown, options: {
491
+ promptId: string;
492
+ providerType: string;
493
+ createdAt?: number;
494
+ origin?: InteractivePrompt['origin'];
495
+ }): InteractivePrompt | null {
496
+ if (!input || typeof input !== 'object') return null;
497
+ const record = input as Record<string, unknown>;
498
+ const questions = Array.isArray(record.questions)
499
+ ? record.questions.map(normalizeQuestion).filter((item): item is InteractiveQuestion => !!item)
500
+ : [];
501
+ if (questions.length === 0) return null;
502
+ return {
503
+ promptId: options.promptId,
504
+ origin: options.origin || 'cli',
505
+ providerType: options.providerType,
506
+ createdAt: options.createdAt || Date.now(),
507
+ questions,
508
+ };
509
+ }
510
+
511
+ export function detectClaudeAskUserQuestionPromptFromJson(value: unknown, providerType = 'claude-cli'): InteractivePrompt | null {
512
+ if (!value || typeof value !== 'object') return null;
513
+ const record = value as Record<string, unknown>;
514
+ const blocks: unknown[] = [];
515
+ if (Array.isArray(record.content)) blocks.push(...record.content);
516
+ const message = record.message;
517
+ if (message && typeof message === 'object' && Array.isArray((message as Record<string, unknown>).content)) {
518
+ blocks.push(...((message as Record<string, unknown>).content as unknown[]));
519
+ }
520
+ if (record.type === 'tool_use') blocks.push(record);
521
+
522
+ for (const block of blocks) {
523
+ if (!block || typeof block !== 'object') continue;
524
+ const b = block as Record<string, unknown>;
525
+ const name = readString(b.name);
526
+ if (b.type !== 'tool_use' || name !== 'AskUserQuestion') continue;
527
+ const id = readString(b.id) || readString(record.id) || `ask-user-${Date.now()}`;
528
+ const prompt = interactivePromptFromClaudeAskUserQuestion(b.input, {
529
+ promptId: id,
530
+ providerType,
531
+ origin: 'cli',
532
+ });
533
+ if (prompt) return prompt;
534
+ }
535
+ return null;
536
+ }
@@ -12,7 +12,7 @@
12
12
  import * as fs from 'fs';
13
13
  import * as path from 'path';
14
14
  import * as os from 'os';
15
- import { execSync } from 'child_process';
15
+ // Removed execSync import
16
16
  import { platform } from 'os';
17
17
  import type { ProviderLoader } from './provider-loader.js';
18
18
  import type { ProviderModule } from './contracts.js';
@@ -117,22 +117,40 @@ export class VersionArchive {
117
117
 
118
118
  // ─── Version Detection ──────────────────────────────
119
119
 
120
- function runCommand(cmd: string, timeout = 10000): string | null {
121
- try {
122
- return execSync(cmd, {
120
+ import { exec } from 'child_process';
121
+
122
+ async function runCommand(cmd: string, timeout = 10000): Promise<string | null> {
123
+ return new Promise((resolve) => {
124
+ exec(cmd, {
123
125
  encoding: 'utf-8',
124
126
  timeout,
125
- stdio: ['pipe', 'pipe', 'pipe'],
126
- }).trim();
127
- } catch {
128
- return null;
129
- }
127
+ }, (error, stdout) => {
128
+ if (error) return resolve(null);
129
+ resolve(stdout.trim());
130
+ });
131
+ });
130
132
  }
131
133
 
132
134
  function findBinary(name: string): string | null {
133
- const cmd = platform() === 'win32' ? `where ${name}` : `which ${name}`;
134
- const result = runCommand(cmd, 5000);
135
- return result ? result.split('\n')[0] : null;
135
+ const isWin = platform() === 'win32';
136
+ const paths = (process.env.PATH || '').split(isWin ? ';' : ':');
137
+ const exes = isWin ? ['.exe', '.cmd', '.bat', ''] : [''];
138
+
139
+ for (const p of paths) {
140
+ if (!p) continue;
141
+ for (const ext of exes) {
142
+ const fullPath = path.join(p, name + ext);
143
+ try {
144
+ if (fs.existsSync(fullPath)) {
145
+ const stat = fs.statSync(fullPath);
146
+ if (stat.isFile() && (isWin || (stat.mode & 0o111))) {
147
+ return fullPath;
148
+ }
149
+ }
150
+ } catch { }
151
+ }
152
+ }
153
+ return null;
136
154
  }
137
155
 
138
156
  /** Extract version string from CLI output */
@@ -162,16 +180,16 @@ function getPlatformVersionCommand(
162
180
  return undefined;
163
181
  }
164
182
 
165
- function getVersion(binary: string, versionCommand?: string): string | null {
183
+ async function getVersion(binary: string, versionCommand?: string): Promise<string | null> {
166
184
  // Custom version command from provider.json
167
185
  if (versionCommand) {
168
- const raw = runCommand(versionCommand);
186
+ const raw = await runCommand(versionCommand);
169
187
  return raw ? parseVersion(raw) : null;
170
188
  }
171
189
 
172
190
  // Default: try --version, then -V, then -v
173
191
  for (const flag of ['--version', '-V', '-v']) {
174
- const raw = runCommand(`"${binary}" ${flag}`);
192
+ const raw = await runCommand(`"${binary}" ${flag}`);
175
193
  if (raw && raw.length < 500) return parseVersion(raw);
176
194
  }
177
195
  return null;
@@ -191,11 +209,11 @@ function checkPathExists(paths: string[]): string | null {
191
209
  }
192
210
 
193
211
  /** macOS: Get app version from Info.plist */
194
- function getMacAppVersion(appPath: string): string | null {
212
+ async function getMacAppVersion(appPath: string): Promise<string | null> {
195
213
  if (platform() !== 'darwin' || !appPath.endsWith('.app')) return null;
196
214
  const plistPath = path.join(appPath, 'Contents', 'Info.plist');
197
215
  if (!fs.existsSync(plistPath)) return null;
198
- const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
216
+ const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
199
217
  return raw || null;
200
218
  }
201
219
 
@@ -242,10 +260,10 @@ export async function detectAllVersions(
242
260
 
243
261
  // Version: try CLI first, then plist
244
262
  if (resolvedBin) {
245
- info.version = getVersion(resolvedBin, versionCommand);
263
+ info.version = await getVersion(resolvedBin, versionCommand);
246
264
  }
247
265
  if (!info.version && appPath) {
248
- info.version = getMacAppVersion(appPath);
266
+ info.version = await getMacAppVersion(appPath);
249
267
  }
250
268
 
251
269
  } else if (provider.category === 'cli' || provider.category === 'acp') {
@@ -256,7 +274,7 @@ export async function detectAllVersions(
256
274
  info.binary = binPath || null;
257
275
 
258
276
  if (binPath) {
259
- info.version = getVersion(binPath, versionCommand);
277
+ info.version = await getVersion(binPath, versionCommand);
260
278
  }
261
279
 
262
280
  } else if (provider.category === 'extension') {