mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import type { SessionEntry } from "../config/sessions.js";
|
|
import { normalizeProviderId } from "./model-selection.js";
|
|
|
|
export function getCliSessionId(
|
|
entry: SessionEntry | undefined,
|
|
provider: string,
|
|
): string | undefined {
|
|
if (!entry) {
|
|
return undefined;
|
|
}
|
|
const normalized = normalizeProviderId(provider);
|
|
const fromMap = entry.cliSessionIds?.[normalized];
|
|
if (fromMap?.trim()) {
|
|
return fromMap.trim();
|
|
}
|
|
if (normalized === "claude-cli") {
|
|
const legacy = entry.claudeCliSessionId?.trim();
|
|
if (legacy) {
|
|
return legacy;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
export function setCliSessionId(entry: SessionEntry, provider: string, sessionId: string): void {
|
|
const normalized = normalizeProviderId(provider);
|
|
const trimmed = sessionId.trim();
|
|
if (!trimmed) {
|
|
return;
|
|
}
|
|
const existing = entry.cliSessionIds ?? {};
|
|
entry.cliSessionIds = { ...existing };
|
|
entry.cliSessionIds[normalized] = trimmed;
|
|
if (normalized === "claude-cli") {
|
|
entry.claudeCliSessionId = trimmed;
|
|
}
|
|
}
|