@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
package/dist/infra/fs-safe.js
CHANGED
|
@@ -3,7 +3,7 @@ import { sameFileIdentity } from "./file-identity.js";
|
|
|
3
3
|
import { assertNoPathAliasEscape } from "./path-alias-guards.js";
|
|
4
4
|
import { constants } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import fs from "node:fs/promises";
|
|
6
|
+
import fs$1 from "node:fs/promises";
|
|
7
7
|
|
|
8
8
|
//#region src/infra/fs-safe.ts
|
|
9
9
|
var SafeOpenError = class extends Error {
|
|
@@ -25,7 +25,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
25
25
|
let handle;
|
|
26
26
|
try {
|
|
27
27
|
const openFlags = options?.allowSymlinkTargetWithinRoot ? options.nonBlockingRead ? OPEN_READ_FOLLOW_NONBLOCK_FLAGS : OPEN_READ_FOLLOW_FLAGS : options?.nonBlockingRead ? OPEN_READ_NONBLOCK_FLAGS : OPEN_READ_FLAGS;
|
|
28
|
-
handle = await fs.open(filePath, openFlags);
|
|
28
|
+
handle = await fs$1.open(filePath, openFlags);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
if (isNotFoundPathError(err)) {
|
|
31
31
|
throw new SafeOpenError("not-found", "file not found");
|
|
@@ -36,7 +36,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
36
36
|
throw err;
|
|
37
37
|
}
|
|
38
38
|
try {
|
|
39
|
-
const [stat, pathStat] = await Promise.all([handle.stat(), options?.allowSymlinkTargetWithinRoot ? fs.stat(filePath) : fs.lstat(filePath)]);
|
|
39
|
+
const [stat, pathStat] = await Promise.all([handle.stat(), options?.allowSymlinkTargetWithinRoot ? fs$1.stat(filePath) : fs$1.lstat(filePath)]);
|
|
40
40
|
if (!options?.allowSymlinkTargetWithinRoot && pathStat.isSymbolicLink()) {
|
|
41
41
|
throw new SafeOpenError("symlink", "symlink not allowed");
|
|
42
42
|
}
|
|
@@ -49,8 +49,8 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
49
49
|
if (!sameFileIdentity(stat, pathStat)) {
|
|
50
50
|
throw new SafeOpenError("path-mismatch", "path changed during read");
|
|
51
51
|
}
|
|
52
|
-
const realPath = await fs.realpath(filePath);
|
|
53
|
-
const realStat = await fs.stat(realPath);
|
|
52
|
+
const realPath = await fs$1.realpath(filePath);
|
|
53
|
+
const realStat = await fs$1.stat(realPath);
|
|
54
54
|
if (options?.rejectHardlinks && realStat.nlink > 1) {
|
|
55
55
|
throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
56
56
|
}
|
|
@@ -76,7 +76,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
76
76
|
async function openFileWithinRoot(params) {
|
|
77
77
|
let rootReal;
|
|
78
78
|
try {
|
|
79
|
-
rootReal = await fs.realpath(params.rootDir);
|
|
79
|
+
rootReal = await fs$1.realpath(params.rootDir);
|
|
80
80
|
} catch (err) {
|
|
81
81
|
if (isNotFoundPathError(err)) {
|
|
82
82
|
throw new SafeOpenError("not-found", "root dir not found");
|
|
@@ -154,7 +154,7 @@ async function readFileWithinRoot(params) {
|
|
|
154
154
|
async function writeFileWithinRoot(params) {
|
|
155
155
|
let rootReal;
|
|
156
156
|
try {
|
|
157
|
-
rootReal = await fs.realpath(params.rootDir);
|
|
157
|
+
rootReal = await fs$1.realpath(params.rootDir);
|
|
158
158
|
} catch (err) {
|
|
159
159
|
if (isNotFoundPathError(err)) {
|
|
160
160
|
throw new SafeOpenError("not-found", "root dir not found");
|
|
@@ -176,7 +176,7 @@ async function writeFileWithinRoot(params) {
|
|
|
176
176
|
throw new SafeOpenError("invalid-path", "path alias escape blocked", { cause: err });
|
|
177
177
|
}
|
|
178
178
|
if (params.mkdir !== false) {
|
|
179
|
-
await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
179
|
+
await fs$1.mkdir(path.dirname(resolved), { recursive: true });
|
|
180
180
|
}
|
|
181
181
|
try {
|
|
182
182
|
await assertNoPathAliasEscape({
|
|
@@ -188,7 +188,7 @@ async function writeFileWithinRoot(params) {
|
|
|
188
188
|
throw new SafeOpenError("invalid-path", "path alias escape blocked", { cause: err });
|
|
189
189
|
}
|
|
190
190
|
try {
|
|
191
|
-
const pathStat = await fs.lstat(resolved);
|
|
191
|
+
const pathStat = await fs$1.lstat(resolved);
|
|
192
192
|
if (pathStat.isSymbolicLink()) {
|
|
193
193
|
throw new SafeOpenError("invalid-path", "symlink open blocked");
|
|
194
194
|
}
|
|
@@ -202,7 +202,7 @@ async function writeFileWithinRoot(params) {
|
|
|
202
202
|
}
|
|
203
203
|
let ioPath = resolved;
|
|
204
204
|
try {
|
|
205
|
-
const resolvedRealPath = await fs.realpath(resolved);
|
|
205
|
+
const resolvedRealPath = await fs$1.realpath(resolved);
|
|
206
206
|
if (!isPathInside(rootWithSep, resolvedRealPath)) {
|
|
207
207
|
throw new SafeOpenError("invalid-path", "path escapes root");
|
|
208
208
|
}
|
|
@@ -217,7 +217,7 @@ async function writeFileWithinRoot(params) {
|
|
|
217
217
|
}
|
|
218
218
|
let handle;
|
|
219
219
|
try {
|
|
220
|
-
handle = await fs.open(ioPath, OPEN_WRITE_FLAGS, 384);
|
|
220
|
+
handle = await fs$1.open(ioPath, OPEN_WRITE_FLAGS, 384);
|
|
221
221
|
} catch (err) {
|
|
222
222
|
if (isNotFoundPathError(err)) {
|
|
223
223
|
throw new SafeOpenError("not-found", "file not found");
|
|
@@ -228,7 +228,7 @@ async function writeFileWithinRoot(params) {
|
|
|
228
228
|
throw err;
|
|
229
229
|
}
|
|
230
230
|
try {
|
|
231
|
-
const [stat, lstat] = await Promise.all([handle.stat(), fs.lstat(ioPath)]);
|
|
231
|
+
const [stat, lstat] = await Promise.all([handle.stat(), fs$1.lstat(ioPath)]);
|
|
232
232
|
if (lstat.isSymbolicLink() || !stat.isFile()) {
|
|
233
233
|
throw new SafeOpenError("invalid-path", "path is not a regular file under root");
|
|
234
234
|
}
|
|
@@ -238,8 +238,8 @@ async function writeFileWithinRoot(params) {
|
|
|
238
238
|
if (!sameFileIdentity(stat, lstat)) {
|
|
239
239
|
throw new SafeOpenError("path-mismatch", "path changed during write");
|
|
240
240
|
}
|
|
241
|
-
const realPath = await fs.realpath(ioPath);
|
|
242
|
-
const realStat = await fs.stat(realPath);
|
|
241
|
+
const realPath = await fs$1.realpath(ioPath);
|
|
242
|
+
const realStat = await fs$1.stat(realPath);
|
|
243
243
|
if (!sameFileIdentity(stat, realStat)) {
|
|
244
244
|
throw new SafeOpenError("path-mismatch", "path mismatch");
|
|
245
245
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveConfigPath, resolveGatewayLockDir, resolveStateDir } from "../config/paths.js";
|
|
2
2
|
import { isPidAlive } from "../shared/pid-alive.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import fs from "node:fs/promises";
|
|
5
|
+
import fs$1 from "node:fs/promises";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import net from "node:net";
|
|
8
8
|
|
|
@@ -44,7 +44,7 @@ function isGatewayArgv(args) {
|
|
|
44
44
|
}
|
|
45
45
|
function readLinuxCmdline(pid) {
|
|
46
46
|
try {
|
|
47
|
-
const raw =
|
|
47
|
+
const raw = fs.readFileSync(`/proc/${pid}/cmdline`, "utf8");
|
|
48
48
|
return parseProcCmdline(raw);
|
|
49
49
|
} catch {
|
|
50
50
|
return null;
|
|
@@ -52,7 +52,7 @@ function readLinuxCmdline(pid) {
|
|
|
52
52
|
}
|
|
53
53
|
function readLinuxStartTime(pid) {
|
|
54
54
|
try {
|
|
55
|
-
const raw =
|
|
55
|
+
const raw = fs.readFileSync(`/proc/${pid}/stat`, "utf8").trim();
|
|
56
56
|
const closeParen = raw.lastIndexOf(")");
|
|
57
57
|
if (closeParen < 0) {
|
|
58
58
|
return null;
|
|
@@ -122,7 +122,7 @@ async function resolveGatewayOwnerStatus(pid, payload, platform, port) {
|
|
|
122
122
|
}
|
|
123
123
|
async function readLockPayload(lockPath) {
|
|
124
124
|
try {
|
|
125
|
-
const raw = await fs.readFile(lockPath, "utf8");
|
|
125
|
+
const raw = await fs$1.readFile(lockPath, "utf8");
|
|
126
126
|
const parsed = JSON.parse(raw);
|
|
127
127
|
if (typeof parsed.pid !== "number") {
|
|
128
128
|
return null;
|
|
@@ -167,12 +167,12 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
167
167
|
const platform = opts.platform ?? process.platform;
|
|
168
168
|
const port = opts.port;
|
|
169
169
|
const { lockPath, configPath } = resolveGatewayLockPath(env);
|
|
170
|
-
await fs.mkdir(path.dirname(lockPath), { recursive: true });
|
|
170
|
+
await fs$1.mkdir(path.dirname(lockPath), { recursive: true });
|
|
171
171
|
const startedAt = Date.now();
|
|
172
172
|
let lastPayload = null;
|
|
173
173
|
while (Date.now() - startedAt < timeoutMs) {
|
|
174
174
|
try {
|
|
175
|
-
const handle = await fs.open(lockPath, "wx");
|
|
175
|
+
const handle = await fs$1.open(lockPath, "wx");
|
|
176
176
|
const startTime = platform === "linux" ? readLinuxStartTime(process.pid) : null;
|
|
177
177
|
const payload = {
|
|
178
178
|
pid: process.pid,
|
|
@@ -188,7 +188,7 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
188
188
|
configPath,
|
|
189
189
|
release: async () => {
|
|
190
190
|
await handle.close().catch(() => undefined);
|
|
191
|
-
await fs.rm(lockPath, { force: true });
|
|
191
|
+
await fs$1.rm(lockPath, { force: true });
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
} catch (err) {
|
|
@@ -200,7 +200,7 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
200
200
|
const ownerPid = lastPayload?.pid;
|
|
201
201
|
const ownerStatus = ownerPid ? await resolveGatewayOwnerStatus(ownerPid, lastPayload, platform, port) : "unknown";
|
|
202
202
|
if (ownerStatus === "dead" && ownerPid) {
|
|
203
|
-
await fs.rm(lockPath, { force: true });
|
|
203
|
+
await fs$1.rm(lockPath, { force: true });
|
|
204
204
|
continue;
|
|
205
205
|
}
|
|
206
206
|
if (ownerStatus !== "alive") {
|
|
@@ -211,14 +211,14 @@ async function acquireGatewayLock(opts = {}) {
|
|
|
211
211
|
}
|
|
212
212
|
if (!stale) {
|
|
213
213
|
try {
|
|
214
|
-
const st = await fs.stat(lockPath);
|
|
214
|
+
const st = await fs$1.stat(lockPath);
|
|
215
215
|
stale = Date.now() - st.mtimeMs > staleMs;
|
|
216
216
|
} catch {
|
|
217
217
|
stale = false;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
if (stale) {
|
|
221
|
-
await fs.rm(lockPath, { force: true });
|
|
221
|
+
await fs$1.rm(lockPath, { force: true });
|
|
222
222
|
continue;
|
|
223
223
|
}
|
|
224
224
|
}
|
package/dist/infra/git-commit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveGitHeadPath } from "./git-root.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/infra/git-commit.ts
|
|
@@ -48,7 +48,7 @@ function isMissingPathError(error) {
|
|
|
48
48
|
function resolveGitRefsBase(headPath) {
|
|
49
49
|
const gitDir = path.dirname(headPath);
|
|
50
50
|
try {
|
|
51
|
-
const commonDirRaw =
|
|
51
|
+
const commonDirRaw = fs.readFileSync(path.join(gitDir, "commondir"), "utf-8").trim();
|
|
52
52
|
if (!commonDirRaw) {
|
|
53
53
|
return gitDir;
|
|
54
54
|
}
|
|
@@ -79,7 +79,7 @@ function resolveRefPath(refsBase, ref) {
|
|
|
79
79
|
}
|
|
80
80
|
function readCommitFromPackedRefs(refsBase, ref) {
|
|
81
81
|
try {
|
|
82
|
-
const packedRefs =
|
|
82
|
+
const packedRefs = fs.readFileSync(path.join(refsBase, "packed-refs"), "utf-8");
|
|
83
83
|
for (const line of packedRefs.split("\n")) {
|
|
84
84
|
if (!line || line.startsWith("#") || line.startsWith("^")) {
|
|
85
85
|
continue;
|
|
@@ -124,7 +124,7 @@ const resolveCommitHash = (options = {}) => {
|
|
|
124
124
|
cachedCommit = null;
|
|
125
125
|
return cachedCommit;
|
|
126
126
|
}
|
|
127
|
-
const head =
|
|
127
|
+
const head = fs.readFileSync(headPath, "utf-8").trim();
|
|
128
128
|
if (!head) {
|
|
129
129
|
cachedCommit = null;
|
|
130
130
|
return cachedCommit;
|
|
@@ -138,7 +138,7 @@ const resolveCommitHash = (options = {}) => {
|
|
|
138
138
|
return cachedCommit;
|
|
139
139
|
}
|
|
140
140
|
try {
|
|
141
|
-
const refHash =
|
|
141
|
+
const refHash = fs.readFileSync(refPath, "utf-8").trim();
|
|
142
142
|
cachedCommit = formatCommit(refHash);
|
|
143
143
|
return cachedCommit;
|
|
144
144
|
} catch (error) {
|
package/dist/infra/git-root.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/git-root.ts
|
|
@@ -22,7 +22,7 @@ function walkUpFrom(startDir, opts, resolveAtDir) {
|
|
|
22
22
|
function hasGitMarker(repoRoot) {
|
|
23
23
|
const gitPath = path.join(repoRoot, ".git");
|
|
24
24
|
try {
|
|
25
|
-
const stat =
|
|
25
|
+
const stat = fs.statSync(gitPath);
|
|
26
26
|
return stat.isDirectory() || stat.isFile();
|
|
27
27
|
} catch {
|
|
28
28
|
return false;
|
|
@@ -34,14 +34,14 @@ function findGitRoot(startDir, opts = {}) {
|
|
|
34
34
|
function resolveGitDirFromMarker(repoRoot) {
|
|
35
35
|
const gitPath = path.join(repoRoot, ".git");
|
|
36
36
|
try {
|
|
37
|
-
const stat =
|
|
37
|
+
const stat = fs.statSync(gitPath);
|
|
38
38
|
if (stat.isDirectory()) {
|
|
39
39
|
return gitPath;
|
|
40
40
|
}
|
|
41
41
|
if (!stat.isFile()) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
const raw =
|
|
44
|
+
const raw = fs.readFileSync(gitPath, "utf-8");
|
|
45
45
|
const match = raw.match(/gitdir:\s*(.+)/i);
|
|
46
46
|
if (!match?.[1]) {
|
|
47
47
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReadStream, createWriteStream } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import fs from "node:fs/promises";
|
|
3
|
+
import fs$1 from "node:fs/promises";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { Readable } from "node:stream";
|
|
6
6
|
import { pipeline } from "node:stream/promises";
|
|
@@ -141,7 +141,7 @@ async function downloadHostedRuntimeDescriptor(params) {
|
|
|
141
141
|
reason: `hosted runtime artifact unavailable (${artifactResponse.status})`
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
await fs.mkdir(params.destinationDir, { recursive: true });
|
|
144
|
+
await fs$1.mkdir(params.destinationDir, { recursive: true });
|
|
145
145
|
const archivePath = path.join(params.destinationDir, descriptor.assetName);
|
|
146
146
|
try {
|
|
147
147
|
await writeResponseBody(artifactResponse, archivePath);
|
|
@@ -153,7 +153,7 @@ async function downloadHostedRuntimeDescriptor(params) {
|
|
|
153
153
|
}
|
|
154
154
|
const actualChecksum = await sha256(archivePath);
|
|
155
155
|
if (actualChecksum !== expectedChecksum) {
|
|
156
|
-
await fs.rm(archivePath, { force: true });
|
|
156
|
+
await fs$1.rm(archivePath, { force: true });
|
|
157
157
|
return {
|
|
158
158
|
kind: "error",
|
|
159
159
|
reason: `hosted runtime checksum mismatch for ${descriptor.assetName}`
|
package/dist/infra/is-main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/is-main.ts
|
|
@@ -8,7 +8,7 @@ function normalizePathCandidate(candidate, cwd) {
|
|
|
8
8
|
}
|
|
9
9
|
const resolved = path.resolve(cwd, candidate);
|
|
10
10
|
try {
|
|
11
|
-
return
|
|
11
|
+
return fs.realpathSync.native(resolved);
|
|
12
12
|
} catch {
|
|
13
13
|
return resolved;
|
|
14
14
|
}
|
package/dist/infra/json-file.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/json-file.ts
|
|
5
5
|
function loadJsonFile(pathname) {
|
|
6
6
|
try {
|
|
7
|
-
if (!
|
|
7
|
+
if (!fs.existsSync(pathname)) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
|
-
const raw =
|
|
10
|
+
const raw = fs.readFileSync(pathname, "utf8");
|
|
11
11
|
return JSON.parse(raw);
|
|
12
12
|
} catch {
|
|
13
13
|
return undefined;
|
|
@@ -15,14 +15,14 @@ function loadJsonFile(pathname) {
|
|
|
15
15
|
}
|
|
16
16
|
function saveJsonFile(pathname, data) {
|
|
17
17
|
const dir = path.dirname(pathname);
|
|
18
|
-
if (!
|
|
19
|
-
|
|
18
|
+
if (!fs.existsSync(dir)) {
|
|
19
|
+
fs.mkdirSync(dir, {
|
|
20
20
|
recursive: true,
|
|
21
21
|
mode: 448
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
fs.writeFileSync(pathname, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
25
|
+
fs.chmodSync(pathname, 384);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import { resolveStateDir } from "../../config/paths.js";
|
|
|
2
2
|
import { formatErrorMessage } from "../errors.js";
|
|
3
3
|
import { generateSecureUuid } from "../secure-random.js";
|
|
4
4
|
import { formatOutboundTargetForLog, redactOutboundTargetInText } from "./format.js";
|
|
5
|
-
import
|
|
5
|
+
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
|
|
8
8
|
//#region src/infra/outbound/delivery-queue.ts
|
|
@@ -26,11 +26,11 @@ function resolveFailedDir(stateDir) {
|
|
|
26
26
|
/** Ensure the queue directory (and failed/ subdirectory) exist. */
|
|
27
27
|
async function ensureQueueDir(stateDir) {
|
|
28
28
|
const queueDir = resolveQueueDir(stateDir);
|
|
29
|
-
await
|
|
29
|
+
await fs.promises.mkdir(queueDir, {
|
|
30
30
|
recursive: true,
|
|
31
31
|
mode: 448
|
|
32
32
|
});
|
|
33
|
-
await
|
|
33
|
+
await fs.promises.mkdir(resolveFailedDir(stateDir), {
|
|
34
34
|
recursive: true,
|
|
35
35
|
mode: 448
|
|
36
36
|
});
|
|
@@ -57,18 +57,18 @@ async function enqueueDelivery(params, stateDir) {
|
|
|
57
57
|
const filePath = path.join(queueDir, `${id}.json`);
|
|
58
58
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
59
59
|
const json = JSON.stringify(entry, null, 2);
|
|
60
|
-
await
|
|
60
|
+
await fs.promises.writeFile(tmp, json, {
|
|
61
61
|
encoding: "utf-8",
|
|
62
62
|
mode: 384
|
|
63
63
|
});
|
|
64
|
-
await
|
|
64
|
+
await fs.promises.rename(tmp, filePath);
|
|
65
65
|
return id;
|
|
66
66
|
}
|
|
67
67
|
/** Remove a successfully delivered entry from the queue. */
|
|
68
68
|
async function ackDelivery(id, stateDir) {
|
|
69
69
|
const filePath = path.join(resolveQueueDir(stateDir), `${id}.json`);
|
|
70
70
|
try {
|
|
71
|
-
await
|
|
71
|
+
await fs.promises.unlink(filePath);
|
|
72
72
|
} catch (err) {
|
|
73
73
|
const code = err && typeof err === "object" && "code" in err ? String(err.code) : null;
|
|
74
74
|
if (code !== "ENOENT") {
|
|
@@ -79,24 +79,24 @@ async function ackDelivery(id, stateDir) {
|
|
|
79
79
|
/** Update a queue entry after a failed delivery attempt. */
|
|
80
80
|
async function failDelivery(id, error, stateDir) {
|
|
81
81
|
const filePath = path.join(resolveQueueDir(stateDir), `${id}.json`);
|
|
82
|
-
const raw = await
|
|
82
|
+
const raw = await fs.promises.readFile(filePath, "utf-8");
|
|
83
83
|
const entry = JSON.parse(raw);
|
|
84
84
|
entry.retryCount += 1;
|
|
85
85
|
entry.lastAttemptAt = Date.now();
|
|
86
86
|
entry.lastError = error;
|
|
87
87
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
88
|
-
await
|
|
88
|
+
await fs.promises.writeFile(tmp, JSON.stringify(entry, null, 2), {
|
|
89
89
|
encoding: "utf-8",
|
|
90
90
|
mode: 384
|
|
91
91
|
});
|
|
92
|
-
await
|
|
92
|
+
await fs.promises.rename(tmp, filePath);
|
|
93
93
|
}
|
|
94
94
|
/** Load all pending delivery entries from the queue directory. */
|
|
95
95
|
async function loadPendingDeliveries(stateDir) {
|
|
96
96
|
const queueDir = resolveQueueDir(stateDir);
|
|
97
97
|
let files;
|
|
98
98
|
try {
|
|
99
|
-
files = await
|
|
99
|
+
files = await fs.promises.readdir(queueDir);
|
|
100
100
|
} catch (err) {
|
|
101
101
|
const code = err && typeof err === "object" && "code" in err ? String(err.code) : null;
|
|
102
102
|
if (code === "ENOENT") {
|
|
@@ -111,20 +111,20 @@ async function loadPendingDeliveries(stateDir) {
|
|
|
111
111
|
}
|
|
112
112
|
const filePath = path.join(queueDir, file);
|
|
113
113
|
try {
|
|
114
|
-
const stat = await
|
|
114
|
+
const stat = await fs.promises.stat(filePath);
|
|
115
115
|
if (!stat.isFile()) {
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
118
|
-
const raw = await
|
|
118
|
+
const raw = await fs.promises.readFile(filePath, "utf-8");
|
|
119
119
|
const parsed = JSON.parse(raw);
|
|
120
120
|
const { entry, migrated } = normalizeLegacyQueuedDeliveryEntry(parsed);
|
|
121
121
|
if (migrated) {
|
|
122
122
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
123
|
-
await
|
|
123
|
+
await fs.promises.writeFile(tmp, JSON.stringify(entry, null, 2), {
|
|
124
124
|
encoding: "utf-8",
|
|
125
125
|
mode: 384
|
|
126
126
|
});
|
|
127
|
-
await
|
|
127
|
+
await fs.promises.rename(tmp, filePath);
|
|
128
128
|
}
|
|
129
129
|
entries.push(entry);
|
|
130
130
|
} catch {}
|
|
@@ -135,13 +135,13 @@ async function loadPendingDeliveries(stateDir) {
|
|
|
135
135
|
async function moveToFailed(id, stateDir) {
|
|
136
136
|
const queueDir = resolveQueueDir(stateDir);
|
|
137
137
|
const failedDir = resolveFailedDir(stateDir);
|
|
138
|
-
await
|
|
138
|
+
await fs.promises.mkdir(failedDir, {
|
|
139
139
|
recursive: true,
|
|
140
140
|
mode: 448
|
|
141
141
|
});
|
|
142
142
|
const src = path.join(queueDir, `${id}.json`);
|
|
143
143
|
const dest = path.join(failedDir, `${id}.json`);
|
|
144
|
-
await
|
|
144
|
+
await fs.promises.rename(src, dest);
|
|
145
145
|
}
|
|
146
146
|
/** Compute the backoff delay in ms for a given retry count. */
|
|
147
147
|
function computeBackoffMs(retryCount) {
|
package/dist/infra/path-env.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { isTruthyEnvValue } from "./env.js";
|
|
2
2
|
import { resolveBrewPathDirs } from "./brew.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
7
|
//#region src/infra/path-env.ts
|
|
8
8
|
function isExecutable(filePath) {
|
|
9
9
|
try {
|
|
10
|
-
|
|
10
|
+
fs.accessSync(filePath, fs.constants.X_OK);
|
|
11
11
|
return true;
|
|
12
12
|
} catch {
|
|
13
13
|
return false;
|
|
@@ -15,7 +15,7 @@ function isExecutable(filePath) {
|
|
|
15
15
|
}
|
|
16
16
|
function isDirectory(dirPath) {
|
|
17
17
|
try {
|
|
18
|
-
return
|
|
18
|
+
return fs.statSync(dirPath).isDirectory();
|
|
19
19
|
} catch {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
package/dist/infra/ports-lsof.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from "node:fs/promises";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import fs$1 from "node:fs/promises";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/ports-lsof.ts
|
|
5
5
|
const LSOF_CANDIDATES = process.platform === "darwin" ? ["/usr/sbin/lsof", "/usr/bin/lsof"] : ["/usr/bin/lsof", "/usr/sbin/lsof"];
|
|
6
6
|
async function canExecute(path) {
|
|
7
7
|
try {
|
|
8
|
-
await fs.access(path,
|
|
8
|
+
await fs$1.access(path, fs.constants.X_OK);
|
|
9
9
|
return true;
|
|
10
10
|
} catch {
|
|
11
11
|
return false;
|
|
@@ -22,7 +22,7 @@ async function resolveLsofCommand() {
|
|
|
22
22
|
function resolveLsofCommandSync() {
|
|
23
23
|
for (const candidate of LSOF_CANDIDATES) {
|
|
24
24
|
try {
|
|
25
|
-
|
|
25
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
26
26
|
return candidate;
|
|
27
27
|
} catch {}
|
|
28
28
|
}
|
|
@@ -9,7 +9,7 @@ import { resolveAuthProfileOrder } from "../agents/auth-profiles/order.js";
|
|
|
9
9
|
import "../agents/auth-profiles.js";
|
|
10
10
|
import { getCustomProviderApiKey } from "../agents/model-auth.js";
|
|
11
11
|
import { normalizeProviderId } from "../agents/model-selection.js";
|
|
12
|
-
import
|
|
12
|
+
import fs from "node:fs";
|
|
13
13
|
import os from "node:os";
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
|
|
@@ -43,10 +43,10 @@ function resolveZaiApiKey() {
|
|
|
43
43
|
}
|
|
44
44
|
try {
|
|
45
45
|
const authPath = path.join(resolveRequiredHomeDir(process.env, os.homedir), ".pi", "agent", "auth.json");
|
|
46
|
-
if (!
|
|
46
|
+
if (!fs.existsSync(authPath)) {
|
|
47
47
|
return undefined;
|
|
48
48
|
}
|
|
49
|
-
const data = JSON.parse(
|
|
49
|
+
const data = JSON.parse(fs.readFileSync(authPath, "utf-8"));
|
|
50
50
|
return data["z-ai"]?.access || data.zai?.access;
|
|
51
51
|
} catch {
|
|
52
52
|
return undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sameFileIdentity as sameFileIdentity$1 } from "./file-identity.js";
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/infra/safe-open-sync.ts
|
|
5
5
|
function isExpectedPathError(error) {
|
|
@@ -10,7 +10,7 @@ function sameFileIdentity(left, right) {
|
|
|
10
10
|
return sameFileIdentity$1(left, right);
|
|
11
11
|
}
|
|
12
12
|
function openVerifiedFileSync(params) {
|
|
13
|
-
const ioFs = params.ioFs ??
|
|
13
|
+
const ioFs = params.ioFs ?? fs;
|
|
14
14
|
const openReadFlags = ioFs.constants.O_RDONLY | (typeof ioFs.constants.O_NOFOLLOW === "number" ? ioFs.constants.O_NOFOLLOW : 0);
|
|
15
15
|
let fd = null;
|
|
16
16
|
try {
|
|
@@ -4,7 +4,7 @@ import { stripInboundMetadata } from "../auto-reply/reply/strip-inbound-meta.js"
|
|
|
4
4
|
import { stripEnvelope, stripMessageIdHints } from "../shared/chat-envelope.js";
|
|
5
5
|
import { normalizeUsage } from "../agents/usage.js";
|
|
6
6
|
import { estimateUsageCost, resolveModelCostConfig } from "../utils/usage-format.js";
|
|
7
|
-
import
|
|
7
|
+
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import readline from "node:readline";
|
|
10
10
|
|
|
@@ -145,7 +145,7 @@ const applyCostTotal = (totals, costTotal) => {
|
|
|
145
145
|
totals.totalCost += costTotal;
|
|
146
146
|
};
|
|
147
147
|
async function* readJsonlRecords(filePath) {
|
|
148
|
-
const fileStream =
|
|
148
|
+
const fileStream = fs.createReadStream(filePath, { encoding: "utf-8" });
|
|
149
149
|
const rl = readline.createInterface({
|
|
150
150
|
input: fileStream,
|
|
151
151
|
crlfDelay: Infinity
|
|
@@ -225,10 +225,10 @@ async function loadCostUsageSummary(params) {
|
|
|
225
225
|
const dailyMap = new Map();
|
|
226
226
|
const totals = emptyTotals();
|
|
227
227
|
const sessionsDir = resolveSessionTranscriptsDirForAgent(params?.agentId);
|
|
228
|
-
const entries = await
|
|
228
|
+
const entries = await fs.promises.readdir(sessionsDir, { withFileTypes: true }).catch(() => []);
|
|
229
229
|
const files = (await Promise.all(entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map(async (entry) => {
|
|
230
230
|
const filePath = path.join(sessionsDir, entry.name);
|
|
231
|
-
const stats = await
|
|
231
|
+
const stats = await fs.promises.stat(filePath).catch(() => null);
|
|
232
232
|
if (!stats) {
|
|
233
233
|
return null;
|
|
234
234
|
}
|
|
@@ -279,14 +279,14 @@ async function loadCostUsageSummary(params) {
|
|
|
279
279
|
*/
|
|
280
280
|
async function discoverAllSessions(params) {
|
|
281
281
|
const sessionsDir = resolveSessionTranscriptsDirForAgent(params?.agentId);
|
|
282
|
-
const entries = await
|
|
282
|
+
const entries = await fs.promises.readdir(sessionsDir, { withFileTypes: true }).catch(() => []);
|
|
283
283
|
const discovered = [];
|
|
284
284
|
for (const entry of entries) {
|
|
285
285
|
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) {
|
|
286
286
|
continue;
|
|
287
287
|
}
|
|
288
288
|
const filePath = path.join(sessionsDir, entry.name);
|
|
289
|
-
const stats = await
|
|
289
|
+
const stats = await fs.promises.stat(filePath).catch(() => null);
|
|
290
290
|
if (!stats) {
|
|
291
291
|
continue;
|
|
292
292
|
}
|
|
@@ -330,7 +330,7 @@ async function discoverAllSessions(params) {
|
|
|
330
330
|
}
|
|
331
331
|
async function loadSessionCostSummary(params) {
|
|
332
332
|
const sessionFile = params.sessionFile ?? (params.sessionId ? resolveSessionFilePath(params.sessionId, params.sessionEntry, { agentId: params.agentId }) : undefined);
|
|
333
|
-
if (!sessionFile || !
|
|
333
|
+
if (!sessionFile || !fs.existsSync(sessionFile)) {
|
|
334
334
|
return null;
|
|
335
335
|
}
|
|
336
336
|
const totals = emptyTotals();
|
|
@@ -547,7 +547,7 @@ async function loadSessionCostSummary(params) {
|
|
|
547
547
|
}
|
|
548
548
|
async function loadSessionUsageTimeSeries(params) {
|
|
549
549
|
const sessionFile = params.sessionFile ?? (params.sessionId ? resolveSessionFilePath(params.sessionId, params.sessionEntry, { agentId: params.agentId }) : undefined);
|
|
550
|
-
if (!sessionFile || !
|
|
550
|
+
if (!sessionFile || !fs.existsSync(sessionFile)) {
|
|
551
551
|
return null;
|
|
552
552
|
}
|
|
553
553
|
const points = [];
|
|
@@ -635,7 +635,7 @@ async function loadSessionUsageTimeSeries(params) {
|
|
|
635
635
|
}
|
|
636
636
|
async function loadSessionLogs(params) {
|
|
637
637
|
const sessionFile = params.sessionFile ?? (params.sessionId ? resolveSessionFilePath(params.sessionId, params.sessionEntry, { agentId: params.agentId }) : undefined);
|
|
638
|
-
if (!sessionFile || !
|
|
638
|
+
if (!sessionFile || !fs.existsSync(sessionFile)) {
|
|
639
639
|
return null;
|
|
640
640
|
}
|
|
641
641
|
const logs = [];
|
package/dist/infra/shell-env.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sanitizeHostExecEnv } from "./host-env-security.js";
|
|
2
2
|
import { isTruthyEnvValue } from "./env.js";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
@@ -34,7 +34,7 @@ function readEtcShells() {
|
|
|
34
34
|
return cachedEtcShells;
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
-
const raw =
|
|
37
|
+
const raw = fs.readFileSync("/etc/shells", "utf8");
|
|
38
38
|
const entries = raw.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#") && path.isAbsolute(line));
|
|
39
39
|
cachedEtcShells = new Set(entries);
|
|
40
40
|
} catch {
|