refactor: unify system prompt runtime params

This commit is contained in:
Peter Steinberger
2026-01-19 05:27:38 +00:00
parent 374da34936
commit 55d034358d
7 changed files with 153 additions and 49 deletions

View File

@@ -0,0 +1,44 @@
import type { ClawdbotConfig } from "../config/config.js";
import {
formatUserTime,
resolveUserTimeFormat,
resolveUserTimezone,
type ResolvedTimeFormat,
} from "./date-time.js";
export type RuntimeInfoInput = {
agentId?: string;
host: string;
os: string;
arch: string;
node: string;
model: string;
channel?: string;
capabilities?: string[];
};
export type SystemPromptRuntimeParams = {
runtimeInfo: RuntimeInfoInput;
userTimezone: string;
userTime?: string;
userTimeFormat?: ResolvedTimeFormat;
};
export function buildSystemPromptParams(params: {
config?: ClawdbotConfig;
agentId?: string;
runtime: Omit<RuntimeInfoInput, "agentId">;
}): SystemPromptRuntimeParams {
const userTimezone = resolveUserTimezone(params.config?.agents?.defaults?.userTimezone);
const userTimeFormat = resolveUserTimeFormat(params.config?.agents?.defaults?.timeFormat);
const userTime = formatUserTime(new Date(), userTimezone, userTimeFormat);
return {
runtimeInfo: {
agentId: params.agentId,
...params.runtime,
},
userTimezone,
userTime,
userTimeFormat,
};
}