mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
30 lines
899 B
TypeScript
30 lines
899 B
TypeScript
// Maintains config metadata fields written alongside user config.
|
|
import { VERSION } from "../version.js";
|
|
import type { OpenClawConfig } from "./types.openclaw.js";
|
|
|
|
/** Metadata keys automatically stamped on config writes. */
|
|
const AUTO_MANAGED_CONFIG_META_FIELDS = {
|
|
lastTouchedVersion: "lastTouchedVersion",
|
|
lastTouchedAt: "lastTouchedAt",
|
|
} as const;
|
|
|
|
export const AUTO_MANAGED_CONFIG_META_PATHS = [
|
|
["meta", AUTO_MANAGED_CONFIG_META_FIELDS.lastTouchedVersion],
|
|
["meta", AUTO_MANAGED_CONFIG_META_FIELDS.lastTouchedAt],
|
|
] as const;
|
|
|
|
export function stampConfigWriteMetadata(
|
|
cfg: OpenClawConfig,
|
|
now: string = new Date().toISOString(),
|
|
version: string = VERSION,
|
|
): OpenClawConfig {
|
|
return {
|
|
...cfg,
|
|
meta: {
|
|
...cfg.meta,
|
|
[AUTO_MANAGED_CONFIG_META_FIELDS.lastTouchedVersion]: version,
|
|
[AUTO_MANAGED_CONFIG_META_FIELDS.lastTouchedAt]: now,
|
|
},
|
|
};
|
|
}
|