stitchkit 0.127.0 → 0.128.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 (233) hide show
  1. package/CHANGELOG.md +137 -6
  2. package/dist/agent-executor/acp/v1-connect.d.ts +9 -1
  3. package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
  4. package/dist/agent-executor/acp/v1-driver.d.ts +8 -2
  5. package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
  6. package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
  7. package/dist/agent-executor/acp/v1-session.d.ts +8 -0
  8. package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
  9. package/dist/agent-executor/claude/cli-driver.d.ts +4 -0
  10. package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
  11. package/dist/agent-executor/claude/protocol.d.ts +20 -2
  12. package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
  13. package/dist/agent-executor/claude/session.d.ts +2 -1
  14. package/dist/agent-executor/claude/session.d.ts.map +1 -1
  15. package/dist/agent-executor/claude/transcript.d.ts +7 -4
  16. package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
  17. package/dist/agent-executor/claude-sdk/driver.d.ts +4 -0
  18. package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
  19. package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
  20. package/dist/agent-executor/codex/driver.d.ts +4 -0
  21. package/dist/agent-executor/codex/driver.d.ts.map +1 -1
  22. package/dist/agent-executor/codex/protocol.d.ts +26 -2
  23. package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
  24. package/dist/agent-executor/codex/session.d.ts +3 -1
  25. package/dist/agent-executor/codex/session.d.ts.map +1 -1
  26. package/dist/agent-executor/image-input.d.ts +71 -0
  27. package/dist/agent-executor/image-input.d.ts.map +1 -0
  28. package/dist/agent-executor/session-primitives.d.ts +0 -3
  29. package/dist/agent-executor/session-primitives.d.ts.map +1 -1
  30. package/dist/agent-runtime/agent-tool.d.ts +21 -7
  31. package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
  32. package/dist/agent-runtime/branch-contract.d.ts +1 -0
  33. package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
  34. package/dist/agent-runtime/branch-identities.d.ts +5 -2
  35. package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
  36. package/dist/agent-runtime/branch-messages.d.ts +9 -9
  37. package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
  38. package/dist/agent-runtime/branch-observations.d.ts +45 -32
  39. package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
  40. package/dist/agent-runtime/branch-provider.d.ts +12 -6
  41. package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
  42. package/dist/agent-runtime/branch-source.d.ts +13 -1
  43. package/dist/agent-runtime/branch-source.d.ts.map +1 -1
  44. package/dist/agent-runtime/child-tools.d.ts +64 -0
  45. package/dist/agent-runtime/child-tools.d.ts.map +1 -1
  46. package/dist/agent-runtime/event-search-tools.d.ts +82 -5
  47. package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
  48. package/dist/agent-runtime/invocation-attempt.d.ts +1 -1
  49. package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
  50. package/dist/agent-runtime/invocation-payload.d.ts +12 -0
  51. package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
  52. package/dist/agent-runtime/invocation-read.d.ts +6 -3
  53. package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
  54. package/dist/agent-runtime/invocation-schema.d.ts +50 -8
  55. package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
  56. package/dist/agent-runtime/invocations.d.ts +20 -9
  57. package/dist/agent-runtime/invocations.d.ts.map +1 -1
  58. package/dist/agent-runtime/postgres.d.ts.map +1 -1
  59. package/dist/agent-runtime/schedule-tools.d.ts +30 -0
  60. package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
  61. package/dist/agent-runtime/schemas-invocation-payload.d.ts +48 -0
  62. package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
  63. package/dist/agent-runtime/sql-events.d.ts.map +1 -1
  64. package/dist/agent-runtime/sql-session.d.ts +11 -0
  65. package/dist/agent-runtime/sql-session.d.ts.map +1 -1
  66. package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
  67. package/dist/agent-runtime/state-tools.d.ts +55 -0
  68. package/dist/agent-runtime/state-tools.d.ts.map +1 -1
  69. package/dist/agent-runtime/store-branch.d.ts.map +1 -1
  70. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
  71. package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
  72. package/dist/agent-runtime/store-create.d.ts.map +1 -1
  73. package/dist/agent-runtime/store-driver-contract.d.ts +12 -0
  74. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  75. package/dist/agent-runtime/store-memory-events.d.ts.map +1 -1
  76. package/dist/agent-runtime/store.d.ts +7 -0
  77. package/dist/agent-runtime/store.d.ts.map +1 -1
  78. package/dist/declaration/declaration.d.ts +6 -3
  79. package/dist/declaration/declaration.d.ts.map +1 -1
  80. package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
  81. package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
  82. package/dist/entrypoints/agent-executor/acp.js +23 -12
  83. package/dist/entrypoints/agent-executor/claude-sdk.js +26 -10
  84. package/dist/entrypoints/agent-executor/claude.js +35 -16
  85. package/dist/entrypoints/agent-executor/codex.js +81 -21
  86. package/dist/entrypoints/agent-executor.js +1 -1
  87. package/dist/entrypoints/agent-runtime/harness.js +5 -6
  88. package/dist/entrypoints/agent-runtime/openrouter.js +2 -2
  89. package/dist/entrypoints/agent-runtime/postgres.js +8 -3
  90. package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
  91. package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -4
  92. package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -4
  93. package/dist/entrypoints/agent-runtime/testing.js +6 -6
  94. package/dist/entrypoints/agent-runtime.d.ts +9 -7
  95. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  96. package/dist/entrypoints/agent-runtime.js +246 -199
  97. package/dist/entrypoints/application/diagnostic-journal.js +4 -4
  98. package/dist/entrypoints/application/directory-inbox.js +8 -8
  99. package/dist/entrypoints/cli/publish.js +8 -8
  100. package/dist/entrypoints/cli.js +10 -9
  101. package/dist/entrypoints/declaration.js +0 -1
  102. package/dist/entrypoints/files.js +40 -17
  103. package/dist/entrypoints/node.js +4 -4
  104. package/dist/entrypoints/observability.js +1 -1
  105. package/dist/entrypoints/process.js +1 -1
  106. package/dist/entrypoints/server.js +7 -7
  107. package/dist/entrypoints/service-host/macos.js +4 -4
  108. package/dist/entrypoints/service-host.d.ts +4 -1
  109. package/dist/entrypoints/service-host.d.ts.map +1 -1
  110. package/dist/entrypoints/service-host.js +831 -220
  111. package/dist/entrypoints/spend.js +1 -1
  112. package/dist/entrypoints/telegram.js +4 -4
  113. package/dist/entrypoints/tools/agent.js +4 -3
  114. package/dist/entrypoints/tools/invoker.js +3 -2
  115. package/dist/entrypoints/tools/mcp.js +4 -3
  116. package/dist/entrypoints/tools/toolkit.js +6 -5
  117. package/dist/entrypoints/tools.d.ts +1 -1
  118. package/dist/entrypoints/tools.d.ts.map +1 -1
  119. package/dist/entrypoints/tools.js +10 -8
  120. package/dist/files/directory-appearance.d.ts +20 -9
  121. package/dist/files/directory-appearance.d.ts.map +1 -1
  122. package/dist/files/polled-json.d.ts.map +1 -1
  123. package/dist/files/regular-file.d.ts +15 -5
  124. package/dist/files/regular-file.d.ts.map +1 -1
  125. package/dist/{index-z4k0hqp9.js → index-0gqs8ght.js} +106 -24
  126. package/dist/{index-caywx1c0.js → index-13dnv6d0.js} +107 -10
  127. package/dist/{index-a725ayvz.js → index-1qwrczr1.js} +1 -1
  128. package/dist/{index-xtkw9866.js → index-2c5w2d1d.js} +1 -1
  129. package/dist/{index-g1q7fwn9.js → index-2nwvn7m2.js} +1 -1
  130. package/dist/{index-4s2w4g37.js → index-3tnwtz38.js} +80 -2
  131. package/dist/{index-5e0zsbf7.js → index-4j8efqr3.js} +1 -1
  132. package/dist/{index-p1m9djt6.js → index-5v5vg85s.js} +1 -1
  133. package/dist/{index-x90w78yz.js → index-673drwkn.js} +23 -8
  134. package/dist/{index-7xp05h20.js → index-6wp4dn9d.js} +6 -6
  135. package/dist/{index-0hdm5sx6.js → index-8x22nprv.js} +6 -2
  136. package/dist/{index-j13gzgdv.js → index-bz3gn6cs.js} +8 -4
  137. package/dist/{index-d96c1n1q.js → index-c5gp2gh6.js} +20 -19
  138. package/dist/{index-wbnpa8z6.js → index-d54npte7.js} +4 -4
  139. package/dist/{index-kmbpej2y.js → index-emgrmavr.js} +102 -61
  140. package/dist/{index-bbzvrq66.js → index-g3e57qj6.js} +455 -202
  141. package/dist/index-gf92hc87.js +100 -0
  142. package/dist/{index-3djgv3ch.js → index-gzny6zsw.js} +25 -10
  143. package/dist/{index-3b31z0pc.js → index-hj1zq7mh.js} +12 -6
  144. package/dist/{index-8xr2eq99.js → index-jfecdk1e.js} +3 -3
  145. package/dist/{index-dvd1qdwa.js → index-ke02kxsr.js} +3 -3
  146. package/dist/{index-83n766x4.js → index-m18xm96h.js} +15 -9
  147. package/dist/{index-qnzhmk2s.js → index-n7f89hjw.js} +90 -47
  148. package/dist/{index-3agqmmrg.js → index-pn5b11ce.js} +7 -9
  149. package/dist/{index-3gwp8ez6.js → index-pwskmywy.js} +12 -17
  150. package/dist/{index-9wh98cpa.js → index-rxnyygke.js} +130 -90
  151. package/dist/{index-0djnptn8.js → index-rzeezh79.js} +10 -3
  152. package/dist/{index-nbv44x0x.js → index-s2e3h616.js} +137 -36
  153. package/dist/{index-5zwac8ft.js → index-t7wa7k12.js} +2 -2
  154. package/dist/{index-xypxnzhp.js → index-v1mxss62.js} +2 -2
  155. package/dist/index-vgzhw2zk.js +304 -0
  156. package/dist/{index-jrka9029.js → index-vmbxj75t.js} +2 -2
  157. package/dist/{index-j516jaaz.js → index-waa6t4zx.js} +49 -2
  158. package/dist/{index-fcw255hd.js → index-xv9jb84s.js} +2 -2
  159. package/dist/{index-dwa6pskj.js → index-y065r8g5.js} +82 -43
  160. package/dist/internal/bounded-file-confirm.d.ts +32 -0
  161. package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
  162. package/dist/internal/bounded-file-read.d.ts +10 -7
  163. package/dist/internal/bounded-file-read.d.ts.map +1 -1
  164. package/dist/internal/file-observation.d.ts +5 -1
  165. package/dist/internal/file-observation.d.ts.map +1 -1
  166. package/dist/internal/process-instance.d.ts +8 -0
  167. package/dist/internal/process-instance.d.ts.map +1 -1
  168. package/dist/internal/unix-socket.d.ts +3 -1
  169. package/dist/internal/unix-socket.d.ts.map +1 -1
  170. package/dist/server/unix-client.d.ts +7 -0
  171. package/dist/server/unix-client.d.ts.map +1 -1
  172. package/dist/service-host/systemd-inspect.d.ts +3 -1
  173. package/dist/service-host/systemd-inspect.d.ts.map +1 -1
  174. package/dist/service-host/systemd-render-shared.d.ts +64 -0
  175. package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
  176. package/dist/service-host/systemd-render.d.ts +31 -26
  177. package/dist/service-host/systemd-render.d.ts.map +1 -1
  178. package/dist/service-host/systemd-timer-render.d.ts +31 -0
  179. package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
  180. package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
  181. package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
  182. package/dist/service-host/systemd-timer.d.ts +82 -0
  183. package/dist/service-host/systemd-timer.d.ts.map +1 -0
  184. package/dist/service-host/systemd-unit-ops.d.ts +26 -0
  185. package/dist/service-host/systemd-unit-ops.d.ts.map +1 -0
  186. package/dist/service-host/systemd.d.ts +1 -1
  187. package/dist/service-host/systemd.d.ts.map +1 -1
  188. package/dist/tools/access.d.ts +30 -1
  189. package/dist/tools/access.d.ts.map +1 -1
  190. package/dist/tools/agent.d.ts +2 -2
  191. package/dist/tools/agent.d.ts.map +1 -1
  192. package/dist/tools/cli/args-scan.d.ts +5 -0
  193. package/dist/tools/cli/args-scan.d.ts.map +1 -1
  194. package/dist/tools/cli/args.d.ts +11 -5
  195. package/dist/tools/cli/args.d.ts.map +1 -1
  196. package/dist/tools/cli/invoke.d.ts +2 -1
  197. package/dist/tools/cli/invoke.d.ts.map +1 -1
  198. package/dist/tools/cli/notices.d.ts.map +1 -1
  199. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  200. package/dist/tools/cli/session.d.ts.map +1 -1
  201. package/dist/tools/execute.d.ts.map +1 -1
  202. package/dist/tools/invoker.d.ts +2 -1
  203. package/dist/tools/invoker.d.ts.map +1 -1
  204. package/dist/tools/list-names.d.ts +2 -3
  205. package/dist/tools/list-names.d.ts.map +1 -1
  206. package/dist/tools/manifest.d.ts +2 -3
  207. package/dist/tools/manifest.d.ts.map +1 -1
  208. package/dist/tools/mcp/mount.d.ts +5 -5
  209. package/dist/tools/mcp/mount.d.ts.map +1 -1
  210. package/dist/tools/mcp/register.d.ts +2 -1
  211. package/dist/tools/mcp/register.d.ts.map +1 -1
  212. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  213. package/llms/agent-executor-acp.txt +10 -6
  214. package/llms/agent-executor-claude-sdk.txt +1 -1
  215. package/llms/agent-executor-claude.txt +1 -1
  216. package/llms/agent-executor-codex.txt +1 -1
  217. package/llms/agent-runtime.4.txt +21 -9
  218. package/llms/cli.3.txt +4 -4
  219. package/llms/cli.txt +1 -0
  220. package/llms/declaration.txt +2 -2
  221. package/llms/files.txt +1 -1
  222. package/llms/node.txt +2 -2
  223. package/llms/server.5.txt +2 -2
  224. package/llms/service-host.txt +5 -5
  225. package/llms/stitchkit.txt +81 -77
  226. package/llms/tools.3.txt +3 -2
  227. package/llms/upgrading-0.128.0.txt +147 -0
  228. package/llms/upgrading.txt +1 -0
  229. package/llms-full.txt +272 -113
  230. package/llms.txt +14 -13
  231. package/package.json +1 -1
  232. package/dist/index-ajmtxsky.js +0 -193
  233. package/dist/index-ax3wns1a.js +0 -93
@@ -10,8 +10,12 @@ import {
10
10
  import {
11
11
  jsonDataRefusal
12
12
  } from "./index-m6w6jtda.js";
13
+ import {
14
+ assertPositiveSafeInteger
15
+ } from "./index-kzavdze2.js";
13
16
  import {
14
17
  abortReason,
18
+ raceAbort,
15
19
  linkAbortSignals
16
20
  } from "./index-rptj3qnc.js";
17
21
 
@@ -73,15 +77,6 @@ function offerTurnDelta(channel, delta) {
73
77
  channel.fail(new Error(`The turn's delta queue refused a delta (${result.reason})`));
74
78
  }
75
79
  }
76
- function extractTextOnlyInput(parts, driverLabel) {
77
- return parts.map((part) => {
78
- if (part.type !== "text") {
79
- throw new TypeError(`${driverLabel} sends text input only, received ${part.type}`);
80
- }
81
- return part.text;
82
- }).join(`
83
- `);
84
- }
85
80
  function sessionAbort(caller) {
86
81
  if (caller?.aborted)
87
82
  throw abortReason(caller);
@@ -145,6 +140,108 @@ function safeJsonValue(value) {
145
140
  return z.json().parse(snapshot.value);
146
141
  }
147
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;
164
+ 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;
201
+ }
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;
216
+ }
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`);
221
+ }
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
+ };
243
+ }
244
+
148
245
  // src/agent-executor/engine-requests.ts
149
246
  function holdEngineRequest(turn, request) {
150
247
  if (turn.state.interruptRequested) {
@@ -196,4 +293,4 @@ function loseEngineTurn(turn, answer, error) {
196
293
  turn.channel.fail(error);
197
294
  }
198
295
 
199
- export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, extractTextOnlyInput, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, holdEngineRequest, answerEngineRequest, drainEngineRequests, endEngineTurn, loseEngineTurn };
296
+ export { nonEmptyString, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, DEFAULT_MAX_IMAGE_BYTES, CLAUDE_CLI_MAX_LINE_BYTES, isSupportedImageMediaType, validateImageOptions, bytesToBase64, resolveImageBytes, assertImageFrameBytes, imageTurnStarter, holdEngineRequest, answerEngineRequest, drainEngineRequests, endEngineTurn, loseEngineTurn };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  writeFileAtomic2
3
- } from "./index-5zwac8ft.js";
3
+ } from "./index-t7wa7k12.js";
4
4
  import {
5
5
  errnoOf
6
6
  } from "./index-jj9228tt.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  closeAfter,
3
3
  closeAfterSync
4
- } from "./index-nbv44x0x.js";
4
+ } from "./index-s2e3h616.js";
5
5
 
6
6
  // src/internal/atomic-publication.ts
7
7
  import { closeSync, fsyncSync, linkSync, openSync, renameSync, unlinkSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-dvd1qdwa.js";
3
+ } from "./index-ke02kxsr.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-mxt0wfjy.js";
@@ -24,7 +24,7 @@ import {
24
24
  isRuntimeSnapshotEntry,
25
25
  appendEventIn,
26
26
  ArchiveSpillSchema
27
- } from "./index-bbzvrq66.js";
27
+ } from "./index-g3e57qj6.js";
28
28
  import {
29
29
  AgentRuntimeHeadSchema2,
30
30
  AgentStoredRunSchema2,
@@ -34,6 +34,11 @@ import {
34
34
  AgentRecoverableDescriptorSchema2,
35
35
  AgentRecoverablePageSchema2
36
36
  } from "./index-9xr44d2g.js";
37
+ import {
38
+ InvocationExpiredPayloadSchema,
39
+ parsePayloadPurgeCutoff,
40
+ redactLiveInvocationPayload
41
+ } from "./index-vgzhw2zk.js";
37
42
  import {
38
43
  AgentConversationPageSchema2,
39
44
  AgentConversationMessagePageSchema2
@@ -127,6 +132,78 @@ var ArchiveSpillRowSchema = z.object({
127
132
  authorization_payload: z.string().nullable(),
128
133
  payload: z.instanceof(Uint8Array)
129
134
  });
135
+ var RedactCandidateRowSchema = z.object({
136
+ row_id: SqlIntegerSchema,
137
+ conversation_id: z.string(),
138
+ seq: SqlIntegerSchema.pipe(z.int().positive()),
139
+ occurred_at: z.string(),
140
+ payload: z.string()
141
+ });
142
+ var MAX_ISO_OFFSET_MS = 24 * 60 * 60 * 1000;
143
+ async function redactExpiredSqlPayloads(dialect, transaction, input) {
144
+ const cutoffEpoch = parsePayloadPurgeCutoff(input.before);
145
+ const upperBoundIso = new Date(cutoffEpoch + MAX_ISO_OFFSET_MS).toISOString();
146
+ const events = dialect.tables.events;
147
+ const batchSize = Math.max(input.limit + 1, 256);
148
+ const matched = [];
149
+ let cursor;
150
+ while (matched.length <= input.limit) {
151
+ const clauses = [
152
+ "kind = 'provider/payload'",
153
+ dialect.contains("payload"),
154
+ "occurred_at <= ?"
155
+ ];
156
+ const values = ['"ciphertext":', upperBoundIso];
157
+ if (input.conversationId !== undefined) {
158
+ clauses.push("conversation_id = ?");
159
+ values.push(input.conversationId);
160
+ }
161
+ if (cursor !== undefined) {
162
+ clauses.push("(occurred_at > ? OR (occurred_at = ? AND (conversation_id > ? OR (conversation_id = ? AND seq > ?))))");
163
+ values.push(cursor.occurredAt, cursor.occurredAt, cursor.conversationId, cursor.conversationId, cursor.seq);
164
+ }
165
+ const batch = (await transaction.all(`SELECT row_id, conversation_id, seq, occurred_at, payload FROM ${events}
166
+ WHERE ${clauses.join(" AND ")}
167
+ ORDER BY occurred_at ASC, conversation_id ASC, seq ASC LIMIT ?`, [...values, batchSize])).map((raw) => RedactCandidateRowSchema.parse(raw));
168
+ for (const row of batch) {
169
+ if (Date.parse(row.occurred_at) >= cutoffEpoch)
170
+ continue;
171
+ const parsed = parseJson(row.payload);
172
+ if (InvocationExpiredPayloadSchema.safeParse(parsed).success)
173
+ continue;
174
+ matched.push({ row, parsed });
175
+ if (matched.length > input.limit)
176
+ break;
177
+ }
178
+ const last = batch.at(-1);
179
+ if (batch.length < batchSize || last === undefined)
180
+ break;
181
+ cursor = {
182
+ occurredAt: last.occurred_at,
183
+ conversationId: last.conversation_id,
184
+ seq: last.seq
185
+ };
186
+ }
187
+ const hasMore = matched.length > input.limit;
188
+ const toPurge = matched.slice(0, input.limit);
189
+ let freedBytes = 0;
190
+ for (const { row, parsed } of toPurge) {
191
+ const expired = redactLiveInvocationPayload(parsed, input.expiredAt);
192
+ if (expired === undefined)
193
+ continue;
194
+ const encoded = encodeJson(expired);
195
+ freedBytes += Math.max(0, Buffer.byteLength(row.payload) - Buffer.byteLength(encoded));
196
+ await transaction.run(`UPDATE ${events} SET payload = ? WHERE conversation_id = ? AND seq = ?`, [encoded, row.conversation_id, row.seq]);
197
+ await dialect.syncUpdatedEventSearch(transaction, {
198
+ rowId: row.row_id,
199
+ conversationId: row.conversation_id,
200
+ seq: row.seq,
201
+ occurredAt: row.occurred_at,
202
+ payload: encoded
203
+ });
204
+ }
205
+ return { purged: toPurge.length, freedBytes, hasMore };
206
+ }
130
207
  function sqlEvents(dialect) {
131
208
  const events = dialect.tables.events;
132
209
  return {
@@ -171,7 +248,8 @@ function sqlEvents(dialect) {
171
248
  async find(transaction, input) {
172
249
  const row = await transaction.get(`SELECT ${EVENT_COLUMNS} FROM ${events} WHERE event_id = ? AND conversation_id = ?`, [input.eventId, input.conversationId]);
173
250
  return row === undefined ? undefined : parseEventRow(row);
174
- }
251
+ },
252
+ redactExpiredPayloads: (transaction, input) => redactExpiredSqlPayloads(dialect, transaction, input)
175
253
  };
176
254
  }
177
255
  function sqlArchive(dialect) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-3ypvpkwr.js";
4
4
  import {
5
5
  contractToolMountable
6
- } from "./index-9wh98cpa.js";
6
+ } from "./index-gf92hc87.js";
7
7
  import {
8
8
  runtimeToolMountable
9
9
  } from "./index-7csn6pva.js";
@@ -105,4 +105,4 @@ function spawnEngineProcess2(input) {
105
105
  };
106
106
  }
107
107
 
108
- export { spawnEngineProcess2 };
108
+ export { ENGINE_LINE_BYTES, spawnEngineProcess2 };
@@ -409,22 +409,37 @@ async function probeProcessOwnerWith(pid, recorded, probes = { read: readProcess
409
409
  const liveness = await probes.liveness(pid);
410
410
  if (liveness === "gone")
411
411
  return { liveness, identity: "pid-gone" };
412
- return judgeObserved(recorded, self.current, await observe(pid));
412
+ const observation = await observe(pid);
413
+ if (observation.state === "unavailable" && await probes.liveness(pid) === "gone") {
414
+ return { liveness: "gone", identity: "pid-gone" };
415
+ }
416
+ return judgeObserved(recorded, self.current, observation);
413
417
  }
414
- function probeProcessOwnerSync(pid, recorded) {
415
- z.number().int().positive().max(MAX_PID).parse(pid);
418
+ function probeProcessOwnerSyncWith(pid, recorded, probes = {
419
+ liveness: probeLivenessSync,
420
+ observe: (target) => observeProcessInstanceAtSync(target, "/proc")
421
+ }) {
416
422
  if (recorded === undefined)
417
- return { liveness: probeLivenessSync(pid), identity: "legacy" };
423
+ return { liveness: probes.liveness(pid), identity: "legacy" };
418
424
  if (recorded === null)
419
425
  return unrecordedLifetime();
420
- ProcessInstanceSchema2.parse(recorded);
421
- const self = judgeAgainstSelf(recorded, observeProcessInstanceAtSync(process.pid, "/proc"));
426
+ const self = judgeAgainstSelf(recorded, probes.observe(process.pid));
422
427
  if (!("current" in self))
423
428
  return self;
424
- const liveness = probeLivenessSync(pid);
429
+ const liveness = probes.liveness(pid);
425
430
  if (liveness === "gone")
426
431
  return { liveness, identity: "pid-gone" };
427
- return judgeObserved(recorded, self.current, observeProcessInstanceAtSync(pid, "/proc"));
432
+ const observation = probes.observe(pid);
433
+ if (observation.state === "unavailable" && probes.liveness(pid) === "gone") {
434
+ return { liveness: "gone", identity: "pid-gone" };
435
+ }
436
+ return judgeObserved(recorded, self.current, observation);
437
+ }
438
+ function probeProcessOwnerSync(pid, recorded) {
439
+ z.number().int().positive().max(MAX_PID).parse(pid);
440
+ if (recorded != null)
441
+ ProcessInstanceSchema2.parse(recorded);
442
+ return probeProcessOwnerSyncWith(pid, recorded);
428
443
  }
429
444
 
430
445
  export { machineIdentity, machineIdentitySync, probeLiveness, ProcessInstanceSchema2, sameProcessInstance, observeProcessInstance2, readProcessInstance, readProcessInstanceSync, observeProcessInstanceAt, probeProcessOwner2, probeProcessOwnerWith, probeProcessOwnerSync };
@@ -1,14 +1,14 @@
1
1
  import {
2
- toolErrorFromResult,
3
- collectTools2,
4
- createToolRunner
5
- } from "./index-9wh98cpa.js";
2
+ resolveToolAccess,
3
+ toolErrorFromResult
4
+ } from "./index-rxnyygke.js";
6
5
  import {
7
6
  assertUniqueToolName
8
7
  } from "./index-3ypvpkwr.js";
9
8
  import {
10
- resolveToolAccess
11
- } from "./index-ax3wns1a.js";
9
+ collectTools2,
10
+ createToolRunner
11
+ } from "./index-gf92hc87.js";
12
12
  import {
13
13
  AppError2
14
14
  } from "./index-9pv126eh.js";
@@ -9,8 +9,9 @@ import {
9
9
  } from "./index-apv5xfef.js";
10
10
  import {
11
11
  assertUnixSocketPathLength,
12
+ assertExpectedOwnerUid,
12
13
  assertUnixSocketClientTarget
13
- } from "./index-3djgv3ch.js";
14
+ } from "./index-gzny6zsw.js";
14
15
  import {
15
16
  DEFAULT_PROCESS_SIGNALS,
16
17
  defaultSignalSource,
@@ -1210,12 +1211,14 @@ function resolveUnixClientLimits(config) {
1210
1211
  throw new TypeError("socketPath must be an absolute Unix socket path");
1211
1212
  }
1212
1213
  assertUnixSocketPathLength(config.socketPath, "createUnixClientTransport");
1214
+ assertExpectedOwnerUid(config.expectedOwnerUid, "createUnixClientTransport");
1213
1215
  if (config.responseBodyMode === "streaming" && config.maxResponseBytes !== undefined) {
1214
1216
  throw new TypeError("maxResponseBytes cannot be combined with responseBodyMode streaming");
1215
1217
  }
1216
1218
  const pos = positiveInteger;
1217
1219
  assertTimerMs("headersTimeoutMs", config.headersTimeoutMs);
1218
1220
  return {
1221
+ expectedOwnerUid: config.expectedOwnerUid,
1219
1222
  maxRequestBytes: pos(config.maxRequestBytes, DEFAULT_MAX_BODY_BYTES, "maxRequestBytes"),
1220
1223
  maxResponseBytes: config.responseBodyMode === "streaming" ? undefined : pos(config.maxResponseBytes, DEFAULT_MAX_BODY_BYTES, "maxResponseBytes"),
1221
1224
  headersTimeoutMs: config.headersTimeoutMs ?? DEFAULT_HEADERS_TIMEOUT_MS,
@@ -1307,6 +1310,7 @@ function nodeUnixRequest(input) {
1307
1310
  }
1308
1311
  function createUnixClientTransport2(config) {
1309
1312
  const {
1313
+ expectedOwnerUid,
1310
1314
  maxRequestBytes,
1311
1315
  maxResponseBytes,
1312
1316
  headersTimeoutMs,
@@ -1330,7 +1334,7 @@ function createUnixClientTransport2(config) {
1330
1334
  if (url.protocol !== "http:") {
1331
1335
  throw new TypeError("Unix client transport accepts only http: request URLs");
1332
1336
  }
1333
- assertUnixSocketClientTarget(config.socketPath);
1337
+ assertUnixSocketClientTarget(config.socketPath, "createUnixClientTransport", expectedOwnerUid);
1334
1338
  const body = await readBoundedRequestBody(request, maxRequestBytes, closeController.signal);
1335
1339
  if (closed)
1336
1340
  throw closedError("not-dispatched");
@@ -3,11 +3,11 @@ import {
3
3
  RegularFileError2,
4
4
  fileCacheIdentity,
5
5
  readRegularFileWithMetaSync,
6
- readRegularFileFromOpen,
6
+ readRegularFileWithMeta,
7
7
  decodeJsonText,
8
8
  parseJsonText,
9
9
  validateJsonValue
10
- } from "./index-3gwp8ez6.js";
10
+ } from "./index-pwskmywy.js";
11
11
  import {
12
12
  messageOf
13
13
  } from "./index-r9kq5ark.js";
@@ -271,13 +271,17 @@ class PolledJsonFiles2 {
271
271
  const existing = this.entries.get(path);
272
272
  const readStartedNs = clockNs();
273
273
  const found = await pathStatOfAsync(path, options.noFollow, readStartedNs);
274
+ signal?.throwIfAborted();
274
275
  const shortcut = this.fromStat(existing, options, found, true);
275
276
  if (shortcut !== undefined)
276
277
  return shortcut;
277
278
  let outcome;
278
279
  try {
279
- const bytes = await readRegularFileFromOpen(path, { ...options, signal });
280
- outcome = { bytes, ...found.kind === "file" && { stamp: found.stamp } };
280
+ const { bytes, after } = await readRegularFileWithMeta(path, { ...options, signal });
281
+ outcome = {
282
+ bytes,
283
+ ...after !== undefined ? { stamp: stampOf(after, readStartedNs) } : found.kind === "file" ? { stamp: found.stamp } : {}
284
+ };
281
285
  } catch (error) {
282
286
  if (signal?.aborted)
283
287
  throw error;
@@ -1,6 +1,6 @@
1
1
  import {
2
- collectToolSurface
3
- } from "./index-5e0zsbf7.js";
2
+ projectToolSurface
3
+ } from "./index-3ypvpkwr.js";
4
4
 
5
5
  // src/tools/manifest.ts
6
6
  function utf8Length(value) {
@@ -8,21 +8,24 @@ function utf8Length(value) {
8
8
  }
9
9
  function describeToolCatalog2(config) {
10
10
  const deferred = new Set(config.deferredNames ?? []);
11
- const entries = collectToolSurface({
12
- surface: config,
13
- transport: config.transport,
11
+ const entries = projectToolSurface(config, config.transport, {
14
12
  extend: config.extend,
15
13
  flattenUnionInput: config.flattenUnionInput,
16
14
  inputRecursionDepth: config.inputRecursionDepth
17
- }).map(({ kind, service, action, mountable }) => {
18
- const schemaBytes = utf8Length(mountable.presentationSchema);
15
+ }).map((projected) => {
16
+ const schemaBytes = utf8Length(projected.presentationSchema);
17
+ const description = projected.kind === "contract" ? projected.source.desc : projected.source.description;
19
18
  return {
20
- name: mountable.name,
21
- description: mountable.method.desc,
22
- inputSchema: mountable.presentationSchema,
23
- source: { kind, service, action },
19
+ name: projected.name,
20
+ description,
21
+ inputSchema: projected.presentationSchema,
22
+ source: {
23
+ kind: projected.kind,
24
+ service: projected.serviceName,
25
+ action: projected.action
26
+ },
24
27
  schemaBytes,
25
- deferred: deferred.has(mountable.name)
28
+ deferred: deferred.has(projected.name)
26
29
  };
27
30
  });
28
31
  if (config.maxSchemaBytes !== undefined) {
@@ -34,16 +37,14 @@ function describeToolCatalog2(config) {
34
37
  return entries;
35
38
  }
36
39
  function buildToolManifest2(config) {
37
- return collectToolSurface({
38
- surface: config,
39
- transport: config.transport,
40
+ return projectToolSurface(config, config.transport, {
40
41
  extend: config.extend,
41
42
  flattenUnionInput: config.flattenUnionInput,
42
43
  inputRecursionDepth: config.inputRecursionDepth
43
- }).map(({ mountable }) => ({
44
- name: mountable.name,
45
- description: mountable.method.desc,
46
- inputSchema: mountable.presentationSchema
44
+ }).map((projected) => ({
45
+ name: projected.name,
46
+ description: projected.kind === "contract" ? projected.source.desc : projected.source.description,
47
+ inputSchema: projected.presentationSchema
47
48
  }));
48
49
  }
49
50
 
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-g1q7fwn9.js";
3
+ } from "./index-2nwvn7m2.js";
4
4
  import {
5
5
  writeAtomicFileData
6
- } from "./index-5zwac8ft.js";
6
+ } from "./index-t7wa7k12.js";
7
7
  import {
8
8
  publishAtomicFile
9
- } from "./index-xtkw9866.js";
9
+ } from "./index-2c5w2d1d.js";
10
10
  import {
11
11
  readBoundedFile
12
- } from "./index-nbv44x0x.js";
12
+ } from "./index-s2e3h616.js";
13
13
  import {
14
14
  errnoOf
15
15
  } from "./index-jj9228tt.js";