import { s as sigils, S as SIGIL_ROLES } from './nexus-schema2-BEd-ol6e.js';
import 'node:fs';
import 'node:path';
import './paths-2M_UxD_H.js';
import './dual-scope-db-ATrwq0LH.js';
import { e as eq } from './logger-ChCwlV5k.js';

new Set(SIGIL_ROLES);
/**
* Convert a DB row into the canonical {@link SigilCard} wire shape.
* Timestamps are stored as canonical TEXT ISO-8601 in the consolidated
* `nexus_sigils` table (T11578 · AC3) and surfaced as ISO 8601 strings on the
* wire contract. The `instanceof Date` branch defends against any legacy
* Date-typed value still in flight pre-exodus.
*
* @param row - Raw row from the `nexus_sigils` table.
* @returns Canonical {@link SigilCard} object.
*/
function rowToSigilCard(row) {
	return {
		peerId: row.peerId,
		cantFile: row.cantFile ?? null,
		displayName: row.displayName,
		role: row.role,
		systemPromptFragment: row.systemPromptFragment ?? null,
		capabilityFlags: row.capabilityFlags ?? null,
		createdAt: new Date(row.createdAt).toISOString(),
		updatedAt: new Date(row.updatedAt).toISOString()
	};
}
/**
* Fetch a single sigil by peer ID.
*
* Returns `null` when no matching row exists.
*
* @param nexusDb - Drizzle nexus database handle.
* @param peerId  - The peer identifier to look up.
* @returns The matching {@link SigilCard}, or `null`.
*/
async function getSigil(nexusDb, peerId) {
	const rows = await nexusDb.select().from(sigils).where(eq(sigils.peerId, peerId)).limit(1);
	if (rows.length === 0) return null;
	return rowToSigilCard(rows[0]);
}

export { getSigil as g };
//# sourceMappingURL=sigil2-DftKm7Um.js.map
