@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
|
@@ -9,9 +9,19 @@ import { DEV_ISSUER, DEV_ORG_ID, DEV_PUBLIC_KEY_PEM } from "../dev/keypair.js";
|
|
|
9
9
|
import { DEV_GATEWAY_KEYS } from "./catalogSettings.generated.js";
|
|
10
10
|
import { helperWorkerName, sentinelDeployTarget, workflowNameFor, } from "./sentinel.js";
|
|
11
11
|
export { helperWorkerName, workflowNameFor } from "./sentinel.js";
|
|
12
|
-
/** The names of the manifest's `secrets
|
|
12
|
+
/** The names of the manifest's `secrets` and its features', whichever form each took. */
|
|
13
13
|
function manifestSecretNames(manifest) {
|
|
14
|
-
return
|
|
14
|
+
return [
|
|
15
|
+
...(manifest.secrets ?? []),
|
|
16
|
+
...Object.values(manifest.features ?? {}).flatMap((feature) => feature.secrets ?? []),
|
|
17
|
+
].map((entry) => (typeof entry === "string" ? entry : entry.name));
|
|
18
|
+
}
|
|
19
|
+
/** The manifest's plain settings and its features'. */
|
|
20
|
+
function manifestSettings(manifest) {
|
|
21
|
+
return [
|
|
22
|
+
...(manifest.settings ?? []),
|
|
23
|
+
...Object.values(manifest.features ?? {}).flatMap((feature) => feature.settings ?? []),
|
|
24
|
+
];
|
|
15
25
|
}
|
|
16
26
|
/** The ids of the manifest's `providers`, whichever form each took. */
|
|
17
27
|
function manifestProviderIds(manifest) {
|
|
@@ -61,8 +71,8 @@ function devGatewayUrl() {
|
|
|
61
71
|
}
|
|
62
72
|
/**
|
|
63
73
|
* The manifest's `capabilities` as the SDK's local-dev twin of the gateway
|
|
64
|
-
* reads them: with no gateway
|
|
65
|
-
*
|
|
74
|
+
* reads them: with no gateway, `integrationStatus()` reports an OAuth
|
|
75
|
+
* provider's declared scopes, and whether the app lists it, from these.
|
|
66
76
|
*/
|
|
67
77
|
function devCapabilities(manifest) {
|
|
68
78
|
return { type: "text", value: JSON.stringify(manifest.capabilities ?? {}) };
|
|
@@ -132,8 +142,9 @@ function addDevProviders(env, root) {
|
|
|
132
142
|
/**
|
|
133
143
|
* The Gateway settings the spec files name for the capabilities the
|
|
134
144
|
* manifest lists outside {@link DEV_GATEWAY_KEYS} (a registered provider's
|
|
135
|
-
* key, a Basic username held as a setting, its host setting
|
|
136
|
-
* loosely: the SDK parses the spec when the
|
|
145
|
+
* key, a Basic username held as a setting, its host setting, an OAuth
|
|
146
|
+
* provider's dev token), read loosely: the SDK parses the spec when the
|
|
147
|
+
* app calls the provider.
|
|
137
148
|
*/
|
|
138
149
|
function devProviderKeys(manifest, root) {
|
|
139
150
|
const listed = Object.keys(manifest.capabilities ?? {}).filter((id) => !Object.hasOwn(DEV_GATEWAY_KEYS.capabilities, id));
|
|
@@ -158,6 +169,11 @@ function devProviderKeys(manifest, root) {
|
|
|
158
169
|
auth?.["secret"],
|
|
159
170
|
record(auth?.["user"])?.["secret"],
|
|
160
171
|
fields["hostSetting"],
|
|
172
|
+
// An OAuth provider: the token that stands in for a connection in
|
|
173
|
+
// dev (devAccessTokenName() in ../server/integrationFetch.ts).
|
|
174
|
+
auth?.["kind"] === "oauth2-user"
|
|
175
|
+
? `${id.toUpperCase().replace(/-/g, "_")}_ACCESS_TOKEN`
|
|
176
|
+
: undefined,
|
|
161
177
|
]) {
|
|
162
178
|
if (typeof name === "string" && /^[A-Z][A-Z0-9_]*$/.test(name)) {
|
|
163
179
|
names.push(name);
|
|
@@ -236,8 +252,7 @@ export function everyAppWorker(options) {
|
|
|
236
252
|
env["EVERYAPP_IDENTITY_ISSUER"] = { type: "text", value: DEV_ISSUER };
|
|
237
253
|
env["GATEWAY_URL"] = devGatewayUrl();
|
|
238
254
|
// The stub gateway's organization, as the deploy's secret would be, so
|
|
239
|
-
//
|
|
240
|
-
// here too. Not a pin: under the dev opt-in everyApp() enforces none,
|
|
255
|
+
// code that reads env.EVERY_APP_ORG_ID runs here too. Not a pin: under the dev opt-in everyApp() enforces none,
|
|
241
256
|
// so `everyapp dev --mode mirror`'s real organizations still open.
|
|
242
257
|
env["EVERY_APP_ORG_ID"] = { type: "text", value: DEV_ORG_ID };
|
|
243
258
|
addDevProviders(env, options.root);
|
|
@@ -252,6 +267,7 @@ export function everyAppWorker(options) {
|
|
|
252
267
|
addSendEmailBindings(env, manifest);
|
|
253
268
|
addSecretsStoreBindings(env, manifest, name, deploy);
|
|
254
269
|
addAnalyticsEngineBindings(env, manifest, name);
|
|
270
|
+
addArtifactsBindings(env, manifest, name, deploy);
|
|
255
271
|
addDatabaseBindings(env, options, name, undefined, deploy);
|
|
256
272
|
// The app binds every class, a helper Worker's in that Worker, and
|
|
257
273
|
// exports only its own.
|
|
@@ -366,6 +382,7 @@ export function everyAppAuxiliaryWorker(options) {
|
|
|
366
382
|
addAiGatewayBindings(env, manifest, appWorker, deploy);
|
|
367
383
|
addSecretsStoreBindings(env, manifest, appWorker, deploy);
|
|
368
384
|
addAnalyticsEngineBindings(env, manifest, appWorker);
|
|
385
|
+
addArtifactsBindings(env, manifest, appWorker, deploy);
|
|
369
386
|
addDatabaseBindings(env, options, appWorker, worker, deploy);
|
|
370
387
|
const { bindings, exports } = classBindings(manifest, appWorker, worker, env);
|
|
371
388
|
Object.assign(env, bindings);
|
|
@@ -705,6 +722,25 @@ function addAnalyticsEngineBindings(env, manifest, appWorker) {
|
|
|
705
722
|
};
|
|
706
723
|
}
|
|
707
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* The manifest's Artifacts namespaces, which every one of the app's Workers
|
|
727
|
+
* binds: `<app worker>--<binding>`. Deployed, the app's Worker name is the
|
|
728
|
+
* build's placeholder, which the install rewrites like every other; in
|
|
729
|
+
* development the account's namespace of the dev Worker's name, reached
|
|
730
|
+
* remotely: Cloudflare has no local Artifacts, so calls throw until the
|
|
731
|
+
* Vite plugin's remoteBindings is on.
|
|
732
|
+
*/
|
|
733
|
+
function addArtifactsBindings(env, manifest, appWorker, deploy) {
|
|
734
|
+
for (const { name: binding } of manifest.resources?.artifacts ?? []) {
|
|
735
|
+
if (env[binding]) {
|
|
736
|
+
throw new Error(`artifacts: ${binding} reuses a binding name the Worker already has.`);
|
|
737
|
+
}
|
|
738
|
+
const namespace = suffixedName(appWorker, binding);
|
|
739
|
+
env[binding] = deploy
|
|
740
|
+
? { type: "artifacts", namespace }
|
|
741
|
+
: { type: "artifacts", namespace, dev: { remote: true } };
|
|
742
|
+
}
|
|
743
|
+
}
|
|
708
744
|
/**
|
|
709
745
|
* DATABASE_PROVIDER and the Hyperdrive configs one of the app's Workers
|
|
710
746
|
* binds: each config every Worker shares, and those a helper (`forWorker`)
|
|
@@ -820,7 +856,7 @@ taken) {
|
|
|
820
856
|
* capabilities.
|
|
821
857
|
*/
|
|
822
858
|
function addSecrets(env, options, deploy) {
|
|
823
|
-
const settings = options.manifest
|
|
859
|
+
const settings = manifestSettings(options.manifest);
|
|
824
860
|
const secrets = [
|
|
825
861
|
...manifestSecretNames(options.manifest),
|
|
826
862
|
...settings.map((setting) => setting.name),
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* @every-app/sdk — what `everyapp.config.ts` imports: `defineEveryApp` and
|
|
3
3
|
* the manifest's types. A leaf, like the config itself (see ./manifest.ts).
|
|
4
4
|
*/
|
|
5
|
-
export { defineEveryApp, type EveryAppCapabilityEntry, type EveryAppClassResource, type EveryAppManifest, type EveryAppPublicRoute, type EveryAppQueueConsumer, type EveryAppResources, type EveryAppSecretEntry, type EveryAppSettingEntry, type EveryAppSettingNeed, type EveryAppWorkerLimits, } from "./manifest.js";
|
|
5
|
+
export { defineEveryApp, type EveryAppCapabilityEntry, type EveryAppKeyCapabilityEntry, type EveryAppOAuthCapabilityEntry, type EveryAppClassResource, type EveryAppFeature, type EveryAppFeatureSecretEntry, type EveryAppFeatureSettingEntry, type EveryAppManifest, type EveryAppPublicRoute, type EveryAppQueueConsumer, type EveryAppResources, type EveryAppSecretEntry, type EveryAppSettingEntry, type EveryAppSettingNeed, type EveryAppWorkerLimits, } from "./manifest.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,cAAc,EACd,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,cAAc,EACd,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC"}
|
|
@@ -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,10 +17,9 @@
|
|
|
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`.
|
|
@@ -44,39 +45,18 @@ export declare const AI_DEFAULT_ROUTES: {
|
|
|
44
45
|
};
|
|
45
46
|
export type AiDefaultRoute = keyof typeof AI_DEFAULT_ROUTES;
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
-
* the Usage page's dialog,
|
|
49
|
-
*
|
|
50
|
-
* the model to
|
|
48
|
+
* The workspace's one setting, as typed (`everyapp ai default
|
|
49
|
+
* openrouter/anthropic/claude-sonnet-5.5`, the Usage page's dialog,
|
|
50
|
+
* `everyapp_ai_default`) and stored (`org_settings.ai_default`): the
|
|
51
|
+
* provider, and the chat model to fill in when an app names none (the
|
|
52
|
+
* provider's seed when left out).
|
|
51
53
|
*/
|
|
52
54
|
export interface AiDefaultChoice {
|
|
53
55
|
provider: string;
|
|
54
56
|
model?: string;
|
|
55
57
|
}
|
|
56
|
-
/** The operator's models for one provider; a field left out serves the seed. */
|
|
57
|
-
export interface AiModelSetting {
|
|
58
|
-
chat?: string;
|
|
59
|
-
embeddings?: string;
|
|
60
|
-
}
|
|
61
|
-
/** The operator's models by provider id (`org_settings.ai_models`, JSON). */
|
|
62
|
-
export type AiModelSettings = Readonly<Record<string, AiModelSetting>>;
|
|
63
|
-
/** A change to one provider's models: a name sets it, null puts the seed back, absent leaves it. */
|
|
64
|
-
export interface AiModelPatch {
|
|
65
|
-
chat?: string | null;
|
|
66
|
-
embeddings?: string | null;
|
|
67
|
-
}
|
|
68
58
|
/** Whether `value` can be a model id: 1 to 200 characters, no surrounding or control whitespace. */
|
|
69
59
|
export declare function isAiModelName(value: string): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* `org_settings.ai_models` as stored: a JSON object of provider id →
|
|
72
|
-
* `{ chat?, embeddings? }`. Anything else (null, malformed JSON, a field
|
|
73
|
-
* that isn't a model name) reads as no setting, so the seed serves.
|
|
74
|
-
*/
|
|
75
|
-
export declare function parseAiModelSettings(value: string | null | undefined): AiModelSettings;
|
|
76
|
-
/** The stored text of the settings, providers sorted; null when nothing is set. */
|
|
77
|
-
export declare function formatAiModelSettings(settings: AiModelSettings): string | null;
|
|
78
|
-
/** `settings` with one provider's models changed by `patch`. */
|
|
79
|
-
export declare function withAiModelSetting(settings: AiModelSettings, provider: string, patch: AiModelPatch): AiModelSettings;
|
|
80
60
|
/**
|
|
81
61
|
* `openrouter` or `openrouter/anthropic/claude-haiku-5.5` as typed:
|
|
82
62
|
* the provider id up to the first slash, the model after it (a model id
|
|
@@ -85,12 +65,6 @@ export declare function withAiModelSetting(settings: AiModelSettings, provider:
|
|
|
85
65
|
export declare function parseAiDefaultChoice(value: string | null | undefined): AiDefaultChoice | null;
|
|
86
66
|
/** The text of a choice: `provider` or `provider/model`. */
|
|
87
67
|
export declare function formatAiDefaultChoice(choice: AiDefaultChoice): string;
|
|
88
|
-
/**
|
|
89
|
-
* The provider id `org_settings.ai_default` holds, or null. The column
|
|
90
|
-
* holds the provider alone (its models are in `ai_models`); text after a
|
|
91
|
-
* first slash is not read.
|
|
92
|
-
*/
|
|
93
|
-
export declare function parseAiDefaultProvider(value: string | null | undefined): string | null;
|
|
94
68
|
/** Whether `name` holds a value, as the Gateway's env or a secret list says. */
|
|
95
69
|
export type IsSet = (name: string) => boolean;
|
|
96
70
|
/** An `ai` entry the default may resolve to: not the proxy, with a chat route. */
|
|
@@ -99,9 +73,10 @@ export type AiDefaultCapability = AiProviderCapability & {
|
|
|
99
73
|
};
|
|
100
74
|
export declare function canBeAiDefault(capability: Capability | undefined): capability is AiDefaultCapability;
|
|
101
75
|
/**
|
|
102
|
-
* The Gateway settings an `ai` entry needs before it serves:
|
|
103
|
-
*
|
|
104
|
-
*
|
|
76
|
+
* The Gateway settings an `ai` entry needs before it serves: every setting
|
|
77
|
+
* its `auth` names, the key and a Basic username held as a setting (unless
|
|
78
|
+
* the entry works without them, `authOptional`), and what its URL needs
|
|
79
|
+
* besides (`alsoNeeds`).
|
|
105
80
|
*/
|
|
106
81
|
export declare function aiRequiredSettings(capability: AiProviderCapability): string[];
|
|
107
82
|
/** Whether every setting the entry needs is set. */
|
|
@@ -117,22 +92,17 @@ export interface AiDefaultCandidate {
|
|
|
117
92
|
/** The Gateway settings it needs; what to set when it isn't configured. */
|
|
118
93
|
settings: string[];
|
|
119
94
|
configured: boolean;
|
|
120
|
-
/** The chat model the
|
|
95
|
+
/** The catalog's chat model (the seed): what it serves when chosen without a model. */
|
|
121
96
|
model: string;
|
|
122
|
-
/** The embeddings model
|
|
97
|
+
/** The catalog's embeddings model; absent when the entry has no embeddings route. */
|
|
123
98
|
embeddingsModel?: string;
|
|
124
|
-
/** The catalog's seeds: what serves where the operator set no model. */
|
|
125
|
-
seed: {
|
|
126
|
-
chat: string;
|
|
127
|
-
embeddings?: string;
|
|
128
|
-
};
|
|
129
99
|
/** Through Cloudflare AI Gateway, as things are set now. */
|
|
130
100
|
viaAiGateway: boolean;
|
|
131
101
|
embeddings: boolean;
|
|
132
102
|
}
|
|
133
103
|
/** Where the resolved default came from. */
|
|
134
104
|
export type AiDefaultSource =
|
|
135
|
-
/** The
|
|
105
|
+
/** The workspace's setting. */
|
|
136
106
|
"setting"
|
|
137
107
|
/** The shipped order: the first provider that is configured. */
|
|
138
108
|
| "order"
|
|
@@ -141,15 +111,10 @@ export type AiDefaultSource =
|
|
|
141
111
|
export interface AiDefaultResolution {
|
|
142
112
|
provider: string;
|
|
143
113
|
label: string;
|
|
144
|
-
/** The chat model the default serves: the
|
|
114
|
+
/** The chat model the default serves: the setting's model, else the provider's seed. */
|
|
145
115
|
model: string;
|
|
146
|
-
/** The embeddings model
|
|
116
|
+
/** The embeddings model (the provider's seed); absent when the provider has no embeddings route. */
|
|
147
117
|
embeddingsModel?: string;
|
|
148
|
-
/** The provider's seeds. */
|
|
149
|
-
seed: {
|
|
150
|
-
chat: string;
|
|
151
|
-
embeddings?: string;
|
|
152
|
-
};
|
|
153
118
|
source: AiDefaultSource;
|
|
154
119
|
/** Every setting the provider needs is set, so the default serves. */
|
|
155
120
|
configured: boolean;
|
|
@@ -158,12 +123,12 @@ export interface AiDefaultResolution {
|
|
|
158
123
|
via: "ai-gateway" | "direct";
|
|
159
124
|
chat: AiRoute;
|
|
160
125
|
embeddings?: AiRoute;
|
|
161
|
-
/** Every provider the default could be, in the shipped order, the
|
|
126
|
+
/** Every provider the default could be, in the shipped order, the chosen one first. */
|
|
162
127
|
candidates: AiDefaultCandidate[];
|
|
163
128
|
/**
|
|
164
|
-
* The
|
|
165
|
-
*
|
|
166
|
-
*
|
|
129
|
+
* The setting names something the default can't be (an id the catalog
|
|
130
|
+
* doesn't have, an entry with no chat route, the proxy): the order
|
|
131
|
+
* decided instead, and this says why.
|
|
167
132
|
*/
|
|
168
133
|
problem?: string;
|
|
169
134
|
}
|
|
@@ -172,27 +137,19 @@ export interface AiDefaultResolution {
|
|
|
172
137
|
* then any other `ai` entry of `lookup` with a chat route (a registered
|
|
173
138
|
* row, one day), each with its state.
|
|
174
139
|
*/
|
|
175
|
-
export declare function aiDefaultCandidates(isSet: IsSet, lookup?: CapabilityLookup
|
|
176
|
-
/** Why `choice
|
|
140
|
+
export declare function aiDefaultCandidates(isSet: IsSet, lookup?: CapabilityLookup): AiDefaultCandidate[];
|
|
141
|
+
/** Why `choice` can't be the default, or null when it can. */
|
|
177
142
|
export declare function aiDefaultChoiceProblem(choice: AiDefaultChoice, lookup?: CapabilityLookup): string | null;
|
|
178
143
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* name, and an embeddings model needs the entry's embeddings route.
|
|
182
|
-
*/
|
|
183
|
-
export declare function aiModelPatchProblem(provider: string, patch: AiModelPatch, lookup?: CapabilityLookup): string | null;
|
|
184
|
-
/**
|
|
185
|
-
* The Gateway's effective default, from the stored choice (or none) and
|
|
186
|
-
* what is set. A choice that names a provider which isn't configured
|
|
144
|
+
* The Gateway's effective default, from the workspace's setting (or none)
|
|
145
|
+
* and what is set. A setting that names a provider which isn't configured
|
|
187
146
|
* still wins (the operator chose it: `configured` is false and `settings`
|
|
188
|
-
* says what to set); a
|
|
147
|
+
* says what to set); a setting the default can't be is reported as
|
|
189
148
|
* `problem` and the order decides.
|
|
190
149
|
*/
|
|
191
150
|
export declare function resolveAiDefault(input: {
|
|
192
|
-
/** The
|
|
193
|
-
|
|
194
|
-
/** The operator's models by provider (`org_settings.ai_models`); none: the seeds serve. */
|
|
195
|
-
models?: AiModelSettings;
|
|
151
|
+
/** The workspace's setting (`org_settings.ai_default`), or null for the shipped order. */
|
|
152
|
+
choice: AiDefaultChoice | null;
|
|
196
153
|
isSet: IsSet;
|
|
197
154
|
lookup?: CapabilityLookup;
|
|
198
155
|
}): AiDefaultResolution;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiDefault.d.ts","sourceRoot":"","sources":["../../src/internal/aiDefault.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"aiDefault.d.ts","sourceRoot":"","sources":["../../src/internal/aiDefault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,qDAGtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAQ7C,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,qEAAqE;AACrE,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oGAAoG;AACpG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOpD;AAKD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/B,eAAe,GAAG,IAAI,CAMxB;AAED,4DAA4D;AAC5D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAErE;AAED,gFAAgF;AACh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