mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-04-28 03:30:23 +00:00
Refactor extensions to async/sync API
Redesign extension handling to support explicit async/sync execution. helpers/extension.py rewrites the extensible decorator, adds call_extensions_async / call_extensions_sync, and a helper to gather extension classes; caching flag adjusted. Updated call sites across the codebase (agent, APIs, plugins, tools, settings, extensions) to use extension.extensible and the new call_extensions_async/sync API, and converted several extension handlers from async to sync. Also small frontend tweaks (use globalThis.runtimeInfo) and minor import updates (csrf_protect in run_ui). This centralizes extension discovery/execution and avoids previously scattered asyncio.run usage.
This commit is contained in:
parent
c2005f4f7a
commit
ab9fc4ee7f
14 changed files with 240 additions and 185 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from helpers.api import ApiHandler, Request, Response
|
||||
from helpers.extension import call_extensions
|
||||
from helpers.extension import call_extensions_async
|
||||
|
||||
|
||||
class GetBanners(ApiHandler):
|
||||
|
|
@ -13,7 +13,7 @@ class GetBanners(ApiHandler):
|
|||
frontend_context = input.get("context", {})
|
||||
|
||||
# Banners array passed by reference - extensions append directly to it
|
||||
await call_extensions("banners", agent=None, banners=banners, frontend_context=frontend_context)
|
||||
await call_extensions_async("banners", agent=None, banners=banners, frontend_context=frontend_context)
|
||||
|
||||
return {"banners": banners}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Message(ApiHandler):
|
|||
|
||||
# call extension point, alow it to modify data
|
||||
data = { "message": message, "attachment_paths": attachment_paths }
|
||||
await extension.call_extensions("user_message_ui", agent=context.get_agent(), data=data)
|
||||
await extension.call_extensions_async("user_message_ui", agent=context.get_agent(), data=data)
|
||||
message = data.get("message", "")
|
||||
attachment_paths = data.get("attachment_paths", [])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue