mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
09672312c4
* feat(gateway): add web-only incognito sessions held in process memory * feat(ui): add incognito toggle and badges to the web new-session flow * fix(sessions): classify incognito by key shape, fail closed on stale keys, and gate memory writes * fix(codex): start harness threads ephemeral for incognito sessions * fix(sessions): reshape internal-effects incognito keys and add doctor repair for reserved key collisions * refactor(plugin-sdk): export canonical incognito key classifier and guard the sentinel path * fix(state): classify incognito DB handles from the recorded open-time set * fix(gateway): isolate incognito sessions from durable lineage and allocation on read-only misses * docs(sessions): pin the reserved incognito namespace ownership decision * feat(gateway): admin-scope incognito visibility and incognito-blind cross-session surfaces * fix(ci): repair kysely guardrails, dead export, docs map, protocol bindings, and ACP reset rotation * fix(gateway): remove non-admin observability side channels for incognito sessions * fix(gateway): enforce admin-scope incognito access and cover all parent-reference creation paths
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
// Agent database path helpers resolve per-agent persisted database paths.
|
|
import path from "node:path";
|
|
import { normalizeAgentId } from "../routing/session-key.js";
|
|
import { resolveOpenClawStateSqliteDir } from "./openclaw-state-db.paths.js";
|
|
|
|
/**
|
|
* Path helpers for per-agent SQLite state.
|
|
*
|
|
* Agent databases live beside the shared state database root so each agent can
|
|
* own private runtime tables while the shared registry can still discover them.
|
|
*/
|
|
/** Inputs for resolving one agent SQLite path or directory. */
|
|
type OpenClawAgentSqlitePathOptions = {
|
|
agentId: string;
|
|
env?: NodeJS.ProcessEnv;
|
|
path?: string;
|
|
};
|
|
|
|
const INCOGNITO_AGENT_SQLITE_BASENAME = "incognito-openclaw-agent.sqlite";
|
|
|
|
/** Resolve the SQLite file for one normalized agent id. */
|
|
export function resolveOpenClawAgentSqlitePath(options: OpenClawAgentSqlitePathOptions): string {
|
|
const agentId = normalizeAgentId(options.agentId);
|
|
return path.resolve(
|
|
options.path ??
|
|
path.join(
|
|
path.dirname(resolveOpenClawStateSqliteDir(options.env ?? process.env)),
|
|
"agents",
|
|
agentId,
|
|
"agent",
|
|
"openclaw-agent.sqlite",
|
|
),
|
|
);
|
|
}
|
|
|
|
/** Resolve the lexical sentinel path that keys one agent's process-held incognito database. */
|
|
export function resolveIncognitoOpenClawAgentSqlitePath(
|
|
options: Omit<OpenClawAgentSqlitePathOptions, "path">,
|
|
): string {
|
|
return path.join(
|
|
path.dirname(resolveOpenClawAgentSqlitePath(options)),
|
|
INCOGNITO_AGENT_SQLITE_BASENAME,
|
|
);
|
|
}
|
|
|
|
/** Identify the reserved incognito sentinel without touching its filesystem path. */
|
|
export function isIncognitoOpenClawAgentSqlitePath(
|
|
pathname: string,
|
|
options: Omit<OpenClawAgentSqlitePathOptions, "path">,
|
|
): boolean {
|
|
return path.resolve(pathname) === resolveIncognitoOpenClawAgentSqlitePath(options);
|
|
}
|