/** * Agent config resolver with project-level discovery. * * Fixes the single-machine multi-agent collision bug where two Claude Code * sessions on one machine share `~/.claude/mcp.json` and therefore share * one set of credentials. * * Resolution hierarchy (first match wins): * 1. `env.AGENTDROP_API_KEY` + `env.AGENTDROP_AGENT_ID` set * → use env credentials directly; optionally load extra fields from * `env.AGENTDROP_CONFIG_DIR/config.json` (agent_uuid, encryption keys). * 2. `env.AGENTDROP_CONFIG_DIR` set alone * → load the whole config from that directory. * 3. Project-level discovery: walk up from `cwd` looking for * `.agentdrop/config.json`. Stop at first match, home dir, or FS root. * 4. Global fallback: `~/.agentdrop/config.json`. * 5. Nothing found → throw a ConfigResolutionError with diagnostic info. * * The function is PURE: all FS + env access is dependency-injected so it * can be unit-tested without touching the real filesystem. */ export interface ResolvedAgentConfig { apiKey: string; agentId: string; agentUuid?: string; configDir?: string; source: "env" | "env-config-dir" | "project" | "project-ancestor" | "global"; } export interface ResolverEnv { AGENTDROP_API_KEY?: string; AGENTDROP_AGENT_ID?: string; AGENTDROP_AGENT_UUID?: string; AGENTDROP_CONFIG_DIR?: string; } export interface ResolverDeps { cwd: string; homeDir: string; env: ResolverEnv; exists: (path: string) => boolean; readJsonFile: (path: string) => Record | null; } export declare class ConfigResolutionError extends Error { searched: string[]; constructor(message: string, searched: string[]); } export declare function resolveAgentConfig(deps: ResolverDeps): ResolvedAgentConfig;