Agents API

    Execute agents, stream results, and manage agent configurations.

    execute()

    Start an agent execution (async). Returns immediately with an execution ID.

    typescript
    const { executionId, sessionId } = await client.agents.execute('agent-uuid', {
      task: 'Analyze these metrics',
      context: { quarter: 'Q4' },         // optional context
      attachmentIds: ['uuid-1', 'uuid-2'], // optional files
      teamUuid: 'team-uuid',              // optional team mode
    });

    executeSync()

    Execute and wait for the result. Polls until completion.

    typescript
    const result = await client.agents.executeSync('agent-uuid', {
      task: 'Summarize this data',
    });
    
    console.log(result.output);
    console.log(result.status);      // 'completed' | 'failed'
    console.log(result.toolResults); // tool call results

    stream()

    Execute with real-time streaming via SSE.

    typescript
    const stream = await client.agents.stream('agent-uuid', {
      task: 'Generate a report',
    });
    
    stream.on('textDelta', ({ delta }) => process.stdout.write(delta));
    stream.on('toolCall', ({ name, input }) => console.log(`Tool: ${name}`));
    stream.on('complete', ({ execution }) => console.log('Done:', execution.output));
    stream.on('error', (err) => console.error(err));
    
    await stream.connect();

    getExecution()

    typescript
    const execution = await client.agents.getExecution(executionId);
    // { id, status, output, toolResults, sessionId, startedAt, completedAt }

    cancelExecution()

    typescript
    await client.agents.cancelExecution(executionId);

    list()

    typescript
    const { data: agents } = await client.agents.list();
    
    agents.forEach(agent => {
      console.log(`${agent.name} (${agent.type}): ${agent.description}`);
    });

    Execution Lifecycle

    pending → Agent queued
    running → Agent executing, streaming events
    paused → Waiting for user input (ask_user)
    completed → Finished successfully
    failed → Error occurred
    cancelled → Cancelled by user