import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
/** The single source of truth for the directory a spawn reads an agent's
 *  identity files from. Admin always reads `agents/admin`; a public agent
 *  reads `agents/<slug>` (Task 638 — keyed on the agent slug, not the role).
 *  The spawn composer (`system-prompt.ts`) and the standing reachability audit
 *  (`public-agent-reachability.ts`) both resolve through THIS function, so the
 *  directory the audit vouches for is byte-identical to the one the spawn
 *  reads — drift is impossible by construction, not by parallel literals. */
export function resolveAgentIdentityDir(accountDir, role, slug) {
    return join(accountDir, 'agents', role === 'public' ? slug : 'admin');
}
/** Whether the identity files a `role=public` spawn requires — IDENTITY.md,
 *  SOUL.md and KNOWLEDGE.md, each non-empty — are present in `dir`. The check
 *  order mirrors the composer's (IDENTITY → SOUL → KNOWLEDGE) so the reported
 *  first-failing file matches the composer's refusal reason. The audit runs
 *  this against `resolveAgentIdentityDir(accountDir, 'public', slug)`, so
 *  `present:true` means the spawn will not refuse on a missing identity file. */
export function publicIdentityFilesPresent(dir) {
    for (const name of ['IDENTITY.md', 'SOUL.md', 'KNOWLEDGE.md']) {
        const path = join(dir, name);
        if (!existsSync(path))
            return { present: false, detail: `${name}:ENOENT` };
        if (readFileSync(path, 'utf-8').length === 0)
            return { present: false, detail: `${name}:empty` };
    }
    return { present: true };
}
//# sourceMappingURL=agent-identity-locator.js.map