mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* feat(ai): add MiMo Code (mimo) agent support scaffolding
Registry/wiring only: discovery entry, managed-agent metadata, model presets, icon, i18n and Settings UI for Xiaomi's MiMo Code CLI (an OpenCode fork). The SDK driver is intentionally not wired yet - it depends on the pending @mimo-ai/sdk parity probe, so DRIVER_REGISTRY keeps a TODO and run-turn/list-models reject the mimo backend until then.
* feat(ai): add MiMo Code (mimo) agent support
Adds Xiaomi's MiMo Code CLI as a managed agent backend, mirroring the existing
OpenCode integration (discovery, managed-agent metadata, model presets, icon,
i18n, Settings UI) and adding the SDK driver that was left as a TODO in the
scaffolding commit.
Driver notes:
- New electron/bridges/aiBridge/sdk/mimoDriver.cjs reuses the pure translation
helpers exported by opencodeDriver.cjs (config/prompt building, event
translation, model mapping) because MiMo Code is an OpenCode fork and speaks
the same wire protocol.
- It does NOT use @mimo-ai/sdk's createOpencode(). On 0.1.15 that helper spawns
a binary named "opencode", waits for an "opencode server listening" banner,
and passes config via OPENCODE_CONFIG_CONTENT; the mimo CLI prints
"mimocode server listening on <url>", reads MIMOCODE_CONFIG_CONTENT, and ships
as "mimo"/"mimo.exe". So createOpencode() can only ever time out. The driver
runs "mimo serve" itself, parses the readiness URL, and attaches the SDK's
createOpencodeClient({ baseUrl }).
- Binary resolution honours binPath, MIMOCODE_BIN and MIMOCODE_BIN_PATH, then
falls back to PATH via resolveCliFromPath (the npm shim is mimo.cmd on
Windows, which Node cannot spawn directly).
- @mimo-ai/sdk ^0.1.15 added as a dependency.
Verified on Windows against mimo 0.1.15 + @mimo-ai/sdk 0.1.15:
- "mimo serve --port" boots and reports its URL; driver parses it.
- SDK symbols used all exist: createOpencodeClient, client.config.providers(),
client.global.event() (SSE stream), client.session.create/abort/promptAsync.
- Live provider catalog reads 2 providers (xiaomi, mimo); MIMO_MODEL_PRESETS
updated to the real lower-case provider-prefixed ids and its TODO removed.
- Server process is killed on close (taskkill tree kill), no orphan processes.
Not yet verified at runtime:
- A full end-to-end turn (no prompt was sent, so no tokens were spent): text /
reasoning / tool-part streaming and abort handling are untested against a
live model.
- MIMOCODE_CONFIG_CONTENT accepting the OpenCode config schema (permission,
mcp, model, share, autoupdate) end-to-end; only that the env var exists in
the binary has been confirmed.
- Whether the loopback server needs MIMOCODE_SERVER_PASSWORD when the API
client attaches.
- The placeholder public/ai/agents/mimo.svg still needs an official asset.
- Multi-turn resume (resumeSessionId) and MCP injection against the live CLI.
* feat(ai): inject MIMOCODE_BIN for discovered MiMo Code agents
Mirror the OpenCode OPENCODE_BIN handling so a discovered or re-detected
mimo binary path reaches the driver, and cover it with the same assertion
shape as the opencode managed-agent env test.
* fix(ai): use MiMo branding in the mimo driver
* test(ai): cover the mimo driver
Add a unit test file for the MiMo Code driver, matching the existing
opencode driver test in shape, runner (node:test via node --test) and
`.test.cjs` extension. It is the last driver in the registry without
one.
Coverage:
- spawn/launch: `mimo serve --hostname/--port` argv, binary resolution
(explicit binPath / MIMOCODE_BIN / MIMOCODE_BIN_PATH), pass-through
env and MIMOCODE_CONFIG_CONTENT; `child_process.spawn` is stubbed, so
no real `mimo` process is ever started.
- readiness: parsing of `mimocode server listening on <url>` from
stdout (including split chunks) and stderr, the OpenCode spelling,
and the MIMO_SERVE_TIMEOUT_MS timeout path (asserts the rejection and
that the child is killed).
- abort/cleanup: stopMimoProcess kill/idempotency/swallow, the Windows
taskkill tree kill, server.close() teardown, and abort mid-turn with
a throwing close().
- branding: OpenCode -> MiMo Code for the busy/idle/status, failed and
tool-failure fallback strings, with tool output and non-brand
technical errors left verbatim.
- happy path: session create -> streamed event translation -> done,
plus listMimoModels catalog mapping and the empty/aborted paths.
* fix(ai): filter MiMo events by session and stop the server behind the npm shim
Address review on #3500:
- The global SSE stream carries every session on the server, and
runMimoTurn translated all of them, so another session's text could leak
into the reply and its session.idle could end the turn early. Skip events
whose session id is not ours, reusing the OpenCode driver's
getOpenCodeSessionIdFromEvent (now exported). Covered by a test with
interleaved sessions.
- On macOS/Linux the official @mimo-ai/cli `mimo` is a Node shim that runs
the native binary through spawnSync, so killing the shim left the server
listening. `mimo serve` is now spawned detached on POSIX and
stopMimoProcess signals its whole process group (SIGTERM, then SIGKILL
after a grace period). Windows keeps taskkill /T.
Verified against the real @mimo-ai/cli@0.1.15 npm shim: on Linux (WSL
Ubuntu 22.04) the listener is the native .mimocode child; before this change
it was still listening 3s after close(), now the port is released within 1s
and no mimo process remains. On Windows the .cmd shim path also releases the
port within 1s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: harden MiMo CLI integration before merge
* fix: wait for MiMo events and handle setup cancellation
* fix: finish MiMo stream handling and scope skill access
* fix: preflight MiMo skill paths before one server startup
* fix: scope MiMo skill reads to trusted roots
* fix: allow MiMo skills from ancestor project roots
* fix: honor MiMo observer and confirm command permissions
* fix: clear MiMo approval when its service exits
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
512 lines
15 KiB
TypeScript
512 lines
15 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
buildManagedAgentState,
|
|
getInitialManagedAgentPaths,
|
|
updateCodebuddyManagedEnv,
|
|
updateCodebuddyManagedOptions,
|
|
} from '../settings/tabs/ai/managedAgentState';
|
|
import type { ExternalAgentConfig } from '../../infrastructure/ai/types';
|
|
|
|
test('buildManagedAgentState removes stale managed agents when path detection fails', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'discovered_codex',
|
|
name: 'Codex CLI',
|
|
command: '/usr/local/bin/codex',
|
|
enabled: true,
|
|
sdkBackend: 'codex',
|
|
},
|
|
{
|
|
id: 'custom-agent',
|
|
name: 'Custom Agent',
|
|
command: '/usr/local/bin/custom-agent',
|
|
enabled: true,
|
|
},
|
|
];
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'discovered_codex',
|
|
'codex',
|
|
{ path: '/usr/local/bin/codex', version: null, available: false },
|
|
);
|
|
|
|
assert.deepEqual(
|
|
state.agents.map((agent) => agent.id),
|
|
['custom-agent'],
|
|
);
|
|
assert.equal(state.defaultAgentId, 'catty');
|
|
});
|
|
|
|
test('buildManagedAgentState keeps unrelated defaults when removing stale managed agents', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'discovered_claude',
|
|
name: 'Claude Code',
|
|
command: '/usr/local/bin/claude',
|
|
enabled: true,
|
|
sdkBackend: 'claude',
|
|
},
|
|
{
|
|
id: 'custom-agent',
|
|
name: 'Custom Agent',
|
|
command: '/usr/local/bin/custom-agent',
|
|
enabled: true,
|
|
},
|
|
];
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'custom-agent',
|
|
'claude',
|
|
{ path: '/usr/local/bin/claude', version: null, available: false },
|
|
);
|
|
|
|
assert.deepEqual(
|
|
state.agents.map((agent) => agent.id),
|
|
['custom-agent'],
|
|
);
|
|
assert.equal(state.defaultAgentId, 'custom-agent');
|
|
});
|
|
|
|
test('buildManagedAgentState stores the system Claude executable for SDK runs', () => {
|
|
const state = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'claude',
|
|
{ path: '/opt/homebrew/bin/claude', version: '2.1.145 (Claude Code)', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].command, '/opt/homebrew/bin/claude');
|
|
assert.equal(state.agents[0].sdkBackend, 'claude');
|
|
assert.deepEqual(state.agents[0].env, {
|
|
CLAUDE_CODE_EXECUTABLE: '/opt/homebrew/bin/claude',
|
|
});
|
|
});
|
|
|
|
test('buildManagedAgentState stores SDK backend keys for discovered managed agents', () => {
|
|
const codexState = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'codex',
|
|
{ path: '/opt/homebrew/bin/codex', version: '1.0.0', available: true },
|
|
);
|
|
const copilotState = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'copilot',
|
|
{ path: '/opt/homebrew/bin/copilot', version: '1.0.0', available: true },
|
|
);
|
|
|
|
assert.equal(codexState.agents[0].sdkBackend, 'codex');
|
|
assert.equal(codexState.agents[0].cliVersion, '1.0.0');
|
|
assert.equal(copilotState.agents[0].sdkBackend, 'copilot');
|
|
assert.equal(copilotState.agents[0].acpArgs, undefined);
|
|
});
|
|
|
|
test('buildManagedAgentState preserves the experimental Codex runtime across path refreshes', () => {
|
|
const state = buildManagedAgentState(
|
|
[{
|
|
id: 'discovered_codex',
|
|
name: 'Codex CLI',
|
|
command: '/old/codex',
|
|
enabled: true,
|
|
sdkBackend: 'codex',
|
|
codexRuntime: 'app-server',
|
|
}],
|
|
'discovered_codex',
|
|
'codex',
|
|
{ path: '/new/codex', version: '0.144.3', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents[0].codexRuntime, 'app-server');
|
|
assert.equal(state.agents[0].command, '/new/codex');
|
|
});
|
|
|
|
test('buildManagedAgentState preserves Grok runtime across path refreshes', () => {
|
|
const state = buildManagedAgentState(
|
|
[{
|
|
id: 'discovered_grok',
|
|
name: 'Grok Build',
|
|
command: '/old/grok',
|
|
enabled: true,
|
|
sdkBackend: 'grok',
|
|
grokRuntime: 'streaming-json',
|
|
}],
|
|
'discovered_grok',
|
|
'grok',
|
|
{ path: '/new/grok', version: '0.2.118', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents[0].grokRuntime, 'streaming-json');
|
|
assert.equal(state.agents[0].command, '/new/grok');
|
|
assert.equal(state.agents[0].sdkBackend, 'grok');
|
|
});
|
|
|
|
test('getInitialManagedAgentPaths ignores auto-detected command paths', () => {
|
|
const state = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'codex',
|
|
{ path: '/opt/homebrew/bin/codex', version: '1.0.0', available: true },
|
|
'auto',
|
|
);
|
|
|
|
assert.equal(state.agents[0].commandSource, 'auto');
|
|
assert.equal(getInitialManagedAgentPaths(state.agents).codex, '');
|
|
});
|
|
|
|
test('getInitialManagedAgentPaths keeps manual and legacy command paths', () => {
|
|
const manualState = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'codex',
|
|
{ path: '/opt/homebrew/bin/codex', version: '1.0.0', available: true },
|
|
'manual',
|
|
);
|
|
|
|
assert.equal(getInitialManagedAgentPaths(manualState.agents).codex, '/opt/homebrew/bin/codex');
|
|
assert.equal(getInitialManagedAgentPaths([{
|
|
id: 'discovered_codex',
|
|
name: 'Codex CLI',
|
|
command: '/legacy/bin/codex',
|
|
enabled: true,
|
|
available: true,
|
|
sdkBackend: 'codex',
|
|
}]).codex, '/legacy/bin/codex');
|
|
});
|
|
|
|
test('buildManagedAgentState stores SDK backend key for discovered Cursor', () => {
|
|
const state = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'cursor',
|
|
{ path: 'cursor', version: 'Cursor SDK 1.0.18', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents[0].id, 'discovered_cursor');
|
|
assert.equal(state.agents[0].name, 'Cursor');
|
|
assert.equal(state.agents[0].command, 'cursor');
|
|
assert.equal(state.agents[0].sdkBackend, 'cursor');
|
|
});
|
|
|
|
test('buildManagedAgentState preserves a saved Cursor API key when SDK is not ready', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'discovered_cursor',
|
|
name: 'Cursor',
|
|
command: 'cursor',
|
|
enabled: true,
|
|
available: true,
|
|
sdkBackend: 'cursor',
|
|
apiKey: 'enc:v1:test',
|
|
},
|
|
];
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'discovered_cursor',
|
|
'cursor',
|
|
{ path: 'cursor', version: 'Cursor SDK', available: false, installed: true },
|
|
);
|
|
|
|
assert.equal(state.agents[0].id, 'discovered_cursor');
|
|
assert.equal(state.agents[0].apiKey, 'enc:v1:test');
|
|
// Keep enabled so a later mode/path that becomes available is not sticky-disabled.
|
|
assert.equal(state.agents[0].enabled, true);
|
|
assert.equal(state.agents[0].available, false);
|
|
assert.equal(state.defaultAgentId, 'catty');
|
|
});
|
|
|
|
test('buildManagedAgentState preserves enabled when CLI login probe is temporarily unavailable', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'discovered_cursor',
|
|
name: 'Cursor',
|
|
command: '/bin/cursor-agent',
|
|
enabled: true,
|
|
available: true,
|
|
sdkBackend: 'cursor',
|
|
cursorAuthMode: 'cli-login',
|
|
apiKey: 'enc:v1:test',
|
|
},
|
|
];
|
|
|
|
const unavailable = buildManagedAgentState(
|
|
agents,
|
|
'discovered_cursor',
|
|
'cursor',
|
|
{
|
|
path: 'cursor',
|
|
version: 'Cursor Agent CLI',
|
|
available: false,
|
|
installed: true,
|
|
cliLoginOk: false,
|
|
apiKeyOk: true,
|
|
sdkInstalled: true,
|
|
},
|
|
);
|
|
assert.equal(unavailable.agents[0].enabled, true);
|
|
assert.equal(unavailable.agents[0].available, false);
|
|
assert.equal(unavailable.agents[0].apiKey, 'enc:v1:test');
|
|
assert.equal(unavailable.agents[0].cursorAuthMode, 'cli-login');
|
|
|
|
// When CLI login returns, mode-aware available becomes true and enabled stays on.
|
|
const recovered = buildManagedAgentState(
|
|
unavailable.agents,
|
|
'catty',
|
|
'cursor',
|
|
{
|
|
path: '/bin/cursor-agent',
|
|
cliBinPath: '/bin/cursor-agent',
|
|
version: 'Cursor Agent CLI',
|
|
available: true,
|
|
installed: true,
|
|
cliLoginOk: true,
|
|
apiKeyOk: true,
|
|
sdkInstalled: true,
|
|
authSource: 'cli-login',
|
|
},
|
|
);
|
|
assert.equal(recovered.agents[0].enabled, true);
|
|
assert.equal(recovered.agents[0].available, true);
|
|
assert.equal(recovered.agents[0].cursorAuthMode, 'cli-login');
|
|
assert.equal(recovered.agents[0].command, '/bin/cursor-agent');
|
|
});
|
|
|
|
test('buildManagedAgentState keeps API key when Cursor stays on CLI login mode', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'discovered_cursor',
|
|
name: 'Cursor',
|
|
command: '/bin/cursor-agent',
|
|
enabled: true,
|
|
available: true,
|
|
sdkBackend: 'cursor',
|
|
cursorAuthMode: 'cli-login',
|
|
apiKey: 'enc:v1:keep-me',
|
|
},
|
|
];
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'discovered_cursor',
|
|
'cursor',
|
|
{
|
|
path: '/bin/cursor-agent',
|
|
cliBinPath: '/bin/cursor-agent',
|
|
version: 'Cursor Agent CLI',
|
|
available: true,
|
|
installed: true,
|
|
cliLoginOk: true,
|
|
apiKeyOk: true,
|
|
sdkInstalled: true,
|
|
authSource: 'cli-login',
|
|
},
|
|
);
|
|
|
|
assert.equal(state.agents[0].apiKey, 'enc:v1:keep-me');
|
|
assert.equal(state.agents[0].cursorAuthMode, 'cli-login');
|
|
});
|
|
|
|
test('buildManagedAgentState stores CODEBUDDY_CODE_PATH for codebuddy', () => {
|
|
const state = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'codebuddy',
|
|
{ path: '/opt/homebrew/bin/codebuddy', version: '0.1.0', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].command, '/opt/homebrew/bin/codebuddy');
|
|
assert.equal(state.agents[0].sdkBackend, 'codebuddy');
|
|
assert.deepEqual(state.agents[0].env, {
|
|
CODEBUDDY_CODE_PATH: '/opt/homebrew/bin/codebuddy',
|
|
});
|
|
});
|
|
|
|
test('buildManagedAgentState stores OPENCODE_BIN for opencode', () => {
|
|
const state = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'opencode',
|
|
{ path: '/opt/homebrew/bin/opencode', version: '1.0.0', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].id, 'discovered_opencode');
|
|
assert.equal(state.agents[0].command, '/opt/homebrew/bin/opencode');
|
|
assert.equal(state.agents[0].sdkBackend, 'opencode');
|
|
assert.deepEqual(state.agents[0].env, {
|
|
OPENCODE_BIN: '/opt/homebrew/bin/opencode',
|
|
});
|
|
});
|
|
|
|
test('buildManagedAgentState stores MIMOCODE_BIN for mimo', () => {
|
|
const state = buildManagedAgentState(
|
|
[],
|
|
'catty',
|
|
'mimo',
|
|
{ path: '/opt/homebrew/bin/mimo', version: '1.0.0', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].id, 'discovered_mimo');
|
|
assert.equal(state.agents[0].command, '/opt/homebrew/bin/mimo');
|
|
assert.equal(state.agents[0].sdkBackend, 'mimo');
|
|
assert.deepEqual(state.agents[0].env, {
|
|
MIMOCODE_BIN: '/opt/homebrew/bin/mimo',
|
|
});
|
|
});
|
|
|
|
test('updateCodebuddyManagedEnv creates a disabled managed entry before CLI detection', () => {
|
|
const state = updateCodebuddyManagedEnv([], 'internal', 'CODEBUDDY_API_KEY=secret');
|
|
|
|
assert.equal(state.length, 1);
|
|
assert.equal(state[0].id, 'discovered_codebuddy');
|
|
assert.equal(state[0].command, 'codebuddy');
|
|
assert.equal(state[0].enabled, false);
|
|
assert.deepEqual(state[0].env, {
|
|
CODEBUDDY_INTERNET_ENVIRONMENT: 'internal',
|
|
CODEBUDDY_API_KEY: 'secret',
|
|
});
|
|
});
|
|
|
|
test('buildManagedAgentState preserves disabled CodeBuddy config when path detection fails', () => {
|
|
const agents = updateCodebuddyManagedEnv([], 'ioa', 'CODEBUDDY_AUTH_TOKEN=token');
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'discovered_codebuddy',
|
|
'codebuddy',
|
|
{ path: null, version: null, available: false },
|
|
);
|
|
|
|
assert.equal(state.defaultAgentId, 'catty');
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].id, 'discovered_codebuddy');
|
|
assert.equal(state.agents[0].enabled, false);
|
|
assert.deepEqual(state.agents[0].env, {
|
|
CODEBUDDY_INTERNET_ENVIRONMENT: 'ioa',
|
|
CODEBUDDY_AUTH_TOKEN: 'token',
|
|
});
|
|
});
|
|
|
|
test('buildManagedAgentState enables preconfigured CodeBuddy when path detection succeeds', () => {
|
|
const agents = updateCodebuddyManagedEnv([], 'internal', 'CODEBUDDY_API_KEY=secret');
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'catty',
|
|
'codebuddy',
|
|
{ path: '/opt/homebrew/bin/codebuddy', version: '0.1.0', available: true },
|
|
);
|
|
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].enabled, true);
|
|
assert.equal(state.agents[0].command, '/opt/homebrew/bin/codebuddy');
|
|
assert.deepEqual(state.agents[0].env, {
|
|
CODEBUDDY_INTERNET_ENVIRONMENT: 'internal',
|
|
CODEBUDDY_API_KEY: 'secret',
|
|
CODEBUDDY_CODE_PATH: '/opt/homebrew/bin/codebuddy',
|
|
});
|
|
});
|
|
|
|
test('updateCodebuddyManagedEnv removes an empty pre-detection placeholder', () => {
|
|
const agents = updateCodebuddyManagedEnv([], 'internal', 'CODEBUDDY_API_KEY=secret');
|
|
const cleared = updateCodebuddyManagedEnv(agents, '', '');
|
|
|
|
assert.deepEqual(cleared, []);
|
|
});
|
|
|
|
test('updateCodebuddyManagedOptions persists settings before CLI detection', () => {
|
|
const state = updateCodebuddyManagedOptions([], {
|
|
effort: 'high',
|
|
enableFileCheckpointing: true,
|
|
});
|
|
|
|
assert.equal(state.length, 1);
|
|
assert.equal(state[0].id, 'discovered_codebuddy');
|
|
assert.equal(state[0].command, 'codebuddy');
|
|
assert.equal(state[0].enabled, false);
|
|
assert.deepEqual(state[0].codebuddyOptions, {
|
|
effort: 'high',
|
|
enableFileCheckpointing: true,
|
|
});
|
|
});
|
|
|
|
test('buildManagedAgentState preserves advanced CodeBuddy config when detection fails', () => {
|
|
const agents = updateCodebuddyManagedOptions([], { effort: 'high' });
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'discovered_codebuddy',
|
|
'codebuddy',
|
|
{ path: null, version: null, available: false },
|
|
);
|
|
|
|
assert.equal(state.defaultAgentId, 'catty');
|
|
assert.equal(state.agents.length, 1);
|
|
assert.equal(state.agents[0].enabled, false);
|
|
assert.equal(state.agents[0].available, false);
|
|
assert.deepEqual(state.agents[0].codebuddyOptions, { effort: 'high' });
|
|
});
|
|
|
|
test('updateCodebuddyManagedOptions removes an empty pre-detection placeholder', () => {
|
|
const agents = updateCodebuddyManagedOptions([], { effort: 'high' });
|
|
const cleared = updateCodebuddyManagedOptions(agents, undefined);
|
|
|
|
assert.deepEqual(cleared, []);
|
|
});
|
|
|
|
test('buildManagedAgentState does not remove user-created matching agents', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'my-claude-wrapper',
|
|
name: 'My Claude Wrapper',
|
|
command: '/usr/local/bin/claude',
|
|
enabled: true,
|
|
sdkBackend: 'claude',
|
|
},
|
|
];
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'my-claude-wrapper',
|
|
'claude',
|
|
{ path: '/usr/local/bin/claude', version: null, available: false },
|
|
);
|
|
|
|
assert.deepEqual(state.agents, agents);
|
|
assert.equal(state.defaultAgentId, 'my-claude-wrapper');
|
|
});
|
|
|
|
test('buildManagedAgentState only rewrites settings-managed discovered agents', () => {
|
|
const agents: ExternalAgentConfig[] = [
|
|
{
|
|
id: 'my-codex-wrapper',
|
|
name: 'My Codex Wrapper',
|
|
command: '/usr/local/bin/codex',
|
|
enabled: true,
|
|
sdkBackend: 'codex',
|
|
},
|
|
];
|
|
|
|
const state = buildManagedAgentState(
|
|
agents,
|
|
'my-codex-wrapper',
|
|
'codex',
|
|
{ path: '/opt/netcatty/codex', version: 'Bundled legacy adapter', available: true },
|
|
);
|
|
|
|
assert.deepEqual(
|
|
state.agents.map((agent) => agent.id),
|
|
['my-codex-wrapper', 'discovered_codex'],
|
|
);
|
|
assert.equal(state.agents[0], agents[0]);
|
|
assert.equal(state.defaultAgentId, 'my-codex-wrapper');
|
|
});
|