From 5bed76d7348e8f67dd4874093187439f70c304c4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 1 May 2026 18:10:32 +0100 Subject: [PATCH] refactor: trim file transfer helper exports --- .../file-transfer/src/node-host/dir-fetch.ts | 14 +++++++------- extensions/file-transfer/src/node-host/dir-list.ts | 12 ++++++------ .../file-transfer/src/node-host/file-fetch.ts | 10 +++++----- extensions/file-transfer/src/shared/audit.ts | 4 ++-- extensions/file-transfer/src/shared/errors.ts | 4 ++-- extensions/file-transfer/src/shared/params.ts | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/extensions/file-transfer/src/node-host/dir-fetch.ts b/extensions/file-transfer/src/node-host/dir-fetch.ts index 81f16699dcf..ab13461c6fb 100644 --- a/extensions/file-transfer/src/node-host/dir-fetch.ts +++ b/extensions/file-transfer/src/node-host/dir-fetch.ts @@ -3,10 +3,10 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; -export const DIR_FETCH_HARD_MAX_BYTES = 16 * 1024 * 1024; -export const DIR_FETCH_DEFAULT_MAX_BYTES = 8 * 1024 * 1024; +const DIR_FETCH_HARD_MAX_BYTES = 16 * 1024 * 1024; +const DIR_FETCH_DEFAULT_MAX_BYTES = 8 * 1024 * 1024; -export type DirFetchParams = { +type DirFetchParams = { path?: unknown; maxBytes?: unknown; includeDotfiles?: unknown; @@ -14,7 +14,7 @@ export type DirFetchParams = { preflightOnly?: unknown; }; -export type DirFetchOk = { +type DirFetchOk = { ok: true; path: string; tarBase64: string; @@ -25,7 +25,7 @@ export type DirFetchOk = { preflightOnly?: boolean; }; -export type DirFetchErrCode = +type DirFetchErrCode = | "INVALID_PATH" | "NOT_FOUND" | "IS_FILE" @@ -33,14 +33,14 @@ export type DirFetchErrCode = | "SYMLINK_REDIRECT" | "READ_ERROR"; -export type DirFetchErr = { +type DirFetchErr = { ok: false; code: DirFetchErrCode; message: string; canonicalPath?: string; }; -export type DirFetchResult = DirFetchOk | DirFetchErr; +type DirFetchResult = DirFetchOk | DirFetchErr; function clampMaxBytes(input: unknown): number { if (typeof input !== "number" || !Number.isFinite(input) || input <= 0) { diff --git a/extensions/file-transfer/src/node-host/dir-list.ts b/extensions/file-transfer/src/node-host/dir-list.ts index bc9523982a3..f6bc587f87d 100644 --- a/extensions/file-transfer/src/node-host/dir-list.ts +++ b/extensions/file-transfer/src/node-host/dir-list.ts @@ -5,14 +5,14 @@ import { mimeFromExtension } from "../shared/mime.js"; export const DIR_LIST_DEFAULT_MAX_ENTRIES = 200; export const DIR_LIST_HARD_MAX_ENTRIES = 5000; -export type DirListParams = { +type DirListParams = { path?: unknown; pageToken?: unknown; maxEntries?: unknown; followSymlinks?: unknown; }; -export type DirListEntry = { +type DirListEntry = { name: string; path: string; size: number; @@ -21,7 +21,7 @@ export type DirListEntry = { mtime: number; }; -export type DirListOk = { +type DirListOk = { ok: true; path: string; entries: DirListEntry[]; @@ -29,7 +29,7 @@ export type DirListOk = { truncated: boolean; }; -export type DirListErrCode = +type DirListErrCode = | "INVALID_PATH" | "NOT_FOUND" | "PERMISSION_DENIED" @@ -37,14 +37,14 @@ export type DirListErrCode = | "SYMLINK_REDIRECT" | "READ_ERROR"; -export type DirListErr = { +type DirListErr = { ok: false; code: DirListErrCode; message: string; canonicalPath?: string; }; -export type DirListResult = DirListOk | DirListErr; +type DirListResult = DirListOk | DirListErr; function clampMaxEntries(input: unknown): number { if (typeof input !== "number" || !Number.isFinite(input) || input <= 0) { diff --git a/extensions/file-transfer/src/node-host/file-fetch.ts b/extensions/file-transfer/src/node-host/file-fetch.ts index 232e5421f0c..fd4151b1491 100644 --- a/extensions/file-transfer/src/node-host/file-fetch.ts +++ b/extensions/file-transfer/src/node-host/file-fetch.ts @@ -7,14 +7,14 @@ import { EXTENSION_MIME } from "../shared/mime.js"; export const FILE_FETCH_HARD_MAX_BYTES = 16 * 1024 * 1024; export const FILE_FETCH_DEFAULT_MAX_BYTES = 8 * 1024 * 1024; -export type FileFetchParams = { +type FileFetchParams = { path?: unknown; maxBytes?: unknown; followSymlinks?: unknown; preflightOnly?: unknown; }; -export type FileFetchOk = { +type FileFetchOk = { ok: true; path: string; size: number; @@ -24,7 +24,7 @@ export type FileFetchOk = { preflightOnly?: boolean; }; -export type FileFetchErrCode = +type FileFetchErrCode = | "INVALID_PATH" | "NOT_FOUND" | "PERMISSION_DENIED" @@ -34,14 +34,14 @@ export type FileFetchErrCode = | "SYMLINK_REDIRECT" | "READ_ERROR"; -export type FileFetchErr = { +type FileFetchErr = { ok: false; code: FileFetchErrCode; message: string; canonicalPath?: string; }; -export type FileFetchResult = FileFetchOk | FileFetchErr; +type FileFetchResult = FileFetchOk | FileFetchErr; function detectMimeType(filePath: string): string { if (process.platform !== "win32") { diff --git a/extensions/file-transfer/src/shared/audit.ts b/extensions/file-transfer/src/shared/audit.ts index 88206ca66aa..d30e6148548 100644 --- a/extensions/file-transfer/src/shared/audit.ts +++ b/extensions/file-transfer/src/shared/audit.ts @@ -14,7 +14,7 @@ import path from "node:path"; export type FileTransferAuditOp = "file.fetch" | "dir.list" | "dir.fetch" | "file.write"; -export type FileTransferAuditDecision = +type FileTransferAuditDecision = | "allowed" | "allowed:once" | "allowed:always" @@ -25,7 +25,7 @@ export type FileTransferAuditDecision = | "denied:symlink_escape" | "error"; -export type FileTransferAuditRecord = { +type FileTransferAuditRecord = { timestamp: string; op: FileTransferAuditOp; nodeId: string; diff --git a/extensions/file-transfer/src/shared/errors.ts b/extensions/file-transfer/src/shared/errors.ts index 9c1ed19d8f0..5044eab1e2a 100644 --- a/extensions/file-transfer/src/shared/errors.ts +++ b/extensions/file-transfer/src/shared/errors.ts @@ -2,7 +2,7 @@ // Every tool returns the same { ok: false, code, message, canonicalPath? } // shape so the model can reason about errors uniformly. -export type FileTransferErrCode = +type FileTransferErrCode = // Path-shape errors (caller's fault) | "INVALID_PATH" | "INVALID_BASE64" @@ -27,7 +27,7 @@ export type FileTransferErrCode = | "POLICY_DENIED" | "NO_POLICY"; -export type FileTransferErr = { +type FileTransferErr = { ok: false; code: FileTransferErrCode; message: string; diff --git a/extensions/file-transfer/src/shared/params.ts b/extensions/file-transfer/src/shared/params.ts index f5b5c3f022e..c9027236132 100644 --- a/extensions/file-transfer/src/shared/params.ts +++ b/extensions/file-transfer/src/shared/params.ts @@ -1,7 +1,7 @@ // Shared param-validation helpers used by all four agent tools. // Goal: identical validation behavior + identical error shapes everywhere. -export type GatewayCallOptions = { +type GatewayCallOptions = { gatewayUrl?: string; gatewayToken?: string; timeoutMs?: number;