feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -24,8 +24,7 @@ const start = (
|
||||
const pending = coordinator.request({
|
||||
sessionId: "session-1",
|
||||
toolCallId: "call-1",
|
||||
name,
|
||||
params,
|
||||
command: { action: name, ...(params as object) },
|
||||
});
|
||||
if (!emitted) throw new Error("request was not emitted");
|
||||
return { emitted, pending };
|
||||
@@ -33,7 +32,7 @@ const start = (
|
||||
|
||||
describe("FrontendActionCoordinator", () => {
|
||||
it("registers the finite view actions with 15 second expiry", () => {
|
||||
expect(frontendActionRegistry.map((action) => action.id).sort()).toEqual(["clear_scada_analysis", "locate_features", "render_scada_analysis", "show_chart", "view_history", "zoom_to_map"]);
|
||||
expect(frontendActionRegistry.map((action) => action.id).sort()).toEqual(["clear_highlights", "clear_overlay", "clear_scada_analysis", "close_chart", "highlight_features", "locate_features", "open_chart", "render_scada_analysis", "set_overlay", "zoom_to_map"]);
|
||||
expect(frontendActionRegistry.every((action) => action.risk === "view" && action.timeoutMs === 15_000)).toBeTrue();
|
||||
});
|
||||
|
||||
@@ -41,14 +40,13 @@ describe("FrontendActionCoordinator", () => {
|
||||
const coordinator = new FrontendActionCoordinator();
|
||||
const { emitted, pending } = start(coordinator);
|
||||
expect(emitted).toMatchObject({
|
||||
name: "render_scada_analysis",
|
||||
command: { action: "render_scada_analysis", items },
|
||||
risk: "view",
|
||||
replayPolicy: "never",
|
||||
params: { items },
|
||||
});
|
||||
expect(emitted.expiresAt - emitted.issuedAt).toBe(15_000);
|
||||
const result = {
|
||||
version: "frontend-action-result@1" as const,
|
||||
version: "frontend-action-result@2" as const,
|
||||
actionId: emitted.actionId,
|
||||
status: "succeeded" as const,
|
||||
output: {
|
||||
@@ -71,14 +69,13 @@ describe("FrontendActionCoordinator", () => {
|
||||
const pending = coordinator.request({
|
||||
sessionId: "session-1",
|
||||
toolCallId: "call-no-replay",
|
||||
name: "clear_scada_analysis",
|
||||
params: {},
|
||||
command: { action: "clear_scada_analysis" },
|
||||
});
|
||||
unregister();
|
||||
coordinator.registerSink("session-1", (request) => emitted.push(request));
|
||||
expect(emitted).toHaveLength(1);
|
||||
coordinator.submitResult("session-1", {
|
||||
version: "frontend-action-result@1",
|
||||
version: "frontend-action-result@2",
|
||||
actionId: emitted[0].actionId,
|
||||
status: "succeeded",
|
||||
output: { cleared: true },
|
||||
@@ -91,14 +88,14 @@ describe("FrontendActionCoordinator", () => {
|
||||
const coordinator = new FrontendActionCoordinator();
|
||||
const { emitted, pending } = start(coordinator, "clear_scada_analysis", {});
|
||||
expect(() => coordinator.submitResult("session-1", {
|
||||
version: "frontend-action-result@1",
|
||||
version: "frontend-action-result@2",
|
||||
actionId: emitted.actionId,
|
||||
status: "succeeded",
|
||||
output: { cleared: false },
|
||||
completedAt: Date.now(),
|
||||
})).toThrow("invalid frontend action output");
|
||||
coordinator.submitResult("session-1", {
|
||||
version: "frontend-action-result@1",
|
||||
version: "frontend-action-result@2",
|
||||
actionId: emitted.actionId,
|
||||
status: "succeeded",
|
||||
output: { cleared: true },
|
||||
@@ -113,21 +110,20 @@ describe("FrontendActionCoordinator", () => {
|
||||
const request = (value: unknown) => coordinator.request({
|
||||
sessionId: "s",
|
||||
toolCallId: "call-validation",
|
||||
name: "render_scada_analysis",
|
||||
params: value,
|
||||
command: { action: "render_scada_analysis", ...(value as object) },
|
||||
});
|
||||
expect(() => request({ items: [] })).toThrow(FrontendActionError);
|
||||
expect(() => request({ items: Array.from({ length: 101 }, (_, index) => ({ device_id: `MP${index}`, level: "low" })) })).toThrow("invalid frontend action params");
|
||||
expect(() => request({ items: [{ device_id: "MP01", level: "high" }, { device_id: "MP01", level: "low" }] })).toThrow("invalid frontend action params");
|
||||
expect(() => request({ items: [{ device_id: "x".repeat(129), level: "low" }] })).toThrow("invalid frontend action params");
|
||||
expect(() => request({ items: [{ device_id: "MP01", level: "critical" }] })).toThrow("invalid frontend action params");
|
||||
expect(() => request({ items: Array.from({ length: 101 }, (_, index) => ({ device_id: `MP${index}`, level: "low" })) })).toThrow("invalid view command");
|
||||
expect(() => request({ items: [{ device_id: "MP01", level: "high" }, { device_id: "MP01", level: "low" }] })).toThrow("invalid view command");
|
||||
expect(() => request({ items: [{ device_id: "x".repeat(129), level: "low" }] })).toThrow("invalid view command");
|
||||
expect(() => request({ items: [{ device_id: "MP01", level: "critical" }] })).toThrow("invalid view command");
|
||||
});
|
||||
|
||||
it("keeps terminal results idempotent and rejects conflicts", async () => {
|
||||
const coordinator = new FrontendActionCoordinator();
|
||||
const { emitted, pending } = start(coordinator, "clear_scada_analysis", {});
|
||||
const result = {
|
||||
version: "frontend-action-result@1" as const,
|
||||
version: "frontend-action-result@2" as const,
|
||||
actionId: emitted.actionId,
|
||||
status: "succeeded" as const,
|
||||
output: { cleared: true as const },
|
||||
|
||||
Reference in New Issue
Block a user