@every-app/sdk 0.3.0-rc.8 → 0.3.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 +75 -74
- package/dist/cloudflare/catalogSettings.generated.d.ts +20 -6
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +45 -14
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/sentinel.d.ts +3 -0
- package/dist/cloudflare/sentinel.d.ts.map +1 -1
- package/dist/cloudflare/sentinel.js +10 -0
- package/dist/cloudflare/worker.d.ts +67 -23
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +68 -32
- 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 +145 -503
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +29 -550
- package/dist/internal/catalog/commerce.js +1 -1
- package/dist/internal/catalog/comms.d.ts +37 -0
- package/dist/internal/catalog/comms.d.ts.map +1 -1
- package/dist/internal/catalog/comms.js +43 -0
- package/dist/internal/catalog/index.d.ts +72 -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 -2
- package/dist/internal/gatewaySettings.d.ts +6 -16
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +6 -24
- 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 +7 -47
- package/dist/internal/oauthClient.d.ts.map +1 -1
- package/dist/internal/oauthClient.js +1 -115
- 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 +39 -15
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +40 -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 -28
- 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 +10 -1
- package/dist/server/attribution.d.ts.map +1 -1
- package/dist/server/attribution.js +7 -1
- package/dist/server/connectUrl.d.ts +4 -9
- package/dist/server/connectUrl.d.ts.map +1 -1
- package/dist/server/connectUrl.js +17 -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/emit.d.ts.map +1 -1
- package/dist/server/emit.js +2 -2
- package/dist/server/env.d.ts +3 -0
- package/dist/server/env.d.ts.map +1 -1
- 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 +19 -1
- package/dist/server/gatewayFetch.d.ts.map +1 -1
- package/dist/server/gatewayFetch.js +45 -3
- 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 +60 -72
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +124 -397
- package/dist/server/listMembers.d.ts.map +1 -1
- package/dist/server/listMembers.js +2 -2
- 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/sendEmail.d.ts.map +1 -1
- package/dist/server/sendEmail.js +2 -2
- package/dist/server/tools.d.ts +17 -6
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +14 -4
- 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,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":"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"}
|
|
@@ -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
|