acpus 0.0.1
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/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +3860 -0
- package/dist/index.d.mts +2742 -0
- package/dist/index.mjs +2 -0
- package/dist/monitor-app-CSjUPe9j.mjs +434 -0
- package/dist/run-workflow-CbxKhAqF.mjs +13586 -0
- package/package.json +76 -0
- package/schemas/workflow-spec.schema.json +2042 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as ReduceStageSchema, A as renderStagePrompt, B as DecisionRuleSchema, C as collectWorkflowOutputCandidates, D as repairFailedEnvelope, E as isRepairableOutputFailure, F as ArtifactSchema, G as FindingSchema, H as FanoutLaneGroupSchema, I as BaseOutputSchema, J as ImplementationOutputSchema, K as GateOutputSchema, L as CheckSchema, M as topologicalOrder, N as EXECUTION_PLAN_VERSION, O as compileExecutionPlan, P as AgentTaskStageSchema, Q as LoopStageSchema, R as ConditionSchema, S as syncRun, T as formatRepairPrompt, U as FanoutLaneSchema, V as DiscoverStageSchema, W as FanoutStageSchema, X as InputTypeSchema, Y as InputDeclarationSchema, Z as LoopBodyStageSchema, _t as RUN_DIAGNOSTICS_VIEW_VERSION, a as previewRunView, at as StageLimitsSchema, b as issue, bt as readNdjsonTail, c as TASK_DETAIL_VIEW_VERSION, ct as TransformSchema, dt as WorkflowLimitsSchema, et as RoleCategorySchema, ft as WorkflowSpecSchema, g as lintWorkflowSpec, h as loadWorkflowSpec, ht as OutputContractNameSchema, i as estimateFanoutWork, it as SeverityCountsSchema, j as stageRoleName, k as renderPromptMap, l as buildRunMonitorView, lt as ValidationOutputSchema, mt as getOutputContract, n as startPreparedRun, nt as RoleSchema, o as runViewFromIndex, ot as StageSchema, pt as contractNameForStage, q as GateStageSchema, r as estimateAgentCalls, rt as SCHEMA_VERSION, s as RUN_MONITOR_VIEW_VERSION, st as SummarizeStageSchema, t as prepareRun, tt as RoleModeSchema, u as buildTaskDetailView, ut as VariableSchema, vt as RunDiagnosticCodes, w as parseWorkflowOutput, x as resultFromIssues, y as OrchestratorError, yt as buildRunDiagnosticsView, z as DecisionGateStageSchema } from "./run-workflow-CbxKhAqF.mjs";
|
|
2
|
+
export { AgentTaskStageSchema, ArtifactSchema, BaseOutputSchema, CheckSchema, ConditionSchema, DecisionGateStageSchema, DecisionRuleSchema, DiscoverStageSchema, EXECUTION_PLAN_VERSION, FanoutLaneGroupSchema, FanoutLaneSchema, FanoutStageSchema, FindingSchema, GateOutputSchema, GateStageSchema, ImplementationOutputSchema, InputDeclarationSchema, InputTypeSchema, LoopBodyStageSchema, LoopStageSchema, OrchestratorError, OutputContractNameSchema, RUN_DIAGNOSTICS_VIEW_VERSION, RUN_MONITOR_VIEW_VERSION, ReduceStageSchema, RoleCategorySchema, RoleModeSchema, RoleSchema, RunDiagnosticCodes, SCHEMA_VERSION, SeverityCountsSchema, StageLimitsSchema, StageSchema, SummarizeStageSchema, TASK_DETAIL_VIEW_VERSION, TransformSchema, ValidationOutputSchema, VariableSchema, WorkflowLimitsSchema, WorkflowSpecSchema, buildRunDiagnosticsView, buildRunMonitorView, buildTaskDetailView, collectWorkflowOutputCandidates, compileExecutionPlan, contractNameForStage, estimateAgentCalls, estimateFanoutWork, formatRepairPrompt, getOutputContract, isRepairableOutputFailure, issue, lintWorkflowSpec, loadWorkflowSpec, parseWorkflowOutput, prepareRun, previewRunView, readNdjsonTail, renderPromptMap, renderStagePrompt, repairFailedEnvelope, resultFromIssues, runViewFromIndex, stageRoleName, startPreparedRun, syncRun, topologicalOrder };
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { Dt as runDir, S as syncRun, ft as WorkflowSpecSchema, gt as resolveRunLocator, l as buildRunMonitorView, u as buildTaskDetailView } from "./run-workflow-CbxKhAqF.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Box, Text, useApp, useInput, useStdout } from "ink";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/tui/monitor-data.ts
|
|
8
|
+
async function loadMonitorSnapshot(runArg) {
|
|
9
|
+
const locator = await resolveRunLocator(runArg);
|
|
10
|
+
const index = await syncRun(locator.cwd, locator.runId, { startPending: false });
|
|
11
|
+
const spec = WorkflowSpecSchema.parse(JSON.parse(await fs.readFile(path.join(runDir(locator.runId, locator.cwd), "workflow.spec.json"), "utf8")));
|
|
12
|
+
return {
|
|
13
|
+
locator,
|
|
14
|
+
view: await buildRunMonitorView(locator.cwd, spec, index)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function loadTaskDetail(locator, taskId) {
|
|
18
|
+
const index = await syncRun(locator.cwd, locator.runId, { startPending: false });
|
|
19
|
+
const spec = WorkflowSpecSchema.parse(JSON.parse(await fs.readFile(path.join(runDir(locator.runId, locator.cwd), "workflow.spec.json"), "utf8")));
|
|
20
|
+
return buildTaskDetailView(locator.cwd, spec, index, taskId);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/tui/monitor-rendering.ts
|
|
24
|
+
function defaultStageIndex(stages) {
|
|
25
|
+
const running = stages.findIndex((stage) => stage.status === "running");
|
|
26
|
+
if (running >= 0) return running;
|
|
27
|
+
const blocked = stages.findIndex((stage) => stage.status === "blocked" || stage.status === "failed");
|
|
28
|
+
if (blocked >= 0) return blocked;
|
|
29
|
+
const open = stages.findIndex((stage) => stage.status !== "completed" && stage.status !== "skipped");
|
|
30
|
+
return open >= 0 ? open : 0;
|
|
31
|
+
}
|
|
32
|
+
function clampIndex(index, length) {
|
|
33
|
+
if (length <= 0) return 0;
|
|
34
|
+
return Math.min(Math.max(index, 0), length - 1);
|
|
35
|
+
}
|
|
36
|
+
function tasksForStage(view, stageId) {
|
|
37
|
+
if (!view || !stageId) return [];
|
|
38
|
+
return view.tasks.filter((task) => task.stageId === stageId);
|
|
39
|
+
}
|
|
40
|
+
function stageProgressLabel(stage) {
|
|
41
|
+
const counts = stage.taskCounts;
|
|
42
|
+
return `${counts.completed}/${counts.total}`;
|
|
43
|
+
}
|
|
44
|
+
function runProgressLabel(view) {
|
|
45
|
+
return `${view.progress.completedTasks}/${view.progress.knownTasks} tasks`;
|
|
46
|
+
}
|
|
47
|
+
function statusMark(status) {
|
|
48
|
+
if (status === "completed") return "✔";
|
|
49
|
+
if (status === "running" || status === "raw_received" || status === "parsing" || status === "repairing") return "●";
|
|
50
|
+
if (status === "blocked" || status === "failed" || status === "cancelled" || status === "timed_out") return "!";
|
|
51
|
+
if (status === "skipped") return "-";
|
|
52
|
+
return " ";
|
|
53
|
+
}
|
|
54
|
+
function shorten(value, width) {
|
|
55
|
+
if (!value) return "";
|
|
56
|
+
if (width <= 0) return "";
|
|
57
|
+
if (value.length <= width) return value;
|
|
58
|
+
if (width <= 3) return value.slice(0, width);
|
|
59
|
+
return `${value.slice(0, width - 3)}...`;
|
|
60
|
+
}
|
|
61
|
+
function detailSummary(detail) {
|
|
62
|
+
if (!detail) return ["No task selected"];
|
|
63
|
+
return [
|
|
64
|
+
`${statusMark(detail.task.status)} ${detail.task.status} - ${detail.task.execution}${detail.task.agent ? ` - ${detail.task.agent}` : ""}`,
|
|
65
|
+
detail.task.durationMs !== void 0 || detail.task.elapsedMs !== void 0 ? `Time: ${formatDuration(detail.task.durationMs ?? detail.task.elapsedMs ?? 0)}` : void 0,
|
|
66
|
+
detail.task.blockedReason ? `Reason: ${detail.task.blockedReason}` : void 0,
|
|
67
|
+
detail.outcome?.summary ? `Outcome: ${detail.outcome.summary}` : void 0,
|
|
68
|
+
detail.outcome?.path ? `Output: ${detail.outcome.path}` : void 0,
|
|
69
|
+
detail.prompt ? `Prompt: ${detail.prompt.lines} line(s)` : void 0,
|
|
70
|
+
detail.prompt?.preview ? detail.prompt.preview : void 0,
|
|
71
|
+
detail.activity.totalAttempts > 0 ? `Attempts: ${detail.activity.totalAttempts}` : "No agent attempts",
|
|
72
|
+
...detail.activity.attempts.map((attempt) => `${attempt.id} ${attempt.status} ${attempt.path}`),
|
|
73
|
+
...(detail.outcome?.artifacts ?? []).map((artifact) => `Artifact: ${artifact.label ?? artifact.kind ?? "artifact"} ${artifact.path ?? artifact.url ?? ""}`)
|
|
74
|
+
].filter((line) => typeof line === "string" && line.length > 0);
|
|
75
|
+
}
|
|
76
|
+
function nextIndex(current, delta, length) {
|
|
77
|
+
return clampIndex(current + delta, length);
|
|
78
|
+
}
|
|
79
|
+
function formatDuration(milliseconds) {
|
|
80
|
+
if (milliseconds === void 0 || !Number.isFinite(milliseconds)) return "";
|
|
81
|
+
const totalSeconds = Math.max(0, Math.floor(milliseconds / 1e3));
|
|
82
|
+
const seconds = totalSeconds % 60;
|
|
83
|
+
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
84
|
+
const minutes = totalMinutes % 60;
|
|
85
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
86
|
+
if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
|
|
87
|
+
if (minutes > 0) return `${minutes}m ${seconds}s`;
|
|
88
|
+
return `${seconds}s`;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/tui/monitor-app.tsx
|
|
92
|
+
function MonitorApp({ runArg, pollMs = 1e3, initialView, initialLocator, initialFocus = "stages", loadSnapshot = loadMonitorSnapshot, loadDetail = loadTaskDetail }) {
|
|
93
|
+
const { exit } = useApp();
|
|
94
|
+
const { stdout } = useStdout();
|
|
95
|
+
const [locator, setLocator] = useState(initialLocator);
|
|
96
|
+
const [view, setView] = useState(initialView);
|
|
97
|
+
const [error, setError] = useState();
|
|
98
|
+
const [focus, setFocus] = useState(initialFocus);
|
|
99
|
+
const [stageIndex, setStageIndex] = useState(() => initialView ? defaultStageIndex(initialView.stages) : 0);
|
|
100
|
+
const [taskIndex, setTaskIndex] = useState(void 0);
|
|
101
|
+
const [detailTaskId, setDetailTaskId] = useState();
|
|
102
|
+
const [detail, setDetail] = useState();
|
|
103
|
+
const refreshRequest = useRef(0);
|
|
104
|
+
const detailRequest = useRef(0);
|
|
105
|
+
const hasLoadedView = useRef(Boolean(initialView));
|
|
106
|
+
const userSelectedStage = useRef(false);
|
|
107
|
+
async function refresh() {
|
|
108
|
+
const requestId = ++refreshRequest.current;
|
|
109
|
+
try {
|
|
110
|
+
const snapshot = await loadSnapshot(runArg);
|
|
111
|
+
if (requestId !== refreshRequest.current) return;
|
|
112
|
+
const shouldSelectDefaultStage = !hasLoadedView.current && !userSelectedStage.current;
|
|
113
|
+
setLocator(snapshot.locator);
|
|
114
|
+
setView(snapshot.view);
|
|
115
|
+
setError(void 0);
|
|
116
|
+
setStageIndex((current) => {
|
|
117
|
+
if (shouldSelectDefaultStage) return defaultStageIndex(snapshot.view.stages);
|
|
118
|
+
return clampIndex(current, snapshot.view.stages.length);
|
|
119
|
+
});
|
|
120
|
+
hasLoadedView.current = true;
|
|
121
|
+
} catch (loadError) {
|
|
122
|
+
if (requestId !== refreshRequest.current) return;
|
|
123
|
+
setError(loadError instanceof Error ? loadError.message : String(loadError));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
refresh();
|
|
128
|
+
const timer = setInterval(() => void refresh(), pollMs);
|
|
129
|
+
return () => clearInterval(timer);
|
|
130
|
+
}, [
|
|
131
|
+
runArg,
|
|
132
|
+
pollMs,
|
|
133
|
+
loadSnapshot
|
|
134
|
+
]);
|
|
135
|
+
const selectedStage = view?.stages[stageIndex];
|
|
136
|
+
const stageTasks = useMemo(() => tasksForStage(view, selectedStage?.id), [view, selectedStage?.id]);
|
|
137
|
+
const selectedTask = taskIndex === void 0 ? void 0 : stageTasks[taskIndex];
|
|
138
|
+
const panelWidths = useMemo(() => monitorPanelWidths(stdout.columns), [stdout.columns]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
setTaskIndex(void 0);
|
|
141
|
+
setDetailTaskId(void 0);
|
|
142
|
+
setDetail(void 0);
|
|
143
|
+
}, [selectedStage?.id]);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
setTaskIndex((current) => current === void 0 ? void 0 : clampIndex(current, stageTasks.length));
|
|
146
|
+
}, [stageTasks.length]);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
setDetailTaskId(selectedTask?.id);
|
|
149
|
+
}, [selectedTask?.id]);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const requestId = ++detailRequest.current;
|
|
152
|
+
if (!locator || !detailTaskId) {
|
|
153
|
+
setDetail(void 0);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
setDetail(void 0);
|
|
157
|
+
loadDetail(locator, detailTaskId).then((nextDetail) => {
|
|
158
|
+
if (requestId !== detailRequest.current) return;
|
|
159
|
+
setDetail(nextDetail);
|
|
160
|
+
setError(void 0);
|
|
161
|
+
}).catch((detailError) => {
|
|
162
|
+
if (requestId !== detailRequest.current) return;
|
|
163
|
+
setDetail(void 0);
|
|
164
|
+
setError(detailError instanceof Error ? detailError.message : String(detailError));
|
|
165
|
+
});
|
|
166
|
+
}, [
|
|
167
|
+
locator?.runId,
|
|
168
|
+
detailTaskId,
|
|
169
|
+
loadDetail
|
|
170
|
+
]);
|
|
171
|
+
useInput((input, key) => {
|
|
172
|
+
if (input === "q" || key.ctrl && input === "c") exit();
|
|
173
|
+
if (input === "r") refresh();
|
|
174
|
+
if (key.escape && focus === "detail") {
|
|
175
|
+
setFocus("tasks");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (key.leftArrow) {
|
|
179
|
+
if (focus === "detail") setFocus("tasks");
|
|
180
|
+
else if (focus === "tasks") setFocus("stages");
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (key.rightArrow) {
|
|
184
|
+
if (focus === "stages" && stageTasks.length > 0) {
|
|
185
|
+
setTaskIndex((current) => current ?? 0);
|
|
186
|
+
setFocus("tasks");
|
|
187
|
+
} else if (focus === "tasks" && selectedTask) setFocus("detail");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (key.upArrow) {
|
|
191
|
+
if (focus === "tasks") setTaskIndex((current) => nextIndex(current ?? 0, -1, stageTasks.length));
|
|
192
|
+
else if (focus === "stages") {
|
|
193
|
+
userSelectedStage.current = true;
|
|
194
|
+
setStageIndex((current) => nextIndex(current, -1, view?.stages.length ?? 0));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (key.downArrow) {
|
|
198
|
+
if (focus === "tasks") setTaskIndex((current) => nextIndex(current ?? 0, 1, stageTasks.length));
|
|
199
|
+
else if (focus === "stages") {
|
|
200
|
+
userSelectedStage.current = true;
|
|
201
|
+
setStageIndex((current) => nextIndex(current, 1, view?.stages.length ?? 0));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (key.return && focus === "tasks" && selectedTask) setFocus("detail");
|
|
205
|
+
});
|
|
206
|
+
if (!view) return /* @__PURE__ */ jsx(Text, { children: error ? `Error: ${error}` : "Loading monitor..." });
|
|
207
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
208
|
+
flexDirection: "column",
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx(Header, { view }),
|
|
211
|
+
error ? /* @__PURE__ */ jsxs(Text, {
|
|
212
|
+
color: "red",
|
|
213
|
+
children: ["Error: ", error]
|
|
214
|
+
}) : null,
|
|
215
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
216
|
+
marginTop: 1,
|
|
217
|
+
children: [
|
|
218
|
+
/* @__PURE__ */ jsx(StageList, {
|
|
219
|
+
view,
|
|
220
|
+
selectedIndex: stageIndex,
|
|
221
|
+
focused: focus === "stages",
|
|
222
|
+
width: panelWidths.stages
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ jsx(StageTaskPanel, {
|
|
225
|
+
view,
|
|
226
|
+
stage: selectedStage,
|
|
227
|
+
tasks: stageTasks,
|
|
228
|
+
selectedIndex: taskIndex,
|
|
229
|
+
focused: focus === "tasks",
|
|
230
|
+
width: panelWidths.tasks
|
|
231
|
+
}),
|
|
232
|
+
/* @__PURE__ */ jsx(DetailPanel, {
|
|
233
|
+
detail,
|
|
234
|
+
focused: focus === "detail",
|
|
235
|
+
width: panelWidths.detail
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ jsx(Text, {
|
|
240
|
+
dimColor: true,
|
|
241
|
+
children: "up/down move - left/right panel - enter detail - esc back - r refresh - q quit"
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function Header({ view }) {
|
|
247
|
+
const title = `${view.run.workflowName}`;
|
|
248
|
+
const worker = view.run.worker ? ` - worker ${view.run.worker.status}` : "";
|
|
249
|
+
const runTime = formatDuration(view.run.durationMs ?? view.run.elapsedMs);
|
|
250
|
+
const meta = `${runProgressLabel(view)} - ${view.run.status}${runTime ? ` - ${runTime}` : ""}${worker}`;
|
|
251
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
252
|
+
flexDirection: "column",
|
|
253
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
254
|
+
color: "blue",
|
|
255
|
+
bold: true,
|
|
256
|
+
children: title
|
|
257
|
+
}), /* @__PURE__ */ jsxs(Text, {
|
|
258
|
+
dimColor: true,
|
|
259
|
+
children: [
|
|
260
|
+
shorten(view.run.logicalRunId, 48),
|
|
261
|
+
" - ",
|
|
262
|
+
meta
|
|
263
|
+
]
|
|
264
|
+
})]
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function StageList({ view, selectedIndex, focused, width }) {
|
|
268
|
+
const currentStage = view.stages.find((stage) => stage.status === "running") ?? view.stages.find((stage) => stage.status === "blocked" || stage.status === "failed") ?? view.stages[selectedIndex];
|
|
269
|
+
const finished = view.stages.filter((stage) => stage.status === "completed" || stage.status === "skipped").length;
|
|
270
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
271
|
+
flexDirection: "column",
|
|
272
|
+
width,
|
|
273
|
+
borderStyle: "single",
|
|
274
|
+
paddingX: 1,
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
277
|
+
bold: true,
|
|
278
|
+
children: [focused ? "🟢 " : " ", "Stage List"]
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
281
|
+
dimColor: true,
|
|
282
|
+
children: ["Current: ", shorten(currentStage?.id ?? "-", Math.max(6, width - 13))]
|
|
283
|
+
}),
|
|
284
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
285
|
+
dimColor: true,
|
|
286
|
+
children: [
|
|
287
|
+
"Finished: ",
|
|
288
|
+
finished,
|
|
289
|
+
"/",
|
|
290
|
+
view.stages.length
|
|
291
|
+
]
|
|
292
|
+
}),
|
|
293
|
+
view.stages.map((stage, index) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
294
|
+
/* @__PURE__ */ jsxs(Text, { children: [focused && index === selectedIndex ? "▶" : " ", " "] }),
|
|
295
|
+
/* @__PURE__ */ jsx(StatusMark, { status: stage.status }),
|
|
296
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
297
|
+
" ",
|
|
298
|
+
shorten(stage.id, 22),
|
|
299
|
+
" ",
|
|
300
|
+
stageProgressLabel(stage)
|
|
301
|
+
] })
|
|
302
|
+
] }, stage.id))
|
|
303
|
+
]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function StageTaskPanel({ view, stage, tasks, selectedIndex, focused, width }) {
|
|
307
|
+
const counts = stage?.taskCounts;
|
|
308
|
+
const stageTime = formatDuration(stage?.durationMs ?? stage?.elapsedMs);
|
|
309
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
310
|
+
flexDirection: "column",
|
|
311
|
+
width,
|
|
312
|
+
borderStyle: "single",
|
|
313
|
+
paddingX: 1,
|
|
314
|
+
children: [
|
|
315
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
316
|
+
bold: true,
|
|
317
|
+
children: [focused ? "🟢 " : " ", "Stage Info"]
|
|
318
|
+
}),
|
|
319
|
+
stage ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
320
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
321
|
+
shorten(stage.id, 28),
|
|
322
|
+
" ",
|
|
323
|
+
/* @__PURE__ */ jsx(Text, {
|
|
324
|
+
dimColor: true,
|
|
325
|
+
children: stage.kind
|
|
326
|
+
})
|
|
327
|
+
] }),
|
|
328
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
329
|
+
"Status: ",
|
|
330
|
+
stage.status,
|
|
331
|
+
counts ? ` - ${counts.completed}/${counts.total} tasks` : "",
|
|
332
|
+
stageTime ? ` - ${stageTime}` : ""
|
|
333
|
+
] }),
|
|
334
|
+
stage.dependsOn.length > 0 ? /* @__PURE__ */ jsxs(Text, {
|
|
335
|
+
dimColor: true,
|
|
336
|
+
children: ["Depends: ", shorten(stage.dependsOn.join(", "), 34)]
|
|
337
|
+
}) : null,
|
|
338
|
+
stage.blockedReason ? /* @__PURE__ */ jsxs(Text, {
|
|
339
|
+
color: "red",
|
|
340
|
+
children: ["Reason: ", shorten(stage.blockedReason, 34)]
|
|
341
|
+
}) : null,
|
|
342
|
+
stage.outputPath ? /* @__PURE__ */ jsxs(Text, {
|
|
343
|
+
dimColor: true,
|
|
344
|
+
children: ["Output: ", shorten(stage.outputPath, 34)]
|
|
345
|
+
}) : null,
|
|
346
|
+
stage.kind === "gate" && view.run.gateVerdict ? /* @__PURE__ */ jsxs(Text, {
|
|
347
|
+
dimColor: true,
|
|
348
|
+
children: ["Gate: ", view.run.gateVerdict]
|
|
349
|
+
}) : null
|
|
350
|
+
] }) : /* @__PURE__ */ jsx(Text, {
|
|
351
|
+
dimColor: true,
|
|
352
|
+
children: "No stage selected"
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ jsx(Text, {
|
|
355
|
+
bold: true,
|
|
356
|
+
children: "Tasks"
|
|
357
|
+
}),
|
|
358
|
+
tasks.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
359
|
+
dimColor: true,
|
|
360
|
+
children: "No known Stage Tasks"
|
|
361
|
+
}) : null,
|
|
362
|
+
tasks.map((task, index) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
363
|
+
/* @__PURE__ */ jsxs(Text, { children: [focused && index === selectedIndex ? "▶" : " ", " "] }),
|
|
364
|
+
/* @__PURE__ */ jsx(StatusMark, { status: task.status }),
|
|
365
|
+
/* @__PURE__ */ jsxs(Text, { children: [" ", shorten(task.label, Math.max(16, width - 24))] }),
|
|
366
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
367
|
+
dimColor: true,
|
|
368
|
+
children: [
|
|
369
|
+
" ",
|
|
370
|
+
shorten(task.agent ?? task.execution, 10),
|
|
371
|
+
" ",
|
|
372
|
+
shorten(formatDuration(task.durationMs ?? task.elapsedMs), 7),
|
|
373
|
+
" ",
|
|
374
|
+
shorten(task.blockedReason ?? task.errorCode ?? "", 10)
|
|
375
|
+
]
|
|
376
|
+
})
|
|
377
|
+
] }, task.id))
|
|
378
|
+
]
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
function DetailPanel({ detail, focused, width }) {
|
|
382
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
383
|
+
flexDirection: "column",
|
|
384
|
+
width,
|
|
385
|
+
borderStyle: "single",
|
|
386
|
+
paddingX: 1,
|
|
387
|
+
children: [
|
|
388
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
389
|
+
bold: true,
|
|
390
|
+
children: [focused ? "🟢 " : " ", "Task Detail"]
|
|
391
|
+
}),
|
|
392
|
+
detail ? /* @__PURE__ */ jsx(Text, { children: shorten(detail.task.label, 60) }) : null,
|
|
393
|
+
detailSummary(detail).slice(0, 16).map((line, index) => /* @__PURE__ */ jsx(Text, {
|
|
394
|
+
dimColor: index > 0,
|
|
395
|
+
children: shorten(line, 100)
|
|
396
|
+
}, `${index}-${line}`))
|
|
397
|
+
]
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
function monitorPanelWidths(columns) {
|
|
401
|
+
const total = Math.max(80, columns ?? 120);
|
|
402
|
+
const stages = Math.max(16, Math.floor(total * .2));
|
|
403
|
+
const tasks = Math.max(40, Math.floor(total * .5));
|
|
404
|
+
return {
|
|
405
|
+
stages,
|
|
406
|
+
tasks,
|
|
407
|
+
detail: Math.max(32, total - stages - tasks)
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function StatusMark({ status }) {
|
|
411
|
+
const mark = statusMark(status);
|
|
412
|
+
if (status === "completed") return /* @__PURE__ */ jsx(Text, {
|
|
413
|
+
color: "green",
|
|
414
|
+
children: mark
|
|
415
|
+
});
|
|
416
|
+
if (status === "running" || status === "raw_received" || status === "parsing" || status === "repairing") return /* @__PURE__ */ jsx(Text, {
|
|
417
|
+
color: "yellow",
|
|
418
|
+
children: mark
|
|
419
|
+
});
|
|
420
|
+
if (status === "blocked" || status === "failed" || status === "cancelled" || status === "timed_out") return /* @__PURE__ */ jsx(Text, {
|
|
421
|
+
color: "red",
|
|
422
|
+
children: mark
|
|
423
|
+
});
|
|
424
|
+
if (status === "skipped") return /* @__PURE__ */ jsx(Text, {
|
|
425
|
+
dimColor: true,
|
|
426
|
+
children: mark
|
|
427
|
+
});
|
|
428
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
429
|
+
dimColor: true,
|
|
430
|
+
children: mark
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
export { MonitorApp };
|