@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.
Files changed (146) hide show
  1. package/README.md +75 -74
  2. package/dist/cloudflare/catalogSettings.generated.d.ts +20 -6
  3. package/dist/cloudflare/catalogSettings.generated.d.ts.map +1 -1
  4. package/dist/cloudflare/catalogSettings.generated.js +45 -14
  5. package/dist/cloudflare/index.d.ts +1 -1
  6. package/dist/cloudflare/index.d.ts.map +1 -1
  7. package/dist/cloudflare/sentinel.d.ts +3 -0
  8. package/dist/cloudflare/sentinel.d.ts.map +1 -1
  9. package/dist/cloudflare/sentinel.js +10 -0
  10. package/dist/cloudflare/worker.d.ts +67 -23
  11. package/dist/cloudflare/worker.d.ts.map +1 -1
  12. package/dist/cloudflare/worker.js +68 -32
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/internal/aiDefault.d.ts +36 -79
  16. package/dist/internal/aiDefault.d.ts.map +1 -1
  17. package/dist/internal/aiDefault.js +47 -149
  18. package/dist/internal/aiProviders.d.ts +1 -1
  19. package/dist/internal/aiProviders.d.ts.map +1 -1
  20. package/dist/internal/aiProviders.js +2 -2
  21. package/dist/internal/appSettings.d.ts +140 -89
  22. package/dist/internal/appSettings.d.ts.map +1 -1
  23. package/dist/internal/appSettings.js +264 -156
  24. package/dist/internal/capabilities.d.ts +145 -503
  25. package/dist/internal/capabilities.d.ts.map +1 -1
  26. package/dist/internal/capabilities.js +29 -550
  27. package/dist/internal/catalog/commerce.js +1 -1
  28. package/dist/internal/catalog/comms.d.ts +37 -0
  29. package/dist/internal/catalog/comms.d.ts.map +1 -1
  30. package/dist/internal/catalog/comms.js +43 -0
  31. package/dist/internal/catalog/index.d.ts +72 -0
  32. package/dist/internal/catalog/index.d.ts.map +1 -1
  33. package/dist/internal/catalog/infra.d.ts +35 -0
  34. package/dist/internal/catalog/infra.d.ts.map +1 -1
  35. package/dist/internal/catalog/infra.js +65 -0
  36. package/dist/internal/devProviders.d.ts +1 -19
  37. package/dist/internal/devProviders.d.ts.map +1 -1
  38. package/dist/internal/devProviders.js +7 -1
  39. package/dist/internal/events.d.ts +52 -1
  40. package/dist/internal/events.d.ts.map +1 -1
  41. package/dist/internal/events.js +66 -2
  42. package/dist/internal/gatewaySettings.d.ts +6 -16
  43. package/dist/internal/gatewaySettings.d.ts.map +1 -1
  44. package/dist/internal/gatewaySettings.js +6 -24
  45. package/dist/internal/index.d.ts +1 -0
  46. package/dist/internal/index.d.ts.map +1 -1
  47. package/dist/internal/index.js +1 -0
  48. package/dist/internal/mcpOAuth.d.ts +210 -0
  49. package/dist/internal/mcpOAuth.d.ts.map +1 -0
  50. package/dist/internal/mcpOAuth.js +735 -0
  51. package/dist/internal/oauthClient.d.ts +7 -47
  52. package/dist/internal/oauthClient.d.ts.map +1 -1
  53. package/dist/internal/oauthClient.js +1 -115
  54. package/dist/internal/oauthPresets.d.ts +356 -20
  55. package/dist/internal/oauthPresets.d.ts.map +1 -1
  56. package/dist/internal/oauthPresets.js +183 -861
  57. package/dist/internal/oauthScopes.d.ts +43 -155
  58. package/dist/internal/oauthScopes.d.ts.map +1 -1
  59. package/dist/internal/oauthScopes.js +82 -475
  60. package/dist/internal/oauthSpec.d.ts +28 -71
  61. package/dist/internal/oauthSpec.d.ts.map +1 -1
  62. package/dist/internal/oauthSpec.js +172 -448
  63. package/dist/internal/protocol.d.ts +39 -15
  64. package/dist/internal/protocol.d.ts.map +1 -1
  65. package/dist/internal/protocol.js +40 -7
  66. package/dist/internal/providerApps.d.ts +2 -2
  67. package/dist/internal/providerApps.js +2 -2
  68. package/dist/internal/providerRegistry.d.ts +5 -64
  69. package/dist/internal/providerRegistry.d.ts.map +1 -1
  70. package/dist/internal/providerRegistry.js +19 -118
  71. package/dist/internal/providerSpec.d.ts.map +1 -1
  72. package/dist/internal/providerSpec.js +14 -36
  73. package/dist/internal/remoteMcp.d.ts +191 -47
  74. package/dist/internal/remoteMcp.d.ts.map +1 -1
  75. package/dist/internal/remoteMcp.js +338 -133
  76. package/dist/internal/signInProviders.d.ts +1 -1
  77. package/dist/internal/signInProviders.d.ts.map +1 -1
  78. package/dist/internal/tools.d.ts +15 -8
  79. package/dist/internal/tools.d.ts.map +1 -1
  80. package/dist/internal/tools.js +9 -8
  81. package/dist/manifest.d.ts +96 -28
  82. package/dist/manifest.d.ts.map +1 -1
  83. package/dist/manifest.js +1 -1
  84. package/dist/server/ai.d.ts +1 -93
  85. package/dist/server/ai.d.ts.map +1 -1
  86. package/dist/server/ai.js +17 -111
  87. package/dist/server/attribution.d.ts +10 -1
  88. package/dist/server/attribution.d.ts.map +1 -1
  89. package/dist/server/attribution.js +7 -1
  90. package/dist/server/connectUrl.d.ts +4 -9
  91. package/dist/server/connectUrl.d.ts.map +1 -1
  92. package/dist/server/connectUrl.js +17 -14
  93. package/dist/server/context.d.ts +12 -14
  94. package/dist/server/context.d.ts.map +1 -1
  95. package/dist/server/context.js +23 -25
  96. package/dist/server/emit.d.ts.map +1 -1
  97. package/dist/server/emit.js +2 -2
  98. package/dist/server/env.d.ts +3 -0
  99. package/dist/server/env.d.ts.map +1 -1
  100. package/dist/server/eventsEndpoint.d.ts +48 -0
  101. package/dist/server/eventsEndpoint.d.ts.map +1 -0
  102. package/dist/server/eventsEndpoint.js +145 -0
  103. package/dist/server/everyApp.d.ts +16 -26
  104. package/dist/server/everyApp.d.ts.map +1 -1
  105. package/dist/server/everyApp.js +22 -46
  106. package/dist/server/gatewayFetch.d.ts +19 -1
  107. package/dist/server/gatewayFetch.d.ts.map +1 -1
  108. package/dist/server/gatewayFetch.js +45 -3
  109. package/dist/server/index.d.ts +6 -9
  110. package/dist/server/index.d.ts.map +1 -1
  111. package/dist/server/index.js +4 -8
  112. package/dist/server/integrationFetch.d.ts +60 -72
  113. package/dist/server/integrationFetch.d.ts.map +1 -1
  114. package/dist/server/integrationFetch.js +124 -397
  115. package/dist/server/listMembers.d.ts.map +1 -1
  116. package/dist/server/listMembers.js +2 -2
  117. package/dist/server/refusal.d.ts +0 -9
  118. package/dist/server/refusal.d.ts.map +1 -1
  119. package/dist/server/refusal.js +0 -22
  120. package/dist/server/sendEmail.d.ts.map +1 -1
  121. package/dist/server/sendEmail.js +2 -2
  122. package/dist/server/tools.d.ts +17 -6
  123. package/dist/server/tools.d.ts.map +1 -1
  124. package/dist/server/tools.js +14 -4
  125. package/dist/server/toolsEndpoint.d.ts +2 -1
  126. package/dist/server/toolsEndpoint.d.ts.map +1 -1
  127. package/dist/server/toolsEndpoint.js +4 -3
  128. package/dist/server/webhooks.d.ts +56 -0
  129. package/dist/server/webhooks.d.ts.map +1 -0
  130. package/dist/server/webhooks.js +205 -0
  131. package/dist/testing/index.d.ts +2 -3
  132. package/dist/testing/index.d.ts.map +1 -1
  133. package/dist/testing/index.js +2 -6
  134. package/package.json +6 -1
  135. package/dist/server/aiBinding.d.ts +0 -68
  136. package/dist/server/aiBinding.d.ts.map +0 -1
  137. package/dist/server/aiBinding.js +0 -294
  138. package/dist/server/authorizeUrl.d.ts +0 -43
  139. package/dist/server/authorizeUrl.d.ts.map +0 -1
  140. package/dist/server/authorizeUrl.js +0 -106
  141. package/dist/server/emailBinding.d.ts +0 -72
  142. package/dist/server/emailBinding.d.ts.map +0 -1
  143. package/dist/server/emailBinding.js +0 -124
  144. package/dist/server/fromMcpTools.d.ts +0 -89
  145. package/dist/server/fromMcpTools.d.ts.map +0 -1
  146. package/dist/server/fromMcpTools.js +0 -192
@@ -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" + tc claim
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
- export declare const TOOL_RISKS: readonly ["read", "write", "destructive"];
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"` identities, one per risk. */
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 `chan: "mcp"` identity must carry to call a tool. */
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"` token to one call. */
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;;;;;;;;;;;GAWG;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,eAAO,MAAM,UAAU,2CAA4C,CAAC;AACpE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,0EAA0E;AAC1E,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAE1D,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAK5D;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAS3D;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,a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ED,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,CAAC,CAAC;IACL,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAaD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACpC,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB"}
@@ -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" + tc claim
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
- export const TOOL_RISKS = ["read", "write", "destructive"];
18
- /** Scopes the gateway mints on `chan: "mcp"` identities, one per risk. */
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 `chan: "mcp"` identity must carry to call a tool. */
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
  /**
@@ -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 scope sets a provider has) are the CLI's: `everyapp deploy`
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
- /** Why a setting is needed and whether the app opens without it (the settings model). */
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
- /** One capability the Gateway serves the app with keys it holds. */
109
- export interface EveryAppCapabilityEntry extends EveryAppSettingNeed {
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
- /** An OAuth client's scope sets, by name (`["gmail.read"]`). */
112
- readonly scopes?: readonly string[];
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
- readonly optional?: boolean;
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, with its need. */
133
- export interface EveryAppSecretEntry extends EveryAppSettingNeed {
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
- /** Its guide in the everyapp skill (`"setup/main-secret.md"`). */
136
- readonly setup?: string;
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 Gateway's default chat model (`ai()`). */
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
- readonly serverFnGuard?: boolean;
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
- /** Who answers `/mcp` on the app's own host, and why it needs to. */
215
- readonly mcp?: {
216
- readonly by: "gateway" | "app";
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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"m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AK,CAAC,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,QAAQ,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 scope sets a provider has) are the CLI's: `everyapp deploy`
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.
@@ -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) is {@link AI_DEFAULT_BASE_URL},
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
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/server/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,gBAAgB,EAOjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,yBAAyB,EAE/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,QAAQ;IACvB,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,gFAAgF;IAChF,KAAK,EAAE,OAAO,gBAAgB,CAAC;IAC/B,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,wDAAuD,CAAC;AAExF;;;;;GAKG;AACH,wBAAgB,EAAE,CAChB,OAAO,EAAE,yBAAyB,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GACtD,QAAQ,GAAG,IAAI,CAAC;AACnB,wBAAgB,EAAE,CAAC,OAAO,EAAE,yBAAyB,GAAG,QAAQ,CAAC;AAajE,2EAA2E;AAC3E,MAAM,WAAW,QAAS,SAAQ,SAAS;IACzC,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,UAAU,EAAE,OAAO,CAAC;IACpB,8BAA8B;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,QAA8B,EAC9B,GAAG,EAAE,cAAc,GACpB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,cAAc,CAAC;CACtB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiFpB;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,QAAQ,GAAE,MAA4B,GAAG,MAAM,CAaxE"}
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
- * `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.
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
- * 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>/…`.
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 { AI_DEFAULT_MODEL, AI_DEFAULT_PROVIDER, CATALOG, ConfigurationError, aiProviderSettings, devAiProvider, resolveAiDefault, } from "../internal/index.js";
23
- import { applyAttribution, attributionFor, } from "./attribution.js";
24
- import { BINDING_ORIGIN, createGatewayFetch, } from "./gatewayFetch.js";
25
- /** The base URL of the default route, as the SDK and the docs name it. */
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) is {@link AI_DEFAULT_BASE_URL},
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