stageflow 0.18.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +2 -1
  2. package/dist/agent/activity.d.ts +9 -0
  3. package/dist/agent/activityObserver.d.ts +3 -0
  4. package/dist/agent/activityObserver.js +6 -1
  5. package/dist/agent/claudeAdapter.js +38 -0
  6. package/dist/agent/fakeAgent.js +3 -1
  7. package/dist/agent/piAdapter.js +40 -4
  8. package/dist/agent/port.d.ts +3 -1
  9. package/dist/agent/providerInspect.d.ts +19 -0
  10. package/dist/agent/providerInspect.js +35 -0
  11. package/dist/agent/stageTimeout.d.ts +9 -0
  12. package/dist/agent/stageTimeout.js +24 -0
  13. package/dist/agent/streamLogRedact.d.ts +2 -0
  14. package/dist/agent/streamLogRedact.js +13 -0
  15. package/dist/cli/artifactCommand.js +2 -2
  16. package/dist/cli/envelopeCommand.js +2 -2
  17. package/dist/cli/exportRunCommand.js +2 -2
  18. package/dist/cli/graphCommand.d.ts +15 -0
  19. package/dist/cli/graphCommand.js +79 -0
  20. package/dist/cli/graphRender.d.ts +2 -0
  21. package/dist/cli/graphRender.js +85 -0
  22. package/dist/cli/hostClient.d.ts +43 -0
  23. package/dist/cli/hostClient.js +182 -0
  24. package/dist/cli/providersCommand.js +5 -3
  25. package/dist/cli/runCommand.d.ts +6 -5
  26. package/dist/cli/runCommand.js +23 -31
  27. package/dist/cli/runOutput.d.ts +1 -1
  28. package/dist/cli/runsCommand.d.ts +4 -8
  29. package/dist/cli/runsCommand.js +65 -89
  30. package/dist/cli.js +13 -5
  31. package/dist/config/describePipeline.d.ts +26 -0
  32. package/dist/config/describePipeline.js +37 -0
  33. package/dist/config/loadPipeline.d.ts +13 -1
  34. package/dist/config/loadPipeline.js +34 -4
  35. package/dist/config/mergePipelineIncludes.d.ts +11 -0
  36. package/dist/config/mergePipelineIncludes.js +75 -0
  37. package/dist/config/validateCatalog.d.ts +2 -2
  38. package/dist/config/validateCatalog.js +24 -17
  39. package/dist/mcp/catalogTools.js +146 -52
  40. package/dist/mcp/controlTools.js +94 -19
  41. package/dist/mcp/deps.d.ts +3 -0
  42. package/dist/mcp/projectMcpTools.d.ts +3 -0
  43. package/dist/mcp/projectMcpTools.js +25 -0
  44. package/dist/mcp/providerTools.d.ts +3 -0
  45. package/dist/mcp/providerTools.js +17 -0
  46. package/dist/mcp/readArtifact.d.ts +9 -0
  47. package/dist/mcp/readArtifact.js +11 -0
  48. package/dist/mcp/server.js +9 -1
  49. package/dist/mcp/tailStreamLog.d.ts +8 -0
  50. package/dist/mcp/tailStreamLog.js +28 -0
  51. package/dist/mcp/toolResults.d.ts +17 -0
  52. package/dist/mcp/toolResults.js +15 -0
  53. package/dist/mcp/tools.js +4 -0
  54. package/dist/mcp/waitRun.js +4 -4
  55. package/dist/mcp/waitingGates.d.ts +1 -0
  56. package/dist/mcp/waitingGates.js +3 -2
  57. package/dist/package-meta.d.ts +1 -1
  58. package/dist/package-meta.js +1 -1
  59. package/dist/projection/projectRun.d.ts +3 -0
  60. package/dist/projection/projectRun.js +7 -0
  61. package/dist/runstore/port.d.ts +3 -1
  62. package/dist/runstore/port.js +2 -0
  63. package/dist/runstore/sqlite/SqliteRunStore.d.ts +2 -1
  64. package/dist/runstore/sqlite/SqliteRunStore.js +15 -1
  65. package/dist/runstore/workspaceLayout.d.ts +1 -0
  66. package/dist/runstore/workspaceLayout.js +3 -0
  67. package/dist/runtime/feedbackLoopCoordinator.d.ts +9 -1
  68. package/dist/runtime/feedbackLoopCoordinator.js +50 -20
  69. package/dist/runtime/feedbackLoopDecision.js +33 -1
  70. package/dist/runtime/forkGeneration.d.ts +4 -0
  71. package/dist/runtime/forkGeneration.js +16 -0
  72. package/dist/runtime/pipelineRunner.d.ts +3 -3
  73. package/dist/runtime/pipelineRunner.js +3 -1
  74. package/dist/runtime/pipelineScheduler.js +23 -1
  75. package/dist/runtime/reopenSkipped.d.ts +13 -0
  76. package/dist/runtime/reopenSkipped.js +56 -0
  77. package/dist/runtime/resumeReconstruct.js +2 -2
  78. package/dist/runtime/resumeTimedOut.d.ts +33 -0
  79. package/dist/runtime/resumeTimedOut.js +165 -0
  80. package/dist/runtime/runManager.d.ts +3 -1
  81. package/dist/runtime/runManager.js +110 -14
  82. package/dist/runtime/settingsFile.d.ts +2 -0
  83. package/dist/runtime/settingsFile.js +19 -0
  84. package/dist/runtime/stageAttemptBootstrap.d.ts +3 -0
  85. package/dist/runtime/stageAttemptBootstrap.js +8 -2
  86. package/dist/runtime/stageRecovery.js +2 -2
  87. package/dist/runtime/stageRunner.js +6 -2
  88. package/dist/runtime/stageStreamLog.d.ts +17 -0
  89. package/dist/runtime/stageStreamLog.js +89 -0
  90. package/dist/runtime/stageWorker.js +2 -1
  91. package/dist/server/bootstrap.js +9 -2
  92. package/dist/server/ensureGlobalService.d.ts +35 -0
  93. package/dist/server/ensureGlobalService.js +138 -0
  94. package/dist/server/http.d.ts +20 -1
  95. package/dist/server/http.js +452 -386
  96. package/dist/server/mcpHost.js +7 -8
  97. package/dist/server/operatorResults.d.ts +10 -0
  98. package/dist/server/operatorResults.js +24 -0
  99. package/dist/server/providerRoutes.d.ts +0 -6
  100. package/dist/server/providerRoutes.js +10 -18
  101. package/dist/tools/askOperator.d.ts +1 -0
  102. package/dist/tools/askOperator.js +14 -11
  103. package/dist/tools/emitStageEnvelope.d.ts +1 -0
  104. package/dist/tools/emitStageEnvelope.js +3 -1
  105. package/dist/tools/prepareToolArguments.d.ts +4 -0
  106. package/dist/tools/prepareToolArguments.js +79 -0
  107. package/dist/types/pipeline.d.ts +8 -0
  108. package/dist/ui/assets/{index-DsgVjLUS.css → index-CSsDued1.css} +1 -1
  109. package/dist/ui/assets/index-Da5EHU6M.js +119 -0
  110. package/dist/ui/index.html +2 -2
  111. package/package.json +1 -1
  112. package/skills/stageflow/references/control-surface.md +2 -2
  113. package/skills/stageflow-run/SKILL.md +27 -9
  114. package/skills/stageflow-run/references/mcp-call.md +1 -1
  115. package/skills/stageflow-run/scripts/mcp-call.mjs +9 -0
  116. package/dist/ui/assets/index-DwKGaQvQ.js +0 -119
@@ -0,0 +1,43 @@
1
+ import type { PipelineRunResult } from "../runtime/pipelineRunner.js";
2
+ import type { AbandonStageResult, DecideFeedbackLoopResult, StartRunResult, StopManualRecoveryResult } from "../runtime/runManager.js";
3
+ import type { DeliverAnswerResult } from "../runtime/stageHitl.js";
4
+ import type { RetryStageResult } from "../runtime/runRetryCoordinator.js";
5
+ import type { RunDetail, RunStore } from "../runstore/port.js";
6
+ export declare function computeRunDir(runId: string): string;
7
+ export declare function httpReadRun(base: string, runId: string): Promise<RunDetail>;
8
+ /** Thin RunStore-shaped reader backed by the global service, for the CLI output helpers that only need `readRun`. */
9
+ export declare function httpStoreReader(base: string): Pick<RunStore, "readRun">;
10
+ export declare function pollRunUntilTerminal(base: string, runId: string, options?: {
11
+ pollIntervalMs?: number;
12
+ }): Promise<RunDetail>;
13
+ export declare function runDetailToPipelineRunResult(detail: RunDetail): PipelineRunResult;
14
+ export type HttpStartRunInput = {
15
+ pipeline: string;
16
+ task: string;
17
+ checkoutOverride?: string;
18
+ skipGates?: boolean;
19
+ gitSha?: string;
20
+ ciPrUrl?: string;
21
+ ciJobUrl?: string;
22
+ };
23
+ export declare function httpStartRun(base: string, input: HttpStartRunInput): Promise<StartRunResult>;
24
+ export declare function httpRerun(base: string, runId: string): Promise<StartRunResult>;
25
+ export declare function httpDeliverAnswer(base: string, runId: string, stageId: string, answer: unknown): Promise<DeliverAnswerResult>;
26
+ export declare function httpDecideFeedbackLoop(base: string, runId: string, stageId: string, input: {
27
+ decision: "extend" | "continue" | "abandon";
28
+ loopId?: string;
29
+ reason?: string;
30
+ }): Promise<DecideFeedbackLoopResult>;
31
+ type RetryOrchestrationResult = {
32
+ ok: true;
33
+ pipeline: PipelineRunResult;
34
+ } | Extract<RetryStageResult, {
35
+ ok: false;
36
+ }>;
37
+ export declare function httpRetryStageUntilStop(base: string, runId: string, stageId: string): Promise<RetryOrchestrationResult>;
38
+ export declare function httpResumeTimedOutStage(base: string, runId: string, stageId: string): Promise<RetryStageResult>;
39
+ export declare function httpRecoverManualStageUntilStop(base: string, runId: string, stageId: string, guidance?: string): Promise<RetryOrchestrationResult>;
40
+ export declare function httpStopManualRecovery(base: string, runId: string, stageId: string): Promise<StopManualRecoveryResult>;
41
+ export declare function httpAbandonStage(base: string, runId: string, stageId: string): Promise<AbandonStageResult>;
42
+ export declare function resolveAbsolute(cwd: string, maybeRelative: string): string;
43
+ export {};
@@ -0,0 +1,182 @@
1
+ import path from "node:path";
2
+ import { globalStageflowHome } from "../project/globalHome.js";
3
+ import { PipelineValidationError } from "../runtime/pipelineValidationError.js";
4
+ import { runWorkspaceDir, storeRootFor } from "../runstore/paths.js";
5
+ async function postJson(base, urlPath, body) {
6
+ const res = await fetch(`${base}${urlPath}`, {
7
+ method: "POST",
8
+ headers: { "Content-Type": "application/json" },
9
+ body: JSON.stringify(body ?? {}),
10
+ });
11
+ return { status: res.status, body: await parseJsonBody(res) };
12
+ }
13
+ async function getJson(base, urlPath) {
14
+ const res = await fetch(`${base}${urlPath}`);
15
+ return { status: res.status, body: await parseJsonBody(res) };
16
+ }
17
+ async function parseJsonBody(res) {
18
+ const text = await res.text();
19
+ if (text.length === 0)
20
+ return undefined;
21
+ try {
22
+ return JSON.parse(text);
23
+ }
24
+ catch {
25
+ return undefined;
26
+ }
27
+ }
28
+ function extractError(body, status) {
29
+ if (body && typeof body === "object" && typeof body.error === "string") {
30
+ return body.error;
31
+ }
32
+ return `request to global Stageflow service failed (status ${status})`;
33
+ }
34
+ function enc(value) {
35
+ return encodeURIComponent(value);
36
+ }
37
+ export function computeRunDir(runId) {
38
+ return runWorkspaceDir(storeRootFor(globalStageflowHome()), runId);
39
+ }
40
+ export async function httpReadRun(base, runId) {
41
+ const { status, body } = await getJson(base, `/api/runs/${enc(runId)}`);
42
+ if (status !== 200) {
43
+ throw new Error(extractError(body, status));
44
+ }
45
+ return body;
46
+ }
47
+ /** Thin RunStore-shaped reader backed by the global service, for the CLI output helpers that only need `readRun`. */
48
+ export function httpStoreReader(base) {
49
+ return { readRun: (runId) => httpReadRun(base, runId) };
50
+ }
51
+ function isRunTerminal(detail) {
52
+ return (detail.status === "succeeded" ||
53
+ detail.status === "failed" ||
54
+ (detail.status === "running" && detail.waiting_stage_id !== undefined));
55
+ }
56
+ function sleep(ms) {
57
+ return new Promise((resolve) => setTimeout(resolve, ms));
58
+ }
59
+ export async function pollRunUntilTerminal(base, runId, options) {
60
+ const pollIntervalMs = options?.pollIntervalMs ?? 500;
61
+ for (;;) {
62
+ const detail = await httpReadRun(base, runId);
63
+ if (isRunTerminal(detail))
64
+ return detail;
65
+ await sleep(pollIntervalMs);
66
+ }
67
+ }
68
+ export function runDetailToPipelineRunResult(detail) {
69
+ const outcome = detail.status === "succeeded"
70
+ ? "succeeded"
71
+ : detail.status === "failed"
72
+ ? "failed"
73
+ : "waiting";
74
+ return {
75
+ ok: outcome === "succeeded",
76
+ outcome,
77
+ runId: detail.run_id,
78
+ runDir: computeRunDir(detail.run_id),
79
+ ...(outcome === "failed" && detail.failed_reason !== undefined
80
+ ? { reason: detail.failed_reason }
81
+ : {}),
82
+ };
83
+ }
84
+ function toStartFailure(status, body) {
85
+ const rest = body && typeof body === "object" ? { ...body } : {};
86
+ const error = typeof rest.error === "string" ? rest.error : undefined;
87
+ delete rest.error;
88
+ return {
89
+ ok: false,
90
+ reason: error ?? extractError(body, status),
91
+ status,
92
+ ...rest,
93
+ };
94
+ }
95
+ function validationResultFrom(body) {
96
+ if (body && typeof body === "object" && "validation" in body) {
97
+ return body.validation;
98
+ }
99
+ return undefined;
100
+ }
101
+ export async function httpStartRun(base, input) {
102
+ const { status, body } = await postJson(base, "/api/runs", input);
103
+ if (status === 400) {
104
+ const validation = validationResultFrom(body);
105
+ if (validation !== undefined)
106
+ throw new PipelineValidationError(validation);
107
+ }
108
+ if (status !== 202)
109
+ return toStartFailure(status, body);
110
+ const runId = body.runId;
111
+ return {
112
+ ok: true,
113
+ runId,
114
+ done: pollRunUntilTerminal(base, runId).then(runDetailToPipelineRunResult),
115
+ };
116
+ }
117
+ export async function httpRerun(base, runId) {
118
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/rerun`, {});
119
+ if (status !== 202)
120
+ return toStartFailure(status, body);
121
+ const newRunId = body.runId;
122
+ return {
123
+ ok: true,
124
+ runId: newRunId,
125
+ done: pollRunUntilTerminal(base, newRunId).then(runDetailToPipelineRunResult),
126
+ };
127
+ }
128
+ export async function httpDeliverAnswer(base, runId, stageId, answer) {
129
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/answer`, answer);
130
+ if (status === 202)
131
+ return { ok: true };
132
+ return { ok: false, reason: extractError(body, status), status: status };
133
+ }
134
+ export async function httpDecideFeedbackLoop(base, runId, stageId, input) {
135
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/feedback-decision`, input);
136
+ if (status === 202) {
137
+ const parsed = body;
138
+ return { ok: true, effect: parsed.effect, loopId: parsed.loopId };
139
+ }
140
+ return { ok: false, reason: extractError(body, status), status };
141
+ }
142
+ export async function httpRetryStageUntilStop(base, runId, stageId) {
143
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/retry`, {});
144
+ if (status !== 202) {
145
+ return { ok: false, reason: extractError(body, status), status };
146
+ }
147
+ const detail = await pollRunUntilTerminal(base, runId);
148
+ return { ok: true, pipeline: runDetailToPipelineRunResult(detail) };
149
+ }
150
+ export async function httpResumeTimedOutStage(base, runId, stageId) {
151
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/resume`, {});
152
+ if (status === 202) {
153
+ const parsed = body;
154
+ return { ok: true, runId: parsed.runId, stageId: parsed.stageId, attemptIndex: parsed.attemptIndex };
155
+ }
156
+ return { ok: false, reason: extractError(body, status), status };
157
+ }
158
+ export async function httpRecoverManualStageUntilStop(base, runId, stageId, guidance) {
159
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/recovery`, guidance !== undefined ? { guidance } : {});
160
+ if (status !== 202) {
161
+ return { ok: false, reason: extractError(body, status), status };
162
+ }
163
+ const detail = await pollRunUntilTerminal(base, runId);
164
+ return { ok: true, pipeline: runDetailToPipelineRunResult(detail) };
165
+ }
166
+ export async function httpStopManualRecovery(base, runId, stageId) {
167
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/recovery/stop`, {});
168
+ if (status === 202)
169
+ return body;
170
+ return { ok: false, reason: extractError(body, status), status };
171
+ }
172
+ export async function httpAbandonStage(base, runId, stageId) {
173
+ const { status, body } = await postJson(base, `/api/runs/${enc(runId)}/stages/${enc(stageId)}/abandon`, {});
174
+ if (status === 202) {
175
+ const parsed = body;
176
+ return { ok: true, runId: parsed.runId, stageId: parsed.stageId };
177
+ }
178
+ return { ok: false, reason: extractError(body, status), status };
179
+ }
180
+ export function resolveAbsolute(cwd, maybeRelative) {
181
+ return path.resolve(cwd, maybeRelative);
182
+ }
@@ -1,4 +1,5 @@
1
- import { defaultContext, detectPiHome, getAuthStatus, getCredentialSourceSettings, listProviders, loginWithApiKey, loginWithOauth, logoutProvider, ProviderAuthError, setCredentialSource, } from "../agent/providerAuth.js";
1
+ import { defaultContext, detectPiHome, getAuthStatus, getCredentialSourceSettings, listProviders, loginWithApiKey, loginWithOauth, logoutProvider, setCredentialSource, } from "../agent/providerAuth.js";
2
+ import { mapProviderAuthError } from "../agent/providerInspect.js";
2
3
  import { createTerminalAuthInteraction } from "./terminalAuthInteraction.js";
3
4
  import { promptSecret, readApiKeyFromEnv } from "./terminalSecret.js";
4
5
  export const PROVIDERS_USAGE = `Usage:
@@ -152,8 +153,9 @@ export async function runProvidersCommand(args, cwd, io = {}, ctx = defaultConte
152
153
  return 0;
153
154
  }
154
155
  catch (err) {
155
- if (err instanceof ProviderAuthError && err.status === 404) {
156
- out.error("Provider not found");
156
+ const mapped = mapProviderAuthError(err);
157
+ if (mapped.status === 404) {
158
+ out.error(mapped.body.error);
157
159
  return 1;
158
160
  }
159
161
  throw err;
@@ -1,5 +1,6 @@
1
1
  import type { RunStore } from "../runstore/port.js";
2
- import { type StartRunResult } from "../runtime/runManager.js";
2
+ import type { StartRunResult } from "../runtime/runManager.js";
3
+ import { type EnsureGlobalServiceResult } from "../server/ensureGlobalService.js";
3
4
  import { type CliRunReportIo } from "./runOutput.js";
4
5
  export declare const RUN_USAGE = "Usage:\n sf run --task <path> --pipeline <path> [--checkout <path>] [--json] [--include stages] [--skip-gates] [--git-sha <sha>] [--ci-pr-url <url>] [--ci-job-url <url>] [--operator-cwd <path>] [--operator-agent-dir <path>]";
5
6
  export type RunCommandIo = CliRunReportIo;
@@ -16,15 +17,15 @@ export declare function completeCliRun(started: Extract<StartRunResult, {
16
17
  ok: true;
17
18
  }>, io?: RunCommandIo, options?: {
18
19
  json?: boolean;
19
- store?: RunStore;
20
+ store?: Pick<RunStore, "readRun">;
20
21
  includeStages?: boolean;
21
22
  }): Promise<number>;
22
23
  export declare function runRunCommand(args: string[], options?: {
23
24
  cwd?: string;
24
- projectRoot?: string;
25
- isGitProject?: boolean;
26
25
  io?: Partial<RunCommandIo>;
27
26
  startRun?: StartRunFn;
28
- store?: RunStore;
27
+ store?: Pick<RunStore, "readRun">;
29
28
  env?: Record<string, string | undefined>;
29
+ hostBaseUrl?: string;
30
+ ensureService?: () => Promise<EnsureGlobalServiceResult>;
30
31
  }): Promise<number>;
@@ -1,11 +1,8 @@
1
- import { resolveGlobalOnlyAgentPort } from "../agent/resolveAgentPort.js";
2
- import { createRunStore } from "../runstore/createStore.js";
3
1
  import { PipelineValidationError } from "../runtime/pipelineRunner.js";
4
- import { RunManager } from "../runtime/runManager.js";
5
- import { readStageExecutionMode } from "../runtime/stageConcurrency.js";
2
+ import { ensureGlobalService, hostBaseUrl, } from "../server/ensureGlobalService.js";
3
+ import { httpStartRun, httpStoreReader, resolveAbsolute } from "./hostClient.js";
6
4
  import { reportCliRun, } from "./runOutput.js";
7
5
  import { resolveCiIdentity } from "./ciIdentity.js";
8
- import { resolveOperatorCatalog } from "./operatorCatalog.js";
9
6
  import { exitCodeForValidation, formatValidationHuman, formatValidationJson, } from "./validateOutput.js";
10
7
  export const RUN_USAGE = `Usage:
11
8
  sf run --task <path> --pipeline <path> [--checkout <path>] [--json] [--include stages] [--skip-gates] [--git-sha <sha>] [--ci-pr-url <url>] [--ci-job-url <url>] [--operator-cwd <path>] [--operator-agent-dir <path>]`;
@@ -133,19 +130,23 @@ function parseRunArgs(args) {
133
130
  operatorAgentDir,
134
131
  };
135
132
  }
136
- function defaultStartRun(cwd, projectRoot, isGitProject, operatorCatalog) {
133
+ function defaultStartRun(cwd, base, ensureService) {
137
134
  return async (input) => {
138
- const store = createRunStore({ rootDir: projectRoot });
139
- const manager = new RunManager({
140
- agent: await resolveGlobalOnlyAgentPort(projectRoot),
141
- store,
142
- cwd,
143
- projectRoot,
144
- isGitProject,
145
- operatorCatalog,
146
- executionMode: readStageExecutionMode(process.env, "process"),
135
+ const ensured = await ensureService();
136
+ if (!ensured.ok) {
137
+ return { ok: false, reason: ensured.message, status: 503 };
138
+ }
139
+ return httpStartRun(base, {
140
+ pipeline: resolveAbsolute(cwd, input.pipeline),
141
+ task: resolveAbsolute(cwd, input.task),
142
+ ...(input.checkoutOverride !== undefined
143
+ ? { checkoutOverride: resolveAbsolute(cwd, input.checkoutOverride) }
144
+ : {}),
145
+ ...(input.skipGates !== undefined ? { skipGates: input.skipGates } : {}),
146
+ ...(input.gitSha !== undefined ? { gitSha: input.gitSha } : {}),
147
+ ...(input.ciPrUrl !== undefined ? { ciPrUrl: input.ciPrUrl } : {}),
148
+ ...(input.ciJobUrl !== undefined ? { ciJobUrl: input.ciJobUrl } : {}),
147
149
  });
148
- return manager.startRun(input);
149
150
  };
150
151
  }
151
152
  export async function completeCliRun(started, io = defaultIo, options = {}) {
@@ -159,9 +160,8 @@ export async function completeCliRun(started, io = defaultIo, options = {}) {
159
160
  }
160
161
  export async function runRunCommand(args, options = {}) {
161
162
  const cwd = options.cwd ?? process.cwd();
162
- const projectRoot = options.projectRoot ?? cwd;
163
- const isGitProject = options.isGitProject ?? false;
164
163
  const out = { ...defaultIo, ...options.io };
164
+ const base = options.hostBaseUrl ?? hostBaseUrl();
165
165
  let parsed;
166
166
  try {
167
167
  parsed = parseRunArgs(args);
@@ -185,16 +185,11 @@ export async function runRunCommand(args, options = {}) {
185
185
  out.error("error: --include stages requires --json");
186
186
  return 1;
187
187
  }
188
- const operatorCatalog = resolveOperatorCatalog({
189
- flags: {
190
- operatorCwd: parsed.operatorCwd,
191
- operatorAgentDir: parsed.operatorAgentDir,
192
- },
193
- env: options.env ?? process.env,
194
- defaultCwd: cwd,
195
- });
188
+ if (parsed.operatorCwd !== undefined || parsed.operatorAgentDir !== undefined) {
189
+ out.error("warning: --operator-cwd/--operator-agent-dir have no effect on `sf run` now that pipelines execute in the shared global Stageflow service; set STAGEFLOW_OPERATOR_CWD/STAGEFLOW_OPERATOR_AGENT_DIR before that service first starts instead.");
190
+ }
196
191
  const startRun = options.startRun ??
197
- defaultStartRun(cwd, projectRoot, isGitProject, operatorCatalog);
192
+ defaultStartRun(cwd, base, options.ensureService ?? (() => ensureGlobalService()));
198
193
  const identity = resolveCiIdentity({
199
194
  flags: {
200
195
  gitSha: parsed.gitSha,
@@ -203,10 +198,7 @@ export async function runRunCommand(args, options = {}) {
203
198
  },
204
199
  env: options.env ?? process.env,
205
200
  });
206
- const store = options.store ??
207
- (parsed.includeStages
208
- ? createRunStore({ rootDir: projectRoot })
209
- : undefined);
201
+ const store = options.store ?? (parsed.includeStages ? httpStoreReader(base) : undefined);
210
202
  try {
211
203
  const started = await startRun({
212
204
  task: parsed.task,
@@ -17,6 +17,6 @@ export type CliRunReportEvent = {
17
17
  export declare function reportCliRun(event: CliRunReportEvent, options: {
18
18
  json?: boolean;
19
19
  io: CliRunReportIo;
20
- store?: RunStore;
20
+ store?: Pick<RunStore, "readRun">;
21
21
  includeStages?: boolean;
22
22
  }): Promise<number>;
@@ -1,22 +1,18 @@
1
1
  import type { RunStore } from "../runstore/port.js";
2
- import { RunManager } from "../runtime/runManager.js";
3
- export declare const RUNS_USAGE = "Usage:\n sf runs list [--status created|running|succeeded|failed] [--since <iso>] [--pipeline <id-or-path>] [--json]\n sf runs show --run <runId> [--from <sf-run.json>] [--json]\n sf runs verify --run <runId> --stage <stageId> [--json]\n sf runs recover --run <runId> --stage <stageId> [--guidance <text>] [--stop] [--json]\n sf runs waiting [--run <runId>] [--json]\n sf runs wait --run <runId> [--from <sf-run.json>] [--until any|waiting|terminal] [--timeout-ms <n>] [--json]\n sf runs answer --run <runId> --stage <stageId> [--answer '<json>'] [--json]\n sf runs feedback-decide --run <runId> --stage <sourceStageId> [--loop <loopId>] --decision extend|continue|abandon [--reason <text>] [--json]\n sf runs retry --run <runId> --stage <stageId> [--json]\n sf runs abandon --run <runId> --stage <stageId> [--json]\n sf runs rerun --run <runId> [--json]";
2
+ import { type EnsureGlobalServiceResult } from "../server/ensureGlobalService.js";
3
+ export declare const RUNS_USAGE = "Usage:\n sf runs list [--status created|running|succeeded|failed] [--since <iso>] [--pipeline <id-or-path>] [--json]\n sf runs show --run <runId> [--from <sf-run.json>] [--json]\n sf runs verify --run <runId> --stage <stageId> [--json]\n sf runs recover --run <runId> --stage <stageId> [--guidance <text>] [--stop] [--json]\n sf runs waiting [--run <runId>] [--json]\n sf runs wait --run <runId> [--from <sf-run.json>] [--until any|waiting|terminal] [--timeout-ms <n>] [--json]\n sf runs answer --run <runId> --stage <stageId> [--answer '<json>'] [--json]\n sf runs feedback-decide --run <runId> --stage <sourceStageId> [--loop <loopId>] --decision extend|continue|abandon [--reason <text>] [--json]\n sf runs retry --run <runId> --stage <stageId> [--json]\n sf runs resume --run <runId> --stage <stageId> [--json]\n sf runs abandon --run <runId> --stage <stageId> [--json]\n sf runs rerun --run <runId> [--json]";
4
4
  export type RunsCommandIo = {
5
5
  log: (line: string) => void;
6
6
  error: (line: string) => void;
7
7
  };
8
- export type HostProbeResult = "up" | "down";
9
- export declare function defaultProbeHost(): Promise<HostProbeResult>;
10
8
  export declare function runRunsCommand(args: string[], options?: {
11
9
  cwd?: string;
12
- projectRoot?: string;
13
- isGitProject?: boolean;
14
10
  io?: Partial<RunsCommandIo>;
15
11
  store?: RunStore;
16
- probeHost?: () => Promise<HostProbeResult>;
17
12
  stdinIsTTY?: boolean;
18
13
  readStdin?: () => string;
19
14
  waitSignal?: AbortSignal;
20
15
  env?: NodeJS.ProcessEnv;
21
- createManager?: (store: RunStore) => RunManager;
16
+ hostBaseUrl?: string;
17
+ ensureService?: () => Promise<EnsureGlobalServiceResult>;
22
18
  }): Promise<number>;