@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 +21 -0
- package/README.md +43 -0
- package/dist/chunk-2ZQNXVQC.js +81 -0
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-EPVZKWUS.js +107 -0
- package/dist/index.cjs +219 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +35 -0
- package/dist/openclaw.cjs +150 -0
- package/dist/openclaw.d.cts +40 -0
- package/dist/openclaw.d.ts +40 -0
- package/dist/openclaw.js +70 -0
- package/dist/result.cjs +112 -0
- package/dist/result.d.cts +25 -0
- package/dist/result.d.ts +25 -0
- package/dist/result.js +20 -0
- package/dist/state.cjs +143 -0
- package/dist/state.d.cts +23 -0
- package/dist/state.d.ts +23 -0
- package/dist/state.js +17 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +179 -0
- package/dist/types.d.ts +179 -0
- package/dist/types.js +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IntegrationContext, JsonValue, RiddleProofRunParams } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
interface OpenClawProofedChangeParams {
|
|
4
|
+
repo?: string;
|
|
5
|
+
branch?: string;
|
|
6
|
+
change_request?: string;
|
|
7
|
+
commit_message?: string;
|
|
8
|
+
prod_url?: string;
|
|
9
|
+
capture_script?: string;
|
|
10
|
+
success_criteria?: string;
|
|
11
|
+
assertions_json?: string;
|
|
12
|
+
verification_mode?: string;
|
|
13
|
+
reference?: "prod" | "before" | "both";
|
|
14
|
+
base_branch?: string;
|
|
15
|
+
before_ref?: string;
|
|
16
|
+
allow_static_preview_fallback?: boolean;
|
|
17
|
+
context?: string;
|
|
18
|
+
reviewer?: string;
|
|
19
|
+
mode?: string;
|
|
20
|
+
build_command?: string;
|
|
21
|
+
build_output?: string;
|
|
22
|
+
server_image?: string;
|
|
23
|
+
server_command?: string;
|
|
24
|
+
server_port?: number;
|
|
25
|
+
server_path?: string;
|
|
26
|
+
use_auth?: boolean;
|
|
27
|
+
color_scheme?: "dark" | "light" | (string & {});
|
|
28
|
+
wait_for_selector?: string;
|
|
29
|
+
ship_after_verify?: boolean;
|
|
30
|
+
ship_mode?: "none" | "ship";
|
|
31
|
+
discord_channel?: string;
|
|
32
|
+
discord_thread_id?: string;
|
|
33
|
+
discord_message_id?: string;
|
|
34
|
+
discord_source_url?: string;
|
|
35
|
+
}
|
|
36
|
+
declare function parseOpenClawAssertions(value: unknown): JsonValue | undefined;
|
|
37
|
+
declare function openClawIntegrationContext(params: OpenClawProofedChangeParams): IntegrationContext;
|
|
38
|
+
declare function toRiddleProofRunParams(params: OpenClawProofedChangeParams): RiddleProofRunParams;
|
|
39
|
+
|
|
40
|
+
export { type OpenClawProofedChangeParams, openClawIntegrationContext, parseOpenClawAssertions, toRiddleProofRunParams };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IntegrationContext, JsonValue, RiddleProofRunParams } from './types.js';
|
|
2
|
+
|
|
3
|
+
interface OpenClawProofedChangeParams {
|
|
4
|
+
repo?: string;
|
|
5
|
+
branch?: string;
|
|
6
|
+
change_request?: string;
|
|
7
|
+
commit_message?: string;
|
|
8
|
+
prod_url?: string;
|
|
9
|
+
capture_script?: string;
|
|
10
|
+
success_criteria?: string;
|
|
11
|
+
assertions_json?: string;
|
|
12
|
+
verification_mode?: string;
|
|
13
|
+
reference?: "prod" | "before" | "both";
|
|
14
|
+
base_branch?: string;
|
|
15
|
+
before_ref?: string;
|
|
16
|
+
allow_static_preview_fallback?: boolean;
|
|
17
|
+
context?: string;
|
|
18
|
+
reviewer?: string;
|
|
19
|
+
mode?: string;
|
|
20
|
+
build_command?: string;
|
|
21
|
+
build_output?: string;
|
|
22
|
+
server_image?: string;
|
|
23
|
+
server_command?: string;
|
|
24
|
+
server_port?: number;
|
|
25
|
+
server_path?: string;
|
|
26
|
+
use_auth?: boolean;
|
|
27
|
+
color_scheme?: "dark" | "light" | (string & {});
|
|
28
|
+
wait_for_selector?: string;
|
|
29
|
+
ship_after_verify?: boolean;
|
|
30
|
+
ship_mode?: "none" | "ship";
|
|
31
|
+
discord_channel?: string;
|
|
32
|
+
discord_thread_id?: string;
|
|
33
|
+
discord_message_id?: string;
|
|
34
|
+
discord_source_url?: string;
|
|
35
|
+
}
|
|
36
|
+
declare function parseOpenClawAssertions(value: unknown): JsonValue | undefined;
|
|
37
|
+
declare function openClawIntegrationContext(params: OpenClawProofedChangeParams): IntegrationContext;
|
|
38
|
+
declare function toRiddleProofRunParams(params: OpenClawProofedChangeParams): RiddleProofRunParams;
|
|
39
|
+
|
|
40
|
+
export { type OpenClawProofedChangeParams, openClawIntegrationContext, parseOpenClawAssertions, toRiddleProofRunParams };
|
package/dist/openclaw.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeIntegrationContext,
|
|
3
|
+
normalizeRunParams
|
|
4
|
+
} from "./chunk-EPVZKWUS.js";
|
|
5
|
+
import {
|
|
6
|
+
compactRecord
|
|
7
|
+
} from "./chunk-2ZQNXVQC.js";
|
|
8
|
+
|
|
9
|
+
// src/openclaw.ts
|
|
10
|
+
function parseOpenClawAssertions(value) {
|
|
11
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
12
|
+
if (typeof value !== "string") return value;
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
if (!trimmed) return void 0;
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(trimmed);
|
|
17
|
+
} catch {
|
|
18
|
+
return trimmed;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function openClawIntegrationContext(params) {
|
|
22
|
+
const hasDiscordContext = Boolean(params.discord_channel || params.discord_thread_id || params.discord_message_id || params.discord_source_url);
|
|
23
|
+
return normalizeIntegrationContext({
|
|
24
|
+
source: hasDiscordContext ? "discord" : "openclaw",
|
|
25
|
+
channel_id: params.discord_channel,
|
|
26
|
+
thread_id: params.discord_thread_id,
|
|
27
|
+
message_id: params.discord_message_id,
|
|
28
|
+
source_url: params.discord_source_url,
|
|
29
|
+
metadata: compactRecord({
|
|
30
|
+
wrapper: "openclaw",
|
|
31
|
+
tool: "proofed_change_run"
|
|
32
|
+
})
|
|
33
|
+
}, "openclaw");
|
|
34
|
+
}
|
|
35
|
+
function toRiddleProofRunParams(params) {
|
|
36
|
+
return normalizeRunParams({
|
|
37
|
+
repo: params.repo,
|
|
38
|
+
branch: params.branch,
|
|
39
|
+
change_request: params.change_request,
|
|
40
|
+
commit_message: params.commit_message,
|
|
41
|
+
prod_url: params.prod_url,
|
|
42
|
+
capture_script: params.capture_script,
|
|
43
|
+
success_criteria: params.success_criteria,
|
|
44
|
+
assertions: parseOpenClawAssertions(params.assertions_json),
|
|
45
|
+
verification_mode: params.verification_mode,
|
|
46
|
+
reference: params.reference,
|
|
47
|
+
base_branch: params.base_branch,
|
|
48
|
+
before_ref: params.before_ref,
|
|
49
|
+
allow_static_preview_fallback: params.allow_static_preview_fallback,
|
|
50
|
+
context: params.context,
|
|
51
|
+
reviewer: params.reviewer,
|
|
52
|
+
mode: params.mode,
|
|
53
|
+
build_command: params.build_command,
|
|
54
|
+
build_output: params.build_output,
|
|
55
|
+
server_image: params.server_image,
|
|
56
|
+
server_command: params.server_command,
|
|
57
|
+
server_port: params.server_port,
|
|
58
|
+
server_path: params.server_path,
|
|
59
|
+
use_auth: params.use_auth,
|
|
60
|
+
color_scheme: params.color_scheme,
|
|
61
|
+
wait_for_selector: params.wait_for_selector,
|
|
62
|
+
ship_mode: params.ship_mode || (params.ship_after_verify ? "ship" : void 0),
|
|
63
|
+
integration_context: openClawIntegrationContext(params)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
openClawIntegrationContext,
|
|
68
|
+
parseOpenClawAssertions,
|
|
69
|
+
toRiddleProofRunParams
|
|
70
|
+
};
|
package/dist/result.cjs
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
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/result.ts
|
|
21
|
+
var result_exports = {};
|
|
22
|
+
__export(result_exports, {
|
|
23
|
+
applyTerminalMetadata: () => applyTerminalMetadata,
|
|
24
|
+
compactRecord: () => compactRecord,
|
|
25
|
+
createRunResult: () => createRunResult,
|
|
26
|
+
isSuccessfulStatus: () => isSuccessfulStatus,
|
|
27
|
+
isTerminalStatus: () => isTerminalStatus,
|
|
28
|
+
nonEmptyString: () => nonEmptyString,
|
|
29
|
+
normalizeTerminalMetadata: () => normalizeTerminalMetadata,
|
|
30
|
+
recordValue: () => recordValue
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(result_exports);
|
|
33
|
+
function isTerminalStatus(status) {
|
|
34
|
+
return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
|
|
35
|
+
}
|
|
36
|
+
function isSuccessfulStatus(status) {
|
|
37
|
+
return status !== "blocked" && status !== "failed";
|
|
38
|
+
}
|
|
39
|
+
function compactRecord(input) {
|
|
40
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
|
|
41
|
+
}
|
|
42
|
+
function nonEmptyString(value) {
|
|
43
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
44
|
+
}
|
|
45
|
+
function recordValue(value) {
|
|
46
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
47
|
+
}
|
|
48
|
+
function normalizeTerminalMetadata(input) {
|
|
49
|
+
const riddleState = recordValue(input.riddleState) || {};
|
|
50
|
+
const result = recordValue(input.engineResult) || {};
|
|
51
|
+
const contract = recordValue(result.checkpointContract) || {};
|
|
52
|
+
const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
|
|
53
|
+
const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
|
|
54
|
+
const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
|
|
55
|
+
return compactRecord({
|
|
56
|
+
pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
|
|
57
|
+
marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
|
|
58
|
+
notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
|
|
59
|
+
proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
|
|
60
|
+
merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
|
|
61
|
+
finalized: typeof finalized === "boolean" ? finalized : void 0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function applyTerminalMetadata(state, metadata) {
|
|
65
|
+
const prUrl = nonEmptyString(metadata.pr_url);
|
|
66
|
+
if (prUrl) state.pr_url = prUrl;
|
|
67
|
+
if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
|
|
68
|
+
const notification = recordValue(metadata.notification);
|
|
69
|
+
if (notification) state.notification = notification;
|
|
70
|
+
const proofDecision = nonEmptyString(metadata.proof_decision);
|
|
71
|
+
if (proofDecision) state.proof_decision = proofDecision;
|
|
72
|
+
const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
|
|
73
|
+
if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
|
|
74
|
+
if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
|
|
75
|
+
return state;
|
|
76
|
+
}
|
|
77
|
+
function createRunResult(input) {
|
|
78
|
+
const status = input.status || input.state.status;
|
|
79
|
+
const ok = isSuccessfulStatus(status);
|
|
80
|
+
const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
|
|
81
|
+
state.status = status;
|
|
82
|
+
state.ok = ok;
|
|
83
|
+
return compactRecord({
|
|
84
|
+
ok,
|
|
85
|
+
status,
|
|
86
|
+
state_path: input.state_path ?? state.state_path ?? null,
|
|
87
|
+
iterations: state.iterations,
|
|
88
|
+
last_checkpoint: state.last_checkpoint ?? null,
|
|
89
|
+
last_summary: input.last_summary ?? null,
|
|
90
|
+
event_count: state.events.length,
|
|
91
|
+
pr_url: state.pr_url,
|
|
92
|
+
marked_ready: state.marked_ready,
|
|
93
|
+
notification: state.notification,
|
|
94
|
+
proof_decision: state.proof_decision,
|
|
95
|
+
merge_recommendation: state.merge_recommendation,
|
|
96
|
+
finalized: state.finalized,
|
|
97
|
+
blocker: state.blocker,
|
|
98
|
+
evidence_bundle: input.evidence_bundle,
|
|
99
|
+
raw: input.raw
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
applyTerminalMetadata,
|
|
105
|
+
compactRecord,
|
|
106
|
+
createRunResult,
|
|
107
|
+
isSuccessfulStatus,
|
|
108
|
+
isTerminalStatus,
|
|
109
|
+
nonEmptyString,
|
|
110
|
+
normalizeTerminalMetadata,
|
|
111
|
+
recordValue
|
|
112
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RiddleProofRunState, RiddleProofTerminalMetadata, RiddleProofStatus, RiddleProofEvidenceBundle, RiddleProofRunResult } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
declare function isTerminalStatus(status: RiddleProofStatus): boolean;
|
|
4
|
+
declare function isSuccessfulStatus(status: RiddleProofStatus): boolean;
|
|
5
|
+
declare function compactRecord<T extends Record<string, unknown>>(input: T): Partial<T>;
|
|
6
|
+
declare function nonEmptyString(value: unknown): string | undefined;
|
|
7
|
+
declare function recordValue(value: unknown): Record<string, unknown> | undefined;
|
|
8
|
+
interface TerminalMetadataInput {
|
|
9
|
+
riddleState?: Record<string, unknown> | null;
|
|
10
|
+
engineResult?: Record<string, unknown> | null;
|
|
11
|
+
checkpointDetails?: Record<string, unknown> | null;
|
|
12
|
+
}
|
|
13
|
+
declare function normalizeTerminalMetadata(input: TerminalMetadataInput): RiddleProofTerminalMetadata;
|
|
14
|
+
declare function applyTerminalMetadata<T extends RiddleProofRunState>(state: T, metadata: RiddleProofTerminalMetadata): T;
|
|
15
|
+
declare function createRunResult(input: {
|
|
16
|
+
state: RiddleProofRunState;
|
|
17
|
+
status?: RiddleProofStatus;
|
|
18
|
+
state_path?: string | null;
|
|
19
|
+
last_summary?: string | null;
|
|
20
|
+
metadata?: RiddleProofTerminalMetadata;
|
|
21
|
+
evidence_bundle?: RiddleProofEvidenceBundle;
|
|
22
|
+
raw?: Record<string, unknown>;
|
|
23
|
+
}): RiddleProofRunResult;
|
|
24
|
+
|
|
25
|
+
export { type TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue };
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RiddleProofRunState, RiddleProofTerminalMetadata, RiddleProofStatus, RiddleProofEvidenceBundle, RiddleProofRunResult } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare function isTerminalStatus(status: RiddleProofStatus): boolean;
|
|
4
|
+
declare function isSuccessfulStatus(status: RiddleProofStatus): boolean;
|
|
5
|
+
declare function compactRecord<T extends Record<string, unknown>>(input: T): Partial<T>;
|
|
6
|
+
declare function nonEmptyString(value: unknown): string | undefined;
|
|
7
|
+
declare function recordValue(value: unknown): Record<string, unknown> | undefined;
|
|
8
|
+
interface TerminalMetadataInput {
|
|
9
|
+
riddleState?: Record<string, unknown> | null;
|
|
10
|
+
engineResult?: Record<string, unknown> | null;
|
|
11
|
+
checkpointDetails?: Record<string, unknown> | null;
|
|
12
|
+
}
|
|
13
|
+
declare function normalizeTerminalMetadata(input: TerminalMetadataInput): RiddleProofTerminalMetadata;
|
|
14
|
+
declare function applyTerminalMetadata<T extends RiddleProofRunState>(state: T, metadata: RiddleProofTerminalMetadata): T;
|
|
15
|
+
declare function createRunResult(input: {
|
|
16
|
+
state: RiddleProofRunState;
|
|
17
|
+
status?: RiddleProofStatus;
|
|
18
|
+
state_path?: string | null;
|
|
19
|
+
last_summary?: string | null;
|
|
20
|
+
metadata?: RiddleProofTerminalMetadata;
|
|
21
|
+
evidence_bundle?: RiddleProofEvidenceBundle;
|
|
22
|
+
raw?: Record<string, unknown>;
|
|
23
|
+
}): RiddleProofRunResult;
|
|
24
|
+
|
|
25
|
+
export { type TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue };
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyTerminalMetadata,
|
|
3
|
+
compactRecord,
|
|
4
|
+
createRunResult,
|
|
5
|
+
isSuccessfulStatus,
|
|
6
|
+
isTerminalStatus,
|
|
7
|
+
nonEmptyString,
|
|
8
|
+
normalizeTerminalMetadata,
|
|
9
|
+
recordValue
|
|
10
|
+
} from "./chunk-2ZQNXVQC.js";
|
|
11
|
+
export {
|
|
12
|
+
applyTerminalMetadata,
|
|
13
|
+
compactRecord,
|
|
14
|
+
createRunResult,
|
|
15
|
+
isSuccessfulStatus,
|
|
16
|
+
isTerminalStatus,
|
|
17
|
+
nonEmptyString,
|
|
18
|
+
normalizeTerminalMetadata,
|
|
19
|
+
recordValue
|
|
20
|
+
};
|
package/dist/state.cjs
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
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/state.ts
|
|
21
|
+
var state_exports = {};
|
|
22
|
+
__export(state_exports, {
|
|
23
|
+
RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
24
|
+
appendRunEvent: () => appendRunEvent,
|
|
25
|
+
createRunState: () => createRunState,
|
|
26
|
+
normalizeIntegrationContext: () => normalizeIntegrationContext,
|
|
27
|
+
normalizeRunParams: () => normalizeRunParams,
|
|
28
|
+
setRunStatus: () => setRunStatus
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(state_exports);
|
|
31
|
+
|
|
32
|
+
// src/result.ts
|
|
33
|
+
function compactRecord(input) {
|
|
34
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
|
|
35
|
+
}
|
|
36
|
+
function nonEmptyString(value) {
|
|
37
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
38
|
+
}
|
|
39
|
+
function recordValue(value) {
|
|
40
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/state.ts
|
|
44
|
+
var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
|
|
45
|
+
function timestamp() {
|
|
46
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
47
|
+
}
|
|
48
|
+
function normalizeIntegrationContext(input, fallbackSource) {
|
|
49
|
+
const value = recordValue(input);
|
|
50
|
+
if (!value) {
|
|
51
|
+
return fallbackSource ? { source: fallbackSource } : void 0;
|
|
52
|
+
}
|
|
53
|
+
const metadata = recordValue(value.metadata);
|
|
54
|
+
return compactRecord({
|
|
55
|
+
source: nonEmptyString(value.source) || fallbackSource,
|
|
56
|
+
channel_id: nonEmptyString(value.channel_id),
|
|
57
|
+
thread_id: nonEmptyString(value.thread_id),
|
|
58
|
+
message_id: nonEmptyString(value.message_id),
|
|
59
|
+
source_url: nonEmptyString(value.source_url),
|
|
60
|
+
metadata: metadata && Object.keys(metadata).length ? metadata : void 0
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function normalizeRunParams(input) {
|
|
64
|
+
return compactRecord({
|
|
65
|
+
repo: input.repo,
|
|
66
|
+
branch: input.branch,
|
|
67
|
+
change_request: input.change_request,
|
|
68
|
+
commit_message: input.commit_message,
|
|
69
|
+
prod_url: input.prod_url,
|
|
70
|
+
capture_script: input.capture_script,
|
|
71
|
+
success_criteria: input.success_criteria,
|
|
72
|
+
assertions: input.assertions,
|
|
73
|
+
verification_mode: input.verification_mode,
|
|
74
|
+
reference: input.reference,
|
|
75
|
+
base_branch: input.base_branch,
|
|
76
|
+
before_ref: input.before_ref,
|
|
77
|
+
allow_static_preview_fallback: input.allow_static_preview_fallback,
|
|
78
|
+
context: input.context,
|
|
79
|
+
reviewer: input.reviewer,
|
|
80
|
+
mode: input.mode,
|
|
81
|
+
build_command: input.build_command,
|
|
82
|
+
build_output: input.build_output,
|
|
83
|
+
server_image: input.server_image,
|
|
84
|
+
server_command: input.server_command,
|
|
85
|
+
server_port: input.server_port,
|
|
86
|
+
server_path: input.server_path,
|
|
87
|
+
use_auth: input.use_auth,
|
|
88
|
+
color_scheme: input.color_scheme,
|
|
89
|
+
wait_for_selector: input.wait_for_selector,
|
|
90
|
+
ship_mode: input.ship_mode,
|
|
91
|
+
integration_context: normalizeIntegrationContext(input.integration_context)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function createRunState(input) {
|
|
95
|
+
const createdAt = input.created_at || timestamp();
|
|
96
|
+
return compactRecord({
|
|
97
|
+
version: RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
98
|
+
state_path: input.state_path,
|
|
99
|
+
status: input.status || "running",
|
|
100
|
+
created_at: createdAt,
|
|
101
|
+
updated_at: input.updated_at || createdAt,
|
|
102
|
+
request: normalizeRunParams(input.request),
|
|
103
|
+
iterations: input.iterations ?? 0,
|
|
104
|
+
last_checkpoint: input.last_checkpoint ?? null,
|
|
105
|
+
events: input.events ? [...input.events] : []
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function appendRunEvent(state, input) {
|
|
109
|
+
const event = {
|
|
110
|
+
ts: input.ts || timestamp(),
|
|
111
|
+
kind: input.kind,
|
|
112
|
+
checkpoint: input.checkpoint,
|
|
113
|
+
stage: input.stage,
|
|
114
|
+
summary: input.summary,
|
|
115
|
+
details: input.details
|
|
116
|
+
};
|
|
117
|
+
state.events.push(compactRecord({
|
|
118
|
+
ts: event.ts,
|
|
119
|
+
kind: event.kind,
|
|
120
|
+
checkpoint: event.checkpoint,
|
|
121
|
+
stage: event.stage,
|
|
122
|
+
summary: event.summary,
|
|
123
|
+
details: event.details
|
|
124
|
+
}));
|
|
125
|
+
if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
|
|
126
|
+
state.updated_at = event.ts;
|
|
127
|
+
return state;
|
|
128
|
+
}
|
|
129
|
+
function setRunStatus(state, status, at = timestamp()) {
|
|
130
|
+
state.status = status;
|
|
131
|
+
state.ok = status !== "blocked" && status !== "failed";
|
|
132
|
+
state.updated_at = at;
|
|
133
|
+
return state;
|
|
134
|
+
}
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
138
|
+
appendRunEvent,
|
|
139
|
+
createRunState,
|
|
140
|
+
normalizeIntegrationContext,
|
|
141
|
+
normalizeRunParams,
|
|
142
|
+
setRunStatus
|
|
143
|
+
});
|
package/dist/state.d.cts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RiddleProofRunParams, RiddleProofStatus, RiddleProofEvent, RiddleProofRunState, IntegrationContext } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
declare const RIDDLE_PROOF_RUN_STATE_VERSION: "riddle-proof.run-state.v1";
|
|
4
|
+
interface CreateRunStateInput {
|
|
5
|
+
request: RiddleProofRunParams;
|
|
6
|
+
status?: RiddleProofStatus;
|
|
7
|
+
state_path?: string;
|
|
8
|
+
created_at?: string;
|
|
9
|
+
updated_at?: string;
|
|
10
|
+
iterations?: number;
|
|
11
|
+
last_checkpoint?: string | null;
|
|
12
|
+
events?: RiddleProofEvent[];
|
|
13
|
+
}
|
|
14
|
+
type RunEventInput = Omit<RiddleProofEvent, "ts"> & {
|
|
15
|
+
ts?: string;
|
|
16
|
+
};
|
|
17
|
+
declare function normalizeIntegrationContext(input?: Partial<IntegrationContext> | Record<string, unknown> | null, fallbackSource?: IntegrationContext["source"]): IntegrationContext | undefined;
|
|
18
|
+
declare function normalizeRunParams(input: RiddleProofRunParams): RiddleProofRunParams;
|
|
19
|
+
declare function createRunState(input: CreateRunStateInput): RiddleProofRunState;
|
|
20
|
+
declare function appendRunEvent<T extends RiddleProofRunState>(state: T, input: RunEventInput): T;
|
|
21
|
+
declare function setRunStatus<T extends RiddleProofRunState>(state: T, status: RiddleProofStatus, at?: string): T;
|
|
22
|
+
|
|
23
|
+
export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RiddleProofRunParams, RiddleProofStatus, RiddleProofEvent, RiddleProofRunState, IntegrationContext } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare const RIDDLE_PROOF_RUN_STATE_VERSION: "riddle-proof.run-state.v1";
|
|
4
|
+
interface CreateRunStateInput {
|
|
5
|
+
request: RiddleProofRunParams;
|
|
6
|
+
status?: RiddleProofStatus;
|
|
7
|
+
state_path?: string;
|
|
8
|
+
created_at?: string;
|
|
9
|
+
updated_at?: string;
|
|
10
|
+
iterations?: number;
|
|
11
|
+
last_checkpoint?: string | null;
|
|
12
|
+
events?: RiddleProofEvent[];
|
|
13
|
+
}
|
|
14
|
+
type RunEventInput = Omit<RiddleProofEvent, "ts"> & {
|
|
15
|
+
ts?: string;
|
|
16
|
+
};
|
|
17
|
+
declare function normalizeIntegrationContext(input?: Partial<IntegrationContext> | Record<string, unknown> | null, fallbackSource?: IntegrationContext["source"]): IntegrationContext | undefined;
|
|
18
|
+
declare function normalizeRunParams(input: RiddleProofRunParams): RiddleProofRunParams;
|
|
19
|
+
declare function createRunState(input: CreateRunStateInput): RiddleProofRunState;
|
|
20
|
+
declare function appendRunEvent<T extends RiddleProofRunState>(state: T, input: RunEventInput): T;
|
|
21
|
+
declare function setRunStatus<T extends RiddleProofRunState>(state: T, status: RiddleProofStatus, at?: string): T;
|
|
22
|
+
|
|
23
|
+
export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 "./chunk-2ZQNXVQC.js";
|
|
10
|
+
export {
|
|
11
|
+
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
12
|
+
appendRunEvent,
|
|
13
|
+
createRunState,
|
|
14
|
+
normalizeIntegrationContext,
|
|
15
|
+
normalizeRunParams,
|
|
16
|
+
setRunStatus
|
|
17
|
+
};
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|