openclaw/src/cli/route.ts
kumarabhirup e4c94cc012
Merge upstream openclaw/main into ironclaw
Resolve 17 merge conflicts preserving ironclaw branding while
incorporating all upstream bug fixes and feature updates:

- Keep ironclaw name, CLI branding, and custom web app bundling
- Take upstream's new gateway auth token auto-generation
- Take upstream's shouldSkipRespawnForArgv respawn guard
- Take upstream's refactored skills frontmatter (resolveOpenClawManifestBlock)
- Merge upstream's ~/.agents/skills path + ironclaw's bundled skills watcher
- Take upstream's new GatewayToolsConfig alongside ironclaw's GatewayWebAppConfig
- Take upstream's minimalTestGateway guard in server.impl.ts
- Take upstream's refactored fs-mocked tests with ironclaw variants
- Take upstream's system message + subagent polling guidance tests
- Take upstream's dynamic import pattern in onboarding wizard
- Fix extensions/feishu workspace reference (openclaw -> ironclaw)
- Regenerate pnpm-lock.yaml with updated dependencies

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-15 15:17:52 -08:00

41 lines
1.2 KiB
TypeScript

import { isTruthyEnvValue } from "../infra/env.js";
import { defaultRuntime } from "../runtime.js";
import { VERSION } from "../version.js";
import { getCommandPath, hasHelpOrVersion } from "./argv.js";
import { emitCliBanner } from "./banner.js";
import { ensurePluginRegistryLoaded } from "./plugin-registry.js";
import { ensureConfigReady } from "./program/config-guard.js";
import { findRoutedCommand } from "./program/routes.js";
async function prepareRoutedCommand(params: {
argv: string[];
commandPath: string[];
loadPlugins?: boolean;
}) {
await emitCliBanner(VERSION, { argv: params.argv });
await ensureConfigReady({ runtime: defaultRuntime, commandPath: params.commandPath });
if (params.loadPlugins) {
ensurePluginRegistryLoaded();
}
}
export async function tryRouteCli(argv: string[]): Promise<boolean> {
if (isTruthyEnvValue(process.env.OPENCLAW_DISABLE_ROUTE_FIRST)) {
return false;
}
if (hasHelpOrVersion(argv)) {
return false;
}
const path = getCommandPath(argv, 2);
if (!path[0]) {
return false;
}
const route = findRoutedCommand(path);
if (!route) {
return false;
}
await prepareRoutedCommand({ argv, commandPath: path, loadPlugins: route.loadPlugins });
return route.run(argv);
}