Add automatic agent updates with verified rollback

This commit is contained in:
2026-10-04 10:40:45 -04:00
parent 020894b816
commit 8d1331c67d
26 changed files with 2568 additions and 110 deletions
+15
View File
@@ -0,0 +1,15 @@
import { describe, expect, it } from 'vitest';
import { validateInventory } from '../../src/lib/server/hosts/index.js';
const update = { enabled: true, state: 'updated', currentVersion: '1.2.0', targetVersion: '1.2.0', checkedAt: '2026-10-04T12:00:00Z' };
describe('agent update inventory', () => {
it('accepts legacy inventory and only publishes recognized update display fields', () => {
expect(validateInventory({ protocolVersion: 1 })).toEqual({ protocolVersion: 1 });
expect(validateInventory({ agentUpdate: { ...update, credential: 'private', journal: { backups: 'local-path' } } }).agentUpdate).toEqual(update);
});
it.each([null, [], 'updated', { ...update, enabled: 'yes' }, { ...update, state: '<script>' },
{ ...update, currentVersion: {} }, { ...update, targetVersion: 'invalid' }, { ...update, checkedAt: 'invalid' },
{ ...update, error: {} }, { ...update, error: 'x'.repeat(2001) }])('rejects invalid update metadata %j', agentUpdate => {
expect(() => validateInventory({ agentUpdate })).toThrow('Invalid agent update inventory');
});
});