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.
This commit is contained in:
Jari Mustonen 2026-03-08 11:30:45 +02:00 committed by Josh Lehman
parent 02222b93c5
commit d827603bc9
No known key found for this signature in database
GPG Key ID: D141B425AC7F876B

View File

@ -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"