UNPKG

@adonis-agora/agent

Version:

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

48 lines • 2.63 kB
import type { AgentEngine, AgentEngineContext } from '../engine.js'; import type { AgentRunner } from '../spi/agent-runner.js'; import type { ProtocolAdapter } from '../spi/protocol-adapter.js'; import { type OpenCodeHost, type OpenCodeSessionStore } from './host.js'; import { OpenCodeMcpEndpoint } from './mcp.js'; import { type OpenCodeEngineSettings, OpenCodeTurns } from './turns.js'; /** A class the container builds (`@inject()` its services into the constructor). */ export type OpenCodeClass<T> = abstract new (...args: any[]) => T; export interface OpenCodeEngineOptions extends OpenCodeEngineSettings { /** * The host: an {@link OpenCodeHost} instance, or a class the app's container builds (so it can * `@inject()` the services that know where the server is and how to set sessions up). */ host: OpenCodeHost | OpenCodeClass<OpenCodeHost>; /** Where each thread's session is kept. Same forms as `host`. Omit → in memory. */ sessions?: OpenCodeSessionStore | OpenCodeClass<OpenCodeSessionStore>; } /** * The OpenCode engine — `engine: openCode({ host })` in `config/agent.ts`. The routes, threads, * stream protocol, approvals, questions and queue stay the library's; OpenCode runs the model, the * tools, skills and the context, on the server and sessions the host provides. */ export declare class OpenCodeEngine implements AgentEngine { #private; readonly options: OpenCodeEngineOptions; readonly name: string; readonly durable: boolean; constructor(options: OpenCodeEngineOptions); /** * The engine's turn steps, once the provider built the runner: `pushToSession` (trusted pushes * into a session's run) and `liveRuns()` for the host's own use. */ get turns(): OpenCodeTurns; /** The tools endpoint, when `tools` is set and the engine has started. */ get endpoint(): OpenCodeMcpEndpoint | undefined; createRunner(context: AgentEngineContext): Promise<AgentRunner>; adapters(): readonly ProtocolAdapter[]; shutdown(): void; /** The host, the session store, the tools endpoint and the turn steps every OpenCode runner needs. */ protected buildTurns(context: AgentEngineContext): Promise<OpenCodeTurns>; } /** * Run the agent's turns on OpenCode 2 — `engine: openCode({ host })` in `config/agent.ts`. In * memory: a turn parked on a person lives in this process (single replica); see * `openCodeDurable()` (`@adonis-agora/agent/opencode/durable`) for turns that survive restarts. */ export declare function openCode(options: OpenCodeEngineOptions): OpenCodeEngine; //# sourceMappingURL=engine.d.ts.map