feat(adapters): allow external plugins to override built-in adapters

Previously external adapters matching a built-in type were skipped with
a warning. Now they override the built-in, so plugin developers can ship
improved versions of existing adapters (e.g. hermes-paperclip-adapter)
without removing the built-in fallback for users who haven't installed
the plugin.
This commit is contained in:
HenkDz 2026-04-03 22:17:34 +01:00
parent 199a2178cf
commit 2a2fa31a03
2 changed files with 36 additions and 4 deletions

View file

@ -55,4 +55,36 @@ describe("server adapter registry", () => {
"Unknown adapter type: external_test",
);
});
it("allows external plugin to override a built-in adapter type", () => {
// claude_local is always built-in
const builtIn = findServerAdapter("claude_local");
expect(builtIn).not.toBeNull();
const plugin: ServerAdapterModule = {
type: "claude_local",
execute: async () => ({
exitCode: 0,
signal: null,
timedOut: false,
}),
testEnvironment: async () => ({
adapterType: "claude_local",
status: "pass",
checks: [],
testedAt: new Date(0).toISOString(),
}),
models: [{ id: "plugin-model", label: "Plugin Override" }],
supportsLocalAgentJwt: false,
};
registerServerAdapter(plugin);
// Plugin wins
const resolved = requireServerAdapter("claude_local");
expect(resolved).toBe(plugin);
expect(resolved.models).toEqual([
{ id: "plugin-model", label: "Plugin Override" },
]);
});
});

View file

@ -234,11 +234,11 @@ const externalAdaptersReady: Promise<void> = (async () => {
try {
const externalAdapters = await buildExternalAdapters();
for (const externalAdapter of externalAdapters) {
if (BUILTIN_ADAPTER_TYPES.has(externalAdapter.type)) {
console.warn(
`[paperclip] Skipping external adapter "${externalAdapter.type}" — conflicts with built-in adapter`,
const overriding = BUILTIN_ADAPTER_TYPES.has(externalAdapter.type);
if (overriding) {
console.log(
`[paperclip] External adapter \"${externalAdapter.type}\" overrides built-in adapter`,
);
continue;
}
adaptersByType.set(
externalAdapter.type,