feat(littleblue): blue tool registry (list/propose action via local API) + run_turn extraEnv

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-04 21:42:27 +10:00
parent 3aa8dc578b
commit ff681847ed
5 changed files with 67 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { listActionsTool, proposeActionTool } from '../../../../lib/ai/agent/tools/blue/actions.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');
});
});