import { type Credentials } from "../internal/credentials.js"; interface DevOptions { port?: string; quiet?: boolean; verbose?: boolean; logLevel?: string; /** * Acknowledge that `lobu run` is about to point at a shared/non-local * Postgres inherited from the shell. Required when the project's own .env * doesn't pin DATABASE_URL — protects against the silent footgun of running * "local dev" against a teammate's tailnet DB or, worse, prod. */ unsafeSharedDb?: boolean; } export type LocalSignInFailureStage = "server_unreachable" | "local_init_http" | "local_init_payload" | "context_setup"; export type LocalSignInResult = { ready: true; localOrgSlug?: string; } | { ready: false; skipped: "external_backend"; } | { ready: false; stage: LocalSignInFailureStage; detail?: string; }; export interface LocalSignInDependencies { waitForReachable: (url: string) => Promise; fetchImpl: (url: string, init?: RequestInit) => Promise; addContextImpl: (name: string, url: string, server?: { lifecycle?: "managed" | "external"; }) => Promise; saveCredentialsImpl: (credentials: Credentials, contextName: string) => Promise; setActiveOrgImpl: (slug: string, contextName: string) => Promise; inspectContextImpl: (contextName: string) => Promise<{ url: string; lifecycle?: "managed" | "external"; } | undefined>; getCurrentContextNameImpl: () => Promise; setCurrentContextImpl: (contextName: string) => Promise; } /** * Treat any DATABASE_URL whose host isn't loopback as "shared". The check * is intentionally crude — anything resolvable from the network counts, * including tailnet (`*.ts.net`), private IPs, and prod hostnames. * * Exported for unit tests; the safety gate in `devCommand` is the consumer. */ export declare function isSharedDatabaseUrl(databaseUrl: string): boolean; /** * `DATABASE_URL` is the single backend selector: * - a `postgres://` / `postgresql://` URL → connect to an external Postgres * - anything else (a filesystem path, optionally `file:`-prefixed) → boot a * local embedded Postgres with its data under `/.lobu/pgdata` * * `lobu run` defaults the path to the user's home dir when nothing is set, so a * bare `lobu run` still works (data at `~/.lobu/pgdata`). The runtime itself * always receives an explicit path — the default is injected here, at the CLI * frontend, exactly like the menubar app supplies its own path. */ export declare function isExternalDatabaseUrl(databaseUrl: string): boolean; /** * Resolve the embedded data ROOT from a path-form DATABASE_URL: strips a * leading `file:` and expands a leading `~`. The Postgres cluster lives at * `/.lobu/pgdata` (see embedded-runtime.ts). */ export declare function resolveEmbeddedDataRoot(databaseUrl: string): string; /** * Decide whether `lobu run` must refuse to boot because the EFFECTIVE * DATABASE_URL points at a shared/non-local DB the project never opted into. * * `mergedEnv` gives the shell higher precedence than the project's `.env`, so * the project only "owns" the URL when its `.env` value is the exact one that * survived the merge. Gating on project-`.env` *presence* alone (the old bug) * let a shared/prod shell URL win silently whenever `.env` also happened to * define its own DATABASE_URL — re-pointing "local dev" at shared/prod data. * * Exported for unit tests; the safety gate in `devCommand` is the consumer. */ export declare function shouldRefuseSharedDatabaseUrl(input: { effectiveDatabaseUrl: string | undefined; projectEnvDatabaseUrl: string | undefined; unsafeSharedDb: boolean | undefined; }): boolean; /** * `lobu run` — start the embedded Lobu stack. * * `DATABASE_URL` selects the backend (see `isExternalDatabaseUrl`): a * `postgres://` URL connects to an external Postgres; a filesystem path boots a * local embedded Postgres rooted there. Unset defaults to an embedded DB at * `~/.lobu/pgdata`. */ export declare function devCommand(cwd: string, options?: DevOptions): Promise; /** * Whether `lobu run` should auto-apply the project. True only when: * - the backend is embedded (never auto-mutate an external/prod DB), AND * - local sign-in registered and credentialed the selected context, AND * - the project actually has a `lobu.config.ts` to apply. */ export declare function shouldAutoApplyLocalProject(opts: { mode: "external" | "embedded"; localContextReady: boolean; hasLobuConfig: boolean; }): boolean; /** * After `lobu run` boots an embedded backend, push the project's `lobu.config.ts` * into the local DB so the agent the user just scaffolded is immediately usable * without a separate `lobu apply`. The apply is pinned to the embedded URL and * bootstrap org rather than relying on the globally active context. * * Best-effort: a project with nothing to apply, or a transient failure, must * never crash the running server. The apply graph (esbuild + connector-worker * + SDK, pulled in by apply-cmd) is imported lazily so it stays out of * `lobu run`'s module-load path — see the dynamic-import allow-list in * AGENTS.md. */ export declare function autoApplyLocalProject(cwd: string, gatewayUrl: string, localOrgSlug?: string, applyImpl?: (opts: { cwd: string; yes: boolean; url: string; org?: string; }) => Promise): Promise; /** * Walk up from `startDir` looking for the Lobu monorepo workspace root: a * `package.json` with a non-empty `workspaces` field AND a * `packages/server/src/index.ts` underneath it. Returns the absolute * path, or `null`. (Mirrors `@lobu/server`'s `findEnclosingMonorepoRoot` — kept * local so the CLI doesn't take a dep on the server package.) */ export declare function findEnclosingMonorepoRoot(startDir: string): string | null; export declare function announceLocalSignIn(gatewayUrl: string, embedded: boolean, dependencies?: LocalSignInDependencies): Promise; export declare function getLocalSignInWarning(result: LocalSignInResult, options: { embedded: boolean; hasLobuConfig: boolean; }): string | null; export declare function waitForServerReachable(url: string, timeoutMs?: number): Promise; export declare function isPortFree(port: number): Promise; export {}; //# sourceMappingURL=dev.d.ts.map