@fased/fased 0.1.49 → 0.1.52
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 +45 -0
- 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/model-catalog-source.js +28 -3
- 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/provider-id.js +1 -1
- 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 +50 -0
- 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/update-command.js +120 -0
- 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-6iCry787.js → app-Bf5WlHKE.js} +1743 -1738
- package/dist/control-ui/assets/{chat-model-ref-C6CFR-GR.js → chat-model-ref-NT82zapt.js} +2 -2
- package/dist/control-ui/assets/{index-CNFgocD9.js → index-DWM6gKjy.js} +3 -3
- package/dist/control-ui/assets/{providers-WTJ1kMKy.js → providers-rQMhp1fb.js} +2 -11
- package/dist/control-ui/index.html +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/probe-payload.js +14 -0
- package/dist/gateway/probe.js +8 -4
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http-lazy.js +2 -4
- package/dist/gateway/server-http.js +6 -8
- package/dist/gateway/server-methods/chat.js +3 -3
- package/dist/gateway/server-methods/models.js +3 -2
- 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-precheck.js +1 -1
- 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/{accounts-B5fY9hZy.js → accounts-BZrfqJmO.js} +1 -1
- package/dist/plugin-sdk/{actions-D-9SsSEy.js → actions-7_zTh8zC.js} +2 -2
- package/dist/plugin-sdk/{active-listener-BH7rDR47.js → active-listener-D8NVRD8J.js} +1 -1
- package/dist/plugin-sdk/{audio-preflight-4faayz5S.js → audio-preflight-D6IPconF.js} +26 -26
- package/dist/plugin-sdk/{audit-BQfsboqd.js → audit-2iRlVyQF.js} +1 -1
- package/dist/plugin-sdk/{channel-access-CDZ-cJPq.js → channel-access-BCf1rJsn.js} +1 -1
- package/dist/plugin-sdk/{channel-access-configure-DlpuhlH6.js → channel-access-configure-B-Z51Qsd.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-CZuCyS7k.js → chunk-BREC9ijl.js} +1 -1
- package/dist/plugin-sdk/{chunk-items-Cyc4Kl6A.js → chunk-items-CTp30xzl.js} +1 -1
- package/dist/plugin-sdk/command-status.js +26 -26
- package/dist/plugin-sdk/{commands-registry-COIbIjGO.js → commands-registry-D3-bFLsz.js} +2 -2
- package/dist/plugin-sdk/{common-LMHJe8KW.js → common-BlqMqEqn.js} +1 -1
- package/dist/plugin-sdk/{config-ZMbTT0kM.js → config-442EDe7Z.js} +81 -13
- package/dist/plugin-sdk/{config-schema-Cku0a8Tm.js → config-schema-DAyzv2C6.js} +2001 -449
- 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-C8ZZfORB.js → handle-action-pNaP87Dr.js} +13 -13
- package/dist/plugin-sdk/{helpers-vfzH9tBn.js → helpers-B994qqVW.js} +1 -1
- package/dist/plugin-sdk/{image-ops-BnOmQA5d.js → image-ops-Doq8nZQw.js} +1 -1
- package/dist/plugin-sdk/index.d.ts +18 -18
- package/dist/plugin-sdk/index.js +28 -28
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{login-C73Wpiw8.js → login-CK2zTIJA.js} +3 -3
- package/dist/plugin-sdk/{login-qr-CRKHA7i8.js → login-qr-u8Mn1mCp.js} +3 -3
- package/dist/plugin-sdk/{manager-CHYhpKHn.js → manager-CeJNf2bH.js} +2 -2
- package/dist/plugin-sdk/{markdown-tables-B84dPWNG.js → markdown-tables-DeZztrY6.js} +1 -1
- package/dist/plugin-sdk/{media-4daDcNER.js → media-CgUAEfhs.js} +2 -2
- package/dist/plugin-sdk/{monitor-DJhU-J5u.js → monitor-CY1W4VTW.js} +31 -31
- package/dist/plugin-sdk/{monitor-CChc6bQV.js → monitor-CkDlxeW5.js} +30 -30
- package/dist/plugin-sdk/{openresponses-http-Dvyczr35.js → openresponses-http-Cu7NLyPf.js} +26 -26
- package/dist/plugin-sdk/{optional-runtime-dependency-BFpqaCzp.js → optional-runtime-dependency-D0BdXz1C.js} +1 -1
- package/dist/plugin-sdk/{outbound-C1xBxfNb.js → outbound-DXGuFrdx.js} +6 -6
- package/dist/plugin-sdk/{outbound-attachment-DvcxPP7b.js → outbound-attachment-oxhGO33g.js} +2 -2
- package/dist/plugin-sdk/{pairing-message-DpYT614h.js → pairing-message-C29ixrvn.js} +1 -1
- package/dist/plugin-sdk/{pairing-message-DWXHX-jt.d.ts → pairing-message-DfIyssV_.d.ts} +1 -1
- package/dist/plugin-sdk/{pairing-store-CprpGco9.js → pairing-store-1kcsOWRs.js} +2 -2
- package/dist/plugin-sdk/{pi-model-discovery-BQ6fFRBA.js → pi-model-discovery-l-xqaEd0.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-BF_89lVj.js → pi-model-discovery-runtime-CibV8F8G.js} +2 -2
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +1 -1
- package/dist/plugin-sdk/{pw-ai-xgpIbHOr.js → pw-ai-9qEBW5-k.js} +3 -3
- package/dist/plugin-sdk/{replies-AzJ6U6Ut.js → replies-BX3L8fX7.js} +2 -2
- package/dist/plugin-sdk/{resolve-outbound-target-COo_TR7B.js → resolve-outbound-target-D0AK10E7.js} +1 -1
- package/dist/plugin-sdk/{resolve-route-CZFzHOIe.js → resolve-route-UO6XLYH3.js} +1 -1
- package/dist/plugin-sdk/{retry-policy-BSdqqXsI.js → retry-policy-C5N8JiHL.js} +1 -1
- package/dist/plugin-sdk/{runtime-CeoGffDi.js → runtime-Dnzwux3G.js} +3 -3
- package/dist/plugin-sdk/{runtime-dependency-Cvbs0GXf.js → runtime-dependency-BDDpVKBO.js} +2 -2
- package/dist/plugin-sdk/sat-runtime.d.ts +2 -2
- package/dist/plugin-sdk/sat-runtime.js +5 -5
- package/dist/plugin-sdk/{send-B_-UtG9F.js → send-B4XLsTL0.js} +6 -6
- package/dist/plugin-sdk/{send-DCxAv7bV.js → send-D5rgCP1r.js} +6 -6
- package/dist/plugin-sdk/{send-CGE7OgsA.js → send-DGEgo_6f.js} +5 -5
- package/dist/plugin-sdk/{send-DVpCBUuL.js → send-DcsYRH2f.js} +7 -7
- package/dist/plugin-sdk/{send-C0Q1u7N1.js → send-bcKv8F5E.js} +8 -8
- package/dist/plugin-sdk/{session-ETYBbhLn.js → session-BoGNOlwv.js} +2 -2
- package/dist/plugin-sdk/{skill-commands-BQL6TBIv.js → skill-commands-Be8s4TGQ.js} +2 -2
- package/dist/plugin-sdk/{slack-actions-CBPZkfTS.js → slack-actions-TNnAXiUx.js} +11 -11
- package/dist/plugin-sdk/{slack-Bs_4uivd.js → slack-papUjf_h.js} +38 -38
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/slack.js +9 -9
- package/dist/plugin-sdk/{sticker-cache-BBZMp-oQ.js → sticker-cache-CPNu_LEe.js} +3 -3
- package/dist/plugin-sdk/{tables-B-G7Bb0l.js → tables-Ch4js2qy.js} +1 -1
- package/dist/plugin-sdk/{targets-D8UaoWHd.js → targets-BGfRUJPE.js} +1 -1
- package/dist/plugin-sdk/{telegram-actions-BARLx9zc.js → telegram-actions-BO-giM1s.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-DwYKCLLq.js → thread-bindings.lifecycle-_uQ2EF17.js} +3 -3
- package/dist/plugin-sdk/{thread-bindings.state-BNWfHA0f.js → thread-bindings.state-DUg0s_1X.js} +2 -2
- package/dist/plugin-sdk/{tmp-fased-dir-Be1wBhVz.d.ts → tmp-fased-dir-Bcp1DTSV.d.ts} +1 -1
- package/dist/plugin-sdk/{types-CJGVZX6j.d.ts → types-BTkcYtOt.d.ts} +2 -2
- package/dist/plugin-sdk/{types-CXLEOrJX.d.ts → types-CMoLtViq.d.ts} +1 -1
- package/dist/plugin-sdk/{wallet-status-Coekn_SJ.js → wallet-status-M6aK3abH.js} +3 -3
- package/dist/plugin-sdk/{web-BwolzGVF.js → web-QpstZjDX.js} +31 -31
- package/dist/plugin-sdk/{whatsapp-actions-CSvf6eev.js → whatsapp-actions-CID_tqAX.js} +13 -13
- package/dist/plugin-sdk/{whatsapp-heartbeat-Bw7OtTe6.js → whatsapp-heartbeat-Bk-aZVMa.js} +2 -2
- package/dist/plugin-sdk/whatsapp.d.ts +9 -9
- package/dist/plugin-sdk/whatsapp.js +12 -12
- package/dist/plugin-sdk/{wsl-By1Mc-oS.js → wsl-C_STtED7.js} +3 -3
- package/dist/plugin-sdk/{zod-schema.providers-core-TI6sL-6B.d.ts → zod-schema.providers-core-CIzCjXH9.d.ts} +75 -75
- 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 +10 -10
- package/dist/plugins/update.js +3 -3
- package/dist/plugins/web-search-install-catalog.js +3 -3
- package/dist/providers/refresh.js +1 -1
- package/dist/providers/refreshed-model-capabilities.js +1935 -406
- package/dist/providers/registry.js +15 -12
- 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 +18 -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 +18 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +18 -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 +18 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +18 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +18 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +18 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +1 -1
- package/scripts/start-managed.sh +14 -0
|
@@ -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);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveRuntimeServiceVersion, resolveRuntimeSource } from "../version.js";
|
|
2
|
+
|
|
3
|
+
//#region src/gateway/probe-payload.ts
|
|
4
|
+
function buildGatewayProbePayload(status) {
|
|
5
|
+
return {
|
|
6
|
+
ok: true,
|
|
7
|
+
status,
|
|
8
|
+
version: resolveRuntimeServiceVersion(process.env, "dev"),
|
|
9
|
+
runtimeSource: resolveRuntimeSource(process.env)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { buildGatewayProbePayload };
|
package/dist/gateway/probe.js
CHANGED
|
@@ -44,7 +44,8 @@ async function probeGateway(opts) {
|
|
|
44
44
|
reason
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
|
-
|
|
47
|
+
tlsFingerprint: opts.tlsFingerprint,
|
|
48
|
+
onHelloOk: async (hello) => {
|
|
48
49
|
connectLatencyMs = Date.now() - startedAt;
|
|
49
50
|
try {
|
|
50
51
|
const [health, status, presence, configSnapshot] = await Promise.all([
|
|
@@ -61,7 +62,8 @@ async function probeGateway(opts) {
|
|
|
61
62
|
health,
|
|
62
63
|
status,
|
|
63
64
|
presence: Array.isArray(presence) ? presence : null,
|
|
64
|
-
configSnapshot
|
|
65
|
+
configSnapshot,
|
|
66
|
+
server: hello.server
|
|
65
67
|
});
|
|
66
68
|
} catch (err) {
|
|
67
69
|
settle({
|
|
@@ -72,7 +74,8 @@ async function probeGateway(opts) {
|
|
|
72
74
|
health: null,
|
|
73
75
|
status: null,
|
|
74
76
|
presence: null,
|
|
75
|
-
configSnapshot: null
|
|
77
|
+
configSnapshot: null,
|
|
78
|
+
server: hello.server
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -86,7 +89,8 @@ async function probeGateway(opts) {
|
|
|
86
89
|
health: null,
|
|
87
90
|
status: null,
|
|
88
91
|
presence: null,
|
|
89
|
-
configSnapshot: null
|
|
92
|
+
configSnapshot: null,
|
|
93
|
+
server: null
|
|
90
94
|
});
|
|
91
95
|
}, Math.max(250, opts.timeoutMs));
|
|
92
96
|
client.start();
|
|
@@ -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();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildGatewayProbePayload } from "./probe-payload.js";
|
|
1
2
|
import { createServer } from "node:http";
|
|
2
3
|
import { createServer as createServer$1 } from "node:https";
|
|
3
4
|
|
|
@@ -35,10 +36,7 @@ function handleGatewayProbeRequest(req, res, opts) {
|
|
|
35
36
|
return true;
|
|
36
37
|
}
|
|
37
38
|
res.statusCode = 200;
|
|
38
|
-
res.end(method === "HEAD" ? undefined : JSON.stringify(
|
|
39
|
-
ok: true,
|
|
40
|
-
status
|
|
41
|
-
}));
|
|
39
|
+
res.end(method === "HEAD" ? undefined : JSON.stringify(buildGatewayProbePayload(status)));
|
|
42
40
|
return true;
|
|
43
41
|
}
|
|
44
42
|
function createGatewayHttpServer(opts) {
|
|
@@ -47,10 +47,11 @@ import { extractHookToken, getHookAgentPolicyError, getHookChannelError, isHookA
|
|
|
47
47
|
import { sendGatewayAuthFailure, setDefaultSecurityHeaders } from "./http-common.js";
|
|
48
48
|
import { getBearerToken, getHeader } from "./http-utils.js";
|
|
49
49
|
import { handleOpenAiHttpRequest } from "./openai-http.js";
|
|
50
|
+
import { buildGatewayProbePayload } from "./probe-payload.js";
|
|
50
51
|
import { canonicalizePathVariant } from "./security-path.js";
|
|
51
52
|
import { handleToolsInvokeHttpRequest } from "./tools-invoke-http.js";
|
|
52
53
|
import { authorizeGatewayConnect, isLocalDirectRequest } from "./auth.js";
|
|
53
|
-
import
|
|
54
|
+
import fs from "node:fs";
|
|
54
55
|
import path from "node:path";
|
|
55
56
|
import { createServer } from "node:http";
|
|
56
57
|
import { createServer as createServer$1 } from "node:https";
|
|
@@ -2101,7 +2102,7 @@ async function readLocalFederationStatus(env = process.env, fetchImpl = fetch) {
|
|
|
2101
2102
|
const sourcePath = path.join(resolveStateDir(env), "federation", "access-token.json");
|
|
2102
2103
|
const managed = (env.FASED_GATEWAY_MODE ?? "").trim().toLowerCase() === "managed";
|
|
2103
2104
|
const configured = resolveConfiguredFederationStatus(env);
|
|
2104
|
-
if (!
|
|
2105
|
+
if (!fs.existsSync(sourcePath)) {
|
|
2105
2106
|
return {
|
|
2106
2107
|
managed,
|
|
2107
2108
|
sourcePath,
|
|
@@ -2113,7 +2114,7 @@ async function readLocalFederationStatus(env = process.env, fetchImpl = fetch) {
|
|
|
2113
2114
|
}
|
|
2114
2115
|
let rawText = "";
|
|
2115
2116
|
try {
|
|
2116
|
-
rawText =
|
|
2117
|
+
rawText = fs.readFileSync(sourcePath, "utf-8");
|
|
2117
2118
|
} catch {
|
|
2118
2119
|
return {
|
|
2119
2120
|
managed,
|
|
@@ -2162,7 +2163,7 @@ async function readLocalFederationStatus(env = process.env, fetchImpl = fetch) {
|
|
|
2162
2163
|
const lifecycle = Number.isFinite(expiresAtMs) ? expiresAtMs > Date.now() ? "active" : "expired" : "invalid";
|
|
2163
2164
|
let fileUpdatedAt;
|
|
2164
2165
|
try {
|
|
2165
|
-
fileUpdatedAt =
|
|
2166
|
+
fileUpdatedAt = fs.statSync(sourcePath).mtime.toISOString();
|
|
2166
2167
|
} catch {
|
|
2167
2168
|
fileUpdatedAt = undefined;
|
|
2168
2169
|
}
|
|
@@ -2649,10 +2650,7 @@ async function handleGatewayProbeRequest(params) {
|
|
|
2649
2650
|
} : { ready: false });
|
|
2650
2651
|
}
|
|
2651
2652
|
} else {
|
|
2652
|
-
body = JSON.stringify(
|
|
2653
|
-
ok: true,
|
|
2654
|
-
status
|
|
2655
|
-
});
|
|
2653
|
+
body = JSON.stringify(buildGatewayProbePayload(status));
|
|
2656
2654
|
}
|
|
2657
2655
|
params.res.statusCode = statusCode;
|
|
2658
2656
|
params.res.end(method === "HEAD" ? undefined : body);
|
|
@@ -30,7 +30,7 @@ import { parseMessageWithAttachments } from "../chat-attachments.js";
|
|
|
30
30
|
import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js";
|
|
31
31
|
import { normalizeRpcAttachmentsToChatAttachments } from "./attachment-normalize.js";
|
|
32
32
|
import { appendInjectedAssistantMessageToTranscript } from "./chat-transcript-inject.js";
|
|
33
|
-
import
|
|
33
|
+
import fs from "node:fs";
|
|
34
34
|
import path from "node:path";
|
|
35
35
|
|
|
36
36
|
//#region src/gateway/server-methods/chat.ts
|
|
@@ -321,7 +321,7 @@ function resolveTranscriptPath(params) {
|
|
|
321
321
|
}
|
|
322
322
|
function transcriptHasIdempotencyKey(transcriptPath, idempotencyKey) {
|
|
323
323
|
try {
|
|
324
|
-
const lines =
|
|
324
|
+
const lines = fs.readFileSync(transcriptPath, "utf-8").split(/\r?\n/);
|
|
325
325
|
for (const line of lines) {
|
|
326
326
|
if (!line.trim()) {
|
|
327
327
|
continue;
|
|
@@ -349,7 +349,7 @@ function appendAssistantTranscriptMessage(params) {
|
|
|
349
349
|
error: "transcript path not resolved"
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
if (!
|
|
352
|
+
if (!fs.existsSync(transcriptPath)) {
|
|
353
353
|
if (!params.createIfMissing) {
|
|
354
354
|
return {
|
|
355
355
|
ok: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defaultRuntime } from "../../runtime.js";
|
|
2
2
|
import { resolveAgentDir, resolveDefaultAgentId, resolveSessionAgentId } from "../../agents/agent-scope.js";
|
|
3
|
-
import { listProviderBrandManifests } from "../../providers/registry.js";
|
|
3
|
+
import { isStandardProviderCatalogEntry, listProviderBrandManifests } from "../../providers/registry.js";
|
|
4
4
|
import { DEFAULT_PROVIDER } from "../../agents/defaults.js";
|
|
5
5
|
import { normalizeSecretInput } from "../../utils/normalize-secret-input.js";
|
|
6
6
|
import { normalizeProviderId } from "../../agents/provider-id.js";
|
|
@@ -862,7 +862,8 @@ const modelsHandlers = {
|
|
|
862
862
|
});
|
|
863
863
|
const providerFilter = typeof params.provider === "string" && params.provider.trim() ? normalizeProviderId(params.provider) : "";
|
|
864
864
|
const modelSource = params.all === true ? usableCatalog : allowedCatalog.length > 0 ? allowedCatalog : usableCatalog;
|
|
865
|
-
const
|
|
865
|
+
const curatedModelSource = params.all === true ? modelSource : modelSource.filter((model) => model.catalogSource === "configured" || isStandardProviderCatalogEntry(model));
|
|
866
|
+
const models = providerFilter ? curatedModelSource.filter((model) => normalizeProviderId(model.provider) === providerFilter) : curatedModelSource;
|
|
866
867
|
const payloadModels = params.includeMetadata === true ? models.map((model) => ({
|
|
867
868
|
...model,
|
|
868
869
|
metadata: model.metadata ?? deriveModelMetadata({
|
|
@@ -30,7 +30,7 @@ import { clearCheckpointBranchIsolationFields } from "../session-compaction-isol
|
|
|
30
30
|
import { applySessionsPatchToStore } from "../sessions-patch.js";
|
|
31
31
|
import { resolveSessionKeyFromResolveParams } from "../sessions-resolve.js";
|
|
32
32
|
import { assertValidParams } from "./validation.js";
|
|
33
|
-
import
|
|
33
|
+
import fs from "node:fs";
|
|
34
34
|
import path from "node:path";
|
|
35
35
|
import { randomUUID } from "node:crypto";
|
|
36
36
|
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
|
@@ -196,7 +196,7 @@ function resolveCheckpointSnapshotFile(params) {
|
|
|
196
196
|
return null;
|
|
197
197
|
}
|
|
198
198
|
try {
|
|
199
|
-
if (!
|
|
199
|
+
if (!fs.statSync(filePath).isFile()) {
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
202
202
|
} catch {
|
|
@@ -543,7 +543,7 @@ const sessionsHandlers = {
|
|
|
543
543
|
}
|
|
544
544
|
const cleanupRestoredFile = () => {
|
|
545
545
|
try {
|
|
546
|
-
|
|
546
|
+
fs.rmSync(sessionFile, { force: true });
|
|
547
547
|
} catch {}
|
|
548
548
|
};
|
|
549
549
|
const cleanupError = await ensureSessionRuntimeCleanup({
|
|
@@ -1068,7 +1068,7 @@ const sessionsHandlers = {
|
|
|
1068
1068
|
}, undefined);
|
|
1069
1069
|
return;
|
|
1070
1070
|
}
|
|
1071
|
-
const filePath = resolveSessionTranscriptCandidates(sessionId, storePath, entry?.sessionFile, target.agentId).find((candidate) =>
|
|
1071
|
+
const filePath = resolveSessionTranscriptCandidates(sessionId, storePath, entry?.sessionFile, target.agentId).find((candidate) => fs.existsSync(candidate));
|
|
1072
1072
|
if (!filePath) {
|
|
1073
1073
|
respond(true, {
|
|
1074
1074
|
ok: true,
|
|
@@ -1078,7 +1078,7 @@ const sessionsHandlers = {
|
|
|
1078
1078
|
}, undefined);
|
|
1079
1079
|
return;
|
|
1080
1080
|
}
|
|
1081
|
-
const raw =
|
|
1081
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
1082
1082
|
const lines = raw.split(/\r?\n/).filter((l) => l.trim().length > 0);
|
|
1083
1083
|
if (lines.length <= maxLines) {
|
|
1084
1084
|
respond(true, {
|
|
@@ -1096,7 +1096,7 @@ const sessionsHandlers = {
|
|
|
1096
1096
|
const archived = archiveFileOnDisk(filePath, "bak");
|
|
1097
1097
|
const keptLines = lines.slice(-maxLines);
|
|
1098
1098
|
try {
|
|
1099
|
-
|
|
1099
|
+
fs.writeFileSync(filePath, `${keptLines.join("\n")}\n`, "utf-8");
|
|
1100
1100
|
} catch (error) {
|
|
1101
1101
|
if (preCompactionSnapshot) {
|
|
1102
1102
|
cleanupSessionCompactionSnapshot(preCompactionSnapshot);
|
|
@@ -12,7 +12,7 @@ import { readCronRunLogEntriesPageAll } from "../../cron/run-log.js";
|
|
|
12
12
|
import { loadCronStore, resolveCronStorePath } from "../../cron/store.js";
|
|
13
13
|
import { discoverAllSessions, loadCostUsageSummary, loadSessionCostSummary, loadSessionUsageTimeSeries } from "../../infra/session-cost-usage.js";
|
|
14
14
|
import { buildUsageAggregateTail } from "../../shared/usage-aggregates.js";
|
|
15
|
-
import
|
|
15
|
+
import fs from "node:fs";
|
|
16
16
|
|
|
17
17
|
//#region src/gateway/server-methods/usage.ts
|
|
18
18
|
const COST_USAGE_CACHE_TTL_MS = 3e4;
|
|
@@ -662,7 +662,7 @@ const usageHandlers = {
|
|
|
662
662
|
return;
|
|
663
663
|
}
|
|
664
664
|
try {
|
|
665
|
-
const stats =
|
|
665
|
+
const stats = fs.statSync(sessionFile);
|
|
666
666
|
if (stats.isFile()) {
|
|
667
667
|
mergedEntries.push({
|
|
668
668
|
key: resolvedStoreKey,
|
|
@@ -68,7 +68,7 @@ import { createWizardSessionTracker } from "./server-wizard-sessions.js";
|
|
|
68
68
|
import { attachGatewayWsHandlers } from "./server-ws-runtime.js";
|
|
69
69
|
import { loadGatewayTlsRuntime } from "./server/tls.js";
|
|
70
70
|
import { createSessionEventSubscriberRegistry, createSessionMessageSubscriberRegistry } from "./session-event-subscribers.js";
|
|
71
|
-
import
|
|
71
|
+
import fs from "node:fs";
|
|
72
72
|
import path from "node:path";
|
|
73
73
|
|
|
74
74
|
//#region src/gateway/server.impl.ts
|
|
@@ -99,10 +99,10 @@ function hasConfiguredLocalSignerKeystoreMaterial(env) {
|
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
101
|
const materialDir = resolveLocalSignerMaterialRootDir(env);
|
|
102
|
-
if (!
|
|
102
|
+
if (!fs.existsSync(materialDir)) {
|
|
103
103
|
return false;
|
|
104
104
|
}
|
|
105
|
-
return
|
|
105
|
+
return fs.readdirSync(materialDir, { withFileTypes: true }).some((entry) => entry.isFile() && /^keystore-solana(?:-.+)?\.v1\.enc$/i.test(entry.name));
|
|
106
106
|
} catch {
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isSessionCompactionCheckpointArtifactName } from "../config/sessions/artifacts.js";
|
|
2
2
|
import "../config/sessions.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
|
|
@@ -88,7 +88,7 @@ function deleteCheckpointSnapshotIfSafe(filePath, expectedDir) {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
try {
|
|
91
|
-
|
|
91
|
+
fs.unlinkSync(resolved);
|
|
92
92
|
} catch {}
|
|
93
93
|
}
|
|
94
94
|
function cleanupSessionCompactionSnapshot(reference) {
|
|
@@ -105,7 +105,7 @@ function captureSessionCompactionSnapshot(params) {
|
|
|
105
105
|
const resolved = path.resolve(sessionFile);
|
|
106
106
|
let stat;
|
|
107
107
|
try {
|
|
108
|
-
stat =
|
|
108
|
+
stat = fs.statSync(resolved);
|
|
109
109
|
} catch {
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
@@ -123,7 +123,7 @@ function captureSessionCompactionSnapshot(params) {
|
|
|
123
123
|
const base = path.basename(resolved, ".jsonl");
|
|
124
124
|
const snapshotFile = path.join(dir, `${base}.checkpoint.${randomUUID()}.jsonl`);
|
|
125
125
|
try {
|
|
126
|
-
|
|
126
|
+
fs.copyFileSync(resolved, snapshotFile);
|
|
127
127
|
} catch {
|
|
128
128
|
return null;
|
|
129
129
|
}
|
|
@@ -7,7 +7,7 @@ import { extractToolCallNames, hasToolCall } from "../utils/transcript-tools.js"
|
|
|
7
7
|
import { stripEnvelope } from "../shared/chat-envelope.js";
|
|
8
8
|
import "./chat-sanitize.js";
|
|
9
9
|
import "../config/sessions.js";
|
|
10
|
-
import
|
|
10
|
+
import fs from "node:fs";
|
|
11
11
|
import os from "node:os";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
|
|
@@ -50,11 +50,11 @@ function setCachedSessionTitleFields(cacheKey, stat, value) {
|
|
|
50
50
|
}
|
|
51
51
|
function readSessionMessages(sessionId, storePath, sessionFile) {
|
|
52
52
|
const candidates = resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile);
|
|
53
|
-
const filePath = candidates.find((p) =>
|
|
53
|
+
const filePath = candidates.find((p) => fs.existsSync(p));
|
|
54
54
|
if (!filePath) {
|
|
55
55
|
return [];
|
|
56
56
|
}
|
|
57
|
-
const lines =
|
|
57
|
+
const lines = fs.readFileSync(filePath, "utf-8").split(/\r?\n/);
|
|
58
58
|
const messages = [];
|
|
59
59
|
for (const line of lines) {
|
|
60
60
|
if (!line.trim()) {
|
|
@@ -123,7 +123,7 @@ function resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile, a
|
|
|
123
123
|
function canonicalizePathForComparison(filePath) {
|
|
124
124
|
const resolved = path.resolve(filePath);
|
|
125
125
|
try {
|
|
126
|
-
return
|
|
126
|
+
return fs.realpathSync(resolved);
|
|
127
127
|
} catch {
|
|
128
128
|
return resolved;
|
|
129
129
|
}
|
|
@@ -131,7 +131,7 @@ function canonicalizePathForComparison(filePath) {
|
|
|
131
131
|
function archiveFileOnDisk(filePath, reason) {
|
|
132
132
|
const ts = formatSessionArchiveTimestamp();
|
|
133
133
|
const archived = `${filePath}.${reason}.${ts}`;
|
|
134
|
-
|
|
134
|
+
fs.renameSync(filePath, archived);
|
|
135
135
|
return archived;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
@@ -149,7 +149,7 @@ function archiveSessionTranscripts(opts) {
|
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
if (!
|
|
152
|
+
if (!fs.existsSync(candidatePath)) {
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
155
|
try {
|
|
@@ -171,7 +171,7 @@ async function cleanupArchivedSessionTranscripts(opts) {
|
|
|
171
171
|
let removed = 0;
|
|
172
172
|
let scanned = 0;
|
|
173
173
|
for (const dir of directories) {
|
|
174
|
-
const entries = await
|
|
174
|
+
const entries = await fs.promises.readdir(dir).catch(() => []);
|
|
175
175
|
for (const entry of entries) {
|
|
176
176
|
const timestamp = parseSessionArchiveTimestamp(entry, reason);
|
|
177
177
|
if (timestamp == null) {
|
|
@@ -182,11 +182,11 @@ async function cleanupArchivedSessionTranscripts(opts) {
|
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
184
|
const fullPath = path.join(dir, entry);
|
|
185
|
-
const stat = await
|
|
185
|
+
const stat = await fs.promises.stat(fullPath).catch(() => null);
|
|
186
186
|
if (!stat?.isFile()) {
|
|
187
187
|
continue;
|
|
188
188
|
}
|
|
189
|
-
await
|
|
189
|
+
await fs.promises.rm(fullPath).catch(() => undefined);
|
|
190
190
|
removed += 1;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -225,7 +225,7 @@ function capArrayByJsonBytes(items, maxBytes) {
|
|
|
225
225
|
const MAX_LINES_TO_SCAN = 10;
|
|
226
226
|
function readSessionTitleFieldsFromTranscript(sessionId, storePath, sessionFile, agentId, opts) {
|
|
227
227
|
const candidates = resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile, agentId);
|
|
228
|
-
const filePath = candidates.find((p) =>
|
|
228
|
+
const filePath = candidates.find((p) => fs.existsSync(p));
|
|
229
229
|
if (!filePath) {
|
|
230
230
|
return {
|
|
231
231
|
firstUserMessage: null,
|
|
@@ -234,7 +234,7 @@ function readSessionTitleFieldsFromTranscript(sessionId, storePath, sessionFile,
|
|
|
234
234
|
}
|
|
235
235
|
let stat;
|
|
236
236
|
try {
|
|
237
|
-
stat =
|
|
237
|
+
stat = fs.statSync(filePath);
|
|
238
238
|
} catch {
|
|
239
239
|
return {
|
|
240
240
|
firstUserMessage: null,
|
|
@@ -256,7 +256,7 @@ function readSessionTitleFieldsFromTranscript(sessionId, storePath, sessionFile,
|
|
|
256
256
|
}
|
|
257
257
|
let fd = null;
|
|
258
258
|
try {
|
|
259
|
-
fd =
|
|
259
|
+
fd = fs.openSync(filePath, "r");
|
|
260
260
|
const size = stat.size;
|
|
261
261
|
let firstUserMessage = null;
|
|
262
262
|
try {
|
|
@@ -286,7 +286,7 @@ function readSessionTitleFieldsFromTranscript(sessionId, storePath, sessionFile,
|
|
|
286
286
|
} finally {
|
|
287
287
|
if (fd !== null) {
|
|
288
288
|
try {
|
|
289
|
-
|
|
289
|
+
fs.closeSync(fd);
|
|
290
290
|
} catch {}
|
|
291
291
|
}
|
|
292
292
|
}
|
|
@@ -314,7 +314,7 @@ function extractTextFromContent(content) {
|
|
|
314
314
|
}
|
|
315
315
|
function readTranscriptHeadChunk(fd, maxBytes = 8192) {
|
|
316
316
|
const buf = Buffer.alloc(maxBytes);
|
|
317
|
-
const bytesRead =
|
|
317
|
+
const bytesRead = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
318
318
|
if (bytesRead <= 0) {
|
|
319
319
|
return null;
|
|
320
320
|
}
|
|
@@ -345,16 +345,16 @@ function extractFirstUserMessageFromTranscriptChunk(chunk, opts) {
|
|
|
345
345
|
}
|
|
346
346
|
function findExistingTranscriptPath(sessionId, storePath, sessionFile, agentId) {
|
|
347
347
|
const candidates = resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile, agentId);
|
|
348
|
-
return candidates.find((p) =>
|
|
348
|
+
return candidates.find((p) => fs.existsSync(p)) ?? null;
|
|
349
349
|
}
|
|
350
350
|
function withOpenTranscriptFd(filePath, read) {
|
|
351
351
|
let fd = null;
|
|
352
352
|
try {
|
|
353
|
-
fd =
|
|
353
|
+
fd = fs.openSync(filePath, "r");
|
|
354
354
|
return read(fd);
|
|
355
355
|
} catch {} finally {
|
|
356
356
|
if (fd !== null) {
|
|
357
|
-
|
|
357
|
+
fs.closeSync(fd);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
return null;
|
|
@@ -378,7 +378,7 @@ function readLastMessagePreviewFromOpenTranscript(params) {
|
|
|
378
378
|
const readStart = Math.max(0, params.size - LAST_MSG_MAX_BYTES);
|
|
379
379
|
const readLen = Math.min(params.size, LAST_MSG_MAX_BYTES);
|
|
380
380
|
const buf = Buffer.alloc(readLen);
|
|
381
|
-
|
|
381
|
+
fs.readSync(params.fd, buf, 0, readLen, readStart);
|
|
382
382
|
const chunk = buf.toString("utf-8");
|
|
383
383
|
const lines = chunk.split(/\r?\n/).filter((l) => l.trim());
|
|
384
384
|
const tailLines = lines.slice(-LAST_MSG_MAX_LINES);
|
|
@@ -404,7 +404,7 @@ function readLastMessagePreviewFromTranscript(sessionId, storePath, sessionFile,
|
|
|
404
404
|
return null;
|
|
405
405
|
}
|
|
406
406
|
return withOpenTranscriptFd(filePath, (fd) => {
|
|
407
|
-
const stat =
|
|
407
|
+
const stat = fs.fstatSync(fd);
|
|
408
408
|
const size = stat.size;
|
|
409
409
|
if (size === 0) {
|
|
410
410
|
return null;
|
|
@@ -522,8 +522,8 @@ function buildPreviewItems(messages, maxItems, maxChars) {
|
|
|
522
522
|
function readRecentMessagesFromTranscript(filePath, maxMessages, readBytes) {
|
|
523
523
|
let fd = null;
|
|
524
524
|
try {
|
|
525
|
-
fd =
|
|
526
|
-
const stat =
|
|
525
|
+
fd = fs.openSync(filePath, "r");
|
|
526
|
+
const stat = fs.fstatSync(fd);
|
|
527
527
|
const size = stat.size;
|
|
528
528
|
if (size === 0) {
|
|
529
529
|
return [];
|
|
@@ -531,7 +531,7 @@ function readRecentMessagesFromTranscript(filePath, maxMessages, readBytes) {
|
|
|
531
531
|
const readStart = Math.max(0, size - readBytes);
|
|
532
532
|
const readLen = Math.min(size, readBytes);
|
|
533
533
|
const buf = Buffer.alloc(readLen);
|
|
534
|
-
|
|
534
|
+
fs.readSync(fd, buf, 0, readLen, readStart);
|
|
535
535
|
const chunk = buf.toString("utf-8");
|
|
536
536
|
const lines = chunk.split(/\r?\n/).filter((l) => l.trim());
|
|
537
537
|
const tailLines = lines.slice(-PREVIEW_MAX_LINES);
|
|
@@ -554,13 +554,13 @@ function readRecentMessagesFromTranscript(filePath, maxMessages, readBytes) {
|
|
|
554
554
|
return [];
|
|
555
555
|
} finally {
|
|
556
556
|
if (fd !== null) {
|
|
557
|
-
|
|
557
|
+
fs.closeSync(fd);
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
function readSessionPreviewItemsFromTranscript(sessionId, storePath, sessionFile, agentId, maxItems, maxChars) {
|
|
562
562
|
const candidates = resolveSessionTranscriptCandidates(sessionId, storePath, sessionFile, agentId);
|
|
563
|
-
const filePath = candidates.find((p) =>
|
|
563
|
+
const filePath = candidates.find((p) => fs.existsSync(p));
|
|
564
564
|
if (!filePath) {
|
|
565
565
|
return [];
|
|
566
566
|
}
|