diff --git a/packages/memory-host-sdk/src/host/embedding-worker-errors.ts b/packages/memory-host-sdk/src/host/embedding-worker-errors.ts index 5342cf56da16..579379ec3a3d 100644 --- a/packages/memory-host-sdk/src/host/embedding-worker-errors.ts +++ b/packages/memory-host-sdk/src/host/embedding-worker-errors.ts @@ -8,14 +8,14 @@ export const LOCAL_EMBEDDING_WORKER_ERROR_CODES = { } as const; /** Error code union for local embedding worker failures. */ -export type LocalEmbeddingWorkerFailureCode = +type LocalEmbeddingWorkerFailureCode = (typeof LOCAL_EMBEDDING_WORKER_ERROR_CODES)[keyof typeof LOCAL_EMBEDDING_WORKER_ERROR_CODES]; /** Cause category for local embedding worker failures. */ type LocalEmbeddingWorkerFailureReason = "exit" | "signal" | "process-error" | "ipc"; -/** Error shape used by callers that need retry/status decisions. */ -export type LocalEmbeddingWorkerFailureError = Error & { +/** Error shape returned by the local embedding worker failure factory. */ +type LocalEmbeddingWorkerFailureError = Error & { code: LocalEmbeddingWorkerFailureCode; reason: LocalEmbeddingWorkerFailureReason; exitCode?: number | null; diff --git a/packages/memory-host-sdk/src/host/fs-utils.ts b/packages/memory-host-sdk/src/host/fs-utils.ts index 019daad2906d..de2aef2fa920 100644 --- a/packages/memory-host-sdk/src/host/fs-utils.ts +++ b/packages/memory-host-sdk/src/host/fs-utils.ts @@ -8,7 +8,6 @@ export { assertNoSymlinkParents, readRegularFile, statRegularFile, - type RegularFileStatResult, } from "@openclaw/fs-safe/advanced"; export { walkDirectory, type WalkDirectoryEntry } from "@openclaw/fs-safe/walk"; diff --git a/packages/memory-host-sdk/src/host/node-llama.ts b/packages/memory-host-sdk/src/host/node-llama.ts index ba7cb2f56155..b6aa69773457 100644 --- a/packages/memory-host-sdk/src/host/node-llama.ts +++ b/packages/memory-host-sdk/src/host/node-llama.ts @@ -1,7 +1,7 @@ // Minimal node-llama-cpp type facade used by the local embedding provider. /** Embedding vector returned by node-llama-cpp. */ -export type LlamaEmbedding = { +type LlamaEmbedding = { vector: Float32Array | number[]; }; @@ -21,7 +21,7 @@ export type LlamaModel = { }; /** Options accepted by node-llama-cpp model file resolution. */ -export type ResolveModelFileOptions = { +type ResolveModelFileOptions = { directory?: string; signal?: AbortSignal; }; diff --git a/packages/memory-host-sdk/src/host/retry-utils.test.ts b/packages/memory-host-sdk/src/host/retry-utils.test.ts index 94695ff8ee1f..0a884fe1a3e2 100644 --- a/packages/memory-host-sdk/src/host/retry-utils.test.ts +++ b/packages/memory-host-sdk/src/host/retry-utils.test.ts @@ -1,37 +1,12 @@ // Memory Host SDK tests cover retry utils behavior. import { afterEach, describe, expect, it, vi } from "vitest"; import { MAX_SAFE_TIMEOUT_DELAY_MS } from "../../../gateway-client/src/timeouts.js"; -import { resolveRetryConfig, retryAsync } from "./retry-utils.js"; +import { retryAsync } from "./retry-utils.js"; afterEach(() => { vi.restoreAllMocks(); }); -describe("resolveRetryConfig", () => { - const defaults = { - attempts: 4, - minDelayMs: 0, - maxDelayMs: 0, - jitter: 0, - }; - - it("does not round malformed attempt counts", () => { - expect(resolveRetryConfig(defaults, { attempts: 1.5 }).attempts).toBe(4); - expect(resolveRetryConfig(defaults, { attempts: Number.POSITIVE_INFINITY }).attempts).toBe(4); - expect(resolveRetryConfig(defaults, { attempts: Number.NaN }).attempts).toBe(4); - }); - - it("caps oversized retry delays at the timer-safe ceiling", () => { - const config = resolveRetryConfig(defaults, { - minDelayMs: Number.MAX_SAFE_INTEGER, - maxDelayMs: Number.MAX_SAFE_INTEGER, - }); - - expect(config.minDelayMs).toBe(MAX_SAFE_TIMEOUT_DELAY_MS); - expect(config.maxDelayMs).toBe(MAX_SAFE_TIMEOUT_DELAY_MS); - }); -}); - describe("retryAsync", () => { it("falls back to the default attempt count for malformed numeric counts", async () => { const run = vi.fn(async () => { @@ -43,6 +18,22 @@ describe("retryAsync", () => { expect(run).toHaveBeenCalledTimes(3); }); + it("falls back to the default attempt count for malformed option counts", async () => { + const run = vi.fn(async () => { + throw new Error("boom"); + }); + + await expect( + retryAsync(run, { + attempts: 1.5, + minDelayMs: 0, + maxDelayMs: 0, + }), + ).rejects.toThrow("boom"); + + expect(run).toHaveBeenCalledTimes(3); + }); + it("caps legacy numeric retry sleeps at the timer-safe ceiling", async () => { const run = vi .fn<() => Promise>() diff --git a/packages/memory-host-sdk/src/host/retry-utils.ts b/packages/memory-host-sdk/src/host/retry-utils.ts index f9899da4baeb..e6b9888b23c5 100644 --- a/packages/memory-host-sdk/src/host/retry-utils.ts +++ b/packages/memory-host-sdk/src/host/retry-utils.ts @@ -2,7 +2,7 @@ import { resolveSafeTimeoutDelayMs } from "../../../gateway-client/src/timeouts.js"; /** Retry timing configuration with optional jitter. */ -export type RetryConfig = { +type RetryConfig = { attempts?: number; minDelayMs?: number; maxDelayMs?: number; @@ -10,7 +10,7 @@ export type RetryConfig = { }; /** Retry callback payload. */ -export type RetryInfo = { +type RetryInfo = { attempt: number; maxAttempts: number; delayMs: number; @@ -19,7 +19,7 @@ export type RetryInfo = { }; /** Retry options for retryAsync. */ -export type RetryOptions = RetryConfig & { +type RetryOptions = RetryConfig & { label?: string; shouldRetry?: (err: unknown, attempt: number) => boolean; retryAfterMs?: (err: unknown) => number | undefined; @@ -64,7 +64,7 @@ function resolveAttempts(value: unknown, fallback: number): number { } /** Resolve retry settings with clamped positive timeout values. */ -export function resolveRetryConfig( +function resolveRetryConfig( defaults: Required = DEFAULT_RETRY_CONFIG, overrides?: RetryConfig, ): Required { diff --git a/packages/memory-host-sdk/src/host/secret-input-utils.ts b/packages/memory-host-sdk/src/host/secret-input-utils.ts index 275ea69d4438..b700630a0947 100644 --- a/packages/memory-host-sdk/src/host/secret-input-utils.ts +++ b/packages/memory-host-sdk/src/host/secret-input-utils.ts @@ -1,10 +1,10 @@ // Secret input parsing shared by memory provider config and gateway-resolved snapshots. /** Supported secret reference backing stores. */ -export type SecretRefSource = "env" | "file" | "exec"; +type SecretRefSource = "env" | "file" | "exec"; /** Canonical secret reference shape used after gateway resolution. */ -export type SecretRef = { +type SecretRef = { source: SecretRefSource; provider: string; id: string; diff --git a/packages/memory-host-sdk/src/host/session-files.ts b/packages/memory-host-sdk/src/host/session-files.ts index 4bc74e57acba..865fcad602d5 100644 --- a/packages/memory-host-sdk/src/host/session-files.ts +++ b/packages/memory-host-sdk/src/host/session-files.ts @@ -34,7 +34,6 @@ import type { MemorySessionSyncTarget } from "./types.js"; export { listSessionTranscriptCorpusEntriesForAgent, - type SessionTranscriptCorpusArtifactKind, type SessionTranscriptCorpusEntry, } from "./session-transcript-corpus.js"; @@ -241,7 +240,7 @@ function isCanonicalSessionsDirForAgent(sessionsDir: string, agentId: string): b ); } -export function loadSessionTranscriptClassificationForSessionsDir( +function loadSessionTranscriptClassificationForSessionsDir( sessionsDir: string, ): SessionTranscriptClassification { const agentId = extractAgentIdFromSessionsDir(sessionsDir); diff --git a/packages/memory-host-sdk/src/host/session-transcript-corpus.ts b/packages/memory-host-sdk/src/host/session-transcript-corpus.ts index b59c57b793d2..86e3126b65cd 100644 --- a/packages/memory-host-sdk/src/host/session-transcript-corpus.ts +++ b/packages/memory-host-sdk/src/host/session-transcript-corpus.ts @@ -18,7 +18,7 @@ import { type SessionEntry, } from "./openclaw-runtime-session.js"; -export type SessionTranscriptCorpusArtifactKind = +type SessionTranscriptCorpusArtifactKind = | "active-session" | "archive-artifact" | "orphan-file-artifact"; diff --git a/packages/memory-host-sdk/src/host/string-utils.ts b/packages/memory-host-sdk/src/host/string-utils.ts index cb7bfafc8b15..2d525a51ed35 100644 --- a/packages/memory-host-sdk/src/host/string-utils.ts +++ b/packages/memory-host-sdk/src/host/string-utils.ts @@ -1,7 +1,7 @@ // Small string normalization helpers kept local to memory-host-sdk for package // builds that should not depend on the full normalization package graph. /** Normalize a non-empty string or return null. */ -export function normalizeNullableString(value: unknown): string | null { +function normalizeNullableString(value: unknown): string | null { if (typeof value !== "string") { return null; }