@getgavel/cli 0.1.17 → 0.1.18

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,5 +1,6 @@
1
1
  {
2
2
  "name": "gavel",
3
+ "version": "0.1.18",
3
4
  "displayName": "Gavel",
4
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.",
5
6
  "author": { "name": "Gavel", "url": "https://getgavel.ai" },
@@ -125,6 +125,17 @@ function joined(events) {
125
125
  return out;
126
126
  }
127
127
  const sentKey = (m) => `${m.text}\u0000${m.gavelId ?? ""}`;
128
+ // An answer from Gavel the bridge can read, or null (a proxy's page, a cut-off body): treated as a
129
+ // failed call, so nothing Gavel or the network sends can end the bridge.
130
+ async function answer(res) {
131
+ try {
132
+ const body = (await res.json());
133
+ return body && typeof body === "object" ? body : null;
134
+ }
135
+ catch {
136
+ return null;
137
+ }
138
+ }
128
139
  // The Gavel side for a harness: the one peek (presence, the person's messages, Stop), their messages
129
140
  // put in beside it with their pictures, the session's words kept (the transcript) and shown as written
130
141
  // (live), its state, and wakes for what waits in Gavel.
@@ -325,6 +336,9 @@ async function harnessBridge(h, harness, setup, ctx) {
325
336
  pending = [];
326
337
  }
327
338
  }
339
+ catch (err) {
340
+ complain(`${err instanceof Error ? err.message : String(err)} waking ${h.name}; trying again`);
341
+ }
328
342
  finally {
329
343
  waking = false;
330
344
  }
@@ -352,14 +366,15 @@ async function harnessBridge(h, harness, setup, ctx) {
352
366
  console.error(`gavel bridge: HTTP ${res.status} watching what waits in Gavel; ${h.name} isn't woken for it`);
353
367
  return;
354
368
  }
355
- if (!res.ok) {
369
+ const body = res.ok ? await answer(res) : null;
370
+ if (!body) {
356
371
  failures++;
357
372
  await pause(backoff(failures));
358
373
  continue;
359
374
  }
360
375
  failures = 0;
361
376
  start = false;
362
- const { items } = (await res.json());
377
+ const items = Array.isArray(body.items) ? body.items : [];
363
378
  const known = new Set(pending.map((i) => `${i.kind}:${i.id}`));
364
379
  pending.push(...items.filter((i) => i.kind !== "chat" && !known.has(`${i.kind}:${i.id}`)));
365
380
  await tryWake();
@@ -407,7 +422,7 @@ async function harnessBridge(h, harness, setup, ctx) {
407
422
  process.on("SIGINT", () => stop());
408
423
  process.on("SIGTERM", () => stop());
409
424
  const here = { home: ctx.home, cwd: ctx.cwd, harness };
410
- void watchLoop();
425
+ void watchLoop().catch((err) => console.error(`gavel bridge: ${err instanceof Error ? err.message : String(err)}; ${h.name} isn't woken for what waits in Gavel`));
411
426
  let start = true;
412
427
  let failures = 0;
413
428
  try {
@@ -433,15 +448,15 @@ async function harnessBridge(h, harness, setup, ctx) {
433
448
  console.error(`gavel bridge: ${(await res.text()) || `HTTP ${res.status}`}`);
434
449
  return 1;
435
450
  }
436
- if (!res.ok) {
451
+ const peeked = res.ok ? await answer(res) : null;
452
+ if (!peeked || typeof peeked.on !== "boolean") {
437
453
  failures++;
438
- console.error(`gavel bridge: HTTP ${res.status}; trying again`);
454
+ console.error(`gavel bridge: ${res.ok ? "an answer it can't read" : `HTTP ${res.status}`}; trying again`);
439
455
  await pause(backoff(failures));
440
456
  continue;
441
457
  }
442
458
  failures = 0;
443
459
  start = false;
444
- const peeked = (await res.json());
445
460
  if (peeked.stop?.id)
446
461
  void stopTurn(peeked.stop.id);
447
462
  if (peeked.on !== on) {
@@ -469,7 +484,7 @@ async function harnessBridge(h, harness, setup, ctx) {
469
484
  }
470
485
  if (!on)
471
486
  continue;
472
- const waiting = peeked.unread.filter((u) => !handled.has(u.id));
487
+ const waiting = (Array.isArray(peeked.unread) ? peeked.unread : []).filter((u) => !handled.has(u.id));
473
488
  for (const m of waiting)
474
489
  if (!delivering.has(m.id))
475
490
  enqueue(m);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
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",