From d827603bc90455da0e7fb020e2126c2ccf64a37a Mon Sep 17 00:00:00 2001 From: Jari Mustonen Date: Sun, 8 Mar 2026 11:30:45 +0200 Subject: [PATCH] feat(memory): restrict registerMemoryPromptSection to memory plugins Throw if a non-memory plugin attempts to register a memory prompt section builder, enforcing the exclusive slot constraint at the API level. --- src/plugins/registry.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/registry.ts b/src/plugins/registry.ts index 2fdadfeb94d..b4007ff6067 100644 --- a/src/plugins/registry.ts +++ b/src/plugins/registry.ts @@ -2,6 +2,7 @@ import path from "node:path"; import type { AnyAgentTool } from "../agents/tools/common.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; import { registerContextEngineForOwner } from "../context-engine/registry.js"; +import { registerMemoryPromptSection } from "../memory/prompt-section.js"; import type { GatewayRequestHandler, GatewayRequestHandlers, @@ -979,6 +980,21 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) { }); } }, + registerMemoryPromptSection: (builder) => { + if (registrationMode !== "full") { + return; + } + if (record.kind !== "memory") { + pushDiagnostic({ + level: "error", + pluginId: record.id, + source: record.source, + message: "only memory plugins can register a memory prompt section", + }); + return; + } + registerMemoryPromptSection(builder); + }, resolvePath: (input: string) => resolveUserPath(input), on: (hookName, handler, opts) => registrationMode === "full"