mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-18 18:29:35 +08:00
3f9e89d345
Injects credentials as request-time stubs so no credential is ever written into a container or to disk. Gateway and CLI versions move to versions.json (machine-checkable pins); breaking upgrades are documented in docs/onecli-upgrades.md as an agent-executable runbook (detect / why / fix / verify / rollback), and the update flow follows linked docs and diffs the pins. BREAKING: requires a gateway upgrade; the doc carries the steps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
/**
|
|
* The step DETECTS gateway /v1 compatibility and warns (pointing at
|
|
* docs/onecli-upgrades.md) — it does not migrate the gateway; that's the
|
|
* agent's job via /update-nanoclaw. The verify helper must distinguish
|
|
* incompatible (pre-/v1 server: warn) from unreachable (transient: nothing to
|
|
* say) so the warning only fires on a real pre-/v1 server.
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { verifyGatewayV1 } from './onecli.js';
|
|
|
|
function fakeFetch(behavior: 'ok' | '404' | 'down'): typeof fetch {
|
|
return (async () => {
|
|
if (behavior === 'down') throw new Error('ECONNREFUSED');
|
|
return { ok: behavior === 'ok' } as Response;
|
|
}) as unknown as typeof fetch;
|
|
}
|
|
|
|
describe('verifyGatewayV1', () => {
|
|
it('ok when /v1/health answers', async () => {
|
|
expect(await verifyGatewayV1('http://x', fakeFetch('ok'))).toBe('ok');
|
|
});
|
|
it('incompatible when the server answers HTTP without /v1', async () => {
|
|
expect(await verifyGatewayV1('http://x', fakeFetch('404'))).toBe('incompatible');
|
|
});
|
|
it('unreachable on connection failure', async () => {
|
|
expect(await verifyGatewayV1('http://x', fakeFetch('down'))).toBe('unreachable');
|
|
});
|
|
});
|