jackwener/OpenCLI · warning · CommandExecutionError
Unexpected Kimi probe: ${JSON.stringify(result)}
Error message
Unexpected Kimi probe: ${JSON.stringify(result)} What it means
After checking auth/http/exception outcomes, verifyKimiIdentity requires the probe result to have `ok:true`. Any other shape (null/undefined result, or an object without ok) triggers a defensive CommandExecutionError embedding the raw probe JSON. This guards against unexpected contract changes in the in-page probe or Kimi's API response.
Source
Thrown at clis/kimi/auth.js:40
const token = ${JSON.stringify(token)};
const res = await fetch('/api/user', { credentials: 'include', headers: { 'Authorization': 'Bearer ' + token, 'Accept': 'application/json' } });
if (res.status === 401 || res.status === 403) {
return { kind: 'auth', detail: 'Kimi /api/user HTTP ' + res.status };
}
if (!res.ok) return { kind: 'http', httpStatus: res.status };
const d = await res.json();
if (!d || !d.id) {
return { kind: 'auth', detail: 'Kimi /api/user returned no id — anonymous' };
}
return { ok: true, user_id: String(d.id), name: String(d.name || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (result?.kind === 'auth') throw new AuthRequiredError('kimi.com', result.detail);
if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/user`);
if (result?.kind === 'exception') throw new CommandExecutionError(`Kimi whoami failed: ${result.detail}`);
if (!result?.ok) throw new CommandExecutionError(`Unexpected Kimi probe: ${JSON.stringify(result)}`);
return { user_id: result.user_id, name: result.name };
}
registerSiteAuthCommands({
site: 'kimi',
domain: 'kimi.com',
loginUrl: 'https://www.kimi.com/',
columns: ['user_id', 'name'],
quickCheck: hasKimiSessionCookie,
verify: verifyKimiIdentity,
poll: async (page) => {
if (!await hasKimiSessionCookie(page)) {
throw new AuthRequiredError('kimi.com', 'Waiting for Kimi auth cookies');
}
return verifyKimiIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the JSON in the message to see the actual probe result shape
- Load kimi.com and inspect /api/user manually to see the new response format
- Update the probe in clis/kimi/auth.js to map the new response shape to {ok:true,user_id,name}
- Re-run the whoami/verify command after fixing the probe
Example fix
// before
if (!result?.ok) throw new CommandExecutionError(`Unexpected Kimi probe: ${JSON.stringify(result)}`);
// after
if (!result) throw new CommandExecutionError('Kimi probe returned no result — check page.evaluate serialization');
if (!result.ok && result.id) return { user_id: String(result.id), name: String(result.name || '') }; // tolerate new shape
if (!result?.ok) throw new CommandExecutionError(`Unexpected Kimi probe: ${JSON.stringify(result)}`); Defensive patterns
Strategy: validation
Validate before calling
const raw = await page.evaluate(`fetch('/api/user').then(r => r.text())`);
let body; try { body = JSON.parse(raw); } catch { body = null; }
if (!body || body.id === undefined) console.warn('Unexpected /api/user shape:', raw.slice(0, 200)); Type guard
function isKimiUserPayload(d) {
return !!d && typeof d === 'object' && (typeof d.id === 'string' || typeof d.id === 'number');
} Try / catch
try {
const user = await kimiWhoami();
} catch (e) {
if (/Unexpected Kimi probe/.test(e.message)) {
console.error('Contract drift — inspect payload:', e.message);
// fall back to manual login check
} else throw e;
} Prevention
- Log the raw probe JSON on failure for diagnosis
- Pin/monitor Kimi API response shape in a smoke test
- Handle both string and numeric id fields in parsing code
When it happens
Trigger: The evaluated probe returns undefined (evaluate failed silently or returned non-serializable value), or returns an object that is neither ok/auth/http/exception — e.g. Kimi /api/user returns a body the probe does not map to ok:true.
Common situations: Kimi changed /api/user response shape (renamed `id`/`name` fields); page.evaluate returned undefined because the async IIFE failed to serialize; an intermediate proxy rewrote the response; a bug after editing the probe script.
Related errors
- HTTP ${result.httpStatus} from /api/user
- Kimi whoami failed: ${result.detail}
- API_ERROR
- API_ERROR
- ${label} returned HTTP ${resp.status}: ${summarizeApiError(p
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8c40fa667d568b9b.
Report an issue: GitHub.