feat: Implement App Agent Discovery System #193
Draft
esafwan wants to merge 3 commits into
Draft
Conversation
Detailed specification for file-based agent discovery enabling external Frappe apps to declare AI capabilities (agents, tools, prompts, providers, models, knowledge sources, triggers) via JSON files in a huf/ directory. Covers: folder convention, JSON schemas for all 7 definition types, discovery engine, import pipeline, validation, upsert strategy, dependency resolution, app isolation, caching, security, UI export, versioning, failure handling, and relationship to existing tool registry. Co-authored-by: Safwan Erooth <esafwan@users.noreply.github.com>
- Add app_registry module: loader, cache, validator, normaliser, importer, discovery, exporter - Add provenance fields (source_app, source_file) to Agent, Agent Tool Function, Agent Prompt, AI Provider, AI Model, Knowledge Source, Agent Trigger - Add last_definition_scans cache field to Agent Settings - Integrate discovery into after_migrate and after_install - Add whitelisted APIs: discover_app_definitions_api, get_app_discovery_status, rebuild_app_definitions, export_definition_api, export_agent_bundle_api - Add App Definitions page and appDiscoveryApi service - Add APP_AGENT_DISCOVERY_IMPLEMENTATION.md documentation Co-authored-by: Safwan Erooth <esafwan@users.noreply.github.com>
…ection, orphan cleanup, and version comparison - Add test_app_registry.py with comprehensive test coverage - Add 16 example definition files for all 7 types - Add circular dependency detection to validator.py - Add orphan detection and cleanup to discovery.py - Add version comparison logic to importer.py - Add comprehensive README.md documentation - Add IMPLEMENTATION_SUMMARY.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the complete App Agent Discovery system that enables external Frappe apps to declare AI capabilities using plain JSON files in their repositories.
Overview
The App Agent Discovery system allows any Frappe app to define AI agents, tools, prompts, providers, models, knowledge sources, and triggers in a huf/ directory. When HUF is installed, these definitions are automatically discovered, validated, and synced into HUF DocTypes.
Key Features Implemented
Files Changed
Modified:
Created:
Technical Details
Architecture:
huf/ai/app_registry/
├── init.py # Public API exports
├── discovery.py # Orchestration and orphan management
├── loader.py # File scanning and JSON loading
├── validator.py # Type-specific validation + circular detection
├── normaliser.py # Payload transformation
├── importer.py # DocType upsert + version comparison
├── exporter.py # Export to JSON
├── cache.py # File hash-based caching
├── test_app_registry.py # Test suite
├── README.md # Documentation
└── examples/ # 16 example files
Key APIs:
Basic discovery
discover_app_definitions()
With orphan cleanup
discover_app_definitions_with_cleanup(cleanup_orphans=True)
Export
export_agent_bundle("Agent Name")
Orphan management
get_orphaned_definitions()
cleanup_orphaned_definitions(dry_run=False)
Testing
Usage Example
In your app's huf/agents/my_agent.agent.json:
Notes