import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { SessionManager } from "@mariozechner/pi-coding-agent"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { getGlobalHookRunner } from "../plugins/hook-runner-global.js"; import {
applyInputProvenanceToUserMessage,
type InputProvenance,
} from "../sessions/input-provenance.js"; import { resolveLiveToolResultMaxChars } from "./pi-embedded-runner/tool-result-truncation.js"; import { installSessionToolResultGuard } from "./session-tool-result-guard.js";
export type GuardedSessionManager = SessionManager & { /** Flush any synthetic tool results for pending tool calls. Idempotent. */
flushPendingToolResults?: () => void; /** Clear pending tool calls without persisting synthetic tool results. Idempotent. */
clearPendingToolResults?: () => void;
};
/** * Apply the tool-result guard to a SessionManager exactly once and expose * a flush method on the instance for easy teardown handling.
*/
export function guardSessionManager(
sessionManager: SessionManager,
opts?: {
agentId?: string;
sessionKey?: string;
config?: OpenClawConfig;
contextWindowTokens?: number;
inputProvenance?: InputProvenance;
allowSyntheticToolResults?: boolean;
missingToolResultText?: string;
allowedToolNames?: Iterable<string>;
},
): GuardedSessionManager { if (typeof (sessionManager as GuardedSessionManager).flushPendingToolResults === "function") { return sessionManager as GuardedSessionManager;
}
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.