UNPKG

@dudousxd/nestjs-diagnostics

Version:

A standard convention for @dudousxd/nestjs-* libs to emit observability events over node:diagnostics_channel.

82 lines • 3.27 kB
import { type OnModuleDestroy, type OnModuleInit } from '@nestjs/common'; import { DiagnosticsExplorer } from './diagnostics.explorer.js'; import { type DiagnosticsModuleOptions } from './diagnostics.options.js'; /** The process-wide slot the Aviary dev MCP endpoint serves (`@dudousxd/nestjs-agent-mcp-server`). */ export declare const DEV_TOOLS_SLOT: unique symbol; /** One property of a {@link DevToolInputSchema}. */ export interface DevToolInputProperty { type: 'string' | 'number' | 'integer' | 'boolean' | 'array'; description?: string; enum?: readonly string[]; items?: { type: 'string'; }; minimum?: number; maximum?: number; } /** A dev tool's input: an object of scalar / enum / array-of-string properties. */ export interface DevToolInputSchema { type: 'object'; properties: Record<string, DevToolInputProperty>; required?: string[]; } /** What a tool's `run` receives besides its input. */ export interface DevToolCall { context: unknown; caller: { id: string; via: 'token' | 'session' | 'open'; }; limits: { maxRows: number; maxBytes: number; }; } /** One developer tool, as the dev-tools slot takes it. */ export interface DiagnosticsDevTool { name: string; kind: 'read' | 'action'; description: string; input: DevToolInputSchema; destructive?: boolean; available?(): boolean | Promise<boolean>; run(input: Record<string, unknown>, call?: DevToolCall): Promise<unknown>; } /** What the tools read about this process, at call time. */ export interface DiagnosticsDevToolsDeps { /** The `DiagnosticsModule` options (`default`, `role`, `transports`). */ options: () => DiagnosticsModuleOptions; /** The `@OnDiagnostic` listeners of this process. */ listeners: () => ReadonlyArray<{ id: string; method: string; matchers: ReadonlyArray<{ lib: string; event?: string | RegExp; }>; }>; } /** The diagnostics developer tools (all read-only): channels, listeners and recent events. */ export declare function diagnosticsDevTools(deps: DiagnosticsDevToolsDeps): DiagnosticsDevTool[]; /** Why {@link registerDiagnosticsDevTools} did or did not register. */ export type DevToolsRegistration = 'registered' | 'unsupported' | 'failed'; /** * Register the diagnostics tools into the dev-tools slot (created when absent), without an * `authorize`: the dev endpoint's `devTools.authorize` gates them. A hub that says it cannot gate a * lib without a console (`supports('endpoint-authorize')` is false) is left alone. Never throws. */ export declare function registerDiagnosticsDevTools(deps: DiagnosticsDevToolsDeps): { outcome: DevToolsRegistration; unregister?: () => void; }; /** Registers the diagnostics dev tools at module init and removes them at module destroy. */ export declare class DiagnosticsDevTools implements OnModuleInit, OnModuleDestroy { private readonly explorer; private readonly logger; private readonly options; private unregister; constructor(explorer: DiagnosticsExplorer, options?: DiagnosticsModuleOptions); onModuleInit(): void; onModuleDestroy(): void; } //# sourceMappingURL=dev-tools.d.ts.map