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 analysis
  • HandoffStrategy.SEQUENTIAL - Sequential model switching
  • HandoffStrategy.TASK_AWARE - Route based on detected task type
  • HandoffStrategy.CAPABILITY_BASED - Route based on model capabilities

Examples

See the examples/ directory for complete working examples:

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

FeaturePython SDKTypeScript SDKStatus
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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Ensure all tests pass: npm test
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support


Open-Dedalus TypeScript SDK - Bringing enterprise-grade AI workflows to TypeScript developers.