@agimon-ai/po-workflow 0.0.0-alpha.37 → 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.
- package/dist/{RecoverWorkflowService-BLehH1qi.cjs → RecoverWorkflowService-CEYR10KF.cjs} +136 -445
- package/dist/RecoverWorkflowService-CEYR10KF.cjs.map +1 -0
- package/dist/{RecoverWorkflowService-BOCa93OS.mjs → RecoverWorkflowService-CY8wIc3A.mjs} +137 -434
- package/dist/RecoverWorkflowService-CY8wIc3A.mjs.map +1 -0
- package/dist/cli.cjs +94 -1592
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +95 -1593
- package/dist/cli.mjs.map +1 -1
- package/dist/extensions/native.mjs +2 -0
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +40 -25
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +40 -25
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +5 -3
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{workflowLaunchCommand-GGqimmTC.mjs → workflowLaunchCommand-7WRoiOKJ.mjs} +5 -3
- package/dist/workflowLaunchCommand-7WRoiOKJ.mjs.map +1 -0
- package/dist/{workflowLaunchCommand-C69Nn3k5.cjs → workflowLaunchCommand-C7anFsDH.cjs} +5 -3
- package/dist/workflowLaunchCommand-C7anFsDH.cjs.map +1 -0
- package/package.json +20 -20
- package/dist/RecoverWorkflowService-BLehH1qi.cjs.map +0 -1
- package/dist/RecoverWorkflowService-BOCa93OS.mjs.map +0 -1
- package/dist/workflowLaunchCommand-C69Nn3k5.cjs.map +0 -1
- package/dist/workflowLaunchCommand-GGqimmTC.mjs.map +0 -1
|
@@ -375,6 +375,7 @@ const StepFieldsSchema = z.object({
|
|
|
375
375
|
artifacts: StepArtifactsSchema.optional(),
|
|
376
376
|
"timeout-minutes": z.number().optional(),
|
|
377
377
|
env: CoercedEnvRecord.optional(),
|
|
378
|
+
secrets: z.array(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/, "Secret names are environment variable names.")).min(1).optional().describe("Env names a run step's command receives from its Po profile; values never reach logs or run records."),
|
|
378
379
|
with: z.record(z.string(), z.string()).optional(),
|
|
379
380
|
"working-directory": z.string().optional(),
|
|
380
381
|
if: z.string().optional(),
|
|
@@ -415,6 +416,11 @@ function refineStep(step, context) {
|
|
|
415
416
|
message: `${key} is only supported with a templated interactiveRun.`,
|
|
416
417
|
path: [key]
|
|
417
418
|
});
|
|
419
|
+
if (step.secrets !== void 0 && (step.run === void 0 || step.interactiveRun || step.customRun)) context.addIssue({
|
|
420
|
+
code: "custom",
|
|
421
|
+
message: "secrets are only supported on run steps.",
|
|
422
|
+
path: ["secrets"]
|
|
423
|
+
});
|
|
418
424
|
if (step["restart-from"] !== void 0 && (step.run === void 0 || step.interactiveRun || step.customRun)) context.addIssue({
|
|
419
425
|
code: "custom",
|
|
420
426
|
message: "restart-from is only supported on run steps.",
|
|
@@ -747,6 +753,7 @@ const WorkflowLauncherMetadataSchema = z.discriminatedUnion("type", [
|
|
|
747
753
|
]);
|
|
748
754
|
const WorkflowRunRecordSchema = z.object({
|
|
749
755
|
activeRepairId: z.string().regex(/^\d+$/).optional(),
|
|
756
|
+
/** Read-only legacy metadata. New runs only write runner. */
|
|
750
757
|
cliAgent: z.string().optional(),
|
|
751
758
|
continueOnError: z.boolean().optional(),
|
|
752
759
|
displayName: z.string(),
|
|
@@ -770,6 +777,7 @@ const WorkflowRunRecordSchema = z.object({
|
|
|
770
777
|
runner: z.string().optional(),
|
|
771
778
|
command: z.string().optional().describe("Command the launch selected for templated interactiveRun steps."),
|
|
772
779
|
choice: z.string().optional().describe("Choice the launch selected for steps that do not pin one."),
|
|
780
|
+
profile: z.string().optional().describe("Po profile name the launch selected as the default runConfig.profile; never its secrets."),
|
|
773
781
|
runId: z.string().uuid().optional(),
|
|
774
782
|
runKey: z.string(),
|
|
775
783
|
secretFile: z.string().optional(),
|
|
@@ -4717,7 +4725,6 @@ var WorkflowRegistryService = class {
|
|
|
4717
4725
|
const runId = randomUUID();
|
|
4718
4726
|
const runRecord = {
|
|
4719
4727
|
activeRepairId: input.activeRepairId,
|
|
4720
|
-
cliAgent: input.cliAgent,
|
|
4721
4728
|
continueOnError: input.continueOnError,
|
|
4722
4729
|
displayName: input.displayName,
|
|
4723
4730
|
dryRun: input.dryRun,
|
|
@@ -4731,6 +4738,7 @@ var WorkflowRegistryService = class {
|
|
|
4731
4738
|
runner: input.runner,
|
|
4732
4739
|
...input.command === void 0 ? {} : { command: input.command },
|
|
4733
4740
|
...input.choice === void 0 ? {} : { choice: input.choice },
|
|
4741
|
+
...input.profile === void 0 ? {} : { profile: input.profile },
|
|
4734
4742
|
runDirectory: input.runDirectory,
|
|
4735
4743
|
runId,
|
|
4736
4744
|
secretFile: input.secretFile,
|
|
@@ -6397,127 +6405,6 @@ const MAX_STEP_TIMEOUT_MINUTES = Math.floor(2147483647 / 6e4);
|
|
|
6397
6405
|
const StepTimeoutMinutesSchema = z.number().positive().finite().max(MAX_STEP_TIMEOUT_MINUTES);
|
|
6398
6406
|
const StepTimeoutRetriesSchema = z.number().int().min(0).max(STEP_TIMEOUT_RETRIES_LIMIT).default(STEP_TIMEOUT_MAX_RETRIES);
|
|
6399
6407
|
//#endregion
|
|
6400
|
-
//#region src/services/CodexQuotaService/index.ts
|
|
6401
|
-
/**
|
|
6402
|
-
* CodexQuotaService
|
|
6403
|
-
*
|
|
6404
|
-
* DESIGN PATTERNS:
|
|
6405
|
-
* - Service pattern for business logic encapsulation
|
|
6406
|
-
* - Single responsibility principle
|
|
6407
|
-
*
|
|
6408
|
-
* CODING STANDARDS:
|
|
6409
|
-
* - Use async/await for asynchronous operations
|
|
6410
|
-
* - Throw descriptive errors for error cases
|
|
6411
|
-
* - Keep methods focused and well-named
|
|
6412
|
-
* - Document complex logic with comments
|
|
6413
|
-
*
|
|
6414
|
-
* AVOID:
|
|
6415
|
-
* - Mixing concerns (keep focused on single domain)
|
|
6416
|
-
* - Direct tool implementation (services should be tool-agnostic)
|
|
6417
|
-
*/
|
|
6418
|
-
const DEFAULT_CODEX_HOME_DIRNAME = ".codex";
|
|
6419
|
-
const AUTH_FILENAME = "auth.json";
|
|
6420
|
-
const CONFIG_FILENAME = "config.toml";
|
|
6421
|
-
const DEFAULT_CHATGPT_BASE_URL = "https://chatgpt.com/backend-api/";
|
|
6422
|
-
const CHATGPT_HOST = "https://chatgpt.com";
|
|
6423
|
-
const CHAT_OPENAI_HOST = "https://chat.openai.com";
|
|
6424
|
-
const BACKEND_API_SEGMENT = "/backend-api";
|
|
6425
|
-
const QUOTA_USER_AGENT = "codex-cli";
|
|
6426
|
-
const PRIMARY_WINDOW = "primary";
|
|
6427
|
-
const SECONDARY_WINDOW = "secondary";
|
|
6428
|
-
const QUOTA_REACHED_PERCENT = 100;
|
|
6429
|
-
var CodexQuotaService = class {
|
|
6430
|
-
codexHome;
|
|
6431
|
-
fetchFn;
|
|
6432
|
-
now;
|
|
6433
|
-
readTextFile;
|
|
6434
|
-
constructor(runtime, deps = {}) {
|
|
6435
|
-
this.codexHome = deps.codexHome ?? runtime.baseEnvironment.CODEX_HOME ?? join(runtime.homeDirectory, DEFAULT_CODEX_HOME_DIRNAME);
|
|
6436
|
-
this.fetchFn = deps.fetchFn ?? fetch;
|
|
6437
|
-
this.now = deps.now ?? (() => Date.now());
|
|
6438
|
-
this.readTextFile = deps.readTextFile ?? (async (path) => getOrThrow(await runtime.fs.readTextFile(path, runtime.ioContext)));
|
|
6439
|
-
}
|
|
6440
|
-
isCodexCommand(command, _sourceAgentKey) {
|
|
6441
|
-
const trimmed = command.trim();
|
|
6442
|
-
return trimmed === "codex" || trimmed.startsWith("codex ");
|
|
6443
|
-
}
|
|
6444
|
-
async getQuotaStatus() {
|
|
6445
|
-
const auth = await this.readAuthFile();
|
|
6446
|
-
const accessToken = auth?.tokens?.access_token?.trim();
|
|
6447
|
-
const accountId = auth?.tokens?.account_id?.trim();
|
|
6448
|
-
if (!accessToken || !accountId) return null;
|
|
6449
|
-
const baseUrl = await this.readChatgptBaseUrl();
|
|
6450
|
-
const response = await this.fetchFn(this.buildUsageUrl(baseUrl), { headers: {
|
|
6451
|
-
Authorization: `Bearer ${accessToken}`,
|
|
6452
|
-
"ChatGPT-Account-Id": accountId,
|
|
6453
|
-
"User-Agent": QUOTA_USER_AGENT
|
|
6454
|
-
} });
|
|
6455
|
-
if (!response.ok) throw new Error(`codex quota request failed with HTTP ${response.status}`);
|
|
6456
|
-
const payload = await response.json();
|
|
6457
|
-
return {
|
|
6458
|
-
blockingLimit: this.findBlockingLimit(payload),
|
|
6459
|
-
planType: payload.plan_type ?? null
|
|
6460
|
-
};
|
|
6461
|
-
}
|
|
6462
|
-
async readAuthFile() {
|
|
6463
|
-
const raw = await this.readOptionalTextFile(join(this.codexHome, AUTH_FILENAME));
|
|
6464
|
-
if (!raw) return null;
|
|
6465
|
-
return JSON.parse(raw);
|
|
6466
|
-
}
|
|
6467
|
-
async readChatgptBaseUrl() {
|
|
6468
|
-
const match = (await this.readOptionalTextFile(join(this.codexHome, CONFIG_FILENAME)))?.match(/^\s*chatgpt_base_url\s*=\s*"([^"]+)"/m);
|
|
6469
|
-
return this.normalizeBaseUrl(match?.[1] ?? DEFAULT_CHATGPT_BASE_URL);
|
|
6470
|
-
}
|
|
6471
|
-
buildUsageUrl(baseUrl) {
|
|
6472
|
-
return baseUrl.includes(BACKEND_API_SEGMENT) ? `${baseUrl}/wham/usage` : `${baseUrl}/api/codex/usage`;
|
|
6473
|
-
}
|
|
6474
|
-
normalizeBaseUrl(baseUrl) {
|
|
6475
|
-
let normalized = baseUrl.trim().replace(/\/+$/, "");
|
|
6476
|
-
if ((normalized.startsWith(CHATGPT_HOST) || normalized.startsWith(CHAT_OPENAI_HOST)) && !normalized.includes(BACKEND_API_SEGMENT)) normalized = `${normalized}${BACKEND_API_SEGMENT}`;
|
|
6477
|
-
return normalized;
|
|
6478
|
-
}
|
|
6479
|
-
async readOptionalTextFile(path) {
|
|
6480
|
-
try {
|
|
6481
|
-
return await this.readTextFile(path);
|
|
6482
|
-
} catch (error) {
|
|
6483
|
-
if (error.code === "ENOENT") return null;
|
|
6484
|
-
throw error;
|
|
6485
|
-
}
|
|
6486
|
-
}
|
|
6487
|
-
findBlockingLimit(payload) {
|
|
6488
|
-
const blocks = [];
|
|
6489
|
-
this.collectBlockingLimit(blocks, "codex", "codex", payload.rate_limit);
|
|
6490
|
-
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);
|
|
6491
|
-
blocks.sort((left, right) => left.resetAt - right.resetAt || right.usedPercent - left.usedPercent);
|
|
6492
|
-
return blocks[0] ?? null;
|
|
6493
|
-
}
|
|
6494
|
-
collectBlockingLimit(blocks, limitId, limitName, limit) {
|
|
6495
|
-
if (!limit) return;
|
|
6496
|
-
const windows = [{
|
|
6497
|
-
payload: limit.primary_window,
|
|
6498
|
-
window: PRIMARY_WINDOW
|
|
6499
|
-
}, {
|
|
6500
|
-
payload: limit.secondary_window,
|
|
6501
|
-
window: SECONDARY_WINDOW
|
|
6502
|
-
}];
|
|
6503
|
-
for (const { payload, window } of windows) {
|
|
6504
|
-
const resetAt = payload?.reset_at;
|
|
6505
|
-
const usedPercent = payload?.used_percent ?? 0;
|
|
6506
|
-
if (typeof resetAt !== "number") continue;
|
|
6507
|
-
if (!(usedPercent >= QUOTA_REACHED_PERCENT || limit.limit_reached === true && resetAt * 1e3 > this.now() || limit.allowed === false && resetAt * 1e3 > this.now())) continue;
|
|
6508
|
-
blocks.push({
|
|
6509
|
-
limitId,
|
|
6510
|
-
limitName,
|
|
6511
|
-
resetAfterSeconds: payload?.reset_after_seconds ?? null,
|
|
6512
|
-
resetAt,
|
|
6513
|
-
usedPercent,
|
|
6514
|
-
window,
|
|
6515
|
-
windowSeconds: payload?.limit_window_seconds ?? null
|
|
6516
|
-
});
|
|
6517
|
-
}
|
|
6518
|
-
}
|
|
6519
|
-
};
|
|
6520
|
-
//#endregion
|
|
6521
6408
|
//#region src/services/StepRunnerService/index.ts
|
|
6522
6409
|
/**
|
|
6523
6410
|
* StepRunnerService
|
|
@@ -6592,6 +6479,10 @@ const INTERACTIVE_RUN_KEY = "interactiveRun";
|
|
|
6592
6479
|
const CUSTOM_RUN_KEY = "customRun";
|
|
6593
6480
|
const CUSTOM_RUN_UNSUPPORTED_MESSAGE = "customRun needs a host step executor and no run or interactiveRun fallback exists for step";
|
|
6594
6481
|
const IN_PROCESS_ONLY_UNSUPPORTED_MESSAGE = "has no run template, and this host cannot run it in-process";
|
|
6482
|
+
const SECRETS_UNAVAILABLE_MESSAGE = "profile secrets are unavailable for step";
|
|
6483
|
+
const SECRETS_LOG_PREFIX = "secrets: ";
|
|
6484
|
+
const RUN_CONFIG_PROFILE_KEY = "profile";
|
|
6485
|
+
const REDACTED = "[redacted]";
|
|
6595
6486
|
const WORKFLOW_RUN_CONFIG_ENV_KEY = "WORKFLOW_RUN_CONFIG";
|
|
6596
6487
|
const DEFAULT_CHOICE = "default";
|
|
6597
6488
|
const OUTPUT_TAIL_LINES = 50;
|
|
@@ -6676,38 +6567,35 @@ const WORKFLOW_STEP_NAME_ENV_KEY = "WORKFLOW_STEP_NAME";
|
|
|
6676
6567
|
const WORKFLOW_STEP_DISPLAY_ENV_KEY = "WORKFLOW_STEP_DISPLAY";
|
|
6677
6568
|
const WORKFLOW_STEP_ARTIFACTS_ENV_KEY = "WORKFLOW_STEP_ARTIFACTS";
|
|
6678
6569
|
const WORKFLOW_TERMINAL_TITLE = "workflow-mcp";
|
|
6679
|
-
const STATUS_FILE_PREFIX = "workflow-step-";
|
|
6680
|
-
const STATUS_FILE_SUFFIX = ".status";
|
|
6681
|
-
const STATUS_FILE_COMPLETION_VALUE = "YES";
|
|
6682
|
-
const STATUS_FILE_COMPLETED_RESULT = { status: "status_completed" };
|
|
6683
|
-
const TRANSIENT_FS_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
6684
|
-
"ENOENT",
|
|
6685
|
-
"EBUSY",
|
|
6686
|
-
"EAGAIN",
|
|
6687
|
-
"EPERM",
|
|
6688
|
-
"not_found"
|
|
6689
|
-
]);
|
|
6690
|
-
const STATUS_FILE_POLL_INTERVAL_MS = 1e3;
|
|
6691
6570
|
const STOP_REQUEST_POLL_INTERVAL_MS = 1e3;
|
|
6692
|
-
const STATUS_DONE = "done";
|
|
6693
6571
|
const STATUS_STOP = "stop";
|
|
6694
6572
|
const EXPLICIT_RUNNER_MISSING_PREFIX = "runner";
|
|
6695
6573
|
const EXPLICIT_RUNNER_MISSING_MIDDLE = "not found for step";
|
|
6696
6574
|
const EXPLICIT_RUNNER_AVAILABLE_PREFIX = "available runner keys:";
|
|
6697
|
-
const QUOTA_WAIT_POLL_INTERVAL_MS = 3e4;
|
|
6698
|
-
const QUOTA_WAIT_RESET_BUFFER_MS = 1e3;
|
|
6699
|
-
const QUOTA_WAIT_SOURCE = "StepRunnerService.waitForCodexQuota";
|
|
6700
|
-
const QUOTA_RETRY_REASON = "codex quota reached after failed step, retrying after reset";
|
|
6701
6575
|
const RESULT_STATUS_COMPLETED = "completed";
|
|
6702
6576
|
const RESULT_STATUS_SPAWN_ERROR = "spawn_error";
|
|
6703
6577
|
const RESULT_STATUS_SIGNALED = "signaled";
|
|
6704
6578
|
const RESULT_STATUS_TIMED_OUT = "timed_out";
|
|
6705
|
-
const RESULT_STATUS_STATUS_COMPLETED = "status_completed";
|
|
6706
6579
|
const RESULT_STATUS_STOP_REQUESTED = "stop_requested";
|
|
6707
6580
|
const RESULT_STATUS_PAUSE_REQUESTED = "pause_requested";
|
|
6708
6581
|
/** The reason a step failure carries when nothing more specific was recorded. */
|
|
6709
6582
|
const STEP_FAILED_REASON = "The step failed.";
|
|
6710
6583
|
/**
|
|
6584
|
+
* Mask each secret value in step output, in its raw, JSON-escaped and
|
|
6585
|
+
* URL-encoded forms, and line by line for a value that spans lines.
|
|
6586
|
+
*/
|
|
6587
|
+
function secretRedactor(values) {
|
|
6588
|
+
const forms = /* @__PURE__ */ new Set();
|
|
6589
|
+
for (const value of values) for (const form of [
|
|
6590
|
+
value,
|
|
6591
|
+
JSON.stringify(value).slice(1, -1),
|
|
6592
|
+
encodeURIComponent(value),
|
|
6593
|
+
...value.split("\n")
|
|
6594
|
+
]) if (form) forms.add(form);
|
|
6595
|
+
const longestFirst = [...forms].sort((left, right) => right.length - left.length);
|
|
6596
|
+
return (text) => longestFirst.reduce((current, form) => current.split(form).join(REDACTED), text);
|
|
6597
|
+
}
|
|
6598
|
+
/**
|
|
6711
6599
|
* Executes workflow steps in child processes and tracks the active process so
|
|
6712
6600
|
* the workflow runner can interrupt it safely.
|
|
6713
6601
|
*
|
|
@@ -6720,16 +6608,15 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6720
6608
|
runtime;
|
|
6721
6609
|
parser;
|
|
6722
6610
|
logger;
|
|
6723
|
-
|
|
6724
|
-
watchStatusFile;
|
|
6611
|
+
watchControlFile;
|
|
6725
6612
|
runDirectoryService;
|
|
6726
6613
|
ownsTerminal;
|
|
6727
6614
|
stepExecutor;
|
|
6615
|
+
resolveSecrets;
|
|
6728
6616
|
activeStep = null;
|
|
6729
6617
|
activeExternal = null;
|
|
6730
6618
|
lastInteractiveReap = null;
|
|
6731
6619
|
interruptedSignal = null;
|
|
6732
|
-
activeQuotaWait = null;
|
|
6733
6620
|
commandSelection = {};
|
|
6734
6621
|
/** Runners of a parallel group's steps, which a stop must reach too. */
|
|
6735
6622
|
forks = /* @__PURE__ */ new Set();
|
|
@@ -6744,15 +6631,15 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6744
6631
|
* must not hand a step's stdin to it, and must not `stty` or reset it
|
|
6745
6632
|
* afterwards, however cooperative the intent.
|
|
6746
6633
|
*/
|
|
6747
|
-
constructor(runtime, parser, logger,
|
|
6634
|
+
constructor(runtime, parser, logger, watchControlFile = runtime.fs.watch.bind(runtime.fs), runDirectoryService = new RunDirectoryService(runtime), ownsTerminal = true, stepExecutor, resolveSecrets) {
|
|
6748
6635
|
this.runtime = runtime;
|
|
6749
6636
|
this.parser = parser;
|
|
6750
6637
|
this.logger = logger;
|
|
6751
|
-
this.
|
|
6752
|
-
this.watchStatusFile = watchStatusFile;
|
|
6638
|
+
this.watchControlFile = watchControlFile;
|
|
6753
6639
|
this.runDirectoryService = runDirectoryService;
|
|
6754
6640
|
this.ownsTerminal = ownsTerminal;
|
|
6755
6641
|
this.stepExecutor = stepExecutor;
|
|
6642
|
+
this.resolveSecrets = resolveSecrets;
|
|
6756
6643
|
}
|
|
6757
6644
|
/**
|
|
6758
6645
|
* Use a workflow's command templates and choices, and what the launch
|
|
@@ -6769,7 +6656,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6769
6656
|
* Release it once its step has finished.
|
|
6770
6657
|
*/
|
|
6771
6658
|
fork(label) {
|
|
6772
|
-
const child = new StepRunnerService(this.runtime, this.parser, labelledLogger(this.logger, label), this.
|
|
6659
|
+
const child = new StepRunnerService(this.runtime, this.parser, labelledLogger(this.logger, label), this.watchControlFile, this.runDirectoryService, this.ownsTerminal, this.stepExecutor, this.resolveSecrets);
|
|
6773
6660
|
child.commandSelection = this.commandSelection;
|
|
6774
6661
|
child.interruptedSignal = this.interruptedSignal;
|
|
6775
6662
|
child.terminalLock = this.terminalLock;
|
|
@@ -6794,16 +6681,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6794
6681
|
for (const child of this.forks) child.stopActiveStep(signal);
|
|
6795
6682
|
return;
|
|
6796
6683
|
}
|
|
6797
|
-
if (this.activeQuotaWait) {
|
|
6798
|
-
if (this.activeQuotaWait.controller.signal.aborted) {
|
|
6799
|
-
this.logger.info(` ${DIM$3}${STATUS_SKIP}${RESET$3} ${this.activeQuotaWait.stepName} ${ALREADY_STOPPING_SUFFIX}`);
|
|
6800
|
-
return;
|
|
6801
|
-
}
|
|
6802
|
-
this.activeQuotaWait.signal = signal;
|
|
6803
|
-
this.activeQuotaWait.controller.abort();
|
|
6804
|
-
this.logger.info(` ${YELLOW$2}${STATUS_INTERRUPTED}${RESET$3} cancelling quota wait for ${this.activeQuotaWait.stepName}`);
|
|
6805
|
-
return;
|
|
6806
|
-
}
|
|
6807
6684
|
if (this.activeExternal) {
|
|
6808
6685
|
if (this.activeExternal.stopSignal) {
|
|
6809
6686
|
this.logger.info(` ${DIM$3}${STATUS_SKIP}${RESET$3} ${this.activeExternal.stepName} ${ALREADY_STOPPING_SUFFIX}`);
|
|
@@ -6902,7 +6779,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6902
6779
|
return false;
|
|
6903
6780
|
}
|
|
6904
6781
|
const { command, custom, inProcessOnly, interactive, template } = resolvedStepCommand;
|
|
6905
|
-
const isCodexCommand = this.quotaService.isCodexCommand(command, resolvedStepCommand.agentKey);
|
|
6906
6782
|
const shouldContinue = step["continue-on-error"] || options.continueOnError;
|
|
6907
6783
|
let timeoutMs;
|
|
6908
6784
|
try {
|
|
@@ -6936,7 +6812,12 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6936
6812
|
stepEnv[PROJECT_PATH_ENV_KEY] = workDir;
|
|
6937
6813
|
stepEnv[WORKFLOW_STEP_NAME_ENV_KEY] = stepName;
|
|
6938
6814
|
stepEnv[WORKFLOW_STEP_DISPLAY_ENV_KEY] = this.formatStepDisplay(stepEnv[WORKFLOW_JOB_NAME_ENV_KEY], stepName);
|
|
6939
|
-
const
|
|
6815
|
+
const stepRunConfig = resolvedStepCommand?.runConfig ?? step.runConfig;
|
|
6816
|
+
const launchProfile = this.commandSelection.profile;
|
|
6817
|
+
const runConfig = launchProfile === void 0 || stepRunConfig?.[RUN_CONFIG_PROFILE_KEY] !== void 0 ? stepRunConfig : {
|
|
6818
|
+
...stepRunConfig,
|
|
6819
|
+
[RUN_CONFIG_PROFILE_KEY]: launchProfile
|
|
6820
|
+
};
|
|
6940
6821
|
stepEnv[WORKFLOW_RUN_CONFIG_ENV_KEY] = JSON.stringify(runConfig ?? {});
|
|
6941
6822
|
if (step.if !== void 0 && !options.dryRun) {
|
|
6942
6823
|
const condition = await this.evaluateStepCondition(step.if, stepContext, workDir, stepEnv, stepName, timeoutMs);
|
|
@@ -6987,15 +6868,11 @@ var StepRunnerService = class StepRunnerService {
|
|
|
6987
6868
|
}
|
|
6988
6869
|
const stepStartedAt = Date.now();
|
|
6989
6870
|
await this.logStepLifecycle("info", "workflow.step.started", stepEnv, { "workflow.step.interactive": interactive });
|
|
6990
|
-
|
|
6991
|
-
if (interactive) {
|
|
6992
|
-
statusFilePath = await this.createStatusFile();
|
|
6993
|
-
stepEnv[STATUS_FILE_ENV_KEY] = statusFilePath;
|
|
6994
|
-
this.logger.info(` ${DIM$3}status-file${RESET$3} ${statusFilePath}`);
|
|
6995
|
-
} else delete stepEnv[STATUS_FILE_ENV_KEY];
|
|
6871
|
+
delete stepEnv[STATUS_FILE_ENV_KEY];
|
|
6996
6872
|
if (options.dryRun) {
|
|
6997
6873
|
this.logger.info(` ${CYAN$2}${STATUS_DRY}${RESET$3} ${stepName}`);
|
|
6998
6874
|
this.logger.info(`${COMMAND_LOG_INDENT}${DIM$3}${COMMAND_LOG_PROMPT}${command.split(COMMAND_LINE_BREAK).join(COMMAND_LOG_CONTINUATION)}${RESET$3}`);
|
|
6875
|
+
if (step.secrets !== void 0 && step.secrets.length > 0) this.logger.info(`${COMMAND_LOG_INDENT}${DIM$3}${SECRETS_LOG_PREFIX}${step.secrets.join(", ")}${RESET$3}`);
|
|
6999
6876
|
await this.logStepLifecycle("info", "workflow.step.finished", stepEnv, {
|
|
7000
6877
|
"workflow.step.duration_ms": Date.now() - stepStartedAt,
|
|
7001
6878
|
"workflow.step.outcome": "dry-run"
|
|
@@ -7027,9 +6904,20 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7027
6904
|
this.logger.error(` ${RED$2}${STATUS_FAIL}${RESET$3} ${stepName}\n`);
|
|
7028
6905
|
return false;
|
|
7029
6906
|
}
|
|
7030
|
-
let
|
|
6907
|
+
let secretEnv;
|
|
6908
|
+
if (step.secrets !== void 0 && step.secrets.length > 0) {
|
|
6909
|
+
secretEnv = await this.resolveStepSecrets(step.secrets, runConfig, interactive || custom !== void 0 || inProcessOnly === true);
|
|
6910
|
+
if (secretEnv === void 0) {
|
|
6911
|
+
fail(`${SECRETS_UNAVAILABLE_MESSAGE} "${stepName}"`);
|
|
6912
|
+
if (shouldContinue) {
|
|
6913
|
+
this.logger.warn(` ${YELLOW$2}${STATUS_FAIL}${RESET$3} ${stepName} ${CONTINUE_ON_ERROR_SUFFIX}\n`);
|
|
6914
|
+
return true;
|
|
6915
|
+
}
|
|
6916
|
+
this.logger.error(` ${RED$2}${STATUS_FAIL}${RESET$3} ${stepName}\n`);
|
|
6917
|
+
return false;
|
|
6918
|
+
}
|
|
6919
|
+
}
|
|
7031
6920
|
for (let attempt = 0; attempt <= maxTimeoutRetries; attempt++) {
|
|
7032
|
-
await this.waitForCodexQuotaAvailability(stepName, command, isCodexCommand);
|
|
7033
6921
|
if (decisionFilePath && decisionIdentity) await resetDecisionFile(this.runtime, decisionFilePath, decisionIdentity);
|
|
7034
6922
|
if (attempt > 0) this.logger.warn(` ${YELLOW$2}${STATUS_RETRY}${RESET$3} ${STEP_TIMEOUT_RETRY_PREFIX} "${stepName}" (attempt ${attempt + 1}/${maxTimeoutRetries + 1})`);
|
|
7035
6923
|
else this.logger.info(` ${CYAN$2}${STATUS_RUN}${RESET$3} ${stepName}`);
|
|
@@ -7054,6 +6942,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7054
6942
|
interactive,
|
|
7055
6943
|
onExecutionStarted: options.onExecutionStarted,
|
|
7056
6944
|
runConfig,
|
|
6945
|
+
secretEnv,
|
|
7057
6946
|
stepEnv,
|
|
7058
6947
|
stepName,
|
|
7059
6948
|
jobEnvironment: this.definedEnv({
|
|
@@ -7065,7 +6954,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7065
6954
|
timeoutMs,
|
|
7066
6955
|
workDir
|
|
7067
6956
|
}));
|
|
7068
|
-
const executionResult = interactive
|
|
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;
|
|
7069
6958
|
if (executionResult.status === RESULT_STATUS_PAUSE_REQUESTED) {
|
|
7070
6959
|
await this.logStepLifecycle("info", "workflow.step.pause_requested", stepEnv, {
|
|
7071
6960
|
"workflow.step.outcome": pausePolicy === "replay" ? "cancelled_for_pause" : "protected_boundary",
|
|
@@ -7122,7 +7011,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7122
7011
|
}
|
|
7123
7012
|
const decision = decisionFilePath ? await readStepDecision(this.runtime, decisionFilePath) : void 0;
|
|
7124
7013
|
if (decision) {
|
|
7125
|
-
if (statusFilePath) await this.cleanupStatusFile(statusFilePath);
|
|
7126
7014
|
if (decision.decision === "complete") {
|
|
7127
7015
|
const artifactProblem = artifactSnapshots ? await this.describeArtifactWarnings(stepEnv, artifactSnapshots) : void 0;
|
|
7128
7016
|
if (!artifactProblem) {
|
|
@@ -7156,15 +7044,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7156
7044
|
}
|
|
7157
7045
|
if (executionResult.status === "timed_out") {
|
|
7158
7046
|
fail(`${STEP_TIMEOUT_FAILURE_PREFIX} ${this.formatTimeoutMs(executionResult.timeoutMs)} "${stepName}" (${command.split(COMMAND_LINE_BREAK)[0]})`);
|
|
7159
|
-
if (attempt < maxTimeoutRetries)
|
|
7160
|
-
if (statusFilePath) try {
|
|
7161
|
-
getOrThrow(await this.runtime.fs.writeFile(statusFilePath, "", this.runtime.ioContext));
|
|
7162
|
-
} catch (error) {
|
|
7163
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file reset failed for ${stepName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
7164
|
-
}
|
|
7165
|
-
continue;
|
|
7166
|
-
}
|
|
7167
|
-
if (statusFilePath) await this.cleanupStatusFile(statusFilePath);
|
|
7047
|
+
if (attempt < maxTimeoutRetries) continue;
|
|
7168
7048
|
if (shouldContinue) {
|
|
7169
7049
|
await this.logStepLifecycle("warn", "workflow.step.finished", stepEnv, {
|
|
7170
7050
|
"workflow.step.duration_ms": Date.now() - stepStartedAt,
|
|
@@ -7181,7 +7061,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7181
7061
|
});
|
|
7182
7062
|
return false;
|
|
7183
7063
|
}
|
|
7184
|
-
if (statusFilePath) await this.cleanupStatusFile(statusFilePath);
|
|
7185
7064
|
if (decisionIdentity?.required && !(executionResult.status === "completed" && executionResult.failure !== void 0)) {
|
|
7186
7065
|
fail(`step "${stepName}" ended without a workflow decision (workflow-mcp step complete|fix|fail)`);
|
|
7187
7066
|
return this.failStep(stepName, stepEnv, stepStartedAt, shouldContinue, report);
|
|
@@ -7204,19 +7083,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7204
7083
|
});
|
|
7205
7084
|
return true;
|
|
7206
7085
|
}
|
|
7207
|
-
if (executionResult.status === "status_completed") {
|
|
7208
|
-
const artifactProblem = artifactSnapshots ? await this.describeArtifactWarnings(stepEnv, artifactSnapshots) : void 0;
|
|
7209
|
-
if (artifactProblem) {
|
|
7210
|
-
fail(`step "${stepName}" ${artifactProblem}`);
|
|
7211
|
-
return this.failStep(stepName, stepEnv, stepStartedAt, shouldContinue, report);
|
|
7212
|
-
}
|
|
7213
|
-
this.logger.info(`\n ${GREEN$2}${STATUS_DONE}${RESET$3} ${stepName} (status-file signaled completion)\n`);
|
|
7214
|
-
await this.logStepLifecycle("info", "workflow.step.finished", stepEnv, {
|
|
7215
|
-
"workflow.step.duration_ms": Date.now() - stepStartedAt,
|
|
7216
|
-
"workflow.step.outcome": "success"
|
|
7217
|
-
});
|
|
7218
|
-
return true;
|
|
7219
|
-
}
|
|
7220
7086
|
if (executionResult.status === "completed" && executionResult.exitCode === 0) {
|
|
7221
7087
|
const artifactProblem = artifactSnapshots ? await this.describeArtifactWarnings(stepEnv, artifactSnapshots) : void 0;
|
|
7222
7088
|
if (!artifactProblem) {
|
|
@@ -7230,12 +7096,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7230
7096
|
fail(`step "${stepName}" ${artifactProblem}`);
|
|
7231
7097
|
}
|
|
7232
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]})`);
|
|
7233
|
-
if (!quotaFailureRetried && await this.shouldRetryForCodexQuota(stepName, isCodexCommand)) {
|
|
7234
|
-
quotaFailureRetried = true;
|
|
7235
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_RETRY}${RESET$3} ${QUOTA_RETRY_REASON}`);
|
|
7236
|
-
attempt -= 1;
|
|
7237
|
-
continue;
|
|
7238
|
-
}
|
|
7239
7099
|
if (shouldContinue) {
|
|
7240
7100
|
await this.logStepLifecycle("warn", "workflow.step.finished", stepEnv, {
|
|
7241
7101
|
"workflow.step.duration_ms": Date.now() - stepStartedAt,
|
|
@@ -7314,10 +7174,30 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7314
7174
|
};
|
|
7315
7175
|
}
|
|
7316
7176
|
/**
|
|
7177
|
+
* Resolve a run step's secrets for its child alone, or undefined when they
|
|
7178
|
+
* cannot be: this host has no resolver, the step is not a plain run, no
|
|
7179
|
+
* profile applies, or the resolver fails. The failure stays generic so no
|
|
7180
|
+
* value or alias detail reaches the log.
|
|
7181
|
+
*/
|
|
7182
|
+
async resolveStepSecrets(names, runConfig, hostedStep) {
|
|
7183
|
+
const profile = runConfig?.[RUN_CONFIG_PROFILE_KEY];
|
|
7184
|
+
if (this.resolveSecrets === void 0 || hostedStep || typeof profile !== "string" || profile === "") return;
|
|
7185
|
+
try {
|
|
7186
|
+
return await this.resolveSecrets({
|
|
7187
|
+
cwd: this.runtime.cwd,
|
|
7188
|
+
profile,
|
|
7189
|
+
names
|
|
7190
|
+
});
|
|
7191
|
+
} catch {
|
|
7192
|
+
return;
|
|
7193
|
+
}
|
|
7194
|
+
}
|
|
7195
|
+
/**
|
|
7317
7196
|
* Spawn a child shell for the step command and normalize its termination
|
|
7318
7197
|
* into a typed result.
|
|
7319
7198
|
*/
|
|
7320
|
-
async executeCommand(command, workDir, stepEnv, stepName, interactive, timeoutMs) {
|
|
7199
|
+
async executeCommand(command, workDir, stepEnv, stepName, interactive, timeoutMs, secretEnv) {
|
|
7200
|
+
const redact = secretEnv === void 0 ? void 0 : secretRedactor(Object.values(secretEnv));
|
|
7321
7201
|
if (interactive) this.logger.info(` ${DIM$3}${INTERACTIVE_OUTPUT_NOTICE}${RESET$3}`);
|
|
7322
7202
|
return await new Promise((resolveResult) => {
|
|
7323
7203
|
const terminalState = interactive ? this.captureTerminalState() : null;
|
|
@@ -7344,6 +7224,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7344
7224
|
detached: this.runtime.workflowHost.platform !== PLATFORM_WINDOWS,
|
|
7345
7225
|
env: {
|
|
7346
7226
|
...stepEnv,
|
|
7227
|
+
...secretEnv,
|
|
7347
7228
|
[FORCE_COLOR_KEY]: FORCE_COLOR_VALUE
|
|
7348
7229
|
},
|
|
7349
7230
|
shell: DEFAULT_SHELL
|
|
@@ -7411,18 +7292,30 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7411
7292
|
outputTail.push(line);
|
|
7412
7293
|
if (outputTail.length > OUTPUT_TAIL_LINES) outputTail.shift();
|
|
7413
7294
|
};
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7295
|
+
const lineReader = (emit) => {
|
|
7296
|
+
let pending = "";
|
|
7297
|
+
const show = (line) => {
|
|
7298
|
+
if (!line) return;
|
|
7299
|
+
const shown = redact === void 0 ? line : redact(line);
|
|
7300
|
+
keep(shown);
|
|
7301
|
+
emit(shown);
|
|
7302
|
+
};
|
|
7303
|
+
return {
|
|
7304
|
+
push: (data) => {
|
|
7305
|
+
const lines = (pending + data.toString()).split("\n");
|
|
7306
|
+
pending = redact === void 0 ? "" : lines.pop() ?? "";
|
|
7307
|
+
for (const line of lines) show(line);
|
|
7308
|
+
},
|
|
7309
|
+
flush: () => {
|
|
7310
|
+
show(pending);
|
|
7311
|
+
pending = "";
|
|
7312
|
+
}
|
|
7313
|
+
};
|
|
7314
|
+
};
|
|
7315
|
+
const stdout = lineReader((line) => this.logger.info(line));
|
|
7316
|
+
const stderr = lineReader((line) => this.logger.error(line));
|
|
7317
|
+
child.stdout?.on("data", stdout.push);
|
|
7318
|
+
child.stderr?.on("data", stderr.push);
|
|
7426
7319
|
child.on("error", (error) => {
|
|
7427
7320
|
settle({
|
|
7428
7321
|
status: "spawn_error",
|
|
@@ -7437,6 +7330,8 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7437
7330
|
child.on("exit", async (code, signal) => {
|
|
7438
7331
|
if (!interactive) await this.cleanupProcessGroup();
|
|
7439
7332
|
await outputDrained(child);
|
|
7333
|
+
stdout.flush();
|
|
7334
|
+
stderr.flush();
|
|
7440
7335
|
if (timedOut && timeoutMs !== null) {
|
|
7441
7336
|
settle({
|
|
7442
7337
|
status: "timed_out",
|
|
@@ -7478,6 +7373,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7478
7373
|
*/
|
|
7479
7374
|
startStepExecution(request) {
|
|
7480
7375
|
const { command, custom, inProcessOnly, interactive, stepEnv, stepName, template, timeoutMs, workDir } = request;
|
|
7376
|
+
if (request.secretEnv !== void 0) return this.executeCommand(command, workDir, stepEnv, stepName, false, timeoutMs, request.secretEnv);
|
|
7481
7377
|
const executor = this.stepExecutor;
|
|
7482
7378
|
const base = {
|
|
7483
7379
|
traceparent: request.traceparent,
|
|
@@ -7544,7 +7440,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7544
7440
|
/**
|
|
7545
7441
|
* Await a host-owned execution and normalize it like a child process.
|
|
7546
7442
|
*
|
|
7547
|
-
* The engine keeps ownership of the timeout; stop
|
|
7443
|
+
* The engine keeps ownership of the timeout; stop and pause
|
|
7548
7444
|
* completion reach the execution through `killActiveStep`, which calls its
|
|
7549
7445
|
* `stop`. A stopped execution reads as signalled so shutdown still interrupts
|
|
7550
7446
|
* the workflow, while the completion races report their own outcome.
|
|
@@ -7867,7 +7763,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7867
7763
|
return [...keys];
|
|
7868
7764
|
}
|
|
7869
7765
|
resolveRunner(options) {
|
|
7870
|
-
return options.runner
|
|
7766
|
+
return options.runner;
|
|
7871
7767
|
}
|
|
7872
7768
|
formatStepDisplay(jobName, stepName) {
|
|
7873
7769
|
return jobName ? `${jobName} > ${stepName}` : stepName;
|
|
@@ -7882,77 +7778,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
7882
7778
|
escapeShellArg(value) {
|
|
7883
7779
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
7884
7780
|
}
|
|
7885
|
-
async shouldRetryForCodexQuota(stepName, isCodexCommand) {
|
|
7886
|
-
if (!isCodexCommand) return false;
|
|
7887
|
-
return (await this.readCodexQuotaStatus(stepName))?.blockingLimit != null;
|
|
7888
|
-
}
|
|
7889
|
-
async waitForCodexQuotaAvailability(stepName, command, isCodexCommand) {
|
|
7890
|
-
if (!isCodexCommand) return;
|
|
7891
|
-
while (true) {
|
|
7892
|
-
const quotaStatus = await this.readCodexQuotaStatus(stepName);
|
|
7893
|
-
const blockingLimit = quotaStatus?.blockingLimit;
|
|
7894
|
-
if (!blockingLimit) return;
|
|
7895
|
-
const waitTargetMs = blockingLimit.resetAt * 1e3 + QUOTA_WAIT_RESET_BUFFER_MS;
|
|
7896
|
-
const remainingMs = Math.max(waitTargetMs - Date.now(), QUOTA_WAIT_RESET_BUFFER_MS);
|
|
7897
|
-
const waitDescription = new Date(waitTargetMs).toLocaleString();
|
|
7898
|
-
const planSuffix = quotaStatus?.planType ? ` (${quotaStatus.planType})` : "";
|
|
7899
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WAIT}${RESET$3} codex quota ${blockingLimit.limitName}/${blockingLimit.window} is at ${blockingLimit.usedPercent}%${planSuffix}; waiting until ${waitDescription}`);
|
|
7900
|
-
await this.waitForQuotaDelay(stepName, command, remainingMs);
|
|
7901
|
-
}
|
|
7902
|
-
}
|
|
7903
|
-
async readCodexQuotaStatus(stepName) {
|
|
7904
|
-
try {
|
|
7905
|
-
return await this.quotaService.getQuotaStatus();
|
|
7906
|
-
} catch (error) {
|
|
7907
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} unable to read codex quota for "${stepName}" (${this.formatQuotaError(error)})`);
|
|
7908
|
-
return null;
|
|
7909
|
-
}
|
|
7910
|
-
}
|
|
7911
|
-
async waitForQuotaDelay(stepName, command, remainingMs) {
|
|
7912
|
-
const controller = new AbortController();
|
|
7913
|
-
this.activeQuotaWait = {
|
|
7914
|
-
controller,
|
|
7915
|
-
signal: null,
|
|
7916
|
-
stepName
|
|
7917
|
-
};
|
|
7918
|
-
try {
|
|
7919
|
-
let timeLeftMs = remainingMs;
|
|
7920
|
-
while (timeLeftMs > 0) {
|
|
7921
|
-
const sleepMs = Math.min(timeLeftMs, QUOTA_WAIT_POLL_INTERVAL_MS);
|
|
7922
|
-
await this.waitForDelay(sleepMs, controller.signal);
|
|
7923
|
-
timeLeftMs -= sleepMs;
|
|
7924
|
-
}
|
|
7925
|
-
} catch (error) {
|
|
7926
|
-
if (controller.signal.aborted) throw new WorkflowInterruptedError(this.activeQuotaWait?.signal ?? TERMINATE_SIGNAL$1, {
|
|
7927
|
-
cause: /* @__PURE__ */ new Error(`Interrupted while waiting for Codex quota reset`),
|
|
7928
|
-
context: {
|
|
7929
|
-
...this.createInterruptContext(stepName, command),
|
|
7930
|
-
phase: QUOTA_WAIT_SOURCE
|
|
7931
|
-
}
|
|
7932
|
-
});
|
|
7933
|
-
throw error;
|
|
7934
|
-
} finally {
|
|
7935
|
-
this.activeQuotaWait = null;
|
|
7936
|
-
}
|
|
7937
|
-
}
|
|
7938
|
-
async waitForDelay(delayMs, signal) {
|
|
7939
|
-
await new Promise((resolveDelay, rejectDelay) => {
|
|
7940
|
-
const timeout = setTimeout(() => {
|
|
7941
|
-
signal.removeEventListener("abort", onAbort);
|
|
7942
|
-
resolveDelay();
|
|
7943
|
-
}, delayMs);
|
|
7944
|
-
const onAbort = () => {
|
|
7945
|
-
clearTimeout(timeout);
|
|
7946
|
-
signal.removeEventListener("abort", onAbort);
|
|
7947
|
-
rejectDelay(/* @__PURE__ */ new Error("aborted"));
|
|
7948
|
-
};
|
|
7949
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
7950
|
-
});
|
|
7951
|
-
}
|
|
7952
|
-
formatQuotaError(error) {
|
|
7953
|
-
if (error instanceof Error && error.message.trim().length > 0) return error.message;
|
|
7954
|
-
return "unknown quota error";
|
|
7955
|
-
}
|
|
7956
7781
|
/**
|
|
7957
7782
|
* Resolve the per-step timeout from workflow YAML into milliseconds.
|
|
7958
7783
|
*/
|
|
@@ -8097,10 +7922,8 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8097
7922
|
return Number.isInteger(parsed) && parsed > 0 ? parsed : PROCESS_EXIT_WAIT_TIMEOUT_MS;
|
|
8098
7923
|
}
|
|
8099
7924
|
/**
|
|
8100
|
-
*
|
|
8101
|
-
*
|
|
8102
|
-
* interactive agent can flush its final telemetry batch (e.g. Claude Code's
|
|
8103
|
-
* 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
|
|
8104
7927
|
* immediately, so this only adds latency when a child lingers. Operator-tunable
|
|
8105
7928
|
* via `WORKFLOW_STEP_FORCE_KILL_GRACE_MS`; defaults to STEP_COMPLETION_KILL_GRACE_MS.
|
|
8106
7929
|
*/
|
|
@@ -8240,7 +8063,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8240
8063
|
* Interactive TUIs such as Claude Code make themselves process-group leaders
|
|
8241
8064
|
* (pid === pgid) and spawn descendants into that group. Reaping by pid alone
|
|
8242
8065
|
* leaves anything spawned after the one-shot tree snapshot alive, which keeps
|
|
8243
|
-
* the interactive session running after
|
|
8066
|
+
* the interactive session running after a stop or pause request.
|
|
8244
8067
|
*/
|
|
8245
8068
|
collectInteractiveProcessGroupIds(processIds) {
|
|
8246
8069
|
if (processIds.length === 0) return [];
|
|
@@ -8343,38 +8166,17 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8343
8166
|
return false;
|
|
8344
8167
|
}
|
|
8345
8168
|
}
|
|
8346
|
-
/**
|
|
8347
|
-
|
|
8348
|
-
* YES to when the agent finishes its turn. The path is injected into
|
|
8349
|
-
* WORKFLOW_STATUS_FILE so the hook can locate it directly — no fallback
|
|
8350
|
-
* marker file is used.
|
|
8351
|
-
*/
|
|
8352
|
-
async createStatusFile() {
|
|
8353
|
-
if (!this.runtime.temporaryDirectory) throw new Error("Workflow interactive status files require an admitted temporaryDirectory");
|
|
8354
|
-
const filePath = join(this.runtime.temporaryDirectory, `${STATUS_FILE_PREFIX}${randomUUID()}${STATUS_FILE_SUFFIX}`);
|
|
8355
|
-
getOrThrow(await this.runtime.fs.writeFile(filePath, "", this.runtime.ioContext));
|
|
8356
|
-
return filePath;
|
|
8357
|
-
}
|
|
8358
|
-
/**
|
|
8359
|
-
* Race interactive step execution against agent completion and workflow stop files.
|
|
8360
|
-
* When the file contains YES, SIGTERM the step process and wait for
|
|
8361
|
-
* it to exit before returning `status_completed`. Escalates to SIGKILL
|
|
8362
|
-
* if the process ignores SIGTERM. The next job must not start until
|
|
8363
|
-
* the child process tree has fully exited.
|
|
8364
|
-
*/
|
|
8365
|
-
async raceInteractiveCompletion(executionPromise, statusFilePath, stepName, stopRequestPath, pausePolicy) {
|
|
8169
|
+
/** Race interactive execution against workflow stop and pause requests. */
|
|
8170
|
+
async raceInteractiveCompletion(executionPromise, stepName, stopRequestPath, pausePolicy) {
|
|
8366
8171
|
return new Promise((resolveRace) => {
|
|
8367
8172
|
let settled = false;
|
|
8368
|
-
let statusFileTriggered = false;
|
|
8369
8173
|
let stopRequestTriggered = false;
|
|
8370
8174
|
let pauseRequestTriggered = false;
|
|
8371
8175
|
const pauseRequestPath = stopRequestPath ? join(dirname(stopRequestPath), PAUSE_REQUEST_FILENAME) : void 0;
|
|
8372
8176
|
let forceKillTimer = null;
|
|
8373
8177
|
let completionSettleTimer = null;
|
|
8374
|
-
let watcher = null;
|
|
8375
8178
|
let stopWatcher = null;
|
|
8376
8179
|
let pauseWatcher = null;
|
|
8377
|
-
let pollTimer = null;
|
|
8378
8180
|
let stopPollTimer = null;
|
|
8379
8181
|
let pausePollTimer = null;
|
|
8380
8182
|
let signalDelivered = false;
|
|
@@ -8382,7 +8184,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8382
8184
|
const resolveCompletionSource = (result) => {
|
|
8383
8185
|
if (stopRequestTriggered) return "stop-request";
|
|
8384
8186
|
if (pauseRequestTriggered) return "pause-request";
|
|
8385
|
-
if (statusFileTriggered) return "status-file";
|
|
8386
8187
|
switch (result.status) {
|
|
8387
8188
|
case RESULT_STATUS_TIMED_OUT: return "timed-out";
|
|
8388
8189
|
case RESULT_STATUS_SPAWN_ERROR: return "spawn-error";
|
|
@@ -8393,10 +8194,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8393
8194
|
const settle = async (result) => {
|
|
8394
8195
|
if (settled) return;
|
|
8395
8196
|
settled = true;
|
|
8396
|
-
if (watcher) {
|
|
8397
|
-
await watcher.close(this.runtime.ioContext).catch((error) => this.logger.warn(`Workflow watcher cleanup failed: ${String(error)}`));
|
|
8398
|
-
watcher = null;
|
|
8399
|
-
}
|
|
8400
8197
|
if (stopWatcher) {
|
|
8401
8198
|
await stopWatcher.close(this.runtime.ioContext).catch((error) => this.logger.warn(`Workflow watcher cleanup failed: ${String(error)}`));
|
|
8402
8199
|
stopWatcher = null;
|
|
@@ -8405,10 +8202,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8405
8202
|
await pauseWatcher.close(this.runtime.ioContext).catch((error) => this.logger.warn(`Workflow watcher cleanup failed: ${String(error)}`));
|
|
8406
8203
|
pauseWatcher = null;
|
|
8407
8204
|
}
|
|
8408
|
-
if (pollTimer) {
|
|
8409
|
-
clearInterval(pollTimer);
|
|
8410
|
-
pollTimer = null;
|
|
8411
|
-
}
|
|
8412
8205
|
if (stopPollTimer) {
|
|
8413
8206
|
clearInterval(stopPollTimer);
|
|
8414
8207
|
stopPollTimer = null;
|
|
@@ -8432,25 +8225,13 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8432
8225
|
await this.recordInteractiveCompletion({
|
|
8433
8226
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8434
8227
|
stepName,
|
|
8435
|
-
statusFilePath,
|
|
8436
8228
|
completionSource: resolveCompletionSource(settledResult),
|
|
8437
|
-
statusFileSignaled: statusFileTriggered,
|
|
8438
8229
|
sigkillEscalated: sigkillEscalated || (this.lastInteractiveReap?.sigkillEscalated ?? false),
|
|
8439
8230
|
survivors: this.lastInteractiveReap?.survivors ?? []
|
|
8440
8231
|
});
|
|
8441
8232
|
this.lastInteractiveReap = null;
|
|
8442
8233
|
resolveRace(settledResult);
|
|
8443
8234
|
};
|
|
8444
|
-
const statusFileHasCompletionValue = async () => {
|
|
8445
|
-
try {
|
|
8446
|
-
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;
|
|
8447
|
-
} catch (error) {
|
|
8448
|
-
const code = error.code;
|
|
8449
|
-
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)}`);
|
|
8450
|
-
else this.logger.info(` ${DIM$3}status-file${RESET$3} transient FS error (${code}) polling ${stepName}`);
|
|
8451
|
-
return false;
|
|
8452
|
-
}
|
|
8453
|
-
};
|
|
8454
8235
|
const scheduleAbsoluteSettle = (result, delayMs) => {
|
|
8455
8236
|
if (settled || completionSettleTimer) return;
|
|
8456
8237
|
completionSettleTimer = setTimeout(() => {
|
|
@@ -8469,24 +8250,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8469
8250
|
settle(result);
|
|
8470
8251
|
}, delayMs);
|
|
8471
8252
|
};
|
|
8472
|
-
const checkFileContent = async () => {
|
|
8473
|
-
if (!await statusFileHasCompletionValue() || settled || statusFileTriggered) return;
|
|
8474
|
-
statusFileTriggered = true;
|
|
8475
|
-
const graceMs = this.stepCompletionKillGraceMs();
|
|
8476
|
-
signalDelivered = this.killActiveStep(TERMINATE_SIGNAL$1);
|
|
8477
|
-
if (!signalDelivered) {
|
|
8478
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} status-file: SIGTERM could not be delivered, process may have already exited`);
|
|
8479
|
-
scheduleAbsoluteSettle(STATUS_FILE_COMPLETED_RESULT, PROCESS_EXIT_WAIT_TIMEOUT_MS);
|
|
8480
|
-
return;
|
|
8481
|
-
}
|
|
8482
|
-
forceKillTimer = setTimeout(() => {
|
|
8483
|
-
if (settled) return;
|
|
8484
|
-
sigkillEscalated = true;
|
|
8485
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} did not exit after status-file SIGTERM, forcing SIGKILL`);
|
|
8486
|
-
this.killActiveStep(TERMINATE_FORCE_KILL_SIGNAL);
|
|
8487
|
-
}, graceMs);
|
|
8488
|
-
scheduleAbsoluteSettle(STATUS_FILE_COMPLETED_RESULT, graceMs + PROCESS_EXIT_WAIT_TIMEOUT_MS);
|
|
8489
|
-
};
|
|
8490
8253
|
const stopRequestExists = async () => Boolean(stopRequestPath && await this.hasCurrentStopRequest(stopRequestPath));
|
|
8491
8254
|
const pauseRequestExists = async () => Boolean(pauseRequestPath && await pathExists(this.runtime.fs, pauseRequestPath, this.runtime.ioContext) && await this.readControlAction(pauseRequestPath) === "pause");
|
|
8492
8255
|
const checkStopRequest = async () => {
|
|
@@ -8526,23 +8289,9 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8526
8289
|
}, graceMs);
|
|
8527
8290
|
scheduleAbsoluteSettle({ status: RESULT_STATUS_PAUSE_REQUESTED }, graceMs + PROCESS_EXIT_WAIT_TIMEOUT_MS);
|
|
8528
8291
|
};
|
|
8529
|
-
try {
|
|
8530
|
-
this.watchStatusFile([{ path: statusFilePath }], () => {
|
|
8531
|
-
checkFileContent().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8532
|
-
}, this.runtime.ioContext).then(async (result) => {
|
|
8533
|
-
const admitted = getOrThrow(result);
|
|
8534
|
-
if (settled) await admitted.close(this.runtime.ioContext);
|
|
8535
|
-
else watcher = admitted;
|
|
8536
|
-
}).catch((error) => this.logger.warn(`Workflow status-file watcher unavailable, polling instead: ${String(error)}`));
|
|
8537
|
-
} catch (error) {
|
|
8538
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file watcher setup failed for ${stepName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8539
|
-
}
|
|
8540
|
-
pollTimer = setInterval(() => {
|
|
8541
|
-
checkFileContent().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8542
|
-
}, STATUS_FILE_POLL_INTERVAL_MS);
|
|
8543
8292
|
if (stopRequestPath) {
|
|
8544
8293
|
try {
|
|
8545
|
-
this.
|
|
8294
|
+
this.watchControlFile([{ path: stopRequestPath }], () => {
|
|
8546
8295
|
checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8547
8296
|
}, this.runtime.ioContext).then(async (result) => {
|
|
8548
8297
|
const admitted = getOrThrow(result);
|
|
@@ -8558,7 +8307,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8558
8307
|
}
|
|
8559
8308
|
if (pauseRequestPath) {
|
|
8560
8309
|
try {
|
|
8561
|
-
this.
|
|
8310
|
+
this.watchControlFile([{ path: pauseRequestPath }], () => {
|
|
8562
8311
|
checkPauseRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8563
8312
|
}, this.runtime.ioContext).then(async (result) => {
|
|
8564
8313
|
const admitted = getOrThrow(result);
|
|
@@ -8572,7 +8321,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8572
8321
|
checkPauseRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8573
8322
|
}, STOP_REQUEST_POLL_INTERVAL_MS);
|
|
8574
8323
|
}
|
|
8575
|
-
checkFileContent().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8576
8324
|
checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8577
8325
|
checkPauseRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8578
8326
|
executionPromise.then(async (result) => {
|
|
@@ -8581,42 +8329,9 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8581
8329
|
settle({ status: RESULT_STATUS_STOP_REQUESTED });
|
|
8582
8330
|
return;
|
|
8583
8331
|
}
|
|
8584
|
-
const
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
settle({ status: RESULT_STATUS_PAUSE_REQUESTED });
|
|
8588
|
-
return;
|
|
8589
|
-
}
|
|
8590
|
-
if (!completedViaStatusFile) {
|
|
8591
|
-
settle(result);
|
|
8592
|
-
return;
|
|
8593
|
-
}
|
|
8594
|
-
if (!statusFileTriggered) {
|
|
8595
|
-
statusFileTriggered = true;
|
|
8596
|
-
this.logger.info(` ${GREEN$2}${STATUS_DONE}${RESET$3} ${stepName} status-file observed during process exit handling`);
|
|
8597
|
-
}
|
|
8598
|
-
switch (result.status) {
|
|
8599
|
-
case RESULT_STATUS_SPAWN_ERROR:
|
|
8600
|
-
case RESULT_STATUS_TIMED_OUT:
|
|
8601
|
-
settle(result);
|
|
8602
|
-
return;
|
|
8603
|
-
case RESULT_STATUS_SIGNALED:
|
|
8604
|
-
if (sigkillEscalated) this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} required SIGKILL escalation (work completed via status-file)`);
|
|
8605
|
-
settle(STATUS_FILE_COMPLETED_RESULT);
|
|
8606
|
-
return;
|
|
8607
|
-
case RESULT_STATUS_COMPLETED:
|
|
8608
|
-
if (sigkillEscalated) this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} ${stepName} required SIGKILL escalation (work completed via status-file, exit code ${result.exitCode})`);
|
|
8609
|
-
settle(STATUS_FILE_COMPLETED_RESULT);
|
|
8610
|
-
return;
|
|
8611
|
-
case RESULT_STATUS_STATUS_COMPLETED:
|
|
8612
|
-
settle(result);
|
|
8613
|
-
return;
|
|
8614
|
-
case RESULT_STATUS_STOP_REQUESTED:
|
|
8615
|
-
case RESULT_STATUS_PAUSE_REQUESTED:
|
|
8616
|
-
settle(result);
|
|
8617
|
-
return;
|
|
8618
|
-
default: settle(result);
|
|
8619
|
-
}
|
|
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);
|
|
8620
8335
|
});
|
|
8621
8336
|
});
|
|
8622
8337
|
}
|
|
@@ -8665,7 +8380,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8665
8380
|
}, FORCE_KILL_GRACE_PERIOD_MS);
|
|
8666
8381
|
};
|
|
8667
8382
|
try {
|
|
8668
|
-
this.
|
|
8383
|
+
this.watchControlFile([{ path: stopRequestPath }], () => {
|
|
8669
8384
|
checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8670
8385
|
}, this.runtime.ioContext).then(async (result) => {
|
|
8671
8386
|
const admitted = getOrThrow(result);
|
|
@@ -8680,7 +8395,7 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8680
8395
|
}, STOP_REQUEST_POLL_INTERVAL_MS);
|
|
8681
8396
|
checkStopRequest().catch((error) => this.logger.warn(`Workflow control check failed: ${String(error)}`));
|
|
8682
8397
|
executionPromise.then(async (result) => {
|
|
8683
|
-
const protectedPauseEligible = result.status ===
|
|
8398
|
+
const protectedPauseEligible = result.status === RESULT_STATUS_COMPLETED && result.exitCode === 0;
|
|
8684
8399
|
if (stopRequestTriggered) settle({ status: RESULT_STATUS_STOP_REQUESTED });
|
|
8685
8400
|
else if (pauseRequestTriggered && (pausePolicy !== "protected" || protectedPauseEligible)) settle({ status: RESULT_STATUS_PAUSE_REQUESTED });
|
|
8686
8401
|
else settle(result);
|
|
@@ -8790,16 +8505,6 @@ var StepRunnerService = class StepRunnerService {
|
|
|
8790
8505
|
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} failed to restore terminal state: ${String(error)}`);
|
|
8791
8506
|
}
|
|
8792
8507
|
}
|
|
8793
|
-
/**
|
|
8794
|
-
* Remove the temp status file and the well-known marker file after step completion.
|
|
8795
|
-
*/
|
|
8796
|
-
async cleanupStatusFile(statusFilePath) {
|
|
8797
|
-
try {
|
|
8798
|
-
if (await pathExists(this.runtime.fs, statusFilePath, this.runtime.ioContext)) getOrThrow(await this.runtime.fs.remove(statusFilePath, { force: true }, this.runtime.ioContext));
|
|
8799
|
-
} catch (error) {
|
|
8800
|
-
this.logger.warn(` ${YELLOW$2}${STATUS_WARN}${RESET$3} status-file cleanup failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
8801
|
-
}
|
|
8802
|
-
}
|
|
8803
8508
|
};
|
|
8804
8509
|
//#endregion
|
|
8805
8510
|
//#region src/services/TriggerService/index.ts
|
|
@@ -9523,7 +9228,7 @@ var RunWorkflowService = class {
|
|
|
9523
9228
|
this.launcherMetadata = dependencies.launcherMetadata;
|
|
9524
9229
|
this.parser = dependencies.parser ?? new WorkflowParserService(this.runtime);
|
|
9525
9230
|
this.serviceManager = dependencies.serviceManager ?? new BackgroundServiceManager(this.runtime, this.logger);
|
|
9526
|
-
this.stepRunner = dependencies.stepRunner ?? new StepRunnerService(this.runtime, this.parser, this.logger, void 0, void 0,
|
|
9231
|
+
this.stepRunner = dependencies.stepRunner ?? new StepRunnerService(this.runtime, this.parser, this.logger, void 0, void 0, dependencies.ownsTerminal, dependencies.stepExecutor, dependencies.resolveSecrets);
|
|
9527
9232
|
this.registry = dependencies.registry ?? new WorkflowRegistryService(this.runtime);
|
|
9528
9233
|
this.runDirectoryService = dependencies.runDirectoryService ?? new RunDirectoryService(this.runtime, this.registry.writeCoordinator);
|
|
9529
9234
|
this.jobRunner = dependencies.jobRunner ?? new JobRunnerService(this.runtime, this.parser, this.stepRunner, this.logger, this.runDirectoryService);
|
|
@@ -9535,6 +9240,7 @@ var RunWorkflowService = class {
|
|
|
9535
9240
|
* Run the workflow from trigger preparation through cleanup.
|
|
9536
9241
|
*/
|
|
9537
9242
|
async run(input) {
|
|
9243
|
+
if ("cliAgent" in input) throw new Error("cliAgent is retired. Use runner explicitly.");
|
|
9538
9244
|
this.stepRunner.resetInterruption();
|
|
9539
9245
|
this.triggerService.resetInterruption();
|
|
9540
9246
|
this.outputLines = [];
|
|
@@ -9717,12 +9423,12 @@ var RunWorkflowService = class {
|
|
|
9717
9423
|
commands: workflow.commands,
|
|
9718
9424
|
choices: workflow.choices,
|
|
9719
9425
|
command: input.command,
|
|
9720
|
-
choice: input.choice
|
|
9426
|
+
choice: input.choice,
|
|
9427
|
+
profile: input.profile
|
|
9721
9428
|
});
|
|
9722
9429
|
}
|
|
9723
9430
|
resolveRunner(input, workflow) {
|
|
9724
|
-
|
|
9725
|
-
return input.runner ?? input.cliAgent ?? (workflow ? this.resolveWorkflowRunner(workflow) : void 0);
|
|
9431
|
+
return input.runner ?? (workflow ? this.resolveWorkflowRunner(workflow) : void 0);
|
|
9726
9432
|
}
|
|
9727
9433
|
/**
|
|
9728
9434
|
* Execute the workflow after signal handlers are installed.
|
|
@@ -9855,7 +9561,6 @@ var RunWorkflowService = class {
|
|
|
9855
9561
|
if (dryRun && input.recovery) registryRun = await this.createRecoveryDryRunHandle(input, resolvedWorkspace);
|
|
9856
9562
|
else registryRun = await this.registry.createRun({
|
|
9857
9563
|
activeRepairId: input.recovery?.activeRepairId,
|
|
9858
|
-
cliAgent: input.cliAgent,
|
|
9859
9564
|
continueOnError: input.continueOnError,
|
|
9860
9565
|
displayName: workflowName,
|
|
9861
9566
|
dryRun,
|
|
@@ -9869,6 +9574,7 @@ var RunWorkflowService = class {
|
|
|
9869
9574
|
runner,
|
|
9870
9575
|
command: input.command,
|
|
9871
9576
|
choice: input.choice,
|
|
9577
|
+
profile: input.profile,
|
|
9872
9578
|
runDirectory: workflow["run-directory"],
|
|
9873
9579
|
secretFile: input.secretFile,
|
|
9874
9580
|
skipLaunch: input.skipLaunch,
|
|
@@ -9947,7 +9653,6 @@ var RunWorkflowService = class {
|
|
|
9947
9653
|
}
|
|
9948
9654
|
if (!await this.triggerService.handleAgentDecision(workflow, workflowEnv, inputs, secrets, {
|
|
9949
9655
|
runner,
|
|
9950
|
-
cliAgent: input.cliAgent,
|
|
9951
9656
|
dryRun,
|
|
9952
9657
|
continueOnError,
|
|
9953
9658
|
stopRequestPath: registryRun.stopRequestPath,
|
|
@@ -9986,7 +9691,6 @@ var RunWorkflowService = class {
|
|
|
9986
9691
|
this.logger.info(` ${"─".repeat(50)}`);
|
|
9987
9692
|
if (!await this.worktreeService.runHook(workflow.worktree.beforeCreate, workflowDir, workflowEnv, inputs, secrets, {
|
|
9988
9693
|
runner,
|
|
9989
|
-
cliAgent: input.cliAgent,
|
|
9990
9694
|
dryRun,
|
|
9991
9695
|
continueOnError,
|
|
9992
9696
|
stopRequestPath: registryRun.stopRequestPath,
|
|
@@ -10018,7 +9722,6 @@ var RunWorkflowService = class {
|
|
|
10018
9722
|
this.logger.info(` ${"─".repeat(50)}`);
|
|
10019
9723
|
if (!await this.worktreeService.runHook(workflow.worktree.afterCreate, worktreePath, workflowEnv, inputs, secrets, {
|
|
10020
9724
|
runner,
|
|
10021
|
-
cliAgent: input.cliAgent,
|
|
10022
9725
|
dryRun,
|
|
10023
9726
|
continueOnError,
|
|
10024
9727
|
stopRequestPath: registryRun.stopRequestPath,
|
|
@@ -10051,7 +9754,6 @@ var RunWorkflowService = class {
|
|
|
10051
9754
|
const preStopRequestPath = registryRun.stopRequestPath;
|
|
10052
9755
|
if (!await this.recordPhase(progress, PRE_PHASE_JOB, () => this.runPreBlock(preBlock, workflowEnv, inputs, secrets, {
|
|
10053
9756
|
runner,
|
|
10054
|
-
cliAgent: input.cliAgent,
|
|
10055
9757
|
dryRun,
|
|
10056
9758
|
continueOnError,
|
|
10057
9759
|
progress,
|
|
@@ -10129,7 +9831,6 @@ var RunWorkflowService = class {
|
|
|
10129
9831
|
runDirectory: workflow["run-directory"]
|
|
10130
9832
|
}, {
|
|
10131
9833
|
runner,
|
|
10132
|
-
cliAgent: input.cliAgent,
|
|
10133
9834
|
dryRun,
|
|
10134
9835
|
continueOnError,
|
|
10135
9836
|
stopRequestPath,
|
|
@@ -10236,7 +9937,6 @@ var RunWorkflowService = class {
|
|
|
10236
9937
|
} : void 0
|
|
10237
9938
|
}, {
|
|
10238
9939
|
runner,
|
|
10239
|
-
cliAgent: input.cliAgent,
|
|
10240
9940
|
dryRun,
|
|
10241
9941
|
continueOnError,
|
|
10242
9942
|
stopRequestPath: registryRun.stopRequestPath,
|
|
@@ -10447,7 +10147,6 @@ var RunWorkflowService = class {
|
|
|
10447
10147
|
this.logger.info(` ${"─".repeat(50)}`);
|
|
10448
10148
|
if (!await this.worktreeService.runHook(workflow.worktree.beforeCompleted, worktreePath, workflowEnv, inputs, secrets, {
|
|
10449
10149
|
runner,
|
|
10450
|
-
cliAgent: input.cliAgent,
|
|
10451
10150
|
dryRun,
|
|
10452
10151
|
continueOnError
|
|
10453
10152
|
})) {
|
|
@@ -10472,7 +10171,6 @@ var RunWorkflowService = class {
|
|
|
10472
10171
|
try {
|
|
10473
10172
|
if (!await this.recordPhase(progress, POST_PHASE_JOB, () => this.runPostBlock(postBlock, workflowEnv, inputs, secrets, {
|
|
10474
10173
|
runner,
|
|
10475
|
-
cliAgent: input.cliAgent,
|
|
10476
10174
|
dryRun,
|
|
10477
10175
|
continueOnError,
|
|
10478
10176
|
progress,
|
|
@@ -10499,7 +10197,6 @@ var RunWorkflowService = class {
|
|
|
10499
10197
|
this.logger.info(` ${"─".repeat(50)}`);
|
|
10500
10198
|
if (!await this.worktreeService.runHook(workflow.worktree.afterCompleted, originalDir, workflowEnv, inputs, secrets, {
|
|
10501
10199
|
runner,
|
|
10502
|
-
cliAgent: input.cliAgent,
|
|
10503
10200
|
dryRun,
|
|
10504
10201
|
continueOnError
|
|
10505
10202
|
})) {
|
|
@@ -10860,6 +10557,7 @@ var RunWorkflowService = class {
|
|
|
10860
10557
|
if (runner) parts.push("--runner", escapeShellArg(runner));
|
|
10861
10558
|
if (input.command) parts.push("--command", escapeShellArg(input.command));
|
|
10862
10559
|
if (input.choice) parts.push("--choice", escapeShellArg(input.choice));
|
|
10560
|
+
if (input.profile) parts.push("--profile", escapeShellArg(input.profile));
|
|
10863
10561
|
if (input.dryRun) parts.push("--dry-run");
|
|
10864
10562
|
if (input.continueOnError) parts.push("--continue-on-error");
|
|
10865
10563
|
if (input.keepWorktree) parts.push("--keep-worktree");
|
|
@@ -11173,16 +10871,21 @@ var RecoverWorkflowService = class {
|
|
|
11173
10871
|
if (!recoveredJob) throw new Error(`Workflow run "${record.workspace}/${record.runKey}" does not include a recoverable failed job`);
|
|
11174
10872
|
if (record.worktreePath && !await pathExists(this.runtime.fs, record.worktreePath, this.runtime.ioContext)) throw new Error(`Recoverable worktree not found: ${record.worktreePath}`);
|
|
11175
10873
|
const runner = input.runner ?? record.runner ?? record.cliAgent;
|
|
11176
|
-
|
|
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.");
|
|
11177
10880
|
const originalJob = fixRestartFrom && !activeRepair ? void 0 : record.job;
|
|
11178
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`);
|
|
11179
10882
|
const ownerSessionId = claimedOwnerSessionId?.trim();
|
|
11180
10883
|
const envOverrides = ownerSessionId ? { [PI_SESSION_ENV]: ownerSessionId } : void 0;
|
|
11181
10884
|
return await this.runner.run({
|
|
11182
|
-
cliAgent,
|
|
11183
10885
|
runner,
|
|
11184
10886
|
command: record.command,
|
|
11185
10887
|
choice: record.choice,
|
|
10888
|
+
profile: record.profile,
|
|
11186
10889
|
workflowPath: record.workflowPath,
|
|
11187
10890
|
job: recoveredJob,
|
|
11188
10891
|
inputs: record.inputs,
|
|
@@ -11235,6 +10938,6 @@ var RecoverWorkflowService = class {
|
|
|
11235
10938
|
}
|
|
11236
10939
|
};
|
|
11237
10940
|
//#endregion
|
|
11238
|
-
export {
|
|
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 };
|
|
11239
10942
|
|
|
11240
|
-
//# sourceMappingURL=RecoverWorkflowService-
|
|
10943
|
+
//# sourceMappingURL=RecoverWorkflowService-CY8wIc3A.mjs.map
|