Merge public-gh/master into paperclip-company-import-export
This commit is contained in:
@@ -63,6 +63,15 @@ import {
|
||||
import {
|
||||
agentConfigurationDoc as piAgentConfigurationDoc,
|
||||
} from "@paperclipai/adapter-pi-local";
|
||||
import {
|
||||
execute as hermesExecute,
|
||||
testEnvironment as hermesTestEnvironment,
|
||||
sessionCodec as hermesSessionCodec,
|
||||
} from "hermes-paperclip-adapter/server";
|
||||
import {
|
||||
agentConfigurationDoc as hermesAgentConfigurationDoc,
|
||||
models as hermesModels,
|
||||
} from "hermes-paperclip-adapter";
|
||||
import { processAdapter } from "./process/index.js";
|
||||
import { httpAdapter } from "./http/index.js";
|
||||
|
||||
@@ -151,6 +160,16 @@ const piLocalAdapter: ServerAdapterModule = {
|
||||
agentConfigurationDoc: piAgentConfigurationDoc,
|
||||
};
|
||||
|
||||
const hermesLocalAdapter: ServerAdapterModule = {
|
||||
type: "hermes_local",
|
||||
execute: hermesExecute,
|
||||
testEnvironment: hermesTestEnvironment,
|
||||
sessionCodec: hermesSessionCodec,
|
||||
models: hermesModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
agentConfigurationDoc: hermesAgentConfigurationDoc,
|
||||
};
|
||||
|
||||
const adaptersByType = new Map<string, ServerAdapterModule>(
|
||||
[
|
||||
claudeLocalAdapter,
|
||||
@@ -160,6 +179,7 @@ const adaptersByType = new Map<string, ServerAdapterModule>(
|
||||
cursorLocalAdapter,
|
||||
geminiLocalAdapter,
|
||||
openclawGatewayAdapter,
|
||||
hermesLocalAdapter,
|
||||
processAdapter,
|
||||
httpAdapter,
|
||||
].map((a) => [a.type, a]),
|
||||
|
||||
@@ -556,6 +556,18 @@ export function buildHostServices(
|
||||
}
|
||||
await scopedBus.emit(params.name, params.companyId, params.payload);
|
||||
},
|
||||
async subscribe(params: { eventPattern: string; filter?: Record<string, unknown> | null }) {
|
||||
const handler = async (event: import("@paperclipai/plugin-sdk").PluginEvent) => {
|
||||
if (notifyWorker) {
|
||||
notifyWorker("onEvent", { event });
|
||||
}
|
||||
};
|
||||
if (params.filter) {
|
||||
scopedBus.subscribe(params.eventPattern as any, params.filter as any, handler);
|
||||
} else {
|
||||
scopedBus.subscribe(params.eventPattern as any, handler);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
http: {
|
||||
@@ -1060,6 +1072,10 @@ export function buildHostServices(
|
||||
dispose() {
|
||||
disposed = true;
|
||||
|
||||
// Clear event bus subscriptions to prevent accumulation on worker restart.
|
||||
// Without this, each crash/restart cycle adds duplicate subscriptions.
|
||||
scopedBus.clear();
|
||||
|
||||
// Snapshot to avoid iterator invalidation from concurrent sendMessage() calls
|
||||
const snapshot = Array.from(activeSubscriptions);
|
||||
activeSubscriptions.clear();
|
||||
|
||||
Reference in New Issue
Block a user