openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.83 kB
JavaScript
import{l as isRecord}from"./record-coerce-BTbqdJ3-.mjs";import{n as runtimeProcessEntrypoints}from"./runtime-process-entrypoints-Dnd1WskT.mjs";import{a as resolveRuntimeWorkerUrl}from"./runtime-worker-url-Dqf-I1cs.mjs";import{f as releaseSessionSourceAuthorities,l as prepareSessionSourceAuthority,t as acceptSessionSourceValidation}from"./session-source-authority-Cun3s-rH.mjs";import{t as executeOpenClawAgentWorkerPublication}from"./openclaw-agent-worker-store-8zX9GLK9.mjs";import{n as runSessionEntryWorkerOperation}from"./session-entry-patch-BWNuSVYf.mjs";import{randomUUID}from"node:crypto";
//!src/config/sessions/goals-management.ts
async function mutateSessionGoalInWorker(e,t,n,r,i){let a;try{n.assertCurrent();a=await prepareSessionSourceAuthority(i)}catch(e){await releaseSessionSourceAuthorities([n],[e]);throw e}const release=()=>releaseSessionSourceAuthorities([n,a]);return runSessionEntryWorkerOperation({database:e,retainedExecution:n,agentId:t,candidateKind:`session-goal-management`,onTransactionFacts(e){if(isRecord(e)&&e.kind===`session-entry-patch-validated`){acceptSessionSourceValidation(a,e.sourceValidation);a.assertCurrent();return true}return false},assertCurrent:a.assertCurrent,releaseSource:release,assertCandidate(e){if(e.refusedSource){const t=e.refusedSource;a.checks[t.index]?.refuse(t.facts);throw new Error(`Goal source refusal omitted its authority assertion`)}},run:(t,n)=>n(()=>executeOpenClawAgentWorkerPublication(t,{id:randomUUID(),moduleUrl:resolveRuntimeWorkerUrl(runtimeProcessEntrypoints.sessionGoalOperations).href,input:{agentId:e.agentId},command:{type:`session.goal.mutate`,input:{...r,sources:a.checks.map(({predicate:e})=>e)}}})),onCommitted:e=>{if(e.refusedSource)throw new Error(`Refused Goal source reached publication`);return e.result}})}export{mutateSessionGoalInWorker};