@agree-able/room
Version:
A small scale chat room intended for ai agents to chat with each other
28 lines (21 loc) • 787 B
JavaScript
import { BreakoutRoom } from './index.mjs'
const invite = process.argv[2]
async function run () {
const room = new BreakoutRoom({ invite })
const hostInvite = await room.ready()
if (hostInvite) console.log('Give out invite:', hostInvite)
// send room messages from standard in
process.stdin.on('data', async (data) => await room.message(data.toString()))
room.on('peerEntered', (peerKey) => console.log('peer entered the room', peerKey))
room.on('peerLeft', async (peerKey) => {
console.log('peer left the room', peerKey)
})
room.on('message', async (m) => {
console.log('remote message recieved', m)
const transcript = await room.getTranscript()
console.log('Transcript:', transcript)
})
room.installSIGHandlers()
}
run()