omnicell-router 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +48 -20
- 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 +20 -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 +242 -51
- 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 +26 -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-Cn3QMOQx.js +1487 -0
- package/frontend/dist/assets/{index-CQSLGFTV.css → index-DxZ9MHKB.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/index-CLvxJjp_.js +0 -1476
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientHookKind, ClientHookStatus
|
|
1
|
+
import { ClientHookKind, ClientHookStatus } from '../types.js';
|
|
2
2
|
import type { ClientLaunchVerb } from './launcher.js';
|
|
3
3
|
/** Last-resort fallback URL when config is unreadable; mirrors the config default. */
|
|
4
4
|
export declare const OCR_DEFAULT_PORT = 4000;
|
|
@@ -79,7 +79,10 @@ export interface ClientActionWarning {
|
|
|
79
79
|
* the caller must fall back. */
|
|
80
80
|
export declare function pluginWarningText(labels: Record<string, string | Record<string, string>> | undefined, code: string, params?: Record<string, string>): string | undefined;
|
|
81
81
|
export interface ClientAdapter {
|
|
82
|
-
|
|
82
|
+
/** Any string id the package declares (ADR-0027: dynamic registration —
|
|
83
|
+
* `plugin-adapters.ts` refuses only core and retired ids). Core hooks type
|
|
84
|
+
* their literals through `CORE_ADAPTERS`' `CoreClientId` keys. */
|
|
85
|
+
name: string;
|
|
83
86
|
displayName: string;
|
|
84
87
|
/** Where the hook lands; the registry stamps it into every status row. */
|
|
85
88
|
hookKind: ClientHookKind;
|
|
@@ -91,6 +94,14 @@ export interface ClientAdapter {
|
|
|
91
94
|
* drives. Declared here so the console never carries a client→logo table.
|
|
92
95
|
*/
|
|
93
96
|
icon?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Hook ids this hook MUTUALLY EXCLUDES: setting this hook up tears the
|
|
99
|
+
* sibling down first, and the registry tears this hook down when one of the
|
|
100
|
+
* listed ids is set up (both directions need only ONE side to declare).
|
|
101
|
+
* Only ids that can actually be installed are legal; the pairing is
|
|
102
|
+
* consulted by the generic `setupClient` logic — never hardcoded per id.
|
|
103
|
+
*/
|
|
104
|
+
exclusiveWith?: readonly string[];
|
|
94
105
|
/**
|
|
95
106
|
* Bare product name, for a surface whose context already implies the variant
|
|
96
107
|
* (the Clients tab header shows `OpenCode`, the flat overview list shows
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientAdapter } from './base.js';
|
|
2
2
|
import { ClientHookStatus } from '../types.js';
|
|
3
3
|
export declare class ClaudeClientAdapter implements ClientAdapter {
|
|
4
|
-
name:
|
|
5
|
-
hookKind:
|
|
4
|
+
name: "claude";
|
|
5
|
+
hookKind: "config";
|
|
6
6
|
displayName: string;
|
|
7
7
|
getConfigPath(): string;
|
|
8
8
|
getStatus(): Promise<Omit<ClientHookStatus, 'hookKind'>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientAdapter } from './base.js';
|
|
2
2
|
import { ClientHookStatus } from '../types.js';
|
|
3
3
|
export declare class CodexClientAdapter implements ClientAdapter {
|
|
4
|
-
name:
|
|
5
|
-
hookKind:
|
|
4
|
+
name: "codex";
|
|
5
|
+
hookKind: "config";
|
|
6
6
|
displayName: string;
|
|
7
7
|
getConfigPath(): string;
|
|
8
8
|
getStatus(): Promise<Omit<ClientHookStatus, 'hookKind'>>;
|
|
@@ -18,8 +18,7 @@ import type { CoreClientId } from './reserved.js';
|
|
|
18
18
|
*
|
|
19
19
|
* Typed `Record<CoreClientId, …>`, not `Record<string, …>`: the key list in
|
|
20
20
|
* `reserved.ts` is the single source, so a hook added or removed here without
|
|
21
|
-
* the id list (or the other way round) is a compile error.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
21
|
+
* the id list (or the other way round) is a compile error. Package hooks are
|
|
22
|
+
* NOT typed here: they register any string id at runtime (ADR-0027), and core
|
|
23
|
+
* code must never string-reference one. */
|
|
25
24
|
export declare const CORE_ADAPTERS: Record<CoreClientId, ClientAdapter>;
|
|
@@ -26,10 +26,9 @@ import { WorkBuddyClientAdapter } from './workbuddy.js';
|
|
|
26
26
|
*
|
|
27
27
|
* Typed `Record<CoreClientId, …>`, not `Record<string, …>`: the key list in
|
|
28
28
|
* `reserved.ts` is the single source, so a hook added or removed here without
|
|
29
|
-
* the id list (or the other way round) is a compile error.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
29
|
+
* the id list (or the other way round) is a compile error. Package hooks are
|
|
30
|
+
* NOT typed here: they register any string id at runtime (ADR-0027), and core
|
|
31
|
+
* code must never string-reference one. */
|
|
33
32
|
export const CORE_ADAPTERS = {
|
|
34
33
|
opencode: new OpenCodeClientAdapter(),
|
|
35
34
|
claude: new ClaudeClientAdapter(),
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ClientAdapter, ClientActionResult } from './base.js';
|
|
2
|
+
import { ClientHookStatus } from '../types.js';
|
|
3
|
+
export declare function launcherPath(): string;
|
|
4
|
+
/** The CLI launcher — written only while `cursor-agent` is installed. */
|
|
5
|
+
export declare function agentLauncherPath(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Loopback never enters the proxy hop. Cursor's Node legs inherit the proxy
|
|
8
|
+
* env vars set by the launcher, and proxying its own local services (language
|
|
9
|
+
* server, extension host, a project's dev server) would tie them to the
|
|
10
|
+
* gateway's lifetime. Both spellings are set on POSIX because libraries differ
|
|
11
|
+
* on which one they read; Windows env blocks are case-insensitive, so `set`
|
|
12
|
+
* emits ONE variable there.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CURSOR_NO_PROXY = "localhost,127.0.0.1,::1";
|
|
15
|
+
export interface CursorLauncherScripts {
|
|
16
|
+
main: string;
|
|
17
|
+
agent?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The launcher text for one platform. Pure so the env contract is testable
|
|
21
|
+
* without a real Cursor install:
|
|
22
|
+
* - `--proxy-server` covers Chromium legs;
|
|
23
|
+
* - lowercase `http(s)_proxy` covers Electron's Node/gRPC legs (they ignore
|
|
24
|
+
* the flag);
|
|
25
|
+
* - `NODE_EXTRA_CA_CERTS` covers Node's bundled Mozilla roots (the OS store
|
|
26
|
+
* is not consulted there);
|
|
27
|
+
* - `NO_PROXY`/`no_proxy` keeps loopback out of the proxy (one variable on
|
|
28
|
+
* Windows — the env block is case-insensitive there).
|
|
29
|
+
*
|
|
30
|
+
* Windows bodies open with `setlocal`: the `set` lines would otherwise rewrite
|
|
31
|
+
* the CALLING shell's proxy env for the rest of its life, and the agent body
|
|
32
|
+
* `call`s the target so an `exit` inside a `.cmd` shim cannot kill the caller.
|
|
33
|
+
*
|
|
34
|
+
* POSIX assignments quote the VALUE (`export K="v"`): a home directory with a
|
|
35
|
+
* space in it (routine on macOS) would otherwise truncate `NODE_EXTRA_CA_CERTS`
|
|
36
|
+
* at the first space. Both Windows bodies forward the caller's arguments with
|
|
37
|
+
* `%*` — `cmd.exe` re-expands them on `call`, which is the caller's business.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildCursorLaunchers(args: {
|
|
40
|
+
platform: NodeJS.Platform;
|
|
41
|
+
binary: string;
|
|
42
|
+
agentBinary?: string | null;
|
|
43
|
+
port: number;
|
|
44
|
+
caPath?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Strict mode (`forwardProxy.requireCredential`) needs the key IN the proxy
|
|
47
|
+
* URL: Chromium can prompt, but the Electron Node/gRPC legs cannot. Only the
|
|
48
|
+
* console setup passes it (the launcher file then holds the secret; written
|
|
49
|
+
* 0600/0700 instead of the default).
|
|
50
|
+
*/
|
|
51
|
+
proxyCredential?: string;
|
|
52
|
+
}): CursorLauncherScripts;
|
|
53
|
+
export declare class CursorProxyClientAdapter implements ClientAdapter {
|
|
54
|
+
name: "cursor-proxy";
|
|
55
|
+
hookKind: "launcher";
|
|
56
|
+
displayName: string;
|
|
57
|
+
versionCmd: string[];
|
|
58
|
+
getConfigPath(): string;
|
|
59
|
+
getStatus(): Promise<Omit<ClientHookStatus, 'hookKind'>>;
|
|
60
|
+
setup(options?: {
|
|
61
|
+
port?: number;
|
|
62
|
+
apiKey?: string;
|
|
63
|
+
}): Promise<ClientActionResult>;
|
|
64
|
+
teardown(): Promise<ClientActionResult>;
|
|
65
|
+
}
|
|
66
|
+
/** Outcome of a passthrough launcher run. */
|
|
67
|
+
export interface CursorLaunchResult {
|
|
68
|
+
ok: boolean;
|
|
69
|
+
code: number;
|
|
70
|
+
/** Launcher returns before the target exits (IDE launcher on win32/darwin). */
|
|
71
|
+
detached: boolean;
|
|
72
|
+
message?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Run one of the managed launchers, forwarding stdio and the launcher's exit code.
|
|
76
|
+
*
|
|
77
|
+
* `ocr cursor` / `ocr cursor-agent` go through the SCRIPT instead of re-deriving
|
|
78
|
+
* the proxy environment here: the launcher stays the single source of the env
|
|
79
|
+
* contract (flag for Chromium legs, lowercase http(s)_proxy + CA for Electron's
|
|
80
|
+
* Node legs), so a CLI launch and a double-click can never drift apart.
|
|
81
|
+
*
|
|
82
|
+
* `detached` flags the IDE launcher on win32/darwin, which returns as soon as
|
|
83
|
+
* the app is started (`start ""` / `nohup … &`): there the exit code is the
|
|
84
|
+
* LAUNCHER's, not the target's, and the target's own stdio never reaches us.
|
|
85
|
+
* The Linux `.sh` and the agent launchers stay attached, so their exit code is
|
|
86
|
+
* the real one.
|
|
87
|
+
*/
|
|
88
|
+
export declare function runCursorLauncher(kind: 'ide' | 'agent', argv: string[]): Promise<CursorLaunchResult>;
|
|
@@ -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 {};
|