feat(agent): add frontend action bridge
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import { frontendActionCallIdPlugin } from "../../.opencode/plugins/frontend-action-call-id.js";
|
||||
|
||||
describe("frontend action call ID plugin", () => {
|
||||
it("overwrites forged IDs only for allowlisted tools", async () => {
|
||||
const hooks = await frontendActionCallIdPlugin({} as never);
|
||||
const before = hooks["tool.execute.before"];
|
||||
if (!before) throw new Error("hook missing");
|
||||
const actionOutput = { args: { x: 1, __frontend_action_call_id: "forged" } };
|
||||
await before({ tool: "zoom_to_map", sessionID: "session", callID: "real" }, actionOutput);
|
||||
expect(actionOutput.args.__frontend_action_call_id).toBe("real");
|
||||
|
||||
const ordinaryOutput = { args: { query: "water" } };
|
||||
await before({ tool: "web_search", sessionID: "session", callID: "ignored" }, ordinaryOutput);
|
||||
expect(ordinaryOutput.args).toEqual({ query: "water" });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user