jackwener/OpenCLI · error · ArgumentError
unknown mode "${name}". Known: ${Object.keys(MODES).join(',
Error message
unknown mode "${name}". Known: ${Object.keys(MODES).join(', ')} What it means
The kimi mode-switch command looks up the requested mode name in the MODES registry (clis/kimi/ui.js). If the name is not a key of MODES, it throws ArgumentError naming the argument and listing valid modes. This is a fail-fast input validation guard so the driver never navigates to an undefined Kimi route.
Source
Thrown at clis/kimi/ui.js:58
browser: true,
siteSession: 'persistent',
navigateBefore: false,
args: [
{ name: 'name', positional: true, required: false, help: 'Mode name (omit to list all)' },
],
columns: UI_COLUMNS,
func: async (page, kwargs) => {
const name = String(kwargs?.name || '').trim().toLowerCase();
if (!name) {
return Object.entries(MODES).map(([m, url]) => ({
Mode: m,
Status: 'available',
Url: KIMI_URL + url.slice(1),
}));
}
const target = MODES[name];
if (!target) {
throw new ArgumentError('name', `unknown mode "${name}". Known: ${Object.keys(MODES).join(', ')}`);
}
await ensureOnKimi(page);
await page.goto(`${KIMI_URL}${target.slice(1)}`);
await page.wait(1);
const url = await page.evaluate('window.location.href');
return [{ Mode: name, Status: 'navigated', Url: String(url || '') }];
},
});
// -------- sidebar-toggle --------
cli({
site: 'kimi',
name: 'sidebar-toggle',
access: 'write',
description: 'Click the LeftBar svg to toggle the Kimi sidebar.',
domain: KIMI_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,View on GitHub (pinned to 49907e53dc)
Solutions
- Run the command without a mode (or list modes) to see the valid names printed in the error's Known: list.
- Correct the mode name to one of the exact keys in MODES (match spelling and casing).
- Validate the mode against Object.keys(MODES) before calling the command in automation scripts.
- Update the library if the mode was recently added and your installed version predates it.
Example fix
// before
await run('kimi', 'mode', { name: 'chat-history' });
// after
await run('kimi', 'mode', { name: 'history' }); // a key that exists in MODES Defensive patterns
Strategy: validation
Validate before calling
const MODES = ['chat','history' /* per Known: list */];
if (!MODES.includes(name)) throw new Error(`invalid mode: ${name}`);
await run('kimi', 'mode', { name }); Type guard
const isValidMode = (n) => typeof n === 'string' && MODES.includes(n);
Try / catch
try {
await run('kimi', 'mode', { name });
} catch (e) {
if (/unknown mode/.test(e.message)) {
const known = e.message.match(/Known: (.*)/)?.[1].split(', ');
console.error(`Pick a mode from: ${known.join(', ')}`);
} else throw e;
} Prevention
- Keep a shared constant of valid mode names imported by all automation scripts.
- Echo the Known: list from the error message when building interactive pickers.
- Add a unit test asserting every mode literal used in scripts exists in MODES.
When it happens
Trigger: Calling the kimi mode command with a name that is not a key of MODES, e.g. a typo, different casing, or a mode from another site's CLI ('kimi', mode='history-all' instead of the registered key).
Common situations: Typo in mode name; using a mode name copied from another CLI site module; casing mismatch ('Chat' vs 'chat'); renaming of MODES keys after a library update while scripts still pass the old literal.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/12f62fcabe76b927.
Report an issue: GitHub.