fix(memory): package broker child entry

This commit is contained in:
Galin Iliev
2026-08-19 07:40:03 -07:00
parent 32ec272e75
commit e5fdf6dd2d
4 changed files with 24 additions and 6 deletions
+10
View File
@@ -362,6 +362,16 @@ describe("memory-core plugin runtime registration", () => {
});
});
it("uses the packaged plugin entry as the selected broker child module", () => {
const capability = registerMemoryCoreCapability();
expect(capability.broker).toEqual({
version: 1,
kind: "local-child",
moduleUrl: new URL("./index.ts", import.meta.url).href,
});
});
it("binds the host local-service hook to the registered memory runtime", async () => {
const runtime = registerMemoryCoreRuntime();
const cfg = {} as OpenClawConfig;
+8 -5
View File
@@ -36,6 +36,11 @@ import { registerScopedMemorySharingGatewayMethods } from "./src/memory/scoped-m
import { buildPromptSection } from "./src/prompt-section.js";
import { registerSessionBackfillGatewayMethods } from "./src/session-backfill-gateway.js";
export {
createMemoryBrokerHandler,
initializeMemoryBroker,
} from "./src/memory/broker-entry.js";
type MemoryToolsModule = typeof import("./src/tools.js");
type StandingIntentToolModule = typeof import("./src/standing-intents-tool.js");
@@ -69,11 +74,9 @@ const loadScopedMemorySharingModule = createLazyRuntimeModule(
() => import("./src/memory/scoped-memory-sharing.js"),
);
// Source-checkout workers inherit the TypeScript loader; packaged brokers load the emitted JS.
const memoryBrokerEntryUrl = new URL(
import.meta.url.endsWith(".ts") ? "./src/memory/broker-entry.ts" : "./src/memory/broker-entry.js",
import.meta.url,
).href;
// The selected broker imports this packaged extension entry, which re-exports its private
// handler. Do not point at a source-relative helper: package builds only guarantee this entry.
const memoryBrokerEntryUrl = import.meta.url;
function getToolConfig(options: MemoryToolOptions): OpenClawConfig | undefined {
return options.getConfig?.() ?? options.config;
+3 -1
View File
@@ -60,8 +60,10 @@ export async function startMemoryBrokerProcess(params: {
const socketPath = path.join(directory, "broker.sock");
const brokerEpoch = randomUUID();
const secret = randomBytes(32);
// The bundled parent can be a code-split chunk at dist/, while the child is a
// deliberate stable entry. Keep the source sibling path for tsx-based development.
const defaultChildModuleUrl = new URL(
import.meta.url.endsWith(".ts") ? "./child.ts" : "./child.js",
import.meta.url.endsWith(".ts") ? "./child.ts" : "./memory-broker/child.js",
import.meta.url,
);
const childModuleUrl = params.childModuleUrl ?? defaultChildModuleUrl;
+3
View File
@@ -395,6 +395,9 @@ function buildCoreDistEntries(): Record<string, string> {
"process/supervisor/service-child-relay": "src/process/supervisor/service-child-relay.ts",
"process/supervisor/service-child-group-anchor":
"src/process/supervisor/service-child-group-anchor.ts",
// Forked by the selected-memory supervisor; this must remain a stable packaged file rather
// than an implementation chunk whose hashed location can change independently of the parent.
"memory-broker/child": "src/memory-broker/child.ts",
// Durable host-side PID for per-session process-isolated worker containers.
"node-host/node-worker-container-shim": "src/node-host/node-worker-container-shim.ts",
"telegram-ingress-worker.runtime": bundledPluginFile(