(binaryPath: string)
| 29 | * ``` |
| 30 | */ |
| 31 | export function createFreebuffTmuxTools(binaryPath: string): { |
| 32 | tools: FreebuffToolDefinition[] |
| 33 | cleanup: () => Promise<void> |
| 34 | } { |
| 35 | let session: FreebuffSession | null = null |
| 36 | |
| 37 | const startTool: FreebuffToolDefinition = { |
| 38 | toolName: 'start_freebuff', |
| 39 | description: |
| 40 | 'Start the Freebuff CLI binary in a tmux terminal session. Call this first before interacting with Freebuff.', |
| 41 | inputSchema: z.object({}), |
| 42 | endsAgentStep: true, |
| 43 | exampleInputs: [{}], |
| 44 | execute: async (): Promise<ToolOutput> => { |
| 45 | if (session) { |
| 46 | return [ |
| 47 | { |
| 48 | type: 'json', |
| 49 | value: { |
| 50 | error: 'Session already running', |
| 51 | sessionName: session.name, |
| 52 | }, |
| 53 | }, |
| 54 | ] |
| 55 | } |
| 56 | session = await FreebuffSession.start(binaryPath) |
| 57 | await session.waitForReady() |
| 58 | const initialOutput = await session.capture() |
| 59 | return [ |
| 60 | { |
| 61 | type: 'json', |
| 62 | value: { |
| 63 | started: true, |
| 64 | sessionName: session.name, |
| 65 | initialOutput, |
| 66 | }, |
| 67 | }, |
| 68 | ] |
| 69 | }, |
| 70 | } |
| 71 | |
| 72 | const sendInputTool: FreebuffToolDefinition = { |
| 73 | toolName: 'send_to_freebuff', |
| 74 | description: |
| 75 | 'Send text input to the running Freebuff CLI. The text is sent as if typed by the user and Enter is pressed.', |
| 76 | inputSchema: z.object({ |
| 77 | text: z.string().describe('Text to send to Freebuff'), |
| 78 | }), |
| 79 | endsAgentStep: false, |
| 80 | exampleInputs: [{ text: '/help' }], |
| 81 | execute: async (input): Promise<ToolOutput> => { |
| 82 | const text = (input as { text: string }).text |
| 83 | if (!session) { |
| 84 | return [ |
| 85 | { |
| 86 | type: 'json', |
| 87 | value: { error: 'No session running. Call start_freebuff first.' }, |
| 88 | }, |
no test coverage detected