@phren/cli 0.3.64 → 0.3.65
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/usage.d.ts +7 -0
- package/dist/bridge/usage.js +18 -1
- package/dist/bridge-hook.mjs +12 -3
- package/package.json +1 -1
package/dist/bridge/usage.d.ts
CHANGED
|
@@ -151,6 +151,13 @@ export declare function claudeOAuthUsage(value: unknown, now?: Date): AccountUsa
|
|
|
151
151
|
* own file, and nothing on macOS (its keychain item name is unverified).
|
|
152
152
|
*/
|
|
153
153
|
export declare function readClaudeToken(execSecurity?: typeof execFile.__promisify__, platform?: NodeJS.Platform, home?: ClaudeHome): Promise<string | undefined>;
|
|
154
|
+
/**
|
|
155
|
+
* Two Claude homes signed in to one login are one allowance, and phones refuse
|
|
156
|
+
* an answer with two rows of one key: one row each, in the first home's place
|
|
157
|
+
* and under its name (the default home comes first), carrying the freshest
|
|
158
|
+
* report any of those homes has. Account choice reads `limits()` per home.
|
|
159
|
+
*/
|
|
160
|
+
export declare function oneRowPerLogin(rows: AccountUsage[]): AccountUsage[];
|
|
154
161
|
/** Fetch live limits; any failure falls back to the local snapshot. */
|
|
155
162
|
export declare function fetchClaudeUsage(token: string, fetchImpl?: typeof fetch, now?: Date): Promise<AccountUsage>;
|
|
156
163
|
/** Only initialize and read limits. Never create a thread, prompt, or login. */
|
package/dist/bridge/usage.js
CHANGED
|
@@ -540,6 +540,23 @@ export async function readClaudeToken(execSecurity = exec, platform = process.pl
|
|
|
540
540
|
return undefined;
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Two Claude homes signed in to one login are one allowance, and phones refuse
|
|
545
|
+
* an answer with two rows of one key: one row each, in the first home's place
|
|
546
|
+
* and under its name (the default home comes first), carrying the freshest
|
|
547
|
+
* report any of those homes has. Account choice reads `limits()` per home.
|
|
548
|
+
*/
|
|
549
|
+
export function oneRowPerLogin(rows) {
|
|
550
|
+
const at = (row) => row.windows.length ? Date.parse(row.updatedAt ?? "") || 0 : -1;
|
|
551
|
+
const best = new Map();
|
|
552
|
+
for (const row of rows) {
|
|
553
|
+
const key = row.account?.key;
|
|
554
|
+
if (key && (!best.has(key) || at(row) > at(best.get(key))))
|
|
555
|
+
best.set(key, row);
|
|
556
|
+
}
|
|
557
|
+
return rows.filter(row => !row.account?.key || rows.find(other => other.account?.key === row.account.key) === row)
|
|
558
|
+
.map(row => row.account?.key ? { ...best.get(row.account.key), account: row.account } : row);
|
|
559
|
+
}
|
|
543
560
|
/** Fetch live limits; any failure falls back to the local snapshot. */
|
|
544
561
|
export async function fetchClaudeUsage(token, fetchImpl = fetch, now = new Date()) {
|
|
545
562
|
const controller = new AbortController();
|
|
@@ -817,7 +834,7 @@ export class AccountUsageReader {
|
|
|
817
834
|
async read(sources, allAccounts = false) {
|
|
818
835
|
const [limits, spending] = await Promise.all([this.limits(allAccounts),
|
|
819
836
|
this.spending(sources?.has("copilot") ?? true, sources?.has("elevenlabs") ?? true)]);
|
|
820
|
-
return { accounts: [...limits, ...spending] };
|
|
837
|
+
return { accounts: [...oneRowPerLogin(limits), ...spending] };
|
|
821
838
|
}
|
|
822
839
|
/** Codex and every Claude home, without the spend readers: what a dispatch capacity probe asks. */
|
|
823
840
|
async limits(allAccounts = true) {
|
package/dist/bridge-hook.mjs
CHANGED
|
@@ -37438,7 +37438,7 @@ var init_package_metadata = __esm({
|
|
|
37438
37438
|
__dirname = path35.dirname(fileURLToPath2(import.meta.url));
|
|
37439
37439
|
ROOT = path35.join(__dirname, "..");
|
|
37440
37440
|
PACKAGE_JSON_PATH = path35.join(ROOT, "package.json");
|
|
37441
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
37441
|
+
BUNDLED_VERSION = true ? "0.3.65" : "0.0.0";
|
|
37442
37442
|
PACKAGE_JSON = readPackageJson();
|
|
37443
37443
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
37444
37444
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -49957,6 +49957,15 @@ async function readClaudeToken(execSecurity = exec10, platform = process.platfor
|
|
|
49957
49957
|
return void 0;
|
|
49958
49958
|
}
|
|
49959
49959
|
}
|
|
49960
|
+
function oneRowPerLogin(rows2) {
|
|
49961
|
+
const at2 = (row) => row.windows.length ? Date.parse(row.updatedAt ?? "") || 0 : -1;
|
|
49962
|
+
const best = /* @__PURE__ */ new Map();
|
|
49963
|
+
for (const row of rows2) {
|
|
49964
|
+
const key4 = row.account?.key;
|
|
49965
|
+
if (key4 && (!best.has(key4) || at2(row) > at2(best.get(key4)))) best.set(key4, row);
|
|
49966
|
+
}
|
|
49967
|
+
return rows2.filter((row) => !row.account?.key || rows2.find((other) => other.account?.key === row.account.key) === row).map((row) => row.account?.key ? { ...best.get(row.account.key), account: row.account } : row);
|
|
49968
|
+
}
|
|
49960
49969
|
async function fetchClaudeUsage(token, fetchImpl = fetch, now = /* @__PURE__ */ new Date()) {
|
|
49961
49970
|
const controller = new AbortController();
|
|
49962
49971
|
const timer = setTimeout(() => controller.abort(), 8e3);
|
|
@@ -50273,7 +50282,7 @@ var init_usage = __esm({
|
|
|
50273
50282
|
this.limits(allAccounts),
|
|
50274
50283
|
this.spending(sources?.has("copilot") ?? true, sources?.has("elevenlabs") ?? true)
|
|
50275
50284
|
]);
|
|
50276
|
-
return { accounts: [...limits, ...spending] };
|
|
50285
|
+
return { accounts: [...oneRowPerLogin(limits), ...spending] };
|
|
50277
50286
|
}
|
|
50278
50287
|
/** Codex and every Claude home, without the spend readers: what a dispatch capacity probe asks. */
|
|
50279
50288
|
async limits(allAccounts = true) {
|
|
@@ -82843,7 +82852,7 @@ async function main() {
|
|
|
82843
82852
|
return askpass2(args[1]);
|
|
82844
82853
|
}
|
|
82845
82854
|
const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_command(), command_exports));
|
|
82846
|
-
return runBridge2(args, "0.3.
|
|
82855
|
+
return runBridge2(args, "0.3.65");
|
|
82847
82856
|
}
|
|
82848
82857
|
main().then((code) => {
|
|
82849
82858
|
process.exitCode = code;
|