/** * Lets `pnpm action ` forward to an already-running local dev server * instead of opening the app database itself. * * The default local dev database is PGlite, which takes an exclusive * process-level lock on its data directory (see `db/client.ts`). Every CLI * action opens the database on its own, so running one while `pnpm dev` is * already holding that lock fails with "already owned by process N" before * the action even starts. When a dev server for the same database is * running, forward the call to it over loopback instead: the server already * holds the connection and the action registry, so the CLI never needs its * own. * * Protocol: the dev server writes `/.agent-native/dev-server.json` * (mode 0600) while listening, and the CLI reads it before touching the * database. The two sides only proceed when the file's `databaseKey` (a hash * of the resolved `DATABASE_URL`) matches the CLI's own — a stale file from a * different app/database in the same directory must never be trusted. The * bearer token in that file is also kept in the server's own process memory * (never persisted anywhere else) and compared with a timing-safe check on * every request. */ import type { ActionEntry } from "../agent/production-agent.js"; export declare const DEV_ACTION_ROUTE = "/_agent-native/dev/action"; export declare const DEV_DB_QUERY_ROUTE = "/_agent-native/dev/db-query"; export declare const DEV_DB_MIGRATE_ROUTE = "/_agent-native/dev/db-migrate"; export declare const DEV_ACTION_TOKEN_HEADER = "x-agent-native-dev-token"; export declare const DEV_ACTION_USER_HEADER = "x-agent-native-dev-user"; export declare const DEV_ACTION_ORG_HEADER = "x-agent-native-dev-org"; export { readDevActionDiscoveryFile } from "./dev-action-discovery.js"; export declare function hashDatabaseKey(databaseUrl: string): string; export declare function isLoopbackDevActionOrigin(origin: string): boolean; export declare function isValidDevActionHandoffUrl(value: unknown, loopbackAppUrl?: string | undefined): value is string; export declare function devActionHandoffUrl(result: unknown): string | undefined; export declare function getDevActionToken(): string | undefined; export declare function writeDevActionDiscoveryFile(appRoot: string, origin: string, databaseKey: string): void; export declare function removeDevActionDiscoveryFile(appRoot: string): void; export interface MountDevActionForwardRouteOptions { appId?: string; } export declare function mountDevActionForwardRoute(nitroApp: any, actions: Record, options?: MountDevActionForwardRouteOptions): void; export declare function mountDevDbQueryForwardRoute(nitroApp: any): void; export declare function mountDevDbMigrateForwardRoute(nitroApp: any): void;