harnery 0.45.0 → 0.45.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/dist/commander.js +0 -1
- package/dist/commands/files.d.ts +2 -2
- package/dist/commands/files.d.ts.map +1 -1
- package/dist/commands/files.js +4 -7
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/commands/servers.js +17 -11
- package/dist/commands/tunnel.d.ts +0 -15
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +153 -453
- package/dist/core/agents/live-authority-v3.d.ts +0 -1
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +0 -11
- package/dist/core/agents/live-lifecycle-v3.d.ts +2 -4
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
- package/dist/core/agents/live-lifecycle-v3.js +7 -28
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +14 -25
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-writer.js +0 -5
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +0 -5
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +70 -180
- package/dist/core/artifacts/activity.d.ts +4 -1
- package/dist/core/artifacts/activity.d.ts.map +1 -1
- package/dist/core/artifacts/activity.js +8 -2
- package/dist/core/artifacts/delivery-card.d.ts.map +1 -1
- package/dist/core/artifacts/delivery-card.js +1 -2
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +38 -12
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +0 -29
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +0 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +0 -7
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +64 -77
- package/dist/core/hooks/cli.js +78 -48
- package/dist/core/servers/index.d.ts +13 -10
- package/dist/core/servers/index.d.ts.map +1 -1
- package/dist/core/servers/index.js +97 -192
- package/dist/core/servers/tunnels.d.ts +3 -5
- package/dist/core/servers/tunnels.d.ts.map +1 -1
- package/dist/core/servers/tunnels.js +2 -45
- package/dist/core/storage/durable-history.js +56 -22
- package/dist/core/storage/segments.d.ts.map +1 -1
- package/dist/core/storage/segments.js +73 -17
- package/dist/core/work/state.js +7 -7
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +21 -65
- package/dist/core/workflow/live-session-v3.d.ts +0 -6
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +5 -126
- package/dist/core/workflow/proof.d.ts +4 -4
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +4 -12
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +0 -19
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +0 -13
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +0 -19
- package/dist/core/workflow/spawn-opencode.d.ts.map +1 -1
- package/dist/core/workflow/spawn-opencode.js +0 -14
- package/dist/core/workflow/types.d.ts +11 -54
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +0 -4
- package/dist/lib/tunnel/state.d.ts +6 -13
- package/dist/lib/tunnel/state.d.ts.map +1 -1
- package/dist/lib/tunnel/state.js +12 -58
- package/package.json +1 -6
- package/src/commander.ts +0 -10
- package/src/commands/files.ts +5 -13
- package/src/commands/servers.ts +23 -12
- package/src/commands/tunnel.ts +166 -533
- package/src/core/agents/live-authority-v3.ts +0 -17
- package/src/core/agents/live-lifecycle-v3.ts +14 -52
- package/src/core/agents/state/heartbeat-writer.ts +12 -29
- package/src/core/agents/state/live-coordination-writer.ts +0 -29
- package/src/core/agents/state/pidmap.ts +0 -13
- package/src/core/agents/state/stale-sweep.ts +82 -247
- package/src/core/artifacts/activity.ts +9 -2
- package/src/core/artifacts/delivery-card.ts +1 -7
- package/src/core/artifacts/index.ts +45 -12
- package/src/core/events/v3/authority-outbox.ts +0 -56
- package/src/core/events/v3/producers/coordination-recorder.ts +0 -15
- package/src/core/events/v3/producers/recorder.ts +68 -94
- package/src/core/hooks/cli.ts +85 -47
- package/src/core/servers/index.ts +106 -228
- package/src/core/servers/tunnels.ts +3 -55
- package/src/core/storage/durable-history.ts +52 -20
- package/src/core/storage/segments.ts +79 -17
- package/src/core/work/state.ts +7 -7
- package/src/core/workflow/engine.ts +21 -73
- package/src/core/workflow/live-session-v3.ts +5 -146
- package/src/core/workflow/proof.ts +5 -21
- package/src/core/workflow/spawn-claude.ts +0 -18
- package/src/core/workflow/spawn-codex.ts +0 -13
- package/src/core/workflow/spawn-cursor.ts +0 -18
- package/src/core/workflow/spawn-opencode.ts +0 -14
- package/src/core/workflow/types.ts +11 -41
- package/src/lib/identities/assume.ts +0 -4
- package/src/lib/tunnel/state.ts +15 -70
- package/dist/commands/turn-rollback.d.ts +0 -5
- package/dist/commands/turn-rollback.d.ts.map +0 -1
- package/dist/commands/turn-rollback.js +0 -76
- package/dist/core/agents/state/unchanged-file.d.ts +0 -44
- package/dist/core/agents/state/unchanged-file.d.ts.map +0 -1
- package/dist/core/agents/state/unchanged-file.js +0 -390
- package/dist/core/events/v3/generation-custody.d.ts +0 -5
- package/dist/core/events/v3/generation-custody.d.ts.map +0 -1
- package/dist/core/events/v3/generation-custody.js +0 -50
- package/dist/core/turn-rollback/content.d.ts +0 -53
- package/dist/core/turn-rollback/content.d.ts.map +0 -1
- package/dist/core/turn-rollback/content.js +0 -396
- package/dist/core/turn-rollback/index.d.ts +0 -72
- package/dist/core/turn-rollback/index.d.ts.map +0 -1
- package/dist/core/turn-rollback/index.js +0 -443
- package/dist/core/workflow/failure-evidence.d.ts +0 -16
- package/dist/core/workflow/failure-evidence.d.ts.map +0 -1
- package/dist/core/workflow/failure-evidence.js +0 -114
- package/src/commands/turn-rollback.ts +0 -111
- package/src/core/agents/state/unchanged-file.ts +0 -456
- package/src/core/events/v3/generation-custody.ts +0 -59
- package/src/core/turn-rollback/content.ts +0 -499
- package/src/core/turn-rollback/index.ts +0 -580
- package/src/core/workflow/failure-evidence.ts +0 -141
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import type { AdapterRawResult } from "../adapters/types.ts";
|
|
3
|
-
import type { SpawnFailureEvidence, SpawnOutputSource, SpawnResult } from "./types.ts";
|
|
4
|
-
|
|
5
|
-
export function unknownFailureEvidence(): SpawnFailureEvidence {
|
|
6
|
-
return {
|
|
7
|
-
effect: { state: "unknown" },
|
|
8
|
-
refusal: { state: "unknown" },
|
|
9
|
-
partial_output: { state: "unknown" },
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Built-in subprocess adapters observe output and process-start failures.
|
|
14
|
-
* Their current vendor envelopes do not prove effects or native refusal.
|
|
15
|
-
* In particular, blank output and 429/5xx statuses leave both unknown. */
|
|
16
|
-
export function observeSpawnFailure(
|
|
17
|
-
raw: Pick<AdapterRawResult, "spawnErrno" | "timedOut"> &
|
|
18
|
-
Partial<Pick<AdapterRawResult, "stdout" | "resultFileText">>,
|
|
19
|
-
text: string,
|
|
20
|
-
source: SpawnOutputSource,
|
|
21
|
-
): SpawnFailureEvidence {
|
|
22
|
-
const bytes = Buffer.byteLength(text);
|
|
23
|
-
return {
|
|
24
|
-
effect:
|
|
25
|
-
raw.spawnErrno === "ENOENT" &&
|
|
26
|
-
!raw.timedOut &&
|
|
27
|
-
bytes === 0 &&
|
|
28
|
-
!raw.stdout?.trim() &&
|
|
29
|
-
!raw.resultFileText?.trim()
|
|
30
|
-
? { state: "none", source: "spawn_errno", reference: "ENOENT" }
|
|
31
|
-
: { state: "unknown" },
|
|
32
|
-
refusal: { state: "unknown" },
|
|
33
|
-
partial_output:
|
|
34
|
-
bytes > 0
|
|
35
|
-
? {
|
|
36
|
-
state: "present",
|
|
37
|
-
source,
|
|
38
|
-
bytes,
|
|
39
|
-
sha256: createHash("sha256").update(text).digest("hex"),
|
|
40
|
-
}
|
|
41
|
-
: { state: "absent", source },
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function record(value: unknown): value is Record<string, unknown> {
|
|
46
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function keys(value: Record<string, unknown>, expected: readonly string[]): boolean {
|
|
50
|
-
return (
|
|
51
|
-
Object.keys(value).length === expected.length &&
|
|
52
|
-
expected.every((key) => Object.hasOwn(value, key))
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function reference(value: unknown): value is string {
|
|
57
|
-
return typeof value === "string" && value.trim().length > 0 && value.length <= 512;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function validEffect(value: unknown): boolean {
|
|
61
|
-
if (!record(value)) return false;
|
|
62
|
-
if (value.state === "unknown") return keys(value, ["state"]);
|
|
63
|
-
if (!keys(value, ["state", "source", "reference"])) return false;
|
|
64
|
-
if (value.state === "none" && value.source === "spawn_errno") {
|
|
65
|
-
return value.reference === "ENOENT";
|
|
66
|
-
}
|
|
67
|
-
return (
|
|
68
|
-
(value.state === "none" || value.state === "observed") &&
|
|
69
|
-
value.source === "adapter_evidence" &&
|
|
70
|
-
reference(value.reference)
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function validRefusal(value: unknown): boolean {
|
|
75
|
-
if (!record(value)) return false;
|
|
76
|
-
if (value.state === "unknown") return keys(value, ["state"]);
|
|
77
|
-
return (
|
|
78
|
-
keys(value, ["state", "source", "reference"]) &&
|
|
79
|
-
value.state === "refused" &&
|
|
80
|
-
value.source === "vendor_envelope" &&
|
|
81
|
-
reference(value.reference)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function validOutput(value: unknown): boolean {
|
|
86
|
-
if (!record(value)) return false;
|
|
87
|
-
if (value.state === "unknown") return keys(value, ["state"]);
|
|
88
|
-
if (
|
|
89
|
-
value.source !== "final_message" &&
|
|
90
|
-
value.source !== "vendor_envelope" &&
|
|
91
|
-
value.source !== "stdout"
|
|
92
|
-
) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
if (value.state === "absent") return keys(value, ["state", "source"]);
|
|
96
|
-
return (
|
|
97
|
-
value.state === "present" &&
|
|
98
|
-
keys(value, ["state", "source", "bytes", "sha256"]) &&
|
|
99
|
-
Number.isSafeInteger(value.bytes) &&
|
|
100
|
-
(value.bytes as number) > 0 &&
|
|
101
|
-
typeof value.sha256 === "string" &&
|
|
102
|
-
/^[a-f0-9]{64}$/.test(value.sha256)
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function isSpawnFailureEvidence(value: unknown): value is SpawnFailureEvidence {
|
|
107
|
-
return (
|
|
108
|
-
record(value) &&
|
|
109
|
-
keys(value, ["effect", "refusal", "partial_output"]) &&
|
|
110
|
-
validEffect(value.effect) &&
|
|
111
|
-
validRefusal(value.refusal) &&
|
|
112
|
-
validOutput(value.partial_output)
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** Missing observations are unknown; malformed positive claims are rejected.
|
|
117
|
-
* This is also used when reading persisted workflow proof. */
|
|
118
|
-
export function resolveFailureEvidence(value: unknown): SpawnFailureEvidence {
|
|
119
|
-
if (value === undefined) return unknownFailureEvidence();
|
|
120
|
-
if (!isSpawnFailureEvidence(value)) throw new Error("invalid spawn failure evidence");
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function failureEvidenceAllowsUncharged(value: unknown): boolean {
|
|
125
|
-
const evidence = resolveFailureEvidence(value);
|
|
126
|
-
return (
|
|
127
|
-
evidence.effect.state === "none" &&
|
|
128
|
-
evidence.refusal.state !== "refused" &&
|
|
129
|
-
evidence.partial_output.state === "absent"
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** A provider retry requires positive no-effect evidence. A missing binary is
|
|
134
|
-
* known not to have started, but retrying that unchanged environment cannot help. */
|
|
135
|
-
export function canRetryFailedSpawn(result: SpawnResult): boolean {
|
|
136
|
-
return (
|
|
137
|
-
!result.ok &&
|
|
138
|
-
result.class !== "environment" &&
|
|
139
|
-
failureEvidenceAllowsUncharged(result.failureEvidence)
|
|
140
|
-
);
|
|
141
|
-
}
|