stitchkit 0.136.0 → 0.136.1
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 +13 -0
- package/README.md +12 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/vocabulary.d.ts +80 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-parts/model.d.ts +94 -0
- package/dist/agent-parts/model.d.ts.map +1 -1
- package/dist/agent-parts/parts.d.ts +176 -0
- package/dist/agent-parts/parts.d.ts.map +1 -1
- package/dist/agent-runtime/browser/browser-control-contract.d.ts +440 -0
- package/dist/agent-runtime/browser/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser/control-schema.d.ts +528 -0
- package/dist/agent-runtime/browser/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +704 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/history/run-history-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts +0 -2
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-approval-signature.d.ts +5 -1
- package/dist/agent-runtime/loop/run-approval-signature.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-loop-events.d.ts +6 -1
- package/dist/agent-runtime/loop/run-loop-events.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-stream-recorded.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-call.d.ts +11 -3
- package/dist/agent-runtime/loop/run-tool-call.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-normalize.d.ts +4 -0
- package/dist/agent-runtime/providers/ai-sdk-normalize.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-tools.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +1 -3
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-json-projection.d.ts +29 -0
- package/dist/agent-runtime/schemas-json-projection.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-message.d.ts +88 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-run.d.ts +88 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -1
- package/dist/agent-runtime/stores/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/stores/branch-replay.d.ts +264 -0
- package/dist/agent-runtime/stores/branch-replay.d.ts.map +1 -1
- package/dist/agent-runtime/stores/conversations.d.ts +88 -0
- package/dist/agent-runtime/stores/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/stores/sql-rows.d.ts +64 -0
- package/dist/agent-runtime/stores/sql-rows.d.ts.map +1 -1
- package/dist/agent-runtime/stores/store-driver-contract.d.ts +616 -0
- package/dist/agent-runtime/stores/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/stores/store-events.d.ts +1056 -0
- package/dist/agent-runtime/stores/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/stores/store.d.ts +1232 -0
- package/dist/agent-runtime/stores/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +69 -5
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +164 -36
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/testing/store-conformance-support.d.ts +82 -18
- package/dist/agent-runtime/testing/store-conformance-support.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/notification-delivery.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +5 -4
- package/dist/entrypoints/agent-executor/claude-sdk.js +7 -6
- package/dist/entrypoints/agent-executor/claude.js +7 -6
- package/dist/entrypoints/agent-executor/codex.js +6 -5
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +4 -3
- package/dist/entrypoints/agent-executor/testing.js +7 -6
- package/dist/entrypoints/agent-executor.js +7 -7
- package/dist/entrypoints/agent-runtime/ai-sdk.js +30 -24
- package/dist/entrypoints/agent-runtime/anthropic.js +3 -3
- package/dist/entrypoints/agent-runtime/browser.js +8 -7
- package/dist/entrypoints/agent-runtime/harness.js +14 -14
- package/dist/entrypoints/agent-runtime/openai.js +3 -3
- package/dist/entrypoints/agent-runtime/openrouter.js +3 -3
- package/dist/entrypoints/agent-runtime/postgres.js +9 -9
- package/dist/entrypoints/agent-runtime/realtime.js +9 -8
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +10 -10
- package/dist/entrypoints/agent-runtime/sqlite/node.js +10 -10
- package/dist/entrypoints/agent-runtime/testing.js +8 -8
- package/dist/entrypoints/agent-runtime.js +21 -21
- package/dist/entrypoints/application/diagnostic-journal.js +14 -10
- package/dist/entrypoints/application.js +16 -4
- package/dist/entrypoints/tools/agent.js +2 -2
- package/dist/entrypoints/tools/toolkit.js +1 -1
- package/dist/entrypoints/tools.js +5 -3
- package/dist/index-1psbyyhj.js +21 -0
- package/dist/{index-kzsetgh9.js → index-26v8hjqm.js} +4 -4
- package/dist/{index-4243301z.js → index-2wm9b9vs.js} +5 -5
- package/dist/{index-tb36xawm.js → index-32ew02z1.js} +1 -1
- package/dist/{index-1en7k3q5.js → index-4q9tmzea.js} +3 -3
- package/dist/{index-shte29pg.js → index-8cnfgwg8.js} +148 -106
- package/dist/{index-mkmep637.js → index-9m1m92rg.js} +1 -1
- package/dist/index-a1rjr381.js +114 -0
- package/dist/{index-6kwdfb9m.js → index-akesakvj.js} +23 -4
- package/dist/{index-rg08syp1.js → index-d5mhgx72.js} +7 -5
- package/dist/{index-36mtj8xm.js → index-e4w0sfm1.js} +2 -2
- package/dist/{index-jperyn0c.js → index-gj4wdts6.js} +1 -1
- package/dist/{index-pd9e8rz4.js → index-gvv7y0s4.js} +1 -1
- package/dist/{index-vebzvse6.js → index-jy907kcs.js} +24 -1
- package/dist/{index-54wp467c.js → index-k5azb3v3.js} +4 -21
- package/dist/{index-qcy8et93.js → index-kaq9nb7h.js} +6 -6
- package/dist/{index-vse7x1qt.js → index-knqye3gv.js} +1 -1
- package/dist/{index-tav72wz5.js → index-ks4rhtcc.js} +5 -0
- package/dist/{index-xnqab06h.js → index-mtpcax6d.js} +3 -3
- package/dist/{index-7qza24g1.js → index-px9r6wv1.js} +1 -1
- package/dist/{index-epwvp88y.js → index-r9w7wfgn.js} +1 -1
- package/dist/{index-aacwkve4.js → index-sjq4akrx.js} +3 -5
- package/dist/{index-5dxgx3yj.js → index-tcv71frn.js} +1 -1
- package/dist/{index-1zy31r3b.js → index-v92djygb.js} +1 -1
- package/dist/{index-9f60gnfn.js → index-xaa3603f.js} +4 -11
- package/dist/{index-j3r7r1mh.js → index-yv7d6tav.js} +1 -1
- package/dist/{index-hberxns4.js → index-zagc12j1.js} +5 -5
- package/dist/{index-j5vzhj3d.js → index-zqc64g69.js} +3 -3
- package/dist/{index-hpzhz1vm.js → index-zthekmrt.js} +2 -2
- package/dist/internal/json-stringify.d.ts +37 -0
- package/dist/internal/json-stringify.d.ts.map +1 -0
- package/llms/agent-runtime.5.txt +1 -1
- package/llms/agent-runtime.txt +14 -0
- package/llms/application.2.txt +6 -3
- package/llms/application.3.txt +2 -1
- package/llms/application.txt +4 -1
- package/llms-full.txt +27 -6
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentTextPartSchema2,
|
|
3
3
|
AgentReasoningPartSchema2,
|
|
4
|
+
AgentFilePartSchema2,
|
|
5
|
+
AgentSourcePartSchema2,
|
|
4
6
|
AgentToolCallPartSchema2,
|
|
5
|
-
AgentToolResultPartSchema2
|
|
6
|
-
|
|
7
|
+
AgentToolResultPartSchema2,
|
|
8
|
+
AgentToolApprovalRequestPartSchema2,
|
|
9
|
+
AgentToolApprovalResponsePartSchema2,
|
|
10
|
+
AgentOpaquePartSchema2,
|
|
11
|
+
AgentControlPartSchema2
|
|
12
|
+
} from "./index-ks4rhtcc.js";
|
|
7
13
|
|
|
8
14
|
// src/agent-executor/vocabulary.ts
|
|
9
15
|
import { z } from "zod";
|
|
16
|
+
var ExecutorToolResultPartSchema = AgentToolResultPartSchema2.omit({ modelOutput: true });
|
|
17
|
+
var ExecutorMessagePartSchema = z.discriminatedUnion("type", [
|
|
18
|
+
AgentTextPartSchema2,
|
|
19
|
+
AgentReasoningPartSchema2,
|
|
20
|
+
AgentFilePartSchema2,
|
|
21
|
+
AgentSourcePartSchema2,
|
|
22
|
+
AgentToolCallPartSchema2,
|
|
23
|
+
ExecutorToolResultPartSchema,
|
|
24
|
+
AgentToolApprovalRequestPartSchema2,
|
|
25
|
+
AgentToolApprovalResponsePartSchema2,
|
|
26
|
+
AgentOpaquePartSchema2,
|
|
27
|
+
AgentControlPartSchema2
|
|
28
|
+
]);
|
|
10
29
|
var ExecutorRawSchema2 = z.strictObject({
|
|
11
30
|
source: z.string().min(1),
|
|
12
31
|
type: z.string().min(1)
|
|
@@ -19,7 +38,7 @@ var base = {
|
|
|
19
38
|
var ExecutorTextDeltaSchema = AgentTextPartSchema2.omit({ provider: true }).extend(base).strict();
|
|
20
39
|
var ExecutorReasoningDeltaSchema = AgentReasoningPartSchema2.extend(base).strict();
|
|
21
40
|
var ExecutorToolCallDeltaSchema = AgentToolCallPartSchema2.extend(base).strict();
|
|
22
|
-
var ExecutorToolResultDeltaSchema =
|
|
41
|
+
var ExecutorToolResultDeltaSchema = ExecutorToolResultPartSchema.extend(base).strict();
|
|
23
42
|
var ExecutorRequestDeltaSchema = z.strictObject({
|
|
24
43
|
type: z.literal("request"),
|
|
25
44
|
...base,
|
|
@@ -141,4 +160,4 @@ var ExecutorDeltaSchema2 = z.discriminatedUnion("type", [
|
|
|
141
160
|
ExecutorWindowDeltaSchema
|
|
142
161
|
]);
|
|
143
162
|
|
|
144
|
-
export { ExecutorRawSchema2, ExecutorTokenUsageSchema2, ExecutorModelUsageSchema2, ExecutorThreadDispositionSchema2, ExecutorStartupPhaseSchema2, ExecutorStatusDeltaSchema2, ExecutorPlanEntryStatusSchema2, ExecutorPlanEntryPrioritySchema2, ExecutorPlanEntrySchema2, ExecutorPlanDeltaSchema2, ExecutorErrorKindSchema2, ExecutorDeltaSchema2 };
|
|
163
|
+
export { ExecutorMessagePartSchema, ExecutorRawSchema2, ExecutorTokenUsageSchema2, ExecutorModelUsageSchema2, ExecutorThreadDispositionSchema2, ExecutorStartupPhaseSchema2, ExecutorStatusDeltaSchema2, ExecutorPlanEntryStatusSchema2, ExecutorPlanEntryPrioritySchema2, ExecutorPlanEntrySchema2, ExecutorPlanDeltaSchema2, ExecutorErrorKindSchema2, ExecutorDeltaSchema2 };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
AgentRecordVersionSchema2,
|
|
8
8
|
AgentTimestampSchema2,
|
|
9
9
|
AgentMessageSchema2
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-yv7d6tav.js";
|
|
11
11
|
import {
|
|
12
12
|
AgentCodingToolAuthorizationSchema2,
|
|
13
13
|
ShellOutputSchema,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
runStateForTerminalReason2,
|
|
24
24
|
AgentRunSchema2,
|
|
25
25
|
AgentSnapshotSchema2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-gvv7y0s4.js";
|
|
27
27
|
import {
|
|
28
28
|
PurgeInvocationPayloadsInputSchema2,
|
|
29
29
|
PurgeInvocationPayloadsResultSchema2,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
AgentSeedReceiptSchema2,
|
|
61
61
|
isActiveRunState,
|
|
62
62
|
emptyHead
|
|
63
|
-
} from "./index-
|
|
63
|
+
} from "./index-kaq9nb7h.js";
|
|
64
64
|
import {
|
|
65
65
|
StepEventPayloadSchema,
|
|
66
66
|
ParkEventPayloadSchema,
|
|
@@ -2180,14 +2180,16 @@ function branchPartAt(ids, part) {
|
|
|
2180
2180
|
callId: ids.reference("call", part.callId),
|
|
2181
2181
|
input: branchToolJson(ids, part.toolName, part.input, false)
|
|
2182
2182
|
};
|
|
2183
|
-
case "tool-result":
|
|
2183
|
+
case "tool-result": {
|
|
2184
|
+
const { modelOutput: _shownInSource, ...result } = part;
|
|
2184
2185
|
return {
|
|
2185
|
-
...
|
|
2186
|
+
...result,
|
|
2186
2187
|
callId: ids.reference("call", part.callId),
|
|
2187
2188
|
...part.output !== undefined && {
|
|
2188
2189
|
output: part.outcome === "success" ? branchToolJson(ids, part.toolName, part.output, true) : branchOpaqueJson(ids, part.output)
|
|
2189
2190
|
}
|
|
2190
2191
|
};
|
|
2192
|
+
}
|
|
2191
2193
|
case "tool-approval-request":
|
|
2192
2194
|
return {
|
|
2193
2195
|
type: part.type,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentControlRequestSchema2,
|
|
3
3
|
AgentControlResponseSchema2
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-26v8hjqm.js";
|
|
5
5
|
import {
|
|
6
6
|
createAgentRuntimeEventSink2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-gj4wdts6.js";
|
|
8
8
|
import {
|
|
9
9
|
assertPositiveSafeInteger
|
|
10
10
|
} from "./index-gr0kxymw.js";
|
|
@@ -76,6 +76,29 @@ var AgentToolModelOutputSchema2 = z.discriminatedUnion("type", [
|
|
|
76
76
|
...ProviderOptionsField
|
|
77
77
|
})
|
|
78
78
|
]);
|
|
79
|
+
var RecordedOptionsField = {
|
|
80
|
+
providerOptions: z.record(z.string(), z.record(z.string(), z.json())).optional(),
|
|
81
|
+
cacheControl: AgentCacheControlSchema2.optional()
|
|
82
|
+
};
|
|
83
|
+
var AgentRecordedToolModelOutputSchema = z.discriminatedUnion("type", [
|
|
84
|
+
z.object({ type: z.literal("text"), value: z.string(), ...RecordedOptionsField }),
|
|
85
|
+
z.object({ type: z.literal("error-text"), value: z.string(), ...RecordedOptionsField }),
|
|
86
|
+
z.object({ type: z.literal("json"), value: z.json(), ...RecordedOptionsField }),
|
|
87
|
+
z.object({ type: z.literal("error-json"), value: z.json(), ...RecordedOptionsField }),
|
|
88
|
+
z.object({
|
|
89
|
+
type: z.literal("execution-denied"),
|
|
90
|
+
reason: z.string().optional(),
|
|
91
|
+
...RecordedOptionsField
|
|
92
|
+
}),
|
|
93
|
+
z.object({
|
|
94
|
+
type: z.literal("content"),
|
|
95
|
+
value: z.array(z.discriminatedUnion("type", [
|
|
96
|
+
z.object({ type: z.literal("text"), text: z.string(), ...RecordedOptionsField }),
|
|
97
|
+
z.object({ type: z.literal("custom"), ...RecordedOptionsField })
|
|
98
|
+
])),
|
|
99
|
+
...RecordedOptionsField
|
|
100
|
+
})
|
|
101
|
+
]);
|
|
79
102
|
var AgentModelSystemMessageSchema2 = z.object({
|
|
80
103
|
role: z.literal("system"),
|
|
81
104
|
content: z.string(),
|
|
@@ -227,4 +250,4 @@ function createAgentGeneratedFile(mediaType, payload, providerMetadata, filename
|
|
|
227
250
|
};
|
|
228
251
|
}
|
|
229
252
|
|
|
230
|
-
export { AgentModelProviderOptionsSchema2, AgentCacheControlSchema2, AgentModelResponseFormatSchema2, AgentModelFileDataSchema2, AgentToolModelOutputSchema2, AgentModelSystemMessageSchema2, normalizeAgentInstructions, AgentModelUserContentPartSchema2, AgentModelAssistantContentPartSchema2, AgentModelToolContentPartSchema2, AgentModelUserMessageSchema2, AgentModelAssistantMessageSchema2, AgentModelToolMessageSchema2, AgentModelMessageSchema2, createAgentGeneratedFile };
|
|
253
|
+
export { AgentModelProviderOptionsSchema2, AgentCacheControlSchema2, AgentModelResponseFormatSchema2, AgentModelFileDataSchema2, AgentToolModelOutputSchema2, AgentRecordedToolModelOutputSchema, AgentModelSystemMessageSchema2, normalizeAgentInstructions, AgentModelUserContentPartSchema2, AgentModelAssistantContentPartSchema2, AgentModelToolContentPartSchema2, AgentModelUserMessageSchema2, AgentModelAssistantMessageSchema2, AgentModelToolMessageSchema2, AgentModelMessageSchema2, createAgentGeneratedFile };
|
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
flattenToolJsonSchema2
|
|
18
18
|
} from "./index-edpkm3k7.js";
|
|
19
|
+
import {
|
|
20
|
+
AgentToolError2
|
|
21
|
+
} from "./index-1psbyyhj.js";
|
|
19
22
|
import {
|
|
20
23
|
collectToolSurface
|
|
21
24
|
} from "./index-bjrcbcn2.js";
|
|
@@ -27,26 +30,6 @@ import {
|
|
|
27
30
|
isAsyncIterable
|
|
28
31
|
} from "./index-ps3djm8d.js";
|
|
29
32
|
|
|
30
|
-
// src/tools/agent-tool-error.ts
|
|
31
|
-
var AGENT_TOOL_ERROR_BRAND = Symbol.for("stitchkit.AgentToolError");
|
|
32
|
-
|
|
33
|
-
class AgentToolError2 extends Error {
|
|
34
|
-
output;
|
|
35
|
-
constructor(output, cause) {
|
|
36
|
-
let message = "Tool execution failed";
|
|
37
|
-
try {
|
|
38
|
-
message = JSON.stringify(output);
|
|
39
|
-
} catch {}
|
|
40
|
-
super(message, cause === undefined ? undefined : { cause });
|
|
41
|
-
this.name = "AgentToolError";
|
|
42
|
-
this.output = output;
|
|
43
|
-
Object.defineProperty(this, AGENT_TOOL_ERROR_BRAND, { value: true });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function isAgentToolError2(value) {
|
|
47
|
-
return typeof value === "object" && value !== null && AGENT_TOOL_ERROR_BRAND in value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
33
|
// src/tools/agent-tools.ts
|
|
51
34
|
var SELF_VALIDATED_NON_ITERABLE_EXECUTORS = new WeakSet;
|
|
52
35
|
function validateToolOutput(schema, value) {
|
|
@@ -228,4 +211,4 @@ function mountAgentTools2(servicesOrConfig, maybeConfig) {
|
|
|
228
211
|
return buildAgentTools(servicesOrConfig, maybeConfig, "mountAgentTools");
|
|
229
212
|
}
|
|
230
213
|
|
|
231
|
-
export {
|
|
214
|
+
export { finalizeAgentToolOutput, zodToAgentInputJsonSchema, defineAgentTool2, buildAgentTools, mountAgentTools2 };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentCacheControlSchema2
|
|
3
|
+
} from "./index-jy907kcs.js";
|
|
1
4
|
import {
|
|
2
5
|
AgentRecordIdSchema2,
|
|
3
6
|
AgentStoreEventKindSchema2,
|
|
@@ -7,19 +10,16 @@ import {
|
|
|
7
10
|
AgentTimestampSchema2,
|
|
8
11
|
AgentMessageSchema2,
|
|
9
12
|
AgentUsageSchema2
|
|
10
|
-
} from "./index-
|
|
13
|
+
} from "./index-yv7d6tav.js";
|
|
11
14
|
import {
|
|
12
15
|
AgentProviderResponseSchema2
|
|
13
|
-
} from "./index-
|
|
16
|
+
} from "./index-px9r6wv1.js";
|
|
14
17
|
import {
|
|
15
18
|
AgentRunOperationSchema2,
|
|
16
19
|
AgentTerminalReasonSchema2,
|
|
17
20
|
AgentRunSchema2,
|
|
18
21
|
AgentSnapshotSchema2
|
|
19
|
-
} from "./index-
|
|
20
|
-
import {
|
|
21
|
-
AgentCacheControlSchema2
|
|
22
|
-
} from "./index-vebzvse6.js";
|
|
22
|
+
} from "./index-gvv7y0s4.js";
|
|
23
23
|
import {
|
|
24
24
|
canonicalZodJson
|
|
25
25
|
} from "./index-brhhaygm.js";
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentRecordedToolModelOutputSchema
|
|
3
|
+
} from "./index-jy907kcs.js";
|
|
4
|
+
|
|
1
5
|
// src/agent-parts/parts.ts
|
|
2
6
|
import { z } from "zod";
|
|
3
7
|
var AgentProviderEnvelopeSchema2 = z.object({
|
|
@@ -40,6 +44,7 @@ var AgentToolResultPartSchema2 = z.object({
|
|
|
40
44
|
toolName: z.string().min(1),
|
|
41
45
|
outcome: z.enum(["success", "error", "interrupted"]),
|
|
42
46
|
output: z.json().optional(),
|
|
47
|
+
modelOutput: AgentRecordedToolModelOutputSchema.optional(),
|
|
43
48
|
provider: AgentProviderEnvelopeSchema2.optional()
|
|
44
49
|
});
|
|
45
50
|
var AgentToolApprovalRequestPartSchema2 = z.object({
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
offerTurnDelta,
|
|
10
10
|
safeJsonValue,
|
|
11
11
|
clampUniqueWindowName
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-sjq4akrx.js";
|
|
13
13
|
import {
|
|
14
14
|
isSupportedImageMediaType
|
|
15
15
|
} from "./index-65p8v81y.js";
|
|
16
16
|
import {
|
|
17
17
|
mergeRateLimitEvent2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-9m1m92rg.js";
|
|
19
19
|
import {
|
|
20
20
|
endEngineTurn
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-tcv71frn.js";
|
|
22
22
|
import {
|
|
23
23
|
errnoOf
|
|
24
24
|
} from "./index-jj9228tt.js";
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-tav72wz5.js";
|
|
4
|
-
import {
|
|
2
|
+
ExecutorMessagePartSchema,
|
|
5
3
|
ExecutorThreadDispositionSchema2,
|
|
6
4
|
ExecutorStartupPhaseSchema2,
|
|
7
5
|
ExecutorDeltaSchema2
|
|
8
|
-
} from "./index-
|
|
6
|
+
} from "./index-akesakvj.js";
|
|
9
7
|
import {
|
|
10
8
|
createBoundedChannel2
|
|
11
9
|
} from "./index-02kdtrcd.js";
|
|
@@ -60,7 +58,7 @@ var TurnOfferSchema2 = z.strictObject({
|
|
|
60
58
|
threadId: ExecutorIdSchema,
|
|
61
59
|
turnOrdinal: TurnOrdinalSchema,
|
|
62
60
|
fence: Fence,
|
|
63
|
-
input: z.array(
|
|
61
|
+
input: z.array(ExecutorMessagePartSchema).min(1),
|
|
64
62
|
inputDigest: z.string().min(1),
|
|
65
63
|
nativeThreadId: z.string().min(1).optional()
|
|
66
64
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentMessagePartSchema2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-ks4rhtcc.js";
|
|
4
4
|
import {
|
|
5
5
|
AgentJsonObjectSchema2,
|
|
6
6
|
AgentMessageSchema2,
|
|
7
7
|
AgentUsageSchema2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-yv7d6tav.js";
|
|
9
9
|
import {
|
|
10
10
|
AgentProviderResponseSchema2
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-px9r6wv1.js";
|
|
12
12
|
import {
|
|
13
13
|
assistantStatus
|
|
14
14
|
} from "./index-kgj8j7bv.js";
|
|
@@ -16,9 +16,6 @@ import {
|
|
|
16
16
|
linkAbortSignals
|
|
17
17
|
} from "./index-rptj3qnc.js";
|
|
18
18
|
|
|
19
|
-
// src/agent-runtime/runtime-internals.ts
|
|
20
|
-
import { z } from "zod";
|
|
21
|
-
|
|
22
19
|
// src/agent-runtime/run-store-retry.ts
|
|
23
20
|
var STORE_RETRY_DELAYS_MS = [25, 100, 400];
|
|
24
21
|
function storeRetryDelay(failures) {
|
|
@@ -222,10 +219,6 @@ function findRun(runs, runId) {
|
|
|
222
219
|
throw new AgentRuntimeConflictError2("run lookup");
|
|
223
220
|
return run;
|
|
224
221
|
}
|
|
225
|
-
function jsonValue(value) {
|
|
226
|
-
const parsed = z.json().safeParse(value);
|
|
227
|
-
return parsed.success ? parsed.data : { message: "Non-JSON tool output omitted" };
|
|
228
|
-
}
|
|
229
222
|
function providerEnvelope(value) {
|
|
230
223
|
const parsed = AgentJsonObjectSchema2.safeParse(value);
|
|
231
224
|
if (!parsed.success)
|
|
@@ -390,4 +383,4 @@ function createIdleDeadline(parent, timeoutMs, maxDurationMs) {
|
|
|
390
383
|
};
|
|
391
384
|
}
|
|
392
385
|
|
|
393
|
-
export { withStoreRetries, AgentRuntimeConflictError2, AgentRunUnsettledError2, appliedSnapshot, terminalOfSnapshot, terminalOfRunView, commitAgentRunTerminal, findRun,
|
|
386
|
+
export { withStoreRetries, AgentRuntimeConflictError2, AgentRunUnsettledError2, appliedSnapshot, terminalOfSnapshot, terminalOfRunView, commitAgentRunTerminal, findRun, providerEnvelope, parseOptionalAgentUsage, providerResponseIdentity, abortTerminalReason, addUsage, mergeModelTotals, normalizeTokenUsage, createIdleDeadline };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
AppendAgentStoreEventSchema2,
|
|
4
4
|
AgentStoreEventPageSchema2,
|
|
5
5
|
AgentMessageSchema2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-yv7d6tav.js";
|
|
7
7
|
import {
|
|
8
8
|
AgentRunSchema2
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-gvv7y0s4.js";
|
|
10
10
|
import {
|
|
11
11
|
SqlIntegerSchema,
|
|
12
12
|
HeadRowSchema,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
isRuntimeSnapshotEntry,
|
|
27
27
|
appendEventIn,
|
|
28
28
|
ArchiveSpillSchema
|
|
29
|
-
} from "./index-
|
|
29
|
+
} from "./index-d5mhgx72.js";
|
|
30
30
|
import {
|
|
31
31
|
InvocationExpiredPayloadSchema,
|
|
32
32
|
parsePayloadPurgeCutoff,
|
|
@@ -38,11 +38,11 @@ import {
|
|
|
38
38
|
AgentAdmissionReceiptSchema2,
|
|
39
39
|
AgentSeedReceiptSchema2,
|
|
40
40
|
AgentHistoryMutationSchema2
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-kaq9nb7h.js";
|
|
42
42
|
import {
|
|
43
43
|
AgentConversationPageSchema2,
|
|
44
44
|
AgentConversationMessagePageSchema2
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-v92djygb.js";
|
|
46
46
|
|
|
47
47
|
// src/agent-runtime/stores/companion-host.ts
|
|
48
48
|
function createCompanionHost(input) {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
AgentStoreEventEnvelopeSchema2,
|
|
4
4
|
AgentStoreEventPageSchema2,
|
|
5
5
|
AgentMessageSchema2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-yv7d6tav.js";
|
|
7
7
|
import {
|
|
8
8
|
InvocationExpiredPayloadSchema,
|
|
9
9
|
parsePayloadPurgeCutoff,
|
|
@@ -16,14 +16,14 @@ import {
|
|
|
16
16
|
AgentSeedReceiptSchema2,
|
|
17
17
|
AgentHistoryMutationSchema2,
|
|
18
18
|
isActiveRunState
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-kaq9nb7h.js";
|
|
20
20
|
import {
|
|
21
21
|
ArchiveProjectionSchema,
|
|
22
22
|
isRuntimeSnapshotEntry,
|
|
23
23
|
replaceMessage,
|
|
24
24
|
ArchiveSpillSchema,
|
|
25
25
|
createAgentRuntimeStore2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-d5mhgx72.js";
|
|
27
27
|
|
|
28
28
|
// src/agent-runtime/stores/store-memory.ts
|
|
29
29
|
import { z as z2 } from "zod";
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
AgentTextPartSchema2,
|
|
6
6
|
AgentFilePartSchema2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-ks4rhtcc.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentControlRequestSchema2,
|
|
10
10
|
AgentControlResponseSchema2,
|
|
11
11
|
AgentControlDeliverySchema2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-26v8hjqm.js";
|
|
13
13
|
|
|
14
14
|
// src/agent-runtime/browser/browser-control-contract.ts
|
|
15
15
|
import { z } from "zod";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/** A JSON value as `JSON.stringify` writes it and `z.json()` reads it back. */
|
|
3
|
+
export type JsonValue = z.infer<ReturnType<typeof z.json>>;
|
|
4
|
+
/** Why `JSON.stringify` cannot write a value. */
|
|
5
|
+
export type JsonProjectionRefusalReason = 'bigint' | 'cycle' | 'threw';
|
|
6
|
+
/** The first value `JSON.stringify` cannot write, and the dotted path to it (`''` is the root). */
|
|
7
|
+
export interface JsonProjectionRefusal {
|
|
8
|
+
readonly reason: JsonProjectionRefusalReason;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
}
|
|
11
|
+
export type JsonProjection = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly value: JsonValue;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly refusal: JsonProjectionRefusal;
|
|
17
|
+
};
|
|
18
|
+
/** `a BigInt at items.0.n` — the refusal as one phrase for an error message. */
|
|
19
|
+
export declare function describeJsonRefusal(refusal: JsonProjectionRefusal): string;
|
|
20
|
+
/**
|
|
21
|
+
* Write `value` as `JSON.stringify` would and read it back, without the string in between.
|
|
22
|
+
*
|
|
23
|
+
* The result is what a model or a later turn reads: a key whose value is `undefined`, a function
|
|
24
|
+
* or a symbol is left out, the same in an array becomes `null`, a non-finite number becomes
|
|
25
|
+
* `null`, and `toJSON` (a `Date`) is called. A value `JSON.stringify` throws on — a BigInt, a
|
|
26
|
+
* cycle, a throwing `toJSON` or getter — is refused with the path to it; a top-level value it
|
|
27
|
+
* writes as nothing reads back as `null`. An own `__proto__` key is dropped, as `z.json()` drops it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function projectJson(value: unknown): JsonProjection;
|
|
30
|
+
/**
|
|
31
|
+
* `projectJson` for a value kept only as a record — a provider's tool result, a raw provider
|
|
32
|
+
* chunk, a tool input. A value `JSON.stringify` cannot write is recorded as a marker naming the
|
|
33
|
+
* field (`{ unrecordable: 'a BigInt at n' }`), never as something that looks like data and never
|
|
34
|
+
* by failing the work that produced it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function recordedJson(value: unknown): JsonValue;
|
|
37
|
+
//# sourceMappingURL=json-stringify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-stringify.d.ts","sourceRoot":"","sources":["../../src/internal/json-stringify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAE3D,iDAAiD;AACjD,MAAM,MAAM,2BAA2B,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAEvE,mGAAmG;AACnG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,2BAA2B,CAAC;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAcpE,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAQ1E;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAyD1D;AAUD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAKtD"}
|
package/llms/agent-runtime.5.txt
CHANGED
|
@@ -58,7 +58,7 @@ Server-only, peer-free optional application runtime. Runs models exclusively thr
|
|
|
58
58
|
| `AgentConversationPurgeResultSchema` / `AgentConversationPurgeResult` | schema / _type_ | typed deletion/refusal outcomes; active refusal includes run IDs |
|
|
59
59
|
| `AgentConversationPurgedError` | class | runtime mutation rejected because its conversation ID is permanently purged |
|
|
60
60
|
| `AgentConversationPurgeDriver` | _type_ | optional `driver.conversations` capability: serialized tombstone read and atomic removal of all owned records |
|
|
61
|
-
| `projectAgentHistory` | function | asynchronously project canonical records and resolved multimodal files into provider-valid peer-free `AgentModelMessage[]` |
|
|
61
|
+
| `projectAgentHistory` | function | asynchronously project canonical records and resolved multimodal files into provider-valid peer-free `AgentModelMessage[]`; a `tool-result` part sends its recorded `modelOutput` (what the tool's `toModelOutput` showed the model in the live step) and calls `toModelOutput` only for a record without it; `resolveToolModelOutput` runs first |
|
|
62
62
|
| `defineModelRegistry` | function | typed language-model descriptors, capabilities and `AgentModelDriverFactory` construction |
|
|
63
63
|
| `AgentModelCatalogSchema` / `AgentModelCatalog` | schema / _type_ | provider-neutral complete/partial model catalog with separately sourced popularity, metrics, prices and observation time |
|
|
64
64
|
| `AgentModelCatalogEntrySchema` / `AgentModelCatalogEntry` | schema / _type_ | one canonical provider model descriptor with optional price, popularity and metric evidence |
|
package/llms/agent-runtime.txt
CHANGED
|
@@ -554,6 +554,20 @@ with `mountAgentTools` from `stitchkit/tools` (including the single-argument
|
|
|
554
554
|
`mountAgentTools({ runtimeTools, access })` form when no HTTP service contracts are mounted). Both
|
|
555
555
|
return `AgentTool` / `AgentToolSet` carrying JSON Schema 2020-12 `inputSchema`, Zod `parseInput`,
|
|
556
556
|
optional `needsApproval`, `onInputAvailable`, and `toModelOutput` returning `AgentToolModelOutput`.
|
|
557
|
+
Without `toModelOutput`, a tool's output reaches the model, and every later turn that reads the run
|
|
558
|
+
back, as `JSON.stringify` writes it: a field left `undefined` drops its key and a `Date` becomes its
|
|
559
|
+
ISO string; a `toModelOutput` JSON value is read the same way. An output `JSON.stringify` cannot
|
|
560
|
+
write (a BigInt, a cycle, a throwing `toJSON`) fails the call with an `AgentToolError` naming the
|
|
561
|
+
tool and the field and saying the tool ran, so the model does not take it for a call that never
|
|
562
|
+
happened. That holds with `toModelOutput` too: a branch presents the result again from the
|
|
563
|
+
recorded output.
|
|
564
|
+
|
|
565
|
+
What `toModelOutput` showed the model is recorded beside the result (`tool-result.modelOutput`),
|
|
566
|
+
and a later turn sends that again rather than calling `toModelOutput` a second time: history is
|
|
567
|
+
what the model read, and it does not change when the function does. Three records are presented
|
|
568
|
+
anew, from the JSON form of the output — where a `Date` is its ISO string: one written before the
|
|
569
|
+
field existed, one whose model output held a `file` part, and a branched one. To present recorded
|
|
570
|
+
results differently on purpose, pass `resolveToolModelOutput` to the history projection.
|
|
557
571
|
|
|
558
572
|
When an operation needs one or a few model steps without a durable conversation store — structured
|
|
559
573
|
extraction, classification, a bounded tool loop, or standalone streaming — call `completeText`,
|
package/llms/application.2.txt
CHANGED
|
@@ -255,9 +255,12 @@ Opt into `delivery: { version, actions, project }` on `createNotificationOutbox`
|
|
|
255
255
|
The pure `actions(payload)` selector runs at enqueue; the versioned plan remains
|
|
256
256
|
fixed throughout retry. Each `send` receives its action and a stable idempotency
|
|
257
257
|
key; return a small JSON receipt such as a remote message or uploaded object ID.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
The receipt is kept as `JSON.stringify` writes it: a field left `undefined` drops,
|
|
259
|
+
a `Date` becomes its ISO string. An action that returned is confirmed and is never
|
|
260
|
+
sent again: a result JSON cannot carry (a BigInt, a cycle), or one that does not fit
|
|
261
|
+
the state's byte budget, is kept as `receipt: null` with
|
|
262
|
+
`unrecorded: 'not-json' | 'too-large'` and reported to `onError`, naming the field
|
|
263
|
+
for `not-json`.
|
|
261
264
|
`project(notification, receipts)` applies all confirmed results locally and must
|
|
262
265
|
be idempotent. Checkpoints and the final projection timestamp live in the existing
|
|
263
266
|
atomic StateStore; completed receipts retain them within retention/byte limits.
|
package/llms/application.3.txt
CHANGED
|
@@ -299,7 +299,8 @@ never trust a client-supplied owner ID as that scope.
|
|
|
299
299
|
immutable executor `version`, pure `actions(payload)` plan selector (1–128 unique
|
|
300
300
|
names, each at most 128 characters), and idempotent `project(notification, receipts)`.
|
|
301
301
|
`send` receives optional `action` and stable `idempotencyKey`, and returns a JSON
|
|
302
|
-
remote receipt (void becomes null)
|
|
302
|
+
remote receipt (void becomes null), kept as `JSON.stringify` writes it. A result JSON
|
|
303
|
+
cannot carry (a BigInt, a cycle; `onError` names the field) or that does not fit the
|
|
303
304
|
byte budget is kept as `receipt: null` with `unrecorded: 'not-json' | 'too-large'`;
|
|
304
305
|
the action stays confirmed and is not sent again. `retiredVersions` maps earlier
|
|
305
306
|
plan versions to their `NotificationProjection` so queued items drain after an
|
package/llms/application.txt
CHANGED
|
@@ -642,7 +642,10 @@ if (result.outcome === 'refused') internalCounter.add(1, { reason: result.reason
|
|
|
642
642
|
await journal.close({ timeoutMs: 5_000 })
|
|
643
643
|
```
|
|
644
644
|
|
|
645
|
-
The owner schema and JSON serialization run synchronously before admission.
|
|
645
|
+
The owner schema and JSON serialization run synchronously before admission. An event is kept as
|
|
646
|
+
`JSON.stringify` writes it, and only if the schema reads that form back: an optional field left
|
|
647
|
+
`undefined` is accepted, while a cycle, a BigInt or a `Date` in a `z.date()` field is `invalid`.
|
|
648
|
+
Accepted frames carry
|
|
646
649
|
a process epoch and contiguous sequence and retain their complete bytes inside both pending limits
|
|
647
650
|
until their append attempt settles. Capacity, invalid, oversized, closed and terminal-failure
|
|
648
651
|
refusals are explicit; accepted ordered frames are never evicted.
|