Skip to main content

SDK Overview

Parallax provides official SDKs for building agents and orchestrating patterns. The SDKs handle communication with the control plane, task management, and result aggregation.

Available SDKs

SDKPackagePurpose
TypeScript@parallax/sdk-typescriptBuild agents, execute patterns, client applications
Pattern SDK@parallax/pattern-sdkBuild, validate, and compile patterns programmatically

Quick Comparison

TypeScript SDK

For building agents and client applications:

import { ParallaxAgent, ParallaxClient } from '@parallax/sdk-typescript';

// Build an agent
const agent = new ParallaxAgent({
name: 'my-agent',
capabilities: ['analysis'],
});

agent.onTask(async (task) => {
return { result: await process(task), confidence: 0.9 };
});

agent.start();

// Or execute patterns as a client
const client = new ParallaxClient({ url: 'http://localhost:8080' });
const result = await client.executePattern('sentiment-analysis', {
text: 'Great product!'
});

Pattern SDK

For programmatically building patterns:

import { PatternBuilder, validatePattern } from '@parallax/pattern-sdk';

const pattern = new PatternBuilder('content-moderation')
.input({ content: 'string' })
.agents({ capabilities: ['moderation'], min: 3 })
.parallel({ timeout: 30000 })
.voting({ method: 'majority' })
.output({ verdict: '$vote.result' })
.build();

// Validate the pattern
const validation = validatePattern(pattern);
if (!validation.valid) {
console.error(validation.errors);
}

Installation

TypeScript SDK

npm install @parallax/sdk-typescript
# or
pnpm add @parallax/sdk-typescript
# or
yarn add @parallax/sdk-typescript

Pattern SDK

npm install @parallax/pattern-sdk
# or
pnpm add @parallax/pattern-sdk
# or
yarn add @parallax/pattern-sdk

Architecture Overview

Common SDK Operations

Agent Operations

OperationSDKMethod
Register agentTypeScriptagent.start()
Handle tasksTypeScriptagent.onTask(handler)
DisconnectTypeScriptagent.stop()
Send heartbeatTypeScriptAutomatic

Client Operations

OperationSDKMethod
Execute patternTypeScriptclient.executePattern()
Stream resultsTypeScriptclient.streamPattern()
List patternsTypeScriptclient.listPatterns()
Get pattern statusTypeScriptclient.getExecution()

Pattern Operations

OperationSDKMethod
Build patternPattern SDKPatternBuilder
Validate patternPattern SDKvalidatePattern()
Compile to YAMLPattern SDKcompileToYaml()
Parse YAMLPattern SDKparsePattern()

Configuration

Environment Variables

# Control plane connection
PARALLAX_CONTROL_PLANE_URL=http://localhost:8080

# Agent configuration
PARALLAX_AGENT_NAME=my-agent
PARALLAX_AGENT_CAPABILITIES=analysis,summarization

# Client configuration
PARALLAX_API_KEY=your-api-key

# Logging
PARALLAX_LOG_LEVEL=info

Programmatic Configuration

import { ParallaxClient } from '@parallax/sdk-typescript';

const client = new ParallaxClient({
url: process.env.PARALLAX_URL || 'http://localhost:8080',
apiKey: process.env.PARALLAX_API_KEY,
timeout: 30000,
retries: 3,
logging: {
level: 'info',
format: 'json',
},
});

Error Handling

All SDKs use typed errors:

import {
ParallaxError,
ConnectionError,
TimeoutError,
ValidationError,
PatternNotFoundError,
} from '@parallax/sdk-typescript';

try {
const result = await client.executePattern('my-pattern', input);
} catch (error) {
if (error instanceof TimeoutError) {
console.error('Pattern execution timed out');
} else if (error instanceof PatternNotFoundError) {
console.error('Pattern does not exist');
} else if (error instanceof ValidationError) {
console.error('Input validation failed:', error.details);
} else if (error instanceof ConnectionError) {
console.error('Cannot connect to control plane');
}
}

TypeScript Support

All SDKs are written in TypeScript and provide full type definitions:

import {
ParallaxAgent,
TaskHandler,
TaskResult,
AgentConfig,
} from '@parallax/sdk-typescript';

// Typed task handler
const handler: TaskHandler<MyInput, MyOutput> = async (task) => {
const input: MyInput = task.input;

const result: TaskResult<MyOutput> = {
result: processInput(input),
confidence: 0.85,
};

return result;
};

// Typed configuration
const config: AgentConfig = {
name: 'typed-agent',
capabilities: ['analysis'],
maxConcurrentTasks: 5,
};

Next Steps