@fased/fased 0.1.42 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/client.js +2 -2
- package/dist/acp/secret-file.js +2 -2
- package/dist/agents/agent-scope.js +2 -2
- package/dist/agents/apply-patch.js +8 -8
- package/dist/agents/auth-profiles/paths.js +2 -2
- package/dist/agents/auth-profiles/store.js +2 -2
- package/dist/agents/bash-tools.shared.js +2 -2
- package/dist/agents/cli-credentials.js +4 -4
- package/dist/agents/docs-path.js +3 -3
- package/dist/agents/embedded-pi-mcp.js +4 -4
- package/dist/agents/identity-avatar.js +3 -3
- package/dist/agents/identity-file.js +2 -2
- package/dist/agents/pi-embedded-subscribe.raw-stream.js +3 -3
- package/dist/agents/pi-extensions/compaction-safeguard.js +3 -3
- package/dist/agents/pi-model-discovery.js +6 -6
- package/dist/agents/pi-project-settings.js +3 -3
- package/dist/agents/sandbox/fs-bridge.js +2 -2
- package/dist/agents/session-dirs.js +4 -4
- package/dist/agents/session-write-lock.js +13 -13
- package/dist/agents/shell-utils.js +5 -5
- package/dist/agents/skills/bundled-dir.js +4 -4
- package/dist/agents/skills/local-loader.js +6 -6
- package/dist/agents/skills/plugin-skills.js +2 -2
- package/dist/agents/skills/workspace.js +13 -13
- package/dist/agents/skills-install-download.js +7 -7
- package/dist/agents/skills-install-plan.js +2 -2
- package/dist/agents/skills-install.js +2 -2
- package/dist/agents/skills-status.js +2 -2
- package/dist/agents/subagent-depth.js +2 -2
- package/dist/agents/system-prompt-params.js +2 -2
- package/dist/agents/workspace.js +22 -22
- package/dist/auto-reply/reply/agent-runner-execution.js +2 -2
- package/dist/auto-reply/reply/agent-runner.js +2 -2
- package/dist/auto-reply/reply/commands-export-session.js +7 -7
- package/dist/auto-reply/reply/post-compaction-audit.js +3 -3
- package/dist/auto-reply/reply/post-compaction-context.js +3 -3
- package/dist/auto-reply/reply/session.js +3 -3
- package/dist/auto-reply/skill-commands.js +3 -3
- package/dist/auto-reply/status.js +6 -6
- package/dist/brand.js +1 -1
- package/dist/browser/chrome.executables.js +3 -3
- package/dist/browser/chrome.js +3 -3
- package/dist/browser/chrome.profile-decoration.js +6 -6
- package/dist/browser/profiles-service.js +2 -2
- package/dist/browser/server-context.js +2 -2
- package/dist/browser/trash.js +4 -4
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/canvas-host/server.js +4 -4
- package/dist/capabilities/catalog.js +3 -3
- package/dist/channels/plugins/catalog.js +3 -3
- package/dist/cli/browser-cli-extension.js +6 -6
- package/dist/cli/command-format.js +2 -2
- package/dist/cli/cron-cli/register.cron-simple.js +2 -2
- package/dist/cli/daemon-cli/restart-health.js +49 -13
- package/dist/cli/dns-cli.js +9 -9
- package/dist/cli/gateway-cli/dev.js +5 -5
- package/dist/cli/gateway-cli/run.js +2 -2
- package/dist/cli/hooks-cli.js +5 -5
- package/dist/cli/memory-cli.js +7 -7
- package/dist/cli/nodes-media-utils.js +2 -2
- package/dist/cli/plugins-cli.js +2 -2
- package/dist/cli/secrets-cli.js +3 -3
- package/dist/cli/update-cli/shared.js +1 -29
- package/dist/cli/update-cli/update-command.js +12 -15
- package/dist/cli/windows-argv.js +2 -2
- package/dist/commands/dashboard-link.js +3 -3
- package/dist/commands/doctor-install.js +5 -5
- package/dist/commands/doctor-memory-search.js +2 -2
- package/dist/commands/doctor-platform-notes.js +2 -2
- package/dist/commands/doctor-sandbox.js +2 -2
- package/dist/commands/doctor-state-integrity.js +23 -23
- package/dist/commands/doctor-workspace.js +3 -3
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/managed-up.js +2 -2
- package/dist/commands/onboard-auth.credentials.js +3 -3
- package/dist/commands/onboarding/plugin-install.js +2 -2
- package/dist/commands/sessions-cleanup.js +2 -2
- package/dist/commands/signal-install.js +6 -6
- package/dist/commands/status-all/channels.js +2 -2
- package/dist/commands/wallet.js +47 -47
- package/dist/config/cache-utils.js +2 -2
- package/dist/config/includes.js +5 -5
- package/dist/config/io.js +2 -2
- package/dist/config/paths.js +3 -3
- package/dist/config/sat-runtime-ids.js +3 -3
- package/dist/config/sessions/disk-budget.js +6 -6
- package/dist/config/sessions/paths.js +2 -2
- package/dist/config/sessions/store.js +17 -17
- package/dist/config/sessions/transcript.js +4 -4
- package/dist/config/talk.js +2 -2
- package/dist/cron/service/store.js +2 -2
- package/dist/cron/store.js +6 -6
- package/dist/daemon/systemd-system.js +5 -5
- package/dist/discord/monitor/thread-bindings.state.js +2 -2
- package/dist/extensions/sat-mining/src/sat-bond-layout.js +9 -9
- package/dist/gateway/control-ui-boot-check.js +6 -6
- package/dist/gateway/control-ui-login.js +7 -7
- package/dist/gateway/control-ui.js +9 -9
- package/dist/gateway/hooks-mapping.js +4 -4
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http.js +4 -4
- package/dist/gateway/server-methods/chat.js +6 -6
- package/dist/gateway/server-methods/sessions.js +6 -6
- package/dist/gateway/server-methods/usage.js +2 -2
- package/dist/gateway/server.impl.js +3 -3
- package/dist/gateway/session-compaction-checkpoints.js +4 -4
- package/dist/gateway/session-utils.fs.js +24 -24
- package/dist/gateway/session-utils.js +6 -6
- package/dist/hooks/bundled-dir.js +4 -4
- package/dist/hooks/gmail-setup-utils.js +6 -6
- package/dist/hooks/import-url.js +2 -2
- package/dist/hooks/loader.js +4 -4
- package/dist/hooks/workspace.js +7 -7
- package/dist/infra/archive.js +17 -17
- package/dist/infra/boundary-file-read.js +2 -2
- package/dist/infra/boundary-path.js +15 -15
- package/dist/infra/brew.js +2 -2
- package/dist/infra/control-ui-assets.js +14 -14
- package/dist/infra/device-auth-store.js +8 -8
- package/dist/infra/device-identity.js +8 -8
- package/dist/infra/dotenv.js +2 -2
- package/dist/infra/exec-approvals.js +8 -8
- package/dist/infra/exec-command-resolution.js +4 -4
- package/dist/infra/exec-safe-bin-trust.js +2 -2
- package/dist/infra/fased-root.js +5 -5
- package/dist/infra/fs-safe.js +14 -14
- package/dist/infra/gateway-lock.js +11 -11
- package/dist/infra/git-commit.js +5 -5
- package/dist/infra/git-root.js +4 -4
- package/dist/infra/hosted-runtime-artifact.js +3 -3
- package/dist/infra/is-main.js +2 -2
- package/dist/infra/json-file.js +7 -7
- package/dist/infra/outbound/delivery-queue.js +16 -16
- package/dist/infra/path-env.js +3 -3
- package/dist/infra/ports-lsof.js +4 -4
- package/dist/infra/provider-usage.auth.js +3 -3
- package/dist/infra/safe-open-sync.js +2 -2
- package/dist/infra/session-cost-usage.js +9 -9
- package/dist/infra/shell-env.js +2 -2
- package/dist/infra/state-migrations.fs.js +6 -6
- package/dist/infra/state-migrations.js +23 -23
- package/dist/infra/tmp-fased-dir.js +6 -6
- package/dist/infra/update-global.js +1 -0
- package/dist/infra/update-runner.js +111 -64
- package/dist/infra/widearea-dns.js +3 -3
- package/dist/infra/wsl.js +2 -2
- package/dist/light-update-status.js +1 -1
- package/dist/line/accounts.js +2 -2
- package/dist/line/download.js +2 -2
- package/dist/logging/config.js +3 -3
- package/dist/logging/logger.js +7 -7
- package/dist/managed/federation.js +3 -3
- package/dist/managed/tunnel.js +3 -3
- package/dist/media/store.js +13 -13
- package/dist/media-understanding/runner.js +3 -3
- package/dist/memory/embeddings.js +2 -2
- package/dist/memory/internal.js +10 -10
- package/dist/memory/manager-sync-ops.js +7 -7
- package/dist/memory/repair-executor.js +17 -17
- package/dist/node-host/invoke-system-run-plan.js +8 -8
- package/dist/node-host/invoke.js +2 -2
- package/dist/node-host/runner.js +3 -3
- package/dist/pairing/pairing-store.js +3 -3
- package/dist/plugin-sdk/{audio-preflight-XJNZUuhw.js → audio-preflight-CzG6BjAn.js} +3 -3
- package/dist/plugin-sdk/channel-plugin-common.d.ts +2 -2
- package/dist/plugin-sdk/{chunk-items-me0j1xjK.js → chunk-items-CxRDAM7m.js} +1 -1
- package/dist/plugin-sdk/command-status.js +3 -3
- package/dist/plugin-sdk/device-pair.d.ts +1 -1
- package/dist/plugin-sdk/discord.d.ts +4 -4
- package/dist/plugin-sdk/index.d.ts +20 -20
- package/dist/plugin-sdk/index.js +5 -4
- package/dist/plugin-sdk/json-store.js +6 -6
- package/dist/plugin-sdk/{monitor-C7si_bKw.js → monitor-B1PUtkd6.js} +5 -5
- package/dist/plugin-sdk/{monitor-DUyt6cCK.js → monitor-BrxWsb7H.js} +7 -7
- package/dist/plugin-sdk/{openresponses-http-sYsdEjGP.js → openresponses-http-DJ2lfMja.js} +3 -3
- package/dist/plugin-sdk/{pairing-message-C5m-8Evp.d.ts → pairing-message-DWXHX-jt.d.ts} +1 -1
- package/dist/plugin-sdk/{pi-embedded-runner-C6HkZJ5E.js → pi-embedded-runner-DMfkIj60.js} +12 -12
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +1 -1
- package/dist/plugin-sdk/{pw-ai-BFHYmEIx.js → pw-ai-BgsJH_P8.js} +1 -1
- package/dist/plugin-sdk/{runtime-dependency-B5Fut2tT.js → runtime-dependency-pUwxUAJp.js} +9 -9
- package/dist/plugin-sdk/sat-runtime.d.ts +2 -2
- package/dist/plugin-sdk/sat-runtime.js +1 -1
- package/dist/plugin-sdk/{slack-CEoLScM7.js → slack-B6lIY1Jk.js} +5 -5
- package/dist/plugin-sdk/slack.d.ts +4 -4
- package/dist/plugin-sdk/{sticker-cache-PRfvBRnv.js → sticker-cache-D4Ljzv1P.js} +2 -2
- package/dist/plugin-sdk/{telegram-actions-D4PNLPEZ.js → telegram-actions-tOhBd6st.js} +4 -4
- package/dist/plugin-sdk/telegram.d.ts +4 -4
- package/dist/plugin-sdk/{tmp-fased-dir-B-AAdaCr.d.ts → tmp-fased-dir-Be1wBhVz.d.ts} +1 -1
- package/dist/plugin-sdk/{types-ZT0DGnls.d.ts → types-CJGVZX6j.d.ts} +2 -2
- package/dist/plugin-sdk/{types-56R2vXgt.d.ts → types-CXLEOrJX.d.ts} +1 -1
- package/dist/plugin-sdk/{wallet-status-D9UVH6k9.js → wallet-status-CdxTkLWz.js} +4 -4
- package/dist/plugin-sdk/{web-CSpyzE3P.js → web-CX12Rpz1.js} +3 -3
- package/dist/plugin-sdk/whatsapp.d.ts +13 -13
- package/dist/plugin-sdk/{zod-schema.providers-core-FaYR6KdD.d.ts → zod-schema.providers-core-BEbNizPe.d.ts} +78 -78
- package/dist/plugins/bundled-dir.js +3 -3
- package/dist/plugins/discovery.js +11 -11
- package/dist/plugins/loader.js +13 -13
- package/dist/plugins/manifest-registry.js +2 -2
- package/dist/plugins/manifest.js +4 -4
- package/dist/plugins/path-safety.js +3 -3
- package/dist/plugins/status-cache.js +9 -9
- package/dist/plugins/update.js +3 -3
- package/dist/plugins/web-search-install-catalog.js +3 -3
- package/dist/secrets/apply.js +16 -16
- package/dist/secrets/audit.js +11 -11
- package/dist/secrets/shared.js +9 -9
- package/dist/security/scan-paths.js +2 -2
- package/dist/shared/config-eval.js +2 -2
- package/dist/shared/pid-alive.js +2 -2
- package/dist/tasks/standing-orders.js +5 -5
- package/dist/tasks/task-flow-registry.js +5 -5
- package/dist/tasks/task-registry.js +5 -5
- package/dist/tasks/workflow-definitions.js +6 -6
- package/dist/telegram/token.js +5 -5
- package/dist/utils.js +5 -5
- package/dist/wallet/local-socket-signer-broker.js +16 -16
- package/dist/wallet/providers/embedded-keystore-adapter.js +5 -5
- package/dist/wallet/providers/local-socket-signer-adapter.js +2 -2
- package/dist/wallet/wallet-approval-auth.js +5 -5
- package/dist/wallet/wallet-audit-log.js +5 -5
- package/dist/wallet/wallet-custody.js +21 -21
- package/dist/wallet/wallet-inbound-events.js +5 -5
- package/dist/wallet/wallet-observability.js +5 -5
- package/dist/wallet/wallet-policy.js +9 -9
- package/dist/wallet/wallet-provider-registry.js +7 -7
- package/dist/wallet/wallet-runtime-config.js +3 -3
- package/dist/wallet/wallet-secrets-store.js +22 -22
- package/dist/wallet/wallet-send-approvals.js +5 -5
- package/dist/wallet/wallet-settlement-links.js +5 -5
- package/dist/web/accounts.js +3 -3
- package/dist/web/auth-store.js +18 -18
- package/dist/web/session.js +4 -4
- package/dist/wizard/host-security-capability.js +2 -2
- package/dist/wizard/onboarding.host-security.js +7 -7
- package/dist/wizard/onboarding.js +7 -7
- package/dist/wizard/onboarding.wallet.js +44 -44
- package/extensions/acpx/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/fased-federation/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +6 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +2 -2
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +6 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +6 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/sat-mining/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +6 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +6 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +6 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +6 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -19,7 +19,7 @@ import { loadSessionStore } from "../config/sessions/store.js";
|
|
|
19
19
|
import "../config/sessions.js";
|
|
20
20
|
import { lookupContextTokens } from "../agents/context.js";
|
|
21
21
|
import { listSessionCompactionCheckpoints } from "./session-compaction-checkpoints.js";
|
|
22
|
-
import
|
|
22
|
+
import fs from "node:fs";
|
|
23
23
|
import path from "node:path";
|
|
24
24
|
|
|
25
25
|
//#region src/gateway/session-utils.ts
|
|
@@ -41,7 +41,7 @@ function isCombinedSessionStoreCacheFresh(entry) {
|
|
|
41
41
|
}
|
|
42
42
|
function readSessionStoreSignature(storePath) {
|
|
43
43
|
try {
|
|
44
|
-
const stat =
|
|
44
|
+
const stat = fs.statSync(storePath);
|
|
45
45
|
return {
|
|
46
46
|
storePath,
|
|
47
47
|
exists: true,
|
|
@@ -94,7 +94,7 @@ function clearCombinedSessionStoreCacheForTest() {
|
|
|
94
94
|
}
|
|
95
95
|
function tryResolveExistingPath(value) {
|
|
96
96
|
try {
|
|
97
|
-
return
|
|
97
|
+
return fs.realpathSync(value);
|
|
98
98
|
} catch {
|
|
99
99
|
return null;
|
|
100
100
|
}
|
|
@@ -132,11 +132,11 @@ function resolveIdentityAvatarUrl(cfg, agentId, avatar) {
|
|
|
132
132
|
return undefined;
|
|
133
133
|
}
|
|
134
134
|
try {
|
|
135
|
-
const buffer =
|
|
135
|
+
const buffer = fs.readFileSync(opened.fd);
|
|
136
136
|
const mime = resolveAvatarMime(resolvedCandidate);
|
|
137
137
|
return `data:${mime};base64,${buffer.toString("base64")}`;
|
|
138
138
|
} finally {
|
|
139
|
-
|
|
139
|
+
fs.closeSync(opened.fd);
|
|
140
140
|
}
|
|
141
141
|
} catch {
|
|
142
142
|
return undefined;
|
|
@@ -304,7 +304,7 @@ function listExistingAgentIdsFromDisk() {
|
|
|
304
304
|
const root = resolveStateDir();
|
|
305
305
|
const agentsDir = path.join(root, "agents");
|
|
306
306
|
try {
|
|
307
|
-
const entries =
|
|
307
|
+
const entries = fs.readdirSync(agentsDir, { withFileTypes: true });
|
|
308
308
|
return entries.filter((entry) => entry.isDirectory()).map((entry) => normalizeAgentId(entry.name)).filter(Boolean);
|
|
309
309
|
} catch {
|
|
310
310
|
return [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/bundled-dir.ts
|
|
@@ -11,14 +11,14 @@ function resolveBundledHooksDir() {
|
|
|
11
11
|
try {
|
|
12
12
|
const execDir = path.dirname(process.execPath);
|
|
13
13
|
const sibling = path.join(execDir, "hooks", "bundled");
|
|
14
|
-
if (
|
|
14
|
+
if (fs.existsSync(sibling)) {
|
|
15
15
|
return sibling;
|
|
16
16
|
}
|
|
17
17
|
} catch {}
|
|
18
18
|
try {
|
|
19
19
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
20
20
|
const distBundled = path.join(moduleDir, "bundled");
|
|
21
|
-
if (
|
|
21
|
+
if (fs.existsSync(distBundled)) {
|
|
22
22
|
return distBundled;
|
|
23
23
|
}
|
|
24
24
|
} catch {}
|
|
@@ -26,7 +26,7 @@ function resolveBundledHooksDir() {
|
|
|
26
26
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
27
27
|
const root = path.resolve(moduleDir, "..", "..");
|
|
28
28
|
const srcBundled = path.join(root, "src", "hooks", "bundled");
|
|
29
|
-
if (
|
|
29
|
+
if (fs.existsSync(srcBundled)) {
|
|
30
30
|
return srcBundled;
|
|
31
31
|
}
|
|
32
32
|
} catch {}
|
|
@@ -3,7 +3,7 @@ import { runCommandWithTimeout } from "../process/exec.js";
|
|
|
3
3
|
import { hasBinary } from "../shared/config-eval.js";
|
|
4
4
|
import "../agents/skills.js";
|
|
5
5
|
import { normalizeServePath } from "./gmail.js";
|
|
6
|
-
import
|
|
6
|
+
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
9
|
//#region src/hooks/gmail-setup-utils.ts
|
|
@@ -71,7 +71,7 @@ function findExecutablesOnPath(bins) {
|
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
73
73
|
try {
|
|
74
|
-
|
|
74
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
75
75
|
matches.push(candidate);
|
|
76
76
|
seen.add(candidate);
|
|
77
77
|
} catch {}
|
|
@@ -100,7 +100,7 @@ function ensureGcloudOnPath() {
|
|
|
100
100
|
];
|
|
101
101
|
for (const candidate of candidates) {
|
|
102
102
|
try {
|
|
103
|
-
|
|
103
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
104
104
|
ensurePathIncludes(path.dirname(candidate), "append");
|
|
105
105
|
return true;
|
|
106
106
|
} catch {}
|
|
@@ -126,7 +126,7 @@ async function resolvePythonExecutablePath() {
|
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
128
128
|
try {
|
|
129
|
-
|
|
129
|
+
fs.accessSync(resolved, fs.constants.X_OK);
|
|
130
130
|
cachedPythonPath = resolved;
|
|
131
131
|
return resolved;
|
|
132
132
|
} catch {}
|
|
@@ -303,11 +303,11 @@ async function ensureTailscaleEndpoint(params) {
|
|
|
303
303
|
async function resolveProjectIdFromGogCredentials() {
|
|
304
304
|
const candidates = gogCredentialsPaths();
|
|
305
305
|
for (const candidate of candidates) {
|
|
306
|
-
if (!
|
|
306
|
+
if (!fs.existsSync(candidate)) {
|
|
307
307
|
continue;
|
|
308
308
|
}
|
|
309
309
|
try {
|
|
310
|
-
const raw =
|
|
310
|
+
const raw = fs.readFileSync(candidate, "utf-8");
|
|
311
311
|
const parsed = JSON.parse(raw);
|
|
312
312
|
const clientId = extractGogClientId(parsed);
|
|
313
313
|
const projectNumber = extractProjectNumber(clientId);
|
package/dist/hooks/import-url.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url";
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/import-url.ts
|
|
5
5
|
/**
|
|
@@ -24,7 +24,7 @@ function buildImportUrl(handlerPath, source) {
|
|
|
24
24
|
return base;
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
-
const { mtimeMs, size } =
|
|
27
|
+
const { mtimeMs, size } = fs.statSync(handlerPath);
|
|
28
28
|
return `${base}?t=${mtimeMs}&s=${size}`;
|
|
29
29
|
} catch {
|
|
30
30
|
return `${base}?t=${Date.now()}`;
|
package/dist/hooks/loader.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveFunctionModuleExport } from "./module-loader.js";
|
|
|
5
5
|
import { resolveHookConfig, shouldIncludeHook } from "./config.js";
|
|
6
6
|
import { loadWorkspaceHookEntries } from "./workspace.js";
|
|
7
7
|
import { buildImportUrl } from "./import-url.js";
|
|
8
|
-
import
|
|
8
|
+
import fs from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
|
|
11
11
|
//#region src/hooks/loader.ts
|
|
@@ -67,7 +67,7 @@ async function loadInternalHooks(cfg, workspaceDir, opts) {
|
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
69
|
const safeHandlerPath = opened.path;
|
|
70
|
-
|
|
70
|
+
fs.closeSync(opened.fd);
|
|
71
71
|
const importUrl = buildImportUrl(safeHandlerPath, entry.hook.source);
|
|
72
72
|
const mod = await import(importUrl);
|
|
73
73
|
const exportName = entry.metadata?.export ?? "default";
|
|
@@ -127,7 +127,7 @@ async function loadInternalHooks(cfg, workspaceDir, opts) {
|
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
129
|
const safeModulePath = opened.path;
|
|
130
|
-
|
|
130
|
+
fs.closeSync(opened.fd);
|
|
131
131
|
const importUrl = buildImportUrl(safeModulePath, "fased-workspace");
|
|
132
132
|
const mod = await import(importUrl);
|
|
133
133
|
const exportName = handlerConfig.export ?? "default";
|
|
@@ -150,7 +150,7 @@ async function loadInternalHooks(cfg, workspaceDir, opts) {
|
|
|
150
150
|
}
|
|
151
151
|
function safeRealpathOrResolve(value) {
|
|
152
152
|
try {
|
|
153
|
-
return
|
|
153
|
+
return fs.realpathSync(value);
|
|
154
154
|
} catch {
|
|
155
155
|
return path.resolve(value);
|
|
156
156
|
}
|
package/dist/hooks/workspace.js
CHANGED
|
@@ -6,7 +6,7 @@ import { isPathInsideWithRealpath } from "../security/scan-paths.js";
|
|
|
6
6
|
import { parseFrontmatter, resolveFasedAgentMetadata, resolveHookInvocationPolicy } from "./frontmatter.js";
|
|
7
7
|
import { shouldIncludeHook } from "./config.js";
|
|
8
8
|
import { resolveBundledHooksDir } from "./bundled-dir.js";
|
|
9
|
-
import
|
|
9
|
+
import fs from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
|
|
12
12
|
//#region src/hooks/workspace.ts
|
|
@@ -106,15 +106,15 @@ function loadHookFromDir(params) {
|
|
|
106
106
|
*/
|
|
107
107
|
function loadHooksFromDir(params) {
|
|
108
108
|
const { dir, source, pluginId } = params;
|
|
109
|
-
if (!
|
|
109
|
+
if (!fs.existsSync(dir)) {
|
|
110
110
|
return [];
|
|
111
111
|
}
|
|
112
|
-
const stat =
|
|
112
|
+
const stat = fs.statSync(dir);
|
|
113
113
|
if (!stat.isDirectory()) {
|
|
114
114
|
return [];
|
|
115
115
|
}
|
|
116
116
|
const hooks = [];
|
|
117
|
-
const entries =
|
|
117
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
118
118
|
for (const entry of entries) {
|
|
119
119
|
if (!entry.isDirectory()) {
|
|
120
120
|
continue;
|
|
@@ -263,11 +263,11 @@ function readBoundaryFileUtf8(params) {
|
|
|
263
263
|
return null;
|
|
264
264
|
}
|
|
265
265
|
try {
|
|
266
|
-
return
|
|
266
|
+
return fs.readFileSync(opened.fd, "utf-8");
|
|
267
267
|
} catch {
|
|
268
268
|
return null;
|
|
269
269
|
} finally {
|
|
270
|
-
|
|
270
|
+
fs.closeSync(opened.fd);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
function resolveBoundaryFilePath(params) {
|
|
@@ -280,7 +280,7 @@ function resolveBoundaryFilePath(params) {
|
|
|
280
280
|
return null;
|
|
281
281
|
}
|
|
282
282
|
const safePath = opened.path;
|
|
283
|
-
|
|
283
|
+
fs.closeSync(opened.fd);
|
|
284
284
|
return safePath;
|
|
285
285
|
}
|
|
286
286
|
|