@sedum-dev/core 0.1.0-alpha.0 → 0.1.0-alpha.11

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.
@@ -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,22 @@
246
270
  "items": {
247
271
  "type": "object",
248
272
  "properties": {
273
+ "provider": {
274
+ "type": "string",
275
+ "minLength": 1,
276
+ "maxLength": 120
277
+ },
278
+ "modality": {
279
+ "type": "string",
280
+ "const": "vision"
281
+ },
249
282
  "purpose": {
250
283
  "type": "string",
251
284
  "enum": [
252
285
  "classification",
253
286
  "locator",
254
- "judge"
287
+ "judge",
288
+ "planner"
255
289
  ]
256
290
  },
257
291
  "requestedModel": {
@@ -384,6 +418,22 @@
384
418
  "type": "string",
385
419
  "maxLength": 512
386
420
  },
421
+ "goal": {
422
+ "type": "object",
423
+ "properties": {
424
+ "text": {
425
+ "type": "string"
426
+ },
427
+ "verify": {
428
+ "type": "string"
429
+ }
430
+ },
431
+ "required": [
432
+ "text",
433
+ "verify"
434
+ ],
435
+ "additionalProperties": false
436
+ },
387
437
  "tags": {
388
438
  "type": "array",
389
439
  "items": {
@@ -420,7 +470,8 @@
420
470
  "type": "string",
421
471
  "enum": [
422
472
  "low_confidence",
423
- "contradiction"
473
+ "contradiction",
474
+ "flaky"
424
475
  ]
425
476
  }
426
477
  },
@@ -473,7 +524,8 @@
473
524
  "type": "string",
474
525
  "enum": [
475
526
  "low_confidence",
476
- "contradiction"
527
+ "contradiction",
528
+ "flaky"
477
529
  ]
478
530
  }
479
531
  },
@@ -589,6 +641,52 @@
589
641
  "type": "string",
590
642
  "maxLength": 512
591
643
  },
644
+ "group": {
645
+ "maxItems": 16,
646
+ "type": "array",
647
+ "items": {
648
+ "type": "string",
649
+ "maxLength": 120
650
+ }
651
+ },
652
+ "goal": {
653
+ "type": "object",
654
+ "properties": {
655
+ "completion": {
656
+ "type": "string",
657
+ "const": "planner"
658
+ },
659
+ "text": {
660
+ "type": "string"
661
+ },
662
+ "actions": {
663
+ "type": "integer",
664
+ "minimum": 0,
665
+ "maximum": 9007199254740991
666
+ },
667
+ "requests": {
668
+ "type": "integer",
669
+ "minimum": 0,
670
+ "maximum": 9007199254740991
671
+ },
672
+ "reason": {
673
+ "type": "string"
674
+ },
675
+ "dataSeed": {
676
+ "type": "integer",
677
+ "minimum": -9007199254740991,
678
+ "maximum": 9007199254740991
679
+ }
680
+ },
681
+ "required": [
682
+ "completion",
683
+ "text",
684
+ "actions",
685
+ "requests",
686
+ "reason"
687
+ ],
688
+ "additionalProperties": false
689
+ },
592
690
  "sourceStack": {
593
691
  "minItems": 1,
594
692
  "type": "array",
@@ -728,6 +826,55 @@
728
826
  {
729
827
  "type": "object",
730
828
  "properties": {
829
+ "vision": {
830
+ "type": "object",
831
+ "properties": {
832
+ "outcome": {
833
+ "type": "string",
834
+ "enum": [
835
+ "selected",
836
+ "abstained",
837
+ "failed"
838
+ ]
839
+ },
840
+ "reason": {
841
+ "type": "string",
842
+ "maxLength": 120
843
+ },
844
+ "abstentionReason": {
845
+ "type": "string",
846
+ "maxLength": 120
847
+ },
848
+ "elapsedMs": {
849
+ "type": "number",
850
+ "minimum": 0
851
+ },
852
+ "failure": {
853
+ "type": "string",
854
+ "enum": [
855
+ "timeout",
856
+ "canceled",
857
+ "http_error",
858
+ "connection",
859
+ "invalid_envelope",
860
+ "invalid_json",
861
+ "invalid_selection",
862
+ "truncated_response",
863
+ "unknown",
864
+ "stale_page"
865
+ ]
866
+ },
867
+ "httpStatus": {
868
+ "type": "integer",
869
+ "minimum": 100,
870
+ "maximum": 599
871
+ }
872
+ },
873
+ "required": [
874
+ "elapsedMs"
875
+ ],
876
+ "additionalProperties": false
877
+ },
731
878
  "confidence": {
732
879
  "anyOf": [
733
880
  {
@@ -977,12 +1124,22 @@
977
1124
  "items": {
978
1125
  "type": "object",
979
1126
  "properties": {
1127
+ "provider": {
1128
+ "type": "string",
1129
+ "minLength": 1,
1130
+ "maxLength": 120
1131
+ },
1132
+ "modality": {
1133
+ "type": "string",
1134
+ "const": "vision"
1135
+ },
980
1136
  "purpose": {
981
1137
  "type": "string",
982
1138
  "enum": [
983
1139
  "classification",
984
1140
  "locator",
985
- "judge"
1141
+ "judge",
1142
+ "planner"
986
1143
  ]
987
1144
  },
988
1145
  "requestedModel": {
@@ -1335,12 +1492,22 @@
1335
1492
  "items": {
1336
1493
  "type": "object",
1337
1494
  "properties": {
1495
+ "provider": {
1496
+ "type": "string",
1497
+ "minLength": 1,
1498
+ "maxLength": 120
1499
+ },
1500
+ "modality": {
1501
+ "type": "string",
1502
+ "const": "vision"
1503
+ },
1338
1504
  "purpose": {
1339
1505
  "type": "string",
1340
1506
  "enum": [
1341
1507
  "classification",
1342
1508
  "locator",
1343
- "judge"
1509
+ "judge",
1510
+ "planner"
1344
1511
  ]
1345
1512
  },
1346
1513
  "requestedModel": {
@@ -0,0 +1,221 @@
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
+ /** Run a bounded goal until planner completion. Verify the outcome separately. */
149
+ goal(goal: string, values?: AiValues, options?: {
150
+ readonly generateData?: boolean;
151
+ }): Promise<void>;
152
+ /** Name a block of steps; every step inside is reported under the name. */
153
+ group<T>(name: string, body: () => Promise<T> | T): Promise<T>;
154
+ group(name: string, sentences: readonly string[], values?: AiValues): Promise<void>;
155
+ /**
156
+ * Ask whether a claim holds on the page now, to branch on what the page
157
+ * shows. It is judged like a verify, never retried, and never fails the test.
158
+ */
159
+ holds(claim: string, values?: AiValues): Promise<boolean>;
160
+ /** Read the text of the element a description refers to. */
161
+ extract(description: string): Promise<string>;
162
+ extract<T>(description: string, parser: Parser<T>): Promise<T>;
163
+ }
164
+ interface TestInfo {
165
+ readonly id: string;
166
+ readonly title: string;
167
+ readonly file: string;
168
+ readonly tags: readonly string[];
169
+ /** 1 for the first attempt, 2 for the first retry, and so on. */
170
+ readonly attempt: number;
171
+ }
172
+ interface TestContext {
173
+ /** The Playwright page the AI steps run on. */
174
+ readonly page: Page;
175
+ readonly context: BrowserContext;
176
+ readonly ai: Ai;
177
+ /** Configured variables and environment, as `sedum run` resolves them. */
178
+ readonly env: Readonly<Record<string, string | undefined>>;
179
+ readonly testInfo: TestInfo;
180
+ }
181
+ interface TestOptions {
182
+ /** Stable identity; defaults to `<file>#<title>`. */
183
+ readonly id?: string;
184
+ /** Entry URL, absolute or relative to `baseUrl`. Omit to start on a blank page. */
185
+ readonly url?: string;
186
+ readonly tags?: readonly string[];
187
+ }
188
+ type TestBody = (context: TestContext) => Promise<void> | void;
189
+ interface ScriptRegistration {
190
+ readonly title: string;
191
+ readonly options: TestOptions;
192
+ readonly body: TestBody;
193
+ /**
194
+ * The innermost stack frame in a `*.test.ts` file when `test()` ran, so a
195
+ * test declared through a helper belongs to the test file that called it.
196
+ * Otherwise the direct caller's frame.
197
+ */
198
+ readonly callSite: string | undefined;
199
+ }
200
+ interface Registry {
201
+ pending: ScriptRegistration[];
202
+ }
203
+ /** @internal */
204
+ declare function scriptRegistry(): Registry;
205
+ /** Declare a test. `sedum run` discovers every `test()` in a `*.test.ts` file. */
206
+ declare function test(title: string, body: TestBody): void;
207
+ declare function test(title: string, options: TestOptions, body: TestBody): void;
208
+ /** One stack frame, as `file:line:col`, parsed from V8's text. */
209
+ declare function parseFrame(frame: string): FlowSource | undefined;
210
+ /**
211
+ * One spelling per file, for comparing paths from stack frames. On Windows a
212
+ * frame may use forward slashes, a long name for a short one (RUNNER~1 in a
213
+ * temp dir), or another drive-letter case.
214
+ */
215
+ declare function pathKey(file: string): string;
216
+ /** Whether a stack frame's path names `file`. */
217
+ declare function samePath(a: string, b: string): boolean;
218
+ /** The innermost stack frame inside `file`, for reporting where a step was written. */
219
+ declare function sourceInFile(stack: string | undefined, file: string): FlowSource | undefined;
220
+
221
+ 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-DzYBsXzT.js';
2
+ export { expect } from 'playwright/test';
3
+ export { BrowserContext, Locator, Page } from 'playwright-core';
@@ -0,0 +1,12 @@
1
+ import {
2
+ secret,
3
+ test
4
+ } from "./chunk-C32TDS2U.js";
5
+
6
+ // src/script-api.ts
7
+ import { expect } from "playwright/test";
8
+ export {
9
+ expect,
10
+ secret,
11
+ test
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sedum-dev/core",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.11",
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,12 +25,20 @@
21
25
  "dist"
22
26
  ],
23
27
  "dependencies": {
28
+ "@faker-js/faker": "10.6.0",
29
+ "jiti": "2.7.0",
30
+ "p-queue": "9.3.3",
31
+ "playwright": "1.63.0",
24
32
  "playwright-core": "1.63.0",
33
+ "sharp": "0.35.5",
25
34
  "yaml": "2.9.1",
26
35
  "zod": "4.6.5"
27
36
  },
37
+ "devDependencies": {
38
+ "@hegeldev/hegel": "0.4.7"
39
+ },
28
40
  "scripts": {
29
- "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",
41
+ "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",
30
42
  "typecheck": "tsc --noEmit"
31
43
  }
32
44
  }