apps 0.0.1-beta.37 → 0.0.1-beta.39

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 (81) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-GHDZEEPO.js → chunk-27TDXHRX.js} +395 -82
  3. package/js/{chunk-KOOJUMLR.js → chunk-3MMG2H6M.js} +2 -2
  4. package/js/{chunk-LQBR7AI7.js → chunk-3V575NIW.js} +217 -19
  5. package/js/{chunk-U74JVKTQ.js → chunk-5NIEOXRZ.js} +7 -7
  6. package/js/{chunk-BWUHMKHQ.js → chunk-5TJA7364.js} +2 -2
  7. package/js/{chunk-7KEKFBV7.js → chunk-7CSHVXVR.js} +3 -3
  8. package/js/{chunk-3LRFKLUX.js → chunk-BO4US6DZ.js} +9 -49
  9. package/js/{chunk-A4O72Z3A.js → chunk-DKUEYTYD.js} +167 -30
  10. package/js/{chunk-ENJCQWVF.js → chunk-E4BWL7KQ.js} +3 -3
  11. package/js/{chunk-CAOHGMNW.js → chunk-F3TBO2U3.js} +7 -94
  12. package/js/{chunk-POOIHRPF.js → chunk-GHXRRFZA.js} +11 -34
  13. package/js/{chunk-RSNZDT4L.js → chunk-JTMDWPCH.js} +2 -2
  14. package/js/{chunk-YW333DH3.js → chunk-KANDIVIH.js} +4 -4
  15. package/js/{chunk-2FWXCU5I.js → chunk-KAQD3DTI.js} +1 -1
  16. package/js/{chunk-QQKHJ72Y.js → chunk-LVWX4UWK.js} +9 -9
  17. package/js/{chunk-KEZ4YZSP.js → chunk-MLHNVYHT.js} +2 -2
  18. package/js/{chunk-IJQ5LE74.js → chunk-MXDKXAY4.js} +363 -401
  19. package/js/{chunk-BI6R577B.js → chunk-P7MGDPFD.js} +2 -2
  20. package/js/{chunk-24EIFQYZ.js → chunk-PCV73KVK.js} +35 -10
  21. package/js/{chunk-JU7F4PRK.js → chunk-RIXVGVA6.js} +2 -2
  22. package/js/{chunk-D45FU4TZ.js → chunk-SDHD6J37.js} +3 -3
  23. package/js/{chunk-UCOMVHGW.js → chunk-U5PFZDVB.js} +2 -2
  24. package/js/{chunk-PHO7HXTC.js → chunk-VIU2XXA7.js} +294 -47
  25. package/js/{chunk-TADLIUEU.js → chunk-VJQXXOQ3.js} +2 -2
  26. package/js/{chunk-NHCFIWN5.js → chunk-W2NV54JD.js} +1 -1
  27. package/js/{chunk-BI45HZWM.js → chunk-YQ35E7KS.js} +1 -1
  28. package/js/{chunk-WDBUOIWV.js → chunk-ZUKBIHMK.js} +3 -3
  29. package/js/client.js +13 -17
  30. package/js/contracts.js +16 -21
  31. package/js/effect.js +19 -24
  32. package/js/graphql.js +21 -26
  33. package/js/host.js +19 -24
  34. package/js/index.js +13 -26
  35. package/js/mcp/effect.js +21 -26
  36. package/js/mcp/stdio.js +21 -26
  37. package/js/mcp.js +23 -28
  38. package/js/openapi.js +17 -21
  39. package/js/react.js +2 -3
  40. package/js/skills/effect.js +6 -7
  41. package/js/skills.js +15 -17
  42. package/js/storage/facet.js +1 -214
  43. package/js/ui/auth/contracts.js +2 -2
  44. package/js/ui/auth.js +5 -5
  45. package/js/ui/contracts.js +5 -6
  46. package/js/ui/serving.js +10 -11
  47. package/package.json +1 -2
  48. package/runtime.json +1 -1
  49. package/types/apps/src/contracts/app.d.ts +0 -2
  50. package/types/apps/src/contracts/context.d.ts +12 -11
  51. package/types/apps/src/contracts/host.d.ts +10 -8
  52. package/types/apps/src/contracts/live.d.ts +2 -0
  53. package/types/apps/src/contracts/operations.d.ts +3 -3
  54. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  55. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  56. package/types/apps/src/contracts/protocols/4.d.ts +3 -3
  57. package/types/apps/src/contracts/protocols/5.d.ts +1 -1
  58. package/types/apps/src/contracts/protocols/6.d.ts +1 -1
  59. package/types/apps/src/contracts/protocols/7.d.ts +1 -1
  60. package/types/apps/src/contracts/sql.d.ts +58 -0
  61. package/types/apps/src/facet.d.ts +4 -5
  62. package/types/apps/src/implementation/openapi-compile.d.ts +2 -2
  63. package/types/apps/src/implementation/schema.d.ts +1 -10
  64. package/types/apps/src/implementation/sql.d.ts +66 -0
  65. package/types/apps/src/index.d.ts +1 -2
  66. package/types/telemetry/src/transport.d.ts +8 -1
  67. package/js/chunk-73AV3JVU.js +0 -186
  68. package/js/chunk-HDAQBRT5.js +0 -1254
  69. package/js/chunk-IU7CCCUC.js +0 -630
  70. package/js/chunk-NHUHTWAF.js +0 -0
  71. package/js/chunk-V5DWGYRK.js +0 -268
  72. package/js/chunk-Y3XN4X4Q.js +0 -19
  73. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  74. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  75. package/types/app-data/src/implementation/promise.d.ts +0 -68
  76. package/types/app-data/src/implementation/range.d.ts +0 -8
  77. package/types/app-data/src/implementation/schema.d.ts +0 -18
  78. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  79. package/types/app-data/src/index.d.ts +0 -4
  80. package/types/apps/src/contracts/storage.d.ts +0 -68
  81. package/types/apps/src/implementation/storage.d.ts +0 -15
@@ -313,7 +313,7 @@ export declare class HostKindMismatch extends HostKindMismatch_base {
313
313
  * Safe error envelope. Author failures carry only their name and bounded message with account
314
314
  * secrets replaced; no source, account fields, stack or cause value is serialized.
315
315
  */
316
- export declare const HostError: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof ProviderError, typeof McpError, typeof SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof HostDeclarationInvalid, typeof HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/index.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/index.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof HostKindMismatch]>;
316
+ export declare const HostError: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof ProviderError, typeof McpError, typeof SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof HostDeclarationInvalid, typeof HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/contracts/database.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/contracts/database.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof HostKindMismatch]>;
317
317
  /** Expected host failures. */
318
318
  export type HostError = typeof HostError.Type;
319
319
  /** Portable response envelope; callers parse the success value for their operation. */
@@ -323,7 +323,7 @@ export declare const HostResponse: Schema.Union<readonly [Schema.Struct<{
323
323
  readonly toolError: Schema.optionalKey<Schema.Literal<true>>;
324
324
  }>, Schema.Struct<{
325
325
  readonly ok: Schema.Literal<false>;
326
- readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof ProviderError, typeof McpError, typeof SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof HostDeclarationInvalid, typeof HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/index.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/index.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof HostKindMismatch]>;
326
+ readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof ProviderError, typeof McpError, typeof SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof HostDeclarationInvalid, typeof HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/contracts/database.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/contracts/database.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof HostKindMismatch]>;
327
327
  }>]>;
328
328
  /** Parsed response envelope. */
329
329
  export type HostResponse = typeof HostResponse.Type;
@@ -949,7 +949,7 @@ export declare const protocol4: {
949
949
  readonly toolError: Schema.optionalKey<Schema.Literal<true>>;
950
950
  }>, Schema.Struct<{
951
951
  readonly ok: Schema.Literal<false>;
952
- readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof ProviderError, typeof McpError, typeof SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof HostDeclarationInvalid, typeof HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/index.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/index.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof HostKindMismatch]>;
952
+ readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof ProviderError, typeof McpError, typeof SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof HostDeclarationInvalid, typeof HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/contracts/database.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/contracts/database.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof HostKindMismatch]>;
953
953
  }>]>;
954
954
  readonly requirements: Schema.Struct<{
955
955
  readonly capabilities: Schema.optionalKey<Schema.Struct<{
@@ -918,7 +918,7 @@ export declare const protocol5: {
918
918
  readonly toolError: Schema.optionalKey<Schema.Literal<true>>;
919
919
  }>, Schema.Struct<{
920
920
  readonly ok: Schema.Literal<false>;
921
- readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof import("./1.js").ProviderError, typeof import("./1.js").McpError, typeof import("./1.js").SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof import("./3.js").HostDeclarationInvalid, typeof import("./3.js").HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/index.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/index.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof import("./4.js").HostKindMismatch]>;
921
+ readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof import("./1.js").ProviderError, typeof import("./1.js").McpError, typeof import("./1.js").SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof import("./3.js").HostDeclarationInvalid, typeof import("./3.js").HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/contracts/database.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/contracts/database.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof import("./4.js").HostKindMismatch]>;
922
922
  }>]>;
923
923
  readonly catalog: Schema.Struct<{
924
924
  readonly tools: Schema.$Array<Schema.Struct<{
@@ -1364,7 +1364,7 @@ export declare const protocol6: {
1364
1364
  readonly toolError: Schema.optionalKey<Schema.Literal<true>>;
1365
1365
  }>, Schema.Struct<{
1366
1366
  readonly ok: Schema.Literal<false>;
1367
- readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof import("./1.js").ProviderError, typeof import("./1.js").McpError, typeof import("./1.js").SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof import("./3.js").HostDeclarationInvalid, typeof import("./3.js").HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/index.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/index.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof import("./4.js").HostKindMismatch]>;
1367
+ readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof import("./1.js").ProviderError, typeof import("./1.js").McpError, typeof import("./1.js").SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof import("./3.js").HostDeclarationInvalid, typeof import("./3.js").HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/contracts/database.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/contracts/database.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof import("./4.js").HostKindMismatch]>;
1368
1368
  }>]>;
1369
1369
  readonly catalog: Schema.Struct<{
1370
1370
  readonly tools: Schema.$Array<Schema.Struct<{
@@ -1528,7 +1528,7 @@ export declare const protocol7: {
1528
1528
  readonly toolError: Schema.optionalKey<Schema.Literal<true>>;
1529
1529
  }>, Schema.Struct<{
1530
1530
  readonly ok: Schema.Literal<false>;
1531
- readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof import("./1.js").ProviderError, typeof import("./1.js").McpError, typeof import("./1.js").SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof import("./3.js").HostDeclarationInvalid, typeof import("./3.js").HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/index.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/index.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof import("./4.js").HostKindMismatch]>;
1531
+ readonly error: Schema.Union<readonly [typeof import("../api-response-error.js").OpenapiResponseError, typeof import("./1.js").ProviderError, typeof import("./1.js").McpError, typeof import("./1.js").SkillLoadFailed, typeof import("../workflows.js").WorkflowFailure, typeof import("./1.js").HostRequestInvalid, typeof import("./1.js").HostAccountsInvalid, typeof import("./3.js").HostDeclarationInvalid, typeof import("./3.js").HostEvaluationFailed, typeof import("./1.js").HostOperationNotFound, typeof import("./3.js").HostOperationFailed, typeof import("../../../../app-data/src/contracts/database.js").DatabaseLimitExceeded, typeof import("../../../../app-data/src/contracts/database.js").DatabaseFieldReserved, typeof import("./1.js").HostToolNotFound, typeof import("./1.js").HostInputInvalid, typeof import("./1.js").HostOutputInvalid, typeof import("./1.js").HostToolBlocked, typeof import("./1.js").HostToolApprovalRequired, typeof import("./1.js").HostToolPolicyFailed, typeof import("../elicitation.js").ElicitationFailed, typeof import("./4.js").HostKindMismatch]>;
1532
1532
  }>]>;
1533
1533
  readonly catalog: Schema.Struct<{
1534
1534
  readonly tools: Schema.$Array<Schema.Struct<{
@@ -0,0 +1,58 @@
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";
@@ -1,5 +1,4 @@
1
- /** Native workerd SQLite capability; used only by the generated data facet, never browser bundles. */
2
- import * as Sqlite from "@effect/sql-sqlite-do/SqliteClient";
3
- import type { AppStorage } from "./contracts/storage.js";
4
- /** Bind one facet's raw storage at the runtime edge. Each operation owns its native SQL scope. */
5
- export declare const facetStorage: (storage: NonNullable<Sqlite.SqliteClientConfig["storage"]>) => AppStorage;
1
+ /** The data facet's storage capability; used only by the generated data facet, never browser bundles. */
2
+ import type { AppSqlStorage } from "./contracts/sql.js";
3
+ /** Bind one facet's storage at the runtime edge. App code receives `ctx.sql` over it, never the storage. */
4
+ export declare const facetStorage: (storage: AppSqlStorage) => AppSqlStorage;
@@ -25,11 +25,10 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
25
25
  }) => Effect.Effect<{
26
26
  operations: {
27
27
  readonly description: string;
28
- readonly name: string;
29
28
  readonly request: {
30
29
  readonly parameters: readonly {
31
30
  readonly name: string;
32
- readonly in: "query" | "path" | "querystring" | "header" | "cookie";
31
+ readonly in: "path" | "query" | "querystring" | "header" | "cookie";
33
32
  readonly required?: boolean;
34
33
  readonly schema?: {
35
34
  readonly [x: string]: Schema.Json;
@@ -65,6 +64,7 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
65
64
  };
66
65
  };
67
66
  readonly path: string;
67
+ readonly name: string;
68
68
  readonly input: {
69
69
  readonly [x: string]: Schema.Json;
70
70
  };
@@ -1,13 +1,10 @@
1
1
  /** Author schema facade. Internals use the native decoder retained by each value. */
2
2
  import { Effect, Schema as EffectSchema } from "effect";
3
3
  import { JsonObject, ValidationError } from "../contracts/schema.js";
4
- import type { Field } from "../../../app-data/src/contracts/database.js";
5
4
  import type { FieldExposure } from "../contracts/provider.js";
6
- declare const StorageField: unique symbol;
7
5
  declare const Decoder: unique symbol;
8
6
  /** An author-facing value schema. Effect is never required in author code. */
9
7
  export interface Schema<T, Optional extends boolean = false> {
10
- readonly [StorageField]?: Field;
11
8
  readonly [Decoder]: EffectSchema.Decoder<T>;
12
9
  readonly optionalValue: Optional;
13
10
  /** Parse an unknown value; invalid input throws a safe ValidationError. */
@@ -46,7 +43,7 @@ export declare const schemaArgument: <S extends Schema<unknown, boolean>>(value:
46
43
  /** Decode within an Effect program. Invalid input is omitted from the failure. */
47
44
  export declare const parse: <T>(decoder: EffectSchema.Decoder<T>, input: unknown) => Effect.Effect<T, ValidationError>;
48
45
  /** Present a native decoder through the synchronous author API. */
49
- export declare function wrap<T, Optional extends boolean>(decoder: EffectSchema.Decoder<T>, optionalValue: Optional, field?: Field): Schema<T, Optional>;
46
+ export declare function wrap<T, Optional extends boolean>(decoder: EffectSchema.Decoder<T>, optionalValue: Optional): Schema<T, Optional>;
50
47
  /** A string, optionally with a minimum length. No coercion. */
51
48
  export declare function string(options?: {
52
49
  readonly minLength?: number;
@@ -165,12 +162,6 @@ export declare const preparedJsonSchemaDecoder: (document: JsonObject) => {
165
162
  export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, ValidationError, never>;
166
163
  /** Import JSON metadata now; unsupported schemas and invalid values fail when parsed. */
167
164
  export declare const jsonSchema: (input: unknown) => Schema<EffectSchema.Json>;
168
- /** Database declaration retained by primitive constructors; nested payload schemas are not database fields. */
169
- export declare const storageFieldOf: (schema: Schema<unknown, boolean>) => Field | undefined;
170
- /** A row reference records the target table; existence is not a foreign-key constraint. */
171
- export declare const id: (table: string) => Schema<string>;
172
- /** A host user identifier, stored as a string without imposing a product auth model. */
173
- export declare const userId: () => Schema<string>;
174
165
  /** Render a decoder as a JSON Schema document, keeping an imported upstream document as-is. */
175
166
  export declare const jsonSchemaDocument: (decoder: EffectSchema.Decoder<unknown>) => Effect.Effect<{
176
167
  readonly [x: string]: EffectSchema.Json;
@@ -0,0 +1,66 @@
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
+ reader: SqlReader;
27
+ writer: Sql;
28
+ close: () => void;
29
+ };
30
+ declare const MigrationFileInvalid_base: Schema.Class<MigrationFileInvalid, Schema.TaggedStruct<"MigrationFileInvalid", {
31
+ readonly path: Schema.String;
32
+ readonly reason: Schema.String;
33
+ }>, import("effect/Cause").YieldableError>;
34
+ /** A file in `migrations/` that is not a migration the host can order. */
35
+ export declare class MigrationFileInvalid extends MigrationFileInvalid_base {
36
+ get message(): string;
37
+ }
38
+ declare const MigrationHistoryChanged_base: Schema.Class<MigrationHistoryChanged, Schema.TaggedStruct<"MigrationHistoryChanged", {
39
+ readonly reason: Schema.String;
40
+ }>, import("effect/Cause").YieldableError>;
41
+ /** The build's migrations no longer start with the ones already applied to the database. */
42
+ export declare class MigrationHistoryChanged extends MigrationHistoryChanged_base {
43
+ get message(): string;
44
+ }
45
+ declare const MigrationFailed_base: Schema.Class<MigrationFailed, Schema.TaggedStruct<"MigrationFailed", {
46
+ readonly path: Schema.String;
47
+ readonly reason: Schema.String;
48
+ }>, import("effect/Cause").YieldableError>;
49
+ /** SQLite rejected a migration. Every migration of the deploy rolled back. */
50
+ export declare class MigrationFailed extends MigrationFailed_base {
51
+ get message(): string;
52
+ }
53
+ /** Whether a build's files give the app a database: any `.sql` file in `migrations/`. */
54
+ export declare const hasMigrations: (files: readonly {
55
+ readonly path: string;
56
+ }[]) => boolean;
57
+ /**
58
+ * Apply the build's pending migrations and report which ran. Every pending migration runs in one
59
+ * transaction, so a failing one leaves the database exactly as the active deployment knows it. The
60
+ * migrations already applied must still be the build's first ones, byte for byte.
61
+ */
62
+ export declare const migrate: (storage: AppSqlStorage, files: readonly SkillFile[]) => Effect.Effect<{
63
+ readonly id: number;
64
+ readonly name: string;
65
+ }[], MigrationFileInvalid | MigrationHistoryChanged | MigrationFailed, never>;
66
+ export {};
@@ -73,8 +73,7 @@ export type JsonResponse = PromiseMethods<NativeResponse>;
73
73
  export declare const decodeJson: <T>(response: JsonResponse, schema: Schema<T, boolean>) => Promise<T>;
74
74
  export { NotImplemented } from "./contracts/app.js";
75
75
  export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
76
- export { table, defineDatabase, type Table, type DatabaseReader, type Database, type DatabaseDefinition, } from "./implementation/storage.js";
77
- export { id, userId } from "./implementation/schema.js";
76
+ export type { Sql, SqlCursor, SqlReader, SqlRow, SqlTransaction, SqlValue, } from "./contracts/sql.js";
78
77
  export { query, mutation, withApproval, toolAnnotations, type Operation, type OperationOptions, } from "./implementation/operations.js";
79
78
  export type { OperationContext } from "./contracts/operations.js";
80
79
  export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
@@ -1,6 +1,13 @@
1
1
  import { Context, Layer } from "effect";
2
- import { HttpClient } from "effect/http";
2
+ import { HttpClient, HttpClientError } from "effect/http";
3
3
  /** Local collector discovery can resolve its destination when an export runs. */
4
4
  export declare const CurrentTelemetryClient: Context.Reference<HttpClient.HttpClient | undefined>;
5
5
  /** Telemetry consumers inspect status and headers; release response I/O inside each export scope. */
6
6
  export declare const telemetryHttpClient: Layer.Layer<HttpClient.HttpClient, never, never>;
7
+ /**
8
+ * Resend an export the collector refused for now, as OTLP requires and Effect's own
9
+ * exporters do: lost connections, 429 and 5xx overload, at most three more times. A
10
+ * collector shedding load answers 429 or 503 with Retry-After, which sets the wait. A
11
+ * wait longer than the caller's budget ends with the budget, without sending again.
12
+ */
13
+ export declare const retryTelemetryExport: (client: HttpClient.HttpClient) => HttpClient.HttpClient.With<HttpClientError.HttpClientError, never>;
@@ -1,186 +0,0 @@
1
- import {
2
- Schema_exports
3
- } from "./chunk-IJQ5LE74.js";
4
-
5
- // ../app-data/src/contracts/database.ts
6
- var DataName = Schema_exports.String.check(
7
- Schema_exports.makeFilter((value) => /^[A-Za-z][A-Za-z0-9_]*$/.test(value) && value.length <= 128)
8
- );
9
- var Scalar = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
10
- var Field = Schema_exports.Struct({
11
- kind: Schema_exports.Literals(["string", "number", "boolean", "id", "userId"]),
12
- optional: Schema_exports.optional(Schema_exports.Boolean),
13
- default: Schema_exports.optional(Scalar),
14
- references: Schema_exports.optional(DataName)
15
- });
16
- var Index = Schema_exports.Struct({ name: DataName, fields: Schema_exports.NonEmptyArray(DataName) });
17
- var Table = Schema_exports.Struct({
18
- fields: Schema_exports.Record(DataName, Field),
19
- indexes: Schema_exports.Array(Index)
20
- });
21
- var DatabaseSchema = Schema_exports.Record(DataName, Table);
22
- var Row = Schema_exports.Record(Schema_exports.String, Scalar);
23
- var RowMetadata = Schema_exports.Struct({
24
- id: Schema_exports.NonEmptyString,
25
- createdAt: Schema_exports.String,
26
- updatedAt: Schema_exports.String
27
- });
28
- var Patch = Schema_exports.Record(DataName, Schema_exports.NullOr(Scalar));
29
- var RangeClause = Schema_exports.Struct({
30
- field: DataName,
31
- op: Schema_exports.Literals(["eq", "gt", "gte", "lt", "lte"]),
32
- value: Schema_exports.NullOr(Scalar)
33
- });
34
- var QueryPlan = Schema_exports.Struct({
35
- table: DataName,
36
- index: DataName,
37
- order: Schema_exports.Literals(["asc", "desc"]),
38
- clauses: Schema_exports.Array(RangeClause)
39
- });
40
- var QueryTerminal = Schema_exports.Union([
41
- Schema_exports.Struct({ kind: Schema_exports.Literal("collect") }),
42
- Schema_exports.Struct({ kind: Schema_exports.Literal("count") }),
43
- Schema_exports.Struct({ kind: Schema_exports.Literal("first") }),
44
- Schema_exports.Struct({
45
- kind: Schema_exports.Literal("take"),
46
- count: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0))
47
- }),
48
- Schema_exports.Struct({
49
- kind: Schema_exports.Literal("paginate"),
50
- cursor: Schema_exports.NullOr(Schema_exports.String),
51
- numItems: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
52
- })
53
- ]);
54
- var DatabaseOperation = Schema_exports.Union([
55
- Schema_exports.Struct({ kind: Schema_exports.Literal("get"), table: DataName, id: Schema_exports.NonEmptyString }),
56
- Schema_exports.Struct({ kind: Schema_exports.Literal("insert"), table: DataName, value: Patch }),
57
- Schema_exports.Struct({
58
- kind: Schema_exports.Literal("update"),
59
- table: DataName,
60
- id: Schema_exports.NonEmptyString,
61
- patch: Patch
62
- }),
63
- Schema_exports.Struct({ kind: Schema_exports.Literal("delete"), table: DataName, id: Schema_exports.NonEmptyString }),
64
- Schema_exports.Struct({ kind: Schema_exports.Literal("query"), plan: QueryPlan, terminal: QueryTerminal })
65
- ]);
66
- var PaginationResult = Schema_exports.Struct({
67
- page: Schema_exports.Array(Row),
68
- continueCursor: Schema_exports.NullOr(Schema_exports.String),
69
- isDone: Schema_exports.Boolean
70
- });
71
- var OperationResult = Schema_exports.Union([
72
- Row,
73
- Schema_exports.Array(Row),
74
- PaginationResult,
75
- Schema_exports.Boolean,
76
- Schema_exports.Finite,
77
- Schema_exports.Null
78
- ]);
79
- var AppDatabaseError = class extends Schema_exports.TaggedError()("AppDatabaseError", {
80
- reason: Schema_exports.Literals([
81
- "schema",
82
- "schema_changed",
83
- "table",
84
- "index",
85
- "range",
86
- "value",
87
- "readonly",
88
- "cursor",
89
- "limit",
90
- "closed",
91
- "storage",
92
- "replay"
93
- ])
94
- }) {
95
- };
96
- var DatabaseLimits = Schema_exports.Struct({
97
- rowsRead: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
98
- rowsReturned: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
99
- bytesRead: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
100
- writes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
101
- scanCalls: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
102
- directGets: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
103
- valueBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
104
- indexBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
105
- });
106
- var defaultDatabaseLimits = {
107
- rowsRead: 5e3,
108
- rowsReturned: 1e3,
109
- bytesRead: 4 * 1024 * 1024,
110
- writes: 1e3,
111
- scanCalls: 100,
112
- directGets: 1e3,
113
- valueBytes: 64 * 1024,
114
- indexBytes: 2048
115
- };
116
- var DatabaseLimit = Schema_exports.Literals([
117
- "scanCalls",
118
- "directGets",
119
- "rowsRead",
120
- "rowsReturned",
121
- "pageSize",
122
- "bytesRead",
123
- "writes",
124
- "valueBytes"
125
- ]);
126
- var count = (value) => value.toLocaleString("en-US");
127
- var limitMessages = {
128
- scanCalls: (maximum, requested) => `This invocation made ${count(requested)} index queries; the limit is ${count(maximum)}. Each first(), take(), collect(), count() or paginate() call on withIndex(...) counts once. Read related rows with one take() or paginate() over a shared index prefix instead of one first() per item, use get(id) for known IDs, or split the work across workflow steps.`,
129
- directGets: (maximum, requested) => `This invocation made ${count(requested)} get(id) calls, including those made by update and delete; the limit is ${count(maximum)}. Split the work across workflow steps or mutations.`,
130
- rowsRead: (maximum, requested) => `This invocation scanned ${count(requested)} rows; the limit is ${count(maximum)}. Narrow the index range, or page with paginate() across calls or workflow steps.`,
131
- rowsReturned: (maximum, requested) => `This invocation returned ${count(requested)} rows; the limit is ${count(maximum)}. collect() fails rather than truncating. Page with paginate() across calls or workflow steps.`,
132
- pageSize: (maximum, requested) => `One call asked for ${count(requested)} rows; take(n) and paginate({ numItems }) accept at most ${count(maximum)}. Page with paginate() across calls or workflow steps.`,
133
- bytesRead: (maximum, requested) => `This invocation read ${count(requested)} bytes; the limit is ${count(maximum)}. Read fewer or smaller rows per call, or page with paginate() across calls or workflow steps.`,
134
- writes: (maximum, requested) => `This mutation made ${count(requested)} writes; the limit is ${count(maximum)}. Split large ingests into batches, one batch per mutation or workflow step.`,
135
- valueBytes: (maximum, requested) => `A row encodes to ${count(requested)} bytes; each row may use at most ${count(maximum)}. Store large content outside the row or split it across rows.`
136
- };
137
- var DatabaseLimitExceeded = class extends Schema_exports.TaggedError()(
138
- "DatabaseLimitExceeded",
139
- {
140
- limit: DatabaseLimit,
141
- maximum: Schema_exports.Int,
142
- requested: Schema_exports.Int
143
- }
144
- ) {
145
- get message() {
146
- return limitMessages[this.limit](this.maximum, this.requested);
147
- }
148
- };
149
- var reservedFieldNames = ["id", "createdAt", "updatedAt"];
150
- var DatabaseFieldReserved = class extends Schema_exports.TaggedError()(
151
- "DatabaseFieldReserved",
152
- {
153
- table: Schema_exports.String,
154
- field: Schema_exports.Literals(reservedFieldNames)
155
- }
156
- ) {
157
- get message() {
158
- return `Table "${this.table}" declares "${this.field}", which is reserved: the host adds id, createdAt and updatedAt to every row. Rename the field, or use the row's own ${this.field}.`;
159
- }
160
- };
161
- var DatabaseRuntimeLimits = Schema_exports.Struct({
162
- maxCursorChars: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
163
- connectionCacheCapacity: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
164
- connectionCacheTtlMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
165
- });
166
- var defaultDatabaseRuntimeLimits = DatabaseRuntimeLimits.make({
167
- maxCursorChars: 8192,
168
- connectionCacheCapacity: 64,
169
- connectionCacheTtlMs: 5 * 60 * 1e3
170
- });
171
-
172
- export {
173
- DatabaseSchema,
174
- Row,
175
- RowMetadata,
176
- RangeClause,
177
- DatabaseOperation,
178
- PaginationResult,
179
- AppDatabaseError,
180
- DatabaseLimits,
181
- defaultDatabaseLimits,
182
- DatabaseLimitExceeded,
183
- reservedFieldNames,
184
- DatabaseFieldReserved,
185
- defaultDatabaseRuntimeLimits
186
- };