feat(pi-workflow): add human-readable run labels
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
||||
function workflowView(overrides: Partial<WorkflowView> = {}): WorkflowView {
|
||||
return {
|
||||
runId: "run-1",
|
||||
featureName: "search-page",
|
||||
request: "Build search page",
|
||||
revision: 4,
|
||||
status: "waiting",
|
||||
workspace: {
|
||||
@@ -243,6 +245,39 @@ test("tool cancellation aborts its active Workflow Run before rejecting", async
|
||||
assert.equal(commands.some((command) => command.action === "abort"), true);
|
||||
});
|
||||
|
||||
test("inspect errors retain the supplied run ID when no label can be derived", async () => {
|
||||
let definition: Parameters<ExtensionAPI["registerTool"]>[0] | undefined;
|
||||
const pi = {
|
||||
registerTool(candidate: Parameters<ExtensionAPI["registerTool"]>[0]) {
|
||||
definition = candidate;
|
||||
},
|
||||
getActiveTools: () => ["read"],
|
||||
} as unknown as ExtensionAPI;
|
||||
registerPiWorkflowTool(pi, {
|
||||
store: {} as never,
|
||||
async engineForContext() {
|
||||
return {
|
||||
async execute() {
|
||||
throw new Error("not found");
|
||||
},
|
||||
} as never;
|
||||
},
|
||||
});
|
||||
assert.ok(definition);
|
||||
await assert.rejects(
|
||||
definition.execute(
|
||||
"inspect-call",
|
||||
{ action: "inspect", runId: "missing-run-id" },
|
||||
new AbortController().signal,
|
||||
undefined,
|
||||
{
|
||||
sessionManager: { getSessionId: () => "session-1" },
|
||||
} as unknown as ExtensionContext,
|
||||
),
|
||||
/Workflow Run missing-run-id could not be loaded/,
|
||||
);
|
||||
});
|
||||
|
||||
test("registered tool executes through the context engine and injects host tools", async () => {
|
||||
let definition: Parameters<ExtensionAPI["registerTool"]>[0] | undefined;
|
||||
const commands: WorkflowCommand[] = [];
|
||||
@@ -267,7 +302,7 @@ test("registered tool executes through the context engine and injects host tools
|
||||
});
|
||||
assert.equal(definition?.name, "pi_workflow");
|
||||
assert.ok(definition);
|
||||
await definition.execute(
|
||||
const result = await definition.execute(
|
||||
"call-1",
|
||||
{
|
||||
action: "decide",
|
||||
@@ -293,4 +328,6 @@ test("registered tool executes through the context engine and injects host tools
|
||||
commands[0]?.action === "decide" ? commands[0].activeToolNames : undefined,
|
||||
["read", "smart_compact"],
|
||||
);
|
||||
assert.match(result.content[0]?.type === "text" ? result.content[0].text : "", /Workflow search-page/);
|
||||
assert.equal((result.details as { runId: string }).runId, "run-1");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user