apps 0.0.1-beta.4 → 0.0.1-beta.41

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 (171) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-QKHR7BMF.js → chunk-3MMG2H6M.js} +89 -53
  4. package/js/{chunk-EQB7JMAL.js → chunk-6XGB4BAL.js} +146 -31
  5. package/js/chunk-ADD6H64X.js +729 -0
  6. package/js/{chunk-6VRYO2BG.js → chunk-AHGGO2VY.js} +837 -254
  7. package/js/{chunk-FDNTX5QJ.js → chunk-CQD3WSYH.js} +2 -2
  8. package/js/{chunk-EVJUVWN2.js → chunk-DKUEYTYD.js} +463 -218
  9. package/js/chunk-EM4UL26F.js +118 -0
  10. package/js/{chunk-2VPJHFOU.js → chunk-FXWRE655.js} +128 -24
  11. package/js/{chunk-5MQZEB6Y.js → chunk-JI3EP2GL.js} +40 -12
  12. package/js/chunk-JJSLEJ6T.js +156 -0
  13. package/js/chunk-KAQD3DTI.js +16 -0
  14. package/js/chunk-KIM5HXNK.js +49 -0
  15. package/js/chunk-MJZYV7IO.js +255 -0
  16. package/js/{chunk-FW5HBOIK.js → chunk-MXDKXAY4.js} +19117 -18309
  17. package/js/{chunk-T2LAZCAD.js → chunk-NKWWPJYX.js} +3 -3
  18. package/js/chunk-OD3KFKZD.js +1617 -0
  19. package/js/{chunk-3M2MEDNL.js → chunk-OTCLXFLL.js} +1337 -188
  20. package/js/chunk-P7MGDPFD.js +240 -0
  21. package/js/{chunk-ZCAMUXSG.js → chunk-PNVCCB4L.js} +432 -79
  22. package/js/{chunk-D47C7KG5.js → chunk-RIXVGVA6.js} +2 -2
  23. package/js/{chunk-NQ3OMCA5.js → chunk-TT6OU4UG.js} +2 -2
  24. package/js/{chunk-YEJOQEII.js → chunk-UOZMSUJ2.js} +61 -9
  25. package/js/chunk-UTJIGUSS.js +42 -0
  26. package/js/{chunk-G7ZIRKMK.js → chunk-VIU2XXA7.js} +228 -264
  27. package/js/{chunk-HDJH3RPR.js → chunk-VJQXXOQ3.js} +4 -4
  28. package/js/{chunk-WFSQXYUT.js → chunk-WPBR4AWB.js} +523 -63
  29. package/js/{chunk-SATWJKN6.js → chunk-YQ35E7KS.js} +2 -2
  30. package/js/chunk-ZUKBIHMK.js +92 -0
  31. package/js/client.js +122 -88
  32. package/js/contracts.js +116 -25
  33. package/js/effect.js +19 -20
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +57 -55
  36. package/js/host.js +19 -20
  37. package/js/index.js +245 -212
  38. package/js/mcp/effect.js +23 -22
  39. package/js/mcp/stdio.js +34 -30
  40. package/js/mcp.js +104 -68
  41. package/js/openapi.js +4087 -1503
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +147 -65
  45. package/js/storage/facet.js +1 -540
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +5 -4
  49. package/js/ui/serving.js +8517 -214
  50. package/package.json +2 -3
  51. package/runtime.json +1 -1
  52. package/types/app-data/src/contracts/database.d.ts +33 -6
  53. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  54. package/types/apps/src/contracts/app.d.ts +7 -8
  55. package/types/apps/src/contracts/cache.d.ts +14 -0
  56. package/types/apps/src/contracts/context.d.ts +12 -11
  57. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  58. package/types/apps/src/contracts/failure.d.ts +54 -0
  59. package/types/apps/src/contracts/graphql.d.ts +2 -1
  60. package/types/apps/src/contracts/host.d.ts +44 -17
  61. package/types/apps/src/contracts/live.d.ts +2 -0
  62. package/types/apps/src/contracts/mcp.d.ts +96 -10
  63. package/types/apps/src/contracts/network.d.ts +84 -0
  64. package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
  65. package/types/apps/src/contracts/openapi.d.ts +45 -9
  66. package/types/apps/src/contracts/operations.d.ts +8 -9
  67. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  68. package/types/apps/src/contracts/protocols/1.d.ts +263 -74
  69. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  70. package/types/apps/src/contracts/protocols/2.d.ts +66 -24
  71. package/types/apps/src/contracts/protocols/3.d.ts +715 -0
  72. package/types/apps/src/contracts/protocols/4.d.ts +1297 -0
  73. package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
  74. package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
  75. package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
  76. package/types/apps/src/contracts/protocols/8.d.ts +1130 -0
  77. package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
  78. package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
  79. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  80. package/types/apps/src/contracts/provider.d.ts +115 -10
  81. package/types/apps/src/contracts/router.d.ts +59 -0
  82. package/types/apps/src/contracts/skills.d.ts +39 -9
  83. package/types/apps/src/contracts/sql.d.ts +58 -0
  84. package/types/apps/src/contracts/ui.d.ts +19 -1
  85. package/types/apps/src/contracts/workflows.d.ts +40 -3
  86. package/types/apps/src/facet.d.ts +4 -5
  87. package/types/apps/src/graphql.d.ts +1 -3
  88. package/types/apps/src/implementation/account-router.d.ts +12 -0
  89. package/types/apps/src/implementation/app.d.ts +5 -4
  90. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  91. package/types/apps/src/implementation/catalog-cache.d.ts +32 -5
  92. package/types/apps/src/implementation/elicitation.d.ts +12 -12
  93. package/types/apps/src/implementation/failure-detail.d.ts +47 -0
  94. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  95. package/types/apps/src/implementation/graphql.d.ts +4 -3
  96. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  97. package/types/apps/src/implementation/live.d.ts +2 -2
  98. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  99. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  100. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  101. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  102. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  103. package/types/apps/src/implementation/mcp.d.ts +52 -25
  104. package/types/apps/src/implementation/network.d.ts +16 -0
  105. package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
  106. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  107. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  108. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  109. package/types/apps/src/implementation/openapi-source.d.ts +8 -6
  110. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  111. package/types/apps/src/implementation/operations.d.ts +36 -3
  112. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  113. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  114. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  115. package/types/apps/src/implementation/provider.d.ts +19 -5
  116. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  117. package/types/apps/src/implementation/router-catalog.d.ts +223 -0
  118. package/types/apps/src/implementation/router.d.ts +68 -0
  119. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  120. package/types/apps/src/implementation/schema.d.ts +95 -11
  121. package/types/apps/src/implementation/skills.d.ts +18 -24
  122. package/types/apps/src/implementation/sql.d.ts +66 -0
  123. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  124. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  125. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  126. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  127. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  128. package/types/apps/src/implementation/ui-serving.d.ts +11 -5
  129. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  130. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  131. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  132. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  133. package/types/apps/src/index.d.ts +30 -13
  134. package/types/apps/src/mcp-stdio.d.ts +2 -5
  135. package/types/apps/src/mcp.d.ts +25 -5
  136. package/types/apps/src/openapi.d.ts +6 -6
  137. package/types/apps/src/react.d.ts +1 -1
  138. package/types/apps/src/skills.d.ts +10 -8
  139. package/types/telemetry/src/app-records.d.ts +42 -0
  140. package/types/telemetry/src/browser-operations.d.ts +6 -3
  141. package/types/telemetry/src/browser.d.ts +2 -2
  142. package/types/telemetry/src/config.d.ts +2 -2
  143. package/types/telemetry/src/layer.d.ts +2 -2
  144. package/types/telemetry/src/recorded-failure.d.ts +20 -0
  145. package/types/telemetry/src/relay.d.ts +2 -2
  146. package/types/telemetry/src/transport.d.ts +8 -1
  147. package/types/utils/src/api-error.d.ts +53 -0
  148. package/types/utils/src/recorded-message.d.ts +15 -0
  149. package/js/chunk-BMOIAIVR.js +0 -138
  150. package/js/chunk-DHUDODG5.js +0 -213
  151. package/js/chunk-FZJOYIZO.js +0 -19
  152. package/js/chunk-LGIYBDWA.js +0 -85
  153. package/js/chunk-M6ZRRIBI.js +0 -877
  154. package/js/chunk-PLCMJREA.js +0 -590
  155. package/js/chunk-PYUYJRSK.js +0 -93
  156. package/js/chunk-SWPD52J7.js +0 -35
  157. package/js/chunk-W7D7WVSY.js +0 -18
  158. package/js/chunk-Z5NMEGJN.js +0 -29
  159. package/js/chunk-ZJWDMTE3.js +0 -63
  160. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  161. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  162. package/types/app-data/src/implementation/promise.d.ts +0 -68
  163. package/types/app-data/src/implementation/range.d.ts +0 -8
  164. package/types/app-data/src/implementation/schema.d.ts +0 -33
  165. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  166. package/types/app-data/src/index.d.ts +0 -4
  167. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  168. package/types/apps/src/contracts/storage.d.ts +0 -68
  169. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  170. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  171. package/types/apps/src/implementation/storage.d.ts +0 -13
@@ -1,35 +0,0 @@
1
- import {
2
- Schema_exports
3
- } from "./chunk-FW5HBOIK.js";
4
-
5
- // src/contracts/api-response-error.ts
6
- var ApiErrorRecovery = Schema_exports.Struct({
7
- action: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(1024)),
8
- instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096))
9
- });
10
- var ApiErrorResponse = Schema_exports.Struct({
11
- code: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)),
12
- status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 400, maximum: 599 })),
13
- message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096)),
14
- recovery: Schema_exports.optionalKey(ApiErrorRecovery)
15
- });
16
- var OpenapiResponseError = class extends Schema_exports.TaggedError()(
17
- "OpenapiResponseError",
18
- ApiErrorResponse.fields
19
- ) {
20
- };
21
- var OpenapiErrorLimits = Schema_exports.Struct({
22
- maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
23
- readTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
24
- });
25
- var defaultOpenapiErrorLimits = OpenapiErrorLimits.make({
26
- maxBodyBytes: 65536,
27
- readTimeoutMs: 2e3
28
- });
29
-
30
- export {
31
- ApiErrorRecovery,
32
- ApiErrorResponse,
33
- OpenapiResponseError,
34
- defaultOpenapiErrorLimits
35
- };
@@ -1,18 +0,0 @@
1
- import {
2
- AccountId
3
- } from "./chunk-SATWJKN6.js";
4
- import {
5
- Schema_exports
6
- } from "./chunk-FW5HBOIK.js";
7
-
8
- // src/contracts/provider-error.ts
9
- var ProviderError = class extends Schema_exports.TaggedError()("ProviderError", {
10
- reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
11
- status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
12
- accountId: Schema_exports.optional(AccountId)
13
- }) {
14
- };
15
-
16
- export {
17
- ProviderError
18
- };
@@ -1,29 +0,0 @@
1
- import {
2
- operationDeclaration
3
- } from "./chunk-PYUYJRSK.js";
4
-
5
- // src/implementation/protocol-operations.ts
6
- var protocolOperations = (operations, kinds = {}) => {
7
- const queries = {};
8
- const mutations = {};
9
- for (const [name, operation] of Object.entries(operations)) {
10
- const kind = Object.hasOwn(kinds, name) ? kinds[name] : operation.readOnly === true ? "query" : "mutation";
11
- const native = {
12
- description: operation.description,
13
- ...operation.title === void 0 ? {} : { title: operation.title },
14
- ...operation.annotations === void 0 ? {} : { annotations: operation.annotations },
15
- ...operation._meta === void 0 ? {} : { _meta: operation._meta },
16
- input: operation.input,
17
- run: operation.run
18
- };
19
- const output = Object.getOwnPropertyDescriptor(operation, "outputSchema");
20
- const withOutput = (target) => output === void 0 || output.get === void 0 && output.value === void 0 ? target : Object.defineProperty(target, "outputSchema", { ...output, enumerable: true });
21
- if (kind === "query") queries[name] = operationDeclaration(withOutput({ ...native, kind }));
22
- else mutations[name] = operationDeclaration(withOutput({ ...native, kind: "mutation" }));
23
- }
24
- return { queries, mutations };
25
- };
26
-
27
- export {
28
- protocolOperations
29
- };
@@ -1,63 +0,0 @@
1
- import {
2
- ProviderError
3
- } from "./chunk-W7D7WVSY.js";
4
- import {
5
- AccountId
6
- } from "./chunk-SATWJKN6.js";
7
- import {
8
- Option_exports,
9
- Schema_exports
10
- } from "./chunk-FW5HBOIK.js";
11
-
12
- // src/implementation/provider-error.ts
13
- function parseProviderError(error) {
14
- return Schema_exports.decodeUnknownOption(ProviderError)(error).pipe(
15
- Option_exports.map(({ reason, status, accountId }) => new ProviderError({ reason, status, accountId }))
16
- );
17
- }
18
- function httpProviderError(status, headers = {}) {
19
- if (status >= 500 && status <= 599) return new ProviderError({ reason: "unavailable", status });
20
- if (status === 401) return new ProviderError({ reason: "unauthorized", status });
21
- if (status === 429) return new ProviderError({ reason: "rate_limited", status });
22
- if (status !== 403) return void 0;
23
- const retry = headers["retry-after"];
24
- if (headers["x-ratelimit-remaining"] === "0" || retry !== void 0 && (/^\d+$/.test(retry) || Number.isFinite(Date.parse(retry))))
25
- return new ProviderError({ reason: "rate_limited", status });
26
- if (/\bBearer\b.*\berror="insufficient_scope"/i.test(headers["www-authenticate"] ?? ""))
27
- return new ProviderError({ reason: "forbidden", status });
28
- return new ProviderError({ reason: "rejected", status });
29
- }
30
- function accountProviderError(error, accountId) {
31
- const parsed = parseProviderError(error);
32
- const account = Schema_exports.decodeUnknownOption(AccountId)(accountId);
33
- if (Option_exports.isNone(parsed) || Option_exports.isNone(account)) return error;
34
- return new ProviderError({
35
- reason: parsed.value.reason,
36
- status: parsed.value.status,
37
- accountId: account.value
38
- });
39
- }
40
- function graphqlProviderError(errors, status) {
41
- const codes = errors.flatMap((error) => {
42
- const parsed = Schema_exports.decodeUnknownOption(
43
- Schema_exports.Struct({
44
- type: Schema_exports.optional(Schema_exports.String),
45
- extensions: Schema_exports.optional(Schema_exports.Struct({ code: Schema_exports.optional(Schema_exports.String) }))
46
- })
47
- )(error);
48
- return Option_exports.isSome(parsed) ? [parsed.value.type, parsed.value.extensions?.code] : [];
49
- });
50
- if (codes.includes("RATE_LIMITED") || codes.includes("TOO_MANY_REQUESTS"))
51
- return new ProviderError({ reason: "rate_limited", status });
52
- if (codes.includes("UNAUTHENTICATED"))
53
- return new ProviderError({ reason: "unauthorized", status });
54
- if (codes.includes("FORBIDDEN")) return new ProviderError({ reason: "forbidden", status });
55
- return void 0;
56
- }
57
-
58
- export {
59
- parseProviderError,
60
- httpProviderError,
61
- accountProviderError,
62
- graphqlProviderError
63
- };
@@ -1,10 +0,0 @@
1
- /** Authenticated, opaque continuation tokens tied to one installation, schema and query plan. */
2
- import { Effect } from "effect";
3
- import { AppDatabaseError } from "../contracts/database.js";
4
- /** Stable SHA-256 fingerprints contain no raw query arguments in logs or metadata keys. */
5
- export declare const fingerprint: (crypto: Crypto, value: string) => Effect.Effect<string, AppDatabaseError, never>;
6
- /** Capture a per-database key. Nonces are fresh, and malformed/tampered/cross-query cursors fail closed. */
7
- export declare const cursorCodec: (crypto: Crypto, bytes: Uint8Array) => Effect.Effect<{
8
- encode: (query: string, position: Uint8Array) => Effect.Effect<string, AppDatabaseError, never>;
9
- decode: (query: string, token: string) => Effect.Effect<Uint8Array<ArrayBufferLike>, AppDatabaseError, never>;
10
- }, AppDatabaseError, never>;
@@ -1,7 +0,0 @@
1
- /** Order-preserving scalar tuples. SQLite BLOB ordering supplies bounded prefix/range scans. */
2
- import { Effect } from "effect";
3
- import { AppDatabaseError, type Scalar } from "../contracts/database.js";
4
- /** Compare UTF-8 strings, booleans and finite doubles consistently, with absence before present values. */
5
- export declare const encodeIndexKey: (values: readonly (Scalar | null)[], maximum?: number) => Effect.Effect<Uint8Array<ArrayBuffer>, AppDatabaseError, never>;
6
- /** Exclusive upper bound for all tuples beginning with this prefix. */
7
- export declare const prefixEnd: (prefix: Uint8Array) => Uint8Array | undefined;
@@ -1,68 +0,0 @@
1
- import { Row, type DatabaseSession } from "../contracts/database.js";
2
- /** Index predicates are accumulated immutably, then checked against the declaration by the engine. */
3
- export interface IndexRange<Fields> {
4
- /** Constrain an index prefix field to one value. Null matches a cleared optional field. */
5
- readonly eq: <Key extends keyof Fields & string>(field: Key, value: Fields[Key] | null) => IndexRange<Fields>;
6
- /** Require a value greater than the bound on the next index field. */
7
- readonly gt: <Key extends keyof Fields & string>(field: Key, value: Fields[Key]) => IndexRange<Fields>;
8
- /** Require a value greater than or equal to the bound on the next index field. */
9
- readonly gte: <Key extends keyof Fields & string>(field: Key, value: Fields[Key]) => IndexRange<Fields>;
10
- /** Require a value less than the bound on the next index field. */
11
- readonly lt: <Key extends keyof Fields & string>(field: Key, value: Fields[Key]) => IndexRange<Fields>;
12
- /** Require a value less than or equal to the bound on the next index field. */
13
- readonly lte: <Key extends keyof Fields & string>(field: Key, value: Fields[Key]) => IndexRange<Fields>;
14
- }
15
- /** Bounded indexed reads; collect/count reject work beyond the invocation budget. */
16
- export interface Query<Row> {
17
- /** Choose ascending or descending index order without changing this query. */
18
- readonly order: (direction: "asc" | "desc") => Query<Row>;
19
- /** Read all matching rows within the invocation budget; exceeding it fails. */
20
- readonly collect: () => Promise<readonly Row[]>;
21
- /** Count matching rows within the scan budget; exceeding it fails. */
22
- readonly count: () => Promise<number>;
23
- /** Read the first matching row, or null when no row matches. */
24
- readonly first: () => Promise<Row | null>;
25
- /** Read at most count matching rows within the invocation budget. */
26
- readonly take: (count: number) => Promise<readonly Row[]>;
27
- /** Read one cursor page. Return its rows, continuation cursor and completion flag. */
28
- readonly paginate: (options: {
29
- readonly numItems: number;
30
- readonly cursor: string | null;
31
- }) => Promise<{
32
- readonly page: readonly Row[];
33
- readonly continueCursor: string | null;
34
- readonly isDone: boolean;
35
- }>;
36
- }
37
- /** Typed table operations exposed to authored queries. */
38
- export interface ReadTable<Row, Index extends string = string> {
39
- /** Read a complete row by ID, or null when it does not exist. */
40
- readonly get: (id: string) => Promise<Row | null>;
41
- /** Select a declared index or by_creation, with optional prefix and range constraints. */
42
- readonly withIndex: (index: Index | "by_creation", range?: (query: IndexRange<Row>) => IndexRange<Row>) => Query<Row>;
43
- }
44
- /** Writes are valid only inside their owning mutation. */
45
- export interface WriteTable<Row, Insert, Index extends string = string> extends ReadTable<Row, Index> {
46
- /** Insert authored fields and return the complete row with generated id, createdAt and updatedAt. */
47
- readonly insert: (value: Insert) => Promise<Row>;
48
- /** Patch authored fields and return the complete row, or null if the ID does not exist. */
49
- readonly update: (id: string, patch: Partial<Insert>) => Promise<Row | null>;
50
- /** Delete the row and return whether it existed. */
51
- readonly delete: (id: string) => Promise<boolean>;
52
- }
53
- /** Build an untyped transport facade; the author schema layer installs exact field and row decoders. */
54
- export declare const promiseTable: (session: DatabaseSession, table: string, signal: AbortSignal) => {
55
- get: (id: string) => Promise<{
56
- readonly [x: string]: string | number | boolean;
57
- } | null>;
58
- insert: (value: unknown) => Promise<{
59
- readonly [x: string]: string | number | boolean;
60
- }>;
61
- update: (id: string, patch: unknown) => Promise<{
62
- readonly [x: string]: string | number | boolean;
63
- } | null>;
64
- delete: (id: string) => Promise<boolean>;
65
- withIndex: (index: string, range?: (query: IndexRange<Row>) => IndexRange<Row>) => Query<{
66
- readonly [x: string]: string | number | boolean;
67
- }>;
68
- };
@@ -1,8 +0,0 @@
1
- /** Index-prefix equality followed by at most one field's lower and upper bounds. */
2
- import { Effect } from "effect";
3
- import { AppDatabaseError, type QueryPlan, type Table } from "../contracts/database.js";
4
- /** Produce half-open BLOB bounds; absent optional values do not satisfy ordinary range predicates. */
5
- export declare const queryBounds: (table: Table, plan: QueryPlan, maximum: number) => Effect.Effect<{
6
- lower: Uint8Array<ArrayBufferLike>;
7
- upper: Uint8Array<ArrayBufferLike> | undefined;
8
- }, AppDatabaseError, never>;
@@ -1,33 +0,0 @@
1
- /** Validate declarations and write values before touching SQLite. */
2
- import { Effect } from "effect";
3
- import { AppDatabaseError, DatabaseSchema, RowMetadata, type Field, type Row, type Scalar, type Table } from "../contracts/database.js";
4
- /** Built-in creation ordering and stable tie-breakers apply to every index. */
5
- export declare const indexesFor: (table: Table) => {
6
- name: string;
7
- fields: string[];
8
- }[];
9
- /** Metadata fields have stable string semantics and cannot be overwritten. */
10
- export declare const fieldFor: (table: Table, name: string) => Field | undefined;
11
- /** Finite numbers and well-formed strings keep JSON and index ordering consistent. */
12
- export declare const validScalar: (field: Field, value: unknown) => value is Scalar;
13
- /** Parse the whole schema, including references and composite-index definitions. */
14
- export declare const parseDatabaseSchema: (input: unknown) => Effect.Effect<{
15
- readonly [x: string]: {
16
- readonly fields: {
17
- readonly [x: string]: {
18
- readonly kind: "string" | "number" | "boolean" | "id" | "userId";
19
- readonly optional?: boolean | undefined;
20
- readonly default?: string | number | boolean | undefined;
21
- readonly references?: string | undefined;
22
- };
23
- };
24
- readonly indexes: readonly {
25
- readonly name: string;
26
- readonly fields: readonly [string, ...string[]];
27
- }[];
28
- };
29
- }, AppDatabaseError, never>;
30
- /** Canonical ordering for schema fingerprints and query-bound cursors. */
31
- export declare const canonicalSchema: (schema: DatabaseSchema) => string;
32
- /** Inserts apply declared defaults; updates reject unknown/metadata fields and clear optional values with null. */
33
- export declare const writeValue: (table: Table, values: Readonly<Record<string, Scalar | null>>, previous: Row | undefined, meta: typeof RowMetadata.Type) => Effect.Effect<Record<string, string | number | boolean>, AppDatabaseError, never>;
@@ -1,11 +0,0 @@
1
- /** Shared SQLite engine. Drivers, persistent paths and app ownership belong to the host. */
2
- import { Effect } from "effect";
3
- import type { SqlClient } from "effect/unstable/sql/SqlClient";
4
- import { AppDatabaseError, DatabaseLimits, type AppDatabase } from "../contracts/database.js";
5
- /** Open a database whose storage is owned by exactly one configured app. Schema changes fail closed. */
6
- export declare const makeSqliteDatabase: (options: {
7
- readonly sql: SqlClient;
8
- readonly schema: unknown;
9
- readonly crypto: Crypto;
10
- readonly limits?: DatabaseLimits;
11
- }) => Effect.Effect<AppDatabase, AppDatabaseError>;
@@ -1,4 +0,0 @@
1
- /** Portable, app-owned database engine and contracts. */
2
- export * from "./contracts/database.js";
3
- export { makeSqliteDatabase } from "./implementation/sqlite.js";
4
- export { promiseTable, type IndexRange, type Query, type ReadTable, type WriteTable, } from "./implementation/promise.js";
@@ -1,13 +0,0 @@
1
- /** Lazy operation discovery and resolution. Executables remain invocation-owned. */
2
- import type { Effect } from "effect";
3
- import type { HostedTool, HostedToolSummary } from "./host.js";
4
- import type { AppOperation } from "./operations.js";
5
- /** Tool names include their queries./mutations. prefix. Resolution never requires listing. */
6
- export interface DynamicTools {
7
- readonly list: () => Effect.Effect<readonly HostedTool[], unknown>;
8
- readonly resolve: (name: string) => Effect.Effect<AppOperation | undefined, unknown>;
9
- /** Names and descriptions without schemas. Omitted sources reduce list(). */
10
- readonly summaries?: () => Effect.Effect<readonly HostedToolSummary[], unknown>;
11
- /** One tool's full metadata without listing. Omitted sources search list(). */
12
- readonly describe?: (name: string) => Effect.Effect<HostedTool | undefined, unknown>;
13
- }
@@ -1,68 +0,0 @@
1
- /** Native app data boundary. Hosts bind a configured app before exposing this capability. */
2
- import { Schema, type Effect } from "effect";
3
- import type { RowMetadata, ReadTable, WriteTable } from "../../../app-data/src/index.js";
4
- import type { Fields, ObjectValue } from "../implementation/schema.js";
5
- import type { DatabaseSchema, DatabaseSession, AppDatabaseError } from "../../../app-data/src/contracts/database.js";
6
- /** Names for authored operations and tables. */
7
- export declare const StorageName: Schema.NonEmptyString;
8
- declare const AppStorageUnavailable_base: Schema.Class<AppStorageUnavailable, Schema.TaggedStruct<"AppStorageUnavailable", {}>, import("effect/Cause").YieldableError>;
9
- /** Storage is not configured on this host. */
10
- export declare class AppStorageUnavailable extends AppStorageUnavailable_base {
11
- }
12
- declare const AppStorageError_base: Schema.Class<AppStorageError, Schema.TaggedStruct<"AppStorageError", {}>, import("effect/Cause").YieldableError>;
13
- /** App storage operations never expose SQL, documents or credentials in failures. */
14
- export declare class AppStorageError extends AppStorageError_base {
15
- }
16
- /** The adapter owns the database connection and transaction for the whole authored invocation. */
17
- export interface AppStorage {
18
- readonly read: <A, E>(schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError | AppStorageUnavailable | AppStorageError>;
19
- readonly mutate: <A, E>(schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError | AppStorageUnavailable | AppStorageError>;
20
- }
21
- type InputValue<F extends Fields> = {
22
- readonly [K in keyof F as F[K]["optionalValue"] extends true ? never : F[K] extends {
23
- readonly hasDefault: true;
24
- } ? never : K]: Exclude<import("../implementation/schema.js").Infer<F[K]>, undefined>;
25
- } & {
26
- readonly [K in keyof F as F[K]["optionalValue"] extends true ? K : F[K] extends {
27
- readonly hasDefault: true;
28
- } ? K : never]?: Exclude<import("../implementation/schema.js").Infer<F[K]>, undefined> | (F[K]["optionalValue"] extends true ? null : F[K] extends {
29
- readonly inputOptional: true;
30
- } ? null : never) | undefined;
31
- };
32
- /** Typed table declaration; indexes refer only to authored or host metadata fields. */
33
- export interface Table<F extends Fields, Index extends string = never> {
34
- readonly fields: F;
35
- readonly indexes: ReadonlyArray<{
36
- readonly name: string;
37
- readonly fields: readonly string[];
38
- }>;
39
- readonly index: <Name extends string>(name: Name, fields: readonly [
40
- (keyof F & string) | keyof typeof RowMetadata.Type,
41
- ...((keyof F & string) | keyof typeof RowMetadata.Type)[]
42
- ]) => Table<F, Index | Name>;
43
- }
44
- /** Structural table catalog accepted at the author boundary. */
45
- export type Tables = Readonly<Record<string, {
46
- readonly fields: Fields;
47
- readonly indexes: ReadonlyArray<{
48
- readonly name: string;
49
- readonly fields: readonly string[];
50
- }>;
51
- }>>;
52
- /** Generated row metadata is read-only and unavailable on inserts. */
53
- export type RowOf<T extends Tables[string]> = ObjectValue<T["fields"]> & typeof RowMetadata.Type;
54
- type IndexOf<T> = T extends Table<Fields, infer I> ? I : string;
55
- /** Queries receive only read methods. */
56
- export type DatabaseReader<T extends Tables> = {
57
- readonly [K in keyof T]: ReadTable<RowOf<T[K]>, IndexOf<T[K]>>;
58
- };
59
- /** Mutation methods stay inside one native SQLite transaction. */
60
- export type Database<T extends Tables> = {
61
- readonly [K in keyof T]: WriteTable<RowOf<T[K]>, InputValue<T[K]["fields"]>, IndexOf<T[K]>>;
62
- };
63
- /** Pure database declaration shared by requirements and derived handler contexts. */
64
- export interface DatabaseDefinition<T extends Tables = Tables> {
65
- readonly schema: DatabaseSchema;
66
- readonly tables: T;
67
- }
68
- export {};
@@ -1,151 +0,0 @@
1
- /** Combine account-bound protocol operations without changing their upstream inputs. */
2
- import { Effect, Schema } from "effect";
3
- import type { DynamicTools } from "../contracts/dynamic-tools.js";
4
- import type { AppOperation, OperationContext } from "../contracts/operations.js";
5
- import { type JsonValue } from "../contracts/schema.js";
6
- import { type Operation } from "./operations.js";
7
- type Operations = {
8
- readonly queries?: Readonly<Record<string, Operation<JsonValue, unknown, "query", OperationContext>>>;
9
- readonly dynamicTools?: DynamicTools;
10
- readonly mutations?: Readonly<Record<string, Operation<JsonValue, unknown, "mutation", OperationContext>>>;
11
- };
12
- /**
13
- * Discover each selected account's protocol operations and combine matching names.
14
- * Calls take { accountId, input }; each branch retains its account's input schema,
15
- * credentials, approval and output validation. Empty selections expose no operations.
16
- * Discovery is sequential and cancellation follows the caller's signal.
17
- */
18
- export declare const accountOperations: <Account extends {
19
- readonly id: string;
20
- }>(accounts: readonly Account[], discover: (account: Account) => Promise<Operations>, options: {
21
- readonly signal: AbortSignal;
22
- }) => Promise<{
23
- queries: {
24
- [k: string]: Operation<{
25
- readonly accountId: string;
26
- readonly input: unknown;
27
- }, unknown, "query", import("../index.js").AppContext>;
28
- };
29
- mutations: {
30
- [k: string]: Operation<{
31
- readonly accountId: string;
32
- readonly input: unknown;
33
- }, unknown, "mutation", import("../index.js").AppContext>;
34
- };
35
- } | {
36
- dynamicTools: {
37
- list: () => Effect.Effect<{
38
- readonly name: string;
39
- readonly description: string;
40
- readonly inputSchema: {
41
- readonly [x: string]: Schema.Json;
42
- };
43
- readonly _meta?: {
44
- readonly [x: string]: Schema.Json;
45
- };
46
- readonly title?: string;
47
- readonly outputSchema?: {
48
- readonly [x: string]: Schema.Json;
49
- };
50
- readonly annotations?: {
51
- readonly title?: string;
52
- readonly readOnlyHint?: boolean;
53
- readonly destructiveHint?: boolean;
54
- readonly idempotentHint?: boolean;
55
- readonly openWorldHint?: boolean;
56
- };
57
- readonly schedules?: readonly {
58
- readonly name: string;
59
- readonly timing: {
60
- readonly kind: "interval";
61
- readonly milliseconds: number;
62
- } | {
63
- readonly kind: "cron";
64
- readonly calendar: {
65
- readonly expression: string;
66
- readonly timezone: string;
67
- };
68
- };
69
- readonly input: Schema.Json;
70
- }[];
71
- readonly readOnly?: boolean;
72
- }[], unknown, never>;
73
- summaries: () => Effect.Effect<{
74
- readonly name: string;
75
- readonly description: string;
76
- readonly title?: string;
77
- readonly annotations?: {
78
- readonly title?: string;
79
- readonly readOnlyHint?: boolean;
80
- readonly destructiveHint?: boolean;
81
- readonly idempotentHint?: boolean;
82
- readonly openWorldHint?: boolean;
83
- };
84
- readonly schedules?: readonly {
85
- readonly name: string;
86
- readonly timing: {
87
- readonly kind: "interval";
88
- readonly milliseconds: number;
89
- } | {
90
- readonly kind: "cron";
91
- readonly calendar: {
92
- readonly expression: string;
93
- readonly timezone: string;
94
- };
95
- };
96
- readonly input: Schema.Json;
97
- }[];
98
- readonly readOnly?: boolean;
99
- }[], unknown, never>;
100
- describe: (name: string) => Effect.Effect<{
101
- readonly name: string;
102
- readonly description: string;
103
- readonly inputSchema: {
104
- readonly [x: string]: Schema.Json;
105
- };
106
- readonly _meta?: {
107
- readonly [x: string]: Schema.Json;
108
- };
109
- readonly title?: string;
110
- readonly outputSchema?: {
111
- readonly [x: string]: Schema.Json;
112
- };
113
- readonly annotations?: {
114
- readonly title?: string;
115
- readonly readOnlyHint?: boolean;
116
- readonly destructiveHint?: boolean;
117
- readonly idempotentHint?: boolean;
118
- readonly openWorldHint?: boolean;
119
- };
120
- readonly schedules?: readonly {
121
- readonly name: string;
122
- readonly timing: {
123
- readonly kind: "interval";
124
- readonly milliseconds: number;
125
- } | {
126
- readonly kind: "cron";
127
- readonly calendar: {
128
- readonly expression: string;
129
- readonly timezone: string;
130
- };
131
- };
132
- readonly input: Schema.Json;
133
- }[];
134
- readonly readOnly?: boolean;
135
- } | undefined, unknown, never>;
136
- resolve: (name: string) => Effect.Effect<AppOperation<unknown, unknown> | undefined, unknown, never>;
137
- };
138
- queries: {
139
- [k: string]: Operation<{
140
- readonly accountId: string;
141
- readonly input: unknown;
142
- }, unknown, "query", import("../index.js").AppContext>;
143
- };
144
- mutations: {
145
- [k: string]: Operation<{
146
- readonly accountId: string;
147
- readonly input: unknown;
148
- }, unknown, "mutation", import("../index.js").AppContext>;
149
- };
150
- }>;
151
- export {};
@@ -1,8 +0,0 @@
1
- import { HostedTool } from "../contracts/host.js";
2
- import type { DynamicTools } from "../contracts/dynamic-tools.js";
3
- import { type OperationDeclaration } from "./operations.js";
4
- /** Declare metadata discovery separately from executable resolution. Names are fully qualified. */
5
- export declare const dynamicTools: (source: {
6
- readonly list: () => Promise<readonly HostedTool[]>;
7
- readonly resolve: (name: string) => Promise<OperationDeclaration<"query" | "mutation"> | undefined>;
8
- }) => DynamicTools;
@@ -1,13 +0,0 @@
1
- import { type DatabaseSession } from "../../../app-data/src/index.js";
2
- import { type AppStorage } from "../contracts/storage.js";
3
- import type { DatabaseDefinition, Database, Table, Tables } from "../contracts/storage.js";
4
- import { type Fields } from "./schema.js";
5
- export type { DatabaseDefinition, Database, DatabaseReader, Table, Tables, RowOf, } from "../contracts/storage.js";
6
- /** Declare scalar columns using the same schemas as operation inputs. */
7
- export declare const table: <const F extends Fields>(fields: F) => Table<F>;
8
- /** Build a fresh Promise database facade for one authorized invocation. */
9
- export declare const authorDatabase: <T extends Tables>(tables: T, session: DatabaseSession, signal: AbortSignal, writable: boolean) => Database<T>;
10
- /** Declare storage independently of handlers; the host binds each invocation's database. */
11
- export declare const defineDatabase: <const T extends Tables>(tables: T) => DatabaseDefinition<T>;
12
- /** Explicit missing capability, never a fallback to another app's data. */
13
- export declare const unavailableStorage: AppStorage;