/** * The root of Fjall's per-user state — credentials, caches, journals, logs. * * A dependency-free leaf module, like its project-local sibling * `configPaths.ts`. That one names state that lives beside a checkout; this * one names state that lives beside the *operator*. * * ## Why the Node built-ins are resolved per call, not statically imported * * This module is re-exported by the root barrel, and the webapp imports that * barrel from BROWSER code (130+ client files, `maskSensitiveOutput` above * all). A browser bundler that cannot tree-shake — Vite's dev server serving * the package raw — evaluates every barrel module, and a static * `import { homedir } from "node:os"` throws at evaluation time against the * browser-external stub, killing hydration on every page. `process * .getBuiltinModule` (Node ≥ 22.3.0 — the engines floor every published * package declares) is the runtime-agnostic form: nothing is referenced at * module scope, and the functions below only ever run in Node. The * barrel-reachability test * (`__tests__/barrelBrowserSafety.test.ts`) pins the class for the whole * package. * * ## Why this is a seam and not a constant * * `~/.fjall/auth.json` holds exactly one API key, so the CLI can be logged * into exactly one organisation at a time. Anyone who works across two — a * platform operator with a production org and a sandbox, an agency with a * client per org, or us dogfooding a fresh signup against our own production * account — has to overwrite the credential to switch, and overwrite it back * to switch again. There is no verb for that and no warning when it happens: * `login` simply replaces the file. Concurrent shells make it worse, because * the second login silently re-aims the first shell's next command. * * `FJALL_CONFIG_DIR` makes the whole state root relocatable, so two * organisations are two directories and a shell decides which one it is in: * * ```sh * FJALL_CONFIG_DIR=~/.fjall-sandbox fjall login * ``` * * It is deliberately the *root*, not a per-file override. Credentials, the * connection cache, the org-config cache, the app-id cache and the drift * journals are all keyed to one organisation; letting them be redirected * independently would allow a coherent-looking mix of two. */ /** Env var relocating the whole state root. Absolute or relative to cwd. */ export declare const FJALL_CONFIG_DIR_ENV = "FJALL_CONFIG_DIR"; /** Directory name under `$HOME` when the env var is unset. */ export declare const FJALL_HOME_DIRNAME = ".fjall"; /** * Absolute path to the state root. * * Resolved on every call rather than captured at module load: the env var is * read by a command that may have been imported long before the process * decided which organisation it is acting for, and a module-level `const` * would freeze the answer at import time — which is exactly why the three * caches that used to capture it could never have honoured an override. * * An empty value is treated as unset. Shells, CI runners and compose * env-files all export `X=` freely, and a path is a *data* env var: the empty * string is invalid input, not a request to write state into `/`. */ export declare function fjallHomeDir(): string; /** A path inside the state root — `fjallStatePath("auth.json")`. */ export declare function fjallStatePath(...segments: string[]): string; /** * The credential file. * * Named here rather than at each reader because there are two of them in * different packages — the CLI writes it on `login`, the MCP server reads it * to answer a tool call — and they used to agree about the path only by * coincidence, each joining `homedir()` with the same two string literals. * Nothing would have failed at typecheck if one of them had moved. */ export declare const FJALL_CREDENTIALS_FILENAME = "auth.json"; export declare function fjallCredentialsPath(): string; /** * Env var relocating logs alone, without moving the rest of the state root. * * The narrower override, and it wins: logs are routinely redirected on their * own — a CI artefact path, a tmpdir in tests — by someone who does not mean * to move the credential alongside them. */ export declare const FJALL_LOG_DIR_ENV = "FJALL_LOG_DIR"; /** * The log directory. * * Two packages write here — the CLI's file logger and the infrastructure * package's validation JSONL — and they each used to re-implement this exact * precedence. Nothing linked them: a change to one would have split the log * stream in half with nothing failing at typecheck. */ export declare function fjallLogDir(): string;