fix: make console graph demo usable

This commit is contained in:
lda
2026-07-02 23:14:06 +07:00 Verified
parent 3cdcf6ff3b
commit 86ccbe35cf
9 changed files with 1560 additions and 23 deletions
+19 -3
View File
@@ -52,6 +52,22 @@ export type WorkflowSourcesListInterpreted = {
readonly total: number;
};
const interpretNextActions = (nextActions: {
readonly can_continue: boolean;
readonly can_save_now: boolean | null;
readonly recommended_next_tool: string | null;
readonly reason: string;
readonly patch_examples: ReadonlyArray<unknown>;
readonly warnings: ReadonlyArray<string>;
}) => ({
canContinue: nextActions.can_continue,
canSaveNow: nextActions.can_save_now,
recommendedNextTool: nextActions.recommended_next_tool,
reason: nextActions.reason,
patchExamples: nextActions.patch_examples,
warnings: nextActions.warnings,
});
const operationEntries: ReadonlyArray<OperationMeta> = [
{
method: "workflow.health",
@@ -236,7 +252,7 @@ const operationEntries: ReadonlyArray<OperationMeta> = [
artifactVersion: decoded.artifact_version,
status: decoded.status,
diagnostics: decoded.diagnostics,
nextActions: decoded.next_actions,
nextActions: interpretNextActions(decoded.next_actions),
};
},
},
@@ -304,7 +320,7 @@ const operationEntries: ReadonlyArray<OperationMeta> = [
output: decoded.output,
diagnostics: decoded.diagnostics,
traceCount: decoded.trace_count,
nextActions: decoded.next_actions,
nextActions: interpretNextActions(decoded.next_actions),
};
},
},
@@ -333,7 +349,7 @@ const operationEntries: ReadonlyArray<OperationMeta> = [
return {
runId: r.run_id,
status: r.status,
trace,
frames: trace,
traceStart: r.trace_start,
traceLimit: r.trace_limit,
traceTruncated: r.trace_truncated,
+1 -1
View File
@@ -93,7 +93,7 @@ const ArtifactNodeSchema = Schema.Struct({
export const WorkflowArtifactsListResultSchema = Schema.Struct({
nodes: Schema.Array(ArtifactNodeSchema),
total: NonNegativeIntegerSchema,
cursor: Schema.NullOr(Schema.String),
cursor: Schema.optional(Schema.NullOr(Schema.String)),
next_cursor: Schema.NullOr(Schema.String),
limit: Schema.optional(PositiveIntegerSchema),
});
+37 -1
View File
@@ -94,7 +94,6 @@ const lifecycleCases = [
},
],
total: 1,
cursor: null,
next_cursor: null,
limit: 50,
},
@@ -436,4 +435,41 @@ describe("lifecycle operations", () => {
expect(exchange.interpreted).toBeDefined();
});
}
it("interprets run trace frames with the console lifecycle shape", async () => {
const traceCase = lifecycleCases.find(
(testCase) => testCase.operation === "workflow.runs.trace",
);
expect(traceCase).toBeDefined();
if (!traceCase) return;
const fetch: typeof globalThis.fetch = async (input, init) => {
const request = await requestBody(input, init);
return jsonResponse({
jsonrpc: "2.0",
id: request.id,
result: traceCase.result,
});
};
const exchange = await runOperation(
{ fetch },
traceCase.operation as "workflow.health" | "workflow.sources.list",
traceCase.params,
);
expect(exchange.interpreted).toMatchObject({
frames: [
{
nodeId: "review",
stepType: "interrupt",
outcome: "submitted",
},
],
traceStart: 0,
traceLimit: 50,
traceTruncated: false,
});
expect(exchange.interpreted).not.toHaveProperty("trace");
});
});