mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
perf(rpc): stop the dispatcher importing every RPC method by default (#39669)
* perf(rpc): stop the dispatcher importing every RPC method by default Callers pass the method list. A test that builds a dispatcher no longer loads the full method registry, cutting the dispatcher's import graph from ~4k to ~550 modules. * chore(lint): keep the RPC dispatcher and plugin RPC off the method registry --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { installPluginHookRunner } from './hooks/plugin-hook-participants'
|
||||
import { installPluginResidentWorkerWarmer } from './workers/plugin-resident-worker'
|
||||
import type { OrcaRuntimeService } from '../runtime/orca-runtime'
|
||||
import { pluginRuntimeRpc } from './plugin-runtime-rpc'
|
||||
import type { DispatcherOptions } from '../runtime/rpc/dispatcher'
|
||||
import type { PluginRuntimeRpc } from './workers/plugin-host-workspace-method-bindings'
|
||||
import {
|
||||
pluginTerminalTitle,
|
||||
@@ -47,10 +48,11 @@ export function pluginRuntimeDelegate(
|
||||
export function bindPluginRuntime(
|
||||
service: PluginService,
|
||||
runtime: OrcaRuntimeService,
|
||||
hookServer: { getStatusSnapshot(): readonly PluginAgentStatusRow[] }
|
||||
hookServer: { getStatusSnapshot(): readonly PluginAgentStatusRow[] },
|
||||
methods: DispatcherOptions['methods']
|
||||
): PluginRuntimeDelegate {
|
||||
const statuses = () => hookServer.getStatusSnapshot()
|
||||
const delegate = pluginRuntimeDelegate(runtime, statuses, pluginRuntimeRpc(runtime))
|
||||
const delegate = pluginRuntimeDelegate(runtime, statuses, pluginRuntimeRpc(runtime, methods))
|
||||
service.setRuntimeDelegate(delegate)
|
||||
installPluginHookRunner(service, runtime)
|
||||
installPluginResidentWorkerWarmer(service)
|
||||
|
||||
@@ -19,11 +19,11 @@ export class PluginRuntimeRpcError extends Error {
|
||||
*/
|
||||
export function pluginRuntimeRpc(
|
||||
runtime: OrcaRuntimeService,
|
||||
methods?: DispatcherOptions['methods']
|
||||
methods: DispatcherOptions['methods']
|
||||
): PluginRuntimeRpc {
|
||||
let dispatcher: RpcDispatcher | null = null
|
||||
return async (method, params, options = {}) => {
|
||||
dispatcher ??= new RpcDispatcher({ runtime, ...(methods ? { methods } : {}) })
|
||||
dispatcher ??= new RpcDispatcher({ runtime, methods })
|
||||
// The dispatcher maps a throw to an error answer; keep the original so its code reaches the plugin.
|
||||
let refusal: unknown = null
|
||||
const response = await dispatcher.dispatch(
|
||||
|
||||
Reference in New Issue
Block a user