@plune-ai/cairn 0.7.0 → 0.9.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/README.md +11 -5
- package/dist/agent/finalize.d.ts +5 -0
- package/dist/agent/finalize.d.ts.map +1 -1
- package/dist/agent/finalize.js +5 -1
- package/dist/agent/finalize.js.map +1 -1
- package/dist/agent/graph.d.ts +9 -0
- package/dist/agent/graph.d.ts.map +1 -1
- package/dist/agent/graph.js +10 -2
- package/dist/agent/graph.js.map +1 -1
- package/dist/agent/index.d.ts +23 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +167 -43
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/repair-loop.d.ts +17 -1
- package/dist/agent/repair-loop.d.ts.map +1 -1
- package/dist/agent/repair-loop.js +88 -5
- package/dist/agent/repair-loop.js.map +1 -1
- package/dist/agent/summary.d.ts +7 -2
- package/dist/agent/summary.d.ts.map +1 -1
- package/dist/agent/summary.js +18 -1
- package/dist/agent/summary.js.map +1 -1
- package/dist/api/coverage.d.ts +23 -0
- package/dist/api/coverage.d.ts.map +1 -1
- package/dist/api/coverage.js +56 -2
- package/dist/api/coverage.js.map +1 -1
- package/dist/api/guard.d.ts +125 -0
- package/dist/api/guard.d.ts.map +1 -0
- package/dist/api/guard.js +284 -0
- package/dist/api/guard.js.map +1 -0
- package/dist/api/runner.d.ts +16 -0
- package/dist/api/runner.d.ts.map +1 -1
- package/dist/api/runner.js +123 -11
- package/dist/api/runner.js.map +1 -1
- package/dist/api/scenario-runner.d.ts +2 -0
- package/dist/api/scenario-runner.d.ts.map +1 -1
- package/dist/api/scenario-runner.js +10 -4
- package/dist/api/scenario-runner.js.map +1 -1
- package/dist/api/testcase-docs.js +1 -1
- package/dist/api/testcase-docs.js.map +1 -1
- package/dist/artifacts/report.d.ts +16 -2
- package/dist/artifacts/report.d.ts.map +1 -1
- package/dist/artifacts/report.js +47 -9
- package/dist/artifacts/report.js.map +1 -1
- package/dist/browser/backends/playwright-lib.d.ts +4 -5
- package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
- package/dist/browser/backends/playwright-lib.js +25 -11
- package/dist/browser/backends/playwright-lib.js.map +1 -1
- package/dist/browser/index.d.ts +3 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types.d.ts +11 -1
- package/dist/browser/types.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +54 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +101 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +3 -2
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/schema.d.ts +10 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +2 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/core/config.d.ts +7 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +4 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/modalities/api.d.ts.map +1 -1
- package/dist/core/modalities/api.js +116 -28
- package/dist/core/modalities/api.js.map +1 -1
- package/dist/core/modalities/explore.d.ts.map +1 -1
- package/dist/core/modalities/explore.js +12 -3
- package/dist/core/modalities/explore.js.map +1 -1
- package/dist/decider/capabilities.d.ts +15 -0
- package/dist/decider/capabilities.d.ts.map +1 -0
- package/dist/decider/capabilities.js +87 -0
- package/dist/decider/capabilities.js.map +1 -0
- package/dist/decider/client-http.d.ts +27 -0
- package/dist/decider/client-http.d.ts.map +1 -0
- package/dist/decider/client-http.js +134 -0
- package/dist/decider/client-http.js.map +1 -0
- package/dist/decider/guarded.d.ts +18 -0
- package/dist/decider/guarded.d.ts.map +1 -0
- package/dist/decider/guarded.js +48 -0
- package/dist/decider/guarded.js.map +1 -0
- package/dist/decider/index.d.ts +61 -0
- package/dist/decider/index.d.ts.map +1 -0
- package/dist/decider/index.js +191 -0
- package/dist/decider/index.js.map +1 -0
- package/dist/decider/redact.d.ts +6 -0
- package/dist/decider/redact.d.ts.map +1 -0
- package/dist/decider/redact.js +265 -0
- package/dist/decider/redact.js.map +1 -0
- package/dist/decider/types.d.ts +139 -0
- package/dist/decider/types.d.ts.map +1 -0
- package/dist/decider/types.js +21 -0
- package/dist/decider/types.js.map +1 -0
- package/dist/decider/uses/coverage.d.ts +37 -0
- package/dist/decider/uses/coverage.d.ts.map +1 -0
- package/dist/decider/uses/coverage.js +63 -0
- package/dist/decider/uses/coverage.js.map +1 -0
- package/dist/decider/uses/locator-heal.d.ts +69 -0
- package/dist/decider/uses/locator-heal.d.ts.map +1 -0
- package/dist/decider/uses/locator-heal.js +216 -0
- package/dist/decider/uses/locator-heal.js.map +1 -0
- package/dist/decider/uses/repair-triage.d.ts +40 -0
- package/dist/decider/uses/repair-triage.d.ts.map +1 -0
- package/dist/decider/uses/repair-triage.js +94 -0
- package/dist/decider/uses/repair-triage.js.map +1 -0
- package/dist/design/critique.d.ts +1 -1
- package/dist/design/schema.d.ts +3 -3
- package/dist/environment/apply.d.ts +37 -0
- package/dist/environment/apply.d.ts.map +1 -0
- package/dist/environment/apply.js +185 -0
- package/dist/environment/apply.js.map +1 -0
- package/dist/environment/cli.d.ts +15 -0
- package/dist/environment/cli.d.ts.map +1 -0
- package/dist/environment/cli.js +17 -0
- package/dist/environment/cli.js.map +1 -0
- package/dist/environment/config.d.ts +47 -0
- package/dist/environment/config.d.ts.map +1 -0
- package/dist/environment/config.js +135 -0
- package/dist/environment/config.js.map +1 -0
- package/dist/environment/errors.d.ts +20 -0
- package/dist/environment/errors.d.ts.map +1 -0
- package/dist/environment/errors.js +34 -0
- package/dist/environment/errors.js.map +1 -0
- package/dist/environment/index.d.ts +9 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +6 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/environment/redact.d.ts +11 -0
- package/dist/environment/redact.d.ts.map +1 -0
- package/dist/environment/redact.js +30 -0
- package/dist/environment/redact.js.map +1 -0
- package/dist/eval/judge.d.ts +12 -0
- package/dist/eval/judge.d.ts.map +1 -1
- package/dist/eval/judge.js +51 -0
- package/dist/eval/judge.js.map +1 -1
- package/dist/flow/crawl.d.ts +9 -0
- package/dist/flow/crawl.d.ts.map +1 -1
- package/dist/flow/crawl.js +0 -0
- package/dist/flow/crawl.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/cost.d.ts +2 -1
- package/dist/llm/cost.d.ts.map +1 -1
- package/dist/llm/cost.js +5 -4
- package/dist/llm/cost.js.map +1 -1
- package/dist/mailbox/fake.d.ts +15 -0
- package/dist/mailbox/fake.d.ts.map +1 -0
- package/dist/mailbox/fake.js +27 -0
- package/dist/mailbox/fake.js.map +1 -0
- package/dist/mailbox/index.d.ts +16 -0
- package/dist/mailbox/index.d.ts.map +1 -0
- package/dist/mailbox/index.js +36 -0
- package/dist/mailbox/index.js.map +1 -0
- package/dist/mailbox/mailsac.d.ts +38 -0
- package/dist/mailbox/mailsac.d.ts.map +1 -0
- package/dist/mailbox/mailsac.js +83 -0
- package/dist/mailbox/mailsac.js.map +1 -0
- package/dist/mailbox/session.d.ts +65 -0
- package/dist/mailbox/session.d.ts.map +1 -0
- package/dist/mailbox/session.js +119 -0
- package/dist/mailbox/session.js.map +1 -0
- package/dist/mailbox/types.d.ts +29 -0
- package/dist/mailbox/types.d.ts.map +1 -0
- package/dist/mailbox/types.js +2 -0
- package/dist/mailbox/types.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +2 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +9 -8
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +9 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/probe/index.d.ts +13 -1
- package/dist/probe/index.d.ts.map +1 -1
- package/dist/probe/index.js +61 -13
- package/dist/probe/index.js.map +1 -1
- package/dist/safety/guardrails.d.ts +17 -0
- package/dist/safety/guardrails.d.ts.map +1 -1
- package/dist/safety/guardrails.js +29 -2
- package/dist/safety/guardrails.js.map +1 -1
- package/dist/telemetry/index.d.ts +23 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +44 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/totp/index.d.ts +26 -0
- package/dist/totp/index.d.ts.map +1 -0
- package/dist/totp/index.js +59 -0
- package/dist/totp/index.js.map +1 -0
- package/dist/tui/hooks/use-runner.d.ts +1 -1
- package/dist/tui/hooks/use-runner.d.ts.map +1 -1
- package/dist/tui/hooks/use-runner.js +5 -0
- package/dist/tui/hooks/use-runner.js.map +1 -1
- package/dist/tui/screens/run-dashboard-screen.d.ts.map +1 -1
- package/dist/tui/screens/run-dashboard-screen.js +1 -0
- package/dist/tui/screens/run-dashboard-screen.js.map +1 -1
- package/dist/tui/screens/summary-screen.d.ts.map +1 -1
- package/dist/tui/screens/summary-screen.js +10 -1
- package/dist/tui/screens/summary-screen.js.map +1 -1
- package/dist/validate/index.d.ts +7 -0
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +2 -0
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/runner.d.ts +25 -2
- package/dist/validate/runner.d.ts.map +1 -1
- package/dist/validate/runner.js +58 -7
- package/dist/validate/runner.js.map +1 -1
- package/dist/validate/trace-chapters.d.ts +6 -0
- package/dist/validate/trace-chapters.d.ts.map +1 -0
- package/dist/validate/trace-chapters.js +99 -0
- package/dist/validate/trace-chapters.js.map +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* locator-heal (spec §6.6, ADR-0022), v1: after a test fails on a locator, propose a verified replacement in the
|
|
3
|
+
* repair hint. The generated spec stays plain `@playwright/test` — healing happens after the failure, never inside
|
|
4
|
+
* the code. Code reads the broken locator out of Playwright's error and narrows the page's elements to the ones a
|
|
5
|
+
* healer may offer — the same or a compatible role, never a destructive one; the decider only picks among them, and
|
|
6
|
+
* its pick counts only when the browser finds exactly one such element.
|
|
7
|
+
*/
|
|
8
|
+
import type { BrowserGateway } from "../../browser/gateway.js";
|
|
9
|
+
import type { ElementRef } from "../../browser/types.js";
|
|
10
|
+
import type { TestResult } from "../../validate/index.js";
|
|
11
|
+
import type { Decider } from "../types.js";
|
|
12
|
+
import type { TriageResult } from "./repair-triage.js";
|
|
13
|
+
export interface BrokenLocator {
|
|
14
|
+
role: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
/** The `getByRole(…)` text as the error printed it — what the repair hint tells the LLM to replace. */
|
|
17
|
+
source: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The locator a failing test waited for. Nothing to heal from a CSS locator, a regex name, or a chained scope
|
|
21
|
+
* (`getByRole('dialog').getByRole(…)`): a candidate from the whole page may sit outside the scope, and `verify`
|
|
22
|
+
* counts matches on the whole page. A trailing `.first()`, `.last()` or `.nth(i)` is kept out of `source`.
|
|
23
|
+
* Only the first locator in the error counts: a strict-mode violation goes on to list each element it resolved to,
|
|
24
|
+
* with an `aka getByRole(…)` hint that is not the locator that failed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseBrokenLocator(error: string): BrokenLocator | undefined;
|
|
27
|
+
export declare function compatibleRoles(role: string): ReadonlySet<string>;
|
|
28
|
+
/**
|
|
29
|
+
* The elements a healer may offer for a broken locator: interactive, named, of a compatible role, one per role and
|
|
30
|
+
* name. Never one the crawler would refuse to click (`DESTRUCTIVE`) or that reads as deleting data — safety rules
|
|
31
|
+
* are not optional (spec §3.5), so the decider is never even asked about them.
|
|
32
|
+
*/
|
|
33
|
+
export declare function healCandidates(aria: string, broken: BrokenLocator): ElementRef[];
|
|
34
|
+
/** The exact locator the repair hint proposes: `getByRole('button', { name: 'Save', exact: true })`. */
|
|
35
|
+
export declare function locatorText(el: {
|
|
36
|
+
role: string;
|
|
37
|
+
name: string;
|
|
38
|
+
}): string;
|
|
39
|
+
/** All a healer does with a browser: load the page, count matches. */
|
|
40
|
+
export type HealGateway = Pick<BrowserGateway, "observe" | "verify">;
|
|
41
|
+
/**
|
|
42
|
+
* A gateway opened on first use and closed with the run: `automate` has no browser of its own, and most runs never
|
|
43
|
+
* heal anything. A browser that fails to open fails that heal (a fallback), never the run's final `close`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function lazyGateway(open: () => Promise<BrowserGateway>): HealGateway & {
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
};
|
|
48
|
+
/** A proposal for the repair hint: the broken locator and a replacement verified to match one element. */
|
|
49
|
+
export interface HealRecord {
|
|
50
|
+
test: string;
|
|
51
|
+
/** The broken `getByRole(…)`, as the error printed it. */
|
|
52
|
+
from: string;
|
|
53
|
+
to: string;
|
|
54
|
+
confidence: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The healer (spec §6.6). Candidates come from the page as it loads now, not as it was when the test failed: a
|
|
58
|
+
* locator reachable only mid-scenario finds no candidate, or none the decider picks, and goes to repair as today.
|
|
59
|
+
* No verdict, no parse, the cli backend, no candidate, a doubt, a pick that does not match exactly one element, or
|
|
60
|
+
* any failure → undefined, and repair runs as it would have without a decider. Shadow mode asks and verifies,
|
|
61
|
+
* records, and proposes nothing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function makeHeal(opts: {
|
|
64
|
+
decider: Decider;
|
|
65
|
+
/** The lib backend's. The cli one counts no matches (`count -1`), so there a heal asks nothing. */
|
|
66
|
+
gateway: HealGateway;
|
|
67
|
+
url: string;
|
|
68
|
+
}): (failure: TestResult, triage: TriageResult) => Promise<HealRecord | undefined>;
|
|
69
|
+
//# sourceMappingURL=locator-heal.d.ts.map
|
|
@@ -0,0 +1 @@
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1G,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAqBD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,mGAAmG;IACnG,OAAO,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmHjF"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { DESTRUCTIVE } from "../../flow/crawl.js";
|
|
2
|
+
import { parseAriaSnapshot } from "../../observe/parse-aria.js";
|
|
3
|
+
import { isDeletionIntent } from "../../safety/guardrails.js";
|
|
4
|
+
import { checkCaps } from "../capabilities.js";
|
|
5
|
+
/** `getByRole('role')` or `getByRole('role', { name: 'Name'[, exact: true] })`, with ' or " quotes. */
|
|
6
|
+
const GET_BY_ROLE = /getByRole\((['"])([a-z]+)\1(?:,\s*\{\s*name:\s*(['"])((?:\\.|(?!\3)[^\\\n])*)\3(?:,\s*exact:\s*(?:true|false))?\s*\})?\)/;
|
|
7
|
+
/** Playwright colours its output; the codes are not part of what it says. */
|
|
8
|
+
const plain = (error) => error.replace(/\u001b\[[0-9;]*m/g, "");
|
|
9
|
+
/** A locator expression. The first one in an error is the one that failed. */
|
|
10
|
+
const ANY_LOCATOR = /\b(?:getBy[A-Z]\w*|locator|frameLocator)\(/;
|
|
11
|
+
/**
|
|
12
|
+
* The locator a failing test waited for. Nothing to heal from a CSS locator, a regex name, or a chained scope
|
|
13
|
+
* (`getByRole('dialog').getByRole(…)`): a candidate from the whole page may sit outside the scope, and `verify`
|
|
14
|
+
* counts matches on the whole page. A trailing `.first()`, `.last()` or `.nth(i)` is kept out of `source`.
|
|
15
|
+
* Only the first locator in the error counts: a strict-mode violation goes on to list each element it resolved to,
|
|
16
|
+
* with an `aka getByRole(…)` hint that is not the locator that failed.
|
|
17
|
+
*/
|
|
18
|
+
export function parseBrokenLocator(error) {
|
|
19
|
+
const text = plain(error);
|
|
20
|
+
const m = GET_BY_ROLE.exec(text);
|
|
21
|
+
if (!m || ANY_LOCATOR.exec(text)?.index !== m.index)
|
|
22
|
+
return undefined;
|
|
23
|
+
const after = text.slice(m.index + m[0].length);
|
|
24
|
+
if (/^\.(?!first\(\)|last\(\)|nth\()/.test(after))
|
|
25
|
+
return undefined; // a scope before it is a first locator already
|
|
26
|
+
const name = m[4]?.replace(/\\(.)/g, "$1");
|
|
27
|
+
return { role: m[2], ...(name !== undefined ? { name } : {}), source: m[0] };
|
|
28
|
+
}
|
|
29
|
+
/** Roles one element can be swapped for without changing what the step does. */
|
|
30
|
+
const ROLE_FAMILIES = [
|
|
31
|
+
["textbox", "searchbox", "combobox"],
|
|
32
|
+
["checkbox", "switch"],
|
|
33
|
+
["menuitem", "menuitemcheckbox", "menuitemradio"],
|
|
34
|
+
];
|
|
35
|
+
export function compatibleRoles(role) {
|
|
36
|
+
return new Set(ROLE_FAMILIES.find((f) => f.includes(role)) ?? [role]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The elements a healer may offer for a broken locator: interactive, named, of a compatible role, one per role and
|
|
40
|
+
* name. Never one the crawler would refuse to click (`DESTRUCTIVE`) or that reads as deleting data — safety rules
|
|
41
|
+
* are not optional (spec §3.5), so the decider is never even asked about them.
|
|
42
|
+
*/
|
|
43
|
+
export function healCandidates(aria, broken) {
|
|
44
|
+
const roles = compatibleRoles(broken.role);
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
return parseAriaSnapshot(aria).filter((e) => {
|
|
47
|
+
const name = e.name?.trim();
|
|
48
|
+
if (!e.interactive || !name || !roles.has(e.role))
|
|
49
|
+
return false;
|
|
50
|
+
if (DESTRUCTIVE.test(name) || isDeletionIntent(name))
|
|
51
|
+
return false;
|
|
52
|
+
const key = `${e.role}\n${name}`;
|
|
53
|
+
if (seen.has(key))
|
|
54
|
+
return false;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const quote = (s) => `'${s.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
60
|
+
/** The exact locator the repair hint proposes: `getByRole('button', { name: 'Save', exact: true })`. */
|
|
61
|
+
export function locatorText(el) {
|
|
62
|
+
return `getByRole(${quote(el.role)}, { name: ${quote(el.name)}, exact: true })`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A gateway opened on first use and closed with the run: `automate` has no browser of its own, and most runs never
|
|
66
|
+
* heal anything. A browser that fails to open fails that heal (a fallback), never the run's final `close`.
|
|
67
|
+
*/
|
|
68
|
+
export function lazyGateway(open) {
|
|
69
|
+
let gw;
|
|
70
|
+
const get = () => (gw ??= open());
|
|
71
|
+
return {
|
|
72
|
+
observe: async (o) => (await get()).observe(o),
|
|
73
|
+
verify: async (els) => (await get()).verify(els),
|
|
74
|
+
close: async () => {
|
|
75
|
+
await gw?.then((g) => g.close(), () => undefined);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Only what triage called a locator failure is healed (spec §6.6 step 1). */
|
|
80
|
+
const HEALABLE = new Set(["locator-missing", "locator-ambiguous"]);
|
|
81
|
+
const NONE = "none-of-these";
|
|
82
|
+
const PICK_INSTRUCTIONS = "Which element on the page did the failing locator mean?";
|
|
83
|
+
const SCORE_LEVELS = ["Unrelated to the failing step", "Plausible", "Clearly the element the step meant"];
|
|
84
|
+
/** The failure in one line. With a question of at most 400 chars (laya) it stays inside every provider's input cap. */
|
|
85
|
+
const MAX_STATE_CHARS = 500;
|
|
86
|
+
/** The two-stage path (spec §6.6, laya): at most the ten best-scored candidates go into the final choice. */
|
|
87
|
+
const MAX_FINALISTS = 10;
|
|
88
|
+
const clip = (s, n) => (s.length <= n ? s : `${s.slice(0, n - 1)}…`);
|
|
89
|
+
/**
|
|
90
|
+
* The healer (spec §6.6). Candidates come from the page as it loads now, not as it was when the test failed: a
|
|
91
|
+
* locator reachable only mid-scenario finds no candidate, or none the decider picks, and goes to repair as today.
|
|
92
|
+
* No verdict, no parse, the cli backend, no candidate, a doubt, a pick that does not match exactly one element, or
|
|
93
|
+
* any failure → undefined, and repair runs as it would have without a decider. Shadow mode asks and verifies,
|
|
94
|
+
* records, and proposes nothing.
|
|
95
|
+
*/
|
|
96
|
+
export function makeHeal(opts) {
|
|
97
|
+
const { decider, gateway, url } = opts;
|
|
98
|
+
const { caps } = decider;
|
|
99
|
+
// ponytail: room for labels up to "c999: " — a page with more candidates would still be refused whole, by checkCaps.
|
|
100
|
+
const room = caps.maxOptionChars - 6;
|
|
101
|
+
const choice = (offered) => ({
|
|
102
|
+
type: "choice",
|
|
103
|
+
instructions: PICK_INSTRUCTIONS,
|
|
104
|
+
options: { ...Object.fromEntries(offered.map((o) => [o.label, o.text])), [NONE]: "the element it meant is not in this list" },
|
|
105
|
+
});
|
|
106
|
+
const fits = (state, q) => {
|
|
107
|
+
try {
|
|
108
|
+
checkCaps(caps, state, { pick: q });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Too many candidates for one choice: score each, in calls of at most `maxQuestionsPerCall`, keep the best that fit. */
|
|
116
|
+
const shortlist = async (state, offered) => {
|
|
117
|
+
const score = new Map();
|
|
118
|
+
for (let i = 0; i < offered.length; i += caps.maxQuestionsPerCall) {
|
|
119
|
+
const chunk = offered.slice(i, i + caps.maxQuestionsPerCall);
|
|
120
|
+
const questions = Object.fromEntries(chunk.map((o) => [
|
|
121
|
+
o.label,
|
|
122
|
+
{ type: "score", instructions: `How well does ${o.text} match the element the failing locator meant?`, levels: SCORE_LEVELS },
|
|
123
|
+
]));
|
|
124
|
+
const answers = await decider.decide("locator-heal", state, questions);
|
|
125
|
+
for (const o of chunk) {
|
|
126
|
+
const a = answers[o.label];
|
|
127
|
+
if (a?.type === "score")
|
|
128
|
+
score.set(o.label, a.value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const ranked = [...offered].sort((a, b) => (score.get(b.label) ?? -1) - (score.get(a.label) ?? -1)); // stable: ties keep page order
|
|
132
|
+
const finalists = [];
|
|
133
|
+
for (const o of ranked) {
|
|
134
|
+
if (finalists.length === MAX_FINALISTS || !fits(state, choice([...finalists, o])))
|
|
135
|
+
break;
|
|
136
|
+
finalists.push(o);
|
|
137
|
+
}
|
|
138
|
+
return finalists;
|
|
139
|
+
};
|
|
140
|
+
/** One broken locator, asked about for the first test that failed on it. */
|
|
141
|
+
const heal = async (failure, ambiguous, broken) => {
|
|
142
|
+
const input = { state: "", candidates: [] };
|
|
143
|
+
// The decider's time alone, as the other use points record it: opening the page and the check are not in it.
|
|
144
|
+
let asked = 0;
|
|
145
|
+
let answered = 0;
|
|
146
|
+
// A no-op for an active decider, so every path below returns through it.
|
|
147
|
+
const record = (d, confidence) => {
|
|
148
|
+
decider.shadow?.record({
|
|
149
|
+
use: "locator-heal",
|
|
150
|
+
input,
|
|
151
|
+
current: "repair",
|
|
152
|
+
decider: d,
|
|
153
|
+
...(confidence !== undefined ? { confidence } : {}),
|
|
154
|
+
latencyMs: asked ? (answered || Date.now()) - asked : 0,
|
|
155
|
+
});
|
|
156
|
+
return undefined;
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
159
|
+
const what = ambiguous ? "matched several elements" : "matched no element";
|
|
160
|
+
// The locator first: a clip cuts the tail, and a long test name must not cut what the decider picks by.
|
|
161
|
+
input.state = clip(decider.scrub(`Locator ${broken.source} ${what} in Playwright test "${failure.test}".`), MAX_STATE_CHARS);
|
|
162
|
+
const { ariaSnapshot, capturedBy } = await gateway.observe({ url });
|
|
163
|
+
if (capturedBy !== "lib")
|
|
164
|
+
return undefined; // the cli backend counts no matches: no pick could be checked
|
|
165
|
+
const offered = healCandidates(ariaSnapshot, broken).map((el, i) => ({ el, label: `c${i + 1}`, text: clip(decider.scrub(`${el.role} "${el.name}"`), room) }));
|
|
166
|
+
if (offered.length === 0)
|
|
167
|
+
return undefined; // nothing to ask about
|
|
168
|
+
input.candidates = offered.map((o) => o.text);
|
|
169
|
+
asked = Date.now();
|
|
170
|
+
const finalists = fits(input.state, choice(offered)) ? offered : await shortlist(input.state, offered);
|
|
171
|
+
const a = (await decider.decide("locator-heal", input.state, { pick: choice(finalists) })).pick;
|
|
172
|
+
answered = Date.now();
|
|
173
|
+
if (a?.type !== "choice")
|
|
174
|
+
throw new Error("an answer of the wrong type");
|
|
175
|
+
if (a.value === NONE)
|
|
176
|
+
return record({ to: null, confidence: a.confidence }, a.confidence);
|
|
177
|
+
const chosen = finalists.find((o) => o.label === a.value);
|
|
178
|
+
if (!chosen)
|
|
179
|
+
throw new Error(`an answer outside the offered candidates: '${a.value}'`); // never trust an unoffered label
|
|
180
|
+
if (!decider.shadow && a.confidence < decider.minConfidence)
|
|
181
|
+
return undefined;
|
|
182
|
+
const [v] = await gateway.verify([chosen.el]);
|
|
183
|
+
const to = locatorText({ role: chosen.el.role, name: chosen.el.name ?? "" });
|
|
184
|
+
if (decider.shadow)
|
|
185
|
+
return record({ to, confidence: a.confidence, verified: v?.count === 1 }, a.confidence);
|
|
186
|
+
return v?.count === 1 ? { to, confidence: a.confidence } : undefined;
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
return record({ unavailable: e instanceof Error ? e.message : String(e) });
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
// A named element that went missing (renamed, say) is the same element for every test that asked for it, so those
|
|
193
|
+
// tests share one heal: one question, check and answer (a renamed login button can fail every test). Which of
|
|
194
|
+
// several matches a test meant, or which unnamed element, depends on the test: asked per test.
|
|
195
|
+
// ponytail: a single heal still costs ceil(candidates / maxQuestionsPerCall) + 1 calls on a page too big for one
|
|
196
|
+
// choice; DECIDER_MAX_CALLS bounds the run, cap the candidates if pilots meet such pages.
|
|
197
|
+
const heals = new Map();
|
|
198
|
+
return async (failure, triage) => {
|
|
199
|
+
if (!HEALABLE.has(triage.category))
|
|
200
|
+
return undefined;
|
|
201
|
+
const broken = parseBrokenLocator(failure.error ?? "");
|
|
202
|
+
if (!broken)
|
|
203
|
+
return undefined;
|
|
204
|
+
// Several matches or none is what Playwright's error says, not what triage (a model) called it — a wrong verdict
|
|
205
|
+
// must not make a heal shared. The key is what the question is built from.
|
|
206
|
+
const ambiguous = /strict mode violation/.test(plain(failure.error ?? ""));
|
|
207
|
+
const shared = !ambiguous && broken.name !== undefined;
|
|
208
|
+
const key = `${ambiguous}\n${broken.source}${shared ? "" : `\n${failure.test}`}`;
|
|
209
|
+
let proposal = heals.get(key);
|
|
210
|
+
if (!proposal)
|
|
211
|
+
heals.set(key, (proposal = heal(failure, ambiguous, broken)));
|
|
212
|
+
const p = await proposal;
|
|
213
|
+
return p && { test: failure.test, from: broken.source, ...p };
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=locator-heal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator-heal.js","sourceRoot":"","sources":["../../../src/decider/uses/locator-heal.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/C,uGAAuG;AACvG,MAAM,WAAW,GACf,0HAA0H,CAAC;AAE7H,6EAA6E;AAC7E,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAA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
|
|
|
1
|
+
import type { TestResult } from "../../validate/index.js";
|
|
2
|
+
import type { Decider, Question } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* repair-triage (spec §6.1, ADR-0022): why did a generated test fail? A confident "the app is broken" or
|
|
5
|
+
* "the environment is broken" keeps the test out of the repair hint — repairing test code cannot fix
|
|
6
|
+
* either — and the run reports it instead. Every other confident category only tags the hint.
|
|
7
|
+
*/
|
|
8
|
+
export type FailureCategory = "locator-ambiguous" | "locator-missing" | "timing" | "wrong-assertion" | "app-bug" | "env-or-session";
|
|
9
|
+
/**
|
|
10
|
+
* label → when it applies. Sent as the choice's criteria: the descriptions are what the model decides by.
|
|
11
|
+
* Short on purpose — the whole question must fit laya's 400-character question cap (capabilities.ts). A
|
|
12
|
+
* "wrong result" belongs to wrong-assertion only: when it is unclear whose fault it is, repair it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FAILURE_CATEGORIES: Record<FailureCategory, string>;
|
|
15
|
+
export declare const TRIAGE_QUESTION: Question;
|
|
16
|
+
export interface TriageResult {
|
|
17
|
+
test: string;
|
|
18
|
+
category: FailureCategory;
|
|
19
|
+
confidence: number;
|
|
20
|
+
/** true → left out of the repair hint and reported as not repaired. */
|
|
21
|
+
exclude: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The test's name and its error, colour codes stripped, scrubbed, THEN clipped to fit `maxChars` whole — clipping
|
|
25
|
+
* first could cut a secret in half, and the half left would no longer match what the scrubber looks for.
|
|
26
|
+
*/
|
|
27
|
+
export declare function triageState(r: TestResult, maxChars: number, scrub: (text: string) => string): string;
|
|
28
|
+
/**
|
|
29
|
+
* One call per failed test, each over its own state, run concurrently (a hanging server costs one timeout,
|
|
30
|
+
* not one per test; the per-run ceiling still holds). Only a confident answer counts; a failure or a doubt
|
|
31
|
+
* leaves the test in the hint exactly as today. Shadow mode records each answer next to "repair" and
|
|
32
|
+
* returns nothing — so the loop runs as it would have without a decider.
|
|
33
|
+
*
|
|
34
|
+
* `next` — shadow mode only: the use point that acts on triage's verdict (locator-heal). Returning nothing,
|
|
35
|
+
* triage leaves the loop no verdict to hand on, so it asks `next` itself on every verdict it would have given,
|
|
36
|
+
* at any confidence (the pilot calibrates the threshold), one at a time (they share one browser page). An
|
|
37
|
+
* active loop asks `next` itself.
|
|
38
|
+
*/
|
|
39
|
+
export declare function makeTriage(decider: Decider, next?: (failure: TestResult, verdict: TriageResult) => Promise<unknown>): (failed: TestResult[]) => Promise<TriageResult[]>;
|
|
40
|
+
//# sourceMappingURL=repair-triage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-triage.d.ts","sourceRoot":"","sources":["../../../src/decider/uses/repair-triage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAU,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,QAAQ,GAAG,iBAAiB,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAEpI;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAO9D,CAAC;AAQF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAKpG;AAgBD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,GACtE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC,CA6CnD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { questionChars } from "../capabilities.js";
|
|
2
|
+
/**
|
|
3
|
+
* label → when it applies. Sent as the choice's criteria: the descriptions are what the model decides by.
|
|
4
|
+
* Short on purpose — the whole question must fit laya's 400-character question cap (capabilities.ts). A
|
|
5
|
+
* "wrong result" belongs to wrong-assertion only: when it is unclear whose fault it is, repair it.
|
|
6
|
+
*/
|
|
7
|
+
export const FAILURE_CATEGORIES = {
|
|
8
|
+
"locator-ambiguous": "locator matched several elements (strict mode)",
|
|
9
|
+
"locator-missing": "locator found no element, or it was hidden",
|
|
10
|
+
timing: "page not ready yet: navigation, data, animation",
|
|
11
|
+
"wrong-assertion": "page worked, but a different result was expected",
|
|
12
|
+
"app-bug": "the app failed: server error, crash, error page",
|
|
13
|
+
"env-or-session": "environment failed: session expired, server unreachable",
|
|
14
|
+
};
|
|
15
|
+
/** Categories a confident answer keeps out of repair — the only direction a decider may push (ADR-0020). */
|
|
16
|
+
const NOT_REPAIRABLE = new Set(["app-bug", "env-or-session"]);
|
|
17
|
+
/** Playwright's own call log follows the cause; beyond this the tokens buy nothing (and cost money on jev). */
|
|
18
|
+
const MAX_STATE_CHARS = 2000;
|
|
19
|
+
export const TRIAGE_QUESTION = {
|
|
20
|
+
type: "choice",
|
|
21
|
+
instructions: "Why did this Playwright test fail?",
|
|
22
|
+
options: FAILURE_CATEGORIES,
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The test's name and its error, colour codes stripped, scrubbed, THEN clipped to fit `maxChars` whole — clipping
|
|
26
|
+
* first could cut a secret in half, and the half left would no longer match what the scrubber looks for.
|
|
27
|
+
*/
|
|
28
|
+
export function triageState(r, maxChars, scrub) {
|
|
29
|
+
const head = `Playwright test "${r.test}" failed.\nError:\n`;
|
|
30
|
+
const error = (r.error ?? "(no error message)").replace(/\u001b\[[0-9;]*m/g, "").trim();
|
|
31
|
+
const full = scrub(head + error);
|
|
32
|
+
return full.length <= maxChars ? full : `${full.slice(0, maxChars - 1)}…`;
|
|
33
|
+
}
|
|
34
|
+
function asCategory(a) {
|
|
35
|
+
if (a?.type !== "choice" || !Object.hasOwn(FAILURE_CATEGORIES, a.value))
|
|
36
|
+
return undefined; // never trust an unoffered label
|
|
37
|
+
return { category: a.value, confidence: a.confidence };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One call per failed test, each over its own state, run concurrently (a hanging server costs one timeout,
|
|
41
|
+
* not one per test; the per-run ceiling still holds). Only a confident answer counts; a failure or a doubt
|
|
42
|
+
* leaves the test in the hint exactly as today. Shadow mode records each answer next to "repair" and
|
|
43
|
+
* returns nothing — so the loop runs as it would have without a decider.
|
|
44
|
+
*
|
|
45
|
+
* `next` — shadow mode only: the use point that acts on triage's verdict (locator-heal). Returning nothing,
|
|
46
|
+
* triage leaves the loop no verdict to hand on, so it asks `next` itself on every verdict it would have given,
|
|
47
|
+
* at any confidence (the pilot calibrates the threshold), one at a time (they share one browser page). An
|
|
48
|
+
* active loop asks `next` itself.
|
|
49
|
+
*/
|
|
50
|
+
export function makeTriage(decider, next) {
|
|
51
|
+
// The provider reads the state together with the question: the error gets what the question leaves.
|
|
52
|
+
const maxChars = Math.min(decider.caps.maxInputChars - questionChars(TRIAGE_QUESTION), MAX_STATE_CHARS);
|
|
53
|
+
return async (failed) => {
|
|
54
|
+
const asked = await Promise.all(failed.map(async (r) => {
|
|
55
|
+
const t0 = Date.now();
|
|
56
|
+
let state = "";
|
|
57
|
+
try {
|
|
58
|
+
state = triageState(r, maxChars, decider.scrub); // inside the try: a scrubbing failure is a fallback
|
|
59
|
+
const answers = await decider.decide("repair-triage", state, { cause: TRIAGE_QUESTION });
|
|
60
|
+
const c = asCategory(answers.cause);
|
|
61
|
+
return { r, state, latencyMs: Date.now() - t0, ...(c ? { c } : { reason: "an answer outside the offered categories" }) };
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
return { r, state, latencyMs: Date.now() - t0, reason: e instanceof Error ? e.message : String(e) };
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
const confident = (c) => c.confidence >= decider.minConfidence;
|
|
68
|
+
if (decider.shadow) {
|
|
69
|
+
for (const a of asked) {
|
|
70
|
+
decider.shadow.record({
|
|
71
|
+
use: "repair-triage",
|
|
72
|
+
input: a.state,
|
|
73
|
+
current: "repair",
|
|
74
|
+
decider: a.c
|
|
75
|
+
? { category: a.c.category, confidence: a.c.confidence, wouldExclude: confident(a.c) && NOT_REPAIRABLE.has(a.c.category) }
|
|
76
|
+
: { unavailable: a.reason },
|
|
77
|
+
...(a.c ? { confidence: a.c.confidence } : {}),
|
|
78
|
+
latencyMs: a.latencyMs,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
for (const a of asked) {
|
|
82
|
+
if (!a.c || !next)
|
|
83
|
+
continue;
|
|
84
|
+
const verdict = { test: a.r.test, ...a.c, exclude: confident(a.c) && NOT_REPAIRABLE.has(a.c.category) };
|
|
85
|
+
await next(a.r, verdict).catch(() => undefined); // shadow bookkeeping never throws into the run
|
|
86
|
+
}
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
return asked.flatMap((a) => a.c && confident(a.c)
|
|
90
|
+
? [{ test: a.r.test, category: a.c.category, confidence: a.c.confidence, exclude: NOT_REPAIRABLE.has(a.c.category) }]
|
|
91
|
+
: []);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=repair-triage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-triage.js","sourceRoot":"","sources":["../../../src/decider/uses/repair-triage.ts"],"names":[],"mappings":"AACA,OAA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,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxG,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,+CAA+C;YAClG,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACzB,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrH,CAAC,CAAC,EAAE,CACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -58,8 +58,8 @@ export declare const CritiqueResultSchema: z.ZodObject<{
|
|
|
58
58
|
Negative: "Negative";
|
|
59
59
|
}>>;
|
|
60
60
|
execution: z.ZodDefault<z.ZodEnum<{
|
|
61
|
-
auto: "auto";
|
|
62
61
|
manual: "manual";
|
|
62
|
+
auto: "auto";
|
|
63
63
|
}>>;
|
|
64
64
|
preconditions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
65
65
|
steps: z.ZodArray<z.ZodString>;
|
package/dist/design/schema.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export declare const TestTypeSchema: z.ZodEnum<{
|
|
|
29
29
|
* manual = manual (full generation/submit, security/XSS, UI-UX/visual, irreversible actions) → MTC, NOT automated.
|
|
30
30
|
*/
|
|
31
31
|
export declare const TestExecutionSchema: z.ZodEnum<{
|
|
32
|
-
auto: "auto";
|
|
33
32
|
manual: "manual";
|
|
33
|
+
auto: "auto";
|
|
34
34
|
}>;
|
|
35
35
|
/** A case as returned by the LLM (without id — we assign the id ourselves). */
|
|
36
36
|
export declare const DesignedCaseSchema: z.ZodObject<{
|
|
@@ -52,8 +52,8 @@ export declare const DesignedCaseSchema: z.ZodObject<{
|
|
|
52
52
|
Negative: "Negative";
|
|
53
53
|
}>>;
|
|
54
54
|
execution: z.ZodDefault<z.ZodEnum<{
|
|
55
|
-
auto: "auto";
|
|
56
55
|
manual: "manual";
|
|
56
|
+
auto: "auto";
|
|
57
57
|
}>>;
|
|
58
58
|
preconditions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
59
59
|
steps: z.ZodArray<z.ZodString>;
|
|
@@ -87,8 +87,8 @@ export declare const DesignResultSchema: z.ZodObject<{
|
|
|
87
87
|
Negative: "Negative";
|
|
88
88
|
}>>;
|
|
89
89
|
execution: z.ZodDefault<z.ZodEnum<{
|
|
90
|
-
auto: "auto";
|
|
91
90
|
manual: "manual";
|
|
91
|
+
auto: "auto";
|
|
92
92
|
}>>;
|
|
93
93
|
preconditions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
94
94
|
steps: z.ZodArray<z.ZodString>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { HttpCredentials, StorageState } from "../browser/index.js";
|
|
2
|
+
import { type Environment } from "./config.js";
|
|
3
|
+
type EnvRecord = Record<string, string | undefined>;
|
|
4
|
+
export interface ApplyOptions {
|
|
5
|
+
processEnv?: EnvRecord;
|
|
6
|
+
/** Progress sink. Every message is redacted before it gets here. */
|
|
7
|
+
onProgress?: (event: string) => void;
|
|
8
|
+
headless?: boolean;
|
|
9
|
+
channel?: string;
|
|
10
|
+
/** A saved session was supplied (`--session*`): the login stage is skipped, the session stays in charge. */
|
|
11
|
+
skipLogin?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AppliedEnvironment {
|
|
14
|
+
/** Where the run starts: baseUrl + startPath (or baseUrl alone). */
|
|
15
|
+
startUrl: string;
|
|
16
|
+
/** Session after the login stage (absent when login was skipped). */
|
|
17
|
+
storageState?: StorageState;
|
|
18
|
+
/** Basic Auth values for the browser context. */
|
|
19
|
+
httpCredentials?: HttpCredentials;
|
|
20
|
+
/** Names of the variables holding Basic Auth — for the generated Playwright config, which reads process.env itself. */
|
|
21
|
+
httpCredentialsEnv?: {
|
|
22
|
+
usernameVar: string;
|
|
23
|
+
passwordVar: string;
|
|
24
|
+
};
|
|
25
|
+
/** Secret values of this environment, for redacting everything else the run writes. */
|
|
26
|
+
secrets: string[];
|
|
27
|
+
}
|
|
28
|
+
/** baseUrl + startPath (or baseUrl alone) — where a run starts. */
|
|
29
|
+
export declare function startUrlOf(environment: Environment): string;
|
|
30
|
+
export declare function applyEnvironment(environment: Environment, opts?: ApplyOptions): Promise<AppliedEnvironment>;
|
|
31
|
+
/**
|
|
32
|
+
* Writes a session to a private temp file for the validation runner (`use.storageState`) and removes it when the
|
|
33
|
+
* process exits. The file holds session cookies, so it never goes into the run dir (which gets uploaded as an artifact).
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeTempSession(state: StorageState): string;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/environment/apply.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAsB,KAAK,WAAW,EAA4B,MAAM,aAAa,CAAC;AAI7F,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC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