@riddledc/riddle-proof 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RiddleDC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @riddledc/riddle-proof
2
+
3
+ Reusable contracts and helpers for Riddle Proof: evidence-backed workflows for
4
+ agent-authored changes.
5
+
6
+ Riddle Proof is agent-agnostic. Bring a coding agent through an adapter; Riddle
7
+ Proof standardizes evidence, proof assessment, ship gates, terminal results,
8
+ and integration metadata.
9
+
10
+ This package is intentionally small at first. The current OpenClaw
11
+ `proofed_change_run` implementation remains the reference workflow while
12
+ reusable contracts and low-risk helpers are extracted here.
13
+
14
+ ## Initial Scope
15
+
16
+ - Run/result/state/event types
17
+ - Evidence bundle and proof assessment types
18
+ - Adapter interfaces
19
+ - State/event helpers for wrappers that need a stable run envelope
20
+ - Terminal ship metadata normalization
21
+ - Stable result helpers
22
+ - OpenClaw parameter normalization via `@riddledc/riddle-proof/openclaw`
23
+
24
+ ## Non-Goals
25
+
26
+ - Supplying a coding agent
27
+ - Replacing the working OpenClaw plugin in place
28
+ - Invoking OpenClaw plugins from inside other plugins
29
+
30
+ Future wrappers can consume this package from OpenClaw, Discord, CLI, GitHub
31
+ Actions, or Riddle-hosted workflows.
32
+
33
+ ## OpenClaw Adapter Boundary
34
+
35
+ `@riddledc/riddle-proof/openclaw` translates the current
36
+ `proofed_change_run`-style tool params into generic `RiddleProofRunParams`.
37
+ It preserves Discord routing metadata as `integration_context` and parses
38
+ `assertions_json` into the shared assertions field.
39
+
40
+ The adapter does not invoke another OpenClaw plugin and does not supply a
41
+ coding agent. It is the reusable mapping layer a future OpenClaw wrapper can
42
+ call before handing the request to its configured implementation, judge, ship,
43
+ and notification adapters.
@@ -0,0 +1,81 @@
1
+ // src/result.ts
2
+ function isTerminalStatus(status) {
3
+ return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
4
+ }
5
+ function isSuccessfulStatus(status) {
6
+ return status !== "blocked" && status !== "failed";
7
+ }
8
+ function compactRecord(input) {
9
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
10
+ }
11
+ function nonEmptyString(value) {
12
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
13
+ }
14
+ function recordValue(value) {
15
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
16
+ }
17
+ function normalizeTerminalMetadata(input) {
18
+ const riddleState = recordValue(input.riddleState) || {};
19
+ const result = recordValue(input.engineResult) || {};
20
+ const contract = recordValue(result.checkpointContract) || {};
21
+ const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
22
+ const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
23
+ const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
24
+ return compactRecord({
25
+ pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
26
+ marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
27
+ notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
28
+ proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
29
+ merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
30
+ finalized: typeof finalized === "boolean" ? finalized : void 0
31
+ });
32
+ }
33
+ function applyTerminalMetadata(state, metadata) {
34
+ const prUrl = nonEmptyString(metadata.pr_url);
35
+ if (prUrl) state.pr_url = prUrl;
36
+ if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
37
+ const notification = recordValue(metadata.notification);
38
+ if (notification) state.notification = notification;
39
+ const proofDecision = nonEmptyString(metadata.proof_decision);
40
+ if (proofDecision) state.proof_decision = proofDecision;
41
+ const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
42
+ if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
43
+ if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
44
+ return state;
45
+ }
46
+ function createRunResult(input) {
47
+ const status = input.status || input.state.status;
48
+ const ok = isSuccessfulStatus(status);
49
+ const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
50
+ state.status = status;
51
+ state.ok = ok;
52
+ return compactRecord({
53
+ ok,
54
+ status,
55
+ state_path: input.state_path ?? state.state_path ?? null,
56
+ iterations: state.iterations,
57
+ last_checkpoint: state.last_checkpoint ?? null,
58
+ last_summary: input.last_summary ?? null,
59
+ event_count: state.events.length,
60
+ pr_url: state.pr_url,
61
+ marked_ready: state.marked_ready,
62
+ notification: state.notification,
63
+ proof_decision: state.proof_decision,
64
+ merge_recommendation: state.merge_recommendation,
65
+ finalized: state.finalized,
66
+ blocker: state.blocker,
67
+ evidence_bundle: input.evidence_bundle,
68
+ raw: input.raw
69
+ });
70
+ }
71
+
72
+ export {
73
+ isTerminalStatus,
74
+ isSuccessfulStatus,
75
+ compactRecord,
76
+ nonEmptyString,
77
+ recordValue,
78
+ normalizeTerminalMetadata,
79
+ applyTerminalMetadata,
80
+ createRunResult
81
+ };
File without changes
@@ -0,0 +1,107 @@
1
+ import {
2
+ compactRecord,
3
+ nonEmptyString,
4
+ recordValue
5
+ } from "./chunk-2ZQNXVQC.js";
6
+
7
+ // src/state.ts
8
+ var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
9
+ function timestamp() {
10
+ return (/* @__PURE__ */ new Date()).toISOString();
11
+ }
12
+ function normalizeIntegrationContext(input, fallbackSource) {
13
+ const value = recordValue(input);
14
+ if (!value) {
15
+ return fallbackSource ? { source: fallbackSource } : void 0;
16
+ }
17
+ const metadata = recordValue(value.metadata);
18
+ return compactRecord({
19
+ source: nonEmptyString(value.source) || fallbackSource,
20
+ channel_id: nonEmptyString(value.channel_id),
21
+ thread_id: nonEmptyString(value.thread_id),
22
+ message_id: nonEmptyString(value.message_id),
23
+ source_url: nonEmptyString(value.source_url),
24
+ metadata: metadata && Object.keys(metadata).length ? metadata : void 0
25
+ });
26
+ }
27
+ function normalizeRunParams(input) {
28
+ return compactRecord({
29
+ repo: input.repo,
30
+ branch: input.branch,
31
+ change_request: input.change_request,
32
+ commit_message: input.commit_message,
33
+ prod_url: input.prod_url,
34
+ capture_script: input.capture_script,
35
+ success_criteria: input.success_criteria,
36
+ assertions: input.assertions,
37
+ verification_mode: input.verification_mode,
38
+ reference: input.reference,
39
+ base_branch: input.base_branch,
40
+ before_ref: input.before_ref,
41
+ allow_static_preview_fallback: input.allow_static_preview_fallback,
42
+ context: input.context,
43
+ reviewer: input.reviewer,
44
+ mode: input.mode,
45
+ build_command: input.build_command,
46
+ build_output: input.build_output,
47
+ server_image: input.server_image,
48
+ server_command: input.server_command,
49
+ server_port: input.server_port,
50
+ server_path: input.server_path,
51
+ use_auth: input.use_auth,
52
+ color_scheme: input.color_scheme,
53
+ wait_for_selector: input.wait_for_selector,
54
+ ship_mode: input.ship_mode,
55
+ integration_context: normalizeIntegrationContext(input.integration_context)
56
+ });
57
+ }
58
+ function createRunState(input) {
59
+ const createdAt = input.created_at || timestamp();
60
+ return compactRecord({
61
+ version: RIDDLE_PROOF_RUN_STATE_VERSION,
62
+ state_path: input.state_path,
63
+ status: input.status || "running",
64
+ created_at: createdAt,
65
+ updated_at: input.updated_at || createdAt,
66
+ request: normalizeRunParams(input.request),
67
+ iterations: input.iterations ?? 0,
68
+ last_checkpoint: input.last_checkpoint ?? null,
69
+ events: input.events ? [...input.events] : []
70
+ });
71
+ }
72
+ function appendRunEvent(state, input) {
73
+ const event = {
74
+ ts: input.ts || timestamp(),
75
+ kind: input.kind,
76
+ checkpoint: input.checkpoint,
77
+ stage: input.stage,
78
+ summary: input.summary,
79
+ details: input.details
80
+ };
81
+ state.events.push(compactRecord({
82
+ ts: event.ts,
83
+ kind: event.kind,
84
+ checkpoint: event.checkpoint,
85
+ stage: event.stage,
86
+ summary: event.summary,
87
+ details: event.details
88
+ }));
89
+ if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
90
+ state.updated_at = event.ts;
91
+ return state;
92
+ }
93
+ function setRunStatus(state, status, at = timestamp()) {
94
+ state.status = status;
95
+ state.ok = status !== "blocked" && status !== "failed";
96
+ state.updated_at = at;
97
+ return state;
98
+ }
99
+
100
+ export {
101
+ RIDDLE_PROOF_RUN_STATE_VERSION,
102
+ normalizeIntegrationContext,
103
+ normalizeRunParams,
104
+ createRunState,
105
+ appendRunEvent,
106
+ setRunStatus
107
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
24
+ appendRunEvent: () => appendRunEvent,
25
+ applyTerminalMetadata: () => applyTerminalMetadata,
26
+ compactRecord: () => compactRecord,
27
+ createRunResult: () => createRunResult,
28
+ createRunState: () => createRunState,
29
+ isSuccessfulStatus: () => isSuccessfulStatus,
30
+ isTerminalStatus: () => isTerminalStatus,
31
+ nonEmptyString: () => nonEmptyString,
32
+ normalizeIntegrationContext: () => normalizeIntegrationContext,
33
+ normalizeRunParams: () => normalizeRunParams,
34
+ normalizeTerminalMetadata: () => normalizeTerminalMetadata,
35
+ recordValue: () => recordValue,
36
+ setRunStatus: () => setRunStatus
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/result.ts
41
+ function isTerminalStatus(status) {
42
+ return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
43
+ }
44
+ function isSuccessfulStatus(status) {
45
+ return status !== "blocked" && status !== "failed";
46
+ }
47
+ function compactRecord(input) {
48
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
49
+ }
50
+ function nonEmptyString(value) {
51
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
52
+ }
53
+ function recordValue(value) {
54
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
55
+ }
56
+ function normalizeTerminalMetadata(input) {
57
+ const riddleState = recordValue(input.riddleState) || {};
58
+ const result = recordValue(input.engineResult) || {};
59
+ const contract = recordValue(result.checkpointContract) || {};
60
+ const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
61
+ const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
62
+ const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
63
+ return compactRecord({
64
+ pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
65
+ marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
66
+ notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
67
+ proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
68
+ merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
69
+ finalized: typeof finalized === "boolean" ? finalized : void 0
70
+ });
71
+ }
72
+ function applyTerminalMetadata(state, metadata) {
73
+ const prUrl = nonEmptyString(metadata.pr_url);
74
+ if (prUrl) state.pr_url = prUrl;
75
+ if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
76
+ const notification = recordValue(metadata.notification);
77
+ if (notification) state.notification = notification;
78
+ const proofDecision = nonEmptyString(metadata.proof_decision);
79
+ if (proofDecision) state.proof_decision = proofDecision;
80
+ const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
81
+ if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
82
+ if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
83
+ return state;
84
+ }
85
+ function createRunResult(input) {
86
+ const status = input.status || input.state.status;
87
+ const ok = isSuccessfulStatus(status);
88
+ const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
89
+ state.status = status;
90
+ state.ok = ok;
91
+ return compactRecord({
92
+ ok,
93
+ status,
94
+ state_path: input.state_path ?? state.state_path ?? null,
95
+ iterations: state.iterations,
96
+ last_checkpoint: state.last_checkpoint ?? null,
97
+ last_summary: input.last_summary ?? null,
98
+ event_count: state.events.length,
99
+ pr_url: state.pr_url,
100
+ marked_ready: state.marked_ready,
101
+ notification: state.notification,
102
+ proof_decision: state.proof_decision,
103
+ merge_recommendation: state.merge_recommendation,
104
+ finalized: state.finalized,
105
+ blocker: state.blocker,
106
+ evidence_bundle: input.evidence_bundle,
107
+ raw: input.raw
108
+ });
109
+ }
110
+
111
+ // src/state.ts
112
+ var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
113
+ function timestamp() {
114
+ return (/* @__PURE__ */ new Date()).toISOString();
115
+ }
116
+ function normalizeIntegrationContext(input, fallbackSource) {
117
+ const value = recordValue(input);
118
+ if (!value) {
119
+ return fallbackSource ? { source: fallbackSource } : void 0;
120
+ }
121
+ const metadata = recordValue(value.metadata);
122
+ return compactRecord({
123
+ source: nonEmptyString(value.source) || fallbackSource,
124
+ channel_id: nonEmptyString(value.channel_id),
125
+ thread_id: nonEmptyString(value.thread_id),
126
+ message_id: nonEmptyString(value.message_id),
127
+ source_url: nonEmptyString(value.source_url),
128
+ metadata: metadata && Object.keys(metadata).length ? metadata : void 0
129
+ });
130
+ }
131
+ function normalizeRunParams(input) {
132
+ return compactRecord({
133
+ repo: input.repo,
134
+ branch: input.branch,
135
+ change_request: input.change_request,
136
+ commit_message: input.commit_message,
137
+ prod_url: input.prod_url,
138
+ capture_script: input.capture_script,
139
+ success_criteria: input.success_criteria,
140
+ assertions: input.assertions,
141
+ verification_mode: input.verification_mode,
142
+ reference: input.reference,
143
+ base_branch: input.base_branch,
144
+ before_ref: input.before_ref,
145
+ allow_static_preview_fallback: input.allow_static_preview_fallback,
146
+ context: input.context,
147
+ reviewer: input.reviewer,
148
+ mode: input.mode,
149
+ build_command: input.build_command,
150
+ build_output: input.build_output,
151
+ server_image: input.server_image,
152
+ server_command: input.server_command,
153
+ server_port: input.server_port,
154
+ server_path: input.server_path,
155
+ use_auth: input.use_auth,
156
+ color_scheme: input.color_scheme,
157
+ wait_for_selector: input.wait_for_selector,
158
+ ship_mode: input.ship_mode,
159
+ integration_context: normalizeIntegrationContext(input.integration_context)
160
+ });
161
+ }
162
+ function createRunState(input) {
163
+ const createdAt = input.created_at || timestamp();
164
+ return compactRecord({
165
+ version: RIDDLE_PROOF_RUN_STATE_VERSION,
166
+ state_path: input.state_path,
167
+ status: input.status || "running",
168
+ created_at: createdAt,
169
+ updated_at: input.updated_at || createdAt,
170
+ request: normalizeRunParams(input.request),
171
+ iterations: input.iterations ?? 0,
172
+ last_checkpoint: input.last_checkpoint ?? null,
173
+ events: input.events ? [...input.events] : []
174
+ });
175
+ }
176
+ function appendRunEvent(state, input) {
177
+ const event = {
178
+ ts: input.ts || timestamp(),
179
+ kind: input.kind,
180
+ checkpoint: input.checkpoint,
181
+ stage: input.stage,
182
+ summary: input.summary,
183
+ details: input.details
184
+ };
185
+ state.events.push(compactRecord({
186
+ ts: event.ts,
187
+ kind: event.kind,
188
+ checkpoint: event.checkpoint,
189
+ stage: event.stage,
190
+ summary: event.summary,
191
+ details: event.details
192
+ }));
193
+ if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
194
+ state.updated_at = event.ts;
195
+ return state;
196
+ }
197
+ function setRunStatus(state, status, at = timestamp()) {
198
+ state.status = status;
199
+ state.ok = status !== "blocked" && status !== "failed";
200
+ state.updated_at = at;
201
+ return state;
202
+ }
203
+ // Annotate the CommonJS export names for ESM import in node:
204
+ 0 && (module.exports = {
205
+ RIDDLE_PROOF_RUN_STATE_VERSION,
206
+ appendRunEvent,
207
+ applyTerminalMetadata,
208
+ compactRecord,
209
+ createRunResult,
210
+ createRunState,
211
+ isSuccessfulStatus,
212
+ isTerminalStatus,
213
+ nonEmptyString,
214
+ normalizeIntegrationContext,
215
+ normalizeRunParams,
216
+ normalizeTerminalMetadata,
217
+ recordValue,
218
+ setRunStatus
219
+ });
@@ -0,0 +1,3 @@
1
+ export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, ShipAdapter } from './types.cjs';
2
+ export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from './result.cjs';
3
+ export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.cjs';
@@ -0,0 +1,3 @@
1
+ export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, ShipAdapter } from './types.js';
2
+ export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from './result.js';
3
+ export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.js';
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ import {
2
+ RIDDLE_PROOF_RUN_STATE_VERSION,
3
+ appendRunEvent,
4
+ createRunState,
5
+ normalizeIntegrationContext,
6
+ normalizeRunParams,
7
+ setRunStatus
8
+ } from "./chunk-EPVZKWUS.js";
9
+ import {
10
+ applyTerminalMetadata,
11
+ compactRecord,
12
+ createRunResult,
13
+ isSuccessfulStatus,
14
+ isTerminalStatus,
15
+ nonEmptyString,
16
+ normalizeTerminalMetadata,
17
+ recordValue
18
+ } from "./chunk-2ZQNXVQC.js";
19
+ import "./chunk-6F4PWJZI.js";
20
+ export {
21
+ RIDDLE_PROOF_RUN_STATE_VERSION,
22
+ appendRunEvent,
23
+ applyTerminalMetadata,
24
+ compactRecord,
25
+ createRunResult,
26
+ createRunState,
27
+ isSuccessfulStatus,
28
+ isTerminalStatus,
29
+ nonEmptyString,
30
+ normalizeIntegrationContext,
31
+ normalizeRunParams,
32
+ normalizeTerminalMetadata,
33
+ recordValue,
34
+ setRunStatus
35
+ };
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/openclaw.ts
21
+ var openclaw_exports = {};
22
+ __export(openclaw_exports, {
23
+ openClawIntegrationContext: () => openClawIntegrationContext,
24
+ parseOpenClawAssertions: () => parseOpenClawAssertions,
25
+ toRiddleProofRunParams: () => toRiddleProofRunParams
26
+ });
27
+ module.exports = __toCommonJS(openclaw_exports);
28
+
29
+ // src/result.ts
30
+ function compactRecord(input) {
31
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
32
+ }
33
+ function nonEmptyString(value) {
34
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
35
+ }
36
+ function recordValue(value) {
37
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
38
+ }
39
+
40
+ // src/state.ts
41
+ function normalizeIntegrationContext(input, fallbackSource) {
42
+ const value = recordValue(input);
43
+ if (!value) {
44
+ return fallbackSource ? { source: fallbackSource } : void 0;
45
+ }
46
+ const metadata = recordValue(value.metadata);
47
+ return compactRecord({
48
+ source: nonEmptyString(value.source) || fallbackSource,
49
+ channel_id: nonEmptyString(value.channel_id),
50
+ thread_id: nonEmptyString(value.thread_id),
51
+ message_id: nonEmptyString(value.message_id),
52
+ source_url: nonEmptyString(value.source_url),
53
+ metadata: metadata && Object.keys(metadata).length ? metadata : void 0
54
+ });
55
+ }
56
+ function normalizeRunParams(input) {
57
+ return compactRecord({
58
+ repo: input.repo,
59
+ branch: input.branch,
60
+ change_request: input.change_request,
61
+ commit_message: input.commit_message,
62
+ prod_url: input.prod_url,
63
+ capture_script: input.capture_script,
64
+ success_criteria: input.success_criteria,
65
+ assertions: input.assertions,
66
+ verification_mode: input.verification_mode,
67
+ reference: input.reference,
68
+ base_branch: input.base_branch,
69
+ before_ref: input.before_ref,
70
+ allow_static_preview_fallback: input.allow_static_preview_fallback,
71
+ context: input.context,
72
+ reviewer: input.reviewer,
73
+ mode: input.mode,
74
+ build_command: input.build_command,
75
+ build_output: input.build_output,
76
+ server_image: input.server_image,
77
+ server_command: input.server_command,
78
+ server_port: input.server_port,
79
+ server_path: input.server_path,
80
+ use_auth: input.use_auth,
81
+ color_scheme: input.color_scheme,
82
+ wait_for_selector: input.wait_for_selector,
83
+ ship_mode: input.ship_mode,
84
+ integration_context: normalizeIntegrationContext(input.integration_context)
85
+ });
86
+ }
87
+
88
+ // src/openclaw.ts
89
+ function parseOpenClawAssertions(value) {
90
+ if (value === void 0 || value === null || value === "") return void 0;
91
+ if (typeof value !== "string") return value;
92
+ const trimmed = value.trim();
93
+ if (!trimmed) return void 0;
94
+ try {
95
+ return JSON.parse(trimmed);
96
+ } catch {
97
+ return trimmed;
98
+ }
99
+ }
100
+ function openClawIntegrationContext(params) {
101
+ const hasDiscordContext = Boolean(params.discord_channel || params.discord_thread_id || params.discord_message_id || params.discord_source_url);
102
+ return normalizeIntegrationContext({
103
+ source: hasDiscordContext ? "discord" : "openclaw",
104
+ channel_id: params.discord_channel,
105
+ thread_id: params.discord_thread_id,
106
+ message_id: params.discord_message_id,
107
+ source_url: params.discord_source_url,
108
+ metadata: compactRecord({
109
+ wrapper: "openclaw",
110
+ tool: "proofed_change_run"
111
+ })
112
+ }, "openclaw");
113
+ }
114
+ function toRiddleProofRunParams(params) {
115
+ return normalizeRunParams({
116
+ repo: params.repo,
117
+ branch: params.branch,
118
+ change_request: params.change_request,
119
+ commit_message: params.commit_message,
120
+ prod_url: params.prod_url,
121
+ capture_script: params.capture_script,
122
+ success_criteria: params.success_criteria,
123
+ assertions: parseOpenClawAssertions(params.assertions_json),
124
+ verification_mode: params.verification_mode,
125
+ reference: params.reference,
126
+ base_branch: params.base_branch,
127
+ before_ref: params.before_ref,
128
+ allow_static_preview_fallback: params.allow_static_preview_fallback,
129
+ context: params.context,
130
+ reviewer: params.reviewer,
131
+ mode: params.mode,
132
+ build_command: params.build_command,
133
+ build_output: params.build_output,
134
+ server_image: params.server_image,
135
+ server_command: params.server_command,
136
+ server_port: params.server_port,
137
+ server_path: params.server_path,
138
+ use_auth: params.use_auth,
139
+ color_scheme: params.color_scheme,
140
+ wait_for_selector: params.wait_for_selector,
141
+ ship_mode: params.ship_mode || (params.ship_after_verify ? "ship" : void 0),
142
+ integration_context: openClawIntegrationContext(params)
143
+ });
144
+ }
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ openClawIntegrationContext,
148
+ parseOpenClawAssertions,
149
+ toRiddleProofRunParams
150
+ });