@riddledc/riddle-proof 0.7.49 → 0.7.50
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/{chunk-Q3X6UTPP.js → chunk-5FHHNCX4.js} +91 -1
- package/dist/cli.cjs +91 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +91 -1
- package/dist/index.js +1 -1
- package/dist/profile.cjs +91 -1
- package/dist/profile.d.cts +4 -1
- package/dist/profile.d.ts +4 -1
- package/dist/profile.js +1 -1
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/package.json +1 -1
|
@@ -40,7 +40,8 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
40
40
|
"clear_storage",
|
|
41
41
|
"wait",
|
|
42
42
|
"wait_for_selector",
|
|
43
|
-
"wait_for_text"
|
|
43
|
+
"wait_for_text",
|
|
44
|
+
"window_call"
|
|
44
45
|
];
|
|
45
46
|
var DEFAULT_VIEWPORTS = [
|
|
46
47
|
{ name: "desktop", width: 1280, height: 800 }
|
|
@@ -63,6 +64,12 @@ function stringFromOwn(input, ...keys) {
|
|
|
63
64
|
}
|
|
64
65
|
return void 0;
|
|
65
66
|
}
|
|
67
|
+
function valueFromOwn(input, ...keys) {
|
|
68
|
+
for (const key of keys) {
|
|
69
|
+
if (hasOwn(input, key)) return input[key];
|
|
70
|
+
}
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
66
73
|
function numberValue(value) {
|
|
67
74
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
68
75
|
}
|
|
@@ -204,6 +211,14 @@ function normalizeSetupActionStorage(value, index) {
|
|
|
204
211
|
if (normalized === "both" || normalized === "all") return "both";
|
|
205
212
|
throw new Error(`target.setup_actions[${index}].storage ${String(value)} is not supported. Supported storage values: local, session, both.`);
|
|
206
213
|
}
|
|
214
|
+
function normalizeSetupActionArgs(input, index) {
|
|
215
|
+
const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
|
|
216
|
+
if (argsInput === void 0) return void 0;
|
|
217
|
+
if (!Array.isArray(argsInput)) {
|
|
218
|
+
throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
|
|
219
|
+
}
|
|
220
|
+
return argsInput.map(toJsonValue);
|
|
221
|
+
}
|
|
207
222
|
function normalizeSetupAction(input, index) {
|
|
208
223
|
if (!isRecord(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
209
224
|
const type = normalizeSetupActionType(stringValue(input.type), index);
|
|
@@ -233,12 +248,21 @@ function normalizeSetupAction(input, index) {
|
|
|
233
248
|
if ((type === "local_storage" || type === "session_storage") && value === void 0 && !hasJsonValue) {
|
|
234
249
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
235
250
|
}
|
|
251
|
+
const path = stringFromOwn(input, "path", "function_path", "functionPath", "window_path", "windowPath");
|
|
252
|
+
if (type === "window_call" && !path) {
|
|
253
|
+
throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
|
|
254
|
+
}
|
|
255
|
+
const args = type === "window_call" ? normalizeSetupActionArgs(input, index) : void 0;
|
|
256
|
+
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
236
257
|
return {
|
|
237
258
|
type,
|
|
238
259
|
selector,
|
|
239
260
|
key,
|
|
240
261
|
value,
|
|
241
262
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
263
|
+
path,
|
|
264
|
+
args,
|
|
265
|
+
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
242
266
|
text: stringValue(input.text),
|
|
243
267
|
pattern: stringValue(input.pattern),
|
|
244
268
|
flags: stringValue(input.flags),
|
|
@@ -1939,6 +1963,19 @@ function setupActionValue(action) {
|
|
|
1939
1963
|
if (setupHasOwn(action, "value")) return String(action.value ?? "");
|
|
1940
1964
|
return "";
|
|
1941
1965
|
}
|
|
1966
|
+
function setupJsonValue(value) {
|
|
1967
|
+
if (value === null || value === undefined) return null;
|
|
1968
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
1969
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
1970
|
+
if (Array.isArray(value)) return value.map(setupJsonValue);
|
|
1971
|
+
if (typeof value === "object") {
|
|
1972
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, setupJsonValue(child)]));
|
|
1973
|
+
}
|
|
1974
|
+
return String(value);
|
|
1975
|
+
}
|
|
1976
|
+
function setupValuesEqual(left, right) {
|
|
1977
|
+
return JSON.stringify(setupJsonValue(left)) === JSON.stringify(setupJsonValue(right));
|
|
1978
|
+
}
|
|
1942
1979
|
async function setupLocatorText(locator, index) {
|
|
1943
1980
|
return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
|
|
1944
1981
|
}
|
|
@@ -2134,6 +2171,59 @@ async function executeSetupAction(action, ordinal) {
|
|
|
2134
2171
|
}
|
|
2135
2172
|
return { ...base, ok: true, storage, reload: action.reload === true };
|
|
2136
2173
|
}
|
|
2174
|
+
if (type === "window_call") {
|
|
2175
|
+
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
2176
|
+
const args = Array.isArray(action.args) ? action.args : [];
|
|
2177
|
+
if (!path) return { ...base, path, reason: "missing_path" };
|
|
2178
|
+
const result = await page.evaluate(async ({ path, args }) => {
|
|
2179
|
+
const toJsonValue = (value) => {
|
|
2180
|
+
if (value === null || value === undefined) return null;
|
|
2181
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
2182
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
2183
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
2184
|
+
if (typeof value === "object") {
|
|
2185
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
|
|
2186
|
+
}
|
|
2187
|
+
return String(value);
|
|
2188
|
+
};
|
|
2189
|
+
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
2190
|
+
let parent = window;
|
|
2191
|
+
let current = window;
|
|
2192
|
+
for (const part of pathParts) {
|
|
2193
|
+
parent = current;
|
|
2194
|
+
current = current?.[part];
|
|
2195
|
+
}
|
|
2196
|
+
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
2197
|
+
try {
|
|
2198
|
+
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
2199
|
+
return { ok: true, returned: toJsonValue(returned) };
|
|
2200
|
+
} catch (error) {
|
|
2201
|
+
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
2202
|
+
}
|
|
2203
|
+
}, { path, args });
|
|
2204
|
+
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
2205
|
+
|| setupHasOwn(action, "expectReturn")
|
|
2206
|
+
|| setupHasOwn(action, "expected_return")
|
|
2207
|
+
|| setupHasOwn(action, "expectedReturn");
|
|
2208
|
+
const expected = setupHasOwn(action, "expect_return")
|
|
2209
|
+
? action.expect_return
|
|
2210
|
+
: setupHasOwn(action, "expectReturn")
|
|
2211
|
+
? action.expectReturn
|
|
2212
|
+
: setupHasOwn(action, "expected_return")
|
|
2213
|
+
? action.expected_return
|
|
2214
|
+
: action.expectedReturn;
|
|
2215
|
+
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
2216
|
+
return {
|
|
2217
|
+
...base,
|
|
2218
|
+
ok: Boolean(result.ok && expectationMet),
|
|
2219
|
+
path,
|
|
2220
|
+
arg_count: args.length,
|
|
2221
|
+
returned: setupJsonValue(result.returned),
|
|
2222
|
+
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
2223
|
+
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
2224
|
+
error: result.error || undefined,
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2137
2227
|
if (type === "click") {
|
|
2138
2228
|
const locator = page.locator(action.selector);
|
|
2139
2229
|
const count = await locator.count();
|
package/dist/cli.cjs
CHANGED
|
@@ -6913,7 +6913,8 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
6913
6913
|
"clear_storage",
|
|
6914
6914
|
"wait",
|
|
6915
6915
|
"wait_for_selector",
|
|
6916
|
-
"wait_for_text"
|
|
6916
|
+
"wait_for_text",
|
|
6917
|
+
"window_call"
|
|
6917
6918
|
];
|
|
6918
6919
|
var DEFAULT_VIEWPORTS = [
|
|
6919
6920
|
{ name: "desktop", width: 1280, height: 800 }
|
|
@@ -6936,6 +6937,12 @@ function stringFromOwn(input, ...keys) {
|
|
|
6936
6937
|
}
|
|
6937
6938
|
return void 0;
|
|
6938
6939
|
}
|
|
6940
|
+
function valueFromOwn(input, ...keys) {
|
|
6941
|
+
for (const key of keys) {
|
|
6942
|
+
if (hasOwn(input, key)) return input[key];
|
|
6943
|
+
}
|
|
6944
|
+
return void 0;
|
|
6945
|
+
}
|
|
6939
6946
|
function numberValue(value) {
|
|
6940
6947
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
6941
6948
|
}
|
|
@@ -7077,6 +7084,14 @@ function normalizeSetupActionStorage(value, index) {
|
|
|
7077
7084
|
if (normalized === "both" || normalized === "all") return "both";
|
|
7078
7085
|
throw new Error(`target.setup_actions[${index}].storage ${String(value)} is not supported. Supported storage values: local, session, both.`);
|
|
7079
7086
|
}
|
|
7087
|
+
function normalizeSetupActionArgs(input, index) {
|
|
7088
|
+
const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
|
|
7089
|
+
if (argsInput === void 0) return void 0;
|
|
7090
|
+
if (!Array.isArray(argsInput)) {
|
|
7091
|
+
throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
|
|
7092
|
+
}
|
|
7093
|
+
return argsInput.map(toJsonValue);
|
|
7094
|
+
}
|
|
7080
7095
|
function normalizeSetupAction(input, index) {
|
|
7081
7096
|
if (!isRecord(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
7082
7097
|
const type = normalizeSetupActionType(stringValue2(input.type), index);
|
|
@@ -7106,12 +7121,21 @@ function normalizeSetupAction(input, index) {
|
|
|
7106
7121
|
if ((type === "local_storage" || type === "session_storage") && value === void 0 && !hasJsonValue) {
|
|
7107
7122
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
7108
7123
|
}
|
|
7124
|
+
const path7 = stringFromOwn(input, "path", "function_path", "functionPath", "window_path", "windowPath");
|
|
7125
|
+
if (type === "window_call" && !path7) {
|
|
7126
|
+
throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
|
|
7127
|
+
}
|
|
7128
|
+
const args = type === "window_call" ? normalizeSetupActionArgs(input, index) : void 0;
|
|
7129
|
+
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
7109
7130
|
return {
|
|
7110
7131
|
type,
|
|
7111
7132
|
selector,
|
|
7112
7133
|
key,
|
|
7113
7134
|
value,
|
|
7114
7135
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
7136
|
+
path: path7,
|
|
7137
|
+
args,
|
|
7138
|
+
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
7115
7139
|
text: stringValue2(input.text),
|
|
7116
7140
|
pattern: stringValue2(input.pattern),
|
|
7117
7141
|
flags: stringValue2(input.flags),
|
|
@@ -8796,6 +8820,19 @@ function setupActionValue(action) {
|
|
|
8796
8820
|
if (setupHasOwn(action, "value")) return String(action.value ?? "");
|
|
8797
8821
|
return "";
|
|
8798
8822
|
}
|
|
8823
|
+
function setupJsonValue(value) {
|
|
8824
|
+
if (value === null || value === undefined) return null;
|
|
8825
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
8826
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
8827
|
+
if (Array.isArray(value)) return value.map(setupJsonValue);
|
|
8828
|
+
if (typeof value === "object") {
|
|
8829
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, setupJsonValue(child)]));
|
|
8830
|
+
}
|
|
8831
|
+
return String(value);
|
|
8832
|
+
}
|
|
8833
|
+
function setupValuesEqual(left, right) {
|
|
8834
|
+
return JSON.stringify(setupJsonValue(left)) === JSON.stringify(setupJsonValue(right));
|
|
8835
|
+
}
|
|
8799
8836
|
async function setupLocatorText(locator, index) {
|
|
8800
8837
|
return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
|
|
8801
8838
|
}
|
|
@@ -8991,6 +9028,59 @@ async function executeSetupAction(action, ordinal) {
|
|
|
8991
9028
|
}
|
|
8992
9029
|
return { ...base, ok: true, storage, reload: action.reload === true };
|
|
8993
9030
|
}
|
|
9031
|
+
if (type === "window_call") {
|
|
9032
|
+
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
9033
|
+
const args = Array.isArray(action.args) ? action.args : [];
|
|
9034
|
+
if (!path) return { ...base, path, reason: "missing_path" };
|
|
9035
|
+
const result = await page.evaluate(async ({ path, args }) => {
|
|
9036
|
+
const toJsonValue = (value) => {
|
|
9037
|
+
if (value === null || value === undefined) return null;
|
|
9038
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
9039
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
9040
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
9041
|
+
if (typeof value === "object") {
|
|
9042
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
|
|
9043
|
+
}
|
|
9044
|
+
return String(value);
|
|
9045
|
+
};
|
|
9046
|
+
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
9047
|
+
let parent = window;
|
|
9048
|
+
let current = window;
|
|
9049
|
+
for (const part of pathParts) {
|
|
9050
|
+
parent = current;
|
|
9051
|
+
current = current?.[part];
|
|
9052
|
+
}
|
|
9053
|
+
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
9054
|
+
try {
|
|
9055
|
+
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
9056
|
+
return { ok: true, returned: toJsonValue(returned) };
|
|
9057
|
+
} catch (error) {
|
|
9058
|
+
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
9059
|
+
}
|
|
9060
|
+
}, { path, args });
|
|
9061
|
+
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
9062
|
+
|| setupHasOwn(action, "expectReturn")
|
|
9063
|
+
|| setupHasOwn(action, "expected_return")
|
|
9064
|
+
|| setupHasOwn(action, "expectedReturn");
|
|
9065
|
+
const expected = setupHasOwn(action, "expect_return")
|
|
9066
|
+
? action.expect_return
|
|
9067
|
+
: setupHasOwn(action, "expectReturn")
|
|
9068
|
+
? action.expectReturn
|
|
9069
|
+
: setupHasOwn(action, "expected_return")
|
|
9070
|
+
? action.expected_return
|
|
9071
|
+
: action.expectedReturn;
|
|
9072
|
+
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
9073
|
+
return {
|
|
9074
|
+
...base,
|
|
9075
|
+
ok: Boolean(result.ok && expectationMet),
|
|
9076
|
+
path,
|
|
9077
|
+
arg_count: args.length,
|
|
9078
|
+
returned: setupJsonValue(result.returned),
|
|
9079
|
+
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
9080
|
+
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
9081
|
+
error: result.error || undefined,
|
|
9082
|
+
};
|
|
9083
|
+
}
|
|
8994
9084
|
if (type === "click") {
|
|
8995
9085
|
const locator = page.locator(action.selector);
|
|
8996
9086
|
const count = await locator.count();
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -8754,7 +8754,8 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
8754
8754
|
"clear_storage",
|
|
8755
8755
|
"wait",
|
|
8756
8756
|
"wait_for_selector",
|
|
8757
|
-
"wait_for_text"
|
|
8757
|
+
"wait_for_text",
|
|
8758
|
+
"window_call"
|
|
8758
8759
|
];
|
|
8759
8760
|
var DEFAULT_VIEWPORTS = [
|
|
8760
8761
|
{ name: "desktop", width: 1280, height: 800 }
|
|
@@ -8777,6 +8778,12 @@ function stringFromOwn(input, ...keys) {
|
|
|
8777
8778
|
}
|
|
8778
8779
|
return void 0;
|
|
8779
8780
|
}
|
|
8781
|
+
function valueFromOwn(input, ...keys) {
|
|
8782
|
+
for (const key of keys) {
|
|
8783
|
+
if (hasOwn(input, key)) return input[key];
|
|
8784
|
+
}
|
|
8785
|
+
return void 0;
|
|
8786
|
+
}
|
|
8780
8787
|
function numberValue3(value) {
|
|
8781
8788
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
8782
8789
|
}
|
|
@@ -8918,6 +8925,14 @@ function normalizeSetupActionStorage(value, index) {
|
|
|
8918
8925
|
if (normalized === "both" || normalized === "all") return "both";
|
|
8919
8926
|
throw new Error(`target.setup_actions[${index}].storage ${String(value)} is not supported. Supported storage values: local, session, both.`);
|
|
8920
8927
|
}
|
|
8928
|
+
function normalizeSetupActionArgs(input, index) {
|
|
8929
|
+
const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
|
|
8930
|
+
if (argsInput === void 0) return void 0;
|
|
8931
|
+
if (!Array.isArray(argsInput)) {
|
|
8932
|
+
throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
|
|
8933
|
+
}
|
|
8934
|
+
return argsInput.map(toJsonValue);
|
|
8935
|
+
}
|
|
8921
8936
|
function normalizeSetupAction(input, index) {
|
|
8922
8937
|
if (!isRecord2(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
8923
8938
|
const type = normalizeSetupActionType(stringValue5(input.type), index);
|
|
@@ -8947,12 +8962,21 @@ function normalizeSetupAction(input, index) {
|
|
|
8947
8962
|
if ((type === "local_storage" || type === "session_storage") && value === void 0 && !hasJsonValue) {
|
|
8948
8963
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
8949
8964
|
}
|
|
8965
|
+
const path6 = stringFromOwn(input, "path", "function_path", "functionPath", "window_path", "windowPath");
|
|
8966
|
+
if (type === "window_call" && !path6) {
|
|
8967
|
+
throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
|
|
8968
|
+
}
|
|
8969
|
+
const args = type === "window_call" ? normalizeSetupActionArgs(input, index) : void 0;
|
|
8970
|
+
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
8950
8971
|
return {
|
|
8951
8972
|
type,
|
|
8952
8973
|
selector,
|
|
8953
8974
|
key,
|
|
8954
8975
|
value,
|
|
8955
8976
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
8977
|
+
path: path6,
|
|
8978
|
+
args,
|
|
8979
|
+
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
8956
8980
|
text: stringValue5(input.text),
|
|
8957
8981
|
pattern: stringValue5(input.pattern),
|
|
8958
8982
|
flags: stringValue5(input.flags),
|
|
@@ -10653,6 +10677,19 @@ function setupActionValue(action) {
|
|
|
10653
10677
|
if (setupHasOwn(action, "value")) return String(action.value ?? "");
|
|
10654
10678
|
return "";
|
|
10655
10679
|
}
|
|
10680
|
+
function setupJsonValue(value) {
|
|
10681
|
+
if (value === null || value === undefined) return null;
|
|
10682
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
10683
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
10684
|
+
if (Array.isArray(value)) return value.map(setupJsonValue);
|
|
10685
|
+
if (typeof value === "object") {
|
|
10686
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, setupJsonValue(child)]));
|
|
10687
|
+
}
|
|
10688
|
+
return String(value);
|
|
10689
|
+
}
|
|
10690
|
+
function setupValuesEqual(left, right) {
|
|
10691
|
+
return JSON.stringify(setupJsonValue(left)) === JSON.stringify(setupJsonValue(right));
|
|
10692
|
+
}
|
|
10656
10693
|
async function setupLocatorText(locator, index) {
|
|
10657
10694
|
return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
|
|
10658
10695
|
}
|
|
@@ -10848,6 +10885,59 @@ async function executeSetupAction(action, ordinal) {
|
|
|
10848
10885
|
}
|
|
10849
10886
|
return { ...base, ok: true, storage, reload: action.reload === true };
|
|
10850
10887
|
}
|
|
10888
|
+
if (type === "window_call") {
|
|
10889
|
+
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
10890
|
+
const args = Array.isArray(action.args) ? action.args : [];
|
|
10891
|
+
if (!path) return { ...base, path, reason: "missing_path" };
|
|
10892
|
+
const result = await page.evaluate(async ({ path, args }) => {
|
|
10893
|
+
const toJsonValue = (value) => {
|
|
10894
|
+
if (value === null || value === undefined) return null;
|
|
10895
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
10896
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
10897
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
10898
|
+
if (typeof value === "object") {
|
|
10899
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
|
|
10900
|
+
}
|
|
10901
|
+
return String(value);
|
|
10902
|
+
};
|
|
10903
|
+
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
10904
|
+
let parent = window;
|
|
10905
|
+
let current = window;
|
|
10906
|
+
for (const part of pathParts) {
|
|
10907
|
+
parent = current;
|
|
10908
|
+
current = current?.[part];
|
|
10909
|
+
}
|
|
10910
|
+
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
10911
|
+
try {
|
|
10912
|
+
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
10913
|
+
return { ok: true, returned: toJsonValue(returned) };
|
|
10914
|
+
} catch (error) {
|
|
10915
|
+
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
10916
|
+
}
|
|
10917
|
+
}, { path, args });
|
|
10918
|
+
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
10919
|
+
|| setupHasOwn(action, "expectReturn")
|
|
10920
|
+
|| setupHasOwn(action, "expected_return")
|
|
10921
|
+
|| setupHasOwn(action, "expectedReturn");
|
|
10922
|
+
const expected = setupHasOwn(action, "expect_return")
|
|
10923
|
+
? action.expect_return
|
|
10924
|
+
: setupHasOwn(action, "expectReturn")
|
|
10925
|
+
? action.expectReturn
|
|
10926
|
+
: setupHasOwn(action, "expected_return")
|
|
10927
|
+
? action.expected_return
|
|
10928
|
+
: action.expectedReturn;
|
|
10929
|
+
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
10930
|
+
return {
|
|
10931
|
+
...base,
|
|
10932
|
+
ok: Boolean(result.ok && expectationMet),
|
|
10933
|
+
path,
|
|
10934
|
+
arg_count: args.length,
|
|
10935
|
+
returned: setupJsonValue(result.returned),
|
|
10936
|
+
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
10937
|
+
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
10938
|
+
error: result.error || undefined,
|
|
10939
|
+
};
|
|
10940
|
+
}
|
|
10851
10941
|
if (type === "click") {
|
|
10852
10942
|
const locator = page.locator(action.selector);
|
|
10853
10943
|
const count = await locator.count();
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
resolveRiddleProofProfileTimeoutSec,
|
|
59
59
|
slugifyRiddleProofProfileName,
|
|
60
60
|
summarizeRiddleProofProfileResult
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-5FHHNCX4.js";
|
|
62
62
|
import {
|
|
63
63
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
64
64
|
DEFAULT_RIDDLE_API_KEY_FILE,
|
package/dist/profile.cjs
CHANGED
|
@@ -83,7 +83,8 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
83
83
|
"clear_storage",
|
|
84
84
|
"wait",
|
|
85
85
|
"wait_for_selector",
|
|
86
|
-
"wait_for_text"
|
|
86
|
+
"wait_for_text",
|
|
87
|
+
"window_call"
|
|
87
88
|
];
|
|
88
89
|
var DEFAULT_VIEWPORTS = [
|
|
89
90
|
{ name: "desktop", width: 1280, height: 800 }
|
|
@@ -106,6 +107,12 @@ function stringFromOwn(input, ...keys) {
|
|
|
106
107
|
}
|
|
107
108
|
return void 0;
|
|
108
109
|
}
|
|
110
|
+
function valueFromOwn(input, ...keys) {
|
|
111
|
+
for (const key of keys) {
|
|
112
|
+
if (hasOwn(input, key)) return input[key];
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
109
116
|
function numberValue(value) {
|
|
110
117
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
111
118
|
}
|
|
@@ -247,6 +254,14 @@ function normalizeSetupActionStorage(value, index) {
|
|
|
247
254
|
if (normalized === "both" || normalized === "all") return "both";
|
|
248
255
|
throw new Error(`target.setup_actions[${index}].storage ${String(value)} is not supported. Supported storage values: local, session, both.`);
|
|
249
256
|
}
|
|
257
|
+
function normalizeSetupActionArgs(input, index) {
|
|
258
|
+
const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
|
|
259
|
+
if (argsInput === void 0) return void 0;
|
|
260
|
+
if (!Array.isArray(argsInput)) {
|
|
261
|
+
throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
|
|
262
|
+
}
|
|
263
|
+
return argsInput.map(toJsonValue);
|
|
264
|
+
}
|
|
250
265
|
function normalizeSetupAction(input, index) {
|
|
251
266
|
if (!isRecord(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
252
267
|
const type = normalizeSetupActionType(stringValue(input.type), index);
|
|
@@ -276,12 +291,21 @@ function normalizeSetupAction(input, index) {
|
|
|
276
291
|
if ((type === "local_storage" || type === "session_storage") && value === void 0 && !hasJsonValue) {
|
|
277
292
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
278
293
|
}
|
|
294
|
+
const path = stringFromOwn(input, "path", "function_path", "functionPath", "window_path", "windowPath");
|
|
295
|
+
if (type === "window_call" && !path) {
|
|
296
|
+
throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
|
|
297
|
+
}
|
|
298
|
+
const args = type === "window_call" ? normalizeSetupActionArgs(input, index) : void 0;
|
|
299
|
+
const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
|
|
279
300
|
return {
|
|
280
301
|
type,
|
|
281
302
|
selector,
|
|
282
303
|
key,
|
|
283
304
|
value,
|
|
284
305
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
306
|
+
path,
|
|
307
|
+
args,
|
|
308
|
+
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
285
309
|
text: stringValue(input.text),
|
|
286
310
|
pattern: stringValue(input.pattern),
|
|
287
311
|
flags: stringValue(input.flags),
|
|
@@ -1982,6 +2006,19 @@ function setupActionValue(action) {
|
|
|
1982
2006
|
if (setupHasOwn(action, "value")) return String(action.value ?? "");
|
|
1983
2007
|
return "";
|
|
1984
2008
|
}
|
|
2009
|
+
function setupJsonValue(value) {
|
|
2010
|
+
if (value === null || value === undefined) return null;
|
|
2011
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
2012
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
2013
|
+
if (Array.isArray(value)) return value.map(setupJsonValue);
|
|
2014
|
+
if (typeof value === "object") {
|
|
2015
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, setupJsonValue(child)]));
|
|
2016
|
+
}
|
|
2017
|
+
return String(value);
|
|
2018
|
+
}
|
|
2019
|
+
function setupValuesEqual(left, right) {
|
|
2020
|
+
return JSON.stringify(setupJsonValue(left)) === JSON.stringify(setupJsonValue(right));
|
|
2021
|
+
}
|
|
1985
2022
|
async function setupLocatorText(locator, index) {
|
|
1986
2023
|
return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
|
|
1987
2024
|
}
|
|
@@ -2177,6 +2214,59 @@ async function executeSetupAction(action, ordinal) {
|
|
|
2177
2214
|
}
|
|
2178
2215
|
return { ...base, ok: true, storage, reload: action.reload === true };
|
|
2179
2216
|
}
|
|
2217
|
+
if (type === "window_call") {
|
|
2218
|
+
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
2219
|
+
const args = Array.isArray(action.args) ? action.args : [];
|
|
2220
|
+
if (!path) return { ...base, path, reason: "missing_path" };
|
|
2221
|
+
const result = await page.evaluate(async ({ path, args }) => {
|
|
2222
|
+
const toJsonValue = (value) => {
|
|
2223
|
+
if (value === null || value === undefined) return null;
|
|
2224
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
2225
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
2226
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
2227
|
+
if (typeof value === "object") {
|
|
2228
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
|
|
2229
|
+
}
|
|
2230
|
+
return String(value);
|
|
2231
|
+
};
|
|
2232
|
+
const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
2233
|
+
let parent = window;
|
|
2234
|
+
let current = window;
|
|
2235
|
+
for (const part of pathParts) {
|
|
2236
|
+
parent = current;
|
|
2237
|
+
current = current?.[part];
|
|
2238
|
+
}
|
|
2239
|
+
if (typeof current !== "function") return { ok: false, reason: "missing_function" };
|
|
2240
|
+
try {
|
|
2241
|
+
const returned = await current.apply(parent, Array.isArray(args) ? args : []);
|
|
2242
|
+
return { ok: true, returned: toJsonValue(returned) };
|
|
2243
|
+
} catch (error) {
|
|
2244
|
+
return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
2245
|
+
}
|
|
2246
|
+
}, { path, args });
|
|
2247
|
+
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
2248
|
+
|| setupHasOwn(action, "expectReturn")
|
|
2249
|
+
|| setupHasOwn(action, "expected_return")
|
|
2250
|
+
|| setupHasOwn(action, "expectedReturn");
|
|
2251
|
+
const expected = setupHasOwn(action, "expect_return")
|
|
2252
|
+
? action.expect_return
|
|
2253
|
+
: setupHasOwn(action, "expectReturn")
|
|
2254
|
+
? action.expectReturn
|
|
2255
|
+
: setupHasOwn(action, "expected_return")
|
|
2256
|
+
? action.expected_return
|
|
2257
|
+
: action.expectedReturn;
|
|
2258
|
+
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
2259
|
+
return {
|
|
2260
|
+
...base,
|
|
2261
|
+
ok: Boolean(result.ok && expectationMet),
|
|
2262
|
+
path,
|
|
2263
|
+
arg_count: args.length,
|
|
2264
|
+
returned: setupJsonValue(result.returned),
|
|
2265
|
+
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
2266
|
+
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
2267
|
+
error: result.error || undefined,
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2180
2270
|
if (type === "click") {
|
|
2181
2271
|
const locator = page.locator(action.selector);
|
|
2182
2272
|
const count = await locator.count();
|
package/dist/profile.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "selector_text_order", "frame_text_visible", "frame_no_horizontal_overflow", "text_visible", "text_absent", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "local_storage", "session_storage", "clear_storage", "wait", "wait_for_selector", "wait_for_text"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "local_storage", "session_storage", "clear_storage", "wait", "wait_for_selector", "wait_for_text", "window_call"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|
|
@@ -23,6 +23,9 @@ interface RiddleProofProfileSetupAction {
|
|
|
23
23
|
key?: string;
|
|
24
24
|
value?: string;
|
|
25
25
|
value_json?: JsonValue;
|
|
26
|
+
path?: string;
|
|
27
|
+
args?: JsonValue[];
|
|
28
|
+
expect_return?: JsonValue;
|
|
26
29
|
text?: string;
|
|
27
30
|
pattern?: string;
|
|
28
31
|
flags?: string;
|
package/dist/profile.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "selector_text_order", "frame_text_visible", "frame_no_horizontal_overflow", "text_visible", "text_absent", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "local_storage", "session_storage", "clear_storage", "wait", "wait_for_selector", "wait_for_text"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "local_storage", "session_storage", "clear_storage", "wait", "wait_for_selector", "wait_for_text", "window_call"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|
|
@@ -23,6 +23,9 @@ interface RiddleProofProfileSetupAction {
|
|
|
23
23
|
key?: string;
|
|
24
24
|
value?: string;
|
|
25
25
|
value_json?: JsonValue;
|
|
26
|
+
path?: string;
|
|
27
|
+
args?: JsonValue[];
|
|
28
|
+
expect_return?: JsonValue;
|
|
26
29
|
text?: string;
|
|
27
30
|
pattern?: string;
|
|
28
31
|
flags?: string;
|
package/dist/profile.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolveRiddleProofProfileTimeoutSec,
|
|
20
20
|
slugifyRiddleProofProfileName,
|
|
21
21
|
summarizeRiddleProofProfileResult
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-5FHHNCX4.js";
|
|
23
23
|
export {
|
|
24
24
|
RIDDLE_PROOF_PROFILE_CHECK_TYPES,
|
|
25
25
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|
|
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
|
|
|
292
292
|
blocking?: boolean;
|
|
293
293
|
details?: Record<string, unknown>;
|
|
294
294
|
ok: boolean;
|
|
295
|
-
action: "
|
|
295
|
+
action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
|
|
296
296
|
state_path: string;
|
|
297
297
|
stage: any;
|
|
298
298
|
summary: string;
|
|
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
|
|
|
382
382
|
continueWithStage?: WorkflowStage | null;
|
|
383
383
|
blocking?: boolean;
|
|
384
384
|
details?: Record<string, unknown>;
|
|
385
|
-
action: "
|
|
385
|
+
action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
|
|
386
386
|
state_path: string;
|
|
387
387
|
stage: any;
|
|
388
388
|
checkpoint: string;
|
|
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
|
|
|
659
659
|
error?: undefined;
|
|
660
660
|
} | {
|
|
661
661
|
ok: boolean;
|
|
662
|
-
action: "
|
|
662
|
+
action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
|
|
663
663
|
state_path: string;
|
|
664
664
|
stage: any;
|
|
665
665
|
summary: string;
|
|
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
|
|
|
292
292
|
blocking?: boolean;
|
|
293
293
|
details?: Record<string, unknown>;
|
|
294
294
|
ok: boolean;
|
|
295
|
-
action: "
|
|
295
|
+
action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
|
|
296
296
|
state_path: string;
|
|
297
297
|
stage: any;
|
|
298
298
|
summary: string;
|
|
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
|
|
|
382
382
|
continueWithStage?: WorkflowStage | null;
|
|
383
383
|
blocking?: boolean;
|
|
384
384
|
details?: Record<string, unknown>;
|
|
385
|
-
action: "
|
|
385
|
+
action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
|
|
386
386
|
state_path: string;
|
|
387
387
|
stage: any;
|
|
388
388
|
checkpoint: string;
|
|
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
|
|
|
659
659
|
error?: undefined;
|
|
660
660
|
} | {
|
|
661
661
|
ok: boolean;
|
|
662
|
-
action: "
|
|
662
|
+
action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
|
|
663
663
|
state_path: string;
|
|
664
664
|
stage: any;
|
|
665
665
|
summary: string;
|