@fased/fased 0.1.60 → 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 +22 -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-CqF4Tc9n.js → app-DLil9VO1.js} +3 -3
- package/dist/control-ui/assets/{index-DYggPSfy.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-C2QXh5Ml.js → audio-preflight-Bwi2Oq03.js} +2 -2
- package/dist/plugin-sdk/channel-plugin-common.d.ts +2 -2
- package/dist/plugin-sdk/{chunk-items-3ZyiGiff.js → chunk-items-DzT4L4Ty.js} +1 -1
- package/dist/plugin-sdk/command-status.js +2 -2
- package/dist/plugin-sdk/{config-schema-C9tx1Lyz.js → config-schema-BrkmtFxB.js} +16 -16
- 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 +20 -20
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{monitor-Xgx6vGcg.js → monitor-M_ta2lMc.js} +4 -4
- package/dist/plugin-sdk/{monitor-XbunF2-r.js → monitor-wYVncM9w.js} +6 -6
- package/dist/plugin-sdk/{openresponses-http-BRUr0JLE.js → openresponses-http-B2GmeSt4.js} +2 -2
- package/dist/plugin-sdk/{pairing-message-C403mq4K.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/{pw-ai-BzV0f18N.js → pw-ai-AFUqn-tQ.js} +1 -1
- package/dist/plugin-sdk/{runtime-dependency-Ch7J9a0d.js → runtime-dependency-DLDmB94f.js} +9 -9
- package/dist/plugin-sdk/sat-runtime.d.ts +2 -2
- package/dist/plugin-sdk/sat-runtime.js +2 -2
- package/dist/plugin-sdk/{slack-BzJfCWjq.js → slack-CxE1mfzj.js} +4 -4
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/{sticker-cache-Dex-XpRj.js → sticker-cache-CGzGWu00.js} +2 -2
- package/dist/plugin-sdk/{telegram-actions-DoFTGX4z.js → telegram-actions-DaEcYQ8r.js} +3 -3
- package/dist/plugin-sdk/telegram.d.ts +4 -4
- package/dist/plugin-sdk/{tmp-fased-dir-Ouj58axY.d.ts → tmp-fased-dir-CS6zsYEE.d.ts} +1 -1
- package/dist/plugin-sdk/{types-B4hj6HgR.d.ts → types-DFAW-n1J.d.ts} +1 -1
- package/dist/plugin-sdk/{types-dWZFX1fk.d.ts → types-vcJrC_uv.d.ts} +2 -2
- package/dist/plugin-sdk/{web--wC3ZfVl.js → web-CInY-lCv.js} +2 -2
- package/dist/plugin-sdk/whatsapp.d.ts +13 -13
- package/dist/plugin-sdk/{zod-schema.providers-core-FaYR6KdD.d.ts → zod-schema.providers-core-BEbNizPe.d.ts} +78 -78
- 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 +12 -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 +12 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +12 -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 +12 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +12 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +12 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +12 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +2 -1
- package/scripts/install-fased-signerd.sh +142 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths.js";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import crypto from "node:crypto";
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ function resolveDefaultIdentityPath() {
|
|
|
8
8
|
return path.join(resolveStateDir(), "identity", "device.json");
|
|
9
9
|
}
|
|
10
10
|
function ensureDir(filePath) {
|
|
11
|
-
|
|
11
|
+
syncFs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
12
12
|
}
|
|
13
13
|
const ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
14
14
|
function base64UrlEncode(buf) {
|
|
@@ -56,8 +56,8 @@ function createEphemeralDeviceIdentity() {
|
|
|
56
56
|
}
|
|
57
57
|
function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
58
58
|
try {
|
|
59
|
-
if (
|
|
60
|
-
const raw =
|
|
59
|
+
if (syncFs.existsSync(filePath)) {
|
|
60
|
+
const raw = syncFs.readFileSync(filePath, "utf8");
|
|
61
61
|
const parsed = JSON.parse(raw);
|
|
62
62
|
if (parsed?.version === 1 && typeof parsed.deviceId === "string" && typeof parsed.publicKeyPem === "string" && typeof parsed.privateKeyPem === "string") {
|
|
63
63
|
const derivedId = fingerprintPublicKey(parsed.publicKeyPem);
|
|
@@ -66,9 +66,9 @@ function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
|
66
66
|
...parsed,
|
|
67
67
|
deviceId: derivedId
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
syncFs.writeFileSync(filePath, `${JSON.stringify(updated, null, 2)}\n`, { mode: 384 });
|
|
70
70
|
try {
|
|
71
|
-
|
|
71
|
+
syncFs.chmodSync(filePath, 384);
|
|
72
72
|
} catch {}
|
|
73
73
|
return {
|
|
74
74
|
deviceId: derivedId,
|
|
@@ -93,9 +93,9 @@ function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
|
93
93
|
privateKeyPem: identity.privateKeyPem,
|
|
94
94
|
createdAtMs: Date.now()
|
|
95
95
|
};
|
|
96
|
-
|
|
96
|
+
syncFs.writeFileSync(filePath, `${JSON.stringify(stored, null, 2)}\n`, { mode: 384 });
|
|
97
97
|
try {
|
|
98
|
-
|
|
98
|
+
syncFs.chmodSync(filePath, 384);
|
|
99
99
|
} catch {}
|
|
100
100
|
return identity;
|
|
101
101
|
}
|
package/dist/infra/dotenv.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveRequiredHomeDir } from "./home-dir.js";
|
|
2
2
|
import { resolveConfigDir } from "../utils.js";
|
|
3
3
|
import { isDangerousHostEnvOverrideVarName, isDangerousHostEnvVarName, normalizeEnvVarKey } from "./host-env-security.js";
|
|
4
|
-
import
|
|
4
|
+
import syncFs from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import dotenv from "dotenv";
|
|
@@ -84,7 +84,7 @@ function shouldBlockWorkspaceDotEnvKey(key) {
|
|
|
84
84
|
function readDotEnvFile(params) {
|
|
85
85
|
let content;
|
|
86
86
|
try {
|
|
87
|
-
content =
|
|
87
|
+
content = syncFs.readFileSync(params.filePath, "utf8");
|
|
88
88
|
} catch (error) {
|
|
89
89
|
if (!params.quiet) {
|
|
90
90
|
const code = error && typeof error === "object" && "code" in error ? String(error.code) : undefined;
|
|
@@ -4,7 +4,7 @@ import { DEFAULT_SAFE_BINS, matchAllowlist, parseExecArgvToken, resolveAllowlist
|
|
|
4
4
|
import { analyzeArgvCommand, analyzeShellCommand, buildEnforcedShellCommand, isWindowsPlatform, splitCommandChain, splitCommandChainWithOperators } from "./exec-approvals-analysis.js";
|
|
5
5
|
import { evaluateExecAllowlist, evaluateShellAllowlist, isSafeBinUsage, normalizeSafeBins, resolveAllowAlwaysPatterns, resolveSafeBins } from "./exec-approvals-allowlist.js";
|
|
6
6
|
import { requestJsonlSocket } from "./jsonl-socket.js";
|
|
7
|
-
import
|
|
7
|
+
import syncFs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import crypto from "node:crypto";
|
|
10
10
|
|
|
@@ -61,7 +61,7 @@ function mergeLegacyAgent(current, legacy) {
|
|
|
61
61
|
}
|
|
62
62
|
function ensureDir(filePath) {
|
|
63
63
|
const dir = path.dirname(filePath);
|
|
64
|
-
|
|
64
|
+
syncFs.mkdirSync(dir, { recursive: true });
|
|
65
65
|
}
|
|
66
66
|
function coerceAllowlistEntries(allowlist) {
|
|
67
67
|
if (!Array.isArray(allowlist) || allowlist.length === 0) {
|
|
@@ -162,7 +162,7 @@ function generateToken() {
|
|
|
162
162
|
}
|
|
163
163
|
function readExecApprovalsSnapshot() {
|
|
164
164
|
const filePath = resolveExecApprovalsPath();
|
|
165
|
-
if (!
|
|
165
|
+
if (!syncFs.existsSync(filePath)) {
|
|
166
166
|
const file = normalizeExecApprovals({
|
|
167
167
|
version: 1,
|
|
168
168
|
agents: {}
|
|
@@ -175,7 +175,7 @@ function readExecApprovalsSnapshot() {
|
|
|
175
175
|
hash: hashExecApprovalsRaw(null)
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
const raw =
|
|
178
|
+
const raw = syncFs.readFileSync(filePath, "utf8");
|
|
179
179
|
let parsed = null;
|
|
180
180
|
try {
|
|
181
181
|
parsed = JSON.parse(raw);
|
|
@@ -197,13 +197,13 @@ function readExecApprovalsSnapshot() {
|
|
|
197
197
|
function loadExecApprovals() {
|
|
198
198
|
const filePath = resolveExecApprovalsPath();
|
|
199
199
|
try {
|
|
200
|
-
if (!
|
|
200
|
+
if (!syncFs.existsSync(filePath)) {
|
|
201
201
|
return normalizeExecApprovals({
|
|
202
202
|
version: 1,
|
|
203
203
|
agents: {}
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
const raw =
|
|
206
|
+
const raw = syncFs.readFileSync(filePath, "utf8");
|
|
207
207
|
const parsed = JSON.parse(raw);
|
|
208
208
|
if (parsed?.version !== 1) {
|
|
209
209
|
return normalizeExecApprovals({
|
|
@@ -222,9 +222,9 @@ function loadExecApprovals() {
|
|
|
222
222
|
function saveExecApprovals(file) {
|
|
223
223
|
const filePath = resolveExecApprovalsPath();
|
|
224
224
|
ensureDir(filePath);
|
|
225
|
-
|
|
225
|
+
syncFs.writeFileSync(filePath, `${JSON.stringify(file, null, 2)}\n`, { mode: 384 });
|
|
226
226
|
try {
|
|
227
|
-
|
|
227
|
+
syncFs.chmodSync(filePath, 384);
|
|
228
228
|
} catch {}
|
|
229
229
|
}
|
|
230
230
|
function ensureExecApprovals() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expandHomePrefix } from "./home-dir.js";
|
|
2
2
|
import { resolveDispatchWrapperExecutionPlan } from "./exec-wrapper-resolution.js";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/infra/exec-command-resolution.ts
|
|
@@ -15,12 +15,12 @@ const DEFAULT_SAFE_BINS = [
|
|
|
15
15
|
];
|
|
16
16
|
function isExecutableFile(filePath) {
|
|
17
17
|
try {
|
|
18
|
-
const stat =
|
|
18
|
+
const stat = syncFs.statSync(filePath);
|
|
19
19
|
if (!stat.isFile()) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
if (process.platform !== "win32") {
|
|
23
|
-
|
|
23
|
+
syncFs.accessSync(filePath, syncFs.constants.X_OK);
|
|
24
24
|
}
|
|
25
25
|
return true;
|
|
26
26
|
} catch {
|
|
@@ -111,7 +111,7 @@ function normalizeMatchTarget(value) {
|
|
|
111
111
|
}
|
|
112
112
|
function tryRealpath(value) {
|
|
113
113
|
try {
|
|
114
|
-
return
|
|
114
|
+
return syncFs.realpathSync(value);
|
|
115
115
|
} catch {
|
|
116
116
|
return null;
|
|
117
117
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/exec-safe-bin-trust.ts
|
|
@@ -61,7 +61,7 @@ function listWritableExplicitTrustedSafeBinDirs(entries) {
|
|
|
61
61
|
for (const dir of resolved) {
|
|
62
62
|
let stat;
|
|
63
63
|
try {
|
|
64
|
-
stat =
|
|
64
|
+
stat = syncFs.statSync(dir);
|
|
65
65
|
} catch {
|
|
66
66
|
continue;
|
|
67
67
|
}
|
package/dist/infra/fased-root.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
-
import
|
|
2
|
+
import syncFs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import fs
|
|
4
|
+
import fs from "node:fs/promises";
|
|
5
5
|
|
|
6
6
|
//#region src/infra/fased-root.ts
|
|
7
7
|
const CORE_PACKAGE_NAMES = new Set(["fased", "@fased/fased"]);
|
|
8
8
|
async function readPackageName(dir) {
|
|
9
9
|
try {
|
|
10
|
-
const raw = await fs
|
|
10
|
+
const raw = await fs.readFile(path.join(dir, "package.json"), "utf-8");
|
|
11
11
|
const parsed = JSON.parse(raw);
|
|
12
12
|
return typeof parsed.name === "string" ? parsed.name : null;
|
|
13
13
|
} catch {
|
|
@@ -16,7 +16,7 @@ async function readPackageName(dir) {
|
|
|
16
16
|
}
|
|
17
17
|
function readPackageNameSync(dir) {
|
|
18
18
|
try {
|
|
19
|
-
const raw =
|
|
19
|
+
const raw = syncFs.readFileSync(path.join(dir, "package.json"), "utf-8");
|
|
20
20
|
const parsed = JSON.parse(raw);
|
|
21
21
|
return typeof parsed.name === "string" ? parsed.name : null;
|
|
22
22
|
} catch {
|
|
@@ -56,7 +56,7 @@ function candidateDirsFromArgv1(argv1) {
|
|
|
56
56
|
const normalized = path.resolve(argv1);
|
|
57
57
|
const candidates = [path.dirname(normalized)];
|
|
58
58
|
try {
|
|
59
|
-
const resolved =
|
|
59
|
+
const resolved = syncFs.realpathSync(normalized);
|
|
60
60
|
if (resolved !== normalized) {
|
|
61
61
|
candidates.push(path.dirname(resolved));
|
|
62
62
|
}
|
package/dist/infra/fs-safe.js
CHANGED
|
@@ -3,7 +3,7 @@ import { sameFileIdentity } from "./file-identity.js";
|
|
|
3
3
|
import { assertNoPathAliasEscape } from "./path-alias-guards.js";
|
|
4
4
|
import { constants } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import fs
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
7
|
|
|
8
8
|
//#region src/infra/fs-safe.ts
|
|
9
9
|
var SafeOpenError = class extends Error {
|
|
@@ -25,7 +25,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
25
25
|
let handle;
|
|
26
26
|
try {
|
|
27
27
|
const openFlags = options?.allowSymlinkTargetWithinRoot ? options.nonBlockingRead ? OPEN_READ_FOLLOW_NONBLOCK_FLAGS : OPEN_READ_FOLLOW_FLAGS : options?.nonBlockingRead ? OPEN_READ_NONBLOCK_FLAGS : OPEN_READ_FLAGS;
|
|
28
|
-
handle = await fs
|
|
28
|
+
handle = await fs.open(filePath, openFlags);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
if (isNotFoundPathError(err)) {
|
|
31
31
|
throw new SafeOpenError("not-found", "file not found");
|
|
@@ -36,7 +36,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
36
36
|
throw err;
|
|
37
37
|
}
|
|
38
38
|
try {
|
|
39
|
-
const [stat, pathStat] = await Promise.all([handle.stat(), options?.allowSymlinkTargetWithinRoot ? fs
|
|
39
|
+
const [stat, pathStat] = await Promise.all([handle.stat(), options?.allowSymlinkTargetWithinRoot ? fs.stat(filePath) : fs.lstat(filePath)]);
|
|
40
40
|
if (!options?.allowSymlinkTargetWithinRoot && pathStat.isSymbolicLink()) {
|
|
41
41
|
throw new SafeOpenError("symlink", "symlink not allowed");
|
|
42
42
|
}
|
|
@@ -49,8 +49,8 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
49
49
|
if (!sameFileIdentity(stat, pathStat)) {
|
|
50
50
|
throw new SafeOpenError("path-mismatch", "path changed during read");
|
|
51
51
|
}
|
|
52
|
-
const realPath = await fs
|
|
53
|
-
const realStat = await fs
|
|
52
|
+
const realPath = await fs.realpath(filePath);
|
|
53
|
+
const realStat = await fs.stat(realPath);
|
|
54
54
|
if (options?.rejectHardlinks && realStat.nlink > 1) {
|
|
55
55
|
throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
56
56
|
}
|
|
@@ -76,7 +76,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
76
76
|
async function openFileWithinRoot(params) {
|
|
77
77
|
let rootReal;
|
|
78
78
|
try {
|
|
79
|
-
rootReal = await fs
|
|
79
|
+
rootReal = await fs.realpath(params.rootDir);
|
|
80
80
|
} catch (err) {
|
|
81
81
|
if (isNotFoundPathError(err)) {
|
|
82
82
|
throw new SafeOpenError("not-found", "root dir not found");
|
|
@@ -154,7 +154,7 @@ async function readFileWithinRoot(params) {
|
|
|
154
154
|
async function writeFileWithinRoot(params) {
|
|
155
155
|
let rootReal;
|
|
156
156
|
try {
|
|
157
|
-
rootReal = await fs
|
|
157
|
+
rootReal = await fs.realpath(params.rootDir);
|
|
158
158
|
} catch (err) {
|
|
159
159
|
if (isNotFoundPathError(err)) {
|
|
160
160
|
throw new SafeOpenError("not-found", "root dir not found");
|
|
@@ -176,7 +176,7 @@ async function writeFileWithinRoot(params) {
|
|
|
176
176
|
throw new SafeOpenError("invalid-path", "path alias escape blocked", { cause: err });
|
|
177
177
|
}
|
|
178
178
|
if (params.mkdir !== false) {
|
|
179
|
-
await fs
|
|
179
|
+
await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
180
180
|
}
|
|
181
181
|
try {
|
|
182
182
|
await assertNoPathAliasEscape({
|
|
@@ -188,7 +188,7 @@ async function writeFileWithinRoot(params) {
|
|
|
188
188
|
throw new SafeOpenError("invalid-path", "path alias escape blocked", { cause: err });
|
|
189
189
|
}
|
|
190
190
|
try {
|
|
191
|
-
const pathStat = await fs
|
|
191
|
+
const pathStat = await fs.lstat(resolved);
|
|
192
192
|
if (pathStat.isSymbolicLink()) {
|
|
193
193
|
throw new SafeOpenError("invalid-path", "symlink open blocked");
|
|
194
194
|
}
|
|
@@ -202,7 +202,7 @@ async function writeFileWithinRoot(params) {
|
|
|
202
202
|
}
|
|
203
203
|
let ioPath = resolved;
|
|
204
204
|
try {
|
|
205
|
-
const resolvedRealPath = await fs
|
|
205
|
+
const resolvedRealPath = await fs.realpath(resolved);
|
|
206
206
|
if (!isPathInside(rootWithSep, resolvedRealPath)) {
|
|
207
207
|
throw new SafeOpenError("invalid-path", "path escapes root");
|
|
208
208
|
}
|
|
@@ -217,7 +217,7 @@ async function writeFileWithinRoot(params) {
|
|
|
217
217
|
}
|
|
218
218
|
let handle;
|
|
219
219
|
try {
|
|
220
|
-
handle = await fs
|
|
220
|
+
handle = await fs.open(ioPath, OPEN_WRITE_FLAGS, 384);
|
|
221
221
|
} catch (err) {
|
|
222
222
|
if (isNotFoundPathError(err)) {
|
|
223
223
|
throw new SafeOpenError("not-found", "file not found");
|
|
@@ -228,7 +228,7 @@ async function writeFileWithinRoot(params) {
|
|
|
228
228
|
throw err;
|
|
229
229
|
}
|
|
230
230
|
try {
|
|
231
|
-
const [stat, lstat] = await Promise.all([handle.stat(), fs
|
|
231
|
+
const [stat, lstat] = await Promise.all([handle.stat(), fs.lstat(ioPath)]);
|
|
232
232
|
if (lstat.isSymbolicLink() || !stat.isFile()) {
|
|
233
233
|
throw new SafeOpenError("invalid-path", "path is not a regular file under root");
|
|
234
234
|
}
|
|
@@ -238,8 +238,8 @@ async function writeFileWithinRoot(params) {
|
|
|
238
238
|
if (!sameFileIdentity(stat, lstat)) {
|
|
239
239
|
throw new SafeOpenError("path-mismatch", "path changed during write");
|
|
240
240
|
}
|
|
241
|
-
const realPath = await fs
|
|
242
|
-
const realStat = await fs
|
|
241
|
+
const realPath = await fs.realpath(ioPath);
|
|
242
|
+
const realStat = await fs.stat(realPath);
|
|
243
243
|
if (!sameFileIdentity(stat, realStat)) {
|
|
244
244
|
throw new SafeOpenError("path-mismatch", "path mismatch");
|
|
245
245
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveConfigPath, resolveGatewayLockDir, resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { isPidAlive } from "../shared/pid-alive.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
|
import { createHash } from "node:crypto";
|
|
7
7
|
import net from "node:net";
|
|
8
8
|
|
|
@@ -44,7 +44,7 @@ function isGatewayArgv(args) {
|
|
|
44
44
|
}
|
|
45
45
|
function readLinuxCmdline(pid) {
|
|
46
46
|
try {
|
|
47
|
-
const raw =
|
|
47
|
+
const raw = syncFs.readFileSync(`/proc/${pid}/cmdline`, "utf8");
|
|
48
48
|
return parseProcCmdline(raw);
|
|
49
49
|
} catch {
|
|
50
50
|
return null;
|
|
@@ -52,7 +52,7 @@ function readLinuxCmdline(pid) {
|
|
|
52
52
|
}
|
|
53
53
|
function readLinuxStartTime(pid) {
|
|
54
54
|
try {
|
|
55
|
-
const raw =
|
|
55
|
+
const raw = syncFs.readFileSync(`/proc/${pid}/stat`, "utf8").trim();
|
|
56
56
|
const closeParen = raw.lastIndexOf(")");
|
|
57
57
|
if (closeParen < 0) {
|
|
58
58
|
return null;
|
|
@@ -122,7 +122,7 @@ async function resolveGatewayOwnerStatus(pid, payload, platform, port) {
|
|
|
122
122
|
}
|
|
123
123
|
async function readLockPayload(lockPath) {
|
|
124
124
|
try {
|
|
125
|
-
const raw = await fs
|
|
125
|
+
const raw = await fs.readFile(lockPath, "utf8");
|
|
126
126
|
const parsed = JSON.parse(raw);
|
|
127
127
|
if (typeof parsed.pid !== "number") {
|
|
128
128
|
return null;
|
|
@@ -167,12 +167,12 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
167
167
|
const platform = opts.platform ?? process.platform;
|
|
168
168
|
const port = opts.port;
|
|
169
169
|
const { lockPath, configPath } = resolveGatewayLockPath(env);
|
|
170
|
-
await fs
|
|
170
|
+
await fs.mkdir(path.dirname(lockPath), { recursive: true });
|
|
171
171
|
const startedAt = Date.now();
|
|
172
172
|
let lastPayload = null;
|
|
173
173
|
while (Date.now() - startedAt < timeoutMs) {
|
|
174
174
|
try {
|
|
175
|
-
const handle = await fs
|
|
175
|
+
const handle = await fs.open(lockPath, "wx");
|
|
176
176
|
const startTime = platform === "linux" ? readLinuxStartTime(process.pid) : null;
|
|
177
177
|
const payload = {
|
|
178
178
|
pid: process.pid,
|
|
@@ -188,7 +188,7 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
188
188
|
configPath,
|
|
189
189
|
release: async () => {
|
|
190
190
|
await handle.close().catch(() => undefined);
|
|
191
|
-
await fs
|
|
191
|
+
await fs.rm(lockPath, { force: true });
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
} catch (err) {
|
|
@@ -200,7 +200,7 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
200
200
|
const ownerPid = lastPayload?.pid;
|
|
201
201
|
const ownerStatus = ownerPid ? await resolveGatewayOwnerStatus(ownerPid, lastPayload, platform, port) : "unknown";
|
|
202
202
|
if (ownerStatus === "dead" && ownerPid) {
|
|
203
|
-
await fs
|
|
203
|
+
await fs.rm(lockPath, { force: true });
|
|
204
204
|
continue;
|
|
205
205
|
}
|
|
206
206
|
if (ownerStatus !== "alive") {
|
|
@@ -211,14 +211,14 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
211
211
|
}
|
|
212
212
|
if (!stale) {
|
|
213
213
|
try {
|
|
214
|
-
const st = await fs
|
|
214
|
+
const st = await fs.stat(lockPath);
|
|
215
215
|
stale = Date.now() - st.mtimeMs > staleMs;
|
|
216
216
|
} catch {
|
|
217
217
|
stale = false;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
if (stale) {
|
|
221
|
-
await fs
|
|
221
|
+
await fs.rm(lockPath, { force: true });
|
|
222
222
|
continue;
|
|
223
223
|
}
|
|
224
224
|
}
|
package/dist/infra/git-commit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveGitHeadPath } from "./git-root.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import
|
|
3
|
+
import syncFs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/infra/git-commit.ts
|
|
@@ -48,7 +48,7 @@ function isMissingPathError(error) {
|
|
|
48
48
|
function resolveGitRefsBase(headPath) {
|
|
49
49
|
const gitDir = path.dirname(headPath);
|
|
50
50
|
try {
|
|
51
|
-
const commonDirRaw =
|
|
51
|
+
const commonDirRaw = syncFs.readFileSync(path.join(gitDir, "commondir"), "utf-8").trim();
|
|
52
52
|
if (!commonDirRaw) {
|
|
53
53
|
return gitDir;
|
|
54
54
|
}
|
|
@@ -79,7 +79,7 @@ function resolveRefPath(refsBase, ref) {
|
|
|
79
79
|
}
|
|
80
80
|
function readCommitFromPackedRefs(refsBase, ref) {
|
|
81
81
|
try {
|
|
82
|
-
const packedRefs =
|
|
82
|
+
const packedRefs = syncFs.readFileSync(path.join(refsBase, "packed-refs"), "utf-8");
|
|
83
83
|
for (const line of packedRefs.split("\n")) {
|
|
84
84
|
if (!line || line.startsWith("#") || line.startsWith("^")) {
|
|
85
85
|
continue;
|
|
@@ -124,7 +124,7 @@ const resolveCommitHash = (options = {}) => {
|
|
|
124
124
|
cachedCommit = null;
|
|
125
125
|
return cachedCommit;
|
|
126
126
|
}
|
|
127
|
-
const head =
|
|
127
|
+
const head = syncFs.readFileSync(headPath, "utf-8").trim();
|
|
128
128
|
if (!head) {
|
|
129
129
|
cachedCommit = null;
|
|
130
130
|
return cachedCommit;
|
|
@@ -138,7 +138,7 @@ const resolveCommitHash = (options = {}) => {
|
|
|
138
138
|
return cachedCommit;
|
|
139
139
|
}
|
|
140
140
|
try {
|
|
141
|
-
const refHash =
|
|
141
|
+
const refHash = syncFs.readFileSync(refPath, "utf-8").trim();
|
|
142
142
|
cachedCommit = formatCommit(refHash);
|
|
143
143
|
return cachedCommit;
|
|
144
144
|
} catch (error) {
|
package/dist/infra/git-root.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/git-root.ts
|
|
@@ -22,7 +22,7 @@ function walkUpFrom(startDir, opts, resolveAtDir) {
|
|
|
22
22
|
function hasGitMarker(repoRoot) {
|
|
23
23
|
const gitPath = path.join(repoRoot, ".git");
|
|
24
24
|
try {
|
|
25
|
-
const stat =
|
|
25
|
+
const stat = syncFs.statSync(gitPath);
|
|
26
26
|
return stat.isDirectory() || stat.isFile();
|
|
27
27
|
} catch {
|
|
28
28
|
return false;
|
|
@@ -34,14 +34,14 @@ function findGitRoot(startDir, opts = {}) {
|
|
|
34
34
|
function resolveGitDirFromMarker(repoRoot) {
|
|
35
35
|
const gitPath = path.join(repoRoot, ".git");
|
|
36
36
|
try {
|
|
37
|
-
const stat =
|
|
37
|
+
const stat = syncFs.statSync(gitPath);
|
|
38
38
|
if (stat.isDirectory()) {
|
|
39
39
|
return gitPath;
|
|
40
40
|
}
|
|
41
41
|
if (!stat.isFile()) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
const raw =
|
|
44
|
+
const raw = syncFs.readFileSync(gitPath, "utf-8");
|
|
45
45
|
const match = raw.match(/gitdir:\s*(.+)/i);
|
|
46
46
|
if (!match?.[1]) {
|
|
47
47
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReadStream, createWriteStream } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import fs
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { Readable } from "node:stream";
|
|
6
6
|
import { pipeline } from "node:stream/promises";
|
|
@@ -141,7 +141,7 @@ async function downloadHostedRuntimeDescriptor(params) {
|
|
|
141
141
|
reason: `hosted runtime artifact unavailable (${artifactResponse.status})`
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
await fs
|
|
144
|
+
await fs.mkdir(params.destinationDir, { recursive: true });
|
|
145
145
|
const archivePath = path.join(params.destinationDir, descriptor.assetName);
|
|
146
146
|
try {
|
|
147
147
|
await writeResponseBody(artifactResponse, archivePath);
|
|
@@ -153,7 +153,7 @@ async function downloadHostedRuntimeDescriptor(params) {
|
|
|
153
153
|
}
|
|
154
154
|
const actualChecksum = await sha256(archivePath);
|
|
155
155
|
if (actualChecksum !== expectedChecksum) {
|
|
156
|
-
await fs
|
|
156
|
+
await fs.rm(archivePath, { force: true });
|
|
157
157
|
return {
|
|
158
158
|
kind: "error",
|
|
159
159
|
reason: `hosted runtime checksum mismatch for ${descriptor.assetName}`
|
package/dist/infra/is-main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/is-main.ts
|
|
@@ -8,7 +8,7 @@ function normalizePathCandidate(candidate, cwd) {
|
|
|
8
8
|
}
|
|
9
9
|
const resolved = path.resolve(cwd, candidate);
|
|
10
10
|
try {
|
|
11
|
-
return
|
|
11
|
+
return syncFs.realpathSync.native(resolved);
|
|
12
12
|
} catch {
|
|
13
13
|
return resolved;
|
|
14
14
|
}
|
package/dist/infra/json-file.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/json-file.ts
|
|
5
5
|
function loadJsonFile(pathname) {
|
|
6
6
|
try {
|
|
7
|
-
if (!
|
|
7
|
+
if (!syncFs.existsSync(pathname)) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
|
-
const raw =
|
|
10
|
+
const raw = syncFs.readFileSync(pathname, "utf8");
|
|
11
11
|
return JSON.parse(raw);
|
|
12
12
|
} catch {
|
|
13
13
|
return undefined;
|
|
@@ -15,14 +15,14 @@ function loadJsonFile(pathname) {
|
|
|
15
15
|
}
|
|
16
16
|
function saveJsonFile(pathname, data) {
|
|
17
17
|
const dir = path.dirname(pathname);
|
|
18
|
-
if (!
|
|
19
|
-
|
|
18
|
+
if (!syncFs.existsSync(dir)) {
|
|
19
|
+
syncFs.mkdirSync(dir, {
|
|
20
20
|
recursive: true,
|
|
21
21
|
mode: 448
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
syncFs.writeFileSync(pathname, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
25
|
+
syncFs.chmodSync(pathname, 384);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
@@ -4,7 +4,7 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
|
-
import fs
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
8
|
import { execFile } from "node:child_process";
|
|
9
9
|
|
|
10
10
|
//#region src/infra/managed-runtime-bootstrap.ts
|
|
@@ -35,12 +35,12 @@ async function ensureManagedRuntimeBootstrap(params) {
|
|
|
35
35
|
const manifestPath = path.join(stateDir, "install.json");
|
|
36
36
|
const updaterPath = path.join(stateDir, "updater", "fased-managed-updater.mjs");
|
|
37
37
|
try {
|
|
38
|
-
const parsed = JSON.parse(await fs
|
|
38
|
+
const parsed = JSON.parse(await fs.readFile(manifestPath, "utf8"));
|
|
39
39
|
if (parsed.schemaVersion === 1) {
|
|
40
40
|
try {
|
|
41
|
-
await fs
|
|
42
|
-
await fs
|
|
43
|
-
await fs
|
|
41
|
+
await fs.access(updaterPath);
|
|
42
|
+
await fs.access(path.join(stateDir, "bin", "fased"));
|
|
43
|
+
await fs.access(path.join(stateDir, "bin", "fased-service"));
|
|
44
44
|
return {
|
|
45
45
|
installed: false,
|
|
46
46
|
manifestPath,
|
|
@@ -71,7 +71,7 @@ async function ensureManagedRuntimeBootstrap(params) {
|
|
|
71
71
|
}
|
|
72
72
|
const installer = path.join(packageRoot, "scripts", "install-managed-runtime.mjs");
|
|
73
73
|
try {
|
|
74
|
-
await fs
|
|
74
|
+
await fs.access(installer);
|
|
75
75
|
} catch {
|
|
76
76
|
return {
|
|
77
77
|
installed: false,
|