UNPKG

@adonis-agora/agent

Version:

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

89 lines • 4.01 kB
import { type ResolvedAgentTenancy, type TenantScope } from '../agora/tenancy.js'; import type { AgentGovernanceQueries } from '../spi/governance-queries.js'; import type { QuotaReport } from '../spi/quota-provider.js'; import type { Actor, ThreadSummary } from '../types.js'; import type { AccountExtension, AccountExtensionContext } from './contract.js'; /** `config/agent.ts` → `accountConsole`: the agent's pages in the authkit account console. */ export interface AgentAccountConsoleOptions { /** * The agent actor of a signed-in account. Default: the app user authkit's account mapping hook * resolved (`subject`), else the account id, with the account's roles. With tenancy on, the active * organization becomes `tenantRef`. */ actor?: (account: AccountExtensionContext['account'], ctx: AccountExtensionContext) => Actor | Promise<Actor>; /** * Link each conversation (and each approval) to your chat page: an app-local path such as * `(threadId) => '/chat/' + threadId`. No link when omitted. */ threadUrl?: (threadId: string) => string; /** Turn single pages off. All on by default (connections and approvals only when available). */ pages?: { usage?: boolean; conversations?: boolean; connections?: boolean; approvals?: boolean; }; } /** What the agent's account pages read and act through. */ export interface AgentAccountDeps { service: { quotaReport(actor: Actor): Promise<QuotaReport>; listThreads(actorRef: string, options?: { limit?: number; tenantScope?: TenantScope | null; }): Promise<ThreadSummary[]>; threadOwner(threadId: string): Promise<string | null>; threadTenantRef(threadId: string): Promise<{ tenantRef: string | null; } | null>; runTenantRef(runId: string): Promise<{ tenantRef: string | null; } | null>; deleteThread(threadId: string): Promise<void>; toolCallRun(toolCallId: string): Promise<string | null>; toolCallApproval(toolCallId: string, runId?: string): Promise<{ status: string; approver: string | null; expiresAt: string | null; } | null>; runOwner(runId: string): Promise<string | null>; mayDecide(actor: Actor, decision: { toolCallId: string; approver: string; requesterRef: string; }): Promise<boolean>; approve(runId: string, toolCallId: string, opts: { executedByRef?: string; via?: string; }): Promise<void>; reject(runId: string, toolCallId: string, reason: string | undefined, opts: { executedByRef?: string; via?: string; }): Promise<void>; }; governance?: AgentGovernanceQueries | undefined; /** The Poppy connections service, when `poppy_connections_provider` is registered. */ connections?: () => Promise<AgentAccountConnections | undefined>; tenancy: ResolvedAgentTenancy; options?: AgentAccountConsoleOptions; } /** The slice of `PoppyConnections` the connections page uses. */ export interface AgentAccountConnections { ownerOf(actor: Actor): string; list(owner: string): Promise<Array<{ domain: string; organization: string; status: 'pending' | 'active' | 'revoked'; scope: string; connectedSince: number | null; }>>; disconnect(owner: string, domain: string): Promise<boolean>; } /** Recorded as `decidedVia` on approvals settled here, next to the in-app ones. */ export declare const ACCOUNT_CONSOLE_VIA = "account-console"; /** * The agent's contribution to the authkit account console: AI usage (`/account/ai`), conversations, * connected agents (Poppy) and pending approvals, each for the signed-in account only. */ export declare function agentAccountExtension(deps: AgentAccountDeps): AccountExtension; //# sourceMappingURL=extension.d.ts.map