/** * Detect if we're running as a Bun compiled binary. * Bun binaries have import.meta.url containing "$bunfs", "~BUN", or "%7EBUN" (Bun's virtual filesystem path) */ export declare const isBunBinary: boolean; /** Detect if Bun is the runtime (compiled binary or bun run) */ export declare const isBunRuntime: boolean; export declare const isBundledNode: boolean; export type InstallMethod = "bun-binary" | "source" | "npm" | "pnpm" | "yarn" | "bun" | "unknown"; interface SelfUpdateCommandStep { command: string; args: string[]; display: string; } export interface SelfUpdateCommand extends SelfUpdateCommandStep { steps?: SelfUpdateCommandStep[]; } export type SelfUpdatePackageTarget = string | { packageName: string; installSpec?: string; }; export declare function detectInstallMethod(): InstallMethod; export declare function getSelfUpdateCommand(packageName: string, npmCommand?: string[], updatePackageTarget?: SelfUpdatePackageTarget): SelfUpdateCommand | undefined; export declare function getSelfUpdateUnavailableInstruction(packageName: string, npmCommand?: string[], updatePackageTarget?: SelfUpdatePackageTarget): string; export declare function getUpdateInstruction(packageName: string): string; /** * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md). * - For Bun binary: returns the directory containing the executable * - For Node.js: returns the package root containing package.json * - Ignores Bun binary metadata copied into dist/ when the package root is available */ export declare function findNodePackageDir(startDir: string): string; export declare function getPackageDir(): string; /** * Get path to built-in themes directory (shipped with package) * - For Bun binary: theme/ next to executable * - For Node.js (dist/): dist/modes/interactive/theme/ * - For source (src/): src/modes/interactive/theme/ */ export declare function getThemesDir(): string; /** * Get path to HTML export template directory (shipped with package) * - For Bun binary: export-html/ next to executable * - For Node.js (dist/): dist/core/export-html/ * - For source (src/): src/core/export-html/ */ export declare function getExportTemplateDir(): string; /** Get path to package.json */ export declare function getPackageJsonPath(): string; /** Get path to README.md */ export declare function getReadmePath(): string; /** Get path to docs directory */ export declare function getDocsPath(): string; /** Get path to examples directory */ export declare function getExamplesPath(): string; /** Get path to CHANGELOG.md */ export declare function getChangelogPath(): string; /** * Get path to built-in interactive assets directory. * - For Bun binary: assets/ next to executable * - For Node.js (dist/): dist/modes/interactive/assets/ * - For source (src/): src/modes/interactive/assets/ */ export declare function getInteractiveAssetsDir(): string; /** * Get path to bundled default config directory (shipped with package). * Holds bundled defaults. settings.json is copied on first run; models.json is loaded directly. */ export declare function getBundledDefaultsDir(): string; /** * Get path to bundled built-in extensions directory (shipped with package). * Loaded directly via additionalExtensionPaths at boot (not copied into the * user agent dir) — same hook as CLI --extension. .ts ships as-is (jiti loads it). * - For Bun binary: extensions/ next to executable * - For Node.js (dist/): dist/extensions/ * - For tsx (src/): src/extensions/ */ export declare function getBundledExtensionsDir(): string; /** * Get path to bundled built-in themes directory (shipped with package). * Loaded directly via additionalThemePaths at boot. */ export declare function getBundledThemesDir(): string; /** * Get path to bundled built-in skills directory (shipped with package). * Loaded directly via additionalSkillPaths at boot. */ export declare function getBundledSkillsDir(): string; /** Get path to a bundled interactive asset */ export declare function getBundledInteractiveAssetPath(name: string): string; /** Called by the Bun entry with the path of the QuickJS wasm file embedded in the compiled executable. */ export declare function setEmbeddedQuickJSWasmPath(path: string): void; /** * Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. Resolved once so the * compiled module cached per path keeps working after an update removes this install (#10439). */ export declare function getQuickJSWasmPath(): string; /** Resolve the codemode worker entry for a release runtime. */ export declare function resolveCodemodeWorkerSpecifier(runtime: "bun-binary" | "bundled-node" | "unbundled", moduleUrl: string): string | URL | undefined; /** * Get the codemode worker entry, or undefined to use the worker that ships next to pi-codemode. * The Bun and Node release builds both pass the worker as an extra entrypoint. */ export declare function getCodemodeWorkerSpecifier(): string | URL | undefined; export type InstallChange = { kind: "updated"; version: string; } | { kind: "removed"; }; /** * Detect that the package this process runs from changed on disk, for example after `pi update` * in another terminal. Code loaded on demand can then be missing or from another version. * * Checks the package.json read at startup. Resolving it again would walk up past a deleted install * and could find an unrelated package.json, such as one in the home directory. */ export declare function detectInstallChange(packageJsonPath?: string | undefined): InstallChange | undefined; export declare const PACKAGE_NAME: string; export declare const APP_NAME: string; export declare const APP_TITLE: string; export declare const CONFIG_DIR_NAME: string; export declare const VERSION: string; /** Upstream Pi platform version (the pinned pi-ai release). pi.dev gates model catalogs on this, not on VERSION. */ export declare const PI_PLATFORM_VERSION: string; export declare const ENV_AGENT_DIR: string; export declare const ENV_SESSION_DIR: string; export declare function expandTildePath(path: string): string; /** Get the share viewer URL for a gist ID. */ export declare function getShareViewerUrl(gistId: string): string; /** Get the agent config directory (e.g., ~/.selesai/agent/) */ export declare function getAgentDir(): string; /** Get path to user's custom themes directory */ export declare function getCustomThemesDir(): string; /** Get path to models.json */ export declare function getModelsPath(): string; /** Get path to auth.json */ export declare function getAuthPath(): string; /** Get path to settings.json */ export declare function getSettingsPath(): string; /** Get path to tools directory */ export declare function getToolsDir(): string; /** Get path to managed binaries directory (fd, rg) */ export declare function getBinDir(): string; /** Get path to prompt templates directory */ export declare function getPromptsDir(): string; /** Get path to sessions directory */ export declare function getSessionsDir(): string; /** Get path to debug log file */ export declare function getDebugLogPath(): string; /** * Marker file written once first-time onboarding completes. Decouples the * first-run dialog gate from settings.json existence so that bootstrapping a * bundled default settings.json does not suppress the dialog. */ export declare function getFirstRunMarkerPath(agentDir?: string): string; /** * Mark first-run onboarding as complete. Safe to call repeatedly. */ export declare function markFirstRunComplete(agentDir?: string): void; /** * Ensure the agent dir and standard subdirs exist (mode 0o700 for privacy). * Safe to call on every startup; no-op when dirs already exist. */ export declare function ensureAgentDir(agentDir?: string): void; /** * Seed a default config file from the bundled defaults dir if it does not yet * exist. Never overwrites an existing user file. Returns the destination path * when a seed was written, undefined when the file already existed or the * bundled source is missing. */ export declare function seedDefaultConfigFile(destPath: string, bundledName: string, bundledDefaultsDir?: string): string | undefined; /** * Add bundled subagent defaults to an existing user settings file when that * top-level setting is absent. The file is modified with a minimal textual * insertion, so unrelated settings (including their formatting and unknown * keys) are preserved byte-for-byte. Invalid or non-object JSON, or a user * file that already configures `subagents`, is left untouched. */ export declare function seedMissingSubagentSettings(destPath: string, bundledDefaultsDir?: string): boolean; /** * Add the bundled `graft.deepModel` default to an existing user settings file. * * The `graft` namespace may already exist without that leaf (graft is configured * field-by-field), so a present `graft` object is merged rather than skipped. A * user-provided `deepModel` is never overwritten. Returns true when the file was * rewritten. */ export declare function seedMissingGraftSettings(destPath: string, bundledDefaultsDir?: string): boolean; /** * Add the bundled `defaultTools` selection (which enables `codemode`) to an existing user * settings file that does not set `defaultTools` at all. Settings files created before the * bundled default existed would otherwise never get it. A user-provided `defaultTools`, even an * empty one or one with only `-name` entries, is never touched. The file is modified with a * minimal textual insertion, so other settings keep their formatting. Returns true when the file * was rewritten. */ export declare function seedMissingDefaultToolsSettings(destPath: string, bundledDefaultsDir?: string): boolean; /** * Bundled extensions load directly from the installed package. Do not copy them * into the user's agent dir, otherwise startup discovers both copies and tool * registration conflicts with itself. * Remove files copied by older releases only when they are byte-identical to * bundled files, so user-edited extensions survive. */ export declare function seedDefaultExtensions(agentDir: string, bundledExtensionsDir?: string): string[]; /** * Seed bundled built-in skills into the user's agent dir/skills. * The bundled copy is authoritative: existing user copies are overwritten so a * stale installed copy never shadows the shipped skill. Retired bundled skills * are removed; other user-only skills are left untouched. Returns the list of * destination paths that were written. */ export declare function seedDefaultSkills(agentDir: string, bundledSkillsDir?: string): string[]; /** * Bundled themes load directly from the installed package via * additionalThemePaths. Do not copy them into the user's agent dir, otherwise * startup discovers both copies and every theme reports a name collision. * Remove files copied by older releases only when they are byte-identical to * bundled files, so user-edited themes survive. */ export declare function seedDefaultThemes(agentDir: string, bundledThemesDir?: string): string[]; /** * Run bootstrap for the agent dir: ensure directories, seed a missing * settings.json, and add missing bundled subagent, graft, and default-tools settings. Idempotent — safe * on every startup. * Bundled models load package-locally; copying them would expose internal * providers as user config. Bundled extensions also stay package-local. */ export declare function bootstrapAgentDir(agentDir?: string): void; export {};