@phren/cli 0.3.12 → 0.3.14
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/dist/bridge/account-usage.d.ts +124 -0
- package/dist/bridge/account-usage.js +258 -0
- package/dist/bridge/agent-hooks.d.ts +3 -0
- package/dist/bridge/agent-hooks.js +20 -1
- package/dist/bridge/codex-app-server.d.ts +6 -0
- package/dist/bridge/codex-app-server.js +3 -1
- package/dist/bridge/codex-hook-trust.d.ts +27 -0
- package/dist/bridge/codex-hook-trust.js +237 -0
- package/dist/bridge/codex-servers.d.ts +25 -1
- package/dist/bridge/codex-servers.js +78 -14
- package/dist/bridge/command.js +4 -1
- package/dist/bridge/dispatch-command.js +9 -3
- package/dist/bridge/dispatch-returns.d.ts +8 -0
- package/dist/bridge/dispatch-returns.js +21 -6
- package/dist/bridge/dispatch.d.ts +25 -1
- package/dist/bridge/dispatch.js +35 -6
- package/dist/bridge/hand-off-queue.d.ts +74 -0
- package/dist/bridge/hand-off-queue.js +235 -0
- package/dist/bridge/hand-off.d.ts +12 -4
- package/dist/bridge/hand-off.js +27 -7
- package/dist/bridge/install.d.ts +8 -1
- package/dist/bridge/install.js +60 -7
- package/dist/bridge/pane-status.d.ts +12 -0
- package/dist/bridge/pane-status.js +50 -1
- package/dist/bridge/push.d.ts +6 -0
- package/dist/bridge/push.js +21 -0
- package/dist/bridge/schedule-launch.d.ts +1 -1
- package/dist/bridge/schedule-launch.js +5 -1
- package/dist/bridge/schedule-watch.d.ts +15 -1
- package/dist/bridge/schedule-watch.js +45 -10
- package/dist/bridge/server-launch.js +14 -4
- package/dist/bridge/server-overview.d.ts +8 -1
- package/dist/bridge/server-overview.js +12 -3
- package/dist/bridge/server-pane-routes.d.ts +1 -0
- package/dist/bridge/server-pane-routes.js +9 -7
- package/dist/bridge/server-routes.d.ts +4 -0
- package/dist/bridge/server-routes.js +57 -7
- package/dist/bridge/server.js +15 -2
- package/dist/bridge/session-activity.d.ts +24 -12
- package/dist/bridge/session-activity.js +36 -14
- package/dist/bridge/stalls.d.ts +22 -0
- package/dist/bridge/stalls.js +57 -0
- package/dist/bridge/sudo.d.ts +209 -0
- package/dist/bridge/sudo.js +501 -0
- package/dist/bridge/terminal-tmux.d.ts +12 -0
- package/dist/bridge/terminal-tmux.js +79 -4
- package/dist/bridge/transcript-claude.d.ts +4 -0
- package/dist/bridge/transcript-claude.js +131 -6
- package/dist/bridge/usage.d.ts +17 -0
- package/dist/bridge/usage.js +37 -3
- package/dist/bridge-hook.mjs +24911 -23487
- package/dist/cli-registry.js +7 -1
- package/dist/modules/registry.js +8 -8
- package/dist/test-global-setup.js +7 -0
- package/dist/tools/dispatch.js +17 -2
- package/package.json +1 -1
- package/starter/global/AGENTS.md +4 -0
- package/starter/global/skills/conductor/SKILL.md +34 -2
|
@@ -93,6 +93,12 @@ export async function claudeChildAgents(file, session) {
|
|
|
93
93
|
}
|
|
94
94
|
const launches = new Map();
|
|
95
95
|
const stops = new Map();
|
|
96
|
+
// A background skill (`/code-review` run as `@code-review`) is announced in
|
|
97
|
+
// a local-command row, not a tool result, and its end is read from its own
|
|
98
|
+
// transcript (claudeSkillFinished).
|
|
99
|
+
const skills = new Set();
|
|
100
|
+
// A Workflow run, by its task id: its agents are in the run's journal.
|
|
101
|
+
const workflows = new Map();
|
|
96
102
|
// Named teammates (the Agent tool with a `name`) run as their own session
|
|
97
103
|
// and never post a task-notification: they announce themselves idle in a
|
|
98
104
|
// teammate-message instead, and may be woken again later. Their file is
|
|
@@ -109,6 +115,23 @@ export async function claudeChildAgents(file, session) {
|
|
|
109
115
|
if (callId)
|
|
110
116
|
launches.set(agentId, { path: String(result.description || result.name || "Agent").slice(0, 200), callId, state: "running" });
|
|
111
117
|
}
|
|
118
|
+
// SendMessage to a finished agent resumes it until its next final notification.
|
|
119
|
+
const resumed = typeof result.resumedAgentId === "string" ? launches.get(result.resumedAgentId) : undefined;
|
|
120
|
+
if (resumed && typeof result.message === "string" && /^Resuming agent\b/i.test(result.message))
|
|
121
|
+
resumed.state = "running";
|
|
122
|
+
if (result.taskType === "local_workflow" && status === "async_launched" && typeof result.taskId === "string"
|
|
123
|
+
&& typeof result.runId === "string" && /^wf_[A-Za-z0-9-]{1,64}$/.test(result.runId)) {
|
|
124
|
+
const callId = String(blocks.find(b => b.type === "tool_result")?.tool_use_id ?? "");
|
|
125
|
+
workflows.set(result.taskId, { runId: result.runId, name: String(result.workflowName || "Workflow").slice(0, 200), callId, state: "running" });
|
|
126
|
+
}
|
|
127
|
+
if (raw.type === "system" && typeof raw.content === "string" && raw.content.includes("<forked-skill-launch>")) {
|
|
128
|
+
const launch = object(JSON.parse(/<forked-skill-launch>([\s\S]*?)<\/forked-skill-launch>/.exec(raw.content)?.[1] ?? "{}"));
|
|
129
|
+
const id = String(launch.agentId ?? "");
|
|
130
|
+
if (/^[A-Za-z0-9._-]{1,128}$/.test(id)) {
|
|
131
|
+
launches.set(id, { path: String(launch.description || (launch.skillName ? `/${launch.skillName}` : "Skill")).slice(0, 200), callId: `skill:${id}`, state: "running" });
|
|
132
|
+
skills.add(id);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
112
135
|
if (raw.type === "assistant") {
|
|
113
136
|
for (const block of blocks) {
|
|
114
137
|
if (block.type !== "tool_use")
|
|
@@ -134,7 +157,7 @@ export async function claudeChildAgents(file, session) {
|
|
|
134
157
|
if (!task)
|
|
135
158
|
continue;
|
|
136
159
|
stops.delete(block.tool_use_id);
|
|
137
|
-
const previous = launches.get(task);
|
|
160
|
+
const previous = launches.get(task) ?? workflows.get(task);
|
|
138
161
|
if (previous && block.is_error !== true && result.task_id === task && typeof result.message === "string"
|
|
139
162
|
&& /^Successfully stopped task\b/i.test(result.message))
|
|
140
163
|
previous.state = "completed";
|
|
@@ -149,7 +172,7 @@ export async function claudeChildAgents(file, session) {
|
|
|
149
172
|
for (const match of notice.matchAll(/<task-notification>([\s\S]*?)<\/task-notification>/g)) {
|
|
150
173
|
const child = /<task-id>([^<>]{1,128})<\/task-id>/.exec(match[1])?.[1], taskStatus = /<status>([^<>]+)<\/status>/.exec(match[1])?.[1].trim();
|
|
151
174
|
// Terminal notifications end only the child named in that envelope.
|
|
152
|
-
const previous = child && launches.get(child);
|
|
175
|
+
const previous = child && (launches.get(child) ?? workflows.get(child));
|
|
153
176
|
if (previous && ["completed", "failed", "cancelled", "canceled", "killed", "stopped"].includes(taskStatus ?? ""))
|
|
154
177
|
previous.state = "completed";
|
|
155
178
|
}
|
|
@@ -167,7 +190,9 @@ export async function claudeChildAgents(file, session) {
|
|
|
167
190
|
// Claude Code records the launch in the parent before the child's own
|
|
168
191
|
// file exists. A launch without a transcript yet is looked for again
|
|
169
192
|
// shortly, rather than being missed until the parent next changes.
|
|
170
|
-
|
|
193
|
+
// Children whose end the parent does not record (background skills,
|
|
194
|
+
// workflow agents) are looked at again on a timer too.
|
|
195
|
+
let awaiting = false, live = false;
|
|
171
196
|
const root = await realpath(path.join(path.dirname(file), session, "subagents")).catch(() => undefined);
|
|
172
197
|
for (const [agentId, launch] of launches) {
|
|
173
198
|
const childFile = root && await realpath(path.join(root, `agent-${agentId}.jsonl`)).catch(() => undefined);
|
|
@@ -176,6 +201,12 @@ export async function claudeChildAgents(file, session) {
|
|
|
176
201
|
awaiting = true;
|
|
177
202
|
continue;
|
|
178
203
|
}
|
|
204
|
+
if (skills.has(agentId) && launch.state === "running") {
|
|
205
|
+
if (await claudeSkillFinished(childFile).catch(() => false))
|
|
206
|
+
launch.state = "completed";
|
|
207
|
+
else
|
|
208
|
+
live = true;
|
|
209
|
+
}
|
|
179
210
|
const model = await claudeChildModel(childFile).catch(() => undefined);
|
|
180
211
|
const checkout = await claudeChildCheckout(childFile).catch(() => ({}));
|
|
181
212
|
relations.push({ id: createHash("sha256").update(`claude\0${session}\0${agentId}`).digest("hex").slice(0, 32),
|
|
@@ -183,10 +214,21 @@ export async function claudeChildAgents(file, session) {
|
|
|
183
214
|
...(model !== undefined ? { model } : {}), ...checkout, children: [] });
|
|
184
215
|
}
|
|
185
216
|
if (teammates.size && root) {
|
|
186
|
-
const
|
|
217
|
+
const entries = await readdir(root).catch(() => []);
|
|
218
|
+
const names = entries.filter(n => /^agent-a[A-Za-z0-9][A-Za-z0-9_-]{0,63}-[0-9a-f]{8,32}\.jsonl$/.test(n));
|
|
219
|
+
// Claude Code 2.1.2xx names a teammate's file by id and keeps its name in
|
|
220
|
+
// the `.meta.json` beside it.
|
|
221
|
+
let named;
|
|
187
222
|
for (const [name, launch] of teammates) {
|
|
188
|
-
|
|
223
|
+
let fileName = names.find(n => n.startsWith(`agent-a${name}-`));
|
|
224
|
+
if (!fileName) {
|
|
225
|
+
named ??= await claudeChildNames(root, entries);
|
|
226
|
+
fileName = named.get(name);
|
|
227
|
+
}
|
|
189
228
|
const agentId = fileName?.slice("agent-".length, -".jsonl".length);
|
|
229
|
+
// A named agent launched in the background is already listed by its launch.
|
|
230
|
+
if (agentId && launches.has(agentId))
|
|
231
|
+
continue;
|
|
190
232
|
const childFile = agentId && await realpath(path.join(root, fileName)).catch(() => undefined);
|
|
191
233
|
if (!agentId || !childFile || !childFile.startsWith(root + path.sep) || !await claudeChildBelongsTo(childFile, session, agentId)) {
|
|
192
234
|
if (launch.state === "running")
|
|
@@ -203,11 +245,94 @@ export async function claudeChildAgents(file, session) {
|
|
|
203
245
|
...(model !== undefined ? { model } : {}), ...checkout, children: [] });
|
|
204
246
|
}
|
|
205
247
|
}
|
|
206
|
-
|
|
248
|
+
if (workflows.size && root) {
|
|
249
|
+
const seen = new Set(relations.map(relation => relation.session));
|
|
250
|
+
for (const workflow of workflows.values()) {
|
|
251
|
+
for (const child of await claudeWorkflowAgents(root, session, workflow)) {
|
|
252
|
+
if (seen.has(child.session))
|
|
253
|
+
continue;
|
|
254
|
+
seen.add(child.session);
|
|
255
|
+
relations.push(child);
|
|
256
|
+
if (child.state === "running")
|
|
257
|
+
live = true;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
claudeRelationCache.set(file, { signature, relations, ...(awaiting || live ? { recheckAt: Date.now() + (awaiting ? 2_000 : 5_000) } : {}) });
|
|
207
262
|
while (claudeRelationCache.size > 64)
|
|
208
263
|
claudeRelationCache.delete(claudeRelationCache.keys().next().value);
|
|
209
264
|
return relations;
|
|
210
265
|
}
|
|
266
|
+
/** How long a background skill's transcript may sit unchanged before it is
|
|
267
|
+
* taken as finished: the parent records no end for it, and a session that
|
|
268
|
+
* exited mid-skill leaves it without a final reply. */
|
|
269
|
+
export const CLAUDE_SKILL_QUIET_MS = 30 * 60 * 1000;
|
|
270
|
+
/** A background skill is done once its transcript ends on a finished reply,
|
|
271
|
+
* or has not changed for CLAUDE_SKILL_QUIET_MS. */
|
|
272
|
+
async function claudeSkillFinished(file, now = Date.now()) {
|
|
273
|
+
const metadata = await stat(file);
|
|
274
|
+
if (now - metadata.mtimeMs >= CLAUDE_SKILL_QUIET_MS)
|
|
275
|
+
return true;
|
|
276
|
+
const start = Math.max(0, metadata.size - 65_536), chunks = [];
|
|
277
|
+
for await (const chunk of createReadStream(file, { start }))
|
|
278
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
279
|
+
const last = Buffer.concat(chunks).toString("utf8").split("\n").filter(line => line.trim()).at(-1);
|
|
280
|
+
try {
|
|
281
|
+
const raw = object(JSON.parse(last ?? ""));
|
|
282
|
+
return raw.type === "assistant" && object(raw.message).stop_reason === "end_turn";
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/** Sub-agent files by the name their `.meta.json` gives them. */
|
|
289
|
+
async function claudeChildNames(root, entries) {
|
|
290
|
+
const names = new Map();
|
|
291
|
+
for (const entry of entries) {
|
|
292
|
+
if (!/^agent-[A-Za-z0-9._-]{1,128}\.meta\.json$/.test(entry))
|
|
293
|
+
continue;
|
|
294
|
+
const meta = await readFile(path.join(root, entry), "utf8").then(v => object(JSON.parse(v))).catch(() => ({}));
|
|
295
|
+
if (typeof meta.name === "string" && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(meta.name))
|
|
296
|
+
names.set(meta.name, entry.slice(0, -".meta.json".length) + ".jsonl");
|
|
297
|
+
}
|
|
298
|
+
return names;
|
|
299
|
+
}
|
|
300
|
+
/** A Workflow run's agents from its journal: each `started` agent runs until
|
|
301
|
+
* the journal records another row for it or the run itself finishes. */
|
|
302
|
+
async function claudeWorkflowAgents(root, session, workflow) {
|
|
303
|
+
const directory = await realpath(path.join(root, "workflows", workflow.runId)).catch(() => undefined);
|
|
304
|
+
if (!directory || !directory.startsWith(root + path.sep))
|
|
305
|
+
return [];
|
|
306
|
+
const journal = path.join(directory, "journal.jsonl");
|
|
307
|
+
const info = await stat(journal).catch(() => undefined);
|
|
308
|
+
if (!info?.isFile() || info.size > 16 * 1024 * 1024)
|
|
309
|
+
return [];
|
|
310
|
+
const agents = new Map();
|
|
311
|
+
for (const line of (await readFile(journal, "utf8")).split("\n")) {
|
|
312
|
+
try {
|
|
313
|
+
const row = object(JSON.parse(line)), id = String(row.agentId ?? "");
|
|
314
|
+
if (!/^[A-Za-z0-9._-]{1,128}$/.test(id))
|
|
315
|
+
continue;
|
|
316
|
+
agents.set(id, row.type === "started" ? agents.get(id) ?? false : true);
|
|
317
|
+
}
|
|
318
|
+
catch { /* A row still being written. */ }
|
|
319
|
+
}
|
|
320
|
+
const relations = [];
|
|
321
|
+
for (const [agentId, done] of agents) {
|
|
322
|
+
const childFile = await realpath(path.join(directory, `agent-${agentId}.jsonl`)).catch(() => undefined);
|
|
323
|
+
if (!childFile || !childFile.startsWith(directory + path.sep) || !await claudeChildBelongsTo(childFile, session, agentId))
|
|
324
|
+
continue;
|
|
325
|
+
const meta = await readFile(childFile.slice(0, -".jsonl".length) + ".meta.json", "utf8").then(v => object(JSON.parse(v))).catch(() => ({}));
|
|
326
|
+
const model = await claudeChildModel(childFile).catch(() => undefined);
|
|
327
|
+
const checkout = await claudeChildCheckout(childFile).catch(() => ({}));
|
|
328
|
+
relations.push({ id: createHash("sha256").update(`claude\0${session}\0${agentId}`).digest("hex").slice(0, 32),
|
|
329
|
+
session: agentId, transcript: childFile, provider: "claude",
|
|
330
|
+
path: String(meta.description || workflow.name).slice(0, 200), callId: workflow.callId || `workflow:${workflow.runId}`,
|
|
331
|
+
state: done || workflow.state === "completed" ? "completed" : "running",
|
|
332
|
+
...(model !== undefined ? { model } : {}), ...checkout, children: [] });
|
|
333
|
+
}
|
|
334
|
+
return relations;
|
|
335
|
+
}
|
|
211
336
|
async function claudeChildBelongsTo(file, parent, agentId) {
|
|
212
337
|
let bytes = Buffer.alloc(0);
|
|
213
338
|
for await (const chunk of createReadStream(file, { start: 0, end: 1_048_575 })) {
|
package/dist/bridge/usage.d.ts
CHANGED
|
@@ -124,6 +124,21 @@ export declare function readCodexLimits(executable?: string): Promise<AccountUsa
|
|
|
124
124
|
export declare function copilotUsage(value: unknown, now?: Date): AccountUsage;
|
|
125
125
|
/** Reads through the GitHub CLI's own sign-in; the token never reaches Phren. */
|
|
126
126
|
export declare function readCopilotUsage(now?: Date, run?: (file: string, args: string[]) => Promise<string>): Promise<AccountUsage>;
|
|
127
|
+
/** Under this much left on any window, an account is near its limit: information for the owner, never a reason to avoid it. */
|
|
128
|
+
export declare const NEAR_LIMIT_LEFT = 20;
|
|
129
|
+
/** No quota on this window now: at 100% or refused by the service, and its reset not yet passed. */
|
|
130
|
+
export declare function windowExhausted(window: UsageWindow, now: number): boolean;
|
|
131
|
+
/** Percent left on a window at `now`: none once its reset passed or with no percent, 0 while the service refuses requests. */
|
|
132
|
+
export declare function windowLeft(window: UsageWindow, now: number): number | undefined;
|
|
133
|
+
/** What a capacity probe says about room: each Codex and Claude account's least room left, and whether it has none
|
|
134
|
+
* (`exhausted`, with `until` the last reset that frees it). */
|
|
135
|
+
export declare function capacityRoom(accounts: readonly AccountUsage[], now: number): Array<{
|
|
136
|
+
source: string;
|
|
137
|
+
account?: string;
|
|
138
|
+
leftPercent?: number;
|
|
139
|
+
exhausted?: true;
|
|
140
|
+
until?: string;
|
|
141
|
+
}>;
|
|
127
142
|
/** A Claude report older than this says nothing about the account now. */
|
|
128
143
|
export declare const CLAUDE_REPORT_MAX_AGE_MS: number;
|
|
129
144
|
/**
|
|
@@ -155,6 +170,8 @@ export declare class AccountUsageReader {
|
|
|
155
170
|
read(sources?: Set<string>, allAccounts?: boolean): Promise<{
|
|
156
171
|
accounts: AccountUsage[];
|
|
157
172
|
}>;
|
|
173
|
+
/** Codex and every Claude home, without the spend readers: what a dispatch capacity probe asks. */
|
|
174
|
+
limits(allAccounts?: boolean): Promise<AccountUsage[]>;
|
|
158
175
|
/** ElevenLabs is read only when the caller shows it: every read spends a request against the key's quota. */
|
|
159
176
|
private spending;
|
|
160
177
|
/** Live first, so the phone's minute-by-minute poll keeps Claude current
|
package/dist/bridge/usage.js
CHANGED
|
@@ -625,6 +625,35 @@ export async function readCopilotUsage(now = new Date(), run = async (file, args
|
|
|
625
625
|
: "Could not read Copilot usage. Sign in with gh auth login on this computer (Copilot reports its quotas through GitHub)." };
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
+
/** Under this much left on any window, an account is near its limit: information for the owner, never a reason to avoid it. */
|
|
629
|
+
export const NEAR_LIMIT_LEFT = 20;
|
|
630
|
+
/** No quota on this window now: at 100% or refused by the service, and its reset not yet passed. */
|
|
631
|
+
export function windowExhausted(window, now) {
|
|
632
|
+
const reset = window.resetsAt ? Date.parse(window.resetsAt) : NaN;
|
|
633
|
+
if (window.reset || Number.isFinite(reset) && reset <= now)
|
|
634
|
+
return false;
|
|
635
|
+
return window.limited === true || typeof window.usedPercent === "number" && window.usedPercent >= 100;
|
|
636
|
+
}
|
|
637
|
+
/** Percent left on a window at `now`: none once its reset passed or with no percent, 0 while the service refuses requests. */
|
|
638
|
+
export function windowLeft(window, now) {
|
|
639
|
+
const reset = window.resetsAt ? Date.parse(window.resetsAt) : NaN;
|
|
640
|
+
if (window.reset || Number.isFinite(reset) && reset <= now)
|
|
641
|
+
return undefined;
|
|
642
|
+
if (window.limited)
|
|
643
|
+
return 0;
|
|
644
|
+
return typeof window.usedPercent === "number" ? Math.max(0, Math.min(100, Math.round(100 - window.usedPercent))) : undefined;
|
|
645
|
+
}
|
|
646
|
+
/** What a capacity probe says about room: each Codex and Claude account's least room left, and whether it has none
|
|
647
|
+
* (`exhausted`, with `until` the last reset that frees it). */
|
|
648
|
+
export function capacityRoom(accounts, now) {
|
|
649
|
+
return accounts.map(usage => {
|
|
650
|
+
const left = usage.windows.map(window => windowLeft(window, now)).filter((value) => value !== undefined);
|
|
651
|
+
const out = usage.windows.filter(window => windowExhausted(window, now));
|
|
652
|
+
const until = out.map(window => window.resetsAt).filter((value) => Boolean(value)).sort().at(-1);
|
|
653
|
+
return { source: usage.source, ...(usage.account?.id ? { account: usage.account.id } : {}), ...(left.length ? { leftPercent: Math.min(...left) } : {}),
|
|
654
|
+
...(out.length ? { exhausted: true, ...(until ? { until } : {}) } : {}) };
|
|
655
|
+
});
|
|
656
|
+
}
|
|
628
657
|
/** A Claude report older than this says nothing about the account now. */
|
|
629
658
|
export const CLAUDE_REPORT_MAX_AGE_MS = 3 * 86_400_000;
|
|
630
659
|
/**
|
|
@@ -681,6 +710,12 @@ export class AccountUsageReader {
|
|
|
681
710
|
/** `allAccounts`: one Claude row per home. Otherwise only the default home's, as
|
|
682
711
|
* before accounts existed, since older phones refuse two rows of one source. */
|
|
683
712
|
async read(sources, allAccounts = false) {
|
|
713
|
+
const [limits, spending] = await Promise.all([this.limits(allAccounts),
|
|
714
|
+
this.spending(sources?.has("copilot") ?? true, sources?.has("elevenlabs") ?? true)]);
|
|
715
|
+
return { accounts: [...limits, ...spending] };
|
|
716
|
+
}
|
|
717
|
+
/** Codex and every Claude home, without the spend readers: what a dispatch capacity probe asks. */
|
|
718
|
+
async limits(allAccounts = true) {
|
|
684
719
|
if (!this.cached || this.now() - this.cached.at >= 60_000) {
|
|
685
720
|
this.pending ??= this.readCodex().then(value => { this.cached = { at: this.now(), value }; return value; }).finally(() => { this.pending = undefined; });
|
|
686
721
|
}
|
|
@@ -691,9 +726,8 @@ export class AccountUsageReader {
|
|
|
691
726
|
const email = claudeAccountEmail(home);
|
|
692
727
|
return { ...settleClaudeUsage(await this.claude(home), this.now()), account: { ...claudeAccountRef(home), ...(email ? { email } : {}) } };
|
|
693
728
|
};
|
|
694
|
-
const [codexValue, claude
|
|
695
|
-
|
|
696
|
-
return { accounts: [{ ...codexValue, account: CODEX_ACCOUNT }, ...claude, ...spending] };
|
|
729
|
+
const [codexValue, claude] = await Promise.all([codex, Promise.all(homes.map(claudeRow))]);
|
|
730
|
+
return [{ ...codexValue, account: CODEX_ACCOUNT }, ...claude];
|
|
697
731
|
}
|
|
698
732
|
/** ElevenLabs is read only when the caller shows it: every read spends a request against the key's quota. */
|
|
699
733
|
async spending(includeCopilot, includeElevenLabs) {
|