mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-04 10:14:47 +08:00
1b08b58fcd
- verify: remove the CLI ping; cli-agent step earlier in setup already proved the round-trip works, and the test agent gets cleaned up before verify runs — so the ping was guaranteed to fail on installs that wired a messaging app instead of staying CLI-only. Status now collapses to service-running ∧ credentials ∧ ≥1 wired group. - agent-ping: catch Claude Code's "Please run /login" / "Not logged in" / "Invalid API key" banners so a successfully-spawned agent that has no credentials no longer reports as 'ok'. - auth paste: validate the full sk-ant-oat…AA shape; when the cleaned input is under 90 chars, surface a truncation-specific hint pointing at terminal wrap as the likely cause. Strip internal whitespace at both validate and assignment so multi-line pastes that survive clack also go through cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { classifyPingResult } from './agent-ping.js';
|
|
|
|
describe('classifyPingResult', () => {
|
|
it('treats a normal text reply as ok', () => {
|
|
expect(classifyPingResult(0, 'pong\n')).toBe('ok');
|
|
});
|
|
|
|
it('detects Anthropic auth errors printed as a chat reply', () => {
|
|
expect(
|
|
classifyPingResult(
|
|
0,
|
|
'Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"}}',
|
|
),
|
|
).toBe('auth_error');
|
|
});
|
|
|
|
it('detects auth errors on stderr too', () => {
|
|
expect(classifyPingResult(1, '', 'Authentication error')).toBe('auth_error');
|
|
});
|
|
|
|
it('detects Claude Code login banners printed as a chat reply', () => {
|
|
expect(
|
|
classifyPingResult(0, 'Invalid API key · Please run /login'),
|
|
).toBe('auth_error');
|
|
expect(
|
|
classifyPingResult(0, 'Not logged in · Please run /login'),
|
|
).toBe('auth_error');
|
|
});
|
|
|
|
it('preserves socket errors', () => {
|
|
expect(classifyPingResult(2, '')).toBe('socket_error');
|
|
});
|
|
|
|
it('treats empty output as no reply', () => {
|
|
expect(classifyPingResult(0, '')).toBe('no_reply');
|
|
});
|
|
});
|