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.
- package/backend/dist/cli/clients/activity.d.ts +35 -0
- package/backend/dist/cli/clients/activity.js +67 -0
- package/backend/dist/cli/clients/base.d.ts +13 -2
- package/backend/dist/cli/clients/claude.d.ts +2 -2
- package/backend/dist/cli/clients/codex.d.ts +2 -2
- package/backend/dist/cli/clients/core-adapters.d.ts +3 -4
- package/backend/dist/cli/clients/core-adapters.js +3 -4
- package/backend/dist/cli/clients/cursor-proxy.d.ts +88 -0
- package/backend/dist/cli/clients/cursor-proxy.js +421 -0
- package/backend/dist/cli/clients/dsh.d.ts +2 -2
- package/backend/dist/cli/clients/grok.d.ts +2 -2
- package/backend/dist/cli/clients/index.d.ts +8 -1
- package/backend/dist/cli/clients/index.js +55 -21
- package/backend/dist/cli/clients/kimi.d.ts +2 -2
- package/backend/dist/cli/clients/launcher.d.ts +8 -0
- package/backend/dist/cli/clients/model-meta.js +1 -1
- package/backend/dist/cli/clients/omp.d.ts +2 -2
- package/backend/dist/cli/clients/openclaw.d.ts +2 -2
- package/backend/dist/cli/clients/opencode-proxy.d.ts +11 -0
- package/backend/dist/cli/clients/opencode-proxy.js +351 -0
- package/backend/dist/cli/clients/opencode.d.ts +2 -2
- package/backend/dist/cli/clients/pi.d.ts +2 -2
- package/backend/dist/cli/clients/plugin-adapters.d.ts +3 -1
- package/backend/dist/cli/clients/plugin-adapters.js +6 -29
- package/backend/dist/cli/clients/qoder-proxy.d.ts +84 -0
- package/backend/dist/cli/clients/qoder-proxy.js +497 -0
- package/backend/dist/cli/clients/reserved.d.ts +2 -6
- package/backend/dist/cli/clients/reserved.js +2 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +2 -2
- package/backend/dist/cli/index.js +60 -9
- package/backend/dist/cli/types.d.ts +29 -8
- package/backend/dist/compression/caveman-prompts.d.ts +1 -1
- package/backend/dist/config/comments-en.js +6 -12
- package/backend/dist/config/comments-zh.js +6 -12
- package/backend/dist/config/defaults.d.ts +56 -1
- package/backend/dist/config/defaults.js +68 -0
- package/backend/dist/config/index.d.ts +9 -2
- package/backend/dist/config/index.js +26 -3
- package/backend/dist/config/types.d.ts +55 -43
- package/backend/dist/forward-proxy/egress.d.ts +10 -2
- package/backend/dist/forward-proxy/egress.js +42 -4
- package/backend/dist/forward-proxy/ordered-relay.d.ts +29 -0
- package/backend/dist/forward-proxy/ordered-relay.js +46 -0
- package/backend/dist/forward-proxy/rules.d.ts +66 -19
- package/backend/dist/forward-proxy/rules.js +61 -14
- package/backend/dist/forward-proxy/server.js +226 -77
- package/backend/dist/forward-proxy/system-proxy.d.ts +42 -2
- package/backend/dist/forward-proxy/system-proxy.js +199 -22
- package/backend/dist/harness/common/market.d.ts +3 -3
- package/backend/dist/harness/host/adapters/amp.d.ts +1 -1
- package/backend/dist/harness/host/adapters/antigravity.d.ts +1 -1
- package/backend/dist/harness/host/adapters/claude.d.ts +1 -1
- package/backend/dist/harness/host/adapters/cline.d.ts +1 -1
- package/backend/dist/harness/host/adapters/codex.d.ts +1 -1
- package/backend/dist/harness/host/adapters/cursor.d.ts +1 -1
- package/backend/dist/harness/host/adapters/dsh.d.ts +2 -2
- package/backend/dist/harness/host/adapters/factory.d.ts +1 -1
- package/backend/dist/harness/host/adapters/gemini-cli.d.ts +1 -1
- package/backend/dist/harness/host/adapters/grok.d.ts +1 -1
- package/backend/dist/harness/host/adapters/kimi.d.ts +1 -1
- package/backend/dist/harness/host/adapters/omp.d.ts +1 -1
- package/backend/dist/harness/host/adapters/openclaw.d.ts +1 -1
- package/backend/dist/harness/host/adapters/opencode.d.ts +1 -1
- package/backend/dist/harness/host/adapters/pi.d.ts +1 -1
- package/backend/dist/harness/host/adapters/universal.d.ts +1 -1
- package/backend/dist/harness/host/adapters/windsurf.d.ts +1 -1
- package/backend/dist/harness/host/adapters/zed.d.ts +1 -1
- package/backend/dist/harness/skill/skills-sh.d.ts +1 -1
- package/backend/dist/harness/translation.js +64 -21
- package/backend/dist/harness/types.d.ts +1 -1
- package/backend/dist/harness/types.js +1 -1
- package/backend/dist/index.js +31 -18
- package/backend/dist/ir/adapters/anthropic-stream.d.ts +18 -0
- package/backend/dist/ir/adapters/anthropic-stream.js +247 -0
- package/backend/dist/ir/adapters/anthropic.d.ts +29 -0
- package/backend/dist/ir/adapters/anthropic.js +788 -0
- package/backend/dist/ir/adapters/chat.d.ts +15 -0
- package/backend/dist/ir/adapters/chat.js +602 -0
- package/backend/dist/ir/adapters/google-stream.d.ts +22 -0
- package/backend/dist/ir/adapters/google-stream.js +242 -0
- package/backend/dist/ir/adapters/google.d.ts +9 -0
- package/backend/dist/ir/adapters/google.js +317 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +8 -5
- package/backend/dist/ir/adapters/openai-responses.d.ts +15 -0
- package/backend/dist/ir/adapters/openai-responses.js +26 -1
- package/backend/dist/ir/adapters/responses-output.d.ts +50 -0
- package/backend/dist/ir/adapters/responses-output.js +348 -0
- package/backend/dist/ir/adapters/responses-stream.d.ts +12 -0
- package/backend/dist/ir/adapters/responses-stream.js +178 -0
- package/backend/dist/ir/adapters/responses.d.ts +14 -0
- package/backend/dist/ir/adapters/responses.js +646 -0
- package/backend/dist/ir/errors.d.ts +2 -2
- package/backend/dist/ir/types.d.ts +2 -1
- package/backend/dist/metrics/request-cost.d.ts +11 -2
- package/backend/dist/metrics/request-cost.js +12 -3
- package/backend/dist/observability/request-identity.d.ts +1 -1
- package/backend/dist/observability/trace-id.d.ts +40 -0
- package/backend/dist/observability/trace-id.js +134 -0
- package/backend/dist/observability/upstream-events.d.ts +82 -60
- package/backend/dist/observability/upstream-events.js +142 -67
- package/backend/dist/opencode/catalog/types.d.ts +9 -0
- package/backend/dist/opencode/credentials/types.d.ts +2 -2
- package/backend/dist/opencode/probe.d.ts +24 -1
- package/backend/dist/opencode/probe.js +28 -4
- package/backend/dist/opencode/user-config.d.ts +5 -0
- package/backend/dist/pipeline/directives.d.ts +6 -2
- package/backend/dist/pipeline/directives.js +7 -3
- package/backend/dist/pipeline/orchestrator.d.ts +28 -27
- package/backend/dist/pipeline/orchestrator.js +220 -194
- package/backend/dist/pipeline/unresolved-model.d.ts +33 -0
- package/backend/dist/pipeline/unresolved-model.js +43 -0
- package/backend/dist/plugins/catalog-def.d.ts +143 -0
- package/backend/dist/plugins/catalog-def.js +177 -0
- package/backend/dist/plugins/gateways.d.ts +62 -3
- package/backend/dist/plugins/gateways.js +139 -2
- package/backend/dist/plugins/host.d.ts +42 -5
- package/backend/dist/plugins/host.js +454 -38
- package/backend/dist/plugins/manifest.d.ts +119 -10
- package/backend/dist/plugins/manifest.js +265 -14
- package/backend/dist/plugins/pack.js +26 -0
- package/backend/dist/plugins/types.d.ts +187 -21
- package/backend/dist/protocols/systemone/convert.d.ts +1 -0
- package/backend/dist/protocols/systemone/convert.js +6 -1
- package/backend/dist/protocols/systemone/decide.js +18 -8
- package/backend/dist/providers/anthropic-messages.d.ts +12 -0
- package/backend/dist/providers/anthropic-messages.js +53 -0
- package/backend/dist/providers/anthropic.d.ts +7 -8
- package/backend/dist/providers/anthropic.js +36 -324
- package/backend/dist/providers/base.d.ts +14 -2
- package/backend/dist/providers/boot-direct.js +68 -38
- package/backend/dist/providers/dispatch.d.ts +5 -19
- package/backend/dist/providers/dispatch.js +46 -58
- package/backend/dist/providers/executors/anthropic-messages.d.ts +1 -0
- package/backend/dist/providers/executors/anthropic-messages.js +3 -0
- package/backend/dist/providers/executors/dispatch.d.ts +16 -2
- package/backend/dist/providers/executors/dispatch.js +39 -9
- package/backend/dist/providers/executors/google-gemini.d.ts +1 -0
- package/backend/dist/providers/executors/google-gemini.js +3 -0
- package/backend/dist/providers/executors/http-stream.js +16 -3
- package/backend/dist/providers/executors/openai-chat.d.ts +1 -0
- package/backend/dist/providers/executors/openai-chat.js +3 -0
- package/backend/dist/providers/executors/openai-responses.d.ts +1 -0
- package/backend/dist/providers/executors/openai-responses.js +3 -0
- package/backend/dist/providers/executors/plugin-adapter.js +4 -4
- package/backend/dist/providers/google-gemini.d.ts +12 -0
- package/backend/dist/providers/google-gemini.js +50 -0
- package/backend/dist/providers/google.d.ts +7 -8
- package/backend/dist/providers/google.js +35 -308
- package/backend/dist/providers/http-json.d.ts +19 -0
- package/backend/dist/providers/http-json.js +104 -0
- package/backend/dist/providers/http-stream.d.ts +52 -0
- package/backend/dist/providers/http-stream.js +423 -0
- package/backend/dist/providers/member-match.d.ts +4 -5
- package/backend/dist/providers/member-match.js +4 -5
- package/backend/dist/providers/openai-chat.d.ts +13 -0
- package/backend/dist/providers/openai-chat.js +99 -0
- package/backend/dist/providers/openai-compatible.d.ts +7 -4
- package/backend/dist/providers/openai-compatible.js +71 -368
- package/backend/dist/providers/openai-responses.d.ts +12 -0
- package/backend/dist/providers/openai-responses.js +68 -0
- package/backend/dist/providers/opencode-proxy.d.ts +5 -5
- package/backend/dist/providers/opencode-proxy.js +49 -125
- package/backend/dist/providers/plugin-adapter.d.ts +9 -0
- package/backend/dist/providers/plugin-adapter.js +31 -0
- package/backend/dist/providers/registry.d.ts +49 -24
- package/backend/dist/providers/registry.js +97 -55
- package/backend/dist/providers/responses.d.ts +7 -28
- package/backend/dist/providers/responses.js +45 -253
- package/backend/dist/providers/tool-markup-leak.d.ts +41 -0
- package/backend/dist/providers/tool-markup-leak.js +57 -0
- package/backend/dist/providers/tool-markup-recovery.d.ts +27 -0
- package/backend/dist/providers/tool-markup-recovery.js +786 -0
- package/backend/dist/providers/virtual-meta.d.ts +21 -2
- package/backend/dist/providers/virtual-meta.js +49 -9
- package/backend/dist/proxy/asset-download.d.ts +54 -0
- package/backend/dist/proxy/asset-download.js +420 -0
- package/backend/dist/proxy/manual-node-spec.d.ts +16 -16
- package/backend/dist/proxy/mihomo-binary.d.ts +17 -2
- package/backend/dist/proxy/mihomo-binary.js +62 -51
- package/backend/dist/proxy/mihomo-client.js +15 -1
- package/backend/dist/proxy/mihomo-config.js +11 -2
- package/backend/dist/proxy/mihomo-geo.d.ts +87 -0
- package/backend/dist/proxy/mihomo-geo.js +213 -0
- package/backend/dist/proxy/mihomo-logs.d.ts +27 -0
- package/backend/dist/proxy/mihomo-logs.js +70 -0
- package/backend/dist/proxy/mihomo-pac.d.ts +11 -0
- package/backend/dist/proxy/mihomo-pac.js +15 -0
- package/backend/dist/proxy/mihomo-rules-import.d.ts +1 -1
- package/backend/dist/proxy/mihomo-rules-import.js +7 -7
- package/backend/dist/proxy/mihomo-sidecar.d.ts +17 -1
- package/backend/dist/proxy/mihomo-sidecar.js +148 -26
- package/backend/dist/quota/adapters/minimax.js +36 -13
- package/backend/dist/quota/cli-login.d.ts +8 -0
- package/backend/dist/quota/cli-login.js +18 -0
- package/backend/dist/quota/declarations.js +10 -0
- package/backend/dist/quota/dsl.js +18 -5
- package/backend/dist/quota/engine.d.ts +22 -1
- package/backend/dist/quota/engine.js +170 -29
- package/backend/dist/quota/prober.d.ts +5 -0
- package/backend/dist/quota/prober.js +11 -2
- package/backend/dist/quota/types.d.ts +87 -8
- package/backend/dist/quota/verdict.d.ts +35 -0
- package/backend/dist/quota/verdict.js +135 -0
- package/backend/dist/ratelimit/admission.d.ts +131 -0
- package/backend/dist/ratelimit/admission.js +233 -0
- package/backend/dist/ratelimit/rate-limiter.js +6 -0
- package/backend/dist/resilience/types.d.ts +2 -2
- package/backend/dist/router/layer2-decision.d.ts +1 -1
- package/backend/dist/router/layer2-decision.js +5 -8
- package/backend/dist/routes/console.js +248 -52
- package/backend/dist/routes/mihomo.d.ts +2 -0
- package/backend/dist/routes/mihomo.js +334 -29
- package/backend/dist/routes/responses.d.ts +87 -8
- package/backend/dist/routes/responses.js +314 -33
- package/backend/dist/server.js +34 -6
- package/backend/dist/session/session-manager.d.ts +6 -0
- package/backend/dist/session/session-manager.js +20 -9
- package/backend/dist/surfaces/chat-pipeline.d.ts +2 -2
- package/backend/dist/surfaces/chat-pipeline.js +17 -7
- package/backend/dist/surfaces/chat.js +15 -0
- package/backend/dist/surfaces/decision-pipeline.js +7 -10
- package/backend/dist/surfaces/direct-forward.d.ts +3 -0
- package/backend/dist/surfaces/direct-forward.js +206 -0
- package/backend/dist/surfaces/rate-limit-response.d.ts +17 -0
- package/backend/dist/surfaces/rate-limit-response.js +57 -0
- package/backend/dist/surfaces/types.d.ts +11 -0
- package/backend/dist/trace/tracker.d.ts +32 -1
- package/backend/dist/trace/tracker.js +29 -4
- package/backend/dist/types/router.d.ts +34 -12
- package/backend/dist/types/router.js +35 -6
- package/backend/dist/utils/chat-stream.d.ts +21 -8
- package/backend/dist/utils/chat-stream.js +46 -9
- package/backend/dist/utils/event-ring.d.ts +4 -0
- package/backend/dist/utils/event-ring.js +4 -0
- package/backend/dist/utils/popularity.js +29 -4
- package/backend/dist/utils/proxy.d.ts +7 -0
- package/backend/dist/utils/proxy.js +35 -10
- package/backend/dist/utils/retry-after.d.ts +21 -0
- package/backend/dist/utils/retry-after.js +36 -0
- package/bin/ocr.js +2 -2
- package/frontend/dist/assets/index-55VVwfFQ.js +1521 -0
- package/frontend/dist/assets/{index-CQSLGFTV.css → index-DxZ9MHKB.css} +1 -1
- package/frontend/dist/assets/workbuddy.color-DOMpQkxJ.svg +29 -0
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/index-CLvxJjp_.js +0 -1476
|
@@ -0,0 +1,421 @@
|
|
|
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
|
+
* Cursor proxy client adapter — forward-proxy hook (no config-file rewrite).
|
|
12
|
+
*
|
|
13
|
+
* Cursor cannot be pointed at a custom LLM endpoint by configuration: its AI
|
|
14
|
+
* traffic is hardcoded to api2.cursor.sh. The `cursor-gateway` plugin MITMs those
|
|
15
|
+
* hosts through OCR's inbound forward proxy. This adapter therefore "hooks"
|
|
16
|
+
* Cursor by publishing launch scripts (<ocrHome>/clients/cursor-launcher.*
|
|
17
|
+
* and, when the CLI exists, cursor-agent-launcher.*) that start Cursor/the
|
|
18
|
+
* CLI through the forward proxy: `--proxy-server` for Chromium legs, plus the
|
|
19
|
+
* lowercase http(s)_proxy + NODE_EXTRA_CA_CERTS + NO_PROXY environment for
|
|
20
|
+
* Electron's Node/gRPC legs (they ignore the flag and the OS cert store).
|
|
21
|
+
* Non-LLM destinations forward transparently.
|
|
22
|
+
*
|
|
23
|
+
* The launchers are the ONLY artifact this adapter writes: phase 1 publishes
|
|
24
|
+
* no model advertisement (the plugin's `AvailableModels` arrives in phase 2).
|
|
25
|
+
* The CA trust and Cursor's own files are NEVER touched by setup/teardown;
|
|
26
|
+
* getStatus only PROBES CA trust (best-effort, honest unknown) so the console
|
|
27
|
+
* can show what still needs manual action.
|
|
28
|
+
*/
|
|
29
|
+
/** Well-known Cursor install locations, per platform. */
|
|
30
|
+
function cursorBinaryCandidates() {
|
|
31
|
+
switch (process.platform) {
|
|
32
|
+
case 'win32': {
|
|
33
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
|
|
34
|
+
return [
|
|
35
|
+
path.join(localAppData, 'Programs', 'cursor', 'Cursor.exe'),
|
|
36
|
+
path.join(localAppData, 'Programs', 'Cursor', 'Cursor.exe'),
|
|
37
|
+
path.join(localAppData, 'cursor', 'Cursor.exe'),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
case 'darwin':
|
|
41
|
+
return [
|
|
42
|
+
'/Applications/Cursor.app/Contents/MacOS/Cursor',
|
|
43
|
+
path.join(os.homedir(), 'Applications', 'Cursor.app/Contents/MacOS/Cursor'),
|
|
44
|
+
];
|
|
45
|
+
default:
|
|
46
|
+
return [
|
|
47
|
+
'/usr/bin/cursor',
|
|
48
|
+
'/usr/local/bin/cursor',
|
|
49
|
+
'/opt/cursor/cursor',
|
|
50
|
+
'/opt/Cursor/cursor',
|
|
51
|
+
'/usr/share/cursor/cursor',
|
|
52
|
+
// AppImage installs are first-class on Linux: the binary IS the file.
|
|
53
|
+
path.join(os.homedir(), 'Applications', 'Cursor.AppImage'),
|
|
54
|
+
path.join(os.homedir(), 'Applications', 'cursor.AppImage'),
|
|
55
|
+
'/opt/Cursor.AppImage',
|
|
56
|
+
'/opt/cursor.AppImage',
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** The detected Cursor binary path, or null. `CURSOR_BIN` wins so an install
|
|
61
|
+
* layout outside the well-known list (Nix, custom AppImage, snap wrapper) can
|
|
62
|
+
* still be hooked without editing this table. */
|
|
63
|
+
function detectCursorBinary() {
|
|
64
|
+
const override = process.env.CURSOR_BIN?.trim();
|
|
65
|
+
if (override && fs.existsSync(override))
|
|
66
|
+
return override;
|
|
67
|
+
const hit = cursorBinaryCandidates().find(p => fs.existsSync(p));
|
|
68
|
+
return hit || null;
|
|
69
|
+
}
|
|
70
|
+
/** Well-known cursor-agent CLI locations, per platform. */
|
|
71
|
+
function agentBinaryCandidates() {
|
|
72
|
+
const home = os.homedir();
|
|
73
|
+
switch (process.platform) {
|
|
74
|
+
case 'win32':
|
|
75
|
+
return [
|
|
76
|
+
path.join(home, 'AppData', 'Local', 'cursor-agent', 'cursor-agent.exe'),
|
|
77
|
+
path.join(home, 'AppData', 'Local', 'cursor-agent', 'cursor-agent.cmd'),
|
|
78
|
+
path.join(home, '.cursor', 'cursor-agent.exe'),
|
|
79
|
+
path.join(home, '.cursor', 'cursor-agent.cmd'),
|
|
80
|
+
];
|
|
81
|
+
case 'darwin':
|
|
82
|
+
return [
|
|
83
|
+
path.join(home, '.cursor', 'bin', 'cursor-agent'),
|
|
84
|
+
'/usr/local/bin/cursor-agent',
|
|
85
|
+
];
|
|
86
|
+
default:
|
|
87
|
+
return [
|
|
88
|
+
path.join(home, '.local', 'bin', 'cursor-agent'),
|
|
89
|
+
'/usr/local/bin/cursor-agent',
|
|
90
|
+
'/usr/bin/cursor-agent',
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** The detected cursor-agent CLI binary path, or null. `CURSOR_AGENT_BIN`
|
|
95
|
+
* overrides the well-known table for non-standard installs. */
|
|
96
|
+
function detectAgentBinary() {
|
|
97
|
+
const override = process.env.CURSOR_AGENT_BIN?.trim();
|
|
98
|
+
if (override && fs.existsSync(override))
|
|
99
|
+
return override;
|
|
100
|
+
const hit = agentBinaryCandidates().find(p => fs.existsSync(p));
|
|
101
|
+
return hit || null;
|
|
102
|
+
}
|
|
103
|
+
/** Launcher script extension per platform (darwin gets a double-clickable .command). */
|
|
104
|
+
function launcherExtension() {
|
|
105
|
+
return process.platform === 'win32' ? '.cmd' : process.platform === 'darwin' ? '.command' : '.sh';
|
|
106
|
+
}
|
|
107
|
+
function clientsDir() {
|
|
108
|
+
return path.join(getOcrHomeDir(), 'clients');
|
|
109
|
+
}
|
|
110
|
+
export function launcherPath() {
|
|
111
|
+
return path.join(clientsDir(), `cursor-launcher${launcherExtension()}`);
|
|
112
|
+
}
|
|
113
|
+
/** The CLI launcher — written only while `cursor-agent` is installed. */
|
|
114
|
+
export function agentLauncherPath() {
|
|
115
|
+
return path.join(clientsDir(), `cursor-agent-launcher${launcherExtension()}`);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Loopback never enters the proxy hop. Cursor's Node legs inherit the proxy
|
|
119
|
+
* env vars set by the launcher, and proxying its own local services (language
|
|
120
|
+
* server, extension host, a project's dev server) would tie them to the
|
|
121
|
+
* gateway's lifetime. Both spellings are set on POSIX because libraries differ
|
|
122
|
+
* on which one they read; Windows env blocks are case-insensitive, so `set`
|
|
123
|
+
* emits ONE variable there.
|
|
124
|
+
*/
|
|
125
|
+
export const CURSOR_NO_PROXY = 'localhost,127.0.0.1,::1';
|
|
126
|
+
/**
|
|
127
|
+
* The launcher text for one platform. Pure so the env contract is testable
|
|
128
|
+
* without a real Cursor install:
|
|
129
|
+
* - `--proxy-server` covers Chromium legs;
|
|
130
|
+
* - lowercase `http(s)_proxy` covers Electron's Node/gRPC legs (they ignore
|
|
131
|
+
* the flag);
|
|
132
|
+
* - `NODE_EXTRA_CA_CERTS` covers Node's bundled Mozilla roots (the OS store
|
|
133
|
+
* is not consulted there);
|
|
134
|
+
* - `NO_PROXY`/`no_proxy` keeps loopback out of the proxy (one variable on
|
|
135
|
+
* Windows — the env block is case-insensitive there).
|
|
136
|
+
*
|
|
137
|
+
* Windows bodies open with `setlocal`: the `set` lines would otherwise rewrite
|
|
138
|
+
* the CALLING shell's proxy env for the rest of its life, and the agent body
|
|
139
|
+
* `call`s the target so an `exit` inside a `.cmd` shim cannot kill the caller.
|
|
140
|
+
*
|
|
141
|
+
* POSIX assignments quote the VALUE (`export K="v"`): a home directory with a
|
|
142
|
+
* space in it (routine on macOS) would otherwise truncate `NODE_EXTRA_CA_CERTS`
|
|
143
|
+
* at the first space. Both Windows bodies forward the caller's arguments with
|
|
144
|
+
* `%*` — `cmd.exe` re-expands them on `call`, which is the caller's business.
|
|
145
|
+
*/
|
|
146
|
+
export function buildCursorLaunchers(args) {
|
|
147
|
+
const userinfo = args.proxyCredential
|
|
148
|
+
? `ocr:${encodeURIComponent(args.proxyCredential)}@`
|
|
149
|
+
: '';
|
|
150
|
+
const proxy = `http://${userinfo}127.0.0.1:${args.port}`;
|
|
151
|
+
const win = args.platform === 'win32';
|
|
152
|
+
// Quote the value so a CA path containing `&`, `^` or spaces cannot break
|
|
153
|
+
// the script.
|
|
154
|
+
const env = (k, v) => (win ? `set "${k}=${v}"` : `export ${k}="${v}"`);
|
|
155
|
+
const envBlock = () => [
|
|
156
|
+
...(args.caPath ? [env('NODE_EXTRA_CA_CERTS', args.caPath)] : []),
|
|
157
|
+
env('https_proxy', proxy),
|
|
158
|
+
env('http_proxy', proxy),
|
|
159
|
+
env('NO_PROXY', CURSOR_NO_PROXY),
|
|
160
|
+
// Windows env blocks are case-insensitive: `no_proxy` IS `NO_PROXY`, so a
|
|
161
|
+
// second `set` would only overwrite the first line.
|
|
162
|
+
...(win ? [] : [env('no_proxy', CURSOR_NO_PROXY)]),
|
|
163
|
+
];
|
|
164
|
+
const main = win
|
|
165
|
+
? [
|
|
166
|
+
'@echo off',
|
|
167
|
+
'setlocal',
|
|
168
|
+
'REM omnicell-router-managed launcher: start Cursor through the OCR forward proxy.',
|
|
169
|
+
'REM Regenerated by `ocr setup cursor-proxy`; manual edits are overwritten on the next setup.',
|
|
170
|
+
...envBlock(),
|
|
171
|
+
`start "" "${args.binary}" --proxy-server=${proxy} %*`,
|
|
172
|
+
'',
|
|
173
|
+
].join('\r\n')
|
|
174
|
+
: [
|
|
175
|
+
'#!/bin/sh',
|
|
176
|
+
'# omnicell-router-managed launcher: start Cursor through the OCR forward proxy.',
|
|
177
|
+
'# Regenerated by `ocr setup cursor-proxy`; manual edits are overwritten on the next setup.',
|
|
178
|
+
...envBlock(),
|
|
179
|
+
// macOS: the `.command` runs inside a Terminal window, so `exec` would
|
|
180
|
+
// make Cursor that window's child — closing the window SIGHUPs Cursor.
|
|
181
|
+
// Detach instead; the Linux `.sh` stays `exec` (terminal-launched by
|
|
182
|
+
// design, and its exit status is the point).
|
|
183
|
+
args.platform === 'darwin'
|
|
184
|
+
? `nohup "${args.binary}" --proxy-server=${proxy} "$@" >/dev/null 2>&1 &`
|
|
185
|
+
: `exec "${args.binary}" --proxy-server=${proxy} "$@"`,
|
|
186
|
+
'',
|
|
187
|
+
].join('\n');
|
|
188
|
+
if (!args.agentBinary)
|
|
189
|
+
return { main };
|
|
190
|
+
const agent = win
|
|
191
|
+
? [
|
|
192
|
+
'@echo off',
|
|
193
|
+
'setlocal',
|
|
194
|
+
'REM omnicell-router-managed launcher: run cursor-agent through the OCR forward proxy.',
|
|
195
|
+
'REM Regenerated by `ocr setup cursor-proxy`; manual edits are overwritten on the next setup.',
|
|
196
|
+
...envBlock(),
|
|
197
|
+
// `call` + `exit /b`: the target may be a `.cmd` shim whose own `exit`
|
|
198
|
+
// would otherwise terminate the caller's cmd.exe.
|
|
199
|
+
`call "${args.agentBinary}" %*`,
|
|
200
|
+
'exit /b %ERRORLEVEL%',
|
|
201
|
+
'',
|
|
202
|
+
].join('\r\n')
|
|
203
|
+
: [
|
|
204
|
+
'#!/bin/sh',
|
|
205
|
+
'# omnicell-router-managed launcher: run cursor-agent through the OCR forward proxy.',
|
|
206
|
+
'# Regenerated by `ocr setup cursor-proxy`; manual edits are overwritten on the next setup.',
|
|
207
|
+
...envBlock(),
|
|
208
|
+
`exec "${args.agentBinary}" "$@"`,
|
|
209
|
+
'',
|
|
210
|
+
].join('\n');
|
|
211
|
+
return { main, agent };
|
|
212
|
+
}
|
|
213
|
+
export class CursorProxyClientAdapter {
|
|
214
|
+
name = 'cursor-proxy';
|
|
215
|
+
hookKind = 'launcher';
|
|
216
|
+
displayName = 'Cursor';
|
|
217
|
+
versionCmd = ['cursor', '--version'];
|
|
218
|
+
getConfigPath() {
|
|
219
|
+
// No client config file is owned — the meaningful artifact is the launcher.
|
|
220
|
+
return launcherPath();
|
|
221
|
+
}
|
|
222
|
+
async getStatus() {
|
|
223
|
+
const fp = resolveForwardProxyEndpoint();
|
|
224
|
+
const live = getForwardProxyStatus();
|
|
225
|
+
const launcher = fs.existsSync(launcherPath());
|
|
226
|
+
const binary = detectCursorBinary();
|
|
227
|
+
const versionProbe = await probeClientVersion(this.versionCmd);
|
|
228
|
+
const installed = !!binary || versionProbe !== null;
|
|
229
|
+
// Only probe when there is something to probe, and only through the TTL
|
|
230
|
+
// cache: an absent Cursor has no trust state worth three subprocesses.
|
|
231
|
+
const caTrusted = installed && fp ? (await probeCaTrustedCached(fp.caPath)).trusted : 'unknown';
|
|
232
|
+
// The CLI launcher is a second owned artifact: setup writes it only while
|
|
233
|
+
// `cursor-agent` is installed and removes it otherwise, so a file left from
|
|
234
|
+
// an earlier setup is shown too (stale, but the operator can still see it).
|
|
235
|
+
const agentLauncher = agentLauncherPath();
|
|
236
|
+
const agentLauncherExists = fs.existsSync(agentLauncher);
|
|
237
|
+
const artifacts = detectAgentBinary() || agentLauncherExists ? [{ path: agentLauncher, exists: agentLauncherExists }] : undefined;
|
|
238
|
+
let hooked = false;
|
|
239
|
+
let details;
|
|
240
|
+
if (!installed) {
|
|
241
|
+
details = 'Cursor not detected (no known install location and no `cursor` command on PATH)';
|
|
242
|
+
}
|
|
243
|
+
else if (!fp) {
|
|
244
|
+
details = 'forwardProxy disabled in config.yaml — enable it before hooking Cursor';
|
|
245
|
+
}
|
|
246
|
+
else if (!launcher) {
|
|
247
|
+
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 Cursor launcher`;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
hooked = true;
|
|
251
|
+
details = `Cursor starts via \`ocr cursor\` (or ${launcherPath()}) with --proxy-server=${fp.url}; quit Cursor 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'}`;
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
name: this.name,
|
|
255
|
+
displayName: this.displayName,
|
|
256
|
+
configPath: this.getConfigPath(),
|
|
257
|
+
exists: launcher,
|
|
258
|
+
hooked,
|
|
259
|
+
backupExists: false,
|
|
260
|
+
details,
|
|
261
|
+
// Slot-less by design: phase 1 publishes no model advertisement, so a
|
|
262
|
+
// picker here would be a control that silently discards the choice.
|
|
263
|
+
modelSlots: [],
|
|
264
|
+
artifacts,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
async setup(options) {
|
|
268
|
+
// The live runtime snapshot is the single source of truth — a fresh
|
|
269
|
+
// loadConfig() could advertise a port the running proxy no longer listens on.
|
|
270
|
+
const fp = resolveForwardProxyEndpoint();
|
|
271
|
+
if (!fp) {
|
|
272
|
+
return {
|
|
273
|
+
success: false,
|
|
274
|
+
reasonCode: 'forward_proxy_disabled',
|
|
275
|
+
message: 'forwardProxy is not enabled in config.yaml — set `forwardProxy.enabled: true` (and keep the gateway running) before hooking Cursor.',
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (!fs.existsSync(fp.caPath)) {
|
|
279
|
+
return {
|
|
280
|
+
success: false,
|
|
281
|
+
reasonCode: 'forward_proxy_ca_missing',
|
|
282
|
+
params: { path: fp.caPath },
|
|
283
|
+
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.`,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
let binary = detectCursorBinary();
|
|
287
|
+
if (!binary) {
|
|
288
|
+
const cli = await probeClientVersion(this.versionCmd);
|
|
289
|
+
if (cli === null) {
|
|
290
|
+
return {
|
|
291
|
+
success: false,
|
|
292
|
+
reasonCode: 'cursor_not_found',
|
|
293
|
+
message: 'Cursor was not detected — install Cursor (or put its `cursor` command on PATH) and retry. The launcher needs the real binary path.',
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
binary = 'cursor';
|
|
297
|
+
}
|
|
298
|
+
const port = Number.isFinite(options?.port) && options?.port > 0 ? options?.port : fp.port;
|
|
299
|
+
// Strict mode closes the proxy to every credential-less connection; the
|
|
300
|
+
// console passes the bound key so the launcher can carry it in the URL.
|
|
301
|
+
const proxyCredential = fp.requireCredential
|
|
302
|
+
? options?.apiKey?.trim() || process.env.OCR_PROXY_KEY?.trim()
|
|
303
|
+
: undefined;
|
|
304
|
+
if (fp.requireCredential && !proxyCredential) {
|
|
305
|
+
return {
|
|
306
|
+
success: false,
|
|
307
|
+
reasonCode: 'proxy_credential_required',
|
|
308
|
+
message: 'forwardProxy.requireCredential is on — setup needs the proxy key. Pick/bind a key in the console Client Hub, or point http(s)_proxy at http://ocr:<key>@host:port manually.',
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
const scripts = buildCursorLaunchers({
|
|
312
|
+
platform: process.platform,
|
|
313
|
+
binary,
|
|
314
|
+
agentBinary: detectAgentBinary(),
|
|
315
|
+
port,
|
|
316
|
+
caPath: fp.caPath,
|
|
317
|
+
...(proxyCredential ? { proxyCredential } : {}),
|
|
318
|
+
});
|
|
319
|
+
const lPath = launcherPath();
|
|
320
|
+
fs.mkdirSync(clientsDir(), { recursive: true });
|
|
321
|
+
const writeScript = (p, text) => {
|
|
322
|
+
const win = process.platform === 'win32';
|
|
323
|
+
// A credential-bearing launcher is owner-only; a plain one only needs
|
|
324
|
+
// the exec bit. `mode` applies on creation only, so chmod unconditionally.
|
|
325
|
+
const mode = proxyCredential ? 0o700 : 0o755;
|
|
326
|
+
fs.writeFileSync(p, text, win ? 'utf8' : { encoding: 'utf8', mode });
|
|
327
|
+
if (!win)
|
|
328
|
+
fs.chmodSync(p, mode);
|
|
329
|
+
};
|
|
330
|
+
writeScript(lPath, scripts.main);
|
|
331
|
+
if (scripts.agent) {
|
|
332
|
+
writeScript(agentLauncherPath(), scripts.agent);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
// No CLI detected: a launcher left from an earlier setup would point at a
|
|
336
|
+
// dead binary and a stale port. setup owns that file — remove it.
|
|
337
|
+
fs.rmSync(agentLauncherPath(), { force: true });
|
|
338
|
+
}
|
|
339
|
+
// The launcher is written and correct; what can STILL fail is the running
|
|
340
|
+
// stack. Report those as warnings, never gates: an operator commonly
|
|
341
|
+
// imports the root right AFTER hooking, and a blocked setup would be a
|
|
342
|
+
// dead end (the wizard that installs the CA lives on another page).
|
|
343
|
+
const warnings = await collectHookWarnings(fp, port);
|
|
344
|
+
return {
|
|
345
|
+
success: true,
|
|
346
|
+
message: `Cursor launcher written at ${lPath}. Start it via \`ocr cursor\` (Chromium legs use --proxy-server, Electron Node legs use http(s)_proxy + NODE_EXTRA_CA_CERTS) — the takeover happens at launch time; Cursor itself is untouched. Import the MITM CA (${fp.caPath}) into the OS trust store if Cursor still fails TLS to api2.cursor.sh. Quit Cursor fully before launching it through the proxy.`,
|
|
347
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
async teardown() {
|
|
351
|
+
const removed = [];
|
|
352
|
+
for (const p of [launcherPath(), agentLauncherPath()]) {
|
|
353
|
+
if (!fs.existsSync(p))
|
|
354
|
+
continue;
|
|
355
|
+
try {
|
|
356
|
+
fs.unlinkSync(p);
|
|
357
|
+
removed.push(p);
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
return {
|
|
361
|
+
success: false,
|
|
362
|
+
reasonCode: 'remove_failed',
|
|
363
|
+
params: { path: p, detail: String(err) },
|
|
364
|
+
message: `Failed to remove ${p}: ${String(err)}`,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (removed.length === 0) {
|
|
369
|
+
return { success: false, reasonCode: 'not_active', message: 'No Cursor launcher to delete — run `ocr setup cursor-proxy` first.' };
|
|
370
|
+
}
|
|
371
|
+
// The CA and Cursor's own files are intentionally untouched.
|
|
372
|
+
return {
|
|
373
|
+
success: true,
|
|
374
|
+
message: `Cursor launchers deleted (${removed.join(', ')}). Cursor itself was never modified — start it normally for a direct connection. The MITM CA remains in the trust store if you imported it manually.`,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Run one of the managed launchers, forwarding stdio and the launcher's exit code.
|
|
380
|
+
*
|
|
381
|
+
* `ocr cursor` / `ocr cursor-agent` go through the SCRIPT instead of re-deriving
|
|
382
|
+
* the proxy environment here: the launcher stays the single source of the env
|
|
383
|
+
* contract (flag for Chromium legs, lowercase http(s)_proxy + CA for Electron's
|
|
384
|
+
* Node legs), so a CLI launch and a double-click can never drift apart.
|
|
385
|
+
*
|
|
386
|
+
* `detached` flags the IDE launcher on win32/darwin, which returns as soon as
|
|
387
|
+
* the app is started (`start ""` / `nohup … &`): there the exit code is the
|
|
388
|
+
* LAUNCHER's, not the target's, and the target's own stdio never reaches us.
|
|
389
|
+
* The Linux `.sh` and the agent launchers stay attached, so their exit code is
|
|
390
|
+
* the real one.
|
|
391
|
+
*/
|
|
392
|
+
export async function runCursorLauncher(kind, argv) {
|
|
393
|
+
const detached = kind === 'ide' && process.platform !== 'linux';
|
|
394
|
+
const script = kind === 'ide' ? launcherPath() : agentLauncherPath();
|
|
395
|
+
if (!fs.existsSync(script)) {
|
|
396
|
+
return {
|
|
397
|
+
ok: false,
|
|
398
|
+
code: 1,
|
|
399
|
+
detached,
|
|
400
|
+
message: `${kind === 'ide' ? 'Cursor' : 'cursor-agent'} launcher not found at ${script} — run \`ocr setup cursor-proxy\`` +
|
|
401
|
+
`${kind === 'agent' ? ' (with the cursor-agent CLI installed)' : ''}.`,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
const win = process.platform === 'win32';
|
|
405
|
+
// `.cmd` needs cmd.exe; `quoteWindowsArgs` is the SAME quoting `runCommand`
|
|
406
|
+
// applies to Windows shims, so an argument survives the extra shell hop.
|
|
407
|
+
const args = win ? quoteWindowsArgs(argv) : argv;
|
|
408
|
+
const cmd = win && /\s/.test(script) ? `"${script}"` : script;
|
|
409
|
+
// Executor form on purpose: the project lib target predates
|
|
410
|
+
// `Promise.withResolvers`, and the child events are the only completion path.
|
|
411
|
+
return await new Promise(resolve => {
|
|
412
|
+
const child = spawn(cmd, args, { stdio: 'inherit', shell: win, windowsHide: true });
|
|
413
|
+
child.on('error', err => resolve({ ok: false, code: 1, detached, message: String(err) }));
|
|
414
|
+
child.on('close', (code, signal) => {
|
|
415
|
+
// A signal-killed child reports `code === null`; POSIX convention is
|
|
416
|
+
// 128 + signum, so a caller can tell an interrupt from a real failure.
|
|
417
|
+
const signum = signal ? os.constants.signals[signal] : undefined;
|
|
418
|
+
resolve({ ok: code === 0, code: code ?? (signum ? 128 + signum : 1), detached });
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientAdapter } from './base.js';
|
|
2
2
|
import { ClientHookStatus } from '../types.js';
|
|
3
3
|
export declare class DshClientAdapter implements ClientAdapter {
|
|
4
|
-
name:
|
|
5
|
-
hookKind:
|
|
4
|
+
name: "dsh";
|
|
5
|
+
hookKind: "config";
|
|
6
6
|
displayName: string;
|
|
7
7
|
/**
|
|
8
8
|
* The profiles ROOT (not one file): every profile under it is a hook
|
|
@@ -12,8 +12,8 @@ import { ClientHookStatus } from '../types.js';
|
|
|
12
12
|
* — the pre-write backup (`createBackup`) is the user-content safety net.
|
|
13
13
|
*/
|
|
14
14
|
export declare class GrokClientAdapter implements ClientAdapter {
|
|
15
|
-
name:
|
|
16
|
-
hookKind:
|
|
15
|
+
name: "grok";
|
|
16
|
+
hookKind: "config";
|
|
17
17
|
displayName: string;
|
|
18
18
|
/** Provider table id this adapter owns inside `[model_providers]`. */
|
|
19
19
|
private static readonly PROVIDER_ID;
|
|
@@ -20,14 +20,21 @@ export declare function getAllClientStatuses(options?: {
|
|
|
20
20
|
type LaunchVerbRow = {
|
|
21
21
|
client: string;
|
|
22
22
|
verb: string;
|
|
23
|
+
/** Retired spellings — resolved explicitly, never dispatched (see `ClientLaunchVerb.aliases`). */
|
|
24
|
+
aliases?: string[];
|
|
23
25
|
script: string;
|
|
24
26
|
detached: boolean;
|
|
25
27
|
summary?: string;
|
|
26
28
|
missingHint?: string;
|
|
27
29
|
};
|
|
28
30
|
export declare function listLaunchVerbs(): LaunchVerbRow[];
|
|
29
|
-
/** One launch verb by name, or undefined when nobody publishes it.
|
|
31
|
+
/** One launch verb by name, or undefined when nobody publishes it. A retired
|
|
32
|
+
* alias names nobody here: it resolves only through `currentLaunchVerb`. */
|
|
30
33
|
export declare function findLaunchVerb(verb: string): LaunchVerbRow | undefined;
|
|
34
|
+
/** The CURRENT spelling of a launch verb, whether `verb` is that spelling or a
|
|
35
|
+
* retired alias (`agy` → `antigravity-cli`), or undefined when nobody
|
|
36
|
+
* publishes either. Calls that must refuse a retired spelling use this. */
|
|
37
|
+
export declare function currentLaunchVerb(verb: string): string | undefined;
|
|
31
38
|
export declare function setupClient(name: string, options?: Parameters<ClientAdapter['setup']>[0]): Promise<ClientActionResult>;
|
|
32
39
|
export declare function teardownClient(name: string, options?: Parameters<ClientAdapter['teardown']>[0]): Promise<ClientActionResult>;
|
|
33
40
|
export {};
|
|
@@ -3,7 +3,8 @@ import { CORE_ADAPTERS } from './core-adapters.js';
|
|
|
3
3
|
import { retiredClientHint } from './reserved.js';
|
|
4
4
|
import { popularityRank } from '../../utils/popularity.js';
|
|
5
5
|
import { compareVersions } from '../../utils/semver.js';
|
|
6
|
-
import { getPluginClientAdapter, listPluginClientAdapters, pluginIdForClient } from './plugin-adapters.js';
|
|
6
|
+
import { getPluginClientAdapter, listPluginClientAdapters, pluginClientRank, pluginIdForClient } from './plugin-adapters.js';
|
|
7
|
+
import { noteClientSetup } from './activity.js';
|
|
7
8
|
/** The hooks this build ships (`core-adapters.ts`) — the authoritative answer
|
|
8
9
|
* for "what is always available", even before the plugin host has run. */
|
|
9
10
|
const adapters = CORE_ADAPTERS;
|
|
@@ -63,7 +64,8 @@ function unknownClientMessage(name) {
|
|
|
63
64
|
export function getAllClientAdapters() {
|
|
64
65
|
// Plugin rows ride AFTER the built-in ones: they are additive, and the
|
|
65
66
|
// console's roster order must not reshuffle when a package is installed.
|
|
66
|
-
const contributed = listPluginClientAdapters().sort((a, b) =>
|
|
67
|
+
const contributed = listPluginClientAdapters().sort((a, b) => (pluginClientRank(a.name) ?? Number.MAX_SAFE_INTEGER) - (pluginClientRank(b.name) ?? Number.MAX_SAFE_INTEGER) ||
|
|
68
|
+
a.name.localeCompare(b.name));
|
|
67
69
|
return [...ORDERED_ADAPTERS, ...contributed];
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
@@ -95,7 +97,9 @@ async function buildRoster() {
|
|
|
95
97
|
// publishes. Stamped here so no console table and no CLI constant has to
|
|
96
98
|
// know a client id in advance.
|
|
97
99
|
const pluginId = pluginIdForClient(adapter.name);
|
|
98
|
-
const
|
|
100
|
+
const published = adapter.launchVerbs?.() ?? [];
|
|
101
|
+
const launch = published.map((v) => v.verb);
|
|
102
|
+
const launchAliases = published.flatMap((v) => v.aliases ?? []);
|
|
99
103
|
return {
|
|
100
104
|
...status,
|
|
101
105
|
hookKind: adapter.hookKind,
|
|
@@ -103,7 +107,8 @@ async function buildRoster() {
|
|
|
103
107
|
...(adapter.shortName ? { shortName: adapter.shortName } : {}),
|
|
104
108
|
...(pluginId ? { pluginId } : {}),
|
|
105
109
|
...(adapter.catalogPlugin ? { catalogPlugin: adapter.catalogPlugin } : {}),
|
|
106
|
-
...(launch
|
|
110
|
+
...(launch.length > 0 ? { launch } : {}),
|
|
111
|
+
...(launchAliases.length > 0 ? { launchAliases } : {}),
|
|
107
112
|
};
|
|
108
113
|
}));
|
|
109
114
|
}
|
|
@@ -133,16 +138,33 @@ export function listLaunchVerbs() {
|
|
|
133
138
|
const verbs = [];
|
|
134
139
|
for (const adapter of getAllClientAdapters()) {
|
|
135
140
|
for (const v of adapter.launchVerbs?.() ?? []) {
|
|
136
|
-
|
|
141
|
+
const { aliases, ...row } = v;
|
|
142
|
+
verbs.push({ client: adapter.name, ...row, ...(aliases && aliases.length > 0 ? { aliases } : {}) });
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
145
|
return verbs;
|
|
140
146
|
}
|
|
141
|
-
/** One launch verb by name, or undefined when nobody publishes it.
|
|
147
|
+
/** One launch verb by name, or undefined when nobody publishes it. A retired
|
|
148
|
+
* alias names nobody here: it resolves only through `currentLaunchVerb`. */
|
|
142
149
|
export function findLaunchVerb(verb) {
|
|
143
150
|
const key = String(verb ?? '').trim();
|
|
144
151
|
return listLaunchVerbs().find((v) => v.verb === key);
|
|
145
152
|
}
|
|
153
|
+
/** The CURRENT spelling of a launch verb, whether `verb` is that spelling or a
|
|
154
|
+
* retired alias (`agy` → `antigravity-cli`), or undefined when nobody
|
|
155
|
+
* publishes either. Calls that must refuse a retired spelling use this. */
|
|
156
|
+
export function currentLaunchVerb(verb) {
|
|
157
|
+
const key = String(verb ?? '').trim().toLowerCase();
|
|
158
|
+
if (!key)
|
|
159
|
+
return undefined;
|
|
160
|
+
for (const v of listLaunchVerbs()) {
|
|
161
|
+
if (v.verb === key)
|
|
162
|
+
return key;
|
|
163
|
+
if ((v.aliases ?? []).includes(key))
|
|
164
|
+
return v.verb;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
146
168
|
export async function setupClient(name, options) {
|
|
147
169
|
// Plugin-contributed hooks (e.g. the packaged OpenCode proxy mode) are only
|
|
148
170
|
// resolvable once the plugin host has run in this process.
|
|
@@ -154,28 +176,40 @@ export async function setupClient(name, options) {
|
|
|
154
176
|
message: unknownClientMessage(name),
|
|
155
177
|
};
|
|
156
178
|
}
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
179
|
+
// Hook exclusivity is package-declared (`ClientAdapter.exclusiveWith`, one
|
|
180
|
+
// side naming the other is enough): enabling this hook tears down every
|
|
181
|
+
// installed, actually-hooked sibling — the one this hook names, and any
|
|
182
|
+
// installed hook that names this one — so `hooked` status never shows both
|
|
183
|
+
// at once. A failed sibling teardown is surfaced in the result message
|
|
161
184
|
// instead of silently swallowed.
|
|
185
|
+
const siblingIds = new Set(adapter.exclusiveWith ?? []);
|
|
186
|
+
for (const other of getAllClientAdapters()) {
|
|
187
|
+
if (other !== adapter && (other.exclusiveWith ?? []).includes(adapter.name))
|
|
188
|
+
siblingIds.add(other.name);
|
|
189
|
+
}
|
|
162
190
|
let siblingNote = '';
|
|
163
|
-
|
|
164
|
-
const sibling = name === 'opencode' ? 'opencode-gateway' : 'opencode';
|
|
191
|
+
for (const sibling of siblingIds) {
|
|
165
192
|
const siblingAdapter = getClientAdapter(sibling);
|
|
166
|
-
if (siblingAdapter
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
193
|
+
if (!siblingAdapter || siblingAdapter === adapter)
|
|
194
|
+
continue;
|
|
195
|
+
if (!(await siblingAdapter.getStatus()).hooked)
|
|
196
|
+
continue;
|
|
197
|
+
const r = await teardownClient(sibling).catch((err) => ({
|
|
198
|
+
success: false,
|
|
199
|
+
message: err instanceof Error ? err.message : String(err),
|
|
200
|
+
}));
|
|
201
|
+
if (!r.success)
|
|
202
|
+
siblingNote += ` (note: previous ${sibling} hook teardown failed: ${r.message})`;
|
|
174
203
|
}
|
|
175
204
|
const result = await adapter.setup(options);
|
|
176
205
|
// A hook flip invalidates the roster snapshot: the next read rebuilds.
|
|
177
|
-
|
|
206
|
+
// The success moment is also the client's "接入" timestamp — the activity
|
|
207
|
+
// ledger's fallback sort key, so a freshly hooked client floats up before
|
|
208
|
+
// it has sent any traffic.
|
|
209
|
+
if (result.success) {
|
|
178
210
|
rosterCache.at = 0;
|
|
211
|
+
noteClientSetup(name);
|
|
212
|
+
}
|
|
179
213
|
return siblingNote && result.success ? { ...result, message: result.message + siblingNote } : result;
|
|
180
214
|
}
|
|
181
215
|
export async function teardownClient(name, options) {
|
|
@@ -21,8 +21,8 @@ import { ClientHookStatus } from '../types.js';
|
|
|
21
21
|
* safety net.
|
|
22
22
|
*/
|
|
23
23
|
export declare class KimiClientAdapter implements ClientAdapter {
|
|
24
|
-
name:
|
|
25
|
-
hookKind:
|
|
24
|
+
name: "kimi";
|
|
25
|
+
hookKind: "config";
|
|
26
26
|
displayName: string;
|
|
27
27
|
/**
|
|
28
28
|
* Compatibility floor = the kimi-code changelog floor (0.2.0, 2026-05-26):
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
export interface ClientLaunchVerb {
|
|
13
13
|
/** The word after `ocr` (`cursor`, `cursor-agent`). */
|
|
14
14
|
verb: string;
|
|
15
|
+
/**
|
|
16
|
+
* Retired spellings of `verb` (`agy` after `antigravity-cli` took its name).
|
|
17
|
+
* `ocr setup ‹alias›` names the hook that publishes the verb, and `ocr ‹alias›`
|
|
18
|
+
* fails with the CURRENT spelling — a silent run would keep the old command
|
|
19
|
+
* in scripts forever, and a generic "unknown command" hides where it went.
|
|
20
|
+
* An alias is never dispatched and never listed in the help text.
|
|
21
|
+
*/
|
|
22
|
+
aliases?: string[];
|
|
15
23
|
/** Absolute path of the managed launcher script this verb runs. */
|
|
16
24
|
script: string;
|
|
17
25
|
/**
|
|
@@ -131,7 +131,7 @@ export async function resolveClientModelMeta(ids) {
|
|
|
131
131
|
}
|
|
132
132
|
const reg = registry.getModel(id);
|
|
133
133
|
if (reg) {
|
|
134
|
-
const supported = modelSupportsEfforts(reg.supportedReasoningEfforts, reg.supportsReasoningEffort);
|
|
134
|
+
const supported = modelSupportsEfforts(reg.supportedReasoningEfforts, reg.supportsReasoningEffort, reg.reasoningDisableable);
|
|
135
135
|
const cat = await findCatalogModel(id, catalogList);
|
|
136
136
|
out[id] = {
|
|
137
137
|
...(cat ? displayMeta(cat) : {}),
|
|
@@ -4,8 +4,8 @@ import { ClientHookStatus } from '../types.js';
|
|
|
4
4
|
* `.yaml` (omp's own precedence); the `.yml` name is the default target. */
|
|
5
5
|
export declare function resolveOmpModelsPath(dir: string): string;
|
|
6
6
|
export declare class OmpClientAdapter implements ClientAdapter {
|
|
7
|
-
name:
|
|
8
|
-
hookKind:
|
|
7
|
+
name: "omp";
|
|
8
|
+
hookKind: "config";
|
|
9
9
|
displayName: string;
|
|
10
10
|
/** models.yml (or models.yaml when only that exists) — the hook target. */
|
|
11
11
|
getConfigPath(): string;
|