stitchkit 0.119.0 → 0.120.0

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 (86) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +10 -7
  3. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
  4. package/dist/entrypoints/agent-runtime/harness.js +4 -4
  5. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  6. package/dist/entrypoints/agent-runtime/sandbox.js +5 -5
  7. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  8. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  9. package/dist/entrypoints/agent-runtime/testing.js +6 -6
  10. package/dist/entrypoints/agent-runtime.js +13 -11
  11. package/dist/entrypoints/application/diagnostic-journal.js +2 -2
  12. package/dist/entrypoints/application/directory-inbox.js +4 -4
  13. package/dist/entrypoints/application.js +6 -6
  14. package/dist/entrypoints/cli/publish.js +4 -4
  15. package/dist/entrypoints/cli.js +7 -7
  16. package/dist/entrypoints/contract.js +4 -4
  17. package/dist/entrypoints/files.js +3 -3
  18. package/dist/entrypoints/http.js +2 -2
  19. package/dist/entrypoints/index.js +2 -2
  20. package/dist/entrypoints/node.js +1 -1
  21. package/dist/entrypoints/process.js +1 -1
  22. package/dist/entrypoints/remote.js +1 -1
  23. package/dist/entrypoints/server.js +11 -11
  24. package/dist/entrypoints/telegram/screens.js +5 -5
  25. package/dist/entrypoints/telegram.js +7 -7
  26. package/dist/entrypoints/testing.js +2 -2
  27. package/dist/entrypoints/tools/agent.d.ts +9 -0
  28. package/dist/entrypoints/tools/agent.d.ts.map +1 -0
  29. package/dist/entrypoints/tools/agent.js +16 -0
  30. package/dist/entrypoints/tools/connections.js +4 -4
  31. package/dist/entrypoints/tools/mcp.js +104 -4
  32. package/dist/entrypoints/tools/toolkit.d.ts +9 -0
  33. package/dist/entrypoints/tools/toolkit.d.ts.map +1 -0
  34. package/dist/entrypoints/tools/toolkit.js +40 -0
  35. package/dist/entrypoints/tools.d.ts +0 -10
  36. package/dist/entrypoints/tools.d.ts.map +1 -1
  37. package/dist/entrypoints/tools.js +25 -69
  38. package/dist/{index-1k18qzqa.js → index-0qyrcjfs.js} +3 -3
  39. package/dist/index-1psbyyhj.js +21 -0
  40. package/dist/index-3prvb42w.js +30 -0
  41. package/dist/{index-ba7are04.js → index-3yb5kft5.js} +1 -1
  42. package/dist/index-568w258r.js +76 -0
  43. package/dist/{index-6a69xzrx.js → index-7zwtbak8.js} +5 -46
  44. package/dist/{index-fcqj44mb.js → index-8ryydawp.js} +4 -4
  45. package/dist/{index-fqd4yqwd.js → index-8xyf8h2k.js} +1 -1
  46. package/dist/{index-6f49krb5.js → index-aa50qwv4.js} +1 -1
  47. package/dist/{index-s20s2mad.js → index-bgcwxhxh.js} +16 -14
  48. package/dist/index-bph35vpy.js +77 -0
  49. package/dist/{index-ynrf908v.js → index-bz479f0x.js} +1 -1
  50. package/dist/{index-q968hy6y.js → index-e452syyh.js} +1 -1
  51. package/dist/index-h1j71dr1.js +48 -0
  52. package/dist/{index-mgb7r8b8.js → index-jswst0h3.js} +1 -1
  53. package/dist/{index-bbvc59gw.js → index-knmnj11j.js} +9 -180
  54. package/dist/{index-57gqaq8b.js → index-nyyam9ce.js} +1 -1
  55. package/dist/{index-s0qjs6ee.js → index-pq2m7t46.js} +9 -81
  56. package/dist/{index-yk4g8805.js → index-pq7rkwkk.js} +1 -30
  57. package/dist/{index-x8d9fdeg.js → index-qctbzmg9.js} +8 -4
  58. package/dist/{index-g444vfz2.js → index-r3db01kh.js} +1 -1
  59. package/dist/index-sb9dr3tq.js +14 -0
  60. package/dist/{index-rxcgp4b9.js → index-yb9n4pgj.js} +1 -1
  61. package/dist/{index-tvtacc9a.js → index-zyc64nbh.js} +1 -34
  62. package/llms/agent-runtime-harness.txt +4 -3
  63. package/llms/agent-runtime-sandbox.txt +1 -1
  64. package/llms/agent-runtime.2.txt +3 -2
  65. package/llms/agent-runtime.3.txt +4 -46
  66. package/llms/agent-runtime.4.txt +113 -0
  67. package/llms/agent-runtime.txt +11 -13
  68. package/llms/cli.txt +1 -1
  69. package/llms/stitchkit.txt +15 -9
  70. package/llms/testing.txt +4 -6
  71. package/llms/tools-agent.txt +24 -0
  72. package/llms/tools-mcp.txt +71 -6
  73. package/llms/tools-toolkit.txt +23 -0
  74. package/llms/tools.2.txt +6 -3
  75. package/llms/tools.3.txt +8 -77
  76. package/llms/tools.txt +8 -8
  77. package/llms/{upgrading-0.106.0-0.119.0.txt → upgrading-0.106.0-0.120.0.txt} +34 -3
  78. package/llms/upgrading.txt +1 -1
  79. package/llms-full.txt +231 -119
  80. package/llms.txt +9 -7
  81. package/package.json +10 -2
  82. package/dist/{index-arjmb6de.js → index-1jwsfkfz.js} +0 -0
  83. package/dist/{index-2dfvv1jg.js → index-2fc1k9k2.js} +0 -0
  84. package/dist/{index-qndsr7f0.js → index-5efrpfmj.js} +3 -3
  85. /package/dist/{index-cyxp8rbf.js → index-mtwh9hyp.js} +0 -0
  86. /package/dist/{index-f4njz9j0.js → index-qevqn3d3.js} +0 -0
@@ -0,0 +1,76 @@
1
+ import {
2
+ DEFAULT_CORS_ALLOW_HEADERS2
3
+ } from "./index-pq7rkwkk.js";
4
+
5
+ // src/server/oauth/metadata.ts
6
+ var PROTECTED_RESOURCE_PATH2 = "/.well-known/oauth-protected-resource";
7
+ function metadataPath(resource) {
8
+ const { pathname } = new URL(resource);
9
+ return pathname === "/" ? PROTECTED_RESOURCE_PATH2 : `${PROTECTED_RESOURCE_PATH2}${pathname}`;
10
+ }
11
+ function protectedResourceMetadataUrl2(resource) {
12
+ return `${new URL(resource).origin}${metadataPath(resource)}`;
13
+ }
14
+ function wwwAuthenticateHeader2(resource) {
15
+ return `Bearer resource_metadata="${protectedResourceMetadataUrl2(resource)}"`;
16
+ }
17
+ var PUBLIC_CORS = {
18
+ "Access-Control-Allow-Origin": "*",
19
+ "Access-Control-Allow-Methods": "GET, OPTIONS",
20
+ "Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS2
21
+ };
22
+ function oauthProtectedResourceRoute2(config) {
23
+ const body = JSON.stringify({
24
+ resource: config.resource,
25
+ authorization_servers: config.authorizationServers,
26
+ ...config.scopesSupported && { scopes_supported: config.scopesSupported },
27
+ bearer_methods_supported: ["header"]
28
+ });
29
+ return {
30
+ method: "ALL",
31
+ path: metadataPath(config.resource),
32
+ handler: (req) => {
33
+ if (req.method === "OPTIONS")
34
+ return new Response(null, { status: 204, headers: PUBLIC_CORS });
35
+ if (req.method !== "GET")
36
+ return new Response("Method Not Allowed", { status: 405 });
37
+ return new Response(body, {
38
+ status: 200,
39
+ headers: { "Content-Type": "application/json", ...PUBLIC_CORS }
40
+ });
41
+ }
42
+ };
43
+ }
44
+
45
+ // src/tools/mcp/progress.ts
46
+ function mcpProgressToken(context) {
47
+ const token = context.mcpReq._meta?.progressToken;
48
+ return typeof token === "string" || typeof token === "number" ? token : undefined;
49
+ }
50
+ function createMcpProgressReporter(context) {
51
+ const token = mcpProgressToken(context);
52
+ if (token === undefined)
53
+ return async () => {
54
+ return;
55
+ };
56
+ let sent = 0;
57
+ let highWater = 0;
58
+ return async (update) => {
59
+ sent += 1;
60
+ const value = update.progress ?? Math.max(sent, highWater + 1);
61
+ highWater = Math.max(highWater, value);
62
+ try {
63
+ await context.mcpReq.notify({
64
+ method: "notifications/progress",
65
+ params: {
66
+ progressToken: token,
67
+ progress: value,
68
+ ...update.total !== undefined && { total: update.total },
69
+ ...update.message !== undefined && { message: update.message }
70
+ }
71
+ });
72
+ } catch {}
73
+ };
74
+ }
75
+
76
+ export { PROTECTED_RESOURCE_PATH2, protectedResourceMetadataUrl2, wwwAuthenticateHeader2, oauthProtectedResourceRoute2, mcpProgressToken, createMcpProgressReporter };
@@ -8,9 +8,11 @@ import {
8
8
  formatToolError
9
9
  } from "./index-ycqhyars.js";
10
10
  import {
11
- AgentToolError2,
12
11
  resolveToolDurability
13
- } from "./index-tvtacc9a.js";
12
+ } from "./index-sb9dr3tq.js";
13
+ import {
14
+ AgentToolError2
15
+ } from "./index-1psbyyhj.js";
14
16
  import {
15
17
  collectToolSurface
16
18
  } from "./index-ff39f9dr.js";
@@ -111,47 +113,4 @@ function mountAgent2(services, config = {}) {
111
113
  return tools;
112
114
  }
113
115
 
114
- // src/tools/manifest.ts
115
- function utf8Length(value) {
116
- return new TextEncoder().encode(JSON.stringify(value)).byteLength;
117
- }
118
- function describeToolCatalog2(config) {
119
- const deferred = new Set(config.deferredNames ?? []);
120
- const entries = collectToolSurface({
121
- surface: config,
122
- transport: config.transport,
123
- extend: config.extend,
124
- flattenUnionInput: config.flattenUnionInput
125
- }).map(({ kind, service, action, mountable }) => {
126
- const schemaBytes = utf8Length(mountable.presentationSchema);
127
- return {
128
- name: mountable.name,
129
- description: mountable.method.desc,
130
- inputSchema: mountable.presentationSchema,
131
- source: { kind, service, action },
132
- schemaBytes,
133
- deferred: deferred.has(mountable.name)
134
- };
135
- });
136
- if (config.maxSchemaBytes !== undefined) {
137
- const total = entries.reduce((sum, entry) => sum + entry.schemaBytes, 0);
138
- if (total > config.maxSchemaBytes) {
139
- throw new TypeError(`Tool catalog schemas use ${total} bytes, exceeding maxSchemaBytes ${config.maxSchemaBytes}`);
140
- }
141
- }
142
- return entries;
143
- }
144
- function buildToolManifest2(config) {
145
- return collectToolSurface({
146
- surface: config,
147
- transport: config.transport,
148
- extend: config.extend,
149
- flattenUnionInput: config.flattenUnionInput
150
- }).map(({ mountable }) => ({
151
- name: mountable.name,
152
- description: mountable.method.desc,
153
- inputSchema: mountable.presentationSchema
154
- }));
155
- }
156
-
157
- export { mountAgent2, describeToolCatalog2, buildToolManifest2 };
116
+ export { mountAgent2 };
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  withSignalDeadline
3
3
  } from "./index-9tqbxv5p.js";
4
+ import {
5
+ writeFileAtomicSync2
6
+ } from "./index-ac6vvm30.js";
4
7
  import {
5
8
  fetchGuarded,
6
9
  PrivateAddressRefusal,
7
10
  readCapped
8
- } from "./index-mgb7r8b8.js";
9
- import {
10
- writeFileAtomicSync2
11
- } from "./index-ac6vvm30.js";
11
+ } from "./index-jswst0h3.js";
12
12
  import {
13
13
  raceAbort
14
14
  } from "./index-b0kddvzw.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-g444vfz2.js";
3
+ } from "./index-r3db01kh.js";
4
4
  import {
5
5
  readBoundedFile
6
6
  } from "./index-m616f0yz.js";
@@ -4,7 +4,7 @@ import {
4
4
  openFileAt,
5
5
  listAt,
6
6
  readContainedUtf8Handle
7
- } from "./index-arjmb6de.js";
7
+ } from "./index-1jwsfkfz.js";
8
8
 
9
9
  // src/agent-runtime/contained-scan.ts
10
10
  import path from "node:path";
@@ -20,6 +20,12 @@ import {
20
20
  import {
21
21
  RELEASE_HEADER2
22
22
  } from "./index-n15jny5b.js";
23
+ import {
24
+ DEFAULT_PROCESS_SIGNALS,
25
+ defaultSignalSource,
26
+ reportSignalError,
27
+ guardSignalCallback
28
+ } from "./index-3prvb42w.js";
23
29
  import {
24
30
  isModuleNotFound
25
31
  } from "./index-srs8hj9c.js";
@@ -32,12 +38,8 @@ import {
32
38
  isOriginAllowed,
33
39
  corsPreflightResponse2,
34
40
  requestCorsHeaders,
35
- applyCors,
36
- DEFAULT_PROCESS_SIGNALS,
37
- defaultSignalSource,
38
- reportSignalError,
39
- guardSignalCallback
40
- } from "./index-yk4g8805.js";
41
+ applyCors
42
+ } from "./index-pq7rkwkk.js";
41
43
  import {
42
44
  runWithRequestContext2,
43
45
  getRequestContext2,
@@ -51,22 +53,22 @@ import {
51
53
  getClientInfo2,
52
54
  parseQueryParams
53
55
  } from "./index-kw1ws0cs.js";
56
+ import {
57
+ isUnsafeKey,
58
+ safeJsonParse
59
+ } from "./index-zsarb5xp.js";
54
60
  import {
55
61
  readBoundedChunks,
56
62
  concatChunks,
57
63
  readBoundedBody2
58
- } from "./index-qndsr7f0.js";
64
+ } from "./index-5efrpfmj.js";
65
+ import {
66
+ assertPositiveSafeInteger
67
+ } from "./index-0s4xebbg.js";
59
68
  import {
60
69
  abortReason,
61
70
  untilAborted
62
71
  } from "./index-a5qr2rj6.js";
63
- import {
64
- isUnsafeKey,
65
- safeJsonParse
66
- } from "./index-zsarb5xp.js";
67
- import {
68
- assertPositiveSafeInteger
69
- } from "./index-0s4xebbg.js";
70
72
  import {
71
73
  AppError2,
72
74
  badRequest2,
@@ -0,0 +1,77 @@
1
+ import {
2
+ sleep
3
+ } from "./index-eemvahkc.js";
4
+
5
+ // src/tools/operations/wait-core.ts
6
+ var DEFAULT_BACKOFF = [2, 3, 5, 5, 8, 10];
7
+ var DEFAULT_TIMEOUT = 600;
8
+
9
+ class WaitTimeoutError extends Error {
10
+ constructor() {
11
+ super("wait deadline elapsed before the first snapshot");
12
+ this.name = "WaitTimeoutError";
13
+ }
14
+ }
15
+ async function pollUntil(params) {
16
+ const backoff = params.backoff?.length ? params.backoff : DEFAULT_BACKOFF;
17
+ const lastBackoff = backoff[backoff.length - 1] ?? 5;
18
+ const timeoutSec = params.timeoutSec ?? DEFAULT_TIMEOUT;
19
+ const pause = params.sleepFn ?? sleep;
20
+ const now = params.nowFn ?? (() => performance.now());
21
+ const startedAt = now();
22
+ const deadline = startedAt + timeoutSec * 1000;
23
+ let last;
24
+ for (let attempt = 0;; attempt++) {
25
+ params.signal?.throwIfAborted();
26
+ const remainingBeforePoll = Math.max(0, deadline - now());
27
+ if (remainingBeforePoll === 0 && last) {
28
+ return { state: last.state, timedOut: true };
29
+ }
30
+ const deadlineController = new AbortController;
31
+ const onCallerAbort = () => deadlineController.abort(params.signal?.reason);
32
+ params.signal?.addEventListener("abort", onCallerAbort, { once: true });
33
+ const deadlineTimer = setTimeout(() => deadlineController.abort(new WaitTimeoutError), remainingBeforePoll);
34
+ deadlineTimer.unref?.();
35
+ let state;
36
+ try {
37
+ state = await params.poll(deadlineController.signal);
38
+ } catch (error) {
39
+ if (params.signal?.aborted)
40
+ throw params.signal.reason ?? error;
41
+ if (deadlineController.signal.aborted && now() >= deadline) {
42
+ if (last)
43
+ return { state: last.state, timedOut: true };
44
+ throw new WaitTimeoutError;
45
+ }
46
+ throw error;
47
+ } finally {
48
+ clearTimeout(deadlineTimer);
49
+ params.signal?.removeEventListener("abort", onCallerAbort);
50
+ }
51
+ params.signal?.throwIfAborted();
52
+ last = { state };
53
+ if (params.done(state))
54
+ return { state, timedOut: false };
55
+ const elapsedMs = now() - startedAt;
56
+ const elapsedSec = elapsedMs / 1000;
57
+ params.onTick?.(attempt + 1, elapsedSec);
58
+ if (elapsedSec >= timeoutSec)
59
+ return { state, timedOut: true };
60
+ const waitSec = backoff[Math.min(attempt, backoff.length - 1)] ?? lastBackoff;
61
+ await pause(Math.min(waitSec * 1000, Math.max(0, deadline - now())), params.signal);
62
+ }
63
+ }
64
+ function runWaitOperation(params) {
65
+ return pollUntil({
66
+ poll: (signal) => params.poll(params.input, signal),
67
+ done: params.done,
68
+ backoff: params.backoff,
69
+ timeoutSec: params.timeoutSec,
70
+ sleepFn: params.sleepFn,
71
+ onTick: params.onTick,
72
+ signal: params.signal,
73
+ nowFn: params.nowFn
74
+ });
75
+ }
76
+
77
+ export { WaitTimeoutError, pollUntil, runWaitOperation };
@@ -3,7 +3,7 @@ import {
3
3
  ProcessInstanceSchema2,
4
4
  readProcessInstance,
5
5
  probeProcessOwner2
6
- } from "./index-f4njz9j0.js";
6
+ } from "./index-qevqn3d3.js";
7
7
  import {
8
8
  BoundedFileReadError,
9
9
  readBoundedFile
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  descriptorPath,
6
6
  NumericFileHandle
7
- } from "./index-arjmb6de.js";
7
+ } from "./index-1jwsfkfz.js";
8
8
  import {
9
9
  stagingName
10
10
  } from "./index-tt30h7mr.js";
@@ -0,0 +1,48 @@
1
+ import {
2
+ collectToolSurface
3
+ } from "./index-ff39f9dr.js";
4
+
5
+ // src/tools/manifest.ts
6
+ function utf8Length(value) {
7
+ return new TextEncoder().encode(JSON.stringify(value)).byteLength;
8
+ }
9
+ function describeToolCatalog2(config) {
10
+ const deferred = new Set(config.deferredNames ?? []);
11
+ const entries = collectToolSurface({
12
+ surface: config,
13
+ transport: config.transport,
14
+ extend: config.extend,
15
+ flattenUnionInput: config.flattenUnionInput
16
+ }).map(({ kind, service, action, mountable }) => {
17
+ const schemaBytes = utf8Length(mountable.presentationSchema);
18
+ return {
19
+ name: mountable.name,
20
+ description: mountable.method.desc,
21
+ inputSchema: mountable.presentationSchema,
22
+ source: { kind, service, action },
23
+ schemaBytes,
24
+ deferred: deferred.has(mountable.name)
25
+ };
26
+ });
27
+ if (config.maxSchemaBytes !== undefined) {
28
+ const total = entries.reduce((sum, entry) => sum + entry.schemaBytes, 0);
29
+ if (total > config.maxSchemaBytes) {
30
+ throw new TypeError(`Tool catalog schemas use ${total} bytes, exceeding maxSchemaBytes ${config.maxSchemaBytes}`);
31
+ }
32
+ }
33
+ return entries;
34
+ }
35
+ function buildToolManifest2(config) {
36
+ return collectToolSurface({
37
+ surface: config,
38
+ transport: config.transport,
39
+ extend: config.extend,
40
+ flattenUnionInput: config.flattenUnionInput
41
+ }).map(({ mountable }) => ({
42
+ name: mountable.name,
43
+ description: mountable.method.desc,
44
+ inputSchema: mountable.presentationSchema
45
+ }));
46
+ }
47
+
48
+ export { describeToolCatalog2, buildToolManifest2 };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-b0kddvzw.js";
4
4
  import {
5
5
  readBoundedChunks
6
- } from "./index-qndsr7f0.js";
6
+ } from "./index-5efrpfmj.js";
7
7
 
8
8
  // src/internal/secure-fetch.ts
9
9
  import { lookup } from "node:dns/promises";
@@ -19,16 +19,17 @@ import {
19
19
  createToolRunner,
20
20
  formatToolError
21
21
  } from "./index-ycqhyars.js";
22
- import {
23
- DEFAULT_CORS_ALLOW_HEADERS2,
24
- DEFAULT_PROCESS_SIGNALS,
25
- defaultSignalSource,
26
- reportSignalError,
27
- guardSignalCallback
28
- } from "./index-yk4g8805.js";
29
22
  import {
30
23
  redact2
31
24
  } from "./index-e6c2spsd.js";
25
+ import {
26
+ argumentsDigest
27
+ } from "./index-r7a7r7ha.js";
28
+ import {
29
+ wwwAuthenticateHeader2,
30
+ mcpProgressToken,
31
+ createMcpProgressReporter
32
+ } from "./index-568w258r.js";
32
33
  import {
33
34
  collectToolSurface
34
35
  } from "./index-ff39f9dr.js";
@@ -42,9 +43,6 @@ import {
42
43
  import {
43
44
  AppError2
44
45
  } from "./index-qcn84byh.js";
45
- import {
46
- argumentsDigest
47
- } from "./index-r7a7r7ha.js";
48
46
  import {
49
47
  compareCodeUnits,
50
48
  serializeCanonicalJson
@@ -56,46 +54,6 @@ import {
56
54
  isRecord
57
55
  } from "./index-9jfdm5tg.js";
58
56
 
59
- // src/server/oauth/metadata.ts
60
- var PROTECTED_RESOURCE_PATH2 = "/.well-known/oauth-protected-resource";
61
- function metadataPath(resource) {
62
- const { pathname } = new URL(resource);
63
- return pathname === "/" ? PROTECTED_RESOURCE_PATH2 : `${PROTECTED_RESOURCE_PATH2}${pathname}`;
64
- }
65
- function protectedResourceMetadataUrl2(resource) {
66
- return `${new URL(resource).origin}${metadataPath(resource)}`;
67
- }
68
- function wwwAuthenticateHeader2(resource) {
69
- return `Bearer resource_metadata="${protectedResourceMetadataUrl2(resource)}"`;
70
- }
71
- var PUBLIC_CORS = {
72
- "Access-Control-Allow-Origin": "*",
73
- "Access-Control-Allow-Methods": "GET, OPTIONS",
74
- "Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS2
75
- };
76
- function oauthProtectedResourceRoute2(config) {
77
- const body = JSON.stringify({
78
- resource: config.resource,
79
- authorization_servers: config.authorizationServers,
80
- ...config.scopesSupported && { scopes_supported: config.scopesSupported },
81
- bearer_methods_supported: ["header"]
82
- });
83
- return {
84
- method: "ALL",
85
- path: metadataPath(config.resource),
86
- handler: (req) => {
87
- if (req.method === "OPTIONS")
88
- return new Response(null, { status: 204, headers: PUBLIC_CORS });
89
- if (req.method !== "GET")
90
- return new Response("Method Not Allowed", { status: 405 });
91
- return new Response(body, {
92
- status: 200,
93
- headers: { "Content-Type": "application/json", ...PUBLIC_CORS }
94
- });
95
- }
96
- };
97
- }
98
-
99
57
  // src/tools/mcp/app.ts
100
58
  import { readFileSync } from "node:fs";
101
59
  import { fileURLToPath } from "node:url";
@@ -301,39 +259,6 @@ import {
301
259
  CLIENT_INFO_META_KEY,
302
260
  PROTOCOL_VERSION_META_KEY
303
261
  } from "@modelcontextprotocol/server";
304
-
305
- // src/tools/mcp/progress.ts
306
- function mcpProgressToken(context) {
307
- const token = context.mcpReq._meta?.progressToken;
308
- return typeof token === "string" || typeof token === "number" ? token : undefined;
309
- }
310
- function createMcpProgressReporter(context) {
311
- const token = mcpProgressToken(context);
312
- if (token === undefined)
313
- return async () => {
314
- return;
315
- };
316
- let sent = 0;
317
- let highWater = 0;
318
- return async (update) => {
319
- sent += 1;
320
- const value = update.progress ?? Math.max(sent, highWater + 1);
321
- highWater = Math.max(highWater, value);
322
- try {
323
- await context.mcpReq.notify({
324
- method: "notifications/progress",
325
- params: {
326
- progressToken: token,
327
- progress: value,
328
- ...update.total !== undefined && { total: update.total },
329
- ...update.message !== undefined && { message: update.message }
330
- }
331
- });
332
- } catch {}
333
- };
334
- }
335
-
336
- // src/tools/mcp/round-context.ts
337
262
  function transportContext(context, toolName, outcome, round) {
338
263
  const protocolVersionValue = isRecord(context.mcpReq.envelope) ? Reflect.get(context.mcpReq.envelope, PROTOCOL_VERSION_META_KEY) : undefined;
339
264
  const protocolVersion = typeof protocolVersionValue === "string" ? protocolVersionValue : undefined;
@@ -1062,100 +987,4 @@ async function createStdioMcpServer2(config) {
1062
987
  });
1063
988
  }
1064
989
 
1065
- // src/tools/mcp/stdio-signals.ts
1066
- var bound = new WeakSet;
1067
- function bindStdioProcessSignals2(handle, options = {}) {
1068
- if (bound.has(handle)) {
1069
- throw new Error("[stitchkit] bindStdioProcessSignals: this stdio handle is already bound; close the first binding before creating another");
1070
- }
1071
- bound.add(handle);
1072
- const signals = [...new Set(options.signals ?? DEFAULT_PROCESS_SIGNALS)];
1073
- const source = options.signalSource ?? defaultSignalSource;
1074
- const handlers = [];
1075
- let started = false;
1076
- let sameTurnAsStart = false;
1077
- let closed = false;
1078
- let resolveChain = () => {
1079
- return;
1080
- };
1081
- let rejectChain = () => {
1082
- return;
1083
- };
1084
- const promise = new Promise((resolve, reject) => {
1085
- resolveChain = resolve;
1086
- rejectChain = reject;
1087
- });
1088
- promise.catch(() => {
1089
- return;
1090
- });
1091
- const removeListeners = () => {
1092
- if (closed)
1093
- return;
1094
- closed = true;
1095
- for (const [signal, handler] of handlers)
1096
- source.off(signal, handler);
1097
- if (!started)
1098
- bound.delete(handle);
1099
- };
1100
- const close = () => {
1101
- const hadStarted = started;
1102
- removeListeners();
1103
- if (!hadStarted)
1104
- resolveChain();
1105
- };
1106
- const run = async (signal) => {
1107
- try {
1108
- await options.onClose?.(signal);
1109
- } catch (error) {
1110
- reportSignalError("prepare", error, options.onError);
1111
- }
1112
- try {
1113
- await handle.close();
1114
- } catch (error) {
1115
- rejectChain(error);
1116
- reportSignalError("close", error, options.onError);
1117
- removeListeners();
1118
- return;
1119
- }
1120
- resolveChain();
1121
- try {
1122
- await options.onComplete?.();
1123
- } catch (error) {
1124
- reportSignalError("complete", error, options.onError);
1125
- } finally {
1126
- removeListeners();
1127
- }
1128
- };
1129
- const onSignal = (signal) => {
1130
- if (!started) {
1131
- started = true;
1132
- sameTurnAsStart = true;
1133
- queueMicrotask(() => {
1134
- sameTurnAsStart = false;
1135
- });
1136
- run(signal).catch((error) => reportSignalError("close", error, options.onError));
1137
- return;
1138
- }
1139
- if (sameTurnAsStart)
1140
- return;
1141
- removeListeners();
1142
- guardSignalCallback(() => options.onRepeatedSignal?.(signal), "close", options.onError);
1143
- let restored = false;
1144
- try {
1145
- restored = source.raiseDefault(signal);
1146
- } catch (error) {
1147
- reportSignalError("close", error, options.onError);
1148
- }
1149
- if (!restored) {
1150
- guardSignalCallback(() => options.onEscalationBlocked?.(signal), "close", options.onError);
1151
- }
1152
- };
1153
- for (const signal of signals) {
1154
- const handler = () => onSignal(signal);
1155
- handlers.push([signal, handler]);
1156
- source.on(signal, handler);
1157
- }
1158
- return { promise, close };
1159
- }
1160
-
1161
- export { PROTECTED_RESOURCE_PATH2, protectedResourceMetadataUrl2, wwwAuthenticateHeader2, oauthProtectedResourceRoute2, RESOURCE_MIME_TYPE2, EXT_APPS_BUNDLE_PLACEHOLDER2, inlineMcpAppBundle2, MCP_CATALOG_META_KEY2, mcpCatalogMeta2, readMcpCatalogStamp2, createMcpProgressReporter, validateMcpSchemas2, mountMcp2, buildMcpServer2, mountMcpResource2, createMcpHandler2, createMcpHttpRoute2, createStdioMcpServer2, bindStdioProcessSignals2 };
990
+ export { RESOURCE_MIME_TYPE2, EXT_APPS_BUNDLE_PLACEHOLDER2, inlineMcpAppBundle2, MCP_CATALOG_META_KEY2, mcpCatalogMeta2, readMcpCatalogStamp2, validateMcpSchemas2, mountMcp2, buildMcpServer2, mountMcpResource2, createMcpHandler2, createMcpHttpRoute2, createStdioMcpServer2 };
@@ -17,7 +17,7 @@ import {
17
17
  replaceMessage,
18
18
  ArchiveSpillSchema,
19
19
  createAgentRuntimeStore2
20
- } from "./index-rxcgp4b9.js";
20
+ } from "./index-yb9n4pgj.js";
21
21
 
22
22
  // src/agent-runtime/store-memory.ts
23
23
  import { z as z2 } from "zod";