@getgavel/cli 0.1.21 → 0.1.23

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gavel",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "displayName": "Gavel",
5
5
  "description": "Gavel in Claude Code: your person's chat in Gavel reaches your sessions at once (Gavel's bridge, started with each session), the end-of-turn reminder of what's waiting for you, and how to work with Gavel.",
6
6
  "author": { "name": "Gavel", "url": "https://getgavel.ai" },
@@ -159,6 +159,7 @@ async function harnessBridge(h, harness, setup, ctx) {
159
159
  let stopping = false;
160
160
  let thread = null;
161
161
  let state = null;
162
+ let opens = null;
162
163
  let liveRoute = true;
163
164
  let outgoing = [];
164
165
  const sent = new Map();
@@ -283,9 +284,12 @@ async function harnessBridge(h, harness, setup, ctx) {
283
284
  const now = Date.now();
284
285
  while (posted.length && posted[0] <= now - 1000)
285
286
  posted.shift();
286
- // A turn's end, with its last words, goes at once even inside the gap: one a turn, and never more
287
- // than three posts in a second (the route takes 240 a minute).
288
- const end = outgoing.some((e) => e.event === "end") && posted.length < 3;
287
+ // A turn's end, with its last words, goes at once even inside the gap: one a turn. So does the
288
+ // session ceasing to work (idle, waiting on the laptop, closed): its last words show then, while
289
+ // its end waits for the push that keeps them. Never more than three posts in a second, but the
290
+ // end's own, a fourth at a turn's close (the route takes 240 a minute).
291
+ const stopped = outgoing.some((e) => e.event === "state" && e.state !== "working");
292
+ const end = outgoing.some((e) => e.event === "end") ? posted.length < 4 : stopped && posted.length < 3;
289
293
  if (liveTimer) {
290
294
  if (!end)
291
295
  return;
@@ -445,10 +449,11 @@ async function harnessBridge(h, harness, setup, ctx) {
445
449
  outgoing.push(event);
446
450
  liveSoon();
447
451
  },
448
- state: (next) => {
452
+ state: (next, open) => {
449
453
  state = next;
454
+ opens = next === "waiting" ? (open ?? null) : null;
450
455
  if (on && liveRoute) {
451
- outgoing.push({ event: "state", state: next });
456
+ outgoing.push({ event: "state", state: next, ...(opens ? { opens } : {}) });
452
457
  liveSoon();
453
458
  }
454
459
  if (next === "idle" || next === "closed")
@@ -530,7 +535,7 @@ async function harnessBridge(h, harness, setup, ctx) {
530
535
  thread = null;
531
536
  sent.clear();
532
537
  if (state)
533
- outgoing.push({ event: "state", state });
538
+ outgoing.push({ event: "state", state, ...(opens ? { opens } : {}) });
534
539
  await push();
535
540
  liveSoon();
536
541
  }
@@ -1,6 +1,6 @@
1
1
  import { execFile, execFileSync, spawn } from "node:child_process";
2
2
  import { createHash, randomBytes } from "node:crypto";
3
- import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, watch, writeFileSync } from "node:fs";
3
+ import { closeSync, copyFileSync, existsSync, fstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, rmSync, statSync, unlinkSync, watch, writeFileSync } from "node:fs";
4
4
  import { createServer } from "node:http";
5
5
  import { connect } from "node:net";
6
6
  import { tmpdir } from "node:os";
@@ -234,6 +234,69 @@ export function sessionWords(jsonl, fromGavel, prompts = new Map()) {
234
234
  }
235
235
  return words.sort((a, b) => Date.parse(a.at) - Date.parse(b.at));
236
236
  }
237
+ const sizeOf = (file) => {
238
+ try {
239
+ return statSync(file).size;
240
+ }
241
+ catch {
242
+ return 0;
243
+ }
244
+ };
245
+ const READ_MAX = 8 * 1024 * 1024;
246
+ // A file from an offset to its end (READ_MAX at most), without reading the whole transcript; null
247
+ // when it can't be read.
248
+ function readFrom(file, offset, max = READ_MAX) {
249
+ try {
250
+ const fd = openSync(file, "r");
251
+ try {
252
+ const length = Math.max(0, Math.min(fstatSync(fd).size - offset, max));
253
+ const buffer = Buffer.alloc(length);
254
+ readSync(fd, buffer, 0, length, offset);
255
+ return buffer;
256
+ }
257
+ finally {
258
+ closeSync(fd);
259
+ }
260
+ }
261
+ catch {
262
+ return null;
263
+ }
264
+ }
265
+ // The first and the last of an answer's words as its transcript line has them (JSON), each within
266
+ // one line of it: Claude Code joins a message's parts with a newline for the Stop hook, so neither
267
+ // spans two parts.
268
+ function wordsOf(last) {
269
+ const lines = last.split("\n");
270
+ const json = (text) => Array.from(JSON.stringify(text).slice(1, -1));
271
+ return [Buffer.from(json(lines[0]).slice(0, 59).join("")), Buffer.from(json(lines.at(-1)).slice(-59).join(""))];
272
+ }
273
+ // Where a turn's prompt line starts (Claude Code keeps the prompt's id in it) in the transcript's
274
+ // last 16 MB; null when it isn't there.
275
+ function promptLine(file, prompt) {
276
+ const from = Math.max(0, sizeOf(file) - 2 * READ_MAX);
277
+ const read = readFrom(file, from, 2 * READ_MAX);
278
+ const at = read?.lastIndexOf(`"promptId":${JSON.stringify(prompt)}`) ?? -1;
279
+ return read && at >= 0 ? from + read.lastIndexOf(10, at) + 1 : null;
280
+ }
281
+ // Whether a transcript read's whole lines hold the agent's line with these words (a line Claude Code
282
+ // is still writing doesn't count), and how far its whole lines go.
283
+ function agentLine(read, words) {
284
+ let start = 0;
285
+ for (let end = read.indexOf(10); end >= 0; start = end + 1, end = read.indexOf(10, start)) {
286
+ const raw = read.subarray(start, end);
287
+ if (!words.every((w) => raw.includes(w)))
288
+ continue;
289
+ try {
290
+ const line = JSON.parse(raw.toString("utf8"));
291
+ if (line.type === "assistant" && !line.isSidechain)
292
+ return { found: true, through: end + 1 };
293
+ }
294
+ catch {
295
+ // a line read from its middle
296
+ }
297
+ }
298
+ return { found: false, through: start };
299
+ }
237
300
  const PICTURES_HOURS = 1;
238
301
  export class ClaudeCodeHarness {
239
302
  ctx;
@@ -247,8 +310,9 @@ export class ClaudeCodeHarness {
247
310
  watcher = null;
248
311
  watching = null;
249
312
  display = null;
250
- resumed = null;
251
313
  lastState = null;
314
+ // The short ids Claude Code gave the sessions the bridge put in the background.
315
+ backgrounded = new Set();
252
316
  changedTimer = null;
253
317
  // The person's name, for the words that say who wrote: the core learns it after it builds the
254
318
  // harness, from GET /v1/me.
@@ -283,17 +347,21 @@ export class ClaudeCodeHarness {
283
347
  }
284
348
  // The session Gavel shows and writes to: the newest one open, else the folder's newest.
285
349
  current() {
286
- const open = [...this.sessions.values()].filter((s) => s.open).sort((a, b) => b.seen - a.seen);
350
+ const open = [...this.sessions.values()].filter((s) => s.open).sort((a, b) => Number(b.begun) - Number(a.begun) || b.seen - a.seen);
287
351
  return open[0] ?? null;
288
352
  }
289
- setState(next) {
290
- if (next === this.lastState)
353
+ setState(next, opens) {
354
+ const said = `${next} ${opens ?? ""}`;
355
+ if (said === this.lastState)
291
356
  return;
292
- this.lastState = next;
293
- this.listener?.state(next);
357
+ this.lastState = said;
358
+ this.listener?.state(next, opens);
294
359
  }
360
+ // A session in the background that waits on a prompt opens with `claude attach` and the short id
361
+ // Claude Code gives it (its id's first 8 characters).
295
362
  stateNow() {
296
- this.setState(this.current()?.state ?? "closed");
363
+ const s = this.current();
364
+ this.setState(s?.state ?? "closed", s?.state === "waiting" && s.background ? `claude attach ${s.id.slice(0, 8)}` : null);
297
365
  }
298
366
  // A transcript write comes as a few file events at once: one changed() for them, quickly, since the
299
367
  // session's copy of a Gavel message is what marks it read.
@@ -336,7 +404,7 @@ export class ClaudeCodeHarness {
336
404
  session(id) {
337
405
  let s = this.sessions.get(id);
338
406
  if (!s) {
339
- s = { id, inbox: null, transcript: null, open: true, state: "idle", seen: Date.now(), run: null, spoken: new Map() };
407
+ s = { id, inbox: null, transcript: null, open: true, hooked: false, background: false, begun: false, state: "idle", seen: Date.now(), run: null, spoken: new Map() };
340
408
  this.sessions.set(id, s);
341
409
  }
342
410
  return s;
@@ -352,6 +420,10 @@ export class ClaudeCodeHarness {
352
420
  return;
353
421
  const s = this.session(id);
354
422
  s.seen = Date.now();
423
+ s.hooked = true;
424
+ s.begun ||= event === "SessionStart" ? input.source !== "startup" : event !== "SessionEnd";
425
+ if (this.backgrounded.has(id.slice(0, 8)))
426
+ s.background = true;
355
427
  if (e.inbox)
356
428
  s.inbox = e.inbox;
357
429
  if (typeof input.transcript_path === "string")
@@ -401,7 +473,7 @@ export class ClaudeCodeHarness {
401
473
  s.run = null;
402
474
  const last = typeof input.last_assistant_message === "string" ? input.last_assistant_message.trim() : "";
403
475
  if (run)
404
- void this.endOnceKept(s, run, event === "Stop" ? last : "");
476
+ void this.endOnceKept(s, run, event === "Stop" ? last : "", typeof input.prompt_id === "string" ? input.prompt_id : null);
405
477
  break;
406
478
  }
407
479
  case "SessionEnd":
@@ -414,19 +486,28 @@ export class ClaudeCodeHarness {
414
486
  this.soon();
415
487
  this.stateNow();
416
488
  }
417
- // A turn's end goes once the transcript has its last words (Claude Code writes the file a moment
418
- // after the Stop hook), so the core's push before it keeps them (Reach's rule for `end`).
419
- async endOnceKept(s, run, last) {
420
- const deadline = Date.now() + 3_000;
421
- while (last && s.transcript && Date.now() < deadline) {
422
- try {
423
- if (readFileSync(s.transcript, "utf8").includes(JSON.stringify(last).slice(1, 60)))
489
+ // A turn's end goes once the transcript has its last words in a whole line (Claude Code writes the
490
+ // file a moment after the Stop hook, and a line sometimes in two writes), so the core's push before
491
+ // it keeps them (Reach's rule for `end`). Looked for after the turn's own prompt line, so an earlier
492
+ // answer in the same words isn't taken for it; without one, from a little before where the file
493
+ // ended at the Stop hook: Claude Code writes large lines after the last words too (a session's
494
+ // first turn adds a prompt snapshot of tens of KB).
495
+ async endOnceKept(s, run, last, prompt) {
496
+ const file = s.transcript;
497
+ if (last && file) {
498
+ const deadline = Date.now() + 3_000;
499
+ const words = wordsOf(last);
500
+ let from = (prompt ? promptLine(file, prompt) : null) ?? Math.max(0, sizeOf(file) - 8 * last.length - 1_048_576);
501
+ while (Date.now() < deadline) {
502
+ const read = readFrom(file, from);
503
+ if (!read)
424
504
  break;
505
+ const scan = agentLine(read, words);
506
+ if (scan.found)
507
+ break;
508
+ from += scan.through || (read.length >= READ_MAX ? read.length : 0);
509
+ await new Promise((r) => setTimeout(r, 20));
425
510
  }
426
- catch {
427
- break;
428
- }
429
- await new Promise((r) => setTimeout(r, 100));
430
511
  }
431
512
  this.listener?.changed();
432
513
  this.listener?.live({ event: "end", runId: run });
@@ -490,15 +571,17 @@ export class ClaudeCodeHarness {
490
571
  return { outcome: "left", say: `${this.ctx.person} wrote in Gavel; your Claude Code session here is open and the bridge can't reach it yet, so it goes in at the session's next step, or once it closes.` };
491
572
  return this.resume(m, text);
492
573
  }
493
- // A closed session, resumed with the person's words as a turn of its own (D-905): nothing that
494
- // would prompt runs. Delivered once the run starts; what it refused, or why it failed, comes after
495
- // as the bridge's note.
574
+ // A closed session, resumed with the person's words as a turn of its own in the background
575
+ // (D-1174, changing D-905's "nothing that would prompt runs"): it runs under their own permission
576
+ // settings, and what would ask them waits till they open it on the laptop (`claude attach`). Its
577
+ // edits stay in the folder, as their own session's: no worktree of its own (Master Gavel's call).
578
+ // The words go on stdin, never in its arguments. Delivered once Claude Code says it's backgrounded;
579
+ // from then the session's own hooks name it, so their next words go through its inbox.
496
580
  resume(m, text) {
497
581
  const newest = claudeSessions(this.ctx.cwd, this.ctx.home, this.ctx.env)[0] ?? null;
498
- const args = ["-p", ...(newest ? ["--resume", newest.id] : []), "--permission-prompts", "none", "--output-format", "json"];
582
+ const args = [...(newest ? ["--resume", newest.id] : []), "--bg", "--settings", JSON.stringify({ worktree: { bgIsolation: "none" } })];
499
583
  return new Promise((resolve) => {
500
- const child = spawn("claude", args, { cwd: this.ctx.cwd, stdio: ["pipe", "pipe", "pipe"] });
501
- this.resumed = child;
584
+ const child = spawn("claude", args, { cwd: this.ctx.cwd, env: this.ctx.env, stdio: ["pipe", "pipe", "pipe"] });
502
585
  let out = "";
503
586
  let err = "";
504
587
  let settled = false;
@@ -507,38 +590,27 @@ export class ClaudeCodeHarness {
507
590
  resolve(d);
508
591
  settled = true;
509
592
  };
593
+ const quit = setTimeout(() => child.kill(), 60_000);
510
594
  child.stdout.on("data", (d) => (out += d));
511
595
  child.stderr.on("data", (d) => (err += d));
512
- child.on("spawn", () => {
513
- this.remember(m.id, promptKey(text));
514
- setTimeout(() => settle({ outcome: "delivered" }), 300).unref();
515
- });
516
596
  child.on("error", (e) => settle({ outcome: "failed", reason: e.code === "ENOENT" ? "Claude Code's claude command isn't on the laptop's PATH where the bridge runs." : `Claude Code didn't start: ${e.message}` }));
517
597
  child.on("close", (code) => {
518
- this.resumed = null;
519
- let result = null;
520
- try {
521
- result = JSON.parse(out);
522
- }
523
- catch {
524
- // its reason is on stderr
525
- }
526
- const first = (t) => t.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
527
- if (code === 0 && result && !result.is_error) {
528
- const refused = [...new Set((result.permission_denials ?? []).map((d) => d?.tool_name).filter((n) => typeof n === "string"))];
529
- if (refused.length)
530
- this.listener?.note(`Claude Code didn't do what it would have asked you about first (${refused.join(", ")}): nobody was at the laptop to allow it. Allow it in the session there, or answer here.`);
598
+ clearTimeout(quit);
599
+ const short = /^backgrounded · ([0-9a-f]{8,36})\b/m.exec(out)?.[1];
600
+ if (code === 0 && short) {
601
+ this.remember(m.id, promptKey(text));
602
+ this.backgrounded.add(short.slice(0, 8));
531
603
  settle({ outcome: "delivered" });
532
604
  }
533
605
  else {
534
- const said = (typeof result?.result === "string" ? first(result.result) : "") || first(err);
535
- const reason = (/unknown option.*permission-prompts/i.test(err) ? "The laptop's Claude Code is too old for the bridge: run claude update there." : said ? `Claude Code said: ${said}` : `Claude Code stopped without answering (code ${code}).`).slice(0, 300);
536
- if (settled)
537
- this.listener?.note(reason);
606
+ const first = (t) => t.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
607
+ const said = first(err) || first(out);
608
+ const reason = (/unknown option.*(--bg|--background)/i.test(err) ? "The laptop's Claude Code is too old for the bridge: run claude update there." : said ? `Claude Code said: ${said}` : `Claude Code stopped without answering (code ${code}).`).slice(0, 300);
538
609
  settle({ outcome: "failed", reason });
539
610
  }
540
611
  this.listener?.changed();
541
612
  });
613
+ child.stdin.on("error", () => undefined);
542
614
  child.stdin.end(text);
543
615
  });
544
616
  }
@@ -546,10 +618,10 @@ export class ClaudeCodeHarness {
546
618
  // missed): the newest one's inbox at its usual address, without the session's key.
547
619
  async liveSession() {
548
620
  try {
549
- const { stdout } = await promisify(execFile)("claude", ["agents", "--json"], { cwd: this.ctx.cwd, timeout: 15_000 });
621
+ const { stdout } = await promisify(execFile)("claude", ["agents", "--json"], { cwd: this.ctx.cwd, env: this.ctx.env, timeout: 15_000 });
550
622
  const live = JSON.parse(stdout).filter((s) => s.cwd === this.ctx.cwd && typeof s.sessionId === "string" && typeof s.pid === "number");
551
623
  for (const s of this.sessions.values())
552
- if (s.open && !live.some((l) => l.sessionId === s.id)) {
624
+ if (s.open && !s.hooked && !live.some((l) => l.sessionId === s.id)) {
553
625
  s.open = false;
554
626
  s.inbox = null;
555
627
  s.state = "closed";
@@ -563,6 +635,7 @@ export class ClaudeCodeHarness {
563
635
  const s = this.session(newest.sessionId);
564
636
  s.open = true;
565
637
  s.inbox = s.inbox ?? (socket ? { socket, token: null } : null);
638
+ s.background ||= newest.kind === "background";
566
639
  s.state = newest.status === "busy" ? "working" : newest.status === "waiting" ? "waiting" : "idle";
567
640
  this.stateNow();
568
641
  return s;
@@ -572,12 +645,8 @@ export class ClaudeCodeHarness {
572
645
  }
573
646
  }
574
647
  // Stop in Gavel: the turn interrupted from its inbox (priority now), Claude then reading why; a
575
- // resumed run is ended. Over when nothing runs.
648
+ // resumed session's too, in the background. Over when nothing runs.
576
649
  async interrupt() {
577
- if (this.resumed) {
578
- this.resumed.kill("SIGINT");
579
- return "stopped";
580
- }
581
650
  const open = this.current();
582
651
  if (!open?.inbox || (open.state !== "working" && open.state !== "waiting"))
583
652
  return "over";
@@ -150,15 +150,7 @@ async function codexQueue(session, text, cwd) {
150
150
  throw new Error(firstLineOf(e.stderr ?? "") || e.message);
151
151
  }
152
152
  }
153
- // What the bridge answers for Codex on a turn it started while nobody had the session open: no.
154
- // Nobody is at the laptop to allow it; the person hears what wasn't done (D-905, as exec did).
155
- const DECLINE = {
156
- "item/commandExecution/requestApproval": { result: { decision: "decline" }, what: "a command" },
157
- "item/fileChange/requestApproval": { result: { decision: "decline" }, what: "a file change" },
158
- "item/permissions/requestApproval": { result: { permissions: {}, scope: "turn" }, what: "more access" },
159
- "item/tool/requestUserInput": { result: { answers: {} }, what: "a question for you" },
160
- "mcpServer/elicitation/request": { result: { action: "decline", content: null, _meta: null }, what: "a tool's question" },
161
- };
153
+ // ---------- The harness ----------
162
154
  const SOURCES = ["cli", "vscode", "exec", "appServer"];
163
155
  const HISTORY_TURNS = 30;
164
156
  // After the person stops a turn at the laptop, Gavel's wake waits this long.
@@ -183,7 +175,6 @@ class CodexHarness {
183
175
  // Threads the bridge loaded itself, with nobody at the laptop, and the turns it started there.
184
176
  ownLoaded = new Set();
185
177
  unattended = new Set();
186
- declined = new Map();
187
178
  // A message put in through Codex's queue has no client id: its copy joins it by its words.
188
179
  queued = new Map();
189
180
  state = null;
@@ -208,7 +199,10 @@ class CodexHarness {
208
199
  if (state === this.state)
209
200
  return;
210
201
  this.state = state;
211
- this.listener?.state(state);
202
+ // Waiting in a session the bridge loaded itself: the person opens it on the laptop, where Codex
203
+ // shows what it asks, and answers there (D-1174).
204
+ const mine = state === "waiting" && this.current && this.ownLoaded.has(this.current.id) ? this.current.id : null;
205
+ this.listener?.state(state, mine ? `codex resume ${mine}` : null);
212
206
  }
213
207
  connect() {
214
208
  if (this.app)
@@ -219,7 +213,7 @@ class CodexHarness {
219
213
  // Codex's shared server, started first if none runs, as a Codex terminal does by itself.
220
214
  async open() {
221
215
  const socket = controlSocket(this.ctx.env, this.ctx.home);
222
- const handlers = { notification: (method, params) => this.notified(method, params), serverRequest: (r) => this.asked(r) };
216
+ const handlers = { notification: (method, params) => this.notified(method, params), serverRequest: () => undefined };
223
217
  let app;
224
218
  try {
225
219
  app = await connectCodex(socket, handlers, cliVersion());
@@ -373,14 +367,8 @@ class CodexHarness {
373
367
  this.turnId = null;
374
368
  if (turn.status === "interrupted")
375
369
  this.stoppedAt = Date.now();
376
- const declined = this.declined.get(turn.id);
377
- if (declined?.length) {
378
- const some = [...new Set(declined)].join(", ");
379
- this.listener?.note(`Codex didn't do what it would have asked you about first (${some}): nobody was at the laptop to allow it. Allow it in the session there, or answer here.`);
380
- }
381
370
  if (turn.status === "failed" && this.unattended.has(turn.id))
382
371
  this.listener?.note(`Codex couldn't finish: ${turn.error?.message ?? "the turn failed"}`.slice(0, 300));
383
- this.declined.delete(turn.id);
384
372
  this.unattended.delete(turn.id);
385
373
  this.listener?.changed();
386
374
  if (this.announced.delete(turn.id))
@@ -389,17 +377,6 @@ class CodexHarness {
389
377
  }
390
378
  }
391
379
  }
392
- // A request Codex puts to its clients. The person's own Codex gets it too and answers it; the bridge
393
- // answers only in a session it opened itself, which nobody has typed in at the laptop since.
394
- asked(request) {
395
- const threadId = typeof request.params.threadId === "string" ? request.params.threadId : null;
396
- const turnId = typeof request.params.turnId === "string" ? request.params.turnId : null;
397
- const decline = DECLINE[request.method];
398
- if (!threadId || !turnId || !decline || !this.ownLoaded.has(threadId))
399
- return;
400
- this.app?.respond(request.id, decline.result);
401
- this.declined.set(turnId, [...(this.declined.get(turnId) ?? []), decline.what]);
402
- }
403
380
  // Into the newest session: started on its turn when idle, steering it while it runs (turn/start does
404
381
  // either); loaded first when nobody has it open, or a new session when the folder has none.
405
382
  async put(app, input, clientUserMessageId, words, wake) {
package/dist/gavel.js CHANGED
@@ -1803,6 +1803,13 @@ async function upload(token, as, { file, contentType }) {
1803
1803
  console.log(jsonText(await finished.json()));
1804
1804
  return 0;
1805
1805
  }
1806
+ const THREAD_WAKES = {
1807
+ added: "you were added to it",
1808
+ mention: "a message names you",
1809
+ answer: "an answer to what you asked",
1810
+ note: "a note, it needs no answer",
1811
+ acknowledgment: "an acknowledgment",
1812
+ };
1806
1813
  // One line per thing that should wake the chat: refs and Gavel's own words only, never a message's
1807
1814
  // text, so the line itself is never someone else's instructions. A kind newer than this command
1808
1815
  // still wakes it, with a line that sends it to the inbox.
@@ -1838,6 +1845,8 @@ export function wakeLine(item) {
1838
1845
  : `GAVEL_WAKE task ${item.ref} ${item.type ?? "changed"} by someone else: gavel work show ${item.ref}`;
1839
1846
  case "replaced":
1840
1847
  return `GAVEL_WAKE replaced ${item.ref}: it no longer holds, ${item.type ?? "a newer decision"} replaces it: gavel get ${item.type ?? item.ref}, and follow that one`;
1848
+ case "thread":
1849
+ return `GAVEL_WAKE thread ${item.ref}: ${THREAD_WAKES[item.type ?? ""] ?? "a message"}: read it with gavel thread ${item.ref}`;
1841
1850
  default:
1842
1851
  return "GAVEL_WAKE something new: see gavel inbox";
1843
1852
  }
@@ -1853,7 +1862,7 @@ async function watch(token, as) {
1853
1862
  for (;;) {
1854
1863
  let res;
1855
1864
  try {
1856
- res = await fetch(`${base}/v1/inbox/watch?watch=${id}&timeout=50&kinds=health,claim,work,drift,task,replaced${start ? "&start=true" : ""}`, {
1865
+ res = await fetch(`${base}/v1/inbox/watch?watch=${id}&timeout=50&kinds=health,claim,work,drift,task,replaced,thread${start ? "&start=true" : ""}`, {
1857
1866
  headers: { authorization: `Bearer ${token}`, accept: "application/json", ...agentHeader(as) },
1858
1867
  });
1859
1868
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "The gavel command: an agent's Gavel from a shell (pair, ask, wait, watch and the rest)",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://getgavel.ai/agents",