@jevitate/cli 0.4.0 → 0.6.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/dist/author-journey-cli.d.ts +2 -0
- package/dist/author-journey-cli.js +106 -11
- package/dist/author-journey-cli.js.map +1 -1
- package/dist/bin.js +2988 -776
- package/dist/build-info.generated.js +2 -2
- package/dist/check-execute.js +1 -0
- package/dist/check-execute.js.map +1 -1
- package/dist/check-plan.js +2 -1
- package/dist/check-plan.js.map +1 -1
- package/dist/check-suite.d.ts +6 -6
- package/dist/check-suite.js +18 -12
- package/dist/check-suite.js.map +1 -1
- package/dist/cli-shared.d.ts +5 -2
- package/dist/cli-shared.js +10 -3
- package/dist/cli-shared.js.map +1 -1
- package/dist/conversation-options.d.ts +3 -0
- package/dist/conversation-options.js +1 -0
- package/dist/conversation-options.js.map +1 -1
- package/dist/demo-aspect-api.js +2 -0
- package/dist/demo-aspect-api.js.map +1 -1
- package/dist/demo-capture.d.ts +16 -4
- package/dist/demo-capture.js +82 -15
- package/dist/demo-capture.js.map +1 -1
- package/dist/exit-codes.d.ts +1 -1
- package/dist/exit-codes.js +1 -1
- package/dist/explore-author.d.ts +28 -6
- package/dist/explore-author.js +66 -32
- package/dist/explore-author.js.map +1 -1
- package/dist/explore-cli.js +68 -79
- package/dist/explore-cli.js.map +1 -1
- package/dist/explore-goal.d.ts +5 -1
- package/dist/explore-goal.js +19 -1
- package/dist/explore-goal.js.map +1 -1
- package/dist/explore-specs.js +12 -2
- package/dist/explore-specs.js.map +1 -1
- package/dist/goal-run-flags.d.ts +120 -0
- package/dist/goal-run-flags.js +220 -0
- package/dist/goal-run-flags.js.map +1 -0
- package/dist/journey-api.js +4 -1
- package/dist/journey-api.js.map +1 -1
- package/dist/journey-network-checks.d.ts +15 -0
- package/dist/journey-network-checks.js +36 -0
- package/dist/journey-network-checks.js.map +1 -0
- package/dist/kill-signal.d.ts +30 -3
- package/dist/kill-signal.js +51 -6
- package/dist/kill-signal.js.map +1 -1
- package/dist/mcp-api.js +8 -4
- package/dist/mcp-api.js.map +1 -1
- package/dist/mcp-cli-tools.js +43 -5
- package/dist/mcp-cli-tools.js.map +1 -1
- package/dist/mission-queue-cli.js +3 -1
- package/dist/mission-queue-cli.js.map +1 -1
- package/dist/secret-command.d.ts +7 -0
- package/dist/secret-command.js +52 -0
- package/dist/secret-command.js.map +1 -0
- package/dist/signal-triage.js +5 -1
- package/dist/signal-triage.js.map +1 -1
- package/dist/source-run-api.js +3 -1
- package/dist/source-run-api.js.map +1 -1
- package/dist/suite-explore-options.d.ts +9 -0
- package/dist/suite-explore-options.js +5 -0
- package/dist/suite-explore-options.js.map +1 -1
- package/dist/target-config.d.ts +3 -1
- package/dist/target-config.js +6 -0
- package/dist/target-config.js.map +1 -1
- package/dist/usability-capture.js +21 -3
- package/dist/usability-capture.js.map +1 -1
- package/dist/ux-usability.d.ts +5 -1
- package/dist/ux-usability.js +19 -2
- package/dist/ux-usability.js.map +1 -1
- package/package.json +7 -7
- package/skills/jevitate-explore/SKILL.md +7 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #369: the goal run's run-shaping flags, shared by `jevitate explore` (goal/usability) and
|
|
3
|
+
* `jevitate explore-author-journey` (whose discovery and corroborating takes ARE goal runs) — one
|
|
4
|
+
* definition of each flag (text, parser, default) and one resolver, so the two commands accept and
|
|
5
|
+
* validate the same setup and an author run can reproduce what a goal run needed.
|
|
6
|
+
*/
|
|
7
|
+
import { Option } from "commander";
|
|
8
|
+
import { type DialogPolicy, type SecretField, type SuccessWhen, type TypeFixture } from "@jevitate/explore";
|
|
9
|
+
import type { EmulationSpec } from "@jevitate/playwright";
|
|
10
|
+
import type { ConversationOptions } from "./conversation-options.js";
|
|
11
|
+
import { type ScreenshotsSpec } from "./run-screenshots.js";
|
|
12
|
+
import { type TargetConfig, type TargetFlags } from "./target-config.js";
|
|
13
|
+
import { type EmulationFlags, type ScreenshotsFlags } from "./cli-shared.js";
|
|
14
|
+
import type { SecretCommandRunner } from "@jevitate/explore";
|
|
15
|
+
/** Each shared flag, built fresh per command (commander owns an `Option` once added). */
|
|
16
|
+
export declare const GOAL_RUN_OPTIONS: {
|
|
17
|
+
readonly successWhen: () => Option;
|
|
18
|
+
readonly allowVacuousChecks: () => Option;
|
|
19
|
+
readonly actionDeltas: () => Option;
|
|
20
|
+
readonly secret: () => Option;
|
|
21
|
+
readonly secretField: () => Option;
|
|
22
|
+
readonly totp: () => Option;
|
|
23
|
+
readonly typeFixture: () => Option;
|
|
24
|
+
readonly fixture: () => Option;
|
|
25
|
+
readonly saveStorageState: () => Option;
|
|
26
|
+
readonly replyWaitMs: () => Option;
|
|
27
|
+
readonly replyQuietMs: () => Option;
|
|
28
|
+
readonly replyCeilingMs: () => Option;
|
|
29
|
+
readonly replyMaxChars: () => Option;
|
|
30
|
+
readonly jobWaitMs: () => Option;
|
|
31
|
+
readonly deny: () => Option;
|
|
32
|
+
readonly paid: () => Option;
|
|
33
|
+
readonly allowDestructive: () => Option;
|
|
34
|
+
readonly dialogs: () => Option;
|
|
35
|
+
readonly readRpc: () => Option;
|
|
36
|
+
readonly hangReplays: () => Option;
|
|
37
|
+
readonly settleIgnore: () => Option;
|
|
38
|
+
readonly longPollMs: () => Option;
|
|
39
|
+
readonly apiPrefix: () => Option;
|
|
40
|
+
readonly ignoreNoProgress: () => Option;
|
|
41
|
+
readonly allowSecretCmd: () => Option;
|
|
42
|
+
readonly secretCmdAttempts: () => Option;
|
|
43
|
+
};
|
|
44
|
+
export type GoalRunOptionName = keyof typeof GOAL_RUN_OPTIONS;
|
|
45
|
+
/** The flags (commander-parsed) the resolvers below read. */
|
|
46
|
+
export interface GoalRunFlags extends EmulationFlags, ScreenshotsFlags {
|
|
47
|
+
successWhen?: string;
|
|
48
|
+
allowVacuousChecks?: boolean;
|
|
49
|
+
actionDeltas?: boolean;
|
|
50
|
+
secret: string[];
|
|
51
|
+
secretField: string[];
|
|
52
|
+
totp: string[];
|
|
53
|
+
allowSecretCmd?: boolean;
|
|
54
|
+
secretCmdAttempts?: number;
|
|
55
|
+
typeFixture: string[];
|
|
56
|
+
fixture?: string;
|
|
57
|
+
saveStorageState?: string;
|
|
58
|
+
replyWaitMs?: string | number;
|
|
59
|
+
replyQuietMs?: string | number;
|
|
60
|
+
replyCeilingMs?: string | number;
|
|
61
|
+
replyMaxChars?: string | number;
|
|
62
|
+
jobWaitMs?: string | number;
|
|
63
|
+
deny: string[];
|
|
64
|
+
paid: string[];
|
|
65
|
+
allowDestructive?: boolean;
|
|
66
|
+
dialogs?: string;
|
|
67
|
+
readRpc: string[];
|
|
68
|
+
hangReplays?: number;
|
|
69
|
+
settleIgnore: string[];
|
|
70
|
+
longPollMs?: string | number;
|
|
71
|
+
apiPrefix: string[];
|
|
72
|
+
ignoreNoProgress: string[];
|
|
73
|
+
allowWrites?: boolean;
|
|
74
|
+
allowWrite?: string[];
|
|
75
|
+
hangReplayWrites?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** A goal-run flag the command must refuse (exit 64): `code` + the user-facing message. */
|
|
78
|
+
export declare class GoalRunFlagError extends Error {
|
|
79
|
+
readonly code: string;
|
|
80
|
+
constructor(code: string, message: string);
|
|
81
|
+
}
|
|
82
|
+
/** `--dialogs`: a mistyped value never silently means "dismiss" (#334). */
|
|
83
|
+
export declare function dialogsFromFlags(o: Pick<GoalRunFlags, "dialogs">): DialogPolicy | undefined;
|
|
84
|
+
/** `--success-when`: final | held | each. */
|
|
85
|
+
export declare function successWhenFromFlags(o: Pick<GoalRunFlags, "successWhen">): SuccessWhen | undefined;
|
|
86
|
+
/** The conversational-page tuning (`--reply-*`, `--job-wait-ms`), validated. */
|
|
87
|
+
export declare function conversationFromFlags(o: Pick<GoalRunFlags, "replyWaitMs" | "replyQuietMs" | "replyCeilingMs" | "replyMaxChars" | "jobWaitMs">): ConversationOptions;
|
|
88
|
+
/** `--secret-field` / `--totp` bindings, resolved from the environment (#72; `cmd:` needs `--allow-secret-cmd`, #324). */
|
|
89
|
+
export declare function secretFieldsFromFlags(o: Pick<GoalRunFlags, "secretField" | "totp" | "allowSecretCmd">, env?: Readonly<Record<string, string | undefined>>): SecretField[];
|
|
90
|
+
/** The `targets.json` flag overlay (patterns added, numbers and opt-ins winning). */
|
|
91
|
+
export declare function targetFlagsFromFlags(o: Partial<GoalRunFlags>, dialogs: DialogPolicy | undefined): TargetFlags;
|
|
92
|
+
/** Everything a goal run takes from these flags (the `runExploration` options of the same names). */
|
|
93
|
+
export interface GoalRunShaping {
|
|
94
|
+
readonly successWhen?: SuccessWhen;
|
|
95
|
+
readonly allowVacuousChecks?: boolean;
|
|
96
|
+
readonly actionDeltas?: boolean;
|
|
97
|
+
readonly secrets?: readonly string[];
|
|
98
|
+
readonly secretFields?: readonly SecretField[];
|
|
99
|
+
readonly secretCommand?: SecretCommandRunner;
|
|
100
|
+
readonly secretCommandAttempts?: number;
|
|
101
|
+
readonly typeFixtures?: readonly TypeFixture[];
|
|
102
|
+
readonly fixture?: string;
|
|
103
|
+
readonly saveStorageState?: string;
|
|
104
|
+
readonly screenshots?: ScreenshotsSpec;
|
|
105
|
+
readonly emulation?: EmulationSpec;
|
|
106
|
+
readonly target?: TargetConfig;
|
|
107
|
+
readonly hangReplays?: number;
|
|
108
|
+
readonly conversation?: ConversationOptions;
|
|
109
|
+
}
|
|
110
|
+
export interface ResolveGoalRunDeps {
|
|
111
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
112
|
+
readonly targetsConfigPath?: string;
|
|
113
|
+
/** Where a literal `--secret`'s warning goes (stderr). */
|
|
114
|
+
readonly warn?: (text: string) => void;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Validates and resolves every shared goal-run flag — before any browser opens — into the goal
|
|
118
|
+
* run's options. Throws `GoalRunFlagError` (exit 64) on the first unusable one.
|
|
119
|
+
*/
|
|
120
|
+
export declare function resolveGoalRunFlags(o: GoalRunFlags, url: string, deps?: ResolveGoalRunDeps): GoalRunShaping;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #369: the goal run's run-shaping flags, shared by `jevitate explore` (goal/usability) and
|
|
3
|
+
* `jevitate explore-author-journey` (whose discovery and corroborating takes ARE goal runs) — one
|
|
4
|
+
* definition of each flag (text, parser, default) and one resolver, so the two commands accept and
|
|
5
|
+
* validate the same setup and an author run can reproduce what a goal run needed.
|
|
6
|
+
*/
|
|
7
|
+
import { Option } from "commander";
|
|
8
|
+
import { parseSecretField, validateDenyPatterns, } from "@jevitate/explore";
|
|
9
|
+
import { intArg, nonNegativeIntArg, positiveIntArg } from "./cli-args.js";
|
|
10
|
+
import { LITERAL_SECRET_WARNING, resolveSecretArgs } from "./secret-args.js";
|
|
11
|
+
import { secretCommandRunner } from "./secret-command.js";
|
|
12
|
+
import { loadTypeFixtures } from "./type-fixture-file.js";
|
|
13
|
+
import { SessionFileInProjectError, assertSessionFileOutsideProject } from "./project-dir.js";
|
|
14
|
+
import { parseScreenshotsArg } from "./run-screenshots.js";
|
|
15
|
+
import { TargetConfigError, loadTargetsFile, resolveTargetConfig } from "./target-config.js";
|
|
16
|
+
import { emulationFromFlags } from "./cli-shared.js";
|
|
17
|
+
const collect = (v, prev) => [...prev, v];
|
|
18
|
+
/** Each shared flag, built fresh per command (commander owns an `Option` once added). */
|
|
19
|
+
export const GOAL_RUN_OPTIONS = {
|
|
20
|
+
successWhen: () => new Option("--success-when <when>", "when the --success page checks must hold: final (default; on the final page) | held (on the final page, or all together at any settled step — a one-time secret, a toast) | " +
|
|
21
|
+
"each (each went from not holding to holding at some settled step, in any order — checks on different pages; the run stops once all have). reloadThen is always final"),
|
|
22
|
+
allowVacuousChecks: () => new Option("--allow-vacuous-checks", "downgrade a vacuous --success check to a warning. By default a check satisfied before the run's first action — a page check that held on the seed page and never changed " +
|
|
23
|
+
"(an empty result container), a requestMade/responseStatus matched only by a page-load or polling request — FAILS: it cannot verify the goal"),
|
|
24
|
+
actionDeltas: () => new Option("--action-deltas", "opt-in (#303; every --strategy, not --feature): record what each action changed on the page — an accessibility snapshot before and after, announcements, " +
|
|
25
|
+
"the action's requests — redacted, with a code verdict per step (no-change | relevant-change | inconclusive) used by the goal loop's no-progress check and a persistence re-check after writes (goal), and as defect evidence (adversarial, coverage); " +
|
|
26
|
+
"adds `delta` to every transcript step (and Recording step, goal) and `actionDeltas` to the result. Costs about 50-100 ms per action on a small page, 0.3-0.5 s on a large one"),
|
|
27
|
+
secret: () => new Option("--secret <value|env:VAR>", "REDACTION ONLY: a secret/PII value kept out of every model call and artifact (repeatable); env:VAR reads it from the environment (preferred: a literal is visible in the process list and shell history). It is never typed into a field — to log in, bind it with --secret-field (or start from --storage-state)")
|
|
28
|
+
.default([])
|
|
29
|
+
.argParser(collect),
|
|
30
|
+
secretField: () => new Option("--secret-field <binding>", "goal/usability strategy: '<label|testId|type|id|name>=<value>=env:<VAR>' (repeatable), e.g. 'label=Password=env:APP_PASSWORD'. When the run types into a matching field, code types $VAR itself; the model sees only «secret:VAR» and the Recording {redacted:true}. " +
|
|
31
|
+
"A value delivered during the run (an emailed code): '<descriptor>=cmd:<command>' runs the command when the field is typed and types its stdout (needs --allow-secret-cmd)")
|
|
32
|
+
.default([])
|
|
33
|
+
.argParser(collect),
|
|
34
|
+
totp: () => new Option("--totp <binding>", "goal/usability strategy: '<descriptor>=env:<VAR>' with $VAR a base32 TOTP seed (repeatable), e.g. 'label=Authentication code=env:APP_TOTP_SEED'. The 6-digit code is computed locally (RFC 6238) when the field is typed; the seed never reaches a model or disk")
|
|
35
|
+
.default([])
|
|
36
|
+
.argParser(collect),
|
|
37
|
+
typeFixture: () => new Option("--type-fixture <binding>", "goal strategy: '<label|testId|type|id|name>=<value>=<file>' (repeatable), e.g. 'label=Paste your text=./fixtures/import.txt'. When the run types into a matching field, code types the file's exact text verbatim (line breaks kept, never paraphrased or capped); the model sees only «fixture:<file name>». Recorded as typed unless it holds a --secret")
|
|
38
|
+
.default([])
|
|
39
|
+
.argParser(collect),
|
|
40
|
+
fixture: () => new Option("--fixture <path>", "local file the upload op attaches to a file input (goal and usability strategies); must exist"),
|
|
41
|
+
saveStorageState: () => new Option("--save-storage-state <file>", "write the context's storageState (cookies + origin storage) here when the run ends; mode 0600, contents never logged. " +
|
|
42
|
+
"Useful with a rotating refresh token: --storage-state's file goes stale after one authenticated run refreshes it, " +
|
|
43
|
+
"so point --save-storage-state at the SAME file (or a new one) to keep it usable for the next run. " +
|
|
44
|
+
"Written on every exit path -- a crash or a SIGTERM/SIGINT kill included (#159), not only a clean end -- but " +
|
|
45
|
+
"never over a good file with a session that already looks lost/logged-out; the last known-good state is used " +
|
|
46
|
+
"instead, or nothing is written if none was ever captured."),
|
|
47
|
+
replyWaitMs: () => new Option("--reply-wait-ms <ms>", "conversational pages: how long to keep waiting for a reply while the page shows no sign of working on one " +
|
|
48
|
+
"(goal and usability; default 60000). While a request the message started is in flight, a busy indicator shows, " +
|
|
49
|
+
"or the reply is still growing, the wait continues up to --reply-ceiling-ms").argParser(positiveIntArg),
|
|
50
|
+
replyQuietMs: () => new Option("--reply-quiet-ms <ms>", "conversational pages: how long a reply must hold still (no new text, no busy sign) before it is read as complete " +
|
|
51
|
+
"(goal and usability; default 1000). Raise it for an assistant that answers in several parts (a sentence, then a card a moment later)").argParser(positiveIntArg),
|
|
52
|
+
replyCeilingMs: () => new Option("--reply-ceiling-ms <ms>", "conversational pages: hard ceiling on the TOTAL wait for one sent message's reply — the send's own wait plus every later 'wait' — " +
|
|
53
|
+
"however busy the page stays; once spent the run ends naming the missing reply (default 180000; never below --reply-wait-ms) (default 180000; never below --reply-wait-ms)").argParser(positiveIntArg),
|
|
54
|
+
replyMaxChars: () => new Option("--reply-max-chars <n>", "conversational pages: cap on each generated chat message (goal and usability; default 300)").argParser(intArg({ min: 20, max: 2000 })),
|
|
55
|
+
jobWaitMs: () => new Option("--job-wait-ms <ms>", "goal and usability: while the page shows an in-progress status (\"Simulating…\", aria-busy, a job \"is running\"), " +
|
|
56
|
+
"waits keep waiting with backoff — and a model 'blocked' is deferred — up to this budget (default: --reply-ceiling-ms, 180000); " +
|
|
57
|
+
"it also bounds a busy indicator the app visibly keeps working behind (live progress, a job poll) before it is a hang, " +
|
|
58
|
+
"and a wait the page documents (\"usually takes a minute\") can raise it").argParser(positiveIntArg),
|
|
59
|
+
deny: () => new Option("--deny <pattern>", "a control no mission may click (repeatable): an accessible-name regex (/Archive/i or Archive) or a descriptor role=button;name=Archive. " +
|
|
60
|
+
"Session-ending (Sign out), destructive (Delete, Revoke, Rotate) and paid (Buy, Run simulation, Generate, Send invite) controls are refused by default")
|
|
61
|
+
.default([])
|
|
62
|
+
.argParser(collect),
|
|
63
|
+
paid: () => new Option("--paid <pattern>", "an app control that costs money or credits (repeatable; same syntax as --deny), e.g. /^(Analyze|Draft|Improve)\\b/i: treated like the built-in paid " +
|
|
64
|
+
"vocabulary — the budget guard sees it, hang replays never repeat it, and a goal that asks for it may still click it")
|
|
65
|
+
.default([])
|
|
66
|
+
.argParser(collect),
|
|
67
|
+
allowDestructive: () => new Option("--allow-destructive", "let missions click session-ending, destructive and paid controls (a --deny pattern still holds). A goal run already may click one its goal asks for"),
|
|
68
|
+
dialogs: () => new Option("--dialogs <policy>", "native window.confirm/prompt dialogs: dismiss (default) or accept. accept still dismisses one whose message names a session-ending, " +
|
|
69
|
+
"destructive or paid action the run may not take (without --allow-destructive or a goal asking for it); every dialog is logged"),
|
|
70
|
+
readRpc: () => new Option("--read-rpc <glob>", "a POST request that only READS (repeatable): an RPC-method glob (Estimate*, pkg.Service/Preview*) or a path glob (/api/search*). " +
|
|
71
|
+
"gRPC-web/Connect Get*/List*/Search*/Find*/Watch*/Stream*/Count*/Describe*/Read* methods are reads already. Reads are never guarded or reported as duplicate writes")
|
|
72
|
+
.default([])
|
|
73
|
+
.argParser(collect),
|
|
74
|
+
hangReplays: () => new Option("--hang-replays <n>", "fresh-context replays that confirm a hang (default 2; 0 = don't replay, the hang is reported unconfirmed)").argParser(nonNegativeIntArg),
|
|
75
|
+
settleIgnore: () => new Option("--settle-ignore <pattern>", "a request URL pattern the target marks as background (never pending work; repeatable, * wildcard)")
|
|
76
|
+
.default([])
|
|
77
|
+
.argParser(collect),
|
|
78
|
+
longPollMs: () => new Option("--long-poll-ms <n>", "a request pending this long on an interactive page is a long-poll (default 5000)").argParser(nonNegativeIntArg),
|
|
79
|
+
apiPrefix: () => new Option("--api-prefix <path>", "a path prefix whose requests are the app's API in the timing summary (repeatable), e.g. /api/")
|
|
80
|
+
.default([])
|
|
81
|
+
.argParser(collect),
|
|
82
|
+
ignoreNoProgress: () => new Option("--ignore-no-progress <pattern>", "a route / action label / busy indicator where ui-no-progress is expected (repeatable, * wildcard)")
|
|
83
|
+
.default([])
|
|
84
|
+
.argParser(collect),
|
|
85
|
+
allowSecretCmd: () => new Option("--allow-secret-cmd", "opt-in: a --secret-field <descriptor>=cmd:<command> may run its command (in a shell, at type time, 60s timeout) and type its output (operator-declared only; refused otherwise)").default(false),
|
|
86
|
+
secretCmdAttempts: () => new Option("--secret-cmd-attempts <n>", "#359: how many times one cmd: secret field's command may run in this run (default 3); past it, typing that field fails without running the command again (read-the-code commands usually have side effects)").argParser(positiveIntArg),
|
|
87
|
+
};
|
|
88
|
+
/** A goal-run flag the command must refuse (exit 64): `code` + the user-facing message. */
|
|
89
|
+
export class GoalRunFlagError extends Error {
|
|
90
|
+
code;
|
|
91
|
+
constructor(code, message) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.code = code;
|
|
94
|
+
this.name = "GoalRunFlagError";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** A refusal keeps its own code when it has a typed one (a session file in the project, a bad targets.json); the rest are E_EXPLORE_ARGS. */
|
|
98
|
+
const asError = (err) => err instanceof GoalRunFlagError
|
|
99
|
+
? err
|
|
100
|
+
: new GoalRunFlagError(err instanceof SessionFileInProjectError || err instanceof TargetConfigError ? err.code : "E_EXPLORE_ARGS", err instanceof Error ? err.message : String(err));
|
|
101
|
+
/** `--dialogs`: a mistyped value never silently means "dismiss" (#334). */
|
|
102
|
+
export function dialogsFromFlags(o) {
|
|
103
|
+
if (o.dialogs === undefined)
|
|
104
|
+
return undefined;
|
|
105
|
+
if (o.dialogs !== "dismiss" && o.dialogs !== "accept") {
|
|
106
|
+
throw new GoalRunFlagError("E_EXPLORE_ARGS", `--dialogs must be dismiss or accept, got ${JSON.stringify(o.dialogs)}`);
|
|
107
|
+
}
|
|
108
|
+
return o.dialogs;
|
|
109
|
+
}
|
|
110
|
+
/** `--success-when`: final | held | each. */
|
|
111
|
+
export function successWhenFromFlags(o) {
|
|
112
|
+
if (o.successWhen === undefined)
|
|
113
|
+
return undefined;
|
|
114
|
+
if (o.successWhen !== "held" && o.successWhen !== "final" && o.successWhen !== "each") {
|
|
115
|
+
throw new GoalRunFlagError("E_EXPLORE_ARGS", `--success-when must be "final", "held" or "each", got ${JSON.stringify(o.successWhen)}`);
|
|
116
|
+
}
|
|
117
|
+
return o.successWhen;
|
|
118
|
+
}
|
|
119
|
+
/** The conversational-page tuning (`--reply-*`, `--job-wait-ms`), validated. */
|
|
120
|
+
export function conversationFromFlags(o) {
|
|
121
|
+
const conversation = {
|
|
122
|
+
...(o.replyWaitMs === undefined ? {} : { replyWaitMs: Number(o.replyWaitMs) }),
|
|
123
|
+
...(o.replyQuietMs === undefined ? {} : { replyQuietMs: Number(o.replyQuietMs) }),
|
|
124
|
+
...(o.replyCeilingMs === undefined ? {} : { replyCeilingMs: Number(o.replyCeilingMs) }),
|
|
125
|
+
...(o.replyMaxChars === undefined ? {} : { replyMaxChars: Number(o.replyMaxChars) }),
|
|
126
|
+
...(o.jobWaitMs === undefined ? {} : { jobWaitMs: Number(o.jobWaitMs) }),
|
|
127
|
+
};
|
|
128
|
+
if ((conversation.replyWaitMs !== undefined && !(Number.isInteger(conversation.replyWaitMs) && conversation.replyWaitMs > 0)) ||
|
|
129
|
+
(conversation.replyCeilingMs !== undefined && !(Number.isInteger(conversation.replyCeilingMs) && conversation.replyCeilingMs > 0)) ||
|
|
130
|
+
(conversation.replyMaxChars !== undefined &&
|
|
131
|
+
!(Number.isInteger(conversation.replyMaxChars) && conversation.replyMaxChars >= 20 && conversation.replyMaxChars <= 2000))) {
|
|
132
|
+
throw new GoalRunFlagError("E_EXPLORE_ARGS", "--reply-wait-ms and --reply-ceiling-ms must be positive integers; --reply-max-chars an integer in 20..2000");
|
|
133
|
+
}
|
|
134
|
+
if (conversation.jobWaitMs !== undefined && !(Number.isInteger(conversation.jobWaitMs) && conversation.jobWaitMs > 0)) {
|
|
135
|
+
throw new GoalRunFlagError("E_EXPLORE_ARGS", "--job-wait-ms must be a positive integer");
|
|
136
|
+
}
|
|
137
|
+
return conversation;
|
|
138
|
+
}
|
|
139
|
+
/** `--secret-field` / `--totp` bindings, resolved from the environment (#72; `cmd:` needs `--allow-secret-cmd`, #324). */
|
|
140
|
+
export function secretFieldsFromFlags(o, env = process.env) {
|
|
141
|
+
try {
|
|
142
|
+
return [
|
|
143
|
+
...o.secretField.map((s) => parseSecretField(s, "value", env, { allowCmd: o.allowSecretCmd === true })),
|
|
144
|
+
...o.totp.map((s) => parseSecretField(s, "totp", env)),
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
throw asError(err);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** The `targets.json` flag overlay (patterns added, numbers and opt-ins winning). */
|
|
152
|
+
export function targetFlagsFromFlags(o, dialogs) {
|
|
153
|
+
return {
|
|
154
|
+
settleIgnore: o.settleIgnore ?? [],
|
|
155
|
+
ignoreNoProgress: o.ignoreNoProgress ?? [],
|
|
156
|
+
apiPrefixes: o.apiPrefix ?? [],
|
|
157
|
+
deny: o.deny ?? [],
|
|
158
|
+
paid: o.paid ?? [],
|
|
159
|
+
readRpc: o.readRpc ?? [],
|
|
160
|
+
...(o.allowDestructive === true ? { allowDestructive: true } : {}),
|
|
161
|
+
...(dialogs === undefined ? {} : { dialogs }),
|
|
162
|
+
...(o.allowWrites === true ? { allowWrites: true } : {}),
|
|
163
|
+
allowWrite: o.allowWrite ?? [],
|
|
164
|
+
...(o.hangReplayWrites === true ? { hangReplayWrites: true } : {}),
|
|
165
|
+
...(o.longPollMs === undefined ? {} : { longPollMs: Number(o.longPollMs) }),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Validates and resolves every shared goal-run flag — before any browser opens — into the goal
|
|
170
|
+
* run's options. Throws `GoalRunFlagError` (exit 64) on the first unusable one.
|
|
171
|
+
*/
|
|
172
|
+
export function resolveGoalRunFlags(o, url, deps = {}) {
|
|
173
|
+
const env = deps.env ?? process.env;
|
|
174
|
+
try {
|
|
175
|
+
const dialogs = dialogsFromFlags(o);
|
|
176
|
+
const successWhen = successWhenFromFlags(o);
|
|
177
|
+
if (o.saveStorageState !== undefined)
|
|
178
|
+
assertSessionFileOutsideProject(o.saveStorageState, "--save-storage-state");
|
|
179
|
+
const resolved = resolveSecretArgs(o.secret, env, "--secret");
|
|
180
|
+
if (resolved.literals > 0)
|
|
181
|
+
deps.warn?.(LITERAL_SECRET_WARNING);
|
|
182
|
+
const screenshots = parseScreenshotsArg(o.screenshots);
|
|
183
|
+
const conversation = conversationFromFlags(o);
|
|
184
|
+
validateDenyPatterns(o.deny);
|
|
185
|
+
validateDenyPatterns(o.paid, "--paid");
|
|
186
|
+
const emulation = emulationFromFlags(o);
|
|
187
|
+
const secretFields = secretFieldsFromFlags(o, env);
|
|
188
|
+
const typeFixtures = o.typeFixture.length === 0 ? [] : loadTypeFixtures(o.typeFixture);
|
|
189
|
+
let target;
|
|
190
|
+
try {
|
|
191
|
+
target = resolveTargetConfig(loadTargetsFile(deps.targetsConfigPath), new URL(url).origin, targetFlagsFromFlags(o, dialogs));
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
// An unparseable URL is refused by the authorized-target guard.
|
|
195
|
+
if (!(err instanceof TypeError))
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
...(successWhen === undefined ? {} : { successWhen }),
|
|
200
|
+
...(o.allowVacuousChecks === true ? { allowVacuousChecks: true } : {}),
|
|
201
|
+
...(o.actionDeltas === true ? { actionDeltas: true } : {}),
|
|
202
|
+
...(resolved.secrets.length === 0 ? {} : { secrets: resolved.secrets }),
|
|
203
|
+
...(secretFields.length === 0 ? {} : { secretFields }),
|
|
204
|
+
...(secretFields.some((f) => f.kind === "cmd") ? { secretCommand: secretCommandRunner() } : {}),
|
|
205
|
+
...(o.secretCmdAttempts === undefined ? {} : { secretCommandAttempts: o.secretCmdAttempts }),
|
|
206
|
+
...(typeFixtures.length === 0 ? {} : { typeFixtures }),
|
|
207
|
+
...(o.fixture === undefined ? {} : { fixture: o.fixture }),
|
|
208
|
+
...(o.saveStorageState === undefined ? {} : { saveStorageState: o.saveStorageState }),
|
|
209
|
+
...(screenshots === undefined ? {} : { screenshots }),
|
|
210
|
+
...(emulation === undefined ? {} : { emulation }),
|
|
211
|
+
...(target === undefined ? {} : { target }),
|
|
212
|
+
...(o.hangReplays === undefined ? {} : { hangReplays: o.hangReplays }),
|
|
213
|
+
...(Object.keys(conversation).length === 0 ? {} : { conversation }),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
throw asError(err);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=goal-run-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-run-flags.js","sourceRoot":"","sources":["../src/goal-run-flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GAKrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CA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AAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/journey-api.js
CHANGED
|
@@ -16,6 +16,7 @@ import { JourneyRunner } from "@jevitate/runtime";
|
|
|
16
16
|
import { gateJourney } from "./site-gate-cli.js";
|
|
17
17
|
import { substituteSetupRefs } from "./mission-fixtures.js";
|
|
18
18
|
import { applyJourneyEnvironment } from "./environments.js";
|
|
19
|
+
import { withNetworkChecks } from "./journey-network-checks.js";
|
|
19
20
|
/**
|
|
20
21
|
* Distinct from `@jevitate/journey`'s `ParamValidationError` so CLI/API callers
|
|
21
22
|
* can tell "no such journey" apart from "params didn't match the journey's
|
|
@@ -173,7 +174,9 @@ export async function runJourneyProgrammatically(opts) {
|
|
|
173
174
|
const runner = new JourneyRunner(actor, interpreter, undefined, undefined, opts.selfHealer);
|
|
174
175
|
let result;
|
|
175
176
|
try {
|
|
176
|
-
|
|
177
|
+
// #322: a full replay (never an anchored prefix) must also satisfy the Journey's network checks.
|
|
178
|
+
const networkChecks = journey === full ? journey.metadata.networkChecks : undefined;
|
|
179
|
+
result = redactSecretParams(await withNetworkChecks(session.page, networkChecks, () => runner.run({ journey, params, policy })), journey, params);
|
|
177
180
|
}
|
|
178
181
|
finally {
|
|
179
182
|
await gate.done();
|
package/dist/journey-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journey-api.js","sourceRoot":"","sources":["../src/journey-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAgB,MAAM,mBAAmB,CAAC;AAC7M,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAkB,KAAK,EAAE,MAAM,kB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-0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #322 — a Journey's `networkChecks` (authored from `explore-author-journey --success
|
|
3
|
+
* requestMade:…|responseStatus:…`), evaluated over the requests its replay itself sent: the SAME
|
|
4
|
+
* page-monitor capture and evaluator a live goal mission's own network check uses (and a
|
|
5
|
+
* network-check regression replays with). A replay whose steps all passed but whose expected
|
|
6
|
+
* request never went out (or got the wrong status) is a failed run, never `ok`.
|
|
7
|
+
*/
|
|
8
|
+
import type { Page } from "playwright";
|
|
9
|
+
import type { JourneyNetworkCheck } from "@jevitate/journey";
|
|
10
|
+
import type { JourneyRunResult } from "@jevitate/runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Runs `replay` with the page's requests captured, then evaluates `checks` over them. With no
|
|
13
|
+
* checks it just runs `replay`. A replay that already failed keeps its own reason.
|
|
14
|
+
*/
|
|
15
|
+
export declare function withNetworkChecks(page: Page, checks: readonly JourneyNetworkCheck[] | undefined, replay: () => Promise<JourneyRunResult>): Promise<JourneyRunResult>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { evaluateNetworkCheck, monitorFor } from "@jevitate/explore";
|
|
2
|
+
/** How long the network may take to go idle after the last step before the checks read it. */
|
|
3
|
+
const SETTLE_CEILING_MS = 5_000;
|
|
4
|
+
/**
|
|
5
|
+
* Runs `replay` with the page's requests captured, then evaluates `checks` over them. With no
|
|
6
|
+
* checks it just runs `replay`. A replay that already failed keeps its own reason.
|
|
7
|
+
*/
|
|
8
|
+
export async function withNetworkChecks(page, checks, replay) {
|
|
9
|
+
if (checks === undefined || checks.length === 0)
|
|
10
|
+
return replay();
|
|
11
|
+
const monitor = monitorFor(page);
|
|
12
|
+
await monitor.instrument();
|
|
13
|
+
const capture = monitor.startCapture();
|
|
14
|
+
let result;
|
|
15
|
+
try {
|
|
16
|
+
result = await replay();
|
|
17
|
+
if (result.outcome === "quarantined")
|
|
18
|
+
return result;
|
|
19
|
+
// A step's postcondition can hold before the write it triggered finished: wait for the network
|
|
20
|
+
// to go idle (bounded) before reading what was sent.
|
|
21
|
+
await monitor.waitSettled({ ceilingMs: SETTLE_CEILING_MS }).catch(() => undefined);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
monitor.stopCapture(capture);
|
|
25
|
+
}
|
|
26
|
+
const failed = checks
|
|
27
|
+
.map((c) => evaluateNetworkCheck(c.kind === "requestMade" ? c : { ...c, status: { ...c.status } }, capture.sent(), capture.truncated))
|
|
28
|
+
.filter((r) => !r.passed);
|
|
29
|
+
if (failed.length === 0)
|
|
30
|
+
return result;
|
|
31
|
+
return {
|
|
32
|
+
outcome: "quarantined",
|
|
33
|
+
reason: `success check${failed.length === 1 ? "" : "s"} not met after the last step: ${failed.map((r) => `${r.check} — ${r.detail}`).join("; ")}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=journey-network-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journey-network-checks.js","sourceRoot":"","sources":["../src/journey-network-checks.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAErE,8FAA8F;AAC9F,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAU,EACV,MAAkD,EAClD,MAAuC;IAEvC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,EAAE,CAAC;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IACvC,IAAI,MAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;QACxB,IAAI,MAAM,CAAC,OAAO,KAAK,aAAa;YAAE,OAAO,MAAM,CAAC;QACpD,+FAA+F;QAC/F,qDAAqD;QACrD,MAAM,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACrF,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,MAAM,GAAG,MAAM;SAClB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;SACrI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACvC,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,gBAAgB,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,iCAAiC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KAClJ,CAAC;AACJ,CAAC"}
|
package/dist/kill-signal.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ import { type EngineInfo } from "./engine.js";
|
|
|
12
12
|
* A single process-level handler is installed lazily, once, the first time any mission arms it
|
|
13
13
|
* (`armMissionKillSwitch`). On SIGTERM/SIGINT it writes a partial typed result — `outcome:
|
|
14
14
|
* "inconclusive"`, `reason: "interrupted by SIG… after N steps"` — built from whatever the journal
|
|
15
|
-
* already flushed, starts closing the shared browser pool,
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* already flushed, starts closing the shared browser pool, terminates every browser process tree
|
|
16
|
+
* this process launched (#326: bounded SIGTERM, then SIGKILL — a blocking wait, never an `await`),
|
|
17
|
+
* then exits with the conventional code (129 SIGHUP or parent death / 130 SIGINT / 143 SIGTERM) —
|
|
18
|
+
* all SYNCHRONOUSLY, in the same turn the signal arrives. Playwright installs its OWN SIGTERM/SIGINT handler on the browsers it
|
|
18
19
|
* launched; the instant that fires, any in-flight page operation starts rejecting, and the killed
|
|
19
20
|
* mission's own error handling can turn that into a normal (non-killed) result and call
|
|
20
21
|
* `process.exit` on its own terms — an `await` here, even a fast one, is enough of a window for
|
|
@@ -95,7 +96,9 @@ export interface KillableMission {
|
|
|
95
96
|
* library use). Set by the CLI command that armed the mission.
|
|
96
97
|
*/
|
|
97
98
|
export type KillSwitchOutput = "envelope" | "human" | "none";
|
|
99
|
+
/** 128 + the signal number, the shell convention. SIGHUP (#326) also stands for "the parent died". */
|
|
98
100
|
declare const SIGNAL_EXIT_CODE: {
|
|
101
|
+
readonly SIGHUP: 129;
|
|
99
102
|
readonly SIGINT: 130;
|
|
100
103
|
readonly SIGTERM: 143;
|
|
101
104
|
};
|
|
@@ -110,6 +113,17 @@ export interface KillSwitchDeps {
|
|
|
110
113
|
transcript: readonly TranscriptEntry[];
|
|
111
114
|
};
|
|
112
115
|
readonly onSignal: (signal: KillSignal, handler: () => void) => void;
|
|
116
|
+
/**
|
|
117
|
+
* #326: closes every browser this process launched SYNCHRONOUSLY (bounded SIGTERM, then SIGKILL of
|
|
118
|
+
* each browser's process tree) before `exit`. Playwright's own `exit` hook only kills the browsers
|
|
119
|
+
* it still tracks; this makes "no Chromium outlives the CLI" not depend on it.
|
|
120
|
+
*/
|
|
121
|
+
readonly terminateBrowsers?: () => void;
|
|
122
|
+
/**
|
|
123
|
+
* #326: calls `onGone` once if this process's parent dies (it is re-parented), so a CLI whose
|
|
124
|
+
* wrapper/harness was SIGKILLed tears down like a SIGHUP instead of running on with its browsers.
|
|
125
|
+
*/
|
|
126
|
+
readonly watchParent?: (onGone: () => void) => void;
|
|
113
127
|
/** This build's identity, stamped on the killed run's result like every other result (#112). */
|
|
114
128
|
readonly engine?: () => EngineInfo;
|
|
115
129
|
/** SYNCHRONOUS stdout write — the process exits in the same turn, so nothing may be buffered. */
|
|
@@ -121,6 +135,19 @@ export interface KillSwitchDeps {
|
|
|
121
135
|
*/
|
|
122
136
|
readonly writeStorageStateSnapshot?: (path: string, json: string) => void;
|
|
123
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* #326: the parent-death watchdog. Linux/macOS only (Windows has no re-parenting). Polls
|
|
140
|
+
* `process.ppid` (one cheap syscall) every `intervalMs` on an unref'd timer, so it never keeps
|
|
141
|
+
* the process alive; when the parent changes (the CLI was re-parented to init or a subreaper) it
|
|
142
|
+
* stops and calls `onGone` once. Off with `JEVITATE_PARENT_WATCHDOG=off` (a run deliberately left
|
|
143
|
+
* behind by `nohup … &`), and when started with no real parent (ppid ≤ 1). Returns the stop function.
|
|
144
|
+
*/
|
|
145
|
+
export declare function watchParentDeath(onGone: () => void, opts?: {
|
|
146
|
+
readonly ppid?: () => number;
|
|
147
|
+
readonly platform?: NodeJS.Platform;
|
|
148
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
149
|
+
readonly intervalMs?: number;
|
|
150
|
+
}): (() => void) | undefined;
|
|
124
151
|
type KilledListener = (killed: {
|
|
125
152
|
resultPath: string;
|
|
126
153
|
exitCode: number;
|