UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

38 lines • 1.79 kB
import * as durable from '@adonis-agora/durable'; import { OpenCodeEngine } from '../engine.js'; import { DurableOpenCodeAgentRunner } from './runner.js'; import { OpenCodeRunWorkflow } from './workflow.js'; /** The OpenCode engine whose turns are `agora.agent.opencode.run` workflows. */ export class OpenCodeDurableEngine extends OpenCodeEngine { options; name = 'opencode-durable'; durable = true; constructor(options) { super(options); this.options = options; } async createRunner(context) { const turns = await this.buildTurns(context); const engine = this.options.workflowEngine ?? (context.make !== undefined ? await context.make(durable.WorkflowEngine) : undefined); if (engine === undefined) { throw new Error('[@adonis-agora/agent/opencode] openCodeDurable() needs a durable engine: configure @adonis-agora/durable, or pass `workflowEngine`.'); } await durable.registerWorkflowClass(engine, OpenCodeRunWorkflow, () => new OpenCodeRunWorkflow(turns, engine)); const { host } = turns; return new DurableOpenCodeAgentRunner(engine, turns, host, context.store); } } /** * `openCode()` whose turns are durable workflows — `engine: openCodeDurable({ host })` next to a * configured `@adonis-agora/durable`. Every step of a turn is checkpointed; a turn waiting on a person * survives restarts and is resumed by whichever process receives the decision. */ export function openCodeDurable(options) { return new OpenCodeDurableEngine(options); } export { DurableOpenCodeAgentRunner } from './runner.js'; export { decisionToken, OPENCODE_RUN_WORKFLOW, OpenCodeRunWorkflow } from './workflow.js'; //# sourceMappingURL=index.js.map