@every-app/sdk 0.3.0-rc.10 → 0.3.0-rc.12

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.
Files changed (120) hide show
  1. package/README.md +67 -67
  2. package/dist/cloudflare/catalogSettings.generated.d.ts +7 -4
  3. package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
  4. package/dist/cloudflare/catalogSettings.generated.js +7 -6
  5. package/dist/cloudflare/index.d.ts +1 -1
  6. package/dist/cloudflare/index.d.ts.map +1 -1
  7. package/dist/cloudflare/worker.d.ts +36 -2
  8. package/dist/cloudflare/worker.d.ts.map +1 -1
  9. package/dist/cloudflare/worker.js +32 -6
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/internal/aiDefault.d.ts +36 -79
  13. package/dist/internal/aiDefault.d.ts.map +1 -1
  14. package/dist/internal/aiDefault.js +47 -149
  15. package/dist/internal/aiProviders.d.ts.map +1 -1
  16. package/dist/internal/aiProviders.js +2 -2
  17. package/dist/internal/appSettings.d.ts +14 -17
  18. package/dist/internal/appSettings.d.ts.map +1 -1
  19. package/dist/internal/appSettings.js +2 -16
  20. package/dist/internal/capabilities.d.ts +106 -489
  21. package/dist/internal/capabilities.d.ts.map +1 -1
  22. package/dist/internal/capabilities.js +49 -550
  23. package/dist/internal/catalog/commerce.js +1 -1
  24. package/dist/internal/catalog/index.d.ts +35 -0
  25. package/dist/internal/catalog/index.d.ts.map +1 -1
  26. package/dist/internal/catalog/infra.d.ts +35 -0
  27. package/dist/internal/catalog/infra.d.ts.map +1 -1
  28. package/dist/internal/catalog/infra.js +65 -0
  29. package/dist/internal/events.d.ts +52 -1
  30. package/dist/internal/events.d.ts.map +1 -1
  31. package/dist/internal/events.js +65 -3
  32. package/dist/internal/gatewaySettings.d.ts +2 -2
  33. package/dist/internal/gatewaySettings.d.ts.map +1 -1
  34. package/dist/internal/gatewaySettings.js +0 -6
  35. package/dist/internal/oauthBuiltIns.d.ts +101 -0
  36. package/dist/internal/oauthBuiltIns.d.ts.map +1 -0
  37. package/dist/internal/oauthBuiltIns.js +122 -0
  38. package/dist/internal/oauthClient.d.ts +7 -47
  39. package/dist/internal/oauthClient.d.ts.map +1 -1
  40. package/dist/internal/oauthClient.js +1 -115
  41. package/dist/internal/oauthPresets.d.ts +14 -15
  42. package/dist/internal/oauthPresets.d.ts.map +1 -1
  43. package/dist/internal/oauthPresets.js +42 -853
  44. package/dist/internal/oauthScopes.d.ts +43 -155
  45. package/dist/internal/oauthScopes.d.ts.map +1 -1
  46. package/dist/internal/oauthScopes.js +82 -475
  47. package/dist/internal/oauthSpec.d.ts +72 -71
  48. package/dist/internal/oauthSpec.d.ts.map +1 -1
  49. package/dist/internal/oauthSpec.js +178 -447
  50. package/dist/internal/protocol.d.ts +24 -14
  51. package/dist/internal/protocol.d.ts.map +1 -1
  52. package/dist/internal/protocol.js +26 -7
  53. package/dist/internal/providerRegistry.d.ts +1 -61
  54. package/dist/internal/providerRegistry.d.ts.map +1 -1
  55. package/dist/internal/providerRegistry.js +8 -115
  56. package/dist/internal/providerSpec.d.ts.map +1 -1
  57. package/dist/internal/providerSpec.js +14 -36
  58. package/dist/internal/remoteMcp.d.ts +4 -6
  59. package/dist/internal/remoteMcp.d.ts.map +1 -1
  60. package/dist/internal/remoteMcp.js +8 -15
  61. package/dist/internal/tools.d.ts +12 -7
  62. package/dist/internal/tools.d.ts.map +1 -1
  63. package/dist/internal/tools.js +9 -8
  64. package/dist/manifest.d.ts +41 -28
  65. package/dist/manifest.d.ts.map +1 -1
  66. package/dist/manifest.js +1 -1
  67. package/dist/server/ai.d.ts +1 -93
  68. package/dist/server/ai.d.ts.map +1 -1
  69. package/dist/server/ai.js +17 -111
  70. package/dist/server/attribution.d.ts +10 -1
  71. package/dist/server/attribution.d.ts.map +1 -1
  72. package/dist/server/attribution.js +7 -1
  73. package/dist/server/connectUrl.d.ts +4 -9
  74. package/dist/server/connectUrl.d.ts.map +1 -1
  75. package/dist/server/connectUrl.js +17 -14
  76. package/dist/server/context.d.ts +12 -14
  77. package/dist/server/context.d.ts.map +1 -1
  78. package/dist/server/context.js +23 -25
  79. package/dist/server/eventsEndpoint.d.ts +48 -0
  80. package/dist/server/eventsEndpoint.d.ts.map +1 -0
  81. package/dist/server/eventsEndpoint.js +145 -0
  82. package/dist/server/everyApp.d.ts +16 -26
  83. package/dist/server/everyApp.d.ts.map +1 -1
  84. package/dist/server/everyApp.js +22 -46
  85. package/dist/server/gatewayFetch.d.ts +1 -1
  86. package/dist/server/gatewayFetch.js +1 -1
  87. package/dist/server/index.d.ts +6 -9
  88. package/dist/server/index.d.ts.map +1 -1
  89. package/dist/server/index.js +4 -8
  90. package/dist/server/integrationFetch.d.ts +60 -72
  91. package/dist/server/integrationFetch.d.ts.map +1 -1
  92. package/dist/server/integrationFetch.js +117 -392
  93. package/dist/server/refusal.d.ts +0 -9
  94. package/dist/server/refusal.d.ts.map +1 -1
  95. package/dist/server/refusal.js +0 -22
  96. package/dist/server/tools.d.ts +13 -5
  97. package/dist/server/tools.d.ts.map +1 -1
  98. package/dist/server/tools.js +10 -3
  99. package/dist/server/toolsEndpoint.d.ts +2 -1
  100. package/dist/server/toolsEndpoint.d.ts.map +1 -1
  101. package/dist/server/toolsEndpoint.js +4 -3
  102. package/dist/server/webhooks.d.ts +56 -0
  103. package/dist/server/webhooks.d.ts.map +1 -0
  104. package/dist/server/webhooks.js +205 -0
  105. package/dist/testing/index.d.ts +2 -3
  106. package/dist/testing/index.d.ts.map +1 -1
  107. package/dist/testing/index.js +2 -6
  108. package/package.json +1 -1
  109. package/dist/server/aiBinding.d.ts +0 -68
  110. package/dist/server/aiBinding.d.ts.map +0 -1
  111. package/dist/server/aiBinding.js +0 -294
  112. package/dist/server/authorizeUrl.d.ts +0 -43
  113. package/dist/server/authorizeUrl.d.ts.map +0 -1
  114. package/dist/server/authorizeUrl.js +0 -106
  115. package/dist/server/emailBinding.d.ts +0 -72
  116. package/dist/server/emailBinding.d.ts.map +0 -1
  117. package/dist/server/emailBinding.js +0 -124
  118. package/dist/server/fromMcpTools.d.ts +0 -89
  119. package/dist/server/fromMcpTools.d.ts.map +0 -1
  120. 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 `ai()`, the route
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 resolved, never assumed: the operator's choice when one
7
- * is stored (`everyapp ai default <provider>[/<model>]`, Manage workspace
8
- * → Usage → AI default), else the shipped order below, first provider
9
- * whose Gateway settings are all set; with none set, the first of the
10
- * order with the settings it needs, so "Needs setup" asks for one key.
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 models resolve the same way: the operator's model setting for the
19
- * provider (`everyapp ai model <provider> --chat … --embeddings …`,
20
- * `org_settings.ai_models`), else the catalog entry's seed (`chat.seedModel`,
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
- * A choice as typed (`everyapp ai default openrouter/anthropic/claude-sonnet-5.5`,
48
- * the Usage page's dialog, `everyapp_ai_default`): the provider, and the
49
- * chat model to store for it. The provider goes to `org_settings.ai_default`,
50
- * the model to that provider's `chat` in `org_settings.ai_models`.
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: its key
103
- * (unless the entry works without one, `authOptional`) and what its URL
104
- * needs besides (`alsoNeeds`).
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 Gateway fills in when the app names none: the operator's setting, else the seed. */
95
+ /** The catalog's chat model (the seed): what it serves when chosen without a model. */
121
96
  model: string;
122
- /** The embeddings model, the same way; absent when the entry has no embeddings route. */
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 operator's stored choice. */
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 operator's setting for the provider, else the seed. */
114
+ /** The chat model the default serves: the setting's model, else the provider's seed. */
145
115
  model: string;
146
- /** The embeddings model, the same way; absent when the provider has no embeddings route. */
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 choice first. */
126
+ /** Every provider the default could be, in the shipped order, the chosen one first. */
162
127
  candidates: AiDefaultCandidate[];
163
128
  /**
164
- * The stored choice names something the default can't be (an id the
165
- * catalog doesn't have, an entry with no chat route, the proxy): the
166
- * order decided instead, and this says why.
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, models?: AiModelSettings): AiDefaultCandidate[];
176
- /** Why `choice.provider` can't be the default, or null when it can. */
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
- * Why `patch` can't be stored for `provider`, or null when it can: the
180
- * provider must be one the default can be, a model name must be a model
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 choice the default can't be is reported as
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 stored provider (`org_settings.ai_default`), or null for the shipped order. */
193
- provider: string | null;
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC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;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,MAAM,CAc1E"}
@@ -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 `ai()`, the route
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 resolved, never assumed: the operator's choice when one
7
- * is stored (`everyapp ai default <provider>[/<model>]`, Manage workspace
8
- * → Usage → AI default), else the shipped order below, first provider
9
- * whose Gateway settings are all set; with none set, the first of the
10
- * order with the settings it needs, so "Needs setup" asks for one key.
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 models resolve the same way: the operator's model setting for the
19
- * provider (`everyapp ai model <provider> --chat … --embeddings …`,
20
- * `org_settings.ai_models`), else the catalog entry's seed (`chat.seedModel`,
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: its key
166
- * (unless the entry works without one, `authOptional`) and what its URL
167
- * needs besides (`alsoNeeds`).
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 ? [] : [capability.auth.secret]),
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
- /** The provider's models: the operator's setting, else the seed. */
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
- ...modelsOf(id, capability, models),
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, models = {}) {
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.provider` can't be the default, or null when it can. */
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
- return null;
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 stored choice (or none) and
274
- * what is set. A choice that names a provider which isn't configured
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 choice the default can't be is reported as
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 models = input.models ?? {};
282
- const { isSet } = input;
283
- const candidates = aiDefaultCandidates(isSet, lookup, models);
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
- ...modelsOf(id, capability, models),
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 (input.provider) {
302
- const capability = lookup.get(input.provider);
303
- const why = aiDefaultChoiceProblem({ provider: input.provider }, lookup);
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(input.provider, capability, "setting");
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", problem);
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
@@ -1 +1 @@
1
- {"version":3,"file":"aiProviders.d.ts","sourceRoot":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OZ;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.keyEnv, ...(spec.alsoNeeds ?? [])];
57
+ return [...authSettingNames(spec.auth), ...(spec.alsoNeeds ?? [])];
58
58
  }
59
59
  /**
60
60
  * An `ai` entry's `basePath` with each `{SETTING}` filled from the
@@ -70,9 +70,9 @@ export interface SettingNeedFields {
70
70
  /** The app works without it; the feature using it says so where it is used. */
71
71
  optional?: boolean;
72
72
  /**
73
- * For an app's own secret: its setup guide, relative to the everyapp
74
- * skill (`setup/main-secret.md`). Providers and capabilities take theirs
75
- * from the registries and can't override it.
73
+ * For an app's own secret: its setup guide, a path in the app
74
+ * (`docs/setup/main-secret.md`). Providers and capabilities take theirs
75
+ * from the registries (guides in the everyapp skill) and can't override it.
76
76
  */
77
77
  setup?: string;
78
78
  /**
@@ -92,7 +92,6 @@ export interface SettingsManifestLike {
92
92
  readonly secrets?: ReadonlyArray<string | SecretEntry>;
93
93
  readonly settings?: ReadonlyArray<SettingEntry>;
94
94
  readonly ai?: {
95
- readonly routes?: readonly string[];
96
95
  /** The app needs the Gateway's default chat model (`/api/ai/default`): `true`, or an entry with its need. */
97
96
  readonly chat?: boolean | SettingNeedFields;
98
97
  };
@@ -102,7 +101,7 @@ export interface SettingsManifestLike {
102
101
  }
103
102
  export type SettingKind = "provider" | "capability" | "secret"
104
103
  /** An app's plain setting (`settings`): a value on its Worker, not a key. */
105
- | "setting" | "ai-routes"
104
+ | "setting"
106
105
  /** The Gateway's default model provider (`ai.chat`): one key of any provider in the order, or the operator's choice. */
107
106
  | "ai-default"
108
107
  /** A remote MCP app's credential (./remoteMcp.ts): one Gateway setting named by the row. */
@@ -119,17 +118,15 @@ export type SettingNeed = {
119
118
  };
120
119
  /** What `appSettings` may be told about the Gateway, for the default model provider. */
121
120
  export interface AppSettingsOptions {
122
- /** The operator's stored default provider (`everyapp ai default`), or none. */
123
- aiDefault?: string | null;
124
121
  /** What is set, to put the configured provider first; absent, the order decides. */
125
122
  isSet?: IsSet;
126
123
  }
127
124
  /** One thing the app needs set, as the manifest declares it. */
128
125
  export interface AppSetting {
129
126
  kind: SettingKind;
130
- /** The provider id, capability id or secret name; "ai-routes" for the AI proxy's extra routes. */
127
+ /** The provider id, capability id or secret name. */
131
128
  id: string;
132
- /** "OpenRouter", "DataForSEO", "MAIN_SECRET", "AI proxy routes". */
129
+ /** "OpenRouter", "DataForSEO", "MAIN_SECRET". */
133
130
  label: string;
134
131
  holder: SettingHolder;
135
132
  /** Every one of these must be set for the setting to count as set (or any one group of `alternatives`). */
@@ -146,11 +143,12 @@ export interface AppSetting {
146
143
  why?: string;
147
144
  docs?: string;
148
145
  /**
149
- * The everyapp skill's setup guide for it, relative to the skill
150
- * (`setup/dataforseo.md`; in an app `.claude/skills/everyapp/setup/…`, in
151
- * the checkout `packages/cli/skills/everyapp/setup/…`): what an agent
152
- * reads to set it up end to end. From the registries for providers and
153
- * capabilities; from the manifest entry for an app's own secret.
146
+ * What an agent reads to set it up end to end. For providers and
147
+ * capabilities, the registry's guide in the everyapp skill, relative to the
148
+ * skill (`setup/dataforseo.md`; in an app
149
+ * `node_modules/everyapp/skills/everyapp/setup/…`, in the checkout
150
+ * `packages/cli/skills/everyapp/setup/…`). For an app's own secret, the
151
+ * manifest entry's guide, a path in the app (`docs/setup/main-secret.md`).
154
152
  */
155
153
  setup?: string;
156
154
  /**
@@ -188,7 +186,7 @@ export interface AnyOfGroup {
188
186
  export interface AppSettingsReport {
189
187
  /** No required setting is unset and every any-of group is met. */
190
188
  ready: boolean;
191
- /** Every setting, in manifest order: providers, capabilities, the AI routes, secrets. */
189
+ /** Every setting, in manifest order: providers, capabilities, secrets. */
192
190
  settings: EvaluatedSetting[];
193
191
  groups: AnyOfGroup[];
194
192
  /** The settings that keep the app closed, in manifest order. */
@@ -228,8 +226,7 @@ export declare function settingValueTakes(rule: SettingValueRule): string;
228
226
  export declare function settingValueProblem(rule: Pick<SettingValueRule, "type" | "values">, value: string): string | null;
229
227
  /**
230
228
  * Every setting the manifest declares, in manifest order: its AI
231
- * providers, its capabilities, the AI proxy's extra routes when `ai.routes`
232
- * asks for any, then the app's own secrets. A provider or capability the
229
+ * providers, its capabilities, then the app's own secrets. A provider or capability the
233
230
  * gateway doesn't offer contributes nothing (the manifest validator refuses
234
231
  * it elsewhere); so does a capability with nothing to set (`members`),
235
232
  * which is always set. `lookup` is where ids are found: the catalog alone