TypeScript SDK
The Vyre TypeScript SDK allows you to programmatically control Vyre agents, orchestrate tasks, configure workspaces, and subscribe to real-time execution events directly from your Node.js, Deno, or Bun applications.
Installation
Install the package via your preferred package manager:
# npm
npm install @vyre/sdk
# pnpm
pnpm add @vyre/sdk
# yarn
yarn add @vyre/sdk
# bun
bun add @vyre/sdkInitialization
Initialize the Vyre client using your API key. We recommend storing the key in your environment variables.
import { VyreClient } from '@vyre/sdk';
// Automatically loads from process.env.VYRE_API_KEY if not provided
const vyre = new VyreClient({
apiKey: process.env.VYRE_API_KEY,
endpoint: 'https://api.usevyre.app', // Optional custom gateway
});Basic Usage
Starting an Agent Session
You can initiate a task and stream agent thought processes and file modifications in real-time.
import { VyreClient } from '@vyre/sdk';
const vyre = new VyreClient();
async function main() {
const session = await vyre.sessions.create({
projectPath: '/path/to/my-project',
task: 'Refactor the old auth routes to use standard JWT helper functions.',
model: 'claude-sonnet-4-5',
cloud: true // Set to true to run in Vyre Cloud
});
console.log(`Session created: ${session.id}`);
// Subscribe to real-time events
const stream = await session.getEventStream();
for await (const event of stream) {
if (event.type === 'text') {
process.stdout.write(event.delta);
} else if (event.type === 'tool_call') {
console.log(`\n[Agent running tool: ${event.toolName}]`);
} else if (event.type === 'completed') {
console.log('\nTask successfully completed!');
}
}
}
main().catch(console.error);Advanced Features
Custom Tool Registration
You can extend the agent's capabilities by registering custom tools written in TypeScript that run on the client-side.
await vyre.tools.register({
name: 'fetchDatabaseSchema',
description: 'Retrieves the schema definition of the current PostgreSQL database.',
handler: async () => {
const schema = await db.query("SELECT * FROM pg_catalog.pg_tables");
return JSON.stringify(schema.rows);
}
});Real-Time Workspace Sync
The SDK automatically tracks local repository status. When running cloud agents, the SDK computes binary diffs and synchronizes dirty state files efficiently before execution.
Interacting with Prompts Programmatically
Send user follow-ups or answer questions mid-run using the session.sendInput() interface:
await session.sendInput("Yes, please use the modern TS path imports instead of relative ones.");