omnicell-router 0.8.1 → 0.8.4
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/auth/api-keys.js +11 -0
- package/backend/dist/auth/key-models.d.ts +36 -0
- package/backend/dist/auth/key-models.js +99 -0
- package/backend/dist/cli/clients/activity.d.ts +35 -0
- package/backend/dist/cli/clients/activity.js +69 -0
- package/backend/dist/cli/clients/codex.d.ts +70 -0
- package/backend/dist/cli/clients/codex.js +470 -57
- package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
- package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
- package/backend/dist/cli/clients/index.js +7 -1
- package/backend/dist/cli/clients/opencode.js +3 -2
- package/backend/dist/cli/clients/reserved.js +2 -0
- package/backend/dist/cli/types.d.ts +18 -0
- package/backend/dist/config/comments-en.js +5 -1
- package/backend/dist/config/comments-zh.js +5 -1
- package/backend/dist/config/defaults.d.ts +98 -1
- package/backend/dist/config/defaults.js +98 -1
- package/backend/dist/config/index.d.ts +15 -1
- package/backend/dist/config/index.js +35 -1
- package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
- package/backend/dist/config/migrations/v4-to-v5.js +42 -0
- package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
- package/backend/dist/config/migrations/v5-to-v6.js +29 -0
- package/backend/dist/config/schema.d.ts +3 -3
- package/backend/dist/config/schema.js +8 -4
- package/backend/dist/config/types.d.ts +54 -3
- package/backend/dist/forward-proxy/egress.js +13 -0
- package/backend/dist/forward-proxy/h2-forward.js +6 -5
- package/backend/dist/forward-proxy/index.js +5 -0
- package/backend/dist/forward-proxy/server.d.ts +12 -0
- package/backend/dist/forward-proxy/server.js +113 -15
- package/backend/dist/index.js +6 -1
- package/backend/dist/ir/adapters/openai-chat.js +5 -3
- package/backend/dist/ir/adapters/openai-responses-output.js +2 -2
- package/backend/dist/ir/adapters/openai-responses.d.ts +33 -0
- package/backend/dist/ir/adapters/openai-responses.js +44 -2
- package/backend/dist/ir/capabilities.js +4 -0
- package/backend/dist/ir/validate.d.ts +24 -0
- package/backend/dist/ir/validate.js +113 -63
- package/backend/dist/opencode/catalog/auto-pull.js +8 -7
- package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
- package/backend/dist/opencode/catalog/ocr-store.js +2 -2
- package/backend/dist/opencode/catalog/overrides-store.d.ts +5 -3
- package/backend/dist/opencode/catalog/overrides-store.js +22 -19
- package/backend/dist/opencode/catalog/repository.js +3 -3
- package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
- package/backend/dist/opencode/catalog/sources/models-dev.js +29 -11
- package/backend/dist/opencode/catalog/types.d.ts +7 -9
- package/backend/dist/opencode/credentials/def-materialize.js +27 -21
- package/backend/dist/opencode/migrate/engine.d.ts +20 -0
- package/backend/dist/opencode/migrate/engine.js +71 -0
- package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
- package/backend/dist/opencode/migrate/migrator.js +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
- package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
- package/backend/dist/opencode/provider-def-adapters.js +43 -27
- package/backend/dist/opencode/provider-defs.d.ts +10 -16
- package/backend/dist/opencode/provider-defs.js +45 -45
- package/backend/dist/opencode/user-config.d.ts +23 -26
- package/backend/dist/opencode/user-config.js +95 -77
- package/backend/dist/pipeline/orchestrator.js +17 -7
- package/backend/dist/plugins/builtin/model-gateway.js +38 -12
- package/backend/dist/plugins/host.d.ts +2 -2
- package/backend/dist/plugins/host.js +15 -12
- package/backend/dist/providers/boot-direct.js +32 -8
- package/backend/dist/providers/dial-wire.d.ts +17 -0
- package/backend/dist/providers/dial-wire.js +49 -0
- package/backend/dist/providers/protocols-field.d.ts +24 -0
- package/backend/dist/providers/protocols-field.js +66 -0
- package/backend/dist/providers/registry.d.ts +3 -1
- package/backend/dist/providers/registry.js +23 -7
- package/backend/dist/quota/cli-login.js +3 -1
- package/backend/dist/routes/console.js +120 -95
- package/backend/dist/server.js +99 -2
- package/backend/dist/surfaces/anthropic.js +4 -1
- package/backend/dist/surfaces/body-admission.d.ts +279 -0
- package/backend/dist/surfaces/body-admission.js +613 -0
- package/backend/dist/surfaces/transport-node-http.d.ts +44 -5
- package/backend/dist/surfaces/transport-node-http.js +86 -13
- package/backend/dist/utils/server-liveness.d.ts +27 -0
- package/backend/dist/utils/server-liveness.js +31 -0
- package/frontend/dist/assets/{index-Cn3QMOQx.js → index-Dk76uc7e.js} +398 -363
- package/frontend/dist/assets/{index-DxZ9MHKB.css → index-KI1OW5x6.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
|
@@ -168,6 +168,14 @@ export function updateApiKey(id, updates) {
|
|
|
168
168
|
if (!saveResult.success) {
|
|
169
169
|
return { success: false, error: saveResult.error || 'Failed to persist API Key changes' };
|
|
170
170
|
}
|
|
171
|
+
// Follow catalogs snapshot this key's allowed model ids — only a modelAccess
|
|
172
|
+
// change rewrites that list. enabled / expiresAt affect auth usability only
|
|
173
|
+
// (calls already fail); same rationale as deleteApiKey (no sync).
|
|
174
|
+
if (updates.modelAccess !== undefined) {
|
|
175
|
+
void import('../cli/clients/follow-catalog-sync.js')
|
|
176
|
+
.then((m) => m.requestFollowCatalogSync({ reason: 'key', keyId: id }))
|
|
177
|
+
.catch(() => { });
|
|
178
|
+
}
|
|
171
179
|
return { success: true, data: updated };
|
|
172
180
|
}
|
|
173
181
|
/**
|
|
@@ -184,5 +192,8 @@ export function deleteApiKey(id) {
|
|
|
184
192
|
if (!saveResult.success) {
|
|
185
193
|
return { success: false, error: saveResult.error || 'Failed to remove API Key from config' };
|
|
186
194
|
}
|
|
195
|
+
// No follow-catalog sync on delete: inbound calls already fail at auth, and
|
|
196
|
+
// the sync pass cannot rewrite a catalog without a usable key — it would only
|
|
197
|
+
// paint card issues. Operator tears down / re-hooks when ready.
|
|
187
198
|
return { success: true };
|
|
188
199
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective model view for ONE API key — what the key can see & use right now.
|
|
3
|
+
* Shared by the admin preview (`GET /api/admin/api-keys/:id/models`) and the
|
|
4
|
+
* follow-catalog auto-resync path so both snapshots stay identical.
|
|
5
|
+
*/
|
|
6
|
+
import type { ProviderRegistry } from '../providers/registry.js';
|
|
7
|
+
export type KeyModelRow = {
|
|
8
|
+
id: string;
|
|
9
|
+
kind: 'auto' | 'tier' | 'combo' | 'model' | 'variant';
|
|
10
|
+
provider: string;
|
|
11
|
+
tiers?: string[];
|
|
12
|
+
tier?: string;
|
|
13
|
+
virtual: boolean;
|
|
14
|
+
allowed: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type KeyModelsView = {
|
|
17
|
+
status: 'ok';
|
|
18
|
+
mode: string;
|
|
19
|
+
policyModels: string[];
|
|
20
|
+
models: KeyModelRow[];
|
|
21
|
+
};
|
|
22
|
+
export type KeyModelsLookupError = {
|
|
23
|
+
status: 'error';
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Build the effective catalog for `keyId`. Returns an error shape when the key
|
|
28
|
+
* is unknown so callers can map to 404 without re-implementing the lookup.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildKeyModelsView(keyId: string, registry: ProviderRegistry): KeyModelsView | KeyModelsLookupError;
|
|
31
|
+
/** Allowed concrete / virtual ids for a follow-mode snapshot. */
|
|
32
|
+
export declare function allowedFollowLists(view: KeyModelsView): {
|
|
33
|
+
extraModels: string[];
|
|
34
|
+
virtualModels: string[];
|
|
35
|
+
allAllowedIds: string[];
|
|
36
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { listApiKeys } from './api-keys.js';
|
|
2
|
+
import { getModelAccessPolicy, isAutoEntryUsable, isModelAllowed, isModelAllowedInTiers, tierFromVirtualEntry, } from './model-access.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build the effective catalog for `keyId`. Returns an error shape when the key
|
|
5
|
+
* is unknown so callers can map to 404 without re-implementing the lookup.
|
|
6
|
+
*/
|
|
7
|
+
export function buildKeyModelsView(keyId, registry) {
|
|
8
|
+
const key = listApiKeys(false).find((k) => k.id === keyId);
|
|
9
|
+
if (!key) {
|
|
10
|
+
return { status: 'error', message: `API Key '${keyId}' not found` };
|
|
11
|
+
}
|
|
12
|
+
const policy = getModelAccessPolicy(key);
|
|
13
|
+
const registered = registry.getAllModels().map((m) => ({
|
|
14
|
+
id: m.id,
|
|
15
|
+
kind: 'model',
|
|
16
|
+
provider: m.provider,
|
|
17
|
+
// FULL membership set (pools are a per-tier projection — a model may
|
|
18
|
+
// belong to several tiers): tierAllowed counts every pool the model can
|
|
19
|
+
// route toward, so auto-X viability never misses a multi-pool member.
|
|
20
|
+
tiers: registry.tiersOf(m),
|
|
21
|
+
virtual: false,
|
|
22
|
+
allowed: isModelAllowedInTiers(m.id, policy, registry.tiersOf(m)),
|
|
23
|
+
}));
|
|
24
|
+
const tierAllowed = (t) => registered.some((m) => m.tiers?.includes(t) && m.allowed);
|
|
25
|
+
// Virtual auto* rows honor runtime viability (mirrors /v1/models): bare
|
|
26
|
+
// `auto` needs an allowed model in ANY tier, auto-X in tier X.
|
|
27
|
+
const virtual = ['auto', 'lite', 'plus', 'pro', 'ultra'].map((id) => ({
|
|
28
|
+
id,
|
|
29
|
+
kind: (id === 'auto' ? 'auto' : 'tier'),
|
|
30
|
+
provider: 'omnicell-router',
|
|
31
|
+
tier: tierFromVirtualEntry(id),
|
|
32
|
+
virtual: true,
|
|
33
|
+
allowed: isAutoEntryUsable(id, policy, tierAllowed),
|
|
34
|
+
}));
|
|
35
|
+
// Combo rows (mirrors /v1/models): routable virtual ids, but concrete
|
|
36
|
+
// selectable entries — NOT auto*-virtual, so follow-mode snapshots keep
|
|
37
|
+
// them. A combo passes only when EVERY member is allowed (the inference
|
|
38
|
+
// entry gate; no silent composition change).
|
|
39
|
+
const combos = registry.getCombos().map((c) => ({
|
|
40
|
+
id: c.id,
|
|
41
|
+
kind: 'combo',
|
|
42
|
+
provider: 'omnicell-router',
|
|
43
|
+
tier: '',
|
|
44
|
+
virtual: false,
|
|
45
|
+
allowed: registry.resolveCombo(c.id).every((mem) => isModelAllowed(mem.id, policy, mem.tier)),
|
|
46
|
+
}));
|
|
47
|
+
// Variant rows (mirrors /v1/models): `base-variant` ids resolve to the
|
|
48
|
+
// base model with a pinned reasoning effort; the policy verdict inherits
|
|
49
|
+
// from the base id.
|
|
50
|
+
const variants = registry.getVariantExposures().map(({ id, base }) => ({
|
|
51
|
+
id,
|
|
52
|
+
kind: 'variant',
|
|
53
|
+
provider: base.provider,
|
|
54
|
+
tiers: registry.tiersOf(base),
|
|
55
|
+
virtual: false,
|
|
56
|
+
allowed: isModelAllowedInTiers(base.id, policy, registry.tiersOf(base)),
|
|
57
|
+
}));
|
|
58
|
+
// Order mirrors the /v1/models wire body EXACTLY (the console list is a
|
|
59
|
+
// pure re-rendering of that payload — same rows, same sequence). The wire
|
|
60
|
+
// builds a provider map whose insertion order IS the display order: the
|
|
61
|
+
// omnicell-router virtual provider (auto alias → tier aliases → combos)
|
|
62
|
+
// first, then concrete providers in registry first-appearance order, each
|
|
63
|
+
// carrying its concrete models then its variant siblings.
|
|
64
|
+
const providerRows = new Map();
|
|
65
|
+
const ensureProviderRows = (pid) => {
|
|
66
|
+
let rows = providerRows.get(pid);
|
|
67
|
+
if (!rows) {
|
|
68
|
+
rows = [];
|
|
69
|
+
providerRows.set(pid, rows);
|
|
70
|
+
}
|
|
71
|
+
return rows;
|
|
72
|
+
};
|
|
73
|
+
for (const m of registry.getAllModels()) {
|
|
74
|
+
ensureProviderRows(m.provider).push(registered.find((r) => r.id === m.id));
|
|
75
|
+
}
|
|
76
|
+
for (const v of variants)
|
|
77
|
+
ensureProviderRows(v.provider).push(v);
|
|
78
|
+
const models = [
|
|
79
|
+
...virtual,
|
|
80
|
+
...combos,
|
|
81
|
+
...[...providerRows.entries()].filter(([pid]) => pid !== 'omnicell-router').flatMap(([, rows]) => rows),
|
|
82
|
+
];
|
|
83
|
+
return {
|
|
84
|
+
status: 'ok',
|
|
85
|
+
mode: policy?.mode ?? 'none',
|
|
86
|
+
policyModels: policy?.models ?? [],
|
|
87
|
+
models,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Allowed concrete / virtual ids for a follow-mode snapshot. */
|
|
91
|
+
export function allowedFollowLists(view) {
|
|
92
|
+
const extraModels = view.models.filter((m) => !m.virtual && m.allowed).map((m) => m.id);
|
|
93
|
+
const virtualModels = view.models.filter((m) => m.virtual && m.allowed).map((m) => m.id);
|
|
94
|
+
return {
|
|
95
|
+
extraModels,
|
|
96
|
+
virtualModels,
|
|
97
|
+
allAllowedIds: [...virtualModels, ...extraModels],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-client activity ledger — the console Clients page's dynamic sort key.
|
|
3
|
+
*
|
|
4
|
+
* A pure in-memory map, two timestamps per client ADAPTER name (the roster
|
|
5
|
+
* row key; there is no per-instance id — a family adapter is still one row):
|
|
6
|
+
*
|
|
7
|
+
* - `lastActiveAt` — stamped by the gateway's auth gate when an inference
|
|
8
|
+
* request arrives whose User-Agent fingerprints a known client CLI. The UA
|
|
9
|
+
* is forgeable and the fingerprint table is deliberately incomplete: this
|
|
10
|
+
* is DISPLAY-ONLY state (same doctrine as utils/harness-profiles.ts) — it
|
|
11
|
+
* never gates, rates or routes anything, so a spoofed or unknown UA costs
|
|
12
|
+
* at most a wrong card position.
|
|
13
|
+
* - `lastSetupAt` — stamped when `setupClient()` hooks a client successfully
|
|
14
|
+
* (the hooking moment — first takeover or a re-hook alike), so a freshly
|
|
15
|
+
* hooked client floats up even before it has sent any traffic.
|
|
16
|
+
*
|
|
17
|
+
* Memory-only by design: a gateway restart clears activity, and the roster
|
|
18
|
+
* falls back to `lastSetupAt` then the registry order. Nothing is persisted,
|
|
19
|
+
* nothing leaves the process.
|
|
20
|
+
*/
|
|
21
|
+
/** Record that `name` was hooked (setup succeeded) at `at`. */
|
|
22
|
+
export declare function noteClientSetup(name: string, at?: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Stamp activity for the client a request's User-Agent fingerprints, if any.
|
|
25
|
+
* Unknown / absent UAs are a no-op. Called per inference request — keep it
|
|
26
|
+
* allocation-free on the miss path.
|
|
27
|
+
*/
|
|
28
|
+
export declare function noteClientActivityFromUserAgent(ua: string | undefined, at?: number): void;
|
|
29
|
+
/** Activity timestamps for the clients the map knows about, keyed by adapter name. */
|
|
30
|
+
export declare function clientActivitySnapshot(): Record<string, {
|
|
31
|
+
lastActiveAt?: number;
|
|
32
|
+
lastSetupAt?: number;
|
|
33
|
+
}>;
|
|
34
|
+
/** Test reset — clears both maps (activity is process-local state). */
|
|
35
|
+
export declare function resetClientActivity(): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-client activity ledger — the console Clients page's dynamic sort key.
|
|
3
|
+
*
|
|
4
|
+
* A pure in-memory map, two timestamps per client ADAPTER name (the roster
|
|
5
|
+
* row key; there is no per-instance id — a family adapter is still one row):
|
|
6
|
+
*
|
|
7
|
+
* - `lastActiveAt` — stamped by the gateway's auth gate when an inference
|
|
8
|
+
* request arrives whose User-Agent fingerprints a known client CLI. The UA
|
|
9
|
+
* is forgeable and the fingerprint table is deliberately incomplete: this
|
|
10
|
+
* is DISPLAY-ONLY state (same doctrine as utils/harness-profiles.ts) — it
|
|
11
|
+
* never gates, rates or routes anything, so a spoofed or unknown UA costs
|
|
12
|
+
* at most a wrong card position.
|
|
13
|
+
* - `lastSetupAt` — stamped when `setupClient()` hooks a client successfully
|
|
14
|
+
* (the hooking moment — first takeover or a re-hook alike), so a freshly
|
|
15
|
+
* hooked client floats up even before it has sent any traffic.
|
|
16
|
+
*
|
|
17
|
+
* Memory-only by design: a gateway restart clears activity, and the roster
|
|
18
|
+
* falls back to `lastSetupAt` then the registry order. Nothing is persisted,
|
|
19
|
+
* nothing leaves the process.
|
|
20
|
+
*/
|
|
21
|
+
const lastActiveAt = new Map();
|
|
22
|
+
const lastSetupAt = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* UA → client-adapter-name fingerprints — first match wins. Only confident,
|
|
25
|
+
* observed wire spellings belong here (measured on real traffic, like the
|
|
26
|
+
* harness-profiles evidence rule); a speculative entry mis-sorts a card.
|
|
27
|
+
* Known CLI User-Agents not listed (kimi, openclaw, dsh, …) simply never
|
|
28
|
+
* move in the sort — add each only once observed.
|
|
29
|
+
*/
|
|
30
|
+
const UA_MATCHERS = [
|
|
31
|
+
{ match: /claude-cli\//i, client: 'claude' },
|
|
32
|
+
{ match: /opencode\//i, client: 'opencode' },
|
|
33
|
+
// ChatGPT Desktop and Codex CLI share the one Codex card / ~/.codex hook.
|
|
34
|
+
{ match: /chatgpt/i, client: 'codex' },
|
|
35
|
+
{ match: /codex/i, client: 'codex' },
|
|
36
|
+
];
|
|
37
|
+
/** Record that `name` was hooked (setup succeeded) at `at`. */
|
|
38
|
+
export function noteClientSetup(name, at = Date.now()) {
|
|
39
|
+
lastSetupAt.set(name, at);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Stamp activity for the client a request's User-Agent fingerprints, if any.
|
|
43
|
+
* Unknown / absent UAs are a no-op. Called per inference request — keep it
|
|
44
|
+
* allocation-free on the miss path.
|
|
45
|
+
*/
|
|
46
|
+
export function noteClientActivityFromUserAgent(ua, at = Date.now()) {
|
|
47
|
+
if (!ua)
|
|
48
|
+
return;
|
|
49
|
+
for (const entry of UA_MATCHERS) {
|
|
50
|
+
if (entry.match.test(ua)) {
|
|
51
|
+
lastActiveAt.set(entry.client, at);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Activity timestamps for the clients the map knows about, keyed by adapter name. */
|
|
57
|
+
export function clientActivitySnapshot() {
|
|
58
|
+
const out = {};
|
|
59
|
+
for (const [name, at] of lastSetupAt)
|
|
60
|
+
out[name] = { lastSetupAt: at };
|
|
61
|
+
for (const [name, at] of lastActiveAt)
|
|
62
|
+
out[name] = { ...out[name], lastActiveAt: at };
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/** Test reset — clears both maps (activity is process-local state). */
|
|
66
|
+
export function resetClientActivity() {
|
|
67
|
+
lastActiveAt.clear();
|
|
68
|
+
lastSetupAt.clear();
|
|
69
|
+
}
|
|
@@ -1,15 +1,57 @@
|
|
|
1
1
|
import { ClientAdapter } from './base.js';
|
|
2
2
|
import { ClientHookStatus } from '../types.js';
|
|
3
|
+
/** One Codex-native catalog row (stock OpenAI entry or synthetic OCR id). */
|
|
4
|
+
export type CodexStockModel = Record<string, unknown> & {
|
|
5
|
+
slug: string;
|
|
6
|
+
};
|
|
7
|
+
/** Injectable stock-catalog loader — CI must not require a live `codex` binary. */
|
|
8
|
+
export type CodexStockCatalogLoader = () => CodexStockModel[];
|
|
9
|
+
/**
|
|
10
|
+
* Default loader: `codex debug models` in a throwaway CODEX_HOME with only
|
|
11
|
+
* the built-in openai provider. Failures surface as an empty list so setup
|
|
12
|
+
* still writes the OCR block (stock is best-effort).
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadCodexStockCatalog(): CodexStockModel[];
|
|
15
|
+
/**
|
|
16
|
+
* Hook target: OpenAI Codex CLI and ChatGPT Desktop — both read
|
|
17
|
+
* `~/.codex/config.toml`. One write shape for both:
|
|
18
|
+
*
|
|
19
|
+
* - keep built-in `model_provider = "openai"`
|
|
20
|
+
* - point `openai_base_url` at the gateway
|
|
21
|
+
* - pin `model_catalog_json` = OCR selection first, then remaining stock
|
|
22
|
+
* OpenAI entries (Desktop’s allowlist still shows stock slugs; CLI `/model`
|
|
23
|
+
* shows the full merged list)
|
|
24
|
+
* - gateway key in `auth.json` (`OPENAI_API_KEY`)
|
|
25
|
+
*
|
|
26
|
+
* Legacy `omnicell-router` provider marks are stripped on setup/teardown so a
|
|
27
|
+
* previous CLI-only hook does not linger. TOML has no comment-preserving
|
|
28
|
+
* rewrite; the pre-write backup is the safety net.
|
|
29
|
+
*/
|
|
3
30
|
export declare class CodexClientAdapter implements ClientAdapter {
|
|
4
31
|
name: "codex";
|
|
5
32
|
hookKind: "config";
|
|
33
|
+
/** One hook covers Codex CLI and ChatGPT Desktop (shared ~/.codex). */
|
|
6
34
|
displayName: string;
|
|
35
|
+
shortName: string;
|
|
36
|
+
/** Retired custom-provider id — still stripped for upgrade cleanliness. */
|
|
37
|
+
private static readonly LEGACY_PROVIDER_ID;
|
|
38
|
+
private static readonly PROFILE_PREFIX;
|
|
39
|
+
private static readonly CATALOG_FILE;
|
|
40
|
+
/** Previous Desktop-only catalog name — cleared on setup/teardown. */
|
|
41
|
+
private static readonly LEGACY_DESKTOP_CATALOG;
|
|
42
|
+
private static readonly AUTH_MODE_API;
|
|
43
|
+
private static readonly CATALOG_INSTRUCTIONS;
|
|
44
|
+
/** Override in tests to supply a fixture stock catalog. */
|
|
45
|
+
stockCatalogLoader: CodexStockCatalogLoader;
|
|
7
46
|
getConfigPath(): string;
|
|
47
|
+
private authPath;
|
|
8
48
|
getStatus(): Promise<Omit<ClientHookStatus, 'hookKind'>>;
|
|
9
49
|
setup(options?: {
|
|
10
50
|
port?: number;
|
|
11
51
|
models?: Record<string, string>;
|
|
12
52
|
apiKey?: string;
|
|
53
|
+
extraModels?: string[];
|
|
54
|
+
virtualModels?: string[];
|
|
13
55
|
}): Promise<{
|
|
14
56
|
success: boolean;
|
|
15
57
|
message: string;
|
|
@@ -18,4 +60,32 @@ export declare class CodexClientAdapter implements ClientAdapter {
|
|
|
18
60
|
success: boolean;
|
|
19
61
|
message: string;
|
|
20
62
|
}>;
|
|
63
|
+
private detectHook;
|
|
64
|
+
private detectLegacyProvider;
|
|
65
|
+
private strip;
|
|
66
|
+
private clearLegacyProvider;
|
|
67
|
+
private clearLegacyProviderKeys;
|
|
68
|
+
/**
|
|
69
|
+
* Picker catalog: OCR-selected ids first (cloned stock template when the id
|
|
70
|
+
* is official, else a synthetic row), then every remaining stock OpenAI
|
|
71
|
+
* entry so Desktop’s allowlist and CLI `/model` both stay populated.
|
|
72
|
+
*/
|
|
73
|
+
private writeMergedCatalog;
|
|
74
|
+
private syntheticCatalogEntry;
|
|
75
|
+
private writeAuthApiKey;
|
|
76
|
+
private restoreAuthBackup;
|
|
77
|
+
private rewriteManagedProfiles;
|
|
78
|
+
private clearManagedProfiles;
|
|
79
|
+
/**
|
|
80
|
+
* Profiles this adapter owns: `ocr-*.config.toml` whose body points at
|
|
81
|
+
* openai (unified) or the retired omnicell-router provider.
|
|
82
|
+
*/
|
|
83
|
+
private listManagedProfiles;
|
|
84
|
+
private uniqueProfileStem;
|
|
85
|
+
private clearCatalog;
|
|
86
|
+
private clearLegacyDesktopCatalog;
|
|
87
|
+
private catalogPath;
|
|
88
|
+
private isOurCatalogPath;
|
|
89
|
+
private readToml;
|
|
90
|
+
private writeToml;
|
|
21
91
|
}
|