-
Notifications
You must be signed in to change notification settings - Fork 16
docs: Add multiple marketplace registrations section to plugins guide #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jpshackelford
wants to merge
1
commit into
main
Choose a base branch
from
feat/multiple-marketplace-registrations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |||||
| ## Plugin Structure | ||||||
|
|
||||||
| <Note> | ||||||
| See the [example_plugins directory](https://github.com/OpenHands/software-agent-sdk/tree/main/examples/05_skills_and_plugins/02_loading_plugins/example_plugins) for a complete working plugin structure. | ||||||
| </Note> | ||||||
|
|
||||||
| A plugin follows this directory structure: | ||||||
|
|
@@ -510,6 +510,133 @@ | |||||
| uninstall_plugin(info.name) | ||||||
| ``` | ||||||
|
|
||||||
| ## Multiple Marketplace Registrations | ||||||
|
|
||||||
| For enterprise and team scenarios, you can register multiple plugin marketplaces | ||||||
| with different loading strategies. This allows you to: | ||||||
|
|
||||||
| - Register internal team marketplaces alongside the public marketplace | ||||||
| - Control which plugins auto-load at conversation start vs load on-demand | ||||||
| - Reference plugins from specific marketplaces using the `plugin@marketplace` syntax | ||||||
|
|
||||||
| ### Loading Strategies | ||||||
|
|
||||||
| | Strategy | Behavior | | ||||||
| |----------|----------| | ||||||
| | `auto_load="all"` | All plugins from the marketplace load automatically when a conversation starts | | ||||||
| | `auto_load=None` (default) | Marketplace is registered but plugins are loaded on-demand via `load_plugin()` | | ||||||
|
|
||||||
| ### Plugin Reference Syntax | ||||||
|
|
||||||
| Use the `plugin-name@marketplace-name` format to explicitly specify which | ||||||
| marketplace a plugin comes from. This syntax follows the same convention as | ||||||
| [Claude Code's plugin install command](https://code.claude.com/docs/en/plugins-reference). | ||||||
|
|
||||||
| ```python icon="python" | ||||||
| # Load a specific plugin from a registered marketplace | ||||||
| conversation.load_plugin("greeter@demo") | ||||||
|
|
||||||
| # If only one marketplace has the plugin, the marketplace name is optional | ||||||
| conversation.load_plugin("greeter") | ||||||
| ``` | ||||||
|
|
||||||
| ### Example: Auto-load and On-demand Loading | ||||||
|
|
||||||
| The example below demonstrates registering two marketplaces with different | ||||||
| loading strategies, then loading an additional plugin on-demand. | ||||||
|
|
||||||
| <Note> | ||||||
| Source: [examples/05_skills_and_plugins/04_multiple_marketplace_registrations/main.py](https://github.com/OpenHands/software-agent-sdk/blob/main/examples/05_skills_and_plugins/04_multiple_marketplace_registrations/main.py) | ||||||
| </Note> | ||||||
|
|
||||||
| ```python icon="python" expandable examples/05_skills_and_plugins/04_multiple_marketplace_registrations/main.py | ||||||
| """Example: Multiple Marketplace Registrations | ||||||
|
|
||||||
| Demonstrates two loading strategies for marketplace plugins: | ||||||
|
|
||||||
| - auto_load="all": Plugins loaded automatically at conversation start | ||||||
| - auto_load=None: Plugins loaded on-demand via conversation.load_plugin() | ||||||
|
|
||||||
| This example uses pre-created marketplaces in: | ||||||
| - ./auto_marketplace/ - auto-loaded at conversation start | ||||||
| - ./demo_marketplace/ - loaded on-demand | ||||||
| """ | ||||||
|
|
||||||
| import os | ||||||
| from pathlib import Path | ||||||
|
|
||||||
| from openhands.sdk import LLM, Agent, AgentContext, Conversation | ||||||
| from openhands.sdk.plugin import MarketplaceRegistration | ||||||
|
|
||||||
| SCRIPT_DIR = Path(__file__).parent | ||||||
|
|
||||||
|
|
||||||
| def main(): | ||||||
| llm = LLM( | ||||||
| model=os.getenv("LLM_MODEL", "anthropic/claude-sonnet-4-5-20250929"), | ||||||
| api_key=os.getenv("LLM_API_KEY"), | ||||||
| base_url=os.getenv("LLM_BASE_URL"), | ||||||
| ) | ||||||
|
|
||||||
| # Register two marketplaces with different loading strategies | ||||||
| agent_context = AgentContext( | ||||||
| registered_marketplaces=[ | ||||||
| # Auto-loaded: plugins available immediately when conversation starts | ||||||
| MarketplaceRegistration( | ||||||
| name="auto", | ||||||
| source=str(SCRIPT_DIR / "auto_marketplace"), | ||||||
| auto_load="all", | ||||||
| ), | ||||||
| # On-demand: registered but not loaded until explicitly requested | ||||||
| MarketplaceRegistration( | ||||||
| name="demo", | ||||||
| source=str(SCRIPT_DIR / "demo_marketplace"), | ||||||
| # auto_load=None (default) - use load_plugin() to load | ||||||
| ), | ||||||
| ], | ||||||
| ) | ||||||
|
|
||||||
| agent = Agent(llm=llm, tools=[], agent_context=agent_context) | ||||||
| conversation = Conversation(agent=agent, workspace=os.getcwd()) | ||||||
|
|
||||||
| # The "auto" marketplace plugins are already loaded | ||||||
| # Now load an additional plugin on-demand from "demo" marketplace | ||||||
| # Format: "plugin-name@marketplace-name" (same as Claude Code plugin syntax) | ||||||
| conversation.load_plugin("greeter@demo") | ||||||
|
|
||||||
| resolved = conversation.resolved_plugins | ||||||
| if resolved: | ||||||
| print(f"Loaded {len(resolved)} plugin(s):") | ||||||
| for plugin in resolved: | ||||||
| print(f" - {plugin.source}") | ||||||
|
|
||||||
| # Use skills from both plugins | ||||||
| conversation.send_message("Give me a tip, then greet me!") | ||||||
| conversation.run() | ||||||
|
|
||||||
| print(f"\nEXAMPLE_COST: {llm.metrics.accumulated_cost:.4f}") | ||||||
|
|
||||||
|
|
||||||
| if __name__ == "__main__": | ||||||
| if not os.getenv("LLM_API_KEY"): | ||||||
| print("Set LLM_API_KEY to run this example") | ||||||
| print("EXAMPLE_COST: 0") | ||||||
| else: | ||||||
| main() | ||||||
| ``` | ||||||
|
|
||||||
| <RunExampleCode path_to_script="examples/05_skills_and_plugins/04_multiple_marketplace_registrations/main.py"/> | ||||||
|
|
||||||
| ### MarketplaceRegistration Fields | ||||||
|
|
||||||
| | Field | Type | Description | | ||||||
| |-------|------|-------------| | ||||||
| | `name` | `str` | Identifier for this marketplace registration | | ||||||
| | `source` | `str` | Plugin source: `github:owner/repo`, git URL, or local path | | ||||||
| | `ref` | `str \| None` | Optional branch, tag, or commit for the marketplace repo | | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Clarify that
Suggested change
|
||||||
| | `repo_path` | `str \| None` | Subdirectory within repo (for monorepos) | | ||||||
| | `auto_load` | `"all" \| None` | Loading strategy (default: `None`) | | ||||||
|
|
||||||
| ## Next Steps | ||||||
|
|
||||||
| - **[Skills](/sdk/guides/skill)** - Learn more about skills and triggers | ||||||
|
|
||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Change "Plugin source" to "Marketplace source" to match the actual field description in the SDK code.
Source