stitchkit 0.123.7 → 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.
Files changed (104) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/entrypoints/agent-runtime/coding-tools.js +1 -1
  3. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  4. package/dist/entrypoints/agent-runtime/sandbox.js +1 -1
  5. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  6. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  7. package/dist/entrypoints/agent-runtime/testing.js +3 -3
  8. package/dist/entrypoints/agent-runtime.js +3 -3
  9. package/dist/entrypoints/application/diagnostic-journal.js +3 -5
  10. package/dist/entrypoints/application/directory-inbox.js +9 -11
  11. package/dist/entrypoints/application.js +3 -3
  12. package/dist/entrypoints/cli/publish.js +6 -6
  13. package/dist/entrypoints/cli.js +7 -4
  14. package/dist/entrypoints/files.js +5 -5
  15. package/dist/entrypoints/index.js +3 -3
  16. package/dist/entrypoints/server.js +6 -6
  17. package/dist/entrypoints/telegram.js +2 -2
  18. package/dist/entrypoints/tools/connections.d.ts +2 -2
  19. package/dist/entrypoints/tools/connections.d.ts.map +1 -1
  20. package/dist/entrypoints/tools/connections.js +121 -29
  21. package/dist/entrypoints/tools/contract.d.ts +1 -1
  22. package/dist/entrypoints/tools/contract.d.ts.map +1 -1
  23. package/dist/entrypoints/tools/contract.js +3 -1
  24. package/dist/entrypoints/tools/mcp.d.ts +1 -1
  25. package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
  26. package/dist/entrypoints/tools/mcp.js +8 -6
  27. package/dist/entrypoints/tools/toolkit.js +3 -3
  28. package/dist/entrypoints/tools.d.ts +1 -1
  29. package/dist/entrypoints/tools.d.ts.map +1 -1
  30. package/dist/entrypoints/tools.js +25 -30
  31. package/dist/{index-jswst0h3.js → index-03qrr49d.js} +49 -4
  32. package/dist/{index-8yky60kq.js → index-1szhrfsf.js} +5 -7
  33. package/dist/{index-mqttte96.js → index-3ymcmpa9.js} +3 -5
  34. package/dist/{index-v8xm2s9v.js → index-7177dxjn.js} +1 -1
  35. package/dist/{index-2x2ch0bt.js → index-782qtc24.js} +1 -1
  36. package/dist/{index-j8rda9n6.js → index-8pwwd6rp.js} +3 -3
  37. package/dist/{index-m616f0yz.js → index-8x0q6yfb.js} +134 -7
  38. package/dist/{index-1a741dpf.js → index-e1x6vze4.js} +10 -4
  39. package/dist/{index-ezwvsqx9.js → index-fvd6pvw3.js} +1 -1
  40. package/dist/{index-bknzva6n.js → index-gy9x38a2.js} +4 -3
  41. package/dist/{index-w0wy05gr.js → index-jkjh7zw4.js} +50 -40
  42. package/dist/{index-ac6vvm30.js → index-jp2qd9jb.js} +1 -1
  43. package/dist/index-mm89hd8v.js +39 -0
  44. package/dist/{index-jc5xgkpk.js → index-qsm899qp.js} +1 -1
  45. package/dist/index-wqzw3qg9.js +91 -0
  46. package/dist/{index-364k2zwa.js → index-wt6rw7rf.js} +5 -7
  47. package/dist/{index-tt3ej8r3.js → index-x0769xt9.js} +217 -24
  48. package/dist/internal/deadline.d.ts +30 -0
  49. package/dist/internal/deadline.d.ts.map +1 -1
  50. package/dist/internal/pinned-http.d.ts +1 -1
  51. package/dist/internal/pinned-http.d.ts.map +1 -1
  52. package/dist/internal/secure-fetch.d.ts +8 -0
  53. package/dist/internal/secure-fetch.d.ts.map +1 -1
  54. package/dist/tools/cli/inline-files.d.ts +5 -5
  55. package/dist/tools/cli/inline-files.d.ts.map +1 -1
  56. package/dist/tools/cli/resumable-download.d.ts +18 -0
  57. package/dist/tools/cli/resumable-download.d.ts.map +1 -0
  58. package/dist/tools/cli/update.d.ts +18 -0
  59. package/dist/tools/cli/update.d.ts.map +1 -1
  60. package/dist/tools/connections/catalog-cache.d.ts +9 -0
  61. package/dist/tools/connections/catalog-cache.d.ts.map +1 -0
  62. package/dist/tools/connections/errors.d.ts +10 -1
  63. package/dist/tools/connections/errors.d.ts.map +1 -1
  64. package/dist/tools/connections/limits.d.ts +16 -4
  65. package/dist/tools/connections/limits.d.ts.map +1 -1
  66. package/dist/tools/connections/mcp-client.d.ts +10 -2
  67. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  68. package/dist/tools/connections/mcp.d.ts.map +1 -1
  69. package/dist/tools/connections/operation-limits.d.ts +12 -1
  70. package/dist/tools/connections/operation-limits.d.ts.map +1 -1
  71. package/dist/tools/connections/sse-session.d.ts +2 -2
  72. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  73. package/dist/tools/connections/types.d.ts +38 -2
  74. package/dist/tools/connections/types.d.ts.map +1 -1
  75. package/dist/tools/mcp/catalog-stamp.d.ts +47 -0
  76. package/dist/tools/mcp/catalog-stamp.d.ts.map +1 -0
  77. package/dist/tools/mcp/catalog.d.ts +1 -30
  78. package/dist/tools/mcp/catalog.d.ts.map +1 -1
  79. package/dist/tools/mcp/handler.d.ts.map +1 -1
  80. package/dist/tools/mcp/mount.d.ts +6 -1
  81. package/dist/tools/mcp/mount.d.ts.map +1 -1
  82. package/dist/tools/mcp/register.d.ts +1 -1
  83. package/dist/tools/mcp/register.d.ts.map +1 -1
  84. package/dist/tools/mcp/runtime-tools.d.ts +1 -1
  85. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  86. package/dist/tools/transfer/view-file-contract.d.ts +17 -6
  87. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
  88. package/dist/tools/transfer/view-file.d.ts +1 -1
  89. package/dist/tools/transfer/view-file.d.ts.map +1 -1
  90. package/llms/cli.2.txt +60 -6
  91. package/llms/cli.txt +3 -2
  92. package/llms/stitchkit.txt +3 -3
  93. package/llms/tools-connections.txt +5 -3
  94. package/llms/tools-mcp.txt +5 -2
  95. package/llms/tools.2.txt +10 -4
  96. package/llms/tools.3.txt +2 -1
  97. package/llms/tools.txt +10 -3
  98. package/llms/{upgrading-0.106.0-0.123.0.txt → upgrading-0.106.0-0.124.0.txt} +39 -3
  99. package/llms/upgrading.txt +1 -1
  100. package/llms-full.txt +134 -24
  101. package/llms.txt +5 -5
  102. package/package.json +1 -1
  103. package/dist/index-9tqbxv5p.js +0 -44
  104. package/dist/index-b56nnscm.js +0 -132
@@ -0,0 +1,91 @@
1
+ import {
2
+ MAX_TIMER_MS
3
+ } from "./index-eemvahkc.js";
4
+ import {
5
+ assertPositiveSafeInteger
6
+ } from "./index-0s4xebbg.js";
7
+
8
+ // src/internal/deadline.ts
9
+ async function withDeadline(value, timeoutMs) {
10
+ if (!(value instanceof Promise))
11
+ return { settled: true, value };
12
+ let timer;
13
+ const expiry = new Promise((resolve) => {
14
+ timer = setTimeout(() => resolve({ settled: false }), timeoutMs);
15
+ });
16
+ try {
17
+ return await Promise.race([
18
+ value.then((settledValue) => ({
19
+ settled: true,
20
+ value: settledValue
21
+ })),
22
+ expiry
23
+ ]);
24
+ } finally {
25
+ if (timer !== undefined)
26
+ clearTimeout(timer);
27
+ }
28
+ }
29
+ async function withSignalDeadline(timeoutMs, caller, makeReason, body) {
30
+ assertPositiveSafeInteger("Deadline timeoutMs", timeoutMs, RangeError);
31
+ if (timeoutMs > MAX_TIMER_MS)
32
+ throw new RangeError("Deadline timeoutMs exceeds the timer range");
33
+ caller?.throwIfAborted();
34
+ const deadline = new AbortController;
35
+ const timer = setTimeout(() => deadline.abort(makeReason()), timeoutMs);
36
+ const signal = caller ? AbortSignal.any([caller, deadline.signal]) : deadline.signal;
37
+ try {
38
+ return await body(signal);
39
+ } finally {
40
+ clearTimeout(timer);
41
+ }
42
+ }
43
+ async function withIdleDeadline(idleMs, parent, makeReason, body) {
44
+ if (idleMs === undefined)
45
+ return body({ signal: parent, touch: () => {
46
+ return;
47
+ } });
48
+ parent.throwIfAborted();
49
+ const quiet = new AbortController;
50
+ const timer = startIdleTimer(idleMs, () => quiet.abort(makeReason()));
51
+ const signal = AbortSignal.any([parent, quiet.signal]);
52
+ const touch = () => {
53
+ if (!signal.aborted)
54
+ timer.touch();
55
+ };
56
+ try {
57
+ return await body({ signal, touch });
58
+ } finally {
59
+ timer.stop();
60
+ }
61
+ }
62
+ function startIdleTimer(idleMs, onIdle, options = {}) {
63
+ assertPositiveSafeInteger("Idle timer idleMs", idleMs, RangeError);
64
+ if (idleMs > MAX_TIMER_MS)
65
+ throw new RangeError("Idle timer idleMs exceeds the timer range");
66
+ let done = false;
67
+ const arm = () => {
68
+ const handle = setTimeout(() => {
69
+ done = true;
70
+ onIdle();
71
+ }, idleMs);
72
+ if (options.unref)
73
+ handle.unref?.();
74
+ return handle;
75
+ };
76
+ let handle = arm();
77
+ return {
78
+ touch() {
79
+ if (done)
80
+ return;
81
+ clearTimeout(handle);
82
+ handle = arm();
83
+ },
84
+ stop() {
85
+ done = true;
86
+ clearTimeout(handle);
87
+ }
88
+ };
89
+ }
90
+
91
+ export { withDeadline, withSignalDeadline, withIdleDeadline, startIdleTimer };
@@ -5,17 +5,15 @@ import {
5
5
  import {
6
6
  isWithinDir2
7
7
  } from "./index-5cc6r990.js";
8
- import {
9
- BoundedFileReadError,
10
- readBoundedFile
11
- } from "./index-m616f0yz.js";
12
8
  import {
13
9
  writeAllBytes,
14
10
  writeAtomicFileStaged
15
- } from "./index-ac6vvm30.js";
11
+ } from "./index-jp2qd9jb.js";
16
12
  import {
17
- AtomicFilePublicationError2
18
- } from "./index-b56nnscm.js";
13
+ AtomicFilePublicationError2,
14
+ BoundedFileReadError,
15
+ readBoundedFile
16
+ } from "./index-8x0q6yfb.js";
19
17
  import {
20
18
  raceAbort
21
19
  } from "./index-b0kddvzw.js";
@@ -1,17 +1,21 @@
1
1
  import {
2
- withSignalDeadline
3
- } from "./index-9tqbxv5p.js";
2
+ ExclusiveLockError2,
3
+ withExclusiveLock2
4
+ } from "./index-fvd6pvw3.js";
4
5
  import {
5
6
  writeFileAtomicSync2
6
- } from "./index-ac6vvm30.js";
7
+ } from "./index-jp2qd9jb.js";
7
8
  import {
8
9
  fetchGuarded,
9
10
  PrivateAddressRefusal,
10
11
  readCapped
11
- } from "./index-jswst0h3.js";
12
+ } from "./index-03qrr49d.js";
12
13
  import {
13
14
  raceAbort
14
15
  } from "./index-b0kddvzw.js";
16
+ import {
17
+ withSignalDeadline
18
+ } from "./index-wqzw3qg9.js";
15
19
  import {
16
20
  assertPositiveSafeInteger
17
21
  } from "./index-0s4xebbg.js";
@@ -139,8 +143,8 @@ function assertCliPublishable2(previous, next) {
139
143
 
140
144
  // src/tools/cli/update.ts
141
145
  import { createHash as createHash2, randomBytes } from "node:crypto";
142
- import { existsSync, readFileSync, statSync, unlinkSync } from "node:fs";
143
- import { basename, dirname, extname, join } from "node:path";
146
+ import { existsSync as existsSync2, readFileSync as readFileSync2, statSync as statSync2, unlinkSync } from "node:fs";
147
+ import { basename, dirname as dirname2, extname, join } from "node:path";
144
148
 
145
149
  // src/tools/cli/publication-assets.ts
146
150
  import { createHash } from "node:crypto";
@@ -251,10 +255,198 @@ async function decodeCliAsset(transferred, asset, maxBytes, signal) {
251
255
  return { bytes, sha256 };
252
256
  }
253
257
 
258
+ // src/tools/cli/resumable-download.ts
259
+ import { existsSync, mkdirSync, readFileSync, rmSync, statSync } from "node:fs";
260
+ import { open } from "node:fs/promises";
261
+ import { dirname } from "node:path";
262
+ import { z as z3 } from "zod";
263
+ var PartialRecordSchema = z3.object({
264
+ url: z3.string(),
265
+ sha256: z3.string(),
266
+ validator: z3.string().optional()
267
+ });
268
+ async function downloadCliAsset(config, decode) {
269
+ const { partialPath } = config;
270
+ if (partialPath === undefined)
271
+ return decode(await downloadInMemory(config));
272
+ mkdirSync(dirname(partialPath), { recursive: true, mode: 448 });
273
+ try {
274
+ return await withExclusiveLock2(`${partialPath}.lock`, async () => {
275
+ const first = await downloadToPart(config, partialPath, true);
276
+ try {
277
+ return await decodeAndForget(first, partialPath, decode);
278
+ } catch (error) {
279
+ if (!first.continued)
280
+ throw error;
281
+ return decodeAndForget(await downloadToPart(config, partialPath, false), partialPath, decode);
282
+ }
283
+ }, { timeoutMs: 0, label: "CLI update download" });
284
+ } catch (error) {
285
+ if (error instanceof ExclusiveLockError2 && error.code === "LOCK_TIMEOUT") {
286
+ throw new Error(`[stitchkit] update: another update is already downloading into ${partialPath}`, { cause: error });
287
+ }
288
+ throw error;
289
+ }
290
+ }
291
+ async function decodeAndForget(transfer, partialPath, decode) {
292
+ try {
293
+ return await decode(transfer.bytes);
294
+ } finally {
295
+ forgetPart(partialPath);
296
+ }
297
+ }
298
+ async function downloadInMemory(config) {
299
+ const response = await fetchGuarded(config.url, config.allowPrivateHosts, fetchOptions(config));
300
+ if (!response.ok) {
301
+ throw new Error(`[stitchkit] update download responded ${response.status}`);
302
+ }
303
+ const transferred = await readCapped(response, config.maxBytes);
304
+ if (!transferred)
305
+ throw new Error("[stitchkit] update download exceeded the size ceiling");
306
+ return transferred;
307
+ }
308
+ function fetchOptions(config, headers) {
309
+ return {
310
+ timeoutMs: config.timeoutMs,
311
+ bodyTimeoutMs: config.timeoutMs,
312
+ ...config.idleTimeoutMs !== undefined && { idleTimeoutMs: config.idleTimeoutMs },
313
+ ...headers && { headers }
314
+ };
315
+ }
316
+ function recordPath(partialPath) {
317
+ return `${partialPath}.json`;
318
+ }
319
+ function forgetPart(partialPath) {
320
+ rmSync(partialPath, { force: true });
321
+ rmSync(recordPath(partialPath), { force: true });
322
+ }
323
+ function keptLength(config, partialPath) {
324
+ if (!existsSync(partialPath) || !existsSync(recordPath(partialPath))) {
325
+ forgetPart(partialPath);
326
+ return { offset: 0 };
327
+ }
328
+ let record;
329
+ try {
330
+ const parsed = PartialRecordSchema.safeParse(JSON.parse(readFileSync(recordPath(partialPath), "utf8")));
331
+ if (parsed.success)
332
+ record = parsed.data;
333
+ } catch {
334
+ record = undefined;
335
+ }
336
+ if (!record || record.url !== config.url.href || record.sha256 !== config.sha256) {
337
+ forgetPart(partialPath);
338
+ return { offset: 0 };
339
+ }
340
+ const offset = statSync(partialPath).size;
341
+ if (offset > config.maxBytes) {
342
+ forgetPart(partialPath);
343
+ return { offset: 0 };
344
+ }
345
+ return { offset, record };
346
+ }
347
+ function readContentRange(value) {
348
+ if (value === null)
349
+ return null;
350
+ const match = /^bytes\s+(?:(\d+)-\d+|\*)\/(\d+|\*)$/i.exec(value.trim());
351
+ if (!match)
352
+ return null;
353
+ return {
354
+ ...match[1] !== undefined && { start: Number(match[1]) },
355
+ ...match[2] !== "*" && match[2] !== undefined && { total: Number(match[2]) }
356
+ };
357
+ }
358
+ function validatorOf(response) {
359
+ const etag = response.headers.get("etag");
360
+ if (etag && !etag.startsWith("W/"))
361
+ return etag;
362
+ return response.headers.get("last-modified") ?? undefined;
363
+ }
364
+ async function downloadToPart(config, partialPath, resume) {
365
+ if (!resume)
366
+ forgetPart(partialPath);
367
+ const kept = resume ? keptLength(config, partialPath) : { offset: 0 };
368
+ const headers = {};
369
+ if (kept.offset > 0) {
370
+ headers.range = `bytes=${kept.offset}-`;
371
+ if (kept.record?.validator)
372
+ headers["if-range"] = kept.record.validator;
373
+ }
374
+ const response = await fetchGuarded(config.url, config.allowPrivateHosts, fetchOptions(config, headers));
375
+ if (kept.offset > 0 && response.status === 416) {
376
+ await response.body?.cancel().catch(() => {
377
+ return;
378
+ });
379
+ if (readContentRange(response.headers.get("content-range"))?.total === kept.offset) {
380
+ return { bytes: readFileSync(partialPath), continued: true };
381
+ }
382
+ return downloadToPart(config, partialPath, false);
383
+ }
384
+ if (!response.ok) {
385
+ await response.body?.cancel().catch(() => {
386
+ return;
387
+ });
388
+ throw new Error(`[stitchkit] update download responded ${response.status}`);
389
+ }
390
+ let offset = 0;
391
+ if (kept.offset > 0 && response.status === 206) {
392
+ if (readContentRange(response.headers.get("content-range"))?.start !== kept.offset) {
393
+ await response.body?.cancel().catch(() => {
394
+ return;
395
+ });
396
+ return downloadToPart(config, partialPath, false);
397
+ }
398
+ offset = kept.offset;
399
+ } else if (response.status === 206) {
400
+ await response.body?.cancel().catch(() => {
401
+ return;
402
+ });
403
+ throw new Error("[stitchkit] update download answered a range nobody asked for");
404
+ }
405
+ const validator = offset > 0 ? kept.record?.validator : validatorOf(response);
406
+ if (offset === 0)
407
+ rmSync(partialPath, { force: true });
408
+ writeFileAtomicSync2(recordPath(partialPath), JSON.stringify({
409
+ url: config.url.href,
410
+ sha256: config.sha256,
411
+ ...validator !== undefined && { validator }
412
+ }), { mode: 384 });
413
+ await appendBody(response, partialPath, offset, config.maxBytes);
414
+ return { bytes: readFileSync(partialPath), continued: offset > 0 };
415
+ }
416
+ async function appendBody(response, partialPath, offset, maxBytes) {
417
+ const out = await open(partialPath, offset > 0 ? "a" : "w", 384);
418
+ let total = offset;
419
+ try {
420
+ if (response.body) {
421
+ for await (const chunk of response.body) {
422
+ if (total + chunk.byteLength > maxBytes)
423
+ throw new SizeCeilingError;
424
+ await out.write(chunk);
425
+ total += chunk.byteLength;
426
+ }
427
+ }
428
+ } catch (error) {
429
+ await out.close().catch(() => {
430
+ return;
431
+ });
432
+ if (error instanceof SizeCeilingError) {
433
+ forgetPart(partialPath);
434
+ throw new Error("[stitchkit] update download exceeded the size ceiling");
435
+ }
436
+ const reason = error instanceof Error ? error.message : String(error);
437
+ throw new Error(`[stitchkit] update download stopped after ${total} bytes (${reason}); ` + `they are kept in ${partialPath} and the next update continues from there`, { cause: error });
438
+ }
439
+ await out.close();
440
+ }
441
+
442
+ class SizeCeilingError extends Error {
443
+ }
444
+
254
445
  // src/tools/cli/update.ts
255
446
  var DEFAULT_CHECK_TIMEOUT_MS = 2000;
256
447
  var DEFAULT_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
257
- var DEFAULT_DOWNLOAD_TIMEOUT_MS = 120000;
448
+ var DEFAULT_DOWNLOAD_TIMEOUT_MS = 30 * 60 * 1000;
449
+ var DEFAULT_DOWNLOAD_IDLE_TIMEOUT_MS = 30000;
258
450
  var DEFAULT_VERIFY_TIMEOUT_MS = 30000;
259
451
  var MANIFEST_MAX_BYTES = 256 * 1024;
260
452
  var DEFAULT_MAX_ASSET_BYTES = 256 * 1024 * 1024;
@@ -379,17 +571,18 @@ async function applyCliUpdate2(config) {
379
571
  throw new Error("[stitchkit] update: the asset is not one the signed manifest names");
380
572
  }
381
573
  }
382
- const response = await fetchGuarded(new URL(config.asset.url), config.allowPrivateHosts ?? false, {
574
+ const maxBytes = config.maxBytes ?? DEFAULT_MAX_ASSET_BYTES;
575
+ const { bytes, sha256 } = await downloadCliAsset({
576
+ url: new URL(config.asset.url),
577
+ sha256: config.asset.sha256,
578
+ allowPrivateHosts: config.allowPrivateHosts ?? false,
579
+ maxBytes,
383
580
  timeoutMs: config.timeoutMs ?? DEFAULT_DOWNLOAD_TIMEOUT_MS,
384
- bodyTimeoutMs: config.timeoutMs ?? DEFAULT_DOWNLOAD_TIMEOUT_MS
385
- });
386
- if (!response.ok) {
387
- throw new Error(`[stitchkit] update download responded ${response.status}`);
388
- }
389
- const transferred = await readCapped(response, config.maxBytes ?? DEFAULT_MAX_ASSET_BYTES);
390
- if (!transferred)
391
- throw new Error("[stitchkit] update download exceeded the size ceiling");
392
- const { bytes, sha256 } = await decodeCliAsset(transferred, config.asset, config.maxBytes ?? DEFAULT_MAX_ASSET_BYTES);
581
+ ...(config.idleTimeoutMs !== undefined || config.timeoutMs === undefined) && {
582
+ idleTimeoutMs: config.idleTimeoutMs ?? DEFAULT_DOWNLOAD_IDLE_TIMEOUT_MS
583
+ },
584
+ ...config.partialPath !== undefined && { partialPath: config.partialPath }
585
+ }, (transferred) => decodeCliAsset(transferred, config.asset, maxBytes));
393
586
  if (config.verify)
394
587
  await verifyCandidate(target, bytes, config.verify, config.verifyTimeoutMs);
395
588
  const backup = config.backupPath ? keepReplacedBinary(target, config.backupPath) : undefined;
@@ -405,7 +598,7 @@ async function verifyCandidate(target, bytes, verify, timeoutMs = DEFAULT_VERIFY
405
598
  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
406
599
  throw new RangeError("[stitchkit] update: verifyTimeoutMs must be a positive number");
407
600
  }
408
- const candidate = join(dirname(target), `.${basename(target)}.candidate-${randomBytes(8).toString("hex")}${extname(target)}`);
601
+ const candidate = join(dirname2(target), `.${basename(target)}.candidate-${randomBytes(8).toString("hex")}${extname(target)}`);
409
602
  writeFileAtomicSync2(candidate, bytes, { mode: 493 });
410
603
  const controller = new AbortController;
411
604
  let timer;
@@ -434,23 +627,23 @@ async function verifyCandidate(target, bytes, verify, timeoutMs = DEFAULT_VERIFY
434
627
  }
435
628
  }
436
629
  function keepReplacedBinary(target, backupPath) {
437
- if (!existsSync(target))
630
+ if (!existsSync2(target))
438
631
  return;
439
- const previous = readFileSync(target);
440
- writeFileAtomicSync2(backupPath, previous, { mode: statSync(target).mode & 511 });
632
+ const previous = readFileSync2(target);
633
+ writeFileAtomicSync2(backupPath, previous, { mode: statSync2(target).mode & 511 });
441
634
  return { path: backupPath, sha256: createHash2("sha256").update(previous).digest("hex") };
442
635
  }
443
636
  function rollbackCliUpdate2(config) {
444
637
  const target = config.targetPath ?? process.execPath;
445
- if (!existsSync(config.backupPath)) {
638
+ if (!existsSync2(config.backupPath)) {
446
639
  throw new Error(`[stitchkit] rollback: no backup at ${config.backupPath}`);
447
640
  }
448
- const bytes = readFileSync(config.backupPath);
641
+ const bytes = readFileSync2(config.backupPath);
449
642
  const sha256 = createHash2("sha256").update(bytes).digest("hex");
450
643
  if (sha256 !== config.expectedSha256) {
451
644
  throw new Error(`[stitchkit] rollback: backup digest ${sha256} does not match the expected ${config.expectedSha256} — refusing to restore it`);
452
645
  }
453
- writeFileAtomicSync2(target, bytes, { mode: statSync(config.backupPath).mode & 511 });
646
+ writeFileAtomicSync2(target, bytes, { mode: statSync2(config.backupPath).mode & 511 });
454
647
  return { path: target, bytes: bytes.length, sha256 };
455
648
  }
456
649
 
@@ -24,4 +24,34 @@ export declare function withDeadline(value: unknown, timeoutMs: number): Promise
24
24
  * (referenced) timer, so a pending wait keeps the process alive until its deadline.
25
25
  */
26
26
  export declare function withSignalDeadline<T>(timeoutMs: number, caller: AbortSignal | undefined, makeReason: () => unknown, body: (signal: AbortSignal) => Promise<T>): Promise<T>;
27
+ /** The signal and progress hook a body runs under in {@link withIdleDeadline}. */
28
+ export interface IdleDeadline {
29
+ /** Aborts with the parent's reason, or with `makeReason()` when no progress arrives in time. */
30
+ readonly signal: AbortSignal;
31
+ /** Report progress: the quiet period starts again. Does nothing once the body settled. */
32
+ touch(): void;
33
+ }
34
+ /**
35
+ * Run `body` under a deadline that restarts on every `touch()` — "nothing arrived for
36
+ * `idleMs`" rather than "the whole exchange took too long", so a slow transfer that keeps
37
+ * delivering is never cut off while a silent one still ends.
38
+ *
39
+ * With `idleMs` undefined there is no idle timer and `signal` is the parent's own. The timer is
40
+ * cleared on every outcome, and a `touch()` that arrives after the body settled — a read still
41
+ * finishing behind a released await — re-arms nothing, so no timer outlives the call.
42
+ */
43
+ export declare function withIdleDeadline<T>(idleMs: number | undefined, parent: AbortSignal, makeReason: () => unknown, body: (idle: IdleDeadline) => Promise<T>): Promise<T>;
44
+ /** A quiet-period timer: `touch()` restarts it, `stop()` ends it for good. */
45
+ export interface IdleTimer {
46
+ touch(): void;
47
+ stop(): void;
48
+ }
49
+ /**
50
+ * Call `onIdle` once `idleMs` pass without a `touch()`. After `stop()` — or after it fired —
51
+ * nothing re-arms it, so a late `touch()` from a read still draining cannot leave a timer
52
+ * behind. The one timer behind {@link withIdleDeadline} and the guarded fetch's idle bound.
53
+ */
54
+ export declare function startIdleTimer(idleMs: number, onIdle: () => void, options?: {
55
+ unref?: boolean;
56
+ }): IdleTimer;
27
57
  //# sourceMappingURL=deadline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../../src/internal/deadline.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CA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AcZ;AAED,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,IAAI,EAClB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAChC,SAAS,CAwBX"}
@@ -12,7 +12,7 @@ import type { IncomingMessage } from 'node:http';
12
12
  export type PinnedTransport = (url: URL, resolved: {
13
13
  address: string;
14
14
  family: 4 | 6;
15
- }, signal: AbortSignal | undefined) => Promise<Response>;
15
+ }, signal: AbortSignal | undefined, headers?: Record<string, string>) => Promise<Response>;
16
16
  /**
17
17
  * One hop over a socket opened to `resolved.address`: the `Host` header keeps
18
18
  * the URL's host and, for TLS, the certificate is verified against it
@@ -1 +1 @@
1
- {"version":3,"file":"pinned-http.d.ts","sourceRoot":"","sources":["../../src/internal/pinned-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GAAG,CAC5B,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,EAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,KAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,EAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACnC,OAAO,CAAC,QAAQ,CAAC,CAgCnB;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,CA6ClE"}
1
+ {"version":3,"file":"pinned-http.d.ts","sourceRoot":"","sources":["../../src/internal/pinned-http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GAAG,CAC5B,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,EAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,EAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACnC,OAAO,CAAC,QAAQ,CAAC,CAiCnB;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,CA6ClE"}
@@ -43,6 +43,14 @@ export interface GuardedFetchOptions {
43
43
  * body must still end. Default 120 seconds.
44
44
  */
45
45
  bodyTimeoutMs?: number;
46
+ /**
47
+ * End the fetch when nothing arrives for this long — no headers yet, or no body chunk since
48
+ * the last one. A slow download that keeps delivering is never cut off by it; `bodyTimeoutMs`
49
+ * still bounds the whole body. Unset: no idle bound.
50
+ */
51
+ idleTimeoutMs?: number;
52
+ /** Request headers (`Range`, `If-Range`), sent on every hop to the starting URL's origin and dropped on a redirect to another. */
53
+ headers?: Record<string, string>;
46
54
  /** Optional caller cancellation, combined with both deadlines. */
47
55
  signal?: AbortSignal;
48
56
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"secure-fetch.d.ts","sourceRoot":"","sources":["../../src/internal/secure-fetch.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmDrD,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CA8D/C;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;AAED;;;;;;GAMG;AACH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,KACnB,OAAO,CAAC,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAAC;AAQzD,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,GAAG,EACV,YAAY,EAAE,OAAO,EACrB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAuDnB;AAqBD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IA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AsB,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGnF"}
@@ -2,7 +2,6 @@ import { z } from 'zod';
2
2
  declare const InlineFileSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
3
  data: z.ZodString;
4
4
  mimeType: z.ZodString;
5
- name: z.ZodOptional<z.ZodString>;
6
5
  annotations: z.ZodOptional<z.ZodObject<{
7
6
  audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
8
7
  assistant: "assistant";
@@ -10,11 +9,11 @@ declare const InlineFileSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
10
9
  }>>>;
11
10
  priority: z.ZodOptional<z.ZodNumber>;
12
11
  }, z.core.$strip>>;
12
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13
13
  type: z.ZodLiteral<"image">;
14
14
  }, z.core.$strip>, z.ZodObject<{
15
15
  data: z.ZodString;
16
16
  mimeType: z.ZodString;
17
- name: z.ZodOptional<z.ZodString>;
18
17
  annotations: z.ZodOptional<z.ZodObject<{
19
18
  audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
20
19
  assistant: "assistant";
@@ -22,6 +21,7 @@ declare const InlineFileSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
22
21
  }>>>;
23
22
  priority: z.ZodOptional<z.ZodNumber>;
24
23
  }, z.core.$strip>>;
24
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
25
  type: z.ZodLiteral<"audio">;
26
26
  }, z.core.$strip>, z.ZodObject<{
27
27
  type: z.ZodLiteral<"resource">;
@@ -52,9 +52,9 @@ export declare function inlineFileBlocks(data: unknown): InlineFileBlock[];
52
52
  export declare function inlineFileBytes(file: InlineFile, maxBytes: number): Buffer;
53
53
  export declare function inlineFileMimeType(file: InlineFile): string | undefined;
54
54
  /**
55
- * The file name of a block: a media block's `name` or the file name in a resource's URI.
56
- * A block that names no file is `<type>-<sha256 of its bytes><extension>`; a media block
57
- * that names an empty one is refused by the writer like any other unusable name.
55
+ * The file name of a block: a media block's `_meta` file name or the file name in a
56
+ * resource's URI. A block that names no file is `<type>-<sha256 of its bytes><extension>`;
57
+ * a media block that names an empty one is refused by the writer like any other unusable name.
58
58
  */
59
59
  export declare function inlineFileName(file: InlineFile, digest: string): string;
60
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"inline-files.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/inline-files.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAIpB,CAAC;AAEH,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnD,6FAA6F;AAC7F,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,EAAE,CAMjE;AAgCD,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1E;AAWD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,KAAK,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAC1F,OAAO,CAiBT"}
1
+ {"version":3,"file":"inline-files.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/inline-files.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAIpB,CAAC;AAEH,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnD,6FAA6F;AAC7F,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,EAAE,CAMjE;AAgCD,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1E;AAWD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAEvE;AASD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,KAAK,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAC1F,OAAO,CAiBT"}
@@ -0,0 +1,18 @@
1
+ export interface CliAssetDownload {
2
+ url: URL;
3
+ /** The build's digest from the manifest — what makes a kept part this build's part. */
4
+ sha256: string;
5
+ allowPrivateHosts: boolean;
6
+ /** Ceiling on transferred bytes, a continued part included. */
7
+ maxBytes: number;
8
+ timeoutMs: number;
9
+ idleTimeoutMs?: number;
10
+ /** Keep the transfer here between attempts; without it nothing survives a failure. */
11
+ partialPath?: string;
12
+ }
13
+ /**
14
+ * Download the asset and hand it to `decode`, which throws when the bytes are not the build.
15
+ * Returns what `decode` returns.
16
+ */
17
+ export declare function downloadCliAsset<T>(config: CliAssetDownload, decode: (bytes: Uint8Array) => Promise<T>): Promise<T>;
18
+ //# sourceMappingURL=resumable-download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resumable-download.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/resumable-download.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,GAAG,CAAC;IACT,uFAAuF;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,OAAO,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAgCZ"}
@@ -52,7 +52,25 @@ export interface CliUpdateApplyConfig {
52
52
  asset: CliBuildAsset;
53
53
  /** The file to replace; defaults to the running executable. */
54
54
  targetPath?: string;
55
+ /**
56
+ * How long the download may take, in milliseconds — bounding the response headers and,
57
+ * separately, the body. Default 1 800 000 (30 minutes).
58
+ */
55
59
  timeoutMs?: number;
60
+ /**
61
+ * End the download when nothing arrives for this many milliseconds — no response yet, or no
62
+ * chunk since the last one. Default 30 000 when `timeoutMs` is not set either; with a
63
+ * declared `timeoutMs` there is none unless set.
64
+ */
65
+ idleTimeoutMs?: number;
66
+ /**
67
+ * Keep the transfer in this file between attempts, so an interrupted download continues from
68
+ * where it stopped (`Range` with `If-Range`) instead of starting over. A record of what the part
69
+ * holds is kept at `<partialPath>.json`, and `<partialPath>.lock` refuses a second download into
70
+ * the same part. Put it in the application's state directory; both files are removed once the
71
+ * download is decoded, whether it was the build or not. Unset: nothing survives a failure.
72
+ */
73
+ partialPath?: string;
56
74
  maxBytes?: number;
57
75
  allowPrivateHosts?: boolean;
58
76
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/update.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,KAAK,cAAc,EAGpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAUrB,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,mBAAmB,CAAA;C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CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,wGAAwG;IACxG,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0D5F;AAoED,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB,CAchF"}
@@ -0,0 +1,9 @@
1
+ import { type McpCatalogStamp } from '../mcp/catalog-stamp.js';
2
+ import type { McpConnectionCatalogStore } from './types.js';
3
+ /** The `tools/list` result: the stored one when it is the served catalog, else a fresh one. */
4
+ export declare function listMcpCatalog(params: {
5
+ store: McpConnectionCatalogStore | undefined;
6
+ served: McpCatalogStamp | undefined;
7
+ list: () => Promise<unknown>;
8
+ }): Promise<unknown>;
9
+ //# sourceMappingURL=catalog-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-cache.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/catalog-cache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAuB,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAA6B,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAkDpF,+FAA+F;AAC/F,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,KAAK,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAC7C,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9B,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBnB"}
@@ -52,9 +52,17 @@ export declare class ConnectionBudgetExceededError extends Error implements Tool
52
52
  constructor(limit: number, actual: number, unit?: string);
53
53
  [TOOL_ERROR_PROJECTION](): AppError;
54
54
  }
55
+ /** Which deadline ended an operation: the whole exchange's, or the quiet period's. */
56
+ export type ConnectionDeadline = 'total' | 'idle';
57
+ /** Diagnostics of a timeout: the operation, and which of its deadlines fired. */
58
+ export interface ConnectionTimeoutContext extends ConnectionFailureContext {
59
+ /** Defaults to `'total'`. */
60
+ deadline?: ConnectionDeadline;
61
+ }
55
62
  /**
56
63
  * One logical operation exceeded its deadline. The original error remains
57
64
  * available to in-process observers while tools receive its safe projection.
65
+ * `timeoutMs` is the limit that fired — `idleTimeoutMs` when `deadline` is `'idle'`.
58
66
  */
59
67
  export declare class ConnectionTimeoutError extends Error implements ToolErrorProjection {
60
68
  readonly connectionName: string;
@@ -62,7 +70,8 @@ export declare class ConnectionTimeoutError extends Error implements ToolErrorPr
62
70
  readonly operation: ConnectionOperation;
63
71
  readonly phase: ConnectionPhase;
64
72
  readonly observedReadBytes: number;
65
- constructor(connectionName: string, timeoutMs: number, context?: ConnectionFailureContext);
73
+ readonly deadline: ConnectionDeadline;
74
+ constructor(connectionName: string, timeoutMs: number, context?: ConnectionTimeoutContext);
66
75
  [TOOL_ERROR_PROJECTION](): AppError;
67
76
  }
68
77
  /** A raw response body or legacy response frame exceeded its byte ceiling. */