/** * Internal registry of installed runtimes (installed_runtimes.json). * Source of truth for what the plugin should run; read on boot, updated by CLI/RPC install/uninstall. * Each entry uses exactly one of runtimeYamlPath or runtimeYamlContent (see InstalledRuntimeEntry). * Migrates from installed_recipes.json and installed_strategies.json on first read if present. */ export declare const REGISTRY_FILENAME = "installed_runtimes.json"; export interface InstalledRuntimeEntry { id: string; runtimeYamlPath?: string; runtimeYamlContent?: string; /** Major version extracted from YAML version field at install time. */ schemaVersion?: number; /** Wallet address from strategy.wallet, stored at install time. */ wallet?: string; /** * Recipe directory, stored for content-installed runtimes so a gateway * restart can resolve an external scanner's relative `path: ./` (the CLI * sends YAML content, not the path, which would otherwise drop the dir). */ runtimeYamlDir?: string; } export interface InstalledRuntimeRegistry { version: number; runtimes: InstalledRuntimeEntry[]; } /** @deprecated Use InstalledRuntimeEntry */ export type InstalledRecipeEntry = InstalledRuntimeEntry; /** @deprecated Use InstalledRuntimeRegistry */ export type InstalledRecipesRegistry = InstalledRuntimeRegistry; /** @deprecated Use InstalledRuntimeEntry */ export type InstalledStrategyEntry = InstalledRuntimeEntry; /** @deprecated Use InstalledRuntimeRegistry */ export type InstalledStrategiesRegistry = InstalledRuntimeRegistry; /** * Sanitize a string for use as registry id: replace non-alphanumeric with underscore, truncate. */ export declare function sanitizeId(candidate: string): string; /** * Derive a human-readable, globally-unique runtime id from the YAML name and wallet. * Format: `-<4-char hash>` (e.g. "fox-strategy-a7k2"). * The hash is derived from name + wallet + timestamp + monotonic counter, * so re-creating a runtime with the same name always produces a distinct id * (no archive collisions). */ export declare function deriveRuntimeId(name: string, wallet: string): string; /** @deprecated Use deriveRuntimeId */ export declare const deriveRecipeId: typeof deriveRuntimeId; /** * Derive default id from file path (basename without extension). * @deprecated Prefer deriveRuntimeId(name, wallet) which uses the YAML name field. */ export declare function deriveIdFromPath(filePath: string, existingIds: string[]): string; /** * Derive default id for content-only entry: content-0, content-1, ... */ export declare function deriveIdForContent(existingIds: string[]): string; /** * Read the installed runtimes registry from stateDir. * Migrates from installed_recipes.json or installed_strategies.json if present. * Missing or invalid file returns { version: 1, runtimes: [] }. */ export declare function readRegistry(stateDir: string): Promise; /** * Write the registry atomically (temp file then rename). */ export declare function writeRegistry(stateDir: string, data: InstalledRuntimeRegistry): Promise; export declare function withRegistryLock(stateDir: string, fn: () => Promise): Promise; /** * Validate that an entry has exactly one of runtimeYamlPath or runtimeYamlContent and id is safe. */ export declare function validateEntry(entry: InstalledRuntimeEntry): { ok: true; } | { ok: false; error: string; }; /** * Check if an id is already present in the registry. */ export declare function hasId(registry: InstalledRuntimeRegistry, id: string): boolean; /** * Find a registry entry by wallet address. * * Case-INSENSITIVE, because a wallet address is one margin account however it is spelled: the * registry stores `strategy.wallet` verbatim from the YAML, so a checksummed address installed by * hand and the lowercase form the backend reports are the same wallet. An exact compare here * failed OPEN at both call sites that matter — the install gate would let a second runtime land on * a wallet it could not see, and deploy's dead-row cleanup would leave the stale row in place and * reinstall beside it. The other wallet compares on this path already fold case * (`installRuntimeCore`'s ownership check, deploy's `registryFindById` never-reuse-an-old-wallet). */ export declare function findByWallet(registry: InstalledRuntimeRegistry, wallet: string): InstalledRuntimeEntry | undefined; //# sourceMappingURL=strategy-registry.d.ts.map