stitchkit 0.129.0 → 0.130.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 (156) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/agent-executor/acp/v1-connect.d.ts +87 -19
  3. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  4. package/dist/agent-executor/acp/v1-driver.d.ts +4 -2
  5. package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
  6. package/dist/agent-executor/acp/v1-handlers.d.ts +56 -0
  7. package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -0
  8. package/dist/agent-executor/acp/v1-map.d.ts +13 -2
  9. package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
  10. package/dist/agent-executor/acp/v1-permission.d.ts +44 -0
  11. package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -0
  12. package/dist/agent-executor/acp/v1-protocol.d.ts +63 -10
  13. package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
  14. package/dist/agent-executor/acp/v1-session.d.ts +34 -7
  15. package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
  16. package/dist/agent-executor/acp/v1-turn.d.ts +51 -13
  17. package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
  18. package/dist/agent-executor/claude/classify.d.ts +10 -0
  19. package/dist/agent-executor/claude/classify.d.ts.map +1 -1
  20. package/dist/agent-executor/claude/cli-driver.d.ts +4 -1
  21. package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
  22. package/dist/agent-executor/claude/events.d.ts +146 -0
  23. package/dist/agent-executor/claude/events.d.ts.map +1 -0
  24. package/dist/agent-executor/claude/limits.d.ts +7 -1
  25. package/dist/agent-executor/claude/limits.d.ts.map +1 -1
  26. package/dist/agent-executor/claude/protocol.d.ts +49 -9
  27. package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
  28. package/dist/agent-executor/claude/session.d.ts +2 -0
  29. package/dist/agent-executor/claude/session.d.ts.map +1 -1
  30. package/dist/agent-executor/claude-sdk/controls.d.ts +10 -1
  31. package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -1
  32. package/dist/agent-executor/claude-sdk/driver.d.ts +97 -3
  33. package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
  34. package/dist/agent-executor/claude-sdk/probe.d.ts +29 -0
  35. package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -0
  36. package/dist/agent-executor/claude-sdk/query-loop.d.ts +53 -5
  37. package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
  38. package/dist/agent-executor/claude-sdk/query-options.d.ts +2 -0
  39. package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -1
  40. package/dist/agent-executor/claude-sdk/session.d.ts +2 -3
  41. package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
  42. package/dist/agent-executor/claude-sdk/turn-usage.d.ts +81 -0
  43. package/dist/agent-executor/claude-sdk/turn-usage.d.ts.map +1 -0
  44. package/dist/agent-executor/codex/classify.d.ts +4 -0
  45. package/dist/agent-executor/codex/classify.d.ts.map +1 -1
  46. package/dist/agent-executor/codex/connect.d.ts +2 -1
  47. package/dist/agent-executor/codex/connect.d.ts.map +1 -1
  48. package/dist/agent-executor/codex/control-client.d.ts +168 -0
  49. package/dist/agent-executor/codex/control-client.d.ts.map +1 -0
  50. package/dist/agent-executor/codex/driver.d.ts +22 -2
  51. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  52. package/dist/agent-executor/codex/handlers.d.ts +47 -0
  53. package/dist/agent-executor/codex/handlers.d.ts.map +1 -0
  54. package/dist/agent-executor/codex/limits.d.ts.map +1 -1
  55. package/dist/agent-executor/codex/protocol.d.ts +124 -0
  56. package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
  57. package/dist/agent-executor/codex/request-answers.d.ts +101 -0
  58. package/dist/agent-executor/codex/request-answers.d.ts.map +1 -0
  59. package/dist/agent-executor/codex/session-controls.d.ts +91 -51
  60. package/dist/agent-executor/codex/session-controls.d.ts.map +1 -1
  61. package/dist/agent-executor/codex/session.d.ts +34 -12
  62. package/dist/agent-executor/codex/session.d.ts.map +1 -1
  63. package/dist/agent-executor/codex/shared-server.d.ts +29 -0
  64. package/dist/agent-executor/codex/shared-server.d.ts.map +1 -0
  65. package/dist/agent-executor/codex/shared-thread.d.ts +46 -0
  66. package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -0
  67. package/dist/agent-executor/codex/thread-controls.d.ts +128 -0
  68. package/dist/agent-executor/codex/thread-controls.d.ts.map +1 -0
  69. package/dist/agent-executor/codex/turn-input.d.ts +30 -0
  70. package/dist/agent-executor/codex/turn-input.d.ts.map +1 -0
  71. package/dist/agent-executor/contract.d.ts +77 -0
  72. package/dist/agent-executor/contract.d.ts.map +1 -1
  73. package/dist/agent-executor/engine.d.ts +6 -2
  74. package/dist/agent-executor/engine.d.ts.map +1 -1
  75. package/dist/agent-executor/executor-contract.d.ts +54 -0
  76. package/dist/agent-executor/executor-contract.d.ts.map +1 -1
  77. package/dist/agent-executor/handoff-schemas.d.ts +407 -0
  78. package/dist/agent-executor/handoff-schemas.d.ts.map +1 -0
  79. package/dist/agent-executor/handoff.d.ts +12 -0
  80. package/dist/agent-executor/handoff.d.ts.map +1 -0
  81. package/dist/agent-executor/hello.d.ts +72 -0
  82. package/dist/agent-executor/hello.d.ts.map +1 -1
  83. package/dist/agent-executor/image-input.d.ts +22 -0
  84. package/dist/agent-executor/image-input.d.ts.map +1 -1
  85. package/dist/agent-executor/projection.d.ts +2 -2
  86. package/dist/agent-executor/projection.d.ts.map +1 -1
  87. package/dist/agent-executor/session-primitives.d.ts +10 -1
  88. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  89. package/dist/agent-executor/testing/conformance.d.ts.map +1 -1
  90. package/dist/agent-executor/testing/replay-driver.d.ts +41 -0
  91. package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -0
  92. package/dist/agent-executor/testing/replay-gate.d.ts +11 -0
  93. package/dist/agent-executor/testing/replay-gate.d.ts.map +1 -0
  94. package/dist/agent-executor/testing/replay-runner.d.ts +27 -0
  95. package/dist/agent-executor/testing/replay-runner.d.ts.map +1 -0
  96. package/dist/agent-executor/testing/replay-scenarios.d.ts +21 -0
  97. package/dist/agent-executor/testing/replay-scenarios.d.ts.map +1 -0
  98. package/dist/agent-executor/testing/replay-transcript.d.ts +296 -0
  99. package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -0
  100. package/dist/agent-executor/vocabulary.d.ts +135 -0
  101. package/dist/agent-executor/vocabulary.d.ts.map +1 -1
  102. package/dist/agent-runtime/branch-provider.d.ts +2 -2
  103. package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
  104. package/dist/entrypoints/agent-executor/acp.d.ts +4 -1
  105. package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
  106. package/dist/entrypoints/agent-executor/acp.js +847 -214
  107. package/dist/entrypoints/agent-executor/claude-sdk.d.ts +5 -1
  108. package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
  109. package/dist/entrypoints/agent-executor/claude-sdk.js +713 -205
  110. package/dist/entrypoints/agent-executor/claude.js +44 -19
  111. package/dist/entrypoints/agent-executor/codex.d.ts +9 -2
  112. package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
  113. package/dist/entrypoints/agent-executor/codex.js +1775 -359
  114. package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
  115. package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
  116. package/dist/entrypoints/agent-executor/testing.js +1002 -2
  117. package/dist/entrypoints/agent-executor.d.ts +4 -2
  118. package/dist/entrypoints/agent-executor.d.ts.map +1 -1
  119. package/dist/entrypoints/agent-executor.js +411 -23
  120. package/dist/entrypoints/agent-runtime.js +4 -23
  121. package/dist/entrypoints/tools/mcp.d.ts +1 -0
  122. package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
  123. package/dist/entrypoints/tools/mcp.js +1 -1
  124. package/dist/entrypoints/tools/toolkit.js +1 -1
  125. package/dist/{index-wv2amqm4.js → index-2s8sy57y.js} +36 -103
  126. package/dist/{index-afb6z77w.js → index-dbp6xemn.js} +75 -7
  127. package/dist/{index-bjmj2q1z.js → index-jrn3prgm.js} +1 -1
  128. package/dist/index-kne9g2c5.js +30 -0
  129. package/dist/index-p1qmpq0p.js +1300 -0
  130. package/dist/{index-7jqn3b3g.js → index-v759mzed.js} +152 -2
  131. package/dist/{index-cbhxhma2.js → index-x5ayy5bn.js} +1 -0
  132. package/dist/index-y0a4gt1s.js +142 -0
  133. package/dist/tools/internal/rank-tools.d.ts +10 -0
  134. package/dist/tools/internal/rank-tools.d.ts.map +1 -0
  135. package/dist/tools/mcp/handler.d.ts +7 -3
  136. package/dist/tools/mcp/handler.d.ts.map +1 -1
  137. package/dist/tools/mcp/lazy-discovery.d.ts +47 -0
  138. package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -0
  139. package/dist/tools/mcp/mount.d.ts +7 -0
  140. package/dist/tools/mcp/mount.d.ts.map +1 -1
  141. package/dist/tools/mcp/register.d.ts +2 -2
  142. package/dist/tools/mcp/register.d.ts.map +1 -1
  143. package/llms/agent-executor-acp.txt +7 -8
  144. package/llms/agent-executor-claude-sdk.txt +4 -2
  145. package/llms/agent-executor-codex.txt +8 -4
  146. package/llms/agent-executor-testing.txt +5 -1
  147. package/llms/agent-executor.txt +7 -6
  148. package/llms/stitchkit.txt +74 -74
  149. package/llms/tools-mcp.txt +3 -2
  150. package/llms/tools.txt +24 -0
  151. package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.130.0.txt} +30 -3
  152. package/llms/upgrading.txt +1 -1
  153. package/llms-full.txt +159 -97
  154. package/llms.txt +8 -8
  155. package/package.json +1 -1
  156. package/dist/index-y71zn1gw.js +0 -586
@@ -2,24 +2,22 @@ import {
2
2
  createBoundedChannel2
3
3
  } from "./index-09f7w2qq.js";
4
4
  import {
5
+ ExecutorStartupPhaseSchema2,
5
6
  engineEnvironment2
6
- } from "./index-afb6z77w.js";
7
+ } from "./index-dbp6xemn.js";
7
8
  import {
8
9
  runNativeCommand2
9
10
  } from "./index-pzhqydxb.js";
10
11
  import {
11
12
  jsonDataRefusal
12
13
  } from "./index-m6w6jtda.js";
13
- import {
14
- assertPositiveSafeInteger
15
- } from "./index-gr0kxymw.js";
16
14
  import {
17
15
  abortReason,
18
- raceAbort,
19
16
  linkAbortSignals
20
17
  } from "./index-rptj3qnc.js";
21
18
 
22
19
  // src/agent-executor/session-primitives.ts
20
+ import { createHash } from "node:crypto";
23
21
  import { z } from "zod";
24
22
  var TURN_QUEUE = { maxItems: 65536, maxBytes: 64 * 1024 * 1024 };
25
23
  var MAX_DATE_MS = 8640000000000000;
@@ -139,107 +137,42 @@ function safeJsonValue(value) {
139
137
  }
140
138
  return z.json().parse(snapshot.value);
141
139
  }
142
-
143
- // src/agent-executor/image-input.ts
144
- var DEFAULT_MAX_IMAGE_BYTES = 5 * 1024 * 1024;
145
- var CLAUDE_CLI_MAX_LINE_BYTES = 16 * 1024 * 1024;
146
- var SUPPORTED_IMAGE_MEDIA_TYPES = new Set([
147
- "image/png",
148
- "image/jpeg",
149
- "image/gif",
150
- "image/webp"
151
- ]);
152
- function isSupportedImageMediaType(value) {
153
- return value === "image/png" || value === "image/jpeg" || value === "image/gif" || value === "image/webp";
154
- }
155
- function validateImageOptions(options) {
156
- assertPositiveSafeInteger("maxImageBytes", options.maxImageBytes);
157
- }
158
- function bytesToBase64(bytes) {
159
- return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
160
- }
161
- async function resolveImageBytes(reference, options) {
162
- assertPositiveSafeInteger("maxImageBytes", options.maxImageBytes);
163
- let bytes;
140
+ function invokeSafely(invoke) {
164
141
  try {
165
- bytes = await options.resolveFile(reference);
166
- } catch {
167
- throw new Error("Failed to resolve image input");
168
- }
169
- if (!(bytes instanceof Uint8Array)) {
170
- throw new TypeError("resolveFile must return a Uint8Array");
171
- }
172
- if (bytes.byteLength === 0) {
173
- throw new RangeError("The image is empty (0 bytes)");
174
- }
175
- if (bytes.byteLength > options.maxImageBytes) {
176
- throw new RangeError(`The image is ${bytes.byteLength} bytes, over maxImageBytes ${options.maxImageBytes}`);
177
- }
178
- return bytes;
179
- }
180
- async function inlineParts(parts, options) {
181
- const maxImageBytes = options.maxImageBytes ?? DEFAULT_MAX_IMAGE_BYTES;
182
- assertPositiveSafeInteger("maxImageBytes", maxImageBytes);
183
- for (const part of parts) {
184
- if (part.type === "text")
185
- continue;
186
- if (part.type !== "file") {
187
- throw new TypeError(`${options.driverLabel} sends text and images, received ${part.type}`);
188
- }
189
- if (!isSupportedImageMediaType(part.mediaType)) {
190
- throw new TypeError(`${options.driverLabel} sends PNG, JPEG, GIF or WebP images only, received a file of ${part.mediaType}`);
191
- }
192
- if (options.resolveFile === undefined) {
193
- throw new TypeError("An image needs resolveFile to read its bytes");
194
- }
195
- }
196
- const resolved = [];
197
- for (const part of parts) {
198
- if (part.type === "text") {
199
- resolved.push({ type: "text", text: part.text });
200
- continue;
142
+ const result = invoke();
143
+ if (typeof result === "object" && result !== null && "then" in result && typeof result.then === "function") {
144
+ Promise.resolve(result).catch(() => {
145
+ return;
146
+ });
201
147
  }
202
- if (part.type !== "file" || options.resolveFile === undefined)
203
- continue;
204
- const read = resolveImageBytes(part.reference, {
205
- resolveFile: options.resolveFile,
206
- maxImageBytes
207
- });
208
- const bytes = options.signal ? await raceAbort(read, options.signal) : await read;
209
- resolved.push({
210
- type: "image",
211
- mediaType: part.mediaType,
212
- base64: bytesToBase64(bytes)
213
- });
214
- }
215
- return resolved;
148
+ } catch {}
216
149
  }
217
- function assertImageFrameBytes(serialized, maxBytes) {
218
- const byteLength = Buffer.byteLength(serialized);
219
- if (byteLength > maxBytes) {
220
- throw new RangeError(`Turn input frame is ${byteLength} bytes, over the ${maxBytes}-byte frame limit`);
150
+ function emitStartupPhase(callback, phase) {
151
+ if (callback === undefined)
152
+ return;
153
+ const parsed = ExecutorStartupPhaseSchema2.parse(phase);
154
+ invokeSafely(() => callback(parsed));
155
+ }
156
+ function clampUniqueWindowName(prefix, suffix, seenNames, disambiguatorSeed, maxChars = 256) {
157
+ const maxPrefix = Math.max(1, maxChars - suffix.length);
158
+ let candidate = prefix.length > maxPrefix ? `${prefix.slice(0, maxPrefix)}${suffix}`.slice(0, maxChars) : `${prefix}${suffix}`;
159
+ if (!seenNames.has(candidate)) {
160
+ seenNames.add(candidate);
161
+ return candidate;
221
162
  }
222
- }
223
- function imageTurnStarter(options) {
224
- let preparing = false;
225
- return async (input) => {
226
- if (preparing)
227
- throw new Error(options.busyMessage);
228
- options.check(input);
229
- preparing = true;
230
- let parts;
231
- try {
232
- parts = await inlineParts(input.input, {
233
- ...options.imageOptions,
234
- driverLabel: options.driverLabel,
235
- signal: options.signal
236
- });
237
- } finally {
238
- preparing = false;
239
- }
240
- options.check(input);
241
- return await options.dispatch(input, parts);
242
- };
163
+ const digest = createHash("sha256").update(disambiguatorSeed).digest("hex").slice(0, 8);
164
+ const tag = `#${digest}${suffix}`;
165
+ const room = Math.max(1, maxChars - tag.length);
166
+ candidate = `${prefix.slice(0, room)}${tag}`.slice(0, maxChars);
167
+ let index = 2;
168
+ while (seenNames.has(candidate)) {
169
+ const indexedTag = `#${digest}_${index}${suffix}`;
170
+ const indexedRoom = Math.max(1, maxChars - indexedTag.length);
171
+ candidate = `${prefix.slice(0, indexedRoom)}${indexedTag}`.slice(0, maxChars);
172
+ index += 1;
173
+ }
174
+ seenNames.add(candidate);
175
+ return candidate;
243
176
  }
244
177
 
245
178
  // src/agent-executor/engine-requests.ts
@@ -293,4 +226,4 @@ function loseEngineTurn(turn, answer, error) {
293
226
  turn.channel.fail(error);
294
227
  }
295
228
 
296
- export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, DEFAULT_MAX_IMAGE_BYTES, CLAUDE_CLI_MAX_LINE_BYTES, isSupportedImageMediaType, validateImageOptions, bytesToBase64, resolveImageBytes, inlineParts, assertImageFrameBytes, imageTurnStarter, holdEngineRequest, answerEngineRequest, drainEngineRequests, endEngineTurn, loseEngineTurn };
229
+ export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, invokeSafely, emitStartupPhase, clampUniqueWindowName, holdEngineRequest, answerEngineRequest, drainEngineRequests, endEngineTurn, loseEngineTurn };
@@ -43,13 +43,43 @@ var ExecutorRequestResolvedDeltaSchema = z.strictObject({
43
43
  interactionId: z.string().min(1)
44
44
  });
45
45
  var TokenCountSchema = z.int().nonnegative();
46
+ var MAX_MODEL_USAGE_ENTRIES = 64;
47
+ var ExecutorTokenUsageSchema2 = z.strictObject({
48
+ inputTokens: TokenCountSchema.optional(),
49
+ outputTokens: TokenCountSchema.optional(),
50
+ cachedInputTokens: TokenCountSchema.optional(),
51
+ cacheCreationInputTokens: TokenCountSchema.optional(),
52
+ thinkingTokens: TokenCountSchema.optional(),
53
+ totalTokens: TokenCountSchema.optional()
54
+ });
55
+ var ExecutorModelUsageSchema2 = z.strictObject({
56
+ inputTokens: TokenCountSchema,
57
+ outputTokens: TokenCountSchema,
58
+ cacheReadInputTokens: TokenCountSchema.optional(),
59
+ cacheCreationInputTokens: TokenCountSchema.optional(),
60
+ thinkingTokens: TokenCountSchema.optional(),
61
+ cacheCreationEphemeral5mInputTokens: TokenCountSchema.optional(),
62
+ cacheCreationEphemeral1hInputTokens: TokenCountSchema.optional(),
63
+ webSearchRequests: TokenCountSchema.optional(),
64
+ costUsd: z.number().nonnegative().optional(),
65
+ contextWindow: TokenCountSchema.optional(),
66
+ maxOutputTokens: TokenCountSchema.optional(),
67
+ canonicalModel: z.string().min(1).max(256).optional(),
68
+ provider: z.string().min(1).max(128).optional(),
69
+ costBasis: z.enum(["list", "managed", "unknown"]).optional()
70
+ });
46
71
  var ExecutorUsageDeltaSchema = z.strictObject({
47
72
  type: z.literal("usage"),
48
73
  ...base,
49
74
  inputTokens: TokenCountSchema.optional(),
50
75
  outputTokens: TokenCountSchema.optional(),
51
76
  cachedInputTokens: TokenCountSchema.optional(),
52
- costUsd: z.number().nonnegative().optional()
77
+ cacheCreationInputTokens: TokenCountSchema.optional(),
78
+ thinkingTokens: TokenCountSchema.optional(),
79
+ totalTokens: TokenCountSchema.optional(),
80
+ costUsd: z.number().nonnegative().optional(),
81
+ total: ExecutorTokenUsageSchema2.optional(),
82
+ modelUsage: z.record(z.string().min(1).max(256), ExecutorModelUsageSchema2).refine((entries) => Object.keys(entries).length <= MAX_MODEL_USAGE_ENTRIES, `modelUsage must carry at most ${MAX_MODEL_USAGE_ENTRIES} models`).optional()
53
83
  });
54
84
  var ExecutorContextUsageDeltaSchema = z.strictObject({
55
85
  type: z.literal("context-usage"),
@@ -57,10 +87,18 @@ var ExecutorContextUsageDeltaSchema = z.strictObject({
57
87
  usedTokens: TokenCountSchema,
58
88
  windowTokens: TokenCountSchema
59
89
  });
90
+ var ExecutorThreadDispositionSchema2 = z.enum(["reusable", "broken"]);
91
+ var ExecutorStartupPhaseSchema2 = z.string().trim().min(1).max(64);
92
+ var ExecutorStatusDeltaSchema2 = z.strictObject({
93
+ type: z.literal("status"),
94
+ ...base,
95
+ phase: ExecutorStartupPhaseSchema2
96
+ });
60
97
  var ExecutorTurnEndDeltaSchema = z.strictObject({
61
98
  type: z.literal("turn-end"),
62
99
  ...base,
63
- outcome: z.enum(["completed", "interrupted", "failed"])
100
+ outcome: z.enum(["completed", "interrupted", "failed"]),
101
+ threadDisposition: ExecutorThreadDispositionSchema2.optional()
64
102
  });
65
103
  var ExecutorErrorKindSchema2 = z.enum([
66
104
  "authRequired",
@@ -89,6 +127,7 @@ var ExecutorDeltaSchema2 = z.discriminatedUnion("type", [
89
127
  ExecutorRequestResolvedDeltaSchema,
90
128
  ExecutorUsageDeltaSchema,
91
129
  ExecutorContextUsageDeltaSchema,
130
+ ExecutorStatusDeltaSchema2,
92
131
  ExecutorTurnEndDeltaSchema,
93
132
  ExecutorErrorDeltaSchema,
94
133
  ExecutorWindowDeltaSchema
@@ -151,7 +190,11 @@ var TurnReportSchema2 = z2.strictObject({
151
190
  executorSeq: z2.int().positive(),
152
191
  phase: TurnPhaseSchema2,
153
192
  deltas: z2.array(ExecutorDeltaSchema2).max(512),
154
- failure: z2.strictObject({ kind: TurnFailureKindSchema2, message: z2.string().min(1).max(4096) }).optional()
193
+ failure: z2.strictObject({
194
+ kind: TurnFailureKindSchema2,
195
+ message: z2.string().min(1).max(4096),
196
+ threadDisposition: ExecutorThreadDispositionSchema2.optional()
197
+ }).optional()
155
198
  });
156
199
  var TurnReportAckSchema2 = z2.discriminatedUnion("outcome", [
157
200
  z2.strictObject({ outcome: z2.literal("applied"), ackedSeq: z2.int().positive() }),
@@ -166,8 +209,16 @@ var InteractionReplySchema2 = z2.strictObject({
166
209
  turnId: ExecutorIdSchema,
167
210
  interactionId: ExecutorIdSchema,
168
211
  reply: z2.discriminatedUnion("kind", [
169
- z2.strictObject({ kind: z2.literal("approve") }),
170
- z2.strictObject({ kind: z2.literal("deny"), message: z2.string().min(1) }),
212
+ z2.strictObject({
213
+ kind: z2.literal("approve"),
214
+ scope: z2.enum(["once", "session"]).optional(),
215
+ updatedInput: z2.record(z2.string(), z2.json()).optional()
216
+ }),
217
+ z2.strictObject({
218
+ kind: z2.literal("deny"),
219
+ message: z2.string().min(1),
220
+ interrupt: z2.boolean().optional()
221
+ }),
171
222
  z2.strictObject({ kind: z2.literal("input"), value: z2.json() })
172
223
  ])
173
224
  });
@@ -193,6 +244,22 @@ var Name = z3.string().min(1).max(HELLO_LIMITS.name);
193
244
  var Text = z3.string().min(1).max(HELLO_LIMITS.text);
194
245
  var ExecutorEngineSchema2 = z3.enum(["claude-cli", "claude-sdk", "codex", "acp"]);
195
246
  var ExecutorReconcileSchema2 = z3.enum(["client-id", "none"]);
247
+ var ExecutorDriverCapabilitiesSchema2 = z3.strictObject({
248
+ runtimePolicyEnforcement: z3.enum(["native", "client-boundary"]),
249
+ sessionApproval: z3.boolean(),
250
+ interruptOnDeny: z3.boolean(),
251
+ updatedToolInput: z3.boolean(),
252
+ structuredInput: z3.boolean(),
253
+ steer: z3.boolean(),
254
+ fork: z3.boolean(),
255
+ revert: z3.boolean(),
256
+ compact: z3.boolean(),
257
+ injectItems: z3.boolean(),
258
+ backgroundWorkOutlivesTurn: z3.boolean(),
259
+ multiThreadPerProcess: z3.boolean(),
260
+ images: z3.boolean(),
261
+ planLimits: z3.enum(["pull", "passive", "none"])
262
+ });
196
263
  var PlanWindowSchema2 = z3.strictObject({
197
264
  name: Name,
198
265
  usedPercent: z3.number().min(0).max(100),
@@ -226,7 +293,8 @@ var ExecutorEngineInfoSchema2 = z3.strictObject({
226
293
  }),
227
294
  z3.strictObject({ answer: z3.literal("not-asked") }),
228
295
  z3.strictObject({ answer: z3.literal("failed"), error: Text })
229
- ])
296
+ ]),
297
+ capabilities: ExecutorDriverCapabilitiesSchema2.optional()
230
298
  });
231
299
  var ExecutorResumableTurnSchema2 = z3.strictObject({
232
300
  turnId: ExecutorIdSchema,
@@ -316,4 +384,4 @@ function helloProfile2(input) {
316
384
  };
317
385
  }
318
386
 
319
- export { ExecutorRawSchema2, ExecutorErrorKindSchema2, ExecutorDeltaSchema2, ThreadClaimSchema2, ThreadLeaseSchema2, ThreadRenewSchema2, ThreadReleaseSchema2, TurnOfferSchema2, TurnPhaseSchema2, TurnFailureKindSchema2, TurnReportSchema2, TurnReportAckSchema2, TurnInterruptSchema2, InteractionReplySchema2, EXECUTOR_ERRORS2, ExecutorEngineSchema2, ExecutorReconcileSchema2, PlanWindowSchema2, PlanLimitsSchema2, ExecutorProfileSchema2, ExecutorEngineInfoSchema2, ExecutorResumableTurnSchema2, ExecutorHelloSchema2, ExecutorHelloAckSchema2, ExecutorProfileConfigSchema2, engineProfile, CREDENTIAL_VARIABLES2, engineEnvironment2, ownCredentials2, helloProfile2 };
387
+ export { ExecutorRawSchema2, ExecutorTokenUsageSchema2, ExecutorModelUsageSchema2, ExecutorThreadDispositionSchema2, ExecutorStartupPhaseSchema2, ExecutorStatusDeltaSchema2, ExecutorErrorKindSchema2, ExecutorDeltaSchema2, ThreadClaimSchema2, ThreadLeaseSchema2, ThreadRenewSchema2, ThreadReleaseSchema2, TurnOfferSchema2, TurnPhaseSchema2, TurnFailureKindSchema2, TurnReportSchema2, TurnReportAckSchema2, TurnInterruptSchema2, InteractionReplySchema2, EXECUTOR_ERRORS2, ExecutorEngineSchema2, ExecutorReconcileSchema2, ExecutorDriverCapabilitiesSchema2, PlanWindowSchema2, PlanLimitsSchema2, ExecutorProfileSchema2, ExecutorEngineInfoSchema2, ExecutorResumableTurnSchema2, ExecutorHelloSchema2, ExecutorHelloAckSchema2, ExecutorProfileConfigSchema2, engineProfile, CREDENTIAL_VARIABLES2, engineEnvironment2, ownCredentials2, helloProfile2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PlanWindowSchema2,
3
3
  PlanLimitsSchema2
4
- } from "./index-afb6z77w.js";
4
+ } from "./index-dbp6xemn.js";
5
5
 
6
6
  // src/agent-executor/plan-limits.ts
7
7
  function planWindowExpired2(window, now) {
@@ -0,0 +1,30 @@
1
+ // src/tools/internal/rank-tools.ts
2
+ function rankToolsByQuery(query, entries) {
3
+ const phrase = rankByPhrase(query, entries);
4
+ return phrase.length > 0 ? phrase : rankByWords(query, entries);
5
+ }
6
+ function rankByWords(query, entries) {
7
+ const words = [
8
+ ...new Set(query.trim().toLocaleLowerCase().split(/\s+/u).filter((word) => word.length > 0))
9
+ ];
10
+ if (words.length < 2)
11
+ return [];
12
+ return entries.map((entry, order) => {
13
+ const haystack = `${entry.name} ${entry.description}`.toLocaleLowerCase();
14
+ const hits = words.filter((word) => haystack.includes(word)).length;
15
+ return { entry, order, hits };
16
+ }).filter((item) => item.hits > 0).sort((left, right) => right.hits - left.hits || left.order - right.order).map((item) => item.entry);
17
+ }
18
+ function rankByPhrase(query, entries) {
19
+ const needle = query.trim().toLocaleLowerCase();
20
+ if (needle.length === 0)
21
+ return [];
22
+ return entries.map((entry, order) => {
23
+ const name = entry.name.toLocaleLowerCase();
24
+ const description = entry.description.toLocaleLowerCase();
25
+ const score = name === needle ? 0 : name.startsWith(needle) ? 1 : name.split(/[_-]/u).some((token) => token.startsWith(needle)) ? 2 : name.includes(needle) ? 3 : description.includes(needle) ? 4 : 5;
26
+ return { entry, order, score };
27
+ }).filter((item) => item.score < 5).sort((left, right) => left.score - right.score || left.order - right.order).map((item) => item.entry);
28
+ }
29
+
30
+ export { rankToolsByQuery };