Skip to content

feature(channels): add channels start|stop|reconnect for existing Gateway RPCs - #183099

Open
nocodet888-arch wants to merge 1 commit into
openclaw:mainfrom
nocodet888-arch:feature/channels-start-stop
Open

nocodet888-arch wants to merge 1 commit into
openclaw:mainfrom
nocodet888-arch:feature/channels-start-stop

Conversation

@nocodet888-arch

Copy link
Copy Markdown
Contributor

Implements #183098

What Problem This Solves

Docs already prescribe channels.stop / channels.start for non-destructive per-account recovery (keep pairing/credentials; crash-loop safe-mode manual override), but operators must hand-craft openclaw gateway call JSON. The channels CLI has list/status/login/logout/dead-letters but no first-class start/stop.

User Impact

User impact: openclaw channels stop|start|reconnect --channel <id> [--account <id>] --json wraps the existing Gateway RPCs. Blank --account fails closed. Unknown channel fails closed. Prefer these over gateway call. Distinct from channels logout (clears credentials) and gateway restart (whole process).

Why This Change Was Made

Thin Alix-style CLI adapters under the existing channels tree only: forward validated params (including Gateway --port/--url) to channels.start / channels.stop, update recovery docs and the crash-loop manual-start hint, and keep Gateway semantics unchanged. No new Gateway methods, schema, or permissions.

Evidence

  • Changed: src/commands/channels/start-stop.ts, src/cli/channels-cli.ts, src/infra/gateway-boot-lifecycle.ts (+ tests), docs/cli/channels.md, docs/gateway/restart-recovery.md, docs/channels/troubleshooting.md
  • Unit: node scripts/run-vitest.mjs src/commands/channels/start-stop.test.ts — 6 passed; src/infra/gateway-boot-lifecycle.test.ts hint cases — 19 passed
  • Packaged CLI e2e below on local Gateway with Telegram accounts

Real behavior proof

Behavior or issue addressed

Operators need native openclaw channels start|stop|reconnect that call existing channels.start / channels.stop; stop/start must return Gateway stopped / started+outcome; blank --account and unknown channel must fail closed; status probe remains available after recovery.

Canonical reachability path

Packaged openclaw channels stop|start|reconnect → channelsStopCommand / channelsStartCommand / channelsReconnectCommand → callGatewayFromCliWithTransport("channels.stop"|"channels.start", …) → src/gateway/server-methods/channels.ts.

Shared helper / provider constraint check

Reuses addGatewayClientOptions, callGatewayFromCliWithTransport, and parseAccountSelector. Does not own channel lifecycle; reuses existing Gateway account start/stop owners (same path login already uses for channels.start).

Real environment tested

Packaged CLI after qaRuntime build on Node 24.22.1; temporary OPENCLAW_STATE_DIR + OPENCLAW_CONFIG_PATH; local openclaw gateway run --port 18821 with token auth; Telegram channel enabled with fake BotFather tokens (accounts default + proof).

Exact steps or command run after this patch

node openclaw.mjs channels stop --channel telegram --account proof --url ws://127.0.0.1:18821 --token "$TOKEN" --json
node openclaw.mjs channels start --channel telegram --account proof --url ws://127.0.0.1:18821 --token "$TOKEN" --json
node openclaw.mjs channels start --channel telegram --account proof --port 18821 --token "$TOKEN" --json
node openclaw.mjs channels reconnect --channel telegram --account proof --url ws://127.0.0.1:18821 --token "$TOKEN" --json
node openclaw.mjs channels status --channel telegram --probe --json
node openclaw.mjs channels start --channel telegram --account "" --json   # blank reject
node openclaw.mjs channels start --channel definitely-not-a-channel --url … --json

Evidence after fix

# channels --help lists start / stop / reconnect
  start         Start one channel account runtime without re-authenticating (channels.start)
  stop          Stop one channel account runtime without clearing credentials (channels.stop)
  reconnect     Stop then start one channel account (non-destructive reconnect)

# stop (exit 0)
{
  "channel": "telegram",
  "accountId": "proof",
  "stopped": true
}

# start --url … (exit 0)
{
  "channel": "telegram",
  "accountId": "proof",
  "started": true,
  "outcome": { "status": "handed-off" }
}

# start --port 18821 … (exit 0) — same started/outcome shape
{
  "channel": "telegram",
  "accountId": "proof",
  "started": true,
  "outcome": { "status": "handed-off" }
}

# reconnect (exit 0)
{
  "stop": { "channel": "telegram", "accountId": "proof", "stopped": true },
  "start": {
    "channel": "telegram",
    "accountId": "proof",
    "started": true,
    "outcome": { "status": "handed-off" }
  }
}

# status --probe after recovery (exit 0) — probe present; running reflects lifecycle
# (fake token → probe 401 Unauthorized; recovery path exercised)

# blank --account (exit 1)
{ "ok": false, "error": { "type": "cli_error", "message": "--account must not be blank" } }

# unknown channel (exit 1)
{ "ok": false, "error": { "type": "cli_error", "message": "invalid channels.start channel" } }

# unconfigured account (Gateway semantics: exit 0, started:false skipped/unconfigured)
{
  "channel": "telegram",
  "accountId": "definitely-missing-acct",
  "started": false,
  "outcome": { "status": "skipped", "reason": "unconfigured" }
}

Notes for reviewers

  • Extends existing channels CLI tree (not a new top-level namespace).
  • Crash-loop recovery hint now points at openclaw channels start --channel … instead of gateway call.
  • AI-assisted. Maintainers can edit.

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: M labels Oct 25, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 25, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds channels start, stop, and reconnect commands over existing Gateway RPCs and updates recovery instructions.

Example: Restart the existing WhatsApp account named work while preserving pairing.

  • Before: Run separate gateway call commands with JSON parameters for channels.stop and channels.start.
  • After: Run openclaw channels reconnect --channel whatsapp --account work --json.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation and relevant runtime evidence support confidence in the patch; unresolved product direction caps overall readiness.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Packaged CLI output against an isolated local Gateway exercises the new command owner, URL and port targeting, stop/start/reconnect responses, and invalid selectors; the recorded 401 probe correctly limits claims about Telegram connectivity.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Operators must construct Gateway RPC JSON to recover one channel account without logging out.
Reason: The convenience is concrete, but existing recovery already works and the new preferred CLI surface lacks an owner decision.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: the focused CLI addition is coherent and has runtime evidence, but adopting it as the preferred recovery interface still needs an owner decision.

Priority: P3
Reviewed head: b87a6304b9b454a24396a1f854935849182249c4
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should dedicated channels start, stop, and reconnect commands become the preferred per-account recovery interface?
  • Recommendation: Adopt the focused CLI commands: Approve the ergonomic interface while preserving the existing RPC contracts and lifecycle owner.
  • Why: Recovery already works through documented Gateway calls, and no recorded owner decision approves expanding and promoting this CLI interface.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

The channels CLI accepts account selectors and Gateway connection options, invokes authenticated lifecycle RPCs, and prints the Gateway-owned runtime outcomes.

flowchart LR
  A[Operator] --> B[Channels CLI]
  B --> C[Shared Gateway client]
  C --> D[Authenticated lifecycle RPCs]
  D --> E[Channel runtime owner]
  E --> F[Account outcome]
Loading

Technical review

Best possible solution:

If approved, expose these commands as thin adapters while retaining Gateway ownership of authorization, account selection, and lifecycle outcomes.

Do we have a high-confidence way to reproduce the issue?

Source confirms the missing dedicated CLI interface and existing recovery RPCs; this feature proposal establishes no separate runtime bug.

Is this the best way to solve the issue?

The adapters fit the existing ownership boundary and avoid new protocol or persistence machinery, but promoting them is a product choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ff9b95f3edb5.

Provenance checked

  • Crash-loop recovery hint keeps the original intent (6b02b00: Make the recovery command target the active profile or container and preserve account targeting.)
  • Per-account recovery documentation changes intended behavior with a stated reason (38feb61: Document credential-preserving stop/start with matching account selectors and distinguish runtime outcomes from provider connectivity.)
  • Safe-mode recovery instructions keeps the original intent (37a269f: Explain the existing manual startup override while keeping crash-loop breaker semantics unchanged.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +188, Tests +151, Docs +1. Total +340 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 195 7 +188
Tests 3 157 6 +151
Docs 3 10 9 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 362 22 +340

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #183098
Summary: This PR is the implementation candidate for the paired CLI-interface request.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This improves an advanced operator workflow that already has a documented, supported recovery command.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-25T01:35:11.365Z sha bf5e59bde9acc9e33ea556db86eff0e348ecc427 :: blocked before merge. :: [P3] Complete the recovery examples' CLI conversion
  • reviewed 2026-10-25T03:49:31.843Z sha 646736357873d7f753ea3300315380fc3bb58b81 :: blocked before merge. :: none

Reviewed October 27, 2026, 8:24 PM ET / October 28, 2026, 00:24 UTC (Revision 3).

@nocodet888-arch
nocodet888-arch force-pushed the feature/channels-start-stop branch from bf5e59b to 6467363 Compare October 25, 2026 03:44
@nocodet888-arch

Copy link
Copy Markdown
Contributor Author

Addressed ClawSweeper author findings on head 646736357873:

  • Fixed crash-loop recovery log example to openclaw channels start --channel <id> (was still prefixed with gateway call).
  • Converted the optional-account JSON comment to --account <account>.
  • Removed the low-value stop-failure unit case that duplicated the start-failure error-handler assertion.

Runtime hint in formatGatewayCrashLoopManualChannelStartHint was already on the channels CLI path.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 25, 2026
@nocodet888-arch
nocodet888-arch force-pushed the feature/channels-start-stop branch from 6467363 to b87a630 Compare October 25, 2026 14:29
@nocodet888-arch

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and polished CI only: assertion-safety // SAFETY: (or equivalent narrowing), oxfmt/docs format on PR-touched files, unused-import cleanup where needed. Feature surface and Real behavior proof unchanged — please re-run CI / @clawsweeper if a fresh pass is useful.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Oct 27, 2026
@nocodet888-arch

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head b87a6304b9b4 (CI polish rebase after the author-findings fix on 646736357873). Feature surface and Real behavior proof unchanged; prior durable review was marked stale against this head. openclaw/ci-gate green.

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant