apps 0.0.1-beta.105 → 0.0.1-beta.108

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.
@@ -68,8 +68,9 @@ var OAuthError = Schema_exports.Struct({
68
68
  error: ErrorToken,
69
69
  error_description: Schema_exports.optional(Schema_exports.String)
70
70
  });
71
- var bounded = (message) => message.length <= maxUpstreamMessageLength ? message : `${message.slice(0, maxUpstreamMessageLength - 1)}\u2026`;
72
- var isShortenedUpstream = (message) => message.length === maxUpstreamMessageLength && message.endsWith("\u2026");
71
+ var boundStated = (text, maximum) => text.length <= maximum ? text : `${text.slice(0, maximum - 1)}\u2026`;
72
+ var isShortenedStated = (text, maximum) => text.length === maximum && text.endsWith("\u2026");
73
+ var bounded = (message) => boundStated(message, maxUpstreamMessageLength);
73
74
  var stated = (code, message) => ({
74
75
  code,
75
76
  ...message === void 0 || message === "" ? {} : { message: bounded(message) }
@@ -160,7 +161,8 @@ export {
160
161
  fromPromise,
161
162
  method,
162
163
  toPromise,
163
- isShortenedUpstream,
164
+ boundStated,
165
+ isShortenedStated,
164
166
  bodyUpstreamError,
165
167
  providerError,
166
168
  parseProviderError,
@@ -2,11 +2,11 @@ import {
2
2
  declaredOperations,
3
3
  nativeOperation,
4
4
  nativeRouter
5
- } from "./chunk-PILIRGJA.js";
5
+ } from "./chunk-QXJPA2YB.js";
6
6
  import {
7
7
  fromPromise,
8
8
  method
9
- } from "./chunk-R3O32PQV.js";
9
+ } from "./chunk-AVDSIC3N.js";
10
10
  import {
11
11
  EmittedEvent,
12
12
  EventName,
@@ -4,12 +4,12 @@ import {
4
4
  import {
5
5
  joinPath,
6
6
  mergeMeta
7
- } from "./chunk-PILIRGJA.js";
7
+ } from "./chunk-QXJPA2YB.js";
8
8
  import {
9
- isShortenedUpstream,
9
+ isShortenedStated,
10
10
  parseProviderError,
11
11
  providerError
12
- } from "./chunk-R3O32PQV.js";
12
+ } from "./chunk-AVDSIC3N.js";
13
13
  import {
14
14
  ApiErrorResponse,
15
15
  CacheError,
@@ -27,6 +27,7 @@ import {
27
27
  NetworkRefused,
28
28
  SkillLoadFailed as SkillLoadFailed2,
29
29
  cacheLimits,
30
+ defaultOpenapiErrorLimits,
30
31
  maxFailureFieldLength,
31
32
  maxFailureFields,
32
33
  maxFailureMessageLength,
@@ -291,6 +292,133 @@ var OpenapiToolNames = Schema_exports.Struct({
291
292
  skipped: Schema_exports.Array(OpenapiSkippedOperation)
292
293
  });
293
294
 
295
+ // src/contracts/graphql.ts
296
+ var GraphqlClientLimits = Schema_exports.Struct({
297
+ timeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
298
+ maxTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
299
+ });
300
+ var defaultGraphqlClientLimits = GraphqlClientLimits.make({
301
+ timeoutMs: 3e4,
302
+ maxTimeoutMs: 3e5
303
+ });
304
+ var GraphqlToolsOptions = Schema_exports.Struct({
305
+ url: HttpUrl,
306
+ accountId: Schema_exports.optional(AccountId),
307
+ headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
308
+ signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
309
+ timeoutMs: Schema_exports.optional(
310
+ Schema_exports.Int.check(
311
+ Schema_exports.isBetween({ minimum: 1, maximum: defaultGraphqlClientLimits.maxTimeoutMs })
312
+ )
313
+ )
314
+ });
315
+ var maxGraphqlStatedErrors = 5;
316
+ var maxGraphqlStatedExtensions = 4;
317
+ var maxGraphqlStatedFieldLength = 256;
318
+ var GraphqlStatedError = Schema_exports.Struct({
319
+ message: Schema_exports.String.check(Schema_exports.isMaxLength(maxUpstreamMessageLength)),
320
+ /** The first segments of the path, as many as a path of the longest carried length shows. */
321
+ path: Schema_exports.optional(
322
+ Schema_exports.Array(
323
+ Schema_exports.Union([
324
+ Schema_exports.String.check(Schema_exports.isMaxLength(maxGraphqlStatedFieldLength)),
325
+ Schema_exports.Int
326
+ ])
327
+ ).check(Schema_exports.isMaxLength(maxGraphqlStatedFieldLength + 1))
328
+ ),
329
+ extensions: Schema_exports.optional(
330
+ Schema_exports.Record(
331
+ FailureFieldName,
332
+ Schema_exports.Union([
333
+ Schema_exports.String.check(Schema_exports.isMaxLength(maxGraphqlStatedFieldLength)),
334
+ Schema_exports.Finite,
335
+ Schema_exports.Boolean
336
+ ])
337
+ ).check(Schema_exports.isMaxProperties(maxGraphqlStatedExtensions))
338
+ )
339
+ });
340
+ var GraphqlError = class extends Schema_exports.TaggedError()("GraphqlError", {
341
+ phase: Schema_exports.Literals(["discover", "call"]),
342
+ reason: Schema_exports.Literals([
343
+ "request",
344
+ "unauthorized",
345
+ "invalid_response",
346
+ "invalid_input",
347
+ "timeout",
348
+ "execution"
349
+ ]),
350
+ status: Schema_exports.optional(Schema_exports.Number),
351
+ /** The first errors the server stated, in its order. */
352
+ errors: Schema_exports.optional(
353
+ Schema_exports.Array(GraphqlStatedError).check(Schema_exports.isMaxLength(maxGraphqlStatedErrors))
354
+ ),
355
+ /** How many errors the server stated in all, when it stated more than `errors` carries. */
356
+ stated: Schema_exports.optional(Schema_exports.Int),
357
+ /**
358
+ * Why Executor did not read the JSON body of a refused request: it was larger than error bodies
359
+ * may be, or it did not arrive in time. The status is still the server's answer.
360
+ */
361
+ unreadBody: Schema_exports.optional(Schema_exports.Literals(["too_large", "incomplete"]))
362
+ }) {
363
+ };
364
+ var Name = Schema_exports.String.check(Schema_exports.isPattern(/^[_A-Za-z][_0-9A-Za-z]*$/u));
365
+ var Kind = Schema_exports.Literals([
366
+ "SCALAR",
367
+ "OBJECT",
368
+ "INTERFACE",
369
+ "UNION",
370
+ "ENUM",
371
+ "INPUT_OBJECT",
372
+ "LIST",
373
+ "NON_NULL"
374
+ ]);
375
+ var GraphqlTypeRef = Schema_exports.Struct({
376
+ kind: Kind,
377
+ name: Schema_exports.NullOr(Name),
378
+ ofType: Schema_exports.optional(Schema_exports.NullOr(Schema_exports.suspend(() => GraphqlTypeRef)))
379
+ });
380
+ var Argument = Schema_exports.Struct({
381
+ name: Name,
382
+ description: Schema_exports.NullOr(Schema_exports.String),
383
+ type: GraphqlTypeRef,
384
+ defaultValue: Schema_exports.NullOr(Schema_exports.String)
385
+ });
386
+ var GraphqlField = Schema_exports.Struct({
387
+ name: Name,
388
+ description: Schema_exports.NullOr(Schema_exports.String),
389
+ args: Schema_exports.Array(Argument),
390
+ type: GraphqlTypeRef
391
+ });
392
+ var GraphqlIntrospection = Schema_exports.Struct({
393
+ __schema: Schema_exports.Struct({
394
+ queryType: Schema_exports.NullOr(Schema_exports.Struct({ name: Name })),
395
+ mutationType: Schema_exports.NullOr(Schema_exports.Struct({ name: Name })),
396
+ types: Schema_exports.Array(
397
+ Schema_exports.Struct({
398
+ kind: Kind,
399
+ name: Name,
400
+ fields: Schema_exports.NullOr(Schema_exports.Array(GraphqlField)),
401
+ inputFields: Schema_exports.NullOr(Schema_exports.Array(Argument)),
402
+ enumValues: Schema_exports.NullOr(Schema_exports.Array(Schema_exports.Struct({ name: Name })))
403
+ })
404
+ )
405
+ })
406
+ });
407
+ var GraphqlResponse = Schema_exports.Struct({
408
+ data: Schema_exports.optional(Schema_exports.NullOr(JsonObject)),
409
+ errors: Schema_exports.optional(Schema_exports.Array(JsonObject))
410
+ });
411
+ var GraphqlToolDefinition = Schema_exports.Struct({
412
+ name: Name,
413
+ kind: Schema_exports.Literals(["query", "mutation"]),
414
+ field: Name,
415
+ description: Schema_exports.String,
416
+ arguments: Schema_exports.Array(Schema_exports.Struct({ name: Name, type: Schema_exports.String })),
417
+ inputSchema: JsonObject,
418
+ composite: Schema_exports.Boolean,
419
+ selection: Schema_exports.String
420
+ });
421
+
294
422
  // src/implementation/failure-detail.ts
295
423
  var cacheMessages = {
296
424
  capacity: "A cache key, value or batch exceeded the app cache's size limits.",
@@ -356,9 +484,19 @@ var accountFieldSecrets = (accounts) => {
356
484
  return [...found].sort((a, b) => b.length - a.length);
357
485
  };
358
486
  var accountSecrets = (accounts) => accountFieldSecrets(Redacted_exports.value(accounts));
487
+ var secretSpellings = (secrets) => [
488
+ ...new Set(
489
+ secrets.flatMap((secret) => [
490
+ secret,
491
+ JSON.stringify(secret).slice(1, -1),
492
+ .../\p{Cs}/u.test(secret) ? [] : [encodeURIComponent(secret)]
493
+ ])
494
+ )
495
+ ].sort((a, b) => b.length - a.length);
359
496
  var replaceSecrets = (text, secrets) => {
360
497
  let redacted = text;
361
- for (const secret of secrets) redacted = redacted.split(secret).join("[redacted]");
498
+ for (const secret of secretSpellings(secrets))
499
+ redacted = redacted.split(secret).join("[redacted]");
362
500
  return redacted;
363
501
  };
364
502
  var bound = (text, maximum) => text.length <= maximum ? text : `${text.slice(0, maximum - 1)}\u2026`;
@@ -376,9 +514,10 @@ var replaceSecretStart = (text, secrets) => {
376
514
  var boundFailureMessage = (message, secrets) => boundText(message, secrets, maxFailureMessageLength);
377
515
  var redactUpstream = (upstream, secrets) => {
378
516
  if (upstream?.message === void 0) return upstream;
379
- const message = isShortenedUpstream(upstream.message) ? `${replaceSecretStart(replaceSecrets(upstream.message.slice(0, -1), secrets), secrets)}\u2026` : replaceSecrets(upstream.message, secrets);
517
+ const message = redactStated(upstream.message, secrets, maxUpstreamMessageLength);
380
518
  return { code: upstream.code, message: bound(message, maxUpstreamMessageLength) };
381
519
  };
520
+ var redactStated = (text, secrets, maximum) => isShortenedStated(text, maximum) ? `${replaceSecretStart(replaceSecrets(text.slice(0, -1), secrets), secrets)}\u2026` : replaceSecrets(text, secrets);
382
521
  var leavingProviderError = (error, secrets, phase) => providerError({
383
522
  ...error,
384
523
  phase: error.phase ?? phase,
@@ -441,6 +580,57 @@ var openapiFailureMessage = (error) => {
441
580
  const response = `${operation} responded with HTTP ${error.status}${shape === "" ? "" : ` (${shape})`}`;
442
581
  return error.status >= 200 && error.status < 300 ? `${response}, but its body could not be read within the response limits.` : `${response}, which matches no error with a message in the API's OpenAPI document.`;
443
582
  };
583
+ var graphqlStages = {
584
+ discover: "while Executor read its schema",
585
+ call: "to this tool call"
586
+ };
587
+ var graphqlPathText = (path, secrets) => bound(
588
+ path.map((segment, index) => {
589
+ if (typeof segment === "number") return `[${segment}]`;
590
+ const name = redactStated(segment, secrets, maxGraphqlStatedFieldLength);
591
+ return /^[_A-Za-z][_0-9A-Za-z]*$/u.test(name) ? index === 0 ? name : `.${name}` : `[${JSON.stringify(name)}]`;
592
+ }).join(""),
593
+ maxGraphqlStatedFieldLength
594
+ );
595
+ var graphqlStatedText = ({ message, path, extensions }, secrets) => {
596
+ const field = (text) => redactStated(text, secrets, maxGraphqlStatedFieldLength);
597
+ const entries = Object.entries(extensions ?? {}).map(
598
+ ([name, value]) => `${name}: ${JSON.stringify(typeof value === "string" ? field(value) : value)}`
599
+ );
600
+ return `${JSON.stringify(redactStated(message, secrets, maxUpstreamMessageLength))}${path === void 0 ? "" : ` at ${graphqlPathText(path, secrets)}`}${entries.length === 0 ? "" : ` (${entries.join(", ")})`}`;
601
+ };
602
+ var unreadBodies = {
603
+ too_large: `Executor did not read its response body, which was larger than ${defaultOpenapiErrorLimits.maxBodyBytes / 1024} KiB.`,
604
+ incomplete: "Executor did not read its response body, which did not arrive in time."
605
+ };
606
+ var graphqlFailureMessage = (error, secrets) => {
607
+ const stage = graphqlStages[error.phase];
608
+ const answered = error.status === void 0 ? "answered" : `answered HTTP ${error.status}`;
609
+ const explanation = Match_exports.value(error.reason).pipe(
610
+ Match_exports.when("timeout", () => `The GraphQL server did not respond in time ${stage}.`),
611
+ Match_exports.when("unauthorized", () => `The GraphQL server rejected the credentials ${stage}.`),
612
+ Match_exports.when(
613
+ "invalid_response",
614
+ () => `The GraphQL server returned a response Executor could not use ${stage}.`
615
+ ),
616
+ Match_exports.when(
617
+ "invalid_input",
618
+ () => error.phase === "call" ? "The input could not be encoded as a GraphQL request for this tool." : "The GraphQL endpoint URL or connection settings are invalid."
619
+ ),
620
+ Match_exports.when(
621
+ "request",
622
+ () => error.status === void 0 ? `The request to the GraphQL server failed ${stage}.` : `The GraphQL server ${answered} ${stage}.`
623
+ ),
624
+ Match_exports.when("execution", () => `The GraphQL server ${answered} with errors ${stage}.`),
625
+ Match_exports.exhaustive
626
+ );
627
+ if (error.unreadBody !== void 0) return `${explanation} ${unreadBodies[error.unreadBody]}`;
628
+ const errors = error.errors ?? [];
629
+ if (errors.length === 0) return explanation;
630
+ const total = error.stated ?? errors.length;
631
+ const more = total - errors.length;
632
+ return `${explanation} It stated${total === 1 ? "" : ` ${total} errors`}: ${errors.map((stated) => graphqlStatedText(stated, secrets)).join("; ")}.${more === 0 ? "" : ` ${more} more ${more === 1 ? "error is" : "errors are"} not shown.`}`;
633
+ };
444
634
  var failureDetail = (error, secrets) => {
445
635
  if (Schema_exports.is(CacheError)(error))
446
636
  return {
@@ -456,6 +646,13 @@ var failureDetail = (error, secrets) => {
456
646
  code: error.reason,
457
647
  message: boundFailureMessage(openapiFailureMessage(error), secrets)
458
648
  };
649
+ if (Schema_exports.is(GraphqlError)(error))
650
+ return {
651
+ source: "service",
652
+ errorName: "GraphqlError",
653
+ code: error.reason,
654
+ message: boundFailureMessage(graphqlFailureMessage(error, secrets), secrets)
655
+ };
459
656
  if (Schema_exports.is(McpError)(error))
460
657
  return {
461
658
  source: "service",
@@ -774,6 +971,15 @@ export {
774
971
  OpenapiCompileError,
775
972
  OpenapiToolName,
776
973
  OpenapiToolNames,
974
+ defaultGraphqlClientLimits,
975
+ GraphqlToolsOptions,
976
+ maxGraphqlStatedErrors,
977
+ maxGraphqlStatedExtensions,
978
+ maxGraphqlStatedFieldLength,
979
+ GraphqlError,
980
+ GraphqlIntrospection,
981
+ GraphqlResponse,
982
+ GraphqlToolDefinition,
777
983
  accountSecrets,
778
984
  boundFailureMessage,
779
985
  leavingProviderError,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getWithReads
3
- } from "./chunk-2B7FHH7S.js";
3
+ } from "./chunk-SEJBC5UM.js";
4
4
  import {
5
5
  fromPromise,
6
6
  method,
7
7
  toPromise
8
- } from "./chunk-R3O32PQV.js";
8
+ } from "./chunk-AVDSIC3N.js";
9
9
  import {
10
10
  CacheError
11
11
  } from "./chunk-2RGJMA7N.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  prepareElicitation
3
- } from "./chunk-3UWLQMMK.js";
3
+ } from "./chunk-XYMLJ42M.js";
4
4
  import {
5
5
  failOnNetworkRefusal
6
6
  } from "./chunk-HLMJBE4T.js";
@@ -10,7 +10,7 @@ import {
10
10
  fromPromise,
11
11
  httpProviderError,
12
12
  providerErrorDetail
13
- } from "./chunk-R3O32PQV.js";
13
+ } from "./chunk-AVDSIC3N.js";
14
14
  import {
15
15
  ElicitationFailed,
16
16
  McpCredentialsUnverified,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fromPromise
3
- } from "./chunk-R3O32PQV.js";
3
+ } from "./chunk-AVDSIC3N.js";
4
4
  import {
5
5
  HostedTool,
6
6
  RouterKey,
@@ -5,7 +5,7 @@ import {
5
5
  fromPromise,
6
6
  method,
7
7
  toPromise
8
- } from "./chunk-R3O32PQV.js";
8
+ } from "./chunk-AVDSIC3N.js";
9
9
  import {
10
10
  CacheAcquired,
11
11
  CacheEntry,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  fixedRouter
3
- } from "./chunk-OTDKCYMH.js";
3
+ } from "./chunk-GD2QMZMA.js";
4
4
  import {
5
5
  nativeOperation,
6
6
  operationDeclaration,
7
7
  routerDeclaration
8
- } from "./chunk-PILIRGJA.js";
8
+ } from "./chunk-QXJPA2YB.js";
9
9
 
10
10
  // src/implementation/protocol-operations.ts
11
11
  var protocolOperations = (operations, kinds = {}) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  authorCache,
3
3
  unavailableCache
4
- } from "./chunk-2B7FHH7S.js";
4
+ } from "./chunk-SEJBC5UM.js";
5
5
  import {
6
6
  accountSecrets,
7
7
  boundFailureMessage,
@@ -12,7 +12,7 @@ import {
12
12
  parseSkillLoadFailed,
13
13
  readCatalog,
14
14
  routerSkills
15
- } from "./chunk-OTDKCYMH.js";
15
+ } from "./chunk-GD2QMZMA.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-QN5BMAG7.js";
29
+ } from "./chunk-CWYIEXX2.js";
30
30
  import {
31
31
  declaredOperations,
32
32
  locate,
33
33
  nativeOperation
34
- } from "./chunk-PILIRGJA.js";
34
+ } from "./chunk-QXJPA2YB.js";
35
35
  import {
36
36
  accountProviderError,
37
37
  appCode,
@@ -39,7 +39,7 @@ import {
39
39
  httpProviderError,
40
40
  parseProviderError,
41
41
  toPromise
42
- } from "./chunk-R3O32PQV.js";
42
+ } from "./chunk-AVDSIC3N.js";
43
43
  import {
44
44
  AccountCheckResult,
45
45
  DeclaredProvider,
package/js/effect.js CHANGED
@@ -3,14 +3,14 @@ import {
3
3
  ApprovalDecision,
4
4
  createAppHandler,
5
5
  prepareElicitation
6
- } from "./chunk-3UWLQMMK.js";
7
- import "./chunk-2B7FHH7S.js";
8
- import "./chunk-OTDKCYMH.js";
6
+ } from "./chunk-XYMLJ42M.js";
7
+ import "./chunk-SEJBC5UM.js";
8
+ import "./chunk-GD2QMZMA.js";
9
9
  import "./chunk-HLMJBE4T.js";
10
10
  import "./chunk-PBGPES67.js";
11
- import "./chunk-QN5BMAG7.js";
12
- import "./chunk-PILIRGJA.js";
13
- import "./chunk-R3O32PQV.js";
11
+ import "./chunk-CWYIEXX2.js";
12
+ import "./chunk-QXJPA2YB.js";
13
+ import "./chunk-AVDSIC3N.js";
14
14
  import {
15
15
  ToolAnnotations
16
16
  } from "./chunk-2RGJMA7N.js";