apps 0.0.1-beta.5 → 0.0.1-beta.7

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 (66) hide show
  1. package/README.md +65 -43
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-FWQC6I3C.js → chunk-5T57N25Q.js} +13 -1
  4. package/js/{chunk-TDNYXSIX.js → chunk-72JNVHPK.js} +21 -9
  5. package/js/{chunk-UDDE5KOR.js → chunk-CMYUWAX7.js} +26 -7
  6. package/js/chunk-FL2QR3XW.js +507 -0
  7. package/js/{chunk-G7T27IWB.js → chunk-MKWZPDR6.js} +1 -1
  8. package/js/{chunk-CYYBFC2K.js → chunk-NKLWZJLE.js} +1 -1
  9. package/js/{chunk-67EVWIGJ.js → chunk-OCYUEU47.js} +4 -4
  10. package/js/{chunk-YEPYT6SD.js → chunk-R3EV5FTO.js} +12 -0
  11. package/js/{chunk-XHO2ZX6W.js → chunk-RFVIONFX.js} +27 -10
  12. package/js/{chunk-LUVSFETN.js → chunk-UESPOTUI.js} +127 -231
  13. package/js/{chunk-DQAZTA4I.js → chunk-WLE7WX2U.js} +290 -20
  14. package/js/{chunk-C3VAOK5B.js → chunk-YXQHV65J.js} +53 -26
  15. package/js/chunk-Z5M2LQOZ.js +209 -0
  16. package/js/client.js +1 -1
  17. package/js/contracts.js +34 -11
  18. package/js/effect.js +9 -11
  19. package/js/graphql.js +25 -32
  20. package/js/host.js +9 -11
  21. package/js/index.js +194 -192
  22. package/js/mcp/effect.js +11 -13
  23. package/js/mcp/stdio.js +15 -17
  24. package/js/mcp.js +50 -36
  25. package/js/openapi.js +166 -108
  26. package/js/skills.js +6 -7
  27. package/package.json +1 -1
  28. package/runtime.json +1 -1
  29. package/types/apps/src/contracts/app.d.ts +2 -5
  30. package/types/apps/src/contracts/host.d.ts +19 -7
  31. package/types/apps/src/contracts/mcp.d.ts +16 -0
  32. package/types/apps/src/contracts/openapi.d.ts +4 -0
  33. package/types/apps/src/contracts/operations.d.ts +0 -5
  34. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  35. package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
  36. package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
  37. package/types/apps/src/contracts/provider.d.ts +51 -5
  38. package/types/apps/src/contracts/router.d.ts +59 -0
  39. package/types/apps/src/graphql.d.ts +1 -3
  40. package/types/apps/src/implementation/account-router.d.ts +12 -0
  41. package/types/apps/src/implementation/app.d.ts +5 -4
  42. package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
  43. package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
  44. package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
  45. package/types/apps/src/implementation/mcp-client.d.ts +35 -19
  46. package/types/apps/src/implementation/mcp.d.ts +35 -19
  47. package/types/apps/src/implementation/openapi-compile.d.ts +2 -1
  48. package/types/apps/src/implementation/openapi-source.d.ts +2 -6
  49. package/types/apps/src/implementation/operations.d.ts +26 -3
  50. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  51. package/types/apps/src/implementation/provider.d.ts +9 -4
  52. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  53. package/types/apps/src/implementation/router.d.ts +59 -0
  54. package/types/apps/src/implementation/schema.d.ts +5 -1
  55. package/types/apps/src/implementation/workflow-context.d.ts +1 -1
  56. package/types/apps/src/index.d.ts +5 -4
  57. package/types/apps/src/mcp-stdio.d.ts +2 -5
  58. package/types/apps/src/mcp.d.ts +5 -4
  59. package/types/apps/src/openapi.d.ts +6 -6
  60. package/js/chunk-3XKZDQLM.js +0 -93
  61. package/js/chunk-4M277YTM.js +0 -136
  62. package/js/chunk-SB3V4YVR.js +0 -18
  63. package/js/chunk-W4DMKWAB.js +0 -35
  64. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  65. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  66. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
package/js/index.js CHANGED
@@ -1,21 +1,27 @@
1
1
  import {
2
+ ResponseDecodeError,
3
+ ResponseStatusError,
2
4
  defineApp,
3
5
  defineDatabase,
4
6
  table,
5
7
  workflow
6
- } from "./chunk-C3VAOK5B.js";
8
+ } from "./chunk-YXQHV65J.js";
7
9
  import "./chunk-ZQINWV4W.js";
8
10
  import {
11
+ dynamicRouter,
9
12
  fromPromise,
10
13
  mutation,
11
14
  nativeOperation,
15
+ nativeRouter,
12
16
  operationDeclaration,
13
17
  query,
18
+ router,
19
+ routerDeclaration,
14
20
  withApproval
15
- } from "./chunk-3XKZDQLM.js";
21
+ } from "./chunk-Z5M2LQOZ.js";
16
22
  import {
17
23
  accountProviderError
18
- } from "./chunk-G7T27IWB.js";
24
+ } from "./chunk-MKWZPDR6.js";
19
25
  import {
20
26
  CalendarSchedule,
21
27
  ElicitationFailed,
@@ -30,16 +36,13 @@ import {
30
36
  ScheduleTiming,
31
37
  SecretsMethod,
32
38
  WorkflowFailure
33
- } from "./chunk-DQAZTA4I.js";
39
+ } from "./chunk-WLE7WX2U.js";
34
40
  import "./chunk-N7YDVXYJ.js";
35
41
  import {
36
- CacheError
37
- } from "./chunk-YEPYT6SD.js";
38
- import "./chunk-JU7VHODU.js";
39
- import "./chunk-W4DMKWAB.js";
40
- import {
42
+ CacheError,
41
43
  ProviderError
42
- } from "./chunk-SB3V4YVR.js";
44
+ } from "./chunk-R3EV5FTO.js";
45
+ import "./chunk-JU7VHODU.js";
43
46
  import {
44
47
  array,
45
48
  boolean,
@@ -59,7 +62,7 @@ import {
59
62
  userId,
60
63
  withLazyJsonSchemaDocument,
61
64
  wrap
62
- } from "./chunk-FWQC6I3C.js";
65
+ } from "./chunk-5T57N25Q.js";
63
66
  import "./chunk-PZB6T6KU.js";
64
67
  import {
65
68
  JsonObject,
@@ -72,24 +75,6 @@ import {
72
75
  } from "./chunk-CDL5PM2Q.js";
73
76
  import "./chunk-CZ7CSFO4.js";
74
77
 
75
- // src/contracts/http.ts
76
- var ResponseStatusError = class extends Schema_exports.TaggedError()(
77
- "ResponseStatusError",
78
- { status: Schema_exports.Number }
79
- ) {
80
- get message() {
81
- return `Request failed with status ${this.status}`;
82
- }
83
- };
84
- var ResponseDecodeError = class extends Schema_exports.TaggedError()(
85
- "ResponseDecodeError",
86
- {}
87
- ) {
88
- get message() {
89
- return "Response body did not match the expected schema";
90
- }
91
- };
92
-
93
78
  // src/implementation/http.ts
94
79
  var decodeJson = (response, schema) => Effect_exports.gen(function* () {
95
80
  if (response.status < 200 || response.status >= 300) {
@@ -102,9 +87,16 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
102
87
  // src/implementation/provider.ts
103
88
  var secrets = (options) => new SecretsMethod(options);
104
89
  var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(Effect_exports.map((config2) => new OAuth2Method({ config: config2, response })));
105
- var defineProvider = (options) => new Provider(options);
90
+ var defineProvider = ({
91
+ health,
92
+ ...options
93
+ }) => {
94
+ if (health === void 0) return new Provider(options);
95
+ const run = fromPromise(health);
96
+ return new Provider({ ...options, health: { run } });
97
+ };
106
98
 
107
- // src/implementation/account-operations.ts
99
+ // src/implementation/account-router.ts
108
100
  var inputDocument = (operation) => {
109
101
  const imported = importedJsonSchema(operation.input);
110
102
  if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
@@ -115,72 +107,70 @@ var declaresOutput = (operation) => {
115
107
  const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
116
108
  return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
117
109
  };
118
- var combine = (kind, groups) => Object.fromEntries(
119
- [...groups].map(([name, accounts]) => {
120
- const variants = [...accounts.values()];
121
- const first = variants[0];
122
- if (first === void 0)
123
- throw new Error("An account operation must have at least one account");
124
- const select = (input2) => {
125
- const operation = accounts.get(input2.accountId);
126
- if (operation === void 0)
127
- throw new Error("Account selection must be decoded before execution");
128
- return operation;
129
- };
130
- const input = Schema_exports.Union(
131
- [...accounts].map(
132
- ([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
133
- )
134
- );
135
- const inputSchema = () => ({
110
+ var combineOperation = (accounts) => {
111
+ const variants = [...accounts.values()];
112
+ const first = variants[0];
113
+ if (first === void 0) throw new Error("An account operation must have at least one account");
114
+ const kind = variants.every((operation) => operation.kind === "query") ? "query" : "mutation";
115
+ const select = (input2) => {
116
+ const operation = accounts.get(input2.accountId);
117
+ if (operation === void 0)
118
+ throw new Error("Account selection must be decoded before execution");
119
+ return operation;
120
+ };
121
+ const input = Schema_exports.Union(
122
+ [...accounts].map(
123
+ ([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
124
+ )
125
+ );
126
+ const inputSchema = () => ({
127
+ type: "object",
128
+ anyOf: [...accounts].map(([accountId, operation], index) => ({
136
129
  type: "object",
137
- anyOf: [...accounts].map(([accountId, operation], index) => ({
138
- type: "object",
139
- properties: {
140
- accountId: { type: "string", const: accountId },
141
- input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
142
- },
143
- required: ["accountId", "input"]
144
- }))
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 });
130
+ properties: {
131
+ accountId: { type: "string", const: accountId },
132
+ input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
160
133
  },
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 });
134
+ required: ["accountId", "input"]
135
+ }))
136
+ });
137
+ const declaration2 = operationDeclaration({
138
+ kind,
139
+ ...first.description === void 0 ? {} : { description: first.description },
140
+ ...first.title === void 0 ? {} : { title: first.title },
141
+ ...first.annotations === void 0 || !variants.every(
142
+ (operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
143
+ ) ? {} : { annotations: first.annotations },
144
+ ...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
145
+ input: withLazyJsonSchemaDocument(input, inputSchema),
146
+ approval: (context) => {
147
+ const operation = select(context.toolInput);
148
+ return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
149
+ },
150
+ run: (context, input2) => {
151
+ const operation = select(input2);
152
+ return operation.run(context, input2.input).pipe(
153
+ Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
154
+ Effect_exports.flatMap(
155
+ (output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
156
+ )
157
+ );
180
158
  }
181
- return [name, declaration2];
182
- })
183
- );
159
+ });
160
+ if (variants.every(declaresOutput)) {
161
+ const outputSchema = once(() => ({
162
+ anyOf: variants.flatMap(
163
+ (operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
164
+ ).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
165
+ }));
166
+ const native2 = nativeOperation(declaration2);
167
+ if (native2 !== void 0)
168
+ Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
169
+ }
170
+ const native = nativeOperation(declaration2);
171
+ if (native === void 0) throw new Error("Expected a combined operation");
172
+ return native;
173
+ };
184
174
  var sameAcross = (key, variants) => {
185
175
  const first = variants[0]?.[1][key];
186
176
  return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
@@ -192,7 +182,7 @@ var mergeSummary = (name, variants) => {
192
182
  name,
193
183
  description: first.description,
194
184
  ...first.title === void 0 ? {} : { title: first.title },
195
- readOnly: name.startsWith("queries."),
185
+ readOnly: variants.every(([, tool]) => tool.readOnly === true),
196
186
  ...sameAcross("annotations", variants)
197
187
  });
198
188
  };
@@ -218,112 +208,123 @@ var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
218
208
  } : {},
219
209
  ...sameAcross("_meta", variants)
220
210
  });
221
- var accountOperations = (accounts, discover, options) => Effect_exports.runPromise(
211
+ var combineDynamic = (sources) => {
212
+ const first = [...sources.values()][0];
213
+ const grouped = (read) => Effect_exports.gen(function* () {
214
+ const groups = /* @__PURE__ */ new Map();
215
+ for (const [accountId, source] of sources) {
216
+ const tools = yield* read(source).pipe(
217
+ Effect_exports.mapError((error) => accountProviderError(error, accountId))
218
+ );
219
+ for (const tool of tools) {
220
+ const variants = groups.get(tool.name) ?? [];
221
+ if (variants.some(([id2]) => id2 === accountId))
222
+ return yield* Effect_exports.die(new Error("Duplicate source operation"));
223
+ variants.push([accountId, tool]);
224
+ groups.set(tool.name, variants);
225
+ }
226
+ }
227
+ return groups;
228
+ });
229
+ return {
230
+ kind: "dynamic",
231
+ // Accounts share one source, so the first account describes the router.
232
+ ...first?.meta === void 0 ? {} : { meta: first.meta },
233
+ ...first?.overrides === void 0 ? {} : { overrides: first.overrides },
234
+ list: () => grouped((source) => source.list()).pipe(
235
+ Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
236
+ ),
237
+ summaries: () => grouped(
238
+ (source) => source.summaries === void 0 ? source.list() : source.summaries()
239
+ ).pipe(
240
+ Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
241
+ ),
242
+ describe: (name) => Effect_exports.gen(function* () {
243
+ const variants = [];
244
+ for (const [accountId, source] of sources) {
245
+ 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)));
246
+ if (tool !== void 0) variants.push([accountId, tool]);
247
+ }
248
+ return variants.length === 0 ? void 0 : merge(name, variants);
249
+ }),
250
+ resolve: (name) => Effect_exports.gen(function* () {
251
+ const operations = /* @__PURE__ */ new Map();
252
+ for (const [accountId, source] of sources) {
253
+ const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
254
+ if (operation !== void 0) operations.set(accountId, operation);
255
+ }
256
+ return operations.size === 0 ? void 0 : combineOperation(operations);
257
+ })
258
+ };
259
+ };
260
+ var combineNode = (variants) => {
261
+ const nodes = [...variants.values()];
262
+ const first = nodes[0];
263
+ if (first === void 0) throw new Error("An account operation must have at least one account");
264
+ switch (first.kind) {
265
+ case "query":
266
+ case "mutation":
267
+ return combineOperation(
268
+ narrow(
269
+ variants,
270
+ (node) => node.kind === "query" || node.kind === "mutation"
271
+ )
272
+ );
273
+ case "dynamic":
274
+ return combineDynamic(
275
+ narrow(variants, (node) => node.kind === "dynamic")
276
+ );
277
+ case "router": {
278
+ const routers = narrow(variants, (node) => node.kind === "router");
279
+ const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
280
+ return {
281
+ kind: "router",
282
+ ...first.meta === void 0 ? {} : { meta: first.meta },
283
+ children: Object.fromEntries(
284
+ [...keys].map((key) => {
285
+ const children = /* @__PURE__ */ new Map();
286
+ for (const [accountId, router2] of routers) {
287
+ const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
288
+ if (child !== void 0) children.set(accountId, child);
289
+ }
290
+ return [key, combineNode(children)];
291
+ })
292
+ )
293
+ };
294
+ }
295
+ }
296
+ };
297
+ var narrow = (variants, is) => {
298
+ const narrowed = /* @__PURE__ */ new Map();
299
+ for (const [accountId, node] of variants) {
300
+ if (!is(node)) throw new Error("Each account's router must have the same shape");
301
+ narrowed.set(accountId, node);
302
+ }
303
+ return narrowed;
304
+ };
305
+ var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
222
306
  Effect_exports.gen(function* () {
223
- const queries = /* @__PURE__ */ new Map();
224
- const mutations = /* @__PURE__ */ new Map();
225
- const sources = /* @__PURE__ */ new Map();
307
+ const routers = /* @__PURE__ */ new Map();
226
308
  for (const account of accounts) {
227
- const operations = yield* Effect_exports.tryPromise({
309
+ const declaration2 = yield* Effect_exports.tryPromise({
228
310
  try: () => discover(account),
229
311
  catch: (error) => accountProviderError(error, account.id)
230
312
  });
231
- if (sources.has(account.id))
313
+ if (routers.has(account.id))
232
314
  return yield* Effect_exports.die(new Error("Account selections must be unique"));
233
- if (operations.dynamicTools !== void 0) sources.set(account.id, operations.dynamicTools);
234
- for (const [source, target] of [
235
- [operations.queries, queries],
236
- [operations.mutations, mutations]
237
- ]) {
238
- for (const [name, declaration2] of Object.entries(source ?? {})) {
239
- const operation = nativeOperation(declaration2);
240
- if (operation === void 0)
241
- return yield* Effect_exports.die(new Error("Expected a protocol operation"));
242
- const group = target.get(name) ?? /* @__PURE__ */ new Map();
243
- if (group.has(account.id))
244
- return yield* Effect_exports.die(new Error("Account selections must be unique"));
245
- group.set(account.id, operation);
246
- target.set(name, group);
247
- }
248
- }
315
+ const router2 = nativeRouter(declaration2);
316
+ if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
317
+ routers.set(account.id, router2);
249
318
  }
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
- };
319
+ if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
320
+ const combined = combineNode(routers);
321
+ if (combined.kind !== "router" && combined.kind !== "dynamic")
322
+ return yield* Effect_exports.die(new Error("Expected a protocol router"));
323
+ return routerDeclaration(combined);
308
324
  }),
309
325
  options
310
326
  );
311
327
 
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
328
  // src/implementation/dynamic-skills.ts
328
329
  var dynamicSkills = (source) => ({
329
330
  list: fromPromise(async () => source.list())
@@ -396,7 +397,7 @@ export {
396
397
  ResponseStatusError,
397
398
  ValidationError,
398
399
  WorkflowFailure,
399
- accountOperations,
400
+ accountRouter,
400
401
  array,
401
402
  boolean,
402
403
  cron,
@@ -404,8 +405,8 @@ export {
404
405
  defineApp,
405
406
  defineDatabase,
406
407
  defineProvider,
408
+ dynamicRouter,
407
409
  dynamicSkills,
408
- dynamicTools,
409
410
  id,
410
411
  interval,
411
412
  json,
@@ -417,6 +418,7 @@ export {
417
418
  object,
418
419
  query,
419
420
  record,
421
+ router,
420
422
  secrets2 as secrets,
421
423
  string,
422
424
  table,
package/js/mcp/effect.js CHANGED
@@ -1,27 +1,25 @@
1
1
  import {
2
2
  mcpClientEffect,
3
3
  mcpToolsEffect
4
- } from "../chunk-67EVWIGJ.js";
5
- import "../chunk-UDDE5KOR.js";
4
+ } from "../chunk-OCYUEU47.js";
5
+ import "../chunk-CMYUWAX7.js";
6
6
  import "../chunk-BCSNKUAC.js";
7
- import "../chunk-LUVSFETN.js";
8
- import "../chunk-CYYBFC2K.js";
7
+ import "../chunk-UESPOTUI.js";
8
+ import "../chunk-NKLWZJLE.js";
9
+ import "../chunk-FL2QR3XW.js";
9
10
  import "../chunk-IPI4MFSN.js";
10
- import "../chunk-4M277YTM.js";
11
- import "../chunk-C3VAOK5B.js";
11
+ import "../chunk-YXQHV65J.js";
12
12
  import "../chunk-ZQINWV4W.js";
13
- import "../chunk-3XKZDQLM.js";
14
- import "../chunk-G7T27IWB.js";
15
- import "../chunk-DQAZTA4I.js";
13
+ import "../chunk-Z5M2LQOZ.js";
14
+ import "../chunk-MKWZPDR6.js";
15
+ import "../chunk-WLE7WX2U.js";
16
16
  import "../chunk-N7YDVXYJ.js";
17
- import "../chunk-YEPYT6SD.js";
17
+ import "../chunk-R3EV5FTO.js";
18
18
  import "../chunk-JU7VHODU.js";
19
- import "../chunk-W4DMKWAB.js";
20
- import "../chunk-SB3V4YVR.js";
21
19
  import "../chunk-RJDDBDSN.js";
22
20
  import "../chunk-57RKNWL2.js";
23
21
  import "../chunk-UK573G7W.js";
24
- import "../chunk-FWQC6I3C.js";
22
+ import "../chunk-5T57N25Q.js";
25
23
  import "../chunk-PZB6T6KU.js";
26
24
  import "../chunk-27F7W2LG.js";
27
25
  import "../chunk-CDL5PM2Q.js";
package/js/mcp/stdio.js CHANGED
@@ -2,32 +2,30 @@ import {
2
2
  adaptMcpTools,
3
3
  mcpClient,
4
4
  mcpJsonSchemaValidator
5
- } from "../chunk-UDDE5KOR.js";
5
+ } from "../chunk-CMYUWAX7.js";
6
6
  import {
7
- protocolOperations
8
- } from "../chunk-TDNYXSIX.js";
7
+ protocolRouter
8
+ } from "../chunk-72JNVHPK.js";
9
9
  import "../chunk-BCSNKUAC.js";
10
- import "../chunk-LUVSFETN.js";
11
- import "../chunk-CYYBFC2K.js";
10
+ import "../chunk-UESPOTUI.js";
11
+ import "../chunk-NKLWZJLE.js";
12
+ import "../chunk-FL2QR3XW.js";
12
13
  import "../chunk-IPI4MFSN.js";
13
- import "../chunk-4M277YTM.js";
14
- import "../chunk-C3VAOK5B.js";
14
+ import "../chunk-YXQHV65J.js";
15
15
  import "../chunk-ZQINWV4W.js";
16
- import "../chunk-3XKZDQLM.js";
17
- import "../chunk-G7T27IWB.js";
16
+ import "../chunk-Z5M2LQOZ.js";
17
+ import "../chunk-MKWZPDR6.js";
18
18
  import {
19
19
  McpError,
20
20
  ProcessConfig
21
- } from "../chunk-DQAZTA4I.js";
21
+ } from "../chunk-WLE7WX2U.js";
22
22
  import "../chunk-N7YDVXYJ.js";
23
- import "../chunk-YEPYT6SD.js";
23
+ import "../chunk-R3EV5FTO.js";
24
24
  import "../chunk-JU7VHODU.js";
25
- import "../chunk-W4DMKWAB.js";
26
- import "../chunk-SB3V4YVR.js";
27
25
  import "../chunk-RJDDBDSN.js";
28
26
  import "../chunk-57RKNWL2.js";
29
27
  import "../chunk-UK573G7W.js";
30
- import "../chunk-FWQC6I3C.js";
28
+ import "../chunk-5T57N25Q.js";
31
29
  import "../chunk-PZB6T6KU.js";
32
30
  import "../chunk-27F7W2LG.js";
33
31
  import {
@@ -120,11 +118,11 @@ var stdioToolsEffect = (input) => Effect_exports.gen(function* () {
120
118
  });
121
119
 
122
120
  // src/mcp-stdio.ts
123
- var stdioOperations = (config, signal, kinds = {}) => Effect_exports.runPromise(
124
- stdioToolsEffect(config).pipe(Effect_exports.map((tools) => protocolOperations(tools, kinds))),
121
+ var stdioRouter = (config, signal, kinds = {}) => Effect_exports.runPromise(
122
+ stdioToolsEffect(config).pipe(Effect_exports.map((tools) => protocolRouter(tools, kinds))),
125
123
  signal === void 0 ? {} : { signal }
126
124
  );
127
125
  export {
128
126
  McpError,
129
- stdioOperations
127
+ stdioRouter
130
128
  };