-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add comprehensive multimodal driver support #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
96f1456
feat: add comprehensive multimodal driver support
JacobFV f5f6a9b
fix(protocol): add missing parseEvent/serializeCommand functions and …
JacobFV 2e64cc0
feat(driver): wire up multimodal options from CLI to driver
JacobFV 1e61f87
fix(driver): add event handlers for multimodal events
JacobFV 80e15b5
chore: bump version to 0.5.0 for multimodal release
JacobFV 576d65a
style(protocol): fix prettier formatting
JacobFV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| # Multimodal Driver Support - Node SDK Updates | ||
|
|
||
| This update adds comprehensive multimodal support to the Node SDK to match the new agi-driver capabilities. | ||
|
|
||
| ## Changes Made | ||
|
|
||
| ### Protocol Updates (`src/driver/protocol.ts`) | ||
|
|
||
| #### New Event Types | ||
| - `AudioTranscriptEvent`: Audio transcript from buffer | ||
| - `VideoFrameEvent`: Video frame from camera/screen | ||
| - `SpeechStartedEvent`: TTS playback started | ||
| - `SpeechFinishedEvent`: TTS playback finished | ||
| - `TurnDetectedEvent`: Voice turn detection | ||
|
|
||
| #### New Command Types | ||
| - `GetAudioTranscriptCommand`: Request audio transcript | ||
| - `GetVideoFrameCommand`: Request video frame | ||
|
|
||
| #### New Interfaces | ||
| - `MCPServerConfig`: MCP server configuration | ||
| - `AgentIdentity`: Agent identity information | ||
| - `ToolChoice`: Tool choice configuration type | ||
|
|
||
| #### Updated StartCommand | ||
| Added fields for multimodal configuration: | ||
| - `agent_identity?: AgentIdentity` - Agent identity (default: agi-2-claude by AGI Company) | ||
| - `tool_choice?: ToolChoice` - Tool choice mode | ||
| - `mcp_servers?: MCPServerConfig[]` - MCP server configurations | ||
| - `audio_input_enabled?: boolean`, `audio_buffer_seconds?: number` | ||
| - `turn_detection_enabled?: boolean`, `turn_detection_silence_ms?: number` | ||
| - `speech_output_enabled?: boolean`, `speech_voice?: string` | ||
| - `camera_enabled?: boolean`, `camera_buffer_seconds?: number` | ||
| - `screen_recording_enabled?: boolean`, `screen_recording_buffer_seconds?: number` | ||
|
|
||
| ### Exports (`src/driver/index.ts`) | ||
| Added exports for all new event and command types, plus helper interfaces. | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Basic Multimodal Session | ||
|
|
||
| ```typescript | ||
| import { AgentDriver } from '@agi-inc/agi-node'; | ||
|
|
||
| const driver = new AgentDriver({ | ||
| mode: 'local', | ||
| agent_name: 'agi-2-claude' | ||
| }); | ||
|
|
||
| // Start with multimodal features | ||
| await driver.start({ | ||
| goal: 'Help me with my computer', | ||
|
JacobFV marked this conversation as resolved.
|
||
| mode: 'local', | ||
| agent_name: 'agi-2-claude', | ||
|
|
||
| // Voice features | ||
| audio_input_enabled: true, | ||
| turn_detection_enabled: true, | ||
| speech_output_enabled: true, | ||
| speech_voice: 'alloy', | ||
|
|
||
| // Video features | ||
| camera_enabled: true, | ||
| screen_recording_enabled: true, | ||
|
|
||
| // MCP servers | ||
| mcp_servers: [ | ||
| { | ||
| name: 'filesystem', | ||
| command: 'npx', | ||
| args: ['-y', '@modelcontextprotocol/server-filesystem', '/path/to/dir'], | ||
| env: {} | ||
| } | ||
| ], | ||
|
|
||
| // Tool choice | ||
| tool_choice: 'auto' | ||
| }); | ||
| ``` | ||
|
|
||
| ### Handling New Events | ||
|
|
||
| ```typescript | ||
| driver.on('audio_transcript', (event: AudioTranscriptEvent) => { | ||
| console.log(`Transcript: ${event.transcript}`); | ||
| }); | ||
|
|
||
| driver.on('video_frame', (event: VideoFrameEvent) => { | ||
| // event.frame_base64 contains JPEG frame | ||
| saveFrame(event.frame_base64); | ||
| }); | ||
|
|
||
| driver.on('speech_started', (event: SpeechStartedEvent) => { | ||
| console.log(`🔊 Speaking: ${event.text}`); | ||
| }); | ||
|
|
||
| driver.on('speech_finished', () => { | ||
| console.log('✓ Finished speaking'); | ||
| }); | ||
|
|
||
| driver.on('turn_detected', (event: TurnDetectedEvent) => { | ||
| console.log(`You said: ${event.transcript}`); | ||
| }); | ||
| ``` | ||
|
|
||
| ### Voice-Only Mode | ||
|
|
||
| ```typescript | ||
| await driver.start({ | ||
| goal: '(voice input)', | ||
| mode: 'local', | ||
| audio_input_enabled: true, | ||
| turn_detection_enabled: true, | ||
| turn_detection_silence_ms: 1000, // 1 second of silence = turn complete | ||
| speech_output_enabled: true, | ||
| speech_voice: 'alloy' // or: echo, fable, onyx, nova, shimmer | ||
| }); | ||
| ``` | ||
|
|
||
| ### MCP Servers | ||
|
|
||
| ```typescript | ||
| const mcpServers: MCPServerConfig[] = [ | ||
| { | ||
| name: 'filesystem', | ||
| command: 'npx', | ||
| args: ['-y', '@modelcontextprotocol/server-filesystem', '/Users/you/Documents'] | ||
| }, | ||
| { | ||
| name: 'database', | ||
| command: 'python', | ||
| args: ['-m', 'my_db_server'], | ||
| env: { DATABASE_URL: 'postgresql://...' } | ||
| } | ||
| ]; | ||
|
|
||
| await driver.start({ | ||
| goal: 'Analyze my documents', | ||
| mode: 'local', | ||
| mcp_servers: mcpServers | ||
| }); | ||
| ``` | ||
|
|
||
| ### Tool Choice Configuration | ||
|
|
||
| ```typescript | ||
| // Auto (default) | ||
| tool_choice: 'auto' | ||
|
|
||
| // Required - must use at least one tool | ||
| tool_choice: 'required' | ||
|
|
||
| // None - no tool use | ||
| tool_choice: 'none' | ||
|
|
||
| // Specific tool | ||
| tool_choice: { type: 'tool', name: 'filesystem__read_file' } | ||
| ``` | ||
|
|
||
| ## Breaking Changes | ||
|
|
||
| ⚠️ This is a breaking change with no backwards compatibility. | ||
|
|
||
| - `StartCommand` interface has many new optional fields | ||
| - New event types may be emitted | ||
| - `agent_name` should be set to `"agi-2-claude"` for new agents | ||
|
|
||
| ## Testing | ||
|
|
||
| ```bash | ||
| # Install updated SDK | ||
| npm install | ||
|
|
||
| # Build TypeScript | ||
| npm run build | ||
|
|
||
| # Run tests | ||
| npm test | ||
|
|
||
| # Try a voice session | ||
| node -e " | ||
| const { AgentDriver } = require('./dist'); | ||
|
|
||
| (async () => { | ||
| const driver = new AgentDriver({ mode: 'local' }); | ||
| const result = await driver.start({ | ||
| goal: 'Test voice', | ||
| mode: 'local', | ||
| audio_input_enabled: true, | ||
| speech_output_enabled: true | ||
| }); | ||
| console.log(result); | ||
| })(); | ||
| " | ||
| ``` | ||
|
|
||
| ## Related PRs | ||
|
|
||
| - agi-api (driver): https://github.com/agi-inc/agents/pull/344 | ||
| - agi-python: https://github.com/agi-inc/agi-python/pull/8 | ||
| - agi-csharp: TBD | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.