import { parseJwt } from "../../util/parse-jwt.js";
//* Get or create a ContextId for the current conversation context. */
export function getContextId(clark, services, name = "main") {
    const userId = parseJwt(clark.context.jwt)?.userId;
    if (!userId) {
        throw new Error("Cannot get context ID: JWT is missing or has no userId. " +
            "This indicates a bug - JWT should be set in AgentPlanning and preserved across state transitions.");
    }
    return {
        appId: services.applicationId,
        userId,
        name,
    };
}
//# sourceMappingURL=context-id.js.map