import fs from 'node:fs'; import path from 'node:path'; import { createHash } from 'node:crypto'; import { REQUEST_LEDGER_MIGRATION } from '../src/core/storage/request-ledger-schema.mjs'; export function writeDataCompatibility(root) { const describe = name => { const bytes = fs.readFileSync(path.join(root, name)); return { path: name, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') }; }; const declaration = { schemaVersion: 1, application: 'agent-workbench-database', readWriteSchemas: [1, 2], ledgerMigration: REQUEST_LEDGER_MIGRATION, sourceInputs: ['src/core/models/request-ledger.mjs', 'src/core/storage/state-database.mjs', 'src/core/storage/request-ledger-schema.mjs'].map(describe), bundles: ['dist-server/server.mjs', 'dist-server/hot-upgrade.mjs'].map(describe) }; fs.writeFileSync(path.join(root, 'dist-server/data-compatibility.json'), JSON.stringify(declaration, null, 2) + '\n'); return declaration; }