@sedum-dev/core 0.1.0-alpha.3 → 0.1.0-alpha.5
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-C32TDS2U.js +100 -0
- package/dist/index.d.ts +647 -124
- package/dist/index.js +3549 -256
- package/dist/page-script/index.global.js +60 -3
- package/dist/run-result.schema.json +115 -6
- package/dist/script-api-D3if59MQ.d.ts +212 -0
- package/dist/script-api.d.ts +3 -0
- package/dist/script-api.js +12 -0
- package/package.json +9 -2
|
@@ -413,6 +413,29 @@ var SedumPageScript = (() => {
|
|
|
413
413
|
}
|
|
414
414
|
if (kbdText && kbdText === shown) addPart("keyboard shortcut");
|
|
415
415
|
return parts.join(", ");
|
|
416
|
+
}, countBadgeKind = function(node, count) {
|
|
417
|
+
const tokens = [];
|
|
418
|
+
let control = null;
|
|
419
|
+
for (let current = node, depth = 0; current && current !== document.body && depth < 4; current = composedParent(current), depth++) {
|
|
420
|
+
tokens.push(
|
|
421
|
+
...[
|
|
422
|
+
current.getAttribute("class") ?? "",
|
|
423
|
+
current.id,
|
|
424
|
+
current.getAttribute("data-test") ?? "",
|
|
425
|
+
current.getAttribute("data-testid") ?? ""
|
|
426
|
+
].join(" ").toLocaleLowerCase().split(/\s+/).map((token) => token.replace(/[_:#/.]+/g, "-")).filter(Boolean)
|
|
427
|
+
);
|
|
428
|
+
if (interactive(current)) {
|
|
429
|
+
control = current;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (!control) return "";
|
|
434
|
+
if (publicText(control, true).replace(/\s+/g, "") !== count) return "";
|
|
435
|
+
const kind = ICON_KINDS.find(
|
|
436
|
+
([pattern]) => tokens.some((token) => pattern.test(token))
|
|
437
|
+
);
|
|
438
|
+
return kind?.[1] ?? "";
|
|
416
439
|
}, clippedAway = function(element) {
|
|
417
440
|
const box = element.getBoundingClientRect();
|
|
418
441
|
const x = box.left + box.width / 2;
|
|
@@ -901,8 +924,10 @@ var SedumPageScript = (() => {
|
|
|
901
924
|
continue;
|
|
902
925
|
}
|
|
903
926
|
if (!parent || !visible(parent) || excludedTextAncestor(parent)) continue;
|
|
904
|
-
const
|
|
905
|
-
if (!
|
|
927
|
+
const text = (node.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
928
|
+
if (!text) continue;
|
|
929
|
+
const kind = /^\d{1,4}\+?$/.test(text) ? countBadgeKind(parent, text) : "";
|
|
930
|
+
const part = kind ? `${kind} icon badge: ${text}` : text;
|
|
906
931
|
size += Array.from(part).length + (pieces.length ? 1 : 0);
|
|
907
932
|
if (size > DIGEST_LIMIT)
|
|
908
933
|
return {
|
|
@@ -1025,7 +1050,7 @@ var SedumPageScript = (() => {
|
|
|
1025
1050
|
return { actionable: false, reason: "stale" };
|
|
1026
1051
|
return hitTest() ?? { actionable: false, reason: "not_actionable" };
|
|
1027
1052
|
};
|
|
1028
|
-
observe2 = observe, composedParent2 = composedParent, allElements2 = allElements, flatTextNodes2 = flatTextNodes, deepElementFromPoint2 = deepElementFromPoint, deepContains2 = deepContains, version2 = version, same2 = same, clearRefs2 = clearRefs, visible2 = visible, modal2 = modal, excludedTextAncestor2 = excludedTextAncestor, publicText2 = publicText, referencedLabelText2 = referencedLabelText, label2 = label, nearbyText2 = nearbyText, mediaName2 = mediaName, hostLabel2 = hostLabel, iconName2 = iconName, describedText2 = describedText, rowLabel2 = rowLabel, candidateName2 = candidateName, hintWords2 = hintWords, addsWords2 = addsWords, siteRootLink2 = siteRootLink, nameHint2 = nameHint, clippedAway2 = clippedAway, ariaHiddenOnly2 = ariaHiddenOnly, isToggle2 = isToggle, transparentToggle2 = transparentToggle, toggleLabel2 = toggleLabel, pointerTarget2 = pointerTarget, landmarkOf2 = landmarkOf, landmarkRoot2 = landmarkRoot, locationOf2 = locationOf, shortText2 = shortText, containerTitle2 = containerTitle, sectionOf2 = sectionOf, boundedName2 = boundedName, role2 = role, interactive2 = interactive, readable2 = readable, editable2 = editable, disabled2 = disabled, path2 = path, inArticleBody2 = inArticleBody, itemContext2 = itemContext, peers2 = peers, scan2 = scan, collect2 = collect, selectOnly2 = selectOnly, selectedText2 = selectedText, digest2 = digest, refElement2 = refElement, fillElement2 = fillElement, readTarget2 = readTarget, aim2 = aim;
|
|
1053
|
+
observe2 = observe, composedParent2 = composedParent, allElements2 = allElements, flatTextNodes2 = flatTextNodes, deepElementFromPoint2 = deepElementFromPoint, deepContains2 = deepContains, version2 = version, same2 = same, clearRefs2 = clearRefs, visible2 = visible, modal2 = modal, excludedTextAncestor2 = excludedTextAncestor, publicText2 = publicText, referencedLabelText2 = referencedLabelText, label2 = label, nearbyText2 = nearbyText, mediaName2 = mediaName, hostLabel2 = hostLabel, iconName2 = iconName, describedText2 = describedText, rowLabel2 = rowLabel, candidateName2 = candidateName, hintWords2 = hintWords, addsWords2 = addsWords, siteRootLink2 = siteRootLink, nameHint2 = nameHint, countBadgeKind2 = countBadgeKind, clippedAway2 = clippedAway, ariaHiddenOnly2 = ariaHiddenOnly, isToggle2 = isToggle, transparentToggle2 = transparentToggle, toggleLabel2 = toggleLabel, pointerTarget2 = pointerTarget, landmarkOf2 = landmarkOf, landmarkRoot2 = landmarkRoot, locationOf2 = locationOf, shortText2 = shortText, containerTitle2 = containerTitle, sectionOf2 = sectionOf, boundedName2 = boundedName, role2 = role, interactive2 = interactive, readable2 = readable, editable2 = editable, disabled2 = disabled, path2 = path, inArticleBody2 = inArticleBody, itemContext2 = itemContext, peers2 = peers, scan2 = scan, collect2 = collect, selectOnly2 = selectOnly, selectedText2 = selectedText, digest2 = digest, refElement2 = refElement, fillElement2 = fillElement, readTarget2 = readTarget, aim2 = aim;
|
|
1029
1054
|
const documentId = Array.from(crypto.getRandomValues(new Uint32Array(4))).map((part) => part.toString(16)).join("-");
|
|
1030
1055
|
let revision = 0;
|
|
1031
1056
|
let route = location.href;
|
|
@@ -1097,6 +1122,37 @@ var SedumPageScript = (() => {
|
|
|
1097
1122
|
const titleCache = /* @__PURE__ */ new Map();
|
|
1098
1123
|
const bridge = {
|
|
1099
1124
|
protocol: PAGE_PROTOCOL,
|
|
1125
|
+
visualCandidates: () => {
|
|
1126
|
+
const current = version();
|
|
1127
|
+
if (!snapshot || !same(snapshot.version, current))
|
|
1128
|
+
throw new Error("stale visual observation");
|
|
1129
|
+
return {
|
|
1130
|
+
version: current,
|
|
1131
|
+
width: innerWidth,
|
|
1132
|
+
height: innerHeight,
|
|
1133
|
+
boxes: snapshot.candidates.flatMap((candidate) => {
|
|
1134
|
+
const element = refElement(candidate.ref);
|
|
1135
|
+
if (!element || !visible(element) || disabled(element)) return [];
|
|
1136
|
+
const rect = element.getBoundingClientRect();
|
|
1137
|
+
if (rect.width <= 0 || rect.height <= 0 || rect.left < 0 || rect.top < 0 || rect.right > innerWidth || rect.bottom > innerHeight)
|
|
1138
|
+
return [];
|
|
1139
|
+
const hit = deepElementFromPoint(
|
|
1140
|
+
rect.left + rect.width / 2,
|
|
1141
|
+
rect.top + rect.height / 2
|
|
1142
|
+
);
|
|
1143
|
+
if (!hit || !deepContains(element, hit)) return [];
|
|
1144
|
+
return [
|
|
1145
|
+
{
|
|
1146
|
+
ref: candidate.ref,
|
|
1147
|
+
x: rect.left,
|
|
1148
|
+
y: rect.top,
|
|
1149
|
+
width: rect.width,
|
|
1150
|
+
height: rect.height
|
|
1151
|
+
}
|
|
1152
|
+
];
|
|
1153
|
+
})
|
|
1154
|
+
};
|
|
1155
|
+
},
|
|
1100
1156
|
collect,
|
|
1101
1157
|
digest,
|
|
1102
1158
|
pageVersion: version,
|
|
@@ -1159,6 +1215,7 @@ var SedumPageScript = (() => {
|
|
|
1159
1215
|
var addsWords2;
|
|
1160
1216
|
var siteRootLink2;
|
|
1161
1217
|
var nameHint2;
|
|
1218
|
+
var countBadgeKind2;
|
|
1162
1219
|
var clippedAway2;
|
|
1163
1220
|
var ariaHiddenOnly2;
|
|
1164
1221
|
var isToggle2;
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"type": "string",
|
|
40
40
|
"enum": [
|
|
41
41
|
"low_confidence",
|
|
42
|
-
"contradiction"
|
|
42
|
+
"contradiction",
|
|
43
|
+
"flaky"
|
|
43
44
|
]
|
|
44
45
|
}
|
|
45
46
|
},
|
|
@@ -142,6 +143,29 @@
|
|
|
142
143
|
"type": "integer",
|
|
143
144
|
"exclusiveMinimum": 0,
|
|
144
145
|
"maximum": 9007199254740991
|
|
146
|
+
},
|
|
147
|
+
"vision": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"properties": {
|
|
150
|
+
"model": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"minLength": 1,
|
|
153
|
+
"maxLength": 200
|
|
154
|
+
},
|
|
155
|
+
"key": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"enum": [
|
|
158
|
+
"accepted",
|
|
159
|
+
"rejected",
|
|
160
|
+
"unreachable"
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"required": [
|
|
165
|
+
"model",
|
|
166
|
+
"key"
|
|
167
|
+
],
|
|
168
|
+
"additionalProperties": false
|
|
145
169
|
}
|
|
146
170
|
},
|
|
147
171
|
"required": [
|
|
@@ -246,12 +270,17 @@
|
|
|
246
270
|
"items": {
|
|
247
271
|
"type": "object",
|
|
248
272
|
"properties": {
|
|
273
|
+
"modality": {
|
|
274
|
+
"type": "string",
|
|
275
|
+
"const": "vision"
|
|
276
|
+
},
|
|
249
277
|
"purpose": {
|
|
250
278
|
"type": "string",
|
|
251
279
|
"enum": [
|
|
252
280
|
"classification",
|
|
253
281
|
"locator",
|
|
254
|
-
"judge"
|
|
282
|
+
"judge",
|
|
283
|
+
"planner"
|
|
255
284
|
]
|
|
256
285
|
},
|
|
257
286
|
"requestedModel": {
|
|
@@ -384,6 +413,22 @@
|
|
|
384
413
|
"type": "string",
|
|
385
414
|
"maxLength": 512
|
|
386
415
|
},
|
|
416
|
+
"goal": {
|
|
417
|
+
"type": "object",
|
|
418
|
+
"properties": {
|
|
419
|
+
"text": {
|
|
420
|
+
"type": "string"
|
|
421
|
+
},
|
|
422
|
+
"verify": {
|
|
423
|
+
"type": "string"
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
"required": [
|
|
427
|
+
"text",
|
|
428
|
+
"verify"
|
|
429
|
+
],
|
|
430
|
+
"additionalProperties": false
|
|
431
|
+
},
|
|
387
432
|
"tags": {
|
|
388
433
|
"type": "array",
|
|
389
434
|
"items": {
|
|
@@ -420,7 +465,8 @@
|
|
|
420
465
|
"type": "string",
|
|
421
466
|
"enum": [
|
|
422
467
|
"low_confidence",
|
|
423
|
-
"contradiction"
|
|
468
|
+
"contradiction",
|
|
469
|
+
"flaky"
|
|
424
470
|
]
|
|
425
471
|
}
|
|
426
472
|
},
|
|
@@ -473,7 +519,8 @@
|
|
|
473
519
|
"type": "string",
|
|
474
520
|
"enum": [
|
|
475
521
|
"low_confidence",
|
|
476
|
-
"contradiction"
|
|
522
|
+
"contradiction",
|
|
523
|
+
"flaky"
|
|
477
524
|
]
|
|
478
525
|
}
|
|
479
526
|
},
|
|
@@ -589,6 +636,14 @@
|
|
|
589
636
|
"type": "string",
|
|
590
637
|
"maxLength": 512
|
|
591
638
|
},
|
|
639
|
+
"group": {
|
|
640
|
+
"maxItems": 16,
|
|
641
|
+
"type": "array",
|
|
642
|
+
"items": {
|
|
643
|
+
"type": "string",
|
|
644
|
+
"maxLength": 120
|
|
645
|
+
}
|
|
646
|
+
},
|
|
592
647
|
"sourceStack": {
|
|
593
648
|
"minItems": 1,
|
|
594
649
|
"type": "array",
|
|
@@ -728,6 +783,50 @@
|
|
|
728
783
|
{
|
|
729
784
|
"type": "object",
|
|
730
785
|
"properties": {
|
|
786
|
+
"vision": {
|
|
787
|
+
"type": "object",
|
|
788
|
+
"properties": {
|
|
789
|
+
"outcome": {
|
|
790
|
+
"type": "string",
|
|
791
|
+
"enum": [
|
|
792
|
+
"selected",
|
|
793
|
+
"abstained",
|
|
794
|
+
"failed"
|
|
795
|
+
]
|
|
796
|
+
},
|
|
797
|
+
"reason": {
|
|
798
|
+
"type": "string",
|
|
799
|
+
"maxLength": 120
|
|
800
|
+
},
|
|
801
|
+
"elapsedMs": {
|
|
802
|
+
"type": "number",
|
|
803
|
+
"minimum": 0
|
|
804
|
+
},
|
|
805
|
+
"failure": {
|
|
806
|
+
"type": "string",
|
|
807
|
+
"enum": [
|
|
808
|
+
"timeout",
|
|
809
|
+
"canceled",
|
|
810
|
+
"http_error",
|
|
811
|
+
"connection",
|
|
812
|
+
"invalid_envelope",
|
|
813
|
+
"invalid_json",
|
|
814
|
+
"invalid_selection",
|
|
815
|
+
"truncated_response",
|
|
816
|
+
"unknown"
|
|
817
|
+
]
|
|
818
|
+
},
|
|
819
|
+
"httpStatus": {
|
|
820
|
+
"type": "integer",
|
|
821
|
+
"minimum": 100,
|
|
822
|
+
"maximum": 599
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
"required": [
|
|
826
|
+
"elapsedMs"
|
|
827
|
+
],
|
|
828
|
+
"additionalProperties": false
|
|
829
|
+
},
|
|
731
830
|
"confidence": {
|
|
732
831
|
"anyOf": [
|
|
733
832
|
{
|
|
@@ -977,12 +1076,17 @@
|
|
|
977
1076
|
"items": {
|
|
978
1077
|
"type": "object",
|
|
979
1078
|
"properties": {
|
|
1079
|
+
"modality": {
|
|
1080
|
+
"type": "string",
|
|
1081
|
+
"const": "vision"
|
|
1082
|
+
},
|
|
980
1083
|
"purpose": {
|
|
981
1084
|
"type": "string",
|
|
982
1085
|
"enum": [
|
|
983
1086
|
"classification",
|
|
984
1087
|
"locator",
|
|
985
|
-
"judge"
|
|
1088
|
+
"judge",
|
|
1089
|
+
"planner"
|
|
986
1090
|
]
|
|
987
1091
|
},
|
|
988
1092
|
"requestedModel": {
|
|
@@ -1335,12 +1439,17 @@
|
|
|
1335
1439
|
"items": {
|
|
1336
1440
|
"type": "object",
|
|
1337
1441
|
"properties": {
|
|
1442
|
+
"modality": {
|
|
1443
|
+
"type": "string",
|
|
1444
|
+
"const": "vision"
|
|
1445
|
+
},
|
|
1338
1446
|
"purpose": {
|
|
1339
1447
|
"type": "string",
|
|
1340
1448
|
"enum": [
|
|
1341
1449
|
"classification",
|
|
1342
1450
|
"locator",
|
|
1343
|
-
"judge"
|
|
1451
|
+
"judge",
|
|
1452
|
+
"planner"
|
|
1344
1453
|
]
|
|
1345
1454
|
},
|
|
1346
1455
|
"requestedModel": {
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Page, BrowserContext } from 'playwright-core';
|
|
2
|
+
import 'playwright/test';
|
|
3
|
+
|
|
4
|
+
/** Source positions come from YAML nodes, never from searching the source text. */
|
|
5
|
+
interface FlowSource {
|
|
6
|
+
readonly file: string;
|
|
7
|
+
readonly line: number;
|
|
8
|
+
readonly col: number;
|
|
9
|
+
}
|
|
10
|
+
interface FlowDiagnostic {
|
|
11
|
+
readonly severity: "error" | "warning";
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly source: FlowSource;
|
|
14
|
+
readonly message: string;
|
|
15
|
+
readonly fix: string;
|
|
16
|
+
}
|
|
17
|
+
type FlowScalar = string | number | boolean | null;
|
|
18
|
+
interface DeclaredDataValue {
|
|
19
|
+
readonly value: FlowScalar;
|
|
20
|
+
readonly source: FlowSource;
|
|
21
|
+
}
|
|
22
|
+
interface FlowToken {
|
|
23
|
+
readonly kind: "placeholder" | "quoted";
|
|
24
|
+
readonly start: number;
|
|
25
|
+
readonly end: number;
|
|
26
|
+
readonly text: string;
|
|
27
|
+
readonly key?: string;
|
|
28
|
+
}
|
|
29
|
+
interface SentenceStep {
|
|
30
|
+
readonly kind: "sentence";
|
|
31
|
+
readonly phase: "before" | "steps" | "after";
|
|
32
|
+
readonly text: string;
|
|
33
|
+
readonly tokens: readonly FlowToken[];
|
|
34
|
+
readonly source: FlowSource;
|
|
35
|
+
/** SED-29 adds module call sites before the sentence source. */
|
|
36
|
+
readonly sourceStack?: readonly FlowSource[];
|
|
37
|
+
}
|
|
38
|
+
interface ModuleBinding {
|
|
39
|
+
readonly value: FlowScalar;
|
|
40
|
+
readonly source: FlowSource;
|
|
41
|
+
}
|
|
42
|
+
interface ModuleStep {
|
|
43
|
+
readonly kind: "module";
|
|
44
|
+
readonly phase: "before" | "steps" | "after";
|
|
45
|
+
readonly use: string;
|
|
46
|
+
readonly with: Readonly<Record<string, FlowScalar>>;
|
|
47
|
+
readonly withSources: Readonly<Record<string, FlowSource>>;
|
|
48
|
+
readonly source: FlowSource;
|
|
49
|
+
/** SED-29 adds each resolved module source after this call site. */
|
|
50
|
+
readonly sourceStack: readonly FlowSource[];
|
|
51
|
+
/** Present only after the complete module graph has been resolved. */
|
|
52
|
+
readonly resolved?: ResolvedModuleCall;
|
|
53
|
+
}
|
|
54
|
+
interface ResolvedModuleCall {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly file: string;
|
|
57
|
+
readonly parameters: readonly string[];
|
|
58
|
+
readonly bindings: Readonly<Record<string, ModuleBinding>>;
|
|
59
|
+
readonly steps: readonly FlowStep[];
|
|
60
|
+
}
|
|
61
|
+
type FlowStep = SentenceStep | ModuleStep;
|
|
62
|
+
interface FlowDefinition {
|
|
63
|
+
readonly version: 1;
|
|
64
|
+
readonly file: string;
|
|
65
|
+
readonly identity: string;
|
|
66
|
+
readonly explicitId?: string;
|
|
67
|
+
readonly idSource?: FlowSource;
|
|
68
|
+
readonly description?: string;
|
|
69
|
+
readonly url?: string;
|
|
70
|
+
/** Position of the `url` value, for entry-URL diagnostics. */
|
|
71
|
+
readonly urlSource?: FlowSource;
|
|
72
|
+
readonly tags: readonly string[];
|
|
73
|
+
readonly meta: Readonly<Record<string, unknown>>;
|
|
74
|
+
readonly data: Readonly<Record<string, DeclaredDataValue>>;
|
|
75
|
+
readonly before: readonly FlowStep[];
|
|
76
|
+
readonly steps: readonly FlowStep[];
|
|
77
|
+
readonly after: readonly FlowStep[];
|
|
78
|
+
readonly goal?: {
|
|
79
|
+
readonly text: string;
|
|
80
|
+
readonly source: FlowSource;
|
|
81
|
+
readonly verify: string;
|
|
82
|
+
readonly verifySource: FlowSource;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
interface ModuleDefinition {
|
|
86
|
+
readonly file: string;
|
|
87
|
+
readonly source: FlowSource;
|
|
88
|
+
readonly parameters: readonly string[];
|
|
89
|
+
readonly steps: readonly FlowStep[];
|
|
90
|
+
}
|
|
91
|
+
interface ParsedModuleResult {
|
|
92
|
+
readonly value?: ModuleDefinition;
|
|
93
|
+
readonly diagnostics: readonly FlowDiagnostic[];
|
|
94
|
+
}
|
|
95
|
+
/** A format-only result cannot be mistaken for full validation. */
|
|
96
|
+
interface FormatCoverage {
|
|
97
|
+
readonly format: "passed" | "failed";
|
|
98
|
+
readonly steps: "not_checked";
|
|
99
|
+
readonly modules: "not_needed" | "not_checked";
|
|
100
|
+
}
|
|
101
|
+
interface ParsedFlowResult {
|
|
102
|
+
readonly value?: FlowDefinition;
|
|
103
|
+
/** Parsed steps retained only for collecting later errors; never executable. */
|
|
104
|
+
readonly candidate?: FlowDefinition;
|
|
105
|
+
readonly diagnostics: readonly FlowDiagnostic[];
|
|
106
|
+
readonly coverage: FullValidationCoverage;
|
|
107
|
+
}
|
|
108
|
+
interface ValidationInput {
|
|
109
|
+
readonly source: string;
|
|
110
|
+
readonly path: string;
|
|
111
|
+
}
|
|
112
|
+
interface FlowValidationResult {
|
|
113
|
+
readonly files: readonly ParsedFlowResult[];
|
|
114
|
+
readonly diagnostics: readonly FlowDiagnostic[];
|
|
115
|
+
readonly coverage: FormatCoverage;
|
|
116
|
+
}
|
|
117
|
+
/** SED-28/29/37 may only mark checks complete after actually performing them. */
|
|
118
|
+
interface FullValidationCoverage {
|
|
119
|
+
readonly format: "passed" | "failed";
|
|
120
|
+
readonly steps: "not_checked" | "checked" | "incomplete";
|
|
121
|
+
readonly modules: "not_needed" | "not_checked" | "checked" | "incomplete";
|
|
122
|
+
}
|
|
123
|
+
declare function isFullyValidated(coverage: FullValidationCoverage, diagnostics: readonly FlowDiagnostic[]): boolean;
|
|
124
|
+
declare function formatFlowDiagnostic(diagnostic: FlowDiagnostic): string;
|
|
125
|
+
|
|
126
|
+
declare const SECRET: unique symbol;
|
|
127
|
+
/** A value typed into the page but never shown to a model or a report. */
|
|
128
|
+
interface SecretValue {
|
|
129
|
+
readonly [SECRET]: () => string;
|
|
130
|
+
}
|
|
131
|
+
/** Mark a value as sensitive: it is typed, but redacted from reports and model input. */
|
|
132
|
+
declare function secret(value: string): SecretValue;
|
|
133
|
+
declare function isSecret(value: unknown): value is SecretValue;
|
|
134
|
+
/** @internal The runner reads a secret's text only to type it. */
|
|
135
|
+
declare function revealSecret(value: SecretValue): string;
|
|
136
|
+
type AiValue = string | number | boolean | SecretValue;
|
|
137
|
+
/** Values for `{{name}}` placeholders; keep them out of the sentence text. */
|
|
138
|
+
type AiValues = Readonly<Record<string, AiValue>>;
|
|
139
|
+
/** Anything with a zod-style `parse`, such as `z.coerce.number()`. */
|
|
140
|
+
interface Parser<T> {
|
|
141
|
+
parse(input: unknown): T;
|
|
142
|
+
}
|
|
143
|
+
interface Ai {
|
|
144
|
+
/** Run one plain-English step, exactly as a YAML step sentence. */
|
|
145
|
+
(sentence: string, values?: AiValues): Promise<void>;
|
|
146
|
+
/** Run several steps in order; they share one values object. */
|
|
147
|
+
(sentences: readonly string[], values?: AiValues): Promise<void>;
|
|
148
|
+
/** Name a block of steps; every step inside is reported under the name. */
|
|
149
|
+
group<T>(name: string, body: () => Promise<T> | T): Promise<T>;
|
|
150
|
+
group(name: string, sentences: readonly string[], values?: AiValues): Promise<void>;
|
|
151
|
+
/** Read the text of the element a description refers to. */
|
|
152
|
+
extract(description: string): Promise<string>;
|
|
153
|
+
extract<T>(description: string, parser: Parser<T>): Promise<T>;
|
|
154
|
+
}
|
|
155
|
+
interface TestInfo {
|
|
156
|
+
readonly id: string;
|
|
157
|
+
readonly title: string;
|
|
158
|
+
readonly file: string;
|
|
159
|
+
readonly tags: readonly string[];
|
|
160
|
+
/** 1 for the first attempt, 2 for the first retry, and so on. */
|
|
161
|
+
readonly attempt: number;
|
|
162
|
+
}
|
|
163
|
+
interface TestContext {
|
|
164
|
+
/** The Playwright page the AI steps run on. */
|
|
165
|
+
readonly page: Page;
|
|
166
|
+
readonly context: BrowserContext;
|
|
167
|
+
readonly ai: Ai;
|
|
168
|
+
/** Configured variables and environment, as `sedum run` resolves them. */
|
|
169
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
170
|
+
readonly testInfo: TestInfo;
|
|
171
|
+
}
|
|
172
|
+
interface TestOptions {
|
|
173
|
+
/** Stable identity; defaults to `<file>#<title>`. */
|
|
174
|
+
readonly id?: string;
|
|
175
|
+
/** Entry URL, absolute or relative to `baseUrl`. Omit to start on a blank page. */
|
|
176
|
+
readonly url?: string;
|
|
177
|
+
readonly tags?: readonly string[];
|
|
178
|
+
}
|
|
179
|
+
type TestBody = (context: TestContext) => Promise<void> | void;
|
|
180
|
+
interface ScriptRegistration {
|
|
181
|
+
readonly title: string;
|
|
182
|
+
readonly options: TestOptions;
|
|
183
|
+
readonly body: TestBody;
|
|
184
|
+
/**
|
|
185
|
+
* The innermost stack frame in a `*.test.ts` file when `test()` ran, so a
|
|
186
|
+
* test declared through a helper belongs to the test file that called it.
|
|
187
|
+
* Otherwise the direct caller's frame.
|
|
188
|
+
*/
|
|
189
|
+
readonly callSite: string | undefined;
|
|
190
|
+
}
|
|
191
|
+
interface Registry {
|
|
192
|
+
pending: ScriptRegistration[];
|
|
193
|
+
}
|
|
194
|
+
/** @internal */
|
|
195
|
+
declare function scriptRegistry(): Registry;
|
|
196
|
+
/** Declare a test. `sedum run` discovers every `test()` in a `*.test.ts` file. */
|
|
197
|
+
declare function test(title: string, body: TestBody): void;
|
|
198
|
+
declare function test(title: string, options: TestOptions, body: TestBody): void;
|
|
199
|
+
/** One stack frame, as `file:line:col`, parsed from V8's text. */
|
|
200
|
+
declare function parseFrame(frame: string): FlowSource | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* One spelling per file, for comparing paths from stack frames. On Windows a
|
|
203
|
+
* frame may use forward slashes, a long name for a short one (RUNNER~1 in a
|
|
204
|
+
* temp dir), or another drive-letter case.
|
|
205
|
+
*/
|
|
206
|
+
declare function pathKey(file: string): string;
|
|
207
|
+
/** Whether a stack frame's path names `file`. */
|
|
208
|
+
declare function samePath(a: string, b: string): boolean;
|
|
209
|
+
/** The innermost stack frame inside `file`, for reporting where a step was written. */
|
|
210
|
+
declare function sourceInFile(stack: string | undefined, file: string): FlowSource | undefined;
|
|
211
|
+
|
|
212
|
+
export { type AiValues as A, scriptRegistry as B, secret as C, type DeclaredDataValue as D, sourceInFile as E, type FlowSource as F, test as G, type ModuleBinding as M, type ParsedFlowResult as P, type ResolvedModuleCall as R, type SentenceStep as S, type TestBody as T, type ValidationInput as V, type FlowToken as a, type FlowScalar as b, type FlowDiagnostic as c, type FlowDefinition as d, type ParsedModuleResult as e, type FlowValidationResult as f, type ModuleStep as g, type FullValidationCoverage as h, type ScriptRegistration as i, type Ai as j, type AiValue as k, type FlowStep as l, type FormatCoverage as m, type ModuleDefinition as n, type Parser as o, type SecretValue as p, type TestContext as q, type TestInfo as r, type TestOptions as s, formatFlowDiagnostic as t, isFullyValidated as u, isSecret as v, parseFrame as w, pathKey as x, revealSecret as y, samePath as z };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { j as Ai, k as AiValue, A as AiValues, o as Parser, p as SecretValue, T as TestBody, q as TestContext, r as TestInfo, s as TestOptions, C as secret, G as test } from './script-api-D3if59MQ.js';
|
|
2
|
+
export { expect } from 'playwright/test';
|
|
3
|
+
export { BrowserContext, Locator, Page } from 'playwright-core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sedum-dev/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"repository": "https://github.com/sedum-dev/sedum",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js"
|
|
16
16
|
},
|
|
17
|
+
"./script": {
|
|
18
|
+
"types": "./dist/script-api.d.ts",
|
|
19
|
+
"import": "./dist/script-api.js"
|
|
20
|
+
},
|
|
17
21
|
"./page-script.js": "./dist/page-script/index.global.js",
|
|
18
22
|
"./run-result.schema.json": "./dist/run-result.schema.json"
|
|
19
23
|
},
|
|
@@ -21,7 +25,10 @@
|
|
|
21
25
|
"dist"
|
|
22
26
|
],
|
|
23
27
|
"dependencies": {
|
|
28
|
+
"jiti": "2.7.0",
|
|
29
|
+
"playwright": "1.63.0",
|
|
24
30
|
"playwright-core": "1.63.0",
|
|
31
|
+
"sharp": "0.35.5",
|
|
25
32
|
"yaml": "2.9.1",
|
|
26
33
|
"zod": "4.6.5"
|
|
27
34
|
},
|
|
@@ -29,7 +36,7 @@
|
|
|
29
36
|
"@hegeldev/hegel": "0.4.7"
|
|
30
37
|
},
|
|
31
38
|
"scripts": {
|
|
32
|
-
"build": "tsup src/index.ts --format esm --dts --clean --out-dir dist && node scripts/write-run-result-schema.mjs && tsup src/page-script/index.ts --format iife --platform browser --global-name SedumPageScript --out-dir dist/page-script",
|
|
39
|
+
"build": "tsup src/index.ts src/script-api.ts --format esm --dts --clean --out-dir dist && node scripts/write-run-result-schema.mjs && tsup src/page-script/index.ts --format iife --platform browser --global-name SedumPageScript --out-dir dist/page-script",
|
|
33
40
|
"typecheck": "tsc --noEmit"
|
|
34
41
|
}
|
|
35
42
|
}
|