Merge remote-tracking branch 'public-gh/master' into paperclip-subissues
* public-gh/master: (51 commits) Use attachment-size limit for company logos Address Greptile company logo feedback Drop lockfile from PR branch Use asset-backed company logos fix: use appType "custom" for Vite dev server so worktree branding is applied docs: fix documentation drift — adapters, plugins, tech stack docs: update documentation for accuracy after plugin system launch chore: ignore superset artifacts Dark theme for CodeMirror code blocks in MDXEditor Remove duplicate @paperclipai/adapter-openclaw-gateway in server/package.json Fix code block styles with robust prose overrides Add Docker setup for untrusted PR review in isolated containers Fix org chart canvas height to fit viewport without scrolling Add doc-maintenance skill for periodic documentation accuracy audits Fix sidebar scrollbar: hide track background when not hovering Restyle markdown code blocks: dark background, smaller font, compact padding Add archive project button and filter archived projects from selectors fix: address review feedback — subscription cleanup, filter nullability, stale diagram fix: wire plugin event subscriptions from worker to host fix(ui): hide scrollbar track background when sidebar is not hovered ... # Conflicts: # packages/db/src/migrations/meta/0030_snapshot.json # packages/db/src/migrations/meta/_journal.json
This commit is contained in:
@@ -103,9 +103,10 @@ export interface HostServices {
|
||||
list(params: WorkerToHostMethods["entities.list"][0]): Promise<WorkerToHostMethods["entities.list"][1]>;
|
||||
};
|
||||
|
||||
/** Provides `events.emit`. */
|
||||
/** Provides `events.emit` and `events.subscribe`. */
|
||||
events: {
|
||||
emit(params: WorkerToHostMethods["events.emit"][0]): Promise<void>;
|
||||
subscribe(params: WorkerToHostMethods["events.subscribe"][0]): Promise<void>;
|
||||
};
|
||||
|
||||
/** Provides `http.fetch`. */
|
||||
@@ -261,6 +262,7 @@ const METHOD_CAPABILITY_MAP: Record<WorkerToHostMethodName, PluginCapability | n
|
||||
|
||||
// Events
|
||||
"events.emit": "events.emit",
|
||||
"events.subscribe": "events.subscribe",
|
||||
|
||||
// HTTP
|
||||
"http.fetch": "http.outbound",
|
||||
@@ -407,6 +409,9 @@ export function createHostClientHandlers(
|
||||
"events.emit": gated("events.emit", async (params) => {
|
||||
return services.events.emit(params);
|
||||
}),
|
||||
"events.subscribe": gated("events.subscribe", async (params) => {
|
||||
return services.events.subscribe(params);
|
||||
}),
|
||||
|
||||
// HTTP
|
||||
"http.fetch": gated("http.fetch", async (params) => {
|
||||
|
||||
@@ -482,6 +482,10 @@ export interface WorkerToHostMethods {
|
||||
params: { name: string; companyId: string; payload: unknown },
|
||||
result: void,
|
||||
];
|
||||
"events.subscribe": [
|
||||
params: { eventPattern: string; filter?: Record<string, unknown> | null },
|
||||
result: void,
|
||||
];
|
||||
|
||||
// HTTP
|
||||
"http.fetch": [
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* |--- request(initialize) -------------> | → calls plugin.setup(ctx)
|
||||
* |<-- response(ok:true) ---------------- |
|
||||
* | |
|
||||
* |--- request(onEvent) ----------------> | → dispatches to registered handler
|
||||
* |<-- response(void) ------------------ |
|
||||
* |--- notification(onEvent) -----------> | → dispatches to registered handler
|
||||
* | |
|
||||
* |<-- request(state.get) --------------- | ← SDK client call from plugin code
|
||||
* |--- response(result) ----------------> |
|
||||
@@ -387,6 +386,13 @@ export function startWorkerRpcHost(options: WorkerRpcHostOptions): WorkerRpcHost
|
||||
registration = { name, filter: filterOrFn, fn: maybeFn };
|
||||
}
|
||||
eventHandlers.push(registration);
|
||||
// Register subscription on the host so events are forwarded to this worker
|
||||
void callHost("events.subscribe", { eventPattern: name, filter: registration.filter ?? null }).catch((err) => {
|
||||
notifyHost("log", {
|
||||
level: "warn",
|
||||
message: `Failed to subscribe to event "${name}" on host: ${err instanceof Error ? err.message : String(err)}`,
|
||||
});
|
||||
});
|
||||
return () => {
|
||||
const idx = eventHandlers.indexOf(registration);
|
||||
if (idx !== -1) eventHandlers.splice(idx, 1);
|
||||
@@ -1107,6 +1113,14 @@ export function startWorkerRpcHost(options: WorkerRpcHostOptions): WorkerRpcHost
|
||||
const event = notif.params as AgentSessionEvent;
|
||||
const cb = sessionEventCallbacks.get(event.sessionId);
|
||||
if (cb) cb(event);
|
||||
} else if (notif.method === "onEvent" && notif.params) {
|
||||
// Plugin event bus notifications — dispatch to registered event handlers
|
||||
handleOnEvent(notif.params as OnEventParams).catch((err) => {
|
||||
notifyHost("log", {
|
||||
level: "error",
|
||||
message: `Failed to handle event notification: ${err instanceof Error ? err.message : String(err)}`,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user