// A synthetic REACTIONS PROJECT for the assistant's tests (release 36 lane // D): what a umtool project holds after the clip finder ran — reactions.json // (two speakers over reactionStream()'s turns, five moments, five proposals: // three in the cut, two not), words.json (the stream's words), a // video.manifest.json whose clips are the three used proposals, and, when // asked, a notes.json with an open comment on a clip. Nothing in it is a // recording, a person or a transcript (reactionStream's filler words). // // r001 40–47 (p004, a comment) r002 88–99 (p001, a laugh) r003 333–344 (p002, a laugh) // not in the cut: p003 512–523 (a weak laugh), p005 170–178 (the chat laughs) // // reactionProject(o) the three documents, as plain data // writeReactionProject(dir,o) them on disk (and notes.json with `note`) // labelAnswer(ids, o) a model's answer for those ids, the way // SUGGEST_ANSWER_SCHEMA asks for it import { mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; import { HOST, SUBJECT, reactionStream } from "./reactionStream.mjs"; export const PROJECT_CHANNEL = "synth-reacts"; export const PROJECT_VIDEO = "react001"; export const PROJECT_NOTE = "n_synth0001"; export const PROPOSED_AT = "2026-10-19T00:00:00.000Z"; export const PROJECT_PROPOSALS = Object.freeze([ { id: "p001", start: 88, end: 99, score: 0.82, moments: ["m001"], used: true, clipId: "r002", why: "the host laughs (0.80)" }, { id: "p002", start: 333, end: 344, score: 0.74, moments: ["m002"], used: true, clipId: "r003", why: "the host laughs (0.70)" }, { id: "p003", start: 512, end: 523, score: 0.31, moments: ["m003"], used: false, clipId: null, why: "a weak laugh" }, { id: "p004", start: 40, end: 47, score: 0.55, moments: ["m004"], used: true, clipId: "r001", why: "the host comments" }, { id: "p005", start: 170, end: 178, score: 0.4, moments: ["m005"], used: false, clipId: null, why: "chat laughs (12 messages)" }, ]); const MOMENTS = Object.freeze([ { id: "m001", t: 95, end: 97.5, kind: "laugh", score: 0.8, speaker: HOST, text: "haha" }, { id: "m002", t: 340, end: 342, kind: "laugh", score: 0.7, speaker: HOST, text: "haha" }, { id: "m003", t: 520, end: 521, kind: "laugh", score: 0.3, speaker: HOST, text: "haha" }, { id: "m004", t: 40, end: 44, kind: "comment", score: 0.5, speaker: HOST, text: "wow that's crazy." }, { id: "m005", t: 172, end: 176, kind: "chat", score: 0.4, speaker: null, text: "", messages: 12 }, ]); /** * @param {{ proposedAt?: string }} [o] */ export function reactionProject({ proposedAt = PROPOSED_AT } = {}) { const s = reactionStream(); const reactions = { version: 1, source: { channel: PROJECT_CHANNEL, video: PROJECT_VIDEO, duration: s.duration, words: "words.json", diarization: { generatedAt: "2026-10-18T00:00:00.000Z", engine: "sherpa-onnx" } }, params: { target: 600, laughMin: 0.25, mergeGap: 6, setupMax: 20, clipMax: 75, scope: null }, speakers: [ { index: HOST, role: "host", label: "Host", seconds: 60, turns: 7, how: "auto" }, { index: SUBJECT, role: "subject", label: "Subject", seconds: 540, turns: 8, how: "auto" }, ], turns: s.turns, laughs: [], moments: MOMENTS.map((m) => ({ ...m })), proposals: PROJECT_PROPOSALS.map((p) => ({ ...p, moments: [...p.moments] })), madeAt: proposedAt, proposedAt, }; const clip = (id, p) => ({ type: "clip", id, channel: PROJECT_CHANNEL, video: PROJECT_VIDEO, start: p.start - 1.5, end: p.end + 1.5, cutStart: p.start, cutEnd: p.end, quote: "", assist: { by: "assistant", proposal: p.id, score: p.score, why: p.why, original: { start: p.start - 1.5, end: p.end + 1.5, cutStart: p.start, cutEnd: p.end }, edits: [] }, }); const byId = Object.fromEntries(PROJECT_PROPOSALS.map((p) => [p.id, p])); const manifest = { slug: "synth-reaction-cut", title: "A synthetic reaction cut", provenance: { channelSlug: PROJECT_CHANNEL, siteOrigin: "" }, render: {}, timeline: [clip("r001", byId.p004), clip("r002", byId.p001), clip("r003", byId.p002)], }; return { reactions, words: { words: s.words }, manifest }; } /** * The project on disk. `note`: an open comment (PROJECT_NOTE) on that clip, * with that text. * @param {string} dir * @param {{ proposedAt?: string, note?: { clip: string, text: string } | null }} [o] */ export function writeReactionProject(dir, { proposedAt = PROPOSED_AT, note = null } = {}) { const { reactions, words, manifest } = reactionProject({ proposedAt }); mkdirSync(dir, { recursive: true }); const put = (name, doc) => writeFileSync(path.join(dir, name), `${JSON.stringify(doc, null, 1)}\n`); put("reactions.json", reactions); put("words.json", words); put("video.manifest.json", manifest); if (note) { put("notes.json", { format: "umtool-notes", version: 1, subject: { kind: "video-project", project: path.basename(dir) }, notes: [{ id: PROJECT_NOTE, status: "open", author: "operator", text: note.text, at: proposedAt, updatedAt: proposedAt, anchor: { kind: "entry", entry: note.clip }, replies: [] }], }); } return { dir, reactions, manifest }; } /** * A model's answer for `ids`: a short label and a why each, scored so the * first id ranks lowest (the rank is code's, by score). * @param {string[]} ids * @param {{ label?: (id: string, i: number) => string }} [o] */ export function labelAnswer(ids, { label = (id) => `the ${id} moment` } = {}) { return { items: ids.map((id, i) => ({ id, label: label(id, i), why: `Something happens in ${id}.`, score: Math.min(10, 2 + i) })) }; }