openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.87 kB
JavaScript
import{n as sha256Hex}from"./node-crypto-DPk8agfR.mjs";
//!src/agents/tools/computer-tool-shared.ts
const COMPUTER_ACT_COMMAND=`computer.act`;const SCREEN_SNAPSHOT_COMMAND=`screen.snapshot`;const COMPUTER_REF_WIDTH=1280;const SCREENSHOT_QUALITY=.85;const COMPUTER_OBSERVATION_ACTIONS=/* @__PURE__ */ new Set([`screenshot`,`wait`,`list_apps`,`list_windows`,`get_accessibility_tree`,`get_cursor_position`,`get_window_state`,`zoom`,`get_browser_state`,`get_recording_state`]);function isComputerObservationAction(e,t){return e!==void 0&&(COMPUTER_OBSERVATION_ACTIONS.has(e)||e===`browser_dialog`&&t===`inspect`)}function computerHostKey(e){return e.host===`gateway`?`gateway`:`node:${e.nodeId}`}function computerTargetDetails(e){return e.host===`gateway`?{target:`gateway`}:{node:e.nodeId,...e.environmentId?{environmentId:e.environmentId}:{}}}function computerFrameImageIdentity(e){const[t,n]=e.filter(e=>e.type===`image`);if(!t||n)return;return sha256Hex(JSON.stringify([t.mimeType,t.data]))}function invalidateComputerFrame(e){if(e.frameToolCallId===void 0&&e.frameImageIdentity===void 0)return false;e.value+=1;delete e.frameToolCallId;delete e.frameImageIdentity;return true}function invalidateComputerFrameIfMissing(e){const t=e.contextEpoch.frameToolCallId;if(t===void 0||e.imagesBlocked)return invalidateComputerFrame(e.contextEpoch);const n=e.messages.findLast(e=>e?.role===`toolResult`&&e.toolName===`computer`&&e.toolCallId===t);const r=n?computerFrameImageIdentity(n.content):void 0;if(r!==void 0&&r===e.contextEpoch.frameImageIdentity)return false;return invalidateComputerFrame(e.contextEpoch)}export{computerFrameImageIdentity as a,invalidateComputerFrameIfMissing as c,SCREEN_SNAPSHOT_COMMAND as i,isComputerObservationAction as l,COMPUTER_REF_WIDTH as n,computerHostKey as o,SCREENSHOT_QUALITY as r,computerTargetDetails as s,COMPUTER_ACT_COMMAND as t};