apps 0.0.1-beta.1 → 0.0.1-beta.100

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 (211) hide show
  1. package/README.md +112 -72
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/chunk-2CURR5Y7.js +264 -0
  5. package/js/chunk-2LSGC7XY.js +42 -0
  6. package/js/{chunk-YEJOQEII.js → chunk-4PIQKACY.js} +65 -10
  7. package/js/chunk-4UPC36ZL.js +5185 -0
  8. package/js/{chunk-4LPG6RCH.js → chunk-4X2UI4R2.js} +7 -27
  9. package/js/chunk-5C6RAGAS.js +335 -0
  10. package/js/chunk-62NVUKED.js +39 -0
  11. package/js/chunk-74H25C4X.js +95 -0
  12. package/js/chunk-7HG422GB.js +90 -0
  13. package/js/chunk-7STIP5CS.js +171 -0
  14. package/js/{chunk-QKHR7BMF.js → chunk-ACQXVKVQ.js} +87 -51
  15. package/js/{chunk-OHRT55C4.js → chunk-DILSCQPJ.js} +226 -265
  16. package/js/chunk-ILYCJ3HV.js +449 -0
  17. package/js/chunk-K6TSCYAO.js +712 -0
  18. package/js/{chunk-EVJUVWN2.js → chunk-KLSEU35Y.js} +463 -218
  19. package/js/chunk-OD3KFKZD.js +1617 -0
  20. package/js/chunk-OWN3DP2W.js +88 -0
  21. package/js/{chunk-ZTFQHGEB.js → chunk-PBGPES67.js} +3 -5
  22. package/js/chunk-QI66R4FP.js +786 -0
  23. package/js/chunk-RN4YB4JT.js +1922 -0
  24. package/js/{chunk-ZCAMUXSG.js → chunk-URKOTNDA.js} +795 -177
  25. package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
  26. package/js/{chunk-2HHMABB6.js → chunk-VAI3EVCS.js} +700 -78
  27. package/js/chunk-VCYWAA4N.js +49 -0
  28. package/js/{chunk-HDJH3RPR.js → chunk-YDW7DX3A.js} +4 -4
  29. package/js/chunk-YWVISRZD.js +268 -0
  30. package/js/{chunk-FW5HBOIK.js → chunk-ZKDXML77.js} +19272 -18299
  31. package/js/client.js +148 -100
  32. package/js/contracts.js +208 -24
  33. package/js/effect.js +18 -19
  34. package/js/es-DIULA3ZF.js +39371 -0
  35. package/js/graphql.js +62 -58
  36. package/js/host.js +83 -60
  37. package/js/index.js +381 -263
  38. package/js/mcp/effect.js +21 -21
  39. package/js/mcp.js +117 -74
  40. package/js/openapi.js +4613 -42691
  41. package/js/react.js +2 -3
  42. package/js/skills/effect.js +6 -4
  43. package/js/skills.js +233 -70
  44. package/js/storage/facet.js +1 -540
  45. package/js/ui/auth/contracts.js +8 -9
  46. package/js/ui/auth.js +16 -14
  47. package/js/ui/contracts.js +9 -8
  48. package/js/ui/serving.js +8609 -227
  49. package/package.json +3 -8
  50. package/runtime.json +1 -1
  51. package/types/app-cache/src/contracts/cache.d.ts +60 -2
  52. package/types/app-cache/src/index.d.ts +92 -2
  53. package/types/app-data/src/contracts/database.d.ts +33 -6
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +63 -17
  56. package/types/apps/src/contracts/cache.d.ts +24 -1
  57. package/types/apps/src/contracts/context.d.ts +60 -17
  58. package/types/apps/src/contracts/elicitation.d.ts +23 -7
  59. package/types/apps/src/contracts/events.d.ts +94 -0
  60. package/types/apps/src/contracts/failure.d.ts +54 -0
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +1325 -534
  63. package/types/apps/src/contracts/icons.d.ts +28 -0
  64. package/types/apps/src/contracts/live.d.ts +2 -0
  65. package/types/apps/src/contracts/mcp.d.ts +97 -20
  66. package/types/apps/src/contracts/network.d.ts +120 -0
  67. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  68. package/types/apps/src/contracts/openapi-document.d.ts +1 -1
  69. package/types/apps/src/contracts/openapi.d.ts +51 -9
  70. package/types/apps/src/contracts/operations.d.ts +14 -12
  71. package/types/apps/src/contracts/placement.d.ts +102 -0
  72. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  73. package/types/apps/src/contracts/protocols/1.d.ts +2241 -0
  74. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  75. package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
  76. package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
  77. package/types/apps/src/contracts/protocols/2.d.ts +711 -0
  78. package/types/apps/src/contracts/protocols/3.d.ts +776 -0
  79. package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
  80. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  81. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  82. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  83. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  84. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  85. package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
  86. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  87. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  88. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  89. package/types/apps/src/contracts/provider.d.ts +140 -10
  90. package/types/apps/src/contracts/router.d.ts +59 -0
  91. package/types/apps/src/contracts/schedules.d.ts +7 -1
  92. package/types/apps/src/contracts/schema.d.ts +21 -0
  93. package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
  94. package/types/apps/src/contracts/skills.d.ts +60 -14
  95. package/types/apps/src/contracts/sql.d.ts +63 -0
  96. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  97. package/types/apps/src/contracts/ui.d.ts +70 -30
  98. package/types/apps/src/contracts/webhooks.d.ts +24 -7
  99. package/types/apps/src/contracts/workflows.d.ts +89 -36
  100. package/types/apps/src/facet.d.ts +4 -5
  101. package/types/apps/src/graphql.d.ts +1 -3
  102. package/types/apps/src/host.d.ts +5 -0
  103. package/types/apps/src/implementation/account-router.d.ts +13 -0
  104. package/types/apps/src/implementation/app.d.ts +44 -16
  105. package/types/apps/src/implementation/authoring.d.ts +25 -5
  106. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  107. package/types/apps/src/implementation/cache.d.ts +32 -3
  108. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  109. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  110. package/types/apps/src/implementation/events.d.ts +64 -0
  111. package/types/apps/src/implementation/failure-detail.d.ts +48 -0
  112. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  113. package/types/apps/src/implementation/graphql.d.ts +4 -3
  114. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  115. package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
  116. package/types/apps/src/implementation/live.d.ts +2 -2
  117. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  118. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  119. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  120. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  121. package/types/apps/src/implementation/mcp.d.ts +52 -25
  122. package/types/apps/src/implementation/network.d.ts +16 -0
  123. package/types/apps/src/implementation/openapi-compile.d.ts +30 -8
  124. package/types/apps/src/implementation/openapi-document.d.ts +46 -21
  125. package/types/apps/src/implementation/openapi-names.d.ts +23 -0
  126. package/types/apps/src/implementation/openapi-request.d.ts +10 -3
  127. package/types/apps/src/implementation/openapi-source.d.ts +30 -8
  128. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  129. package/types/apps/src/implementation/operations.d.ts +84 -10
  130. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  131. package/types/apps/src/implementation/placement.d.ts +60 -0
  132. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  133. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  134. package/types/apps/src/implementation/provider.d.ts +26 -6
  135. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  136. package/types/apps/src/implementation/router-catalog.d.ts +227 -0
  137. package/types/apps/src/implementation/router.d.ts +78 -0
  138. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  139. package/types/apps/src/implementation/schedules.d.ts +39 -8
  140. package/types/apps/src/implementation/schema.d.ts +111 -15
  141. package/types/apps/src/implementation/skills.d.ts +18 -24
  142. package/types/apps/src/implementation/sql.d.ts +71 -0
  143. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  144. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  145. package/types/apps/src/implementation/ui-auth.d.ts +12 -6
  146. package/types/apps/src/implementation/ui-client.d.ts +3 -3
  147. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  148. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  149. package/types/apps/src/implementation/ui-serving.d.ts +31 -12
  150. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  151. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  152. package/types/apps/src/implementation/webhooks.d.ts +15 -6
  153. package/types/apps/src/implementation/workflow-context.d.ts +17 -5
  154. package/types/apps/src/implementation/workflows.d.ts +11 -4
  155. package/types/apps/src/index.d.ts +71 -21
  156. package/types/apps/src/mcp.d.ts +25 -5
  157. package/types/apps/src/openapi.d.ts +11 -6
  158. package/types/apps/src/react.d.ts +1 -1
  159. package/types/apps/src/skills.d.ts +13 -8
  160. package/types/apps/src/ui-auth.d.ts +2 -2
  161. package/types/apps/src/ui-serving.d.ts +1 -1
  162. package/types/telemetry/src/app-records.d.ts +42 -0
  163. package/types/telemetry/src/browser-operations.d.ts +7 -4
  164. package/types/telemetry/src/browser.d.ts +8 -3
  165. package/types/telemetry/src/config.d.ts +2 -2
  166. package/types/telemetry/src/index.d.ts +2 -1
  167. package/types/telemetry/src/layer.d.ts +10 -4
  168. package/types/telemetry/src/measurements.d.ts +1 -1
  169. package/types/telemetry/src/ownership.d.ts +60 -0
  170. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  171. package/types/telemetry/src/relay.d.ts +16 -6
  172. package/types/telemetry/src/span-attributes.d.ts +17 -1
  173. package/types/telemetry/src/transport.d.ts +8 -1
  174. package/types/utils/src/api-error.d.ts +55 -0
  175. package/types/utils/src/connection-failure.d.ts +33 -0
  176. package/types/utils/src/legacy-keys.d.ts +20 -0
  177. package/types/utils/src/recorded-message.d.ts +18 -0
  178. package/types/utils/src/schema-definitions.d.ts +13 -0
  179. package/types/utils/src/user-facing-error.d.ts +83 -0
  180. package/js/chunk-6IIO4NPI.js +0 -29
  181. package/js/chunk-6YBRWRK3.js +0 -160
  182. package/js/chunk-BMOIAIVR.js +0 -138
  183. package/js/chunk-FZJOYIZO.js +0 -19
  184. package/js/chunk-G7IE6BKC.js +0 -224
  185. package/js/chunk-IHQ4ML7K.js +0 -2193
  186. package/js/chunk-KOXMLKTM.js +0 -1288
  187. package/js/chunk-M6ZRRIBI.js +0 -877
  188. package/js/chunk-PLCMJREA.js +0 -590
  189. package/js/chunk-PZ36XMXW.js +0 -93
  190. package/js/chunk-RBAC33PQ.js +0 -267
  191. package/js/chunk-SATWJKN6.js +0 -34
  192. package/js/chunk-SWPD52J7.js +0 -35
  193. package/js/chunk-TE4KO4HI.js +0 -47
  194. package/js/chunk-W7D7WVSY.js +0 -18
  195. package/js/chunk-X7SFGU4Q.js +0 -280
  196. package/js/chunk-ZJWDMTE3.js +0 -63
  197. package/js/mcp/stdio.js +0 -128
  198. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  199. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  200. package/types/app-data/src/implementation/promise.d.ts +0 -68
  201. package/types/app-data/src/implementation/range.d.ts +0 -8
  202. package/types/app-data/src/implementation/schema.d.ts +0 -33
  203. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  204. package/types/app-data/src/index.d.ts +0 -4
  205. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  206. package/types/apps/src/contracts/storage.d.ts +0 -68
  207. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  208. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  209. package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
  210. package/types/apps/src/implementation/storage.d.ts +0 -13
  211. package/types/apps/src/mcp-stdio.d.ts +0 -8
@@ -0,0 +1,71 @@
1
+ /**
2
+ * `ctx.sql` over a data facet's SQLite storage, and the deploy-time migrator.
3
+ *
4
+ * Every statement runs inside a synchronous SQLite transaction: alone, or inside the author's
5
+ * `transaction`. Nothing here can wait on another call, so no lock or transaction outlives the
6
+ * statement that needs it. What a statement may do is decided by SQLite, not by reading the SQL:
7
+ * a query runs in a transaction that is always rolled back.
8
+ */
9
+ import { Effect, Schema } from "effect";
10
+ import { type AppSqlStorage, type Sql, type SqlReader } from "../contracts/sql.js";
11
+ import type { SkillFile } from "../contracts/skills.js";
12
+ export declare const noDatabase: Sql;
13
+ /** A workflow step mutation's identity, from the host's replay record. */
14
+ export interface StepReplay {
15
+ readonly key: string;
16
+ readonly fingerprint: string;
17
+ }
18
+ /**
19
+ * One invocation's SQL. Once the invocation ends or `signal` aborts, every statement is refused, so
20
+ * code still running after a timeout or cancellation cannot write late.
21
+ */
22
+ export declare const authorSql: (storage: AppSqlStorage, options: {
23
+ readonly signal: AbortSignal;
24
+ readonly step?: StepReplay;
25
+ /**
26
+ * The invocation's emitted events. A transaction that rolls back also discards the events its
27
+ * callback emitted, so subscribers never hear of writes that did not commit.
28
+ */
29
+ readonly emitted?: unknown[];
30
+ }) => {
31
+ reader: SqlReader;
32
+ writer: Sql;
33
+ close: () => void;
34
+ };
35
+ declare const MigrationFileInvalid_base: Schema.Class<MigrationFileInvalid, Schema.TaggedStruct<"MigrationFileInvalid", {
36
+ readonly path: Schema.String;
37
+ readonly reason: Schema.String;
38
+ }>, import("effect/Cause").YieldableError>;
39
+ /** A file in `migrations/` that is not a migration the host can order. */
40
+ export declare class MigrationFileInvalid extends MigrationFileInvalid_base {
41
+ get message(): string;
42
+ }
43
+ declare const MigrationHistoryChanged_base: Schema.Class<MigrationHistoryChanged, Schema.TaggedStruct<"MigrationHistoryChanged", {
44
+ readonly reason: Schema.String;
45
+ }>, import("effect/Cause").YieldableError>;
46
+ /** The build's migrations no longer start with the ones already applied to the database. */
47
+ export declare class MigrationHistoryChanged extends MigrationHistoryChanged_base {
48
+ get message(): string;
49
+ }
50
+ declare const MigrationFailed_base: Schema.Class<MigrationFailed, Schema.TaggedStruct<"MigrationFailed", {
51
+ readonly path: Schema.String;
52
+ readonly reason: Schema.String;
53
+ }>, import("effect/Cause").YieldableError>;
54
+ /** SQLite rejected a migration. Every migration of the deploy rolled back. */
55
+ export declare class MigrationFailed extends MigrationFailed_base {
56
+ get message(): string;
57
+ }
58
+ /** Whether a build's files give the app a database: any `.sql` file in `migrations/`. */
59
+ export declare const hasMigrations: (files: readonly {
60
+ readonly path: string;
61
+ }[]) => boolean;
62
+ /**
63
+ * Apply the build's pending migrations and report which ran. Every pending migration runs in one
64
+ * transaction, so a failing one leaves the database exactly as the active version knows it. The
65
+ * migrations already applied must still be the build's first ones, byte for byte.
66
+ */
67
+ export declare const migrate: (storage: AppSqlStorage, files: readonly SkillFile[]) => Effect.Effect<{
68
+ readonly id: number;
69
+ readonly name: string;
70
+ }[], MigrationFileInvalid | MigrationHistoryChanged | MigrationFailed, never>;
71
+ export {};
@@ -0,0 +1,28 @@
1
+ /** Swagger is most of the OpenAPI module's code. Discovery from a cached catalog never needs it,
2
+ * so a cold app Worker evaluates it only when it resolves a document or builds a request.
3
+ */
4
+ import "../contracts/swagger-client.ts";
5
+ export type SwaggerClient = typeof import("swagger-client").default;
6
+ export declare const loadSwaggerClient: () => Promise<{
7
+ buildRequest(options: {
8
+ spec: unknown;
9
+ operationId?: string;
10
+ pathName?: string;
11
+ method?: string;
12
+ parameters?: Readonly<Record<string, unknown>>;
13
+ requestBody?: unknown;
14
+ requestContentType?: string;
15
+ securities?: {
16
+ authorized: Readonly<Record<string, unknown>>;
17
+ };
18
+ }): unknown;
19
+ resolve(options: {
20
+ spec: unknown;
21
+ skipNormalization: boolean;
22
+ useCircularStructures: boolean;
23
+ requestInterceptor: () => never;
24
+ }): Promise<{
25
+ spec: unknown;
26
+ errors: readonly unknown[];
27
+ }>;
28
+ }>;
@@ -0,0 +1,9 @@
1
+ /** Host-rendered account notices; no authored app code or provider responses enter them. */
2
+ import type { UiAccountNotice, UiAccountProblem } from "../contracts/ui.js";
3
+ /** Missing, removed, incompatible, or rejected accounts stop the app; other failed checks are advisory. */
4
+ export declare const accountProblemBlocks: (problem: UiAccountProblem) => boolean;
5
+ export declare const accountProblemText: (problem: UiAccountProblem) => string;
6
+ /** Full page shown instead of the app while an account problem stops it from working. */
7
+ export declare const accountBlockedPage: (notice: UiAccountNotice) => string;
8
+ /** Inline card for advisory problems; the app still loads underneath. */
9
+ export declare const accountNoticeBootstrap: (notice: UiAccountNotice) => string;
@@ -1,5 +1,6 @@
1
- /** Trusted bootstrap documents run before authored UI and never contain product credentials. */
2
- import { HttpServerResponse } from "effect/unstable/http";
1
+ /** Host responses around app sign-in. They carry no script and never contain product credentials. */
2
+ import { HttpServerResponse } from "effect/http";
3
+ import { type AppSignInId } from "../contracts/ui-auth.js";
3
4
  /** Private app responses must not leak authentication URLs through caches or referrers. */
4
5
  export declare const appPrivateHeaders: {
5
6
  "cache-control": string;
@@ -7,7 +8,12 @@ export declare const appPrivateHeaders: {
7
8
  "x-content-type-options": string;
8
9
  "content-security-policy": string;
9
10
  };
10
- /** Serve only a fixed host script while authentication runs; the original URL remains available to that script. */
11
- export declare const appSignInPage: () => HttpServerResponse.HttpServerResponse;
12
- /** Preserve deep links, erase callback proofs before any request, and let the host set HttpOnly cookies. */
13
- export declare const appSignInScript: () => HttpServerResponse.HttpServerResponse;
11
+ /** Every sign-in hop is a server redirect, so the browser paints nothing until the app itself. */
12
+ export declare const appRedirect: (url: string) => HttpServerResponse.HttpServerResponse;
13
+ /**
14
+ * The callback URL carries the code in its query. It exists only as a redirect `Location`, never as
15
+ * a rendered document, and redeeming it also requires the attempt's HttpOnly cookie.
16
+ */
17
+ export declare const appSignInCallback: (origin: string, request: AppSignInId, code: string) => string;
18
+ /** A failed callback explains itself without script; reopening the app URL starts a new attempt. */
19
+ export declare const appSignInFailed: () => HttpServerResponse.HttpServerResponse;
@@ -1,7 +1,7 @@
1
- import { Atom } from "effect/unstable/reactivity";
1
+ import { AsyncResult, Atom } from "effect/reactivity";
2
2
  import { type OperationReference } from "../contracts/live.js";
3
3
  import { type Schema } from "./schema.js";
4
- /** A scoped page client. Host-injected context carries only the deployment, never credentials. */
4
+ /** A scoped page client. Host-injected context carries only the version, never credentials. */
5
5
  export declare const createAppClient: () => {
6
6
  /** Close this client when its page or embedding owner is removed. */
7
7
  dispose: () => Promise<void>;
@@ -12,5 +12,5 @@ export declare const createAppClient: () => {
12
12
  /** Create a callable mutation with optional withOptimisticUpdate projections over mounted queries. */
13
13
  mutation: <Input, Output>(reference: OperationReference<Input, Output, "mutation">, output: Schema<NoInfer<Output>, boolean>) => import("../client.js").AppMutation<Input, Output>;
14
14
  /** Share a live query across mounts and reconcile optimistic changes against fresh server reads. */
15
- queryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<Output, unknown>>;
15
+ queryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Atom.Atom<AsyncResult.AsyncResult<Output, unknown>>;
16
16
  };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Retained files sit at the version's asset root. Resolving path-relative resource URLs there,
3
+ * instead of with `<base>`, leaves the document base as the page URL for links, history and forms.
4
+ */
5
+ export declare const versionDocument: (html: string, version: string) => string;
@@ -1,2 +1,2 @@
1
1
  /** Inline host script: no app dependencies, credentials, or authored HTML enter its source. */
2
- export declare const appFailureBootstrap: string;
2
+ export declare const appFailureBootstrap = "<script>\"use strict\";(()=>{var M=()=>{let d,w=Date.now(),m=0,g=0,f=new Map,v=/^(?:chrome|moz|safari-web)-extension:/,A=new Set([\"ResizeObserver loop completed with undelivered notifications.\",\"ResizeObserver loop limit exceeded\"]),V=new Set([\"Error\",\"TypeError\",\"ReferenceError\",\"SyntaxError\",\"RangeError\",\"URIError\",\"EvalError\",\"AggregateError\"]),b=(e,t=0,i=0)=>{let r=[];if(!URL.canParse(e))return r;let a=new URL(e);return a.origin!==location.origin||!a.pathname.startsWith(\"/_executor/assets/\")||!a.pathname.endsWith(\".js\")||(r.push({key:\"code.file.path\",value:{stringValue:a.pathname}}),Number.isSafeInteger(t)&&t>0&&r.push({key:\"code.line.number\",value:{intValue:String(t)}}),Number.isSafeInteger(i)&&i>0&&r.push({key:\"code.column.number\",value:{intValue:String(i)}})),r},h=(e,t,i=[])=>{let r=Date.now();r-w>=6e4&&(w=r,m=0,f.clear());let a=`${e}:${t.slice(0,2e3)}`,x=f.get(a);if(x!==void 0&&r-x<1e3||m>=20){g++;return}f.set(a,r),m++,i.push({key:\"executor.ui.failure.suppressed\",value:{intValue:String(g)}}),g=0;let E=Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,\"0\")).join(\"\"),S=`${Date.now()}000000`,n,l=\"Sending error report\\u2026\",k=()=>{if(d?.open)return;let s=document.createElement(\"div\"),D=s.attachShadow({mode:\"open\"}),o=document.createElement(\"dialog\");d=o,o.setAttribute(\"aria-labelledby\",\"executor-failure-title\");let y=document.createElement(\"h2\");y.id=\"executor-failure-title\",y.textContent=e===\"script\"?\"This app could not load\":\"This app stopped working\";let C=document.createElement(\"p\");C.textContent=e===\"script\"?\"A file needed by this page did not load. Reload the page to try again.\":\"The app encountered an unexpected error. Reload the page to try again.\";let L=document.createElement(\"p\");L.textContent=\"Copy any unsaved work before reloading.\";let R=document.createElement(\"details\"),T=document.createElement(\"summary\");T.textContent=\"Error details\";let c=document.createElement(\"textarea\");c.readOnly=!0,c.rows=10,c.cols=36,c.setAttribute(\"aria-label\",\"Error details\"),c.value=`${t.slice(0,12e3)}\n\nDiagnostic ID: ${E}`,R.append(T,c),n=document.createElement(\"p\"),n.setAttribute(\"role\",\"status\"),n.textContent=l;let u=document.createElement(\"button\");u.type=\"button\",u.textContent=\"Reload page\",u.addEventListener(\"click\",()=>location.reload());let p=document.createElement(\"button\");p.type=\"button\",p.textContent=\"Close\",p.addEventListener(\"click\",()=>o.close()),o.addEventListener(\"close\",()=>{d===o&&(d=void 0),s.remove()}),o.append(y,C,L,R,n,u,p),D.append(o),document.documentElement.append(s),o.showModal()};document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",k,{once:!0}):k(),fetch(\"/_executor/api/telemetry/traces\",{method:\"POST\",headers:{\"content-type\":\"application/json\"},credentials:\"same-origin\",keepalive:!0,body:JSON.stringify({resourceSpans:[{scopeSpans:[{spans:[{traceId:E,spanId:E.slice(0,16),name:\"ui.app.failure\",kind:1,startTimeUnixNano:S,endTimeUnixNano:S,status:{code:2},attributes:[{key:\"executor.ui.failure.kind\",value:{stringValue:e}},...i]}]}]}]})}).then(s=>{l=s.ok?\"Error report sent.\":\"Could not send the error report. You can copy the error details.\",n&&(n.textContent=l)},()=>{l=\"Could not send the error report. You can copy the error details.\",n&&(n.textContent=l)})};window.addEventListener(\"error\",e=>{if(e instanceof ErrorEvent){if(v.test(e.filename)||e.error===null&&e.lineno===0&&A.has(e.message))return;let t=b(e.filename,e.lineno,e.colno);e.error instanceof Error&&V.has(e.error.name)&&t.push({key:\"exception.type\",value:{stringValue:e.error.name}}),h(\"runtime\",e.error instanceof Error?e.error.stack??e.message:e.message,t)}else e.target instanceof HTMLScriptElement&&h(\"script\",`Could not load script: ${e.target.src}`,b(e.target.src))},!0),window.addEventListener(\"unhandledrejection\",e=>{let t=e.reason;h(\"rejection\",t instanceof Error?t.stack??t.message:\"An app operation failed without handling its error.\")})};M();})();</script>";
@@ -1,16 +1,35 @@
1
- import { Effect } from "effect";
2
- import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
3
- import { UiForbidden, type AppUiAsset } from "../contracts/ui.js";
4
- /** Render an authorized deployment with a host-owned deployment watcher. */
1
+ import { Effect, Option, Stream } from "effect";
2
+ import { HttpServerRequest, HttpServerResponse } from "effect/http";
3
+ import { UiFailed, UiForbidden, type AppUiAsset, type AppUiRange, type AppUiStoredFile, type UiAccountNotice } from "../contracts/ui.js";
4
+ /**
5
+ * Render an authorized version with a host-owned version watcher. Account problems that stop
6
+ * the app replace its document with a page that links to their fix; others add a dismissible card.
7
+ */
5
8
  export declare const appDocument: <E, R>(options: {
6
- readonly deployment: string;
7
- readonly profile?: string | undefined;
8
- readonly expectedProfileRevision?: number | undefined;
9
+ readonly version: string;
10
+ /** The account IDs the page runs with, by requirement. */
11
+ readonly accountIds?: Readonly<Record<string, readonly string[]>> | undefined;
9
12
  readonly origin: string;
13
+ readonly accounts?: UiAccountNotice | undefined;
10
14
  readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
11
- }) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
12
- /** Revalidate immutable assets only after the host has checked current access and file existence.
13
- * Browsers may retain bytes, but neither browsers nor shared proxies may reuse them without authorization.
14
- * HTML remains an uncached host-rendered entry point.
15
+ }) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed | UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
16
+ /**
17
+ * A version's public file, read from the host's store. The version lists it, so bytes that
18
+ * are gone are a storage fault, never a missing page.
19
+ */
20
+ export declare const storedAppFile: <E1, E2>(stored: {
21
+ readonly contentType: string;
22
+ readonly size: number;
23
+ readonly etag: string;
24
+ }, read: (range: AppUiRange | undefined) => Effect.Effect<Option.Option<{
25
+ readonly body: Stream.Stream<Uint8Array, E1>;
26
+ }>, E2>) => AppUiStoredFile;
27
+ /** The file a URL path names: each segment percent-decoded, or none when one does not decode. */
28
+ export declare const assetPath: (path: string) => Option.Option<string>;
29
+ /** Serve an asset only after the host has checked current access and file existence.
30
+ * Asset URLs name their version, so their bytes never change: the browser keeps them for a year
31
+ * and does not ask again. Shared proxies never store them. Revoking access stops every new request
32
+ * and all app data, while bytes a browser already downloaded stay in its cache.
33
+ * HTML remains an uncached host-rendered entry point; other HTML files are served as they are.
15
34
  */
16
- export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>;
35
+ export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed, HttpServerRequest.HttpServerRequest>;
@@ -1,2 +1,2 @@
1
1
  /** Dependency-free browser source served by each host after app authorization. */
2
- export declare const appWatchScript: string;
2
+ export declare const appWatchScript = "\"use strict\";(()=>{var c=()=>{let s=document.getElementById(\"executor-context\")?.textContent;if(!s)return;let n=JSON.parse(s);if(typeof n!=\"object\"||n===null||!(\"version\"in n))return;let r=n.version;if(typeof r!=\"string\"||r.length===0)return;let t=new EventSource(\"/_executor/version\"),d=!1,o=()=>{d||(d=!0,t.close(),location.reload())};t.addEventListener(\"version\",i=>{let e=JSON.parse(i.data);typeof e==\"object\"&&e!==null&&\"version\"in e&&(e.version===null||typeof e.version==\"string\")&&e.version!==r&&o()}),t.addEventListener(\"revoked\",o),window.addEventListener(\"executor:deployment-changed\",o),window.addEventListener(\"pagehide\",()=>t.close(),{once:!0}),window.addEventListener(\"pageshow\",i=>{i.persisted&&o()})};c();})();";
@@ -0,0 +1,7 @@
1
+ import { UpstreamError } from "../contracts/failure.js";
2
+ /** Whether `bounded` shortened this message, so it may end partway through a secret. */
3
+ export declare const isShortenedUpstream: (message: string) => boolean;
4
+ /** The error a JSON error body states, if it uses a nested error object or OAuth's format. */
5
+ export declare const bodyUpstreamError: (json: unknown) => UpstreamError | undefined;
6
+ /** The `error` and `error_description` of a Bearer challenge (RFC 6750, section 3). */
7
+ export declare const challengeUpstreamError: (header: string | undefined) => UpstreamError | undefined;
@@ -1,13 +1,21 @@
1
1
  /** Native webhook dispatch. The author verifies signatures before parsing or performing side effects. */
2
2
  import { Effect, Schema } from "effect";
3
- import type { AppDefinition } from "../contracts/app.js";
4
- import { HostDeclarationInvalid, HostInputInvalid, HostOperationFailed, HostOperationNotFound, HostOutputInvalid, type ResolvedAccounts } from "../contracts/host.js";
3
+ import type { AppDefinition, ScopedSlots } from "../contracts/app.js";
4
+ import { HostDeclarationInvalid, HostInputInvalid, HostOperationFailed, HostOperationNotFound, HostAccountsInvalid, HostOutputInvalid } from "../contracts/host.js";
5
5
  import { type WebhookCommand } from "../contracts/webhook-protocol.js";
6
- /** Run one hook with freshly bound context. No credentials or raw failures enter the response envelope. */
6
+ type ScopeAccounts = {
7
+ readonly accounts: Readonly<Record<string, unknown>>;
8
+ };
9
+ /**
10
+ * Run one hook with freshly bound context. No credentials or raw failures enter the response
11
+ * envelope. An app-account hook runs without a caller: its context has no `user`, whatever the
12
+ * invocation bound.
13
+ */
7
14
  export declare const dispatchWebhook: <Context extends {
8
15
  readonly signal?: AbortSignal;
9
- readonly accounts: Readonly<Record<string, unknown>>;
10
- }>(definition: AppDefinition<Context>, command: WebhookCommand, context: Context, accounts: ResolvedAccounts) => Effect.Effect<Schema.Json | {
16
+ readonly app: ScopeAccounts;
17
+ readonly user?: ScopeAccounts;
18
+ }>(definition: AppDefinition<Context>, command: WebhookCommand, context: Context, slots: ScopedSlots) => Effect.Effect<Schema.Json | {
11
19
  readonly name: string;
12
20
  readonly account: string;
13
21
  readonly configSchema: {
@@ -26,4 +34,5 @@ export declare const dispatchWebhook: <Context extends {
26
34
  readonly [x: string]: string;
27
35
  };
28
36
  readonly body: string;
29
- }, HostDeclarationInvalid | HostOperationNotFound | HostOperationFailed | HostInputInvalid | HostOutputInvalid, never>;
37
+ }, HostDeclarationInvalid | HostAccountsInvalid | HostOperationNotFound | HostOperationFailed | HostInputInvalid | HostOutputInvalid, never>;
38
+ export {};
@@ -1,8 +1,20 @@
1
1
  /** Author-facing step methods delegate persistence to the host's durable engine. */
2
2
  import { Effect } from "effect";
3
- import type { AppDefinition } from "../contracts/app.js";
4
- import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext } from "../contracts/workflows.js";
5
- /** Preserve typed failures and cancellation; authored exception text never leaves the app. */
6
- export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>) => Effect.Effect<A, WorkflowFailure>;
3
+ import type { AccountScope, AppDefinition } from "../contracts/app.js";
4
+ import type { AppRequirements } from "../contracts/context.js";
5
+ import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext as AuthorStepContext } from "../contracts/workflows.js";
6
+ /** A step's context as the host builds it: a run without a caller has no `user`. */
7
+ type WorkflowStepContext = AuthorStepContext<AppRequirements, AccountScope> & Partial<Pick<AuthorStepContext, "user">>;
8
+ /**
9
+ * Preserve typed failures and cancellation. Other errors keep their name and bounded message,
10
+ * with the given account secrets replaced.
11
+ */
12
+ export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>, secrets: readonly string[]) => Effect.Effect<A, WorkflowFailure>;
7
13
  /** Construct one replay's Promise context. Step callbacks acquire fresh capabilities per actual attempt. */
8
- export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "queries" | "mutations">, fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<WorkflowStepContext, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
14
+ export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "tools">,
15
+ /** A step attempt's context, and the raw account secrets its failures must not reveal. */
16
+ fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
17
+ readonly context: WorkflowStepContext;
18
+ readonly secrets: readonly string[];
19
+ }, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
20
+ export {};
@@ -1,23 +1,30 @@
1
1
  /** Ordinary async workflow declarations, adapted once into native Effect handlers. */
2
- import { type Schema as EffectSchema } from "effect";
2
+ import type { Schema as EffectSchema } from "effect";
3
3
  import type { AppWorkflow, WorkflowContext } from "../contracts/workflows.js";
4
+ import type { AppRequirements } from "../contracts/context.js";
5
+ import type { AccountScope } from "../contracts/app.js";
4
6
  import { type Schema } from "./schema.js";
5
7
  declare const NativeWorkflow: unique symbol;
8
+ /**
9
+ * The context any workflow may declare: either scope, so a run started without a caller, such as
10
+ * by an app schedule, declares `WorkflowContext<typeof requirements, "app">`.
11
+ */
12
+ export type AnyWorkflowContext = WorkflowContext<AppRequirements, AccountScope>;
6
13
  declare const HandlerContext: unique symbol;
7
14
  /** A workflow declaration retains input/output inference and required context compatibility. */
8
- export interface Workflow<Input, Output, Context extends WorkflowContext = WorkflowContext> {
15
+ export interface Workflow<Input, Output, Context extends AnyWorkflowContext = WorkflowContext> {
9
16
  readonly [HandlerContext]?: (context: Context) => void;
10
17
  readonly [NativeWorkflow]: AppWorkflow<Input, Output>;
11
18
  }
12
19
  /** Composition view erases input only after retaining its runtime decoder. */
13
- export interface WorkflowDeclaration<Context extends WorkflowContext> {
20
+ export interface WorkflowDeclaration<Context extends AnyWorkflowContext> {
14
21
  readonly [HandlerContext]?: (context: Context) => void;
15
22
  readonly [NativeWorkflow]: Omit<AppWorkflow<never>, "input"> & {
16
23
  readonly input: EffectSchema.Decoder<unknown>;
17
24
  };
18
25
  }
19
26
  /** Declare durable orchestration without starting a run or performing I/O. */
20
- export declare const workflow: <Input, Output, Context extends WorkflowContext = WorkflowContext>(options: {
27
+ export declare const workflow: <Input, Output, Context extends AnyWorkflowContext = WorkflowContext>(options: {
21
28
  readonly input: Schema<Input, boolean>;
22
29
  readonly output?: Schema<Output, boolean>;
23
30
  readonly description?: string;
@@ -1,4 +1,5 @@
1
1
  export { ProviderError } from "./contracts/provider-error.js";
2
+ export { FetchOptionUnsupported, NetworkRefused } from "./contracts/network.js";
2
3
  export type { AppCache, CacheLoadContext, CacheGetOptions } from "./contracts/cache.js";
3
4
  export { CacheError } from "../../app-cache/src/contracts/cache.js";
4
5
  /**
@@ -6,48 +7,92 @@ export { CacheError } from "../../app-cache/src/contracts/cache.js";
6
7
  * exposes ordinary declarations, schema helpers and Promise operations.
7
8
  */
8
9
  import { type Schema as EffectSchema } from "effect";
9
- import type { WebhookContext } from "./contracts/context.js";
10
+ import type { AppRequirements, WebhookContext } from "./contracts/context.js";
11
+ import type { AccountScope } from "./contracts/app.js";
10
12
  import { type JsonResponse as NativeResponse } from "./contracts/http.js";
11
- import { type OAuth2Config, type OAuth2Method as NativeOAuth2Method, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
13
+ import { type OAuth2Config as NativeOAuth2Config, type OAuth2Method as NativeOAuth2Method, type ReservedAuthorizationParam, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
12
14
  import type { Webhook as NativeWebhook } from "./contracts/webhooks.js";
13
15
  import { type PromiseMethods } from "./implementation/authoring.js";
14
- import { type Fields, type Infer, type ObjectSchema, type Schema } from "./implementation/schema.js";
15
- export { type JsonObject, type JsonValue, ValidationError } from "./contracts/schema.js";
16
- export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, } from "./implementation/schema.js";
17
- export { type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type OAuth2Config, type Provider, } from "./contracts/provider.js";
18
- export { defineProvider } from "./implementation/provider.js";
19
- export { accountOperations } from "./implementation/account-operations.js";
20
- export { dynamicTools } from "./implementation/dynamic-tools.js";
16
+ import { type PlacementInput, type RequestPlacements } from "./implementation/placement.js";
17
+ import type { Placement } from "./contracts/placement.js";
18
+ import type { QueryContext as NativeQueryContext } from "./contracts/context.js";
19
+ import { query as operationQuery, type AnyContext, type OperationOptions } from "./implementation/operations.js";
20
+ import { type Fields, type Infer, type ObjectSchema, type Schema, type SecretFields, type SecretObject } from "./implementation/schema.js";
21
+ export { DeclarationInvalid, type DeclarationIssue, type JsonObject, type JsonValue, ValidationError, } from "./contracts/schema.js";
22
+ export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, plain, raw, type SecretString, } from "./implementation/schema.js";
23
+ export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type Provider, type ReservedAuthorizationParam, } from "./contracts/provider.js";
24
+ export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
25
+ export { base64, basic, bearer, header, t, type FieldRef, type FieldRefs, type PlacementInput, type PlacementValue, type RequestPlacements, } from "./implementation/placement.js";
26
+ export type { Placement };
27
+ export type { AccountRequest } from "./contracts/provider.js";
28
+ export { accountRouter } from "./implementation/account-router.js";
29
+ export { router, dynamicRouter, withApprovals, renameTools, type OperationChild, type OperationDeclaration, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
30
+ export type { RouterIcon } from "./contracts/router.js";
31
+ export type { AppIcon } from "./contracts/icons.js";
21
32
  export { dynamicSkills } from "./implementation/dynamic-skills.js";
22
33
  export type { HostedTool as OperationDescription } from "./contracts/host.js";
34
+ /** Account fields as app code receives them from a method declared with this schema. */
35
+ type AccountFields<S> = S extends ObjectSchema<infer F> ? SecretFields<F> : SecretObject<Infer<S>>;
23
36
  /** A secrets declaration inferred from an author schema. */
24
- export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<Infer<Shape>>>;
37
+ export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<AccountFields<Shape>>>;
25
38
  /** An OAuth declaration inferred from its author-facing response schema. */
26
- export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<Infer<Response>>>;
39
+ export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<AccountFields<Response>>>;
40
+ /** The names of an object schema's fields, which a method's `request` can reference. */
41
+ type FieldNameOf<S> = S extends ObjectSchema<infer F> ? keyof F & string : never;
27
42
  /** Default OAuth fields visible to app code. Host-only grants and clients stay private. */
28
43
  export declare const OAuth2AccessToken: Schema<{
29
44
  readonly access_token: string;
30
45
  }, false>;
31
- /** Declare a secrets method without requiring an Effect schema from the author. */
46
+ /**
47
+ * OAuth options as authors write them. `authorizationParams` naming a host-owned protocol
48
+ * parameter such as `state` or `scope` is a type error as well as a declaration failure.
49
+ */
50
+ export type OAuth2Config = WithoutReservedParams<NativeOAuth2Config>;
51
+ type WithoutReservedParams<Config> = Config extends unknown ? "authorizationParams" extends keyof Config ? Config & {
52
+ readonly authorizationParams?: {
53
+ readonly [Key in ReservedAuthorizationParam]?: never;
54
+ };
55
+ } : Config : never;
56
+ /**
57
+ * Declare a secrets method without requiring an Effect schema from the author. `request` says
58
+ * where its secret fields may be sent, such as `({ token }) => bearer(token)`; it runs once, here.
59
+ */
32
60
  export declare const secrets: <const F extends Fields>(options: {
33
61
  readonly label: string;
34
62
  readonly fields: ObjectSchema<F>;
63
+ readonly request?: RequestPlacements<keyof F & string>;
35
64
  }) => SecretsMethod<ObjectSchema<F>>;
36
- /** Declare OAuth discovery/endpoints and an optional app-visible response projection. */
37
- export declare function oauth2(options: OAuth2Config): OAuth2Method<typeof OAuth2AccessToken>;
65
+ /**
66
+ * Declare OAuth discovery/endpoints and an optional app-visible response projection.
67
+ * `authorizationParams` adds service-defined sign-in parameters; a declared `authorizationUrl`
68
+ * keeps its own query. Neither can set host-owned parameters, and each parameter appears once.
69
+ * `request` says where the projected secret fields may be sent, such as
70
+ * `({ access_token }) => bearer(access_token)`; it runs once, here.
71
+ */
72
+ export declare function oauth2(options: OAuth2Config & {
73
+ readonly request?: RequestPlacements<"access_token">;
74
+ }): OAuth2Method<typeof OAuth2AccessToken>;
38
75
  export declare function oauth2<Response extends Schema<unknown, boolean>>(options: OAuth2Config & {
39
76
  readonly response: Response;
77
+ readonly request?: RequestPlacements<FieldNameOf<Response>>;
40
78
  }): OAuth2Method<Response>;
41
- export type { AccountSlots } from "./contracts/app.js";
42
- export type { AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
79
+ export type { AccountScope, AccountSlots, WebhookAccount } from "./contracts/app.js";
80
+ export type { AnyScopeMutationContext, AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
43
81
  export { type App, type AppDefinition, defineApp } from "./implementation/app.js";
82
+ export { event, type EventDeclaration, type EventEmitter } from "./implementation/events.js";
83
+ export type { EmitOptions } from "./contracts/events.js";
44
84
  export type { Approval, ApprovalContext, ApprovalDecision } from "./approval.js";
45
85
  type AuthorWebhook<Member, Config, State> = Member extends object ? Omit<PromiseMethods<Member>, "config" | "state"> & {
46
86
  readonly config: Config;
47
87
  readonly state: State;
48
88
  } : never;
49
89
  /** Author lifecycle methods use async functions and share native decoded context/state types. */
50
- export type Webhook<Context extends WebhookContext, Config extends Schema<unknown, boolean>, State extends Schema<unknown, boolean>> = AuthorWebhook<NativeWebhook<Context, EffectSchema.Decoder<Infer<Config>>, EffectSchema.Decoder<Infer<State>>>, Config, State>;
90
+ /**
91
+ * A webhook's context names its source account's scope: one with `user` serves a user requirement
92
+ * (`account: { user: "x" }`), one of the `"app"` scope an app requirement (`account: { app: "x" }`)
93
+ * and runs without a caller.
94
+ */
95
+ export type Webhook<Context extends WebhookContext<AppRequirements, AccountScope>, Config extends Schema<unknown, boolean>, State extends Schema<unknown, boolean>> = AuthorWebhook<NativeWebhook<Context, EffectSchema.Decoder<Infer<Config>>, EffectSchema.Decoder<Infer<State>>>, Config, State>;
51
96
  export { ResponseDecodeError, ResponseStatusError } from "./contracts/http.js";
52
97
  /** Native fetch-compatible response accepted at the author boundary. */
53
98
  export type JsonResponse = PromiseMethods<NativeResponse>;
@@ -55,11 +100,16 @@ export type JsonResponse = PromiseMethods<NativeResponse>;
55
100
  export declare const decodeJson: <T>(response: JsonResponse, schema: Schema<T, boolean>) => Promise<T>;
56
101
  export { NotImplemented } from "./contracts/app.js";
57
102
  export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
58
- export { table, defineDatabase, type Table, type DatabaseReader, type Database, type DatabaseDefinition, } from "./implementation/storage.js";
59
- export { id, userId } from "./implementation/schema.js";
60
- export { query, mutation, withApproval, type Operation, type OperationOptions, } from "./implementation/operations.js";
103
+ export type { Sql, SqlCursor, SqlReader, SqlRow, SqlTransaction, SqlValue, } from "./contracts/sql.js";
104
+ /**
105
+ * `query(options, run)` declares a read operation. `query(name, value)` inside a method's
106
+ * `request` places a credential in a query parameter, such as `query("key", key)`.
107
+ */
108
+ export declare function query(name: string, value: PlacementInput): Placement;
109
+ export declare function query<Input, Output, Context extends AnyContext = NativeQueryContext>(options: OperationOptions<Input, Output>, run: (context: Context, input: Input) => Promise<Output>): ReturnType<typeof operationQuery<Input, Output, Context>>;
110
+ export { mutation, withApproval, toolAnnotations, type Approved, type Operation, type OperationOptions, } from "./implementation/operations.js";
61
111
  export type { OperationContext } from "./contracts/operations.js";
62
112
  export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
63
113
  export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";
64
- export { interval, cron, type ScheduleDeclaration } from "./implementation/schedules.js";
114
+ export { appCron, appInterval, userCron, userInterval, type ScheduleDeclaration, } from "./implementation/schedules.js";
65
115
  export type { AppSkillSource as Skill, SkillFile } from "./contracts/skills.js";
@@ -1,10 +1,30 @@
1
1
  /** HTTP MCP helpers. Requires the optional @modelcontextprotocol/sdk peer. */
2
2
  import type { OperationKinds } from "./implementation/protocol-operations.js";
3
+ import type { McpHealthOptions } from "./contracts/mcp.js";
4
+ import type { AccountCheckContext, AuthMethods } from "./contracts/provider.js";
3
5
  import { type McpCatalogOptions } from "./implementation/mcp-catalog.js";
4
6
  export type { McpCatalogOptions } from "./implementation/mcp-catalog.js";
5
- export { McpError, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
6
- /** Discover operations for the selected account. Kinds override uncertain upstream read-only hints. */
7
- export declare const mcpOperations: (options: McpCatalogOptions, kinds?: OperationKinds) => Promise<{
8
- dynamicTools: import("./contracts/dynamic-tools.js").DynamicTools;
9
- }>;
7
+ export { McpCredentialsUnverified, McpError, type McpHealthOptions, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
8
+ /**
9
+ * A router over a server's tools for the selected account. Its title, description and
10
+ * instructions come from the server. Kinds override uncertain upstream read-only hints.
11
+ */
12
+ export declare const mcpRouter: (options: McpCatalogOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
13
+ /**
14
+ * A provider `health` check for an MCP server. Pass the check context `health` receives, then the
15
+ * server's `url` and the `headers` that send the account's credentials:
16
+ * `health: (check) => mcpHealth(check, { url, headers: headers(check.account) })`.
17
+ *
18
+ * It connects with those headers, initializes, and reads the first page of tools, then does the
19
+ * same without any headers. No tool runs. The check passes only when the server accepts the account
20
+ * and refuses the attempt without credentials. A refused account throws `ProviderError`, as HTTP
21
+ * helpers do. An unreachable or unusable server throws `McpError`, and a request Executor's network
22
+ * refuses throws `NetworkRefused`. A server that also answers without credentials, or whose answer
23
+ * to that attempt is not a refusal, throws `McpCredentialsUnverified`. Each of these errors means
24
+ * the check could not verify the account, and the account form explains why. Send credentials only
25
+ * in `headers`; the attempt without them uses the same `url`. The check context's `signal` cancels
26
+ * both attempts, and they share one budget that ends early enough before its `deadline` to report a
27
+ * server that did not answer in time. `timeoutMs` can only shorten that budget.
28
+ */
29
+ export declare const mcpHealth: <Auth extends AuthMethods>(check: AccountCheckContext<Auth>, options: McpHealthOptions) => Promise<void>;
10
30
  export type { OperationKinds } from "./implementation/protocol-operations.js";
@@ -2,11 +2,16 @@
2
2
  import { type OperationKinds } from "./implementation/protocol-operations.js";
3
3
  import type { OpenapiToolsOptions } from "./contracts/openapi.js";
4
4
  export { OpenapiError, isOpenapiTextMedia, openapiBinaryResultSchema, OpenapiErrorResponse, type OpenapiToolsOptions, type OpenapiOperation, type CredentialBinding, OpenapiParameter, OpenapiRequestBody, openapiMediaKind, } from "./contracts/openapi.js";
5
- /** Discover operations for the selected account. Kinds override uncertain upstream read-only hints. */
6
- export declare const openapiOperations: (options: OpenapiToolsOptions, kinds?: OperationKinds) => Promise<{
7
- queries: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "query", import("./index.js").OperationContext>>;
8
- mutations: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "mutation", import("./index.js").OperationContext>>;
9
- }>;
5
+ /**
6
+ * Discover a document's operations as a router for the selected account. Kinds override uncertain
7
+ * upstream read-only hints. Mount it under a key, or override its metadata with `router(...)`.
8
+ */
9
+ export declare const openapiRouter: (options: OpenapiToolsOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
10
10
  export type { OperationKinds } from "./implementation/protocol-operations.js";
11
11
  export * from "./contracts/openapi-compile.js";
12
- export { liveOpenapiOperations, type OpenapiSourceOptions, } from "./implementation/openapi-source.js";
12
+ /**
13
+ * The names `liveOpenapiRouter` gives a document's operations, from each operation's
14
+ * operationId, first tag, method and path alone. It reads no document and compiles nothing.
15
+ */
16
+ export { planOperationNames, type OperationNameInput } from "./implementation/openapi-names.js";
17
+ export { liveOpenapiRouter, openapiToolNames, type OpenapiSourceOptions, type OpenapiToolNamesOptions, } from "./implementation/openapi-source.js";
@@ -1,4 +1,4 @@
1
- import { AsyncResult, type Atom } from "effect/unstable/reactivity";
1
+ import { AsyncResult, type Atom } from "effect/reactivity";
2
2
  /** Subscribe for the component lifetime. Each mount owns and disposes its registry, including StrictMode remounts. */
3
3
  export declare const useAppQuery: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>) => {
4
4
  data: A | undefined;