refactor: normalize main session key handling
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
loadConfig,
|
||||
STATE_DIR_CLAWDBOT,
|
||||
} from "../config/config.js";
|
||||
import { normalizeAgentId } from "../routing/session-key.js";
|
||||
import { normalizeAgentId, normalizeMainKey } from "../routing/session-key.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
import {
|
||||
@@ -1045,7 +1045,7 @@ export async function resolveSandboxContext(params: {
|
||||
if (!rawSessionKey) return null;
|
||||
const agentId = resolveAgentIdFromSessionKey(rawSessionKey);
|
||||
const cfg = resolveSandboxConfigForAgent(params.config, agentId);
|
||||
const mainKey = params.config?.session?.mainKey?.trim() || "main";
|
||||
const mainKey = normalizeMainKey(params.config?.session?.mainKey);
|
||||
if (!shouldSandboxSession(cfg, rawSessionKey, mainKey)) return null;
|
||||
|
||||
await maybePruneSandboxes(cfg);
|
||||
@@ -1121,7 +1121,7 @@ export async function ensureSandboxWorkspaceForSession(params: {
|
||||
if (!rawSessionKey) return null;
|
||||
const agentId = resolveAgentIdFromSessionKey(rawSessionKey);
|
||||
const cfg = resolveSandboxConfigForAgent(params.config, agentId);
|
||||
const mainKey = params.config?.session?.mainKey?.trim() || "main";
|
||||
const mainKey = normalizeMainKey(params.config?.session?.mainKey);
|
||||
if (!shouldSandboxSession(cfg, rawSessionKey, mainKey)) return null;
|
||||
|
||||
const agentWorkspaceDir = resolveUserPath(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import { normalizeMainKey } from "../../routing/session-key.js";
|
||||
|
||||
export type SessionKind = "main" | "group" | "cron" | "hook" | "node" | "other";
|
||||
|
||||
@@ -8,7 +9,7 @@ function normalizeKey(value?: string) {
|
||||
}
|
||||
|
||||
export function resolveMainSessionAlias(cfg: ClawdbotConfig) {
|
||||
const mainKey = normalizeKey(cfg.session?.mainKey) ?? "main";
|
||||
const mainKey = normalizeMainKey(cfg.session?.mainKey);
|
||||
const scope = cfg.session?.scope ?? "per-sender";
|
||||
const alias = scope === "global" ? "global" : mainKey;
|
||||
return { mainKey, alias, scope };
|
||||
|
||||
Reference in New Issue
Block a user