bpmax-cli 0.2.1-beta.56 → 0.2.1-beta.57

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/bin.js CHANGED
@@ -499,7 +499,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
499
499
  // package.json
500
500
  var package_default = {
501
501
  name: "bpmax-cli",
502
- version: "0.2.1-beta.56",
502
+ version: "0.2.1-beta.57",
503
503
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
504
504
  type: "module",
505
505
  bin: {
@@ -22810,6 +22810,8 @@ async function prepareV2TestSuiteConfirmation(options) {
22810
22810
  digest: request.digest,
22811
22811
  confirmation_required: true,
22812
22812
  exact_confirmation_text_required: false,
22813
+ autonomous_accept_supported: true,
22814
+ acceptance_modes: ["explicit_user_confirmation", "explicit_test_request"],
22813
22815
  confirmation_summary: {
22814
22816
  scope: request.scope,
22815
22817
  scenario_ids: request.scenario_ids,
@@ -22831,25 +22833,46 @@ async function acceptV2TestSuiteConfirmation(options) {
22831
22833
  const base = { ...request };
22832
22834
  delete base.digest;
22833
22835
  if (request.version !== 1 || request.kind !== "bpmax_e2e_v2_confirmation_request" || request.state !== "pending" || request.digest !== v2ConfirmationDigest(base)) fail(`invalid V2 confirmation request: ${requestPath}`, { rule_id: "test_suite.v2_confirmation.request_invalid", path: requestPath });
22834
- if (options.confirmed !== true) {
22836
+ if (options.confirmed === true && options.autonomous === true) {
22837
+ fail("V2 confirmation acceptance must use either explicit confirmation or autonomous test-request authorization, not both", {
22838
+ rule_id: "test_suite.v2_confirmation.mode_conflict",
22839
+ path: requestPath
22840
+ });
22841
+ }
22842
+ if (options.autonomous === true && request.scope === "shared_scenario_replace") {
22843
+ fail("Replacing a shared V2 scenario cannot use autonomous test-request authorization", {
22844
+ rule_id: "test_suite.v2_confirmation.autonomous_shared_replace_forbidden",
22845
+ path: requestPath,
22846
+ suggestion: "Keep the isolated draft, or obtain explicit confirmation before replacing the shared scenario."
22847
+ });
22848
+ }
22849
+ if (options.confirmed !== true && options.autonomous !== true) {
22835
22850
  fail("V2 confirmation request has not been explicitly confirmed by the user", {
22836
22851
  rule_id: "test_suite.v2_confirmation.explicit_confirmation_required",
22837
22852
  path: requestPath,
22838
- suggestion: "After the user clearly confirms the displayed scenario, case scope, and operation, retry with --confirmed."
22853
+ suggestion: "Use --confirmed after a separate confirmation, or --autonomous when the current explicit test request already authorizes automatic execution of the displayed scope."
22839
22854
  });
22840
22855
  }
22856
+ const confirmationMode = options.autonomous === true ? "explicit_test_request" : "explicit_user_confirmation";
22841
22857
  const receipt = {
22842
22858
  ...request,
22843
22859
  kind: "bpmax_e2e_v2_confirmation_receipt",
22844
22860
  state: "accepted",
22845
- confirmation_mode: "explicit_user_confirmation",
22861
+ confirmation_mode: confirmationMode,
22846
22862
  request: requestPath,
22847
22863
  request_sha256: await sha256(requestPath),
22848
22864
  accepted_at: (/* @__PURE__ */ new Date()).toISOString()
22849
22865
  };
22850
22866
  const receiptPath = path15.resolve(options.receipt ?? path15.join(path15.dirname(requestPath), V2_CONFIRMATION_RECEIPT));
22851
22867
  await writeAtomicJson(receiptPath, receipt);
22852
- return { ok: true, receipt: receiptPath, digest: receipt.digest, scope: receipt.scope };
22868
+ return {
22869
+ ok: true,
22870
+ receipt: receiptPath,
22871
+ digest: receipt.digest,
22872
+ scope: receipt.scope,
22873
+ confirmation_mode: receipt.confirmation_mode,
22874
+ continue_without_second_confirmation: receipt.confirmation_mode === "explicit_test_request"
22875
+ };
22853
22876
  }
22854
22877
  async function validateV2Confirmation(options) {
22855
22878
  if (!options.required) return void 0;
@@ -22885,7 +22908,7 @@ async function validateV2Confirmation(options) {
22885
22908
  const expectedScopes = Array.isArray(options.scope) ? options.scope : [options.scope];
22886
22909
  const receiptScenarios = [...receipt.scenario_ids ?? []].sort();
22887
22910
  const receiptCases = normalizedCaseIds(receipt.selected_case_ids ?? []);
22888
- if (receipt.version !== 1 || receipt.kind !== "bpmax_e2e_v2_confirmation_receipt" || receipt.state !== "accepted" || !expectedScopes.includes(receipt.scope) || JSON.stringify(receiptScenarios) !== JSON.stringify(scenarioIds) || (options.validateCaseIds ?? true) && JSON.stringify(receiptCases) !== JSON.stringify(expectedCaseIds) || receipt.confirmation_mode !== "explicit_user_confirmation" || !receipt.accepted_at || Number.isNaN(Date.parse(receipt.accepted_at))) fail("V2 confirmation receipt does not match this scenario, selected cases, or operation scope", {
22911
+ if (receipt.version !== 1 || receipt.kind !== "bpmax_e2e_v2_confirmation_receipt" || receipt.state !== "accepted" || !expectedScopes.includes(receipt.scope) || JSON.stringify(receiptScenarios) !== JSON.stringify(scenarioIds) || (options.validateCaseIds ?? true) && JSON.stringify(receiptCases) !== JSON.stringify(expectedCaseIds) || !["explicit_user_confirmation", "explicit_test_request"].includes(receipt.confirmation_mode) || !receipt.accepted_at || Number.isNaN(Date.parse(receipt.accepted_at))) fail("V2 confirmation receipt does not match this scenario, selected cases, or operation scope", {
22889
22912
  rule_id: "test_suite.v2_confirmation.scope_mismatch",
22890
22913
  path: receiptPath
22891
22914
  });
@@ -29935,6 +29958,28 @@ function repairRequiresAutomationChange(result) {
29935
29958
  "assertion_failed"
29936
29959
  ].includes(String(result.failure_kind || ""));
29937
29960
  }
29961
+ function isBrowserAuthenticationErrorMessage(message) {
29962
+ return /e2e\.browser\.(?:interactive_login_timeout|login_bootstrap_required|auth_(?:cookie|import)_probe_failed|auth_context_missing)/i.test(message);
29963
+ }
29964
+ function isBrowserAuthenticationFailure(result) {
29965
+ return isBrowserAuthenticationErrorMessage(String(result.error || ""));
29966
+ }
29967
+ function interactiveLoginRecoveryAction() {
29968
+ return {
29969
+ kind: "playwright_authentication_recovery",
29970
+ user_action_required: true,
29971
+ instruction: "Complete or repair authentication for the run-scoped Playwright profile. A normal --resume will stay blocked and will not reopen Chrome.",
29972
+ next_command: `Re-run the same e2e scenario execute command with --resume --retry-interactive-login only when the user is ready to complete one visible login attempt.`
29973
+ };
29974
+ }
29975
+ function orphanedRunRecoveryAction() {
29976
+ return {
29977
+ kind: "playwright_orphaned_run_recovery",
29978
+ user_action_required: true,
29979
+ instruction: "The previous scenario process ended while its checkpoint was running. Confirm that no browser process remains and that no mutation was attempted.",
29980
+ next_command: "Re-run the same e2e scenario execute command with --resume --recover-orphaned-run only after the stale browser process is gone."
29981
+ };
29982
+ }
29938
29983
  function completedBrowserStepHashes(execution, automation) {
29939
29984
  const hashes = {};
29940
29985
  for (const step of executionSteps(execution)) {
@@ -30087,6 +30132,7 @@ async function saveOperationState(file, state) {
30087
30132
  await writeAtomicJson3(file, state);
30088
30133
  }
30089
30134
  function pausedResult(state, checkpoint) {
30135
+ const userActionRequired = state.status === "paused_external_action" && ["playwright_authentication_required", "orphaned_execution_recovery_required"].includes(state.pause?.kind || "");
30090
30136
  return {
30091
30137
  ok: false,
30092
30138
  status: state.status,
@@ -30096,7 +30142,8 @@ function pausedResult(state, checkpoint) {
30096
30142
  current_step: state.current_step,
30097
30143
  current_action_index: state.current_action_index,
30098
30144
  mutation_state: state.mutation_state,
30099
- resume_allowed: state.status !== "paused_write_state_unknown",
30145
+ resume_allowed: state.status !== "paused_write_state_unknown" && !userActionRequired,
30146
+ ...userActionRequired ? { user_action_required: true } : {},
30100
30147
  llm_intervention_required: state.status === "paused_repairable",
30101
30148
  ...state.pause ? { pause: state.pause } : {}
30102
30149
  };
@@ -30189,6 +30236,21 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
30189
30236
  if (operation.manifest !== manifest || operation.scenario !== scenario || operation.plan_file !== planFile || operation.automation_file !== automationFile) {
30190
30237
  throw new Error("e2e.scenario.checkpoint_binding_mismatch: checkpoint is bound to a different manifest, scenario, plan, or automation file");
30191
30238
  }
30239
+ if (hasCheckpoint && options.resume && operation.status === "running" && options.recoverOrphanedRun !== true) {
30240
+ if (operation.mutation_state !== "not_attempted") {
30241
+ throw new Error("e2e.scenario.orphaned_mutation_state_unknown: a crashed running checkpoint may have attempted a mutation; resolve current-run write state before recovery");
30242
+ }
30243
+ operation.status = "paused_external_action";
30244
+ operation.pause = {
30245
+ kind: "orphaned_execution_recovery_required",
30246
+ message: "The previous scenario process ended while the checkpoint was running. Automatic resume is blocked to prevent repeated browser launches.",
30247
+ ...operation.current_step ? { repair_scope: operation.current_step } : {},
30248
+ script_change_required: false,
30249
+ external_action: orphanedRunRecoveryAction()
30250
+ };
30251
+ await saveOperationState(checkpoint, operation);
30252
+ return pausedResult(operation, checkpoint);
30253
+ }
30192
30254
  const mutationGuard = initialMutationGuard;
30193
30255
  let recoveredMutationGuard = false;
30194
30256
  if (mutationGuard) {
@@ -30278,6 +30340,18 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
30278
30340
  throw new Error(`e2e.scenario.mutation_guard_mismatch: guarded step is already ${String(guardedStep.status)}`);
30279
30341
  }
30280
30342
  }
30343
+ if (operation.status === "paused_repairable" && isBrowserAuthenticationErrorMessage(operation.pause?.message || "")) {
30344
+ operation.status = "paused_external_action";
30345
+ operation.pause = {
30346
+ ...operation.pause,
30347
+ kind: "playwright_authentication_required",
30348
+ message: operation.pause?.message || "Playwright authentication must be restored before this run can continue.",
30349
+ repair_request: void 0,
30350
+ script_change_required: false,
30351
+ external_action: interactiveLoginRecoveryAction()
30352
+ };
30353
+ await saveOperationState(checkpoint, operation);
30354
+ }
30281
30355
  if (recoveredMutationGuard && operation.status === "complete") {
30282
30356
  return {
30283
30357
  ok: true,
@@ -30334,6 +30408,12 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
30334
30408
  if (operation.status === "complete") {
30335
30409
  throw new Error("test_suite.run.completed_manifest: completed cases are never resumed or reused; start a new full_rerun manifest");
30336
30410
  }
30411
+ if (options.resume && operation.status === "paused_external_action" && operation.pause?.kind === "playwright_authentication_required" && options.retryInteractiveLogin !== true) {
30412
+ return pausedResult(operation, checkpoint);
30413
+ }
30414
+ if (options.resume && operation.status === "paused_external_action" && operation.pause?.kind === "orphaned_execution_recovery_required" && options.recoverOrphanedRun !== true) {
30415
+ return pausedResult(operation, checkpoint);
30416
+ }
30337
30417
  if (options.resume && operation.status === "paused_external_action" && operation.pause?.kind === "report_sync_failed") {
30338
30418
  try {
30339
30419
  const reportSync = await dependencies.syncTestSuiteRunReport(manifest);
@@ -30723,6 +30803,21 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
30723
30803
  await saveOperationState(checkpoint, operation);
30724
30804
  return pausedResult(operation, checkpoint);
30725
30805
  }
30806
+ if (isBrowserAuthenticationFailure(result)) {
30807
+ operation.status = "paused_external_action";
30808
+ operation.mutation_state = "not_attempted";
30809
+ operation.pause = {
30810
+ kind: "playwright_authentication_required",
30811
+ message: result.error || result.status,
30812
+ repair_scope: failedStepKey,
30813
+ failed_action_index: result.failure_action_index,
30814
+ script_change_required: false,
30815
+ evidence: result.evidence,
30816
+ external_action: interactiveLoginRecoveryAction()
30817
+ };
30818
+ await saveOperationState(checkpoint, operation);
30819
+ return pausedResult(operation, checkpoint);
30820
+ }
30726
30821
  if (result.repairable || ["cache_stale", "execution_failed"].includes(result.status)) {
30727
30822
  const failedStepHash = browserAutomationStepSha256(requiredAutomationStep(automation, failedStepKey));
30728
30823
  const scriptChangeRequired = repairRequiresAutomationChange(result);
@@ -34188,7 +34283,7 @@ function registerE2eCommands(program2) {
34188
34283
  });
34189
34284
  });
34190
34285
  const scenario = e2e.command("scenario").description("Run resumable BPMAX E2E scenario plans");
34191
- scenario.command("execute").description("Execute the formal deterministic operation flow until complete or a controlled pause").requiredOption("--plan <file>", "Scenario plan JSON file").requiredOption("--automation <file>", "Scenario automation.json").requiredOption("--execution-manifest <file>", "Current formal test-suite execution manifest").option("--data-profile <json>", "Current-run JSON variables or @file").option("--base-url <url>", "Browser base URL; defaults to the manifest profile origin").option("--profile <profile>", "Profile name; must match the execution manifest").option("--cdp-endpoint <url>", "Connect to an existing authenticated Chrome CDP endpoint").option("--cookie-env <name>", "Environment variable containing a current browser Cookie header", "BPMAX_COOKIE_HEADER").option("--storage-state <file>", "Playwright storage state JSON").option("--user-data-dir <dir>", "Persistent Chrome user data directory").option("--executable-path <file>", "Chrome/Chromium executable path").option("--headed", "Run a visible browser window").option("--no-interactive-login", "Fail instead of opening a visible Playwright login window when authentication is missing").option("--login-timeout <seconds>", "Maximum time to wait for interactive Playwright login", "300").option("--checkpoint <file>", "Operation-flow checkpoint; defaults to the current report run directory").option("--resume", "Resume the same unfinished operation flow after a controlled repair or external action").option("--format <format>", "Output format", "json").action(async (options) => {
34286
+ scenario.command("execute").description("Execute the formal deterministic operation flow until complete or a controlled pause").requiredOption("--plan <file>", "Scenario plan JSON file").requiredOption("--automation <file>", "Scenario automation.json").requiredOption("--execution-manifest <file>", "Current formal test-suite execution manifest").option("--data-profile <json>", "Current-run JSON variables or @file").option("--base-url <url>", "Browser base URL; defaults to the manifest profile origin").option("--profile <profile>", "Profile name; must match the execution manifest").option("--cdp-endpoint <url>", "Connect to an existing authenticated Chrome CDP endpoint").option("--cookie-env <name>", "Environment variable containing a current browser Cookie header", "BPMAX_COOKIE_HEADER").option("--storage-state <file>", "Playwright storage state JSON").option("--user-data-dir <dir>", "Persistent Chrome user data directory").option("--executable-path <file>", "Chrome/Chromium executable path").option("--headed", "Run a visible browser window").option("--no-interactive-login", "Fail instead of opening a visible Playwright login window when authentication is missing").option("--retry-interactive-login", "Explicitly allow one new visible login attempt after an authentication pause").option("--recover-orphaned-run", "Explicitly recover a stale running checkpoint after confirming no browser process or mutation remains").option("--login-timeout <seconds>", "Maximum time to wait for interactive Playwright login", "300").option("--checkpoint <file>", "Operation-flow checkpoint; defaults to the current report run directory").option("--resume", "Resume the same unfinished operation flow after a controlled repair or external action").option("--format <format>", "Output format", "json").action(async (options) => {
34192
34287
  const loginTimeoutMs = Number(options.loginTimeout) * 1e3;
34193
34288
  if (!Number.isFinite(loginTimeoutMs) || loginTimeoutMs <= 0) {
34194
34289
  throw new Error("e2e.browser.login_timeout_invalid: --login-timeout must be a positive number of seconds");
@@ -39679,7 +39774,7 @@ function registerTestSuiteCommands(program2) {
39679
39774
  output: options.output
39680
39775
  }));
39681
39776
  });
39682
- confirmation.command("accept").description("Accept a prepared V2 E2E confirmation request after explicit user confirmation").requiredOption("--request <file>", "Prepared V2 confirmation request").option("--confirmed", "The user explicitly confirmed the displayed scenario, case scope, and operation").option("--receipt <file>", "Accepted confirmation receipt output path").option("--format <format>", "Output format", "json").action(async (options) => {
39777
+ confirmation.command("accept").description("Accept a prepared V2 E2E scope after explicit confirmation or an explicit autonomous test request").requiredOption("--request <file>", "Prepared V2 confirmation request").option("--confirmed", "The user explicitly confirmed the displayed scenario, case scope, and operation").option("--autonomous", "The current explicit test request authorizes automatic execution of the bound scope without a second confirmation").option("--receipt <file>", "Accepted confirmation receipt output path").option("--format <format>", "Output format", "json").action(async (options) => {
39683
39778
  printResult(options.format, await acceptV2TestSuiteConfirmation(options));
39684
39779
  });
39685
39780
  suite.command("draft-update").description("Copy one formal suite scenario to the draft suite for editing").requiredOption("--scenario <id>", "Scenario id").option("--suite-root <path>", "Formal suite root directory", DEFAULT_SUITE_ROOT).option("--draft-root <path>", "Draft suite root directory", DEFAULT_DRAFT_ROOT).option("--replace", "Allow replacing an existing draft scenario").option("--diff-reviewed", "Confirm the copy diff preview was reviewed").requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options) => {