feat: initialize experimental agent repo
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import { toUiEnvelopeFromToolCall } from "../../src/uiEnvelope/fromToolCall.js";
|
||||
|
||||
describe("toUiEnvelopeFromToolCall", () => {
|
||||
it("maps show_chart calls to chart envelopes", () => {
|
||||
const envelope = toUiEnvelopeFromToolCall({
|
||||
tool: "show_chart",
|
||||
reason: "展示压力趋势",
|
||||
params: {
|
||||
title: "压力趋势",
|
||||
chart_type: "line",
|
||||
x_data: ["00:00", "01:00"],
|
||||
series: [{ name: "P-1", data: [0.41, 0.43] }],
|
||||
},
|
||||
});
|
||||
|
||||
expect(envelope).toMatchObject({
|
||||
kind: "chart",
|
||||
schemaVersion: "agent-ui@1",
|
||||
grammar: "echarts-safe-subset",
|
||||
surface: "chat_inline",
|
||||
fallbackText: "展示压力趋势",
|
||||
data: {
|
||||
x_data: ["00:00", "01:00"],
|
||||
series: [{ name: "P-1", data: [0.41, 0.43] }],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects render_junctions without a valid render_ref", () => {
|
||||
expect(
|
||||
toUiEnvelopeFromToolCall({
|
||||
tool: "render_junctions",
|
||||
params: { render_ref: "/tmp/payload.json" },
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("maps view_scada calls to registered component envelopes", () => {
|
||||
const envelope = toUiEnvelopeFromToolCall({
|
||||
tool: "view_scada",
|
||||
params: { device_id: "D-1" },
|
||||
});
|
||||
|
||||
expect(envelope).toMatchObject({
|
||||
kind: "registered_component",
|
||||
component: "ScadaPanel",
|
||||
surface: "side_panel",
|
||||
props: { device_id: "D-1" },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user