stitchkit 0.110.1 → 0.110.3
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 +16 -0
- package/dist/agent-runtime/archive-projection.d.ts +10 -0
- package/dist/agent-runtime/archive-projection.d.ts.map +1 -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-events.d.ts.map +1 -1
- 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-support.d.ts +5 -5
- 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 +1131 -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-replay.d.ts +4 -0
- package/dist/agent-runtime/store-replay.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +3 -0
- package/dist/agent-runtime/store.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 +1 -2
- package/dist/entrypoints/agent-runtime/harness.js +4 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -5
- 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 +2 -1
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +27 -15
- package/dist/entrypoints/tools.js +5 -3
- package/dist/{index-0gs4ymfj.js → index-4fgg1507.js} +31 -2
- package/dist/{index-c17xcx4k.js → index-56yx8dxp.js} +19 -96
- package/dist/{index-8rstkvcf.js → index-7c046kxr.js} +1 -1
- package/dist/{index-tjdsyrys.js → index-bm180f2d.js} +203 -83
- package/dist/{index-924500c3.js → index-ddkwkcvn.js} +2 -2
- package/dist/{index-c0hffcmj.js → index-dgfah0g8.js} +21 -9
- package/dist/index-j1cwtyk1.js +2269 -0
- package/dist/index-snef22zr.js +94 -0
- package/dist/{index-5p55xreg.js → index-w619fqvv.js} +67 -29
- package/llms/agent-runtime.3.txt +4 -0
- package/llms/agent-runtime.txt +75 -0
- package/llms-full.txt +79 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/index-8ks9b85e.js +0 -129
- package/dist/index-d2h99n7d.js +0 -1071
|
@@ -4,13 +4,6 @@ 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
|
|
@@ -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 };
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
createLocalStepDurability2,
|
|
23
23
|
isAgentToolError2,
|
|
24
24
|
createToolDurabilityContext
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-56yx8dxp.js";
|
|
26
26
|
import {
|
|
27
27
|
canonicalAgentJson2,
|
|
28
28
|
createToolChronology,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
isAssistantHistoryEvidence2,
|
|
32
32
|
isCompleteAgentHistoryTurn,
|
|
33
33
|
assistantStatus
|
|
34
|
-
} from "./index-
|
|
34
|
+
} from "./index-4fgg1507.js";
|
|
35
35
|
import {
|
|
36
36
|
messageOf
|
|
37
37
|
} from "./index-g149e9pk.js";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
AgentRecoverableDescriptorSchema2,
|
|
6
6
|
AgentRecoverablePageSchema2,
|
|
7
7
|
canonicalAgentJson2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-4fgg1507.js";
|
|
9
9
|
import {
|
|
10
10
|
AgentMessageSchema2,
|
|
11
11
|
AgentRunSchema2
|
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
AgentSeedReceiptSchema2,
|
|
18
18
|
AgentHistoryMutationSchema2,
|
|
19
19
|
appendEventIn,
|
|
20
|
+
ArchiveProjectionSchema,
|
|
20
21
|
createAgentRuntimeStore2
|
|
21
|
-
} from "./index-
|
|
22
|
+
} from "./index-j1cwtyk1.js";
|
|
22
23
|
import {
|
|
23
24
|
AgentConversationPageSchema2,
|
|
24
25
|
AgentConversationMessagePageSchema2
|
|
@@ -63,6 +64,14 @@ function sqliteConversationPurge(database) {
|
|
|
63
64
|
if (table === null || table === undefined)
|
|
64
65
|
return;
|
|
65
66
|
return {
|
|
67
|
+
async isEmpty(transaction, conversationId) {
|
|
68
|
+
for (const table of OWNED_TABLES) {
|
|
69
|
+
const row = transaction.prepare(`SELECT 1 FROM ${table} WHERE conversation_id = ? LIMIT 1`).get(conversationId);
|
|
70
|
+
if (row !== null && row !== undefined)
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return transaction.prepare("SELECT 1 FROM stitchkit_agent_runtime_children WHERE parent_conversation_id = ? OR child_conversation_id = ? LIMIT 1").get(conversationId, conversationId) == null;
|
|
74
|
+
},
|
|
66
75
|
async isPurged(transaction, conversationId) {
|
|
67
76
|
const row = transaction.prepare("SELECT conversation_id FROM stitchkit_agent_runtime_purged WHERE conversation_id = ?").get(conversationId);
|
|
68
77
|
return row !== null && row !== undefined;
|
|
@@ -584,13 +593,7 @@ var sqliteArchive = {
|
|
|
584
593
|
if (typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.archiveType === "runtime-snapshot") {
|
|
585
594
|
continue;
|
|
586
595
|
}
|
|
587
|
-
const projection =
|
|
588
|
-
name: z4.string(),
|
|
589
|
-
version: z4.int().positive(),
|
|
590
|
-
uptoSeq: z4.int().nonnegative(),
|
|
591
|
-
value: z4.json(),
|
|
592
|
-
updatedAt: z4.string()
|
|
593
|
-
}).strict().parse(raw);
|
|
596
|
+
const projection = ArchiveProjectionSchema.parse(raw);
|
|
594
597
|
transaction.prepare(`
|
|
595
598
|
INSERT INTO stitchkit_agent_runtime_projections
|
|
596
599
|
(conversation_id, name, version, upto_seq, payload, updated_at)
|
|
@@ -629,6 +632,15 @@ var sqliteArchive = {
|
|
|
629
632
|
|
|
630
633
|
// src/agent-runtime/sqlite-history.ts
|
|
631
634
|
var sqliteHistory = {
|
|
635
|
+
async restore(transaction, input) {
|
|
636
|
+
const compacted = new Set(input.compactedMessageIds);
|
|
637
|
+
for (const [position, message] of input.messages.entries()) {
|
|
638
|
+
if (message.conversationId !== input.conversationId)
|
|
639
|
+
throw new TypeError("Restored history has a foreign conversation");
|
|
640
|
+
transaction.prepare(`INSERT INTO stitchkit_agent_runtime_messages
|
|
641
|
+
(conversation_id, id, position, active, payload) VALUES (?, ?, ?, ?, ?)`).run(input.conversationId, message.id, position, compacted.has(message.id) ? 0 : 1, encodeJson(message));
|
|
642
|
+
}
|
|
643
|
+
},
|
|
632
644
|
async load(transaction, conversationId) {
|
|
633
645
|
return transaction.prepare(`
|
|
634
646
|
SELECT payload FROM stitchkit_agent_runtime_messages
|