fix(plugins): make Matrix recovery paths tolerate stale plugin config (#52899)

This commit is contained in:
Catalin Lupuleti
2026-03-23 23:17:21 +02:00
committed by Peter Steinberger
parent 5c9e4cd30a
commit 3ae100a8d7
8 changed files with 149 additions and 24 deletions

View File

@@ -4,6 +4,7 @@ import { onAgentEvent } from "../../infra/agent-events.js";
import { requestHeartbeatNow } from "../../infra/heartbeat-wake.js";
import * as execModule from "../../process/exec.js";
import { onSessionTranscriptUpdate } from "../../sessions/transcript-events.js";
import { VERSION } from "../../version.js";
import {
clearGatewaySubagentRuntime,
createPluginRuntime,
@@ -141,4 +142,9 @@ describe("plugin runtime command execution", () => {
});
expect(run).toHaveBeenCalledWith({ sessionKey: "s-2", message: "hello" });
});
it("exposes runtime.version from the shared VERSION constant", () => {
const runtime = createPluginRuntime();
expect(runtime.version).toBe(VERSION);
});
});

View File

@@ -1,4 +1,3 @@
import { createRequire } from "node:module";
import { resolveStateDir } from "../../config/paths.js";
import {
listRuntimeImageGenerationProviders,
@@ -10,6 +9,7 @@ import {
createLazyRuntimeMethodBinder,
createLazyRuntimeModule,
} from "../../shared/lazy-runtime.js";
import { VERSION } from "../../version.js";
import { listWebSearchProviders, runWebSearch } from "../../web-search/runtime.js";
import { createRuntimeAgent } from "./runtime-agent.js";
import { createRuntimeChannel } from "./runtime-channel.js";
@@ -96,23 +96,6 @@ function createRuntimeModelAuth(): PluginRuntime["modelAuth"] {
};
}
let cachedVersion: string | null = null;
function resolveVersion(): string {
if (cachedVersion) {
return cachedVersion;
}
try {
const require = createRequire(import.meta.url);
const pkg = require("../../../package.json") as { version?: string };
cachedVersion = pkg.version ?? "unknown";
return cachedVersion;
} catch {
cachedVersion = "unknown";
return cachedVersion;
}
}
function createUnavailableSubagentRuntime(): PluginRuntime["subagent"] {
const unavailable = () => {
throw new Error("Plugin runtime subagent methods are only available during a gateway request.");
@@ -201,7 +184,7 @@ export type CreatePluginRuntimeOptions = {
export function createPluginRuntime(_options: CreatePluginRuntimeOptions = {}): PluginRuntime {
const mediaUnderstanding = createRuntimeMediaUnderstandingFacade();
const runtime = {
version: resolveVersion(),
version: VERSION,
config: createRuntimeConfig(),
agent: createRuntimeAgent(),
subagent: createLateBindingSubagent(