@relayplane/sdk
Version:
RelayPlane SDK - Local-first AI workflow engine for building multi-step AI workflows
247 lines • 8.15 kB
TypeScript
/**
* RelayPlane SDK v3
*
* Developer-facing API for building and running local-first AI workflows.
* Provides a type-safe fluent builder interface with phantom types.
*
* @packageDocumentation
* @example
* ```typescript
* import { relay } from '@relayplane/sdk';
*
* const result = await relay
* .workflow('invoice-processor')
* .step('extract').with('openai:gpt-4o').prompt('Extract invoice data from the document')
* .step('summarize').with('anthropic:claude-sonnet-4-20250514').depends('extract')
* .run({ fileUrl: 'https://example.com/invoice.pdf' });
* ```
*/
import { createWorkflow } from './v3-builder';
import { configure, getConfig, resetConfig, getPolicy, listPolicies, getAllPolicies, hasPolicy } from './v3-config';
import { useRemote, saveRemote, deleteRemote } from './v3-remote';
import { execute } from './v3-policy';
export type { StepConfig, StepDefinition, WorkflowBuilder as WorkflowBuilderV3Type, StepWith, StepWithModel, StepMCP, StepMCPWithParams, StepComplete, RunOptions, WorkflowResult, ProviderConfig, MCPServerConfig, GlobalConfig, CloudFeatures, Policy, PolicyExecuteInput, PolicyExecuteResult, } from './v3-types';
export { configure, getConfig, resetConfig };
export { RelayPlaneError, RelayPlaneErrorCode, isRelayPlaneError, providerNotConfiguredError, policyNotFoundError, costCapExceededError, circularDependencyError, stepFailedError, timeoutError, fromUnknownError, } from './errors';
export type { RelayPlaneErrorPayload } from './errors';
export { getPolicy, listPolicies, getAllPolicies, hasPolicy } from './v3-config';
export { execute, getPolicyDetails } from './v3-policy';
export { kv } from './v3-kv';
export type { KVOptions, KVEntry, KVBatchEntry, KVListResult } from './v3-kv';
export { backup } from './v3-backup';
export type { BackupOptions, RestoreOptions, ListBackupsOptions, Backup } from './v3-backup';
export { checkForUpdates, resetVersionCheck } from './version-check';
export type { VersionCheckResult } from './version-check';
export { AdapterRegistry, defaultAdapterRegistry } from '@relayplane/adapters';
export type { ProviderType } from '@relayplane/adapters';
export type { WorkflowRunResult } from '@relayplane/engine';
/**
* Main RelayPlane SDK entry point.
*
* Provides the fluent builder API for creating type-safe workflows.
* Uses v3 API by default with phantom types for compile-time guarantees.
*
* @example
* ```typescript
* import { relay } from '@relayplane/sdk';
*
* const result = await relay
* .workflow('invoice-processor')
* .step('extract').with('openai:gpt-4o').prompt('Extract invoice data from the document')
* .step('summarize').with('anthropic:claude-sonnet-4-20250514').depends('extract')
* .run({ fileUrl: 'https://example.com/invoice.pdf' });
* ```
*/
export declare const relay: {
/**
* Creates a new workflow builder using v3 API.
*
* @param name - Unique workflow name
* @returns Type-safe workflow builder
*
* @example
* ```typescript
* const workflow = relay.workflow('invoice-processor');
* ```
*/
workflow: typeof createWorkflow;
/**
* Uses a remote workflow configuration from cloud.
*
* @param name - Remote workflow name
* @param options - Optional version and cache settings
* @returns Promise resolving to workflow builder
*
* @example
* ```typescript
* const result = await relay
* .useRemote('invoice-processor')
* .run({ input: 'data' });
* ```
*/
useRemote: typeof useRemote;
/**
* Saves a workflow configuration to cloud.
*
* @param name - Workflow name
* @param config - Workflow configuration
* @returns Promise resolving to saved config metadata
*/
saveRemote: typeof saveRemote;
/**
* Deletes a remote workflow configuration.
*
* @param name - Workflow name
* @returns Promise resolving when deleted
*/
deleteRemote: typeof deleteRemote;
/**
* Configures global SDK settings.
*
* @param config - Global configuration
*
* @example
* ```typescript
* relay.configure({
* providers: {
* openai: { apiKey: process.env.OPENAI_API_KEY! }
* }
* });
* ```
*/
configure: typeof configure;
/**
* Gets current global configuration.
*
* @returns Current config (read-only)
*/
getConfig: typeof getConfig;
/**
* Resets global configuration (mainly for testing).
*/
resetConfig: typeof resetConfig;
/**
* Key-value store for sharing data across workflow runs.
*
* @example
* ```typescript
* // Store data
* await relay.kv.set('user:settings', { theme: 'dark' });
*
* // Retrieve data
* const settings = await relay.kv.get('user:settings');
*
* // With TTL
* await relay.kv.set('cache:data', data, { ttl: 3600 });
*
* // Team-scoped
* await relay.kv.set('config', value, { teamId: 'team-123' });
* ```
*/
kv: {
get: typeof import("./v3-kv").get;
getWithMetadata: typeof import("./v3-kv").getWithMetadata;
set: typeof import("./v3-kv").set;
delete: typeof import("./v3-kv").del;
list: typeof import("./v3-kv").list;
batchSet: typeof import("./v3-kv").batchSet;
batchGet: typeof import("./v3-kv").batchGet;
};
/**
* Cloud backup and restore for workflows and data.
*
* @example
* ```typescript
* // Create backup
* const backupId = await relay.backup.create({
* name: 'daily-backup',
* includes: { workflows: true, agents: true, configs: true }
* });
*
* // List backups
* const { backups } = await relay.backup.list({ limit: 10 });
*
* // Restore backup
* await relay.backup.restore({
* backupId,
* mode: 'merge',
* conflictResolution: 'skip'
* });
* ```
*/
backup: {
create: typeof import("./v3-backup").create;
restore: typeof import("./v3-backup").restore;
list: typeof import("./v3-backup").list;
delete: typeof import("./v3-backup").deleteBackup;
};
/**
* Executes a prompt using a pre-configured policy.
*
* Policies provide standardized execution patterns with:
* - Primary model selection
* - Automatic fallback on failure
* - Cost controls and limits
* - Retry configuration
*
* @param policyId - ID of the policy to use
* @param input - Execution input (prompt, variables, schema)
* @returns Execution result with output and metadata
*
* @example
* ```typescript
* // Configure policies
* relay.configure({
* providers: {
* openai: { apiKey: process.env.OPENAI_API_KEY! }
* },
* policies: {
* 'fast-analysis': {
* id: 'fast-analysis',
* model: 'openai:gpt-4o',
* fallback: ['anthropic:claude-sonnet-4-20250514'],
* costCaps: { maxCostPerExecution: 0.10 }
* }
* }
* });
*
* // Execute using policy
* const result = await relay.execute('fast-analysis', {
* prompt: 'Analyze this text: {{text}}',
* variables: { text: 'Hello world' }
* });
* ```
*/
execute: typeof execute;
/**
* Gets a policy by ID.
*
* @param policyId - The policy ID
* @returns Policy configuration or undefined
*/
getPolicy: typeof getPolicy;
/**
* Lists all configured policy IDs.
*
* @returns Array of policy IDs
*/
listPolicies: typeof listPolicies;
/**
* Gets all configured policies.
*
* @returns Record of policy ID to configuration
*/
getAllPolicies: typeof getAllPolicies;
/**
* Checks if a policy exists.
*
* @param policyId - The policy ID to check
* @returns True if policy exists
*/
hasPolicy: typeof hasPolicy;
};
/**
* Default export for convenience.
*/
export default relay;
//# sourceMappingURL=index.d.ts.map