MCP 改为 loopback 并绑定项目 scope,补齐越界拒绝、风险元数据和结构化状态。 新增分层 readiness、配置迁移与设置页投影;正式安装版可选择登录自启动,debug 与非安装路径明确拒绝。 Feature-Confirmed: true Rules-Applied: R01,R06,R07,R08,R10,R12,R13
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { AgentRuntimeStatus, AgentRuntimeState } from "../../lib/commands";
|
|
import { getAgentRuntimePresentation } from "./SettingsPage";
|
|
|
|
const layer = (state: AgentRuntimeState, detail = state) => ({ state, detail });
|
|
|
|
function status(overrides: Partial<AgentRuntimeStatus> = {}): AgentRuntimeStatus {
|
|
return {
|
|
project_id: "p1",
|
|
ready: true,
|
|
configured: layer("ready"),
|
|
reachable: layer("ready"),
|
|
handshake: layer("ready"),
|
|
tools_ready: layer("ready"),
|
|
reload_required: { ...layer("ready"), required: false },
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("getAgentRuntimePresentation", () => {
|
|
it.each([
|
|
[status({ configured: layer("missing") }), "未配置", "注入 MCP"],
|
|
[status({ reachable: layer("unavailable") }), "炼境未运行", "托盘运行"],
|
|
[status({ handshake: layer("protocol_error") }), "协议或工具异常", "重启或升级"],
|
|
[status({ reload_required: { ...layer("missing"), required: true } }), "需重载 Codex", "新建 Codex 任务"],
|
|
[status(), "Agent 已就绪", "无需操作"],
|
|
])("为每种阻塞状态给出唯一行动", (runtime, label, action) => {
|
|
const view = getAgentRuntimePresentation(runtime);
|
|
expect(view.label).toBe(label);
|
|
expect(view.action).toContain(action);
|
|
});
|
|
});
|