Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.abloatai.com/llms.txt

Use this file to discover all available pages before exploring further.

Most server agents should import the app schema and use the same model methods as the product UI.
import Ablo from '@abloatai/ablo';
import { defineSchema, model, z } from '@abloatai/ablo/schema';

const schema = defineSchema({
  tasks: model({
    title: z.string(),
    status: z.enum(['todo', 'doing', 'done']),
    summary: z.string().optional(),
  }),
});

const ablo = Ablo({
  schema,
  apiKey: process.env.ABLO_API_KEY,
});

export async function completeTask(taskId: string) {
  await ablo.ready();

  const [task] = await ablo.tasks.load({ where: { id: taskId } });
  if (!task) return { status: 'not_found' };

  const busy = ablo.intents.list({ resource: 'tasks', id: taskId });
  if (busy.length > 0) {
    return { status: 'busy', intents: busy };
  }

  const snap = ablo.snapshot({ tasks: taskId });
  const updated = await ablo.tasks.update(
    taskId,
    { status: 'done' },
    { readAt: snap.stamp, onStale: 'reject', wait: 'confirmed' },
  );

  return { status: 'done', task: updated };
}

Advanced Schema-Less Run

Use agent.run(...) when the worker intentionally cannot import the app schema. It creates the run envelope and returns done, failed, or cancelled.
const api = Ablo({ apiKey: process.env.ABLO_API_KEY });

const result = await api.agent('task-writer', {
  can: ['tasks.retrieve', 'tasks.update'],
  syncGroups: ['workspace:acme'],
}).run(
  {
    prompt: 'Mark task_123 done.',
    surface: 'agent_worker',
  },
  async ({ resource }) => {
    const tasks = resource<{ title: string; status: string }>('tasks');

    const { data, stamp, intents } = await tasks.retrieve('task_123', {
      ifBusy: 'return',
    });

    if (intents.length > 0) {
      return { skipped: true, reason: 'busy' };
    }

    return tasks.update(
      'task_123',
      { status: 'done' },
      { readAt: stamp, onStale: 'reject', wait: 'confirmed' },
    );
  },
);

if (result.status === 'failed') throw result.error;
if (result.status === 'cancelled') return;
Use the schema-backed version first. The schema-less version is for generic agent infrastructure, MCP routes, and platform code.