From 89079a32ef95bd120e2c4fd21abbdd3fe2ca218b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 28 Apr 2026 06:40:33 +0100 Subject: [PATCH] refactor(memory-host): narrow runtime adapters --- .../.generated/plugin-sdk-api-baseline.sha256 | 4 +- .../memory-host-sdk/src/engine-embeddings.ts | 4 +- .../memory-host-sdk/src/engine-foundation.ts | 40 +++++++++---------- packages/memory-host-sdk/src/engine-qmd.ts | 2 +- .../src/host/embeddings-remote-client.ts | 2 +- packages/memory-host-sdk/src/host/internal.ts | 6 ++- .../src/host/openclaw-runtime-agent.ts | 21 ++++++++++ .../src/host/openclaw-runtime-auth.ts | 1 + .../src/host/openclaw-runtime-cli.ts | 17 ++++++++ .../src/host/openclaw-runtime-config.ts | 22 ++++++++++ .../src/host/openclaw-runtime-io.ts | 15 +++++++ .../src/host/openclaw-runtime-memory.ts | 29 ++++++++++++++ .../src/host/openclaw-runtime-network.ts | 5 +++ .../src/host/openclaw-runtime-session.ts | 18 +++++++++ .../src/host/openclaw-runtime.ts | 11 +++++ .../memory-host-sdk/src/host/remote-http.ts | 2 +- .../memory-host-sdk/src/host/session-files.ts | 5 +-- packages/memory-host-sdk/src/runtime-cli.ts | 18 ++++----- packages/memory-host-sdk/src/runtime-core.ts | 36 ++++++++--------- ...tension-package-project-boundaries.test.ts | 20 ++++++++++ 20 files changed, 219 insertions(+), 59 deletions(-) create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-agent.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-auth.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-cli.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-config.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-io.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-memory.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-network.ts create mode 100644 packages/memory-host-sdk/src/host/openclaw-runtime-session.ts diff --git a/docs/.generated/plugin-sdk-api-baseline.sha256 b/docs/.generated/plugin-sdk-api-baseline.sha256 index 8eff8a180b0..a9dc066c4bb 100644 --- a/docs/.generated/plugin-sdk-api-baseline.sha256 +++ b/docs/.generated/plugin-sdk-api-baseline.sha256 @@ -1,2 +1,2 @@ -282897f1e044b79bd444e164646e492602f987fa0fefb20a3336aa0b2445e6b7 plugin-sdk-api-baseline.json -49cc5b3330e19a86a4884c71d08070034a39463d7e25ab8eca124f65028f1114 plugin-sdk-api-baseline.jsonl +ffc0924db91ebb9b79c488879bc9938b199047a2577fc469e194af673c9e1303 plugin-sdk-api-baseline.json +f2445b07d3ead6c38ab2a37c2e0eccb6414ade36d3fb9eb3dd157e5104f88b0d plugin-sdk-api-baseline.jsonl diff --git a/packages/memory-host-sdk/src/engine-embeddings.ts b/packages/memory-host-sdk/src/engine-embeddings.ts index 33a7216a8f3..405343215ab 100644 --- a/packages/memory-host-sdk/src/engine-embeddings.ts +++ b/packages/memory-host-sdk/src/engine-embeddings.ts @@ -5,7 +5,7 @@ export { listRegisteredMemoryEmbeddingProviders, listMemoryEmbeddingProviders, listRegisteredMemoryEmbeddingProviderAdapters, -} from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-memory.js"; export type { MemoryEmbeddingBatchChunk, MemoryEmbeddingBatchOptions, @@ -14,7 +14,7 @@ export type { MemoryEmbeddingProviderCreateOptions, MemoryEmbeddingProviderCreateResult, MemoryEmbeddingProviderRuntime, -} from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-memory.js"; export { createLocalEmbeddingProvider, DEFAULT_LOCAL_MODEL } from "./host/embeddings.js"; export { extractBatchErrorMessage, formatUnavailableBatchError } from "./host/batch-error-utils.js"; export { postJsonWithRetry } from "./host/batch-http.js"; diff --git a/packages/memory-host-sdk/src/engine-foundation.ts b/packages/memory-host-sdk/src/engine-foundation.ts index d7a84798299..bbd64312047 100644 --- a/packages/memory-host-sdk/src/engine-foundation.ts +++ b/packages/memory-host-sdk/src/engine-foundation.ts @@ -6,37 +6,37 @@ export { resolveAgentWorkspaceDir, resolveDefaultAgentId, resolveSessionAgentId, -} from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-agent.js"; export { resolveMemorySearchConfig, resolveMemorySearchSyncConfig, type ResolvedMemorySearchConfig, type ResolvedMemorySearchSyncConfig, -} from "./host/openclaw-runtime.js"; -export { parseDurationMs } from "./host/openclaw-runtime.js"; -export { loadConfig } from "./host/openclaw-runtime.js"; -export { resolveStateDir } from "./host/openclaw-runtime.js"; -export { resolveSessionTranscriptsDirForAgent } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-agent.js"; +export { parseDurationMs } from "./host/openclaw-runtime-config.js"; +export { loadConfig } from "./host/openclaw-runtime-config.js"; +export { resolveStateDir } from "./host/openclaw-runtime-config.js"; +export { resolveSessionTranscriptsDirForAgent } from "./host/openclaw-runtime-config.js"; export { hasConfiguredSecretInput, normalizeResolvedSecretInputString, -} from "./host/openclaw-runtime.js"; -export { writeFileWithinRoot } from "./host/openclaw-runtime.js"; -export { createSubsystemLogger } from "./host/openclaw-runtime.js"; -export { detectMime } from "./host/openclaw-runtime.js"; -export { resolveGlobalSingleton } from "./host/openclaw-runtime.js"; -export { onSessionTranscriptUpdate } from "./host/openclaw-runtime.js"; -export { splitShellArgs } from "./host/openclaw-runtime.js"; -export { runTasksWithConcurrency } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-config.js"; +export { writeFileWithinRoot } from "./host/openclaw-runtime-io.js"; +export { createSubsystemLogger } from "./host/openclaw-runtime-io.js"; +export { detectMime } from "./host/openclaw-runtime-io.js"; +export { resolveGlobalSingleton } from "./host/openclaw-runtime-io.js"; +export { onSessionTranscriptUpdate } from "./host/openclaw-runtime-session.js"; +export { splitShellArgs } from "./host/openclaw-runtime-io.js"; +export { runTasksWithConcurrency } from "./host/openclaw-runtime-io.js"; export { shortenHomeInString, shortenHomePath, resolveUserPath, truncateUtf16Safe, -} from "./host/openclaw-runtime.js"; -export type { OpenClawConfig } from "./host/openclaw-runtime.js"; -export type { SessionSendPolicyConfig } from "./host/openclaw-runtime.js"; -export type { SecretInput } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-io.js"; +export type { OpenClawConfig } from "./host/openclaw-runtime-config.js"; +export type { SessionSendPolicyConfig } from "./host/openclaw-runtime-config.js"; +export type { SecretInput } from "./host/openclaw-runtime-config.js"; export type { MemoryBackend, MemoryCitationsMode, @@ -44,5 +44,5 @@ export type { MemoryQmdIndexPath, MemoryQmdMcporterConfig, MemoryQmdSearchMode, -} from "./host/openclaw-runtime.js"; -export type { MemorySearchConfig } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-config.js"; +export type { MemorySearchConfig } from "./host/openclaw-runtime-config.js"; diff --git a/packages/memory-host-sdk/src/engine-qmd.ts b/packages/memory-host-sdk/src/engine-qmd.ts index bdd495fcb53..cbade42d286 100644 --- a/packages/memory-host-sdk/src/engine-qmd.ts +++ b/packages/memory-host-sdk/src/engine-qmd.ts @@ -12,7 +12,7 @@ export { type SessionFileEntry, type SessionTranscriptClassification, } from "./host/session-files.js"; -export { parseUsageCountedSessionIdFromFileName } from "./host/openclaw-runtime.js"; +export { parseUsageCountedSessionIdFromFileName } from "./host/openclaw-runtime-session.js"; export { parseQmdQueryJson, type QmdQueryResult } from "./host/qmd-query-parser.js"; export { deriveQmdScopeChannel, diff --git a/packages/memory-host-sdk/src/host/embeddings-remote-client.ts b/packages/memory-host-sdk/src/host/embeddings-remote-client.ts index 551f3d27011..9fc26864c90 100644 --- a/packages/memory-host-sdk/src/host/embeddings-remote-client.ts +++ b/packages/memory-host-sdk/src/host/embeddings-remote-client.ts @@ -1,5 +1,5 @@ import type { EmbeddingProviderOptions } from "./embeddings.types.js"; -import { requireApiKey, resolveApiKeyForProvider } from "./openclaw-runtime.js"; +import { requireApiKey, resolveApiKeyForProvider } from "./openclaw-runtime-auth.js"; import { buildRemoteBaseUrlPolicy } from "./remote-http.js"; import { resolveMemorySecretInputString } from "./secret-input.js"; import type { SsrFPolicy } from "./ssrf-policy.js"; diff --git a/packages/memory-host-sdk/src/host/internal.ts b/packages/memory-host-sdk/src/host/internal.ts index 078d3b68254..4357ef6a9dc 100644 --- a/packages/memory-host-sdk/src/host/internal.ts +++ b/packages/memory-host-sdk/src/host/internal.ts @@ -16,10 +16,12 @@ import { CHARS_PER_TOKEN_ESTIMATE, detectMime, estimateStringChars, - resolveCanonicalRootMemoryFile, runTasksWithConcurrency, +} from "./openclaw-runtime-io.js"; +import { + resolveCanonicalRootMemoryFile, shouldSkipRootMemoryAuxiliaryPath, -} from "./openclaw-runtime.js"; +} from "./openclaw-runtime-memory.js"; export { hashText } from "./hash.js"; import { hashText } from "./hash.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-agent.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-agent.ts new file mode 100644 index 00000000000..ed964606922 --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-agent.ts @@ -0,0 +1,21 @@ +export { + DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR, + asToolParamsRecord, + jsonResult, + parseAgentSessionKey, + readNumberParam, + readStringParam, + resolveAgentContextLimits, + resolveAgentDir, + resolveAgentWorkspaceDir, + resolveCronStyleNow, + resolveDefaultAgentId, + resolveMemorySearchConfig, + resolveMemorySearchSyncConfig, + resolveSessionAgentId, +} from "./openclaw-runtime.js"; +export type { + AnyAgentTool, + ResolvedMemorySearchConfig, + ResolvedMemorySearchSyncConfig, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-auth.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-auth.ts new file mode 100644 index 00000000000..87dfe7707c7 --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-auth.ts @@ -0,0 +1 @@ +export { requireApiKey, resolveApiKeyForProvider } from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-cli.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-cli.ts new file mode 100644 index 00000000000..0eef6c67c82 --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-cli.ts @@ -0,0 +1,17 @@ +export { + colorize, + defaultRuntime, + formatDocsLink, + formatErrorMessage, + formatHelpExamples, + isRich, + isVerbose, + resolveCommandSecretRefsViaGateway, + setVerbose, + shortenHomeInString, + shortenHomePath, + theme, + withManager, + withProgress, + withProgressTotals, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-config.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-config.ts new file mode 100644 index 00000000000..2620d437a2c --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-config.ts @@ -0,0 +1,22 @@ +export { + getRuntimeConfig, + hasConfiguredSecretInput, + loadConfig, + normalizeResolvedSecretInputString, + parseDurationMs, + parseNonNegativeByteSize, + resolveSessionTranscriptsDirForAgent, + resolveStateDir, +} from "./openclaw-runtime.js"; +export type { + MemoryBackend, + MemoryCitationsMode, + MemoryQmdConfig, + MemoryQmdIndexPath, + MemoryQmdMcporterConfig, + MemoryQmdSearchMode, + MemorySearchConfig, + OpenClawConfig, + SecretInput, + SessionSendPolicyConfig, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-io.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-io.ts new file mode 100644 index 00000000000..beaea0efc20 --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-io.ts @@ -0,0 +1,15 @@ +export { + CHARS_PER_TOKEN_ESTIMATE, + createSubsystemLogger, + detectMime, + estimateStringChars, + redactSensitiveText, + resolveGlobalSingleton, + resolveUserPath, + runTasksWithConcurrency, + shortenHomeInString, + shortenHomePath, + splitShellArgs, + truncateUtf16Safe, + writeFileWithinRoot, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-memory.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-memory.ts new file mode 100644 index 00000000000..bb01b3877d8 --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-memory.ts @@ -0,0 +1,29 @@ +export { + buildActiveMemoryPromptSection, + emptyPluginConfigSchema, + getMemoryCapabilityRegistration, + getMemoryEmbeddingProvider, + listActiveMemoryPublicArtifacts, + listMemoryEmbeddingProviders, + listRegisteredMemoryEmbeddingProviderAdapters, + listRegisteredMemoryEmbeddingProviders, + resolveCanonicalRootMemoryFile, + shouldSkipRootMemoryAuxiliaryPath, +} from "./openclaw-runtime.js"; +export type { + MemoryEmbeddingBatchChunk, + MemoryEmbeddingBatchOptions, + MemoryEmbeddingProvider, + MemoryEmbeddingProviderAdapter, + MemoryEmbeddingProviderCreateOptions, + MemoryEmbeddingProviderCreateResult, + MemoryEmbeddingProviderRuntime, + MemoryFlushPlan, + MemoryFlushPlanResolver, + MemoryPluginCapability, + MemoryPluginPublicArtifact, + MemoryPluginPublicArtifactsProvider, + MemoryPluginRuntime, + MemoryPromptSectionBuilder, + OpenClawPluginApi, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-network.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-network.ts new file mode 100644 index 00000000000..27dc9a67bd3 --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-network.ts @@ -0,0 +1,5 @@ +export { + fetchWithSsrFGuard, + shouldUseEnvHttpProxyForUrl, + ssrfPolicyFromHttpBaseUrlAllowedHostname, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime-session.ts b/packages/memory-host-sdk/src/host/openclaw-runtime-session.ts new file mode 100644 index 00000000000..8d51c60a63e --- /dev/null +++ b/packages/memory-host-sdk/src/host/openclaw-runtime-session.ts @@ -0,0 +1,18 @@ +export { + HEARTBEAT_PROMPT, + HEARTBEAT_TOKEN, + SILENT_REPLY_TOKEN, + hasInterSessionUserProvenance, + isCompactionCheckpointTranscriptFileName, + isCronRunSessionKey, + isExecCompletionEvent, + isHeartbeatUserMessage, + isSessionArchiveArtifactName, + isSilentReplyPayloadText, + isUsageCountedSessionTranscriptFileName, + onSessionTranscriptUpdate, + parseUsageCountedSessionIdFromFileName, + resolveSessionTranscriptsDirForAgent, + stripInboundMetadata, + stripInternalRuntimeContext, +} from "./openclaw-runtime.js"; diff --git a/packages/memory-host-sdk/src/host/openclaw-runtime.ts b/packages/memory-host-sdk/src/host/openclaw-runtime.ts index 489a299dc02..f8cfdec5acf 100644 --- a/packages/memory-host-sdk/src/host/openclaw-runtime.ts +++ b/packages/memory-host-sdk/src/host/openclaw-runtime.ts @@ -1,3 +1,4 @@ +// Agent/runtime helpers. export { resolveCronStyleNow } from "../../../../src/agents/current-time.js"; export { resolveAgentContextLimits, @@ -22,6 +23,8 @@ export { type ResolvedMemorySearchConfig, type ResolvedMemorySearchSyncConfig, } from "../../../../src/agents/memory-search.js"; + +// Session and reply helpers. export { isHeartbeatUserMessage } from "../../../../src/auto-reply/heartbeat-filter.js"; export { HEARTBEAT_PROMPT } from "../../../../src/auto-reply/heartbeat.js"; export { stripInboundMetadata } from "../../../../src/auto-reply/reply/strip-inbound-meta.js"; @@ -30,6 +33,8 @@ export { SILENT_REPLY_TOKEN, isSilentReplyPayloadText, } from "../../../../src/auto-reply/tokens.js"; + +// CLI/runtime/config helpers. export { formatErrorMessage, withManager } from "../../../../src/cli/cli-utils.js"; export { resolveCommandSecretRefsViaGateway } from "../../../../src/cli/command-secret-gateway.js"; export { formatHelpExamples } from "../../../../src/cli/help-format.js"; @@ -66,6 +71,8 @@ export { export type { SecretInput } from "../../../../src/config/types.secrets.js"; export type { MemorySearchConfig } from "../../../../src/config/types.tools.js"; export { isVerbose, setVerbose } from "../../../../src/globals.js"; + +// IO, network, and logging helpers. export { isExecCompletionEvent } from "../../../../src/infra/heartbeat-events-filter.js"; export { writeFileWithinRoot } from "../../../../src/infra/fs-safe.js"; export { fetchWithSsrFGuard } from "../../../../src/infra/net/fetch-guard.js"; @@ -74,6 +81,8 @@ export { ssrfPolicyFromHttpBaseUrlAllowedHostname } from "../../../../src/infra/ export { redactSensitiveText } from "../../../../src/logging/redact.js"; export { createSubsystemLogger } from "../../../../src/logging/subsystem.js"; export { detectMime } from "../../../../src/media/mime.js"; + +// Memory plugin helpers. export { resolveCanonicalRootMemoryFile, shouldSkipRootMemoryAuxiliaryPath, @@ -109,6 +118,8 @@ export type { MemoryPromptSectionBuilder, } from "../../../../src/plugins/memory-state.js"; export type { OpenClawPluginApi } from "../../../../src/plugins/types.js"; + +// Shared session/text utilities. export { defaultRuntime } from "../../../../src/runtime.js"; export { parseAgentSessionKey } from "../../../../src/routing/session-key.js"; export { hasInterSessionUserProvenance } from "../../../../src/sessions/input-provenance.js"; diff --git a/packages/memory-host-sdk/src/host/remote-http.ts b/packages/memory-host-sdk/src/host/remote-http.ts index 21d1307540a..ef438d874ea 100644 --- a/packages/memory-host-sdk/src/host/remote-http.ts +++ b/packages/memory-host-sdk/src/host/remote-http.ts @@ -2,7 +2,7 @@ import { fetchWithSsrFGuard, shouldUseEnvHttpProxyForUrl, ssrfPolicyFromHttpBaseUrlAllowedHostname, -} from "./openclaw-runtime.js"; +} from "./openclaw-runtime-network.js"; import type { SsrFPolicy } from "./ssrf-policy.js"; export const MEMORY_REMOTE_TRUSTED_ENV_PROXY_MODE = "trusted_env_proxy"; diff --git a/packages/memory-host-sdk/src/host/session-files.ts b/packages/memory-host-sdk/src/host/session-files.ts index e2eab1b7b0d..86bdc8b4c95 100644 --- a/packages/memory-host-sdk/src/host/session-files.ts +++ b/packages/memory-host-sdk/src/host/session-files.ts @@ -2,8 +2,8 @@ import fsSync from "node:fs"; import fs from "node:fs/promises"; import path from "node:path"; import { hashText } from "./hash.js"; +import { createSubsystemLogger, redactSensitiveText } from "./openclaw-runtime-io.js"; import { - createSubsystemLogger, HEARTBEAT_PROMPT, HEARTBEAT_TOKEN, hasInterSessionUserProvenance, @@ -14,11 +14,10 @@ import { isSessionArchiveArtifactName, isSilentReplyPayloadText, isUsageCountedSessionTranscriptFileName, - redactSensitiveText, resolveSessionTranscriptsDirForAgent, stripInboundMetadata, stripInternalRuntimeContext, -} from "./openclaw-runtime.js"; +} from "./openclaw-runtime-session.js"; const DREAMING_NARRATIVE_RUN_PREFIX = "dreaming-narrative-"; // Keep the historical one-line-per-message export shape for normal turns, but diff --git a/packages/memory-host-sdk/src/runtime-cli.ts b/packages/memory-host-sdk/src/runtime-cli.ts index edfd0f4e1a9..a5386e33542 100644 --- a/packages/memory-host-sdk/src/runtime-cli.ts +++ b/packages/memory-host-sdk/src/runtime-cli.ts @@ -1,11 +1,11 @@ // Focused runtime contract for memory CLI/UI helpers. -export { formatErrorMessage, withManager } from "./host/openclaw-runtime.js"; -export { formatHelpExamples } from "./host/openclaw-runtime.js"; -export { resolveCommandSecretRefsViaGateway } from "./host/openclaw-runtime.js"; -export { withProgress, withProgressTotals } from "./host/openclaw-runtime.js"; -export { defaultRuntime } from "./host/openclaw-runtime.js"; -export { formatDocsLink } from "./host/openclaw-runtime.js"; -export { colorize, isRich, theme } from "./host/openclaw-runtime.js"; -export { isVerbose, setVerbose } from "./host/openclaw-runtime.js"; -export { shortenHomeInString, shortenHomePath } from "./host/openclaw-runtime.js"; +export { formatErrorMessage, withManager } from "./host/openclaw-runtime-cli.js"; +export { formatHelpExamples } from "./host/openclaw-runtime-cli.js"; +export { resolveCommandSecretRefsViaGateway } from "./host/openclaw-runtime-cli.js"; +export { withProgress, withProgressTotals } from "./host/openclaw-runtime-cli.js"; +export { defaultRuntime } from "./host/openclaw-runtime-cli.js"; +export { formatDocsLink } from "./host/openclaw-runtime-cli.js"; +export { colorize, isRich, theme } from "./host/openclaw-runtime-cli.js"; +export { isVerbose, setVerbose } from "./host/openclaw-runtime-cli.js"; +export { shortenHomeInString, shortenHomePath } from "./host/openclaw-runtime-cli.js"; diff --git a/packages/memory-host-sdk/src/runtime-core.ts b/packages/memory-host-sdk/src/runtime-core.ts index 29abed737da..4c1cb382524 100644 --- a/packages/memory-host-sdk/src/runtime-core.ts +++ b/packages/memory-host-sdk/src/runtime-core.ts @@ -1,34 +1,34 @@ // Focused runtime contract for memory plugin config/state/helpers. -export type { AnyAgentTool } from "./host/openclaw-runtime.js"; -export { resolveCronStyleNow } from "./host/openclaw-runtime.js"; -export { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR } from "./host/openclaw-runtime.js"; -export { resolveDefaultAgentId, resolveSessionAgentId } from "./host/openclaw-runtime.js"; -export { resolveMemorySearchConfig } from "./host/openclaw-runtime.js"; +export type { AnyAgentTool } from "./host/openclaw-runtime-agent.js"; +export { resolveCronStyleNow } from "./host/openclaw-runtime-agent.js"; +export { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR } from "./host/openclaw-runtime-agent.js"; +export { resolveDefaultAgentId, resolveSessionAgentId } from "./host/openclaw-runtime-agent.js"; +export { resolveMemorySearchConfig } from "./host/openclaw-runtime-agent.js"; export { asToolParamsRecord, jsonResult, readNumberParam, readStringParam, -} from "./host/openclaw-runtime.js"; -export { SILENT_REPLY_TOKEN } from "./host/openclaw-runtime.js"; -export { parseNonNegativeByteSize } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-agent.js"; +export { SILENT_REPLY_TOKEN } from "./host/openclaw-runtime-session.js"; +export { parseNonNegativeByteSize } from "./host/openclaw-runtime-config.js"; export { getRuntimeConfig, /** @deprecated Use getRuntimeConfig(), or pass the already loaded config through the call path. */ loadConfig, -} from "./host/openclaw-runtime.js"; -export { resolveStateDir } from "./host/openclaw-runtime.js"; -export { resolveSessionTranscriptsDirForAgent } from "./host/openclaw-runtime.js"; -export { emptyPluginConfigSchema } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-config.js"; +export { resolveStateDir } from "./host/openclaw-runtime-config.js"; +export { resolveSessionTranscriptsDirForAgent } from "./host/openclaw-runtime-config.js"; +export { emptyPluginConfigSchema } from "./host/openclaw-runtime-memory.js"; export { buildActiveMemoryPromptSection, getMemoryCapabilityRegistration, listActiveMemoryPublicArtifacts, -} from "./host/openclaw-runtime.js"; -export { parseAgentSessionKey } from "./host/openclaw-runtime.js"; -export type { OpenClawConfig } from "./host/openclaw-runtime.js"; -export type { MemoryCitationsMode } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-memory.js"; +export { parseAgentSessionKey } from "./host/openclaw-runtime-agent.js"; +export type { OpenClawConfig } from "./host/openclaw-runtime-config.js"; +export type { MemoryCitationsMode } from "./host/openclaw-runtime-config.js"; export type { MemoryFlushPlan, MemoryFlushPlanResolver, @@ -37,5 +37,5 @@ export type { MemoryPluginPublicArtifactsProvider, MemoryPluginRuntime, MemoryPromptSectionBuilder, -} from "./host/openclaw-runtime.js"; -export type { OpenClawPluginApi } from "./host/openclaw-runtime.js"; +} from "./host/openclaw-runtime-memory.js"; +export type { OpenClawPluginApi } from "./host/openclaw-runtime-memory.js"; diff --git a/src/plugins/contracts/extension-package-project-boundaries.test.ts b/src/plugins/contracts/extension-package-project-boundaries.test.ts index b8d8ca84bdd..29fb48b886c 100644 --- a/src/plugins/contracts/extension-package-project-boundaries.test.ts +++ b/src/plugins/contracts/extension-package-project-boundaries.test.ts @@ -58,6 +58,16 @@ const MEMORY_HOST_SDK_EXPORTS = [ const MEMORY_HOST_SDK_ALLOWED_CORE_BRIDGE_FILES = [ "packages/memory-host-sdk/src/host/openclaw-runtime.ts", ] as const; +const MEMORY_HOST_SDK_RUNTIME_ADAPTER_FILES = [ + "packages/memory-host-sdk/src/host/openclaw-runtime-agent.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-auth.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-cli.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-config.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-io.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-memory.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-network.ts", + "packages/memory-host-sdk/src/host/openclaw-runtime-session.ts", +] as const; // oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets assertions ascribe JSON file shape. function readJsonFile(relativePath: string): T { @@ -87,6 +97,13 @@ function collectCoreReferenceFiles(relativeDir: string): string[] { }); } +function collectOpenClawRuntimeDirectImportFiles(relativeDir: string): string[] { + return collectCodeFiles(relativeDir).filter((file) => { + const source = readFileSync(resolve(REPO_ROOT, file), "utf8"); + return source.includes('"./openclaw-runtime.js"'); + }); +} + describe("opt-in extension package boundaries", () => { it("keeps path aliases in a dedicated shared config", () => { const pathsConfig = readJsonFile(EXTENSION_PACKAGE_BOUNDARY_PATHS_CONFIG); @@ -239,6 +256,9 @@ describe("opt-in extension package boundaries", () => { expect(collectCoreReferenceFiles("packages/memory-host-sdk/src")).toEqual([ ...MEMORY_HOST_SDK_ALLOWED_CORE_BRIDGE_FILES, ]); + expect(collectOpenClawRuntimeDirectImportFiles("packages/memory-host-sdk/src")).toEqual([ + ...MEMORY_HOST_SDK_RUNTIME_ADAPTER_FILES, + ]); }); it("keeps plugin-package-contract independent from core internals", () => {