v2.2-paseo-providers: Paseo provider stack + v2.2.1 pane-scoped chat fixes
Ship Paseo-equivalent provider snapshot, AgentComposerBar, ACP dispatch rewrite with streaming/persist, permission prompts, and agent commands. Follow-up: pane-scoped chat resolution, CoderMessageList tool timeline, WS user-delta replace, and inference orphan tool_call stripping. Archive openspec v2-2; update CHANGELOG and CURRENT. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
154
apps/coder/src/services/__tests__/acp-derive.test.ts
Normal file
154
apps/coder/src/services/__tests__/acp-derive.test.ts
Normal file
@@ -0,0 +1,154 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { SessionConfigOption } from '@agentclientprotocol/sdk';
|
||||
import {
|
||||
deriveModesFromACP,
|
||||
deriveModelDefinitionsFromACP,
|
||||
findThoughtLevelConfigId,
|
||||
} from '../acp-derive.js';
|
||||
|
||||
describe('deriveModesFromACP', () => {
|
||||
it('prefers modeState.availableModes when present', () => {
|
||||
const { modes, currentModeId } = deriveModesFromACP(
|
||||
[{ id: 'fallback', label: 'Fallback' }],
|
||||
{
|
||||
currentModeId: 'plan',
|
||||
availableModes: [
|
||||
{ id: 'plan', name: 'Plan', description: 'Read-only planning' },
|
||||
{ id: 'code', name: 'Code' },
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
expect(modes).toEqual([
|
||||
{ id: 'plan', label: 'Plan', description: 'Read-only planning' },
|
||||
{ id: 'code', label: 'Code', description: undefined },
|
||||
]);
|
||||
expect(currentModeId).toBe('plan');
|
||||
});
|
||||
|
||||
it('falls back to configOptions mode select', () => {
|
||||
const configOptions: SessionConfigOption[] = [
|
||||
{
|
||||
type: 'select',
|
||||
id: 'mode',
|
||||
category: 'mode',
|
||||
currentValue: 'auto',
|
||||
options: [
|
||||
{ value: 'auto', name: 'Auto' },
|
||||
{ value: 'manual', name: 'Manual', description: 'Ask first' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const { modes, currentModeId } = deriveModesFromACP([], null, configOptions);
|
||||
|
||||
expect(modes).toEqual([
|
||||
{ id: 'auto', label: 'Auto', description: undefined },
|
||||
{ id: 'manual', label: 'Manual', description: 'Ask first' },
|
||||
]);
|
||||
expect(currentModeId).toBe('auto');
|
||||
});
|
||||
|
||||
it('uses static fallback when no ACP mode data', () => {
|
||||
const fallback = [{ id: 'default', label: 'Default' }];
|
||||
const { modes, currentModeId } = deriveModesFromACP(fallback, null, null);
|
||||
|
||||
expect(modes).toEqual(fallback);
|
||||
expect(currentModeId).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('deriveModelDefinitionsFromACP', () => {
|
||||
it('maps availableModels with thought_level options', () => {
|
||||
const configOptions: SessionConfigOption[] = [
|
||||
{
|
||||
type: 'select',
|
||||
id: 'thought',
|
||||
category: 'thought_level',
|
||||
currentValue: 'medium',
|
||||
options: [
|
||||
{ value: 'low', name: 'Low' },
|
||||
{ value: 'medium', name: 'Medium' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const models = deriveModelDefinitionsFromACP(
|
||||
{
|
||||
currentModelId: 'gpt-4',
|
||||
availableModels: [
|
||||
{ modelId: 'gpt-4', name: 'GPT-4' },
|
||||
{ modelId: 'gpt-4-mini', name: 'Mini', description: 'Cheaper' },
|
||||
],
|
||||
},
|
||||
configOptions,
|
||||
);
|
||||
|
||||
expect(models).toEqual([
|
||||
{
|
||||
id: 'gpt-4',
|
||||
label: 'GPT-4',
|
||||
description: undefined,
|
||||
isDefault: true,
|
||||
thinkingOptions: [
|
||||
{ id: 'low', label: 'Low', isDefault: false },
|
||||
{ id: 'medium', label: 'Medium', isDefault: true },
|
||||
],
|
||||
defaultThinkingOptionId: 'medium',
|
||||
},
|
||||
{
|
||||
id: 'gpt-4-mini',
|
||||
label: 'Mini',
|
||||
description: 'Cheaper',
|
||||
isDefault: false,
|
||||
thinkingOptions: [
|
||||
{ id: 'low', label: 'Low', isDefault: false },
|
||||
{ id: 'medium', label: 'Medium', isDefault: true },
|
||||
],
|
||||
defaultThinkingOptionId: 'medium',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('falls back to model select config when no availableModels', () => {
|
||||
const configOptions: SessionConfigOption[] = [
|
||||
{
|
||||
type: 'select',
|
||||
id: 'model',
|
||||
category: 'model',
|
||||
currentValue: 'sonnet',
|
||||
options: [
|
||||
{ value: 'sonnet', name: 'Sonnet' },
|
||||
{ value: 'opus', name: 'Opus' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const models = deriveModelDefinitionsFromACP(null, configOptions);
|
||||
|
||||
expect(models).toEqual([
|
||||
{ id: 'sonnet', label: 'Sonnet', isDefault: true, defaultThinkingOptionId: undefined },
|
||||
{ id: 'opus', label: 'Opus', isDefault: false, defaultThinkingOptionId: undefined },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findThoughtLevelConfigId', () => {
|
||||
it('returns thought_level select id', () => {
|
||||
const configOptions: SessionConfigOption[] = [
|
||||
{
|
||||
type: 'select',
|
||||
id: 'effort',
|
||||
category: 'thought_level',
|
||||
currentValue: 'high',
|
||||
options: [{ value: 'high', name: 'High' }],
|
||||
},
|
||||
];
|
||||
|
||||
expect(findThoughtLevelConfigId(configOptions)).toBe('effort');
|
||||
});
|
||||
|
||||
it('returns null when missing', () => {
|
||||
expect(findThoughtLevelConfigId(null)).toBeNull();
|
||||
});
|
||||
});
|
||||
66
apps/coder/src/services/__tests__/acp-tool-snapshot.test.ts
Normal file
66
apps/coder/src/services/__tests__/acp-tool-snapshot.test.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
mergeToolSnapshot,
|
||||
mapToolLifecycleStatus,
|
||||
snapshotToWireToolCall,
|
||||
synthesizeCanceledSnapshots,
|
||||
} from '../acp-tool-snapshot.js';
|
||||
|
||||
describe('mergeToolSnapshot', () => {
|
||||
it('preserves stable toolCallId across updates', () => {
|
||||
const first = mergeToolSnapshot('tc-1', {
|
||||
toolCallId: 'tc-1',
|
||||
title: 'Read file',
|
||||
kind: 'read',
|
||||
status: 'in_progress',
|
||||
rawInput: { path: 'foo.ts' },
|
||||
});
|
||||
const merged = mergeToolSnapshot(
|
||||
'tc-1',
|
||||
{
|
||||
toolCallId: 'tc-1',
|
||||
title: 'Read file',
|
||||
status: 'completed',
|
||||
rawOutput: { content: 'hello' },
|
||||
},
|
||||
first,
|
||||
);
|
||||
expect(merged.toolCallId).toBe('tc-1');
|
||||
expect(merged.rawInput).toEqual({ path: 'foo.ts' });
|
||||
expect(merged.status).toBe('completed');
|
||||
expect(merged.rawOutput).toEqual({ content: 'hello' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('snapshotToWireToolCall', () => {
|
||||
it('embeds ACP lifecycle meta for UI merge', () => {
|
||||
const wire = snapshotToWireToolCall({
|
||||
toolCallId: 'tc-42',
|
||||
title: 'Edit',
|
||||
kind: 'edit',
|
||||
status: 'completed',
|
||||
rawInput: { path: 'a.ts' },
|
||||
rawOutput: 'ok',
|
||||
});
|
||||
expect(wire.id).toBe('tc-42');
|
||||
expect(wire.name).toBe('edit');
|
||||
expect(wire.args._acp).toMatchObject({ status: 'completed', title: 'Edit', output: 'ok' });
|
||||
});
|
||||
|
||||
it('maps synthesized cancel to canceled lifecycle', () => {
|
||||
const [canceled] = synthesizeCanceledSnapshots([
|
||||
{ toolCallId: 'tc-1', title: 'Run', status: 'in_progress' },
|
||||
]);
|
||||
const wire = snapshotToWireToolCall(canceled!);
|
||||
expect(wire.args._acp).toMatchObject({ status: 'canceled' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapToolLifecycleStatus', () => {
|
||||
it('maps ACP statuses to UI lifecycle', () => {
|
||||
expect(mapToolLifecycleStatus('completed')).toBe('completed');
|
||||
expect(mapToolLifecycleStatus('failed')).toBe('failed');
|
||||
expect(mapToolLifecycleStatus('in_progress')).toBe('running');
|
||||
expect(mapToolLifecycleStatus(undefined, 'canceled')).toBe('canceled');
|
||||
});
|
||||
});
|
||||
47
apps/coder/src/services/__tests__/cursor-models.test.ts
Normal file
47
apps/coder/src/services/__tests__/cursor-models.test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseCursorAgentModelsOutput } from '../cursor-models.js';
|
||||
|
||||
describe('parseCursorAgentModelsOutput', () => {
|
||||
it('parses cursor-agent models output with default marker', () => {
|
||||
const output = `
|
||||
Available models
|
||||
claude-4-sonnet - Claude 4 Sonnet (default)
|
||||
gpt-4.1 - GPT-4.1
|
||||
Tip: use cursor-agent models for full list
|
||||
`.trim();
|
||||
|
||||
const models = parseCursorAgentModelsOutput(output);
|
||||
|
||||
expect(models).toEqual([
|
||||
{ id: 'claude-4-sonnet', label: 'Claude 4 Sonnet', isDefault: true },
|
||||
{ id: 'gpt-4.1', label: 'GPT-4.1', isDefault: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it('uses current marker when no default', () => {
|
||||
const output = `
|
||||
model-a - Model A (current)
|
||||
model-b - Model B
|
||||
`.trim();
|
||||
|
||||
const models = parseCursorAgentModelsOutput(output);
|
||||
|
||||
expect(models.find((m) => m.id === 'model-a')?.isDefault).toBe(true);
|
||||
expect(models.find((m) => m.id === 'model-b')?.isDefault).toBe(false);
|
||||
});
|
||||
|
||||
it('defaults to first model when no markers', () => {
|
||||
const output = 'alpha - Alpha\nbeta - Beta';
|
||||
const models = parseCursorAgentModelsOutput(output);
|
||||
|
||||
expect(models[0]?.isDefault).toBe(true);
|
||||
expect(models[1]?.isDefault).toBe(false);
|
||||
});
|
||||
|
||||
it('skips malformed lines', () => {
|
||||
const output = 'no-separator\nvalid - Valid';
|
||||
const models = parseCursorAgentModelsOutput(output);
|
||||
|
||||
expect(models).toEqual([{ id: 'valid', label: 'Valid', isDefault: true }]);
|
||||
});
|
||||
});
|
||||
26
apps/coder/src/services/__tests__/provider-commands.test.ts
Normal file
26
apps/coder/src/services/__tests__/provider-commands.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { getManifestCommands, mergeCommands, PROVIDER_COMMANDS } from '../provider-commands.js';
|
||||
|
||||
describe('provider-commands', () => {
|
||||
it('defines commands for every external harness', () => {
|
||||
for (const name of ['claude', 'opencode', 'cursor', 'goose', 'qwen', 'copilot']) {
|
||||
expect(getManifestCommands(name).length, name).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
|
||||
it('boocode uses frontend skills — empty manifest', () => {
|
||||
expect(getManifestCommands('boocode')).toEqual([]);
|
||||
expect(PROVIDER_COMMANDS.boocode).toEqual([]);
|
||||
});
|
||||
|
||||
it('mergeCommands dedupes by name with later override', () => {
|
||||
const merged = mergeCommands(
|
||||
[{ name: 'help', description: 'a' }],
|
||||
[{ name: 'help', description: 'b' }, { name: 'clear' }],
|
||||
);
|
||||
expect(merged).toEqual([
|
||||
{ name: 'clear' },
|
||||
{ name: 'help', description: 'b' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
168
apps/coder/src/services/__tests__/provider-snapshot.test.ts
Normal file
168
apps/coder/src/services/__tests__/provider-snapshot.test.ts
Normal file
@@ -0,0 +1,168 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import {
|
||||
mergeModels,
|
||||
prefixLlamaSwapModels,
|
||||
clearProviderSnapshotCache,
|
||||
getProviderSnapshot,
|
||||
} from '../provider-snapshot.js';
|
||||
|
||||
vi.mock('../acp-probe.js', () => ({
|
||||
probeAcpProvider: vi.fn(),
|
||||
}));
|
||||
|
||||
import { probeAcpProvider } from '../acp-probe.js';
|
||||
|
||||
const mockProbe = vi.mocked(probeAcpProvider);
|
||||
|
||||
function mockSql(agents: Array<{
|
||||
name: string;
|
||||
install_path: string | null;
|
||||
supports_acp: boolean;
|
||||
models: Array<{ id: string; label: string }> | null;
|
||||
label: string | null;
|
||||
transport: string | null;
|
||||
}>) {
|
||||
return vi.fn((strings: TemplateStringsArray) => {
|
||||
const query = strings.join('');
|
||||
if (query.includes('FROM available_agents')) {
|
||||
return Promise.resolve(agents);
|
||||
}
|
||||
if (query.includes('UPDATE available_agents')) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return Promise.resolve([]);
|
||||
}) as unknown as import('../db.js').Sql;
|
||||
}
|
||||
|
||||
const config = {
|
||||
LLAMA_SWAP_URL: 'http://llama-swap.test',
|
||||
} as import('../config.js').Config;
|
||||
|
||||
describe('prefixLlamaSwapModels', () => {
|
||||
it('prefixes bare ids', () => {
|
||||
expect(prefixLlamaSwapModels([{ id: 'qwen3', label: 'qwen3' }])).toEqual([
|
||||
{ id: 'llama-swap/qwen3', label: 'qwen3' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('leaves already-prefixed ids unchanged', () => {
|
||||
expect(prefixLlamaSwapModels([{ id: 'llama-swap/qwen3', label: 'qwen3' }])).toEqual([
|
||||
{ id: 'llama-swap/qwen3', label: 'qwen3' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mergeModels', () => {
|
||||
it('dedupes by id preserving first occurrence', () => {
|
||||
const merged = mergeModels(
|
||||
[{ id: 'a', label: 'A' }],
|
||||
[{ id: 'a', label: 'A2' }, { id: 'b', label: 'B' }],
|
||||
);
|
||||
expect(merged).toEqual([
|
||||
{ id: 'a', label: 'A' },
|
||||
{ id: 'b', label: 'B' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getProviderSnapshot', () => {
|
||||
beforeEach(() => {
|
||||
clearProviderSnapshotCache();
|
||||
vi.restoreAllMocks();
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: [{ id: 'local-model' }, { id: 'llama-swap/existing' }],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('merges opencode ACP models with prefixed llama-swap models', async () => {
|
||||
mockProbe.mockResolvedValue({
|
||||
ok: true,
|
||||
models: [{ id: 'opencode/big-pickle', label: 'Big Pickle', isDefault: true }],
|
||||
modes: [{ id: 'build', label: 'Build' }],
|
||||
defaultModeId: 'build',
|
||||
commands: [{ name: 'custom', description: 'From ACP probe' }],
|
||||
});
|
||||
|
||||
const sql = mockSql([
|
||||
{
|
||||
name: 'opencode',
|
||||
install_path: '/usr/bin/opencode',
|
||||
supports_acp: true,
|
||||
models: null,
|
||||
label: 'OpenCode',
|
||||
transport: 'acp',
|
||||
},
|
||||
]);
|
||||
|
||||
const entries = await getProviderSnapshot(sql, config, '/tmp/project', true);
|
||||
const opencode = entries.find((e) => e.name === 'opencode');
|
||||
|
||||
expect(opencode?.models.map((m) => m.id)).toEqual([
|
||||
'opencode/big-pickle',
|
||||
'llama-swap/local-model',
|
||||
'llama-swap/existing',
|
||||
]);
|
||||
expect(opencode?.commands.some((c) => c.name === 'help')).toBe(true);
|
||||
expect(opencode?.commands.some((c) => c.name === 'custom')).toBe(true);
|
||||
});
|
||||
|
||||
it('combines qwen-shaped probe and settings model lists via mergeModels', () => {
|
||||
const merged = mergeModels(
|
||||
[{ id: 'qwen-probed', label: 'Qwen Probed' }],
|
||||
[{ id: 'from-settings', label: 'from-settings' }],
|
||||
);
|
||||
expect(merged.map((m) => m.id)).toEqual(['qwen-probed', 'from-settings']);
|
||||
});
|
||||
|
||||
it('returns cached entries on second call within TTL', async () => {
|
||||
mockProbe.mockResolvedValue({
|
||||
ok: true,
|
||||
models: [{ id: 'm1', label: 'M1' }],
|
||||
modes: [],
|
||||
defaultModeId: null,
|
||||
commands: [],
|
||||
});
|
||||
|
||||
const sql = mockSql([
|
||||
{
|
||||
name: 'goose',
|
||||
install_path: '/usr/bin/goose',
|
||||
supports_acp: true,
|
||||
models: null,
|
||||
label: 'Goose',
|
||||
transport: 'acp',
|
||||
},
|
||||
]);
|
||||
|
||||
await getProviderSnapshot(sql, config, '/tmp/cwd', true);
|
||||
await getProviderSnapshot(sql, config, '/tmp/cwd', false);
|
||||
|
||||
expect(mockProbe).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('attaches claude thinking options', async () => {
|
||||
const sql = mockSql([
|
||||
{
|
||||
name: 'claude',
|
||||
install_path: '/usr/bin/claude',
|
||||
supports_acp: false,
|
||||
models: [{ id: 'claude-sonnet', label: 'Sonnet' }],
|
||||
label: 'Claude Code',
|
||||
transport: 'pty',
|
||||
},
|
||||
]);
|
||||
|
||||
const entries = await getProviderSnapshot(sql, config, '/tmp/project', true);
|
||||
const claude = entries.find((e) => e.name === 'claude');
|
||||
|
||||
expect(claude?.models[0]?.thinkingOptions?.length).toBeGreaterThan(0);
|
||||
expect(claude?.modes.length).toBeGreaterThan(0);
|
||||
expect(claude?.commands.some((c) => c.name === 'help')).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user