stitchkit 0.87.1 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +190 -0
- package/dist/agent-runtime/child-blocking.d.ts +17 -0
- package/dist/agent-runtime/child-blocking.d.ts.map +1 -0
- package/dist/agent-runtime/child-budget-policy.d.ts +23 -0
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -0
- package/dist/agent-runtime/children-contract.d.ts +155 -0
- package/dist/agent-runtime/children-contract.d.ts.map +1 -0
- package/dist/agent-runtime/children.d.ts +4 -99
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/coding-shell-process.d.ts +33 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-contract.d.ts +18 -0
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-paths.d.ts +1 -1
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-utf8.d.ts +28 -0
- package/dist/agent-runtime/coding-tool-utf8.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +20 -0
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/durability-contract.d.ts +176 -0
- package/dist/agent-runtime/durability-contract.d.ts.map +1 -0
- package/dist/agent-runtime/durability-json.d.ts +3 -0
- package/dist/agent-runtime/durability-json.d.ts.map +1 -0
- package/dist/agent-runtime/durability-ledger.d.ts +16 -0
- package/dist/agent-runtime/durability-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/durability-scheduler.d.ts +29 -0
- package/dist/agent-runtime/durability-scheduler.d.ts.map +1 -0
- package/dist/agent-runtime/durability.d.ts +14 -0
- package/dist/agent-runtime/durability.d.ts.map +1 -0
- package/dist/agent-runtime/event-search.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +37 -0
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +8 -0
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/models.d.ts +14 -0
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +8 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts +16 -0
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -0
- package/dist/agent-runtime/prompt.d.ts +23 -0
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +16 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +25 -0
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-broker.d.ts +7 -0
- package/dist/agent-runtime/sandbox-broker.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts +9 -0
- package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts +22 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap.d.ts +14 -0
- package/dist/agent-runtime/sandbox-bubblewrap.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-coding-adapter.d.ts +15 -0
- package/dist/agent-runtime/sandbox-coding-adapter.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-coding.d.ts +15 -0
- package/dist/agent-runtime/sandbox-coding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-contract.d.ts +93 -0
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-owner.d.ts +11 -0
- package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process.d.ts +8 -0
- package/dist/agent-runtime/sandbox-process.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-session.d.ts +5 -0
- package/dist/agent-runtime/sandbox-session.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox.d.ts +19 -0
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +6 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts +127 -0
- package/dist/agent-runtime/store-driver.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +106 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts +14 -0
- package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +115 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime-browser.js +5 -3
- package/dist/agent-runtime-coding-tools.js +11 -1236
- package/dist/agent-runtime-harness.d.ts +1 -1
- package/dist/agent-runtime-harness.d.ts.map +1 -1
- package/dist/agent-runtime-harness.js +69 -19
- package/dist/agent-runtime-openrouter.d.ts +3 -12
- package/dist/agent-runtime-openrouter.d.ts.map +1 -1
- package/dist/agent-runtime-openrouter.js +22 -9
- package/dist/agent-runtime-sandbox.d.ts +5 -0
- package/dist/agent-runtime-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime-sandbox.js +797 -0
- package/dist/agent-runtime-sqlite-bun.js +5 -5
- package/dist/agent-runtime-sqlite-node.js +5 -5
- package/dist/agent-runtime.d.ts +6 -5
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +266 -69
- package/dist/application.js +26 -26
- package/dist/cli.js +8 -8
- package/dist/{index-rcgsnrr6.js → index-31jw8fjq.js} +3 -3
- package/dist/{index-9hw9eq48.js → index-7601qfg1.js} +14 -14
- package/dist/{index-3xnq72rz.js → index-7rkhw9ec.js} +14 -1
- package/dist/{index-0vfdh685.js → index-8c3a7m4g.js} +1 -1
- package/dist/{index-t7gh5w3v.js → index-bn2cjajt.js} +27 -6
- package/dist/{index-z2452tsw.js → index-bt14acb5.js} +2 -2
- package/dist/index-cp20z0n6.js +1351 -0
- package/dist/{index-9553432s.js → index-crykmqkr.js} +1 -1
- package/dist/{index-6g273pqx.js → index-fadnxwna.js} +89 -7
- package/dist/{index-p1b1y93x.js → index-gtj3zc53.js} +5 -1
- package/dist/{index-5wezxcxx.js → index-hrbajay7.js} +107 -5
- package/dist/{index-35aefxby.js → index-hw2chdvy.js} +768 -49
- package/dist/{index-0ydchz76.js → index-mnm4qp0p.js} +5 -5
- package/dist/{index-tg3m2ec5.js → index-mqv3b5rh.js} +4 -1
- package/dist/{index-1szetq6f.js → index-q3ve2d1k.js} +30 -8
- package/dist/{index-hkm6wysp.js → index-y64k3s0h.js} +1 -1
- package/dist/{index-z1m86vc8.js → index-zwkgfq1s.js} +97 -86
- package/dist/{index-wn9cb82y.js → index-zyvby92n.js} +12 -9
- package/dist/index.js +13 -13
- package/dist/server/index.js +9 -9
- package/dist/testing/agent-store-conformance.d.ts.map +1 -1
- package/dist/testing.js +69 -24
- package/dist/tool-invoker.js +6 -6
- package/dist/tools/agent.d.ts +6 -0
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts +6 -0
- package/dist/tools/connections/define.d.ts.map +1 -0
- package/dist/tools/connections/errors.d.ts +50 -0
- package/dist/tools/connections/errors.d.ts.map +1 -0
- package/dist/tools/connections/http.d.ts +3 -0
- package/dist/tools/connections/http.d.ts.map +1 -0
- package/dist/tools/connections/index.d.ts +19 -0
- package/dist/tools/connections/index.d.ts.map +1 -0
- package/dist/tools/connections/index.js +1047 -0
- package/dist/tools/connections/instance.d.ts +3 -0
- package/dist/tools/connections/instance.d.ts.map +1 -0
- package/dist/tools/connections/json-rpc.d.ts +8 -0
- package/dist/tools/connections/json-rpc.d.ts.map +1 -0
- package/dist/tools/connections/limits.d.ts +36 -0
- package/dist/tools/connections/limits.d.ts.map +1 -0
- package/dist/tools/connections/mcp-client.d.ts +44 -0
- package/dist/tools/connections/mcp-client.d.ts.map +1 -0
- package/dist/tools/connections/mcp.d.ts +5 -0
- package/dist/tools/connections/mcp.d.ts.map +1 -0
- package/dist/tools/connections/mount.d.ts +12 -0
- package/dist/tools/connections/mount.d.ts.map +1 -0
- package/dist/tools/connections/openapi-document.d.ts +4 -0
- package/dist/tools/connections/openapi-document.d.ts.map +1 -0
- package/dist/tools/connections/openapi.d.ts +5 -0
- package/dist/tools/connections/openapi.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +29 -0
- package/dist/tools/connections/runtime.d.ts.map +1 -0
- package/dist/tools/connections/schema-budget.d.ts +8 -0
- package/dist/tools/connections/schema-budget.d.ts.map +1 -0
- package/dist/tools/connections/sse-frames.d.ts +7 -0
- package/dist/tools/connections/sse-frames.d.ts.map +1 -0
- package/dist/tools/connections/sse-session.d.ts +26 -0
- package/dist/tools/connections/sse-session.d.ts.map +1 -0
- package/dist/tools/connections/ssrf.d.ts +15 -0
- package/dist/tools/connections/ssrf.d.ts.map +1 -0
- package/dist/tools/connections/types.d.ts +60 -0
- package/dist/tools/connections/types.d.ts.map +1 -0
- package/dist/tools/durability-context.d.ts +7 -0
- package/dist/tools/durability-context.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +2 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/registry.d.ts +38 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/runtime-tool.d.ts +4 -0
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools.d.ts +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +83 -26
- package/llms-full.txt +329 -14
- package/llms.txt +1 -0
- package/package.json +9 -1
- package/dist/{index-evcnmsc3.js → index-t7fkyxcr.js} +3 -3
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectTools,
|
|
3
3
|
createToolRunner
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-8c3a7m4g.js";
|
|
5
5
|
import {
|
|
6
6
|
toolErrorFromResult
|
|
7
|
-
} from "./index-
|
|
8
|
-
import {
|
|
9
|
-
assertUniqueToolName
|
|
10
|
-
} from "./index-r159gjwy.js";
|
|
7
|
+
} from "./index-zyvby92n.js";
|
|
11
8
|
import {
|
|
12
9
|
AppError
|
|
13
10
|
} from "./index-0w9abg87.js";
|
|
11
|
+
import {
|
|
12
|
+
assertUniqueToolName
|
|
13
|
+
} from "./index-r159gjwy.js";
|
|
14
14
|
|
|
15
15
|
// src/tools/invoker.ts
|
|
16
16
|
function createToolInvoker(services, config) {
|
|
@@ -128,7 +128,10 @@ function defineModelRegistry(config) {
|
|
|
128
128
|
return {
|
|
129
129
|
descriptor: selected,
|
|
130
130
|
model: provider.create(selected.modelId),
|
|
131
|
-
...provider.normalizeUsage && { normalizeUsage: provider.normalizeUsage }
|
|
131
|
+
...provider.normalizeUsage && { normalizeUsage: provider.normalizeUsage },
|
|
132
|
+
...provider.resolveResponseProvider && {
|
|
133
|
+
resolveResponseProvider: provider.resolveResponseProvider
|
|
134
|
+
}
|
|
132
135
|
};
|
|
133
136
|
},
|
|
134
137
|
snapshot(input) {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AgentToolError
|
|
3
|
-
|
|
2
|
+
AgentToolError,
|
|
3
|
+
resolveToolDurability
|
|
4
|
+
} from "./index-7rkhw9ec.js";
|
|
4
5
|
import {
|
|
5
6
|
collectToolSurface
|
|
6
|
-
} from "./index-
|
|
7
|
+
} from "./index-31jw8fjq.js";
|
|
7
8
|
import {
|
|
8
9
|
createToolRunner,
|
|
9
10
|
formatToolError
|
|
10
|
-
} from "./index-
|
|
11
|
+
} from "./index-8c3a7m4g.js";
|
|
11
12
|
import {
|
|
12
13
|
isToolExecutionControlError,
|
|
14
|
+
toolCauseFromResult,
|
|
13
15
|
toolResultFromError
|
|
14
|
-
} from "./index-
|
|
16
|
+
} from "./index-zyvby92n.js";
|
|
15
17
|
import {
|
|
16
18
|
isRecord
|
|
17
19
|
} from "./index-77fekveh.js";
|
|
@@ -20,6 +22,10 @@ import {
|
|
|
20
22
|
import { jsonSchema, tool } from "ai";
|
|
21
23
|
function mountAgent(services, config = {}) {
|
|
22
24
|
const serviceList = Array.isArray(services) ? services : [services];
|
|
25
|
+
if (config.registry && config.runtimeTools) {
|
|
26
|
+
throw new Error("mountAgent accepts either runtimeTools or a registry, not both");
|
|
27
|
+
}
|
|
28
|
+
const runtimeTools = config.registry ? config.registry.tools : config.runtimeTools;
|
|
23
29
|
const tools = {};
|
|
24
30
|
const runTool = createToolRunner({
|
|
25
31
|
source: "agent",
|
|
@@ -32,7 +38,7 @@ function mountAgent(services, config = {}) {
|
|
|
32
38
|
onOutputStrip: config.onOutputStrip
|
|
33
39
|
});
|
|
34
40
|
for (const entry of collectToolSurface({
|
|
35
|
-
surface: { services: serviceList, runtimeTools
|
|
41
|
+
surface: { services: serviceList, runtimeTools },
|
|
36
42
|
transport: "AGENT",
|
|
37
43
|
extend: config.extend,
|
|
38
44
|
flattenUnionInput: config.flattenUnionInput
|
|
@@ -43,7 +49,23 @@ function mountAgent(services, config = {}) {
|
|
|
43
49
|
});
|
|
44
50
|
const execute = async (rawArgs, options) => {
|
|
45
51
|
const args = isRecord(rawArgs) ? rawArgs : {};
|
|
46
|
-
const
|
|
52
|
+
const durability = resolveToolDurability(options.context, options.toolCallId, options.abortSignal);
|
|
53
|
+
const executeTool = durability ? createToolRunner({
|
|
54
|
+
source: "agent",
|
|
55
|
+
extend: config.extend,
|
|
56
|
+
context: {
|
|
57
|
+
...config.context,
|
|
58
|
+
step: durability.step,
|
|
59
|
+
sleep: durability.sleep,
|
|
60
|
+
waitFor: durability.waitFor
|
|
61
|
+
},
|
|
62
|
+
hooks: config.hooks,
|
|
63
|
+
lifecycle: config.lifecycle,
|
|
64
|
+
errorHint: config.errorHint,
|
|
65
|
+
coerceJsonArgs: config.coerceJsonArgs,
|
|
66
|
+
onOutputStrip: config.onOutputStrip
|
|
67
|
+
}) : runTool;
|
|
68
|
+
const result = await executeTool(mountable, args, {
|
|
47
69
|
signal: options.abortSignal
|
|
48
70
|
}).catch((err) => {
|
|
49
71
|
if (isToolExecutionControlError(err))
|
|
@@ -52,7 +74,7 @@ function mountAgent(services, config = {}) {
|
|
|
52
74
|
});
|
|
53
75
|
if (result.ok)
|
|
54
76
|
return result.data;
|
|
55
|
-
throw new AgentToolError(formatToolError(result, mountable.name, config.errorHint));
|
|
77
|
+
throw new AgentToolError(formatToolError(result, mountable.name, config.errorHint), toolCauseFromResult(result));
|
|
56
78
|
};
|
|
57
79
|
const presenter = entry.kind === "runtime" ? entry.definition.present?.agent : undefined;
|
|
58
80
|
if (entry.kind === "runtime" && presenter) {
|
|
@@ -7,89 +7,7 @@ import {
|
|
|
7
7
|
AgentSnapshotSchema,
|
|
8
8
|
AgentTerminalReasonSchema,
|
|
9
9
|
AgentUsageSchema
|
|
10
|
-
} from "./index-
|
|
11
|
-
|
|
12
|
-
// src/agent-runtime/history-chronology.ts
|
|
13
|
-
function createToolChronology() {
|
|
14
|
-
return { calls: new Map, approvals: new Map, pending: 0, resultsStarted: false };
|
|
15
|
-
}
|
|
16
|
-
function advanceToolChronology(previous, parts) {
|
|
17
|
-
const calls = new Map(previous.calls);
|
|
18
|
-
const approvals = new Map(previous.approvals);
|
|
19
|
-
let { pending, resultsStarted } = previous;
|
|
20
|
-
for (const part of parts) {
|
|
21
|
-
if (part.type === "tool-call") {
|
|
22
|
-
if (calls.has(part.callId) || resultsStarted && pending > 0)
|
|
23
|
-
return;
|
|
24
|
-
if (pending === 0)
|
|
25
|
-
resultsStarted = false;
|
|
26
|
-
calls.set(part.callId, { toolName: part.toolName, phase: "called" });
|
|
27
|
-
pending += 1;
|
|
28
|
-
} else if (part.type === "tool-approval-request") {
|
|
29
|
-
const call = calls.get(part.callId);
|
|
30
|
-
if (call?.phase !== "called" || approvals.has(part.approvalId))
|
|
31
|
-
return;
|
|
32
|
-
approvals.set(part.approvalId, part.callId);
|
|
33
|
-
calls.set(part.callId, { ...call, phase: "requested" });
|
|
34
|
-
} else if (part.type === "tool-approval-response") {
|
|
35
|
-
const callId = approvals.get(part.approvalId);
|
|
36
|
-
const call = callId === undefined ? undefined : calls.get(callId);
|
|
37
|
-
if (callId === undefined || !call || call.phase !== "requested")
|
|
38
|
-
return;
|
|
39
|
-
calls.set(callId, { ...call, phase: part.approved ? "approved" : "denied" });
|
|
40
|
-
} else if (part.type === "tool-result") {
|
|
41
|
-
const call = calls.get(part.callId);
|
|
42
|
-
if (!call || call.toolName !== part.toolName || call.phase === "result" || call.phase === "requested" || call.phase === "denied" && part.outcome === "success")
|
|
43
|
-
return;
|
|
44
|
-
calls.set(part.callId, { ...call, phase: "result" });
|
|
45
|
-
pending -= 1;
|
|
46
|
-
resultsStarted = true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return { calls, approvals, pending, resultsStarted };
|
|
50
|
-
}
|
|
51
|
-
function canProjectToolChronology(state) {
|
|
52
|
-
return [...state.calls.values()].every(({ phase }) => phase !== "called");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// src/agent-runtime/terminal-status.ts
|
|
56
|
-
function isSpeakableAssistantStatus(status) {
|
|
57
|
-
return status === "completed" || status === "interrupted" || status === "committed";
|
|
58
|
-
}
|
|
59
|
-
function isAssistantHistoryEvidence(status, policy) {
|
|
60
|
-
return isSpeakableAssistantStatus(status) || status === "failed" && policy?.failedAssistant === "assistant-marked";
|
|
61
|
-
}
|
|
62
|
-
function isCompleteAgentHistoryTurn(messages, policy) {
|
|
63
|
-
if (messages[0]?.role !== "user")
|
|
64
|
-
return false;
|
|
65
|
-
let chronology = createToolChronology();
|
|
66
|
-
let assistantCount = 0;
|
|
67
|
-
for (const message of messages) {
|
|
68
|
-
if (message.role === "assistant") {
|
|
69
|
-
if (!isAssistantHistoryEvidence(message.status, policy))
|
|
70
|
-
return false;
|
|
71
|
-
assistantCount += 1;
|
|
72
|
-
}
|
|
73
|
-
const next = advanceToolChronology(chronology, message.parts);
|
|
74
|
-
if (!next)
|
|
75
|
-
return false;
|
|
76
|
-
chronology = next;
|
|
77
|
-
}
|
|
78
|
-
return assistantCount > 0 && chronology.pending === 0;
|
|
79
|
-
}
|
|
80
|
-
function assistantStatus(reason) {
|
|
81
|
-
if (reason === "success" || reason === "policy_stop" || reason === "provider_stop") {
|
|
82
|
-
return "completed";
|
|
83
|
-
}
|
|
84
|
-
if (reason === "superseded")
|
|
85
|
-
return "superseded";
|
|
86
|
-
if (reason === "absorbed")
|
|
87
|
-
return "superseded";
|
|
88
|
-
if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
|
|
89
|
-
return "interrupted";
|
|
90
|
-
}
|
|
91
|
-
return "failed";
|
|
92
|
-
}
|
|
10
|
+
} from "./index-gtj3zc53.js";
|
|
93
11
|
|
|
94
12
|
// src/agent-runtime/store.ts
|
|
95
13
|
import { z } from "zod";
|
|
@@ -186,6 +104,11 @@ var ReplaceCompactedRangeSchema = z.object({
|
|
|
186
104
|
replacedMessageIds: z.array(AgentRecordIdSchema).min(1),
|
|
187
105
|
summary: AgentMessageSchema
|
|
188
106
|
});
|
|
107
|
+
var SeedConversationInputSchema = z.object({
|
|
108
|
+
conversationId: AgentRecordIdSchema,
|
|
109
|
+
seedKey: z.string().min(1),
|
|
110
|
+
inputs: z.array(AgentMessageSchema).min(1)
|
|
111
|
+
});
|
|
189
112
|
var AgentRecoverableDescriptorSchema = z.object({
|
|
190
113
|
conversationId: AgentRecordIdSchema,
|
|
191
114
|
run: AgentRunSchema
|
|
@@ -202,6 +125,7 @@ var AgentStoreEventKindSchema = z2.enum([
|
|
|
202
125
|
"runtime/baseline",
|
|
203
126
|
"runtime/transition",
|
|
204
127
|
"provider/request",
|
|
128
|
+
"provider/response",
|
|
205
129
|
"provider/message",
|
|
206
130
|
"state/set",
|
|
207
131
|
"spill/created",
|
|
@@ -215,7 +139,11 @@ var AgentStoreEventKindSchema = z2.enum([
|
|
|
215
139
|
"child/state",
|
|
216
140
|
"retry/scheduled",
|
|
217
141
|
"retry/started",
|
|
218
|
-
"sandbox/probed"
|
|
142
|
+
"sandbox/probed",
|
|
143
|
+
"approval/response-rejected",
|
|
144
|
+
"durability/step",
|
|
145
|
+
"durability/park",
|
|
146
|
+
"durability/event"
|
|
219
147
|
]);
|
|
220
148
|
var AgentStoreTransitionSchema = z2.discriminatedUnion("type", [
|
|
221
149
|
z2.object({ type: z2.literal("accept"), input: AcceptInputAndAssignRunSchema }).strict(),
|
|
@@ -225,7 +153,8 @@ var AgentStoreTransitionSchema = z2.discriminatedUnion("type", [
|
|
|
225
153
|
z2.object({ type: z2.literal("interrupt"), input: RequestRunInterruptSchema }).strict(),
|
|
226
154
|
z2.object({ type: z2.literal("recover"), input: RecoverAgentRunSchema }).strict(),
|
|
227
155
|
z2.object({ type: z2.literal("terminal"), input: CommitRunTerminalSchema }).strict(),
|
|
228
|
-
z2.object({ type: z2.literal("compact"), input: ReplaceCompactedRangeSchema }).strict()
|
|
156
|
+
z2.object({ type: z2.literal("compact"), input: ReplaceCompactedRangeSchema }).strict(),
|
|
157
|
+
z2.object({ type: z2.literal("seed"), input: SeedConversationInputSchema }).strict()
|
|
229
158
|
]);
|
|
230
159
|
var AgentStoreEventEnvelopeSchema = z2.object({
|
|
231
160
|
schemaVersion: z2.int().positive(),
|
|
@@ -331,4 +260,86 @@ function decodeAgentConversationArchive(bytes) {
|
|
|
331
260
|
return archive;
|
|
332
261
|
}
|
|
333
262
|
|
|
334
|
-
|
|
263
|
+
// src/agent-runtime/history-chronology.ts
|
|
264
|
+
function createToolChronology() {
|
|
265
|
+
return { calls: new Map, approvals: new Map, pending: 0, resultsStarted: false };
|
|
266
|
+
}
|
|
267
|
+
function advanceToolChronology(previous, parts) {
|
|
268
|
+
const calls = new Map(previous.calls);
|
|
269
|
+
const approvals = new Map(previous.approvals);
|
|
270
|
+
let { pending, resultsStarted } = previous;
|
|
271
|
+
for (const part of parts) {
|
|
272
|
+
if (part.type === "tool-call") {
|
|
273
|
+
if (calls.has(part.callId) || resultsStarted && pending > 0)
|
|
274
|
+
return;
|
|
275
|
+
if (pending === 0)
|
|
276
|
+
resultsStarted = false;
|
|
277
|
+
calls.set(part.callId, { toolName: part.toolName, phase: "called" });
|
|
278
|
+
pending += 1;
|
|
279
|
+
} else if (part.type === "tool-approval-request") {
|
|
280
|
+
const call = calls.get(part.callId);
|
|
281
|
+
if (call?.phase !== "called" || approvals.has(part.approvalId))
|
|
282
|
+
return;
|
|
283
|
+
approvals.set(part.approvalId, part.callId);
|
|
284
|
+
calls.set(part.callId, { ...call, phase: "requested" });
|
|
285
|
+
} else if (part.type === "tool-approval-response") {
|
|
286
|
+
const callId = approvals.get(part.approvalId);
|
|
287
|
+
const call = callId === undefined ? undefined : calls.get(callId);
|
|
288
|
+
if (callId === undefined || !call || call.phase !== "requested")
|
|
289
|
+
return;
|
|
290
|
+
calls.set(callId, { ...call, phase: part.approved ? "approved" : "denied" });
|
|
291
|
+
} else if (part.type === "tool-result") {
|
|
292
|
+
const call = calls.get(part.callId);
|
|
293
|
+
if (!call || call.toolName !== part.toolName || call.phase === "result" || call.phase === "requested" || call.phase === "denied" && part.outcome === "success")
|
|
294
|
+
return;
|
|
295
|
+
calls.set(part.callId, { ...call, phase: "result" });
|
|
296
|
+
pending -= 1;
|
|
297
|
+
resultsStarted = true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return { calls, approvals, pending, resultsStarted };
|
|
301
|
+
}
|
|
302
|
+
function canProjectToolChronology(state) {
|
|
303
|
+
return [...state.calls.values()].every(({ phase }) => phase !== "called");
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/agent-runtime/terminal-status.ts
|
|
307
|
+
function isSpeakableAssistantStatus(status) {
|
|
308
|
+
return status === "completed" || status === "interrupted" || status === "committed";
|
|
309
|
+
}
|
|
310
|
+
function isAssistantHistoryEvidence(status, policy) {
|
|
311
|
+
return isSpeakableAssistantStatus(status) || status === "failed" && policy?.failedAssistant === "assistant-marked";
|
|
312
|
+
}
|
|
313
|
+
function isCompleteAgentHistoryTurn(messages, policy) {
|
|
314
|
+
if (messages[0]?.role !== "user")
|
|
315
|
+
return false;
|
|
316
|
+
let chronology = createToolChronology();
|
|
317
|
+
let assistantCount = 0;
|
|
318
|
+
for (const message of messages) {
|
|
319
|
+
if (message.role === "assistant") {
|
|
320
|
+
if (!isAssistantHistoryEvidence(message.status, policy))
|
|
321
|
+
return false;
|
|
322
|
+
assistantCount += 1;
|
|
323
|
+
}
|
|
324
|
+
const next = advanceToolChronology(chronology, message.parts);
|
|
325
|
+
if (!next)
|
|
326
|
+
return false;
|
|
327
|
+
chronology = next;
|
|
328
|
+
}
|
|
329
|
+
return assistantCount > 0 && chronology.pending === 0;
|
|
330
|
+
}
|
|
331
|
+
function assistantStatus(reason) {
|
|
332
|
+
if (reason === "success" || reason === "policy_stop" || reason === "provider_stop") {
|
|
333
|
+
return "completed";
|
|
334
|
+
}
|
|
335
|
+
if (reason === "superseded")
|
|
336
|
+
return "superseded";
|
|
337
|
+
if (reason === "absorbed")
|
|
338
|
+
return "superseded";
|
|
339
|
+
if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
|
|
340
|
+
return "interrupted";
|
|
341
|
+
}
|
|
342
|
+
return "failed";
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export { AgentStoreConflictSchema, AgentStoreNotFoundSchema, AgentStoreAppliedSchema, AgentStoreDuplicateSchema, AgentStoreMutationResultSchema, AgentRunViewSchema, AcceptInputAndAssignRunSchema, AcquireAgentRunSchema, CheckpointRunAssistantSchema, RecordRunOperationSchema, CommitRunTerminalSchema, RequestRunInterruptSchema, RecoverAgentRunSchema, ReplaceCompactedRangeSchema, SeedConversationInputSchema, AgentRecoverableDescriptorSchema, AgentRecoverablePageSchema, AgentStoreEventKindSchema, AgentStoreTransitionSchema, AgentStoreEventEnvelopeSchema, AppendAgentStoreEventSchema, ReadAgentStoreEventsSchema, AgentStoreEventPageSchema, decodeAgentStoreEvent, agentStoreEventDraft, canonicalAgentJson, AgentConversationArchiveSchema, encodeAgentConversationArchive, decodeAgentConversationArchive, createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence, isCompleteAgentHistoryTurn, assistantStatus };
|
|
@@ -2,12 +2,6 @@ import {
|
|
|
2
2
|
getRequestContext,
|
|
3
3
|
runWithRequestContext
|
|
4
4
|
} from "./index-vsbzgd7b.js";
|
|
5
|
-
import {
|
|
6
|
-
objectShapeKeys
|
|
7
|
-
} from "./index-r159gjwy.js";
|
|
8
|
-
import {
|
|
9
|
-
coerceJsonArgs
|
|
10
|
-
} from "./index-7zbps32p.js";
|
|
11
5
|
import {
|
|
12
6
|
formatZodError,
|
|
13
7
|
normalizeError,
|
|
@@ -18,9 +12,15 @@ import {
|
|
|
18
12
|
STITCH_ERROR_STATUS,
|
|
19
13
|
isStitchErrorCode
|
|
20
14
|
} from "./index-0w9abg87.js";
|
|
15
|
+
import {
|
|
16
|
+
coerceJsonArgs
|
|
17
|
+
} from "./index-7zbps32p.js";
|
|
21
18
|
import {
|
|
22
19
|
isUnsafeKey
|
|
23
20
|
} from "./index-kzfs85xp.js";
|
|
21
|
+
import {
|
|
22
|
+
objectShapeKeys
|
|
23
|
+
} from "./index-r159gjwy.js";
|
|
24
24
|
import {
|
|
25
25
|
isRecord
|
|
26
26
|
} from "./index-77fekveh.js";
|
|
@@ -46,18 +46,21 @@ function toolResultFromError(err) {
|
|
|
46
46
|
details: appErr.details ?? { message: appErr.message },
|
|
47
47
|
...appErr.hint && { hint: appErr.hint }
|
|
48
48
|
};
|
|
49
|
-
normalizedToolErrors.set(result, appErr);
|
|
49
|
+
normalizedToolErrors.set(result, { normalized: appErr, cause: err });
|
|
50
50
|
return result;
|
|
51
51
|
}
|
|
52
52
|
function toolErrorFromResult(result) {
|
|
53
53
|
const retained = normalizedToolErrors.get(result);
|
|
54
54
|
if (retained)
|
|
55
|
-
return retained;
|
|
55
|
+
return retained.normalized;
|
|
56
56
|
const details = isRecord(result.details) ? result.details : undefined;
|
|
57
57
|
const message = typeof details?.message === "string" ? details.message : result.code;
|
|
58
58
|
const status = isStitchErrorCode(result.code) ? STITCH_ERROR_STATUS[result.code] : 500;
|
|
59
59
|
return new AppError(result.code, message, status, details, result.hint);
|
|
60
60
|
}
|
|
61
|
+
function toolCauseFromResult(result) {
|
|
62
|
+
return normalizedToolErrors.get(result)?.cause;
|
|
63
|
+
}
|
|
61
64
|
async function executeToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson = false, onOutputStrip, extension, finalizeOutput) {
|
|
62
65
|
return inToolCallContext({ source: context.source, toolName, method }, () => runToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson, onOutputStrip, extension, finalizeOutput));
|
|
63
66
|
}
|
|
@@ -258,4 +261,4 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
|
|
|
258
261
|
}
|
|
259
262
|
}
|
|
260
263
|
|
|
261
|
-
export { ToolExecutionControlError, isToolExecutionControlError, toolResultFromError, toolErrorFromResult, executeToolMethod };
|
|
264
|
+
export { ToolExecutionControlError, isToolExecutionControlError, toolResultFromError, toolErrorFromResult, toolCauseFromResult, executeToolMethod };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,16 @@ import {
|
|
|
6
6
|
createBackoff,
|
|
7
7
|
resumableIterator
|
|
8
8
|
} from "./index-s8cnx02s.js";
|
|
9
|
+
import {
|
|
10
|
+
contractEndpointMatchers,
|
|
11
|
+
createClient,
|
|
12
|
+
createClients,
|
|
13
|
+
createScopedClients,
|
|
14
|
+
createScopedUrlBuilders,
|
|
15
|
+
createUrlBuilder,
|
|
16
|
+
createUrlBuilders,
|
|
17
|
+
parseNDJSON
|
|
18
|
+
} from "./index-27gm3d6g.js";
|
|
9
19
|
import {
|
|
10
20
|
REALTIME_REJECTION_KEY,
|
|
11
21
|
asRealtimeRejection,
|
|
@@ -22,6 +32,9 @@ import {
|
|
|
22
32
|
RealtimeRequestRejectedError,
|
|
23
33
|
RealtimeRequestTimeoutError
|
|
24
34
|
} from "./index-2qzskm8h.js";
|
|
35
|
+
import {
|
|
36
|
+
parseSSE
|
|
37
|
+
} from "./index-qmgs7y68.js";
|
|
25
38
|
import {
|
|
26
39
|
LiveStateControllerStatusSchema,
|
|
27
40
|
LiveStatePhaseSchema,
|
|
@@ -29,19 +42,6 @@ import {
|
|
|
29
42
|
createLiveStateController
|
|
30
43
|
} from "./index-ywd0y6m1.js";
|
|
31
44
|
import"./index-7gnkny4z.js";
|
|
32
|
-
import {
|
|
33
|
-
contractEndpointMatchers,
|
|
34
|
-
createClient,
|
|
35
|
-
createClients,
|
|
36
|
-
createScopedClients,
|
|
37
|
-
createScopedUrlBuilders,
|
|
38
|
-
createUrlBuilder,
|
|
39
|
-
createUrlBuilders,
|
|
40
|
-
parseNDJSON
|
|
41
|
-
} from "./index-27gm3d6g.js";
|
|
42
|
-
import {
|
|
43
|
-
parseSSE
|
|
44
|
-
} from "./index-qmgs7y68.js";
|
|
45
45
|
import {
|
|
46
46
|
ApiError,
|
|
47
47
|
createHttpClient
|
package/dist/server/index.js
CHANGED
|
@@ -27,6 +27,11 @@ import {
|
|
|
27
27
|
} from "../index-3z73fh2c.js";
|
|
28
28
|
import"../index-apn8repm.js";
|
|
29
29
|
import"../index-2qzskm8h.js";
|
|
30
|
+
import {
|
|
31
|
+
inputIsQuery,
|
|
32
|
+
parseSSE,
|
|
33
|
+
streamSSE
|
|
34
|
+
} from "../index-qmgs7y68.js";
|
|
30
35
|
import {
|
|
31
36
|
composeAuthHooks,
|
|
32
37
|
createAuthHook,
|
|
@@ -70,15 +75,6 @@ import {
|
|
|
70
75
|
resolveSocketIp,
|
|
71
76
|
resolveTraceId
|
|
72
77
|
} from "../index-f9mb610r.js";
|
|
73
|
-
import {
|
|
74
|
-
jsonSchemaFields,
|
|
75
|
-
toJsonSchema
|
|
76
|
-
} from "../index-cby4ar3v.js";
|
|
77
|
-
import {
|
|
78
|
-
inputIsQuery,
|
|
79
|
-
parseSSE,
|
|
80
|
-
streamSSE
|
|
81
|
-
} from "../index-qmgs7y68.js";
|
|
82
78
|
import {
|
|
83
79
|
errorCode,
|
|
84
80
|
formatZodError,
|
|
@@ -105,6 +101,10 @@ import {
|
|
|
105
101
|
} from "../index-0w9abg87.js";
|
|
106
102
|
import"../index-zcgf3gqf.js";
|
|
107
103
|
import"../index-kzfs85xp.js";
|
|
104
|
+
import {
|
|
105
|
+
jsonSchemaFields,
|
|
106
|
+
toJsonSchema
|
|
107
|
+
} from "../index-cby4ar3v.js";
|
|
108
108
|
import {
|
|
109
109
|
isRecord
|
|
110
110
|
} from "../index-77fekveh.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-store-conformance.d.ts","sourceRoot":"","sources":["../../src/testing/agent-store-conformance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE;;;;;;;;;GASG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,WAAW,CACT,OAAO,EAAE,4BAA4B,GACpC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClD;;;;;;;;OAQG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAwCD,gFAAgF;AAChF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"agent-store-conformance.d.ts","sourceRoot":"","sources":["../../src/testing/agent-store-conformance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE;;;;;;;;;GASG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,WAAW,CACT,OAAO,EAAE,4BAA4B,GACpC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClD;;;;;;;;OAQG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAwCD,gFAAgF;AAChF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,CAqCf"}
|
package/dist/testing.js
CHANGED
|
@@ -1,47 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createApplication
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-2k4yrqkc.js";
|
|
3
|
+
} from "./index-t7fkyxcr.js";
|
|
5
4
|
import"./index-3gye9wzb.js";
|
|
5
|
+
import"./index-2k4yrqkc.js";
|
|
6
6
|
import"./index-3z73fh2c.js";
|
|
7
7
|
import {
|
|
8
8
|
createMemoryAgentRuntimeStore
|
|
9
|
-
} from "./index-
|
|
10
|
-
import {
|
|
11
|
-
createAgentRaceBarrier,
|
|
12
|
-
createAgentRaceDriver,
|
|
13
|
-
createAgentRaceTrace
|
|
14
|
-
} from "./index-cnyk6te3.js";
|
|
9
|
+
} from "./index-hrbajay7.js";
|
|
15
10
|
import {
|
|
16
11
|
decodeAgentConversationArchive
|
|
17
|
-
} from "./index-
|
|
12
|
+
} from "./index-zwkgfq1s.js";
|
|
18
13
|
import {
|
|
19
14
|
AgentMessageSchema,
|
|
20
15
|
AgentRunSchema
|
|
21
|
-
} from "./index-
|
|
16
|
+
} from "./index-gtj3zc53.js";
|
|
17
|
+
import {
|
|
18
|
+
createAgentRaceBarrier,
|
|
19
|
+
createAgentRaceDriver,
|
|
20
|
+
createAgentRaceTrace
|
|
21
|
+
} from "./index-cnyk6te3.js";
|
|
22
22
|
import {
|
|
23
23
|
RealtimeRejectDirectionSchema,
|
|
24
24
|
RealtimeRejectFaultSchema,
|
|
25
25
|
RealtimeRejectPhaseSchema,
|
|
26
26
|
RealtimeRejectReasonSchema
|
|
27
27
|
} from "./index-p7hgdyhb.js";
|
|
28
|
+
import {
|
|
29
|
+
createClient,
|
|
30
|
+
createClients
|
|
31
|
+
} from "./index-27gm3d6g.js";
|
|
28
32
|
import {
|
|
29
33
|
RealtimeRequestDisconnectedError,
|
|
30
34
|
RealtimeRequestInvalidAcknowledgementError,
|
|
31
35
|
RealtimeRequestTimeoutError
|
|
32
36
|
} from "./index-2qzskm8h.js";
|
|
33
|
-
import {
|
|
34
|
-
mcpProjectionCandidate,
|
|
35
|
-
prepareProjectedMcpTools,
|
|
36
|
-
projectToolSurface
|
|
37
|
-
} from "./index-r159gjwy.js";
|
|
38
|
-
import {
|
|
39
|
-
toJsonSchema
|
|
40
|
-
} from "./index-cby4ar3v.js";
|
|
41
|
-
import {
|
|
42
|
-
createClient,
|
|
43
|
-
createClients
|
|
44
|
-
} from "./index-27gm3d6g.js";
|
|
45
37
|
import"./index-qmgs7y68.js";
|
|
46
38
|
import"./index-3xwxfj4z.js";
|
|
47
39
|
import"./index-7evdsyez.js";
|
|
@@ -52,6 +44,14 @@ import"./index-6k1937bx.js";
|
|
|
52
44
|
import"./index-0w9abg87.js";
|
|
53
45
|
import"./index-zcgf3gqf.js";
|
|
54
46
|
import"./index-kzfs85xp.js";
|
|
47
|
+
import {
|
|
48
|
+
mcpProjectionCandidate,
|
|
49
|
+
prepareProjectedMcpTools,
|
|
50
|
+
projectToolSurface
|
|
51
|
+
} from "./index-r159gjwy.js";
|
|
52
|
+
import {
|
|
53
|
+
toJsonSchema
|
|
54
|
+
} from "./index-cby4ar3v.js";
|
|
55
55
|
import {
|
|
56
56
|
isRecord
|
|
57
57
|
} from "./index-77fekveh.js";
|
|
@@ -97,7 +97,8 @@ async function runAgentStoreConformance(config) {
|
|
|
97
97
|
`${run}-causal-active`,
|
|
98
98
|
`${run}-interrupt-priority`,
|
|
99
99
|
`${run}-ledger`,
|
|
100
|
-
`${run}-archive
|
|
100
|
+
`${run}-archive`,
|
|
101
|
+
`${run}-seed`
|
|
101
102
|
]
|
|
102
103
|
};
|
|
103
104
|
const store = await config.createStore(context);
|
|
@@ -117,6 +118,36 @@ async function runAgentStoreConformance(config) {
|
|
|
117
118
|
if (failure !== undefined)
|
|
118
119
|
throw failure;
|
|
119
120
|
}
|
|
121
|
+
async function seedScenario(store, conversationId) {
|
|
122
|
+
const input = {
|
|
123
|
+
conversationId,
|
|
124
|
+
seedKey: "brief",
|
|
125
|
+
inputs: [userMessage(conversationId, "seed-a"), userMessage(conversationId, "seed-b")]
|
|
126
|
+
};
|
|
127
|
+
const first = await store.seedConversationInput(input);
|
|
128
|
+
requireOutcome(first, "applied");
|
|
129
|
+
const before = await store.loadSnapshot(conversationId);
|
|
130
|
+
if (before.messages.map((message) => message.id).join(",") !== "seed-a,seed-b")
|
|
131
|
+
throw new Error("Seed conformance: complete ordered seed missing");
|
|
132
|
+
await Promise.all([store.seedConversationInput(input), store.seedConversationInput(input)]);
|
|
133
|
+
const repeated = await store.loadSnapshot(conversationId);
|
|
134
|
+
if (repeated.version !== before.version || repeated.messages.length !== 2)
|
|
135
|
+
throw new Error("Seed conformance: replay changed history");
|
|
136
|
+
const compacted = await store.replaceCompactedRange({
|
|
137
|
+
conversationId,
|
|
138
|
+
expectedVersion: repeated.version,
|
|
139
|
+
replacedMessageIds: ["seed-a", "seed-b"],
|
|
140
|
+
summary: AgentMessageSchema.parse({
|
|
141
|
+
...userMessage(conversationId, "seed-summary"),
|
|
142
|
+
role: "summary"
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
requireOutcome(compacted, "applied");
|
|
146
|
+
await store.seedConversationInput(input);
|
|
147
|
+
const after = await store.loadSnapshot(conversationId);
|
|
148
|
+
if (after.messages.some((message) => message.id === "seed-a" || message.id === "seed-b"))
|
|
149
|
+
throw new Error("Seed conformance: compacted instructions resurrected");
|
|
150
|
+
}
|
|
120
151
|
async function conformanceScenario(store, conversationIds) {
|
|
121
152
|
const [
|
|
122
153
|
conversationId,
|
|
@@ -126,8 +157,11 @@ async function conformanceScenario(store, conversationIds) {
|
|
|
126
157
|
causalActiveConversationId,
|
|
127
158
|
interruptPriorityConversationId,
|
|
128
159
|
ledgerConversationId,
|
|
129
|
-
archiveConversationId
|
|
160
|
+
archiveConversationId,
|
|
161
|
+
seedConversationId
|
|
130
162
|
] = conversationIds;
|
|
163
|
+
if (seedConversationId)
|
|
164
|
+
await seedScenario(store, seedConversationId);
|
|
131
165
|
if (ledgerConversationId)
|
|
132
166
|
await ledgerScenario(store, ledgerConversationId);
|
|
133
167
|
if (archiveConversationId)
|
|
@@ -541,6 +575,17 @@ async function conformanceScenario(store, conversationIds) {
|
|
|
541
575
|
if (terminalRun?.state !== "abandoned" || terminalMessage?.status !== "failed") {
|
|
542
576
|
throw new Error("Abandon recovery did not atomically terminalize its assistant record");
|
|
543
577
|
}
|
|
578
|
+
const abandonedView = await store.loadRun({
|
|
579
|
+
conversationId: recoveryConversationId,
|
|
580
|
+
runId: abandonedRun.id
|
|
581
|
+
});
|
|
582
|
+
if (abandonedView?.run.state !== "abandoned" || abandonedView.run.terminalReason !== "abandoned" || abandonedView.assistant?.status !== "failed") {
|
|
583
|
+
throw new Error("The canonical run record disagrees with its abandoned index projection");
|
|
584
|
+
}
|
|
585
|
+
const afterAbandon = await store.scanRecoverable({ limit: 100 });
|
|
586
|
+
if (afterAbandon.items.some((item) => item.run.id === abandonedRun.id)) {
|
|
587
|
+
throw new Error("The recoverable index still exposes a canonically abandoned run");
|
|
588
|
+
}
|
|
544
589
|
await assertCausalHistoryOrder(store, causalHistoryConversationId);
|
|
545
590
|
await assertActiveRunCausalOrder(store, causalActiveConversationId);
|
|
546
591
|
await assertInterruptPriorityOrder(store, interruptPriorityConversationId);
|
package/dist/tool-invoker.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolInvoker
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-mnm4qp0p.js";
|
|
4
|
+
import"./index-8c3a7m4g.js";
|
|
5
|
+
import"./index-zyvby92n.js";
|
|
6
6
|
import"./index-vsbzgd7b.js";
|
|
7
7
|
import"./index-f9mb610r.js";
|
|
8
|
-
import"./index-r159gjwy.js";
|
|
9
|
-
import"./index-cby4ar3v.js";
|
|
10
|
-
import"./index-7zbps32p.js";
|
|
11
8
|
import"./index-7evdsyez.js";
|
|
12
9
|
import"./index-2bxcmqkb.js";
|
|
13
10
|
import"./index-6k1937bx.js";
|
|
14
11
|
import"./index-0w9abg87.js";
|
|
15
12
|
import"./index-zcgf3gqf.js";
|
|
13
|
+
import"./index-7zbps32p.js";
|
|
16
14
|
import"./index-kzfs85xp.js";
|
|
15
|
+
import"./index-r159gjwy.js";
|
|
16
|
+
import"./index-cby4ar3v.js";
|
|
17
17
|
import"./index-77fekveh.js";
|
|
18
18
|
export {
|
|
19
19
|
createToolInvoker
|