apps 0.0.1-beta.6 → 0.0.1-beta.60

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 (173) hide show
  1. package/README.md +24 -21
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-ECQFRCH4.js → chunk-2ARGIHVD.js} +4 -3
  4. package/js/chunk-5FHWNLCI.js +88 -0
  5. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  6. package/js/{chunk-NKLWZJLE.js → chunk-AQU56EPI.js} +9 -5
  7. package/js/chunk-CDXQDN7W.js +92 -0
  8. package/js/{chunk-ITM77QPO.js → chunk-CWW7QWP4.js} +126 -31
  9. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  10. package/js/chunk-ERJ5JGCB.js +266 -0
  11. package/js/{chunk-RJDDBDSN.js → chunk-FFSO3J76.js} +633 -89
  12. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  13. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  14. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  15. package/js/{chunk-RFVIONFX.js → chunk-IJ6Y2KFQ.js} +79 -41
  16. package/js/{chunk-T7GKZBLP.js → chunk-JIU25DIL.js} +67 -55
  17. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  18. package/js/{chunk-5T57N25Q.js → chunk-KGCTYL2S.js} +511 -63
  19. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  20. package/js/chunk-MRV45IXB.js +340 -0
  21. package/js/chunk-MWKHKOTL.js +240 -0
  22. package/js/{chunk-SB4HEPNJ.js → chunk-MZNCLCGJ.js} +883 -189
  23. package/js/chunk-NS3DEHVA.js +49 -0
  24. package/js/chunk-OD3KFKZD.js +1617 -0
  25. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  26. package/js/chunk-T53665H5.js +171 -0
  27. package/js/{chunk-B3EOZTK3.js → chunk-TLWLJ7PD.js} +2227 -453
  28. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  29. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  30. package/js/{chunk-MNMNLXBL.js → chunk-ZYTA5MK4.js} +316 -69
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +103 -26
  33. package/js/effect.js +19 -19
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +50 -40
  36. package/js/host.js +83 -58
  37. package/js/index.js +90 -61
  38. package/js/mcp/effect.js +23 -21
  39. package/js/mcp/stdio.js +44 -34
  40. package/js/mcp.js +76 -53
  41. package/js/openapi.js +4050 -1354
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -81
  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-cache/src/index.d.ts +10 -1
  53. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  54. package/types/apps/src/contracts/app.d.ts +7 -3
  55. package/types/apps/src/contracts/cache.d.ts +20 -0
  56. package/types/apps/src/contracts/context.d.ts +19 -11
  57. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  58. package/types/apps/src/contracts/events.d.ts +93 -0
  59. package/types/apps/src/contracts/failure.d.ts +30 -1
  60. package/types/apps/src/contracts/graphql.d.ts +2 -1
  61. package/types/apps/src/contracts/host.d.ts +48 -13
  62. package/types/apps/src/contracts/live.d.ts +2 -0
  63. package/types/apps/src/contracts/mcp.d.ts +80 -10
  64. package/types/apps/src/contracts/network.d.ts +84 -0
  65. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  66. package/types/apps/src/contracts/openapi.d.ts +41 -9
  67. package/types/apps/src/contracts/operations.d.ts +8 -4
  68. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  69. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  70. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  71. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  72. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  73. package/types/apps/src/contracts/protocols/4.d.ts +122 -45
  74. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  75. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  76. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  77. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  78. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  79. package/types/apps/src/contracts/protocols/current.d.ts +2476 -0
  80. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  81. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  82. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  83. package/types/apps/src/contracts/provider.d.ts +115 -10
  84. package/types/apps/src/contracts/skills.d.ts +50 -13
  85. package/types/apps/src/contracts/sql.d.ts +58 -0
  86. package/types/apps/src/contracts/ui.d.ts +19 -1
  87. package/types/apps/src/contracts/workflows.d.ts +6 -0
  88. package/types/apps/src/facet.d.ts +4 -5
  89. package/types/apps/src/host.d.ts +5 -0
  90. package/types/apps/src/implementation/account-router.d.ts +4 -3
  91. package/types/apps/src/implementation/authoring.d.ts +25 -5
  92. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  93. package/types/apps/src/implementation/cache.d.ts +4 -0
  94. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  95. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  96. package/types/apps/src/implementation/events.d.ts +59 -0
  97. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  98. package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
  99. package/types/apps/src/implementation/graphql.d.ts +4 -3
  100. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  101. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  102. package/types/apps/src/implementation/live.d.ts +2 -2
  103. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  104. package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
  105. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  106. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  107. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  108. package/types/apps/src/implementation/mcp.d.ts +20 -9
  109. package/types/apps/src/implementation/network.d.ts +16 -0
  110. package/types/apps/src/implementation/openapi-compile.d.ts +26 -6
  111. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  112. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  113. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  114. package/types/apps/src/implementation/openapi-source.d.ts +18 -0
  115. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  116. package/types/apps/src/implementation/operations.d.ts +17 -2
  117. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  118. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  119. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  120. package/types/apps/src/implementation/provider.d.ts +19 -5
  121. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  122. package/types/apps/src/implementation/router-catalog.d.ts +11 -13
  123. package/types/apps/src/implementation/router.d.ts +16 -5
  124. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  125. package/types/apps/src/implementation/schema.d.ts +90 -10
  126. package/types/apps/src/implementation/skills.d.ts +18 -24
  127. package/types/apps/src/implementation/sql.d.ts +71 -0
  128. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  129. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  130. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  131. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  132. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  133. package/types/apps/src/implementation/ui-serving.d.ts +11 -5
  134. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  135. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  136. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  137. package/types/apps/src/implementation/workflows.d.ts +1 -1
  138. package/types/apps/src/index.d.ts +30 -12
  139. package/types/apps/src/mcp.d.ts +20 -1
  140. package/types/apps/src/openapi.d.ts +1 -1
  141. package/types/apps/src/react.d.ts +1 -1
  142. package/types/apps/src/skills.d.ts +10 -8
  143. package/types/telemetry/src/app-records.d.ts +42 -0
  144. package/types/telemetry/src/browser-operations.d.ts +7 -4
  145. package/types/telemetry/src/browser.d.ts +8 -3
  146. package/types/telemetry/src/config.d.ts +2 -2
  147. package/types/telemetry/src/index.d.ts +1 -0
  148. package/types/telemetry/src/layer.d.ts +2 -2
  149. package/types/telemetry/src/ownership.d.ts +56 -0
  150. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  151. package/types/telemetry/src/relay.d.ts +11 -3
  152. package/types/telemetry/src/transport.d.ts +8 -1
  153. package/types/utils/src/api-error.d.ts +55 -0
  154. package/types/utils/src/connection-failure.d.ts +33 -0
  155. package/types/utils/src/recorded-message.d.ts +18 -0
  156. package/types/utils/src/user-facing-error.d.ts +83 -0
  157. package/js/chunk-6BSSI67S.js +0 -224
  158. package/js/chunk-MKWZPDR6.js +0 -63
  159. package/js/chunk-N7YDVXYJ.js +0 -186
  160. package/js/chunk-OE3QQTSB.js +0 -222
  161. package/js/chunk-PJJ24GU7.js +0 -877
  162. package/js/chunk-PZB6T6KU.js +0 -19
  163. package/js/chunk-R3EV5FTO.js +0 -97
  164. package/js/chunk-ZQINWV4W.js +0 -630
  165. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  166. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  167. package/types/app-data/src/implementation/promise.d.ts +0 -68
  168. package/types/app-data/src/implementation/range.d.ts +0 -8
  169. package/types/app-data/src/implementation/schema.d.ts +0 -18
  170. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  171. package/types/app-data/src/index.d.ts +0 -4
  172. package/types/apps/src/contracts/storage.d.ts +0 -68
  173. package/types/apps/src/implementation/storage.d.ts +0 -15
package/js/index.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import {
2
+ ResponseDecodeError,
3
+ ResponseStatusError,
2
4
  defineApp,
3
- defineDatabase,
4
- table,
5
+ event,
5
6
  workflow
6
- } from "./chunk-OE3QQTSB.js";
7
- import "./chunk-ZQINWV4W.js";
7
+ } from "./chunk-ERJ5JGCB.js";
8
8
  import {
9
9
  dynamicRouter,
10
- fromPromise,
11
10
  mutation,
12
11
  nativeOperation,
13
12
  nativeRouter,
@@ -15,11 +14,14 @@ import {
15
14
  query,
16
15
  router,
17
16
  routerDeclaration,
18
- withApproval
19
- } from "./chunk-T7GKZBLP.js";
17
+ toolAnnotations,
18
+ withApproval,
19
+ withApprovals
20
+ } from "./chunk-JIU25DIL.js";
20
21
  import {
21
- accountProviderError
22
- } from "./chunk-MKWZPDR6.js";
22
+ accountProviderError,
23
+ fromPromise
24
+ } from "./chunk-T53665H5.js";
23
25
  import {
24
26
  CalendarSchedule,
25
27
  ElicitationFailed,
@@ -34,19 +36,21 @@ import {
34
36
  ScheduleTiming,
35
37
  SecretsMethod,
36
38
  WorkflowFailure
37
- } from "./chunk-B3EOZTK3.js";
38
- import "./chunk-N7YDVXYJ.js";
39
+ } from "./chunk-TLWLJ7PD.js";
39
40
  import {
40
41
  CacheError,
42
+ FetchOptionUnsupported,
43
+ NetworkRefused,
41
44
  ProviderError
42
- } from "./chunk-R3EV5FTO.js";
43
- import "./chunk-JU7VHODU.js";
45
+ } from "./chunk-MWKHKOTL.js";
46
+ import "./chunk-H72MEDMN.js";
44
47
  import {
45
48
  array,
46
49
  boolean,
47
50
  decoderOf,
48
- id,
51
+ fieldExposure,
49
52
  importedJsonSchema,
53
+ isSchema,
50
54
  json,
51
55
  jsonSchema,
52
56
  literal,
@@ -55,42 +59,29 @@ import {
55
59
  object,
56
60
  once,
57
61
  parse,
62
+ plain,
63
+ raw,
58
64
  record,
59
65
  string,
60
- userId,
61
66
  withLazyJsonSchemaDocument,
62
67
  wrap
63
- } from "./chunk-5T57N25Q.js";
64
- import "./chunk-PZB6T6KU.js";
68
+ } from "./chunk-KGCTYL2S.js";
69
+ import "./chunk-FFSO3J76.js";
70
+ import "./chunk-PD6I2SDG.js";
71
+ import "./chunk-5FHWNLCI.js";
65
72
  import {
66
73
  JsonObject,
67
74
  JsonValue,
68
75
  ValidationError
69
- } from "./chunk-27F7W2LG.js";
76
+ } from "./chunk-H2CJWXA3.js";
77
+ import "./chunk-TUMGL2OC.js";
78
+ import "./chunk-EOPQ727L.js";
70
79
  import {
71
80
  Effect_exports,
72
81
  Schema_exports
73
- } from "./chunk-CDL5PM2Q.js";
82
+ } from "./chunk-IFJU5SYQ.js";
74
83
  import "./chunk-CZ7CSFO4.js";
75
84
 
76
- // src/contracts/http.ts
77
- var ResponseStatusError = class extends Schema_exports.TaggedError()(
78
- "ResponseStatusError",
79
- { status: Schema_exports.Number }
80
- ) {
81
- get message() {
82
- return `Request failed with status ${this.status}`;
83
- }
84
- };
85
- var ResponseDecodeError = class extends Schema_exports.TaggedError()(
86
- "ResponseDecodeError",
87
- {}
88
- ) {
89
- get message() {
90
- return "Response body did not match the expected schema";
91
- }
92
- };
93
-
94
85
  // src/implementation/http.ts
95
86
  var decodeJson = (response, schema) => Effect_exports.gen(function* () {
96
87
  if (response.status < 200 || response.status >= 300) {
@@ -102,20 +93,33 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
102
93
 
103
94
  // src/implementation/provider.ts
104
95
  var secrets = (options) => new SecretsMethod(options);
105
- var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(Effect_exports.map((config2) => new OAuth2Method({ config: config2, response })));
106
- var defineProvider = (options) => new Provider(options);
96
+ var oauth2 = (config, response, exposure) => parse(OAuth2Config, config).pipe(
97
+ Effect_exports.map(
98
+ (config2) => new OAuth2Method({ config: config2, response, ...exposure === void 0 ? {} : { exposure } })
99
+ )
100
+ );
101
+ var defineProvider = ({
102
+ health,
103
+ ...options
104
+ }) => {
105
+ if (health === void 0) return new Provider(options);
106
+ const run = fromPromise(health, "check");
107
+ return new Provider({ ...options, health: { run } });
108
+ };
107
109
 
108
110
  // src/implementation/account-router.ts
109
- var inputDocument = (operation) => {
110
- const imported = importedJsonSchema(operation.input);
111
+ var decoderDocument = (decoder) => {
112
+ const imported = importedJsonSchema(decoder);
111
113
  if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
112
- const document = Schema_exports.toJsonSchemaDocument(operation.input);
114
+ const document = Schema_exports.toJsonSchemaDocument(decoder);
113
115
  return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
114
116
  };
115
117
  var declaresOutput = (operation) => {
118
+ if (operation.output !== void 0) return true;
116
119
  const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
117
120
  return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
118
121
  };
122
+ var outputDocument = (operation) => operation.output === void 0 ? operation.outputSchema : decoderDocument(operation.output);
119
123
  var combineOperation = (accounts) => {
120
124
  const variants = [...accounts.values()];
121
125
  const first = variants[0];
@@ -138,7 +142,10 @@ var combineOperation = (accounts) => {
138
142
  type: "object",
139
143
  properties: {
140
144
  accountId: { type: "string", const: accountId },
141
- input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
145
+ input: nestJsonSchema(
146
+ decoderDocument(operation.input),
147
+ `#/anyOf/${index}/properties/input`
148
+ )
142
149
  },
143
150
  required: ["accountId", "input"]
144
151
  }))
@@ -168,9 +175,10 @@ var combineOperation = (accounts) => {
168
175
  });
169
176
  if (variants.every(declaresOutput)) {
170
177
  const outputSchema = once(() => ({
171
- anyOf: variants.flatMap(
172
- (operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
173
- ).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
178
+ anyOf: variants.flatMap((operation) => {
179
+ const output = outputDocument(operation);
180
+ return output === void 0 ? [] : [output];
181
+ }).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
174
182
  }));
175
183
  const native2 = nativeOperation(declaration2);
176
184
  if (native2 !== void 0)
@@ -227,7 +235,7 @@ var combineDynamic = (sources) => {
227
235
  );
228
236
  for (const tool of tools) {
229
237
  const variants = groups.get(tool.name) ?? [];
230
- if (variants.some(([id2]) => id2 === accountId))
238
+ if (variants.some(([id]) => id === accountId))
231
239
  return yield* Effect_exports.die(new Error("Duplicate source operation"));
232
240
  variants.push([accountId, tool]);
233
241
  groups.set(tool.name, variants);
@@ -316,7 +324,7 @@ var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
316
324
  const routers = /* @__PURE__ */ new Map();
317
325
  for (const account of accounts) {
318
326
  const declaration2 = yield* Effect_exports.tryPromise({
319
- try: () => discover(account),
327
+ try: async () => discover(account),
320
328
  catch: (error) => accountProviderError(error, account.id)
321
329
  });
322
330
  if (routers.has(account.id))
@@ -336,7 +344,7 @@ var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
336
344
 
337
345
  // src/implementation/dynamic-skills.ts
338
346
  var dynamicSkills = (source) => ({
339
- list: fromPromise(async () => source.list())
347
+ list: fromPromise(async () => source.list(), "skills")
340
348
  });
341
349
 
342
350
  // src/contracts/app.ts
@@ -375,21 +383,39 @@ var cron = (calendar, operation, input) => declaration(
375
383
  );
376
384
 
377
385
  // src/index.ts
386
+ var isFields = (value) => typeof value === "object" && value !== null && Object.values(value).every(isSchema);
387
+ var accountDecoder = (schema) => (
388
+ // SAFETY: the brand exists only in types; secret values are strings at runtime.
389
+ decoderOf(schema)
390
+ );
391
+ var exposureOf = (schema) => {
392
+ const marked = "fields" in schema && isFields(schema.fields) ? fieldExposure(schema.fields) : {};
393
+ return Object.keys(marked).length === 0 ? {} : { exposure: marked };
394
+ };
378
395
  var OAuth2AccessToken2 = wrap(OAuth2AccessToken, false);
379
- var secrets2 = (options) => secrets({ label: options.label, fields: decoderOf(options.fields) });
396
+ var secrets2 = (options) => secrets({
397
+ label: options.label,
398
+ fields: accountDecoder(options.fields),
399
+ ...exposureOf(options.fields)
400
+ });
380
401
  function oauth22(options) {
381
402
  const { response = OAuth2AccessToken2, ...config } = options;
382
- return Effect_exports.runSync(oauth2(config, decoderOf(response)));
403
+ return Effect_exports.runSync(
404
+ oauth2(config, accountDecoder(response), exposureOf(response).exposure)
405
+ );
383
406
  }
384
407
  var decodeJson2 = (response, schema) => {
385
408
  const native = {
386
409
  status: response.status,
387
- json: () => Effect_exports.tryPromise({
388
- try: () => response.json(),
389
- catch: (error) => error
390
- }).pipe(
391
- Effect_exports.catch(
392
- (error) => error instanceof SyntaxError ? Effect_exports.fail(new ResponseDecodeError()) : Effect_exports.die(error)
410
+ json: () => (
411
+ // oxlint-disable-next-line executor/authored-code-through-adapter -- a Response the app passes from its own code
412
+ Effect_exports.tryPromise({
413
+ try: () => response.json(),
414
+ catch: (error) => error
415
+ }).pipe(
416
+ Effect_exports.catch(
417
+ (error) => error instanceof SyntaxError ? Effect_exports.fail(new ResponseDecodeError()) : Effect_exports.die(error)
418
+ )
393
419
  )
394
420
  )
395
421
  };
@@ -398,6 +424,8 @@ var decodeJson2 = (response, schema) => {
398
424
  export {
399
425
  CacheError,
400
426
  ElicitationFailed,
427
+ FetchOptionUnsupported,
428
+ NetworkRefused,
401
429
  NonRetryableError,
402
430
  NotImplemented,
403
431
  OAuth2AccessToken2 as OAuth2AccessToken,
@@ -412,11 +440,10 @@ export {
412
440
  cron,
413
441
  decodeJson2 as decodeJson,
414
442
  defineApp,
415
- defineDatabase,
416
443
  defineProvider,
417
444
  dynamicRouter,
418
445
  dynamicSkills,
419
- id,
446
+ event,
420
447
  interval,
421
448
  json,
422
449
  jsonSchema,
@@ -425,13 +452,15 @@ export {
425
452
  number,
426
453
  oauth22 as oauth2,
427
454
  object,
455
+ plain,
428
456
  query,
457
+ raw,
429
458
  record,
430
459
  router,
431
460
  secrets2 as secrets,
432
461
  string,
433
- table,
434
- userId,
462
+ toolAnnotations,
435
463
  withApproval,
464
+ withApprovals,
436
465
  workflow
437
466
  };
package/js/mcp/effect.js CHANGED
@@ -1,30 +1,32 @@
1
1
  import {
2
2
  mcpClientEffect,
3
+ mcpHealthEffect,
3
4
  mcpToolsEffect
4
- } from "../chunk-6BSSI67S.js";
5
- import "../chunk-ITM77QPO.js";
5
+ } from "../chunk-MRV45IXB.js";
6
+ import "../chunk-CWW7QWP4.js";
6
7
  import "../chunk-BCSNKUAC.js";
7
- import "../chunk-SB4HEPNJ.js";
8
- import "../chunk-NKLWZJLE.js";
9
- import "../chunk-MNMNLXBL.js";
10
- import "../chunk-IPI4MFSN.js";
11
- import "../chunk-OE3QQTSB.js";
12
- import "../chunk-ZQINWV4W.js";
13
- import "../chunk-T7GKZBLP.js";
14
- import "../chunk-MKWZPDR6.js";
15
- import "../chunk-B3EOZTK3.js";
16
- import "../chunk-N7YDVXYJ.js";
17
- import "../chunk-R3EV5FTO.js";
18
- import "../chunk-JU7VHODU.js";
19
- import "../chunk-RJDDBDSN.js";
20
- import "../chunk-57RKNWL2.js";
21
- import "../chunk-UK573G7W.js";
22
- import "../chunk-5T57N25Q.js";
23
- import "../chunk-PZB6T6KU.js";
24
- import "../chunk-27F7W2LG.js";
25
- import "../chunk-CDL5PM2Q.js";
8
+ import "../chunk-MZNCLCGJ.js";
9
+ import "../chunk-AQU56EPI.js";
10
+ import "../chunk-ZYTA5MK4.js";
11
+ import "../chunk-NS3DEHVA.js";
12
+ import "../chunk-XBG7HHXC.js";
13
+ import "../chunk-ERJ5JGCB.js";
14
+ import "../chunk-JIU25DIL.js";
15
+ import "../chunk-T53665H5.js";
16
+ import "../chunk-TLWLJ7PD.js";
17
+ import "../chunk-MWKHKOTL.js";
18
+ import "../chunk-H72MEDMN.js";
19
+ import "../chunk-KGCTYL2S.js";
20
+ import "../chunk-FFSO3J76.js";
21
+ import "../chunk-PD6I2SDG.js";
22
+ import "../chunk-5FHWNLCI.js";
23
+ import "../chunk-H2CJWXA3.js";
24
+ import "../chunk-TUMGL2OC.js";
25
+ import "../chunk-EOPQ727L.js";
26
+ import "../chunk-IFJU5SYQ.js";
26
27
  import "../chunk-CZ7CSFO4.js";
27
28
  export {
28
29
  mcpClientEffect,
30
+ mcpHealthEffect,
29
31
  mcpToolsEffect
30
32
  };
package/js/mcp/stdio.js CHANGED
@@ -1,37 +1,40 @@
1
1
  import {
2
2
  adaptMcpTools,
3
+ answeredError,
3
4
  mcpClient,
4
5
  mcpJsonSchemaValidator
5
- } from "../chunk-ITM77QPO.js";
6
+ } from "../chunk-CWW7QWP4.js";
6
7
  import {
7
8
  protocolRouter
8
- } from "../chunk-ECQFRCH4.js";
9
+ } from "../chunk-2ARGIHVD.js";
9
10
  import "../chunk-BCSNKUAC.js";
10
- import "../chunk-SB4HEPNJ.js";
11
- import "../chunk-NKLWZJLE.js";
12
- import "../chunk-MNMNLXBL.js";
13
- import "../chunk-IPI4MFSN.js";
14
- import "../chunk-OE3QQTSB.js";
15
- import "../chunk-ZQINWV4W.js";
16
- import "../chunk-T7GKZBLP.js";
17
- import "../chunk-MKWZPDR6.js";
11
+ import "../chunk-MZNCLCGJ.js";
12
+ import "../chunk-AQU56EPI.js";
13
+ import "../chunk-ZYTA5MK4.js";
14
+ import "../chunk-NS3DEHVA.js";
15
+ import "../chunk-XBG7HHXC.js";
16
+ import "../chunk-ERJ5JGCB.js";
17
+ import "../chunk-JIU25DIL.js";
18
+ import "../chunk-T53665H5.js";
18
19
  import {
19
20
  McpError,
20
21
  ProcessConfig
21
- } from "../chunk-B3EOZTK3.js";
22
- import "../chunk-N7YDVXYJ.js";
23
- import "../chunk-R3EV5FTO.js";
24
- import "../chunk-JU7VHODU.js";
25
- import "../chunk-RJDDBDSN.js";
26
- import "../chunk-57RKNWL2.js";
27
- import "../chunk-UK573G7W.js";
28
- import "../chunk-5T57N25Q.js";
29
- import "../chunk-PZB6T6KU.js";
30
- import "../chunk-27F7W2LG.js";
22
+ } from "../chunk-TLWLJ7PD.js";
23
+ import "../chunk-MWKHKOTL.js";
24
+ import "../chunk-H72MEDMN.js";
25
+ import "../chunk-KGCTYL2S.js";
26
+ import {
27
+ owned
28
+ } from "../chunk-FFSO3J76.js";
29
+ import "../chunk-PD6I2SDG.js";
30
+ import "../chunk-5FHWNLCI.js";
31
+ import "../chunk-H2CJWXA3.js";
32
+ import "../chunk-TUMGL2OC.js";
33
+ import "../chunk-EOPQ727L.js";
31
34
  import {
32
35
  Effect_exports,
33
36
  Schema_exports
34
- } from "../chunk-CDL5PM2Q.js";
37
+ } from "../chunk-IFJU5SYQ.js";
35
38
  import "../chunk-CZ7CSFO4.js";
36
39
 
37
40
  // src/implementation/mcp-stdio.ts
@@ -59,10 +62,14 @@ var OwnedTransport = class extends StdioClientTransport {
59
62
  })();
60
63
  }
61
64
  };
62
- var failure = (phase, error) => new McpError({
63
- phase,
64
- reason: error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : "request"
65
- });
65
+ var failure = (phase, error) => {
66
+ const upstream = answeredError(error);
67
+ return new McpError({
68
+ phase,
69
+ reason: error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : "request",
70
+ ...upstream === void 0 ? {} : { upstream }
71
+ });
72
+ };
66
73
  function withClient(config, mode, use) {
67
74
  return Effect_exports.scoped(
68
75
  Effect_exports.gen(function* () {
@@ -83,22 +90,25 @@ function withClient(config, mode, use) {
83
90
  stderr: "ignore"
84
91
  })
85
92
  })),
86
- ({ client: client2, transport: transport2 }) => Effect_exports.tryPromise(async () => {
87
- try {
88
- await client2.close();
89
- } finally {
90
- await transport2.close();
91
- }
92
- }).pipe(Effect_exports.withSpan("provider.mcp.close"), Effect_exports.orDie)
93
+ ({ client: client2, transport: transport2 }) => (
94
+ // oxlint-disable-next-line executor/authored-code-through-adapter -- MCP SDK
95
+ Effect_exports.tryPromise(async () => {
96
+ try {
97
+ await client2.close();
98
+ } finally {
99
+ await transport2.close();
100
+ }
101
+ }).pipe(owned("upstream", "provider.mcp.close"), Effect_exports.orDie)
102
+ )
93
103
  );
94
104
  yield* Effect_exports.tryPromise({
95
105
  try: (signal) => client.connect(transport, { signal, timeout: config.timeoutMs }),
96
106
  catch: (error) => failure("connect", error)
97
- }).pipe(Effect_exports.timeout(config.timeoutMs), Effect_exports.withSpan("provider.mcp.connect"));
107
+ }).pipe(Effect_exports.timeout(config.timeoutMs), owned("upstream", "provider.mcp.connect"));
98
108
  return yield* use(client);
99
109
  })
100
110
  ).pipe(
101
- Effect_exports.withSpan("provider.mcp.session", {
111
+ owned("upstream", "provider.mcp.session", {
102
112
  attributes: { "mcp.transport": "stdio", "mcp.operation": mode }
103
113
  }),
104
114
  (operation) => mode === "discover" ? operation.pipe(Effect_exports.timeout(config.timeoutMs)) : operation,
package/js/mcp.js CHANGED
@@ -1,55 +1,62 @@
1
1
  import {
2
- mcpClientEffect
3
- } from "./chunk-6BSSI67S.js";
2
+ mcpClientEffect,
3
+ mcpHealthEffect
4
+ } from "./chunk-MRV45IXB.js";
4
5
  import {
5
- catalogCache
6
- } from "./chunk-RFVIONFX.js";
6
+ catalogCache,
7
+ catalogScope
8
+ } from "./chunk-IJ6Y2KFQ.js";
7
9
  import {
8
10
  adaptMcpTool
9
- } from "./chunk-ITM77QPO.js";
11
+ } from "./chunk-CWW7QWP4.js";
10
12
  import {
11
13
  protocolOperations
12
- } from "./chunk-ECQFRCH4.js";
14
+ } from "./chunk-2ARGIHVD.js";
13
15
  import "./chunk-BCSNKUAC.js";
14
- import "./chunk-SB4HEPNJ.js";
16
+ import "./chunk-MZNCLCGJ.js";
15
17
  import {
16
18
  cacheKey
17
- } from "./chunk-NKLWZJLE.js";
18
- import "./chunk-MNMNLXBL.js";
19
- import "./chunk-IPI4MFSN.js";
20
- import "./chunk-OE3QQTSB.js";
21
- import "./chunk-ZQINWV4W.js";
19
+ } from "./chunk-AQU56EPI.js";
20
+ import {
21
+ operationDescription
22
+ } from "./chunk-ZYTA5MK4.js";
23
+ import "./chunk-NS3DEHVA.js";
24
+ import "./chunk-XBG7HHXC.js";
25
+ import "./chunk-ERJ5JGCB.js";
22
26
  import {
23
27
  nativeOperation,
24
28
  routerDeclaration
25
- } from "./chunk-T7GKZBLP.js";
26
- import "./chunk-MKWZPDR6.js";
29
+ } from "./chunk-JIU25DIL.js";
30
+ import {
31
+ fromPromise,
32
+ method
33
+ } from "./chunk-T53665H5.js";
27
34
  import {
35
+ McpCredentialsUnverified,
28
36
  McpError,
29
37
  McpServerHeader,
30
38
  McpToolMetadata,
31
39
  McpToolsOptions
32
- } from "./chunk-B3EOZTK3.js";
33
- import "./chunk-N7YDVXYJ.js";
34
- import "./chunk-R3EV5FTO.js";
35
- import "./chunk-JU7VHODU.js";
36
- import "./chunk-RJDDBDSN.js";
37
- import "./chunk-57RKNWL2.js";
38
- import "./chunk-UK573G7W.js";
39
- import "./chunk-5T57N25Q.js";
40
- import "./chunk-PZB6T6KU.js";
41
- import "./chunk-27F7W2LG.js";
40
+ } from "./chunk-TLWLJ7PD.js";
41
+ import "./chunk-MWKHKOTL.js";
42
+ import "./chunk-H72MEDMN.js";
43
+ import "./chunk-KGCTYL2S.js";
44
+ import "./chunk-FFSO3J76.js";
45
+ import "./chunk-PD6I2SDG.js";
46
+ import "./chunk-5FHWNLCI.js";
47
+ import "./chunk-H2CJWXA3.js";
48
+ import "./chunk-TUMGL2OC.js";
49
+ import "./chunk-EOPQ727L.js";
42
50
  import {
43
51
  Effect_exports,
44
52
  Schema_exports
45
- } from "./chunk-CDL5PM2Q.js";
53
+ } from "./chunk-IFJU5SYQ.js";
46
54
  import "./chunk-CZ7CSFO4.js";
47
55
 
48
56
  // src/implementation/mcp-catalog.ts
49
57
  var McpToolSummary = McpToolMetadata.mapFields(
50
58
  ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
51
59
  );
52
- var invoke = (work) => Effect_exports.tryPromise({ try: work, catch: (error) => error });
53
60
  var serverMeta = (server) => {
54
61
  const title = server.title ?? server.name;
55
62
  return {
@@ -60,20 +67,22 @@ var serverMeta = (server) => {
60
67
  };
61
68
  };
62
69
  var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
63
- const parsed = yield* Schema_exports.decodeUnknownEffect(McpToolsOptions)(options).pipe(
64
- Effect_exports.mapError(() => new McpError({ phase: "connect", reason: "invalid_input" }))
65
- );
66
- const headers = {};
67
- new Headers(parsed.headers).forEach((value, name) => {
68
- headers[name] = value;
69
- });
70
- const id = yield* cacheKey({ url: parsed.url, headers, accountId: parsed.accountId ?? null });
70
+ const invalid = () => new McpError({ phase: "connect", reason: "invalid_input" });
71
+ const parsed = yield* Schema_exports.decodeUnknownEffect(McpToolsOptions)({
72
+ url: options.url,
73
+ accountId: options.account?.id,
74
+ headers: options.headers,
75
+ signal: options.signal,
76
+ timeoutMs: options.timeoutMs
77
+ }).pipe(Effect_exports.mapError(invalid));
78
+ const cache = yield* catalogScope(options, options.headers, invalid);
79
+ const id = yield* cacheKey({ url: parsed.url });
71
80
  const key = ["mcp-catalog-v3", id, "current"];
72
- const cache = options.cache;
73
- const changed = cache === void 0 ? void 0 : invoke(() => cache.invalidate(key));
74
- const client = yield* mcpClientEffect(options, changed);
81
+ const changed = cache === void 0 ? void 0 : fromPromise(method(cache, "invalidate"), "cache")(key);
82
+ const client = yield* mcpClientEffect(parsed, changed);
75
83
  const catalog = yield* catalogCache({
76
84
  ...options,
85
+ cache,
77
86
  prefix: ["mcp-catalog-v3", id],
78
87
  schema: McpToolMetadata,
79
88
  summary: {
@@ -82,7 +91,7 @@ var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
82
91
  },
83
92
  load: (context) => (context === void 0 ? client.list : mcpClientEffect(
84
93
  { ...parsed, signal: context.signal },
85
- invoke(() => context.cache.invalidate(key))
94
+ fromPromise(method(context.cache, "invalidate"), "cache")(key)
86
95
  ).pipe(Effect_exports.flatMap((source) => source.list))).pipe(
87
96
  Effect_exports.flatMap(
88
97
  ({ tools, server }) => Schema_exports.encodeEffect(McpServerHeader)(server).pipe(
@@ -99,12 +108,18 @@ var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
99
108
  ...tool.title === void 0 ? {} : { title: tool.title },
100
109
  annotations: { ...tool.annotations, readOnlyHint: kindOf(tool) === "query" }
101
110
  });
102
- const describe = (tool) => ({
103
- ...summarize(tool),
104
- inputSchema: tool.inputSchema,
105
- ...tool.outputSchema === void 0 ? {} : { outputSchema: tool.outputSchema },
106
- ...tool._meta === void 0 ? {} : { _meta: tool._meta }
107
- });
111
+ const operation = (tool) => adaptMcpTool(client, tool).pipe(
112
+ Effect_exports.map(
113
+ (adapted) => nativeOperation(
114
+ protocolOperations({ selected: adapted }, { selected: kindOf(tool) }).selected
115
+ )
116
+ )
117
+ );
118
+ const describe = (tool) => operation(tool).pipe(
119
+ Effect_exports.flatMap(
120
+ (selected) => selected === void 0 ? Effect_exports.succeed(void 0) : operationDescription(tool.name, "", selected)
121
+ )
122
+ );
108
123
  const router = {
109
124
  kind: "dynamic",
110
125
  meta: () => catalog.header().pipe(
@@ -113,16 +128,21 @@ var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
113
128
  ),
114
129
  Effect_exports.map(serverMeta)
115
130
  ),
116
- list: () => catalog.list().pipe(Effect_exports.map((tools) => tools.map(describe))),
131
+ list: () => catalog.list().pipe(
132
+ Effect_exports.flatMap((tools) => Effect_exports.forEach(tools, describe)),
133
+ Effect_exports.map((tools) => tools.filter((tool) => tool !== void 0))
134
+ ),
117
135
  summaries: () => catalog.summaries().pipe(Effect_exports.map((tools) => tools.map(summarize))),
118
- describe: (name) => catalog.resolve(name).pipe(Effect_exports.map((tool) => tool === void 0 ? void 0 : describe(tool))),
119
- resolve: (name) => Effect_exports.gen(function* () {
120
- const tool = yield* catalog.resolve(name);
121
- if (tool === void 0) return void 0;
122
- const adapted = yield* adaptMcpTool(client, tool);
123
- const operations = protocolOperations({ selected: adapted }, { selected: kindOf(tool) });
124
- return nativeOperation(operations.selected);
125
- })
136
+ describe: (name) => catalog.resolve(name).pipe(
137
+ Effect_exports.flatMap(
138
+ (tool) => tool === void 0 ? Effect_exports.succeed(void 0) : describe(tool)
139
+ )
140
+ ),
141
+ resolve: (name) => catalog.resolve(name).pipe(
142
+ Effect_exports.flatMap(
143
+ (tool) => tool === void 0 ? Effect_exports.succeed(void 0) : operation(tool)
144
+ )
145
+ )
126
146
  };
127
147
  return routerDeclaration(router);
128
148
  });
@@ -132,7 +152,10 @@ var mcpRouter = (options, kinds = {}) => Effect_exports.runPromise(
132
152
  mcpCatalog(options, kinds),
133
153
  options.signal === void 0 ? {} : { signal: options.signal }
134
154
  );
155
+ var mcpHealth = (check, options) => Effect_exports.runPromise(mcpHealthEffect(check, options), { signal: check.signal });
135
156
  export {
157
+ McpCredentialsUnverified,
136
158
  McpError,
159
+ mcpHealth,
137
160
  mcpRouter
138
161
  };