import { normalizeStr } from '../user-cache'

/**
 * Resolve the initial session id at CLI startup.
 *
 * Rules:
 * - If the CLI explicitly requests a session id, reuse it.
 * - Otherwise, return undefined (no session created until first message).
 *
 * Sessions should only be created when the user sends their first message,
 * not at CLI startup.
 */
export async function resolveStartupSessionId(
  opts: Readonly<{
    envSessionId?: string | undefined
  }>,
): Promise<string | undefined> {
  return normalizeStr(opts.envSessionId)
}
