@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
49 lines • 2.94 kB
TypeScript
import type { RolesPolicy } from './spi/roles-policy.js';
import type { Actor, AgentDefinition, Persona, PersonaCatalogEntry, ToolSpec, TurnPersona } from './types.js';
/** First filter layer: drop tools the actor's role may not invoke. `can` may be async (authz). */
export declare function filterToolsByRole(tools: ToolSpec[], actor: Actor, policy: RolesPolicy): Promise<ToolSpec[]>;
/** Second filter layer: if the persona pins an allow-list, keep only those tool names. */
export declare function personaFilterTools(tools: ToolSpec[], allowedTools: string[] | undefined): ToolSpec[];
/**
* The narrower of two tool allow-lists. `undefined` is "no restriction", so it yields the other; two
* lists yield the names on both, in the order of the first.
*/
export declare function intersectAllowLists(first: readonly string[] | undefined, second: readonly string[] | undefined): string[] | undefined;
/** The persona `id` of `definition`, or `undefined` when it declares none by that id. */
export declare function findPersona(definition: Pick<AgentDefinition, 'personas'> | undefined, id: string | undefined): Persona | undefined;
/**
* The persona an agent runs under when nothing names one: its `defaultPersona`, else the persona
* whose id is `'default'` when it declares one. Undefined → none.
*/
export declare function defaultPersonaOf(definition: Pick<AgentDefinition, 'personas' | 'defaultPersona'> | undefined): string | undefined;
/** A persona as a picker reads it — never its prompt or its allow-list. */
export declare function personaCatalogEntry(persona: Persona): PersonaCatalogEntry;
/** Where a former agent name now lives: an agent, and the persona of it the name stands for. */
export interface PersonaAlias {
agent: string;
persona: string;
}
/**
* Resolve `name` through the {@link Persona.aliases} of `definitions`: the agent and persona that
* answer for it, or `undefined` when no persona claims it. A name that IS a registered agent is never
* an alias — the caller checks that first, so a real agent always wins.
*/
export declare function resolvePersonaAlias(definitions: readonly AgentDefinition[], name: string): PersonaAlias | undefined;
/**
* The persona as the turn's prompt builders and tools see it: the frozen definition, never the
* config's — its prompt is the resolved text, so a reader of `ctx.persona.systemPrompt` sees what the
* turn actually ran on.
*/
export declare function personaFromTurn(turn: TurnPersona): Persona;
/**
* A send named a persona its agent does not declare. The routes answer `400` with
* `code: 'persona_not_found'` — before a thread or a run is created.
*/
export declare class PersonaNotFoundError extends Error {
readonly agentName: string;
readonly persona: string;
readonly status: 400;
readonly code: 'persona_not_found';
constructor(agentName: string, persona: string);
}
//# sourceMappingURL=personas.d.ts.map