@kortix/sdk 0.13.39 → 0.13.41
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/README.md +31 -4
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +4 -0
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.js +15 -0
- package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts +1 -10
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +11 -1
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts +14 -0
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts.map +1 -0
- package/dist/browser/stores/sync-store/reconcile-parts.js +55 -0
- package/dist/browser/stores/sync-store/reconcile-parts.js.map +1 -0
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +11 -92
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/agents/composer-agents.d.ts +73 -0
- package/dist/core/agents/composer-agents.d.ts.map +1 -0
- package/dist/core/agents/composer-agents.js +100 -0
- package/dist/core/agents/composer-agents.js.map +1 -0
- package/dist/core/client/kortix.d.ts +39 -3
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +20 -1
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/models/bedrock-invokable.d.ts +58 -0
- package/dist/core/models/bedrock-invokable.d.ts.map +1 -0
- package/dist/core/models/bedrock-invokable.js +83 -0
- package/dist/core/models/bedrock-invokable.js.map +1 -0
- package/dist/core/models/composer-model.d.ts +51 -0
- package/dist/core/models/composer-model.d.ts.map +1 -0
- package/dist/core/models/composer-model.js +88 -0
- package/dist/core/models/composer-model.js.map +1 -0
- package/dist/core/models/model-flatten.d.ts +90 -0
- package/dist/core/models/model-flatten.d.ts.map +1 -0
- package/dist/core/models/model-flatten.js +86 -0
- package/dist/core/models/model-flatten.js.map +1 -0
- package/dist/core/models/model-key.d.ts +18 -0
- package/dist/core/models/model-key.d.ts.map +1 -0
- package/dist/core/models/model-key.js +16 -0
- package/dist/core/models/model-key.js.map +1 -0
- package/dist/core/models/model-lookup.d.ts +3 -0
- package/dist/core/models/model-lookup.d.ts.map +1 -0
- package/dist/core/models/model-lookup.js +4 -0
- package/dist/core/models/model-lookup.js.map +1 -0
- package/dist/core/models/model-visibility.d.ts +85 -0
- package/dist/core/models/model-visibility.d.ts.map +1 -0
- package/dist/core/models/model-visibility.js +215 -0
- package/dist/core/models/model-visibility.js.map +1 -0
- package/dist/core/models/provider-selection.d.ts +142 -0
- package/dist/core/models/provider-selection.d.ts.map +1 -0
- package/dist/core/models/provider-selection.js +472 -0
- package/dist/core/models/provider-selection.js.map +1 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts +4 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/access.d.ts +6 -1
- package/dist/core/rest/projects-client/access.d.ts.map +1 -1
- package/dist/core/rest/projects-client/access.js +3 -1
- package/dist/core/rest/projects-client/access.js.map +1 -1
- package/dist/core/rest/projects-client/account-secret-resources.d.ts +7 -0
- package/dist/core/rest/projects-client/account-secret-resources.d.ts.map +1 -1
- package/dist/core/rest/projects-client/account-secret-resources.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +7 -0
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +12 -3
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/github.d.ts +25 -0
- package/dist/core/rest/projects-client/github.d.ts.map +1 -1
- package/dist/core/rest/projects-client/github.js +19 -0
- package/dist/core/rest/projects-client/github.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +2 -0
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +2 -0
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/project-agents.d.ts +29 -0
- package/dist/core/rest/projects-client/project-agents.d.ts.map +1 -0
- package/dist/core/rest/projects-client/project-agents.js +41 -0
- package/dist/core/rest/projects-client/project-agents.js.map +1 -0
- package/dist/core/rest/projects-client/projects.d.ts +10 -2
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +8 -1
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/review-items.d.ts +3 -0
- package/dist/core/rest/projects-client/review-items.d.ts.map +1 -1
- package/dist/core/rest/projects-client/review-items.js +1 -0
- package/dist/core/rest/projects-client/review-items.js.map +1 -1
- package/dist/core/rest/projects-client/session-reminders.d.ts +63 -0
- package/dist/core/rest/projects-client/session-reminders.d.ts.map +1 -0
- package/dist/core/rest/projects-client/session-reminders.js +29 -0
- package/dist/core/rest/projects-client/session-reminders.js.map +1 -0
- package/dist/core/rest/projects-client/sessions.d.ts +6 -0
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +2 -0
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/setup-links.d.ts +2 -0
- package/dist/core/rest/projects-client/setup-links.d.ts.map +1 -1
- package/dist/core/rest/projects-client/setup-links.js.map +1 -1
- package/dist/core/rest/projects-client/tokens.d.ts +30 -0
- package/dist/core/rest/projects-client/tokens.d.ts.map +1 -1
- package/dist/core/rest/projects-client/tokens.js +11 -0
- package/dist/core/rest/projects-client/tokens.js.map +1 -1
- package/dist/core/session/connection.d.ts +22 -0
- package/dist/core/session/connection.d.ts.map +1 -1
- package/dist/core/session/connection.js +28 -0
- package/dist/core/session/connection.js.map +1 -1
- package/dist/core/session/status-vocabulary.d.ts +1 -1
- package/dist/core/session/status-vocabulary.js +1 -1
- package/dist/core/session/status-vocabulary.js.map +1 -1
- package/dist/core/session-sync/saved-copy-store.d.ts +5 -1
- package/dist/core/session-sync/saved-copy-store.d.ts.map +1 -1
- package/dist/core/session-sync/saved-copy-store.js +50 -2
- package/dist/core/session-sync/saved-copy-store.js.map +1 -1
- package/dist/core/session-sync/saved-transcript.d.ts +35 -0
- package/dist/core/session-sync/saved-transcript.d.ts.map +1 -1
- package/dist/core/session-sync/saved-transcript.js +22 -0
- package/dist/core/session-sync/saved-transcript.js.map +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts +2 -0
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/session-sync/session-sync-controller.js +19 -2
- package/dist/core/session-sync/session-sync-controller.js.map +1 -1
- package/dist/core/stream/keepalive.d.ts +1 -1
- package/dist/core/stream/keepalive.js +1 -1
- package/dist/core/turns/errors.d.ts +6 -0
- package/dist/core/turns/errors.d.ts.map +1 -1
- package/dist/core/turns/errors.js +7 -1
- package/dist/core/turns/errors.js.map +1 -1
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +22 -129
- package/dist/core/turns/parts.js.map +1 -1
- package/dist/core/turns/tools/web-helpers.d.ts.map +1 -1
- package/dist/core/turns/tools/web-helpers.js +79 -139
- package/dist/core/turns/tools/web-helpers.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +37 -37
- package/dist/kortix.global.js +37 -37
- package/dist/react/bedrock-invokable.d.ts +1 -57
- package/dist/react/bedrock-invokable.d.ts.map +1 -1
- package/dist/react/bedrock-invokable.js +2 -82
- package/dist/react/bedrock-invokable.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-flatten.d.ts +1 -89
- package/dist/react/model-flatten.d.ts.map +1 -1
- package/dist/react/model-flatten.js +2 -85
- package/dist/react/model-flatten.js.map +1 -1
- package/dist/react/model-lookup.d.ts +1 -2
- package/dist/react/model-lookup.d.ts.map +1 -1
- package/dist/react/model-lookup.js +2 -3
- package/dist/react/model-lookup.js.map +1 -1
- package/dist/react/provider-selection.d.ts +1 -107
- package/dist/react/provider-selection.d.ts.map +1 -1
- package/dist/react/provider-selection.js +2 -437
- package/dist/react/provider-selection.js.map +1 -1
- package/dist/react/query-keys.d.ts +6 -0
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +6 -0
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +1 -1
- package/dist/react/use-model-defaults.d.ts +2 -1
- package/dist/react/use-model-defaults.d.ts.map +1 -1
- package/dist/react/use-model-defaults.js +3 -7
- package/dist/react/use-model-defaults.js.map +1 -1
- package/dist/react/use-model-store.d.ts +3 -44
- package/dist/react/use-model-store.d.ts.map +1 -1
- package/dist/react/use-model-store.js +16 -182
- package/dist/react/use-model-store.js.map +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-local.js +41 -110
- package/dist/react/use-opencode-local.js.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts +2 -7
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.js +3 -27
- package/dist/react/use-opencode-sessions/agents.js.map +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.js +4 -4
- package/dist/react/use-opencode-sessions/providers.js.map +1 -1
- package/dist/react/use-reminders.d.ts +465 -0
- package/dist/react/use-reminders.d.ts.map +1 -0
- package/dist/react/use-reminders.js +50 -0
- package/dist/react/use-reminders.js.map +1 -0
- package/dist/react/use-runtime-reconnect.d.ts +41 -8
- package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
- package/dist/react/use-runtime-reconnect.js +93 -27
- package/dist/react/use-runtime-reconnect.js.map +1 -1
- package/dist/react/use-session-sync.d.ts +7 -0
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +15 -8
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session-transcript-history.d.ts +2 -0
- package/dist/react/use-session-transcript-history.d.ts.map +1 -1
- package/dist/react/use-session-transcript-history.js +13 -0
- package/dist/react/use-session-transcript-history.js.map +1 -1
- package/dist/react/use-session.d.ts +15 -8
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +40 -10
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-visible-agents.d.ts +5 -5
- package/dist/react/use-visible-agents.d.ts.map +1 -1
- package/dist/react/use-visible-agents.js +10 -28
- package/dist/react/use-visible-agents.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type ProviderListResponse } from './provider-selection.js';
|
|
2
|
+
/**
|
|
3
|
+
* Flat model list + the flattening logic (relocated from web's session-chat-input —
|
|
4
|
+
* it's data, not UI). Used by the model/agent resolution hooks.
|
|
5
|
+
*/
|
|
6
|
+
export interface FlatModel {
|
|
7
|
+
providerID: string;
|
|
8
|
+
providerName: string;
|
|
9
|
+
modelID: string;
|
|
10
|
+
modelName: string;
|
|
11
|
+
variants?: Record<string, Record<string, unknown>>;
|
|
12
|
+
/** Capabilities extracted from the provider API response */
|
|
13
|
+
capabilities?: {
|
|
14
|
+
reasoning?: boolean;
|
|
15
|
+
vision?: boolean;
|
|
16
|
+
toolcall?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Context window size in tokens */
|
|
19
|
+
contextWindow?: number;
|
|
20
|
+
/** ISO date string for release date */
|
|
21
|
+
releaseDate?: string;
|
|
22
|
+
/** Model family (used for "latest" logic) */
|
|
23
|
+
family?: string;
|
|
24
|
+
/** Cost per token (input/output) */
|
|
25
|
+
cost?: {
|
|
26
|
+
input: number;
|
|
27
|
+
output: number;
|
|
28
|
+
};
|
|
29
|
+
/** Provider source (env, api, config, custom) */
|
|
30
|
+
providerSource?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The REAL upstream provider this model resolves against ('anthropic',
|
|
33
|
+
* 'openai', 'codex', 'kortix', ...) — carried explicitly off the gateway's
|
|
34
|
+
* served model so the picker never has to recover it by string-splitting
|
|
35
|
+
* `modelID`. Every gateway model is registered under `providerID: 'kortix'`;
|
|
36
|
+
* this is the field that identifies who ACTUALLY serves it. Undefined for
|
|
37
|
+
* providers/models predating this field.
|
|
38
|
+
*/
|
|
39
|
+
provider?: string;
|
|
40
|
+
/** Tunable reasoning-effort values (models.dev's `reasoning_options`), when
|
|
41
|
+
* the model exposes one. */
|
|
42
|
+
reasoningOptions?: Array<{
|
|
43
|
+
type: string;
|
|
44
|
+
values?: string[];
|
|
45
|
+
min?: number;
|
|
46
|
+
max?: number;
|
|
47
|
+
}>;
|
|
48
|
+
/** Free-text blurb models.dev publishes for the model. */
|
|
49
|
+
description?: string;
|
|
50
|
+
/** True when the model's weights are publicly released (open-weights) vs.
|
|
51
|
+
* closed API-only. models.dev's `open_weights` field, mirrored. */
|
|
52
|
+
openWeights?: boolean;
|
|
53
|
+
/** When models.dev last refreshed this model's own entry. */
|
|
54
|
+
lastUpdated?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the project OFFERS this model. Server-owned per-project
|
|
57
|
+
* enablement, resolved by the API (`/model-picker`) — the picker renders the
|
|
58
|
+
* enabled ones and "Manage models" switches on this flag. Neither re-derives
|
|
59
|
+
* it, and the gateway never refuses a request over it (display-only).
|
|
60
|
+
* Undefined on catalogs that don't carry enablement (anything but
|
|
61
|
+
* `/model-picker`), which callers read as "not applicable".
|
|
62
|
+
*/
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether `key` may be offered/resolved from `models` — present in the catalog
|
|
67
|
+
* and not turned off by the server's per-project enablement (`enabled` above).
|
|
68
|
+
* THE one predicate for "is this model selectable?"; a second, client-local
|
|
69
|
+
* visibility heuristic beside it is exactly what made the session picker and
|
|
70
|
+
* "Manage models" disagree.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isOfferedModel(models: FlatModel[], key: {
|
|
73
|
+
providerID: string;
|
|
74
|
+
modelID: string;
|
|
75
|
+
}): boolean;
|
|
76
|
+
export declare function flattenModels(providers: ProviderListResponse | undefined, opts?: {
|
|
77
|
+
/**
|
|
78
|
+
* Which provider universe this list belongs to (modelProviderMode).
|
|
79
|
+
*
|
|
80
|
+
* • 'gateway' (default) — the synthetic `kortix` provider is the ONLY
|
|
81
|
+
* renderable provider; a native provider that slips into the response
|
|
82
|
+
* is a bypass and is dropped (defense in depth on top of source
|
|
83
|
+
* filtering).
|
|
84
|
+
* • 'native' (project `llm_gateway` flag OFF) — OpenCode's own connected
|
|
85
|
+
* providers (`anthropic`, `openrouter`, `opencode`, …) ARE the catalog;
|
|
86
|
+
* only a stale `kortix` entry (a box mid-toggle) is dropped.
|
|
87
|
+
*/
|
|
88
|
+
providerMode?: 'gateway' | 'native';
|
|
89
|
+
}): FlatModel[];
|
|
90
|
+
//# sourceMappingURL=model-flatten.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-flatten.d.ts","sourceRoot":"","sources":["../../../src/core/models/model-flatten.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsCvF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,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;;OAUG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CACrC,GACA,SAAS,EAAE,CAiEb"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { GATEWAY_PROVIDER_IDS } from './provider-selection.js';
|
|
2
|
+
function hasCapabilities(model) {
|
|
3
|
+
return 'capabilities' in model && model.capabilities != null;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Whether `key` may be offered/resolved from `models` — present in the catalog
|
|
7
|
+
* and not turned off by the server's per-project enablement (`enabled` above).
|
|
8
|
+
* THE one predicate for "is this model selectable?"; a second, client-local
|
|
9
|
+
* visibility heuristic beside it is exactly what made the session picker and
|
|
10
|
+
* "Manage models" disagree.
|
|
11
|
+
*/
|
|
12
|
+
export function isOfferedModel(models, key) {
|
|
13
|
+
const model = models.find((m) => m.providerID === key.providerID && m.modelID === key.modelID);
|
|
14
|
+
return !!model && model.enabled !== false;
|
|
15
|
+
}
|
|
16
|
+
export function flattenModels(providers, opts) {
|
|
17
|
+
if (!providers)
|
|
18
|
+
return [];
|
|
19
|
+
const providerMode = opts?.providerMode ?? 'gateway';
|
|
20
|
+
const all = Array.isArray(providers.all) ? providers.all : [];
|
|
21
|
+
const connected = Array.isArray(providers.connected) ? providers.connected : [];
|
|
22
|
+
const result = [];
|
|
23
|
+
for (const p of all) {
|
|
24
|
+
if (!connected.includes(p.id))
|
|
25
|
+
continue;
|
|
26
|
+
if (providerMode === 'gateway' ? !GATEWAY_PROVIDER_IDS.has(p.id) : GATEWAY_PROVIDER_IDS.has(p.id))
|
|
27
|
+
continue;
|
|
28
|
+
for (const [modelID, model] of Object.entries(p.models)) {
|
|
29
|
+
// Old sandboxes can carry a baked catalog from before the synthetic model
|
|
30
|
+
// was removed. Never expose or send those stale entries.
|
|
31
|
+
if (modelID === 'auto' || modelID === 'kortix/auto')
|
|
32
|
+
continue;
|
|
33
|
+
// Narrow `model` itself (not a copy) so the loose-shape-only fields
|
|
34
|
+
// (`reasoning`, `tool_call`, `modalities`) are safe to read below.
|
|
35
|
+
let capabilities;
|
|
36
|
+
// `vision` gates whether the composer refuses an attached image, so a
|
|
37
|
+
// catalog that says NOTHING about modalities must stay `undefined`. A
|
|
38
|
+
// custom or self-hosted provider carries no signal, and reading that
|
|
39
|
+
// silence as `false` would block images on a model that can read them.
|
|
40
|
+
if (hasCapabilities(model)) {
|
|
41
|
+
const caps = model.capabilities;
|
|
42
|
+
capabilities = {
|
|
43
|
+
reasoning: caps.reasoning ?? false,
|
|
44
|
+
vision: caps.input ? (caps.input.image ?? false) : undefined,
|
|
45
|
+
toolcall: caps.toolcall ?? false,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const modalityInput = model.modalities?.input;
|
|
50
|
+
capabilities = {
|
|
51
|
+
reasoning: model.reasoning ?? false,
|
|
52
|
+
vision: modalityInput
|
|
53
|
+
? modalityInput.includes('image')
|
|
54
|
+
: model.attachment,
|
|
55
|
+
toolcall: model.tool_call ?? false,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
result.push({
|
|
59
|
+
providerID: p.id,
|
|
60
|
+
providerName: p.name,
|
|
61
|
+
modelID,
|
|
62
|
+
modelName: (model.name || modelID).replace('(latest)', '').trim(),
|
|
63
|
+
variants: model.variants,
|
|
64
|
+
capabilities,
|
|
65
|
+
contextWindow: model.limit?.context,
|
|
66
|
+
releaseDate: model.release_date,
|
|
67
|
+
family: model.family,
|
|
68
|
+
cost: model.cost
|
|
69
|
+
? {
|
|
70
|
+
input: model.cost.input ?? 0,
|
|
71
|
+
output: model.cost.output ?? 0,
|
|
72
|
+
}
|
|
73
|
+
: undefined,
|
|
74
|
+
providerSource: p.source,
|
|
75
|
+
provider: model.provider,
|
|
76
|
+
reasoningOptions: model.reasoning_options,
|
|
77
|
+
description: model.description,
|
|
78
|
+
openWeights: model.open_weights,
|
|
79
|
+
lastUpdated: model.last_updated,
|
|
80
|
+
enabled: model.enabled,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=model-flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-flatten.js","sourceRoot":"","sources":["../../../src/core/models/model-flatten.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA6B,MAAM,sBAAsB,CAAC;AAkCvF,SAAS,eAAe,CAAC,KAAiB;IACxC,OAAO,cAAc,IAAI,KAAK,IAAI,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC;AAC/D,CAAC;AA6DD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,GAA4C;IAE5C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/F,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC;AAC5C,CAAC;AAiBD,MAAM,UAAU,aAAa,CAC3B,SAA2C,EAC3C,IAaC;IAED,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,SAAS,CAAC;IACrD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI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KAA2B,CAAC,UAAU;oBAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,IAAI,KAAK;iBACnC,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,IAAI,CAAC;gBACV,UAAU,EAAE,CAAC,CAAC,EAAE;gBAChB,YAAY,EAAE,CAAC,CAAC,IAAI;gBACpB,OAAO;gBACP,SAAS,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;gBACjE,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,YAAY;gBACZ,aAAa,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO;gBACnC,WAAW,EAAE,KAAK,CAAC,YAAY;gBAC/B,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,IAAI,EAAE,KAAK,CAAC,IAAI;oBACd,CAAC,CAAC;wBACE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;wBAC5B,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC;qBAC/B;oBACH,CAAC,CAAC,SAAS;gBACb,cAAc,EAAE,CAAC,CAAC,MAAM;gBACxB,QAAQ,EAAG,KAA2B,CAAC,QAAQ;gBAC/C,gBAAgB,EAAG,KAA2B,CAAC,iBAAiB;gBAChE,WAAW,EAAG,KAA2B,CAAC,WAAW;gBACrD,WAAW,EAAG,KAA2B,CAAC,YAAY;gBACtD,WAAW,EAAG,KAA2B,CAAC,YAAY;gBACtD,OAAO,EAAG,KAA2B,CAAC,OAAO;aAC9C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A model's identity in the composer: provider + model id. */
|
|
2
|
+
export type ModelKey = {
|
|
3
|
+
providerID: string;
|
|
4
|
+
modelID: string;
|
|
5
|
+
/**
|
|
6
|
+
* The REAL upstream provider a `kortix`-gateway model resolves against
|
|
7
|
+
* ('anthropic', 'openai', 'codex', 'kortix', ...) — see `FlatModel.provider`
|
|
8
|
+
* (model-flatten.ts). When present, `subProviderOf` uses it directly instead
|
|
9
|
+
* of parsing `modelID`, so connection-gating never depends on the wire id
|
|
10
|
+
* happening to be namespaced `<provider>/<model>`. Optional so every
|
|
11
|
+
* existing caller (which only ever had `providerID`/`modelID`) keeps
|
|
12
|
+
* compiling unchanged.
|
|
13
|
+
*/
|
|
14
|
+
provider?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function modelKeyToWire(model: ModelKey): string;
|
|
17
|
+
export declare function wireToModelKey(wire: string): ModelKey;
|
|
18
|
+
//# sourceMappingURL=model-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-key.d.ts","sourceRoot":"","sources":["../../../src/core/models/model-key.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAOF,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAGtD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAIrD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ── Gateway wire-model ⟷ ModelKey conversion ───────────────────────────────
|
|
2
|
+
// The LLM gateway identifies a model by its "wire model" — what opencode sends
|
|
3
|
+
// as `body.model`. Under the kortix gateway provider that is just the modelID
|
|
4
|
+
// (a bare managed id like 'glm-5.3-flash', or a BYOK 'provider/model'). A direct
|
|
5
|
+
// provider model uses 'provider/model'.
|
|
6
|
+
export function modelKeyToWire(model) {
|
|
7
|
+
if (model.providerID === 'kortix' || model.providerID === 'opencode')
|
|
8
|
+
return model.modelID;
|
|
9
|
+
return `${model.providerID}/${model.modelID}`;
|
|
10
|
+
}
|
|
11
|
+
export function wireToModelKey(wire) {
|
|
12
|
+
// Managed (bare) and BYOK ('provider/model') both live under the kortix
|
|
13
|
+
// provider in the picker namespace, so the modelID carries the full wire id.
|
|
14
|
+
return { providerID: 'kortix', modelID: wire };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=model-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-key.js","sourceRoot":"","sources":["../../../src/core/models/model-key.ts"],"names":[],"mappings":"AAgBA,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,iFAAiF;AACjF,wCAAwC;AACxC,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,IAAI,KAAK,CAAC,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAC3F,OAAO,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,wEAAwE;IACxE,6EAA6E;IAC7E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-lookup.d.ts","sourceRoot":"","sources":["../../../src/core/models/model-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAE7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-lookup.js","sourceRoot":"","sources":["../../../src/core/models/model-lookup.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { FlatModel } from './model-flatten.js';
|
|
2
|
+
import type { ModelKey } from './model-key.js';
|
|
3
|
+
/**
|
|
4
|
+
* True when at least one model in `allModels` is actually usable right now —
|
|
5
|
+
* i.e. would work if sent, not merely present in the catalog. The gateway
|
|
6
|
+
* bakes its ENTIRE routable catalog into every project regardless of plan or
|
|
7
|
+
* connected keys (`providers.connected` always includes `kortix`), so raw
|
|
8
|
+
* catalog presence (`providerListHasModels`, `models.length`) is never a
|
|
9
|
+
* reliable "nothing is connected" signal — it's true even for a brand-new,
|
|
10
|
+
* unpaid, no-BYOK account. This mirrors the entitlement half of `isVisible`
|
|
11
|
+
* (managed models gated by `!freeTier`, BYOK-under-gateway models gated by
|
|
12
|
+
* their sub-provider being connected) without its display-curation half
|
|
13
|
+
* (the "latest per family" / flagship-only default view) — a model can be
|
|
14
|
+
* fully usable while `isVisible` still hides it by default.
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasUsableModel(allModels: FlatModel[], opts: {
|
|
17
|
+
connectedProviderIds?: Set<string>;
|
|
18
|
+
freeTier?: boolean;
|
|
19
|
+
}): boolean;
|
|
20
|
+
export declare function isDefaultVisible(model: ModelKey): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* "Latest" models, keyed `providerID:modelID` for the store's lookup maps.
|
|
23
|
+
*
|
|
24
|
+
* The RULE itself lives in `@kortix/llm-catalog` — the gateway enforces the
|
|
25
|
+
* same default set server-side, and two copies of "newest per family within
|
|
26
|
+
* the window" is exactly how the picker and "Manage models" drifted apart.
|
|
27
|
+
* This is only the key-shape adapter.
|
|
28
|
+
*/
|
|
29
|
+
export declare function computeLatestSet(models: FlatModel[]): Set<string>;
|
|
30
|
+
/** A user's explicit show/hide choice for one model ("Manage models"). */
|
|
31
|
+
export interface ModelVisibilityPin extends ModelKey {
|
|
32
|
+
visibility: 'show' | 'hide';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build the default-visibility predicate for a model picker. Later pins for
|
|
36
|
+
* the same model win. Rules, in order:
|
|
37
|
+
* • a `hide` pin hides;
|
|
38
|
+
* • gateway (`kortix`) models: a platform-managed model shows unless
|
|
39
|
+
* `freeTier`; any other shows only while its real provider is connected,
|
|
40
|
+
* then by `show` pin, newest-per-family, or the undated-flagship rule;
|
|
41
|
+
* • native models: `show` pin, newest per family within the window
|
|
42
|
+
* (`computeLatestSet`), else only the flagship when undated.
|
|
43
|
+
*
|
|
44
|
+
* `catalogModels` is the canonical universe the "latest" set and release dates
|
|
45
|
+
* are read from — pass the full catalog from every surface so one model key
|
|
46
|
+
* resolves the same everywhere.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createModelVisibility(input: {
|
|
49
|
+
catalogModels: FlatModel[];
|
|
50
|
+
pins?: ReadonlyArray<ModelVisibilityPin>;
|
|
51
|
+
connectedProviderIds?: Set<string>;
|
|
52
|
+
freeTier?: boolean;
|
|
53
|
+
}): (model: ModelKey) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Which models the picker shows when the search box is EMPTY — the default
|
|
56
|
+
* view.
|
|
57
|
+
*
|
|
58
|
+
* Gateway (`kortix`-provider) models are already server-curated: the
|
|
59
|
+
* `/model-picker` catalog stamps `enabled` from the shared newest-per-family
|
|
60
|
+
* rule, and the `enabled !== false` filter upstream of this function applies
|
|
61
|
+
* it. NATIVE provider models had no equivalent — the runtime list (opencode's
|
|
62
|
+
* own catalog) and the pre-runtime list (models.dev via the API) are both
|
|
63
|
+
* unstamped, so a connected OpenRouter key rendered ALL ~355 models as a
|
|
64
|
+
* wall. This applies the client twin of the same rule: `isStoreVisible`
|
|
65
|
+
* (`createModelVisibility` — newest per family within the window, flagships,
|
|
66
|
+
* plus the user's explicit show/hide pins).
|
|
67
|
+
*
|
|
68
|
+
* Two deliberate carve-outs:
|
|
69
|
+
* • a SEARCH query reveals everything — typing is intent, and hiding search
|
|
70
|
+
* hits behind a second toggle is how models become unfindable;
|
|
71
|
+
* • the currently-selected model always renders, or the check mark would
|
|
72
|
+
* point at a row that does not exist.
|
|
73
|
+
*/
|
|
74
|
+
export declare function modelInDefaultView(model: FlatModel, input: {
|
|
75
|
+
search: string;
|
|
76
|
+
isStoreVisible: (model: {
|
|
77
|
+
providerID: string;
|
|
78
|
+
modelID: string;
|
|
79
|
+
}) => boolean;
|
|
80
|
+
selected: {
|
|
81
|
+
providerID: string;
|
|
82
|
+
modelID: string;
|
|
83
|
+
} | null;
|
|
84
|
+
}): boolean;
|
|
85
|
+
//# sourceMappingURL=model-visibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-visibility.d.ts","sourceRoot":"","sources":["../../../src/core/models/model-visibility.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA+C5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,EAAE,EACtB,IAAI,EAAE;IAAE,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/D,OAAO,CAeT;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAajE;AAED,0EAA0E;AAC1E,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,aAAa,EAAE,SAAS,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACzC,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CA8D/B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE;IACL,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;IAC5E,QAAQ,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC1D,GACA,OAAO,CAWT"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { DEFAULT_MANAGED_MODEL_IDS, MANAGED_FLAGSHIP_MODEL_ID, defaultEnabledModelIds, } from '@kortix/llm-catalog/lite';
|
|
2
|
+
import { createModelLookup } from './model-lookup.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which models a composer's model picker shows out of the box. Framework-free:
|
|
5
|
+
* `useModelStore` (web) wraps it with persisted pins, and any other host calls
|
|
6
|
+
* it with its own.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Fallback allowlist for the rare non-gateway model that carries no release-date
|
|
10
|
+
* metadata: only the flagship shows out of the box, everything else is opt-in via
|
|
11
|
+
* "Manage models".
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_VISIBLE_MODEL_IDS = new Set([MANAGED_FLAGSHIP_MODEL_ID]);
|
|
14
|
+
/**
|
|
15
|
+
* Provider id of the managed Kortix LLM gateway (see the sandbox's
|
|
16
|
+
* `opencode.ts` provider config). It's a small, hand-picked catalog we control,
|
|
17
|
+
* so every model in it is shown by default — `isVisible` short-circuits the
|
|
18
|
+
* date-based "latest" heuristic for this provider. The newest-per-family
|
|
19
|
+
* behaviour is kept for BYO providers, which is what it's for.
|
|
20
|
+
*/
|
|
21
|
+
const MANAGED_GATEWAY_PROVIDER_ID = 'kortix';
|
|
22
|
+
const SUBSCRIPTION_PROVIDER_ID = 'codex';
|
|
23
|
+
// The gateway bakes its ENTIRE routable catalog (every BYOK provider's models)
|
|
24
|
+
// into opencode so any model is callable the instant its key is connected — no
|
|
25
|
+
// session restart. The picker must therefore NOT show all of it by default: a
|
|
26
|
+
// `kortix` model is on out-of-the-box only when it's a platform-managed default
|
|
27
|
+
// or its underlying provider is connected (live, from project secrets). The
|
|
28
|
+
// rest stay one search away. Single source for the managed set lives in
|
|
29
|
+
// @kortix/llm-catalog (mirrors the gateway's managed-ids).
|
|
30
|
+
const MANAGED_MODEL_IDS = new Set(DEFAULT_MANAGED_MODEL_IDS);
|
|
31
|
+
// `explicitProvider` (a model's `FlatModel.provider` / `ModelKey.provider`) is
|
|
32
|
+
// the robust path — the gateway now serves it directly, so grouping/gating
|
|
33
|
+
// never has to guess the real provider from string-splitting `modelID`.
|
|
34
|
+
// String-splitting on "/" remains only a fallback for a stale/older baked
|
|
35
|
+
// catalog that predates the field.
|
|
36
|
+
function subProviderOf(modelID, explicitProvider) {
|
|
37
|
+
if (explicitProvider)
|
|
38
|
+
return explicitProvider;
|
|
39
|
+
const slash = modelID.indexOf('/');
|
|
40
|
+
return slash === -1 ? modelID : modelID.slice(0, slash);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* True when at least one model in `allModels` is actually usable right now —
|
|
44
|
+
* i.e. would work if sent, not merely present in the catalog. The gateway
|
|
45
|
+
* bakes its ENTIRE routable catalog into every project regardless of plan or
|
|
46
|
+
* connected keys (`providers.connected` always includes `kortix`), so raw
|
|
47
|
+
* catalog presence (`providerListHasModels`, `models.length`) is never a
|
|
48
|
+
* reliable "nothing is connected" signal — it's true even for a brand-new,
|
|
49
|
+
* unpaid, no-BYOK account. This mirrors the entitlement half of `isVisible`
|
|
50
|
+
* (managed models gated by `!freeTier`, BYOK-under-gateway models gated by
|
|
51
|
+
* their sub-provider being connected) without its display-curation half
|
|
52
|
+
* (the "latest per family" / flagship-only default view) — a model can be
|
|
53
|
+
* fully usable while `isVisible` still hides it by default.
|
|
54
|
+
*/
|
|
55
|
+
export function hasUsableModel(allModels, opts) {
|
|
56
|
+
const connectedProviderIds = opts.connectedProviderIds;
|
|
57
|
+
const freeTier = opts.freeTier ?? false;
|
|
58
|
+
return allModels.some((m) => {
|
|
59
|
+
if (m.providerID !== MANAGED_GATEWAY_PROVIDER_ID) {
|
|
60
|
+
// Native/direct provider models: flattenModels only includes models
|
|
61
|
+
// from CONNECTED providers, so presence here already means usable.
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (MANAGED_MODEL_IDS.has(m.modelID))
|
|
65
|
+
return !freeTier;
|
|
66
|
+
const sub = subProviderOf(m.modelID, m.provider);
|
|
67
|
+
return sub === SUBSCRIPTION_PROVIDER_ID
|
|
68
|
+
? (connectedProviderIds?.has(SUBSCRIPTION_PROVIDER_ID) ?? false)
|
|
69
|
+
: (connectedProviderIds?.has(sub) ?? false);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function isDefaultVisible(model) {
|
|
73
|
+
return DEFAULT_VISIBLE_MODEL_IDS.has(model.modelID);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* "Latest" models, keyed `providerID:modelID` for the store's lookup maps.
|
|
77
|
+
*
|
|
78
|
+
* The RULE itself lives in `@kortix/llm-catalog` — the gateway enforces the
|
|
79
|
+
* same default set server-side, and two copies of "newest per family within
|
|
80
|
+
* the window" is exactly how the picker and "Manage models" drifted apart.
|
|
81
|
+
* This is only the key-shape adapter.
|
|
82
|
+
*/
|
|
83
|
+
export function computeLatestSet(models) {
|
|
84
|
+
return defaultEnabledModelIds(models.map((m) => ({
|
|
85
|
+
// Feed the store's own composite key through as the candidate id so the
|
|
86
|
+
// result needs no lossy id → model lookup on the way back out.
|
|
87
|
+
id: `${m.providerID}:${m.modelID}`,
|
|
88
|
+
released: m.releaseDate,
|
|
89
|
+
family: m.family,
|
|
90
|
+
// `provider` is the real upstream under the gateway (every model is
|
|
91
|
+
// served as `kortix`); for a native provider it IS the providerID.
|
|
92
|
+
provider: m.provider ?? m.providerID,
|
|
93
|
+
})));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build the default-visibility predicate for a model picker. Later pins for
|
|
97
|
+
* the same model win. Rules, in order:
|
|
98
|
+
* • a `hide` pin hides;
|
|
99
|
+
* • gateway (`kortix`) models: a platform-managed model shows unless
|
|
100
|
+
* `freeTier`; any other shows only while its real provider is connected,
|
|
101
|
+
* then by `show` pin, newest-per-family, or the undated-flagship rule;
|
|
102
|
+
* • native models: `show` pin, newest per family within the window
|
|
103
|
+
* (`computeLatestSet`), else only the flagship when undated.
|
|
104
|
+
*
|
|
105
|
+
* `catalogModels` is the canonical universe the "latest" set and release dates
|
|
106
|
+
* are read from — pass the full catalog from every surface so one model key
|
|
107
|
+
* resolves the same everywhere.
|
|
108
|
+
*/
|
|
109
|
+
export function createModelVisibility(input) {
|
|
110
|
+
const { connectedProviderIds } = input;
|
|
111
|
+
const freeTier = input.freeTier ?? false;
|
|
112
|
+
const latestSet = computeLatestSet(input.catalogModels);
|
|
113
|
+
const modelByKey = createModelLookup(input.catalogModels);
|
|
114
|
+
const visibilityMap = new Map();
|
|
115
|
+
for (const item of input.pins ?? []) {
|
|
116
|
+
visibilityMap.set(`${item.providerID}:${item.modelID}`, item.visibility);
|
|
117
|
+
}
|
|
118
|
+
return (model) => {
|
|
119
|
+
const key = `${model.providerID}:${model.modelID}`;
|
|
120
|
+
const state = visibilityMap.get(key);
|
|
121
|
+
if (state === 'hide')
|
|
122
|
+
return false;
|
|
123
|
+
// Gateway (kortix) models. The catalog is namespaced `<provider>/<model>`,
|
|
124
|
+
// and connection is AUTHORITATIVE — it overrides any stale `show` pin, so a
|
|
125
|
+
// disconnected provider's models disappear (even ones you'd used) and a
|
|
126
|
+
// freshly connected provider's models appear, with no per-model pinning.
|
|
127
|
+
// Visible only when: Codex subscription (`codex/<id>`, present once
|
|
128
|
+
// connected), a platform-managed default, or the BYOK provider is
|
|
129
|
+
// connected. Everything else is search-only so the catalog can't flood.
|
|
130
|
+
if (model.providerID === MANAGED_GATEWAY_PROVIDER_ID) {
|
|
131
|
+
const sub = subProviderOf(model.modelID, model.provider);
|
|
132
|
+
// Codex (ChatGPT subscription) is now baked unconditionally like BYOK, so
|
|
133
|
+
// gate its display on the subscription being connected.
|
|
134
|
+
const connected = sub === SUBSCRIPTION_PROVIDER_ID
|
|
135
|
+
? (connectedProviderIds?.has(SUBSCRIPTION_PROVIDER_ID) ?? false)
|
|
136
|
+
: (connectedProviderIds?.has(sub) ?? false);
|
|
137
|
+
if (MANAGED_MODEL_IDS.has(model.modelID)) {
|
|
138
|
+
if (freeTier)
|
|
139
|
+
return false;
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
if (!connected)
|
|
143
|
+
return false;
|
|
144
|
+
if (state === 'show')
|
|
145
|
+
return true;
|
|
146
|
+
if (latestSet.has(key))
|
|
147
|
+
return true;
|
|
148
|
+
const m = modelByKey.get(key);
|
|
149
|
+
if (!m?.releaseDate)
|
|
150
|
+
return isDefaultVisible(model);
|
|
151
|
+
try {
|
|
152
|
+
const d = new Date(m.releaseDate);
|
|
153
|
+
if (Number.isNaN(d.getTime()))
|
|
154
|
+
return isDefaultVisible(model);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return isDefaultVisible(model);
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (state === 'show')
|
|
162
|
+
return true;
|
|
163
|
+
if (latestSet.has(key))
|
|
164
|
+
return true;
|
|
165
|
+
const m = modelByKey.get(key);
|
|
166
|
+
// No (or invalid) release metadata — the managed Kortix gateway case.
|
|
167
|
+
// Default to showing only the flagship; every other model is opt-in via
|
|
168
|
+
// "Manage models". Providers that DO carry release dates keep the
|
|
169
|
+
// newest-per-family "latest" behaviour handled above.
|
|
170
|
+
if (!m?.releaseDate)
|
|
171
|
+
return isDefaultVisible(model);
|
|
172
|
+
try {
|
|
173
|
+
const d = new Date(m.releaseDate);
|
|
174
|
+
if (Number.isNaN(d.getTime()))
|
|
175
|
+
return isDefaultVisible(model);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return isDefaultVisible(model);
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Which models the picker shows when the search box is EMPTY — the default
|
|
185
|
+
* view.
|
|
186
|
+
*
|
|
187
|
+
* Gateway (`kortix`-provider) models are already server-curated: the
|
|
188
|
+
* `/model-picker` catalog stamps `enabled` from the shared newest-per-family
|
|
189
|
+
* rule, and the `enabled !== false` filter upstream of this function applies
|
|
190
|
+
* it. NATIVE provider models had no equivalent — the runtime list (opencode's
|
|
191
|
+
* own catalog) and the pre-runtime list (models.dev via the API) are both
|
|
192
|
+
* unstamped, so a connected OpenRouter key rendered ALL ~355 models as a
|
|
193
|
+
* wall. This applies the client twin of the same rule: `isStoreVisible`
|
|
194
|
+
* (`createModelVisibility` — newest per family within the window, flagships,
|
|
195
|
+
* plus the user's explicit show/hide pins).
|
|
196
|
+
*
|
|
197
|
+
* Two deliberate carve-outs:
|
|
198
|
+
* • a SEARCH query reveals everything — typing is intent, and hiding search
|
|
199
|
+
* hits behind a second toggle is how models become unfindable;
|
|
200
|
+
* • the currently-selected model always renders, or the check mark would
|
|
201
|
+
* point at a row that does not exist.
|
|
202
|
+
*/
|
|
203
|
+
export function modelInDefaultView(model, input) {
|
|
204
|
+
if (input.search.trim().length > 0)
|
|
205
|
+
return true;
|
|
206
|
+
if (model.providerID === 'kortix')
|
|
207
|
+
return true;
|
|
208
|
+
if (input.selected &&
|
|
209
|
+
input.selected.providerID === model.providerID &&
|
|
210
|
+
input.selected.modelID === model.modelID) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
return input.isStoreVisible({ providerID: model.providerID, modelID: model.modelID });
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=model-visibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-visibility.js","sourceRoot":"","sources":["../../../src/core/models/model-visibility.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAS,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,2BAA2B,GAAG,QAAQ,CAAC;AAE7C,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS,yBAAyB,CAAC,CAAC;AAErE,+EAA+E;AAC/E,2EAA2E;AAC3E,wEAAwE;AACxE,0EAA0E;AAC1E,mCAAmC;AACnC,SAAS,aAAa,CAAC,OAAe,EAAE,gBAAyB;IAC/D,IAAI,gBAAgB;QAAE,OAAO,gBAAgB,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACn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