@intentic/sandbox-contract 1.245.0 → 1.247.0
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 +17 -1
- package/dist/batch-runs.d.ts +2 -0
- package/dist/batch-runs.d.ts.map +1 -1
- package/dist/batch-runs.js +1 -0
- package/dist/batch-runs.js.map +1 -1
- package/dist/command-classes.d.ts +6 -3
- package/dist/command-classes.d.ts.map +1 -1
- package/dist/command-classes.js +43 -18
- package/dist/command-classes.js.map +1 -1
- package/dist/contracts/{cursor.contract.d.ts → accounts.contract.d.ts} +102 -3
- package/dist/contracts/accounts.contract.d.ts.map +1 -0
- package/dist/contracts/accounts.contract.js +61 -0
- package/dist/contracts/accounts.contract.js.map +1 -0
- package/dist/contracts/agent.contract.d.ts +19 -0
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +121 -0
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.js +4 -4
- package/dist/contracts/agents.contract.js.map +1 -1
- package/dist/contracts/ci.contract.d.ts +2 -0
- package/dist/contracts/ci.contract.d.ts.map +1 -1
- package/dist/contracts/host.contract.d.ts +35 -0
- package/dist/contracts/host.contract.d.ts.map +1 -1
- package/dist/contracts/host.contract.js +3 -2
- package/dist/contracts/host.contract.js.map +1 -1
- package/dist/contracts/personas.contract.d.ts +4 -2
- package/dist/contracts/personas.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +2 -2
- package/dist/contracts/settings.contract.d.ts +58 -20
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +80 -30
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.js +26 -17
- package/dist/contracts/system.contract.js.map +1 -1
- package/dist/contracts/usage.contract.d.ts +22 -0
- package/dist/contracts/usage.contract.d.ts.map +1 -1
- package/dist/contracts/usage.contract.js +19 -0
- package/dist/contracts/usage.contract.js.map +1 -1
- package/dist/definition.d.ts +20 -28
- package/dist/definition.d.ts.map +1 -1
- package/dist/documents.d.ts +0 -1
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +1 -2
- package/dist/documents.js.map +1 -1
- package/dist/embed.d.ts +23 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +84 -0
- package/dist/embed.js.map +1 -0
- package/dist/events.d.ts +21 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +5 -2
- package/dist/events.js.map +1 -1
- package/dist/fast-tier.js +1 -1
- package/dist/fast-tier.js.map +1 -1
- package/dist/history-state.d.ts.map +1 -1
- package/dist/history-state.js +2 -0
- package/dist/history-state.js.map +1 -1
- package/dist/index.d.ts +453 -306
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -15
- package/dist/index.js.map +1 -1
- package/dist/model-pins.d.ts +17 -0
- package/dist/model-pins.d.ts.map +1 -0
- package/dist/{quick-model.js → model-pins.js} +18 -11
- package/dist/model-pins.js.map +1 -0
- package/dist/model-roles.d.ts +144 -0
- package/dist/model-roles.d.ts.map +1 -0
- package/dist/model-roles.js +129 -0
- package/dist/model-roles.js.map +1 -0
- package/dist/peer-dial.d.ts +33 -0
- package/dist/peer-dial.d.ts.map +1 -0
- package/dist/peer-dial.js +79 -0
- package/dist/peer-dial.js.map +1 -0
- package/dist/peer-mcp-server.d.ts +36 -0
- package/dist/peer-mcp-server.d.ts.map +1 -0
- package/dist/peer-mcp-server.js +71 -0
- package/dist/peer-mcp-server.js.map +1 -0
- package/dist/provider-specs.d.ts +38 -20
- package/dist/provider-specs.d.ts.map +1 -1
- package/dist/provider-specs.js +39 -13
- package/dist/provider-specs.js.map +1 -1
- package/dist/runtime-state.d.ts +1 -1
- package/dist/runtime-state.js +1 -1
- package/dist/runtime-state.js.map +1 -1
- package/dist/safety-policy.d.ts +12 -3
- package/dist/safety-policy.d.ts.map +1 -1
- package/dist/safety-policy.js +30 -5
- package/dist/safety-policy.js.map +1 -1
- package/dist/schemas/agent.d.ts +27 -8
- package/dist/schemas/agent.d.ts.map +1 -1
- package/dist/schemas/agent.js +10 -4
- package/dist/schemas/agent.js.map +1 -1
- package/dist/schemas/agents.d.ts +42 -0
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/agents.js +25 -4
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/automations.d.ts +11 -2
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/automations.js +1 -1
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/ci.d.ts +6 -0
- package/dist/schemas/ci.d.ts.map +1 -1
- package/dist/schemas/ci.js +3 -2
- package/dist/schemas/ci.js.map +1 -1
- package/dist/schemas/context.d.ts +30 -0
- package/dist/schemas/context.d.ts.map +1 -0
- package/dist/schemas/context.js +34 -0
- package/dist/schemas/context.js.map +1 -0
- package/dist/schemas/{computers.d.ts → devices.d.ts} +154 -60
- package/dist/schemas/devices.d.ts.map +1 -0
- package/dist/schemas/devices.js +157 -0
- package/dist/schemas/devices.js.map +1 -0
- package/dist/schemas/hosts.d.ts +12 -0
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +1 -0
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/issues.d.ts +0 -5
- package/dist/schemas/issues.d.ts.map +1 -1
- package/dist/schemas/issues.js +0 -1
- package/dist/schemas/issues.js.map +1 -1
- package/dist/schemas/personas.d.ts +5 -3
- package/dist/schemas/personas.d.ts.map +1 -1
- package/dist/schemas/personas.js +3 -2
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/plan-limits.d.ts +20 -0
- package/dist/schemas/plan-limits.d.ts.map +1 -1
- package/dist/schemas/plan-limits.js +21 -0
- package/dist/schemas/plan-limits.js.map +1 -1
- package/dist/schemas/provider-oauth.d.ts +48 -16
- package/dist/schemas/provider-oauth.d.ts.map +1 -1
- package/dist/schemas/provider-oauth.js +22 -20
- package/dist/schemas/provider-oauth.js.map +1 -1
- package/dist/schemas/settings.d.ts +42 -16
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +22 -28
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/terminal.js +9 -9
- package/dist/schemas/terminal.js.map +1 -1
- package/dist/schemas/usage.d.ts +5 -2
- package/dist/schemas/usage.d.ts.map +1 -1
- package/dist/schemas/usage.js +5 -2
- package/dist/schemas/usage.js.map +1 -1
- package/dist/shell-regions.d.ts +4 -0
- package/dist/shell-regions.d.ts.map +1 -0
- package/dist/shell-regions.js +156 -0
- package/dist/shell-regions.js.map +1 -0
- package/dist/workspace-state.d.ts +8 -0
- package/dist/workspace-state.d.ts.map +1 -1
- package/dist/workspace-state.js +13 -5
- package/dist/workspace-state.js.map +1 -1
- package/package.json +37 -4
- package/src/agent-catalog.ts +2 -2
- package/src/arrival.ts +3 -3
- package/src/batch-runs.test.ts +10 -5
- package/src/batch-runs.ts +10 -3
- package/src/command-classes.test.ts +195 -71
- package/src/command-classes.ts +148 -46
- package/src/contracts/accounts.contract.ts +94 -0
- package/src/contracts/agents.contract.ts +4 -3
- package/src/contracts/exit.contract.ts +2 -2
- package/src/contracts/host.contract.ts +17 -5
- package/src/contracts/settings.contract.ts +1 -1
- package/src/contracts/system.contract.ts +43 -24
- package/src/contracts/usage.contract.ts +31 -0
- package/src/contracts/vpn.contract.ts +2 -2
- package/src/documents.test.ts +2 -1
- package/src/documents.ts +7 -11
- package/src/embed.test.ts +68 -0
- package/src/embed.ts +164 -0
- package/src/events.ts +31 -4
- package/src/fast-tier.test.ts +1 -1
- package/src/fast-tier.ts +5 -5
- package/src/history-state.ts +12 -3
- package/src/host-protocol.ts +2 -2
- package/src/index.ts +8 -16
- package/src/model-order.ts +1 -1
- package/src/{quick-model.test.ts → model-pins.test.ts} +73 -29
- package/src/model-pins.ts +183 -0
- package/src/model-roles.ts +224 -0
- package/src/peer-dial.test.ts +203 -0
- package/src/peer-dial.ts +163 -0
- package/src/peer-mcp-server.test.ts +104 -0
- package/src/peer-mcp-server.ts +144 -0
- package/src/plan-pools.ts +1 -1
- package/src/prompt-complexity.test.ts +1 -1
- package/src/prompt-complexity.ts +2 -2
- package/src/provider-specs.test.ts +45 -18
- package/src/provider-specs.ts +147 -67
- package/src/routes.test.ts +6 -3
- package/src/runner-protocol.ts +1 -1
- package/src/runtime-state.ts +2 -2
- package/src/safety-policy.test.ts +88 -0
- package/src/safety-policy.ts +84 -14
- package/src/schemas/agent.ts +83 -30
- package/src/schemas/agents.ts +67 -6
- package/src/schemas/automations.ts +6 -4
- package/src/schemas/capabilities.ts +4 -4
- package/src/schemas/ci.ts +23 -6
- package/src/schemas/context.ts +87 -0
- package/src/schemas/{computers.ts → devices.ts} +190 -107
- package/src/schemas/hosts.ts +5 -1
- package/src/schemas/issues.ts +0 -4
- package/src/schemas/personas.ts +8 -3
- package/src/schemas/plan-limits.ts +50 -0
- package/src/schemas/provider-oauth.ts +49 -52
- package/src/schemas/settings.ts +105 -140
- package/src/schemas/terminal.ts +12 -12
- package/src/schemas/usage.ts +62 -27
- package/src/schemas/version-seam.test.ts +0 -1
- package/src/shell-regions.ts +289 -0
- package/src/versions.ts +2 -2
- package/src/webext-links.ts +2 -2
- package/src/webext-protocol.ts +2 -2
- package/src/workspace-state.test.ts +48 -1
- package/src/workspace-state.ts +48 -11
- package/dist/agent-run-model.d.ts +0 -4
- package/dist/agent-run-model.d.ts.map +0 -1
- package/dist/agent-run-model.js +0 -13
- package/dist/agent-run-model.js.map +0 -1
- package/dist/contracts/claude.contract.d.ts +0 -91
- package/dist/contracts/claude.contract.d.ts.map +0 -1
- package/dist/contracts/claude.contract.js +0 -50
- package/dist/contracts/claude.contract.js.map +0 -1
- package/dist/contracts/cursor.contract.d.ts.map +0 -1
- package/dist/contracts/cursor.contract.js +0 -50
- package/dist/contracts/cursor.contract.js.map +0 -1
- package/dist/contracts/grok.contract.d.ts +0 -36
- package/dist/contracts/grok.contract.d.ts.map +0 -1
- package/dist/contracts/grok.contract.js +0 -31
- package/dist/contracts/grok.contract.js.map +0 -1
- package/dist/contracts/keys.contract.d.ts +0 -81
- package/dist/contracts/keys.contract.d.ts.map +0 -1
- package/dist/contracts/keys.contract.js +0 -51
- package/dist/contracts/keys.contract.js.map +0 -1
- package/dist/quick-model.d.ts +0 -15
- package/dist/quick-model.d.ts.map +0 -1
- package/dist/quick-model.js.map +0 -1
- package/dist/schemas/computers.d.ts.map +0 -1
- package/dist/schemas/computers.js +0 -135
- package/dist/schemas/computers.js.map +0 -1
- package/src/agent-run-model.test.ts +0 -76
- package/src/agent-run-model.ts +0 -65
- package/src/contracts/claude.contract.ts +0 -71
- package/src/contracts/cursor.contract.ts +0 -74
- package/src/contracts/grok.contract.ts +0 -41
- package/src/contracts/keys.contract.ts +0 -79
- package/src/quick-model.ts +0 -155
package/src/quick-model.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { accessFor, modelsFor, PROVIDERS } from "./agent-catalog.js";
|
|
2
|
-
import { ACCESS_COST } from "./provider-specs.js";
|
|
3
|
-
import { compareCheapestFirst, familyOf, tierRankOf } from "./model-order.js";
|
|
4
|
-
import type { AgentProvider } from "./schemas/agent.js";
|
|
5
|
-
|
|
6
|
-
/* THE QUICK MODEL, the cheap, fast model a small automatic job spends instead of the frontier model the chat
|
|
7
|
-
* runs on. Today that is the commit message written when an agent's work lands; anything else of that shape (a
|
|
8
|
-
* branch name, a PR description) reads the same answer, which is the reason this is a `quickModel` setting
|
|
9
|
-
* rather than a commit-message one.
|
|
10
|
-
*
|
|
11
|
-
* IT IS AN ORDER, NOT A MODEL, and that is the whole shape of this file. A single pick is a single point of
|
|
12
|
-
* failure: the account it names spends its allowance on the chat all morning, and every job for the rest of the
|
|
13
|
-
* day fails on a limit while three other connected providers sit idle. So the setting is a LIST
|
|
14
|
-
* read top to bottom, the resolver hands back the whole ladder, and the daemon walks it until one answers.
|
|
15
|
-
* Nothing here decides WHICH failures are worth stepping over, that is the daemon's, since only it has run
|
|
16
|
-
* the call, this side only says what the running order is.
|
|
17
|
-
*
|
|
18
|
-
* The rule lives in the contract because BOTH sides need the same answer for different jobs: the daemon runs
|
|
19
|
-
* the model, and the browser has to NAME it, in the settings row's "Auto (…)" label, before anything has been
|
|
20
|
-
* run. Two implementations would drift precisely where it matters most, since a label promising Haiku while the
|
|
21
|
-
* daemon bills Opus is worse than no label.
|
|
22
|
-
*
|
|
23
|
-
* The default is DERIVED, NEVER STORED. `quickModel` ships EMPTY and that means "work it out from whatever is
|
|
24
|
-
* connected right now", so connecting a Google account tomorrow improves the default by itself and
|
|
25
|
-
* disconnecting a pinned provider degrades to Auto instead of to a dead button. Same instinct as the rest of
|
|
26
|
-
* this repo's model handling: model-order.ts derives tier and recency from the id and curates nothing, and the
|
|
27
|
-
* web's defaultModelFor reads the live catalog rather than naming an id that a release will falsify. */
|
|
28
|
-
|
|
29
|
-
/* One provider's standing in the decision: whether a turn on it can be sent at all, and what its catalog holds.
|
|
30
|
-
*
|
|
31
|
-
* ACP agents are deliberately not expressible here, an ACP row's model id is empty because the agent owns its
|
|
32
|
-
* own model, so there is no cheap rung to point it at. `endpoint/<id>` providers ARE, and have to be: their
|
|
33
|
-
* models appear in the same picker the settings row builds its options from, so a pin naming one has to hold
|
|
34
|
-
* rather than fall silently back to Auto and spend an account the user was deliberately steering away from. */
|
|
35
|
-
export interface QuickModelSource {
|
|
36
|
-
// AgentProvider, not NativeProvider: an endpoint's id is user-created and cannot be in a fixed union. Auto's
|
|
37
|
-
// ranking degrades gracefully for one, costOf falls to the metered rung and an id with no tier word is
|
|
38
|
-
// UNRANKED, which is genuine last place, so an endpoint effectively only wins Auto when nothing else is
|
|
39
|
-
// connected, while a PIN on one holds. Both are the right answers: what a turn on someone's own model server
|
|
40
|
-
// costs is not a fact this repo can know, so it is not one Auto should be asserting.
|
|
41
|
-
readonly provider: AgentProvider;
|
|
42
|
-
// The same connection predicate every other surface gates on (access.ts web-side, the daemon's own account
|
|
43
|
-
// stores daemon-side). A catalog is never empty by construction, so "has rows" says nothing about "can send".
|
|
44
|
-
readonly ready: boolean;
|
|
45
|
-
readonly models: readonly string[];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface QuickModelChoice {
|
|
49
|
-
readonly provider: AgentProvider;
|
|
50
|
-
readonly model: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// A pinned selection on the wire: `${provider}:${modelId}`, the same key shape the model picker already mints
|
|
54
|
-
// for its entries (PickerEntry.key). An empty LIST of these ⇒ Auto.
|
|
55
|
-
export const quickModelKey = (choice: QuickModelChoice): string => `${choice.provider}:${choice.model}`;
|
|
56
|
-
|
|
57
|
-
/* Split on the FIRST colon only: a provider id never contains one and a model id might. Exported because the
|
|
58
|
-
* key is what several surfaces carry a pinned pair AS: `autoFastModels` stores the same keys, the settings rows
|
|
59
|
-
* read one back to draw the model they name, and a session composed from a pin travels as one (composeSession).
|
|
60
|
-
*
|
|
61
|
-
* `agentRunModels` is the one list that does NOT: an agent-run entry is an object, because it carries how the
|
|
62
|
-
* model is to be run beside which model it is (AgentRunPinSchema), and a key with knobs spelled into it would
|
|
63
|
-
* be a second encoding of the same thing for nobody's benefit. */
|
|
64
|
-
export const parsePinned = (pinned: string): QuickModelChoice | undefined => {
|
|
65
|
-
const separator = pinned.indexOf(`:`);
|
|
66
|
-
if (separator <= 0 || separator === pinned.length - 1) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
return { provider: pinned.slice(0, separator), model: pinned.slice(separator + 1) };
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/* A pin as a person reads it: the catalog's own label for the id, or the id itself for one the static catalog
|
|
73
|
-
* has not caught up with (the picker offers a custom-id escape hatch, so this is a real case rather than a
|
|
74
|
-
* defensive branch). Beside parsePinned because the two are always wanted together, by any surface that has to
|
|
75
|
-
* name what a click is about to spend BEFORE it spends it, and the two loudest of those are extensions that
|
|
76
|
-
* share no other code with each other. */
|
|
77
|
-
export const pinnedModelLabel = (choice: QuickModelChoice): string =>
|
|
78
|
-
modelsFor(choice.provider).find((option) => option.value === choice.model)?.label ?? choice.model;
|
|
79
|
-
|
|
80
|
-
// The cheapest row a provider publishes, its whole catalog read from the cheap end. Undefined for a catalog
|
|
81
|
-
// that hasn't loaded yet, which is a real state: every provider serves a floor, but only once something has
|
|
82
|
-
// asked it.
|
|
83
|
-
const cheapestOf = (source: QuickModelSource): string | undefined => source.models.toSorted(compareCheapestFirst)[0];
|
|
84
|
-
|
|
85
|
-
// Where a provider's cheapest row sits on the shared tier scale, and therefore how well it answers the question
|
|
86
|
-
// this whole module asks. UNRANKED (-1) is a genuine last place: it means the id carries no tier word we know,
|
|
87
|
-
// so the row is the provider's base line rather than its budget one.
|
|
88
|
-
const tierOf = (model: string): number => tierRankOf(familyOf(model));
|
|
89
|
-
|
|
90
|
-
// PROVIDERS order, as the final tiebreak. Arbitrary, but the SAME arbitrary answer on every read, the property
|
|
91
|
-
// compareUnrankedModelIds exists to guarantee, and the one a default actually needs. An endpoint is in no fixed
|
|
92
|
-
// list, so it reads -1 and leads the tiebreak; unreachable in practice, since it can never tie on cost.
|
|
93
|
-
const providerOrder = (provider: AgentProvider): number => PROVIDERS.findIndex((entry) => entry.value === provider);
|
|
94
|
-
|
|
95
|
-
// How much a call on this provider costs at the margin. Every native provider declares an access kind; an
|
|
96
|
-
// endpoint declares none, and takes the metered rung, the conservative reading of a model API whose bill this
|
|
97
|
-
// repo cannot see, which keeps Auto from reaching for someone's paid gateway on its own initiative.
|
|
98
|
-
const costOf = (provider: AgentProvider): number => {
|
|
99
|
-
const access = accessFor(provider);
|
|
100
|
-
return access === undefined ? ACCESS_COST.key : ACCESS_COST[access.kind];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/* AUTO, every connected provider's cheapest row, best-first, as a ladder rather than a winner.
|
|
104
|
-
*
|
|
105
|
-
* Ranked on TIER FIRST, then cost. That order is the point of the feature: the helper exists to not be the
|
|
106
|
-
* frontier model, so a free flagship is still the wrong tool, while a free Haiku-class row and a subscription
|
|
107
|
-
* Haiku-class row differ only in whose quota they spend. Cost then breaks that tie towards the channel the user
|
|
108
|
-
* is not paying per token for, and against the one they are.
|
|
109
|
-
*
|
|
110
|
-
* The whole ladder, not just its head, because the same ranking that picks the best answer also states the best
|
|
111
|
-
* SECOND answer, and a sandbox with three accounts connected should not lose its commit messages for six hours
|
|
112
|
-
* because one of them is spent. */
|
|
113
|
-
const autoLadder = (sources: readonly QuickModelSource[]): readonly QuickModelChoice[] =>
|
|
114
|
-
sources
|
|
115
|
-
.filter((source) => source.ready)
|
|
116
|
-
.flatMap((source) => {
|
|
117
|
-
const model = cheapestOf(source);
|
|
118
|
-
return model === undefined ? [] : [{ provider: source.provider, model }];
|
|
119
|
-
})
|
|
120
|
-
.toSorted(
|
|
121
|
-
(left, right) =>
|
|
122
|
-
tierOf(right.model) - tierOf(left.model) ||
|
|
123
|
-
costOf(left.provider) - costOf(right.provider) ||
|
|
124
|
-
providerOrder(left.provider) - providerOrder(right.provider),
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
/* WHICH MODELS A QUICK HELPER MAY RUN, IN THE ORDER IT SHOULD TRY THEM, given what this sandbox has connected.
|
|
128
|
-
* `pinned` is the stored setting: an ordered list of `${provider}:${model}` keys, empty for Auto.
|
|
129
|
-
*
|
|
130
|
-
* A pin only holds while its provider is READY: an account the user disconnected would otherwise sit at the
|
|
131
|
-
* head of the chain failing on a credential error, when the sandbox can plainly still answer. Dropping it is
|
|
132
|
-
* the same move the composer already makes when a live catalog stops offering the selected model.
|
|
133
|
-
*
|
|
134
|
-
* THE PINNED LIST IS THE WHOLE ANSWER whenever any of it survives that filter. Auto does NOT get appended
|
|
135
|
-
* underneath, and that is deliberate: a user who writes down three models has said which accounts this feature
|
|
136
|
-
* may spend, and quietly reaching for a fourth when all three are out is exactly the "spend an account they
|
|
137
|
-
* were steering away from" failure a pin exists to prevent. When NONE of the pins is connected any more the
|
|
138
|
-
* list has stopped saying anything about this sandbox, so Auto takes over rather than leaving a dead button.
|
|
139
|
-
*
|
|
140
|
-
* Empty when nothing is connected: the caller renders a control that says so, rather than a live button that
|
|
141
|
-
* fails on click. */
|
|
142
|
-
export const resolveQuickModels = (sources: readonly QuickModelSource[], pinned: readonly string[]): readonly QuickModelChoice[] => {
|
|
143
|
-
const ready = new Set(sources.filter((source) => source.ready).map((source) => source.provider));
|
|
144
|
-
const requested = pinned.flatMap((key) => {
|
|
145
|
-
// Taken verbatim, unvalidated against the catalog on purpose: the picker already offers a custom-id
|
|
146
|
-
// escape hatch for a model a catalog hasn't caught up with, and second-guessing the user's own id here
|
|
147
|
-
// would silently run a different model than the settings row names.
|
|
148
|
-
const choice = parsePinned(key);
|
|
149
|
-
return choice === undefined || !ready.has(choice.provider) ? [] : [choice];
|
|
150
|
-
});
|
|
151
|
-
// The same model twice would spend two attempts proving the same account is out, a real state, since the
|
|
152
|
-
// list is edited by hand and Auto's ladder can rank a provider the user has also pinned.
|
|
153
|
-
const chain = [...new Map(requested.map((choice) => [quickModelKey(choice), choice])).values()];
|
|
154
|
-
return chain.length > 0 ? chain : autoLadder(sources);
|
|
155
|
-
};
|