create-pmos 0.241.0 → 0.243.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/c3-report-design-real-test.js +13 -2
- package/workspace/c3-report-design-test.js +25 -3
- package/workspace/c3-report-structure-real-test.js +38 -1
- package/workspace/c3-report-structure-test.js +21 -6
- package/workspace/guide/console-calendar.md +15 -1
- package/workspace/guide/notes.md +26 -1
- package/workspace/guide/report-structure.md +3 -3
- package/workspace/guide/reports-page.md +3 -1
- package/workspace/guide/reports-set-up.md +5 -1
- package/workspace/lib/headless.js +7 -2
- package/workspace/lib/meeting-material.js +151 -0
- package/workspace/lib/meeting-replay.js +184 -0
- package/workspace/lib/notes-screen.js +128 -8
- package/workspace/lib/report-structure.js +49 -5
- package/workspace/lib/route-modules.js +2 -0
- package/workspace/lib/routes-meeting-focus.js +5 -3
- package/workspace/lib/routes-meeting-material.js +143 -0
- package/workspace/lib/routes-meeting-replay.js +75 -0
- package/workspace/lib/routes-notes.js +37 -4
- package/workspace/lib/routes-report-setups.js +16 -2
- package/workspace/lib/routes-report-structure.js +176 -5
- package/workspace/lib/routes-reports.js +10 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/c3-audience-link.js +21 -0
- package/workspace/public/pm/c3-audience.js +46 -0
- package/workspace/public/pm/c3-boot.js +2 -1
- package/workspace/public/pm/c3-calendar.js +15 -3
- package/workspace/public/pm/c3-demo-material.js +58 -0
- package/workspace/public/pm/c3-demo.js +5 -1
- package/workspace/public/pm/c3-focus.js +83 -16
- package/workspace/public/pm/c3-listen.css +10 -0
- package/workspace/public/pm/c3-material.css +22 -0
- package/workspace/public/pm/c3-material.js +321 -0
- package/workspace/public/pm/c3-notes.js +12 -4
- package/workspace/public/pm/c3-replay.css +133 -0
- package/workspace/public/pm/c3-replay.js +429 -0
- package/workspace/public/pm/c3-report-deck.css +5 -0
- package/workspace/public/pm/c3-report-deck.js +41 -5
- package/workspace/public/pm/c3-report-setup.css +5 -0
- package/workspace/public/pm/c3-report-setup.js +20 -2
- package/workspace/public/pm/c3-report-store.js +24 -2
- package/workspace/public/pm/c3-report-structure.css +4 -0
- package/workspace/public/pm/c3-report-structure.js +26 -8
- package/workspace/public/pm/c3-shell.js +2 -0
- package/workspace/public/pm/dest-notes.js +4 -2
- package/workspace/public/pm/dest-reports.js +10 -1
- package/workspace/public/pm/listen-sheet.js +94 -0
- package/workspace/public/pm/listen-sources.js +82 -0
- package/workspace/public/pm/notes-aside.js +62 -0
- package/workspace/public/pm/notes-screen-capture.js +23 -10
- package/workspace/public/pm/notes-screen-view.js +18 -5
- package/workspace/public/pm/notes-shots.js +55 -0
- package/workspace/public/pm/report-view.js +23 -1
- package/workspace/public/pm/reports-copy.js +5 -0
- package/workspace/public/pm/shell-recording.js +10 -2
- package/workspace/public/pm/view-notes.js +48 -8
- package/workspace/server.js +8 -1
- package/workspace/skills/report-structure-pull.skill +45 -0
- package/workspace/test-lists/meeting-material.json +6 -0
- package/workspace/test-lists/meeting-replay.json +6 -0
- package/workspace/test-lists/mm-capture.json +15 -0
- package/workspace/test-lists/report-structure-gaps.json +5 -0
|
@@ -69,6 +69,8 @@ const MODULES = Object.freeze([
|
|
|
69
69
|
'routes-hooks', // planning-flows run 7: CLI hook endpoints (session token, per-run JSONL)
|
|
70
70
|
'routes-sources', // workspace-data-freshness: how old each source is, Refresh now, the change detector switch
|
|
71
71
|
'routes-meeting-focus', // console3 Meeting focus: the meeting, its note's talk, the companion's notes (GET); topic corrections and Ask PMOS quietly (page press)
|
|
72
|
+
'routes-meeting-replay', // meeting-material-replay: the note, the Focus state and the shots joined for the Replay page (GET, read-only)
|
|
73
|
+
'routes-meeting-material', // meeting-material-replay: the material the PM links to a meeting (GET list and suggest; page-press POST add and remove; meeting-material.jsonl)
|
|
72
74
|
'routes-stage-tools', // stage-tools-records: the records the PM edits per stage, what PMOS holds per stage, the sprint burndown
|
|
73
75
|
'routes-driver', // initiative-driver: the Agent strip's data, Keep, Send back, Drop, Pause and the board mode (driver.jsonl)
|
|
74
76
|
'routes-scan', // horizon-scan-portfolio: one scan for the workspace: the watch list and setting, Scan now and Stop, report documents and their proposals (approve, change, dismiss, undo), plus the first scan's per-board and Briefing reads (scan.jsonl)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* routes-meeting-focus.js — the Meeting focus page's server side (initiative c3-meeting-focus; lib/route-modules.js).
|
|
3
3
|
*
|
|
4
4
|
* GET /api/meeting-focus?event=<id>&date=YYYY-MM-DD[&ws=]
|
|
5
|
-
* → { ok, now_ms, event, brief, note, topics, current, runs, tail, captured, gist, chips, notes, asks, companion }
|
|
5
|
+
* → { ok, now_ms, event, brief, material, note, topics, current, runs, tail, captured, gist, chips, notes, asks, companion }
|
|
6
6
|
* The meeting (the calendar read for that day), its brief (lib/calendar-layers.js briefOf), the note linked to it, the last
|
|
7
7
|
* minutes of that note's transcript with who said them, the decisions, actions and questions so far, and the companion's state.
|
|
8
8
|
* An unknown meeting is a 404. The read also starts the companion when lib/meeting-focus.js shouldRun says it may: the note
|
|
@@ -193,13 +193,15 @@ async function read(q, ctx) {
|
|
|
193
193
|
const url = l && typeof l.url === 'string' && /^https?:\/\//i.test(l.url) ? l.url : ''; if (!url || seen.has(url)) continue;
|
|
194
194
|
seen.add(url); links.push({ label: F.str(l.label, 120) || url, url });
|
|
195
195
|
}
|
|
196
|
+
let material = []; try { material = require('./meeting-material.js').forMeeting(ctx.runtimeDir, { id: ev.id, title: ev.title, series: ev.series || null }); } catch { material = []; }
|
|
196
197
|
const sessions = note && Array.isArray(note.sessions) && note.sessions.length ? note.sessions : [];
|
|
197
198
|
return { status: 200, body: {
|
|
198
199
|
ok: true, now_ms: nowMs, date: day,
|
|
199
200
|
talk,
|
|
200
201
|
event: { id: ev.id, title: ev.title, at: ev.at, end: ev.end, attendees: [].concat(ev.attendees || ev.people || []).map((p) => (p && typeof p === 'object' ? p.name || p.id : p)).filter(Boolean).map(String),
|
|
201
|
-
initiative: ev.initiative || null, purpose: ev.purpose || (brief && brief.purpose) || null, links },
|
|
202
|
+
initiative: ev.initiative || null, series: ev.series || null, purpose: ev.purpose || (brief && brief.purpose) || null, links },
|
|
202
203
|
brief: brief || null,
|
|
204
|
+
material,
|
|
203
205
|
note: note ? { id: note.id, title: note.title || ev.title, state: note.state, recorded_from: note.recorded_from || null, lines: (note.transcript || []).length, sessions } : null,
|
|
204
206
|
topics: fresh.topics, current: fresh.current, runs: fresh.runs,
|
|
205
207
|
tail: note ? F.tailOf(note, { now: nowMs }) : [], captured: F.capturedFrom(note),
|
|
@@ -317,7 +319,7 @@ const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true;
|
|
|
317
319
|
|
|
318
320
|
module.exports = {
|
|
319
321
|
prefixes: ['/api/meeting-focus'],
|
|
320
|
-
read, now: nowRoute, topic, ask, askState, settleAsk, settleRun, findEvent, keyOf,
|
|
322
|
+
read, now: nowRoute, topic, ask, askState, settleAsk, settleRun, findEvent, keyOf, linesOf, noteFor, noteEvent, realBrief,
|
|
321
323
|
handle: async (req, res, url, ctx) => {
|
|
322
324
|
const p = url.pathname;
|
|
323
325
|
const wsId = url.searchParams.get('ws');
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-meeting-material.js — the material of a meeting: what the PM linked to it (initiative meeting-material-replay, part 1; lib/route-modules.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/meeting-material?event=<id>&series=&title=[&date=][&topics=1][&ws=]
|
|
5
|
+
* → { ok, key, items: [item], topics? } item: { id, kind, ref, url, title, ws, topic, present, scope: meeting|series, from: 'you', by, at }
|
|
6
|
+
* The items of the meeting: the ones for every meeting of its series and the ones for this one. title is required (it names the series when
|
|
7
|
+
* series is empty). With topics=1 the answer also lists the topics Focus starts the meeting with, for the Add material sheet.
|
|
8
|
+
* POST /api/meeting-material { op?: 'add'|'remove', event: { id?, title, series? }, scope: 'meeting'|'series', item: { kind, ref|url, title?, ws? }, topic?, present? }
|
|
9
|
+
* → { ok, items } page press (lib/pm-guard.js requirePagePress). Appends one line to <runtime>/meeting-material.jsonl. The calendar is never written.
|
|
10
|
+
* GET /api/meeting-material/suggest?ws=&initiative=&board=&q=[&limit=]
|
|
11
|
+
* → { ok, suggested: [pick], found: [pick] } pick: { kind, ref, title, meta, why?, present, ws }
|
|
12
|
+
* suggested: the documents of the meeting's level (the initiative's, newest first) and the newest report cycles. found: a search over the
|
|
13
|
+
* titles and paths of PMOS documents and report cycles (two letters or more). Read-only.
|
|
14
|
+
*
|
|
15
|
+
* Handlers are pure over (req, body, ctx): ctx = { runtimeDir, getWs, stateDirFor?, initiativeIndex?, readEvents?, briefFor?, json } so a test needs no server. */
|
|
16
|
+
const store = require('./meeting-material.js');
|
|
17
|
+
const guard = require('./pm-guard.js');
|
|
18
|
+
|
|
19
|
+
const fail = (status, error, extra) => ({ status, body: { ok: false, error, ...(extra || {}) } });
|
|
20
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
21
|
+
const str = (v, n) => String(v == null ? '' : v).trim().slice(0, n || 300);
|
|
22
|
+
const eventOf = (q) => ({ id: str(q.event, 120), title: str(q.title, 300), series: str(q.series, 300) || null });
|
|
23
|
+
|
|
24
|
+
/** The topics Focus starts the meeting with (lib/meeting-focus.js topicsFrom). Best effort: no calendar read, no topics. */
|
|
25
|
+
async function topicsOf(q, ctx) {
|
|
26
|
+
try {
|
|
27
|
+
const F = require('./meeting-focus.js');
|
|
28
|
+
const R = require('./routes-meeting-focus.js');
|
|
29
|
+
const events = typeof ctx.readEvents === 'function' ? ctx.readEvents() : require('./calendar-events.js').readAll(ctx.runtimeDir, { now: Date.now() });
|
|
30
|
+
const date = q.date && DAY.test(String(q.date)) ? String(q.date) : '';
|
|
31
|
+
const ev = R.findEvent(events, str(q.event, 120), date);
|
|
32
|
+
if (!ev) return [];
|
|
33
|
+
const day = date || String(ev.at || '').slice(0, 10);
|
|
34
|
+
const w = ctx.getWs ? ctx.getWs(q.ws || null) : null;
|
|
35
|
+
const brief = typeof ctx.briefFor === 'function' ? await ctx.briefFor(ev, day) : await R.realBrief({ ...ctx, w }, ev, day);
|
|
36
|
+
return F.topicsFrom(ev, brief).map((t) => ({ id: t.id, text: t.text }));
|
|
37
|
+
} catch { return []; }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function list(q, ctx) {
|
|
41
|
+
const e = eventOf(q);
|
|
42
|
+
if (!e.title) return fail(400, 'title is required');
|
|
43
|
+
if (!ctx.runtimeDir) return { status: 200, body: { ok: true, key: store.keyOf(e), items: [] } };
|
|
44
|
+
const body = { ok: true, key: store.keyOf(e), items: store.forMeeting(ctx.runtimeDir, e) };
|
|
45
|
+
if (q.topics === '1' || q.topics === 'true') body.topics = await topicsOf(q, ctx);
|
|
46
|
+
return { status: 200, body };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function post(req, body, ctx) {
|
|
50
|
+
const g = guard.requirePagePress(req, body);
|
|
51
|
+
if (!g.ok) return fail(g.status, g.error);
|
|
52
|
+
if (!ctx.runtimeDir) return fail(409, 'this server has no runtime folder, so the material cannot be saved');
|
|
53
|
+
const out = store.append(ctx.runtimeDir, body, g.actor && g.actor.by ? g.actor.by : null);
|
|
54
|
+
return out.ok ? { status: 200, body: out } : fail(400, out.error);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* ── what PMOS can offer ──────────────────────────────────────────────────────────────────────────────────────────── */
|
|
58
|
+
|
|
59
|
+
const dayText = (d) => {
|
|
60
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); if (!m) return '';
|
|
61
|
+
const t = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3]));
|
|
62
|
+
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][t.getUTCDay()] + ' ' + (+m[3]) + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+m[2] - 1];
|
|
63
|
+
};
|
|
64
|
+
const isReportPath = (p) => /(^|\/)reports\//.test(p);
|
|
65
|
+
|
|
66
|
+
/** Every document and report cycle PMOS holds for a workspace, as picks. Each read is best effort: a failing source adds nothing. */
|
|
67
|
+
function candidates(ctx, w) {
|
|
68
|
+
const docs = []; const reports = [];
|
|
69
|
+
const root = w.root;
|
|
70
|
+
const owner = new Map();
|
|
71
|
+
try {
|
|
72
|
+
if (typeof ctx.initiativeIndex === 'function') {
|
|
73
|
+
for (const g of ctx.initiativeIndex(root).initiatives || []) for (const a of g.artifacts || []) { const rel = String(a.path).split('\\').join('/'); if (!a.shared && !owner.has(rel)) owner.set(rel, { id: g.id, title: g.title || g.id }); }
|
|
74
|
+
}
|
|
75
|
+
} catch { /* no attribution: a document has no initiative */ }
|
|
76
|
+
try {
|
|
77
|
+
const lib = require('./doc-library.js').library(root, { stateDir: typeof ctx.stateDirFor === 'function' ? ctx.stateDirFor(w) : undefined, owners: () => owner });
|
|
78
|
+
if (lib && lib.ok) {
|
|
79
|
+
const cat = new Map((lib.categories || []).map((c) => [c.key, c.name]));
|
|
80
|
+
for (const f of lib.files || []) {
|
|
81
|
+
if (f.node || isReportPath(f.path)) continue;
|
|
82
|
+
const o = owner.get(f.path) || (f.initiative ? { id: f.initiative } : null);
|
|
83
|
+
docs.push({ kind: 'pmos-doc', ref: f.path, title: f.title || f.path, date: f.date || '', ini: o ? o.id : null, ws: w.id,
|
|
84
|
+
meta: (o ? o.id + ' documents' : cat.get(f.category) || 'Documents') + (f.date ? ' · ' + dayText(f.date) : '') });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} catch { /* no library */ }
|
|
88
|
+
try {
|
|
89
|
+
const rs = require('./routes-report-setups.js');
|
|
90
|
+
for (const d of rs.documentsOf({ runtimeDir: ctx.runtimeDir, getWs: ctx.getWs }, w).docs || []) {
|
|
91
|
+
const deck = d.output === 'google-slides';
|
|
92
|
+
reports.push({ kind: deck ? 'pmos-deck' : 'report', ref: d.path, title: (d.name || d.id) + (d.slot ? ' · ' + d.slot : ''), date: String(d.slot || '').slice(0, 10), ini: null, ws: w.id,
|
|
93
|
+
meta: 'Reports · ' + (deck ? 'deck' : 'document') + (d.state === 'issued' ? ' · issued' : ' · draft'), present: deck });
|
|
94
|
+
}
|
|
95
|
+
} catch { /* no reports */ }
|
|
96
|
+
return { docs, reports };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const newest = (a, b) => String(b.date || '').localeCompare(String(a.date || ''));
|
|
100
|
+
const pick = (c, why) => ({ kind: c.kind, ref: c.ref, title: c.title, meta: c.meta, ...(why ? { why } : {}), present: c.present === true, ws: c.ws });
|
|
101
|
+
|
|
102
|
+
function suggest(q, ctx) {
|
|
103
|
+
const w = ctx.getWs ? ctx.getWs(q.ws || null) : null;
|
|
104
|
+
if (!w || !w.root) return fail(404, 'no such workspace');
|
|
105
|
+
const limit = Math.max(1, Math.min(20, Number(q.limit) || 6));
|
|
106
|
+
const ini = str(q.initiative, 120);
|
|
107
|
+
const c = candidates(ctx, w);
|
|
108
|
+
const suggested = [];
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
const add = (x, why) => { if (suggested.length >= limit || seen.has(x.ref)) return; seen.add(x.ref); suggested.push(pick(x, why)); };
|
|
111
|
+
if (ini) {
|
|
112
|
+
for (const d of c.docs.filter((x) => x.ini === ini).sort(newest).slice(0, 4)) add(d, 'In ' + ini + (d.date ? ', edited ' + dayText(d.date) : ''));
|
|
113
|
+
}
|
|
114
|
+
for (const r of c.reports.slice().sort(newest).slice(0, 2)) add(r, 'A report PMOS keeps' + (r.date ? ', ' + dayText(r.date) : ''));
|
|
115
|
+
const text = str(q.q, 120).toLowerCase();
|
|
116
|
+
let found = [];
|
|
117
|
+
if (text.length >= 2) {
|
|
118
|
+
const hit = (x) => (x.title + ' ' + x.ref).toLowerCase().includes(text);
|
|
119
|
+
found = [...c.reports.filter(hit), ...c.docs.filter(hit)].sort(newest).slice(0, 8).map((x) => pick(x));
|
|
120
|
+
}
|
|
121
|
+
return { status: 200, body: { ok: true, suggested, found } };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
prefixes: ['/api/meeting-material'],
|
|
128
|
+
list, post, suggest, candidates,
|
|
129
|
+
handle: async (req, res, url, ctx) => {
|
|
130
|
+
const p = url.pathname;
|
|
131
|
+
const q = Object.fromEntries(url.searchParams);
|
|
132
|
+
if (p === '/api/meeting-material/suggest') {
|
|
133
|
+
if (req.method !== 'GET') return respond(ctx, res, fail(405, 'GET only'));
|
|
134
|
+
return respond(ctx, res, suggest(q, ctx));
|
|
135
|
+
}
|
|
136
|
+
if (p !== '/api/meeting-material') return false;
|
|
137
|
+
if (req.method === 'GET') return respond(ctx, res, await list(q, ctx));
|
|
138
|
+
if (req.method !== 'POST') return respond(ctx, res, fail(405, 'GET or POST only'));
|
|
139
|
+
const got = await ctx.readJson(req);
|
|
140
|
+
if (!got.ok || !got.body || typeof got.body !== 'object' || Array.isArray(got.body)) return respond(ctx, res, fail(400, 'the body must be a JSON object'));
|
|
141
|
+
return respond(ctx, res, post(req, got.body, ctx));
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-meeting-replay.js — the meeting replay's server side (initiative meeting-material-replay, part 2; lib/route-modules.js).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/meeting-replay?note=<id>[&event=<id>&date=YYYY-MM-DD]
|
|
5
|
+
* GET /api/meeting-replay?event=<id>[&date=YYYY-MM-DD] the note linked to that meeting
|
|
6
|
+
* → { ok, note, meeting, audio, start_ms, length_ms, lines, keys, topics, runs, notes, shots, aside_count } (lib/meeting-replay.js)
|
|
7
|
+
* The note (transcript, decisions, next steps, questions), the Focus state file (topics, stretches, PMOS's notes) and the
|
|
8
|
+
* shots, joined. Read only: it writes nothing, starts no run and reaches nothing outside the machine. A private note is a
|
|
9
|
+
* 404 (it keeps no audio and no shots); an unknown note or a meeting with no note is a 404. A shot that was set aside
|
|
10
|
+
* (`aside`) is not in `shots`; `aside_count` says how many there are.
|
|
11
|
+
* Handlers are pure over (query, ctx): ctx = { runtimeDir, readEvents?, now? }, so a test needs no server.
|
|
12
|
+
*/
|
|
13
|
+
const focus = require('./routes-meeting-focus.js');
|
|
14
|
+
const notes = require('./notes.js');
|
|
15
|
+
const notesAudio = require('./notes-audio.js');
|
|
16
|
+
const notesScreen = require('./notes-screen.js');
|
|
17
|
+
const F = require('./meeting-focus.js');
|
|
18
|
+
const R = require('./meeting-replay.js');
|
|
19
|
+
|
|
20
|
+
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
21
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
22
|
+
|
|
23
|
+
/** The note's shots, the kept ones and the set-aside ones, so the join can count the set-aside ones and leave them out.
|
|
24
|
+
* notesScreen.list(dir, id) lists the kept shots; { aside: true } lists only the set-aside ones. */
|
|
25
|
+
function framesOf(dir, id) {
|
|
26
|
+
let all = [];
|
|
27
|
+
try { all = [...(notesScreen.list(dir, id) || []), ...(notesScreen.list(dir, id, { aside: true }) || [])]; } catch { all = []; }
|
|
28
|
+
return all.filter((f) => f && typeof f.t === 'number').sort((a, b) => a.t - b.t);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function read(q, ctx) {
|
|
32
|
+
const dir = ctx.runtimeDir;
|
|
33
|
+
const noteId = String((q && q.note) || '').slice(0, 120);
|
|
34
|
+
const eventId = String((q && q.event) || '').slice(0, 120);
|
|
35
|
+
const date = q && q.date ? String(q.date) : '';
|
|
36
|
+
if (!noteId && !eventId) return fail(400, 'note or event is required');
|
|
37
|
+
if (date && !DAY.test(date)) return fail(400, 'date must be YYYY-MM-DD');
|
|
38
|
+
const nowMs = typeof ctx.now === 'function' ? ctx.now() : Date.now();
|
|
39
|
+
let events = [];
|
|
40
|
+
try { events = typeof ctx.readEvents === 'function' ? ctx.readEvents() : require('./calendar-events.js').readAll(dir, { now: nowMs }); } catch { events = []; }
|
|
41
|
+
let note = null; let ev = null;
|
|
42
|
+
if (noteId) {
|
|
43
|
+
const r = notes.read(dir, noteId);
|
|
44
|
+
if (!r.ok) return fail(404, 'no such note');
|
|
45
|
+
note = r.note;
|
|
46
|
+
if (eventId) ev = focus.findEvent(events, eventId, date);
|
|
47
|
+
const m = note.meeting;
|
|
48
|
+
if (!ev && m && m.kind === 'event' && m.event_id) ev = focus.findEvent(events, String(m.event_id), date || String(m.start || '').slice(0, 10));
|
|
49
|
+
} else {
|
|
50
|
+
ev = focus.findEvent(events, eventId, date);
|
|
51
|
+
if (!ev) return fail(404, 'no such meeting on the calendar');
|
|
52
|
+
note = focus.noteFor(dir, ev, null);
|
|
53
|
+
if (!note) return fail(404, 'this meeting has no note to replay');
|
|
54
|
+
}
|
|
55
|
+
if (note.private) return fail(404, 'This note is private. It keeps no audio and no shots, so it has no replay.');
|
|
56
|
+
const talk = !ev;
|
|
57
|
+
if (!ev) ev = focus.noteEvent(note);
|
|
58
|
+
const keys = [focus.keyOf(ev.id), focus.keyOf(note.id)];
|
|
59
|
+
const rec = notesAudio.info(dir, note.id);
|
|
60
|
+
const audio = rec ? { url: '/api/notes/recording?id=' + encodeURIComponent(note.id) + '&b=' + rec.bytes + (notesAudio.hasClean(dir, note.id) ? '&c=1' : ''), ms: rec.ms } : null;
|
|
61
|
+
const body = R.build({ note, event: ev, stateLines: focus.linesOf(dir, keys), frames: framesOf(dir, note.id), audio, topics: talk ? [] : F.topicsFrom(ev, null), now: nowMs });
|
|
62
|
+
return { status: 200, body };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
prefixes: ['/api/meeting-replay'],
|
|
69
|
+
read,
|
|
70
|
+
handle: async (req, res, url, ctx) => {
|
|
71
|
+
if (url.pathname !== '/api/meeting-replay') return false;
|
|
72
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
73
|
+
return respond(ctx, res, await read(Object.fromEntries(url.searchParams), { runtimeDir: ctx.runtimeDir, json: ctx.json }));
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
* Refused: a private note (409), a note not listening (409), "Capture the shared screen" switched off (409),
|
|
41
41
|
* a token that is not the live capture's (409), a bad t or picture (400), a full note (409)
|
|
42
42
|
* GET /api/notes/screen?id=…&t=… → image/jpeg|png|webp the shot kept at meeting time t; 404 for a private note or no such shot
|
|
43
|
+
* (a shot set aside is not served, unless aside=1 is added: the review sheet's thumbnails)
|
|
44
|
+
* POST /api/notes/screen also takes surface: 'window' | 'browser' | 'monitor', what the picture shows; a 'monitor' shot is checked for other apps
|
|
45
|
+
* GET /api/notes/screen-aside?id=… → { ok, frames: [{ t, w, h, bytes, app, text? }], days } the shots set aside as another app (meeting-material-replay)
|
|
46
|
+
* POST /api/notes/screen-aside { id, action: 'keep' | 'delete' | 'delete-all', t? } → { ok, frame? , deleted?, aside } the PM's answer; GET /api/notes/one
|
|
47
|
+
* also carries screen.aside, the count. Set-aside shots older than 7 days are deleted on their own.
|
|
43
48
|
* POST /api/notes/screen-delete { id } → { ok, deleted } deletes the note's screenshots and keeps the rest
|
|
44
49
|
* POST /api/notes/clean-audio { id } → { ok, started } makes the cleaned copy of the replay now (Run 3 of notes-audio-quality; needs ffmpeg)
|
|
45
50
|
* GET /api/notes/engine?ws=… → { ok, whisper, jev } is Whisper set up; which Jev gates hold (booleans only)
|
|
@@ -111,7 +116,7 @@ const VOCAB_TTL_MS = 60 * 1000;
|
|
|
111
116
|
const prefixes = ['/api/notes'];
|
|
112
117
|
const POSTS = new Set(['/api/notes/new', '/api/notes/save', '/api/notes/dictate', '/api/notes/record', '/api/notes/transcript',
|
|
113
118
|
'/api/notes/private', '/api/notes/pause', '/api/notes/stop', '/api/notes/summarize', '/api/notes/summarize-agent', '/api/notes/delete', '/api/notes/audio', '/api/notes/label',
|
|
114
|
-
'/api/notes/speaker', '/api/notes/switch', '/api/notes/whisper-setup', '/api/notes/final', '/api/notes/final-setup', '/api/notes/line', '/api/notes/recording-delete', '/api/notes/screen', '/api/notes/screen-delete', '/api/notes/clean-audio', '/api/notes/link', '/api/notes/bullet', '/api/notes/highlight', '/api/notes/highlight-remove', '/api/notes/final-edit', '/api/notes/wispr-fetch', '/api/notes/series-done', '/api/notes/series-bring', '/api/notes/series-unbring', '/api/notes/series-member']);
|
|
119
|
+
'/api/notes/speaker', '/api/notes/switch', '/api/notes/whisper-setup', '/api/notes/final', '/api/notes/final-setup', '/api/notes/line', '/api/notes/recording-delete', '/api/notes/screen', '/api/notes/screen-delete', '/api/notes/screen-aside', '/api/notes/clean-audio', '/api/notes/link', '/api/notes/bullet', '/api/notes/highlight', '/api/notes/highlight-remove', '/api/notes/final-edit', '/api/notes/wispr-fetch', '/api/notes/series-done', '/api/notes/series-bring', '/api/notes/series-unbring', '/api/notes/series-member']);
|
|
115
120
|
|
|
116
121
|
/* ── labels and checks, one note at a time ───────────────────────────────────────────────────── */
|
|
117
122
|
const chains = new Map(); // note id → the promise of its work so far (minute batches, imports, labels, checks)
|
|
@@ -674,6 +679,13 @@ function resumeStuck(ctx) {
|
|
|
674
679
|
|
|
675
680
|
const send = (ctx, res, r) => ctx.json(res, r, r.ok ? 200 : (r.status || 400));
|
|
676
681
|
|
|
682
|
+
/** Delete the shots set aside for more than 7 days. At most once in ten minutes unless `now` is true. */
|
|
683
|
+
let asideSweptAt = 0;
|
|
684
|
+
function sweepAsideSoon(dir, now = false) {
|
|
685
|
+
if (!now && Date.now() - asideSweptAt < 10 * 60000) return;
|
|
686
|
+
asideSweptAt = Date.now();
|
|
687
|
+
try { notesScreen.sweepAside(dir); } catch { /* a folder that cannot be read stays as it was */ }
|
|
688
|
+
}
|
|
677
689
|
async function handle(req, res, url, ctx) {
|
|
678
690
|
const p = url.pathname;
|
|
679
691
|
const dir = ctx.runtimeDir;
|
|
@@ -683,6 +695,7 @@ async function handle(req, res, url, ctx) {
|
|
|
683
695
|
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
684
696
|
if (p === '/api/notes') {
|
|
685
697
|
const l = notes.list(dir, { resumeMs: resumeMsOf(ctx) });
|
|
698
|
+
sweepAsideSoon(dir);
|
|
686
699
|
if (l.ok) { sweepExpired(ctx, l.notes); try { l.series_open = notesSeries.openCounts(dir, l.notes); } catch { l.series_open = {}; } }
|
|
687
700
|
send(ctx, res, l); return true;
|
|
688
701
|
}
|
|
@@ -697,7 +710,7 @@ async function handle(req, res, url, ctx) {
|
|
|
697
710
|
if (r.ok && mergeWispr(ctx, nid)) r = notes.read(dir, nid, { resumeMs: resumeMsOf(ctx) });
|
|
698
711
|
if (r.ok) {
|
|
699
712
|
r.audio = { pending: transcriber ? transcriber.pending() : 0, error: audioErrors.get(nid) || null }; r.recording = notesAudio.info(dir, nid); if (r.recording) r.recording = { ...r.recording, cleaned: notesAudio.hasClean(dir, nid) };
|
|
700
|
-
r.screen = { frames: r.note.private ? [] : notesScreen.list(dir, nid) };
|
|
713
|
+
r.screen = { frames: r.note.private ? [] : notesScreen.list(dir, nid), aside: r.note.private ? 0 : notesScreen.asideCount(dir, nid) };
|
|
701
714
|
if (!Array.isArray(r.note.bullets)) r.note.bullets = [];
|
|
702
715
|
r.bullets_state = bulletsState(ctx, r.note);
|
|
703
716
|
// where the note sits in its meeting series, and what changed since the meeting before (c3-notes-series)
|
|
@@ -717,7 +730,16 @@ async function handle(req, res, url, ctx) {
|
|
|
717
730
|
const r = notes.read(dir, nid);
|
|
718
731
|
if (!r.ok) { send(ctx, res, r); return true; }
|
|
719
732
|
if (r.note.private) { ctx.json(res, { ok: false, error: 'this note is private and keeps no screenshots' }, 404); return true; }
|
|
720
|
-
notesScreen.serve(req, res, dir, nid, url.searchParams.get('t'));
|
|
733
|
+
notesScreen.serve(req, res, dir, nid, url.searchParams.get('t'), { aside: url.searchParams.get('aside') === '1' });
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
if (p === '/api/notes/screen-aside' && req.method === 'GET') {
|
|
737
|
+
const nid = url.searchParams.get('id');
|
|
738
|
+
const r = notes.read(dir, nid);
|
|
739
|
+
if (!r.ok) { send(ctx, res, r); return true; }
|
|
740
|
+
if (r.note.private) { ctx.json(res, { ok: true, frames: [], days: notesScreen.ASIDE_DAYS }); return true; }
|
|
741
|
+
sweepAsideSoon(dir, true);
|
|
742
|
+
ctx.json(res, { ok: true, days: notesScreen.ASIDE_DAYS, frames: notesScreen.listAside(dir, nid).map((f) => ({ t: f.t, w: f.w, h: f.h, bytes: f.bytes, app: f.asideApp || '', text: f.text || '', at: f.asideAt || null })) });
|
|
721
743
|
return true;
|
|
722
744
|
}
|
|
723
745
|
if (p === '/api/notes/recording' && (req.method === 'GET' || req.method === 'HEAD')) {
|
|
@@ -915,7 +937,18 @@ async function handle(req, res, url, ctx) {
|
|
|
915
937
|
if (!own.ok) return done(own);
|
|
916
938
|
if (typeof body.t !== 'number' || !Number.isFinite(body.t) || body.t < 0) return done({ ok: false, status: 400, error: 'a screenshot needs its meeting time' });
|
|
917
939
|
if (typeof body.img !== 'string' || !body.img) return done({ ok: false, status: 400, error: 'there is no picture to keep' });
|
|
918
|
-
return done(notesScreen.add(dir, { id, t: body.t, buf: Buffer.from(body.img, 'base64'), w: body.w, h: body.h, why: body.why }));
|
|
940
|
+
return done(notesScreen.add(dir, { id, t: body.t, buf: Buffer.from(body.img, 'base64'), w: body.w, h: body.h, why: body.why, surface: body.surface }));
|
|
941
|
+
}
|
|
942
|
+
if (p === '/api/notes/screen-aside') {
|
|
943
|
+
const r = notes.read(dir, id);
|
|
944
|
+
if (!r.ok) return done(r);
|
|
945
|
+
const act = body.action;
|
|
946
|
+
let out;
|
|
947
|
+
if (act === 'keep') out = notesScreen.keep(dir, id, body.t);
|
|
948
|
+
else if (act === 'delete') out = notesScreen.discard(dir, id, body.t);
|
|
949
|
+
else if (act === 'delete-all') out = notesScreen.discardAll(dir, id);
|
|
950
|
+
else return done({ ok: false, status: 400, error: 'say action: keep, delete or delete-all' });
|
|
951
|
+
return done(out.ok ? { ...out, aside: notesScreen.asideCount(dir, id) } : out);
|
|
919
952
|
}
|
|
920
953
|
if (p === '/api/notes/screen-delete') {
|
|
921
954
|
const r = notes.read(dir, id);
|
|
@@ -120,10 +120,16 @@ function documentsOf(ctx, w) {
|
|
|
120
120
|
return { docs, reports: r.reports };
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** The state of a report's structure draft, else null (report-structure-gaps). */
|
|
124
|
+
function draftStateOf(ctx, w, s) {
|
|
125
|
+
if (!ctx || typeof ctx.structureDraftState !== 'function' || s.source !== 'work') return null;
|
|
126
|
+
try { return ctx.structureDraftState(w, s.id) || null; } catch { return null; }
|
|
127
|
+
}
|
|
128
|
+
|
|
123
129
|
/** The saved structure of a report (initiative report-structure): { saved, at, charts, sections }, else null. */
|
|
124
130
|
function structureOf(root, id) { try { return require('./report-structure.js').savedOf(root, id); } catch { return null; } }
|
|
125
131
|
|
|
126
|
-
function setupOut(s, now, docsOf, idx, root) {
|
|
132
|
+
function setupOut(s, now, docsOf, idx, root, draft) {
|
|
127
133
|
const mine = (docsOf.reports || []).filter((x) => x.cadence === s.id);
|
|
128
134
|
const issued = mine.filter((x) => x.issued).map((x) => x.slot).sort().pop() || null;
|
|
129
135
|
const latest = mine.slice().sort((a, b) => (a.slot < b.slot ? 1 : -1))[0] || null;
|
|
@@ -134,6 +140,7 @@ function setupOut(s, now, docsOf, idx, root) {
|
|
|
134
140
|
next_draft: next, last_issued: issued, status: s.status, cycles: mine.length,
|
|
135
141
|
copy: copyOf(latest ? linkFor(idx, latest.path, s.output) : null, docSync.copyKindOf(s.output)),
|
|
136
142
|
structure: structureOf(root, s.id),
|
|
143
|
+
draft: draft || null, // report-structure-gaps: { state: 'drafting' | 'held' | 'ended', since, … } while a draft that follows the saved structure is being made
|
|
137
144
|
};
|
|
138
145
|
}
|
|
139
146
|
|
|
@@ -162,7 +169,7 @@ function listAnswer(ctx, w, now) {
|
|
|
162
169
|
const docsOf = documentsOf(ctx, w);
|
|
163
170
|
const idx = copyIndex(w.root);
|
|
164
171
|
return {
|
|
165
|
-
setups: [...st.setups.values()].map((s) => setupOut(s, new Date(now), docsOf, idx, w.root)),
|
|
172
|
+
setups: [...st.setups.values()].map((s) => setupOut(s, new Date(now), docsOf, idx, w.root, draftStateOf(ctx, w, s))),
|
|
166
173
|
findings: RS.openFindings(st).map((f) => ({ id: f.id, name: f.name, why: f.why, evidence: f.evidence, confidence: f.confidence, proposal: f.proposal })),
|
|
167
174
|
asks: [...st.asks.values()].map((a) => ({ id: a.id, text: a.text, state: a.state, changed: !!a.changed, proposal: a.proposal, error: a.error })),
|
|
168
175
|
finder: finderOut(ctx, st, now),
|
|
@@ -360,6 +367,13 @@ async function handle(req, res, url, ctx) {
|
|
|
360
367
|
if (s.source !== 'work') return send(bad(400, 'a dashboard report is drafted from its dashboard on its day'));
|
|
361
368
|
let next = null; try { next = RS.nextDraftAt(s.schedule, s.last_run, new Date()); } catch { next = null; }
|
|
362
369
|
const day = next ? `${next.getFullYear()}-${String(next.getMonth() + 1).padStart(2, '0')}-${String(next.getDate()).padStart(2, '0')}` : null; // the local day, as setUp names a slot
|
|
370
|
+
// A report with a saved structure is drafted by the session the schedule would start, so the draft follows the structure (report-structure-gaps).
|
|
371
|
+
// One with no saved structure keeps the instant draft below.
|
|
372
|
+
const sd = typeof ctx.structureDraft === 'function' ? ctx.structureDraft(w, s.id) : { structured: false };
|
|
373
|
+
if (sd.structured) {
|
|
374
|
+
if (sd.status) return send(bad(sd.status, sd.error));
|
|
375
|
+
return send({ status: 200, body: { ok: true, drafting: true, held: !!sd.held, state: sd.state || null, id: s.id } });
|
|
376
|
+
}
|
|
363
377
|
const d = draftCycle(root, s.id, day, g.actor);
|
|
364
378
|
if (d.error) return send(bad(500, 'the draft was not written: ' + d.error));
|
|
365
379
|
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
|