UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

123 lines (122 loc) • 4.58 kB
import { s as readGoalContinuationContext } from "./goal-continuation-return-DCxKXc44.mjs"; import { t as BUILTIN_AGENT_HARNESS_METADATA } from "./builtin-openclaw-metadata-DYXgWX-u.mjs"; import { t as runHostPreparedIsolatedCompletion } from "./host-prepared-isolated-completion-BSUb9Bqp.mjs"; import { n as projectSettledTurnFinalizationAttemptResult } from "./settled-turn-finalization-result-DSvueaqd.mjs"; //#region src/agents/harness/types.ts /** * Checks whether an agent harness explicitly declares support for turn-scoped * tool restrictions (such as dynamic tool prefiltering). */ function harnessSupportsTurnScopedToolRestrictions(e) { return e?.supportsTurnScopedToolRestrictions === true; } //#endregion //#region src/agents/harness/builtin-openclaw.ts const builtInOpenClawHarnesses = /* @__PURE__ */ new WeakSet(); function buildRestrictedFinalizationAttempt(e) { const t = e; return { admittedRunContext: t.admittedRunContext, replyOperation: t.replyOperation, sessionId: e.sessionId, sessionKey: e.sessionKey, sessionTarget: e.sessionTarget, lifecycleGeneration: e.lifecycleGeneration, promptCacheKey: e.promptCacheKey, sandboxSessionKey: e.sandboxSessionKey, agentId: e.agentId, workspaceDir: e.workspaceDir, cwd: e.cwd, agentDir: e.agentDir, config: e.config, prompt: e.prompt, timeoutMs: e.timeoutMs, runTimeoutOverrideMs: e.runTimeoutOverrideMs, runId: e.runId, abortSignal: e.abortSignal, onExecutionStarted: e.onExecutionStarted, onExecutionPhase: e.onExecutionPhase, onLaneWait: e.onLaneWait, onRunProgress: e.onRunProgress, onAgentEvent: e.onAgentEvent, deferTerminalLifecycle: e.deferTerminalLifecycle, onAttemptTimeoutArmed: e.onAttemptTimeoutArmed, onAttemptDeadlineChanged: e.onAttemptDeadlineChanged, onAttemptTimeout: e.onAttemptTimeout, onAttemptAbort: e.onAttemptAbort, preparedModelRuntime: e.preparedModelRuntime, sessionFile: e.sessionFile, sessionManager: e.sessionManager, sessionPersistence: e.sessionPersistence, prepareAssistantTranscriptMessage: e.prepareAssistantTranscriptMessage, privateCompletion: e.privateCompletion, contextTokenBudget: e.contextTokenBudget, contextWindowInfo: e.contextWindowInfo, resolvedApiKey: e.resolvedApiKey, authProfileId: e.authProfileId, authProfileIdSource: e.authProfileIdSource, provider: e.provider, modelId: e.modelId, requestedModelId: e.requestedModelId, agentHarnessId: e.agentHarnessId, runtimePlan: e.runtimePlan, model: e.model, authStorage: e.authStorage, authProfileStore: e.authProfileStore, toolAuthProfileStore: e.toolAuthProfileStore, modelRegistry: e.modelRegistry, thinkLevel: e.thinkLevel, fastMode: e.fastMode, fastModeAuto: e.fastModeAuto, operation: "settled-tool-finalization", disableTools: true, disableTrajectory: true, skipPreparedUserTurnMessage: true, suppressNextUserMessagePersistence: true, initialReplayState: { replayInvalid: false, hadPotentialSideEffects: false } }; } function createOpenClawAgentHarness() { const e = { ...BUILTIN_AGENT_HARNESS_METADATA, supportsTurnScopedToolRestrictions: true, runAttempt: async (t) => { const n = readGoalContinuationContext({ runId: t.runId, sessionKey: t.sessionKey, currentInboundContext: t.currentInboundContext }); const r = { ...t, ...n ? { currentInboundContext: n } : {}, supportsTurnScopedToolRestrictions: harnessSupportsTurnScopedToolRestrictions(e) }; const { runEmbeddedAttempt: i } = await import("./attempt-BkPSOuia.mjs"); return i(r); }, runIsolatedCompletionV2: runHostPreparedIsolatedCompletion, finalizeSettledTurn: async ({ attempt: e, settledAttempt: t }) => { const n = t.settledTurnFinalizationContext; const r = n?.source === "openclaw-transcript" ? n.messages : n === void 0 ? t.messagesSnapshot : void 0; if (!r) throw new Error("OpenClaw finalization requires the settled attempt transcript view"); const i = { ...buildRestrictedFinalizationAttempt(e), settledTurnFinalizationMessages: Object.freeze([...r]) }; const { runEmbeddedAttempt: a } = await import("./attempt-BkPSOuia.mjs"); const o = await a(i); return projectSettledTurnFinalizationAttemptResult(o); } }; builtInOpenClawHarnesses.add(e); return e; } /** Distinguishes the internal runtime from an untrusted harness that copies its public id. */ function isBuiltInOpenClawAgentHarness(e) { return builtInOpenClawHarnesses.has(e); } //#endregion export { isBuiltInOpenClawAgentHarness as n, createOpenClawAgentHarness as t };