@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.
- package/README.md +67 -67
- package/dist/cloudflare/catalogSettings.generated.d.ts +7 -4
- package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
- package/dist/cloudflare/catalogSettings.generated.js +7 -6
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/worker.d.ts +36 -2
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +32 -6
- 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.map +1 -1
- package/dist/internal/aiProviders.js +2 -2
- package/dist/internal/appSettings.d.ts +14 -17
- package/dist/internal/appSettings.d.ts.map +1 -1
- package/dist/internal/appSettings.js +2 -16
- package/dist/internal/capabilities.d.ts +106 -489
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +49 -550
- package/dist/internal/catalog/commerce.js +1 -1
- package/dist/internal/catalog/index.d.ts +35 -0
- package/dist/internal/catalog/index.d.ts.map +1 -1
- package/dist/internal/catalog/infra.d.ts +35 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -1
- package/dist/internal/catalog/infra.js +65 -0
- package/dist/internal/events.d.ts +52 -1
- package/dist/internal/events.d.ts.map +1 -1
- package/dist/internal/events.js +65 -3
- package/dist/internal/gatewaySettings.d.ts +2 -2
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +0 -6
- package/dist/internal/oauthBuiltIns.d.ts +101 -0
- package/dist/internal/oauthBuiltIns.d.ts.map +1 -0
- package/dist/internal/oauthBuiltIns.js +122 -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 +14 -15
- package/dist/internal/oauthPresets.d.ts.map +1 -1
- package/dist/internal/oauthPresets.js +42 -853
- 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 +72 -71
- package/dist/internal/oauthSpec.d.ts.map +1 -1
- package/dist/internal/oauthSpec.js +178 -447
- package/dist/internal/protocol.d.ts +24 -14
- package/dist/internal/protocol.d.ts.map +1 -1
- package/dist/internal/protocol.js +26 -7
- package/dist/internal/providerRegistry.d.ts +1 -61
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +8 -115
- package/dist/internal/providerSpec.d.ts.map +1 -1
- package/dist/internal/providerSpec.js +14 -36
- package/dist/internal/remoteMcp.d.ts +4 -6
- package/dist/internal/remoteMcp.d.ts.map +1 -1
- package/dist/internal/remoteMcp.js +8 -15
- package/dist/internal/tools.d.ts +12 -7
- package/dist/internal/tools.d.ts.map +1 -1
- package/dist/internal/tools.js +9 -8
- package/dist/manifest.d.ts +41 -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/eventsEndpoint.d.ts +48 -0
- package/dist/server/eventsEndpoint.d.ts.map +1 -0
- package/dist/server/eventsEndpoint.js +145 -0
- package/dist/server/everyApp.d.ts +16 -26
- package/dist/server/everyApp.d.ts.map +1 -1
- package/dist/server/everyApp.js +22 -46
- package/dist/server/gatewayFetch.d.ts +1 -1
- package/dist/server/gatewayFetch.js +1 -1
- package/dist/server/index.d.ts +6 -9
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -8
- package/dist/server/integrationFetch.d.ts +60 -72
- package/dist/server/integrationFetch.d.ts.map +1 -1
- package/dist/server/integrationFetch.js +117 -392
- package/dist/server/refusal.d.ts +0 -9
- package/dist/server/refusal.d.ts.map +1 -1
- package/dist/server/refusal.js +0 -22
- package/dist/server/tools.d.ts +13 -5
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +10 -3
- 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 +1 -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
|
@@ -147,11 +147,7 @@ export function reservedUpstreamHosts() {
|
|
|
147
147
|
hosts.add(host);
|
|
148
148
|
}
|
|
149
149
|
else if (capability.mode === "oauth_client") {
|
|
150
|
-
|
|
151
|
-
if ("host" in endpoint && typeof endpoint.host === "string") {
|
|
152
|
-
hosts.add(endpoint.host);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
150
|
+
hosts.add(new URL(capability.flow.tokenUrl).hostname);
|
|
155
151
|
}
|
|
156
152
|
}
|
|
157
153
|
return [...hosts].sort();
|
|
@@ -352,7 +348,7 @@ export function parseRemoteMcpBlock(raw) {
|
|
|
352
348
|
if (!isToolRisk(override["risk"])) {
|
|
353
349
|
return {
|
|
354
350
|
ok: false,
|
|
355
|
-
problem: `remote.tools.${name}.risk must be read
|
|
351
|
+
problem: `remote.tools.${name}.risk must be read or write`,
|
|
356
352
|
};
|
|
357
353
|
}
|
|
358
354
|
out.risk = override["risk"];
|
|
@@ -451,12 +447,10 @@ export function remoteMcpAppManifest(input) {
|
|
|
451
447
|
}
|
|
452
448
|
/**
|
|
453
449
|
* A tool's risk for the Gateway. An override wins; then the app's `read`
|
|
454
|
-
* or `write` default; then the server's hints
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* default for `destructiveHint` is not followed: it would hide every
|
|
459
|
-
* unhinted tool.
|
|
450
|
+
* or `write` default; then the server's hints: an explicit `readOnlyHint:
|
|
451
|
+
* true` is `read`, and anything else, a missing hint included, is `write`.
|
|
452
|
+
* A write tool keeps the server's `destructiveHint`, so clients still ask
|
|
453
|
+
* before calling it.
|
|
460
454
|
*/
|
|
461
455
|
export function remoteToolRisk(hints, block, upstreamName) {
|
|
462
456
|
const override = remoteToolOverride(block, upstreamName)?.risk;
|
|
@@ -467,9 +461,8 @@ export function remoteToolRisk(hints, block, upstreamName) {
|
|
|
467
461
|
}
|
|
468
462
|
if (hints?.readOnlyHint === true)
|
|
469
463
|
return { risk: "read", source: "hint" };
|
|
470
|
-
if (hints?.destructiveHint === true)
|
|
471
|
-
return { risk: "
|
|
472
|
-
}
|
|
464
|
+
if (hints?.destructiveHint === true)
|
|
465
|
+
return { risk: "write", source: "hint" };
|
|
473
466
|
return { risk: "write", source: "default" };
|
|
474
467
|
}
|
|
475
468
|
/** Whether the operator left the tool on (the default). */
|
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;
|
|
@@ -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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M,CAAC;IACtB,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACpC,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB"}
|
package/dist/internal/tools.js
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,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.
|
|
@@ -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,12 +111,31 @@ 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
|
|
@@ -132,7 +158,7 @@ export interface EveryAppSettingEntry {
|
|
|
132
158
|
/** One of the app's own secrets, with its need. */
|
|
133
159
|
export interface EveryAppSecretEntry extends EveryAppSettingNeed {
|
|
134
160
|
readonly name: string;
|
|
135
|
-
/** Its guide in the
|
|
161
|
+
/** Its setup guide, a path in the app (`"docs/setup/main-secret.md"`). */
|
|
136
162
|
readonly setup?: string;
|
|
137
163
|
}
|
|
138
164
|
/** `everyapp.config.ts`. */
|
|
@@ -144,8 +170,6 @@ export interface EveryAppManifest {
|
|
|
144
170
|
readonly description?: string;
|
|
145
171
|
/** The path of an SVG the app serves (`"/everyapp-icon.svg"`). */
|
|
146
172
|
readonly icon?: string;
|
|
147
|
-
/** Legacy: the entry comes from `cloudflare.config.ts`. */
|
|
148
|
-
readonly main?: string;
|
|
149
173
|
/** YYYY-MM-DD. */
|
|
150
174
|
readonly compatibilityDate?: string;
|
|
151
175
|
readonly resources?: EveryAppResources;
|
|
@@ -168,18 +192,6 @@ export interface EveryAppManifest {
|
|
|
168
192
|
* OG image): path patterns, GET and HEAD, never Worker code.
|
|
169
193
|
*/
|
|
170
194
|
readonly publicAssets?: readonly string[];
|
|
171
|
-
/**
|
|
172
|
-
* Routes a bearer client (a native app, a script with a personal token)
|
|
173
|
-
* reaches with its token only: `paths` in `public`'s glob syntax, every
|
|
174
|
-
* method, and `why` the app needs them, shown to the operator. The
|
|
175
|
-
* Gateway answers 401 to a request carrying its session cookie there,
|
|
176
|
-
* and `everyapp access on` lets these paths through Cloudflare Access.
|
|
177
|
-
* Default: none.
|
|
178
|
-
*/
|
|
179
|
-
readonly bearerRoutes?: {
|
|
180
|
-
readonly paths: readonly string[];
|
|
181
|
-
readonly why: string;
|
|
182
|
-
};
|
|
183
195
|
/** AI providers the Gateway calls for the app, by id or with their need. */
|
|
184
196
|
readonly providers?: readonly (string | (EveryAppSettingNeed & {
|
|
185
197
|
readonly id: string;
|
|
@@ -197,7 +209,7 @@ export interface EveryAppManifest {
|
|
|
197
209
|
readonly models?: readonly string[];
|
|
198
210
|
/** OpenAI API paths beyond inference (`"/v1/files"`). */
|
|
199
211
|
readonly routes?: readonly string[];
|
|
200
|
-
/** The app takes the
|
|
212
|
+
/** The app takes the workspace's default chat model (`/api/ai/default`, `aiBaseUrl()`). */
|
|
201
213
|
readonly chat?: boolean | EveryAppSettingNeed;
|
|
202
214
|
};
|
|
203
215
|
/** `inbound: true`: the Worker exports an `email()` handler. */
|
|
@@ -206,14 +218,10 @@ export interface EveryAppManifest {
|
|
|
206
218
|
};
|
|
207
219
|
/** Who can open the app once registered; `"admins"` by default. */
|
|
208
220
|
readonly access?: "everyone" | "admins";
|
|
209
|
-
readonly serverFnGuard?: boolean;
|
|
210
|
-
readonly serverFnBase?: string;
|
|
211
221
|
/** Shell command that builds the app; `cf build` by default. */
|
|
212
222
|
readonly build?: string;
|
|
213
223
|
/** Shell command `everyapp dev` starts; it must listen on PORT. */
|
|
214
224
|
readonly dev?: string;
|
|
215
|
-
/** Legacy: the port comes from PORT. */
|
|
216
|
-
readonly devPort?: number;
|
|
217
225
|
/** Dependency install command; false skips it. */
|
|
218
226
|
readonly install?: false | string;
|
|
219
227
|
readonly migrations?: {
|
|
@@ -223,9 +231,14 @@ export interface EveryAppManifest {
|
|
|
223
231
|
readonly config?: string;
|
|
224
232
|
readonly binding?: string;
|
|
225
233
|
};
|
|
226
|
-
/**
|
|
227
|
-
|
|
228
|
-
|
|
234
|
+
/**
|
|
235
|
+
* The Gateway events the app receives at `everyApp(handler, { events: {
|
|
236
|
+
* on } })`: types or patterns from `member.*` (but `member.password_reset`),
|
|
237
|
+
* `group.*`, `app.*`, `mcp_app.*`, `connection.*` and `tool.*`, for the
|
|
238
|
+
* app's own organization. Anything else is refused at deploy.
|
|
239
|
+
*/
|
|
240
|
+
readonly events?: {
|
|
241
|
+
readonly subscribe: readonly string[];
|
|
229
242
|
readonly why: string;
|
|
230
243
|
};
|
|
231
244
|
}
|
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,yFAAyF;AACzF,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,QAAQ,CAA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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 = gatewayBinding(env);
|
|
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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Whom a call through the gateway is for, which decides the organization
|
|
3
3
|
* it counts against. Left out, it comes from the request context: the
|
|
4
4
|
* request `everyApp()` is serving (its person, while the identity is good),
|
|
5
|
-
* or the organization
|
|
5
|
+
* or the organization the SDK's event delivery runs under. Given explicitly:
|
|
6
6
|
*
|
|
7
7
|
* - the inbound `Request`: its person, by the identity the gateway put on
|
|
8
8
|
* it (forwarded as is);
|
|
@@ -12,10 +12,19 @@
|
|
|
12
12
|
* checks is active and has a live member. An organization's own app may
|
|
13
13
|
* leave it out (the gateway knows its organization) and may only name
|
|
14
14
|
* its own.
|
|
15
|
+
* - `{ background: true, organizationId, userId }`: a call to an OAuth
|
|
16
|
+
* provider's API (`integrationFetch`) on the connection member `userId`
|
|
17
|
+
* made in this app, at any time, even while serving another person's
|
|
18
|
+
* request: the call carries that member (`x-everyapp-user`) and never
|
|
19
|
+
* the identity of the person being served. Only an organization's own
|
|
20
|
+
* app may name a member, and only one who may still open the app. No
|
|
21
|
+
* identity for the member reaches the app. Other gateway calls ignore
|
|
22
|
+
* `userId`.
|
|
15
23
|
*/
|
|
16
24
|
export type GatewayCallFor = Request | {
|
|
17
25
|
background: true;
|
|
18
26
|
organizationId?: string;
|
|
27
|
+
userId?: string;
|
|
19
28
|
};
|
|
20
29
|
/**
|
|
21
30
|
* A gateway call that doesn't say whom it is for where it must: from a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/server/attribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/server/attribution.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,0BAA0B;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,GACX,cAAc,GAAG,SAAS,CAI5B;AAmCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,IAAI,CAYN;AASD,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAO1D"}
|