Adds Agent Console (@magpie-community/page-agent-console 1.0.0), a community page plugin that drives the Agent CLIs on this computer (Claude Code, Codex, ACP agents) through a local daemon on 127.0.0.1, with its source in packages/agent-console and a registry entry. Claude Code is the user's own `claude` CLI driven over stream-json (daemon/src/providers/claude/cli.ts); no Anthropic SDK is installed, bundled or in the branch's history. Cold install ~45 MB (node-pty ~26 MB), stated in the README and registry summary in en and zh. By qingnian108 (#535). What was run at 8e8f910 (mote, macOS, throwaway HOME, no real accounts): - packages/agent-console: `npm ci --ignore-scripts --workspaces=false`; `node scripts/verify-build.mjs`: all five bundles byte-identical (daemon/dist/main.js 08c95aa3…, app/app.js 9a6911f3…); `vitest run`: 45 files, 254 passed, 17 skipped; `npm run check` clean. - Real Claude Code 2.1.316 (npm @anthropic-ai/claude-code, sandbox HOME/CLAUDE_CONFIG_DIR, local fake Messages API): `AC_REAL_CLAUDE=… vitest run --config vitest.real.config.ts test/real/claude-cli.real.test.ts`: 4 of 4 (initialize lists 51 slash commands, streaming turn, Bash permission approved and denied, interrupt, --resume with set_model). - Probe: the driver's exact argv with `--permission-mode bypassPermissions --allow-dangerously-skip-permissions`: the tool runs with no can_use_tool request. - Repo root: `HOME=$(mktemp -d) bun test`: 4006 tests, 0 fail; `bun scripts/check.mjs` exit 0. - Install as magpie does: `npm pack --ignore-scripts` (552 KB) then `bun add --ignore-scripts`: 45 MB node_modules, no @anthropic-ai/*, index.mjs imports. - Read every changed line since 41c7a94: argv values limited to SAFE_ARG tokens (no cmd.exe metacharacters reach the shim path), no new network hosts, no install scripts, no eval; no commit in main..8e8f910 contains claude-agent-sdk. Not tried: magpie's desktop window loading the page; a Windows .cmd/.ps1 claude shim end to end.
71 lines
3.9 KiB
TypeScript
71 lines
3.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { parseAcpSession, probeToModels, cursorCatalogToModels } from "../../daemon/src/providers/acp/probe.js";
|
|
|
|
describe("Cursor model catalog (cursor/list_available_models)", () => {
|
|
it("each model has its own level parameter; the current model is the default; models without levels get no dropdown", () => {
|
|
const models = cursorCatalogToModels({
|
|
models: [
|
|
{ value: "grok-4.6[effort=high,fast=true]", name: "Grok 4.6", configOptions: [
|
|
{ id: "effort", category: "thought_level", type: "select", currentValue: "high", options: [
|
|
{ value: "low", name: "Low" }, { value: "medium", name: "Medium" }, { value: "high", name: "High" }, { value: "xhigh", name: "Extra High" },
|
|
] },
|
|
{ id: "fast", category: "model_config", type: "select", currentValue: "true", options: [{ value: "false" }, { value: "true" }] },
|
|
] },
|
|
{ value: "gpt-5.6-sol[reasoning=medium]", name: "GPT-5.6 Sol", configOptions: [
|
|
{ id: "reasoning", category: "thought_level", type: "select", currentValue: "medium", options: [{ value: "none" }, { value: "max" }] },
|
|
] },
|
|
{ value: "composer-2.5[fast=true]", name: "Composer 2.5", configOptions: [
|
|
{ id: "fast", category: "model_config", type: "select", currentValue: "true", options: [{ value: "false" }, { value: "true" }] },
|
|
] },
|
|
],
|
|
}, "grok-4.6[effort=high,fast=true]");
|
|
expect(models.map((m) => m.id)).toEqual(["grok-4.6", "gpt-5.6-sol", "composer-2.5"]);
|
|
expect(models[0]).toMatchObject({ isDefault: true, defaultThinking: "high", thinkingParam: "effort" });
|
|
expect(models[0].thinkingOptions?.map((o) => o.id)).toEqual(["low", "medium", "high", "xhigh"]);
|
|
expect(models[1]).toMatchObject({ thinkingParam: "reasoning" });
|
|
expect(models[2].thinkingOptions).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("ACP probe parsing", () => {
|
|
it("Devin: model + thought_level config options", () => {
|
|
const r = parseAcpSession({
|
|
configOptions: [
|
|
{ id: "mode", category: "mode", type: "select", currentValue: "accept-edits", options: [{ value: "accept-edits", name: "Code" }] },
|
|
{ id: "model", category: "model", type: "select", currentValue: "swe-2-high", options: [
|
|
{ value: "adaptive", name: "Adaptive" }, { value: "swe-2-high", name: "SWE-2" },
|
|
] },
|
|
{ id: "thought_level", category: "thought_level", type: "select", currentValue: "high", options: [
|
|
{ value: "medium", name: "Medium" }, { value: "high", name: "High" }, { value: "max", name: "Max" },
|
|
] },
|
|
],
|
|
});
|
|
expect(r.models.map((m) => m.id)).toEqual(["adaptive", "swe-2-high"]);
|
|
expect(r.currentModel).toBe("swe-2-high");
|
|
const models = probeToModels(r);
|
|
expect(models.find((m) => m.isDefault)?.id).toBe("swe-2-high");
|
|
expect(models[1].thinkingOptions?.map((t) => t.id)).toEqual(["medium", "high", "max"]);
|
|
expect(models[1].defaultThinking).toBe("high");
|
|
});
|
|
|
|
it("Copilot: duplicate auto is deduped", () => {
|
|
const r = parseAcpSession({
|
|
configOptions: [{ id: "model", category: "model", type: "select", currentValue: "auto", options: [
|
|
{ value: "auto", name: "Auto" }, { value: "auto", name: "Auto" },
|
|
] }],
|
|
});
|
|
expect(r.models).toEqual([{ id: "auto", name: "Auto" }]);
|
|
});
|
|
|
|
it("grouped options are flattened; falls back to the models field without configOptions", () => {
|
|
const grouped = parseAcpSession({
|
|
configOptions: [{ id: "model", category: "model", type: "select", currentValue: "b", options: [
|
|
{ name: "G", options: [{ value: "a", name: "A" }, { value: "b", name: "B" }] },
|
|
] }],
|
|
});
|
|
expect(grouped.models.map((m) => m.id)).toEqual(["a", "b"]);
|
|
const legacy = parseAcpSession({ models: { currentModelId: "x", availableModels: [{ modelId: "x", name: "X" }] } });
|
|
expect(legacy).toMatchObject({ currentModel: "x", models: [{ id: "x", name: "X" }] });
|
|
});
|
|
});
|