apps 0.0.1-beta.115 → 0.0.1-beta.116

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.
@@ -12,7 +12,7 @@ import {
12
12
  parseSkillLoadFailed,
13
13
  readCatalog,
14
14
  routerSkills
15
- } from "./chunk-7XZKCNGB.js";
15
+ } from "./chunk-6A6P5TYV.js";
16
16
  import {
17
17
  appInvocationFetch
18
18
  } from "./chunk-HLMJBE4T.js";
@@ -26,12 +26,12 @@ import {
26
26
  makeEmitter,
27
27
  toEffectApp,
28
28
  withPlacements
29
- } from "./chunk-3BI34I5S.js";
29
+ } from "./chunk-ES6QUAAC.js";
30
30
  import {
31
31
  declaredOperations,
32
32
  locate,
33
33
  nativeOperation
34
- } from "./chunk-ZXG7RMCB.js";
34
+ } from "./chunk-OIMMQRYE.js";
35
35
  import {
36
36
  accountProviderError,
37
37
  appCode,
package/js/effect.js CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  ApprovalDecision,
4
4
  createAppHandler,
5
5
  prepareElicitation
6
- } from "./chunk-27DVBAB5.js";
6
+ } from "./chunk-OSVCX4MV.js";
7
7
  import "./chunk-UPTAFF6L.js";
8
- import "./chunk-7XZKCNGB.js";
8
+ import "./chunk-6A6P5TYV.js";
9
9
  import "./chunk-HLMJBE4T.js";
10
10
  import "./chunk-PBGPES67.js";
11
- import "./chunk-3BI34I5S.js";
12
- import "./chunk-ZXG7RMCB.js";
11
+ import "./chunk-ES6QUAAC.js";
12
+ import "./chunk-OIMMQRYE.js";
13
13
  import "./chunk-OIH73VFM.js";
14
14
  import {
15
15
  ToolAnnotations
package/js/graphql.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  } from "./chunk-SXQVVXJE.js";
5
5
  import {
6
6
  protocolOperations
7
- } from "./chunk-FDZGNN3U.js";
7
+ } from "./chunk-GFRK2I3S.js";
8
8
  import "./chunk-BCSNKUAC.js";
9
- import "./chunk-27DVBAB5.js";
9
+ import "./chunk-OSVCX4MV.js";
10
10
  import {
11
11
  cacheKey
12
12
  } from "./chunk-UPTAFF6L.js";
@@ -20,16 +20,16 @@ import {
20
20
  maxGraphqlStatedErrors,
21
21
  maxGraphqlStatedExtensions,
22
22
  maxGraphqlStatedFieldLength
23
- } from "./chunk-7XZKCNGB.js";
23
+ } from "./chunk-6A6P5TYV.js";
24
24
  import {
25
25
  failOnNetworkRefusal
26
26
  } from "./chunk-HLMJBE4T.js";
27
27
  import "./chunk-PBGPES67.js";
28
- import "./chunk-3BI34I5S.js";
28
+ import "./chunk-ES6QUAAC.js";
29
29
  import {
30
30
  nativeOperation,
31
31
  routerDeclaration
32
- } from "./chunk-ZXG7RMCB.js";
32
+ } from "./chunk-OIMMQRYE.js";
33
33
  import {
34
34
  accountProviderError,
35
35
  boundStated,
package/js/host.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  createAppHandler
3
- } from "./chunk-27DVBAB5.js";
3
+ } from "./chunk-OSVCX4MV.js";
4
4
  import "./chunk-UPTAFF6L.js";
5
- import "./chunk-7XZKCNGB.js";
5
+ import "./chunk-6A6P5TYV.js";
6
6
  import "./chunk-HLMJBE4T.js";
7
7
  import "./chunk-PBGPES67.js";
8
- import "./chunk-3BI34I5S.js";
9
- import "./chunk-ZXG7RMCB.js";
8
+ import "./chunk-ES6QUAAC.js";
9
+ import "./chunk-OIMMQRYE.js";
10
10
  import "./chunk-OIH73VFM.js";
11
11
  import {
12
12
  CacheCommand,
package/js/index.js CHANGED
@@ -11,23 +11,20 @@ import {
11
11
  query,
12
12
  t,
13
13
  workflow
14
- } from "./chunk-3BI34I5S.js";
14
+ } from "./chunk-ES6QUAAC.js";
15
15
  import {
16
+ accountRouter,
16
17
  dynamicRouter,
17
18
  mutation,
18
19
  nativeOperation,
19
- nativeRouter,
20
- operationDeclaration,
21
20
  query as query2,
22
21
  renameTools,
23
22
  router,
24
- routerDeclaration,
25
23
  toolAnnotations,
26
24
  withApproval,
27
25
  withApprovals
28
- } from "./chunk-ZXG7RMCB.js";
26
+ } from "./chunk-OIMMQRYE.js";
29
27
  import {
30
- accountProviderError,
31
28
  fromPromise
32
29
  } from "./chunk-OIH73VFM.js";
33
30
  import {
@@ -35,8 +32,6 @@ import {
35
32
  CalendarSchedule,
36
33
  ElicitationFailed,
37
34
  FetchOptionUnsupported,
38
- HostedTool,
39
- HostedToolSummary,
40
35
  Interval,
41
36
  NetworkRefused,
42
37
  NonRetryableError,
@@ -53,24 +48,20 @@ import "./chunk-4PIQKACY.js";
53
48
  import {
54
49
  array,
55
50
  boolean,
56
- combineJsonSchemas,
57
51
  decoderOf,
58
52
  fieldExposure,
59
- importedJsonSchema,
60
53
  isSchema,
61
54
  json,
62
55
  jsonSchema,
63
56
  literal,
64
57
  number,
65
58
  object,
66
- once,
67
59
  parse,
68
60
  parseDeclaration,
69
61
  plain,
70
62
  raw,
71
63
  record,
72
64
  string,
73
- withLazyJsonSchemaDocument,
74
65
  wrap
75
66
  } from "./chunk-VAI3EVCS.js";
76
67
  import "./chunk-URKOTNDA.js";
@@ -78,7 +69,6 @@ import "./chunk-YDW7DX3A.js";
78
69
  import "./chunk-OWN3DP2W.js";
79
70
  import {
80
71
  DeclarationInvalid,
81
- JsonObject,
82
72
  JsonValue,
83
73
  ValidationError
84
74
  } from "./chunk-7HG422GB.js";
@@ -132,261 +122,6 @@ var defineProvider = ({
132
122
  return new Provider({ ...options, health: { run } });
133
123
  };
134
124
 
135
- // src/implementation/account-router.ts
136
- var decoderDocument = (decoder) => {
137
- const imported = importedJsonSchema(decoder);
138
- if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
139
- const document = Schema_exports.toJsonSchemaDocument(decoder);
140
- return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
141
- };
142
- var accountBranches = (variants) => {
143
- const groups = /* @__PURE__ */ new Map();
144
- for (const [accountId, schema] of variants) {
145
- const key = JSON.stringify(schema);
146
- const group = groups.get(key);
147
- if (group === void 0) groups.set(key, { schema, first: accountId, rest: [] });
148
- else group.rest.push(accountId);
149
- }
150
- const branches = [...groups.values()];
151
- const { $defs, schemas } = combineJsonSchemas(
152
- branches.map(({ schema }) => schema),
153
- (index) => `#/anyOf/${index}/properties/input`
154
- );
155
- return {
156
- type: "object",
157
- ...$defs === void 0 ? {} : { $defs },
158
- anyOf: schemas.map((input, index) => {
159
- const { first, rest } = branches[index];
160
- return {
161
- type: "object",
162
- properties: {
163
- accountId: rest.length === 0 ? { type: "string", const: first } : { type: "string", enum: [first, ...rest] },
164
- input
165
- },
166
- required: ["accountId", "input"]
167
- };
168
- })
169
- };
170
- };
171
- var outputBranches = (outputs) => {
172
- const { $defs, schemas } = combineJsonSchemas(
173
- [...new Map(outputs.map((output) => [JSON.stringify(output), output])).values()],
174
- (index) => `#/anyOf/${index}`
175
- );
176
- return { ...$defs === void 0 ? {} : { $defs }, anyOf: schemas };
177
- };
178
- var declaresOutput = (operation) => {
179
- if (operation.output !== void 0) return true;
180
- const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
181
- return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
182
- };
183
- var outputDocument = (operation) => operation.output === void 0 ? operation.outputSchema : decoderDocument(operation.output);
184
- var combineOperation = (accounts) => {
185
- const variants = [...accounts.values()];
186
- const first = variants[0];
187
- if (first === void 0) throw new Error("An account operation must have at least one account");
188
- const kind = variants.every((operation) => operation.kind === "query") ? "query" : "mutation";
189
- const select = (input2) => {
190
- const operation = accounts.get(input2.accountId);
191
- if (operation === void 0)
192
- throw new Error("Account selection must be decoded before execution");
193
- return operation;
194
- };
195
- const input = Schema_exports.Union(
196
- [...accounts].map(
197
- ([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
198
- )
199
- );
200
- const inputSchema = () => accountBranches(
201
- [...accounts].map(([accountId, operation]) => [accountId, decoderDocument(operation.input)])
202
- );
203
- const declaration2 = operationDeclaration({
204
- kind,
205
- ...first.description === void 0 ? {} : { description: first.description },
206
- ...first.title === void 0 ? {} : { title: first.title },
207
- ...first.annotations === void 0 || !variants.every(
208
- (operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
209
- ) ? {} : { annotations: first.annotations },
210
- ...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
211
- input: withLazyJsonSchemaDocument(input, inputSchema),
212
- approval: (context) => {
213
- const operation = select(context.toolInput);
214
- return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
215
- },
216
- run: (context, input2) => {
217
- const operation = select(input2);
218
- return operation.run(context, input2.input).pipe(
219
- Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
220
- Effect_exports.flatMap(
221
- (output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
222
- )
223
- );
224
- }
225
- });
226
- if (variants.every(declaresOutput)) {
227
- const outputSchema = once(
228
- () => outputBranches(
229
- variants.flatMap((operation) => {
230
- const output = outputDocument(operation);
231
- return output === void 0 ? [] : [output];
232
- })
233
- )
234
- );
235
- const native2 = nativeOperation(declaration2);
236
- if (native2 !== void 0)
237
- Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
238
- }
239
- const native = nativeOperation(declaration2);
240
- if (native === void 0) throw new Error("Expected a combined operation");
241
- return native;
242
- };
243
- var sameAcross = (key, variants) => {
244
- const first = variants[0]?.[1][key];
245
- return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
246
- };
247
- var mergeSummary = (name, variants) => {
248
- const first = variants[0]?.[1];
249
- if (first === void 0) throw new Error("Expected a source operation");
250
- return Schema_exports.decodeUnknownSync(HostedToolSummary)({
251
- name,
252
- description: first.description,
253
- ...first.title === void 0 ? {} : { title: first.title },
254
- readOnly: variants.every(([, tool]) => tool.readOnly === true),
255
- ...variants.every(([, tool]) => tool.kindConfirmed === true) ? { kindConfirmed: true } : {},
256
- ...sameAcross("annotations", variants)
257
- });
258
- };
259
- var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
260
- ...mergeSummary(name, variants),
261
- inputSchema: accountBranches(
262
- variants.map(([accountId, tool]) => [accountId, tool.inputSchema])
263
- ),
264
- ...variants.every(([, tool]) => tool.outputSchema !== void 0) ? {
265
- outputSchema: outputBranches(
266
- variants.flatMap(
267
- ([, tool]) => tool.outputSchema === void 0 ? [] : [tool.outputSchema]
268
- )
269
- )
270
- } : {},
271
- ...sameAcross("_meta", variants)
272
- });
273
- var combineDynamic = (sources) => {
274
- const first = [...sources.values()][0];
275
- const grouped = (read) => Effect_exports.gen(function* () {
276
- const groups = /* @__PURE__ */ new Map();
277
- for (const [accountId, source] of sources) {
278
- const tools = yield* read(source).pipe(
279
- Effect_exports.mapError((error) => accountProviderError(error, accountId))
280
- );
281
- for (const tool of tools) {
282
- const variants = groups.get(tool.name) ?? [];
283
- if (variants.some(([id]) => id === accountId))
284
- return yield* Effect_exports.die(new Error("Duplicate source operation"));
285
- variants.push([accountId, tool]);
286
- groups.set(tool.name, variants);
287
- }
288
- }
289
- return groups;
290
- });
291
- return {
292
- kind: "dynamic",
293
- // Accounts share one source, so the first account describes the router.
294
- ...first?.meta === void 0 ? {} : { meta: first.meta },
295
- ...first?.overrides === void 0 ? {} : { overrides: first.overrides },
296
- list: () => grouped((source) => source.list()).pipe(
297
- Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
298
- ),
299
- summaries: () => grouped(
300
- (source) => source.summaries === void 0 ? source.list() : source.summaries()
301
- ).pipe(
302
- Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
303
- ),
304
- describe: (name) => Effect_exports.gen(function* () {
305
- const variants = [];
306
- for (const [accountId, source] of sources) {
307
- 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)));
308
- if (tool !== void 0) variants.push([accountId, tool]);
309
- }
310
- return variants.length === 0 ? void 0 : merge(name, variants);
311
- }),
312
- resolve: (name) => Effect_exports.gen(function* () {
313
- const operations = /* @__PURE__ */ new Map();
314
- for (const [accountId, source] of sources) {
315
- const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
316
- if (operation !== void 0) operations.set(accountId, operation);
317
- }
318
- return operations.size === 0 ? void 0 : combineOperation(operations);
319
- })
320
- };
321
- };
322
- var combineNode = (variants) => {
323
- const nodes = [...variants.values()];
324
- const first = nodes[0];
325
- if (first === void 0) throw new Error("An account operation must have at least one account");
326
- switch (first.kind) {
327
- case "query":
328
- case "mutation":
329
- return combineOperation(
330
- narrow(
331
- variants,
332
- (node) => node.kind === "query" || node.kind === "mutation"
333
- )
334
- );
335
- case "dynamic":
336
- return combineDynamic(
337
- narrow(variants, (node) => node.kind === "dynamic")
338
- );
339
- case "router": {
340
- const routers = narrow(variants, (node) => node.kind === "router");
341
- const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
342
- return {
343
- kind: "router",
344
- ...first.meta === void 0 ? {} : { meta: first.meta },
345
- children: Object.fromEntries(
346
- [...keys].map((key) => {
347
- const children = /* @__PURE__ */ new Map();
348
- for (const [accountId, router2] of routers) {
349
- const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
350
- if (child !== void 0) children.set(accountId, child);
351
- }
352
- return [key, combineNode(children)];
353
- })
354
- )
355
- };
356
- }
357
- }
358
- };
359
- var narrow = (variants, is) => {
360
- const narrowed = /* @__PURE__ */ new Map();
361
- for (const [accountId, node] of variants) {
362
- if (!is(node)) throw new Error("Each account's router must have the same shape");
363
- narrowed.set(accountId, node);
364
- }
365
- return narrowed;
366
- };
367
- var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
368
- Effect_exports.gen(function* () {
369
- const routers = /* @__PURE__ */ new Map();
370
- for (const account of accounts) {
371
- const declaration2 = yield* Effect_exports.tryPromise({
372
- try: async () => discover(account),
373
- catch: (error) => accountProviderError(error, account.id)
374
- });
375
- if (routers.has(account.id))
376
- return yield* Effect_exports.die(new Error("Account selections must be unique"));
377
- const router2 = nativeRouter(declaration2);
378
- if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
379
- routers.set(account.id, router2);
380
- }
381
- if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
382
- const combined = combineNode(routers);
383
- if (combined.kind !== "router" && combined.kind !== "dynamic")
384
- return yield* Effect_exports.die(new Error("Expected a protocol router"));
385
- return routerDeclaration(combined);
386
- }),
387
- options
388
- );
389
-
390
125
  // src/implementation/dynamic-skills.ts
391
126
  var dynamicSkills = (source) => ({
392
127
  list: fromPromise(async () => source.list(), "skills")
package/js/mcp/effect.js CHANGED
@@ -2,15 +2,15 @@ import {
2
2
  mcpClientEffect,
3
3
  mcpHealthEffect,
4
4
  mcpToolsEffect
5
- } from "../chunk-FCVF3PEM.js";
5
+ } from "../chunk-4EOLLVQ6.js";
6
6
  import "../chunk-BCSNKUAC.js";
7
- import "../chunk-27DVBAB5.js";
7
+ import "../chunk-OSVCX4MV.js";
8
8
  import "../chunk-UPTAFF6L.js";
9
- import "../chunk-7XZKCNGB.js";
9
+ import "../chunk-6A6P5TYV.js";
10
10
  import "../chunk-HLMJBE4T.js";
11
11
  import "../chunk-PBGPES67.js";
12
- import "../chunk-3BI34I5S.js";
13
- import "../chunk-ZXG7RMCB.js";
12
+ import "../chunk-ES6QUAAC.js";
13
+ import "../chunk-OIMMQRYE.js";
14
14
  import "../chunk-OIH73VFM.js";
15
15
  import "../chunk-2RGJMA7N.js";
16
16
  import "../chunk-4PIQKACY.js";
package/js/mcp.js CHANGED
@@ -4,27 +4,27 @@ import {
4
4
  } from "./chunk-SXQVVXJE.js";
5
5
  import {
6
6
  protocolOperations
7
- } from "./chunk-FDZGNN3U.js";
7
+ } from "./chunk-GFRK2I3S.js";
8
8
  import {
9
9
  adaptMcpTool,
10
10
  mcpClientEffect,
11
11
  mcpHealthEffect
12
- } from "./chunk-FCVF3PEM.js";
12
+ } from "./chunk-4EOLLVQ6.js";
13
13
  import "./chunk-BCSNKUAC.js";
14
- import "./chunk-27DVBAB5.js";
14
+ import "./chunk-OSVCX4MV.js";
15
15
  import {
16
16
  cacheKey
17
17
  } from "./chunk-UPTAFF6L.js";
18
18
  import {
19
19
  operationDescription
20
- } from "./chunk-7XZKCNGB.js";
20
+ } from "./chunk-6A6P5TYV.js";
21
21
  import "./chunk-HLMJBE4T.js";
22
22
  import "./chunk-PBGPES67.js";
23
- import "./chunk-3BI34I5S.js";
23
+ import "./chunk-ES6QUAAC.js";
24
24
  import {
25
25
  nativeOperation,
26
26
  routerDeclaration
27
- } from "./chunk-ZXG7RMCB.js";
27
+ } from "./chunk-OIMMQRYE.js";
28
28
  import {
29
29
  fromPromise,
30
30
  method
package/js/openapi.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  protocolOperations,
10
10
  protocolRouter
11
- } from "./chunk-FDZGNN3U.js";
11
+ } from "./chunk-GFRK2I3S.js";
12
12
  import {
13
13
  OpenapiCompileError,
14
14
  OpenapiCompileErrorCode,
@@ -29,7 +29,7 @@ import {
29
29
  isOpenapiTextMedia,
30
30
  openapiBinaryResultSchema,
31
31
  openapiMediaKind
32
- } from "./chunk-7XZKCNGB.js";
32
+ } from "./chunk-6A6P5TYV.js";
33
33
  import {
34
34
  failOnNetworkRefusal
35
35
  } from "./chunk-HLMJBE4T.js";
@@ -37,7 +37,7 @@ import "./chunk-PBGPES67.js";
37
37
  import {
38
38
  nativeOperation,
39
39
  routerDeclaration
40
- } from "./chunk-ZXG7RMCB.js";
40
+ } from "./chunk-OIMMQRYE.js";
41
41
  import {
42
42
  accountProviderError,
43
43
  bodyUpstreamError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps",
3
- "version": "0.0.1-beta.115",
3
+ "version": "0.0.1-beta.116",
4
4
  "description": "TypeScript apps with typed tools, accounts, storage, and UI.",
5
5
  "type": "module",
6
6
  "sideEffects": false,