Skip to content

Commit 49a0659

Browse files
committed
fix: global plugin hook AdminForth/1955/implement-ability-for-agent-pl
validateConfigAfterDiscover was called only for plugins in resource.plugins, so a global plugin never got it. The agent built its system prompt there, so the model got "undefined" in its place, and its startup checks (MCP plugin, audio and chat surface adapters) never ran. Call it for config.globalPlugins after all resources are discovered; resourceConfig is optional, a global plugin belongs to no resource.
1 parent 447fe53 commit 49a0659

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎adminforth/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ class AdminForth implements IAdminForth {
629629
for (const res of this.config.resources) {
630630
this.configValidator.postProcessAfterDiscover(res);
631631
}
632+
// resource plugins are validated by postProcessAfterDiscover, global ones belong to no resource
633+
for (const plugin of this.config.globalPlugins ?? []) {
634+
plugin.validateConfigAfterDiscover?.(this);
635+
}
632636

633637
this.operationalResources = {};
634638
this.config.resources.forEach((resource) => {

‎adminforth/types/Back.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,9 @@ export interface IAdminForthPlugin {
799799
/**
800800
* Optional method which will be called after AdminForth discovers all resources and their columns.
801801
* Can be used to validate types of columns, check if some columns are missing, etc.
802+
* `resourceConfig` is the resource of a resource plugin; a global plugin gets no resource.
802803
*/
803-
validateConfigAfterDiscover?(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
804+
validateConfigAfterDiscover?(adminforth: IAdminForth, resourceConfig?: AdminForthResource): void;
804805

805806
/**
806807
* Here you can register custom endpoints for your plugin.

0 commit comments

Comments
 (0)