@double_geste/agent-standup 1.43.1 → 1.45.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/bin/agent-standup.js +3 -0
- package/package.json +2 -1
- package/public/index.html +158 -52
- package/public/locales/da.json +23 -2
- package/public/locales/de.json +23 -2
- package/public/locales/en.json +23 -2
- package/public/locales/es.json +23 -2
- package/public/locales/ja.json +23 -2
- package/public/locales/ko.json +23 -2
- package/public/locales/pt-BR.json +23 -2
- package/public/locales/zh-CN.json +23 -2
- package/public/locales/zh-TW.json +23 -2
- package/reply.js +51 -0
- package/server.js +13 -3
package/server.js
CHANGED
|
@@ -8,12 +8,14 @@ const os = require('os');
|
|
|
8
8
|
const crypto = require('crypto');
|
|
9
9
|
const codex = require('./codex.js'); // Codex sessions, read as the same call (see codex.js)
|
|
10
10
|
const vibe = require('./vibe.js'); // Mistral Vibe sessions, the same way (see vibe.js)
|
|
11
|
+
const reply = require('./reply.js'); // the human's line, typed into the session's tmux pane (see reply.js); off unless AGENT_STANDUP_REPLY=on
|
|
11
12
|
const SOURCES = [codex, vibe], sourceOf = (proj) => SOURCES.find((m) => m.PROJ === proj) || null, guard = (fn, or) => { try { return fn(); } catch (e) { logError('reader', e); return or; } }; // guard: a session of another tool that cannot be read costs that session, never the list // the tools other than Claude Code: each lists its sessions under one made-up project
|
|
12
13
|
const kokoro = require('./kokoro.js'); // natural voices, installed on demand (see kokoro.js)
|
|
13
14
|
const zlib = require('zlib');
|
|
14
15
|
const { execFileSync, execFile } = require('child_process');
|
|
15
16
|
|
|
16
17
|
const PORT = process.env.PORT || 4747;
|
|
18
|
+
const REPLY_TOKEN = crypto.randomBytes(24).toString('hex'), replyTokenOk = (t) => { if (typeof t !== 'string') return false; const a = Buffer.from(t), b = Buffer.from(REPLY_TOKEN); return a.length === b.length && crypto.timingSafeEqual(a, b); }; // made at each start, given only to the page through /api/prefs.js
|
|
17
19
|
// Same place Claude Code writes to: honours CLAUDE_CONFIG_DIR (custom config dirs are common on Linux); AGENT_STANDUP_PROJECTS overrides it.
|
|
18
20
|
const CLAUDE_HOME = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), ONE_FOLDER = !!process.env.AGENT_STANDUP_PROJECTS, EXTRA_HOMES = String(process.env.AGENT_STANDUP_CLAUDE_DIRS || '');
|
|
19
21
|
const ROOT = process.env.AGENT_STANDUP_PROJECTS || path.join(CLAUDE_HOME, 'projects');
|
|
@@ -596,11 +598,12 @@ const alive = (pid) => { try { process.kill(pid, 0); return true; } catch (e) {
|
|
|
596
598
|
function liveStatus() { // session id → { status, since, pid, ep (where it runs: claude-vscode, cli, claude-desktop, sdk-cli…), and for missingTranscripts: raw (the status as written), cwd, kind, startedAt, version, updatedAt (when the file was last written: a /clear moves it, and the id, but not statusUpdatedAt) }
|
|
597
599
|
const out = new Map(), later = (a, b) => Math.max(a.updatedAt, a.since) > Math.max(b.updatedAt, b.since);
|
|
598
600
|
for (const [i, dir] of statusDirs().entries()) { const into = i ? new Map() : out; let names = []; try { names = fs.readdirSync(dir); } catch { continue; }
|
|
599
|
-
for (const n of names) { if (!/^\d+\.json$/.test(n)) continue; try { const s = JSON.parse(fs.readFileSync(path.join(dir, n), 'utf8')); if (s && typeof s.sessionId === 'string' && /^(busy|idle|waiting)$/.test(s.status) && Number.isInteger(s.pid) && s.pid > 0 && alive(s.pid)) into.set(s.sessionId, { status: s.status !== 'waiting' ? s.status : s.waitingFor === 'dialog open' ? 'idle' : s.entrypoint === 'sdk-cli' ? 'busy' : s.status, since: Number(s.statusUpdatedAt) || 0, pid: s.pid, ep: String(s.entrypoint || ''), raw: s.status, cwd: typeof s.cwd === 'string' ? s.cwd : '', kind: typeof s.kind === 'string' ? s.kind : '', startedAt: Number(s.startedAt) || 0, version: typeof s.version === 'string' ? s.version : '', updatedAt: Number(s.updatedAt) || 0 }); } catch {} } /* a dialog you opened yourself (/model, /config, /mcp…) also says waiting: it is not a question for you. Nor is a menu of a session started with claude -p (entrypoint sdk-cli): its question goes to the program that started it. An Agent SDK host (sdk-ts, sdk-py: Zed, a home-made app) may show its menus to a person, so those are kept */
|
|
601
|
+
for (const n of names) { if (!/^\d+\.json$/.test(n)) continue; try { const s = JSON.parse(fs.readFileSync(path.join(dir, n), 'utf8')); if (s && typeof s.sessionId === 'string' && /^(busy|idle|waiting)$/.test(s.status) && Number.isInteger(s.pid) && s.pid > 0 && alive(s.pid)) into.set(s.sessionId, { status: s.status !== 'waiting' ? s.status : s.waitingFor === 'dialog open' ? 'idle' : s.entrypoint === 'sdk-cli' ? 'busy' : s.status, since: Number(s.statusUpdatedAt) || 0, pid: s.pid, ep: String(s.entrypoint || ''), raw: s.status, cwd: typeof s.cwd === 'string' ? s.cwd : '', kind: typeof s.kind === 'string' ? s.kind : '', startedAt: Number(s.startedAt) || 0, version: typeof s.version === 'string' ? s.version : '', updatedAt: Number(s.updatedAt) || 0, procStart: s.procStart, name: typeof s.name === 'string' ? s.name : '' }); } catch {} } /* a dialog you opened yourself (/model, /config, /mcp…) also says waiting: it is not a question for you. Nor is a menu of a session started with claude -p (entrypoint sdk-cli): its question goes to the program that started it. An Agent SDK host (sdk-ts, sdk-py: Zed, a home-made app) may show its menus to a person, so those are kept */
|
|
600
602
|
if (i) { const byPid = new Map([...out].map(([k, v]) => [v.pid, k])); for (const [k, v] of into) { const o = out.get(k), pk = byPid.get(v.pid), p = pk != null && pk !== k ? out.get(pk) : null; if ((o && !later(v, o)) || (p && !later(v, p))) continue; if (p) out.delete(pk); out.set(k, v); byPid.set(v.pid, k); } } // a folder copied while a session ran keeps its status frozen: of two that name the same session, or the same process (its id changed since with /clear), the one written last
|
|
601
603
|
}
|
|
602
604
|
return out;
|
|
603
605
|
}
|
|
606
|
+
reply.use(liveStatus); // reply.js finds the session to type into with this same reader (procStart: to tell a reused pid, name: the recipient shown)
|
|
604
607
|
// A Claude Code session that is open and has worked, yet whose transcript is nowhere in the projects folder read here. The call cannot show it; the page says so, and why it may be (issue #9). Read from the status files alone, nothing sent.
|
|
605
608
|
// Only one cause is visible this way (Claude Code 2.1.304, tried): CLAUDE_CODE_SKIP_PROMPT_HISTORY=1 writes the status file (interactive, idle/busy) and shows "Transcript saving is off", but no transcript.
|
|
606
609
|
// An inherited CLAUDE_CODE_CHILD_SESSION=1 writes neither, and another CLAUDE_CONFIG_DIR puts the status file in that other folder: neither leaves anything here (that folder is read too when it is one of claudeHomes). What is listed may also be a cause not known yet.
|
|
@@ -1499,7 +1502,7 @@ function start(port = PORT) {
|
|
|
1499
1502
|
const sendFile = (fp) => { const s = fs.createReadStream(fp); s.on('error', () => res.destroy()); s.pipe(res); }; // a file that vanished between the check and the read ends this answer, not the server
|
|
1500
1503
|
// Endpoints with side effects (they spawn programs or claim the sound), and the one that serves pictures from a session, refuse requests that a browser marks as coming from another site, e.g. an <img> on a web page.
|
|
1501
1504
|
const sfs = req.headers['sec-fetch-site'];
|
|
1502
|
-
if (sfs && sfs !== 'same-origin' && sfs !== 'none' && (req.method !== 'GET' || ['/api/translate', '/api/quips', '/api/warm', '/api/audio', '/api/tts', '/api/prefs', '/api/prefs.js', '/api/voices', '/api/kokoro', '/api/kokoro/install', '/api/media', '/api/taskout', '/api/artifact', '/api/errors', '/api/packs', '/api/update'].includes(url.pathname))) { res.writeHead(403); return res.end('forbidden'); }
|
|
1505
|
+
if (sfs && sfs !== 'same-origin' && sfs !== 'none' && (req.method !== 'GET' || ['/api/translate', '/api/quips', '/api/warm', '/api/audio', '/api/tts', '/api/prefs', '/api/prefs.js', '/api/voices', '/api/kokoro', '/api/kokoro/install', '/api/media', '/api/taskout', '/api/artifact', '/api/errors', '/api/packs', '/api/update', '/api/reply'].includes(url.pathname))) { res.writeHead(403); return res.end('forbidden'); }
|
|
1503
1506
|
const readBody = (cb, max = 262144) => { // request bodies are small JSON: stop reading beyond 256 KB (or max) and give up after 10 s
|
|
1504
1507
|
const chunks = []; let size = 0, over = false; req.setTimeout(10000, () => req.destroy());
|
|
1505
1508
|
if (+req.headers['content-length'] > max) { res.writeHead(413); res.end('too large'); return req.destroy(); }
|
|
@@ -1537,7 +1540,7 @@ function start(port = PORT) {
|
|
|
1537
1540
|
.then((f) => { res.writeHead(200, { 'content-type': 'audio/wav', 'cache-control': 'max-age=86400' }); sendFile(f); })
|
|
1538
1541
|
.catch((e) => json({ error: String(e.message) }, 400));
|
|
1539
1542
|
}
|
|
1540
|
-
if (url.pathname === '/api/prefs.js') { res.writeHead(200, { 'content-type': 'application/javascript', 'cache-control': 'no-store' }); return res.end('window.SAVED_PREFS = ' + JSON.stringify(readPrefs()).replace(/</g, '\\u003c') + '; window.AS_APP = ' + JSON.stringify(appKind()).replace(/</g, '\\u003c') + ';'); }
|
|
1543
|
+
if (url.pathname === '/api/prefs.js') { res.writeHead(200, { 'content-type': 'application/javascript', 'cache-control': 'no-store' }); return res.end('window.SAVED_PREFS = ' + JSON.stringify(readPrefs()).replace(/</g, '\\u003c') + '; window.AS_APP = ' + JSON.stringify(appKind()).replace(/</g, '\\u003c') + ';' + (reply.on() ? 'window.REPLY_TOKEN = "' + REPLY_TOKEN + '";' : '')); }
|
|
1541
1544
|
if (url.pathname === '/api/prefs' && req.method === 'PUT') return readBody((body) => { try { let v = JSON.parse(body); if (!v || typeof v !== 'object' || Array.isArray(v)) throw new Error('prefs must be an object'); const cur = readPrefs() || {}; const pt = v._patch && typeof v._patch === 'object' && !Array.isArray(v._patch) ? v._patch : null, set = pt && pt.set && typeof pt.set === 'object' && !Array.isArray(pt.set) ? pt.set : {}; if (pt && (!('_t' in set) || !('_t' in v) || +set._t === +v._t)) { const del = Array.isArray(pt.del) ? pt.del : []; v = { ...cur, ...set }; for (const k of del) if (typeof k === 'string' && !(k in set)) delete v[k]; } delete v._patch; /* a patch dated otherwise than the settings it came with is a stale copy (a page before 1.42 that read one from the file): those settings are written whole */ /* a page sends what it changed, merged into the file as it is now: a window opened earlier no longer puts back what another one changed. A whole object (an older page) still replaces the file */ if ((+cur.shareUsageT || 0) > (+v.shareUsageT || 0)) { v.shareUsage = cur.shareUsage; v.shareUsageT = cur.shareUsageT; v.usageAsked = cur.usageAsked; } if ((+cur.updateNoticeT || 0) > (+v.updateNoticeT || 0)) { v.updateNotice = cur.updateNotice; v.updateNoticeT = cur.updateNoticeT; v.updateAsked = cur.updateAsked; } writePrefs(v); /* the usage answer: a page opened before it was changed elsewhere (another tab, the desktop app) writes back its old settings, not its old answer */ json({ ok: true }); } catch (e) { json({ error: String(e.message || e) }, 400); } });
|
|
1542
1545
|
if (url.pathname === '/api/prefs') return json(readPrefs() || {});
|
|
1543
1546
|
if (url.pathname === '/api/answer' && req.method === 'POST') return readBody((body) => { let v = {}; try { v = JSON.parse(body); } catch {} json(answerIn(String((v && v.id) || ''))); }); /* a click on what needs you: open it where it can be answered (answerIn) */
|
|
@@ -1588,6 +1591,13 @@ function start(port = PORT) {
|
|
|
1588
1591
|
const body = Buffer.from((/^\s*<!doctype/i.test(page.html) ? '' : '<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">') + page.html, 'utf8'); // an artifact is published as the inside of a page: claude.ai adds the rest, and so does this
|
|
1589
1592
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'content-length': body.length, 'content-security-policy': artifactCsp(q('net') === '1'), 'x-content-type-options': 'nosniff', 'referrer-policy': 'no-referrer', 'cache-control': 'private, no-store' }); return res.end(body);
|
|
1590
1593
|
}
|
|
1594
|
+
if (url.pathname === '/api/reply') { // the human's line: can this session hear it (GET), type it into its terminal (POST)
|
|
1595
|
+
if (!reply.on()) { res.writeHead(404); return res.end('not found'); }
|
|
1596
|
+
if (process.platform !== 'linux') return req.method === 'POST' ? json({ error: 'platform' }, 409) : json({ ok: false, why: 'platform' }); // said before the peer check, which cannot work there either
|
|
1597
|
+
const peer = reply.peerUid(req.socket); if (peer == null || peer !== process.getuid()) return json({ error: 'peer' }, 403); // another local user, or a process we cannot tell: the token alone is readable by anyone who can reach the port
|
|
1598
|
+
if (req.method === 'POST') return readBody((body) => { let b = {}; try { b = JSON.parse(body) || {}; } catch {} if (!replyTokenOk(b.token)) return json({ error: 'token' }, 403); reply.send(String(b.id || ''), b.text).then((r) => json(r, r.ok ? 200 : r.error === 'text' ? 400 : 409), (e) => { logError('reply', e); json({ error: 'tmux' }, 500); }); }, 16384);
|
|
1599
|
+
return reply.lookup(url.searchParams.get('id') || '').then(({ pane, ...r }) => json(r), (e) => { logError('reply', e); json({ ok: false, why: 'tmux' }); });
|
|
1600
|
+
}
|
|
1591
1601
|
if (url.pathname === '/api/session') {
|
|
1592
1602
|
const proj = url.searchParams.get('proj') || '', sid = url.searchParams.get('id') || '', SAFE = /^[\w.\-]+$/;
|
|
1593
1603
|
if (!SAFE.test(proj) || !SAFE.test(sid) || proj === '..' || sid === '..' || proj.length > 200 || sid.length > 200) { res.writeHead(400); return res.end('bad request'); }
|