feat: add SCADA frontend action bridge

This commit is contained in:
2026-07-20 19:57:25 +08:00
parent 72019ac1f2
commit 432edaaf2f
16 changed files with 445 additions and 20 deletions
+32
View File
@@ -0,0 +1,32 @@
import { describe, expect, it } from "bun:test";
import { unwrapFrontendActionResult } from "../../.opencode/tools/frontend_action.js";
describe("frontend action tool bridge", () => {
it("returns only validated browser output for successful actions", () => {
expect(unwrapFrontendActionResult(JSON.stringify({
version: "frontend-action-result@1",
actionId: "action-1",
status: "succeeded",
output: { cleared: true },
completedAt: Date.now(),
}))).toBe('{"cleared":true}');
});
it("throws the browser error for failed and expired actions", () => {
expect(() => unwrapFrontendActionResult(JSON.stringify({
version: "frontend-action-result@1",
actionId: "action-1",
status: "failed",
error: { code: "WFS_UNAVAILABLE", message: "SCADA geometry query failed" },
completedAt: Date.now(),
}))).toThrow("WFS_UNAVAILABLE: SCADA geometry query failed");
expect(() => unwrapFrontendActionResult(JSON.stringify({
version: "frontend-action-result@1",
actionId: "action-2",
status: "expired",
error: { code: "ACTION_TIMEOUT", message: "browser action timed out" },
completedAt: Date.now(),
}))).toThrow("ACTION_TIMEOUT: browser action timed out");
});
});