feat(pi-workflow): add human-readable run labels
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
type ContextTransitionRuntime,
|
||||
} from "./context-transition.ts";
|
||||
import type { WorkflowCommand, WorkflowView } from "./engine.ts";
|
||||
import { deriveRunLabel } from "./run-label.ts";
|
||||
|
||||
const ACTIONS = ["start", "inspect", "decide", "abort"] as const;
|
||||
const WORKFLOW_MODES = ["feature", "feature-script", "analysis-script"] as const;
|
||||
@@ -370,9 +371,9 @@ function boundToolOutput(contents: string) {
|
||||
return `${characters.join("")}${marker}`;
|
||||
}
|
||||
|
||||
function resultText(details: WorkflowToolDetails) {
|
||||
function resultText(details: WorkflowToolDetails, label: string) {
|
||||
const lines = [
|
||||
`Workflow ${details.runId}: ${details.status} at revision ${details.revision}.`,
|
||||
`Workflow ${label}: ${details.status} at revision ${details.revision}.`,
|
||||
];
|
||||
if (details.openGate) {
|
||||
lines.push(
|
||||
@@ -479,6 +480,14 @@ export function registerPiWorkflowTool(
|
||||
await cancellationWork;
|
||||
throw cancellationError();
|
||||
}
|
||||
} catch (error) {
|
||||
if (params.action === "inspect" && params.runId) {
|
||||
const reason = error instanceof Error ? error.message : String(error);
|
||||
throw new Error(
|
||||
`Workflow Run ${params.runId} could not be loaded: ${reason}`,
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
} finally {
|
||||
executionSignal.removeEventListener("abort", onAbort);
|
||||
}
|
||||
@@ -488,7 +497,9 @@ export function registerPiWorkflowTool(
|
||||
ctx.sessionManager.getSessionId(),
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text" as const, text: resultText(details) }],
|
||||
content: [
|
||||
{ type: "text" as const, text: resultText(details, deriveRunLabel(view)) },
|
||||
],
|
||||
details,
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user