App Capability Discovery: App-first tool & trigger creation (V1: Phase 0-3) - #596
App Capability Discovery: App-first tool & trigger creation (V1: Phase 0-3)#596esafwan wants to merge 23 commits into
Conversation
…, ActionDetail, CapabilityCard, CapabilityBadges)
…ourceDetail, EventDetail)
…e rejects spaces)
|
Addressed 2 of the 3 follow-up items from the review noted in the PR description:
Both verified: Left out of this PR on purpose: general whitelisted-method discovery beyond |
…py scan Extends discover_whitelisted_actions_for_app to also scan an app's api.py / *_api.py files (an existing naming convention used ~18x in this codebase for whitelisted HTTP endpoints), not just huf_tools-declared function paths. Every candidate is still re-verified via get_function_metadata(..., require_whitelisted=True) before being surfaced, satisfying plan section 18.2's allowlist rule (installed app AND callable AND @frappe.whitelist()) without adding general filesystem/AST scanning. Also fixes describe_app_action, which previously resolved capability ids via the limit=50 search_app_actions() results -- with declared actions always sorted first, huf's 100+ declared actions made every framework-discovered action undescribable. It now looks up declared/discovered descriptors directly, unaffected by search pagination limits. Closes the gap noted in PR #596 as deliberately out of scope.
Follow-up: general whitelisted-method discovery for zero-config appsCloses the gap this PR's description explicitly flagged as out of scope ("general whitelisted-method discovery beyond
Every candidate from this new surface — exactly like the existing Bug found and fixed during an independent review pass: 11/11 tests pass in Commit: e590a64 |
…iscovery huf/ai/capabilities.py (chat capability gating, from feat/chat-ux-improvements on develop) and the huf/ai/capabilities/ package (App Capability Discovery, PR #596) collided on the same module name once merged together onto pre-dev-stg -- a Python module and package cannot share a name in the same parent package. Renamed the discovery package to capability_discovery and updated every backend import, frontend service call, docstring, and test mock reference to match; huf.ai.capabilities (the chat-capability module) is untouched.
Summary
Implements V1 (Phase 0-3) of the App Capability Discovery & App-First Agent Builder plan: replaces "know the dotted Python path" tool creation and "pick from every DocType" trigger creation with an app-scoped capability explorer.
resolve_function_descriptor,inspect_function_parameters,get_function_metadata) inagent_tool_function.py, behavior-preserving for the existingfetch_tool_parameters_from_codeflow.huf/ai/capabilities/{apps,actions,api}.py+frontend/src/components/capabilities/{AppPicker,CapabilitySearch,ActionDetail,CapabilityCard,CapabilityBadges}.tsx, wired intoSelectToolsModal.tsxas a new "From Apps" tab. Discovered-but-new actions always persist astypes: "Custom Function"(never"App Provided") to avoid colliding withtool_registry.py's huf_tools sync/orphan-cleanup; already-declared (huf_tools) actions attach the existing synced tool directly instead of duplicating it.huf/ai/capabilities/{resources,ranking}.py+ResourceCard/ResourceDetail.tsx. Three-tier disclosure (recommended viaHUF App.exposed_tables-> discovered/ranked -> all), reusing the existing DocType-ownership-via-Module-Def helper (extracted intoapps_loader.py).huf/ai/capabilities/events.py(human-labeled event descriptors + a pure Trigger Builder adapter) +EventDetail.tsx, wired intoTriggerModal.tsxas a new "From App" guided path that reuses the existing Doc Event form/validation/submit code path.CapabilityDescriptor—huf/ai/capabilities/models.py/frontend/src/types/capability.types.ts, the single normalized shape all three discovery surfaces emit.All discovery endpoints in
huf/ai/capabilities/api.pyare gated to System Manager / Huf Admin / Huf Manager. No new runtime Tool/Trigger DocType was introduced — this is a discovery/index layer over the existingAgent Tool Function/Agent Triggerprimitives, per the plan's explicit "what not to do" list (no bulk materialization of tools, no arbitrary Python callable exposure, no third-partyhooks.pyedits, no live-LLM-dependent ranking).Existing "Tool Library" / "Create New" (manual function path) and the raw Advanced trigger-type/DocType/event picker are left fully functional and untouched.
Test plan
bench build --app huf— clean, no TS errorsbench migrate— cleanhuf.ai.capabilities.tests.{test_actions (6), test_resources (16), test_events (7), test_agent_tool_function_descriptor (5)}python3 -m py_compileclean on every new/changed Python filefunction_pathfetch breaking the attach-existing-tool path, invalidtool_nameslugs from humanized titles, JSON-Schema vs array mismatch inparameters_schemarendering, an internal-key leak inscope=allresource results)🤖 Generated with multi-agent assistance (Claude Code): ~20 sub-agents across research/backend/frontend/test/review waves, orchestrated in a disposable frappe-multihand bench.