refactor: extract memory host sdk package

This commit is contained in:
Peter Steinberger
2026-03-27 02:48:06 +00:00
parent dff3ca2018
commit bd6c7969ea
41 changed files with 577 additions and 289 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
export * from "openclaw/plugin-sdk/memory-core-host-runtime";

View File

@@ -7,13 +7,7 @@ import {
defaultRuntime,
formatErrorMessage,
isRich,
listMemoryFiles,
loadConfig,
normalizeExtraMemoryPaths,
resolveCommandSecretRefsViaGateway,
resolveDefaultAgentId,
resolveSessionTranscriptsDirForAgent,
resolveStateDir,
setVerbose,
shortenHomeInString,
shortenHomePath,
@@ -21,8 +15,18 @@ import {
withManager,
withProgress,
withProgressTotals,
} from "openclaw/plugin-sdk/memory-core-host-runtime-cli";
import {
loadConfig,
resolveDefaultAgentId,
resolveSessionTranscriptsDirForAgent,
resolveStateDir,
type OpenClawConfig,
} from "./api.js";
} from "openclaw/plugin-sdk/memory-core-host-runtime-core";
import {
listMemoryFiles,
normalizeExtraMemoryPaths,
} from "openclaw/plugin-sdk/memory-core-host-runtime-files";
import type { MemoryCommandOptions, MemorySearchCommandOptions } from "./cli.types.js";
import { getMemorySearchManager } from "./runtime-api.js";

View File

@@ -20,12 +20,21 @@ const resolveCommandSecretRefsViaGateway = vi.hoisted(() =>
})),
);
vi.mock("./api.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("./api.js")>();
vi.mock("openclaw/plugin-sdk/memory-core-host-runtime-core", async (importOriginal) => {
const actual =
await importOriginal<typeof import("openclaw/plugin-sdk/memory-core-host-runtime-core")>();
return {
...actual,
loadConfig,
resolveDefaultAgentId,
};
});
vi.mock("openclaw/plugin-sdk/memory-core-host-runtime-cli", async (importOriginal) => {
const actual =
await importOriginal<typeof import("openclaw/plugin-sdk/memory-core-host-runtime-cli")>();
return {
...actual,
resolveCommandSecretRefsViaGateway,
};
});
@@ -39,13 +48,14 @@ vi.mock("./runtime-api.js", async (importOriginal) => {
});
let registerMemoryCli: typeof import("./cli.js").registerMemoryCli;
let defaultRuntime: typeof import("./api.js").defaultRuntime;
let isVerbose: typeof import("./api.js").isVerbose;
let setVerbose: typeof import("./api.js").setVerbose;
let defaultRuntime: typeof import("openclaw/plugin-sdk/memory-core-host-runtime-cli").defaultRuntime;
let isVerbose: typeof import("openclaw/plugin-sdk/memory-core-host-runtime-cli").isVerbose;
let setVerbose: typeof import("openclaw/plugin-sdk/memory-core-host-runtime-cli").setVerbose;
beforeAll(async () => {
({ registerMemoryCli } = await import("./cli.js"));
({ defaultRuntime, isVerbose, setVerbose } = await import("./api.js"));
({ defaultRuntime, isVerbose, setVerbose } =
await import("openclaw/plugin-sdk/memory-core-host-runtime-cli"));
});
beforeEach(() => {

View File

@@ -1,5 +1,9 @@
import type { Command } from "commander";
import { formatDocsLink, formatHelpExamples, theme } from "./api.js";
import {
formatDocsLink,
formatHelpExamples,
theme,
} from "openclaw/plugin-sdk/memory-core-host-runtime-cli";
import type { MemoryCommandOptions, MemorySearchCommandOptions } from "./cli.types.js";
type MemoryCliRuntime = typeof import("./cli.runtime.js");

View File

@@ -1 +1,4 @@
export * from "openclaw/plugin-sdk/memory-core-host-engine";
export * from "openclaw/plugin-sdk/memory-core-host-engine-foundation";
export * from "openclaw/plugin-sdk/memory-core-host-engine-storage";
export * from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
export * from "openclaw/plugin-sdk/memory-core-host-engine-qmd";

View File

@@ -5,7 +5,7 @@ import {
SILENT_REPLY_TOKEN,
type MemoryFlushPlan,
type OpenClawConfig,
} from "./api.js";
} from "openclaw/plugin-sdk/memory-core-host-runtime-core";
export const DEFAULT_MEMORY_FLUSH_SOFT_TOKENS = 4000;
export const DEFAULT_MEMORY_FLUSH_FORCE_TRANSCRIPT_BYTES = 2 * 1024 * 1024;

View File

@@ -67,10 +67,10 @@ function isMcporterCommand(cmd: unknown): boolean {
return /(^|[\\/])mcporter(?:\.cmd)?$/i.test(cmd);
}
vi.mock("openclaw/plugin-sdk/memory-core-host-engine", async () => {
vi.mock("openclaw/plugin-sdk/memory-core-host-engine-foundation", async () => {
const actual = await vi.importActual<
typeof import("openclaw/plugin-sdk/memory-core-host-engine")
>("openclaw/plugin-sdk/memory-core-host-engine");
typeof import("openclaw/plugin-sdk/memory-core-host-engine-foundation")
>("openclaw/plugin-sdk/memory-core-host-engine-foundation");
return {
...actual,
createSubsystemLogger: () => {

View File

@@ -1,4 +1,4 @@
import type { MemoryPromptSectionBuilder } from "./api.js";
import type { MemoryPromptSectionBuilder } from "openclaw/plugin-sdk/memory-core-host-runtime-core";
export const buildPromptSection: MemoryPromptSectionBuilder = ({
availableTools,

View File

@@ -1,2 +1 @@
export * from "./api.js";
export * from "./memory/index.js";

View File

@@ -1,4 +1,5 @@
import { resolveMemoryBackendConfig, type MemoryPluginRuntime } from "./api.js";
import type { MemoryPluginRuntime } from "openclaw/plugin-sdk/memory-core-host-runtime-core";
import { resolveMemoryBackendConfig } from "openclaw/plugin-sdk/memory-core-host-runtime-files";
import { closeAllMemorySearchManagers, getMemorySearchManager } from "./runtime-api.js";
export const memoryRuntime: MemoryPluginRuntime = {

View File

@@ -1,9 +1,9 @@
import {
parseAgentSessionKey,
type MemoryCitationsMode,
type MemorySearchResult,
type OpenClawConfig,
} from "./api.js";
} from "openclaw/plugin-sdk/memory-core-host-runtime-core";
import type { MemorySearchResult } from "openclaw/plugin-sdk/memory-core-host-runtime-files";
export function resolveMemoryCitationsMode(cfg: OpenClawConfig): MemoryCitationsMode {
const mode = cfg.memory?.citations;

View File

@@ -1,2 +1,5 @@
export { readAgentMemoryFile, resolveMemoryBackendConfig } from "./api.js";
export {
readAgentMemoryFile,
resolveMemoryBackendConfig,
} from "openclaw/plugin-sdk/memory-core-host-runtime-files";
export { getMemorySearchManager } from "./runtime-api.js";

View File

@@ -4,7 +4,7 @@ import {
resolveSessionAgentId,
type AnyAgentTool,
type OpenClawConfig,
} from "./api.js";
} from "openclaw/plugin-sdk/memory-core-host-runtime-core";
type MemoryToolRuntime = typeof import("./tools.runtime.js");
type MemorySearchManagerResult = Awaited<

View File

@@ -4,7 +4,7 @@ import {
readStringParam,
type AnyAgentTool,
type OpenClawConfig,
} from "./api.js";
} from "openclaw/plugin-sdk/memory-core-host-runtime-core";
import {
clampResultsByInjectedChars,
decorateCitations,

View File

@@ -432,10 +432,38 @@
"types": "./dist/plugin-sdk/memory-core-host-engine.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-engine.js"
},
"./plugin-sdk/memory-core-host-engine-embeddings": {
"types": "./dist/plugin-sdk/memory-core-host-engine-embeddings.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-engine-embeddings.js"
},
"./plugin-sdk/memory-core-host-engine-foundation": {
"types": "./dist/plugin-sdk/memory-core-host-engine-foundation.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-engine-foundation.js"
},
"./plugin-sdk/memory-core-host-engine-qmd": {
"types": "./dist/plugin-sdk/memory-core-host-engine-qmd.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-engine-qmd.js"
},
"./plugin-sdk/memory-core-host-engine-storage": {
"types": "./dist/plugin-sdk/memory-core-host-engine-storage.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-engine-storage.js"
},
"./plugin-sdk/memory-core-host-runtime": {
"types": "./dist/plugin-sdk/memory-core-host-runtime.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-runtime.js"
},
"./plugin-sdk/memory-core-host-runtime-cli": {
"types": "./dist/plugin-sdk/memory-core-host-runtime-cli.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-runtime-cli.js"
},
"./plugin-sdk/memory-core-host-runtime-core": {
"types": "./dist/plugin-sdk/memory-core-host-runtime-core.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-runtime-core.js"
},
"./plugin-sdk/memory-core-host-runtime-files": {
"types": "./dist/plugin-sdk/memory-core-host-runtime-files.d.ts",
"default": "./dist/plugin-sdk/memory-core-host-runtime-files.js"
},
"./plugin-sdk/memory-lancedb": {
"types": "./dist/plugin-sdk/memory-lancedb.d.ts",
"default": "./dist/plugin-sdk/memory-lancedb.js"

View File

@@ -0,0 +1,17 @@
{
"name": "@openclaw/memory-host-sdk",
"version": "0.0.0-private",
"private": true,
"type": "module",
"exports": {
"./runtime": "./src/runtime.ts",
"./runtime-core": "./src/runtime-core.ts",
"./runtime-cli": "./src/runtime-cli.ts",
"./runtime-files": "./src/runtime-files.ts",
"./engine": "./src/engine.ts",
"./engine-foundation": "./src/engine-foundation.ts",
"./engine-storage": "./src/engine-storage.ts",
"./engine-embeddings": "./src/engine-embeddings.ts",
"./engine-qmd": "./src/engine-qmd.ts"
}
}

View File

@@ -0,0 +1,67 @@
// Real workspace contract for memory embedding providers and batch helpers.
export {
getMemoryEmbeddingProvider,
listMemoryEmbeddingProviders,
} from "../../../src/plugins/memory-embedding-providers.js";
export type {
MemoryEmbeddingBatchChunk,
MemoryEmbeddingBatchOptions,
MemoryEmbeddingProvider,
MemoryEmbeddingProviderAdapter,
MemoryEmbeddingProviderCreateOptions,
MemoryEmbeddingProviderCreateResult,
MemoryEmbeddingProviderRuntime,
} from "../../../src/plugins/memory-embedding-providers.js";
export {
createLocalEmbeddingProvider,
DEFAULT_LOCAL_MODEL,
} from "../../../src/plugins/memory-host/embeddings.js";
export {
createGeminiEmbeddingProvider,
DEFAULT_GEMINI_EMBEDDING_MODEL,
buildGeminiEmbeddingRequest,
} from "../../../src/plugins/memory-host/embeddings-gemini.js";
export {
createMistralEmbeddingProvider,
DEFAULT_MISTRAL_EMBEDDING_MODEL,
} from "../../../src/plugins/memory-host/embeddings-mistral.js";
export {
createOllamaEmbeddingProvider,
DEFAULT_OLLAMA_EMBEDDING_MODEL,
} from "../../../src/plugins/memory-host/embeddings-ollama.js";
export {
createOpenAiEmbeddingProvider,
DEFAULT_OPENAI_EMBEDDING_MODEL,
} from "../../../src/plugins/memory-host/embeddings-openai.js";
export {
createVoyageEmbeddingProvider,
DEFAULT_VOYAGE_EMBEDDING_MODEL,
} from "../../../src/plugins/memory-host/embeddings-voyage.js";
export {
runGeminiEmbeddingBatches,
type GeminiBatchRequest,
} from "../../../src/plugins/memory-host/batch-gemini.js";
export {
OPENAI_BATCH_ENDPOINT,
runOpenAiEmbeddingBatches,
type OpenAiBatchRequest,
} from "../../../src/plugins/memory-host/batch-openai.js";
export {
runVoyageEmbeddingBatches,
type VoyageBatchRequest,
} from "../../../src/plugins/memory-host/batch-voyage.js";
export { enforceEmbeddingMaxInputTokens } from "../../../src/plugins/memory-host/embedding-chunk-limits.js";
export {
estimateStructuredEmbeddingInputBytes,
estimateUtf8Bytes,
} from "../../../src/plugins/memory-host/embedding-input-limits.js";
export {
hasNonTextEmbeddingParts,
type EmbeddingInput,
} from "../../../src/plugins/memory-host/embedding-inputs.js";
export {
buildCaseInsensitiveExtensionGlob,
classifyMemoryMultimodalPath,
getMemoryMultimodalExtensions,
} from "../../../src/plugins/memory-host/multimodal.js";

View File

@@ -0,0 +1,45 @@
// Real workspace contract for memory engine foundation concerns.
export {
resolveAgentDir,
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
resolveSessionAgentId,
} from "../../../src/agents/agent-scope.js";
export {
resolveMemorySearchConfig,
type ResolvedMemorySearchConfig,
} from "../../../src/agents/memory-search.js";
export { parseDurationMs } from "../../../src/cli/parse-duration.js";
export { loadConfig } from "../../../src/config/config.js";
export { resolveStateDir } from "../../../src/config/paths.js";
export { resolveSessionTranscriptsDirForAgent } from "../../../src/config/sessions/paths.js";
export {
hasConfiguredSecretInput,
normalizeResolvedSecretInputString,
} from "../../../src/config/types.secrets.js";
export { writeFileWithinRoot } from "../../../src/infra/fs-safe.js";
export { createSubsystemLogger } from "../../../src/logging/subsystem.js";
export { detectMime } from "../../../src/media/mime.js";
export { resolveGlobalSingleton } from "../../../src/shared/global-singleton.js";
export { onSessionTranscriptUpdate } from "../../../src/sessions/transcript-events.js";
export { splitShellArgs } from "../../../src/utils/shell-argv.js";
export { runTasksWithConcurrency } from "../../../src/utils/run-with-concurrency.js";
export {
shortenHomeInString,
shortenHomePath,
resolveUserPath,
truncateUtf16Safe,
} from "../../../src/utils.js";
export type { OpenClawConfig } from "../../../src/config/config.js";
export type { SessionSendPolicyConfig } from "../../../src/config/types.base.js";
export type { SecretInput } from "../../../src/config/types.secrets.js";
export type {
MemoryBackend,
MemoryCitationsMode,
MemoryQmdConfig,
MemoryQmdIndexPath,
MemoryQmdMcporterConfig,
MemoryQmdSearchMode,
} from "../../../src/config/types.memory.js";
export type { MemorySearchConfig } from "../../../src/config/types.tools.js";

View File

@@ -0,0 +1,25 @@
// Real workspace contract for QMD/session/query helpers used by the memory engine.
export {
extractKeywords,
isQueryStopWordToken,
} from "../../../src/plugins/memory-host/query-expansion.js";
export {
buildSessionEntry,
listSessionFilesForAgent,
sessionPathForFile,
type SessionFileEntry,
} from "../../../src/plugins/memory-host/session-files.js";
export {
parseQmdQueryJson,
type QmdQueryResult,
} from "../../../src/plugins/memory-host/qmd-query-parser.js";
export {
deriveQmdScopeChannel,
deriveQmdScopeChatType,
isQmdScopeAllowed,
} from "../../../src/plugins/memory-host/qmd-scope.js";
export {
resolveCliSpawnInvocation,
runCliCommand,
} from "../../../src/plugins/memory-host/qmd-process.js";

View File

@@ -0,0 +1,36 @@
// Real workspace contract for memory engine storage/index helpers.
export {
buildFileEntry,
buildMultimodalChunkForIndexing,
chunkMarkdown,
cosineSimilarity,
ensureDir,
hashText,
listMemoryFiles,
normalizeExtraMemoryPaths,
parseEmbedding,
remapChunkLines,
runWithConcurrency,
type MemoryChunk,
type MemoryFileEntry,
} from "../../../src/plugins/memory-host/internal.js";
export { readMemoryFile } from "../../../src/plugins/memory-host/read-file.js";
export { resolveMemoryBackendConfig } from "../../../src/plugins/memory-host/backend-config.js";
export type {
ResolvedMemoryBackendConfig,
ResolvedQmdConfig,
ResolvedQmdMcporterConfig,
} from "../../../src/plugins/memory-host/backend-config.js";
export type {
MemoryEmbeddingProbeResult,
MemoryProviderStatus,
MemorySearchManager,
MemorySearchResult,
MemorySource,
MemorySyncProgressUpdate,
} from "../../../src/plugins/memory-host/types.js";
export { ensureMemoryIndexSchema } from "../../../src/plugins/memory-host/memory-schema.js";
export { loadSqliteVecExtension } from "../../../src/plugins/memory-host/sqlite-vec.js";
export { requireNodeSqlite } from "../../../src/plugins/memory-host/sqlite.js";
export { isFileMissingError, statRegularFile } from "../../../src/plugins/memory-host/fs-utils.js";

View File

@@ -0,0 +1,7 @@
// Aggregate workspace contract for the memory engine surface.
// Keep focused subpaths preferred for new code.
export * from "./engine-foundation.js";
export * from "./engine-storage.js";
export * from "./engine-embeddings.js";
export * from "./engine-qmd.js";

View File

@@ -0,0 +1,11 @@
// Focused runtime contract for memory CLI/UI helpers.
export { formatErrorMessage, withManager } from "../../../src/cli/cli-utils.js";
export { formatHelpExamples } from "../../../src/cli/help-format.js";
export { resolveCommandSecretRefsViaGateway } from "../../../src/cli/command-secret-gateway.js";
export { withProgress, withProgressTotals } from "../../../src/cli/progress.js";
export { defaultRuntime } from "../../../src/runtime.js";
export { formatDocsLink } from "../../../src/terminal/links.js";
export { colorize, isRich, theme } from "../../../src/terminal/theme.js";
export { isVerbose, setVerbose } from "../../../src/globals.js";
export { shortenHomeInString, shortenHomePath } from "../../../src/utils.js";

View File

@@ -0,0 +1,24 @@
// Focused runtime contract for memory plugin config/state/helpers.
export type { AnyAgentTool } from "../../../src/agents/tools/common.js";
export { resolveCronStyleNow } from "../../../src/agents/current-time.js";
export { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR } from "../../../src/agents/pi-settings.js";
export { resolveDefaultAgentId, resolveSessionAgentId } from "../../../src/agents/agent-scope.js";
export { resolveMemorySearchConfig } from "../../../src/agents/memory-search.js";
export { jsonResult, readNumberParam, readStringParam } from "../../../src/agents/tools/common.js";
export { SILENT_REPLY_TOKEN } from "../../../src/auto-reply/tokens.js";
export { parseNonNegativeByteSize } from "../../../src/config/byte-size.js";
export { loadConfig } from "../../../src/config/config.js";
export { resolveStateDir } from "../../../src/config/paths.js";
export { resolveSessionTranscriptsDirForAgent } from "../../../src/config/sessions/paths.js";
export { emptyPluginConfigSchema } from "../../../src/plugins/config-schema.js";
export { parseAgentSessionKey } from "../../../src/routing/session-key.js";
export type { OpenClawConfig } from "../../../src/config/config.js";
export type { MemoryCitationsMode } from "../../../src/config/types.memory.js";
export type {
MemoryFlushPlan,
MemoryFlushPlanResolver,
MemoryPluginRuntime,
MemoryPromptSectionBuilder,
} from "../../../src/plugins/memory-state.js";
export type { OpenClawPluginApi } from "../../../src/plugins/types.js";

View File

@@ -0,0 +1,9 @@
// Focused runtime contract for memory file/backend access.
export {
listMemoryFiles,
normalizeExtraMemoryPaths,
} from "../../../src/plugins/memory-host/internal.js";
export { readAgentMemoryFile } from "../../../src/plugins/memory-host/read-file.js";
export { resolveMemoryBackendConfig } from "../../../src/plugins/memory-host/backend-config.js";
export type { MemorySearchResult } from "../../../src/plugins/memory-host/types.js";

View File

@@ -0,0 +1,6 @@
// Aggregate workspace contract for memory runtime/helper seams.
// Keep focused subpaths preferred for new code.
export * from "./runtime-core.js";
export * from "./runtime-cli.js";
export * from "./runtime-files.js";

View File

@@ -98,7 +98,14 @@
"memory-core-engine-runtime",
"memory-core-host",
"memory-core-host-engine",
"memory-core-host-engine-embeddings",
"memory-core-host-engine-foundation",
"memory-core-host-engine-qmd",
"memory-core-host-engine-storage",
"memory-core-host-runtime",
"memory-core-host-runtime-cli",
"memory-core-host-runtime-core",
"memory-core-host-runtime-files",
"memory-lancedb",
"msteams",
"nextcloud-talk",

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/engine-embeddings.js";

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/engine-foundation.js";

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/engine-qmd.js";

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/engine-storage.js";

View File

@@ -1,168 +1,7 @@
// Narrow engine surface for the bundled memory-core plugin.
// Keep this limited to host utilities needed by the memory engine cluster.
// Compatibility aggregate for older imports.
// Prefer the narrower `memory-core-host-engine-*` subpaths for new code.
export {
resolveAgentDir,
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
resolveSessionAgentId,
} from "../agents/agent-scope.js";
export {
resolveMemorySearchConfig,
type ResolvedMemorySearchConfig,
} from "../agents/memory-search.js";
export { parseDurationMs } from "../cli/parse-duration.js";
export { loadConfig } from "../config/config.js";
export { resolveStateDir } from "../config/paths.js";
export { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js";
export {
hasConfiguredSecretInput,
normalizeResolvedSecretInputString,
} from "../config/types.secrets.js";
export { writeFileWithinRoot } from "../infra/fs-safe.js";
export { createSubsystemLogger } from "../logging/subsystem.js";
export { resolveGlobalSingleton } from "../shared/global-singleton.js";
export { onSessionTranscriptUpdate } from "../sessions/transcript-events.js";
export {
buildFileEntry,
buildMultimodalChunkForIndexing,
chunkMarkdown,
cosineSimilarity,
ensureDir,
hashText,
listMemoryFiles,
normalizeExtraMemoryPaths,
parseEmbedding,
remapChunkLines,
runWithConcurrency,
type MemoryChunk,
type MemoryFileEntry,
} from "../plugins/memory-host/internal.js";
export { readMemoryFile } from "../plugins/memory-host/read-file.js";
export { resolveMemoryBackendConfig } from "../plugins/memory-host/backend-config.js";
export type {
ResolvedMemoryBackendConfig,
ResolvedQmdConfig,
ResolvedQmdMcporterConfig,
} from "../plugins/memory-host/backend-config.js";
export type {
MemoryEmbeddingProbeResult,
MemoryProviderStatus,
MemorySearchManager,
MemorySearchResult,
MemorySource,
MemorySyncProgressUpdate,
} from "../plugins/memory-host/types.js";
export {
getMemoryEmbeddingProvider,
listMemoryEmbeddingProviders,
} from "../plugins/memory-embedding-providers.js";
export type {
MemoryEmbeddingBatchChunk,
MemoryEmbeddingBatchOptions,
MemoryEmbeddingProvider,
MemoryEmbeddingProviderAdapter,
MemoryEmbeddingProviderCreateOptions,
MemoryEmbeddingProviderCreateResult,
MemoryEmbeddingProviderRuntime,
} from "../plugins/memory-embedding-providers.js";
export {
createLocalEmbeddingProvider,
createEmbeddingProvider,
DEFAULT_LOCAL_MODEL,
type EmbeddingProvider,
type EmbeddingProviderRequest,
type EmbeddingProviderResult,
type GeminiEmbeddingClient,
type MistralEmbeddingClient,
type OllamaEmbeddingClient,
type OpenAiEmbeddingClient,
type VoyageEmbeddingClient,
} from "../plugins/memory-host/embeddings.js";
export {
createGeminiEmbeddingProvider,
DEFAULT_GEMINI_EMBEDDING_MODEL,
buildGeminiEmbeddingRequest,
} from "../plugins/memory-host/embeddings-gemini.js";
export {
createMistralEmbeddingProvider,
DEFAULT_MISTRAL_EMBEDDING_MODEL,
} from "../plugins/memory-host/embeddings-mistral.js";
export {
createOllamaEmbeddingProvider,
DEFAULT_OLLAMA_EMBEDDING_MODEL,
} from "../plugins/memory-host/embeddings-ollama.js";
export {
createOpenAiEmbeddingProvider,
DEFAULT_OPENAI_EMBEDDING_MODEL,
} from "../plugins/memory-host/embeddings-openai.js";
export {
createVoyageEmbeddingProvider,
DEFAULT_VOYAGE_EMBEDDING_MODEL,
} from "../plugins/memory-host/embeddings-voyage.js";
export {
runGeminiEmbeddingBatches,
type GeminiBatchRequest,
} from "../plugins/memory-host/batch-gemini.js";
export {
OPENAI_BATCH_ENDPOINT,
runOpenAiEmbeddingBatches,
type OpenAiBatchRequest,
} from "../plugins/memory-host/batch-openai.js";
export {
runVoyageEmbeddingBatches,
type VoyageBatchRequest,
} from "../plugins/memory-host/batch-voyage.js";
export { enforceEmbeddingMaxInputTokens } from "../plugins/memory-host/embedding-chunk-limits.js";
export {
estimateStructuredEmbeddingInputBytes,
estimateUtf8Bytes,
} from "../plugins/memory-host/embedding-input-limits.js";
export {
hasNonTextEmbeddingParts,
type EmbeddingInput,
} from "../plugins/memory-host/embedding-inputs.js";
export {
buildCaseInsensitiveExtensionGlob,
classifyMemoryMultimodalPath,
getMemoryMultimodalExtensions,
} from "../plugins/memory-host/multimodal.js";
export { ensureMemoryIndexSchema } from "../plugins/memory-host/memory-schema.js";
export { loadSqliteVecExtension } from "../plugins/memory-host/sqlite-vec.js";
export { requireNodeSqlite } from "../plugins/memory-host/sqlite.js";
export { extractKeywords, isQueryStopWordToken } from "../plugins/memory-host/query-expansion.js";
export {
buildSessionEntry,
listSessionFilesForAgent,
sessionPathForFile,
type SessionFileEntry,
} from "../plugins/memory-host/session-files.js";
export { parseQmdQueryJson, type QmdQueryResult } from "../plugins/memory-host/qmd-query-parser.js";
export {
deriveQmdScopeChannel,
deriveQmdScopeChatType,
isQmdScopeAllowed,
} from "../plugins/memory-host/qmd-scope.js";
export { isFileMissingError, statRegularFile } from "../plugins/memory-host/fs-utils.js";
export { resolveCliSpawnInvocation, runCliCommand } from "../plugins/memory-host/qmd-process.js";
export { detectMime } from "../media/mime.js";
export { splitShellArgs } from "../utils/shell-argv.js";
export { runTasksWithConcurrency } from "../utils/run-with-concurrency.js";
export {
shortenHomeInString,
shortenHomePath,
resolveUserPath,
truncateUtf16Safe,
} from "../utils.js";
export type { OpenClawConfig } from "../config/config.js";
export type { SessionSendPolicyConfig } from "../config/types.base.js";
export type {
MemoryBackend,
MemoryCitationsMode,
MemoryQmdConfig,
MemoryQmdIndexPath,
MemoryQmdMcporterConfig,
MemoryQmdSearchMode,
} from "../config/types.memory.js";
export type { MemorySearchConfig } from "../config/types.tools.js";
export type { SecretInput } from "../config/types.secrets.js";
export * from "./memory-core-host-engine-foundation.js";
export * from "./memory-core-host-engine-storage.js";
export * from "./memory-core-host-engine-embeddings.js";
export * from "./memory-core-host-engine-qmd.js";

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/runtime-cli.js";

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/runtime-core.js";

View File

@@ -0,0 +1 @@
export * from "../../packages/memory-host-sdk/src/runtime-files.js";

View File

@@ -1,38 +1,6 @@
// Narrow runtime/helper surface for the bundled memory-core plugin.
// Keep this focused on non-engine plugin wiring: CLI, tools, prompt, flush.
// Compatibility aggregate for older imports.
// Prefer the narrower `memory-core-host-runtime-*` subpaths for new code.
export type { AnyAgentTool } from "../agents/tools/common.js";
export { resolveCronStyleNow } from "../agents/current-time.js";
export { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR } from "../agents/pi-settings.js";
export { resolveDefaultAgentId, resolveSessionAgentId } from "../agents/agent-scope.js";
export { resolveMemorySearchConfig } from "../agents/memory-search.js";
export { jsonResult, readNumberParam, readStringParam } from "../agents/tools/common.js";
export { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
export { formatErrorMessage, withManager } from "../cli/cli-utils.js";
export { formatHelpExamples } from "../cli/help-format.js";
export { resolveCommandSecretRefsViaGateway } from "../cli/command-secret-gateway.js";
export { withProgress, withProgressTotals } from "../cli/progress.js";
export { parseNonNegativeByteSize } from "../config/byte-size.js";
export { loadConfig } from "../config/config.js";
export { resolveStateDir } from "../config/paths.js";
export { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js";
export { listMemoryFiles, normalizeExtraMemoryPaths } from "../plugins/memory-host/internal.js";
export { readAgentMemoryFile } from "../plugins/memory-host/read-file.js";
export { resolveMemoryBackendConfig } from "../plugins/memory-host/backend-config.js";
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { parseAgentSessionKey } from "../routing/session-key.js";
export { defaultRuntime } from "../runtime.js";
export { formatDocsLink } from "../terminal/links.js";
export { colorize, isRich, theme } from "../terminal/theme.js";
export { isVerbose, setVerbose } from "../globals.js";
export { shortenHomeInString, shortenHomePath } from "../utils.js";
export type { OpenClawConfig } from "../config/config.js";
export type { MemoryCitationsMode } from "../config/types.memory.js";
export type { MemorySearchResult } from "../plugins/memory-host/types.js";
export type {
MemoryFlushPlan,
MemoryFlushPlanResolver,
MemoryPluginRuntime,
MemoryPromptSectionBuilder,
} from "../plugins/memory-state.js";
export type { OpenClawPluginApi } from "../plugins/types.js";
export * from "./memory-core-host-runtime-core.js";
export * from "./memory-core-host-runtime-cli.js";
export * from "./memory-core-host-runtime-files.js";

View File

@@ -1,42 +1,55 @@
// Narrow plugin-sdk surface for the bundled memory-core plugin.
// Keep this list additive and scoped to symbols used under extensions/memory-core.
export type { AnyAgentTool } from "../agents/tools/common.js";
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { resolveCronStyleNow } from "../agents/current-time.js";
export { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR } from "../agents/pi-settings.js";
export { resolveDefaultAgentId, resolveSessionAgentId } from "../agents/agent-scope.js";
export { resolveMemorySearchConfig } from "../agents/memory-search.js";
export { parseAgentSessionKey } from "../routing/session-key.js";
export { jsonResult, readNumberParam, readStringParam } from "../agents/tools/common.js";
export { parseNonNegativeByteSize } from "../config/byte-size.js";
export { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
export { loadConfig } from "../config/config.js";
export { resolveStateDir } from "../config/paths.js";
export { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js";
export { getMemorySearchManager, MemoryIndexManager } from "./memory-core-engine-runtime.js";
export {
DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR,
emptyPluginConfigSchema,
jsonResult,
loadConfig,
parseAgentSessionKey,
parseNonNegativeByteSize,
readNumberParam,
readStringParam,
resolveCronStyleNow,
resolveDefaultAgentId,
resolveMemorySearchConfig,
resolveSessionAgentId,
resolveSessionTranscriptsDirForAgent,
resolveStateDir,
SILENT_REPLY_TOKEN,
} from "./memory-core-host-runtime-core.js";
export type {
AnyAgentTool,
MemoryCitationsMode,
MemoryFlushPlan,
MemoryFlushPlanResolver,
MemoryPluginRuntime,
MemoryPromptSectionBuilder,
OpenClawConfig,
OpenClawPluginApi,
} from "./memory-core-host-runtime-core.js";
export {
colorize,
defaultRuntime,
formatDocsLink,
formatErrorMessage,
formatHelpExamples,
isRich,
isVerbose,
resolveCommandSecretRefsViaGateway,
setVerbose,
shortenHomeInString,
shortenHomePath,
theme,
withManager,
withProgress,
withProgressTotals,
} from "./memory-core-host-runtime-cli.js";
export {
listMemoryFiles,
normalizeExtraMemoryPaths,
readAgentMemoryFile,
resolveMemoryBackendConfig,
} from "./memory-core-host-runtime.js";
export { setVerbose, isVerbose } from "../globals.js";
export { defaultRuntime } from "../runtime.js";
export { colorize, isRich, theme } from "../terminal/theme.js";
export { formatDocsLink } from "../terminal/links.js";
export { formatHelpExamples } from "../cli/help-format.js";
export { formatErrorMessage, withManager } from "../cli/cli-utils.js";
export { resolveCommandSecretRefsViaGateway } from "../cli/command-secret-gateway.js";
export { withProgress, withProgressTotals } from "../cli/progress.js";
export { shortenHomeInString, shortenHomePath } from "../utils.js";
export type { OpenClawConfig } from "../config/config.js";
export type { MemoryCitationsMode } from "../config/types.memory.js";
export type { MemorySearchResult } from "./memory-core-host-runtime.js";
export type {
MemoryFlushPlan,
MemoryFlushPlanResolver,
MemoryPluginRuntime,
MemoryPromptSectionBuilder,
} from "../plugins/memory-state.js";
export type { OpenClawPluginApi } from "../plugins/types.js";
} from "./memory-core-host-runtime-files.js";
export type { MemorySearchResult } from "./memory-core-host-runtime-files.js";

View File

@@ -248,6 +248,18 @@ describe("plugin-sdk subpath exports", () => {
"listDirectoryEntriesFromSources",
"listResolvedDirectoryEntriesFromSources",
]);
expectSourceContains(
"memory-core-host-runtime-core",
'export * from "../../packages/memory-host-sdk/src/runtime-core.js";',
);
expectSourceContains(
"memory-core-host-runtime-cli",
'export * from "../../packages/memory-host-sdk/src/runtime-cli.js";',
);
expectSourceContains(
"memory-core-host-runtime-files",
'export * from "../../packages/memory-host-sdk/src/runtime-files.js";',
);
});
it("exports channel runtime helpers from the dedicated subpath", () => {

View File

@@ -24,6 +24,6 @@
"openclaw/plugin-sdk/account-id": ["./src/plugin-sdk/account-id.ts"]
}
},
"include": ["src/**/*", "ui/**/*", "extensions/**/*"],
"include": ["src/**/*", "ui/**/*", "extensions/**/*", "packages/**/*"],
"exclude": ["node_modules", "dist"]
}

View File

@@ -10,6 +10,10 @@
"rootDir": ".",
"tsBuildInfoFile": "dist/plugin-sdk/.tsbuildinfo"
},
"include": ["src/plugin-sdk/**/*.ts", "src/types/**/*.d.ts"],
"include": [
"src/plugin-sdk/**/*.ts",
"src/types/**/*.d.ts",
"packages/memory-host-sdk/src/**/*.ts"
],
"exclude": ["node_modules", "dist", "src/**/*.test.ts"]
}