@fased/fased 0.1.61 → 0.1.62
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/CHANGELOG.md +11 -0
- package/dist/acp/client.js +2 -2
- package/dist/acp/secret-file.js +2 -2
- package/dist/agents/agent-scope.js +2 -2
- package/dist/agents/apply-patch.js +8 -8
- package/dist/agents/auth-profiles/paths.js +2 -2
- package/dist/agents/auth-profiles/store.js +2 -2
- package/dist/agents/bash-tools.shared.js +2 -2
- package/dist/agents/cli-credentials.js +4 -4
- package/dist/agents/docs-path.js +3 -3
- package/dist/agents/embedded-pi-mcp.js +4 -4
- package/dist/agents/identity-avatar.js +3 -3
- package/dist/agents/identity-file.js +2 -2
- package/dist/agents/openai-codex-app-server.js +5 -5
- package/dist/agents/pi-embedded-subscribe.raw-stream.js +3 -3
- package/dist/agents/pi-extensions/compaction-safeguard.js +3 -3
- package/dist/agents/pi-model-discovery.js +6 -6
- package/dist/agents/pi-project-settings.js +3 -3
- package/dist/agents/sandbox/fs-bridge.js +2 -2
- package/dist/agents/session-dirs.js +4 -4
- package/dist/agents/session-write-lock.js +13 -13
- package/dist/agents/shell-utils.js +5 -5
- package/dist/agents/skills/bundled-dir.js +4 -4
- package/dist/agents/skills/local-loader.js +6 -6
- package/dist/agents/skills/plugin-skills.js +2 -2
- package/dist/agents/skills/workspace.js +13 -13
- package/dist/agents/skills-install-download.js +7 -7
- package/dist/agents/skills-install-plan.js +2 -2
- package/dist/agents/skills-install.js +2 -2
- package/dist/agents/skills-status.js +2 -2
- package/dist/agents/subagent-depth.js +2 -2
- package/dist/agents/system-prompt-params.js +2 -2
- package/dist/agents/workspace.js +22 -22
- package/dist/auto-reply/reply/agent-runner-execution.js +2 -2
- package/dist/auto-reply/reply/agent-runner.js +2 -2
- package/dist/auto-reply/reply/commands-export-session.js +7 -7
- package/dist/auto-reply/reply/post-compaction-audit.js +3 -3
- package/dist/auto-reply/reply/post-compaction-context.js +3 -3
- package/dist/auto-reply/reply/session.js +3 -3
- package/dist/auto-reply/skill-commands.js +3 -3
- package/dist/auto-reply/status.js +6 -6
- package/dist/brand.js +1 -1
- package/dist/browser/chrome.executables.js +3 -3
- package/dist/browser/chrome.js +3 -3
- package/dist/browser/chrome.profile-decoration.js +6 -6
- package/dist/browser/profiles-service.js +2 -2
- package/dist/browser/server-context.js +2 -2
- package/dist/browser/trash.js +4 -4
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/canvas-host/server.js +4 -4
- package/dist/capabilities/catalog.js +3 -3
- package/dist/channels/plugins/catalog.js +3 -3
- package/dist/cli/browser-cli-extension.js +6 -6
- package/dist/cli/command-format.js +2 -2
- package/dist/cli/cron-cli/register.cron-simple.js +2 -2
- package/dist/cli/dns-cli.js +9 -9
- package/dist/cli/gateway-cli/dev.js +5 -5
- package/dist/cli/gateway-cli/run.js +2 -2
- package/dist/cli/hooks-cli.js +5 -5
- package/dist/cli/lightweight/gateway-runtime-probe.js +2 -2
- package/dist/cli/memory-cli.js +7 -7
- package/dist/cli/nodes-media-utils.js +2 -2
- package/dist/cli/plugins-cli.js +2 -2
- package/dist/cli/secrets-cli.js +3 -3
- package/dist/cli/windows-argv.js +2 -2
- package/dist/commands/dashboard-link.js +3 -3
- package/dist/commands/doctor-install.js +5 -5
- package/dist/commands/doctor-memory-search.js +2 -2
- package/dist/commands/doctor-platform-notes.js +2 -2
- package/dist/commands/doctor-sandbox.js +2 -2
- package/dist/commands/doctor-state-integrity.js +23 -23
- package/dist/commands/doctor-workspace.js +3 -3
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/managed-up.js +2 -2
- package/dist/commands/onboard-auth.credentials.js +3 -3
- package/dist/commands/onboarding/plugin-install.js +2 -2
- package/dist/commands/sessions-cleanup.js +2 -2
- package/dist/commands/signal-install.js +6 -6
- package/dist/commands/status-all/channels.js +2 -2
- package/dist/commands/wallet.js +47 -47
- package/dist/config/cache-utils.js +2 -2
- package/dist/config/includes.js +5 -5
- package/dist/config/io.js +2 -2
- package/dist/config/paths.js +3 -3
- package/dist/config/sat-runtime-ids.js +3 -3
- package/dist/config/sessions/disk-budget.js +6 -6
- package/dist/config/sessions/paths.js +2 -2
- package/dist/config/sessions/store.js +17 -17
- package/dist/config/sessions/transcript.js +4 -4
- package/dist/config/talk.js +2 -2
- package/dist/control-ui/assets/{app-BXA4gPvN.js → app-DLil9VO1.js} +3 -3
- package/dist/control-ui/assets/{index-D2QbJhVg.js → index-DdE_NIXo.js} +3 -3
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/version.json +1 -1
- package/dist/cron/service/store.js +2 -2
- package/dist/cron/store.js +6 -6
- package/dist/daemon/systemd-system.js +5 -5
- package/dist/discord/monitor/thread-bindings.state.js +2 -2
- package/dist/extensions/sat-mining/src/sat-bond-layout.js +9 -9
- package/dist/gateway/control-ui-boot-check.js +6 -6
- package/dist/gateway/control-ui-login.js +7 -7
- package/dist/gateway/control-ui.js +9 -9
- package/dist/gateway/hooks-mapping.js +4 -4
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http.js +4 -4
- package/dist/gateway/server-methods/chat.js +3 -3
- package/dist/gateway/server-methods/sessions.js +6 -6
- package/dist/gateway/server-methods/usage.js +2 -2
- package/dist/gateway/server.impl.js +3 -3
- package/dist/gateway/session-compaction-checkpoints.js +4 -4
- package/dist/gateway/session-utils.fs.js +24 -24
- package/dist/gateway/session-utils.js +6 -6
- package/dist/hooks/bundled-dir.js +4 -4
- package/dist/hooks/gmail-setup-utils.js +6 -6
- package/dist/hooks/import-url.js +2 -2
- package/dist/hooks/loader.js +4 -4
- package/dist/hooks/workspace.js +7 -7
- package/dist/infra/archive.js +17 -17
- package/dist/infra/boundary-file-read.js +2 -2
- package/dist/infra/boundary-path.js +15 -15
- package/dist/infra/brew.js +2 -2
- package/dist/infra/control-ui-assets.js +14 -14
- package/dist/infra/device-auth-store.js +8 -8
- package/dist/infra/device-identity.js +8 -8
- package/dist/infra/dotenv.js +2 -2
- package/dist/infra/exec-approvals.js +8 -8
- package/dist/infra/exec-command-resolution.js +4 -4
- package/dist/infra/exec-safe-bin-trust.js +2 -2
- package/dist/infra/fased-root.js +5 -5
- package/dist/infra/fs-safe.js +14 -14
- package/dist/infra/gateway-lock.js +11 -11
- package/dist/infra/git-commit.js +5 -5
- package/dist/infra/git-root.js +4 -4
- package/dist/infra/hosted-runtime-artifact.js +3 -3
- package/dist/infra/is-main.js +2 -2
- package/dist/infra/json-file.js +7 -7
- package/dist/infra/managed-runtime-bootstrap.js +6 -6
- package/dist/infra/outbound/delivery-queue.js +16 -16
- package/dist/infra/path-env.js +3 -3
- package/dist/infra/ports-lsof.js +4 -4
- package/dist/infra/provider-usage.auth.js +3 -3
- package/dist/infra/safe-open-sync.js +2 -2
- package/dist/infra/session-cost-usage.js +9 -9
- package/dist/infra/shell-env.js +2 -2
- package/dist/infra/state-migrations.fs.js +6 -6
- package/dist/infra/state-migrations.js +23 -23
- package/dist/infra/tmp-fased-dir.js +6 -6
- package/dist/infra/widearea-dns.js +3 -3
- package/dist/infra/wsl.js +2 -2
- package/dist/line/accounts.js +2 -2
- package/dist/line/download.js +2 -2
- package/dist/logging/config.js +3 -3
- package/dist/logging/logger.js +7 -7
- package/dist/managed/federation.js +3 -3
- package/dist/managed/tunnel.js +3 -3
- package/dist/media/store.js +13 -13
- package/dist/media-understanding/runner.js +3 -3
- package/dist/memory/embeddings.js +2 -2
- package/dist/memory/internal.js +10 -10
- package/dist/memory/manager-sync-ops.js +7 -7
- package/dist/memory/repair-executor.js +17 -17
- package/dist/node-host/invoke-system-run-plan.js +8 -8
- package/dist/node-host/invoke.js +2 -2
- package/dist/node-host/runner.js +3 -3
- package/dist/pairing/pairing-store.js +3 -3
- package/dist/plugin-sdk/{audio-preflight-Bv0hUOWL.js → audio-preflight-Bwi2Oq03.js} +1 -1
- package/dist/plugin-sdk/channel-plugin-common.d.ts +2 -2
- package/dist/plugin-sdk/{chunk-items-Bk--NU3E.js → chunk-items-DzT4L4Ty.js} +1 -1
- package/dist/plugin-sdk/command-status.js +1 -1
- package/dist/plugin-sdk/{config-schema-CGW6J3Pv.js → config-schema-BrkmtFxB.js} +7 -7
- package/dist/plugin-sdk/device-pair.d.ts +1 -1
- package/dist/plugin-sdk/discord.d.ts +4 -4
- package/dist/plugin-sdk/index.d.ts +17 -17
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{monitor-B9Cmt_Je.js → monitor-M_ta2lMc.js} +3 -3
- package/dist/plugin-sdk/{monitor-B71iwAgC.js → monitor-wYVncM9w.js} +3 -3
- package/dist/plugin-sdk/{openresponses-http-Du4GMmwo.js → openresponses-http-B2GmeSt4.js} +1 -1
- package/dist/plugin-sdk/{pairing-message-BMkkS038.d.ts → pairing-message-B3bHYGaw.d.ts} +1 -1
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +1 -1
- package/dist/plugin-sdk/sat-runtime.d.ts +2 -2
- package/dist/plugin-sdk/sat-runtime.js +1 -1
- package/dist/plugin-sdk/{slack-D_bbE6Yd.js → slack-CxE1mfzj.js} +3 -3
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/{sticker-cache-Dqo9nRhi.js → sticker-cache-CGzGWu00.js} +2 -2
- package/dist/plugin-sdk/{telegram-actions-Cnag7JTH.js → telegram-actions-DaEcYQ8r.js} +2 -2
- package/dist/plugin-sdk/telegram.d.ts +4 -4
- package/dist/plugin-sdk/{tmp-fased-dir-BdFQvrvw.d.ts → tmp-fased-dir-CS6zsYEE.d.ts} +1 -1
- package/dist/plugin-sdk/{types-BYDL6dQj.d.ts → types-DFAW-n1J.d.ts} +1 -1
- package/dist/plugin-sdk/{types-CLIvQaVg.d.ts → types-vcJrC_uv.d.ts} +1 -1
- package/dist/plugin-sdk/{web-BInKQkc4.js → web-CInY-lCv.js} +1 -1
- package/dist/plugin-sdk/whatsapp.d.ts +11 -11
- package/dist/plugin-sdk/{zod-schema.providers-core-CIzCjXH9.d.ts → zod-schema.providers-core-BEbNizPe.d.ts} +61 -61
- package/dist/plugins/bundled-dir.js +3 -3
- package/dist/plugins/discovery.js +11 -11
- package/dist/plugins/loader.js +13 -13
- package/dist/plugins/manifest-registry.js +2 -2
- package/dist/plugins/manifest.js +4 -4
- package/dist/plugins/path-safety.js +3 -3
- package/dist/plugins/status-cache.js +9 -9
- package/dist/plugins/update.js +3 -3
- package/dist/plugins/web-search-install-catalog.js +3 -3
- package/dist/secrets/apply.js +16 -16
- package/dist/secrets/audit.js +11 -11
- package/dist/secrets/shared.js +9 -9
- package/dist/security/scan-paths.js +2 -2
- package/dist/shared/config-eval.js +2 -2
- package/dist/shared/pid-alive.js +2 -2
- package/dist/tasks/standing-orders.js +5 -5
- package/dist/tasks/task-flow-registry.js +5 -5
- package/dist/tasks/task-registry.js +5 -5
- package/dist/tasks/workflow-definitions.js +6 -6
- package/dist/telegram/token.js +5 -5
- package/dist/utils.js +5 -5
- package/dist/wallet/local-socket-signer-broker.js +16 -16
- package/dist/wallet/providers/embedded-keystore-adapter.js +5 -5
- package/dist/wallet/providers/local-socket-signer-adapter.js +2 -2
- package/dist/wallet/wallet-approval-auth.js +5 -5
- package/dist/wallet/wallet-audit-log.js +5 -5
- package/dist/wallet/wallet-custody.js +21 -21
- package/dist/wallet/wallet-inbound-events.js +5 -5
- package/dist/wallet/wallet-observability.js +5 -5
- package/dist/wallet/wallet-policy.js +9 -9
- package/dist/wallet/wallet-provider-registry.js +7 -7
- package/dist/wallet/wallet-runtime-config.js +3 -3
- package/dist/wallet/wallet-secrets-store.js +22 -22
- package/dist/wallet/wallet-send-approvals.js +5 -5
- package/dist/wallet/wallet-settlement-links.js +5 -5
- package/dist/web/accounts.js +3 -3
- package/dist/web/auth-store.js +18 -18
- package/dist/web/session.js +4 -4
- package/dist/wizard/host-security-capability.js +2 -2
- package/dist/wizard/onboarding.host-security.js +7 -7
- package/dist/wizard/onboarding.js +11 -28
- package/dist/wizard/onboarding.wallet.js +132 -85
- package/extensions/acpx/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/fased-federation/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +6 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +2 -2
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +6 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +6 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/sat-mining/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +6 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +6 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +6 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +6 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +2 -1
- package/scripts/install-fased-signerd.sh +142 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ This changelog starts with the public Fased Agent release line. Required
|
|
|
4
4
|
third-party and copied-code notices are kept in [LICENSE](./LICENSE) and
|
|
5
5
|
[THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
|
|
6
6
|
|
|
7
|
+
## 0.1.62
|
|
8
|
+
|
|
9
|
+
- Install a version-matched, checksum-verified local wallet signer automatically
|
|
10
|
+
when first-time wallet setup selects the local socket signer path; normal
|
|
11
|
+
installs no longer require Go.
|
|
12
|
+
- Show automatic signer installation in both Local and Hosting QuickStart while
|
|
13
|
+
keeping the redundant wallet-backend prompt hidden in the hosting profile.
|
|
14
|
+
- Publish static Linux and macOS signer assets for x64 and arm64 with release
|
|
15
|
+
checksums, module-relative installer resolution, and clear WSL2 guidance for
|
|
16
|
+
Windows users.
|
|
17
|
+
|
|
7
18
|
## 0.1.61
|
|
8
19
|
|
|
9
20
|
- Harden local Docker deployments with loopback-only published ports, dropped
|
package/dist/acp/client.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isKnownCoreToolId } from "../agents/tool-catalog.js";
|
|
|
2
2
|
import { DANGEROUS_ACP_TOOLS } from "../security/dangerous-tools.js";
|
|
3
3
|
import { ensureFasedAgentCliOnPath } from "../infra/path-env.js";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import
|
|
5
|
+
import syncFs from "node:fs";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
@@ -269,7 +269,7 @@ function resolveSelfEntryPath() {
|
|
|
269
269
|
try {
|
|
270
270
|
const here = fileURLToPath(import.meta.url);
|
|
271
271
|
const candidate = path.resolve(path.dirname(here), "..", "entry.js");
|
|
272
|
-
if (
|
|
272
|
+
if (syncFs.existsSync(candidate)) {
|
|
273
273
|
return candidate;
|
|
274
274
|
}
|
|
275
275
|
} catch {}
|
package/dist/acp/secret-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveUserPath } from "../utils.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/acp/secret-file.ts
|
|
5
5
|
function readSecretFromFile(filePath, label) {
|
|
@@ -9,7 +9,7 @@ function readSecretFromFile(filePath, label) {
|
|
|
9
9
|
}
|
|
10
10
|
let raw = "";
|
|
11
11
|
try {
|
|
12
|
-
raw =
|
|
12
|
+
raw = syncFs.readFileSync(resolvedPath, "utf8");
|
|
13
13
|
} catch (err) {
|
|
14
14
|
throw new Error(`Failed to read ${label} file at ${resolvedPath}: ${String(err)}`, { cause: err });
|
|
15
15
|
}
|
|
@@ -6,7 +6,7 @@ import { parseAgentSessionKey } from "../sessions/session-key-utils.js";
|
|
|
6
6
|
import { DEFAULT_AGENT_ID, normalizeAgentId, resolveAgentIdFromSessionKey } from "../routing/session-key.js";
|
|
7
7
|
import { resolveEffectiveAgentSkillFilter } from "./skills/agent-filter.js";
|
|
8
8
|
import { resolveDefaultAgentWorkspaceDir } from "./workspace.js";
|
|
9
|
-
import
|
|
9
|
+
import syncFs from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
|
|
12
12
|
//#region src/agents/agent-scope.ts
|
|
@@ -245,7 +245,7 @@ function normalizePathForComparison(input) {
|
|
|
245
245
|
const resolved = path.resolve(stripNullBytes(resolveUserPath(input)));
|
|
246
246
|
let normalized = resolved;
|
|
247
247
|
try {
|
|
248
|
-
normalized =
|
|
248
|
+
normalized = syncFs.realpathSync.native(resolved);
|
|
249
249
|
} catch {}
|
|
250
250
|
if (process.platform === "win32") {
|
|
251
251
|
return normalized.toLowerCase();
|
|
@@ -3,9 +3,9 @@ import { PATH_ALIAS_POLICIES } from "../infra/path-alias-guards.js";
|
|
|
3
3
|
import { writeFileWithinRoot } from "../infra/fs-safe.js";
|
|
4
4
|
import { applyUpdateHunk } from "./apply-patch-update.js";
|
|
5
5
|
import { assertSandboxPath, resolveSandboxInputPath } from "./sandbox-paths.js";
|
|
6
|
-
import
|
|
6
|
+
import syncFs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
|
-
import fs
|
|
8
|
+
import fs from "node:fs/promises";
|
|
9
9
|
import { Type } from "@sinclair/typebox";
|
|
10
10
|
|
|
11
11
|
//#region src/agents/apply-patch.ts
|
|
@@ -159,7 +159,7 @@ function resolvePatchFileOps(options) {
|
|
|
159
159
|
return {
|
|
160
160
|
readFile: async (filePath) => {
|
|
161
161
|
if (!workspaceOnly) {
|
|
162
|
-
return await fs
|
|
162
|
+
return await fs.readFile(filePath, "utf8");
|
|
163
163
|
}
|
|
164
164
|
const opened = await openBoundaryFile({
|
|
165
165
|
absolutePath: filePath,
|
|
@@ -168,14 +168,14 @@ function resolvePatchFileOps(options) {
|
|
|
168
168
|
});
|
|
169
169
|
assertBoundaryRead(opened, filePath);
|
|
170
170
|
try {
|
|
171
|
-
return
|
|
171
|
+
return syncFs.readFileSync(opened.fd, "utf8");
|
|
172
172
|
} finally {
|
|
173
|
-
|
|
173
|
+
syncFs.closeSync(opened.fd);
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
176
|
writeFile: async (filePath, content) => {
|
|
177
177
|
if (!workspaceOnly) {
|
|
178
|
-
await fs
|
|
178
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
const relative = toRelativeWorkspacePath(options.cwd, filePath);
|
|
@@ -186,8 +186,8 @@ function resolvePatchFileOps(options) {
|
|
|
186
186
|
encoding: "utf8"
|
|
187
187
|
});
|
|
188
188
|
},
|
|
189
|
-
remove: (filePath) => fs
|
|
190
|
-
mkdirp: (dir) => fs
|
|
189
|
+
remove: (filePath) => fs.rm(filePath),
|
|
190
|
+
mkdirp: (dir) => fs.mkdir(dir, { recursive: true }).then(() => {})
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
async function ensureDir(filePath, ops) {
|
|
@@ -2,7 +2,7 @@ import { resolveUserPath } from "../../utils.js";
|
|
|
2
2
|
import { saveJsonFile } from "../../infra/json-file.js";
|
|
3
3
|
import { AUTH_PROFILE_FILENAME, AUTH_STORE_VERSION, LEGACY_AUTH_FILENAME } from "./constants.js";
|
|
4
4
|
import { resolveFasedAgentAgentDir } from "../agent-paths.js";
|
|
5
|
-
import
|
|
5
|
+
import syncFs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
|
|
8
8
|
//#region src/agents/auth-profiles/paths.ts
|
|
@@ -19,7 +19,7 @@ function resolveAuthStorePathForDisplay(agentDir) {
|
|
|
19
19
|
return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
|
|
20
20
|
}
|
|
21
21
|
function ensureAuthStoreFile(pathname) {
|
|
22
|
-
if (
|
|
22
|
+
if (syncFs.existsSync(pathname)) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
const payload = {
|
|
@@ -5,7 +5,7 @@ import { withFileLock } from "../../plugin-sdk/file-lock.js";
|
|
|
5
5
|
import "../../infra/file-lock.js";
|
|
6
6
|
import { syncExternalCliCredentials } from "./external-cli-sync.js";
|
|
7
7
|
import { ensureAuthStoreFile, resolveAuthStorePath, resolveLegacyAuthStorePath } from "./paths.js";
|
|
8
|
-
import
|
|
8
|
+
import syncFs from "node:fs";
|
|
9
9
|
|
|
10
10
|
//#region src/agents/auth-profiles/store.ts
|
|
11
11
|
const AUTH_PROFILE_TYPES = new Set([
|
|
@@ -361,7 +361,7 @@ function loadAuthProfileStoreForAgent(agentDir, options) {
|
|
|
361
361
|
if (shouldWrite && legacy !== null) {
|
|
362
362
|
const legacyPath = resolveLegacyAuthStorePath(agentDir);
|
|
363
363
|
try {
|
|
364
|
-
|
|
364
|
+
syncFs.unlinkSync(legacyPath);
|
|
365
365
|
} catch (err) {
|
|
366
366
|
if (err?.code !== "ENOENT") {
|
|
367
367
|
log.warn("failed to delete legacy auth.json after migration", {
|
|
@@ -3,7 +3,7 @@ import { assertSandboxPath } from "./sandbox-paths.js";
|
|
|
3
3
|
import { existsSync, statSync } from "node:fs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import fs
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
7
|
|
|
8
8
|
//#region src/agents/bash-tools.shared.ts
|
|
9
9
|
const CHUNK_LIMIT = 8 * 1024;
|
|
@@ -67,7 +67,7 @@ async function resolveSandboxWorkdir(params) {
|
|
|
67
67
|
cwd: process.cwd(),
|
|
68
68
|
root: params.sandbox.workspaceDir
|
|
69
69
|
});
|
|
70
|
-
const stats = await fs
|
|
70
|
+
const stats = await fs.stat(resolved.resolved);
|
|
71
71
|
if (!stats.isDirectory()) {
|
|
72
72
|
throw new Error("workdir is not a directory");
|
|
73
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveUserPath } from "../utils.js";
|
|
2
2
|
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
3
3
|
import { loadJsonFile, saveJsonFile } from "../infra/json-file.js";
|
|
4
|
-
import
|
|
4
|
+
import syncFs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { execFileSync, execSync } from "node:child_process";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
@@ -61,7 +61,7 @@ function resolveCodexHomePath() {
|
|
|
61
61
|
const configured = process.env.CODEX_HOME;
|
|
62
62
|
const home = configured ? resolveUserPath(configured) : resolveUserPath("~/.codex");
|
|
63
63
|
try {
|
|
64
|
-
return
|
|
64
|
+
return syncFs.realpathSync.native(home);
|
|
65
65
|
} catch {
|
|
66
66
|
return home;
|
|
67
67
|
}
|
|
@@ -264,7 +264,7 @@ function writeClaudeCliKeychainCredentials(newCredentials, options) {
|
|
|
264
264
|
}
|
|
265
265
|
function writeClaudeCliFileCredentials(newCredentials, options) {
|
|
266
266
|
const credPath = resolveClaudeCliCredentialsPath(options?.homeDir);
|
|
267
|
-
if (!
|
|
267
|
+
if (!syncFs.existsSync(credPath)) {
|
|
268
268
|
return false;
|
|
269
269
|
}
|
|
270
270
|
try {
|
|
@@ -331,7 +331,7 @@ function readCodexCliCredentials(options) {
|
|
|
331
331
|
}
|
|
332
332
|
let expires;
|
|
333
333
|
try {
|
|
334
|
-
const stat =
|
|
334
|
+
const stat = syncFs.statSync(authPath);
|
|
335
335
|
expires = stat.mtimeMs + 60 * 60 * 1e3;
|
|
336
336
|
} catch {
|
|
337
337
|
expires = Date.now() + 60 * 60 * 1e3;
|
package/dist/agents/docs-path.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveFasedAgentPackageRoot } from "../infra/fased-root.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
//#region src/agents/docs-path.ts
|
|
@@ -7,7 +7,7 @@ async function resolveFasedAgentDocsPath(params) {
|
|
|
7
7
|
const workspaceDir = params.workspaceDir?.trim();
|
|
8
8
|
if (workspaceDir) {
|
|
9
9
|
const workspaceDocs = path.join(workspaceDir, "docs");
|
|
10
|
-
if (
|
|
10
|
+
if (syncFs.existsSync(workspaceDocs)) {
|
|
11
11
|
return workspaceDocs;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -20,7 +20,7 @@ async function resolveFasedAgentDocsPath(params) {
|
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
const packageDocs = path.join(packageRoot, "docs");
|
|
23
|
-
return
|
|
23
|
+
return syncFs.existsSync(packageDocs) ? packageDocs : null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { STATE_DIR } from "../config/paths.js";
|
|
2
2
|
import { isRecord, resolveUserPath } from "../utils.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/agents/embedded-pi-mcp.ts
|
|
@@ -66,10 +66,10 @@ function readBundleMcpFile(params) {
|
|
|
66
66
|
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
67
67
|
return {};
|
|
68
68
|
}
|
|
69
|
-
if (!
|
|
69
|
+
if (!syncFs.existsSync(filePath)) {
|
|
70
70
|
return {};
|
|
71
71
|
}
|
|
72
|
-
const raw = JSON.parse(
|
|
72
|
+
const raw = JSON.parse(syncFs.readFileSync(filePath, "utf-8"));
|
|
73
73
|
const servers = extractMcpServerMap(raw);
|
|
74
74
|
const baseDir = path.dirname(filePath);
|
|
75
75
|
return Object.fromEntries(Object.entries(servers).map(([serverName, server]) => [serverName, absolutizeBundleMcpServer({
|
|
@@ -99,7 +99,7 @@ function loadEnabledBundleMcpConfig(params) {
|
|
|
99
99
|
cfg: params.cfg,
|
|
100
100
|
pluginId
|
|
101
101
|
})) {
|
|
102
|
-
if (!
|
|
102
|
+
if (!syncFs.existsSync(rootDir)) {
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
105
|
for (const fileName of BUNDLE_MCP_FILENAMES) {
|
|
@@ -3,7 +3,7 @@ import { resolveAgentWorkspaceDir } from "./agent-scope.js";
|
|
|
3
3
|
import { AVATAR_MAX_BYTES, isAvatarDataUrl, isAvatarHttpUrl, isPathWithinRoot, isSupportedLocalAvatarExtension } from "../shared/avatar-policy.js";
|
|
4
4
|
import { resolveAgentIdentity } from "./identity.js";
|
|
5
5
|
import { loadAgentIdentityFromWorkspace } from "./identity-file.js";
|
|
6
|
-
import
|
|
6
|
+
import syncFs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
9
|
//#region src/agents/identity-avatar.ts
|
|
@@ -28,7 +28,7 @@ function resolveAvatarSource(cfg, agentId, opts) {
|
|
|
28
28
|
}
|
|
29
29
|
function resolveExistingPath(value) {
|
|
30
30
|
try {
|
|
31
|
-
return
|
|
31
|
+
return syncFs.realpathSync(value);
|
|
32
32
|
} catch {
|
|
33
33
|
return path.resolve(value);
|
|
34
34
|
}
|
|
@@ -51,7 +51,7 @@ function resolveLocalAvatarPath(params) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
-
const stat =
|
|
54
|
+
const stat = syncFs.statSync(realPath);
|
|
55
55
|
if (!stat.isFile()) {
|
|
56
56
|
return {
|
|
57
57
|
ok: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_IDENTITY_FILENAME } from "./workspace.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
//#region src/agents/identity-file.ts
|
|
@@ -67,7 +67,7 @@ function identityHasValues(identity) {
|
|
|
67
67
|
}
|
|
68
68
|
function loadIdentityFromFile(identityPath) {
|
|
69
69
|
try {
|
|
70
|
-
const content =
|
|
70
|
+
const content = syncFs.readFileSync(identityPath, "utf-8");
|
|
71
71
|
const parsed = parseIdentityMarkdown(content);
|
|
72
72
|
if (!identityHasValues(parsed)) {
|
|
73
73
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveFasedAgentPackageRootSync } from "../infra/fased-root.js";
|
|
2
2
|
import { resolvePluginInstallDir } from "../plugins/install.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
@@ -60,17 +60,17 @@ function resolveOpenAICodexExecutable() {
|
|
|
60
60
|
const explicitlyConfigured = process.env.FASED_CODEX_BIN?.trim();
|
|
61
61
|
for (const candidate of codexExecutableCandidates()) {
|
|
62
62
|
try {
|
|
63
|
-
if (!
|
|
63
|
+
if (!syncFs.statSync(candidate).isFile()) {
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
if (explicitlyConfigured && candidate === explicitlyConfigured) {
|
|
67
67
|
return candidate;
|
|
68
68
|
}
|
|
69
|
-
const resolved =
|
|
69
|
+
const resolved = syncFs.realpathSync(candidate);
|
|
70
70
|
let current = path.dirname(resolved);
|
|
71
71
|
for (let depth = 0; depth < 6; depth += 1) {
|
|
72
72
|
try {
|
|
73
|
-
const parsed = JSON.parse(
|
|
73
|
+
const parsed = JSON.parse(syncFs.readFileSync(path.join(current, "package.json"), "utf8"));
|
|
74
74
|
if (parsed.name === "@openai/codex") {
|
|
75
75
|
if (parsed.version === OPENAI_CODEX_APP_SERVER_VERSION) {
|
|
76
76
|
return candidate;
|
|
@@ -90,7 +90,7 @@ function resolveOpenAICodexExecutable() {
|
|
|
90
90
|
}
|
|
91
91
|
function managedCodexHome() {
|
|
92
92
|
const directory = path.join(stateDir(), "runtime", "openai-codex");
|
|
93
|
-
|
|
93
|
+
syncFs.mkdirSync(directory, {
|
|
94
94
|
recursive: true,
|
|
95
95
|
mode: 448
|
|
96
96
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { isTruthyEnvValue } from "../infra/env.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/agents/pi-embedded-subscribe.raw-stream.ts
|
|
@@ -14,11 +14,11 @@ function appendRawStream(payload) {
|
|
|
14
14
|
if (!rawStreamReady) {
|
|
15
15
|
rawStreamReady = true;
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
syncFs.mkdirSync(path.dirname(RAW_STREAM_PATH), { recursive: true });
|
|
18
18
|
} catch {}
|
|
19
19
|
}
|
|
20
20
|
try {
|
|
21
|
-
void
|
|
21
|
+
void syncFs.promises.appendFile(RAW_STREAM_PATH, `${JSON.stringify(payload)}\n`);
|
|
22
22
|
} catch {}
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -3,7 +3,7 @@ import { getCompactionSafeguardRuntime } from "./compaction-safeguard-runtime.js
|
|
|
3
3
|
import { extractSections } from "../../auto-reply/reply/post-compaction-context.js";
|
|
4
4
|
import { BASE_CHUNK_RATIO, MIN_CHUNK_RATIO, SAFETY_MARGIN, SUMMARIZATION_OVERHEAD_TOKENS, computeAdaptiveChunkRatio, estimateMessagesTokens, isOversizedForSummary, pruneHistoryForContextShare, resolveContextWindowTokens, summarizeInStages } from "../compaction.js";
|
|
5
5
|
import { collectTextContentBlocks } from "../content-blocks.js";
|
|
6
|
-
import
|
|
6
|
+
import syncFs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
9
|
//#region src/agents/pi-extensions/compaction-safeguard.ts
|
|
@@ -122,10 +122,10 @@ async function readWorkspaceContextForSummary() {
|
|
|
122
122
|
const workspaceDir = process.cwd();
|
|
123
123
|
const agentsPath = path.join(workspaceDir, "AGENTS.md");
|
|
124
124
|
try {
|
|
125
|
-
if (!
|
|
125
|
+
if (!syncFs.existsSync(agentsPath)) {
|
|
126
126
|
return "";
|
|
127
127
|
}
|
|
128
|
-
const content = await
|
|
128
|
+
const content = await syncFs.promises.readFile(agentsPath, "utf-8");
|
|
129
129
|
const sections = extractSections(content, ["Session Startup", "Red Lines"]);
|
|
130
130
|
if (sections.length === 0) {
|
|
131
131
|
return "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureAuthProfileStore } from "./auth-profiles/store.js";
|
|
2
2
|
import "./auth-profiles.js";
|
|
3
3
|
import { resolvePiCredentialMapFromStore } from "./pi-auth-credentials.js";
|
|
4
|
-
import
|
|
4
|
+
import syncFs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import * as PiCodingAgent from "@mariozechner/pi-coding-agent";
|
|
7
7
|
|
|
@@ -25,12 +25,12 @@ function scrubLegacyStaticAuthJsonEntries(pathname) {
|
|
|
25
25
|
if (process.env.FASED_AUTH_STORE_READONLY === "1") {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
if (!
|
|
28
|
+
if (!syncFs.existsSync(pathname)) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
let parsed;
|
|
32
32
|
try {
|
|
33
|
-
parsed = JSON.parse(
|
|
33
|
+
parsed = JSON.parse(syncFs.readFileSync(pathname, "utf8"));
|
|
34
34
|
} catch {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -52,11 +52,11 @@ function scrubLegacyStaticAuthJsonEntries(pathname) {
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
if (Object.keys(parsed).length === 0) {
|
|
55
|
-
|
|
55
|
+
syncFs.rmSync(pathname, { force: true });
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
syncFs.writeFileSync(pathname, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
|
|
59
|
+
syncFs.chmodSync(pathname, 384);
|
|
60
60
|
}
|
|
61
61
|
function createAuthStorage(AuthStorageLike, path, creds) {
|
|
62
62
|
const withInMemory = AuthStorageLike;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyMergePatch } from "../config/merge-patch.js";
|
|
2
2
|
import { applyPiCompactionSettingsFromConfig } from "./pi-settings.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { SettingsManager } from "@mariozechner/pi-coding-agent";
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ function buildEmbeddedPiSettingsSnapshot(params) {
|
|
|
28
28
|
}
|
|
29
29
|
function readJsonFile(filePath) {
|
|
30
30
|
try {
|
|
31
|
-
const raw =
|
|
31
|
+
const raw = syncFs.readFileSync(filePath, "utf8");
|
|
32
32
|
const parsed = JSON.parse(raw);
|
|
33
33
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
34
34
|
} catch {
|
|
@@ -49,7 +49,7 @@ function loadEnabledBundlePiSettingsSnapshot(params) {
|
|
|
49
49
|
const servers = mcp.mcpServers && typeof mcp.mcpServers === "object" && !Array.isArray(mcp.mcpServers) ? mcp.mcpServers : undefined;
|
|
50
50
|
if (servers) {
|
|
51
51
|
const resolvedServers = {};
|
|
52
|
-
const resolvedRoot =
|
|
52
|
+
const resolvedRoot = syncFs.realpathSync.native?.(pluginRoot) ?? syncFs.realpathSync(pluginRoot);
|
|
53
53
|
for (const [name, server] of Object.entries(servers)) {
|
|
54
54
|
if (!server || typeof server !== "object" || Array.isArray(server)) {
|
|
55
55
|
resolvedServers[name] = server;
|
|
@@ -3,7 +3,7 @@ import { PATH_ALIAS_POLICIES } from "../../infra/path-alias-guards.js";
|
|
|
3
3
|
import { execDockerRaw } from "./docker.js";
|
|
4
4
|
import { isPathInsideContainerRoot, normalizeContainerPath } from "./path-utils.js";
|
|
5
5
|
import { buildSandboxFsMounts, resolveSandboxFsPathWithMounts } from "./fs-paths.js";
|
|
6
|
-
import
|
|
6
|
+
import syncFs from "node:fs";
|
|
7
7
|
|
|
8
8
|
//#region src/agents/sandbox/fs-bridge.ts
|
|
9
9
|
function createSandboxFsBridge(params) {
|
|
@@ -160,7 +160,7 @@ var SandboxFsBridgeImpl = class {
|
|
|
160
160
|
throw guarded.error instanceof Error ? guarded.error : new Error(`Sandbox boundary checks failed; cannot ${options.action}: ${target.containerPath}`);
|
|
161
161
|
}
|
|
162
162
|
} else {
|
|
163
|
-
|
|
163
|
+
syncFs.closeSync(guarded.fd);
|
|
164
164
|
}
|
|
165
165
|
const canonicalContainerPath = await this.resolveCanonicalContainerPath({
|
|
166
166
|
containerPath: target.containerPath,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import fs
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
4
|
|
|
5
5
|
//#region src/agents/session-dirs.ts
|
|
6
6
|
function mapAgentSessionDirs(agentsDir, entries) {
|
|
@@ -9,7 +9,7 @@ function mapAgentSessionDirs(agentsDir, entries) {
|
|
|
9
9
|
async function resolveAgentSessionDirsFromAgentsDir(agentsDir) {
|
|
10
10
|
let entries = [];
|
|
11
11
|
try {
|
|
12
|
-
entries = await fs
|
|
12
|
+
entries = await fs.readdir(agentsDir, { withFileTypes: true });
|
|
13
13
|
} catch (err) {
|
|
14
14
|
const code = err.code;
|
|
15
15
|
if (code === "ENOENT") {
|
|
@@ -22,7 +22,7 @@ async function resolveAgentSessionDirsFromAgentsDir(agentsDir) {
|
|
|
22
22
|
function resolveAgentSessionDirsFromAgentsDirSync(agentsDir) {
|
|
23
23
|
let entries = [];
|
|
24
24
|
try {
|
|
25
|
-
entries =
|
|
25
|
+
entries = syncFs.readdirSync(agentsDir, { withFileTypes: true });
|
|
26
26
|
} catch (err) {
|
|
27
27
|
const code = err.code;
|
|
28
28
|
if (code === "ENOENT") {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isPidAlive } from "../shared/pid-alive.js";
|
|
2
2
|
import { resolveProcessScopedMap } from "../shared/process-scoped-map.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import fs
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
6
|
|
|
7
7
|
//#region src/agents/session-write-lock.ts
|
|
8
8
|
const CLEANUP_SIGNALS = [
|
|
@@ -84,7 +84,7 @@ async function releaseHeldLock(normalizedSessionFile, held, opts = {}) {
|
|
|
84
84
|
await held.handle.close();
|
|
85
85
|
} catch {}
|
|
86
86
|
try {
|
|
87
|
-
await fs
|
|
87
|
+
await fs.rm(held.lockPath, { force: true });
|
|
88
88
|
} catch {}
|
|
89
89
|
})();
|
|
90
90
|
try {
|
|
@@ -106,7 +106,7 @@ function releaseAllLocksSync() {
|
|
|
106
106
|
}
|
|
107
107
|
} catch {}
|
|
108
108
|
try {
|
|
109
|
-
|
|
109
|
+
syncFs.rmSync(held.lockPath, { force: true });
|
|
110
110
|
} catch {}
|
|
111
111
|
HELD_LOCKS.delete(sessionFile);
|
|
112
112
|
}
|
|
@@ -175,7 +175,7 @@ function registerCleanupHandlers() {
|
|
|
175
175
|
}
|
|
176
176
|
async function readLockPayload(lockPath) {
|
|
177
177
|
try {
|
|
178
|
-
const raw = await fs
|
|
178
|
+
const raw = await fs.readFile(lockPath, "utf8");
|
|
179
179
|
const parsed = JSON.parse(raw);
|
|
180
180
|
const payload = {};
|
|
181
181
|
if (typeof parsed.pid === "number") {
|
|
@@ -226,7 +226,7 @@ async function shouldReclaimContendedLockFile(lockPath, details, staleMs, nowMs)
|
|
|
226
226
|
return true;
|
|
227
227
|
}
|
|
228
228
|
try {
|
|
229
|
-
const stat = await fs
|
|
229
|
+
const stat = await fs.stat(lockPath);
|
|
230
230
|
const ageMs = Math.max(0, nowMs - stat.mtimeMs);
|
|
231
231
|
return ageMs > staleMs;
|
|
232
232
|
} catch (error) {
|
|
@@ -241,7 +241,7 @@ async function cleanStaleLockFiles(params) {
|
|
|
241
241
|
const nowMs = params.nowMs ?? Date.now();
|
|
242
242
|
let entries = [];
|
|
243
243
|
try {
|
|
244
|
-
entries = await fs
|
|
244
|
+
entries = await fs.readdir(sessionsDir, { withFileTypes: true });
|
|
245
245
|
} catch (err) {
|
|
246
246
|
const code = err.code;
|
|
247
247
|
if (code === "ENOENT") {
|
|
@@ -265,7 +265,7 @@ async function cleanStaleLockFiles(params) {
|
|
|
265
265
|
removed: false
|
|
266
266
|
};
|
|
267
267
|
if (lockInfo.stale && removeStale) {
|
|
268
|
-
await fs
|
|
268
|
+
await fs.rm(lockPath, { force: true });
|
|
269
269
|
lockInfo.removed = true;
|
|
270
270
|
cleaned.push(lockInfo);
|
|
271
271
|
params.log?.warn?.(`removed stale session lock: ${lockPath} (${lockInfo.staleReasons.join(", ") || "unknown"})`);
|
|
@@ -284,10 +284,10 @@ async function acquireSessionWriteLock(params) {
|
|
|
284
284
|
const maxHoldMs = resolvePositiveMs(params.maxHoldMs, DEFAULT_MAX_HOLD_MS);
|
|
285
285
|
const sessionFile = path.resolve(params.sessionFile);
|
|
286
286
|
const sessionDir = path.dirname(sessionFile);
|
|
287
|
-
await fs
|
|
287
|
+
await fs.mkdir(sessionDir, { recursive: true });
|
|
288
288
|
let normalizedDir = sessionDir;
|
|
289
289
|
try {
|
|
290
|
-
normalizedDir = await fs
|
|
290
|
+
normalizedDir = await fs.realpath(sessionDir);
|
|
291
291
|
} catch {}
|
|
292
292
|
const normalizedSessionFile = path.join(normalizedDir, path.basename(sessionFile));
|
|
293
293
|
const lockPath = `${normalizedSessionFile}.lock`;
|
|
@@ -305,7 +305,7 @@ async function acquireSessionWriteLock(params) {
|
|
|
305
305
|
attempt += 1;
|
|
306
306
|
let handle = null;
|
|
307
307
|
try {
|
|
308
|
-
handle = await fs
|
|
308
|
+
handle = await fs.open(lockPath, "wx");
|
|
309
309
|
const createdAt = new Date().toISOString();
|
|
310
310
|
await handle.writeFile(JSON.stringify({
|
|
311
311
|
pid: process.pid,
|
|
@@ -328,7 +328,7 @@ async function acquireSessionWriteLock(params) {
|
|
|
328
328
|
await handle.close();
|
|
329
329
|
} catch {}
|
|
330
330
|
try {
|
|
331
|
-
await fs
|
|
331
|
+
await fs.rm(lockPath, { force: true });
|
|
332
332
|
} catch {}
|
|
333
333
|
}
|
|
334
334
|
const code = err.code;
|
|
@@ -339,7 +339,7 @@ async function acquireSessionWriteLock(params) {
|
|
|
339
339
|
const nowMs = Date.now();
|
|
340
340
|
const inspected = inspectLockPayload(payload, staleMs, nowMs);
|
|
341
341
|
if (await shouldReclaimContendedLockFile(lockPath, inspected, staleMs, nowMs)) {
|
|
342
|
-
await fs
|
|
342
|
+
await fs.rm(lockPath, { force: true });
|
|
343
343
|
continue;
|
|
344
344
|
}
|
|
345
345
|
const delay = Math.min(1e3, 50 * attempt);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
|
|
@@ -6,13 +6,13 @@ import { spawn } from "node:child_process";
|
|
|
6
6
|
function resolvePowerShellPath() {
|
|
7
7
|
const programFiles = process.env.ProgramFiles || process.env.PROGRAMFILES || "C:\\Program Files";
|
|
8
8
|
const pwsh7 = path.join(programFiles, "PowerShell", "7", "pwsh.exe");
|
|
9
|
-
if (
|
|
9
|
+
if (syncFs.existsSync(pwsh7)) {
|
|
10
10
|
return pwsh7;
|
|
11
11
|
}
|
|
12
12
|
const programW6432 = process.env.ProgramW6432;
|
|
13
13
|
if (programW6432 && programW6432 !== programFiles) {
|
|
14
14
|
const pwsh7Alt = path.join(programW6432, "PowerShell", "7", "pwsh.exe");
|
|
15
|
-
if (
|
|
15
|
+
if (syncFs.existsSync(pwsh7Alt)) {
|
|
16
16
|
return pwsh7Alt;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -23,7 +23,7 @@ function resolvePowerShellPath() {
|
|
|
23
23
|
const systemRoot = process.env.SystemRoot || process.env.WINDIR;
|
|
24
24
|
if (systemRoot) {
|
|
25
25
|
const candidate = path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
26
|
-
if (
|
|
26
|
+
if (syncFs.existsSync(candidate)) {
|
|
27
27
|
return candidate;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -73,7 +73,7 @@ function resolveShellFromPath(name) {
|
|
|
73
73
|
for (const entry of entries) {
|
|
74
74
|
const candidate = path.join(entry, name);
|
|
75
75
|
try {
|
|
76
|
-
|
|
76
|
+
syncFs.accessSync(candidate, syncFs.constants.X_OK);
|
|
77
77
|
return candidate;
|
|
78
78
|
} catch {}
|
|
79
79
|
}
|