UNPKG

@adonis-agora/agent

Version:

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

48 lines • 3.02 kB
/** * The one matcher for console capabilities (SECURITY-UNIFORM-SPEC §10.16b). Every console-capability * check of an `@adonis-agora` lib goes through it: the console's token, the viewer's capabilities, * the narrowing of what the console sends, the gating of the console's own app, the UI. * * This file is copied, not shared through a package, and kept byte-identical across the libs apart * from {@link LIB}. The lib passes its own table of console capabilities (which are reads, which are * writes) where it calls {@link consoleCapabilityAllows}. * * `granted` allows `required` when one of its entries is: * * - exactly `required`; * - a literal alias: `*`, `<lib>:*` or `<lib>:console:*` (for any `<lib>:` capability); * - `<lib>:console:write`, when `required` is a read or a write console capability (write implies * read), or `<lib>:console:read`, when it is a read; * - a hierarchical grant under `<lib>:` whose ONLY `*` is its last segment, and whose other * segments are `required`'s first ones (`<lib>:secrets:*` allows `<lib>:secrets:read`). * * Any other `*` grants nothing: in the middle (`<lib>:*:read`), inside a segment * (`<lib>:console:w*`, `<lib>:c*`), or in another namespace (`*:console:*`, `other:console:*`). * A capability neither listed as a read nor as a write (a sensitive one) is only allowed by an * exact grant, a literal alias, or a hierarchical grant. * * Not for data-operation grammars with key patterns (crypto's `crypto:decrypt:<key-pattern>`): * those keep their own matcher. */ /** Whether a console capability reads or writes. */ export type ConsoleCapabilityKind = 'read' | 'write'; /** A lib's console capabilities, each a read or a write (`{ 'config:read': 'read', … }`). */ export type ConsoleCapabilityTable = Readonly<Record<string, ConsoleCapabilityKind>>; /** The alias that covers every read console capability of this lib. */ export declare const CONSOLE_READ = "agent:console:read"; /** The alias that covers every read and write console capability of this lib. */ export declare const CONSOLE_WRITE = "agent:console:write"; /** The alias that covers every capability of this lib. */ export declare const CONSOLE_ALL = "agent:console:*"; /** * Whether `capability` reads or writes, by the lib's `table`. The two aliases classify themselves * (`<lib>:console:read` is a read, `<lib>:console:write` a write); anything else unlisted is * `undefined` (sensitive: no read/write alias covers it). */ export declare function consoleCapabilityKind(capability: string, table?: ConsoleCapabilityTable): ConsoleCapabilityKind | undefined; /** * Whether `granted` (a token's or a viewer's capabilities) allows `required`, by the rules above. * Non-string and empty entries grant nothing; a malformed `granted` (not an array) allows nothing. */ export declare function consoleCapabilityAllows(granted: readonly unknown[] | undefined, required: string, table?: ConsoleCapabilityTable): boolean; //# sourceMappingURL=console_capabilities.d.ts.map