@qawolf/cli 1.40.0 → 1.42.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);
@@ -16590,6 +16604,146 @@ async function downloadBundle(signedUrl, deps) {
16590
16604
  return { ok: true, value: { tmpArchive } };
16591
16605
  }
16592
16606
 
16607
+ // node_modules/@qawolf/api-contracts/dist/v1/pagination.js
16608
+ var makePaginationInputFields = (limits) => ({
16609
+ cursor: string2().min(1).optional().describe("Opaque cursor copied from the previous response's nextCursor. Omit to fetch the first page."),
16610
+ limit: number2().int().min(1).max(limits.maxLimit).default(limits.defaultLimit).describe(`Maximum rows per page. Defaults to ${limits.defaultLimit}, capped at ${limits.maxLimit}.`)
16611
+ });
16612
+ var nextCursorSchema = string2().min(1).optional().describe("Repeat the request with this value as cursor to fetch the next page. Absent when there are no further results.");
16613
+
16614
+ // node_modules/@qawolf/api-contracts/dist/v1/resource.js
16615
+ function resource(fields, { urlFieldDescription = "Absolute URL." } = {}) {
16616
+ return object({
16617
+ ...fields,
16618
+ url: url().describe(urlFieldDescription)
16619
+ });
16620
+ }
16621
+
16622
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/resource.js
16623
+ var promotionStatusSchema = _enum([
16624
+ "pending",
16625
+ "conflicted",
16626
+ "resolving",
16627
+ "promoted",
16628
+ "no-changes",
16629
+ "abandoned"
16630
+ ]).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 terminated before the promotion settled).");
16631
+ var conflictSchema = object({
16632
+ paths: array(string2()).describe("Every path that conflicts between the head and the base. A resolution must cover exactly these paths."),
16633
+ sourceCommitHash: string2().describe("The head environment's flow code commit the conflict was computed against."),
16634
+ targetCommitHash: string2().describe("The base environment's flow code commit the conflict was computed against.")
16635
+ });
16636
+ var makePromotionResourceSchema = (ids) => resource({
16637
+ 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."),
16638
+ baseEnvironmentId: ids.environment.describe("The environment the flow changes promote into."),
16639
+ 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."),
16640
+ createdAt: exports_iso.datetime().describe("When the promotion was requested."),
16641
+ headEnvironmentId: ids.environment.describe("The environment whose flow changes are promoted."),
16642
+ id: ids.promotion,
16643
+ promotedCommitHash: string2().optional().describe("The commit the promotion landed on the base environment's flow code branch. Present when status is promoted."),
16644
+ settledAt: exports_iso.datetime().optional().describe("When the promotion reached promoted, no-changes or abandoned. Absent while it is open."),
16645
+ status: promotionStatusSchema
16646
+ }, { urlFieldDescription: "Absolute URL of the head environment's page." });
16647
+
16648
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/find.js
16649
+ var makeFindPromotionsContract = (ids) => {
16650
+ const input = object({
16651
+ 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."),
16652
+ status: promotionStatusSchema.optional().describe("Only list promotions in this status. Use conflicted to see the promotions that need attention."),
16653
+ 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."),
16654
+ ...makePaginationInputFields({ defaultLimit: 20, maxLimit: 100 })
16655
+ });
16656
+ const output = object({
16657
+ nextCursor: nextCursorSchema,
16658
+ promotions: array(makePromotionResourceSchema(ids)).describe("The workspace's promotions, newest first.")
16659
+ });
16660
+ return {
16661
+ annotationJustifications: {
16662
+ destructiveHint: "Does not change promotions, environments or flow code branches.",
16663
+ openWorldHint: "Reads private QA Wolf promotion records without changing external systems.",
16664
+ readOnlyHint: "Lists promotions in the authorized workspace without changing them."
16665
+ },
16666
+ annotations: {
16667
+ destructiveHint: false,
16668
+ openWorldHint: false,
16669
+ readOnlyHint: true
16670
+ },
16671
+ 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.",
16672
+ input,
16673
+ kind: "read",
16674
+ name: "promotion.find",
16675
+ output
16676
+ };
16677
+ };
16678
+
16679
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/get.js
16680
+ var makeGetPromotionContract = (ids) => {
16681
+ const input = object({ promotionId: ids.promotion });
16682
+ const output = makePromotionResourceSchema(ids);
16683
+ return {
16684
+ annotationJustifications: {
16685
+ destructiveHint: "Does not change the promotion, its environments or flow code branches.",
16686
+ openWorldHint: "Reads a private QA Wolf promotion record without changing external systems.",
16687
+ readOnlyHint: "Retrieves one authorized promotion's status and conflict without changing it."
16688
+ },
16689
+ annotations: {
16690
+ destructiveHint: false,
16691
+ openWorldHint: false,
16692
+ readOnlyHint: true
16693
+ },
16694
+ 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.",
16695
+ input,
16696
+ kind: "read",
16697
+ name: "promotion.get",
16698
+ output
16699
+ };
16700
+ };
16701
+
16702
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/resolve.js
16703
+ var maxResolvedFileBytes = 1e6;
16704
+ var utf8ByteLength = (content) => new TextEncoder().encode(content).byteLength;
16705
+ var keptFileSizeIssues = (writes) => Object.entries(writes).map(([path, content]) => ({ bytes: utf8ByteLength(content), path })).filter(({ bytes }) => bytes >= maxResolvedFileBytes).map(({ bytes, path }) => ({
16706
+ code: "custom",
16707
+ message: `Each kept file must be under ${maxResolvedFileBytes} bytes of UTF-8; ${path} is ${bytes} bytes.`,
16708
+ path: [path]
16709
+ }));
16710
+ var makeResolvePromotionContract = (ids) => {
16711
+ const input = object({
16712
+ deletes: array(string2().min(1)).optional().describe("Conflicting paths to remove from the base environment. Repeat the flag once per path."),
16713
+ expectedSourceCommitHash: string2().min(1).describe("The head environment's commit the conflict was computed against: conflict.sourceCommitHash from promotion.get. A different current commit means the branch moved and the call is refused."),
16714
+ expectedTargetCommitHash: string2().min(1).describe("The base environment's commit the conflict was computed against: conflict.targetCommitHash from promotion.get. A different current commit means the branch moved and the call is refused."),
16715
+ promotionId: ids.promotion,
16716
+ writes: record(string2().min(1), string2()).superRefine((writes, refinement) => {
16717
+ keptFileSizeIssues(writes).forEach((issue) => refinement.addIssue(issue));
16718
+ }).optional().describe("The resolved full contents of each conflicting path to keep, keyed by path. Repeat the flag once per path as PATH=CONTENT. Each file must be under 1 MB of UTF-8.")
16719
+ });
16720
+ const output = makePromotionResourceSchema(ids);
16721
+ return {
16722
+ annotationJustifications: {
16723
+ destructiveHint: "Lands the resolved files on the base environment's flow code branch and terminates the head environment once they land.",
16724
+ openWorldHint: "Changes QA Wolf flow code branches only, not the customer's own repository or deployments.",
16725
+ readOnlyHint: "Records a resolution that a background executor applies to the base branch."
16726
+ },
16727
+ annotations: {
16728
+ destructiveHint: true,
16729
+ openWorldHint: false,
16730
+ readOnlyHint: false
16731
+ },
16732
+ description: "Submit the resolution of a conflicted promotion: the full resolved contents of every conflicting path to keep, and every conflicting path to delete. Together they must cover exactly the paths in the promotion's conflict, and both commit hashes must match the conflict's; if a branch moved since, the call is refused as stale-conflict and promotion.get has the current conflict. Returns the promotion in resolving; poll promotion.get until it is promoted, or conflicted again if the branches moved while it applied.",
16733
+ input,
16734
+ kind: "write",
16735
+ name: "promotion.resolve",
16736
+ output
16737
+ };
16738
+ };
16739
+
16740
+ // node_modules/@qawolf/api-contracts/dist/v1/promotion/index.js
16741
+ var makePromotionContracts = (ids) => ({
16742
+ find: makeFindPromotionsContract(ids),
16743
+ get: makeGetPromotionContract(ids),
16744
+ resolve: makeResolvePromotionContract(ids)
16745
+ });
16746
+
16593
16747
  // node_modules/@qawolf/api-contracts/dist/v1/agent/status.js
16594
16748
  var agentSessionStatuses = [
16595
16749
  "working",
@@ -16686,14 +16840,6 @@ var didNotRunReasonSchema = _enum([
16686
16840
  ].join(`
16687
16841
  `));
16688
16842
 
16689
- // node_modules/@qawolf/api-contracts/dist/v1/resource.js
16690
- function resource(fields, { urlFieldDescription = "Absolute URL." } = {}) {
16691
- return object({
16692
- ...fields,
16693
- url: url().describe(urlFieldDescription)
16694
- });
16695
- }
16696
-
16697
16843
  // node_modules/@qawolf/api-contracts/dist/v1/email/resource.js
16698
16844
  var emailDirectionSchema = _enum(["inbound", "outbound"]);
16699
16845
  var namedAddressSchema = object({
@@ -16860,6 +17006,7 @@ var defaultIdSchemas = {
16860
17006
  flow: string2().min(1).describe("The id of the flow."),
16861
17007
  issue: string2().min(1).describe("The id of the issue."),
16862
17008
  legacyTrigger: string2().min(1).describe("The id of the legacy trigger, from legacyTrigger.find."),
17009
+ promotion: string2().min(1).describe("The id of the promotion, from promotion.find or environment.promote."),
16863
17010
  run: string2().min(1).describe("The id of the run."),
16864
17011
  runAttempt: string2().min(1).describe("The id of the run attempt."),
16865
17012
  trigger: string2().min(1).describe("The id of the trigger."),
@@ -17180,7 +17327,7 @@ var makeInspectOnRunnerContract = (ids) => {
17180
17327
  openWorldHint: false,
17181
17328
  readOnlyHint: false
17182
17329
  },
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,
17330
+ 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
17331
  input,
17185
17332
  kind: "read",
17186
17333
  name: "runner.inspect",
@@ -17250,8 +17397,8 @@ var elementsRequestSchema = discriminatedUnion("by", [
17250
17397
  by: literal("point"),
17251
17398
  context: string2().min(1).optional(),
17252
17399
  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.")
17400
+ x: int().min(0).describe("Whole pixels in the same space as `runner.takeScreenshot`."),
17401
+ y: int().min(0).describe("Whole pixels in the same space as `runner.takeScreenshot`.")
17255
17402
  }),
17256
17403
  object({
17257
17404
  by: literal("text"),
@@ -17313,7 +17460,7 @@ var inspectMobileAnswerSchema = discriminatedUnion("what", [
17313
17460
  context: string2(),
17314
17461
  orientation: orientationSchema,
17315
17462
  outcome: literal("success"),
17316
- pageSource: pageSourceNodeSchema,
17463
+ 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
17464
  what: literal("page")
17318
17465
  }),
17319
17466
  object({
@@ -17349,7 +17496,7 @@ var makeInspectMobileOnRunnerContract = (ids) => {
17349
17496
  openWorldHint: false,
17350
17497
  readOnlyHint: true
17351
17498
  },
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}`,
17499
+ 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
17500
  input,
17354
17501
  kind: "read",
17355
17502
  name: "runner.inspectMobile",
@@ -17394,9 +17541,9 @@ var readJournalResponseSchema = object({
17394
17541
  var maxRunFilesByteLength = 30 * 1024 * 1024;
17395
17542
  var maxRunnerRequestEncodedByteLength = 30 * 1024 * 1024;
17396
17543
  function runFilesByteLength(files) {
17397
- return Object.entries(files).reduce((total, [path, content]) => total + utf8ByteLength(content) + utf8ByteLength(path), 0);
17544
+ return Object.entries(files).reduce((total, [path, content]) => total + utf8ByteLength2(content) + utf8ByteLength2(path), 0);
17398
17545
  }
17399
- function utf8ByteLength(text) {
17546
+ function utf8ByteLength2(text) {
17400
17547
  return Buffer.byteLength(text, "utf8");
17401
17548
  }
17402
17549
  var runFilesSchema = record(string2(), string2()).superRefine((files, refinementContext) => {
@@ -17478,19 +17625,20 @@ var screenFailureReasons = [
17478
17625
  "screen-not-ready"
17479
17626
  ];
17480
17627
  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`.";
17628
+ 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.";
17629
+ 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
17630
  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
17631
 
17485
17632
  // node_modules/@qawolf/api-contracts/dist/v1/runner/performAction.js
17486
17633
  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.";
17634
+ 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.";
17635
+ 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`.";
17636
+ 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.";
17637
+ 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
17638
  var maxActionErrorMessageLength = 1000;
17491
17639
  var makePerformActionOnRunnerContract = (ids) => {
17492
17640
  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}`),
17641
+ 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
17642
  id: runnerIdSchema.describe("Id of the runner to act on."),
17495
17643
  withScreenshot: boolean2().optional().describe(withScreenshotDescription),
17496
17644
  workspaceId: ids.workspace.optional().describe(runnerWorkspaceIdDescription)
@@ -17528,7 +17676,7 @@ var makePerformActionOnRunnerContract = (ids) => {
17528
17676
  openWorldHint: true,
17529
17677
  readOnlyHint: false
17530
17678
  },
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}`,
17679
+ 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
17680
  input,
17533
17681
  kind: "write",
17534
17682
  name: "runner.performAction",
@@ -17637,7 +17785,7 @@ var makePerformActionsOnRunnerContract = (ids) => {
17637
17785
  openWorldHint: true,
17638
17786
  readOnlyHint: false
17639
17787
  },
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.",
17788
+ 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
17789
  input,
17642
17790
  kind: "write",
17643
17791
  name: "runner.performActions",
@@ -17812,7 +17960,7 @@ var makeTriggerScheduleFields = (ids) => ({
17812
17960
  var makeTriggerDeploymentFields = (ids) => ({
17813
17961
  action: makeTriggerActionSchema(ids),
17814
17962
  branchPattern: string2().min(1).optional().describe("Only fire for deployments of a branch matching this pattern."),
17815
- deployTargetPattern: string2().min(1).optional().describe("Only fire for deployments whose deploy target matches this pattern. A deploy target is the URL or label the deploy reported, which many deployments do not carry."),
17963
+ deployTargetPattern: string2().min(1).optional().describe("Only fire for deployments whose deploy target matches this pattern. A deploy target is the URL the deploy reported, which many deployments do not carry."),
17816
17964
  environmentIds: array(ids.environment).default([]).describe("Only fire for deployments to these environments. Mutually exclusive with environmentPattern."),
17817
17965
  environmentPattern: string2().min(1).optional().describe("Only fire for deployments to environments matching this pattern. Mutually exclusive with environmentIds."),
17818
17966
  servicePattern: string2().min(1).optional().describe("Only fire for deployments whose service matches this pattern. A deployment that names no service never matches it.")
@@ -18163,7 +18311,7 @@ var makeAgentGetContract = (ids) => {
18163
18311
  const input = object({
18164
18312
  cursor: string2().min(1).optional().describe("Opaque cursor copied from this same session's previous nextCursor. Omit to read from its first reply."),
18165
18313
  sessionId: ids.chatSession.describe("The id agent.send answered with."),
18166
- waitSeconds: number2().int().min(0).optional().describe(`How long the server may hold this check open, in seconds. Omit or pass 0 to answer at once. A larger value clamps to ${maxAgentWaitSeconds}. Check again as soon as a held check returns.`)
18314
+ waitSeconds: number2().int().min(0).optional().describe(`How long the server may hold this check open, in seconds. Defaults to ${maxAgentWaitSeconds}, the longest hold, and a larger value clamps to it. Pass 0 to answer at once. Check again as soon as a held check returns.`)
18167
18315
  });
18168
18316
  const output = resource({
18169
18317
  nextCursor: string2().min(1).describe("Send back as cursor on the next check to read only what follows. Always present, even with no replies. Belongs to this session alone."),
@@ -18230,6 +18378,88 @@ var makeAgentSendContract = (ids) => {
18230
18378
  };
18231
18379
  };
18232
18380
 
18381
+ // node_modules/@qawolf/api-contracts/dist/v1/attempt/get.js
18382
+ var makeGetAttemptContract = (ids) => {
18383
+ const input = object({ attemptId: ids.runAttempt });
18384
+ const attemptStatus = _enum([
18385
+ "passed",
18386
+ "failed",
18387
+ "canceled",
18388
+ "aborted",
18389
+ "skipped"
18390
+ ]);
18391
+ const attemptNeighbor = object({
18392
+ attemptId: ids.runAttempt,
18393
+ status: attemptStatus
18394
+ });
18395
+ const response = object({
18396
+ flowId: ids.flow,
18397
+ flowStatus: _enum(publicRunStatusValues),
18398
+ retryContext: object({
18399
+ currentOrdinal: number2().int().min(1),
18400
+ next: attemptNeighbor.optional(),
18401
+ previous: attemptNeighbor.optional(),
18402
+ total: number2().int().min(1)
18403
+ }),
18404
+ runId: ids.run,
18405
+ runStatus: _enum(publicRunSummaryStatusValues)
18406
+ });
18407
+ const attempt = object({
18408
+ attemptId: ids.runAttempt,
18409
+ completedAt: exports_iso.datetime().optional(),
18410
+ createdAt: exports_iso.datetime(),
18411
+ error: string2().optional(),
18412
+ startedAt: exports_iso.datetime().optional()
18413
+ });
18414
+ const output = discriminatedUnion("artifactStatus", [
18415
+ response.extend({
18416
+ artifacts: object({
18417
+ logsUrl: url().optional(),
18418
+ traceUrl: url().optional(),
18419
+ videoUrl: url().optional()
18420
+ }),
18421
+ artifactStatus: literal("signed"),
18422
+ attempt: attempt.extend({
18423
+ kind: literal("automated"),
18424
+ status: attemptStatus
18425
+ })
18426
+ }),
18427
+ response.extend({
18428
+ artifacts: object({}).strict(),
18429
+ artifactStatus: literal("signing-failed"),
18430
+ attempt: attempt.extend({
18431
+ kind: literal("automated"),
18432
+ status: attemptStatus
18433
+ })
18434
+ }),
18435
+ response.extend({
18436
+ artifacts: object({}).strict(),
18437
+ artifactStatus: literal("not-captured"),
18438
+ attempt: attempt.extend({
18439
+ kind: literal("manual"),
18440
+ status: literal("passed")
18441
+ })
18442
+ })
18443
+ ]);
18444
+ return {
18445
+ annotationJustifications: {
18446
+ destructiveHint: "Does not retry, cancel or alter the run attempt.",
18447
+ openWorldHint: "Reads recorded QA Wolf artifacts without changing the application under test.",
18448
+ readOnlyHint: "Retrieves a finished attempt's metadata and signed artifact URLs."
18449
+ },
18450
+ annotations: {
18451
+ destructiveHint: false,
18452
+ openWorldHint: false,
18453
+ readOnlyHint: true
18454
+ },
18455
+ 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.",
18456
+ input,
18457
+ kind: "read",
18458
+ name: "attempt.get",
18459
+ output
18460
+ };
18461
+ };
18462
+
18233
18463
  // node_modules/@qawolf/api-contracts/dist/v1/codeHostIntegration/resource.js
18234
18464
  var makeCodeHostIntegrationResourceSchema = () => resource({
18235
18465
  connectedAt: exports_iso.datetime().describe("When the code host was connected to the workspace."),
@@ -18273,13 +18503,6 @@ var makeFindCodeHostIntegrationsContract = (ids) => {
18273
18503
  };
18274
18504
  };
18275
18505
 
18276
- // node_modules/@qawolf/api-contracts/dist/v1/pagination.js
18277
- var makePaginationInputFields = (limits) => ({
18278
- cursor: string2().min(1).optional().describe("Opaque cursor copied from the previous response's nextCursor. Omit to fetch the first page."),
18279
- limit: number2().int().min(1).max(limits.maxLimit).default(limits.defaultLimit).describe(`Maximum rows per page. Defaults to ${limits.defaultLimit}, capped at ${limits.maxLimit}.`)
18280
- });
18281
- var nextCursorSchema = string2().min(1).optional().describe("Repeat the request with this value as cursor to fetch the next page. Absent when there are no further results.");
18282
-
18283
18506
  // node_modules/@qawolf/api-contracts/dist/v1/codeHostIntegration/listRepositories.js
18284
18507
  var makeListCodeHostRepositoriesContract = (ids) => {
18285
18508
  const input = object({
@@ -18318,11 +18541,12 @@ var makeDeploymentResourceSchema = (ids) => resource({
18318
18541
  commitSha: string2().optional().describe("The sha of the deployed commit."),
18319
18542
  commitUrl: string2().optional().describe("A link to the deployed commit, as declared by the deployment report."),
18320
18543
  deployedAt: exports_iso.datetime().describe("When QA Wolf first received the deployment."),
18321
- deployTarget: string2().optional().describe("Identifies the deployed app within the environment: the URL it serves, or the build path of a mobile build. A trigger's deployTargetPattern matches against it."),
18544
+ deployTarget: string2().optional().describe("The URL the deployment serves. A trigger's deployTargetPattern matches against it."),
18322
18545
  environmentId: ids.environment.describe("The QA Wolf environment the deployment reported into."),
18323
18546
  environmentName: string2().optional().describe("The environment's name. Absent when the environment has since been deleted."),
18324
18547
  id: ids.deployment,
18325
18548
  provider: _enum(["github", "gitlab", "api"]).optional().describe("How QA Wolf received the deployment: a GitHub webhook, a GitLab webhook, or the deployment.reportStatus API."),
18549
+ repository: string2().optional().describe('The repository the deployment came from, as "owner/name". Absent when neither the code host nor the deployment report named one.'),
18326
18550
  service: string2().optional().describe("Which application was deployed, as the deployer named it. Absent when the deployer named none."),
18327
18551
  status: _enum(["pending", "success", "failure", "inactive"]).optional().describe("The deployment's lifecycle status, in the vocabulary deployment.reportStatus accepts. Absent when no status was ever reported.")
18328
18552
  }, {
@@ -18472,7 +18696,7 @@ var makeReportDeploymentStatusContract = (ids) => {
18472
18696
  error: "Send environment as either { id } or { name }, with optional ephemeral and baseEphemeralEnvironment."
18473
18697
  });
18474
18698
  const input = strictObject({
18475
- deployTarget: httpUrl().max(2048).describe("The URL the deployment serves, e.g. a preview URL.").optional(),
18699
+ deployTarget: httpUrl().max(2048).describe("The URL the deployment serves, e.g. a preview URL. A mobile pipeline leaves it unset and reports a service instead.").optional(),
18476
18700
  environment: environment.describe("Selects the environment the deployment reports into.").optional(),
18477
18701
  environmentVariables: record(string2(), string2()).describe("Environment variable overrides for the runs this deployment requests. A report that omits this field keeps the stored values. A report that sends it replaces them.").optional(),
18478
18702
  metadata: deploymentReportMetadata.describe("Details the deployer declares about the deployed revision; a code host integration's own record of the same commit is shown in preference to the message and author declared here.").optional(),
@@ -18720,6 +18944,7 @@ var makeSendEmailContract = (ids) => {
18720
18944
  // node_modules/@qawolf/api-contracts/dist/v1/environment/resource.js
18721
18945
  var makeEnvironmentResourceSchema = (ids) => resource({
18722
18946
  alias: string2().optional().describe("The environment's alias: a team-unique slug that team API keys can use in place of the id. Terminated environments have none."),
18947
+ baseEnvironmentId: ids.environment.optional().describe("The environment this one promotes its flow changes into, if it has a base."),
18723
18948
  flowCodeBranch: discriminatedUnion("syncStatus", [
18724
18949
  object({
18725
18950
  lastSyncedCommitHash: string2().describe("Hash of the latest reconciled commit."),
@@ -18733,6 +18958,7 @@ var makeEnvironmentResourceSchema = (ids) => resource({
18733
18958
  ]).optional().describe("The environment's flow code branch and its git reconciliation state, if it has one."),
18734
18959
  id: ids.environment,
18735
18960
  isDefault: boolean2().describe("Whether this is the workspace's default environment."),
18961
+ isDefaultBase: boolean2().describe("Whether this is the workspace's default base environment."),
18736
18962
  kind: _enum(["static", "preview"]).describe("Whether the environment is static or a preview."),
18737
18963
  name: string2(),
18738
18964
  runConcurrencyLimit: string2().describe('Maximum number of concurrent runs: a whole number, "unlimited", or a concurrency expression.'),
@@ -18941,6 +19167,58 @@ var makeSetEnvironmentVariableContract = (ids) => {
18941
19167
  };
18942
19168
  };
18943
19169
 
19170
+ // node_modules/@qawolf/api-contracts/dist/v1/environment/promote.js
19171
+ var makePromoteEnvironmentContract = (ids) => {
19172
+ const input = object({
19173
+ environmentId: ids.environmentRef,
19174
+ workspaceId: workspaceForEnvironmentRef(ids.workspace)
19175
+ });
19176
+ const output = makePromotionResourceSchema(ids);
19177
+ return {
19178
+ annotationJustifications: {
19179
+ destructiveHint: "Merges the environment's flow changes into its base and terminates the environment once they land.",
19180
+ openWorldHint: "Changes QA Wolf flow code branches only, not the customer's own repository or deployments.",
19181
+ readOnlyHint: "Records a promotion request that a background executor carries out."
19182
+ },
19183
+ annotations: {
19184
+ destructiveHint: true,
19185
+ openWorldHint: false,
19186
+ readOnlyHint: false
19187
+ },
19188
+ 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.terminate instead when the work is abandoned.",
19189
+ input,
19190
+ kind: "write",
19191
+ name: "environment.promote",
19192
+ output
19193
+ };
19194
+ };
19195
+
19196
+ // node_modules/@qawolf/api-contracts/dist/v1/environment/terminate.js
19197
+ var makeTerminateEnvironmentContract = (ids) => {
19198
+ const input = object({
19199
+ environmentId: ids.environmentRef,
19200
+ workspaceId: workspaceForEnvironmentRef(ids.workspace)
19201
+ });
19202
+ const output = makeEnvironmentResourceSchema(ids);
19203
+ return {
19204
+ annotationJustifications: {
19205
+ destructiveHint: "Terminates the environment for good: its runs are canceled and its flow changes are never promoted.",
19206
+ openWorldHint: "Changes QA Wolf environments only, not the customer's own repository or deployments.",
19207
+ readOnlyHint: "Terminates an environment and returns it terminated."
19208
+ },
19209
+ annotations: {
19210
+ destructiveHint: true,
19211
+ openWorldHint: false,
19212
+ readOnlyHint: false
19213
+ },
19214
+ description: "Terminate a preview environment, typically when its pull request closes without merging: its flow changes are not promoted into its base. Returns the environment, now terminated. A terminated environment cannot be terminated again. Use environment.promote instead when the work is accepted.",
19215
+ input,
19216
+ kind: "write",
19217
+ name: "environment.terminate",
19218
+ output
19219
+ };
19220
+ };
19221
+
18944
19222
  // node_modules/@qawolf/api-contracts/dist/v1/environment/update.js
18945
19223
  var makeUpdateEnvironmentContract = (ids) => {
18946
19224
  const nameSchema = string2().trim().min(1).max(255).describe("New display name. Must be unique within the team.");
@@ -19043,6 +19321,52 @@ var makeAddTagToFlowsContract = (ids) => {
19043
19321
  };
19044
19322
  };
19045
19323
 
19324
+ // node_modules/@qawolf/api-contracts/dist/v1/flow/getHistory.js
19325
+ var makeGetFlowHistoryContract = (ids) => {
19326
+ const input = object({
19327
+ createdAfter: exports_iso.datetime({ offset: true }).optional().describe("Only include results of runs created strictly after this instant."),
19328
+ createdBefore: exports_iso.datetime({ offset: true }).optional().describe("Only include results of runs created strictly before this instant."),
19329
+ ...makePaginationInputFields({ defaultLimit: 20, maxLimit: 100 }),
19330
+ environmentId: ids.environmentRef,
19331
+ flowId: ids.flow.describe("The flow whose results to list. It must belong to the environment's workspace."),
19332
+ workspaceId: workspaceForEnvironmentRef(ids.workspace)
19333
+ });
19334
+ const result = resource({
19335
+ attemptCount: number2().int().nonnegative().describe("How many automated attempts the flow made in this run."),
19336
+ completedAt: exports_iso.datetime().optional().describe("When the flow finished. Absent until it does."),
19337
+ createdAt: exports_iso.datetime(),
19338
+ diagnosis: object({
19339
+ issueId: ids.issue,
19340
+ type: _enum(["bug", "maintenance"])
19341
+ }).optional().describe("QA Wolf's investigation verdict for a failed result: `bug` means the application is broken, `maintenance` means the test needed an update. Absent until the investigation reaches a verdict, and for results that did not fail."),
19342
+ durationMs: number2().int().nonnegative().optional().describe("Milliseconds from the flow's start to its completion. Absent when either is unknown."),
19343
+ passedAfterRetry: boolean2().describe("The flow passed, but only after at least one earlier attempt in the same run. A signal of flakiness."),
19344
+ runId: ids.run.describe("The run this result belongs to."),
19345
+ status: _enum(publicRunStatusValues)
19346
+ }, { urlFieldDescription: "Absolute URL of the run page." });
19347
+ const output = object({
19348
+ nextCursor: nextCursorSchema,
19349
+ results: array(result).describe("The flow's results in the environment, newest first.")
19350
+ });
19351
+ return {
19352
+ annotationJustifications: {
19353
+ destructiveHint: "Does not rerun, edit or remove the flow or its runs.",
19354
+ openWorldHint: "Reads recorded QA Wolf results without changing the application under test.",
19355
+ readOnlyHint: "Lists one flow's past results across runs."
19356
+ },
19357
+ annotations: {
19358
+ destructiveHint: false,
19359
+ openWorldHint: false,
19360
+ readOnlyHint: true
19361
+ },
19362
+ description: "List one flow's results across runs in an environment, newest first, with status, attempts, duration, and diagnosis. Use it to spot flakiness, failure streaks, and duration trends.",
19363
+ input,
19364
+ kind: "read",
19365
+ name: "flow.getHistory",
19366
+ output
19367
+ };
19368
+ };
19369
+
19046
19370
  // node_modules/@qawolf/api-contracts/dist/v1/flow/readiness.js
19047
19371
  var flowReadinessSchema = _enum(["draft", "active"]);
19048
19372
 
@@ -19279,6 +19603,7 @@ var makeInvestigationFindingSchema = (ids) => object({
19279
19603
  type: literal("commit")
19280
19604
  }),
19281
19605
  object({
19606
+ applyOn: string2().optional().describe(`When the new baseline applies. Known values: "now" (once a person applies the proposal) and "merge" (when the run's pull request merges, because every environment of the workspace shares baselines). Absent means "now". New values can appear.`),
19282
19607
  baselineChangeId: string2().optional().describe('The baseline change that made the new screenshot the baseline, on a "fixed" finding. `run restoreScreenshotBaseline` undoes it.'),
19283
19608
  comparisonId: string2().describe("The failed screenshot comparison whose new screenshot becomes the baseline, as `run listScreenshotComparisons` names it."),
19284
19609
  type: literal("baseline")
@@ -19290,6 +19615,12 @@ var makeInvestigationFindingSchema = (ids) => object({
19290
19615
  kind: string2().describe('What the failure is. Known values: "maintenance", "bug", "flake" and "unknown". New values can appear.'),
19291
19616
  matchReason: string2().optional(),
19292
19617
  priority: issuePrioritySchema.optional(),
19618
+ pullRequest: object({
19619
+ file: string2().optional().describe("The changed file that explains the verdict."),
19620
+ line: number2().int().optional().describe("The line in `file` that explains the verdict."),
19621
+ reason: string2().describe("Why the investigation reached the verdict."),
19622
+ verdict: string2().describe('Whether the pull request caused the failure. Known values: "caused", "not-caused" and "unclear". New values can appear.')
19623
+ }).optional().describe("Whether the pull request the run tested caused this finding. Absent on a run that didn't test a pull request, and when the investigation didn't say."),
19293
19624
  question: object({
19294
19625
  answers: array(object({
19295
19626
  description: string2().optional(),
@@ -19303,7 +19634,8 @@ var makeInvestigationFindingSchema = (ids) => object({
19303
19634
  answer: string2().optional(),
19304
19635
  at: exports_iso.datetime(),
19305
19636
  reason: string2().optional(),
19306
- type: string2().describe('Known values: "answer" and "dispute". New values can appear.')
19637
+ text: string2().optional().describe("A person's answer in their own words, when they typed one."),
19638
+ type: string2().describe('Known values: "answer", "dispute" and "reply". New values can appear.')
19307
19639
  }).optional().describe("A person's answer or dispute that the investigation hasn't acted on yet."),
19308
19640
  state: string2().describe(investigationFindingStateDescription),
19309
19641
  steps: array(string2()).optional(),
@@ -19320,7 +19652,7 @@ var makeGetInvestigationContract = (ids) => {
19320
19652
  findings: array(makeInvestigationFindingSchema(ids)),
19321
19653
  runId: ids.run,
19322
19654
  sessionId: ids.chatSession.optional().describe("The investigation session. Absent when the run has none."),
19323
- status: _enum(["investigating", "finished", "not-investigated"]).describe('Whether the lead or any child investigator is still working. "not-investigated" when the run has no investigation.'),
19655
+ status: _enum(["investigating", "finished", "not-investigated", "not-enabled"]).describe('Whether the lead or any child investigator is still working. "not-investigated" when the run has no investigation. ' + '"not-enabled" when automatic investigation does not cover this run, because its workspace has it off or investigates only pull request runs: read its failures with run.get and attempt.get instead.'),
19324
19656
  subSessions: array(object({
19325
19657
  sessionId: ids.chatSession,
19326
19658
  status: agentSessionStatusSchema
@@ -19337,7 +19669,7 @@ var makeGetInvestigationContract = (ids) => {
19337
19669
  openWorldHint: false,
19338
19670
  readOnlyHint: true
19339
19671
  },
19340
- description: "Read what the QA Wolf AI investigating a run has concluded: one finding per cause of its failures, " + "with the question waiting for a person and any answer or dispute the investigation hasn't acted on yet.",
19672
+ description: "Read what the QA Wolf AI investigating a run has concluded: one finding per cause of its failures, " + "with the question waiting for a person and any answer or dispute the investigation hasn't acted on yet. " + 'A run that automatic investigation does not cover answers status "not-enabled".',
19341
19673
  input,
19342
19674
  kind: "read",
19343
19675
  name: "investigation.get",
@@ -19426,6 +19758,60 @@ var makeCreateIssueContract = (ids) => {
19426
19758
  };
19427
19759
  };
19428
19760
 
19761
+ // node_modules/@qawolf/api-contracts/dist/v1/issue/listActivity.js
19762
+ var issueActivityTypeSchema = _enum([
19763
+ "created",
19764
+ "status-changed",
19765
+ "priority-changed",
19766
+ "resolved",
19767
+ "auto-resolved",
19768
+ "reopened",
19769
+ "flow-started-reproducing",
19770
+ "flow-stopped-reproducing",
19771
+ "flow-removed",
19772
+ "maintenance-reason-changed",
19773
+ "due-date-changed",
19774
+ "other"
19775
+ ]).describe("What happened. resolved is a person resolving the issue, auto-resolved is QA Wolf resolving it once no flow reproduces it. flow-stopped-reproducing means a run of the flow passed. flow-removed means the flow was detached from the issue, deleted, or its environment ended. other covers edits such as the name or description.");
19776
+ var issueActivityActorKindSchema = _enum(["qa-wolf", "user", "api-key"]).optional().describe("Who caused the event: QA Wolf automation, a person, or an API key. Absent on older events.");
19777
+ var makeListIssueActivityContract = (ids) => {
19778
+ const input = object({
19779
+ issueId: ids.issue,
19780
+ ...makePaginationInputFields({ defaultLimit: 50, maxLimit: 200 })
19781
+ });
19782
+ const output = object({
19783
+ events: array(object({
19784
+ actorKind: issueActivityActorKindSchema,
19785
+ environmentId: ids.environment.optional(),
19786
+ flowId: ids.flow.optional(),
19787
+ fromPriority: issuePrioritySchema.optional(),
19788
+ occurredAt: exports_iso.datetime(),
19789
+ runId: ids.run.optional().describe("The run whose result caused the event."),
19790
+ toPriority: issuePrioritySchema.optional(),
19791
+ toStatus: issueStatusSchema.optional().describe("The issue status after the event."),
19792
+ type: issueActivityTypeSchema
19793
+ })).describe("The issue's activity, oldest first."),
19794
+ nextCursor: nextCursorSchema
19795
+ });
19796
+ return {
19797
+ annotationJustifications: {
19798
+ destructiveHint: "Does not edit the issue or its activity.",
19799
+ openWorldHint: "Reads QA Wolf issue history without publishing updates to linked trackers.",
19800
+ readOnlyHint: "Lists the recorded activity of one issue."
19801
+ },
19802
+ annotations: {
19803
+ destructiveHint: false,
19804
+ openWorldHint: false,
19805
+ readOnlyHint: true
19806
+ },
19807
+ description: "List an issue's activity, oldest first: creation, status and priority changes, and the flows that started or stopped reproducing it. Use it to measure time to fix or to find issues that came back.",
19808
+ input,
19809
+ kind: "read",
19810
+ name: "issue.listActivity",
19811
+ output
19812
+ };
19813
+ };
19814
+
19429
19815
  // node_modules/@qawolf/api-contracts/dist/v1/issue/removeFlows.js
19430
19816
  var makeRemoveFlowsFromIssueContract = (ids) => {
19431
19817
  const input = object({
@@ -19652,6 +20038,9 @@ var makeAcceptScreenshotBaselineContract = (ids) => {
19652
20038
  object({
19653
20039
  outcome: literal("not-investigation-session").describe("An API key that is not a person's can change a baseline only as the investigation of the run, and chatSessionId is missing or is not the session that investigates the run. Nothing changed.")
19654
20040
  }),
20041
+ object({
20042
+ outcome: literal("waits-for-merge").describe("The investigation proposed this baseline to apply when the run's pull request merges, and it hasn't merged. Nothing changed. QA Wolf applies the approved baseline on merge.")
20043
+ }),
19655
20044
  object({
19656
20045
  outcome: literal("nothing-to-accept").describe("The comparison did not fail, or has no new screenshot to accept. Nothing changed.")
19657
20046
  })
@@ -19842,88 +20231,6 @@ var makeGetRunContract = (ids) => {
19842
20231
  };
19843
20232
  };
19844
20233
 
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
20234
  // node_modules/@qawolf/api-contracts/dist/v1/run/optOutOfInvestigation.js
19928
20235
  var makeOptOutOfInvestigationRunContract = (ids) => {
19929
20236
  const input = object({
@@ -19961,6 +20268,7 @@ var makeReattemptRunContract = (ids) => {
19961
20268
  });
19962
20269
  const output = resource({
19963
20270
  reattemptedFlowIds: array(ids.flow).describe("The flows a new attempt was requested for."),
20271
+ reattemptedInRunIds: array(ids.run).describe("The runs the new attempts were added to, which is where to poll " + "for their results. It is this run alone unless a flow had kept " + "failing in later runs, because the attempt then goes to the " + "latest of them."),
19964
20272
  runId: ids.run
19965
20273
  }, { urlFieldDescription: "Absolute URL of the run page." });
19966
20274
  return {
@@ -19974,7 +20282,7 @@ var makeReattemptRunContract = (ids) => {
19974
20282
  openWorldHint: true,
19975
20283
  readOnlyHint: false
19976
20284
  },
19977
- description: "Request new attempts for a run's flows, in the same run. " + "A flow is eligible once its result is failed or canceled and QA Wolf's " + "automatic retries have finished. " + "A fully investigated run no longer accepts reattempts. " + "Attempts run with the latest flow code. Poll run.get for results.",
20285
+ description: "Request new attempts for a run's flows. " + "A flow is eligible once its result is failed or canceled and QA Wolf's " + "automatic retries have finished. " + "A flow that kept failing in later runs is attempted in the latest of " + "them, because that is the run carrying the failure, so read " + "reattemptedInRunIds for where each attempt landed. " + "A fully investigated run no longer accepts reattempts. " + "Attempts run with the latest flow code. Poll run.get for results.",
19978
20286
  input,
19979
20287
  kind: "write",
19980
20288
  name: "run.reattempt",
@@ -20394,7 +20702,7 @@ var makeRunFlowOnRunnerContract = (ids) => {
20394
20702
  const input = object({
20395
20703
  entryPointPath: runFilePathSchema.describe("Path of the flow file to run, as it appears in `files`."),
20396
20704
  env: runEnvironmentSchema.optional().describe("Environment variables to make available to the run."),
20397
- environmentId: ids.environmentRef.optional().describe("A QA Wolf environment whose variables the run is given, by id or alias. QA Wolf reads and decrypts them itself, so they never travel in the request and the count and length limits on `env` do not apply to them. Send this or `env`, not both."),
20705
+ environmentId: ids.environmentRef.optional().describe("A QA Wolf environment whose variables the run is given, by id or alias. QA Wolf reads and decrypts them itself, so they never travel in the request and the count and length limits on `env` do not apply to them. The run also gets `QAWOLF_ENVIRONMENT_ID`, `QAWOLF_ENVIRONMENT_NAME` and `QAWOLF_TEAM_API_KEY`, as a cloud run on that environment does, so a flow can save environment variables with `@qawolf/testkit`. Send this or `env`, not both."),
20398
20706
  files: runFilesSchema.describe("Every file the run needs keyed by its path — the flow file, everything it imports, package.json and tsconfig.json. A runner holds no copy of your project, so what runs is exactly what is sent here."),
20399
20707
  flowId: ids.flow.optional().describe("The QA Wolf flow this run is for. The run then sees it as `QAWOLF_WORKFLOW_ID`, the same value a platform run of that flow sees, so fixtures named and cleaned up by it match across both. Omitted, the flow whose file is at `entryPointPath` on the named environment's flow-code branch stands in; a file not in QA Wolf yet, or a run given no environment, leaves the run with no `QAWOLF_WORKFLOW_ID`."),
20400
20708
  id: runnerIdSchema.describe("Id of the runner to run the flow on."),
@@ -20520,7 +20828,7 @@ var makeTakeScreenshotOnRunnerContract = (ids) => {
20520
20828
  openWorldHint: false,
20521
20829
  readOnlyHint: false
20522
20830
  },
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}`,
20831
+ 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
20832
  input,
20525
20833
  kind: "read",
20526
20834
  name: "runner.takeScreenshot",
@@ -20652,6 +20960,9 @@ var makeContractsV1 = (ids) => {
20652
20960
  get: makeAgentGetContract(resolvedIds),
20653
20961
  send: makeAgentSendContract(resolvedIds)
20654
20962
  },
20963
+ attempt: {
20964
+ get: makeGetAttemptContract(resolvedIds)
20965
+ },
20655
20966
  codeHostIntegration: {
20656
20967
  find: makeFindCodeHostIntegrationsContract(resolvedIds),
20657
20968
  listRepositories: makeListCodeHostRepositoriesContract(resolvedIds)
@@ -20672,12 +20983,15 @@ var makeContractsV1 = (ids) => {
20672
20983
  get: makeGetEnvironmentContract(resolvedIds),
20673
20984
  getVariable: makeGetEnvironmentVariableContract(resolvedIds),
20674
20985
  listVariableNames: makeListEnvironmentVariableNamesContract(resolvedIds),
20986
+ promote: makePromoteEnvironmentContract(resolvedIds),
20675
20987
  setVariable: makeSetEnvironmentVariableContract(resolvedIds),
20988
+ terminate: makeTerminateEnvironmentContract(resolvedIds),
20676
20989
  update: makeUpdateEnvironmentContract(resolvedIds)
20677
20990
  },
20678
20991
  file: makeFileContracts(resolvedIds),
20679
20992
  flow: {
20680
20993
  addTag: makeAddTagToFlowsContract(resolvedIds),
20994
+ getHistory: makeGetFlowHistoryContract(resolvedIds),
20681
20995
  list: makeListFlowsContract(resolvedIds),
20682
20996
  removeTag: makeRemoveTagFromFlowsContract(resolvedIds),
20683
20997
  update: makeUpdateFlowContract(resolvedIds)
@@ -20688,17 +21002,18 @@ var makeContractsV1 = (ids) => {
20688
21002
  create: makeCreateIssueContract(resolvedIds),
20689
21003
  find: makeFindIssuesContract(resolvedIds),
20690
21004
  get: makeGetIssueContract(resolvedIds),
21005
+ listActivity: makeListIssueActivityContract(resolvedIds),
20691
21006
  removeFlows: makeRemoveFlowsFromIssueContract(resolvedIds),
20692
21007
  update: makeUpdateIssueContract(resolvedIds)
20693
21008
  },
20694
21009
  legacyTrigger: makeLegacyTriggerContracts(resolvedIds),
21010
+ promotion: makePromotionContracts(resolvedIds),
20695
21011
  run: {
20696
21012
  acceptScreenshotBaseline: makeAcceptScreenshotBaselineContract(resolvedIds),
20697
21013
  create: makeCreateRunContract(resolvedIds),
20698
21014
  diagnose: makeDiagnoseRunContract(resolvedIds),
20699
21015
  find: makeFindRunsContract(resolvedIds),
20700
21016
  get: makeGetRunContract(resolvedIds),
20701
- getAttemptArtifacts: makeGetRunAttemptArtifactsContract(resolvedIds),
20702
21017
  listScreenshotComparisons: makeListScreenshotComparisonsContract(resolvedIds),
20703
21018
  optOutOfInvestigation: makeOptOutOfInvestigationRunContract(resolvedIds),
20704
21019
  reattempt: makeReattemptRunContract(resolvedIds),
@@ -23219,7 +23534,7 @@ function startUpdateCheck(deps) {
23219
23534
  // package.json
23220
23535
  var package_default = {
23221
23536
  name: "@qawolf/cli",
23222
- version: "1.40.0",
23537
+ version: "1.42.0",
23223
23538
  description: "Run and manage QA Wolf flows from the terminal, CI, or an AI agent",
23224
23539
  keywords: [
23225
23540
  "automation",
@@ -23247,6 +23562,7 @@ var package_default = {
23247
23562
  "LICENSE",
23248
23563
  "README.md",
23249
23564
  "dist/cli.js",
23565
+ "dist/investigation-parser.js",
23250
23566
  "dist/runner-sdk.js",
23251
23567
  "dist/types/runnerSdk/index.d.ts",
23252
23568
  "dist/types/runnerSdk/types.d.ts",
@@ -23290,13 +23606,14 @@ var package_default = {
23290
23606
  "@clack/prompts": "1.5.1",
23291
23607
  "@napi-rs/keyring": "1.3.0",
23292
23608
  "@oxc-node/core": "0.1.0",
23293
- "@qawolf/api-contracts": "0.81.0",
23609
+ "@qawolf/api-contracts": "0.91.0",
23294
23610
  "@qawolf/emails": "1.1.1",
23295
23611
  "@qawolf/flow-targets": "1.0.0",
23296
23612
  "@qawolf/flows": "0.1.4",
23297
23613
  "@qawolf/testkit": "1.2.1",
23298
23614
  commander: "14.0.3",
23299
23615
  "env-paths": "4.0.0",
23616
+ jszip: "3.10.1",
23300
23617
  picomatch: "4.0.4",
23301
23618
  pino: "10.3.1",
23302
23619
  playwright: "1.62.0",
@@ -36377,6 +36694,387 @@ Examples:
36377
36694
  });
36378
36695
  }
36379
36696
 
36697
+ // src/domains/investigation/handle.ts
36698
+ import { basename as basename8 } from "node:path";
36699
+
36700
+ // src/domains/investigation/download.ts
36701
+ var traceLimit = 50 * 1024 * 1024;
36702
+ var logTailLimit = 5 * 1024 * 1024;
36703
+ var logTransferLimit = 50 * 1024 * 1024;
36704
+ var downloadTimeoutMs = 120000;
36705
+ function downloadFailure(error) {
36706
+ return { status: isTimeoutError(error) ? "timed-out" : "unavailable" };
36707
+ }
36708
+ async function responseFailure(response) {
36709
+ await response.body?.cancel().catch(() => {
36710
+ return;
36711
+ });
36712
+ if (response.status === 404)
36713
+ return { status: "not-found" };
36714
+ if (response.status === 401 || response.status === 403)
36715
+ return { status: "expired-url" };
36716
+ return { status: "unavailable" };
36717
+ }
36718
+ async function readBounded(response, options) {
36719
+ if (!response.ok)
36720
+ return responseFailure(response);
36721
+ const declaredLength = Number(response.headers.get("content-length"));
36722
+ if (Number.isFinite(declaredLength) && declaredLength > options.transferBytes) {
36723
+ await response.body?.cancel().catch(() => {
36724
+ return;
36725
+ });
36726
+ return { status: "too-large" };
36727
+ }
36728
+ if (!response.body)
36729
+ return { status: "unavailable" };
36730
+ const reader = response.body.getReader();
36731
+ const chunks = [];
36732
+ let retained = 0;
36733
+ let transferred = 0;
36734
+ while (true) {
36735
+ const next = await reader.read();
36736
+ if (next.done)
36737
+ break;
36738
+ const chunk = next.value;
36739
+ if (!(chunk instanceof Uint8Array)) {
36740
+ await reader.cancel();
36741
+ return { status: "unavailable" };
36742
+ }
36743
+ transferred += chunk.byteLength;
36744
+ if (transferred > options.transferBytes) {
36745
+ await reader.cancel();
36746
+ return { status: "too-large" };
36747
+ }
36748
+ chunks.push(chunk);
36749
+ retained += chunk.byteLength;
36750
+ if (options.keepTail) {
36751
+ while (chunks.length > 1 && retained - chunks[0].byteLength >= options.retainBytes) {
36752
+ retained -= chunks.shift().byteLength;
36753
+ }
36754
+ } else if (retained > options.retainBytes) {
36755
+ await reader.cancel();
36756
+ return { status: "too-large" };
36757
+ }
36758
+ }
36759
+ let bytes = Buffer.concat(chunks);
36760
+ const contentRange = response.headers.get("content-range");
36761
+ const rangeStart = contentRange ? Number(/^bytes (\d+)-/.exec(contentRange)?.[1]) : Number.NaN;
36762
+ let offset = Number.isFinite(rangeStart) ? rangeStart : transferred - bytes.byteLength;
36763
+ if (bytes.byteLength > options.retainBytes) {
36764
+ const removed = bytes.byteLength - options.retainBytes;
36765
+ bytes = bytes.subarray(removed);
36766
+ offset += removed;
36767
+ }
36768
+ return { bytes, offset, status: "available" };
36769
+ }
36770
+ async function downloadTrace(url, fetchImpl = globalThis.fetch) {
36771
+ try {
36772
+ const signal = AbortSignal.timeout(downloadTimeoutMs);
36773
+ const response = await fetchImpl(url, { redirect: "follow", signal });
36774
+ return await readBounded(response, {
36775
+ keepTail: false,
36776
+ retainBytes: traceLimit,
36777
+ transferBytes: traceLimit
36778
+ });
36779
+ } catch (error) {
36780
+ return downloadFailure(error);
36781
+ }
36782
+ }
36783
+ async function downloadLogTail(url, fetchImpl = globalThis.fetch) {
36784
+ try {
36785
+ const signal = AbortSignal.timeout(downloadTimeoutMs);
36786
+ const response = await fetchImpl(url, {
36787
+ headers: { range: `bytes=-${logTailLimit}` },
36788
+ redirect: "follow",
36789
+ signal
36790
+ });
36791
+ return await readBounded(response, {
36792
+ keepTail: true,
36793
+ retainBytes: logTailLimit,
36794
+ transferBytes: logTransferLimit
36795
+ });
36796
+ } catch (error) {
36797
+ return downloadFailure(error);
36798
+ }
36799
+ }
36800
+
36801
+ // src/domains/investigation/lazyParser.ts
36802
+ var parserPromise;
36803
+ function loadInvestigationParser() {
36804
+ parserPromise ??= import(parserSpecifier());
36805
+ return parserPromise;
36806
+ }
36807
+ function parserSpecifier() {
36808
+ const embedded = globalThis.qawolfInvestigationParserPath;
36809
+ if (embedded)
36810
+ return embedded;
36811
+ const sourceModule = import.meta.url.includes("/src/domains/investigation/");
36812
+ return new URL(sourceModule ? "./parser/index.ts" : "./investigation-parser.js", import.meta.url).href;
36813
+ }
36814
+
36815
+ // src/domains/investigation/handle.ts
36816
+ function artifactUnavailable(status) {
36817
+ return { status };
36818
+ }
36819
+ async function loadSummaryArtifacts(value) {
36820
+ if (value.artifactStatus !== "signed") {
36821
+ const unavailable = artifactUnavailable(value.artifactStatus);
36822
+ return { logs: unavailable, trace: unavailable };
36823
+ }
36824
+ const [logs, trace] = await Promise.all([
36825
+ value.artifacts.logsUrl ? downloadLogTail(value.artifacts.logsUrl) : artifactUnavailable("not-captured"),
36826
+ value.artifacts.traceUrl ? downloadTrace(value.artifacts.traceUrl) : artifactUnavailable("not-captured")
36827
+ ]);
36828
+ return { logs, trace };
36829
+ }
36830
+ async function loadInspectArtifact(value, type) {
36831
+ const inactive = artifactUnavailable("not-captured");
36832
+ if (value.artifactStatus !== "signed") {
36833
+ const unavailable = artifactUnavailable(value.artifactStatus);
36834
+ return type === "log" ? { logs: unavailable, trace: inactive } : { logs: inactive, trace: unavailable };
36835
+ }
36836
+ if (type === "log") {
36837
+ return {
36838
+ logs: value.artifacts.logsUrl ? await downloadLogTail(value.artifacts.logsUrl) : inactive,
36839
+ trace: inactive
36840
+ };
36841
+ }
36842
+ return {
36843
+ logs: inactive,
36844
+ trace: value.artifacts.traceUrl ? await downloadTrace(value.artifacts.traceUrl) : inactive
36845
+ };
36846
+ }
36847
+ var defaultInspectLimit = "20";
36848
+ var maxInspectLimit = 100;
36849
+ var filterSelectors = [
36850
+ ["evidenceId", "--evidence-id", ["console", "log"]],
36851
+ ["limit", "--limit", ["timeline", "network", "console", "log"]],
36852
+ ["startTimeMs", "--start-time-ms", ["network", "console"]],
36853
+ ["endTimeMs", "--end-time-ms", ["network", "console"]],
36854
+ ["startTimestamp", "--start-timestamp", ["log"]],
36855
+ ["endTimestamp", "--end-timestamp", ["log"]],
36856
+ ["source", "--source", ["log"]],
36857
+ ["method", "--method", ["network"]],
36858
+ ["status", "--status", ["network"]],
36859
+ ["urlContains", "--url-contains", ["network"]]
36860
+ ];
36861
+ function inapplicableFilter(options) {
36862
+ for (const [field, flag, selectors] of filterSelectors) {
36863
+ if (options[field] === undefined || selectors.includes(options.type))
36864
+ continue;
36865
+ const allowed = selectors.map((selector) => `--${selector}`).join(", ");
36866
+ return {
36867
+ error: `${flag} does not apply to --${options.type}; use it with ${allowed}.`
36868
+ };
36869
+ }
36870
+ return;
36871
+ }
36872
+ function numberFlag(value, name, options = {}) {
36873
+ if (value === undefined)
36874
+ return;
36875
+ const parsed = Number(value);
36876
+ if (!Number.isFinite(parsed) || options.integer === true && !Number.isInteger(parsed) || options.min !== undefined && parsed < options.min)
36877
+ return { error: `Invalid ${name}: ${value}.` };
36878
+ if (options.max !== undefined && parsed > options.max)
36879
+ return { error: `${name} must be at most ${options.max}, got ${value}.` };
36880
+ return parsed;
36881
+ }
36882
+ function timestampFlag(value, name) {
36883
+ if (value === undefined || !Number.isNaN(Date.parse(value)))
36884
+ return;
36885
+ return {
36886
+ error: `Invalid ${name}: ${value}. Use an ISO 8601 timestamp such as 2026-01-31T12:00:00Z.`
36887
+ };
36888
+ }
36889
+ function validateInspect(options) {
36890
+ if (options.type === "action" && !options.actionId)
36891
+ return { error: "--action requires an evidence ID." };
36892
+ if (options.type === "request" && !options.requestId)
36893
+ return { error: "--request requires an evidence ID." };
36894
+ if (options.type === "snapshot" && !options.snapshotId)
36895
+ return { error: "--snapshot requires an evidence ID." };
36896
+ if (options.type === "screenshot" && !options.screenshotId)
36897
+ return { error: "--screenshot requires an evidence ID." };
36898
+ if (options.format === "html" && options.type !== "snapshot")
36899
+ return { error: "--format html is supported only with --snapshot." };
36900
+ if (options.type === "screenshot" && !options.outputFile)
36901
+ return {
36902
+ error: "--output-file is required for screenshot evidence."
36903
+ };
36904
+ if (options.outputFile && options.format !== "html" && options.type !== "screenshot")
36905
+ return {
36906
+ error: "--output-file is supported only with --snapshot and --format html, or with --screenshot."
36907
+ };
36908
+ return;
36909
+ }
36910
+ function renderText(result) {
36911
+ return JSON.stringify(result, undefined, 2);
36912
+ }
36913
+ async function fetchAttempt(ctx, attemptId) {
36914
+ return ctx.platformClient.callPublicApi(publicContractsV1.attempt.get, {
36915
+ attemptId
36916
+ });
36917
+ }
36918
+ async function handleInvestigationSummary(ctx, attemptId) {
36919
+ const authorized = await fetchAttempt(ctx, attemptId);
36920
+ if (!authorized.ok)
36921
+ return failureFields(authorized);
36922
+ const artifacts = await loadSummaryArtifacts(authorized.value);
36923
+ const parser = await loadInvestigationParser();
36924
+ const evidence = await parser.investigate({
36925
+ artifacts,
36926
+ attempt: authorized.value.attempt,
36927
+ flowId: authorized.value.flowId,
36928
+ mode: "summary",
36929
+ runId: authorized.value.runId
36930
+ });
36931
+ const result = {
36932
+ ...authorized.value,
36933
+ artifacts: undefined,
36934
+ evidence
36935
+ };
36936
+ ctx.ui.output(result, renderText(result));
36937
+ return;
36938
+ }
36939
+ async function handleInvestigationInspect(ctx, options) {
36940
+ const invalid = validateInspect(options) ?? inapplicableFilter(options);
36941
+ if (invalid)
36942
+ return invalid;
36943
+ if (options.outputFile && await ctx.fs.pathExists(options.outputFile))
36944
+ return {
36945
+ error: `Refusing to overwrite existing file: ${options.outputFile}`
36946
+ };
36947
+ const limit = numberFlag(options.limit ?? defaultInspectLimit, "--limit", {
36948
+ integer: true,
36949
+ max: maxInspectLimit,
36950
+ min: 1
36951
+ });
36952
+ if (typeof limit !== "number")
36953
+ return limit;
36954
+ const startTimeMilliseconds = numberFlag(options.startTimeMs, "--start-time-ms");
36955
+ if (typeof startTimeMilliseconds === "object")
36956
+ return startTimeMilliseconds;
36957
+ const endTimeMilliseconds = numberFlag(options.endTimeMs, "--end-time-ms");
36958
+ if (typeof endTimeMilliseconds === "object")
36959
+ return endTimeMilliseconds;
36960
+ const status = numberFlag(options.status, "--status", {
36961
+ integer: true,
36962
+ min: 0
36963
+ });
36964
+ if (typeof status === "object")
36965
+ return status;
36966
+ const timestampError = timestampFlag(options.startTimestamp, "--start-timestamp") ?? timestampFlag(options.endTimestamp, "--end-timestamp");
36967
+ if (timestampError)
36968
+ return timestampError;
36969
+ const authorized = await fetchAttempt(ctx, options.attemptId);
36970
+ if (!authorized.ok)
36971
+ return failureFields(authorized);
36972
+ const artifacts = await loadInspectArtifact(authorized.value, options.type);
36973
+ const request = {
36974
+ artifacts,
36975
+ attempt: authorized.value.attempt,
36976
+ flowId: authorized.value.flowId,
36977
+ inspect: {
36978
+ actionId: options.actionId,
36979
+ endTimeMilliseconds,
36980
+ endTimestamp: options.endTimestamp,
36981
+ evidenceId: options.evidenceId,
36982
+ format: options.format,
36983
+ limit,
36984
+ method: options.method,
36985
+ requestId: options.requestId,
36986
+ screenshotId: options.screenshotId,
36987
+ snapshotId: options.snapshotId,
36988
+ source: options.source,
36989
+ startTimeMilliseconds,
36990
+ startTimestamp: options.startTimestamp,
36991
+ status,
36992
+ type: options.type,
36993
+ urlContains: options.urlContains
36994
+ },
36995
+ mode: "inspect",
36996
+ runId: authorized.value.runId
36997
+ };
36998
+ const parser = await loadInvestigationParser();
36999
+ const parsed = await parser.investigate(request);
37000
+ return outputInvestigationInspection(ctx, options, parsed);
37001
+ }
37002
+ async function outputInvestigationInspection(ctx, options, parsed) {
37003
+ const { binary, ...result } = parsed;
37004
+ if (options.outputFile) {
37005
+ if (!binary)
37006
+ return {
37007
+ error: "The requested evidence did not contain exportable data."
37008
+ };
37009
+ const written = await ctx.fs.writeFileExclusive(options.outputFile, Buffer.from(binary.bytesBase64, "base64"), { mode: 384 });
37010
+ if (!written)
37011
+ return {
37012
+ error: `Refusing to overwrite existing file: ${options.outputFile}`
37013
+ };
37014
+ const output = { ...result, outputFile: options.outputFile };
37015
+ ctx.ui.output(output, `${renderText(result)}
37016
+ Saved ${binary.extension}: ${basename8(options.outputFile)}`);
37017
+ return;
37018
+ }
37019
+ if (binary?.extension === "html") {
37020
+ const html = Buffer.from(binary.bytesBase64, "base64").toString("utf8");
37021
+ ctx.ui.output({ ...result, html }, html);
37022
+ return;
37023
+ }
37024
+ ctx.ui.output(result, renderText(result));
37025
+ return;
37026
+ }
37027
+
37028
+ // src/commands/attempt/inspectSelection.ts
37029
+ function resolveInspectSelection(options) {
37030
+ const candidates = [
37031
+ options.action === undefined ? undefined : { actionId: options.action, type: "action" },
37032
+ options.timeline ? { type: "timeline" } : undefined,
37033
+ options.network ? { type: "network" } : undefined,
37034
+ options.request === undefined ? undefined : { requestId: options.request, type: "request" },
37035
+ options.snapshot === undefined ? undefined : { snapshotId: options.snapshot, type: "snapshot" },
37036
+ options.screenshot === undefined ? undefined : { screenshotId: options.screenshot, type: "screenshot" },
37037
+ options.console ? { type: "console" } : undefined,
37038
+ options.log ? { type: "log" } : undefined
37039
+ ];
37040
+ const selected = candidates.filter((selection) => selection !== undefined);
37041
+ return selected.length === 1 ? selected[0] : {
37042
+ error: "Choose exactly one evidence selector: --action, --timeline, --network, --request, --snapshot, --screenshot, --console, or --log."
37043
+ };
37044
+ }
37045
+
37046
+ // src/commands/attempt/index.ts
37047
+ function parseFormat(value) {
37048
+ if (value === "html" || value === "text")
37049
+ return value;
37050
+ throw new Error("Expected text or html.");
37051
+ }
37052
+ function registerAttemptCommand(program, signals) {
37053
+ const attempt = program.command("attempt").description("Investigate a finished run attempt from recorded evidence");
37054
+ 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));
37055
+ 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([
37056
+ "qawolfTraceCollection",
37057
+ "serverConsole"
37058
+ ])).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) => {
37059
+ const selection = resolveInspectSelection(options);
37060
+ if ("error" in selection)
37061
+ return command.error(selection.error);
37062
+ const {
37063
+ action: _action,
37064
+ console: _console,
37065
+ log: _log,
37066
+ network: _network,
37067
+ request: _request,
37068
+ screenshot: _screenshot,
37069
+ snapshot: _snapshot,
37070
+ timeline: _timeline,
37071
+ ...common
37072
+ } = options;
37073
+ const normalized = { ...common, ...selection };
37074
+ return withAuthContext(signals, (ctx) => handleInvestigationInspect(ctx, normalized))(options, command);
37075
+ });
37076
+ }
37077
+
36380
37078
  // src/core/publicApi/flagNames.ts
36381
37079
  var kebabCase = (segment) => segment.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
36382
37080
  var capitalize = (segment) => `${segment.slice(0, 1).toUpperCase()}${segment.slice(1)}`;
@@ -39961,6 +40659,7 @@ function createProgram({
39961
40659
  registerFlowsCommand(program, signals);
39962
40660
  registerInitCommand(program, signals);
39963
40661
  registerInstallCommand(program, signals);
40662
+ registerAttemptCommand(program, signals);
39964
40663
  registerRunnerCommand(program, signals);
39965
40664
  registerPublicApiCommands(program, signals);
39966
40665
  registerHelpCommand(program);
@@ -39977,4 +40676,4 @@ createProgram({ signals }).parseAsync().catch(() => {
39977
40676
  process.exitCode = 1;
39978
40677
  }).finally(() => exitWhenIdle(typeof process.exitCode === "number" ? process.exitCode : 0));
39979
40678
 
39980
- //# debugId=A9F5B8A99DA7D0CB64756E2164756E21
40679
+ //# debugId=19B86D665A1B773064756E2164756E21