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.
- package/framework-reference.json +1 -1
- package/js/{chunk-IJX4CYZO.js → chunk-2TP7C25K.js} +3 -3
- package/js/{chunk-KUMBKVJD.js → chunk-3YN4UDPB.js} +2 -2
- package/js/{chunk-B3T7CZOH.js → chunk-4CMJD7AB.js} +29 -7
- package/js/{chunk-M3B3DE4K.js → chunk-AAAMPT6F.js} +2 -2
- package/js/{chunk-3HH4OZR3.js → chunk-BTRBOOTD.js} +23 -25
- package/js/chunk-DAIW2WM3.js +118 -0
- package/js/{chunk-CDL5PM2Q.js → chunk-DM5U7G7V.js} +124 -124
- package/js/{chunk-ODEIDRGW.js → chunk-DUEZ2XCO.js} +3 -3
- package/js/{chunk-WFEUCUFF.js → chunk-EXDR4HVM.js} +184 -30
- package/js/{chunk-N7YDVXYJ.js → chunk-GH6PY5BQ.js} +1 -1
- package/js/{chunk-K2QATKIF.js → chunk-HIYRKEWP.js} +77 -22
- package/js/{chunk-PZB6T6KU.js → chunk-HQKIPKM5.js} +1 -1
- package/js/{chunk-66JAEDTE.js → chunk-IE6W5RNN.js} +2 -2
- package/js/{chunk-27F7W2LG.js → chunk-KKGRSXUK.js} +1 -1
- package/js/{chunk-57RKNWL2.js → chunk-KNJAOYV4.js} +2 -2
- package/js/{chunk-ZQINWV4W.js → chunk-LPN4ONWW.js} +2 -2
- package/js/{chunk-A5BSZKFF.js → chunk-NXO2GN2T.js} +8 -8
- package/js/{chunk-UK573G7W.js → chunk-OBXHLFGQ.js} +1 -1
- package/js/{chunk-JWNSH5CA.js → chunk-OI7OI2U3.js} +2 -2
- package/js/{chunk-IPI4MFSN.js → chunk-PC5RHPUP.js} +2 -2
- package/js/{chunk-VFZKSM3T.js → chunk-SUY33XAY.js} +1 -1
- package/js/{chunk-R3EV5FTO.js → chunk-T7WRQJUF.js} +55 -3
- package/js/{chunk-JU7VHODU.js → chunk-TACLXEAE.js} +1 -1
- package/js/{chunk-2KZ7GG43.js → chunk-VGEPL4BV.js} +146 -53
- package/js/{chunk-S47NFEWF.js → chunk-WPKXOTKM.js} +3 -3
- package/js/{chunk-PJJ24GU7.js → chunk-XBG3M64K.js} +1 -1
- package/js/{chunk-AK54RD3A.js → chunk-XIRAIB3P.js} +4 -4
- package/js/{chunk-NKLWZJLE.js → chunk-ZVMZWXVF.js} +2 -2
- package/js/client.js +10 -10
- package/js/contracts.js +36 -14
- package/js/effect.js +19 -19
- package/js/graphql.js +21 -21
- package/js/host.js +19 -19
- package/js/index.js +12 -12
- package/js/mcp/effect.js +21 -21
- package/js/mcp/stdio.js +30 -25
- package/js/mcp.js +23 -23
- package/js/openapi.js +595 -200
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -3
- package/js/skills.js +11 -11
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +8 -8
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/host.d.ts +5 -4
- package/types/apps/src/contracts/mcp.d.ts +8 -1
- package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
- package/types/apps/src/contracts/openapi.d.ts +16 -6
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +16 -2
- package/types/apps/src/contracts/protocols/2.d.ts +1 -1
- package/types/apps/src/contracts/protocols/3.d.ts +1 -3
- package/types/apps/src/contracts/protocols/4.d.ts +1 -2
- package/types/apps/src/contracts/protocols/5.d.ts +3 -3
- package/types/apps/src/contracts/protocols/6.d.ts +3 -3
- package/types/apps/src/contracts/protocols/7.d.ts +3 -3
- package/types/apps/src/contracts/protocols/8.d.ts +1119 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/implementation/failure-detail.d.ts +22 -3
- package/types/apps/src/implementation/mcp-client.d.ts +6 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +12 -2
- package/types/apps/src/implementation/openapi-document.d.ts +20 -6
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-source.d.ts +6 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/router-catalog.d.ts +2 -3
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/telemetry/src/config.d.ts +2 -2
- package/js/chunk-MKWZPDR6.js +0 -63
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
skillFromFiles
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PC5RHPUP.js";
|
|
4
4
|
import {
|
|
5
5
|
joinPath,
|
|
6
6
|
mergeMeta
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WPKXOTKM.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
isShortenedUpstream,
|
|
10
|
+
parseProviderError,
|
|
11
|
+
providerError
|
|
12
|
+
} from "./chunk-DAIW2WM3.js";
|
|
11
13
|
import {
|
|
12
14
|
ApiErrorResponse,
|
|
13
15
|
HostDeclarationInvalid,
|
|
@@ -15,31 +17,36 @@ import {
|
|
|
15
17
|
HostedRouter,
|
|
16
18
|
HostedTool,
|
|
17
19
|
HostedToolSummary,
|
|
18
|
-
McpError
|
|
19
|
-
|
|
20
|
-
} from "./chunk-2KZ7GG43.js";
|
|
20
|
+
McpError
|
|
21
|
+
} from "./chunk-VGEPL4BV.js";
|
|
21
22
|
import {
|
|
22
23
|
AppDatabaseError
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-GH6PY5BQ.js";
|
|
24
25
|
import {
|
|
25
|
-
CacheError
|
|
26
|
-
|
|
26
|
+
CacheError,
|
|
27
|
+
FailureCode,
|
|
28
|
+
FailureFieldName,
|
|
29
|
+
maxFailureFieldLength,
|
|
30
|
+
maxFailureFields,
|
|
31
|
+
maxFailureMessageLength,
|
|
32
|
+
maxUpstreamMessageLength
|
|
33
|
+
} from "./chunk-T7WRQJUF.js";
|
|
27
34
|
import {
|
|
28
35
|
SkillLoadFailed,
|
|
29
36
|
skillFormatLimits
|
|
30
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-TACLXEAE.js";
|
|
31
38
|
import {
|
|
32
39
|
jsonSchemaDocument
|
|
33
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-IE6W5RNN.js";
|
|
34
41
|
import {
|
|
35
42
|
AppStorageError,
|
|
36
43
|
AppStorageUnavailable
|
|
37
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-HQKIPKM5.js";
|
|
38
45
|
import {
|
|
39
46
|
AccountId,
|
|
40
47
|
HttpUrl,
|
|
41
48
|
JsonObject
|
|
42
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-KKGRSXUK.js";
|
|
43
50
|
import {
|
|
44
51
|
Cause_exports,
|
|
45
52
|
Effect_exports,
|
|
@@ -48,7 +55,7 @@ import {
|
|
|
48
55
|
Redacted_exports,
|
|
49
56
|
Result_exports,
|
|
50
57
|
Schema_exports
|
|
51
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-DM5U7G7V.js";
|
|
52
59
|
|
|
53
60
|
// src/contracts/openapi.ts
|
|
54
61
|
var OpenapiErrorResponse = Schema_exports.Struct({
|
|
@@ -62,7 +69,8 @@ var OpenapiErrorResponse = Schema_exports.Struct({
|
|
|
62
69
|
});
|
|
63
70
|
var OpenapiParameter = Schema_exports.Struct({
|
|
64
71
|
name: Schema_exports.String,
|
|
65
|
-
|
|
72
|
+
/** OpenAPI 3.2's `querystring` is the whole query string, serialized from one `content` value. */
|
|
73
|
+
in: Schema_exports.Literals(["path", "query", "querystring", "header", "cookie"]),
|
|
66
74
|
required: Schema_exports.optionalKey(Schema_exports.Boolean),
|
|
67
75
|
schema: Schema_exports.optionalKey(JsonObject),
|
|
68
76
|
style: Schema_exports.optionalKey(Schema_exports.String),
|
|
@@ -87,7 +95,7 @@ var OpenapiOperation = Schema_exports.Struct({
|
|
|
87
95
|
/** The document's operationId, when it declares one. `kinds` overrides are keyed by it. */
|
|
88
96
|
operationId: Schema_exports.optionalKey(Schema_exports.String),
|
|
89
97
|
description: Schema_exports.String,
|
|
90
|
-
method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
|
|
98
|
+
method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "QUERY"]),
|
|
91
99
|
path: Schema_exports.String,
|
|
92
100
|
baseUrl: HttpUrl,
|
|
93
101
|
openapi: Schema_exports.String,
|
|
@@ -107,6 +115,7 @@ var OpenapiOperation = Schema_exports.Struct({
|
|
|
107
115
|
outputSchema: Schema_exports.optionalKey(JsonObject),
|
|
108
116
|
errorResponses: Schema_exports.optionalKey(Schema_exports.Array(OpenapiErrorResponse))
|
|
109
117
|
});
|
|
118
|
+
var isOpenapiReadMethod = (method) => method === "GET" || method === "HEAD" || method === "OPTIONS" || method === "QUERY";
|
|
110
119
|
var CredentialBinding = Schema_exports.Struct({
|
|
111
120
|
scheme: Schema_exports.String,
|
|
112
121
|
field: Schema_exports.String,
|
|
@@ -148,7 +157,8 @@ var defaultOpenapiResponseLimits = {
|
|
|
148
157
|
maxBodyBytes: 16777216,
|
|
149
158
|
readTimeoutMs: 3e4
|
|
150
159
|
};
|
|
151
|
-
var
|
|
160
|
+
var isOpenapiJsonSequence = (type) => /^application\/(?:x-)?(?:ndjson|jsonl|jsonlines|json-seq)\s*(?:;|$)/i.test(type);
|
|
161
|
+
var isOpenapiTextMedia = (type) => isOpenapiJsonSequence(type) || /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-www-form-urlencoded))/i.test(
|
|
152
162
|
type
|
|
153
163
|
);
|
|
154
164
|
var isOpenapiFileSchema = (shape) => shape.contentMediaType !== void 0 && shape.contentEncoding === void 0 || shape.type === "string" && shape.format === "binary";
|
|
@@ -161,7 +171,84 @@ var openapiBinaryResultSchema = {
|
|
|
161
171
|
required: ["base64", "contentType"],
|
|
162
172
|
additionalProperties: false
|
|
163
173
|
};
|
|
164
|
-
var openapiMediaKind = (type) => type.includes("json") && !type
|
|
174
|
+
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";
|
|
175
|
+
|
|
176
|
+
// src/contracts/openapi-compile.ts
|
|
177
|
+
var OpenapiCompileErrorCode = Schema_exports.Literals([
|
|
178
|
+
"server_protocol",
|
|
179
|
+
"server_url",
|
|
180
|
+
"external_reference",
|
|
181
|
+
"circular_reference",
|
|
182
|
+
"schema_keyword",
|
|
183
|
+
"schema_reference",
|
|
184
|
+
"missing_component",
|
|
185
|
+
"openapi_version",
|
|
186
|
+
"auth_helper",
|
|
187
|
+
"auth_missing",
|
|
188
|
+
"operation_path",
|
|
189
|
+
"operation_method",
|
|
190
|
+
"duplicate_operation",
|
|
191
|
+
"server_missing",
|
|
192
|
+
"multiple_hosts",
|
|
193
|
+
"parameter_encoding",
|
|
194
|
+
"parameter_style",
|
|
195
|
+
"request_body",
|
|
196
|
+
"combined_oauth",
|
|
197
|
+
"auth_method",
|
|
198
|
+
"event_stream",
|
|
199
|
+
"input_schema",
|
|
200
|
+
"no_operations",
|
|
201
|
+
"no_supported_operations",
|
|
202
|
+
"invalid_document",
|
|
203
|
+
"source_generation",
|
|
204
|
+
"authoring_reference"
|
|
205
|
+
]);
|
|
206
|
+
var OpenapiSkippedOperation = Schema_exports.Struct({
|
|
207
|
+
/** The tool name the operation would have; reading that tool reports why it is missing. */
|
|
208
|
+
name: Schema_exports.String,
|
|
209
|
+
/** The HTTP method, such as `GET`. */
|
|
210
|
+
method: Schema_exports.String,
|
|
211
|
+
/** The path as the definition declares it. */
|
|
212
|
+
path: Schema_exports.String,
|
|
213
|
+
code: OpenapiCompileErrorCode,
|
|
214
|
+
reason: Schema_exports.String
|
|
215
|
+
});
|
|
216
|
+
var listedReasons = 8;
|
|
217
|
+
var reasonLength = 240;
|
|
218
|
+
var cut = (text) => text.length <= reasonLength ? text : `${text.slice(0, reasonLength - 1)}\u2026`;
|
|
219
|
+
var compileMessage = (error) => {
|
|
220
|
+
const skipped = error.skipped ?? [];
|
|
221
|
+
if (skipped.length === 0) return error.reason;
|
|
222
|
+
const groups = /* @__PURE__ */ new Map();
|
|
223
|
+
for (const operation of skipped) {
|
|
224
|
+
const key = JSON.stringify([operation.code, operation.reason]);
|
|
225
|
+
const group = groups.get(key);
|
|
226
|
+
if (group === void 0) groups.set(key, { first: operation, count: 1 });
|
|
227
|
+
else group.count++;
|
|
228
|
+
}
|
|
229
|
+
const example = ({ first, count }) => `${first.method} ${first.path}${count > 1 ? ` and ${count - 1} more` : ""}`;
|
|
230
|
+
const [only, ...others] = groups.values();
|
|
231
|
+
if (only !== void 0 && others.length === 0 && only.first.code === error.code && only.first.reason === error.reason)
|
|
232
|
+
return `${error.reason} Left out: ${example(only)}.`;
|
|
233
|
+
const listed = [...groups.values()].slice(0, listedReasons);
|
|
234
|
+
const rest = groups.size - listed.length;
|
|
235
|
+
return `${error.reason} Left out: ${listed.map(
|
|
236
|
+
(group) => `${example(group)} (${group.first.code}: ${cut(group.first.reason.replace(/\.$/, ""))})`
|
|
237
|
+
).join("; ")}${rest > 0 ? `; and ${rest} other reasons` : ""}.`;
|
|
238
|
+
};
|
|
239
|
+
var OpenapiCompileError = class extends Schema_exports.TaggedError()(
|
|
240
|
+
"OpenapiCompileError",
|
|
241
|
+
{
|
|
242
|
+
code: OpenapiCompileErrorCode,
|
|
243
|
+
reason: Schema_exports.String,
|
|
244
|
+
skipped: Schema_exports.optionalKey(Schema_exports.Array(OpenapiSkippedOperation)),
|
|
245
|
+
origins: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
|
|
246
|
+
}
|
|
247
|
+
) {
|
|
248
|
+
get message() {
|
|
249
|
+
return compileMessage(this);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
165
252
|
|
|
166
253
|
// src/implementation/failure-detail.ts
|
|
167
254
|
var storageMessages = {
|
|
@@ -204,12 +291,63 @@ var accountFieldSecrets = (accounts) => {
|
|
|
204
291
|
return [...found].sort((a, b) => b.length - a.length);
|
|
205
292
|
};
|
|
206
293
|
var accountSecrets = (accounts) => accountFieldSecrets(Redacted_exports.value(accounts));
|
|
207
|
-
var
|
|
208
|
-
let redacted =
|
|
294
|
+
var replaceSecrets = (text, secrets) => {
|
|
295
|
+
let redacted = text;
|
|
209
296
|
for (const secret of secrets) redacted = redacted.split(secret).join("[redacted]");
|
|
210
|
-
return redacted
|
|
297
|
+
return redacted;
|
|
298
|
+
};
|
|
299
|
+
var bound = (text, maximum) => text.length <= maximum ? text : `${text.slice(0, maximum - 1)}\u2026`;
|
|
300
|
+
var boundText = (text, secrets, maximum) => bound(replaceSecrets(text, secrets), maximum);
|
|
301
|
+
var replaceSecretStart = (text, secrets) => {
|
|
302
|
+
let longest = 0;
|
|
303
|
+
for (const secret of secrets)
|
|
304
|
+
for (let length = Math.min(secret.length - 1, text.length); length > longest; length--)
|
|
305
|
+
if (text.endsWith(secret.slice(0, length))) {
|
|
306
|
+
longest = length;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
return longest === 0 ? text : `${text.slice(0, -longest)}[redacted]`;
|
|
310
|
+
};
|
|
311
|
+
var boundFailureMessage = (message, secrets) => boundText(message, secrets, maxFailureMessageLength);
|
|
312
|
+
var redactUpstream = (upstream, secrets) => {
|
|
313
|
+
if (upstream?.message === void 0) return upstream;
|
|
314
|
+
const message = isShortenedUpstream(upstream.message) ? `${replaceSecretStart(replaceSecrets(upstream.message.slice(0, -1), secrets), secrets)}\u2026` : replaceSecrets(upstream.message, secrets);
|
|
315
|
+
return { code: upstream.code, message: bound(message, maxUpstreamMessageLength) };
|
|
211
316
|
};
|
|
317
|
+
var leavingProviderError = (error, secrets, phase) => providerError({
|
|
318
|
+
...error,
|
|
319
|
+
phase: error.phase ?? phase,
|
|
320
|
+
upstream: redactUpstream(error.upstream, secrets)
|
|
321
|
+
});
|
|
322
|
+
var parseMcpError = (error, secrets) => Schema_exports.decodeUnknownOption(McpError)(error).pipe(
|
|
323
|
+
Option_exports.map(({ phase, reason, status, upstream }) => {
|
|
324
|
+
const stated = redactUpstream(upstream, secrets);
|
|
325
|
+
return new McpError({
|
|
326
|
+
phase,
|
|
327
|
+
reason,
|
|
328
|
+
...status === void 0 ? {} : { status },
|
|
329
|
+
...stated === void 0 ? {} : { upstream: stated }
|
|
330
|
+
});
|
|
331
|
+
})
|
|
332
|
+
);
|
|
212
333
|
var errorName = (error) => (error.name.length > 0 ? error.name : "Error").slice(0, 128);
|
|
334
|
+
var ownCode = (error, secrets) => Predicate_exports.hasProperty(error, "code") && Schema_exports.is(FailureCode)(error.code) && error.code !== "" ? boundText(error.code, secrets, 128) : void 0;
|
|
335
|
+
var reservedFields = /* @__PURE__ */ new Set(["name", "message", "stack", "cause", "_tag"]);
|
|
336
|
+
var ownFields = (error, code, secrets) => {
|
|
337
|
+
const fields = {};
|
|
338
|
+
let count = 0;
|
|
339
|
+
for (const [key, value] of Object.entries(error)) {
|
|
340
|
+
if (count === maxFailureFields) break;
|
|
341
|
+
if (reservedFields.has(key) || key === "code" && code !== void 0) continue;
|
|
342
|
+
if (!Schema_exports.is(FailureFieldName)(key)) continue;
|
|
343
|
+
if (typeof value === "string") fields[key] = boundText(value, secrets, maxFailureFieldLength);
|
|
344
|
+
else if (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))
|
|
345
|
+
fields[key] = value;
|
|
346
|
+
else continue;
|
|
347
|
+
count++;
|
|
348
|
+
}
|
|
349
|
+
return count === 0 ? void 0 : fields;
|
|
350
|
+
};
|
|
213
351
|
var ownMessage = (error) => {
|
|
214
352
|
const cause = error.cause;
|
|
215
353
|
const suffix = cause instanceof Error && cause.message.length > 0 ? ` (caused by ${errorName(cause)}: ${cause.message})` : "";
|
|
@@ -250,15 +388,27 @@ var failureDetail = (error, secrets) => {
|
|
|
250
388
|
code: error.reason,
|
|
251
389
|
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."
|
|
252
390
|
};
|
|
253
|
-
if (error
|
|
391
|
+
if (Schema_exports.is(OpenapiCompileError)(error))
|
|
392
|
+
return {
|
|
393
|
+
source: "app",
|
|
394
|
+
errorName: "OpenapiCompileError",
|
|
395
|
+
code: error.code,
|
|
396
|
+
message: boundFailureMessage(error.message, secrets)
|
|
397
|
+
};
|
|
398
|
+
if (error instanceof Error) {
|
|
399
|
+
const code = ownCode(error, secrets);
|
|
400
|
+
const fields = ownFields(error, code, secrets);
|
|
254
401
|
return {
|
|
255
402
|
source: "app",
|
|
256
403
|
errorName: errorName(error),
|
|
404
|
+
...code === void 0 ? {} : { code },
|
|
257
405
|
message: boundFailureMessage(
|
|
258
406
|
ownMessage(error) ?? `${errorName(error)} was thrown without a message.`,
|
|
259
407
|
secrets
|
|
260
|
-
)
|
|
408
|
+
),
|
|
409
|
+
...fields === void 0 ? {} : { fields }
|
|
261
410
|
};
|
|
411
|
+
}
|
|
262
412
|
if (typeof error === "string")
|
|
263
413
|
return { source: "app", errorName: "string", message: boundFailureMessage(error, secrets) };
|
|
264
414
|
return {
|
|
@@ -271,7 +421,7 @@ var failureDetail = (error, secrets) => {
|
|
|
271
421
|
// src/implementation/router-catalog.ts
|
|
272
422
|
var safeFailure = (error, secrets) => {
|
|
273
423
|
const provider = parseProviderError(error);
|
|
274
|
-
if (Option_exports.isSome(provider)) return provider.value;
|
|
424
|
+
if (Option_exports.isSome(provider)) return leavingProviderError(provider.value, secrets, "discover");
|
|
275
425
|
const skills = Schema_exports.decodeUnknownOption(SkillLoadFailed)(error);
|
|
276
426
|
if (Option_exports.isSome(skills)) {
|
|
277
427
|
const { reason, message, status } = skills.value;
|
|
@@ -281,11 +431,8 @@ var safeFailure = (error, secrets) => {
|
|
|
281
431
|
...status === void 0 ? {} : { status }
|
|
282
432
|
});
|
|
283
433
|
}
|
|
284
|
-
const mcp =
|
|
285
|
-
if (Option_exports.isSome(mcp))
|
|
286
|
-
const { phase, reason, status } = mcp.value;
|
|
287
|
-
return new McpError({ phase, reason, ...status === void 0 ? {} : { status } });
|
|
288
|
-
}
|
|
434
|
+
const mcp = parseMcpError(error, secrets);
|
|
435
|
+
if (Option_exports.isSome(mcp)) return mcp.value;
|
|
289
436
|
if (Schema_exports.is(HostDeclarationInvalid)(error)) return error;
|
|
290
437
|
return new HostEvaluationFailed(failureDetail(error, secrets));
|
|
291
438
|
};
|
|
@@ -507,15 +654,22 @@ export {
|
|
|
507
654
|
OpenapiParameter,
|
|
508
655
|
OpenapiRequestBody,
|
|
509
656
|
OpenapiOperation,
|
|
657
|
+
isOpenapiReadMethod,
|
|
510
658
|
OpenapiToolsOptions,
|
|
511
659
|
OpenapiError,
|
|
512
660
|
defaultOpenapiResponseLimits,
|
|
661
|
+
isOpenapiJsonSequence,
|
|
513
662
|
isOpenapiTextMedia,
|
|
514
663
|
isOpenapiFileSchema,
|
|
515
664
|
openapiBinaryResultSchema,
|
|
516
665
|
openapiMediaKind,
|
|
666
|
+
OpenapiCompileErrorCode,
|
|
667
|
+
OpenapiSkippedOperation,
|
|
668
|
+
OpenapiCompileError,
|
|
517
669
|
accountSecrets,
|
|
518
670
|
boundFailureMessage,
|
|
671
|
+
leavingProviderError,
|
|
672
|
+
parseMcpError,
|
|
519
673
|
describeFailure,
|
|
520
674
|
failureDetail,
|
|
521
675
|
operationDescription,
|
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
import {
|
|
2
2
|
adaptMcpTools,
|
|
3
|
+
answeredError,
|
|
3
4
|
mcpClient,
|
|
4
5
|
mcpJsonSchemaValidator
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4CMJD7AB.js";
|
|
6
7
|
import {
|
|
7
8
|
accountProviderError,
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
bodyUpstreamError,
|
|
10
|
+
httpProviderError,
|
|
11
|
+
providerErrorDetail
|
|
12
|
+
} from "./chunk-DAIW2WM3.js";
|
|
10
13
|
import {
|
|
11
14
|
McpError,
|
|
12
15
|
McpToolsOptions,
|
|
13
16
|
defaultMcpClientLimits
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VGEPL4BV.js";
|
|
15
18
|
import {
|
|
16
19
|
ProviderError
|
|
17
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-T7WRQJUF.js";
|
|
18
21
|
import {
|
|
19
22
|
captureTelemetry
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-DUEZ2XCO.js";
|
|
21
24
|
import {
|
|
22
25
|
FetchHttpClient_exports
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KNJAOYV4.js";
|
|
24
27
|
import {
|
|
25
28
|
HttpClientRequest_exports,
|
|
26
29
|
HttpClient_exports
|
|
27
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-OBXHLFGQ.js";
|
|
28
31
|
import {
|
|
29
32
|
Deferred_exports,
|
|
30
33
|
Effect_exports,
|
|
34
|
+
Option_exports,
|
|
31
35
|
Redacted_exports,
|
|
36
|
+
Ref_exports,
|
|
32
37
|
Schema_exports,
|
|
33
38
|
Stream_exports
|
|
34
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-DM5U7G7V.js";
|
|
35
40
|
|
|
36
41
|
// src/implementation/mcp.ts
|
|
37
42
|
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
@@ -51,13 +56,39 @@ var failure = (phase, error) => {
|
|
|
51
56
|
const status = error instanceof UnauthorizedError ? 401 : error instanceof StreamableHTTPError || error instanceof SseError ? error.code : void 0;
|
|
52
57
|
const provider = status === void 0 ? void 0 : httpProviderError(status);
|
|
53
58
|
if (provider !== void 0) return provider;
|
|
59
|
+
const upstream = answeredError(error);
|
|
54
60
|
return new McpError({
|
|
55
61
|
phase,
|
|
56
62
|
reason: error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : "request",
|
|
57
|
-
...status === void 0 ? {} : { status }
|
|
63
|
+
...status === void 0 ? {} : { status },
|
|
64
|
+
...upstream === void 0 ? {} : { upstream }
|
|
58
65
|
});
|
|
59
66
|
};
|
|
60
|
-
var
|
|
67
|
+
var errorBodyLimits = { maxBytes: 65536, readTimeoutMs: 2e3 };
|
|
68
|
+
var errorBody = (response) => Effect_exports.gen(function* () {
|
|
69
|
+
const json = /^application\/(?:[\w.-]+\+)?json$/i.test(
|
|
70
|
+
response.headers["content-type"]?.split(";")[0]?.trim() ?? ""
|
|
71
|
+
);
|
|
72
|
+
const length = response.headers["content-length"];
|
|
73
|
+
if (!json || length !== void 0 && Number(length) > errorBodyLimits.maxBytes)
|
|
74
|
+
return { body: Stream_exports.toReadableStream(response.stream), upstream: void 0 };
|
|
75
|
+
const unreadable = new McpError({ phase: "transport", reason: "invalid_response" });
|
|
76
|
+
const read = yield* response.stream.pipe(
|
|
77
|
+
Stream_exports.mapError(() => unreadable),
|
|
78
|
+
Stream_exports.limitBytes(errorBodyLimits.maxBytes, () => Stream_exports.fail(unreadable)),
|
|
79
|
+
Stream_exports.decodeText,
|
|
80
|
+
Stream_exports.mkString,
|
|
81
|
+
Effect_exports.timeout(errorBodyLimits.readTimeoutMs),
|
|
82
|
+
Effect_exports.option
|
|
83
|
+
);
|
|
84
|
+
if (Option_exports.isNone(read)) return { body: null, upstream: void 0 };
|
|
85
|
+
const parsed = Schema_exports.decodeUnknownOption(Schema_exports.fromJsonString(Schema_exports.Json))(read.value);
|
|
86
|
+
return {
|
|
87
|
+
body: read.value,
|
|
88
|
+
upstream: Option_exports.isSome(parsed) ? bodyUpstreamError(parsed.value) : void 0
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
var transportFetch = (connection, telemetry, rejected, answered) => (url, init) => Effect_exports.runPromiseWith(telemetry.context)(
|
|
61
92
|
Effect_exports.gen(function* () {
|
|
62
93
|
const target = yield* Effect_exports.try({
|
|
63
94
|
try: () => new URL(url),
|
|
@@ -75,18 +106,23 @@ var transportFetch = (connection, telemetry, rejected) => (url, init) => Effect_
|
|
|
75
106
|
});
|
|
76
107
|
const client = yield* HttpClient_exports.HttpClient;
|
|
77
108
|
const response = yield* client.execute(request);
|
|
109
|
+
if (response.status < 400)
|
|
110
|
+
return new Response(
|
|
111
|
+
[204, 205, 304].includes(response.status) ? null : Stream_exports.toReadableStream(response.stream),
|
|
112
|
+
{
|
|
113
|
+
status: response.status,
|
|
114
|
+
headers: response.headers
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
const { body, upstream } = yield* errorBody(response);
|
|
78
118
|
const provider = httpProviderError(response.status, response.headers);
|
|
79
119
|
if (provider !== void 0) {
|
|
80
|
-
|
|
81
|
-
|
|
120
|
+
const refused = providerErrorDetail(provider, { upstream });
|
|
121
|
+
yield* Deferred_exports.fail(rejected, refused);
|
|
122
|
+
return yield* refused;
|
|
82
123
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
status: response.status,
|
|
87
|
-
headers: response.headers
|
|
88
|
-
}
|
|
89
|
-
);
|
|
124
|
+
yield* Ref_exports.set(answered, { status: response.status, upstream });
|
|
125
|
+
return new Response(body, { status: response.status, headers: response.headers });
|
|
90
126
|
}).pipe(
|
|
91
127
|
Effect_exports.provide(FetchHttpClient_exports.layer),
|
|
92
128
|
Effect_exports.provideService(FetchHttpClient_exports.RequestInit, { redirect: "manual" }),
|
|
@@ -104,15 +140,30 @@ var transportFetch = (connection, telemetry, rejected) => (url, init) => Effect_
|
|
|
104
140
|
),
|
|
105
141
|
init?.signal ? { signal: init.signal } : {}
|
|
106
142
|
);
|
|
143
|
+
var explain = (error, phase, response) => {
|
|
144
|
+
if (Schema_exports.is(ProviderError)(error)) return providerErrorDetail(error, { phase });
|
|
145
|
+
if (!Schema_exports.is(McpError)(error) || error.upstream !== void 0 || error.status === void 0 || response?.status !== error.status || response.upstream === void 0)
|
|
146
|
+
return error;
|
|
147
|
+
return new McpError({
|
|
148
|
+
phase: error.phase,
|
|
149
|
+
reason: error.reason,
|
|
150
|
+
status: error.status,
|
|
151
|
+
upstream: response.upstream
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
var explained = (phase, answered) => (error) => Ref_exports.get(answered).pipe(
|
|
155
|
+
Effect_exports.flatMap((response) => Effect_exports.fail(explain(error, phase, response)))
|
|
156
|
+
);
|
|
107
157
|
function withClient(connection, mode, use, changed) {
|
|
108
158
|
const attempt = (kind) => Effect_exports.scoped(
|
|
109
159
|
Effect_exports.gen(function* () {
|
|
110
160
|
const telemetry = yield* captureTelemetry;
|
|
111
161
|
const rejected = yield* Deferred_exports.make();
|
|
162
|
+
const answered = yield* Ref_exports.make(void 0);
|
|
112
163
|
const pending = /* @__PURE__ */ new Set();
|
|
113
164
|
const { client, transport } = yield* Effect_exports.acquireRelease(
|
|
114
165
|
Effect_exports.sync(() => {
|
|
115
|
-
const fetch = transportFetch(connection, telemetry, rejected);
|
|
166
|
+
const fetch = transportFetch(connection, telemetry, rejected, answered);
|
|
116
167
|
const client2 = new Client(
|
|
117
168
|
{ name: "executor-apps", version: "0.1.0" },
|
|
118
169
|
{
|
|
@@ -168,10 +219,14 @@ function withClient(connection, mode, use, changed) {
|
|
|
168
219
|
catch: (error) => failure("connect", error)
|
|
169
220
|
}).pipe(
|
|
170
221
|
Effect_exports.raceFirst(Deferred_exports.await(rejected)),
|
|
222
|
+
Effect_exports.catch(explained("connect", answered)),
|
|
171
223
|
Effect_exports.timeout(connection.timeoutMs),
|
|
172
224
|
Effect_exports.withSpan("provider.mcp.connect")
|
|
173
225
|
);
|
|
174
|
-
return yield* use(client).pipe(
|
|
226
|
+
return yield* use(client).pipe(
|
|
227
|
+
Effect_exports.raceFirst(Deferred_exports.await(rejected)),
|
|
228
|
+
Effect_exports.catch(explained(mode, answered))
|
|
229
|
+
);
|
|
175
230
|
})
|
|
176
231
|
).pipe(
|
|
177
232
|
Effect_exports.withSpan("provider.mcp.session", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JsonObject,
|
|
3
3
|
ValidationError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KKGRSXUK.js";
|
|
5
5
|
import {
|
|
6
6
|
Cause_exports,
|
|
7
7
|
Effect_exports,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SchemaIssue_exports,
|
|
11
11
|
SchemaParser_exports,
|
|
12
12
|
Schema_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DM5U7G7V.js";
|
|
14
14
|
|
|
15
15
|
// ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
16
16
|
function deepCompareStrict(a, b) {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
fromWeb,
|
|
5
5
|
layerMergedContext,
|
|
6
6
|
make2 as make
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OBXHLFGQ.js";
|
|
8
8
|
import {
|
|
9
9
|
Reference,
|
|
10
10
|
Service,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
succeed4 as succeed,
|
|
18
18
|
toReadableStreamEffect,
|
|
19
19
|
tryPromise
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DM5U7G7V.js";
|
|
21
21
|
import {
|
|
22
22
|
__export
|
|
23
23
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
defaultDatabaseLimits,
|
|
13
13
|
defaultDatabaseRuntimeLimits,
|
|
14
14
|
reservedFieldNames
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GH6PY5BQ.js";
|
|
16
16
|
import {
|
|
17
17
|
Cause_exports,
|
|
18
18
|
Clock_exports,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Encoding_exports,
|
|
21
21
|
Schema_exports,
|
|
22
22
|
Semaphore_exports
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-DM5U7G7V.js";
|
|
24
24
|
|
|
25
25
|
// ../app-data/src/implementation/schema.ts
|
|
26
26
|
var metadata = new Set(reservedFieldNames);
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
promiseTable
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LPN4ONWW.js";
|
|
4
4
|
import {
|
|
5
5
|
declaredOperations,
|
|
6
6
|
fromPromise,
|
|
7
7
|
nativeOperation,
|
|
8
8
|
nativeRouter
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WPKXOTKM.js";
|
|
10
10
|
import {
|
|
11
11
|
ScheduleTiming
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VGEPL4BV.js";
|
|
13
13
|
import {
|
|
14
14
|
DatabaseSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GH6PY5BQ.js";
|
|
16
16
|
import {
|
|
17
17
|
decoderOf,
|
|
18
18
|
isSchema,
|
|
19
19
|
storageFieldOf
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IE6W5RNN.js";
|
|
21
21
|
import {
|
|
22
22
|
AppStorageUnavailable
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-HQKIPKM5.js";
|
|
24
24
|
import {
|
|
25
25
|
JsonValue
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KKGRSXUK.js";
|
|
27
27
|
import {
|
|
28
28
|
Effect_exports,
|
|
29
29
|
Schema_exports
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DM5U7G7V.js";
|
|
31
31
|
|
|
32
32
|
// src/contracts/http.ts
|
|
33
33
|
var ResponseStatusError = class extends Schema_exports.TaggedError()(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fixedRouter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EXDR4HVM.js";
|
|
4
4
|
import {
|
|
5
5
|
nativeOperation,
|
|
6
6
|
operationDeclaration,
|
|
7
7
|
routerDeclaration
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WPKXOTKM.js";
|
|
9
9
|
|
|
10
10
|
// src/implementation/protocol-operations.ts
|
|
11
11
|
var protocolOperations = (operations, kinds = {}) => {
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
SkillDefinitionInvalid,
|
|
6
6
|
SkillFile,
|
|
7
7
|
SkillFilePath
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TACLXEAE.js";
|
|
9
9
|
import {
|
|
10
10
|
Effect_exports,
|
|
11
11
|
Schema_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DM5U7G7V.js";
|
|
13
13
|
|
|
14
14
|
// src/implementation/skill-files.ts
|
|
15
15
|
var skillFromFiles = (input, source = {}) => Effect_exports.gen(function* () {
|