feat(tui,gemini): implement verbose transfer and url image fetch

This commit is contained in:
William Valentin
2026-02-17 10:58:14 -08:00
parent 77ae15b3e2
commit e3b6f9df7c
8 changed files with 254 additions and 30 deletions
+63
View File
@@ -22,6 +22,10 @@ function asRouter(value: unknown): ModelClient & ModelRouter {
return value as ModelClient & ModelRouter;
}
function asModelClient(value: unknown): ModelClient {
return value as ModelClient;
}
function asAgent(value: unknown): NativeAgent {
return value as NativeAgent;
}
@@ -30,6 +34,9 @@ function minimalTuiPrivates(value: MinimalTui): {
handleBackendCommand: (provider: string) => Promise<void>;
handleModelCommand: (tier: string, providerModel?: string) => void;
handleContextCommand: () => void;
handleVerboseCommand: () => void;
handleToolEvent: (event: unknown) => void;
handleCommand: (command: unknown) => Promise<void>;
handleEscapeAction: () => boolean;
prompt: (text: string) => Promise<string>;
rl: {
@@ -45,6 +52,9 @@ function minimalTuiPrivates(value: MinimalTui): {
handleBackendCommand: (provider: string) => Promise<void>;
handleModelCommand: (tier: string, providerModel?: string) => void;
handleContextCommand: () => void;
handleVerboseCommand: () => void;
handleToolEvent: (event: unknown) => void;
handleCommand: (command: unknown) => Promise<void>;
handleEscapeAction: () => boolean;
prompt: (text: string) => Promise<string>;
rl: {
@@ -328,6 +338,59 @@ describe('MinimalTui backend command', () => {
}
}
});
it('prints transfer result text when /transfer is invoked', async () => {
const mockSession = {
id: 'test',
getHistory: () => [],
addMessage: vi.fn(),
clear: vi.fn(),
replaceHistory: vi.fn(),
};
const onTransfer = vi.fn(() => 'Session transferred to Telegram (12345)');
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
try {
const tui = new MinimalTui({
session: asSession(mockSession),
modelClient: asModelClient({}),
systemPrompt: 'test',
onTransfer,
});
await minimalTuiPrivates(tui).handleCommand({ type: 'transfer', target: 'telegram' });
expect(onTransfer).toHaveBeenCalledWith('telegram');
expect(logSpy).toHaveBeenCalledWith('Session transferred to Telegram (12345)\n');
} finally {
logSpy.mockRestore();
}
});
it('only renders tool activity when verbose mode is enabled', () => {
const mockSession = {
id: 'test',
getHistory: () => [],
addMessage: vi.fn(),
clear: vi.fn(),
replaceHistory: vi.fn(),
};
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
try {
const tui = new MinimalTui({
session: asSession(mockSession),
modelClient: asModelClient({}),
systemPrompt: 'test',
});
minimalTuiPrivates(tui).handleToolEvent({ type: 'start', tool: 'shell.exec', args: { command: 'ls' } });
expect(logSpy).not.toHaveBeenCalled();
minimalTuiPrivates(tui).handleVerboseCommand();
minimalTuiPrivates(tui).handleToolEvent({ type: 'start', tool: 'shell.exec', args: { command: 'ls' } });
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('Shell: Exec'));
} finally {
logSpy.mockRestore();
}
});
});
describe('MinimalTui prompt cancellation', () => {