@fased/fased 0.1.42 → 0.1.43
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/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/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/daemon-cli/restart-health.js +49 -13
- 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/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/update-cli/shared.js +1 -29
- package/dist/cli/update-cli/update-command.js +12 -15
- 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/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 +6 -6
- 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/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/update-global.js +1 -0
- package/dist/infra/update-runner.js +111 -64
- package/dist/infra/widearea-dns.js +3 -3
- package/dist/infra/wsl.js +2 -2
- package/dist/light-update-status.js +1 -1
- 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-XJNZUuhw.js → audio-preflight-CzG6BjAn.js} +3 -3
- package/dist/plugin-sdk/channel-plugin-common.d.ts +2 -2
- package/dist/plugin-sdk/{chunk-items-me0j1xjK.js → chunk-items-CxRDAM7m.js} +1 -1
- package/dist/plugin-sdk/command-status.js +3 -3
- 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 +5 -4
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{monitor-C7si_bKw.js → monitor-B1PUtkd6.js} +5 -5
- package/dist/plugin-sdk/{monitor-DUyt6cCK.js → monitor-BrxWsb7H.js} +7 -7
- package/dist/plugin-sdk/{openresponses-http-sYsdEjGP.js → openresponses-http-DJ2lfMja.js} +3 -3
- package/dist/plugin-sdk/{pairing-message-C5m-8Evp.d.ts → pairing-message-DWXHX-jt.d.ts} +1 -1
- package/dist/plugin-sdk/{pi-embedded-runner-C6HkZJ5E.js → pi-embedded-runner-DMfkIj60.js} +12 -12
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +1 -1
- package/dist/plugin-sdk/{pw-ai-BFHYmEIx.js → pw-ai-BgsJH_P8.js} +1 -1
- package/dist/plugin-sdk/{runtime-dependency-B5Fut2tT.js → runtime-dependency-pUwxUAJp.js} +9 -9
- package/dist/plugin-sdk/sat-runtime.d.ts +2 -2
- package/dist/plugin-sdk/sat-runtime.js +1 -1
- package/dist/plugin-sdk/{slack-CEoLScM7.js → slack-B6lIY1Jk.js} +5 -5
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/{sticker-cache-PRfvBRnv.js → sticker-cache-D4Ljzv1P.js} +2 -2
- package/dist/plugin-sdk/{telegram-actions-D4PNLPEZ.js → telegram-actions-tOhBd6st.js} +4 -4
- package/dist/plugin-sdk/telegram.d.ts +4 -4
- package/dist/plugin-sdk/{tmp-fased-dir-B-AAdaCr.d.ts → tmp-fased-dir-Be1wBhVz.d.ts} +1 -1
- package/dist/plugin-sdk/{types-ZT0DGnls.d.ts → types-CJGVZX6j.d.ts} +2 -2
- package/dist/plugin-sdk/{types-56R2vXgt.d.ts → types-CXLEOrJX.d.ts} +1 -1
- package/dist/plugin-sdk/{wallet-status-D9UVH6k9.js → wallet-status-CdxTkLWz.js} +4 -4
- package/dist/plugin-sdk/{web-CSpyzE3P.js → web-CX12Rpz1.js} +3 -3
- 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 +7 -7
- package/dist/wizard/onboarding.wallet.js +44 -44
- 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 +1 -1
|
@@ -10,7 +10,7 @@ import { archiveSessionTranscripts, cleanupArchivedSessionTranscripts } from "..
|
|
|
10
10
|
import { deliveryContextFromSession, mergeDeliveryContext, normalizeDeliveryContext, normalizeSessionDeliveryFields } from "../../utils/delivery-context.js";
|
|
11
11
|
import { getFileMtimeMs, isCacheEnabled, resolveCacheTtlMs } from "../cache-utils.js";
|
|
12
12
|
import { enforceSessionDiskBudget } from "./disk-budget.js";
|
|
13
|
-
import
|
|
13
|
+
import fs from "node:fs";
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import crypto from "node:crypto";
|
|
16
16
|
|
|
@@ -155,7 +155,7 @@ function loadSessionStore(storePath, opts = {}) {
|
|
|
155
155
|
const retryBuf = maxReadAttempts > 1 ? new Int32Array(new SharedArrayBuffer(4)) : undefined;
|
|
156
156
|
for (let attempt = 0; attempt < maxReadAttempts; attempt++) {
|
|
157
157
|
try {
|
|
158
|
-
const raw =
|
|
158
|
+
const raw = fs.readFileSync(storePath, "utf-8");
|
|
159
159
|
if (raw.length === 0 && attempt < maxReadAttempts - 1) {
|
|
160
160
|
Atomics.wait(retryBuf, 0, 0, 50);
|
|
161
161
|
continue;
|
|
@@ -406,7 +406,7 @@ function capEntryCount(store, overrideMax, opts = {}) {
|
|
|
406
406
|
}
|
|
407
407
|
async function getSessionFileSize(storePath) {
|
|
408
408
|
try {
|
|
409
|
-
const stat = await
|
|
409
|
+
const stat = await fs.promises.stat(storePath);
|
|
410
410
|
return stat.size;
|
|
411
411
|
} catch {
|
|
412
412
|
return null;
|
|
@@ -428,7 +428,7 @@ async function rotateSessionFile(storePath, overrideBytes) {
|
|
|
428
428
|
}
|
|
429
429
|
const backupPath = `${storePath}.bak.${Date.now()}`;
|
|
430
430
|
try {
|
|
431
|
-
await
|
|
431
|
+
await fs.promises.rename(storePath, backupPath);
|
|
432
432
|
log.info("rotated session store file", {
|
|
433
433
|
backupPath: path.basename(backupPath),
|
|
434
434
|
sizeBytes: fileSize
|
|
@@ -439,13 +439,13 @@ async function rotateSessionFile(storePath, overrideBytes) {
|
|
|
439
439
|
try {
|
|
440
440
|
const dir = path.dirname(storePath);
|
|
441
441
|
const baseName = path.basename(storePath);
|
|
442
|
-
const files = await
|
|
442
|
+
const files = await fs.promises.readdir(dir);
|
|
443
443
|
const backups = files.filter((f) => f.startsWith(`${baseName}.bak.`)).toSorted().toReversed();
|
|
444
444
|
const maxBackups = 3;
|
|
445
445
|
if (backups.length > maxBackups) {
|
|
446
446
|
const toDelete = backups.slice(maxBackups);
|
|
447
447
|
for (const old of toDelete) {
|
|
448
|
-
await
|
|
448
|
+
await fs.promises.unlink(path.join(dir, old)).catch(() => undefined);
|
|
449
449
|
}
|
|
450
450
|
log.info("cleaned up old session store backups", { deleted: toDelete.length });
|
|
451
451
|
}
|
|
@@ -561,15 +561,15 @@ async function saveSessionStoreUnlocked(storePath, store, opts) {
|
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
await
|
|
564
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
565
565
|
const json = JSON.stringify(store, null, 2);
|
|
566
566
|
if (process.platform === "win32") {
|
|
567
567
|
const tmp = `${storePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
568
568
|
try {
|
|
569
|
-
await
|
|
569
|
+
await fs.promises.writeFile(tmp, json, "utf-8");
|
|
570
570
|
for (let i = 0; i < 5; i++) {
|
|
571
571
|
try {
|
|
572
|
-
await
|
|
572
|
+
await fs.promises.rename(tmp, storePath);
|
|
573
573
|
break;
|
|
574
574
|
} catch {
|
|
575
575
|
if (i < 4) {
|
|
@@ -587,28 +587,28 @@ async function saveSessionStoreUnlocked(storePath, store, opts) {
|
|
|
587
587
|
}
|
|
588
588
|
throw err;
|
|
589
589
|
} finally {
|
|
590
|
-
await
|
|
590
|
+
await fs.promises.rm(tmp, { force: true }).catch(() => undefined);
|
|
591
591
|
}
|
|
592
592
|
return;
|
|
593
593
|
}
|
|
594
594
|
const tmp = `${storePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
595
595
|
try {
|
|
596
|
-
await
|
|
596
|
+
await fs.promises.writeFile(tmp, json, {
|
|
597
597
|
mode: 384,
|
|
598
598
|
encoding: "utf-8"
|
|
599
599
|
});
|
|
600
|
-
await
|
|
601
|
-
await
|
|
600
|
+
await fs.promises.rename(tmp, storePath);
|
|
601
|
+
await fs.promises.chmod(storePath, 384);
|
|
602
602
|
} catch (err) {
|
|
603
603
|
const code = err && typeof err === "object" && "code" in err ? String(err.code) : null;
|
|
604
604
|
if (code === "ENOENT") {
|
|
605
605
|
try {
|
|
606
|
-
await
|
|
607
|
-
await
|
|
606
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
607
|
+
await fs.promises.writeFile(storePath, json, {
|
|
608
608
|
mode: 384,
|
|
609
609
|
encoding: "utf-8"
|
|
610
610
|
});
|
|
611
|
-
await
|
|
611
|
+
await fs.promises.chmod(storePath, 384);
|
|
612
612
|
} catch (err2) {
|
|
613
613
|
const code2 = err2 && typeof err2 === "object" && "code" in err2 ? String(err2.code) : null;
|
|
614
614
|
if (code2 === "ENOENT") {
|
|
@@ -620,7 +620,7 @@ async function saveSessionStoreUnlocked(storePath, store, opts) {
|
|
|
620
620
|
}
|
|
621
621
|
throw err;
|
|
622
622
|
} finally {
|
|
623
|
-
await
|
|
623
|
+
await fs.promises.rm(tmp, { force: true });
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
async function saveSessionStore(storePath, store, opts) {
|
|
@@ -2,7 +2,7 @@ import { resolveDefaultSessionStorePath, resolveSessionTranscriptPathInDir } fro
|
|
|
2
2
|
import { loadSessionStore } from "./store.js";
|
|
3
3
|
import { emitSessionTranscriptUpdate } from "../../sessions/transcript-events.js";
|
|
4
4
|
import { resolveAndPersistSessionFile } from "./session-file.js";
|
|
5
|
-
import
|
|
5
|
+
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
8
8
|
|
|
@@ -65,10 +65,10 @@ async function resolveSessionTranscriptFile(params) {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
async function ensureSessionHeader(params) {
|
|
68
|
-
if (
|
|
68
|
+
if (fs.existsSync(params.sessionFile)) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
await
|
|
71
|
+
await fs.promises.mkdir(path.dirname(params.sessionFile), { recursive: true });
|
|
72
72
|
const header = {
|
|
73
73
|
type: "session",
|
|
74
74
|
version: CURRENT_SESSION_VERSION,
|
|
@@ -76,7 +76,7 @@ async function ensureSessionHeader(params) {
|
|
|
76
76
|
timestamp: new Date().toISOString(),
|
|
77
77
|
cwd: process.cwd()
|
|
78
78
|
};
|
|
79
|
-
await
|
|
79
|
+
await fs.promises.writeFile(params.sessionFile, `${JSON.stringify(header)}\n`, {
|
|
80
80
|
encoding: "utf-8",
|
|
81
81
|
mode: 384
|
|
82
82
|
});
|
package/dist/config/talk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { coerceSecretRef } from "./types.secrets.js";
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
@@ -254,7 +254,7 @@ function buildTalkConfigResponse(value) {
|
|
|
254
254
|
return Object.keys(payload).length > 0 ? payload : undefined;
|
|
255
255
|
}
|
|
256
256
|
function readTalkApiKeyFromProfile(deps = {}) {
|
|
257
|
-
const fsImpl = deps.fs ??
|
|
257
|
+
const fsImpl = deps.fs ?? fs;
|
|
258
258
|
const osImpl = deps.os ?? os;
|
|
259
259
|
const pathImpl = deps.path ?? path;
|
|
260
260
|
const home = osImpl.homedir();
|
|
@@ -5,7 +5,7 @@ import { inferLegacyName, normalizeOptionalText } from "./normalize.js";
|
|
|
5
5
|
import { normalizeCronStaggerMs, resolveDefaultCronStaggerMs } from "../stagger.js";
|
|
6
6
|
import { loadCronStore, saveCronStore } from "../store.js";
|
|
7
7
|
import { recomputeNextRuns } from "./jobs.js";
|
|
8
|
-
import
|
|
8
|
+
import fs from "node:fs";
|
|
9
9
|
|
|
10
10
|
//#region src/cron/service/store.ts
|
|
11
11
|
function buildDeliveryPatchFromLegacyPayload(payload) {
|
|
@@ -179,7 +179,7 @@ function stripLegacyTopLevelFields(raw) {
|
|
|
179
179
|
}
|
|
180
180
|
async function getFileMtimeMs(path) {
|
|
181
181
|
try {
|
|
182
|
-
const stats = await
|
|
182
|
+
const stats = await fs.promises.stat(path);
|
|
183
183
|
return stats.mtimeMs;
|
|
184
184
|
} catch {
|
|
185
185
|
return null;
|
package/dist/cron/store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expandHomePrefix } from "../infra/home-dir.js";
|
|
2
2
|
import { CONFIG_DIR } from "../utils.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import JSON5 from "json5";
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ function resolveCronStorePath(storePath) {
|
|
|
19
19
|
}
|
|
20
20
|
async function loadCronStore(storePath) {
|
|
21
21
|
try {
|
|
22
|
-
const raw = await
|
|
22
|
+
const raw = await fs.promises.readFile(storePath, "utf-8");
|
|
23
23
|
let parsed;
|
|
24
24
|
try {
|
|
25
25
|
parsed = JSON5.parse(raw);
|
|
@@ -45,14 +45,14 @@ async function loadCronStore(storePath) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
async function saveCronStore(storePath, store) {
|
|
48
|
-
await
|
|
48
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
49
49
|
const { randomBytes } = await import("node:crypto");
|
|
50
50
|
const tmp = `${storePath}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
|
|
51
51
|
const json = JSON.stringify(store, null, 2);
|
|
52
|
-
await
|
|
53
|
-
await
|
|
52
|
+
await fs.promises.writeFile(tmp, json, "utf-8");
|
|
53
|
+
await fs.promises.rename(tmp, storePath);
|
|
54
54
|
try {
|
|
55
|
-
await
|
|
55
|
+
await fs.promises.copyFile(storePath, `${storePath}.bak`);
|
|
56
56
|
} catch {}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -4,7 +4,7 @@ import { parseSystemdShow } from "./systemd.js";
|
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import fs from "node:fs/promises";
|
|
7
|
+
import fs$1 from "node:fs/promises";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
|
|
10
10
|
//#region src/daemon/systemd-system.ts
|
|
@@ -23,7 +23,7 @@ function findHostedSystemdUnitPath(candidates = SYSTEM_UNIT_CANDIDATES) {
|
|
|
23
23
|
}
|
|
24
24
|
async function readHostedSystemdCommand(unitPath) {
|
|
25
25
|
try {
|
|
26
|
-
const content = await fs.readFile(unitPath, "utf8");
|
|
26
|
+
const content = await fs$1.readFile(unitPath, "utf8");
|
|
27
27
|
let workingDirectory = "";
|
|
28
28
|
let execStart = "";
|
|
29
29
|
const environment = {};
|
|
@@ -151,7 +151,7 @@ function buildHostedSystemdUnit(params) {
|
|
|
151
151
|
return lines.join("\n");
|
|
152
152
|
}
|
|
153
153
|
async function runHelper(unit, runAsUser) {
|
|
154
|
-
await fs.access(INSTALL_HELPER);
|
|
154
|
+
await fs$1.access(INSTALL_HELPER);
|
|
155
155
|
await new Promise((resolve, reject) => {
|
|
156
156
|
const child = spawn("sudo", [
|
|
157
157
|
"-n",
|
|
@@ -206,8 +206,8 @@ async function installHostedSystemdService(params) {
|
|
|
206
206
|
`${SERVICE_NAME}.service`
|
|
207
207
|
]).catch(() => undefined);
|
|
208
208
|
const userUnit = path.join(os.homedir(), ".config", "systemd", "user", `${SERVICE_NAME}.service`);
|
|
209
|
-
await fs.rm(userUnit, { force: true }).catch(() => undefined);
|
|
210
|
-
await fs.rm(`${userUnit}.d`, {
|
|
209
|
+
await fs$1.rm(userUnit, { force: true }).catch(() => undefined);
|
|
210
|
+
await fs$1.rm(`${userUnit}.d`, {
|
|
211
211
|
recursive: true,
|
|
212
212
|
force: true
|
|
213
213
|
}).catch(() => undefined);
|
|
@@ -3,7 +3,7 @@ import { normalizeAccountId } from "../../routing/account-id.js";
|
|
|
3
3
|
import { resolveAgentIdFromSessionKey } from "../../routing/session-key.js";
|
|
4
4
|
import { loadJsonFile, saveJsonFile } from "../../infra/json-file.js";
|
|
5
5
|
import { DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS, DEFAULT_THREAD_BINDING_MAX_AGE_MS, RECENT_UNBOUND_WEBHOOK_ECHO_WINDOW_MS, THREAD_BINDINGS_VERSION } from "./thread-bindings.types.js";
|
|
6
|
-
import
|
|
6
|
+
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
9
|
//#region src/discord/monitor/thread-bindings.state.ts
|
|
@@ -320,7 +320,7 @@ function shouldPersistBindingMutations() {
|
|
|
320
320
|
if (shouldPersistAnyBindingState()) {
|
|
321
321
|
return true;
|
|
322
322
|
}
|
|
323
|
-
return
|
|
323
|
+
return fs.existsSync(resolveThreadBindingsPath());
|
|
324
324
|
}
|
|
325
325
|
function saveBindingsToDisk(params = {}) {
|
|
326
326
|
if (!params.force && !shouldPersistAnyBindingState()) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SAT_RUNTIME_DEFAULTS } from "../../../config/sat-runtime-ids.js";
|
|
2
2
|
import "../../../plugin-sdk/sat-runtime.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region extensions/sat-mining/src/sat-bond-layout.ts
|
|
@@ -162,7 +162,7 @@ function resolveLayoutPath(env = process.env) {
|
|
|
162
162
|
path.resolve(import.meta.dirname, "..", "..", "..", "..", "..", "token", "sat", "bond-api", "bond-position-layout.json")
|
|
163
163
|
];
|
|
164
164
|
for (const candidate of candidates) {
|
|
165
|
-
if (candidate &&
|
|
165
|
+
if (candidate && fs.existsSync(candidate)) {
|
|
166
166
|
return candidate;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -178,7 +178,7 @@ function resolvePolicyLayoutPath(env = process.env) {
|
|
|
178
178
|
path.resolve(import.meta.dirname, "..", "..", "..", "..", "..", "token", "sat", "bond-api", "bond-tier-policy-layout.json")
|
|
179
179
|
];
|
|
180
180
|
for (const candidate of candidates) {
|
|
181
|
-
if (candidate &&
|
|
181
|
+
if (candidate && fs.existsSync(candidate)) {
|
|
182
182
|
return candidate;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -194,7 +194,7 @@ function resolveStakingDistributorLayoutPath(env = process.env) {
|
|
|
194
194
|
path.resolve(import.meta.dirname, "..", "..", "..", "..", "..", "token", "sat", "bond-api", "bond-staking-distributor-layout.json")
|
|
195
195
|
];
|
|
196
196
|
for (const candidate of candidates) {
|
|
197
|
-
if (candidate &&
|
|
197
|
+
if (candidate && fs.existsSync(candidate)) {
|
|
198
198
|
return candidate;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -210,7 +210,7 @@ function resolveStakingPositionLayoutPath(env = process.env) {
|
|
|
210
210
|
path.resolve(import.meta.dirname, "..", "..", "..", "..", "..", "token", "sat", "bond-api", "bond-staking-position-layout.json")
|
|
211
211
|
];
|
|
212
212
|
for (const candidate of candidates) {
|
|
213
|
-
if (candidate &&
|
|
213
|
+
if (candidate && fs.existsSync(candidate)) {
|
|
214
214
|
return candidate;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -224,7 +224,7 @@ function loadSatBondLayout(env = process.env) {
|
|
|
224
224
|
}
|
|
225
225
|
const layoutPath = resolveLayoutPath(env);
|
|
226
226
|
if (layoutPath) {
|
|
227
|
-
const loaded = JSON.parse(
|
|
227
|
+
const loaded = JSON.parse(fs.readFileSync(layoutPath, "utf-8"));
|
|
228
228
|
cachedLayout = {
|
|
229
229
|
mode,
|
|
230
230
|
value: loaded
|
|
@@ -244,7 +244,7 @@ function loadSatBondPolicyLayout(env = process.env) {
|
|
|
244
244
|
}
|
|
245
245
|
const layoutPath = resolvePolicyLayoutPath(env);
|
|
246
246
|
if (layoutPath) {
|
|
247
|
-
cachedPolicyLayout = JSON.parse(
|
|
247
|
+
cachedPolicyLayout = JSON.parse(fs.readFileSync(layoutPath, "utf-8"));
|
|
248
248
|
return cachedPolicyLayout;
|
|
249
249
|
}
|
|
250
250
|
cachedPolicyLayout = DEDICATED_FALLBACK_POLICY_LAYOUT;
|
|
@@ -257,7 +257,7 @@ function loadSatBondStakingDistributorLayout(env = process.env) {
|
|
|
257
257
|
}
|
|
258
258
|
const layoutPath = resolveStakingDistributorLayoutPath(env);
|
|
259
259
|
if (layoutPath) {
|
|
260
|
-
cachedStakingDistributorLayout = JSON.parse(
|
|
260
|
+
cachedStakingDistributorLayout = JSON.parse(fs.readFileSync(layoutPath, "utf-8"));
|
|
261
261
|
return cachedStakingDistributorLayout;
|
|
262
262
|
}
|
|
263
263
|
cachedStakingDistributorLayout ??= DEDICATED_FALLBACK_STAKING_DISTRIBUTOR_LAYOUT;
|
|
@@ -270,7 +270,7 @@ function loadSatBondStakingPositionLayout(env = process.env) {
|
|
|
270
270
|
}
|
|
271
271
|
const layoutPath = resolveStakingPositionLayoutPath(env);
|
|
272
272
|
if (layoutPath) {
|
|
273
|
-
cachedStakingPositionLayout = JSON.parse(
|
|
273
|
+
cachedStakingPositionLayout = JSON.parse(fs.readFileSync(layoutPath, "utf-8"));
|
|
274
274
|
return cachedStakingPositionLayout;
|
|
275
275
|
}
|
|
276
276
|
cachedStakingPositionLayout ??= DEDICATED_FALLBACK_STAKING_POSITION_LAYOUT;
|
|
@@ -2,7 +2,7 @@ import { openBoundaryFileSync } from "../infra/boundary-file-read.js";
|
|
|
2
2
|
import { isWithinDir } from "../infra/path-safety.js";
|
|
3
3
|
import { resolveControlUiRootSync } from "../infra/control-ui-assets.js";
|
|
4
4
|
import { normalizeControlUiBasePath } from "./control-ui-shared.js";
|
|
5
|
-
import
|
|
5
|
+
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
|
|
8
8
|
//#region src/gateway/control-ui-boot-check.ts
|
|
@@ -189,7 +189,7 @@ function readControlUiBootAsset(params) {
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
try {
|
|
192
|
-
const body =
|
|
192
|
+
const body = fs.readFileSync(safeFile.fd);
|
|
193
193
|
return {
|
|
194
194
|
check: {
|
|
195
195
|
url: params.url,
|
|
@@ -200,7 +200,7 @@ function readControlUiBootAsset(params) {
|
|
|
200
200
|
text: body.toString("utf8")
|
|
201
201
|
};
|
|
202
202
|
} finally {
|
|
203
|
-
|
|
203
|
+
fs.closeSync(safeFile.fd);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
function resolveBootCheckRoot(rootState) {
|
|
@@ -231,7 +231,7 @@ function resolveBootCheckRoot(rootState) {
|
|
|
231
231
|
return {
|
|
232
232
|
ok: true,
|
|
233
233
|
root,
|
|
234
|
-
rootReal:
|
|
234
|
+
rootReal: fs.realpathSync(root)
|
|
235
235
|
};
|
|
236
236
|
} catch (error) {
|
|
237
237
|
if (isExpectedSafePathError(error)) {
|
|
@@ -268,9 +268,9 @@ function resolveControlUiBootCheck(params) {
|
|
|
268
268
|
}
|
|
269
269
|
let html = "";
|
|
270
270
|
try {
|
|
271
|
-
html =
|
|
271
|
+
html = fs.readFileSync(safeIndex.fd, "utf8");
|
|
272
272
|
} finally {
|
|
273
|
-
|
|
273
|
+
fs.closeSync(safeIndex.fd);
|
|
274
274
|
}
|
|
275
275
|
const entryJsUrl = extractHtmlScriptAssetUrls(html, indexUrl)[0] ?? null;
|
|
276
276
|
const entry = entryJsUrl == null ? {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { safeEqualSecret } from "../security/secret-equal.js";
|
|
3
3
|
import { isTrustedProxyAddress } from "./net.js";
|
|
4
|
-
import
|
|
4
|
+
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
7
7
|
|
|
@@ -512,10 +512,10 @@ var ControlUiLoginService = class {
|
|
|
512
512
|
}
|
|
513
513
|
readState() {
|
|
514
514
|
try {
|
|
515
|
-
if (!
|
|
515
|
+
if (!fs.existsSync(this.statePath)) {
|
|
516
516
|
return buildEmptyState();
|
|
517
517
|
}
|
|
518
|
-
const raw =
|
|
518
|
+
const raw = fs.readFileSync(this.statePath, "utf8");
|
|
519
519
|
return normalizeState(safeJsonParse(raw));
|
|
520
520
|
} catch {
|
|
521
521
|
return buildEmptyState();
|
|
@@ -525,13 +525,13 @@ var ControlUiLoginService = class {
|
|
|
525
525
|
if (!this.state) {
|
|
526
526
|
return;
|
|
527
527
|
}
|
|
528
|
-
|
|
528
|
+
fs.mkdirSync(path.dirname(this.statePath), { recursive: true });
|
|
529
529
|
const tmpPath = `${this.statePath}.${process.pid}.${Date.now()}.tmp`;
|
|
530
530
|
const body = `${JSON.stringify(this.state, null, 2)}\n`;
|
|
531
|
-
|
|
532
|
-
|
|
531
|
+
fs.writeFileSync(tmpPath, body, { mode: 384 });
|
|
532
|
+
fs.renameSync(tmpPath, this.statePath);
|
|
533
533
|
try {
|
|
534
|
-
|
|
534
|
+
fs.chmodSync(this.statePath, 384);
|
|
535
535
|
} catch {}
|
|
536
536
|
}
|
|
537
537
|
};
|
|
@@ -7,7 +7,7 @@ import { CONTROL_UI_AVATAR_PREFIX, buildControlUiAvatarUrl, normalizeControlUiBa
|
|
|
7
7
|
import { DEFAULT_ASSISTANT_IDENTITY, resolveAssistantIdentity } from "./assistant-identity.js";
|
|
8
8
|
import { CONTROL_UI_BOOTSTRAP_CONFIG_PATH } from "./control-ui-contract.js";
|
|
9
9
|
import { buildControlUiCspHeader } from "./control-ui-csp.js";
|
|
10
|
-
import
|
|
10
|
+
import fs from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
|
|
13
13
|
//#region src/gateway/control-ui.ts
|
|
@@ -151,10 +151,10 @@ function handleControlUiAvatarRequest(req, res, opts) {
|
|
|
151
151
|
res.end();
|
|
152
152
|
return true;
|
|
153
153
|
}
|
|
154
|
-
serveResolvedFile(res, safeAvatar.path,
|
|
154
|
+
serveResolvedFile(res, safeAvatar.path, fs.readFileSync(safeAvatar.fd));
|
|
155
155
|
return true;
|
|
156
156
|
} finally {
|
|
157
|
-
|
|
157
|
+
fs.closeSync(safeAvatar.fd);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
function respondNotFound(res) {
|
|
@@ -316,7 +316,7 @@ function handleControlUiHttpRequest(req, res, opts) {
|
|
|
316
316
|
}
|
|
317
317
|
const rootReal = (() => {
|
|
318
318
|
try {
|
|
319
|
-
return
|
|
319
|
+
return fs.realpathSync(root);
|
|
320
320
|
} catch (error) {
|
|
321
321
|
if (isExpectedSafePathError(error)) {
|
|
322
322
|
return null;
|
|
@@ -362,13 +362,13 @@ function handleControlUiHttpRequest(req, res, opts) {
|
|
|
362
362
|
return true;
|
|
363
363
|
}
|
|
364
364
|
if (path.basename(safeFile.path) === "index.html") {
|
|
365
|
-
serveResolvedIndexHtml(res,
|
|
365
|
+
serveResolvedIndexHtml(res, fs.readFileSync(safeFile.fd, "utf8"));
|
|
366
366
|
return true;
|
|
367
367
|
}
|
|
368
|
-
serveResolvedFile(res, safeFile.path,
|
|
368
|
+
serveResolvedFile(res, safeFile.path, fs.readFileSync(safeFile.fd));
|
|
369
369
|
return true;
|
|
370
370
|
} finally {
|
|
371
|
-
|
|
371
|
+
fs.closeSync(safeFile.fd);
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
if (STATIC_ASSET_EXTENSIONS.has(path.extname(fileRel).toLowerCase())) {
|
|
@@ -385,10 +385,10 @@ function handleControlUiHttpRequest(req, res, opts) {
|
|
|
385
385
|
res.end();
|
|
386
386
|
return true;
|
|
387
387
|
}
|
|
388
|
-
serveResolvedIndexHtml(res,
|
|
388
|
+
serveResolvedIndexHtml(res, fs.readFileSync(safeIndex.fd, "utf8"));
|
|
389
389
|
return true;
|
|
390
390
|
} finally {
|
|
391
|
-
|
|
391
|
+
fs.closeSync(safeIndex.fd);
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
respondNotFound(res);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CONFIG_PATH } from "../config/paths.js";
|
|
2
2
|
import "../config/config.js";
|
|
3
3
|
import { importFileModule, resolveFunctionModuleExport } from "../hooks/module-loader.js";
|
|
4
|
-
import
|
|
4
|
+
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
7
|
//#region src/gateway/hooks-mapping.ts
|
|
@@ -301,8 +301,8 @@ function escapesBase(baseDir, candidate) {
|
|
|
301
301
|
}
|
|
302
302
|
function safeRealpathSync(candidate) {
|
|
303
303
|
try {
|
|
304
|
-
const nativeRealpath =
|
|
305
|
-
return nativeRealpath ? nativeRealpath(candidate) :
|
|
304
|
+
const nativeRealpath = fs.realpathSync.native;
|
|
305
|
+
return nativeRealpath ? nativeRealpath(candidate) : fs.realpathSync(candidate);
|
|
306
306
|
} catch {
|
|
307
307
|
return null;
|
|
308
308
|
}
|
|
@@ -310,7 +310,7 @@ function safeRealpathSync(candidate) {
|
|
|
310
310
|
function resolveExistingAncestor(candidate) {
|
|
311
311
|
let current = path.resolve(candidate);
|
|
312
312
|
while (true) {
|
|
313
|
-
if (
|
|
313
|
+
if (fs.existsSync(current)) {
|
|
314
314
|
return current;
|
|
315
315
|
}
|
|
316
316
|
const parent = path.dirname(current);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runExec } from "../process/exec.js";
|
|
2
2
|
import { getTailnetHostname } from "../infra/tailscale.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/gateway/server-discovery.ts
|
|
@@ -20,7 +20,7 @@ function resolveBonjourCliPath(opts = {}) {
|
|
|
20
20
|
if (envPath) {
|
|
21
21
|
return envPath;
|
|
22
22
|
}
|
|
23
|
-
const statSync = opts.statSync ??
|
|
23
|
+
const statSync = opts.statSync ?? fs.statSync;
|
|
24
24
|
const isFile = (candidate) => {
|
|
25
25
|
try {
|
|
26
26
|
return statSync(candidate).isFile();
|
|
@@ -50,7 +50,7 @@ import { handleOpenAiHttpRequest } from "./openai-http.js";
|
|
|
50
50
|
import { canonicalizePathVariant } from "./security-path.js";
|
|
51
51
|
import { handleToolsInvokeHttpRequest } from "./tools-invoke-http.js";
|
|
52
52
|
import { authorizeGatewayConnect, isLocalDirectRequest } from "./auth.js";
|
|
53
|
-
import
|
|
53
|
+
import fs from "node:fs";
|
|
54
54
|
import path from "node:path";
|
|
55
55
|
import { createServer } from "node:http";
|
|
56
56
|
import { createServer as createServer$1 } from "node:https";
|
|
@@ -2101,7 +2101,7 @@ async function readLocalFederationStatus(env = process.env, fetchImpl = fetch) {
|
|
|
2101
2101
|
const sourcePath = path.join(resolveStateDir(env), "federation", "access-token.json");
|
|
2102
2102
|
const managed = (env.FASED_GATEWAY_MODE ?? "").trim().toLowerCase() === "managed";
|
|
2103
2103
|
const configured = resolveConfiguredFederationStatus(env);
|
|
2104
|
-
if (!
|
|
2104
|
+
if (!fs.existsSync(sourcePath)) {
|
|
2105
2105
|
return {
|
|
2106
2106
|
managed,
|
|
2107
2107
|
sourcePath,
|
|
@@ -2113,7 +2113,7 @@ async function readLocalFederationStatus(env = process.env, fetchImpl = fetch) {
|
|
|
2113
2113
|
}
|
|
2114
2114
|
let rawText = "";
|
|
2115
2115
|
try {
|
|
2116
|
-
rawText =
|
|
2116
|
+
rawText = fs.readFileSync(sourcePath, "utf-8");
|
|
2117
2117
|
} catch {
|
|
2118
2118
|
return {
|
|
2119
2119
|
managed,
|
|
@@ -2162,7 +2162,7 @@ async function readLocalFederationStatus(env = process.env, fetchImpl = fetch) {
|
|
|
2162
2162
|
const lifecycle = Number.isFinite(expiresAtMs) ? expiresAtMs > Date.now() ? "active" : "expired" : "invalid";
|
|
2163
2163
|
let fileUpdatedAt;
|
|
2164
2164
|
try {
|
|
2165
|
-
fileUpdatedAt =
|
|
2165
|
+
fileUpdatedAt = fs.statSync(sourcePath).mtime.toISOString();
|
|
2166
2166
|
} catch {
|
|
2167
2167
|
fileUpdatedAt = undefined;
|
|
2168
2168
|
}
|
|
@@ -29,7 +29,7 @@ import { parseMessageWithAttachments } from "../chat-attachments.js";
|
|
|
29
29
|
import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js";
|
|
30
30
|
import { normalizeRpcAttachmentsToChatAttachments } from "./attachment-normalize.js";
|
|
31
31
|
import { appendInjectedAssistantMessageToTranscript } from "./chat-transcript-inject.js";
|
|
32
|
-
import
|
|
32
|
+
import fs from "node:fs";
|
|
33
33
|
import path from "node:path";
|
|
34
34
|
import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";
|
|
35
35
|
|
|
@@ -320,11 +320,11 @@ function resolveTranscriptPath(params) {
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
function ensureTranscriptFile(params) {
|
|
323
|
-
if (
|
|
323
|
+
if (fs.existsSync(params.transcriptPath)) {
|
|
324
324
|
return { ok: true };
|
|
325
325
|
}
|
|
326
326
|
try {
|
|
327
|
-
|
|
327
|
+
fs.mkdirSync(path.dirname(params.transcriptPath), { recursive: true });
|
|
328
328
|
const header = {
|
|
329
329
|
type: "session",
|
|
330
330
|
version: CURRENT_SESSION_VERSION,
|
|
@@ -332,7 +332,7 @@ function ensureTranscriptFile(params) {
|
|
|
332
332
|
timestamp: new Date().toISOString(),
|
|
333
333
|
cwd: process.cwd()
|
|
334
334
|
};
|
|
335
|
-
|
|
335
|
+
fs.writeFileSync(params.transcriptPath, `${JSON.stringify(header)}\n`, {
|
|
336
336
|
encoding: "utf-8",
|
|
337
337
|
mode: 384
|
|
338
338
|
});
|
|
@@ -346,7 +346,7 @@ function ensureTranscriptFile(params) {
|
|
|
346
346
|
}
|
|
347
347
|
function transcriptHasIdempotencyKey(transcriptPath, idempotencyKey) {
|
|
348
348
|
try {
|
|
349
|
-
const lines =
|
|
349
|
+
const lines = fs.readFileSync(transcriptPath, "utf-8").split(/\r?\n/);
|
|
350
350
|
for (const line of lines) {
|
|
351
351
|
if (!line.trim()) {
|
|
352
352
|
continue;
|
|
@@ -374,7 +374,7 @@ function appendAssistantTranscriptMessage(params) {
|
|
|
374
374
|
error: "transcript path not resolved"
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
if (!
|
|
377
|
+
if (!fs.existsSync(transcriptPath)) {
|
|
378
378
|
if (!params.createIfMissing) {
|
|
379
379
|
return {
|
|
380
380
|
ok: false,
|