Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions web/src/api/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,20 @@ describe("CyberAgentClient", () => {
}, "web-run-execution-operation-0002")).rejects.toThrow("invalid");
});

it("rejects a Run execution response with an unknown Run status", async () => {
vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response(JSON.stringify({
version: "api.v1", request_id: "req-execute-status-forged",
data: { ...runExecutionData, run_status: "arbitrary" },
}), { status: 202, headers: { "Content-Type": "application/json" } })));
const client = new CyberAgentClient("read-secret", "/api/v1", "control-secret", {
runExecutionEnabled: true,
});

await expect(client.executeRun("run-1", {
version: "run_execution_handoff.v1", max_steps: 2,
}, "web-run-execution-status-0001")).rejects.toThrow("invalid");
});

it("accepts an exact lifecycle replay after the Run has advanced", async () => {
const delayedReplay = {
...runLifecycleData, replayed: true,
Expand Down
2 changes: 1 addition & 1 deletion web/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ function parseRunExecutionControl(value: unknown, expectedRunID: string,
value.cancelled_count !== value.selected_count ||
!safePositiveInteger(value.completion_event_sequence) ||
(value.status !== "completed" && value.status !== "failed") ||
typeof value.run_status !== "string" || typeof value.stop_reason !== "string" ||
!isRunStatus(value.run_status) || typeof value.stop_reason !== "string" ||
value.stop_reason.length === 0 || value.stop_reason.length > 64 ||
typeof value.replayed !== "boolean" || typeof value.execution_started !== "boolean" ||
typeof value.model_called !== "boolean" || typeof value.tool_called !== "boolean" ||
Expand Down