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.
- package/CHANGELOG.md +137 -6
- package/dist/agent-executor/acp/v1-connect.d.ts +9 -1
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +8 -2
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +8 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +4 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/protocol.d.ts +20 -2
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -1
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude/transcript.d.ts +7 -4
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +4 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/driver.d.ts +4 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +26 -2
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/session.d.ts +3 -1
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +71 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +0 -3
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-runtime/agent-tool.d.ts +21 -7
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +1 -0
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +5 -2
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +9 -9
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +45 -32
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +12 -6
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-source.d.ts +13 -1
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +64 -0
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-tools.d.ts +82 -5
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +12 -0
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts +6 -3
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +50 -8
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocations.d.ts +20 -9
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/postgres.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +30 -0
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-invocation-payload.d.ts +48 -0
- package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -1
- package/dist/agent-runtime/sql-session.d.ts +11 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +55 -0
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +12 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-events.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +7 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/declaration/declaration.d.ts +6 -3
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +23 -12
- package/dist/entrypoints/agent-executor/claude-sdk.js +26 -10
- package/dist/entrypoints/agent-executor/claude.js +35 -16
- package/dist/entrypoints/agent-executor/codex.js +81 -21
- package/dist/entrypoints/agent-executor.js +1 -1
- package/dist/entrypoints/agent-runtime/harness.js +5 -6
- package/dist/entrypoints/agent-runtime/openrouter.js +2 -2
- package/dist/entrypoints/agent-runtime/postgres.js +8 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -4
- package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -4
- package/dist/entrypoints/agent-runtime/testing.js +6 -6
- package/dist/entrypoints/agent-runtime.d.ts +9 -7
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +246 -199
- package/dist/entrypoints/application/diagnostic-journal.js +4 -4
- package/dist/entrypoints/application/directory-inbox.js +8 -8
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.js +10 -9
- package/dist/entrypoints/declaration.js +0 -1
- package/dist/entrypoints/files.js +40 -17
- package/dist/entrypoints/node.js +4 -4
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +1 -1
- package/dist/entrypoints/server.js +7 -7
- package/dist/entrypoints/service-host/macos.js +4 -4
- package/dist/entrypoints/service-host.d.ts +4 -1
- package/dist/entrypoints/service-host.d.ts.map +1 -1
- package/dist/entrypoints/service-host.js +831 -220
- package/dist/entrypoints/spend.js +1 -1
- package/dist/entrypoints/telegram.js +4 -4
- package/dist/entrypoints/tools/agent.js +4 -3
- package/dist/entrypoints/tools/invoker.js +3 -2
- package/dist/entrypoints/tools/mcp.js +4 -3
- package/dist/entrypoints/tools/toolkit.js +6 -5
- package/dist/entrypoints/tools.d.ts +1 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +10 -8
- package/dist/files/directory-appearance.d.ts +20 -9
- package/dist/files/directory-appearance.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts.map +1 -1
- package/dist/files/regular-file.d.ts +15 -5
- package/dist/files/regular-file.d.ts.map +1 -1
- package/dist/{index-z4k0hqp9.js → index-0gqs8ght.js} +106 -24
- package/dist/{index-caywx1c0.js → index-13dnv6d0.js} +107 -10
- package/dist/{index-a725ayvz.js → index-1qwrczr1.js} +1 -1
- package/dist/{index-xtkw9866.js → index-2c5w2d1d.js} +1 -1
- package/dist/{index-g1q7fwn9.js → index-2nwvn7m2.js} +1 -1
- package/dist/{index-4s2w4g37.js → index-3tnwtz38.js} +80 -2
- package/dist/{index-5e0zsbf7.js → index-4j8efqr3.js} +1 -1
- package/dist/{index-p1m9djt6.js → index-5v5vg85s.js} +1 -1
- package/dist/{index-x90w78yz.js → index-673drwkn.js} +23 -8
- package/dist/{index-7xp05h20.js → index-6wp4dn9d.js} +6 -6
- package/dist/{index-0hdm5sx6.js → index-8x22nprv.js} +6 -2
- package/dist/{index-j13gzgdv.js → index-bz3gn6cs.js} +8 -4
- package/dist/{index-d96c1n1q.js → index-c5gp2gh6.js} +20 -19
- package/dist/{index-wbnpa8z6.js → index-d54npte7.js} +4 -4
- package/dist/{index-kmbpej2y.js → index-emgrmavr.js} +102 -61
- package/dist/{index-bbzvrq66.js → index-g3e57qj6.js} +455 -202
- package/dist/index-gf92hc87.js +100 -0
- package/dist/{index-3djgv3ch.js → index-gzny6zsw.js} +25 -10
- package/dist/{index-3b31z0pc.js → index-hj1zq7mh.js} +12 -6
- package/dist/{index-8xr2eq99.js → index-jfecdk1e.js} +3 -3
- package/dist/{index-dvd1qdwa.js → index-ke02kxsr.js} +3 -3
- package/dist/{index-83n766x4.js → index-m18xm96h.js} +15 -9
- package/dist/{index-qnzhmk2s.js → index-n7f89hjw.js} +90 -47
- package/dist/{index-3agqmmrg.js → index-pn5b11ce.js} +7 -9
- package/dist/{index-3gwp8ez6.js → index-pwskmywy.js} +12 -17
- package/dist/{index-9wh98cpa.js → index-rxnyygke.js} +130 -90
- package/dist/{index-0djnptn8.js → index-rzeezh79.js} +10 -3
- package/dist/{index-nbv44x0x.js → index-s2e3h616.js} +137 -36
- package/dist/{index-5zwac8ft.js → index-t7wa7k12.js} +2 -2
- package/dist/{index-xypxnzhp.js → index-v1mxss62.js} +2 -2
- package/dist/index-vgzhw2zk.js +304 -0
- package/dist/{index-jrka9029.js → index-vmbxj75t.js} +2 -2
- package/dist/{index-j516jaaz.js → index-waa6t4zx.js} +49 -2
- package/dist/{index-fcw255hd.js → index-xv9jb84s.js} +2 -2
- package/dist/{index-dwa6pskj.js → index-y065r8g5.js} +82 -43
- package/dist/internal/bounded-file-confirm.d.ts +32 -0
- package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
- package/dist/internal/bounded-file-read.d.ts +10 -7
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +5 -1
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +8 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/unix-socket.d.ts +3 -1
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +7 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/systemd-inspect.d.ts +3 -1
- package/dist/service-host/systemd-inspect.d.ts.map +1 -1
- package/dist/service-host/systemd-render-shared.d.ts +64 -0
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +31 -26
- package/dist/service-host/systemd-render.d.ts.map +1 -1
- package/dist/service-host/systemd-timer-render.d.ts +31 -0
- package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
- package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
- package/dist/service-host/systemd-timer.d.ts +82 -0
- package/dist/service-host/systemd-timer.d.ts.map +1 -0
- package/dist/service-host/systemd-unit-ops.d.ts +26 -0
- package/dist/service-host/systemd-unit-ops.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +1 -1
- package/dist/service-host/systemd.d.ts.map +1 -1
- package/dist/tools/access.d.ts +30 -1
- package/dist/tools/access.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +2 -2
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +5 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +11 -5
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +2 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -3
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +5 -5
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +10 -6
- package/llms/agent-executor-claude-sdk.txt +1 -1
- package/llms/agent-executor-claude.txt +1 -1
- package/llms/agent-executor-codex.txt +1 -1
- package/llms/agent-runtime.4.txt +21 -9
- package/llms/cli.3.txt +4 -4
- package/llms/cli.txt +1 -0
- package/llms/declaration.txt +2 -2
- package/llms/files.txt +1 -1
- package/llms/node.txt +2 -2
- package/llms/server.5.txt +2 -2
- package/llms/service-host.txt +5 -5
- package/llms/stitchkit.txt +81 -77
- package/llms/tools.3.txt +3 -2
- package/llms/upgrading-0.128.0.txt +147 -0
- package/llms/upgrading.txt +1 -0
- package/llms-full.txt +272 -113
- package/llms.txt +14 -13
- package/package.json +1 -1
- package/dist/index-ajmtxsky.js +0 -193
- 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,
|
|
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 };
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
isRuntimeSnapshotEntry,
|
|
25
25
|
appendEventIn,
|
|
26
26
|
ArchiveSpillSchema
|
|
27
|
-
} from "./index-
|
|
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) {
|
|
@@ -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
|
-
|
|
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
|
|
415
|
-
|
|
418
|
+
function probeProcessOwnerSyncWith(pid, recorded, probes = {
|
|
419
|
+
liveness: probeLivenessSync,
|
|
420
|
+
observe: (target) => observeProcessInstanceAtSync(target, "/proc")
|
|
421
|
+
}) {
|
|
416
422
|
if (recorded === undefined)
|
|
417
|
-
return { liveness:
|
|
423
|
+
return { liveness: probes.liveness(pid), identity: "legacy" };
|
|
418
424
|
if (recorded === null)
|
|
419
425
|
return unrecordedLifetime();
|
|
420
|
-
|
|
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 =
|
|
429
|
+
const liveness = probes.liveness(pid);
|
|
425
430
|
if (liveness === "gone")
|
|
426
431
|
return { liveness, identity: "pid-gone" };
|
|
427
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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-
|
|
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
|
-
|
|
6
|
+
readRegularFileWithMeta,
|
|
7
7
|
decodeJsonText,
|
|
8
8
|
parseJsonText,
|
|
9
9
|
validateJsonValue
|
|
10
|
-
} from "./index-
|
|
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
|
|
280
|
-
outcome = {
|
|
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
|
-
|
|
3
|
-
} from "./index-
|
|
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 =
|
|
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((
|
|
18
|
-
const schemaBytes = utf8Length(
|
|
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:
|
|
21
|
-
description
|
|
22
|
-
inputSchema:
|
|
23
|
-
source: {
|
|
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(
|
|
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
|
|
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((
|
|
44
|
-
name:
|
|
45
|
-
description:
|
|
46
|
-
inputSchema:
|
|
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-
|
|
3
|
+
} from "./index-2nwvn7m2.js";
|
|
4
4
|
import {
|
|
5
5
|
writeAtomicFileData
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-t7wa7k12.js";
|
|
7
7
|
import {
|
|
8
8
|
publishAtomicFile
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-2c5w2d1d.js";
|
|
10
10
|
import {
|
|
11
11
|
readBoundedFile
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-s2e3h616.js";
|
|
13
13
|
import {
|
|
14
14
|
errnoOf
|
|
15
15
|
} from "./index-jj9228tt.js";
|