feat(actions): agent_actions table + repo

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-04 21:39:05 +10:00
parent d500b6fa00
commit 135244cb13
3 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { describe, it, expect, beforeAll } from 'vitest';
import { resetDb } from '../helpers/db.js';
import { migrateUp } from '../../lib/db/migrate.js';
import * as aa from '../../lib/db/repos/agent_actions.js';
const owner = { kind: 'user', id: null };
beforeAll(async () => { await resetDb(); await migrateUp(); });
describe('agent_actions repo', () => {
it('creates pending, lists it, resolves once', async () => {
const row = await aa.create({ action_id: 'stop-ct107', tier: 'risky', params: {}, requested_by: owner });
expect(row.status).toBe('pending');
expect((await aa.listPending()).some(r => r.id === row.id)).toBe(true);
const done = await aa.resolve(row.id, 'executed', { ok: true }, owner);
expect(done.status).toBe('executed');
const again = await aa.resolve(row.id, 'rejected', null, owner); // already resolved
expect(again).toBeUndefined();
});
});