This work (network_hosts inventory + infra_audit MCP tool, /api/cluster + Sacred Valley cluster card, topbar cluster-health pill + SW self-heal) was built in an earlier session and DEPLOYED to CT 311 as alpha.24–26, but was never committed to git — prod was running code absent from the repo. Commits it as-is (already prod-validated) so git matches the live state, and restores its alpha.24/25/26 CHANGELOG entries. Files are disjoint from the fold-in work; both now ship together under alpha.27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.9 KiB
JavaScript
33 lines
1.9 KiB
JavaScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { listActionsTool, proposeActionTool } from '../../../../lib/ai/agent/tools/blue/actions.js';
|
|
import { infraAuditTool } from '../../../../lib/ai/agent/tools/blue/infra_audit.js';
|
|
|
|
beforeEach(() => { process.env.VOID_API_URL = 'http://127.0.0.1:3000'; process.env.VOID_AGENT_TOKEN = 'blue-tok'; });
|
|
|
|
describe('blue action tools', () => {
|
|
it('list_actions GETs the whitelist with the agent bearer', async () => {
|
|
const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ actions: [{ id: 'restart-caddy-ct100', tier: 'safe' }] }) }));
|
|
const out = await listActionsTool.handler({}, {}, { fetchImpl: fetchMock });
|
|
expect(out.actions[0].id).toBe('restart-caddy-ct100');
|
|
const [url, opts] = fetchMock.mock.calls[0];
|
|
expect(url).toBe('http://127.0.0.1:3000/api/actions');
|
|
expect(opts.headers.Authorization).toBe('Bearer blue-tok');
|
|
});
|
|
it('propose_action POSTs run and returns the queued/executed result', async () => {
|
|
const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ queued: true, action_row_id: 'r1' }) }));
|
|
const out = await proposeActionTool.handler({ action_id: 'stop-ct107' }, {}, { fetchImpl: fetchMock });
|
|
expect(out.queued).toBe(true);
|
|
expect(fetchMock.mock.calls[0][0]).toBe('http://127.0.0.1:3000/api/actions/stop-ct107/run');
|
|
expect(fetchMock.mock.calls[0][1].method).toBe('POST');
|
|
});
|
|
|
|
it('infra_audit GETs the read-only audit with the agent bearer', async () => {
|
|
const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ ok: false, docs: { summary: { unreachable: 1 } } }) }));
|
|
const out = await infraAuditTool.handler({}, {}, { fetchImpl: fetchMock });
|
|
expect(out.ok).toBe(false);
|
|
const [url, opts] = fetchMock.mock.calls[0];
|
|
expect(url).toBe('http://127.0.0.1:3000/api/infra/audit');
|
|
expect(opts.headers.Authorization).toBe('Bearer blue-tok');
|
|
});
|
|
});
|