apps 0.0.1-beta.24 → 0.0.1-beta.26

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 (76) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-IJX4CYZO.js → chunk-2TP7C25K.js} +3 -3
  3. package/js/{chunk-KUMBKVJD.js → chunk-3YN4UDPB.js} +2 -2
  4. package/js/{chunk-B3T7CZOH.js → chunk-4CMJD7AB.js} +29 -7
  5. package/js/{chunk-M3B3DE4K.js → chunk-AAAMPT6F.js} +2 -2
  6. package/js/{chunk-3HH4OZR3.js → chunk-BTRBOOTD.js} +23 -25
  7. package/js/chunk-DAIW2WM3.js +118 -0
  8. package/js/{chunk-CDL5PM2Q.js → chunk-DM5U7G7V.js} +124 -124
  9. package/js/{chunk-ODEIDRGW.js → chunk-DUEZ2XCO.js} +3 -3
  10. package/js/{chunk-WFEUCUFF.js → chunk-EXDR4HVM.js} +184 -30
  11. package/js/{chunk-N7YDVXYJ.js → chunk-GH6PY5BQ.js} +1 -1
  12. package/js/{chunk-K2QATKIF.js → chunk-HIYRKEWP.js} +77 -22
  13. package/js/{chunk-PZB6T6KU.js → chunk-HQKIPKM5.js} +1 -1
  14. package/js/{chunk-66JAEDTE.js → chunk-IE6W5RNN.js} +2 -2
  15. package/js/{chunk-27F7W2LG.js → chunk-KKGRSXUK.js} +1 -1
  16. package/js/{chunk-57RKNWL2.js → chunk-KNJAOYV4.js} +2 -2
  17. package/js/{chunk-ZQINWV4W.js → chunk-LPN4ONWW.js} +2 -2
  18. package/js/{chunk-A5BSZKFF.js → chunk-NXO2GN2T.js} +8 -8
  19. package/js/{chunk-UK573G7W.js → chunk-OBXHLFGQ.js} +1 -1
  20. package/js/{chunk-JWNSH5CA.js → chunk-OI7OI2U3.js} +2 -2
  21. package/js/{chunk-IPI4MFSN.js → chunk-PC5RHPUP.js} +2 -2
  22. package/js/{chunk-VFZKSM3T.js → chunk-SUY33XAY.js} +1 -1
  23. package/js/{chunk-R3EV5FTO.js → chunk-T7WRQJUF.js} +55 -3
  24. package/js/{chunk-JU7VHODU.js → chunk-TACLXEAE.js} +1 -1
  25. package/js/{chunk-2KZ7GG43.js → chunk-VGEPL4BV.js} +146 -53
  26. package/js/{chunk-S47NFEWF.js → chunk-WPKXOTKM.js} +3 -3
  27. package/js/{chunk-PJJ24GU7.js → chunk-XBG3M64K.js} +1 -1
  28. package/js/{chunk-AK54RD3A.js → chunk-XIRAIB3P.js} +4 -4
  29. package/js/{chunk-NKLWZJLE.js → chunk-ZVMZWXVF.js} +2 -2
  30. package/js/client.js +10 -10
  31. package/js/contracts.js +36 -14
  32. package/js/effect.js +19 -19
  33. package/js/graphql.js +21 -21
  34. package/js/host.js +19 -19
  35. package/js/index.js +12 -12
  36. package/js/mcp/effect.js +21 -21
  37. package/js/mcp/stdio.js +30 -25
  38. package/js/mcp.js +23 -23
  39. package/js/openapi.js +595 -200
  40. package/js/react.js +3 -3
  41. package/js/skills/effect.js +3 -3
  42. package/js/skills.js +11 -11
  43. package/js/storage/facet.js +4 -4
  44. package/js/ui/auth/contracts.js +2 -2
  45. package/js/ui/auth.js +5 -5
  46. package/js/ui/contracts.js +4 -4
  47. package/js/ui/serving.js +8 -8
  48. package/package.json +1 -1
  49. package/runtime.json +1 -1
  50. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  51. package/types/apps/src/contracts/failure.d.ts +30 -1
  52. package/types/apps/src/contracts/host.d.ts +5 -4
  53. package/types/apps/src/contracts/mcp.d.ts +8 -1
  54. package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
  55. package/types/apps/src/contracts/openapi.d.ts +16 -6
  56. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  57. package/types/apps/src/contracts/protocols/1.d.ts +16 -2
  58. package/types/apps/src/contracts/protocols/2.d.ts +1 -1
  59. package/types/apps/src/contracts/protocols/3.d.ts +1 -3
  60. package/types/apps/src/contracts/protocols/4.d.ts +1 -2
  61. package/types/apps/src/contracts/protocols/5.d.ts +3 -3
  62. package/types/apps/src/contracts/protocols/6.d.ts +3 -3
  63. package/types/apps/src/contracts/protocols/7.d.ts +3 -3
  64. package/types/apps/src/contracts/protocols/8.d.ts +1119 -0
  65. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  66. package/types/apps/src/implementation/failure-detail.d.ts +22 -3
  67. package/types/apps/src/implementation/mcp-client.d.ts +6 -0
  68. package/types/apps/src/implementation/openapi-compile.d.ts +12 -2
  69. package/types/apps/src/implementation/openapi-document.d.ts +20 -6
  70. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  71. package/types/apps/src/implementation/openapi-source.d.ts +6 -0
  72. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  73. package/types/apps/src/implementation/router-catalog.d.ts +2 -3
  74. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  75. package/types/telemetry/src/config.d.ts +2 -2
  76. package/js/chunk-MKWZPDR6.js +0 -63
@@ -19,10 +19,10 @@ import {
19
19
  text,
20
20
  uint8Array,
21
21
  urlParams
22
- } from "./chunk-UK573G7W.js";
22
+ } from "./chunk-OBXHLFGQ.js";
23
23
  import {
24
24
  JsonValue
25
- } from "./chunk-27F7W2LG.js";
25
+ } from "./chunk-KKGRSXUK.js";
26
26
  import {
27
27
  Cause,
28
28
  Defect,
@@ -118,7 +118,7 @@ import {
118
118
  transformEffect,
119
119
  transformPull,
120
120
  void_2 as void_
121
- } from "./chunk-CDL5PM2Q.js";
121
+ } from "./chunk-DM5U7G7V.js";
122
122
  import {
123
123
  __export
124
124
  } from "./chunk-CZ7CSFO4.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  appSignInCallbackPath
3
- } from "./chunk-VFZKSM3T.js";
3
+ } from "./chunk-SUY33XAY.js";
4
4
  import {
5
5
  HttpServerResponse_exports
6
- } from "./chunk-UK573G7W.js";
6
+ } from "./chunk-OBXHLFGQ.js";
7
7
 
8
8
  // src/implementation/ui-auth.ts
9
9
  var appPrivateHeaders = {
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  prepareElicitation
3
- } from "./chunk-3HH4OZR3.js";
3
+ } from "./chunk-BTRBOOTD.js";
4
4
  import {
5
5
  fromPromise
6
- } from "./chunk-S47NFEWF.js";
6
+ } from "./chunk-WPKXOTKM.js";
7
+ import {
8
+ bodyUpstreamError
9
+ } from "./chunk-DAIW2WM3.js";
7
10
  import {
8
11
  ElicitationFailed,
9
12
  McpError,
@@ -15,15 +18,15 @@ import {
15
18
  defaultElicitationLimits,
16
19
  defaultMcpClientLimits,
17
20
  mcpSdkTimerCeilingMs
18
- } from "./chunk-2KZ7GG43.js";
21
+ } from "./chunk-VGEPL4BV.js";
19
22
  import {
20
23
  jsonSchemaDecoder,
21
24
  nestJsonSchema,
22
25
  preparedJsonSchemaDecoder
23
- } from "./chunk-66JAEDTE.js";
26
+ } from "./chunk-IE6W5RNN.js";
24
27
  import {
25
28
  JsonObject
26
- } from "./chunk-27F7W2LG.js";
29
+ } from "./chunk-KKGRSXUK.js";
27
30
  import {
28
31
  Clock_exports,
29
32
  Deferred_exports,
@@ -32,7 +35,7 @@ import {
32
35
  Option_exports,
33
36
  Queue_exports,
34
37
  Schema_exports
35
- } from "./chunk-CDL5PM2Q.js";
38
+ } from "./chunk-DM5U7G7V.js";
36
39
 
37
40
  // src/implementation/mcp-tools.ts
38
41
  var resultFields = {
@@ -128,7 +131,11 @@ var adaptMcpTools = (client) => Effect_exports.gen(function* () {
128
131
  });
129
132
 
130
133
  // src/implementation/mcp-client.ts
131
- import { ListToolsResultSchema } from "@modelcontextprotocol/sdk/types.js";
134
+ import {
135
+ ErrorCode as ErrorCode2,
136
+ ListToolsResultSchema,
137
+ McpError as ProtocolError2
138
+ } from "@modelcontextprotocol/sdk/types.js";
132
139
 
133
140
  // src/implementation/mcp-call.ts
134
141
  import {
@@ -257,6 +264,20 @@ var mcpCall = (client, name, input, context, timeoutMs, failure) => Effect_expor
257
264
  );
258
265
 
259
266
  // src/implementation/mcp-client.ts
267
+ var clientCodes = /* @__PURE__ */ new Set([
268
+ ErrorCode2.RequestTimeout,
269
+ ErrorCode2.ConnectionClosed
270
+ ]);
271
+ var answeredError = (error) => {
272
+ if (!(error instanceof ProtocolError2) || clientCodes.has(error.code)) return void 0;
273
+ const prefix = `MCP error ${error.code}: `;
274
+ return bodyUpstreamError({
275
+ error: {
276
+ code: error.code,
277
+ message: error.message.startsWith(prefix) ? error.message.slice(prefix.length) : error.message
278
+ }
279
+ });
280
+ };
260
281
  var mcpJsonSchemaValidator = {
261
282
  getValidator(document) {
262
283
  const decoder = Effect_exports.runSync(jsonSchemaDecoder(document));
@@ -341,6 +362,7 @@ function mcpClient(withClient, timeoutMs, failure) {
341
362
  export {
342
363
  adaptMcpTool,
343
364
  adaptMcpTools,
365
+ answeredError,
344
366
  mcpJsonSchemaValidator,
345
367
  mcpClient
346
368
  };
@@ -3,7 +3,7 @@ import {
3
3
  invalidate,
4
4
  layer,
5
5
  mutation
6
- } from "./chunk-PJJ24GU7.js";
6
+ } from "./chunk-XBG3M64K.js";
7
7
  import {
8
8
  Boolean,
9
9
  Cause,
@@ -158,7 +158,7 @@ import {
158
158
  void_2,
159
159
  whileLoop,
160
160
  zipRight
161
- } from "./chunk-CDL5PM2Q.js";
161
+ } from "./chunk-DM5U7G7V.js";
162
162
  import {
163
163
  __export
164
164
  } from "./chunk-CZ7CSFO4.js";
@@ -1,39 +1,41 @@
1
1
  import {
2
2
  makeCache
3
- } from "./chunk-NKLWZJLE.js";
3
+ } from "./chunk-ZVMZWXVF.js";
4
4
  import {
5
5
  accountSecrets,
6
6
  boundFailureMessage,
7
7
  describeFailure,
8
8
  failureDetail,
9
+ leavingProviderError,
10
+ parseMcpError,
9
11
  readCatalog,
10
12
  routerSkills
11
- } from "./chunk-WFEUCUFF.js";
13
+ } from "./chunk-EXDR4HVM.js";
12
14
  import {
13
15
  folderSkillsEffect
14
- } from "./chunk-IPI4MFSN.js";
16
+ } from "./chunk-PC5RHPUP.js";
15
17
  import {
16
18
  ResponseStatusError,
17
19
  authorDatabase,
18
20
  isApp,
19
21
  toEffectApp,
20
22
  unavailableStorage
21
- } from "./chunk-A5BSZKFF.js";
23
+ } from "./chunk-NXO2GN2T.js";
22
24
  import {
23
25
  parseDatabaseSchema
24
- } from "./chunk-ZQINWV4W.js";
26
+ } from "./chunk-LPN4ONWW.js";
25
27
  import {
26
28
  declaredOperations,
27
29
  fromPromise,
28
30
  locate,
29
31
  nativeOperation,
30
32
  toPromise
31
- } from "./chunk-S47NFEWF.js";
33
+ } from "./chunk-WPKXOTKM.js";
32
34
  import {
33
35
  accountProviderError,
34
36
  httpProviderError,
35
37
  parseProviderError
36
- } from "./chunk-MKWZPDR6.js";
38
+ } from "./chunk-DAIW2WM3.js";
37
39
  import {
38
40
  AccountCheckResult,
39
41
  DeclaredProvider,
@@ -64,7 +66,6 @@ import {
64
66
  InvocationDeadline,
65
67
  ManualWebhookSetup,
66
68
  ManyAccounts,
67
- McpError,
68
69
  NonRetryableError,
69
70
  OpenapiResponseError,
70
71
  ResolvedAccounts,
@@ -81,29 +82,29 @@ import {
81
82
  defaultWebhookTransportLimits,
82
83
  maxInputProblems,
83
84
  workflowDurationMillis
84
- } from "./chunk-2KZ7GG43.js";
85
+ } from "./chunk-VGEPL4BV.js";
85
86
  import {
86
87
  CacheError
87
- } from "./chunk-R3EV5FTO.js";
88
+ } from "./chunk-T7WRQJUF.js";
88
89
  import {
89
90
  AppSkills,
90
91
  SkillFile,
91
92
  SkillLoadFailed
92
- } from "./chunk-JU7VHODU.js";
93
+ } from "./chunk-TACLXEAE.js";
93
94
  import {
94
95
  captureTelemetry,
95
96
  invocationFetch
96
- } from "./chunk-ODEIDRGW.js";
97
+ } from "./chunk-DUEZ2XCO.js";
97
98
  import {
98
99
  decoderOf,
99
100
  importedJsonSchema,
100
101
  jsonSchemaDecoder,
101
102
  jsonSchemaDocument
102
- } from "./chunk-66JAEDTE.js";
103
+ } from "./chunk-IE6W5RNN.js";
103
104
  import {
104
105
  JsonObject,
105
106
  JsonValue
106
- } from "./chunk-27F7W2LG.js";
107
+ } from "./chunk-KKGRSXUK.js";
107
108
  import {
108
109
  Cause_exports,
109
110
  Clock_exports,
@@ -115,7 +116,7 @@ import {
115
116
  SchemaIssue_exports,
116
117
  Schema_exports,
117
118
  Stream_exports
118
- } from "./chunk-CDL5PM2Q.js";
119
+ } from "./chunk-DM5U7G7V.js";
119
120
 
120
121
  // src/implementation/elicitation.ts
121
122
  var prepareElicitation = (input) => Effect_exports.gen(function* () {
@@ -575,9 +576,9 @@ var evaluationSafe = (work, secrets) => work.pipe(
575
576
  const error = Cause_exports.squash(cause);
576
577
  const provider = parseProviderError(error);
577
578
  const skills = parseSkillLoadFailed(error);
578
- const mcp = parseMcpError(error);
579
+ const mcp = parseMcpError(error, secrets);
579
580
  return Effect_exports.fail(
580
- Option_exports.isSome(provider) ? provider.value : Option_exports.isSome(skills) ? skills.value : Option_exports.isSome(mcp) ? mcp.value : new HostEvaluationFailed(failureDetail(error, secrets))
581
+ Option_exports.isSome(provider) ? leavingProviderError(provider.value, secrets, "discover") : Option_exports.isSome(skills) ? skills.value : Option_exports.isSome(mcp) ? mcp.value : new HostEvaluationFailed(failureDetail(error, secrets))
581
582
  );
582
583
  })
583
584
  );
@@ -1106,14 +1107,15 @@ function dispatch(app, request, context, signal) {
1106
1107
  const error = Cause_exports.squash(cause);
1107
1108
  const provider = parseProviderError(error);
1108
1109
  const response = Schema_exports.decodeUnknownOption(OpenapiResponseError)(error);
1110
+ const mcp = parseMcpError(error, secrets);
1109
1111
  const failure = Schema_exports.decodeUnknownOption(ElicitationFailed)(error);
1110
1112
  return Effect_exports.fail(
1111
- Option_exports.isSome(provider) ? provider.value : Option_exports.isSome(response) ? new OpenapiResponseError({
1113
+ Option_exports.isSome(provider) ? leavingProviderError(provider.value, secrets, "call") : Option_exports.isSome(response) ? new OpenapiResponseError({
1112
1114
  code: response.value.code,
1113
1115
  status: response.value.status,
1114
1116
  message: response.value.message,
1115
1117
  ...response.value.recovery === void 0 ? {} : { recovery: response.value.recovery }
1116
- }) : Option_exports.isSome(failure) ? failure.value : new HostOperationFailed(failureDetail(error, secrets))
1118
+ }) : Option_exports.isSome(mcp) ? mcp.value : Option_exports.isSome(failure) ? failure.value : new HostOperationFailed(failureDetail(error, secrets))
1117
1119
  );
1118
1120
  }),
1119
1121
  Effect_exports.withSpan("app.operation.execute", {
@@ -1178,8 +1180,9 @@ function checkAccount(slots, declared, requirement, context, signal) {
1178
1180
  const error = Cause_exports.squash(cause);
1179
1181
  const status = Schema_exports.decodeUnknownOption(ResponseStatusError)(error);
1180
1182
  const classified = Option_exports.isSome(status) ? Option_exports.fromNullishOr(httpProviderError(status.value.status)) : parseProviderError(error);
1183
+ const secrets = accountSecrets(context.accounts);
1181
1184
  return Effect_exports.fail(
1182
- Option_exports.isSome(classified) ? accountProviderError(classified.value, account.id) : new HostOperationFailed(failureDetail(error, accountSecrets(context.accounts)))
1185
+ Option_exports.isSome(classified) ? leavingProviderError(accountProviderError(classified.value, account.id), secrets) : new HostOperationFailed(failureDetail(error, secrets))
1183
1186
  );
1184
1187
  }),
1185
1188
  Effect_exports.withSpan("app.account.check")
@@ -1202,11 +1205,6 @@ var parseSkillLoadFailed = (error) => Schema_exports.decodeUnknownOption(SkillLo
1202
1205
  })
1203
1206
  )
1204
1207
  );
1205
- var parseMcpError = (error) => Schema_exports.decodeUnknownOption(McpError)(error).pipe(
1206
- Option_exports.map(
1207
- ({ phase, reason, status }) => new McpError({ phase, reason, ...status === void 0 ? {} : { status } })
1208
- )
1209
- );
1210
1208
  var errorStatus = Match_exports.type().pipe(
1211
1209
  Match_exports.tagsExhaustive({
1212
1210
  ProviderError: () => 502,
@@ -0,0 +1,118 @@
1
+ import {
2
+ ProviderError,
3
+ maxUpstreamMessageLength
4
+ } from "./chunk-T7WRQJUF.js";
5
+ import {
6
+ AccountId
7
+ } from "./chunk-KKGRSXUK.js";
8
+ import {
9
+ Option_exports,
10
+ Schema_exports
11
+ } from "./chunk-DM5U7G7V.js";
12
+
13
+ // src/implementation/upstream-error.ts
14
+ var ErrorToken = Schema_exports.String.check(Schema_exports.isPattern(/^[A-Za-z0-9._-]{1,128}$/));
15
+ var JsonRpcError = Schema_exports.Struct({
16
+ error: Schema_exports.Struct({ code: Schema_exports.Int, message: Schema_exports.String })
17
+ });
18
+ var OAuthError = Schema_exports.Struct({
19
+ error: ErrorToken,
20
+ error_description: Schema_exports.optional(Schema_exports.String)
21
+ });
22
+ var bounded = (message) => message.length <= maxUpstreamMessageLength ? message : `${message.slice(0, maxUpstreamMessageLength - 1)}\u2026`;
23
+ var isShortenedUpstream = (message) => message.length === maxUpstreamMessageLength && message.endsWith("\u2026");
24
+ var stated = (code, message) => ({
25
+ code,
26
+ ...message === void 0 || message === "" ? {} : { message: bounded(message) }
27
+ });
28
+ var bodyUpstreamError = (json) => {
29
+ const rpc = Schema_exports.decodeUnknownOption(JsonRpcError)(json);
30
+ if (Option_exports.isSome(rpc)) return stated(rpc.value.error.code, rpc.value.error.message);
31
+ const oauth = Schema_exports.decodeUnknownOption(OAuthError)(json);
32
+ if (Option_exports.isSome(oauth)) return stated(oauth.value.error, oauth.value.error_description);
33
+ return void 0;
34
+ };
35
+ var authParam = /([A-Za-z][A-Za-z0-9_-]*)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,"]+))/g;
36
+ var challengeUpstreamError = (header) => {
37
+ const bearer = header === void 0 ? -1 : header.search(/\bBearer\b/i);
38
+ if (header === void 0 || bearer === -1) return void 0;
39
+ const params = /* @__PURE__ */ new Map();
40
+ for (const [, name, quoted, token] of header.slice(bearer + "Bearer".length).matchAll(authParam))
41
+ if (name !== void 0 && !params.has(name.toLowerCase()))
42
+ params.set(name.toLowerCase(), quoted?.replace(/\\(.)/g, "$1") ?? token ?? "");
43
+ const code = Schema_exports.decodeUnknownOption(ErrorToken)(params.get("error"));
44
+ return Option_exports.isNone(code) ? void 0 : stated(code.value, params.get("error_description"));
45
+ };
46
+
47
+ // src/implementation/provider-error.ts
48
+ var providerError = ({
49
+ reason,
50
+ status,
51
+ accountId,
52
+ phase,
53
+ upstream
54
+ }) => new ProviderError({
55
+ reason,
56
+ ...status === void 0 ? {} : { status },
57
+ ...accountId === void 0 ? {} : { accountId },
58
+ ...phase === void 0 ? {} : { phase },
59
+ ...upstream === void 0 ? {} : { upstream }
60
+ });
61
+ function parseProviderError(error) {
62
+ return Schema_exports.decodeUnknownOption(ProviderError)(error).pipe(Option_exports.map(providerError));
63
+ }
64
+ function providerErrorDetail(error, detail) {
65
+ return providerError({
66
+ ...error,
67
+ phase: error.phase ?? detail.phase,
68
+ upstream: error.upstream ?? detail.upstream
69
+ });
70
+ }
71
+ function httpProviderError(status, headers = {}) {
72
+ const upstream = challengeUpstreamError(headers["www-authenticate"]);
73
+ if (status >= 500 && status <= 599)
74
+ return providerError({ reason: "unavailable", status, upstream });
75
+ if (status === 401) return providerError({ reason: "unauthorized", status, upstream });
76
+ if (status === 429) return providerError({ reason: "rate_limited", status, upstream });
77
+ if (status !== 403) return void 0;
78
+ const retry = headers["retry-after"];
79
+ if (headers["x-ratelimit-remaining"] === "0" || retry !== void 0 && (/^\d+$/.test(retry) || Number.isFinite(Date.parse(retry))))
80
+ return providerError({ reason: "rate_limited", status, upstream });
81
+ if (typeof upstream?.code === "string" && upstream.code.toLowerCase() === "insufficient_scope")
82
+ return providerError({ reason: "forbidden", status, upstream });
83
+ return providerError({ reason: "rejected", status, upstream });
84
+ }
85
+ function accountProviderError(error, accountId) {
86
+ const parsed = parseProviderError(error);
87
+ const account = Schema_exports.decodeUnknownOption(AccountId)(accountId);
88
+ if (Option_exports.isNone(parsed) || Option_exports.isNone(account)) return error;
89
+ return providerError({ ...parsed.value, accountId: account.value });
90
+ }
91
+ function graphqlProviderError(errors, status) {
92
+ const codes = errors.flatMap((error) => {
93
+ const parsed = Schema_exports.decodeUnknownOption(
94
+ Schema_exports.Struct({
95
+ type: Schema_exports.optional(Schema_exports.String),
96
+ extensions: Schema_exports.optional(Schema_exports.Struct({ code: Schema_exports.optional(Schema_exports.String) }))
97
+ })
98
+ )(error);
99
+ return Option_exports.isSome(parsed) ? [parsed.value.type, parsed.value.extensions?.code] : [];
100
+ });
101
+ if (codes.includes("RATE_LIMITED") || codes.includes("TOO_MANY_REQUESTS"))
102
+ return new ProviderError({ reason: "rate_limited", status });
103
+ if (codes.includes("UNAUTHENTICATED"))
104
+ return new ProviderError({ reason: "unauthorized", status });
105
+ if (codes.includes("FORBIDDEN")) return new ProviderError({ reason: "forbidden", status });
106
+ return void 0;
107
+ }
108
+
109
+ export {
110
+ isShortenedUpstream,
111
+ bodyUpstreamError,
112
+ providerError,
113
+ parseProviderError,
114
+ providerErrorDetail,
115
+ httpProviderError,
116
+ accountProviderError,
117
+ graphqlProviderError
118
+ };