@getgavel/cli 0.1.22 → 0.1.24

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.22",
3
+ "version": "0.1.24",
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
  }
@@ -110,6 +110,32 @@ export function displayHook(home, cwd) {
110
110
  }
111
111
  return { port, secret, url: `http://127.0.0.1:${port}${DISPLAY_PATH}${secret}`, file };
112
112
  }
113
+ // The display hook on another port, the folder's own being another program's: kept for next time,
114
+ // and its address rewritten where the bridge's hooks put it, the folder's own settings, which a
115
+ // running session reloads; never in a file git tracks. What it did, in words for the bridge's log.
116
+ export function moveDisplayHook(home, cwd, port) {
117
+ const was = displayHook(home, cwd);
118
+ writeFileSync(was.file, `${JSON.stringify({ port, secret: was.secret })}\n`, { mode: 0o600 });
119
+ const name = ".claude/settings.local.json";
120
+ let settings;
121
+ try {
122
+ settings = JSON.parse(readFileSync(join(cwd, name), "utf8"));
123
+ }
124
+ catch {
125
+ return `kept it; no ${name} here names the hook`;
126
+ }
127
+ const named = Object.values(settings.hooks ?? {})
128
+ .flatMap((groups) => (groups ?? []).flatMap((g) => g.hooks ?? []))
129
+ .filter((h) => h.url === was.url);
130
+ if (!named.length)
131
+ return `kept it; ${name} doesn't name the hook`;
132
+ if (gitIn(["ls-files", "--error-unmatch", name], cwd))
133
+ return `kept it, but git tracks ${name}, so the hook there still names the old port`;
134
+ for (const h of named)
135
+ h.url = `http://127.0.0.1:${port}${DISPLAY_PATH}${was.secret}`;
136
+ writeWhole(join(cwd, name), `${JSON.stringify(settings, null, 2)}\n`);
137
+ return `wrote it into ${name}`;
138
+ }
113
139
  const gitIn = (args, cwd) => {
114
140
  try {
115
141
  execFileSync("git", args, { cwd, stdio: "ignore" });
@@ -310,8 +336,9 @@ export class ClaudeCodeHarness {
310
336
  watcher = null;
311
337
  watching = null;
312
338
  display = null;
313
- resumed = null;
314
339
  lastState = null;
340
+ // The short ids Claude Code gave the sessions the bridge put in the background.
341
+ backgrounded = new Set();
315
342
  changedTimer = null;
316
343
  // The person's name, for the words that say who wrote: the core learns it after it builds the
317
344
  // harness, from GET /v1/me.
@@ -346,17 +373,21 @@ export class ClaudeCodeHarness {
346
373
  }
347
374
  // The session Gavel shows and writes to: the newest one open, else the folder's newest.
348
375
  current() {
349
- const open = [...this.sessions.values()].filter((s) => s.open).sort((a, b) => b.seen - a.seen);
376
+ const open = [...this.sessions.values()].filter((s) => s.open).sort((a, b) => Number(b.begun) - Number(a.begun) || b.seen - a.seen);
350
377
  return open[0] ?? null;
351
378
  }
352
- setState(next) {
353
- if (next === this.lastState)
379
+ setState(next, opens) {
380
+ const said = `${next} ${opens ?? ""}`;
381
+ if (said === this.lastState)
354
382
  return;
355
- this.lastState = next;
356
- this.listener?.state(next);
383
+ this.lastState = said;
384
+ this.listener?.state(next, opens);
357
385
  }
386
+ // A session in the background that waits on a prompt opens with `claude attach` and the short id
387
+ // Claude Code gives it (its id's first 8 characters).
358
388
  stateNow() {
359
- this.setState(this.current()?.state ?? "closed");
389
+ const s = this.current();
390
+ this.setState(s?.state ?? "closed", s?.state === "waiting" && s.background ? `claude attach ${s.id.slice(0, 8)}` : null);
360
391
  }
361
392
  // A transcript write comes as a few file events at once: one changed() for them, quickly, since the
362
393
  // session's copy of a Gavel message is what marks it read.
@@ -399,7 +430,7 @@ export class ClaudeCodeHarness {
399
430
  session(id) {
400
431
  let s = this.sessions.get(id);
401
432
  if (!s) {
402
- s = { id, inbox: null, transcript: null, open: true, hooked: false, state: "idle", seen: Date.now(), run: null, spoken: new Map() };
433
+ s = { id, inbox: null, transcript: null, open: true, hooked: false, background: false, begun: false, state: "idle", seen: Date.now(), run: null, spoken: new Map() };
403
434
  this.sessions.set(id, s);
404
435
  }
405
436
  return s;
@@ -416,6 +447,9 @@ export class ClaudeCodeHarness {
416
447
  const s = this.session(id);
417
448
  s.seen = Date.now();
418
449
  s.hooked = true;
450
+ s.begun ||= event === "SessionStart" ? input.source !== "startup" : event !== "SessionEnd";
451
+ if (this.backgrounded.has(id.slice(0, 8)))
452
+ s.background = true;
419
453
  if (e.inbox)
420
454
  s.inbox = e.inbox;
421
455
  if (typeof input.transcript_path === "string")
@@ -563,15 +597,17 @@ export class ClaudeCodeHarness {
563
597
  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.` };
564
598
  return this.resume(m, text);
565
599
  }
566
- // A closed session, resumed with the person's words as a turn of its own (D-905): nothing that
567
- // would prompt runs. Delivered once the run starts; what it refused, or why it failed, comes after
568
- // as the bridge's note.
600
+ // A closed session, resumed with the person's words as a turn of its own in the background
601
+ // (D-1174, changing D-905's "nothing that would prompt runs"): it runs under their own permission
602
+ // settings, and what would ask them waits till they open it on the laptop (`claude attach`). Its
603
+ // edits stay in the folder, as their own session's: no worktree of its own (Master Gavel's call).
604
+ // The words go on stdin, never in its arguments. Delivered once Claude Code says it's backgrounded;
605
+ // from then the session's own hooks name it, so their next words go through its inbox.
569
606
  resume(m, text) {
570
607
  const newest = claudeSessions(this.ctx.cwd, this.ctx.home, this.ctx.env)[0] ?? null;
571
- const args = ["-p", ...(newest ? ["--resume", newest.id] : []), "--permission-prompts", "none", "--output-format", "json"];
608
+ const args = [...(newest ? ["--resume", newest.id] : []), "--bg", "--settings", JSON.stringify({ worktree: { bgIsolation: "none" } })];
572
609
  return new Promise((resolve) => {
573
- const child = spawn("claude", args, { cwd: this.ctx.cwd, stdio: ["pipe", "pipe", "pipe"] });
574
- this.resumed = child;
610
+ const child = spawn("claude", args, { cwd: this.ctx.cwd, env: this.ctx.env, stdio: ["pipe", "pipe", "pipe"] });
575
611
  let out = "";
576
612
  let err = "";
577
613
  let settled = false;
@@ -580,38 +616,27 @@ export class ClaudeCodeHarness {
580
616
  resolve(d);
581
617
  settled = true;
582
618
  };
619
+ const quit = setTimeout(() => child.kill(), 60_000);
583
620
  child.stdout.on("data", (d) => (out += d));
584
621
  child.stderr.on("data", (d) => (err += d));
585
- child.on("spawn", () => {
586
- this.remember(m.id, promptKey(text));
587
- setTimeout(() => settle({ outcome: "delivered" }), 300).unref();
588
- });
589
622
  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}` }));
590
623
  child.on("close", (code) => {
591
- this.resumed = null;
592
- let result = null;
593
- try {
594
- result = JSON.parse(out);
595
- }
596
- catch {
597
- // its reason is on stderr
598
- }
599
- const first = (t) => t.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
600
- if (code === 0 && result && !result.is_error) {
601
- const refused = [...new Set((result.permission_denials ?? []).map((d) => d?.tool_name).filter((n) => typeof n === "string"))];
602
- if (refused.length)
603
- 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.`);
624
+ clearTimeout(quit);
625
+ const short = /^backgrounded · ([0-9a-f]{8,36})\b/m.exec(out)?.[1];
626
+ if (code === 0 && short) {
627
+ this.remember(m.id, promptKey(text));
628
+ this.backgrounded.add(short.slice(0, 8));
604
629
  settle({ outcome: "delivered" });
605
630
  }
606
631
  else {
607
- const said = (typeof result?.result === "string" ? first(result.result) : "") || first(err);
608
- 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);
609
- if (settled)
610
- this.listener?.note(reason);
632
+ const first = (t) => t.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
633
+ const said = first(err) || first(out);
634
+ 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);
611
635
  settle({ outcome: "failed", reason });
612
636
  }
613
637
  this.listener?.changed();
614
638
  });
639
+ child.stdin.on("error", () => undefined);
615
640
  child.stdin.end(text);
616
641
  });
617
642
  }
@@ -636,6 +661,7 @@ export class ClaudeCodeHarness {
636
661
  const s = this.session(newest.sessionId);
637
662
  s.open = true;
638
663
  s.inbox = s.inbox ?? (socket ? { socket, token: null } : null);
664
+ s.background ||= newest.kind === "background";
639
665
  s.state = newest.status === "busy" ? "working" : newest.status === "waiting" ? "waiting" : "idle";
640
666
  this.stateNow();
641
667
  return s;
@@ -645,12 +671,8 @@ export class ClaudeCodeHarness {
645
671
  }
646
672
  }
647
673
  // Stop in Gavel: the turn interrupted from its inbox (priority now), Claude then reading why; a
648
- // resumed run is ended. Over when nothing runs.
674
+ // resumed session's too, in the background. Over when nothing runs.
649
675
  async interrupt() {
650
- if (this.resumed) {
651
- this.resumed.kill("SIGINT");
652
- return "stopped";
653
- }
654
676
  const open = this.current();
655
677
  if (!open?.inbox || (open.state !== "working" && open.state !== "waiting"))
656
678
  return "over";
@@ -666,8 +688,10 @@ export class ClaudeCodeHarness {
666
688
  this.listener = l;
667
689
  this.stateNow();
668
690
  void this.liveSession().then(() => this.stateNow());
691
+ // Claude Code's words as they're shown, on the folder's own port; one another program holds is
692
+ // left for one the system hands out, so they're neither unheard nor sent to that program.
669
693
  const hook = displayHook(this.ctx.home, this.ctx.cwd);
670
- this.display = createServer((req, res) => {
694
+ const display = createServer((req, res) => {
671
695
  let raw = "";
672
696
  req.on("data", (c) => {
673
697
  raw += c;
@@ -688,11 +712,24 @@ export class ClaudeCodeHarness {
688
712
  }
689
713
  });
690
714
  });
691
- this.display.on("error", () => {
715
+ let moved = false;
716
+ display.on("error", (e) => {
717
+ if (e.code === "EADDRINUSE" && !moved) {
718
+ moved = true;
719
+ display.listen(0, "127.0.0.1");
720
+ return;
721
+ }
692
722
  this.display = null;
723
+ 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.`);
724
+ });
725
+ display.on("listening", () => {
726
+ const at = display.address();
727
+ if (moved)
728
+ 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)}.`);
693
729
  });
694
- this.display.listen(hook.port, "127.0.0.1");
695
- this.display.unref();
730
+ display.listen(hook.port, "127.0.0.1");
731
+ display.unref();
732
+ this.display = display;
696
733
  }
697
734
  // The chat off in Gavel (D-1140): what the bridge kept on the laptop for it goes too, its copies
698
735
  // of the person's pictures and the ids it joins by. The hooks stay: they start no bridge while
@@ -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
@@ -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 }) };
@@ -1836,7 +1877,9 @@ export function wakeLine(item) {
1836
1877
  case "claim":
1837
1878
  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
1879
  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`;
1880
+ return item.type === "stale"
1881
+ ? `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`
1882
+ : `GAVEL_WAKE work ${item.ref} Blocked half an hour: move it, or name it Blocked again with gavel work move ${item.ref} Blocked`;
1840
1883
  case "drift":
1841
1884
  return `GAVEL_WAKE drift on ${item.ref}: it may go against ${item.type ?? "a decision"}: see gavel inbox`;
1842
1885
  case "task":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
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",