@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
65 lines • 2.6 kB
TypeScript
import type { HttpContext } from '@adonisjs/core/http';
import type { ToolRegistry } from '../tool-registry.js';
import type { Actor } from '../types.js';
import type { A2aAuth, A2aCaller } from './auth.js';
import type { A2aStore } from './store.js';
import { type A2aActionPolicy, type A2aTurnService } from './turn.js';
/** What an Agent Card says about the agent, beyond what the surface fills in. */
export interface A2aCardInput {
name: string;
description: string;
version?: string;
provider?: {
organization: string;
url: string;
};
documentationUrl?: string;
iconUrl?: string;
skills?: {
id: string;
name: string;
description: string;
tags: string[];
examples?: string[];
}[];
}
/** One agent exposed over A2A — a "brand" in PACT terms, at `/{path}/{id}`. */
export interface A2aBrand {
id: string;
/** The registered agent that answers. */
agentName: string;
card: A2aCardInput;
}
export interface A2aHandlerOptions {
/** Mount prefix, no slashes (`'a2a'` → `/a2a/{brand}/…`). */
path: string;
/** Public origin the card's interface URL is built on. Omitted → the request's. */
baseUrl?: string;
brands: ReadonlyMap<string, A2aBrand>;
/** Serve this brand's card at `/.well-known/agent-card.json` too (PACT §2.1's standard place). */
rootCardBrand?: string;
auth: A2aAuth;
store: A2aStore;
service: A2aTurnService;
/** Where a tool's roles are read when the service does not answer them. */
registry: ToolRegistry;
actions: A2aActionPolicy;
timeoutMs: number;
maxBodyBytes: number;
/** Roles of the actor a turn runs as. Default: the personal-agent role plus the delegated scopes. */
roles?: (caller: A2aCaller) => string[];
/** Map the caller to the app's actor (see `A2aConfig.actor`). */
actor?: (caller: A2aCaller, defaults: Actor) => Actor | Promise<Actor>;
}
/**
* The actor of an identity-only turn: stable per (personal agent, its user), never an account id —
* the `pa:` prefix keeps it from ever colliding with one.
*/
export declare function personalAgentActorId(issuer: string, sub: string): string;
/**
* The A2A 1.0 HTTP+JSON surface (PACT §2, §4, §5.5) over the agent runtime. Returns a request
* handler that answers everything under `/{path}/` and reports `false` for anything else, so it can
* sit in front of the router.
*/
export declare function createA2aHandler(options: A2aHandlerOptions): (ctx: HttpContext) => Promise<boolean>;
//# sourceMappingURL=handler.d.ts.map