@getgavel/cli 0.1.28 → 0.1.31

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.28",
3
+ "version": "0.1.31",
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" },
@@ -10,6 +10,7 @@ import { claudeSessions } from "./claude-code.js";
10
10
  import { ClaudeCodeHarness } from "./claude-live.js";
11
11
  import { codexHarness, codexSessions } from "./codex.js";
12
12
  import { planEnvironment, planIdPattern, planMachine, rememberPlanSession } from "./plan-profiles.js";
13
+ import { runOf } from "./runtime.js";
13
14
  import { apiFor, claudeSetups, codexSetups } from "./setup.js";
14
15
  // `gavel bridge` (D-905): run by a person on their laptop, in the folder where their agent works
15
16
  // (Claude Code or Codex), beside it. It shows the newest session's words in the person's Gavel chat
@@ -378,7 +379,7 @@ async function harnessBridge(initial, harness, setup, ctx) {
378
379
  urgentUntil = Date.now() + PUSH_URGENT_MS;
379
380
  const result = await launch(async () => {
380
381
  const route = await pick(null, "chat");
381
- return route.allowed ? h.deliver({ id: m.id, text: m.text, decision: m.decision, pictures: paths }, route.fresh) : null;
382
+ return route.allowed ? h.deliver({ id: m.id, text: m.text, decision: m.decision, pictures: paths }, route.fresh, route.run) : null;
382
383
  });
383
384
  if (!result)
384
385
  return;
@@ -446,7 +447,26 @@ async function harnessBridge(initial, harness, setup, ctx) {
446
447
  }
447
448
  };
448
449
  const busy = () => state === "working" || state === "waiting";
450
+ // What a run about to start goes with (W-249): the model, effort and context Gavel's router or an
451
+ // override chose for the agent's kind of job. A session already open takes none, nor does one the
452
+ // bridge keeps going; a Gavel with no such route, or an agent not on a bridge harness, none either.
449
453
  const pick = async (fresh, job = "wake") => {
454
+ const kind = fresh?.per === "item" ? "work" : job;
455
+ const chosen = await pickPlan(fresh, job);
456
+ if (!chosen.allowed || busy() || (!chosen.fresh && thread && state === "idle"))
457
+ return chosen;
458
+ const res = await call(api, "GET", `/v1/agents/me/runtime?job=${kind}`).catch(() => null);
459
+ if (!res?.ok) {
460
+ void res?.body?.cancel();
461
+ return chosen;
462
+ }
463
+ const run = runOf(await answer(res));
464
+ if (!run)
465
+ return chosen;
466
+ const mine = { model: run.harness === activeHarness ? run.model : null, effort: run.effort, context: run.context };
467
+ return { allowed: true, fresh: chosen.fresh ? { ...chosen.fresh, ...mine } : null, run: mine };
468
+ };
469
+ const pickPlan = async (fresh, job = "wake") => {
450
470
  if (!machineId || busy() || (!fresh && thread && state === "idle"))
451
471
  return { allowed: true, fresh };
452
472
  if (state === null)
@@ -8,6 +8,7 @@ import { basename, dirname, extname, join } from "node:path";
8
8
  import { promisify } from "node:util";
9
9
  import { bridgePaths, isBridgeStatusLine, ownStatusLineEntry } from "./background.js";
10
10
  import { claudeSessions, claudeWords } from "./claude-code.js";
11
+ import { claudeFlags } from "./runtime.js";
11
12
  import { claudeSetups } from "./setup.js";
12
13
  // Claude Code live (W-132): what a session tells the bridge through its hooks, and how the bridge
13
14
  // reaches it. Relied on, from Claude Code's docs and its 2.1.332 binary:
@@ -670,7 +671,7 @@ export class ClaudeCodeHarness {
670
671
  return to;
671
672
  });
672
673
  }
673
- async deliver(m, fresh) {
674
+ async deliver(m, fresh, run) {
674
675
  const pictures = this.keepPictures(m);
675
676
  const text = this.prompt(m, pictures);
676
677
  let open = this.current();
@@ -686,7 +687,7 @@ export class ClaudeCodeHarness {
686
687
  }
687
688
  if (open)
688
689
  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.` };
689
- return this.resume(m, text, fresh);
690
+ return this.resume(m, text, fresh, run);
690
691
  }
691
692
  // A closed session, resumed with the person's words as a turn of its own in the background
692
693
  // (D-1174, changing D-905's "nothing that would prompt runs"): it runs under their own permission
@@ -694,9 +695,9 @@ export class ClaudeCodeHarness {
694
695
  // edits stay in the folder, as their own session's: no worktree of its own (Master Gavel's call).
695
696
  // The words go on stdin, never in its arguments. Delivered once Claude Code says it's backgrounded;
696
697
  // from then the session's own hooks name it, so their next words go through its inbox.
697
- async resume(m, text, fresh) {
698
+ async resume(m, text, fresh, run) {
698
699
  const newest = claudeSessions(this.ctx.cwd, this.ctx.home, this.ctx.env)[0] ?? null;
699
- const started = await this.background(text, { resume: fresh ? null : newest?.id ?? null, model: fresh?.model ?? null, effort: fresh?.effort });
700
+ const started = await this.background(text, { resume: fresh ? null : newest?.id ?? null, run: fresh ?? run ?? null });
700
701
  if ("reason" in started)
701
702
  return { outcome: "failed", reason: started.reason };
702
703
  this.remember(m.id, promptKey(text));
@@ -705,12 +706,21 @@ export class ClaudeCodeHarness {
705
706
  }
706
707
  // `claude [--resume <id>] --bg` with the words on stdin: the short id Claude Code names the
707
708
  // background session by, or why it didn't start.
708
- background(text, opts) {
709
+ // A model or effort this Claude Code refuses starts the session without them, so what Gavel chose can
710
+ // never keep the person's message from reaching it.
711
+ async background(text, opts) {
712
+ const started = await this.spawnBackground(text, opts);
713
+ if ("short" in started || !opts.run || !/model|effort/i.test(started.reason))
714
+ return started;
715
+ return this.spawnBackground(text, { ...opts, run: null });
716
+ }
717
+ spawnBackground(text, opts) {
718
+ const { model, effort } = claudeFlags(opts.run);
709
719
  const settings = JSON.stringify({ worktree: { bgIsolation: "none" } });
710
720
  const command = process.argv[1] ? [process.execPath, process.argv[1]] : null;
711
721
  const managed = this.ctx.env.GAVEL_PLAN_PROFILE && (this.ctx.env.CLAUDE_CONFIG_DIR || this.ctx.env.GAVEL_BRIDGE_OWNER_HARNESS === "codex");
712
722
  const launchSettings = managed && command ? withBridgeHooks(settings, command, null, command) ?? settings : settings;
713
- const args = [...(opts.resume ? ["--resume", opts.resume] : []), ...(opts.model ? ["--model", opts.model] : []), ...(opts.effort ? ["--effort", opts.effort] : []), "--bg", "--settings", launchSettings];
723
+ const args = [...(opts.resume ? ["--resume", opts.resume] : []), ...(model ? ["--model", model] : []), ...(effort ? ["--effort", effort] : []), "--bg", "--settings", launchSettings];
714
724
  return new Promise((resolve) => {
715
725
  const child = spawn("claude", args, { cwd: this.ctx.cwd, env: this.ctx.env, stdio: ["pipe", "pipe", "pipe"] });
716
726
  let out = "";
@@ -803,7 +813,7 @@ export class ClaudeCodeHarness {
803
813
  if (!there && Date.now() - last.at < STARTING_MS)
804
814
  return false;
805
815
  }
806
- const started = await this.background(`${fresh.brief}\n\n${line}`, { resume: null, model: fresh.model, effort: fresh.effort });
816
+ const started = await this.background(`${fresh.brief}\n\n${line}`, { resume: null, run: fresh });
807
817
  if ("reason" in started)
808
818
  throw new Error(started.reason);
809
819
  this.backgrounded.add(started.short);
@@ -6,6 +6,7 @@ import { promisify } from "node:util";
6
6
  import { cliVersion, withCodexHooks, writeWhole } from "../hook.js";
7
7
  import { connectCodex, controlSocket, startCodexServer } from "./codex-app.js";
8
8
  import { CodexPlanUsage } from "./codex-plan.js";
9
+ import { codexFlags } from "./runtime.js";
9
10
  import { codexSetups } from "./setup.js";
10
11
  import { WebSocketError } from "./websocket.js";
11
12
  import { cut } from "./words.js";
@@ -399,11 +400,15 @@ class CodexHarness {
399
400
  }
400
401
  // Into the newest session: started on its turn when idle, steering it while it runs (turn/start does
401
402
  // either); loaded first when nobody has it open, or a new session when the folder has none.
402
- async put(app, input, clientUserMessageId, words, wake) {
403
+ async put(app, input, clientUserMessageId, words, wake, run) {
403
404
  await this.newest();
404
405
  let current = this.current;
406
+ // What a session started or loaded here goes with (W-249); one already loaded, whose turn may run
407
+ // and which the person may have open, keeps its own.
408
+ let flags = null;
405
409
  if (!current) {
406
- const { thread } = await app.request("thread/start", { cwd: this.ctx.cwd });
410
+ flags = run ?? null;
411
+ const { thread } = await this.starting(app, flags);
407
412
  current = this.current = { id: thread.id, status: thread.status, path: thread.path, subscribed: true };
408
413
  this.started = { id: thread.id, at: Date.now() };
409
414
  this.words.clear();
@@ -418,17 +423,38 @@ class CodexHarness {
418
423
  current.subscribed = true;
419
424
  current.status = { type: "idle" };
420
425
  this.ownLoaded.add(current.id);
426
+ flags = run ?? null;
421
427
  }
422
428
  if (wake && (this.turnId || current.status.type === "active" || Date.now() - this.stoppedAt < QUIET_AFTER_STOP_MS))
423
429
  return "busy";
424
- const { turn } = await app.request("turn/start", { threadId: current.id, input, clientUserMessageId });
430
+ const { turn } = await this.turning(app, { threadId: current.id, input, clientUserMessageId }, flags);
425
431
  if (turn.status === "inProgress")
426
432
  this.planTurns.add(turn.id);
427
433
  if (this.ownLoaded.has(current.id))
428
434
  this.unattended.add(turn.id);
429
435
  return "in";
430
436
  }
431
- async deliver(message, fresh) {
437
+ // A new thread with the model and the 1M window asked for; one Codex refuses them for starts without,
438
+ // so a model it doesn't offer never keeps a message from reaching it.
439
+ async starting(app, run) {
440
+ const { model, config } = codexFlags(run);
441
+ const params = { cwd: this.ctx.cwd };
442
+ if (!model && !config)
443
+ return app.request("thread/start", params);
444
+ return app
445
+ .request("thread/start", { ...params, ...(model ? { model } : {}), ...(config ? { config } : {}) })
446
+ .catch(() => app.request("thread/start", params));
447
+ }
448
+ // A turn with the effort (and model) asked for, the same way: without them if Codex refuses them.
449
+ async turning(app, params, run) {
450
+ const { model, effort } = codexFlags(run);
451
+ if (!model && !effort)
452
+ return app.request("turn/start", params);
453
+ return app
454
+ .request("turn/start", { ...params, ...(model ? { model } : {}), ...(effort ? { effort } : {}) })
455
+ .catch(() => app.request("turn/start", params));
456
+ }
457
+ async deliver(message, fresh, run) {
432
458
  const words = message.decision ? `About ${message.decision.ref}: ${message.decision.question}\n\n${message.text}` : message.text;
433
459
  const input = [{ type: "text", text: words, text_elements: [] }, ...message.pictures.map((path) => ({ type: "localImage", path }))];
434
460
  let app;
@@ -440,18 +466,18 @@ class CodexHarness {
440
466
  }
441
467
  try {
442
468
  if (fresh && this.ctx.env.GAVEL_PLAN_PROFILE && !this.turnId && this.current?.status.type !== "active") {
443
- const { thread } = await app.request("thread/start", { cwd: this.ctx.cwd, model: fresh.model ?? undefined });
469
+ const { thread } = await this.starting(app, fresh);
444
470
  this.current = { id: thread.id, status: thread.status, path: thread.path, subscribed: true };
445
471
  this.started = { id: thread.id, at: Date.now() };
446
472
  this.words.clear();
447
473
  this.ownLoaded.add(thread.id);
448
- const { turn } = await app.request("turn/start", { threadId: thread.id, input, clientUserMessageId: `${FROM_GAVEL}${message.id}`, effort: fresh.effort ?? undefined });
474
+ const { turn } = await this.turning(app, { threadId: thread.id, input, clientUserMessageId: `${FROM_GAVEL}${message.id}` }, { model: null, effort: fresh.effort });
449
475
  if (turn.status === "inProgress")
450
476
  this.planTurns.add(turn.id);
451
477
  this.unattended.add(turn.id);
452
478
  return { outcome: "delivered", read: true };
453
479
  }
454
- const into = await this.put(app, input, `${FROM_GAVEL}${message.id}`, words, false);
480
+ const into = await this.put(app, input, `${FROM_GAVEL}${message.id}`, words, false, run);
455
481
  if (into === "queued") {
456
482
  this.queued.set(words.trim(), message.id);
457
483
  if (message.pictures.length)
@@ -490,17 +516,13 @@ class CodexHarness {
490
516
  if (fresh && this.ctx.env.GAVEL_PLAN_PROFILE) {
491
517
  if (this.turnId || this.current?.status.type === "active")
492
518
  return false;
493
- const model = fresh.model ?? undefined;
494
- const { thread } = await app.request("thread/start", { cwd: this.ctx.cwd, model });
519
+ const { thread } = await this.starting(app, fresh);
495
520
  this.current = { id: thread.id, status: thread.status, path: thread.path, subscribed: true };
496
521
  this.started = { id: thread.id, at: Date.now() };
497
522
  this.words.clear();
498
523
  this.ownLoaded.add(thread.id);
499
524
  const text = [fresh.brief, line].filter(Boolean).join("\n\n");
500
- const { turn } = await app.request("turn/start", {
501
- threadId: thread.id, input: [{ type: "text", text, text_elements: [] }], clientUserMessageId: `${WAKE}${randomUUID()}`,
502
- effort: fresh.effort ?? undefined,
503
- });
525
+ const { turn } = await this.turning(app, { threadId: thread.id, input: [{ type: "text", text, text_elements: [] }], clientUserMessageId: `${WAKE}${randomUUID()}` }, { model: null, effort: fresh.effort });
504
526
  if (turn.status === "inProgress")
505
527
  this.planTurns.add(turn.id);
506
528
  this.unattended.add(turn.id);
@@ -22,15 +22,20 @@ export function claudeSignIn(file, folder, native) {
22
22
  return null;
23
23
  const type = String(account.organizationType ?? "");
24
24
  const limit = String(account.userRateLimitTier ?? "");
25
- const tier = type === "claude_max" ? (/20x/.test(limit) ? "Max 20x" : "Max 5x")
26
- : type === "claude_pro" ? "Pro"
27
- : type === "claude_enterprise" ? "Enterprise"
28
- : null;
29
- // A Team seat doesn't say whether it's Standard or Premium.
30
- const choices = type === "claude_team" ? ["Team", "Team Premium"] : tier ? [] : ["Pro", "Max 5x", "Max 20x", "Team", "Team Premium", "Enterprise"];
25
+ // Anthropic's names since Nov 1, 2026: Max (was 5x) and Ultra (was 20x). planDisplayName says which when
26
+ // it names one Gavel knows; else 20x in either rate-limit tier is Ultra, and any other Max is Max.
27
+ const named = String(account.planDisplayName ?? "").trim().toLowerCase();
28
+ const tier = /^(ultra|max|pro)$/.test(named) && type !== "claude_team" && type !== "claude_enterprise" ? named[0].toUpperCase() + named.slice(1)
29
+ : type === "claude_max" ? (/20x/.test(`${account.organizationRateLimitTier ?? ""} ${limit}`) ? "Ultra" : "Max")
30
+ : type === "claude_pro" ? "Pro"
31
+ : type === "claude_enterprise" ? "Enterprise"
32
+ : null;
33
+ // A Team seat with Max limits is Premium; otherwise it doesn't say whether it's Standard or Premium.
34
+ const team = type === "claude_team" ? (/max/.test(limit) ? "Team Premium" : null) : undefined;
35
+ const choices = type === "claude_team" ? (team ? [] : ["Team", "Team Premium"]) : tier ? [] : ["Pro", "Max", "Ultra", "Team", "Team Premium", "Enterprise"];
31
36
  return {
32
37
  provider: "anthropic", key: hash("claude", account.accountUuid, typeof account.organizationUuid === "string" ? account.organizationUuid : ""),
33
- tier, choices, domain: domainOf(account.emailAddress),
38
+ tier: team ?? tier, choices, domain: domainOf(account.emailAddress),
34
39
  org: type === "claude_team" || type === "claude_enterprise" ? (typeof account.organizationName === "string" ? account.organizationName.slice(0, 60) : null) : null,
35
40
  folder, native,
36
41
  };
@@ -54,10 +59,10 @@ export function codexSignIn(folder, native) {
54
59
  if (!account)
55
60
  return null;
56
61
  const plan = String(auth.chatgpt_plan_type ?? "");
57
- const tier = plan === "plus" ? "Plus" : plan === "pro" ? "Pro" : plan === "team" || plan === "business" ? "Business" : plan === "enterprise" ? "Enterprise" : null;
62
+ const tier = plan === "plus" ? "Plus" : plan === "pro" ? "Pro 200" : plan === "promax" ? "Pro 500" : plan === "team" || plan === "business" ? "Business" : plan === "enterprise" ? "Enterprise" : null;
58
63
  return {
59
64
  provider: "openai", key: hash("codex", account, typeof auth.chatgpt_user_id === "string" ? auth.chatgpt_user_id : ""),
60
- tier, choices: tier ? [] : ["Plus", "Pro", "Business", "Enterprise"], domain: domainOf(claims.email), org: null, folder, native,
65
+ tier, choices: tier ? [] : ["Plus", "Pro 100", "Pro 200", "Pro 500", "Business", "Enterprise"], domain: domainOf(claims.email), org: null, folder, native,
61
66
  };
62
67
  }
63
68
  // Every sign-in on this machine: the native ones, and each of Gavel's own profile folders.
@@ -111,6 +116,28 @@ async function askTier(local, signIn, ask) {
111
116
  writeFileSync(answers, `${JSON.stringify({ ...kept, [signIn.key]: picked }, null, 2)}\n`, { mode: 0o600 });
112
117
  return picked;
113
118
  }
119
+ // The profile on this machine for an account: the native sign-in, or the account's own folder (Agent
120
+ // Twelve's markers), and which account it is (a hash, 600).
121
+ function markProfile(local, signIn, planId, known, moved) {
122
+ const folder = join(profilesRoot(local.home), planId);
123
+ if (!signIn.native && signIn.folder !== folder) {
124
+ if (existsSync(folder))
125
+ throw new Error("A profile for that account is already on this machine.");
126
+ renameSync(signIn.folder, folder);
127
+ moved();
128
+ }
129
+ mkdirSync(folder, { recursive: true, mode: 0o700 });
130
+ const harness = signIn.provider === "openai" ? "codex" : "claude-code";
131
+ if (signIn.native) {
132
+ // The native sign-in is one account's at a time: another account's claim on it goes.
133
+ for (const id of readdirSync(profilesRoot(local.home)).filter((id) => planIdPattern.test(id) && id !== planId)) {
134
+ if (existsSync(profileMarker(local.home, id)) && readFileSync(profileMarker(local.home, id), "utf8") === `native:${harness}` && known(id) !== signIn.key)
135
+ writeFileSync(profileMarker(local.home, id), "unclaimed", { mode: 0o600 });
136
+ }
137
+ }
138
+ writeFileSync(profileMarker(local.home, planId), signIn.native ? `native:${harness}` : "isolated", { mode: 0o600 });
139
+ writeFileSync(accountFile(local.home, planId), `${signIn.key}\n`, { mode: 0o600 });
140
+ }
114
141
  export async function connectAccounts(local, options, io) {
115
142
  const say = io?.say ?? ((line) => console.log(line));
116
143
  const ask = io?.ask ?? (async (question) => {
@@ -125,7 +152,10 @@ export async function connectAccounts(local, options, io) {
125
152
  }
126
153
  });
127
154
  const http = io?.fetch ?? fetch;
128
- const { base, headers } = personalApi(local, options.server);
155
+ // With a code from Your accounts, no token at all; else the paired personal agent's, acting for them.
156
+ const { base, headers } = options.code
157
+ ? { base: (local.env.GAVEL_API_URL ?? "https://api.getgavel.ai").replace(/\/+$/, ""), headers: {} }
158
+ : personalApi(local, options.server);
129
159
  const call = async (method, path, body) => {
130
160
  const res = await http(`${base}${path}`, { method, headers: { ...headers, ...(body ? { "content-type": "application/json" } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}) });
131
161
  if (!res.ok)
@@ -146,17 +176,51 @@ export async function connectAccounts(local, options, io) {
146
176
  say("No Claude Code or Codex sign-in on this machine. Sign in to either, or run gavel connect --add claude (or codex).");
147
177
  return 1;
148
178
  }
179
+ if (options.label !== undefined && signIns.length !== 1) {
180
+ say(`--label names one account, and this machine has ${signIns.length}: connect them without it, then name each in Settings › You › Your accounts.`);
181
+ return 1;
182
+ }
149
183
  const machineId = planMachine(local.home, true);
150
184
  if (!machineId)
151
185
  throw new Error("This machine's Gavel ID couldn't be read.");
152
- let accounts = (await call("GET", "/v1/me/plans")).plans ?? [];
153
186
  const known = keyOf(local.home);
187
+ if (options.code) {
188
+ // Every sign-in's plan first (asking here), then one request with the code.
189
+ const ids = existsSync(profilesRoot(local.home)) ? readdirSync(profilesRoot(local.home)).filter((id) => planIdPattern.test(id)) : [];
190
+ const items = [];
191
+ for (const signIn of signIns) {
192
+ const tier = signIn.tier ?? (options.tier && signIn.choices.includes(options.tier) ? options.tier : await askTier(local, signIn, ask));
193
+ const label = options.label ?? `${product(signIn.provider)} ${tier}${signIn.org ? ` · ${signIn.org}` : signIn.domain ? ` (${signIn.domain})` : ""}`;
194
+ items.push({ signIn, body: { planId: ids.find((id) => known(id) === signIn.key) ?? null, provider: signIn.provider, tier, label, domain: signIn.domain, ...(options.label !== undefined ? { named: true } : {}) } });
195
+ }
196
+ const res = await http(`${base}/v1/plans/connect`, {
197
+ method: "POST", headers: { "content-type": "application/json" },
198
+ body: JSON.stringify({ code: options.code, machineId, signIns: items.map((i) => i.body) }),
199
+ });
200
+ if (res.status === 404 || res.status === 410) {
201
+ say("That code is wrong, used or run out: take a new one from Settings › You › Your accounts.");
202
+ return 1;
203
+ }
204
+ if (!res.ok)
205
+ throw new Error(`Gavel answered ${res.status} to connecting your accounts`);
206
+ const { accounts } = (await res.json());
207
+ for (const [i, done] of accounts.entries()) {
208
+ const signIn = items[i].signIn;
209
+ if (!planIdPattern.test(done.planId))
210
+ throw new Error("Gavel didn't return the account it saved.");
211
+ markProfile(local, signIn, done.planId, known, () => (pending = signIn.folder === pending ? null : pending));
212
+ say(`${done.added ? "Added" : "Connected"} ${done.label}${done.company ? ", your company's seat" : ""}. Its use reaches Gavel through the bridge.`);
213
+ }
214
+ say("Your accounts are in Settings › You › Your accounts, in every workspace you're in.");
215
+ return 0;
216
+ }
217
+ let accounts = (await call("GET", "/v1/me/plans")).plans ?? [];
154
218
  for (const signIn of signIns) {
155
219
  const tier = signIn.tier ?? (options.tier && signIn.choices.includes(options.tier) ? options.tier : await askTier(local, signIn, ask));
156
220
  const match = matchAccount(signIn, tier, accounts, known);
157
221
  const name = `${product(signIn.provider)} ${tier}${signIn.org ? ` · ${signIn.org}` : signIn.domain ? ` (${signIn.domain})` : ""}`;
158
222
  const body = {
159
- provider: signIn.provider, tier, label: match?.label ?? name,
223
+ provider: signIn.provider, tier, label: options.label ?? match?.label ?? name,
160
224
  // An account's own price stays; the list price is Gavel's to say.
161
225
  monthlyCents: match && match.monthlyCents !== match.listCents && !match.seatId ? match.monthlyCents : null,
162
226
  ...(signIn.domain ? { domain: signIn.domain } : {}),
@@ -166,26 +230,7 @@ export async function connectAccounts(local, options, io) {
166
230
  const account = match ? accounts.find((a) => a.id === match.id) : accounts.find((a) => a.provider === signIn.provider && !known(a.id) && a.label === body.label && a.tier === tier);
167
231
  if (!account || !planIdPattern.test(account.id))
168
232
  throw new Error("Gavel didn't return the account it saved.");
169
- // The profile on this machine: the native sign-in, or the account's own folder.
170
- const folder = join(profilesRoot(local.home), account.id);
171
- if (!signIn.native && signIn.folder !== folder) {
172
- if (existsSync(folder))
173
- throw new Error(`A profile for ${account.label} is already on this machine.`);
174
- renameSync(signIn.folder, folder);
175
- if (signIn.folder === pending)
176
- pending = null;
177
- }
178
- mkdirSync(folder, { recursive: true, mode: 0o700 });
179
- const harness = signIn.provider === "openai" ? "codex" : "claude-code";
180
- if (signIn.native) {
181
- // The native sign-in is one account's at a time: another account's claim on it goes.
182
- for (const id of readdirSync(profilesRoot(local.home)).filter((id) => planIdPattern.test(id) && id !== account.id)) {
183
- if (existsSync(profileMarker(local.home, id)) && readFileSync(profileMarker(local.home, id), "utf8") === `native:${harness}` && known(id) !== signIn.key)
184
- writeFileSync(profileMarker(local.home, id), "unclaimed", { mode: 0o600 });
185
- }
186
- }
187
- writeFileSync(profileMarker(local.home, account.id), signIn.native ? `native:${harness}` : "isolated", { mode: 0o600 });
188
- writeFileSync(accountFile(local.home, account.id), `${signIn.key}\n`, { mode: 0o600 });
233
+ markProfile(local, signIn, account.id, known, () => (pending = signIn.folder === pending ? null : pending));
189
234
  await call("PUT", `/v1/me/plans/${account.id}/machines/${machineId}`);
190
235
  const seat = account.seatId ? ", your company's seat" : "";
191
236
  say(`${match ? "Connected" : "Added"} ${account.label}${seat}. Its use reaches Gavel through the bridge.`);
@@ -0,0 +1,29 @@
1
+ // What a run the bridge starts goes with (W-249): the model, thinking effort and context Gavel's router
2
+ // or an override chose for the agent's kind of job (GET /v1/agents/me/runtime), as each harness takes
3
+ // them. Gavel names them in its own words; each harness gets the nearest it offers, and a value it has
4
+ // no way to take is left out, never sent.
5
+ const MODEL = /^[A-Za-z0-9][\w.:[\]-]{0,79}$/;
6
+ const CLAUDE_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
7
+ const CODEX_EFFORTS = ["low", "medium", "high", "xhigh"];
8
+ // The run as an answer from Gavel says it, rebuilt from its known fields; null when it names nothing.
9
+ export function runOf(body) {
10
+ const run = body?.run;
11
+ if (!run || (run.harness !== "claude-code" && run.harness !== "codex"))
12
+ return null;
13
+ const model = typeof run.model === "string" && MODEL.test(run.model) ? run.model : null;
14
+ const effort = typeof run.effort === "string" ? run.effort : null;
15
+ const context = typeof run.context === "string" ? run.context : null;
16
+ return { harness: run.harness, model, effort, context };
17
+ }
18
+ // Claude Code: `--model` with its 1M window as the model's suffix (its default window is 200k, so 300k
19
+ // is the model as it is), `--effort` as named.
20
+ export function claudeFlags(run) {
21
+ const model = run?.model && MODEL.test(run.model) ? (run.context === "1m" && !run.model.endsWith("]") ? `${run.model}[1m]` : run.model) : null;
22
+ return { model, effort: run?.effort && CLAUDE_EFFORTS.includes(run.effort) ? run.effort : null };
23
+ }
24
+ // Codex: its own model, its reasoning effort (max is its xhigh), and a 1M window as a config override
25
+ // of the thread (its default window, the model's own, is what 300k asks for).
26
+ export function codexFlags(run) {
27
+ const effort = run?.effort === "max" ? "xhigh" : run?.effort && CODEX_EFFORTS.includes(run.effort) ? run.effort : null;
28
+ return { model: run?.model && MODEL.test(run.model) ? run.model : null, effort, config: run?.context === "1m" ? { model_context_window: 1_000_000 } : null };
29
+ }
package/dist/gavel.js CHANGED
@@ -33,9 +33,11 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
33
33
  what's waiting for you in Gavel, in one line, or nothing;
34
34
  --hook answers as that software's end-of-turn hook (run by
35
35
  the hook, not by hand); always exits 0
36
- gavel connect [--add claude|codex] [--tier <plan>] [--server <name>]
36
+ gavel connect [--code <code>] [--add claude|codex] [--tier <plan>] [--label <name>] [--server <name>]
37
37
  the Claude Code and Codex sign-ins on this machine become
38
- your accounts in Gavel, once (D-1349): only each one's plan,
38
+ your accounts in Gavel, once (D-1349), with the one-time
39
+ code from Settings › You › Your accounts (from any folder,
40
+ no token), or as this folder's personal agent: only each one's plan,
39
41
  a name and its email's domain go, never a sign-in; --add
40
42
  signs in another account first, with a link that works
41
43
  from your phone, in a folder of its own
@@ -75,7 +77,7 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
75
77
  gavel revise <D-12> --file decision.json a draft the editor sent back, fixed (the whole ask again)
76
78
  gavel todo --file todo.json ask a person to do something: title, steps, why (MCP ask_to_do's input)
77
79
  gavel get <D-12>
78
- gavel subscribe (<D-12> | --item <W-12> [--stop true] | --quiet answer,decision|none)
80
+ gavel subscribe (<D-12> | --item <W-12> [--stop true] | --column Queued [--stop true] | --quiet answer,decision|none)
79
81
  follow a decision you didn't ask (wait returns its answer
80
82
  to you too), or a work item: what happens to it wakes you;
81
83
  --stop true stops following the item; --quiet: answers to
@@ -322,14 +324,14 @@ const FLAGS = {
322
324
  waiting: ["hook", "server", "file"],
323
325
  bridge: ["harness", "server"],
324
326
  plans: ["plan", "claim", "server"],
325
- connect: ["add", "tier", "server"],
327
+ connect: ["add", "tier", "server", "code", "label"],
326
328
  "actions-env": [],
327
329
  search: ["query", "area", "status", "limit"],
328
330
  ask: ["file"],
329
331
  revise: ["file"],
330
332
  todo: ["file"],
331
333
  get: [],
332
- subscribe: ["item", "stop", "quiet"],
334
+ subscribe: ["item", "column", "stop", "quiet"],
333
335
  wait: ["timeout"],
334
336
  withdraw: ["reason"],
335
337
  attach: ["file"],
@@ -1087,7 +1089,7 @@ export function toRequest(argv) {
1087
1089
  upTo(0);
1088
1090
  if (f.add !== undefined && f.add !== "claude" && f.add !== "codex")
1089
1091
  throw new UsageError("--add takes claude or codex");
1090
- return { connect: { ...(f.add ? { add: f.add } : {}), ...(f.tier ? { tier: f.tier } : {}), ...(f.server ? { server: f.server } : {}) } };
1092
+ return { connect: { ...(f.add ? { add: f.add } : {}), ...(f.tier ? { tier: f.tier } : {}), ...(f.server ? { server: f.server } : {}), ...(f.code ? { code: f.code } : {}), ...(f.label !== undefined ? { label: f.label } : {}) } };
1091
1093
  }
1092
1094
  case "plans":
1093
1095
  upTo(1);
@@ -1168,6 +1170,11 @@ export function toRequest(argv) {
1168
1170
  }
1169
1171
  if (f.stop !== undefined && f.stop !== "true" && f.stop !== "false")
1170
1172
  throw new UsageError("--stop is true or false");
1173
+ if (f.column !== undefined) {
1174
+ if (p.length || f.item !== undefined)
1175
+ throw new UsageError("give one: a decision, --item or --column");
1176
+ return { method: f.stop === "true" ? "DELETE" : "POST", path: `/v1/work/columns/${encodeURIComponent(f.column)}/follow` };
1177
+ }
1171
1178
  if (f.item === undefined) {
1172
1179
  if (f.stop !== undefined)
1173
1180
  throw new UsageError("--stop goes with --item: following a decision ends with its answer");
@@ -1933,7 +1940,9 @@ export function wakeLine(item) {
1933
1940
  case "task":
1934
1941
  return item.type === "ready"
1935
1942
  ? `GAVEL_WAKE task ${item.ref} ready: what it waited on is finished: gavel work show ${item.ref}`
1936
- : `GAVEL_WAKE task ${item.ref} ${item.type ?? "changed"} by someone else: gavel work show ${item.ref}`;
1943
+ : item.type === "new"
1944
+ ? `GAVEL_WAKE task ${item.ref} new in a column you follow, with no one on it: gavel work show ${item.ref}, then give it to a free builder`
1945
+ : `GAVEL_WAKE task ${item.ref} ${item.type ?? "changed"} by someone else: gavel work show ${item.ref}`;
1937
1946
  case "replaced":
1938
1947
  return `GAVEL_WAKE replaced ${item.ref}: it no longer holds, ${item.type ?? "a newer decision"} replaces it: gavel get ${item.type ?? item.ref}, and follow that one`;
1939
1948
  case "budget":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.28",
3
+ "version": "0.1.31",
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",