






















@@ -422,6 +422,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
422422handler: Parameters<typeof registerInternalHook>[1],
423423opts: OpenClawPluginHookOptions | undefined,
424424config: OpenClawPluginApi["config"],
425+pluginConfig: unknown,
425426) => {
426427const eventList = Array.isArray(events) ? events : [events];
427428const normalizedEvents = eventList.map((event) => event.trim()).filter(Boolean);
@@ -499,8 +500,16 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
499500handler: Parameters<typeof registerInternalHook>[1];
500501}> = [];
501502for (const event of normalizedEvents) {
502-registerInternalHook(event, handler);
503-nextRegistrations.push({ event, handler });
503+// Wrap handler to inject pluginConfig into event context
504+// so plugins can access their configured pluginConfig at invocation time
505+const wrappedHandler: typeof handler = async (evt) => {
506+if (evt.context && typeof evt.context === "object") {
507+(evt.context as Record<string, unknown>).pluginConfig = pluginConfig;
508+}
509+return handler(evt);
510+};
511+registerInternalHook(event, wrappedHandler);
512+nextRegistrations.push({ event, handler: wrappedHandler });
504513}
505514activePluginHookRegistrations.set(hookName, nextRegistrations);
506515const rollbackEntries = pluginHookRollback.get(record.id) ?? [];
@@ -1466,7 +1475,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
14661475 ? {
14671476registerTool: (tool, opts) => registerTool(record, tool, opts),
14681477registerHook: (events, handler, opts) =>
1469-registerHook(record, events, handler, opts, params.config),
1478+registerHook(record, events, handler, opts, params.config, params.pluginConfig),
14701479registerHttpRoute: (routeParams) => registerHttpRoute(record, routeParams),
14711480registerProvider: (provider) => registerProvider(record, provider),
14721481registerAgentHarness: (harness) => registerAgentHarness(record, harness),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。