stitchkit 0.124.0 → 0.124.1
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/CHANGELOG.md +48 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +1 -1
- package/dist/entrypoints/agent-runtime/realtime.js +3 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +1 -1
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +3 -3
- package/dist/entrypoints/agent-runtime.js +3 -3
- package/dist/entrypoints/application/diagnostic-journal.js +3 -5
- package/dist/entrypoints/application/directory-inbox.js +9 -11
- package/dist/entrypoints/application.js +3 -3
- package/dist/entrypoints/cli/publish.js +6 -6
- package/dist/entrypoints/cli.js +6 -3
- package/dist/entrypoints/files.js +5 -5
- package/dist/entrypoints/index.js +3 -3
- package/dist/entrypoints/server.js +6 -6
- package/dist/entrypoints/telegram.js +2 -2
- package/dist/entrypoints/tools/connections.d.ts +2 -2
- package/dist/entrypoints/tools/connections.d.ts.map +1 -1
- package/dist/entrypoints/tools/connections.js +121 -29
- package/dist/entrypoints/tools/mcp.d.ts +1 -1
- package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
- package/dist/entrypoints/tools/mcp.js +8 -6
- package/dist/entrypoints/tools/toolkit.js +2 -2
- package/dist/entrypoints/tools.js +2 -2
- package/dist/{index-jswst0h3.js → index-03qrr49d.js} +49 -4
- package/dist/{index-8yky60kq.js → index-1szhrfsf.js} +5 -7
- package/dist/{index-mqttte96.js → index-3ymcmpa9.js} +3 -5
- package/dist/{index-v8xm2s9v.js → index-7177dxjn.js} +1 -1
- package/dist/{index-2x2ch0bt.js → index-782qtc24.js} +1 -1
- package/dist/{index-j8rda9n6.js → index-8pwwd6rp.js} +3 -3
- package/dist/{index-m616f0yz.js → index-8x0q6yfb.js} +134 -7
- package/dist/{index-q89kd1xc.js → index-e1x6vze4.js} +1 -1
- package/dist/{index-ezwvsqx9.js → index-fvd6pvw3.js} +1 -1
- package/dist/{index-w0wy05gr.js → index-jkjh7zw4.js} +50 -40
- package/dist/{index-ac6vvm30.js → index-jp2qd9jb.js} +1 -1
- package/dist/index-mm89hd8v.js +39 -0
- package/dist/{index-jc5xgkpk.js → index-qsm899qp.js} +1 -1
- package/dist/index-wqzw3qg9.js +91 -0
- package/dist/{index-364k2zwa.js → index-wt6rw7rf.js} +5 -7
- package/dist/{index-tt3ej8r3.js → index-x0769xt9.js} +217 -24
- package/dist/internal/deadline.d.ts +30 -0
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/pinned-http.d.ts +1 -1
- package/dist/internal/pinned-http.d.ts.map +1 -1
- package/dist/internal/secure-fetch.d.ts +8 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/tools/cli/resumable-download.d.ts +18 -0
- package/dist/tools/cli/resumable-download.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts +18 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/connections/catalog-cache.d.ts +9 -0
- package/dist/tools/connections/catalog-cache.d.ts.map +1 -0
- package/dist/tools/connections/errors.d.ts +10 -1
- package/dist/tools/connections/errors.d.ts.map +1 -1
- package/dist/tools/connections/limits.d.ts +16 -4
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts +10 -2
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/operation-limits.d.ts +12 -1
- package/dist/tools/connections/operation-limits.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts +2 -2
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +38 -2
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/mcp/catalog-stamp.d.ts +47 -0
- package/dist/tools/mcp/catalog-stamp.d.ts.map +1 -0
- package/dist/tools/mcp/catalog.d.ts +1 -30
- package/dist/tools/mcp/catalog.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +6 -1
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +1 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/llms/cli.2.txt +60 -6
- package/llms/tools-connections.txt +5 -3
- package/llms/tools-mcp.txt +5 -2
- package/llms/tools.txt +10 -3
- package/llms-full.txt +80 -14
- package/llms.txt +4 -4
- package/package.json +1 -1
- package/dist/index-9tqbxv5p.js +0 -44
- package/dist/index-b56nnscm.js +0 -132
|
@@ -13,8 +13,10 @@ import {
|
|
|
13
13
|
markRemoteSchemaVerdict
|
|
14
14
|
} from "../../index-dsa676h8.js";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
MCP_CATALOG_HEADER,
|
|
17
|
+
readMcpCatalogStamp2,
|
|
18
|
+
readMcpCatalogHeader
|
|
19
|
+
} from "../../index-mm89hd8v.js";
|
|
18
20
|
import {
|
|
19
21
|
defineRuntimeTool2
|
|
20
22
|
} from "../../index-6k47xdtt.js";
|
|
@@ -24,6 +26,11 @@ import {
|
|
|
24
26
|
import {
|
|
25
27
|
raceAbort
|
|
26
28
|
} from "../../index-b0kddvzw.js";
|
|
29
|
+
import {
|
|
30
|
+
withDeadline,
|
|
31
|
+
withSignalDeadline,
|
|
32
|
+
withIdleDeadline
|
|
33
|
+
} from "../../index-wqzw3qg9.js";
|
|
27
34
|
import {
|
|
28
35
|
safeJsonParse
|
|
29
36
|
} from "../../index-zsarb5xp.js";
|
|
@@ -161,11 +168,14 @@ class ConnectionTimeoutError extends Error {
|
|
|
161
168
|
operation;
|
|
162
169
|
phase;
|
|
163
170
|
observedReadBytes;
|
|
171
|
+
deadline;
|
|
164
172
|
constructor(connectionName, timeoutMs, context = {}) {
|
|
165
|
-
|
|
173
|
+
const deadline = context.deadline ?? "total";
|
|
174
|
+
super(deadline === "idle" ? `Connection "${connectionName}" received nothing for ${timeoutMs} ms` : `Connection "${connectionName}" timed out after ${timeoutMs} ms`);
|
|
166
175
|
this.name = "ConnectionTimeoutError";
|
|
167
176
|
this.connectionName = connectionName;
|
|
168
177
|
this.timeoutMs = timeoutMs;
|
|
178
|
+
this.deadline = deadline;
|
|
169
179
|
this.operation = context.operation ?? "request";
|
|
170
180
|
this.phase = context.phase ?? "call";
|
|
171
181
|
this.observedReadBytes = context.observedReadBytes ?? 0;
|
|
@@ -178,6 +188,7 @@ class ConnectionTimeoutError extends Error {
|
|
|
178
188
|
details: {
|
|
179
189
|
message,
|
|
180
190
|
reason: "deadline-exceeded",
|
|
191
|
+
deadline: this.deadline,
|
|
181
192
|
operation: this.operation,
|
|
182
193
|
phase: this.phase,
|
|
183
194
|
timeoutMs: this.timeoutMs,
|
|
@@ -226,6 +237,8 @@ class ConnectionResponseTooLargeError extends Error {
|
|
|
226
237
|
// src/tools/connections/limits.ts
|
|
227
238
|
var DEFAULT_CONNECTION_TIMEOUT_MS = 30000;
|
|
228
239
|
var DEFAULT_MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
240
|
+
var DEFAULT_DISCOVERY_TIMEOUT_MS = 300000;
|
|
241
|
+
var DEFAULT_DISCOVERY_IDLE_TIMEOUT_MS = 30000;
|
|
229
242
|
function connectionTimeoutMs(value) {
|
|
230
243
|
if (value === undefined)
|
|
231
244
|
return DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
@@ -234,6 +247,18 @@ function connectionTimeoutMs(value) {
|
|
|
234
247
|
}
|
|
235
248
|
return value;
|
|
236
249
|
}
|
|
250
|
+
function connectionIdleTimeoutMs(value) {
|
|
251
|
+
if (value === undefined)
|
|
252
|
+
return;
|
|
253
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > MAX_TIMER_MS) {
|
|
254
|
+
throw new RangeError("Connection idleTimeoutMs must be a positive integer within timer range");
|
|
255
|
+
}
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
function recordConnectionRead(context, bytes) {
|
|
259
|
+
context.observedReadBytes += bytes;
|
|
260
|
+
context.touch?.();
|
|
261
|
+
}
|
|
237
262
|
function connectionMaxResponseBytes(value) {
|
|
238
263
|
if (value === undefined)
|
|
239
264
|
return DEFAULT_MAX_RESPONSE_BYTES;
|
|
@@ -245,11 +270,15 @@ function awaitConnection(pending, signal) {
|
|
|
245
270
|
}
|
|
246
271
|
function withConnectionDeadline(connectionName, context, callerSignal, body) {
|
|
247
272
|
const timeoutMs = connectionTimeoutMs(context.timeoutMs);
|
|
273
|
+
const idleTimeoutMs = connectionIdleTimeoutMs(context.idleTimeoutMs);
|
|
248
274
|
let scoped = context;
|
|
249
|
-
return withSignalDeadline(timeoutMs, callerSignal, () => new ConnectionTimeoutError(connectionName, timeoutMs, scoped), (signal) => {
|
|
250
|
-
scoped
|
|
251
|
-
|
|
252
|
-
})
|
|
275
|
+
return withSignalDeadline(timeoutMs, callerSignal, () => new ConnectionTimeoutError(connectionName, timeoutMs, scoped), (signal) => withIdleDeadline(idleTimeoutMs, signal, () => new ConnectionTimeoutError(connectionName, idleTimeoutMs ?? timeoutMs, {
|
|
276
|
+
...scoped,
|
|
277
|
+
deadline: "idle"
|
|
278
|
+
}), (idle) => {
|
|
279
|
+
scoped = { ...context, signal: idle.signal, touch: idle.touch };
|
|
280
|
+
return raceAbort(body(scoped), idle.signal);
|
|
281
|
+
}));
|
|
253
282
|
}
|
|
254
283
|
async function readBoundedText(response, maxBytes, connectionName, context) {
|
|
255
284
|
const result = await readBoundedChunks(response.body, {
|
|
@@ -257,7 +286,7 @@ async function readBoundedText(response, maxBytes, connectionName, context) {
|
|
|
257
286
|
...context?.signal && { signal: context.signal },
|
|
258
287
|
onChunk: (chunk) => {
|
|
259
288
|
if (context)
|
|
260
|
-
context
|
|
289
|
+
recordConnectionRead(context, chunk.byteLength);
|
|
261
290
|
}
|
|
262
291
|
});
|
|
263
292
|
if (result.kind === "over-limit") {
|
|
@@ -285,15 +314,17 @@ async function readConnectionErrorText(response, connectionName, context) {
|
|
|
285
314
|
|
|
286
315
|
// src/tools/connections/operation-limits.ts
|
|
287
316
|
function resolveMcpLimits(config) {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
maxResponseBytes: connectionMaxResponseBytes(config.maxResponseBytes)
|
|
291
|
-
};
|
|
317
|
+
const sharedTimeoutMs = config.timeoutMs === undefined ? undefined : connectionTimeoutMs(config.timeoutMs);
|
|
318
|
+
const sharedMaxResponseBytes = connectionMaxResponseBytes(config.maxResponseBytes);
|
|
292
319
|
const resolve = (phase) => {
|
|
293
320
|
const override = config.limits?.[phase];
|
|
321
|
+
const discovery = phase === "discovery";
|
|
322
|
+
const declaredTimeout = override?.timeoutMs !== undefined || sharedTimeoutMs !== undefined;
|
|
323
|
+
const idleTimeoutMs = connectionIdleTimeoutMs(override?.idleTimeoutMs ?? (discovery && !declaredTimeout ? DEFAULT_DISCOVERY_IDLE_TIMEOUT_MS : undefined));
|
|
294
324
|
return {
|
|
295
|
-
timeoutMs: connectionTimeoutMs(override?.timeoutMs
|
|
296
|
-
maxResponseBytes: connectionMaxResponseBytes(override?.maxResponseBytes === undefined ?
|
|
325
|
+
timeoutMs: connectionTimeoutMs(override?.timeoutMs ?? sharedTimeoutMs ?? (discovery ? DEFAULT_DISCOVERY_TIMEOUT_MS : undefined)),
|
|
326
|
+
maxResponseBytes: connectionMaxResponseBytes(override?.maxResponseBytes === undefined ? sharedMaxResponseBytes : override.maxResponseBytes),
|
|
327
|
+
...idleTimeoutMs !== undefined && { idleTimeoutMs }
|
|
297
328
|
};
|
|
298
329
|
};
|
|
299
330
|
return { discovery: resolve("discovery"), call: resolve("call") };
|
|
@@ -363,7 +394,52 @@ function connectionInstanceId(name, url, instanceKey) {
|
|
|
363
394
|
}
|
|
364
395
|
|
|
365
396
|
// src/tools/connections/mcp.ts
|
|
366
|
-
import { z as
|
|
397
|
+
import { z as z3 } from "zod";
|
|
398
|
+
|
|
399
|
+
// src/tools/connections/catalog-cache.ts
|
|
400
|
+
import { z } from "zod";
|
|
401
|
+
var StoredEntrySchema = z.object({
|
|
402
|
+
stamp: z.object({ digest: z.string().min(1), tools: z.int().nonnegative() }),
|
|
403
|
+
result: z.unknown()
|
|
404
|
+
});
|
|
405
|
+
function sameStamp(left, right) {
|
|
406
|
+
return left !== null && left.digest === right.digest && left.tools === right.tools;
|
|
407
|
+
}
|
|
408
|
+
function listedUnder(result, stamp) {
|
|
409
|
+
if (!isRecord(result) || !Array.isArray(result.tools))
|
|
410
|
+
return false;
|
|
411
|
+
if (result.tools.length !== stamp.tools)
|
|
412
|
+
return false;
|
|
413
|
+
return result.tools.every((tool) => isRecord(tool) && sameStamp(readMcpCatalogStamp2(tool._meta), stamp));
|
|
414
|
+
}
|
|
415
|
+
var STORE_TIMEOUT_MS = 1e4;
|
|
416
|
+
async function loadEntry(store) {
|
|
417
|
+
try {
|
|
418
|
+
const loaded = await withDeadline(Promise.resolve(store.load()), STORE_TIMEOUT_MS);
|
|
419
|
+
if (!loaded.settled)
|
|
420
|
+
return;
|
|
421
|
+
const parsed = StoredEntrySchema.safeParse(loaded.value);
|
|
422
|
+
return parsed.success ? parsed.data : undefined;
|
|
423
|
+
} catch {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
async function listMcpCatalog(params) {
|
|
428
|
+
const { store, served } = params;
|
|
429
|
+
if (!store || !served)
|
|
430
|
+
return params.list();
|
|
431
|
+
const stored = await loadEntry(store);
|
|
432
|
+
if (stored && sameStamp(stored.stamp, served) && listedUnder(stored.result, served)) {
|
|
433
|
+
return stored.result;
|
|
434
|
+
}
|
|
435
|
+
const result = await params.list();
|
|
436
|
+
if (listedUnder(result, served)) {
|
|
437
|
+
try {
|
|
438
|
+
await withDeadline(Promise.resolve(store.store({ stamp: { ...served }, result })), STORE_TIMEOUT_MS);
|
|
439
|
+
} catch {}
|
|
440
|
+
}
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
367
443
|
|
|
368
444
|
// src/tools/connections/http.ts
|
|
369
445
|
async function fetchConnection(target, init, allowedHosts, connectionName) {
|
|
@@ -415,7 +491,7 @@ async function* readSseFrames(response, maxBytes, connectionName, options = {})
|
|
|
415
491
|
if (options.onChunk)
|
|
416
492
|
options.onChunk(value.byteLength);
|
|
417
493
|
else if (options.context)
|
|
418
|
-
options.context
|
|
494
|
+
recordConnectionRead(options.context, value.byteLength);
|
|
419
495
|
if (options.totalLimit && bytes > (context()?.maxResponseBytes ?? maxBytes)) {
|
|
420
496
|
throw tooLarge(bytes);
|
|
421
497
|
}
|
|
@@ -552,6 +628,7 @@ class SseSession {
|
|
|
552
628
|
body: JSON.stringify(message),
|
|
553
629
|
signal
|
|
554
630
|
}, this.options.allowedHosts, this.connectionName);
|
|
631
|
+
context.touch?.();
|
|
555
632
|
await this.assertStatus(post, context);
|
|
556
633
|
await readBoundedText(post, context.maxResponseBytes, this.connectionName, context);
|
|
557
634
|
return message.id === undefined ? undefined : await awaitConnection(response.promise, signal);
|
|
@@ -586,7 +663,7 @@ class SseSession {
|
|
|
586
663
|
observeChunk(bytes) {
|
|
587
664
|
const active = this.endpointReady ? this.active : new Set([this.endpointContext]);
|
|
588
665
|
for (const context of active) {
|
|
589
|
-
context
|
|
666
|
+
recordConnectionRead(context, bytes);
|
|
590
667
|
const total = (this.streamBytes.get(context) ?? 0) + bytes;
|
|
591
668
|
this.streamBytes.set(context, total);
|
|
592
669
|
if (total > context.maxResponseBytes) {
|
|
@@ -602,7 +679,7 @@ class SseSession {
|
|
|
602
679
|
signal: this.controller.signal
|
|
603
680
|
}, this.options.allowedHosts, this.connectionName);
|
|
604
681
|
await this.assertStatus(response, this.endpointContext);
|
|
605
|
-
for await (const frame of readSseFrames(response, this.options.maxResponseBytes, this.connectionName, {
|
|
682
|
+
for await (const frame of readSseFrames(response, connectionMaxResponseBytes(this.options.maxResponseBytes), this.connectionName, {
|
|
606
683
|
signal: this.controller.signal,
|
|
607
684
|
currentContext: () => this.currentContext(),
|
|
608
685
|
onChunk: (bytes) => this.observeChunk(bytes)
|
|
@@ -649,6 +726,7 @@ class McpHttpClient {
|
|
|
649
726
|
initialized = false;
|
|
650
727
|
initialInitializePending = true;
|
|
651
728
|
sse;
|
|
729
|
+
served;
|
|
652
730
|
limits;
|
|
653
731
|
constructor(connectionName, instanceId, options) {
|
|
654
732
|
this.connectionName = connectionName;
|
|
@@ -656,8 +734,12 @@ class McpHttpClient {
|
|
|
656
734
|
this.options = options;
|
|
657
735
|
this.limits = resolveMcpLimits(options);
|
|
658
736
|
}
|
|
737
|
+
servedCatalog() {
|
|
738
|
+
return this.served;
|
|
739
|
+
}
|
|
659
740
|
teardown() {
|
|
660
741
|
this.initialized = false;
|
|
742
|
+
this.served = undefined;
|
|
661
743
|
this.initialInitializePending = true;
|
|
662
744
|
this.sessionId = undefined;
|
|
663
745
|
this.sse?.close();
|
|
@@ -719,6 +801,7 @@ class McpHttpClient {
|
|
|
719
801
|
body: JSON.stringify(message),
|
|
720
802
|
signal: context.signal
|
|
721
803
|
}, this.options.allowedHosts, this.connectionName);
|
|
804
|
+
context.touch?.();
|
|
722
805
|
if (response.status === 401) {
|
|
723
806
|
response.body?.cancel().catch(() => {
|
|
724
807
|
return;
|
|
@@ -731,6 +814,9 @@ class McpHttpClient {
|
|
|
731
814
|
const session = response.headers.get("mcp-session-id");
|
|
732
815
|
if (session)
|
|
733
816
|
this.sessionId = session;
|
|
817
|
+
if (message.method === "initialize") {
|
|
818
|
+
this.served = readMcpCatalogHeader(response.headers.get(MCP_CATALOG_HEADER)) ?? undefined;
|
|
819
|
+
}
|
|
734
820
|
if (message.id === undefined) {
|
|
735
821
|
await readBoundedText(response, context.maxResponseBytes, this.connectionName, context);
|
|
736
822
|
return;
|
|
@@ -833,7 +919,7 @@ function mcpToolFailure(toolName, result) {
|
|
|
833
919
|
}
|
|
834
920
|
|
|
835
921
|
// src/tools/connections/runtime.ts
|
|
836
|
-
import { z } from "zod";
|
|
922
|
+
import { z as z2 } from "zod";
|
|
837
923
|
async function withConnectionToken(params, body) {
|
|
838
924
|
const token = await params.provider?.(params.context);
|
|
839
925
|
try {
|
|
@@ -847,14 +933,14 @@ async function withConnectionToken(params, body) {
|
|
|
847
933
|
}
|
|
848
934
|
function zodObjectFromJsonSchema(schema) {
|
|
849
935
|
if (!schema || Object.keys(schema).length === 0)
|
|
850
|
-
return
|
|
851
|
-
const parsed =
|
|
852
|
-
if (parsed instanceof
|
|
936
|
+
return z2.looseObject({});
|
|
937
|
+
const parsed = z2.fromJSONSchema(reconcileDialect(schema));
|
|
938
|
+
if (parsed instanceof z2.ZodObject) {
|
|
853
939
|
markJsonSchemaObjectGuards(parsed);
|
|
854
940
|
markRemoteSchemaVerdict(parsed);
|
|
855
941
|
return parsed;
|
|
856
942
|
}
|
|
857
|
-
return
|
|
943
|
+
return z2.looseObject({});
|
|
858
944
|
}
|
|
859
945
|
function reconcileDialect(schema) {
|
|
860
946
|
return declaresDraft07(schema.$schema) ? schema : withDraft2020Keywords(schema);
|
|
@@ -903,14 +989,20 @@ async function mountMcpConnection(connection, instanceId, onSkipped) {
|
|
|
903
989
|
const createClient = () => new McpHttpClient(connection.name, instanceId, {
|
|
904
990
|
transport: connection.transport,
|
|
905
991
|
allowedHosts,
|
|
906
|
-
timeoutMs:
|
|
907
|
-
|
|
992
|
+
...connection.timeoutMs !== undefined && { timeoutMs: connection.timeoutMs },
|
|
993
|
+
...connection.maxResponseBytes !== undefined && {
|
|
994
|
+
maxResponseBytes: connection.maxResponseBytes
|
|
995
|
+
},
|
|
908
996
|
...connection.limits && { limits: connection.limits }
|
|
909
997
|
});
|
|
910
998
|
const discovery = createClient();
|
|
911
999
|
const listed = await withConnectionToken({ instanceId, provider: connection.token, client: discovery }, async (token) => {
|
|
912
1000
|
await discovery.initialize(token);
|
|
913
|
-
return
|
|
1001
|
+
return listMcpCatalog({
|
|
1002
|
+
store: connection.catalog,
|
|
1003
|
+
served: discovery.servedCatalog(),
|
|
1004
|
+
list: () => discovery.request("tools/list", {}, token)
|
|
1005
|
+
});
|
|
914
1006
|
}).finally(() => discovery.teardown());
|
|
915
1007
|
const discovered = readDiscoveredTools(listed, connection.name);
|
|
916
1008
|
const filtered = filterMcpTools(discovered, connection.tools);
|
|
@@ -925,7 +1017,7 @@ async function mountMcpConnection(connection, instanceId, onSkipped) {
|
|
|
925
1017
|
...tool.annotations && { annotations: tool.annotations },
|
|
926
1018
|
...connection.transports && { transports: connection.transports },
|
|
927
1019
|
input,
|
|
928
|
-
output:
|
|
1020
|
+
output: z3.unknown(),
|
|
929
1021
|
handler: (context) => {
|
|
930
1022
|
const client = createClient();
|
|
931
1023
|
return withConnectionToken({ instanceId, provider: connection.token, client, context }, async (token) => {
|
|
@@ -966,7 +1058,7 @@ function filterMcpTools(tools, filter) {
|
|
|
966
1058
|
}
|
|
967
1059
|
|
|
968
1060
|
// src/tools/connections/openapi.ts
|
|
969
|
-
import { z as
|
|
1061
|
+
import { z as z4 } from "zod";
|
|
970
1062
|
|
|
971
1063
|
// src/tools/connections/openapi-document.ts
|
|
972
1064
|
function resolveOpenApiDocument(document) {
|
|
@@ -1062,7 +1154,7 @@ async function mountOpenApiConnection(connection, instanceId, onSkipped) {
|
|
|
1062
1154
|
},
|
|
1063
1155
|
...connection.transports && { transports: connection.transports },
|
|
1064
1156
|
input,
|
|
1065
|
-
output:
|
|
1157
|
+
output: z4.unknown(),
|
|
1066
1158
|
handler: (context) => withConnectionToken({ instanceId, provider: connection.token, context }, async (token) => {
|
|
1067
1159
|
const args = isRecord(context.input) ? context.input : {};
|
|
1068
1160
|
const url = buildOperationUrl(baseUrl, entry, args);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { McpServer } from '@modelcontextprotocol/server';
|
|
2
2
|
export type { ToolSurfaceProjection } from '../../tools/internal/surface-projector.js';
|
|
3
3
|
export { EXT_APPS_BUNDLE_PLACEHOLDER, inlineMcpAppBundle, type McpAppCsp, type McpAppResourceMeta, type McpResourceDef, RESOURCE_MIME_TYPE, } from '../../tools/mcp/app.js';
|
|
4
|
-
export { MCP_CATALOG_META_KEY, type McpCatalogStamp, mcpCatalogMeta, readMcpCatalogStamp, } from '../../tools/mcp/catalog.js';
|
|
4
|
+
export { MCP_CATALOG_META_KEY, type McpCatalogStamp, mcpCatalogMeta, readMcpCatalogStamp, } from '../../tools/mcp/catalog-stamp.js';
|
|
5
5
|
export { createMcpHandler, createMcpHttpRoute, type McpHandlerConfig, type McpHttpConfig, type McpHttpHandler, type McpHttpSecurityConfig, type McpLegacyPolicy, } from '../../tools/mcp/handler.js';
|
|
6
6
|
export { buildMcpServer, type DirectMcpSurfaceConfig, type FiniteMcpSurfaceConfig, type McpMountConfig, type McpServerBuildConfig, type McpServerSharedConfig, mountMcp, mountMcpResource, validateMcpSchemas, } from '../../tools/mcp/mount.js';
|
|
7
7
|
export type { IncompatibleSchemaPolicy, McpSchemaValidationConfig, McpSurfaceDefinition, McpSurfaceRegistry, ValidateMcpSchemasConfig, } from '../../tools/mcp/prepare.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/tools/mcp.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,cAAc,EACd,mBAAmB,GACpB,MAAM,
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/tools/mcp.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,cAAc,EACd,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,GAChC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,qBAAqB,EACrB,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EACV,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import"../../index-ct75c3at.js";
|
|
2
|
-
import"../../index-332d0m9g.js";
|
|
3
1
|
import"../../index-ndjzbt2v.js";
|
|
4
2
|
import"../../index-dsa676h8.js";
|
|
5
3
|
import"../../index-t8jz0e20.js";
|
|
4
|
+
import"../../index-ct75c3at.js";
|
|
6
5
|
import"../../index-tynna0n4.js";
|
|
7
6
|
import"../../index-s512scra.js";
|
|
8
7
|
import"../../index-yt1gg11x.js";
|
|
9
8
|
import"../../index-qc7tq0za.js";
|
|
9
|
+
import"../../index-332d0m9g.js";
|
|
10
10
|
import {
|
|
11
11
|
RESOURCE_MIME_TYPE2,
|
|
12
12
|
EXT_APPS_BUNDLE_PLACEHOLDER2,
|
|
13
13
|
inlineMcpAppBundle2,
|
|
14
|
-
MCP_CATALOG_META_KEY2,
|
|
15
|
-
mcpCatalogMeta2,
|
|
16
|
-
readMcpCatalogStamp2,
|
|
17
14
|
validateMcpSchemas2,
|
|
18
15
|
mountMcp2,
|
|
19
16
|
buildMcpServer2,
|
|
@@ -21,13 +18,18 @@ import {
|
|
|
21
18
|
createMcpHandler2,
|
|
22
19
|
createMcpHttpRoute2,
|
|
23
20
|
createStdioMcpServer2
|
|
24
|
-
} from "../../index-
|
|
21
|
+
} from "../../index-jkjh7zw4.js";
|
|
25
22
|
import {
|
|
26
23
|
DEFAULT_PROCESS_SIGNALS,
|
|
27
24
|
defaultSignalSource,
|
|
28
25
|
reportSignalError,
|
|
29
26
|
guardSignalCallback
|
|
30
27
|
} from "../../index-3prvb42w.js";
|
|
28
|
+
import {
|
|
29
|
+
MCP_CATALOG_META_KEY2,
|
|
30
|
+
mcpCatalogMeta2,
|
|
31
|
+
readMcpCatalogStamp2
|
|
32
|
+
} from "../../index-mm89hd8v.js";
|
|
31
33
|
import"../../index-993vtv1w.js";
|
|
32
34
|
import"../../index-6k47xdtt.js";
|
|
33
35
|
// src/tools/mcp/stdio-signals.ts
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../../index-yebkpytc.js";
|
|
12
12
|
import {
|
|
13
13
|
createCli2
|
|
14
|
-
} from "../../index-
|
|
14
|
+
} from "../../index-e1x6vze4.js";
|
|
15
15
|
import"../../index-332d0m9g.js";
|
|
16
16
|
import"../../index-sqc6ezrb.js";
|
|
17
17
|
import"../../index-gy9x38a2.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
buildMcpServer2,
|
|
22
22
|
createMcpHandler2,
|
|
23
23
|
createStdioMcpServer2
|
|
24
|
-
} from "../../index-
|
|
24
|
+
} from "../../index-jkjh7zw4.js";
|
|
25
25
|
import"../../index-fa53vygr.js";
|
|
26
26
|
import"../../index-ww3gss55.js";
|
|
27
27
|
import"../../index-993vtv1w.js";
|
|
@@ -100,12 +100,12 @@ import {
|
|
|
100
100
|
} from "../index-6k47xdtt.js";
|
|
101
101
|
import {
|
|
102
102
|
ManagedFileError2
|
|
103
|
-
} from "../index-
|
|
103
|
+
} from "../index-wt6rw7rf.js";
|
|
104
104
|
import {
|
|
105
105
|
fetchGuarded,
|
|
106
106
|
fetchPinnedDocument,
|
|
107
107
|
readCapped
|
|
108
|
-
} from "../index-
|
|
108
|
+
} from "../index-03qrr49d.js";
|
|
109
109
|
import {
|
|
110
110
|
readBoundedChunks,
|
|
111
111
|
concatChunks
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
raceAbort
|
|
3
3
|
} from "./index-b0kddvzw.js";
|
|
4
|
+
import {
|
|
5
|
+
startIdleTimer
|
|
6
|
+
} from "./index-wqzw3qg9.js";
|
|
4
7
|
import {
|
|
5
8
|
readBoundedChunks
|
|
6
9
|
} from "./index-5efrpfmj.js";
|
|
@@ -25,7 +28,7 @@ async function requestPinned(url, resolved, signal, headers = {}) {
|
|
|
25
28
|
method: "GET",
|
|
26
29
|
signal,
|
|
27
30
|
...url.protocol === "https:" ? { servername: url.hostname } : {},
|
|
28
|
-
headers: {
|
|
31
|
+
headers: { accept: "*/*", ...headers, host: url.host }
|
|
29
32
|
}, (response) => {
|
|
30
33
|
answered = true;
|
|
31
34
|
resolve(response);
|
|
@@ -200,6 +203,7 @@ async function fetchGuarded(start, allowPrivate, options = {}) {
|
|
|
200
203
|
controller.abort(new Error(`fetch did not produce response headers within ${timeoutMs}ms`));
|
|
201
204
|
}, timeoutMs);
|
|
202
205
|
headerTimer.unref?.();
|
|
206
|
+
const idle = options.idleTimeoutMs === undefined ? undefined : startIdleTimer(options.idleTimeoutMs, () => controller.abort(new Error(`fetch received nothing for ${options.idleTimeoutMs}ms`)), { unref: true });
|
|
203
207
|
const transport = options.transport ?? requestPinned;
|
|
204
208
|
let settled = false;
|
|
205
209
|
try {
|
|
@@ -209,7 +213,9 @@ async function fetchGuarded(start, allowPrivate, options = {}) {
|
|
|
209
213
|
throw new Error("refusing to fetch a URL that carries credentials");
|
|
210
214
|
}
|
|
211
215
|
const resolved = await resolveAddress(url, allowPrivate, signal, options.dns);
|
|
212
|
-
const
|
|
216
|
+
const headers = url.origin === start.origin ? options.headers : undefined;
|
|
217
|
+
const res = await transport(url, resolved, signal, headers);
|
|
218
|
+
idle?.touch();
|
|
213
219
|
const location = res.status >= 300 && res.status < 400 ? res.headers.get("location") : null;
|
|
214
220
|
if (location === null) {
|
|
215
221
|
settled = true;
|
|
@@ -218,16 +224,55 @@ async function fetchGuarded(start, allowPrivate, options = {}) {
|
|
|
218
224
|
controller.abort(new Error(`fetch body was not consumed within ${bodyTimeoutMs}ms`));
|
|
219
225
|
}, bodyTimeoutMs);
|
|
220
226
|
bodyTimer.unref?.();
|
|
221
|
-
return res;
|
|
227
|
+
return observeBody(res, signal, idle, bodyTimer);
|
|
222
228
|
}
|
|
223
229
|
await res.body?.cancel();
|
|
224
230
|
url = new URL(location, url);
|
|
225
231
|
}
|
|
226
232
|
throw new Error("too many redirects");
|
|
227
233
|
} finally {
|
|
228
|
-
if (!settled)
|
|
234
|
+
if (!settled) {
|
|
229
235
|
clearTimeout(headerTimer);
|
|
236
|
+
idle?.stop();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function observeBody(res, signal, idle, bodyTimer) {
|
|
241
|
+
const end = () => {
|
|
242
|
+
idle?.stop();
|
|
243
|
+
clearTimeout(bodyTimer);
|
|
244
|
+
};
|
|
245
|
+
if (!res.body) {
|
|
246
|
+
end();
|
|
247
|
+
return res;
|
|
230
248
|
}
|
|
249
|
+
const reader = res.body.getReader();
|
|
250
|
+
const body = new ReadableStream({
|
|
251
|
+
async pull(controller) {
|
|
252
|
+
try {
|
|
253
|
+
const { done, value } = await reader.read();
|
|
254
|
+
if (done) {
|
|
255
|
+
end();
|
|
256
|
+
controller.close();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
idle?.touch();
|
|
260
|
+
controller.enqueue(value);
|
|
261
|
+
} catch (error) {
|
|
262
|
+
end();
|
|
263
|
+
controller.error(signal.aborted ? signal.reason : error);
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
cancel(reason) {
|
|
267
|
+
end();
|
|
268
|
+
return reader.cancel(reason);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
return new Response(body, {
|
|
272
|
+
status: res.status,
|
|
273
|
+
statusText: res.statusText,
|
|
274
|
+
headers: res.headers
|
|
275
|
+
});
|
|
231
276
|
}
|
|
232
277
|
async function resolveAddress(url, allowPrivate, signal, dns) {
|
|
233
278
|
if (!allowPrivate)
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withExclusiveLock2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import {
|
|
5
|
-
readBoundedFile
|
|
6
|
-
} from "./index-m616f0yz.js";
|
|
3
|
+
} from "./index-fvd6pvw3.js";
|
|
7
4
|
import {
|
|
8
5
|
writeAtomicFileData
|
|
9
|
-
} from "./index-
|
|
6
|
+
} from "./index-jp2qd9jb.js";
|
|
10
7
|
import {
|
|
11
|
-
publishAtomicFile
|
|
12
|
-
|
|
8
|
+
publishAtomicFile,
|
|
9
|
+
readBoundedFile
|
|
10
|
+
} from "./index-8x0q6yfb.js";
|
|
13
11
|
import {
|
|
14
12
|
errnoOf
|
|
15
13
|
} from "./index-jj9228tt.js";
|
|
@@ -5,13 +5,11 @@ import {
|
|
|
5
5
|
probeProcessOwner2
|
|
6
6
|
} from "./index-bqzgaj57.js";
|
|
7
7
|
import {
|
|
8
|
+
AtomicFilePublicationError2,
|
|
9
|
+
publishAtomicFile,
|
|
8
10
|
BoundedFileReadError,
|
|
9
11
|
readBoundedFile
|
|
10
|
-
} from "./index-
|
|
11
|
-
import {
|
|
12
|
-
AtomicFilePublicationError2,
|
|
13
|
-
publishAtomicFile
|
|
14
|
-
} from "./index-b56nnscm.js";
|
|
12
|
+
} from "./index-8x0q6yfb.js";
|
|
15
13
|
import {
|
|
16
14
|
isRecord
|
|
17
15
|
} from "./index-hkxgennw.js";
|
|
@@ -28,15 +28,15 @@ import {
|
|
|
28
28
|
containedEntryMetadata,
|
|
29
29
|
openContainedParentFile
|
|
30
30
|
} from "./index-ww3gss55.js";
|
|
31
|
-
import {
|
|
32
|
-
withSignalDeadline
|
|
33
|
-
} from "./index-9tqbxv5p.js";
|
|
34
31
|
import {
|
|
35
32
|
defineRuntimeTool2
|
|
36
33
|
} from "./index-6k47xdtt.js";
|
|
37
34
|
import {
|
|
38
35
|
errnoOf
|
|
39
36
|
} from "./index-jj9228tt.js";
|
|
37
|
+
import {
|
|
38
|
+
withSignalDeadline
|
|
39
|
+
} from "./index-wqzw3qg9.js";
|
|
40
40
|
import {
|
|
41
41
|
MAX_TIMER_MS
|
|
42
42
|
} from "./index-eemvahkc.js";
|