openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
35 lines (34 loc) • 1.65 kB
JavaScript
import { d as joinPresentTextSegments } from "./hooks-BiZpB_10.mjs";
import { c as persistToolResultProjections } from "./session-prompt-state-H0jXFYE1.mjs";
//#region src/agents/embedded-agent-runner/run/attempt-thread-helpers.ts
/** Combines already-normalized hook sections without rewriting an unchanged prompt. */
function composeSystemPromptWithHookContext(e) {
if (!e.prependSystemContext && !e.appendSystemContext) return;
return joinPresentTextSegments([
e.prependSystemContext,
e.baseSystemPrompt,
e.appendSystemContext
], { trim: true });
}
/**
* Returns the workspace path that must be mounted for sandboxed spawn attempts.
* Read-only sandbox modes need the resolved workspace explicitly; full rw
* access uses the normal workspace wiring.
*/
function resolveAttemptSpawnWorkspaceDir(e) {
return e.sandbox?.enabled && e.sandbox.workspaceAccess !== "rw" ? e.resolvedWorkspace : void 0;
}
/**
* Appends the cache-TTL transcript marker when context-pruning policy and model
* eligibility both allow it.
*/
async function appendAttemptCacheTtlIfNeeded(e) {
if (e.timedOutDuringCompaction || e.compactionOccurredThisAttempt || e.config?.agents?.defaults?.contextPruning?.mode !== "cache-ttl" || !e.isCacheTtlEligibleProvider(e.provider, e.modelId, e.modelApi, e.modelRoute)) return;
await persistToolResultProjections(e.toolResultPromptProjectionState, (t, n) => e.sessionManager.appendCustomEntryAsync(t, n), {
timestamp: Date.now(),
provider: e.provider,
modelId: e.modelId
});
}
//#endregion
export { composeSystemPromptWithHookContext as n, resolveAttemptSpawnWorkspaceDir as r, appendAttemptCacheTtlIfNeeded as t };