apps 0.0.1-beta.1 → 0.0.1-beta.11

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 (118) hide show
  1. package/README.md +65 -43
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
  5. package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
  6. package/js/{chunk-2HHMABB6.js → chunk-5T57N25Q.js} +61 -13
  7. package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
  8. package/js/{chunk-X7SFGU4Q.js → chunk-EFAPIRVB.js} +28 -9
  9. package/js/chunk-GPFVWWDZ.js +209 -0
  10. package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
  11. package/js/{chunk-ZTFQHGEB.js → chunk-IPI4MFSN.js} +3 -5
  12. package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
  13. package/js/{chunk-IHQ4ML7K.js → chunk-KRSCJDTW.js} +586 -111
  14. package/js/chunk-KUMBKVJD.js +39 -0
  15. package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
  16. package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
  17. package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
  18. package/js/chunk-NKLWZJLE.js +172 -0
  19. package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
  20. package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
  21. package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
  22. package/js/chunk-R3EV5FTO.js +97 -0
  23. package/js/{chunk-KOXMLKTM.js → chunk-RELFXUOO.js} +308 -316
  24. package/js/{chunk-6YBRWRK3.js → chunk-RFVIONFX.js} +43 -14
  25. package/js/{chunk-RBAC33PQ.js → chunk-TYVDBQSI.js} +58 -83
  26. package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
  27. package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
  28. package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
  29. package/js/{chunk-6IIO4NPI.js → chunk-WVVV4TX2.js} +21 -9
  30. package/js/{chunk-G7IE6BKC.js → chunk-YBRC463S.js} +8 -8
  31. package/js/chunk-Z2QY3YTF.js +507 -0
  32. package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
  33. package/js/client.js +10 -26
  34. package/js/contracts.js +70 -15
  35. package/js/effect.js +19 -19
  36. package/js/es-APDZKREY.js +40968 -0
  37. package/js/graphql.js +34 -39
  38. package/js/host.js +23 -23
  39. package/js/index.js +199 -195
  40. package/js/mcp/effect.js +21 -21
  41. package/js/mcp/stdio.js +25 -25
  42. package/js/mcp.js +60 -44
  43. package/js/openapi.js +826 -41682
  44. package/js/react.js +3 -3
  45. package/js/skills/effect.js +3 -4
  46. package/js/skills.js +53 -17
  47. package/js/storage/facet.js +4 -4
  48. package/js/ui/auth/contracts.js +8 -9
  49. package/js/ui/auth.js +16 -14
  50. package/js/ui/contracts.js +4 -4
  51. package/js/ui/serving.js +9 -8
  52. package/package.json +1 -1
  53. package/runtime.json +1 -1
  54. package/types/app-cache/src/contracts/cache.d.ts +42 -2
  55. package/types/app-cache/src/index.d.ts +59 -1
  56. package/types/app-data/src/contracts/database.d.ts +33 -6
  57. package/types/app-data/src/implementation/schema.d.ts +2 -17
  58. package/types/apps/src/contracts/app.d.ts +7 -6
  59. package/types/apps/src/contracts/cache.d.ts +4 -1
  60. package/types/apps/src/contracts/failure.d.ts +25 -0
  61. package/types/apps/src/contracts/host.d.ts +34 -679
  62. package/types/apps/src/contracts/mcp.d.ts +16 -0
  63. package/types/apps/src/contracts/openapi.d.ts +11 -1
  64. package/types/apps/src/contracts/operations.d.ts +0 -5
  65. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  66. package/types/apps/src/contracts/protocols/1.d.ts +1589 -0
  67. package/types/apps/src/contracts/protocols/2.d.ts +668 -0
  68. package/types/apps/src/contracts/protocols/3.d.ts +676 -0
  69. package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
  70. package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
  71. package/types/apps/src/contracts/provider.d.ts +56 -5
  72. package/types/apps/src/contracts/router.d.ts +59 -0
  73. package/types/apps/src/contracts/skills.d.ts +17 -8
  74. package/types/apps/src/contracts/storage.d.ts +3 -3
  75. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  76. package/types/apps/src/contracts/workflows.d.ts +34 -3
  77. package/types/apps/src/graphql.d.ts +1 -3
  78. package/types/apps/src/implementation/account-router.d.ts +12 -0
  79. package/types/apps/src/implementation/app.d.ts +5 -4
  80. package/types/apps/src/implementation/cache.d.ts +3 -1
  81. package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
  82. package/types/apps/src/implementation/elicitation.d.ts +1 -1
  83. package/types/apps/src/implementation/failure-detail.d.ts +25 -0
  84. package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
  85. package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
  86. package/types/apps/src/implementation/mcp-client.d.ts +35 -19
  87. package/types/apps/src/implementation/mcp.d.ts +35 -19
  88. package/types/apps/src/implementation/openapi-compile.d.ts +3 -2
  89. package/types/apps/src/implementation/openapi-document.d.ts +0 -2
  90. package/types/apps/src/implementation/openapi-names.d.ts +18 -0
  91. package/types/apps/src/implementation/openapi-request.d.ts +0 -1
  92. package/types/apps/src/implementation/openapi-source.d.ts +7 -7
  93. package/types/apps/src/implementation/operations.d.ts +26 -3
  94. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  95. package/types/apps/src/implementation/provider.d.ts +9 -4
  96. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  97. package/types/apps/src/implementation/router.d.ts +59 -0
  98. package/types/apps/src/implementation/schema.d.ts +5 -6
  99. package/types/apps/src/implementation/storage.d.ts +5 -3
  100. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  101. package/types/apps/src/implementation/ui-auth.d.ts +11 -5
  102. package/types/apps/src/implementation/ui-serving.d.ts +4 -2
  103. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  104. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  105. package/types/apps/src/index.d.ts +21 -6
  106. package/types/apps/src/mcp-stdio.d.ts +2 -5
  107. package/types/apps/src/mcp.d.ts +5 -4
  108. package/types/apps/src/openapi.d.ts +6 -6
  109. package/types/apps/src/skills.d.ts +6 -3
  110. package/types/apps/src/ui-auth.d.ts +2 -2
  111. package/types/telemetry/src/browser-operations.d.ts +5 -2
  112. package/js/chunk-PZ36XMXW.js +0 -93
  113. package/js/chunk-SWPD52J7.js +0 -35
  114. package/js/chunk-TE4KO4HI.js +0 -47
  115. package/js/chunk-W7D7WVSY.js +0 -18
  116. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  117. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  118. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
@@ -16,7 +16,17 @@ export declare const cacheLimits: {
16
16
  readonly totalEntries: 100000;
17
17
  readonly retentionMs: number;
18
18
  readonly loadTimeoutMs: 90000;
19
- readonly leaseMs: 120000;
19
+ /**
20
+ * A loader's lease lapses this long after its host last renewed it. Hosts renew every
21
+ * `renewMs` while the invocation that claimed it runs, so a stalled or lost holder frees the
22
+ * key well inside an MCP execute budget.
23
+ */
24
+ readonly leaseMs: 15000;
25
+ readonly renewMs: 5000;
26
+ /** The longest a caller waits on another loader before loading for itself without publishing. */
27
+ readonly waitMs: 10000;
28
+ /** Bound for one command to a host store; a lost reply fails instead of holding its caller. */
29
+ readonly commandTimeoutMs: 10000;
20
30
  };
21
31
  /** Stored values carry a version independent of their freshness clock. */
22
32
  export declare const CacheEntry: Schema.Struct<{
@@ -27,10 +37,31 @@ export declare const CacheEntry: Schema.Struct<{
27
37
  }>;
28
38
  /** Decoded cache value envelope. */
29
39
  export type CacheEntry = typeof CacheEntry.Type;
30
- /** Publication requires the lease acquired against the previously observed version. */
40
+ /** The current entry, and a lease when this caller now owns its load. */
41
+ export declare const CacheAcquired: Schema.Struct<{
42
+ readonly entry: Schema.NullOr<Schema.Struct<{
43
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
44
+ readonly version: Schema.String;
45
+ readonly freshUntil: Schema.Finite;
46
+ readonly staleUntil: Schema.Finite;
47
+ }>>;
48
+ readonly lease: Schema.NullOr<Schema.String>;
49
+ }>;
50
+ /**
51
+ * Publication requires the lease acquired against the previously observed version.
52
+ * `acquire` reads one entry and claims its load in the same transaction, so a cache
53
+ * miss costs one round trip. `read` and `claim` remain for builds retained before it.
54
+ */
31
55
  export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
32
56
  readonly operation: Schema.Literal<"read">;
33
57
  readonly keys: Schema.$Array<Schema.String>;
58
+ }>, Schema.Struct<{
59
+ readonly operation: Schema.Literal<"acquire">;
60
+ readonly key: Schema.String;
61
+ /** Claim even a fresh entry, as an explicit refresh does. */
62
+ readonly refresh: Schema.Boolean;
63
+ /** Claim only while the entry still has this version. Absent accepts the current one. */
64
+ readonly version: Schema.optionalKey<Schema.NullOr<Schema.String>>;
34
65
  }>, Schema.Struct<{
35
66
  readonly operation: Schema.Literal<"claim">;
36
67
  readonly key: Schema.String;
@@ -49,6 +80,10 @@ export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
49
80
  readonly operation: Schema.Literal<"release">;
50
81
  readonly key: Schema.String;
51
82
  readonly lease: Schema.String;
83
+ }>, Schema.Struct<{
84
+ readonly operation: Schema.Literal<"renew">;
85
+ readonly key: Schema.String;
86
+ readonly lease: Schema.String;
52
87
  }>, Schema.Struct<{
53
88
  readonly operation: Schema.Literal<"write">;
54
89
  readonly entries: Schema.$Array<Schema.Struct<{
@@ -68,6 +103,11 @@ export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
68
103
  export type CacheCommand = typeof CacheCommand.Type;
69
104
  /** Replies remain JSON across Worker RPC and are decoded by each caller. */
70
105
  export type CacheTransport = (command: CacheCommand) => Effect.Effect<Schema.Json, CacheError>;
106
+ /**
107
+ * Whether a command replaced or removed retained data: a published refresh, a direct write or an
108
+ * invalidation. Hosts report these so results evaluated from the earlier data are not reused.
109
+ */
110
+ export declare const changesCache: (command: unknown) => boolean;
71
111
  /** Safe protocol envelope used at process boundaries. */
72
112
  export declare const CacheReply: Schema.Union<readonly [Schema.Struct<{
73
113
  readonly ok: Schema.Literal<true>;
@@ -13,7 +13,9 @@ export interface CacheGet<A> {
13
13
  readonly load: Effect.Effect<A, unknown>;
14
14
  }
15
15
  /** Create a scoped cache client; a background runner must retain all task resources until completion. */
16
- export declare const makeCache: (transport: CacheTransport, background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>, scope?: Schema.Json) => {
16
+ export declare const makeCache: (host: CacheTransport, background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>, scope?: Schema.Json,
17
+ /** The caller's own deadline, when the host supplies one. Waiting never runs past it. */
18
+ deadline?: number) => {
17
19
  /** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
18
20
  read: (keys: readonly Schema.Json[]) => Effect.Effect<readonly ({
19
21
  readonly value: Schema.Json;
@@ -33,3 +35,59 @@ export declare const makeCache: (transport: CacheTransport, background: (task: E
33
35
  /** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
34
36
  revalidate: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
35
37
  };
38
+ /**
39
+ * Host-side lease ownership for one app invocation. Leases the invocation claims are renewed while
40
+ * it runs, so a slow load keeps its key, and released when the host ends the invocation, including
41
+ * interrupted and cancelled ones and loads whose own release never arrived. A holder that stops
42
+ * running, or whose store channel stops answering, loses its lease within `leaseMs`.
43
+ */
44
+ export declare const holdLeases: (transport: CacheTransport) => Effect.Effect<{
45
+ /** Use for every command of the invocation. Each command is bounded by `commandTimeoutMs`. */
46
+ transport: (input: {
47
+ readonly operation: "read";
48
+ readonly keys: readonly string[];
49
+ } | {
50
+ readonly operation: "acquire";
51
+ readonly key: string;
52
+ readonly refresh: boolean;
53
+ readonly version?: string | null;
54
+ } | {
55
+ readonly operation: "claim";
56
+ readonly key: string;
57
+ readonly version: string | null;
58
+ } | {
59
+ readonly operation: "publish";
60
+ readonly key: string;
61
+ readonly lease: string;
62
+ readonly entry: {
63
+ readonly value: Schema.Json;
64
+ readonly version: string;
65
+ readonly freshUntil: number;
66
+ readonly staleUntil: number;
67
+ };
68
+ } | {
69
+ readonly operation: "release";
70
+ readonly key: string;
71
+ readonly lease: string;
72
+ } | {
73
+ readonly operation: "renew";
74
+ readonly key: string;
75
+ readonly lease: string;
76
+ } | {
77
+ readonly operation: "write";
78
+ readonly entries: readonly {
79
+ readonly key: string;
80
+ readonly entry: {
81
+ readonly value: Schema.Json;
82
+ readonly version: string;
83
+ readonly freshUntil: number;
84
+ readonly staleUntil: number;
85
+ };
86
+ }[];
87
+ } | {
88
+ readonly operation: "invalidate";
89
+ readonly key: string;
90
+ }) => Effect.Effect<Schema.Json, CacheError, never>;
91
+ /** Stop renewing and release every lease the invocation still holds. */
92
+ close: Effect.Effect<void, never, never>;
93
+ }, never, never>;
@@ -157,6 +157,33 @@ export declare const DatabaseLimits: Schema.Struct<{
157
157
  export type DatabaseLimits = typeof DatabaseLimits.Type;
158
158
  /** Current per-invocation budgets, shared by every database adapter. */
159
159
  export declare const defaultDatabaseLimits: DatabaseLimits;
160
+ /**
161
+ * The budget a query or mutation exhausted. `pageSize` bounds one take(n) or paginate call;
162
+ * `valueBytes` bounds one stored row; the rest accumulate across the whole invocation.
163
+ */
164
+ export declare const DatabaseLimit: Schema.Literals<readonly ["scanCalls", "directGets", "rowsRead", "rowsReturned", "pageSize", "bytesRead", "writes", "valueBytes"]>;
165
+ export type DatabaseLimit = typeof DatabaseLimit.Type;
166
+ declare const DatabaseLimitExceeded_base: Schema.Class<DatabaseLimitExceeded, Schema.TaggedStruct<"DatabaseLimitExceeded", {
167
+ readonly limit: Schema.Literals<readonly ["scanCalls", "directGets", "rowsRead", "rowsReturned", "pageSize", "bytesRead", "writes", "valueBytes"]>;
168
+ readonly maximum: Schema.Int;
169
+ readonly requested: Schema.Int;
170
+ }>, import("effect/Cause").YieldableError>;
171
+ /** A query or mutation exceeded one of its database budgets. Nothing it wrote is committed. */
172
+ export declare class DatabaseLimitExceeded extends DatabaseLimitExceeded_base {
173
+ get message(): string;
174
+ }
175
+ /** Host-owned row metadata that authored tables cannot declare. */
176
+ export declare const reservedFieldNames: readonly ["id", "createdAt", "updatedAt"];
177
+ declare const DatabaseFieldReserved_base: Schema.Class<DatabaseFieldReserved, Schema.TaggedStruct<"DatabaseFieldReserved", {
178
+ readonly table: Schema.String;
179
+ readonly field: Schema.Literals<readonly ["id", "createdAt", "updatedAt"]>;
180
+ }>, import("effect/Cause").YieldableError>;
181
+ /** A table declared a field the host adds to every row. */
182
+ export declare class DatabaseFieldReserved extends DatabaseFieldReserved_base {
183
+ get message(): string;
184
+ }
185
+ /** Failures a database session reports to authored code and its host. */
186
+ export type DatabaseError = AppDatabaseError | DatabaseLimitExceeded;
160
187
  /** Host resource bounds outside an individual database transaction. Durations are milliseconds. */
161
188
  export declare const DatabaseRuntimeLimits: Schema.Struct<{
162
189
  readonly maxCursorChars: Schema.Int;
@@ -173,21 +200,21 @@ export declare const defaultDatabaseRuntimeLimits: {
173
200
  /** The host binds one database and read/write authority for the entire invocation. */
174
201
  export interface DatabaseSession {
175
202
  /** Host-only idempotency receipt, committed atomically with the mutation and validated result. */
176
- readonly once: <E, R>(key: string, fingerprint: string, work: () => Effect.Effect<Schema.Json, E, R>) => Effect.Effect<Schema.Json, E | AppDatabaseError, R>;
203
+ readonly once: <E, R>(key: string, fingerprint: string, work: () => Effect.Effect<Schema.Json, E, R>) => Effect.Effect<Schema.Json, E | DatabaseError, R>;
177
204
  readonly readTables: ReadonlySet<string>;
178
205
  readonly changedTables: ReadonlySet<string>;
179
- readonly execute: (operation: DatabaseOperation) => Effect.Effect<OperationResult, AppDatabaseError>;
206
+ readonly execute: (operation: DatabaseOperation) => Effect.Effect<OperationResult, DatabaseError>;
180
207
  }
181
208
  /** Native operation scope owns snapshot consistency, write rollback and commit notifications. */
182
209
  export interface AppDatabase {
183
210
  readonly schema: DatabaseSchema;
184
211
  readonly schemaHash: string;
185
- readonly read: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | AppDatabaseError, R>;
186
- readonly mutate: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | AppDatabaseError, R>;
212
+ readonly read: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | DatabaseError, R>;
213
+ readonly mutate: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | DatabaseError, R>;
187
214
  }
188
215
  /** Product-independent app partitions. A host supplies persistent storage; callers never choose filenames. */
189
216
  export interface AppDatabases {
190
- readonly read: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError>;
191
- readonly mutate: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError>;
217
+ readonly read: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError>;
218
+ readonly mutate: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError>;
192
219
  }
193
220
  export {};
@@ -1,6 +1,6 @@
1
1
  /** Validate declarations and write values before touching SQLite. */
2
2
  import { Effect } from "effect";
3
- import { AppDatabaseError, DatabaseSchema, RowMetadata, type Field, type Row, type Scalar, type Table } from "../contracts/database.js";
3
+ import { AppDatabaseError, DatabaseFieldReserved, DatabaseSchema, RowMetadata, type Field, type Row, type Scalar, type Table } from "../contracts/database.js";
4
4
  /** Built-in creation ordering and stable tie-breakers apply to every index. */
5
5
  export declare const indexesFor: (table: Table) => {
6
6
  name: string;
@@ -11,22 +11,7 @@ export declare const fieldFor: (table: Table, name: string) => Field | undefined
11
11
  /** Finite numbers and well-formed strings keep JSON and index ordering consistent. */
12
12
  export declare const validScalar: (field: Field, value: unknown) => value is Scalar;
13
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>;
14
+ export declare const parseDatabaseSchema: (input: unknown) => Effect.Effect<DatabaseSchema, AppDatabaseError | DatabaseFieldReserved>;
30
15
  /** Canonical ordering for schema fingerprints and query-bound cursors. */
31
16
  export declare const canonicalSchema: (schema: DatabaseSchema) => string;
32
17
  /** Inserts apply declared defaults; updates reject unknown/metadata fields and clear optional values with null. */
@@ -3,7 +3,6 @@ import type { DatabaseDefinition } from "./storage.js";
3
3
  /** Native app contracts; factories and handlers compose in the host's Effect runtime. */
4
4
  import { type Effect, Schema } from "effect";
5
5
  import type { OperationSchedule } from "./schedules.js";
6
- import type { AppOperation } from "./operations.js";
7
6
  import type { AccountOf, AuthMethods, ManyAccounts, Provider } from "./provider.js";
8
7
  import type { AppWorkflow, WorkflowReads } from "./workflows.js";
9
8
  import type { Elicit } from "./elicitation.js";
@@ -11,8 +10,8 @@ import type { Elicit } from "./elicitation.js";
11
10
  type Handler<Context> = (context: Context, input: never) => Effect.Effect<unknown, unknown>;
12
11
  /** App capabilities share one account context. Package metadata belongs in package.json. */
13
12
  export interface AppDefinition<Context> {
14
- /** Optional dynamic tools; resolution does not enumerate the catalog. */
15
- readonly dynamicTools?: import("./dynamic-tools.js").DynamicTools;
13
+ /** The app's root router. Its keys form tool paths such as `issues.list`. */
14
+ readonly tools?: import("./router.js").AppRouter | import("./router.js").DynamicRouter;
16
15
  /** Omission reads packaged skills/. An explicit catalog replaces that default, including []. */
17
16
  readonly skills?: readonly AppSkillSource[];
18
17
  /** Optional lazy skills, added to the static catalog. Only skill reads call them. */
@@ -21,8 +20,6 @@ export interface AppDefinition<Context> {
21
20
  readonly schedules?: Readonly<Record<string, Omit<OperationSchedule, "name"> & {
22
21
  readonly tool: string;
23
22
  }>>;
24
- readonly queries?: Readonly<Record<string, AppOperation>>;
25
- readonly mutations?: Readonly<Record<string, AppOperation>>;
26
23
  readonly webhooks?: Readonly<Record<string, {
27
24
  readonly account: string;
28
25
  readonly config: Schema.Decoder<unknown>;
@@ -46,7 +43,11 @@ export interface BoundContext<Slots extends AccountSlots> {
46
43
  readonly workflows: WorkflowReads;
47
44
  /** Ask for user input during this tool call. Unavailable during discovery and after the invocation closes. */
48
45
  readonly elicit: Elicit;
49
- /** Invocation-owned HTTP requests with trace propagation and host cancellation. */
46
+ /**
47
+ * Invocation-owned HTTP requests with trace propagation and host cancellation. It lasts until the
48
+ * invocation and every app cache refresh it started in the background have ended, so a catalog
49
+ * loader given this fetch can refresh after the reply.
50
+ */
50
51
  readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
51
52
  /** Host cancellation for this invocation. Pass it to fetch and other interruptible APIs. */
52
53
  readonly signal: AbortSignal;
@@ -29,7 +29,10 @@ export interface AppCache {
29
29
  readonly value: JsonValue;
30
30
  }[], retention: Duration.Input) => Promise<void>;
31
31
  readonly invalidate: (key: JsonValue) => Promise<void>;
32
- /** Uses the current bound credentials' fingerprint, never just the saved account ID. */
32
+ /**
33
+ * Scope entries to a bound account and its credential generation. Token renewal keeps the
34
+ * entries; reconnecting or replacing the account's credentials starts an empty scope.
35
+ */
33
36
  readonly forAccount: (account: {
34
37
  readonly id: string;
35
38
  }) => AppCache;
@@ -0,0 +1,25 @@
1
+ /** Failure detail that crosses the runtime boundary to the app's own caller. */
2
+ import { Schema } from "effect";
3
+ /** Longest failure message carried across the runtime boundary. */
4
+ export declare const maxFailureMessageLength = 2048;
5
+ /**
6
+ * `app` for errors thrown by authored code, `storage` for app data failures the host raised, and
7
+ * `service` for an external API the app called through a framework helper.
8
+ */
9
+ export declare const FailureSource: Schema.Literals<readonly ["app", "storage", "service"]>;
10
+ /** The thrown error's name, such as `TypeError`, or the host error's tag. */
11
+ export declare const FailureName: Schema.String;
12
+ /** A stable host failure code, such as an app data reason. */
13
+ export declare const FailureCode: Schema.String;
14
+ /** Bounded, with the invocation's account secrets replaced. */
15
+ export declare const FailureMessage: Schema.String;
16
+ /**
17
+ * The error an app's own code raised, or the specific host failure it hit. Stacks and cause
18
+ * values stay private. Builds from before these fields existed send none.
19
+ */
20
+ export declare const FailureDetail: {
21
+ source: Schema.optionalKey<Schema.Literals<readonly ["app", "storage", "service"]>>;
22
+ errorName: Schema.optionalKey<Schema.String>;
23
+ code: Schema.optionalKey<Schema.String>;
24
+ message: Schema.optionalKey<Schema.String>;
25
+ };