@getgavel/cli 0.1.28 → 0.1.29

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.29",
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);
@@ -26,11 +26,12 @@ export function claudeSignIn(file, folder, native) {
26
26
  : type === "claude_pro" ? "Pro"
27
27
  : type === "claude_enterprise" ? "Enterprise"
28
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"];
29
+ // A Team seat with Max limits is Premium; otherwise it doesn't say whether it's Standard or Premium.
30
+ const team = type === "claude_team" ? (/max/.test(limit) ? "Team Premium" : null) : undefined;
31
+ const choices = type === "claude_team" ? (team ? [] : ["Team", "Team Premium"]) : tier ? [] : ["Pro", "Max 5x", "Max 20x", "Team", "Team Premium", "Enterprise"];
31
32
  return {
32
33
  provider: "anthropic", key: hash("claude", account.accountUuid, typeof account.organizationUuid === "string" ? account.organizationUuid : ""),
33
- tier, choices, domain: domainOf(account.emailAddress),
34
+ tier: team ?? tier, choices, domain: domainOf(account.emailAddress),
34
35
  org: type === "claude_team" || type === "claude_enterprise" ? (typeof account.organizationName === "string" ? account.organizationName.slice(0, 60) : null) : null,
35
36
  folder, native,
36
37
  };
@@ -111,6 +112,28 @@ async function askTier(local, signIn, ask) {
111
112
  writeFileSync(answers, `${JSON.stringify({ ...kept, [signIn.key]: picked }, null, 2)}\n`, { mode: 0o600 });
112
113
  return picked;
113
114
  }
115
+ // The profile on this machine for an account: the native sign-in, or the account's own folder (Agent
116
+ // Twelve's markers), and which account it is (a hash, 600).
117
+ function markProfile(local, signIn, planId, known, moved) {
118
+ const folder = join(profilesRoot(local.home), planId);
119
+ if (!signIn.native && signIn.folder !== folder) {
120
+ if (existsSync(folder))
121
+ throw new Error("A profile for that account is already on this machine.");
122
+ renameSync(signIn.folder, folder);
123
+ moved();
124
+ }
125
+ mkdirSync(folder, { recursive: true, mode: 0o700 });
126
+ const harness = signIn.provider === "openai" ? "codex" : "claude-code";
127
+ if (signIn.native) {
128
+ // The native sign-in is one account's at a time: another account's claim on it goes.
129
+ for (const id of readdirSync(profilesRoot(local.home)).filter((id) => planIdPattern.test(id) && id !== planId)) {
130
+ if (existsSync(profileMarker(local.home, id)) && readFileSync(profileMarker(local.home, id), "utf8") === `native:${harness}` && known(id) !== signIn.key)
131
+ writeFileSync(profileMarker(local.home, id), "unclaimed", { mode: 0o600 });
132
+ }
133
+ }
134
+ writeFileSync(profileMarker(local.home, planId), signIn.native ? `native:${harness}` : "isolated", { mode: 0o600 });
135
+ writeFileSync(accountFile(local.home, planId), `${signIn.key}\n`, { mode: 0o600 });
136
+ }
114
137
  export async function connectAccounts(local, options, io) {
115
138
  const say = io?.say ?? ((line) => console.log(line));
116
139
  const ask = io?.ask ?? (async (question) => {
@@ -125,7 +148,10 @@ export async function connectAccounts(local, options, io) {
125
148
  }
126
149
  });
127
150
  const http = io?.fetch ?? fetch;
128
- const { base, headers } = personalApi(local, options.server);
151
+ // With a code from Your accounts, no token at all; else the paired personal agent's, acting for them.
152
+ const { base, headers } = options.code
153
+ ? { base: (local.env.GAVEL_API_URL ?? "https://api.getgavel.ai").replace(/\/+$/, ""), headers: {} }
154
+ : personalApi(local, options.server);
129
155
  const call = async (method, path, body) => {
130
156
  const res = await http(`${base}${path}`, { method, headers: { ...headers, ...(body ? { "content-type": "application/json" } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}) });
131
157
  if (!res.ok)
@@ -149,8 +175,38 @@ export async function connectAccounts(local, options, io) {
149
175
  const machineId = planMachine(local.home, true);
150
176
  if (!machineId)
151
177
  throw new Error("This machine's Gavel ID couldn't be read.");
152
- let accounts = (await call("GET", "/v1/me/plans")).plans ?? [];
153
178
  const known = keyOf(local.home);
179
+ if (options.code) {
180
+ // Every sign-in's plan first (asking here), then one request with the code.
181
+ const ids = existsSync(profilesRoot(local.home)) ? readdirSync(profilesRoot(local.home)).filter((id) => planIdPattern.test(id)) : [];
182
+ const items = [];
183
+ for (const signIn of signIns) {
184
+ const tier = signIn.tier ?? (options.tier && signIn.choices.includes(options.tier) ? options.tier : await askTier(local, signIn, ask));
185
+ const label = `${product(signIn.provider)} ${tier}${signIn.org ? ` · ${signIn.org}` : signIn.domain ? ` (${signIn.domain})` : ""}`;
186
+ items.push({ signIn, body: { planId: ids.find((id) => known(id) === signIn.key) ?? null, provider: signIn.provider, tier, label, domain: signIn.domain } });
187
+ }
188
+ const res = await http(`${base}/v1/plans/connect`, {
189
+ method: "POST", headers: { "content-type": "application/json" },
190
+ body: JSON.stringify({ code: options.code, machineId, signIns: items.map((i) => i.body) }),
191
+ });
192
+ if (res.status === 404 || res.status === 410) {
193
+ say("That code is wrong, used or run out: take a new one from Settings › You › Your accounts.");
194
+ return 1;
195
+ }
196
+ if (!res.ok)
197
+ throw new Error(`Gavel answered ${res.status} to connecting your accounts`);
198
+ const { accounts } = (await res.json());
199
+ for (const [i, done] of accounts.entries()) {
200
+ const signIn = items[i].signIn;
201
+ if (!planIdPattern.test(done.planId))
202
+ throw new Error("Gavel didn't return the account it saved.");
203
+ markProfile(local, signIn, done.planId, known, () => (pending = signIn.folder === pending ? null : pending));
204
+ say(`${done.added ? "Added" : "Connected"} ${done.label}${done.company ? ", your company's seat" : ""}. Its use reaches Gavel through the bridge.`);
205
+ }
206
+ say("Your accounts are in Settings › You › Your accounts, in every workspace you're in.");
207
+ return 0;
208
+ }
209
+ let accounts = (await call("GET", "/v1/me/plans")).plans ?? [];
154
210
  for (const signIn of signIns) {
155
211
  const tier = signIn.tier ?? (options.tier && signIn.choices.includes(options.tier) ? options.tier : await askTier(local, signIn, ask));
156
212
  const match = matchAccount(signIn, tier, accounts, known);
@@ -166,26 +222,7 @@ export async function connectAccounts(local, options, io) {
166
222
  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
223
  if (!account || !planIdPattern.test(account.id))
168
224
  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 });
225
+ markProfile(local, signIn, account.id, known, () => (pending = signIn.folder === pending ? null : pending));
189
226
  await call("PUT", `/v1/me/plans/${account.id}/machines/${machineId}`);
190
227
  const seat = account.seatId ? ", your company's seat" : "";
191
228
  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>] [--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
@@ -322,7 +324,7 @@ 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"],
326
328
  "actions-env": [],
327
329
  search: ["query", "area", "status", "limit"],
328
330
  ask: ["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 } : {}) } };
1091
1093
  }
1092
1094
  case "plans":
1093
1095
  upTo(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
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",