/**
 * SessionId implementation for gemini-cli.
 *
 * Gemini assigns a UUID to each session (the `"sessionId"` field in its
 * on-disk session file). The adapter's SessionHandle binds to that
 * gemini-side session UUID. This primitive provides the binding both
 * directions.
 *
 * Mirrors openai-codex/observability/sessionId.ts: an in-memory bidirectional
 * map, populated when the adapter observes a session's id, plus a synthetic
 * handle for a known session id without a live process.
 */
import { sessionHandle } from '../../../types.js';
import { CapabilityFlag } from '../../../capabilities.js';
import { GEMINI_CLI_ID } from '../errors.js';
const handleToSession = new Map();
const sessionToHandle = new Map();
class GeminiCliSessionId {
    capability = CapabilityFlag.SessionId;
    async providerIdFor(session, _options) {
        return handleToSession.get(session) ?? null;
    }
    async handleFor(providerSessionId, _options) {
        return sessionToHandle.get(providerSessionId) ?? null;
    }
}
/** Bind a Gemini session UUID to a SessionHandle. */
export function bindGeminiSessionId(handle, sessionId) {
    handleToSession.set(handle, sessionId);
    sessionToHandle.set(sessionId, handle);
}
/** Look up the SessionHandle for a Gemini session UUID. */
export function handleForGeminiSession(sessionId) {
    return sessionToHandle.get(sessionId) ?? null;
}
/** Construct a session handle for a known gemini session without a live process. */
export function syntheticHandleForGeminiSession(sessionId) {
    return sessionHandle(`${GEMINI_CLI_ID}/session-${sessionId}`);
}
/** Construct a process-pid handle for a live one-shot spawn (used by HardKill). */
export function pidHandle(pid) {
    return sessionHandle(`${GEMINI_CLI_ID}/pid-${pid}`);
}
export function createSessionId() {
    return new GeminiCliSessionId();
}
/** Test-only: clear the in-memory session-id binding maps. */
export function _resetGeminiSessionIdMaps() {
    handleToSession.clear();
    sessionToHandle.clear();
}
//# sourceMappingURL=sessionId.js.map