feat(cli): implement send command for one-shot agent messages

This commit is contained in:
William Valentin
2026-02-05 22:15:46 -08:00
parent 72c75a8bd7
commit 237246a8cf
2 changed files with 98 additions and 3 deletions
+25
View File
@@ -0,0 +1,25 @@
import { describe, it, expect, vi } from 'vitest';
import { createSendAgent } from './send.js';
import type { ChatRequest, ChatResponse } from '../models/types.js';
describe('send command', () => {
it('createSendAgent creates an agent that can process a message', async () => {
// Mock model client that returns a canned response
const mockModelClient = {
chat: vi.fn().mockImplementation(async (_request: ChatRequest): Promise<ChatResponse> => ({
content: 'Hello from Flynn!',
stopReason: 'end_turn',
usage: { inputTokens: 10, outputTokens: 5 },
})),
};
const agent = createSendAgent({
modelClient: mockModelClient,
systemPrompt: 'You are Flynn.',
});
const response = await agent.process('Hi there');
expect(response).toBe('Hello from Flynn!');
expect(mockModelClient.chat).toHaveBeenCalledOnce();
});
});