@kortix/sdk 0.13.40 → 0.13.42
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 +40 -7
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +7 -4
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.js +18 -4
- 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/cache/persisted-query-cache.d.ts.map +1 -1
- package/dist/core/cache/persisted-query-cache.js +9 -0
- package/dist/core/cache/persisted-query-cache.js.map +1 -1
- package/dist/core/client/kortix.d.ts +44 -3
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +22 -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 +88 -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/agent-config.d.ts +4 -0
- package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
- package/dist/core/rest/projects-client/agent-config.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +58 -2
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +27 -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 +24 -4
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +8 -3
- 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 +35 -0
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +14 -1
- 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/runtime/kortix-master.d.ts +74 -5
- package/dist/core/runtime/kortix-master.d.ts.map +1 -1
- package/dist/core/runtime/kortix-master.js +78 -5
- package/dist/core/runtime/kortix-master.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 +46 -2
- package/dist/core/session-sync/saved-transcript.d.ts.map +1 -1
- package/dist/core/session-sync/saved-transcript.js +40 -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/fetch-sse.d.ts +4 -0
- package/dist/core/stream/fetch-sse.d.ts.map +1 -1
- package/dist/core/stream/fetch-sse.js +4 -0
- package/dist/core/stream/fetch-sse.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/memory-helpers.d.ts +5 -0
- package/dist/core/turns/tools/memory-helpers.d.ts.map +1 -1
- package/dist/core/turns/tools/memory-helpers.js +9 -1
- package/dist/core/turns/tools/memory-helpers.js.map +1 -1
- package/dist/core/turns/tools/skill-helpers.d.ts +1 -1
- package/dist/core/turns/tools/skill-helpers.d.ts.map +1 -1
- package/dist/core/turns/tools/skill-helpers.js +7 -6
- package/dist/core/turns/tools/skill-helpers.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 +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -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 +19 -1
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +25 -54
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/runtime-actions.d.ts +7 -0
- package/dist/react/runtime-actions.d.ts.map +1 -1
- package/dist/react/runtime-actions.js +7 -0
- package/dist/react/runtime-actions.js.map +1 -1
- package/dist/react/session-cache-write.d.ts +1 -1
- package/dist/react/session-cache-write.d.ts.map +1 -1
- package/dist/react/session-cache-write.js +38 -4
- package/dist/react/session-cache-write.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +1 -1
- package/dist/react/use-feature-flag.d.ts +3 -3
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +8 -4
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-kortix-master.d.ts +81 -3
- package/dist/react/use-kortix-master.d.ts.map +1 -1
- package/dist/react/use-kortix-master.js +84 -3
- package/dist/react/use-kortix-master.js.map +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-events/helpers.d.ts.map +1 -1
- package/dist/react/use-opencode-events/helpers.js +5 -0
- package/dist/react/use-opencode-events/helpers.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-mcp.d.ts +6 -0
- package/dist/react/use-opencode-mcp.d.ts.map +1 -1
- package/dist/react/use-opencode-mcp.js +6 -0
- package/dist/react/use-opencode-mcp.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 +4 -28
- package/dist/react/use-opencode-sessions/agents.js.map +1 -1
- package/dist/react/use-opencode-sessions/mcp.d.ts +1 -0
- package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/mcp.js +1 -0
- package/dist/react/use-opencode-sessions/mcp.js.map +1 -1
- package/dist/react/use-opencode-sessions/parts.d.ts +4 -0
- package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/parts.js +4 -0
- package/dist/react/use-opencode-sessions/parts.js.map +1 -1
- package/dist/react/use-opencode-sessions/projects.d.ts +1 -0
- package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/projects.js +1 -0
- package/dist/react/use-opencode-sessions/projects.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-opencode-sessions/sessions.d.ts +1 -0
- package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.js +1 -0
- package/dist/react/use-opencode-sessions/sessions.js.map +1 -1
- package/dist/react/use-opencode-sessions/sharing.d.ts +2 -0
- package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sharing.js +2 -0
- package/dist/react/use-opencode-sessions/sharing.js.map +1 -1
- package/dist/react/use-opencode-sessions/tools.d.ts +2 -0
- package/dist/react/use-opencode-sessions/tools.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/tools.js +2 -0
- package/dist/react/use-opencode-sessions/tools.js.map +1 -1
- package/dist/react/use-project-sessions.d.ts +221 -1
- package/dist/react/use-project-sessions.d.ts.map +1 -1
- package/dist/react/use-project-sessions.js +27 -1
- package/dist/react/use-project-sessions.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 +25 -12
- 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 +3 -0
- package/dist/react/use-session-transcript-history.js.map +1 -1
- package/dist/react/use-session.d.ts +25 -15
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +136 -21
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-tunnel.d.ts +59 -7
- package/dist/react/use-tunnel.d.ts.map +1 -1
- package/dist/react/use-tunnel.js +82 -123
- package/dist/react/use-tunnel.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
- package/dist/core/session-sync/durable-log.d.ts +0 -96
- package/dist/core/session-sync/durable-log.d.ts.map +0 -1
- package/dist/core/session-sync/durable-log.js +0 -94
- package/dist/core/session-sync/durable-log.js.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { autoSeedableModels } from '@kortix/llm-catalog/lite';
|
|
2
|
+
import { healBedrockModelKey } from './bedrock-invokable.js';
|
|
3
|
+
import { isOfferedModel } from './model-flatten.js';
|
|
4
|
+
import { wireToModelKey } from './model-key.js';
|
|
5
|
+
/**
|
|
6
|
+
* Which model the session composer runs — framework-free, so every host
|
|
7
|
+
* resolves the same default from the same inputs.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The gateway's configured default for an agent, from
|
|
11
|
+
* `GET /projects/:id/model-defaults`: agent → project → account → platform.
|
|
12
|
+
* A free-tier account never resolves the platform default.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveModelDefault(data, agentName) {
|
|
15
|
+
const wire = (agentName ? data?.agentDefaults?.[agentName] : undefined) ??
|
|
16
|
+
data?.projectDefault ??
|
|
17
|
+
data?.accountDefault ??
|
|
18
|
+
(data?.freeTier ? undefined : data?.platformDefault);
|
|
19
|
+
return wire ? wireToModelKey(wire) : undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the composer's model. Every candidate must be offered by `models`
|
|
23
|
+
* (`isOfferedModel`: present and not `enabled: false`); an invalid one is
|
|
24
|
+
* skipped, never sent.
|
|
25
|
+
*
|
|
26
|
+
* Priority: `picks` (in order) > `serverDefault` > `globalDefault` >
|
|
27
|
+
* `agentModel` > fallback. Fallback: `configModel` (`provider/model`) > the
|
|
28
|
+
* first valid `recent` > each connected provider's configured default, else
|
|
29
|
+
* its first auto-seedable model (provider order = `providers.all`).
|
|
30
|
+
*/
|
|
31
|
+
export function resolveComposerModel(input) {
|
|
32
|
+
const { models, providers } = input;
|
|
33
|
+
const isValid = (model) => isOfferedModel(models, model);
|
|
34
|
+
const firstValid = (candidates) => candidates.find((model) => !!model && isValid(model));
|
|
35
|
+
const fallback = (() => {
|
|
36
|
+
// Priority 1: Config model (from opencode.json)
|
|
37
|
+
if (input.configModel) {
|
|
38
|
+
const parts = input.configModel.split('/');
|
|
39
|
+
if (parts.length >= 2) {
|
|
40
|
+
const [providerID, ...rest] = parts;
|
|
41
|
+
const modelID = rest.join('/');
|
|
42
|
+
if (isValid({ providerID, modelID })) {
|
|
43
|
+
return { providerID, modelID };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Priority 2: Most recent valid model from persisted recent list
|
|
48
|
+
for (const item of input.recent ?? []) {
|
|
49
|
+
if (isValid(item)) {
|
|
50
|
+
return item;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Priority 3: Provider defaults -> first model of first connected provider
|
|
54
|
+
if (providers) {
|
|
55
|
+
const defaults = providers.default || {};
|
|
56
|
+
const all = Array.isArray(providers.all) ? providers.all : [];
|
|
57
|
+
const connectedIds = Array.isArray(providers.connected) ? providers.connected : [];
|
|
58
|
+
const connected = all.filter((p) => connectedIds.includes(p.id));
|
|
59
|
+
for (const p of connected) {
|
|
60
|
+
const configured = defaults[p.id];
|
|
61
|
+
if (configured) {
|
|
62
|
+
const key = { providerID: p.id, modelID: configured };
|
|
63
|
+
if (isValid(key))
|
|
64
|
+
return key;
|
|
65
|
+
}
|
|
66
|
+
// `autoSeedableModels`, not the raw key order: on Bedrock the newest
|
|
67
|
+
// id is the BARE `xai.grok-4.6`, which Bedrock refuses for on-demand
|
|
68
|
+
// use. Auto-picking must never surface a bare id while the provider
|
|
69
|
+
// serves inference profiles. Inert for every other provider.
|
|
70
|
+
for (const model of autoSeedableModels(Object.keys(p.models).map((modelID) => ({ id: modelID })))) {
|
|
71
|
+
const key = { providerID: p.id, modelID: model.id };
|
|
72
|
+
if (isValid(key))
|
|
73
|
+
return key;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
})();
|
|
79
|
+
const explicit = firstValid(input.picks ?? []);
|
|
80
|
+
const resolved = explicit ??
|
|
81
|
+
firstValid([input.serverDefault, input.globalDefault, input.agentModel, fallback]);
|
|
82
|
+
// EVERY source above can hand back a bare Bedrock in-region id — the
|
|
83
|
+
// explicit slot most of all. Bedrock answers a hard 400 for those and
|
|
84
|
+
// OpenCode retries forever, so heal here, at the single seam every source
|
|
85
|
+
// funnels through. No-op off Bedrock.
|
|
86
|
+
return { model: healBedrockModelKey(resolved, models), explicit, fallback };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=composer-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer-model.js","sourceRoot":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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;AAwCvF;;;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,CAAC;IACnD,4DAA4D;IAC5D,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;iCAC6B;IAC7B,gBAAgB,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1F,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;wEACoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,EAAE,EACnB,GAAG,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAGT;AAkBD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,oBAAoB,GAAG,SAAS,EAC3C,IAAI,CAAC,EAAE;IACL;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CACrC,GACA,SAAS,EAAE,CAmEb"}
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
// The gateway lists every model under one synthetic `kortix` provider;
|
|
61
|
+
// a BYOK model names its real provider instead.
|
|
62
|
+
providerName: model.provider_name ?? p.name,
|
|
63
|
+
modelID,
|
|
64
|
+
modelName: (model.name || modelID).replace('(latest)', '').trim(),
|
|
65
|
+
variants: model.variants,
|
|
66
|
+
capabilities,
|
|
67
|
+
contextWindow: model.limit?.context,
|
|
68
|
+
releaseDate: model.release_date,
|
|
69
|
+
family: model.family,
|
|
70
|
+
cost: model.cost
|
|
71
|
+
? {
|
|
72
|
+
input: model.cost.input ?? 0,
|
|
73
|
+
output: model.cost.output ?? 0,
|
|
74
|
+
}
|
|
75
|
+
: undefined,
|
|
76
|
+
providerSource: p.source,
|
|
77
|
+
provider: model.provider,
|
|
78
|
+
reasoningOptions: model.reasoning_options,
|
|
79
|
+
description: model.description,
|
|
80
|
+
openWeights: model.open_weights,
|
|
81
|
+
lastUpdated: model.last_updated,
|
|
82
|
+
enabled: model.enabled,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
//# 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;AAoCvF,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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C,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,EAA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