stitchkit 0.120.0 → 0.122.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 (163) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/agent-runtime/browser-control-contract.d.ts +12 -0
  3. package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
  4. package/dist/agent-runtime/coding-discovery.d.ts +25 -0
  5. package/dist/agent-runtime/coding-discovery.d.ts.map +1 -0
  6. package/dist/agent-runtime/coding-search-automaton.d.ts +37 -0
  7. package/dist/agent-runtime/coding-search-automaton.d.ts.map +1 -0
  8. package/dist/agent-runtime/coding-search-case-fold.d.ts +4 -0
  9. package/dist/agent-runtime/coding-search-case-fold.d.ts.map +1 -0
  10. package/dist/agent-runtime/coding-search-class-ranges.d.ts +10 -0
  11. package/dist/agent-runtime/coding-search-class-ranges.d.ts.map +1 -0
  12. package/dist/agent-runtime/coding-search-contract.d.ts +86 -0
  13. package/dist/agent-runtime/coding-search-contract.d.ts.map +1 -0
  14. package/dist/agent-runtime/coding-search-limits.d.ts +13 -0
  15. package/dist/agent-runtime/coding-search-limits.d.ts.map +1 -0
  16. package/dist/agent-runtime/coding-search-matcher.d.ts +33 -0
  17. package/dist/agent-runtime/coding-search-matcher.d.ts.map +1 -0
  18. package/dist/agent-runtime/coding-search-output.d.ts +5 -0
  19. package/dist/agent-runtime/coding-search-output.d.ts.map +1 -0
  20. package/dist/agent-runtime/coding-search-regex-syntax.d.ts +39 -0
  21. package/dist/agent-runtime/coding-search-regex-syntax.d.ts.map +1 -0
  22. package/dist/agent-runtime/coding-search-unit-classes.d.ts +31 -0
  23. package/dist/agent-runtime/coding-search-unit-classes.d.ts.map +1 -0
  24. package/dist/agent-runtime/coding-shell-process.d.ts +1 -0
  25. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  26. package/dist/agent-runtime/coding-tool-contract.d.ts +8 -3
  27. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  28. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
  29. package/dist/agent-runtime/coding-tool-listing.d.ts +1 -11
  30. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  31. package/dist/agent-runtime/coding-tool-paths.d.ts +6 -2
  32. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  33. package/dist/agent-runtime/coding-tool-refusals.d.ts +6 -0
  34. package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
  35. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  36. package/dist/agent-runtime/coding-tool-search.d.ts +113 -0
  37. package/dist/agent-runtime/coding-tool-search.d.ts.map +1 -0
  38. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
  39. package/dist/agent-runtime/contained-scan-budget.d.ts +32 -0
  40. package/dist/agent-runtime/contained-scan-budget.d.ts.map +1 -0
  41. package/dist/agent-runtime/contained-scan-contract.d.ts +52 -0
  42. package/dist/agent-runtime/contained-scan-contract.d.ts.map +1 -0
  43. package/dist/agent-runtime/contained-scan.d.ts +48 -13
  44. package/dist/agent-runtime/contained-scan.d.ts.map +1 -1
  45. package/dist/agent-runtime/control-schema.d.ts +27 -4
  46. package/dist/agent-runtime/control-schema.d.ts.map +1 -1
  47. package/dist/agent-runtime/event-schema.d.ts +33 -0
  48. package/dist/agent-runtime/event-schema.d.ts.map +1 -1
  49. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  50. package/dist/agent-runtime/run-execution-state.d.ts +6 -0
  51. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
  52. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
  53. package/dist/agent-runtime/run-stream-parts.d.ts +11 -0
  54. package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
  55. package/dist/agent-runtime/sandbox.d.ts +5 -1
  56. package/dist/agent-runtime/sandbox.d.ts.map +1 -1
  57. package/dist/agent-runtime/tool-progress.d.ts +21 -0
  58. package/dist/agent-runtime/tool-progress.d.ts.map +1 -0
  59. package/dist/agent-runtime/workspace-glob.d.ts +6 -0
  60. package/dist/agent-runtime/workspace-glob.d.ts.map +1 -0
  61. package/dist/entrypoints/agent-runtime/browser.js +7 -3
  62. package/dist/entrypoints/agent-runtime/coding-tools.js +7 -7
  63. package/dist/entrypoints/agent-runtime/harness.js +8 -8
  64. package/dist/entrypoints/agent-runtime/realtime.js +5 -5
  65. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  66. package/dist/entrypoints/agent-runtime/sqlite/bun.js +9 -9
  67. package/dist/entrypoints/agent-runtime/sqlite/node.js +9 -9
  68. package/dist/entrypoints/agent-runtime/testing.js +9 -9
  69. package/dist/entrypoints/agent-runtime.d.ts +1 -1
  70. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  71. package/dist/entrypoints/agent-runtime.js +15 -13
  72. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  73. package/dist/entrypoints/application/directory-inbox.js +5 -5
  74. package/dist/entrypoints/cli/publish.js +4 -4
  75. package/dist/entrypoints/cli.js +4 -4
  76. package/dist/entrypoints/files.js +4 -4
  77. package/dist/entrypoints/process/owner-loss.js +2 -1
  78. package/dist/entrypoints/process.js +4 -4
  79. package/dist/entrypoints/server.d.ts +1 -0
  80. package/dist/entrypoints/server.d.ts.map +1 -1
  81. package/dist/entrypoints/server.js +112 -47
  82. package/dist/entrypoints/telegram.js +3 -3
  83. package/dist/entrypoints/tools/agent.js +1 -1
  84. package/dist/entrypoints/tools/toolkit.js +5 -5
  85. package/dist/{index-yb9n4pgj.js → index-10rg78vf.js} +1 -1
  86. package/dist/{index-7zwtbak8.js → index-1fyea34p.js} +9 -4
  87. package/dist/{index-3yb5kft5.js → index-4tyt1qya.js} +1 -1
  88. package/dist/{index-8xyf8h2k.js → index-6j15ktag.js} +1 -1
  89. package/dist/{index-zrdcmg6j.js → index-72xtvcvr.js} +40 -6
  90. package/dist/{index-4qnzda76.js → index-7qyv50r4.js} +1 -1
  91. package/dist/{index-qctbzmg9.js → index-am1h8c9v.js} +69 -27
  92. package/dist/{index-e452syyh.js → index-aqmadanx.js} +2 -2
  93. package/dist/{index-yt7gyg5x.js → index-b51tzcgh.js} +1 -1
  94. package/dist/{index-aw6zahv1.js → index-dqpesdck.js} +2 -2
  95. package/dist/{index-1jwsfkfz.js → index-eeahxwvg.js} +60 -76
  96. package/dist/{index-sb9dr3tq.js → index-eh71zr32.js} +4 -4
  97. package/dist/{index-nyyam9ce.js → index-f6pw75e1.js} +1 -1
  98. package/dist/{index-qevqn3d3.js → index-gq3fnq3f.js} +1 -1
  99. package/dist/{index-bz479f0x.js → index-gtx3eknx.js} +1 -1
  100. package/dist/{index-mnkk1ffz.js → index-hs76yzt7.js} +13 -1
  101. package/dist/{index-nn9qvkww.js → index-j95jp7ee.js} +45 -9
  102. package/dist/{index-2kbysk9s.js → index-m5m9rmvt.js} +2 -0
  103. package/dist/{index-r3db01kh.js → index-nwm3ww60.js} +1 -1
  104. package/dist/index-qaqxdbxf.js +2857 -0
  105. package/dist/index-s9a0fjh3.js +305 -0
  106. package/dist/{index-b0w7rbpt.js → index-t05a2ry4.js} +39 -3
  107. package/dist/{index-pq2m7t46.js → index-v8yqk4w7.js} +22 -8
  108. package/dist/internal/contained-directory.d.ts +1 -1
  109. package/dist/internal/contained-directory.d.ts.map +1 -1
  110. package/dist/internal/contained-files.d.ts +18 -51
  111. package/dist/internal/contained-files.d.ts.map +1 -1
  112. package/dist/internal/contained-read.d.ts +17 -0
  113. package/dist/internal/contained-read.d.ts.map +1 -0
  114. package/dist/internal/darwin-binding.d.ts +3 -1
  115. package/dist/internal/darwin-binding.d.ts.map +1 -1
  116. package/dist/process/bun-child.d.ts.map +1 -1
  117. package/dist/process/command-owner.d.ts.map +1 -1
  118. package/dist/process/group.d.ts +2 -0
  119. package/dist/process/group.d.ts.map +1 -1
  120. package/dist/process/launch.d.ts +1 -0
  121. package/dist/process/launch.d.ts.map +1 -1
  122. package/dist/process/owned-child.d.ts.map +1 -1
  123. package/dist/process/owner-loss-guard.d.ts.map +1 -1
  124. package/dist/process/owner-loss-protocol.d.ts +1 -0
  125. package/dist/process/owner-loss-protocol.d.ts.map +1 -1
  126. package/dist/server/openapi-security.d.ts +73 -0
  127. package/dist/server/openapi-security.d.ts.map +1 -0
  128. package/dist/server/openapi.d.ts +12 -0
  129. package/dist/server/openapi.d.ts.map +1 -1
  130. package/dist/tools/agent.d.ts.map +1 -1
  131. package/dist/tools/cli/format.d.ts +11 -2
  132. package/dist/tools/cli/format.d.ts.map +1 -1
  133. package/dist/tools/cli/repeatable-read.d.ts +9 -0
  134. package/dist/tools/cli/repeatable-read.d.ts.map +1 -0
  135. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  136. package/dist/tools/cli/run-native.d.ts.map +1 -1
  137. package/dist/tools/runtime-call-context.d.ts +15 -0
  138. package/dist/tools/runtime-call-context.d.ts.map +1 -0
  139. package/llms/agent-runtime-browser.txt +4 -1
  140. package/llms/agent-runtime-coding-tools.txt +9 -9
  141. package/llms/agent-runtime.2.txt +30 -108
  142. package/llms/agent-runtime.3.txt +111 -1
  143. package/llms/agent-runtime.txt +59 -24
  144. package/llms/application.3.txt +5 -2
  145. package/llms/cli.txt +21 -9
  146. package/llms/contract.txt +1 -1
  147. package/llms/process.txt +3 -1
  148. package/llms/server.2.txt +48 -0
  149. package/llms/server.5.txt +4 -0
  150. package/llms/stitchkit.txt +3 -3
  151. package/llms/tools.txt +4 -1
  152. package/llms/{upgrading-0.106.0-0.120.0.txt → upgrading-0.106.0-0.122.0.txt} +81 -3
  153. package/llms/upgrading.txt +1 -1
  154. package/llms-full.txt +255 -35
  155. package/llms.txt +7 -7
  156. package/native/darwin-arm64.node +0 -0
  157. package/native/darwin-x64.node +0 -0
  158. package/native-assets.json +4 -4
  159. package/package.json +2 -1
  160. package/dist/index-0qyrcjfs.js +0 -1478
  161. package/dist/index-aa50qwv4.js +0 -107
  162. package/dist/tools/durability-context.d.ts +0 -7
  163. package/dist/tools/durability-context.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadDarwinBinding
3
- } from "./index-2kbysk9s.js";
3
+ } from "./index-m5m9rmvt.js";
4
4
  import {
5
5
  errnoOf
6
6
  } from "./index-jj9228tt.js";
@@ -90,6 +90,12 @@ async function openPinnedDirectory(absolute, options = {}, io = { realpath }) {
90
90
  if (process.platform !== "linux" && process.platform !== "darwin") {
91
91
  throw new Error("Contained filesystem operations support Linux and macOS only");
92
92
  }
93
+ if (typeof absolute !== "string") {
94
+ const searchOnly = options.readable === false;
95
+ if (process.platform === "darwin")
96
+ return new NumericFileHandle(loadDarwinBinding().reopenDirectory(absolute.fd, searchOnly));
97
+ return open(`${descriptorPath(absolute)}/.`, directoryFlags(searchOnly));
98
+ }
93
99
  let prefix = path.resolve(absolute);
94
100
  const missing = [];
95
101
  let canonical;
@@ -131,11 +137,8 @@ async function openPinnedDirectory(absolute, options = {}, io = { realpath }) {
131
137
 
132
138
  // src/internal/contained-files.ts
133
139
  import { constants as constants2 } from "node:fs";
134
- import { lstat, open as open2, readdir } from "node:fs/promises";
140
+ import { lstat, open as open2, opendir, readdir } from "node:fs/promises";
135
141
  import path2 from "node:path";
136
- function containedEntryKind(entry) {
137
- return entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
138
- }
139
142
  function sameIdentity(left, right) {
140
143
  return left.dev === right.dev && left.ino === right.ino;
141
144
  }
@@ -177,59 +180,48 @@ async function statAt(directory, name) {
177
180
  throw error;
178
181
  });
179
182
  }
180
- async function listAt(directory) {
183
+ async function listAt(directory, maxEntries, progress) {
184
+ progress?.check();
181
185
  if (process.platform === "darwin") {
182
- return loadDarwinBinding().listAt(directory.fd).map(({ name, mode }) => ({ name, ...entryMetadata(mode) }));
186
+ return loadDarwinBinding().listAt(directory.fd, maxEntries, progress ? (entry) => {
187
+ if (entry)
188
+ progress.entry();
189
+ progress.check();
190
+ } : undefined).map(({ name, mode }) => ({ name, ...entryMetadata(mode) }));
191
+ }
192
+ if (maxEntries !== undefined) {
193
+ const stream = await opendir(descriptorPath(directory), { bufferSize: 1 });
194
+ const entries = [];
195
+ try {
196
+ while (entries.length < maxEntries) {
197
+ progress?.check();
198
+ const entry = await stream.read();
199
+ if (entry)
200
+ progress?.entry();
201
+ progress?.check();
202
+ if (!entry)
203
+ break;
204
+ entries.push(entry);
205
+ }
206
+ return entries;
207
+ } finally {
208
+ await stream.close();
209
+ }
183
210
  }
184
211
  return readdir(descriptorPath(directory), { withFileTypes: true });
185
212
  }
186
- async function listContainedDirectory(root, relative, maxEntries, authorizePath) {
213
+ async function openContainedDirectory(root, relative, beforeOpen) {
187
214
  let current = await openPinnedDirectory(root);
188
215
  try {
189
- if (relative !== ".") {
216
+ if (relative !== ".")
190
217
  for (const segment of safeSegments(relative)) {
218
+ beforeOpen?.();
191
219
  current = await descend(current, await openDirectoryAt(current, segment));
192
220
  }
193
- }
194
- const raw = [...await listAt(current)];
195
- raw.sort((left, right) => left.name.localeCompare(right.name));
196
- const admitted = [];
197
- const denied = [];
198
- for (const entry of raw) {
199
- const entryPath = relative === "." ? entry.name : path2.join(relative, entry.name);
200
- if (authorizePath && !await authorizePath(entryPath)) {
201
- denied.push({ name: entry.name, kind: containedEntryKind(entry) });
202
- continue;
203
- }
204
- admitted.push(entry);
205
- }
206
- const entries = [];
207
- for (const entry of admitted.slice(0, maxEntries)) {
208
- const kind = containedEntryKind(entry);
209
- if (kind !== "file") {
210
- entries.push({ name: entry.name, kind });
211
- continue;
212
- }
213
- const metadata = await statAt(current, entry.name);
214
- entries.push({
215
- name: entry.name,
216
- kind,
217
- ...metadata && { bytes: metadata.size }
218
- });
219
- }
220
- entries.sort((left, right) => {
221
- if (left.kind === right.kind)
222
- return left.name.localeCompare(right.name);
223
- return left.kind === "directory" ? -1 : right.kind === "directory" ? 1 : 0;
224
- });
225
- return {
226
- entries,
227
- truncated: admitted.length > maxEntries,
228
- denied: denied.slice(0, maxEntries),
229
- deniedTruncated: denied.length > maxEntries
230
- };
231
- } finally {
221
+ return current;
222
+ } catch (error) {
232
223
  await current.close();
224
+ throw error;
233
225
  }
234
226
  }
235
227
  async function missingContainedDirectories(root, relative) {
@@ -265,27 +257,41 @@ function alternateSpellings(name) {
265
257
  const swapped = [...name].map((letter) => letter === letter.toLowerCase() ? letter.toUpperCase() : letter.toLowerCase()).join("");
266
258
  return [...new Set([swapped, name.normalize("NFC"), name.normalize("NFD")])].filter((spelling) => spelling !== name);
267
259
  }
268
- async function misspelledContainedSegment(root, relative) {
260
+ async function misspelledContainedSegment(root, relative, progress) {
269
261
  const segments = safeSegments(relative);
270
- let current = await openPinnedDirectory(root);
262
+ const wait = (operation, disposeLate) => progress ? progress.wait(operation, disposeLate) : operation();
263
+ const dispose = (handle) => {
264
+ handle.close().catch(() => {
265
+ return;
266
+ });
267
+ };
268
+ let current = await wait(() => openPinnedDirectory(root), dispose);
271
269
  try {
272
270
  for (const [index, segment] of segments.entries()) {
273
- const exists = async (name) => await statAt(current, name).catch(() => null) !== null;
271
+ progress?.check();
272
+ const exists = async (name) => await wait(() => statAt(current, name).catch(() => null)) !== null;
274
273
  let folded = false;
275
274
  for (const spelling of alternateSpellings(segment)) {
276
275
  folded ||= await exists(spelling);
277
276
  }
278
277
  if (folded && await exists(segment)) {
279
- const stored = (await listAt(current)).some(({ name }) => name === segment);
278
+ const maximum = progress?.remainingEntries();
279
+ const entries = await wait(() => listAt(current, maximum, progress));
280
+ progress?.remainingEntries();
281
+ const stored = entries.some(({ name }) => name === segment);
280
282
  if (!stored)
281
283
  return segment;
282
284
  }
283
285
  if (index === segments.length - 1)
284
286
  return;
285
- const next = await openDirectoryAt(current, segment).catch((error) => {
287
+ progress?.directory();
288
+ const next = await wait(() => openDirectoryAt(current, segment).catch((error) => {
286
289
  if (["ENOENT", "ENOTDIR", "ELOOP"].includes(errnoOf(error) ?? ""))
287
290
  return null;
288
291
  throw error;
292
+ }), (handle) => {
293
+ if (handle)
294
+ dispose(handle);
289
295
  });
290
296
  if (!next)
291
297
  return;
@@ -395,27 +401,5 @@ async function openContainedParentFile(parent) {
395
401
  }
396
402
  return handle;
397
403
  }
398
- async function readContainedUtf8Handle(handle, maxBytes) {
399
- const metadata = await handle.stat();
400
- if (!metadata.isFile())
401
- throw new Error("Contained path is not a regular file");
402
- if (metadata.size > maxBytes)
403
- throw new Error("Contained file exceeds byte budget");
404
- const buffer = Buffer.alloc(metadata.size);
405
- let offset = 0;
406
- while (offset < buffer.byteLength) {
407
- const { bytesRead } = await handle.read(buffer, offset, buffer.byteLength - offset, offset);
408
- if (bytesRead === 0)
409
- break;
410
- offset += bytesRead;
411
- }
412
- if (offset !== metadata.size)
413
- throw new Error("Contained file changed while being read");
414
- return {
415
- text: new TextDecoder("utf-8", { fatal: true }).decode(buffer),
416
- bytes: offset,
417
- mode: metadata.mode
418
- };
419
- }
420
404
 
421
- export { descriptorPath, NumericFileHandle, openDirectoryAt, openPinnedDirectory, isSafeEntryName, openFileAt, listAt, listContainedDirectory, missingContainedDirectories, misspelledContainedSegment, UnapprovedContainedDirectoryError, openContainedParent, openContainedFile, ContainedPathChangedError, assertContainedFileCurrent, assertContainedParentCurrent, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle };
405
+ export { descriptorPath, NumericFileHandle, openDirectoryAt, openPinnedDirectory, isSafeEntryName, openFileAt, listAt, openContainedDirectory, missingContainedDirectories, misspelledContainedSegment, UnapprovedContainedDirectoryError, openContainedParent, openContainedFile, ContainedPathChangedError, assertContainedFileCurrent, assertContainedParentCurrent, containedEntryMetadata, openContainedParentFile };
@@ -1,14 +1,14 @@
1
- // src/tools/durability-context.ts
1
+ // src/tools/runtime-call-context.ts
2
2
  var contexts = new WeakMap;
3
- function createToolDurabilityContext(factory) {
3
+ function createRuntimeToolContext(factory) {
4
4
  const context = {};
5
5
  contexts.set(context, factory);
6
6
  return context;
7
7
  }
8
- function resolveToolDurability(context, callId, signal) {
8
+ function resolveRuntimeToolCall(context, callId, signal) {
9
9
  if (typeof context !== "object" || context === null)
10
10
  return;
11
11
  return contexts.get(context)?.(callId, signal);
12
12
  }
13
13
 
14
- export { createToolDurabilityContext, resolveToolDurability };
14
+ export { createRuntimeToolContext, resolveRuntimeToolCall };
@@ -17,7 +17,7 @@ import {
17
17
  replaceMessage,
18
18
  ArchiveSpillSchema,
19
19
  createAgentRuntimeStore2
20
- } from "./index-yb9n4pgj.js";
20
+ } from "./index-10rg78vf.js";
21
21
 
22
22
  // src/agent-runtime/store-memory.ts
23
23
  import { z as z2 } from "zod";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadDarwinBinding
3
- } from "./index-2kbysk9s.js";
3
+ } from "./index-m5m9rmvt.js";
4
4
  import {
5
5
  errnoOf
6
6
  } from "./index-jj9228tt.js";
@@ -3,7 +3,7 @@ import {
3
3
  ProcessInstanceSchema2,
4
4
  readProcessInstance,
5
5
  probeProcessOwner2
6
- } from "./index-qevqn3d3.js";
6
+ } from "./index-gq3fnq3f.js";
7
7
  import {
8
8
  BoundedFileReadError,
9
9
  readBoundedFile
@@ -86,6 +86,17 @@ var AgentToolStatusEventSchema2 = EventIdentitySchema.extend({
86
86
  input: z.json().optional(),
87
87
  output: z.json().optional()
88
88
  });
89
+ var AGENT_TOOL_PROGRESS_MESSAGE_MAX2 = 280;
90
+ var AgentToolProgressEventSchema2 = EventIdentitySchema.extend({
91
+ type: z.literal("tool-progress"),
92
+ runtimeEpoch: z.string().min(1),
93
+ sequence: z.int().nonnegative(),
94
+ callId: AgentRecordIdSchema2,
95
+ toolName: z.string().min(1),
96
+ message: z.string().max(AGENT_TOOL_PROGRESS_MESSAGE_MAX2).optional(),
97
+ progress: z.number().finite().optional(),
98
+ total: z.number().finite().optional()
99
+ });
89
100
  var AgentTerminalEventSchema2 = EventIdentitySchema.extend({
90
101
  type: z.literal("terminal"),
91
102
  eventId: AgentRecordIdSchema2,
@@ -106,6 +117,7 @@ var AgentRuntimeEventSchema2 = z.discriminatedUnion("type", [
106
117
  AgentRunStateEventSchema2,
107
118
  AgentRunOperationEventSchema2,
108
119
  AgentToolStatusEventSchema2,
120
+ AgentToolProgressEventSchema2,
109
121
  AgentTerminalEventSchema2
110
122
  ]);
111
123
  var AgentRuntimeEventCursorSchema2 = z.object({
@@ -147,4 +159,4 @@ function agentDurableEventId2(type, runId, snapshotVersion) {
147
159
  return `${runId}:${type}:${snapshotVersion}`;
148
160
  }
149
161
 
150
- export { AgentAdmissionEventSchema2, AgentTransientDeltaEventSchema2, AgentReasoningStartEventSchema2, AgentReasoningDeltaEventSchema2, AgentReasoningEndEventSchema2, AgentAttemptResetEventSchema2, AgentCheckpointEventSchema2, AgentRunStateEventSchema2, AgentRunOperationEventSchema2, AgentToolStatusEventSchema2, AgentTerminalEventSchema2, AgentRuntimeEventSchema2, AgentRuntimeEventCursorSchema2, advanceAgentRuntimeEventCursor2, agentDurableEventId2 };
162
+ export { AgentAdmissionEventSchema2, AgentTransientDeltaEventSchema2, AgentReasoningStartEventSchema2, AgentReasoningDeltaEventSchema2, AgentReasoningEndEventSchema2, AgentAttemptResetEventSchema2, AgentCheckpointEventSchema2, AgentRunStateEventSchema2, AgentRunOperationEventSchema2, AgentToolStatusEventSchema2, AGENT_TOOL_PROGRESS_MESSAGE_MAX2, AgentToolProgressEventSchema2, AgentTerminalEventSchema2, AgentRuntimeEventSchema2, AgentRuntimeEventCursorSchema2, advanceAgentRuntimeEventCursor2, agentDurableEventId2 };
@@ -11,7 +11,7 @@ import {
11
11
  spawnBunChild,
12
12
  spawnBunInheritedChild,
13
13
  ownerLossGuardEntry
14
- } from "./index-zrdcmg6j.js";
14
+ } from "./index-72xtvcvr.js";
15
15
  import {
16
16
  errnoOf
17
17
  } from "./index-jj9228tt.js";
@@ -173,7 +173,7 @@ async function waitForProcessGroupExit(pid, deadline, killLiveMembers) {
173
173
  function createCommandDeadline(timeoutMs, reason) {
174
174
  assertPositiveSafeInteger("Command deadline", timeoutMs, RangeError);
175
175
  const controller = new AbortController;
176
- const deadline = performance.now() + timeoutMs;
176
+ let deadline = performance.now() + timeoutMs;
177
177
  let timer;
178
178
  const schedule = () => {
179
179
  const remaining = deadline - performance.now();
@@ -188,6 +188,15 @@ function createCommandDeadline(timeoutMs, reason) {
188
188
  cancel() {
189
189
  if (timer !== undefined)
190
190
  clearTimeout(timer);
191
+ },
192
+ restart(nextMs) {
193
+ assertPositiveSafeInteger("Command deadline", nextMs, RangeError);
194
+ if (controller.signal.aborted)
195
+ return;
196
+ if (timer !== undefined)
197
+ clearTimeout(timer);
198
+ deadline = performance.now() + nextMs;
199
+ schedule();
191
200
  }
192
201
  };
193
202
  }
@@ -440,10 +449,16 @@ function nodeChild(input) {
440
449
  });
441
450
  const [executable, ...args] = ownerLossGuardCommand(input.ownerLoss, input.executable, input.args);
442
451
  const child = spawn(executable, args, {
443
- cwd: input.cwd,
452
+ cwd: input.ownerLoss.cwdDescriptor === undefined ? input.cwd : undefined,
444
453
  env: input.env,
445
454
  detached: input.group,
446
- stdio: ["pipe", "pipe", "pipe", "pipe"]
455
+ stdio: [
456
+ "pipe",
457
+ "pipe",
458
+ "pipe",
459
+ "pipe",
460
+ ...input.ownerLoss.cwdDescriptor === undefined ? [] : [input.ownerLoss.cwdDescriptor]
461
+ ]
447
462
  });
448
463
  const control = child.stdio[3];
449
464
  if (!(control instanceof Duplex)) {
@@ -451,7 +466,12 @@ function nodeChild(input) {
451
466
  throw new Error("Owner-loss guard supplied no control pipe");
452
467
  }
453
468
  attachOwnerLossControl(child, control);
454
- return child;
469
+ const { stdin, stdout, stderr } = child;
470
+ if (!stdin || !stdout || !stderr) {
471
+ abortOwnerLossLaunch(child.pid);
472
+ throw new Error("Owner-loss guard supplied incomplete command pipes");
473
+ }
474
+ return Object.assign(child, { stdin, stdout, stderr });
455
475
  }
456
476
  var INHERITED_OUTPUT = {
457
477
  destroyed: true,
@@ -497,10 +517,16 @@ function spawnInheritedCommand(input) {
497
517
  });
498
518
  const [executable, ...args] = ownerLossGuardCommand(input.ownerLoss, input.executable, input.args);
499
519
  const spawned = spawn(executable, args, {
500
- cwd: input.cwd,
520
+ cwd: input.ownerLoss.cwdDescriptor === undefined ? input.cwd : undefined,
501
521
  env: input.env,
502
522
  detached: input.group,
503
- stdio: ["inherit", "inherit", "inherit", "pipe"]
523
+ stdio: [
524
+ "inherit",
525
+ "inherit",
526
+ "inherit",
527
+ "pipe",
528
+ ...input.ownerLoss.cwdDescriptor === undefined ? [] : [input.ownerLoss.cwdDescriptor]
529
+ ]
504
530
  });
505
531
  const control = spawned.stdio[3];
506
532
  if (!(control instanceof Duplex)) {
@@ -723,7 +749,13 @@ function launchNativeCommand({
723
749
  cwd: options.cwd,
724
750
  env: options.envPolicy === "ambient" ? { ...process.env, ...options.env } : options.env ?? {},
725
751
  group: options.group === "own" && (driver?.group ?? true),
726
- ownerLoss: options.ownerLoss === "terminate" ? { entry: ownerLossGuardEntry(), signalTarget: options.stop.target } : undefined
752
+ ownerLoss: options.ownerLoss === "terminate" || driver?.cwdDescriptor !== undefined ? {
753
+ entry: ownerLossGuardEntry(),
754
+ signalTarget: options.stop.target,
755
+ ...driver?.cwdDescriptor !== undefined && {
756
+ cwdDescriptor: driver.cwdDescriptor
757
+ }
758
+ } : undefined
727
759
  };
728
760
  let inherited;
729
761
  if (!launch) {
@@ -914,6 +946,7 @@ async function terminateOwnedGroup(child, closed, cleanupTimeoutMs) {
914
946
  }
915
947
 
916
948
  // src/process/command-owner.ts
949
+ var GUARD_START_FLOOR_MS = 5000;
917
950
  function startNativeCommand(input, onSpawn, driver) {
918
951
  const options = NativeCommandOptionsSchema.parse(input);
919
952
  options.signal?.throwIfAborted();
@@ -937,7 +970,8 @@ function startNativeCommand(input, onSpawn, driver) {
937
970
  options.signal?.removeEventListener("abort", abort);
938
971
  killOn?.removeEventListener("abort", kill);
939
972
  };
940
- const deadline = timeoutMs === undefined ? undefined : createCommandDeadline(timeoutMs, new NativeCommandError2("COMMAND_LIMIT", "Command deadline exceeded", {
973
+ const guarded = options.ownerLoss === "terminate" || driver?.cwdDescriptor !== undefined;
974
+ const deadline = timeoutMs === undefined ? undefined : createCommandDeadline(guarded ? Math.max(timeoutMs, GUARD_START_FLOOR_MS) : timeoutMs, new NativeCommandError2("COMMAND_LIMIT", "Command deadline exceeded", {
941
975
  reason: "deadline"
942
976
  }));
943
977
  const expired = () => controller.abort(deadline?.signal.reason);
@@ -1038,6 +1072,8 @@ function startNativeCommand(input, onSpawn, driver) {
1038
1072
  ]);
1039
1073
  drains.catch((error) => controller.abort(error));
1040
1074
  const pid = await raceAbort(started, controller.signal);
1075
+ if (timeoutMs !== undefined)
1076
+ deadline?.restart(timeoutMs);
1041
1077
  if (pid !== undefined)
1042
1078
  options.onLeaderStarted?.({ pid });
1043
1079
  admitted.resolve();
@@ -23,6 +23,8 @@ function loadDarwinBinding() {
23
23
  }
24
24
  const methods = [
25
25
  "openDirectoryAt",
26
+ "reopenDirectory",
27
+ "changeDirectory",
26
28
  "openFileAt",
27
29
  "createFileAt",
28
30
  "createDirectoryAt",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-bz479f0x.js";
3
+ } from "./index-gtx3eknx.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-eemvahkc.js";