mirror of
https://github.com/actionbook/actionbook.git
synced 2026-09-19 03:28:06 +08:00
2db938d519
* chore: align dify plugin manifest and privacy policy * [packages/dify-plugin]refactor: replace hyperbrowser SDK with direct HTTP API Remove hyperbrowser Python SDK dependency and use requests to call Hyperbrowser REST API directly. This eliminates an extra dependency that may not install cleanly in Dify Cloud's serverless runtime. - providers/hyperbrowser.py: HTTP POST/PUT instead of SDK client - pyproject.toml: drop hyperbrowser>=0.1.0 dependency - requirements.txt: add explicit requirements file - tests/test_providers.py: mock requests instead of SDK classes * [packages/dify-plugin]feat: add HTML misroute guard and simplify tool error handling Add utils/http_guard.py to detect when API responses return HTML instead of expected text/JSON — a common symptom of ACTIONBOOK_API_URL pointing to a non-Actionbook endpoint (e.g. Dify app API). - Integrate HTML guard into search_actions, get_action_by_area_id, provider - Simplify verbose error branches into concise messages - Remove debug-level logging from hot paths - Update all related tests with Content-Type headers and new assertions * [packages/dify-plugin]refactor: lazy-load browser deps for serverless compatibility Defer importing playwright and connection_pool until first browser tool invocation. This allows search_actions and get_action_by_area_id to work even when playwright binaries are unavailable (e.g. Dify Cloud serverless runtime). - tools/__init__.py: lazy __getattr__ for browser tool classes - browser_create_session.py: thread-safe lazy pool import - browser_operator.py: lazy import with stub exception fallbacks * [packages/dify-plugin]fix: review fixes — dead code, lazy import, session recovery - Remove unreachable except BaseException blocks in search_actions and get_action_by_area_id (dead code: only re-raised what it caught) - Apply lazy connection_pool import in browser_stop_session, matching browser_create_session and browser_operator pattern for serverless - Preserve provider_name/api_key on session recovery reconnect to prevent remote session leaks when browser_stop_session runs later - Update tests accordingly * [root]chore: use changeset for dify-plugin version bump Revert manual 0.1.1 bump back to 0.1.0 and add a changeset file so CI handles versioning through the standard two-phase flow. Also extend sync-versions.js to run `uv lock` after updating pyproject.toml to keep uv.lock in sync automatically.
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Actionbook Dify Plugin Tools.
|
|
|
|
Browser tool classes are imported lazily to avoid loading playwright and
|
|
connection_pool at module level. The non-browser tools (search_actions,
|
|
get_action_by_area_id) are imported eagerly so they remain fast.
|
|
"""
|
|
|
|
from .get_action_by_area_id import GetActionByAreaIdTool
|
|
from .search_actions import SearchActionsTool
|
|
|
|
|
|
def __getattr__(name: str):
|
|
"""Lazy-load browser tool classes on first access and cache in module globals."""
|
|
_lazy_map = {
|
|
"BrowserCreateSessionTool": ".browser_create_session",
|
|
"BrowserOperatorTool": ".browser_operator",
|
|
"BrowserStopSessionTool": ".browser_stop_session",
|
|
}
|
|
if name in _lazy_map:
|
|
import importlib
|
|
mod = importlib.import_module(_lazy_map[name], __name__)
|
|
cls = getattr(mod, name)
|
|
globals()[name] = cls # cache so __getattr__ is not called again
|
|
return cls
|
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
|
|
|
|
__all__ = [
|
|
"BrowserCreateSessionTool",
|
|
"BrowserOperatorTool",
|
|
"BrowserStopSessionTool",
|
|
"GetActionByAreaIdTool",
|
|
"SearchActionsTool",
|
|
]
|