openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
26 lines (25 loc) • 1.26 kB
JavaScript
//#region src/infra/git-maintenance-env.ts
const AUTO_MAINTENANCE_CONFIG = [["maintenance.auto", "false"], ["gc.auto", "0"]];
const AGENT_GIT_CONFIG_PARAMETERS = AUTO_MAINTENANCE_CONFIG.map(([e, t]) => `'${e}=${t}'`).join(" ");
const gitMaintenanceEnvironment = () => appendGitConfig({}, AUTO_MAINTENANCE_CONFIG);
/** Append entries without replacing configuration already owned by the caller. */
function appendGitConfig(e, t) {
const n = { ...e };
let r = Number(e.GIT_CONFIG_COUNT ?? 0);
for (const [e, i] of t) {
n[`GIT_CONFIG_KEY_${r}`] = e;
n[`GIT_CONFIG_VALUE_${r++}`] = i;
}
n.GIT_CONFIG_COUNT = String(r);
return n;
}
/** Serialize remote expressions without relying on compiled function source. */
function gitMaintenanceEnvironmentExpression(e) {
const t = gitMaintenanceEnvironment();
const n = Number(t.GIT_CONFIG_COUNT);
const r = new Set(e.flatMap((e, t) => [`GIT_CONFIG_KEY_${n + t}`, `GIT_CONFIG_VALUE_${n + t}`]));
const i = appendGitConfig(t, e);
return `{${Object.entries(i).map(([e, t]) => `${JSON.stringify(e)}: ${r.has(e) ? t : JSON.stringify(t)}`).join(", ")}}`;
}
//#endregion
export { gitMaintenanceEnvironmentExpression as i, appendGitConfig as n, gitMaintenanceEnvironment as r, AGENT_GIT_CONFIG_PARAMETERS as t };