Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,36 @@ describe('executeTaskCreate', () => {
});
});

it('uses ACP for unattended providers whose PTY prompt requires keystroke injection', async () => {
await executeTaskCreate(
{
...automation,
conversationConfig: {
prompt: 'Complete the full assignment',
provider: 'kimi',
autoApprove: true,
type: 'pty',
},
},
run,
noopStep
);

expect(createConversation).toHaveBeenCalledWith(
expect.objectContaining({
provider: 'kimi',
initialQueue: [{ text: 'Complete the full assignment' }],
type: 'acp',
})
);
expect(mockAcpStartSession).toHaveBeenCalledWith({
input: expect.objectContaining({
providerId: 'kimi',
initialQueue: [{ text: 'Complete the full assignment' }],
}),
});
});

it('opens the project when it is not loaded', async () => {
vi.mocked(projectManager.getProject)
.mockReturnValueOnce(undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ function resolveAutomationAgentAutoApprove(
return getPlugin(provider).capabilities.autoApprove.kind === 'supported' ? true : configured;
}

function resolveAutomationConversationType(
provider: AgentProviderId,
configured: 'pty' | 'acp' | undefined
): 'pty' | 'acp' {
if (configured === 'acp' || !isValidProviderId(provider)) return configured ?? 'pty';

const capabilities = getPlugin(provider).capabilities;
// Background runs cannot recover when a TUI misses synthetic paste/Enter delivery. ACP gives
// the prompt to the provider as a structured first turn and acknowledges session startup.
if (capabilities.prompt.kind === 'keystroke' && capabilities.acp.kind === 'supported') {
return 'acp';
}

return 'pty';
}

async function buildAutomationInitialQueue(
automation: Automation,
projectId: string,
Expand Down Expand Up @@ -141,7 +157,10 @@ export async function executeTaskCreate(
const provider = (automation.conversationConfig?.provider ||
(await appSettingsService.get('defaultAgent')) ||
DEFAULT_AGENT_ID) as AgentProviderId;
const conversationType = automation.conversationConfig?.type ?? 'pty';
const conversationType = resolveAutomationConversationType(
provider,
automation.conversationConfig?.type
);
const initialQueue =
conversationType === 'acp'
? await buildAutomationInitialQueue(automation, projectId, prompt)
Expand Down