@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
74 lines • 3.18 kB
TypeScript
import type { AgentStore } from './spi/agent-store.js';
import type { DetachedDelivery } from './types.js';
/**
* What a detached delegation hands the model in place of an answer. Its `status` is the whole point:
* a model that is given an object shaped like a result will report one, and this run has none yet.
*/
export interface DetachedDelegationReceipt {
detached: true;
status: 'started';
/** The agent now working on it. */
agent: string;
/** The run doing the work — what a client subscribes to, and what stamps the delivered message. */
runId: string;
/**
* The same fact in the only vocabulary the model reliably acts on: prose in a tool result. The
* structured fields above are for a client; this is for the turn that has to explain itself to a
* user without claiming a result it does not hold.
*/
note: string;
}
/** How a detached delegation ended, written back onto its tool-call row once the run settles. */
export interface DetachedDelegationOutcome {
detached: true;
status: 'delivered' | 'failed' | 'cancelled';
agent: string;
runId: string;
/** The delivered answer. Present on `delivered` only. */
text?: string;
/** Why it did not deliver. Present on `failed` only. */
error?: string;
}
/** The receipt an `agent`-kind call returns the moment its delegate is under way. */
export declare function detachedStarted(args: {
agent: string;
runId: string;
}): DetachedDelegationReceipt;
/** The outcome written onto the delegating tool call when a detached run finishes its answer. */
export declare function detachedDelivered(args: {
agent: string;
runId: string;
text: string;
}): DetachedDelegationOutcome;
/**
* The outcome written onto the delegating tool call when a detached run never produced an answer.
* Written by the RUNNER, not the loop: a run that crashed or was stopped cannot record its own ending.
*/
export declare function detachedUnsettled(args: {
agent: string;
runId: string;
status: 'failed' | 'cancelled';
error?: string;
}): DetachedDelegationOutcome;
/**
* Settle the delegation a detached run was started for, when that run ends with no answer.
*
* Two writes, because a reader needs both: the tool-call row, so a governance surface stops counting
* it as in flight, and a MESSAGE in the delegating thread, so the person who asked finds out. A
* delivered answer already arrives as a message; without this, failure is the one outcome that
* silently never does, and the conversation shows "started" for ever.
*
* Called by the RUNNER, never the loop. Skipped when the thread is gone (as delivery is), and when the
* thread already holds a message from this run — so a second settle is a no-op.
*/
export declare function settleUnsettledDelegation(args: {
store: AgentStore;
delivery: DetachedDelivery;
agent: string;
runId: string;
/** The run that made the delegating call (the detached run's `parentRunId`), whose row is settled. */
parentRunId?: string;
status: 'failed' | 'cancelled';
error?: string;
}): Promise<void>;
//# sourceMappingURL=delegation.d.ts.map