apps 0.0.1-beta.25 → 0.0.1-beta.27

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 (62) hide show
  1. package/README.md +6 -6
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-VWU6I23D.js → chunk-3TEX4ZND.js} +23 -17
  4. package/js/{chunk-K3MQX2KO.js → chunk-4OD7PHQL.js} +2 -2
  5. package/js/{chunk-AAAMPT6F.js → chunk-65SZ23BK.js} +2 -2
  6. package/js/{chunk-XBG3M64K.js → chunk-6JBTHTI5.js} +1 -1
  7. package/js/{chunk-J3RUZMLO.js → chunk-7AZNPMQH.js} +149 -15
  8. package/js/{chunk-VGEPL4BV.js → chunk-7R5JY5H7.js} +19 -5
  9. package/js/{chunk-VSLWGXPW.js → chunk-AHI26TO6.js} +24 -8
  10. package/js/{chunk-OBXHLFGQ.js → chunk-B5YJQU45.js} +1 -1
  11. package/js/{chunk-T7WRQJUF.js → chunk-BRGF7VFN.js} +2 -2
  12. package/js/{chunk-HQKIPKM5.js → chunk-BTJMXW4I.js} +1 -1
  13. package/js/{chunk-GG4IFBN3.js → chunk-HIJW4LWC.js} +64 -21
  14. package/js/{chunk-DAIW2WM3.js → chunk-KQCMHI3K.js} +3 -3
  15. package/js/{chunk-GH6PY5BQ.js → chunk-M2KEEOIQ.js} +1 -1
  16. package/js/{chunk-TACLXEAE.js → chunk-NSBRV4FJ.js} +1 -1
  17. package/js/{chunk-DM5U7G7V.js → chunk-NXTXZ635.js} +1842 -1840
  18. package/js/{chunk-3YN4UDPB.js → chunk-PTUZSCEV.js} +2 -2
  19. package/js/{chunk-KKGRSXUK.js → chunk-PWF2DRJ3.js} +1 -1
  20. package/js/{chunk-2TP7C25K.js → chunk-SDLIDQXG.js} +3 -3
  21. package/js/{chunk-NXO2GN2T.js → chunk-T2UFJKZR.js} +8 -8
  22. package/js/{chunk-PC5RHPUP.js → chunk-TSLG2WPA.js} +2 -2
  23. package/js/{chunk-WPKXOTKM.js → chunk-TX2XCAL6.js} +3 -3
  24. package/js/{chunk-KNJAOYV4.js → chunk-V2I3MMPM.js} +2 -2
  25. package/js/{chunk-ZVMZWXVF.js → chunk-VUVBMNKC.js} +2 -2
  26. package/js/{chunk-SUY33XAY.js → chunk-WQ5MVBTP.js} +1 -1
  27. package/js/{chunk-LPN4ONWW.js → chunk-XBQTJP76.js} +2 -2
  28. package/js/{chunk-IE6W5RNN.js → chunk-YML53Z7H.js} +2 -2
  29. package/js/{chunk-DUEZ2XCO.js → chunk-YXKXKGN6.js} +3 -3
  30. package/js/{chunk-XIRAIB3P.js → chunk-ZZOCEUTB.js} +4 -4
  31. package/js/client.js +10 -10
  32. package/js/contracts.js +7 -7
  33. package/js/effect.js +19 -19
  34. package/js/graphql.js +21 -21
  35. package/js/host.js +19 -19
  36. package/js/index.js +12 -12
  37. package/js/mcp/effect.js +23 -21
  38. package/js/mcp/stdio.js +21 -21
  39. package/js/mcp.js +29 -24
  40. package/js/openapi.js +595 -200
  41. package/js/react.js +3 -3
  42. package/js/skills/effect.js +3 -3
  43. package/js/skills.js +11 -11
  44. package/js/storage/facet.js +4 -4
  45. package/js/ui/auth/contracts.js +2 -2
  46. package/js/ui/auth.js +5 -5
  47. package/js/ui/contracts.js +4 -4
  48. package/js/ui/serving.js +8 -8
  49. package/package.json +1 -1
  50. package/runtime.json +1 -1
  51. package/types/apps/src/contracts/mcp.d.ts +49 -3
  52. package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
  53. package/types/apps/src/contracts/openapi.d.ts +16 -6
  54. package/types/apps/src/contracts/provider.d.ts +6 -0
  55. package/types/apps/src/implementation/failure-detail.d.ts +3 -2
  56. package/types/apps/src/implementation/mcp-client.d.ts +1 -0
  57. package/types/apps/src/implementation/mcp.d.ts +11 -1
  58. package/types/apps/src/implementation/openapi-compile.d.ts +12 -2
  59. package/types/apps/src/implementation/openapi-document.d.ts +20 -6
  60. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  61. package/types/apps/src/implementation/openapi-source.d.ts +6 -0
  62. package/types/apps/src/mcp.d.ts +20 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeCache
3
- } from "./chunk-ZVMZWXVF.js";
3
+ } from "./chunk-VUVBMNKC.js";
4
4
  import {
5
5
  accountSecrets,
6
6
  boundFailureMessage,
@@ -10,32 +10,32 @@ import {
10
10
  parseMcpError,
11
11
  readCatalog,
12
12
  routerSkills
13
- } from "./chunk-J3RUZMLO.js";
13
+ } from "./chunk-7AZNPMQH.js";
14
14
  import {
15
15
  folderSkillsEffect
16
- } from "./chunk-PC5RHPUP.js";
16
+ } from "./chunk-TSLG2WPA.js";
17
17
  import {
18
18
  ResponseStatusError,
19
19
  authorDatabase,
20
20
  isApp,
21
21
  toEffectApp,
22
22
  unavailableStorage
23
- } from "./chunk-NXO2GN2T.js";
23
+ } from "./chunk-T2UFJKZR.js";
24
24
  import {
25
25
  parseDatabaseSchema
26
- } from "./chunk-LPN4ONWW.js";
26
+ } from "./chunk-XBQTJP76.js";
27
27
  import {
28
28
  declaredOperations,
29
29
  fromPromise,
30
30
  locate,
31
31
  nativeOperation,
32
32
  toPromise
33
- } from "./chunk-WPKXOTKM.js";
33
+ } from "./chunk-TX2XCAL6.js";
34
34
  import {
35
35
  accountProviderError,
36
36
  httpProviderError,
37
37
  parseProviderError
38
- } from "./chunk-DAIW2WM3.js";
38
+ } from "./chunk-KQCMHI3K.js";
39
39
  import {
40
40
  AccountCheckResult,
41
41
  DeclaredProvider,
@@ -82,29 +82,29 @@ import {
82
82
  defaultWebhookTransportLimits,
83
83
  maxInputProblems,
84
84
  workflowDurationMillis
85
- } from "./chunk-VGEPL4BV.js";
85
+ } from "./chunk-7R5JY5H7.js";
86
86
  import {
87
87
  CacheError
88
- } from "./chunk-T7WRQJUF.js";
88
+ } from "./chunk-BRGF7VFN.js";
89
89
  import {
90
90
  AppSkills,
91
91
  SkillFile,
92
92
  SkillLoadFailed
93
- } from "./chunk-TACLXEAE.js";
93
+ } from "./chunk-NSBRV4FJ.js";
94
94
  import {
95
95
  captureTelemetry,
96
96
  invocationFetch
97
- } from "./chunk-DUEZ2XCO.js";
97
+ } from "./chunk-YXKXKGN6.js";
98
98
  import {
99
99
  decoderOf,
100
100
  importedJsonSchema,
101
101
  jsonSchemaDecoder,
102
102
  jsonSchemaDocument
103
- } from "./chunk-IE6W5RNN.js";
103
+ } from "./chunk-YML53Z7H.js";
104
104
  import {
105
105
  JsonObject,
106
106
  JsonValue
107
- } from "./chunk-KKGRSXUK.js";
107
+ } from "./chunk-PWF2DRJ3.js";
108
108
  import {
109
109
  Cause_exports,
110
110
  Clock_exports,
@@ -116,7 +116,7 @@ import {
116
116
  SchemaIssue_exports,
117
117
  Schema_exports,
118
118
  Stream_exports
119
- } from "./chunk-DM5U7G7V.js";
119
+ } from "./chunk-NXTXZ635.js";
120
120
 
121
121
  // src/implementation/elicitation.ts
122
122
  var prepareElicitation = (input) => Effect_exports.gen(function* () {
@@ -805,7 +805,8 @@ function dispatch(app, request, context, signal) {
805
805
  declared,
806
806
  request.requirement,
807
807
  context,
808
- invocationSignal
808
+ invocationSignal,
809
+ deadline
809
810
  ).pipe(withinDeadline);
810
811
  let running;
811
812
  let transactionOpen = false;
@@ -1155,7 +1156,7 @@ function dispatch(app, request, context, signal) {
1155
1156
  })
1156
1157
  );
1157
1158
  }
1158
- function checkAccount(slots, declared, requirement, context, signal) {
1159
+ function checkAccount(slots, declared, requirement, context, signal, deadline) {
1159
1160
  return Effect_exports.gen(function* () {
1160
1161
  const selection = Object.hasOwn(slots, requirement) ? slots[requirement] : void 0;
1161
1162
  const slot = Object.hasOwn(declared.accounts, requirement) ? declared.accounts[requirement] : void 0;
@@ -1172,7 +1173,12 @@ function checkAccount(slots, declared, requirement, context, signal) {
1172
1173
  if (account === void 0 || !("id" in account)) return yield* new HostAccountsInvalid();
1173
1174
  const result = yield* Effect_exports.suspend(
1174
1175
  () => Effect_exports.gen(function* () {
1175
- return yield* health.run({ account, fetch: yield* invocationFetch(signal), signal });
1176
+ return yield* health.run({
1177
+ account,
1178
+ fetch: yield* invocationFetch(signal),
1179
+ signal,
1180
+ ...deadline === void 0 ? {} : { deadline }
1181
+ });
1176
1182
  })
1177
1183
  ).pipe(
1178
1184
  Effect_exports.catchCause((cause) => {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  fixedRouter
3
- } from "./chunk-J3RUZMLO.js";
3
+ } from "./chunk-7AZNPMQH.js";
4
4
  import {
5
5
  nativeOperation,
6
6
  operationDeclaration,
7
7
  routerDeclaration
8
- } from "./chunk-WPKXOTKM.js";
8
+ } from "./chunk-TX2XCAL6.js";
9
9
 
10
10
  // src/implementation/protocol-operations.ts
11
11
  var protocolOperations = (operations, kinds = {}) => {
@@ -3,7 +3,7 @@ import {
3
3
  invalidate,
4
4
  layer,
5
5
  mutation
6
- } from "./chunk-XBG3M64K.js";
6
+ } from "./chunk-6JBTHTI5.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-DM5U7G7V.js";
161
+ } from "./chunk-NXTXZ635.js";
162
162
  import {
163
163
  __export
164
164
  } from "./chunk-CZ7CSFO4.js";
@@ -58,7 +58,7 @@ import {
58
58
  useSpan,
59
59
  void_2 as void_,
60
60
  withFiber
61
- } from "./chunk-DM5U7G7V.js";
61
+ } from "./chunk-NXTXZ635.js";
62
62
 
63
63
  // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Reactivity.js
64
64
  var TypeId = "~effect/reactivity/Reactivity";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  skillFromFiles
3
- } from "./chunk-PC5RHPUP.js";
3
+ } from "./chunk-TSLG2WPA.js";
4
4
  import {
5
5
  joinPath,
6
6
  mergeMeta
7
- } from "./chunk-WPKXOTKM.js";
7
+ } from "./chunk-TX2XCAL6.js";
8
8
  import {
9
9
  isShortenedUpstream,
10
10
  parseProviderError,
11
11
  providerError
12
- } from "./chunk-DAIW2WM3.js";
12
+ } from "./chunk-KQCMHI3K.js";
13
13
  import {
14
14
  ApiErrorResponse,
15
15
  HostDeclarationInvalid,
@@ -17,11 +17,12 @@ import {
17
17
  HostedRouter,
18
18
  HostedTool,
19
19
  HostedToolSummary,
20
+ McpCredentialsUnverified,
20
21
  McpError
21
- } from "./chunk-VGEPL4BV.js";
22
+ } from "./chunk-7R5JY5H7.js";
22
23
  import {
23
24
  AppDatabaseError
24
- } from "./chunk-GH6PY5BQ.js";
25
+ } from "./chunk-M2KEEOIQ.js";
25
26
  import {
26
27
  CacheError,
27
28
  FailureCode,
@@ -30,32 +31,33 @@ import {
30
31
  maxFailureFields,
31
32
  maxFailureMessageLength,
32
33
  maxUpstreamMessageLength
33
- } from "./chunk-T7WRQJUF.js";
34
+ } from "./chunk-BRGF7VFN.js";
34
35
  import {
35
36
  SkillLoadFailed,
36
37
  skillFormatLimits
37
- } from "./chunk-TACLXEAE.js";
38
+ } from "./chunk-NSBRV4FJ.js";
38
39
  import {
39
40
  jsonSchemaDocument
40
- } from "./chunk-IE6W5RNN.js";
41
+ } from "./chunk-YML53Z7H.js";
41
42
  import {
42
43
  AppStorageError,
43
44
  AppStorageUnavailable
44
- } from "./chunk-HQKIPKM5.js";
45
+ } from "./chunk-BTJMXW4I.js";
45
46
  import {
46
47
  AccountId,
47
48
  HttpUrl,
48
49
  JsonObject
49
- } from "./chunk-KKGRSXUK.js";
50
+ } from "./chunk-PWF2DRJ3.js";
50
51
  import {
51
52
  Cause_exports,
52
53
  Effect_exports,
54
+ Match_exports,
53
55
  Option_exports,
54
56
  Predicate_exports,
55
57
  Redacted_exports,
56
58
  Result_exports,
57
59
  Schema_exports
58
- } from "./chunk-DM5U7G7V.js";
60
+ } from "./chunk-NXTXZ635.js";
59
61
 
60
62
  // src/contracts/openapi.ts
61
63
  var OpenapiErrorResponse = Schema_exports.Struct({
@@ -69,7 +71,8 @@ var OpenapiErrorResponse = Schema_exports.Struct({
69
71
  });
70
72
  var OpenapiParameter = Schema_exports.Struct({
71
73
  name: Schema_exports.String,
72
- in: Schema_exports.Literals(["path", "query", "header", "cookie"]),
74
+ /** OpenAPI 3.2's `querystring` is the whole query string, serialized from one `content` value. */
75
+ in: Schema_exports.Literals(["path", "query", "querystring", "header", "cookie"]),
73
76
  required: Schema_exports.optionalKey(Schema_exports.Boolean),
74
77
  schema: Schema_exports.optionalKey(JsonObject),
75
78
  style: Schema_exports.optionalKey(Schema_exports.String),
@@ -94,7 +97,7 @@ var OpenapiOperation = Schema_exports.Struct({
94
97
  /** The document's operationId, when it declares one. `kinds` overrides are keyed by it. */
95
98
  operationId: Schema_exports.optionalKey(Schema_exports.String),
96
99
  description: Schema_exports.String,
97
- method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
100
+ method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "QUERY"]),
98
101
  path: Schema_exports.String,
99
102
  baseUrl: HttpUrl,
100
103
  openapi: Schema_exports.String,
@@ -114,6 +117,7 @@ var OpenapiOperation = Schema_exports.Struct({
114
117
  outputSchema: Schema_exports.optionalKey(JsonObject),
115
118
  errorResponses: Schema_exports.optionalKey(Schema_exports.Array(OpenapiErrorResponse))
116
119
  });
120
+ var isOpenapiReadMethod = (method) => method === "GET" || method === "HEAD" || method === "OPTIONS" || method === "QUERY";
117
121
  var CredentialBinding = Schema_exports.Struct({
118
122
  scheme: Schema_exports.String,
119
123
  field: Schema_exports.String,
@@ -155,7 +159,8 @@ var defaultOpenapiResponseLimits = {
155
159
  maxBodyBytes: 16777216,
156
160
  readTimeoutMs: 3e4
157
161
  };
158
- var isOpenapiTextMedia = (type) => /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-ndjson|x-www-form-urlencoded))/i.test(
162
+ var isOpenapiJsonSequence = (type) => /^application\/(?:x-)?(?:ndjson|jsonl|jsonlines|json-seq)\s*(?:;|$)/i.test(type);
163
+ var isOpenapiTextMedia = (type) => isOpenapiJsonSequence(type) || /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-www-form-urlencoded))/i.test(
159
164
  type
160
165
  );
161
166
  var isOpenapiFileSchema = (shape) => shape.contentMediaType !== void 0 && shape.contentEncoding === void 0 || shape.type === "string" && shape.format === "binary";
@@ -168,7 +173,84 @@ var openapiBinaryResultSchema = {
168
173
  required: ["base64", "contentType"],
169
174
  additionalProperties: false
170
175
  };
171
- var openapiMediaKind = (type) => type.includes("json") && !type.includes("ndjson") ? "json" : type === "application/x-www-form-urlencoded" ? "form" : type === "multipart/form-data" ? "multipart" : isOpenapiTextMedia(type) ? "text" : "binary";
176
+ var openapiMediaKind = (type) => type.includes("json") && !isOpenapiJsonSequence(type) ? "json" : type === "application/x-www-form-urlencoded" ? "form" : type === "multipart/form-data" ? "multipart" : isOpenapiTextMedia(type) ? "text" : "binary";
177
+
178
+ // src/contracts/openapi-compile.ts
179
+ var OpenapiCompileErrorCode = Schema_exports.Literals([
180
+ "server_protocol",
181
+ "server_url",
182
+ "external_reference",
183
+ "circular_reference",
184
+ "schema_keyword",
185
+ "schema_reference",
186
+ "missing_component",
187
+ "openapi_version",
188
+ "auth_helper",
189
+ "auth_missing",
190
+ "operation_path",
191
+ "operation_method",
192
+ "duplicate_operation",
193
+ "server_missing",
194
+ "multiple_hosts",
195
+ "parameter_encoding",
196
+ "parameter_style",
197
+ "request_body",
198
+ "combined_oauth",
199
+ "auth_method",
200
+ "event_stream",
201
+ "input_schema",
202
+ "no_operations",
203
+ "no_supported_operations",
204
+ "invalid_document",
205
+ "source_generation",
206
+ "authoring_reference"
207
+ ]);
208
+ var OpenapiSkippedOperation = Schema_exports.Struct({
209
+ /** The tool name the operation would have; reading that tool reports why it is missing. */
210
+ name: Schema_exports.String,
211
+ /** The HTTP method, such as `GET`. */
212
+ method: Schema_exports.String,
213
+ /** The path as the definition declares it. */
214
+ path: Schema_exports.String,
215
+ code: OpenapiCompileErrorCode,
216
+ reason: Schema_exports.String
217
+ });
218
+ var listedReasons = 8;
219
+ var reasonLength = 240;
220
+ var cut = (text) => text.length <= reasonLength ? text : `${text.slice(0, reasonLength - 1)}\u2026`;
221
+ var compileMessage = (error) => {
222
+ const skipped = error.skipped ?? [];
223
+ if (skipped.length === 0) return error.reason;
224
+ const groups = /* @__PURE__ */ new Map();
225
+ for (const operation of skipped) {
226
+ const key = JSON.stringify([operation.code, operation.reason]);
227
+ const group = groups.get(key);
228
+ if (group === void 0) groups.set(key, { first: operation, count: 1 });
229
+ else group.count++;
230
+ }
231
+ const example = ({ first, count }) => `${first.method} ${first.path}${count > 1 ? ` and ${count - 1} more` : ""}`;
232
+ const [only, ...others] = groups.values();
233
+ if (only !== void 0 && others.length === 0 && only.first.code === error.code && only.first.reason === error.reason)
234
+ return `${error.reason} Left out: ${example(only)}.`;
235
+ const listed = [...groups.values()].slice(0, listedReasons);
236
+ const rest = groups.size - listed.length;
237
+ return `${error.reason} Left out: ${listed.map(
238
+ (group) => `${example(group)} (${group.first.code}: ${cut(group.first.reason.replace(/\.$/, ""))})`
239
+ ).join("; ")}${rest > 0 ? `; and ${rest} other reasons` : ""}.`;
240
+ };
241
+ var OpenapiCompileError = class extends Schema_exports.TaggedError()(
242
+ "OpenapiCompileError",
243
+ {
244
+ code: OpenapiCompileErrorCode,
245
+ reason: Schema_exports.String,
246
+ skipped: Schema_exports.optionalKey(Schema_exports.Array(OpenapiSkippedOperation)),
247
+ origins: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
248
+ }
249
+ ) {
250
+ get message() {
251
+ return compileMessage(this);
252
+ }
253
+ };
172
254
 
173
255
  // src/implementation/failure-detail.ts
174
256
  var storageMessages = {
@@ -192,6 +274,32 @@ var cacheMessages = {
192
274
  storage: "The app cache failed to complete the operation.",
193
275
  timeout: "The app cache did not respond in time."
194
276
  };
277
+ var mcpStages = {
278
+ connect: "connecting",
279
+ transport: "connecting",
280
+ discover: "listing its tools",
281
+ schema: "reading a tool's schema",
282
+ call: "calling a tool"
283
+ };
284
+ var mcpMessage = ({ phase, reason, status }) => {
285
+ const stage = mcpStages[phase];
286
+ return Match_exports.value(reason).pipe(
287
+ Match_exports.when("timeout", () => `The MCP server did not respond in time while ${stage}.`),
288
+ Match_exports.when("unauthorized", () => `The MCP server rejected the credentials while ${stage}.`),
289
+ Match_exports.when(
290
+ "invalid_response",
291
+ () => `The MCP server returned a response Executor could not use while ${stage}, such as an unreadable message or an address on another origin.`
292
+ ),
293
+ Match_exports.when("invalid_input", () => "The MCP server URL or connection settings are invalid."),
294
+ // Only a transport failure has no answer from the server; a JSON-RPC error is an answer.
295
+ Match_exports.when(
296
+ "request",
297
+ () => status !== void 0 ? `The MCP server answered HTTP ${status} while ${stage}.` : phase === "transport" ? `Executor could not reach the MCP server while ${stage}.` : `The request to the MCP server failed while ${stage}.`
298
+ ),
299
+ Match_exports.exhaustive
300
+ );
301
+ };
302
+ var unverifiedMessage = ({ anonymous }) => anonymous === "answered" ? "This MCP server answers without credentials, so Executor can't check this account. A refused key will show up when a tool is called." : `The MCP server accepted the credentials, but the same check without them failed, so Executor can't tell whether it requires them. ${Schema_exports.is(McpError)(anonymous) ? mcpMessage(anonymous) : anonymous.status === void 0 ? "The MCP server could not answer the request." : `The MCP server answered HTTP ${anonymous.status}.`}`;
195
303
  var minimumSecretLength = 6;
196
304
  var secretValues = (value, found) => {
197
305
  if (typeof value === "string") {
@@ -308,6 +416,27 @@ var failureDetail = (error, secrets) => {
308
416
  code: error.reason,
309
417
  message: error.reason === "request" ? error.status === void 0 ? "The API request failed before a response arrived." : `The API responded with HTTP ${error.status}, which its OpenAPI document does not declare as an error with a message.` : error.reason === "invalid_input" ? "The input could not be encoded as a request for this API operation." : "The API's OpenAPI definition for this operation is invalid."
310
418
  };
419
+ if (Schema_exports.is(McpError)(error))
420
+ return {
421
+ source: "service",
422
+ errorName: "McpError",
423
+ code: error.reason,
424
+ message: mcpMessage(error)
425
+ };
426
+ if (Schema_exports.is(McpCredentialsUnverified)(error))
427
+ return {
428
+ source: "service",
429
+ errorName: "McpCredentialsUnverified",
430
+ code: error.anonymous === "answered" ? "anonymous_access" : error.anonymous.reason,
431
+ message: unverifiedMessage(error)
432
+ };
433
+ if (Schema_exports.is(OpenapiCompileError)(error))
434
+ return {
435
+ source: "app",
436
+ errorName: "OpenapiCompileError",
437
+ code: error.code,
438
+ message: boundFailureMessage(error.message, secrets)
439
+ };
311
440
  if (error instanceof Error) {
312
441
  const code = ownCode(error, secrets);
313
442
  const fields = ownFields(error, code, secrets);
@@ -567,13 +696,18 @@ export {
567
696
  OpenapiParameter,
568
697
  OpenapiRequestBody,
569
698
  OpenapiOperation,
699
+ isOpenapiReadMethod,
570
700
  OpenapiToolsOptions,
571
701
  OpenapiError,
572
702
  defaultOpenapiResponseLimits,
703
+ isOpenapiJsonSequence,
573
704
  isOpenapiTextMedia,
574
705
  isOpenapiFileSchema,
575
706
  openapiBinaryResultSchema,
576
707
  openapiMediaKind,
708
+ OpenapiCompileErrorCode,
709
+ OpenapiSkippedOperation,
710
+ OpenapiCompileError,
577
711
  accountSecrets,
578
712
  boundFailureMessage,
579
713
  leavingProviderError,
@@ -2,7 +2,7 @@ import {
2
2
  DatabaseFieldReserved,
3
3
  DatabaseLimitExceeded,
4
4
  DatabaseSchema
5
- } from "./chunk-GH6PY5BQ.js";
5
+ } from "./chunk-M2KEEOIQ.js";
6
6
  import {
7
7
  CacheCommand,
8
8
  CacheReply,
@@ -13,18 +13,18 @@ import {
13
13
  FailureSource,
14
14
  ProviderError,
15
15
  UpstreamError
16
- } from "./chunk-T7WRQJUF.js";
16
+ } from "./chunk-BRGF7VFN.js";
17
17
  import {
18
18
  AppSkillName,
19
19
  AppSkills,
20
20
  SkillLoadFailed
21
- } from "./chunk-TACLXEAE.js";
21
+ } from "./chunk-NSBRV4FJ.js";
22
22
  import {
23
23
  AccountId,
24
24
  HttpUrl,
25
25
  JsonObject as JsonObject2,
26
26
  JsonValue
27
- } from "./chunk-KKGRSXUK.js";
27
+ } from "./chunk-PWF2DRJ3.js";
28
28
  import {
29
29
  Any,
30
30
  ArraySchema,
@@ -78,7 +78,7 @@ import {
78
78
  transformOptional,
79
79
  withConstructorDefault,
80
80
  withDefault
81
- } from "./chunk-DM5U7G7V.js";
81
+ } from "./chunk-NXTXZ635.js";
82
82
 
83
83
  // src/contracts/router.ts
84
84
  var reservedRouterKeys = /* @__PURE__ */ new Set([
@@ -141,6 +141,12 @@ var McpToolsOptions = Schema_exports.Struct({
141
141
  )
142
142
  )
143
143
  });
144
+ var McpHealthInput = Schema_exports.Struct({
145
+ ...McpToolsOptions.fields,
146
+ headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
147
+ deadline: Schema_exports.optional(Schema_exports.Finite)
148
+ });
149
+ var mcpHealthReserveMs = 2 * defaultMcpClientLimits.cleanupTimeoutMs + 250;
144
150
  var McpToolResult = Schema_exports.Struct({
145
151
  content: Schema_exports.Array(JsonObject2),
146
152
  structuredContent: Schema_exports.optionalKey(JsonObject2),
@@ -178,6 +184,11 @@ var McpError = class extends Schema_exports.TaggedError()("McpError", {
178
184
  upstream: Schema_exports.optional(UpstreamError)
179
185
  }) {
180
186
  };
187
+ var McpCredentialsUnverified = class extends Schema_exports.TaggedError()(
188
+ "McpCredentialsUnverified",
189
+ { anonymous: Schema_exports.Union([Schema_exports.Literal("answered"), McpError, ProviderError]) }
190
+ ) {
191
+ };
181
192
  var ProcessConfig = Schema_exports.Struct({
182
193
  command: Schema_exports.NonEmptyString,
183
194
  args: Schema_exports.Array(Schema_exports.String),
@@ -2945,10 +2956,13 @@ export {
2945
2956
  defaultMcpClientLimits,
2946
2957
  mcpSdkTimerCeilingMs,
2947
2958
  McpToolsOptions,
2959
+ McpHealthInput,
2960
+ mcpHealthReserveMs,
2948
2961
  McpToolResult,
2949
2962
  McpToolMetadata,
2950
2963
  McpServerHeader,
2951
2964
  McpError,
2965
+ McpCredentialsUnverified,
2952
2966
  ProcessConfig,
2953
2967
  maxApiErrorInstructionsLength,
2954
2968
  ApiErrorRecovery,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  prepareElicitation
3
- } from "./chunk-VWU6I23D.js";
3
+ } from "./chunk-3TEX4ZND.js";
4
4
  import {
5
5
  fromPromise
6
- } from "./chunk-WPKXOTKM.js";
6
+ } from "./chunk-TX2XCAL6.js";
7
7
  import {
8
8
  bodyUpstreamError
9
- } from "./chunk-DAIW2WM3.js";
9
+ } from "./chunk-KQCMHI3K.js";
10
10
  import {
11
11
  ElicitationFailed,
12
12
  McpError,
@@ -18,15 +18,15 @@ import {
18
18
  defaultElicitationLimits,
19
19
  defaultMcpClientLimits,
20
20
  mcpSdkTimerCeilingMs
21
- } from "./chunk-VGEPL4BV.js";
21
+ } from "./chunk-7R5JY5H7.js";
22
22
  import {
23
23
  jsonSchemaDecoder,
24
24
  nestJsonSchema,
25
25
  preparedJsonSchemaDecoder
26
- } from "./chunk-IE6W5RNN.js";
26
+ } from "./chunk-YML53Z7H.js";
27
27
  import {
28
28
  JsonObject
29
- } from "./chunk-KKGRSXUK.js";
29
+ } from "./chunk-PWF2DRJ3.js";
30
30
  import {
31
31
  Clock_exports,
32
32
  Deferred_exports,
@@ -35,7 +35,7 @@ import {
35
35
  Option_exports,
36
36
  Queue_exports,
37
37
  Schema_exports
38
- } from "./chunk-DM5U7G7V.js";
38
+ } from "./chunk-NXTXZ635.js";
39
39
 
40
40
  // src/implementation/mcp-tools.ts
41
41
  var resultFields = {
@@ -353,10 +353,26 @@ function mcpClient(withClient, timeoutMs, failure) {
353
353
  };
354
354
  })
355
355
  ).pipe(Effect_exports.withSpan("provider.mcp.discover"));
356
+ const check = withClient(
357
+ "discover",
358
+ (client) => Effect_exports.tryPromise({
359
+ try: (signal) => client.request({ method: "tools/list", params: {} }, ListToolsResultSchema, {
360
+ signal,
361
+ timeout: timeoutMs
362
+ }),
363
+ catch: (error) => failure("discover", error)
364
+ }).pipe(
365
+ Effect_exports.asVoid,
366
+ Effect_exports.withSpan("provider.mcp.request", {
367
+ kind: "client",
368
+ attributes: { "rpc.system.name": "jsonrpc", "rpc.method": "tools/list" }
369
+ })
370
+ )
371
+ ).pipe(Effect_exports.withSpan("provider.mcp.check"));
356
372
  const call = (name, input, context) => withClient("call", (client) => mcpCall(client, name, input, context, timeoutMs, failure)).pipe(
357
373
  Effect_exports.withSpan("provider.mcp.call", { attributes: { "mcp.tool.name": name } })
358
374
  );
359
- return { list, call };
375
+ return { list, check, call };
360
376
  }
361
377
 
362
378
  export {
@@ -211,7 +211,7 @@ import {
211
211
  withFiber,
212
212
  withParentSpan,
213
213
  zero2 as zero
214
- } from "./chunk-DM5U7G7V.js";
214
+ } from "./chunk-NXTXZ635.js";
215
215
  import {
216
216
  __export
217
217
  } from "./chunk-CZ7CSFO4.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  AccountId
3
- } from "./chunk-KKGRSXUK.js";
3
+ } from "./chunk-PWF2DRJ3.js";
4
4
  import {
5
5
  Schema_exports
6
- } from "./chunk-DM5U7G7V.js";
6
+ } from "./chunk-NXTXZ635.js";
7
7
 
8
8
  // src/contracts/failure.ts
9
9
  var maxFailureMessageLength = 2048;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-DM5U7G7V.js";
3
+ } from "./chunk-NXTXZ635.js";
4
4
 
5
5
  // src/contracts/storage.ts
6
6
  var StorageName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));