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
@@ -1,5 +1,6 @@
1
1
  /** Portable Agent Skills returned by an app factory or loaded from published files. */
2
2
  import { Schema } from "effect";
3
+ import { ApiError } from "../../../utils/src/api-error.js";
3
4
  /** Canonical resource path within one skill. */
4
5
  export declare const SkillFilePath: Schema.NonEmptyString;
5
6
  /** UTF-8 text resource. Reading a resource never executes it. */
@@ -40,13 +41,25 @@ export declare const AppSkillSource: Schema.Struct<{
40
41
  readonly "allowed-tools": Schema.optionalKey<Schema.String>;
41
42
  }>;
42
43
  export type AppSkillSource = typeof AppSkillSource.Type;
43
- declare const SkillDefinitionInvalid_base: Schema.Class<SkillDefinitionInvalid, Schema.TaggedStruct<"SkillDefinitionInvalid", {
44
+ /** Invalid selected skill files fail the load. Errors identify the file without disclosing its contents. */
45
+ export declare const SkillDefinitionInvalid: Schema.Class<{
46
+ readonly file: string;
47
+ readonly reason: "metadata" | "files" | "directory" | "missing-document" | "frontmatter" | "name-mismatch";
48
+ } & ApiError & {
49
+ readonly _tag: "SkillDefinitionInvalid";
50
+ }, Omit<Schema.TaggedStruct<"SkillDefinitionInvalid", {
44
51
  readonly file: Schema.NonEmptyString;
45
52
  readonly reason: Schema.Literals<readonly ["files", "directory", "missing-document", "frontmatter", "metadata", "name-mismatch"]>;
46
- }>, import("effect/Cause").YieldableError>;
47
- /** Invalid selected skill files fail the load. Errors identify the file without disclosing its contents. */
48
- export declare class SkillDefinitionInvalid extends SkillDefinitionInvalid_base {
49
- }
53
+ } & {
54
+ readonly message: typeof import("../../../utils/src/api-error.js").MessageField;
55
+ }>, "~type.make.in"> & {
56
+ readonly "~type.make.in": {
57
+ readonly reason: "metadata" | "files" | "directory" | "missing-document" | "frontmatter" | "name-mismatch";
58
+ readonly file: string;
59
+ readonly _tag?: "SkillDefinitionInvalid";
60
+ };
61
+ }, ApiError>;
62
+ export type SkillDefinitionInvalid = typeof SkillDefinitionInvalid.Type;
50
63
  /** One evaluated catalog cannot contain ambiguous names. */
51
64
  export declare const AppSkills: Schema.$Array<Schema.Struct<{
52
65
  readonly files: Schema.$Array<Schema.Struct<{
@@ -66,11 +79,16 @@ declare const SkillLoadFailed_base: Schema.Class<SkillLoadFailed, Schema.TaggedS
66
79
  readonly reason: Schema.Literals<readonly ["source", "request", "rate_limited", "document", "limit", "changed", "encoding"]>;
67
80
  readonly message: Schema.optional<Schema.String>;
68
81
  readonly status: Schema.optional<Schema.Int>;
82
+ readonly missing: Schema.optional<Schema.Literals<readonly ["repository", "ref"]>>;
69
83
  }>, import("effect/Cause").YieldableError>;
70
84
  /**
71
85
  * A skill loader failure shown to people. `message` is the explanation they read; write it for
72
86
  * them and never include URLs, tokens or response bodies. `reason` selects the title and whether
73
87
  * a retry can help. Custom loaders throw this error to get the same presentation as built-ins.
88
+ * With `source`, `missing` names what the service's answer points to as missing: the `repository`,
89
+ * or the branch or tag (`ref`). It may be missing, or not readable with the request's credentials.
90
+ * Without it, the source's settings or the paths it lists are not valid.
91
+ * These fields choose the explanation; they never show that the failure lies outside Executor.
74
92
  */
75
93
  export declare class SkillLoadFailed extends SkillLoadFailed_base {
76
94
  }
@@ -80,6 +98,8 @@ export declare const skillLoadLimits: {
80
98
  readonly fileBytes: 2000000;
81
99
  readonly totalBytes: 20000000;
82
100
  readonly concurrency: 8;
101
+ /** The request that checks whether a kept catalog's publication changed. */
102
+ readonly checkMillis: 5000;
83
103
  };
84
104
  /** Invocation-owned transport and cancellation, supplied by the app context. */
85
105
  export interface SkillTransport {
@@ -90,19 +110,45 @@ export interface SkillTransport {
90
110
  export interface SkillReaderOptions extends SkillTransport {
91
111
  readonly service: string;
92
112
  }
93
- /** A public GitHub repository and an optional immutable commit, tag or branch. */
94
- export interface GitHubSkillsOptions extends SkillTransport {
95
- readonly repo: string;
96
- readonly path?: string;
97
- readonly ref?: string;
113
+ /**
114
+ * Catalog reuse shared by remote skill loaders. Pass `ctx.cache` to keep the loaded catalog;
115
+ * without it every read fetches the source again. Unlike an MCP tool catalog, a skill catalog
116
+ * past `freshFor` is not served while it refreshes: the read first asks the source whether its
117
+ * publication changed, so agents never read skills that a refresh replaces moments later.
118
+ */
119
+ export interface SkillCacheOptions {
120
+ readonly cache?: import("./cache.js").AppCache;
121
+ /** Reuse the catalog without asking the source for this duration. Defaults to five minutes. */
122
+ readonly freshFor?: import("effect").Duration.Input;
98
123
  /**
99
- * Pass `ctx.cache` to keep each commit's skill file list. Content at a commit never changes,
100
- * so later reads of the same commit skip the tree fetch. The ref is still resolved each read.
124
+ * Keep the catalog this long after `freshFor`. A read then confirms it with one request and
125
+ * loads the files again only when the publication changed. Defaults to one day.
101
126
  */
102
- readonly cache?: import("./cache.js").AppCache;
127
+ readonly staleFor?: import("effect").Duration.Input;
103
128
  }
129
+ /**
130
+ * Whose access reads the repository. A public repository needs neither field. A private one takes
131
+ * a GitHub account and its token, sent on every request of this read. The token comes only with
132
+ * its account, so the catalog is cached in that account's scope and failures name the account.
133
+ */
134
+ export type GitHubSkillsAccount = import("./cache.js").AccountCredential<{
135
+ /**
136
+ * The account's token or its handle, such as `account.fields.token`. Its provider declares
137
+ * hosts `github.com` and `raw.githubusercontent.com`, so app code never holds the value.
138
+ */
139
+ readonly token: string;
140
+ }>;
141
+ /**
142
+ * A GitHub repository and an optional immutable commit, tag or branch. With a cache, a branch or
143
+ * tag is resolved again once the catalog is past `freshFor`, and each commit's file list is kept.
144
+ */
145
+ export type GitHubSkillsOptions = SkillTransport & SkillCacheOptions & GitHubSkillsAccount & {
146
+ readonly repo: string;
147
+ readonly path?: string;
148
+ readonly ref?: string;
149
+ };
104
150
  /** A published directory index, including its listed skill documents and text references. */
105
- export interface WellKnownSkillsOptions extends SkillTransport {
151
+ export interface WellKnownSkillsOptions extends SkillTransport, SkillCacheOptions {
106
152
  readonly url: string;
107
153
  }
108
154
  /** A folder in the deployed package; omitted path selects skills/. No host filesystem access. */
@@ -0,0 +1,63 @@
1
+ /**
2
+ * App-owned SQLite. An app with migrations in `migrations/` reads and writes its own database with
3
+ * plain SQL. The author API mirrors Cloudflare's `SqlStorage`, so tools built for Durable Object
4
+ * SQLite fit it.
5
+ */
6
+ /** A value SQLite stores or returns. */
7
+ export type SqlValue = string | number | null | ArrayBuffer;
8
+ /** One result row, keyed by column name. */
9
+ export type SqlRow = Record<string, SqlValue>;
10
+ /** The rows of one statement, already read, and what the statement read and wrote. */
11
+ export interface SqlCursor<Row extends SqlRow = SqlRow> extends Iterable<Row> {
12
+ readonly columnNames: readonly string[];
13
+ readonly rowsRead: number;
14
+ readonly rowsWritten: number;
15
+ toArray(): Row[];
16
+ /** The only row. Throws unless the statement returned exactly one. */
17
+ one(): Row;
18
+ }
19
+ /**
20
+ * Read-only SQL. Query tools receive this. A query runs in a transaction that is always rolled
21
+ * back, so nothing it changes commits; one that changes rows fails.
22
+ */
23
+ export interface SqlReader {
24
+ exec<Row extends SqlRow = SqlRow>(query: string, ...bindings: SqlValue[]): SqlCursor<Row>;
25
+ }
26
+ /** SQL inside one transaction. */
27
+ export type SqlTransaction = SqlReader;
28
+ /**
29
+ * Writable SQL. Outside a transaction every statement commits on its own. `transaction` runs its
30
+ * callback synchronously in one SQLite transaction, so no transaction can stay open while the app
31
+ * waits on anything else; throwing rolls it back. Apps call outside services between transactions.
32
+ */
33
+ export interface Sql extends SqlReader {
34
+ transaction<T>(work: (tx: SqlTransaction) => Synchronous<T>): T;
35
+ }
36
+ /** A transaction callback's result: a Promise means the callback awaited, which is refused. */
37
+ export type Synchronous<T> = T extends PromiseLike<unknown> ? never : T;
38
+ /** The Durable Object storage a data facet hands its app. App code never receives it. */
39
+ export interface AppSqlStorage {
40
+ readonly sql: {
41
+ exec(query: string, ...bindings: SqlValue[]): {
42
+ readonly columnNames: string[];
43
+ readonly rowsRead: number;
44
+ readonly rowsWritten: number;
45
+ toArray(): Record<string, SqlValue>[];
46
+ };
47
+ };
48
+ transactionSync<T>(work: () => T): T;
49
+ }
50
+ /**
51
+ * Tables Executor keeps in an app's database: applied migrations, workflow step receipts, and
52
+ * `_executor_legacy_rows (table_name, id, body)`, the rows of the document API apps used before
53
+ * SQL, with JSON bodies (empty for apps that never stored any). Apps should only read them; a
54
+ * changed migration history fails the next deploy.
55
+ */
56
+ export declare const reservedTablePrefix = "_executor_";
57
+ /** Where an app keeps its migrations: `0001_create_notes.sql`, applied in number order. */
58
+ export declare const migrationsDirectory = "migrations";
59
+ /**
60
+ * The most values one statement may bind. Durable Object SQLite sets `SQLITE_LIMIT_VARIABLE_NUMBER`
61
+ * to 100 on every host; `ctx.sql` checks it first so the error names the limit.
62
+ */
63
+ export declare const sqlBindingsLimit = 100;
@@ -1,7 +1,5 @@
1
1
  /** Browser authentication protocol. Identity and session storage belong to the host. */
2
2
  import { Schema } from "effect";
3
- import { HttpApi, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
4
- import { UiFailed, UiForbidden, UiUnauthorized } from "./ui.js";
5
3
  /** Opaque correlation ID; possession alone does not authorize an app session. */
6
4
  export declare const AppSignInId: Schema.brand<Schema.String, "AppSignInId">;
7
5
  export type AppSignInId = typeof AppSignInId.Type;
@@ -10,19 +8,13 @@ export declare const AppSignInCode: Schema.RedactedFromValue<Schema.String>;
10
8
  /** A path on the current app origin, including its query and fragment; never a redirect to another host or host-owned route. */
11
9
  export declare const AppReturnPath: Schema.brand<Schema.String, "AppReturnPath">;
12
10
  export type AppReturnPath = typeof AppReturnPath.Type;
13
- /** The trusted callback exchanges an authorization code bound to a browser attempt. */
11
+ /** Callback query on the app origin. The code is single-use and works only with its attempt's cookie. */
14
12
  export declare const AppSignInCallback: Schema.Struct<{
15
13
  readonly request: Schema.brand<Schema.String, "AppSignInId">;
16
14
  readonly code: Schema.RedactedFromValue<Schema.String>;
17
15
  }>;
18
- /** Host-owned endpoints on every app origin, independent of the product's login mechanism. */
19
- export declare const AppSignInApi: HttpApi.HttpApi<"app-sign-in", HttpApiGroup.HttpApiGroup<"appSignIn", HttpApiEndpoint.HttpApiEndpoint<"start", "POST", "/_executor/auth/start", never, never, Schema.toCodecJson<Schema.Struct<{
20
- readonly returnTo: Schema.brand<Schema.String, "AppReturnPath">;
21
- }>>, never, Schema.toCodecJson<Schema.Struct<{
22
- readonly url: Schema.String;
23
- }>>, Schema.toCodecJson<typeof UiForbidden | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"complete", "POST", "/_executor/auth/complete", never, never, Schema.toCodecJson<Schema.Struct<{
24
- readonly request: Schema.brand<Schema.String, "AppSignInId">;
25
- readonly code: Schema.RedactedFromValue<Schema.String>;
26
- }>>, never, Schema.toCodecJson<Schema.Struct<{
27
- readonly returnTo: Schema.brand<Schema.String, "AppReturnPath">;
28
- }>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiFailed>, never, never>, false>>;
16
+ /** Host-owned callback path on every app origin. */
17
+ export declare const appSignInCallbackPath = "/_executor/auth/callback";
18
+ /** Why the product could not authorize an attempt; the dashboard explains it without retrying. */
19
+ export declare const AppSignInFailure: Schema.Literals<readonly ["ended", "forbidden", "unavailable"]>;
20
+ export type AppSignInFailure = typeof AppSignInFailure.Type;
@@ -1,24 +1,58 @@
1
1
  /** Browser-to-host operations bind identity and authentication outside authored app code. */
2
- import { Schema } from "effect";
3
- import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
4
- /** Non-secret page context injected by the serving host. */
5
- export declare const UiContext: Schema.Struct<{
6
- readonly deployment: Schema.NonEmptyString;
7
- readonly profile: Schema.optional<Schema.NonEmptyString>;
8
- readonly expectedProfileRevision: Schema.optional<Schema.Int>;
2
+ import { Schema, type Effect, type Stream } from "effect";
3
+ import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
4
+ import { withLegacyKeys } from "../../../utils/src/legacy-keys.js";
5
+ export declare const UiContext: withLegacyKeys<Schema.Struct<{
6
+ readonly version: Schema.NonEmptyString;
7
+ readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
8
+ }>, {
9
+ readonly version: "deployment";
9
10
  }>;
11
+ /** A problem with one of the page's accounts, from stored state. Labels are the owner's own names. */
12
+ export type UiAccountProblem = {
13
+ readonly provider: string;
14
+ readonly reason: "missing" | "removed" | "incompatible";
15
+ } | {
16
+ readonly provider: string;
17
+ readonly account: string;
18
+ readonly reason: "credentials_rejected" | "forbidden" | "upstream_unavailable" | "check_failed";
19
+ };
20
+ /** Account problems found when the page opened, with dashboard links that resolve them. */
21
+ export interface UiAccountNotice {
22
+ readonly app: string;
23
+ readonly problems: readonly UiAccountProblem[];
24
+ /** The app's accounts in the dashboard. */
25
+ readonly fix: string;
26
+ }
10
27
  /** Retained browser bytes. Hosts authorize access before reading or rendering them. */
11
- export interface AppUiAsset {
28
+ export interface AppUiFile {
12
29
  readonly body: Uint8Array;
13
30
  readonly contentType: string;
14
31
  }
15
- /** Requests name an operation on this app and the page's deployment, never another app or account. */
16
- export declare const UiOperation: Schema.Struct<{
32
+ /** One byte range of a stored file, already within its size. */
33
+ export interface AppUiRange {
34
+ readonly offset: number;
35
+ readonly length: number;
36
+ }
37
+ /**
38
+ * A public file the version's source served from `ui/public/`, which the host copied to its
39
+ * own store. `etag` names its exact bytes. Hosts authorize access before reading it.
40
+ */
41
+ export interface AppUiStoredFile {
42
+ readonly contentType: string;
43
+ readonly size: number;
44
+ readonly etag: string;
45
+ readonly read: (range: AppUiRange | undefined) => Effect.Effect<Stream.Stream<Uint8Array, UiFailed>, UiFailed>;
46
+ }
47
+ export type AppUiAsset = AppUiFile | AppUiStoredFile;
48
+ /** Requests name an operation on this app and the page's version, never another app or account. */
49
+ export declare const UiOperation: withLegacyKeys<Schema.Struct<{
17
50
  readonly name: Schema.NonEmptyString;
18
51
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
19
- readonly deployment: Schema.NonEmptyString;
20
- readonly profile: Schema.optional<Schema.NonEmptyString>;
21
- readonly expectedProfileRevision: Schema.optional<Schema.Int>;
52
+ readonly version: Schema.NonEmptyString;
53
+ readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
54
+ }>, {
55
+ readonly version: "deployment";
22
56
  }>;
23
57
  declare const UiUnauthorized_base: Schema.Class<UiUnauthorized, Schema.TaggedStruct<"UiUnauthorized", {}>, import("effect/Cause").YieldableError>;
24
58
  /** The app session is absent or its parent login was revoked. */
@@ -28,9 +62,12 @@ declare const UiForbidden_base: Schema.Class<UiForbidden, Schema.TaggedStruct<"U
28
62
  /** The request did not originate from the configured app. */
29
63
  export declare class UiForbidden extends UiForbidden_base {
30
64
  }
31
- declare const UiDeploymentChanged_base: Schema.Class<UiDeploymentChanged, Schema.TaggedStruct<"UiDeploymentChanged", {}>, import("effect/Cause").YieldableError>;
32
- /** The page should reload before starting another operation. */
33
- export declare class UiDeploymentChanged extends UiDeploymentChanged_base {
65
+ declare const UiVersionChanged_base: Schema.Class<UiVersionChanged, Schema.TaggedStruct<"UiDeploymentChanged", {}>, import("effect/Cause").YieldableError>;
66
+ /**
67
+ * The page should reload before starting another operation. The tag keeps its former name: pages
68
+ * built with earlier framework releases reload on it.
69
+ */
70
+ export declare class UiVersionChanged extends UiVersionChanged_base {
34
71
  }
35
72
  declare const UiFailed_base: Schema.Class<UiFailed, Schema.TaggedStruct<"UiFailed", {
36
73
  readonly reason: Schema.Literals<readonly ["unavailable", "operation_failed", "account_required"]>;
@@ -50,24 +87,27 @@ export declare const UiSnapshot: Schema.Union<readonly [Schema.Struct<{
50
87
  readonly type: Schema.Literal<"heartbeat">;
51
88
  }>]>;
52
89
  /** Portable serving contract; the host authenticates and resolves the configured app. */
53
- export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGroup<"ui", HttpApiEndpoint.HttpApiEndpoint<"query", "POST", "/_executor/api/query", never, never, Schema.toCodecJson<Schema.Struct<{
90
+ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGroup<"ui", HttpApiEndpoint.HttpApiEndpoint<"query", "POST", "/_executor/api/query", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
54
91
  readonly name: Schema.NonEmptyString;
55
92
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
56
- readonly deployment: Schema.NonEmptyString;
57
- readonly profile: Schema.optional<Schema.NonEmptyString>;
58
- readonly expectedProfileRevision: Schema.optional<Schema.Int>;
59
- }>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiDeploymentChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mutate", "POST", "/_executor/api/mutate", never, never, Schema.toCodecJson<Schema.Struct<{
93
+ readonly version: Schema.NonEmptyString;
94
+ readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
95
+ }>, {
96
+ readonly version: "deployment";
97
+ }>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mutate", "POST", "/_executor/api/mutate", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
60
98
  readonly name: Schema.NonEmptyString;
61
99
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
62
- readonly deployment: Schema.NonEmptyString;
63
- readonly profile: Schema.optional<Schema.NonEmptyString>;
64
- readonly expectedProfileRevision: Schema.optional<Schema.Int>;
65
- }>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiDeploymentChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"subscribe", "POST", "/_executor/api/subscribe", never, never, Schema.toCodecJson<Schema.Struct<{
100
+ readonly version: Schema.NonEmptyString;
101
+ readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
102
+ }>, {
103
+ readonly version: "deployment";
104
+ }>>, never, Schema.toCodecJson<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"subscribe", "POST", "/_executor/api/subscribe", never, never, Schema.toCodecJson<withLegacyKeys<Schema.Struct<{
66
105
  readonly name: Schema.NonEmptyString;
67
106
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
68
- readonly deployment: Schema.NonEmptyString;
69
- readonly profile: Schema.optional<Schema.NonEmptyString>;
70
- readonly expectedProfileRevision: Schema.optional<Schema.Int>;
107
+ readonly version: Schema.NonEmptyString;
108
+ readonly accounts: Schema.optional<Schema.$Record<Schema.NonEmptyString, Schema.$Array<Schema.NonEmptyString>>>;
109
+ }>, {
110
+ readonly version: "deployment";
71
111
  }>>, never, HttpApiSchema.StreamSse<HttpApiSchema.SseEventFromData<Schema.Union<readonly [Schema.Struct<{
72
112
  readonly type: Schema.Literal<"snapshot">;
73
113
  readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
@@ -77,7 +117,7 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
77
117
  readonly error: typeof UiFailed;
78
118
  }>, Schema.Struct<{
79
119
  readonly type: Schema.Literal<"heartbeat">;
80
- }>]>>, Schema.Union<readonly [typeof UiUnauthorized, typeof UiForbidden, typeof UiDeploymentChanged, typeof UiFailed]>, {
120
+ }>]>>, Schema.Union<readonly [typeof UiUnauthorized, typeof UiForbidden, typeof UiVersionChanged, typeof UiFailed]>, {
81
121
  readonly value: Schema.Json;
82
122
  readonly type: "snapshot";
83
123
  readonly trace?: unknown;
@@ -86,5 +126,5 @@ export declare const AppUiApi: HttpApi.HttpApi<"app-ui", HttpApiGroup.HttpApiGro
86
126
  readonly error: UiFailed;
87
127
  } | {
88
128
  readonly type: "heartbeat";
89
- }>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiDeploymentChanged | typeof UiFailed>, never, never>, false>>;
129
+ }>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiVersionChanged | typeof UiFailed>, never, never>, false>>;
90
130
  export {};
@@ -1,17 +1,34 @@
1
1
  /** Account-bound webhook lifecycle. Register and unregister must be idempotent for subscriptionId. */
2
2
  import type { Effect, Schema } from "effect";
3
3
  import type { ManualWebhookSetup } from "./webhook-protocol.js";
4
- import type { AccountSlots, BoundContext } from "./app.js";
5
- type SourceAccount<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">> = keyof Context["accounts"] & string;
6
- type SelectedAccount<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">> = {
7
- [Slot in keyof Context["accounts"]]: Context["accounts"][Slot] extends readonly (infer Account)[] ? Account : Context["accounts"][Slot];
8
- }[keyof Context["accounts"]];
4
+ import type { AccountScope, BoundContext, ScopedSlots } from "./app.js";
5
+ /** What every webhook context provides; a context with `user` serves user-account webhooks. */
6
+ type HookContext = Pick<BoundContext<ScopedSlots, AccountScope>, "app" | "fetch" | "signal">;
7
+ /**
8
+ * The accounts of the webhook's scope. A context with `user` names a user requirement; one of the
9
+ * `"app"` scope, which has no `user`, an app requirement.
10
+ */
11
+ type ScopeAccounts<Context extends HookContext> = Context extends {
12
+ readonly user: {
13
+ readonly accounts: infer Accounts;
14
+ };
15
+ } ? Accounts : Context["app"]["accounts"];
16
+ type SourceAccount<Context extends HookContext> = Context extends {
17
+ readonly user: unknown;
18
+ } ? {
19
+ readonly user: keyof ScopeAccounts<Context> & string;
20
+ } : {
21
+ readonly app: keyof ScopeAccounts<Context> & string;
22
+ };
23
+ type SelectedAccount<Context extends HookContext> = {
24
+ [Slot in keyof ScopeAccounts<Context>]: ScopeAccounts<Context>[Slot] extends readonly (infer Account)[] ? Account : ScopeAccounts<Context>[Slot];
25
+ }[keyof ScopeAccounts<Context>];
9
26
  /**
10
27
  * Registration, delivery and cleanup share the selected accounts.
11
28
  * The host stores account IDs and parsed state, never credentials.
12
29
  * Register runs when enabling a subscription, not on every app evaluation.
13
30
  */
14
- interface WebhookLifecycle<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> {
31
+ interface WebhookLifecycle<Context extends HookContext, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> {
15
32
  readonly account: SourceAccount<Context>;
16
33
  readonly config: Config;
17
34
  readonly state: State;
@@ -43,7 +60,7 @@ interface WebhookLifecycle<Context extends Pick<BoundContext<AccountSlots>, "acc
43
60
  }) => Effect.Effect<void, Error>;
44
61
  }
45
62
  /** Manual subscriptions collect the state schema in a private browser form instead of invoking provider APIs. */
46
- export type Webhook<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> = (WebhookLifecycle<Context, Config, State, Error> & {
63
+ export type Webhook<Context extends HookContext, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> = (WebhookLifecycle<Context, Config, State, Error> & {
47
64
  readonly setup?: never;
48
65
  }) | (Omit<WebhookLifecycle<Context, Config, State, Error>, "register" | "unregister"> & {
49
66
  readonly setup: typeof ManualWebhookSetup.Type;