@qawolf/cli 1.40.0 → 1.41.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/cli.js CHANGED
@@ -9262,6 +9262,20 @@ function makeDefaultFs() {
9262
9262
  await fs2.promises.writeFile(path, data, options ?? undefined);
9263
9263
  }
9264
9264
  },
9265
+ async writeFileExclusive(path, data, options) {
9266
+ try {
9267
+ await fs2.promises.writeFile(path, data, {
9268
+ encoding: typeof data === "string" ? "utf8" : undefined,
9269
+ flag: "wx",
9270
+ mode: options?.mode
9271
+ });
9272
+ return true;
9273
+ } catch (error) {
9274
+ if (errorCode(error) === "EEXIST")
9275
+ return false;
9276
+ throw error;
9277
+ }
9278
+ },
9265
9279
  openWriteHandle: openFsWriteHandle,
9266
9280
  readdir(path) {
9267
9281
  return fs2.promises.readdir(path);
@@ -16860,6 +16874,7 @@ var defaultIdSchemas = {
16860
16874
  flow: string2().min(1).describe("The id of the flow."),
16861
16875
  issue: string2().min(1).describe("The id of the issue."),
16862
16876
  legacyTrigger: string2().min(1).describe("The id of the legacy trigger, from legacyTrigger.find."),
16877
+ promotion: string2().min(1).describe("The id of the promotion, from promotion.find or environment.promote."),
16863
16878
  run: string2().min(1).describe("The id of the run."),
16864
16879
  runAttempt: string2().min(1).describe("The id of the run attempt."),
16865
16880
  trigger: string2().min(1).describe("The id of the trigger."),
@@ -17180,7 +17195,7 @@ var makeInspectOnRunnerContract = (ids) => {
17180
17195
  openWorldHint: false,
17181
17196
  readOnlyHint: false
17182
17197
  },
17183
- description: "Inspect one thing on an interactive runner: an element's HTML, the page's HTML simplified for a model, or a top-level variable's value as JSON. This refreshes the inactivity timer and can extend the runner's billed lifetime. `nothing-to-inspect` means the runner had nothing to answer with: no live page, no element matching the selector, or no variable under that name. A runner cannot tell those apart, so it reports the one reason and puts whatever it did say in `errorMessage`. `runner-is-not-a-browser` on a mobile runner — call `runner.inspectMobile` for its equivalent surface instead. " + retryableRunnerUnreachableDescription,
17198
+ description: "Inspect one thing on an interactive runner: an element's HTML, the page's HTML simplified for a model, or a top-level variable's value as JSON. This refreshes the inactivity timer and can extend the runner's billed lifetime. `nothing-to-inspect` means the runner had nothing to answer with: no live page, no element matching the selector, or no variable under that name. A runner cannot tell those apart, so it reports the one reason and puts whatever it did say in `errorMessage`. A mobile or Windows runner answers `variable`; for `element-html` or `page-html` it answers `runner-is-not-a-browser` — call `runner.inspectMobile` for its equivalent surface instead. " + retryableRunnerUnreachableDescription,
17184
17199
  input,
17185
17200
  kind: "read",
17186
17201
  name: "runner.inspect",
@@ -17250,8 +17265,8 @@ var elementsRequestSchema = discriminatedUnion("by", [
17250
17265
  by: literal("point"),
17251
17266
  context: string2().min(1).optional(),
17252
17267
  what: literal("elements"),
17253
- x: int().min(0).describe("Whole pixels on the device's own screen."),
17254
- y: int().min(0).describe("Whole pixels on the device's own screen.")
17268
+ x: int().min(0).describe("Whole pixels in the same space as `runner.takeScreenshot`."),
17269
+ y: int().min(0).describe("Whole pixels in the same space as `runner.takeScreenshot`.")
17255
17270
  }),
17256
17271
  object({
17257
17272
  by: literal("text"),
@@ -17313,7 +17328,7 @@ var inspectMobileAnswerSchema = discriminatedUnion("what", [
17313
17328
  context: string2(),
17314
17329
  orientation: orientationSchema,
17315
17330
  outcome: literal("success"),
17316
- pageSource: pageSourceNodeSchema,
17331
+ pageSource: pageSourceNodeSchema.describe("The element tree. Its bounds are in the device's own pixels, not the screenshot's; to find a point to act on, ask for `elements`, whose bounds and centers are in screenshot pixels."),
17317
17332
  what: literal("page")
17318
17333
  }),
17319
17334
  object({
@@ -17349,7 +17364,7 @@ var makeInspectMobileOnRunnerContract = (ids) => {
17349
17364
  openWorldHint: false,
17350
17365
  readOnlyHint: true
17351
17366
  },
17352
- description: `Inspect one thing on a mobile interactive runner: the Appium session's status, the WebView contexts available, the current context's page source, or the elements at a point, carrying some text, or matching a selector. This does not refresh the runner's inactivity timer. Mobile only — a browser runner answers \`runner-is-not-mobile\`; call \`runner.inspect\` for a browser's equivalent surface instead. \`what: "session"\` always answers with the session's own status rather than \`screen-needs-a-run\`, since that is the question it exists to answer; the other three request kinds need a live session first and answer the same \`screen-needs-a-run\` or \`screen-not-ready\` outcomes \`runner.performAction\` and \`runner.takeScreenshot\` use, instead of reading anything when there is none. \`screen-needs-a-run\` means no Appium session has started on this runner yet — call \`runner.runFlow\` with a flow that opens one, then inspect again. \`screen-not-ready\` means the runner's Appium session exists but did not answer this instant, or more than one is somehow live — retry once; if it persists, relaunch the runner. \`runner-is-not-mobile\` means there is nothing here to inspect, and retrying will never help — launch an \`android\` or \`ios\` runner instead. \`invalid-selector\` (elements by selector only) means the selector itself could not be parsed under the given \`strategy\` — distinct from a selector that parsed fine but matched nothing, which answers \`matches: []\` instead. ${retryableRunnerUnreachableDescription}`,
17367
+ description: `Inspect one thing on a mobile or Windows interactive runner: the Appium session's status, the contexts available (WebViews on mobile, top-level windows on Windows), the current context's page source, or the elements at a point, carrying some text, or matching a selector. This does not refresh the runner's inactivity timer. Mobile and Windows only — a browser runner answers \`runner-is-not-mobile\`; call \`runner.inspect\` for a browser's equivalent surface instead. \`what: "session"\` always answers with the session's own status rather than \`screen-needs-a-run\`, since that is the question it exists to answer; the other three request kinds need a live session first and answer the same \`screen-needs-a-run\` or \`screen-not-ready\` outcomes \`runner.performAction\` and \`runner.takeScreenshot\` use, instead of reading anything when there is none. \`screen-needs-a-run\` means no Appium session has started on this runner yet — call \`runner.runFlow\` with a flow that opens one, then inspect again. \`screen-not-ready\` means the runner's Appium session exists but did not answer this instant, or more than one is somehow live — retry once; if it persists, relaunch the runner. \`runner-is-not-mobile\` means there is nothing here to inspect, and retrying will never help — launch an \`android\`, \`ios\` or \`windows\` runner instead. \`invalid-selector\` (elements by selector only) means the selector itself could not be parsed under the given \`strategy\` — distinct from a selector that parsed fine but matched nothing, which answers \`matches: []\` instead. ${retryableRunnerUnreachableDescription}`,
17353
17368
  input,
17354
17369
  kind: "read",
17355
17370
  name: "runner.inspectMobile",
@@ -17478,19 +17493,20 @@ var screenFailureReasons = [
17478
17493
  "screen-not-ready"
17479
17494
  ];
17480
17495
  var screenNotReadyDescription = "`screen-not-ready` if the runner has a screen that cannot serve this instant. Retry in a second or two: the desktop restarts when a run changes the display size, and it serves one see-or-act request at a time, so a screenshot or action already in flight is the usual reason. Do not submit a run to clear this — a run may restart the display and discard what is on it.";
17481
- var screenNeedsARunDescription = "`screen-needs-a-run` if the runner's virtual desktop has never started. Waiting will not change this and retrying is pointless — call `runner.runFlow` with a flow that opens a browser, then ask for the screen again. On a runner image with a browser that has never run anything, any `runner.performAction` also starts the browser itself. Evaluating a snippet does not start the desktop.";
17482
- var runnerHasNoScreenDescription = "`runner-has-no-screen` if this runner has no browser desktop to see or drive, and retrying will never help. Launch a `playwright` runner, or on `windows` use `runner.runFlow`.";
17496
+ var screenNeedsARunDescription = "`screen-needs-a-run` if the runner's virtual desktop has never started. Waiting will not change this and retrying is pointless — call `runner.runFlow` with a flow that opens a browser, then ask for the screen again. On a Windows runner any flow run claims the VM and brings up its screen. On a runner image with a browser that has never run anything, any `runner.performAction` also starts the browser itself. Evaluating a snippet does not start the desktop.";
17497
+ var runnerHasNoScreenDescription = "`runner-has-no-screen` if this runner has no browser desktop to see or drive, and retrying will never help. Launch a `playwright` runner.";
17483
17498
  var screenshotImageSchema = string2().min(1).describe("The screenshot, as a base64-encoded JPEG. Decode it and write the bytes to a `.jpg` file — writing this string to the file leaves you with base64 text rather than an image.");
17484
17499
 
17485
17500
  // node_modules/@qawolf/api-contracts/dist/v1/runner/performAction.js
17486
17501
  var unreachableDescription = "`runner-unreachable` if the runner could not be reached: it may still be starting, it may have terminated after inactivity, or it may have stopped answering mid-action. This does not mean the action was not performed — take a screenshot before repeating it.";
17487
- var notSupportedOnMobileDescription = "`action-not-supported-on-mobile` if the runner is a mobile device and this action has no touchscreen equivalent: `double_click`, `scroll`, `move`, `keypress` and `navigate`, and a `click` whose `button` is not `left`, are all pointer-device concepts a touchscreen has nothing to offer for. `type` types into whatever the last tap focused. Deprecated on mobile and to be removed: `click` taps and `drag` swipes between its path's first and last point; send `tap` and `swipe` instead.";
17488
- var mobileActionsDescription = "Only a mobile runner performs `tap`, `swipe` and `fill`: `tap` touches a point or the element a `selector` names, `swipe` moves from one point to another over `duration_ms`, and `fill` replaces the value of the field a `selector` names. A browser runner answers them with `action-not-supported-on-browser`.";
17489
- var withScreenshotDescription = "With `withScreenshot: true`, the answer also carries `imageJpegBase64`: a screenshot taken after the action. One call instead of `runner.performAction` followed by `runner.takeScreenshot`. The action itself is performed exactly as without the option; if the screen could serve no frame after it — a display restart, or a `navigate` on a desktop that is still starting — the action's result comes back without `imageJpegBase64`, so take a screenshot separately rather than repeating the action. On a mobile runner the screenshot is the device's own, taken right after a performed action.";
17502
+ var notSupportedOnMobileDescription = "`action-not-supported-on-mobile` if the runner is a mobile device and this is a browser action other than `type`: `click`, `double_click`, `drag`, `scroll`, `move`, `keypress` and `navigate` describe a mouse and keyboard, so send `tap` and `swipe` instead. `type` types into whatever the last tap focused.";
17503
+ var mobileActionsDescription = "Only a mobile or Windows runner performs `tap`, `swipe` and `fill`: `tap` touches a point or the element a `selector` names, `swipe` moves from one point to another over `duration_ms`, and `fill` replaces the value of the field a `selector` names. A browser runner answers them with `action-not-supported-on-browser`.";
17504
+ var windowsActionsDescription = "On a Windows runner, `click`, `double_click`, `move`, `scroll`, `drag`, `keypress` and `type` act on the whole desktop with a mouse and keyboard, at screenshot coordinates; a `drag` takes only its start and end point, and `swipe` is a drag. `tap` and `fill` also accept a UI Automation XPath `selector` (as in `runner.inspectMobile`) in place of a point. `navigate` is refused with `action-failed` because it needs a browser: open the page from a flow instead. Take points to act on from `runner.inspectMobile` `elements` (their `center`), not from page-source bounds, which are in the desktop's own pixels.";
17505
+ var withScreenshotDescription = "With `withScreenshot: true`, the answer also carries `imageJpegBase64`: a screenshot taken after the action. One call instead of `runner.performAction` followed by `runner.takeScreenshot`. The action itself is performed exactly as without the option; if the screen could serve no frame after it — a display restart, or a `navigate` on a desktop that is still starting — the action's result comes back without `imageJpegBase64`, so take a screenshot separately rather than repeating the action. On a mobile or Windows runner the screenshot is the device's own screen (on Windows, the whole desktop), taken right after a performed action.";
17490
17506
  var maxActionErrorMessageLength = 1000;
17491
17507
  var makePerformActionOnRunnerContract = (ids) => {
17492
17508
  const input = object({
17493
- action: runnerActionSchema.describe(`The action to perform. Coordinates are whole pixels on the runner's virtual desktop, in the same space as \`runner.takeScreenshot\`. The browser action shapes follow the computer-use vocabulary, minus \`screenshot\` (use \`runner.takeScreenshot\`) and \`wait\` (delay on the caller's side). A \`navigate\` does not go through the screen, so a screen that is not ready does not stop it. ${notSupportedOnMobileDescription} ${mobileActionsDescription}`),
17509
+ action: runnerActionSchema.describe(`The action to perform. Coordinates are whole pixels on the runner's virtual desktop, in the same space as \`runner.takeScreenshot\`. The browser action shapes follow the computer-use vocabulary, minus \`screenshot\` (use \`runner.takeScreenshot\`) and \`wait\` (delay on the caller's side). A \`navigate\` does not go through the screen, so a screen that is not ready does not stop it. ${notSupportedOnMobileDescription} ${mobileActionsDescription} ${windowsActionsDescription}`),
17494
17510
  id: runnerIdSchema.describe("Id of the runner to act on."),
17495
17511
  withScreenshot: boolean2().optional().describe(withScreenshotDescription),
17496
17512
  workspaceId: ids.workspace.optional().describe(runnerWorkspaceIdDescription)
@@ -17528,7 +17544,7 @@ var makePerformActionOnRunnerContract = (ids) => {
17528
17544
  openWorldHint: true,
17529
17545
  readOnlyHint: false
17530
17546
  },
17531
- description: `Perform one raw action on an interactive runner: click, double_click, move, drag, scroll, keypress, type, or navigate; on mobile, tap, swipe, fill, or type. One action per request, and the runner serves one at a time. A success means the action took effect. \`action-failed\`, with a reason, if it reached the runner and did not take effect. On a runner image with a browser, the first action on a runner that has never run anything starts its browser and waits for it, so it can take up to a minute to answer — no \`runner.runFlow\` is needed before acting; if the browser is still starting when the wait runs out, the answer is \`screen-not-ready\` and retrying converges. On a mobile runner, the same \`screen-needs-a-run\` and \`screen-not-ready\` outcomes mean no Appium session has started yet, or it did not answer this instant; \`runner.runFlow\` is what starts one, same as a browser. \`screen-needs-a-run\` if the browser could not be started that way — usually a runner whose runs all finished without starting its desktop; call \`runner.runFlow\` with a flow that opens a browser. ${screenNotReadyDescription} ${runnerHasNoScreenDescription} ${unreachableDescription}`,
17547
+ description: `Perform one raw action on an interactive runner: click, double_click, move, drag, scroll, keypress, type, or navigate; on mobile or Windows, also tap, swipe, or fill. One action per request, and the runner serves one at a time. A success means the action took effect. \`action-failed\`, with a reason, if it reached the runner and did not take effect. On a runner image with a browser, the first action on a runner that has never run anything starts its browser and waits for it, so it can take up to a minute to answer — no \`runner.runFlow\` is needed before acting; if the browser is still starting when the wait runs out, the answer is \`screen-not-ready\` and retrying converges. On a mobile or Windows runner, the same \`screen-needs-a-run\` and \`screen-not-ready\` outcomes mean no Appium session has started yet, or it did not answer this instant; \`runner.runFlow\` is what starts one, same as a browser. \`screen-needs-a-run\` if the browser could not be started that way — usually a runner whose runs all finished without starting its desktop; call \`runner.runFlow\` with a flow that opens a browser. ${screenNotReadyDescription} ${runnerHasNoScreenDescription} ${unreachableDescription}`,
17532
17548
  input,
17533
17549
  kind: "write",
17534
17550
  name: "runner.performAction",
@@ -17637,7 +17653,7 @@ var makePerformActionsOnRunnerContract = (ids) => {
17637
17653
  openWorldHint: true,
17638
17654
  readOnlyHint: false
17639
17655
  },
17640
- description: "Perform a sequence of raw actions on an interactive runner in one request, one after another, and answer with what happened to each. A `success` means every action took effect. A `failure` names the first action that did not (`failedIndex`, `failureReason`), the last one that did (`lastCompletedIndex`), and whether actions were left unperformed (`stoppedEarly`); `results` has one entry per action reached, in order. Read `effect` on an entry before sending its action again: `performed` means the runner did it; `not-performed` means the runner answered that it did not take effect, though a `navigate` that timed out may still be loading; `unknown` means the runner stopped answering with the action in flight (`runner-unreachable`), or its screen went quiet mid-action (`action-unconfirmed`), and it may have taken effect — a click that submitted a form, say — so take a screenshot instead of repeating it. A sequence gets about a minute to start its actions; an action it did not reach in time is `out-of-time`, nothing after it was attempted, and the rest can go in a new request. Everything `runner.performAction` says about a runner that has never run anything, a mobile runner, and the `screen-needs-a-run`, `screen-not-ready`, `runner-has-no-screen`, `action-not-supported-on-mobile` and `action-not-supported-on-browser` reasons holds for each action here.",
17656
+ description: "Perform a sequence of raw actions on an interactive runner in one request, one after another, and answer with what happened to each. A `success` means every action took effect. A `failure` names the first action that did not (`failedIndex`, `failureReason`), the last one that did (`lastCompletedIndex`), and whether actions were left unperformed (`stoppedEarly`); `results` has one entry per action reached, in order. Read `effect` on an entry before sending its action again: `performed` means the runner did it; `not-performed` means the runner answered that it did not take effect, though a `navigate` that timed out may still be loading; `unknown` means the runner stopped answering with the action in flight (`runner-unreachable`), or its screen went quiet mid-action (`action-unconfirmed`), and it may have taken effect — a click that submitted a form, say — so take a screenshot instead of repeating it. A sequence gets about a minute to start its actions; an action it did not reach in time is `out-of-time`, nothing after it was attempted, and the rest can go in a new request. Everything `runner.performAction` says about a runner that has never run anything, a mobile or Windows runner, and the `screen-needs-a-run`, `screen-not-ready`, `runner-has-no-screen`, `action-not-supported-on-mobile` and `action-not-supported-on-browser` reasons holds for each action here.",
17641
17657
  input,
17642
17658
  kind: "write",
17643
17659
  name: "runner.performActions",
@@ -18230,6 +18246,88 @@ var makeAgentSendContract = (ids) => {
18230
18246
  };
18231
18247
  };
18232
18248
 
18249
+ // node_modules/@qawolf/api-contracts/dist/v1/attempt/get.js
18250
+ var makeGetAttemptContract = (ids) => {
18251
+ const input = object({ attemptId: ids.runAttempt });
18252
+ const attemptStatus = _enum([
18253
+ "passed",
18254
+ "failed",
18255
+ "canceled",
18256
+ "aborted",
18257
+ "skipped"
18258
+ ]);
18259
+ const attemptNeighbor = object({
18260
+ attemptId: ids.runAttempt,
18261
+ status: attemptStatus
18262
+ });
18263
+ const response = object({
18264
+ flowId: ids.flow,
18265
+ flowStatus: _enum(publicRunStatusValues),
18266
+ retryContext: object({
18267
+ currentOrdinal: number2().int().min(1),
18268
+ next: attemptNeighbor.optional(),
18269
+ previous: attemptNeighbor.optional(),
18270
+ total: number2().int().min(1)
18271
+ }),
18272
+ runId: ids.run,
18273
+ runStatus: _enum(publicRunSummaryStatusValues)
18274
+ });
18275
+ const attempt = object({
18276
+ attemptId: ids.runAttempt,
18277
+ completedAt: exports_iso.datetime().optional(),
18278
+ createdAt: exports_iso.datetime(),
18279
+ error: string2().optional(),
18280
+ startedAt: exports_iso.datetime().optional()
18281
+ });
18282
+ const output = discriminatedUnion("artifactStatus", [
18283
+ response.extend({
18284
+ artifacts: object({
18285
+ logsUrl: url().optional(),
18286
+ traceUrl: url().optional(),
18287
+ videoUrl: url().optional()
18288
+ }),
18289
+ artifactStatus: literal("signed"),
18290
+ attempt: attempt.extend({
18291
+ kind: literal("automated"),
18292
+ status: attemptStatus
18293
+ })
18294
+ }),
18295
+ response.extend({
18296
+ artifacts: object({}).strict(),
18297
+ artifactStatus: literal("signing-failed"),
18298
+ attempt: attempt.extend({
18299
+ kind: literal("automated"),
18300
+ status: attemptStatus
18301
+ })
18302
+ }),
18303
+ response.extend({
18304
+ artifacts: object({}).strict(),
18305
+ artifactStatus: literal("not-captured"),
18306
+ attempt: attempt.extend({
18307
+ kind: literal("manual"),
18308
+ status: literal("passed")
18309
+ })
18310
+ })
18311
+ ]);
18312
+ return {
18313
+ annotationJustifications: {
18314
+ destructiveHint: "Does not retry, cancel or alter the run attempt.",
18315
+ openWorldHint: "Reads recorded QA Wolf artifacts without changing the application under test.",
18316
+ readOnlyHint: "Retrieves a finished attempt's metadata and signed artifact URLs."
18317
+ },
18318
+ annotations: {
18319
+ destructiveHint: false,
18320
+ openWorldHint: false,
18321
+ readOnlyHint: true
18322
+ },
18323
+ description: "Get a finished run attempt: its run and flow status, its place among that flow's attempts in the run, and signed links to its logs, trace, and video when they were captured.",
18324
+ input,
18325
+ kind: "read",
18326
+ name: "attempt.get",
18327
+ output
18328
+ };
18329
+ };
18330
+
18233
18331
  // node_modules/@qawolf/api-contracts/dist/v1/codeHostIntegration/resource.js
18234
18332
  var makeCodeHostIntegrationResourceSchema = () => resource({
18235
18333
  connectedAt: exports_iso.datetime().describe("When the code host was connected to the workspace."),
@@ -18796,6 +18894,32 @@ var makeDeleteEnvironmentVariableContract = (ids) => {
18796
18894
  };
18797
18895
  };
18798
18896
 
18897
+ // node_modules/@qawolf/api-contracts/dist/v1/environment/discard.js
18898
+ var makeDiscardEnvironmentContract = (ids) => {
18899
+ const input = object({
18900
+ environmentId: ids.environmentRef,
18901
+ workspaceId: workspaceForEnvironmentRef(ids.workspace)
18902
+ });
18903
+ const output = makeEnvironmentResourceSchema(ids);
18904
+ return {
18905
+ annotationJustifications: {
18906
+ destructiveHint: "Terminates the environment for good: its runs are canceled and its flow changes are never promoted.",
18907
+ openWorldHint: "Changes QA Wolf environments only, not the customer's own repository or deployments.",
18908
+ readOnlyHint: "Terminates an environment and returns it terminated."
18909
+ },
18910
+ annotations: {
18911
+ destructiveHint: true,
18912
+ openWorldHint: false,
18913
+ readOnlyHint: false
18914
+ },
18915
+ description: "Declare a preview environment's work discarded, typically when its pull request closes without merging: the environment is terminated and its flow changes are not promoted into its base. Returns the environment, now terminated. A terminated environment cannot be discarded again. Use environment.promote instead when the work is accepted.",
18916
+ input,
18917
+ kind: "write",
18918
+ name: "environment.discard",
18919
+ output
18920
+ };
18921
+ };
18922
+
18799
18923
  // node_modules/@qawolf/api-contracts/dist/v1/environment/find.js
18800
18924
  var makeFindEnvironmentsContract = (ids) => {
18801
18925
  const input = object({
@@ -18941,6 +19065,58 @@ var makeSetEnvironmentVariableContract = (ids) => {
18941
19065
  };
18942
19066
  };
18943
19067
 
19068
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/resource.js
19069
+ var promotionStatusSchema = _enum([
19070
+ "pending",
19071
+ "conflicted",
19072
+ "resolving",
19073
+ "promoted",
19074
+ "no-changes",
19075
+ "abandoned"
19076
+ ]).describe("pending (requested, the merge has not run yet), conflicted (the head's flow changes clash with the base and await a resolution), resolving (a submitted resolution is being applied), promoted (merged into the base and the head environment terminated), no-changes (the head had nothing to promote and was terminated), abandoned (the head environment was discarded or terminated before the promotion settled).");
19077
+ var conflictSchema = object({
19078
+ paths: array(string2()).describe("Every path that conflicts between the head and the base. A resolution must cover exactly these paths."),
19079
+ sourceCommitHash: string2().describe("The head environment's flow code commit the conflict was computed against."),
19080
+ targetCommitHash: string2().describe("The base environment's flow code commit the conflict was computed against.")
19081
+ });
19082
+ var makePromotionResourceSchema = (ids) => resource({
19083
+ aiTaskId: ids.aiTask.optional().describe("The AI task dispatched to resolve this promotion's conflicts. Absent until the agent is dispatched. A promotion that stays conflicted after this is set means the agent could not resolve it."),
19084
+ baseEnvironmentId: ids.environment.describe("The environment the flow changes promote into."),
19085
+ conflict: conflictSchema.optional().describe("The conflict awaiting resolution. Present while status is conflicted or resolving. A resolution must name both commit hashes and cover exactly these paths; if either branch moves, the conflict is recomputed and this changes."),
19086
+ createdAt: exports_iso.datetime().describe("When the promotion was requested."),
19087
+ headEnvironmentId: ids.environment.describe("The environment whose flow changes are promoted."),
19088
+ id: ids.promotion,
19089
+ promotedCommitHash: string2().optional().describe("The commit the promotion landed on the base environment's flow code branch. Present when status is promoted."),
19090
+ settledAt: exports_iso.datetime().optional().describe("When the promotion reached promoted, no-changes or abandoned. Absent while it is open."),
19091
+ status: promotionStatusSchema
19092
+ }, { urlFieldDescription: "Absolute URL of the head environment's page." });
19093
+
19094
+ // node_modules/@qawolf/api-contracts/dist/v1/environment/promote.js
19095
+ var makePromoteEnvironmentContract = (ids) => {
19096
+ const input = object({
19097
+ environmentId: ids.environmentRef,
19098
+ workspaceId: workspaceForEnvironmentRef(ids.workspace)
19099
+ });
19100
+ const output = makePromotionResourceSchema(ids);
19101
+ return {
19102
+ annotationJustifications: {
19103
+ destructiveHint: "Merges the environment's flow changes into its base and terminates the environment once they land.",
19104
+ openWorldHint: "Changes QA Wolf flow code branches only, not the customer's own repository or deployments.",
19105
+ readOnlyHint: "Records a promotion request that a background executor carries out."
19106
+ },
19107
+ annotations: {
19108
+ destructiveHint: true,
19109
+ openWorldHint: false,
19110
+ readOnlyHint: false
19111
+ },
19112
+ description: "Declare a preview environment's work accepted, typically when its pull request merges: its flow changes are promoted into its base environment and the environment is terminated once they land. Returns the promotion in pending; poll promotion.get to learn how it settled. Calling again while a promotion is open returns that promotion. A conflict settles the promotion conflicted and cancels the environment's in-progress runs; promotion.get names the conflicting paths. Use environment.discard instead when the work is abandoned.",
19113
+ input,
19114
+ kind: "write",
19115
+ name: "environment.promote",
19116
+ output
19117
+ };
19118
+ };
19119
+
18944
19120
  // node_modules/@qawolf/api-contracts/dist/v1/environment/update.js
18945
19121
  var makeUpdateEnvironmentContract = (ids) => {
18946
19122
  const nameSchema = string2().trim().min(1).max(255).describe("New display name. Must be unique within the team.");
@@ -19303,7 +19479,8 @@ var makeInvestigationFindingSchema = (ids) => object({
19303
19479
  answer: string2().optional(),
19304
19480
  at: exports_iso.datetime(),
19305
19481
  reason: string2().optional(),
19306
- type: string2().describe('Known values: "answer" and "dispute". New values can appear.')
19482
+ text: string2().optional().describe("A person's answer in their own words, when they typed one."),
19483
+ type: string2().describe('Known values: "answer", "dispute" and "reply". New values can appear.')
19307
19484
  }).optional().describe("A person's answer or dispute that the investigation hasn't acted on yet."),
19308
19485
  state: string2().describe(investigationFindingStateDescription),
19309
19486
  steps: array(string2()).optional(),
@@ -19627,6 +19804,66 @@ var makeLegacyTriggerContracts = (ids) => ({
19627
19804
  resume: makeResumeLegacyTriggerContract(ids)
19628
19805
  });
19629
19806
 
19807
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/find.js
19808
+ var makeFindPromotionsContract = (ids) => {
19809
+ const input = object({
19810
+ environmentId: ids.environmentRef.optional().describe("Only list promotions out of this head environment, by id or alias. Omit to list the whole workspace's promotions."),
19811
+ status: promotionStatusSchema.optional().describe("Only list promotions in this status. Use conflicted to see the promotions that need attention."),
19812
+ workspaceId: ids.workspace.optional().describe("The workspace to list promotions from, which an environment alias resolves in. Required when authenticating with an organization or user API key."),
19813
+ ...makePaginationInputFields({ defaultLimit: 20, maxLimit: 100 })
19814
+ });
19815
+ const output = object({
19816
+ nextCursor: nextCursorSchema,
19817
+ promotions: array(makePromotionResourceSchema(ids)).describe("The workspace's promotions, newest first.")
19818
+ });
19819
+ return {
19820
+ annotationJustifications: {
19821
+ destructiveHint: "Does not change promotions, environments or flow code branches.",
19822
+ openWorldHint: "Reads private QA Wolf promotion records without changing external systems.",
19823
+ readOnlyHint: "Lists promotions in the authorized workspace without changing them."
19824
+ },
19825
+ annotations: {
19826
+ destructiveHint: false,
19827
+ openWorldHint: false,
19828
+ readOnlyHint: true
19829
+ },
19830
+ description: "List environment promotions, newest first. A promotion moves the flow changes made in a head environment into its base environment. Filter by status conflicted to find the promotions whose conflicts still need a resolution.",
19831
+ input,
19832
+ kind: "read",
19833
+ name: "promotion.find",
19834
+ output
19835
+ };
19836
+ };
19837
+
19838
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/get.js
19839
+ var makeGetPromotionContract = (ids) => {
19840
+ const input = object({ promotionId: ids.promotion });
19841
+ const output = makePromotionResourceSchema(ids);
19842
+ return {
19843
+ annotationJustifications: {
19844
+ destructiveHint: "Does not change the promotion, its environments or flow code branches.",
19845
+ openWorldHint: "Reads a private QA Wolf promotion record without changing external systems.",
19846
+ readOnlyHint: "Retrieves one authorized promotion's status and conflict without changing it."
19847
+ },
19848
+ annotations: {
19849
+ destructiveHint: false,
19850
+ openWorldHint: false,
19851
+ readOnlyHint: true
19852
+ },
19853
+ description: "Read one environment promotion: its status, the conflicting paths and commit hashes while it is conflicted or resolving, the commit it landed when promoted, and the AI task resolving it. Poll it after environment.promote to learn how the promotion settled. It does not serve file contents; a resolver reads both branches from the flow code repository.",
19854
+ input,
19855
+ kind: "read",
19856
+ name: "promotion.get",
19857
+ output
19858
+ };
19859
+ };
19860
+
19861
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/index.js
19862
+ var makePromotionContracts = (ids) => ({
19863
+ find: makeFindPromotionsContract(ids),
19864
+ get: makeGetPromotionContract(ids)
19865
+ });
19866
+
19630
19867
  // node_modules/@qawolf/api-contracts/dist/v1/run/investigationSessionId.js
19631
19868
  var investigationSessionId = string2().trim().min(1).max(100).optional();
19632
19869
 
@@ -19842,88 +20079,6 @@ var makeGetRunContract = (ids) => {
19842
20079
  };
19843
20080
  };
19844
20081
 
19845
- // node_modules/@qawolf/api-contracts/dist/v1/run/getAttemptArtifacts.js
19846
- var makeGetRunAttemptArtifactsContract = (ids) => {
19847
- const input = object({ attemptId: ids.runAttempt });
19848
- const attemptStatus = _enum([
19849
- "passed",
19850
- "failed",
19851
- "canceled",
19852
- "aborted",
19853
- "skipped"
19854
- ]);
19855
- const attemptNeighbor = object({
19856
- attemptId: ids.runAttempt,
19857
- status: attemptStatus
19858
- });
19859
- const response = object({
19860
- flowId: ids.flow,
19861
- flowStatus: _enum(publicRunStatusValues),
19862
- retryContext: object({
19863
- currentOrdinal: number2().int().min(1),
19864
- next: attemptNeighbor.optional(),
19865
- previous: attemptNeighbor.optional(),
19866
- total: number2().int().min(1)
19867
- }),
19868
- runId: ids.run,
19869
- runStatus: _enum(publicRunSummaryStatusValues)
19870
- });
19871
- const attempt = object({
19872
- attemptId: ids.runAttempt,
19873
- completedAt: exports_iso.datetime().optional(),
19874
- createdAt: exports_iso.datetime(),
19875
- error: string2().optional(),
19876
- startedAt: exports_iso.datetime().optional()
19877
- });
19878
- const output = discriminatedUnion("artifactStatus", [
19879
- response.extend({
19880
- artifacts: object({
19881
- logsUrl: url().optional(),
19882
- traceUrl: url().optional(),
19883
- videoUrl: url().optional()
19884
- }),
19885
- artifactStatus: literal("signed"),
19886
- attempt: attempt.extend({
19887
- kind: literal("automated"),
19888
- status: attemptStatus
19889
- })
19890
- }),
19891
- response.extend({
19892
- artifacts: object({}).strict(),
19893
- artifactStatus: literal("signing-failed"),
19894
- attempt: attempt.extend({
19895
- kind: literal("automated"),
19896
- status: attemptStatus
19897
- })
19898
- }),
19899
- response.extend({
19900
- artifacts: object({}).strict(),
19901
- artifactStatus: literal("not-captured"),
19902
- attempt: attempt.extend({
19903
- kind: literal("manual"),
19904
- status: literal("passed")
19905
- })
19906
- })
19907
- ]);
19908
- return {
19909
- annotationJustifications: {
19910
- destructiveHint: "Does not retry, cancel or alter the run attempt.",
19911
- openWorldHint: "Reads recorded QA Wolf artifacts without changing the application under test.",
19912
- readOnlyHint: "Retrieves a finished attempt's metadata and signed artifact URLs."
19913
- },
19914
- annotations: {
19915
- destructiveHint: false,
19916
- openWorldHint: false,
19917
- readOnlyHint: true
19918
- },
19919
- description: "Get metadata and signed artifact URLs for one finished run attempt.",
19920
- input,
19921
- kind: "read",
19922
- name: "run.getAttemptArtifacts",
19923
- output
19924
- };
19925
- };
19926
-
19927
20082
  // node_modules/@qawolf/api-contracts/dist/v1/run/optOutOfInvestigation.js
19928
20083
  var makeOptOutOfInvestigationRunContract = (ids) => {
19929
20084
  const input = object({
@@ -20520,7 +20675,7 @@ var makeTakeScreenshotOnRunnerContract = (ids) => {
20520
20675
  openWorldHint: false,
20521
20676
  readOnlyHint: false
20522
20677
  },
20523
- description: `Take one screenshot of an interactive runner's screen. On a runner with a browser the image is the whole virtual desktop, browser window and all; this refreshes the inactivity timer and can extend the runner's billed lifetime. On a mobile runner it is the device's own screen, re-encoded to JPEG on the pod so this contract reads one image format regardless of runner family. ${screenNeedsARunDescription} ${screenNotReadyDescription} ${runnerHasNoScreenDescription} ${retryableRunnerUnreachableDescription}`,
20678
+ description: `Take one screenshot of an interactive runner's screen. On a runner with a browser the image is the whole virtual desktop, browser window and all; this refreshes the inactivity timer and can extend the runner's billed lifetime. On a mobile runner it is the device's own screen, and on Windows the VM's whole desktop, re-encoded to JPEG on the pod so this contract reads one image format regardless of runner family. ${screenNeedsARunDescription} ${screenNotReadyDescription} ${runnerHasNoScreenDescription} ${retryableRunnerUnreachableDescription}`,
20524
20679
  input,
20525
20680
  kind: "read",
20526
20681
  name: "runner.takeScreenshot",
@@ -20652,6 +20807,9 @@ var makeContractsV1 = (ids) => {
20652
20807
  get: makeAgentGetContract(resolvedIds),
20653
20808
  send: makeAgentSendContract(resolvedIds)
20654
20809
  },
20810
+ attempt: {
20811
+ get: makeGetAttemptContract(resolvedIds)
20812
+ },
20655
20813
  codeHostIntegration: {
20656
20814
  find: makeFindCodeHostIntegrationsContract(resolvedIds),
20657
20815
  listRepositories: makeListCodeHostRepositoriesContract(resolvedIds)
@@ -20668,10 +20826,12 @@ var makeContractsV1 = (ids) => {
20668
20826
  environment: {
20669
20827
  create: makeCreateEnvironmentContract(resolvedIds),
20670
20828
  deleteVariable: makeDeleteEnvironmentVariableContract(resolvedIds),
20829
+ discard: makeDiscardEnvironmentContract(resolvedIds),
20671
20830
  find: makeFindEnvironmentsContract(resolvedIds),
20672
20831
  get: makeGetEnvironmentContract(resolvedIds),
20673
20832
  getVariable: makeGetEnvironmentVariableContract(resolvedIds),
20674
20833
  listVariableNames: makeListEnvironmentVariableNamesContract(resolvedIds),
20834
+ promote: makePromoteEnvironmentContract(resolvedIds),
20675
20835
  setVariable: makeSetEnvironmentVariableContract(resolvedIds),
20676
20836
  update: makeUpdateEnvironmentContract(resolvedIds)
20677
20837
  },
@@ -20692,13 +20852,13 @@ var makeContractsV1 = (ids) => {
20692
20852
  update: makeUpdateIssueContract(resolvedIds)
20693
20853
  },
20694
20854
  legacyTrigger: makeLegacyTriggerContracts(resolvedIds),
20855
+ promotion: makePromotionContracts(resolvedIds),
20695
20856
  run: {
20696
20857
  acceptScreenshotBaseline: makeAcceptScreenshotBaselineContract(resolvedIds),
20697
20858
  create: makeCreateRunContract(resolvedIds),
20698
20859
  diagnose: makeDiagnoseRunContract(resolvedIds),
20699
20860
  find: makeFindRunsContract(resolvedIds),
20700
20861
  get: makeGetRunContract(resolvedIds),
20701
- getAttemptArtifacts: makeGetRunAttemptArtifactsContract(resolvedIds),
20702
20862
  listScreenshotComparisons: makeListScreenshotComparisonsContract(resolvedIds),
20703
20863
  optOutOfInvestigation: makeOptOutOfInvestigationRunContract(resolvedIds),
20704
20864
  reattempt: makeReattemptRunContract(resolvedIds),
@@ -23219,7 +23379,7 @@ function startUpdateCheck(deps) {
23219
23379
  // package.json
23220
23380
  var package_default = {
23221
23381
  name: "@qawolf/cli",
23222
- version: "1.40.0",
23382
+ version: "1.41.0",
23223
23383
  description: "Run and manage QA Wolf flows from the terminal, CI, or an AI agent",
23224
23384
  keywords: [
23225
23385
  "automation",
@@ -23247,6 +23407,7 @@ var package_default = {
23247
23407
  "LICENSE",
23248
23408
  "README.md",
23249
23409
  "dist/cli.js",
23410
+ "dist/investigation-parser.js",
23250
23411
  "dist/runner-sdk.js",
23251
23412
  "dist/types/runnerSdk/index.d.ts",
23252
23413
  "dist/types/runnerSdk/types.d.ts",
@@ -23290,13 +23451,14 @@ var package_default = {
23290
23451
  "@clack/prompts": "1.5.1",
23291
23452
  "@napi-rs/keyring": "1.3.0",
23292
23453
  "@oxc-node/core": "0.1.0",
23293
- "@qawolf/api-contracts": "0.81.0",
23454
+ "@qawolf/api-contracts": "0.83.0",
23294
23455
  "@qawolf/emails": "1.1.1",
23295
23456
  "@qawolf/flow-targets": "1.0.0",
23296
23457
  "@qawolf/flows": "0.1.4",
23297
23458
  "@qawolf/testkit": "1.2.1",
23298
23459
  commander: "14.0.3",
23299
23460
  "env-paths": "4.0.0",
23461
+ jszip: "3.10.1",
23300
23462
  picomatch: "4.0.4",
23301
23463
  pino: "10.3.1",
23302
23464
  playwright: "1.62.0",
@@ -36377,6 +36539,387 @@ Examples:
36377
36539
  });
36378
36540
  }
36379
36541
 
36542
+ // src/domains/investigation/handle.ts
36543
+ import { basename as basename8 } from "node:path";
36544
+
36545
+ // src/domains/investigation/download.ts
36546
+ var traceLimit = 50 * 1024 * 1024;
36547
+ var logTailLimit = 5 * 1024 * 1024;
36548
+ var logTransferLimit = 50 * 1024 * 1024;
36549
+ var downloadTimeoutMs = 120000;
36550
+ function downloadFailure(error) {
36551
+ return { status: isTimeoutError(error) ? "timed-out" : "unavailable" };
36552
+ }
36553
+ async function responseFailure(response) {
36554
+ await response.body?.cancel().catch(() => {
36555
+ return;
36556
+ });
36557
+ if (response.status === 404)
36558
+ return { status: "not-found" };
36559
+ if (response.status === 401 || response.status === 403)
36560
+ return { status: "expired-url" };
36561
+ return { status: "unavailable" };
36562
+ }
36563
+ async function readBounded(response, options) {
36564
+ if (!response.ok)
36565
+ return responseFailure(response);
36566
+ const declaredLength = Number(response.headers.get("content-length"));
36567
+ if (Number.isFinite(declaredLength) && declaredLength > options.transferBytes) {
36568
+ await response.body?.cancel().catch(() => {
36569
+ return;
36570
+ });
36571
+ return { status: "too-large" };
36572
+ }
36573
+ if (!response.body)
36574
+ return { status: "unavailable" };
36575
+ const reader = response.body.getReader();
36576
+ const chunks = [];
36577
+ let retained = 0;
36578
+ let transferred = 0;
36579
+ while (true) {
36580
+ const next = await reader.read();
36581
+ if (next.done)
36582
+ break;
36583
+ const chunk = next.value;
36584
+ if (!(chunk instanceof Uint8Array)) {
36585
+ await reader.cancel();
36586
+ return { status: "unavailable" };
36587
+ }
36588
+ transferred += chunk.byteLength;
36589
+ if (transferred > options.transferBytes) {
36590
+ await reader.cancel();
36591
+ return { status: "too-large" };
36592
+ }
36593
+ chunks.push(chunk);
36594
+ retained += chunk.byteLength;
36595
+ if (options.keepTail) {
36596
+ while (chunks.length > 1 && retained - chunks[0].byteLength >= options.retainBytes) {
36597
+ retained -= chunks.shift().byteLength;
36598
+ }
36599
+ } else if (retained > options.retainBytes) {
36600
+ await reader.cancel();
36601
+ return { status: "too-large" };
36602
+ }
36603
+ }
36604
+ let bytes = Buffer.concat(chunks);
36605
+ const contentRange = response.headers.get("content-range");
36606
+ const rangeStart = contentRange ? Number(/^bytes (\d+)-/.exec(contentRange)?.[1]) : Number.NaN;
36607
+ let offset = Number.isFinite(rangeStart) ? rangeStart : transferred - bytes.byteLength;
36608
+ if (bytes.byteLength > options.retainBytes) {
36609
+ const removed = bytes.byteLength - options.retainBytes;
36610
+ bytes = bytes.subarray(removed);
36611
+ offset += removed;
36612
+ }
36613
+ return { bytes, offset, status: "available" };
36614
+ }
36615
+ async function downloadTrace(url, fetchImpl = globalThis.fetch) {
36616
+ try {
36617
+ const signal = AbortSignal.timeout(downloadTimeoutMs);
36618
+ const response = await fetchImpl(url, { redirect: "follow", signal });
36619
+ return await readBounded(response, {
36620
+ keepTail: false,
36621
+ retainBytes: traceLimit,
36622
+ transferBytes: traceLimit
36623
+ });
36624
+ } catch (error) {
36625
+ return downloadFailure(error);
36626
+ }
36627
+ }
36628
+ async function downloadLogTail(url, fetchImpl = globalThis.fetch) {
36629
+ try {
36630
+ const signal = AbortSignal.timeout(downloadTimeoutMs);
36631
+ const response = await fetchImpl(url, {
36632
+ headers: { range: `bytes=-${logTailLimit}` },
36633
+ redirect: "follow",
36634
+ signal
36635
+ });
36636
+ return await readBounded(response, {
36637
+ keepTail: true,
36638
+ retainBytes: logTailLimit,
36639
+ transferBytes: logTransferLimit
36640
+ });
36641
+ } catch (error) {
36642
+ return downloadFailure(error);
36643
+ }
36644
+ }
36645
+
36646
+ // src/domains/investigation/lazyParser.ts
36647
+ var parserPromise;
36648
+ function loadInvestigationParser() {
36649
+ parserPromise ??= import(parserSpecifier());
36650
+ return parserPromise;
36651
+ }
36652
+ function parserSpecifier() {
36653
+ const embedded = globalThis.qawolfInvestigationParserPath;
36654
+ if (embedded)
36655
+ return embedded;
36656
+ const sourceModule = import.meta.url.includes("/src/domains/investigation/");
36657
+ return new URL(sourceModule ? "./parser/index.ts" : "./investigation-parser.js", import.meta.url).href;
36658
+ }
36659
+
36660
+ // src/domains/investigation/handle.ts
36661
+ function artifactUnavailable(status) {
36662
+ return { status };
36663
+ }
36664
+ async function loadSummaryArtifacts(value) {
36665
+ if (value.artifactStatus !== "signed") {
36666
+ const unavailable = artifactUnavailable(value.artifactStatus);
36667
+ return { logs: unavailable, trace: unavailable };
36668
+ }
36669
+ const [logs, trace] = await Promise.all([
36670
+ value.artifacts.logsUrl ? downloadLogTail(value.artifacts.logsUrl) : artifactUnavailable("not-captured"),
36671
+ value.artifacts.traceUrl ? downloadTrace(value.artifacts.traceUrl) : artifactUnavailable("not-captured")
36672
+ ]);
36673
+ return { logs, trace };
36674
+ }
36675
+ async function loadInspectArtifact(value, type) {
36676
+ const inactive = artifactUnavailable("not-captured");
36677
+ if (value.artifactStatus !== "signed") {
36678
+ const unavailable = artifactUnavailable(value.artifactStatus);
36679
+ return type === "log" ? { logs: unavailable, trace: inactive } : { logs: inactive, trace: unavailable };
36680
+ }
36681
+ if (type === "log") {
36682
+ return {
36683
+ logs: value.artifacts.logsUrl ? await downloadLogTail(value.artifacts.logsUrl) : inactive,
36684
+ trace: inactive
36685
+ };
36686
+ }
36687
+ return {
36688
+ logs: inactive,
36689
+ trace: value.artifacts.traceUrl ? await downloadTrace(value.artifacts.traceUrl) : inactive
36690
+ };
36691
+ }
36692
+ var defaultInspectLimit = "20";
36693
+ var maxInspectLimit = 100;
36694
+ var filterSelectors = [
36695
+ ["evidenceId", "--evidence-id", ["console", "log"]],
36696
+ ["limit", "--limit", ["timeline", "network", "console", "log"]],
36697
+ ["startTimeMs", "--start-time-ms", ["network", "console"]],
36698
+ ["endTimeMs", "--end-time-ms", ["network", "console"]],
36699
+ ["startTimestamp", "--start-timestamp", ["log"]],
36700
+ ["endTimestamp", "--end-timestamp", ["log"]],
36701
+ ["source", "--source", ["log"]],
36702
+ ["method", "--method", ["network"]],
36703
+ ["status", "--status", ["network"]],
36704
+ ["urlContains", "--url-contains", ["network"]]
36705
+ ];
36706
+ function inapplicableFilter(options) {
36707
+ for (const [field, flag, selectors] of filterSelectors) {
36708
+ if (options[field] === undefined || selectors.includes(options.type))
36709
+ continue;
36710
+ const allowed = selectors.map((selector) => `--${selector}`).join(", ");
36711
+ return {
36712
+ error: `${flag} does not apply to --${options.type}; use it with ${allowed}.`
36713
+ };
36714
+ }
36715
+ return;
36716
+ }
36717
+ function numberFlag(value, name, options = {}) {
36718
+ if (value === undefined)
36719
+ return;
36720
+ const parsed = Number(value);
36721
+ if (!Number.isFinite(parsed) || options.integer === true && !Number.isInteger(parsed) || options.min !== undefined && parsed < options.min)
36722
+ return { error: `Invalid ${name}: ${value}.` };
36723
+ if (options.max !== undefined && parsed > options.max)
36724
+ return { error: `${name} must be at most ${options.max}, got ${value}.` };
36725
+ return parsed;
36726
+ }
36727
+ function timestampFlag(value, name) {
36728
+ if (value === undefined || !Number.isNaN(Date.parse(value)))
36729
+ return;
36730
+ return {
36731
+ error: `Invalid ${name}: ${value}. Use an ISO 8601 timestamp such as 2026-01-31T12:00:00Z.`
36732
+ };
36733
+ }
36734
+ function validateInspect(options) {
36735
+ if (options.type === "action" && !options.actionId)
36736
+ return { error: "--action requires an evidence ID." };
36737
+ if (options.type === "request" && !options.requestId)
36738
+ return { error: "--request requires an evidence ID." };
36739
+ if (options.type === "snapshot" && !options.snapshotId)
36740
+ return { error: "--snapshot requires an evidence ID." };
36741
+ if (options.type === "screenshot" && !options.screenshotId)
36742
+ return { error: "--screenshot requires an evidence ID." };
36743
+ if (options.format === "html" && options.type !== "snapshot")
36744
+ return { error: "--format html is supported only with --snapshot." };
36745
+ if (options.type === "screenshot" && !options.outputFile)
36746
+ return {
36747
+ error: "--output-file is required for screenshot evidence."
36748
+ };
36749
+ if (options.outputFile && options.format !== "html" && options.type !== "screenshot")
36750
+ return {
36751
+ error: "--output-file is supported only with --snapshot and --format html, or with --screenshot."
36752
+ };
36753
+ return;
36754
+ }
36755
+ function renderText(result) {
36756
+ return JSON.stringify(result, undefined, 2);
36757
+ }
36758
+ async function fetchAttempt(ctx, attemptId) {
36759
+ return ctx.platformClient.callPublicApi(publicContractsV1.attempt.get, {
36760
+ attemptId
36761
+ });
36762
+ }
36763
+ async function handleInvestigationSummary(ctx, attemptId) {
36764
+ const authorized = await fetchAttempt(ctx, attemptId);
36765
+ if (!authorized.ok)
36766
+ return failureFields(authorized);
36767
+ const artifacts = await loadSummaryArtifacts(authorized.value);
36768
+ const parser = await loadInvestigationParser();
36769
+ const evidence = await parser.investigate({
36770
+ artifacts,
36771
+ attempt: authorized.value.attempt,
36772
+ flowId: authorized.value.flowId,
36773
+ mode: "summary",
36774
+ runId: authorized.value.runId
36775
+ });
36776
+ const result = {
36777
+ ...authorized.value,
36778
+ artifacts: undefined,
36779
+ evidence
36780
+ };
36781
+ ctx.ui.output(result, renderText(result));
36782
+ return;
36783
+ }
36784
+ async function handleInvestigationInspect(ctx, options) {
36785
+ const invalid = validateInspect(options) ?? inapplicableFilter(options);
36786
+ if (invalid)
36787
+ return invalid;
36788
+ if (options.outputFile && await ctx.fs.pathExists(options.outputFile))
36789
+ return {
36790
+ error: `Refusing to overwrite existing file: ${options.outputFile}`
36791
+ };
36792
+ const limit = numberFlag(options.limit ?? defaultInspectLimit, "--limit", {
36793
+ integer: true,
36794
+ max: maxInspectLimit,
36795
+ min: 1
36796
+ });
36797
+ if (typeof limit !== "number")
36798
+ return limit;
36799
+ const startTimeMilliseconds = numberFlag(options.startTimeMs, "--start-time-ms");
36800
+ if (typeof startTimeMilliseconds === "object")
36801
+ return startTimeMilliseconds;
36802
+ const endTimeMilliseconds = numberFlag(options.endTimeMs, "--end-time-ms");
36803
+ if (typeof endTimeMilliseconds === "object")
36804
+ return endTimeMilliseconds;
36805
+ const status = numberFlag(options.status, "--status", {
36806
+ integer: true,
36807
+ min: 0
36808
+ });
36809
+ if (typeof status === "object")
36810
+ return status;
36811
+ const timestampError = timestampFlag(options.startTimestamp, "--start-timestamp") ?? timestampFlag(options.endTimestamp, "--end-timestamp");
36812
+ if (timestampError)
36813
+ return timestampError;
36814
+ const authorized = await fetchAttempt(ctx, options.attemptId);
36815
+ if (!authorized.ok)
36816
+ return failureFields(authorized);
36817
+ const artifacts = await loadInspectArtifact(authorized.value, options.type);
36818
+ const request = {
36819
+ artifacts,
36820
+ attempt: authorized.value.attempt,
36821
+ flowId: authorized.value.flowId,
36822
+ inspect: {
36823
+ actionId: options.actionId,
36824
+ endTimeMilliseconds,
36825
+ endTimestamp: options.endTimestamp,
36826
+ evidenceId: options.evidenceId,
36827
+ format: options.format,
36828
+ limit,
36829
+ method: options.method,
36830
+ requestId: options.requestId,
36831
+ screenshotId: options.screenshotId,
36832
+ snapshotId: options.snapshotId,
36833
+ source: options.source,
36834
+ startTimeMilliseconds,
36835
+ startTimestamp: options.startTimestamp,
36836
+ status,
36837
+ type: options.type,
36838
+ urlContains: options.urlContains
36839
+ },
36840
+ mode: "inspect",
36841
+ runId: authorized.value.runId
36842
+ };
36843
+ const parser = await loadInvestigationParser();
36844
+ const parsed = await parser.investigate(request);
36845
+ return outputInvestigationInspection(ctx, options, parsed);
36846
+ }
36847
+ async function outputInvestigationInspection(ctx, options, parsed) {
36848
+ const { binary, ...result } = parsed;
36849
+ if (options.outputFile) {
36850
+ if (!binary)
36851
+ return {
36852
+ error: "The requested evidence did not contain exportable data."
36853
+ };
36854
+ const written = await ctx.fs.writeFileExclusive(options.outputFile, Buffer.from(binary.bytesBase64, "base64"), { mode: 384 });
36855
+ if (!written)
36856
+ return {
36857
+ error: `Refusing to overwrite existing file: ${options.outputFile}`
36858
+ };
36859
+ const output = { ...result, outputFile: options.outputFile };
36860
+ ctx.ui.output(output, `${renderText(result)}
36861
+ Saved ${binary.extension}: ${basename8(options.outputFile)}`);
36862
+ return;
36863
+ }
36864
+ if (binary?.extension === "html") {
36865
+ const html = Buffer.from(binary.bytesBase64, "base64").toString("utf8");
36866
+ ctx.ui.output({ ...result, html }, html);
36867
+ return;
36868
+ }
36869
+ ctx.ui.output(result, renderText(result));
36870
+ return;
36871
+ }
36872
+
36873
+ // src/commands/attempt/inspectSelection.ts
36874
+ function resolveInspectSelection(options) {
36875
+ const candidates = [
36876
+ options.action === undefined ? undefined : { actionId: options.action, type: "action" },
36877
+ options.timeline ? { type: "timeline" } : undefined,
36878
+ options.network ? { type: "network" } : undefined,
36879
+ options.request === undefined ? undefined : { requestId: options.request, type: "request" },
36880
+ options.snapshot === undefined ? undefined : { snapshotId: options.snapshot, type: "snapshot" },
36881
+ options.screenshot === undefined ? undefined : { screenshotId: options.screenshot, type: "screenshot" },
36882
+ options.console ? { type: "console" } : undefined,
36883
+ options.log ? { type: "log" } : undefined
36884
+ ];
36885
+ const selected = candidates.filter((selection) => selection !== undefined);
36886
+ return selected.length === 1 ? selected[0] : {
36887
+ error: "Choose exactly one evidence selector: --action, --timeline, --network, --request, --snapshot, --screenshot, --console, or --log."
36888
+ };
36889
+ }
36890
+
36891
+ // src/commands/attempt/index.ts
36892
+ function parseFormat(value) {
36893
+ if (value === "html" || value === "text")
36894
+ return value;
36895
+ throw new Error("Expected text or html.");
36896
+ }
36897
+ function registerAttemptCommand(program, signals) {
36898
+ const attempt = program.command("attempt").description("Investigate a finished run attempt from recorded evidence");
36899
+ declareCommandKind(attempt.command("investigate"), "read").description("Summarize the evidence for one finished attempt").requiredOption("--attempt-id <id>", "Attempt to summarize").action((options, command) => withAuthContext(signals, (ctx) => handleInvestigationSummary(ctx, options.attemptId))(options, command));
36900
+ declareCommandKind(attempt.command("inspect"), "read").description("Inspect one kind of evidence for a finished attempt").requiredOption("--attempt-id <id>", "Attempt to inspect").option("--action <id>", "Inspect one action evidence ID").option("--timeline", "Inspect the action timeline").option("--network", "Inspect network requests").option("--request <id>", "Inspect one network request evidence ID").option("--snapshot <id>", "Inspect one page snapshot evidence ID").option("--screenshot <id>", "Export one screenshot evidence ID").option("--console", "Inspect browser console evidence").option("--log", "Inspect execution log evidence").option("--evidence-id <id>", "Return only this console or log record").option("--limit <number>", "Maximum entries to return, 20 by default and up to 100: the most recent for --timeline, --network and --log, the earliest for --console").option("--start-time-ms <number>", "Earliest trace timestamp in milliseconds").option("--end-time-ms <number>", "Latest trace timestamp in milliseconds").option("--start-timestamp <iso>", "Earliest execution log timestamp").option("--end-timestamp <iso>", "Latest execution log timestamp").addOption(new Option2("--source <source>", "Execution log source").choices([
36901
+ "qawolfTraceCollection",
36902
+ "serverConsole"
36903
+ ])).option("--method <method>", "Network HTTP method").option("--status <code>", "Network HTTP status").option("--url-contains <text>", "Network URL substring").option("--format <format>", "Snapshot format (text or html)", parseFormat, "text").option("--output-file <path>", "Write HTML or screenshot bytes without overwriting").action((options, command) => {
36904
+ const selection = resolveInspectSelection(options);
36905
+ if ("error" in selection)
36906
+ return command.error(selection.error);
36907
+ const {
36908
+ action: _action,
36909
+ console: _console,
36910
+ log: _log,
36911
+ network: _network,
36912
+ request: _request,
36913
+ screenshot: _screenshot,
36914
+ snapshot: _snapshot,
36915
+ timeline: _timeline,
36916
+ ...common
36917
+ } = options;
36918
+ const normalized = { ...common, ...selection };
36919
+ return withAuthContext(signals, (ctx) => handleInvestigationInspect(ctx, normalized))(options, command);
36920
+ });
36921
+ }
36922
+
36380
36923
  // src/core/publicApi/flagNames.ts
36381
36924
  var kebabCase = (segment) => segment.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
36382
36925
  var capitalize = (segment) => `${segment.slice(0, 1).toUpperCase()}${segment.slice(1)}`;
@@ -39961,6 +40504,7 @@ function createProgram({
39961
40504
  registerFlowsCommand(program, signals);
39962
40505
  registerInitCommand(program, signals);
39963
40506
  registerInstallCommand(program, signals);
40507
+ registerAttemptCommand(program, signals);
39964
40508
  registerRunnerCommand(program, signals);
39965
40509
  registerPublicApiCommands(program, signals);
39966
40510
  registerHelpCommand(program);
@@ -39977,4 +40521,4 @@ createProgram({ signals }).parseAsync().catch(() => {
39977
40521
  process.exitCode = 1;
39978
40522
  }).finally(() => exitWhenIdle(typeof process.exitCode === "number" ? process.exitCode : 0));
39979
40523
 
39980
- //# debugId=A9F5B8A99DA7D0CB64756E2164756E21
40524
+ //# debugId=60ABEEB099A36FAE64756E2164756E21