openclaw-multi-auto 1.8.0 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-BomWJjOy.js → agent-ef71Xoo3.js} +10 -10
- package/dist/{audio-preflight-GAYJDgGF.js → audio-preflight-BK4MI6Gs.js} +1 -1
- package/dist/{audio-preflight-CZHCr2-5.js → audio-preflight-BQoP-O-0.js} +9 -9
- package/dist/{audio-preflight-SOY4qjTl.js → audio-preflight-DcneE70v.js} +6 -6
- package/dist/{audit-membership-runtime-fBOVjLNx.js → audit-membership-runtime-0b4ZhE41.js} +4 -4
- package/dist/{audit-membership-runtime-BQmoiW7f.js → audit-membership-runtime-BDoMjPgy.js} +3 -3
- package/dist/{auth-profiles-CEEqFOKJ.js → auth-profiles-Dta-Mhaw.js} +438 -438
- package/dist/auth-profiles.runtime-CLSx3zsq.js +7 -0
- package/dist/auth-profiles.runtime-CuInvQ6F.js +11 -0
- package/dist/{auth-profiles.runtime-IXde-3_L.js → auth-profiles.runtime-DEhTAVAo.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +10 -10
- package/dist/bundled/bootstrap-extra-files/handler.js +5 -5
- package/dist/bundled/command-logger/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +9 -9
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/compact.runtime-BOg89Gro.js +11 -0
- package/dist/compact.runtime-BgRco6mO.js +7 -0
- package/dist/{compact.runtime-BCHQpekB.js → compact.runtime-CH24Vvny.js} +1 -1
- package/dist/daemon-cli.js +53 -53
- package/dist/{deliver-runtime-Bm3VqH55.js → deliver-runtime-6WeFOxSI.js} +1 -1
- package/dist/deliver-runtime-BBwve6gL.js +7 -0
- package/dist/deliver-runtime-CUrIlSzN.js +11 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/{fetch-wjPVlu-r.js → fetch-Bdod8UI1.js} +3 -3
- package/dist/{fetch-BdTTF2z-.js → fetch-sH_NN8SV.js} +2 -2
- package/dist/{frontmatter-DZlWsaUx.js → frontmatter-DhmdUnBP.js} +3 -3
- package/dist/{github-copilot-token-C-NbPL95.js → github-copilot-token-368sRGBD.js} +2 -2
- package/dist/{github-copilot-token-BeFx3MLn.js → github-copilot-token-BgPOyCXe.js} +7 -7
- package/dist/{image-runtime-CReMeTZL.js → image-runtime-BwzYRCA5.js} +1 -1
- package/dist/image-runtime-DiA6CU2y.js +7 -0
- package/dist/image-runtime-Dur8cmII.js +11 -0
- package/dist/llm-slug-generator.js +9 -9
- package/dist/{logger-mQKrXyAc.js → logger-Budylr6i.js} +18 -18
- package/dist/{logger-DCBlX1uz.js → logger-C0l_Gj8Y.js} +7 -7
- package/dist/{login-xsvrgJJt.js → login-BEOnxdap.js} +2 -2
- package/dist/{login-Ctt81ov4.js → login-Bk8BjEUN.js} +3 -3
- package/dist/{login-CKmmxErc.js → login-CvFRLU0k.js} +4 -4
- package/dist/{login-qr-CHrXhUJY.js → login-qr-CVQlH0l0.js} +7 -7
- package/dist/{login-qr-KVA4wuh0.js → login-qr-D-_3HfJq.js} +10 -10
- package/dist/{login-qr-D2jYdV8v.js → login-qr-FW_sLvPl.js} +2 -2
- package/dist/manager-runtime-BW_M_Kzt.js +7 -0
- package/dist/manager-runtime-CfBjUnwB.js +11 -0
- package/dist/{manager-runtime-BBxiBzvv.js → manager-runtime-DV0_pZDZ.js} +1 -1
- package/dist/{manager.runtime-CF3GyuMb.js → manager.runtime-CynsHdcO.js} +7 -7
- package/dist/{manager.runtime-BV-CBNb2.js → manager.runtime-DF-LRAbL.js} +10 -10
- package/dist/{manager.runtime-C5odxL4B.js → manager.runtime-KPIwNjNW.js} +12 -12
- package/dist/{model-selection-CNRMBWfR.js → model-selection-C9tlIhgN.js} +271 -271
- package/dist/{model-selection-BQm6_iuT.js → model-selection-qaBek98Q.js} +43 -43
- package/dist/{paths-jtwudEDq.js → paths-BnSNMlFT.js} +5 -5
- package/dist/{paths-CNIc83Pn.js → paths-BwJ6yG6k.js} +5 -5
- package/dist/pi-model-discovery-runtime-CK36RhYz.js +11 -0
- package/dist/{pi-model-discovery-runtime-C-YPAOQR.js → pi-model-discovery-runtime-CLfgSk3o.js} +6 -6
- package/dist/{pi-model-discovery-runtime-DeRljgTs.js → pi-model-discovery-runtime-Q0BoklY3.js} +1 -1
- package/dist/{pi-tools.before-tool-call.runtime-PhxG0y1R.js → pi-tools.before-tool-call.runtime-B_uML_Gt.js} +1 -1
- package/dist/{pi-tools.before-tool-call.runtime-CWgsv7kC.js → pi-tools.before-tool-call.runtime-CKzFGrVv.js} +6 -6
- package/dist/{pi-tools.before-tool-call.runtime-DgAiY2la.js → pi-tools.before-tool-call.runtime-CLRTNt4A.js} +9 -9
- package/dist/plugin-sdk/{audio-preflight-yyFn-I5K.js → audio-preflight-CVWl4NKo.js} +12 -12
- package/dist/plugin-sdk/{audit-membership-runtime-DHo6vLy0.js → audit-membership-runtime-D1VvFm38.js} +5 -5
- package/dist/plugin-sdk/{auth-profiles.runtime-DN3bNNeo.js → auth-profiles.runtime-Cy2e2Wah.js} +12 -12
- package/dist/plugin-sdk/{bluebubbles-BPDNQxEz.js → bluebubbles-B_tcmPhi.js} +1 -1
- package/dist/plugin-sdk/bluebubbles.js +15 -15
- package/dist/plugin-sdk/{channel-access-BaZDvsTA.js → channel-access-GDk6vyOi.js} +1 -1
- package/dist/plugin-sdk/{channel-access-configure-DLZc22_m.js → channel-access-configure-CerQrsyV.js} +1 -1
- package/dist/plugin-sdk/{channel-config-helpers-CFkTEzkz.js → channel-config-helpers-CX9AfjCJ.js} +3 -3
- package/dist/plugin-sdk/{compact.runtime-D1HfZ8IJ.js → compact.runtime-0XuiRVw-.js} +12 -12
- package/dist/plugin-sdk/compat.js +28 -28
- package/dist/plugin-sdk/core.js +14 -14
- package/dist/plugin-sdk/{deliver-runtime-DrD2s_GI.js → deliver-runtime-D37pd8wU.js} +12 -12
- package/dist/plugin-sdk/device-pair.js +5 -5
- package/dist/plugin-sdk/diagnostics-otel.js +2 -2
- package/dist/plugin-sdk/{discord-BZR9M1Ft.js → discord-dU71XVvQ.js} +4 -4
- package/dist/plugin-sdk/discord.js +16 -16
- package/dist/plugin-sdk/{exec-BvTkR9oI.js → exec-88qB5pUO.js} +2 -2
- package/dist/plugin-sdk/feishu.js +14 -14
- package/dist/plugin-sdk/{fetch-yk-axchG.js → fetch-Cqwcg-Kq.js} +2 -2
- package/dist/plugin-sdk/{fetch-guard-Cwx1pJhf.js → fetch-guard-DEyOIg88.js} +1 -1
- package/dist/plugin-sdk/google-gemini-cli-auth.js +4 -4
- package/dist/plugin-sdk/googlechat.js +14 -14
- package/dist/plugin-sdk/{helpers-Cj2lgcNt.js → helpers-zm9M-XCJ.js} +1 -1
- package/dist/plugin-sdk/{http-registry-DyBqqyPO.js → http-registry-CR-l0QpT.js} +2 -2
- package/dist/plugin-sdk/{image-runtime-ChtfQsK-.js → image-runtime-CSZNFoHc.js} +12 -12
- package/dist/plugin-sdk/{imessage-DtibPuZP.js → imessage-DvtFTwJr.js} +3 -3
- package/dist/plugin-sdk/imessage.js +14 -14
- package/dist/plugin-sdk/{inbound-reply-dispatch-CfNEV0ZG.js → inbound-reply-dispatch-DpGprwTU.js} +1 -1
- package/dist/plugin-sdk/index.js +28 -28
- package/dist/plugin-sdk/irc.js +15 -15
- package/dist/plugin-sdk/{logger-C9fkmDdb.js → logger-D-go2oXy.js} +2 -2
- package/dist/plugin-sdk/{logger-DXnvMlr-.js → logger-Jt8cCPPV.js} +2 -2
- package/dist/plugin-sdk/{login-BC7QDpvj.js → login-CnT14vQ1.js} +5 -5
- package/dist/plugin-sdk/{login-qr-rnZFcwNs.js → login-qr-Di9Gqms7.js} +13 -13
- package/dist/plugin-sdk/{manager-runtime-B8O--3Jt.js → manager-runtime-DzCE2bL1.js} +12 -12
- package/dist/plugin-sdk/{manager.runtime-U_d65Qv1.js → manager.runtime-D6nT5fqn.js} +18 -18
- package/dist/plugin-sdk/matrix.js +16 -16
- package/dist/plugin-sdk/mattermost.js +14 -14
- package/dist/plugin-sdk/msteams.js +16 -16
- package/dist/plugin-sdk/nextcloud-talk.js +15 -15
- package/dist/plugin-sdk/nostr.js +4 -4
- package/dist/plugin-sdk/{outbound-media-DWtG1X8J.js → outbound-media-CN8bsq-T.js} +1 -1
- package/dist/plugin-sdk/{persistent-dedupe-BroxGf3Q.js → persistent-dedupe-CjCe_L5g.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-DWyENOD9.js → pi-model-discovery-runtime-1vkd_hCn.js} +12 -12
- package/dist/plugin-sdk/{pi-tools.before-tool-call.runtime-CPBeYJY2.js → pi-tools.before-tool-call.runtime-D0XEYwCa.js} +12 -12
- package/dist/plugin-sdk/{pw-ai-DR8Hjs-J.js → pw-ai-DkDE5awL.js} +12 -12
- package/dist/plugin-sdk/{qmd-manager-3qRPZ5ye.js → qmd-manager-CguAGtaF.js} +7 -7
- package/dist/plugin-sdk/{query-expansion-BnFYorqr.js → query-expansion-ChYs46vb.js} +5 -5
- package/dist/plugin-sdk/{redact-DTcVTGFU.js → redact-CqHkGWow.js} +1 -1
- package/dist/plugin-sdk/{run-command-qzkvaQG1.js → run-command-nYfMDZC3.js} +1 -1
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-UvsfFa7Q.js +24 -0
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-CYBj8E4x.js +23 -0
- package/dist/plugin-sdk/{send-BZgg6N38.js → send-BDZssl9O.js} +5 -5
- package/dist/plugin-sdk/{session-Dm0FT_vI.js → session-DPhL1rLb.js} +5 -5
- package/dist/plugin-sdk/{signal-Dy_XjHKL.js → signal-BKMAyRnz.js} +6 -6
- package/dist/plugin-sdk/signal.js +14 -14
- package/dist/plugin-sdk/{slack-DNwpGTSd.js → slack-jues0BBq.js} +3 -3
- package/dist/plugin-sdk/slack.js +16 -16
- package/dist/plugin-sdk/{slash-commands.runtime-Bn7T59g3.js → slash-commands.runtime-BJ6veGjC.js} +12 -12
- package/dist/plugin-sdk/{slash-dispatch.runtime-BPsvStS0.js → slash-dispatch.runtime-CyWyh0DI.js} +12 -12
- package/dist/plugin-sdk/{slash-skill-commands.runtime-TDVZ7jxr.js → slash-skill-commands.runtime-BiDqNceZ.js} +12 -12
- package/dist/plugin-sdk/{subagent-registry-runtime-D3DovVGQ.js → subagent-registry-runtime-BVsFNLUF.js} +12 -12
- package/dist/plugin-sdk/{subsystem-DXcqLSNd.js → subsystem-DOh66yR6.js} +1 -1
- package/dist/plugin-sdk/synology-chat.js +4 -4
- package/dist/plugin-sdk/{telegram-B1RGxv8p.js → telegram-D3JLaXTI.js} +4 -4
- package/dist/plugin-sdk/telegram.js +14 -14
- package/dist/plugin-sdk/{text-chunking-CaqMErUv.js → text-chunking-Bd2LMKfE.js} +1 -1
- package/dist/plugin-sdk/{thread-bindings-Bp_o0GHR.js → thread-bindings-Cc59nx4d.js} +48 -48
- package/dist/plugin-sdk/tlon.js +13 -13
- package/dist/plugin-sdk/twitch.js +14 -14
- package/dist/plugin-sdk/{utils-BQpbGej3.js → utils-BhiRkVxe.js} +1 -1
- package/dist/plugin-sdk/{vllm-setup-wjrX_svM.js → vllm-setup-R5M9rOvm.js} +2 -2
- package/dist/plugin-sdk/voice-call.js +12 -12
- package/dist/plugin-sdk/{web-Dz6AjTQn.js → web-BpHTS6sG.js} +16 -16
- package/dist/plugin-sdk/{webhook-targets-yTQuv0k1.js → webhook-targets-t3fxeJQf.js} +1 -1
- package/dist/plugin-sdk/{whatsapp-actions-C5SohPL-.js → whatsapp-actions-BAJ27s8B.js} +13 -13
- package/dist/plugin-sdk/{whatsapp-heartbeat-_Kw4PPKA.js → whatsapp-heartbeat-D6NF4OC0.js} +3 -3
- package/dist/plugin-sdk/whatsapp.js +13 -13
- package/dist/plugin-sdk/zalo.js +15 -15
- package/dist/plugin-sdk/zalouser.js +16 -16
- package/dist/{pw-ai-BFfAJexr.js → pw-ai-BZnl84YT.js} +6 -6
- package/dist/{pw-ai-3ual6adI.js → pw-ai-CRL5SGWK.js} +9 -9
- package/dist/{pw-ai-CzFFsGR7.js → pw-ai-DzdseGw2.js} +1 -1
- package/dist/{qmd-manager-rY-Y6sbN.js → qmd-manager-BmuMJQP3.js} +3 -3
- package/dist/{qmd-manager-DvglNhlJ.js → qmd-manager-CFVuAj9l.js} +5 -5
- package/dist/{query-expansion-BIMwPSMg.js → query-expansion-BMQzl41m.js} +89 -89
- package/dist/{query-expansion-DXwSmE_K.js → query-expansion-DnS6CGY2.js} +8 -8
- package/dist/runtime-whatsapp-login.runtime-CO-iUlqS.js +13 -0
- package/dist/runtime-whatsapp-login.runtime-Dd6rJjLo.js +9 -0
- package/dist/{runtime-whatsapp-login.runtime-vKFKNi8Z.js → runtime-whatsapp-login.runtime-Dsz-DNfa.js} +3 -3
- package/dist/{runtime-whatsapp-outbound.runtime-SAT-C6UE.js → runtime-whatsapp-outbound.runtime-BeZMBTt6.js} +2 -2
- package/dist/runtime-whatsapp-outbound.runtime-CatYliOE.js +8 -0
- package/dist/runtime-whatsapp-outbound.runtime-IeVUgrJu.js +12 -0
- package/dist/{send-UG1n3OAg.js → send-CHO1gc7n.js} +2 -2
- package/dist/{send-CXnKWzde.js → send-CsgNtXyY.js} +3 -3
- package/dist/{send-DGQUY-kp.js → send-DxYxezcL.js} +1 -1
- package/dist/{session-CbQ43pUq.js → session--tqRfZQU.js} +1 -1
- package/dist/{session-kt-bqE_z.js → session-BhX4LYCK.js} +7 -7
- package/dist/{session-Bpmn--zO.js → session-r38wrRC6.js} +6 -6
- package/dist/slash-commands.runtime-BTNXGYOP.js +11 -0
- package/dist/{slash-commands.runtime-DoT9bJKb.js → slash-commands.runtime-C8j-n-bX.js} +1 -1
- package/dist/{slash-commands.runtime-DIrX0Ynq.js → slash-commands.runtime-J-gBOPcL.js} +6 -6
- package/dist/{slash-dispatch.runtime--9HmQuIE.js → slash-dispatch.runtime-BA-MMy0P.js} +1 -1
- package/dist/{slash-dispatch.runtime-CG-xSDdf.js → slash-dispatch.runtime-CwO02PY8.js} +6 -6
- package/dist/{slash-dispatch.runtime-Cu8ghe1h.js → slash-dispatch.runtime-cYx62DOd.js} +9 -9
- package/dist/slash-skill-commands.runtime-BQRfyLdb.js +7 -0
- package/dist/{slash-skill-commands.runtime-BZqnnkHJ.js → slash-skill-commands.runtime-Cm8K1kWM.js} +1 -1
- package/dist/slash-skill-commands.runtime-ThOxhaze.js +11 -0
- package/dist/{subagent-registry-runtime-rBYzVSXG.js → subagent-registry-runtime-1IiL0xom.js} +6 -6
- package/dist/{subagent-registry-runtime-9WfVik2h.js → subagent-registry-runtime-DKOXxZgH.js} +1 -1
- package/dist/{subagent-registry-runtime-Z0fdsGSq.js → subagent-registry-runtime-DkamrsVw.js} +9 -9
- package/dist/{subsystem-Cr1MiLhx.js → subsystem-CDcEQtQK.js} +14 -14
- package/dist/{web-DbsQPRh2.js → web-B_GcnsRF.js} +9 -9
- package/dist/{web-B_EVHbEP.js → web-RzQ9jrtt.js} +4 -4
- package/dist/{web-CXyjF_si.js → web-bHB4SzXZ.js} +12 -12
- package/dist/{whatsapp-actions-CnWp29AN.js → whatsapp-actions-BCgsmzOa.js} +7 -7
- package/dist/{whatsapp-actions-pQqLTCXJ.js → whatsapp-actions-BmDvJijd.js} +2 -2
- package/dist/{whatsapp-actions-BUvGEDSk.js → whatsapp-actions-BqFiZbuw.js} +10 -10
- package/dist/{workspace-Bi8vpJN0.js → workspace-Cg3kGb1y.js} +20 -20
- package/package.json +1 -1
- package/scripts/create-instance.sh +21 -3
- package/dist/auth-profiles.runtime-DNqCx0L5.js +0 -11
- package/dist/auth-profiles.runtime-DXPqJP5A.js +0 -7
- package/dist/compact.runtime-DS9UVeOh.js +0 -7
- package/dist/compact.runtime-pgjSlzSY.js +0 -11
- package/dist/deliver-runtime-D4aWAXZ9.js +0 -11
- package/dist/deliver-runtime-D929PgeO.js +0 -7
- package/dist/image-runtime-Brryt_BU.js +0 -11
- package/dist/image-runtime-CkdY0-Oo.js +0 -7
- package/dist/manager-runtime-D9AEoM1M.js +0 -11
- package/dist/manager-runtime-PqJtJx-b.js +0 -7
- package/dist/pi-model-discovery-runtime-CDKkuBYh.js +0 -11
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-BDbgMnYK.js +0 -24
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-BYZKJw25.js +0 -23
- package/dist/runtime-whatsapp-login.runtime-Br3SxDXL.js +0 -13
- package/dist/runtime-whatsapp-login.runtime-DeV-bhiR.js +0 -9
- package/dist/runtime-whatsapp-outbound.runtime-BFY32bnC.js +0 -8
- package/dist/runtime-whatsapp-outbound.runtime-L3Qkst0n.js +0 -12
- package/dist/slash-commands.runtime-BYfxn_xu.js +0 -11
- package/dist/slash-skill-commands.runtime-8dS5PTaH.js +0 -11
- package/dist/slash-skill-commands.runtime-JEA80FeR.js +0 -7
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
|
-
import { a as resolveGatewayPort, c as resolveOAuthPath, i as resolveDefaultConfigCandidates, l as resolveStateDir, n as STATE_DIR, p as resolveRequiredHomeDir, r as resolveConfigPath$1, s as resolveOAuthDir, t as DEFAULT_GATEWAY_PORT, u as expandHomePrefix } from "./paths-
|
|
3
|
-
import { $ as consumeRootOptionToken, A as shortenHomePath, B as shouldLogVerbose, C as normalizeE164, D as resolveUserPath, F as isPlainObject$2, G as theme, H as warn, I as danger, K as getChildLogger, L as info, M as sliceUtf16Safe, O as safeParseJson, P as truncateUtf16Safe, Q as resolvePreferredOpenClawTmpDir, R as logVerbose, S as jidToE164, T as resolveConfigDir, U as colorize, V as success, W as isRich, X as normalizeLogLevel, Z as readLoggingConfig, _ as ensureDir$3, a as createSubsystemLogger, b as isRecord$7, c as createNonExitingRuntime, d as registerActiveProgressLine, f as unregisterActiveProgressLine, g as clampNumber$1, h as clampInt, i as logWarn, j as sleep$2, k as shortenHomeInString, l as defaultRuntime, n as logError, o as sanitizeForLog, p as CONFIG_DIR, r as logInfo, s as stripAnsi, t as logDebug, u as clearActiveProgressLine, v as escapeRegExp, y as formatTerminalLink, z as setVerbose } from "./logger-
|
|
4
|
-
import { $ as getDefaultRedactPatterns, $t as normalizeWindowsPathForComparison, A as supportsMemoryMultimodalEmbeddings, An as resolveAgentModelFallbackValues, At as DEFAULT_BOOTSTRAP_FILENAME, B as resolveWindowsSpawnProgram, Bt as resolveOpenClawPackageRootSync, C as isFileMissingError, Cn as deriveSessionChatType, Ct as resolveDefaultAgentId, D as getMemoryMultimodalExtensions, Dn as isSubagentSessionKey, Dt as resolveSessionAgentIds, E as classifyMemoryMultimodalPath, En as isCronSessionKey, Et as resolveSessionAgentId, F as resolveSessionTranscriptPath$1, Ft as DEFAULT_USER_FILENAME, G as openFileWithinRoot, Gt as markOpenClawExecEnv, H as appendFileWithinRoot, Ht as runExec, I as resolveSessionTranscriptPathInDir, It as ensureAgentWorkspace, Jt as openBoundaryFileSync, K as readFileWithinRoot, Kt as canUseBoundaryFileOpen, L as resolveSessionTranscriptsDirForAgent, Lt as filterBootstrapFilesForSession, M as resolveDefaultSessionStorePath, Mn as toAgentModelListLike, Mt as DEFAULT_IDENTITY_FILENAME, N as resolveSessionFilePath, Nt as DEFAULT_SOUL_FILENAME, O as isMemoryMultimodalEnabled, On as parseAgentSessionKey, Ot as DEFAULT_AGENTS_FILENAME, P as resolveSessionFilePathOptions, Pt as DEFAULT_TOOLS_FILENAME, Q as runTasksWithConcurrency, Qt as isPathInside$2, R as resolveStorePath$1, Rt as loadWorkspaceBootstrapFiles, S as splitTextToUtf8ByteLimit, Sn as isBlockedObjectKey, St as resolveAgentWorkspaceDir, T as buildCaseInsensitiveExtensionGlob, Tn as isAcpSessionKey, Tt as resolveRunModelFallbacksOverride, U as copyFileWithinRoot, Ut as resolveWindowsCommandShim, V as SafeOpenError, Vt as runCommandWithTimeout, W as createRootScopedReadFile, Wt as spawnWithFallback, X as PATH_ALIAS_POLICIES, Xt as resolvePathViaExistingAncestorSync, Y as writeFileWithinRoot, Yt as openVerifiedFileSync, Z as assertNoPathAliasEscape, Zt as isNotFoundPathError, _ as remapChunkLines, _n as scopedHeartbeatWakeOptions, _t as resolveAgentConfig, a as listSessionFilesForAgent, an as DEFAULT_AGENT_ID, at as extensionForMime, b as estimateStructuredEmbeddingInputBytes, bn as normalizeAccountId$3, bt as resolveAgentModelFallbacksOverride, c as buildMultimodalChunkForIndexing, cn as buildAgentPeerSessionKey, ct as isAudioFileName, d as ensureDir$4, dn as isValidAgentId, dt as normalizeMimeType$1, en as normalizeSkillFilter, et as redactSensitiveText, f as hashText$1, fn as normalizeAgentId, ft as MAX_IMAGE_BYTES$1, g as parseEmbedding, gn as sanitizeAgentId, gt as listAgentIds, h as normalizeExtraMemoryPaths, hn as resolveThreadSessionKeys, ht as hasConfiguredModelFallbacks, i as buildSessionEntry, in as normalizeStringEntriesLower, it as detectMime, j as resolveAgentsDirFromSessionStorePath, jn as resolveAgentModelPrimaryValue, jt as DEFAULT_HEARTBEAT_FILENAME, k as normalizeMemoryMultimodalSettings, kn as resolveThreadParentSessionKey, kt as DEFAULT_AGENT_WORKSPACE_DIR, l as chunkMarkdown, lt as isGifMedia, m as listMemoryFiles, mn as resolveAgentIdFromSessionKey, mt as mediaKindFromMime, n as isQueryStopWordToken, nn as normalizeHyphenSlug, nt as compileSafeRegex, o as sessionPathForFile, on as DEFAULT_MAIN_KEY, ot as getFileExtension, p as isMemoryPath, pn as normalizeMainKey, pt as maxBytesForKind, q as readLocalFileSafely, qt as openBoundaryFile, r as requireNodeSqlite, rn as normalizeStringEntries, rt as testRegexWithBoundedInput, s as buildFileEntry, sn as buildAgentMainSessionKey, st as imageMimeFromFormat, t as extractKeywords, tn as normalizeAtHashSlug, tt as redactToolDetail, u as cosineSimilarity, un as classifySessionKeyShape, ut as kindFromMime, v as runWithConcurrency$1, vn as toAgentRequestSessionKey, vt as resolveAgentDir, w as statRegularFile, wn as getSubagentDepth, x as estimateUtf8Bytes, xn as normalizeOptionalAccountId, xt as resolveAgentSkillsFilter, y as hasNonTextEmbeddingParts, yn as DEFAULT_ACCOUNT_ID, yt as resolveAgentEffectiveModelPrimary, z as materializeWindowsSpawnProgram, zt as resolveOpenClawPackageRoot } from "./query-expansion-
|
|
5
|
-
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-
|
|
6
|
-
import { c as makeProxyFetch, d as hasProxyEnvConfigured, f as bindAbortRelay, h as parseBooleanValue$1, l as resolveProxyFetchFromEnv, m as isTruthyEnvValue, n as resolveTelegramTransport, o as resolveFetch, p as fetchWithTimeout, r as shouldRetryTelegramIpv4Fallback, s as wrapFetchWithAbortSignal, t as resolveTelegramFetch, u as hasEnvHttpProxyConfigured } from "./fetch-
|
|
2
|
+
import { a as resolveGatewayPort, c as resolveOAuthPath, i as resolveDefaultConfigCandidates, l as resolveStateDir, n as STATE_DIR, p as resolveRequiredHomeDir, r as resolveConfigPath$1, s as resolveOAuthDir, t as DEFAULT_GATEWAY_PORT, u as expandHomePrefix } from "./paths-BnSNMlFT.js";
|
|
3
|
+
import { $ as consumeRootOptionToken, A as shortenHomePath, B as shouldLogVerbose, C as normalizeE164, D as resolveUserPath, F as isPlainObject$2, G as theme, H as warn, I as danger, K as getChildLogger, L as info, M as sliceUtf16Safe, O as safeParseJson, P as truncateUtf16Safe, Q as resolvePreferredOpenClawTmpDir, R as logVerbose, S as jidToE164, T as resolveConfigDir, U as colorize, V as success, W as isRich, X as normalizeLogLevel, Z as readLoggingConfig, _ as ensureDir$3, a as createSubsystemLogger, b as isRecord$7, c as createNonExitingRuntime, d as registerActiveProgressLine, f as unregisterActiveProgressLine, g as clampNumber$1, h as clampInt, i as logWarn, j as sleep$2, k as shortenHomeInString, l as defaultRuntime, n as logError, o as sanitizeForLog, p as CONFIG_DIR, r as logInfo, s as stripAnsi, t as logDebug, u as clearActiveProgressLine, v as escapeRegExp, y as formatTerminalLink, z as setVerbose } from "./logger-Budylr6i.js";
|
|
4
|
+
import { $ as getDefaultRedactPatterns, $t as normalizeWindowsPathForComparison, A as supportsMemoryMultimodalEmbeddings, An as resolveAgentModelFallbackValues, At as DEFAULT_BOOTSTRAP_FILENAME, B as resolveWindowsSpawnProgram, Bt as resolveOpenClawPackageRootSync, C as isFileMissingError, Cn as deriveSessionChatType, Ct as resolveDefaultAgentId, D as getMemoryMultimodalExtensions, Dn as isSubagentSessionKey, Dt as resolveSessionAgentIds, E as classifyMemoryMultimodalPath, En as isCronSessionKey, Et as resolveSessionAgentId, F as resolveSessionTranscriptPath$1, Ft as DEFAULT_USER_FILENAME, G as openFileWithinRoot, Gt as markOpenClawExecEnv, H as appendFileWithinRoot, Ht as runExec, I as resolveSessionTranscriptPathInDir, It as ensureAgentWorkspace, Jt as openBoundaryFileSync, K as readFileWithinRoot, Kt as canUseBoundaryFileOpen, L as resolveSessionTranscriptsDirForAgent, Lt as filterBootstrapFilesForSession, M as resolveDefaultSessionStorePath, Mn as toAgentModelListLike, Mt as DEFAULT_IDENTITY_FILENAME, N as resolveSessionFilePath, Nt as DEFAULT_SOUL_FILENAME, O as isMemoryMultimodalEnabled, On as parseAgentSessionKey, Ot as DEFAULT_AGENTS_FILENAME, P as resolveSessionFilePathOptions, Pt as DEFAULT_TOOLS_FILENAME, Q as runTasksWithConcurrency, Qt as isPathInside$2, R as resolveStorePath$1, Rt as loadWorkspaceBootstrapFiles, S as splitTextToUtf8ByteLimit, Sn as isBlockedObjectKey, St as resolveAgentWorkspaceDir, T as buildCaseInsensitiveExtensionGlob, Tn as isAcpSessionKey, Tt as resolveRunModelFallbacksOverride, U as copyFileWithinRoot, Ut as resolveWindowsCommandShim, V as SafeOpenError, Vt as runCommandWithTimeout, W as createRootScopedReadFile, Wt as spawnWithFallback, X as PATH_ALIAS_POLICIES, Xt as resolvePathViaExistingAncestorSync, Y as writeFileWithinRoot, Yt as openVerifiedFileSync, Z as assertNoPathAliasEscape, Zt as isNotFoundPathError, _ as remapChunkLines, _n as scopedHeartbeatWakeOptions, _t as resolveAgentConfig, a as listSessionFilesForAgent, an as DEFAULT_AGENT_ID, at as extensionForMime, b as estimateStructuredEmbeddingInputBytes, bn as normalizeAccountId$3, bt as resolveAgentModelFallbacksOverride, c as buildMultimodalChunkForIndexing, cn as buildAgentPeerSessionKey, ct as isAudioFileName, d as ensureDir$4, dn as isValidAgentId, dt as normalizeMimeType$1, en as normalizeSkillFilter, et as redactSensitiveText, f as hashText$1, fn as normalizeAgentId, ft as MAX_IMAGE_BYTES$1, g as parseEmbedding, gn as sanitizeAgentId, gt as listAgentIds, h as normalizeExtraMemoryPaths, hn as resolveThreadSessionKeys, ht as hasConfiguredModelFallbacks, i as buildSessionEntry, in as normalizeStringEntriesLower, it as detectMime, j as resolveAgentsDirFromSessionStorePath, jn as resolveAgentModelPrimaryValue, jt as DEFAULT_HEARTBEAT_FILENAME, k as normalizeMemoryMultimodalSettings, kn as resolveThreadParentSessionKey, kt as DEFAULT_AGENT_WORKSPACE_DIR, l as chunkMarkdown, lt as isGifMedia, m as listMemoryFiles, mn as resolveAgentIdFromSessionKey, mt as mediaKindFromMime, n as isQueryStopWordToken, nn as normalizeHyphenSlug, nt as compileSafeRegex, o as sessionPathForFile, on as DEFAULT_MAIN_KEY, ot as getFileExtension, p as isMemoryPath, pn as normalizeMainKey, pt as maxBytesForKind, q as readLocalFileSafely, qt as openBoundaryFile, r as requireNodeSqlite, rn as normalizeStringEntries, rt as testRegexWithBoundedInput, s as buildFileEntry, sn as buildAgentMainSessionKey, st as imageMimeFromFormat, t as extractKeywords, tn as normalizeAtHashSlug, tt as redactToolDetail, u as cosineSimilarity, un as classifySessionKeyShape, ut as kindFromMime, v as runWithConcurrency$1, vn as toAgentRequestSessionKey, vt as resolveAgentDir, w as statRegularFile, wn as getSubagentDepth, x as estimateUtf8Bytes, xn as normalizeOptionalAccountId, xt as resolveAgentSkillsFilter, y as hasNonTextEmbeddingParts, yn as DEFAULT_ACCOUNT_ID, yt as resolveAgentEffectiveModelPrimary, z as materializeWindowsSpawnProgram, zt as resolveOpenClawPackageRoot } from "./query-expansion-BMQzl41m.js";
|
|
5
|
+
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-BgPOyCXe.js";
|
|
6
|
+
import { c as makeProxyFetch, d as hasProxyEnvConfigured, f as bindAbortRelay, h as parseBooleanValue$1, l as resolveProxyFetchFromEnv, m as isTruthyEnvValue, n as resolveTelegramTransport, o as resolveFetch, p as fetchWithTimeout, r as shouldRetryTelegramIpv4Fallback, s as wrapFetchWithAbortSignal, t as resolveTelegramFetch, u as hasEnvHttpProxyConfigured } from "./fetch-Bdod8UI1.js";
|
|
7
7
|
import { n as recordCommandPoll, r as resetCommandPollCount } from "./command-poll-backoff-CnlBJLY5.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
|
-
import
|
|
9
|
+
import fsSync, { constants, existsSync, mkdirSync, mkdtempSync, promises, readFileSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
10
|
import os, { homedir } from "node:os";
|
|
11
11
|
import * as path$1 from "node:path";
|
|
12
12
|
import path, { isAbsolute, join, posix } from "node:path";
|
|
13
13
|
import JSON5 from "json5";
|
|
14
14
|
import util, { inspect, isDeepStrictEqual, promisify } from "node:util";
|
|
15
|
-
import * as fs$
|
|
16
|
-
import fs
|
|
15
|
+
import * as fs$1 from "node:fs/promises";
|
|
16
|
+
import fs, { appendFile, mkdir } from "node:fs/promises";
|
|
17
17
|
import { execFile, execFileSync, execSync, spawn, spawnSync } from "node:child_process";
|
|
18
18
|
import "node:process";
|
|
19
19
|
import { URL as URL$1, fileURLToPath } from "node:url";
|
|
@@ -4544,7 +4544,7 @@ function normalizeStringList$2(value) {
|
|
|
4544
4544
|
function resolvePluginManifestPath(rootDir) {
|
|
4545
4545
|
for (const filename of PLUGIN_MANIFEST_FILENAMES) {
|
|
4546
4546
|
const candidate = path.join(rootDir, filename);
|
|
4547
|
-
if (
|
|
4547
|
+
if (fsSync.existsSync(candidate)) return candidate;
|
|
4548
4548
|
}
|
|
4549
4549
|
return path.join(rootDir, PLUGIN_MANIFEST_FILENAME);
|
|
4550
4550
|
}
|
|
@@ -4570,7 +4570,7 @@ function loadPluginManifest(rootDir, rejectHardlinks = true) {
|
|
|
4570
4570
|
}
|
|
4571
4571
|
let raw;
|
|
4572
4572
|
try {
|
|
4573
|
-
raw = JSON.parse(
|
|
4573
|
+
raw = JSON.parse(fsSync.readFileSync(opened.fd, "utf-8"));
|
|
4574
4574
|
} catch (err) {
|
|
4575
4575
|
return {
|
|
4576
4576
|
ok: false,
|
|
@@ -4578,7 +4578,7 @@ function loadPluginManifest(rootDir, rejectHardlinks = true) {
|
|
|
4578
4578
|
manifestPath
|
|
4579
4579
|
};
|
|
4580
4580
|
} finally {
|
|
4581
|
-
|
|
4581
|
+
fsSync.closeSync(opened.fd);
|
|
4582
4582
|
}
|
|
4583
4583
|
if (!isRecord$7(raw)) return {
|
|
4584
4584
|
ok: false,
|
|
@@ -4658,7 +4658,7 @@ function safeRealpathSync$1(targetPath, cache) {
|
|
|
4658
4658
|
const cached = cache?.get(targetPath);
|
|
4659
4659
|
if (cached) return cached;
|
|
4660
4660
|
try {
|
|
4661
|
-
const resolved =
|
|
4661
|
+
const resolved = fsSync.realpathSync(targetPath);
|
|
4662
4662
|
cache?.set(targetPath, resolved);
|
|
4663
4663
|
return resolved;
|
|
4664
4664
|
} catch {
|
|
@@ -4667,7 +4667,7 @@ function safeRealpathSync$1(targetPath, cache) {
|
|
|
4667
4667
|
}
|
|
4668
4668
|
function safeStatSync(targetPath) {
|
|
4669
4669
|
try {
|
|
4670
|
-
return
|
|
4670
|
+
return fsSync.statSync(targetPath);
|
|
4671
4671
|
} catch {
|
|
4672
4672
|
return null;
|
|
4673
4673
|
}
|
|
@@ -4683,13 +4683,13 @@ function resolveBundledPluginsDir(env = process.env) {
|
|
|
4683
4683
|
try {
|
|
4684
4684
|
const execDir = path.dirname(process.execPath);
|
|
4685
4685
|
const sibling = path.join(execDir, "extensions");
|
|
4686
|
-
if (
|
|
4686
|
+
if (fsSync.existsSync(sibling)) return sibling;
|
|
4687
4687
|
} catch {}
|
|
4688
4688
|
try {
|
|
4689
4689
|
let cursor = path.dirname(fileURLToPath(import.meta.url));
|
|
4690
4690
|
for (let i = 0; i < 6; i += 1) {
|
|
4691
4691
|
const candidate = path.join(cursor, "extensions");
|
|
4692
|
-
if (
|
|
4692
|
+
if (fsSync.existsSync(candidate)) return candidate;
|
|
4693
4693
|
const parent = path.dirname(cursor);
|
|
4694
4694
|
if (parent === cursor) break;
|
|
4695
4695
|
cursor = parent;
|
|
@@ -4789,7 +4789,7 @@ function checkPathStatAndPermissions(params) {
|
|
|
4789
4789
|
};
|
|
4790
4790
|
let modeBits = stat.mode & 511;
|
|
4791
4791
|
if ((modeBits & 2) !== 0 && params.origin === "bundled") try {
|
|
4792
|
-
|
|
4792
|
+
fsSync.chmodSync(targetPath, modeBits & -19);
|
|
4793
4793
|
const repairedStat = safeStatSync(targetPath);
|
|
4794
4794
|
if (!repairedStat) return {
|
|
4795
4795
|
reason: "path_stat_failed",
|
|
@@ -4874,12 +4874,12 @@ function readPackageManifest(dir, rejectHardlinks = true) {
|
|
|
4874
4874
|
});
|
|
4875
4875
|
if (!opened.ok) return null;
|
|
4876
4876
|
try {
|
|
4877
|
-
const raw =
|
|
4877
|
+
const raw = fsSync.readFileSync(opened.fd, "utf-8");
|
|
4878
4878
|
return JSON.parse(raw);
|
|
4879
4879
|
} catch {
|
|
4880
4880
|
return null;
|
|
4881
4881
|
} finally {
|
|
4882
|
-
|
|
4882
|
+
fsSync.closeSync(opened.fd);
|
|
4883
4883
|
}
|
|
4884
4884
|
}
|
|
4885
4885
|
function deriveIdHint(params) {
|
|
@@ -4937,14 +4937,14 @@ function resolvePackageEntrySource(params) {
|
|
|
4937
4937
|
return null;
|
|
4938
4938
|
}
|
|
4939
4939
|
const safeSource = opened.path;
|
|
4940
|
-
|
|
4940
|
+
fsSync.closeSync(opened.fd);
|
|
4941
4941
|
return safeSource;
|
|
4942
4942
|
}
|
|
4943
4943
|
function discoverInDirectory(params) {
|
|
4944
|
-
if (!
|
|
4944
|
+
if (!fsSync.existsSync(params.dir)) return;
|
|
4945
4945
|
let entries = [];
|
|
4946
4946
|
try {
|
|
4947
|
-
entries =
|
|
4947
|
+
entries = fsSync.readdirSync(params.dir, { withFileTypes: true });
|
|
4948
4948
|
} catch (err) {
|
|
4949
4949
|
params.diagnostics.push({
|
|
4950
4950
|
level: "warn",
|
|
@@ -5005,7 +5005,7 @@ function discoverInDirectory(params) {
|
|
|
5005
5005
|
}
|
|
5006
5006
|
continue;
|
|
5007
5007
|
}
|
|
5008
|
-
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(fullPath, candidate)).find((candidate) =>
|
|
5008
|
+
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(fullPath, candidate)).find((candidate) => fsSync.existsSync(candidate));
|
|
5009
5009
|
if (indexFile && isExtensionFile(indexFile)) addCandidate({
|
|
5010
5010
|
candidates: params.candidates,
|
|
5011
5011
|
diagnostics: params.diagnostics,
|
|
@@ -5023,7 +5023,7 @@ function discoverInDirectory(params) {
|
|
|
5023
5023
|
}
|
|
5024
5024
|
function discoverFromPath(params) {
|
|
5025
5025
|
const resolved = resolveUserPath(params.rawPath, params.env);
|
|
5026
|
-
if (!
|
|
5026
|
+
if (!fsSync.existsSync(resolved)) {
|
|
5027
5027
|
params.diagnostics.push({
|
|
5028
5028
|
level: "error",
|
|
5029
5029
|
message: `plugin path not found: ${resolved}`,
|
|
@@ -5031,7 +5031,7 @@ function discoverFromPath(params) {
|
|
|
5031
5031
|
});
|
|
5032
5032
|
return;
|
|
5033
5033
|
}
|
|
5034
|
-
const stat =
|
|
5034
|
+
const stat = fsSync.statSync(resolved);
|
|
5035
5035
|
if (stat.isFile()) {
|
|
5036
5036
|
if (!isExtensionFile(resolved)) {
|
|
5037
5037
|
params.diagnostics.push({
|
|
@@ -5089,7 +5089,7 @@ function discoverFromPath(params) {
|
|
|
5089
5089
|
}
|
|
5090
5090
|
return;
|
|
5091
5091
|
}
|
|
5092
|
-
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(resolved, candidate)).find((candidate) =>
|
|
5092
|
+
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(resolved, candidate)).find((candidate) => fsSync.existsSync(candidate));
|
|
5093
5093
|
if (indexFile && isExtensionFile(indexFile)) {
|
|
5094
5094
|
addCandidate({
|
|
5095
5095
|
candidates: params.candidates,
|
|
@@ -5673,7 +5673,7 @@ function buildCacheKey$1(params) {
|
|
|
5673
5673
|
}
|
|
5674
5674
|
function safeStatMtimeMs(filePath) {
|
|
5675
5675
|
try {
|
|
5676
|
-
return
|
|
5676
|
+
return fsSync.statSync(filePath).mtimeMs;
|
|
5677
5677
|
} catch {
|
|
5678
5678
|
return null;
|
|
5679
5679
|
}
|
|
@@ -5986,7 +5986,7 @@ function resolveTimeoutMs$3(timeoutMs) {
|
|
|
5986
5986
|
function readEtcShells() {
|
|
5987
5987
|
if (cachedEtcShells !== void 0) return cachedEtcShells;
|
|
5988
5988
|
try {
|
|
5989
|
-
const entries =
|
|
5989
|
+
const entries = fsSync.readFileSync("/etc/shells", "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#") && path.isAbsolute(line));
|
|
5990
5990
|
cachedEtcShells = new Set(entries);
|
|
5991
5991
|
} catch {
|
|
5992
5992
|
cachedEtcShells = null;
|
|
@@ -6460,7 +6460,7 @@ function loadDotEnv(opts) {
|
|
|
6460
6460
|
const quiet = opts?.quiet ?? true;
|
|
6461
6461
|
dotenv.config({ quiet });
|
|
6462
6462
|
const globalEnvPath = path.join(resolveConfigDir(process.env), ".env");
|
|
6463
|
-
if (!
|
|
6463
|
+
if (!fsSync.existsSync(globalEnvPath)) return;
|
|
6464
6464
|
dotenv.config({
|
|
6465
6465
|
quiet,
|
|
6466
6466
|
path: globalEnvPath,
|
|
@@ -6803,7 +6803,7 @@ function resolveActiveTalkProviderConfig(talk) {
|
|
|
6803
6803
|
};
|
|
6804
6804
|
}
|
|
6805
6805
|
function readTalkApiKeyFromProfile(deps = {}) {
|
|
6806
|
-
const fsImpl = deps.fs ??
|
|
6806
|
+
const fsImpl = deps.fs ?? fsSync;
|
|
6807
6807
|
const osImpl = deps.os ?? os;
|
|
6808
6808
|
const pathImpl = deps.path ?? path;
|
|
6809
6809
|
const home = osImpl.homedir();
|
|
@@ -7456,7 +7456,7 @@ function isPathInside(basePath, candidatePath) {
|
|
|
7456
7456
|
}
|
|
7457
7457
|
function safeRealpathSync(filePath) {
|
|
7458
7458
|
try {
|
|
7459
|
-
return
|
|
7459
|
+
return fsSync.realpathSync(filePath);
|
|
7460
7460
|
} catch {
|
|
7461
7461
|
return null;
|
|
7462
7462
|
}
|
|
@@ -7563,7 +7563,7 @@ var IncludeProcessor = class IncludeProcessor {
|
|
|
7563
7563
|
const normalized = path.normalize(resolved);
|
|
7564
7564
|
if (!isPathInside(this.rootDir, normalized)) throw new ConfigIncludeError(`Include path escapes config directory: ${includePath} (root: ${this.rootDir})`, includePath);
|
|
7565
7565
|
try {
|
|
7566
|
-
const real =
|
|
7566
|
+
const real = fsSync.realpathSync(normalized);
|
|
7567
7567
|
if (!isPathInside(this.rootRealDir, real)) throw new ConfigIncludeError(`Include path resolves outside config directory (symlink): ${includePath} (root: ${this.rootDir})`, includePath);
|
|
7568
7568
|
} catch (err) {
|
|
7569
7569
|
if (err instanceof ConfigIncludeError) throw err;
|
|
@@ -7605,13 +7605,13 @@ var IncludeProcessor = class IncludeProcessor {
|
|
|
7605
7605
|
};
|
|
7606
7606
|
function safeRealpath(target) {
|
|
7607
7607
|
try {
|
|
7608
|
-
return
|
|
7608
|
+
return fsSync.realpathSync(target);
|
|
7609
7609
|
} catch {
|
|
7610
7610
|
return target;
|
|
7611
7611
|
}
|
|
7612
7612
|
}
|
|
7613
7613
|
function readConfigIncludeFileWithGuards(params) {
|
|
7614
|
-
const ioFs = params.ioFs ??
|
|
7614
|
+
const ioFs = params.ioFs ?? fsSync;
|
|
7615
7615
|
const maxBytes = params.maxBytes ?? 2097152;
|
|
7616
7616
|
if (!canUseBoundaryFileOpen(ioFs)) return ioFs.readFileSync(params.resolvedPath, "utf-8");
|
|
7617
7617
|
const opened = openBoundaryFileSync({
|
|
@@ -7634,7 +7634,7 @@ function readConfigIncludeFileWithGuards(params) {
|
|
|
7634
7634
|
}
|
|
7635
7635
|
}
|
|
7636
7636
|
const defaultResolver = {
|
|
7637
|
-
readFile: (p) =>
|
|
7637
|
+
readFile: (p) => fsSync.readFileSync(p, "utf-8"),
|
|
7638
7638
|
readFileWithGuards: ({ includePath, resolvedPath, rootRealDir }) => readConfigIncludeFileWithGuards({
|
|
7639
7639
|
includePath,
|
|
7640
7640
|
resolvedPath,
|
|
@@ -9272,7 +9272,7 @@ function normalizeMatchTarget(value) {
|
|
|
9272
9272
|
}
|
|
9273
9273
|
function tryRealpath$1(value) {
|
|
9274
9274
|
try {
|
|
9275
|
-
return
|
|
9275
|
+
return fsSync.realpathSync(value);
|
|
9276
9276
|
} catch {
|
|
9277
9277
|
return null;
|
|
9278
9278
|
}
|
|
@@ -9836,13 +9836,13 @@ function resolveWindowsExecutableExtSet(env) {
|
|
|
9836
9836
|
}
|
|
9837
9837
|
function isExecutableFile(filePath) {
|
|
9838
9838
|
try {
|
|
9839
|
-
if (!
|
|
9839
|
+
if (!fsSync.statSync(filePath).isFile()) return false;
|
|
9840
9840
|
if (process.platform === "win32") {
|
|
9841
9841
|
const ext = path.extname(filePath).toLowerCase();
|
|
9842
9842
|
if (!ext) return true;
|
|
9843
9843
|
return resolveWindowsExecutableExtSet(void 0).has(ext);
|
|
9844
9844
|
}
|
|
9845
|
-
|
|
9845
|
+
fsSync.accessSync(filePath, fsSync.constants.X_OK);
|
|
9846
9846
|
return true;
|
|
9847
9847
|
} catch {
|
|
9848
9848
|
return false;
|
|
@@ -9880,7 +9880,7 @@ const DEFAULT_SAFE_BINS = [
|
|
|
9880
9880
|
function tryResolveRealpath(filePath) {
|
|
9881
9881
|
if (!filePath) return;
|
|
9882
9882
|
try {
|
|
9883
|
-
return
|
|
9883
|
+
return fsSync.realpathSync(filePath);
|
|
9884
9884
|
} catch {
|
|
9885
9885
|
return;
|
|
9886
9886
|
}
|
|
@@ -10760,7 +10760,7 @@ function listWritableExplicitTrustedSafeBinDirs(entries) {
|
|
|
10760
10760
|
for (const dir of resolved) {
|
|
10761
10761
|
let stat;
|
|
10762
10762
|
try {
|
|
10763
|
-
stat =
|
|
10763
|
+
stat = fsSync.statSync(dir);
|
|
10764
10764
|
} catch {
|
|
10765
10765
|
continue;
|
|
10766
10766
|
}
|
|
@@ -16160,7 +16160,7 @@ function resolveConfigPathForDeps(deps) {
|
|
|
16160
16160
|
}
|
|
16161
16161
|
function normalizeDeps(overrides = {}) {
|
|
16162
16162
|
return {
|
|
16163
|
-
fs: overrides.fs ??
|
|
16163
|
+
fs: overrides.fs ?? fsSync,
|
|
16164
16164
|
json5: overrides.json5 ?? JSON5,
|
|
16165
16165
|
env: overrides.env ?? process.env,
|
|
16166
16166
|
homedir: overrides.homedir ?? (() => resolveRequiredHomeDir(overrides.env ?? process.env, os.homedir)),
|
|
@@ -16990,7 +16990,7 @@ async function planOpenClawModelsJson(params) {
|
|
|
16990
16990
|
const MODELS_JSON_WRITE_LOCKS = /* @__PURE__ */ new Map();
|
|
16991
16991
|
async function readExistingModelsFile(pathname) {
|
|
16992
16992
|
try {
|
|
16993
|
-
const raw = await fs
|
|
16993
|
+
const raw = await fs.readFile(pathname, "utf8");
|
|
16994
16994
|
return {
|
|
16995
16995
|
raw,
|
|
16996
16996
|
parsed: JSON.parse(raw)
|
|
@@ -17003,12 +17003,12 @@ async function readExistingModelsFile(pathname) {
|
|
|
17003
17003
|
}
|
|
17004
17004
|
}
|
|
17005
17005
|
async function ensureModelsFileMode(pathname) {
|
|
17006
|
-
await fs
|
|
17006
|
+
await fs.chmod(pathname, 384).catch(() => {});
|
|
17007
17007
|
}
|
|
17008
17008
|
async function writeModelsFileAtomic(targetPath, contents) {
|
|
17009
17009
|
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp`;
|
|
17010
|
-
await fs
|
|
17011
|
-
await fs
|
|
17010
|
+
await fs.writeFile(tempPath, contents, { mode: 384 });
|
|
17011
|
+
await fs.rename(tempPath, targetPath);
|
|
17012
17012
|
}
|
|
17013
17013
|
function resolveModelsConfigInput(config) {
|
|
17014
17014
|
const runtimeSource = getRuntimeConfigSourceSnapshot();
|
|
@@ -17072,7 +17072,7 @@ async function ensureOpenClawModelsJson(config, agentDirOverride) {
|
|
|
17072
17072
|
wrote: false
|
|
17073
17073
|
};
|
|
17074
17074
|
}
|
|
17075
|
-
await fs
|
|
17075
|
+
await fs.mkdir(agentDir, {
|
|
17076
17076
|
recursive: true,
|
|
17077
17077
|
mode: 448
|
|
17078
17078
|
});
|
|
@@ -17089,7 +17089,7 @@ async function ensureOpenClawModelsJson(config, agentDirOverride) {
|
|
|
17089
17089
|
const log$41 = createSubsystemLogger("model-catalog");
|
|
17090
17090
|
let modelCatalogPromise = null;
|
|
17091
17091
|
let hasLoggedModelCatalogError = false;
|
|
17092
|
-
const defaultImportPiSdk = () => import("./pi-model-discovery-runtime-
|
|
17092
|
+
const defaultImportPiSdk = () => import("./pi-model-discovery-runtime-CLfgSk3o.js");
|
|
17093
17093
|
let importPiSdk = defaultImportPiSdk;
|
|
17094
17094
|
const CODEX_PROVIDER = "openai-codex";
|
|
17095
17095
|
const OPENAI_PROVIDER = "openai";
|
|
@@ -18148,7 +18148,7 @@ var MediaAttachmentCache = class {
|
|
|
18148
18148
|
const size = await this.ensureLocalStat(entry);
|
|
18149
18149
|
if (entry.resolvedPath) {
|
|
18150
18150
|
if (size !== void 0 && size > params.maxBytes) throw new MediaUnderstandingSkipError("maxBytes", `Attachment ${params.attachmentIndex + 1} exceeds maxBytes ${params.maxBytes}`);
|
|
18151
|
-
const buffer = await fs
|
|
18151
|
+
const buffer = await fs.readFile(entry.resolvedPath);
|
|
18152
18152
|
entry.buffer = buffer;
|
|
18153
18153
|
entry.bufferMime = entry.bufferMime ?? entry.attachment.mime ?? await detectMime({
|
|
18154
18154
|
buffer,
|
|
@@ -18218,10 +18218,10 @@ var MediaAttachmentCache = class {
|
|
|
18218
18218
|
prefix: "openclaw-media",
|
|
18219
18219
|
extension: path.extname(bufferResult.fileName || "") || ""
|
|
18220
18220
|
});
|
|
18221
|
-
await fs
|
|
18221
|
+
await fs.writeFile(tmpPath, bufferResult.buffer);
|
|
18222
18222
|
entry.tempPath = tmpPath;
|
|
18223
18223
|
entry.tempCleanup = async () => {
|
|
18224
|
-
await fs
|
|
18224
|
+
await fs.unlink(tmpPath).catch(() => {});
|
|
18225
18225
|
};
|
|
18226
18226
|
return {
|
|
18227
18227
|
path: tmpPath,
|
|
@@ -18268,12 +18268,12 @@ var MediaAttachmentCache = class {
|
|
|
18268
18268
|
if (entry.statSize !== void 0) return entry.statSize;
|
|
18269
18269
|
try {
|
|
18270
18270
|
const currentPath = entry.resolvedPath;
|
|
18271
|
-
const stat = await fs
|
|
18271
|
+
const stat = await fs.stat(currentPath);
|
|
18272
18272
|
if (!stat.isFile()) {
|
|
18273
18273
|
entry.resolvedPath = void 0;
|
|
18274
18274
|
return;
|
|
18275
18275
|
}
|
|
18276
|
-
const canonicalPath = await fs
|
|
18276
|
+
const canonicalPath = await fs.realpath(currentPath).catch(() => currentPath);
|
|
18277
18277
|
if (!isInboundPathAllowed({
|
|
18278
18278
|
filePath: canonicalPath,
|
|
18279
18279
|
roots: await this.getCanonicalLocalPathRoots()
|
|
@@ -18295,7 +18295,7 @@ var MediaAttachmentCache = class {
|
|
|
18295
18295
|
if (this.canonicalLocalPathRoots) return await this.canonicalLocalPathRoots;
|
|
18296
18296
|
this.canonicalLocalPathRoots = (async () => mergeInboundPathRoots(this.localPathRoots, await Promise.all(this.localPathRoots.map(async (root) => {
|
|
18297
18297
|
if (root.includes("*")) return root;
|
|
18298
|
-
return await fs
|
|
18298
|
+
return await fs.realpath(root).catch(() => root);
|
|
18299
18299
|
}))))();
|
|
18300
18300
|
return await this.canonicalLocalPathRoots;
|
|
18301
18301
|
}
|
|
@@ -18366,7 +18366,7 @@ const MIN_AUDIO_FILE_BYTES = 1024;
|
|
|
18366
18366
|
async function fileExists$1(filePath) {
|
|
18367
18367
|
if (!filePath) return false;
|
|
18368
18368
|
try {
|
|
18369
|
-
await fs
|
|
18369
|
+
await fs.stat(filePath);
|
|
18370
18370
|
return true;
|
|
18371
18371
|
} catch {
|
|
18372
18372
|
return false;
|
|
@@ -18666,10 +18666,10 @@ function clampToBudget(content, budget) {
|
|
|
18666
18666
|
async function ensureSessionHeader$1(params) {
|
|
18667
18667
|
const file = params.sessionFile;
|
|
18668
18668
|
try {
|
|
18669
|
-
await fs
|
|
18669
|
+
await fs.stat(file);
|
|
18670
18670
|
return;
|
|
18671
18671
|
} catch {}
|
|
18672
|
-
await fs
|
|
18672
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
18673
18673
|
const entry = {
|
|
18674
18674
|
type: "session",
|
|
18675
18675
|
version: 2,
|
|
@@ -18677,7 +18677,7 @@ async function ensureSessionHeader$1(params) {
|
|
|
18677
18677
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18678
18678
|
cwd: params.cwd
|
|
18679
18679
|
};
|
|
18680
|
-
await fs
|
|
18680
|
+
await fs.writeFile(file, `${JSON.stringify(entry)}\n`, "utf-8");
|
|
18681
18681
|
}
|
|
18682
18682
|
function buildBootstrapContextFiles(files, opts) {
|
|
18683
18683
|
const maxChars = opts?.maxChars ?? 2e4;
|
|
@@ -20161,7 +20161,7 @@ function formatWindowsAclSummary(summary) {
|
|
|
20161
20161
|
//#region src/security/audit-fs.ts
|
|
20162
20162
|
async function safeStat(targetPath) {
|
|
20163
20163
|
try {
|
|
20164
|
-
const lst = await fs
|
|
20164
|
+
const lst = await fs.lstat(targetPath);
|
|
20165
20165
|
return {
|
|
20166
20166
|
ok: true,
|
|
20167
20167
|
isSymlink: lst.isSymbolicLink(),
|
|
@@ -20200,7 +20200,7 @@ async function inspectPathPermissions(targetPath, opts) {
|
|
|
20200
20200
|
let effectiveMode = st.mode;
|
|
20201
20201
|
let effectiveIsDir = st.isDir;
|
|
20202
20202
|
if (st.isSymlink) try {
|
|
20203
|
-
const target = await fs
|
|
20203
|
+
const target = await fs.stat(targetPath);
|
|
20204
20204
|
effectiveMode = typeof target.mode === "number" ? target.mode : st.mode;
|
|
20205
20205
|
effectiveIsDir = target.isDirectory();
|
|
20206
20206
|
} catch {}
|
|
@@ -20427,7 +20427,7 @@ async function assertSecurePath(params) {
|
|
|
20427
20427
|
if (stat.isSymlink) {
|
|
20428
20428
|
if (!params.allowSymlinkPath) throw new Error(`${params.label} must not be a symlink: ${effectivePath}`);
|
|
20429
20429
|
try {
|
|
20430
|
-
effectivePath = await fs
|
|
20430
|
+
effectivePath = await fs.realpath(effectivePath);
|
|
20431
20431
|
} catch {
|
|
20432
20432
|
throw new Error(`${params.label} symlink target is not readable: ${params.targetPath}`);
|
|
20433
20433
|
}
|
|
@@ -20473,7 +20473,7 @@ async function readFileProviderPayload(params) {
|
|
|
20473
20473
|
}, timeoutMs);
|
|
20474
20474
|
});
|
|
20475
20475
|
try {
|
|
20476
|
-
const payload = await Promise.race([fs
|
|
20476
|
+
const payload = await Promise.race([fs.readFile(secureFilePath, { signal: abortController.signal }), timeoutPromise]);
|
|
20477
20477
|
if (payload.byteLength > maxBytes) throw new Error(`File provider "${params.providerName}" exceeded maxBytes (${maxBytes}).`);
|
|
20478
20478
|
const text = payload.toString("utf8");
|
|
20479
20479
|
if (params.providerConfig.mode === "singleValue") return text.replace(/\r?\n$/, "");
|
|
@@ -21290,7 +21290,7 @@ function hasBinary$1(bin) {
|
|
|
21290
21290
|
for (const part of parts) for (const ext of extensions) {
|
|
21291
21291
|
const candidate = path.join(part, bin + ext);
|
|
21292
21292
|
try {
|
|
21293
|
-
|
|
21293
|
+
fsSync.accessSync(candidate, fsSync.constants.X_OK);
|
|
21294
21294
|
hasBinaryCache.set(bin, true);
|
|
21295
21295
|
return true;
|
|
21296
21296
|
} catch {}
|
|
@@ -22119,13 +22119,13 @@ function shortPath(value) {
|
|
|
22119
22119
|
//#region src/agents/skills/bundled-dir.ts
|
|
22120
22120
|
function looksLikeSkillsDir(dir) {
|
|
22121
22121
|
try {
|
|
22122
|
-
const entries =
|
|
22122
|
+
const entries = fsSync.readdirSync(dir, { withFileTypes: true });
|
|
22123
22123
|
for (const entry of entries) {
|
|
22124
22124
|
if (entry.name.startsWith(".")) continue;
|
|
22125
22125
|
const fullPath = path.join(dir, entry.name);
|
|
22126
22126
|
if (entry.isFile() && entry.name.endsWith(".md")) return true;
|
|
22127
22127
|
if (entry.isDirectory()) {
|
|
22128
|
-
if (
|
|
22128
|
+
if (fsSync.existsSync(path.join(fullPath, "SKILL.md"))) return true;
|
|
22129
22129
|
}
|
|
22130
22130
|
}
|
|
22131
22131
|
} catch {
|
|
@@ -22140,7 +22140,7 @@ function resolveBundledSkillsDir(opts = {}) {
|
|
|
22140
22140
|
const execPath = opts.execPath ?? process.execPath;
|
|
22141
22141
|
const execDir = path.dirname(execPath);
|
|
22142
22142
|
const sibling = path.join(execDir, "skills");
|
|
22143
|
-
if (
|
|
22143
|
+
if (fsSync.existsSync(sibling)) return sibling;
|
|
22144
22144
|
} catch {}
|
|
22145
22145
|
try {
|
|
22146
22146
|
const moduleUrl = opts.moduleUrl ?? import.meta.url;
|
|
@@ -22202,7 +22202,7 @@ function resolvePluginSkillDirs(params) {
|
|
|
22202
22202
|
const trimmed = raw.trim();
|
|
22203
22203
|
if (!trimmed) continue;
|
|
22204
22204
|
const candidate = path.resolve(record.rootDir, trimmed);
|
|
22205
|
-
if (!
|
|
22205
|
+
if (!fsSync.existsSync(candidate)) {
|
|
22206
22206
|
log$39.warn(`plugin skill path not found (${record.id}): ${candidate}`);
|
|
22207
22207
|
continue;
|
|
22208
22208
|
}
|
|
@@ -22231,7 +22231,7 @@ async function serializeByKey(key, task) {
|
|
|
22231
22231
|
}
|
|
22232
22232
|
//#endregion
|
|
22233
22233
|
//#region src/agents/skills/workspace.ts
|
|
22234
|
-
const fsp =
|
|
22234
|
+
const fsp = fsSync.promises;
|
|
22235
22235
|
const skillsLogger = createSubsystemLogger("skills");
|
|
22236
22236
|
const skillCommandDebugOnce = /* @__PURE__ */ new Set();
|
|
22237
22237
|
/**
|
|
@@ -22308,7 +22308,7 @@ function resolveSkillsLimits(config) {
|
|
|
22308
22308
|
}
|
|
22309
22309
|
function listChildDirectories(dir) {
|
|
22310
22310
|
try {
|
|
22311
|
-
const entries =
|
|
22311
|
+
const entries = fsSync.readdirSync(dir, { withFileTypes: true });
|
|
22312
22312
|
const dirs = [];
|
|
22313
22313
|
for (const entry of entries) {
|
|
22314
22314
|
if (entry.name.startsWith(".")) continue;
|
|
@@ -22319,7 +22319,7 @@ function listChildDirectories(dir) {
|
|
|
22319
22319
|
continue;
|
|
22320
22320
|
}
|
|
22321
22321
|
if (entry.isSymbolicLink()) try {
|
|
22322
|
-
if (
|
|
22322
|
+
if (fsSync.statSync(fullPath).isDirectory()) dirs.push(entry.name);
|
|
22323
22323
|
} catch {}
|
|
22324
22324
|
}
|
|
22325
22325
|
return dirs;
|
|
@@ -22329,7 +22329,7 @@ function listChildDirectories(dir) {
|
|
|
22329
22329
|
}
|
|
22330
22330
|
function tryRealpath(filePath) {
|
|
22331
22331
|
try {
|
|
22332
|
-
return
|
|
22332
|
+
return fsSync.realpathSync(filePath);
|
|
22333
22333
|
} catch {
|
|
22334
22334
|
return null;
|
|
22335
22335
|
}
|
|
@@ -22374,7 +22374,7 @@ function filterLoadedSkillsInsideRoot(params) {
|
|
|
22374
22374
|
function resolveNestedSkillsRoot(dir, opts) {
|
|
22375
22375
|
const nested = path.join(dir, "skills");
|
|
22376
22376
|
try {
|
|
22377
|
-
if (!
|
|
22377
|
+
if (!fsSync.existsSync(nested) || !fsSync.statSync(nested).isDirectory()) return { baseDir: dir };
|
|
22378
22378
|
} catch {
|
|
22379
22379
|
return { baseDir: dir };
|
|
22380
22380
|
}
|
|
@@ -22383,7 +22383,7 @@ function resolveNestedSkillsRoot(dir, opts) {
|
|
|
22383
22383
|
const toScan = scanLimit === 0 ? [] : nestedDirs.slice(0, Math.min(nestedDirs.length, scanLimit));
|
|
22384
22384
|
for (const name of toScan) {
|
|
22385
22385
|
const skillMd = path.join(nested, name, "SKILL.md");
|
|
22386
|
-
if (
|
|
22386
|
+
if (fsSync.existsSync(skillMd)) return {
|
|
22387
22387
|
baseDir: nested,
|
|
22388
22388
|
note: `Detected nested skills root at ${nested}`
|
|
22389
22389
|
};
|
|
@@ -22412,7 +22412,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
22412
22412
|
});
|
|
22413
22413
|
if (!baseDirRealPath) return [];
|
|
22414
22414
|
const rootSkillMd = path.join(baseDir, "SKILL.md");
|
|
22415
|
-
if (
|
|
22415
|
+
if (fsSync.existsSync(rootSkillMd)) {
|
|
22416
22416
|
const rootSkillRealPath = resolveContainedSkillPath({
|
|
22417
22417
|
source: params.source,
|
|
22418
22418
|
rootDir,
|
|
@@ -22421,7 +22421,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
22421
22421
|
});
|
|
22422
22422
|
if (!rootSkillRealPath) return [];
|
|
22423
22423
|
try {
|
|
22424
|
-
const size =
|
|
22424
|
+
const size = fsSync.statSync(rootSkillRealPath).size;
|
|
22425
22425
|
if (size > limits.maxSkillFileBytes) {
|
|
22426
22426
|
skillsLogger.warn("Skipping skills root due to oversized SKILL.md.", {
|
|
22427
22427
|
dir: baseDir,
|
|
@@ -22471,7 +22471,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
22471
22471
|
candidatePath: skillDir
|
|
22472
22472
|
})) continue;
|
|
22473
22473
|
const skillMd = path.join(skillDir, "SKILL.md");
|
|
22474
|
-
if (!
|
|
22474
|
+
if (!fsSync.existsSync(skillMd)) continue;
|
|
22475
22475
|
const skillMdRealPath = resolveContainedSkillPath({
|
|
22476
22476
|
source: params.source,
|
|
22477
22477
|
rootDir,
|
|
@@ -22480,7 +22480,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
22480
22480
|
});
|
|
22481
22481
|
if (!skillMdRealPath) continue;
|
|
22482
22482
|
try {
|
|
22483
|
-
const size =
|
|
22483
|
+
const size = fsSync.statSync(skillMdRealPath).size;
|
|
22484
22484
|
if (size > limits.maxSkillFileBytes) {
|
|
22485
22485
|
skillsLogger.warn("Skipping skill due to oversized SKILL.md.", {
|
|
22486
22486
|
skill: name,
|
|
@@ -22553,7 +22553,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
22553
22553
|
return Array.from(merged.values()).map((skill) => {
|
|
22554
22554
|
let frontmatter = {};
|
|
22555
22555
|
try {
|
|
22556
|
-
frontmatter = parseFrontmatter(
|
|
22556
|
+
frontmatter = parseFrontmatter(fsSync.readFileSync(skill.filePath, "utf-8"));
|
|
22557
22557
|
} catch {}
|
|
22558
22558
|
return {
|
|
22559
22559
|
skill,
|
|
@@ -23096,12 +23096,12 @@ async function callTool(profileName, name, args = {}) {
|
|
|
23096
23096
|
return result;
|
|
23097
23097
|
}
|
|
23098
23098
|
async function withTempFile(fn) {
|
|
23099
|
-
const dir = await fs
|
|
23099
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-chrome-mcp-"));
|
|
23100
23100
|
const filePath = path.join(dir, randomUUID());
|
|
23101
23101
|
try {
|
|
23102
23102
|
return await fn(filePath);
|
|
23103
23103
|
} finally {
|
|
23104
|
-
await fs
|
|
23104
|
+
await fs.rm(dir, {
|
|
23105
23105
|
recursive: true,
|
|
23106
23106
|
force: true
|
|
23107
23107
|
}).catch(() => {});
|
|
@@ -23173,7 +23173,7 @@ async function takeChromeMcpScreenshot(params) {
|
|
|
23173
23173
|
...params.uid ? { uid: params.uid } : {},
|
|
23174
23174
|
...params.fullPage ? { fullPage: true } : {}
|
|
23175
23175
|
});
|
|
23176
|
-
return await fs
|
|
23176
|
+
return await fs.readFile(filePath);
|
|
23177
23177
|
});
|
|
23178
23178
|
}
|
|
23179
23179
|
async function clickChromeMcpElement(params) {
|
|
@@ -23351,7 +23351,7 @@ function isModuleNotFoundError(err) {
|
|
|
23351
23351
|
}
|
|
23352
23352
|
async function loadPwAiModule(mode) {
|
|
23353
23353
|
try {
|
|
23354
|
-
return await import("./pw-ai-
|
|
23354
|
+
return await import("./pw-ai-BZnl84YT.js");
|
|
23355
23355
|
} catch (err) {
|
|
23356
23356
|
if (mode === "soft") return null;
|
|
23357
23357
|
if (isModuleNotFoundError(err)) return null;
|
|
@@ -23519,28 +23519,28 @@ function invalidPath(scopeLabel) {
|
|
|
23519
23519
|
}
|
|
23520
23520
|
async function resolveRealPathIfExists(targetPath) {
|
|
23521
23521
|
try {
|
|
23522
|
-
return await fs
|
|
23522
|
+
return await fs.realpath(targetPath);
|
|
23523
23523
|
} catch {
|
|
23524
23524
|
return;
|
|
23525
23525
|
}
|
|
23526
23526
|
}
|
|
23527
23527
|
async function resolveTrustedRootRealPath(rootDir) {
|
|
23528
23528
|
try {
|
|
23529
|
-
const rootLstat = await fs
|
|
23529
|
+
const rootLstat = await fs.lstat(rootDir);
|
|
23530
23530
|
if (!rootLstat.isDirectory() || rootLstat.isSymbolicLink()) return;
|
|
23531
|
-
return await fs
|
|
23531
|
+
return await fs.realpath(rootDir);
|
|
23532
23532
|
} catch {
|
|
23533
23533
|
return;
|
|
23534
23534
|
}
|
|
23535
23535
|
}
|
|
23536
23536
|
async function validateCanonicalPathWithinRoot(params) {
|
|
23537
23537
|
try {
|
|
23538
|
-
const candidateLstat = await fs
|
|
23538
|
+
const candidateLstat = await fs.lstat(params.candidatePath);
|
|
23539
23539
|
if (candidateLstat.isSymbolicLink()) return "invalid";
|
|
23540
23540
|
if (params.expect === "directory" && !candidateLstat.isDirectory()) return "invalid";
|
|
23541
23541
|
if (params.expect === "file" && !candidateLstat.isFile()) return "invalid";
|
|
23542
23542
|
if (params.expect === "file" && candidateLstat.nlink > 1) return "invalid";
|
|
23543
|
-
const candidateRealPath = await fs
|
|
23543
|
+
const candidateRealPath = await fs.realpath(params.candidatePath);
|
|
23544
23544
|
return isPathInside$2(params.rootRealPath, candidateRealPath) ? "ok" : "invalid";
|
|
23545
23545
|
} catch (err) {
|
|
23546
23546
|
return isNotFoundPathError(err) ? "not-found" : "invalid";
|
|
@@ -23618,7 +23618,7 @@ async function resolveCheckedPathsWithinRoot(params) {
|
|
|
23618
23618
|
};
|
|
23619
23619
|
if (!rootRealPath || !raw || !path.isAbsolute(raw)) return lexicalPathResult;
|
|
23620
23620
|
try {
|
|
23621
|
-
const resolvedExistingPath = await fs
|
|
23621
|
+
const resolvedExistingPath = await fs.realpath(raw);
|
|
23622
23622
|
const relativePath = path.relative(rootRealPath, resolvedExistingPath);
|
|
23623
23623
|
if (!isInRoot(relativePath)) return lexicalPathResult;
|
|
23624
23624
|
return {
|
|
@@ -23669,7 +23669,7 @@ async function resolveCheckedPathsWithinRoot(params) {
|
|
|
23669
23669
|
//#endregion
|
|
23670
23670
|
//#region src/browser/routes/output-paths.ts
|
|
23671
23671
|
async function ensureOutputRootDir(rootDir) {
|
|
23672
|
-
await fs
|
|
23672
|
+
await fs.mkdir(rootDir, { recursive: true });
|
|
23673
23673
|
}
|
|
23674
23674
|
async function resolveWritableOutputPathOrRespond(params) {
|
|
23675
23675
|
if (params.ensureRootDir) await ensureOutputRootDir(params.rootDir);
|
|
@@ -24969,7 +24969,7 @@ function getMediaDir() {
|
|
|
24969
24969
|
}
|
|
24970
24970
|
async function ensureMediaDir() {
|
|
24971
24971
|
const mediaDir = resolveMediaDir();
|
|
24972
|
-
await fs
|
|
24972
|
+
await fs.mkdir(mediaDir, {
|
|
24973
24973
|
recursive: true,
|
|
24974
24974
|
mode: 448
|
|
24975
24975
|
});
|
|
@@ -24983,7 +24983,7 @@ async function retryAfterRecreatingDir(dir, run) {
|
|
|
24983
24983
|
return await run();
|
|
24984
24984
|
} catch (err) {
|
|
24985
24985
|
if (!isMissingPathError$1(err)) throw err;
|
|
24986
|
-
await fs
|
|
24986
|
+
await fs.mkdir(dir, {
|
|
24987
24987
|
recursive: true,
|
|
24988
24988
|
mode: 448
|
|
24989
24989
|
});
|
|
@@ -25006,13 +25006,13 @@ function buildSavedMediaResult(params) {
|
|
|
25006
25006
|
}
|
|
25007
25007
|
async function writeSavedMediaBuffer(params) {
|
|
25008
25008
|
const dest = path.join(params.dir, params.id);
|
|
25009
|
-
await retryAfterRecreatingDir(params.dir, () => fs
|
|
25009
|
+
await retryAfterRecreatingDir(params.dir, () => fs.writeFile(dest, params.buffer, { mode: MEDIA_FILE_MODE }));
|
|
25010
25010
|
return dest;
|
|
25011
25011
|
}
|
|
25012
25012
|
async function saveMediaBuffer(buffer, contentType, subdir = "inbound", maxBytes = MAX_BYTES, originalFilename) {
|
|
25013
25013
|
if (buffer.byteLength > maxBytes) throw new Error(`Media exceeds ${(maxBytes / (1024 * 1024)).toFixed(0)}MB limit`);
|
|
25014
25014
|
const dir = path.join(resolveMediaDir(), subdir);
|
|
25015
|
-
await fs
|
|
25015
|
+
await fs.mkdir(dir, {
|
|
25016
25016
|
recursive: true,
|
|
25017
25017
|
mode: 448
|
|
25018
25018
|
});
|
|
@@ -25488,7 +25488,7 @@ function formatPortDiagnostics(diagnostics) {
|
|
|
25488
25488
|
const LSOF_CANDIDATES = process.platform === "darwin" ? ["/usr/sbin/lsof", "/usr/bin/lsof"] : ["/usr/bin/lsof", "/usr/sbin/lsof"];
|
|
25489
25489
|
async function canExecute(path) {
|
|
25490
25490
|
try {
|
|
25491
|
-
await fs
|
|
25491
|
+
await fs.access(path, fsSync.constants.X_OK);
|
|
25492
25492
|
return true;
|
|
25493
25493
|
} catch {
|
|
25494
25494
|
return false;
|
|
@@ -25500,7 +25500,7 @@ async function resolveLsofCommand() {
|
|
|
25500
25500
|
}
|
|
25501
25501
|
function resolveLsofCommandSync() {
|
|
25502
25502
|
for (const candidate of LSOF_CANDIDATES) try {
|
|
25503
|
-
|
|
25503
|
+
fsSync.accessSync(candidate, fsSync.constants.X_OK);
|
|
25504
25504
|
return candidate;
|
|
25505
25505
|
} catch {}
|
|
25506
25506
|
return "lsof";
|
|
@@ -25910,7 +25910,7 @@ const CHROMIUM_EXE_NAMES = new Set([
|
|
|
25910
25910
|
]);
|
|
25911
25911
|
function exists$1(filePath) {
|
|
25912
25912
|
try {
|
|
25913
|
-
return
|
|
25913
|
+
return fsSync.existsSync(filePath);
|
|
25914
25914
|
} catch {
|
|
25915
25915
|
return false;
|
|
25916
25916
|
}
|
|
@@ -26053,7 +26053,7 @@ function findDesktopFilePath(desktopId) {
|
|
|
26053
26053
|
}
|
|
26054
26054
|
function readDesktopExecLine(desktopPath) {
|
|
26055
26055
|
try {
|
|
26056
|
-
const lines =
|
|
26056
|
+
const lines = fsSync.readFileSync(desktopPath, "utf8").split(/\r?\n/);
|
|
26057
26057
|
for (const line of lines) if (line.startsWith("Exec=")) return line.slice(5).trim();
|
|
26058
26058
|
} catch {}
|
|
26059
26059
|
return null;
|
|
@@ -26312,8 +26312,8 @@ function decoratedMarkerPath(userDataDir) {
|
|
|
26312
26312
|
}
|
|
26313
26313
|
function safeReadJson(filePath) {
|
|
26314
26314
|
try {
|
|
26315
|
-
if (!
|
|
26316
|
-
const raw =
|
|
26315
|
+
if (!fsSync.existsSync(filePath)) return null;
|
|
26316
|
+
const raw = fsSync.readFileSync(filePath, "utf-8");
|
|
26317
26317
|
const parsed = JSON.parse(raw);
|
|
26318
26318
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
26319
26319
|
return parsed;
|
|
@@ -26322,8 +26322,8 @@ function safeReadJson(filePath) {
|
|
|
26322
26322
|
}
|
|
26323
26323
|
}
|
|
26324
26324
|
function safeWriteJson(filePath, data) {
|
|
26325
|
-
|
|
26326
|
-
|
|
26325
|
+
fsSync.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
26326
|
+
fsSync.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
26327
26327
|
}
|
|
26328
26328
|
function setDeep(obj, keys, value) {
|
|
26329
26329
|
let node = obj;
|
|
@@ -26450,7 +26450,7 @@ function decorateOpenClawProfile(userDataDir, opts) {
|
|
|
26450
26450
|
}
|
|
26451
26451
|
safeWriteJson(preferencesPath, prefs);
|
|
26452
26452
|
try {
|
|
26453
|
-
|
|
26453
|
+
fsSync.writeFileSync(decoratedMarkerPath(userDataDir), `${Date.now()}\n`, "utf-8");
|
|
26454
26454
|
} catch {}
|
|
26455
26455
|
}
|
|
26456
26456
|
function ensureProfileCleanExit(userDataDir) {
|
|
@@ -26465,7 +26465,7 @@ function ensureProfileCleanExit(userDataDir) {
|
|
|
26465
26465
|
const log$38 = createSubsystemLogger("browser").child("chrome");
|
|
26466
26466
|
function exists(filePath) {
|
|
26467
26467
|
try {
|
|
26468
|
-
return
|
|
26468
|
+
return fsSync.existsSync(filePath);
|
|
26469
26469
|
} catch {
|
|
26470
26470
|
return false;
|
|
26471
26471
|
}
|
|
@@ -26577,7 +26577,7 @@ async function launchOpenClawChrome(resolved, profile) {
|
|
|
26577
26577
|
const exe = resolveBrowserExecutable(resolved);
|
|
26578
26578
|
if (!exe) throw new Error("No supported browser found (Chrome/Brave/Edge/Chromium on macOS, Linux, or Windows).");
|
|
26579
26579
|
const userDataDir = resolveOpenClawUserDataDir(profile.name);
|
|
26580
|
-
|
|
26580
|
+
fsSync.mkdirSync(userDataDir, { recursive: true });
|
|
26581
26581
|
const needsDecorate = !isProfileDecorated(userDataDir, profile.name, (profile.color ?? "#FF4500").toUpperCase());
|
|
26582
26582
|
const spawnOnce = () => {
|
|
26583
26583
|
const args = [
|
|
@@ -27582,7 +27582,7 @@ function createProfileAvailability({ opts, profile, state, getProfileState, setP
|
|
|
27582
27582
|
};
|
|
27583
27583
|
const closePlaywrightBrowserConnectionForProfile = async (cdpUrl) => {
|
|
27584
27584
|
try {
|
|
27585
|
-
await (await import("./pw-ai-
|
|
27585
|
+
await (await import("./pw-ai-BZnl84YT.js")).closePlaywrightBrowserConnection(cdpUrl ? { cdpUrl } : void 0);
|
|
27586
27586
|
} catch {}
|
|
27587
27587
|
};
|
|
27588
27588
|
const reconcileProfileRuntime = async () => {
|
|
@@ -27697,11 +27697,11 @@ async function movePathToTrash(targetPath) {
|
|
|
27697
27697
|
return targetPath;
|
|
27698
27698
|
} catch {
|
|
27699
27699
|
const trashDir = path.join(os.homedir(), ".Trash");
|
|
27700
|
-
|
|
27700
|
+
fsSync.mkdirSync(trashDir, { recursive: true });
|
|
27701
27701
|
const base = path.basename(targetPath);
|
|
27702
27702
|
let dest = path.join(trashDir, `${base}-${Date.now()}`);
|
|
27703
|
-
if (
|
|
27704
|
-
|
|
27703
|
+
if (fsSync.existsSync(dest)) dest = path.join(trashDir, `${base}-${Date.now()}-${generateSecureToken(6)}`);
|
|
27704
|
+
fsSync.renameSync(targetPath, dest);
|
|
27705
27705
|
return dest;
|
|
27706
27706
|
}
|
|
27707
27707
|
}
|
|
@@ -27709,7 +27709,7 @@ async function movePathToTrash(targetPath) {
|
|
|
27709
27709
|
//#region src/browser/server-context.reset.ts
|
|
27710
27710
|
async function closePlaywrightBrowserConnectionForProfile(cdpUrl) {
|
|
27711
27711
|
try {
|
|
27712
|
-
await (await import("./pw-ai-
|
|
27712
|
+
await (await import("./pw-ai-BZnl84YT.js")).closePlaywrightBrowserConnection(cdpUrl ? { cdpUrl } : void 0);
|
|
27713
27713
|
} catch {}
|
|
27714
27714
|
}
|
|
27715
27715
|
function createProfileResetOps({ profile, getProfileState, stopRunningBrowser, isHttpReachable, resolveOpenClawUserDataDir }) {
|
|
@@ -27728,7 +27728,7 @@ function createProfileResetOps({ profile, getProfileState, stopRunningBrowser, i
|
|
|
27728
27728
|
if (await isHttpReachable(300) && !profileState.running) await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
|
|
27729
27729
|
if (profileState.running) await stopRunningBrowser();
|
|
27730
27730
|
await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
|
|
27731
|
-
if (!
|
|
27731
|
+
if (!fsSync.existsSync(userDataDir)) return {
|
|
27732
27732
|
moved: false,
|
|
27733
27733
|
from: userDataDir
|
|
27734
27734
|
};
|
|
@@ -29351,11 +29351,11 @@ function readJpegExifOrientation(buffer) {
|
|
|
29351
29351
|
return null;
|
|
29352
29352
|
}
|
|
29353
29353
|
async function withTempDir(fn) {
|
|
29354
|
-
const dir = await fs
|
|
29354
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-img-"));
|
|
29355
29355
|
try {
|
|
29356
29356
|
return await fn(dir);
|
|
29357
29357
|
} finally {
|
|
29358
|
-
await fs
|
|
29358
|
+
await fs.rm(dir, {
|
|
29359
29359
|
recursive: true,
|
|
29360
29360
|
force: true
|
|
29361
29361
|
}).catch(() => {});
|
|
@@ -29364,7 +29364,7 @@ async function withTempDir(fn) {
|
|
|
29364
29364
|
async function sipsMetadataFromBuffer(buffer) {
|
|
29365
29365
|
return await withTempDir(async (dir) => {
|
|
29366
29366
|
const input = path.join(dir, "in.img");
|
|
29367
|
-
await fs
|
|
29367
|
+
await fs.writeFile(input, buffer);
|
|
29368
29368
|
const { stdout } = await runExec("/usr/bin/sips", [
|
|
29369
29369
|
"-g",
|
|
29370
29370
|
"pixelWidth",
|
|
@@ -29392,7 +29392,7 @@ async function sipsResizeToJpeg(params) {
|
|
|
29392
29392
|
return await withTempDir(async (dir) => {
|
|
29393
29393
|
const input = path.join(dir, "in.img");
|
|
29394
29394
|
const output = path.join(dir, "out.jpg");
|
|
29395
|
-
await fs
|
|
29395
|
+
await fs.writeFile(input, params.buffer);
|
|
29396
29396
|
await runExec("/usr/bin/sips", [
|
|
29397
29397
|
"-Z",
|
|
29398
29398
|
String(Math.max(1, Math.round(params.maxSide))),
|
|
@@ -29409,14 +29409,14 @@ async function sipsResizeToJpeg(params) {
|
|
|
29409
29409
|
timeoutMs: 2e4,
|
|
29410
29410
|
maxBuffer: 1024 * 1024
|
|
29411
29411
|
});
|
|
29412
|
-
return await fs
|
|
29412
|
+
return await fs.readFile(output);
|
|
29413
29413
|
});
|
|
29414
29414
|
}
|
|
29415
29415
|
async function sipsConvertToJpeg(buffer) {
|
|
29416
29416
|
return await withTempDir(async (dir) => {
|
|
29417
29417
|
const input = path.join(dir, "in.heic");
|
|
29418
29418
|
const output = path.join(dir, "out.jpg");
|
|
29419
|
-
await fs
|
|
29419
|
+
await fs.writeFile(input, buffer);
|
|
29420
29420
|
await runExec("/usr/bin/sips", [
|
|
29421
29421
|
"-s",
|
|
29422
29422
|
"format",
|
|
@@ -29428,7 +29428,7 @@ async function sipsConvertToJpeg(buffer) {
|
|
|
29428
29428
|
timeoutMs: 2e4,
|
|
29429
29429
|
maxBuffer: 1024 * 1024
|
|
29430
29430
|
});
|
|
29431
|
-
return await fs
|
|
29431
|
+
return await fs.readFile(output);
|
|
29432
29432
|
});
|
|
29433
29433
|
}
|
|
29434
29434
|
async function getImageMetadata(buffer) {
|
|
@@ -29479,7 +29479,7 @@ async function sipsApplyOrientation(buffer, orientation) {
|
|
|
29479
29479
|
return await withTempDir(async (dir) => {
|
|
29480
29480
|
const input = path.join(dir, "in.jpg");
|
|
29481
29481
|
const output = path.join(dir, "out.jpg");
|
|
29482
|
-
await fs
|
|
29482
|
+
await fs.writeFile(input, buffer);
|
|
29483
29483
|
await runExec("/usr/bin/sips", [
|
|
29484
29484
|
...ops,
|
|
29485
29485
|
input,
|
|
@@ -29489,7 +29489,7 @@ async function sipsApplyOrientation(buffer, orientation) {
|
|
|
29489
29489
|
timeoutMs: 2e4,
|
|
29490
29490
|
maxBuffer: 1024 * 1024
|
|
29491
29491
|
});
|
|
29492
|
-
return await fs
|
|
29492
|
+
return await fs.readFile(output);
|
|
29493
29493
|
});
|
|
29494
29494
|
}
|
|
29495
29495
|
async function resizeToJpeg(params) {
|
|
@@ -30614,7 +30614,7 @@ function createBrowserProfilesService(ctx) {
|
|
|
30614
30614
|
} catch {}
|
|
30615
30615
|
const userDataDir = resolveOpenClawUserDataDir(name);
|
|
30616
30616
|
const profileDir = path.dirname(userDataDir);
|
|
30617
|
-
if (
|
|
30617
|
+
if (fsSync.existsSync(profileDir)) {
|
|
30618
30618
|
await movePathToTrash(profileDir);
|
|
30619
30619
|
deleted = true;
|
|
30620
30620
|
}
|
|
@@ -31219,22 +31219,22 @@ async function writeTextAtomic(filePath, content, options) {
|
|
|
31219
31219
|
const payload = options?.appendTrailingNewline && !content.endsWith("\n") ? `${content}\n` : content;
|
|
31220
31220
|
const mkdirOptions = { recursive: true };
|
|
31221
31221
|
if (typeof options?.ensureDirMode === "number") mkdirOptions.mode = options.ensureDirMode;
|
|
31222
|
-
await fs
|
|
31222
|
+
await fs.mkdir(path.dirname(filePath), mkdirOptions);
|
|
31223
31223
|
const tmp = `${filePath}.${randomUUID()}.tmp`;
|
|
31224
31224
|
try {
|
|
31225
|
-
await fs
|
|
31225
|
+
await fs.writeFile(tmp, payload, {
|
|
31226
31226
|
encoding: "utf8",
|
|
31227
31227
|
mode
|
|
31228
31228
|
});
|
|
31229
31229
|
try {
|
|
31230
|
-
await fs
|
|
31230
|
+
await fs.chmod(tmp, mode);
|
|
31231
31231
|
} catch {}
|
|
31232
|
-
await fs
|
|
31232
|
+
await fs.rename(tmp, filePath);
|
|
31233
31233
|
try {
|
|
31234
|
-
await fs
|
|
31234
|
+
await fs.chmod(filePath, mode);
|
|
31235
31235
|
} catch {}
|
|
31236
31236
|
} finally {
|
|
31237
|
-
await fs
|
|
31237
|
+
await fs.rm(tmp, { force: true }).catch(() => void 0);
|
|
31238
31238
|
}
|
|
31239
31239
|
}
|
|
31240
31240
|
function createAsyncLock() {
|
|
@@ -31265,7 +31265,7 @@ function isValidPid(pid) {
|
|
|
31265
31265
|
function isZombieProcess(pid) {
|
|
31266
31266
|
if (process.platform !== "linux") return false;
|
|
31267
31267
|
try {
|
|
31268
|
-
return
|
|
31268
|
+
return fsSync.readFileSync(`/proc/${pid}/status`, "utf8").match(/^State:\s+(\S)/m)?.[1] === "Z";
|
|
31269
31269
|
} catch {
|
|
31270
31270
|
return false;
|
|
31271
31271
|
}
|
|
@@ -31292,7 +31292,7 @@ function getProcessStartTime(pid) {
|
|
|
31292
31292
|
if (process.platform !== "linux") return null;
|
|
31293
31293
|
if (!isValidPid(pid)) return null;
|
|
31294
31294
|
try {
|
|
31295
|
-
const stat =
|
|
31295
|
+
const stat = fsSync.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
31296
31296
|
const commEndIndex = stat.lastIndexOf(")");
|
|
31297
31297
|
if (commEndIndex < 0) return null;
|
|
31298
31298
|
const fields = stat.slice(commEndIndex + 1).trimStart().split(/\s+/);
|
|
@@ -31378,7 +31378,7 @@ async function releaseHeldLock$1(normalizedSessionFile, held, opts = {}) {
|
|
|
31378
31378
|
await held.handle.close();
|
|
31379
31379
|
} catch {}
|
|
31380
31380
|
try {
|
|
31381
|
-
await fs
|
|
31381
|
+
await fs.rm(held.lockPath, { force: true });
|
|
31382
31382
|
} catch {}
|
|
31383
31383
|
})();
|
|
31384
31384
|
try {
|
|
@@ -31398,7 +31398,7 @@ function releaseAllLocksSync() {
|
|
|
31398
31398
|
if (typeof held.handle.close === "function") held.handle.close().catch(() => {});
|
|
31399
31399
|
} catch {}
|
|
31400
31400
|
try {
|
|
31401
|
-
|
|
31401
|
+
fsSync.rmSync(held.lockPath, { force: true });
|
|
31402
31402
|
} catch {}
|
|
31403
31403
|
HELD_LOCKS$1.delete(sessionFile);
|
|
31404
31404
|
}
|
|
@@ -31457,7 +31457,7 @@ function registerCleanupHandlers() {
|
|
|
31457
31457
|
}
|
|
31458
31458
|
async function readLockPayload$1(lockPath) {
|
|
31459
31459
|
try {
|
|
31460
|
-
const raw = await fs
|
|
31460
|
+
const raw = await fs.readFile(lockPath, "utf8");
|
|
31461
31461
|
const parsed = JSON.parse(raw);
|
|
31462
31462
|
const payload = {};
|
|
31463
31463
|
if (isValidLockNumber(parsed.pid) && parsed.pid > 0) payload.pid = parsed.pid;
|
|
@@ -31501,7 +31501,7 @@ async function shouldReclaimContendedLockFile(lockPath, details, staleMs, nowMs)
|
|
|
31501
31501
|
if (!details.stale) return false;
|
|
31502
31502
|
if (!lockInspectionNeedsMtimeStaleFallback(details)) return true;
|
|
31503
31503
|
try {
|
|
31504
|
-
const stat = await fs
|
|
31504
|
+
const stat = await fs.stat(lockPath);
|
|
31505
31505
|
return Math.max(0, nowMs - stat.mtimeMs) > staleMs;
|
|
31506
31506
|
} catch (error) {
|
|
31507
31507
|
return error?.code !== "ENOENT";
|
|
@@ -31519,10 +31519,10 @@ async function acquireSessionWriteLock(params) {
|
|
|
31519
31519
|
const maxHoldMs = resolvePositiveMs(params.maxHoldMs, DEFAULT_MAX_HOLD_MS);
|
|
31520
31520
|
const sessionFile = path.resolve(params.sessionFile);
|
|
31521
31521
|
const sessionDir = path.dirname(sessionFile);
|
|
31522
|
-
await fs
|
|
31522
|
+
await fs.mkdir(sessionDir, { recursive: true });
|
|
31523
31523
|
let normalizedDir = sessionDir;
|
|
31524
31524
|
try {
|
|
31525
|
-
normalizedDir = await fs
|
|
31525
|
+
normalizedDir = await fs.realpath(sessionDir);
|
|
31526
31526
|
} catch {}
|
|
31527
31527
|
const normalizedSessionFile = path.join(normalizedDir, path.basename(sessionFile));
|
|
31528
31528
|
const lockPath = `${normalizedSessionFile}.lock`;
|
|
@@ -31540,7 +31540,7 @@ async function acquireSessionWriteLock(params) {
|
|
|
31540
31540
|
attempt += 1;
|
|
31541
31541
|
let handle = null;
|
|
31542
31542
|
try {
|
|
31543
|
-
handle = await fs
|
|
31543
|
+
handle = await fs.open(lockPath, "wx");
|
|
31544
31544
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
31545
31545
|
const starttime = getProcessStartTime(process.pid);
|
|
31546
31546
|
const lockPayload = {
|
|
@@ -31566,7 +31566,7 @@ async function acquireSessionWriteLock(params) {
|
|
|
31566
31566
|
await handle.close();
|
|
31567
31567
|
} catch {}
|
|
31568
31568
|
try {
|
|
31569
|
-
await fs
|
|
31569
|
+
await fs.rm(lockPath, { force: true });
|
|
31570
31570
|
} catch {}
|
|
31571
31571
|
}
|
|
31572
31572
|
if (err.code !== "EEXIST") throw err;
|
|
@@ -31581,7 +31581,7 @@ async function acquireSessionWriteLock(params) {
|
|
|
31581
31581
|
stale: true,
|
|
31582
31582
|
staleReasons: inspected.staleReasons.includes("orphan-self-pid") ? inspected.staleReasons : [...inspected.staleReasons, "orphan-self-pid"]
|
|
31583
31583
|
} : inspected, staleMs, nowMs)) {
|
|
31584
|
-
await fs
|
|
31584
|
+
await fs.rm(lockPath, { force: true });
|
|
31585
31585
|
continue;
|
|
31586
31586
|
}
|
|
31587
31587
|
const delay = Math.min(1e3, 50 * attempt);
|
|
@@ -31619,7 +31619,7 @@ async function withRegistryLock(registryPath, fn) {
|
|
|
31619
31619
|
}
|
|
31620
31620
|
async function readRegistryFromFile(registryPath, mode) {
|
|
31621
31621
|
try {
|
|
31622
|
-
const raw = await fs
|
|
31622
|
+
const raw = await fs.readFile(registryPath, "utf-8");
|
|
31623
31623
|
const parsed = JSON.parse(raw);
|
|
31624
31624
|
if (isRegistryFile(parsed)) return parsed;
|
|
31625
31625
|
if (mode === "fallback") return { entries: [] };
|
|
@@ -32995,7 +32995,7 @@ var SandboxFsPathGuard = class {
|
|
|
32995
32995
|
if (guarded.reason !== "path") {
|
|
32996
32996
|
if (!(options.allowedType === "directory" && this.pathIsExistingDirectory(target.hostPath))) throw guarded.error instanceof Error ? guarded.error : /* @__PURE__ */ new Error(`Sandbox boundary checks failed; cannot ${options.action}: ${target.containerPath}`);
|
|
32997
32997
|
}
|
|
32998
|
-
} else
|
|
32998
|
+
} else fsSync.closeSync(guarded.fd);
|
|
32999
32999
|
const canonicalContainerPath = await this.resolveCanonicalContainerPath({
|
|
33000
33000
|
containerPath: target.containerPath,
|
|
33001
33001
|
allowFinalSymlinkForUnlink: options.aliasPolicy?.allowFinalSymlinkForUnlink === true
|
|
@@ -33062,7 +33062,7 @@ var SandboxFsPathGuard = class {
|
|
|
33062
33062
|
}
|
|
33063
33063
|
pathIsExistingDirectory(hostPath) {
|
|
33064
33064
|
try {
|
|
33065
|
-
return
|
|
33065
|
+
return fsSync.statSync(hostPath).isDirectory();
|
|
33066
33066
|
} catch {
|
|
33067
33067
|
return false;
|
|
33068
33068
|
}
|
|
@@ -33412,9 +33412,9 @@ var SandboxFsBridgeImpl = class {
|
|
|
33412
33412
|
async readPinnedFile(target) {
|
|
33413
33413
|
const opened = await this.pathGuard.openReadableFile(target);
|
|
33414
33414
|
try {
|
|
33415
|
-
return
|
|
33415
|
+
return fsSync.readFileSync(opened.fd);
|
|
33416
33416
|
} finally {
|
|
33417
|
-
|
|
33417
|
+
fsSync.closeSync(opened.fd);
|
|
33418
33418
|
}
|
|
33419
33419
|
}
|
|
33420
33420
|
async runCheckedCommand(plan) {
|
|
@@ -34177,7 +34177,7 @@ function loadSecretFileSync(filePath, label, options = {}) {
|
|
|
34177
34177
|
const maxBytes = options.maxBytes ?? 16384;
|
|
34178
34178
|
let previewStat;
|
|
34179
34179
|
try {
|
|
34180
|
-
previewStat =
|
|
34180
|
+
previewStat = fsSync.lstatSync(resolvedPath);
|
|
34181
34181
|
} catch (error) {
|
|
34182
34182
|
return {
|
|
34183
34183
|
ok: false,
|
|
@@ -34216,7 +34216,7 @@ function loadSecretFileSync(filePath, label, options = {}) {
|
|
|
34216
34216
|
};
|
|
34217
34217
|
}
|
|
34218
34218
|
try {
|
|
34219
|
-
const secret =
|
|
34219
|
+
const secret = fsSync.readFileSync(opened.fd, "utf8").trim();
|
|
34220
34220
|
if (!secret) return {
|
|
34221
34221
|
ok: false,
|
|
34222
34222
|
resolvedPath,
|
|
@@ -34235,7 +34235,7 @@ function loadSecretFileSync(filePath, label, options = {}) {
|
|
|
34235
34235
|
message: `Failed to read ${label} file at ${resolvedPath}: ${String(error)}`
|
|
34236
34236
|
};
|
|
34237
34237
|
} finally {
|
|
34238
|
-
|
|
34238
|
+
fsSync.closeSync(opened.fd);
|
|
34239
34239
|
}
|
|
34240
34240
|
}
|
|
34241
34241
|
function tryReadSecretFileSync(filePath, label, options = {}) {
|
|
@@ -34949,7 +34949,7 @@ function resolveWebCredsBackupPath(authDir) {
|
|
|
34949
34949
|
}
|
|
34950
34950
|
function hasWebCredsSync(authDir) {
|
|
34951
34951
|
try {
|
|
34952
|
-
const stats =
|
|
34952
|
+
const stats = fsSync.statSync(resolveWebCredsPath(authDir));
|
|
34953
34953
|
return stats.isFile() && stats.size > 1;
|
|
34954
34954
|
} catch {
|
|
34955
34955
|
return false;
|
|
@@ -34957,10 +34957,10 @@ function hasWebCredsSync(authDir) {
|
|
|
34957
34957
|
}
|
|
34958
34958
|
function readCredsJsonRaw(filePath) {
|
|
34959
34959
|
try {
|
|
34960
|
-
if (!
|
|
34961
|
-
const stats =
|
|
34960
|
+
if (!fsSync.existsSync(filePath)) return null;
|
|
34961
|
+
const stats = fsSync.statSync(filePath);
|
|
34962
34962
|
if (!stats.isFile() || stats.size <= 1) return null;
|
|
34963
|
-
return
|
|
34963
|
+
return fsSync.readFileSync(filePath, "utf-8");
|
|
34964
34964
|
} catch {
|
|
34965
34965
|
return null;
|
|
34966
34966
|
}
|
|
@@ -34978,9 +34978,9 @@ function maybeRestoreCredsFromBackup(authDir) {
|
|
|
34978
34978
|
const backupRaw = readCredsJsonRaw(backupPath);
|
|
34979
34979
|
if (!backupRaw) return;
|
|
34980
34980
|
JSON.parse(backupRaw);
|
|
34981
|
-
|
|
34981
|
+
fsSync.copyFileSync(backupPath, credsPath);
|
|
34982
34982
|
try {
|
|
34983
|
-
|
|
34983
|
+
fsSync.chmodSync(credsPath, 384);
|
|
34984
34984
|
} catch {}
|
|
34985
34985
|
logger.warn({ credsPath }, "restored corrupted WhatsApp creds.json from backup");
|
|
34986
34986
|
} catch {}
|
|
@@ -34990,14 +34990,14 @@ async function webAuthExists(authDir = resolveDefaultWebAuthDir()) {
|
|
|
34990
34990
|
maybeRestoreCredsFromBackup(resolvedAuthDir);
|
|
34991
34991
|
const credsPath = resolveWebCredsPath(resolvedAuthDir);
|
|
34992
34992
|
try {
|
|
34993
|
-
await fs
|
|
34993
|
+
await fs.access(resolvedAuthDir);
|
|
34994
34994
|
} catch {
|
|
34995
34995
|
return false;
|
|
34996
34996
|
}
|
|
34997
34997
|
try {
|
|
34998
|
-
const stats = await fs
|
|
34998
|
+
const stats = await fs.stat(credsPath);
|
|
34999
34999
|
if (!stats.isFile() || stats.size <= 1) return false;
|
|
35000
|
-
const raw = await fs
|
|
35000
|
+
const raw = await fs.readFile(credsPath, "utf-8");
|
|
35001
35001
|
JSON.parse(raw);
|
|
35002
35002
|
return true;
|
|
35003
35003
|
} catch {
|
|
@@ -35005,7 +35005,7 @@ async function webAuthExists(authDir = resolveDefaultWebAuthDir()) {
|
|
|
35005
35005
|
}
|
|
35006
35006
|
}
|
|
35007
35007
|
async function clearLegacyBaileysAuthState(authDir) {
|
|
35008
|
-
const entries = await fs
|
|
35008
|
+
const entries = await fs.readdir(authDir, { withFileTypes: true });
|
|
35009
35009
|
const shouldDelete = (name) => {
|
|
35010
35010
|
if (name === "oauth.json") return false;
|
|
35011
35011
|
if (name === "creds.json" || name === "creds.json.bak") return true;
|
|
@@ -35015,7 +35015,7 @@ async function clearLegacyBaileysAuthState(authDir) {
|
|
|
35015
35015
|
await Promise.all(entries.map(async (entry) => {
|
|
35016
35016
|
if (!entry.isFile()) return;
|
|
35017
35017
|
if (!shouldDelete(entry.name)) return;
|
|
35018
|
-
await fs
|
|
35018
|
+
await fs.rm(path.join(authDir, entry.name), { force: true });
|
|
35019
35019
|
}));
|
|
35020
35020
|
}
|
|
35021
35021
|
async function logoutWeb(params) {
|
|
@@ -35026,7 +35026,7 @@ async function logoutWeb(params) {
|
|
|
35026
35026
|
return false;
|
|
35027
35027
|
}
|
|
35028
35028
|
if (params.isLegacyAuthDir) await clearLegacyBaileysAuthState(resolvedAuthDir);
|
|
35029
|
-
else await fs
|
|
35029
|
+
else await fs.rm(resolvedAuthDir, {
|
|
35030
35030
|
recursive: true,
|
|
35031
35031
|
force: true
|
|
35032
35032
|
});
|
|
@@ -35036,11 +35036,11 @@ async function logoutWeb(params) {
|
|
|
35036
35036
|
function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
|
|
35037
35037
|
try {
|
|
35038
35038
|
const credsPath = resolveWebCredsPath(resolveUserPath(authDir));
|
|
35039
|
-
if (!
|
|
35039
|
+
if (!fsSync.existsSync(credsPath)) return {
|
|
35040
35040
|
e164: null,
|
|
35041
35041
|
jid: null
|
|
35042
35042
|
};
|
|
35043
|
-
const raw =
|
|
35043
|
+
const raw = fsSync.readFileSync(credsPath, "utf-8");
|
|
35044
35044
|
const jid = JSON.parse(raw)?.me?.id ?? null;
|
|
35045
35045
|
return {
|
|
35046
35046
|
e164: jid ? jidToE164(jid, { authDir }) : null,
|
|
@@ -35059,7 +35059,7 @@ function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
|
|
|
35059
35059
|
*/
|
|
35060
35060
|
function getWebAuthAgeMs(authDir = resolveDefaultWebAuthDir()) {
|
|
35061
35061
|
try {
|
|
35062
|
-
const stats =
|
|
35062
|
+
const stats = fsSync.statSync(resolveWebCredsPath(resolveUserPath(authDir)));
|
|
35063
35063
|
return Date.now() - stats.mtimeMs;
|
|
35064
35064
|
} catch {
|
|
35065
35065
|
return null;
|
|
@@ -35088,7 +35088,7 @@ function listWhatsAppAuthDirs(cfg) {
|
|
|
35088
35088
|
accountId
|
|
35089
35089
|
}).authDir);
|
|
35090
35090
|
try {
|
|
35091
|
-
const entries =
|
|
35091
|
+
const entries = fsSync.readdirSync(whatsappDir, { withFileTypes: true });
|
|
35092
35092
|
for (const entry of entries) {
|
|
35093
35093
|
if (!entry.isDirectory()) continue;
|
|
35094
35094
|
authDirs.add(path.join(whatsappDir, entry.name));
|
|
@@ -35110,7 +35110,7 @@ function resolveLegacyAuthDir() {
|
|
|
35110
35110
|
}
|
|
35111
35111
|
function legacyAuthExists(authDir) {
|
|
35112
35112
|
try {
|
|
35113
|
-
return
|
|
35113
|
+
return fsSync.existsSync(path.join(authDir, "creds.json"));
|
|
35114
35114
|
} catch {
|
|
35115
35115
|
return false;
|
|
35116
35116
|
}
|
|
@@ -36914,14 +36914,14 @@ function resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile, a
|
|
|
36914
36914
|
function canonicalizePathForComparison$1(filePath) {
|
|
36915
36915
|
const resolved = path.resolve(filePath);
|
|
36916
36916
|
try {
|
|
36917
|
-
return
|
|
36917
|
+
return fsSync.realpathSync(resolved);
|
|
36918
36918
|
} catch {
|
|
36919
36919
|
return resolved;
|
|
36920
36920
|
}
|
|
36921
36921
|
}
|
|
36922
36922
|
function archiveFileOnDisk(filePath, reason) {
|
|
36923
36923
|
const archived = `${filePath}.${reason}.${formatSessionArchiveTimestamp()}`;
|
|
36924
|
-
|
|
36924
|
+
fsSync.renameSync(filePath, archived);
|
|
36925
36925
|
return archived;
|
|
36926
36926
|
}
|
|
36927
36927
|
/**
|
|
@@ -36937,7 +36937,7 @@ function archiveSessionTranscripts(opts) {
|
|
|
36937
36937
|
const relative = path.relative(storeDir, candidatePath);
|
|
36938
36938
|
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) continue;
|
|
36939
36939
|
}
|
|
36940
|
-
if (!
|
|
36940
|
+
if (!fsSync.existsSync(candidatePath)) continue;
|
|
36941
36941
|
try {
|
|
36942
36942
|
archived.push(archiveFileOnDisk(candidatePath, opts.reason));
|
|
36943
36943
|
} catch {}
|
|
@@ -36955,15 +36955,15 @@ async function cleanupArchivedSessionTranscripts(opts) {
|
|
|
36955
36955
|
let removed = 0;
|
|
36956
36956
|
let scanned = 0;
|
|
36957
36957
|
for (const dir of directories) {
|
|
36958
|
-
const entries = await
|
|
36958
|
+
const entries = await fsSync.promises.readdir(dir).catch(() => []);
|
|
36959
36959
|
for (const entry of entries) {
|
|
36960
36960
|
const timestamp = parseSessionArchiveTimestamp(entry, reason);
|
|
36961
36961
|
if (timestamp == null) continue;
|
|
36962
36962
|
scanned += 1;
|
|
36963
36963
|
if (now - timestamp <= opts.olderThanMs) continue;
|
|
36964
36964
|
const fullPath = path.join(dir, entry);
|
|
36965
|
-
if (!(await
|
|
36966
|
-
await
|
|
36965
|
+
if (!(await fsSync.promises.stat(fullPath).catch(() => null))?.isFile()) continue;
|
|
36966
|
+
await fsSync.promises.rm(fullPath).catch(() => void 0);
|
|
36967
36967
|
removed += 1;
|
|
36968
36968
|
}
|
|
36969
36969
|
}
|
|
@@ -37114,7 +37114,7 @@ function isCacheEnabled(ttlMs) {
|
|
|
37114
37114
|
}
|
|
37115
37115
|
function getFileStatSnapshot(filePath) {
|
|
37116
37116
|
try {
|
|
37117
|
-
const stats =
|
|
37117
|
+
const stats = fsSync.statSync(filePath);
|
|
37118
37118
|
return {
|
|
37119
37119
|
mtimeMs: stats.mtimeMs,
|
|
37120
37120
|
sizeBytes: stats.size
|
|
@@ -37132,7 +37132,7 @@ const NOOP_LOGGER = {
|
|
|
37132
37132
|
function canonicalizePathForComparison(filePath) {
|
|
37133
37133
|
const resolved = path.resolve(filePath);
|
|
37134
37134
|
try {
|
|
37135
|
-
return
|
|
37135
|
+
return fsSync.realpathSync(resolved);
|
|
37136
37136
|
} catch {
|
|
37137
37137
|
return resolved;
|
|
37138
37138
|
}
|
|
@@ -37190,12 +37190,12 @@ function resolveReferencedSessionTranscriptPaths(params) {
|
|
|
37190
37190
|
return referenced;
|
|
37191
37191
|
}
|
|
37192
37192
|
async function readSessionsDirFiles(sessionsDir) {
|
|
37193
|
-
const dirEntries = await
|
|
37193
|
+
const dirEntries = await fsSync.promises.readdir(sessionsDir, { withFileTypes: true }).catch(() => []);
|
|
37194
37194
|
const files = [];
|
|
37195
37195
|
for (const dirent of dirEntries) {
|
|
37196
37196
|
if (!dirent.isFile()) continue;
|
|
37197
37197
|
const filePath = path.join(sessionsDir, dirent.name);
|
|
37198
|
-
const stat = await
|
|
37198
|
+
const stat = await fsSync.promises.stat(filePath).catch(() => null);
|
|
37199
37199
|
if (!stat?.isFile()) continue;
|
|
37200
37200
|
files.push({
|
|
37201
37201
|
path: filePath,
|
|
@@ -37208,9 +37208,9 @@ async function readSessionsDirFiles(sessionsDir) {
|
|
|
37208
37208
|
return files;
|
|
37209
37209
|
}
|
|
37210
37210
|
async function removeFileIfExists(filePath) {
|
|
37211
|
-
const stat = await
|
|
37211
|
+
const stat = await fsSync.promises.stat(filePath).catch(() => null);
|
|
37212
37212
|
if (!stat?.isFile()) return 0;
|
|
37213
|
-
await
|
|
37213
|
+
await fsSync.promises.rm(filePath, { force: true }).catch(() => void 0);
|
|
37214
37214
|
return stat.size;
|
|
37215
37215
|
}
|
|
37216
37216
|
async function removeFileForBudget(params) {
|
|
@@ -37567,7 +37567,7 @@ function capEntryCount(store, overrideMax, opts = {}) {
|
|
|
37567
37567
|
}
|
|
37568
37568
|
async function getSessionFileSize(storePath) {
|
|
37569
37569
|
try {
|
|
37570
|
-
return (await
|
|
37570
|
+
return (await fsSync.promises.stat(storePath)).size;
|
|
37571
37571
|
} catch {
|
|
37572
37572
|
return null;
|
|
37573
37573
|
}
|
|
@@ -37584,7 +37584,7 @@ async function rotateSessionFile(storePath, overrideBytes) {
|
|
|
37584
37584
|
if (fileSize <= maxBytes) return false;
|
|
37585
37585
|
const backupPath = `${storePath}.bak.${Date.now()}`;
|
|
37586
37586
|
try {
|
|
37587
|
-
await
|
|
37587
|
+
await fsSync.promises.rename(storePath, backupPath);
|
|
37588
37588
|
log$35.info("rotated session store file", {
|
|
37589
37589
|
backupPath: path.basename(backupPath),
|
|
37590
37590
|
sizeBytes: fileSize
|
|
@@ -37595,11 +37595,11 @@ async function rotateSessionFile(storePath, overrideBytes) {
|
|
|
37595
37595
|
try {
|
|
37596
37596
|
const dir = path.dirname(storePath);
|
|
37597
37597
|
const baseName = path.basename(storePath);
|
|
37598
|
-
const backups = (await
|
|
37598
|
+
const backups = (await fsSync.promises.readdir(dir)).filter((f) => f.startsWith(`${baseName}.bak.`)).toSorted().toReversed();
|
|
37599
37599
|
const maxBackups = 3;
|
|
37600
37600
|
if (backups.length > maxBackups) {
|
|
37601
37601
|
const toDelete = backups.slice(maxBackups);
|
|
37602
|
-
for (const old of toDelete) await
|
|
37602
|
+
for (const old of toDelete) await fsSync.promises.unlink(path.join(dir, old)).catch(() => void 0);
|
|
37603
37603
|
log$35.info("cleaned up old session store backups", { deleted: toDelete.length });
|
|
37604
37604
|
}
|
|
37605
37605
|
} catch {}
|
|
@@ -37720,7 +37720,7 @@ function loadSessionStore(storePath, opts = {}) {
|
|
|
37720
37720
|
const maxReadAttempts = process.platform === "win32" ? 3 : 1;
|
|
37721
37721
|
const retryBuf = maxReadAttempts > 1 ? new Int32Array(new SharedArrayBuffer(4)) : void 0;
|
|
37722
37722
|
for (let attempt = 0; attempt < maxReadAttempts; attempt++) try {
|
|
37723
|
-
const raw =
|
|
37723
|
+
const raw = fsSync.readFileSync(storePath, "utf-8");
|
|
37724
37724
|
if (raw.length === 0 && attempt < maxReadAttempts - 1) {
|
|
37725
37725
|
Atomics.wait(retryBuf, 0, 0, 50);
|
|
37726
37726
|
continue;
|
|
@@ -37870,7 +37870,7 @@ async function saveSessionStoreUnlocked(storePath, store, opts) {
|
|
|
37870
37870
|
});
|
|
37871
37871
|
}
|
|
37872
37872
|
}
|
|
37873
|
-
await
|
|
37873
|
+
await fsSync.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
37874
37874
|
const json = JSON.stringify(store, null, 2);
|
|
37875
37875
|
if (getSerializedSessionStore(storePath) === json) {
|
|
37876
37876
|
updateSessionStoreWriteCaches({
|
|
@@ -38279,8 +38279,8 @@ function resolveMirroredTranscriptText(params) {
|
|
|
38279
38279
|
return trimmed ? trimmed : null;
|
|
38280
38280
|
}
|
|
38281
38281
|
async function ensureSessionHeader(params) {
|
|
38282
|
-
if (
|
|
38283
|
-
await
|
|
38282
|
+
if (fsSync.existsSync(params.sessionFile)) return;
|
|
38283
|
+
await fsSync.promises.mkdir(path.dirname(params.sessionFile), { recursive: true });
|
|
38284
38284
|
const header = {
|
|
38285
38285
|
type: "session",
|
|
38286
38286
|
version: CURRENT_SESSION_VERSION,
|
|
@@ -38288,7 +38288,7 @@ async function ensureSessionHeader(params) {
|
|
|
38288
38288
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38289
38289
|
cwd: process.cwd()
|
|
38290
38290
|
};
|
|
38291
|
-
await
|
|
38291
|
+
await fsSync.promises.writeFile(params.sessionFile, `${JSON.stringify(header)}\n`, {
|
|
38292
38292
|
encoding: "utf-8",
|
|
38293
38293
|
mode: 384
|
|
38294
38294
|
});
|
|
@@ -38402,7 +38402,7 @@ async function appendAssistantMessageToSessionTranscript(params) {
|
|
|
38402
38402
|
}
|
|
38403
38403
|
async function transcriptHasIdempotencyKey(transcriptPath, idempotencyKey) {
|
|
38404
38404
|
try {
|
|
38405
|
-
const raw = await
|
|
38405
|
+
const raw = await fsSync.promises.readFile(transcriptPath, "utf-8");
|
|
38406
38406
|
for (const line of raw.split(/\r?\n/)) {
|
|
38407
38407
|
if (!line.trim()) continue;
|
|
38408
38408
|
try {
|
|
@@ -38424,7 +38424,7 @@ function mapAgentSessionDirs(agentsDir, entries) {
|
|
|
38424
38424
|
async function resolveAgentSessionDirsFromAgentsDir(agentsDir) {
|
|
38425
38425
|
let entries = [];
|
|
38426
38426
|
try {
|
|
38427
|
-
entries = await fs
|
|
38427
|
+
entries = await fs.readdir(agentsDir, { withFileTypes: true });
|
|
38428
38428
|
} catch (err) {
|
|
38429
38429
|
if (err.code === "ENOENT") return [];
|
|
38430
38430
|
throw err;
|
|
@@ -38434,7 +38434,7 @@ async function resolveAgentSessionDirsFromAgentsDir(agentsDir) {
|
|
|
38434
38434
|
function resolveAgentSessionDirsFromAgentsDirSync(agentsDir) {
|
|
38435
38435
|
let entries = [];
|
|
38436
38436
|
try {
|
|
38437
|
-
entries =
|
|
38437
|
+
entries = fsSync.readdirSync(agentsDir, { withFileTypes: true });
|
|
38438
38438
|
} catch (err) {
|
|
38439
38439
|
if (err.code === "ENOENT") return [];
|
|
38440
38440
|
throw err;
|
|
@@ -38469,10 +38469,10 @@ function shouldSkipDiscoveredAgentDirName(dirName, agentId) {
|
|
|
38469
38469
|
function resolveValidatedDiscoveredStorePathSync(params) {
|
|
38470
38470
|
const storePath = path.join(params.sessionsDir, "sessions.json");
|
|
38471
38471
|
try {
|
|
38472
|
-
const stat =
|
|
38472
|
+
const stat = fsSync.lstatSync(storePath);
|
|
38473
38473
|
if (stat.isSymbolicLink() || !stat.isFile()) return;
|
|
38474
|
-
const realStorePath =
|
|
38475
|
-
return isWithinRoot(realStorePath, params.realAgentsRoot ??
|
|
38474
|
+
const realStorePath = fsSync.realpathSync.native(storePath);
|
|
38475
|
+
return isWithinRoot(realStorePath, params.realAgentsRoot ?? fsSync.realpathSync.native(params.agentsRoot)) ? realStorePath : void 0;
|
|
38476
38476
|
} catch (err) {
|
|
38477
38477
|
if (shouldSkipDiscoveryError(err)) return;
|
|
38478
38478
|
throw err;
|
|
@@ -38481,10 +38481,10 @@ function resolveValidatedDiscoveredStorePathSync(params) {
|
|
|
38481
38481
|
async function resolveValidatedDiscoveredStorePath(params) {
|
|
38482
38482
|
const storePath = path.join(params.sessionsDir, "sessions.json");
|
|
38483
38483
|
try {
|
|
38484
|
-
const stat = await fs
|
|
38484
|
+
const stat = await fs.lstat(storePath);
|
|
38485
38485
|
if (stat.isSymbolicLink() || !stat.isFile()) return;
|
|
38486
|
-
const realStorePath = await fs
|
|
38487
|
-
return isWithinRoot(realStorePath, params.realAgentsRoot ?? await fs
|
|
38486
|
+
const realStorePath = await fs.realpath(storePath);
|
|
38487
|
+
return isWithinRoot(realStorePath, params.realAgentsRoot ?? await fs.realpath(params.agentsRoot)) ? realStorePath : void 0;
|
|
38488
38488
|
} catch (err) {
|
|
38489
38489
|
if (shouldSkipDiscoveryError(err)) return;
|
|
38490
38490
|
throw err;
|
|
@@ -38519,7 +38519,7 @@ function resolveAllAgentSessionStoreTargetsSync(cfg, params = {}) {
|
|
|
38519
38519
|
const cached = realAgentsRoots.get(agentsRoot);
|
|
38520
38520
|
if (cached !== void 0) return cached;
|
|
38521
38521
|
try {
|
|
38522
|
-
const realAgentsRoot =
|
|
38522
|
+
const realAgentsRoot = fsSync.realpathSync.native(agentsRoot);
|
|
38523
38523
|
realAgentsRoots.set(agentsRoot, realAgentsRoot);
|
|
38524
38524
|
return realAgentsRoot;
|
|
38525
38525
|
} catch (err) {
|
|
@@ -38569,7 +38569,7 @@ async function resolveAllAgentSessionStoreTargets(cfg, params = {}) {
|
|
|
38569
38569
|
const cached = realAgentsRoots.get(agentsRoot);
|
|
38570
38570
|
if (cached !== void 0) return cached;
|
|
38571
38571
|
try {
|
|
38572
|
-
const realAgentsRoot = await fs
|
|
38572
|
+
const realAgentsRoot = await fs.realpath(agentsRoot);
|
|
38573
38573
|
realAgentsRoots.set(agentsRoot, realAgentsRoot);
|
|
38574
38574
|
return realAgentsRoot;
|
|
38575
38575
|
} catch (err) {
|
|
@@ -38738,7 +38738,7 @@ function formatSandboxToolPolicyBlockedMessage(params) {
|
|
|
38738
38738
|
//#endregion
|
|
38739
38739
|
//#region src/agents/sandbox/workspace.ts
|
|
38740
38740
|
async function ensureSandboxWorkspace(workspaceDir, seedFrom, skipBootstrap) {
|
|
38741
|
-
await fs
|
|
38741
|
+
await fs.mkdir(workspaceDir, { recursive: true });
|
|
38742
38742
|
if (seedFrom) {
|
|
38743
38743
|
const seed = resolveUserPath(seedFrom);
|
|
38744
38744
|
const files = [
|
|
@@ -38754,7 +38754,7 @@ async function ensureSandboxWorkspace(workspaceDir, seedFrom, skipBootstrap) {
|
|
|
38754
38754
|
const src = path.join(seed, name);
|
|
38755
38755
|
const dest = path.join(workspaceDir, name);
|
|
38756
38756
|
try {
|
|
38757
|
-
await fs
|
|
38757
|
+
await fs.access(dest);
|
|
38758
38758
|
} catch {
|
|
38759
38759
|
try {
|
|
38760
38760
|
const opened = await openBoundaryFile({
|
|
@@ -38764,13 +38764,13 @@ async function ensureSandboxWorkspace(workspaceDir, seedFrom, skipBootstrap) {
|
|
|
38764
38764
|
});
|
|
38765
38765
|
if (!opened.ok) continue;
|
|
38766
38766
|
try {
|
|
38767
|
-
const content =
|
|
38768
|
-
await fs
|
|
38767
|
+
const content = fsSync.readFileSync(opened.fd, "utf-8");
|
|
38768
|
+
await fs.writeFile(dest, content, {
|
|
38769
38769
|
encoding: "utf-8",
|
|
38770
38770
|
flag: "wx"
|
|
38771
38771
|
});
|
|
38772
38772
|
} finally {
|
|
38773
|
-
|
|
38773
|
+
fsSync.closeSync(opened.fd);
|
|
38774
38774
|
}
|
|
38775
38775
|
} catch {}
|
|
38776
38776
|
}
|
|
@@ -38802,7 +38802,7 @@ async function ensureSandboxWorkspaceLayout(params) {
|
|
|
38802
38802
|
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
|
38803
38803
|
defaultRuntime.error?.(`Sandbox skill sync failed: ${message}`);
|
|
38804
38804
|
}
|
|
38805
|
-
} else await fs
|
|
38805
|
+
} else await fs.mkdir(workspaceDir, { recursive: true });
|
|
38806
38806
|
return {
|
|
38807
38807
|
agentWorkspaceDir,
|
|
38808
38808
|
scopeKey,
|
|
@@ -38812,7 +38812,7 @@ async function ensureSandboxWorkspaceLayout(params) {
|
|
|
38812
38812
|
}
|
|
38813
38813
|
async function resolveSandboxDockerUser(params) {
|
|
38814
38814
|
if (params.docker.user?.trim()) return params.docker;
|
|
38815
|
-
const stat = params.stat ?? ((workspaceDir) => fs
|
|
38815
|
+
const stat = params.stat ?? ((workspaceDir) => fs.stat(workspaceDir));
|
|
38816
38816
|
try {
|
|
38817
38817
|
const workspaceStat = await stat(params.workspaceDir);
|
|
38818
38818
|
const uid = Number.isInteger(workspaceStat.uid) ? workspaceStat.uid : null;
|
|
@@ -42375,7 +42375,7 @@ function resolveProviderVisionModelFromConfig(params) {
|
|
|
42375
42375
|
//#region src/media-understanding/providers/image.ts
|
|
42376
42376
|
let piModelDiscoveryRuntimePromise = null;
|
|
42377
42377
|
function loadPiModelDiscoveryRuntime() {
|
|
42378
|
-
piModelDiscoveryRuntimePromise ??= import("./pi-model-discovery-runtime-
|
|
42378
|
+
piModelDiscoveryRuntimePromise ??= import("./pi-model-discovery-runtime-CLfgSk3o.js");
|
|
42379
42379
|
return piModelDiscoveryRuntimePromise;
|
|
42380
42380
|
}
|
|
42381
42381
|
async function describeImageWithModel(params) {
|
|
@@ -43150,7 +43150,7 @@ async function resolveCliOutput(params) {
|
|
|
43150
43150
|
const commandId = commandBase(params.command);
|
|
43151
43151
|
const fileOutput = commandId === "whisper-cli" ? resolveWhisperCppOutputPath(params.args) : commandId === "whisper" ? resolveWhisperOutputPath(params.args, params.mediaPath) : commandId === "parakeet-mlx" ? resolveParakeetOutputPath(params.args, params.mediaPath) : null;
|
|
43152
43152
|
if (fileOutput && await fileExists$1(fileOutput)) try {
|
|
43153
|
-
const content = await fs
|
|
43153
|
+
const content = await fs.readFile(fileOutput, "utf8");
|
|
43154
43154
|
if (content.trim()) return content.trim();
|
|
43155
43155
|
} catch {}
|
|
43156
43156
|
if (commandId === "gemini") {
|
|
@@ -43459,10 +43459,10 @@ async function runCliEntry$1(params) {
|
|
|
43459
43459
|
timeoutMs
|
|
43460
43460
|
});
|
|
43461
43461
|
if (capability === "audio") assertMinAudioSize({
|
|
43462
|
-
size: (await fs
|
|
43462
|
+
size: (await fs.stat(pathResult.path)).size,
|
|
43463
43463
|
attachmentIndex: params.attachmentIndex
|
|
43464
43464
|
});
|
|
43465
|
-
const outputDir = await fs
|
|
43465
|
+
const outputDir = await fs.mkdtemp(path.join(resolvePreferredOpenClawTmpDir(), "openclaw-media-cli-"));
|
|
43466
43466
|
const mediaPath = pathResult.path;
|
|
43467
43467
|
const outputBase = path.join(outputDir, path.parse(mediaPath).name);
|
|
43468
43468
|
const templCtx = {
|
|
@@ -43496,7 +43496,7 @@ async function runCliEntry$1(params) {
|
|
|
43496
43496
|
model: command
|
|
43497
43497
|
};
|
|
43498
43498
|
} finally {
|
|
43499
|
-
await fs
|
|
43499
|
+
await fs.rm(outputDir, {
|
|
43500
43500
|
recursive: true,
|
|
43501
43501
|
force: true
|
|
43502
43502
|
}).catch(() => {});
|
|
@@ -43539,9 +43539,9 @@ function candidateBinaryNames(name) {
|
|
|
43539
43539
|
}
|
|
43540
43540
|
async function isExecutable(filePath) {
|
|
43541
43541
|
try {
|
|
43542
|
-
if (!(await fs
|
|
43542
|
+
if (!(await fs.stat(filePath)).isFile()) return false;
|
|
43543
43543
|
if (process.platform === "win32") return true;
|
|
43544
|
-
await fs
|
|
43544
|
+
await fs.access(filePath, constants.X_OK);
|
|
43545
43545
|
return true;
|
|
43546
43546
|
} catch {
|
|
43547
43547
|
return false;
|
|
@@ -45553,10 +45553,10 @@ function isRecord$2(value) {
|
|
|
45553
45553
|
}
|
|
45554
45554
|
function scrubLegacyStaticAuthJsonEntries(pathname) {
|
|
45555
45555
|
if (process.env.OPENCLAW_AUTH_STORE_READONLY === "1") return;
|
|
45556
|
-
if (!
|
|
45556
|
+
if (!fsSync.existsSync(pathname)) return;
|
|
45557
45557
|
let parsed;
|
|
45558
45558
|
try {
|
|
45559
|
-
parsed = JSON.parse(
|
|
45559
|
+
parsed = JSON.parse(fsSync.readFileSync(pathname, "utf8"));
|
|
45560
45560
|
} catch {
|
|
45561
45561
|
return;
|
|
45562
45562
|
}
|
|
@@ -45570,11 +45570,11 @@ function scrubLegacyStaticAuthJsonEntries(pathname) {
|
|
|
45570
45570
|
}
|
|
45571
45571
|
if (!changed) return;
|
|
45572
45572
|
if (Object.keys(parsed).length === 0) {
|
|
45573
|
-
|
|
45573
|
+
fsSync.rmSync(pathname, { force: true });
|
|
45574
45574
|
return;
|
|
45575
45575
|
}
|
|
45576
|
-
|
|
45577
|
-
|
|
45576
|
+
fsSync.writeFileSync(pathname, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
|
|
45577
|
+
fsSync.chmodSync(pathname, 384);
|
|
45578
45578
|
}
|
|
45579
45579
|
function createAuthStorage(AuthStorageLike, path, creds) {
|
|
45580
45580
|
const withInMemory = AuthStorageLike;
|
|
@@ -47249,7 +47249,7 @@ async function assertLocalMediaAllowed(mediaPath, localRoots) {
|
|
|
47249
47249
|
const roots = localRoots ?? getDefaultLocalRoots();
|
|
47250
47250
|
let resolved;
|
|
47251
47251
|
try {
|
|
47252
|
-
resolved = await fs
|
|
47252
|
+
resolved = await fs.realpath(mediaPath);
|
|
47253
47253
|
} catch {
|
|
47254
47254
|
resolved = path.resolve(mediaPath);
|
|
47255
47255
|
}
|
|
@@ -47266,7 +47266,7 @@ async function assertLocalMediaAllowed(mediaPath, localRoots) {
|
|
|
47266
47266
|
for (const root of roots) {
|
|
47267
47267
|
let resolvedRoot;
|
|
47268
47268
|
try {
|
|
47269
|
-
resolvedRoot = await fs
|
|
47269
|
+
resolvedRoot = await fs.realpath(root);
|
|
47270
47270
|
} catch {
|
|
47271
47271
|
resolvedRoot = path.resolve(root);
|
|
47272
47272
|
}
|
|
@@ -50358,7 +50358,7 @@ function convertMarkdownTables(markdown, mode) {
|
|
|
50358
50358
|
async function unlinkIfExists(filePath) {
|
|
50359
50359
|
if (!filePath) return;
|
|
50360
50360
|
try {
|
|
50361
|
-
await fs
|
|
50361
|
+
await fs.unlink(filePath);
|
|
50362
50362
|
} catch {}
|
|
50363
50363
|
}
|
|
50364
50364
|
//#endregion
|
|
@@ -50532,7 +50532,7 @@ async function generateWaveformFromPcm(filePath) {
|
|
|
50532
50532
|
"8000",
|
|
50533
50533
|
tempPcm
|
|
50534
50534
|
]);
|
|
50535
|
-
const pcmData = await fs
|
|
50535
|
+
const pcmData = await fs.readFile(tempPcm);
|
|
50536
50536
|
const samples = new Int16Array(pcmData.buffer, pcmData.byteOffset, pcmData.byteLength / 2);
|
|
50537
50537
|
const step = Math.max(1, Math.floor(samples.length / WAVEFORM_SAMPLES));
|
|
50538
50538
|
const waveform = [];
|
|
@@ -50915,7 +50915,7 @@ async function materializeVoiceMessageInput(mediaUrl) {
|
|
|
50915
50915
|
const ext = extFromName || extFromMime || ".bin";
|
|
50916
50916
|
const tempDir = resolvePreferredOpenClawTmpDir();
|
|
50917
50917
|
const filePath = path.join(tempDir, `voice-src-${crypto.randomUUID()}${ext}`);
|
|
50918
|
-
await fs
|
|
50918
|
+
await fs.writeFile(filePath, media.buffer, { mode: 384 });
|
|
50919
50919
|
return { filePath };
|
|
50920
50920
|
}
|
|
50921
50921
|
/**
|
|
@@ -50951,7 +50951,7 @@ async function sendVoiceMessageDiscord(to, audioPath, opts = {}) {
|
|
|
50951
50951
|
oggPath = ogg.path;
|
|
50952
50952
|
oggCleanup = ogg.cleanup;
|
|
50953
50953
|
const metadata = await getVoiceMessageMetadata(oggPath);
|
|
50954
|
-
const audioBuffer = await fs
|
|
50954
|
+
const audioBuffer = await fs.readFile(oggPath);
|
|
50955
50955
|
const result = await sendDiscordVoiceMessage(rest, channelId, audioBuffer, metadata, opts.replyTo, request, opts.silent, token);
|
|
50956
50956
|
recordChannelActivity({
|
|
50957
50957
|
channel: "discord",
|
|
@@ -52615,7 +52615,7 @@ function computeDelayMs(retries, attempt) {
|
|
|
52615
52615
|
}
|
|
52616
52616
|
async function readLockPayload(lockPath) {
|
|
52617
52617
|
try {
|
|
52618
|
-
const raw = await fs
|
|
52618
|
+
const raw = await fs.readFile(lockPath, "utf8");
|
|
52619
52619
|
const parsed = JSON.parse(raw);
|
|
52620
52620
|
if (typeof parsed.pid !== "number" || typeof parsed.createdAt !== "string") return null;
|
|
52621
52621
|
return {
|
|
@@ -52629,9 +52629,9 @@ async function readLockPayload(lockPath) {
|
|
|
52629
52629
|
async function resolveNormalizedFilePath(filePath) {
|
|
52630
52630
|
const resolved = path.resolve(filePath);
|
|
52631
52631
|
const dir = path.dirname(resolved);
|
|
52632
|
-
await fs
|
|
52632
|
+
await fs.mkdir(dir, { recursive: true });
|
|
52633
52633
|
try {
|
|
52634
|
-
const realDir = await fs
|
|
52634
|
+
const realDir = await fs.realpath(dir);
|
|
52635
52635
|
return path.join(realDir, path.basename(resolved));
|
|
52636
52636
|
} catch {
|
|
52637
52637
|
return resolved;
|
|
@@ -52645,7 +52645,7 @@ async function isStaleLock(lockPath, staleMs) {
|
|
|
52645
52645
|
if (!Number.isFinite(createdAt) || Date.now() - createdAt > staleMs) return true;
|
|
52646
52646
|
}
|
|
52647
52647
|
try {
|
|
52648
|
-
const stat = await fs
|
|
52648
|
+
const stat = await fs.stat(lockPath);
|
|
52649
52649
|
return Date.now() - stat.mtimeMs > staleMs;
|
|
52650
52650
|
} catch {
|
|
52651
52651
|
return true;
|
|
@@ -52658,7 +52658,7 @@ async function releaseHeldLock(normalizedFile) {
|
|
|
52658
52658
|
if (current.count > 0) return;
|
|
52659
52659
|
HELD_LOCKS.delete(normalizedFile);
|
|
52660
52660
|
await current.handle.close().catch(() => void 0);
|
|
52661
|
-
await fs
|
|
52661
|
+
await fs.rm(current.lockPath, { force: true }).catch(() => void 0);
|
|
52662
52662
|
}
|
|
52663
52663
|
async function acquireFileLock(filePath, options) {
|
|
52664
52664
|
const normalizedFile = await resolveNormalizedFilePath(filePath);
|
|
@@ -52673,7 +52673,7 @@ async function acquireFileLock(filePath, options) {
|
|
|
52673
52673
|
}
|
|
52674
52674
|
const attempts = Math.max(1, options.retries.retries + 1);
|
|
52675
52675
|
for (let attempt = 0; attempt < attempts; attempt += 1) try {
|
|
52676
|
-
const handle = await fs
|
|
52676
|
+
const handle = await fs.open(lockPath, "wx");
|
|
52677
52677
|
await handle.writeFile(JSON.stringify({
|
|
52678
52678
|
pid: process.pid,
|
|
52679
52679
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -52690,7 +52690,7 @@ async function acquireFileLock(filePath, options) {
|
|
|
52690
52690
|
} catch (err) {
|
|
52691
52691
|
if (err.code !== "EEXIST") throw err;
|
|
52692
52692
|
if (await isStaleLock(lockPath, options.stale)) {
|
|
52693
|
-
await fs
|
|
52693
|
+
await fs.rm(lockPath, { force: true }).catch(() => void 0);
|
|
52694
52694
|
continue;
|
|
52695
52695
|
}
|
|
52696
52696
|
if (attempt >= attempts - 1) break;
|
|
@@ -52710,7 +52710,7 @@ async function withFileLock$1(filePath, options, fn) {
|
|
|
52710
52710
|
//#region src/plugin-sdk/json-store.ts
|
|
52711
52711
|
async function readJsonFileWithFallback(filePath, fallback) {
|
|
52712
52712
|
try {
|
|
52713
|
-
const parsed = safeParseJson(await
|
|
52713
|
+
const parsed = safeParseJson(await fsSync.promises.readFile(filePath, "utf-8"));
|
|
52714
52714
|
if (parsed == null) return {
|
|
52715
52715
|
value: fallback,
|
|
52716
52716
|
exists: true
|
|
@@ -52796,7 +52796,7 @@ async function readPairingRequests(filePath) {
|
|
|
52796
52796
|
}
|
|
52797
52797
|
async function ensureJsonFile(filePath, fallback) {
|
|
52798
52798
|
try {
|
|
52799
|
-
await
|
|
52799
|
+
await fsSync.promises.access(filePath);
|
|
52800
52800
|
} catch {
|
|
52801
52801
|
await writeJsonFile(filePath, fallback);
|
|
52802
52802
|
}
|
|
@@ -52952,7 +52952,7 @@ function resolveAllowFromReadCacheOrMissing(filePath, stat) {
|
|
|
52952
52952
|
async function readAllowFromStateForPathWithExists(channel, filePath) {
|
|
52953
52953
|
let stat = null;
|
|
52954
52954
|
try {
|
|
52955
|
-
stat = await
|
|
52955
|
+
stat = await fsSync.promises.stat(filePath);
|
|
52956
52956
|
} catch (err) {
|
|
52957
52957
|
if (err.code !== "ENOENT") throw err;
|
|
52958
52958
|
}
|
|
@@ -52995,7 +52995,7 @@ async function writeAllowFromState(filePath, allowFrom) {
|
|
|
52995
52995
|
});
|
|
52996
52996
|
let stat = null;
|
|
52997
52997
|
try {
|
|
52998
|
-
stat = await
|
|
52998
|
+
stat = await fsSync.promises.stat(filePath);
|
|
52999
52999
|
} catch {}
|
|
53000
53000
|
setAllowFromReadCache(filePath, {
|
|
53001
53001
|
exists: true,
|
|
@@ -53988,7 +53988,7 @@ function shouldPersistAnyBindingState() {
|
|
|
53988
53988
|
}
|
|
53989
53989
|
function shouldPersistBindingMutations() {
|
|
53990
53990
|
if (shouldPersistAnyBindingState()) return true;
|
|
53991
|
-
return
|
|
53991
|
+
return fsSync.existsSync(resolveThreadBindingsPath());
|
|
53992
53992
|
}
|
|
53993
53993
|
function saveBindingsToDisk(params = {}) {
|
|
53994
53994
|
if (!params.force && !shouldPersistAnyBindingState()) return;
|
|
@@ -58016,7 +58016,7 @@ var LegacyContextEngine = class {
|
|
|
58016
58016
|
}
|
|
58017
58017
|
async afterTurn(_params) {}
|
|
58018
58018
|
async compact(params) {
|
|
58019
|
-
const { compactEmbeddedPiSessionDirect } = await import("./compact.runtime-
|
|
58019
|
+
const { compactEmbeddedPiSessionDirect } = await import("./compact.runtime-BgRco6mO.js");
|
|
58020
58020
|
const runtimeContext = params.runtimeContext ?? {};
|
|
58021
58021
|
const currentTokenCount = params.currentTokenCount ?? (typeof runtimeContext.currentTokenCount === "number" && Number.isFinite(runtimeContext.currentTokenCount) && runtimeContext.currentTokenCount > 0 ? Math.floor(runtimeContext.currentTokenCount) : void 0);
|
|
58022
58022
|
const result = await compactEmbeddedPiSessionDirect({
|
|
@@ -58882,7 +58882,7 @@ function canAutoSelectLocal(options) {
|
|
|
58882
58882
|
if (/^(hf:|https?:)/i.test(modelPath)) return false;
|
|
58883
58883
|
const resolved = resolveUserPath(modelPath);
|
|
58884
58884
|
try {
|
|
58885
|
-
return
|
|
58885
|
+
return fsSync.statSync(resolved).isFile();
|
|
58886
58886
|
} catch {
|
|
58887
58887
|
return false;
|
|
58888
58888
|
}
|
|
@@ -59219,7 +59219,7 @@ async function extractTimestamp(params) {
|
|
|
59219
59219
|
if (!params.workspaceDir) return null;
|
|
59220
59220
|
const absolutePath = path.isAbsolute(params.filePath) ? params.filePath : path.resolve(params.workspaceDir, params.filePath);
|
|
59221
59221
|
try {
|
|
59222
|
-
const stat = await fs
|
|
59222
|
+
const stat = await fs.stat(absolutePath);
|
|
59223
59223
|
if (!Number.isFinite(stat.mtimeMs)) return null;
|
|
59224
59224
|
return new Date(stat.mtimeMs);
|
|
59225
59225
|
} catch {
|
|
@@ -60370,7 +60370,7 @@ var MemoryManagerSyncOps = class {
|
|
|
60370
60370
|
const source = `${sourceBase}${suffix}`;
|
|
60371
60371
|
const target = `${targetBase}${suffix}`;
|
|
60372
60372
|
try {
|
|
60373
|
-
await fs
|
|
60373
|
+
await fs.rename(source, target);
|
|
60374
60374
|
} catch (err) {
|
|
60375
60375
|
if (err.code !== "ENOENT") throw err;
|
|
60376
60376
|
}
|
|
@@ -60381,7 +60381,7 @@ var MemoryManagerSyncOps = class {
|
|
|
60381
60381
|
"",
|
|
60382
60382
|
"-wal",
|
|
60383
60383
|
"-shm"
|
|
60384
|
-
].map((suffix) => fs
|
|
60384
|
+
].map((suffix) => fs.rm(`${basePath}${suffix}`, { force: true })));
|
|
60385
60385
|
}
|
|
60386
60386
|
ensureSchema() {
|
|
60387
60387
|
const result = ensureMemoryIndexSchema({
|
|
@@ -60405,7 +60405,7 @@ var MemoryManagerSyncOps = class {
|
|
|
60405
60405
|
]);
|
|
60406
60406
|
const additionalPaths = normalizeExtraMemoryPaths(this.workspaceDir, this.settings.extraPaths);
|
|
60407
60407
|
for (const entry of additionalPaths) try {
|
|
60408
|
-
const stat =
|
|
60408
|
+
const stat = fsSync.lstatSync(entry);
|
|
60409
60409
|
if (stat.isSymbolicLink()) continue;
|
|
60410
60410
|
if (stat.isDirectory()) {
|
|
60411
60411
|
watchPaths.add(path.join(entry, "**", "*.md"));
|
|
@@ -60477,7 +60477,7 @@ var MemoryManagerSyncOps = class {
|
|
|
60477
60477
|
if (!thresholds) return null;
|
|
60478
60478
|
let stat;
|
|
60479
60479
|
try {
|
|
60480
|
-
stat = await fs
|
|
60480
|
+
stat = await fs.stat(sessionFile);
|
|
60481
60481
|
} catch {
|
|
60482
60482
|
return null;
|
|
60483
60483
|
}
|
|
@@ -60519,7 +60519,7 @@ var MemoryManagerSyncOps = class {
|
|
|
60519
60519
|
if (end <= start) return 0;
|
|
60520
60520
|
let handle;
|
|
60521
60521
|
try {
|
|
60522
|
-
handle = await fs
|
|
60522
|
+
handle = await fs.open(absPath, "r");
|
|
60523
60523
|
} catch (err) {
|
|
60524
60524
|
if (isFileMissingError(err)) return 0;
|
|
60525
60525
|
throw err;
|
|
@@ -61593,7 +61593,7 @@ var MemoryManagerEmbeddingOps = class extends MemoryManagerSyncOps {
|
|
|
61593
61593
|
structuredInputBytes = multimodalChunk.structuredInputBytes;
|
|
61594
61594
|
chunks = [multimodalChunk.chunk];
|
|
61595
61595
|
} else {
|
|
61596
|
-
const content = options.content ?? await fs
|
|
61596
|
+
const content = options.content ?? await fs.readFile(entry.absPath, "utf-8");
|
|
61597
61597
|
chunks = enforceEmbeddingMaxInputTokens(this.provider, chunkMarkdown(content, this.settings.chunking).filter((chunk) => chunk.text.trim().length > 0), EMBEDDING_BATCH_MAX_TOKENS);
|
|
61598
61598
|
if (options.source === "sessions" && "lineMap" in entry) remapChunkLines(chunks, entry.lineMap);
|
|
61599
61599
|
}
|
|
@@ -62057,7 +62057,7 @@ var MemoryIndexManager = class MemoryIndexManager extends MemoryManagerEmbedding
|
|
|
62057
62057
|
if (!allowedWorkspace && this.settings.extraPaths.length > 0) {
|
|
62058
62058
|
const additionalPaths = normalizeExtraMemoryPaths(this.workspaceDir, this.settings.extraPaths);
|
|
62059
62059
|
for (const additionalPath of additionalPaths) try {
|
|
62060
|
-
const stat = await fs
|
|
62060
|
+
const stat = await fs.lstat(additionalPath);
|
|
62061
62061
|
if (stat.isSymbolicLink()) continue;
|
|
62062
62062
|
if (stat.isDirectory()) {
|
|
62063
62063
|
if (absPath === additionalPath || absPath.startsWith(`${additionalPath}${path.sep}`)) {
|
|
@@ -62082,7 +62082,7 @@ var MemoryIndexManager = class MemoryIndexManager extends MemoryManagerEmbedding
|
|
|
62082
62082
|
};
|
|
62083
62083
|
let content;
|
|
62084
62084
|
try {
|
|
62085
|
-
content = await fs
|
|
62085
|
+
content = await fs.readFile(absPath, "utf-8");
|
|
62086
62086
|
} catch (err) {
|
|
62087
62087
|
if (isFileMissingError(err)) return {
|
|
62088
62088
|
text: "",
|
|
@@ -62455,7 +62455,7 @@ const log$25 = createSubsystemLogger("memory");
|
|
|
62455
62455
|
const QMD_MANAGER_CACHE = /* @__PURE__ */ new Map();
|
|
62456
62456
|
let managerRuntimePromise = null;
|
|
62457
62457
|
function loadManagerRuntime() {
|
|
62458
|
-
managerRuntimePromise ??= import("./manager-runtime-
|
|
62458
|
+
managerRuntimePromise ??= import("./manager-runtime-BW_M_Kzt.js");
|
|
62459
62459
|
return managerRuntimePromise;
|
|
62460
62460
|
}
|
|
62461
62461
|
async function getMemorySearchManager(params) {
|
|
@@ -62469,7 +62469,7 @@ async function getMemorySearchManager(params) {
|
|
|
62469
62469
|
if (cached) return { manager: cached };
|
|
62470
62470
|
}
|
|
62471
62471
|
try {
|
|
62472
|
-
const { QmdMemoryManager } = await import("./qmd-manager-
|
|
62472
|
+
const { QmdMemoryManager } = await import("./qmd-manager-BmuMJQP3.js");
|
|
62473
62473
|
const primary = await QmdMemoryManager.create({
|
|
62474
62474
|
cfg: params.cfg,
|
|
62475
62475
|
agentId: params.agentId,
|
|
@@ -63396,7 +63396,7 @@ async function resolveOpenClawDocsPath(params) {
|
|
|
63396
63396
|
const workspaceDir = params.workspaceDir?.trim();
|
|
63397
63397
|
if (workspaceDir) {
|
|
63398
63398
|
const workspaceDocs = path.join(workspaceDir, "docs");
|
|
63399
|
-
if (
|
|
63399
|
+
if (fsSync.existsSync(workspaceDocs)) return workspaceDocs;
|
|
63400
63400
|
}
|
|
63401
63401
|
const packageRoot = await resolveOpenClawPackageRoot({
|
|
63402
63402
|
cwd: params.cwd,
|
|
@@ -63405,7 +63405,7 @@ async function resolveOpenClawDocsPath(params) {
|
|
|
63405
63405
|
});
|
|
63406
63406
|
if (!packageRoot) return null;
|
|
63407
63407
|
const packageDocs = path.join(packageRoot, "docs");
|
|
63408
|
-
return
|
|
63408
|
+
return fsSync.existsSync(packageDocs) ? packageDocs : null;
|
|
63409
63409
|
}
|
|
63410
63410
|
//#endregion
|
|
63411
63411
|
//#region src/agents/model-tool-support.ts
|
|
@@ -64075,7 +64075,7 @@ function resolvePluginTools(params) {
|
|
|
64075
64075
|
//#endregion
|
|
64076
64076
|
//#region src/agents/apply-patch-update.ts
|
|
64077
64077
|
async function defaultReadFile(filePath) {
|
|
64078
|
-
return fs
|
|
64078
|
+
return fs.readFile(filePath, "utf8");
|
|
64079
64079
|
}
|
|
64080
64080
|
async function applyUpdateHunk(filePath, chunks, options) {
|
|
64081
64081
|
const originalLines = (await (options?.readFile ?? defaultReadFile)(filePath).catch((err) => {
|
|
@@ -64400,7 +64400,7 @@ function resolvePatchFileOps(options) {
|
|
|
64400
64400
|
const workspaceOnly = options.workspaceOnly !== false;
|
|
64401
64401
|
return {
|
|
64402
64402
|
readFile: async (filePath) => {
|
|
64403
|
-
if (!workspaceOnly) return await fs
|
|
64403
|
+
if (!workspaceOnly) return await fs.readFile(filePath, "utf8");
|
|
64404
64404
|
const opened = await openBoundaryFile({
|
|
64405
64405
|
absolutePath: filePath,
|
|
64406
64406
|
rootPath: options.cwd,
|
|
@@ -64408,14 +64408,14 @@ function resolvePatchFileOps(options) {
|
|
|
64408
64408
|
});
|
|
64409
64409
|
assertBoundaryRead(opened, filePath);
|
|
64410
64410
|
try {
|
|
64411
|
-
return
|
|
64411
|
+
return fsSync.readFileSync(opened.fd, "utf8");
|
|
64412
64412
|
} finally {
|
|
64413
|
-
|
|
64413
|
+
fsSync.closeSync(opened.fd);
|
|
64414
64414
|
}
|
|
64415
64415
|
},
|
|
64416
64416
|
writeFile: async (filePath, content) => {
|
|
64417
64417
|
if (!workspaceOnly) {
|
|
64418
|
-
await fs
|
|
64418
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
64419
64419
|
return;
|
|
64420
64420
|
}
|
|
64421
64421
|
const relative = toRelativeSandboxPath(options.cwd, filePath);
|
|
@@ -64426,8 +64426,8 @@ function resolvePatchFileOps(options) {
|
|
|
64426
64426
|
encoding: "utf8"
|
|
64427
64427
|
});
|
|
64428
64428
|
},
|
|
64429
|
-
remove: (filePath) => fs
|
|
64430
|
-
mkdirp: (dir) => fs
|
|
64429
|
+
remove: (filePath) => fs.rm(filePath),
|
|
64430
|
+
mkdirp: (dir) => fs.mkdir(dir, { recursive: true }).then(() => {})
|
|
64431
64431
|
};
|
|
64432
64432
|
}
|
|
64433
64433
|
async function ensureDir$2(filePath, ops) {
|
|
@@ -64690,7 +64690,7 @@ function mergeLegacyAgent(current, legacy) {
|
|
|
64690
64690
|
}
|
|
64691
64691
|
function ensureDir$1(filePath) {
|
|
64692
64692
|
const dir = path.dirname(filePath);
|
|
64693
|
-
|
|
64693
|
+
fsSync.mkdirSync(dir, { recursive: true });
|
|
64694
64694
|
}
|
|
64695
64695
|
function coerceAllowlistEntries(allowlist) {
|
|
64696
64696
|
if (!Array.isArray(allowlist) || allowlist.length === 0) return Array.isArray(allowlist) ? allowlist : void 0;
|
|
@@ -64760,11 +64760,11 @@ function generateToken() {
|
|
|
64760
64760
|
function loadExecApprovals() {
|
|
64761
64761
|
const filePath = resolveExecApprovalsPath();
|
|
64762
64762
|
try {
|
|
64763
|
-
if (!
|
|
64763
|
+
if (!fsSync.existsSync(filePath)) return normalizeExecApprovals({
|
|
64764
64764
|
version: 1,
|
|
64765
64765
|
agents: {}
|
|
64766
64766
|
});
|
|
64767
|
-
const raw =
|
|
64767
|
+
const raw = fsSync.readFileSync(filePath, "utf8");
|
|
64768
64768
|
const parsed = JSON.parse(raw);
|
|
64769
64769
|
if (parsed?.version !== 1) return normalizeExecApprovals({
|
|
64770
64770
|
version: 1,
|
|
@@ -64781,9 +64781,9 @@ function loadExecApprovals() {
|
|
|
64781
64781
|
function saveExecApprovals(file) {
|
|
64782
64782
|
const filePath = resolveExecApprovalsPath();
|
|
64783
64783
|
ensureDir$1(filePath);
|
|
64784
|
-
|
|
64784
|
+
fsSync.writeFileSync(filePath, `${JSON.stringify(file, null, 2)}\n`, { mode: 384 });
|
|
64785
64785
|
try {
|
|
64786
|
-
|
|
64786
|
+
fsSync.chmodSync(filePath, 384);
|
|
64787
64787
|
} catch {}
|
|
64788
64788
|
}
|
|
64789
64789
|
function ensureExecApprovals() {
|
|
@@ -65584,18 +65584,18 @@ function applyPathPrepend(env, prepend, options) {
|
|
|
65584
65584
|
function resolvePowerShellPath() {
|
|
65585
65585
|
const programFiles = process.env.ProgramFiles || process.env.PROGRAMFILES || "C:\\Program Files";
|
|
65586
65586
|
const pwsh7 = path.join(programFiles, "PowerShell", "7", "pwsh.exe");
|
|
65587
|
-
if (
|
|
65587
|
+
if (fsSync.existsSync(pwsh7)) return pwsh7;
|
|
65588
65588
|
const programW6432 = process.env.ProgramW6432;
|
|
65589
65589
|
if (programW6432 && programW6432 !== programFiles) {
|
|
65590
65590
|
const pwsh7Alt = path.join(programW6432, "PowerShell", "7", "pwsh.exe");
|
|
65591
|
-
if (
|
|
65591
|
+
if (fsSync.existsSync(pwsh7Alt)) return pwsh7Alt;
|
|
65592
65592
|
}
|
|
65593
65593
|
const pwshInPath = resolveShellFromPath("pwsh");
|
|
65594
65594
|
if (pwshInPath) return pwshInPath;
|
|
65595
65595
|
const systemRoot = process.env.SystemRoot || process.env.WINDIR;
|
|
65596
65596
|
if (systemRoot) {
|
|
65597
65597
|
const candidate = path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
65598
|
-
if (
|
|
65598
|
+
if (fsSync.existsSync(candidate)) return candidate;
|
|
65599
65599
|
}
|
|
65600
65600
|
return "powershell.exe";
|
|
65601
65601
|
}
|
|
@@ -65633,7 +65633,7 @@ function resolveShellFromPath(name) {
|
|
|
65633
65633
|
for (const entry of entries) {
|
|
65634
65634
|
const candidate = path.join(entry, name);
|
|
65635
65635
|
try {
|
|
65636
|
-
|
|
65636
|
+
fsSync.accessSync(candidate, fsSync.constants.X_OK);
|
|
65637
65637
|
return candidate;
|
|
65638
65638
|
} catch {}
|
|
65639
65639
|
}
|
|
@@ -66387,7 +66387,7 @@ async function resolveSandboxWorkdir(params) {
|
|
|
66387
66387
|
cwd: process.cwd(),
|
|
66388
66388
|
root: params.sandbox.workspaceDir
|
|
66389
66389
|
});
|
|
66390
|
-
if (!(await fs
|
|
66390
|
+
if (!(await fs.stat(resolved.resolved)).isDirectory()) throw new Error("workdir is not a directory");
|
|
66391
66391
|
const relative = resolved.relative ? resolved.relative.split(path.sep).join(path.posix.sep) : "";
|
|
66392
66392
|
const containerWorkdir = relative ? path.posix.join(params.sandbox.containerWorkdir, relative) : params.sandbox.containerWorkdir;
|
|
66393
66393
|
return {
|
|
@@ -66856,7 +66856,7 @@ function resolveDefaultIdentityPath() {
|
|
|
66856
66856
|
return path.join(resolveStateDir(), "identity", "device.json");
|
|
66857
66857
|
}
|
|
66858
66858
|
function ensureDir(filePath) {
|
|
66859
|
-
|
|
66859
|
+
fsSync.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
66860
66860
|
}
|
|
66861
66861
|
const ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
66862
66862
|
function base64UrlEncode(buf) {
|
|
@@ -66892,8 +66892,8 @@ function generateIdentity() {
|
|
|
66892
66892
|
}
|
|
66893
66893
|
function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
66894
66894
|
try {
|
|
66895
|
-
if (
|
|
66896
|
-
const raw =
|
|
66895
|
+
if (fsSync.existsSync(filePath)) {
|
|
66896
|
+
const raw = fsSync.readFileSync(filePath, "utf8");
|
|
66897
66897
|
const parsed = JSON.parse(raw);
|
|
66898
66898
|
if (parsed?.version === 1 && typeof parsed.deviceId === "string" && typeof parsed.publicKeyPem === "string" && typeof parsed.privateKeyPem === "string") {
|
|
66899
66899
|
const derivedId = fingerprintPublicKey(parsed.publicKeyPem);
|
|
@@ -66902,9 +66902,9 @@ function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
|
66902
66902
|
...parsed,
|
|
66903
66903
|
deviceId: derivedId
|
|
66904
66904
|
};
|
|
66905
|
-
|
|
66905
|
+
fsSync.writeFileSync(filePath, `${JSON.stringify(updated, null, 2)}\n`, { mode: 384 });
|
|
66906
66906
|
try {
|
|
66907
|
-
|
|
66907
|
+
fsSync.chmodSync(filePath, 384);
|
|
66908
66908
|
} catch {}
|
|
66909
66909
|
return {
|
|
66910
66910
|
deviceId: derivedId,
|
|
@@ -66929,9 +66929,9 @@ function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
|
66929
66929
|
privateKeyPem: identity.privateKeyPem,
|
|
66930
66930
|
createdAtMs: Date.now()
|
|
66931
66931
|
};
|
|
66932
|
-
|
|
66932
|
+
fsSync.writeFileSync(filePath, `${JSON.stringify(stored, null, 2)}\n`, { mode: 384 });
|
|
66933
66933
|
try {
|
|
66934
|
-
|
|
66934
|
+
fsSync.chmodSync(filePath, 384);
|
|
66935
66935
|
} catch {}
|
|
66936
66936
|
return identity;
|
|
66937
66937
|
}
|
|
@@ -66952,7 +66952,7 @@ function normalizeFingerprint(input) {
|
|
|
66952
66952
|
const execFileAsync = promisify(execFile);
|
|
66953
66953
|
async function fileExists(filePath) {
|
|
66954
66954
|
try {
|
|
66955
|
-
await fs
|
|
66955
|
+
await fs.access(filePath);
|
|
66956
66956
|
return true;
|
|
66957
66957
|
} catch {
|
|
66958
66958
|
return false;
|
|
@@ -66979,8 +66979,8 @@ async function generateSelfSignedCert(params) {
|
|
|
66979
66979
|
"-subj",
|
|
66980
66980
|
"/CN=openclaw-gateway"
|
|
66981
66981
|
]);
|
|
66982
|
-
await fs
|
|
66983
|
-
await fs
|
|
66982
|
+
await fs.chmod(params.keyPath, 384).catch(() => {});
|
|
66983
|
+
await fs.chmod(params.certPath, 384).catch(() => {});
|
|
66984
66984
|
params.log?.info?.(`gateway tls: generated self-signed cert at ${shortenHomeInString(params.certPath)}`);
|
|
66985
66985
|
}
|
|
66986
66986
|
async function loadGatewayTlsRuntime(cfg, log) {
|
|
@@ -67018,9 +67018,9 @@ async function loadGatewayTlsRuntime(cfg, log) {
|
|
|
67018
67018
|
error: "gateway tls: cert/key missing"
|
|
67019
67019
|
};
|
|
67020
67020
|
try {
|
|
67021
|
-
const cert = await fs
|
|
67022
|
-
const key = await fs
|
|
67023
|
-
const ca = caPath ? await fs
|
|
67021
|
+
const cert = await fs.readFile(certPath, "utf8");
|
|
67022
|
+
const key = await fs.readFile(keyPath, "utf8");
|
|
67023
|
+
const ca = caPath ? await fs.readFile(caPath, "utf8") : void 0;
|
|
67024
67024
|
const fingerprintSha256 = normalizeFingerprint(new X509Certificate(cert).fingerprint256 ?? "");
|
|
67025
67025
|
if (!fingerprintSha256) return {
|
|
67026
67026
|
enabled: false,
|
|
@@ -67139,8 +67139,8 @@ function resolveDeviceAuthPath(env = process.env) {
|
|
|
67139
67139
|
}
|
|
67140
67140
|
function readStore(filePath) {
|
|
67141
67141
|
try {
|
|
67142
|
-
if (!
|
|
67143
|
-
const raw =
|
|
67142
|
+
if (!fsSync.existsSync(filePath)) return null;
|
|
67143
|
+
const raw = fsSync.readFileSync(filePath, "utf8");
|
|
67144
67144
|
const parsed = JSON.parse(raw);
|
|
67145
67145
|
if (parsed?.version !== 1 || typeof parsed.deviceId !== "string") return null;
|
|
67146
67146
|
if (!parsed.tokens || typeof parsed.tokens !== "object") return null;
|
|
@@ -67150,10 +67150,10 @@ function readStore(filePath) {
|
|
|
67150
67150
|
}
|
|
67151
67151
|
}
|
|
67152
67152
|
function writeStore(filePath, store) {
|
|
67153
|
-
|
|
67154
|
-
|
|
67153
|
+
fsSync.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
67154
|
+
fsSync.writeFileSync(filePath, `${JSON.stringify(store, null, 2)}\n`, { mode: 384 });
|
|
67155
67155
|
try {
|
|
67156
|
-
|
|
67156
|
+
fsSync.chmodSync(filePath, 384);
|
|
67157
67157
|
} catch {}
|
|
67158
67158
|
}
|
|
67159
67159
|
function loadDeviceAuthToken(params) {
|
|
@@ -69948,7 +69948,7 @@ async function imageResult(params) {
|
|
|
69948
69948
|
}, params.label, params.imageSanitization);
|
|
69949
69949
|
}
|
|
69950
69950
|
async function imageResultFromFile(params) {
|
|
69951
|
-
const buf = await fs
|
|
69951
|
+
const buf = await fs.readFile(params.path);
|
|
69952
69952
|
const mimeType = await detectMime({ buffer: buf.slice(0, 256) }) ?? "image/png";
|
|
69953
69953
|
return await imageResult({
|
|
69954
69954
|
label: params.label,
|
|
@@ -71299,13 +71299,13 @@ async function validateScriptFileForShellBleed(params) {
|
|
|
71299
71299
|
cwd: params.workdir,
|
|
71300
71300
|
root: params.workdir
|
|
71301
71301
|
});
|
|
71302
|
-
stat = await fs
|
|
71302
|
+
stat = await fs.stat(absPath);
|
|
71303
71303
|
} catch {
|
|
71304
71304
|
return;
|
|
71305
71305
|
}
|
|
71306
71306
|
if (!stat.isFile()) return;
|
|
71307
71307
|
if (stat.size > 512 * 1024) return;
|
|
71308
|
-
const content = await fs
|
|
71308
|
+
const content = await fs.readFile(absPath, "utf-8");
|
|
71309
71309
|
const first = /\$[A-Z_][A-Z0-9_]{1,}/g.exec(content);
|
|
71310
71310
|
if (first) {
|
|
71311
71311
|
const idx = first.index;
|
|
@@ -76816,7 +76816,7 @@ function asBoolean(value) {
|
|
|
76816
76816
|
}
|
|
76817
76817
|
function resolveTempPathParts(opts) {
|
|
76818
76818
|
const tmpDir = opts.tmpDir ?? resolvePreferredOpenClawTmpDir();
|
|
76819
|
-
if (!opts.tmpDir)
|
|
76819
|
+
if (!opts.tmpDir) fsSync.mkdirSync(tmpDir, {
|
|
76820
76820
|
recursive: true,
|
|
76821
76821
|
mode: 448
|
|
76822
76822
|
});
|
|
@@ -76901,7 +76901,7 @@ async function writeUrlToFile(filePath, url, opts) {
|
|
|
76901
76901
|
if (typeof contentLength === "number" && Number.isFinite(contentLength) && contentLength > MAX_CAMERA_URL_DOWNLOAD_BYTES) throw new Error(`writeUrlToFile: content-length ${contentLength} exceeds max ${MAX_CAMERA_URL_DOWNLOAD_BYTES}`);
|
|
76902
76902
|
const body = res.body;
|
|
76903
76903
|
if (!body) throw new Error(`failed to download ${url}: empty response body`);
|
|
76904
|
-
const fileHandle = await fs$
|
|
76904
|
+
const fileHandle = await fs$1.open(filePath, "w");
|
|
76905
76905
|
let thrown;
|
|
76906
76906
|
try {
|
|
76907
76907
|
const reader = body.getReader();
|
|
@@ -76919,7 +76919,7 @@ async function writeUrlToFile(filePath, url, opts) {
|
|
|
76919
76919
|
await fileHandle.close();
|
|
76920
76920
|
}
|
|
76921
76921
|
if (thrown) {
|
|
76922
|
-
await fs$
|
|
76922
|
+
await fs$1.unlink(filePath).catch(() => {});
|
|
76923
76923
|
throw thrown;
|
|
76924
76924
|
}
|
|
76925
76925
|
} finally {
|
|
@@ -76932,7 +76932,7 @@ async function writeUrlToFile(filePath, url, opts) {
|
|
|
76932
76932
|
}
|
|
76933
76933
|
async function writeBase64ToFile(filePath, base64) {
|
|
76934
76934
|
const buf = Buffer.from(base64, "base64");
|
|
76935
|
-
await fs$
|
|
76935
|
+
await fs$1.writeFile(filePath, buf);
|
|
76936
76936
|
return {
|
|
76937
76937
|
path: filePath,
|
|
76938
76938
|
bytes: buf.length
|
|
@@ -77015,7 +77015,7 @@ async function readJsonlFromPath(jsonlPath) {
|
|
|
77015
77015
|
if (shouldLogVerbose()) logVerbose(`Blocked canvas jsonlPath outside allowed roots: ${resolved}`);
|
|
77016
77016
|
throw new Error("jsonlPath outside allowed roots");
|
|
77017
77017
|
}
|
|
77018
|
-
const canonical = await fs
|
|
77018
|
+
const canonical = await fs.realpath(resolved).catch(() => resolved);
|
|
77019
77019
|
if (!isInboundPathAllowed({
|
|
77020
77020
|
filePath: canonical,
|
|
77021
77021
|
roots
|
|
@@ -77023,7 +77023,7 @@ async function readJsonlFromPath(jsonlPath) {
|
|
|
77023
77023
|
if (shouldLogVerbose()) logVerbose(`Blocked canvas jsonlPath outside allowed roots: ${canonical}`);
|
|
77024
77024
|
throw new Error("jsonlPath outside allowed roots");
|
|
77025
77025
|
}
|
|
77026
|
-
return await fs
|
|
77026
|
+
return await fs.readFile(canonical, "utf8");
|
|
77027
77027
|
}
|
|
77028
77028
|
const CanvasToolSchema = Type.Object({
|
|
77029
77029
|
action: stringEnum(CANVAS_ACTIONS),
|
|
@@ -77956,12 +77956,12 @@ function resolveRestartSentinelPath(env = process.env) {
|
|
|
77956
77956
|
}
|
|
77957
77957
|
async function writeRestartSentinel(payload, env = process.env) {
|
|
77958
77958
|
const filePath = resolveRestartSentinelPath(env);
|
|
77959
|
-
await fs
|
|
77959
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
77960
77960
|
const data = {
|
|
77961
77961
|
version: 1,
|
|
77962
77962
|
payload
|
|
77963
77963
|
};
|
|
77964
|
-
await fs
|
|
77964
|
+
await fs.writeFile(filePath, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
|
|
77965
77965
|
return filePath;
|
|
77966
77966
|
}
|
|
77967
77967
|
//#endregion
|
|
@@ -78329,7 +78329,7 @@ function relaunchGatewayScheduledTask(env = process.env) {
|
|
|
78329
78329
|
const scriptPath = path.join(resolvePreferredOpenClawTmpDir(), `openclaw-schtasks-restart-${randomUUID()}.cmd`);
|
|
78330
78330
|
const quotedScriptPath = quoteCmdScriptArg(scriptPath);
|
|
78331
78331
|
try {
|
|
78332
|
-
|
|
78332
|
+
fsSync.writeFileSync(scriptPath, `${buildScheduledTaskRestartScript(taskName)}\r\n`, "utf8");
|
|
78333
78333
|
spawn("cmd.exe", [
|
|
78334
78334
|
"/d",
|
|
78335
78335
|
"/s",
|
|
@@ -78347,7 +78347,7 @@ function relaunchGatewayScheduledTask(env = process.env) {
|
|
|
78347
78347
|
};
|
|
78348
78348
|
} catch (err) {
|
|
78349
78349
|
try {
|
|
78350
|
-
|
|
78350
|
+
fsSync.unlinkSync(scriptPath);
|
|
78351
78351
|
} catch {}
|
|
78352
78352
|
return {
|
|
78353
78353
|
ok: false,
|
|
@@ -81403,9 +81403,9 @@ function loadExternalCatalogEntries(options) {
|
|
|
81403
81403
|
const entries = [];
|
|
81404
81404
|
for (const rawPath of paths) {
|
|
81405
81405
|
const resolved = resolveUserPath(rawPath, env);
|
|
81406
|
-
if (!
|
|
81406
|
+
if (!fsSync.existsSync(resolved)) continue;
|
|
81407
81407
|
try {
|
|
81408
|
-
const payload = JSON.parse(
|
|
81408
|
+
const payload = JSON.parse(fsSync.readFileSync(resolved, "utf-8"));
|
|
81409
81409
|
entries.push(...parseCatalogEntries(payload));
|
|
81410
81410
|
} catch {}
|
|
81411
81411
|
}
|
|
@@ -82670,17 +82670,17 @@ function getErrnoCode(err) {
|
|
|
82670
82670
|
}
|
|
82671
82671
|
async function unlinkBestEffort(filePath) {
|
|
82672
82672
|
try {
|
|
82673
|
-
await
|
|
82673
|
+
await fsSync.promises.unlink(filePath);
|
|
82674
82674
|
} catch {}
|
|
82675
82675
|
}
|
|
82676
82676
|
/** Ensure the queue directory (and failed/ subdirectory) exist. */
|
|
82677
82677
|
async function ensureQueueDir(stateDir) {
|
|
82678
82678
|
const queueDir = resolveQueueDir(stateDir);
|
|
82679
|
-
await
|
|
82679
|
+
await fsSync.promises.mkdir(queueDir, {
|
|
82680
82680
|
recursive: true,
|
|
82681
82681
|
mode: 448
|
|
82682
82682
|
});
|
|
82683
|
-
await
|
|
82683
|
+
await fsSync.promises.mkdir(resolveFailedDir(stateDir), {
|
|
82684
82684
|
recursive: true,
|
|
82685
82685
|
mode: 448
|
|
82686
82686
|
});
|
|
@@ -82708,11 +82708,11 @@ async function enqueueDelivery(params, stateDir) {
|
|
|
82708
82708
|
const filePath = path.join(queueDir, `${id}.json`);
|
|
82709
82709
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
82710
82710
|
const json = JSON.stringify(entry, null, 2);
|
|
82711
|
-
await
|
|
82711
|
+
await fsSync.promises.writeFile(tmp, json, {
|
|
82712
82712
|
encoding: "utf-8",
|
|
82713
82713
|
mode: 384
|
|
82714
82714
|
});
|
|
82715
|
-
await
|
|
82715
|
+
await fsSync.promises.rename(tmp, filePath);
|
|
82716
82716
|
return id;
|
|
82717
82717
|
}
|
|
82718
82718
|
/** Remove a successfully delivered entry from the queue.
|
|
@@ -82727,7 +82727,7 @@ async function enqueueDelivery(params, stateDir) {
|
|
|
82727
82727
|
async function ackDelivery(id, stateDir) {
|
|
82728
82728
|
const { jsonPath, deliveredPath } = resolveQueueEntryPaths(id, stateDir);
|
|
82729
82729
|
try {
|
|
82730
|
-
await
|
|
82730
|
+
await fsSync.promises.rename(jsonPath, deliveredPath);
|
|
82731
82731
|
} catch (err) {
|
|
82732
82732
|
if (getErrnoCode(err) === "ENOENT") {
|
|
82733
82733
|
await unlinkBestEffort(deliveredPath);
|
|
@@ -82740,17 +82740,17 @@ async function ackDelivery(id, stateDir) {
|
|
|
82740
82740
|
/** Update a queue entry after a failed delivery attempt. */
|
|
82741
82741
|
async function failDelivery(id, error, stateDir) {
|
|
82742
82742
|
const filePath = path.join(resolveQueueDir(stateDir), `${id}.json`);
|
|
82743
|
-
const raw = await
|
|
82743
|
+
const raw = await fsSync.promises.readFile(filePath, "utf-8");
|
|
82744
82744
|
const entry = JSON.parse(raw);
|
|
82745
82745
|
entry.retryCount += 1;
|
|
82746
82746
|
entry.lastAttemptAt = Date.now();
|
|
82747
82747
|
entry.lastError = error;
|
|
82748
82748
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
82749
|
-
await
|
|
82749
|
+
await fsSync.promises.writeFile(tmp, JSON.stringify(entry, null, 2), {
|
|
82750
82750
|
encoding: "utf-8",
|
|
82751
82751
|
mode: 384
|
|
82752
82752
|
});
|
|
82753
|
-
await
|
|
82753
|
+
await fsSync.promises.rename(tmp, filePath);
|
|
82754
82754
|
}
|
|
82755
82755
|
//#endregion
|
|
82756
82756
|
//#region src/auto-reply/reply/reply-tags.ts
|
|
@@ -88648,7 +88648,7 @@ function normalizeReplyPayload(payload, opts = {}) {
|
|
|
88648
88648
|
*/
|
|
88649
88649
|
let deliverRuntimePromise$2 = null;
|
|
88650
88650
|
function loadDeliverRuntime$2() {
|
|
88651
|
-
deliverRuntimePromise$2 ??= import("./deliver-runtime-
|
|
88651
|
+
deliverRuntimePromise$2 ??= import("./deliver-runtime-BBwve6gL.js");
|
|
88652
88652
|
return deliverRuntimePromise$2;
|
|
88653
88653
|
}
|
|
88654
88654
|
/**
|
|
@@ -89198,7 +89198,7 @@ function ensureContextWindowCacheLoaded() {
|
|
|
89198
89198
|
await ensureOpenClawModelsJson(cfg);
|
|
89199
89199
|
} catch {}
|
|
89200
89200
|
try {
|
|
89201
|
-
const { discoverAuthStorage, discoverModels } = await import("./pi-model-discovery-runtime-
|
|
89201
|
+
const { discoverAuthStorage, discoverModels } = await import("./pi-model-discovery-runtime-CLfgSk3o.js");
|
|
89202
89202
|
const agentDir = resolveOpenClawAgentDir();
|
|
89203
89203
|
const modelRegistry = discoverModels(discoverAuthStorage(agentDir), agentDir);
|
|
89204
89204
|
applyDiscoveredContextWindows({
|
|
@@ -89458,7 +89458,7 @@ function walkUpFrom(startDir, opts, resolveAtDir) {
|
|
|
89458
89458
|
function hasGitMarker(repoRoot) {
|
|
89459
89459
|
const gitPath = path.join(repoRoot, ".git");
|
|
89460
89460
|
try {
|
|
89461
|
-
const stat =
|
|
89461
|
+
const stat = fsSync.statSync(gitPath);
|
|
89462
89462
|
return stat.isDirectory() || stat.isFile();
|
|
89463
89463
|
} catch {
|
|
89464
89464
|
return false;
|
|
@@ -89470,10 +89470,10 @@ function findGitRoot(startDir, opts = {}) {
|
|
|
89470
89470
|
function resolveGitDirFromMarker(repoRoot) {
|
|
89471
89471
|
const gitPath = path.join(repoRoot, ".git");
|
|
89472
89472
|
try {
|
|
89473
|
-
const stat =
|
|
89473
|
+
const stat = fsSync.statSync(gitPath);
|
|
89474
89474
|
if (stat.isDirectory()) return gitPath;
|
|
89475
89475
|
if (!stat.isFile()) return null;
|
|
89476
|
-
const match =
|
|
89476
|
+
const match = fsSync.readFileSync(gitPath, "utf-8").match(/gitdir:\s*(.+)/i);
|
|
89477
89477
|
if (!match?.[1]) return null;
|
|
89478
89478
|
return path.resolve(repoRoot, match[1].trim());
|
|
89479
89479
|
} catch {
|
|
@@ -89511,13 +89511,13 @@ const resolveCommitSearchDir = (options) => {
|
|
|
89511
89511
|
};
|
|
89512
89512
|
/** Read at most `limit` bytes from a file to avoid unbounded reads. */
|
|
89513
89513
|
const safeReadFilePrefix = (filePath, limit = 256) => {
|
|
89514
|
-
const fd =
|
|
89514
|
+
const fd = fsSync.openSync(filePath, "r");
|
|
89515
89515
|
try {
|
|
89516
89516
|
const buf = Buffer.alloc(limit);
|
|
89517
|
-
const bytesRead =
|
|
89517
|
+
const bytesRead = fsSync.readSync(fd, buf, 0, limit, 0);
|
|
89518
89518
|
return buf.subarray(0, bytesRead).toString("utf-8");
|
|
89519
89519
|
} finally {
|
|
89520
|
-
|
|
89520
|
+
fsSync.closeSync(fd);
|
|
89521
89521
|
}
|
|
89522
89522
|
};
|
|
89523
89523
|
const cacheGitCommit = (searchDir, commit) => {
|
|
@@ -89533,7 +89533,7 @@ const resolveGitLookupDepth = (searchDir, packageRoot) => {
|
|
|
89533
89533
|
const readCommitFromGit = (searchDir, packageRoot) => {
|
|
89534
89534
|
const headPath = resolveGitHeadPath(searchDir, { maxDepth: resolveGitLookupDepth(searchDir, packageRoot) });
|
|
89535
89535
|
if (!headPath) return;
|
|
89536
|
-
const head =
|
|
89536
|
+
const head = fsSync.readFileSync(headPath, "utf-8").trim();
|
|
89537
89537
|
if (!head) return null;
|
|
89538
89538
|
if (head.startsWith("ref:")) {
|
|
89539
89539
|
const refPath = resolveRefPath(headPath, head.replace(/^ref:\s*/i, "").trim());
|
|
@@ -89860,17 +89860,17 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
|
|
|
89860
89860
|
} catch {
|
|
89861
89861
|
return;
|
|
89862
89862
|
}
|
|
89863
|
-
if (!
|
|
89863
|
+
if (!fsSync.existsSync(logPath)) return;
|
|
89864
89864
|
try {
|
|
89865
89865
|
const TAIL_BYTES = 8192;
|
|
89866
|
-
const stat =
|
|
89866
|
+
const stat = fsSync.statSync(logPath);
|
|
89867
89867
|
const offset = Math.max(0, stat.size - TAIL_BYTES);
|
|
89868
89868
|
const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
|
|
89869
|
-
const fd =
|
|
89869
|
+
const fd = fsSync.openSync(logPath, "r");
|
|
89870
89870
|
try {
|
|
89871
|
-
|
|
89871
|
+
fsSync.readSync(fd, buf, 0, buf.length, offset);
|
|
89872
89872
|
} finally {
|
|
89873
|
-
|
|
89873
|
+
fsSync.closeSync(fd);
|
|
89874
89874
|
}
|
|
89875
89875
|
const tail = buf.toString("utf-8");
|
|
89876
89876
|
const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
|
|
@@ -90437,8 +90437,8 @@ function resolveZaiApiKey() {
|
|
|
90437
90437
|
}
|
|
90438
90438
|
try {
|
|
90439
90439
|
const authPath = path.join(resolveRequiredHomeDir(process.env, os.homedir), ".pi", "agent", "auth.json");
|
|
90440
|
-
if (!
|
|
90441
|
-
const data = JSON.parse(
|
|
90440
|
+
if (!fsSync.existsSync(authPath)) return;
|
|
90441
|
+
const data = JSON.parse(fsSync.readFileSync(authPath, "utf-8"));
|
|
90442
90442
|
return data["z-ai"]?.access || data.zai?.access;
|
|
90443
90443
|
} catch {
|
|
90444
90444
|
return;
|
|
@@ -94118,7 +94118,7 @@ function normalizeSessionKey$1(value) {
|
|
|
94118
94118
|
}
|
|
94119
94119
|
function readSessionStore$1(storePath) {
|
|
94120
94120
|
try {
|
|
94121
|
-
const raw =
|
|
94121
|
+
const raw = fsSync.readFileSync(storePath, "utf-8");
|
|
94122
94122
|
const parsed = JSON5.parse(raw);
|
|
94123
94123
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
94124
94124
|
} catch {}
|
|
@@ -94198,7 +94198,7 @@ const MAX_TIMER_SAFE_TIMEOUT_MS = 2147e6;
|
|
|
94198
94198
|
const GATEWAY_TIMEOUT_PATTERN = /gateway timeout/i;
|
|
94199
94199
|
let subagentRegistryRuntimePromise = null;
|
|
94200
94200
|
function loadSubagentRegistryRuntime() {
|
|
94201
|
-
subagentRegistryRuntimePromise ??= import("./subagent-registry-runtime-
|
|
94201
|
+
subagentRegistryRuntimePromise ??= import("./subagent-registry-runtime-1IiL0xom.js");
|
|
94202
94202
|
return subagentRegistryRuntimePromise;
|
|
94203
94203
|
}
|
|
94204
94204
|
const DIRECT_ANNOUNCE_TRANSIENT_RETRY_DELAYS_MS = FAST_TEST_MODE ? [
|
|
@@ -100223,7 +100223,7 @@ const LOOP_WARNING_BUCKET_SIZE = 10;
|
|
|
100223
100223
|
const MAX_LOOP_WARNING_KEYS = 256;
|
|
100224
100224
|
let beforeToolCallRuntimePromise = null;
|
|
100225
100225
|
function loadBeforeToolCallRuntime() {
|
|
100226
|
-
beforeToolCallRuntimePromise ??= import("./pi-tools.before-tool-call.runtime-
|
|
100226
|
+
beforeToolCallRuntimePromise ??= import("./pi-tools.before-tool-call.runtime-CKzFGrVv.js");
|
|
100227
100227
|
return beforeToolCallRuntimePromise;
|
|
100228
100228
|
}
|
|
100229
100229
|
function buildAdjustedParamsKey(params) {
|
|
@@ -100674,7 +100674,7 @@ function wrapHostEditToolWithPostWriteRecovery(base, root) {
|
|
|
100674
100674
|
if (!pathParam || !newText) throw err;
|
|
100675
100675
|
try {
|
|
100676
100676
|
const absolutePath = resolveHostEditPath(root, pathParam);
|
|
100677
|
-
const content = await fs
|
|
100677
|
+
const content = await fs.readFile(absolutePath, "utf-8");
|
|
100678
100678
|
const hasNew = content.includes(newText);
|
|
100679
100679
|
const stillHasOld = oldText !== void 0 && oldText.length > 0 && content.includes(oldText);
|
|
100680
100680
|
if (hasNew && !stillHasOld) return {
|
|
@@ -101055,7 +101055,7 @@ async function readOptionalUtf8File(params) {
|
|
|
101055
101055
|
signal: params.signal
|
|
101056
101056
|
})).toString("utf-8");
|
|
101057
101057
|
}
|
|
101058
|
-
return await fs
|
|
101058
|
+
return await fs.readFile(params.absolutePath, "utf-8");
|
|
101059
101059
|
} catch (error) {
|
|
101060
101060
|
if (error?.code === "ENOENT") return "";
|
|
101061
101061
|
throw error;
|
|
@@ -101095,8 +101095,8 @@ async function appendMemoryFlushContent(params) {
|
|
|
101095
101095
|
});
|
|
101096
101096
|
return;
|
|
101097
101097
|
}
|
|
101098
|
-
await fs
|
|
101099
|
-
await fs
|
|
101098
|
+
await fs.mkdir(path.dirname(params.absolutePath), { recursive: true });
|
|
101099
|
+
await fs.writeFile(params.absolutePath, next, "utf-8");
|
|
101100
101100
|
}
|
|
101101
101101
|
function wrapToolMemoryFlushAppendOnlyWrite(tool, options) {
|
|
101102
101102
|
const allowedAbsolutePath = path.resolve(options.root, options.relativePath);
|
|
@@ -101254,14 +101254,14 @@ function createSandboxEditOperations(params) {
|
|
|
101254
101254
|
}
|
|
101255
101255
|
async function writeHostFile(absolutePath, content) {
|
|
101256
101256
|
const resolved = path.resolve(absolutePath);
|
|
101257
|
-
await fs
|
|
101258
|
-
await fs
|
|
101257
|
+
await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
101258
|
+
await fs.writeFile(resolved, content, "utf-8");
|
|
101259
101259
|
}
|
|
101260
101260
|
function createHostWriteOperations(root, options) {
|
|
101261
101261
|
if (!(options?.workspaceOnly ?? false)) return {
|
|
101262
101262
|
mkdir: async (dir) => {
|
|
101263
101263
|
const resolved = path.resolve(dir);
|
|
101264
|
-
await fs
|
|
101264
|
+
await fs.mkdir(resolved, { recursive: true });
|
|
101265
101265
|
},
|
|
101266
101266
|
writeFile: writeHostFile
|
|
101267
101267
|
};
|
|
@@ -101274,7 +101274,7 @@ function createHostWriteOperations(root, options) {
|
|
|
101274
101274
|
cwd: root,
|
|
101275
101275
|
root
|
|
101276
101276
|
});
|
|
101277
|
-
await fs
|
|
101277
|
+
await fs.mkdir(resolved, { recursive: true });
|
|
101278
101278
|
},
|
|
101279
101279
|
writeFile: async (absolutePath, content) => {
|
|
101280
101280
|
await writeFileWithinRoot({
|
|
@@ -101290,12 +101290,12 @@ function createHostEditOperations(root, options) {
|
|
|
101290
101290
|
if (!(options?.workspaceOnly ?? false)) return {
|
|
101291
101291
|
readFile: async (absolutePath) => {
|
|
101292
101292
|
const resolved = path.resolve(absolutePath);
|
|
101293
|
-
return await fs
|
|
101293
|
+
return await fs.readFile(resolved);
|
|
101294
101294
|
},
|
|
101295
101295
|
writeFile: writeHostFile,
|
|
101296
101296
|
access: async (absolutePath) => {
|
|
101297
101297
|
const resolved = path.resolve(absolutePath);
|
|
101298
|
-
await fs
|
|
101298
|
+
await fs.access(resolved);
|
|
101299
101299
|
}
|
|
101300
101300
|
};
|
|
101301
101301
|
return {
|
|
@@ -102167,7 +102167,7 @@ async function repairSessionFileIfNeeded(params) {
|
|
|
102167
102167
|
};
|
|
102168
102168
|
let content;
|
|
102169
102169
|
try {
|
|
102170
|
-
content = await fs
|
|
102170
|
+
content = await fs.readFile(sessionFile, "utf-8");
|
|
102171
102171
|
} catch (err) {
|
|
102172
102172
|
if (err?.code === "ENOENT") return {
|
|
102173
102173
|
repaired: false,
|
|
@@ -102215,15 +102215,15 @@ async function repairSessionFileIfNeeded(params) {
|
|
|
102215
102215
|
const backupPath = `${sessionFile}.bak-${process.pid}-${Date.now()}`;
|
|
102216
102216
|
const tmpPath = `${sessionFile}.repair-${process.pid}-${Date.now()}.tmp`;
|
|
102217
102217
|
try {
|
|
102218
|
-
const stat = await fs
|
|
102219
|
-
await fs
|
|
102220
|
-
if (stat) await fs
|
|
102221
|
-
await fs
|
|
102222
|
-
if (stat) await fs
|
|
102223
|
-
await fs
|
|
102218
|
+
const stat = await fs.stat(sessionFile).catch(() => null);
|
|
102219
|
+
await fs.writeFile(backupPath, content, "utf-8");
|
|
102220
|
+
if (stat) await fs.chmod(backupPath, stat.mode);
|
|
102221
|
+
await fs.writeFile(tmpPath, cleaned, "utf-8");
|
|
102222
|
+
if (stat) await fs.chmod(tmpPath, stat.mode);
|
|
102223
|
+
await fs.rename(tmpPath, sessionFile);
|
|
102224
102224
|
} catch (err) {
|
|
102225
102225
|
try {
|
|
102226
|
-
await fs
|
|
102226
|
+
await fs.unlink(tmpPath);
|
|
102227
102227
|
} catch (cleanupErr) {
|
|
102228
102228
|
params.warn?.(`session file repair cleanup failed: ${cleanupErr instanceof Error ? cleanupErr.message : "unknown error"} (${path.basename(tmpPath)})`);
|
|
102229
102229
|
}
|
|
@@ -103325,9 +103325,9 @@ async function readPostCompactionContext(workspaceDir, cfg, nowMs) {
|
|
|
103325
103325
|
if (!opened.ok) return null;
|
|
103326
103326
|
const content = (() => {
|
|
103327
103327
|
try {
|
|
103328
|
-
return
|
|
103328
|
+
return fsSync.readFileSync(opened.fd, "utf-8");
|
|
103329
103329
|
} finally {
|
|
103330
|
-
|
|
103330
|
+
fsSync.closeSync(opened.fd);
|
|
103331
103331
|
}
|
|
103332
103332
|
})();
|
|
103333
103333
|
const configuredSections = cfg?.agents?.defaults?.compaction?.postCompactionSections;
|
|
@@ -104079,9 +104079,9 @@ async function readWorkspaceContextForSummary() {
|
|
|
104079
104079
|
if (!opened.ok) return "";
|
|
104080
104080
|
const content = (() => {
|
|
104081
104081
|
try {
|
|
104082
|
-
return
|
|
104082
|
+
return fsSync.readFileSync(opened.fd, "utf-8");
|
|
104083
104083
|
} finally {
|
|
104084
|
-
|
|
104084
|
+
fsSync.closeSync(opened.fd);
|
|
104085
104085
|
}
|
|
104086
104086
|
})();
|
|
104087
104087
|
let sections = extractSections(content, ["Session Startup", "Red Lines"]);
|
|
@@ -105215,7 +105215,7 @@ async function prewarmSessionFile(sessionFile) {
|
|
|
105215
105215
|
if (!isSessionManagerCacheEnabled()) return;
|
|
105216
105216
|
if (isSessionManagerCached(sessionFile)) return;
|
|
105217
105217
|
try {
|
|
105218
|
-
const handle = await fs
|
|
105218
|
+
const handle = await fs.open(sessionFile, "r");
|
|
105219
105219
|
try {
|
|
105220
105220
|
const buffer = Buffer$1.alloc(4096);
|
|
105221
105221
|
await handle.read(buffer, 0, buffer.length, 0);
|
|
@@ -106096,14 +106096,14 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
106096
106096
|
if (!apiKeyInfo.apiKey) {
|
|
106097
106097
|
if (apiKeyInfo.mode !== "aws-sdk") throw new Error(`No API key resolved for provider "${model.provider}" (auth mode: ${apiKeyInfo.mode}).`);
|
|
106098
106098
|
} else if (model.provider === "github-copilot") {
|
|
106099
|
-
const { resolveCopilotApiToken } = await import("./github-copilot-token-
|
|
106099
|
+
const { resolveCopilotApiToken } = await import("./github-copilot-token-BgPOyCXe.js").then((n) => n.n);
|
|
106100
106100
|
const copilotToken = await resolveCopilotApiToken({ githubToken: apiKeyInfo.apiKey });
|
|
106101
106101
|
authStorage.setRuntimeApiKey(model.provider, copilotToken.token);
|
|
106102
106102
|
} else authStorage.setRuntimeApiKey(model.provider, apiKeyInfo.apiKey);
|
|
106103
106103
|
} catch (err) {
|
|
106104
106104
|
return fail(describeUnknownError(err));
|
|
106105
106105
|
}
|
|
106106
|
-
await fs
|
|
106106
|
+
await fs.mkdir(resolvedWorkspace, { recursive: true });
|
|
106107
106107
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
106108
106108
|
const sandbox = await resolveSandboxContext({
|
|
106109
106109
|
config: params.config,
|
|
@@ -106111,7 +106111,7 @@ async function compactEmbeddedPiSessionDirect(params) {
|
|
|
106111
106111
|
workspaceDir: resolvedWorkspace
|
|
106112
106112
|
});
|
|
106113
106113
|
const effectiveWorkspace = sandbox?.enabled ? sandbox.workspaceAccess === "rw" ? resolvedWorkspace : sandbox.workspaceDir : resolvedWorkspace;
|
|
106114
|
-
await fs
|
|
106114
|
+
await fs.mkdir(effectiveWorkspace, { recursive: true });
|
|
106115
106115
|
await ensureSessionHeader$1({
|
|
106116
106116
|
sessionFile: params.sessionFile,
|
|
106117
106117
|
sessionId: params.sessionId,
|
|
@@ -107670,12 +107670,12 @@ function getQueuedFileWriter(writers, filePath) {
|
|
|
107670
107670
|
const existing = writers.get(filePath);
|
|
107671
107671
|
if (existing) return existing;
|
|
107672
107672
|
const dir = path.dirname(filePath);
|
|
107673
|
-
const ready = fs
|
|
107673
|
+
const ready = fs.mkdir(dir, { recursive: true }).catch(() => void 0);
|
|
107674
107674
|
let queue = Promise.resolve();
|
|
107675
107675
|
const writer = {
|
|
107676
107676
|
filePath,
|
|
107677
107677
|
write: (line) => {
|
|
107678
|
-
queue = queue.then(() => ready).then(() => fs
|
|
107678
|
+
queue = queue.then(() => ready).then(() => fs.appendFile(filePath, line, "utf8")).catch(() => void 0);
|
|
107679
107679
|
}
|
|
107680
107680
|
};
|
|
107681
107681
|
writers.set(filePath, writer);
|
|
@@ -109551,11 +109551,11 @@ function appendRawStream(payload) {
|
|
|
109551
109551
|
if (!rawStreamReady) {
|
|
109552
109552
|
rawStreamReady = true;
|
|
109553
109553
|
try {
|
|
109554
|
-
|
|
109554
|
+
fsSync.mkdirSync(path.dirname(RAW_STREAM_PATH), { recursive: true });
|
|
109555
109555
|
} catch {}
|
|
109556
109556
|
}
|
|
109557
109557
|
try {
|
|
109558
|
-
|
|
109558
|
+
fsSync.promises.appendFile(RAW_STREAM_PATH, `${JSON.stringify(payload)}\n`);
|
|
109559
109559
|
} catch {}
|
|
109560
109560
|
}
|
|
109561
109561
|
//#endregion
|
|
@@ -111103,7 +111103,7 @@ function resolveRepoRoot(params) {
|
|
|
111103
111103
|
const configured = params.config?.agents?.defaults?.repoRoot?.trim();
|
|
111104
111104
|
if (configured) try {
|
|
111105
111105
|
const resolved = path.resolve(configured);
|
|
111106
|
-
if (
|
|
111106
|
+
if (fsSync.statSync(resolved).isDirectory()) return resolved;
|
|
111107
111107
|
} catch {}
|
|
111108
111108
|
const candidates = [params.workspaceDir, params.cwd].map((value) => value?.trim()).filter(Boolean);
|
|
111109
111109
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -111398,7 +111398,7 @@ async function prepareSessionManagerForRun(params) {
|
|
|
111398
111398
|
return;
|
|
111399
111399
|
}
|
|
111400
111400
|
if (params.hadSessionFile && header && !hasAssistant) {
|
|
111401
|
-
await fs
|
|
111401
|
+
await fs.writeFile(params.sessionFile, "", "utf-8");
|
|
111402
111402
|
sm.fileEntries = [header];
|
|
111403
111403
|
sm.byId?.clear?.();
|
|
111404
111404
|
sm.labelsById?.clear?.();
|
|
@@ -112599,7 +112599,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
112599
112599
|
ensureGlobalUndiciEnvProxyDispatcher();
|
|
112600
112600
|
ensureGlobalUndiciStreamTimeouts();
|
|
112601
112601
|
log$14.debug(`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${params.provider} model=${params.modelId} thinking=${params.thinkLevel} messageChannel=${params.messageChannel ?? params.messageProvider ?? "unknown"}`);
|
|
112602
|
-
await fs
|
|
112602
|
+
await fs.mkdir(resolvedWorkspace, { recursive: true });
|
|
112603
112603
|
const sandboxSessionKey = params.sessionKey?.trim() || params.sessionId;
|
|
112604
112604
|
const sandbox = await resolveSandboxContext({
|
|
112605
112605
|
config: params.config,
|
|
@@ -112607,7 +112607,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
112607
112607
|
workspaceDir: resolvedWorkspace
|
|
112608
112608
|
});
|
|
112609
112609
|
const effectiveWorkspace = sandbox?.enabled ? sandbox.workspaceAccess === "rw" ? resolvedWorkspace : sandbox.workspaceDir : resolvedWorkspace;
|
|
112610
|
-
await fs
|
|
112610
|
+
await fs.mkdir(effectiveWorkspace, { recursive: true });
|
|
112611
112611
|
let restoreSkillEnv;
|
|
112612
112612
|
process.chdir(effectiveWorkspace);
|
|
112613
112613
|
try {
|
|
@@ -112896,7 +112896,7 @@ async function runEmbeddedAttempt(params) {
|
|
|
112896
112896
|
sessionFile: params.sessionFile,
|
|
112897
112897
|
warn: (message) => log$14.warn(message)
|
|
112898
112898
|
});
|
|
112899
|
-
const hadSessionFile = await fs
|
|
112899
|
+
const hadSessionFile = await fs.stat(params.sessionFile).then(() => true).catch(() => false);
|
|
112900
112900
|
const transcriptPolicy = resolveTranscriptPolicy({
|
|
112901
112901
|
modelApi: params.model?.api,
|
|
112902
112902
|
provider: params.provider,
|
|
@@ -114059,7 +114059,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
114059
114059
|
await copilotTokenState.refreshInFlight;
|
|
114060
114060
|
return;
|
|
114061
114061
|
}
|
|
114062
|
-
const { resolveCopilotApiToken } = await import("./github-copilot-token-
|
|
114062
|
+
const { resolveCopilotApiToken } = await import("./github-copilot-token-BgPOyCXe.js").then((n) => n.n);
|
|
114063
114063
|
copilotTokenState.refreshInFlight = (async () => {
|
|
114064
114064
|
const githubToken = copilotTokenState.githubToken.trim();
|
|
114065
114065
|
if (!githubToken) throw new Error("Copilot refresh requires a GitHub token.");
|
|
@@ -114151,7 +114151,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
114151
114151
|
return;
|
|
114152
114152
|
}
|
|
114153
114153
|
if (model.provider === "github-copilot") {
|
|
114154
|
-
const { resolveCopilotApiToken } = await import("./github-copilot-token-
|
|
114154
|
+
const { resolveCopilotApiToken } = await import("./github-copilot-token-BgPOyCXe.js").then((n) => n.n);
|
|
114155
114155
|
const copilotToken = await resolveCopilotApiToken({ githubToken: apiKeyInfo.apiKey });
|
|
114156
114156
|
authStorage.setRuntimeApiKey(model.provider, copilotToken.token);
|
|
114157
114157
|
if (copilotTokenState) {
|
|
@@ -114306,7 +114306,7 @@ async function runEmbeddedPiAgent(params) {
|
|
|
114306
114306
|
const copilotAuthRetry = authRetryPending;
|
|
114307
114307
|
authRetryPending = false;
|
|
114308
114308
|
attemptedThinking.add(thinkLevel);
|
|
114309
|
-
await fs
|
|
114309
|
+
await fs.mkdir(resolvedWorkspace, { recursive: true });
|
|
114310
114310
|
const prompt = provider === "anthropic" ? scrubAnthropicRefusalMagic(params.prompt) : params.prompt;
|
|
114311
114311
|
const attempt = await runEmbeddedAttempt({
|
|
114312
114312
|
sessionId: params.sessionId,
|
|
@@ -116462,7 +116462,7 @@ async function runWithConcurrency(tasks, limit) {
|
|
|
116462
116462
|
//#region src/media-understanding/echo-transcript.ts
|
|
116463
116463
|
let deliverRuntimePromise$1 = null;
|
|
116464
116464
|
function loadDeliverRuntime$1() {
|
|
116465
|
-
deliverRuntimePromise$1 ??= import("./deliver-runtime-
|
|
116465
|
+
deliverRuntimePromise$1 ??= import("./deliver-runtime-BBwve6gL.js");
|
|
116466
116466
|
return deliverRuntimePromise$1;
|
|
116467
116467
|
}
|
|
116468
116468
|
function formatEchoTranscript(transcript, format) {
|
|
@@ -121888,13 +121888,13 @@ function listSkillCommandsForAgents(params) {
|
|
|
121888
121888
|
const workspaceFilters = /* @__PURE__ */ new Map();
|
|
121889
121889
|
for (const agentId of agentIds) {
|
|
121890
121890
|
const workspaceDir = resolveAgentWorkspaceDir(params.cfg, agentId);
|
|
121891
|
-
if (!
|
|
121891
|
+
if (!fsSync.existsSync(workspaceDir)) {
|
|
121892
121892
|
logVerbose(`Skipping agent "${agentId}": workspace does not exist: ${workspaceDir}`);
|
|
121893
121893
|
continue;
|
|
121894
121894
|
}
|
|
121895
121895
|
let canonicalDir;
|
|
121896
121896
|
try {
|
|
121897
|
-
canonicalDir =
|
|
121897
|
+
canonicalDir = fsSync.realpathSync(workspaceDir);
|
|
121898
121898
|
} catch {
|
|
121899
121899
|
logVerbose(`Skipping agent "${agentId}": cannot resolve workspace: ${workspaceDir}`);
|
|
121900
121900
|
continue;
|
|
@@ -122271,7 +122271,7 @@ async function buildContextReply(params) {
|
|
|
122271
122271
|
//#region src/auto-reply/reply/commands-export-session.ts
|
|
122272
122272
|
const EXPORT_HTML_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "export-html");
|
|
122273
122273
|
function loadTemplate(fileName) {
|
|
122274
|
-
return
|
|
122274
|
+
return fsSync.readFileSync(path.join(EXPORT_HTML_DIR, fileName), "utf-8");
|
|
122275
122275
|
}
|
|
122276
122276
|
function generateHtml(sessionData) {
|
|
122277
122277
|
const template = loadTemplate("template.html");
|
|
@@ -122345,7 +122345,7 @@ async function buildExportSessionReply(params) {
|
|
|
122345
122345
|
} catch (err) {
|
|
122346
122346
|
return { text: `❌ Failed to resolve session file: ${err instanceof Error ? err.message : String(err)}` };
|
|
122347
122347
|
}
|
|
122348
|
-
if (!
|
|
122348
|
+
if (!fsSync.existsSync(sessionFile)) return { text: `❌ Session file not found: ${sessionFile}` };
|
|
122349
122349
|
const sessionManager = SessionManager.open(sessionFile);
|
|
122350
122350
|
const entries = sessionManager.getEntries();
|
|
122351
122351
|
const header = sessionManager.getHeader();
|
|
@@ -122366,8 +122366,8 @@ async function buildExportSessionReply(params) {
|
|
|
122366
122366
|
const defaultFileName = `openclaw-session-${entry.sessionId.slice(0, 8)}-${timestamp}.html`;
|
|
122367
122367
|
const outputPath = args.outputPath ? path.resolve(args.outputPath.startsWith("~") ? args.outputPath.replace("~", process.env.HOME ?? "") : args.outputPath) : path.join(params.workspaceDir, defaultFileName);
|
|
122368
122368
|
const outputDir = path.dirname(outputPath);
|
|
122369
|
-
if (!
|
|
122370
|
-
|
|
122369
|
+
if (!fsSync.existsSync(outputDir)) fsSync.mkdirSync(outputDir, { recursive: true });
|
|
122370
|
+
fsSync.writeFileSync(outputPath, html, "utf-8");
|
|
122371
122371
|
const relativePath = path.relative(params.workspaceDir, outputPath);
|
|
122372
122372
|
return { text: [
|
|
122373
122373
|
"✅ Session exported!",
|
|
@@ -123850,7 +123850,7 @@ function summarizeLifecycleForLog(record, defaults) {
|
|
|
123850
123850
|
function loadBindingsFromDisk(accountId) {
|
|
123851
123851
|
const filePath = resolveBindingsPath(accountId);
|
|
123852
123852
|
try {
|
|
123853
|
-
const raw =
|
|
123853
|
+
const raw = fsSync.readFileSync(filePath, "utf-8");
|
|
123854
123854
|
const parsed = JSON.parse(raw);
|
|
123855
123855
|
if (parsed?.version !== STORE_VERSION$1 || !Array.isArray(parsed.bindings)) return [];
|
|
123856
123856
|
const bindings = [];
|
|
@@ -124292,7 +124292,7 @@ const applyCostTotal = (totals, costTotal) => {
|
|
|
124292
124292
|
totals.totalCost += costTotal;
|
|
124293
124293
|
};
|
|
124294
124294
|
async function* readJsonlRecords(filePath) {
|
|
124295
|
-
const fileStream =
|
|
124295
|
+
const fileStream = fsSync.createReadStream(filePath, { encoding: "utf-8" });
|
|
124296
124296
|
const rl = readline.createInterface({
|
|
124297
124297
|
input: fileStream,
|
|
124298
124298
|
crlfDelay: Infinity
|
|
@@ -124364,10 +124364,10 @@ async function loadCostUsageSummary(params) {
|
|
|
124364
124364
|
const dailyMap = /* @__PURE__ */ new Map();
|
|
124365
124365
|
const totals = emptyTotals();
|
|
124366
124366
|
const sessionsDir = resolveSessionTranscriptsDirForAgent(params?.agentId);
|
|
124367
|
-
const entries = await
|
|
124367
|
+
const entries = await fsSync.promises.readdir(sessionsDir, { withFileTypes: true }).catch(() => []);
|
|
124368
124368
|
const files = (await Promise.all(entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map(async (entry) => {
|
|
124369
124369
|
const filePath = path.join(sessionsDir, entry.name);
|
|
124370
|
-
const stats = await
|
|
124370
|
+
const stats = await fsSync.promises.stat(filePath).catch(() => null);
|
|
124371
124371
|
if (!stats) return null;
|
|
124372
124372
|
if (stats.mtimeMs < sinceTime) return null;
|
|
124373
124373
|
return filePath;
|
|
@@ -124400,7 +124400,7 @@ async function loadCostUsageSummary(params) {
|
|
|
124400
124400
|
}
|
|
124401
124401
|
async function loadSessionCostSummary(params) {
|
|
124402
124402
|
const sessionFile = params.sessionFile ?? (params.sessionId ? resolveSessionFilePath(params.sessionId, params.sessionEntry, { agentId: params.agentId }) : void 0);
|
|
124403
|
-
if (!sessionFile || !
|
|
124403
|
+
if (!sessionFile || !fsSync.existsSync(sessionFile)) return null;
|
|
124404
124404
|
const totals = emptyTotals();
|
|
124405
124405
|
let firstActivity;
|
|
124406
124406
|
let lastActivity;
|
|
@@ -125742,7 +125742,7 @@ async function emitResetCommandHooks(params) {
|
|
|
125742
125742
|
try {
|
|
125743
125743
|
const messages = [];
|
|
125744
125744
|
if (sessionFile) {
|
|
125745
|
-
const content = await fs
|
|
125745
|
+
const content = await fs.readFile(sessionFile, "utf-8");
|
|
125746
125746
|
for (const line of content.split("\n")) {
|
|
125747
125747
|
if (!line.trim()) continue;
|
|
125748
125748
|
try {
|
|
@@ -126354,7 +126354,7 @@ async function createModelSelectionState(params) {
|
|
|
126354
126354
|
}
|
|
126355
126355
|
}
|
|
126356
126356
|
if (sessionEntry && sessionStore && sessionKey && sessionEntry.authProfileOverride) {
|
|
126357
|
-
const { ensureAuthProfileStore } = await import("./auth-profiles.runtime-
|
|
126357
|
+
const { ensureAuthProfileStore } = await import("./auth-profiles.runtime-CLSx3zsq.js");
|
|
126358
126358
|
const profile = ensureAuthProfileStore(void 0, { allowKeychainPrompt: false }).profiles[sessionEntry.authProfileOverride];
|
|
126359
126359
|
const providerKey = normalizeProviderId(provider);
|
|
126360
126360
|
if (!profile || normalizeProviderId(profile.provider) !== providerKey) await clearSessionAuthProfileOverride({
|
|
@@ -129171,18 +129171,18 @@ function appendImagePathsToPrompt(prompt, paths) {
|
|
|
129171
129171
|
return `${trimmed}${trimmed ? "\n\n" : ""}${paths.join("\n")}`;
|
|
129172
129172
|
}
|
|
129173
129173
|
async function writeCliImages(images) {
|
|
129174
|
-
const tempDir = await fs
|
|
129174
|
+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-cli-images-"));
|
|
129175
129175
|
const paths = [];
|
|
129176
129176
|
for (let i = 0; i < images.length; i += 1) {
|
|
129177
129177
|
const image = images[i];
|
|
129178
129178
|
const ext = resolveImageExtension(image.mimeType);
|
|
129179
129179
|
const filePath = path.join(tempDir, `image-${i + 1}.${ext}`);
|
|
129180
129180
|
const buffer = Buffer.from(image.data, "base64");
|
|
129181
|
-
await fs
|
|
129181
|
+
await fs.writeFile(filePath, buffer, { mode: 384 });
|
|
129182
129182
|
paths.push(filePath);
|
|
129183
129183
|
}
|
|
129184
129184
|
const cleanup = async () => {
|
|
129185
|
-
await fs
|
|
129185
|
+
await fs.rm(tempDir, {
|
|
129186
129186
|
recursive: true,
|
|
129187
129187
|
force: true
|
|
129188
129188
|
});
|
|
@@ -130495,7 +130495,7 @@ async function runAgentTurnWithFallback(params) {
|
|
|
130495
130495
|
if (corruptedSessionId) {
|
|
130496
130496
|
const transcriptPath = resolveSessionTranscriptPath$1(corruptedSessionId);
|
|
130497
130497
|
try {
|
|
130498
|
-
|
|
130498
|
+
fsSync.unlinkSync(transcriptPath);
|
|
130499
130499
|
} catch {}
|
|
130500
130500
|
}
|
|
130501
130501
|
delete params.activeSessionStore[sessionKey];
|
|
@@ -130753,7 +130753,7 @@ async function readSessionLogSnapshot(params) {
|
|
|
130753
130753
|
if (!logPath) return {};
|
|
130754
130754
|
const snapshot = {};
|
|
130755
130755
|
if (params.includeByteSize) try {
|
|
130756
|
-
const stat = await
|
|
130756
|
+
const stat = await fsSync.promises.stat(logPath);
|
|
130757
130757
|
const size = Math.floor(stat.size);
|
|
130758
130758
|
snapshot.byteSize = Number.isFinite(size) && size >= 0 ? size : void 0;
|
|
130759
130759
|
} catch {
|
|
@@ -130767,7 +130767,7 @@ async function readSessionLogSnapshot(params) {
|
|
|
130767
130767
|
return snapshot;
|
|
130768
130768
|
}
|
|
130769
130769
|
async function readLastNonzeroUsageFromSessionLog(logPath) {
|
|
130770
|
-
const handle = await
|
|
130770
|
+
const handle = await fsSync.promises.open(logPath, "r");
|
|
130771
130771
|
try {
|
|
130772
130772
|
let position = (await handle.stat()).size;
|
|
130773
130773
|
let leadingPartial = "";
|
|
@@ -131082,7 +131082,7 @@ function resolveCronStorePath(storePath) {
|
|
|
131082
131082
|
}
|
|
131083
131083
|
async function loadCronStore(storePath) {
|
|
131084
131084
|
try {
|
|
131085
|
-
const raw = await
|
|
131085
|
+
const raw = await fsSync.promises.readFile(storePath, "utf-8");
|
|
131086
131086
|
let parsed;
|
|
131087
131087
|
try {
|
|
131088
131088
|
parsed = JSON5.parse(raw);
|
|
@@ -131108,21 +131108,21 @@ async function loadCronStore(storePath) {
|
|
|
131108
131108
|
}
|
|
131109
131109
|
}
|
|
131110
131110
|
async function setSecureFileMode(filePath) {
|
|
131111
|
-
await
|
|
131111
|
+
await fsSync.promises.chmod(filePath, 384).catch(() => void 0);
|
|
131112
131112
|
}
|
|
131113
131113
|
async function saveCronStore(storePath, store, opts) {
|
|
131114
131114
|
const storeDir = path.dirname(storePath);
|
|
131115
|
-
await
|
|
131115
|
+
await fsSync.promises.mkdir(storeDir, {
|
|
131116
131116
|
recursive: true,
|
|
131117
131117
|
mode: 448
|
|
131118
131118
|
});
|
|
131119
|
-
await
|
|
131119
|
+
await fsSync.promises.chmod(storeDir, 448).catch(() => void 0);
|
|
131120
131120
|
const json = JSON.stringify(store, null, 2);
|
|
131121
131121
|
const cached = serializedStoreCache.get(storePath);
|
|
131122
131122
|
if (cached === json) return;
|
|
131123
131123
|
let previous = cached ?? null;
|
|
131124
131124
|
if (previous === null) try {
|
|
131125
|
-
previous = await
|
|
131125
|
+
previous = await fsSync.promises.readFile(storePath, "utf-8");
|
|
131126
131126
|
} catch (err) {
|
|
131127
131127
|
if (err.code !== "ENOENT") throw err;
|
|
131128
131128
|
}
|
|
@@ -131131,14 +131131,14 @@ async function saveCronStore(storePath, store, opts) {
|
|
|
131131
131131
|
return;
|
|
131132
131132
|
}
|
|
131133
131133
|
const tmp = `${storePath}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
|
|
131134
|
-
await
|
|
131134
|
+
await fsSync.promises.writeFile(tmp, json, {
|
|
131135
131135
|
encoding: "utf-8",
|
|
131136
131136
|
mode: 384
|
|
131137
131137
|
});
|
|
131138
131138
|
await setSecureFileMode(tmp);
|
|
131139
131139
|
if (previous !== null && !opts?.skipBackup) try {
|
|
131140
131140
|
const backupPath = `${storePath}.bak`;
|
|
131141
|
-
await
|
|
131141
|
+
await fsSync.promises.copyFile(storePath, backupPath);
|
|
131142
131142
|
await setSecureFileMode(backupPath);
|
|
131143
131143
|
} catch {}
|
|
131144
131144
|
await renameWithRetry(tmp, storePath);
|
|
@@ -131149,7 +131149,7 @@ const RENAME_MAX_RETRIES = 3;
|
|
|
131149
131149
|
const RENAME_BASE_DELAY_MS = 50;
|
|
131150
131150
|
async function renameWithRetry(src, dest) {
|
|
131151
131151
|
for (let attempt = 0; attempt <= RENAME_MAX_RETRIES; attempt++) try {
|
|
131152
|
-
await
|
|
131152
|
+
await fsSync.promises.rename(src, dest);
|
|
131153
131153
|
return;
|
|
131154
131154
|
} catch (err) {
|
|
131155
131155
|
const code = err.code;
|
|
@@ -131158,8 +131158,8 @@ async function renameWithRetry(src, dest) {
|
|
|
131158
131158
|
continue;
|
|
131159
131159
|
}
|
|
131160
131160
|
if (code === "EPERM" || code === "EEXIST") {
|
|
131161
|
-
await
|
|
131162
|
-
await
|
|
131161
|
+
await fsSync.promises.copyFile(src, dest);
|
|
131162
|
+
await fsSync.promises.unlink(src).catch(() => {});
|
|
131163
131163
|
return;
|
|
131164
131164
|
}
|
|
131165
131165
|
throw err;
|
|
@@ -131766,7 +131766,7 @@ async function runReplyAgent(params) {
|
|
|
131766
131766
|
if (resolved) transcriptCandidates.add(resolved);
|
|
131767
131767
|
transcriptCandidates.add(resolveSessionTranscriptPath$1(prevSessionId, agentId));
|
|
131768
131768
|
for (const candidate of transcriptCandidates) try {
|
|
131769
|
-
|
|
131769
|
+
fsSync.unlinkSync(candidate);
|
|
131770
131770
|
} catch {}
|
|
131771
131771
|
}
|
|
131772
131772
|
return true;
|
|
@@ -132714,7 +132714,7 @@ const warnedContexts = /* @__PURE__ */ new Map();
|
|
|
132714
132714
|
const log$6 = createSubsystemLogger("session-maintenance-warning");
|
|
132715
132715
|
let deliverRuntimePromise = null;
|
|
132716
132716
|
function loadDeliverRuntime() {
|
|
132717
|
-
deliverRuntimePromise ??= import("./deliver-runtime-
|
|
132717
|
+
deliverRuntimePromise ??= import("./deliver-runtime-BBwve6gL.js");
|
|
132718
132718
|
return deliverRuntimePromise;
|
|
132719
132719
|
}
|
|
132720
132720
|
function shouldSendWarning() {
|
|
@@ -132898,7 +132898,7 @@ function forkSessionFromParent(params) {
|
|
|
132898
132898
|
agentId: params.agentId,
|
|
132899
132899
|
sessionsDir: params.sessionsDir
|
|
132900
132900
|
});
|
|
132901
|
-
if (!parentSessionFile || !
|
|
132901
|
+
if (!parentSessionFile || !fsSync.existsSync(parentSessionFile)) return null;
|
|
132902
132902
|
try {
|
|
132903
132903
|
const manager = SessionManager.open(parentSessionFile);
|
|
132904
132904
|
const leafId = manager.getLeafId();
|
|
@@ -132922,7 +132922,7 @@ function forkSessionFromParent(params) {
|
|
|
132922
132922
|
cwd: manager.getCwd(),
|
|
132923
132923
|
parentSession: parentSessionFile
|
|
132924
132924
|
};
|
|
132925
|
-
|
|
132925
|
+
fsSync.writeFileSync(sessionFile, `${JSON.stringify(header)}\n`, "utf-8");
|
|
132926
132926
|
return {
|
|
132927
132927
|
sessionId,
|
|
132928
132928
|
sessionFile
|
|
@@ -133383,7 +133383,7 @@ async function stageSandboxMedia(params) {
|
|
|
133383
133383
|
const remoteMediaCacheDir = ctx.MediaRemoteHost ? path.join(CONFIG_DIR, "media", "remote-cache", sessionKey) : null;
|
|
133384
133384
|
const effectiveWorkspaceDir = sandbox?.workspaceDir ?? remoteMediaCacheDir;
|
|
133385
133385
|
if (!effectiveWorkspaceDir) return;
|
|
133386
|
-
await fs
|
|
133386
|
+
await fs.mkdir(effectiveWorkspaceDir, { recursive: true });
|
|
133387
133387
|
const remoteAttachmentRoots = resolveIMessageRemoteAttachmentRoots({
|
|
133388
133388
|
cfg,
|
|
133389
133389
|
accountId: ctx.AccountId
|
|
@@ -133442,8 +133442,8 @@ async function stageLocalFileIntoRoot(params) {
|
|
|
133442
133442
|
}
|
|
133443
133443
|
async function stageRemoteFileIntoRoot(params) {
|
|
133444
133444
|
const tmpRoot = resolvePreferredOpenClawTmpDir();
|
|
133445
|
-
await fs
|
|
133446
|
-
const tmpDir = await fs
|
|
133445
|
+
await fs.mkdir(tmpRoot, { recursive: true });
|
|
133446
|
+
const tmpDir = await fs.mkdtemp(path.join(tmpRoot, "stage-sandbox-media-"));
|
|
133447
133447
|
const tmpPath = path.join(tmpDir, "download");
|
|
133448
133448
|
try {
|
|
133449
133449
|
await scpFile(params.remoteHost, params.remotePath, tmpPath);
|
|
@@ -133454,7 +133454,7 @@ async function stageRemoteFileIntoRoot(params) {
|
|
|
133454
133454
|
maxBytes: params.maxBytes
|
|
133455
133455
|
});
|
|
133456
133456
|
} finally {
|
|
133457
|
-
await fs
|
|
133457
|
+
await fs.rm(tmpDir, {
|
|
133458
133458
|
recursive: true,
|
|
133459
133459
|
force: true
|
|
133460
133460
|
}).catch(() => {});
|
|
@@ -134578,12 +134578,12 @@ async function resolveAcpAttachments(ctx) {
|
|
|
134578
134578
|
const filePath = normalizeAttachmentPath(attachment.path);
|
|
134579
134579
|
if (!filePath) continue;
|
|
134580
134580
|
try {
|
|
134581
|
-
const stat = await fs
|
|
134581
|
+
const stat = await fs.stat(filePath);
|
|
134582
134582
|
if (stat.size > ACP_ATTACHMENT_MAX_BYTES) {
|
|
134583
134583
|
logVerbose(`dispatch-acp: skipping attachment ${filePath} (${stat.size} bytes exceeds ${ACP_ATTACHMENT_MAX_BYTES} byte limit)`);
|
|
134584
134584
|
continue;
|
|
134585
134585
|
}
|
|
134586
|
-
const buf = await fs
|
|
134586
|
+
const buf = await fs.readFile(filePath);
|
|
134587
134587
|
results.push({
|
|
134588
134588
|
mediaType,
|
|
134589
134589
|
data: buf.toString("base64")
|
|
@@ -136469,7 +136469,7 @@ function identityHasValues(identity) {
|
|
|
136469
136469
|
}
|
|
136470
136470
|
function loadIdentityFromFile(identityPath) {
|
|
136471
136471
|
try {
|
|
136472
|
-
const parsed = parseIdentityMarkdown(
|
|
136472
|
+
const parsed = parseIdentityMarkdown(fsSync.readFileSync(identityPath, "utf-8"));
|
|
136473
136473
|
if (!identityHasValues(parsed)) return null;
|
|
136474
136474
|
return parsed;
|
|
136475
136475
|
} catch {
|
|
@@ -136492,7 +136492,7 @@ function resolveAvatarSource(cfg, agentId) {
|
|
|
136492
136492
|
}
|
|
136493
136493
|
function resolveExistingPath(value) {
|
|
136494
136494
|
try {
|
|
136495
|
-
return
|
|
136495
|
+
return fsSync.realpathSync(value);
|
|
136496
136496
|
} catch {
|
|
136497
136497
|
return path.resolve(value);
|
|
136498
136498
|
}
|
|
@@ -136510,7 +136510,7 @@ function resolveLocalAvatarPath(params) {
|
|
|
136510
136510
|
reason: "unsupported_extension"
|
|
136511
136511
|
};
|
|
136512
136512
|
try {
|
|
136513
|
-
const stat =
|
|
136513
|
+
const stat = fsSync.statSync(realPath);
|
|
136514
136514
|
if (!stat.isFile()) return {
|
|
136515
136515
|
ok: false,
|
|
136516
136516
|
reason: "missing"
|
|
@@ -137878,7 +137878,7 @@ async function resolveDiscordPreflightAudioMentionContext(params) {
|
|
|
137878
137878
|
hasTypedText
|
|
137879
137879
|
};
|
|
137880
137880
|
try {
|
|
137881
|
-
const { transcribeFirstAudio } = await import("./audio-preflight-
|
|
137881
|
+
const { transcribeFirstAudio } = await import("./audio-preflight-DcneE70v.js");
|
|
137882
137882
|
if (params.abortSignal?.aborted) return {
|
|
137883
137883
|
hasAudioAttachment,
|
|
137884
137884
|
hasTypedText
|
|
@@ -144214,7 +144214,7 @@ function resolveDiscordRestFetch(proxyUrl, runtime) {
|
|
|
144214
144214
|
//#region extensions/discord/src/monitor/provider.ts
|
|
144215
144215
|
let discordVoiceRuntimePromise;
|
|
144216
144216
|
async function loadDiscordVoiceRuntime() {
|
|
144217
|
-
discordVoiceRuntimePromise ??= import("./manager.runtime-
|
|
144217
|
+
discordVoiceRuntimePromise ??= import("./manager.runtime-KPIwNjNW.js");
|
|
144218
144218
|
return await discordVoiceRuntimePromise;
|
|
144219
144219
|
}
|
|
144220
144220
|
function formatThreadBindingDurationForConfigLabel(durationMs) {
|
|
@@ -145087,7 +145087,7 @@ async function detectBinary(name) {
|
|
|
145087
145087
|
if (!isSafeExecutableValue(name)) return false;
|
|
145088
145088
|
const resolved = name.startsWith("~") ? resolveUserPath(name) : name;
|
|
145089
145089
|
if (path.isAbsolute(resolved) || resolved.startsWith(".") || resolved.includes("/") || resolved.includes("\\")) try {
|
|
145090
|
-
await fs
|
|
145090
|
+
await fs.access(resolved);
|
|
145091
145091
|
return true;
|
|
145092
145092
|
} catch {
|
|
145093
145093
|
return false;
|
|
@@ -146049,7 +146049,7 @@ function createSelfChatCache() {
|
|
|
146049
146049
|
async function detectRemoteHostFromCliPath(cliPath) {
|
|
146050
146050
|
try {
|
|
146051
146051
|
const expanded = cliPath.startsWith("~") ? cliPath.replace(/^~/, process.env.HOME ?? "") : cliPath;
|
|
146052
|
-
const content = await fs
|
|
146052
|
+
const content = await fs.readFile(expanded, "utf8");
|
|
146053
146053
|
const userHostMatch = content.match(/\bssh\b[^\n]*?\s+([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/);
|
|
146054
146054
|
if (userHostMatch) return userHostMatch[1];
|
|
146055
146055
|
return content.match(/\bssh\b[^\n]*?\s+([a-zA-Z][a-zA-Z0-9._-]*)\s+\S*\bimsg\b/)?.[1];
|
|
@@ -152227,15 +152227,15 @@ let slashCommandsRuntimePromise = null;
|
|
|
152227
152227
|
let slashDispatchRuntimePromise = null;
|
|
152228
152228
|
let slashSkillCommandsRuntimePromise = null;
|
|
152229
152229
|
function loadSlashCommandsRuntime() {
|
|
152230
|
-
slashCommandsRuntimePromise ??= import("./slash-commands.runtime-
|
|
152230
|
+
slashCommandsRuntimePromise ??= import("./slash-commands.runtime-J-gBOPcL.js");
|
|
152231
152231
|
return slashCommandsRuntimePromise;
|
|
152232
152232
|
}
|
|
152233
152233
|
function loadSlashDispatchRuntime() {
|
|
152234
|
-
slashDispatchRuntimePromise ??= import("./slash-dispatch.runtime-
|
|
152234
|
+
slashDispatchRuntimePromise ??= import("./slash-dispatch.runtime-CwO02PY8.js");
|
|
152235
152235
|
return slashDispatchRuntimePromise;
|
|
152236
152236
|
}
|
|
152237
152237
|
function loadSlashSkillCommandsRuntime() {
|
|
152238
|
-
slashSkillCommandsRuntimePromise ??= import("./slash-skill-commands.runtime-
|
|
152238
|
+
slashSkillCommandsRuntimePromise ??= import("./slash-skill-commands.runtime-BQRfyLdb.js");
|
|
152239
152239
|
return slashSkillCommandsRuntimePromise;
|
|
152240
152240
|
}
|
|
152241
152241
|
const slackExternalArgMenuStore = createSlackExternalArgMenuStore();
|
|
@@ -153246,7 +153246,7 @@ function collectTelegramUnmentionedGroupIds(groups) {
|
|
|
153246
153246
|
}
|
|
153247
153247
|
let auditMembershipRuntimePromise = null;
|
|
153248
153248
|
function loadAuditMembershipRuntime() {
|
|
153249
|
-
auditMembershipRuntimePromise ??= import("./audit-membership-runtime-
|
|
153249
|
+
auditMembershipRuntimePromise ??= import("./audit-membership-runtime-BDoMjPgy.js");
|
|
153250
153250
|
return auditMembershipRuntimePromise;
|
|
153251
153251
|
}
|
|
153252
153252
|
async function auditTelegramGroupMembership(params) {
|
|
@@ -155855,7 +155855,7 @@ function getCacheStats() {
|
|
|
155855
155855
|
const STICKER_DESCRIPTION_PROMPT = "Describe this sticker image in 1-2 sentences. Focus on what the sticker depicts (character, object, action, emotion). Be concise and objective.";
|
|
155856
155856
|
let imageRuntimePromise = null;
|
|
155857
155857
|
function loadImageRuntime() {
|
|
155858
|
-
imageRuntimePromise ??= import("./image-runtime-
|
|
155858
|
+
imageRuntimePromise ??= import("./image-runtime-DiA6CU2y.js");
|
|
155859
155859
|
return imageRuntimePromise;
|
|
155860
155860
|
}
|
|
155861
155861
|
/**
|
|
@@ -155921,7 +155921,7 @@ async function describeStickerImage(params) {
|
|
|
155921
155921
|
const { provider, model } = resolved;
|
|
155922
155922
|
logVerbose(`telegram: describing sticker with ${provider}/${model}`);
|
|
155923
155923
|
try {
|
|
155924
|
-
const buffer = await fs
|
|
155924
|
+
const buffer = await fs.readFile(imagePath);
|
|
155925
155925
|
const { describeImageWithModel } = await loadImageRuntime();
|
|
155926
155926
|
return (await describeImageWithModel({
|
|
155927
155927
|
buffer,
|
|
@@ -157587,7 +157587,7 @@ async function resolveTelegramInboundBody(params) {
|
|
|
157587
157587
|
const disableAudioPreflight = (topicConfig?.disableAudioPreflight ?? groupConfig?.disableAudioPreflight) === true;
|
|
157588
157588
|
let preflightTranscript;
|
|
157589
157589
|
if (isGroup && requireMention && hasAudio && !hasUserText && mentionRegexes.length > 0 && !disableAudioPreflight) try {
|
|
157590
|
-
const { transcribeFirstAudio } = await import("./audio-preflight-
|
|
157590
|
+
const { transcribeFirstAudio } = await import("./audio-preflight-DcneE70v.js");
|
|
157591
157591
|
preflightTranscript = await transcribeFirstAudio({
|
|
157592
157592
|
ctx: {
|
|
157593
157593
|
MediaPaths: allMedia.length > 0 ? allMedia.map((m) => m.path) : void 0,
|
|
@@ -159684,7 +159684,7 @@ function resolveCommandHashPath(accountId, botIdentity) {
|
|
|
159684
159684
|
}
|
|
159685
159685
|
async function readCachedCommandHash(accountId, botIdentity) {
|
|
159686
159686
|
try {
|
|
159687
|
-
return (await fs
|
|
159687
|
+
return (await fs.readFile(resolveCommandHashPath(accountId, botIdentity), "utf-8")).trim();
|
|
159688
159688
|
} catch {
|
|
159689
159689
|
return null;
|
|
159690
159690
|
}
|
|
@@ -159692,8 +159692,8 @@ async function readCachedCommandHash(accountId, botIdentity) {
|
|
|
159692
159692
|
async function writeCachedCommandHash(accountId, botIdentity, hash) {
|
|
159693
159693
|
const filePath = resolveCommandHashPath(accountId, botIdentity);
|
|
159694
159694
|
try {
|
|
159695
|
-
await fs
|
|
159696
|
-
await fs
|
|
159695
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
159696
|
+
await fs.writeFile(filePath, hash, "utf-8");
|
|
159697
159697
|
} catch {}
|
|
159698
159698
|
}
|
|
159699
159699
|
function syncTelegramMenuCommands(params) {
|
|
@@ -160901,7 +160901,7 @@ function safeParseState(raw) {
|
|
|
160901
160901
|
async function readTelegramUpdateOffset(params) {
|
|
160902
160902
|
const filePath = resolveTelegramUpdateOffsetPath(params.accountId, params.env);
|
|
160903
160903
|
try {
|
|
160904
|
-
const parsed = safeParseState(await fs
|
|
160904
|
+
const parsed = safeParseState(await fs.readFile(filePath, "utf-8"));
|
|
160905
160905
|
const expectedBotId = extractBotIdFromToken(params.botToken);
|
|
160906
160906
|
if (expectedBotId && parsed?.botId && parsed.botId !== expectedBotId) return null;
|
|
160907
160907
|
if (expectedBotId && parsed?.botId === null) return null;
|
|
@@ -164382,7 +164382,7 @@ async function downloadLineMedia(messageId, channelAccessToken, maxBytes = 10 *
|
|
|
164382
164382
|
prefix: "line-media",
|
|
164383
164383
|
extension: getExtensionForContentType(contentType)
|
|
164384
164384
|
});
|
|
164385
|
-
await
|
|
164385
|
+
await fsSync.promises.writeFile(filePath, buffer);
|
|
164386
164386
|
logVerbose(`line: downloaded media ${messageId} to ${filePath} (${buffer.length} bytes)`);
|
|
164387
164387
|
return {
|
|
164388
164388
|
path: filePath,
|
|
@@ -165709,7 +165709,7 @@ function createWhatsAppLoginTool() {
|
|
|
165709
165709
|
force: Type.Optional(Type.Boolean())
|
|
165710
165710
|
}),
|
|
165711
165711
|
execute: async (_toolCallId, args) => {
|
|
165712
|
-
const { startWebLoginWithQr, waitForWebLogin } = await import("./login-qr-
|
|
165712
|
+
const { startWebLoginWithQr, waitForWebLogin } = await import("./login-qr-CVQlH0l0.js");
|
|
165713
165713
|
if ((args?.action ?? "start") === "wait") {
|
|
165714
165714
|
const result = await waitForWebLogin({ timeoutMs: typeof args.timeoutMs === "number" ? args.timeoutMs : void 0 });
|
|
165715
165715
|
return {
|
|
@@ -165783,23 +165783,23 @@ let webOutboundPromise = null;
|
|
|
165783
165783
|
let webLoginPromise = null;
|
|
165784
165784
|
let whatsappActionsPromise = null;
|
|
165785
165785
|
function loadWebOutbound() {
|
|
165786
|
-
webOutboundPromise ??= import("./runtime-whatsapp-outbound.runtime-
|
|
165786
|
+
webOutboundPromise ??= import("./runtime-whatsapp-outbound.runtime-CatYliOE.js");
|
|
165787
165787
|
return webOutboundPromise;
|
|
165788
165788
|
}
|
|
165789
165789
|
function loadWebLogin() {
|
|
165790
|
-
webLoginPromise ??= import("./runtime-whatsapp-login.runtime-
|
|
165790
|
+
webLoginPromise ??= import("./runtime-whatsapp-login.runtime-Dd6rJjLo.js");
|
|
165791
165791
|
return webLoginPromise;
|
|
165792
165792
|
}
|
|
165793
165793
|
function loadWebLoginQr() {
|
|
165794
|
-
webLoginQrPromise ??= import("./login-qr-
|
|
165794
|
+
webLoginQrPromise ??= import("./login-qr-CVQlH0l0.js");
|
|
165795
165795
|
return webLoginQrPromise;
|
|
165796
165796
|
}
|
|
165797
165797
|
function loadWebChannel() {
|
|
165798
|
-
webChannelPromise ??= import("./web-
|
|
165798
|
+
webChannelPromise ??= import("./web-B_GcnsRF.js");
|
|
165799
165799
|
return webChannelPromise;
|
|
165800
165800
|
}
|
|
165801
165801
|
function loadWhatsAppActions() {
|
|
165802
|
-
whatsappActionsPromise ??= import("./whatsapp-actions-
|
|
165802
|
+
whatsappActionsPromise ??= import("./whatsapp-actions-BCgsmzOa.js");
|
|
165803
165803
|
return whatsappActionsPromise;
|
|
165804
165804
|
}
|
|
165805
165805
|
function createRuntimeWhatsApp() {
|
|
@@ -166832,7 +166832,7 @@ async function withMemoryManagerForAgent(params) {
|
|
|
166832
166832
|
}
|
|
166833
166833
|
async function checkReadableFile(pathname) {
|
|
166834
166834
|
try {
|
|
166835
|
-
await fs
|
|
166835
|
+
await fs.access(pathname, fsSync.constants.R_OK);
|
|
166836
166836
|
return { exists: true };
|
|
166837
166837
|
} catch (err) {
|
|
166838
166838
|
const code = err.code;
|
|
@@ -166849,7 +166849,7 @@ async function scanSessionFiles(agentId) {
|
|
|
166849
166849
|
try {
|
|
166850
166850
|
return {
|
|
166851
166851
|
source: "sessions",
|
|
166852
|
-
totalFiles: (await fs
|
|
166852
|
+
totalFiles: (await fs.readdir(sessionsDir, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).length,
|
|
166853
166853
|
issues
|
|
166854
166854
|
};
|
|
166855
166855
|
} catch (err) {
|
|
@@ -166881,7 +166881,7 @@ async function scanMemoryFiles(workspaceDir, extraPaths = []) {
|
|
|
166881
166881
|
if (alt.issue) issues.push(alt.issue);
|
|
166882
166882
|
const resolvedExtraPaths = normalizeExtraMemoryPaths(workspaceDir, extraPaths);
|
|
166883
166883
|
for (const extraPath of resolvedExtraPaths) try {
|
|
166884
|
-
if ((await fs
|
|
166884
|
+
if ((await fs.lstat(extraPath)).isSymbolicLink()) continue;
|
|
166885
166885
|
const extraCheck = await checkReadableFile(extraPath);
|
|
166886
166886
|
if (extraCheck.issue) issues.push(extraCheck.issue);
|
|
166887
166887
|
} catch (err) {
|
|
@@ -166891,7 +166891,7 @@ async function scanMemoryFiles(workspaceDir, extraPaths = []) {
|
|
|
166891
166891
|
}
|
|
166892
166892
|
let dirReadable = null;
|
|
166893
166893
|
try {
|
|
166894
|
-
await fs
|
|
166894
|
+
await fs.access(memoryDir, fsSync.constants.R_OK);
|
|
166895
166895
|
dirReadable = true;
|
|
166896
166896
|
} catch (err) {
|
|
166897
166897
|
const code = err.code;
|
|
@@ -166939,7 +166939,7 @@ async function summarizeQmdIndexArtifact(manager) {
|
|
|
166939
166939
|
if (!dbPath) return null;
|
|
166940
166940
|
let stat;
|
|
166941
166941
|
try {
|
|
166942
|
-
stat = await fs
|
|
166942
|
+
stat = await fs.stat(dbPath);
|
|
166943
166943
|
} catch (err) {
|
|
166944
166944
|
const code = err.code;
|
|
166945
166945
|
if (code === "ENOENT") throw new Error(`QMD index file not found: ${shortenHomePath(dbPath)}`, { cause: err });
|
|
@@ -167383,7 +167383,7 @@ const resolvePluginSdkAliasFile = (params) => {
|
|
|
167383
167383
|
srcFile: params.srcFile,
|
|
167384
167384
|
distFile: params.distFile,
|
|
167385
167385
|
modulePath
|
|
167386
|
-
})) if (
|
|
167386
|
+
})) if (fsSync.existsSync(candidate)) return candidate;
|
|
167387
167387
|
} catch {}
|
|
167388
167388
|
return null;
|
|
167389
167389
|
};
|
|
@@ -167399,7 +167399,7 @@ function listPluginSdkExportedSubpaths(params = {}) {
|
|
|
167399
167399
|
const cached = cachedPluginSdkExportedSubpaths.get(packageRoot);
|
|
167400
167400
|
if (cached) return cached;
|
|
167401
167401
|
try {
|
|
167402
|
-
const pkgRaw =
|
|
167402
|
+
const pkgRaw = fsSync.readFileSync(path.join(packageRoot, "package.json"), "utf-8");
|
|
167403
167403
|
const pkg = JSON.parse(pkgRaw);
|
|
167404
167404
|
const subpaths = Object.keys(pkg.exports ?? {}).filter((key) => key.startsWith("./plugin-sdk/")).map((key) => key.slice(13)).filter((subpath) => Boolean(subpath) && !subpath.includes("/")).toSorted();
|
|
167405
167405
|
cachedPluginSdkExportedSubpaths.set(packageRoot, subpaths);
|
|
@@ -167873,7 +167873,7 @@ function loadOpenClawPlugins(options = {}) {
|
|
|
167873
167873
|
continue;
|
|
167874
167874
|
}
|
|
167875
167875
|
const safeSource = opened.path;
|
|
167876
|
-
|
|
167876
|
+
fsSync.closeSync(opened.fd);
|
|
167877
167877
|
let mod = null;
|
|
167878
167878
|
try {
|
|
167879
167879
|
mod = getJiti()(safeSource);
|
|
@@ -167991,7 +167991,7 @@ function loadOpenClawPlugins(options = {}) {
|
|
|
167991
167991
|
}
|
|
167992
167992
|
function safeRealpathOrResolve(value) {
|
|
167993
167993
|
try {
|
|
167994
|
-
return
|
|
167994
|
+
return fsSync.realpathSync(value);
|
|
167995
167995
|
} catch {
|
|
167996
167996
|
return path.resolve(value);
|
|
167997
167997
|
}
|
|
@@ -169021,7 +169021,7 @@ function resolveCodexHomePath() {
|
|
|
169021
169021
|
const configured = process.env.CODEX_HOME;
|
|
169022
169022
|
const home = configured ? resolveUserPath(configured) : resolveUserPath("~/.codex");
|
|
169023
169023
|
try {
|
|
169024
|
-
return
|
|
169024
|
+
return fsSync.realpathSync.native(home);
|
|
169025
169025
|
} catch {
|
|
169026
169026
|
return home;
|
|
169027
169027
|
}
|
|
@@ -169118,7 +169118,7 @@ function readCodexCliCredentials(options) {
|
|
|
169118
169118
|
if (typeof refreshToken !== "string" || !refreshToken) return null;
|
|
169119
169119
|
let expires;
|
|
169120
169120
|
try {
|
|
169121
|
-
expires =
|
|
169121
|
+
expires = fsSync.statSync(authPath).mtimeMs + 3600 * 1e3;
|
|
169122
169122
|
} catch {
|
|
169123
169123
|
expires = Date.now() + 3600 * 1e3;
|
|
169124
169124
|
}
|
|
@@ -169246,7 +169246,7 @@ function resolveAuthStorePathForDisplay(agentDir) {
|
|
|
169246
169246
|
return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
|
|
169247
169247
|
}
|
|
169248
169248
|
function ensureAuthStoreFile(pathname) {
|
|
169249
|
-
if (
|
|
169249
|
+
if (fsSync.existsSync(pathname)) return;
|
|
169250
169250
|
saveJsonFile(pathname, {
|
|
169251
169251
|
version: 1,
|
|
169252
169252
|
profiles: {}
|
|
@@ -169507,7 +169507,7 @@ function loadAuthProfileStoreForAgent(agentDir, options) {
|
|
|
169507
169507
|
if (shouldWrite && legacy !== null) {
|
|
169508
169508
|
const legacyPath = resolveLegacyAuthStorePath(agentDir);
|
|
169509
169509
|
try {
|
|
169510
|
-
|
|
169510
|
+
fsSync.unlinkSync(legacyPath);
|
|
169511
169511
|
} catch (err) {
|
|
169512
169512
|
if (err?.code !== "ENOENT") log$52.warn("failed to delete legacy auth.json after migration", {
|
|
169513
169513
|
err,
|