omnicell-router 0.7.0 → 0.8.2

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 (246) hide show
  1. package/backend/dist/cli/clients/activity.d.ts +35 -0
  2. package/backend/dist/cli/clients/activity.js +67 -0
  3. package/backend/dist/cli/clients/base.d.ts +13 -2
  4. package/backend/dist/cli/clients/claude.d.ts +2 -2
  5. package/backend/dist/cli/clients/codex.d.ts +2 -2
  6. package/backend/dist/cli/clients/core-adapters.d.ts +3 -4
  7. package/backend/dist/cli/clients/core-adapters.js +3 -4
  8. package/backend/dist/cli/clients/cursor-proxy.d.ts +88 -0
  9. package/backend/dist/cli/clients/cursor-proxy.js +421 -0
  10. package/backend/dist/cli/clients/dsh.d.ts +2 -2
  11. package/backend/dist/cli/clients/grok.d.ts +2 -2
  12. package/backend/dist/cli/clients/index.d.ts +8 -1
  13. package/backend/dist/cli/clients/index.js +55 -21
  14. package/backend/dist/cli/clients/kimi.d.ts +2 -2
  15. package/backend/dist/cli/clients/launcher.d.ts +8 -0
  16. package/backend/dist/cli/clients/model-meta.js +1 -1
  17. package/backend/dist/cli/clients/omp.d.ts +2 -2
  18. package/backend/dist/cli/clients/openclaw.d.ts +2 -2
  19. package/backend/dist/cli/clients/opencode-proxy.d.ts +11 -0
  20. package/backend/dist/cli/clients/opencode-proxy.js +351 -0
  21. package/backend/dist/cli/clients/opencode.d.ts +2 -2
  22. package/backend/dist/cli/clients/pi.d.ts +2 -2
  23. package/backend/dist/cli/clients/plugin-adapters.d.ts +3 -1
  24. package/backend/dist/cli/clients/plugin-adapters.js +6 -29
  25. package/backend/dist/cli/clients/qoder-proxy.d.ts +84 -0
  26. package/backend/dist/cli/clients/qoder-proxy.js +497 -0
  27. package/backend/dist/cli/clients/reserved.d.ts +2 -6
  28. package/backend/dist/cli/clients/reserved.js +2 -0
  29. package/backend/dist/cli/clients/workbuddy.d.ts +2 -2
  30. package/backend/dist/cli/index.js +60 -9
  31. package/backend/dist/cli/types.d.ts +29 -8
  32. package/backend/dist/compression/caveman-prompts.d.ts +1 -1
  33. package/backend/dist/config/comments-en.js +6 -12
  34. package/backend/dist/config/comments-zh.js +6 -12
  35. package/backend/dist/config/defaults.d.ts +56 -1
  36. package/backend/dist/config/defaults.js +68 -0
  37. package/backend/dist/config/index.d.ts +9 -2
  38. package/backend/dist/config/index.js +26 -3
  39. package/backend/dist/config/types.d.ts +55 -43
  40. package/backend/dist/forward-proxy/egress.d.ts +10 -2
  41. package/backend/dist/forward-proxy/egress.js +42 -4
  42. package/backend/dist/forward-proxy/ordered-relay.d.ts +29 -0
  43. package/backend/dist/forward-proxy/ordered-relay.js +46 -0
  44. package/backend/dist/forward-proxy/rules.d.ts +66 -19
  45. package/backend/dist/forward-proxy/rules.js +61 -14
  46. package/backend/dist/forward-proxy/server.js +226 -77
  47. package/backend/dist/forward-proxy/system-proxy.d.ts +42 -2
  48. package/backend/dist/forward-proxy/system-proxy.js +199 -22
  49. package/backend/dist/harness/common/market.d.ts +3 -3
  50. package/backend/dist/harness/host/adapters/amp.d.ts +1 -1
  51. package/backend/dist/harness/host/adapters/antigravity.d.ts +1 -1
  52. package/backend/dist/harness/host/adapters/claude.d.ts +1 -1
  53. package/backend/dist/harness/host/adapters/cline.d.ts +1 -1
  54. package/backend/dist/harness/host/adapters/codex.d.ts +1 -1
  55. package/backend/dist/harness/host/adapters/cursor.d.ts +1 -1
  56. package/backend/dist/harness/host/adapters/dsh.d.ts +2 -2
  57. package/backend/dist/harness/host/adapters/factory.d.ts +1 -1
  58. package/backend/dist/harness/host/adapters/gemini-cli.d.ts +1 -1
  59. package/backend/dist/harness/host/adapters/grok.d.ts +1 -1
  60. package/backend/dist/harness/host/adapters/kimi.d.ts +1 -1
  61. package/backend/dist/harness/host/adapters/omp.d.ts +1 -1
  62. package/backend/dist/harness/host/adapters/openclaw.d.ts +1 -1
  63. package/backend/dist/harness/host/adapters/opencode.d.ts +1 -1
  64. package/backend/dist/harness/host/adapters/pi.d.ts +1 -1
  65. package/backend/dist/harness/host/adapters/universal.d.ts +1 -1
  66. package/backend/dist/harness/host/adapters/windsurf.d.ts +1 -1
  67. package/backend/dist/harness/host/adapters/zed.d.ts +1 -1
  68. package/backend/dist/harness/skill/skills-sh.d.ts +1 -1
  69. package/backend/dist/harness/translation.js +64 -21
  70. package/backend/dist/harness/types.d.ts +1 -1
  71. package/backend/dist/harness/types.js +1 -1
  72. package/backend/dist/index.js +31 -18
  73. package/backend/dist/ir/adapters/anthropic-stream.d.ts +18 -0
  74. package/backend/dist/ir/adapters/anthropic-stream.js +247 -0
  75. package/backend/dist/ir/adapters/anthropic.d.ts +29 -0
  76. package/backend/dist/ir/adapters/anthropic.js +788 -0
  77. package/backend/dist/ir/adapters/chat.d.ts +15 -0
  78. package/backend/dist/ir/adapters/chat.js +602 -0
  79. package/backend/dist/ir/adapters/google-stream.d.ts +22 -0
  80. package/backend/dist/ir/adapters/google-stream.js +242 -0
  81. package/backend/dist/ir/adapters/google.d.ts +9 -0
  82. package/backend/dist/ir/adapters/google.js +317 -0
  83. package/backend/dist/ir/adapters/openai-responses-output.js +8 -5
  84. package/backend/dist/ir/adapters/openai-responses.d.ts +15 -0
  85. package/backend/dist/ir/adapters/openai-responses.js +26 -1
  86. package/backend/dist/ir/adapters/responses-output.d.ts +50 -0
  87. package/backend/dist/ir/adapters/responses-output.js +348 -0
  88. package/backend/dist/ir/adapters/responses-stream.d.ts +12 -0
  89. package/backend/dist/ir/adapters/responses-stream.js +178 -0
  90. package/backend/dist/ir/adapters/responses.d.ts +14 -0
  91. package/backend/dist/ir/adapters/responses.js +646 -0
  92. package/backend/dist/ir/errors.d.ts +2 -2
  93. package/backend/dist/ir/types.d.ts +2 -1
  94. package/backend/dist/metrics/request-cost.d.ts +11 -2
  95. package/backend/dist/metrics/request-cost.js +12 -3
  96. package/backend/dist/observability/request-identity.d.ts +1 -1
  97. package/backend/dist/observability/trace-id.d.ts +40 -0
  98. package/backend/dist/observability/trace-id.js +134 -0
  99. package/backend/dist/observability/upstream-events.d.ts +82 -60
  100. package/backend/dist/observability/upstream-events.js +142 -67
  101. package/backend/dist/opencode/catalog/types.d.ts +9 -0
  102. package/backend/dist/opencode/credentials/types.d.ts +2 -2
  103. package/backend/dist/opencode/probe.d.ts +24 -1
  104. package/backend/dist/opencode/probe.js +28 -4
  105. package/backend/dist/opencode/user-config.d.ts +5 -0
  106. package/backend/dist/pipeline/directives.d.ts +6 -2
  107. package/backend/dist/pipeline/directives.js +7 -3
  108. package/backend/dist/pipeline/orchestrator.d.ts +28 -27
  109. package/backend/dist/pipeline/orchestrator.js +220 -194
  110. package/backend/dist/pipeline/unresolved-model.d.ts +33 -0
  111. package/backend/dist/pipeline/unresolved-model.js +43 -0
  112. package/backend/dist/plugins/catalog-def.d.ts +143 -0
  113. package/backend/dist/plugins/catalog-def.js +177 -0
  114. package/backend/dist/plugins/gateways.d.ts +62 -3
  115. package/backend/dist/plugins/gateways.js +139 -2
  116. package/backend/dist/plugins/host.d.ts +42 -5
  117. package/backend/dist/plugins/host.js +454 -38
  118. package/backend/dist/plugins/manifest.d.ts +119 -10
  119. package/backend/dist/plugins/manifest.js +265 -14
  120. package/backend/dist/plugins/pack.js +26 -0
  121. package/backend/dist/plugins/types.d.ts +187 -21
  122. package/backend/dist/protocols/systemone/convert.d.ts +1 -0
  123. package/backend/dist/protocols/systemone/convert.js +6 -1
  124. package/backend/dist/protocols/systemone/decide.js +18 -8
  125. package/backend/dist/providers/anthropic-messages.d.ts +12 -0
  126. package/backend/dist/providers/anthropic-messages.js +53 -0
  127. package/backend/dist/providers/anthropic.d.ts +7 -8
  128. package/backend/dist/providers/anthropic.js +36 -324
  129. package/backend/dist/providers/base.d.ts +14 -2
  130. package/backend/dist/providers/boot-direct.js +68 -38
  131. package/backend/dist/providers/dispatch.d.ts +5 -19
  132. package/backend/dist/providers/dispatch.js +46 -58
  133. package/backend/dist/providers/executors/anthropic-messages.d.ts +1 -0
  134. package/backend/dist/providers/executors/anthropic-messages.js +3 -0
  135. package/backend/dist/providers/executors/dispatch.d.ts +16 -2
  136. package/backend/dist/providers/executors/dispatch.js +39 -9
  137. package/backend/dist/providers/executors/google-gemini.d.ts +1 -0
  138. package/backend/dist/providers/executors/google-gemini.js +3 -0
  139. package/backend/dist/providers/executors/http-stream.js +16 -3
  140. package/backend/dist/providers/executors/openai-chat.d.ts +1 -0
  141. package/backend/dist/providers/executors/openai-chat.js +3 -0
  142. package/backend/dist/providers/executors/openai-responses.d.ts +1 -0
  143. package/backend/dist/providers/executors/openai-responses.js +3 -0
  144. package/backend/dist/providers/executors/plugin-adapter.js +4 -4
  145. package/backend/dist/providers/google-gemini.d.ts +12 -0
  146. package/backend/dist/providers/google-gemini.js +50 -0
  147. package/backend/dist/providers/google.d.ts +7 -8
  148. package/backend/dist/providers/google.js +35 -308
  149. package/backend/dist/providers/http-json.d.ts +19 -0
  150. package/backend/dist/providers/http-json.js +104 -0
  151. package/backend/dist/providers/http-stream.d.ts +52 -0
  152. package/backend/dist/providers/http-stream.js +423 -0
  153. package/backend/dist/providers/member-match.d.ts +4 -5
  154. package/backend/dist/providers/member-match.js +4 -5
  155. package/backend/dist/providers/openai-chat.d.ts +13 -0
  156. package/backend/dist/providers/openai-chat.js +99 -0
  157. package/backend/dist/providers/openai-compatible.d.ts +7 -4
  158. package/backend/dist/providers/openai-compatible.js +71 -368
  159. package/backend/dist/providers/openai-responses.d.ts +12 -0
  160. package/backend/dist/providers/openai-responses.js +68 -0
  161. package/backend/dist/providers/opencode-proxy.d.ts +5 -5
  162. package/backend/dist/providers/opencode-proxy.js +49 -125
  163. package/backend/dist/providers/plugin-adapter.d.ts +9 -0
  164. package/backend/dist/providers/plugin-adapter.js +31 -0
  165. package/backend/dist/providers/registry.d.ts +49 -24
  166. package/backend/dist/providers/registry.js +97 -55
  167. package/backend/dist/providers/responses.d.ts +7 -28
  168. package/backend/dist/providers/responses.js +45 -253
  169. package/backend/dist/providers/tool-markup-leak.d.ts +41 -0
  170. package/backend/dist/providers/tool-markup-leak.js +57 -0
  171. package/backend/dist/providers/tool-markup-recovery.d.ts +27 -0
  172. package/backend/dist/providers/tool-markup-recovery.js +786 -0
  173. package/backend/dist/providers/virtual-meta.d.ts +21 -2
  174. package/backend/dist/providers/virtual-meta.js +49 -9
  175. package/backend/dist/proxy/asset-download.d.ts +54 -0
  176. package/backend/dist/proxy/asset-download.js +420 -0
  177. package/backend/dist/proxy/manual-node-spec.d.ts +16 -16
  178. package/backend/dist/proxy/mihomo-binary.d.ts +17 -2
  179. package/backend/dist/proxy/mihomo-binary.js +62 -51
  180. package/backend/dist/proxy/mihomo-client.js +15 -1
  181. package/backend/dist/proxy/mihomo-config.js +11 -2
  182. package/backend/dist/proxy/mihomo-geo.d.ts +87 -0
  183. package/backend/dist/proxy/mihomo-geo.js +213 -0
  184. package/backend/dist/proxy/mihomo-logs.d.ts +27 -0
  185. package/backend/dist/proxy/mihomo-logs.js +70 -0
  186. package/backend/dist/proxy/mihomo-pac.d.ts +11 -0
  187. package/backend/dist/proxy/mihomo-pac.js +15 -0
  188. package/backend/dist/proxy/mihomo-rules-import.d.ts +1 -1
  189. package/backend/dist/proxy/mihomo-rules-import.js +7 -7
  190. package/backend/dist/proxy/mihomo-sidecar.d.ts +17 -1
  191. package/backend/dist/proxy/mihomo-sidecar.js +148 -26
  192. package/backend/dist/quota/adapters/minimax.js +36 -13
  193. package/backend/dist/quota/cli-login.d.ts +8 -0
  194. package/backend/dist/quota/cli-login.js +18 -0
  195. package/backend/dist/quota/declarations.js +10 -0
  196. package/backend/dist/quota/dsl.js +18 -5
  197. package/backend/dist/quota/engine.d.ts +22 -1
  198. package/backend/dist/quota/engine.js +170 -29
  199. package/backend/dist/quota/prober.d.ts +5 -0
  200. package/backend/dist/quota/prober.js +11 -2
  201. package/backend/dist/quota/types.d.ts +87 -8
  202. package/backend/dist/quota/verdict.d.ts +35 -0
  203. package/backend/dist/quota/verdict.js +135 -0
  204. package/backend/dist/ratelimit/admission.d.ts +131 -0
  205. package/backend/dist/ratelimit/admission.js +233 -0
  206. package/backend/dist/ratelimit/rate-limiter.js +6 -0
  207. package/backend/dist/resilience/types.d.ts +2 -2
  208. package/backend/dist/router/layer2-decision.d.ts +1 -1
  209. package/backend/dist/router/layer2-decision.js +5 -8
  210. package/backend/dist/routes/console.js +248 -52
  211. package/backend/dist/routes/mihomo.d.ts +2 -0
  212. package/backend/dist/routes/mihomo.js +334 -29
  213. package/backend/dist/routes/responses.d.ts +87 -8
  214. package/backend/dist/routes/responses.js +314 -33
  215. package/backend/dist/server.js +34 -6
  216. package/backend/dist/session/session-manager.d.ts +6 -0
  217. package/backend/dist/session/session-manager.js +20 -9
  218. package/backend/dist/surfaces/chat-pipeline.d.ts +2 -2
  219. package/backend/dist/surfaces/chat-pipeline.js +17 -7
  220. package/backend/dist/surfaces/chat.js +15 -0
  221. package/backend/dist/surfaces/decision-pipeline.js +7 -10
  222. package/backend/dist/surfaces/direct-forward.d.ts +3 -0
  223. package/backend/dist/surfaces/direct-forward.js +206 -0
  224. package/backend/dist/surfaces/rate-limit-response.d.ts +17 -0
  225. package/backend/dist/surfaces/rate-limit-response.js +57 -0
  226. package/backend/dist/surfaces/types.d.ts +11 -0
  227. package/backend/dist/trace/tracker.d.ts +32 -1
  228. package/backend/dist/trace/tracker.js +29 -4
  229. package/backend/dist/types/router.d.ts +34 -12
  230. package/backend/dist/types/router.js +35 -6
  231. package/backend/dist/utils/chat-stream.d.ts +21 -8
  232. package/backend/dist/utils/chat-stream.js +46 -9
  233. package/backend/dist/utils/event-ring.d.ts +4 -0
  234. package/backend/dist/utils/event-ring.js +4 -0
  235. package/backend/dist/utils/popularity.js +29 -4
  236. package/backend/dist/utils/proxy.d.ts +7 -0
  237. package/backend/dist/utils/proxy.js +35 -10
  238. package/backend/dist/utils/retry-after.d.ts +21 -0
  239. package/backend/dist/utils/retry-after.js +36 -0
  240. package/bin/ocr.js +2 -2
  241. package/frontend/dist/assets/index-55VVwfFQ.js +1521 -0
  242. package/frontend/dist/assets/{index-CQSLGFTV.css → index-DxZ9MHKB.css} +1 -1
  243. package/frontend/dist/assets/workbuddy.color-DOMpQkxJ.svg +29 -0
  244. package/frontend/dist/index.html +2 -2
  245. package/package.json +1 -1
  246. package/frontend/dist/assets/index-CLvxJjp_.js +0 -1476
@@ -0,0 +1,497 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { spawn } from 'node:child_process';
5
+ import { collectHookWarnings, probeClientVersion, resolveForwardProxyEndpoint } from './base.js';
6
+ import { quoteWindowsArgs } from '../../utils/run-command.js';
7
+ import { getOcrHomeDir } from '../paths.js';
8
+ import { getForwardProxyStatus } from '../../forward-proxy/status.js';
9
+ import { probeCaTrustedCached } from '../../forward-proxy/ca-trust.js';
10
+ /**
11
+ * Qoder proxy client adapter — forward-proxy hook (no config-file rewrite).
12
+ *
13
+ * Qoder cannot be pointed at a custom LLM endpoint: its AI traffic is
14
+ * hardcoded to the vendor hosts (`api2-v2.qoder.sh` and friends, or
15
+ * `gateway.qoder.com.cn` in the China build). The `qoder-gateway` plugin MITMs
16
+ * those hosts through OCR's inbound forward proxy. This adapter publishes a
17
+ * launch script that starts Qoder through that proxy:
18
+ *
19
+ * - `--proxy-server` for Chromium legs;
20
+ * - lowercase `http(s)_proxy` + `grpc_proxy` for the agent SDK's Node fetch
21
+ * and grpc-js legs (grpc-js reads `grpc_proxy` FIRST, then `https_proxy`);
22
+ * - `NODE_EXTRA_CA_CERTS` for Node's bundled roots;
23
+ * - `NO_PROXY` to keep loopback out of the proxy hop.
24
+ *
25
+ * Non-LLM destinations forward transparently. The launchers are the only files
26
+ * this adapter WRITES; the sole client-side state it touches is the cached model
27
+ * catalog's mtime (`staleModelCatalog`) — never its contents.
28
+ */
29
+ /** Well-known Qoder install locations, per platform. */
30
+ function qoderBinaryCandidates() {
31
+ const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
32
+ switch (process.platform) {
33
+ case 'win32':
34
+ return [
35
+ path.join(localAppData, 'Programs', 'Qoder', 'Qoder.exe'),
36
+ path.join(localAppData, 'Programs', 'Qoder CN', 'Qoder.exe'),
37
+ path.join(localAppData, 'Qoder', 'Qoder.exe'),
38
+ ];
39
+ case 'darwin':
40
+ return [
41
+ '/Applications/Qoder.app/Contents/MacOS/Qoder',
42
+ '/Applications/Qoder CN.app/Contents/MacOS/Qoder',
43
+ path.join(os.homedir(), 'Applications', 'Qoder.app/Contents/MacOS/Qoder'),
44
+ ];
45
+ default:
46
+ return [
47
+ '/usr/bin/qoder',
48
+ '/usr/local/bin/qoder',
49
+ '/opt/Qoder/qoder',
50
+ '/opt/qoder/qoder',
51
+ path.join(os.homedir(), 'Applications', 'Qoder.AppImage'),
52
+ '/opt/Qoder.AppImage',
53
+ ];
54
+ }
55
+ }
56
+ /** The detected Qoder binary path, or null. `QODER_BIN` wins so an install
57
+ * layout outside the well-known list can still be hooked. */
58
+ function detectQoderBinary() {
59
+ const override = process.env.QODER_BIN?.trim();
60
+ if (override && fs.existsSync(override))
61
+ return override;
62
+ return qoderBinaryCandidates().find((candidate) => fs.existsSync(candidate)) ?? null;
63
+ }
64
+ /** Qoder's per-user data root; the agent SDK honours `QODER_HOME`. */
65
+ function qoderDataHome() {
66
+ const override = process.env.QODER_HOME?.trim();
67
+ return override || path.join(os.homedir(), '.qoder');
68
+ }
69
+ const CATALOG_FILE = /^catalog-v(\d+)$/;
70
+ /** Old enough that the client's freshness check can never pass. */
71
+ const STALE_MS = 30 * 24 * 60 * 60 * 1000;
72
+ /**
73
+ * Qoder's agent serves the model catalog from `<qoderHome>/.models/<uid>/catalog-v<N>`
74
+ * and only refreshes it in the BACKGROUND when that file is present but STALE.
75
+ * A missing file is not a miss it recovers from: `get_models` returns an empty
76
+ * list and never touches the network, which leaves the composer stuck on
77
+ * "this account cannot use the model for this task".
78
+ *
79
+ * So: keep the file, backdate its mtime. The client then serves the old list
80
+ * immediately (nothing is disabled) and refetches through the gateway, which
81
+ * merges the `ocr/*` entries into the reply.
82
+ */
83
+ export function staleModelCatalog(home = qoderDataHome()) {
84
+ const root = path.join(home, '.models');
85
+ const touched = [];
86
+ let entries;
87
+ try {
88
+ entries = fs.readdirSync(root, { withFileTypes: true });
89
+ }
90
+ catch {
91
+ return touched;
92
+ }
93
+ for (const entry of entries) {
94
+ if (!entry.isDirectory())
95
+ continue;
96
+ const dir = path.join(root, entry.name);
97
+ let files;
98
+ try {
99
+ files = fs.readdirSync(dir);
100
+ }
101
+ catch {
102
+ continue;
103
+ }
104
+ const canonical = files.filter((file) => CATALOG_FILE.test(file));
105
+ const stale = new Date(Date.now() - STALE_MS);
106
+ for (const file of canonical) {
107
+ const full = path.join(dir, file);
108
+ try {
109
+ fs.utimesSync(full, stale, stale);
110
+ touched.push(full);
111
+ }
112
+ catch {
113
+ // Locked by a running Qoder; the next setup after a full quit marks it.
114
+ }
115
+ }
116
+ }
117
+ return touched;
118
+ }
119
+ /** Count catalogs the client would serve without a background refresh. */
120
+ export function countFreshCatalogs(home = qoderDataHome(), maxAgeMs = 60 * 60 * 1000) {
121
+ const root = path.join(home, '.models');
122
+ const cutoff = Date.now() - maxAgeMs;
123
+ try {
124
+ return fs
125
+ .readdirSync(root, { withFileTypes: true })
126
+ .filter((entry) => entry.isDirectory())
127
+ .reduce((total, entry) => {
128
+ const dir = path.join(root, entry.name);
129
+ let files;
130
+ try {
131
+ files = fs.readdirSync(dir).filter((file) => CATALOG_FILE.test(file));
132
+ }
133
+ catch {
134
+ return total;
135
+ }
136
+ return total + files.filter((file) => {
137
+ try {
138
+ return fs.statSync(path.join(dir, file)).mtimeMs > cutoff;
139
+ }
140
+ catch {
141
+ return false;
142
+ }
143
+ }).length;
144
+ }, 0);
145
+ }
146
+ catch {
147
+ return 0;
148
+ }
149
+ }
150
+ function launcherExtension() {
151
+ return process.platform === 'win32' ? '.cmd' : process.platform === 'darwin' ? '.command' : '.sh';
152
+ }
153
+ function clientsDir() {
154
+ return path.join(getOcrHomeDir(), 'clients');
155
+ }
156
+ export function launcherPath() {
157
+ return path.join(clientsDir(), `qoder-launcher${launcherExtension()}`);
158
+ }
159
+ /** The CLI launcher — written only while `qodercli` is installed. */
160
+ export function cliLauncherPath() {
161
+ return path.join(clientsDir(), `qoder-cli-launcher${launcherExtension()}`);
162
+ }
163
+ /**
164
+ * The `qodercli` executable, resolved from `PATH` (npm installs a `.cmd` shim
165
+ * on Windows). `QODERCLI_BIN` wins for non-standard installs. The CLI is a
166
+ * plain Node program, so its launcher can use the CLEAN trust switch
167
+ * (`NODE_OPTIONS=--use-system-ca`), unlike the Electron daemon.
168
+ */
169
+ export function detectQoderCliBin(env = process.env) {
170
+ const override = env.QODERCLI_BIN?.trim();
171
+ if (override && fs.existsSync(override))
172
+ return override;
173
+ const dirs = (env.PATH ?? '').split(path.delimiter).filter(Boolean);
174
+ const exts = process.platform === 'win32' ? ['.cmd', '.exe', '.bat', ''] : [''];
175
+ for (const dir of dirs) {
176
+ for (const ext of exts) {
177
+ const candidate = path.join(dir, `qodercli${ext}`);
178
+ if (fs.existsSync(candidate))
179
+ return candidate;
180
+ }
181
+ }
182
+ return null;
183
+ }
184
+ /**
185
+ * Strict mode (`forwardProxy.requireCredential`) needs the key IN the URL:
186
+ * Chromium can prompt, but the agent SDK's grpc-js/fetch legs cannot. Only the
187
+ * console setup passes it; the launcher file then holds the secret.
188
+ */
189
+ function proxyUrl(port, credential) {
190
+ const userinfo = credential ? `ocr:${encodeURIComponent(credential)}@` : '';
191
+ return `http://${userinfo}127.0.0.1:${port}`;
192
+ }
193
+ /**
194
+ * CLI launcher text. Unlike the desktop launcher this one forwards argv and
195
+ * returns the CLI's exit status; `NODE_OPTIONS=--use-system-ca` makes Node use
196
+ * the OS root store, where the gateway CA lives, without disabling
197
+ * verification (the SDK ignores `NODE_EXTRA_CA_CERTS`).
198
+ */
199
+ export function buildQoderCliLauncher(args) {
200
+ const proxy = proxyUrl(args.port, args.proxyCredential);
201
+ const win = args.platform === 'win32';
202
+ const env = (k, v) => (win ? `set "${k}=${v}"` : `export ${k}="${v}"`);
203
+ const envBlock = () => [
204
+ ...(args.caPath ? [env('NODE_EXTRA_CA_CERTS', args.caPath)] : []),
205
+ env('NODE_OPTIONS', '--use-system-ca'),
206
+ env('grpc_proxy', proxy),
207
+ env('https_proxy', proxy),
208
+ env('http_proxy', proxy),
209
+ env('NO_PROXY', QODER_NO_PROXY),
210
+ ...(win ? [] : [env('no_proxy', QODER_NO_PROXY)]),
211
+ ];
212
+ if (win) {
213
+ return [
214
+ '@echo off',
215
+ 'setlocal',
216
+ 'REM omnicell-router-managed launcher: run qodercli through the OCR forward proxy.',
217
+ 'REM Regenerated by `ocr setup qoder-proxy`; manual edits are overwritten on the next setup.',
218
+ ...envBlock(),
219
+ // `call` + `exit /b`: the npm shim is a `.cmd` whose `exit` would
220
+ // otherwise terminate the caller's cmd.exe.
221
+ `call "${args.binary}" %*`,
222
+ 'exit /b %ERRORLEVEL%',
223
+ '',
224
+ ].join('\r\n');
225
+ }
226
+ return [
227
+ '#!/bin/sh',
228
+ '# omnicell-router-managed launcher: run qodercli through the OCR forward proxy.',
229
+ '# Regenerated by `ocr setup qoder-proxy`; manual edits are overwritten on the next setup.',
230
+ ...envBlock(),
231
+ `exec "${args.binary}" "$@"`,
232
+ '',
233
+ ].join('\n');
234
+ }
235
+ /**
236
+ * Loopback never enters the proxy hop. Both spellings are set on POSIX because
237
+ * libraries differ on which one they read; Windows env blocks are
238
+ * case-insensitive, so `set` emits ONE variable there.
239
+ */
240
+ export const QODER_NO_PROXY = 'localhost,127.0.0.1,::1';
241
+ /**
242
+ * The launcher text for one platform. Pure so the env contract is testable
243
+ * without a real Qoder install. Windows bodies open with `setlocal` so the
244
+ * `set` lines cannot rewrite the CALLING shell's proxy env.
245
+ */
246
+ export function buildQoderLauncher(args) {
247
+ const proxy = proxyUrl(args.port, args.proxyCredential);
248
+ const win = args.platform === 'win32';
249
+ const env = (k, v) => (win ? `set "${k}=${v}"` : `export ${k}="${v}"`);
250
+ const envBlock = () => [
251
+ ...(args.caPath ? [env('NODE_EXTRA_CA_CERTS', args.caPath)] : []),
252
+ // The desktop daemon drops NODE_OPTIONS (so `--use-system-ca` cannot reach
253
+ // it) and its SDK builds its own `ca` list, ignoring
254
+ // NODE_EXTRA_CA_CERTS. Verification stays disabled for THIS process only;
255
+ // otherwise every call dies at TLS before a request reaches the proxy.
256
+ env('NODE_TLS_REJECT_UNAUTHORIZED', '0'),
257
+ // grpc-js prefers `grpc_proxy`; the fetch/undici leg reads http(s)_proxy.
258
+ env('grpc_proxy', proxy),
259
+ env('https_proxy', proxy),
260
+ env('http_proxy', proxy),
261
+ env('NO_PROXY', QODER_NO_PROXY),
262
+ ...(win ? [] : [env('no_proxy', QODER_NO_PROXY)]),
263
+ ];
264
+ if (win) {
265
+ return [
266
+ '@echo off',
267
+ 'setlocal',
268
+ 'REM omnicell-router-managed launcher: start Qoder through the OCR forward proxy.',
269
+ 'REM Regenerated by `ocr setup qoder-proxy`; manual edits are overwritten on the next setup.',
270
+ ...envBlock(),
271
+ `start "" "${args.binary}" --proxy-server=${proxy} %*`,
272
+ '',
273
+ ].join('\r\n');
274
+ }
275
+ return [
276
+ '#!/bin/sh',
277
+ '# omnicell-router-managed launcher: start Qoder through the OCR forward proxy.',
278
+ '# Regenerated by `ocr setup qoder-proxy`; manual edits are overwritten on the next setup.',
279
+ ...envBlock(),
280
+ // macOS: the `.command` runs inside a Terminal window, so `exec` would make
281
+ // Qoder that window's child — closing the window SIGHUPs Qoder. Detach.
282
+ args.platform === 'darwin'
283
+ ? `nohup "${args.binary}" --proxy-server=${proxy} "$@" >/dev/null 2>&1 &`
284
+ : `exec "${args.binary}" --proxy-server=${proxy} "$@"`,
285
+ '',
286
+ ].join('\n');
287
+ }
288
+ export class QoderProxyClientAdapter {
289
+ name = 'qoder-proxy';
290
+ hookKind = 'launcher';
291
+ displayName = 'Qoder';
292
+ versionCmd = ['qoder', '--version'];
293
+ getConfigPath() {
294
+ // No client config file is owned — the launcher is the artifact.
295
+ return launcherPath();
296
+ }
297
+ async getStatus() {
298
+ const fp = resolveForwardProxyEndpoint();
299
+ const live = getForwardProxyStatus();
300
+ const launcher = fs.existsSync(launcherPath());
301
+ const binary = detectQoderBinary();
302
+ const versionProbe = await probeClientVersion(this.versionCmd);
303
+ const installed = !!binary || versionProbe !== null;
304
+ const caTrusted = installed && fp ? (await probeCaTrustedCached(fp.caPath)).trusted : 'unknown';
305
+ // The CLI launcher is a second owned artifact, written by setup only while
306
+ // `qodercli` is installed; a stale file from an earlier setup is shown too.
307
+ const cliLauncher = cliLauncherPath();
308
+ const cliLauncherExists = fs.existsSync(cliLauncher);
309
+ const cliBin = detectQoderCliBin();
310
+ const artifacts = cliBin || cliLauncherExists ? [{ path: cliLauncher, exists: cliLauncherExists }] : undefined;
311
+ const cliNote = cliBin
312
+ ? `; Qoder CLI detected at ${cliBin} — ${cliLauncherExists ? 'launch it via ' + cliLauncher : 'run setup to write ' + cliLauncher}`
313
+ : cliLauncherExists
314
+ ? `; stale CLI launcher ${cliLauncher} (qodercli no longer on PATH)`
315
+ : '';
316
+ let hooked = false;
317
+ let details;
318
+ if (!installed) {
319
+ details = 'Qoder not detected (no known install location and no `qoder` command on PATH)';
320
+ }
321
+ else if (!fp) {
322
+ details = 'forwardProxy disabled in config.yaml — enable it before hooking Qoder';
323
+ }
324
+ else if (!launcher) {
325
+ details = `Forward proxy enabled (port ${live.port ?? fp.port}${live.running ? ', running' : ', NOT running'}) — CA trust: ${caTrusted === true ? 'trusted' : caTrusted === false ? 'NOT trusted' : 'unknown'} — run setup to write the Qoder launcher`;
326
+ }
327
+ else {
328
+ hooked = true;
329
+ const fresh = countFreshCatalogs();
330
+ details = `Qoder starts via ${launcherPath()} with --proxy-server=${fp.url} and grpc_proxy for the agent SDK; quit Qoder fully before launching — an existing instance ignores a later launcher invocation; forward proxy ${live.running ? `running on port ${live.port ?? fp.port}` : 'NOT running (start the gateway)'}; CA trust: ${caTrusted === true ? 'trusted' : caTrusted === false ? `NOT trusted — import ${fp.caPath} manually` : 'unknown'}${fresh > 0 ? `; ${fresh} fresh model catalog cache(s) found — run setup again so Qoder refetches through the gateway instead of serving the old list` : ''}${cliNote}`;
331
+ }
332
+ return {
333
+ name: this.name,
334
+ displayName: this.displayName,
335
+ configPath: this.getConfigPath(),
336
+ exists: launcher,
337
+ hooked,
338
+ backupExists: false,
339
+ details,
340
+ ...(artifacts ? { artifacts } : {}),
341
+ // The gateway plugin owns model selection; a slot picker here would be a
342
+ // control that silently discards the choice.
343
+ modelSlots: [],
344
+ };
345
+ }
346
+ async setup(options) {
347
+ // The live runtime snapshot is the single source of truth — a fresh
348
+ // loadConfig() could advertise a port the running proxy no longer listens on.
349
+ const fp = resolveForwardProxyEndpoint();
350
+ if (!fp) {
351
+ return {
352
+ success: false,
353
+ reasonCode: 'forward_proxy_disabled',
354
+ message: 'forwardProxy is not enabled in config.yaml — set `forwardProxy.enabled: true` (and keep the gateway running) before hooking Qoder.',
355
+ };
356
+ }
357
+ if (!fs.existsSync(fp.caPath)) {
358
+ return {
359
+ success: false,
360
+ reasonCode: 'forward_proxy_ca_missing',
361
+ params: { path: fp.caPath },
362
+ message: `Forward-proxy MITM CA not found at ${fp.caPath} — it is generated when the gateway boots with forwardProxy enabled. Start the gateway and retry.`,
363
+ };
364
+ }
365
+ let binary = detectQoderBinary();
366
+ if (!binary) {
367
+ const cli = await probeClientVersion(this.versionCmd);
368
+ if (cli === null) {
369
+ return {
370
+ success: false,
371
+ reasonCode: 'qoder_not_found',
372
+ message: 'Qoder was not detected — install Qoder (or set QODER_BIN to its executable) and retry. The launcher needs the real binary path.',
373
+ };
374
+ }
375
+ binary = 'qoder';
376
+ }
377
+ const port = Number.isFinite(options?.port) && options?.port > 0 ? options?.port : fp.port;
378
+ // Strict mode closes the proxy to every credential-less connection; the
379
+ // console passes the bound key so the launcher can carry it in the URL.
380
+ const proxyCredential = fp.requireCredential
381
+ ? options?.apiKey?.trim() || process.env.OCR_PROXY_KEY?.trim()
382
+ : undefined;
383
+ if (fp.requireCredential && !proxyCredential) {
384
+ return {
385
+ success: false,
386
+ reasonCode: 'proxy_credential_required',
387
+ message: 'forwardProxy.requireCredential is on — setup needs the proxy key. Pick/bind a key in the console Client Hub, or point grpc_proxy/http(s)_proxy at http://ocr:<key>@host:port manually.',
388
+ };
389
+ }
390
+ const text = buildQoderLauncher({
391
+ platform: process.platform,
392
+ binary,
393
+ port,
394
+ caPath: fp.caPath,
395
+ ...(proxyCredential ? { proxyCredential } : {}),
396
+ });
397
+ const lPath = launcherPath();
398
+ fs.mkdirSync(clientsDir(), { recursive: true });
399
+ const win = process.platform === 'win32';
400
+ const mode = proxyCredential ? 0o700 : 0o755;
401
+ fs.writeFileSync(lPath, text, win ? 'utf8' : { encoding: 'utf8', mode });
402
+ if (!win)
403
+ fs.chmodSync(lPath, mode);
404
+ // Second owned artifact: the CLI launcher, only while `qodercli` exists.
405
+ // A launcher left from an earlier setup would point at a dead binary and a
406
+ // stale port, so setup owns (and prunes) that file too.
407
+ const cliBin = detectQoderCliBin();
408
+ const cliPath = cliLauncherPath();
409
+ if (cliBin) {
410
+ fs.writeFileSync(cliPath, buildQoderCliLauncher({
411
+ platform: process.platform,
412
+ binary: cliBin,
413
+ port,
414
+ caPath: fp.caPath,
415
+ ...(proxyCredential ? { proxyCredential } : {}),
416
+ }), win ? 'utf8' : { encoding: 'utf8', mode });
417
+ if (!win)
418
+ fs.chmodSync(cliPath, mode);
419
+ }
420
+ else {
421
+ fs.rmSync(cliPath, { force: true });
422
+ }
423
+ // A fresh catalog cache is served without asking the gateway; a MISSING one
424
+ // is never recovered from (the client returns an empty list and stays
425
+ // offline). Backdating is the only state that yields both: the old list is
426
+ // still displayed and the client refreshes it in the background.
427
+ const staled = staleModelCatalog();
428
+ // Same advisories as the Cursor hook: the launcher disables verification
429
+ // for the Node/grpc SDK only — Chromium legs still read the OS store, and
430
+ // a stopped listener breaks every leg.
431
+ const warnings = await collectHookWarnings(fp, port);
432
+ return {
433
+ success: true,
434
+ message: `Qoder launcher written at ${lPath}. Start the desktop app via \`ocr qoder\` — the takeover happens at launch time; Qoder itself is untouched.${cliBin ? ` Qoder CLI launcher: ${cliPath} (run \`ocr qoder-cli -p "..."\`). ` : ' '}${staled.length > 0 ? `Marked ${staled.length} cached model catalog(s) stale — quit Qoder completely first, then launch through the proxy; it will serve the old list and refetch in the background through the gateway. ` : ''}Install/enable the \`qoder-gateway\` plugin for OCR models; the desktop launcher disables TLS verification for the Node/grpc SDK because its daemon ignores every CA store except the compiled-in one.`,
435
+ ...(warnings.length > 0 ? { warnings } : {}),
436
+ };
437
+ }
438
+ async teardown() {
439
+ const targets = [launcherPath(), cliLauncherPath()];
440
+ const removed = [];
441
+ for (const target of targets) {
442
+ if (!fs.existsSync(target))
443
+ continue;
444
+ try {
445
+ fs.unlinkSync(target);
446
+ removed.push(target);
447
+ }
448
+ catch (err) {
449
+ return {
450
+ success: false,
451
+ reasonCode: 'remove_failed',
452
+ params: { path: target, detail: String(err) },
453
+ message: `Failed to remove ${target}: ${String(err)}`,
454
+ };
455
+ }
456
+ }
457
+ if (removed.length === 0) {
458
+ return { success: false, reasonCode: 'not_active', message: 'No Qoder launcher to delete — run `ocr setup qoder-proxy` first.' };
459
+ }
460
+ // The CA and Qoder's own files are intentionally untouched — the catalog
461
+ // mtimes setup backdated are left stale, so the next launch refreshes them.
462
+ return {
463
+ success: true,
464
+ message: `Qoder launchers deleted (${removed.join(', ')}). Qoder itself was never modified — start it normally for a direct connection. The MITM CA remains in the trust store if you imported it manually.`,
465
+ };
466
+ }
467
+ }
468
+ /**
469
+ * Run one of the managed launchers, forwarding stdio and the launcher's exit
470
+ * code — the `ocr qoder` / `ocr qoder-cli` contract, identical to Cursor's.
471
+ * The CLI is interactive (`-p`, or a full TUI), so it must keep the caller's
472
+ * stdio; the desktop launcher detaches by itself via `start`.
473
+ */
474
+ export async function runQoderLauncher(kind, argv) {
475
+ const detached = kind === 'desktop' && process.platform !== 'linux';
476
+ const script = kind === 'desktop' ? launcherPath() : cliLauncherPath();
477
+ if (!fs.existsSync(script)) {
478
+ return {
479
+ ok: false,
480
+ code: 1,
481
+ detached,
482
+ message: `${kind === 'desktop' ? 'Qoder' : 'Qoder CLI'} launcher not found at ${script} — run \`ocr setup qoder-proxy\`` +
483
+ `${kind === 'cli' ? ' (with qodercli installed)' : ''}.`,
484
+ };
485
+ }
486
+ const win = process.platform === 'win32';
487
+ const args = win ? quoteWindowsArgs(argv) : argv;
488
+ const cmd = win && /\s/.test(script) ? `"${script}"` : script;
489
+ return await new Promise(resolve => {
490
+ const child = spawn(cmd, args, { stdio: 'inherit', shell: win, windowsHide: true });
491
+ child.on('error', err => resolve({ ok: false, code: 1, detached, message: String(err) }));
492
+ child.on('close', (code, signal) => {
493
+ const signum = signal ? os.constants.signals[signal] : undefined;
494
+ resolve({ ok: code === 0, code: code ?? (signum ? 128 + signum : 1), detached });
495
+ });
496
+ });
497
+ }
@@ -1,4 +1,3 @@
1
- import type { SupportedClient } from '../types.js';
2
1
  /**
3
2
  * Client-id vocabulary a plugin cannot claim — the RESERVED half of the Client
4
3
  * Hub registry (ADR-0027 / ADR-0029).
@@ -44,8 +43,5 @@ export declare function isCoreClientId(name: string): name is CoreClientId;
44
43
  export declare const RETIRED_CLIENT_IDS: Readonly<Record<string, string>>;
45
44
  /** Human-readable hint for a retired id, or undefined when the id is not one. */
46
45
  export declare function retiredClientHint(name: string): string | undefined;
47
- /** Compile-time guard: a reserved id must stay part of the union the console
48
- * and CLI can ADDRESS, or the roster would hold an id nothing can type. */
49
- type AssertTrue<T extends true> = T;
50
- export type CoreClientIdsAreAddressable = AssertTrue<CoreClientId extends SupportedClient ? true : false>;
51
- export {};
46
+ /** `CoreClientId` is the ENTIRE core client vocabulary — there is no second
47
+ * union for package ids: those register as runtime strings (ADR-0027). */
@@ -51,3 +51,5 @@ export function retiredClientHint(name) {
51
51
  return undefined;
52
52
  return `client '${name}' was renamed to '${replacement}' — uninstall the old package (its row is superseded) and use '${replacement}'`;
53
53
  }
54
+ /** `CoreClientId` is the ENTIRE core client vocabulary — there is no second
55
+ * union for package ids: those register as runtime strings (ADR-0027). */
@@ -13,8 +13,8 @@ export declare function workbuddyConfigCandidates(): string[];
13
13
  */
14
14
  export declare function resolveWorkbuddyConfigPath(candidates?: string[]): string;
15
15
  export declare class WorkBuddyClientAdapter implements ClientAdapter {
16
- name: 'workbuddy';
17
- hookKind: 'config';
16
+ name: "workbuddy";
17
+ hookKind: "config";
18
18
  displayName: string;
19
19
  getConfigPath(): string;
20
20
  getStatus(): Promise<Omit<ClientHookStatus, 'hookKind'>>;
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { startDaemon, stopDaemon, restartDaemon, getStatusOutput, launchWeb, launchDesktop, getRunningPid, getDaemonInfo } from './daemon.js';
3
- import { setupClient, teardownClient, CLIENT_TARGETS, ensurePluginClientAdapters, findLaunchVerb, getAllClientAdapters, listLaunchVerbs, pluginWarningLabelsFor, } from './clients/index.js';
3
+ import { setupClient, teardownClient, CLIENT_TARGETS, currentLaunchVerb, ensurePluginClientAdapters, findLaunchVerb, getAllClientAdapters, listLaunchVerbs, pluginWarningLabelsFor, } from './clients/index.js';
4
4
  import { defaultGatewayPort, pluginWarningText } from './clients/base.js';
5
5
  import { runLauncherScript } from './clients/launcher.js';
6
+ import { isCoreClientId } from './clients/reserved.js';
6
7
  import { registerGlobalShims, shimStatus, unregisterGlobalShims } from './shim.js';
7
8
  import { APP_VERSION } from '../version.js';
8
9
  import { DEFAULT_ENV_NAME, createEnv, envExists, listEnvs, peekEnvName, readPointer, resetSandboxEnv, writePointer, } from '../config/env.js';
@@ -107,14 +108,44 @@ ${C.bold}SYSTEM COMMANDS:${C.reset}
107
108
  ocr --help, -h Display this help manual
108
109
  `);
109
110
  }
111
+ /** The id of the one hook that IS `target`, when the target was refused as a
112
+ * launch verb: the product hook (`antigravity`) comes before its CLI verb
113
+ * (`antigravity-cli`), whichever spelling produced the hit. */
114
+ function hookIdForLaunchVerb(adapters, key) {
115
+ const hooks = adapters.filter((a) => a.launchVerbs?.().some((v) => v.verb === key || (v.aliases ?? []).includes(key)));
116
+ return hooks.find((a) => a.name === key)?.name ?? hooks[0]?.name;
117
+ }
110
118
  /**
111
119
  * Bare launch verbs name the target tool, never a hook target: point the
112
- * operator at the id that PUBLISHES the verb (the registry knows which hook
113
- * that is) instead of the generic unknown-client message.
120
+ * operator at the hook that PUBLISHES the verb (the registry knows which one)
121
+ * instead of the generic unknown-client message. A retired verb spelling
122
+ * (`ocr setup agy`) is answered the same way, with the current name.
114
123
  */
115
- function launchVerbHint(target, verb) {
116
- const hit = findLaunchVerb(target.toLowerCase());
117
- return hit ? `'${target}' is a launch verb, not a hook target. Run \`ocr ${verb} ${hit.client}\`.` : null;
124
+ function launchVerbHint(target, verb, adapters) {
125
+ const client = currentLaunchVerb(target);
126
+ if (!client)
127
+ return null;
128
+ if (client !== String(target).trim().toLowerCase())
129
+ return `'${target}' was renamed — run \`ocr ${client}\`.`;
130
+ const hook = hookIdForLaunchVerb(adapters, client);
131
+ return `'${target}' is a launch verb, not a hook target.${hook ? ` Run \`ocr ${verb} ${hook}\`.` : ''}`;
132
+ }
133
+ /**
134
+ * A target that names a PRODUCT the hooked surface is installed for
135
+ * (`antigravity`) is not a hook id (`antigravity-proxy`): say which id to use
136
+ * instead of the generic unknown-client list.
137
+ */
138
+ function retiredTargetHint(target, verb, adapters) {
139
+ const key = String(target ?? '').trim().toLowerCase();
140
+ if (!key || isCoreClientId(key))
141
+ return null;
142
+ // The branding key a MECHANISM-named hook declares for the product it drives
143
+ // (`antigravity-proxy` → `antigravity`). A hook whose id IS the product
144
+ // already resolves through the registry, so only the id differs here.
145
+ const owners = adapters.filter((a) => a.icon === key && a.name !== key);
146
+ if (owners.length !== 1)
147
+ return null;
148
+ return `'${target}' is a product, not a hook target. Run \`ocr ${verb} ${owners[0].name}\`.`;
118
149
  }
119
150
  async function handleStatus() {
120
151
  printBanner();
@@ -311,7 +342,12 @@ const OCR_COMMANDS = {
311
342
  async function handleClientLaunch(verb, argv) {
312
343
  const hit = findLaunchVerb(verb);
313
344
  if (!hit) {
314
- console.error(`${C.red}✗ Unknown command '${verb}'.${C.reset} Run ${C.cyan}ocr help${C.reset} for the current verbs.`);
345
+ // A retired spelling is refused BY NAME: running the old word silently
346
+ // would keep it alive in scripts, and "unknown command" hides the rename.
347
+ const current = currentLaunchVerb(verb);
348
+ console.error(current
349
+ ? `${C.red}✗ '${verb}' was renamed — run ${C.cyan}ocr ${current}${C.reset}.`
350
+ : `${C.red}✗ Unknown command '${verb}'.${C.reset} Run ${C.cyan}ocr help${C.reset} for the current verbs.`);
315
351
  process.exitCode = 1;
316
352
  return;
317
353
  }
@@ -441,7 +477,11 @@ async function main() {
441
477
  console.error(`${C.red}✗ Missing client target.${C.reset} Usage: \`ocr setup <${CLIENT_TARGETS}>\``);
442
478
  process.exit(1);
443
479
  }
444
- const launchHint = launchVerbHint(client, 'setup');
480
+ // await: the roster arrives with the package hooks, and a hint computed
481
+ // before they register would answer "unknown" for a hooked product.
482
+ await ensurePluginClientAdapters();
483
+ const hints = getAllClientAdapters();
484
+ const launchHint = launchVerbHint(client, 'setup', hints) ?? retiredTargetHint(client, 'setup', hints);
445
485
  if (launchHint) {
446
486
  console.error(`${C.red}✗ ${launchHint}${C.reset}`);
447
487
  process.exit(1);
@@ -471,7 +511,10 @@ async function main() {
471
511
  console.error(`${C.red}✗ Missing client target.${C.reset} Usage: \`ocr teardown <${CLIENT_TARGETS}>\``);
472
512
  process.exit(1);
473
513
  }
474
- const launchHint = launchVerbHint(client, 'teardown');
514
+ // await: see the `setup` case — package hooks register on this promise.
515
+ await ensurePluginClientAdapters();
516
+ const hints = getAllClientAdapters();
517
+ const launchHint = launchVerbHint(client, 'teardown', hints) ?? retiredTargetHint(client, 'teardown', hints);
475
518
  if (launchHint) {
476
519
  console.error(`${C.red}✗ ${launchHint}${C.reset}`);
477
520
  process.exit(1);
@@ -534,6 +577,14 @@ async function main() {
534
577
  break;
535
578
  }
536
579
  default: {
580
+ // A retired verb spelling (`ocr agy`) is named here too: it is not a
581
+ // launch verb any more, and "unknown command" would hide the rename.
582
+ const renamed = currentLaunchVerb(action);
583
+ if (renamed) {
584
+ console.error(`${C.red}✗ '${action}' was renamed — run ${C.cyan}ocr ${renamed}${C.reset}`);
585
+ process.exitCode = 1;
586
+ break;
587
+ }
537
588
  console.error(`${C.red}✗ Unknown command: '${action}'${C.reset}`);
538
589
  console.error(` Run \`ocr --help\` to see supported commands.`);
539
590
  process.exit(2);