UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

685 lines (684 loc) • 25.6 kB
import "./redact-BDinS1q9.js"; import "./errors-BxyFnvP3.js"; import "./unhandled-rejections-CDJ8dOVP.js"; import "./logger-kwZIqwuw.js"; import { _ as resolveStateDir, h as resolveOAuthDir, i as isNixMode, o as resolveConfigPath, u as resolveGatewayPort } from "./paths-ViKUYWUK.js"; import "./tmp-openclaw-dir-idKIOMmb.js"; import { r as theme } from "./theme-CdOoMzRk.js"; import "./globals-DBUMOBZ8.js"; import { m as defaultRuntime } from "./subsystem-DISldKSB.js"; import "./ansi-BEJF8NKS.js"; import "./boolean-C3GkJetE.js"; import "./env-Dnra1IpT.js"; import "./warning-filter-CBhOcgHd.js"; import { _ as resolveHomeDir } from "./utils-CS0Ikux6.js"; import { t as formatDocsLink } from "./links-8xRhWBQL.js"; import "./paths-C4Oy7wjk.js"; import "./auth-profiles-DRuJBw5y.js"; import "./agent-scope-bjWqU22i.js"; import "./boundary-path-Dm0QJ7-y.js"; import "./boundary-file-read-DcZxlWD8.js"; import "./logger-BmpSCz93.js"; import { n as runCommandWithTimeout } from "./exec-B5_AYfQG.js"; import "./workspace-D4K6QX9X.js"; import "./model-selection-BnFtDmP7.js"; import { d as readConfigFileSnapshot, s as loadConfig } from "./io-y3Az_Onx.js"; import "./shell-env-BOu7XeT_.js"; import "./safe-text-yavot2qw.js"; import "./version-CD3oP1-d.js"; import "./env-substitution-O6uabUmO.js"; import "./includes-Bj3eLUWH.js"; import "./zod-schema.providers-core-COy5nBQ0.js"; import "./legacy-web-search-BB-ZHEhz.js"; import "./registry-C5UkPpaO.js"; import "./config-state-Br0ucqMb.js"; import "./min-host-version-RMBWtIAR.js"; import "./manifest-registry-B5JNQdOM.js"; import "./runtime-guard-PhQ6PwQa.js"; import "./avatar-policy-B5nOfso_.js"; import "./ip-Ce8EDTBZ.js"; import "./zod-schema.agent-runtime-Dtg4Jy6G.js"; import "./zod-schema.core-BuVz8Rk7.js"; import "./config-D4zN4BRl.js"; import "./file-lock-DEiVq2ow.js"; import "./audit-fs-DTQIjp2r.js"; import "./resolve-B7S4PlnO.js"; import "./profiles-COPO-hHI.js"; import { t as formatCliCommand } from "./command-format-DBQUhADm.js"; import "./daemon-install-plan.shared-DlNoT_tA.js"; import "./runtime-paths-DOEOEFe-.js"; import "./gateway-install-token-De_pFluK.js"; import "./tailscale-CxY-91GZ.js"; import "./tailnet-DHiKSG7V.js"; import "./net-JAg9zL0G.js"; import "./auth-Buq0Niri.js"; import { d as readGatewayTokenEnv } from "./credentials-D8pfRimu.js"; import "./message-channel-BliByQBl.js"; import "./store-C5UK26Ce.js"; import "./runtime-Iz8uZ7EU.js"; import "./plugins-B09-vgme.js"; import "./sessions-D9ZgHCHb.js"; import "./paths-rhN9LKM_.js"; import "./session-write-lock-va3qZE6f.js"; import "./method-scopes-BiEi0X2g.js"; import "./call-CQbSO4Fr.js"; import "./control-ui-shared-BBhZvISc.js"; import { d as openUrl, g as resolveControlUiLinks, i as detectBrowserOpenSupport, o as formatControlUiSshHint } from "./onboard-helpers-D5cfC-Ra.js"; import { n as stylePromptMessage, r as stylePromptTitle, t as stylePromptHint } from "./prompt-style-C4CV4Y_p.js"; import "./ports-lsof-BLEgL_Gn.js"; import "./restart-stale-pids-BsPvlGJd.js"; import "./runtime-parse-BUn1nl6s.js"; import "./launchd-yOx8f787.js"; import { n as resolveGatewayService } from "./service-DdJ2Qk7P.js"; import "./ports-FldL_Lhq.js"; import "./systemd-bGhJCG6J.js"; import "./systemd-hints-DvBn5bxv.js"; import "./logging-CznuqaMu.js"; import "./commands-C6oAw_H-.js"; import "./issue-format-BtLIwOtN.js"; import "./diagnostics-CwDNepDU.js"; import "./inspect-CWK9qVB8.js"; import "./progress-C78aA91n.js"; import "./identity-Dp-UIak4.js"; import "./heartbeat-Bdfr_onc.js"; import "./pi-embedded-CbCYZxIb.js"; import "./internal-hooks-CIUghoK4.js"; import "./multimodal-B8yEZcl5.js"; import "./memory-search-B_aq08y5.js"; import "./provider-catalog-rVN7ZbR5.js"; import "./secret-input-DXoOLNgb.js"; import "./bindings-CFudGB9Z.js"; import "./resolve-route-DwFWP4JW.js"; import "./routing-zOQ0wwtV.js"; import "./identity-file-DVLib087.js"; import "./outbound-runtime-m-y0nd6F.js"; import "./provider-env-vars-CpUJqT5v.js"; import "./provider-auth-input-Bus9W_qh.js"; import "./provider-model-minimax-DSmX4BNO.js"; import "./provider-models-BKjzpTsb.js"; import "./anthropic-vertex-provider-B2x4YywE.js"; import "./provider-catalog-BTgF8VyO.js"; import "./provider-catalog-D0IlX18O.js"; import "./provider-catalog-BTmUX0Mp.js"; import "./provider-catalog-sph_Rl63.js"; import "./provider-catalog-C7tUyBwV.js"; import "./provider-catalog-C8dPZpHW.js"; import "./provider-catalog-BJNff1VI.js"; import "./provider-catalog-IAdymoqT.js"; import "./provider-catalog-Bjc7evzh.js"; import "./models-config.providers.discovery-CjkO08q6.js"; import "./text-runtime-DVXt5xhi.js"; import "./tool-catalog-BjSY4C4F.js"; import "./docker-Bhjg8g2t.js"; import "./sandbox-DTlKNieF.js"; import "./common-zReYuoMM.js"; import "./image-ops-By4YfyWa.js"; import "./thinking-CJoSRIGR.js"; import "./path-alias-guards-CwRM04O1.js"; import "./sandbox-paths-Cn8i8Jxm.js"; import "./channel-actions-fV93bLjV.js"; import "./mime-CsUtzcn2.js"; import "./ssrf-0bPJMoZR.js"; import "./fetch-guard-CYl1q2XH.js"; import "./provider-web-search-COZNygbd.js"; import "./manager-Bw8JrihM.js"; import "./config-schema-CPzP2Ds6.js"; import "./channel-plugin-common-ClptUZHU.js"; import "./status-helpers-Cflmo90d.js"; import "./conversation-runtime-nmWgJSXS.js"; import "./runtime-whatsapp-boundary-XjdkYMz_.js"; import "./pairing-store-BGKLrjo6.js"; import "./json-store--JDX3zNL.js"; import "./secret-file-Bif7RlZ-.js"; import "./channel-config-schema-CgpS17zB.js"; import "./setup-binary-C2MYZTCc.js"; import "./archive-pOxyr9r4.js"; import "./fs-safe-DZyOgpPN.js"; import "./signal-cli-install-fVOL9FvX.js"; import "./setup-wizard-proxy-DoOpOF8S.js"; import "./setup-BI3ohdrT.js"; import "./dm-policy-shared-DtcQProI.js"; import "./runtime-env-DQOYrXVl.js"; import "./temp-path-B91lt0LF.js"; import "./diagnostic-CDTtMQBT.js"; import "./logging-CCTKg_fh.js"; import "./config-runtime-BYNizC50.js"; import "./level-overrides-DzIzQ3ZY.js"; import "./exec-approvals-BF_Qfdq8.js"; import "./webhook-ingress-D-H5frou.js"; import "./system-events-BU_NYynX.js"; import "./ssrf-policy-DYINyIKC.js"; import "./hook-runtime-BUYmDbaA.js"; import "./templating-BDXRiJUh.js"; import "./channel-reply-pipeline-BxH4-AP2.js"; import "./reply-history-n7nOPLta.js"; import "./commands-registry.data-BFXJWoqi.js"; import "./commands-registry-Bh9pJ817.js"; import "./frontmatter-CP5371Rm.js"; import "./env-overrides-BNSo89u5.js"; import "./skills-M0AZJeXx.js"; import "./skills-remote-BHxDA4Jw.js"; import "./workspace-dirs-DqDLiRvZ.js"; import "./pairing-token-DAszGmwD.js"; import "./skill-commands-D73dGR_l.js"; import "./config-CLRQPUSt.js"; import { at as resolveConfiguredSecretInputWithFallback } from "./routes-XT2JfvT-.js"; import "./ssh-tunnel-LM52qY6N.js"; import "./server-middleware-BP59C6FL.js"; import "./provider-auth-ref-CQEp9sp3.js"; import "./provider-auth-helpers-Do3RFvdi.js"; import "./provider-api-key-auth-BEeRW3dq.js"; import "./pairing-labels-D27Y4Vv6.js"; import "./directory-runtime-D9Y42mW-.js"; import "./read-only-account-inspect-CJPRBFj7.js"; import "./src-BoNU6eQs.js"; import "./web-media-PKy3RbRG.js"; import "./media-understanding-BDOSvuM9.js"; import "./web-media-CiSbdGPs.js"; import "./state-paths-Dvb3Mfl3.js"; import "./llm-task-Br6Ixjlh.js"; import "./pi-model-discovery-DO3tFksS.js"; import "./exec-inline-eval-CpmxWJsW.js"; import "./target-registry-9OUOvlxj.js"; import "./external-content-DZI9vlJn.js"; import "./brave-onFD06fq.js"; import "./duckduckgo-CZuAOfiQ.js"; import "./exa-5bwgY04k.js"; import "./security-runtime-xlw0Fxx2.js"; import "./provider-usage-ClxTGn5c.js"; import "./provider-models-Bjv0V4OP.js"; import "./media-understanding-provider-DllGbg-v.js"; import "./media-understanding-provider-BDq4rFL-.js"; import "./provider-onboard-CSnPvkMM.js"; import "./onboard-BU8aRvq7.js"; import "./perplexity-web-search-provider-CI38RNUU.js"; import "./perplexity-CMZbsreI.js"; import "./model-definitions-CLagLj0g.js"; import "./onboard-0P7GBI2D.js"; import "./provider-catalog-CKHo9CRM.js"; import "./provider-models-Dmjtw6kn.js"; import "./stream-C-KGzzT0.js"; import "./web-search-CO1hvu_l.js"; import "./stagger-CFqdtCYL.js"; import "./command-secret-targets-DLs8jC2H.js"; import "./delivery-queue-DHURMSqX.js"; import "./channel-summary-Ctrv7moa.js"; import "./follow-redirects-CVAaqIk4.js"; import "./tool-policy-match-DQWWRSN4.js"; import "./runtime-CAdCdG-M.js"; import "./channel-status-BfM90KqH.js"; import "./discord-core-DLbIyXWy.js"; import "./cli-runtime-Cx1v7N7v.js"; import "./config-presence-DA3j8Nmi.js"; import "./query-expansion-BOJBTXsp.js"; import "./search-manager-DNBHwaee.js"; import "./acp-runtime-BHZj-SLU.js"; import "./telegram-core-DD8gCuaX.js"; import "./audit-BI48Fi3j.js"; import "./gateway-runtime-Dn2qAGY7.js"; import "./connection-auth-Nl2a3tDb.js"; import "./mcp-config-CDIWSqVk.js"; import "./run-command-DPUsJhO7.js"; import "./channel-setup-C5JbULY6.js"; import "./ssrf-runtime-BT3ekdqD.js"; import { a as removePath, i as listAgentSessionDirs, o as removeStateAndLinkedPaths, r as buildCleanupPlan, s as removeWorkspaceDirs } from "./backup-create-BuxXJpr7.js"; import "./matrix-wu3iTLk7.js"; import "./helper-api-CFToxS1G.js"; import "./setup-group-access-BIiwXi_V.js"; import "./runtime-api-C0mTuF54.js"; import "./matrix-migration-snapshot-DTfN6Lm9.js"; import "./skills-status-BhDjqqQc.js"; import "./status-DI5hmNdJ.js"; import "./auth-health-MPTaawEO.js"; import { n as runCommandWithRuntime } from "./cli-utils-C5ijQCJ_.js"; import "./note-Cq-EkeJ6.js"; import "./completion-cli-CiWodvo_.js"; import "./register.subclis-DWT5Gugx.js"; import "./command-registry-D51hzEl_.js"; import "./program-context-wCWmc15y.js"; import "./heartbeat-summary-B-oiNNxm.js"; import "./health-CSjz5K7z.js"; import "./control-ui-assets-DBgPQZLL.js"; import "./server-startup-matrix-migration-DR8lh8kT.js"; import "./update-check-PKXwMGZy.js"; import "./channels-status-issues-DweHoyQa.js"; import "./provider-auth-guidance-BLTUrTMo.js"; import "./systemd-linger-CPlvYre1.js"; import "./health-format-7GPO1PzB.js"; import { n as doctorCommand, t as selectStyled } from "./prompt-select-styled-DhgZI13f.js"; import "./doctor-completion-Crwr0k76.js"; import "./doctor-config-preflight-LCtZbUGU.js"; import "./channel-account-context-B1QSXfoG.js"; import "./doctor-state-migrations-EWrVSdyy.js"; import "./provider-openai-codex-oauth-tls-D-P88CMr.js"; import path from "node:path"; import { cancel, confirm, isCancel, multiselect } from "@clack/prompts"; //#region src/infra/clipboard.ts async function copyToClipboard(value) { for (const attempt of [ { argv: ["pbcopy"] }, { argv: [ "xclip", "-selection", "clipboard" ] }, { argv: ["wl-copy"] }, { argv: ["clip.exe"] }, { argv: [ "powershell", "-NoProfile", "-Command", "Set-Clipboard" ] } ]) try { const result = await runCommandWithTimeout(attempt.argv, { timeoutMs: 3e3, input: value }); if (result.code === 0 && !result.killed) return true; } catch {} return false; } //#endregion //#region src/commands/dashboard.ts async function resolveDashboardToken(cfg, env = process.env) { const resolved = await resolveConfiguredSecretInputWithFallback({ config: cfg, env, value: cfg.gateway?.auth?.token, path: "gateway.auth.token", readFallback: () => readGatewayTokenEnv(env) }); return { token: resolved.value, source: resolved.source === "config" ? "config" : resolved.source === "secretRef" ? "secretRef" : resolved.source === "fallback" ? "env" : void 0, unresolvedRefReason: resolved.unresolvedRefReason, tokenSecretRefConfigured: resolved.secretRefConfigured }; } async function dashboardCommand(runtime = defaultRuntime, options = {}) { const snapshot = await readConfigFileSnapshot(); const cfg = snapshot.valid ? snapshot.config : {}; const port = resolveGatewayPort(cfg); const bind = cfg.gateway?.bind ?? "loopback"; const basePath = cfg.gateway?.controlUi?.basePath; const customBindHost = cfg.gateway?.customBindHost; const resolvedToken = await resolveDashboardToken(cfg, process.env); const token = resolvedToken.token ?? ""; const links = resolveControlUiLinks({ port, bind: bind === "lan" ? "loopback" : bind, customBindHost, basePath }); const includeTokenInUrl = token.length > 0 && !resolvedToken.tokenSecretRefConfigured; const dashboardUrl = includeTokenInUrl ? `${links.httpUrl}#token=${encodeURIComponent(token)}` : links.httpUrl; runtime.log(`Dashboard URL: ${dashboardUrl}`); if (resolvedToken.tokenSecretRefConfigured && token) runtime.log("Token auto-auth is disabled for SecretRef-managed gateway.auth.token; use your external token source if prompted."); if (resolvedToken.unresolvedRefReason) { runtime.log(`Token auto-auth unavailable: ${resolvedToken.unresolvedRefReason}`); runtime.log("Set OPENCLAW_GATEWAY_TOKEN in this shell or resolve your secret provider, then rerun `openclaw dashboard`."); } const copied = await copyToClipboard(dashboardUrl).catch(() => false); runtime.log(copied ? "Copied to clipboard." : "Copy to clipboard unavailable."); let opened = false; let hint; if (!options.noOpen) { if ((await detectBrowserOpenSupport()).ok) opened = await openUrl(dashboardUrl); if (!opened) hint = formatControlUiSshHint({ port, basePath, token: includeTokenInUrl ? token || void 0 : void 0 }); } else hint = "Browser launch disabled (--no-open). Use the URL above."; if (opened) runtime.log("Opened in your browser. Keep that tab to control OpenClaw."); else if (hint) runtime.log(hint); } //#endregion //#region src/commands/cleanup-plan.ts function resolveCleanupPlanFromDisk() { const cfg = loadConfig(); const stateDir = resolveStateDir(); const configPath = resolveConfigPath(); const oauthDir = resolveOAuthDir(); return { cfg, stateDir, configPath, oauthDir, ...buildCleanupPlan({ cfg, stateDir, configPath, oauthDir }) }; } //#endregion //#region src/commands/reset.ts async function stopGatewayIfRunning(runtime) { if (isNixMode) return; const service = resolveGatewayService(); let loaded = false; try { loaded = await service.isLoaded({ env: process.env }); } catch (err) { runtime.error(`Gateway service check failed: ${String(err)}`); return; } if (!loaded) return; try { await service.stop({ env: process.env, stdout: process.stdout }); } catch (err) { runtime.error(`Gateway stop failed: ${String(err)}`); } } function logBackupRecommendation$1(runtime) { runtime.log(`Recommended first: ${formatCliCommand("openclaw backup create")}`); } async function resetCommand(runtime, opts) { const interactive = !opts.nonInteractive; if (!interactive && !opts.yes) { runtime.error("Non-interactive mode requires --yes."); runtime.exit(1); return; } let scope = opts.scope; if (!scope) { if (!interactive) { runtime.error("Non-interactive mode requires --scope."); runtime.exit(1); return; } const selection = await selectStyled({ message: "Reset scope", options: [ { value: "config", label: "Config only", hint: "openclaw.json" }, { value: "config+creds+sessions", label: "Config + credentials + sessions", hint: "keeps workspace + auth profiles" }, { value: "full", label: "Full reset", hint: "state dir + workspace" } ], initialValue: "config+creds+sessions" }); if (isCancel(selection)) { cancel(stylePromptTitle("Reset cancelled.") ?? "Reset cancelled."); runtime.exit(0); return; } scope = selection; } if (![ "config", "config+creds+sessions", "full" ].includes(scope)) { runtime.error("Invalid --scope. Expected \"config\", \"config+creds+sessions\", or \"full\"."); runtime.exit(1); return; } if (interactive && !opts.yes) { const ok = await confirm({ message: stylePromptMessage(`Proceed with ${scope} reset?`) }); if (isCancel(ok) || !ok) { cancel(stylePromptTitle("Reset cancelled.") ?? "Reset cancelled."); runtime.exit(0); return; } } const dryRun = Boolean(opts.dryRun); const { stateDir, configPath, oauthDir, configInsideState, oauthInsideState, workspaceDirs } = resolveCleanupPlanFromDisk(); if (scope !== "config") { logBackupRecommendation$1(runtime); if (dryRun) runtime.log("[dry-run] stop gateway service"); else await stopGatewayIfRunning(runtime); } if (scope === "config") { await removePath(configPath, runtime, { dryRun, label: configPath }); return; } if (scope === "config+creds+sessions") { await removePath(configPath, runtime, { dryRun, label: configPath }); await removePath(oauthDir, runtime, { dryRun, label: oauthDir }); const sessionDirs = await listAgentSessionDirs(stateDir); for (const dir of sessionDirs) await removePath(dir, runtime, { dryRun, label: dir }); runtime.log(`Next: ${formatCliCommand("openclaw onboard --install-daemon")}`); return; } if (scope === "full") { await removeStateAndLinkedPaths({ stateDir, configPath, oauthDir, configInsideState, oauthInsideState }, runtime, { dryRun }); await removeWorkspaceDirs(workspaceDirs, runtime, { dryRun }); runtime.log(`Next: ${formatCliCommand("openclaw onboard --install-daemon")}`); return; } } //#endregion //#region src/commands/uninstall.ts const multiselectStyled = (params) => multiselect({ ...params, message: stylePromptMessage(params.message), options: params.options.map((opt) => opt.hint === void 0 ? opt : { ...opt, hint: stylePromptHint(opt.hint) }) }); function buildScopeSelection(opts) { const hadExplicit = Boolean(opts.all || opts.service || opts.state || opts.workspace || opts.app); const scopes = /* @__PURE__ */ new Set(); if (opts.all || opts.service) scopes.add("service"); if (opts.all || opts.state) scopes.add("state"); if (opts.all || opts.workspace) scopes.add("workspace"); if (opts.all || opts.app) scopes.add("app"); return { scopes, hadExplicit }; } async function stopAndUninstallService(runtime) { if (isNixMode) { runtime.error("Nix mode detected; service uninstall is disabled."); return false; } const service = resolveGatewayService(); let loaded = false; try { loaded = await service.isLoaded({ env: process.env }); } catch (err) { runtime.error(`Gateway service check failed: ${String(err)}`); return false; } if (!loaded) { runtime.log(`Gateway service ${service.notLoadedText}.`); return true; } try { await service.stop({ env: process.env, stdout: process.stdout }); } catch (err) { runtime.error(`Gateway stop failed: ${String(err)}`); } try { await service.uninstall({ env: process.env, stdout: process.stdout }); return true; } catch (err) { runtime.error(`Gateway uninstall failed: ${String(err)}`); return false; } } async function removeMacApp(runtime, dryRun) { if (process.platform !== "darwin") return; await removePath("/Applications/OpenClaw.app", runtime, { dryRun, label: "/Applications/OpenClaw.app" }); } function logBackupRecommendation(runtime) { runtime.log(`Recommended first: ${formatCliCommand("openclaw backup create")}`); } async function uninstallCommand(runtime, opts) { const { scopes, hadExplicit } = buildScopeSelection(opts); const interactive = !opts.nonInteractive; if (!interactive && !opts.yes) { runtime.error("Non-interactive mode requires --yes."); runtime.exit(1); return; } if (!hadExplicit) { if (!interactive) { runtime.error("Non-interactive mode requires explicit scopes (use --all)."); runtime.exit(1); return; } const selection = await multiselectStyled({ message: "Uninstall which components?", options: [ { value: "service", label: "Gateway service", hint: "launchd / systemd / schtasks" }, { value: "state", label: "State + config", hint: "~/.openclaw" }, { value: "workspace", label: "Workspace", hint: "agent files" }, { value: "app", label: "macOS app", hint: "/Applications/OpenClaw.app" } ], initialValues: [ "service", "state", "workspace" ] }); if (isCancel(selection)) { cancel(stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled."); runtime.exit(0); return; } for (const value of selection) scopes.add(value); } if (scopes.size === 0) { runtime.log("Nothing selected."); return; } if (interactive && !opts.yes) { const ok = await confirm({ message: stylePromptMessage("Proceed with uninstall?") }); if (isCancel(ok) || !ok) { cancel(stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled."); runtime.exit(0); return; } } const dryRun = Boolean(opts.dryRun); const { stateDir, configPath, oauthDir, configInsideState, oauthInsideState, workspaceDirs } = resolveCleanupPlanFromDisk(); if (scopes.has("state") || scopes.has("workspace")) logBackupRecommendation(runtime); if (scopes.has("service")) if (dryRun) runtime.log("[dry-run] remove gateway service"); else await stopAndUninstallService(runtime); if (scopes.has("state")) await removeStateAndLinkedPaths({ stateDir, configPath, oauthDir, configInsideState, oauthInsideState }, runtime, { dryRun }); if (scopes.has("workspace")) await removeWorkspaceDirs(workspaceDirs, runtime, { dryRun }); if (scopes.has("app")) await removeMacApp(runtime, dryRun); runtime.log("CLI still installed. Remove via npm/pnpm if desired."); if (scopes.has("state") && !scopes.has("workspace")) { const home = resolveHomeDir(); if (home && workspaceDirs.some((dir) => dir.startsWith(path.resolve(home)))) runtime.log("Tip: workspaces were preserved. Re-run with --workspace to remove them."); } } //#endregion //#region src/cli/program/register.maintenance.ts function registerMaintenanceCommands(program) { program.command("doctor").description("Health checks + quick fixes for the gateway and channels").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/doctor", "docs.openclaw.ai/cli/doctor")}\n`).option("--no-workspace-suggestions", "Disable workspace memory system suggestions", false).option("--yes", "Accept defaults without prompting", false).option("--repair", "Apply recommended repairs without prompting", false).option("--fix", "Apply recommended repairs (alias for --repair)", false).option("--force", "Apply aggressive repairs (overwrites custom service config)", false).option("--non-interactive", "Run without prompts (safe migrations only)", false).option("--generate-gateway-token", "Generate and configure a gateway token", false).option("--deep", "Scan system services for extra gateway installs", false).action(async (opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await doctorCommand(defaultRuntime, { workspaceSuggestions: opts.workspaceSuggestions, yes: Boolean(opts.yes), repair: Boolean(opts.repair) || Boolean(opts.fix), force: Boolean(opts.force), nonInteractive: Boolean(opts.nonInteractive), generateGatewayToken: Boolean(opts.generateGatewayToken), deep: Boolean(opts.deep) }); defaultRuntime.exit(0); }); }); program.command("dashboard").description("Open the Control UI with your current token").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/dashboard", "docs.openclaw.ai/cli/dashboard")}\n`).option("--no-open", "Print URL but do not launch a browser").action(async (opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await dashboardCommand(defaultRuntime, { noOpen: opts.open === false }); }); }); program.command("reset").description("Reset local config/state (keeps the CLI installed)").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/reset", "docs.openclaw.ai/cli/reset")}\n`).option("--scope <scope>", "config|config+creds+sessions|full (default: interactive prompt)").option("--yes", "Skip confirmation prompts", false).option("--non-interactive", "Disable prompts (requires --scope + --yes)", false).option("--dry-run", "Print actions without removing files", false).action(async (opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await resetCommand(defaultRuntime, { scope: opts.scope, yes: Boolean(opts.yes), nonInteractive: Boolean(opts.nonInteractive), dryRun: Boolean(opts.dryRun) }); }); }); program.command("uninstall").description("Uninstall the gateway service + local data (CLI remains)").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/uninstall", "docs.openclaw.ai/cli/uninstall")}\n`).option("--service", "Remove the gateway service", false).option("--state", "Remove state + config", false).option("--workspace", "Remove workspace dirs", false).option("--app", "Remove the macOS app", false).option("--all", "Remove service + state + workspace + app", false).option("--yes", "Skip confirmation prompts", false).option("--non-interactive", "Disable prompts (requires --yes)", false).option("--dry-run", "Print actions without removing files", false).action(async (opts) => { await runCommandWithRuntime(defaultRuntime, async () => { await uninstallCommand(defaultRuntime, { service: Boolean(opts.service), state: Boolean(opts.state), workspace: Boolean(opts.workspace), app: Boolean(opts.app), all: Boolean(opts.all), yes: Boolean(opts.yes), nonInteractive: Boolean(opts.nonInteractive), dryRun: Boolean(opts.dryRun) }); }); }); } //#endregion export { registerMaintenanceCommands };