@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
53 lines • 2.99 kB
TypeScript
import type { WorkflowEngine } from '@adonis-agora/durable';
import { type ChatQueueService } from '../chat-queue-service.js';
import type { HumanReply } from '../elicitation.js';
import type { AgentRunner, AgentRunStartOptions } from '../spi/agent-runner.js';
import type { AgentStore } from '../spi/agent-store.js';
import type { TokenStreamSink } from '../spi/token-stream-sink.js';
import type { AgentRunInput } from '../types.js';
/**
* Runs the agent turn as an `@adonis-agora/durable` workflow ({@link AgentRunWorkflow}) — the opt-in
* runner (`durable: true`). `start` enqueues the run and returns its id immediately (a worker runs the
* body and streams to the sink meanwhile); HITL approval is delivered as a durable signal namespaced
* by run, so it can never cross-resolve another run. Mirrors the {@link InlineAgentRunner} interface.
*/
export declare class DurableAgentRunner implements AgentRunner {
private readonly engine;
private readonly store?;
/** The thread message queue — what a cancel hands the thread to. */
private readonly queue?;
/** Where a cancelled thread turn's stream is ended (`cancelled` frame, then the end). */
private readonly sink?;
/**
* `store` is optional so a bare `new DurableAgentRunner(engine)` still works; when passed (the
* provider does), {@link cancel} settles the `agent_run` row `cancelled` for governance.
*/
constructor(engine: WorkflowEngine, store?: AgentStore | undefined,
/** The thread message queue — what a cancel hands the thread to. */
queue?: ChatQueueService | undefined,
/** Where a cancelled thread turn's stream is ended (`cancelled` frame, then the end). */
sink?: TokenStreamSink | undefined);
start(input: AgentRunInput, options?: AgentRunStartOptions): Promise<{
runId: string;
}>;
signal(runId: string, toolCallId: string, reply: HumanReply): Promise<void>;
/** The runs {@link drive} set going that have not ended yet. */
private readonly driving;
/** Lease and execute here what of `runId` is still pending — see {@link drivePendingRuns}. */
drive(runId: string): Promise<void>;
/**
* From the engine's own run row. A run it does not know yet counts as running — a queued turn is
* claimed before its start lands — and so does one it cannot be asked about: only a run the engine
* reports settled (`completed`/`failed`/`cancelled`/`dead`) is stale.
*/
isRunActive(runId: string): Promise<boolean>;
cancel(runId: string): Promise<void>;
/** Tell the delegating thread a detached run was stopped, and end that run's own stream. */
private settleStoppedDelegation;
/**
* A detached child the engine cancelled along with its parent (a `spawn:` journaled before detached
* runs were started on their own): end it the way a Stop on its own id would have.
*/
private settleCascadedDetached;
}
//# sourceMappingURL=durable-agent-runner.d.ts.map