stageflow 0.19.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/a2a/configDiscovery.d.ts +9 -0
- package/dist/a2a/configDiscovery.js +18 -0
- package/dist/a2a/contracts.d.ts +93 -0
- package/dist/a2a/contracts.js +163 -0
- package/dist/a2a/limits.d.ts +14 -0
- package/dist/a2a/limits.js +29 -0
- package/dist/a2a/registry.d.ts +44 -0
- package/dist/a2a/registry.js +159 -0
- package/dist/a2a/server.d.ts +29 -0
- package/dist/a2a/server.js +341 -0
- package/dist/a2a/service.d.ts +97 -0
- package/dist/a2a/service.js +496 -0
- package/dist/a2a/store.d.ts +106 -0
- package/dist/a2a/store.js +245 -0
- package/dist/agent/activity.d.ts +5 -0
- package/dist/agent/activityObserver.d.ts +3 -0
- package/dist/agent/activityObserver.js +6 -1
- package/dist/agent/piAdapter.js +7 -3
- package/dist/agent/port.d.ts +2 -0
- package/dist/agent/providerInspect.d.ts +19 -0
- package/dist/agent/providerInspect.js +35 -0
- package/dist/agent/streamLogRedact.d.ts +2 -0
- package/dist/agent/streamLogRedact.js +13 -0
- package/dist/cli/a2aCommand.d.ts +8 -0
- package/dist/cli/a2aCommand.js +131 -0
- package/dist/cli/artifactCommand.js +2 -2
- package/dist/cli/envelopeCommand.js +2 -2
- package/dist/cli/exportRunCommand.js +2 -2
- package/dist/cli/hostClient.d.ts +43 -0
- package/dist/cli/hostClient.js +182 -0
- package/dist/cli/providersCommand.js +5 -3
- package/dist/cli/runCommand.d.ts +6 -5
- package/dist/cli/runCommand.js +23 -31
- package/dist/cli/runOutput.d.ts +1 -1
- package/dist/cli/runStageCommand.d.ts +33 -0
- package/dist/cli/runStageCommand.js +407 -0
- package/dist/cli/runsCommand.d.ts +3 -7
- package/dist/cli/runsCommand.js +33 -94
- package/dist/cli.js +20 -5
- package/dist/config/describePipeline.d.ts +26 -0
- package/dist/config/describePipeline.js +37 -0
- package/dist/config/loadPipeline.d.ts +13 -1
- package/dist/config/loadPipeline.js +34 -4
- package/dist/config/mergePipelineIncludes.d.ts +11 -0
- package/dist/config/mergePipelineIncludes.js +75 -0
- package/dist/config/validateCatalog.d.ts +2 -2
- package/dist/config/validateCatalog.js +24 -17
- package/dist/mcp/catalogTools.js +285 -52
- package/dist/mcp/controlTools.js +77 -19
- package/dist/mcp/deps.d.ts +3 -0
- package/dist/mcp/projectMcpTools.d.ts +3 -0
- package/dist/mcp/projectMcpTools.js +25 -0
- package/dist/mcp/providerTools.d.ts +3 -0
- package/dist/mcp/providerTools.js +17 -0
- package/dist/mcp/readArtifact.d.ts +9 -0
- package/dist/mcp/readArtifact.js +11 -0
- package/dist/mcp/server.js +9 -1
- package/dist/mcp/tailStreamLog.d.ts +8 -0
- package/dist/mcp/tailStreamLog.js +28 -0
- package/dist/mcp/toolResults.d.ts +17 -0
- package/dist/mcp/toolResults.js +15 -0
- package/dist/mcp/tools.js +4 -0
- package/dist/mcp/waitRun.js +4 -4
- package/dist/mcp/waitingGates.d.ts +1 -0
- package/dist/mcp/waitingGates.js +3 -2
- package/dist/package-meta.d.ts +1 -1
- package/dist/package-meta.js +1 -1
- package/dist/projection/projectRun.d.ts +3 -0
- package/dist/projection/projectRun.js +7 -0
- package/dist/runstore/createStore.d.ts +10 -0
- package/dist/runstore/createStore.js +13 -4
- package/dist/runstore/port.d.ts +17 -2
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +11 -1
- package/dist/runstore/sqlite/SqliteRunStore.js +81 -26
- package/dist/runstore/sqlite/schema.d.ts +1 -1
- package/dist/runstore/sqlite/schema.js +6 -0
- package/dist/runstore/submission.d.ts +11 -0
- package/dist/runstore/submission.js +7 -0
- package/dist/runstore/workspaceLayout.d.ts +1 -0
- package/dist/runstore/workspaceLayout.js +3 -0
- package/dist/runtime/feedbackLoopCoordinator.d.ts +9 -1
- package/dist/runtime/feedbackLoopCoordinator.js +50 -20
- package/dist/runtime/feedbackLoopDecision.js +33 -1
- package/dist/runtime/pipelineRunner.d.ts +5 -3
- package/dist/runtime/pipelineRunner.js +6 -1
- package/dist/runtime/pipelineScheduler.js +32 -15
- package/dist/runtime/reloadRunCatalog.js +7 -1
- package/dist/runtime/resolveEnvelopeRef.d.ts +30 -0
- package/dist/runtime/resolveEnvelopeRef.js +79 -0
- package/dist/runtime/resumeReconstruct.js +2 -2
- package/dist/runtime/runManager.d.ts +24 -2
- package/dist/runtime/runManager.js +83 -19
- package/dist/runtime/settingsFile.d.ts +2 -0
- package/dist/runtime/settingsFile.js +19 -0
- package/dist/runtime/stageAttemptBootstrap.d.ts +3 -0
- package/dist/runtime/stageAttemptBootstrap.js +8 -2
- package/dist/runtime/stageStreamLog.d.ts +17 -0
- package/dist/runtime/stageStreamLog.js +89 -0
- package/dist/runtime/stageWorker.js +2 -1
- package/dist/server/bootstrap.d.ts +2 -0
- package/dist/server/bootstrap.js +22 -4
- package/dist/server/createHttpHost.js +6 -0
- package/dist/server/ensureGlobalService.d.ts +35 -0
- package/dist/server/ensureGlobalService.js +138 -0
- package/dist/server/http.d.ts +20 -1
- package/dist/server/http.js +450 -402
- package/dist/server/mcpHost.js +7 -8
- package/dist/server/operatorResults.d.ts +10 -0
- package/dist/server/operatorResults.js +24 -0
- package/dist/server/providerRoutes.d.ts +0 -6
- package/dist/server/providerRoutes.js +10 -18
- package/dist/types/pipeline.d.ts +8 -0
- package/dist/ui/assets/{index-DMVdl1qB.js → index-Da5EHU6M.js} +5 -5
- package/dist/ui/index.html +1 -1
- package/package.json +2 -1
- package/skills/stageflow/references/control-surface.md +2 -2
- package/skills/stageflow-run/SKILL.md +27 -9
- package/skills/stageflow-run/references/mcp-call.md +1 -1
- package/skills/stageflow-run/scripts/mcp-call.mjs +9 -0
|
@@ -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,
|
|
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
|
-
|
|
156
|
-
|
|
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;
|
package/dist/cli/runCommand.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RunStore } from "../runstore/port.js";
|
|
2
|
-
import {
|
|
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>;
|
package/dist/cli/runCommand.js
CHANGED
|
@@ -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 {
|
|
5
|
-
import {
|
|
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,
|
|
133
|
+
function defaultStartRun(cwd, base, ensureService) {
|
|
137
134
|
return async (input) => {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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,
|
|
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,
|
package/dist/cli/runOutput.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type EnsureGlobalServiceResult } from "../server/ensureGlobalService.js";
|
|
2
|
+
export declare const RUN_STAGE_USAGE = "Usage:\n sf run-stage (--stage <path> | --stage-inline '<json>') (--task <path> | --task-inline '<json>' | --envelope-ref <runId>:<stageId>[:<attempt>] [--envelope-ref ...]) [--checkout <path>] [--model <id>] [--blocking] [--timeout-ms <n>] [--json]\n\nRun a single stage directly against the shared Stageflow service, without authoring a pipeline file. Distinct from the internal-only, worker-process-only `sf internal run-stage`.\n --stage <path> Filesystem path to a catalog stage YAML file\n --stage-inline <json> Inline stage body object ({ id, system_prompt, io, ... } \u2014 no uses:/route/pipeline wrapper)\n --task <path> Filesystem path to a catalog task YAML file\n --task-inline <json> Inline task object ({ id, goal, ... })\n --envelope-ref <ref> Resolve a previously stored StageEnvelope as this stage's input instead of a task: <runId>:<stageId>[:<attempt>]. Repeat to pass more than one \u2014 each resolved payload is namespaced under its stageId in input (disambiguated by runId on a stageId collision), and summaries are combined into goal.\n --checkout <path> Optional checkout to use with --envelope-ref (--task/--task-inline carry their own checkout)\n --model <id> Override the model/backend for this call only, ahead of the stage's own declared model\n --blocking Wait for the run to reach a terminal or waiting state and print the result in this same call, instead of returning immediately with just the run id\n --timeout-ms <n> Wait budget in ms when --blocking is set\n --json Machine-readable JSON output";
|
|
3
|
+
export type RunStageEnvelopeRef = {
|
|
4
|
+
runId: string;
|
|
5
|
+
stageId: string;
|
|
6
|
+
attempt?: number;
|
|
7
|
+
};
|
|
8
|
+
export type RunStageToolArgs = {
|
|
9
|
+
stage: string | Record<string, unknown>;
|
|
10
|
+
task_path?: string;
|
|
11
|
+
task?: Record<string, unknown>;
|
|
12
|
+
envelope_ref?: RunStageEnvelopeRef | RunStageEnvelopeRef[];
|
|
13
|
+
checkout?: string;
|
|
14
|
+
model?: string;
|
|
15
|
+
blocking?: boolean;
|
|
16
|
+
timeout_ms?: number;
|
|
17
|
+
};
|
|
18
|
+
export type RunStageToolResult = {
|
|
19
|
+
isError: boolean;
|
|
20
|
+
payload: Record<string, unknown> | null;
|
|
21
|
+
};
|
|
22
|
+
export type RunStageCallFn = (args: RunStageToolArgs) => Promise<RunStageToolResult>;
|
|
23
|
+
export type RunStageCommandIo = {
|
|
24
|
+
log: (line: string) => void;
|
|
25
|
+
error: (line: string) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare function runRunStageCommand(args: string[], options?: {
|
|
28
|
+
cwd?: string;
|
|
29
|
+
io?: Partial<RunStageCommandIo>;
|
|
30
|
+
callTool?: RunStageCallFn;
|
|
31
|
+
hostBaseUrl?: string;
|
|
32
|
+
ensureService?: () => Promise<EnsureGlobalServiceResult>;
|
|
33
|
+
}): Promise<number>;
|