import { applyReportRefresh, buildReportAdapterDescriptor, ReportAdapterDescriptor, ReportAdapterOptions, ReportBackgroundQueryTask, ReportDataQueryResult, ReportExportActionHost, ReportExportSnapshotBinding, ReportQueryOptions, ReportRefreshActionHost } from '@happyvertical/smrt-reports'; import { DataQueryRequest } from '@happyvertical/smrt-types'; import { DataSurfaceDefinition, DataSurfaceExecutionContext, DataSurfaceToolsOptions } from './data-surface.js'; import { PrincipalRun } from './execute-as-principal.js'; import { PrincipalTool } from './invoke-agent.js'; export declare const REPORT_QUERY_TOOL_SLUG = "reports.query"; export declare const REPORT_REFRESH_TOOL_SLUG = "reports.refresh"; export declare const REPORT_DRILLDOWN_TOOL_SLUG = "reports.drilldown"; export declare const REPORT_EXPORT_TOOL_SLUG = "reports.export"; export declare const REPORT_QUERY_FUNCTION_NAME = "reports-query"; export declare const REPORT_REFRESH_FUNCTION_NAME = "reports-refresh"; export declare const REPORT_DRILLDOWN_FUNCTION_NAME = "reports-drilldown"; export declare const REPORT_EXPORT_FUNCTION_NAME = "reports-export"; type ReportCtor = Parameters[0]; type ReportReadOptions = Omit; /** A server-authenticated browser command compatible with the chat bridge. */ export interface ReportDataSurfaceVisibleCommand { version: 1; commandId: string; identity: { surfaceId: string; kind: 'report'; }; expectedRevision: number; controlId: 'query'; payload: { request: DataQueryRequest; }; } /** Browser acknowledgement is required before a visible query succeeds. */ export interface ReportDataSurfaceVisibleAck { commandId: string; identity: { surfaceId: string; kind: 'report'; }; ok: boolean; revision?: number; reason?: string; } export interface ReportDataSurfaceVisibleHost { /** * The host must bind the command to an authenticated browser session and * await its acknowledgement. It must not use this command as authorization. */ send(command: ReportDataSurfaceVisibleCommand, context: { run: PrincipalRun; }): Promise; } export interface ReportDataSurfaceExportHost { /** The host captures an opaque immutable materialization binding. */ captureSnapshot(context: { run: PrincipalRun; descriptor: ReportAdapterDescriptor; result: ReportDataQueryResult; }): Promise; /** The returned host owns current authorization, audit, and queueing. */ actionHost(context: { run: PrincipalRun; }): ReportExportActionHost | Promise; } export interface ReportDataSurfaceRefreshHost { /** The returned host authorizes and audits against the live principal. */ actionHost(context: { run: PrincipalRun; }): ReportRefreshActionHost | Promise; /** Optional queue tuning that remains application-owned. */ options?: Omit[1], 'db' | 'host' | 'mode' | 'refreshAction'>; } export interface ReportDataSurfaceDefinition { /** Report model; never supplied by a model or browser argument. */ report: ReportCtor; /** Permission-catalog collection used for the shared read gate. */ collection: string; label?: string; description?: string; adapter?: ReportAdapterOptions; /** Application-owned collection/lifecycle seam for materialized reads. */ query?: (context: DataSurfaceExecutionContext) => ReportReadOptions | Promise; /** Background execution never receives principal or tenant in its task. */ enqueueBackgroundQuery?: (task: ReportBackgroundQueryTask, context: { run: PrincipalRun; }) => Promise<{ taskId: string; }>; visible?: ReportDataSurfaceVisibleHost; refresh?: ReportDataSurfaceRefreshHost; export?: ReportDataSurfaceExportHost; } export interface ReportDataSurfaceAuditEntry { action: 'query' | 'refresh' | 'drilldown' | 'export'; reportId: string; userId: string; tenantId: string | null; } export interface ReportDataSurfaceToolsOptions { reports: readonly ReportDataSurfaceDefinition[] | ((run: PrincipalRun) => readonly ReportDataSurfaceDefinition[] | Promise); /** Optional audit of agent-level handoffs; report action hosts audit mutations. */ audit?: (entry: ReportDataSurfaceAuditEntry) => void | Promise; /** Passed through to generic data.discover/data.inspect/data.query tools. */ dataSurface?: Omit; } export declare class ReportDataSurfaceVisibleError extends Error { constructor(reason?: string); } export declare class ReportDataSurfaceConfigurationError extends Error { constructor(message: string); } /** * Convert a report adapter into the safe generic catalog consumed by * data.discover/data.inspect/data.query. Generic agent queries are always * silent; browser changes require the explicit report query tool below. */ export declare function createReportDataSurfaceDefinition(definition: ReportDataSurfaceDefinition, run?: PrincipalRun, auditAvailable?: boolean): Promise; /** * Build generic report discovery/query tools plus report-only operational * tools. Every report is looked up from a server-owned catalog per live run. */ export declare function createReportDataSurfaceTools(options: ReportDataSurfaceToolsOptions): PrincipalTool[]; export {}; //# sourceMappingURL=report-data-surface.d.ts.map