@omnicross/cli-launcher 0.1.7 → 0.1.8
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/dist/index.cjs +52 -20
- package/dist/index.d.cts +20 -27
- package/dist/index.d.ts +20 -27
- package/dist/index.js +53 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -412,6 +412,17 @@ function createProcessSupervisor() {
|
|
|
412
412
|
var _completion = require('@omnicross/core/completion');
|
|
413
413
|
var _providerproxy = require('@omnicross/core/provider-proxy');
|
|
414
414
|
var CLAUDE_PROXY_API_KEY_SENTINEL = "omnicross-proxy";
|
|
415
|
+
function buildClaudeRuntimeLaunchDescriptor(baseUrl, model, routeToken) {
|
|
416
|
+
return {
|
|
417
|
+
env: {
|
|
418
|
+
ANTHROPIC_BASE_URL: baseUrl,
|
|
419
|
+
ANTHROPIC_AUTH_TOKEN: routeToken,
|
|
420
|
+
ANTHROPIC_API_KEY: CLAUDE_PROXY_API_KEY_SENTINEL,
|
|
421
|
+
ANTHROPIC_MODEL: model
|
|
422
|
+
},
|
|
423
|
+
extraArgs: []
|
|
424
|
+
};
|
|
425
|
+
}
|
|
415
426
|
async function buildClaudeCliLaunchConfig(inputs) {
|
|
416
427
|
const provider = await inputs.llmConfig.getProvider(inputs.providerId);
|
|
417
428
|
if (!provider) {
|
|
@@ -442,14 +453,9 @@ async function buildClaudeCliLaunchConfig(inputs) {
|
|
|
442
453
|
providerId: inputs.providerId,
|
|
443
454
|
model: inputs.model
|
|
444
455
|
});
|
|
445
|
-
const
|
|
446
|
-
ANTHROPIC_BASE_URL: baseUrl,
|
|
447
|
-
ANTHROPIC_AUTH_TOKEN: token,
|
|
448
|
-
ANTHROPIC_API_KEY: CLAUDE_PROXY_API_KEY_SENTINEL,
|
|
449
|
-
ANTHROPIC_MODEL: inputs.model
|
|
450
|
-
};
|
|
456
|
+
const descriptor = buildClaudeRuntimeLaunchDescriptor(baseUrl, inputs.model, token);
|
|
451
457
|
return {
|
|
452
|
-
env,
|
|
458
|
+
env: descriptor.env,
|
|
453
459
|
baseUrl,
|
|
454
460
|
onSessionEnd: () => {
|
|
455
461
|
try {
|
|
@@ -638,6 +644,9 @@ function resolveApiKey2(apiKey) {
|
|
|
638
644
|
// src/proxy-env/codex-proxy-env.ts
|
|
639
645
|
|
|
640
646
|
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
641
650
|
var CODEX_PROXY_PROVIDER_NAME = "omnicross";
|
|
642
651
|
var CODEX_PROXY_BASE_PATH = "/openai";
|
|
643
652
|
function buildCodexConfigOverrides(baseUrl) {
|
|
@@ -647,15 +656,13 @@ function buildCodexConfigOverrides(baseUrl) {
|
|
|
647
656
|
"-c",
|
|
648
657
|
`model_provider="${name}"`,
|
|
649
658
|
"-c",
|
|
650
|
-
`model_providers.${name}.name="
|
|
659
|
+
`model_providers.${name}.name="OmniCross"`,
|
|
651
660
|
"-c",
|
|
652
661
|
`model_providers.${name}.base_url="${providerBaseUrl}"`,
|
|
653
662
|
"-c",
|
|
654
663
|
`model_providers.${name}.wire_api="responses"`,
|
|
655
|
-
// requires_openai_auth is a boolean — UNQUOTED so the TOML override is typed
|
|
656
|
-
// as a bool, not the string "true".
|
|
657
664
|
"-c",
|
|
658
|
-
`model_providers.${name}.
|
|
665
|
+
`model_providers.${name}.env_key="${_providerproxy.ROUTE_LEASE_CODEX_TOKEN_ENV}"`,
|
|
659
666
|
// disable_response_storage: the CLI sends full context each turn (no
|
|
660
667
|
// server-side response store) — required because the proxy upstream is
|
|
661
668
|
// stateless w.r.t. Codex's response-id store (design Q3 contract).
|
|
@@ -663,6 +670,12 @@ function buildCodexConfigOverrides(baseUrl) {
|
|
|
663
670
|
"disable_response_storage=true"
|
|
664
671
|
];
|
|
665
672
|
}
|
|
673
|
+
function buildCodexRuntimeLaunchDescriptor(baseUrl, routeToken) {
|
|
674
|
+
return {
|
|
675
|
+
env: { [_providerproxy.ROUTE_LEASE_CODEX_TOKEN_ENV]: routeToken },
|
|
676
|
+
extraArgs: buildCodexConfigOverrides(baseUrl)
|
|
677
|
+
};
|
|
678
|
+
}
|
|
666
679
|
async function buildCodexLaunchConfig(inputs) {
|
|
667
680
|
const authMode = _nullishCoalesce(inputs.authMode, () => ( "byo"));
|
|
668
681
|
if (authMode === "byo") {
|
|
@@ -701,15 +714,9 @@ async function buildCodexLaunchConfig(inputs) {
|
|
|
701
714
|
model: inputs.model,
|
|
702
715
|
authMode
|
|
703
716
|
});
|
|
717
|
+
const descriptor = buildCodexRuntimeLaunchDescriptor(baseUrl, token);
|
|
704
718
|
return {
|
|
705
|
-
|
|
706
|
-
// Satisfy the CLI's `requires_openai_auth = true` precondition. The CLI
|
|
707
|
-
// forwards this as the Responses-API key; the resident proxy uses it as
|
|
708
|
-
// the route TOKEN (looked up, then discarded) and re-authenticates
|
|
709
|
-
// upstream from the route's own provider/subscription credential.
|
|
710
|
-
OPENAI_API_KEY: token
|
|
711
|
-
},
|
|
712
|
-
extraArgs: buildCodexConfigOverrides(baseUrl),
|
|
719
|
+
...descriptor,
|
|
713
720
|
baseUrl,
|
|
714
721
|
onSessionEnd: () => {
|
|
715
722
|
proxy.removeRoute(token);
|
|
@@ -724,6 +731,28 @@ function resolveApiKey3(apiKey) {
|
|
|
724
731
|
return apiKey;
|
|
725
732
|
}
|
|
726
733
|
|
|
734
|
+
// src/proxy-env/runtime-launch-descriptor.ts
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
var routeLeaseDescriptorPort = {
|
|
739
|
+
has(runtime) {
|
|
740
|
+
return runtime === "claude" || runtime === "codex";
|
|
741
|
+
},
|
|
742
|
+
build(runtime, input) {
|
|
743
|
+
switch (runtime) {
|
|
744
|
+
case "claude":
|
|
745
|
+
return buildClaudeRuntimeLaunchDescriptor(input.proxyBaseUrl, input.model, input.routeToken);
|
|
746
|
+
case "codex":
|
|
747
|
+
return buildCodexRuntimeLaunchDescriptor(input.proxyBaseUrl, input.routeToken);
|
|
748
|
+
default: {
|
|
749
|
+
const exhaustive = runtime;
|
|
750
|
+
throw new (0, _providerproxy.RouteLeaseError)("runtime_unsupported", `runtime adapter unavailable: ${String(exhaustive)}`);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
|
|
727
756
|
// src/index.ts
|
|
728
757
|
var instance = null;
|
|
729
758
|
function getProcessSupervisor() {
|
|
@@ -743,4 +772,7 @@ function getProcessSupervisor() {
|
|
|
743
772
|
|
|
744
773
|
|
|
745
774
|
|
|
746
|
-
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
exports.CHAT_PROXY_BASE_PATH = CHAT_PROXY_BASE_PATH; exports.CLAUDE_PROXY_API_KEY_SENTINEL = CLAUDE_PROXY_API_KEY_SENTINEL; exports.CODEX_PROXY_BASE_PATH = CODEX_PROXY_BASE_PATH; exports.CODEX_PROXY_PROVIDER_NAME = CODEX_PROXY_PROVIDER_NAME; exports.OPENCODE_PROXY_PROVIDER_ID = OPENCODE_PROXY_PROVIDER_ID; exports.OPENCODE_PROXY_TOKEN_ENV = OPENCODE_PROXY_TOKEN_ENV; exports.buildChatCliLaunchConfig = buildChatCliLaunchConfig; exports.buildClaudeCliLaunchConfig = buildClaudeCliLaunchConfig; exports.buildClaudeRuntimeLaunchDescriptor = buildClaudeRuntimeLaunchDescriptor; exports.buildCodexConfigOverrides = buildCodexConfigOverrides; exports.buildCodexLaunchConfig = buildCodexLaunchConfig; exports.buildCodexRuntimeLaunchDescriptor = buildCodexRuntimeLaunchDescriptor; exports.buildGeminiCliLaunchConfig = buildGeminiCliLaunchConfig; exports.getProcessSupervisor = getProcessSupervisor; exports.routeLeaseDescriptorPort = routeLeaseDescriptorPort;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ import { ChildProcess } from 'node:child_process';
|
|
|
4
4
|
export { PtyAdapterHandle } from './pty-adapter.cjs';
|
|
5
5
|
import { ProviderConfigSource, UsageRecorderImport } from '@omnicross/core';
|
|
6
6
|
import { ApiKeyPoolService } from '@omnicross/core/completion/ApiKeyPoolService';
|
|
7
|
+
import { RuntimeLaunchDescriptor, RouteAuthMode, RouteLeaseDescriptorPort } from '@omnicross/core/provider-proxy';
|
|
7
8
|
import { SubscriptionAuthProfile } from '@omnicross/core/pipeline/SubscriptionAuthSource';
|
|
8
|
-
import { RouteAuthMode } from '@omnicross/core/provider-proxy';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* child_process spawn adapter.
|
|
@@ -197,6 +197,8 @@ interface ClaudeCliLaunchConfigInputs {
|
|
|
197
197
|
/** Usage recorder — when set, anthropic-ingress usage is persisted. */
|
|
198
198
|
readonly usageRecorder?: UsageRecorderImport | null;
|
|
199
199
|
}
|
|
200
|
+
/** Pure Claude descriptor. It never reads credentials, registers routes, or writes files. */
|
|
201
|
+
declare function buildClaudeRuntimeLaunchDescriptor(baseUrl: string, model: string, routeToken: string): RuntimeLaunchDescriptor;
|
|
200
202
|
/**
|
|
201
203
|
* Build the env + route for a claude CLI redirect (BYO only). Validates the
|
|
202
204
|
* provider row + key up front (throws BEFORE registering a route when the
|
|
@@ -215,20 +217,15 @@ declare function buildClaudeCliLaunchConfig(inputs: ClaudeCliLaunchConfigInputs)
|
|
|
215
217
|
* `codex-responses-ingress` change): the Codex CLI does NOT honor an
|
|
216
218
|
* `OPENAI_BASE_URL` env var for base-url redirection. It is redirected via its
|
|
217
219
|
* config — `~/.codex/config.toml`'s `[model_providers.<name>]` block
|
|
218
|
-
* (`base_url`, `wire_api = "responses"`,
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* leaves the user's real config untouched (no file management, no rollback risk).
|
|
220
|
+
* (`base_url`, `wire_api = "responses"`, and a dedicated `env_key`) selected by
|
|
221
|
+
* `model_provider = "<name>"`. Codex exposes those config keys as command-line
|
|
222
|
+
* `-c key=value` overrides (the SAME mechanism the canvas-MCP and builtin-MCP CLI
|
|
223
|
+
* injectors already use for `mcp_servers.*`), so this builder returns the `-c`
|
|
224
|
+
* overrides as `extraArgs` rather than writing the user's `~/.codex/config.toml`
|
|
225
|
+
* on disk. This keeps redirection session-scoped and leaves user config untouched.
|
|
225
226
|
*
|
|
226
|
-
* The
|
|
227
|
-
*
|
|
228
|
-
* re-authenticates every upstream call with the resolved provider/subscription
|
|
229
|
-
* credential; the value the CLI forwards is never used upstream. We still inject
|
|
230
|
-
* a sentinel so the CLI's `requires_openai_auth = true` precondition is met
|
|
231
|
-
* without the CLI falling back to a real `~/.codex/auth.json`.
|
|
227
|
+
* The route token is supplied only through `OMNICROSS_CODEX_ROUTE_TOKEN`, named
|
|
228
|
+
* by the custom provider's `env_key`; no OpenAI login or auth file is required.
|
|
232
229
|
*
|
|
233
230
|
* What this builder returns (mirroring `ProviderEnvResult` from provider-env.ts):
|
|
234
231
|
* - `env` — env vars merged into the Codex subprocess (the auth sentinel).
|
|
@@ -282,21 +279,12 @@ interface CodexLaunchConfigInputs {
|
|
|
282
279
|
* Codex-specific `extraArgs` (config overrides) and the `baseUrl`.
|
|
283
280
|
*/
|
|
284
281
|
interface CodexLaunchConfig {
|
|
285
|
-
/**
|
|
286
|
-
* Env vars to merge into the Codex subprocess env. The Codex CLI's
|
|
287
|
-
* `requires_openai_auth = true` precondition is satisfied by a sentinel
|
|
288
|
-
* `OPENAI_API_KEY` (the value is never used upstream — the proxy re-auths).
|
|
289
|
-
*/
|
|
282
|
+
/** Env vars to merge into the Codex subprocess env, including its route token. */
|
|
290
283
|
readonly env: Record<string, string>;
|
|
291
284
|
/**
|
|
292
285
|
* `-c key=value` config overrides appended to the Codex argv. These override
|
|
293
|
-
* `~/.codex/config.toml` for THIS spawn only, pointing the CLI at the proxy
|
|
294
|
-
*
|
|
295
|
-
* `-c model_providers.omnicross.name="omnicross"`
|
|
296
|
-
* `-c model_providers.omnicross.base_url="http://127.0.0.1:<port>/openai"`
|
|
297
|
-
* `-c model_providers.omnicross.wire_api="responses"`
|
|
298
|
-
* `-c model_providers.omnicross.requires_openai_auth=true`
|
|
299
|
-
* (`requires_openai_auth` is an UNQUOTED boolean — TOML overrides are typed.)
|
|
286
|
+
* `~/.codex/config.toml` for THIS spawn only, pointing the CLI at the proxy and
|
|
287
|
+
* naming `OMNICROSS_CODEX_ROUTE_TOKEN` as the custom provider's `env_key`.
|
|
300
288
|
*/
|
|
301
289
|
readonly extraArgs: string[];
|
|
302
290
|
/** Stops the booted proxy listener. Best-effort; never throws. */
|
|
@@ -312,6 +300,8 @@ interface CodexLaunchConfig {
|
|
|
312
300
|
* @param baseUrl listener base (`http://127.0.0.1:<port>`)
|
|
313
301
|
*/
|
|
314
302
|
declare function buildCodexConfigOverrides(baseUrl: string): string[];
|
|
303
|
+
/** Pure, argv-safe Codex descriptor. It performs no route or process I/O. */
|
|
304
|
+
declare function buildCodexRuntimeLaunchDescriptor(baseUrl: string, routeToken: string): RuntimeLaunchDescriptor;
|
|
315
305
|
/**
|
|
316
306
|
* Boot the codex proxy route and return the launch redirection for the Codex CLI
|
|
317
307
|
* subprocess. The analogue of `buildProviderEnvWithProxy` for the Codex CLI.
|
|
@@ -329,6 +319,9 @@ declare function buildCodexConfigOverrides(baseUrl: string): string[];
|
|
|
329
319
|
*/
|
|
330
320
|
declare function buildCodexLaunchConfig(inputs: CodexLaunchConfigInputs): Promise<CodexLaunchConfig>;
|
|
331
321
|
|
|
322
|
+
/** Shared pure descriptor adapter used by RouteLeaseManager and compatibility wrappers. */
|
|
323
|
+
declare const routeLeaseDescriptorPort: RouteLeaseDescriptorPort;
|
|
324
|
+
|
|
332
325
|
/**
|
|
333
326
|
* Process Supervisor module — singleton accessor and re-exports.
|
|
334
327
|
*
|
|
@@ -337,4 +330,4 @@ declare function buildCodexLaunchConfig(inputs: CodexLaunchConfigInputs): Promis
|
|
|
337
330
|
|
|
338
331
|
declare function getProcessSupervisor(): ProcessSupervisor;
|
|
339
332
|
|
|
340
|
-
export { CHAT_PROXY_BASE_PATH, CLAUDE_PROXY_API_KEY_SENTINEL, CODEX_PROXY_BASE_PATH, CODEX_PROXY_PROVIDER_NAME, type ChatCliBackendId, type ChatCliLaunchConfig, type ChatCliLaunchConfigInputs, type ChildAdapterHandle, type ClaudeCliLaunchConfigInputs, type CodexLaunchConfig, type CodexLaunchConfigInputs, type GeminiCliLaunchConfigInputs, OPENCODE_PROXY_PROVIDER_ID, OPENCODE_PROXY_TOKEN_ENV, ProcessSupervisor, buildChatCliLaunchConfig, buildClaudeCliLaunchConfig, buildCodexConfigOverrides, buildCodexLaunchConfig, buildGeminiCliLaunchConfig, getProcessSupervisor };
|
|
333
|
+
export { CHAT_PROXY_BASE_PATH, CLAUDE_PROXY_API_KEY_SENTINEL, CODEX_PROXY_BASE_PATH, CODEX_PROXY_PROVIDER_NAME, type ChatCliBackendId, type ChatCliLaunchConfig, type ChatCliLaunchConfigInputs, type ChildAdapterHandle, type ClaudeCliLaunchConfigInputs, type CodexLaunchConfig, type CodexLaunchConfigInputs, type GeminiCliLaunchConfigInputs, OPENCODE_PROXY_PROVIDER_ID, OPENCODE_PROXY_TOKEN_ENV, ProcessSupervisor, buildChatCliLaunchConfig, buildClaudeCliLaunchConfig, buildClaudeRuntimeLaunchDescriptor, buildCodexConfigOverrides, buildCodexLaunchConfig, buildCodexRuntimeLaunchDescriptor, buildGeminiCliLaunchConfig, getProcessSupervisor, routeLeaseDescriptorPort };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { ChildProcess } from 'node:child_process';
|
|
|
4
4
|
export { PtyAdapterHandle } from './pty-adapter.js';
|
|
5
5
|
import { ProviderConfigSource, UsageRecorderImport } from '@omnicross/core';
|
|
6
6
|
import { ApiKeyPoolService } from '@omnicross/core/completion/ApiKeyPoolService';
|
|
7
|
+
import { RuntimeLaunchDescriptor, RouteAuthMode, RouteLeaseDescriptorPort } from '@omnicross/core/provider-proxy';
|
|
7
8
|
import { SubscriptionAuthProfile } from '@omnicross/core/pipeline/SubscriptionAuthSource';
|
|
8
|
-
import { RouteAuthMode } from '@omnicross/core/provider-proxy';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* child_process spawn adapter.
|
|
@@ -197,6 +197,8 @@ interface ClaudeCliLaunchConfigInputs {
|
|
|
197
197
|
/** Usage recorder — when set, anthropic-ingress usage is persisted. */
|
|
198
198
|
readonly usageRecorder?: UsageRecorderImport | null;
|
|
199
199
|
}
|
|
200
|
+
/** Pure Claude descriptor. It never reads credentials, registers routes, or writes files. */
|
|
201
|
+
declare function buildClaudeRuntimeLaunchDescriptor(baseUrl: string, model: string, routeToken: string): RuntimeLaunchDescriptor;
|
|
200
202
|
/**
|
|
201
203
|
* Build the env + route for a claude CLI redirect (BYO only). Validates the
|
|
202
204
|
* provider row + key up front (throws BEFORE registering a route when the
|
|
@@ -215,20 +217,15 @@ declare function buildClaudeCliLaunchConfig(inputs: ClaudeCliLaunchConfigInputs)
|
|
|
215
217
|
* `codex-responses-ingress` change): the Codex CLI does NOT honor an
|
|
216
218
|
* `OPENAI_BASE_URL` env var for base-url redirection. It is redirected via its
|
|
217
219
|
* config — `~/.codex/config.toml`'s `[model_providers.<name>]` block
|
|
218
|
-
* (`base_url`, `wire_api = "responses"`,
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* leaves the user's real config untouched (no file management, no rollback risk).
|
|
220
|
+
* (`base_url`, `wire_api = "responses"`, and a dedicated `env_key`) selected by
|
|
221
|
+
* `model_provider = "<name>"`. Codex exposes those config keys as command-line
|
|
222
|
+
* `-c key=value` overrides (the SAME mechanism the canvas-MCP and builtin-MCP CLI
|
|
223
|
+
* injectors already use for `mcp_servers.*`), so this builder returns the `-c`
|
|
224
|
+
* overrides as `extraArgs` rather than writing the user's `~/.codex/config.toml`
|
|
225
|
+
* on disk. This keeps redirection session-scoped and leaves user config untouched.
|
|
225
226
|
*
|
|
226
|
-
* The
|
|
227
|
-
*
|
|
228
|
-
* re-authenticates every upstream call with the resolved provider/subscription
|
|
229
|
-
* credential; the value the CLI forwards is never used upstream. We still inject
|
|
230
|
-
* a sentinel so the CLI's `requires_openai_auth = true` precondition is met
|
|
231
|
-
* without the CLI falling back to a real `~/.codex/auth.json`.
|
|
227
|
+
* The route token is supplied only through `OMNICROSS_CODEX_ROUTE_TOKEN`, named
|
|
228
|
+
* by the custom provider's `env_key`; no OpenAI login or auth file is required.
|
|
232
229
|
*
|
|
233
230
|
* What this builder returns (mirroring `ProviderEnvResult` from provider-env.ts):
|
|
234
231
|
* - `env` — env vars merged into the Codex subprocess (the auth sentinel).
|
|
@@ -282,21 +279,12 @@ interface CodexLaunchConfigInputs {
|
|
|
282
279
|
* Codex-specific `extraArgs` (config overrides) and the `baseUrl`.
|
|
283
280
|
*/
|
|
284
281
|
interface CodexLaunchConfig {
|
|
285
|
-
/**
|
|
286
|
-
* Env vars to merge into the Codex subprocess env. The Codex CLI's
|
|
287
|
-
* `requires_openai_auth = true` precondition is satisfied by a sentinel
|
|
288
|
-
* `OPENAI_API_KEY` (the value is never used upstream — the proxy re-auths).
|
|
289
|
-
*/
|
|
282
|
+
/** Env vars to merge into the Codex subprocess env, including its route token. */
|
|
290
283
|
readonly env: Record<string, string>;
|
|
291
284
|
/**
|
|
292
285
|
* `-c key=value` config overrides appended to the Codex argv. These override
|
|
293
|
-
* `~/.codex/config.toml` for THIS spawn only, pointing the CLI at the proxy
|
|
294
|
-
*
|
|
295
|
-
* `-c model_providers.omnicross.name="omnicross"`
|
|
296
|
-
* `-c model_providers.omnicross.base_url="http://127.0.0.1:<port>/openai"`
|
|
297
|
-
* `-c model_providers.omnicross.wire_api="responses"`
|
|
298
|
-
* `-c model_providers.omnicross.requires_openai_auth=true`
|
|
299
|
-
* (`requires_openai_auth` is an UNQUOTED boolean — TOML overrides are typed.)
|
|
286
|
+
* `~/.codex/config.toml` for THIS spawn only, pointing the CLI at the proxy and
|
|
287
|
+
* naming `OMNICROSS_CODEX_ROUTE_TOKEN` as the custom provider's `env_key`.
|
|
300
288
|
*/
|
|
301
289
|
readonly extraArgs: string[];
|
|
302
290
|
/** Stops the booted proxy listener. Best-effort; never throws. */
|
|
@@ -312,6 +300,8 @@ interface CodexLaunchConfig {
|
|
|
312
300
|
* @param baseUrl listener base (`http://127.0.0.1:<port>`)
|
|
313
301
|
*/
|
|
314
302
|
declare function buildCodexConfigOverrides(baseUrl: string): string[];
|
|
303
|
+
/** Pure, argv-safe Codex descriptor. It performs no route or process I/O. */
|
|
304
|
+
declare function buildCodexRuntimeLaunchDescriptor(baseUrl: string, routeToken: string): RuntimeLaunchDescriptor;
|
|
315
305
|
/**
|
|
316
306
|
* Boot the codex proxy route and return the launch redirection for the Codex CLI
|
|
317
307
|
* subprocess. The analogue of `buildProviderEnvWithProxy` for the Codex CLI.
|
|
@@ -329,6 +319,9 @@ declare function buildCodexConfigOverrides(baseUrl: string): string[];
|
|
|
329
319
|
*/
|
|
330
320
|
declare function buildCodexLaunchConfig(inputs: CodexLaunchConfigInputs): Promise<CodexLaunchConfig>;
|
|
331
321
|
|
|
322
|
+
/** Shared pure descriptor adapter used by RouteLeaseManager and compatibility wrappers. */
|
|
323
|
+
declare const routeLeaseDescriptorPort: RouteLeaseDescriptorPort;
|
|
324
|
+
|
|
332
325
|
/**
|
|
333
326
|
* Process Supervisor module — singleton accessor and re-exports.
|
|
334
327
|
*
|
|
@@ -337,4 +330,4 @@ declare function buildCodexLaunchConfig(inputs: CodexLaunchConfigInputs): Promis
|
|
|
337
330
|
|
|
338
331
|
declare function getProcessSupervisor(): ProcessSupervisor;
|
|
339
332
|
|
|
340
|
-
export { CHAT_PROXY_BASE_PATH, CLAUDE_PROXY_API_KEY_SENTINEL, CODEX_PROXY_BASE_PATH, CODEX_PROXY_PROVIDER_NAME, type ChatCliBackendId, type ChatCliLaunchConfig, type ChatCliLaunchConfigInputs, type ChildAdapterHandle, type ClaudeCliLaunchConfigInputs, type CodexLaunchConfig, type CodexLaunchConfigInputs, type GeminiCliLaunchConfigInputs, OPENCODE_PROXY_PROVIDER_ID, OPENCODE_PROXY_TOKEN_ENV, ProcessSupervisor, buildChatCliLaunchConfig, buildClaudeCliLaunchConfig, buildCodexConfigOverrides, buildCodexLaunchConfig, buildGeminiCliLaunchConfig, getProcessSupervisor };
|
|
333
|
+
export { CHAT_PROXY_BASE_PATH, CLAUDE_PROXY_API_KEY_SENTINEL, CODEX_PROXY_BASE_PATH, CODEX_PROXY_PROVIDER_NAME, type ChatCliBackendId, type ChatCliLaunchConfig, type ChatCliLaunchConfigInputs, type ChildAdapterHandle, type ClaudeCliLaunchConfigInputs, type CodexLaunchConfig, type CodexLaunchConfigInputs, type GeminiCliLaunchConfigInputs, OPENCODE_PROXY_PROVIDER_ID, OPENCODE_PROXY_TOKEN_ENV, ProcessSupervisor, buildChatCliLaunchConfig, buildClaudeCliLaunchConfig, buildClaudeRuntimeLaunchDescriptor, buildCodexConfigOverrides, buildCodexLaunchConfig, buildCodexRuntimeLaunchDescriptor, buildGeminiCliLaunchConfig, getProcessSupervisor, routeLeaseDescriptorPort };
|
package/dist/index.js
CHANGED
|
@@ -412,6 +412,17 @@ function createProcessSupervisor() {
|
|
|
412
412
|
import { resolveProviderEndpoint } from "@omnicross/core/completion";
|
|
413
413
|
import { getProviderProxy } from "@omnicross/core/provider-proxy";
|
|
414
414
|
var CLAUDE_PROXY_API_KEY_SENTINEL = "omnicross-proxy";
|
|
415
|
+
function buildClaudeRuntimeLaunchDescriptor(baseUrl, model, routeToken) {
|
|
416
|
+
return {
|
|
417
|
+
env: {
|
|
418
|
+
ANTHROPIC_BASE_URL: baseUrl,
|
|
419
|
+
ANTHROPIC_AUTH_TOKEN: routeToken,
|
|
420
|
+
ANTHROPIC_API_KEY: CLAUDE_PROXY_API_KEY_SENTINEL,
|
|
421
|
+
ANTHROPIC_MODEL: model
|
|
422
|
+
},
|
|
423
|
+
extraArgs: []
|
|
424
|
+
};
|
|
425
|
+
}
|
|
415
426
|
async function buildClaudeCliLaunchConfig(inputs) {
|
|
416
427
|
const provider = await inputs.llmConfig.getProvider(inputs.providerId);
|
|
417
428
|
if (!provider) {
|
|
@@ -442,14 +453,9 @@ async function buildClaudeCliLaunchConfig(inputs) {
|
|
|
442
453
|
providerId: inputs.providerId,
|
|
443
454
|
model: inputs.model
|
|
444
455
|
});
|
|
445
|
-
const
|
|
446
|
-
ANTHROPIC_BASE_URL: baseUrl,
|
|
447
|
-
ANTHROPIC_AUTH_TOKEN: token,
|
|
448
|
-
ANTHROPIC_API_KEY: CLAUDE_PROXY_API_KEY_SENTINEL,
|
|
449
|
-
ANTHROPIC_MODEL: inputs.model
|
|
450
|
-
};
|
|
456
|
+
const descriptor = buildClaudeRuntimeLaunchDescriptor(baseUrl, inputs.model, token);
|
|
451
457
|
return {
|
|
452
|
-
env,
|
|
458
|
+
env: descriptor.env,
|
|
453
459
|
baseUrl,
|
|
454
460
|
onSessionEnd: () => {
|
|
455
461
|
try {
|
|
@@ -637,7 +643,10 @@ function resolveApiKey2(apiKey) {
|
|
|
637
643
|
|
|
638
644
|
// src/proxy-env/codex-proxy-env.ts
|
|
639
645
|
import { resolveProviderEndpoint as resolveProviderEndpoint3 } from "@omnicross/core/completion";
|
|
640
|
-
import {
|
|
646
|
+
import {
|
|
647
|
+
getProviderProxy as getProviderProxy3,
|
|
648
|
+
ROUTE_LEASE_CODEX_TOKEN_ENV
|
|
649
|
+
} from "@omnicross/core/provider-proxy";
|
|
641
650
|
var CODEX_PROXY_PROVIDER_NAME = "omnicross";
|
|
642
651
|
var CODEX_PROXY_BASE_PATH = "/openai";
|
|
643
652
|
function buildCodexConfigOverrides(baseUrl) {
|
|
@@ -647,15 +656,13 @@ function buildCodexConfigOverrides(baseUrl) {
|
|
|
647
656
|
"-c",
|
|
648
657
|
`model_provider="${name}"`,
|
|
649
658
|
"-c",
|
|
650
|
-
`model_providers.${name}.name="
|
|
659
|
+
`model_providers.${name}.name="OmniCross"`,
|
|
651
660
|
"-c",
|
|
652
661
|
`model_providers.${name}.base_url="${providerBaseUrl}"`,
|
|
653
662
|
"-c",
|
|
654
663
|
`model_providers.${name}.wire_api="responses"`,
|
|
655
|
-
// requires_openai_auth is a boolean — UNQUOTED so the TOML override is typed
|
|
656
|
-
// as a bool, not the string "true".
|
|
657
664
|
"-c",
|
|
658
|
-
`model_providers.${name}.
|
|
665
|
+
`model_providers.${name}.env_key="${ROUTE_LEASE_CODEX_TOKEN_ENV}"`,
|
|
659
666
|
// disable_response_storage: the CLI sends full context each turn (no
|
|
660
667
|
// server-side response store) — required because the proxy upstream is
|
|
661
668
|
// stateless w.r.t. Codex's response-id store (design Q3 contract).
|
|
@@ -663,6 +670,12 @@ function buildCodexConfigOverrides(baseUrl) {
|
|
|
663
670
|
"disable_response_storage=true"
|
|
664
671
|
];
|
|
665
672
|
}
|
|
673
|
+
function buildCodexRuntimeLaunchDescriptor(baseUrl, routeToken) {
|
|
674
|
+
return {
|
|
675
|
+
env: { [ROUTE_LEASE_CODEX_TOKEN_ENV]: routeToken },
|
|
676
|
+
extraArgs: buildCodexConfigOverrides(baseUrl)
|
|
677
|
+
};
|
|
678
|
+
}
|
|
666
679
|
async function buildCodexLaunchConfig(inputs) {
|
|
667
680
|
const authMode = inputs.authMode ?? "byo";
|
|
668
681
|
if (authMode === "byo") {
|
|
@@ -701,15 +714,9 @@ async function buildCodexLaunchConfig(inputs) {
|
|
|
701
714
|
model: inputs.model,
|
|
702
715
|
authMode
|
|
703
716
|
});
|
|
717
|
+
const descriptor = buildCodexRuntimeLaunchDescriptor(baseUrl, token);
|
|
704
718
|
return {
|
|
705
|
-
|
|
706
|
-
// Satisfy the CLI's `requires_openai_auth = true` precondition. The CLI
|
|
707
|
-
// forwards this as the Responses-API key; the resident proxy uses it as
|
|
708
|
-
// the route TOKEN (looked up, then discarded) and re-authenticates
|
|
709
|
-
// upstream from the route's own provider/subscription credential.
|
|
710
|
-
OPENAI_API_KEY: token
|
|
711
|
-
},
|
|
712
|
-
extraArgs: buildCodexConfigOverrides(baseUrl),
|
|
719
|
+
...descriptor,
|
|
713
720
|
baseUrl,
|
|
714
721
|
onSessionEnd: () => {
|
|
715
722
|
proxy.removeRoute(token);
|
|
@@ -724,6 +731,28 @@ function resolveApiKey3(apiKey) {
|
|
|
724
731
|
return apiKey;
|
|
725
732
|
}
|
|
726
733
|
|
|
734
|
+
// src/proxy-env/runtime-launch-descriptor.ts
|
|
735
|
+
import {
|
|
736
|
+
RouteLeaseError
|
|
737
|
+
} from "@omnicross/core/provider-proxy";
|
|
738
|
+
var routeLeaseDescriptorPort = {
|
|
739
|
+
has(runtime) {
|
|
740
|
+
return runtime === "claude" || runtime === "codex";
|
|
741
|
+
},
|
|
742
|
+
build(runtime, input) {
|
|
743
|
+
switch (runtime) {
|
|
744
|
+
case "claude":
|
|
745
|
+
return buildClaudeRuntimeLaunchDescriptor(input.proxyBaseUrl, input.model, input.routeToken);
|
|
746
|
+
case "codex":
|
|
747
|
+
return buildCodexRuntimeLaunchDescriptor(input.proxyBaseUrl, input.routeToken);
|
|
748
|
+
default: {
|
|
749
|
+
const exhaustive = runtime;
|
|
750
|
+
throw new RouteLeaseError("runtime_unsupported", `runtime adapter unavailable: ${String(exhaustive)}`);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
|
|
727
756
|
// src/index.ts
|
|
728
757
|
var instance = null;
|
|
729
758
|
function getProcessSupervisor() {
|
|
@@ -739,8 +768,11 @@ export {
|
|
|
739
768
|
OPENCODE_PROXY_TOKEN_ENV,
|
|
740
769
|
buildChatCliLaunchConfig,
|
|
741
770
|
buildClaudeCliLaunchConfig,
|
|
771
|
+
buildClaudeRuntimeLaunchDescriptor,
|
|
742
772
|
buildCodexConfigOverrides,
|
|
743
773
|
buildCodexLaunchConfig,
|
|
774
|
+
buildCodexRuntimeLaunchDescriptor,
|
|
744
775
|
buildGeminiCliLaunchConfig,
|
|
745
|
-
getProcessSupervisor
|
|
776
|
+
getProcessSupervisor,
|
|
777
|
+
routeLeaseDescriptorPort
|
|
746
778
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnicross/cli-launcher",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Omnicross CLI-launcher 鈥?the ProcessSupervisor subprocess-lifecycle mechanism + per-CLI proxy-env wiring.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sayo (https://github.com/Dumoedss)",
|