stitchkit 0.110.0 → 0.110.2
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 +17 -0
- package/dist/agent-runtime/archive-spill.d.ts +61 -0
- package/dist/agent-runtime/archive-spill.d.ts.map +1 -0
- package/dist/agent-runtime/branch-contract.d.ts +102 -0
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -0
- package/dist/agent-runtime/branch-events.d.ts +18 -0
- package/dist/agent-runtime/branch-events.d.ts.map +1 -0
- package/dist/agent-runtime/branch-identities.d.ts +20 -0
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -0
- package/dist/agent-runtime/branch-messages.d.ts +32 -0
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -0
- package/dist/agent-runtime/branch-observations.d.ts +104 -0
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -0
- package/dist/agent-runtime/branch-provider.d.ts +130 -0
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -0
- package/dist/agent-runtime/branch-replay.d.ts +426 -0
- package/dist/agent-runtime/branch-replay.d.ts.map +1 -0
- package/dist/agent-runtime/branch-source.d.ts +16 -0
- package/dist/agent-runtime/branch-source.d.ts.map +1 -0
- package/dist/agent-runtime/branch-transitions.d.ts +6 -0
- package/dist/agent-runtime/branch-transitions.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-history.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts +1 -0
- package/dist/agent-runtime/store-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts +5 -0
- package/dist/agent-runtime/store-branch.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts +4 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +6 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +90 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-archive.d.ts +8 -0
- package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -0
- package/dist/agent-runtime/store-memory-events.d.ts +7 -0
- package/dist/agent-runtime/store-memory-events.d.ts.map +1 -0
- package/dist/agent-runtime/store-memory.d.ts +1 -1
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store-purge.d.ts +2 -0
- package/dist/agent-runtime/store-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-run.d.ts +2 -2
- package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +1 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
- package/dist/agent-runtime/store-reducer.d.ts +2 -2
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +3 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/browser/socket-io-client.d.ts +6 -0
- package/dist/browser/socket-io-client.d.ts.map +1 -0
- package/dist/browser/socket-io-contract.d.ts +183 -0
- package/dist/browser/socket-io-contract.d.ts.map +1 -0
- package/dist/browser/socket-io-default-peer.d.ts +3 -0
- package/dist/browser/socket-io-default-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-explicit-peer.d.ts +12 -0
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +2 -11
- package/dist/browser/socket-io-peer.d.ts.map +1 -1
- package/dist/browser/socket-io.d.ts +5 -224
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/durability/events.d.ts +4 -0
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -3
- package/dist/entrypoints/agent-runtime/harness.js +5 -4
- package/dist/entrypoints/agent-runtime/realtime.js +3 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +4 -6
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -3
- package/dist/entrypoints/agent-runtime/testing.js +89 -5
- package/dist/entrypoints/agent-runtime.d.ts +1 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +28 -18
- package/dist/entrypoints/application/directory-inbox.js +6 -6
- package/dist/entrypoints/application.js +1 -1
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/cli.js +8 -8
- package/dist/entrypoints/contract.js +1 -1
- package/dist/entrypoints/files.js +1 -1
- package/dist/entrypoints/http.d.ts +1 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +6 -2
- package/dist/entrypoints/index.js +20 -411
- package/dist/entrypoints/node.js +3 -3
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +1 -1
- package/dist/entrypoints/realtime.d.ts +6 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -0
- package/dist/entrypoints/realtime.js +25 -0
- package/dist/entrypoints/remote.js +1 -1
- package/dist/entrypoints/server.js +11 -11
- package/dist/entrypoints/telegram/screens.js +9 -9
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/testing.js +2 -2
- package/dist/entrypoints/tools/connections.js +3 -3
- package/dist/entrypoints/tools/invoker.js +3 -3
- package/dist/entrypoints/tools/mcp.js +4 -4
- package/dist/entrypoints/tools.js +26 -24
- package/dist/{index-61m15a18.js → index-0d8m0kee.js} +1 -1
- package/dist/{index-dmfr2cg5.js → index-2tazbwhv.js} +6 -6
- package/dist/{index-c17xcx4k.js → index-56yx8dxp.js} +19 -96
- package/dist/{index-0gs4ymfj.js → index-6qeqdz0z.js} +7 -1
- package/dist/{index-064zxbwj.js → index-79zxnh52.js} +3 -3
- package/dist/{index-2pevnh0x.js → index-7c046kxr.js} +4 -4
- package/dist/index-86sxnvpr.js +336 -0
- package/dist/{index-jyw90rps.js → index-bm180f2d.js} +204 -84
- package/dist/{index-mnhtbqrb.js → index-dd1z5kxb.js} +2 -2
- package/dist/{index-7a1xhhdx.js → index-e1sjcjfy.js} +31 -11
- package/dist/{index-5p55xreg.js → index-e9rbhw1s.js} +67 -29
- package/dist/{index-p6mvqcbq.js → index-ghwntn9n.js} +1 -1
- package/dist/index-hqsbtvta.js +92 -0
- package/dist/{index-73cz22ds.js → index-mha6b4vk.js} +6 -6
- package/dist/index-s2bgwsyr.js +2280 -0
- package/dist/{index-fnra8n1j.js → index-s2eybn7b.js} +9 -9
- package/dist/{index-njs9gvrh.js → index-s6d8zsha.js} +6 -6
- package/dist/index-snef22zr.js +94 -0
- package/dist/{index-c0hffcmj.js → index-zbssway3.js} +19 -2
- package/dist/process/group-presence.d.ts +3 -0
- package/dist/process/group-presence.d.ts.map +1 -0
- package/dist/process/group-settlement.d.ts.map +1 -1
- package/dist/process/group.d.ts.map +1 -1
- package/llms/agent-runtime.3.txt +3 -0
- package/llms/agent-runtime.txt +60 -0
- package/llms/realtime.txt +31 -0
- package/llms/stitchkit.txt +1 -0
- package/llms-full.txt +85 -0
- package/llms.txt +3 -2
- package/package.json +5 -1
- package/dist/index-8ks9b85e.js +0 -129
- package/dist/index-d2h99n7d.js +0 -1071
- package/dist/{index-9j2atjte.js → index-2f9r0jgr.js} +3 -3
- package/dist/{index-y70v24cw.js → index-8asb62xn.js} +0 -0
- package/dist/{index-k7qdkh3n.js → index-h1spd9kv.js} +3 -3
- package/dist/{index-zgwkwr1g.js → index-jk44mbqb.js} +0 -0
- package/dist/{index-qd8x73e8.js → index-k8fbzggr.js} +0 -0
- package/dist/{index-85qve8mq.js → index-pzw0fpek.js} +0 -0
- package/dist/{index-y3nemndz.js → index-r6v4mc67.js} +3 -3
- package/dist/{index-ktjmgq9p.js → index-s0xbnpfh.js} +3 -3
|
@@ -4,17 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
NativeCommandError2
|
|
6
6
|
} from "./index-84bf5spd.js";
|
|
7
|
-
import {
|
|
8
|
-
probeAgentProcessSandboxOutcome,
|
|
9
|
-
missingSandboxRestrictions2,
|
|
10
|
-
codingRefusal,
|
|
11
|
-
codingPathRefusal,
|
|
12
|
-
refuseMissingCodingPath
|
|
13
|
-
} from "./index-8ks9b85e.js";
|
|
14
7
|
import {
|
|
15
8
|
CommandStopped,
|
|
16
9
|
startNativeCommand
|
|
17
|
-
} from "./index-
|
|
10
|
+
} from "./index-e1sjcjfy.js";
|
|
18
11
|
import {
|
|
19
12
|
NumericFileHandle,
|
|
20
13
|
descriptorPath,
|
|
@@ -36,8 +29,10 @@ import {
|
|
|
36
29
|
defineRuntimeTool2
|
|
37
30
|
} from "./index-636mggad.js";
|
|
38
31
|
import {
|
|
32
|
+
AppError2,
|
|
39
33
|
forbidden2,
|
|
40
|
-
conflict2
|
|
34
|
+
conflict2,
|
|
35
|
+
STITCH_ERROR_STATUS2
|
|
41
36
|
} from "./index-j9gxbztg.js";
|
|
42
37
|
|
|
43
38
|
// src/agent-runtime/coding-tool-contract.ts
|
|
@@ -183,9 +178,80 @@ function resolveCodingToolLimits(input) {
|
|
|
183
178
|
return AgentCodingToolLimitsSchema2.parse({ ...DEFAULT_LIMITS, ...input });
|
|
184
179
|
}
|
|
185
180
|
|
|
181
|
+
// src/agent-runtime/sandbox.ts
|
|
182
|
+
import { z as z2 } from "zod";
|
|
183
|
+
var AgentSandboxRestrictionSchema2 = z2.enum([
|
|
184
|
+
"network-denied",
|
|
185
|
+
"write-contained",
|
|
186
|
+
"secrets-hidden",
|
|
187
|
+
"process-contained"
|
|
188
|
+
]);
|
|
189
|
+
var AgentSandboxGradeSchema2 = z2.discriminatedUnion("grade", [
|
|
190
|
+
z2.object({ grade: z2.literal("full"), restrictions: z2.array(AgentSandboxRestrictionSchema2) }).strict(),
|
|
191
|
+
z2.object({
|
|
192
|
+
grade: z2.literal("partial"),
|
|
193
|
+
restrictions: z2.array(AgentSandboxRestrictionSchema2),
|
|
194
|
+
gaps: z2.array(AgentSandboxRestrictionSchema2)
|
|
195
|
+
}).strict(),
|
|
196
|
+
z2.object({ grade: z2.literal("unavailable"), reason: z2.string().min(1) }).strict()
|
|
197
|
+
]);
|
|
198
|
+
var probes = new WeakMap;
|
|
199
|
+
var PROBE_FAILED = "sandbox probe failed";
|
|
200
|
+
var PROBE_INVALID = "sandbox probe returned no valid grade";
|
|
201
|
+
async function runProbe(sandbox) {
|
|
202
|
+
let value;
|
|
203
|
+
try {
|
|
204
|
+
value = await sandbox.probe();
|
|
205
|
+
} catch (cause) {
|
|
206
|
+
return { grade: { grade: "unavailable", reason: PROBE_FAILED }, cause };
|
|
207
|
+
}
|
|
208
|
+
const parsed = AgentSandboxGradeSchema2.safeParse(value);
|
|
209
|
+
if (parsed.success)
|
|
210
|
+
return { grade: parsed.data };
|
|
211
|
+
return { grade: { grade: "unavailable", reason: PROBE_INVALID }, cause: parsed.error };
|
|
212
|
+
}
|
|
213
|
+
function probeAgentProcessSandboxOutcome(sandbox, options = {}) {
|
|
214
|
+
if (options.refresh)
|
|
215
|
+
probes.delete(sandbox);
|
|
216
|
+
const present = probes.get(sandbox);
|
|
217
|
+
if (present)
|
|
218
|
+
return present;
|
|
219
|
+
const pending = runProbe(sandbox);
|
|
220
|
+
probes.set(sandbox, pending);
|
|
221
|
+
return pending;
|
|
222
|
+
}
|
|
223
|
+
async function probeAgentProcessSandbox2(sandbox, options = {}) {
|
|
224
|
+
const fresh = options.refresh === true || !probes.has(sandbox);
|
|
225
|
+
const outcome = await probeAgentProcessSandboxOutcome(sandbox, options);
|
|
226
|
+
if (fresh && outcome.cause !== undefined) {
|
|
227
|
+
process.emitWarning(new Error("Sandbox probe failed", { cause: outcome.cause }));
|
|
228
|
+
}
|
|
229
|
+
return outcome.grade;
|
|
230
|
+
}
|
|
231
|
+
function missingSandboxRestrictions2(grade, required) {
|
|
232
|
+
if (grade.grade === "unavailable")
|
|
233
|
+
return required;
|
|
234
|
+
const present = new Set(grade.restrictions);
|
|
235
|
+
return required.filter((restriction) => !present.has(restriction));
|
|
236
|
+
}
|
|
237
|
+
async function recordAgentSandboxProbe2(input) {
|
|
238
|
+
const grade = await probeAgentProcessSandbox2(input.sandbox);
|
|
239
|
+
const missing = missingSandboxRestrictions2(grade, input.required);
|
|
240
|
+
await input.store.appendEvent({
|
|
241
|
+
conversationId: input.conversationId,
|
|
242
|
+
kind: "sandbox/probed",
|
|
243
|
+
payload: {
|
|
244
|
+
result: grade,
|
|
245
|
+
required: [...input.required],
|
|
246
|
+
missing: [...missing]
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
return grade;
|
|
250
|
+
}
|
|
251
|
+
|
|
186
252
|
// src/agent-runtime/coding-tools.ts
|
|
187
253
|
import path5 from "node:path";
|
|
188
|
-
import { z as
|
|
254
|
+
import { z as z5 } from "zod";
|
|
189
255
|
|
|
190
256
|
// src/agent-runtime/coding-tool-files.ts
|
|
191
257
|
import { createHash } from "node:crypto";
|
|
@@ -194,6 +260,60 @@ import { realpath as realpath2 } from "node:fs/promises";
|
|
|
194
260
|
// src/agent-runtime/coding-tool-paths.ts
|
|
195
261
|
import { lstat, realpath } from "node:fs/promises";
|
|
196
262
|
import path from "node:path";
|
|
263
|
+
|
|
264
|
+
// src/agent-runtime/coding-tool-refusals.ts
|
|
265
|
+
function codingRefusal(code, message, options = {}) {
|
|
266
|
+
throw new AppError2(code, {
|
|
267
|
+
message,
|
|
268
|
+
status: STITCH_ERROR_STATUS2[code],
|
|
269
|
+
details: { message, ...options.details },
|
|
270
|
+
hint: options.hint,
|
|
271
|
+
..."cause" in options && { cause: options.cause }
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function codingPathRefusal(code, message, path, options = {}) {
|
|
275
|
+
codingRefusal(code, message, {
|
|
276
|
+
details: { path, ...options.details },
|
|
277
|
+
...options.hint && { hint: options.hint }
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function refuseMissingCodingPath(error, relative) {
|
|
281
|
+
const code = error?.code;
|
|
282
|
+
if (error instanceof Error && error.message.includes("is not a regular file")) {
|
|
283
|
+
codingPathRefusal("BAD_REQUEST", "This path is not a regular file", relative, {
|
|
284
|
+
hint: "Use list_directory to see what is here."
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
if (code === "ENOENT") {
|
|
288
|
+
codingPathRefusal("NOT_FOUND", "This path does not exist", relative, {
|
|
289
|
+
hint: "Use list_directory or glob to find the right path."
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
if (code === "ENOTDIR") {
|
|
293
|
+
codingPathRefusal("BAD_REQUEST", "A segment of this path is not a directory", relative, {
|
|
294
|
+
hint: "Check the path with list_directory."
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (code === "ELOOP") {
|
|
298
|
+
codingPathRefusal("FORBIDDEN", "This path is a symlink, which is not followed", relative, {
|
|
299
|
+
hint: "Read or write the target directly, by its own workspace-relative path."
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
if (code === "EISDIR") {
|
|
303
|
+
codingPathRefusal("BAD_REQUEST", "This path is not a regular file", relative, {
|
|
304
|
+
hint: "Use list_directory to see what is here."
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
function refuseUnknownSpillReference(reference) {
|
|
310
|
+
codingRefusal("SPILL_REFERENCE_UNKNOWN", `No spilled output is held under \`${reference}\``, {
|
|
311
|
+
details: { reference },
|
|
312
|
+
hint: "Use the reference returned by the command that spilled its output, not a session or call id."
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/agent-runtime/coding-tool-paths.ts
|
|
197
317
|
function within(root, target) {
|
|
198
318
|
const relative = path.relative(root, target);
|
|
199
319
|
return relative === "" || !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative);
|
|
@@ -579,7 +699,7 @@ function createFileCodingTools(config, limits) {
|
|
|
579
699
|
// src/agent-runtime/coding-tool-listing.ts
|
|
580
700
|
import { realpath as realpath3 } from "node:fs/promises";
|
|
581
701
|
import path3 from "node:path";
|
|
582
|
-
import { z as
|
|
702
|
+
import { z as z3 } from "zod";
|
|
583
703
|
var DEFAULT_EXCLUDED_DIRECTORIES = [
|
|
584
704
|
".git",
|
|
585
705
|
".next",
|
|
@@ -589,28 +709,28 @@ var DEFAULT_EXCLUDED_DIRECTORIES = [
|
|
|
589
709
|
"dist",
|
|
590
710
|
"node_modules"
|
|
591
711
|
];
|
|
592
|
-
var ListInputSchema =
|
|
593
|
-
var ListOutputSchema =
|
|
594
|
-
path:
|
|
595
|
-
entries:
|
|
596
|
-
name:
|
|
597
|
-
kind:
|
|
598
|
-
bytes:
|
|
599
|
-
excluded:
|
|
712
|
+
var ListInputSchema = z3.object({ path: z3.string().min(1).default(".") }).strict();
|
|
713
|
+
var ListOutputSchema = z3.object({
|
|
714
|
+
path: z3.string().min(1),
|
|
715
|
+
entries: z3.array(z3.object({
|
|
716
|
+
name: z3.string().min(1),
|
|
717
|
+
kind: z3.enum(["file", "directory", "symlink", "other"]),
|
|
718
|
+
bytes: z3.int().nonnegative().optional(),
|
|
719
|
+
excluded: z3.boolean().optional()
|
|
600
720
|
}).strict()),
|
|
601
|
-
truncated:
|
|
602
|
-
denied:
|
|
603
|
-
deniedTruncated:
|
|
721
|
+
truncated: z3.boolean(),
|
|
722
|
+
denied: z3.array(CodingDeniedEntrySchema).optional(),
|
|
723
|
+
deniedTruncated: z3.boolean().optional()
|
|
604
724
|
}).strict();
|
|
605
|
-
var GlobInputSchema =
|
|
606
|
-
var GlobOutputSchema =
|
|
607
|
-
paths:
|
|
608
|
-
truncated:
|
|
609
|
-
resultTruncated:
|
|
610
|
-
skippedDirectories:
|
|
611
|
-
scannedFiles:
|
|
612
|
-
denied:
|
|
613
|
-
deniedTruncated:
|
|
725
|
+
var GlobInputSchema = z3.object({ pattern: z3.string().min(1), path: z3.string().min(1).default(".") }).strict();
|
|
726
|
+
var GlobOutputSchema = z3.object({
|
|
727
|
+
paths: z3.array(z3.string().min(1)),
|
|
728
|
+
truncated: z3.boolean(),
|
|
729
|
+
resultTruncated: z3.boolean(),
|
|
730
|
+
skippedDirectories: z3.int().nonnegative(),
|
|
731
|
+
scannedFiles: z3.int().nonnegative(),
|
|
732
|
+
denied: z3.array(CodingDeniedEntrySchema).optional(),
|
|
733
|
+
deniedTruncated: z3.boolean().optional()
|
|
614
734
|
}).strict();
|
|
615
735
|
function compileWorkspaceGlob(pattern) {
|
|
616
736
|
let source = "";
|
|
@@ -743,29 +863,29 @@ function createListingCodingTools(config, limits) {
|
|
|
743
863
|
import { createHash as createHash2 } from "node:crypto";
|
|
744
864
|
import { realpath as realpath4 } from "node:fs/promises";
|
|
745
865
|
import path4 from "node:path";
|
|
746
|
-
import { z as
|
|
747
|
-
var SearchInputSchema =
|
|
748
|
-
query:
|
|
749
|
-
mode:
|
|
750
|
-
regex:
|
|
751
|
-
context:
|
|
752
|
-
include:
|
|
866
|
+
import { z as z4 } from "zod";
|
|
867
|
+
var SearchInputSchema = z4.object({
|
|
868
|
+
query: z4.string().min(1),
|
|
869
|
+
mode: z4.enum(["path", "content"]).default("content"),
|
|
870
|
+
regex: z4.boolean().default(false),
|
|
871
|
+
context: z4.int().nonnegative().max(10).default(0),
|
|
872
|
+
include: z4.string().min(1).describe("Anchored `**`/`*`/`?` pattern matched against the whole workspace-relative path. `*` does not cross `/`; use `**/` to include matching files in subdirectories.").optional()
|
|
753
873
|
}).strict();
|
|
754
|
-
var SearchOutputSchema =
|
|
755
|
-
matches:
|
|
756
|
-
path:
|
|
757
|
-
line:
|
|
758
|
-
text:
|
|
759
|
-
before:
|
|
760
|
-
after:
|
|
874
|
+
var SearchOutputSchema = z4.object({
|
|
875
|
+
matches: z4.array(z4.object({
|
|
876
|
+
path: z4.string().min(1),
|
|
877
|
+
line: z4.int().positive().optional(),
|
|
878
|
+
text: z4.string().optional(),
|
|
879
|
+
before: z4.array(z4.string()).optional(),
|
|
880
|
+
after: z4.array(z4.string()).optional()
|
|
761
881
|
}).strict()),
|
|
762
|
-
truncated:
|
|
763
|
-
scannedFiles:
|
|
764
|
-
skippedDirectories:
|
|
765
|
-
skippedSymlinks:
|
|
766
|
-
denied:
|
|
767
|
-
deniedTruncated:
|
|
768
|
-
hint:
|
|
882
|
+
truncated: z4.boolean(),
|
|
883
|
+
scannedFiles: z4.int().nonnegative().describe("Files admitted by include and host authorization that reached path or content comparison."),
|
|
884
|
+
skippedDirectories: z4.int().nonnegative(),
|
|
885
|
+
skippedSymlinks: z4.int().nonnegative(),
|
|
886
|
+
denied: z4.array(CodingDeniedEntrySchema).optional(),
|
|
887
|
+
deniedTruncated: z4.boolean().optional(),
|
|
888
|
+
hint: z4.string().min(1).optional()
|
|
769
889
|
}).strict();
|
|
770
890
|
function compileSearchRegex(pattern) {
|
|
771
891
|
if (/\\[1-9]/.test(pattern) || /\(\?<?[=!]/.test(pattern)) {
|
|
@@ -784,21 +904,21 @@ function compileSearchRegex(pattern) {
|
|
|
784
904
|
}
|
|
785
905
|
}
|
|
786
906
|
var MAX_SEARCHED_LINE_BYTES = 8192;
|
|
787
|
-
var EditInputSchema =
|
|
788
|
-
path:
|
|
789
|
-
oldText:
|
|
790
|
-
newText:
|
|
791
|
-
replaceAll:
|
|
792
|
-
expectedSha256:
|
|
793
|
-
dryRun:
|
|
907
|
+
var EditInputSchema = z4.object({
|
|
908
|
+
path: z4.string().min(1),
|
|
909
|
+
oldText: z4.string().min(1),
|
|
910
|
+
newText: z4.string(),
|
|
911
|
+
replaceAll: z4.boolean().default(false),
|
|
912
|
+
expectedSha256: z4.string().length(64).optional(),
|
|
913
|
+
dryRun: z4.boolean().default(false)
|
|
794
914
|
}).strict();
|
|
795
|
-
var EditOutputSchema =
|
|
796
|
-
path:
|
|
797
|
-
baseSha256:
|
|
798
|
-
sha256:
|
|
799
|
-
replacements:
|
|
800
|
-
bytes:
|
|
801
|
-
applied:
|
|
915
|
+
var EditOutputSchema = z4.object({
|
|
916
|
+
path: z4.string().min(1),
|
|
917
|
+
baseSha256: z4.string().length(64),
|
|
918
|
+
sha256: z4.string().length(64),
|
|
919
|
+
replacements: z4.int().positive(),
|
|
920
|
+
bytes: z4.int().nonnegative(),
|
|
921
|
+
applied: z4.boolean()
|
|
802
922
|
}).strict();
|
|
803
923
|
function sha256(value) {
|
|
804
924
|
return createHash2("sha256").update(value).digest("hex");
|
|
@@ -1278,17 +1398,17 @@ function createAgentCodingTools2(config) {
|
|
|
1278
1398
|
name: AGENT_CODING_TOOL_NAMES.readOutput,
|
|
1279
1399
|
description: "Read a bounded byte slice from one opaque coding output artifact.",
|
|
1280
1400
|
identity: { serviceName: "coding", action: "read-artifact", method: "POST" },
|
|
1281
|
-
input:
|
|
1282
|
-
reference:
|
|
1283
|
-
offset:
|
|
1284
|
-
maxBytes:
|
|
1401
|
+
input: z5.object({
|
|
1402
|
+
reference: z5.string().min(1),
|
|
1403
|
+
offset: z5.int().nonnegative().default(0),
|
|
1404
|
+
maxBytes: z5.int().positive().optional()
|
|
1285
1405
|
}).strict(),
|
|
1286
|
-
output:
|
|
1287
|
-
reference:
|
|
1288
|
-
offset:
|
|
1289
|
-
text:
|
|
1290
|
-
bytes:
|
|
1291
|
-
totalBytes:
|
|
1406
|
+
output: z5.object({
|
|
1407
|
+
reference: z5.string().min(1),
|
|
1408
|
+
offset: z5.int().nonnegative(),
|
|
1409
|
+
text: z5.string(),
|
|
1410
|
+
bytes: z5.int().nonnegative(),
|
|
1411
|
+
totalBytes: z5.int().nonnegative().optional()
|
|
1292
1412
|
}).strict(),
|
|
1293
1413
|
transports: ["AGENT"],
|
|
1294
1414
|
handler: async ({ input }) => {
|
|
@@ -1327,14 +1447,14 @@ function createAgentCodingTools2(config) {
|
|
|
1327
1447
|
name: AGENT_CODING_TOOL_NAMES.searchOutput,
|
|
1328
1448
|
description: "Search a durable spilled output without loading it into context.",
|
|
1329
1449
|
identity: { serviceName: "coding", action: "search-artifact", method: "POST" },
|
|
1330
|
-
input:
|
|
1331
|
-
reference:
|
|
1332
|
-
query:
|
|
1333
|
-
maxMatches:
|
|
1450
|
+
input: z5.object({
|
|
1451
|
+
reference: z5.string().min(1),
|
|
1452
|
+
query: z5.string().min(1),
|
|
1453
|
+
maxMatches: z5.int().positive().max(limits.maxSearchResults).default(20)
|
|
1334
1454
|
}).strict(),
|
|
1335
|
-
output:
|
|
1336
|
-
reference:
|
|
1337
|
-
matches:
|
|
1455
|
+
output: z5.object({
|
|
1456
|
+
reference: z5.string(),
|
|
1457
|
+
matches: z5.array(z5.object({ line: z5.int().positive(), text: z5.string() }))
|
|
1338
1458
|
}).strict(),
|
|
1339
1459
|
transports: ["AGENT"],
|
|
1340
1460
|
handler: async ({ input }) => {
|
|
@@ -1371,4 +1491,4 @@ function createAgentCodingTools2(config) {
|
|
|
1371
1491
|
];
|
|
1372
1492
|
}
|
|
1373
1493
|
|
|
1374
|
-
export { AgentCodingToolLimitsSchema2, AgentCodingToolAuthorizationSchema2, AgentCodingToolPathAuthorizationSchema2, createAgentCodingTools2 };
|
|
1494
|
+
export { AgentCodingToolLimitsSchema2, AgentCodingToolAuthorizationSchema2, AgentCodingToolPathAuthorizationSchema2, ShellOutputSchema, AgentSandboxRestrictionSchema2, AgentSandboxGradeSchema2, probeAgentProcessSandbox2, missingSandboxRestrictions2, recordAgentSandboxProbe2, codingRefusal, refuseUnknownSpillReference, AGENT_CODING_TOOL_NAMES, createAgentCodingTools2 };
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "./index-q6crhe1n.js";
|
|
4
4
|
import {
|
|
5
5
|
toolErrorFromResult
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-mha6b4vk.js";
|
|
7
7
|
import {
|
|
8
8
|
collectTools2,
|
|
9
9
|
createToolRunner
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-ghwntn9n.js";
|
|
11
11
|
import {
|
|
12
12
|
AppError2
|
|
13
13
|
} from "./index-j9gxbztg.js";
|
|
@@ -23,6 +23,22 @@ import {
|
|
|
23
23
|
assertPositiveSafeInteger
|
|
24
24
|
} from "./index-0s4xebbg.js";
|
|
25
25
|
|
|
26
|
+
// src/process/group-presence.ts
|
|
27
|
+
function processGroupExists(pid) {
|
|
28
|
+
try {
|
|
29
|
+
process.kill(-pid, 0);
|
|
30
|
+
return true;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error instanceof Error && "code" in error) {
|
|
33
|
+
if (error.code === "ESRCH")
|
|
34
|
+
return false;
|
|
35
|
+
if (process.platform === "darwin" && error.code === "EPERM")
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
// src/process/group-settlement.ts
|
|
27
43
|
import { execFile } from "node:child_process";
|
|
28
44
|
function hasLiveGroupMember(table, group) {
|
|
@@ -50,13 +66,26 @@ function processGroups(timeoutMs) {
|
|
|
50
66
|
async function waitForProcessGroupExit(pid, deadline) {
|
|
51
67
|
if (pid === undefined)
|
|
52
68
|
return;
|
|
69
|
+
let observations = 0;
|
|
70
|
+
let lastStates = [];
|
|
53
71
|
for (;; ) {
|
|
54
72
|
const remaining = Math.ceil(deadline - performance.now());
|
|
55
73
|
if (remaining <= 0)
|
|
56
|
-
throw new Error("Command process group
|
|
74
|
+
throw new Error("Command process group settlement was not confirmed after SIGKILL", {
|
|
75
|
+
cause: { groupId: pid, observations, lastStates }
|
|
76
|
+
});
|
|
77
|
+
if (!processGroupExists(pid))
|
|
78
|
+
return;
|
|
57
79
|
const table = await processGroups(remaining);
|
|
80
|
+
observations++;
|
|
58
81
|
if (!hasLiveGroupMember(table, pid))
|
|
59
82
|
return;
|
|
83
|
+
lastStates = table.split(/\r?\n/).flatMap((row) => {
|
|
84
|
+
const fields = /^\s*(\d+)\s+(\S+)\s*$/.exec(row);
|
|
85
|
+
return Number(fields?.[1]) === pid ? [fields?.[2] ?? "unknown"] : [];
|
|
86
|
+
}).slice(0, 16);
|
|
87
|
+
if (!processGroupExists(pid))
|
|
88
|
+
return;
|
|
60
89
|
await sleep(Math.min(5, Math.max(0, deadline - performance.now())));
|
|
61
90
|
}
|
|
62
91
|
}
|
|
@@ -104,16 +133,7 @@ function signalGroup(pid, signal) {
|
|
|
104
133
|
function exists(pid) {
|
|
105
134
|
if (pid === undefined)
|
|
106
135
|
return false;
|
|
107
|
-
|
|
108
|
-
process.kill(-pid, 0);
|
|
109
|
-
return true;
|
|
110
|
-
} catch (error) {
|
|
111
|
-
if (isErrno(error, "ESRCH"))
|
|
112
|
-
return false;
|
|
113
|
-
if (deniedOnDarwin(error))
|
|
114
|
-
return true;
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
136
|
+
return processGroupExists(pid);
|
|
117
137
|
}
|
|
118
138
|
async function signalUntilSettled(pid, signal, deadline) {
|
|
119
139
|
for (;; ) {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
AgentStoreEventEnvelopeSchema2,
|
|
3
3
|
AgentStoreEventPageSchema2,
|
|
4
4
|
AgentRecoverablePageSchema2
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-6qeqdz0z.js";
|
|
6
6
|
import {
|
|
7
7
|
AgentRecordIdSchema2,
|
|
8
8
|
AgentMessageSchema2
|
|
@@ -15,12 +15,64 @@ import {
|
|
|
15
15
|
AgentHistoryMutationSchema2,
|
|
16
16
|
isActiveRunState,
|
|
17
17
|
replaceMessage,
|
|
18
|
+
ArchiveSpillSchema,
|
|
18
19
|
createAgentRuntimeStore2
|
|
19
|
-
} from "./index-
|
|
20
|
+
} from "./index-s2bgwsyr.js";
|
|
20
21
|
|
|
21
22
|
// src/agent-runtime/store-memory.ts
|
|
23
|
+
import { z as z2 } from "zod";
|
|
24
|
+
|
|
25
|
+
// src/agent-runtime/store-memory-archive.ts
|
|
22
26
|
import { z } from "zod";
|
|
23
|
-
var
|
|
27
|
+
var memoryArchive = {
|
|
28
|
+
async export(transaction, conversationId) {
|
|
29
|
+
return {
|
|
30
|
+
projections: [],
|
|
31
|
+
spills: z.array(z.json()).parse(structuredClone(transaction.spills.get(conversationId) ?? []))
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
async import(transaction, archive) {
|
|
35
|
+
const spills = archive.spills.map((value) => ArchiveSpillSchema.parse(value));
|
|
36
|
+
const occupied = new Set([...transaction.spills.values()].flatMap((entries) => entries.map((spill) => spill.reference)));
|
|
37
|
+
for (const spill of spills) {
|
|
38
|
+
if (occupied.has(spill.reference))
|
|
39
|
+
throw new TypeError("Conversation archive spill identity is already present");
|
|
40
|
+
occupied.add(spill.reference);
|
|
41
|
+
}
|
|
42
|
+
transaction.spills.set(archive.conversationId, structuredClone(spills));
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/agent-runtime/store-memory-events.ts
|
|
47
|
+
var memoryEvents = {
|
|
48
|
+
async append(transaction, draft) {
|
|
49
|
+
const current = transaction.events.get(draft.conversationId) ?? [];
|
|
50
|
+
const event = AgentStoreEventEnvelopeSchema2.parse({
|
|
51
|
+
...draft,
|
|
52
|
+
seq: (current.at(-1)?.seq ?? 0) + 1
|
|
53
|
+
});
|
|
54
|
+
if (current.some((candidate) => candidate.eventId === event.eventId)) {
|
|
55
|
+
throw new TypeError("Agent store event identity is already present");
|
|
56
|
+
}
|
|
57
|
+
transaction.events.set(draft.conversationId, [...current, event]);
|
|
58
|
+
return event;
|
|
59
|
+
},
|
|
60
|
+
async list(transaction, input) {
|
|
61
|
+
const selected = (transaction.events.get(input.conversationId) ?? []).filter((event) => (input.fromSeq === undefined || event.seq >= input.fromSeq) && (input.toSeq === undefined || event.seq <= input.toSeq));
|
|
62
|
+
const items = selected.slice(0, input.limit);
|
|
63
|
+
const last = items.at(-1);
|
|
64
|
+
return AgentStoreEventPageSchema2.parse({
|
|
65
|
+
items,
|
|
66
|
+
...selected.length > items.length && last ? { nextSeq: last.seq + 1 } : {}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
async find(transaction, input) {
|
|
70
|
+
return (transaction.events.get(input.conversationId) ?? []).find((event) => event.eventId === input.eventId);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/agent-runtime/store-memory.ts
|
|
75
|
+
var RecoverableCursorSchema = z2.tuple([AgentRecordIdSchema2, AgentRecordIdSchema2]);
|
|
24
76
|
function recoverableCursor(input) {
|
|
25
77
|
return JSON.stringify([input.conversationId, input.run.id]);
|
|
26
78
|
}
|
|
@@ -46,6 +98,9 @@ function cloneHistoryMap(source) {
|
|
|
46
98
|
]));
|
|
47
99
|
}
|
|
48
100
|
var memoryConversations = {
|
|
101
|
+
async isEmpty(transaction, id) {
|
|
102
|
+
return !transaction.heads.has(id) && !transaction.runs.has(id) && !transaction.admissions.has(id) && !transaction.seeds.has(id) && !transaction.histories.has(id) && !transaction.events.has(id) && !transaction.spills.has(id);
|
|
103
|
+
},
|
|
49
104
|
async isPurged(transaction, conversationId) {
|
|
50
105
|
return transaction.purged.has(conversationId);
|
|
51
106
|
},
|
|
@@ -57,6 +112,7 @@ var memoryConversations = {
|
|
|
57
112
|
transaction.seeds.delete(conversationId);
|
|
58
113
|
transaction.histories.delete(conversationId);
|
|
59
114
|
transaction.events.delete(conversationId);
|
|
115
|
+
transaction.spills.delete(conversationId);
|
|
60
116
|
}
|
|
61
117
|
};
|
|
62
118
|
var memoryHead = {
|
|
@@ -140,6 +196,10 @@ var memorySeeds = {
|
|
|
140
196
|
}
|
|
141
197
|
};
|
|
142
198
|
var memoryHistory = {
|
|
199
|
+
async restore(transaction, input) {
|
|
200
|
+
const compacted = new Set(input.compactedMessageIds);
|
|
201
|
+
transaction.histories.set(input.conversationId, input.messages.filter((message) => !compacted.has(message.id)).map((message) => AgentMessageSchema2.parse(structuredClone(message))));
|
|
202
|
+
},
|
|
143
203
|
async load(transaction, conversationId) {
|
|
144
204
|
return (transaction.histories.get(conversationId) ?? []).map((message) => AgentMessageSchema2.parse(structuredClone(message)));
|
|
145
205
|
},
|
|
@@ -181,32 +241,6 @@ var memoryHistory = {
|
|
|
181
241
|
]);
|
|
182
242
|
}
|
|
183
243
|
};
|
|
184
|
-
var memoryEvents = {
|
|
185
|
-
async append(transaction, draft) {
|
|
186
|
-
const current = transaction.events.get(draft.conversationId) ?? [];
|
|
187
|
-
const event = AgentStoreEventEnvelopeSchema2.parse({
|
|
188
|
-
...draft,
|
|
189
|
-
seq: (current.at(-1)?.seq ?? 0) + 1
|
|
190
|
-
});
|
|
191
|
-
if (current.some((candidate) => candidate.eventId === event.eventId)) {
|
|
192
|
-
throw new TypeError("Agent store event identity is already present");
|
|
193
|
-
}
|
|
194
|
-
transaction.events.set(draft.conversationId, [...current, event]);
|
|
195
|
-
return event;
|
|
196
|
-
},
|
|
197
|
-
async list(transaction, input) {
|
|
198
|
-
const selected = (transaction.events.get(input.conversationId) ?? []).filter((event) => (input.fromSeq === undefined || event.seq >= input.fromSeq) && (input.toSeq === undefined || event.seq <= input.toSeq));
|
|
199
|
-
const items = selected.slice(0, input.limit);
|
|
200
|
-
const last = items.at(-1);
|
|
201
|
-
return AgentStoreEventPageSchema2.parse({
|
|
202
|
-
items,
|
|
203
|
-
...selected.length > items.length && last ? { nextSeq: last.seq + 1 } : {}
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
async find(transaction, input) {
|
|
207
|
-
return (transaction.events.get(input.conversationId) ?? []).find((event) => event.eventId === input.eventId);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
244
|
function scanMemoryRecoverable(runs, input) {
|
|
211
245
|
const descriptors = [...runs].flatMap(([conversationId, conversationRuns]) => [...conversationRuns.values()].filter((record) => isActiveRunState(record.run.state)).map((record) => ({ conversationId, run: record.run }))).sort((left, right) => left.conversationId.localeCompare(right.conversationId) || left.run.id.localeCompare(right.run.id));
|
|
212
246
|
const cursorTuple = input.cursor ? parseRecoverableCursor(input.cursor) : undefined;
|
|
@@ -230,6 +264,7 @@ function createMemoryAgentRuntimeStore2() {
|
|
|
230
264
|
let seeds = new Map;
|
|
231
265
|
let histories = new Map;
|
|
232
266
|
let events = new Map;
|
|
267
|
+
let spills = new Map;
|
|
233
268
|
let transactionTail = Promise.resolve();
|
|
234
269
|
const driver = {
|
|
235
270
|
async transaction(work) {
|
|
@@ -243,6 +278,7 @@ function createMemoryAgentRuntimeStore2() {
|
|
|
243
278
|
});
|
|
244
279
|
const transaction = {
|
|
245
280
|
purged: new Set(purged),
|
|
281
|
+
spills: structuredClone(spills),
|
|
246
282
|
heads: cloneHeadMap(heads),
|
|
247
283
|
runs: cloneNestedMap(runs, (record) => AgentStoredRunSchema2.parse(structuredClone(record))),
|
|
248
284
|
admissions: cloneNestedMap(admissions, (receipt) => AgentAdmissionReceiptSchema2.parse(structuredClone(receipt))),
|
|
@@ -256,6 +292,7 @@ function createMemoryAgentRuntimeStore2() {
|
|
|
256
292
|
try {
|
|
257
293
|
const result = await work(transaction);
|
|
258
294
|
purged = transaction.purged;
|
|
295
|
+
spills = transaction.spills;
|
|
259
296
|
heads = transaction.heads;
|
|
260
297
|
runs = transaction.runs;
|
|
261
298
|
admissions = transaction.admissions;
|
|
@@ -274,6 +311,7 @@ function createMemoryAgentRuntimeStore2() {
|
|
|
274
311
|
seeds: memorySeeds,
|
|
275
312
|
history: memoryHistory,
|
|
276
313
|
events: memoryEvents,
|
|
314
|
+
archive: memoryArchive,
|
|
277
315
|
async scanRecoverable(input) {
|
|
278
316
|
return scanMemoryRecoverable(runs, input);
|
|
279
317
|
}
|