@getgavel/cli 0.1.8 → 0.1.10

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.
Files changed (3) hide show
  1. package/README.md +23 -0
  2. package/dist/gavel.js +467 -21
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -38,6 +38,29 @@ gavel act --help # one command's usage
38
38
  `GAVEL_TOKEN` is your agent's token (pairing sets it up); `GAVEL_API_URL` defaults to
39
39
  `https://api.getgavel.ai`. How an agent works with Gavel: <https://getgavel.ai/agents.md>.
40
40
 
41
+ ## For your person
42
+
43
+ Once your person lets you, their personal agent, do what they can in Gavel (Settings › Agents,
44
+ "Can do what you can in Gavel"), you act as them: on their decisions, settings, trusts, agents and
45
+ Blockers.
46
+
47
+ ```sh
48
+ gavel my-queue # their queue
49
+ gavel decide-mine D-12 --option <id> --their-words "ship it" # only on their word, from your chat
50
+ gavel boomerang D-12 # forward-mine, research-more, ask-someone, defer, undo…
51
+ gavel set-my-day --day-start 09:00 --day-end 18:00 # their day, alerts, reports and trusts
52
+ gavel move-agent-mine <agent id> --under <agent id> # their agents: edit, pause, archive…
53
+ gavel my-blockers # what's stuck; nudge-mine, reassign
54
+ gavel call GET /v1/me --for-person true # any route, as you or as them
55
+ ```
56
+
57
+ ## In GitHub Actions
58
+
59
+ A job with `permissions: id-token: write` needs no pasted token: the command trades GitHub's token
60
+ for the run's own, once a person has let the repository's runs ask under one of their agents
61
+ (Settings › Agents). `gavel actions-env` writes it, masked, as `GAVEL_TOKEN` for the job's later
62
+ steps, for an agent there that speaks MCP.
63
+
41
64
  ## Your Claude Code or Codex chat, in Gavel
42
65
 
43
66
  If your agent works in Claude Code or Codex on your laptop, run this in its folder, in a terminal
package/dist/gavel.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  // The `gavel` command-line tool: the MCP server's operations over the HTTP API, for agents that
3
3
  // prefer a shell. GAVEL_TOKEN (an agent's token) and GAVEL_API_URL (default https://api.getgavel.ai);
4
- // on a fleet token, the chat's name with --as or GAVEL_AGENT (sent as X-Gavel-Agent).
4
+ // on a fleet token, the chat's name with --as or GAVEL_AGENT (sent as X-Gavel-Agent). In a GitHub
5
+ // Actions job with id-token: write and no GAVEL_TOKEN, the run's own token, traded for GitHub's.
5
6
  // Prints the API's JSON; on an error, prints it to stderr and exits 1.
6
7
  import { execFileSync } from "node:child_process";
7
8
  import { createHash, randomUUID } from "node:crypto";
@@ -23,6 +24,9 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
23
24
  the words it would send from the newest session here; sends
24
25
  nothing
25
26
  gavel bridge wake [--server <name>] the bridge's wake hook, which Claude Code runs (not by hand)
27
+ gavel actions-env in a GitHub Actions job with id-token: write, GAVEL_TOKEN
28
+ for its next steps: the run's own token, traded for
29
+ GitHub's and masked (never printed)
26
30
  gavel search (<words> | --query <words>) [--area <slug>] [--status open|decided|any] [--limit <n>]
27
31
  gavel ask --file decision.json the decision, as MCP ask's input
28
32
  gavel revise <D-12> --file decision.json a draft the editor sent back, fixed (the whole ask again)
@@ -52,20 +56,22 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
52
56
  which follows your state (Building, or Blocked)
53
57
  gavel work file (<title> | --title <words>) [--status <status>] [--description <words>]
54
58
  [--worker <email or agent> | --worker none] [--reporter <email or agent>]
55
- [--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]...
59
+ [--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]... [--label <Group: Name>]...
56
60
  a work item on the Board's Being done (W-12), when you
57
61
  start: you're its worker unless you name another, Backlog
58
62
  unless --status (Triage, Backlog, Needs Decision, Queued,
59
63
  Building, Blocked, Deployed, Icebox, Closed, Duplicate)
60
64
  gavel work move <W-12> [<status>] [--waiting-on <email or agent>] [--decision <D-12>]
61
65
  [--code <url>]... [--worker <email or agent> | --worker none] [--title <words>]
62
- [--description <words>]
66
+ [--description <words>] [--label <Group: Name>]... [--label none]
63
67
  move it as your work moves: Building, Blocked with
64
68
  --waiting-on, Needs Decision with --decision, Deployed
65
- with --code (a commit or pull request; again for each)
69
+ with --code (a commit or pull request; again for each);
70
+ --label sets all its labels (again for each)
66
71
  gavel work show <W-12> an item and its history
67
72
  gavel work list [--worker me|<email or agent>] [--status <status>] [--open true]
68
- the workspace's items, the latest changed first
73
+ the workspace's items, the latest changed first, and
74
+ its labels
69
75
  gavel message (--to-agent <id> | --to-person <email>) (<text> | --text <words>) [--decision <D-12>]
70
76
  start a conversation with another agent
71
77
  gavel message --conversation <C-12> (<text> | --text <words>)
@@ -98,21 +104,92 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
98
104
  your person's own machine (My Machines), --agent starts an
99
105
  agent under you, or yourself, as itself (no --name), its
100
106
  old tokens ended
107
+ gavel move-agent <agent id> --under <agent id>
108
+ an agent below you, with what's under it, under you or
109
+ another agent below you
110
+ gavel call <GET|POST|PUT|PATCH|DELETE> </v1/path> [--query <name=value>] [--body <file.json>]
111
+ [--for-person true] any route of the API as you, or as your person with
112
+ --for-person: MCP's do_action, the answer as it comes
101
113
  gavel me
114
+ gavel my-queue [--view mine|asked|decided] [--before <time>] [--limit <n>]
115
+ your person's queue, what they asked, or their Decided
116
+ gavel decide-mine <D-12> (--option <id> | --text <words>) --their-words <words> [--note <words>]
117
+ decide one of theirs, only on their word: what they said
118
+ in your chat that decides it
119
+ gavel forward-mine <D-12> (--to-person <email> | --to-agent <id>) [--note <words>]
120
+ gavel boomerang <D-12> [--until <time>] [--when-answers <email>]
121
+ back at their next morning, at --until, or when someone
122
+ answers
123
+ gavel research-more <D-12> (<prompt> | --prompt <words>) [--to-person <email,email>]
124
+ [--to-agent <id,id>] to those mentioned, else to you, their personal agent
125
+ gavel ask-someone <D-12> (--to-person <email> | --to-agent <id>) (<prompt> | --prompt <words>)
126
+ gavel defer <D-12> [--trust-words <words>]
127
+ to you, with a trust that makes decisions like it yours
128
+ gavel undo <eventId> their latest action, by them or by you (the card's
129
+ undo.eventId)
130
+ gavel todo-done <D-12> --their-words <words> [--note <words>]
131
+ gavel todo-cant <D-12> (<reason> | --reason <words>) --their-words <words>
132
+ gavel decided-without-you [--date <YYYY-MM-DD>]
133
+ what their agents decided on their own that day
134
+ gavel overrule <D-12> [--text <words> --their-words <words>] [--note <words>]
135
+ what one of their agents decided: their own decision
136
+ instead, or reopened in their queue
137
+ gavel my-settings your person's day, alerts, weekly report and Slack messages
138
+ gavel set-my-day [--timezone <zone>] [--day-start <HH:MM>] [--day-end <HH:MM>] [--morning <HH:MM>]
139
+ [--later-every <minutes>] when Now alerts may reach them, their morning, Later's pace
140
+ gavel set-my-alerts [--on-call true|false] [--sounds all|now|off] [--sound <name>]
141
+ [--later-like-now true|false] [--muted true|false] [--workspace-sound <name>|none]
142
+ [--snooze-until <time>|none]
143
+ gavel set-my-reports [--weekly-report true|false] [--slack-messages true|false]
144
+ gavel my-notifications [--limit <n>] what went out to them, and how many are unread
145
+ gavel mark-notification-read <id>
146
+ gavel my-weekly-report
147
+ gavel my-trusts what their agents decide without asking them
148
+ gavel add-trust --agent <id> --words <plain words> [--area <id>]
149
+ for one of their own agents
150
+ gavel edit-trust <trust id> [--words <plain words>] [--area <id>|none]
151
+ gavel revoke-trust <trust id>
152
+ gavel trust-decisions <trust id>
153
+ gavel trust-suggestions <D-12> Defer to my agent's ready-made trusts for a decision
154
+ gavel my-agents your person's agents and their sub-agents
155
+ gavel edit-agent <agent id> [--name <name>] [--title <title>|none] [--description <words>]
156
+ gavel show-agent <agent id> --visible true|false
157
+ shown to the workspace, or hidden, with what's under it
158
+ gavel pause-agent <agent id> [--paused true|false]
159
+ paused (the default), or resumed with --paused false
160
+ gavel set-agent-permissions <agent id> [--permissions <ask,answer>] [--may-invite true|false]
161
+ [--may-ask-person true|false]
162
+ gavel add-sub-agent <parent agent id> --name <name> [--description <words>] [--permissions <ask,answer>]
163
+ no token: your person pairs it by hand
164
+ gavel move-agent-mine <agent id> --under <agent id>
165
+ one of theirs, with what's under it, under another of theirs
166
+ gavel archive-agent <agent id> a sub-agent, back as it was on its next call
167
+ gavel remove-agent <agent id> --their-words <words>
168
+ an agent and everything under it, for good: only on
169
+ their word
170
+ gavel my-blockers what's stuck, as Blockers shows your person
171
+ gavel nudge-mine <D-12> its decider, for them: once a day, when it blocks them
172
+ gavel reassign <D-12> (--to-person <email> | --to-agent <id>) [--note <words>]
173
+ a stuck decision to someone else, for them: an Admin's
102
174
 
103
175
  --as <name> on a fleet token, which chat you are (the name you go by,
104
176
  e.g. worker 35 or the task you're on; keep using the same one)
105
177
 
106
178
  gavel <command> --help shows one command's usage. A command refuses a flag or a word it doesn't
107
- take, and a flag given twice (but --option), with its usage.
179
+ take, and a flag given twice (but --option, --code, --label and --query), with its usage.
180
+ The commands from my-queue to reassign act for your person, as them, once they've let you
181
+ (Settings › Agents); each goes with X-Gavel-For-Person.
108
182
  A text argument or --file of "-" is read from stdin.
109
- Environment: GAVEL_TOKEN (required), GAVEL_API_URL (default https://api.getgavel.ai),
110
- GAVEL_AGENT (instead of --as).`;
183
+ Environment: GAVEL_TOKEN (required, but a GitHub Actions job with id-token: write trades GitHub's
184
+ token for the run's own, named by --as or GAVEL_AGENT), GAVEL_API_URL (default
185
+ https://api.getgavel.ai), GAVEL_AGENT (instead of --as), GAVEL_WORKSPACE (a run's workspace, only
186
+ when its repository asks in more than one).`;
111
187
  // What each command takes besides its words, as its usage above names them: anything else is
112
188
  // refused with that usage, never dropped.
113
189
  const FLAGS = {
114
190
  pair: ["harness", "machine"],
115
191
  bridge: ["harness", "server"],
192
+ "actions-env": [],
116
193
  search: ["query", "area", "status", "limit"],
117
194
  ask: ["file"],
118
195
  revise: ["file"],
@@ -126,7 +203,7 @@ const FLAGS = {
126
203
  act: ["note"],
127
204
  inbox: [],
128
205
  status: ["text", "description", "folders", "state", "issue", "waiting-on", "item"],
129
- work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "open"],
206
+ work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open"],
130
207
  message: ["to-agent", "to-person", "conversation", "text", "decision"],
131
208
  conversations: [],
132
209
  "wait-for-reply": ["timeout"],
@@ -142,8 +219,88 @@ const FLAGS = {
142
219
  agents: [],
143
220
  invite: ["name", "description", "permissions"],
144
221
  "start-cloud-agent": ["name", "repo", "task", "branch", "open-pr", "machine", "agent"],
222
+ "move-agent": ["under"],
223
+ call: ["query", "body", "for-person"],
145
224
  me: [],
225
+ "my-queue": ["view", "before", "limit"],
226
+ "decide-mine": ["option", "text", "note", "their-words"],
227
+ "forward-mine": ["to-person", "to-agent", "note"],
228
+ boomerang: ["until", "when-answers"],
229
+ "research-more": ["prompt", "to-person", "to-agent"],
230
+ "ask-someone": ["to-person", "to-agent", "prompt"],
231
+ defer: ["trust-words"],
232
+ undo: [],
233
+ "todo-done": ["note", "their-words"],
234
+ "todo-cant": ["reason", "their-words"],
235
+ "decided-without-you": ["date"],
236
+ overrule: ["text", "note", "their-words"],
237
+ "my-settings": [],
238
+ "set-my-day": ["timezone", "day-start", "day-end", "morning", "later-every"],
239
+ "set-my-alerts": ["on-call", "sounds", "sound", "later-like-now", "muted", "workspace-sound", "snooze-until"],
240
+ "set-my-reports": ["weekly-report", "slack-messages"],
241
+ "my-notifications": ["limit"],
242
+ "mark-notification-read": [],
243
+ "my-weekly-report": [],
244
+ "my-trusts": [],
245
+ "add-trust": ["agent", "words", "area"],
246
+ "edit-trust": ["words", "area"],
247
+ "revoke-trust": [],
248
+ "trust-decisions": [],
249
+ "trust-suggestions": [],
250
+ "my-agents": [],
251
+ "edit-agent": ["name", "title", "description"],
252
+ "show-agent": ["visible"],
253
+ "pause-agent": ["paused"],
254
+ "set-agent-permissions": ["permissions", "may-invite", "may-ask-person"],
255
+ "add-sub-agent": ["name", "description", "permissions"],
256
+ "move-agent-mine": ["under"],
257
+ "archive-agent": [],
258
+ "remove-agent": ["their-words"],
259
+ "my-blockers": [],
260
+ "nudge-mine": [],
261
+ reassign: ["to-person", "to-agent", "note"],
146
262
  };
263
+ // Your person's own actions, sent as them (X-Gavel-For-Person) once they've let you act for them
264
+ // (D-911): the MCP tools' names.
265
+ const FOR_PERSON = [
266
+ "my-queue",
267
+ "decide-mine",
268
+ "forward-mine",
269
+ "boomerang",
270
+ "research-more",
271
+ "ask-someone",
272
+ "defer",
273
+ "undo",
274
+ "todo-done",
275
+ "todo-cant",
276
+ "decided-without-you",
277
+ "overrule",
278
+ "my-settings",
279
+ "set-my-day",
280
+ "set-my-alerts",
281
+ "set-my-reports",
282
+ "my-notifications",
283
+ "mark-notification-read",
284
+ "my-weekly-report",
285
+ "my-trusts",
286
+ "add-trust",
287
+ "edit-trust",
288
+ "revoke-trust",
289
+ "trust-decisions",
290
+ "trust-suggestions",
291
+ "my-agents",
292
+ "edit-agent",
293
+ "show-agent",
294
+ "pause-agent",
295
+ "set-agent-permissions",
296
+ "add-sub-agent",
297
+ "move-agent-mine",
298
+ "archive-agent",
299
+ "remove-agent",
300
+ "my-blockers",
301
+ "nudge-mine",
302
+ "reassign",
303
+ ];
147
304
  const isCommand = (name) => Object.hasOwn(FLAGS, name);
148
305
  // A command's own entries in USAGE: each line naming it, with the lines indented under it.
149
306
  export function usageOf(command) {
@@ -161,9 +318,9 @@ export function usageOf(command) {
161
318
  }
162
319
  class UsageError extends Error {
163
320
  }
164
- // Only --option (a multiple question's picks) and --code (a work item's commits and pull requests)
165
- // may come again: `flags` holds each flag's value and `lists` every one given.
166
- const REPEATABLE = ["option", "code"];
321
+ // Only --option (a multiple question's picks), --code and --label (a work item's commits and pull
322
+ // requests, and its labels) may come again: `flags` holds each flag's value and `lists` every one given.
323
+ const REPEATABLE = ["option", "code", "label", "query"];
167
324
  export function parseArgs(argv, command) {
168
325
  const positional = [];
169
326
  const flags = {};
@@ -197,7 +354,7 @@ export function parseArgs(argv, command) {
197
354
  return { positional, flags, lists };
198
355
  }
199
356
  // gavel work file|move|show|list: a work item on the Board's Being done (features/work).
200
- function workRequest(p, f, code) {
357
+ function workRequest(p, f, code, label) {
201
358
  const [sub, ...rest] = p;
202
359
  const only = (allowed) => {
203
360
  const extra = Object.keys(f).find((k) => !allowed.includes(k));
@@ -207,6 +364,7 @@ function workRequest(p, f, code) {
207
364
  const worker = f.worker === undefined ? undefined : f.worker === "none" ? null : f.worker;
208
365
  const description = f.description === undefined ? undefined : readText(f.description);
209
366
  const links = code.length ? code.map((url) => ({ url })) : undefined;
367
+ const labels = !label.length ? undefined : label.length === 1 && label[0] === "none" ? [] : label;
210
368
  const ref = (value) => {
211
369
  if (!value || !/^W-\d+$/i.test(value))
212
370
  throw new UsageError(`work ${sub} needs its item, like W-12`);
@@ -214,18 +372,18 @@ function workRequest(p, f, code) {
214
372
  };
215
373
  switch (sub) {
216
374
  case "file": {
217
- only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code"]);
375
+ only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label"]);
218
376
  if (f.title !== undefined && rest.length)
219
377
  throw new UsageError("give the title once: as words or as --title");
220
378
  const title = readText(need(f.title ?? rest.join(" "), "the item's title"));
221
- return { method: "POST", path: "/v1/work", body: compact({ title, status: f.status, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links }) };
379
+ return { method: "POST", path: "/v1/work", body: compact({ title, status: f.status, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels }) };
222
380
  }
223
381
  case "move": {
224
- only(["title", "status", "description", "worker", "waiting-on", "decision", "code"]);
382
+ only(["title", "status", "description", "worker", "waiting-on", "decision", "code", "label"]);
225
383
  const [item, ...words] = rest;
226
384
  if (f.status !== undefined && words.length)
227
385
  throw new UsageError("give the status once: as words or as --status");
228
- const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links });
386
+ const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels });
229
387
  if (!Object.keys(body).length)
230
388
  throw new UsageError("work move needs a status or something to change");
231
389
  return { method: "PATCH", path: `/v1/work/${ref(item)}`, body };
@@ -248,6 +406,201 @@ function workRequest(p, f, code) {
248
406
  throw new UsageError(sub ? `work doesn't take "${sub}": use file, move, show or list` : "work needs file, move, show or list");
249
407
  }
250
408
  }
409
+ // gavel my-queue … overrule: your person's actions, as them (FOR_PERSON).
410
+ function personRequest(command, p, f, options) {
411
+ const upTo = (n) => {
412
+ if (p.length > n)
413
+ throw new UsageError(`${command} doesn't take "${p[n]}"`);
414
+ };
415
+ const words = (flag, from, what) => {
416
+ if (f[flag] !== undefined && from.length)
417
+ throw new UsageError(`give ${what} once: as words or as --${flag}`);
418
+ return readText(need(f[flag] ?? from.join(" "), what));
419
+ };
420
+ const theirWords = () => readText(need(f["their-words"], "--their-words: what your person said in your chat that decides it"));
421
+ const list = (value) => value?.split(",").map((s) => s.trim()).filter(Boolean) ?? [];
422
+ const asThem = (method, path, body) => ({ method, path, ...(body ? { body: compact(body) } : {}), forPerson: true });
423
+ const yesNo = (flag) => {
424
+ const v = f[flag];
425
+ if (v === undefined)
426
+ return undefined;
427
+ if (v !== "true" && v !== "false")
428
+ throw new UsageError(`--${flag} is true or false`);
429
+ return v === "true";
430
+ };
431
+ const orNone = (flag) => (f[flag] === undefined ? undefined : f[flag] === "none" ? null : f[flag]);
432
+ const changes = (body) => {
433
+ const set = compact(body);
434
+ if (!Object.keys(set).length)
435
+ throw new UsageError(`${command} needs something to change`);
436
+ return asThem("PATCH", "/v1/me", set);
437
+ };
438
+ const id = (what) => encodeURIComponent(need(p[0], what));
439
+ switch (command) {
440
+ case "my-queue": {
441
+ upTo(0);
442
+ const view = f.view ?? "mine";
443
+ if (view !== "mine" && view !== "asked" && view !== "decided")
444
+ throw new UsageError("--view is mine, asked or decided");
445
+ if (view !== "decided") {
446
+ if (f.before !== undefined || f.limit !== undefined)
447
+ throw new UsageError("--before and --limit go with --view decided");
448
+ return asThem("GET", `/v1/queue?view=${view}`);
449
+ }
450
+ const query = new URLSearchParams(compact({ before: f.before, limit: f.limit }));
451
+ return asThem("GET", `/v1/queue/decided${query.size ? `?${query}` : ""}`);
452
+ }
453
+ case "decide-mine":
454
+ upTo(1);
455
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/decide`, { ...picks(options), text: f.text && readText(f.text), note: f.note, theirWords: theirWords() });
456
+ case "forward-mine":
457
+ upTo(1);
458
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/forward`, { toPerson: f["to-person"], toAgentId: f["to-agent"], note: f.note });
459
+ case "boomerang":
460
+ upTo(1);
461
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/boomerang`, { until: f.until, whenPersonAnswers: f["when-answers"] });
462
+ case "research-more": {
463
+ const to = [...list(f["to-person"]).map((toPerson) => ({ toPerson })), ...list(f["to-agent"]).map((toAgentId) => ({ toAgentId }))];
464
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/research`, { prompt: words("prompt", p.slice(1), "the prompt"), to: to.length ? to : undefined });
465
+ }
466
+ case "ask-someone":
467
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/ask-someone`, { toPerson: f["to-person"], toAgentId: f["to-agent"], prompt: words("prompt", p.slice(1), "the prompt") });
468
+ case "defer":
469
+ upTo(1);
470
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/defer`, { trustWords: f["trust-words"] && readText(f["trust-words"]) });
471
+ case "undo":
472
+ upTo(1);
473
+ return asThem("POST", `/v1/events/${encodeURIComponent(need(p[0], "the event: the card's undo.eventId"))}/undo`);
474
+ case "todo-done":
475
+ upTo(1);
476
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/done`, { note: f.note && readText(f.note), theirWords: theirWords() });
477
+ case "todo-cant":
478
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/cant`, { reason: words("reason", p.slice(1), "why it can't be done"), theirWords: theirWords() });
479
+ case "decided-without-you":
480
+ upTo(0);
481
+ return asThem("GET", `/v1/decided-without-you${f.date ? `?date=${encodeURIComponent(f.date)}` : ""}`);
482
+ case "overrule":
483
+ upTo(1);
484
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/overrule`, { text: f.text && readText(f.text), note: f.note, theirWords: f["their-words"] && readText(f["their-words"]) });
485
+ case "my-settings":
486
+ upTo(0);
487
+ return asThem("GET", "/v1/me");
488
+ case "set-my-day": {
489
+ upTo(0);
490
+ const later = f["later-every"] === undefined ? undefined : Number(f["later-every"]);
491
+ if (later !== undefined && !Number.isInteger(later))
492
+ throw new UsageError("--later-every is a number of minutes");
493
+ return changes({ timezone: f.timezone, dayStart: f["day-start"], dayEnd: f["day-end"], morningTime: f.morning, laterEveryMinutes: later });
494
+ }
495
+ case "set-my-alerts":
496
+ upTo(0);
497
+ return changes({
498
+ onCall: yesNo("on-call"),
499
+ sounds: f.sounds,
500
+ alertSound: f.sound,
501
+ laterLikeNow: yesNo("later-like-now"),
502
+ muted: yesNo("muted"),
503
+ workspaceSound: orNone("workspace-sound"),
504
+ snoozedUntil: orNone("snooze-until"),
505
+ });
506
+ case "set-my-reports":
507
+ upTo(0);
508
+ return changes({ weeklyReport: yesNo("weekly-report"), slackMessages: yesNo("slack-messages") });
509
+ case "my-notifications":
510
+ upTo(0);
511
+ return asThem("GET", `/v1/notifications${f.limit ? `?limit=${encodeURIComponent(f.limit)}` : ""}`);
512
+ case "mark-notification-read":
513
+ upTo(1);
514
+ return asThem("POST", `/v1/notifications/${id("the notification's id")}/read`);
515
+ case "my-weekly-report":
516
+ upTo(0);
517
+ return asThem("GET", "/v1/weekly-report");
518
+ case "my-trusts":
519
+ upTo(0);
520
+ return asThem("GET", "/v1/trusts");
521
+ case "add-trust":
522
+ upTo(0);
523
+ return asThem("POST", "/v1/trusts", { agentId: need(f.agent, "--agent"), plainWords: readText(need(f.words, "--words")), areaId: f.area });
524
+ case "edit-trust": {
525
+ upTo(1);
526
+ const trust = id("the trust's id");
527
+ const body = compact({ plainWords: f.words && readText(f.words), areaId: orNone("area") });
528
+ if (!Object.keys(body).length)
529
+ throw new UsageError("edit-trust needs --words or --area");
530
+ return asThem("PATCH", `/v1/trusts/${trust}`, body);
531
+ }
532
+ case "revoke-trust":
533
+ upTo(1);
534
+ return asThem("DELETE", `/v1/trusts/${id("the trust's id")}`);
535
+ case "trust-decisions":
536
+ upTo(1);
537
+ return asThem("GET", `/v1/trusts/${id("the trust's id")}/decisions`);
538
+ case "trust-suggestions":
539
+ upTo(1);
540
+ return asThem("GET", `/v1/trusts/suggestions?decision=${ref(p[0])}`);
541
+ case "my-agents":
542
+ upTo(0);
543
+ return asThem("GET", "/v1/agents");
544
+ case "edit-agent": {
545
+ upTo(1);
546
+ const agent = id("the agent's id");
547
+ const body = compact({ name: f.name, title: orNone("title"), description: f.description && readText(f.description) });
548
+ if (!Object.keys(body).length)
549
+ throw new UsageError("edit-agent needs --name, --title or --description");
550
+ return asThem("PATCH", `/v1/agents/${agent}`, body);
551
+ }
552
+ case "show-agent": {
553
+ upTo(1);
554
+ const agent = id("the agent's id");
555
+ const visible = yesNo("visible");
556
+ if (visible === undefined)
557
+ throw new UsageError("show-agent needs --visible true or false");
558
+ return asThem("PATCH", `/v1/agents/${agent}`, { visibleToOrg: visible });
559
+ }
560
+ case "pause-agent": {
561
+ upTo(1);
562
+ const agent = id("the agent's id");
563
+ return asThem("PATCH", `/v1/agents/${agent}`, { status: yesNo("paused") === false ? "active" : "paused" });
564
+ }
565
+ case "set-agent-permissions": {
566
+ upTo(1);
567
+ const agent = id("the agent's id");
568
+ const body = compact({ permissions: f.permissions === undefined ? undefined : list(f.permissions), mayInvite: yesNo("may-invite"), mayAskPersonDirectly: yesNo("may-ask-person") });
569
+ if (!Object.keys(body).length)
570
+ throw new UsageError("set-agent-permissions needs --permissions, --may-invite or --may-ask-person");
571
+ return asThem("PATCH", `/v1/agents/${agent}`, body);
572
+ }
573
+ case "add-sub-agent": {
574
+ upTo(1);
575
+ const parent = id("the agent to add it under");
576
+ return asThem("POST", `/v1/agents/${parent}/sub-agents`, {
577
+ name: need(f.name, "--name"),
578
+ description: f.description && readText(f.description),
579
+ permissions: f.permissions === undefined ? undefined : list(f.permissions),
580
+ });
581
+ }
582
+ case "move-agent-mine":
583
+ upTo(1);
584
+ return asThem("PATCH", `/v1/agents/${id("the agent's id")}`, { parentAgentId: need(f.under, "--under") });
585
+ case "archive-agent":
586
+ upTo(1);
587
+ return asThem("POST", `/v1/agents/${id("the agent's id")}/archive`);
588
+ case "remove-agent":
589
+ upTo(1);
590
+ return asThem("DELETE", `/v1/agents/${id("the agent's id")}`, { theirWords: theirWords() });
591
+ case "my-blockers":
592
+ upTo(0);
593
+ return asThem("GET", "/v1/blockers");
594
+ case "nudge-mine":
595
+ upTo(1);
596
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/nudge`);
597
+ case "reassign":
598
+ upTo(1);
599
+ return asThem("POST", `/v1/decisions/${ref(p[0])}/reassign`, { toPerson: f["to-person"], toAgentId: f["to-agent"], note: f.note });
600
+ default:
601
+ throw new UsageError(`unknown command "${command}"`);
602
+ }
603
+ }
251
604
  // One --option is optionId; several, on a multiple question, are optionIds.
252
605
  const picks = (options) => (options && options.length > 1 ? { optionIds: options } : { optionId: options?.[0] });
253
606
  let stdinCache = null;
@@ -286,6 +639,7 @@ const attachBody = (file) => {
286
639
  const json = readJson(file);
287
640
  return json && typeof json === "object" && !Array.isArray(json) && SECTIONS.some((k) => k in json) ? json : { items: Array.isArray(json) ? json : [json] };
288
641
  };
642
+ const CALL_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
289
643
  // --as <name> (or --as=<name>) may come anywhere on the line; it's the caller's, not the command's.
290
644
  export function takeAs(argv) {
291
645
  const rest = [];
@@ -326,6 +680,8 @@ export function toRequest(argv) {
326
680
  if (rest.includes("--help") || rest.includes("-h"))
327
681
  return { help: usageOf(command) };
328
682
  const { positional: p, flags: f, lists } = parseArgs(rest, command);
683
+ if (FOR_PERSON.includes(command))
684
+ return personRequest(command, p, f, lists.option ?? []);
329
685
  const upTo = (n) => {
330
686
  if (p.length > n)
331
687
  throw new UsageError(`${command} doesn't take "${p[n]}"`);
@@ -353,6 +709,9 @@ export function toRequest(argv) {
353
709
  throw new UsageError(`--harness is one of ${BRIDGE_HARNESSES.join(", ")}`);
354
710
  return { bridge: { action, harness, server: f.server } };
355
711
  }
712
+ case "actions-env":
713
+ upTo(0);
714
+ return { actionsEnv: true };
356
715
  case "watch":
357
716
  upTo(0);
358
717
  return { watch: true };
@@ -415,7 +774,7 @@ export function toRequest(argv) {
415
774
  return { method: "PATCH", path: "/v1/agents/me/status", body: compact({ text: readText(said) || null, description, folders, state: f.state, linearIssue: f.issue, waitingOn: f["waiting-on"], item: f.item }) };
416
775
  }
417
776
  case "work":
418
- return workRequest(p, f, lists.code ?? []);
777
+ return workRequest(p, f, lists.code ?? [], lists.label ?? []);
419
778
  case "message": {
420
779
  const text = readText(words("text", p, "what to say"));
421
780
  if ([f.conversation, f["to-agent"], f["to-person"]].filter(Boolean).length !== 1)
@@ -504,6 +863,34 @@ export function toRequest(argv) {
504
863
  agentId: f.agent,
505
864
  }),
506
865
  };
866
+ case "move-agent":
867
+ upTo(1);
868
+ return { method: "PATCH", path: `/v1/agents/${encodeURIComponent(need(p[0], "the agent's id"))}`, body: { parentAgentId: need(f.under, "--under") } };
869
+ case "call": {
870
+ upTo(2);
871
+ const method = CALL_METHODS.find((m) => m === need(p[0], "the method: GET, POST, PUT, PATCH or DELETE").toUpperCase());
872
+ if (!method)
873
+ throw new UsageError(`call's method is GET, POST, PUT, PATCH or DELETE, not "${p[0]}"`);
874
+ const path = need(p[1], "the path, like /v1/blockers");
875
+ if (!path.startsWith("/v1/") || path.split("?")[0].split("/").includes(".."))
876
+ throw new UsageError("call's path is one under /v1/, like /v1/blockers");
877
+ const query = new URLSearchParams();
878
+ for (const pair of lists.query ?? []) {
879
+ const eq = pair.indexOf("=");
880
+ if (eq < 1)
881
+ throw new UsageError(`--query is name=value, not "${pair}"`);
882
+ query.append(pair.slice(0, eq), pair.slice(eq + 1));
883
+ }
884
+ const forPerson = f["for-person"];
885
+ if (forPerson !== undefined && forPerson !== "true" && forPerson !== "false")
886
+ throw new UsageError("--for-person is true or false");
887
+ return {
888
+ method,
889
+ path: query.size ? `${path}${path.includes("?") ? "&" : "?"}${query}` : path,
890
+ ...(f.body !== undefined ? { body: readJson(f.body) } : {}),
891
+ ...(forPerson === "true" ? { forPerson: true } : {}),
892
+ };
893
+ }
507
894
  case "me":
508
895
  upTo(0);
509
896
  return { method: "GET", path: "/v1/me" };
@@ -889,6 +1276,62 @@ async function watch(token, as) {
889
1276
  console.log(wakeLine(item));
890
1277
  }
891
1278
  }
1279
+ // ---------- GitHub Actions (server/src/features/automations) ----------
1280
+ // A job with permissions: id-token: write can ask GitHub for its run's own token.
1281
+ export function inGitHubActions(env) {
1282
+ return !!env.ACTIONS_ID_TOKEN_REQUEST_URL && !!env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
1283
+ }
1284
+ // The run's own Gavel token, traded for GitHub's token for the run (asked for with Gavel's address as
1285
+ // its audience), as the sub-agent named by the run's task (--as, GAVEL_AGENT; else the server names
1286
+ // it by the workflow and run number). Kept in the job's temp folder, which goes with the job, so a job
1287
+ // trades once per name until five minutes before its hour is up. Never printed.
1288
+ async function runToken(base, name, env) {
1289
+ const named = name?.trim() || null;
1290
+ const kept = env.RUNNER_TEMP ? join(env.RUNNER_TEMP, `gavel-run-${createHash("sha256").update(`${base}\n${named ?? ""}`).digest("hex").slice(0, 16)}.json`) : null;
1291
+ if (kept && existsSync(kept)) {
1292
+ try {
1293
+ const run = JSON.parse(readFileSync(kept, "utf8"));
1294
+ if (new Date(run.expiresAt).getTime() - Date.now() > 5 * 60_000)
1295
+ return run;
1296
+ }
1297
+ catch {
1298
+ // Unreadable: trade again.
1299
+ }
1300
+ }
1301
+ const github = await fetch(`${env.ACTIONS_ID_TOKEN_REQUEST_URL}&audience=${encodeURIComponent(base)}`, {
1302
+ headers: { authorization: `bearer ${env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}`, accept: "application/json" },
1303
+ });
1304
+ const proof = (await github.json().catch(() => ({})));
1305
+ if (!github.ok || !proof.value)
1306
+ throw new Error(`GitHub didn't give this run its token (HTTP ${github.status}): the job needs permissions: id-token: write`);
1307
+ const res = await fetch(`${base}/v1/automations/runs`, {
1308
+ method: "POST",
1309
+ headers: { "content-type": "application/json", accept: "application/json" },
1310
+ body: JSON.stringify({ githubToken: proof.value, ...(named ? { name: named } : {}), ...(env.GAVEL_WORKSPACE ? { workspace: env.GAVEL_WORKSPACE } : {}) }),
1311
+ });
1312
+ const body = (await res.json().catch(() => ({})));
1313
+ if (!res.ok)
1314
+ throw new Error(body.error?.message ?? `Gavel refused this run (HTTP ${res.status})`);
1315
+ if (kept)
1316
+ writeFileSync(kept, JSON.stringify(body), { mode: 0o600 });
1317
+ return body;
1318
+ }
1319
+ // For an agent in the job that speaks MCP: the run's token for the steps after this one, through the
1320
+ // job's GITHUB_ENV, masked first, GitHub's own way, so its log never shows it. The mask line is the
1321
+ // one line that holds the token, and the runner takes it rather than printing it.
1322
+ async function actionsEnv(as) {
1323
+ const env = process.env;
1324
+ if (!inGitHubActions(env) || !env.GITHUB_ENV) {
1325
+ console.error("gavel actions-env: run it in a GitHub Actions job with permissions: id-token: write");
1326
+ return 2;
1327
+ }
1328
+ const base = (env.GAVEL_API_URL ?? "https://api.getgavel.ai").replace(/\/+$/, "");
1329
+ const run = await runToken(base, as, env);
1330
+ console.log(`::add-mask::${run.token}`);
1331
+ appendFileSync(env.GITHUB_ENV, `GAVEL_TOKEN=${run.token}\nGAVEL_API_URL=${base}\nGAVEL_MCP_URL=${run.mcpUrl}\n`);
1332
+ console.log(JSON.stringify({ set: ["GAVEL_TOKEN", "GAVEL_API_URL", "GAVEL_MCP_URL"], agent: run.agent, workspace: run.workspace, server: run.server, expiresAt: run.expiresAt }, null, 2));
1333
+ return 0;
1334
+ }
892
1335
  async function main(argvIn) {
893
1336
  let request;
894
1337
  let as = null;
@@ -915,22 +1358,25 @@ async function main(argvIn) {
915
1358
  return pair(request.pair);
916
1359
  if ("bridge" in request)
917
1360
  return runBridge(request.bridge, { cwd: process.cwd(), home: homedir(), env: process.env, as });
918
- const token = process.env.GAVEL_TOKEN;
1361
+ if ("actionsEnv" in request)
1362
+ return actionsEnv(as);
1363
+ const base = (process.env.GAVEL_API_URL ?? "https://api.getgavel.ai").replace(/\/+$/, "");
1364
+ const token = process.env.GAVEL_TOKEN || (inGitHubActions(process.env) ? (await runToken(base, as, process.env)).token : undefined);
919
1365
  if (!token) {
920
- console.error("gavel: set GAVEL_TOKEN to your agent token (gvl_agent_…)");
1366
+ console.error("gavel: set GAVEL_TOKEN to your agent token (gvl_agent_…), or in a GitHub Actions job give it permissions: id-token: write");
921
1367
  return 2;
922
1368
  }
923
1369
  if ("watch" in request)
924
1370
  return watch(token, as);
925
1371
  if ("upload" in request)
926
1372
  return upload(token, as, request.upload);
927
- const base = (process.env.GAVEL_API_URL ?? "https://api.getgavel.ai").replace(/\/+$/, "");
928
1373
  const res = await fetch(base + request.path, {
929
1374
  method: request.method,
930
1375
  headers: {
931
1376
  authorization: `Bearer ${token}`,
932
1377
  accept: "application/json",
933
1378
  ...agentHeader(as),
1379
+ ...(request.forPerson ? { "x-gavel-for-person": "true" } : {}),
934
1380
  ...(request.body !== undefined ? { "content-type": "application/json" } : {}),
935
1381
  },
936
1382
  ...(request.body !== undefined ? { body: JSON.stringify(request.body) } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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",