@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,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,SAA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,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type ProviderAuthRequirement } from '@kortix/llm-catalog/lite';
|
|
2
|
+
import type { ProviderListResponse as SdkProviderListResponse } from '@opencode-ai/sdk/v2/client';
|
|
3
|
+
import type { ProjectLlmCatalogProvidersResponse, ProjectLlmCatalogResponse } from '../rest/projects-client/index.js';
|
|
4
|
+
export type ProviderListResponse = SdkProviderListResponse;
|
|
5
|
+
/**
|
|
6
|
+
* Provider → Kortix-owned auth requirement, derived from the shared
|
|
7
|
+
* models.dev catalog via `providerAuthRequirement` (NOT the raw catalog
|
|
8
|
+
* `env` list — see that function's doc comment for why: models.dev lists
|
|
9
|
+
* every auth method the upstream SDK supports, not what Kortix actually
|
|
10
|
+
* reads). Mirrors the `{ id, authRequirement }` projection of the web's
|
|
11
|
+
* `LLM_PROVIDERS` (built from the same catalog + the same override table),
|
|
12
|
+
* so connection inference is identical without depending on the web-only
|
|
13
|
+
* provider-modal catalog module.
|
|
14
|
+
*
|
|
15
|
+
* Reads `CATALOG_PROVIDER_ENV` (the catalog's `{ id, env }` projection), not
|
|
16
|
+
* `CATALOG`: this module is in every browser route's graph, and `CATALOG` is
|
|
17
|
+
* the full ~7.6 MB models.dev snapshot.
|
|
18
|
+
*/
|
|
19
|
+
export declare const LLM_PROVIDER_CREDENTIALS: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
authRequirement: ProviderAuthRequirement;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const GATEWAY_PROVIDER_IDS: Set<string>;
|
|
24
|
+
export declare function normalizeProviderList(providers: ProviderListResponse): ProviderListResponse;
|
|
25
|
+
/**
|
|
26
|
+
* True when a provider-list response actually carries usable models — i.e. at
|
|
27
|
+
* least one CONNECTED provider that exposes >=1 model. A response failing this
|
|
28
|
+
* is a transient boot state, not a real answer.
|
|
29
|
+
*/
|
|
30
|
+
export declare function providerListHasModels(providers: ProviderListResponse | undefined): boolean;
|
|
31
|
+
export declare function providerListHasGateway(providers: ProviderListResponse | undefined): boolean;
|
|
32
|
+
export declare function filterToGatewayProviders(providers: ProviderListResponse): ProviderListResponse;
|
|
33
|
+
export declare function mergeProviderLists(primary: ProviderListResponse, secondary: ProviderListResponse): ProviderListResponse;
|
|
34
|
+
export declare function filterToNativeProviders(providers: ProviderListResponse): ProviderListResponse;
|
|
35
|
+
export declare function mergeProjectSecretConnectedProviders(providers: ProviderListResponse, secretNames: Set<string>, providerCredentials: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
authRequirement: ProviderAuthRequirement;
|
|
38
|
+
}>): ProviderListResponse;
|
|
39
|
+
/** The catalog fields the pre-runtime picker source reads per model — a
|
|
40
|
+
* structural subset of `@kortix/llm-catalog`'s `CatalogModel` (the wire
|
|
41
|
+
* shape), typed loose so both the shared type and test fixtures satisfy it. */
|
|
42
|
+
interface NativeCatalogModel {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
released?: string | null;
|
|
46
|
+
status?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
family?: string;
|
|
49
|
+
reasoning?: boolean;
|
|
50
|
+
reasoning_options?: Array<{
|
|
51
|
+
type: string;
|
|
52
|
+
values?: Array<string | null>;
|
|
53
|
+
min?: number;
|
|
54
|
+
max?: number;
|
|
55
|
+
}>;
|
|
56
|
+
tool_call?: boolean;
|
|
57
|
+
attachment?: boolean;
|
|
58
|
+
open_weights?: boolean;
|
|
59
|
+
last_updated?: string;
|
|
60
|
+
modalities?: {
|
|
61
|
+
input?: string[];
|
|
62
|
+
output?: string[];
|
|
63
|
+
};
|
|
64
|
+
limit?: {
|
|
65
|
+
context?: number;
|
|
66
|
+
input?: number;
|
|
67
|
+
output?: number;
|
|
68
|
+
};
|
|
69
|
+
cost?: {
|
|
70
|
+
input?: number;
|
|
71
|
+
output?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare function nativeProviderListFromCatalog(catalog: {
|
|
75
|
+
providers: Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
models: Array<NativeCatalogModel>;
|
|
79
|
+
}>;
|
|
80
|
+
}, secretNames: Set<string>): ProviderListResponse;
|
|
81
|
+
/**
|
|
82
|
+
* ONE native picker across sandbox states. Pre-boot the picker reads the
|
|
83
|
+
* catalog synthesis (`nativeProviderListFromCatalog`); once the runtime
|
|
84
|
+
* reports `/config/providers` it is the truth for what the box can actually
|
|
85
|
+
* serve. Swapping sources on boot changed the picker under the user (provider
|
|
86
|
+
* order, Zen appearing, the auto-picked default flipping). Merged instead:
|
|
87
|
+
*
|
|
88
|
+
* - shared provider ids take the RUNTIME object (real variant settings, the
|
|
89
|
+
* box's exact model set), in CATALOG order (flagship rank);
|
|
90
|
+
* - runtime-only providers (Zen, auth.json logins) append after;
|
|
91
|
+
* - the curated catalog default wins per provider while the runtime serves
|
|
92
|
+
* that model, else the runtime default — the auto-pick is stable across
|
|
93
|
+
* boot and never names a model the box cannot run.
|
|
94
|
+
*/
|
|
95
|
+
export declare function mergeNativeProviderLists(catalog: ProviderListResponse | undefined, runtime: ProviderListResponse | undefined): ProviderListResponse | undefined;
|
|
96
|
+
export declare function connectedGatewayProviderIdsFromSecretNames(secretNames: Set<string>): Set<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Restamp `enabled` on a gateway ProviderListResponse from an overrides map
|
|
99
|
+
* (`wireModelId -> enabled`), touching only the models the map names. Pure —
|
|
100
|
+
* returns a new list. Used to optimistically update the cached
|
|
101
|
+
* `['project-providers', :id, 'gateway']` query when "Manage models" writes an
|
|
102
|
+
* override, so the session picker (which renders from THAT cache, staleTime
|
|
103
|
+
* Infinity) reflects the toggle without waiting for the refetch.
|
|
104
|
+
*/
|
|
105
|
+
export declare function applyEnablementToProviderList(providers: ProviderListResponse, overrides: Record<string, boolean>): ProviderListResponse;
|
|
106
|
+
export declare function projectLlmCatalogToProviderList(catalog: ProjectLlmCatalogResponse): ProviderListResponse;
|
|
107
|
+
/**
|
|
108
|
+
* A project session runtime's `/provider` answer, as the native picker reads
|
|
109
|
+
* it: normalized, providers the project's secrets connect marked connected,
|
|
110
|
+
* and the gateway's `kortix` provider removed.
|
|
111
|
+
*/
|
|
112
|
+
export declare function nativeRuntimeProviderList(runtime: ProviderListResponse, secretNames: Set<string>): ProviderListResponse;
|
|
113
|
+
/** The raw sources a project composer's model picker is built from. */
|
|
114
|
+
export interface PickerProviderListInput {
|
|
115
|
+
/** The project's `experimental.llm_gateway` flag (`GET /projects/:id/detail`). */
|
|
116
|
+
gatewayEnabled: boolean;
|
|
117
|
+
/** Gateway mode: `GET /projects/:id/model-picker`. */
|
|
118
|
+
modelPicker?: ProjectLlmCatalogResponse;
|
|
119
|
+
/** Native mode, once the session runtime is up: its `/provider` list. */
|
|
120
|
+
runtimeProviders?: ProviderListResponse;
|
|
121
|
+
/** Native mode, any time: `GET /projects/:id/llm-catalog/providers`. */
|
|
122
|
+
llmCatalogProviders?: ProjectLlmCatalogProvidersResponse;
|
|
123
|
+
/** Native mode: the project's secret NAMES (never values). */
|
|
124
|
+
secretNames?: Set<string>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The provider list a project composer's model picker renders — the same
|
|
128
|
+
* sources and rules `useOpenCodeProviders` applies. Feed the result to
|
|
129
|
+
* `flattenModels(list, { providerMode })`.
|
|
130
|
+
*
|
|
131
|
+
* - Gateway: the `/model-picker` catalog as the single `kortix` provider
|
|
132
|
+
* (`auto` dropped, per-model `enabled` kept).
|
|
133
|
+
* - Native: the catalog synthesis (connected by secret names) merged with the
|
|
134
|
+
* runtime list — runtime objects win, catalog order and curated defaults
|
|
135
|
+
* stay. A model-less runtime answer is a sandbox still wiring its providers
|
|
136
|
+
* and is ignored.
|
|
137
|
+
*
|
|
138
|
+
* `undefined` = nothing loaded yet.
|
|
139
|
+
*/
|
|
140
|
+
export declare function pickerProviderList(input: PickerProviderListInput): ProviderListResponse | undefined;
|
|
141
|
+
export {};
|
|
142
|
+
//# sourceMappingURL=provider-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-selection.d.ts","sourceRoot":"","sources":["../../../src/core/models/provider-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAM7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,oBAAoB,IAAI,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAElG,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,uBAAuB,CAAC;CAC1C,CAGE,CAAC;AAIJ,eAAO,MAAM,oBAAoB,aAAsB,CAAC;AAGxD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,oBAAoB,GAAG,oBAAoB,CAiC3F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,oBAAoB,GAAG,SAAS,GAAG,OAAO,CAO1F;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,oBAAoB,GAAG,SAAS,GAAG,OAAO,CAM3F;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,GAAG,oBAAoB,CAS9F;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,oBAAoB,GAC9B,oBAAoB,CAmBtB;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,oBAAoB,GAAG,oBAAoB,CAS7F;AAED,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,oBAAoB,EAC/B,WAAW,EAAE,GAAG,CAAC,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