Skip to content

feat(extensions): phase-1 extension manifest and plugin install progress - #70176

Closed
sliverp wants to merge 2 commits into
mainfrom
feat/extensions-as-npm-plugins-phase1
Closed

sliverp wants to merge 2 commits into
mainfrom
feat/extensions-as-npm-plugins-phase1

Conversation

@sliverp

@sliverp sliverp commented Apr 22, 2026

Copy link
Copy Markdown
Member

feat(extensions): phase-1 extension manifest and plugin install progress

The approach adds a manifest.json under extension to declare which external plugins are available. The entries in the manifest are loaded into the onboarding UI based on their type, and when a user selects one, it is automatically installed via NPM with progress feedback shown during the process. From an architecture perspective, the file structure also leaves room for future extensions such as remote registry support and plugin marketplace-style expansion.

The PR uses wecom as an example and has been tested. Review would be appreciated.

#70150

Introduce a declarative extension manifest under extensions/ so plugins can
be distributed as external npm packages and installed on demand via
'openclaw plugins install <npm-spec>'. WeCom (@wecom/wecom-openclaw-plugin)
is the first adopter.

- extensions/manifest.json + manifest.schema.json: bundled manifest of
  extension entries (channel/provider/tool/hook/skill kinds), designed to
  be forward-compatible with local-override and remote sources planned for
  phase-2/3.
- src/plugins/extension-registry/: manifest resolver with priority
  local-override > remote > bundled; bundled-source, local-override-source,
  remote-source stubs; unit tests.
- src/channels/bundled-channel-catalog-read.ts: merge extension-manifest
  channel entries as virtual bundled entries so they appear in
  CHAT_CHANNEL_ORDER / listChatChannels() (the onboard picker seed).
  Wrapped in try/catch so manifest failures never block onboard.
- src/channels/plugins/catalog.ts: add EXTENSION_MANIFEST_PRIORITY seam so
  installable catalog entries for manifest-declared channels surface during
  onboard ("install plugin to enable").
- src/commands/channel-setup/install-plan-progress.ts: 6-step install
  progress (resolve -> download -> verify -> scan -> extract -> register)
  for the onboard UX, with unit tests.
- src/channels/plugins/catalog.extension-manifest.test.ts: integration
  test proving manifest-only entries appear as installable catalog
  entries.

Refs #70150
@aisle-research-bot

aisle-research-bot Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 2 potential security issue(s) in this PR:

# Severity Title
1 🟠 High Untrusted local override manifest path can lead to confused-deputy plugin selection
2 🟡 Medium Terminal escape/log injection via unsanitized install progress detail rendered to CLI spinner
1. 🟠 Untrusted local override manifest path can lead to confused-deputy plugin selection
Property Value
Severity High
CWE CWE-426
Location src/plugins/extension-registry/local-override-source.ts:46-58

Description

createLocalOverrideManifestSource() loads an override manifest from a path derived from environment-controlled config resolution and gives it highest precedence in the extension registry.

  • Input: ctx.env ?? process.env is used to resolve the config directory via resolveConfigDir(env).
  • resolveConfigDir honors environment overrides (OPENCLAW_STATE_DIR / OPENCLAW_CONFIG_PATH) without validating the resulting path.
  • The code then reads and parses $CONFIG_DIR/extensions/manifest.json and treats its contents as authoritative plugin entries.

If OpenClaw is ever executed in a more-privileged context (e.g., as root, a service account, via sudo, or by an automated installer) while an attacker can influence the environment variables or provide a writable/symlinked config directory, the attacker may be able to point the process at an attacker-controlled manifest and cause it to offer/install attacker-chosen extensions (confused deputy / local privilege escalation vector depending on how extensions are later fetched/executed).

Recommendation

Harden the override-manifest trust boundary:

  • Do not allow environment variables to redirect the config dir in privileged executions (e.g., when process.getuid?.() === 0 or when effective uid differs from real uid).
  • Validate the override manifest file before reading:
    • Resolve real paths (fs.realpathSync) and reject symlinks (lstat.isSymbolicLink())
    • Enforce ownership (root or expected user) and safe permissions (not group/world-writable)
    • Optionally require the override path to be under a fixed, known directory (e.g., $HOME/.openclaw) unless an explicit --allow-unsafe-config flag is provided.

Example (sketch):

import os from "node:os";

function isPrivileged(): boolean {
  const getuid = process.getuid?.bind(process);
  const geteuid = process.geteuid?.bind(process);
  return Boolean(getuid && geteuid && geteuid() === 0 || (getuid && geteuid && geteuid() !== getuid()));
}

load(ctx) {
  const env = ctx.env ?? process.env;
  if (isPrivileged()) {
    ​// Ignore env-based overrides in privileged context
    env = { ...env, OPENCLAW_STATE_DIR: "", OPENCLAW_CONFIG_PATH: "" } as NodeJS.ProcessEnv;
  }
  const configDir = resolveConfigDir(env);
  const manifestPath = path.join(configDir, OVERRIDE_RELATIVE_PATH);
  const st = fs.lstatSync(manifestPath);
  if (st.isSymbolicLink() || (st.mode & 0o022) !== 0) return [];
  ​// optionally: check st.uid matches expected uid
  ...
}

This prevents attacker-controlled config paths from being used as an authority source when the process runs with elevated privileges.

2. 🟡 Terminal escape/log injection via unsanitized install progress detail rendered to CLI spinner
Property Value
Severity Medium
CWE CWE-150
Location src/commands/channel-setup/install-plan-progress.ts:60-95

Description

InstallPlanEvent.detail is concatenated directly into a human-facing progress label and then rendered to terminal UI components (WizardProgress.update / @​clack/prompts spinner and OSC progress label) without neutralizing control characters.

  • Inputs (untrusted):
    • initialDetail (e.g., user-supplied npm spec from CLI args)
    • err.message from thrown errors (may include attacker-controlled strings from registries, network responses, crafted package names, etc.)
  • Sink: progress.update(...) ultimately calls terminal renderers (spinner/OSC) that write to TTY.
  • Impact: If detail contains newlines, carriage returns, tabs, or ANSI escape sequences, an attacker could:
    • spoof or overwrite terminal output (prompt spoofing)
    • forge CI logs / mislead operators
    • potentially trigger terminal-specific escape behaviors

Vulnerable code:

if (event.detail) {
  return `${base} — ${event.detail}`;
}
...
progress.update(formatInstallPlanLabel(event));

A helper already exists (src/terminal/safe-text.ts:sanitizeTerminalText) but is not used here.

Recommendation

Sanitize/normalize any untrusted text before rendering it to the terminal.

Option A (local fix in this module):

import { sanitizeTerminalText } from "../../terminal/safe-text.js";

export function formatInstallPlanLabel(event: InstallPlanEvent): string {
  const counter = `[${event.index}/${event.total}]`;
  const base = `${counter} ${event.label}`;
  if (event.detail) {
    return `${base} — ${sanitizeTerminalText(event.detail)}`;
  }
  return base;
}

Option B (defense-in-depth): also sanitize inside WizardProgress.update / createCliProgress.setLabel so all progress labels are safe by default.

Ensure the sanitization removes ANSI escapes and replaces \r, \n, \t with visible sequences (as sanitizeTerminalText already does).


Analyzed PR: #70176 at commit b10b470

Last updated on: 2026-04-22T13:10:09Z

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XL maintainer Maintainer-authored PR labels Apr 22, 2026
@greptile-apps

greptile-apps Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a phase-1 extension manifest system: a new extensions/manifest.json declares external npm plugins (using @wecom/wecom-openclaw-plugin as the example), a three-source registry (bundled, remote, local-override) merges them with priority-based deduplication, and the channel catalog is updated to surface manifest entries in the onboarding picker. A runInstallPlanWithProgress helper adds a structured 6-step install event stream for UI feedback. The implementation is well-tested and degrades gracefully when the manifest is missing or invalid.

Confidence Score: 5/5

Safe to merge; all findings are P2 quality/design suggestions with no blocking defects.

All four findings are P2: a phase-1 scoping gap (local-override excluded from sync path), silent error swallowing, an inaccurate comment, and a coarse failure-step attribution. None cause incorrect data, breakage, or security risk. The degradation behaviour is well-tested and explicitly designed to be non-blocking.

src/plugins/extension-registry/index.ts (local-override excluded from sync default sources), src/commands/channel-setup/install-plan-progress.ts (comment/failure-step accuracy)

Comments Outside Diff (3)

  1. src/channels/plugins/catalog.ts, line 334-337 (link)

    P2 Silent catch swallows all extension manifest errors

    The bare catch { return []; } and its counterpart in bundled-channel-catalog-read.ts (lines 226–228) discard every failure—parse errors, unexpected throws from future source logic, file permission issues—with no log line or diagnostic. When the manifest silently produces nothing, there is no way to distinguish "no external plugins configured" from "manifest is broken." A single debug-level log call (e.g. logger.debug("extension manifest load failed", err)) before returning [] would make onboard failures diagnosable without breaking the degradation guarantee.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/channels/plugins/catalog.ts
    Line: 334-337
    
    Comment:
    **Silent catch swallows all extension manifest errors**
    
    The bare `catch { return []; }` and its counterpart in `bundled-channel-catalog-read.ts` (lines 226–228) discard every failure—parse errors, unexpected throws from future source logic, file permission issues—with no log line or diagnostic. When the manifest silently produces nothing, there is no way to distinguish "no external plugins configured" from "manifest is broken." A single debug-level log call (e.g. `logger.debug("extension manifest load failed", err)`) before returning `[]` would make onboard failures diagnosable without breaking the degradation guarantee.
    
    How can I resolve this? If you propose a fix, please make it concise.
  2. src/commands/channel-setup/install-plan-progress.ts, line 652-683 (link)

    P2 All failures are reported as resolve:error regardless of which step actually failed

    When isSuccess returns false, the code always maps the error to the "resolve" step. If the underlying install fails because of a network timeout during download, an integrity mismatch during verify, or a registration conflict, the event stream still reports resolve:error. For non-interactive consumers (CI, --json mode via createJsonLinesProgressReporter) this makes the failure step systematically inaccurate and prevents actionable error attribution. The comment says "Map failures to the most likely step," but resolve is the least likely root cause for the majority of failure modes.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/commands/channel-setup/install-plan-progress.ts
    Line: 652-683
    
    Comment:
    **All failures are reported as `resolve:error` regardless of which step actually failed**
    
    When `isSuccess` returns `false`, the code always maps the error to the `"resolve"` step. If the underlying install fails because of a network timeout during download, an integrity mismatch during verify, or a registration conflict, the event stream still reports `resolve:error`. For non-interactive consumers (CI, `--json` mode via `createJsonLinesProgressReporter`) this makes the failure step systematically inaccurate and prevents actionable error attribution. The comment says "Map failures to the most likely step," but `resolve` is the least likely root cause for the majority of failure modes.
    
    How can I resolve this? If you propose a fix, please make it concise.
  3. src/commands/channel-setup/install-plan-progress.ts, line 654-659 (link)

    P2 Comment says "resolve+download as 'start'" but only resolve:start is emitted

    The block comment reads: "eagerly announce resolve+download as 'start' so the user immediately sees what's coming." The implementation only calls report(makeEvent("resolve", "start", …)) before run(); there is no corresponding download:start event. The download step receives only an ok event (or no event on failure). The comment should be corrected to match actual behavior, or a download:start event should be emitted before awaiting run() if the dual-start intent is genuine.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/commands/channel-setup/install-plan-progress.ts
    Line: 654-659
    
    Comment:
    **Comment says "resolve+download as 'start'" but only `resolve:start` is emitted**
    
    The block comment reads: *"eagerly announce resolve+download as 'start' so the user immediately sees what's coming."* The implementation only calls `report(makeEvent("resolve", "start", …))` before `run()`; there is no corresponding `download:start` event. The `download` step receives only an `ok` event (or no event on failure). The comment should be corrected to match actual behavior, or a `download:start` event should be emitted before awaiting `run()` if the dual-start intent is genuine.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/plugins/extension-registry/index.ts
Line: 107-117

Comment:
**Local-override source is sync but excluded from the sync path**

`local-override-source.ts` uses `fs.readFileSync`, so it returns `ExtensionEntry[]` (not a `Promise`). The sync guard in `resolveExtensionManifestSync` (`if (!Array.isArray(entries))`) would correctly handle it. However, the default sources list for the sync variant is `[createBundledManifestSource()]` only, which means any operator who creates `$OPENCLAW_CONFIG_DIR/extensions/manifest.json` to pin/inject extensions will have those entries silently ignored by the channel picker, since all catalog callers use the sync path.

The comment says "may do IO and are opted out… deliberately," but `local-override-source.ts` uses synchronous IO. If the phase-1 intent is that local overrides are not yet active, the exported `createLocalOverrideManifestSource` is never reachable from production code paths (only from tests), which should be documented or the factory omitted until phase 2.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/channels/plugins/catalog.ts
Line: 334-337

Comment:
**Silent catch swallows all extension manifest errors**

The bare `catch { return []; }` and its counterpart in `bundled-channel-catalog-read.ts` (lines 226–228) discard every failure—parse errors, unexpected throws from future source logic, file permission issues—with no log line or diagnostic. When the manifest silently produces nothing, there is no way to distinguish "no external plugins configured" from "manifest is broken." A single debug-level log call (e.g. `logger.debug("extension manifest load failed", err)`) before returning `[]` would make onboard failures diagnosable without breaking the degradation guarantee.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/commands/channel-setup/install-plan-progress.ts
Line: 652-683

Comment:
**All failures are reported as `resolve:error` regardless of which step actually failed**

When `isSuccess` returns `false`, the code always maps the error to the `"resolve"` step. If the underlying install fails because of a network timeout during download, an integrity mismatch during verify, or a registration conflict, the event stream still reports `resolve:error`. For non-interactive consumers (CI, `--json` mode via `createJsonLinesProgressReporter`) this makes the failure step systematically inaccurate and prevents actionable error attribution. The comment says "Map failures to the most likely step," but `resolve` is the least likely root cause for the majority of failure modes.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/commands/channel-setup/install-plan-progress.ts
Line: 654-659

Comment:
**Comment says "resolve+download as 'start'" but only `resolve:start` is emitted**

The block comment reads: *"eagerly announce resolve+download as 'start' so the user immediately sees what's coming."* The implementation only calls `report(makeEvent("resolve", "start", …))` before `run()`; there is no corresponding `download:start` event. The `download` step receives only an `ok` event (or no event on failure). The comment should be corrected to match actual behavior, or a `download:start` event should be emitted before awaiting `run()` if the dual-start intent is genuine.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(extensions): phase-1 extension mani..." | Re-trigger Greptile

Comment on lines +107 to +117
* runs inside sync discovery paths). Only consults the bundled source — the
* remote/local-override sources may do IO and are opted out of the sync path
* deliberately.
*
* Phase 2 note: if remote caching moves to a fully-materialised on-disk
* cache, it can also expose a sync read and be added here.
*/
export function resolveExtensionManifestSync(
options: ResolveExtensionManifestOptions = {},
): ResolvedExtensionEntry[] {
const sources = options.sources ?? [createBundledManifestSource()];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Local-override source is sync but excluded from the sync path

local-override-source.ts uses fs.readFileSync, so it returns ExtensionEntry[] (not a Promise). The sync guard in resolveExtensionManifestSync (if (!Array.isArray(entries))) would correctly handle it. However, the default sources list for the sync variant is [createBundledManifestSource()] only, which means any operator who creates $OPENCLAW_CONFIG_DIR/extensions/manifest.json to pin/inject extensions will have those entries silently ignored by the channel picker, since all catalog callers use the sync path.

The comment says "may do IO and are opted out… deliberately," but local-override-source.ts uses synchronous IO. If the phase-1 intent is that local overrides are not yet active, the exported createLocalOverrideManifestSource is never reachable from production code paths (only from tests), which should be documented or the factory omitted until phase 2.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugins/extension-registry/index.ts
Line: 107-117

Comment:
**Local-override source is sync but excluded from the sync path**

`local-override-source.ts` uses `fs.readFileSync`, so it returns `ExtensionEntry[]` (not a `Promise`). The sync guard in `resolveExtensionManifestSync` (`if (!Array.isArray(entries))`) would correctly handle it. However, the default sources list for the sync variant is `[createBundledManifestSource()]` only, which means any operator who creates `$OPENCLAW_CONFIG_DIR/extensions/manifest.json` to pin/inject extensions will have those entries silently ignored by the channel picker, since all catalog callers use the sync path.

The comment says "may do IO and are opted out… deliberately," but `local-override-source.ts` uses synchronous IO. If the phase-1 intent is that local overrides are not yet active, the exported `createLocalOverrideManifestSource` is never reachable from production code paths (only from tests), which should be documented or the factory omitted until phase 2.

How can I resolve this? If you propose a fix, please make it concise.

The aliases in CHAT_CHANNEL_ALIASES are derived from listBundledChannelCatalogEntries(), which merges extensions/manifest.json as Layer 2. The test was comparing against listChannelCatalogEntries({ origin: 'bundled' }) which only reflects physically discovered plugins, so manifest-only entries (e.g. WeCom's qywx/wework aliases) appeared on the expected side but not the received side.

Use the same source as the production constant so the assertion stays meaningful and does not regress when new channel entries are declared in the manifest without a bundled package.

Refs #70150

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4bae187d0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (!packageRoot) {
return [];
}
const manifestPath = path.join(packageRoot, MANIFEST_DIR_NAME, MANIFEST_FILE_NAME);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve bundled manifest from packaged extension tree

Load path is hardcoded to ${packageRoot}/extensions/manifest.json, but installed builds resolve bundled plugins from dist/extensions (and npm packaging only ships dist/**), so this source returns [] in packaged CLIs and external manifest channels never appear in onboarding/catalog flows. This means the feature works in source checkouts but silently disappears for end users running the published package.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor

Maintainer review notes from local pass. Request changes before treating this as closing #70150.

Blocking:

  • src/plugins/extension-registry/bundled-source.ts:67: bundled manifest lookup hardcodes <packageRoot>/extensions/manifest.json, but the npm package ships dist/ via package.json:23. Published CLIs will not include/read this file, so manifest-only channels can disappear for end users. Please either stage/copy the manifest into dist and resolve it there, or resolve through the bundled plugin dir/package artifact path used by packaged installs.

  • src/plugins/extension-registry/remote-source.ts:22: OPENCLAW_EXTENSION_MANIFEST_URL is read and then ignored. Externalize extensions: manifest-driven discovery + on-demand install via openclaw plugins install #70150 acceptance says a test remote manifest should populate onboarding; this currently always returns [].

  • src/commands/channel-setup/plugin-install.ts:188: the actual onboarding install path still calls installPluginFromNpmSpec directly. runInstallPlanWithProgress is only used by its tests, so the PR does not yet surface live wizard progress / JSON progress from real installs.

Other gaps vs the issue: no manifest generation/check script, no docs update, no plugins search / manifest refresh, and local override is implemented but excluded from the sync catalog path used by onboarding.

Verification:

  • Passed: pnpm test src/plugins/extension-registry/index.test.ts src/plugins/extension-registry/bundled-source.test.ts src/channels/plugins/catalog.extension-manifest.test.ts src/commands/channel-setup/install-plan-progress.test.ts src/channels/ids.test.ts
  • pnpm check:changed is blocked by existing-looking core type errors in src/agents/pi-embedded-runner/*; PR CI is currently green.

@vincentkoc

Copy link
Copy Markdown
Member

This is superseded by #70012.

#70176 is pushing in the same install-on-demand direction, but through a parallel extensions/manifest.json / channel-only registry path. #70012 lands the more general onboarding seam instead:

  • shared onboarding installer
  • channel onboarding reuses it
  • provider onboarding also supports install-on-demand
  • a future external registry can plug into the same seam without adding a separate extension-manifest stack

I reviewed #70176 before closing it. I do not think we should carry code across as-is:

  • src/plugins/extension-registry/bundled-source.ts:67 resolves extensions/manifest.json from the package root, so manifest-only channels likely disappear in packaged installs
  • src/plugins/extension-registry/index.ts:117 excludes the sync local-override source from the sync path used by channel catalog callers
  • src/plugins/extension-registry/remote-source.ts:22 reads OPENCLAW_EXTENSION_MANIFEST_URL but still returns [], so the remote manifest path is not implemented yet
  • src/commands/channel-setup/plugin-install.ts:188 still calls installPluginFromNpmSpec directly, so the install progress helper added in this PR is not wired into the real onboarding path

Thanks for the WeCom example and the registry-layering exploration. If we want a future external registry, we should build it on top of the generalized onboarding install/catalog seams in #70012 instead of landing a separate channel-only manifest stack.

@vincentkoc vincentkoc closed this Apr 22, 2026
@shakkernerd
shakkernerd deleted the feat/extensions-as-npm-plugins-phase1 branch October 19, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants