feat(agent): add typed server API tools
This commit is contained in:
@@ -44,4 +44,47 @@ describe("FrontendActionCoordinator", () => {
|
||||
coordinator.registerSink("s", () => undefined);
|
||||
expect(() => coordinator.request({ sessionId: "s", toolCallId: "c", name: "unknown", params: {} })).toThrow("unknown frontend action");
|
||||
});
|
||||
|
||||
it("requires a valid time range when opening history data", async () => {
|
||||
const coordinator = new FrontendActionCoordinator();
|
||||
let emitted: FrontendActionRequest | undefined;
|
||||
coordinator.registerSink("s", (request) => { emitted = request; });
|
||||
expect(() => coordinator.request({
|
||||
sessionId: "s",
|
||||
toolCallId: "c",
|
||||
name: "view_history",
|
||||
params: { feature_infos: [["node-1", "junction"]], data_type: "realtime" },
|
||||
})).toThrow("invalid frontend action params");
|
||||
expect(() => coordinator.request({
|
||||
sessionId: "s",
|
||||
toolCallId: "c",
|
||||
name: "view_history",
|
||||
params: {
|
||||
feature_infos: [["node-1", "junction"]],
|
||||
data_type: "realtime",
|
||||
start_time: "2026-07-14T00:00:00Z",
|
||||
end_time: "2026-07-14T00:00:00Z",
|
||||
},
|
||||
})).toThrow("invalid frontend action params");
|
||||
const pending = coordinator.request({
|
||||
sessionId: "s",
|
||||
toolCallId: "c",
|
||||
name: "view_history",
|
||||
params: {
|
||||
feature_infos: [["node-1", "junction"]],
|
||||
data_type: "realtime",
|
||||
start_time: "2026-07-14T00:00:00Z",
|
||||
end_time: "2026-07-14T01:00:00Z",
|
||||
},
|
||||
});
|
||||
if (!emitted) throw new Error("request was not emitted");
|
||||
coordinator.submitResult("s", {
|
||||
version: "frontend-action-result@1",
|
||||
actionId: emitted.actionId,
|
||||
status: "succeeded",
|
||||
output: { component: "HistoryPanel", rendered: true, itemCount: 1 },
|
||||
completedAt: Date.now(),
|
||||
});
|
||||
await expect(pending).resolves.toMatchObject({ status: "succeeded" });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user