apps 0.0.1-beta.2 → 0.0.1-beta.21

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 (119) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
  4. package/js/{chunk-WFSQXYUT.js → chunk-4QQ62BVS.js} +37 -3
  5. package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
  6. package/js/chunk-625MBYU4.js +524 -0
  7. package/js/{chunk-RN2MXB4R.js → chunk-BLI53LPN.js} +28 -9
  8. package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
  9. package/js/{chunk-J7O55ZV7.js → chunk-CHAK4P5C.js} +317 -176
  10. package/js/{chunk-HDTGZWP2.js → chunk-CMRKLZZY.js} +8 -8
  11. package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
  12. package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
  13. package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
  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-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
  19. package/js/chunk-NMKHTJOQ.js +254 -0
  20. package/js/chunk-OD3KFKZD.js +1617 -0
  21. package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
  22. package/js/{chunk-5MQZEB6Y.js → chunk-OZ4UK3CD.js} +37 -12
  23. package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
  24. package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
  25. package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
  26. package/js/{chunk-Z5NMEGJN.js → chunk-RAAPJMVZ.js} +21 -9
  27. package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
  28. package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
  29. package/js/{chunk-MYYEW3RA.js → chunk-VXWY44LE.js} +780 -55
  30. package/js/{chunk-JN55AYQH.js → chunk-XNCYIB4D.js} +61 -32
  31. package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
  32. package/js/client.js +10 -26
  33. package/js/contracts.js +74 -16
  34. package/js/effect.js +19 -20
  35. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  36. package/js/graphql.js +47 -49
  37. package/js/host.js +19 -20
  38. package/js/index.js +232 -201
  39. package/js/mcp/effect.js +21 -22
  40. package/js/mcp/stdio.js +25 -26
  41. package/js/mcp.js +74 -56
  42. package/js/openapi.js +3428 -1276
  43. package/js/react.js +3 -3
  44. package/js/skills/effect.js +3 -3
  45. package/js/skills.js +12 -13
  46. package/js/storage/facet.js +4 -4
  47. package/js/ui/auth/contracts.js +8 -9
  48. package/js/ui/auth.js +16 -14
  49. package/js/ui/contracts.js +4 -4
  50. package/js/ui/serving.js +71 -218
  51. package/package.json +1 -1
  52. package/runtime.json +1 -1
  53. package/types/app-data/src/contracts/database.d.ts +33 -6
  54. package/types/app-data/src/implementation/schema.d.ts +2 -17
  55. package/types/apps/src/contracts/app.d.ts +7 -6
  56. package/types/apps/src/contracts/failure.d.ts +25 -0
  57. package/types/apps/src/contracts/host.d.ts +31 -10
  58. package/types/apps/src/contracts/mcp.d.ts +16 -0
  59. package/types/apps/src/contracts/openapi.d.ts +5 -1
  60. package/types/apps/src/contracts/operations.d.ts +0 -5
  61. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  62. package/types/apps/src/contracts/protocols/1.d.ts +235 -67
  63. package/types/apps/src/contracts/protocols/2.d.ts +710 -0
  64. package/types/apps/src/contracts/protocols/3.d.ts +718 -0
  65. package/types/apps/src/contracts/protocols/4.d.ts +1299 -0
  66. package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
  67. package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
  68. package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
  69. package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
  70. package/types/apps/src/contracts/provider.d.ts +109 -10
  71. package/types/apps/src/contracts/router.d.ts +59 -0
  72. package/types/apps/src/contracts/storage.d.ts +3 -3
  73. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  74. package/types/apps/src/contracts/ui.d.ts +18 -0
  75. package/types/apps/src/contracts/workflows.d.ts +34 -3
  76. package/types/apps/src/graphql.d.ts +1 -3
  77. package/types/apps/src/implementation/account-router.d.ts +12 -0
  78. package/types/apps/src/implementation/app.d.ts +5 -4
  79. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  80. package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
  81. package/types/apps/src/implementation/elicitation.d.ts +2 -2
  82. package/types/apps/src/implementation/failure-detail.d.ts +26 -0
  83. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  84. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  85. package/types/apps/src/implementation/mcp-client.d.ts +35 -19
  86. package/types/apps/src/implementation/mcp.d.ts +35 -19
  87. package/types/apps/src/implementation/openapi-compile.d.ts +9 -5
  88. package/types/apps/src/implementation/openapi-document.d.ts +15 -2
  89. package/types/apps/src/implementation/openapi-request.d.ts +8 -1
  90. package/types/apps/src/implementation/openapi-source.d.ts +2 -6
  91. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  92. package/types/apps/src/implementation/operations.d.ts +36 -3
  93. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  94. package/types/apps/src/implementation/provider.d.ts +19 -5
  95. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  96. package/types/apps/src/implementation/router.d.ts +68 -0
  97. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  98. package/types/apps/src/implementation/schema.d.ts +44 -1
  99. package/types/apps/src/implementation/storage.d.ts +5 -3
  100. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  101. package/types/apps/src/implementation/ui-auth.d.ts +11 -5
  102. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  103. package/types/apps/src/implementation/ui-serving.d.ts +10 -4
  104. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  105. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  106. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  107. package/types/apps/src/index.d.ts +28 -11
  108. package/types/apps/src/mcp-stdio.d.ts +2 -5
  109. package/types/apps/src/mcp.d.ts +5 -4
  110. package/types/apps/src/openapi.d.ts +6 -6
  111. package/types/apps/src/ui-auth.d.ts +2 -2
  112. package/types/telemetry/src/browser-operations.d.ts +5 -2
  113. package/js/chunk-PYUYJRSK.js +0 -93
  114. package/js/chunk-SWPD52J7.js +0 -35
  115. package/js/chunk-TE4KO4HI.js +0 -47
  116. package/js/chunk-W7D7WVSY.js +0 -18
  117. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  118. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  119. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
@@ -1,29 +1,51 @@
1
1
  import {
2
- parseDatabaseSchema,
3
2
  promiseTable
4
- } from "./chunk-PLCMJREA.js";
3
+ } from "./chunk-ZQINWV4W.js";
5
4
  import {
5
+ declaredOperations,
6
6
  fromPromise,
7
- nativeOperation
8
- } from "./chunk-PYUYJRSK.js";
7
+ nativeOperation,
8
+ nativeRouter
9
+ } from "./chunk-NMKHTJOQ.js";
9
10
  import {
10
11
  ScheduleTiming
11
- } from "./chunk-MYYEW3RA.js";
12
+ } from "./chunk-VXWY44LE.js";
13
+ import {
14
+ DatabaseSchema
15
+ } from "./chunk-N7YDVXYJ.js";
12
16
  import {
13
17
  decoderOf,
14
18
  isSchema,
15
19
  storageFieldOf
16
- } from "./chunk-WFSQXYUT.js";
20
+ } from "./chunk-4QQ62BVS.js";
17
21
  import {
18
22
  AppStorageUnavailable
19
- } from "./chunk-FZJOYIZO.js";
23
+ } from "./chunk-PZB6T6KU.js";
20
24
  import {
21
25
  JsonValue
22
- } from "./chunk-SATWJKN6.js";
26
+ } from "./chunk-27F7W2LG.js";
23
27
  import {
24
28
  Effect_exports,
25
29
  Schema_exports
26
- } from "./chunk-FW5HBOIK.js";
30
+ } from "./chunk-CDL5PM2Q.js";
31
+
32
+ // src/contracts/http.ts
33
+ var ResponseStatusError = class extends Schema_exports.TaggedError()(
34
+ "ResponseStatusError",
35
+ { status: Schema_exports.Number }
36
+ ) {
37
+ get message() {
38
+ return `Request failed with status ${this.status}`;
39
+ }
40
+ };
41
+ var ResponseDecodeError = class extends Schema_exports.TaggedError()(
42
+ "ResponseDecodeError",
43
+ {}
44
+ ) {
45
+ get message() {
46
+ return "Response body did not match the expected schema";
47
+ }
48
+ };
27
49
 
28
50
  // src/implementation/workflows.ts
29
51
  var NativeWorkflow = /* @__PURE__ */ Symbol("apps.Workflow");
@@ -48,8 +70,12 @@ var nativeWorkflow = (value) => {
48
70
  var InternalApp = /* @__PURE__ */ Symbol("apps.App");
49
71
  var isApp = (value) => typeof value === "object" && value !== null && InternalApp in value;
50
72
  var toEffectApp = (app) => app[InternalApp];
73
+ function rejectCatalogs(definition) {
74
+ if ("queries" in definition || "mutations" in definition)
75
+ throw new Error("Put queries and mutations in a router under tools");
76
+ }
51
77
  function adaptDefinition(definition) {
52
- if ("tools" in definition) throw new Error("Use queries and mutations instead of tools");
78
+ rejectCatalogs(definition);
53
79
  const webhooks = definition.webhooks === void 0 ? {} : {
54
80
  webhooks: Object.fromEntries(
55
81
  Object.entries(definition.webhooks).map(([name, webhook]) => [
@@ -65,42 +91,42 @@ function adaptDefinition(definition) {
65
91
  ])
66
92
  )
67
93
  };
68
- const operations = (kind, catalog) => Object.fromEntries(
69
- Object.entries(catalog).map(([name, value]) => {
70
- const operation = nativeOperation(value);
71
- if (operation === void 0 || operation.kind !== kind)
72
- throw new Error("Invalid app data operation");
73
- return [name, operation];
74
- })
75
- );
76
94
  const workflows = definition.workflows === void 0 ? {} : {
77
95
  workflows: Object.fromEntries(
78
96
  Object.entries(definition.workflows).map(([name, value]) => {
79
- const declared = nativeWorkflow(value);
80
- if (declared === void 0) throw new Error("Invalid workflow declaration");
81
- return [name, declared];
97
+ const declared2 = nativeWorkflow(value);
98
+ if (declared2 === void 0) throw new Error("Invalid workflow declaration");
99
+ return [name, declared2];
82
100
  })
83
101
  )
84
102
  };
85
- const data = {
86
- ...definition.queries === void 0 ? {} : { queries: operations("query", definition.queries) },
87
- ...definition.mutations === void 0 ? {} : { mutations: operations("mutation", definition.mutations) }
88
- };
103
+ const root = definition.tools === void 0 ? void 0 : nativeRouter(definition.tools);
104
+ if (definition.tools !== void 0 && root === void 0)
105
+ throw new Error("tools must be a router");
106
+ const data = root === void 0 ? {} : { tools: root };
107
+ const declared = root?.kind === "router" ? declaredOperations(root) : [];
108
+ const mutations = /* @__PURE__ */ new Set();
109
+ for (const { operation } of declared) {
110
+ if (operation.kind !== "mutation") continue;
111
+ if (mutations.has(operation))
112
+ throw new Error("A mutation can be mounted at only one path in tools");
113
+ mutations.add(operation);
114
+ }
89
115
  const schedules = definition.schedules === void 0 ? {} : {
90
116
  schedules: Object.fromEntries(
91
117
  Object.entries(definition.schedules).map(([name, schedule]) => {
92
- const matches = Object.entries(definition.mutations ?? {}).filter(
93
- ([, operation]) => operation === schedule.operation
118
+ const target = nativeOperation(schedule.operation);
119
+ const match = declared.find(
120
+ ({ operation }) => operation === target && operation.kind === "mutation"
94
121
  );
95
- const match = matches[0];
96
- if (match === void 0 || matches.length !== 1)
97
- throw new Error("A schedule must reference exactly one named mutation in this app");
122
+ if (match === void 0)
123
+ throw new Error("A schedule must reference a mutation in this app's tools");
98
124
  return [
99
125
  name,
100
126
  {
101
127
  timing: Schema_exports.decodeUnknownSync(ScheduleTiming)(schedule.timing),
102
128
  input: Schema_exports.decodeUnknownSync(JsonValue)(schedule.input),
103
- tool: `mutations.${match[0]}`
129
+ tool: match.name
104
130
  }
105
131
  ];
106
132
  })
@@ -115,6 +141,7 @@ function adaptDefinition(definition) {
115
141
  };
116
142
  }
117
143
  var defineApp = (requirements, definition) => {
144
+ if (typeof definition !== "function") rejectCatalogs(definition);
118
145
  const evaluate = typeof definition === "function" ? definition : async () => definition;
119
146
  const factory = fromPromise(evaluate);
120
147
  const native = {
@@ -152,7 +179,7 @@ var serialize = (tables) => {
152
179
  }
153
180
  ])
154
181
  );
155
- return Effect_exports.runSync(parseDatabaseSchema(definitions));
182
+ return Schema_exports.decodeUnknownSync(DatabaseSchema)(definitions);
156
183
  };
157
184
  var authorDatabase = (tables, session, signal, writable) => {
158
185
  return Object.fromEntries(
@@ -202,6 +229,8 @@ var unavailableStorage = {
202
229
  };
203
230
 
204
231
  export {
232
+ ResponseStatusError,
233
+ ResponseDecodeError,
205
234
  workflow,
206
235
  isApp,
207
236
  toEffectApp,
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  AppDatabaseError,
3
+ DatabaseFieldReserved,
4
+ DatabaseLimitExceeded,
3
5
  DatabaseLimits,
4
6
  DatabaseOperation,
5
7
  DatabaseSchema,
@@ -8,18 +10,21 @@ import {
8
10
  Row,
9
11
  RowMetadata,
10
12
  defaultDatabaseLimits,
11
- defaultDatabaseRuntimeLimits
12
- } from "./chunk-BMOIAIVR.js";
13
+ defaultDatabaseRuntimeLimits,
14
+ reservedFieldNames
15
+ } from "./chunk-N7YDVXYJ.js";
13
16
  import {
17
+ Cause_exports,
14
18
  Clock_exports,
15
19
  Effect_exports,
16
20
  Encoding_exports,
17
21
  Schema_exports,
18
22
  Semaphore_exports
19
- } from "./chunk-FW5HBOIK.js";
23
+ } from "./chunk-CDL5PM2Q.js";
20
24
 
21
25
  // ../app-data/src/implementation/schema.ts
22
- var metadata = /* @__PURE__ */ new Set(["id", "createdAt", "updatedAt"]);
26
+ var metadata = new Set(reservedFieldNames);
27
+ var reserved = (name) => metadata.has(name);
23
28
  var indexesFor = (table) => [{ name: "by_creation", fields: [] }, ...table.indexes].map((index) => ({
24
29
  name: index.name,
25
30
  fields: [
@@ -33,23 +38,25 @@ var validScalar = (field, value) => field.kind === "number" ? typeof value === "
33
38
  return point !== void 0 && point >= 55296 && point <= 57343;
34
39
  });
35
40
  var parseDatabaseSchema = (input) => Schema_exports.decodeUnknownEffect(DatabaseSchema)(input).pipe(
41
+ Effect_exports.mapError(() => new AppDatabaseError({ reason: "schema" })),
36
42
  Effect_exports.flatMap(
37
43
  (schema) => Effect_exports.gen(function* () {
38
- for (const table of Object.values(schema)) {
39
- if (Object.keys(table.fields).some((name) => metadata.has(name)) || new Set(table.indexes.map((index) => index.name)).size !== table.indexes.length)
44
+ for (const [name, table] of Object.entries(schema)) {
45
+ const field = Object.keys(table.fields).find(reserved);
46
+ if (field !== void 0) return yield* new DatabaseFieldReserved({ table: name, field });
47
+ if (new Set(table.indexes.map((index) => index.name)).size !== table.indexes.length)
40
48
  return yield* new AppDatabaseError({ reason: "schema" });
41
- for (const field of Object.values(table.fields)) {
42
- if ((field.kind === "id" ? field.references === void 0 : field.references !== void 0) || field.default !== void 0 && !validScalar(field, field.default) || field.references !== void 0 && !Object.hasOwn(schema, field.references))
49
+ for (const field2 of Object.values(table.fields)) {
50
+ if ((field2.kind === "id" ? field2.references === void 0 : field2.references !== void 0) || field2.default !== void 0 && !validScalar(field2, field2.default) || field2.references !== void 0 && !Object.hasOwn(schema, field2.references))
43
51
  return yield* new AppDatabaseError({ reason: "schema" });
44
52
  }
45
53
  for (const index of table.indexes)
46
- if (index.name === "by_creation" || new Set(index.fields).size !== index.fields.length || index.fields.some((name) => fieldFor(table, name) === void 0))
54
+ if (index.name === "by_creation" || new Set(index.fields).size !== index.fields.length || index.fields.some((name2) => fieldFor(table, name2) === void 0))
47
55
  return yield* new AppDatabaseError({ reason: "schema" });
48
56
  }
49
57
  return schema;
50
58
  })
51
- ),
52
- Effect_exports.mapError(() => new AppDatabaseError({ reason: "schema" }))
59
+ )
53
60
  );
54
61
  var canonicalSchema = (schema) => JSON.stringify(
55
62
  Object.fromEntries(
@@ -248,7 +255,12 @@ var decodeBody = Schema_exports.decodeUnknownEffect(Schema_exports.fromJsonStrin
248
255
  var storageError = () => new AppDatabaseError({ reason: "storage" });
249
256
  var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
250
257
  const { sql, crypto } = options;
251
- const schema = yield* parseDatabaseSchema(options.schema);
258
+ const schema = yield* parseDatabaseSchema(options.schema).pipe(
259
+ Effect_exports.catchTag(
260
+ "DatabaseFieldReserved",
261
+ () => Effect_exports.fail(new AppDatabaseError({ reason: "schema" }))
262
+ )
263
+ );
252
264
  const limits = yield* Schema_exports.decodeUnknownEffect(DatabaseLimits)(
253
265
  options.limits ?? defaultDatabaseLimits
254
266
  ).pipe(Effect_exports.mapError(() => new AppDatabaseError({ reason: "limit" })));
@@ -295,7 +307,13 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
295
307
  };
296
308
  const charge = (name, amount) => Effect_exports.suspend(() => {
297
309
  used[name] += amount;
298
- return used[name] > limits[name] ? Effect_exports.fail(new AppDatabaseError({ reason: "limit" })) : Effect_exports.void;
310
+ return used[name] > limits[name] ? Effect_exports.fail(
311
+ new DatabaseLimitExceeded({
312
+ limit: name,
313
+ maximum: limits[name],
314
+ requested: used[name]
315
+ })
316
+ ) : Effect_exports.void;
299
317
  });
300
318
  const get = (table, id) => Effect_exports.gen(function* () {
301
319
  yield* charge("directGets", 1);
@@ -312,8 +330,13 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
312
330
  const store = (tableName, table, row) => Effect_exports.gen(function* () {
313
331
  const meta = yield* Schema_exports.decodeUnknownEffect(RowMetadata)(row);
314
332
  const body = JSON.stringify(row);
315
- if (new TextEncoder().encode(body).length > limits.valueBytes)
316
- return yield* new AppDatabaseError({ reason: "limit" });
333
+ const bytes = new TextEncoder().encode(body).length;
334
+ if (bytes > limits.valueBytes)
335
+ return yield* new DatabaseLimitExceeded({
336
+ limit: "valueBytes",
337
+ maximum: limits.valueBytes,
338
+ requested: bytes
339
+ });
317
340
  const keys = yield* Effect_exports.forEach(
318
341
  indexesFor(table),
319
342
  (index) => encodeIndexKey(
@@ -384,9 +407,14 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
384
407
  const bounds = yield* queryBounds(table, plan, limits.indexBytes);
385
408
  reads.add(tableName);
386
409
  yield* charge("scanCalls", 1);
387
- const maximum = terminal.kind === "count" ? limits.rowsRead - used.rowsRead : limits.rowsReturned - used.rowsReturned;
388
- const count = terminal.kind === "first" ? 1 : terminal.kind === "take" ? terminal.count : terminal.kind === "paginate" ? terminal.numItems : maximum;
389
- if (count > maximum) return yield* new AppDatabaseError({ reason: "limit" });
410
+ const remaining = terminal.kind === "count" ? limits.rowsRead - used.rowsRead : limits.rowsReturned - used.rowsReturned;
411
+ const count = terminal.kind === "first" ? 1 : terminal.kind === "take" ? terminal.count : terminal.kind === "paginate" ? terminal.numItems : remaining;
412
+ if ((terminal.kind === "take" || terminal.kind === "paginate") && count > limits.rowsReturned)
413
+ return yield* new DatabaseLimitExceeded({
414
+ limit: "pageSize",
415
+ maximum: limits.rowsReturned,
416
+ requested: count
417
+ });
390
418
  if (count === 0 && terminal.kind === "take") return [];
391
419
  const query = yield* fingerprint(
392
420
  crypto,
@@ -412,7 +440,10 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
412
440
  plan.order === "asc" ? sql`i.sort_key > ${position}` : sql`i.sort_key < ${position}`
413
441
  );
414
442
  const direction = plan.order === "asc" ? sql.literal("ASC") : sql.literal("DESC");
415
- const limit = terminal.kind === "first" || terminal.kind === "take" ? count : count + 1;
443
+ const limit = Math.min(
444
+ terminal.kind === "first" || terminal.kind === "take" ? count : count + 1,
445
+ remaining + 1
446
+ );
416
447
  if (terminal.kind === "count") {
417
448
  const rows2 = yield* sql`SELECT i.sort_key FROM app_indexes i WHERE ${sql.and(predicates)} ORDER BY i.sort_key ${direction} LIMIT ${limit}`.pipe(
418
449
  Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(CountRow)))
@@ -436,7 +467,11 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
436
467
  )
437
468
  );
438
469
  if (terminal.kind === "collect" && rows.length > count)
439
- return yield* new AppDatabaseError({ reason: "limit" });
470
+ return yield* new DatabaseLimitExceeded({
471
+ limit: "rowsReturned",
472
+ maximum: limits.rowsReturned,
473
+ requested: used.rowsReturned + rows.length
474
+ });
440
475
  const page = rows.slice(0, count);
441
476
  yield* charge("rowsReturned", page.length);
442
477
  const values = yield* Effect_exports.forEach(page, (row) => decodeBody(row.body));
@@ -502,6 +537,11 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
502
537
  })
503
538
  };
504
539
  return yield* Effect_exports.suspend(() => work(session)).pipe(
540
+ // A failed database call poisons the session. Report that failure even when
541
+ // authored code caught it or threw something else in its place.
542
+ Effect_exports.catchCause(
543
+ (cause) => failed === void 0 || Cause_exports.hasInterrupts(cause) ? Effect_exports.failCause(cause) : Effect_exports.fail(failed)
544
+ ),
505
545
  Effect_exports.tap(
506
546
  () => gate.withPermits(1)(
507
547
  Effect_exports.suspend(() => failed === void 0 ? Effect_exports.void : Effect_exports.fail(failed))
package/js/client.js CHANGED
@@ -4,37 +4,36 @@ import {
4
4
  UiContext,
5
5
  UiDeploymentChanged,
6
6
  UiFailed
7
- } from "./chunk-OHRT55C4.js";
7
+ } from "./chunk-IJX4CYZO.js";
8
8
  import {
9
9
  AsyncResult_exports,
10
10
  AtomRegistry_exports,
11
11
  Atom_exports,
12
12
  queryResult
13
- } from "./chunk-EVJUVWN2.js";
14
- import "./chunk-M6ZRRIBI.js";
13
+ } from "./chunk-M3B3DE4K.js";
14
+ import "./chunk-PJJ24GU7.js";
15
15
  import {
16
16
  OtlpExporter_exports,
17
- TraceContext,
18
17
  externalTrace,
19
18
  pendingSpan,
20
19
  telemetryLayer,
21
20
  traceLinks
22
- } from "./chunk-ZCAMUXSG.js";
21
+ } from "./chunk-ODEIDRGW.js";
23
22
  import {
24
23
  FetchHttpClient_exports
25
- } from "./chunk-HDJH3RPR.js";
24
+ } from "./chunk-57RKNWL2.js";
26
25
  import {
27
26
  HttpClientError_exports
28
- } from "./chunk-QKHR7BMF.js";
27
+ } from "./chunk-UK573G7W.js";
29
28
  import {
30
29
  decoderOf
31
- } from "./chunk-WFSQXYUT.js";
30
+ } from "./chunk-4QQ62BVS.js";
32
31
  import {
33
32
  StorageName
34
- } from "./chunk-FZJOYIZO.js";
33
+ } from "./chunk-PZB6T6KU.js";
35
34
  import {
36
35
  JsonValue
37
- } from "./chunk-SATWJKN6.js";
36
+ } from "./chunk-27F7W2LG.js";
38
37
  import {
39
38
  Cause_exports,
40
39
  Clock_exports,
@@ -52,7 +51,7 @@ import {
52
51
  Semaphore_exports,
53
52
  Stream_exports,
54
53
  Tracer_exports
55
- } from "./chunk-FW5HBOIK.js";
54
+ } from "./chunk-CDL5PM2Q.js";
56
55
  import "./chunk-CZ7CSFO4.js";
57
56
 
58
57
  // src/contracts/live.ts
@@ -448,21 +447,6 @@ var observeBrowserPerformance = Effect_exports.gen(function* () {
448
447
  };
449
448
  });
450
449
 
451
- // ../telemetry/src/browser-operations.ts
452
- var BrowserOperationFailure = Schema_exports.Struct({
453
- error_type: Schema_exports.Literals([
454
- "BrowserDecodeFailed",
455
- "BrowserTransportFailed",
456
- "BrowserOperationFailed"
457
- ]),
458
- trace_id: TraceContext.fields.traceId,
459
- span_id: TraceContext.fields.spanId,
460
- page_id: Schema_exports.String
461
- });
462
- var ResponseTrace = Context_exports.Reference("telemetry/ResponseTrace", {
463
- defaultValue: () => void 0
464
- });
465
-
466
450
  // ../telemetry/src/browser.ts
467
451
  var BrowserTelemetry = class extends Context_exports.Service()("executor/BrowserTelemetry") {
468
452
  };
package/js/contracts.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import {
2
+ AccountCheckCommand,
3
+ AccountCheckResult,
4
+ AccountInfo,
5
+ ApiErrorResponse,
2
6
  ApprovalElicitation,
3
7
  ApprovalResponse,
4
8
  CalendarSchedule,
9
+ CredentialHost,
5
10
  DeclaredAuthMethod,
6
11
  DeclaredProvider,
7
12
  DeclaredRequirements,
@@ -9,7 +14,13 @@ import {
9
14
  ElicitationLimits,
10
15
  ElicitationReply,
11
16
  ElicitationResponse,
17
+ FailureCode,
18
+ FailureDetail,
19
+ FailureMessage,
20
+ FailureName,
21
+ FailureSource,
12
22
  FormElicitation,
23
+ HostAccountCheckError,
13
24
  HostAccountsInvalid,
14
25
  HostCallError,
15
26
  HostDataError,
@@ -19,6 +30,7 @@ import {
19
30
  HostInputInvalid,
20
31
  HostInspectError,
21
32
  HostInvocation,
33
+ HostKindMismatch,
22
34
  HostOperationFailed,
23
35
  HostOperationNotFound,
24
36
  HostOutputInvalid,
@@ -26,10 +38,14 @@ import {
26
38
  HostRequestInvalid,
27
39
  HostRequirementsError,
28
40
  HostResponse,
41
+ HostRouterError,
29
42
  HostToolApprovalRequired,
30
43
  HostToolBlocked,
31
44
  HostToolNotFound,
32
45
  HostToolPolicyFailed,
46
+ HostedCatalog,
47
+ HostedCatalogSummary,
48
+ HostedRouter,
33
49
  HostedTool,
34
50
  HostedToolSummary,
35
51
  HostedWebhook,
@@ -44,10 +60,15 @@ import {
44
60
  NonRetryableError,
45
61
  OAuthClientAuth,
46
62
  OAuthSecretClientAuth,
63
+ OAuthTokenRequestFormat,
64
+ OAuthTokenResponse,
65
+ OpenapiResponseError,
47
66
  OperationSchedule,
48
- OperationToolPrefixes,
49
67
  ResolvedAccount,
50
68
  ResolvedAccounts,
69
+ RouterIcon,
70
+ RouterKey,
71
+ RouterMeta,
51
72
  ScheduleTiming,
52
73
  SkillCatalogResponse,
53
74
  SkillSources,
@@ -61,11 +82,13 @@ import {
61
82
  WorkflowControlCommand,
62
83
  WorkflowDuration,
63
84
  WorkflowFailure,
85
+ WorkflowFailureDetail,
64
86
  WorkflowName,
65
87
  WorkflowReplay,
66
88
  WorkflowRpcCommand,
67
89
  WorkflowRpcResult,
68
90
  WorkflowRun,
91
+ WorkflowRunFailure,
69
92
  WorkflowRunId,
70
93
  WorkflowRunPage,
71
94
  WorkflowStepOptions,
@@ -77,16 +100,28 @@ import {
77
100
  frameworkProtocol,
78
101
  indexCommand,
79
102
  inspectCommand,
103
+ maxFailureMessageLength,
80
104
  maxInputProblems,
81
105
  minimumIntervalMilliseconds,
82
106
  protocol1,
107
+ protocol2,
108
+ protocol3,
109
+ protocol4,
110
+ protocol5,
111
+ protocol6,
112
+ protocol7,
83
113
  selectTools,
84
114
  skillCatalog,
85
115
  skillsCommand,
86
116
  workflowDurationMillis
87
- } from "./chunk-MYYEW3RA.js";
88
- import "./chunk-BMOIAIVR.js";
89
- import "./chunk-LGIYBDWA.js";
117
+ } from "./chunk-VXWY44LE.js";
118
+ import {
119
+ DatabaseFieldReserved,
120
+ DatabaseLimitExceeded
121
+ } from "./chunk-N7YDVXYJ.js";
122
+ import {
123
+ ProviderError
124
+ } from "./chunk-R3EV5FTO.js";
90
125
  import {
91
126
  AppSkillMetadata,
92
127
  AppSkillName,
@@ -99,27 +134,23 @@ import {
99
134
  SkillServiceName,
100
135
  skillFormatLimits,
101
136
  skillLoadLimits
102
- } from "./chunk-YEJOQEII.js";
103
- import {
104
- ApiErrorResponse,
105
- OpenapiResponseError
106
- } from "./chunk-SWPD52J7.js";
107
- import {
108
- ProviderError
109
- } from "./chunk-W7D7WVSY.js";
137
+ } from "./chunk-JU7VHODU.js";
110
138
  import {
111
139
  AppStorageError,
112
140
  AppStorageUnavailable,
113
141
  StorageName
114
- } from "./chunk-FZJOYIZO.js";
142
+ } from "./chunk-PZB6T6KU.js";
115
143
  import {
116
144
  AccountId,
117
145
  HttpUrl
118
- } from "./chunk-SATWJKN6.js";
119
- import "./chunk-FW5HBOIK.js";
146
+ } from "./chunk-27F7W2LG.js";
147
+ import "./chunk-CDL5PM2Q.js";
120
148
  import "./chunk-CZ7CSFO4.js";
121
149
  export {
150
+ AccountCheckCommand,
151
+ AccountCheckResult,
122
152
  AccountId,
153
+ AccountInfo,
123
154
  ApiErrorResponse,
124
155
  AppSkillMetadata,
125
156
  AppSkillName,
@@ -130,6 +161,9 @@ export {
130
161
  ApprovalElicitation,
131
162
  ApprovalResponse,
132
163
  CalendarSchedule,
164
+ CredentialHost,
165
+ DatabaseFieldReserved,
166
+ DatabaseLimitExceeded,
133
167
  DeclaredAuthMethod,
134
168
  DeclaredProvider,
135
169
  DeclaredRequirements,
@@ -137,7 +171,13 @@ export {
137
171
  ElicitationLimits,
138
172
  ElicitationReply,
139
173
  ElicitationResponse,
174
+ FailureCode,
175
+ FailureDetail,
176
+ FailureMessage,
177
+ FailureName,
178
+ FailureSource,
140
179
  FormElicitation,
180
+ HostAccountCheckError,
141
181
  HostAccountsInvalid,
142
182
  HostCallError,
143
183
  HostDataError,
@@ -147,6 +187,7 @@ export {
147
187
  HostInputInvalid,
148
188
  HostInspectError,
149
189
  HostInvocation,
190
+ HostKindMismatch,
150
191
  HostOperationFailed,
151
192
  HostOperationNotFound,
152
193
  HostOutputInvalid,
@@ -154,10 +195,14 @@ export {
154
195
  HostRequestInvalid,
155
196
  HostRequirementsError,
156
197
  HostResponse,
198
+ HostRouterError,
157
199
  HostToolApprovalRequired,
158
200
  HostToolBlocked,
159
201
  HostToolNotFound,
160
202
  HostToolPolicyFailed,
203
+ HostedCatalog,
204
+ HostedCatalogSummary,
205
+ HostedRouter,
161
206
  HostedTool,
162
207
  HostedToolSummary,
163
208
  HostedWebhook,
@@ -173,12 +218,16 @@ export {
173
218
  NonRetryableError,
174
219
  OAuthClientAuth,
175
220
  OAuthSecretClientAuth,
221
+ OAuthTokenRequestFormat,
222
+ OAuthTokenResponse,
176
223
  OpenapiResponseError,
177
224
  OperationSchedule,
178
- OperationToolPrefixes,
179
225
  ProviderError,
180
226
  ResolvedAccount,
181
227
  ResolvedAccounts,
228
+ RouterIcon,
229
+ RouterKey,
230
+ RouterMeta,
182
231
  ScheduleTiming,
183
232
  SkillCatalogResponse,
184
233
  SkillDefinitionInvalid,
@@ -198,11 +247,13 @@ export {
198
247
  WorkflowControlCommand,
199
248
  WorkflowDuration,
200
249
  WorkflowFailure,
250
+ WorkflowFailureDetail,
201
251
  WorkflowName,
202
252
  WorkflowReplay,
203
253
  WorkflowRpcCommand,
204
254
  WorkflowRpcResult,
205
255
  WorkflowRun,
256
+ WorkflowRunFailure,
206
257
  WorkflowRunId,
207
258
  WorkflowRunPage,
208
259
  WorkflowStepOptions,
@@ -214,9 +265,16 @@ export {
214
265
  frameworkProtocol,
215
266
  indexCommand,
216
267
  inspectCommand,
268
+ maxFailureMessageLength,
217
269
  maxInputProblems,
218
270
  minimumIntervalMilliseconds,
219
271
  protocol1,
272
+ protocol2,
273
+ protocol3,
274
+ protocol4,
275
+ protocol5,
276
+ protocol6,
277
+ protocol7,
220
278
  selectTools,
221
279
  skillCatalog,
222
280
  skillFormatLimits,