Open-Dedalus TypeScript SDK
August 23, 2025 ยท View on GitHub
Open-source implementation of Dedalus Labs SDK for TypeScript/JavaScript. Unified AI agents ecosystem with Bring Your Own Key (BYOK) support.
Features
๐ Core Capabilities
- BYOK Support: Use your own API keys from 12+ AI providers
- Multi-Model Workflows: Intelligent handoffs between different models
- Tool Execution: Execute JavaScript functions and external tools
- Streaming Support: Real-time response streaming
- MCP Integration: Model Context Protocol server support (planned)
- Policy System: Dynamic behavior control during execution
๐ค Supported Providers
- OpenAI (GPT-4, GPT-3.5, etc.)
- Anthropic (Claude 3.5, Claude 3, etc.)
- Google (Gemini Pro, Gemini Flash)
- Fireworks AI
- xAI (Grok)
- Perplexity
- DeepSeek
- Groq
- Cohere
- Together AI
- Cerebras
- Mistral
Installation
npm install open-dedalus
Quick Start
Basic Chat Completion
import { AsyncDedalus, DedalusRunner } from 'open-dedalus';
const client = new AsyncDedalus();
const runner = new DedalusRunner(client);
const result = await runner.run({
input: "What is the capital of France?",
model: "openai/gpt-4o-mini"
});
console.log(result.final_output);
Using Your Own API Keys
// Option 1: Pass key directly
const client = new AsyncDedalus("your-api-key-here");
// Option 2: Set environment variable
process.env.OPENAI_API_KEY = "your-openai-key";
const client = new AsyncDedalus(); // Will auto-detect
Tool Execution
function add(a: number, b: number): number {
return a + b;
}
function multiply(a: number, b: number): number {
return a * b;
}
const result = await runner.run({
input: "Calculate (15 + 27) * 2",
model: "openai/gpt-4",
tools: [add, multiply]
});
Multi-Model Handoffs
const result = await runner.run({
input: "Research AI trends and then write a creative story about them",
model: ["openai/gpt-4", "anthropic/claude-3-5-sonnet-20241022"],
mcp_servers: ["research-tools"]
});
Streaming Responses
import { streamAsync } from 'open-dedalus';
const result = await runner.run({
input: "Tell me a story",
model: "openai/gpt-4o-mini",
stream: true
});
// Stream output to console
await streamAsync(result as AsyncIterable<string>);
Environment Setup
Create a .env file in your project:
# Required for OpenAI models
OPENAI_API_KEY=your_openai_key_here
# Required for Anthropic models
ANTHROPIC_API_KEY=your_anthropic_key_here
# Optional - other providers
GOOGLE_API_KEY=your_google_key_here
FIREWORKS_API_KEY=your_fireworks_key_here
# ... etc
API Reference
AsyncDedalus
Core client for making AI API calls.
const client = new AsyncDedalus(apiKey?, baseUrl?);
await client.chatCompletion(model, messages, options?);
DedalusRunner
Workflow engine for complex AI tasks.
const runner = new DedalusRunner(client);
const result = await runner.run(options);
RunOptions
interface RunOptions {
input: string; // User input/prompt
model: string | string[]; // Model(s) to use
tools?: Function[]; // JavaScript functions as tools
mcp_servers?: string[]; // MCP server names
stream?: boolean; // Enable streaming
policy?: (context: any) => any; // Dynamic behavior policy
on_tool_event?: (event: any) => void; // Tool execution callback
max_steps?: number; // Maximum execution steps
handoff_strategy?: HandoffStrategy; // Multi-model routing
temperature?: number; // Response randomness
max_tokens?: number; // Token limit
}
HandoffStrategy
Control multi-model routing behavior:
HandoffStrategy.INTELLIGENT- Smart routing based on task analysisHandoffStrategy.SEQUENTIAL- Sequential model switchingHandoffStrategy.TASK_AWARE- Route based on detected task typeHandoffStrategy.CAPABILITY_BASED- Route based on model capabilities
Examples
See the examples/ directory for complete working examples:
- Hello World - Basic usage
- Basic Tools - Tool execution
- Streaming - Real-time responses
- MCP Integration - External tools
- Model Handoffs - Multi-model workflows
- Tool Chaining - Complex workflows
- Policy System - Dynamic behavior control
Run examples with:
npx ts-node examples/01_hello_world.ts
Development
Setup
git clone <repository>
cd open-dedalus/typescript
npm install
Build
npm run build
Test
npm test # Run all tests
npm run test:watch # Watch mode
npm test -- --coverage # With coverage
Lint
npm run lint # Check code style
npm run lint:fix # Auto-fix issues
Testing
Comprehensive test suite with Jest:
- 70%+ code coverage requirement
- Unit tests for all core components
- Mock-based testing (no real API calls)
- Error handling and edge case coverage
See src/__tests__/README.md for testing details.
Architecture
src/
โโโ client.ts # AsyncDedalus - API client with BYOK
โโโ runner.ts # DedalusRunner - Workflow engine
โโโ handoffs.ts # Multi-model routing system
โโโ mcp/ # Model Context Protocol integration
โ โโโ client.ts # MCP client (placeholder)
โ โโโ types.ts # MCP type definitions
โโโ utils/ # Utility functions
โ โโโ streaming.ts # Streaming helpers
โโโ types.ts # TypeScript definitions
โโโ index.ts # Main exports
โโโ __tests__/ # Test suite
Comparison with Python SDK
| Feature | Python SDK | TypeScript SDK | Status |
|---|---|---|---|
| BYOK Support | โ | โ | Complete |
| Multi-Model Handoffs | โ | โ | Complete |
| Tool Execution | โ | โ | Complete |
| Streaming | โ | โ | Complete |
| Policy System | โ | โ | Complete |
| MCP Integration | โ | ๐ง | Planned |
| Examples | โ | โ | Complete |
| Testing | โ | โ | Complete |
Roadmap
- MCP Integration: Full Model Context Protocol support
- Provider Streaming: Native streaming from providers
- Advanced Handoffs: More sophisticated routing algorithms
- Tool Marketplace: Built-in tool discovery and execution
- Performance Optimization: Request batching and caching
- React Integration: Hooks for React applications
Contributing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure all tests pass:
npm test - Submit a pull request
License
MIT License - see LICENSE file for details.
Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
Open-Dedalus TypeScript SDK - Bringing enterprise-grade AI workflows to TypeScript developers.