@riddledc/riddle-proof 0.5.44 → 0.5.46
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/README.md +17 -0
- package/dist/checkpoint.cjs +366 -0
- package/dist/checkpoint.d.cts +44 -1
- package/dist/checkpoint.d.ts +44 -1
- package/dist/checkpoint.js +8 -2
- package/dist/{chunk-W7VTDN4T.js → chunk-DUFDZJOF.js} +1 -0
- package/dist/{chunk-7S7O3NKF.js → chunk-JTNMEH57.js} +6 -1
- package/dist/{chunk-MRSYJMF4.js → chunk-L26NTZOU.js} +2 -2
- package/dist/chunk-NOBFZDZG.js +754 -0
- package/dist/chunk-PLSGW2GI.js +161 -0
- package/dist/chunk-R6SCWJCI.js +656 -0
- package/dist/{chunk-MJD37CLH.js → chunk-X3AQ2WUM.js} +201 -18
- package/dist/cli.cjs +6129 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +160 -0
- package/dist/codex-exec-agent.cjs +790 -0
- package/dist/codex-exec-agent.d.cts +91 -0
- package/dist/codex-exec-agent.d.ts +91 -0
- package/dist/codex-exec-agent.js +10 -0
- package/dist/engine-harness.cjs +1013 -323
- package/dist/engine-harness.js +5 -4
- package/dist/index.cjs +1702 -247
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +37 -17
- package/dist/openclaw.js +4 -2
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/dist/result.cjs +1 -0
- package/dist/result.js +1 -1
- package/dist/run-card.cjs +212 -0
- package/dist/run-card.d.cts +10 -0
- package/dist/run-card.d.ts +10 -0
- package/dist/run-card.js +10 -0
- package/dist/runner.cjs +2 -0
- package/dist/runner.js +5 -3
- package/dist/state.cjs +174 -5
- package/dist/state.d.cts +2 -1
- package/dist/state.d.ts +2 -1
- package/dist/state.js +4 -2
- package/dist/types.d.cts +64 -2
- package/dist/types.d.ts +64 -2
- package/package.json +15 -2
- package/dist/chunk-RI25RGQP.js +0 -293
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
statePathsForRunState
|
|
3
|
+
} from "./chunk-R6SCWJCI.js";
|
|
4
|
+
import {
|
|
5
|
+
compactRecord,
|
|
6
|
+
isTerminalStatus,
|
|
7
|
+
nonEmptyString,
|
|
8
|
+
recordValue
|
|
9
|
+
} from "./chunk-DUFDZJOF.js";
|
|
10
|
+
|
|
11
|
+
// src/run-card.ts
|
|
12
|
+
var RIDDLE_PROOF_RUN_CARD_VERSION = "riddle-proof.run-card.v1";
|
|
13
|
+
function elapsedMs(start, end) {
|
|
14
|
+
const startMs = start ? Date.parse(start) : NaN;
|
|
15
|
+
const endMs = end ? Date.parse(end) : NaN;
|
|
16
|
+
if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
|
|
17
|
+
return Math.max(0, endMs - startMs);
|
|
18
|
+
}
|
|
19
|
+
function jsonCloneRecord(value) {
|
|
20
|
+
const record = recordValue(value);
|
|
21
|
+
if (!record) return void 0;
|
|
22
|
+
try {
|
|
23
|
+
return JSON.parse(JSON.stringify(record));
|
|
24
|
+
} catch {
|
|
25
|
+
return { ...record };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function compactText(value, limit = 600) {
|
|
29
|
+
const text = nonEmptyString(value);
|
|
30
|
+
if (!text) return void 0;
|
|
31
|
+
return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
|
|
32
|
+
}
|
|
33
|
+
function visualDeltaFrom(input) {
|
|
34
|
+
const fullState = input.fullRiddleState || {};
|
|
35
|
+
const bundle = recordValue(fullState.evidence_bundle);
|
|
36
|
+
const after = recordValue(bundle?.after);
|
|
37
|
+
const afterDelta = recordValue(after?.visual_delta);
|
|
38
|
+
if (afterDelta && Object.keys(afterDelta).length) return afterDelta;
|
|
39
|
+
const requestDelta = recordValue(recordValue(fullState.proof_assessment_request)?.visual_delta);
|
|
40
|
+
if (requestDelta && Object.keys(requestDelta).length) return requestDelta;
|
|
41
|
+
const packetDelta = recordValue(input.runState.checkpoint_packet?.evidence_excerpt?.visual_delta);
|
|
42
|
+
return packetDelta && Object.keys(packetDelta).length ? packetDelta : void 0;
|
|
43
|
+
}
|
|
44
|
+
function artifactsFrom(input) {
|
|
45
|
+
const packetArtifacts = input.runState.checkpoint_packet?.artifacts;
|
|
46
|
+
if (packetArtifacts?.length) return packetArtifacts.slice(0, 12);
|
|
47
|
+
const fullState = input.fullRiddleState || {};
|
|
48
|
+
const artifacts = [];
|
|
49
|
+
for (const role of ["before", "prod", "after"]) {
|
|
50
|
+
const url = nonEmptyString(fullState[`${role}_cdn`]) || nonEmptyString(input.runState[`${role}_artifact_url`]);
|
|
51
|
+
if (url) artifacts.push({ role, url, name: `${role}.png`, mime_type: "image/png" });
|
|
52
|
+
}
|
|
53
|
+
return artifacts.length ? artifacts : void 0;
|
|
54
|
+
}
|
|
55
|
+
function ownerFor(state) {
|
|
56
|
+
if (state.status === "awaiting_checkpoint") {
|
|
57
|
+
const role = nonEmptyString(state.checkpoint_packet?.routing_hint?.suggested_role);
|
|
58
|
+
return role || "supervising_agent";
|
|
59
|
+
}
|
|
60
|
+
if (state.status === "running") return "engine";
|
|
61
|
+
if (state.status === "blocked" || state.status === "failed") return "human_or_operator";
|
|
62
|
+
return "none";
|
|
63
|
+
}
|
|
64
|
+
function actionFor(state) {
|
|
65
|
+
if (state.status === "awaiting_checkpoint") return state.checkpoint_packet?.question || "Answer the pending checkpoint.";
|
|
66
|
+
if (state.status === "running") return "Continue the current Riddle Proof stage.";
|
|
67
|
+
if (state.status === "blocked" || state.status === "failed") return state.blocker?.message || "Inspect the blocker and decide whether a new run or infrastructure repair is needed.";
|
|
68
|
+
if (state.status === "ready_to_ship") return "Ship is held by policy; review PR/ship policy before advancing.";
|
|
69
|
+
return "No next action; run is terminal.";
|
|
70
|
+
}
|
|
71
|
+
function evidenceIssueCode(input) {
|
|
72
|
+
const packetIssue = nonEmptyString(input.runState.checkpoint_packet?.evidence_excerpt?.evidence_issue_code);
|
|
73
|
+
if (packetIssue) return packetIssue;
|
|
74
|
+
const assessmentIssue = nonEmptyString(recordValue(input.fullRiddleState?.proof_assessment)?.evidence_issue_code);
|
|
75
|
+
if (assessmentIssue) return assessmentIssue;
|
|
76
|
+
const delta = visualDeltaFrom(input);
|
|
77
|
+
const status = nonEmptyString(delta?.status);
|
|
78
|
+
if (status === "unmeasured") {
|
|
79
|
+
const reason = `${nonEmptyString(delta?.reason) || ""}
|
|
80
|
+
${input.runState.blocker?.message || ""}`.toLowerCase();
|
|
81
|
+
return reason.includes("fetch") || reason.includes("allowlist") || reason.includes("registered domain") || reason.includes("high risk") || reason.includes("comparator") ? "comparator_fetch_blocked" : "visual_delta_unmeasured";
|
|
82
|
+
}
|
|
83
|
+
if (status === "measured" && delta?.passed === false) return "semantic_proof_failed";
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
function createRiddleProofRunCard(state, input = {}) {
|
|
87
|
+
const at = input.at || (/* @__PURE__ */ new Date()).toISOString();
|
|
88
|
+
const fullState = input.fullRiddleState || {};
|
|
89
|
+
const packet = state.checkpoint_packet;
|
|
90
|
+
const latestEvent = state.events[state.events.length - 1];
|
|
91
|
+
const bundle = recordValue(fullState.evidence_bundle);
|
|
92
|
+
const artifactContract = jsonCloneRecord(packet?.artifact_contract) || jsonCloneRecord(recordValue(fullState.proof_assessment_request)?.artifact_contract) || jsonCloneRecord(recordValue(bundle?.artifact_contract)) || jsonCloneRecord(state.proof_contract?.artifact_contract);
|
|
93
|
+
const required = jsonCloneRecord(recordValue(artifactContract)?.required);
|
|
94
|
+
const statePaths = input.state_paths || state.state_paths || statePathsForRunState(state);
|
|
95
|
+
const visualDelta = visualDeltaFrom({ fullRiddleState: fullState, runState: state });
|
|
96
|
+
const artifacts = artifactsFrom({ fullRiddleState: fullState, runState: state });
|
|
97
|
+
return {
|
|
98
|
+
version: RIDDLE_PROOF_RUN_CARD_VERSION,
|
|
99
|
+
run_id: state.run_id || "unknown",
|
|
100
|
+
status: state.status,
|
|
101
|
+
goal: compactRecord({
|
|
102
|
+
repo: state.request.repo || nonEmptyString(fullState.repo),
|
|
103
|
+
branch: state.request.branch || nonEmptyString(fullState.branch),
|
|
104
|
+
change_request: state.request.change_request || nonEmptyString(fullState.change_request),
|
|
105
|
+
verification_mode: state.request.verification_mode || nonEmptyString(fullState.verification_mode),
|
|
106
|
+
success_criteria: state.request.success_criteria
|
|
107
|
+
}),
|
|
108
|
+
durable_state: compactRecord({
|
|
109
|
+
...statePaths,
|
|
110
|
+
worktree_path: state.worktree_path || nonEmptyString(fullState.after_worktree) || null,
|
|
111
|
+
branch: state.branch || nonEmptyString(fullState.branch) || null
|
|
112
|
+
}),
|
|
113
|
+
current_phase: compactRecord({
|
|
114
|
+
stage: state.current_stage ?? null,
|
|
115
|
+
checkpoint: state.last_checkpoint ?? packet?.checkpoint ?? null,
|
|
116
|
+
latest_event: latestEvent?.kind ?? null,
|
|
117
|
+
elapsed_ms: elapsedMs(state.created_at, at),
|
|
118
|
+
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
119
|
+
iterations: state.iterations
|
|
120
|
+
}),
|
|
121
|
+
owner_next_action: compactRecord({
|
|
122
|
+
owner: ownerFor(state),
|
|
123
|
+
action: actionFor(state),
|
|
124
|
+
checkpoint_kind: packet?.kind || null,
|
|
125
|
+
allowed_decisions: packet?.allowed_decisions,
|
|
126
|
+
retryable: state.status === "running" || state.status === "awaiting_checkpoint",
|
|
127
|
+
reason: state.blocker?.code || packet?.summary || latestEvent?.summary || null
|
|
128
|
+
}),
|
|
129
|
+
evidence_contract: compactRecord({
|
|
130
|
+
verification_mode: state.request.verification_mode || nonEmptyString(fullState.verification_mode),
|
|
131
|
+
required,
|
|
132
|
+
artifact_contract: artifactContract,
|
|
133
|
+
proof_plan: compactText(state.proof_contract?.proof_plan || fullState.proof_plan, 600),
|
|
134
|
+
stop_condition: compactText(state.proof_contract?.stop_condition, 400)
|
|
135
|
+
}),
|
|
136
|
+
latest_evidence: compactRecord({
|
|
137
|
+
before_url: nonEmptyString(fullState.before_cdn) || state.before_artifact_url || null,
|
|
138
|
+
prod_url: nonEmptyString(fullState.prod_cdn) || state.prod_artifact_url || null,
|
|
139
|
+
after_url: nonEmptyString(fullState.after_cdn) || state.after_artifact_url || null,
|
|
140
|
+
visual_delta: visualDelta || null,
|
|
141
|
+
evidence_issue_code: evidenceIssueCode({ fullRiddleState: fullState, runState: state }) || null,
|
|
142
|
+
proof_evidence_present: fullState.proof_evidence_present === true || Boolean(bundle?.proof_evidence || bundle?.proof_evidence_sample),
|
|
143
|
+
artifacts
|
|
144
|
+
}),
|
|
145
|
+
stop_condition: compactRecord({
|
|
146
|
+
status: state.status,
|
|
147
|
+
terminal: isTerminalStatus(state.status),
|
|
148
|
+
blocker_code: state.blocker?.code || null,
|
|
149
|
+
blocker_message: state.blocker?.message || null,
|
|
150
|
+
proof_decision: state.proof_decision,
|
|
151
|
+
merge_recommendation: state.merge_recommendation,
|
|
152
|
+
monitor_should_continue: !isTerminalStatus(state.status)
|
|
153
|
+
}),
|
|
154
|
+
updated_at: state.updated_at
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export {
|
|
159
|
+
RIDDLE_PROOF_RUN_CARD_VERSION,
|
|
160
|
+
createRiddleProofRunCard
|
|
161
|
+
};
|