N AgentNava
AgentNava · Get Started

Examples

Five shapes that cover most of what people build.

A support agent in your product

One agent, many of your users, each with their own conversation.

import { AgentNava } from '@cerebro-labs/agentnava-sdk';

const ws = new AgentNava();

// Once, at setup.
const agent = await ws.agents.create({
  name: 'Refund checker',
  instructions: 'You help a support agent decide whether a refund is warranted.',
  workflows: [{
    name: 'Late delivery refund',
    when: 'A customer reports a delivery arrived late or damaged.',
    content: '1. Pull the order. 2. Compare delivered against promised. 3. Nine days or more: approve.',
  }],
});
// store agent.id

// Per person, the first time they open the panel.
const conversation = await ws.agent(agentId).start();
// store conversation.id against their user row

// Every message after that.
export async function onMessage(conversationId: string, text: string, res: Response) {
  for await (const e of ws.conversation(conversationId).ask(text)) {
    if (e.type === 'text') res.write(e.text);
    if (e.type === 'done') res.end();
  }
}

Answering from your own documents

No vector store, no chunking, no retriever. The documents are files and the agent searches them.

const policy = await ws.agents.create({
  name: 'Policy desk',
  instructions: `
You answer questions about company policy.

Your policies are files under /knowledge. Search them before answering.
Quote the sentence you relied on and name the file it came from.
If the policies do not cover the question, say so. Do not fill the gap.
  `.trim(),
});

await policy.knowledge.put('refunds/consumer.md', await readFile('./policies/consumer.md'));
await policy.knowledge.put('refunds/enterprise.md', await readFile('./policies/enterprise.md'));

const conversation = await policy.start();
console.log(await conversation.ask('Refund 45 days after delivery in Germany. Are we obliged?'));

One document, one conversation

A contract this person uploaded belongs to their conversation, not to the agent.

const conversation = await reader.start();

await conversation.writeFile('input/acme-msa.pdf', bytes);

console.log(await conversation.ask('What is the termination notice period?'));

// Anything the agent wrote while working is on the same drive.
for (const f of await conversation.files()) console.log(f.path, f.size);

const href = await conversation.fileUrl('risk-summary.md', { download: true, ttl: 300 });

A report nobody has to ask for

await agent.setTriggers([
  { kind: 'chat' },
  {
    kind: 'schedule',
    cron: '0 8 * * 1',
    timezone: 'America/Los_Angeles',
    message: 'Summarise last week\'s failed payments over 500 dollars and post the total.',
  },
]);

Every firing is a billed turn. Set maxRuns on an interval unless you mean it to run forever.

Work that needs more than one specialist

const project = await ws.projects.create({
  name: 'Q3 vendor review',
  goal: 'Review each vendor contract for risk and produce one summary per vendor.',
  agents: [analyst.id, writer.id],
  managerInstructions: 'Check with me before anything goes to a customer.',
});

const conversation = await project.start();
await conversation.ask('Start with Acme and Globex.');

await project.files();   // the whole team works in one folder