@agimon-ai/po-workflow 0.0.0-alpha.38 → 0.0.0-alpha.39

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.
@@ -753,6 +753,7 @@ const WorkflowLauncherMetadataSchema = z.discriminatedUnion("type", [
753
753
  ]);
754
754
  const WorkflowRunRecordSchema = z.object({
755
755
  activeRepairId: z.string().regex(/^\d+$/).optional(),
756
+ /** Read-only legacy metadata. New runs only write runner. */
756
757
  cliAgent: z.string().optional(),
757
758
  continueOnError: z.boolean().optional(),
758
759
  displayName: z.string(),
@@ -4724,7 +4725,6 @@ var WorkflowRegistryService = class {
4724
4725
  const runId = randomUUID();
4725
4726
  const runRecord = {
4726
4727
  activeRepairId: input.activeRepairId,
4727
- cliAgent: input.cliAgent,
4728
4728
  continueOnError: input.continueOnError,
4729
4729
  displayName: input.displayName,
4730
4730
  dryRun: input.dryRun,
@@ -6405,127 +6405,6 @@ const MAX_STEP_TIMEOUT_MINUTES = Math.floor(2147483647 / 6e4);
6405
6405
  const StepTimeoutMinutesSchema = z.number().positive().finite().max(MAX_STEP_TIMEOUT_MINUTES);
6406
6406
  const StepTimeoutRetriesSchema = z.number().int().min(0).max(STEP_TIMEOUT_RETRIES_LIMIT).default(STEP_TIMEOUT_MAX_RETRIES);
6407
6407
  //#endregion
6408
- //#region src/services/CodexQuotaService/index.ts
6409
- /**
6410
- * CodexQuotaService
6411
- *
6412
- * DESIGN PATTERNS:
6413
- * - Service pattern for business logic encapsulation
6414
- * - Single responsibility principle
6415
- *
6416
- * CODING STANDARDS:
6417
- * - Use async/await for asynchronous operations
6418
- * - Throw descriptive errors for error cases
6419
- * - Keep methods focused and well-named
6420
- * - Document complex logic with comments
6421
- *
6422
- * AVOID:
6423
- * - Mixing concerns (keep focused on single domain)
6424
- * - Direct tool implementation (services should be tool-agnostic)
6425
- */
6426
- const DEFAULT_CODEX_HOME_DIRNAME = ".codex";
6427
- const AUTH_FILENAME = "auth.json";
6428
- const CONFIG_FILENAME = "config.toml";
6429
- const DEFAULT_CHATGPT_BASE_URL = "https://chatgpt.com/backend-api/";
6430
- const CHATGPT_HOST = "https://chatgpt.com";
6431
- const CHAT_OPENAI_HOST = "https://chat.openai.com";
6432
- const BACKEND_API_SEGMENT = "/backend-api";
6433
- const QUOTA_USER_AGENT = "codex-cli";
6434
- const PRIMARY_WINDOW = "primary";
6435
- const SECONDARY_WINDOW = "secondary";
6436
- const QUOTA_REACHED_PERCENT = 100;
6437
- var CodexQuotaService = class {
6438
- codexHome;
6439
- fetchFn;
6440
- now;
6441
- readTextFile;
6442
- constructor(runtime, deps = {}) {
6443
- this.codexHome = deps.codexHome ?? runtime.baseEnvironment.CODEX_HOME ?? join(runtime.homeDirectory, DEFAULT_CODEX_HOME_DIRNAME);
6444
- this.fetchFn = deps.fetchFn ?? fetch;
6445
- this.now = deps.now ?? (() => Date.now());
6446
- this.readTextFile = deps.readTextFile ?? (async (path) => getOrThrow(await runtime.fs.readTextFile(path, runtime.ioContext)));
6447
- }
6448
- isCodexCommand(command, _sourceAgentKey) {
6449
- const trimmed = command.trim();
6450
- return trimmed === "codex" || trimmed.startsWith("codex ");
6451
- }
6452
- async getQuotaStatus() {
6453
- const auth = await this.readAuthFile();
6454
- const accessToken = auth?.tokens?.access_token?.trim();
6455
- const accountId = auth?.tokens?.account_id?.trim();
6456
- if (!accessToken || !accountId) return null;
6457
- const baseUrl = await this.readChatgptBaseUrl();
6458
- const response = await this.fetchFn(this.buildUsageUrl(baseUrl), { headers: {
6459
- Authorization: `Bearer ${accessToken}`,
6460
- "ChatGPT-Account-Id": accountId,
6461
- "User-Agent": QUOTA_USER_AGENT
6462
- } });
6463
- if (!response.ok) throw new Error(`codex quota request failed with HTTP ${response.status}`);
6464
- const payload = await response.json();
6465
- return {
6466
- blockingLimit: this.findBlockingLimit(payload),
6467
- planType: payload.plan_type ?? null
6468
- };
6469
- }
6470
- async readAuthFile() {
6471
- const raw = await this.readOptionalTextFile(join(this.codexHome, AUTH_FILENAME));
6472
- if (!raw) return null;
6473
- return JSON.parse(raw);
6474
- }
6475
- async readChatgptBaseUrl() {
6476
- const match = (await this.readOptionalTextFile(join(this.codexHome, CONFIG_FILENAME)))?.match(/^\s*chatgpt_base_url\s*=\s*"([^"]+)"/m);
6477
- return this.normalizeBaseUrl(match?.[1] ?? DEFAULT_CHATGPT_BASE_URL);
6478
- }
6479
- buildUsageUrl(baseUrl) {
6480
- return baseUrl.includes(BACKEND_API_SEGMENT) ? `${baseUrl}/wham/usage` : `${baseUrl}/api/codex/usage`;
6481
- }
6482
- normalizeBaseUrl(baseUrl) {
6483
- let normalized = baseUrl.trim().replace(/\/+$/, "");
6484
- if ((normalized.startsWith(CHATGPT_HOST) || normalized.startsWith(CHAT_OPENAI_HOST)) && !normalized.includes(BACKEND_API_SEGMENT)) normalized = `${normalized}${BACKEND_API_SEGMENT}`;
6485
- return normalized;
6486
- }
6487
- async readOptionalTextFile(path) {
6488
- try {
6489
- return await this.readTextFile(path);
6490
- } catch (error) {
6491
- if (error.code === "ENOENT") return null;
6492
- throw error;
6493
- }
6494
- }
6495
- findBlockingLimit(payload) {
6496
- const blocks = [];
6497
- this.collectBlockingLimit(blocks, "codex", "codex", payload.rate_limit);
6498
- for (const additionalLimit of payload.additional_rate_limits ?? []) this.collectBlockingLimit(blocks, additionalLimit.metered_feature ?? additionalLimit.limit_name ?? "codex", additionalLimit.limit_name ?? additionalLimit.metered_feature ?? "codex", additionalLimit.rate_limit);
6499
- blocks.sort((left, right) => left.resetAt - right.resetAt || right.usedPercent - left.usedPercent);
6500
- return blocks[0] ?? null;
6501
- }
6502
- collectBlockingLimit(blocks, limitId, limitName, limit) {
6503
- if (!limit) return;
6504
- const windows = [{
6505
- payload: limit.primary_window,
6506
- window: PRIMARY_WINDOW
6507
- }, {
6508
- payload: limit.secondary_window,
6509
- window: SECONDARY_WINDOW
6510
- }];
6511
- for (const { payload, window } of windows) {
6512
- const resetAt = payload?.reset_at;
6513
- const usedPercent = payload?.used_percent ?? 0;
6514
- if (typeof resetAt !== "number") continue;
6515
- if (!(usedPercent >= QUOTA_REACHED_PERCENT || limit.limit_reached === true && resetAt * 1e3 > this.now() || limit.allowed === false && resetAt * 1e3 > this.now())) continue;
6516
- blocks.push({
6517
- limitId,
6518
- limitName,
6519
- resetAfterSeconds: payload?.reset_after_seconds ?? null,
6520
- resetAt,
6521
- usedPercent,
6522
- window,
6523
- windowSeconds: payload?.limit_window_seconds ?? null
6524
- });
6525
- }
6526
- }
6527
- };
6528
- //#endregion
6529
6408
  //#region src/services/StepRunnerService/index.ts
6530
6409
  /**
6531
6410
  * StepRunnerService
@@ -6688,33 +6567,15 @@ const WORKFLOW_STEP_NAME_ENV_KEY = "WORKFLOW_STEP_NAME";
6688
6567
  const WORKFLOW_STEP_DISPLAY_ENV_KEY = "WORKFLOW_STEP_DISPLAY";
6689
6568
  const WORKFLOW_STEP_ARTIFACTS_ENV_KEY = "WORKFLOW_STEP_ARTIFACTS";
6690
6569
  const WORKFLOW_TERMINAL_TITLE = "workflow-mcp";
6691
- const STATUS_FILE_PREFIX = "workflow-step-";
6692
- const STATUS_FILE_SUFFIX = ".status";
6693
- const STATUS_FILE_COMPLETION_VALUE = "YES";
6694
- const STATUS_FILE_COMPLETED_RESULT = { status: "status_completed" };
6695
- const TRANSIENT_FS_ERROR_CODES = /* @__PURE__ */ new Set([
6696
- "ENOENT",
6697
- "EBUSY",
6698
- "EAGAIN",
6699
- "EPERM",
6700
- "not_found"
6701
- ]);
6702
- const STATUS_FILE_POLL_INTERVAL_MS = 1e3;
6703
6570
  const STOP_REQUEST_POLL_INTERVAL_MS = 1e3;
6704
- const STATUS_DONE = "done";
6705
6571
  const STATUS_STOP = "stop";
6706
6572
  const EXPLICIT_RUNNER_MISSING_PREFIX = "runner";
6707
6573
  const EXPLICIT_RUNNER_MISSING_MIDDLE = "not found for step";
6708
6574
  const EXPLICIT_RUNNER_AVAILABLE_PREFIX = "available runner keys:";
6709
- const QUOTA_WAIT_POLL_INTERVAL_MS = 3e4;
6710
- const QUOTA_WAIT_RESET_BUFFER_MS = 1e3;
6711
- const QUOTA_WAIT_SOURCE = "StepRunnerService.waitForCodexQuota";
6712
- const QUOTA_RETRY_REASON = "codex quota reached after failed step, retrying after reset";
6713
6575
  const RESULT_STATUS_COMPLETED = "completed";
6714
6576
  const RESULT_STATUS_SPAWN_ERROR = "spawn_error";
6715
6577
  const RESULT_STATUS_SIGNALED = "signaled";
6716
6578
  const RESULT_STATUS_TIMED_OUT = "timed_out";
6717
- const RESULT_STATUS_STATUS_COMPLETED = "status_completed";
6718
6579
  const RESULT_STATUS_STOP_REQUESTED = "stop_requested";
6719
6580
  const RESULT_STATUS_PAUSE_REQUESTED = "pause_requested";
6720
6581
  /** The reason a step failure carries when nothing more specific was recorded. */
@@ -6747,8 +6608,7 @@ var StepRunnerService = class StepRunnerService {
6747
6608
  runtime;
6748
6609
  parser;
6749
6610
  logger;
6750
- quotaService;
6751
- watchStatusFile;
6611
+ watchControlFile;
6752
6612
  runDirectoryService;
6753
6613
  ownsTerminal;
6754
6614
  stepExecutor;
@@ -6757,7 +6617,6 @@ var StepRunnerService = class StepRunnerService {
6757
6617
  activeExternal = null;
6758
6618
  lastInteractiveReap = null;
6759
6619
  interruptedSignal = null;
6760
- activeQuotaWait = null;
6761
6620
  commandSelection = {};
6762
6621
  /** Runners of a parallel group's steps, which a stop must reach too. */
6763
6622
  forks = /* @__PURE__ */ new Set();
@@ -6772,12 +6631,11 @@ var StepRunnerService = class StepRunnerService {
6772
6631
  * must not hand a step's stdin to it, and must not `stty` or reset it
6773
6632
  * afterwards, however cooperative the intent.
6774
6633
  */
6775
- constructor(runtime, parser, logger, quotaService = new CodexQuotaService(runtime), watchStatusFile = runtime.fs.watch.bind(runtime.fs), runDirectoryService = new RunDirectoryService(runtime), ownsTerminal = true, stepExecutor, resolveSecrets) {
6634
+ constructor(runtime, parser, logger, watchControlFile = runtime.fs.watch.bind(runtime.fs), runDirectoryService = new RunDirectoryService(runtime), ownsTerminal = true, stepExecutor, resolveSecrets) {
6776
6635
  this.runtime = runtime;
6777
6636
  this.parser = parser;
6778
6637
  this.logger = logger;
6779
- this.quotaService = quotaService;
6780
- this.watchStatusFile = watchStatusFile;
6638
+ this.watchControlFile = watchControlFile;
6781
6639
  this.runDirectoryService = runDirectoryService;
6782
6640
  this.ownsTerminal = ownsTerminal;
6783
6641
  this.stepExecutor = stepExecutor;
@@ -6798,7 +6656,7 @@ var StepRunnerService = class StepRunnerService {
6798
6656
  * Release it once its step has finished.
6799
6657
  */
6800
6658
  fork(label) {
6801
- const child = new StepRunnerService(this.runtime, this.parser, labelledLogger(this.logger, label), this.quotaService, this.watchStatusFile, this.runDirectoryService, this.ownsTerminal, this.stepExecutor, this.resolveSecrets);
6659
+ const child = new StepRunnerService(this.runtime, this.parser, labelledLogger(this.logger, label), this.watchControlFile, this.runDirectoryService, this.ownsTerminal, this.stepExecutor, this.resolveSecrets);
6802
6660
  child.commandSelection = this.commandSelection;
6803
6661
  child.interruptedSignal = this.interruptedSignal;
6804
6662
  child.terminalLock = this.terminalLock;
@@ -6823,16 +6681,6 @@ var StepRunnerService = class StepRunnerService {
6823
6681
  for (const child of this.forks) child.stopActiveStep(signal);
6824
6682
  return;
6825
6683
  }
6826
- if (this.activeQuotaWait) {
6827
- if (this.activeQuotaWait.controller.signal.aborted) {
6828
- this.logger.info(` ${DIM$3}${STATUS_SKIP}${RESET$3} ${this.activeQuotaWait.stepName} ${ALREADY_STOPPING_SUFFIX}`);
6829
- return;
6830
- }
6831
- this.activeQuotaWait.signal = signal;
6832
- this.activeQuotaWait.controller.abort();
6833
- this.logger.info(` ${YELLOW$2}${STATUS_INTERRUPTED}${RESET$3} cancelling quota wait for ${this.activeQuotaWait.stepName}`);
6834
- return;
6835
- }
6836
6684
  if (this.activeExternal) {
6837
6685
  if (this.activeExternal.stopSignal) {
6838
6686
  this.logger.info(` ${DIM$3}${STATUS_SKIP}${RESET$3} ${this.activeExternal.stepName} ${ALREADY_STOPPING_SUFFIX}`);
@@ -6931,7 +6779,6 @@ var StepRunnerService = class StepRunnerService {
6931
6779
  return false;
6932
6780
  }
6933
6781
  const { command, custom, inProcessOnly, interactive, template } = resolvedStepCommand;
6934
- const isCodexCommand = this.quotaService.isCodexCommand(command, resolvedStepCommand.agentKey);
6935
6782
  const shouldContinue = step["continue-on-error"] || options.continueOnError;
6936
6783
  let timeoutMs;
6937
6784
  try {
@@ -7021,12 +6868,7 @@ var StepRunnerService = class StepRunnerService {
7021
6868
  }
7022
6869
  const stepStartedAt = Date.now();
7023
6870
  await this.logStepLifecycle("info", "workflow.step.started", stepEnv, { "workflow.step.interactive": interactive });
7024
- let statusFilePath;
7025
- if (interactive) {
7026
- statusFilePath = await this.createStatusFile();
7027
- stepEnv[STATUS_FILE_ENV_KEY] = statusFilePath;
7028
- this.logger.info(` ${DIM$3}status-file${RESET$3} ${statusFilePath}`);
7029
- } else delete stepEnv[STATUS_FILE_ENV_KEY];
6871
+ delete stepEnv[STATUS_FILE_ENV_KEY];
7030
6872
  if (options.dryRun) {
7031
6873
  this.logger.info(` ${CYAN$2}${STATUS_DRY}${RESET$3} ${stepName}`);
7032
6874
  this.logger.info(`${COMMAND_LOG_INDENT}${DIM$3}${COMMAND_LOG_PROMPT}${command.split(COMMAND_LINE_BREAK).join(COMMAND_LOG_CONTINUATION)}${RESET$3}`);
@@ -7075,9 +6917,7 @@ var StepRunnerService = class StepRunnerService {
7075
6917
  return false;
7076
6918
  }
7077
6919
  }
7078
- let quotaFailureRetried = false;
7079
6920
  for (let attempt = 0; attempt <= maxTimeoutRetries; attempt++) {
7080
- await this.waitForCodexQuotaAvailability(stepName, command, isCodexCommand);
7081
6921
  if (decisionFilePath && decisionIdentity) await resetDecisionFile(this.runtime, decisionFilePath, decisionIdentity);
7082
6922
  if (attempt > 0) this.logger.warn(` ${YELLOW$2}${STATUS_RETRY}${RESET$3} ${STEP_TIMEOUT_RETRY_PREFIX} "${stepName}" (attempt ${attempt + 1}/${maxTimeoutRetries + 1})`);
7083
6923
  else this.logger.info(` ${CYAN$2}${STATUS_RUN}${RESET$3} ${stepName}`);
@@ -7114,7 +6954,7 @@ var StepRunnerService = class StepRunnerService {
7114
6954
  timeoutMs,
7115
6955
  workDir
7116
6956
  }));
7117
- const executionResult = interactive && statusFilePath ? await this.raceInteractiveCompletion(executionPromise, statusFilePath, stepName, options.stopRequestPath, step["pause-policy"] ?? "replay") : options.stopRequestPath ? await this.raceStopRequest(executionPromise, stepName, options.stopRequestPath, step["pause-policy"] ?? "replay") : await executionPromise;
6957
+ const executionResult = interactive ? await this.raceInteractiveCompletion(executionPromise, stepName, options.stopRequestPath, step["pause-policy"] ?? "replay") : options.stopRequestPath ? await this.raceStopRequest(executionPromise, stepName, options.stopRequestPath, step["pause-policy"] ?? "replay") : await executionPromise;
7118
6958
  if (executionResult.status === RESULT_STATUS_PAUSE_REQUESTED) {
7119
6959
  await this.logStepLifecycle("info", "workflow.step.pause_requested", stepEnv, {
7120
6960
  "workflow.step.outcome": pausePolicy === "replay" ? "cancelled_for_pause" : "protected_boundary",
@@ -7171,7 +7011,6 @@ var StepRunnerService = class StepRunnerService {
7171
7011
  }
7172
7012
  const decision = decisionFilePath ? await readStepDecision(this.runtime, decisionFilePath) : void 0;
7173
7013
  if (decision) {
7174
- if (statusFilePath) await this.cleanupStatusFile(statusFilePath);
7175
7014
  if (decision.decision === "complete") {
7176
7015
  const artifactProblem = artifactSnapshots ? await this.describeArtifactWarnings(stepEnv, artifactSnapshots) : void 0;
7177
7016
  if (!artifactProblem) {
@@ -7205,15 +7044,7 @@ var StepRunnerService = class StepRunnerService {
7205
7044
  }
7206
7045
  if (executionResult.status === "timed_out") {
7207
7046
  fail(`${STEP_TIMEOUT_FAILURE_PREFIX} ${this.formatTimeoutMs(executionResult.timeoutMs)} "${stepName}" (${command.split(COMMAND_LINE_BREAK)[0]})`);
7208
- if (attempt < maxTimeoutRetries) {
7209
- if (statusFilePath) try {
7210
- getOrThrow(await this.runtime.fs.writeFile(statusFilePath, "", this.runtime.ioContext));
7211
- } catch (error) {
7212
- this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file reset failed for ${stepName}: ${error instanceof Error ? error.message : String(error)}`);
7213
- }
7214
- continue;
7215
- }
7216
- if (statusFilePath) await this.cleanupStatusFile(statusFilePath);
7047
+ if (attempt < maxTimeoutRetries) continue;
7217
7048
  if (shouldContinue) {
7218
7049
  await this.logStepLifecycle("warn", "workflow.step.finished", stepEnv, {
7219
7050
  "workflow.step.duration_ms": Date.now() - stepStartedAt,
@@ -7230,7 +7061,6 @@ var StepRunnerService = class StepRunnerService {
7230
7061
  });
7231
7062
  return false;
7232
7063
  }
7233
- if (statusFilePath) await this.cleanupStatusFile(statusFilePath);
7234
7064
  if (decisionIdentity?.required && !(executionResult.status === "completed" && executionResult.failure !== void 0)) {
7235
7065
  fail(`step "${stepName}" ended without a workflow decision (workflow-mcp step complete|fix|fail)`);
7236
7066
  return this.failStep(stepName, stepEnv, stepStartedAt, shouldContinue, report);
@@ -7253,19 +7083,6 @@ var StepRunnerService = class StepRunnerService {
7253
7083
  });
7254
7084
  return true;
7255
7085
  }
7256
- if (executionResult.status === "status_completed") {
7257
- const artifactProblem = artifactSnapshots ? await this.describeArtifactWarnings(stepEnv, artifactSnapshots) : void 0;
7258
- if (artifactProblem) {
7259
- fail(`step "${stepName}" ${artifactProblem}`);
7260
- return this.failStep(stepName, stepEnv, stepStartedAt, shouldContinue, report);
7261
- }
7262
- this.logger.info(`\n ${GREEN$2}${STATUS_DONE}${RESET$3} ${stepName} (status-file signaled completion)\n`);
7263
- await this.logStepLifecycle("info", "workflow.step.finished", stepEnv, {
7264
- "workflow.step.duration_ms": Date.now() - stepStartedAt,
7265
- "workflow.step.outcome": "success"
7266
- });
7267
- return true;
7268
- }
7269
7086
  if (executionResult.status === "completed" && executionResult.exitCode === 0) {
7270
7087
  const artifactProblem = artifactSnapshots ? await this.describeArtifactWarnings(stepEnv, artifactSnapshots) : void 0;
7271
7088
  if (!artifactProblem) {
@@ -7279,12 +7096,6 @@ var StepRunnerService = class StepRunnerService {
7279
7096
  fail(`step "${stepName}" ${artifactProblem}`);
7280
7097
  }
7281
7098
  if (executionResult.status === "completed" && executionResult.exitCode !== 0) fail(executionResult.failure ? `step "${stepName}" failed: ${executionResult.failure}` : `${STEP_EXIT_FAILURE_PREFIX} "${stepName}" ${STEP_EXIT_FAILURE_MIDDLE} ${executionResult.exitCode} (${command.split(COMMAND_LINE_BREAK)[0]})`);
7282
- if (!quotaFailureRetried && await this.shouldRetryForCodexQuota(stepName, isCodexCommand)) {
7283
- quotaFailureRetried = true;
7284
- this.logger.warn(` ${YELLOW$2}${STATUS_RETRY}${RESET$3} ${QUOTA_RETRY_REASON}`);
7285
- attempt -= 1;
7286
- continue;
7287
- }
7288
7099
  if (shouldContinue) {
7289
7100
  await this.logStepLifecycle("warn", "workflow.step.finished", stepEnv, {
7290
7101
  "workflow.step.duration_ms": Date.now() - stepStartedAt,
@@ -7629,7 +7440,7 @@ var StepRunnerService = class StepRunnerService {
7629
7440
  /**
7630
7441
  * Await a host-owned execution and normalize it like a child process.
7631
7442
  *
7632
- * The engine keeps ownership of the timeout; stop, pause and status-file
7443
+ * The engine keeps ownership of the timeout; stop and pause
7633
7444
  * completion reach the execution through `killActiveStep`, which calls its
7634
7445
  * `stop`. A stopped execution reads as signalled so shutdown still interrupts
7635
7446
  * the workflow, while the completion races report their own outcome.
@@ -7952,7 +7763,7 @@ var StepRunnerService = class StepRunnerService {
7952
7763
  return [...keys];
7953
7764
  }
7954
7765
  resolveRunner(options) {
7955
- return options.runner ?? options.cliAgent;
7766
+ return options.runner;
7956
7767
  }
7957
7768
  formatStepDisplay(jobName, stepName) {
7958
7769
  return jobName ? `${jobName} > ${stepName}` : stepName;
@@ -7967,77 +7778,6 @@ var StepRunnerService = class StepRunnerService {
7967
7778
  escapeShellArg(value) {
7968
7779
  return `'${value.replace(/'/g, "'\\''")}'`;
7969
7780
  }
7970
- async shouldRetryForCodexQuota(stepName, isCodexCommand) {
7971
- if (!isCodexCommand) return false;
7972
- return (await this.readCodexQuotaStatus(stepName))?.blockingLimit != null;
7973
- }
7974
- async waitForCodexQuotaAvailability(stepName, command, isCodexCommand) {
7975
- if (!isCodexCommand) return;
7976
- while (true) {
7977
- const quotaStatus = await this.readCodexQuotaStatus(stepName);
7978
- const blockingLimit = quotaStatus?.blockingLimit;
7979
- if (!blockingLimit) return;
7980
- const waitTargetMs = blockingLimit.resetAt * 1e3 + QUOTA_WAIT_RESET_BUFFER_MS;
7981
- const remainingMs = Math.max(waitTargetMs - Date.now(), QUOTA_WAIT_RESET_BUFFER_MS);
7982
- const waitDescription = new Date(waitTargetMs).toLocaleString();
7983
- const planSuffix = quotaStatus?.planType ? ` (${quotaStatus.planType})` : "";
7984
- this.logger.warn(` ${YELLOW$2}${STATUS_WAIT}${RESET$3} codex quota ${blockingLimit.limitName}/${blockingLimit.window} is at ${blockingLimit.usedPercent}%${planSuffix}; waiting until ${waitDescription}`);
7985
- await this.waitForQuotaDelay(stepName, command, remainingMs);
7986
- }
7987
- }
7988
- async readCodexQuotaStatus(stepName) {
7989
- try {
7990
- return await this.quotaService.getQuotaStatus();
7991
- } catch (error) {
7992
- this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} unable to read codex quota for "${stepName}" (${this.formatQuotaError(error)})`);
7993
- return null;
7994
- }
7995
- }
7996
- async waitForQuotaDelay(stepName, command, remainingMs) {
7997
- const controller = new AbortController();
7998
- this.activeQuotaWait = {
7999
- controller,
8000
- signal: null,
8001
- stepName
8002
- };
8003
- try {
8004
- let timeLeftMs = remainingMs;
8005
- while (timeLeftMs > 0) {
8006
- const sleepMs = Math.min(timeLeftMs, QUOTA_WAIT_POLL_INTERVAL_MS);
8007
- await this.waitForDelay(sleepMs, controller.signal);
8008
- timeLeftMs -= sleepMs;
8009
- }
8010
- } catch (error) {
8011
- if (controller.signal.aborted) throw new WorkflowInterruptedError(this.activeQuotaWait?.signal ?? TERMINATE_SIGNAL$1, {
8012
- cause: /* @__PURE__ */ new Error(`Interrupted while waiting for Codex quota reset`),
8013
- context: {
8014
- ...this.createInterruptContext(stepName, command),
8015
- phase: QUOTA_WAIT_SOURCE
8016
- }
8017
- });
8018
- throw error;
8019
- } finally {
8020
- this.activeQuotaWait = null;
8021
- }
8022
- }
8023
- async waitForDelay(delayMs, signal) {
8024
- await new Promise((resolveDelay, rejectDelay) => {
8025
- const timeout = setTimeout(() => {
8026
- signal.removeEventListener("abort", onAbort);
8027
- resolveDelay();
8028
- }, delayMs);
8029
- const onAbort = () => {
8030
- clearTimeout(timeout);
8031
- signal.removeEventListener("abort", onAbort);
8032
- rejectDelay(/* @__PURE__ */ new Error("aborted"));
8033
- };
8034
- signal.addEventListener("abort", onAbort, { once: true });
8035
- });
8036
- }
8037
- formatQuotaError(error) {
8038
- if (error instanceof Error && error.message.trim().length > 0) return error.message;
8039
- return "unknown quota error";
8040
- }
8041
7781
  /**
8042
7782
  * Resolve the per-step timeout from workflow YAML into milliseconds.
8043
7783
  */
@@ -8182,10 +7922,8 @@ var StepRunnerService = class StepRunnerService {
8182
7922
  return Number.isInteger(parsed) && parsed > 0 ? parsed : PROCESS_EXIT_WAIT_TIMEOUT_MS;
8183
7923
  }
8184
7924
  /**
8185
- * SIGTERM→SIGKILL grace on the completion path (status file signalled `YES`).
8186
- * Deliberately longer than the timeout-path `FORCE_KILL_GRACE_PERIOD_MS` so an
8187
- * interactive agent can flush its final telemetry batch (e.g. Claude Code's
8188
- * OTEL Stop-hook events) before SIGKILL. A fast graceful exit still settles
7925
+ * Grace for interactive stop and pause teardown, allowing telemetry to flush.
7926
+ * A fast graceful exit still settles
8189
7927
  * immediately, so this only adds latency when a child lingers. Operator-tunable
8190
7928
  * via `WORKFLOW_STEP_FORCE_KILL_GRACE_MS`; defaults to STEP_COMPLETION_KILL_GRACE_MS.
8191
7929
  */
@@ -8325,7 +8063,7 @@ var StepRunnerService = class StepRunnerService {
8325
8063
  * Interactive TUIs such as Claude Code make themselves process-group leaders
8326
8064
  * (pid === pgid) and spawn descendants into that group. Reaping by pid alone
8327
8065
  * leaves anything spawned after the one-shot tree snapshot alive, which keeps
8328
- * the interactive session running after the Stop hook signalled completion.
8066
+ * the interactive session running after a stop or pause request.
8329
8067
  */
8330
8068
  collectInteractiveProcessGroupIds(processIds) {
8331
8069
  if (processIds.length === 0) return [];
@@ -8428,38 +8166,17 @@ var StepRunnerService = class StepRunnerService {
8428
8166
  return false;
8429
8167
  }
8430
8168
  }
8431
- /**
8432
- * Create an empty temp file that the Claude Code Stop hook will write
8433
- * YES to when the agent finishes its turn. The path is injected into
8434
- * WORKFLOW_STATUS_FILE so the hook can locate it directly — no fallback
8435
- * marker file is used.
8436
- */
8437
- async createStatusFile() {
8438
- if (!this.runtime.temporaryDirectory) throw new Error("Workflow interactive status files require an admitted temporaryDirectory");
8439
- const filePath = join(this.runtime.temporaryDirectory, `${STATUS_FILE_PREFIX}${randomUUID()}${STATUS_FILE_SUFFIX}`);
8440
- getOrThrow(await this.runtime.fs.writeFile(filePath, "", this.runtime.ioContext));
8441
- return filePath;
8442
- }
8443
- /**
8444
- * Race interactive step execution against agent completion and workflow stop files.
8445
- * When the file contains YES, SIGTERM the step process and wait for
8446
- * it to exit before returning `status_completed`. Escalates to SIGKILL
8447
- * if the process ignores SIGTERM. The next job must not start until
8448
- * the child process tree has fully exited.
8449
- */
8450
- async raceInteractiveCompletion(executionPromise, statusFilePath, stepName, stopRequestPath, pausePolicy) {
8169
+ /** Race interactive execution against workflow stop and pause requests. */
8170
+ async raceInteractiveCompletion(executionPromise, stepName, stopRequestPath, pausePolicy) {
8451
8171
  return new Promise((resolveRace) => {
8452
8172
  let settled = false;
8453
- let statusFileTriggered = false;
8454
8173
  let stopRequestTriggered = false;
8455
8174
  let pauseRequestTriggered = false;
8456
8175
  const pauseRequestPath = stopRequestPath ? join(dirname(stopRequestPath), PAUSE_REQUEST_FILENAME) : void 0;
8457
8176
  let forceKillTimer = null;
8458
8177
  let completionSettleTimer = null;
8459
- let watcher = null;
8460
8178
  let stopWatcher = null;
8461
8179
  let pauseWatcher = null;
8462
- let pollTimer = null;
8463
8180
  let stopPollTimer = null;
8464
8181
  let pausePollTimer = null;
8465
8182
  let signalDelivered = false;
@@ -8467,7 +8184,6 @@ var StepRunnerService = class StepRunnerService {
8467
8184
  const resolveCompletionSource = (result) => {
8468
8185
  if (stopRequestTriggered) return "stop-request";
8469
8186
  if (pauseRequestTriggered) return "pause-request";
8470
- if (statusFileTriggered) return "status-file";
8471
8187
  switch (result.status) {
8472
8188
  case RESULT_STATUS_TIMED_OUT: return "timed-out";
8473
8189
  case RESULT_STATUS_SPAWN_ERROR: return "spawn-error";
@@ -8478,10 +8194,6 @@ var StepRunnerService = class StepRunnerService {
8478
8194
  const settle = async (result) => {
8479
8195
  if (settled) return;
8480
8196
  settled = true;
8481
- if (watcher) {
8482
- await watcher.close(this.runtime.ioContext).catch((error) => this.logger.warn(`Workflow watcher cleanup failed: ${String(error)}`));
8483
- watcher = null;
8484
- }
8485
8197
  if (stopWatcher) {
8486
8198
  await stopWatcher.close(this.runtime.ioContext).catch((error) => this.logger.warn(`Workflow watcher cleanup failed: ${String(error)}`));
8487
8199
  stopWatcher = null;
@@ -8490,10 +8202,6 @@ var StepRunnerService = class StepRunnerService {
8490
8202
  await pauseWatcher.close(this.runtime.ioContext).catch((error) => this.logger.warn(`Workflow watcher cleanup failed: ${String(error)}`));
8491
8203
  pauseWatcher = null;
8492
8204
  }
8493
- if (pollTimer) {
8494
- clearInterval(pollTimer);
8495
- pollTimer = null;
8496
- }
8497
8205
  if (stopPollTimer) {
8498
8206
  clearInterval(stopPollTimer);
8499
8207
  stopPollTimer = null;
@@ -8517,25 +8225,13 @@ var StepRunnerService = class StepRunnerService {
8517
8225
  await this.recordInteractiveCompletion({
8518
8226
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
8519
8227
  stepName,
8520
- statusFilePath,
8521
8228
  completionSource: resolveCompletionSource(settledResult),
8522
- statusFileSignaled: statusFileTriggered,
8523
8229
  sigkillEscalated: sigkillEscalated || (this.lastInteractiveReap?.sigkillEscalated ?? false),
8524
8230
  survivors: this.lastInteractiveReap?.survivors ?? []
8525
8231
  });
8526
8232
  this.lastInteractiveReap = null;
8527
8233
  resolveRace(settledResult);
8528
8234
  };
8529
- const statusFileHasCompletionValue = async () => {
8530
- try {
8531
- return await pathExists(this.runtime.fs, statusFilePath, this.runtime.ioContext) && getOrThrow(await this.runtime.fs.readTextFile(statusFilePath, this.runtime.ioContext)).trim() === STATUS_FILE_COMPLETION_VALUE;
8532
- } catch (error) {
8533
- const code = error.code;
8534
- if (!code || !TRANSIENT_FS_ERROR_CODES.has(code)) this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file read failed for ${stepName}: ${error instanceof Error ? error.message : String(error)}`);
8535
- else this.logger.info(` ${DIM$3}status-file${RESET$3} transient FS error (${code}) polling ${stepName}`);
8536
- return false;
8537
- }
8538
- };
8539
8235
  const scheduleAbsoluteSettle = (result, delayMs) => {
8540
8236
  if (settled || completionSettleTimer) return;
8541
8237
  completionSettleTimer = setTimeout(() => {
@@ -8554,24 +8250,6 @@ var StepRunnerService = class StepRunnerService {
8554
8250
  settle(result);
8555
8251
  }, delayMs);
8556
8252
  };
8557
- const checkFileContent = async () => {
8558
- if (!await statusFileHasCompletionValue() || settled || statusFileTriggered) return;
8559
- statusFileTriggered = true;
8560
- const graceMs = this.stepCompletionKillGraceMs();
8561
- signalDelivered = this.killActiveStep(TERMINATE_SIGNAL$1);
8562
- if (!signalDelivered) {
8563
- this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} status-file: SIGTERM could not be delivered, process may have already exited`);
8564
- scheduleAbsoluteSettle(STATUS_FILE_COMPLETED_RESULT, PROCESS_EXIT_WAIT_TIMEOUT_MS);
8565
- return;
8566
- }
8567
- forceKillTimer = setTimeout(() => {
8568
- if (settled) return;
8569
- sigkillEscalated = true;
8570
- this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} did not exit after status-file SIGTERM, forcing SIGKILL`);
8571
- this.killActiveStep(TERMINATE_FORCE_KILL_SIGNAL);
8572
- }, graceMs);
8573
- scheduleAbsoluteSettle(STATUS_FILE_COMPLETED_RESULT, graceMs + PROCESS_EXIT_WAIT_TIMEOUT_MS);
8574
- };
8575
8253
  const stopRequestExists = async () => Boolean(stopRequestPath && await this.hasCurrentStopRequest(stopRequestPath));
8576
8254
  const pauseRequestExists = async () => Boolean(pauseRequestPath && await pathExists(this.runtime.fs, pauseRequestPath, this.runtime.ioContext) && await this.readControlAction(pauseRequestPath) === "pause");
8577
8255
  const checkStopRequest = async () => {
@@ -8611,23 +8289,9 @@ var StepRunnerService = class StepRunnerService {
8611
8289
  }, graceMs);
8612
8290
  scheduleAbsoluteSettle({ status: RESULT_STATUS_PAUSE_REQUESTED }, graceMs + PROCESS_EXIT_WAIT_TIMEOUT_MS);
8613
8291
  };
8614
- try {
8615
- this.watchStatusFile([{ path: statusFilePath }], () => {
8616
- checkFileContent().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8617
- }, this.runtime.ioContext).then(async (result) => {
8618
- const admitted = getOrThrow(result);
8619
- if (settled) await admitted.close(this.runtime.ioContext);
8620
- else watcher = admitted;
8621
- }).catch((error) => this.logger.warn(`Workflow status-file watcher unavailable, polling instead: ${String(error)}`));
8622
- } catch (error) {
8623
- this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file watcher setup failed for ${stepName}: ${error instanceof Error ? error.message : String(error)}`);
8624
- }
8625
- pollTimer = setInterval(() => {
8626
- checkFileContent().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8627
- }, STATUS_FILE_POLL_INTERVAL_MS);
8628
8292
  if (stopRequestPath) {
8629
8293
  try {
8630
- this.watchStatusFile([{ path: stopRequestPath }], () => {
8294
+ this.watchControlFile([{ path: stopRequestPath }], () => {
8631
8295
  checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8632
8296
  }, this.runtime.ioContext).then(async (result) => {
8633
8297
  const admitted = getOrThrow(result);
@@ -8643,7 +8307,7 @@ var StepRunnerService = class StepRunnerService {
8643
8307
  }
8644
8308
  if (pauseRequestPath) {
8645
8309
  try {
8646
- this.watchStatusFile([{ path: pauseRequestPath }], () => {
8310
+ this.watchControlFile([{ path: pauseRequestPath }], () => {
8647
8311
  checkPauseRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8648
8312
  }, this.runtime.ioContext).then(async (result) => {
8649
8313
  const admitted = getOrThrow(result);
@@ -8657,7 +8321,6 @@ var StepRunnerService = class StepRunnerService {
8657
8321
  checkPauseRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8658
8322
  }, STOP_REQUEST_POLL_INTERVAL_MS);
8659
8323
  }
8660
- checkFileContent().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8661
8324
  checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8662
8325
  checkPauseRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8663
8326
  executionPromise.then(async (result) => {
@@ -8666,42 +8329,9 @@ var StepRunnerService = class StepRunnerService {
8666
8329
  settle({ status: RESULT_STATUS_STOP_REQUESTED });
8667
8330
  return;
8668
8331
  }
8669
- const completedViaStatusFile = statusFileTriggered || await statusFileHasCompletionValue();
8670
- const protectedPauseEligible = result.status === RESULT_STATUS_STATUS_COMPLETED || result.status === RESULT_STATUS_COMPLETED && result.exitCode === 0;
8671
- if (pauseRequestTriggered && (pausePolicy !== "protected" || protectedPauseEligible) && (pausePolicy === "protected" || !statusFileTriggered)) {
8672
- settle({ status: RESULT_STATUS_PAUSE_REQUESTED });
8673
- return;
8674
- }
8675
- if (!completedViaStatusFile) {
8676
- settle(result);
8677
- return;
8678
- }
8679
- if (!statusFileTriggered) {
8680
- statusFileTriggered = true;
8681
- this.logger.info(` ${GREEN$2}${STATUS_DONE}${RESET$3} ${stepName} status-file observed during process exit handling`);
8682
- }
8683
- switch (result.status) {
8684
- case RESULT_STATUS_SPAWN_ERROR:
8685
- case RESULT_STATUS_TIMED_OUT:
8686
- settle(result);
8687
- return;
8688
- case RESULT_STATUS_SIGNALED:
8689
- if (sigkillEscalated) this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} required SIGKILL escalation (work completed via status-file)`);
8690
- settle(STATUS_FILE_COMPLETED_RESULT);
8691
- return;
8692
- case RESULT_STATUS_COMPLETED:
8693
- if (sigkillEscalated) this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} required SIGKILL escalation (work completed via status-file, exit code ${result.exitCode})`);
8694
- settle(STATUS_FILE_COMPLETED_RESULT);
8695
- return;
8696
- case RESULT_STATUS_STATUS_COMPLETED:
8697
- settle(result);
8698
- return;
8699
- case RESULT_STATUS_STOP_REQUESTED:
8700
- case RESULT_STATUS_PAUSE_REQUESTED:
8701
- settle(result);
8702
- return;
8703
- default: settle(result);
8704
- }
8332
+ const protectedPauseEligible = result.status === RESULT_STATUS_COMPLETED && result.exitCode === 0;
8333
+ if (pauseRequestTriggered && (pausePolicy !== "protected" || protectedPauseEligible)) settle({ status: RESULT_STATUS_PAUSE_REQUESTED });
8334
+ else settle(result);
8705
8335
  });
8706
8336
  });
8707
8337
  }
@@ -8750,7 +8380,7 @@ var StepRunnerService = class StepRunnerService {
8750
8380
  }, FORCE_KILL_GRACE_PERIOD_MS);
8751
8381
  };
8752
8382
  try {
8753
- this.watchStatusFile([{ path: stopRequestPath }], () => {
8383
+ this.watchControlFile([{ path: stopRequestPath }], () => {
8754
8384
  checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8755
8385
  }, this.runtime.ioContext).then(async (result) => {
8756
8386
  const admitted = getOrThrow(result);
@@ -8765,7 +8395,7 @@ var StepRunnerService = class StepRunnerService {
8765
8395
  }, STOP_REQUEST_POLL_INTERVAL_MS);
8766
8396
  checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
8767
8397
  executionPromise.then(async (result) => {
8768
- const protectedPauseEligible = result.status === RESULT_STATUS_STATUS_COMPLETED || result.status === RESULT_STATUS_COMPLETED && result.exitCode === 0;
8398
+ const protectedPauseEligible = result.status === RESULT_STATUS_COMPLETED && result.exitCode === 0;
8769
8399
  if (stopRequestTriggered) settle({ status: RESULT_STATUS_STOP_REQUESTED });
8770
8400
  else if (pauseRequestTriggered && (pausePolicy !== "protected" || protectedPauseEligible)) settle({ status: RESULT_STATUS_PAUSE_REQUESTED });
8771
8401
  else settle(result);
@@ -8875,16 +8505,6 @@ var StepRunnerService = class StepRunnerService {
8875
8505
  this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} failed to restore terminal state: ${String(error)}`);
8876
8506
  }
8877
8507
  }
8878
- /**
8879
- * Remove the temp status file and the well-known marker file after step completion.
8880
- */
8881
- async cleanupStatusFile(statusFilePath) {
8882
- try {
8883
- if (await pathExists(this.runtime.fs, statusFilePath, this.runtime.ioContext)) getOrThrow(await this.runtime.fs.remove(statusFilePath, { force: true }, this.runtime.ioContext));
8884
- } catch (error) {
8885
- this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file cleanup failed: ${error instanceof Error ? error.message : String(error)}`);
8886
- }
8887
- }
8888
8508
  };
8889
8509
  //#endregion
8890
8510
  //#region src/services/TriggerService/index.ts
@@ -9608,7 +9228,7 @@ var RunWorkflowService = class {
9608
9228
  this.launcherMetadata = dependencies.launcherMetadata;
9609
9229
  this.parser = dependencies.parser ?? new WorkflowParserService(this.runtime);
9610
9230
  this.serviceManager = dependencies.serviceManager ?? new BackgroundServiceManager(this.runtime, this.logger);
9611
- this.stepRunner = dependencies.stepRunner ?? new StepRunnerService(this.runtime, this.parser, this.logger, void 0, void 0, void 0, dependencies.ownsTerminal, dependencies.stepExecutor, dependencies.resolveSecrets);
9231
+ this.stepRunner = dependencies.stepRunner ?? new StepRunnerService(this.runtime, this.parser, this.logger, void 0, void 0, dependencies.ownsTerminal, dependencies.stepExecutor, dependencies.resolveSecrets);
9612
9232
  this.registry = dependencies.registry ?? new WorkflowRegistryService(this.runtime);
9613
9233
  this.runDirectoryService = dependencies.runDirectoryService ?? new RunDirectoryService(this.runtime, this.registry.writeCoordinator);
9614
9234
  this.jobRunner = dependencies.jobRunner ?? new JobRunnerService(this.runtime, this.parser, this.stepRunner, this.logger, this.runDirectoryService);
@@ -9620,6 +9240,7 @@ var RunWorkflowService = class {
9620
9240
  * Run the workflow from trigger preparation through cleanup.
9621
9241
  */
9622
9242
  async run(input) {
9243
+ if ("cliAgent" in input) throw new Error("cliAgent is retired. Use runner explicitly.");
9623
9244
  this.stepRunner.resetInterruption();
9624
9245
  this.triggerService.resetInterruption();
9625
9246
  this.outputLines = [];
@@ -9807,8 +9428,7 @@ var RunWorkflowService = class {
9807
9428
  });
9808
9429
  }
9809
9430
  resolveRunner(input, workflow) {
9810
- if (input.runner && input.cliAgent && input.runner !== input.cliAgent) throw new Error(`Conflicting runner selectors: runner="${input.runner}" cliAgent="${input.cliAgent}"`);
9811
- return input.runner ?? input.cliAgent ?? (workflow ? this.resolveWorkflowRunner(workflow) : void 0);
9431
+ return input.runner ?? (workflow ? this.resolveWorkflowRunner(workflow) : void 0);
9812
9432
  }
9813
9433
  /**
9814
9434
  * Execute the workflow after signal handlers are installed.
@@ -9941,7 +9561,6 @@ var RunWorkflowService = class {
9941
9561
  if (dryRun && input.recovery) registryRun = await this.createRecoveryDryRunHandle(input, resolvedWorkspace);
9942
9562
  else registryRun = await this.registry.createRun({
9943
9563
  activeRepairId: input.recovery?.activeRepairId,
9944
- cliAgent: input.cliAgent,
9945
9564
  continueOnError: input.continueOnError,
9946
9565
  displayName: workflowName,
9947
9566
  dryRun,
@@ -10034,7 +9653,6 @@ var RunWorkflowService = class {
10034
9653
  }
10035
9654
  if (!await this.triggerService.handleAgentDecision(workflow, workflowEnv, inputs, secrets, {
10036
9655
  runner,
10037
- cliAgent: input.cliAgent,
10038
9656
  dryRun,
10039
9657
  continueOnError,
10040
9658
  stopRequestPath: registryRun.stopRequestPath,
@@ -10073,7 +9691,6 @@ var RunWorkflowService = class {
10073
9691
  this.logger.info(` ${"─".repeat(50)}`);
10074
9692
  if (!await this.worktreeService.runHook(workflow.worktree.beforeCreate, workflowDir, workflowEnv, inputs, secrets, {
10075
9693
  runner,
10076
- cliAgent: input.cliAgent,
10077
9694
  dryRun,
10078
9695
  continueOnError,
10079
9696
  stopRequestPath: registryRun.stopRequestPath,
@@ -10105,7 +9722,6 @@ var RunWorkflowService = class {
10105
9722
  this.logger.info(` ${"─".repeat(50)}`);
10106
9723
  if (!await this.worktreeService.runHook(workflow.worktree.afterCreate, worktreePath, workflowEnv, inputs, secrets, {
10107
9724
  runner,
10108
- cliAgent: input.cliAgent,
10109
9725
  dryRun,
10110
9726
  continueOnError,
10111
9727
  stopRequestPath: registryRun.stopRequestPath,
@@ -10138,7 +9754,6 @@ var RunWorkflowService = class {
10138
9754
  const preStopRequestPath = registryRun.stopRequestPath;
10139
9755
  if (!await this.recordPhase(progress, PRE_PHASE_JOB, () => this.runPreBlock(preBlock, workflowEnv, inputs, secrets, {
10140
9756
  runner,
10141
- cliAgent: input.cliAgent,
10142
9757
  dryRun,
10143
9758
  continueOnError,
10144
9759
  progress,
@@ -10216,7 +9831,6 @@ var RunWorkflowService = class {
10216
9831
  runDirectory: workflow["run-directory"]
10217
9832
  }, {
10218
9833
  runner,
10219
- cliAgent: input.cliAgent,
10220
9834
  dryRun,
10221
9835
  continueOnError,
10222
9836
  stopRequestPath,
@@ -10323,7 +9937,6 @@ var RunWorkflowService = class {
10323
9937
  } : void 0
10324
9938
  }, {
10325
9939
  runner,
10326
- cliAgent: input.cliAgent,
10327
9940
  dryRun,
10328
9941
  continueOnError,
10329
9942
  stopRequestPath: registryRun.stopRequestPath,
@@ -10534,7 +10147,6 @@ var RunWorkflowService = class {
10534
10147
  this.logger.info(` ${"─".repeat(50)}`);
10535
10148
  if (!await this.worktreeService.runHook(workflow.worktree.beforeCompleted, worktreePath, workflowEnv, inputs, secrets, {
10536
10149
  runner,
10537
- cliAgent: input.cliAgent,
10538
10150
  dryRun,
10539
10151
  continueOnError
10540
10152
  })) {
@@ -10559,7 +10171,6 @@ var RunWorkflowService = class {
10559
10171
  try {
10560
10172
  if (!await this.recordPhase(progress, POST_PHASE_JOB, () => this.runPostBlock(postBlock, workflowEnv, inputs, secrets, {
10561
10173
  runner,
10562
- cliAgent: input.cliAgent,
10563
10174
  dryRun,
10564
10175
  continueOnError,
10565
10176
  progress,
@@ -10586,7 +10197,6 @@ var RunWorkflowService = class {
10586
10197
  this.logger.info(` ${"─".repeat(50)}`);
10587
10198
  if (!await this.worktreeService.runHook(workflow.worktree.afterCompleted, originalDir, workflowEnv, inputs, secrets, {
10588
10199
  runner,
10589
- cliAgent: input.cliAgent,
10590
10200
  dryRun,
10591
10201
  continueOnError
10592
10202
  })) {
@@ -11261,13 +10871,17 @@ var RecoverWorkflowService = class {
11261
10871
  if (!recoveredJob) throw new Error(`Workflow run "${record.workspace}/${record.runKey}" does not include a recoverable failed job`);
11262
10872
  if (record.worktreePath && !await pathExists(this.runtime.fs, record.worktreePath, this.runtime.ioContext)) throw new Error(`Recoverable worktree not found: ${record.worktreePath}`);
11263
10873
  const runner = input.runner ?? record.runner ?? record.cliAgent;
11264
- const cliAgent = runner === record.cliAgent ? record.cliAgent : void 0;
10874
+ if ([runner, record.command].some((value) => value !== void 0 && [
10875
+ "claude",
10876
+ "claude-code",
10877
+ "codex",
10878
+ "antigravity"
10879
+ ].includes(value))) throw new Error("Retired workflow execution cannot be replayed. Select a supported runner explicitly.");
11265
10880
  const originalJob = fixRestartFrom && !activeRepair ? void 0 : record.job;
11266
10881
  if (!this.parser.resolveJobOrder(workflow.jobs, originalJob ?? null).includes(recoveredJob)) throw new Error(`Workflow run "${record.workspace}/${record.runKey}" recovery target "${recoveredJob}" is not in the workflow job order`);
11267
10882
  const ownerSessionId = claimedOwnerSessionId?.trim();
11268
10883
  const envOverrides = ownerSessionId ? { [PI_SESSION_ENV]: ownerSessionId } : void 0;
11269
10884
  return await this.runner.run({
11270
- cliAgent,
11271
10885
  runner,
11272
10886
  command: record.command,
11273
10887
  choice: record.choice,
@@ -11324,6 +10938,6 @@ var RecoverWorkflowService = class {
11324
10938
  }
11325
10939
  };
11326
10940
  //#endregion
11327
- export { readWorkflowCatalog as A, readWorkflowPackageVersion as C, WorkflowParserService as D, diagnoseWorkflows as E, listWorkflows as M, createWorkflowRuntime as O, createWorkflowHost as S, diagnoseWorkflow as T, RunDirectoryService as _, WorkflowRegistryService as a, serveNativeTerminal as b, summarizeWorkflowProgress as c, WORKFLOW_DECISION_STEERING_ENV as d, WORKFLOW_DECISION_STEERING_HOST as f, recordStepDecision as g, readStepDecision as h, CodexQuotaService as i, summarizeWorkflow as j, workflowShellOutput as k, workflowRunPhase as l, gateStepDecision as m, RunWorkflowService as n, readWorkflowProgress as o, formatArtifactWarning as p, createEmbeddedRunWorkflowService as r, readWorkflowProgressFrom as s, RecoverWorkflowService as t, WORKFLOW_DECISION_FILE_ENV as u, NativeTerminalService as v, resolveWorkflowCliPath as w, terminalSocketPath as x, connectNativeTerminal as y };
10941
+ export { listWorkflows as A, diagnoseWorkflow as C, workflowShellOutput as D, createWorkflowRuntime as E, readWorkflowCatalog as O, resolveWorkflowCliPath as S, WorkflowParserService as T, connectNativeTerminal as _, readWorkflowProgress as a, createWorkflowHost as b, workflowRunPhase as c, WORKFLOW_DECISION_STEERING_HOST as d, gateStepDecision as f, NativeTerminalService as g, RunDirectoryService as h, WorkflowRegistryService as i, summarizeWorkflow as k, WORKFLOW_DECISION_FILE_ENV as l, recordStepDecision as m, RunWorkflowService as n, readWorkflowProgressFrom as o, readStepDecision as p, createEmbeddedRunWorkflowService as r, summarizeWorkflowProgress as s, RecoverWorkflowService as t, WORKFLOW_DECISION_STEERING_ENV as u, serveNativeTerminal as v, diagnoseWorkflows as w, readWorkflowPackageVersion as x, terminalSocketPath as y };
11328
10942
 
11329
- //# sourceMappingURL=RecoverWorkflowService-DZZmRtBJ.mjs.map
10943
+ //# sourceMappingURL=RecoverWorkflowService-CY8wIc3A.mjs.map