stitchkit 0.110.1 → 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 +6 -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-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 +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/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 +1 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +25 -15
- package/dist/entrypoints/tools.js +5 -3
- package/dist/{index-c17xcx4k.js → index-56yx8dxp.js} +19 -96
- package/dist/{index-0gs4ymfj.js → index-6qeqdz0z.js} +7 -1
- package/dist/{index-924500c3.js → index-79zxnh52.js} +2 -2
- package/dist/{index-8rstkvcf.js → index-7c046kxr.js} +1 -1
- package/dist/{index-tjdsyrys.js → index-bm180f2d.js} +203 -83
- package/dist/{index-5p55xreg.js → index-e9rbhw1s.js} +67 -29
- package/dist/index-s2bgwsyr.js +2280 -0
- package/dist/index-snef22zr.js +94 -0
- package/dist/{index-c0hffcmj.js → index-zbssway3.js} +19 -2
- package/llms/agent-runtime.3.txt +3 -0
- package/llms/agent-runtime.txt +60 -0
- package/llms-full.txt +63 -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
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentSandboxRestrictionSchema2,
|
|
3
|
+
AgentSandboxGradeSchema2,
|
|
4
|
+
probeAgentProcessSandbox2,
|
|
5
|
+
missingSandboxRestrictions2,
|
|
6
|
+
recordAgentSandboxProbe2,
|
|
7
|
+
refuseUnknownSpillReference
|
|
8
|
+
} from "../index-bm180f2d.js";
|
|
1
9
|
import {
|
|
2
10
|
AgentRecordIdSchema2,
|
|
3
11
|
AgentRecordVersionSchema2,
|
|
@@ -36,6 +44,9 @@ import {
|
|
|
36
44
|
AgentRunMetricsSchema2
|
|
37
45
|
} from "../index-8kzct1d6.js";
|
|
38
46
|
import {
|
|
47
|
+
BranchAgentConversationInputSchema2,
|
|
48
|
+
AgentConversationBranchReceiptSchema2,
|
|
49
|
+
AgentConversationBranchResultSchema2,
|
|
39
50
|
AgentConversationPurgeInputSchema2,
|
|
40
51
|
AgentConversationPurgeResultSchema2,
|
|
41
52
|
AgentConversationPurgedError2,
|
|
@@ -47,7 +58,7 @@ import {
|
|
|
47
58
|
AgentHistoryMutationSchema2,
|
|
48
59
|
ACTIVE_AGENT_RUN_STATES2,
|
|
49
60
|
createAgentRuntimeStore2
|
|
50
|
-
} from "../index-
|
|
61
|
+
} from "../index-s2bgwsyr.js";
|
|
51
62
|
import {
|
|
52
63
|
AgentStoreEventKindSchema2,
|
|
53
64
|
AgentStoreEventEnvelopeSchema2,
|
|
@@ -79,7 +90,7 @@ import {
|
|
|
79
90
|
decodeAgentConversationArchive2,
|
|
80
91
|
isAssistantHistoryEvidence2,
|
|
81
92
|
isCompleteAgentHistoryTurn
|
|
82
|
-
} from "../index-
|
|
93
|
+
} from "../index-6qeqdz0z.js";
|
|
83
94
|
import"../index-5w6t91ze.js";
|
|
84
95
|
import {
|
|
85
96
|
AgentRuntimeConflictError2,
|
|
@@ -111,7 +122,7 @@ import {
|
|
|
111
122
|
agentGoalStateSlot2,
|
|
112
123
|
agentTodoStateSlot2,
|
|
113
124
|
createAgentRuntime2
|
|
114
|
-
} from "../index-
|
|
125
|
+
} from "../index-79zxnh52.js";
|
|
115
126
|
import {
|
|
116
127
|
AgentConversationSummarySchema2,
|
|
117
128
|
AgentConversationPageSchema2,
|
|
@@ -127,7 +138,7 @@ import"../index-ghwntn9n.js";
|
|
|
127
138
|
import {
|
|
128
139
|
mountAgent2,
|
|
129
140
|
buildToolManifest2
|
|
130
|
-
} from "../index-
|
|
141
|
+
} from "../index-7c046kxr.js";
|
|
131
142
|
import {
|
|
132
143
|
createBoundedSinkManager
|
|
133
144
|
} from "../index-qaet40b2.js";
|
|
@@ -172,21 +183,18 @@ import {
|
|
|
172
183
|
StepAbortedError2,
|
|
173
184
|
ParkRecordDecodeError2,
|
|
174
185
|
ParkAbortedError2
|
|
175
|
-
} from "../index-
|
|
176
|
-
import
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
probeAgentProcessSandbox2,
|
|
180
|
-
missingSandboxRestrictions2,
|
|
181
|
-
recordAgentSandboxProbe2,
|
|
182
|
-
refuseUnknownSpillReference
|
|
183
|
-
} from "../index-8ks9b85e.js";
|
|
186
|
+
} from "../index-snef22zr.js";
|
|
187
|
+
import"../index-56yx8dxp.js";
|
|
188
|
+
import"../index-2kbysk9s.js";
|
|
189
|
+
import"../index-84bf5spd.js";
|
|
184
190
|
import {
|
|
185
191
|
createMemoryAgentRuntimeStore2
|
|
186
|
-
} from "../index-
|
|
192
|
+
} from "../index-e9rbhw1s.js";
|
|
187
193
|
import {
|
|
188
194
|
createAgentRuntimeEventSink2
|
|
189
195
|
} from "../index-616xh7f2.js";
|
|
196
|
+
import"../index-e1sjcjfy.js";
|
|
197
|
+
import"../index-zrtrjkbf.js";
|
|
190
198
|
import {
|
|
191
199
|
MAX_TIMER_MS
|
|
192
200
|
} from "../index-eemvahkc.js";
|
|
@@ -202,7 +210,6 @@ import {
|
|
|
202
210
|
createTraceContext2,
|
|
203
211
|
childSpan2
|
|
204
212
|
} from "../index-yex7eg1v.js";
|
|
205
|
-
|
|
206
213
|
// src/agent-runtime/child-tools.ts
|
|
207
214
|
import { z as z2 } from "zod";
|
|
208
215
|
|
|
@@ -2614,6 +2621,8 @@ export {
|
|
|
2614
2621
|
AgentContextOverflowError2 as AgentContextOverflowError,
|
|
2615
2622
|
AgentControlPartSchema2 as AgentControlPartSchema,
|
|
2616
2623
|
AgentConversationArchiveSchema2 as AgentConversationArchiveSchema,
|
|
2624
|
+
AgentConversationBranchReceiptSchema2 as AgentConversationBranchReceiptSchema,
|
|
2625
|
+
AgentConversationBranchResultSchema2 as AgentConversationBranchResultSchema,
|
|
2617
2626
|
AgentConversationMessagePageSchema2 as AgentConversationMessagePageSchema,
|
|
2618
2627
|
AgentConversationPageSchema2 as AgentConversationPageSchema,
|
|
2619
2628
|
AgentConversationPurgeInputSchema2 as AgentConversationPurgeInputSchema,
|
|
@@ -2702,6 +2711,7 @@ export {
|
|
|
2702
2711
|
AgentUsageSchema2 as AgentUsageSchema,
|
|
2703
2712
|
AgentUsageValueSchema2 as AgentUsageValueSchema,
|
|
2704
2713
|
AppendAgentStoreEventSchema2 as AppendAgentStoreEventSchema,
|
|
2714
|
+
BranchAgentConversationInputSchema2 as BranchAgentConversationInputSchema,
|
|
2705
2715
|
CheckpointRunAssistantSchema2 as CheckpointRunAssistantSchema,
|
|
2706
2716
|
CommitRunTerminalSchema2 as CommitRunTerminalSchema,
|
|
2707
2717
|
CompletionInvocationInputSchema2 as CompletionInvocationInputSchema,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
EffectUnresolvedError2
|
|
2
|
+
EffectUnresolvedError2
|
|
3
|
+
} from "../index-snef22zr.js";
|
|
4
|
+
import {
|
|
3
5
|
createLocalStepDurability2,
|
|
4
6
|
AgentToolError2,
|
|
5
7
|
isAgentToolError2
|
|
6
|
-
} from "../index-
|
|
8
|
+
} from "../index-56yx8dxp.js";
|
|
7
9
|
import {
|
|
8
10
|
normalizeError2
|
|
9
11
|
} from "../index-fynr93w4.js";
|
|
@@ -31,7 +33,7 @@ import {
|
|
|
31
33
|
mountAgent2,
|
|
32
34
|
describeToolCatalog2,
|
|
33
35
|
buildToolManifest2
|
|
34
|
-
} from "../index-
|
|
36
|
+
} from "../index-7c046kxr.js";
|
|
35
37
|
import"../index-m38ej7e5.js";
|
|
36
38
|
import {
|
|
37
39
|
ALL_TRANSPORTS2,
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DURABILITY_STEP_EVENT_KIND2,
|
|
3
|
+
DURABILITY_PARK_EVENT_KIND,
|
|
4
|
+
DURABILITY_EVENT_EVENT_KIND,
|
|
5
|
+
DURABILITY_EFFECT_EVENT_KIND,
|
|
6
|
+
StepEventPayloadSchema,
|
|
7
|
+
ParkEventPayloadSchema,
|
|
8
|
+
DeliveredEventPayloadSchema,
|
|
9
|
+
EffectEventPayloadSchema,
|
|
10
|
+
StepResultDecodeError2,
|
|
11
|
+
StepResultNotSerializableError2,
|
|
12
|
+
StepAbortedError2,
|
|
13
|
+
EffectUnresolvedError2,
|
|
14
|
+
ParkRecordDecodeError2,
|
|
15
|
+
ParkAbortedError2
|
|
16
|
+
} from "./index-snef22zr.js";
|
|
1
17
|
import {
|
|
2
18
|
raceAbort
|
|
3
19
|
} from "./index-b0kddvzw.js";
|
|
@@ -8,102 +24,9 @@ import {
|
|
|
8
24
|
MAX_TIMER_MS
|
|
9
25
|
} from "./index-eemvahkc.js";
|
|
10
26
|
|
|
11
|
-
// src/durability/contract.ts
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
var DURABILITY_STEP_EVENT_KIND2 = "durability/step";
|
|
14
|
-
var DURABILITY_PARK_EVENT_KIND = "durability/park";
|
|
15
|
-
var DURABILITY_EVENT_EVENT_KIND = "durability/event";
|
|
16
|
-
var DURABILITY_EFFECT_EVENT_KIND = "durability/effect";
|
|
17
|
-
var StepEventPayloadSchema = z.object({
|
|
18
|
-
runId: z.string().min(1),
|
|
19
|
-
stepName: z.string().min(1),
|
|
20
|
-
encoded: z.string()
|
|
21
|
-
});
|
|
22
|
-
var SleepParkSchema = z.object({
|
|
23
|
-
runId: z.string().min(1),
|
|
24
|
-
kind: z.literal("sleep"),
|
|
25
|
-
name: z.string().min(1),
|
|
26
|
-
deadline: z.number()
|
|
27
|
-
});
|
|
28
|
-
var WaitParkSchema = z.object({
|
|
29
|
-
runId: z.string().min(1),
|
|
30
|
-
kind: z.literal("wait"),
|
|
31
|
-
event: z.string().min(1),
|
|
32
|
-
id: z.string().min(1)
|
|
33
|
-
});
|
|
34
|
-
var ParkEventPayloadSchema = z.discriminatedUnion("kind", [
|
|
35
|
-
SleepParkSchema,
|
|
36
|
-
WaitParkSchema
|
|
37
|
-
]);
|
|
38
|
-
var DeliveredEventPayloadSchema = z.object({
|
|
39
|
-
runId: z.string().min(1),
|
|
40
|
-
event: z.string().min(1),
|
|
41
|
-
id: z.string().min(1),
|
|
42
|
-
encoded: z.string()
|
|
43
|
-
});
|
|
44
|
-
var EffectIdentity = { runId: z.string().min(1), effectName: z.string().min(1) };
|
|
45
|
-
var EffectEventPayloadSchema = z.discriminatedUnion("phase", [
|
|
46
|
-
z.object({ ...EffectIdentity, phase: z.literal("intent") }),
|
|
47
|
-
z.object({
|
|
48
|
-
...EffectIdentity,
|
|
49
|
-
phase: z.literal("accepted"),
|
|
50
|
-
encoded: z.string(),
|
|
51
|
-
via: z.enum(["run", "reconcile"])
|
|
52
|
-
}),
|
|
53
|
-
z.object({ ...EffectIdentity, phase: z.literal("uncertain") })
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
class StepResultDecodeError2 extends Error {
|
|
57
|
-
constructor(message, options) {
|
|
58
|
-
super(message, options);
|
|
59
|
-
this.name = "StepResultDecodeError";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
class StepResultNotSerializableError2 extends Error {
|
|
64
|
-
constructor(stepName, cause) {
|
|
65
|
-
super(`Step "${stepName}" returned a value that is not JSON-serializable`, {
|
|
66
|
-
cause
|
|
67
|
-
});
|
|
68
|
-
this.name = "StepResultNotSerializableError";
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
class StepAbortedError2 extends Error {
|
|
73
|
-
constructor(stepName) {
|
|
74
|
-
super(`Step "${stepName}" was aborted before it started`);
|
|
75
|
-
this.name = "StepAbortedError";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
class EffectUnresolvedError2 extends Error {
|
|
80
|
-
effectName;
|
|
81
|
-
reason;
|
|
82
|
-
constructor(effectName, reason, options) {
|
|
83
|
-
super(`Effect "${effectName}" is unresolved (${reason}); its intent stands`, options);
|
|
84
|
-
this.effectName = effectName;
|
|
85
|
-
this.reason = reason;
|
|
86
|
-
this.name = "EffectUnresolvedError";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
class ParkRecordDecodeError2 extends Error {
|
|
91
|
-
constructor(message, options) {
|
|
92
|
-
super(message, options);
|
|
93
|
-
this.name = "ParkRecordDecodeError";
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
class ParkAbortedError2 extends Error {
|
|
98
|
-
constructor(park) {
|
|
99
|
-
super(`Park "${park}" was aborted before it was satisfied`);
|
|
100
|
-
this.name = "ParkAbortedError";
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
27
|
// src/durability/json.ts
|
|
105
|
-
import { z
|
|
106
|
-
var DurableJsonSchema =
|
|
28
|
+
import { z } from "zod";
|
|
29
|
+
var DurableJsonSchema = z.custom((value) => isJsonData(value, {
|
|
107
30
|
maxDepth: 100,
|
|
108
31
|
maxNodes: Number.MAX_SAFE_INTEGER,
|
|
109
32
|
omitObjectUndefined: false
|
|
@@ -653,4 +576,4 @@ function resolveToolDurability(context, callId, signal) {
|
|
|
653
576
|
return contexts.get(context)?.(callId, signal);
|
|
654
577
|
}
|
|
655
578
|
|
|
656
|
-
export {
|
|
579
|
+
export { createLocalStepDurability2, AgentToolError2, isAgentToolError2, createToolDurabilityContext, resolveToolDurability };
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
var AgentStoreEventKindSchema2 = z.enum([
|
|
18
18
|
"runtime/baseline",
|
|
19
|
+
"runtime/branched",
|
|
20
|
+
"runtime/branch-observation",
|
|
19
21
|
"runtime/transition",
|
|
20
22
|
"invocation/started",
|
|
21
23
|
"invocation/finished",
|
|
@@ -188,7 +190,11 @@ var AgentStoreTransitionSchema2 = z3.discriminatedUnion("type", [
|
|
|
188
190
|
z3.object({ type: z3.literal("checkpoint"), input: CheckpointRunAssistantSchema2 }).strict(),
|
|
189
191
|
z3.object({ type: z3.literal("operation"), input: RecordRunOperationSchema2 }).strict(),
|
|
190
192
|
z3.object({ type: z3.literal("interrupt"), input: RequestRunInterruptSchema2 }).strict(),
|
|
191
|
-
z3.object({
|
|
193
|
+
z3.object({
|
|
194
|
+
type: z3.literal("recover"),
|
|
195
|
+
input: RecoverAgentRunSchema2,
|
|
196
|
+
assistant: AgentMessageSchema2.optional()
|
|
197
|
+
}).strict(),
|
|
192
198
|
z3.object({ type: z3.literal("terminal"), input: CommitRunTerminalSchema2 }).strict(),
|
|
193
199
|
z3.object({ type: z3.literal("compact"), input: ReplaceCompactedRangeSchema2 }).strict(),
|
|
194
200
|
z3.object({ type: z3.literal("seed"), input: SeedConversationInputSchema2 }).strict()
|
|
@@ -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-6qeqdz0z.js";
|
|
35
35
|
import {
|
|
36
36
|
messageOf
|
|
37
37
|
} from "./index-g149e9pk.js";
|
|
@@ -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 };
|