A script on a shared document: Alice shares a small plan as a room on a development Kition Server, her script numbers every item’s title through the room, and Bob sees the new titles arrive. Neither runs a kit: each keeps a replica of the room.
kition-sdk · examples/sdk-scripts/run-room.mjsrun-room.mjsimport { createRoom, openRoom } from '@kition/script/node'
// Alice's plan (kit example.plan, the example's own schema), made with the Kit Data Model alone.
const { docId, shareLink } = await createRoom({
server, token: alice, kit, schema, name: 'Plan', document: replica.snapshot(),
})
// Bob opens the room by its share link and listens.
const watcher = await openRoom({ server, token: bob, shareLink, schema })
const arrived = new Promise((resolve) => watcher.on('changed', (event) => resolve(event.origin)))
// Alice's script, on the same room: extension/script is the origin its changes carry.
const script = await openRoom({
server, token: alice, docId, kit, schema,
origin: { kind: 'extension', principal: 'example:retitle' },
})
const after = await titles(script, (title, index) => `${index + 1}. ${title}`)