UNPKG

@adonis-agora/agent

Version:

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

61 lines • 3.48 kB
import type { WorkflowEngine } from '@adonis-agora/durable'; import type { AgentDepsFactory } from '../agent-deps-factory.js'; import type { ChatQueueService } from '../chat-queue-service.js'; import type { AgentStore } from '../spi/agent-store.js'; /** * The runtime graph the durable {@link import('./agent-run-workflow.js').AgentRunWorkflow} body needs. * * A durable workflow class is instantiated by the engine with NO constructor arguments (see the * durable lib's `registerWorkflowClass`), so — unlike the NestJS reference, which injected these via * DI — the AdonisJS workflow reads them from this module-level holder instead. The provider populates * it once at boot (and a test sets it directly), mirroring the durable lib's own * `setWorkflowEngineResolver` seam. Re-read on every replay (it's a pure lookup, no side effect), so * it stays deterministic. */ export interface DurableAgentContext { factory: AgentDepsFactory; store: AgentStore; /** * The thread message queue a settling turn hands its thread to. Set on every pod of a deployment * or on none: whether a turn writes the queue checkpoints must not depend on which pod replays it. */ queue?: ChatQueueService; /** * The engine a DETACHED delegation is started on, as a run of its own (not a `spawn:` child, which * a Stop on the delegating turn would cascade to). The provider sets it. Absent, the engine * `registerAgentWorkflow` was last called with is used — every wiring calls it — and failing that, * `AgentRunWorkflow.dispatch` from outside the ambient ctx, which resolves the engine the way any * `BaseWorkflow` static does. */ engine?: WorkflowEngine; } /** Install (or clear, with `undefined`) the durable agent context. Called by the provider at boot. */ export declare function setDurableAgentContext(context: DurableAgentContext | undefined): void; /** * The installed {@link DurableAgentContext}. Throws if the durable runner was reached without the * provider having wired it — a misconfiguration, never a normal path. */ export declare function getDurableAgentContext(): DurableAgentContext; /** @internal Recorded by `registerAgentWorkflow`: the engine the agent workflow runs on. */ export declare function rememberAgentEngine(engine: WorkflowEngine | undefined): void; /** * @internal The engine the agent's durable runner was wired on (`durable: true`), if it was — what * the text channels run their inbound messages on. */ export declare function registeredAgentEngine(): WorkflowEngine | undefined; /** * @internal Be told when the agent's durable engine is wired (now, when it already is). Returns an * unsubscribe function. */ export declare function onAgentEngine(listener: (engine: WorkflowEngine) => void): () => void; /** * @internal Where the app's durable engine serves dispatched steps by name (its transport) — * recorded by the provider before the agent workflow is registered, so the text channels dispatch * their phases there. */ export declare function rememberAgentStepServer(server: unknown): void; /** @internal See {@link rememberAgentStepServer}. */ export declare function registeredAgentStepServer(): unknown; /** @internal The engine a detached delegation starts on — see {@link DurableAgentContext.engine}. */ export declare function agentEngine(context: DurableAgentContext): WorkflowEngine | undefined; //# sourceMappingURL=agent-run-context.d.ts.map