import * as bullmq from 'bullmq'; import { Queue, RedisOptions } from 'bullmq'; import { l as AlertStore, n as AlertsOptions, b as AlertContactPoint, i as AlertRule, h as AlertPersistence, d as AlertContactPointPublic, W as WorkbenchCore, L as WorkbenchOptions } from './workbench-WdZriyFZ.js'; export { A as ActivityBucket, a as ActivityStatsResponse, c as AlertContactPointPreset, e as AlertDeliveryRecord, f as AlertEvent, g as AlertManager, j as AlertRuntimeStatus, k as AlertSeverity, m as AlertTrigger, C as CreateFlowChildRequest, o as CreateFlowRequest, D as DelayedJobInfo, p as DelayedSortField, q as DiscoveryMeta, F as FailingJobType, r as FlowNode, s as FlowSummary, H as HourlyBucket, J as JobInfo, t as JobLogsResponse, u as JobStatus, v as JobTags, M as MetricsResponse, O as OverviewStats, P as PaginatedResponse, Q as QueueInfo, w as QueueManager, x as QueueMetrics, R as RepeatableSortField, y as RunInfo, z as RunInfoList, B as RunSortField, S as SchedulerInfo, E as SearchResult, G as SlowestJob, I as SortDirection, K as SortOptions, T as TestJobRequest, N as WorkerInfo } from './workbench-WdZriyFZ.js'; declare function toPublicContactPoint(cp: AlertContactPoint): AlertContactPointPublic; interface CreateAlertStoreContext { /** Workbench-level Redis connection (auto-discovery) */ redis?: string | bullmq.RedisOptions; /** Connection from the first mounted BullMQ queue (BullMQ `ConnectionOptions`) */ queueConnection?: unknown; /** Key prefix for Redis storage; defaults to Workbench `prefix` or `"bull"` */ prefix?: string; } /** * Resolve the alert config store. Redis is the default when a connection exists. * Code-defined `contactPoints` / `rules` seed Redis on first run only. */ declare function createAlertStore(alerts: AlertsOptions, ctx: CreateAlertStoreContext): { store: AlertStore; persistence: AlertPersistence; }; declare class MemoryAlertStore implements AlertStore { private contactPoints; private rules; constructor(seed?: Pick); getContactPoints(): Promise; getContactPoint(id: string): Promise; createContactPoint(input: Omit): Promise; updateContactPoint(id: string, input: Partial>): Promise; deleteContactPoint(id: string): Promise; getRules(): Promise; getRule(id: string): Promise; createRule(input: Omit): Promise; updateRule(id: string, input: Partial>): Promise; deleteRule(id: string): Promise; } interface FetchHandlerResult { /** * Web-standard fetch handler. Accepts a `Request` and returns a `Response`. * Suitable for Elysia's `.mount(path, handler)`, Next.js route handlers, * Bun.serve, and any other web-standards-friendly runtime. */ fetch: (req: Request) => Promise; /** * The underlying `WorkbenchCore` instance. Exposed so adapters can read * config, query state, or wire up custom auth strategies. */ core: WorkbenchCore; } /** * Build a self-contained web-fetch handler for Workbench: API routes, * `/config`, static `/assets/:file`, an `index.html` catch-all with a * correct ``, CORS on `/api/*`, and optional Basic Auth on * everything. * * This is the engine shared by every fetch-native adapter (Elysia, Next.js). * Express and Fastify adapters use {@link buildRouteTable} directly instead. * * When `options.basePath` is set, the handler rewrites the incoming Request * URL to strip that prefix before routing. This makes the bridge work * uniformly for both fetch hosts: * * - `Elysia.mount()` already strips the prefix before calling us — the * strip below is a no-op in that case. * - Next.js App Router preserves the full path — the strip is what lets * our internal routes (`/api/*`, `/config`, …) match. */ declare function createFetchHandler(options: WorkbenchOptions | Queue[]): FetchHandlerResult; /** * Framework-agnostic HTTP method. */ type HttpMethod = "get" | "post" | "put" | "patch" | "delete"; /** * Normalized input passed to every handler. Adapters are responsible for * mapping their framework-specific request shape to this. */ interface HandlerInput { params: Record; query: Record; body?: unknown; } /** * Normalized output returned by every handler. Adapters serialize this * onto their framework-specific response object. */ interface HandlerResult { status: number; body: unknown; } /** * A framework-agnostic route handler. Closes over a `WorkbenchCore` and * takes a normalized request envelope. */ type Handler = (input: HandlerInput) => Promise; /** * A framework-agnostic route definition. * * `path` uses `:param` syntax compatible with Hono, Express, and Fastify. * Paths are relative to `/api` — adapters mount them under that prefix. */ interface RouteDef { method: HttpMethod; path: string; handler: Handler; } /** * Build the framework-agnostic route table for the Workbench API. * * Adapters iterate this list and register each route on their host framework. * Paths are relative to `/api`. */ declare function buildRouteTable(core: WorkbenchCore): RouteDef[]; /** * Discover BullMQ queues on a Redis connection by scanning for `:*:meta` * keys. Returns one `Queue` instance per discovered queue, each constructed * with a fresh clone of the connection options. * * Used by `WorkbenchCore.fromOptions` for the desktop client where the user * supplies a Redis URL but no explicit queue list. */ declare function discoverQueues(connection: string | RedisOptions, prefix?: string): Promise; interface RedisAlertStoreOptions { connection: string | RedisOptions; /** BullMQ-style prefix; keys are `${prefix}:workbench:alerts:*` */ prefix?: string; /** Imported once when Redis has no stored config yet */ seed?: Pick; } /** * Persists alert contact points and rules in the user's Redis. * Webhook URLs and rules created in the dashboard survive process restarts. */ declare class RedisAlertStore implements AlertStore { private readonly client; private readonly contactPointsKey; private readonly rulesKey; private readonly seed?; private seeded; constructor(options: RedisAlertStoreOptions); close(): Promise; private ensureSeeded; private readHash; getContactPoints(): Promise; getContactPoint(id: string): Promise; createContactPoint(input: Omit): Promise; updateContactPoint(id: string, input: Partial>): Promise; deleteContactPoint(id: string): Promise; getRules(): Promise; getRule(id: string): Promise; createRule(input: Omit): Promise; updateRule(id: string, input: Partial>): Promise; deleteRule(id: string): Promise; } declare function computeBasePath(pathname: string): string; /** * Resolve the dashboard's base path, preferring an explicit override. * * Adapters where the host framework preserves the mount prefix on the * incoming URL (Hono `.route()`, Express `req.originalUrl`, Next.js route * files) can rely on auto-detection. Adapters where the prefix is stripped * before the handler runs (Elysia `.mount()`) require the user to pass * `basePath` so the dashboard's HTML still references assets under the * correct prefix. */ declare function resolveBasePath(override: string | undefined, pathname: string): string; /** * Parse a `Basic` Authorization header and check it against the configured * credentials. Uses constant-time comparison to avoid leaking timing info * about which character mismatched. * * Returns `true` when credentials are valid, `false` otherwise. Both inputs * being undefined or empty count as a failed check — adapters should only * call this when `core.requiresAuth()` is true. */ declare function checkBasicAuth(authHeader: string | undefined, username: string, password: string): boolean; /** * Standard 401 response body + header for an unauthenticated Basic auth * request. Adapters use this when `checkBasicAuth` returns false. */ declare const BASIC_AUTH_CHALLENGE: { status: 401; headers: { "WWW-Authenticate": string; }; body: string; }; interface StaticAssetResult { status: 200 | 404; body: Buffer | null; contentType: string; } /** * Read a bundled UI asset from `UI_DIST_PATH/assets/`. * * Returns a uniform `{ status, body, contentType }` shape so each adapter * can serialize it onto its framework-native response without re-implementing * the file lookup or content-type sniffing. */ declare function serveStaticAsset(filename: string): StaticAssetResult; /** * Read a bundled UI file from `UI_DIST_PATH/`. * Used for root-level assets like `app-icon.svg` that Vite copies from `public/`. */ declare function serveUiFile(relativePath: string): StaticAssetResult; interface IndexHtmlResult { body: string; contentType: "text/html; charset=utf-8"; } /** * Read the bundled `index.html`, inject a `` matching the request's * mount path so client-side asset URLs resolve correctly, and return it. * * Falls back to a tiny "UI assets not found" stub when the core package has * not been built yet — useful for `bun run dev` against a fresh checkout. */ declare function renderIndexHtml(basePath: string, title: string): IndexHtmlResult; /** * Absolute filesystem path to the bundled UI assets (index.html + /assets). * Adapters that don't go through {@link createFetchHandler} serve static * files from this directory directly. */ declare const UI_DIST_PATH: string; export { AlertContactPoint, AlertContactPointPublic, AlertPersistence, AlertRule, AlertStore, AlertsOptions, BASIC_AUTH_CHALLENGE, type FetchHandlerResult, type Handler, type HandlerInput, type HandlerResult, type HttpMethod, type IndexHtmlResult, MemoryAlertStore, RedisAlertStore, type RouteDef, type StaticAssetResult, UI_DIST_PATH, WorkbenchCore, WorkbenchOptions, buildRouteTable, checkBasicAuth, computeBasePath, createAlertStore, createFetchHandler, discoverQueues, renderIndexHtml, resolveBasePath, serveStaticAsset, serveUiFile, toPublicContactPoint };