@dibssoftware/dibs 0.0.178 → 0.0.179
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/CHANGELOG.md +17 -0
- package/README.md +48 -197
- package/bin/dibs.mjs +46 -24
- package/docs/machines.md +1 -1
- package/docs/questions.md +1 -1
- package/docs/reference.md +157 -0
- package/docs/releasing.md +8 -6
- package/docs/scheduling.md +2 -2
- package/package.json +2 -1
- package/skills/dibs/SKILL.md +104 -83
- package/src/acquire.mjs +11 -8
- package/src/alerts.mjs +100 -38
- package/src/answers.mjs +2 -2
- package/src/board.mjs +2 -2
- package/src/commands.mjs +14 -5
- package/src/config.mjs +6 -2
- package/src/diskwarn.mjs +28 -35
- package/src/events.mjs +3 -1
- package/src/files.mjs +27 -4
- package/src/guard.mjs +31 -1
- package/src/hogs.mjs +18 -5
- package/src/news.mjs +101 -0
- package/src/notes.mjs +171 -0
- package/src/notices.mjs +52 -13
- package/src/ondemand.mjs +1 -1
- package/src/override.mjs +22 -13
- package/src/plain.mjs +5 -2
- package/src/preempt.mjs +3 -3
- package/src/primer.mjs +43 -15
- package/src/proc.mjs +4 -3
- package/src/progress.mjs +33 -4
- package/src/schedule.mjs +46 -21
- package/src/serve.mjs +6 -0
- package/src/talk.mjs +199 -20
- package/src/version.mjs +1 -1
- package/src/web.mjs +4 -2
package/src/talk.mjs
CHANGED
|
@@ -24,11 +24,16 @@ import { takeAgent, talkKey } from './files.mjs';
|
|
|
24
24
|
import { asked, forYou } from './questions.mjs';
|
|
25
25
|
import { named, minutes, lower } from './plain.mjs';
|
|
26
26
|
import { bold, dim, columns } from './style.mjs';
|
|
27
|
-
import { die, now, say as note, sleepSync, fakeFull } from './util.mjs';
|
|
27
|
+
import { die, now, say as note, sleepSync, fakeFull, ms, dur, SIGNALS, signalExit } from './util.mjs';
|
|
28
|
+
import { VERSION } from './version.mjs';
|
|
29
|
+
import { newer, since, seenBy, markSeen, diskVersion, latest, toldOf, tell as toldRelease, UPGRADE } from './news.mjs';
|
|
28
30
|
|
|
29
31
|
const FILE = path.join(HOME, 'messages.json');
|
|
30
32
|
const LOCK = path.join(HOME, 'messages.lock');
|
|
31
33
|
export const INBOX = path.join(HOME, 'inbox.json');
|
|
34
|
+
// Who's running dibs listen, by thread key: { pid, pstart, at }. Its own small file, written under
|
|
35
|
+
// this lock, so the guard hook can tell at a stop whether a session is still listening (one read).
|
|
36
|
+
export const LISTENERS = path.join(HOME, 'listeners.json');
|
|
32
37
|
// Writes take milliseconds, so a lock this old belongs to a dibs that died holding it.
|
|
33
38
|
const LOCK_STALE = 5000;
|
|
34
39
|
const LOCK_WAIT = 15e3;
|
|
@@ -45,6 +50,13 @@ const RECENT = 20;
|
|
|
45
50
|
// an hour is stale advice, and it would keep inbox.json around for nothing.
|
|
46
51
|
const NOTICE_LIFE = 36e5;
|
|
47
52
|
|
|
53
|
+
// dibs listen: how long it waits by default, and how often it looks in case a change to
|
|
54
|
+
// messages.json slipped past fs.watch (a rename it didn't report, a volume that doesn't).
|
|
55
|
+
const LISTEN_FOR = 60 * 6e4;
|
|
56
|
+
const LISTEN_POLL = 5000;
|
|
57
|
+
// Its exit code when the time runs out with nothing for it (DIBS_CODES in src/commands.mjs).
|
|
58
|
+
export const LISTEN_TIMEOUT = 3;
|
|
59
|
+
|
|
48
60
|
const STOPS = new Set(['Stop', 'SubagentStop']);
|
|
49
61
|
const MAIN = 'main';
|
|
50
62
|
|
|
@@ -166,7 +178,7 @@ function parse(args) {
|
|
|
166
178
|
for (let i = 0; i < args.length; i++) {
|
|
167
179
|
const a = args[i];
|
|
168
180
|
if (a === '--as') o.as = args[++i] ?? die('--as needs a value');
|
|
169
|
-
else if (a === '--to')
|
|
181
|
+
else if (a === '--to') o.to = args[++i] ?? die('--to needs a value: dibs say --to person "...", or an agent\'s name');
|
|
170
182
|
else if (a === '--json') o.json = true;
|
|
171
183
|
else if (a.startsWith('-') && a.length > 1) die(`unknown flag ${a}. Try: dibs help`);
|
|
172
184
|
else o.words.push(a);
|
|
@@ -182,6 +194,11 @@ function parse(args) {
|
|
|
182
194
|
export function say(args) {
|
|
183
195
|
const o = parse(args);
|
|
184
196
|
if (!o.text) die('say what? dibs say "migration done, tests pass"');
|
|
197
|
+
// dibs say --to <agent> is what people and agents write to reach an agent (2026-11-03): it's a tell.
|
|
198
|
+
if (o.to && o.to !== 'person') {
|
|
199
|
+
const r = send(o.to, o.text);
|
|
200
|
+
{ const d = delivery(r); return console.log(`Sent as a message to ${r.to} (dibs tell ${r.to})${d.startsWith('but ') ? ', ' : ': '}${d}`); }
|
|
201
|
+
}
|
|
185
202
|
const r = locked(s => {
|
|
186
203
|
const th = mine(s, 'say', args, o);
|
|
187
204
|
const t = now();
|
|
@@ -211,16 +228,21 @@ export function noteAs(by, text) {
|
|
|
211
228
|
}, HOOK_LOCK_WAIT);
|
|
212
229
|
}
|
|
213
230
|
|
|
214
|
-
// The thread the person means by name:
|
|
215
|
-
//
|
|
231
|
+
// The thread the person means by name: the running Claude Code session by that name first
|
|
232
|
+
// (the most recently active, if two share it), then a live thread, then the newest that ended.
|
|
233
|
+
// A session's own record outranks an old thread: 2026-11-03, "dibs tell alex-2e" went to
|
|
234
|
+
// a thread with no session while session 8176ff00 by that name was running, and earlier tells
|
|
235
|
+
// went to sessions long dead (a4 to 8e, 30 to b1).
|
|
216
236
|
function target(s, name) {
|
|
217
237
|
const named = names(s.threads);
|
|
218
238
|
const alive = liveness(s.threads);
|
|
219
239
|
const found = s.threads.filter(th => named.get(th.key) === name).sort((a, b) => b.last - a.last);
|
|
220
|
-
const live = found.find(alive);
|
|
221
|
-
if (live) return live;
|
|
222
240
|
const files = sessionFiles().filter(f => f.name === name);
|
|
223
|
-
const
|
|
241
|
+
const up = makeAlive(files.map(f => f.pid));
|
|
242
|
+
const running = files.filter(f => up(f.pid)).sort((a, b) => b.updated - a.updated);
|
|
243
|
+
// A live thread (a subagent's, or a caller's outside Claude Code) only when no session by that name runs.
|
|
244
|
+
const live = found.find(alive);
|
|
245
|
+
if (live && !running.length) return live;
|
|
224
246
|
const f = running[0] || (!found.length && files[0]);
|
|
225
247
|
if (f) {
|
|
226
248
|
const key = keyOf(f.sessionId, name, MAIN);
|
|
@@ -245,32 +267,49 @@ const nobody = (s, name) => {
|
|
|
245
267
|
// dibs tell <agent> "text": the person, or another agent, queues a message for an agent.
|
|
246
268
|
// An agent's message says which agent sent it, never that the person did.
|
|
247
269
|
export function tell(args) {
|
|
248
|
-
|
|
249
|
-
// "desk" is whichever agent config.json names to answer the person (the app's chat).
|
|
250
|
-
if (name === 'desk') name = loadConfig().desk || die('no desk agent is set. Name one in ~/.dibs/config.json: "desk": "<agent name>" (names: dibs threads)');
|
|
270
|
+
const [name, ...rest] = args;
|
|
251
271
|
const o = parse(rest);
|
|
272
|
+
if (o.to) die('--to goes with dibs say. dibs tell <agent> "..." already names who it\'s for');
|
|
252
273
|
if (!name || !o.text) die('tell whom what? dibs tell <agent> "use the staging database" (names: dibs threads)');
|
|
274
|
+
const r = send(name, o.text);
|
|
275
|
+
if (!r.th.session) console.log(`queued for ${r.to}, which isn't a Claude Code session: the hook can't hand it over. It gets it the next time it runs dibs say.`);
|
|
276
|
+
else { const d = delivery(r); console.log(`queued for ${r.to}${d.startsWith('but ') ? ', ' : ': '}${d}`); }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// When a message queued for an agent reaches it.
|
|
280
|
+
const delivery = r => (!r.th.session ? "it isn't a Claude Code session, so it gets it the next time it runs dibs say."
|
|
281
|
+
: !r.alive ? `${r.th.agentId === MAIN ? 'its session has ended' : 'that subagent has finished'}. It stays queued, shown as not delivered, in case it comes back.`
|
|
282
|
+
: r.listening ? "it's listening (dibs listen), so it gets it within seconds."
|
|
283
|
+
// An idle agent makes no tool call and no stop, so nothing hands it over until it works again
|
|
284
|
+
// (2026-11-03: two of the owner's messages sat unread for hours in an idle session).
|
|
285
|
+
: r.idle ? `but ${r.to} is idle and not listening: it won't see this until it next works. Once it runs dibs listen in the background, messages wake it.`
|
|
286
|
+
: 'it gets it with its next tool call, or as it finishes its turn.');
|
|
287
|
+
|
|
288
|
+
// Queue text for the agent called name, from whoever is calling, on the record.
|
|
289
|
+
function send(name, text) {
|
|
290
|
+
// "desk" is whichever agent config.json names to answer the person (the app's chat).
|
|
291
|
+
if (name === 'desk') name = loadConfig().desk || die('no desk agent is set. Name one in ~/.dibs/config.json: "desk": "<agent name>" (names: dibs threads)');
|
|
253
292
|
const who = actor();
|
|
254
293
|
const r = locked(s => {
|
|
255
294
|
const th = target(s, name);
|
|
256
295
|
if (!th) return { no: nobody(s, name) };
|
|
257
296
|
const t = now();
|
|
258
|
-
s.messages.push({ id: ++s.seq, key: th.key, at: t, from: 'person', kind: 'message', text
|
|
297
|
+
s.messages.push({ id: ++s.seq, key: th.key, at: t, from: 'person', kind: 'message', text, state: 'queued',
|
|
259
298
|
session: th.session, agentId: th.agentId, ...(who.agent && { by: who.name }) });
|
|
260
299
|
th.last = t;
|
|
261
|
-
|
|
300
|
+
// Claude Code's own word for whether the session is working now (its session file).
|
|
301
|
+
const status = th.agentId === MAIN ? sessionFiles().find(f => f.sessionId === th.session)?.status || null : null;
|
|
302
|
+
return { th: { ...th }, alive: liveness([th])(th), listening: listening().has(th.key), idle: status === 'idle' };
|
|
262
303
|
});
|
|
263
304
|
if (r.no) die(r.no, 1);
|
|
264
305
|
const to = names([r.th]).get(r.th.key);
|
|
265
306
|
logChange('tell', { to });
|
|
266
|
-
|
|
267
|
-
else if (!r.alive) console.log(`queued for ${to}, but ${r.th.agentId === MAIN ? 'its session has ended' : 'that subagent has finished'}. It stays queued, shown as not delivered, in case it comes back.`);
|
|
268
|
-
else console.log(`queued for ${to}: it gets it with its next tool call, or as it finishes its turn.`);
|
|
307
|
+
return { ...r, to };
|
|
269
308
|
}
|
|
270
309
|
|
|
271
310
|
// Mark one queued message handed over, with a line in the thread saying how.
|
|
272
311
|
const VIA = { tool: 'got it with its next tool call', stop: 'got it as it was finishing, and kept going', say: 'got it when it ran dibs say',
|
|
273
|
-
command: 'got it with its next dibs command' };
|
|
312
|
+
command: 'got it with its next dibs command', listen: 'got it while listening' };
|
|
274
313
|
function handOver(s, m, via, t) {
|
|
275
314
|
Object.assign(m, { state: 'delivered', deliveredAt: t, via });
|
|
276
315
|
if (m.kind === 'notice') return;
|
|
@@ -353,7 +392,10 @@ export function deliver(input, out) {
|
|
|
353
392
|
return mine;
|
|
354
393
|
}, HOOK_LOCK_WAIT));
|
|
355
394
|
if (!text) return out;
|
|
356
|
-
|
|
395
|
+
// additionalContext keeps the agent going with the message as hook feedback.
|
|
396
|
+
// decision: 'block' did too, but Claude Code shows its reason as a "Stop hook
|
|
397
|
+
// blocking error", and agents read the person's message as a failure (2026-11-03).
|
|
398
|
+
if (stop) return { hookSpecificOutput: { hookEventName: input.hook_event_name, additionalContext: text } };
|
|
357
399
|
if (!out) return { hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext: text } };
|
|
358
400
|
const h = out.hookSpecificOutput;
|
|
359
401
|
return { ...out, hookSpecificOutput: { ...h, additionalContext: [h.additionalContext, text].filter(Boolean).join('\n\n') } };
|
|
@@ -373,6 +415,142 @@ export function noticesFor(who) {
|
|
|
373
415
|
} catch { return ''; }
|
|
374
416
|
}
|
|
375
417
|
|
|
418
|
+
// dibs listen [--for 60m] [--json]: for an agent whose turn is over. The hook hands messages over
|
|
419
|
+
// only with a tool call or at a stop, so an idle agent never hears one; this waits until
|
|
420
|
+
// something is queued for it (a message, an answer in words, a notice about its jobs), hands it
|
|
421
|
+
// over under the lock exactly as the hook would, prints it and exits 0. Run with Claude Code's
|
|
422
|
+
// run_in_background, its exit wakes the agent. One listener per thread: a newer one takes over
|
|
423
|
+
// and the older one exits 0 saying so. No message in time: exit 3.
|
|
424
|
+
// listeners.json says who listens, for the board, dibs threads and the hook's reminder at a stop.
|
|
425
|
+
const readListeners = () => { try { return JSON.parse(fs.readFileSync(LISTENERS, 'utf8')); } catch { return {}; } };
|
|
426
|
+
function writeListeners(l) {
|
|
427
|
+
if (!Object.keys(l).length) return fs.rmSync(LISTENERS, { force: true });
|
|
428
|
+
fs.writeFileSync(`${LISTENERS}.tmp`, JSON.stringify(l));
|
|
429
|
+
fs.renameSync(`${LISTENERS}.tmp`, LISTENERS);
|
|
430
|
+
}
|
|
431
|
+
// Said when it hands messages over: listening stops with this run, and the hook reminds the
|
|
432
|
+
// agent at its next stop if it doesn't start again (src/guard.mjs rearm).
|
|
433
|
+
const AGAIN = 'To keep listening, start dibs listen again with run_in_background.';
|
|
434
|
+
export async function listen(args) {
|
|
435
|
+
const o = { for: LISTEN_FOR, json: false, words: [] };
|
|
436
|
+
for (let i = 0; i < args.length; i++) {
|
|
437
|
+
const a = args[i];
|
|
438
|
+
if (a === '--for') o.for = ms(args[++i] ?? die('--for needs a time: dibs listen --for 30m'));
|
|
439
|
+
else if (a === '--json') o.json = true;
|
|
440
|
+
else if (a === '--as') o.as = args[++i] ?? die('--as needs a value');
|
|
441
|
+
else die(`unknown ${a}. dibs listen [--for 60m] [--json]`);
|
|
442
|
+
}
|
|
443
|
+
if (!(o.for > 0)) die('--for needs a time above zero: dibs listen --for 30m');
|
|
444
|
+
const me = { pid: process.pid, pstart: pstart(process.pid), at: now() };
|
|
445
|
+
const th = locked(s => {
|
|
446
|
+
const t = mine(s, 'listen', args, o);
|
|
447
|
+
// The key the what's-new line knows this agent by (bin/dibs.mjs announce).
|
|
448
|
+
t.seenKey = String(identity(o).spid || identity(o).who);
|
|
449
|
+
const l = readListeners();
|
|
450
|
+
const up = makeAlive(Object.values(l).map(x => x.pid));
|
|
451
|
+
// Dead ones stay until a new listener for the same thread replaces them: the hook's reminder
|
|
452
|
+
// at a stop needs to know this session listened before.
|
|
453
|
+
for (const [k, x] of Object.entries(l)) if (!up(x.pid, x.pstart) && now() - x.at > KEEP_FOR) delete l[k];
|
|
454
|
+
l[t.key] = me;
|
|
455
|
+
writeListeners(l);
|
|
456
|
+
return { ...t };
|
|
457
|
+
});
|
|
458
|
+
// Queued for this thread: by session and agent inside Claude Code (as the hook matches), by
|
|
459
|
+
// thread outside it, plus notices left for the name when there's no session.
|
|
460
|
+
const ours = m => m.state === 'queued' && (th.session ? m.session === th.session && m.agentId === th.agentId
|
|
461
|
+
: m.key === th.key || (m.kind === 'notice' && !m.session && m.to === th.who));
|
|
462
|
+
const still = () => readListeners()[th.key]?.pid === me.pid;
|
|
463
|
+
// Gone from the list only when killed: one that ran its course stays, so the hook can tell
|
|
464
|
+
// the agent at its stop that it isn't listening any more.
|
|
465
|
+
const leave = () => { try { locked(() => { const l = readListeners(); if (l[th.key]?.pid === me.pid) { delete l[th.key]; writeListeners(l); } }, HOOK_LOCK_WAIT); } catch {} };
|
|
466
|
+
// Killed (the agent stopped its background task): no listener left behind on the board.
|
|
467
|
+
for (const sig of SIGNALS) process.on(sig, () => { leave(); process.exit(signalExit(sig)); });
|
|
468
|
+
const end = now() + o.for;
|
|
469
|
+
const r = await new Promise(resolve => {
|
|
470
|
+
let watcher = null, done = false;
|
|
471
|
+
const finish = x => {
|
|
472
|
+
if (done) return;
|
|
473
|
+
done = true;
|
|
474
|
+
watcher?.close();
|
|
475
|
+
clearInterval(poll);
|
|
476
|
+
clearTimeout(stop);
|
|
477
|
+
resolve(x);
|
|
478
|
+
};
|
|
479
|
+
// A look without the lock first, then the lock only when there's something to take.
|
|
480
|
+
const check = () => {
|
|
481
|
+
if (done) return;
|
|
482
|
+
if (!still()) return finish({ replaced: true });
|
|
483
|
+
if (load().messages.some(ours)) {
|
|
484
|
+
const got = locked(s2 => {
|
|
485
|
+
if (!still()) return { replaced: true };
|
|
486
|
+
const list = s2.messages.filter(ours);
|
|
487
|
+
if (!list.length) return null;
|
|
488
|
+
const t = now();
|
|
489
|
+
for (const m of list) {
|
|
490
|
+
handOver(s2, m, 'listen', t);
|
|
491
|
+
const x = s2.threads.find(y => y.key === m.key);
|
|
492
|
+
if (x) Object.assign(x, { ended: null, last: t });
|
|
493
|
+
}
|
|
494
|
+
return { got: list.map(m => ({ ...m })) };
|
|
495
|
+
});
|
|
496
|
+
if (got) return finish(got);
|
|
497
|
+
}
|
|
498
|
+
// dibs itself changed under this listener: what's on disk is what the agent's next call runs.
|
|
499
|
+
// Once per agent and version: seen.json, which the what's-new line shares, says what it heard.
|
|
500
|
+
const v = diskVersion();
|
|
501
|
+
if (v && newer(v, VERSION) && newer(v, seenBy(th.seenKey) || VERSION)) return finish({ updated: v });
|
|
502
|
+
const out = latest();
|
|
503
|
+
if (out && newer(out, VERSION) && toldOf(th.key) !== out) return finish({ release: out });
|
|
504
|
+
if (now() >= end) finish({ timeout: true });
|
|
505
|
+
};
|
|
506
|
+
try { watcher = fs.watch(HOME, (ev, name) => { if (!name || name === 'messages.json' || name === 'listeners.json') check(); }); } catch {}
|
|
507
|
+
const poll = setInterval(check, LISTEN_POLL);
|
|
508
|
+
const stop = setTimeout(check, o.for + 50);
|
|
509
|
+
check();
|
|
510
|
+
});
|
|
511
|
+
if (r.replaced) {
|
|
512
|
+
if (o.json) return console.log(JSON.stringify({ replaced: true, messages: [] }));
|
|
513
|
+
return console.log('Another dibs listen for this agent took over, so this one stopped. Nothing was handed over here.');
|
|
514
|
+
}
|
|
515
|
+
// Heard here, so not again from the what's-new line on the agent's next dibs call.
|
|
516
|
+
if (r.updated) {
|
|
517
|
+
const changes = since(seenBy(th.seenKey) || VERSION, r.updated);
|
|
518
|
+
markSeen(th.seenKey, r.updated);
|
|
519
|
+
if (o.json) return console.log(JSON.stringify({ updated: r.updated, changes, again: AGAIN }));
|
|
520
|
+
return console.log(`dibs was updated to ${r.updated}. What changed for you:\n\n${changes.map(c => `${c.version}\n${c.body}`).join('\n\n') || '(no notes)'}\n\n${AGAIN}`);
|
|
521
|
+
}
|
|
522
|
+
if (r.release) {
|
|
523
|
+
toldRelease(th.key, r.release);
|
|
524
|
+
if (o.json) return console.log(JSON.stringify({ release: r.release, have: VERSION, upgrade: UPGRADE, again: AGAIN }));
|
|
525
|
+
return console.log(`dibs ${r.release} is out (you have ${VERSION}). The person upgrades with: ${UPGRADE}\nDon't upgrade it yourself; mention it to the person if it matters to your work.\n\n${AGAIN}`);
|
|
526
|
+
}
|
|
527
|
+
if (r.timeout) {
|
|
528
|
+
if (o.json) console.log(JSON.stringify({ timeout: true, messages: [] }));
|
|
529
|
+
else console.log(`no messages in ${dur(o.for)}; run it again to keep listening`);
|
|
530
|
+
process.exit(LISTEN_TIMEOUT);
|
|
531
|
+
}
|
|
532
|
+
if (o.json) return console.log(JSON.stringify({ messages: r.got.map(m => ({ from: m.kind === 'notice' ? 'dibs' : m.by ? 'agent' : 'person', ...(m.by && { by: m.by }), kind: m.kind, text: m.text, at: m.at })), again: AGAIN }));
|
|
533
|
+
console.log(`${texts(r.got)}\n\n${AGAIN}`);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// Who's listening now, by thread key, read without the lock: for the board and dibs threads.
|
|
537
|
+
export function listening() {
|
|
538
|
+
const l = Object.entries(readListeners());
|
|
539
|
+
if (!l.length) return new Map();
|
|
540
|
+
const up = makeAlive(l.map(([, x]) => x.pid));
|
|
541
|
+
return new Map(l.filter(([, x]) => up(x.pid, x.pstart)));
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// The names listening, for the board: as dibs tell takes them.
|
|
545
|
+
export function listeners() {
|
|
546
|
+
if (!fs.existsSync(FILE)) return [];
|
|
547
|
+
const on = listening();
|
|
548
|
+
if (!on.size) return [];
|
|
549
|
+
const s = load();
|
|
550
|
+
const named = names(s.threads);
|
|
551
|
+
return s.threads.filter(th => on.has(th.key)).map(th => named.get(th.key));
|
|
552
|
+
}
|
|
553
|
+
|
|
376
554
|
// A subagent that finished: its thread shows it can't be reached until it runs again.
|
|
377
555
|
export function finished(input) {
|
|
378
556
|
if (!input.agent_id || !fs.existsSync(FILE)) return;
|
|
@@ -427,11 +605,12 @@ function view(s, t = now()) {
|
|
|
427
605
|
const named = names(threads);
|
|
428
606
|
const alive = liveness(threads);
|
|
429
607
|
const desk = deskName();
|
|
608
|
+
const on = listening();
|
|
430
609
|
return threads.map(th => {
|
|
431
610
|
const messages = lines.get(th.key).sort((a, b) => a.at - b.at);
|
|
432
611
|
return { agent: th.who, label: th.label || '', session: th.session, agentId: th.agentId, to: named.get(th.key), alive: alive(th),
|
|
433
612
|
...(desk && named.get(th.key) === desk && { desk: true }),
|
|
434
|
-
working: workingId(doing(th, st)), doing: doing(th, st), unread: messages.filter(m => m.from === 'agent' && m.kind !== 'delivered' && m.at > (th.readAt || 0)).length,
|
|
613
|
+
working: doing(th, st) || !on.has(th.key) ? workingId(doing(th, st)) : 'listening', doing: doing(th, st), ...(on.has(th.key) && { listening: true }), unread: messages.filter(m => m.from === 'agent' && m.kind !== 'delivered' && m.at > (th.readAt || 0)).length,
|
|
435
614
|
last: th.last, messages };
|
|
436
615
|
}).sort((a, b) => b.last - a.last);
|
|
437
616
|
}
|
|
@@ -477,7 +656,7 @@ export function threads(args) {
|
|
|
477
656
|
out.push(...columns(list.map(th => {
|
|
478
657
|
const lastLine = th.messages.filter(m => m.kind !== 'delivered').at(-1);
|
|
479
658
|
const flags = [th.unread ? `${th.unread} unread` : '', th.messages.some(m => m.state === 'queued') ? 'your message is not delivered yet' : ''].filter(Boolean).join(', ');
|
|
480
|
-
return [th.to, `${th.alive ? workingPlain(th.doing, cfg) : 'not running'}, last heard ${ago(t, th.last)}${flags ? ` (${flags})` : ''}.`,
|
|
659
|
+
return [th.to, `${th.alive ? (th.listening && !th.doing ? 'listening for messages' : workingPlain(th.doing, cfg)) : 'not running'}, last heard ${ago(t, th.last)}${flags ? ` (${flags})` : ''}.`,
|
|
481
660
|
lastLine ? dim(`${lastLine.from === 'person' ? 'You' : lastLine.from === 'dibs' ? 'dibs' : 'They'}: ${lastLine.text}`) : ''];
|
|
482
661
|
})));
|
|
483
662
|
out.push('', dim('Read one: dibs threads read <agent>. Write to one: dibs tell <agent> "..."'));
|
|
@@ -505,7 +684,7 @@ function read(args) {
|
|
|
505
684
|
if (r.no) die(r.no, 1);
|
|
506
685
|
const out = [];
|
|
507
686
|
for (const th of r.list) {
|
|
508
|
-
out.push(bold(`${th.to}: ${th.alive ? workingPlain(th.doing, loadConfig()) : 'not running (your messages wait for it)'}.`));
|
|
687
|
+
out.push(bold(`${th.to}: ${th.alive ? (th.listening && !th.doing ? 'listening for messages' : workingPlain(th.doing, loadConfig())) : 'not running (your messages wait for it)'}.`));
|
|
509
688
|
for (const m of th.messages.slice(-RECENT)) {
|
|
510
689
|
const who = m.from === 'person' ? 'you' : m.from === 'dibs' ? 'dibs told them' : 'them';
|
|
511
690
|
const what = m.kind === 'question' ? `asked (#${m.questionId}, ${m.state}): ${m.text}${m.options ? ` (${m.options.join(' / ')})` : ''}`
|
package/src/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Bump with every release and add a matching section at the top of CHANGELOG.md.
|
|
2
|
-
export const VERSION = '0.0.
|
|
2
|
+
export const VERSION = '0.0.179';
|
package/src/web.mjs
CHANGED
|
@@ -321,18 +321,20 @@ export function snapshot(j, t = now()) {
|
|
|
321
321
|
// What's wrong and what fixes it (src/alerts.mjs), open ones first.
|
|
322
322
|
alerts: (j.alerts || []).map(a => ({ id: a.id, cause: a.cause, level: a.level, title: a.title, why: a.why || null, detail: a.detail || null, fix: a.fix,
|
|
323
323
|
job: a.job ?? null, who: a.who || null, since: a.since, resolvedAt: a.resolvedAt || null, dismissed: !!a.dismissed })),
|
|
324
|
+
// Agents waiting on dibs listen: a message to them wakes them within seconds.
|
|
325
|
+
listening: Array.isArray(j.listening) ? j.listening : [],
|
|
324
326
|
};
|
|
325
327
|
}
|
|
326
328
|
|
|
327
329
|
// The agents, merged from their jobs and their progress posts.
|
|
328
330
|
function people(b, posts) {
|
|
329
331
|
const ts = taskList(posts);
|
|
330
|
-
const names = new Set([...b.jobs.map(x => x.who), ...b.later.map(x => x.who), ...ts.map(x => x.who)]);
|
|
332
|
+
const names = new Set([...b.jobs.map(x => x.who), ...b.later.map(x => x.who), ...ts.map(x => x.who), ...(b.listening || [])]);
|
|
331
333
|
const last = new Map();
|
|
332
334
|
for (const p of posts) last.set(p.who, p);
|
|
333
335
|
return [...names].map(who => ({
|
|
334
336
|
who, jobs: b.jobs.filter(x => x.who === who), later: b.later.filter(x => x.who === who), tasks: ts.filter(x => x.who === who),
|
|
335
|
-
lastPost: last.get(who) || null,
|
|
337
|
+
lastPost: last.get(who) || null, listening: (b.listening || []).includes(who),
|
|
336
338
|
})).sort((a, b2) => (b2.lastPost?.at || 0) - (a.lastPost?.at || 0) || b2.jobs.length - a.jobs.length);
|
|
337
339
|
}
|
|
338
340
|
|