/** * refactored in slice 4.0.8 to be adapter-owned per RD §5 + C1). * * As of 4.0.8 the per-platform `PLATFORM_FALLBACKS` table is DELETED. * Per the user-confirmed product decision (2026-08-03, C1): * * "Every caller resolution MUST go through the active IDE adapter. * Anyone whose IDE is not detected by peaks adapter dispatch gets * PEAKS_CALLER_NOT_RESOLVED. This is the desired product contract * (vendor-neutral)." * * Resolution order (4.0.8): * 1. `opts.flagValue` (per-invocation `--caller-id ` override) → * a vendor-neutral flag short-circuits BEFORE the adapter. * 2. `opts.envOverride ?? process.env.PEAKS_CALLER_ID` (vendor-neutral * env override) → also short-circuits BEFORE the adapter, so CI * / scripted usage can still pin a caller id without an adapter. * The trimmed value MUST match `CALLER_ID_REGEX` or we throw. * 3. The active IDE adapter's `resolveCallerId(env)` method. The * adapter owns its priority rules; vendor signal lives ONLY in * the adapter. The adapter throws `PEAKS_CALLER_NOT_RESOLVED` * (via `(err as { code: string }).code`) on unsupported / missing * resolution. We surface the same code on the boundary. * 4. → **D2 fires**: throw `CallerIdError(EX_USAGE, 'none', ...)` * after surfacing `PEAKS_CALLER_NOT_RESOLVED` upstream. * * The function is synchronous and pure. It does NOT touch the * filesystem, does NOT read any caller binding file, and does NOT * mutate state. The caller (a CLI command, a service, a test) decides * what to do with the resolved id. * * for the slice 4.0.8 contract. */ import { CallerIdError, type CallerProjection, type CallerProjectionSource } from './caller-id-types.js'; export { CallerIdError }; export type { CallerProjection, CallerProjectionSource }; export interface ResolveCallerIdOptions { /** * The `--caller-id ` flag value (per-invocation override). * Priority level 1: flag wins. Validated against CALLER_ID_REGEX. */ flagValue?: string; /** * Override for the `PEAKS_CALLER_ID` environment variable. Priority * level 2: env wins. Defaults to `process.env.PEAKS_CALLER_ID`. The * override exists so tests can run without mutating process.env. */ envOverride?: string; /** * The env object to read. Defaults to `process.env`. Exists so * tests can drive Level 3 (adapter) without mutating process.env. */ env?: NodeJS.ProcessEnv; /** * The IDE id to use for adapter-driven resolution. Defaults to * `detectInstalledIde(process.cwd())` or `'claude-code'` when no IDE * is detected. Tests can pin the adapter via this option. */ ideId?: string; /** * The project root for IDE auto-detection. Defaults to * `process.cwd()`. Passed through to `detectInstalledIde`. */ projectRoot?: string; } /** * Resolve the calling process's callerId per the 4.0.8 adapter-owned * contract. See file header for the full priority table. On failure * (no flag, no env, adapter threw PEAKS_CALLER_NOT_RESOLVED), throws * a `CallerIdError(EX_USAGE, 'none', ...)`. * * @example * resolveCallerId({ flagValue: 'foo-bar' }) // → 'foo-bar' * resolveCallerId({ envOverride: 'baz' }) // → 'baz' * resolveCallerId({ env: { CLAUDE_CODE_SESSION_ID: 'sid-123' } }) * // → 'sid-123' * resolveCallerId() // → throws CallerIdError (EX_USAGE) */ export declare function resolveCallerId(opts?: ResolveCallerIdOptions): string; /** * Projected resolution for the 4.0.8 contract. Returns a typed * `CallerProjection` envelope so consumers can read the adapter id + * callerId + (optional) workflowId / graphRef in one call. * * Pure: does not touch the filesystem, does not consult the lease or * the index. The `workflowId` / `graphRef` fields stay `null` here; * callers that need the full binding should resolve the lease via * `presence-lease-service` after the caller id is in hand. */ export declare function resolveCallerProjection(opts?: ResolveCallerIdOptions): CallerProjection;