Skip to main content

Droid

The Droid class is the main entry point for the SDK. It provides methods for executing prompts and managing conversation threads.

Import

import { Droid, MODELS } from '@activade/droid-sdk';

Constructor

new Droid(config?: DroidConfig)

Creates a new Droid instance with the specified configuration.

Parameters

ParameterTypeRequiredDefaultDescription
configDroidConfigNo{}Configuration options

DroidConfig Properties

PropertyTypeDefaultDescription
cwdstringprocess.cwd()Working directory for CLI operations
modelModelId | string-AI model to use for generation
autonomyLevelAutonomyLevel'default'Level: 'default', 'low', 'medium', 'high'
reasoningEffortReasoningEffort-Intensity: 'off', 'none', 'low', 'medium', 'high'
droidPathstring'droid'Path to the Droid CLI binary
timeoutnumber600000Maximum execution time in milliseconds

Example

const droid = new Droid({
model: MODELS.CLAUDE_SONNET,
autonomyLevel: 'high',
reasoningEffort: 'medium',
cwd: '/path/to/project',
timeout: 300000
});

Properties

config

get config(): Readonly<DroidConfig>

Returns the current configuration as a readonly object.

const droid = new Droid({ model: MODELS.CLAUDE_SONNET });
console.log(droid.config.model); // 'claude-sonnet-4-5-20250929'

Methods

startThread()

startThread(options?: ThreadOptions): Thread

Creates a new conversation thread for multi-turn interactions.

ParameterTypeRequiredDescription
optionsThreadOptionsNoThread-specific configuration

Returns: A new Thread instance.

const thread = droid.startThread({
autonomyLevel: 'high',
enabledTools: ['file_read', 'file_write']
});

await thread.run('Create a REST API');
await thread.run('Add authentication');

console.log('Session ID:', thread.id);

resumeThread()

resumeThread(sessionId: string, options?: ThreadOptions): Thread

Resumes a previously created conversation thread.

ParameterTypeRequiredDescription
sessionIdstringYesSession ID from a previous thread
optionsThreadOptionsNoThread-specific configuration

Returns: A Thread instance connected to the existing session.

const thread = droid.resumeThread('session_abc123...');
await thread.run('What did we work on last time?');

exec()

exec(prompt: string, options?: ExecOptions): Promise<TurnResult>

Executes a single prompt without maintaining conversation state.

ParameterTypeRequiredDescription
promptstringYesThe natural language prompt
optionsExecOptionsNoExecution options

Returns: A promise resolving to the execution result.

Throws:

  • ExecutionError - If the CLI execution fails
  • TimeoutError - If the operation exceeds the configured timeout
  • CliNotFoundError - If the Droid CLI is not installed
const result = await droid.exec('Generate a UUID');
console.log(result.finalResponse);

listTools()

listTools(model?: string): Promise<string[]>

Lists all available tools for the configured or specified model.

ParameterTypeRequiredDescription
modelstringNoModel ID (defaults to instance model)

Returns: A promise resolving to an array of tool names.

const tools = await droid.listTools();
console.log('Available tools:', tools);
// ['file_read', 'file_write', 'shell_exec', ...]

Full Example

import { Droid, MODELS } from '@activade/droid-sdk';
import { z } from 'zod';

const droid = new Droid({
model: MODELS.CLAUDE_SONNET,
autonomyLevel: 'high',
cwd: './my-project'
});

// One-shot execution
const result = await droid.exec('Create a hello world function');
console.log(result.finalResponse);

// Multi-turn conversation
const thread = droid.startThread();
await thread.run('Create a React component');
await thread.run('Add unit tests for it');

// Structured output
const schema = z.object({
name: z.string(),
version: z.string()
});

const pkgResult = await droid.exec('Get package info as JSON');
const pkg = pkgResult.parse(schema);
console.log(pkg.name, pkg.version);