import { type AccessContext } from "../sharing/access.js"; export declare const MAX_PROGRAM_ROWS = 10000; export declare const MAX_PROGRAM_RESULT_BYTES: number; export declare const MAX_ACTIVE_PROGRAMS_PER_APP = 200; export declare const MIN_REFRESH_TTL_MS = 60000; export declare const dataProgramsStore: import("../db/store-registry.js").Store; export declare function ensureDataProgramTables(): Promise; export declare function registerDataProgramsShareable(): void; export declare function _resetDataProgramInitPromiseForTests(): void; export type DataProgramRefreshMode = "manual" | "ttl"; export interface DataProgramRow { id: string; appId: string; name: string; title: string; description: string; code: string; paramsSchema: string | null; defaultParams: string | null; outputColumns: string | null; refreshMode: DataProgramRefreshMode; refreshTtlMs: number; background: boolean; createdAt: string; updatedAt: string; archivedAt: string | null; ownerEmail: string; orgId: string | null; visibility: "private" | "org" | "public"; } export interface UpsertDataProgramInput { id?: string; appId: string; name: string; title: string; description?: string; code: string; paramsSchema?: string | null; defaultParams?: string | null; outputColumns?: string | null; refreshMode?: DataProgramRefreshMode; refreshTtlMs?: number; background?: boolean; ownerEmail: string; orgId?: string | null; } export declare function upsertDataProgram(input: UpsertDataProgramInput): Promise; /** * Look up a program by id. Pass `appId` to scope the lookup to the calling * app — in a shared-database multi-app deployment, a program created in one * app must not be readable/runnable from another app's agent chat just * because the caller otherwise has row-level (owner/org/share) access to it. * `appId` is optional only because a handful of internal call sites * (`upsertDataProgram`'s existing-row lookup, tests) look up a program they * already know is scoped correctly by construction. */ export declare function getDataProgram(id: string, appId?: string, ctx?: AccessContext): Promise; export declare function getDataProgramByName(appId: string, name: string, ownerEmail: string): Promise; export interface ListDataProgramsOptions { includeArchived?: boolean; } export declare function listDataPrograms(appId: string, ctx: AccessContext, options?: ListDataProgramsOptions): Promise; export declare function archiveDataProgram(id: string, appId?: string, ctx?: AccessContext): Promise; export type DataProgramRunStatus = "queued" | "running" | "succeeded" | "failed" | "timed_out"; export interface DataProgramRunRow { id: string; programId: string; paramsHash: string; paramsJson: string; status: DataProgramRunStatus; rowsJson: string | null; schemaJson: string | null; truncated: boolean; rowCount: number; byteSize: number; errorCode: string | null; errorMessage: string | null; logsTail: string | null; executionId: string | null; triggeredBy: string; startedAt: number; finishedAt: number | null; durationMs: number | null; } export interface RecordDataProgramRunInput { programId: string; paramsHash: string; paramsJson: string; status: DataProgramRunStatus; rowsJson?: string | null; schemaJson?: string | null; truncated?: boolean; rowCount?: number; byteSize?: number; errorCode?: string | null; errorMessage?: string | null; logsTail?: string | null; executionId?: string | null; triggeredBy: string; startedAt?: number; finishedAt?: number | null; durationMs?: number | null; keep?: number; } export declare function recordDataProgramRun(input: RecordDataProgramRunInput): Promise; export interface UpdateDataProgramRunInput { status?: DataProgramRunStatus; rowsJson?: string | null; schemaJson?: string | null; truncated?: boolean; rowCount?: number; byteSize?: number; errorCode?: string | null; errorMessage?: string | null; logsTail?: string | null; executionId?: string | null; finishedAt?: number | null; durationMs?: number | null; keep?: number; } export declare function updateDataProgramRun(runId: string, updates: UpdateDataProgramRunInput): Promise; export declare function getLatestSuccessfulRun(programId: string, paramsHash: string): Promise; export declare function getLatestRun(programId: string, paramsHash: string): Promise; export declare function getActiveRun(programId: string, paramsHash: string): Promise; export declare function pruneDataProgramRuns(programId: string, paramsHash: string, keep?: number): Promise;