@every-app/sdk 0.3.0-rc.9 → 0.3.1
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 +79 -74
- package/dist/cloudflare/catalogSettings.generated.d.ts +19 -6
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +43 -14
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/worker.d.ts +63 -9
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +45 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/aiDefault.d.ts +36 -79
- package/dist/internal/aiDefault.d.ts.map +1 -1
- package/dist/internal/aiDefault.js +47 -149
- package/dist/internal/aiProviders.d.ts +1 -1
- package/dist/internal/aiProviders.d.ts.map +1 -1
- package/dist/internal/aiProviders.js +2 -2
- package/dist/internal/appSettings.d.ts +140 -89
- package/dist/internal/appSettings.d.ts.map +1 -1
- package/dist/internal/appSettings.js +264 -156
- package/dist/internal/capabilities.d.ts +109 -503
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +30 -550
- package/dist/internal/catalog/commerce.js +1 -1
- package/dist/internal/catalog/index.d.ts +35 -0
- package/dist/internal/catalog/index.d.ts.map +1 -1
- package/dist/internal/catalog/infra.d.ts +35 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -1
- package/dist/internal/catalog/infra.js +65 -0
- package/dist/internal/devProviders.d.ts +1 -19
- package/dist/internal/devProviders.d.ts.map +1 -1
- package/dist/internal/devProviders.js +7 -1
- package/dist/internal/events.d.ts +52 -1
- package/dist/internal/events.d.ts.map +1 -1
- package/dist/internal/events.js +66 -4
- package/dist/internal/gatewaySettings.d.ts +6 -16
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +5 -23
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/mcpOAuth.d.ts +210 -0
- package/dist/internal/mcpOAuth.d.ts.map +1 -0
- package/dist/internal/mcpOAuth.js +735 -0
- package/dist/internal/oauthClient.d.ts +36 -44
- package/dist/internal/oauthClient.d.ts.map +1 -1
- package/dist/internal/oauthClient.js +30 -113
- package/dist/internal/oauthPresets.d.ts +356 -20
- package/dist/internal/oauthPresets.d.ts.map +1 -1
- package/dist/internal/oauthPresets.js +183 -861
- package/dist/internal/oauthScopes.d.ts +43 -155
- package/dist/internal/oauthScopes.d.ts.map +1 -1
- package/dist/internal/oauthScopes.js +82 -475
- package/dist/internal/oauthSpec.d.ts +28 -71
- package/dist/internal/oauthSpec.d.ts.map +1 -1
- package/dist/internal/oauthSpec.js +172 -448
- package/dist/internal/protocol.d.ts +24 -14
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +26 -7
- package/dist/internal/providerApps.d.ts +2 -2
- package/dist/internal/providerApps.js +2 -2
- package/dist/internal/providerRegistry.d.ts +5 -64
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +19 -118
- package/dist/internal/providerSpec.d.ts.map +1 -1
- package/dist/internal/providerSpec.js +14 -36
- package/dist/internal/remoteMcp.d.ts +191 -47
- package/dist/internal/remoteMcp.d.ts.map +1 -1
- package/dist/internal/remoteMcp.js +338 -133
- package/dist/internal/signInProviders.d.ts +1 -1
- package/dist/internal/signInProviders.d.ts.map +1 -1
- package/dist/internal/tools.d.ts +15 -8
- package/dist/internal/tools.d.ts.map +1 -1
- package/dist/internal/tools.js +9 -8
- package/dist/manifest.d.ts +96 -40
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +1 -1
- package/dist/server/ai.d.ts +1 -93
- package/dist/server/ai.d.ts.map +1 -1
- package/dist/server/ai.js +17 -111
- package/dist/server/attribution.d.ts +11 -1
- package/dist/server/attribution.d.ts.map +1 -1
- package/dist/server/attribution.js +7 -1
- package/dist/server/connectUrl.d.ts +5 -10
- package/dist/server/connectUrl.d.ts.map +1 -1
- package/dist/server/connectUrl.js +22 -14
- package/dist/server/context.d.ts +12 -14
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/context.js +23 -25
- package/dist/server/eventsEndpoint.d.ts +48 -0
- package/dist/server/eventsEndpoint.d.ts.map +1 -0
- package/dist/server/eventsEndpoint.js +145 -0
- package/dist/server/everyApp.d.ts +16 -26
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +22 -46
- package/dist/server/gatewayFetch.d.ts +1 -1
- package/dist/server/gatewayFetch.js +1 -1
- package/dist/server/index.d.ts +6 -9
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -8
- package/dist/server/integrationFetch.d.ts +66 -72
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +120 -392
- package/dist/server/refusal.d.ts +0 -9
- package/dist/server/refusal.d.ts.map +1 -1
- package/dist/server/refusal.js +0 -22
- package/dist/server/tools.d.ts +18 -7
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +15 -5
- package/dist/server/toolsEndpoint.d.ts +2 -1
- package/dist/server/toolsEndpoint.d.ts.map +1 -1
- package/dist/server/toolsEndpoint.js +4 -3
- package/dist/server/webhooks.d.ts +56 -0
- package/dist/server/webhooks.d.ts.map +1 -0
- package/dist/server/webhooks.js +205 -0
- package/dist/testing/index.d.ts +2 -3
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -6
- package/package.json +6 -1
- package/dist/server/aiBinding.d.ts +0 -68
- package/dist/server/aiBinding.d.ts.map +0 -1
- package/dist/server/aiBinding.js +0 -294
- package/dist/server/authorizeUrl.d.ts +0 -43
- package/dist/server/authorizeUrl.d.ts.map +0 -1
- package/dist/server/authorizeUrl.js +0 -106
- package/dist/server/emailBinding.d.ts +0 -72
- package/dist/server/emailBinding.d.ts.map +0 -1
- package/dist/server/emailBinding.js +0 -124
- package/dist/server/fromMcpTools.d.ts +0 -89
- package/dist/server/fromMcpTools.d.ts.map +0 -1
- package/dist/server/fromMcpTools.js +0 -192
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Gateway's default model provider: what an app that says "I need a
|
|
3
|
-
* chat model" (manifest `ai: { chat: true }`, the SDK's `
|
|
3
|
+
* chat model" (manifest `ai: { chat: true }`, the SDK's `aiBaseUrl()`, the route
|
|
4
4
|
* `/api/ai/default/…`) is served (docs/design/2026-10-model-providers.md).
|
|
5
5
|
*
|
|
6
|
-
* The default is
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* The default is one setting per workspace, `<provider>[/<model>]`
|
|
7
|
+
* (`everyapp ai default`, Manage workspace → Usage → AI default, the
|
|
8
|
+
* `everyapp_ai_default` tool; `org_settings.ai_default`): the provider is
|
|
9
|
+
* everything up to the first slash, the model everything after it. With
|
|
10
|
+
* no setting, the shipped order below decides: the first provider whose
|
|
11
|
+
* Gateway settings are all set; with none set, the first of the order
|
|
12
|
+
* with the settings it needs, so "Needs setup" asks for one key.
|
|
11
13
|
* OpenRouter comes first because one key reaches many models; Workers AI
|
|
12
14
|
* second because it needs no provider account (the Gateway's own
|
|
13
15
|
* Cloudflare token), with weaker models; then the single-vendor keys.
|
|
@@ -15,15 +17,14 @@
|
|
|
15
17
|
* and fronts whichever provider the default resolves to when
|
|
16
18
|
* `AI_GATEWAY_ID` is set (./capabilities.ts, `aig`).
|
|
17
19
|
*
|
|
18
|
-
* The
|
|
19
|
-
*
|
|
20
|
-
* `
|
|
21
|
-
* `embeddings.seedModel`). Nothing reads a seed except through here.
|
|
20
|
+
* The chat model is the setting's model, else the catalog entry's seed
|
|
21
|
+
* (`chat.seedModel`); embeddings always use the entry's seed
|
|
22
|
+
* (`embeddings.seedModel`). Nothing reads a seed except through here.
|
|
22
23
|
*
|
|
23
24
|
* Everything here is pure: what is set is asked of the caller (`isSet`),
|
|
24
25
|
* which reads the Gateway's env, the Worker's secret names, or `.dev.vars`.
|
|
25
26
|
*/
|
|
26
|
-
import { CATALOG, } from "./capabilities.js";
|
|
27
|
+
import { CATALOG, authSettingNames, } from "./capabilities.js";
|
|
27
28
|
/** The reserved provider id apps call for the default: `/api/ai/default/…`. */
|
|
28
29
|
export const AI_DEFAULT_PROVIDER = "default";
|
|
29
30
|
/** The catalog id of Cloudflare AI Gateway, the proxy entry. */
|
|
@@ -60,74 +61,6 @@ export function isAiModelName(value) {
|
|
|
60
61
|
value.trim() === value &&
|
|
61
62
|
!/[\u0000-\u001f\u007f]/.test(value));
|
|
62
63
|
}
|
|
63
|
-
/**
|
|
64
|
-
* `org_settings.ai_models` as stored: a JSON object of provider id →
|
|
65
|
-
* `{ chat?, embeddings? }`. Anything else (null, malformed JSON, a field
|
|
66
|
-
* that isn't a model name) reads as no setting, so the seed serves.
|
|
67
|
-
*/
|
|
68
|
-
export function parseAiModelSettings(value) {
|
|
69
|
-
if (typeof value !== "string" || value.trim() === "")
|
|
70
|
-
return {};
|
|
71
|
-
let parsed;
|
|
72
|
-
try {
|
|
73
|
-
parsed = JSON.parse(value);
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return {};
|
|
77
|
-
}
|
|
78
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
79
|
-
return {};
|
|
80
|
-
const settings = {};
|
|
81
|
-
for (const [provider, entry] of Object.entries(parsed)) {
|
|
82
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
83
|
-
continue;
|
|
84
|
-
const setting = {};
|
|
85
|
-
for (const kind of ["chat", "embeddings"]) {
|
|
86
|
-
const model = entry[kind];
|
|
87
|
-
if (typeof model === "string" && isAiModelName(model)) {
|
|
88
|
-
setting[kind] = model;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (setting.chat !== undefined || setting.embeddings !== undefined) {
|
|
92
|
-
settings[provider] = setting;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return settings;
|
|
96
|
-
}
|
|
97
|
-
/** The stored text of the settings, providers sorted; null when nothing is set. */
|
|
98
|
-
export function formatAiModelSettings(settings) {
|
|
99
|
-
const providers = Object.keys(settings)
|
|
100
|
-
.filter((id) => settings[id]?.chat !== undefined ||
|
|
101
|
-
settings[id]?.embeddings !== undefined)
|
|
102
|
-
.sort();
|
|
103
|
-
if (providers.length === 0)
|
|
104
|
-
return null;
|
|
105
|
-
return JSON.stringify(Object.fromEntries(providers.map((id) => {
|
|
106
|
-
const { chat, embeddings } = settings[id];
|
|
107
|
-
return [
|
|
108
|
-
id,
|
|
109
|
-
{
|
|
110
|
-
...(chat === undefined ? {} : { chat }),
|
|
111
|
-
...(embeddings === undefined ? {} : { embeddings }),
|
|
112
|
-
},
|
|
113
|
-
];
|
|
114
|
-
})));
|
|
115
|
-
}
|
|
116
|
-
/** `settings` with one provider's models changed by `patch`. */
|
|
117
|
-
export function withAiModelSetting(settings, provider, patch) {
|
|
118
|
-
const next = { ...settings[provider] };
|
|
119
|
-
for (const kind of ["chat", "embeddings"]) {
|
|
120
|
-
const value = patch[kind];
|
|
121
|
-
if (value === null)
|
|
122
|
-
delete next[kind];
|
|
123
|
-
else if (value !== undefined)
|
|
124
|
-
next[kind] = value;
|
|
125
|
-
}
|
|
126
|
-
const rest = Object.fromEntries(Object.entries(settings).filter(([id]) => id !== provider));
|
|
127
|
-
return next.chat === undefined && next.embeddings === undefined
|
|
128
|
-
? rest
|
|
129
|
-
: { ...rest, [provider]: next };
|
|
130
|
-
}
|
|
131
64
|
/** A choice must name a provider id; the model is free text after the first slash. */
|
|
132
65
|
const CHOICE = /^([a-z][a-z0-9-]{1,39})(?:\/(.{1,200}))?$/;
|
|
133
66
|
/**
|
|
@@ -148,27 +81,20 @@ export function parseAiDefaultChoice(value) {
|
|
|
148
81
|
export function formatAiDefaultChoice(choice) {
|
|
149
82
|
return choice.model ? `${choice.provider}/${choice.model}` : choice.provider;
|
|
150
83
|
}
|
|
151
|
-
/**
|
|
152
|
-
* The provider id `org_settings.ai_default` holds, or null. The column
|
|
153
|
-
* holds the provider alone (its models are in `ai_models`); text after a
|
|
154
|
-
* first slash is not read.
|
|
155
|
-
*/
|
|
156
|
-
export function parseAiDefaultProvider(value) {
|
|
157
|
-
return parseAiDefaultChoice(value)?.provider ?? null;
|
|
158
|
-
}
|
|
159
84
|
export function canBeAiDefault(capability) {
|
|
160
85
|
return (capability?.mode === "ai" &&
|
|
161
86
|
capability.kind !== "proxy" &&
|
|
162
87
|
capability.chat !== undefined);
|
|
163
88
|
}
|
|
164
89
|
/**
|
|
165
|
-
* The Gateway settings an `ai` entry needs before it serves:
|
|
166
|
-
*
|
|
167
|
-
*
|
|
90
|
+
* The Gateway settings an `ai` entry needs before it serves: every setting
|
|
91
|
+
* its `auth` names, the key and a Basic username held as a setting (unless
|
|
92
|
+
* the entry works without them, `authOptional`), and what its URL needs
|
|
93
|
+
* besides (`alsoNeeds`).
|
|
168
94
|
*/
|
|
169
95
|
export function aiRequiredSettings(capability) {
|
|
170
96
|
return [
|
|
171
|
-
...(capability.authOptional ? [] :
|
|
97
|
+
...(capability.authOptional ? [] : authSettingNames(capability.auth)),
|
|
172
98
|
...(capability.alsoNeeds ?? []),
|
|
173
99
|
];
|
|
174
100
|
}
|
|
@@ -184,28 +110,16 @@ export function aiGatewayConfigured(isSet) {
|
|
|
184
110
|
export function viaAiGateway(capability, isSet) {
|
|
185
111
|
return capability.aig !== undefined && aiGatewayConfigured(isSet);
|
|
186
112
|
}
|
|
187
|
-
|
|
188
|
-
function modelsOf(id, capability, models) {
|
|
189
|
-
const setting = models[id];
|
|
190
|
-
const { chat, embeddings } = capability;
|
|
191
|
-
return {
|
|
192
|
-
model: setting?.chat ?? chat.seedModel,
|
|
193
|
-
...(embeddings
|
|
194
|
-
? { embeddingsModel: setting?.embeddings ?? embeddings.seedModel }
|
|
195
|
-
: {}),
|
|
196
|
-
seed: {
|
|
197
|
-
chat: chat.seedModel,
|
|
198
|
-
...(embeddings ? { embeddings: embeddings.seedModel } : {}),
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function candidateOf(id, capability, isSet, models) {
|
|
113
|
+
function candidateOf(id, capability, isSet) {
|
|
203
114
|
return {
|
|
204
115
|
id,
|
|
205
116
|
label: capability.label,
|
|
206
117
|
settings: aiRequiredSettings(capability),
|
|
207
118
|
configured: aiProviderConfigured(capability, isSet),
|
|
208
|
-
|
|
119
|
+
model: capability.chat.seedModel,
|
|
120
|
+
...(capability.embeddings
|
|
121
|
+
? { embeddingsModel: capability.embeddings.seedModel }
|
|
122
|
+
: {}),
|
|
209
123
|
viaAiGateway: viaAiGateway(capability, isSet),
|
|
210
124
|
embeddings: capability.embeddings !== undefined,
|
|
211
125
|
};
|
|
@@ -215,7 +129,7 @@ function candidateOf(id, capability, isSet, models) {
|
|
|
215
129
|
* then any other `ai` entry of `lookup` with a chat route (a registered
|
|
216
130
|
* row, one day), each with its state.
|
|
217
131
|
*/
|
|
218
|
-
export function aiDefaultCandidates(isSet, lookup = CATALOG
|
|
132
|
+
export function aiDefaultCandidates(isSet, lookup = CATALOG) {
|
|
219
133
|
const ids = [
|
|
220
134
|
...AI_DEFAULT_ORDER,
|
|
221
135
|
...lookup.ids().filter((id) => !AI_DEFAULT_ORDER.includes(id)),
|
|
@@ -225,12 +139,10 @@ export function aiDefaultCandidates(isSet, lookup = CATALOG, models = {}) {
|
|
|
225
139
|
// A registered row whose key isn't bound to the hosts it has now reads
|
|
226
140
|
// as unset everywhere (`providers.value-bound-to-hosts`).
|
|
227
141
|
const set = lookup.bound && !lookup.bound(id) ? () => false : isSet;
|
|
228
|
-
return canBeAiDefault(capability)
|
|
229
|
-
? [candidateOf(id, capability, set, models)]
|
|
230
|
-
: [];
|
|
142
|
+
return canBeAiDefault(capability) ? [candidateOf(id, capability, set)] : [];
|
|
231
143
|
});
|
|
232
144
|
}
|
|
233
|
-
/** Why `choice
|
|
145
|
+
/** Why `choice` can't be the default, or null when it can. */
|
|
234
146
|
export function aiDefaultChoiceProblem(choice, lookup = CATALOG) {
|
|
235
147
|
const capability = lookup.get(choice.provider);
|
|
236
148
|
if (!capability)
|
|
@@ -244,47 +156,29 @@ export function aiDefaultChoiceProblem(choice, lookup = CATALOG) {
|
|
|
244
156
|
if (!capability.chat) {
|
|
245
157
|
return `${capability.label} has no OpenAI-shaped chat route, so it can't serve the default; an app pins it by listing it under providers`;
|
|
246
158
|
}
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Why `patch` can't be stored for `provider`, or null when it can: the
|
|
251
|
-
* provider must be one the default can be, a model name must be a model
|
|
252
|
-
* name, and an embeddings model needs the entry's embeddings route.
|
|
253
|
-
*/
|
|
254
|
-
export function aiModelPatchProblem(provider, patch, lookup = CATALOG) {
|
|
255
|
-
const why = aiDefaultChoiceProblem({ provider }, lookup);
|
|
256
|
-
if (why)
|
|
257
|
-
return why;
|
|
258
|
-
const capability = lookup.get(provider);
|
|
259
|
-
if (!canBeAiDefault(capability))
|
|
260
|
-
return `${provider} can't serve the default`;
|
|
261
|
-
for (const kind of ["chat", "embeddings"]) {
|
|
262
|
-
const value = patch[kind];
|
|
263
|
-
if (typeof value === "string" && !isAiModelName(value)) {
|
|
264
|
-
return `${JSON.stringify(value)} isn't a model id: 1 to 200 characters, no surrounding spaces`;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (typeof patch.embeddings === "string" && !capability.embeddings) {
|
|
268
|
-
return `${capability.label} has no embeddings route, so it serves no embeddings model`;
|
|
159
|
+
if (choice.model !== undefined && !isAiModelName(choice.model)) {
|
|
160
|
+
return `${JSON.stringify(choice.model)} isn't a model id: 1 to 200 characters, no surrounding spaces`;
|
|
269
161
|
}
|
|
270
162
|
return null;
|
|
271
163
|
}
|
|
272
164
|
/**
|
|
273
|
-
* The Gateway's effective default, from the
|
|
274
|
-
* what is set. A
|
|
165
|
+
* The Gateway's effective default, from the workspace's setting (or none)
|
|
166
|
+
* and what is set. A setting that names a provider which isn't configured
|
|
275
167
|
* still wins (the operator chose it: `configured` is false and `settings`
|
|
276
|
-
* says what to set); a
|
|
168
|
+
* says what to set); a setting the default can't be is reported as
|
|
277
169
|
* `problem` and the order decides.
|
|
278
170
|
*/
|
|
279
171
|
export function resolveAiDefault(input) {
|
|
280
172
|
const lookup = input.lookup ?? CATALOG;
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
const resolve = (id, capability, source, problem) => ({
|
|
173
|
+
const { isSet, choice } = input;
|
|
174
|
+
const candidates = aiDefaultCandidates(isSet, lookup);
|
|
175
|
+
const resolve = (id, capability, source, extra = {}) => ({
|
|
285
176
|
provider: id,
|
|
286
177
|
label: capability.label,
|
|
287
|
-
|
|
178
|
+
model: extra.model ?? capability.chat.seedModel,
|
|
179
|
+
...(capability.embeddings
|
|
180
|
+
? { embeddingsModel: capability.embeddings.seedModel }
|
|
181
|
+
: {}),
|
|
288
182
|
source,
|
|
289
183
|
configured: aiProviderConfigured(capability, isSet),
|
|
290
184
|
settings: aiRequiredSettings(capability),
|
|
@@ -295,14 +189,16 @@ export function resolveAiDefault(input) {
|
|
|
295
189
|
...candidates.filter((candidate) => candidate.id === id),
|
|
296
190
|
...candidates.filter((candidate) => candidate.id !== id),
|
|
297
191
|
],
|
|
298
|
-
...(problem ? { problem } : {}),
|
|
192
|
+
...(extra.problem ? { problem: extra.problem } : {}),
|
|
299
193
|
});
|
|
300
194
|
let problem;
|
|
301
|
-
if (
|
|
302
|
-
const capability = lookup.get(
|
|
303
|
-
const why = aiDefaultChoiceProblem(
|
|
195
|
+
if (choice) {
|
|
196
|
+
const capability = lookup.get(choice.provider);
|
|
197
|
+
const why = aiDefaultChoiceProblem(choice, lookup);
|
|
304
198
|
if (!why && canBeAiDefault(capability)) {
|
|
305
|
-
return resolve(
|
|
199
|
+
return resolve(choice.provider, capability, "setting", {
|
|
200
|
+
...(choice.model ? { model: choice.model } : {}),
|
|
201
|
+
});
|
|
306
202
|
}
|
|
307
203
|
problem = why ?? undefined;
|
|
308
204
|
}
|
|
@@ -314,7 +210,9 @@ export function resolveAiDefault(input) {
|
|
|
314
210
|
const capability = lookup.get(first.id);
|
|
315
211
|
if (!canBeAiDefault(capability))
|
|
316
212
|
throw new Error("unreachable");
|
|
317
|
-
return resolve(first.id, capability, configured ? "order" : "none",
|
|
213
|
+
return resolve(first.id, capability, configured ? "order" : "none", {
|
|
214
|
+
...(problem ? { problem } : {}),
|
|
215
|
+
});
|
|
318
216
|
}
|
|
319
217
|
/**
|
|
320
218
|
* The sentence setup shows for an unconfigured default: the one key to
|
|
@@ -19,7 +19,7 @@ export interface DevAiProviderSpec {
|
|
|
19
19
|
auth: ApiKeyAuth;
|
|
20
20
|
/** Where an operator gets the key: the provider's API keys page. */
|
|
21
21
|
docs: string;
|
|
22
|
-
/**
|
|
22
|
+
/** Its setup guide, relative to the agent docs (`setup/openai.md`: https://everyapp.com/docs/agent/setup/openai.md). */
|
|
23
23
|
setup?: string;
|
|
24
24
|
/** Gateway settings the provider's URL needs besides the key, under the same names. */
|
|
25
25
|
alsoNeeds?: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiProviders.d.ts","sourceRoot":"","sources":["../../src/internal/aiProviders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"aiProviders.d.ts","sourceRoot":"","sources":["../../src/internal/aiProviders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,+GAA+G;IAC/G,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uFAAuF;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,IAAI,EAAE,UAAU,CAAC;IACjB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,wHAAwH;IACxH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,MAAM,CAAC;IAClE,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,QAAQ,CAAC;CACpE;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC;AAEzC,qDAAqD;AACrD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,oBAAoB,GAC/B,iBAAiB,CAoBnB;AAED,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAUG,CAAC;AAE9C,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM;AACZ,kHAAkH;AAClH,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACzC,iBAAiB,GAAG,SAAS,CAS/B;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,kBAAkB,GAC3B,MAAM,GAAG,IAAI,CAcf;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,kBAAkB,GAC3B,MAAM,GAAG,IAAI,CAIf;AAED,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,GAAG,GAAG,IAAI,CAOZ;AAWD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAqBV"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* this derives the fallback's view of each, and holds the one response
|
|
8
8
|
* rewrite the gateway has (Workers AI's numeric tokens).
|
|
9
9
|
*/
|
|
10
|
-
import { CAPABILITIES, CAPABILITY_IDS, } from "./capabilities.js";
|
|
10
|
+
import { CAPABILITIES, CAPABILITY_IDS, authSettingNames, } from "./capabilities.js";
|
|
11
11
|
import { resolveDevProvider } from "./devProviders.js";
|
|
12
12
|
/** The fallback's view of one `ai` catalog entry. */
|
|
13
13
|
export function devAiProviderSpec(capability) {
|
|
@@ -54,7 +54,7 @@ values) {
|
|
|
54
54
|
}
|
|
55
55
|
/** Every setting a provider needs, its key first: the names `.dev.vars` and the gateway use. */
|
|
56
56
|
export function aiProviderSettings(spec) {
|
|
57
|
-
return [spec.
|
|
57
|
+
return [...authSettingNames(spec.auth), ...(spec.alsoNeeds ?? [])];
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* An `ai` entry's `basePath` with each `{SETTING}` filled from the
|