/** * Caller-Binding Service (slice 020 — caller-keyed session binding). * * Each caller has its own on-disk binding file at * `.peaks/_runtime/callers/.json`. This service is the * single read/write surface for that file. Legacy single-file bindings * (`.peaks/_runtime/session.json` and `.peaks/.session.json`) remain * readable for one minor release (M1 / M4); the read path falls back * to them with a `legacy-fallback-used: true` flag. * * M2: legacy bindings resolve into a synthetic callerId of the form * `legacy-<8hex-of-sha256(outerSessionId)>`, with `claudeSessionId` * and `projectRoot` as fallback hash inputs. The synthetic id is * permanent and recognisable by the `legacy-` prefix. * * See `.peaks/_runtime/2026-06-09-session-8bfe7d/prd/source/caller-id-contract.md` * for the freeze-in contract. */ import { type CallerBinding } from './caller-id-types.js'; /** * On-disk location of the per-caller binding file. P4 invariant: * the `callers/.json` lives at `.peaks/_runtime/callers/`, * the same root as the per-peak session dirs. */ export declare function getCallerBindingFile(projectRoot: string, callerId: string): string; /** * On-disk location of the per-(peak, caller) active-skill file. D6: * one file per (peakSessionId, callerId) pair; two callers bound to * the same peak session never clobber each other. */ export declare function getActiveSkillFileForCaller(projectRoot: string, peakSessionId: string, callerId: string): string; /** * Resolve a stable, deterministic callerId for a legacy single-file * binding (M2). The hash input priority is: * * 1. `outerSessionId` (slice 018 stamped this on the per-peak * session.json for sessions created after the slice shipped). * 2. `claudeSessionId` (legacy field name on pre-018 presence * files; honour the read side so v1.2.x data does not lose its * binding). * 3. `projectRoot` (truly anonymous case: pre-018 sessions that * never recorded an outer / claude id). * * The synthetic id is `legacy-`. * 32 bits of entropy is enough for typical on-disk state * (R1: <100 legacy peak sessions per project; the test asserts * uniqueness across 1000 synthetic ids). */ export declare function synthesiseLegacyCallerId(input: string): string; /** * Read a per-caller binding file. Returns `null` if the file does * not exist, is malformed, or is for a different project (M1 back-compat * read returns the legacy file but only after the per-caller file is * absent). */ export declare function getCallerBinding(projectRoot: string, callerId: string): CallerBinding | null; /** * Write or update a per-caller binding file. The caller is responsible * for the binding object (callerId must match the file stem, peakSessionId * must be a valid session id, projectRoot is canonicalized). Idempotent: * re-writing the same callerId overwrites the file. */ export declare function setCallerBinding(projectRoot: string, callerId: string, binding: CallerBinding): void; /** * Enumerate the per-caller binding files under * `.peaks/_runtime/callers/`. Returns the parsed bindings plus the * raw filenames (so callers can list orphan / legacy files without * re-reading). */ export declare function listCallerBindings(projectRoot: string): CallerBinding[];