@dudousxd/nestjs-agent-dashboard 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/index.cjs +795 -102
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +164 -3
- package/dist/server/index.d.ts +164 -3
- package/dist/server/index.js +768 -87
- package/dist/server/index.js.map +1 -1
- package/dist/spa/assets/index-BW1bqmTf.css +1 -0
- package/dist/spa/assets/index-C4U9WEBt.js +1 -0
- package/dist/spa/assets/{preview-CbqJ2CAQ.js → preview-CJ1UfhOA.js} +1 -1
- package/dist/spa/index.html +3 -3
- package/dist/spa/preview.html +3 -3
- package/package.json +1 -1
- package/dist/spa/assets/index-ClnZsvJ1.css +0 -1
- package/dist/spa/assets/index-D3yTBCU0.js +0 -1
- /package/dist/spa/assets/{index-DS11tOEH.js → index-Br3YfiYJ.js} +0 -0
package/dist/server/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActorSpendRow, AgentGovernanceQueries, ActorDirectory, AgentPricingStore, AgentApprovalPort, GovernanceRange, ModelSpendRow, UsageTrendPoint, FeatureSpendRow, ThreadSpendRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, ToolCallActivityRow, GovernancePageQuery, ToolCallWhere, GovernancePage, RunWhere, PendingApprovalRow, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, ThreadActivityRow, ToolStatRow, GenuiStats, ThreadWhere, CurrentModelPrice, ActorResolver, ModelPriceInput } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
export { ActorDirectory } from '@dudousxd/nestjs-agent-core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
|
-
import { ExecutionContext, Type, Logger, DynamicModule, StreamableFile, HttpException, ExceptionFilter, ArgumentsHost, CanActivate,
|
|
4
|
+
import { ExecutionContext, Type, Logger, DynamicModule, StreamableFile, OnModuleInit, HttpException, ExceptionFilter, ArgumentsHost, CanActivate, OnModuleDestroy } from '@nestjs/common';
|
|
5
5
|
import { ModuleRef, HttpAdapterHost } from '@nestjs/core';
|
|
6
6
|
|
|
7
7
|
/** An actor-scoped row decorated with its resolved display label — `null` when unbound or unresolved. */
|
|
@@ -295,9 +295,14 @@ interface AgentDashboardMountPathsOptions {
|
|
|
295
295
|
*/
|
|
296
296
|
declare function agentDashboardMountPaths(options?: AgentDashboardMountPathsOptions): string[];
|
|
297
297
|
|
|
298
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* What an `authorize` check answers. An allow may name who it let in (`caller`, for example
|
|
300
|
+
* `'user:42'`): the dev MCP endpoint logs it as the caller of a developer tool. Never put a secret
|
|
301
|
+
* in it.
|
|
302
|
+
*/
|
|
299
303
|
type ConsoleAuthorizeResult = boolean | {
|
|
300
304
|
allowed: true;
|
|
305
|
+
caller?: string;
|
|
301
306
|
} | {
|
|
302
307
|
allowed: false;
|
|
303
308
|
reason?: 'unauthenticated' | 'forbidden';
|
|
@@ -321,6 +326,7 @@ type ConsoleAuthorize = ((context: ExecutionContext) => ConsoleAuthorizeResult |
|
|
|
321
326
|
/** A normalized `authorize` answer. */
|
|
322
327
|
type ConsoleDecision = {
|
|
323
328
|
allowed: true;
|
|
329
|
+
caller?: string;
|
|
324
330
|
} | {
|
|
325
331
|
allowed: false;
|
|
326
332
|
reason: 'unauthenticated' | 'forbidden';
|
|
@@ -356,10 +362,22 @@ declare function resolveConsoleAuthorize(authorize: ConsoleAuthorize | undefined
|
|
|
356
362
|
/**
|
|
357
363
|
* `authorize` by a bearer token: allows when `Authorization: Bearer <token>` matches (compared in
|
|
358
364
|
* constant time), else `unauthenticated`. Header only. An empty token throws here, at config time.
|
|
365
|
+
* The allow names its caller `token:<first 12 hex of sha256(token)>`, never the token.
|
|
359
366
|
*/
|
|
360
367
|
declare function authorizeByToken(options: {
|
|
361
368
|
token: string | undefined;
|
|
362
369
|
}): (context: ExecutionContext) => ConsoleAuthorizeResult;
|
|
370
|
+
/**
|
|
371
|
+
* One `authorize` from several: allowed when any form allows (checked in order, stopping at the
|
|
372
|
+
* first that does, whose `caller` it keeps); otherwise `unauthenticated` when any form said so (keeping the first
|
|
373
|
+
* `redirectTo`), else `forbidden`. Each form is any `authorize` value: a function, a class, a lazy
|
|
374
|
+
* import, `{ policy, ability }` or a gate name.
|
|
375
|
+
*
|
|
376
|
+
* ```ts
|
|
377
|
+
* authorize: anyAuthorize(authorizeByToken({ token: process.env.CONSOLE_TOKEN }), AdminSessionAuthorizer)
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function anyAuthorize(...forms: ConsoleAuthorize[]): ConsoleAuthorizerClass;
|
|
363
381
|
|
|
364
382
|
/**
|
|
365
383
|
* `TReq` mirrors core's `ActorResolver<TReq>` convention: the transport request type
|
|
@@ -415,6 +433,12 @@ interface AgentDashboardOptions<TReq = unknown> {
|
|
|
415
433
|
* `executedByRef` unset — the explicit override wins outright, with no resolver fallback.
|
|
416
434
|
*/
|
|
417
435
|
approvalActorRef?: (req: TReq) => string | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Register the console's reads as developer tools on the agent MCP server's dev endpoint
|
|
438
|
+
* (`/mcp/aviary`), gated by this console's `authorize`. Default: on when the console's routes are
|
|
439
|
+
* mounted, off with `routes: false`.
|
|
440
|
+
*/
|
|
441
|
+
devTools?: boolean;
|
|
418
442
|
}
|
|
419
443
|
/** Holds the JSON API + SSE controller and its read service, mounted on its own path. */
|
|
420
444
|
declare class AgentApiModule {
|
|
@@ -424,6 +448,7 @@ declare class AgentApiModule {
|
|
|
424
448
|
routes?: boolean;
|
|
425
449
|
approvalActorRef?: (req: TReq) => string | undefined;
|
|
426
450
|
authorize?: ConsoleAuthorize;
|
|
451
|
+
devTools?: boolean;
|
|
427
452
|
}): DynamicModule;
|
|
428
453
|
}
|
|
429
454
|
/**
|
|
@@ -448,6 +473,8 @@ interface UiPageResponse {
|
|
|
448
473
|
status(code: number): unknown;
|
|
449
474
|
setHeader(name: string, value: string): unknown;
|
|
450
475
|
}
|
|
476
|
+
/** The id of the page's JSON config block. */
|
|
477
|
+
declare const AGENT_DASHBOARD_CONFIG_ID = "agent-dashboard-config";
|
|
451
478
|
/**
|
|
452
479
|
* Serves the bundled AI-gateway console SPA at the configured base (+ hashed assets at
|
|
453
480
|
* `<base>/assets`). The path comes from `RouterModule` (set by
|
|
@@ -463,6 +490,11 @@ declare class AgentUiController {
|
|
|
463
490
|
private readonly dir;
|
|
464
491
|
constructor(basePath: string, apiBasePath: string);
|
|
465
492
|
index(req: UiPageRequest, res: UiPageResponse): string;
|
|
493
|
+
/**
|
|
494
|
+
* The page's JSON config block (`agent-dashboard-config`, CSP-safe: data, not script). It carries
|
|
495
|
+
* `switcher` only when another Aviary console is registered.
|
|
496
|
+
*/
|
|
497
|
+
private configBlock;
|
|
466
498
|
asset(file: string): StreamableFile;
|
|
467
499
|
}
|
|
468
500
|
|
|
@@ -522,6 +554,133 @@ declare class ConsoleAuthorizeFilter implements ExceptionFilter<ConsoleAccessDen
|
|
|
522
554
|
*/
|
|
523
555
|
declare function UseConsoleAuthorize(): ClassDecorator & MethodDecorator;
|
|
524
556
|
|
|
557
|
+
/** The process-wide slot every Aviary console registers into (created by whichever boots first). */
|
|
558
|
+
declare const AVIARY_CONSOLES_SLOT: unique symbol;
|
|
559
|
+
/** The icon a console shows in the switcher. An unknown value renders as `generic`. */
|
|
560
|
+
type AviaryConsoleIcon = 'workflow' | 'telescope' | 'media' | 'payments' | 'agent' | 'identity' | 'generic';
|
|
561
|
+
/** What a console's `authorize` answers; only `allowed: true` lists it. */
|
|
562
|
+
interface AviaryConsoleDecision {
|
|
563
|
+
allowed: boolean;
|
|
564
|
+
reason?: string;
|
|
565
|
+
redirectTo?: string;
|
|
566
|
+
}
|
|
567
|
+
/** One console the switcher can list. */
|
|
568
|
+
interface AviaryConsoleEntry {
|
|
569
|
+
/** `/^[a-z][a-z0-9-]*$/`: `'durable'`, `'telescope'`, `'agent'`, `'media'`, … */
|
|
570
|
+
id: string;
|
|
571
|
+
/** Product title: `'Workflows'`, `'Telescope'`, `'Agents'`, `'Media'`. */
|
|
572
|
+
title: string;
|
|
573
|
+
icon: AviaryConsoleIcon;
|
|
574
|
+
/** Same-origin absolute path of the console's page (`/ai-gateway`). */
|
|
575
|
+
path: string;
|
|
576
|
+
/** Sort key: durable 10, telescope 20, agent 30, media 50. */
|
|
577
|
+
order: number;
|
|
578
|
+
/** The console's resolved gate (what its own routes run). Never throws. */
|
|
579
|
+
authorize(context: ExecutionContext): Promise<AviaryConsoleDecision>;
|
|
580
|
+
}
|
|
581
|
+
/** The value at {@link AVIARY_CONSOLES_SLOT}. Data only, so every console's copy is identical. */
|
|
582
|
+
interface AviaryConsoleRegistry {
|
|
583
|
+
readonly version: 1;
|
|
584
|
+
readonly entries: AviaryConsoleEntry[];
|
|
585
|
+
}
|
|
586
|
+
/** One console as `GET <api>/consoles` returns it. */
|
|
587
|
+
interface VisibleConsole {
|
|
588
|
+
id: string;
|
|
589
|
+
title: string;
|
|
590
|
+
icon: AviaryConsoleIcon;
|
|
591
|
+
href: string;
|
|
592
|
+
}
|
|
593
|
+
/** The answer of `GET <api>/consoles`. */
|
|
594
|
+
interface VisibleConsoles {
|
|
595
|
+
version: 1;
|
|
596
|
+
current: string;
|
|
597
|
+
consoles: VisibleConsole[];
|
|
598
|
+
}
|
|
599
|
+
/** How long another console's `authorize` may take before it is left out. */
|
|
600
|
+
declare const CONSOLE_PROBE_TIMEOUT_MS = 300;
|
|
601
|
+
/**
|
|
602
|
+
* Adds a console to the process's switcher registry, creating it when absent. Returns a function
|
|
603
|
+
* that removes the entry again, or `undefined` when it was not added (another registry version, or
|
|
604
|
+
* the id is taken: logged as a warning). A bad `id` or `path` throws.
|
|
605
|
+
*/
|
|
606
|
+
declare function registerAviaryConsole(entry: AviaryConsoleEntry, logger?: {
|
|
607
|
+
warn(message: string): void;
|
|
608
|
+
}): (() => void) | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* The consoles other than `selfId` the viewer may open, by `order` then `id`. Every other entry's
|
|
611
|
+
* `authorize` runs in parallel, each given `timeoutMs`; a timeout, a rejection or any denial hides
|
|
612
|
+
* it. No reason is ever returned.
|
|
613
|
+
*/
|
|
614
|
+
declare function listVisibleConsoles(registry: AviaryConsoleRegistry | undefined, selfId: string, context: ExecutionContext, timeoutMs?: number): Promise<VisibleConsoles>;
|
|
615
|
+
/** The agent console's id in the registry. */
|
|
616
|
+
declare const AGENT_CONSOLE_ID = "agent";
|
|
617
|
+
/**
|
|
618
|
+
* Registers the agent console into the switcher registry (the console's page path, gated by its
|
|
619
|
+
* resolved `authorize`). Provided only when the console's routes are mounted; removed on shutdown.
|
|
620
|
+
*/
|
|
621
|
+
declare class AgentConsoleRegistration implements OnModuleInit, OnModuleDestroy {
|
|
622
|
+
#private;
|
|
623
|
+
private readonly basePath;
|
|
624
|
+
private readonly access;
|
|
625
|
+
constructor(basePath: string, access: DashboardConsoleAccess);
|
|
626
|
+
onModuleInit(): void;
|
|
627
|
+
onModuleDestroy(): void;
|
|
628
|
+
}
|
|
629
|
+
/** What the route hands on to the other consoles' `authorize`: this request's `ExecutionContext`. */
|
|
630
|
+
interface CurrentContext {
|
|
631
|
+
context: ExecutionContext;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* `GET <api>/consoles`: the other Aviary consoles this viewer may open. Behind the console's own
|
|
635
|
+
* access check, like every API route, so only someone who may open this console learns the list.
|
|
636
|
+
*/
|
|
637
|
+
declare class AgentConsolesController {
|
|
638
|
+
consoles(current: CurrentContext): Promise<VisibleConsoles>;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
interface DevToolInputProperty {
|
|
642
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
643
|
+
description?: string;
|
|
644
|
+
enum?: readonly string[];
|
|
645
|
+
items?: {
|
|
646
|
+
type: 'string';
|
|
647
|
+
};
|
|
648
|
+
minimum?: number;
|
|
649
|
+
maximum?: number;
|
|
650
|
+
}
|
|
651
|
+
interface DevToolInputSchema {
|
|
652
|
+
type: 'object';
|
|
653
|
+
properties: Record<string, DevToolInputProperty>;
|
|
654
|
+
required?: string[];
|
|
655
|
+
}
|
|
656
|
+
/** One developer tool, as the dev-tools slot takes it. */
|
|
657
|
+
interface AgentDevTool {
|
|
658
|
+
name: string;
|
|
659
|
+
kind: 'read' | 'action';
|
|
660
|
+
description: string;
|
|
661
|
+
input: DevToolInputSchema;
|
|
662
|
+
run(input: Record<string, unknown>): Promise<unknown>;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* The agent's developer tools (lib `agent`): the governance console's reads, through the same
|
|
666
|
+
* {@link DashboardService} methods its API serves. No actions: approving a tool call over MCP would
|
|
667
|
+
* bypass the human approval it exists for.
|
|
668
|
+
*/
|
|
669
|
+
declare function agentDevTools(dashboard: DashboardService): AgentDevTool[];
|
|
670
|
+
/**
|
|
671
|
+
* Registers the agent's tools into the dev-tools slot, gated by the console's own resolved
|
|
672
|
+
* `authorize`, when the console is mounted (or `devTools: true`). Removed again on shutdown.
|
|
673
|
+
*/
|
|
674
|
+
declare class AgentDevToolsRegistration implements OnModuleInit, OnModuleDestroy {
|
|
675
|
+
#private;
|
|
676
|
+
private readonly enabled;
|
|
677
|
+
private readonly dashboard;
|
|
678
|
+
private readonly access;
|
|
679
|
+
constructor(enabled: boolean, dashboard: DashboardService, access: DashboardConsoleAccess);
|
|
680
|
+
onModuleInit(): void;
|
|
681
|
+
onModuleDestroy(): void;
|
|
682
|
+
}
|
|
683
|
+
|
|
525
684
|
/**
|
|
526
685
|
* Minimal shape guard for a `POST <api>/pricing` body — rejects junk before it reaches
|
|
527
686
|
* `AgentPricingStore.upsertModelPrice`. Not a full schema validator (the store adapter owns real
|
|
@@ -587,5 +746,7 @@ declare const DASHBOARD_API_PATH: unique symbol;
|
|
|
587
746
|
declare const DASHBOARD_APPROVAL_ACTOR_REF: unique symbol;
|
|
588
747
|
/** DI token carrying the console's `authorize` (and whether to warn when it is omitted). */
|
|
589
748
|
declare const DASHBOARD_CONSOLE_OPTIONS: unique symbol;
|
|
749
|
+
/** DI token: whether the agent's dev tools register into the dev-tools slot. */
|
|
750
|
+
declare const DASHBOARD_DEV_TOOLS: unique symbol;
|
|
590
751
|
|
|
591
|
-
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_GOVERNANCE_QUERIES, AGENT_PRICING_STORE, type ActorSpendRowWithLabel, AgentApiController, AgentApiModule, AgentDashboardModule, type AgentDashboardMountPathsOptions, type AgentDashboardOptions, AgentUiController, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, DASHBOARD_API_PATH, DASHBOARD_APPROVAL_ACTOR_REF, DASHBOARD_BASE_PATH, DASHBOARD_CONSOLE_OPTIONS, DashboardConsoleAccess, DashboardService, type LiveAgentEvent, type ReliabilityOverview, type RunDetailWithLabel, type SpendOverview, type ThreadActivityRowWithLabel, type ThreadDetailWithLabel, type ThreadSpendRowWithLabel, UseConsoleAuthorize, type WithActorLabel, agentDashboardMountPaths, authorizeByToken, normalizeConsoleResult, parsePriceInput, resolveConsoleAuthorize };
|
|
752
|
+
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_CONSOLE_ID, AGENT_DASHBOARD_CONFIG_ID, AGENT_GOVERNANCE_QUERIES, AGENT_PRICING_STORE, AVIARY_CONSOLES_SLOT, type ActorSpendRowWithLabel, AgentApiController, AgentApiModule, AgentConsoleRegistration, AgentConsolesController, AgentDashboardModule, type AgentDashboardMountPathsOptions, type AgentDashboardOptions, type AgentDevTool, AgentDevToolsRegistration, AgentUiController, type AviaryConsoleDecision, type AviaryConsoleEntry, type AviaryConsoleIcon, type AviaryConsoleRegistry, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, CONSOLE_PROBE_TIMEOUT_MS, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, DASHBOARD_API_PATH, DASHBOARD_APPROVAL_ACTOR_REF, DASHBOARD_BASE_PATH, DASHBOARD_CONSOLE_OPTIONS, DASHBOARD_DEV_TOOLS, DashboardConsoleAccess, DashboardService, type LiveAgentEvent, type ReliabilityOverview, type RunDetailWithLabel, type SpendOverview, type ThreadActivityRowWithLabel, type ThreadDetailWithLabel, type ThreadSpendRowWithLabel, UseConsoleAuthorize, type VisibleConsole, type VisibleConsoles, type WithActorLabel, agentDashboardMountPaths, agentDevTools, anyAuthorize, authorizeByToken, listVisibleConsoles, normalizeConsoleResult, parsePriceInput, registerAviaryConsole, resolveConsoleAuthorize };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActorSpendRow, AgentGovernanceQueries, ActorDirectory, AgentPricingStore, AgentApprovalPort, GovernanceRange, ModelSpendRow, UsageTrendPoint, FeatureSpendRow, ThreadSpendRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, ToolCallActivityRow, GovernancePageQuery, ToolCallWhere, GovernancePage, RunWhere, PendingApprovalRow, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, ThreadActivityRow, ToolStatRow, GenuiStats, ThreadWhere, CurrentModelPrice, ActorResolver, ModelPriceInput } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
export { ActorDirectory } from '@dudousxd/nestjs-agent-core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
|
-
import { ExecutionContext, Type, Logger, DynamicModule, StreamableFile, HttpException, ExceptionFilter, ArgumentsHost, CanActivate,
|
|
4
|
+
import { ExecutionContext, Type, Logger, DynamicModule, StreamableFile, OnModuleInit, HttpException, ExceptionFilter, ArgumentsHost, CanActivate, OnModuleDestroy } from '@nestjs/common';
|
|
5
5
|
import { ModuleRef, HttpAdapterHost } from '@nestjs/core';
|
|
6
6
|
|
|
7
7
|
/** An actor-scoped row decorated with its resolved display label — `null` when unbound or unresolved. */
|
|
@@ -295,9 +295,14 @@ interface AgentDashboardMountPathsOptions {
|
|
|
295
295
|
*/
|
|
296
296
|
declare function agentDashboardMountPaths(options?: AgentDashboardMountPathsOptions): string[];
|
|
297
297
|
|
|
298
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* What an `authorize` check answers. An allow may name who it let in (`caller`, for example
|
|
300
|
+
* `'user:42'`): the dev MCP endpoint logs it as the caller of a developer tool. Never put a secret
|
|
301
|
+
* in it.
|
|
302
|
+
*/
|
|
299
303
|
type ConsoleAuthorizeResult = boolean | {
|
|
300
304
|
allowed: true;
|
|
305
|
+
caller?: string;
|
|
301
306
|
} | {
|
|
302
307
|
allowed: false;
|
|
303
308
|
reason?: 'unauthenticated' | 'forbidden';
|
|
@@ -321,6 +326,7 @@ type ConsoleAuthorize = ((context: ExecutionContext) => ConsoleAuthorizeResult |
|
|
|
321
326
|
/** A normalized `authorize` answer. */
|
|
322
327
|
type ConsoleDecision = {
|
|
323
328
|
allowed: true;
|
|
329
|
+
caller?: string;
|
|
324
330
|
} | {
|
|
325
331
|
allowed: false;
|
|
326
332
|
reason: 'unauthenticated' | 'forbidden';
|
|
@@ -356,10 +362,22 @@ declare function resolveConsoleAuthorize(authorize: ConsoleAuthorize | undefined
|
|
|
356
362
|
/**
|
|
357
363
|
* `authorize` by a bearer token: allows when `Authorization: Bearer <token>` matches (compared in
|
|
358
364
|
* constant time), else `unauthenticated`. Header only. An empty token throws here, at config time.
|
|
365
|
+
* The allow names its caller `token:<first 12 hex of sha256(token)>`, never the token.
|
|
359
366
|
*/
|
|
360
367
|
declare function authorizeByToken(options: {
|
|
361
368
|
token: string | undefined;
|
|
362
369
|
}): (context: ExecutionContext) => ConsoleAuthorizeResult;
|
|
370
|
+
/**
|
|
371
|
+
* One `authorize` from several: allowed when any form allows (checked in order, stopping at the
|
|
372
|
+
* first that does, whose `caller` it keeps); otherwise `unauthenticated` when any form said so (keeping the first
|
|
373
|
+
* `redirectTo`), else `forbidden`. Each form is any `authorize` value: a function, a class, a lazy
|
|
374
|
+
* import, `{ policy, ability }` or a gate name.
|
|
375
|
+
*
|
|
376
|
+
* ```ts
|
|
377
|
+
* authorize: anyAuthorize(authorizeByToken({ token: process.env.CONSOLE_TOKEN }), AdminSessionAuthorizer)
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function anyAuthorize(...forms: ConsoleAuthorize[]): ConsoleAuthorizerClass;
|
|
363
381
|
|
|
364
382
|
/**
|
|
365
383
|
* `TReq` mirrors core's `ActorResolver<TReq>` convention: the transport request type
|
|
@@ -415,6 +433,12 @@ interface AgentDashboardOptions<TReq = unknown> {
|
|
|
415
433
|
* `executedByRef` unset — the explicit override wins outright, with no resolver fallback.
|
|
416
434
|
*/
|
|
417
435
|
approvalActorRef?: (req: TReq) => string | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Register the console's reads as developer tools on the agent MCP server's dev endpoint
|
|
438
|
+
* (`/mcp/aviary`), gated by this console's `authorize`. Default: on when the console's routes are
|
|
439
|
+
* mounted, off with `routes: false`.
|
|
440
|
+
*/
|
|
441
|
+
devTools?: boolean;
|
|
418
442
|
}
|
|
419
443
|
/** Holds the JSON API + SSE controller and its read service, mounted on its own path. */
|
|
420
444
|
declare class AgentApiModule {
|
|
@@ -424,6 +448,7 @@ declare class AgentApiModule {
|
|
|
424
448
|
routes?: boolean;
|
|
425
449
|
approvalActorRef?: (req: TReq) => string | undefined;
|
|
426
450
|
authorize?: ConsoleAuthorize;
|
|
451
|
+
devTools?: boolean;
|
|
427
452
|
}): DynamicModule;
|
|
428
453
|
}
|
|
429
454
|
/**
|
|
@@ -448,6 +473,8 @@ interface UiPageResponse {
|
|
|
448
473
|
status(code: number): unknown;
|
|
449
474
|
setHeader(name: string, value: string): unknown;
|
|
450
475
|
}
|
|
476
|
+
/** The id of the page's JSON config block. */
|
|
477
|
+
declare const AGENT_DASHBOARD_CONFIG_ID = "agent-dashboard-config";
|
|
451
478
|
/**
|
|
452
479
|
* Serves the bundled AI-gateway console SPA at the configured base (+ hashed assets at
|
|
453
480
|
* `<base>/assets`). The path comes from `RouterModule` (set by
|
|
@@ -463,6 +490,11 @@ declare class AgentUiController {
|
|
|
463
490
|
private readonly dir;
|
|
464
491
|
constructor(basePath: string, apiBasePath: string);
|
|
465
492
|
index(req: UiPageRequest, res: UiPageResponse): string;
|
|
493
|
+
/**
|
|
494
|
+
* The page's JSON config block (`agent-dashboard-config`, CSP-safe: data, not script). It carries
|
|
495
|
+
* `switcher` only when another Aviary console is registered.
|
|
496
|
+
*/
|
|
497
|
+
private configBlock;
|
|
466
498
|
asset(file: string): StreamableFile;
|
|
467
499
|
}
|
|
468
500
|
|
|
@@ -522,6 +554,133 @@ declare class ConsoleAuthorizeFilter implements ExceptionFilter<ConsoleAccessDen
|
|
|
522
554
|
*/
|
|
523
555
|
declare function UseConsoleAuthorize(): ClassDecorator & MethodDecorator;
|
|
524
556
|
|
|
557
|
+
/** The process-wide slot every Aviary console registers into (created by whichever boots first). */
|
|
558
|
+
declare const AVIARY_CONSOLES_SLOT: unique symbol;
|
|
559
|
+
/** The icon a console shows in the switcher. An unknown value renders as `generic`. */
|
|
560
|
+
type AviaryConsoleIcon = 'workflow' | 'telescope' | 'media' | 'payments' | 'agent' | 'identity' | 'generic';
|
|
561
|
+
/** What a console's `authorize` answers; only `allowed: true` lists it. */
|
|
562
|
+
interface AviaryConsoleDecision {
|
|
563
|
+
allowed: boolean;
|
|
564
|
+
reason?: string;
|
|
565
|
+
redirectTo?: string;
|
|
566
|
+
}
|
|
567
|
+
/** One console the switcher can list. */
|
|
568
|
+
interface AviaryConsoleEntry {
|
|
569
|
+
/** `/^[a-z][a-z0-9-]*$/`: `'durable'`, `'telescope'`, `'agent'`, `'media'`, … */
|
|
570
|
+
id: string;
|
|
571
|
+
/** Product title: `'Workflows'`, `'Telescope'`, `'Agents'`, `'Media'`. */
|
|
572
|
+
title: string;
|
|
573
|
+
icon: AviaryConsoleIcon;
|
|
574
|
+
/** Same-origin absolute path of the console's page (`/ai-gateway`). */
|
|
575
|
+
path: string;
|
|
576
|
+
/** Sort key: durable 10, telescope 20, agent 30, media 50. */
|
|
577
|
+
order: number;
|
|
578
|
+
/** The console's resolved gate (what its own routes run). Never throws. */
|
|
579
|
+
authorize(context: ExecutionContext): Promise<AviaryConsoleDecision>;
|
|
580
|
+
}
|
|
581
|
+
/** The value at {@link AVIARY_CONSOLES_SLOT}. Data only, so every console's copy is identical. */
|
|
582
|
+
interface AviaryConsoleRegistry {
|
|
583
|
+
readonly version: 1;
|
|
584
|
+
readonly entries: AviaryConsoleEntry[];
|
|
585
|
+
}
|
|
586
|
+
/** One console as `GET <api>/consoles` returns it. */
|
|
587
|
+
interface VisibleConsole {
|
|
588
|
+
id: string;
|
|
589
|
+
title: string;
|
|
590
|
+
icon: AviaryConsoleIcon;
|
|
591
|
+
href: string;
|
|
592
|
+
}
|
|
593
|
+
/** The answer of `GET <api>/consoles`. */
|
|
594
|
+
interface VisibleConsoles {
|
|
595
|
+
version: 1;
|
|
596
|
+
current: string;
|
|
597
|
+
consoles: VisibleConsole[];
|
|
598
|
+
}
|
|
599
|
+
/** How long another console's `authorize` may take before it is left out. */
|
|
600
|
+
declare const CONSOLE_PROBE_TIMEOUT_MS = 300;
|
|
601
|
+
/**
|
|
602
|
+
* Adds a console to the process's switcher registry, creating it when absent. Returns a function
|
|
603
|
+
* that removes the entry again, or `undefined` when it was not added (another registry version, or
|
|
604
|
+
* the id is taken: logged as a warning). A bad `id` or `path` throws.
|
|
605
|
+
*/
|
|
606
|
+
declare function registerAviaryConsole(entry: AviaryConsoleEntry, logger?: {
|
|
607
|
+
warn(message: string): void;
|
|
608
|
+
}): (() => void) | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* The consoles other than `selfId` the viewer may open, by `order` then `id`. Every other entry's
|
|
611
|
+
* `authorize` runs in parallel, each given `timeoutMs`; a timeout, a rejection or any denial hides
|
|
612
|
+
* it. No reason is ever returned.
|
|
613
|
+
*/
|
|
614
|
+
declare function listVisibleConsoles(registry: AviaryConsoleRegistry | undefined, selfId: string, context: ExecutionContext, timeoutMs?: number): Promise<VisibleConsoles>;
|
|
615
|
+
/** The agent console's id in the registry. */
|
|
616
|
+
declare const AGENT_CONSOLE_ID = "agent";
|
|
617
|
+
/**
|
|
618
|
+
* Registers the agent console into the switcher registry (the console's page path, gated by its
|
|
619
|
+
* resolved `authorize`). Provided only when the console's routes are mounted; removed on shutdown.
|
|
620
|
+
*/
|
|
621
|
+
declare class AgentConsoleRegistration implements OnModuleInit, OnModuleDestroy {
|
|
622
|
+
#private;
|
|
623
|
+
private readonly basePath;
|
|
624
|
+
private readonly access;
|
|
625
|
+
constructor(basePath: string, access: DashboardConsoleAccess);
|
|
626
|
+
onModuleInit(): void;
|
|
627
|
+
onModuleDestroy(): void;
|
|
628
|
+
}
|
|
629
|
+
/** What the route hands on to the other consoles' `authorize`: this request's `ExecutionContext`. */
|
|
630
|
+
interface CurrentContext {
|
|
631
|
+
context: ExecutionContext;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* `GET <api>/consoles`: the other Aviary consoles this viewer may open. Behind the console's own
|
|
635
|
+
* access check, like every API route, so only someone who may open this console learns the list.
|
|
636
|
+
*/
|
|
637
|
+
declare class AgentConsolesController {
|
|
638
|
+
consoles(current: CurrentContext): Promise<VisibleConsoles>;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
interface DevToolInputProperty {
|
|
642
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
643
|
+
description?: string;
|
|
644
|
+
enum?: readonly string[];
|
|
645
|
+
items?: {
|
|
646
|
+
type: 'string';
|
|
647
|
+
};
|
|
648
|
+
minimum?: number;
|
|
649
|
+
maximum?: number;
|
|
650
|
+
}
|
|
651
|
+
interface DevToolInputSchema {
|
|
652
|
+
type: 'object';
|
|
653
|
+
properties: Record<string, DevToolInputProperty>;
|
|
654
|
+
required?: string[];
|
|
655
|
+
}
|
|
656
|
+
/** One developer tool, as the dev-tools slot takes it. */
|
|
657
|
+
interface AgentDevTool {
|
|
658
|
+
name: string;
|
|
659
|
+
kind: 'read' | 'action';
|
|
660
|
+
description: string;
|
|
661
|
+
input: DevToolInputSchema;
|
|
662
|
+
run(input: Record<string, unknown>): Promise<unknown>;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* The agent's developer tools (lib `agent`): the governance console's reads, through the same
|
|
666
|
+
* {@link DashboardService} methods its API serves. No actions: approving a tool call over MCP would
|
|
667
|
+
* bypass the human approval it exists for.
|
|
668
|
+
*/
|
|
669
|
+
declare function agentDevTools(dashboard: DashboardService): AgentDevTool[];
|
|
670
|
+
/**
|
|
671
|
+
* Registers the agent's tools into the dev-tools slot, gated by the console's own resolved
|
|
672
|
+
* `authorize`, when the console is mounted (or `devTools: true`). Removed again on shutdown.
|
|
673
|
+
*/
|
|
674
|
+
declare class AgentDevToolsRegistration implements OnModuleInit, OnModuleDestroy {
|
|
675
|
+
#private;
|
|
676
|
+
private readonly enabled;
|
|
677
|
+
private readonly dashboard;
|
|
678
|
+
private readonly access;
|
|
679
|
+
constructor(enabled: boolean, dashboard: DashboardService, access: DashboardConsoleAccess);
|
|
680
|
+
onModuleInit(): void;
|
|
681
|
+
onModuleDestroy(): void;
|
|
682
|
+
}
|
|
683
|
+
|
|
525
684
|
/**
|
|
526
685
|
* Minimal shape guard for a `POST <api>/pricing` body — rejects junk before it reaches
|
|
527
686
|
* `AgentPricingStore.upsertModelPrice`. Not a full schema validator (the store adapter owns real
|
|
@@ -587,5 +746,7 @@ declare const DASHBOARD_API_PATH: unique symbol;
|
|
|
587
746
|
declare const DASHBOARD_APPROVAL_ACTOR_REF: unique symbol;
|
|
588
747
|
/** DI token carrying the console's `authorize` (and whether to warn when it is omitted). */
|
|
589
748
|
declare const DASHBOARD_CONSOLE_OPTIONS: unique symbol;
|
|
749
|
+
/** DI token: whether the agent's dev tools register into the dev-tools slot. */
|
|
750
|
+
declare const DASHBOARD_DEV_TOOLS: unique symbol;
|
|
590
751
|
|
|
591
|
-
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_GOVERNANCE_QUERIES, AGENT_PRICING_STORE, type ActorSpendRowWithLabel, AgentApiController, AgentApiModule, AgentDashboardModule, type AgentDashboardMountPathsOptions, type AgentDashboardOptions, AgentUiController, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, DASHBOARD_API_PATH, DASHBOARD_APPROVAL_ACTOR_REF, DASHBOARD_BASE_PATH, DASHBOARD_CONSOLE_OPTIONS, DashboardConsoleAccess, DashboardService, type LiveAgentEvent, type ReliabilityOverview, type RunDetailWithLabel, type SpendOverview, type ThreadActivityRowWithLabel, type ThreadDetailWithLabel, type ThreadSpendRowWithLabel, UseConsoleAuthorize, type WithActorLabel, agentDashboardMountPaths, authorizeByToken, normalizeConsoleResult, parsePriceInput, resolveConsoleAuthorize };
|
|
752
|
+
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_CONSOLE_ID, AGENT_DASHBOARD_CONFIG_ID, AGENT_GOVERNANCE_QUERIES, AGENT_PRICING_STORE, AVIARY_CONSOLES_SLOT, type ActorSpendRowWithLabel, AgentApiController, AgentApiModule, AgentConsoleRegistration, AgentConsolesController, AgentDashboardModule, type AgentDashboardMountPathsOptions, type AgentDashboardOptions, type AgentDevTool, AgentDevToolsRegistration, AgentUiController, type AviaryConsoleDecision, type AviaryConsoleEntry, type AviaryConsoleIcon, type AviaryConsoleRegistry, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, CONSOLE_PROBE_TIMEOUT_MS, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, DASHBOARD_API_PATH, DASHBOARD_APPROVAL_ACTOR_REF, DASHBOARD_BASE_PATH, DASHBOARD_CONSOLE_OPTIONS, DASHBOARD_DEV_TOOLS, DashboardConsoleAccess, DashboardService, type LiveAgentEvent, type ReliabilityOverview, type RunDetailWithLabel, type SpendOverview, type ThreadActivityRowWithLabel, type ThreadDetailWithLabel, type ThreadSpendRowWithLabel, UseConsoleAuthorize, type VisibleConsole, type VisibleConsoles, type WithActorLabel, agentDashboardMountPaths, agentDevTools, anyAuthorize, authorizeByToken, listVisibleConsoles, normalizeConsoleResult, parsePriceInput, registerAviaryConsole, resolveConsoleAuthorize };
|