diff --git a/src/memory/batch-embedding-common.ts b/src/memory/batch-embedding-common.ts new file mode 100644 index 00000000000..f572427ea65 --- /dev/null +++ b/src/memory/batch-embedding-common.ts @@ -0,0 +1,16 @@ +export { extractBatchErrorMessage, formatUnavailableBatchError } from "./batch-error-utils.js"; +export { postJsonWithRetry } from "./batch-http.js"; +export { applyEmbeddingBatchOutputLine } from "./batch-output.js"; +export { + EMBEDDING_BATCH_ENDPOINT, + type EmbeddingBatchStatus, + type ProviderBatchOutputLine, +} from "./batch-provider-common.js"; +export { + buildEmbeddingBatchGroupOptions, + runEmbeddingBatchGroups, + type EmbeddingBatchExecutionParams, +} from "./batch-runner.js"; +export { uploadBatchJsonlFile } from "./batch-upload.js"; +export { buildBatchHeaders, normalizeBatchBaseUrl } from "./batch-utils.js"; +export { withRemoteHttpResponse } from "./remote-http.js"; diff --git a/src/memory/batch-openai.ts b/src/memory/batch-openai.ts index 158b75faf1f..cdf5a10a8a0 100644 --- a/src/memory/batch-openai.ts +++ b/src/memory/batch-openai.ts @@ -1,20 +1,20 @@ -import { extractBatchErrorMessage, formatUnavailableBatchError } from "./batch-error-utils.js"; -import { postJsonWithRetry } from "./batch-http.js"; -import { applyEmbeddingBatchOutputLine } from "./batch-output.js"; -import { - EMBEDDING_BATCH_ENDPOINT, - type EmbeddingBatchStatus, - type ProviderBatchOutputLine, -} from "./batch-provider-common.js"; import { + applyEmbeddingBatchOutputLine, + buildBatchHeaders, buildEmbeddingBatchGroupOptions, + EMBEDDING_BATCH_ENDPOINT, + extractBatchErrorMessage, + formatUnavailableBatchError, + normalizeBatchBaseUrl, + postJsonWithRetry, runEmbeddingBatchGroups, type EmbeddingBatchExecutionParams, -} from "./batch-runner.js"; -import { uploadBatchJsonlFile } from "./batch-upload.js"; -import { buildBatchHeaders, normalizeBatchBaseUrl } from "./batch-utils.js"; + type EmbeddingBatchStatus, + type ProviderBatchOutputLine, + uploadBatchJsonlFile, + withRemoteHttpResponse, +} from "./batch-embedding-common.js"; import type { OpenAiEmbeddingClient } from "./embeddings-openai.js"; -import { withRemoteHttpResponse } from "./remote-http.js"; export type OpenAiBatchRequest = { custom_id: string; diff --git a/src/memory/batch-voyage.ts b/src/memory/batch-voyage.ts index 07722ac19f2..35bd0d4e60e 100644 --- a/src/memory/batch-voyage.ts +++ b/src/memory/batch-voyage.ts @@ -1,22 +1,22 @@ import { createInterface } from "node:readline"; import { Readable } from "node:stream"; -import { extractBatchErrorMessage, formatUnavailableBatchError } from "./batch-error-utils.js"; -import { postJsonWithRetry } from "./batch-http.js"; -import { applyEmbeddingBatchOutputLine } from "./batch-output.js"; -import { - EMBEDDING_BATCH_ENDPOINT, - type EmbeddingBatchStatus, - type ProviderBatchOutputLine, -} from "./batch-provider-common.js"; import { + applyEmbeddingBatchOutputLine, + buildBatchHeaders, buildEmbeddingBatchGroupOptions, + EMBEDDING_BATCH_ENDPOINT, + extractBatchErrorMessage, + formatUnavailableBatchError, + normalizeBatchBaseUrl, + postJsonWithRetry, runEmbeddingBatchGroups, type EmbeddingBatchExecutionParams, -} from "./batch-runner.js"; -import { uploadBatchJsonlFile } from "./batch-upload.js"; -import { buildBatchHeaders, normalizeBatchBaseUrl } from "./batch-utils.js"; + type EmbeddingBatchStatus, + type ProviderBatchOutputLine, + uploadBatchJsonlFile, + withRemoteHttpResponse, +} from "./batch-embedding-common.js"; import type { VoyageEmbeddingClient } from "./embeddings-voyage.js"; -import { withRemoteHttpResponse } from "./remote-http.js"; /** * Voyage Batch API Input Line format. diff --git a/src/secrets/apply.ts b/src/secrets/apply.ts index a9756b760a1..44adedc3d5f 100644 --- a/src/secrets/apply.ts +++ b/src/secrets/apply.ts @@ -20,7 +20,7 @@ import { import { listKnownSecretEnvVarNames } from "./provider-env-vars.js"; import { resolveSecretRefValue } from "./resolve.js"; import { prepareSecretsRuntimeSnapshot } from "./runtime.js"; -import { isNonEmptyString, isRecord, writeTextFileAtomic } from "./shared.js"; +import { isNonEmptyString, isRecord, parseEnvValue, writeTextFileAtomic } from "./shared.js"; type FileSnapshot = { existed: boolean; @@ -118,17 +118,6 @@ function resolveTargetPathSegments(target: SecretsPlanTarget): string[] { return resolved; } -function parseEnvValue(raw: string): string { - const trimmed = raw.trim(); - if ( - (trimmed.startsWith('"') && trimmed.endsWith('"')) || - (trimmed.startsWith("'") && trimmed.endsWith("'")) - ) { - return trimmed.slice(1, -1); - } - return trimmed; -} - function scrubEnvRaw( raw: string, migratedValues: Set, diff --git a/src/secrets/audit.ts b/src/secrets/audit.ts index fc4ba874ca6..906aafa21fb 100644 --- a/src/secrets/audit.ts +++ b/src/secrets/audit.ts @@ -14,7 +14,7 @@ import { resolveSecretRefValues, type SecretRefResolveCache, } from "./resolve.js"; -import { isNonEmptyString, isRecord } from "./shared.js"; +import { isNonEmptyString, isRecord, parseEnvValue } from "./shared.js"; export type SecretsAuditCode = | "PLAINTEXT_FOUND" @@ -116,17 +116,6 @@ function parseDotPath(pathname: string): string[] { return pathname.split(".").filter(Boolean); } -function parseEnvValue(raw: string): string { - const trimmed = raw.trim(); - if ( - (trimmed.startsWith('"') && trimmed.endsWith('"')) || - (trimmed.startsWith("'") && trimmed.endsWith("'")) - ) { - return trimmed.slice(1, -1); - } - return trimmed; -} - function collectEnvPlaintext(params: { envPath: string; collector: AuditCollector }): void { if (!fs.existsSync(params.envPath)) { return; diff --git a/src/secrets/shared.ts b/src/secrets/shared.ts index d576ae1cdba..c3e3e086857 100644 --- a/src/secrets/shared.ts +++ b/src/secrets/shared.ts @@ -9,6 +9,17 @@ export function isNonEmptyString(value: unknown): value is string { return typeof value === "string" && value.trim().length > 0; } +export function parseEnvValue(raw: string): string { + const trimmed = raw.trim(); + if ( + (trimmed.startsWith('"') && trimmed.endsWith('"')) || + (trimmed.startsWith("'") && trimmed.endsWith("'")) + ) { + return trimmed.slice(1, -1); + } + return trimmed; +} + export function normalizePositiveInt(value: unknown, fallback: number): number { if (typeof value === "number" && Number.isFinite(value)) { return Math.max(1, Math.floor(value));