apps 0.0.1-beta.0 → 0.0.1-beta.2

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 (114) hide show
  1. package/README.md +97 -4
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/{chunk-SBKHUC5L.js → chunk-4LPG6RCH.js} +2 -2
  5. package/js/chunk-5MQZEB6Y.js +172 -0
  6. package/js/{chunk-7JXHF5IF.js → chunk-BMOIAIVR.js} +1 -1
  7. package/js/chunk-CZ7CSFO4.js +39 -0
  8. package/js/chunk-D47C7KG5.js +172 -0
  9. package/js/{chunk-YDR4CPJA.js → chunk-EVJUVWN2.js} +8 -8
  10. package/js/chunk-FDNTX5QJ.js +78 -0
  11. package/js/{chunk-2OTCEKL2.js → chunk-FW5HBOIK.js} +2352 -1493
  12. package/js/{chunk-EP6AEUZO.js → chunk-FZJOYIZO.js} +1 -1
  13. package/js/{chunk-VFUZI3NY.js → chunk-HDJH3RPR.js} +4 -4
  14. package/js/{chunk-WIDTG42X.js → chunk-HDTGZWP2.js} +79 -26
  15. package/js/{chunk-Q2FD5IBM.js → chunk-J7O55ZV7.js} +298 -37
  16. package/js/{chunk-X3YBZCJW.js → chunk-JN55AYQH.js} +8 -41
  17. package/js/chunk-LGIYBDWA.js +85 -0
  18. package/js/{chunk-D6BKYP2L.js → chunk-M6ZRRIBI.js} +4 -4
  19. package/js/{chunk-HP7E42X6.js → chunk-MYYEW3RA.js} +767 -249
  20. package/js/{chunk-3ANFZFCV.js → chunk-OHRT55C4.js} +15 -15
  21. package/js/{chunk-R6JMJSVT.js → chunk-PLCMJREA.js} +2 -2
  22. package/js/{chunk-C24KEZXR.js → chunk-PYUYJRSK.js} +36 -2
  23. package/js/{chunk-W7Q5EOTS.js → chunk-QKHR7BMF.js} +32 -32
  24. package/js/{chunk-KWTCHVLT.js → chunk-RN2MXB4R.js} +47 -51
  25. package/js/{chunk-36DNRFZQ.js → chunk-SATWJKN6.js} +1 -1
  26. package/js/chunk-SWPD52J7.js +35 -0
  27. package/js/{chunk-BKVL7XAJ.js → chunk-TE4KO4HI.js} +1 -1
  28. package/js/chunk-UVL56Z6E.js +6641 -0
  29. package/js/chunk-W7D7WVSY.js +18 -0
  30. package/js/{chunk-BPEFS4YF.js → chunk-WFSQXYUT.js} +109 -17
  31. package/js/chunk-YEJOQEII.js +104 -0
  32. package/js/{chunk-LOKGDT6B.js → chunk-Z5NMEGJN.js} +5 -4
  33. package/js/{chunk-OWD2YICM.js → chunk-ZCAMUXSG.js} +116 -87
  34. package/js/chunk-ZJWDMTE3.js +63 -0
  35. package/js/client.js +11 -11
  36. package/js/contracts.js +88 -25
  37. package/js/effect.js +21 -15
  38. package/js/es-APDZKREY.js +40968 -0
  39. package/js/graphql.js +224 -121
  40. package/js/host.js +76 -19
  41. package/js/index.js +193 -51
  42. package/js/mcp/effect.js +25 -17
  43. package/js/mcp/stdio.js +23 -17
  44. package/js/mcp.js +110 -24
  45. package/js/openapi.js +3045 -105
  46. package/js/operations/approval.js +1 -1
  47. package/js/react.js +4 -4
  48. package/js/skills/effect.js +11 -0
  49. package/js/skills.js +894 -0
  50. package/js/storage/facet.js +7 -7
  51. package/js/ui/auth/contracts.js +6 -6
  52. package/js/ui/auth.js +8 -8
  53. package/js/ui/contracts.js +5 -5
  54. package/js/ui/serving.js +12 -12
  55. package/package.json +9 -1
  56. package/runtime.json +1 -1
  57. package/types/app-cache/src/contracts/cache.d.ts +119 -0
  58. package/types/app-cache/src/index.d.ts +93 -0
  59. package/types/apps/src/contracts/api-response-error.d.ts +43 -0
  60. package/types/apps/src/contracts/app.d.ts +11 -0
  61. package/types/apps/src/contracts/cache.d.ts +44 -0
  62. package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
  63. package/types/apps/src/contracts/dynamic-tools.d.ts +13 -0
  64. package/types/apps/src/contracts/graphql.d.ts +18 -1
  65. package/types/apps/src/contracts/host.d.ts +54 -525
  66. package/types/apps/src/contracts/mcp.d.ts +3 -1
  67. package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
  68. package/types/apps/src/contracts/openapi-document.d.ts +53 -0
  69. package/types/apps/src/contracts/openapi.d.ts +156 -30
  70. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  71. package/types/apps/src/contracts/protocols/1.d.ts +1575 -0
  72. package/types/apps/src/contracts/provider-error.d.ts +15 -0
  73. package/types/apps/src/contracts/provider.d.ts +18 -1
  74. package/types/apps/src/contracts/skills.d.ts +122 -0
  75. package/types/apps/src/contracts/swagger-client.d.ts +29 -0
  76. package/types/apps/src/graphql.d.ts +6 -6
  77. package/types/apps/src/host.d.ts +1 -0
  78. package/types/apps/src/implementation/account-operations.d.ts +122 -3
  79. package/types/apps/src/implementation/app.d.ts +1 -1
  80. package/types/apps/src/implementation/cache-session.d.ts +7 -0
  81. package/types/apps/src/implementation/cache.d.ts +8 -0
  82. package/types/apps/src/implementation/catalog-cache.d.ts +29 -0
  83. package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
  84. package/types/apps/src/implementation/dynamic-tools.d.ts +8 -0
  85. package/types/apps/src/implementation/elicitation.d.ts +12 -12
  86. package/types/apps/src/implementation/git.d.ts +25 -0
  87. package/types/apps/src/implementation/graphql-catalog.d.ts +10 -0
  88. package/types/apps/src/implementation/graphql.d.ts +81 -3
  89. package/types/apps/src/implementation/inflate.d.ts +16 -0
  90. package/types/apps/src/implementation/input-problems.d.ts +3 -0
  91. package/types/apps/src/implementation/mcp-call.d.ts +3 -2
  92. package/types/apps/src/implementation/mcp-catalog.d.ts +12 -0
  93. package/types/apps/src/implementation/mcp-client.d.ts +9 -8
  94. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  95. package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
  96. package/types/apps/src/implementation/mcp.d.ts +39 -2
  97. package/types/apps/src/implementation/openapi-compile.d.ts +119 -0
  98. package/types/apps/src/implementation/openapi-document.d.ts +51 -0
  99. package/types/apps/src/implementation/openapi-names.d.ts +18 -0
  100. package/types/apps/src/implementation/openapi-request.d.ts +10 -4
  101. package/types/apps/src/implementation/openapi-source.d.ts +40 -0
  102. package/types/apps/src/implementation/openapi.d.ts +39 -3
  103. package/types/apps/src/implementation/provider-error.d.ts +10 -0
  104. package/types/apps/src/implementation/schema.d.ts +6 -5
  105. package/types/apps/src/implementation/skill-files.d.ts +10 -0
  106. package/types/apps/src/implementation/skills.d.ts +43 -0
  107. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  108. package/types/apps/src/index.d.ts +7 -0
  109. package/types/apps/src/mcp.d.ts +5 -5
  110. package/types/apps/src/openapi.d.ts +3 -1
  111. package/types/apps/src/skills.d.ts +75 -0
  112. package/types/telemetry/src/config.d.ts +2 -0
  113. package/js/chunk-22WRQZT7.js +0 -389
  114. package/js/chunk-MLKGABMK.js +0 -9
package/js/index.js CHANGED
@@ -3,18 +3,24 @@ import {
3
3
  defineDatabase,
4
4
  table,
5
5
  workflow
6
- } from "./chunk-X3YBZCJW.js";
7
- import "./chunk-R6JMJSVT.js";
6
+ } from "./chunk-JN55AYQH.js";
7
+ import "./chunk-PLCMJREA.js";
8
8
  import {
9
+ fromPromise,
9
10
  mutation,
10
11
  nativeOperation,
11
12
  operationDeclaration,
12
13
  query,
13
14
  withApproval
14
- } from "./chunk-C24KEZXR.js";
15
+ } from "./chunk-PYUYJRSK.js";
16
+ import {
17
+ accountProviderError
18
+ } from "./chunk-ZJWDMTE3.js";
15
19
  import {
16
20
  CalendarSchedule,
17
21
  ElicitationFailed,
22
+ HostedTool,
23
+ HostedToolSummary,
18
24
  Interval,
19
25
  NonRetryableError,
20
26
  OAuth2AccessToken,
@@ -24,8 +30,16 @@ import {
24
30
  ScheduleTiming,
25
31
  SecretsMethod,
26
32
  WorkflowFailure
27
- } from "./chunk-HP7E42X6.js";
28
- import "./chunk-7JXHF5IF.js";
33
+ } from "./chunk-MYYEW3RA.js";
34
+ import "./chunk-BMOIAIVR.js";
35
+ import {
36
+ CacheError
37
+ } from "./chunk-LGIYBDWA.js";
38
+ import "./chunk-YEJOQEII.js";
39
+ import "./chunk-SWPD52J7.js";
40
+ import {
41
+ ProviderError
42
+ } from "./chunk-W7D7WVSY.js";
29
43
  import {
30
44
  array,
31
45
  boolean,
@@ -38,24 +52,25 @@ import {
38
52
  nestJsonSchema,
39
53
  number,
40
54
  object,
55
+ once,
41
56
  parse,
42
57
  record,
43
58
  string,
44
59
  userId,
45
- withJsonSchemaDocument,
60
+ withLazyJsonSchemaDocument,
46
61
  wrap
47
- } from "./chunk-BPEFS4YF.js";
48
- import "./chunk-EP6AEUZO.js";
62
+ } from "./chunk-WFSQXYUT.js";
63
+ import "./chunk-FZJOYIZO.js";
49
64
  import {
50
65
  JsonObject,
51
66
  JsonValue,
52
67
  ValidationError
53
- } from "./chunk-36DNRFZQ.js";
68
+ } from "./chunk-SATWJKN6.js";
54
69
  import {
55
70
  Effect_exports,
56
71
  Schema_exports
57
- } from "./chunk-2OTCEKL2.js";
58
- import "./chunk-MLKGABMK.js";
72
+ } from "./chunk-FW5HBOIK.js";
73
+ import "./chunk-CZ7CSFO4.js";
59
74
 
60
75
  // src/contracts/http.ts
61
76
  var ResponseStatusError = class extends Schema_exports.TaggedError()(
@@ -96,6 +111,10 @@ var inputDocument = (operation) => {
96
111
  const document = Schema_exports.toJsonSchemaDocument(operation.input);
97
112
  return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
98
113
  };
114
+ var declaresOutput = (operation) => {
115
+ const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
116
+ return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
117
+ };
99
118
  var combine = (kind, groups) => Object.fromEntries(
100
119
  [...groups].map(([name, accounts]) => {
101
120
  const variants = [...accounts.values()];
@@ -108,15 +127,12 @@ var combine = (kind, groups) => Object.fromEntries(
108
127
  throw new Error("Account selection must be decoded before execution");
109
128
  return operation;
110
129
  };
111
- const outputs = variants.flatMap(
112
- (operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
113
- );
114
130
  const input = Schema_exports.Union(
115
131
  [...accounts].map(
116
132
  ([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
117
133
  )
118
134
  );
119
- const inputSchema = {
135
+ const inputSchema = () => ({
120
136
  type: "object",
121
137
  anyOf: [...accounts].map(([accountId, operation], index) => ({
122
138
  type: "object",
@@ -126,55 +142,100 @@ var combine = (kind, groups) => Object.fromEntries(
126
142
  },
127
143
  required: ["accountId", "input"]
128
144
  }))
129
- };
130
- return [
131
- name,
132
- operationDeclaration({
133
- kind,
134
- ...first.description === void 0 ? {} : { description: first.description },
135
- ...first.title === void 0 ? {} : { title: first.title },
136
- ...first.annotations === void 0 || !variants.every(
137
- (operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
138
- ) ? {} : { annotations: first.annotations },
139
- ...first._meta === void 0 || !variants.every(
140
- (operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)
141
- ) ? {} : { _meta: first._meta },
142
- input: withJsonSchemaDocument(input, inputSchema),
143
- ...outputs.length !== variants.length ? {} : {
144
- outputSchema: {
145
- anyOf: outputs.map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
146
- }
147
- },
148
- approval: (context) => {
149
- const operation = select(context.toolInput);
150
- return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
151
- },
152
- run: (context, input2) => {
153
- const operation = select(input2);
154
- return operation.run(context, input2.input).pipe(
155
- Effect_exports.flatMap(
156
- (output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
157
- )
158
- );
159
- }
160
- })
161
- ];
145
+ });
146
+ const declaration2 = operationDeclaration({
147
+ kind,
148
+ ...first.description === void 0 ? {} : { description: first.description },
149
+ ...first.title === void 0 ? {} : { title: first.title },
150
+ ...first.annotations === void 0 || !variants.every(
151
+ (operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
152
+ ) ? {} : { annotations: first.annotations },
153
+ ...first._meta === void 0 || !variants.every(
154
+ (operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)
155
+ ) ? {} : { _meta: first._meta },
156
+ input: withLazyJsonSchemaDocument(input, inputSchema),
157
+ approval: (context) => {
158
+ const operation = select(context.toolInput);
159
+ return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
160
+ },
161
+ run: (context, input2) => {
162
+ const operation = select(input2);
163
+ return operation.run(context, input2.input).pipe(
164
+ Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
165
+ Effect_exports.flatMap(
166
+ (output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
167
+ )
168
+ );
169
+ }
170
+ });
171
+ if (variants.every(declaresOutput)) {
172
+ const outputSchema = once(() => ({
173
+ anyOf: variants.flatMap(
174
+ (operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
175
+ ).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
176
+ }));
177
+ const native = nativeOperation(declaration2);
178
+ if (native !== void 0)
179
+ Object.defineProperty(native, "outputSchema", { enumerable: true, get: outputSchema });
180
+ }
181
+ return [name, declaration2];
162
182
  })
163
183
  );
184
+ var sameAcross = (key, variants) => {
185
+ const first = variants[0]?.[1][key];
186
+ return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
187
+ };
188
+ var mergeSummary = (name, variants) => {
189
+ const first = variants[0]?.[1];
190
+ if (first === void 0) throw new Error("Expected a source operation");
191
+ return Schema_exports.decodeUnknownSync(HostedToolSummary)({
192
+ name,
193
+ description: first.description,
194
+ ...first.title === void 0 ? {} : { title: first.title },
195
+ readOnly: name.startsWith("queries."),
196
+ ...sameAcross("annotations", variants)
197
+ });
198
+ };
199
+ var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
200
+ ...mergeSummary(name, variants),
201
+ inputSchema: {
202
+ type: "object",
203
+ anyOf: variants.map(([accountId, tool], index) => ({
204
+ type: "object",
205
+ properties: {
206
+ accountId: { type: "string", const: accountId },
207
+ input: nestJsonSchema(tool.inputSchema, `#/anyOf/${index}/properties/input`)
208
+ },
209
+ required: ["accountId", "input"]
210
+ }))
211
+ },
212
+ ...variants.every(([, tool]) => tool.outputSchema !== void 0) ? {
213
+ outputSchema: {
214
+ anyOf: variants.flatMap(
215
+ ([, tool], index) => tool.outputSchema === void 0 ? [] : [nestJsonSchema(tool.outputSchema, `#/anyOf/${index}`)]
216
+ )
217
+ }
218
+ } : {},
219
+ ...sameAcross("_meta", variants)
220
+ });
164
221
  var accountOperations = (accounts, discover, options) => Effect_exports.runPromise(
165
222
  Effect_exports.gen(function* () {
166
223
  const queries = /* @__PURE__ */ new Map();
167
224
  const mutations = /* @__PURE__ */ new Map();
225
+ const sources = /* @__PURE__ */ new Map();
168
226
  for (const account of accounts) {
169
227
  const operations = yield* Effect_exports.tryPromise({
170
228
  try: () => discover(account),
171
- catch: (error) => error
229
+ catch: (error) => accountProviderError(error, account.id)
172
230
  });
231
+ if (sources.has(account.id))
232
+ return yield* Effect_exports.die(new Error("Account selections must be unique"));
233
+ if (operations.dynamicTools !== void 0) sources.set(account.id, operations.dynamicTools);
173
234
  for (const [source, target] of [
174
235
  [operations.queries, queries],
175
236
  [operations.mutations, mutations]
176
237
  ]) {
177
- for (const [name, declaration2] of Object.entries(source)) {
238
+ for (const [name, declaration2] of Object.entries(source ?? {})) {
178
239
  const operation = nativeOperation(declaration2);
179
240
  if (operation === void 0)
180
241
  return yield* Effect_exports.die(new Error("Expected a protocol operation"));
@@ -186,11 +247,88 @@ var accountOperations = (accounts, discover, options) => Effect_exports.runPromi
186
247
  }
187
248
  }
188
249
  }
189
- return { queries: combine("query", queries), mutations: combine("mutation", mutations) };
250
+ const declared = {
251
+ queries: combine("query", queries),
252
+ mutations: combine("mutation", mutations)
253
+ };
254
+ if (sources.size === 0) return declared;
255
+ const grouped = (read) => Effect_exports.gen(function* () {
256
+ const groups = /* @__PURE__ */ new Map();
257
+ for (const [accountId, source] of sources) {
258
+ const tools = yield* read(source).pipe(
259
+ Effect_exports.mapError((error) => accountProviderError(error, accountId))
260
+ );
261
+ for (const tool of tools) {
262
+ const variants = groups.get(tool.name) ?? [];
263
+ if (variants.some(([id2]) => id2 === accountId))
264
+ return yield* Effect_exports.die(new Error("Duplicate source operation"));
265
+ variants.push([accountId, tool]);
266
+ groups.set(tool.name, variants);
267
+ }
268
+ }
269
+ return groups;
270
+ });
271
+ return {
272
+ ...declared,
273
+ dynamicTools: {
274
+ list: () => grouped((source) => source.list()).pipe(
275
+ Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
276
+ ),
277
+ summaries: () => grouped(
278
+ (source) => source.summaries === void 0 ? source.list() : source.summaries()
279
+ ).pipe(
280
+ Effect_exports.map(
281
+ (groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants))
282
+ )
283
+ ),
284
+ describe: (name) => Effect_exports.gen(function* () {
285
+ const variants = [];
286
+ for (const [accountId, source] of sources) {
287
+ const tool = yield* (source.describe === void 0 ? source.list().pipe(Effect_exports.map((tools) => tools.find((tool2) => tool2.name === name))) : source.describe(name)).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
288
+ if (tool !== void 0) variants.push([accountId, tool]);
289
+ }
290
+ return variants.length === 0 ? void 0 : merge(name, variants);
291
+ }),
292
+ resolve: (name) => Effect_exports.gen(function* () {
293
+ const kind = name.startsWith("queries.") ? "query" : "mutation";
294
+ const operations = /* @__PURE__ */ new Map();
295
+ for (const [accountId, source] of sources) {
296
+ const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
297
+ if (operation !== void 0) {
298
+ if (operation.kind !== kind)
299
+ return yield* Effect_exports.die(new Error("Operation kind changed"));
300
+ operations.set(accountId, operation);
301
+ }
302
+ }
303
+ if (operations.size === 0) return void 0;
304
+ return nativeOperation(combine(kind, /* @__PURE__ */ new Map([[name, operations]]))[name]);
305
+ })
306
+ }
307
+ };
190
308
  }),
191
309
  options
192
310
  );
193
311
 
312
+ // src/implementation/dynamic-tools.ts
313
+ var dynamicTools = (source) => ({
314
+ list: () => fromPromise(source.list)().pipe(
315
+ Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
316
+ ),
317
+ resolve: (name) => fromPromise(source.resolve)(name).pipe(
318
+ Effect_exports.map((value) => {
319
+ if (value === void 0) return void 0;
320
+ const operation = nativeOperation(value);
321
+ if (operation === void 0) throw new Error("Expected an operation declaration");
322
+ return operation;
323
+ })
324
+ )
325
+ });
326
+
327
+ // src/implementation/dynamic-skills.ts
328
+ var dynamicSkills = (source) => ({
329
+ list: fromPromise(async () => source.list())
330
+ });
331
+
194
332
  // src/contracts/app.ts
195
333
  var NotImplemented = class extends Schema_exports.TaggedError()("NotImplemented", {
196
334
  operation: Schema_exports.String
@@ -248,10 +386,12 @@ var decodeJson2 = (response, schema) => {
248
386
  return Effect_exports.runPromise(decodeJson(native, decoderOf(schema)));
249
387
  };
250
388
  export {
389
+ CacheError,
251
390
  ElicitationFailed,
252
391
  NonRetryableError,
253
392
  NotImplemented,
254
393
  OAuth2AccessToken2 as OAuth2AccessToken,
394
+ ProviderError,
255
395
  ResponseDecodeError,
256
396
  ResponseStatusError,
257
397
  ValidationError,
@@ -264,6 +404,8 @@ export {
264
404
  defineApp,
265
405
  defineDatabase,
266
406
  defineProvider,
407
+ dynamicSkills,
408
+ dynamicTools,
267
409
  id,
268
410
  interval,
269
411
  json,
package/js/mcp/effect.js CHANGED
@@ -1,23 +1,31 @@
1
1
  import {
2
+ mcpClientEffect,
2
3
  mcpToolsEffect
3
- } from "../chunk-WIDTG42X.js";
4
- import "../chunk-KWTCHVLT.js";
4
+ } from "../chunk-HDTGZWP2.js";
5
+ import "../chunk-RN2MXB4R.js";
5
6
  import "../chunk-BCSNKUAC.js";
6
- import "../chunk-Q2FD5IBM.js";
7
- import "../chunk-X3YBZCJW.js";
8
- import "../chunk-R6JMJSVT.js";
9
- import "../chunk-C24KEZXR.js";
10
- import "../chunk-22WRQZT7.js";
11
- import "../chunk-HP7E42X6.js";
12
- import "../chunk-7JXHF5IF.js";
13
- import "../chunk-OWD2YICM.js";
14
- import "../chunk-VFUZI3NY.js";
15
- import "../chunk-W7Q5EOTS.js";
16
- import "../chunk-BPEFS4YF.js";
17
- import "../chunk-EP6AEUZO.js";
18
- import "../chunk-36DNRFZQ.js";
19
- import "../chunk-2OTCEKL2.js";
20
- import "../chunk-MLKGABMK.js";
7
+ import "../chunk-J7O55ZV7.js";
8
+ import "../chunk-D47C7KG5.js";
9
+ import "../chunk-FDNTX5QJ.js";
10
+ import "../chunk-JN55AYQH.js";
11
+ import "../chunk-PLCMJREA.js";
12
+ import "../chunk-PYUYJRSK.js";
13
+ import "../chunk-ZJWDMTE3.js";
14
+ import "../chunk-MYYEW3RA.js";
15
+ import "../chunk-BMOIAIVR.js";
16
+ import "../chunk-LGIYBDWA.js";
17
+ import "../chunk-YEJOQEII.js";
18
+ import "../chunk-SWPD52J7.js";
19
+ import "../chunk-W7D7WVSY.js";
20
+ import "../chunk-ZCAMUXSG.js";
21
+ import "../chunk-HDJH3RPR.js";
22
+ import "../chunk-QKHR7BMF.js";
23
+ import "../chunk-WFSQXYUT.js";
24
+ import "../chunk-FZJOYIZO.js";
25
+ import "../chunk-SATWJKN6.js";
26
+ import "../chunk-FW5HBOIK.js";
27
+ import "../chunk-CZ7CSFO4.js";
21
28
  export {
29
+ mcpClientEffect,
22
30
  mcpToolsEffect
23
31
  };
package/js/mcp/stdio.js CHANGED
@@ -2,32 +2,38 @@ import {
2
2
  adaptMcpTools,
3
3
  mcpClient,
4
4
  mcpJsonSchemaValidator
5
- } from "../chunk-KWTCHVLT.js";
5
+ } from "../chunk-RN2MXB4R.js";
6
6
  import {
7
7
  protocolOperations
8
- } from "../chunk-LOKGDT6B.js";
8
+ } from "../chunk-Z5NMEGJN.js";
9
9
  import "../chunk-BCSNKUAC.js";
10
- import "../chunk-Q2FD5IBM.js";
11
- import "../chunk-X3YBZCJW.js";
12
- import "../chunk-R6JMJSVT.js";
13
- import "../chunk-C24KEZXR.js";
10
+ import "../chunk-J7O55ZV7.js";
11
+ import "../chunk-D47C7KG5.js";
12
+ import "../chunk-FDNTX5QJ.js";
13
+ import "../chunk-JN55AYQH.js";
14
+ import "../chunk-PLCMJREA.js";
15
+ import "../chunk-PYUYJRSK.js";
16
+ import "../chunk-ZJWDMTE3.js";
14
17
  import {
15
18
  McpError,
16
19
  ProcessConfig
17
- } from "../chunk-22WRQZT7.js";
18
- import "../chunk-HP7E42X6.js";
19
- import "../chunk-7JXHF5IF.js";
20
- import "../chunk-OWD2YICM.js";
21
- import "../chunk-VFUZI3NY.js";
22
- import "../chunk-W7Q5EOTS.js";
23
- import "../chunk-BPEFS4YF.js";
24
- import "../chunk-EP6AEUZO.js";
25
- import "../chunk-36DNRFZQ.js";
20
+ } from "../chunk-MYYEW3RA.js";
21
+ import "../chunk-BMOIAIVR.js";
22
+ import "../chunk-LGIYBDWA.js";
23
+ import "../chunk-YEJOQEII.js";
24
+ import "../chunk-SWPD52J7.js";
25
+ import "../chunk-W7D7WVSY.js";
26
+ import "../chunk-ZCAMUXSG.js";
27
+ import "../chunk-HDJH3RPR.js";
28
+ import "../chunk-QKHR7BMF.js";
29
+ import "../chunk-WFSQXYUT.js";
30
+ import "../chunk-FZJOYIZO.js";
31
+ import "../chunk-SATWJKN6.js";
26
32
  import {
27
33
  Effect_exports,
28
34
  Schema_exports
29
- } from "../chunk-2OTCEKL2.js";
30
- import "../chunk-MLKGABMK.js";
35
+ } from "../chunk-FW5HBOIK.js";
36
+ import "../chunk-CZ7CSFO4.js";
31
37
 
32
38
  // src/implementation/mcp-stdio.ts
33
39
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
package/js/mcp.js CHANGED
@@ -1,34 +1,120 @@
1
1
  import {
2
- mcpToolsEffect
3
- } from "./chunk-WIDTG42X.js";
4
- import "./chunk-KWTCHVLT.js";
2
+ mcpClientEffect
3
+ } from "./chunk-HDTGZWP2.js";
4
+ import {
5
+ catalogCache
6
+ } from "./chunk-5MQZEB6Y.js";
7
+ import {
8
+ adaptMcpTool
9
+ } from "./chunk-RN2MXB4R.js";
5
10
  import {
6
11
  protocolOperations
7
- } from "./chunk-LOKGDT6B.js";
12
+ } from "./chunk-Z5NMEGJN.js";
8
13
  import "./chunk-BCSNKUAC.js";
9
- import "./chunk-Q2FD5IBM.js";
10
- import "./chunk-X3YBZCJW.js";
11
- import "./chunk-R6JMJSVT.js";
12
- import "./chunk-C24KEZXR.js";
13
- import {
14
- McpError
15
- } from "./chunk-22WRQZT7.js";
16
- import "./chunk-HP7E42X6.js";
17
- import "./chunk-7JXHF5IF.js";
18
- import "./chunk-OWD2YICM.js";
19
- import "./chunk-VFUZI3NY.js";
20
- import "./chunk-W7Q5EOTS.js";
21
- import "./chunk-BPEFS4YF.js";
22
- import "./chunk-EP6AEUZO.js";
23
- import "./chunk-36DNRFZQ.js";
24
- import {
25
- Effect_exports
26
- } from "./chunk-2OTCEKL2.js";
27
- import "./chunk-MLKGABMK.js";
14
+ import "./chunk-J7O55ZV7.js";
15
+ import {
16
+ cacheKey
17
+ } from "./chunk-D47C7KG5.js";
18
+ import "./chunk-FDNTX5QJ.js";
19
+ import "./chunk-JN55AYQH.js";
20
+ import "./chunk-PLCMJREA.js";
21
+ import {
22
+ nativeOperation
23
+ } from "./chunk-PYUYJRSK.js";
24
+ import "./chunk-ZJWDMTE3.js";
25
+ import {
26
+ McpError,
27
+ McpToolMetadata,
28
+ McpToolsOptions
29
+ } from "./chunk-MYYEW3RA.js";
30
+ import "./chunk-BMOIAIVR.js";
31
+ import "./chunk-LGIYBDWA.js";
32
+ import "./chunk-YEJOQEII.js";
33
+ import "./chunk-SWPD52J7.js";
34
+ import "./chunk-W7D7WVSY.js";
35
+ import "./chunk-ZCAMUXSG.js";
36
+ import "./chunk-HDJH3RPR.js";
37
+ import "./chunk-QKHR7BMF.js";
38
+ import "./chunk-WFSQXYUT.js";
39
+ import "./chunk-FZJOYIZO.js";
40
+ import "./chunk-SATWJKN6.js";
41
+ import {
42
+ Effect_exports,
43
+ Schema_exports
44
+ } from "./chunk-FW5HBOIK.js";
45
+ import "./chunk-CZ7CSFO4.js";
46
+
47
+ // src/implementation/mcp-catalog.ts
48
+ var McpToolSummary = McpToolMetadata.mapFields(
49
+ ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
50
+ );
51
+ var invoke = (work) => Effect_exports.tryPromise({ try: work, catch: (error) => error });
52
+ var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
53
+ const parsed = yield* Schema_exports.decodeUnknownEffect(McpToolsOptions)(options).pipe(
54
+ Effect_exports.mapError(() => new McpError({ phase: "connect", reason: "invalid_input" }))
55
+ );
56
+ const headers = {};
57
+ new Headers(parsed.headers).forEach((value, name) => {
58
+ headers[name] = value;
59
+ });
60
+ const id = yield* cacheKey({ url: parsed.url, headers, accountId: parsed.accountId ?? null });
61
+ const key = ["mcp-catalog-v2", id, "current"];
62
+ const cache = options.cache;
63
+ const changed = cache === void 0 ? void 0 : invoke(() => cache.invalidate(key));
64
+ const client = yield* mcpClientEffect(options, changed);
65
+ const catalog = yield* catalogCache({
66
+ ...options,
67
+ prefix: ["mcp-catalog-v2", id],
68
+ schema: McpToolMetadata,
69
+ summary: {
70
+ schema: McpToolSummary,
71
+ of: ({ inputSchema: _input, outputSchema: _output, _meta, ...summary }) => summary
72
+ },
73
+ load: (context) => context === void 0 ? client.list : mcpClientEffect(
74
+ { ...parsed, signal: context.signal },
75
+ invoke(() => context.cache.invalidate(key))
76
+ ).pipe(Effect_exports.flatMap((source) => source.list))
77
+ });
78
+ const kindOf = (tool) => Object.hasOwn(kinds, tool.name) ? kinds[tool.name] ?? "mutation" : tool.annotations?.readOnlyHint === true ? "query" : "mutation";
79
+ const qualified = (tool) => `${kindOf(tool) === "query" ? "queries" : "mutations"}.${tool.name}`;
80
+ const summarize = (tool) => ({
81
+ name: qualified(tool),
82
+ description: tool.description ?? tool.title ?? tool.name,
83
+ readOnly: kindOf(tool) === "query",
84
+ ...tool.title === void 0 ? {} : { title: tool.title },
85
+ annotations: { ...tool.annotations, readOnlyHint: kindOf(tool) === "query" }
86
+ });
87
+ const describe = (tool) => ({
88
+ ...summarize(tool),
89
+ inputSchema: tool.inputSchema,
90
+ ...tool.outputSchema === void 0 ? {} : { outputSchema: tool.outputSchema },
91
+ ...tool._meta === void 0 ? {} : { _meta: tool._meta }
92
+ });
93
+ const selected = (name) => Effect_exports.gen(function* () {
94
+ if (!name.startsWith("queries.") && !name.startsWith("mutations.")) return void 0;
95
+ const tool = yield* catalog.resolve(name.slice(name.indexOf(".") + 1));
96
+ return tool === void 0 || qualified(tool) !== name ? void 0 : tool;
97
+ });
98
+ const dynamicTools = {
99
+ list: () => catalog.list().pipe(Effect_exports.map((tools) => tools.map(describe))),
100
+ summaries: () => catalog.summaries().pipe(Effect_exports.map((tools) => tools.map(summarize))),
101
+ describe: (name) => selected(name).pipe(
102
+ Effect_exports.map((tool) => tool === void 0 ? void 0 : describe(tool))
103
+ ),
104
+ resolve: (name) => Effect_exports.gen(function* () {
105
+ const tool = yield* selected(name);
106
+ if (tool === void 0) return void 0;
107
+ const adapted = yield* adaptMcpTool(client, tool);
108
+ const operations = protocolOperations({ selected: adapted }, { selected: kindOf(tool) });
109
+ return nativeOperation(operations.queries.selected ?? operations.mutations.selected);
110
+ })
111
+ };
112
+ return { dynamicTools };
113
+ });
28
114
 
29
115
  // src/mcp.ts
30
116
  var mcpOperations = (options, kinds = {}) => Effect_exports.runPromise(
31
- mcpToolsEffect(options).pipe(Effect_exports.map((operations) => protocolOperations(operations, kinds))),
117
+ mcpCatalog(options, kinds),
32
118
  options.signal === void 0 ? {} : { signal: options.signal }
33
119
  );
34
120
  export {