@getgavel/cli 0.1.25 → 0.1.27
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.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/bridge/background.js +106 -4
- package/dist/bridge/bridge.js +74 -11
- package/dist/bridge/claude-code.js +5 -5
- package/dist/bridge/claude-days.js +236 -0
- package/dist/bridge/claude-live.js +87 -17
- package/dist/bridge/claude-plan.js +257 -0
- package/dist/bridge/codex-app.js +0 -1
- package/dist/bridge/codex-plan.js +261 -0
- package/dist/bridge/codex.js +21 -0
- package/dist/gavel.js +27 -10
- package/package.json +1 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { hostname } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
const countKeys = ["inputTokens", "cacheWriteTokens", "cacheReadTokens", "outputTokens"];
|
|
6
|
+
const zero = () => ({ inputTokens: 0, cacheWriteTokens: 0, cacheReadTokens: 0, outputTokens: 0 });
|
|
7
|
+
export function codexCounts(value) {
|
|
8
|
+
if (!value || typeof value !== "object")
|
|
9
|
+
return null;
|
|
10
|
+
const { inputTokens, cachedInputTokens, outputTokens } = value;
|
|
11
|
+
if (typeof inputTokens !== "number" || typeof cachedInputTokens !== "number" || typeof outputTokens !== "number")
|
|
12
|
+
return null;
|
|
13
|
+
if (![inputTokens, cachedInputTokens, outputTokens].every((count) => Number.isSafeInteger(count) && count >= 0))
|
|
14
|
+
return null;
|
|
15
|
+
return { inputTokens: Math.max(0, inputTokens - cachedInputTokens), cacheReadTokens: cachedInputTokens, outputTokens, cacheWriteTokens: 0 };
|
|
16
|
+
}
|
|
17
|
+
export function codexWindows(snapshot) {
|
|
18
|
+
const buckets = Object.entries(snapshot.rateLimitsByLimitId ?? {});
|
|
19
|
+
if (!buckets.length && snapshot.rateLimits)
|
|
20
|
+
buckets.push(["codex", snapshot.rateLimits]);
|
|
21
|
+
const windows = new Map();
|
|
22
|
+
for (const [key, bucket] of buckets) {
|
|
23
|
+
if (!bucket || typeof bucket !== "object")
|
|
24
|
+
continue;
|
|
25
|
+
const limitId = typeof bucket.limitId === "string" ? bucket.limitId : key;
|
|
26
|
+
if (!/^[a-z0-9_-]{1,64}$/i.test(limitId))
|
|
27
|
+
continue;
|
|
28
|
+
for (const value of [bucket.primary, bucket.secondary]) {
|
|
29
|
+
if (!value || typeof value !== "object")
|
|
30
|
+
continue;
|
|
31
|
+
const { windowDurationMins, usedPercent, resetsAt } = value;
|
|
32
|
+
if (typeof windowDurationMins !== "number" || !Number.isInteger(windowDurationMins) || windowDurationMins < 1 || windowDurationMins > 100_800)
|
|
33
|
+
continue;
|
|
34
|
+
if (typeof usedPercent !== "number" || !Number.isFinite(usedPercent) || usedPercent < 0 || usedPercent > 10_000)
|
|
35
|
+
continue;
|
|
36
|
+
if (typeof resetsAt !== "number" || !Number.isFinite(resetsAt) || resetsAt <= 0 || resetsAt > 253402300799)
|
|
37
|
+
continue;
|
|
38
|
+
windows.set(`${limitId}:${windowDurationMins}`, {
|
|
39
|
+
limitId, durationMinutes: windowDurationMins, usedPercent, resetsAt: new Date(resetsAt * 1000).toISOString(),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return [...windows.values()].slice(0, 32);
|
|
44
|
+
}
|
|
45
|
+
async function accountOf(app) {
|
|
46
|
+
const { account } = await app.request("account/read", { refreshToken: false });
|
|
47
|
+
return account?.type === "chatgpt" && typeof account.email === "string" ? account.email.trim().toLowerCase() : null;
|
|
48
|
+
}
|
|
49
|
+
function boundAccount(home, planId, account) {
|
|
50
|
+
if (!/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i.test(planId))
|
|
51
|
+
return false;
|
|
52
|
+
const dir = join(home, ".gavel", "plan-accounts");
|
|
53
|
+
const file = join(dir, `codex-${planId}`);
|
|
54
|
+
const fingerprint = createHash("sha256").update(planId).update("\0").update(account).digest("hex");
|
|
55
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
56
|
+
try {
|
|
57
|
+
writeFileSync(file, fingerprint, { mode: 0o600, flag: "wx" });
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (err.code !== "EEXIST")
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
return readFileSync(file, "utf8") === fingerprint;
|
|
64
|
+
}
|
|
65
|
+
const MINUTE = 60_000;
|
|
66
|
+
const localDate = (date) => [date.getFullYear(), String(date.getMonth() + 1).padStart(2, "0"), String(date.getDate()).padStart(2, "0")].join("-");
|
|
67
|
+
export class CodexPlanUsage {
|
|
68
|
+
home;
|
|
69
|
+
cwd;
|
|
70
|
+
reporter;
|
|
71
|
+
checking = false;
|
|
72
|
+
accountRevision = 0;
|
|
73
|
+
confirmedPlan = null;
|
|
74
|
+
pendingApp = null;
|
|
75
|
+
quotaTimer = null;
|
|
76
|
+
dayTimer = null;
|
|
77
|
+
nextQuota = 0;
|
|
78
|
+
nextDay = 0;
|
|
79
|
+
lastWindows = "";
|
|
80
|
+
warned = new Set();
|
|
81
|
+
totals = new Map();
|
|
82
|
+
pendingDays = new Map();
|
|
83
|
+
sendingDays = false;
|
|
84
|
+
constructor(home, cwd, reporter) {
|
|
85
|
+
this.home = home;
|
|
86
|
+
this.cwd = cwd;
|
|
87
|
+
this.reporter = reporter;
|
|
88
|
+
}
|
|
89
|
+
once(key, line) {
|
|
90
|
+
if (this.warned.has(key))
|
|
91
|
+
return;
|
|
92
|
+
this.warned.add(key);
|
|
93
|
+
console.error(line);
|
|
94
|
+
}
|
|
95
|
+
source() {
|
|
96
|
+
const folder = createHash("sha256").update(this.cwd).digest("hex").slice(0, 16);
|
|
97
|
+
const path = join(this.home, ".gavel", "plan-accounts", `source-${folder}`);
|
|
98
|
+
try {
|
|
99
|
+
writeFileSync(path, randomUUID(), { mode: 0o600, flag: "wx" });
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (err.code !== "EEXIST")
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
return { folder, sourceId: readFileSync(path, "utf8") };
|
|
106
|
+
}
|
|
107
|
+
observe(thread, usage, count) {
|
|
108
|
+
if (!usage || typeof usage !== "object")
|
|
109
|
+
return;
|
|
110
|
+
const raw = usage;
|
|
111
|
+
const total = codexCounts(raw.total);
|
|
112
|
+
if (!total)
|
|
113
|
+
return;
|
|
114
|
+
const before = this.totals.get(thread);
|
|
115
|
+
this.totals.set(thread, total);
|
|
116
|
+
const planId = this.confirmedPlan;
|
|
117
|
+
if (!count || !planId)
|
|
118
|
+
return;
|
|
119
|
+
const delta = before ? zero() : codexCounts(raw.last);
|
|
120
|
+
if (!delta)
|
|
121
|
+
return;
|
|
122
|
+
if (before)
|
|
123
|
+
for (const key of countKeys)
|
|
124
|
+
delta[key] = Math.max(0, total[key] - before[key]);
|
|
125
|
+
if (countKeys.every((key) => delta[key] === 0))
|
|
126
|
+
return;
|
|
127
|
+
try {
|
|
128
|
+
const date = localDate(new Date());
|
|
129
|
+
const { folder, sourceId } = this.source();
|
|
130
|
+
const file = join(this.home, ".gavel", "plan-accounts", `codex-${planId}-${folder}-${date}.json`);
|
|
131
|
+
let sum = zero();
|
|
132
|
+
try {
|
|
133
|
+
sum = JSON.parse(readFileSync(file, "utf8"));
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
if (err.code !== "ENOENT")
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
for (const key of countKeys)
|
|
140
|
+
sum[key] += delta[key];
|
|
141
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
142
|
+
writeFileSync(temp, JSON.stringify(sum), { mode: 0o600 });
|
|
143
|
+
renameSync(temp, file);
|
|
144
|
+
this.pendingDays.set(`${planId}:${date}`, { planId, date, sourceId, ...sum });
|
|
145
|
+
this.scheduleDay();
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
this.once("day-storage", "Gavel could not store local Codex usage counts.");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
scheduleDay() {
|
|
152
|
+
if (this.dayTimer || this.sendingDays || !this.pendingDays.size)
|
|
153
|
+
return;
|
|
154
|
+
this.dayTimer = setTimeout(() => {
|
|
155
|
+
this.dayTimer = null;
|
|
156
|
+
void this.flushDay();
|
|
157
|
+
}, Math.max(0, this.nextDay - Date.now()));
|
|
158
|
+
this.dayTimer.unref();
|
|
159
|
+
}
|
|
160
|
+
async flushDay() {
|
|
161
|
+
if (this.sendingDays || !this.pendingDays.size)
|
|
162
|
+
return;
|
|
163
|
+
if (this.dayTimer)
|
|
164
|
+
clearTimeout(this.dayTimer);
|
|
165
|
+
this.dayTimer = null;
|
|
166
|
+
this.sendingDays = true;
|
|
167
|
+
this.nextDay = Date.now() + MINUTE;
|
|
168
|
+
try {
|
|
169
|
+
for (const [key, day] of this.pendingDays) {
|
|
170
|
+
if (day.planId !== await this.reporter.linked()) {
|
|
171
|
+
this.pendingDays.delete(key);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
await this.reporter.day(day);
|
|
175
|
+
if (this.pendingDays.get(key) === day)
|
|
176
|
+
this.pendingDays.delete(key);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
this.once("day-refused", "Gavel could not record Codex's daily usage. The bridge will retry.");
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
this.sendingDays = false;
|
|
184
|
+
this.scheduleDay();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
refresh(app, accountChanged = false) {
|
|
188
|
+
if (accountChanged) {
|
|
189
|
+
this.accountRevision++;
|
|
190
|
+
this.confirmedPlan = null;
|
|
191
|
+
this.totals.clear();
|
|
192
|
+
}
|
|
193
|
+
this.pendingApp = app;
|
|
194
|
+
this.scheduleQuota();
|
|
195
|
+
}
|
|
196
|
+
scheduleQuota() {
|
|
197
|
+
if (this.quotaTimer || this.checking || !this.pendingApp)
|
|
198
|
+
return;
|
|
199
|
+
this.quotaTimer = setTimeout(() => {
|
|
200
|
+
this.quotaTimer = null;
|
|
201
|
+
void this.readQuota();
|
|
202
|
+
}, Math.max(0, this.nextQuota - Date.now()));
|
|
203
|
+
this.quotaTimer.unref();
|
|
204
|
+
}
|
|
205
|
+
async readQuota() {
|
|
206
|
+
const app = this.pendingApp;
|
|
207
|
+
if (!app)
|
|
208
|
+
return;
|
|
209
|
+
this.pendingApp = null;
|
|
210
|
+
this.checking = true;
|
|
211
|
+
const revision = this.accountRevision;
|
|
212
|
+
this.nextQuota = Date.now() + MINUTE;
|
|
213
|
+
try {
|
|
214
|
+
const planId = await this.reporter.linked();
|
|
215
|
+
if (!planId) {
|
|
216
|
+
this.confirmedPlan = null;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const account = await accountOf(app);
|
|
220
|
+
if (!account || !boundAccount(this.home, planId, account)) {
|
|
221
|
+
this.confirmedPlan = null;
|
|
222
|
+
if (account)
|
|
223
|
+
this.once(planId, "Gavel plan usage paused: Codex switched accounts. Link the active plan in Settings.");
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const snapshot = await app.request("account/rateLimits/read");
|
|
227
|
+
if (await accountOf(app) !== account || revision !== this.accountRevision)
|
|
228
|
+
return;
|
|
229
|
+
this.confirmedPlan = planId;
|
|
230
|
+
const windows = codexWindows(snapshot);
|
|
231
|
+
if (!windows.length)
|
|
232
|
+
return;
|
|
233
|
+
const buckets = Object.values(snapshot.rateLimitsByLimitId ?? {});
|
|
234
|
+
const limitReached = [...buckets, snapshot.rateLimits].some((bucket) => typeof bucket?.rateLimitReachedType === "string");
|
|
235
|
+
const signature = JSON.stringify([planId, windows.map((w) => ({ ...w, usedPercent: Math.floor(w.usedPercent) })), limitReached]);
|
|
236
|
+
if (signature === this.lastWindows)
|
|
237
|
+
return;
|
|
238
|
+
const machineName = hostname().replace(/\p{Cc}/gu, "").slice(0, 64) || "Codex";
|
|
239
|
+
await this.reporter.record({ planId, windows, observedAt: new Date().toISOString(), machineName, ...(limitReached ? { limitReached: true } : {}) });
|
|
240
|
+
this.lastWindows = signature;
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
this.once("quota-refused", "Gavel could not read or record Codex plan usage. The bridge will retry.");
|
|
244
|
+
if (revision === this.accountRevision)
|
|
245
|
+
this.pendingApp ??= app;
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
this.checking = false;
|
|
249
|
+
this.scheduleQuota();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
disconnect() {
|
|
253
|
+
this.accountRevision++;
|
|
254
|
+
this.confirmedPlan = null;
|
|
255
|
+
this.pendingApp = null;
|
|
256
|
+
this.totals.clear();
|
|
257
|
+
if (this.quotaTimer)
|
|
258
|
+
clearTimeout(this.quotaTimer);
|
|
259
|
+
this.quotaTimer = null;
|
|
260
|
+
}
|
|
261
|
+
}
|
package/dist/bridge/codex.js
CHANGED
|
@@ -5,6 +5,7 @@ import { basename, join } from "node:path";
|
|
|
5
5
|
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
|
+
import { CodexPlanUsage } from "./codex-plan.js";
|
|
8
9
|
import { codexSetups } from "./setup.js";
|
|
9
10
|
import { WebSocketError } from "./websocket.js";
|
|
10
11
|
import { cut } from "./words.js";
|
|
@@ -180,8 +181,11 @@ class CodexHarness {
|
|
|
180
181
|
state = null;
|
|
181
182
|
stoppedAt = 0;
|
|
182
183
|
started = null;
|
|
184
|
+
planTurns = new Set();
|
|
185
|
+
planUsage;
|
|
183
186
|
constructor(ctx) {
|
|
184
187
|
this.ctx = ctx;
|
|
188
|
+
this.planUsage = ctx.planReporter ? new CodexPlanUsage(ctx.home, ctx.cwd, ctx.planReporter) : null;
|
|
185
189
|
}
|
|
186
190
|
here(cwd) {
|
|
187
191
|
return cwd === this.ctx.cwd || realpath(cwd) === realpath(this.ctx.cwd);
|
|
@@ -227,10 +231,12 @@ class CodexHarness {
|
|
|
227
231
|
app = await connectCodex(socket, handlers, cliVersion());
|
|
228
232
|
}
|
|
229
233
|
this.app = app;
|
|
234
|
+
this.planUsage?.refresh(app, true);
|
|
230
235
|
void app.closed.then(() => {
|
|
231
236
|
if (this.app !== app)
|
|
232
237
|
return;
|
|
233
238
|
this.app = null;
|
|
239
|
+
this.planUsage?.disconnect();
|
|
234
240
|
if (this.current)
|
|
235
241
|
this.current.subscribed = false;
|
|
236
242
|
this.turnId = null;
|
|
@@ -303,6 +309,10 @@ class CodexHarness {
|
|
|
303
309
|
return { thread: `codex:${current.id}`, label: this.label(), session: current.id, messages: [...this.words.values()].sort((a, b) => a.at.localeCompare(b.at)) };
|
|
304
310
|
}
|
|
305
311
|
notified(method, params) {
|
|
312
|
+
if (this.app && (method === "account/rateLimits/updated" || method === "account/updated")) {
|
|
313
|
+
this.planUsage?.refresh(this.app, method === "account/updated");
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
306
316
|
const threadId = typeof params.threadId === "string" ? params.threadId : null;
|
|
307
317
|
if (method === "thread/started") {
|
|
308
318
|
const thread = params.thread;
|
|
@@ -314,6 +324,10 @@ class CodexHarness {
|
|
|
314
324
|
if (!current || threadId !== current.id)
|
|
315
325
|
return;
|
|
316
326
|
switch (method) {
|
|
327
|
+
case "thread/tokenUsage/updated":
|
|
328
|
+
if (this.app)
|
|
329
|
+
this.planUsage?.observe(current.id, params.tokenUsage, typeof params.turnId === "string" && this.planTurns.has(params.turnId));
|
|
330
|
+
return;
|
|
317
331
|
case "thread/status/changed":
|
|
318
332
|
current.status = params.status;
|
|
319
333
|
this.setState(stateOf(current.status));
|
|
@@ -334,6 +348,8 @@ class CodexHarness {
|
|
|
334
348
|
const item = params.item;
|
|
335
349
|
if (item.type === "agentMessage")
|
|
336
350
|
this.offsets.set(item.id, 0);
|
|
351
|
+
if (item.type === "userMessage" && item.clientId?.startsWith("gavel") && typeof params.turnId === "string")
|
|
352
|
+
this.planTurns.add(params.turnId);
|
|
337
353
|
// Someone typed at the laptop: the session has its person there now.
|
|
338
354
|
if (item.type === "userMessage" && !item.clientId?.startsWith("gavel"))
|
|
339
355
|
this.ownLoaded.delete(current.id);
|
|
@@ -370,6 +386,8 @@ class CodexHarness {
|
|
|
370
386
|
if (turn.status === "failed" && this.unattended.has(turn.id))
|
|
371
387
|
this.listener?.note(`Codex couldn't finish: ${turn.error?.message ?? "the turn failed"}`.slice(0, 300));
|
|
372
388
|
this.unattended.delete(turn.id);
|
|
389
|
+
if (this.planTurns.delete(turn.id))
|
|
390
|
+
void this.planUsage?.flushDay();
|
|
373
391
|
this.listener?.changed();
|
|
374
392
|
if (this.announced.delete(turn.id))
|
|
375
393
|
this.listener?.live({ event: "end", runId: turn.id });
|
|
@@ -402,6 +420,8 @@ class CodexHarness {
|
|
|
402
420
|
if (wake && (this.turnId || current.status.type === "active" || Date.now() - this.stoppedAt < QUIET_AFTER_STOP_MS))
|
|
403
421
|
return "busy";
|
|
404
422
|
const { turn } = await app.request("turn/start", { threadId: current.id, input, clientUserMessageId });
|
|
423
|
+
if (turn.status === "inProgress")
|
|
424
|
+
this.planTurns.add(turn.id);
|
|
405
425
|
if (this.ownLoaded.has(current.id))
|
|
406
426
|
this.unattended.add(turn.id);
|
|
407
427
|
return "in";
|
|
@@ -467,6 +487,7 @@ class CodexHarness {
|
|
|
467
487
|
// Codex's session is heard through its server, whatever the chat: nothing to put in or take out.
|
|
468
488
|
}
|
|
469
489
|
async close() {
|
|
490
|
+
this.planUsage?.disconnect();
|
|
470
491
|
this.app?.close();
|
|
471
492
|
this.app = null;
|
|
472
493
|
}
|
package/dist/gavel.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
9
9
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { homedir, hostname } from "node:os";
|
|
11
11
|
import { basename, dirname, extname, join } from "node:path";
|
|
12
|
-
import { bridgeStatus, harnessFor, holdBridge, hookEvent, lastingCommand, startBridge, stopBridge } from "./bridge/background.js";
|
|
12
|
+
import { bridgeStatus, bridgeStatusLine, harnessFor, holdBridge, hookEvent, lastingCommand, startBridge, stopBridge } from "./bridge/background.js";
|
|
13
13
|
import { claudeBridgeHooks, claudeHeld, gavelPluginOn } from "./bridge/claude-live.js";
|
|
14
14
|
import { codexBridgeHooks } from "./bridge/codex.js";
|
|
15
15
|
import { claudeSetups } from "./bridge/setup.js";
|
|
@@ -47,6 +47,9 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
47
47
|
gavel bridge event <name> [--harness claude-code|codex] [--server <name>]
|
|
48
48
|
a hook's event for this folder's bridge, its input on stdin
|
|
49
49
|
(run by the hook, not by hand); prints nothing, exits 0
|
|
50
|
+
gavel bridge status-line Claude Code's status line in a folder with the bridge's
|
|
51
|
+
hooks (run by Claude Code, not by hand): your plan's use to
|
|
52
|
+
the bridge, then your own status line, as it prints it
|
|
50
53
|
gavel bridge service install|remove|status [--harness claude-code|codex] [--server <name>]
|
|
51
54
|
the bridge for this folder kept running by the system (a
|
|
52
55
|
LaunchAgent on a Mac, systemd on Linux), so a closed
|
|
@@ -83,7 +86,10 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
83
86
|
answer an Ask someone
|
|
84
87
|
gavel act <D-12> (<note> | --note <words>)
|
|
85
88
|
what you did with the answer
|
|
86
|
-
gavel inbox
|
|
89
|
+
gavel inbox [<section>] [--offset <n>] [--limit <n>]
|
|
90
|
+
what's waiting on you, each list's first 10 (counts has
|
|
91
|
+
every total); with a section (requests, decisions, …),
|
|
92
|
+
that list's next page
|
|
87
93
|
gavel status (<title> | --text <words>) [--description <words>] [--folders <a,b>]
|
|
88
94
|
[--state working|blocked|idle] [--issue <MA-482>] [--waiting-on <email or agent>] [--item <W-12>]
|
|
89
95
|
what you're doing now: a title of two to four words in
|
|
@@ -216,7 +222,8 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
216
222
|
[--snooze-until <time>|none]
|
|
217
223
|
gavel set-my-reports [--weekly-report true|false] [--slack-messages true|false]
|
|
218
224
|
gavel set-agent-runtime <agent id> [--model <id>|cursor-default|none] [--effort low|medium|high|xhigh|max|none]
|
|
219
|
-
[--context 300k|1m|none]
|
|
225
|
+
[--context 300k|1m|none] [--sessions item|batch|continuous|none]
|
|
226
|
+
a Cursor agent's model, effort, context and sessions (none: the router's)
|
|
220
227
|
gavel set-area-runtime <area id> [--model <id>|cursor-default|none] [--effort <effort>|none] [--context 300k|1m|none]
|
|
221
228
|
gavel set-job-runtime work|wake|chat|night [--model <id>|cursor-default|none] [--effort <effort>|none] [--context 300k|1m|none]
|
|
222
229
|
gavel my-notifications [--limit <n>] what went out to them, and how many are unread
|
|
@@ -318,7 +325,7 @@ const FLAGS = {
|
|
|
318
325
|
upload: ["type"],
|
|
319
326
|
answer: ["response"],
|
|
320
327
|
act: ["note"],
|
|
321
|
-
inbox: [],
|
|
328
|
+
inbox: ["offset", "limit"],
|
|
322
329
|
status: ["text", "description", "folders", "state", "issue", "waiting-on", "item"],
|
|
323
330
|
"claim-folders": ["mode", "item"],
|
|
324
331
|
work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open", "waits-on", "program", "area", "why", "key"],
|
|
@@ -360,7 +367,7 @@ const FLAGS = {
|
|
|
360
367
|
"set-my-day": ["timezone", "day-start", "day-end", "morning", "later-every"],
|
|
361
368
|
"set-my-alerts": ["on-call", "sounds", "sound", "later-like-now", "muted", "workspace-sound", "snooze-until"],
|
|
362
369
|
"set-my-reports": ["weekly-report", "slack-messages"],
|
|
363
|
-
"set-agent-runtime": ["model", "effort", "context"],
|
|
370
|
+
"set-agent-runtime": ["model", "effort", "context", "sessions"],
|
|
364
371
|
"set-area-runtime": ["model", "effort", "context"],
|
|
365
372
|
"set-job-runtime": ["model", "effort", "context"],
|
|
366
373
|
"my-notifications": ["limit"],
|
|
@@ -726,9 +733,9 @@ function personRequest(command, p, f, options) {
|
|
|
726
733
|
case "set-area-runtime":
|
|
727
734
|
case "set-job-runtime": {
|
|
728
735
|
upTo(1);
|
|
729
|
-
const body = compact({ model: orNone("model"), effort: orNone("effort"), context: orNone("context") });
|
|
736
|
+
const body = compact({ model: orNone("model"), effort: orNone("effort"), context: orNone("context"), ...(command === "set-agent-runtime" ? { sessions: orNone("sessions") } : {}) });
|
|
730
737
|
if (!Object.keys(body).length)
|
|
731
|
-
throw new UsageError(
|
|
738
|
+
throw new UsageError(`give --model, --effort${command === "set-agent-runtime" ? ", --context or --sessions" : " or --context"}: none sets one back to the router's pick`);
|
|
732
739
|
if (command === "set-agent-runtime")
|
|
733
740
|
return asThem("PUT", `/v1/agents/${encodeURIComponent(need(p[0], "the agent's id"))}/runtime`, body);
|
|
734
741
|
if (command === "set-area-runtime")
|
|
@@ -1081,6 +1088,10 @@ export function toRequest(argv) {
|
|
|
1081
1088
|
throw new UsageError(`"${name}" isn't a hook's event`);
|
|
1082
1089
|
return { bridgeBackground: { action, harness, server: f.server, name } };
|
|
1083
1090
|
}
|
|
1091
|
+
if (action === "status-line") {
|
|
1092
|
+
upTo(1);
|
|
1093
|
+
return { bridgeBackground: { action, harness: "claude-code", server: f.server } };
|
|
1094
|
+
}
|
|
1084
1095
|
if (action === "service" || action === "hooks") {
|
|
1085
1096
|
upTo(2);
|
|
1086
1097
|
const what = need(p[1], "install, remove or status");
|
|
@@ -1159,9 +1170,13 @@ export function toRequest(argv) {
|
|
|
1159
1170
|
return { method: "POST", path: `/v1/requests/${encodeURIComponent(need(p[0], "the request id"))}/answer`, body: { response: readText(words("response", p.slice(1), "the response")) } };
|
|
1160
1171
|
case "act":
|
|
1161
1172
|
return { method: "POST", path: `/v1/decisions/${ref(p[0])}/act`, body: { note: readText(words("note", p.slice(1), "the note")) } };
|
|
1162
|
-
case "inbox":
|
|
1163
|
-
upTo(
|
|
1164
|
-
|
|
1173
|
+
case "inbox": {
|
|
1174
|
+
upTo(1);
|
|
1175
|
+
if (!p[0] && (f.offset !== undefined || f.limit !== undefined))
|
|
1176
|
+
throw new UsageError("--offset and --limit go with a section: gavel inbox requests --offset 10");
|
|
1177
|
+
const query = new URLSearchParams(compact({ section: p[0], offset: f.offset, limit: f.limit }));
|
|
1178
|
+
return { method: "GET", path: `/v1/inbox${query.size ? `?${query}` : ""}` };
|
|
1179
|
+
}
|
|
1165
1180
|
case "chat": {
|
|
1166
1181
|
if (f.text !== undefined && p.length)
|
|
1167
1182
|
throw new UsageError("give your answer once: as words or as --text");
|
|
@@ -1706,6 +1721,8 @@ async function background(run) {
|
|
|
1706
1721
|
const cwd = process.cwd();
|
|
1707
1722
|
const env = process.env;
|
|
1708
1723
|
const print = (answer) => console.log(JSON.stringify(answer, null, 2));
|
|
1724
|
+
if (run.action === "status-line")
|
|
1725
|
+
return bridgeStatusLine({ home, cwd, env });
|
|
1709
1726
|
if (run.action === "hooks") {
|
|
1710
1727
|
// A folder whose harness can't be told is Claude Code's to answer, refusal and all.
|
|
1711
1728
|
let which = run.harness ?? "claude-code";
|
package/package.json
CHANGED