#19735: fix: inject CLAWD_URL/CLAWD_TOKEN env vars in Lobster plugin
extensions: lobster
cli
size: XS
trusted-contributor
Fixes #19709
## What changed
- Added CLAWD_URL and CLAWD_TOKEN environment variables to the Lobster plugin subprocess execution
- The gateway URL is resolved from config (default port 18789) or falls back to ws://127.0.0.1:18789
- The token is resolved from config gateway.auth.token or OPENCLAW_GATEWAY_TOKEN env var
## AI-assisted contribution
This fix was generated by an AI agent (OpenClaw cron: gh-issues-fix)
Testing depth: validated with pnpm build && pnpm tsgo && pnpm vitest run extensions/lobster
The fix addresses the root cause described in the issue by injecting the required CLAWD_URL and CLAWD_TOKEN environment variables into the lobster subprocess, which are needed by local tools like clawd.invoke to communicate with the gateway.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR makes two changes to fix issue #19709:
1. **Lobster plugin env injection** (`extensions/lobster/src/lobster-tool.ts`): Injects `CLAWD_URL` and `CLAWD_TOKEN` environment variables into the lobster subprocess so that local tools like `clawd.invoke` can communicate with the gateway. The gateway URL is constructed from the configured port (defaulting to 18789) and the token is resolved from config or the `OPENCLAW_GATEWAY_TOKEN` env var.
2. **Plugin registry loading** (`src/cli/channels-cli.ts`): Ensures the plugin registry is loaded before running channel commands by calling `ensurePluginRegistryLoaded()` in both `runChannelsCommand` and `runChannelsCommandWithDanger`.
- Both changes are straightforward and follow existing patterns in the codebase.
- Minor style note: the lobster tool uses `||` for fallbacks where the rest of the codebase consistently uses `??` for the same gateway config patterns.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge — both changes are low-risk and follow established patterns.
- The changes are straightforward: env var injection into a subprocess and an idempotent plugin registry load call. The only issues are style-level inconsistencies (|| vs ??) that don't affect correctness in practice. No security concerns — the token is passed to a validated trusted binary.
- extensions/lobster/src/lobster-tool.ts has minor style inconsistencies with || vs ?? fallback operators.
<sub>Last reviewed commit: 3b91eec</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#8515: Lobster: disable Windows shell fallback
by coygeek · 2026-02-04
79.8%
#11454: fix(plugins): remove workspace:* from extension dependencies
by AnonO6 · 2026-02-07
75.7%
#21934: fix #21914 - Add the most obvious option to the error message
by vivganes · 2026-02-20
75.5%
#11602: fix(config): skip stale legacy config files when openclaw.json exists
by akoscz · 2026-02-08
74.8%
#17916: [ fix ] : correct config directory path during onboarding
by Dijo-404 · 2026-02-16
74.2%
#11439: fix(security): warn on relative OPENCLAW_CONFIG_PATH and disable co...
by coygeek · 2026-02-07
73.9%
#13176: fix: resolve llm-task module import for global installs
by striking · 2026-02-10
73.8%
#9200: Fix: Strip dangerous env vars from baseEnv in host execution
by vishaltandale00 · 2026-02-05
73.6%
#11159: fix(cli): parse --profile flag after subcommand name
by hclsys · 2026-02-07
73.6%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
73.5%