@agnt5/sdk
v0.3.2
Published
AGNT5 TypeScript SDK - Durable AI workflows and agents
Downloads
411
Maintainers
Readme
AGNT5 TypeScript SDK
Durable AI workflows and agents for TypeScript.
Features
- ✅ Durable Functions - Automatic retry with configurable policies
- ✅ Checkpointing - Resume from last successful step on failure
- ✅ Multi-Runtime - Works on Node.js, Bun, Deno, and Edge runtimes
- ✅ Type-Safe - Full TypeScript support with type inference
- 🔄 Phase 1 - Local execution (current)
- 📋 Phase 2 - Platform integration (coming soon)
Installation
npm install @agnt5/sdk
# or
yarn add @agnt5/sdk
# or
pnpm add @agnt5/sdkQuick Start
Define a Function
import { fn } from '@agnt5/sdk';
export const greet = fn('greet').run(async (ctx, name: string) => {
ctx.logger.info(`Greeting ${name}`);
return `Hello, ${name}!`;
});With Retry and Backoff
import { fn } from '@agnt5/sdk';
export const processData = fn('process-data')
.retry({ maxAttempts: 3, initialIntervalMs: 1000 })
.backoff({ type: 'exponential', multiplier: 2.0 })
.run(async (ctx, data: DataInput) => {
// Your processing logic here
return { processed: true };
});With Checkpointing
import { fn } from '@agnt5/sdk';
export const dataPipeline = fn('data-pipeline').run(async (ctx, datasetId: string) => {
// Step 1: Load data (checkpointed)
const data = await ctx.step('load', () => loadData(datasetId));
// Step 2: Transform (checkpointed)
const transformed = await ctx.step('transform', () => transform(data));
// Step 3: Validate (checkpointed)
const validated = await ctx.step('validate', () => validate(transformed));
return { success: true, records: validated.length };
});Create a Worker
import { Worker } from '@agnt5/sdk';
import './functions'; // Import your function definitions
const worker = new Worker('my-service');
await worker.run();Runtime Support
The SDK automatically detects and adapts to your runtime:
| Runtime | Binding | Performance | Status | |---------|---------|-------------|---------| | Node.js | NAPI (native) | ⚡ Fastest | ✅ Supported | | Bun | NAPI (native) | ⚡ Fastest | ✅ Supported | | Deno | NAPI (compat) | ⚡ Fastest | ✅ Supported | | Cloudflare Workers | WASM | 🔥 Fast | 📋 Phase 2 | | Vercel Edge | WASM | 🔥 Fast | 📋 Phase 2 | | Next.js Edge | WASM | 🔥 Fast | 📋 Phase 2 |
No configuration needed - the right binding is automatically selected!
Documentation
- Overview - SDK architecture and concepts
- Function Component - Durable functions API
- Context API - Execution context capabilities
- Runtime Support - Multi-runtime architecture
- Tool Component - Agent capabilities (Phase 2)
- Agent Component - LLM-driven agents (Phase 2)
- Entity Component - Stateful components (Phase 2)
- Workflow Component - Multi-step orchestration (Phase 2)
Development
Setup
# Install dependencies
npm install
# Build TypeScript
npm run build:ts
# Run tests
npm test
# Watch mode
npm run devProject Structure
sdk-typescript/
├── src/ # TypeScript source code
│ ├── function.ts # Function builder
│ ├── context.ts # Execution context
│ ├── worker.ts # Worker implementation
│ ├── types.ts # TypeScript types
│ └── __tests__/ # Test files
├── native/ # NAPI-RS bindings (Phase 2)
├── wasm/ # WASM bindings (Phase 2)
├── docs/ # Documentation
└── dist/ # Compiled outputExamples
See the examples/ directory for complete working examples:
basic-function.ts- Simple function definitionretry-backoff.ts- Retry and backoff configurationcheckpointing.ts- Multi-step checkpointingworker.ts- Worker setup
Phase 1 vs Phase 2
Phase 1 (Current) - Local Execution
- ✅ Function builder API
- ✅ Context with state and checkpointing
- ✅ Retry policies and backoff strategies
- ✅ Worker infrastructure
- ✅ TypeScript types and inference
- ⚠️ In-memory state (not persistent)
- ⚠️ In-memory checkpoints (not durable)
Phase 2 (Coming Soon) - Platform Integration
- 📋 NAPI and WASM bindings to Rust core
- 📋 Durable state (survives process restarts)
- 📋 Distributed execution across workers
- 📋 Platform orchestration APIs
- 📋 LLM integration
- 📋 Tool and Agent components
- 📋 Entity and Workflow components
Contributing
See CONTRIBUTING.md for development guidelines.
License
MIT - See LICENSE for details.
