openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 2.54 kB
JavaScript
import{a as e,i as t}from"./transcript-record-coerce-CPLgmAk9.mjs";import{i as n,r}from"./transcript-global-singleton-DIJgobpU.mjs";import{a as i}from"./transcript-string-coerce-DTk-8HSr.mjs";import"./transcript-number-coercion-D2B2TTt-.mjs";import"./transcript-session-key-MDDhuEG9.mjs";const a=`Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or safe to repeat. If it may have had side effects, verify the current state first instead of repeating it.`,o=`openclaw.runtime-context`,s=`<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>`,c=`<<<END_OPENCLAW_INTERNAL_CONTEXT>>>`,l=`OpenClaw runtime context:`,u=`End OpenClaw runtime context.`;function hasLegacyRuntimeContextEnvelope(e){return e.startsWith(`<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>
`)&&e.endsWith(`
<<<END_OPENCLAW_INTERNAL_CONTEXT>>>`)}function escapeRuntimeContextFooter(e){return e.replaceAll(u,`[[RUNTIME_CONTEXT_FOOTER_ESCAPED]]`)}function labelRuntimeContextText(e){return`${l}\n${escapeRuntimeContextFooter(e)}\n${u}`}function labelRuntimeContextContent(e){return typeof e==`string`?labelRuntimeContextText(e):e.length===0?[{type:`text`,text:`${l}\n${u}`}]:e.map((t,n)=>({...t,text:[...n===0?[l]:[],escapeRuntimeContextFooter(t.text),...n===e.length-1?[u]:[]].join(`
`)}))}function hasRuntimeContextMarker(e){return e.role===`user`&&(e.runtimeContext!==void 0||e.runtimeContextCarrier===!0)}function readSessionTranscriptRunId(n){return e(n)?i((t(n.__openclaw)??{}).runId):void 0}function readSessionTranscriptFailureRunId(t){if(e(t)&&(t.type===`custom_message`||t.role===`custom`)&&t.customType===`run-failed-before-reply`&&e(t.details))return i(t.details.runId)}function resolveTerminalAssistantTranscriptRunId(t,n){let r=i(n);if(r&&e(t)&&t.role===`assistant`&&!(t.stopReason===`toolUse`||Array.isArray(t.content)&&t.content.some(t=>e(t)&&(t.type===`toolCall`||t.type===`toolUse`||t.type===`functionCall`))))return r}r(Symbol.for(`openclaw.sessionTranscriptListeners`),`close-and-restart`),r(Symbol.for(`openclaw.internalSessionTranscriptListeners`),`close-and-restart`);const d=n(Symbol.for(`openclaw.sessionTranscriptUpdateState`),()=>({version:0}));function advanceSessionTranscriptUpdateVersion(){d.version+=1}export{a,c,hasLegacyRuntimeContextEnvelope as d,hasRuntimeContextMarker as f,resolveTerminalAssistantTranscriptRunId as i,u as l,readSessionTranscriptFailureRunId as n,s as o,labelRuntimeContextContent as p,readSessionTranscriptRunId as r,o as s,advanceSessionTranscriptUpdateVersion as t,l as u};