@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
99 lines • 4.75 kB
TypeScript
import { type UiAction } from '../../genui/actions.js';
import { type UiCapabilities } from '../../genui/capabilities.js';
import { type InterruptAddress } from './interrupt-id.js';
import type { AgUiContext, AgUiMessage, AgUiResumeEntry, AgUiRunInput } from './types.js';
/**
* Read a request body as a `RunAgentInput`, or say why it is not one.
*
* Only what this producer acts on is checked, and a KNOWN member with a value the schema rejects is
* malformed (the run never starts). A member it does not recognise is not an error — the protocol's
* asymmetry: a newer consumer's input must not bounce off an older producer.
*/
export declare function parseRunInput(body: unknown): AgUiRunInput | string;
/** A media part carried inline, ready to be staged as an attachment. */
export interface InlineMedia {
kind: 'image' | 'audio' | 'video' | 'document';
contentType: string;
data: Buffer;
filename: string;
}
/**
* The `provider` of a `file` source naming an upload this agent already staged
* (`POST <path>/attachments`): `{ type: 'file', provider: 'agora', value: <mediaId> }`.
*/
export declare const AG_UI_STAGED_MEDIA_PROVIDER = "agora";
export interface UserTurn {
/** The text of the message the run answers. */
text: string;
media: InlineMedia[];
/**
* Uploads this agent staged itself, named by `mediaId` (a `file` source whose `provider` is
* {@link AG_UI_STAGED_MEDIA_PROVIDER}). Resolved for the caller like the native `attachments`
* refs: one that is not the caller's refuses the send.
*/
staged: {
mediaId: string;
}[];
/** Why a part was not used, one sentence each — reported, never fatal. */
dropped: string[];
}
/**
* The turn a run answers: the LAST user message of the input. The library keeps each thread's
* history itself, so the earlier messages the consumer restates are not read back in — what the
* agent resumes from is what it stored.
*
* Multimodal parts: text parts are the message's text; a media part carried inline (`data`) becomes
* an attachment, and so does a `file` handle naming an upload this agent staged
* ({@link AG_UI_STAGED_MEDIA_PROVIDER}). A part by `url` or by any other provider's `file` handle
* is dropped and said so — this producer hands the model only bytes it staged itself, never an
* address a caller supplied.
*/
export declare function readUserTurn(messages: readonly AgUiMessage[]): UserTurn | null;
/** `context` entries as the library's page context carries them, or `undefined` for none. */
export declare function readContext(context: readonly AgUiContext[] | undefined): AgUiContext[] | undefined;
/**
* What the library reads from `forwardedProps` — the consumer's channel for what AG-UI does not
* model: which agent, which model, which persona, the page context the tools see, and whether the
* run regenerates the last answer.
*/
export interface ForwardedOptions {
uiCapabilities?: UiCapabilities;
/** Re-answer the thread's last user message instead of appending this one (`regenerate: true`). */
regenerate?: boolean;
agent?: string;
model?: string;
persona?: string;
pageContext?: Record<string, unknown>;
/**
* A UI action that IS this turn: `forwardedProps.uiAction` (a `UiAction` — a sandbox's
* `agent.send`) or `forwardedProps.a2uiAction.userAction` (A2UI's AG-UI binding). A string when
* one was sent but refused.
*/
uiAction?: UiAction | string;
}
export declare function readForwardedProps(forwarded: unknown): ForwardedOptions;
/** One resume entry this producer can act on. */
export interface ResumeDecision {
address: InterruptAddress;
entry: AgUiResumeEntry;
}
export interface ResumePlan {
decisions: ResumeDecision[];
/** Entries naming an interrupt this producer did not raise: skipped with a warning, never fatal. */
unrecognised: string[];
}
/**
* Sort a resume list into what it answers. Every recognised entry must continue the SAME library
* run from the SAME point — they are the interrupts of one `RUN_FINISHED` — and a list that does not
* is malformed (a string says why).
*/
export declare function planResume(resume: readonly AgUiResumeEntry[]): ResumePlan | string;
/** `{ approved, reason?, remember? }` out of an approval's resume payload. A bare boolean is accepted. */
export declare function readApprovalPayload(payload: unknown): {
approved: boolean;
reason?: string;
remember?: boolean;
} | null;
/** `questionId → string[]` out of an elicitation's resume payload (`{ answers }` or the map itself). */
export declare function readAnswersPayload(payload: unknown): Record<string, string[]> | null;
//# sourceMappingURL=input.d.ts.map