@double_geste/agent-standup 1.30.0 → 1.31.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/codex.js +2 -1
- package/package.json +1 -1
- package/public/index.html +234 -46
- package/public/locales/README.md +3 -0
- package/public/locales/da.json +15 -3
- package/public/locales/de.json +15 -3
- package/public/locales/en.json +14 -2
- package/public/locales/es.json +15 -3
- package/public/locales/ja.json +15 -3
- package/public/locales/ko.json +15 -3
- package/public/locales/pt-BR.json +15 -3
- package/public/locales/zh-CN.json +15 -3
- package/public/locales/zh-TW.json +15 -3
- package/server.js +83 -17
- package/vibe.js +2 -1
package/server.js
CHANGED
|
@@ -24,6 +24,32 @@ const blocks = (rec) => {
|
|
|
24
24
|
return Array.isArray(c) ? c : [];
|
|
25
25
|
};
|
|
26
26
|
const clip = (x, n = 700) => String(x == null ? '' : x).slice(0, n);
|
|
27
|
+
// The documents a command names, in its text or in what it printed: an export, a report, a picture, a package. The call shows one under it when the lead names it too
|
|
28
|
+
// and it was written since (see sessionFile): a name is all that is taken here, nothing is read. cd: a command, where "cd dir &&" says from which folder the names that follow are given.
|
|
29
|
+
const OUT_EXT = /\.(html?|md|markdown|txt|rtf|pdf|docx?|pptx?|xlsx?|csv|tsv|png|jpe?g|gif|webp|svg|zip|tgz|vsix|mp4|mov|webm|mp3|wav|epub)$/i, ROOTED = /^([~\/\\]|[A-Za-z]:[\\/])/;
|
|
30
|
+
function noHere(t) { // a command without what its here-documents hold: that is a file's content, not the command (the rest of the line that opens one is: "> list.txt"). Read once from left to right, a few of them at most: a text full of "<<" (C++, shifts) costs nothing
|
|
31
|
+
let out = '', i = 0; const open = /<<-?[ \t]*(['"]?)(\w+)\1/y;
|
|
32
|
+
for (let n = 0; n < 8; n++) {
|
|
33
|
+
const j = t.indexOf('<<', i); if (j < 0) break; open.lastIndex = j; const m = t[j - 1] !== '<' && t[j + 2] !== '<' && open.exec(t); if (!m) { out += t.slice(i, j + 2); i = j + 2; continue; }
|
|
34
|
+
const eol = t.indexOf('\n', open.lastIndex); if (eol < 0) return out + t.slice(i, j) + ' ' + t.slice(open.lastIndex);
|
|
35
|
+
out += t.slice(i, j) + ' ' + t.slice(open.lastIndex, eol); i = t.length; // to the line that closes it, or to the end when none does
|
|
36
|
+
for (let a = eol + 1; a <= t.length;) { const b = t.indexOf('\n', a), line = t.slice(a, b < 0 ? t.length : b); if (line.trim() === m[2]) { i = b < 0 ? t.length : b; break; } if (b < 0) break; a = b + 1; }
|
|
37
|
+
}
|
|
38
|
+
return out + t.slice(i);
|
|
39
|
+
}
|
|
40
|
+
function docPaths(text, cd) {
|
|
41
|
+
const out = []; let dir = '';
|
|
42
|
+
const cmd = cd ? noHere(String(text || '').slice(0, 20000)) : String(text || '').slice(0, 20000);
|
|
43
|
+
for (const seg of cmd.split(cd ? /&&|\|\||;|\n/ : /\n/)) {
|
|
44
|
+
const m = cd && seg.match(/^\s*cd\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/); if (m) { const d = m[1] || m[2] || m[3]; dir = ROOTED.test(d) ? d : path.join(dir, d); continue; }
|
|
45
|
+
for (const t of seg.matchAll(/"([^"\n]+)"|'([^'\n]+)'|([^\s"'`|&;<>()=,]+)/g)) {
|
|
46
|
+
const f = (t[1] || t[2] || t[3]).replace(/[.:;!?)\]]+$/, ''); if (!OUT_EXT.test(f) || /:\/\/|[*?{}$\[]|^(\\\\|\/\/)/.test(f) || f.length > 400) continue; // not a link, a pattern or a variable, nor a path on another machine (the server would go and look there)
|
|
47
|
+
const full = dir && !ROOTED.test(f) ? path.join(dir, f) : f; if (!out.includes(full)) out.push(full); if (out.length >= 16) return out;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
const absPath = (f, cwd) => (/^~([\\/]|$)/.test(f) ? path.join(os.homedir(), f.slice(1)) : path.isAbsolute(f) ? path.normalize(f) : cwd ? path.resolve(cwd, f) : f); // cwd: the folder the session was in when it wrote that record
|
|
27
53
|
// What each tool call looks like on a screen ("d"), plus its id/timestamp so the result can be matched later.
|
|
28
54
|
const toolLabel = (b, ts) => {
|
|
29
55
|
const i = b.input || {};
|
|
@@ -31,7 +57,7 @@ const toolLabel = (b, ts) => {
|
|
|
31
57
|
const arg = i.file_path || i.notebook_path || i.path || i.pattern || i.command || i.url || i.query || i.skill || (q0 && q0.question) || i.description || firstStr || '';
|
|
32
58
|
const out = { id: b.id, ts, name: b.name, arg: String(arg).slice(0, 90) };
|
|
33
59
|
switch (b.name) {
|
|
34
|
-
case 'Bash': out.d = { kind: 'cmd', text: clip(i.command, 1200), note: clip(i.description, 140) }; break;
|
|
60
|
+
case 'Bash': { out.d = { kind: 'cmd', text: clip(i.command, 1200), note: clip(i.description, 140) }; const outs = docPaths(i.command, true); if (outs.length) out.d.outs = outs; break; }
|
|
35
61
|
case 'Read': out.d = { kind: 'read', file: i.file_path, offset: i.offset, limit: i.limit }; break;
|
|
36
62
|
case 'Edit': case 'MultiEdit': { const e = i.edits ? i.edits[0] || {} : i; out.d = { kind: 'edit', file: i.file_path, old: clip(e.old_string, 500), new: clip(e.new_string, 500) }; break; }
|
|
37
63
|
case 'Write': out.d = { kind: 'write', file: i.file_path, text: clip(i.content, 800) }; break;
|
|
@@ -184,12 +210,13 @@ let boardMemo = { at: 0, rows: [] };
|
|
|
184
210
|
function parseTail(file, st) {
|
|
185
211
|
const sig = st.mtimeMs + ':' + st.size, hit = boardCache.get(file); if (hit && hit.sig === sig) return hit;
|
|
186
212
|
const { text, cut } = readTail(file, 192 * 1024), lines = text.split('\n'); if (cut) lines.shift();
|
|
187
|
-
const pend = new Map(); let lastType = null, lastTool = false, lastTs = 0, custom = (hit && hit.custom) || null, ai = (hit && hit.ai) || null, first = hit ? hit.first : undefined;
|
|
213
|
+
const pend = new Map(); let lastType = null, lastTool = false, lastStop = null, stops = false, esc = false, lastTs = 0, custom = (hit && hit.custom) || null, ai = (hit && hit.ai) || null, first = hit ? hit.first : undefined;
|
|
188
214
|
for (const l of lines) {
|
|
189
215
|
if (!l) continue; let r; try { r = JSON.parse(l); } catch { continue; }
|
|
190
216
|
if (r.type === 'custom-title' && typeof r.customTitle === 'string') custom = r.customTitle; else if (r.type === 'ai-title' && typeof r.aiTitle === 'string') ai = r.aiTitle; // a session is renamed, or named, long after its row was first shown: the latest one read wins
|
|
191
217
|
const t = Date.parse(r.timestamp) || 0, bl = blocks(r);
|
|
192
|
-
if (r.type === 'assistant' || r.type === 'user') { lastType = r.type; lastTool = bl.some((b) => b.type === 'tool_use'); if (t) lastTs = t;
|
|
218
|
+
if (r.type === 'assistant' || r.type === 'user') { lastType = r.type; lastTool = bl.some((b) => b.type === 'tool_use'); lastStop = (r.type === 'assistant' && r.message && r.message.stop_reason) || null; if (lastStop) stops = true; if (t) lastTs = t;
|
|
219
|
+
esc = r.type === 'user' && bl.some((b) => b.type === 'text' && /^\s*\[Request interrupted/i.test(b.text || '')); if (esc) pend.clear(); } // Esc: the turn stops there, and no call is waited for any more
|
|
193
220
|
for (const b of bl) { if (b.type === 'tool_use') pend.set(b.id, { name: b.name, ts: t }); else if (b.type === 'tool_result') pend.delete(b.tool_use_id); }
|
|
194
221
|
}
|
|
195
222
|
if (!hit && !custom) { // first look at this file: a little further back than the lines read above, and without needing whole lines
|
|
@@ -197,7 +224,7 @@ function parseTail(file, st) {
|
|
|
197
224
|
custom = un([...big.matchAll(/"type":"custom-title","customTitle":"((?:[^"\\]|\\.)*)"/g)].pop()); if (!ai) ai = un([...big.matchAll(/"type":"ai-title","aiTitle":"((?:[^"\\]|\\.)*)"/g)].pop());
|
|
198
225
|
}
|
|
199
226
|
if (!custom && !ai && first == null) first = firstPrompt(file) || (st.size > 64 * 1024 ? '' : null); // '' = looked for and not there; a file that has just been created is looked at again
|
|
200
|
-
const out = { sig, title: custom || ai || first || null, custom, ai, first, lastType, lastTool, lastTs, pending: [...pend.values()] }; // a title the person typed wins over the generated one, and both over the first prompt
|
|
227
|
+
const out = { sig, title: custom || ai || first || null, custom, ai, first, lastType, lastTool, lastStop, stops, esc, lastTs, pending: [...pend.values()] }; // a title the person typed wins over the generated one, and both over the first prompt
|
|
201
228
|
boardCache.set(file, out); if (boardCache.size > 200) boardCache.delete(boardCache.keys().next().value); return out;
|
|
202
229
|
}
|
|
203
230
|
function firstPrompt(file) { // the first thing the person typed, read record by record: a pattern over the raw text ran from a user record into the assistant's first answer and took that as the title
|
|
@@ -229,12 +256,14 @@ function boardRows0() {
|
|
|
229
256
|
if (age < 30 * 60e3) {
|
|
230
257
|
if (lp) { ageMs = now - (lp.ts || st.mtimeMs); tool = lp.name;
|
|
231
258
|
state = SUBTOOL.test(lp.name) ? 'waiting' : (ASKS.test(lp.name) && ageMs > 4000) || (APPROVAL.test(lp.name) && ageMs > 15000) ? 'blocked' : 'working'; }
|
|
232
|
-
else if (p.
|
|
259
|
+
else if (p.esc) state = 'turn'; // you stopped it (Esc): it is your turn there, not "working" for the next ten minutes
|
|
260
|
+
else if (p.lastType === 'assistant' && !p.lastTool && p.lastStop !== 'tool_use' && !(p.lastStop == null && p.stops && age < 45000)) state = 'turn'; // a line whose message goes on with a tool call is not the end of the turn: the call is written after it, a long one many seconds after.
|
|
261
|
+
// Claude Code up to 2.1.87 writes that line without saying why it stopped: in a transcript that does say it elsewhere, such a line is given 45 s for its call to come (1 in 100 takes longer than 25 s)
|
|
233
262
|
else state = age < 10 * 60e3 ? 'working' : 'idle';
|
|
234
263
|
}
|
|
235
264
|
let subActive = 0, subTotal = 0;
|
|
236
265
|
for (const x of subFiles(proj, id)) { subTotal++; if (now - mtimeOf(x.file) < 90e3) subActive++; }
|
|
237
|
-
return { proj, id, title: p.title || id, mtime: st.mtimeMs, state, tool, ageMs, subActive, subTotal };
|
|
266
|
+
return { proj, id, title: p.title || id, mtime: st.mtimeMs, state, tool, ageMs, subActive, subTotal, ...(p.esc ? { cut: 1 } : {}) }; // cut: stopped by you, which is no news to tell you
|
|
238
267
|
}).filter(Boolean);
|
|
239
268
|
}
|
|
240
269
|
// Settings live in a file, not only in the page's localStorage: the port changes between VS Code windows and reloads, and localStorage is per origin (port included).
|
|
@@ -316,20 +345,22 @@ function parseRecord(st, r) {
|
|
|
316
345
|
}
|
|
317
346
|
if (r.type === 'user') {
|
|
318
347
|
const items = [], wf = r.toolUseResult && typeof r.toolUseResult === 'object' && typeof r.toolUseResult.runId === 'string' ? r.toolUseResult.runId : ''; // tool results: the real output that appeared on the agent's screen
|
|
348
|
+
if (st.out) for (const b of blocks(r)) if (b.type === 'tool_result') st.out.delete(b.tool_use_id);
|
|
319
349
|
for (const b of blocks(r)) if (b.type === 'tool_result' && wf) push({ ts, agent, kind: 'wfrun', toolId: b.tool_use_id, run: wf }); // the answer to a Workflow call names the run it started: its agents are in subagents/workflows/<run>/
|
|
320
350
|
for (const b of blocks(r)) if (b.type === 'tool_result' && (st.toolName[b.tool_use_id] === 'Agent' || st.toolName[b.tool_use_id] === 'Task') && !(st.bg && st.bg[b.tool_use_id]) && !/^\s*Async agent launched/i.test(resultText(b.content))) push({ ts, agent, kind: 'agentdone', toolId: b.tool_use_id }); // a synchronous call: the lead got the sub-agent's answer back, so it has finished (async launches answer immediately and are not a completion)
|
|
321
351
|
for (const b of blocks(r)) if (b.type === 'tool_result' && st.toolName[b.tool_use_id] && !NO_RESULT.has(st.toolName[b.tool_use_id])) {
|
|
322
|
-
const n = st.toolName[b.tool_use_id], img = resultImages(b.content).length;
|
|
323
|
-
items.push({ id: b.tool_use_id, err: !!b.is_error, out: clip(resultText(b.content).replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '').trimEnd(), RESULT_MAX[n] || (/^mcp__/.test(n) ? 900 : 600)), ...(img ? { img } : {}) }); // img: how many pictures came back; the page fetches them from /api/media
|
|
352
|
+
const n = st.toolName[b.tool_use_id], img = resultImages(b.content).length, files = n === 'Bash' && !b.is_error ? docPaths(resultText(b.content), false).map((f) => absPath(f, r.cwd)) : [];
|
|
353
|
+
items.push({ id: b.tool_use_id, err: !!b.is_error, out: clip(resultText(b.content).replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '').trimEnd(), RESULT_MAX[n] || (/^mcp__/.test(n) ? 900 : 600)), ...(img ? { img } : {}), ...(files.length ? { files } : {}) }); // img: how many pictures came back; the page fetches them from /api/media · files: the documents a command says it made
|
|
324
354
|
}
|
|
325
355
|
if (items.length) push({ ts, agent, kind: 'results', items });
|
|
326
356
|
const typed = blocks(r).filter((b) => b.type === 'text').map((b) => b.text).join('\n').replace(HARNESS, ''), cut = /^\s*\[Request interrupted[^\]]*\]/i.test(typed); // what the human typed, without the blocks the harness wraps around it
|
|
327
357
|
if (agent !== 'main') { if (!st.prompt && typed.trim() && !st.raw.length) st.prompt = { ts, text: typed.trim() }; return; } // a sub-agent's first user message is the order, emitted from the parent's side (kept here for the agents of a workflow, whose order is in no other file)
|
|
328
|
-
if (cut && st.act >= 0) st.raw[st.act].end = 1; // Esc: the turn stops there, without the end_turn mark. The last thing the lead said or did closes it
|
|
358
|
+
if (cut && st.out) st.out.clear(); if (cut && st.act >= 0) st.raw[st.act].end = 1; // Esc: the turn stops there, without the end_turn mark. The last thing the lead said or did closes it
|
|
329
359
|
const txt = typed.replace(/^\s*\[Request interrupted[^\]]*\]\s*/i, '').trim();
|
|
330
|
-
if (txt && !/^<(system-reminder|command-|local-command|task-notification)/.test(txt) && !r.isMeta && !r.isCompactSummary) push({ ts, agent: 'user', kind: 'user', text: txt }); // not the summary Claude Code writes when it compacts: thousands of characters the human never typed
|
|
360
|
+
if (txt && !/^<(system-reminder|command-|local-command|task-notification)/.test(txt) && !r.isMeta && !r.isCompactSummary) { if (st.out) st.out.clear(); push({ ts, agent: 'user', kind: 'user', text: txt }); } // a call that never got its answer is not waited for across your next message · not the summary Claude Code writes when it compacts: thousands of characters the human never typed
|
|
331
361
|
} else if (r.type === 'assistant') {
|
|
332
362
|
const m = r.message || {}; let said = null;
|
|
363
|
+
if (agent === 'main') { st.lead = 1; if (m.stop_reason) st.stops = 1; } // this transcript says why each message stopped: its turns end with a mark, and until one comes the lead is at work (see marks, below)
|
|
333
364
|
if (m.id && m.usage) { // the same message is repeated once per content block with identical numbers: keep one per message id
|
|
334
365
|
const u = m.usage, prev = st.msgUsage.get(m.id);
|
|
335
366
|
st.msgUsage.set(m.id, { ts: prev ? prev.ts : ts, u: { i: u.input_tokens || 0, o: u.output_tokens || 0, r: u.cache_read_input_tokens || 0, w: u.cache_creation_input_tokens || 0 }, model: m.model });
|
|
@@ -339,12 +370,12 @@ function parseRecord(st, r) {
|
|
|
339
370
|
if (b.type === 'thinking' && typeof b.thinking === 'string' && b.thinking.trim()) st.th = clip(b.thinking.replace(/[^\S\n]+/g, ' ').replace(/ ?\n[\n ]*/g, '\n').trim(), 900); // line breaks are kept: each line of its notes is a thought of its own
|
|
340
371
|
else if (b.type === 'text' && typeof b.text === 'string' && b.text.trim()) { said = push({ ts, agent, kind: 'say', text: b.text.trim(), ...th() }); st.act = st.raw.length - 1; st.sayOf = m.id; st.sayAt = st.act; }
|
|
341
372
|
else if (b.type === 'tool_use') {
|
|
342
|
-
st.toolName[b.id] = b.name; if (b.input && b.input.run_in_background) (st.bg = st.bg || {})[b.id] = true;
|
|
373
|
+
st.toolName[b.id] = b.name; (st.out = st.out || new Set()).add(b.id); if (b.input && b.input.run_in_background) (st.bg = st.bg || {})[b.id] = true; // out: the calls that have no answer yet
|
|
343
374
|
if (b.name === 'Agent' || b.name === 'Task') push({ ts, agent, kind: 'agentcall', toolId: b.id, bg: !!(b.input && b.input.run_in_background), text: (b.input && b.input.prompt) || '', title: (b.input && b.input.description) || '', ...(b.input && typeof b.input.name === 'string' && b.input.name.trim() ? { nm: b.input.name.trim() } : {}) });
|
|
344
|
-
else { push({ ts, agent, kind: 'tool', tool
|
|
375
|
+
else { const tool = toolLabel(b, ts); if (tool.d && tool.d.outs) tool.d.outs = tool.d.outs.map((f) => absPath(f, r.cwd)); push({ ts, agent, kind: 'tool', tool, ...th() }); st.act = st.raw.length - 1; }
|
|
345
376
|
}
|
|
346
377
|
}
|
|
347
|
-
if (agent === 'main' && m.stop_reason === 'end_turn') { // the lead's turn is over: Claude Code writes one record per content block, each with the message's stop reason, so the mark goes on the line this record carries (a thinking block carries none)
|
|
378
|
+
if (agent === 'main' && (m.stop_reason === 'end_turn' || ((r.isApiErrorMessage || (m.model === '<synthetic>' && m.stop_reason === 'stop_sequence')) && !(st.out && st.out.size)))) { // also a turn that ends on a message Claude Code writes itself, in the place of the model's: the API is down, the limit is reached, the request was refused, or there was nothing to answer. Nothing follows it, unless a call of the lead is still out: the connection dropped while its agents worked, and it goes on when they answer. (A message of the model that a safety check cuts is not the end either: Claude Code tells the model, which goes on.) The lead's turn is over: Claude Code writes one record per content block, each with the message's stop reason, so the mark goes on the line this record carries (a thinking block carries none)
|
|
348
379
|
if (!said && m.id && st.sayOf === m.id) said = st.raw[st.sayAt]; // ...or on the line the same message brought in an earlier record
|
|
349
380
|
if (said) said.end = 1;
|
|
350
381
|
}
|
|
@@ -420,7 +451,8 @@ function buildTimeline(proj, id, files = []) {
|
|
|
420
451
|
else { merged.push(e.kind === 'tool' ? { ts: e.ts, agent: e.agent, kind: 'tools', tools: [e.tool], ...(e.end ? { end: 1 } : {}), ...(e.th ? { th: e.th } : {}), k: e.k } : e); lastReal = merged.length - 1; }
|
|
421
452
|
}
|
|
422
453
|
const real = merged.find((e) => e.kind !== 'usage' && e.kind !== 'finish' && e.kind !== 'compact'), first = real ? real.ts : 0, last = merged.length ? merged[merged.length - 1].ts : 0; // time zero = the first thing said or done
|
|
423
|
-
|
|
454
|
+
const marks = !sx && states[0] && (states[0].stops || !states[0].lead) ? { marks: 1 } : {}; // a Claude Code session whose turns end with a mark, also before the lead has written anything: a session that has not closed a turn yet is not one without marks, and its lead is not "done" each time it thinks for a while
|
|
455
|
+
return { id, proj, agents: Object.values(agents), events: merged.map((e) => ({ ...e, t: Math.max(0, e.ts - first) })), durationMs: last - first, recentUntil, ...marks };
|
|
424
456
|
}
|
|
425
457
|
|
|
426
458
|
// Ask the local `claude` CLI (uses the user's existing login) to map a JSON array of strings to another array. Cached.
|
|
@@ -606,6 +638,30 @@ function listCharacters(pack) {
|
|
|
606
638
|
return { stem: st, file: f, talk: by.get(l + '-talk') || null, role: /^(lead|claude)$/.test(l) ? 'lead' : /^(you|human|user)$/.test(l) ? 'you' : 'agent' }; }).sort((a, b) => a.stem.localeCompare(b.stem));
|
|
607
639
|
return { dir, max: CHAR_MAX, chars };
|
|
608
640
|
}
|
|
641
|
+
// ---- Shared files: a file the session created is shown in its folder (Finder, Explorer, the file manager) when the page asks. Only a file a Write call of that very session names, and only if it is still there:
|
|
642
|
+
// the page cannot have any other path opened, nothing is read and nothing is run. A Codex or Vibe session may name a file from the folder it was started in.
|
|
643
|
+
// The same goes for a document one of its commands names (an export, a report made by a script), from the moment that command started: an older file by that name is not one of its files.
|
|
644
|
+
function sessionFile(proj, id, file) { // { fp: where it is, since: 0 for a file it wrote, else when the first command that names it started }
|
|
645
|
+
const sx = sourceOf(proj); if (!(sx ? guard(() => sx.fileOf(id), null) : fs.existsSync(path.join(ROOT, proj, id + '.jsonl')))) return null;
|
|
646
|
+
const ev = timeline(proj, id).events, said = new Set(); let since = ev.some((e) => e.kind === 'tools' && e.tools.some((t) => t.d && t.d.kind === 'write' && t.d.file === file)) ? 0 : null;
|
|
647
|
+
if (since == null) {
|
|
648
|
+
for (const e of ev) if (e.kind === 'results') for (const it of e.items) if (it.files && it.files.includes(file)) said.add(it.id); // named in what a command printed: counted from when that command started
|
|
649
|
+
for (const e of ev) if (e.kind === 'tools' && e.tools.some((t) => said.has(t.id) || (t.d && t.d.kind === 'cmd' && t.d.outs && t.d.outs.includes(file)))) since = since == null ? e.ts || 1 : Math.min(since, e.ts || 1);
|
|
650
|
+
}
|
|
651
|
+
if (since == null || (since && ev.some((e) => e.kind === 'tools' && e.tools.some((t) => t.d && t.d.kind === 'edit' && t.d.file === file)))) return null; // a file the session changed by hand is recent for that reason: a command that names it did not make it
|
|
652
|
+
if (path.isAbsolute(file)) return { fp: path.normalize(file), since };
|
|
653
|
+
const cwd = sx && sx.cwd ? guard(() => sx.cwd(id), '') : ''; return cwd ? { fp: path.resolve(cwd, file), since } : null;
|
|
654
|
+
}
|
|
655
|
+
const reveal = { // run and stat: replaced in the tests, which must not open a window nor write a file outside their folder
|
|
656
|
+
stat: (f) => fs.statSync(f),
|
|
657
|
+
cmds(file, platform = process.platform) { // one or two commands: the second is tried when the first fails
|
|
658
|
+
if (platform === 'darwin') return [['open', ['-R', file]]];
|
|
659
|
+
if (platform === 'win32') return [['explorer.exe', ['/select,"' + file + '"'], { windowsVerbatimArguments: true }]]; // Explorer wants the quotes around the path only (no file name holds a quote on Windows)
|
|
660
|
+
const dir = ['xdg-open', [path.dirname(file)]]; // Linux: the file manager is asked to select the file; one that cannot do it opens the folder (as does a name with a comma, which dbus-send would read as two files)
|
|
661
|
+
return file.includes(',') ? [dir] : [['dbus-send', ['--session', '--dest=org.freedesktop.FileManager1', '--type=method_call', '--print-reply', '/org/freedesktop/FileManager1', 'org.freedesktop.FileManager1.ShowItems', 'array:string:' + require('url').pathToFileURL(file).href, 'string:'], { timeout: 3000 }], dir];
|
|
662
|
+
},
|
|
663
|
+
run(file) { const go = (list) => { const c = list[0]; if (!c) return; try { execFile(c[0], c[1], c[2] || {}, (err) => { if (err) go(list.slice(1)); }); } catch { go(list.slice(1)); } }; go(reveal.cmds(file)); },
|
|
664
|
+
};
|
|
609
665
|
let audioOwner = { id: null, seen: 0 };
|
|
610
666
|
function start(port = PORT) {
|
|
611
667
|
return http.createServer((req, res) => {
|
|
@@ -662,6 +718,16 @@ function start(port = PORT) {
|
|
|
662
718
|
if (url.pathname === '/api/board') return json(boardRows());
|
|
663
719
|
if (url.pathname === '/api/characters') return json(listCharacters(url.searchParams.get('pack') || ''));
|
|
664
720
|
if (url.pathname === '/api/packs') return json(Object.keys(PACKS).map((name) => ({ name, n: listCharacters(name).chars.length })));
|
|
721
|
+
if (url.pathname === '/api/reveal' && req.method === 'POST') return readBody((body) => { // 404: not a file this session created · 410: created, and no longer there
|
|
722
|
+
try {
|
|
723
|
+
let b = null; try { b = JSON.parse(body); } catch {} const SAFE = /^[\w.\-]+$/, ok = (v) => typeof v === 'string' && SAFE.test(v) && v !== '..' && v.length <= 200;
|
|
724
|
+
if (!b || !ok(b.proj) || !ok(b.id) || typeof b.file !== 'string' || !b.file || b.file.length > 4096) return json({ error: 'bad request' }, 400);
|
|
725
|
+
const f = sessionFile(b.proj, b.id, b.file); if (!f) return json({ error: 'not a file of this session' }, 404);
|
|
726
|
+
let st = null; try { st = reveal.stat(f.fp); } catch {} if (!st || !st.isFile()) return json({ error: 'gone' }, 410);
|
|
727
|
+
if (f.since && st.mtimeMs < f.since - 2000) return json({ error: 'not a file of this session' }, 404); // a command names it, and it was there before: read, listed or removed, not made
|
|
728
|
+
if (b.check !== true) reveal.run(f.fp); json({ ok: true }); // check: the page asks whether a document a command names is there, before it shows it
|
|
729
|
+
} catch (e) { json({ error: String(e.message || e) }, 500); }
|
|
730
|
+
});
|
|
665
731
|
if (url.pathname === '/api/media') {
|
|
666
732
|
const q = (k) => url.searchParams.get(k) || '', SAFE = /^[\w.\-]+$/, n = +q('n') || 0, bad = [q('proj'), q('id'), q('agent'), q('tool')].some((v) => !SAFE.test(v) || v === '..' || v.length > 200) || q('tool').length < 6; // no tool call has an id that short, and looking for one meant reading the whole transcript
|
|
667
733
|
const file = bad || !Number.isInteger(n) || n < 0 || n > 9 ? null : mediaFile(q('proj'), q('id'), q('agent')), im = file && toolImage(file, q('tool'), n);
|
|
@@ -683,8 +749,8 @@ function start(port = PORT) {
|
|
|
683
749
|
}
|
|
684
750
|
if (ep == null) return json({ id: tl.id, agents: tl.agents, total: tl.events.length, events: tl.events.slice(+after) }); // a page loaded before 1.25.7 still asks by position
|
|
685
751
|
const a = +after; if (ep !== tl.ep || !(a >= 0 && a <= tl.seq)) return json({ resync: true }); // not the feed this page was following (restart, session dropped from memory, transcript rewritten): it loads the session again
|
|
686
|
-
if (a === tl.seq) { if (!entry.idle) entry.idle = JSON.stringify({ id: tl.id, agents: tl.agents, ep: tl.ep, seq: tl.seq, events: [] }); res.writeHead(200, { 'content-type': 'application/json' }); return res.end(entry.idle); } // nothing new, which is the answer to nearly every poll: written once
|
|
687
|
-
return json({ id: tl.id, agents: tl.agents, ep: tl.ep, seq: tl.seq, events: feedSince(entry, a) }); // new events and changed ones alike, whole, under the key they always had
|
|
752
|
+
if (a === tl.seq) { if (!entry.idle) entry.idle = JSON.stringify({ id: tl.id, agents: tl.agents, ep: tl.ep, seq: tl.seq, marks: tl.marks, events: [] }); res.writeHead(200, { 'content-type': 'application/json' }); return res.end(entry.idle); } // nothing new, which is the answer to nearly every poll: written once
|
|
753
|
+
return json({ id: tl.id, agents: tl.agents, ep: tl.ep, seq: tl.seq, marks: tl.marks, events: feedSince(entry, a) }); // new events and changed ones alike, whole, under the key they always had
|
|
688
754
|
}
|
|
689
755
|
const pk = url.pathname.match(/^\/packs\/([a-z]+)\/(.*)$/);
|
|
690
756
|
if (url.pathname.startsWith('/characters/') || (pk && packDir(pk[1]))) { // only plain image files of the characters folder (or of a built-in pack), by exact name
|
|
@@ -701,7 +767,7 @@ function start(port = PORT) {
|
|
|
701
767
|
} catch (e) { if (res.headersSent) return res.destroy(); json({ error: String(e.message || e) }, 500); }
|
|
702
768
|
}).listen(port, '127.0.0.1', function () { console.log(`Agent Standup → http://localhost:${this.address().port}`); });
|
|
703
769
|
}
|
|
704
|
-
module.exports = { start, currentSession, shutdown, findClaude, bundledClaude, boardRows, charactersDir, listCharacters };
|
|
770
|
+
module.exports = { start, currentSession, shutdown, findClaude, bundledClaude, boardRows, sessionRows: listSessions, charactersDir, listCharacters, _reveal: reveal };
|
|
705
771
|
if (require.main === module) {
|
|
706
772
|
start().on('error', (e) => {
|
|
707
773
|
console.error(e.code === 'EADDRINUSE' ? `Port ${PORT} is already in use (maybe Agent Standup is already running, e.g. inside VS Code). Try: PORT=4790 node server.js` : String(e));
|
package/vibe.js
CHANGED
|
@@ -74,6 +74,7 @@ function meta(dir) {
|
|
|
74
74
|
// The sessions a person started, newest first, each with the folder it was started in.
|
|
75
75
|
function sessions(limit = 80) { return scan().rows.slice(0, limit).map((r) => { const m = meta(r.dir); return { ...r, cwd: m.cwd, key: dirKey(m.cwd) }; }); } // meta.json is written in both formats
|
|
76
76
|
const inProject = (id, key) => { const r = row(id); if (!r || !key) return false; if (key === PROJ) return true; const d = dirKey(meta(r.dir).cwd); return d === key || d.startsWith(key + '-'); };
|
|
77
|
+
const cwd = (id) => { const r = row(id); return r ? meta(r.dir).cwd : ''; }; // the folder the session was started in: where a file it names by a relative path is
|
|
77
78
|
const projectLabel = (cwd) => { const h = os.homedir(), rel = cwd && cwd.startsWith(h + path.sep) ? cwd.slice(h.length + 1) : cwd; return 'Mistral Vibe' + (rel ? ' · ' + rel.split(path.sep).join('/') : ''); };
|
|
78
79
|
|
|
79
80
|
// ---- names: the title Vibe gave the session, else the first thing the person typed
|
|
@@ -319,4 +320,4 @@ function parser({ toolLabel, clip, resultMax = {} }) {
|
|
|
319
320
|
};
|
|
320
321
|
return record;
|
|
321
322
|
}
|
|
322
|
-
module.exports = { PROJ, SOURCE, home, dirKey, sessions, row, fileOf, inProject, projectLabel, title, boardRow, subFiles, subCount, watch, state, parser };
|
|
323
|
+
module.exports = { PROJ, SOURCE, home, dirKey, sessions, row, fileOf, cwd, inProject, projectLabel, title, boardRow, subFiles, subCount, watch, state, parser };
|