Skip to content

The SDK

Start and follow tasks, and answer approvals, from code with @sypnia/agent.

Applies to EngineCloud
View as Markdown
TypeScript
import { createClient } from '@sypnia/agent/client';

const agent = createClient({ token: process.env.SYPNIA_TOKEN });

const task = await agent.tasks.create({
  repository: 'laespiga/web',
  request: 'Customers can cancel an order until 10 am',
  budget: { credits: 40 },
});

for await (const event of agent.tasks.events(task.id)) {
  if (event.type === 'question') await agent.questions.answer(event.id, event.choices[0].id);
  if (event.type === 'approval') console.log('Waiting for a person to approve:', event.summary);
  if (event.type === 'done') console.log(event.pullRequest, event.cost);
}

The client never approves on its own unless your code does it explicitly; approvals of always ask actions require a person’s session, not an API token (Approvals).

Running locally

TypeScript
import { createRunner } from '@sypnia/agent/runner';

const runner = createRunner({
  workspace: process.cwd(),
  model: { endpoint: 'https://openrouter.ai/api/v1', key: process.env.OPENROUTER_API_KEY },
});

    Search pages, sections and terms