@getgavel/cli 0.1.29 → 0.1.32

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.29",
3
+ "version": "0.1.32",
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" },
@@ -5,7 +5,7 @@ import { basename, join } from "node:path";
5
5
  import { jsonText } from "../output.js";
6
6
  import { markChatOff, onHookEvent, STATUS_LINE_EVENT } from "./background.js";
7
7
  import { claudeDayReporter, DAYS_EVERY_MS } from "./claude-days.js";
8
- import { accountOf, claudePlanReporter, planUsageOf, usageBody } from "./claude-plan.js";
8
+ import { accountOf, checkClaudeExtra, claudePlanReporter, planUsageOf, usageBody } from "./claude-plan.js";
9
9
  import { claudeSessions } from "./claude-code.js";
10
10
  import { ClaudeCodeHarness } from "./claude-live.js";
11
11
  import { codexHarness, codexSessions } from "./codex.js";
@@ -141,6 +141,7 @@ const PICTURE_KEEP_MS = 15 * 60_000;
141
141
  // Live pieces go at most twice a second (the live route's own limit, 240 a minute an agent).
142
142
  const LIVE_EVERY_MS = 500;
143
143
  const LIVE_PIECE = 20_000;
144
+ const LONG_TEXT = 8_000;
144
145
  const PUSH_EVERY_MS = 2000;
145
146
  // What changed goes this long after (what changes with it goes along), and pushes that send words
146
147
  // stay this far apart while things keep changing: each counts in the agent's 120 calls a minute.
@@ -367,6 +368,16 @@ async function harnessBridge(initial, harness, setup, ctx) {
367
368
  }
368
369
  return { paths, missed };
369
370
  };
371
+ // A long message goes to a private file the software reads: a session's inbox can't carry 50,000
372
+ // characters whole (W-289).
373
+ const longAsFile = (text) => {
374
+ if (text.length <= LONG_TEXT)
375
+ return text;
376
+ const file = join(pictures, `${randomUUID()}.md`);
377
+ writeFileSync(file, text, { mode: 0o600 });
378
+ setTimeout(() => rmSync(file, { force: true }), PICTURE_KEEP_MS).unref();
379
+ return `${text.slice(0, 1_000)}\n\n[This message is ${text.length} characters, so it's longer than fits here. Read all of it, from its start, in the file ${file}, and answer that.]`;
380
+ };
370
381
  let launchQueue = Promise.resolve();
371
382
  const launch = (run) => {
372
383
  const chosen = launchQueue.then(run);
@@ -379,7 +390,7 @@ async function harnessBridge(initial, harness, setup, ctx) {
379
390
  urgentUntil = Date.now() + PUSH_URGENT_MS;
380
391
  const result = await launch(async () => {
381
392
  const route = await pick(null, "chat");
382
- return route.allowed ? h.deliver({ id: m.id, text: m.text, decision: m.decision, pictures: paths }, route.fresh, route.run) : null;
393
+ return route.allowed ? h.deliver({ id: m.id, text: longAsFile(m.text), decision: m.decision, pictures: paths }, route.fresh, route.run) : null;
383
394
  });
384
395
  if (!result)
385
396
  return;
@@ -466,6 +477,7 @@ async function harnessBridge(initial, harness, setup, ctx) {
466
477
  const mine = { model: run.harness === activeHarness ? run.model : null, effort: run.effort, context: run.context };
467
478
  return { allowed: true, fresh: chosen.fresh ? { ...chosen.fresh, ...mine } : null, run: mine };
468
479
  };
480
+ const checkedExtra = new Map();
469
481
  const pickPlan = async (fresh, job = "wake") => {
470
482
  if (!machineId || busy() || (!fresh && thread && state === "idle"))
471
483
  return { allowed: true, fresh };
@@ -479,6 +491,22 @@ async function harnessBridge(initial, harness, setup, ctx) {
479
491
  if (res.status === 404)
480
492
  return { allowed: true, fresh };
481
493
  const route = res.ok ? await answer(res) : null;
494
+ const observe = route?.observeExtraPlanId;
495
+ if (observe && planIdPattern.test(observe) && Date.now() - (checkedExtra.get(observe) ?? 0) >= 3_600_000) {
496
+ const probeEnv = planEnvironment(ctx, observe, "claude-code");
497
+ if (probeEnv) {
498
+ checkedExtra.set(observe, Date.now());
499
+ void checkClaudeExtra(ctx.cwd, probeEnv).then(async (extraUsageAvailable) => {
500
+ if (extraUsageAvailable === null)
501
+ return;
502
+ const reported = await call(api, "POST", "/v1/agents/me/plan/usage", {
503
+ ...usageBody(observe, { windows: [], limitReached: false, spendLimit: null }, new Date()), machineId, extraUsageAvailable,
504
+ });
505
+ if (reported.ok)
506
+ retryPlanAt = 0;
507
+ }).catch(() => undefined);
508
+ }
509
+ }
482
510
  if (route?.why === "unmanaged")
483
511
  return { allowed: true, fresh };
484
512
  if (route?.why === "wait") {
@@ -1,3 +1,5 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createInterface } from "node:readline";
1
3
  import { createHash } from "node:crypto";
2
4
  import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
3
5
  import { hostname } from "node:os";
@@ -99,6 +101,43 @@ export function claudeAccount(home, env = process.env) {
99
101
  return null;
100
102
  }
101
103
  }
104
+ // Claude's native headless stream reports whether the subscription can use overage. A
105
+ // deliberately short turn gives the bridge this signal even without an attached status line.
106
+ export async function checkClaudeExtra(cwd, env) {
107
+ const { CLAUDECODE: _nested, ...nativeEnv } = env;
108
+ const child = spawn("claude", [
109
+ "-p", "--no-session-persistence", "--tools", "", "--model", "haiku", "--setting-sources", "",
110
+ "--strict-mcp-config", "--mcp-config", '{"mcpServers":{}}', "--output-format", "stream-json", "--verbose",
111
+ "Reply with OK.",
112
+ ], { cwd, env: nativeEnv, stdio: ["ignore", "pipe", "ignore"] });
113
+ const lines = createInterface({ input: child.stdout });
114
+ let available = null;
115
+ lines.on("line", (line) => {
116
+ try {
117
+ const event = JSON.parse(line);
118
+ if (event.type !== "rate_limit_event")
119
+ return;
120
+ const status = event.rate_limit_info?.overageStatus;
121
+ if (status === "allowed" || status === "allowed_warning")
122
+ available = true;
123
+ if (status === "rejected")
124
+ available = false;
125
+ }
126
+ catch {
127
+ // Only native numeric usage and the overage flag are reportable.
128
+ }
129
+ });
130
+ return new Promise((resolve) => {
131
+ const timer = setTimeout(() => child.kill(), 15_000);
132
+ const done = () => {
133
+ clearTimeout(timer);
134
+ lines.close();
135
+ resolve(available);
136
+ };
137
+ child.once("error", done);
138
+ child.once("close", done);
139
+ });
140
+ }
102
141
  // Which account first reported under each plan, kept beside the bridge's locks (mode 600).
103
142
  function accountsFile(home) {
104
143
  return join(home, ".gavel", "bridge", "plan-accounts.json");
@@ -22,13 +22,17 @@ 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;
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;
29
33
  // A Team seat with Max limits is Premium; otherwise it doesn't say whether it's Standard or Premium.
30
34
  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"];
35
+ const choices = type === "claude_team" ? (team ? [] : ["Team", "Team Premium"]) : tier ? [] : ["Pro", "Max", "Ultra", "Team", "Team Premium", "Enterprise"];
32
36
  return {
33
37
  provider: "anthropic", key: hash("claude", account.accountUuid, typeof account.organizationUuid === "string" ? account.organizationUuid : ""),
34
38
  tier: team ?? tier, choices, domain: domainOf(account.emailAddress),
@@ -55,10 +59,10 @@ export function codexSignIn(folder, native) {
55
59
  if (!account)
56
60
  return null;
57
61
  const plan = String(auth.chatgpt_plan_type ?? "");
58
- 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;
59
63
  return {
60
64
  provider: "openai", key: hash("codex", account, typeof auth.chatgpt_user_id === "string" ? auth.chatgpt_user_id : ""),
61
- 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,
62
66
  };
63
67
  }
64
68
  // Every sign-in on this machine: the native ones, and each of Gavel's own profile folders.
@@ -172,6 +176,10 @@ export async function connectAccounts(local, options, io) {
172
176
  say("No Claude Code or Codex sign-in on this machine. Sign in to either, or run gavel connect --add claude (or codex).");
173
177
  return 1;
174
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
+ }
175
183
  const machineId = planMachine(local.home, true);
176
184
  if (!machineId)
177
185
  throw new Error("This machine's Gavel ID couldn't be read.");
@@ -182,8 +190,8 @@ export async function connectAccounts(local, options, io) {
182
190
  const items = [];
183
191
  for (const signIn of signIns) {
184
192
  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 } });
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 } : {}) } });
187
195
  }
188
196
  const res = await http(`${base}/v1/plans/connect`, {
189
197
  method: "POST", headers: { "content-type": "application/json" },
@@ -212,7 +220,7 @@ export async function connectAccounts(local, options, io) {
212
220
  const match = matchAccount(signIn, tier, accounts, known);
213
221
  const name = `${product(signIn.provider)} ${tier}${signIn.org ? ` · ${signIn.org}` : signIn.domain ? ` (${signIn.domain})` : ""}`;
214
222
  const body = {
215
- provider: signIn.provider, tier, label: match?.label ?? name,
223
+ provider: signIn.provider, tier, label: options.label ?? match?.label ?? name,
216
224
  // An account's own price stays; the list price is Gavel's to say.
217
225
  monthlyCents: match && match.monthlyCents !== match.listCents && !match.seatId ? match.monthlyCents : null,
218
226
  ...(signIn.domain ? { domain: signIn.domain } : {}),
package/dist/gavel.js CHANGED
@@ -33,7 +33,7 @@ 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 [--code <code>] [--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
38
  your accounts in Gavel, once (D-1349), with the one-time
39
39
  code from Settings › You › Your accounts (from any folder,
@@ -77,7 +77,7 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
77
77
  gavel revise <D-12> --file decision.json a draft the editor sent back, fixed (the whole ask again)
78
78
  gavel todo --file todo.json ask a person to do something: title, steps, why (MCP ask_to_do's input)
79
79
  gavel get <D-12>
80
- 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)
81
81
  follow a decision you didn't ask (wait returns its answer
82
82
  to you too), or a work item: what happens to it wakes you;
83
83
  --stop true stops following the item; --quiet: answers to
@@ -324,14 +324,14 @@ const FLAGS = {
324
324
  waiting: ["hook", "server", "file"],
325
325
  bridge: ["harness", "server"],
326
326
  plans: ["plan", "claim", "server"],
327
- connect: ["add", "tier", "server", "code"],
327
+ connect: ["add", "tier", "server", "code", "label"],
328
328
  "actions-env": [],
329
329
  search: ["query", "area", "status", "limit"],
330
330
  ask: ["file"],
331
331
  revise: ["file"],
332
332
  todo: ["file"],
333
333
  get: [],
334
- subscribe: ["item", "stop", "quiet"],
334
+ subscribe: ["item", "column", "stop", "quiet"],
335
335
  wait: ["timeout"],
336
336
  withdraw: ["reason"],
337
337
  attach: ["file"],
@@ -1089,7 +1089,7 @@ export function toRequest(argv) {
1089
1089
  upTo(0);
1090
1090
  if (f.add !== undefined && f.add !== "claude" && f.add !== "codex")
1091
1091
  throw new UsageError("--add takes claude or codex");
1092
- return { connect: { ...(f.add ? { add: f.add } : {}), ...(f.tier ? { tier: f.tier } : {}), ...(f.server ? { server: f.server } : {}), ...(f.code ? { code: f.code } : {}) } };
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 } : {}) } };
1093
1093
  }
1094
1094
  case "plans":
1095
1095
  upTo(1);
@@ -1170,6 +1170,11 @@ export function toRequest(argv) {
1170
1170
  }
1171
1171
  if (f.stop !== undefined && f.stop !== "true" && f.stop !== "false")
1172
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
+ }
1173
1178
  if (f.item === undefined) {
1174
1179
  if (f.stop !== undefined)
1175
1180
  throw new UsageError("--stop goes with --item: following a decision ends with its answer");
@@ -1935,7 +1940,9 @@ export function wakeLine(item) {
1935
1940
  case "task":
1936
1941
  return item.type === "ready"
1937
1942
  ? `GAVEL_WAKE task ${item.ref} ready: what it waited on is finished: gavel work show ${item.ref}`
1938
- : `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}`;
1939
1946
  case "replaced":
1940
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`;
1941
1948
  case "budget":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.29",
3
+ "version": "0.1.32",
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",