@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
package/dist/internal/tools.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* gateway's service binding and never public:
|
|
5
5
|
*
|
|
6
6
|
* POST /__everyapp/tools/list x-everyapp-system JWT (purpose "tools.list")
|
|
7
|
-
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp"
|
|
7
|
+
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp"
|
|
8
|
+
* + tc claim
|
|
8
9
|
*
|
|
9
10
|
* MCP itself (protocol eras, headers, envelopes) stays in the gateway; apps
|
|
10
11
|
* only ever speak this small versioned JSON shape. Both sides import the
|
|
@@ -14,19 +15,23 @@ export declare const TOOLS_PROTOCOL_VERSION = 1;
|
|
|
14
15
|
export declare const TOOLS_PATH_PREFIX = "/__everyapp/tools";
|
|
15
16
|
export declare const TOOLS_LIST_PATH = "/__everyapp/tools/list";
|
|
16
17
|
export declare const TOOLS_CALL_PATH = "/__everyapp/tools/call";
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A tool reads or writes. A write tool that deletes or can't be undone also
|
|
20
|
+
* says `destructiveHint` in its annotations, so clients ask before calling.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TOOL_RISKS: readonly ["read", "write"];
|
|
18
23
|
export type ToolRisk = (typeof TOOL_RISKS)[number];
|
|
19
|
-
/** Scopes the gateway mints on `chan: "mcp"`
|
|
24
|
+
/** Scopes the gateway mints on tool-call identities (`chan: "mcp"`), one per risk. */
|
|
20
25
|
export declare const MCP_READ_SCOPE = "mcp:read";
|
|
21
26
|
export declare const MCP_WRITE_SCOPE = "mcp:write";
|
|
22
|
-
/** Never minted in v1: destructive tools are hidden until approvals exist. */
|
|
23
|
-
export declare const MCP_DESTRUCTIVE_SCOPE = "mcp:destructive";
|
|
24
27
|
/** Local tool names: lowercase snake_case, at most 48 characters. */
|
|
25
28
|
export declare const TOOL_NAME_PATTERN: RegExp;
|
|
26
29
|
export declare function isToolRisk(value: unknown): value is ToolRisk;
|
|
27
|
-
/** The exact scope a
|
|
30
|
+
/** The exact scope a tool-call identity must carry to call a tool. */
|
|
28
31
|
export declare function requiredScopeForRisk(risk: ToolRisk): string;
|
|
29
32
|
export interface ToolAnnotationsV1 {
|
|
33
|
+
/** A write tool deletes or can't be undone: clients ask before calling. */
|
|
34
|
+
destructiveHint?: boolean;
|
|
30
35
|
idempotentHint?: boolean;
|
|
31
36
|
openWorldHint?: boolean;
|
|
32
37
|
}
|
|
@@ -55,7 +60,7 @@ export interface ToolsListResponseV1 {
|
|
|
55
60
|
/** Tools the SDK left out because it can't describe them, and why. */
|
|
56
61
|
warnings?: string[];
|
|
57
62
|
}
|
|
58
|
-
/** The `tc` identity claim: binds a `chan: "mcp"`
|
|
63
|
+
/** The `tc` identity claim: binds a tool-call token (`chan: "mcp"`) to one call. */
|
|
59
64
|
export interface ToolCallClaim {
|
|
60
65
|
id: string;
|
|
61
66
|
name: string;
|
|
@@ -76,7 +81,9 @@ export interface ToolCallResultV1 {
|
|
|
76
81
|
structuredContent?: Record<string, unknown>;
|
|
77
82
|
isError?: boolean;
|
|
78
83
|
}
|
|
79
|
-
export type ToolsErrorCodeV1 = "unknown_tool" | "invalid_arguments" | "invalid_request" | "forbidden" | "unauthenticated" | "method_not_allowed" | "misconfigured"
|
|
84
|
+
export type ToolsErrorCodeV1 = "unknown_tool" | "invalid_arguments" | "invalid_request" | "forbidden" | "unauthenticated" | "method_not_allowed" | "misconfigured"
|
|
85
|
+
/** A proxied server failed (unreachable, timed out, refused): not a setup problem. */
|
|
86
|
+
| "upstream_failed";
|
|
80
87
|
export interface ToolIssueV1 {
|
|
81
88
|
message: string;
|
|
82
89
|
path?: (string | number)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/internal/tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/internal/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,eAAe,2BAA8B,CAAC;AAC3D,eAAO,MAAM,eAAe,2BAA8B,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,UAAU,4BAA6B,CAAC;AACrD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,sFAAsF;AACtF,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAE1D,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAK5D;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAO3D;AAED,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC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everyapp/tools/list x-everyapp-system JWT (purpose "tools.list")
|
|
7
|
-
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp"
|
|
7
|
+
* POST /__everyapp/tools/call x-everyapp-identity JWT, chan "mcp"
|
|
8
|
+
* + tc claim
|
|
8
9
|
*
|
|
9
10
|
* MCP itself (protocol eras, headers, envelopes) stays in the gateway; apps
|
|
10
11
|
* only ever speak this small versioned JSON shape. Both sides import the
|
|
@@ -14,27 +15,27 @@ export const TOOLS_PROTOCOL_VERSION = 1;
|
|
|
14
15
|
export const TOOLS_PATH_PREFIX = "/__everyapp/tools";
|
|
15
16
|
export const TOOLS_LIST_PATH = `${TOOLS_PATH_PREFIX}/list`;
|
|
16
17
|
export const TOOLS_CALL_PATH = `${TOOLS_PATH_PREFIX}/call`;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A tool reads or writes. A write tool that deletes or can't be undone also
|
|
20
|
+
* says `destructiveHint` in its annotations, so clients ask before calling.
|
|
21
|
+
*/
|
|
22
|
+
export const TOOL_RISKS = ["read", "write"];
|
|
23
|
+
/** Scopes the gateway mints on tool-call identities (`chan: "mcp"`), one per risk. */
|
|
19
24
|
export const MCP_READ_SCOPE = "mcp:read";
|
|
20
25
|
export const MCP_WRITE_SCOPE = "mcp:write";
|
|
21
|
-
/** Never minted in v1: destructive tools are hidden until approvals exist. */
|
|
22
|
-
export const MCP_DESTRUCTIVE_SCOPE = "mcp:destructive";
|
|
23
26
|
/** Local tool names: lowercase snake_case, at most 48 characters. */
|
|
24
27
|
export const TOOL_NAME_PATTERN = /^[a-z][a-z0-9_]{0,47}$/;
|
|
25
28
|
export function isToolRisk(value) {
|
|
26
29
|
return (typeof value === "string" &&
|
|
27
30
|
TOOL_RISKS.includes(value));
|
|
28
31
|
}
|
|
29
|
-
/** The exact scope a
|
|
32
|
+
/** The exact scope a tool-call identity must carry to call a tool. */
|
|
30
33
|
export function requiredScopeForRisk(risk) {
|
|
31
34
|
switch (risk) {
|
|
32
35
|
case "read":
|
|
33
36
|
return MCP_READ_SCOPE;
|
|
34
37
|
case "write":
|
|
35
38
|
return MCP_WRITE_SCOPE;
|
|
36
|
-
case "destructive":
|
|
37
|
-
return MCP_DESTRUCTIVE_SCOPE;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
/**
|
package/dist/manifest.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Types only, and a leaf module: `cloudflare.config.ts` imports the manifest,
|
|
13
13
|
* and the Cloudflare Vite plugin hides from the Worker every file the config
|
|
14
14
|
* imports. The rules beyond the shape (which ids exist, which names are
|
|
15
|
-
* reserved, which
|
|
15
|
+
* reserved, which scopes a provider takes) are the CLI's: `everyapp deploy`
|
|
16
16
|
* and `everyapp dev` validate the manifest and say what is wrong. The
|
|
17
17
|
* perimeter's schema (`@every-app/perimeter/manifest`) is held to this type
|
|
18
18
|
* by a test there.
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
* The Worker reads the manifest back as `env.EVERYAPP_MANIFEST`, which
|
|
21
21
|
* `everyAppWorker()` sets and `cf workers types` types from the file.
|
|
22
22
|
*/
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Why a setting is needed (the settings model). Everything listed at the
|
|
25
|
+
* top level is required; what the app works without goes in an optional
|
|
26
|
+
* feature (`features`).
|
|
27
|
+
*/
|
|
24
28
|
export interface EveryAppSettingNeed {
|
|
25
29
|
/** Why the app needs it, for whoever sets it. At most 200 characters. */
|
|
26
30
|
readonly why?: string;
|
|
27
31
|
/** An https page that says where the key or client comes from. */
|
|
28
32
|
readonly docs?: string;
|
|
29
|
-
/** The app opens without it; the feature using it says what is missing. */
|
|
30
|
-
readonly optional?: boolean;
|
|
31
|
-
/** The group of which one member is enough ("AI model"). */
|
|
32
|
-
readonly anyOf?: string;
|
|
33
33
|
}
|
|
34
34
|
/** A route reachable without a signed-in member. */
|
|
35
35
|
export interface EveryAppPublicRoute {
|
|
@@ -37,6 +37,13 @@ export interface EveryAppPublicRoute {
|
|
|
37
37
|
readonly path: string;
|
|
38
38
|
/** The methods it answers; `["GET"]` when left out. */
|
|
39
39
|
readonly methods?: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* A bearer route: a native app or a script reaches it with its Gateway
|
|
42
|
+
* token only, on every method (no `methods`). The Gateway answers 401 to
|
|
43
|
+
* a request carrying its session cookie there, and Cloudflare Access
|
|
44
|
+
* lets it through like any public route.
|
|
45
|
+
*/
|
|
46
|
+
readonly bearer?: true;
|
|
40
47
|
}
|
|
41
48
|
/** A Durable Object or Workflow class: its binding, the class, and the helper Worker that defines it. */
|
|
42
49
|
export interface EveryAppClassResource {
|
|
@@ -104,24 +111,47 @@ export interface EveryAppResources {
|
|
|
104
111
|
readonly name: string;
|
|
105
112
|
readonly dataset?: string;
|
|
106
113
|
}[];
|
|
114
|
+
readonly artifacts?: readonly {
|
|
115
|
+
readonly name: string;
|
|
116
|
+
}[];
|
|
107
117
|
}
|
|
108
|
-
/**
|
|
109
|
-
|
|
118
|
+
/**
|
|
119
|
+
* One capability the Gateway serves the app with: an API-key provider or
|
|
120
|
+
* a service, by `access`; an OAuth provider, by the provider's own scopes.
|
|
121
|
+
*/
|
|
122
|
+
export type EveryAppCapabilityEntry = EveryAppKeyCapabilityEntry | EveryAppOAuthCapabilityEntry;
|
|
123
|
+
/** A provider whose key the Gateway holds, or a Gateway service. */
|
|
124
|
+
export interface EveryAppKeyCapabilityEntry extends EveryAppSettingNeed {
|
|
110
125
|
readonly access: "read" | "write";
|
|
111
|
-
|
|
112
|
-
|
|
126
|
+
readonly scopes?: never;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* An OAuth provider (`google-workspace`, `github`): the provider's own
|
|
130
|
+
* scope strings the app needs, short (`gmail.modify`) or in full. A person
|
|
131
|
+
* connects in the app for exactly these; the Gateway adds the scopes that
|
|
132
|
+
* name the account, and refuses a token that carries more.
|
|
133
|
+
*/
|
|
134
|
+
export interface EveryAppOAuthCapabilityEntry extends EveryAppSettingNeed {
|
|
135
|
+
readonly scopes: readonly string[];
|
|
136
|
+
/** Why the app needs it, shown where people connect. At most 200 characters. */
|
|
137
|
+
readonly why: string;
|
|
138
|
+
readonly access?: never;
|
|
113
139
|
}
|
|
114
140
|
/**
|
|
115
141
|
* One of the app's plain settings: a value that isn't a secret and
|
|
116
142
|
* differs per install (a PostHog host, a region), set with `everyapp
|
|
117
143
|
* configure <app>` and read from `env`.
|
|
118
144
|
*/
|
|
119
|
-
export interface EveryAppSettingEntry {
|
|
120
|
-
readonly name: string;
|
|
145
|
+
export interface EveryAppSettingEntry extends EveryAppFeatureSettingEntry {
|
|
121
146
|
/** Why the app needs it: what whoever installs the app reads. */
|
|
122
147
|
readonly why: string;
|
|
123
148
|
readonly docs?: string;
|
|
124
|
-
|
|
149
|
+
}
|
|
150
|
+
/** A plain setting in a feature: the feature says why. */
|
|
151
|
+
export interface EveryAppFeatureSettingEntry {
|
|
152
|
+
readonly name: string;
|
|
153
|
+
/** Where the value is and what it needs, for whoever sets it (200 characters at most; `{appUrl}`, `{gatewayUrl}` are filled in). */
|
|
154
|
+
readonly how?: string;
|
|
125
155
|
/** What it takes; text when not given. */
|
|
126
156
|
readonly type?: "text" | "url" | "number" | "boolean";
|
|
127
157
|
/** The values a text setting may take. */
|
|
@@ -129,23 +159,56 @@ export interface EveryAppSettingEntry {
|
|
|
129
159
|
/** What the app reads while nobody has set it; the deploy writes it. */
|
|
130
160
|
readonly default?: string;
|
|
131
161
|
}
|
|
132
|
-
/** One of the app's own secrets
|
|
133
|
-
export interface
|
|
162
|
+
/** One of the app's own secrets in a feature: the feature says why. */
|
|
163
|
+
export interface EveryAppFeatureSecretEntry {
|
|
134
164
|
readonly name: string;
|
|
135
|
-
/**
|
|
136
|
-
readonly
|
|
165
|
+
/** Where the value is and what permission it needs (200 characters at most; `{appUrl}`, `{gatewayUrl}` are filled in). */
|
|
166
|
+
readonly how?: string;
|
|
167
|
+
/** `everyapp configure` makes it (32 random bytes, base64url) when unset; shown once when `how` says where to paste it. */
|
|
168
|
+
readonly generate?: boolean;
|
|
169
|
+
/** The value is a file's contents (a .pem): the prompt takes the file's path. */
|
|
170
|
+
readonly file?: boolean;
|
|
171
|
+
}
|
|
172
|
+
/** One of the app's own secrets. */
|
|
173
|
+
export interface EveryAppSecretEntry extends EveryAppSettingNeed, EveryAppFeatureSecretEntry {
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* One feature: a named group of secrets, settings and Gateway capabilities
|
|
177
|
+
* with numbered setup steps. A required one keeps the app closed until it
|
|
178
|
+
* is set; an optional one (the default) is all or nothing.
|
|
179
|
+
*/
|
|
180
|
+
export interface EveryAppFeature {
|
|
181
|
+
/** What people read: "GitHub". */
|
|
182
|
+
readonly name: string;
|
|
183
|
+
/** Default false: the app opens without it. */
|
|
184
|
+
readonly required?: boolean;
|
|
185
|
+
/** What it gives the app, in one sentence (200 characters at most). */
|
|
186
|
+
readonly why: string;
|
|
187
|
+
/** Short Markdown lines, numbered when shown; links as plain URLs or `[text](url)`; `{appUrl}`, `{gatewayUrl}` are filled in. */
|
|
188
|
+
readonly steps?: readonly string[];
|
|
189
|
+
readonly settings?: readonly EveryAppFeatureSettingEntry[];
|
|
190
|
+
readonly secrets?: readonly (string | EveryAppFeatureSecretEntry)[];
|
|
191
|
+
/** Capabilities it needs, by id; each declared under `capabilities` too. */
|
|
192
|
+
readonly capabilities?: readonly string[];
|
|
193
|
+
/** AI providers it needs, by id; each declared under `providers` too. */
|
|
194
|
+
readonly providers?: readonly string[];
|
|
137
195
|
}
|
|
138
196
|
/** `everyapp.config.ts`. */
|
|
139
197
|
export interface EveryAppManifest {
|
|
140
198
|
/** Stable id, kebab-case: the app's hostname and Worker. */
|
|
141
199
|
readonly id: string;
|
|
200
|
+
/**
|
|
201
|
+
* The ids the app had before, to rename it: change `id` and list the old
|
|
202
|
+
* one here. The deploy moves the registered app to the new id, keeping
|
|
203
|
+
* its Worker, data and Gateway state, and the old hostname keeps working
|
|
204
|
+
* until its id leaves this list.
|
|
205
|
+
*/
|
|
206
|
+
readonly previousIds?: readonly string[];
|
|
142
207
|
readonly name?: string;
|
|
143
208
|
/** The one line the Gateway's app library shows under the name. */
|
|
144
209
|
readonly description?: string;
|
|
145
210
|
/** The path of an SVG the app serves (`"/everyapp-icon.svg"`). */
|
|
146
211
|
readonly icon?: string;
|
|
147
|
-
/** Legacy: the entry comes from `cloudflare.config.ts`. */
|
|
148
|
-
readonly main?: string;
|
|
149
212
|
/** YYYY-MM-DD. */
|
|
150
213
|
readonly compatibilityDate?: string;
|
|
151
214
|
readonly resources?: EveryAppResources;
|
|
@@ -180,12 +243,16 @@ export interface EveryAppManifest {
|
|
|
180
243
|
readonly secrets?: readonly (string | EveryAppSecretEntry)[];
|
|
181
244
|
/** The app's plain settings: per-install values that aren't secrets. */
|
|
182
245
|
readonly settings?: readonly EveryAppSettingEntry[];
|
|
246
|
+
/** Features by id (a lowercase slug): what the app needs set, grouped, with setup steps. */
|
|
247
|
+
readonly features?: {
|
|
248
|
+
readonly [id: string]: EveryAppFeature;
|
|
249
|
+
};
|
|
183
250
|
readonly ai?: {
|
|
184
251
|
/** Model ids the app may request; any other is `model_not_allowed`. */
|
|
185
252
|
readonly models?: readonly string[];
|
|
186
253
|
/** OpenAI API paths beyond inference (`"/v1/files"`). */
|
|
187
254
|
readonly routes?: readonly string[];
|
|
188
|
-
/** The app takes the
|
|
255
|
+
/** The app takes the workspace's default chat model (`/api/ai/default`, `aiBaseUrl()`). */
|
|
189
256
|
readonly chat?: boolean | EveryAppSettingNeed;
|
|
190
257
|
};
|
|
191
258
|
/** `inbound: true`: the Worker exports an `email()` handler. */
|
|
@@ -194,14 +261,10 @@ export interface EveryAppManifest {
|
|
|
194
261
|
};
|
|
195
262
|
/** Who can open the app once registered; `"admins"` by default. */
|
|
196
263
|
readonly access?: "everyone" | "admins";
|
|
197
|
-
|
|
198
|
-
readonly serverFnBase?: string;
|
|
199
|
-
/** Shell command that builds the app; `cf build` by default. */
|
|
264
|
+
/** Shell command that builds the app; `cf build` by default (`--mode production` without Vite). */
|
|
200
265
|
readonly build?: string;
|
|
201
266
|
/** Shell command `everyapp dev` starts; it must listen on PORT. */
|
|
202
267
|
readonly dev?: string;
|
|
203
|
-
/** Legacy: the port comes from PORT. */
|
|
204
|
-
readonly devPort?: number;
|
|
205
268
|
/** Dependency install command; false skips it. */
|
|
206
269
|
readonly install?: false | string;
|
|
207
270
|
readonly migrations?: {
|
|
@@ -211,9 +274,14 @@ export interface EveryAppManifest {
|
|
|
211
274
|
readonly config?: string;
|
|
212
275
|
readonly binding?: string;
|
|
213
276
|
};
|
|
214
|
-
/**
|
|
215
|
-
|
|
216
|
-
|
|
277
|
+
/**
|
|
278
|
+
* The Gateway events the app receives at `everyApp(handler, { events: {
|
|
279
|
+
* on } })`: types or patterns from `member.*` (but `member.password_reset`),
|
|
280
|
+
* `group.*`, `app.*`, `mcp_app.*`, `connection.*` and `tool.*`, for the
|
|
281
|
+
* app's own organization. Anything else is refused at deploy.
|
|
282
|
+
*/
|
|
283
|
+
readonly events?: {
|
|
284
|
+
readonly subscribe: readonly string[];
|
|
217
285
|
readonly why: string;
|
|
218
286
|
};
|
|
219
287
|
}
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC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Q,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;QAC3C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;QACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,gBAAgB,EAC7D,QAAQ,EAAE,CAAC,GACV,CAAC,CAEH"}
|
package/dist/manifest.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Types only, and a leaf module: `cloudflare.config.ts` imports the manifest,
|
|
13
13
|
* and the Cloudflare Vite plugin hides from the Worker every file the config
|
|
14
14
|
* imports. The rules beyond the shape (which ids exist, which names are
|
|
15
|
-
* reserved, which
|
|
15
|
+
* reserved, which scopes a provider takes) are the CLI's: `everyapp deploy`
|
|
16
16
|
* and `everyapp dev` validate the manifest and say what is wrong. The
|
|
17
17
|
* perimeter's schema (`@every-app/perimeter/manifest`) is held to this type
|
|
18
18
|
* by a test there.
|
package/dist/server/ai.d.ts
CHANGED
|
@@ -1,95 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ai()`: the Gateway's default chat model for an app that needs "a model"
|
|
3
|
-
* rather than one provider (docs/design/2026-10-model-providers.md). The
|
|
4
|
-
* manifest says `ai: { chat: true }` (or `{ chat: { why } }`); the Gateway's
|
|
5
|
-
* operator decides which provider and model that is (`everyapp ai
|
|
6
|
-
* default`, else OpenRouter → Workers AI → OpenAI → …, the first with its
|
|
7
|
-
* key set), and the app never names either: it sends OpenAI-shaped chat
|
|
8
|
-
* completions (and embeddings) to `/api/ai/default/v1/…` with `model:
|
|
9
|
-
* "default"` or no model at all, and the Gateway fills the model in.
|
|
10
|
-
*
|
|
11
|
-
* An OpenAI client takes `baseURL` and `fetch` as they are:
|
|
12
|
-
*
|
|
13
|
-
* const { baseURL, fetch, model } = ai({ env, for: request });
|
|
14
|
-
* const client = new OpenAI({ baseURL, fetch, apiKey: "gateway-managed" });
|
|
15
|
-
* await client.chat.completions.create({ model, messages });
|
|
16
|
-
*
|
|
17
|
-
* In local development with no Gateway, the developer's own key in
|
|
18
|
-
* `.dev.vars` decides the provider by the same order (createGatewayFetch's
|
|
19
|
-
* fallback). An app that needs one provider in particular keeps listing it
|
|
20
|
-
* under `providers` and calling `/api/ai/<provider>/…`.
|
|
21
|
-
*/
|
|
22
|
-
import { AI_DEFAULT_MODEL } from "../internal/index.js";
|
|
23
|
-
import { type GatewayCallFor } from "./attribution.js";
|
|
24
|
-
import { type CreateGatewayFetchOptions } from "./gatewayFetch.js";
|
|
25
|
-
import type { SetupInfo } from "./refusal.js";
|
|
26
|
-
export interface AiClient {
|
|
27
|
-
/** `http://every-app-gateway.internal/api/ai/default/v1`: an OpenAI client's base URL. */
|
|
28
|
-
baseURL: string;
|
|
29
|
-
/** The fetch that reaches the Gateway (or, in dev, the provider directly). */
|
|
30
|
-
fetch: typeof fetch;
|
|
31
|
-
/** The model name that means "whatever the Gateway's default is": `default`. */
|
|
32
|
-
model: typeof AI_DEFAULT_MODEL;
|
|
33
|
-
/** The default route's chat completions URL, for a plain `fetch`. */
|
|
34
|
-
chatCompletionsUrl: string;
|
|
35
|
-
/** The default route's embeddings URL, for a plain `fetch`. */
|
|
36
|
-
embeddingsUrl: string;
|
|
37
|
-
}
|
|
38
|
-
/** The base URL of the default route, as the SDK and the docs name it. */
|
|
39
|
-
export declare const AI_DEFAULT_BASE_URL = "http://every-app-gateway.internal/api/ai/default/v1";
|
|
40
|
-
/**
|
|
41
|
-
* The Gateway's default chat model as a client: a base URL, a fetch and
|
|
42
|
-
* the model name to send. Throws `ConfigurationError` where
|
|
43
|
-
* `createGatewayFetch` does (no binding and no dev key) and
|
|
44
|
-
* `AttributionError` where a shared app's call says nobody's.
|
|
45
|
-
*/
|
|
46
|
-
export declare function ai(options: CreateGatewayFetchOptions & {
|
|
47
|
-
optional: true;
|
|
48
|
-
}): AiClient | null;
|
|
49
|
-
export declare function ai(options: CreateGatewayFetchOptions): AiClient;
|
|
50
|
-
/** Whether model calls to a provider (or the default) would go through. */
|
|
51
|
-
export interface AiStatus extends SetupInfo {
|
|
52
|
-
/** The id asked about: `default`, or a provider's (`openrouter`, `workers-ai`, …). */
|
|
53
|
-
provider: string;
|
|
54
|
-
/** The manifest asks for it: `ai.chat` for `default`, else `providers`. */
|
|
55
|
-
requested: boolean;
|
|
56
|
-
/** The Gateway (in local dev, `.dev.vars`) holds every setting it needs. */
|
|
57
|
-
configured: boolean;
|
|
58
|
-
/** Calls would go through. */
|
|
59
|
-
ready: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* For `default`: the provider and model calls go to now, or null while
|
|
62
|
-
* none is configured. Null for a named provider.
|
|
63
|
-
*/
|
|
64
|
-
resolved: {
|
|
65
|
-
provider: string;
|
|
66
|
-
label: string;
|
|
67
|
-
model: string;
|
|
68
|
-
} | null;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Whether the app can use a model right now, without calling one: gate
|
|
72
|
-
* an AI feature and show `setup` ("A chat model isn't set up on this
|
|
73
|
-
* Gateway: it needs OPENROUTER_API_KEY. An admin runs: pnpm everyapp
|
|
74
|
-
* configure inbox") up front instead of failing mid-task. `provider`
|
|
75
|
-
* defaults to `default`, the Gateway's default model (`ai: { chat: true }`);
|
|
76
|
-
* name one the manifest lists under `providers` to ask about it instead.
|
|
77
|
-
* The Gateway owns the wording: show `setup` and `command` as they are.
|
|
78
|
-
*
|
|
79
|
-
* Over the binding it sends `GET /api/ai/<provider>`; in local dev it
|
|
80
|
-
* answers from `.dev.vars` by the same rule `createGatewayFetch()` uses.
|
|
81
|
-
*/
|
|
82
|
-
export declare function aiStatus({ env, provider, for: explicitTarget, }: {
|
|
83
|
-
env: object;
|
|
84
|
-
provider?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Whom the status is for: the default resolves on that organization's
|
|
87
|
-
* choice (`everyapp ai default`). Left out, the request `everyApp()` is
|
|
88
|
-
* serving or the organization `withOrganization()` named, as on every
|
|
89
|
-
* call.
|
|
90
|
-
*/
|
|
91
|
-
for?: GatewayCallFor;
|
|
92
|
-
}): Promise<AiStatus>;
|
|
93
1
|
/**
|
|
94
2
|
* A provider's root behind the Gateway, `http://every-app-gateway.internal/api/ai/<provider>`:
|
|
95
3
|
* join the provider's own paths onto it (`/api/v1/chat/completions` for
|
|
@@ -100,7 +8,7 @@ export declare function providerBaseUrl(provider: string): string;
|
|
|
100
8
|
/**
|
|
101
9
|
* The OpenAI-compatible base URL of `provider` behind the Gateway, for an
|
|
102
10
|
* OpenAI client's `baseURL` (with `fetch: createGatewayFetch(...)`):
|
|
103
|
-
* `default` (the default
|
|
11
|
+
* `default` (the default, and what it is when left out) is
|
|
104
12
|
* `…/api/ai/default/v1`; a catalog provider's is its root and the prefix
|
|
105
13
|
* of its chat route (`…/api/ai/openrouter/api/v1`, `…/api/ai/workers-ai/v1`,
|
|
106
14
|
* `…/api/ai/openai/v1`). Throws `ConfigurationError` for a provider with
|
package/dist/server/ai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/server/ai.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/server/ai.ts"],"names":[],"mappings":"AA2BA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,QAAQ,GAAE,MAA4B,GAAG,MAAM,CAaxE"}
|
package/dist/server/ai.js
CHANGED
|
@@ -1,116 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* default
|
|
7
|
-
*
|
|
8
|
-
* completions (and embeddings) to `/api/ai/default/v1/…` with `model:
|
|
9
|
-
* "default"` or no model at all, and the Gateway fills the model in.
|
|
2
|
+
* Where an app's model calls go behind the Gateway, for an OpenAI client's
|
|
3
|
+
* `baseURL` or a plain `fetch`, both sent with `createGatewayFetch()`:
|
|
4
|
+
* `aiBaseUrl("openai")` (a provider's OpenAI-compatible base), `aiBaseUrl()`
|
|
5
|
+
* (the Gateway's default model, `ai: { chat: true }`: send `model:
|
|
6
|
+
* "default"` or none and the Gateway fills in the workspace's model), and
|
|
7
|
+
* `providerBaseUrl("openai")` (a provider's root, for its own paths).
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* In local development with no Gateway, the developer's own key in
|
|
18
|
-
* `.dev.vars` decides the provider by the same order (createGatewayFetch's
|
|
19
|
-
* fallback). An app that needs one provider in particular keeps listing it
|
|
20
|
-
* under `providers` and calling `/api/ai/<provider>/…`.
|
|
9
|
+
* const client = new OpenAI({
|
|
10
|
+
* baseURL: aiBaseUrl(),
|
|
11
|
+
* fetch: createGatewayFetch({ env }),
|
|
12
|
+
* apiKey: "gateway-managed",
|
|
13
|
+
* });
|
|
14
|
+
* await client.chat.completions.create({ model: "default", messages });
|
|
21
15
|
*/
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const AI_DEFAULT_BASE_URL = `${BINDING_ORIGIN}/api/ai/${AI_DEFAULT_PROVIDER}/v1`;
|
|
27
|
-
export function ai(options) {
|
|
28
|
-
const fetch = createGatewayFetch(options);
|
|
29
|
-
if (!fetch)
|
|
30
|
-
return null;
|
|
31
|
-
return {
|
|
32
|
-
baseURL: AI_DEFAULT_BASE_URL,
|
|
33
|
-
fetch,
|
|
34
|
-
model: AI_DEFAULT_MODEL,
|
|
35
|
-
chatCompletionsUrl: `${AI_DEFAULT_BASE_URL}/chat/completions`,
|
|
36
|
-
embeddingsUrl: `${AI_DEFAULT_BASE_URL}/embeddings`,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Whether the app can use a model right now, without calling one: gate
|
|
41
|
-
* an AI feature and show `setup` ("A chat model isn't set up on this
|
|
42
|
-
* Gateway: it needs OPENROUTER_API_KEY. An admin runs: pnpm everyapp
|
|
43
|
-
* configure inbox") up front instead of failing mid-task. `provider`
|
|
44
|
-
* defaults to `default`, the Gateway's default model (`ai: { chat: true }`);
|
|
45
|
-
* name one the manifest lists under `providers` to ask about it instead.
|
|
46
|
-
* The Gateway owns the wording: show `setup` and `command` as they are.
|
|
47
|
-
*
|
|
48
|
-
* Over the binding it sends `GET /api/ai/<provider>`; in local dev it
|
|
49
|
-
* answers from `.dev.vars` by the same rule `createGatewayFetch()` uses.
|
|
50
|
-
*/
|
|
51
|
-
export async function aiStatus({ env, provider = AI_DEFAULT_PROVIDER, for: explicitTarget, }) {
|
|
52
|
-
const target = attributionFor(env, explicitTarget, "aiStatus");
|
|
53
|
-
const values = env;
|
|
54
|
-
const binding = values["EVERY_APP_GATEWAY"];
|
|
55
|
-
const unavailable = {
|
|
56
|
-
provider,
|
|
57
|
-
requested: false,
|
|
58
|
-
configured: false,
|
|
59
|
-
ready: false,
|
|
60
|
-
resolved: null,
|
|
61
|
-
settings: [],
|
|
62
|
-
setup: null,
|
|
63
|
-
command: null,
|
|
64
|
-
};
|
|
65
|
-
if (binding && typeof binding.fetch === "function") {
|
|
66
|
-
const headers = new Headers();
|
|
67
|
-
if (target !== undefined)
|
|
68
|
-
applyAttribution(headers, target);
|
|
69
|
-
const response = await binding.fetch(`${BINDING_ORIGIN}/api/ai/${encodeURIComponent(provider)}`, { headers });
|
|
70
|
-
if (!response.ok)
|
|
71
|
-
return unavailable;
|
|
72
|
-
const body = (await response.json());
|
|
73
|
-
return {
|
|
74
|
-
...unavailable,
|
|
75
|
-
...body,
|
|
76
|
-
provider,
|
|
77
|
-
settings: Array.isArray(body.settings) ? body.settings : [],
|
|
78
|
-
setup: typeof body.setup === "string" ? body.setup : null,
|
|
79
|
-
command: typeof body.command === "string" ? body.command : null,
|
|
80
|
-
resolved: body.resolved ?? null,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (!values["EVERYAPP_DEV"])
|
|
84
|
-
return unavailable;
|
|
85
|
-
const isSet = (name) => typeof values[name] === "string" && values[name].trim() !== "";
|
|
86
|
-
const dev = (label, settings, configured, resolved, also = "") => ({
|
|
87
|
-
provider,
|
|
88
|
-
requested: true,
|
|
89
|
-
configured,
|
|
90
|
-
ready: configured,
|
|
91
|
-
resolved,
|
|
92
|
-
settings: configured ? [] : [...settings],
|
|
93
|
-
setup: configured
|
|
94
|
-
? null
|
|
95
|
-
: `${label} isn't set up for local development: set ${settings.join(" and ")}${also} in .dev.vars.`,
|
|
96
|
-
command: null,
|
|
97
|
-
});
|
|
98
|
-
if (provider === AI_DEFAULT_PROVIDER) {
|
|
99
|
-
const resolution = resolveAiDefault({ provider: null, isSet });
|
|
100
|
-
return dev("A chat model", resolution.settings, resolution.configured, resolution.configured
|
|
101
|
-
? {
|
|
102
|
-
provider: resolution.provider,
|
|
103
|
-
label: resolution.label,
|
|
104
|
-
model: resolution.model,
|
|
105
|
-
}
|
|
106
|
-
: null, " (or another model provider's key)");
|
|
107
|
-
}
|
|
108
|
-
const spec = devAiProvider(provider);
|
|
109
|
-
if (!spec)
|
|
110
|
-
return unavailable;
|
|
111
|
-
const settings = aiProviderSettings(spec);
|
|
112
|
-
return dev(CATALOG.get(provider)?.label ?? provider, settings, settings.every(isSet), null);
|
|
113
|
-
}
|
|
16
|
+
import { AI_DEFAULT_PROVIDER, CATALOG, ConfigurationError, } from "../internal/index.js";
|
|
17
|
+
import { BINDING_ORIGIN } from "./gatewayFetch.js";
|
|
18
|
+
/** The base URL of the default route, `…/api/ai/default/v1`. */
|
|
19
|
+
const AI_DEFAULT_BASE_URL = `${BINDING_ORIGIN}/api/ai/${AI_DEFAULT_PROVIDER}/v1`;
|
|
114
20
|
const CHAT_COMPLETIONS = "/chat/completions";
|
|
115
21
|
/**
|
|
116
22
|
* A provider's root behind the Gateway, `http://every-app-gateway.internal/api/ai/<provider>`:
|
|
@@ -124,7 +30,7 @@ export function providerBaseUrl(provider) {
|
|
|
124
30
|
/**
|
|
125
31
|
* The OpenAI-compatible base URL of `provider` behind the Gateway, for an
|
|
126
32
|
* OpenAI client's `baseURL` (with `fetch: createGatewayFetch(...)`):
|
|
127
|
-
* `default` (the default
|
|
33
|
+
* `default` (the default, and what it is when left out) is
|
|
128
34
|
* `…/api/ai/default/v1`; a catalog provider's is its root and the prefix
|
|
129
35
|
* of its chat route (`…/api/ai/openrouter/api/v1`, `…/api/ai/workers-ai/v1`,
|
|
130
36
|
* `…/api/ai/openai/v1`). Throws `ConfigurationError` for a provider with
|