@sideboard-ai/core 0.1.198 → 0.1.200
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/{abletime-JINF5KJV.js → abletime-345SE3B4.js} +2 -2
- package/dist/{abletime-HR6P4GJH.js → abletime-KGPD3UUJ.js} +2 -2
- package/dist/{agents-5TZY6LLX.js → agents-N7WXOGN6.js} +28 -4
- package/dist/{agents-AQQKPD46.js → agents-ZRIFDXCB.js} +28 -4
- package/dist/{app-settings-5KHVKJKO.js → app-settings-AXCURTZJ.js} +11 -1
- package/dist/{app-settings-J775CYOO.js → app-settings-V6IHESEQ.js} +11 -1
- package/dist/{chunk-SYXSSU7G.js → chunk-5XSDGJMP.js} +369 -4
- package/dist/{chunk-DROELG52.js → chunk-62IMZIIZ.js} +58 -41
- package/dist/{chunk-E37JHCO3.js → chunk-7AHAABKN.js} +1 -1
- package/dist/{chunk-S5GLSRLP.js → chunk-CXFW5LIH.js} +48 -1
- package/dist/{chunk-6YTI2HBG.js → chunk-EWDE54OI.js} +2 -2
- package/dist/{chunk-AH6WIBLY.js → chunk-ISV5IFH3.js} +48 -1
- package/dist/{chunk-DP4TKAMZ.js → chunk-NXM45OS3.js} +1 -1
- package/dist/{chunk-6YS5IKD2.js → chunk-O2DRYD2B.js} +59 -42
- package/dist/{chunk-S4QCBBXS.js → chunk-OSPE25A7.js} +1 -1
- package/dist/{chunk-HZTHWU6A.js → chunk-PDMNYCPL.js} +2 -2
- package/dist/{chunk-KTHRWHA3.js → chunk-PGQGP4FD.js} +1 -1
- package/dist/{chunk-EA67VQM2.js → chunk-PKUPOVKP.js} +369 -4
- package/dist/{coordinator-prompt-IX66YUJ2.js → coordinator-prompt-2RWBH6W7.js} +3 -3
- package/dist/{coordinator-prompt-LYKS3YNG.js → coordinator-prompt-AL62H73U.js} +3 -3
- package/dist/{global-workspace-SNJ2Z6SL.js → global-workspace-VAO3BQP5.js} +3 -3
- package/dist/{global-workspace-4QX6UEOY.js → global-workspace-Y5KKGXN7.js} +3 -3
- package/dist/index.cjs +766 -280
- package/dist/index.d.cts +116 -11
- package/dist/index.d.ts +116 -11
- package/dist/index.js +42 -8
- package/dist/mcp/run-stdio.cjs +374 -276
- package/dist/mcp/run-stdio.js +8 -8
- package/dist/{orchestrator-L2H42HPW.js → orchestrator-D2EJ4Z7Z.js} +5 -5
- package/dist/{orchestrator-6ZNKCPNL.js → orchestrator-DPHIMK44.js} +5 -5
- package/dist/{workspaces-URMUVGAQ.js → workspaces-DZZQM745.js} +3 -3
- package/dist/{workspaces-UTOYGBYB.js → workspaces-HEKFQP4B.js} +3 -3
- package/dist/{worktree-R43JOR4V.js → worktree-ENRMJUI3.js} +2 -2
- package/dist/{worktree-RM6UWNGZ.js → worktree-IEUSQ63V.js} +2 -2
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isOrchestratorThread
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PDMNYCPL.js";
|
|
4
4
|
import {
|
|
5
5
|
codexUnattendedGitConfigArgs,
|
|
6
6
|
mergeAgentGitAuthEnv,
|
|
7
7
|
resolveAgentGitAuthEnv,
|
|
8
8
|
resolveCodexGitWritableRoots
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OSPE25A7.js";
|
|
10
10
|
import {
|
|
11
11
|
applyConnectedTeamToCli,
|
|
12
12
|
brightsyMcpServerName,
|
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
loadBrightsyConfig
|
|
18
18
|
} from "./chunk-AN3THU7F.js";
|
|
19
|
+
import {
|
|
20
|
+
httpFetch
|
|
21
|
+
} from "./chunk-N7WZ6NIN.js";
|
|
19
22
|
import {
|
|
20
23
|
applyAgentRunnerHeapEnv,
|
|
21
24
|
applyNodeLaunch,
|
|
@@ -38,7 +41,7 @@ import {
|
|
|
38
41
|
loadAppSettings,
|
|
39
42
|
resolveAgentExecutable,
|
|
40
43
|
resolveClaudeExecutable
|
|
41
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-CXFW5LIH.js";
|
|
42
45
|
import {
|
|
43
46
|
isElectronLikeCommand,
|
|
44
47
|
unwrapStrippedElectronLaunch
|
|
@@ -1934,7 +1937,7 @@ var claudeAdapter = {
|
|
|
1934
1937
|
);
|
|
1935
1938
|
}
|
|
1936
1939
|
const mode = permissionMode(thread);
|
|
1937
|
-
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-
|
|
1940
|
+
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-Y5KKGXN7.js");
|
|
1938
1941
|
const isOrchestrator = isOrchestratorThread2(thread);
|
|
1939
1942
|
const injectedServers = await buildInjectedMcpServers({
|
|
1940
1943
|
includeSideboard: true,
|
|
@@ -3427,6 +3430,356 @@ function resolveQuotaFallbackAgent(current, preferred) {
|
|
|
3427
3430
|
return ordered.find((a) => a !== current) ?? (current === "cursor" ? "codex" : "cursor");
|
|
3428
3431
|
}
|
|
3429
3432
|
|
|
3433
|
+
// src/agents/claude-usage.ts
|
|
3434
|
+
var WINDOW_META = {
|
|
3435
|
+
five_hour: {
|
|
3436
|
+
label: "5-hour session",
|
|
3437
|
+
shortLabel: "5h",
|
|
3438
|
+
detail: "Rolling 5-hour limit across all models"
|
|
3439
|
+
},
|
|
3440
|
+
seven_day: {
|
|
3441
|
+
label: "Weekly",
|
|
3442
|
+
shortLabel: "wk",
|
|
3443
|
+
detail: "7-day cap across all models"
|
|
3444
|
+
},
|
|
3445
|
+
seven_day_opus: {
|
|
3446
|
+
label: "Opus",
|
|
3447
|
+
shortLabel: "Opus",
|
|
3448
|
+
detail: "Weekly Opus-only cap"
|
|
3449
|
+
},
|
|
3450
|
+
seven_day_sonnet: {
|
|
3451
|
+
label: "Sonnet",
|
|
3452
|
+
shortLabel: "Sonnet",
|
|
3453
|
+
detail: "Weekly Sonnet-only cap"
|
|
3454
|
+
}
|
|
3455
|
+
};
|
|
3456
|
+
var WINDOW_ORDER = [
|
|
3457
|
+
"five_hour",
|
|
3458
|
+
"seven_day",
|
|
3459
|
+
"seven_day_opus",
|
|
3460
|
+
"seven_day_sonnet"
|
|
3461
|
+
];
|
|
3462
|
+
function parseClaudeResetsAt(value) {
|
|
3463
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
3464
|
+
const ms = value > 1e12 ? value : value * 1e3;
|
|
3465
|
+
const d = new Date(ms);
|
|
3466
|
+
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
3467
|
+
}
|
|
3468
|
+
if (typeof value === "string") {
|
|
3469
|
+
const trimmed = value.trim();
|
|
3470
|
+
if (!trimmed) return null;
|
|
3471
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
3472
|
+
return parseClaudeResetsAt(Number(trimmed));
|
|
3473
|
+
}
|
|
3474
|
+
const d = new Date(trimmed);
|
|
3475
|
+
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
3476
|
+
}
|
|
3477
|
+
return null;
|
|
3478
|
+
}
|
|
3479
|
+
function parseClaudeUtilization(value) {
|
|
3480
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
3481
|
+
return Math.max(0, Math.min(100, value));
|
|
3482
|
+
}
|
|
3483
|
+
function windowFromRaw(id, raw) {
|
|
3484
|
+
if (!raw || typeof raw !== "object") return null;
|
|
3485
|
+
const row = raw;
|
|
3486
|
+
const used = parseClaudeUtilization(row.utilization ?? row.used_percentage);
|
|
3487
|
+
if (used == null) return null;
|
|
3488
|
+
const meta = WINDOW_META[id];
|
|
3489
|
+
return {
|
|
3490
|
+
id,
|
|
3491
|
+
label: meta.label,
|
|
3492
|
+
shortLabel: meta.shortLabel,
|
|
3493
|
+
detail: meta.detail,
|
|
3494
|
+
usedPercent: used,
|
|
3495
|
+
remainingPercent: Math.max(0, Math.min(100, 100 - used)),
|
|
3496
|
+
resetsAt: parseClaudeResetsAt(row.resets_at)
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
function extraUsageFromRaw(raw) {
|
|
3500
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
3501
|
+
const row = raw;
|
|
3502
|
+
const enabled = row.is_enabled === true || row.enabled === true;
|
|
3503
|
+
if (!enabled && row.is_enabled !== false && row.enabled !== false) return void 0;
|
|
3504
|
+
const usedCredits = numberOrUndef(row.used_credits ?? row.used);
|
|
3505
|
+
const monthlyLimit = numberOrUndef(row.monthly_limit);
|
|
3506
|
+
const usedPercent = parseClaudeUtilization(row.utilization) ?? void 0;
|
|
3507
|
+
return {
|
|
3508
|
+
enabled,
|
|
3509
|
+
...usedCredits != null ? { usedCredits } : {},
|
|
3510
|
+
...monthlyLimit != null ? { monthlyLimit } : {},
|
|
3511
|
+
...usedPercent != null ? { usedPercent } : {}
|
|
3512
|
+
};
|
|
3513
|
+
}
|
|
3514
|
+
function numberOrUndef(value) {
|
|
3515
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
3516
|
+
return value;
|
|
3517
|
+
}
|
|
3518
|
+
function parseClaudeUsagePayload(raw, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
3519
|
+
if (!raw || typeof raw !== "object") return null;
|
|
3520
|
+
const obj = raw;
|
|
3521
|
+
const source = obj.rate_limits && typeof obj.rate_limits === "object" ? obj.rate_limits : obj;
|
|
3522
|
+
const windows = [];
|
|
3523
|
+
for (const id of WINDOW_ORDER) {
|
|
3524
|
+
const parsed = windowFromRaw(id, source[id]);
|
|
3525
|
+
if (parsed) windows.push(parsed);
|
|
3526
|
+
}
|
|
3527
|
+
if (windows.length === 0) return null;
|
|
3528
|
+
const extra = extraUsageFromRaw(obj.extra_usage ?? source.extra_usage);
|
|
3529
|
+
return {
|
|
3530
|
+
windows,
|
|
3531
|
+
...extra ? { extraUsage: extra } : {},
|
|
3532
|
+
fetchedAt
|
|
3533
|
+
};
|
|
3534
|
+
}
|
|
3535
|
+
function hottestClaudeWindow(usage) {
|
|
3536
|
+
if (usage.windows.length === 0) return null;
|
|
3537
|
+
return usage.windows.reduce((a, b) => b.usedPercent > a.usedPercent ? b : a);
|
|
3538
|
+
}
|
|
3539
|
+
function formatClaudeUsageReset(resetsAt, now = /* @__PURE__ */ new Date()) {
|
|
3540
|
+
if (!resetsAt) return "";
|
|
3541
|
+
const at = new Date(resetsAt);
|
|
3542
|
+
if (Number.isNaN(at.getTime())) return "";
|
|
3543
|
+
const ms = at.getTime() - now.getTime();
|
|
3544
|
+
if (ms <= 0) return "resets soon";
|
|
3545
|
+
const minutes = Math.round(ms / 6e4);
|
|
3546
|
+
if (minutes < 60) return `resets in ${Math.max(1, minutes)}m`;
|
|
3547
|
+
const hours = Math.round(minutes / 60);
|
|
3548
|
+
if (hours < 36) return `resets in ${hours}h`;
|
|
3549
|
+
try {
|
|
3550
|
+
return `resets ${at.toLocaleString(void 0, {
|
|
3551
|
+
weekday: "short",
|
|
3552
|
+
hour: "numeric",
|
|
3553
|
+
minute: "2-digit"
|
|
3554
|
+
})}`;
|
|
3555
|
+
} catch {
|
|
3556
|
+
return `resets ${at.toISOString()}`;
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
function formatClaudeUsageResetClock(resetsAt) {
|
|
3560
|
+
if (!resetsAt) return "";
|
|
3561
|
+
const at = new Date(resetsAt);
|
|
3562
|
+
if (Number.isNaN(at.getTime())) return "";
|
|
3563
|
+
try {
|
|
3564
|
+
return at.toLocaleString(void 0, {
|
|
3565
|
+
weekday: "short",
|
|
3566
|
+
month: "short",
|
|
3567
|
+
day: "numeric",
|
|
3568
|
+
hour: "numeric",
|
|
3569
|
+
minute: "2-digit"
|
|
3570
|
+
});
|
|
3571
|
+
} catch {
|
|
3572
|
+
return at.toISOString();
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
function formatClaudeUsageFetchedAt(fetchedAt, now = /* @__PURE__ */ new Date()) {
|
|
3576
|
+
const at = new Date(fetchedAt);
|
|
3577
|
+
if (Number.isNaN(at.getTime())) return "";
|
|
3578
|
+
const minutes = Math.max(0, Math.round((now.getTime() - at.getTime()) / 6e4));
|
|
3579
|
+
if (minutes < 1) return "Updated just now";
|
|
3580
|
+
if (minutes < 60) return `Updated ${minutes}m ago`;
|
|
3581
|
+
const hours = Math.round(minutes / 60);
|
|
3582
|
+
if (hours < 36) return `Updated ${hours}h ago`;
|
|
3583
|
+
return `Updated ${formatClaudeUsageResetClock(fetchedAt)}`;
|
|
3584
|
+
}
|
|
3585
|
+
function formatClaudeExtraUsageDetail(extra) {
|
|
3586
|
+
if (!extra.enabled) return "Extra usage off";
|
|
3587
|
+
const bits = ["Extra usage on"];
|
|
3588
|
+
if (extra.usedCredits != null && extra.monthlyLimit != null) {
|
|
3589
|
+
bits.push(`${extra.usedCredits} / ${extra.monthlyLimit} credits this month`);
|
|
3590
|
+
} else if (extra.usedCredits != null) {
|
|
3591
|
+
bits.push(`${extra.usedCredits} credits used`);
|
|
3592
|
+
}
|
|
3593
|
+
if (extra.usedPercent != null) {
|
|
3594
|
+
bits.push(`${Math.round(extra.usedPercent)}% of extra pool`);
|
|
3595
|
+
}
|
|
3596
|
+
return bits.join(" \xB7 ");
|
|
3597
|
+
}
|
|
3598
|
+
function formatClaudeUsageWindowLine(window, now = /* @__PURE__ */ new Date()) {
|
|
3599
|
+
const reset = formatClaudeUsageReset(window.resetsAt, now);
|
|
3600
|
+
const clock = formatClaudeUsageResetClock(window.resetsAt);
|
|
3601
|
+
const left = `${Math.round(window.remainingPercent)}% left`;
|
|
3602
|
+
const used = `${Math.round(window.usedPercent)}% used`;
|
|
3603
|
+
const resetBit = reset ? clock && !reset.includes(clock) ? `${reset} (${clock})` : reset : "";
|
|
3604
|
+
return resetBit ? `${window.label} \u2014 ${window.detail}. ${left} \xB7 ${used} \xB7 ${resetBit}` : `${window.label} \u2014 ${window.detail}. ${left} \xB7 ${used}`;
|
|
3605
|
+
}
|
|
3606
|
+
function formatClaudeUsageTooltip(usage, now = /* @__PURE__ */ new Date()) {
|
|
3607
|
+
const lines = [
|
|
3608
|
+
"Claude Code plan",
|
|
3609
|
+
...usage.windows.map((w) => formatClaudeUsageWindowLine(w, now))
|
|
3610
|
+
];
|
|
3611
|
+
if (usage.extraUsage) {
|
|
3612
|
+
lines.push(formatClaudeExtraUsageDetail(usage.extraUsage));
|
|
3613
|
+
}
|
|
3614
|
+
const fetched = formatClaudeUsageFetchedAt(usage.fetchedAt, now);
|
|
3615
|
+
if (fetched) lines.push(fetched);
|
|
3616
|
+
return lines.join("\n");
|
|
3617
|
+
}
|
|
3618
|
+
function formatClaudeUsageCompact(window) {
|
|
3619
|
+
return `${window.shortLabel} ${Math.round(window.remainingPercent)}%`;
|
|
3620
|
+
}
|
|
3621
|
+
function claudeUsageWindowOverLimit(window) {
|
|
3622
|
+
return window.remainingPercent <= 0 || window.usedPercent >= 100;
|
|
3623
|
+
}
|
|
3624
|
+
function claudeUsageOverLimitWindows(usage) {
|
|
3625
|
+
if (!usage) return [];
|
|
3626
|
+
return usage.windows.filter(claudeUsageWindowOverLimit);
|
|
3627
|
+
}
|
|
3628
|
+
function formatOverLimitWindowList(windows, now) {
|
|
3629
|
+
const parts = windows.map((w) => {
|
|
3630
|
+
const reset = formatClaudeUsageReset(w.resetsAt, now);
|
|
3631
|
+
return reset ? `${w.label} (${reset})` : w.label;
|
|
3632
|
+
});
|
|
3633
|
+
return {
|
|
3634
|
+
list: parts.join(", "),
|
|
3635
|
+
verb: windows.length === 1 ? "is" : "are"
|
|
3636
|
+
};
|
|
3637
|
+
}
|
|
3638
|
+
function formatClaudeUsageOverLimitConfirm(windows, now = /* @__PURE__ */ new Date()) {
|
|
3639
|
+
if (windows.length === 0) return "";
|
|
3640
|
+
const { list, verb } = formatOverLimitWindowList(windows, now);
|
|
3641
|
+
return `Claude Code ${list} ${verb} at or over the plan limit. Send this message anyway?`;
|
|
3642
|
+
}
|
|
3643
|
+
function formatClaudeUsageOverLimitWait(windows, now = /* @__PURE__ */ new Date()) {
|
|
3644
|
+
if (windows.length === 0) return "";
|
|
3645
|
+
const { list, verb } = formatOverLimitWindowList(windows, now);
|
|
3646
|
+
return `Claude Code ${list} ${verb} at or over the plan limit. Sending is paused until the window resets.`;
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3649
|
+
// src/agents/claude-usage-client.ts
|
|
3650
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4 } from "fs";
|
|
3651
|
+
import { homedir as homedir4 } from "os";
|
|
3652
|
+
import { join as join6 } from "path";
|
|
3653
|
+
var CLAUDE_OAUTH_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
3654
|
+
var CLAUDE_USAGE_TTL_MS = 9e4;
|
|
3655
|
+
var CLAUDE_USAGE_ERROR_TTL_MS = 5 * 6e4;
|
|
3656
|
+
var CLAUDE_USAGE_STALE_OK_MS = 30 * 6e4;
|
|
3657
|
+
var KEYCHAIN_SERVICES = ["Claude Code-credentials", "Claude Code"];
|
|
3658
|
+
var cache = null;
|
|
3659
|
+
var errorUntil = 0;
|
|
3660
|
+
var inflight = null;
|
|
3661
|
+
var lastGood = null;
|
|
3662
|
+
var claudeVersion = null;
|
|
3663
|
+
function accessTokenFromCredentialsJson(raw) {
|
|
3664
|
+
const trimmed = raw.trim();
|
|
3665
|
+
if (!trimmed) return null;
|
|
3666
|
+
if (trimmed.startsWith("sk-ant-")) {
|
|
3667
|
+
const token = trimmed.split(/\s+/)[0];
|
|
3668
|
+
return token || null;
|
|
3669
|
+
}
|
|
3670
|
+
try {
|
|
3671
|
+
const parsed = JSON.parse(trimmed);
|
|
3672
|
+
const oauth = parsed.claudeAiOauth && typeof parsed.claudeAiOauth === "object" ? parsed.claudeAiOauth : parsed;
|
|
3673
|
+
const token = oauth.accessToken ?? oauth.access_token;
|
|
3674
|
+
return typeof token === "string" && token.trim() ? token.trim() : null;
|
|
3675
|
+
} catch {
|
|
3676
|
+
return null;
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
function claudeCredentialsPath() {
|
|
3680
|
+
const root = process.env.CLAUDE_CONFIG_DIR?.trim() || join6(homedir4(), ".claude");
|
|
3681
|
+
return join6(root, ".credentials.json");
|
|
3682
|
+
}
|
|
3683
|
+
async function readFileAccessToken() {
|
|
3684
|
+
const path = claudeCredentialsPath();
|
|
3685
|
+
if (!existsSync9(path)) return null;
|
|
3686
|
+
try {
|
|
3687
|
+
return accessTokenFromCredentialsJson(readFileSync4(path, "utf8"));
|
|
3688
|
+
} catch {
|
|
3689
|
+
return null;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
async function readKeychainAccessToken() {
|
|
3693
|
+
if (process.platform !== "darwin") return null;
|
|
3694
|
+
for (const service of KEYCHAIN_SERVICES) {
|
|
3695
|
+
const result = await run("security", ["find-generic-password", "-s", service, "-w"], {
|
|
3696
|
+
reject: false,
|
|
3697
|
+
timeoutMs: 4e3
|
|
3698
|
+
});
|
|
3699
|
+
if (result.exitCode !== 0 || !result.stdout.trim()) continue;
|
|
3700
|
+
const token = accessTokenFromCredentialsJson(result.stdout);
|
|
3701
|
+
if (token) return token;
|
|
3702
|
+
}
|
|
3703
|
+
return null;
|
|
3704
|
+
}
|
|
3705
|
+
async function readClaudeAccessToken() {
|
|
3706
|
+
const envToken = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
|
|
3707
|
+
if (envToken) return envToken;
|
|
3708
|
+
const fromFile = await readFileAccessToken();
|
|
3709
|
+
if (fromFile) return fromFile;
|
|
3710
|
+
return readKeychainAccessToken();
|
|
3711
|
+
}
|
|
3712
|
+
async function resolveClaudeUserAgent() {
|
|
3713
|
+
if (claudeVersion) return `claude-code/${claudeVersion}`;
|
|
3714
|
+
try {
|
|
3715
|
+
const claude = resolveClaudeExecutable();
|
|
3716
|
+
const result = await run(claude, ["--version"], { reject: false, timeoutMs: 4e3 });
|
|
3717
|
+
const match = `${result.stdout}
|
|
3718
|
+
${result.stderr}`.match(/(\d+\.\d+\.\d+)/);
|
|
3719
|
+
claudeVersion = match?.[1] ?? "2.1.80";
|
|
3720
|
+
} catch {
|
|
3721
|
+
claudeVersion = "2.1.80";
|
|
3722
|
+
}
|
|
3723
|
+
return `claude-code/${claudeVersion}`;
|
|
3724
|
+
}
|
|
3725
|
+
function staleOk(now) {
|
|
3726
|
+
if (!lastGood) return null;
|
|
3727
|
+
if (now - lastGood.at > CLAUDE_USAGE_STALE_OK_MS) return null;
|
|
3728
|
+
return lastGood.value;
|
|
3729
|
+
}
|
|
3730
|
+
async function getClaudePlanUsage(opts = {}) {
|
|
3731
|
+
const now = opts.now ?? Date.now();
|
|
3732
|
+
if (!opts.force) {
|
|
3733
|
+
if (cache && now - cache.at < CLAUDE_USAGE_TTL_MS) return cache.value;
|
|
3734
|
+
if (now < errorUntil) return staleOk(now);
|
|
3735
|
+
}
|
|
3736
|
+
if (inflight) return inflight;
|
|
3737
|
+
inflight = (async () => {
|
|
3738
|
+
try {
|
|
3739
|
+
const token = await (opts.readAccessToken ?? readClaudeAccessToken)();
|
|
3740
|
+
if (!token) {
|
|
3741
|
+
cache = { at: now, value: null };
|
|
3742
|
+
return null;
|
|
3743
|
+
}
|
|
3744
|
+
const fetchFn = opts.fetch ?? httpFetch;
|
|
3745
|
+
const userAgent = opts.userAgent ?? await resolveClaudeUserAgent();
|
|
3746
|
+
const ac = new AbortController();
|
|
3747
|
+
const timer = setTimeout(() => ac.abort(), 8e3);
|
|
3748
|
+
let res;
|
|
3749
|
+
try {
|
|
3750
|
+
res = await fetchFn(CLAUDE_OAUTH_USAGE_URL, {
|
|
3751
|
+
headers: {
|
|
3752
|
+
Authorization: `Bearer ${token}`,
|
|
3753
|
+
"anthropic-beta": "oauth-2025-04-20",
|
|
3754
|
+
"User-Agent": userAgent
|
|
3755
|
+
},
|
|
3756
|
+
signal: ac.signal
|
|
3757
|
+
});
|
|
3758
|
+
} finally {
|
|
3759
|
+
clearTimeout(timer);
|
|
3760
|
+
}
|
|
3761
|
+
if (res.status === 401 || res.status === 403) {
|
|
3762
|
+
cache = { at: now, value: null };
|
|
3763
|
+
return null;
|
|
3764
|
+
}
|
|
3765
|
+
if (!res.ok) {
|
|
3766
|
+
errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
|
|
3767
|
+
return staleOk(now);
|
|
3768
|
+
}
|
|
3769
|
+
const usage = parseClaudeUsagePayload(await res.json(), new Date(now).toISOString());
|
|
3770
|
+
cache = { at: now, value: usage };
|
|
3771
|
+
if (usage) lastGood = { at: now, value: usage };
|
|
3772
|
+
return usage;
|
|
3773
|
+
} catch {
|
|
3774
|
+
errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
|
|
3775
|
+
return staleOk(now);
|
|
3776
|
+
} finally {
|
|
3777
|
+
inflight = null;
|
|
3778
|
+
}
|
|
3779
|
+
})();
|
|
3780
|
+
return inflight;
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3430
3783
|
// src/agents/install.ts
|
|
3431
3784
|
var SETUP = {
|
|
3432
3785
|
claude: {
|
|
@@ -3758,6 +4111,18 @@ export {
|
|
|
3758
4111
|
isSessionQuotaLimit,
|
|
3759
4112
|
parseSessionQuotaResetAt,
|
|
3760
4113
|
resolveQuotaFallbackAgent,
|
|
4114
|
+
parseClaudeUsagePayload,
|
|
4115
|
+
hottestClaudeWindow,
|
|
4116
|
+
formatClaudeUsageReset,
|
|
4117
|
+
formatClaudeUsageResetClock,
|
|
4118
|
+
formatClaudeUsageFetchedAt,
|
|
4119
|
+
formatClaudeExtraUsageDetail,
|
|
4120
|
+
formatClaudeUsageTooltip,
|
|
4121
|
+
formatClaudeUsageCompact,
|
|
4122
|
+
claudeUsageOverLimitWindows,
|
|
4123
|
+
formatClaudeUsageOverLimitConfirm,
|
|
4124
|
+
formatClaudeUsageOverLimitWait,
|
|
4125
|
+
getClaudePlanUsage,
|
|
3761
4126
|
getAgentSetupInfo,
|
|
3762
4127
|
listAgentSetupInfo,
|
|
3763
4128
|
resolveLoginCommand,
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
enrichWorkspacesWithGithub,
|
|
8
8
|
ensureGlobalCoordinatorCwd,
|
|
9
9
|
formatWorkspaceInventory
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-PDMNYCPL.js";
|
|
11
|
+
import "./chunk-OSPE25A7.js";
|
|
12
12
|
import "./chunk-6K64FJDD.js";
|
|
13
13
|
import "./chunk-QQKDGPUI.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-CXFW5LIH.js";
|
|
15
15
|
import "./chunk-4TR3HZFT.js";
|
|
16
16
|
import "./chunk-WDRMZKVB.js";
|
|
17
17
|
import "./chunk-JT7R45JB.js";
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
enrichWorkspacesWithGithub,
|
|
10
10
|
ensureGlobalCoordinatorCwd,
|
|
11
11
|
formatWorkspaceInventory
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-EWDE54OI.js";
|
|
13
|
+
import "./chunk-NXM45OS3.js";
|
|
14
14
|
import "./chunk-D6JWYJ4P.js";
|
|
15
15
|
import "./chunk-CJFBSQIB.js";
|
|
16
16
|
import "./chunk-SYFVUF2C.js";
|
|
17
17
|
import "./chunk-FNQNJOHY.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-ISV5IFH3.js";
|
|
19
19
|
import "./chunk-NSTQ6QKD.js";
|
|
20
20
|
import "./chunk-KGZBYWZ3.js";
|
|
21
21
|
import "./chunk-EQNRWDLN.js";
|
|
@@ -17,13 +17,13 @@ import {
|
|
|
17
17
|
orchestratorSessionPoisonedByBuiltins,
|
|
18
18
|
slackCoordinatorSourceRef,
|
|
19
19
|
takenTeamSlugsForOrchestration
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-EWDE54OI.js";
|
|
21
|
+
import "./chunk-NXM45OS3.js";
|
|
22
22
|
import "./chunk-D6JWYJ4P.js";
|
|
23
23
|
import "./chunk-CJFBSQIB.js";
|
|
24
24
|
import "./chunk-SYFVUF2C.js";
|
|
25
25
|
import "./chunk-FNQNJOHY.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-ISV5IFH3.js";
|
|
27
27
|
import "./chunk-NSTQ6QKD.js";
|
|
28
28
|
import "./chunk-KGZBYWZ3.js";
|
|
29
29
|
import {
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
orchestratorSessionPoisonedByBuiltins,
|
|
16
16
|
slackCoordinatorSourceRef,
|
|
17
17
|
takenTeamSlugsForOrchestration
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-PDMNYCPL.js";
|
|
19
|
+
import "./chunk-OSPE25A7.js";
|
|
20
20
|
import "./chunk-6K64FJDD.js";
|
|
21
21
|
import "./chunk-QQKDGPUI.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-CXFW5LIH.js";
|
|
23
23
|
import "./chunk-4TR3HZFT.js";
|
|
24
24
|
import "./chunk-WDRMZKVB.js";
|
|
25
25
|
import "./chunk-JT7R45JB.js";
|