import fs from "node:fs/promises"; import type { AgentContextInjection } from "../config/types.agent-defaults.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; import { resolveSessionAgentIds } from "./agent-scope.js"; import { getOrLoadBootstrapFiles } from "./bootstrap-cache.js"; import { applyBootstrapHookOverrides } from "./bootstrap-hooks.js"; import { shouldIncludeHeartbeatGuidanceForSystemPrompt } from "./heartbeat-system-prompt.js"; import type { EmbeddedContextFile } from "./pi-embedded-helpers.js"; import {
buildBootstrapContextFiles,
resolveBootstrapMaxChars,
resolveBootstrapTotalMaxChars,
} from "./pi-embedded-helpers.js"; import {
DEFAULT_HEARTBEAT_FILENAME,
filterBootstrapFilesForSession,
isWorkspaceBootstrapPending,
loadWorkspaceBootstrapFiles,
type WorkspaceBootstrapFile,
} from "./workspace.js";
export type BootstrapContextMode = "full" | "lightweight";
export type BootstrapContextRunKind = "default" | "heartbeat" | "cron";
const records = text
.split(/\r?\n/u)
.filter((line) => line.trim().length > 0)
.slice(-CONTINUATION_SCAN_MAX_RECORDS);
let compactedAfterLatestAssistant = false;
for (let i = records.length - 1; i >= 0; i--) { const line = records[i]; if (!line) { continue;
}
let entry: unknown; try {
entry = JSON.parse(line);
} catch { continue;
} const record = entry as
| {
type?: string;
customType?: string;
message?: { role?: string };
}
| null
| undefined; if (record?.type === "compaction") {
compactedAfterLatestAssistant = true; continue;
} if (
record?.type === "custom" &&
record.customType === FULL_BOOTSTRAP_COMPLETED_CUSTOM_TYPE
) { return !compactedAfterLatestAssistant;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.