fix(cli): keep the metadata-only registration away from the host runtime - #996
Draft
gorkem2020 wants to merge 1 commit into
Draft
Conversation
Current hosts register plugins in a "cli-metadata" mode to collect the CLI command tree before any runtime exists: api.runtime is a proxy that throws on access, and nothing registered in that pass ever runs (the host loads the command's owning plugin again in full mode to execute it). register() wired the LLM client eagerly and feature-detected the host completion surface by reading api.runtime.llm, so every CLI process logged "smart extraction init failed, falling back to regex" and did the whole LLM and admission wiring for a registration whose handlers never run. The runtime probe now reads a throwing runtime as unavailable; register() skips the LLM client, smart extraction and admission wiring under cli-metadata registration while still registering the CLI tree; the root CLI registration passes a parse-time descriptor next to the command name; and the manifest declares the memory-pro root command in cliCommands, the surface the host's own guidance points at. Regressions: the throw-safe probe and the mode check, a cli-metadata registration that registers the CLI without touching the runtime or logging an init failure, an unchanged full-mode registration, and the manifest declaration matching the registrar's descriptor.
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.
Summary
Current OpenClaw hosts register plugins in a
cli-metadatamode to collect the CLI command tree before any runtime exists. In that modeapi.runtimeis a proxy that throws on access, and nothing registered there ever executes (the host loads the command's owning plugin again in full mode to run it). This plugin'sregister()wires the LLM client eagerly and feature-detects the host completion surface by readingapi.runtime.llm, so every CLI process loggedon commands as harmless as
openclaw memory-pro stats, and the metadata pass ran the whole LLM and admission wiring for a registration whose handlers never run. The gateway (full mode) was never affected.Changes
index.ts:resolveRuntimeLlmCompletereads a throwing runtime as "unavailable" instead of propagating the error;register()skips the LLM client, smart extraction and admission wiring whenapi.registrationModeiscli-metadata(isCliMetadataRegistration), leaving the CLI tree registration in place; the root CLI registration now passes a parse-time descriptor (MEMORY_PRO_CLI_DESCRIPTOR) alongsidecommands, so the host can registermemory-proas a lazy placeholder.openclaw.plugin.json: declares thememory-proroot command incliCommands, the manifest surface the host's message points at, so help and activation planning resolve the owner without loading the plugin.test/cli-metadata-registration.test.mjscovers the throw-safe probe, the mode check, acli-metadataregistration that registers the CLI tree without touching the runtime or logging an init failure, an unchanged full-mode registration (admission wiring still constructed), and the manifest declaration matching the registrar's descriptor. Registered in thenpm testchain and the CI manifest (core-regression).Notes
registrationModenever set it, so the gate is inert there; the descriptor option is ignored by hosts that do not read it.runtime.llmis unchanged; it simply no longer fires on the metadata pass, where it had nothing to do.Verification
npm run build,npm test, thecli-smokeCI group, the new regression file (four of its six cases red against the previous code by construction), and the existingcommand-reflection-guard,llm-host-transport,llm-host-transport-composition,admission-control-host-transport,llm-transport-credential-hygieneandplugin-manifest-regressionsuites.openclaw memory-pro statsprinted the init-failure line before its output on every invocation; with this change the metadata pass logs a debug line and no warning.