cclawd 1.0.0 → 1.0.2
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/{active-listener-DYmI7imH.js → active-listener-BLd27Pxd.js} +2 -2
- package/dist/{api-key-rotation-DLU4jvSu.js → api-key-rotation-Dg3JlNDQ.js} +1 -1
- package/dist/{audio-preflight-C9TMbRb4.js → audio-preflight-eV5m9mMp.js} +15 -15
- package/dist/{audio-transcription-runner-Q5zG_hYd.js → audio-transcription-runner-CQU4Eg1M.js} +10 -10
- package/dist/{audit-membership-runtime-DhxSwFnF.js → audit-membership-runtime-hXUuer4x.js} +6 -6
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +35 -35
- 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 +35 -35
- package/dist/{channel-activity-Bx08UTAg.js → channel-activity-dT3cYb0e.js} +2 -2
- package/dist/{commands-registry-llLVCTH9.js → commands-registry-CyLMCPuP.js} +2 -2
- package/dist/compact.runtime-DGRl4st4.js +39 -0
- package/dist/{deliver-DJf2ZBpe.js → deliver-B6eTtXSk.js} +19 -19
- package/dist/deliver-runtime-CLDpY6AW.js +19 -0
- package/dist/deps-send-discord.runtime-CxADlame.js +19 -0
- package/dist/deps-send-imessage.runtime-Wi79xm6H.js +18 -0
- package/dist/deps-send-signal.runtime-BDtzvsnR.js +17 -0
- package/dist/deps-send-slack.runtime-CgX24hgT.js +17 -0
- package/dist/deps-send-telegram.runtime-CEWc7ePn.js +20 -0
- package/dist/deps-send-whatsapp.runtime-B1KJ7YOp.js +43 -0
- package/dist/{diagnostic-BCCMF3O_.js → diagnostic-BZmAxdu9.js} +2 -2
- package/dist/{env-aYXLHjfZ.js → env-lw2hsIUY.js} +1 -1
- package/dist/{fetch-bvgIiupu.js → fetch-C0iyt-Iz.js} +3 -3
- package/dist/{fetch-DCTUdr1U.js → fetch-CMLoICyN.js} +5 -5
- package/dist/{fetch-guard-CqpEmMQ2.js → fetch-guard-DCj3k042.js} +2 -2
- package/dist/{frontmatter-DjZuS525.js → frontmatter-C_obXuTp.js} +3 -3
- package/dist/{github-copilot-token-CQmATy5E.js → github-copilot-token-8N63GdbE.js} +7 -7
- package/dist/{image-Q8E1-lZn.js → image-Bt49ybRv.js} +4 -4
- package/dist/image-runtime-Cilhq73U.js +12 -0
- package/dist/{ir-CzM3SxId.js → ir-CVtBjUiL.js} +6 -6
- package/dist/llm-slug-generator.js +35 -35
- package/dist/{logger-ChbX1G7s.js → logger-CbUVl62f.js} +7 -7
- package/dist/{login-B0mtU11X.js → login-D0fUoX-p.js} +4 -4
- package/dist/{login-qr-DY_i60f5.js → login-qr-ClBxstxZ.js} +10 -10
- package/dist/{manager-FAQPC0uO.js → manager-DSfEj66R.js} +12 -12
- package/dist/manager-runtime-BrZlGJsj.js +15 -0
- package/dist/{model-selection-wf3OY5DX.js → model-selection-CMEj8bpy.js} +130 -130
- package/dist/{outbound-Bw0dOVS7.js → outbound-BxIJyMzV.js} +6 -6
- package/dist/{outbound-attachment-1R6r9Pg_.js → outbound-attachment-CVJwpypG.js} +2 -2
- package/dist/{paths-C0HLtPu0.js → paths-CehYKFsO.js} +7 -7
- package/dist/{paths-hfkBoC7i.js → paths-DkxwiA8g.js} +5 -5
- package/dist/{pi-embedded-BAHaY-Oh.js → pi-embedded-CHNPEUAv.js} +159 -159
- package/dist/{pi-model-discovery-ItS07aJB.js → pi-model-discovery-D-r5y7kV.js} +7 -7
- package/dist/pi-model-discovery-runtime-DZQXYmdu.js +12 -0
- package/dist/{pi-tools.before-tool-call.runtime-D_mthvtC.js → pi-tools.before-tool-call.runtime-DagGpfw0.js} +10 -10
- package/dist/{proxy-fetch-c1ZUFFcO.js → proxy-fetch-BOh1PLOW.js} +1 -1
- package/dist/{pw-ai-Ok6KGelf.js → pw-ai-CoIUdns_.js} +9 -9
- package/dist/{qmd-manager-DhfEz4Ar.js → qmd-manager-DEscZz5_.js} +6 -6
- package/dist/{query-expansion-GqNV2iIE.js → query-expansion-BErUY8P2.js} +4 -4
- package/dist/runtime-whatsapp-login.runtime-ChqE9BkX.js +13 -0
- package/dist/runtime-whatsapp-outbound.runtime-yiy6jzKk.js +17 -0
- package/dist/{send-DPflcjM5.js → send-4rRrSKp9.js} +6 -6
- package/dist/{send-CEg4P96c.js → send-BKO1-P1t.js} +5 -5
- package/dist/{send-CS0ocZHl.js → send-EDBPXjTT.js} +3 -3
- package/dist/{send-6R8b9zsj.js → send-K2mAG7KC.js} +5 -5
- package/dist/{send-DwAoiT2p.js → send-V1MRV7QF.js} +25 -25
- package/dist/{session-BoIID5UR.js → session-CuVCho2m.js} +7 -7
- package/dist/{skill-commands-DhdiziMs.js → skill-commands-B55LOaMB.js} +9 -9
- package/dist/slash-commands.runtime-BchS0VkW.js +12 -0
- package/dist/slash-dispatch.runtime-BIKRY3fr.js +39 -0
- package/dist/slash-skill-commands.runtime-BP4jBHU9.js +13 -0
- package/dist/subagent-registry-runtime-DjEYzSyM.js +39 -0
- package/dist/{subsystem-C8z6w6xC.js → subsystem-DfXy5gUB.js} +14 -14
- package/dist/{tables-DQusRhkD.js → tables-BAGqh2XD.js} +1 -1
- package/dist/{target-errors-CfavnC9U.js → target-errors-CeBF8Pws.js} +1 -1
- package/dist/{tokens-BWDIKewp.js → tokens-6ul2IrzG.js} +1 -1
- package/dist/{web-CrcrTQ2c.js → web-BRSmQdtm.js} +39 -39
- package/dist/{whatsapp-actions-B0u0ZAme.js → whatsapp-actions-Dxb2K2Xh.js} +15 -15
- package/dist/{workspace-CWDYHR27.js → workspace-DGIcKCCW.js} +20 -20
- package/extensions/mfa-auth/README.md +33 -38
- package/extensions/mfa-auth/index.ts +97 -92
- package/extensions/mfa-auth/node_modules/.bin/qrcode-terminal +1 -6
- package/extensions/mfa-auth/node_modules/.bin/qrcode-terminal.cmd +17 -0
- package/extensions/mfa-auth/node_modules/.bin/qrcode-terminal.ps1 +0 -13
- package/extensions/mfa-auth/node_modules/.bin/tsx +1 -6
- package/extensions/mfa-auth/node_modules/.bin/tsx.cmd +17 -0
- package/extensions/mfa-auth/node_modules/.bin/tsx.ps1 +0 -13
- package/extensions/mfa-auth/node_modules/.package-lock.json +103 -0
- package/extensions/mfa-auth/package-lock.json +115 -0
- package/extensions/mfa-auth/package.json +1 -1
- package/extensions/mfa-auth/src/auth-manager.ts +4 -2
- package/extensions/mfa-auth/src/config.ts +1 -4
- package/extensions/mfa-auth/src/dabby-client.test.ts +68 -147
- package/extensions/mfa-auth/src/dabby-client.ts +70 -89
- package/extensions/mfa-auth/src/feishu-support/index.ts +2 -2
- package/extensions/mfa-auth/src/notification-service.ts +19 -14
- package/extensions/mfa-auth/src/providers/base.ts +0 -1
- package/extensions/mfa-auth/src/providers/qr-code.ts +3 -506
- package/extensions/mfa-auth/src/server.ts +3 -223
- package/extensions/mfa-auth/src/types.ts +13 -36
- package/package.json +458 -460
- package/dist/compact.runtime-BEn3giMt.js +0 -39
- package/dist/deliver-runtime-DkQ3XzGv.js +0 -19
- package/dist/deps-send-discord.runtime-BLpqSj6s.js +0 -19
- package/dist/deps-send-imessage.runtime-BFzyYqvR.js +0 -18
- package/dist/deps-send-signal.runtime-DT0TYCy1.js +0 -17
- package/dist/deps-send-slack.runtime-BhaGFfMX.js +0 -17
- package/dist/deps-send-telegram.runtime-B6Cic9NX.js +0 -20
- package/dist/deps-send-whatsapp.runtime-WtEhIq2S.js +0 -43
- package/dist/image-runtime-B1LFYfQ2.js +0 -12
- package/dist/manager-runtime-Da7ME9vS.js +0 -15
- package/dist/pi-model-discovery-runtime-DjM7Z1fx.js +0 -12
- package/dist/runtime-whatsapp-login.runtime-D4BRhQkK.js +0 -13
- package/dist/runtime-whatsapp-outbound.runtime-DJPpS6g-.js +0 -17
- package/dist/slash-commands.runtime-Cu1lTjV9.js +0 -12
- package/dist/slash-dispatch.runtime-DRVJEF4l.js +0 -39
- package/dist/slash-skill-commands.runtime-C373PJjv.js +0 -13
- package/dist/subagent-registry-runtime-D7hWBo1G.js +0 -39
- package/extensions/mfa-auth/node_modules/.bin/qrcode-terminal.CMD +0 -12
- package/extensions/mfa-auth/node_modules/.bin/tsx.CMD +0 -12
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
|
-
import { B as normalizeSkillFilter, E as runTasksWithConcurrency, F as resolveDefaultAgentId, H as normalizeHyphenSlug, K as resolveAgentModelPrimaryValue, P as resolveAgentWorkspaceDir, R as resolveSessionAgentId, S as redactSensitiveText, U as normalizeStringEntries, V as normalizeAtHashSlug, a as resolveSessionTranscriptPathInDir, b as assertNoPathAliasEscape, c as materializeWindowsSpawnProgram, i as resolveSessionTranscriptPath, j as resolveAgentEffectiveModelPrimary, k as resolveAgentConfig, l as resolveWindowsSpawnProgram, m as openFileWithinRoot, n as resolveSessionFilePath, q as toAgentModelListLike, r as resolveSessionFilePathOptions, s as resolveStorePath, t as resolveDefaultSessionStorePath, u as SafeOpenError, x as getDefaultRedactPatterns, y as PATH_ALIAS_POLICIES } from "./paths-
|
|
3
|
-
import { a as resolveGatewayPort, c as resolveStateDir, d as resolveRequiredHomeDir, i as resolveDefaultConfigCandidates, l as expandHomePrefix, n as STATE_DIR, o as resolveOAuthDir, r as resolveConfigPath, s as resolveOAuthPath, t as DEFAULT_GATEWAY_PORT } from "./paths-
|
|
4
|
-
import { E as resolvePreferredOpenClawTmpDir, T as readLoggingConfig, a as defaultRuntime, b as getChildLogger, d as logVerbose, h as success, n as sanitizeForLog, r as stripAnsi, t as createSubsystemLogger, u as info } from "./subsystem-
|
|
5
|
-
import { B as normalizeMainKey, E as resolvePathViaExistingAncestorSync, J as normalizeOptionalAccountId, K as DEFAULT_ACCOUNT_ID, M as DEFAULT_AGENT_ID, O as isNotFoundPathError, P as buildAgentMainSessionKey, S as openBoundaryFileSync, V as resolveAgentIdFromSessionKey, Y as isBlockedObjectKey, _ as runExec, a as DEFAULT_IDENTITY_FILENAME, b as canUseBoundaryFileOpen, c as DEFAULT_USER_FILENAME, h as resolveOpenClawPackageRootSync, i as DEFAULT_HEARTBEAT_FILENAME, k as isPathInside$2, l as ensureAgentWorkspace, n as DEFAULT_AGENT_WORKSPACE_DIR, o as DEFAULT_SOUL_FILENAME, q as normalizeAccountId$1, r as DEFAULT_BOOTSTRAP_FILENAME, s as DEFAULT_TOOLS_FILENAME, t as DEFAULT_AGENTS_FILENAME, x as openBoundaryFile, y as markOpenClawExecEnv, z as normalizeAgentId } from "./workspace-
|
|
6
|
-
import { C as sleep, D as isPlainObject$2, E as truncateUtf16Safe, _ as resolveConfigDir, a as CONFIG_DIR, f as isRecord$4, h as normalizeE164, m as jidToE164, u as escapeRegExp, y as resolveUserPath } from "./logger-
|
|
7
|
-
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-
|
|
2
|
+
import { B as normalizeSkillFilter, E as runTasksWithConcurrency, F as resolveDefaultAgentId, H as normalizeHyphenSlug, K as resolveAgentModelPrimaryValue, P as resolveAgentWorkspaceDir, R as resolveSessionAgentId, S as redactSensitiveText, U as normalizeStringEntries, V as normalizeAtHashSlug, a as resolveSessionTranscriptPathInDir, b as assertNoPathAliasEscape, c as materializeWindowsSpawnProgram, i as resolveSessionTranscriptPath, j as resolveAgentEffectiveModelPrimary, k as resolveAgentConfig, l as resolveWindowsSpawnProgram, m as openFileWithinRoot, n as resolveSessionFilePath, q as toAgentModelListLike, r as resolveSessionFilePathOptions, s as resolveStorePath, t as resolveDefaultSessionStorePath, u as SafeOpenError, x as getDefaultRedactPatterns, y as PATH_ALIAS_POLICIES } from "./paths-CehYKFsO.js";
|
|
3
|
+
import { a as resolveGatewayPort, c as resolveStateDir, d as resolveRequiredHomeDir, i as resolveDefaultConfigCandidates, l as expandHomePrefix, n as STATE_DIR, o as resolveOAuthDir, r as resolveConfigPath, s as resolveOAuthPath, t as DEFAULT_GATEWAY_PORT } from "./paths-DkxwiA8g.js";
|
|
4
|
+
import { E as resolvePreferredOpenClawTmpDir, T as readLoggingConfig, a as defaultRuntime, b as getChildLogger, d as logVerbose, h as success, n as sanitizeForLog, r as stripAnsi, t as createSubsystemLogger, u as info } from "./subsystem-DfXy5gUB.js";
|
|
5
|
+
import { B as normalizeMainKey, E as resolvePathViaExistingAncestorSync, J as normalizeOptionalAccountId, K as DEFAULT_ACCOUNT_ID, M as DEFAULT_AGENT_ID, O as isNotFoundPathError, P as buildAgentMainSessionKey, S as openBoundaryFileSync, V as resolveAgentIdFromSessionKey, Y as isBlockedObjectKey, _ as runExec, a as DEFAULT_IDENTITY_FILENAME, b as canUseBoundaryFileOpen, c as DEFAULT_USER_FILENAME, h as resolveOpenClawPackageRootSync, i as DEFAULT_HEARTBEAT_FILENAME, k as isPathInside$2, l as ensureAgentWorkspace, n as DEFAULT_AGENT_WORKSPACE_DIR, o as DEFAULT_SOUL_FILENAME, q as normalizeAccountId$1, r as DEFAULT_BOOTSTRAP_FILENAME, s as DEFAULT_TOOLS_FILENAME, t as DEFAULT_AGENTS_FILENAME, x as openBoundaryFile, y as markOpenClawExecEnv, z as normalizeAgentId } from "./workspace-DGIcKCCW.js";
|
|
6
|
+
import { C as sleep, D as isPlainObject$2, E as truncateUtf16Safe, _ as resolveConfigDir, a as CONFIG_DIR, f as isRecord$4, h as normalizeE164, m as jidToE164, u as escapeRegExp, y as resolveUserPath } from "./logger-CbUVl62f.js";
|
|
7
|
+
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-8N63GdbE.js";
|
|
8
8
|
import { t as parseBooleanValue } from "./boolean-C7Ct_klp.js";
|
|
9
|
-
import { t as isTruthyEnvValue } from "./env-
|
|
10
|
-
import { a as parseOpenClawManifestInstallBase, c as resolveOpenClawManifestOs, d as evaluateRuntimeEligibility, f as hasBinary, i as parseFrontmatterBool, l as resolveOpenClawManifestRequires, m as MANIFEST_KEY, n as getFrontmatterString, o as resolveOpenClawManifestBlock, p as isConfigPathTruthyWithDefaults, r as normalizeStringList$2, s as resolveOpenClawManifestInstall, t as applyOpenClawManifestInstallCommonFields, u as parseFrontmatterBlock, v as registerInternalHook } from "./frontmatter-
|
|
9
|
+
import { t as isTruthyEnvValue } from "./env-lw2hsIUY.js";
|
|
10
|
+
import { a as parseOpenClawManifestInstallBase, c as resolveOpenClawManifestOs, d as evaluateRuntimeEligibility, f as hasBinary, i as parseFrontmatterBool, l as resolveOpenClawManifestRequires, m as MANIFEST_KEY, n as getFrontmatterString, o as resolveOpenClawManifestBlock, p as isConfigPathTruthyWithDefaults, r as normalizeStringList$2, s as resolveOpenClawManifestInstall, t as applyOpenClawManifestInstallCommonFields, u as parseFrontmatterBlock, v as registerInternalHook } from "./frontmatter-C_obXuTp.js";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
12
|
import fs from "node:fs/promises";
|
|
13
13
|
import os from "node:os";
|
|
14
14
|
import path, { posix } from "node:path";
|
|
15
|
-
import
|
|
15
|
+
import syncFs from "node:fs";
|
|
16
16
|
import JSON5 from "json5";
|
|
17
17
|
import util, { isDeepStrictEqual } from "node:util";
|
|
18
18
|
import { execFileSync, spawn } from "node:child_process";
|
|
@@ -32,7 +32,7 @@ import "node:stream/promises";
|
|
|
32
32
|
import http, { createServer } from "node:http";
|
|
33
33
|
import https from "node:https";
|
|
34
34
|
import { fileTypeFromBuffer } from "file-type";
|
|
35
|
-
import WebSocket
|
|
35
|
+
import WebSocket, { WebSocketServer } from "ws";
|
|
36
36
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
37
37
|
import { BedrockClient, ListFoundationModelsCommand } from "@aws-sdk/client-bedrock";
|
|
38
38
|
import { createAssistantMessageEventStream, getEnvApiKey } from "@mariozechner/pi-ai";
|
|
@@ -247,7 +247,7 @@ function isValidPid(pid) {
|
|
|
247
247
|
function isZombieProcess(pid) {
|
|
248
248
|
if (process.platform !== "linux") return false;
|
|
249
249
|
try {
|
|
250
|
-
return
|
|
250
|
+
return syncFs.readFileSync(`/proc/${pid}/status`, "utf8").match(/^State:\s+(\S)/m)?.[1] === "Z";
|
|
251
251
|
} catch {
|
|
252
252
|
return false;
|
|
253
253
|
}
|
|
@@ -274,7 +274,7 @@ function getProcessStartTime(pid) {
|
|
|
274
274
|
if (process.platform !== "linux") return null;
|
|
275
275
|
if (!isValidPid(pid)) return null;
|
|
276
276
|
try {
|
|
277
|
-
const stat =
|
|
277
|
+
const stat = syncFs.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
278
278
|
const commEndIndex = stat.lastIndexOf(")");
|
|
279
279
|
if (commEndIndex < 0) return null;
|
|
280
280
|
const fields = stat.slice(commEndIndex + 1).trimStart().split(/\s+/);
|
|
@@ -535,7 +535,7 @@ function resolveAuthStorePathForDisplay(agentDir) {
|
|
|
535
535
|
return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
|
|
536
536
|
}
|
|
537
537
|
function ensureAuthStoreFile(pathname) {
|
|
538
|
-
if (
|
|
538
|
+
if (syncFs.existsSync(pathname)) return;
|
|
539
539
|
saveJsonFile(pathname, {
|
|
540
540
|
version: 1,
|
|
541
541
|
profiles: {}
|
|
@@ -796,7 +796,7 @@ function loadAuthProfileStoreForAgent(agentDir, options) {
|
|
|
796
796
|
if (shouldWrite && legacy !== null) {
|
|
797
797
|
const legacyPath = resolveLegacyAuthStorePath(agentDir);
|
|
798
798
|
try {
|
|
799
|
-
|
|
799
|
+
syncFs.unlinkSync(legacyPath);
|
|
800
800
|
} catch (err) {
|
|
801
801
|
if (err?.code !== "ENOENT") log$18.warn("failed to delete legacy auth.json after migration", {
|
|
802
802
|
err,
|
|
@@ -979,7 +979,7 @@ function loadDotEnv(opts) {
|
|
|
979
979
|
const quiet = opts?.quiet ?? true;
|
|
980
980
|
dotenv.config({ quiet });
|
|
981
981
|
const globalEnvPath = path.join(resolveConfigDir(process.env), ".env");
|
|
982
|
-
if (!
|
|
982
|
+
if (!syncFs.existsSync(globalEnvPath)) return;
|
|
983
983
|
dotenv.config({
|
|
984
984
|
quiet,
|
|
985
985
|
path: globalEnvPath,
|
|
@@ -1128,7 +1128,7 @@ function resolveTimeoutMs(timeoutMs) {
|
|
|
1128
1128
|
function readEtcShells() {
|
|
1129
1129
|
if (cachedEtcShells !== void 0) return cachedEtcShells;
|
|
1130
1130
|
try {
|
|
1131
|
-
const entries =
|
|
1131
|
+
const entries = syncFs.readFileSync("/etc/shells", "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#") && path.isAbsolute(line));
|
|
1132
1132
|
cachedEtcShells = new Set(entries);
|
|
1133
1133
|
} catch {
|
|
1134
1134
|
cachedEtcShells = null;
|
|
@@ -1615,7 +1615,7 @@ function resolveActiveTalkProviderConfig(talk) {
|
|
|
1615
1615
|
};
|
|
1616
1616
|
}
|
|
1617
1617
|
function readTalkApiKeyFromProfile(deps = {}) {
|
|
1618
|
-
const fsImpl = deps.fs ??
|
|
1618
|
+
const fsImpl = deps.fs ?? syncFs;
|
|
1619
1619
|
const osImpl = deps.os ?? os;
|
|
1620
1620
|
const pathImpl = deps.path ?? path;
|
|
1621
1621
|
const home = osImpl.homedir();
|
|
@@ -2265,7 +2265,7 @@ function isPathInside$1(basePath, candidatePath) {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
function safeRealpathSync$1(filePath) {
|
|
2267
2267
|
try {
|
|
2268
|
-
return
|
|
2268
|
+
return syncFs.realpathSync(filePath);
|
|
2269
2269
|
} catch {
|
|
2270
2270
|
return null;
|
|
2271
2271
|
}
|
|
@@ -2372,7 +2372,7 @@ var IncludeProcessor = class IncludeProcessor {
|
|
|
2372
2372
|
const normalized = path.normalize(resolved);
|
|
2373
2373
|
if (!isPathInside$1(this.rootDir, normalized)) throw new ConfigIncludeError(`Include path escapes config directory: ${includePath} (root: ${this.rootDir})`, includePath);
|
|
2374
2374
|
try {
|
|
2375
|
-
const real =
|
|
2375
|
+
const real = syncFs.realpathSync(normalized);
|
|
2376
2376
|
if (!isPathInside$1(this.rootRealDir, real)) throw new ConfigIncludeError(`Include path resolves outside config directory (symlink): ${includePath} (root: ${this.rootDir})`, includePath);
|
|
2377
2377
|
} catch (err) {
|
|
2378
2378
|
if (err instanceof ConfigIncludeError) throw err;
|
|
@@ -2414,13 +2414,13 @@ var IncludeProcessor = class IncludeProcessor {
|
|
|
2414
2414
|
};
|
|
2415
2415
|
function safeRealpath(target) {
|
|
2416
2416
|
try {
|
|
2417
|
-
return
|
|
2417
|
+
return syncFs.realpathSync(target);
|
|
2418
2418
|
} catch {
|
|
2419
2419
|
return target;
|
|
2420
2420
|
}
|
|
2421
2421
|
}
|
|
2422
2422
|
function readConfigIncludeFileWithGuards(params) {
|
|
2423
|
-
const ioFs = params.ioFs ??
|
|
2423
|
+
const ioFs = params.ioFs ?? syncFs;
|
|
2424
2424
|
const maxBytes = params.maxBytes ?? 2097152;
|
|
2425
2425
|
if (!canUseBoundaryFileOpen(ioFs)) return ioFs.readFileSync(params.resolvedPath, "utf-8");
|
|
2426
2426
|
const opened = openBoundaryFileSync({
|
|
@@ -2443,7 +2443,7 @@ function readConfigIncludeFileWithGuards(params) {
|
|
|
2443
2443
|
}
|
|
2444
2444
|
}
|
|
2445
2445
|
const defaultResolver = {
|
|
2446
|
-
readFile: (p) =>
|
|
2446
|
+
readFile: (p) => syncFs.readFileSync(p, "utf-8"),
|
|
2447
2447
|
readFileWithGuards: ({ includePath, resolvedPath, rootRealDir }) => readConfigIncludeFileWithGuards({
|
|
2448
2448
|
includePath,
|
|
2449
2449
|
resolvedPath,
|
|
@@ -4080,7 +4080,7 @@ function normalizeMatchTarget(value) {
|
|
|
4080
4080
|
}
|
|
4081
4081
|
function tryRealpath$1(value) {
|
|
4082
4082
|
try {
|
|
4083
|
-
return
|
|
4083
|
+
return syncFs.realpathSync(value);
|
|
4084
4084
|
} catch {
|
|
4085
4085
|
return null;
|
|
4086
4086
|
}
|
|
@@ -4638,8 +4638,8 @@ function resolveWindowsExecutableExtensions(executable, env) {
|
|
|
4638
4638
|
}
|
|
4639
4639
|
function isExecutableFile(filePath) {
|
|
4640
4640
|
try {
|
|
4641
|
-
if (!
|
|
4642
|
-
if (process.platform !== "win32")
|
|
4641
|
+
if (!syncFs.statSync(filePath).isFile()) return false;
|
|
4642
|
+
if (process.platform !== "win32") syncFs.accessSync(filePath, syncFs.constants.X_OK);
|
|
4643
4643
|
return true;
|
|
4644
4644
|
} catch {
|
|
4645
4645
|
return false;
|
|
@@ -4677,7 +4677,7 @@ const DEFAULT_SAFE_BINS = [
|
|
|
4677
4677
|
function tryResolveRealpath(filePath) {
|
|
4678
4678
|
if (!filePath) return;
|
|
4679
4679
|
try {
|
|
4680
|
-
return
|
|
4680
|
+
return syncFs.realpathSync(filePath);
|
|
4681
4681
|
} catch {
|
|
4682
4682
|
return;
|
|
4683
4683
|
}
|
|
@@ -5557,7 +5557,7 @@ function listWritableExplicitTrustedSafeBinDirs(entries) {
|
|
|
5557
5557
|
for (const dir of resolved) {
|
|
5558
5558
|
let stat;
|
|
5559
5559
|
try {
|
|
5560
|
-
stat =
|
|
5560
|
+
stat = syncFs.statSync(dir);
|
|
5561
5561
|
} catch {
|
|
5562
5562
|
continue;
|
|
5563
5563
|
}
|
|
@@ -6845,13 +6845,13 @@ function resolveBundledPluginsDir() {
|
|
|
6845
6845
|
try {
|
|
6846
6846
|
const execDir = path.dirname(process.execPath);
|
|
6847
6847
|
const sibling = path.join(execDir, "extensions");
|
|
6848
|
-
if (
|
|
6848
|
+
if (syncFs.existsSync(sibling)) return sibling;
|
|
6849
6849
|
} catch {}
|
|
6850
6850
|
try {
|
|
6851
6851
|
let cursor = path.dirname(fileURLToPath(import.meta.url));
|
|
6852
6852
|
for (let i = 0; i < 6; i += 1) {
|
|
6853
6853
|
const candidate = path.join(cursor, "extensions");
|
|
6854
|
-
if (
|
|
6854
|
+
if (syncFs.existsSync(candidate)) return candidate;
|
|
6855
6855
|
const parent = path.dirname(cursor);
|
|
6856
6856
|
if (parent === cursor) break;
|
|
6857
6857
|
cursor = parent;
|
|
@@ -6869,7 +6869,7 @@ function normalizeStringList$1(value) {
|
|
|
6869
6869
|
function resolvePluginManifestPath(rootDir) {
|
|
6870
6870
|
for (const filename of PLUGIN_MANIFEST_FILENAMES) {
|
|
6871
6871
|
const candidate = path.join(rootDir, filename);
|
|
6872
|
-
if (
|
|
6872
|
+
if (syncFs.existsSync(candidate)) return candidate;
|
|
6873
6873
|
}
|
|
6874
6874
|
return path.join(rootDir, PLUGIN_MANIFEST_FILENAME);
|
|
6875
6875
|
}
|
|
@@ -6895,7 +6895,7 @@ function loadPluginManifest(rootDir, rejectHardlinks = true) {
|
|
|
6895
6895
|
}
|
|
6896
6896
|
let raw;
|
|
6897
6897
|
try {
|
|
6898
|
-
raw = JSON.parse(
|
|
6898
|
+
raw = JSON.parse(syncFs.readFileSync(opened.fd, "utf-8"));
|
|
6899
6899
|
} catch (err) {
|
|
6900
6900
|
return {
|
|
6901
6901
|
ok: false,
|
|
@@ -6903,7 +6903,7 @@ function loadPluginManifest(rootDir, rejectHardlinks = true) {
|
|
|
6903
6903
|
manifestPath
|
|
6904
6904
|
};
|
|
6905
6905
|
} finally {
|
|
6906
|
-
|
|
6906
|
+
syncFs.closeSync(opened.fd);
|
|
6907
6907
|
}
|
|
6908
6908
|
if (!isRecord$4(raw)) return {
|
|
6909
6909
|
ok: false,
|
|
@@ -6983,7 +6983,7 @@ function safeRealpathSync(targetPath, cache) {
|
|
|
6983
6983
|
const cached = cache?.get(targetPath);
|
|
6984
6984
|
if (cached) return cached;
|
|
6985
6985
|
try {
|
|
6986
|
-
const resolved =
|
|
6986
|
+
const resolved = syncFs.realpathSync(targetPath);
|
|
6987
6987
|
cache?.set(targetPath, resolved);
|
|
6988
6988
|
return resolved;
|
|
6989
6989
|
} catch {
|
|
@@ -6992,7 +6992,7 @@ function safeRealpathSync(targetPath, cache) {
|
|
|
6992
6992
|
}
|
|
6993
6993
|
function safeStatSync(targetPath) {
|
|
6994
6994
|
try {
|
|
6995
|
-
return
|
|
6995
|
+
return syncFs.statSync(targetPath);
|
|
6996
6996
|
} catch {
|
|
6997
6997
|
return null;
|
|
6998
6998
|
}
|
|
@@ -7141,12 +7141,12 @@ function readPackageManifest(dir, rejectHardlinks = true) {
|
|
|
7141
7141
|
});
|
|
7142
7142
|
if (!opened.ok) return null;
|
|
7143
7143
|
try {
|
|
7144
|
-
const raw =
|
|
7144
|
+
const raw = syncFs.readFileSync(opened.fd, "utf-8");
|
|
7145
7145
|
return JSON.parse(raw);
|
|
7146
7146
|
} catch {
|
|
7147
7147
|
return null;
|
|
7148
7148
|
} finally {
|
|
7149
|
-
|
|
7149
|
+
syncFs.closeSync(opened.fd);
|
|
7150
7150
|
}
|
|
7151
7151
|
}
|
|
7152
7152
|
function deriveIdHint(params) {
|
|
@@ -7199,14 +7199,14 @@ function resolvePackageEntrySource(params) {
|
|
|
7199
7199
|
return null;
|
|
7200
7200
|
}
|
|
7201
7201
|
const safeSource = opened.path;
|
|
7202
|
-
|
|
7202
|
+
syncFs.closeSync(opened.fd);
|
|
7203
7203
|
return safeSource;
|
|
7204
7204
|
}
|
|
7205
7205
|
function discoverInDirectory(params) {
|
|
7206
|
-
if (!
|
|
7206
|
+
if (!syncFs.existsSync(params.dir)) return;
|
|
7207
7207
|
let entries = [];
|
|
7208
7208
|
try {
|
|
7209
|
-
entries =
|
|
7209
|
+
entries = syncFs.readdirSync(params.dir, { withFileTypes: true });
|
|
7210
7210
|
} catch (err) {
|
|
7211
7211
|
params.diagnostics.push({
|
|
7212
7212
|
level: "warn",
|
|
@@ -7267,7 +7267,7 @@ function discoverInDirectory(params) {
|
|
|
7267
7267
|
}
|
|
7268
7268
|
continue;
|
|
7269
7269
|
}
|
|
7270
|
-
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(fullPath, candidate)).find((candidate) =>
|
|
7270
|
+
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(fullPath, candidate)).find((candidate) => syncFs.existsSync(candidate));
|
|
7271
7271
|
if (indexFile && isExtensionFile(indexFile)) addCandidate({
|
|
7272
7272
|
candidates: params.candidates,
|
|
7273
7273
|
diagnostics: params.diagnostics,
|
|
@@ -7285,7 +7285,7 @@ function discoverInDirectory(params) {
|
|
|
7285
7285
|
}
|
|
7286
7286
|
function discoverFromPath(params) {
|
|
7287
7287
|
const resolved = resolveUserPath(params.rawPath);
|
|
7288
|
-
if (!
|
|
7288
|
+
if (!syncFs.existsSync(resolved)) {
|
|
7289
7289
|
params.diagnostics.push({
|
|
7290
7290
|
level: "error",
|
|
7291
7291
|
message: `plugin path not found: ${resolved}`,
|
|
@@ -7293,7 +7293,7 @@ function discoverFromPath(params) {
|
|
|
7293
7293
|
});
|
|
7294
7294
|
return;
|
|
7295
7295
|
}
|
|
7296
|
-
const stat =
|
|
7296
|
+
const stat = syncFs.statSync(resolved);
|
|
7297
7297
|
if (stat.isFile()) {
|
|
7298
7298
|
if (!isExtensionFile(resolved)) {
|
|
7299
7299
|
params.diagnostics.push({
|
|
@@ -7351,7 +7351,7 @@ function discoverFromPath(params) {
|
|
|
7351
7351
|
}
|
|
7352
7352
|
return;
|
|
7353
7353
|
}
|
|
7354
|
-
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(resolved, candidate)).find((candidate) =>
|
|
7354
|
+
const indexFile = [...DEFAULT_PLUGIN_ENTRY_CANDIDATES].map((candidate) => path.join(resolved, candidate)).find((candidate) => syncFs.existsSync(candidate));
|
|
7355
7355
|
if (indexFile && isExtensionFile(indexFile)) {
|
|
7356
7356
|
addCandidate({
|
|
7357
7357
|
candidates: params.candidates,
|
|
@@ -7483,7 +7483,7 @@ function buildCacheKey$1(params) {
|
|
|
7483
7483
|
}
|
|
7484
7484
|
function safeStatMtimeMs(filePath) {
|
|
7485
7485
|
try {
|
|
7486
|
-
return
|
|
7486
|
+
return syncFs.statSync(filePath).mtimeMs;
|
|
7487
7487
|
} catch {
|
|
7488
7488
|
return null;
|
|
7489
7489
|
}
|
|
@@ -12649,7 +12649,7 @@ function resolveConfigPathForDeps(deps) {
|
|
|
12649
12649
|
}
|
|
12650
12650
|
function normalizeDeps(overrides = {}) {
|
|
12651
12651
|
return {
|
|
12652
|
-
fs: overrides.fs ??
|
|
12652
|
+
fs: overrides.fs ?? syncFs,
|
|
12653
12653
|
json5: overrides.json5 ?? JSON5,
|
|
12654
12654
|
env: overrides.env ?? process.env,
|
|
12655
12655
|
homedir: overrides.homedir ?? (() => resolveRequiredHomeDir(overrides.env ?? process.env, os.homedir)),
|
|
@@ -16719,13 +16719,13 @@ function shortPath(value) {
|
|
|
16719
16719
|
//#region src/agents/skills/bundled-dir.ts
|
|
16720
16720
|
function looksLikeSkillsDir(dir) {
|
|
16721
16721
|
try {
|
|
16722
|
-
const entries =
|
|
16722
|
+
const entries = syncFs.readdirSync(dir, { withFileTypes: true });
|
|
16723
16723
|
for (const entry of entries) {
|
|
16724
16724
|
if (entry.name.startsWith(".")) continue;
|
|
16725
16725
|
const fullPath = path.join(dir, entry.name);
|
|
16726
16726
|
if (entry.isFile() && entry.name.endsWith(".md")) return true;
|
|
16727
16727
|
if (entry.isDirectory()) {
|
|
16728
|
-
if (
|
|
16728
|
+
if (syncFs.existsSync(path.join(fullPath, "SKILL.md"))) return true;
|
|
16729
16729
|
}
|
|
16730
16730
|
}
|
|
16731
16731
|
} catch {
|
|
@@ -16740,7 +16740,7 @@ function resolveBundledSkillsDir(opts = {}) {
|
|
|
16740
16740
|
const execPath = opts.execPath ?? process.execPath;
|
|
16741
16741
|
const execDir = path.dirname(execPath);
|
|
16742
16742
|
const sibling = path.join(execDir, "skills");
|
|
16743
|
-
if (
|
|
16743
|
+
if (syncFs.existsSync(sibling)) return sibling;
|
|
16744
16744
|
} catch {}
|
|
16745
16745
|
try {
|
|
16746
16746
|
const moduleUrl = opts.moduleUrl ?? import.meta.url;
|
|
@@ -16802,7 +16802,7 @@ function resolvePluginSkillDirs(params) {
|
|
|
16802
16802
|
const trimmed = raw.trim();
|
|
16803
16803
|
if (!trimmed) continue;
|
|
16804
16804
|
const candidate = path.resolve(record.rootDir, trimmed);
|
|
16805
|
-
if (!
|
|
16805
|
+
if (!syncFs.existsSync(candidate)) {
|
|
16806
16806
|
log$15.warn(`plugin skill path not found (${record.id}): ${candidate}`);
|
|
16807
16807
|
continue;
|
|
16808
16808
|
}
|
|
@@ -16831,7 +16831,7 @@ async function serializeByKey(key, task) {
|
|
|
16831
16831
|
}
|
|
16832
16832
|
//#endregion
|
|
16833
16833
|
//#region src/agents/skills/workspace.ts
|
|
16834
|
-
const fsp =
|
|
16834
|
+
const fsp = syncFs.promises;
|
|
16835
16835
|
const skillsLogger = createSubsystemLogger("skills");
|
|
16836
16836
|
const skillCommandDebugOnce = /* @__PURE__ */ new Set();
|
|
16837
16837
|
/**
|
|
@@ -16908,7 +16908,7 @@ function resolveSkillsLimits(config) {
|
|
|
16908
16908
|
}
|
|
16909
16909
|
function listChildDirectories(dir) {
|
|
16910
16910
|
try {
|
|
16911
|
-
const entries =
|
|
16911
|
+
const entries = syncFs.readdirSync(dir, { withFileTypes: true });
|
|
16912
16912
|
const dirs = [];
|
|
16913
16913
|
for (const entry of entries) {
|
|
16914
16914
|
if (entry.name.startsWith(".")) continue;
|
|
@@ -16919,7 +16919,7 @@ function listChildDirectories(dir) {
|
|
|
16919
16919
|
continue;
|
|
16920
16920
|
}
|
|
16921
16921
|
if (entry.isSymbolicLink()) try {
|
|
16922
|
-
if (
|
|
16922
|
+
if (syncFs.statSync(fullPath).isDirectory()) dirs.push(entry.name);
|
|
16923
16923
|
} catch {}
|
|
16924
16924
|
}
|
|
16925
16925
|
return dirs;
|
|
@@ -16929,7 +16929,7 @@ function listChildDirectories(dir) {
|
|
|
16929
16929
|
}
|
|
16930
16930
|
function tryRealpath(filePath) {
|
|
16931
16931
|
try {
|
|
16932
|
-
return
|
|
16932
|
+
return syncFs.realpathSync(filePath);
|
|
16933
16933
|
} catch {
|
|
16934
16934
|
return null;
|
|
16935
16935
|
}
|
|
@@ -16974,7 +16974,7 @@ function filterLoadedSkillsInsideRoot(params) {
|
|
|
16974
16974
|
function resolveNestedSkillsRoot(dir, opts) {
|
|
16975
16975
|
const nested = path.join(dir, "skills");
|
|
16976
16976
|
try {
|
|
16977
|
-
if (!
|
|
16977
|
+
if (!syncFs.existsSync(nested) || !syncFs.statSync(nested).isDirectory()) return { baseDir: dir };
|
|
16978
16978
|
} catch {
|
|
16979
16979
|
return { baseDir: dir };
|
|
16980
16980
|
}
|
|
@@ -16983,7 +16983,7 @@ function resolveNestedSkillsRoot(dir, opts) {
|
|
|
16983
16983
|
const toScan = scanLimit === 0 ? [] : nestedDirs.slice(0, Math.min(nestedDirs.length, scanLimit));
|
|
16984
16984
|
for (const name of toScan) {
|
|
16985
16985
|
const skillMd = path.join(nested, name, "SKILL.md");
|
|
16986
|
-
if (
|
|
16986
|
+
if (syncFs.existsSync(skillMd)) return {
|
|
16987
16987
|
baseDir: nested,
|
|
16988
16988
|
note: `Detected nested skills root at ${nested}`
|
|
16989
16989
|
};
|
|
@@ -17012,7 +17012,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
17012
17012
|
});
|
|
17013
17013
|
if (!baseDirRealPath) return [];
|
|
17014
17014
|
const rootSkillMd = path.join(baseDir, "SKILL.md");
|
|
17015
|
-
if (
|
|
17015
|
+
if (syncFs.existsSync(rootSkillMd)) {
|
|
17016
17016
|
const rootSkillRealPath = resolveContainedSkillPath({
|
|
17017
17017
|
source: params.source,
|
|
17018
17018
|
rootDir,
|
|
@@ -17021,7 +17021,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
17021
17021
|
});
|
|
17022
17022
|
if (!rootSkillRealPath) return [];
|
|
17023
17023
|
try {
|
|
17024
|
-
const size =
|
|
17024
|
+
const size = syncFs.statSync(rootSkillRealPath).size;
|
|
17025
17025
|
if (size > limits.maxSkillFileBytes) {
|
|
17026
17026
|
skillsLogger.warn("Skipping skills root due to oversized SKILL.md.", {
|
|
17027
17027
|
dir: baseDir,
|
|
@@ -17071,7 +17071,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
17071
17071
|
candidatePath: skillDir
|
|
17072
17072
|
})) continue;
|
|
17073
17073
|
const skillMd = path.join(skillDir, "SKILL.md");
|
|
17074
|
-
if (!
|
|
17074
|
+
if (!syncFs.existsSync(skillMd)) continue;
|
|
17075
17075
|
const skillMdRealPath = resolveContainedSkillPath({
|
|
17076
17076
|
source: params.source,
|
|
17077
17077
|
rootDir,
|
|
@@ -17080,7 +17080,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
17080
17080
|
});
|
|
17081
17081
|
if (!skillMdRealPath) continue;
|
|
17082
17082
|
try {
|
|
17083
|
-
const size =
|
|
17083
|
+
const size = syncFs.statSync(skillMdRealPath).size;
|
|
17084
17084
|
if (size > limits.maxSkillFileBytes) {
|
|
17085
17085
|
skillsLogger.warn("Skipping skill due to oversized SKILL.md.", {
|
|
17086
17086
|
skill: name,
|
|
@@ -17153,7 +17153,7 @@ function loadSkillEntries(workspaceDir, opts) {
|
|
|
17153
17153
|
return Array.from(merged.values()).map((skill) => {
|
|
17154
17154
|
let frontmatter = {};
|
|
17155
17155
|
try {
|
|
17156
|
-
frontmatter = parseFrontmatter(
|
|
17156
|
+
frontmatter = parseFrontmatter(syncFs.readFileSync(skill.filePath, "utf-8"));
|
|
17157
17157
|
} catch {}
|
|
17158
17158
|
return {
|
|
17159
17159
|
skill,
|
|
@@ -17803,7 +17803,7 @@ function isModuleNotFoundError(err) {
|
|
|
17803
17803
|
}
|
|
17804
17804
|
async function loadPwAiModule(mode) {
|
|
17805
17805
|
try {
|
|
17806
|
-
return await import("./pw-ai-
|
|
17806
|
+
return await import("./pw-ai-CoIUdns_.js");
|
|
17807
17807
|
} catch (err) {
|
|
17808
17808
|
if (mode === "soft") return null;
|
|
17809
17809
|
if (isModuleNotFoundError(err)) return null;
|
|
@@ -19310,7 +19310,7 @@ async function ensureChromeExtensionRelayServer(opts) {
|
|
|
19310
19310
|
let extensionWs = null;
|
|
19311
19311
|
const cdpClients = /* @__PURE__ */ new Set();
|
|
19312
19312
|
const connectedTargets = /* @__PURE__ */ new Map();
|
|
19313
|
-
const extensionConnected = () => extensionWs?.readyState === WebSocket
|
|
19313
|
+
const extensionConnected = () => extensionWs?.readyState === WebSocket.OPEN;
|
|
19314
19314
|
const hasConnectedTargets = () => connectedTargets.size > 0;
|
|
19315
19315
|
let extensionDisconnectCleanupTimer = null;
|
|
19316
19316
|
const extensionReconnectWaiters = /* @__PURE__ */ new Set();
|
|
@@ -19362,7 +19362,7 @@ async function ensureChromeExtensionRelayServer(opts) {
|
|
|
19362
19362
|
let nextExtensionId = 1;
|
|
19363
19363
|
const sendToExtension = async (payload) => {
|
|
19364
19364
|
const ws = extensionWs;
|
|
19365
|
-
if (!ws || ws.readyState !== WebSocket
|
|
19365
|
+
if (!ws || ws.readyState !== WebSocket.OPEN) throw new Error("Chrome extension not connected");
|
|
19366
19366
|
ws.send(JSON.stringify(payload));
|
|
19367
19367
|
return await new Promise((resolve, reject) => {
|
|
19368
19368
|
const timer = setTimeout(() => {
|
|
@@ -19379,12 +19379,12 @@ async function ensureChromeExtensionRelayServer(opts) {
|
|
|
19379
19379
|
const broadcastToCdpClients = (evt) => {
|
|
19380
19380
|
const msg = JSON.stringify(evt);
|
|
19381
19381
|
for (const ws of cdpClients) {
|
|
19382
|
-
if (ws.readyState !== WebSocket
|
|
19382
|
+
if (ws.readyState !== WebSocket.OPEN) continue;
|
|
19383
19383
|
ws.send(msg);
|
|
19384
19384
|
}
|
|
19385
19385
|
};
|
|
19386
19386
|
const sendResponseToCdp = (ws, res) => {
|
|
19387
|
-
if (ws.readyState !== WebSocket
|
|
19387
|
+
if (ws.readyState !== WebSocket.OPEN) return;
|
|
19388
19388
|
ws.send(JSON.stringify(res));
|
|
19389
19389
|
};
|
|
19390
19390
|
const dropConnectedTargetSession = (sessionId) => {
|
|
@@ -19638,7 +19638,7 @@ async function ensureChromeExtensionRelayServer(opts) {
|
|
|
19638
19638
|
rejectUpgrade(socket, 401, "Unauthorized");
|
|
19639
19639
|
return;
|
|
19640
19640
|
}
|
|
19641
|
-
if (extensionWs && extensionWs.readyState !== WebSocket
|
|
19641
|
+
if (extensionWs && extensionWs.readyState !== WebSocket.OPEN) {
|
|
19642
19642
|
try {
|
|
19643
19643
|
extensionWs.terminate();
|
|
19644
19644
|
} catch {}
|
|
@@ -19671,7 +19671,7 @@ async function ensureChromeExtensionRelayServer(opts) {
|
|
|
19671
19671
|
clearExtensionDisconnectCleanupTimer();
|
|
19672
19672
|
flushExtensionReconnectWaiters(true);
|
|
19673
19673
|
const ping = setInterval(() => {
|
|
19674
|
-
if (ws.readyState !== WebSocket
|
|
19674
|
+
if (ws.readyState !== WebSocket.OPEN) return;
|
|
19675
19675
|
ws.send(JSON.stringify({ method: "ping" }));
|
|
19676
19676
|
}, 5e3);
|
|
19677
19677
|
ws.on("message", (data) => {
|
|
@@ -20055,7 +20055,7 @@ function openCdpWebSocket(wsUrl, opts) {
|
|
|
20055
20055
|
const headers = getHeadersWithAuth(wsUrl, opts?.headers ?? {});
|
|
20056
20056
|
const handshakeTimeoutMs = typeof opts?.handshakeTimeoutMs === "number" && Number.isFinite(opts.handshakeTimeoutMs) ? Math.max(1, Math.floor(opts.handshakeTimeoutMs)) : CDP_WS_HANDSHAKE_TIMEOUT_MS;
|
|
20057
20057
|
const agent = getDirectAgentForCdp(wsUrl);
|
|
20058
|
-
return new WebSocket
|
|
20058
|
+
return new WebSocket(wsUrl, {
|
|
20059
20059
|
handshakeTimeout: handshakeTimeoutMs,
|
|
20060
20060
|
...Object.keys(headers).length ? { headers } : {},
|
|
20061
20061
|
...agent ? { agent } : {}
|
|
@@ -21401,7 +21401,7 @@ const CHROMIUM_EXE_NAMES = new Set([
|
|
|
21401
21401
|
]);
|
|
21402
21402
|
function exists$1(filePath) {
|
|
21403
21403
|
try {
|
|
21404
|
-
return
|
|
21404
|
+
return syncFs.existsSync(filePath);
|
|
21405
21405
|
} catch {
|
|
21406
21406
|
return false;
|
|
21407
21407
|
}
|
|
@@ -21544,7 +21544,7 @@ function findDesktopFilePath(desktopId) {
|
|
|
21544
21544
|
}
|
|
21545
21545
|
function readDesktopExecLine(desktopPath) {
|
|
21546
21546
|
try {
|
|
21547
|
-
const lines =
|
|
21547
|
+
const lines = syncFs.readFileSync(desktopPath, "utf8").split(/\r?\n/);
|
|
21548
21548
|
for (const line of lines) if (line.startsWith("Exec=")) return line.slice(5).trim();
|
|
21549
21549
|
} catch {}
|
|
21550
21550
|
return null;
|
|
@@ -21830,7 +21830,7 @@ function deriveDefaultBrowserCdpPortRange(browserControlPort) {
|
|
|
21830
21830
|
const LSOF_CANDIDATES = process.platform === "darwin" ? ["/usr/sbin/lsof", "/usr/bin/lsof"] : ["/usr/bin/lsof", "/usr/sbin/lsof"];
|
|
21831
21831
|
function resolveLsofCommandSync() {
|
|
21832
21832
|
for (const candidate of LSOF_CANDIDATES) try {
|
|
21833
|
-
|
|
21833
|
+
syncFs.accessSync(candidate, syncFs.constants.X_OK);
|
|
21834
21834
|
return candidate;
|
|
21835
21835
|
} catch {}
|
|
21836
21836
|
return "lsof";
|
|
@@ -21872,8 +21872,8 @@ function decoratedMarkerPath(userDataDir) {
|
|
|
21872
21872
|
}
|
|
21873
21873
|
function safeReadJson(filePath) {
|
|
21874
21874
|
try {
|
|
21875
|
-
if (!
|
|
21876
|
-
const raw =
|
|
21875
|
+
if (!syncFs.existsSync(filePath)) return null;
|
|
21876
|
+
const raw = syncFs.readFileSync(filePath, "utf-8");
|
|
21877
21877
|
const parsed = JSON.parse(raw);
|
|
21878
21878
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
21879
21879
|
return parsed;
|
|
@@ -21882,8 +21882,8 @@ function safeReadJson(filePath) {
|
|
|
21882
21882
|
}
|
|
21883
21883
|
}
|
|
21884
21884
|
function safeWriteJson(filePath, data) {
|
|
21885
|
-
|
|
21886
|
-
|
|
21885
|
+
syncFs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
21886
|
+
syncFs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
21887
21887
|
}
|
|
21888
21888
|
function setDeep(obj, keys, value) {
|
|
21889
21889
|
let node = obj;
|
|
@@ -22010,7 +22010,7 @@ function decorateOpenClawProfile(userDataDir, opts) {
|
|
|
22010
22010
|
}
|
|
22011
22011
|
safeWriteJson(preferencesPath, prefs);
|
|
22012
22012
|
try {
|
|
22013
|
-
|
|
22013
|
+
syncFs.writeFileSync(decoratedMarkerPath(userDataDir), `${Date.now()}\n`, "utf-8");
|
|
22014
22014
|
} catch {}
|
|
22015
22015
|
}
|
|
22016
22016
|
function ensureProfileCleanExit(userDataDir) {
|
|
@@ -22025,7 +22025,7 @@ function ensureProfileCleanExit(userDataDir) {
|
|
|
22025
22025
|
const log$14 = createSubsystemLogger("browser").child("chrome");
|
|
22026
22026
|
function exists(filePath) {
|
|
22027
22027
|
try {
|
|
22028
|
-
return
|
|
22028
|
+
return syncFs.existsSync(filePath);
|
|
22029
22029
|
} catch {
|
|
22030
22030
|
return false;
|
|
22031
22031
|
}
|
|
@@ -22137,7 +22137,7 @@ async function launchOpenClawChrome(resolved, profile) {
|
|
|
22137
22137
|
const exe = resolveBrowserExecutable(resolved);
|
|
22138
22138
|
if (!exe) throw new Error("No supported browser found (Chrome/Brave/Edge/Chromium on macOS, Linux, or Windows).");
|
|
22139
22139
|
const userDataDir = resolveOpenClawUserDataDir(profile.name);
|
|
22140
|
-
|
|
22140
|
+
syncFs.mkdirSync(userDataDir, { recursive: true });
|
|
22141
22141
|
const needsDecorate = !isProfileDecorated(userDataDir, profile.name, (profile.color ?? "#FF4500").toUpperCase());
|
|
22142
22142
|
const spawnOnce = () => {
|
|
22143
22143
|
const args = [
|
|
@@ -22501,11 +22501,11 @@ async function movePathToTrash(targetPath) {
|
|
|
22501
22501
|
return targetPath;
|
|
22502
22502
|
} catch {
|
|
22503
22503
|
const trashDir = path.join(os.homedir(), ".Trash");
|
|
22504
|
-
|
|
22504
|
+
syncFs.mkdirSync(trashDir, { recursive: true });
|
|
22505
22505
|
const base = path.basename(targetPath);
|
|
22506
22506
|
let dest = path.join(trashDir, `${base}-${Date.now()}`);
|
|
22507
|
-
if (
|
|
22508
|
-
|
|
22507
|
+
if (syncFs.existsSync(dest)) dest = path.join(trashDir, `${base}-${Date.now()}-${generateSecureToken(6)}`);
|
|
22508
|
+
syncFs.renameSync(targetPath, dest);
|
|
22509
22509
|
return dest;
|
|
22510
22510
|
}
|
|
22511
22511
|
}
|
|
@@ -22598,7 +22598,7 @@ function createBrowserProfilesService(ctx) {
|
|
|
22598
22598
|
} catch {}
|
|
22599
22599
|
const userDataDir = resolveOpenClawUserDataDir(name);
|
|
22600
22600
|
const profileDir = path.dirname(userDataDir);
|
|
22601
|
-
if (
|
|
22601
|
+
if (syncFs.existsSync(profileDir)) {
|
|
22602
22602
|
await movePathToTrash(profileDir);
|
|
22603
22603
|
deleted = true;
|
|
22604
22604
|
}
|
|
@@ -23032,7 +23032,7 @@ function createProfileAvailability({ opts, profile, state, getProfileState, setP
|
|
|
23032
23032
|
};
|
|
23033
23033
|
const closePlaywrightBrowserConnectionForProfile = async (cdpUrl) => {
|
|
23034
23034
|
try {
|
|
23035
|
-
await (await import("./pw-ai-
|
|
23035
|
+
await (await import("./pw-ai-CoIUdns_.js")).closePlaywrightBrowserConnection(cdpUrl ? { cdpUrl } : void 0);
|
|
23036
23036
|
} catch {}
|
|
23037
23037
|
};
|
|
23038
23038
|
const reconcileProfileRuntime = async () => {
|
|
@@ -23129,7 +23129,7 @@ function createProfileAvailability({ opts, profile, state, getProfileState, setP
|
|
|
23129
23129
|
//#region src/browser/server-context.reset.ts
|
|
23130
23130
|
async function closePlaywrightBrowserConnectionForProfile(cdpUrl) {
|
|
23131
23131
|
try {
|
|
23132
|
-
await (await import("./pw-ai-
|
|
23132
|
+
await (await import("./pw-ai-CoIUdns_.js")).closePlaywrightBrowserConnection(cdpUrl ? { cdpUrl } : void 0);
|
|
23133
23133
|
} catch {}
|
|
23134
23134
|
}
|
|
23135
23135
|
function createProfileResetOps({ profile, getProfileState, stopRunningBrowser, isHttpReachable, resolveOpenClawUserDataDir }) {
|
|
@@ -23148,7 +23148,7 @@ function createProfileResetOps({ profile, getProfileState, stopRunningBrowser, i
|
|
|
23148
23148
|
if (await isHttpReachable(300) && !profileState.running) await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
|
|
23149
23149
|
if (profileState.running) await stopRunningBrowser();
|
|
23150
23150
|
await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
|
|
23151
|
-
if (!
|
|
23151
|
+
if (!syncFs.existsSync(userDataDir)) return {
|
|
23152
23152
|
moved: false,
|
|
23153
23153
|
from: userDataDir
|
|
23154
23154
|
};
|
|
@@ -23942,7 +23942,7 @@ function releaseAllLocksSync() {
|
|
|
23942
23942
|
if (typeof held.handle.close === "function") held.handle.close().catch(() => {});
|
|
23943
23943
|
} catch {}
|
|
23944
23944
|
try {
|
|
23945
|
-
|
|
23945
|
+
syncFs.rmSync(held.lockPath, { force: true });
|
|
23946
23946
|
} catch {}
|
|
23947
23947
|
HELD_LOCKS.delete(sessionFile);
|
|
23948
23948
|
}
|
|
@@ -25210,7 +25210,7 @@ var SandboxFsPathGuard = class {
|
|
|
25210
25210
|
if (guarded.reason !== "path") {
|
|
25211
25211
|
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}`);
|
|
25212
25212
|
}
|
|
25213
|
-
} else
|
|
25213
|
+
} else syncFs.closeSync(guarded.fd);
|
|
25214
25214
|
const canonicalContainerPath = await this.resolveCanonicalContainerPath({
|
|
25215
25215
|
containerPath: target.containerPath,
|
|
25216
25216
|
allowFinalSymlinkForUnlink: options.aliasPolicy?.allowFinalSymlinkForUnlink === true
|
|
@@ -25242,7 +25242,7 @@ var SandboxFsPathGuard = class {
|
|
|
25242
25242
|
}
|
|
25243
25243
|
pathIsExistingDirectory(hostPath) {
|
|
25244
25244
|
try {
|
|
25245
|
-
return
|
|
25245
|
+
return syncFs.statSync(hostPath).isDirectory();
|
|
25246
25246
|
} catch {
|
|
25247
25247
|
return false;
|
|
25248
25248
|
}
|
|
@@ -25631,9 +25631,9 @@ var SandboxFsBridgeImpl = class {
|
|
|
25631
25631
|
async readPinnedFile(target) {
|
|
25632
25632
|
const opened = await this.pathGuard.openReadableFile(target);
|
|
25633
25633
|
try {
|
|
25634
|
-
return
|
|
25634
|
+
return syncFs.readFileSync(opened.fd);
|
|
25635
25635
|
} finally {
|
|
25636
|
-
|
|
25636
|
+
syncFs.closeSync(opened.fd);
|
|
25637
25637
|
}
|
|
25638
25638
|
}
|
|
25639
25639
|
async runCheckedCommand(plan) {
|
|
@@ -26537,7 +26537,7 @@ function resolveWebCredsBackupPath(authDir) {
|
|
|
26537
26537
|
}
|
|
26538
26538
|
function hasWebCredsSync(authDir) {
|
|
26539
26539
|
try {
|
|
26540
|
-
const stats =
|
|
26540
|
+
const stats = syncFs.statSync(resolveWebCredsPath(authDir));
|
|
26541
26541
|
return stats.isFile() && stats.size > 1;
|
|
26542
26542
|
} catch {
|
|
26543
26543
|
return false;
|
|
@@ -26545,10 +26545,10 @@ function hasWebCredsSync(authDir) {
|
|
|
26545
26545
|
}
|
|
26546
26546
|
function readCredsJsonRaw(filePath) {
|
|
26547
26547
|
try {
|
|
26548
|
-
if (!
|
|
26549
|
-
const stats =
|
|
26548
|
+
if (!syncFs.existsSync(filePath)) return null;
|
|
26549
|
+
const stats = syncFs.statSync(filePath);
|
|
26550
26550
|
if (!stats.isFile() || stats.size <= 1) return null;
|
|
26551
|
-
return
|
|
26551
|
+
return syncFs.readFileSync(filePath, "utf-8");
|
|
26552
26552
|
} catch {
|
|
26553
26553
|
return null;
|
|
26554
26554
|
}
|
|
@@ -26566,9 +26566,9 @@ function maybeRestoreCredsFromBackup(authDir) {
|
|
|
26566
26566
|
const backupRaw = readCredsJsonRaw(backupPath);
|
|
26567
26567
|
if (!backupRaw) return;
|
|
26568
26568
|
JSON.parse(backupRaw);
|
|
26569
|
-
|
|
26569
|
+
syncFs.copyFileSync(backupPath, credsPath);
|
|
26570
26570
|
try {
|
|
26571
|
-
|
|
26571
|
+
syncFs.chmodSync(credsPath, 384);
|
|
26572
26572
|
} catch {}
|
|
26573
26573
|
logger.warn({ credsPath }, "restored corrupted WhatsApp creds.json from backup");
|
|
26574
26574
|
} catch {}
|
|
@@ -26624,11 +26624,11 @@ async function logoutWeb(params) {
|
|
|
26624
26624
|
function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
|
|
26625
26625
|
try {
|
|
26626
26626
|
const credsPath = resolveWebCredsPath(resolveUserPath(authDir));
|
|
26627
|
-
if (!
|
|
26627
|
+
if (!syncFs.existsSync(credsPath)) return {
|
|
26628
26628
|
e164: null,
|
|
26629
26629
|
jid: null
|
|
26630
26630
|
};
|
|
26631
|
-
const raw =
|
|
26631
|
+
const raw = syncFs.readFileSync(credsPath, "utf-8");
|
|
26632
26632
|
const jid = JSON.parse(raw)?.me?.id ?? null;
|
|
26633
26633
|
return {
|
|
26634
26634
|
e164: jid ? jidToE164(jid, { authDir }) : null,
|
|
@@ -26647,7 +26647,7 @@ function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
|
|
|
26647
26647
|
*/
|
|
26648
26648
|
function getWebAuthAgeMs(authDir = resolveDefaultWebAuthDir()) {
|
|
26649
26649
|
try {
|
|
26650
|
-
const stats =
|
|
26650
|
+
const stats = syncFs.statSync(resolveWebCredsPath(resolveUserPath(authDir)));
|
|
26651
26651
|
return Date.now() - stats.mtimeMs;
|
|
26652
26652
|
} catch {
|
|
26653
26653
|
return null;
|
|
@@ -26676,7 +26676,7 @@ function listWhatsAppAuthDirs(cfg) {
|
|
|
26676
26676
|
accountId
|
|
26677
26677
|
}).authDir);
|
|
26678
26678
|
try {
|
|
26679
|
-
const entries =
|
|
26679
|
+
const entries = syncFs.readdirSync(whatsappDir, { withFileTypes: true });
|
|
26680
26680
|
for (const entry of entries) {
|
|
26681
26681
|
if (!entry.isDirectory()) continue;
|
|
26682
26682
|
authDirs.add(path.join(whatsappDir, entry.name));
|
|
@@ -26698,7 +26698,7 @@ function resolveLegacyAuthDir() {
|
|
|
26698
26698
|
}
|
|
26699
26699
|
function legacyAuthExists(authDir) {
|
|
26700
26700
|
try {
|
|
26701
|
-
return
|
|
26701
|
+
return syncFs.existsSync(path.join(authDir, "creds.json"));
|
|
26702
26702
|
} catch {
|
|
26703
26703
|
return false;
|
|
26704
26704
|
}
|
|
@@ -27126,7 +27126,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
27126
27126
|
const accountCfg = resolveAccountCfg(accountId !== "default" ? accountId : DEFAULT_ACCOUNT_ID);
|
|
27127
27127
|
const accountTokenFile = accountCfg?.tokenFile?.trim();
|
|
27128
27128
|
if (accountTokenFile) {
|
|
27129
|
-
if (!
|
|
27129
|
+
if (!syncFs.existsSync(accountTokenFile)) {
|
|
27130
27130
|
opts.logMissingFile?.(`channels.telegram.accounts.${accountId}.tokenFile not found: ${accountTokenFile}`);
|
|
27131
27131
|
return {
|
|
27132
27132
|
token: "",
|
|
@@ -27134,7 +27134,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
27134
27134
|
};
|
|
27135
27135
|
}
|
|
27136
27136
|
try {
|
|
27137
|
-
const token =
|
|
27137
|
+
const token = syncFs.readFileSync(accountTokenFile, "utf-8").trim();
|
|
27138
27138
|
if (token) return {
|
|
27139
27139
|
token,
|
|
27140
27140
|
source: "tokenFile"
|
|
@@ -27162,7 +27162,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
27162
27162
|
const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
|
|
27163
27163
|
const tokenFile = telegramCfg?.tokenFile?.trim();
|
|
27164
27164
|
if (tokenFile) {
|
|
27165
|
-
if (!
|
|
27165
|
+
if (!syncFs.existsSync(tokenFile)) {
|
|
27166
27166
|
opts.logMissingFile?.(`channels.telegram.tokenFile not found: ${tokenFile}`);
|
|
27167
27167
|
return {
|
|
27168
27168
|
token: "",
|
|
@@ -27170,7 +27170,7 @@ function resolveTelegramToken(cfg, opts = {}) {
|
|
|
27170
27170
|
};
|
|
27171
27171
|
}
|
|
27172
27172
|
try {
|
|
27173
|
-
const token =
|
|
27173
|
+
const token = syncFs.readFileSync(tokenFile, "utf-8").trim();
|
|
27174
27174
|
if (token) return {
|
|
27175
27175
|
token,
|
|
27176
27176
|
source: "tokenFile"
|
|
@@ -27317,13 +27317,13 @@ function listEnabledTelegramAccounts(cfg) {
|
|
|
27317
27317
|
function inspectTokenFile(pathValue) {
|
|
27318
27318
|
const tokenFile = typeof pathValue === "string" ? pathValue.trim() : "";
|
|
27319
27319
|
if (!tokenFile) return null;
|
|
27320
|
-
if (!
|
|
27320
|
+
if (!syncFs.existsSync(tokenFile)) return {
|
|
27321
27321
|
token: "",
|
|
27322
27322
|
tokenSource: "tokenFile",
|
|
27323
27323
|
tokenStatus: "configured_unavailable"
|
|
27324
27324
|
};
|
|
27325
27325
|
try {
|
|
27326
|
-
const token =
|
|
27326
|
+
const token = syncFs.readFileSync(tokenFile, "utf-8").trim();
|
|
27327
27327
|
return {
|
|
27328
27328
|
token,
|
|
27329
27329
|
tokenSource: "tokenFile",
|
|
@@ -28802,14 +28802,14 @@ function resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile, a
|
|
|
28802
28802
|
function canonicalizePathForComparison$1(filePath) {
|
|
28803
28803
|
const resolved = path.resolve(filePath);
|
|
28804
28804
|
try {
|
|
28805
|
-
return
|
|
28805
|
+
return syncFs.realpathSync(resolved);
|
|
28806
28806
|
} catch {
|
|
28807
28807
|
return resolved;
|
|
28808
28808
|
}
|
|
28809
28809
|
}
|
|
28810
28810
|
function archiveFileOnDisk(filePath, reason) {
|
|
28811
28811
|
const archived = `${filePath}.${reason}.${formatSessionArchiveTimestamp()}`;
|
|
28812
|
-
|
|
28812
|
+
syncFs.renameSync(filePath, archived);
|
|
28813
28813
|
return archived;
|
|
28814
28814
|
}
|
|
28815
28815
|
/**
|
|
@@ -28825,7 +28825,7 @@ function archiveSessionTranscripts(opts) {
|
|
|
28825
28825
|
const relative = path.relative(storeDir, candidatePath);
|
|
28826
28826
|
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) continue;
|
|
28827
28827
|
}
|
|
28828
|
-
if (!
|
|
28828
|
+
if (!syncFs.existsSync(candidatePath)) continue;
|
|
28829
28829
|
try {
|
|
28830
28830
|
archived.push(archiveFileOnDisk(candidatePath, opts.reason));
|
|
28831
28831
|
} catch {}
|
|
@@ -28843,15 +28843,15 @@ async function cleanupArchivedSessionTranscripts(opts) {
|
|
|
28843
28843
|
let removed = 0;
|
|
28844
28844
|
let scanned = 0;
|
|
28845
28845
|
for (const dir of directories) {
|
|
28846
|
-
const entries = await
|
|
28846
|
+
const entries = await syncFs.promises.readdir(dir).catch(() => []);
|
|
28847
28847
|
for (const entry of entries) {
|
|
28848
28848
|
const timestamp = parseSessionArchiveTimestamp(entry, reason);
|
|
28849
28849
|
if (timestamp == null) continue;
|
|
28850
28850
|
scanned += 1;
|
|
28851
28851
|
if (now - timestamp <= opts.olderThanMs) continue;
|
|
28852
28852
|
const fullPath = path.join(dir, entry);
|
|
28853
|
-
if (!(await
|
|
28854
|
-
await
|
|
28853
|
+
if (!(await syncFs.promises.stat(fullPath).catch(() => null))?.isFile()) continue;
|
|
28854
|
+
await syncFs.promises.rm(fullPath).catch(() => void 0);
|
|
28855
28855
|
removed += 1;
|
|
28856
28856
|
}
|
|
28857
28857
|
}
|
|
@@ -28998,7 +28998,7 @@ function isCacheEnabled(ttlMs) {
|
|
|
28998
28998
|
}
|
|
28999
28999
|
function getFileStatSnapshot(filePath) {
|
|
29000
29000
|
try {
|
|
29001
|
-
const stats =
|
|
29001
|
+
const stats = syncFs.statSync(filePath);
|
|
29002
29002
|
return {
|
|
29003
29003
|
mtimeMs: stats.mtimeMs,
|
|
29004
29004
|
sizeBytes: stats.size
|
|
@@ -29016,7 +29016,7 @@ const NOOP_LOGGER = {
|
|
|
29016
29016
|
function canonicalizePathForComparison(filePath) {
|
|
29017
29017
|
const resolved = path.resolve(filePath);
|
|
29018
29018
|
try {
|
|
29019
|
-
return
|
|
29019
|
+
return syncFs.realpathSync(resolved);
|
|
29020
29020
|
} catch {
|
|
29021
29021
|
return resolved;
|
|
29022
29022
|
}
|
|
@@ -29074,12 +29074,12 @@ function resolveReferencedSessionTranscriptPaths(params) {
|
|
|
29074
29074
|
return referenced;
|
|
29075
29075
|
}
|
|
29076
29076
|
async function readSessionsDirFiles(sessionsDir) {
|
|
29077
|
-
const dirEntries = await
|
|
29077
|
+
const dirEntries = await syncFs.promises.readdir(sessionsDir, { withFileTypes: true }).catch(() => []);
|
|
29078
29078
|
const files = [];
|
|
29079
29079
|
for (const dirent of dirEntries) {
|
|
29080
29080
|
if (!dirent.isFile()) continue;
|
|
29081
29081
|
const filePath = path.join(sessionsDir, dirent.name);
|
|
29082
|
-
const stat = await
|
|
29082
|
+
const stat = await syncFs.promises.stat(filePath).catch(() => null);
|
|
29083
29083
|
if (!stat?.isFile()) continue;
|
|
29084
29084
|
files.push({
|
|
29085
29085
|
path: filePath,
|
|
@@ -29092,9 +29092,9 @@ async function readSessionsDirFiles(sessionsDir) {
|
|
|
29092
29092
|
return files;
|
|
29093
29093
|
}
|
|
29094
29094
|
async function removeFileIfExists(filePath) {
|
|
29095
|
-
const stat = await
|
|
29095
|
+
const stat = await syncFs.promises.stat(filePath).catch(() => null);
|
|
29096
29096
|
if (!stat?.isFile()) return 0;
|
|
29097
|
-
await
|
|
29097
|
+
await syncFs.promises.rm(filePath, { force: true }).catch(() => void 0);
|
|
29098
29098
|
return stat.size;
|
|
29099
29099
|
}
|
|
29100
29100
|
async function removeFileForBudget(params) {
|
|
@@ -29451,7 +29451,7 @@ function capEntryCount(store, overrideMax, opts = {}) {
|
|
|
29451
29451
|
}
|
|
29452
29452
|
async function getSessionFileSize(storePath) {
|
|
29453
29453
|
try {
|
|
29454
|
-
return (await
|
|
29454
|
+
return (await syncFs.promises.stat(storePath)).size;
|
|
29455
29455
|
} catch {
|
|
29456
29456
|
return null;
|
|
29457
29457
|
}
|
|
@@ -29468,7 +29468,7 @@ async function rotateSessionFile(storePath, overrideBytes) {
|
|
|
29468
29468
|
if (fileSize <= maxBytes) return false;
|
|
29469
29469
|
const backupPath = `${storePath}.bak.${Date.now()}`;
|
|
29470
29470
|
try {
|
|
29471
|
-
await
|
|
29471
|
+
await syncFs.promises.rename(storePath, backupPath);
|
|
29472
29472
|
log$11.info("rotated session store file", {
|
|
29473
29473
|
backupPath: path.basename(backupPath),
|
|
29474
29474
|
sizeBytes: fileSize
|
|
@@ -29479,11 +29479,11 @@ async function rotateSessionFile(storePath, overrideBytes) {
|
|
|
29479
29479
|
try {
|
|
29480
29480
|
const dir = path.dirname(storePath);
|
|
29481
29481
|
const baseName = path.basename(storePath);
|
|
29482
|
-
const backups = (await
|
|
29482
|
+
const backups = (await syncFs.promises.readdir(dir)).filter((f) => f.startsWith(`${baseName}.bak.`)).toSorted().toReversed();
|
|
29483
29483
|
const maxBackups = 3;
|
|
29484
29484
|
if (backups.length > maxBackups) {
|
|
29485
29485
|
const toDelete = backups.slice(maxBackups);
|
|
29486
|
-
for (const old of toDelete) await
|
|
29486
|
+
for (const old of toDelete) await syncFs.promises.unlink(path.join(dir, old)).catch(() => void 0);
|
|
29487
29487
|
log$11.info("cleaned up old session store backups", { deleted: toDelete.length });
|
|
29488
29488
|
}
|
|
29489
29489
|
} catch {}
|
|
@@ -29604,7 +29604,7 @@ function loadSessionStore(storePath, opts = {}) {
|
|
|
29604
29604
|
const maxReadAttempts = process.platform === "win32" ? 3 : 1;
|
|
29605
29605
|
const retryBuf = maxReadAttempts > 1 ? new Int32Array(new SharedArrayBuffer(4)) : void 0;
|
|
29606
29606
|
for (let attempt = 0; attempt < maxReadAttempts; attempt++) try {
|
|
29607
|
-
const raw =
|
|
29607
|
+
const raw = syncFs.readFileSync(storePath, "utf-8");
|
|
29608
29608
|
if (raw.length === 0 && attempt < maxReadAttempts - 1) {
|
|
29609
29609
|
Atomics.wait(retryBuf, 0, 0, 50);
|
|
29610
29610
|
continue;
|
|
@@ -29754,7 +29754,7 @@ async function saveSessionStoreUnlocked(storePath, store, opts) {
|
|
|
29754
29754
|
});
|
|
29755
29755
|
}
|
|
29756
29756
|
}
|
|
29757
|
-
await
|
|
29757
|
+
await syncFs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
29758
29758
|
const json = JSON.stringify(store, null, 2);
|
|
29759
29759
|
if (getSerializedSessionStore(storePath) === json) {
|
|
29760
29760
|
updateSessionStoreWriteCaches({
|
|
@@ -30163,8 +30163,8 @@ function resolveMirroredTranscriptText(params) {
|
|
|
30163
30163
|
return trimmed ? trimmed : null;
|
|
30164
30164
|
}
|
|
30165
30165
|
async function ensureSessionHeader(params) {
|
|
30166
|
-
if (
|
|
30167
|
-
await
|
|
30166
|
+
if (syncFs.existsSync(params.sessionFile)) return;
|
|
30167
|
+
await syncFs.promises.mkdir(path.dirname(params.sessionFile), { recursive: true });
|
|
30168
30168
|
const header = {
|
|
30169
30169
|
type: "session",
|
|
30170
30170
|
version: CURRENT_SESSION_VERSION,
|
|
@@ -30172,7 +30172,7 @@ async function ensureSessionHeader(params) {
|
|
|
30172
30172
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30173
30173
|
cwd: process.cwd()
|
|
30174
30174
|
};
|
|
30175
|
-
await
|
|
30175
|
+
await syncFs.promises.writeFile(params.sessionFile, `${JSON.stringify(header)}\n`, {
|
|
30176
30176
|
encoding: "utf-8",
|
|
30177
30177
|
mode: 384
|
|
30178
30178
|
});
|
|
@@ -30390,13 +30390,13 @@ async function ensureSandboxWorkspace(workspaceDir, seedFrom, skipBootstrap) {
|
|
|
30390
30390
|
});
|
|
30391
30391
|
if (!opened.ok) continue;
|
|
30392
30392
|
try {
|
|
30393
|
-
const content =
|
|
30393
|
+
const content = syncFs.readFileSync(opened.fd, "utf-8");
|
|
30394
30394
|
await fs.writeFile(dest, content, {
|
|
30395
30395
|
encoding: "utf-8",
|
|
30396
30396
|
flag: "wx"
|
|
30397
30397
|
});
|
|
30398
30398
|
} finally {
|
|
30399
|
-
|
|
30399
|
+
syncFs.closeSync(opened.fd);
|
|
30400
30400
|
}
|
|
30401
30401
|
} catch {}
|
|
30402
30402
|
}
|