openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
78 lines (77 loc) • 3.01 kB
JavaScript
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs";
//#region scripts/lib/native-session-catalogs.json
var native_session_catalogs_default = [{
"pluginId": "anthropic",
"label": "Claude Code",
"legacyDefaultEnabled": true,
"description": "Existing native Claude Code conversations on this Gateway and eligible paired nodes.",
"nodeCommands": [
"anthropic.claude.sessions.list.v1",
"anthropic.claude.sessions.read.v1",
"anthropic.claude.terminal.resume.v1"
]
}, {
"pluginId": "codex",
"label": "Codex",
"legacyDefaultEnabled": true,
"description": "Existing native Codex conversations on this Gateway and eligible paired nodes.",
"nodeCommands": [
"codex.appServer.threads.list.v1",
"codex.appServer.thread.turns.list.v1",
"codex.sessionCatalog.transcript.read.v1",
"codex.terminal.resume.v1",
"codex.cli.sessions.list"
]
}];
//#endregion
//#region src/plugins/native-session-catalog-config.ts
const shippedNativeSessionCatalogs = native_session_catalogs_default;
/** Only host-generated declarations can carry a shipped implicit-on upgrade contract. */
function hasLegacyNativeSessionCatalogDefault(e) {
return shippedNativeSessionCatalogs.some((t) => t.pluginId === e && t.legacyDefaultEnabled === true);
}
function readNativeSessionCatalogPreference(e, t) {
const n = e.plugins?.entries?.[t]?.config;
const r = isRecord(n) && isRecord(n.sessionCatalog) ? n.sessionCatalog : void 0;
return typeof r?.enabled === "boolean" ? r.enabled : void 0;
}
/** A first-write privacy preference alone does not request plugin installation. */
function isNativeSessionCatalogOptOutOnly(e, t) {
if (!shippedNativeSessionCatalogs.some((t) => t.pluginId === e) || !isRecord(t) || Object.keys(t).length !== 1 || !isRecord(t.config) || Object.keys(t.config).length !== 1) return false;
const n = t.config.sessionCatalog;
return isRecord(n) && Object.keys(n).length === 1 && n.enabled === false;
}
function applyNativeSessionCatalogPreference(e, t, n, r = false) {
const i = { ...e.plugins?.entries };
let a = false;
for (const e of t) {
const t = i[e] ?? {};
const o = isRecord(t.config) ? t.config : {};
const s = isRecord(o.sessionCatalog) ? o.sessionCatalog : {};
if (s.enabled === n || r && Object.hasOwn(s, "enabled")) continue;
i[e] = {
...t,
config: {
...o,
sessionCatalog: {
...s,
enabled: n
}
}
};
a = true;
}
return a ? {
...e,
plugins: {
...e.plugins,
entries: i
}
} : e;
}
/** Called only by the config writer after its snapshot proves the file is absent. */
function initializeNativeSessionCatalogPreferences(e) {
return applyNativeSessionCatalogPreference(e, shippedNativeSessionCatalogs.map(({ pluginId: e }) => e), false, true);
}
//#endregion
export { readNativeSessionCatalogPreference as a, isNativeSessionCatalogOptOutOnly as i, hasLegacyNativeSessionCatalogDefault as n, shippedNativeSessionCatalogs as o, initializeNativeSessionCatalogPreferences as r, applyNativeSessionCatalogPreference as t };