@qvac/harness 0.7.0 → 1.0.0-rc.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 +42 -1
- package/README.md +239 -2
- package/dist-lib/index.d.ts +58 -3
- package/dist-lib/index.js +736 -239
- package/dist-lib/lib/capabilities/completion-engine/abort-polyfill.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/abort-polyfill.js +10 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +17 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/approval.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/approval.js +29 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +73 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +41 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execute.js +49 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +102 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.d.ts +47 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +87 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/finishing.d.ts +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/finishing.js +32 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-preload.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-preload.js +75 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +152 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +94 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preload-failure.d.ts +9 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preload-failure.js +11 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preloading.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preloading.js +114 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +198 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +71 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/rejection.d.ts +18 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/rejection.js +70 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +60 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +21 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +48 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +156 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +7 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +61 -0
- package/dist-lib/lib/capabilities/completion-engine/driver.d.ts +25 -0
- package/dist-lib/lib/capabilities/completion-engine/driver.js +553 -0
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +61 -0
- package/dist-lib/lib/capabilities/completion-engine/durable.js +150 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.d.ts +6 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +239 -0
- package/dist-lib/lib/capabilities/completion-engine/ports.d.ts +3 -0
- package/dist-lib/lib/capabilities/completion-engine/ports.js +267 -0
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +76 -0
- package/dist-lib/lib/capabilities/completion-engine/session.js +70 -0
- package/dist-lib/lib/capabilities/completion-loop/index.d.ts +80 -0
- package/dist-lib/lib/capabilities/completion-loop/index.js +158 -0
- package/dist-lib/lib/capabilities/completion-loop/metrics.d.ts +5 -0
- package/dist-lib/lib/capabilities/completion-loop/metrics.js +29 -0
- package/dist-lib/lib/capabilities/completion-loop/round.d.ts +33 -0
- package/dist-lib/lib/capabilities/completion-loop/round.js +353 -0
- package/dist-lib/lib/capabilities/completion-loop/tool-execution.d.ts +60 -0
- package/dist-lib/lib/capabilities/completion-loop/tool-execution.js +270 -0
- package/dist-lib/lib/capabilities/completion-loop/turns.d.ts +23 -0
- package/dist-lib/lib/capabilities/completion-loop/turns.js +112 -0
- package/dist-lib/lib/capabilities/completion-runtime.d.ts +46 -0
- package/dist-lib/lib/capabilities/completion-runtime.js +74 -0
- package/dist-lib/lib/capabilities/completion.d.ts +18 -335
- package/dist-lib/lib/capabilities/completion.js +20 -1301
- package/dist-lib/lib/capabilities/download.d.ts +1 -1
- package/dist-lib/lib/capabilities/download.js +7 -2
- package/dist-lib/lib/capabilities/invoke.js +5 -3
- package/dist-lib/lib/capabilities/tool-plan.d.ts +35 -0
- package/dist-lib/lib/capabilities/tool-plan.js +66 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +11 -2
- package/dist-lib/lib/capabilities/tool-turns.js +30 -2
- package/dist-lib/lib/capabilities/types.d.ts +287 -0
- package/dist-lib/lib/capabilities/types.js +1 -0
- package/dist-lib/lib/completion-lifecycle.d.ts +14 -0
- package/dist-lib/lib/completion-lifecycle.js +126 -0
- package/dist-lib/lib/connect.d.ts +10 -3
- package/dist-lib/lib/connect.js +329 -23
- package/dist-lib/lib/contract-types.d.ts +19 -2
- package/dist-lib/lib/harness-lifecycle.d.ts +66 -0
- package/dist-lib/lib/harness-lifecycle.js +129 -0
- package/dist-lib/lib/helpers/detach-json.d.ts +1 -0
- package/dist-lib/lib/helpers/detach-json.js +146 -0
- package/dist-lib/lib/helpers/markup-scanner.d.ts +26 -0
- package/dist-lib/lib/helpers/markup-scanner.js +156 -0
- package/dist-lib/lib/helpers/markup-stream-filter.js +138 -35
- package/dist-lib/lib/helpers/race-abort.d.ts +9 -4
- package/dist-lib/lib/helpers/race-abort.js +2 -7
- package/dist-lib/lib/helpers/recovery-required.d.ts +1 -0
- package/dist-lib/lib/helpers/recovery-required.js +1 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +10 -2
- package/dist-lib/lib/helpers/run-outcome.js +8 -5
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +2 -0
- package/dist-lib/lib/helpers/tool-call-markup.js +197 -82
- package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +1 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +1 -0
- package/dist-lib/lib/hooks/built-in/egress.d.ts +1 -0
- package/dist-lib/lib/hooks/built-in/egress.js +2 -1
- package/dist-lib/lib/hooks/built-in/sandbox.d.ts +1 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +6 -1
- package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +1 -0
- package/dist-lib/lib/hooks/built-in/skill-catalog.js +2 -1
- package/dist-lib/lib/hooks/pipeline.d.ts +4 -1
- package/dist-lib/lib/hooks/pipeline.js +24 -2
- package/dist-lib/lib/hooks/run.d.ts +2 -1
- package/dist-lib/lib/hooks/run.js +19 -7
- package/dist-lib/lib/hooks/types.d.ts +17 -6
- package/dist-lib/lib/machine/completion/actions/approval.d.ts +3 -0
- package/dist-lib/lib/machine/completion/actions/approval.js +16 -0
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +23 -0
- package/dist-lib/lib/machine/completion/actions/completion.js +142 -0
- package/dist-lib/lib/machine/completion/actions/skills.d.ts +9 -0
- package/dist-lib/lib/machine/completion/actions/skills.js +83 -0
- package/dist-lib/lib/machine/completion/actions/tools.d.ts +16 -0
- package/dist-lib/lib/machine/completion/actions/tools.js +173 -0
- package/dist-lib/lib/machine/completion/context.d.ts +9 -0
- package/dist-lib/lib/machine/completion/context.js +44 -0
- package/dist-lib/lib/machine/completion/contract.d.ts +6 -0
- package/dist-lib/lib/machine/completion/contract.js +1 -0
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +9 -0
- package/dist-lib/lib/machine/completion/guards/retry.js +25 -0
- package/dist-lib/lib/machine/completion/implementations.d.ts +81 -0
- package/dist-lib/lib/machine/completion/implementations.js +152 -0
- package/dist-lib/lib/machine/completion/machine.d.ts +375 -0
- package/dist-lib/lib/machine/completion/machine.js +511 -0
- package/dist-lib/lib/machine/completion/ports.d.ts +65 -0
- package/dist-lib/lib/machine/completion/ports.js +224 -0
- package/dist-lib/lib/machine/completion/rules.d.ts +39 -0
- package/dist-lib/lib/machine/completion/rules.js +115 -0
- package/dist-lib/lib/machine/completion/types.d.ts +493 -0
- package/dist-lib/lib/machine/completion/types.js +1 -0
- package/dist-lib/lib/machine/engine.d.ts +93 -0
- package/dist-lib/lib/machine/engine.js +483 -0
- package/dist-lib/lib/machine/errors.d.ts +44 -0
- package/dist-lib/lib/machine/errors.js +373 -0
- package/dist-lib/lib/machine/guards.d.ts +2 -0
- package/dist-lib/lib/machine/guards.js +6 -0
- package/dist-lib/lib/machine/index.d.ts +20 -0
- package/dist-lib/lib/machine/index.js +11 -0
- package/dist-lib/lib/machine/replay-output.d.ts +24 -0
- package/dist-lib/lib/machine/replay-output.js +50 -0
- package/dist-lib/lib/machine/stable-stringify.d.ts +1 -0
- package/dist-lib/lib/machine/stable-stringify.js +11 -0
- package/dist-lib/lib/models/model-handle.d.ts +5 -1
- package/dist-lib/lib/models/model-handle.js +8 -3
- package/dist-lib/lib/models/model-list.d.ts +5 -3
- package/dist-lib/lib/models/model-pool.d.ts +18 -7
- package/dist-lib/lib/models/model-pool.js +126 -38
- package/dist-lib/lib/run-log/history-codec.d.ts +23 -0
- package/dist-lib/lib/run-log/history-codec.js +973 -0
- package/dist-lib/lib/run-log/patch.d.ts +6 -0
- package/dist-lib/lib/run-log/patch.js +93 -0
- package/dist-lib/lib/run-log/persisted-actor.d.ts +18 -0
- package/dist-lib/lib/run-log/persisted-actor.js +218 -0
- package/dist-lib/lib/run-log/protocol-types.d.ts +153 -0
- package/dist-lib/lib/run-log/protocol-types.js +1 -0
- package/dist-lib/lib/run-log/protocol.d.ts +27 -0
- package/dist-lib/lib/run-log/protocol.js +1056 -0
- package/dist-lib/lib/run-log/replay.d.ts +25 -0
- package/dist-lib/lib/run-log/replay.js +129 -0
- package/dist-lib/lib/run-log/run-journal.d.ts +125 -0
- package/dist-lib/lib/run-log/run-journal.js +783 -0
- package/dist-lib/lib/run-log-inspect.d.ts +25 -0
- package/dist-lib/lib/run-log-inspect.js +627 -0
- package/dist-lib/lib/run-log-protocol.d.ts +2 -0
- package/dist-lib/lib/run-log-protocol.js +1 -0
- package/dist-lib/lib/run-log-redact.d.ts +27 -0
- package/dist-lib/lib/run-log-redact.js +1107 -0
- package/dist-lib/lib/serve.js +308 -12
- package/dist-lib/lib/spawn.js +3 -2
- package/dist-lib/lib/tool-call-display.d.ts +1 -21
- package/dist-lib/lib/tools/exec.d.ts +2 -1
- package/dist-lib/lib/tools/exec.js +57 -2
- package/dist-lib/lib/tools/generate-image.js +1 -1
- package/dist-lib/lib/tools/generate-music.js +1 -1
- package/dist-lib/lib/tools/http-request.d.ts +2 -1
- package/dist-lib/lib/tools/http-request.js +2 -1
- package/dist-lib/lib/tools/mcp-call.js +8 -1
- package/dist-lib/lib/tools/operations/builders.d.ts +1 -0
- package/dist-lib/lib/tools/operations/builders.js +1 -0
- package/dist-lib/lib/tools/operations/compile.js +11 -1
- package/dist-lib/lib/tools/operations/manifest.js +1 -0
- package/dist-lib/lib/tools/outbound-guard.d.ts +8 -6
- package/dist-lib/lib/tools/outbound-guard.js +25 -8
- package/dist-lib/lib/tools/skills/catalog.d.ts +1 -0
- package/dist-lib/lib/tools/skills/catalog.js +35 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +25 -0
- package/dist-lib/lib/wire.d.ts +5 -0
- package/dist-lib/lib/wire.js +128 -5
- package/dist-lib/schema/harness.js +22 -6
- package/dist-lib/spec/hrpc/messages.js +100 -18
- package/dist-lib/spec/hyperschema/index.js +100 -18
- package/dist-lib/spec/hyperschema/schema.json +74 -1
- package/dist-lib/spec/hyperschema/types.d.ts +11 -3
- package/package.json +19 -1
- package/patches/@qvac%2Finference@0.20.0.patch +67 -0
- package/patches/bare-stow@0.1.5.patch +68 -0
- package/patches/hypercore-blob-server@1.15.0.patch +15 -0
- package/patches/localwatch@1.4.3.patch +13 -0
- package/patches/pyodide@314.0.2.patch +144 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AnyMachineSnapshot, type AnyStateMachine } from 'xstate';
|
|
2
|
+
import { type Patch } from './patch.ts';
|
|
3
|
+
import type { MachineLog } from './persisted-actor.ts';
|
|
4
|
+
import type { MachineTransitionTrace } from './protocol-types.ts';
|
|
5
|
+
interface ReplayEvent extends Record<string, unknown> {
|
|
6
|
+
type: string;
|
|
7
|
+
}
|
|
8
|
+
interface ReplayFrame {
|
|
9
|
+
index: number;
|
|
10
|
+
event: ReplayEvent;
|
|
11
|
+
snapshot: AnyMachineSnapshot;
|
|
12
|
+
}
|
|
13
|
+
export declare class ReplayDivergence extends Error {
|
|
14
|
+
readonly index: number;
|
|
15
|
+
readonly drift: Patch;
|
|
16
|
+
constructor(index: number, drift: Patch);
|
|
17
|
+
}
|
|
18
|
+
export declare class ReplayTraceDivergence extends Error {
|
|
19
|
+
readonly index: number;
|
|
20
|
+
readonly expected: MachineTransitionTrace[];
|
|
21
|
+
readonly actual: MachineTransitionTrace[];
|
|
22
|
+
constructor(index: number, expected: MachineTransitionTrace[], actual: MachineTransitionTrace[]);
|
|
23
|
+
}
|
|
24
|
+
export declare function replayRun(machine: AnyStateMachine, core: MachineLog): AsyncGenerator<ReplayFrame>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createActor, transition } from 'xstate';
|
|
2
|
+
import { diff } from './patch.js';
|
|
3
|
+
import { isRecord } from '../guards.js';
|
|
4
|
+
import { copy, readRunLog } from './run-journal.js';
|
|
5
|
+
import { stableStringify } from '../machine/stable-stringify.js';
|
|
6
|
+
import { transitionName } from './protocol.js';
|
|
7
|
+
export class ReplayDivergence extends Error {
|
|
8
|
+
index;
|
|
9
|
+
drift;
|
|
10
|
+
constructor(index, drift) {
|
|
11
|
+
super(`Replay diverges from the run log at record ${index}: ${JSON.stringify(drift)}`);
|
|
12
|
+
this.name = 'ReplayDivergence';
|
|
13
|
+
this.index = index;
|
|
14
|
+
this.drift = drift;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class ReplayTraceDivergence extends Error {
|
|
18
|
+
index;
|
|
19
|
+
expected;
|
|
20
|
+
actual;
|
|
21
|
+
constructor(index, expected, actual) {
|
|
22
|
+
super(`Transition trace replay diverges from the run log at record ${index}`);
|
|
23
|
+
this.name = 'ReplayTraceDivergence';
|
|
24
|
+
this.index = index;
|
|
25
|
+
this.expected = expected;
|
|
26
|
+
this.actual = actual;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function* replayRun(machine, core) {
|
|
30
|
+
let current;
|
|
31
|
+
for await (const { index, record, snapshot, events } of readRunLog(core)) {
|
|
32
|
+
if (record.type === 'fork' && current) {
|
|
33
|
+
current = createActor(machine, { snapshot: parsePersistedSnapshot(snapshot) }).getSnapshot();
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (record.type !== 'checkpoint' && record.type !== 'delta') {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!current) {
|
|
40
|
+
if (record.type !== 'checkpoint') {
|
|
41
|
+
throw new Error('Run log has a delta before any checkpoint');
|
|
42
|
+
}
|
|
43
|
+
current = createActor(machine, { snapshot: parsePersistedSnapshot(snapshot) }).getSnapshot();
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const parsedEvents = events.map(parseReplayEvent);
|
|
47
|
+
verifyRecordTrace(machine, {
|
|
48
|
+
start: current,
|
|
49
|
+
events: parsedEvents,
|
|
50
|
+
expected: record.trace ?? [],
|
|
51
|
+
index
|
|
52
|
+
});
|
|
53
|
+
for (const event of parsedEvents) {
|
|
54
|
+
current = transition(machine, current, event)[0];
|
|
55
|
+
yield { index, event, snapshot: current };
|
|
56
|
+
}
|
|
57
|
+
const drift = diff(view(snapshot), view(machine.getPersistedSnapshot(current)));
|
|
58
|
+
if (drift) {
|
|
59
|
+
throw new ReplayDivergence(index, drift);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function verifyRecordTrace(machine, input) {
|
|
64
|
+
let current = input.start;
|
|
65
|
+
const actual = [];
|
|
66
|
+
for (const event of input.events) {
|
|
67
|
+
actual.push(...transitionTrace(machine, current, event));
|
|
68
|
+
current = transition(machine, current, event)[0];
|
|
69
|
+
}
|
|
70
|
+
assertTrace(input.index, input.expected, actual);
|
|
71
|
+
}
|
|
72
|
+
function transitionTrace(machine, snapshot, event) {
|
|
73
|
+
return machine.getTransitionData(snapshot, event).map((item) => ({
|
|
74
|
+
eventType: item.eventType ?? '',
|
|
75
|
+
sourceIds: [item.source.id],
|
|
76
|
+
targetIds: item.target?.map((state) => state.id) ?? [],
|
|
77
|
+
guardNames: item.guard ? [transitionName(item.guard)] : [],
|
|
78
|
+
actionNames: item.actions.map(transitionName)
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
function assertTrace(index, expected, actual) {
|
|
82
|
+
const triggeredExpected = expected.filter((item) => item.eventType !== '');
|
|
83
|
+
const triggeredActual = actual.filter((item) => item.eventType !== '');
|
|
84
|
+
if (stableStringify(triggeredExpected) !== stableStringify(triggeredActual)) {
|
|
85
|
+
throw new ReplayTraceDivergence(index, triggeredExpected, triggeredActual);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function view(snapshot) {
|
|
89
|
+
const detached = copy(snapshot);
|
|
90
|
+
if (!isRecord(detached)) {
|
|
91
|
+
throw new Error('Machine replay snapshot is malformed');
|
|
92
|
+
}
|
|
93
|
+
const children = detached.children;
|
|
94
|
+
return {
|
|
95
|
+
value: detached.value,
|
|
96
|
+
status: detached.status,
|
|
97
|
+
context: detached.context,
|
|
98
|
+
historyValue: detached.historyValue,
|
|
99
|
+
children: isRecord(children) ? Object.keys(children).sort() : [],
|
|
100
|
+
output: detached.output,
|
|
101
|
+
error: detached.error
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function parsePersistedSnapshot(value) {
|
|
105
|
+
const snapshot = copy(value);
|
|
106
|
+
if (!isRecord(snapshot) || !isSnapshotStatus(snapshot.status)) {
|
|
107
|
+
throw new Error('Machine replay snapshot is malformed');
|
|
108
|
+
}
|
|
109
|
+
if ((snapshot.status === 'active' || snapshot.status === 'stopped') &&
|
|
110
|
+
(snapshot.output !== undefined || snapshot.error !== undefined)) {
|
|
111
|
+
throw new Error('Machine replay snapshot has output or error for a nonterminal state');
|
|
112
|
+
}
|
|
113
|
+
if (snapshot.status === 'done' && snapshot.error !== undefined) {
|
|
114
|
+
throw new Error('Machine replay snapshot has an error for a done state');
|
|
115
|
+
}
|
|
116
|
+
if (snapshot.status === 'error' && snapshot.output !== undefined) {
|
|
117
|
+
throw new Error('Machine replay snapshot has output for an error state');
|
|
118
|
+
}
|
|
119
|
+
return snapshot;
|
|
120
|
+
}
|
|
121
|
+
function parseReplayEvent(value) {
|
|
122
|
+
if (!isRecord(value) || typeof value.type !== 'string') {
|
|
123
|
+
throw new Error('Machine replay event is malformed');
|
|
124
|
+
}
|
|
125
|
+
return { ...value, type: value.type };
|
|
126
|
+
}
|
|
127
|
+
function isSnapshotStatus(value) {
|
|
128
|
+
return value === 'active' || value === 'done' || value === 'error' || value === 'stopped';
|
|
129
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { MachineLog } from './persisted-actor.ts';
|
|
2
|
+
import { RecoveryRequired, type Operation } from '../machine/errors.ts';
|
|
3
|
+
import { type Patch } from './patch.ts';
|
|
4
|
+
import { RUN_LOG_VERSION, pendingCallNames, pendingToolArgs, unsettledRedactedIds, type EngineBoot, type EngineStep, type ForkOrigin, type ForkSegment, type Receipt, type RecoveryResolution, type RunRecord } from './protocol.ts';
|
|
5
|
+
export { RUN_LOG_VERSION, RecoveryRequired, type Operation, pendingCallNames, pendingToolArgs, unsettledRedactedIds };
|
|
6
|
+
export declare const MACHINE_VERSION = 12;
|
|
7
|
+
export declare const XSTATE_VERSION: string;
|
|
8
|
+
export declare const ENGINE_BOUNDARY_BOOT: unique symbol;
|
|
9
|
+
export type { EngineBoot, EngineStep, ForkOrigin, ForkSegment, Receipt, RecoveryResolution, RunRecord };
|
|
10
|
+
export declare class RunIncompatible extends Error {
|
|
11
|
+
readonly runId: string | undefined;
|
|
12
|
+
readonly found: number | string;
|
|
13
|
+
readonly expected: number | string;
|
|
14
|
+
readonly kind: 'machine' | 'log' | 'xstate';
|
|
15
|
+
constructor(opts: RunIncompatibleOptions);
|
|
16
|
+
}
|
|
17
|
+
interface RunIncompatibleOptions {
|
|
18
|
+
runId?: string;
|
|
19
|
+
found: number | string;
|
|
20
|
+
expected: number | string;
|
|
21
|
+
kind: 'machine' | 'log' | 'xstate';
|
|
22
|
+
}
|
|
23
|
+
export type { MachineTransitionTrace } from './protocol.ts';
|
|
24
|
+
export declare function copy<Value>(value: Value): Value;
|
|
25
|
+
export declare function unresolvedWriteIds(receipts: Iterable<Receipt>): string[];
|
|
26
|
+
export declare function forkRepeatsSettledWrite(receipts: Iterable<Receipt>, forkBeforeWrite: ReadonlyMap<string, number>, forkAt: number | null): boolean;
|
|
27
|
+
export declare function safeForkLength(receipts: Iterable<Receipt>, forkBeforeWrite: ReadonlyMap<string, number>, unredactedLength: number): number | null;
|
|
28
|
+
export declare function recoveryAdvice(ids: readonly string[], receipts: Iterable<Receipt>, redactedPendingIds: readonly string[]): string;
|
|
29
|
+
interface OperationFactsAdapter {
|
|
30
|
+
capture(): unknown;
|
|
31
|
+
restore(value: unknown): void;
|
|
32
|
+
}
|
|
33
|
+
interface OperationSignal {
|
|
34
|
+
readonly aborted: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ReadRunLogOptions {
|
|
37
|
+
anyMachine?: boolean;
|
|
38
|
+
legacyInspection?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface RunLogInspectionEntry {
|
|
41
|
+
index: number;
|
|
42
|
+
sourceVersion: number;
|
|
43
|
+
record: RunRecord;
|
|
44
|
+
snapshot: unknown;
|
|
45
|
+
events: Record<string, unknown>[];
|
|
46
|
+
}
|
|
47
|
+
export declare class RunJournal {
|
|
48
|
+
snapshotSavedAt: number | undefined;
|
|
49
|
+
firstSavedAt: number | undefined;
|
|
50
|
+
deltasSinceCheckpoint: number;
|
|
51
|
+
redactedPendingArgs: boolean | null;
|
|
52
|
+
unredactedLength: number;
|
|
53
|
+
private restoredRedacted;
|
|
54
|
+
private readonly forkBeforeWrite;
|
|
55
|
+
knownLength: number;
|
|
56
|
+
metadata: Extract<RunRecord, {
|
|
57
|
+
type: 'metadata';
|
|
58
|
+
}> | undefined;
|
|
59
|
+
readonly receipts: Map<string, Receipt>;
|
|
60
|
+
private readonly intentArgs;
|
|
61
|
+
private tail;
|
|
62
|
+
private settledTail;
|
|
63
|
+
uncertainWrite(): (Operation & {
|
|
64
|
+
facts?: unknown;
|
|
65
|
+
status: 'intent' | 'retry';
|
|
66
|
+
}) | undefined;
|
|
67
|
+
failure: Error | null;
|
|
68
|
+
detachedEffects: Promise<void> | null;
|
|
69
|
+
sealed: boolean;
|
|
70
|
+
onFailure?: (error: Error) => void;
|
|
71
|
+
readonly core: MachineLog;
|
|
72
|
+
restored: boolean;
|
|
73
|
+
private readonly redact;
|
|
74
|
+
private readonly redactShared;
|
|
75
|
+
private readonly redactOperationResult;
|
|
76
|
+
private readonly redactRecord?;
|
|
77
|
+
private readonly hasRedactionProvenance;
|
|
78
|
+
private readonly initialBoot?;
|
|
79
|
+
private engineBoot;
|
|
80
|
+
get snapshot(): unknown;
|
|
81
|
+
get requestHistoryBase(): readonly unknown[] | undefined;
|
|
82
|
+
compactSnapshot(snapshot: unknown): unknown;
|
|
83
|
+
constructor(core: MachineLog, opts?: RunJournalOptions);
|
|
84
|
+
redactValue<Value>(value: Value): Value;
|
|
85
|
+
restore(): Promise<void>;
|
|
86
|
+
private assertCompatibleBoot;
|
|
87
|
+
private allowLegacyFailureResults;
|
|
88
|
+
private restoreBoot;
|
|
89
|
+
exportBoot(): EngineBoot;
|
|
90
|
+
exportSnapshot(): unknown;
|
|
91
|
+
private trackForkPoint;
|
|
92
|
+
settledCall(receiptId: string): boolean;
|
|
93
|
+
private unresolvedWriteIds;
|
|
94
|
+
redactedPendingCallIds(snapshot: unknown): string[];
|
|
95
|
+
private safeForkLength;
|
|
96
|
+
getReceipt(receiptId: string): Receipt | undefined;
|
|
97
|
+
commitResultFacts(receiptId: string, facts: unknown): Promise<void>;
|
|
98
|
+
retryLifecycleReceipts(): Receipt[];
|
|
99
|
+
pendingArgumentsWereRedacted(snapshot: unknown): boolean | null;
|
|
100
|
+
append(record: RunRecord): Promise<void>;
|
|
101
|
+
private fail;
|
|
102
|
+
hasPendingFlush(): boolean;
|
|
103
|
+
flush(): Promise<void>;
|
|
104
|
+
resolve(resolutions: readonly RecoveryResolution[]): Promise<void>;
|
|
105
|
+
operation<Result>(operation: Operation, execute: () => Promise<Result>, facts?: OperationFactsAdapter, signal?: OperationSignal): Promise<Result>;
|
|
106
|
+
}
|
|
107
|
+
interface RunJournalOptions {
|
|
108
|
+
redact?: <Value>(value: Value) => Value;
|
|
109
|
+
redactShared?: <Value>(value: Value) => Value;
|
|
110
|
+
redactOperationResult?: <Value>(operation: Operation, value: Value) => Value;
|
|
111
|
+
redactRecord?: (record: RunRecord) => RunRecord;
|
|
112
|
+
boot?: EngineBoot;
|
|
113
|
+
}
|
|
114
|
+
export declare function acquireRun(owner: object, runId: string): () => void;
|
|
115
|
+
export declare class EventCodec {
|
|
116
|
+
private base;
|
|
117
|
+
private readonly historyBase;
|
|
118
|
+
constructor(historyBase?: readonly unknown[]);
|
|
119
|
+
reset(): void;
|
|
120
|
+
encode(event: unknown): Patch;
|
|
121
|
+
decode(patch: Patch): Record<string, unknown>;
|
|
122
|
+
decodeLegacy(patch: Patch): Record<string, unknown>;
|
|
123
|
+
private merge;
|
|
124
|
+
}
|
|
125
|
+
export declare function readRunLog(core: MachineLog, opts?: ReadRunLogOptions): AsyncGenerator<RunLogInspectionEntry>;
|