@getgavel/cli 0.1.23 → 0.1.25

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.23",
3
+ "version": "0.1.25",
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" },
@@ -2,6 +2,7 @@ import { execFileSync, spawn } from "node:child_process";
2
2
  import { createHash } from "node:crypto";
3
3
  import { chmodSync, closeSync, copyFileSync, existsSync, linkSync, mkdirSync, openSync, readdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
4
4
  import { connect, createServer } from "node:net";
5
+ import { tmpdir } from "node:os";
5
6
  import { dirname, join } from "node:path";
6
7
  import { claudeSetups, codexSetups } from "./setup.js";
7
8
  // How long a bridge a hook started stays after its folder's last session ends: long enough for a
@@ -19,15 +20,29 @@ const realpath = (path) => {
19
20
  }
20
21
  };
21
22
  export const bridgeDir = (home) => join(home, ".gavel", "bridge");
22
- // One key per folder and harness: a short hash, so the socket's path stays under the ~104 bytes a
23
- // Unix socket's address allows.
23
+ // One key per folder and harness: a short hash, so the socket's path stays under the bytes a Unix
24
+ // socket's address allows.
24
25
  export function bridgeKey(cwd, harness) {
25
26
  return createHash("sha256").update(`${realpath(cwd)}\0${harness}`).digest("hex").slice(0, 16);
26
27
  }
28
+ // The longest path a Unix socket can listen on: macOS's address holds 104 bytes with its closing
29
+ // zero (Linux's 108), and past it listen fails (W-244).
30
+ export const MAX_SOCKET_PATH = 103;
31
+ // The hook socket beside the lock, unless a long home folder pushes it past the limit: then in a
32
+ // private folder of the user's own under the system's temporary folder, which the lock names.
33
+ function socketPath(dir, key) {
34
+ const beside = join(dir, `${key}.sock`);
35
+ if (Buffer.byteLength(beside) <= MAX_SOCKET_PATH)
36
+ return beside;
37
+ return join(tmpdir(), `gavel-bridge-${process.getuid?.() ?? "user"}`, `${key}.sock`);
38
+ }
27
39
  export function bridgePaths(home, cwd, harness) {
28
40
  const dir = bridgeDir(home);
29
41
  const key = bridgeKey(cwd, harness);
30
- return { dir, key, lock: join(dir, `${key}.json`), log: join(dir, `${key}.log`), socket: join(dir, `${key}.sock`) };
42
+ return { dir, key, lock: join(dir, `${key}.json`), log: join(dir, `${key}.log`), socket: socketPath(dir, key) };
43
+ }
44
+ // Says why the hook socket can't be made, in words a person can act on.
45
+ export class BridgeSocketError extends Error {
31
46
  }
32
47
  function privateDir(dir) {
33
48
  mkdirSync(dir, { recursive: true, mode: 0o700 });
@@ -84,6 +99,11 @@ export function onHookEvent(fn) {
84
99
  export function holdBridge(opts) {
85
100
  const paths = bridgePaths(opts.home, opts.cwd, opts.harness);
86
101
  privateDir(paths.dir);
102
+ if (Buffer.byteLength(paths.socket) > MAX_SOCKET_PATH) {
103
+ throw new BridgeSocketError(`the bridge's socket path (${paths.socket}) is longer than the ${MAX_SOCKET_PATH} bytes a Unix socket allows: set TMPDIR to a shorter folder, such as /tmp`);
104
+ }
105
+ if (dirname(paths.socket) !== paths.dir)
106
+ privateDir(dirname(paths.socket));
87
107
  const open = new Set();
88
108
  let lastClosed = null;
89
109
  const lock = {
@@ -173,6 +193,12 @@ export function holdBridge(opts) {
173
193
  });
174
194
  conn.on("error", () => undefined);
175
195
  });
196
+ // A socket that can't listen is said, never a silent exit (W-244).
197
+ server.on("error", (err) => {
198
+ console.error(`gavel bridge: can't listen for hooks at ${paths.socket} (${err.code ?? err.message}).`);
199
+ release();
200
+ process.exit(1);
201
+ });
176
202
  server.listen(paths.socket, () => chmodSync(paths.socket, 0o600));
177
203
  server.unref();
178
204
  let released = false;
@@ -24,11 +24,22 @@ import { claudeSetups } from "./setup.js";
24
24
  // PostToolUse, Stop, StopFailure and SessionEnd.
25
25
  export const BRIDGE_MIN_VERSION = [2, 1, 224];
26
26
  // One message into a session's inbox; true once Claude Code took the line.
27
+ const ENVELOPE = "cross-session-message";
28
+ // Claude Code (2.1.332) holds another session's message for approval in a session that bypasses
29
+ // permission prompts, unless the sender says it bypasses them too, in the message's own envelope
30
+ // (`from-mode`); the bridge says so for a session it knows bypasses them (W-256), carrying its
31
+ // person's own words and Gavel's wakes. Only that: said to a session that prompts, `bypass` is held
32
+ // as a mismatch, and saying nothing it takes. Words holding the envelope's closing tag go as they are.
33
+ export function attested(text, bypass) {
34
+ if (!bypass || new RegExp(`</${ENVELOPE}`, "i").test(text))
35
+ return text;
36
+ return `<${ENVELOPE} from-name="Gavel" from-mode="bypass">\n${text}\n</${ENVELOPE}>`;
37
+ }
27
38
  export function inboxSend(inbox, text, opts) {
28
39
  return new Promise((resolve) => {
29
40
  const lines = [
30
41
  ...(inbox.token ? [JSON.stringify({ type: "auth", token: inbox.token })] : []),
31
- JSON.stringify({ type: "user", message: { role: "user", content: text }, priority: opts.priority, ...(opts.msgId ? { msg_id: opts.msgId } : {}) }),
42
+ JSON.stringify({ type: "user", message: { role: "user", content: attested(text, opts.bypass === true) }, priority: opts.priority, ...(opts.msgId ? { msg_id: opts.msgId } : {}) }),
32
43
  ];
33
44
  const conn = connect(inbox.socket, () => conn.end(`${lines.join("\n")}\n`));
34
45
  conn.setTimeout(5_000, () => conn.destroy(new Error("timeout")));
@@ -110,6 +121,32 @@ export function displayHook(home, cwd) {
110
121
  }
111
122
  return { port, secret, url: `http://127.0.0.1:${port}${DISPLAY_PATH}${secret}`, file };
112
123
  }
124
+ // The display hook on another port, the folder's own being another program's: kept for next time,
125
+ // and its address rewritten where the bridge's hooks put it, the folder's own settings, which a
126
+ // running session reloads; never in a file git tracks. What it did, in words for the bridge's log.
127
+ export function moveDisplayHook(home, cwd, port) {
128
+ const was = displayHook(home, cwd);
129
+ writeFileSync(was.file, `${JSON.stringify({ port, secret: was.secret })}\n`, { mode: 0o600 });
130
+ const name = ".claude/settings.local.json";
131
+ let settings;
132
+ try {
133
+ settings = JSON.parse(readFileSync(join(cwd, name), "utf8"));
134
+ }
135
+ catch {
136
+ return `kept it; no ${name} here names the hook`;
137
+ }
138
+ const named = Object.values(settings.hooks ?? {})
139
+ .flatMap((groups) => (groups ?? []).flatMap((g) => g.hooks ?? []))
140
+ .filter((h) => h.url === was.url);
141
+ if (!named.length)
142
+ return `kept it; ${name} doesn't name the hook`;
143
+ if (gitIn(["ls-files", "--error-unmatch", name], cwd))
144
+ return `kept it, but git tracks ${name}, so the hook there still names the old port`;
145
+ for (const h of named)
146
+ h.url = `http://127.0.0.1:${port}${DISPLAY_PATH}${was.secret}`;
147
+ writeWhole(join(cwd, name), `${JSON.stringify(settings, null, 2)}\n`);
148
+ return `wrote it into ${name}`;
149
+ }
113
150
  const gitIn = (args, cwd) => {
114
151
  try {
115
152
  execFileSync("git", args, { cwd, stdio: "ignore" });
@@ -226,8 +263,9 @@ export function sessionWords(jsonl, fromGavel, prompts = new Map()) {
226
263
  const id = line.origin?.msg_id;
227
264
  if (line.type !== "user" || line.origin?.kind !== "peer" || typeof id !== "string" || !fromGavel.has(id) || !line.uuid || !line.timestamp)
228
265
  continue;
266
+ // An attested message's words are its envelope's body, which Claude Code keeps beside it.
229
267
  const content = typeof line.message?.content === "string" ? line.message.content : "";
230
- const body = content.replace(PEER_HEADER, "");
268
+ const body = typeof line.origin.body === "string" ? line.origin.body : content.replace(PEER_HEADER, "");
231
269
  const end = body.indexOf(PEER_FOOTER);
232
270
  const text = theirWords(end >= 0 ? body.slice(0, end) : body);
233
271
  words.push({ id: line.uuid, side: "person", text: text || "(message)", at: line.timestamp, gavelId: id });
@@ -262,6 +300,54 @@ function readFrom(file, offset, max = READ_MAX) {
262
300
  return null;
263
301
  }
264
302
  }
303
+ // A session's permission mode as its transcript last noted it (Claude Code writes it as the file
304
+ // starts and with each prompt), from the file's last 256 KB; null when it says none.
305
+ export function lastMode(file) {
306
+ const read = readFrom(file, Math.max(0, sizeOf(file) - 262_144), 262_144);
307
+ const all = read ? [...read.toString("utf8").matchAll(/"permissionMode":"([A-Za-z]+)"/g)] : [];
308
+ return all.at(-1)?.[1] ?? null;
309
+ }
310
+ // What Claude Code held of the messages other sessions sent this one, as its transcript notes each
311
+ // ("Held peer message", a notice for the person); how many, and when the last was.
312
+ export function heldNotices(file) {
313
+ let held = 0;
314
+ let lastAt = null;
315
+ let text = "";
316
+ try {
317
+ text = readFileSync(file, "utf8");
318
+ }
319
+ catch {
320
+ return { held, lastAt };
321
+ }
322
+ for (const raw of text.split("\n")) {
323
+ if (!raw.includes("Held peer message"))
324
+ continue;
325
+ try {
326
+ const line = JSON.parse(raw);
327
+ if (line.type !== "system" || typeof line.content !== "string" || !line.content.startsWith("Held peer message"))
328
+ continue;
329
+ held++;
330
+ if (typeof line.timestamp === "string")
331
+ lastAt = line.timestamp;
332
+ }
333
+ catch {
334
+ // a line read as it was written
335
+ }
336
+ }
337
+ return { held, lastAt };
338
+ }
339
+ // For `gavel bridge status`: what Claude Code held in the folder's newest session of the messages
340
+ // other sessions sent it (the bridge's before it said who it is, W-256), and how they go through.
341
+ export function claudeHeld(cwd, home, env) {
342
+ const newest = claudeSessions(cwd, home, env)[0];
343
+ const notes = newest ? heldNotices(newest.file) : null;
344
+ if (!notes?.held)
345
+ return null;
346
+ return {
347
+ ...notes,
348
+ release: "Claude Code holds messages from other sessions while this session bypasses permission prompts. Let them through in the session's dialog (Deliver), or in /config, Messages from your other sessions. The bridge from 0.1.25 says who it is, so its messages aren't held.",
349
+ };
350
+ }
265
351
  // The first and the last of an answer's words as its transcript line has them (JSON), each within
266
352
  // one line of it: Claude Code joins a message's parts with a newline for the Stop hook, so neither
267
353
  // spans two parts.
@@ -346,6 +432,11 @@ export class ClaudeCodeHarness {
346
432
  renameSync(temp, this.idsFile);
347
433
  }
348
434
  // The session Gavel shows and writes to: the newest one open, else the folder's newest.
435
+ // Whether a session bypasses permission prompts, as its hooks or else its transcript last said.
436
+ bypasses(s) {
437
+ const file = s.transcript ?? claudeSessions(this.ctx.cwd, this.ctx.home, this.ctx.env).find((c) => c.id === s.id)?.file ?? null;
438
+ return (s.mode ?? (file ? lastMode(file) : null)) === "bypassPermissions";
439
+ }
349
440
  current() {
350
441
  const open = [...this.sessions.values()].filter((s) => s.open).sort((a, b) => Number(b.begun) - Number(a.begun) || b.seen - a.seen);
351
442
  return open[0] ?? null;
@@ -404,7 +495,7 @@ export class ClaudeCodeHarness {
404
495
  session(id) {
405
496
  let s = this.sessions.get(id);
406
497
  if (!s) {
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() };
498
+ s = { id, inbox: null, transcript: null, open: true, hooked: false, background: false, begun: false, mode: null, state: "idle", seen: Date.now(), run: null, spoken: new Map() };
408
499
  this.sessions.set(id, s);
409
500
  }
410
501
  return s;
@@ -428,6 +519,8 @@ export class ClaudeCodeHarness {
428
519
  s.inbox = e.inbox;
429
520
  if (typeof input.transcript_path === "string")
430
521
  s.transcript = input.transcript_path;
522
+ if (typeof input.permission_mode === "string")
523
+ s.mode = input.permission_mode;
431
524
  const runId = typeof input.prompt_id === "string" ? input.prompt_id : s.run;
432
525
  switch (event) {
433
526
  case "SessionStart":
@@ -561,7 +654,7 @@ export class ClaudeCodeHarness {
561
654
  open = (await this.liveSession()) ?? this.current();
562
655
  if (open?.inbox) {
563
656
  this.remember(m.id);
564
- if (await inboxSend(open.inbox, text, { priority: "next", msgId: m.id }))
657
+ if (await inboxSend(open.inbox, text, { priority: "next", msgId: m.id, bypass: this.bypasses(open) }))
565
658
  return { outcome: "delivered" };
566
659
  open.open = false;
567
660
  open.inbox = null;
@@ -650,20 +743,22 @@ export class ClaudeCodeHarness {
650
743
  const open = this.current();
651
744
  if (!open?.inbox || (open.state !== "working" && open.state !== "waiting"))
652
745
  return "over";
653
- const sent = await inboxSend(open.inbox, `${this.ctx.person} pressed Stop in Gavel: stop what you're doing, say in a line where you stopped, and wait for them.`, { priority: "now" });
746
+ const sent = await inboxSend(open.inbox, `${this.ctx.person} pressed Stop in Gavel: stop what you're doing, say in a line where you stopped, and wait for them.`, { priority: "now", bypass: this.bypasses(open) });
654
747
  return sent ? "stopped" : "over";
655
748
  }
656
749
  // Gavel's one-line wake (D-1103), into an open session: mid-turn or as a turn of its own.
657
750
  async wake(line) {
658
751
  const open = this.current();
659
- return open?.inbox ? inboxSend(open.inbox, line, { priority: "next" }) : false;
752
+ return open?.inbox ? inboxSend(open.inbox, line, { priority: "next", bypass: this.bypasses(open) }) : false;
660
753
  }
661
754
  listen(l) {
662
755
  this.listener = l;
663
756
  this.stateNow();
664
757
  void this.liveSession().then(() => this.stateNow());
758
+ // Claude Code's words as they're shown, on the folder's own port; one another program holds is
759
+ // left for one the system hands out, so they're neither unheard nor sent to that program.
665
760
  const hook = displayHook(this.ctx.home, this.ctx.cwd);
666
- this.display = createServer((req, res) => {
761
+ const display = createServer((req, res) => {
667
762
  let raw = "";
668
763
  req.on("data", (c) => {
669
764
  raw += c;
@@ -684,11 +779,24 @@ export class ClaudeCodeHarness {
684
779
  }
685
780
  });
686
781
  });
687
- this.display.on("error", () => {
782
+ let moved = false;
783
+ display.on("error", (e) => {
784
+ if (e.code === "EADDRINUSE" && !moved) {
785
+ moved = true;
786
+ display.listen(0, "127.0.0.1");
787
+ return;
788
+ }
688
789
  this.display = null;
790
+ console.error(`gavel bridge: Claude Code's words as they're shown can't reach the bridge here (${e.code ?? e.message}); they show in Gavel once kept.`);
791
+ });
792
+ display.on("listening", () => {
793
+ const at = display.address();
794
+ if (moved)
795
+ console.error(`gavel bridge: another program holds port ${hook.port}, where Claude Code sends its words as they're shown, so the bridge took ${at.port} and ${moveDisplayHook(this.ctx.home, this.ctx.cwd, at.port)}.`);
689
796
  });
690
- this.display.listen(hook.port, "127.0.0.1");
691
- this.display.unref();
797
+ display.listen(hook.port, "127.0.0.1");
798
+ display.unref();
799
+ this.display = display;
692
800
  }
693
801
  // The chat off in Gavel (D-1140): what the bridge kept on the laptop for it goes too, its copies
694
802
  // of the person's pictures and the ids it joins by. The hooks stay: they start no bridge while
package/dist/gavel.js CHANGED
@@ -10,7 +10,7 @@ import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, realpat
10
10
  import { homedir, hostname } from "node:os";
11
11
  import { basename, dirname, extname, join } from "node:path";
12
12
  import { bridgeStatus, harnessFor, holdBridge, hookEvent, lastingCommand, startBridge, stopBridge } from "./bridge/background.js";
13
- import { claudeBridgeHooks, gavelPluginOn } from "./bridge/claude-live.js";
13
+ import { claudeBridgeHooks, claudeHeld, gavelPluginOn } from "./bridge/claude-live.js";
14
14
  import { codexBridgeHooks } from "./bridge/codex.js";
15
15
  import { claudeSetups } from "./bridge/setup.js";
16
16
  import { BRIDGE_HARNESSES, runBridge } from "./bridge/bridge.js";
@@ -99,21 +99,25 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
99
99
  gavel work file (<title> | --title <words>) [--status <status>] [--description <words>]
100
100
  [--worker <email or agent> | --worker none] [--reporter <email or agent>]
101
101
  [--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]... [--label <Group: Name>]...
102
- [--waits-on <W-3,W-4>] [--key <key>]
102
+ [--waits-on <W-3,W-4>] [--program <W-145>] [--key <key>]
103
103
  a work item on the Board's Being done (W-12), when you
104
- start: you're its worker unless you name another, Backlog
104
+ start: you're its worker unless you name another, your
105
+ person its reporter unless you name who directed it (you
106
+ only for your own finding), Backlog
105
107
  unless --status (Triage, Backlog, Needs Decision, Queued,
106
108
  Building, Blocked, Deployed, Icebox, Closed, Duplicate);
107
- --waits-on the items it waits on; --key your own id for
108
- it, so a retry files it once
109
+ --waits-on the items it waits on; --program the item
110
+ it's a piece of; --key your own id for it, so a retry
111
+ files it once
109
112
  gavel work move <W-12> [<status>] [--waiting-on <email or agent>] [--decision <D-12>]
110
- [--code <url>]... [--worker <email or agent> | --worker none] [--title <words>]
111
- [--description <words>] [--label <Group: Name>]... [--label none] [--waits-on <W-3,W-4> | --waits-on none]
113
+ [--code <url>]... [--worker <email or agent> | --worker none] [--reporter <email or agent>]
114
+ [--title <words>] [--description <words>] [--label <Group: Name>]... [--label none]
115
+ [--waits-on <W-3,W-4> | --waits-on none] [--program <W-145> | --program none]
112
116
  move it as your work moves: Building, Blocked with
113
117
  --waiting-on, Needs Decision with --decision, Deployed
114
118
  with --code (a commit or pull request; again for each);
115
119
  --label sets all its labels (again for each), --waits-on
116
- all the items it waits on
120
+ all the items it waits on, --reporter who directed it
117
121
  gavel work show <W-12> an item and its history
118
122
  gavel work list [--worker me|<email or agent>] [--status <status>] [--open true]
119
123
  the workspace's items, the latest changed first, and
@@ -127,11 +131,13 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
127
131
  gavel work done <W-12> [--code <url>]... finish it: Deployed with its code, your claim ends; if
128
132
  your push already deployed it, done, the code added
129
133
  gavel message (--to-agent <id> | --to-person <email>) (<text> | --text <words>) [--decision <D-12>]
130
- [--no-reply true] [--key <key>]
134
+ [--no-reply true] [--now true] [--key <key>]
131
135
  start a conversation with another agent
132
- gavel message --conversation <C-12> (<text> | --text <words>) [--no-reply true] [--key <key>]
136
+ gavel message --conversation <C-12> (<text> | --text <words>) [--no-reply true] [--now true] [--key <key>]
133
137
  reply in one; --no-reply true: a note, which never wakes
134
- them; --key: your own id for it, so a retry sends it once
138
+ them; --now true: wake an agent below you at once (else
139
+ it comes with their next routine wake); --key: your own
140
+ id for it, so a retry sends it once
135
141
  gavel message --item <W-12> (<text> | --text <words>) [--no-reply true] [--key <key>]
136
142
  write in a work item's thread, which all on it read
137
143
  gavel conversations [<C-12>] yours, or one with its messages (reads it)
@@ -195,7 +201,8 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
195
201
  gavel undo <eventId> their latest action, by them or by you (the card's
196
202
  undo.eventId)
197
203
  gavel todo-done <D-12> --their-words <words> [--note <words>]
198
- gavel todo-cant <D-12> (<reason> | --reason <words>) --their-words <words>
204
+ gavel todo-ignore <D-12> [<reason> | --reason <words>] --their-words <words>
205
+ closes it; its asker hears it was ignored
199
206
  gavel decided-without-you [--date <YYYY-MM-DD>]
200
207
  what their agents decided on their own that day
201
208
  gavel overrule <D-12> [--text <words> --their-words <words>] [--note <words>]
@@ -208,6 +215,10 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
208
215
  [--later-like-now true|false] [--muted true|false] [--workspace-sound <name>|none]
209
216
  [--snooze-until <time>|none]
210
217
  gavel set-my-reports [--weekly-report true|false] [--slack-messages true|false]
218
+ gavel set-agent-runtime <agent id> [--model <id>|cursor-default|none] [--effort low|medium|high|xhigh|max|none]
219
+ [--context 300k|1m|none] a Cursor agent's model, effort and context (none: the router's)
220
+ gavel set-area-runtime <area id> [--model <id>|cursor-default|none] [--effort <effort>|none] [--context 300k|1m|none]
221
+ gavel set-job-runtime work|wake|chat|night [--model <id>|cursor-default|none] [--effort <effort>|none] [--context 300k|1m|none]
211
222
  gavel my-notifications [--limit <n>] what went out to them, and how many are unread
212
223
  gavel mark-notification-read <id>
213
224
  gavel my-weekly-report
@@ -310,8 +321,8 @@ const FLAGS = {
310
321
  inbox: [],
311
322
  status: ["text", "description", "folders", "state", "issue", "waiting-on", "item"],
312
323
  "claim-folders": ["mode", "item"],
313
- work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open", "waits-on", "area", "why", "key"],
314
- message: ["to-agent", "to-person", "conversation", "item", "text", "decision", "no-reply", "key"],
324
+ work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open", "waits-on", "program", "area", "why", "key"],
325
+ message: ["to-agent", "to-person", "conversation", "item", "text", "decision", "no-reply", "now", "key"],
315
326
  thread: [],
316
327
  conversations: [],
317
328
  "wait-for-reply": ["timeout"],
@@ -341,6 +352,7 @@ const FLAGS = {
341
352
  defer: ["trust-words"],
342
353
  undo: [],
343
354
  "todo-done": ["note", "their-words"],
355
+ "todo-ignore": ["reason", "their-words"],
344
356
  "todo-cant": ["reason", "their-words"],
345
357
  "decided-without-you": ["date"],
346
358
  overrule: ["text", "note", "their-words"],
@@ -348,6 +360,9 @@ const FLAGS = {
348
360
  "set-my-day": ["timezone", "day-start", "day-end", "morning", "later-every"],
349
361
  "set-my-alerts": ["on-call", "sounds", "sound", "later-like-now", "muted", "workspace-sound", "snooze-until"],
350
362
  "set-my-reports": ["weekly-report", "slack-messages"],
363
+ "set-agent-runtime": ["model", "effort", "context"],
364
+ "set-area-runtime": ["model", "effort", "context"],
365
+ "set-job-runtime": ["model", "effort", "context"],
351
366
  "my-notifications": ["limit"],
352
367
  "mark-notification-read": [],
353
368
  "my-weekly-report": [],
@@ -409,6 +424,7 @@ const FOR_PERSON = [
409
424
  "defer",
410
425
  "undo",
411
426
  "todo-done",
427
+ "todo-ignore",
412
428
  "todo-cant",
413
429
  "decided-without-you",
414
430
  "overrule",
@@ -416,6 +432,9 @@ const FOR_PERSON = [
416
432
  "set-my-day",
417
433
  "set-my-alerts",
418
434
  "set-my-reports",
435
+ "set-agent-runtime",
436
+ "set-area-runtime",
437
+ "set-job-runtime",
419
438
  "my-notifications",
420
439
  "mark-notification-read",
421
440
  "my-weekly-report",
@@ -542,22 +561,23 @@ function workRequest(p, f, code, label) {
542
561
  };
543
562
  switch (sub) {
544
563
  case "file": {
545
- only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "waits-on", "key"]);
564
+ only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "waits-on", "program", "key"]);
546
565
  if (f.title !== undefined && rest.length)
547
566
  throw new UsageError("give the title once: as words or as --title");
548
567
  const title = readText(need(f.title ?? rest.join(" "), "the item's title"));
549
568
  return {
550
569
  method: "POST",
551
570
  path: "/v1/work",
552
- body: compact({ title, status: f.status, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels, waitsOn, key: f.key }),
571
+ body: compact({ title, status: f.status, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels, waitsOn, program: f.program, key: f.key }),
553
572
  };
554
573
  }
555
574
  case "move": {
556
- only(["title", "status", "description", "worker", "waiting-on", "decision", "code", "label", "waits-on"]);
575
+ only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "waits-on", "program"]);
557
576
  const [item, ...words] = rest;
558
577
  if (f.status !== undefined && words.length)
559
578
  throw new UsageError("give the status once: as words or as --status");
560
- const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels, waitsOn });
579
+ const program = f.program === undefined ? undefined : f.program === "none" ? null : f.program;
580
+ const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels, waitsOn, program });
561
581
  if (!Object.keys(body).length)
562
582
  throw new UsageError("work move needs a status or something to change");
563
583
  return { method: "PATCH", path: `/v1/work/${ref(item)}`, body };
@@ -664,8 +684,14 @@ function personRequest(command, p, f, options) {
664
684
  case "todo-done":
665
685
  upTo(1);
666
686
  return asThem("POST", `/v1/decisions/${ref(p[0])}/done`, { note: f.note && readText(f.note), theirWords: theirWords() });
667
- case "todo-cant":
668
- return asThem("POST", `/v1/decisions/${ref(p[0])}/cant`, { reason: words("reason", p.slice(1), "why it can't be done"), theirWords: theirWords() });
687
+ // todo-cant is todo-ignore's earlier name.
688
+ case "todo-ignore":
689
+ case "todo-cant": {
690
+ if (f.reason !== undefined && p.length > 1)
691
+ throw new UsageError("give why once: as words or as --reason");
692
+ const reason = f.reason ?? p.slice(1).join(" ");
693
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/ignore`, { reason: reason ? readText(reason) : undefined, theirWords: theirWords() });
694
+ }
669
695
  case "decided-without-you":
670
696
  upTo(0);
671
697
  return asThem("GET", `/v1/decided-without-you${f.date ? `?date=${encodeURIComponent(f.date)}` : ""}`);
@@ -696,6 +722,19 @@ function personRequest(command, p, f, options) {
696
722
  case "set-my-reports":
697
723
  upTo(0);
698
724
  return changes({ weeklyReport: yesNo("weekly-report"), slackMessages: yesNo("slack-messages") });
725
+ case "set-agent-runtime":
726
+ case "set-area-runtime":
727
+ case "set-job-runtime": {
728
+ upTo(1);
729
+ const body = compact({ model: orNone("model"), effort: orNone("effort"), context: orNone("context") });
730
+ if (!Object.keys(body).length)
731
+ throw new UsageError("give --model, --effort or --context: none sets one back to the router's pick");
732
+ if (command === "set-agent-runtime")
733
+ return asThem("PUT", `/v1/agents/${encodeURIComponent(need(p[0], "the agent's id"))}/runtime`, body);
734
+ if (command === "set-area-runtime")
735
+ return asThem("PUT", `/v1/areas/${encodeURIComponent(need(p[0], "the area's id"))}/runtime`, body);
736
+ return asThem("PUT", `/v1/workspace/runtime/jobs/${encodeURIComponent(need(p[0], "the kind of job: work, wake, chat or night"))}`, body);
737
+ }
699
738
  case "my-notifications":
700
739
  upTo(0);
701
740
  return asThem("GET", `/v1/notifications${f.limit ? `?limit=${encodeURIComponent(f.limit)}` : ""}`);
@@ -1153,7 +1192,7 @@ export function toRequest(argv) {
1153
1192
  case "message": {
1154
1193
  const text = readText(words("text", p, "what to say"));
1155
1194
  if (f.item) {
1156
- if (f.conversation || f["to-agent"] || f["to-person"] || f.decision !== undefined)
1195
+ if (f.conversation || f["to-agent"] || f["to-person"] || f.decision !== undefined || f.now !== undefined)
1157
1196
  throw new UsageError("--item writes in a work item's thread: give it alone, with --no-reply and --key if you like");
1158
1197
  const quiet = f["no-reply"];
1159
1198
  if (quiet !== undefined && quiet !== "true" && quiet !== "false")
@@ -1167,7 +1206,9 @@ export function toRequest(argv) {
1167
1206
  const noReply = f["no-reply"];
1168
1207
  if (noReply !== undefined && noReply !== "true" && noReply !== "false")
1169
1208
  throw new UsageError("--no-reply is true or false");
1170
- const sending = { noReply: noReply === undefined ? undefined : noReply === "true", key: f.key };
1209
+ if (f.now !== undefined && f.now !== "true" && f.now !== "false")
1210
+ throw new UsageError("--now is true or false");
1211
+ const sending = { noReply: noReply === undefined ? undefined : noReply === "true", now: f.now === undefined ? undefined : f.now === "true", key: f.key };
1171
1212
  if (f.conversation)
1172
1213
  return { method: "POST", path: `/v1/conversations/${encodeURIComponent(f.conversation)}/messages`, body: compact({ text, ...sending }) };
1173
1214
  return { method: "POST", path: "/v1/conversations", body: compact({ toAgentId: f["to-agent"], toPerson: f["to-person"], text, decision: f.decision, ...sending }) };
@@ -1695,17 +1736,26 @@ async function background(run) {
1695
1736
  return hookEvent({ home, cwd, harness, server: run.server, name: run.name, env });
1696
1737
  case "start": {
1697
1738
  const started = await startBridge({ home, cwd, harness, server: run.server, untilClosed: false, env });
1698
- print(started.bridge === "failed" ? { ...started, reason: lastLine(started.log) } : started);
1699
- return started.bridge === "failed" ? 1 : 0;
1739
+ if (started.bridge !== "failed") {
1740
+ print(started);
1741
+ return 0;
1742
+ }
1743
+ const reason = lastLine(started.log);
1744
+ print({ ...started, reason });
1745
+ // On stderr too, so a failed start always says why (W-244).
1746
+ console.error(`gavel bridge: it didn't start${reason ? `: ${reason}` : ""} (its log: ${started.log}).`);
1747
+ return 1;
1700
1748
  }
1701
1749
  case "stop": {
1702
1750
  const stopped = await stopBridge({ home, cwd, harness });
1703
1751
  print(stopped);
1704
1752
  return stopped.bridge === "still running" ? 1 : 0;
1705
1753
  }
1706
- case "status":
1707
- print(bridgeStatus({ home, cwd, harness }));
1754
+ case "status": {
1755
+ const held = harness === "claude-code" ? claudeHeld(cwd, home, env) : null;
1756
+ print({ ...bridgeStatus({ home, cwd, harness }), ...(held ? { held } : {}) });
1708
1757
  return 0;
1758
+ }
1709
1759
  case "service": {
1710
1760
  const answer = bridgeService(run.service, { home, cwd, harness, server: run.server, env });
1711
1761
  print(answer);
@@ -1836,7 +1886,9 @@ export function wakeLine(item) {
1836
1886
  case "claim":
1837
1887
  return `GAVEL_WAKE claim on ${item.ref} ran out, back in Queued: see gavel inbox, then give it to an agent or let one claim it`;
1838
1888
  case "work":
1839
- return `GAVEL_WAKE work ${item.ref} Blocked half an hour: move it, or name it Blocked again with gavel work move ${item.ref} Blocked`;
1889
+ return item.type === "stale"
1890
+ ? `GAVEL_WAKE work ${item.ref} two hours quiet in Building: move it to where it really is (gavel work done ${item.ref}, gavel work release ${item.ref}, or Blocked with gavel work move), or work on it`
1891
+ : `GAVEL_WAKE work ${item.ref} Blocked half an hour: move it, or name it Blocked again with gavel work move ${item.ref} Blocked`;
1840
1892
  case "drift":
1841
1893
  return `GAVEL_WAKE drift on ${item.ref}: it may go against ${item.type ?? "a decision"}: see gavel inbox`;
1842
1894
  case "task":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
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",