Agent SDK (@solenai/sdk)
Three lines of code. Wrap any agent — LangGraph, CrewAI, AutoGen, or custom — and Solen checkpoints state, monitors every step, and heals failures in production.
Install
Copy-paste this into your agent entry point:
Quick start (3 lines)
npm install @solenai/sdk
import { withSolen } from '@solenai/sdk';
await withSolen(
{
apiKey: process.env.SOLEN_API_KEY!,
agentId: 'research-agent',
framework: 'langgraph',
},
async (ctx) => {
// Your agent logic here
return result;
}
);Get your apiKey from Settings → API Keys.
What happens after install
Once withSolen() runs:
- Solen creates a run via
POST /api/agent-runtime/runswith youragentIdandframework - Every
ctx.step()reports tool calls, LLM invocations, duration, and status to the Runtime Kernel - Checkpoints are saved at configurable intervals (default every 10 steps) and on explicit
ctx.checkpoint()calls - On step failure or stall, Solen opens a heal incident and either pattern-matches a known fix or runs AI diagnosis
- On completion, the run is marked
COMPLETEDorFAILEDwith failure detail
The SDK never throws on network failures — telemetry is fire-and-forget so it cannot crash your agent.
Reporting steps
ctx.step()
import { withSolen } from '@solenai/sdk';
await withSolen(config, async (ctx) => {
const data = await ctx.step('tool_call', () => searchWeb(query), {
toolName: 'search_web',
});
const analysis = await ctx.step('llm_call', () => analyzeWithLlm(data));
return analysis;
});Checkpoints
ctx.checkpoint()
import { withSolen } from '@solenai/sdk';
await withSolen(config, async (ctx) => {
const state = { messages, currentStep: 10 };
await ctx.checkpoint(state);
return state;
});Configuration options
| Option | Required | Description |
|---|---|---|
apiKey | Yes | Workspace API key from Settings → API Keys. Sent as Bearer token. |
agentId | Yes | Stable agent identifier. Appears in /agents dashboard. |
framework | Yes | langgraph, crewai, autogen, or custom. |
baseUrl | No | API base URL. Default https://api.solenai.ca. |
checkpointEveryNSteps | No | Auto-checkpoint interval. Default 10 steps. |
maxTokens | No | Token budget per run. Exceeding triggers a heal incident. |
debug | No | Log SDK requests to console. Default false. |
Requirements
- Node.js 18+ (uses built-in
fetch) - Zero runtime dependencies
- Works with LangGraph, CrewAI, AutoGen, and custom agent loops