interplane-mv
INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.
Brought by drakestapleton
interplane-mv / tests / hardware / fixtures.mjs
| 1 | import fs from 'node:fs'; |
| 2 | import {createHash} from 'node:crypto'; |
| 3 | const root=new URL('../../',import.meta.url).pathname; |
| 4 | const catalog = JSON.parse(fs.readFileSync(root+'omega/hardware/catalog.json')); |
| 5 | const canonical = v => v === null || typeof v !== 'object' ? JSON.stringify(v) : Array.isArray(v) ? '['+v.map(canonical).join(',')+']' : '{'+Object.keys(v).sort().map(k=>JSON.stringify(k)+':'+canonical(v[k])).join(',')+'}'; |
| 6 | const schemaDigest = v => 'sha256:'+createHash('sha256').update(canonical(v)).digest('hex'); |
| 7 | const pairs=catalog.capabilities.map(c=>[c.name,schemaDigest(c.parameters)]).sort((a,b)=>a[0].localeCompare(b[0], 'en')); |
| 8 | export const digest = createHash('sha256').update(canonical(pairs)).digest(); |
| 9 | export const names=['cpu.discover','timer.arm','interrupt.bind','dma.map','power.request']; |
| 10 | export function discovery() { |
| 11 | const b=Buffer.alloc(96); b.write('HWD1'); |
| 12 | Buffer.from([1,1,1,0,1,1,1,1,1,3,3,2,1,2]).copy(b,4); |
| 13 | b.writeBigUInt64LE(7n,24); digest.copy(b,32); return b; |
| 14 | } |
| 15 | export function intent(op=1) { |
| 16 | const b=Buffer.alloc(96); b.write('HWI1'); Buffer.from([1,op,1,1,1,0]).copy(b,4); |
| 17 | b.writeUInt32LE(op===3?32:op===5?1:0,12); |
| 18 | b.writeBigUInt64LE(op===2?1n:op===4?4096n:0n,16); |
| 19 | b.writeBigUInt64LE(7n,24); digest.copy(b,32); b.writeBigUInt64LE(1n,64); return b; |
| 20 | } |