UNPKG

@adonis-agora/agent

Version:

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

61 lines • 3.3 kB
import type { HttpContext } from '@adonisjs/core/http'; import type { ApplicationService } from '@adonisjs/core/types'; import { type ConsoleAuthorizeDecision } from '../console-authorize.js'; import { type McpAuth } from '../mcp/auth.js'; import { type DevToolsActions } from './actions.js'; import { type DevToolsAuth } from './auth.js'; import type { DevToolsHubImpl } from './hub.js'; /** The scope a Poppy (personal agent) grant must carry to reach the dev tools. */ export declare const AGORA_DEV_SCOPE = "agora:dev"; export type { DevToolsActionRequest, DevToolsActions, DevToolsActionsAuthorizer, DevToolsActionsMap, } from './actions.js'; /** The logger surface the endpoint writes its audit lines to. */ export interface DevToolsLogger { info(obj: object, msg: string): void; debug(obj: object, msg: string): void; warn(obj: object, msg: string): void; } export interface DevToolsEndpointOptions { app: ApplicationService; hub: DevToolsHubImpl; /** Normalized route path, no slashes around (`mcp/agora`). */ path: string; actions: DevToolsActions; /** `authKitAuth()` resolved, when `@adonis-agora/authkit-server` is in the app (and no `auth`). */ authkit?: McpAuth | undefined; /** `devTools.auth`: OAuth with any authorization server. Wins over `authkit`. */ auth?: DevToolsAuth | undefined; logger: () => Promise<DevToolsLogger | undefined>; version: string; /** * The resolved `devTools.authorize`: gates the libs registered without an `authorize` of their own * (libs that have no console). `undefined` → open outside production, `403` in production. */ endpointAuthorize?: ((ctx: HttpContext) => Promise<ConsoleAuthorizeDecision>) | undefined; /** `app.inProduction`, read for the endpoint gate's default. */ inProduction?: boolean; } /** * The dev MCP endpoint: stateless, re-authorized on every request, per lib. See the "Dev tools over * MCP" docs page for the behaviour; the order of a request is: * * 1. a bearer token is first offered to `devTools.auth` when set (its principal is bound to the * request: `devToolsPrincipal(ctx)`, and `ctx.auth.user` with a resolved user), else to authkit * (when installed): a token issued for THIS endpoint signs the account in and is bridged into the * request like a browser session; a Poppy token needs the `agora:dev` scope. A bearer neither * recognizes is left on the request for `authorizeByToken`. * 2. each lib the JSON-RPC message needs runs its own console `authorize(ctx)`, once. * 3. none allowed → `401`/`403`; else a registry of the allowed libs' tools serves the message. */ export declare class DevToolsEndpoint { #private; constructor(options: DevToolsEndpointOptions); get path(): string; /** Whether the hub does OAuth discovery (`devTools.auth`, or authkit). */ get oauth(): boolean; /** `GET /.well-known/oauth-protected-resource/<path>` — only mounted with `devTools.auth` or authkit. */ metadata(ctx: HttpContext): Promise<void>; handlePost(ctx: HttpContext): Promise<void>; /** `GET`/`DELETE`: the endpoint is stateless. Authorized first, so a stranger gets the 401. */ methodNotAllowed(ctx: HttpContext): Promise<void>; } //# sourceMappingURL=endpoint.d.ts.map