fix(runtime): persist miniapp tool progress
This commit is contained in:
@@ -19,4 +19,14 @@ describe("MiniAppToolStateMachine", () => {
|
||||
expect(machine.cancel("call-2", "task:2", "app_closed", "2026-08-04T00:00:02.000Z")).toEqual(expect.objectContaining({ disposition: "invalid_scope" }));
|
||||
expect(machine.cancel("call-2", "task:1", "app_closed", "2026-08-04T00:00:02.000Z")).toMatchObject({ disposition: "accepted", record: { status: "cancelled", cancel_reason: "app_closed" } });
|
||||
});
|
||||
|
||||
it("keeps the latest progress in the durable call record", () => {
|
||||
const machine = new MiniAppToolStateMachine();
|
||||
machine.receive({ call_id: "call-progress", tool_id: "task-dashboard.open", inventory_revision: "catalog-1", app_scope: "task-dashboard", instance_id: "task:1", conversation_id: "c", input: {}, created_at: "2026-08-04T00:00:00.000Z" });
|
||||
machine.route("call-progress", "task:1", "2026-08-04T00:00:01.000Z");
|
||||
expect(machine.progress("call-progress", "task:1", { percent: 42, status: "working", detail: "正在处理" }, "2026-08-04T00:00:02.000Z")).toMatchObject({ disposition: "accepted", record: { progress: { percent: 42, status: "working", detail: "正在处理" } } });
|
||||
const restored = new MiniAppToolStateMachine();
|
||||
restored.restore(machine.list(), "2026-08-04T00:00:03.000Z");
|
||||
expect(restored.get("call-progress")).toMatchObject({ status: "waiting_for_app", progress: { percent: 42, status: "working", detail: "正在处理" } });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user