[OMEGA-161][OMEGA-205] Add plugin API to universally load any kind of plugins, add existing communication channels and LLM providers as plugins#222
Conversation
blackhammer116
left a comment
There was a problem hiding this comment.
Its a fairly nice implementation overall, but I highly recommend to move the plugin code from src to another dir like config. The src directory should only contain code that is directly related to the core functionality of OmegaClaw like the main loop, memory management, channels interface... and not a plugin config script
Being able loading and calling plugins is a core OmegaClaw functionality as all LLM and communication channel integrations are implemented via this mechanism. Thus I don't understand why it should be moved into a separate directory. |
|
Tested OMEGA-161. What I checked (works):
Blocking:
These unit tests import channels/wschat.py directly (in-process, no container). This PR adds a module-level import pluginapi as plugin (wschat.py:64), so importing the module now needs pluginapi on the path, which run_mandatory doesn't provide. The tests existed and passed on main before the plugin refactor. Guarding the import fixes it with no test changes (the 6 unit tests pass again). Inline suggestion on line 64. Not merge-ready until run_mandatory is green. |
Thanks @TossSky I applied the change you suggested. I think we should find a proper way to run unit tests with using production like environment. |
| print(f"_initPythonPlugin: loading {name} plugin from {location} using Python module loader") | ||
| spec = importlib.util.spec_from_file_location(name, location) | ||
| mod = importlib.util.module_from_spec(spec) | ||
| spec.loader.exec_module(mod) |
There was a problem hiding this comment.
@vsbogd
Sorry, the wschat quickfix wasn't enough, CI is still red, on a different failure now. After the recent main merges the channels also import auth (channels/auth.py) and the plugin loader doesn't put the plugin's directory or the repo root on sys.path, so plugins that import a sibling or Autotests.mock.* fail at startup and the agent never becomes ready (ModuleNotFoundError: No module named 'auth').
Adding the plugin dir and repo root to sys.path in _initPythonPlugin before exec_module fixes it.
Verified: agent starts and run_mandatory is green (49 passed).
| spec.loader.exec_module(mod) | |
| import sys | |
| for _extra in (str(location.parent), str(_REPO)): | |
| if _extra not in sys.path: | |
| sys.path.insert(0, _extra) | |
| spec.loader.exec_module(mod) |
There was a problem hiding this comment.
Import of the Python module in PeTTa changes the sys.path. Thus moving websearch.py from channels to src changed the sys.path contents which led to the plugin code unable importing the module from `channels.
It would be logical to add plugin location into the sys.path thus I implemented it as a fix in 1823c3f
There was a problem hiding this comment.
After rebase this fix is included into the first commit.
|
Have to rebase it because of conflicts in |
Any extension is module which implements loadOmegaClawPlugin function and uses pluginapi module to register callbacks and intervene to the agents working loop. In this commit IRC plugin is added which registers IRC communication channel callbacks which are used by the agent to communicate via IRC.
The plugin adds integration with Anthropic, ASICloud, Ollama-local and any other endpoint which is reachable via OpenAI API and doesn't requires specific processing.
"model" parameter can be used to override OpenRouter provider model.
Unit test imports wschat in environment which doesn't include the pluginapi module. This commit is a quickfix for the issue. Co-authored-by: TossSky <v.totski@etorn.ee>
|
Fixed incorrect logger imports (thanks @besSveta) 35da8f9 |
Well, before, the channel adapters were in a separate dir (as well as the LLM handler) because they where, in a way, configs. and since the plugin is doing the same, but in a more modular and optimal way, that's why I suggested moving it out of the dir. But it's not a hard blocker the code can be cleaned once functionality has been achived |
If you are talking about
|
|
@blackhammer116 @TossSky I have found that asking for a model after selecting provider in the If you don't mind, I will change the order. It should be one-liner which should not trigger the full retesting of code I believe. What do you think? |
|
@vsbogd |
The plugin refactor never ported the WebSocket channel, so -t websocket crashed at startup with "Communication channel plugin websocket is not registered". - channels/wschat.py: add WSChannel(CommChannel) and loadOmegaClawPlugin() registering it as "websocket"; config() passes WS_URL/WS_TOKEN into the existing start_websocket. - config/plugins.yaml: list wschat so the loader imports it. - import pluginapi by its bare name so the registration lands in the registry the loader reads, with src.pluginapi as fallback for the in-process unit test.
|
Tested OMEGA-161. One failure:
Fix: vsbogd#6 Everything else passed. |
[OMEGA-161] Register websocket channel as a plugin
Thanks applied your fix, looks like my implementation was lost during rebase.
Thanks for the fast response, I will do this then. |
Return order of actions which is more aligned with previous user experience.
|
@TossSky I have tested interactive part of the |
|
Retested. All passed. |
Description
Plugin API is introduced to allow writing any kind of plugins which are uniformly loaded and registered inside OmegaClaw agent. This PR replaces #169
The API can be found inside src/pluginapi.py. At the moment it contains communication channel and LLM provider APIs. Skills to be added later in a separate PR. Supporting both MeTTa and Python plugins are planned but this PR implements only Python API because all of the plugins we already have are written in Python.
Python plugins can be loaded as a single Python path anywhere in the file-system or any Python module within the
PYTHONPATH. To uniformly load them the config/plugins.yaml file is introduced because Python modules cannot be found in specific locations and should be listed explicitly. It can be overridden by the user in the specific deployments. The only required exported function in the plugin isloadOmegaClawPlugin()which should usesrc/pluginapi.pyto register all necessary callbacks.All existing communication channels and LLM providers are represented as plugins and listed in the
config/plugins.yaml. Both communication channel and LLM provider plugins gets the list of OmegaClaw command line parameters on configuration step in order to extract necessary information from them.New
modelparameter is added to LLM providers which allows user overriding the model used by specifyingmodel=<model-name>command line parameter. Newopenaiapi_urlcommand line parameter is added to allow specifying the URL of the LLM API endpoint. This makesOllama-localprovider unnecessary and it is replaced by universalOpenAIAPIprovider.How Has This Been Tested?
Run docker using each communication channel.
Run docker using each LLM provider.
Run docker using OpenAIAPI LLM provider specifying
claude-opus-4-8as amodelandhttps://api.anthropic.com/v1/asopenaiapi_url.Ask
What is the distance to the Sun?in each run.Checklist