@fased/fased 0.1.47 → 0.1.48
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/current-model-catalog.js +21 -3
- 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/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/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/protocol-contract.js +63 -0
- package/dist/extensions/sat-mining/src/sat-bond-layout.js +9 -9
- package/dist/extensions/sat-mining/src/solana-submit.js +3 -52
- 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/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/inventory.js +25 -4
- package/dist/memory/manager-sync-ops.js +7 -7
- package/dist/memory/repair-executor.js +17 -17
- package/dist/mining/mainnet-sync.js +70 -26
- 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/{accounts-DzLdrOVC.js → accounts-DI5226U8.js} +1 -1
- package/dist/plugin-sdk/{actions-PhofTgnO.js → actions-CEj4gOU2.js} +2 -2
- package/dist/plugin-sdk/{active-listener-C8a74qPO.js → active-listener-Ss4UKXZb.js} +1 -1
- package/dist/plugin-sdk/{audio-preflight-CARAVcz-.js → audio-preflight-Cu4alGjb.js} +26 -26
- package/dist/plugin-sdk/{audit-ByK45Q1d.js → audit-BTskqjJ_.js} +1 -1
- package/dist/plugin-sdk/{channel-access-BEin0yA4.js → channel-access-B1KciKmw.js} +1 -1
- package/dist/plugin-sdk/{channel-access-configure-Di_DoR-Q.js → channel-access-configure-Y91FLOJc.js} +1 -1
- package/dist/plugin-sdk/channel-plugin-common.d.ts +2 -2
- package/dist/plugin-sdk/channel-plugin-common.js +4 -4
- package/dist/plugin-sdk/{chunk-CwN3c1Fq.js → chunk-CSUjIQSx.js} +1 -1
- package/dist/plugin-sdk/{chunk-items-DH7ooQBZ.js → chunk-items-Q8HhMuSe.js} +1 -1
- package/dist/plugin-sdk/command-status.js +26 -26
- package/dist/plugin-sdk/{commands-registry-Bea-V_lR.js → commands-registry-DJ0pfCcY.js} +2 -2
- package/dist/plugin-sdk/{common-BJPuBxmx.js → common-Cjm8psuW.js} +1 -1
- package/dist/plugin-sdk/{config-BxOWD3gF.js → config-DutIeFge.js} +21 -3
- package/dist/plugin-sdk/{config-schema-ChJcPn7x.js → config-schema-Cg6PYSHR.js} +85 -64
- package/dist/plugin-sdk/device-pair.d.ts +1 -1
- package/dist/plugin-sdk/discord.d.ts +4 -4
- package/dist/plugin-sdk/discord.js +19 -19
- package/dist/plugin-sdk/{handle-action-Bk-L2J84.js → handle-action-Dp2741iu.js} +13 -13
- package/dist/plugin-sdk/{helpers-0E444CR0.js → helpers-BCZ9d3fl.js} +1 -1
- package/dist/plugin-sdk/{image-ops-BYc-Ol7C.js → image-ops-B-QR_M9Z.js} +1 -1
- package/dist/plugin-sdk/index.d.ts +20 -20
- package/dist/plugin-sdk/index.js +28 -28
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{login-B_At7IVI.js → login-BFvQxf9o.js} +3 -3
- package/dist/plugin-sdk/{login-qr-BlSQ8QJF.js → login-qr-CERTe_nD.js} +3 -3
- package/dist/plugin-sdk/{manager-VNI6sxbG.js → manager-Dhq3SXpO.js} +2 -2
- package/dist/plugin-sdk/{markdown-tables-CpNefu6e.js → markdown-tables-B1Tx7c77.js} +1 -1
- package/dist/plugin-sdk/{media-QBCmvhBQ.js → media-BwsqooWC.js} +2 -2
- package/dist/plugin-sdk/{monitor-C9UczH5N.js → monitor-BYzN5Qr4.js} +31 -31
- package/dist/plugin-sdk/{monitor-BhHlerHI.js → monitor-CJiacqtR.js} +30 -30
- package/dist/plugin-sdk/{openresponses-http-CtuFHD5w.js → openresponses-http-VLSSqCZZ.js} +26 -26
- package/dist/plugin-sdk/{optional-runtime-dependency-BaVO1F3i.js → optional-runtime-dependency-BEBP4VFJ.js} +1 -1
- package/dist/plugin-sdk/{outbound-CWrcAWpE.js → outbound-BqWgaC5M.js} +6 -6
- package/dist/plugin-sdk/{outbound-attachment-Dhi2Q-_f.js → outbound-attachment-L1q40kiu.js} +2 -2
- package/dist/plugin-sdk/{pairing-message-D01_6FkJ.js → pairing-message-CZBahREg.js} +1 -1
- package/dist/plugin-sdk/{pairing-message-6XVXW554.d.ts → pairing-message-DWXHX-jt.d.ts} +1 -1
- package/dist/plugin-sdk/{pairing-store-DADXOv-J.js → pairing-store-D7I1Qmiw.js} +2 -2
- package/dist/plugin-sdk/{pi-model-discovery-D9-CQFS2.js → pi-model-discovery-C5klknQZ.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-DhNNXQgq.js → pi-model-discovery-runtime-DIEMhCZ5.js} +2 -2
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +1 -1
- package/dist/plugin-sdk/{pw-ai-CQG7vp-Y.js → pw-ai-Bv-q25gY.js} +3 -3
- package/dist/plugin-sdk/{replies-C_FeIOF4.js → replies-Bd9ktEkq.js} +2 -2
- package/dist/plugin-sdk/{resolve-outbound-target-DD8edEdz.js → resolve-outbound-target-CCIyBb5H.js} +1 -1
- package/dist/plugin-sdk/{resolve-route-BPkfG5Pg.js → resolve-route-B7vZ3nKp.js} +1 -1
- package/dist/plugin-sdk/{retry-policy-C0YsRX_6.js → retry-policy-ChC3G4lv.js} +1 -1
- package/dist/plugin-sdk/{runtime-CyTWeylK.js → runtime-BLknHFGz.js} +3 -3
- package/dist/plugin-sdk/{runtime-dependency-D6tYtvtU.js → runtime-dependency-C5rJfC0u.js} +2 -2
- package/dist/plugin-sdk/sat-runtime.d.ts +3 -2
- package/dist/plugin-sdk/sat-runtime.js +5 -5
- package/dist/plugin-sdk/{send-CNxLDNQ9.js → send-Bd3Z-jAd.js} +6 -6
- package/dist/plugin-sdk/{send-Qckp3h4k.js → send-Bmtz9ICm.js} +8 -8
- package/dist/plugin-sdk/{send-BedQ8ekw.js → send-CMoWt-EX.js} +7 -7
- package/dist/plugin-sdk/{send-FcEJfLTd.js → send-CUGEhiUa.js} +6 -6
- package/dist/plugin-sdk/{send-BtFuV6zU.js → send-mkyZzhCO.js} +5 -5
- package/dist/plugin-sdk/{session-C3Ul4abD.js → session-D2zmelOL.js} +2 -2
- package/dist/plugin-sdk/{skill-commands-C2CnUTPX.js → skill-commands-BybEjJ1_.js} +2 -2
- package/dist/plugin-sdk/{slack-bSeSOI9d.js → slack-DogXvGG3.js} +38 -38
- package/dist/plugin-sdk/{slack-actions-CLyEd8FK.js → slack-actions-uXb55QWW.js} +11 -11
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/slack.js +9 -9
- package/dist/plugin-sdk/{sticker-cache-DBnS3hHh.js → sticker-cache-BuPw7fTf.js} +3 -3
- package/dist/plugin-sdk/{tables-L5mXZ5y_.js → tables-CVDOT5dX.js} +1 -1
- package/dist/plugin-sdk/{targets-eG595pY0.js → targets-DskkhJAp.js} +1 -1
- package/dist/plugin-sdk/{telegram-actions-D0Kyqy_e.js → telegram-actions-_KQPbjpI.js} +29 -29
- package/dist/plugin-sdk/telegram.d.ts +4 -4
- package/dist/plugin-sdk/telegram.js +8 -8
- package/dist/plugin-sdk/{thread-bindings.lifecycle-C_5BEWmL.js → thread-bindings.lifecycle-CrhQXYEU.js} +3 -3
- package/dist/plugin-sdk/{thread-bindings.state-DRZAbcUu.js → thread-bindings.state-ssxdG7xV.js} +2 -2
- package/dist/plugin-sdk/{tmp-fased-dir-BpMLNd4L.d.ts → tmp-fased-dir-Be1wBhVz.d.ts} +1 -1
- package/dist/plugin-sdk/{types-0CsXVmg8.d.ts → types-CJGVZX6j.d.ts} +1 -1
- package/dist/plugin-sdk/{types-DMLEeE52.d.ts → types-CXLEOrJX.d.ts} +1 -1
- package/dist/plugin-sdk/{wallet-status-2yrXvqSS.js → wallet-status-CQI89c_6.js} +70 -28
- package/dist/plugin-sdk/{web-CSRe4zy2.js → web-C8DwA0eO.js} +31 -31
- package/dist/plugin-sdk/{whatsapp-actions-CkLkpg8M.js → whatsapp-actions-DfvM-mlZ.js} +13 -13
- package/dist/plugin-sdk/{whatsapp-heartbeat-DuAE9_88.js → whatsapp-heartbeat-DyJasLDB.js} +2 -2
- package/dist/plugin-sdk/whatsapp.d.ts +13 -13
- package/dist/plugin-sdk/whatsapp.js +12 -12
- package/dist/plugin-sdk/{wsl-CXVwPntb.js → wsl-JwmI6Zu8.js} +3 -3
- package/dist/plugin-sdk/{zod-schema.providers-core-FaYR6KdD.d.ts → zod-schema.providers-core-BE_5DNhj.d.ts} +80 -80
- 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/index.ts +1 -1
- package/extensions/sat-mining/package.json +1 -1
- package/extensions/sat-mining/src/protocol-contract.ts +64 -0
- package/extensions/sat-mining/src/round-watcher.ts +6 -4
- package/extensions/sat-mining/src/solana-submit.ts +7 -53
- 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
|
@@ -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
|
|
@@ -26,7 +26,7 @@ function buildHostedSystemctlControlArgs(action) {
|
|
|
26
26
|
}
|
|
27
27
|
async function readHostedSystemdCommand(unitPath) {
|
|
28
28
|
try {
|
|
29
|
-
const content = await fs.readFile(unitPath, "utf8");
|
|
29
|
+
const content = await fs$1.readFile(unitPath, "utf8");
|
|
30
30
|
let workingDirectory = "";
|
|
31
31
|
let execStart = "";
|
|
32
32
|
const environment = {};
|
|
@@ -150,7 +150,7 @@ function buildHostedSystemdUnit(params) {
|
|
|
150
150
|
return lines.join("\n");
|
|
151
151
|
}
|
|
152
152
|
async function runHelper(unit, runAsUser) {
|
|
153
|
-
await fs.access(INSTALL_HELPER);
|
|
153
|
+
await fs$1.access(INSTALL_HELPER);
|
|
154
154
|
await new Promise((resolve, reject) => {
|
|
155
155
|
const child = spawn("sudo", [
|
|
156
156
|
"-n",
|
|
@@ -205,8 +205,8 @@ async function installHostedSystemdService(params) {
|
|
|
205
205
|
`${SERVICE_NAME}.service`
|
|
206
206
|
]).catch(() => undefined);
|
|
207
207
|
const userUnit = path.join(os.homedir(), ".config", "systemd", "user", `${SERVICE_NAME}.service`);
|
|
208
|
-
await fs.rm(userUnit, { force: true }).catch(() => undefined);
|
|
209
|
-
await fs.rm(`${userUnit}.d`, {
|
|
208
|
+
await fs$1.rm(userUnit, { force: true }).catch(() => undefined);
|
|
209
|
+
await fs$1.rm(`${userUnit}.d`, {
|
|
210
210
|
recursive: true,
|
|
211
211
|
force: true
|
|
212
212
|
}).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()) {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region extensions/sat-mining/src/protocol-contract.ts
|
|
2
|
+
const SAT_INSTRUCTION_DISCRIMINATORS = {
|
|
3
|
+
bootstrap: 34,
|
|
4
|
+
initializeCycle: 38,
|
|
5
|
+
finalizeEpoch: 43,
|
|
6
|
+
openRound: 44,
|
|
7
|
+
submitValidatorAttestation: 45,
|
|
8
|
+
openDispute: 46,
|
|
9
|
+
claim: 47,
|
|
10
|
+
resolveDispute: 48,
|
|
11
|
+
republishEpochRoots: 49,
|
|
12
|
+
submitParticipation: 52,
|
|
13
|
+
initMinerCapital: 36,
|
|
14
|
+
depositMinerCapital: 37,
|
|
15
|
+
openCycle: 56,
|
|
16
|
+
submitCycle: 57,
|
|
17
|
+
claimCycleRewards: 59,
|
|
18
|
+
retargetUnlock: 60,
|
|
19
|
+
claimCycleRewardsBatch: 62,
|
|
20
|
+
settleCyclePage: 63,
|
|
21
|
+
finalizeCycleSettlement: 64,
|
|
22
|
+
scoreCyclePage: 65,
|
|
23
|
+
distributeCyclePage: 66,
|
|
24
|
+
withdrawMinerCapital: 67,
|
|
25
|
+
setActiveCommit: 68,
|
|
26
|
+
closeResolvedMinerCycleState: 69,
|
|
27
|
+
closeResolvedCycleRegistryPage: 70,
|
|
28
|
+
closeResolvedCycleArtifacts: 71,
|
|
29
|
+
compactPendingCycleRange: 75,
|
|
30
|
+
setProtocolRecipients: 76,
|
|
31
|
+
claimProtocolTreasury: 77,
|
|
32
|
+
openBondPosition: 79,
|
|
33
|
+
increaseBondPosition: 80,
|
|
34
|
+
requestBondUnlock: 81,
|
|
35
|
+
cancelBondUnlock: 82,
|
|
36
|
+
finalizeBondUnlock: 83,
|
|
37
|
+
claimProtocolDistributorSat: 85,
|
|
38
|
+
refillRegistryReserveFromTreasury: 88,
|
|
39
|
+
miningCrank: 33
|
|
40
|
+
};
|
|
41
|
+
const SAT_BOND_INSTRUCTION_DISCRIMINATORS = {
|
|
42
|
+
initTierPolicy: 0,
|
|
43
|
+
updateTierPolicy: 1,
|
|
44
|
+
openBondPosition: 2,
|
|
45
|
+
increaseBondPosition: 3,
|
|
46
|
+
requestBondUnlock: 4,
|
|
47
|
+
cancelBondUnlock: 5,
|
|
48
|
+
finalizeBondUnlock: 6,
|
|
49
|
+
initStakingDistributor: 7,
|
|
50
|
+
syncStakingRewards: 8,
|
|
51
|
+
syncStakingPosition: 9,
|
|
52
|
+
claimStakingRewards: 10
|
|
53
|
+
};
|
|
54
|
+
const SAT_PROTOCOL_CONSTANTS = {
|
|
55
|
+
allocationBuckets: 25,
|
|
56
|
+
cycleSeconds: 300,
|
|
57
|
+
cycleErosionPpm: 83n,
|
|
58
|
+
minimumEntryLamports: 25e7,
|
|
59
|
+
registryReserveTargetLamports: 200000000n
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { SAT_BOND_INSTRUCTION_DISCRIMINATORS, SAT_INSTRUCTION_DISCRIMINATORS };
|
|
@@ -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;
|
|
@@ -8,6 +8,7 @@ import { enforceWalletCustodyForAutonomousSend } from "../../../wallet/wallet-cu
|
|
|
8
8
|
import "../../../plugin-sdk/sat-runtime.js";
|
|
9
9
|
import { inspectSatCycleRegistryMeta, inspectSatMinerCyclesByAddress } from "./rpc-read.js";
|
|
10
10
|
import { decodeHash32 } from "./hash-spec.js";
|
|
11
|
+
import { SAT_BOND_INSTRUCTION_DISCRIMINATORS, SAT_INSTRUCTION_DISCRIMINATORS } from "./protocol-contract.js";
|
|
11
12
|
import { createRequire } from "node:module";
|
|
12
13
|
|
|
13
14
|
//#region extensions/sat-mining/src/solana-submit.ts
|
|
@@ -41,58 +42,8 @@ const MINING_POOL_SEED = "mining_pool";
|
|
|
41
42
|
const MINING_STAKE_SEED = "mining_stake";
|
|
42
43
|
const TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
43
44
|
const ASSOCIATED_TOKEN_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
44
|
-
const IX =
|
|
45
|
-
|
|
46
|
-
initializeCycle: 38,
|
|
47
|
-
finalizeEpoch: 43,
|
|
48
|
-
openRound: 44,
|
|
49
|
-
submitValidatorAttestation: 45,
|
|
50
|
-
openDispute: 46,
|
|
51
|
-
claim: 47,
|
|
52
|
-
resolveDispute: 48,
|
|
53
|
-
republishEpochRoots: 49,
|
|
54
|
-
submitParticipation: 52,
|
|
55
|
-
initMinerCapital: 36,
|
|
56
|
-
depositMinerCapital: 37,
|
|
57
|
-
openCycle: 56,
|
|
58
|
-
submitCycle: 57,
|
|
59
|
-
claimCycleRewards: 59,
|
|
60
|
-
retargetUnlock: 60,
|
|
61
|
-
claimCycleRewardsBatch: 62,
|
|
62
|
-
settleCyclePage: 63,
|
|
63
|
-
finalizeCycleSettlement: 64,
|
|
64
|
-
scoreCyclePage: 65,
|
|
65
|
-
distributeCyclePage: 66,
|
|
66
|
-
withdrawMinerCapital: 67,
|
|
67
|
-
setActiveCommit: 68,
|
|
68
|
-
closeResolvedMinerCycleState: 69,
|
|
69
|
-
closeResolvedCycleRegistryPage: 70,
|
|
70
|
-
closeResolvedCycleArtifacts: 71,
|
|
71
|
-
compactPendingCycleRange: 75,
|
|
72
|
-
setProtocolRecipients: 76,
|
|
73
|
-
claimProtocolTreasury: 77,
|
|
74
|
-
claimProtocolDistributorSat: 85,
|
|
75
|
-
refillRegistryReserveFromTreasury: 88,
|
|
76
|
-
openBondPosition: 79,
|
|
77
|
-
increaseBondPosition: 80,
|
|
78
|
-
requestBondUnlock: 81,
|
|
79
|
-
cancelBondUnlock: 82,
|
|
80
|
-
finalizeBondUnlock: 83,
|
|
81
|
-
miningCrank: 33
|
|
82
|
-
};
|
|
83
|
-
const BOND_IX = {
|
|
84
|
-
initTierPolicy: 0,
|
|
85
|
-
updateTierPolicy: 1,
|
|
86
|
-
openBondPosition: 2,
|
|
87
|
-
increaseBondPosition: 3,
|
|
88
|
-
requestBondUnlock: 4,
|
|
89
|
-
cancelBondUnlock: 5,
|
|
90
|
-
finalizeBondUnlock: 6,
|
|
91
|
-
initStakingDistributor: 7,
|
|
92
|
-
syncStakingRewards: 8,
|
|
93
|
-
syncStakingPosition: 9,
|
|
94
|
-
claimStakingRewards: 10
|
|
95
|
-
};
|
|
45
|
+
const IX = SAT_INSTRUCTION_DISCRIMINATORS;
|
|
46
|
+
const BOND_IX = SAT_BOND_INSTRUCTION_DISCRIMINATORS;
|
|
96
47
|
function satSubmitDebug(message) {
|
|
97
48
|
if (String(process.env.FASED_SAT_SUBMIT_DEBUG ?? "").trim() === "1") {
|
|
98
49
|
console.error(message);
|
|
@@ -2,7 +2,7 @@ import { openBoundaryFileSync } from "../infra/boundary-file-read.js";
|
|
|
2
2
|
import { isWithinDir } from "../infra/path-safety.js";
|
|
3
3
|
import { normalizeControlUiBasePath } from "./control-ui-shared.js";
|
|
4
4
|
import { resolveControlUiRootSync } from "../infra/control-ui-assets.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 { resolveControlUiRootSync } from "../infra/control-ui-assets.js";
|
|
|
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,
|