Move project and host queries into native MCP with host-owned OAuth/context, while retaining memory, skills, actions and publication plugins. Add nearby-model queries and explicit chat/task/learning model defaults. Adopt Responses HTTP/SSE and native steer/queue inbox delivery, preserving scoped session ownership, pending input edits and investigation communication. Disable local-provider discovery: Server /health allowed native vLLM to probe /v1/models on port 8000. A native before/after regression prevents recurrence. Validation: 170 focused Bun tests; service/plugin typechecks; native discovery, provider-discovery and input-inbox smoke checks; no paid model inference.
52 lines
3.3 KiB
TypeScript
52 lines
3.3 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
|
|
import publishPresentation from "../../.opencode/tools/publish_task_presentation.js";
|
|
import publishProgress from "../../.opencode/tools/publish_task_progress.js";
|
|
import { taskPublicationCommandSchema, taskPublicationProgressSchema } from "../../.opencode/tools/task-publication-schema.js";
|
|
import { taskProgressSchema } from "../../src/product/investigation-report.js";
|
|
import { taskPresentationCommandSchema } from "../../src/product/task-presentation.js";
|
|
|
|
describe("task presentation input boundaries", () => {
|
|
it("aligns native and product progress schemas for legacy and current diagrams", () => {
|
|
const progress = { summary: "实际读取监测资料", diagram: { title: "当前路线", mermaid: "flowchart TD\nQUERY --> REVIEW", node_refs: [
|
|
{ node_id: "QUERY", label: "查询", status: "running", map_targets: [{ source_id: "pipes", feature_id: "P-1" }] },
|
|
{ node_id: "REVIEW", label: "复核", status: null },
|
|
] } };
|
|
expect(taskProgressSchema.parse(taskPublicationProgressSchema.parse(progress))).toEqual(taskProgressSchema.parse(progress));
|
|
expect(taskProgressSchema.parse(taskPublicationProgressSchema.parse({ summary: "当前无图" }))).toEqual({ summary: "当前无图", diagram: null });
|
|
});
|
|
|
|
it("accepts finite display commands and rejects unsupported data, layers and chart evidence", () => {
|
|
const chart = { title: "压力", chart_type: "line", x_data: ["10:00"], series: [{ name: "MP01", data: [0.4] }] };
|
|
const commands = [
|
|
{ action: "highlight_features", layer: "scada", feature_ids: ["MP01"] },
|
|
{ action: "clear_highlights" },
|
|
{ action: "open_chart", chart_id: "pressure", chart, evidence_refs: ["reading-1"] },
|
|
{ action: "close_chart", chart_id: "pressure" },
|
|
{ action: "set_overlay", overlay_id: "complaints", title: "实际投诉", mode: "heatmap", evidence_id: "query-1" },
|
|
{ action: "clear_overlay", overlay_id: "complaints" },
|
|
];
|
|
for (const command of commands) {
|
|
expect(taskPresentationCommandSchema.parse(taskPublicationCommandSchema.parse(command))).toEqual(taskPresentationCommandSchema.parse(command));
|
|
}
|
|
for (const command of [
|
|
{ ...commands[0], layer: "drainage" },
|
|
{ ...commands[2], evidence_refs: [] },
|
|
{ ...commands[2], chart: { ...chart, series: [{ name: "MP01", data: [0.4, 0.5] }] } },
|
|
{ ...commands[4], data: { coordinates: [1, 2] } },
|
|
{ ...commands[4], script: "alert(1)" },
|
|
]) expect(() => taskPresentationCommandSchema.parse(command)).toThrow();
|
|
});
|
|
|
|
it("revalidates semantic chart and Mermaid inputs before sending a tool request", async () => {
|
|
const request_id = "60000000-0000-4000-8000-000000000001";
|
|
await expect(publishPresentation.execute({ request_id, command: {
|
|
action: "open_chart", chart_id: "pressure", evidence_refs: ["reading-1"],
|
|
chart: { title: "压力", chart_type: "line", x_data: ["10:00"], series: [{ name: "MP01", data: [0.4, 0.5] }] },
|
|
} }, { sessionID: "test" })).rejects.toThrow("series must align");
|
|
await expect(publishProgress.execute({ request_id, progress: {
|
|
summary: "查询", diagram: { title: "路线", mermaid: "flowchart TD; A-->B; click A callback", node_refs: [] },
|
|
} }, { sessionID: "test" })).rejects.toThrow("Mermaid");
|
|
});
|
|
});
|