feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -196,6 +196,26 @@ describe("OperationalTaskClient", () => {
|
||||
expect(requests[2]!.headers.get("authorization")).toBe("Bearer transient-secret");
|
||||
});
|
||||
|
||||
it("injects the claimed run into task questions without changing its lease revision", async () => {
|
||||
const requests: Request[] = [];
|
||||
globalThis.fetch = (async (input, init) => {
|
||||
const request = new Request(input, init); requests.push(request);
|
||||
if (request.url.endsWith("/questions")) return Response.json({ question_request_id: crypto.randomUUID(), status: "pending", version: 1 });
|
||||
return Response.json(run);
|
||||
}) as typeof fetch;
|
||||
bindOperationalTaskCredential("runtime-1", { authorization: "Bearer transient-secret", projectId: "project-1" });
|
||||
const client = new OperationalTaskClient("http://server.test");
|
||||
const questions = [{ question_id: "flow", title: "流量", body: "是否有计量记录?", options: [],
|
||||
mode: "single" as const, allow_custom: true, required: true }];
|
||||
await expect(client.askTaskUser("runtime-1", taskId, { request_id: executionRequestId,
|
||||
sourceSessionId: "session-1", questions })).rejects.toThrow("task run context unavailable");
|
||||
await client.claimTask("runtime-1", taskId, runId, { requestId: executionRequestId, expectedRevision: 1, sourceSessionId: "session-1" });
|
||||
await client.askTaskUser("runtime-1", taskId, { request_id: executionRequestId, sourceSessionId: "session-1", questions });
|
||||
expect(await requests[1]!.json()).toEqual({ request_id: executionRequestId, source_session_id: "session-1", run_id: runId, questions });
|
||||
await client.heartbeatTask("runtime-1", taskId, runId, "session-1");
|
||||
expect(await requests[2]!.json()).toMatchObject({ expected_revision: run.revision });
|
||||
});
|
||||
|
||||
it("fails closed without a current product credential", async () => {
|
||||
const client = new OperationalTaskClient("http://server.test");
|
||||
expect(client.getAgentContext("runtime-1", "50000000-0000-4000-8000-000000000001"))
|
||||
|
||||
Reference in New Issue
Block a user