claude-use 11.11.0 → 11.13.0
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/README.md +1 -0
- package/dist/cli.cjs +566 -29
- package/dist/index.cjs +9 -2
- package/dist/index.mjs +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,6 +159,7 @@ agent-shim frontdoor rc mcp-authenticate --session <cse_id> --server <name> --re
|
|
|
159
159
|
agent-shim frontdoor rc mcp-oauth-callback-url --session <cse_id> --server <name> --callback-url <url> [--json]
|
|
160
160
|
agent-shim frontdoor rc watch [<cse_id>] [--json]
|
|
161
161
|
agent-shim frontdoor rc selfhost mint <identity> [--force] [--json]
|
|
162
|
+
agent-shim statusline # serve as a statusline entrypoint: enrich the client's stdin payload with the identity's live provider, account and usage windows, then delegate to $AGENT_SHIM_STATUSLINE_CMD or render the built-in line
|
|
162
163
|
agent-shim usage [--identity <name>] [--provider <name>] [--since <duration>] [--refresh] [--json]
|
|
163
164
|
agent-shim session list [--identity <name>] [--all] [--json] # sessions that spawned agents or ran workflows, from the transcripts on disk
|
|
164
165
|
agent-shim session show <session> [--identity <name>] [--json] # one session's subagents, forks, workflow agents, tasks and workflow runs
|
package/dist/cli.cjs
CHANGED
|
@@ -34093,7 +34093,7 @@ var init_package = __esm({
|
|
|
34093
34093
|
"package.json"() {
|
|
34094
34094
|
package_default = {
|
|
34095
34095
|
name: "claude-use",
|
|
34096
|
-
version: "11.
|
|
34096
|
+
version: "11.13.0",
|
|
34097
34097
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
34098
34098
|
license: "MIT",
|
|
34099
34099
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -63774,10 +63774,10 @@ function resolveLaunch(params) {
|
|
|
63774
63774
|
environment
|
|
63775
63775
|
};
|
|
63776
63776
|
}
|
|
63777
|
-
function runLaunchPlan(plan,
|
|
63777
|
+
function runLaunchPlan(plan, spawn7) {
|
|
63778
63778
|
try {
|
|
63779
63779
|
plan.markChildStarted();
|
|
63780
|
-
const result =
|
|
63780
|
+
const result = spawn7.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
|
|
63781
63781
|
if (result.error !== void 0) {
|
|
63782
63782
|
throw result.error;
|
|
63783
63783
|
}
|
|
@@ -64152,7 +64152,7 @@ function quotaFreshnessMs(quota) {
|
|
|
64152
64152
|
const lengths = quota.windows.flatMap((window) => window.periodMs === void 0 ? [] : [window.periodMs]);
|
|
64153
64153
|
return lengths.length === 0 ? Number.POSITIVE_INFINITY : Math.min(...lengths) / PERCENT3;
|
|
64154
64154
|
}
|
|
64155
|
-
var ProviderQuotaError, MS_PER_SECOND6, SECONDS_PER_HOUR, HOURS_PER_DAY3, DAYS_PER_MONTH, PERCENT3, HTTP_OK, ZAI_SOURCE, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZAI_MEASURES, ZaiLimitSchema, ZaiResponseSchema, zaiQuotaAdapter, OPENROUTER_SOURCE, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, HTTP_FORBIDDEN, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, openRouterQuotaAdapter, ANTIGRAVITY_SOURCE, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, GOOGLE_TOKENINFO_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, ANTIGRAVITY_WINDOW_MS, antigravityQuotaAdapter, PROVIDER_QUOTA_ADAPTERS;
|
|
64155
|
+
var ProviderQuotaError, MS_PER_SECOND6, SECONDS_PER_HOUR, HOURS_PER_DAY3, DAYS_PER_MONTH, PERCENT3, HTTP_OK, ZAI_SOURCE, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZAI_MEASURES, ZaiLimitSchema, ZaiResponseSchema, zaiQuotaAdapter, OPENROUTER_SOURCE, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, HTTP_FORBIDDEN, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, openRouterQuotaAdapter, ANTIGRAVITY_SOURCE, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, GOOGLE_TOKENINFO_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema, ANTIGRAVITY_WINDOW_MS, antigravityQuotaAdapter, PROVIDER_QUOTA_ADAPTERS;
|
|
64156
64156
|
var init_providerQuota = __esm({
|
|
64157
64157
|
"src/usage/providerQuota.ts"() {
|
|
64158
64158
|
"use strict";
|
|
@@ -64274,6 +64274,7 @@ var init_providerQuota = __esm({
|
|
|
64274
64274
|
ANTIGRAVITY_SOURCE = "Cloud Code";
|
|
64275
64275
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
64276
64276
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
64277
|
+
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
64277
64278
|
GOOGLE_TOKENINFO_URL = "https://oauth2.googleapis.com/tokeninfo";
|
|
64278
64279
|
FIVE_HOURS2 = 5;
|
|
64279
64280
|
DAYS_PER_WEEK = 7;
|
|
@@ -64289,6 +64290,12 @@ var init_providerQuota = __esm({
|
|
|
64289
64290
|
email: external_exports.string().optional(),
|
|
64290
64291
|
sub: external_exports.string().optional()
|
|
64291
64292
|
});
|
|
64293
|
+
AntigravityUserSchema = external_exports.object({
|
|
64294
|
+
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
64295
|
+
currentTier: external_exports.object({ name: external_exports.string().optional(), id: external_exports.string().optional() }).optional(),
|
|
64296
|
+
/** The account's paid subscription; absent when the account has none. */
|
|
64297
|
+
paidTier: external_exports.object({ name: external_exports.string().optional(), id: external_exports.string().optional() }).optional()
|
|
64298
|
+
});
|
|
64292
64299
|
ANTIGRAVITY_WINDOW_MS = { "gemini-5h": FIVE_HOURS_MS, "3p-5h": FIVE_HOURS_MS, "gemini-weekly": WEEK_MS, "3p-weekly": WEEK_MS };
|
|
64293
64300
|
antigravityQuotaAdapter = {
|
|
64294
64301
|
source: ANTIGRAVITY_SOURCE,
|
|
@@ -64320,9 +64327,20 @@ var init_providerQuota = __esm({
|
|
|
64320
64327
|
} catch {
|
|
64321
64328
|
}
|
|
64322
64329
|
}
|
|
64330
|
+
let level;
|
|
64331
|
+
const userResponse = await http8(ANTIGRAVITY_USER_URL, headers, signal, { method: "POST", body: "{}" });
|
|
64332
|
+
if (userResponse.status === HTTP_OK) {
|
|
64333
|
+
try {
|
|
64334
|
+
const tiers = AntigravityUserSchema.parse(JSON.parse(userResponse.text));
|
|
64335
|
+
const tier = tiers.paidTier ?? tiers.currentTier;
|
|
64336
|
+
level = tier?.name ?? tier?.id;
|
|
64337
|
+
} catch {
|
|
64338
|
+
}
|
|
64339
|
+
}
|
|
64323
64340
|
return ProviderQuotaSchema.parse({
|
|
64324
64341
|
observedAt: new Date(nowMs).toISOString(),
|
|
64325
64342
|
source: ANTIGRAVITY_SOURCE,
|
|
64343
|
+
...level === void 0 ? {} : { level },
|
|
64326
64344
|
...account === void 0 ? {} : { account },
|
|
64327
64345
|
windows: parsed.data.groups.flatMap(
|
|
64328
64346
|
(group) => group.buckets.map((bucket) => ({
|
|
@@ -126844,7 +126862,7 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
126844
126862
|
latest.set(snapshot.identity, snapshot);
|
|
126845
126863
|
});
|
|
126846
126864
|
const announced = /* @__PURE__ */ new Set();
|
|
126847
|
-
const
|
|
126865
|
+
const windowsOf2 = (snapshot) => {
|
|
126848
126866
|
const views = [];
|
|
126849
126867
|
for (const provider of Object.keys(snapshot.providers).sort()) {
|
|
126850
126868
|
const unified = snapshot.providers[provider]?.rateLimit?.unified;
|
|
@@ -126867,7 +126885,7 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
126867
126885
|
if (snapshot === void 0) {
|
|
126868
126886
|
continue;
|
|
126869
126887
|
}
|
|
126870
|
-
for (const { provider, view } of
|
|
126888
|
+
for (const { provider, view } of windowsOf2(snapshot)) {
|
|
126871
126889
|
if (view.utilization >= 1 || view.resetsAtMs <= now || view.resetsAtMs - now >= view.spanMs * QUOTA_EXPIRING_WINDOW_FRACTION) {
|
|
126872
126890
|
continue;
|
|
126873
126891
|
}
|
|
@@ -127792,11 +127810,13 @@ function resolveAntigravityConfig(config2) {
|
|
|
127792
127810
|
}
|
|
127793
127811
|
};
|
|
127794
127812
|
}
|
|
127813
|
+
var CONTEXT_MARKER_1M = "[1m]";
|
|
127795
127814
|
function mapModel2(requested, config2) {
|
|
127796
|
-
|
|
127797
|
-
|
|
127815
|
+
const stripped = requested.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? requested.slice(0, -CONTEXT_MARKER_1M.length) : requested;
|
|
127816
|
+
if (stripped.startsWith("gemini-") || stripped.startsWith("antigravity-")) {
|
|
127817
|
+
return stripped;
|
|
127798
127818
|
}
|
|
127799
|
-
const lower =
|
|
127819
|
+
const lower = stripped.toLowerCase();
|
|
127800
127820
|
const tier = ANTIGRAVITY_TIERS.find((candidate) => lower.includes(candidate));
|
|
127801
127821
|
return tier === void 0 ? config2.defaultModel : config2.models[tier];
|
|
127802
127822
|
}
|
|
@@ -128054,8 +128074,8 @@ function translateRequest2(request7, config2) {
|
|
|
128054
128074
|
init_cloudUpstream();
|
|
128055
128075
|
var MS_PER_SECOND8 = 1e3;
|
|
128056
128076
|
var DEFAULT_RETRY_AFTER_SECONDS = 60;
|
|
128057
|
-
var
|
|
128058
|
-
var
|
|
128077
|
+
var FRACTION_DIGITS = 3;
|
|
128078
|
+
var EXHAUSTED_FRACTION = "1.000";
|
|
128059
128079
|
var GEMINI_5H_KEYS = ["gemini-5h", "gemini_5h", "gemini"];
|
|
128060
128080
|
var GEMINI_WEEKLY_KEYS = ["gemini-weekly", "gemini_weekly"];
|
|
128061
128081
|
var THIRD_PARTY_5H_KEYS = ["3p-5h", "claude-5h", "3p_5h", "claude_5h", "claude"];
|
|
@@ -128075,7 +128095,7 @@ function calculateUtilization(remainingFraction) {
|
|
|
128075
128095
|
}
|
|
128076
128096
|
const clampedRem = Math.max(0, Math.min(1, remainingFraction));
|
|
128077
128097
|
const used = Math.max(0, 1 - clampedRem);
|
|
128078
|
-
return
|
|
128098
|
+
return used.toFixed(FRACTION_DIGITS);
|
|
128079
128099
|
}
|
|
128080
128100
|
function calculateResetTimestamp(nowSec, resetInSeconds) {
|
|
128081
128101
|
if (resetInSeconds === void 0 || !Number.isFinite(resetInSeconds) || resetInSeconds < 0) {
|
|
@@ -128101,9 +128121,6 @@ function parseRetryAfterSeconds(raw, defaultSeconds = DEFAULT_RETRY_AFTER_SECOND
|
|
|
128101
128121
|
function unifiedAntigravityQuotaHeaders(params) {
|
|
128102
128122
|
const rejected = params.rejected === true;
|
|
128103
128123
|
const nowSec = Math.floor(params.nowMs / MS_PER_SECOND8);
|
|
128104
|
-
const headers = {
|
|
128105
|
-
"anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed"
|
|
128106
|
-
};
|
|
128107
128124
|
const modelLower = (params.model ?? "").toLowerCase();
|
|
128108
128125
|
const isGemini = modelLower.includes("gemini");
|
|
128109
128126
|
const fiveHourKeys = isGemini ? GEMINI_5H_KEYS : THIRD_PARTY_5H_KEYS;
|
|
@@ -128115,6 +128132,12 @@ function unifiedAntigravityQuotaHeaders(params) {
|
|
|
128115
128132
|
const reset5h = calculateResetTimestamp(nowSec, b5h?.reset_in_seconds);
|
|
128116
128133
|
const used7d = calculateUtilization(bWk?.remaining_fraction);
|
|
128117
128134
|
const reset7d = calculateResetTimestamp(nowSec, bWk?.reset_in_seconds);
|
|
128135
|
+
if (!rejected && used5h === void 0 && reset5h === void 0 && used7d === void 0 && reset7d === void 0) {
|
|
128136
|
+
return {};
|
|
128137
|
+
}
|
|
128138
|
+
const headers = {
|
|
128139
|
+
"anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed"
|
|
128140
|
+
};
|
|
128118
128141
|
let earliestResetSec;
|
|
128119
128142
|
if (used5h !== void 0 && reset5h !== void 0) {
|
|
128120
128143
|
headers["anthropic-ratelimit-unified-5h-utilization"] = used5h;
|
|
@@ -128131,11 +128154,11 @@ function unifiedAntigravityQuotaHeaders(params) {
|
|
|
128131
128154
|
const retrySec = params.retryAfterSeconds ?? DEFAULT_RETRY_AFTER_SECONDS;
|
|
128132
128155
|
const fallbackReset = String(nowSec + retrySec);
|
|
128133
128156
|
if (headers["anthropic-ratelimit-unified-5h-utilization"] === void 0) {
|
|
128134
|
-
headers["anthropic-ratelimit-unified-5h-utilization"] =
|
|
128157
|
+
headers["anthropic-ratelimit-unified-5h-utilization"] = EXHAUSTED_FRACTION;
|
|
128135
128158
|
headers["anthropic-ratelimit-unified-5h-reset"] = fallbackReset;
|
|
128136
128159
|
}
|
|
128137
128160
|
if (headers["anthropic-ratelimit-unified-7d-utilization"] === void 0) {
|
|
128138
|
-
headers["anthropic-ratelimit-unified-7d-utilization"] =
|
|
128161
|
+
headers["anthropic-ratelimit-unified-7d-utilization"] = EXHAUSTED_FRACTION;
|
|
128139
128162
|
headers["anthropic-ratelimit-unified-7d-reset"] = fallbackReset;
|
|
128140
128163
|
}
|
|
128141
128164
|
earliestResetSec = earliestResetSec === void 0 ? nowSec + retrySec : Math.min(earliestResetSec, nowSec + retrySec);
|
|
@@ -128370,10 +128393,10 @@ function quotaHeaders(upstream) {
|
|
|
128370
128393
|
}
|
|
128371
128394
|
return headers;
|
|
128372
128395
|
}
|
|
128373
|
-
var
|
|
128396
|
+
var EXHAUSTED_PERCENT = "100";
|
|
128374
128397
|
function unifiedQuotaHeaders(upstream, rejected, quotaError) {
|
|
128375
128398
|
const headers = { "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed" };
|
|
128376
|
-
const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ?
|
|
128399
|
+
const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ? EXHAUSTED_PERCENT : null);
|
|
128377
128400
|
const reset7d = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
|
|
128378
128401
|
if (used7d !== null && reset7d !== null) {
|
|
128379
128402
|
headers["anthropic-ratelimit-unified-7d-utilization"] = used7d;
|
|
@@ -128396,7 +128419,7 @@ function unifiedQuotaHeaders(upstream, rejected, quotaError) {
|
|
|
128396
128419
|
}
|
|
128397
128420
|
var MS_PER_SECOND9 = 1e3;
|
|
128398
128421
|
function buildUsageSnapshot(upstream, quotaError, nowMs) {
|
|
128399
|
-
const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null :
|
|
128422
|
+
const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null : EXHAUSTED_PERCENT);
|
|
128400
128423
|
const reset7 = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
|
|
128401
128424
|
const sevenDay = used7 !== null && reset7 !== null ? { used_percentage: Number(used7), resets_at: new Date(Number(reset7) * MS_PER_SECOND9).toISOString() } : void 0;
|
|
128402
128425
|
let fiveHour;
|
|
@@ -128888,10 +128911,12 @@ function createAntigravityRelay(params) {
|
|
|
128888
128911
|
frames.length = 0;
|
|
128889
128912
|
ensureStarted();
|
|
128890
128913
|
if (chunk.usageMetadata !== void 0) {
|
|
128914
|
+
const cached2 = chunk.usageMetadata.cachedContentTokenCount ?? 0;
|
|
128915
|
+
const promptTotal = chunk.usageMetadata.promptTokenCount ?? usage.input_tokens + cached2;
|
|
128891
128916
|
usage = {
|
|
128892
|
-
input_tokens:
|
|
128917
|
+
input_tokens: Math.max(0, promptTotal - cached2),
|
|
128893
128918
|
cache_creation_input_tokens: 0,
|
|
128894
|
-
cache_read_input_tokens:
|
|
128919
|
+
cache_read_input_tokens: cached2,
|
|
128895
128920
|
output_tokens: chunk.usageMetadata.candidatesTokenCount ?? usage.output_tokens
|
|
128896
128921
|
};
|
|
128897
128922
|
}
|
|
@@ -133242,6 +133267,517 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
133242
133267
|
});
|
|
133243
133268
|
}
|
|
133244
133269
|
|
|
133270
|
+
// src/statusline/commands.ts
|
|
133271
|
+
var import_node_child_process7 = require("node:child_process");
|
|
133272
|
+
init_commandDeps();
|
|
133273
|
+
init_realPorts();
|
|
133274
|
+
init_account();
|
|
133275
|
+
init_read();
|
|
133276
|
+
|
|
133277
|
+
// src/statusline/enrich.ts
|
|
133278
|
+
var FULL_PERCENT = 100;
|
|
133279
|
+
function identityOf(env) {
|
|
133280
|
+
const headers = env.ANTHROPIC_CUSTOM_HEADERS;
|
|
133281
|
+
if (headers !== void 0) {
|
|
133282
|
+
const match = /x-agent-shim-identity:\s*([A-Za-z0-9@._-]+)/i.exec(headers);
|
|
133283
|
+
if (match !== null) {
|
|
133284
|
+
return match[1];
|
|
133285
|
+
}
|
|
133286
|
+
}
|
|
133287
|
+
const configDir = env.CLAUDE_CONFIG_DIR;
|
|
133288
|
+
if (configDir !== void 0) {
|
|
133289
|
+
const slash = configDir.lastIndexOf("/");
|
|
133290
|
+
const name = slash === -1 ? "" : configDir.slice(slash + 1);
|
|
133291
|
+
const parent = slash === -1 ? "" : configDir.slice(0, slash);
|
|
133292
|
+
const parentSlash = parent.lastIndexOf("/");
|
|
133293
|
+
if (parentSlash !== -1 && parent.slice(parentSlash + 1) === "identities" && name !== "") {
|
|
133294
|
+
return name;
|
|
133295
|
+
}
|
|
133296
|
+
}
|
|
133297
|
+
return void 0;
|
|
133298
|
+
}
|
|
133299
|
+
function windowsOf(states) {
|
|
133300
|
+
let fiveHourUsed;
|
|
133301
|
+
let fiveHourResetAt;
|
|
133302
|
+
let sevenDayUsed;
|
|
133303
|
+
let sevenDayResetAt;
|
|
133304
|
+
for (const state of states) {
|
|
133305
|
+
const unified = state.rateLimit?.unified;
|
|
133306
|
+
if (unified === void 0) {
|
|
133307
|
+
continue;
|
|
133308
|
+
}
|
|
133309
|
+
const fiveWindow = unified.fiveHour === void 0 ? void 0 : unified.fiveHour.utilization;
|
|
133310
|
+
const five = typeof fiveWindow === "number" && Number.isFinite(fiveWindow) ? Math.round(Math.min(1, Math.max(0, fiveWindow)) * FULL_PERCENT) : void 0;
|
|
133311
|
+
if (five !== void 0 && (fiveHourUsed === void 0 || five > fiveHourUsed)) {
|
|
133312
|
+
fiveHourUsed = five;
|
|
133313
|
+
fiveHourResetAt = unified.fiveHour?.resetsAt;
|
|
133314
|
+
}
|
|
133315
|
+
const sevenWindow = unified.sevenDay === void 0 ? void 0 : unified.sevenDay.utilization;
|
|
133316
|
+
const seven = typeof sevenWindow === "number" && Number.isFinite(sevenWindow) ? Math.round(Math.min(1, Math.max(0, sevenWindow)) * FULL_PERCENT) : void 0;
|
|
133317
|
+
if (seven !== void 0 && (sevenDayUsed === void 0 || seven > sevenDayUsed)) {
|
|
133318
|
+
sevenDayUsed = seven;
|
|
133319
|
+
sevenDayResetAt = unified.sevenDay?.resetsAt;
|
|
133320
|
+
}
|
|
133321
|
+
}
|
|
133322
|
+
return { fiveHourUsed, fiveHourResetAt, sevenDayUsed, sevenDayResetAt };
|
|
133323
|
+
}
|
|
133324
|
+
function enrichStatuslinePayload(params) {
|
|
133325
|
+
const identity = identityOf(params.env);
|
|
133326
|
+
let summary = {
|
|
133327
|
+
identity,
|
|
133328
|
+
provider: params.env.AGENT_SHIM_PROVIDER === void 0 || params.env.AGENT_SHIM_PROVIDER === "" ? void 0 : params.env.AGENT_SHIM_PROVIDER,
|
|
133329
|
+
providerAccountEmail: void 0,
|
|
133330
|
+
providerAccountSub: void 0,
|
|
133331
|
+
providerPlan: void 0,
|
|
133332
|
+
loginAccountEmail: params.account?.emailAddress,
|
|
133333
|
+
loginRateLimitTier: params.account?.userRateLimitTier ?? params.account?.organizationRateLimitTier,
|
|
133334
|
+
loginOrganizationName: params.account?.organizationName,
|
|
133335
|
+
loginOrganizationType: params.account?.organizationType,
|
|
133336
|
+
loginSeatTier: params.account?.seatTier === "none" ? void 0 : params.account?.seatTier,
|
|
133337
|
+
fiveHourUsed: void 0,
|
|
133338
|
+
fiveHourResetAt: void 0,
|
|
133339
|
+
sevenDayUsed: void 0,
|
|
133340
|
+
sevenDayResetAt: void 0
|
|
133341
|
+
};
|
|
133342
|
+
if (params.snapshot !== void 0) {
|
|
133343
|
+
const scopedName = providerScopedState(params.snapshot, params.env.AGENT_SHIM_PROVIDER);
|
|
133344
|
+
const scopedState = scopedName === void 0 ? void 0 : params.snapshot.providers[scopedName];
|
|
133345
|
+
const states = scopedState === void 0 ? Object.values(params.snapshot.providers) : [scopedState];
|
|
133346
|
+
let email3;
|
|
133347
|
+
let sub;
|
|
133348
|
+
let plan;
|
|
133349
|
+
for (const state of states) {
|
|
133350
|
+
const account = state.quota?.account;
|
|
133351
|
+
const candidateEmail = account?.email;
|
|
133352
|
+
if (email3 === void 0 && typeof candidateEmail === "string" && candidateEmail !== "") {
|
|
133353
|
+
email3 = candidateEmail;
|
|
133354
|
+
}
|
|
133355
|
+
const candidateSub = account?.accountId;
|
|
133356
|
+
if (sub === void 0 && typeof candidateSub === "string" && candidateSub !== "") {
|
|
133357
|
+
sub = candidateSub;
|
|
133358
|
+
}
|
|
133359
|
+
const candidatePlan = state.quota?.level;
|
|
133360
|
+
if (plan === void 0 && typeof candidatePlan === "string" && candidatePlan !== "") {
|
|
133361
|
+
plan = candidatePlan;
|
|
133362
|
+
}
|
|
133363
|
+
}
|
|
133364
|
+
summary = { ...summary, ...windowsOf(states), providerAccountEmail: email3, providerAccountSub: sub, providerPlan: plan };
|
|
133365
|
+
}
|
|
133366
|
+
if (typeof params.payload !== "object" || params.payload === null || Array.isArray(params.payload)) {
|
|
133367
|
+
return { payload: params.payload, summary };
|
|
133368
|
+
}
|
|
133369
|
+
const enriched = { agent_shim: summary };
|
|
133370
|
+
for (const [key, value2] of Object.entries(params.payload)) {
|
|
133371
|
+
enriched[key] = value2;
|
|
133372
|
+
}
|
|
133373
|
+
return { payload: enriched, summary };
|
|
133374
|
+
}
|
|
133375
|
+
function providerScopedState(snapshot, providerDisplayName) {
|
|
133376
|
+
if (providerDisplayName === void 0 || providerDisplayName === "") {
|
|
133377
|
+
return void 0;
|
|
133378
|
+
}
|
|
133379
|
+
const wanted = providerDisplayName.toLowerCase();
|
|
133380
|
+
for (const name of Object.keys(snapshot.providers)) {
|
|
133381
|
+
if (name.toLowerCase() === wanted) {
|
|
133382
|
+
return name;
|
|
133383
|
+
}
|
|
133384
|
+
}
|
|
133385
|
+
return void 0;
|
|
133386
|
+
}
|
|
133387
|
+
|
|
133388
|
+
// src/statusline/render.ts
|
|
133389
|
+
var BAR_WIDTH = 10;
|
|
133390
|
+
var SECONDS_PER_MINUTE2 = 60;
|
|
133391
|
+
var MINUTES_PER_HOUR3 = 60;
|
|
133392
|
+
var SECONDS_PER_DAY = 86400;
|
|
133393
|
+
var THOUSAND = 1e3;
|
|
133394
|
+
var MILLION = 1e6;
|
|
133395
|
+
var TEN = 10;
|
|
133396
|
+
var TWENTY = 20;
|
|
133397
|
+
var RESERVED_COLUMNS = 4;
|
|
133398
|
+
var SEPARATOR2 = " | ";
|
|
133399
|
+
var FULL_PERCENT2 = 100;
|
|
133400
|
+
var USED_RED_AT = 0.9;
|
|
133401
|
+
var USED_YELLOW_AT = 0.7;
|
|
133402
|
+
var ESCAPE_CHAR_CODE = 27;
|
|
133403
|
+
var ESCAPE = String.fromCharCode(ESCAPE_CHAR_CODE);
|
|
133404
|
+
var RESET = `${ESCAPE}[0m`;
|
|
133405
|
+
var DIM = `${ESCAPE}[90m`;
|
|
133406
|
+
var GREEN = `${ESCAPE}[32m`;
|
|
133407
|
+
var YELLOW = `${ESCAPE}[33m`;
|
|
133408
|
+
var RED = `${ESCAPE}[31m`;
|
|
133409
|
+
var ANSI_REGEX = new RegExp(`${ESCAPE}\\[[0-9;]*[a-zA-Z]`, "g");
|
|
133410
|
+
function visibleLength(text2) {
|
|
133411
|
+
return text2.replace(ANSI_REGEX, "").length;
|
|
133412
|
+
}
|
|
133413
|
+
function colorize() {
|
|
133414
|
+
return process.env.NO_COLOR === void 0;
|
|
133415
|
+
}
|
|
133416
|
+
function statusColor(fraction, isUsedMetric) {
|
|
133417
|
+
if (!colorize()) {
|
|
133418
|
+
return "";
|
|
133419
|
+
}
|
|
133420
|
+
if (isUsedMetric) {
|
|
133421
|
+
if (fraction >= USED_RED_AT) {
|
|
133422
|
+
return RED;
|
|
133423
|
+
}
|
|
133424
|
+
return fraction >= USED_YELLOW_AT ? YELLOW : GREEN;
|
|
133425
|
+
}
|
|
133426
|
+
if (fraction <= 1 - USED_RED_AT) {
|
|
133427
|
+
return RED;
|
|
133428
|
+
}
|
|
133429
|
+
return fraction <= 1 - USED_YELLOW_AT ? YELLOW : GREEN;
|
|
133430
|
+
}
|
|
133431
|
+
function formatTokens(num) {
|
|
133432
|
+
if (num >= MILLION) {
|
|
133433
|
+
const val = num / MILLION;
|
|
133434
|
+
return val % 1 === 0 ? `${String(Math.round(val))}M` : `${val.toFixed(1)}M`;
|
|
133435
|
+
}
|
|
133436
|
+
if (num >= THOUSAND) {
|
|
133437
|
+
const val = num / THOUSAND;
|
|
133438
|
+
return val >= TEN ? `${String(Math.round(val))}k` : `${val.toFixed(1)}k`;
|
|
133439
|
+
}
|
|
133440
|
+
return String(Math.round(num));
|
|
133441
|
+
}
|
|
133442
|
+
function formatDuration(seconds) {
|
|
133443
|
+
if (seconds === void 0 || seconds <= 0) {
|
|
133444
|
+
return "available";
|
|
133445
|
+
}
|
|
133446
|
+
const days = Math.floor(seconds / SECONDS_PER_DAY);
|
|
133447
|
+
const hours = Math.floor(seconds % SECONDS_PER_DAY / (MINUTES_PER_HOUR3 * SECONDS_PER_MINUTE2));
|
|
133448
|
+
const minutes = Math.floor(seconds % (MINUTES_PER_HOUR3 * SECONDS_PER_MINUTE2) / SECONDS_PER_MINUTE2);
|
|
133449
|
+
if (days > 0) {
|
|
133450
|
+
return `${String(days)}d ${String(hours)}h`;
|
|
133451
|
+
}
|
|
133452
|
+
if (hours > 0) {
|
|
133453
|
+
return `${String(hours)}h ${String(minutes).padStart(2, "0")}m`;
|
|
133454
|
+
}
|
|
133455
|
+
return `${String(minutes)}m`;
|
|
133456
|
+
}
|
|
133457
|
+
function cacheShareText(view) {
|
|
133458
|
+
const hitRatio = view.cacheHitRatio;
|
|
133459
|
+
if (hitRatio !== void 0 && Number.isFinite(hitRatio)) {
|
|
133460
|
+
return ` (Cache: ${(Math.max(0, Math.min(1, hitRatio)) * FULL_PERCENT2).toFixed(0)}%)`;
|
|
133461
|
+
}
|
|
133462
|
+
const promptTotal = (view.cacheReadTokens ?? 0) + (view.freshInputTokens ?? 0);
|
|
133463
|
+
if (promptTotal > 0 && (view.cacheReadTokens ?? 0) > 0) {
|
|
133464
|
+
return ` (Cache: ${((view.cacheReadTokens ?? 0) / promptTotal * FULL_PERCENT2).toFixed(0)}%)`;
|
|
133465
|
+
}
|
|
133466
|
+
return "";
|
|
133467
|
+
}
|
|
133468
|
+
function tierSuffixOf(tier) {
|
|
133469
|
+
const match = /_(\d+x)$/i.exec(tier ?? "");
|
|
133470
|
+
return match === null ? void 0 : match[1];
|
|
133471
|
+
}
|
|
133472
|
+
function accountPlanLabel(summary) {
|
|
133473
|
+
switch (summary.loginOrganizationType) {
|
|
133474
|
+
case void 0:
|
|
133475
|
+
return planLabelOf(summary.loginRateLimitTier);
|
|
133476
|
+
case "claude_max": {
|
|
133477
|
+
const tier = tierSuffixOf(summary.loginRateLimitTier);
|
|
133478
|
+
return tier === void 0 ? "Max" : `Max ${tier}`;
|
|
133479
|
+
}
|
|
133480
|
+
case "claude_pro":
|
|
133481
|
+
return "Pro";
|
|
133482
|
+
case "claude_team":
|
|
133483
|
+
if (summary.loginSeatTier === "team_standard") {
|
|
133484
|
+
return "Team Standard";
|
|
133485
|
+
}
|
|
133486
|
+
if (summary.loginSeatTier === "team_tier_1") {
|
|
133487
|
+
return "Team Premium";
|
|
133488
|
+
}
|
|
133489
|
+
return "Team";
|
|
133490
|
+
case "claude_enterprise":
|
|
133491
|
+
return "Enterprise";
|
|
133492
|
+
default:
|
|
133493
|
+
return summary.loginOrganizationType;
|
|
133494
|
+
}
|
|
133495
|
+
}
|
|
133496
|
+
function planLabelOf(tier) {
|
|
133497
|
+
if (tier === void 0 || tier === "") {
|
|
133498
|
+
return void 0;
|
|
133499
|
+
}
|
|
133500
|
+
const cleaned = tier.startsWith("default_") ? tier.slice("default_".length) : tier;
|
|
133501
|
+
if (cleaned === "free") {
|
|
133502
|
+
return "Free";
|
|
133503
|
+
}
|
|
133504
|
+
const maxWithMultiplier = /^claude_max_(\d+)x$/.exec(cleaned);
|
|
133505
|
+
if (maxWithMultiplier !== null) {
|
|
133506
|
+
return `Max ${maxWithMultiplier[1] ?? ""}x`;
|
|
133507
|
+
}
|
|
133508
|
+
if (cleaned === "claude_max") {
|
|
133509
|
+
return "Max";
|
|
133510
|
+
}
|
|
133511
|
+
if (cleaned === "claude_pro") {
|
|
133512
|
+
return "Pro";
|
|
133513
|
+
}
|
|
133514
|
+
return cleaned;
|
|
133515
|
+
}
|
|
133516
|
+
function secondsUntil(resetAt, nowMs) {
|
|
133517
|
+
if (resetAt === void 0) {
|
|
133518
|
+
return void 0;
|
|
133519
|
+
}
|
|
133520
|
+
const resetMs = Date.parse(resetAt);
|
|
133521
|
+
return Number.isNaN(resetMs) ? void 0 : Math.max(0, Math.round((resetMs - nowMs) / THOUSAND));
|
|
133522
|
+
}
|
|
133523
|
+
var Segment = class {
|
|
133524
|
+
constructor(kind, text2 = "", prefix = "", suffix = "", fraction = 0, isUsed = true) {
|
|
133525
|
+
this.kind = kind;
|
|
133526
|
+
this.text = text2;
|
|
133527
|
+
this.prefix = prefix;
|
|
133528
|
+
this.suffix = suffix;
|
|
133529
|
+
this.fraction = fraction;
|
|
133530
|
+
this.isUsed = isUsed;
|
|
133531
|
+
}
|
|
133532
|
+
kind;
|
|
133533
|
+
text;
|
|
133534
|
+
prefix;
|
|
133535
|
+
suffix;
|
|
133536
|
+
fraction;
|
|
133537
|
+
isUsed;
|
|
133538
|
+
baseLength(baseBarWidth) {
|
|
133539
|
+
if (this.kind === "static") {
|
|
133540
|
+
return visibleLength(this.text);
|
|
133541
|
+
}
|
|
133542
|
+
return visibleLength(this.prefix) + baseBarWidth + 2 + visibleLength(this.suffix);
|
|
133543
|
+
}
|
|
133544
|
+
render(barWidth) {
|
|
133545
|
+
if (this.kind === "static") {
|
|
133546
|
+
return this.text;
|
|
133547
|
+
}
|
|
133548
|
+
const clamped = Math.max(0, Math.min(1, this.fraction));
|
|
133549
|
+
const filled = Math.round(clamped * barWidth);
|
|
133550
|
+
const color = statusColor(clamped, this.isUsed);
|
|
133551
|
+
const bar = color === "" ? `[${"\u2588".repeat(filled)}${"\u2591".repeat(barWidth - filled)}]` : `[${color}${"\u2588".repeat(filled)}${DIM}${"\u2591".repeat(barWidth - filled)}${RESET}]`;
|
|
133552
|
+
return `${this.prefix}${bar}${this.suffix}`;
|
|
133553
|
+
}
|
|
133554
|
+
};
|
|
133555
|
+
function renderLineWithExtra(segments, maxWidth, separator, baseBarWidth) {
|
|
133556
|
+
const separatorLength = visibleLength(separator);
|
|
133557
|
+
const bars = segments.filter((segment) => segment.kind === "bar");
|
|
133558
|
+
const lineBase = segments.reduce((total, segment) => total + segment.baseLength(baseBarWidth), 0) + separatorLength * (segments.length - 1);
|
|
133559
|
+
const extra = Math.max(0, maxWidth - lineBase);
|
|
133560
|
+
const extraById = /* @__PURE__ */ new Map();
|
|
133561
|
+
if (bars.length > 0 && extra > 0) {
|
|
133562
|
+
const perBar = Math.floor(extra / bars.length);
|
|
133563
|
+
const remainder = extra % bars.length;
|
|
133564
|
+
bars.forEach((bar, index) => {
|
|
133565
|
+
extraById.set(bar, perBar + (index < remainder ? 1 : 0));
|
|
133566
|
+
});
|
|
133567
|
+
}
|
|
133568
|
+
return segments.map((segment) => segment.render(baseBarWidth + (extraById.get(segment) ?? 0))).join(separator);
|
|
133569
|
+
}
|
|
133570
|
+
function justifySegments(segments, maxWidth, separator, baseBarWidth) {
|
|
133571
|
+
const rendered = segments.map((segment) => segment.render(baseBarWidth));
|
|
133572
|
+
if (segments.length < 2) {
|
|
133573
|
+
return rendered.join(separator);
|
|
133574
|
+
}
|
|
133575
|
+
const separatorLength = visibleLength(separator);
|
|
133576
|
+
const total = segments.reduce((sum, segment) => sum + segment.baseLength(baseBarWidth), 0) + separatorLength * (segments.length - 1);
|
|
133577
|
+
const spare = maxWidth - total;
|
|
133578
|
+
if (spare <= 0) {
|
|
133579
|
+
return rendered.join(separator);
|
|
133580
|
+
}
|
|
133581
|
+
const gaps = segments.length - 1;
|
|
133582
|
+
const extraPerGap = Math.floor(spare / gaps);
|
|
133583
|
+
let remainder = spare % gaps;
|
|
133584
|
+
const parts = [];
|
|
133585
|
+
segments.forEach((_, index) => {
|
|
133586
|
+
if (index > 0) {
|
|
133587
|
+
const extra = extraPerGap + (remainder > 0 ? 1 : 0);
|
|
133588
|
+
if (remainder > 0) {
|
|
133589
|
+
remainder -= 1;
|
|
133590
|
+
}
|
|
133591
|
+
const left = Math.floor(extra / 2);
|
|
133592
|
+
parts.push(`${" ".repeat(left + 1)}|${" ".repeat(extra - left + 1)}`);
|
|
133593
|
+
}
|
|
133594
|
+
parts.push(rendered[index] ?? "");
|
|
133595
|
+
});
|
|
133596
|
+
return parts.join("");
|
|
133597
|
+
}
|
|
133598
|
+
function packSegments(segments, maxWidth, separator, baseBarWidth, fillWrapped) {
|
|
133599
|
+
const separatorLength = visibleLength(separator);
|
|
133600
|
+
const lines = [];
|
|
133601
|
+
let current = [];
|
|
133602
|
+
let currentWidth = 0;
|
|
133603
|
+
for (const segment of segments) {
|
|
133604
|
+
const width = segment.baseLength(baseBarWidth);
|
|
133605
|
+
const added = current.length === 0 ? width : width + separatorLength;
|
|
133606
|
+
if (current.length > 0 && currentWidth + added > maxWidth) {
|
|
133607
|
+
lines.push(current);
|
|
133608
|
+
current = [segment];
|
|
133609
|
+
currentWidth = width;
|
|
133610
|
+
} else {
|
|
133611
|
+
current.push(segment);
|
|
133612
|
+
currentWidth += added;
|
|
133613
|
+
}
|
|
133614
|
+
}
|
|
133615
|
+
if (current.length > 0) {
|
|
133616
|
+
lines.push(current);
|
|
133617
|
+
}
|
|
133618
|
+
return lines.map((line) => fillWrapped ? renderLineWithExtra(line, maxWidth, separator, baseBarWidth) : justifySegments(line, maxWidth, separator, baseBarWidth));
|
|
133619
|
+
}
|
|
133620
|
+
function layoutGrouped(group1, group2, maxWidth, fillMode, separator, baseBarWidth) {
|
|
133621
|
+
const separatorLength = visibleLength(separator);
|
|
133622
|
+
const allSegments = [...group1, ...group2];
|
|
133623
|
+
if (allSegments.length === 0) {
|
|
133624
|
+
return "";
|
|
133625
|
+
}
|
|
133626
|
+
const fillUnwrapped = fillMode === "always";
|
|
133627
|
+
const fillWrapped = fillMode === "always" || fillMode === "wrapped";
|
|
133628
|
+
const totalBase = allSegments.reduce((total, segment) => total + segment.baseLength(baseBarWidth), 0) + separatorLength * (allSegments.length - 1);
|
|
133629
|
+
if (totalBase <= maxWidth) {
|
|
133630
|
+
if (fillUnwrapped) {
|
|
133631
|
+
return renderLineWithExtra(allSegments, maxWidth, separator, baseBarWidth);
|
|
133632
|
+
}
|
|
133633
|
+
return justifySegments(allSegments, maxWidth, separator, baseBarWidth);
|
|
133634
|
+
}
|
|
133635
|
+
const lines = [group1, group2].map((group) => {
|
|
133636
|
+
if (group.length === 0) {
|
|
133637
|
+
return "";
|
|
133638
|
+
}
|
|
133639
|
+
const groupBase = group.reduce((total, segment) => total + segment.baseLength(baseBarWidth), 0) + separatorLength * (group.length - 1);
|
|
133640
|
+
if (groupBase <= maxWidth) {
|
|
133641
|
+
return fillWrapped ? renderLineWithExtra(group, maxWidth, separator, baseBarWidth) : group.map((segment) => segment.render(baseBarWidth)).join(separator);
|
|
133642
|
+
}
|
|
133643
|
+
return packSegments(group, maxWidth, separator, baseBarWidth, fillWrapped).join("\n");
|
|
133644
|
+
});
|
|
133645
|
+
return lines.filter((line) => line !== "").join("\n");
|
|
133646
|
+
}
|
|
133647
|
+
function renderStatuslineBlock(summary, view, terminalWidth, nowMs) {
|
|
133648
|
+
const header = [];
|
|
133649
|
+
if (view.modelDisplayName !== void 0 && view.modelDisplayName !== "") {
|
|
133650
|
+
header.push(new Segment("static", view.modelDisplayName));
|
|
133651
|
+
}
|
|
133652
|
+
if (summary.provider !== void 0) {
|
|
133653
|
+
const account = [summary.providerAccountEmail, summary.providerPlan].filter((part) => part !== void 0);
|
|
133654
|
+
header.push(new Segment("static", account.length > 0 ? `${summary.provider} \xB7 ${account.join(" \xB7 ")}` : summary.provider));
|
|
133655
|
+
}
|
|
133656
|
+
const loginPlan = summary.provider === void 0 ? accountPlanLabel(summary) : void 0;
|
|
133657
|
+
const loginOrgName = summary.loginOrganizationType === "claude_team" || summary.loginOrganizationType === "claude_enterprise" ? summary.loginOrganizationName : void 0;
|
|
133658
|
+
const loginParts = [summary.loginAccountEmail, loginOrgName, loginPlan].filter((part) => part !== void 0);
|
|
133659
|
+
if (summary.loginAccountEmail !== void 0 && summary.loginAccountEmail !== summary.providerAccountEmail) {
|
|
133660
|
+
header.push(new Segment("static", loginParts.join(" \xB7 ")));
|
|
133661
|
+
} else if (summary.provider === void 0 && loginParts.length > 0) {
|
|
133662
|
+
header.push(new Segment("static", loginParts.join(" \xB7 ")));
|
|
133663
|
+
}
|
|
133664
|
+
if (summary.identity !== void 0 && summary.provider !== void 0 && summary.identity !== summary.providerAccountEmail && summary.identity !== summary.loginAccountEmail) {
|
|
133665
|
+
header.push(new Segment("static", summary.identity));
|
|
133666
|
+
}
|
|
133667
|
+
const contextGroup = [];
|
|
133668
|
+
if (view.contextUsedPercentage !== void 0) {
|
|
133669
|
+
const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT2));
|
|
133670
|
+
const color = statusColor(fraction, true);
|
|
133671
|
+
const percent2 = `${color}${view.contextUsedPercentage.toFixed(1)}%${RESET}`;
|
|
133672
|
+
const tokens = view.contextTotalTokens !== void 0 && view.contextWindowTokens !== void 0 ? `${formatTokens(view.contextTotalTokens)}/${formatTokens(view.contextWindowTokens)} ` : "";
|
|
133673
|
+
const cache = cacheShareText(view);
|
|
133674
|
+
contextGroup.push(new Segment("bar", "", `Ctx ${tokens}`, ` ${percent2}${cache}`, fraction, true));
|
|
133675
|
+
}
|
|
133676
|
+
const quotaGroup = [];
|
|
133677
|
+
if (summary.fiveHourUsed !== void 0) {
|
|
133678
|
+
const fraction = Math.max(0, Math.min(1, summary.fiveHourUsed / FULL_PERCENT2));
|
|
133679
|
+
const color = statusColor(fraction, true);
|
|
133680
|
+
quotaGroup.push(new Segment("bar", "", "5h ", ` ${color}${summary.fiveHourUsed.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(summary.fiveHourResetAt, nowMs))})`, fraction, true));
|
|
133681
|
+
}
|
|
133682
|
+
if (summary.sevenDayUsed !== void 0) {
|
|
133683
|
+
const fraction = Math.max(0, Math.min(1, summary.sevenDayUsed / FULL_PERCENT2));
|
|
133684
|
+
const color = statusColor(fraction, true);
|
|
133685
|
+
quotaGroup.push(new Segment("bar", "", "Wk ", ` ${color}${summary.sevenDayUsed.toFixed(1)}%${RESET} (${formatDuration(secondsUntil(summary.sevenDayResetAt, nowMs))})`, fraction, true));
|
|
133686
|
+
}
|
|
133687
|
+
const width = Math.max(TWENTY, terminalWidth - RESERVED_COLUMNS);
|
|
133688
|
+
const lines = [];
|
|
133689
|
+
if (header.length > 0) {
|
|
133690
|
+
lines.push(layoutGrouped(header, [], width, "never", SEPARATOR2, BAR_WIDTH));
|
|
133691
|
+
}
|
|
133692
|
+
const body = layoutGrouped(contextGroup, quotaGroup, width, "always", SEPARATOR2, BAR_WIDTH);
|
|
133693
|
+
if (body !== "") {
|
|
133694
|
+
lines.push(body);
|
|
133695
|
+
}
|
|
133696
|
+
return lines.join("\n");
|
|
133697
|
+
}
|
|
133698
|
+
|
|
133699
|
+
// src/statusline/commands.ts
|
|
133700
|
+
function payloadViewOf(payload) {
|
|
133701
|
+
const empty = { modelDisplayName: void 0, contextUsedPercentage: void 0, contextTotalTokens: void 0, contextWindowTokens: void 0, cacheHitRatio: void 0, cacheReadTokens: void 0, freshInputTokens: void 0 };
|
|
133702
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
133703
|
+
return empty;
|
|
133704
|
+
}
|
|
133705
|
+
const record2 = {};
|
|
133706
|
+
for (const [key, value2] of Object.entries(payload)) {
|
|
133707
|
+
record2[key] = value2;
|
|
133708
|
+
}
|
|
133709
|
+
const model = record2.model;
|
|
133710
|
+
const displayName = typeof model === "object" && model !== null && !Array.isArray(model) && "display_name" in model && typeof model.display_name === "string" ? model.display_name : void 0;
|
|
133711
|
+
const context = record2.context_window;
|
|
133712
|
+
const ctx = typeof context === "object" && context !== null && !Array.isArray(context) ? context : void 0;
|
|
133713
|
+
const used = ctx !== void 0 && "used_percentage" in ctx && typeof ctx.used_percentage === "number" ? ctx.used_percentage : void 0;
|
|
133714
|
+
const totalIn = ctx !== void 0 && "total_input_tokens" in ctx && typeof ctx.total_input_tokens === "number" ? ctx.total_input_tokens : void 0;
|
|
133715
|
+
const size = ctx !== void 0 && "context_window_size" in ctx && typeof ctx.context_window_size === "number" ? ctx.context_window_size : void 0;
|
|
133716
|
+
const current = ctx !== void 0 && "current_usage" in ctx && typeof ctx.current_usage === "object" && ctx.current_usage !== null && !Array.isArray(ctx.current_usage) ? ctx.current_usage : void 0;
|
|
133717
|
+
const cacheRead = current !== void 0 && "cache_read_input_tokens" in current && typeof current.cache_read_input_tokens === "number" ? current.cache_read_input_tokens : void 0;
|
|
133718
|
+
const fresh = current !== void 0 && "input_tokens" in current && typeof current.input_tokens === "number" ? current.input_tokens : void 0;
|
|
133719
|
+
const promptCache = record2.prompt_cache;
|
|
133720
|
+
const cache = typeof promptCache === "object" && promptCache !== null && !Array.isArray(promptCache) ? promptCache : void 0;
|
|
133721
|
+
const hitRatio = cache !== void 0 && "hit_ratio" in cache && typeof cache.hit_ratio === "number" ? cache.hit_ratio : void 0;
|
|
133722
|
+
return { modelDisplayName: displayName, contextUsedPercentage: used, contextTotalTokens: totalIn, contextWindowTokens: size, cacheHitRatio: hitRatio, cacheReadTokens: cacheRead, freshInputTokens: fresh };
|
|
133723
|
+
}
|
|
133724
|
+
async function readAllStdin() {
|
|
133725
|
+
return await new Promise((resolve2) => {
|
|
133726
|
+
const chunks = [];
|
|
133727
|
+
process.stdin.on("data", (chunk) => {
|
|
133728
|
+
chunks.push(chunk);
|
|
133729
|
+
});
|
|
133730
|
+
process.stdin.on("end", () => {
|
|
133731
|
+
resolve2(Buffer.concat(chunks).toString("utf8"));
|
|
133732
|
+
});
|
|
133733
|
+
process.stdin.resume();
|
|
133734
|
+
});
|
|
133735
|
+
}
|
|
133736
|
+
var DEFAULT_COLUMNS = 80;
|
|
133737
|
+
function registerStatuslineCommand(program2, deps) {
|
|
133738
|
+
withExamples(
|
|
133739
|
+
program2.command("statusline").description("Serve as a statusline entrypoint: read the client's stdin payload, add the identity's live provider, account and usage windows under an agent_shim key, then run the renderer named in AGENT_SHIM_STATUSLINE_CMD or print the built-in line.").action(async () => {
|
|
133740
|
+
const stdin2 = await readAllStdin();
|
|
133741
|
+
let payload;
|
|
133742
|
+
try {
|
|
133743
|
+
payload = JSON.parse(stdin2);
|
|
133744
|
+
} catch {
|
|
133745
|
+
payload = void 0;
|
|
133746
|
+
}
|
|
133747
|
+
const identity = identityOf(process.env);
|
|
133748
|
+
let snapshot;
|
|
133749
|
+
let account;
|
|
133750
|
+
if (identity !== void 0) {
|
|
133751
|
+
try {
|
|
133752
|
+
snapshot = readUsageSnapshot(realFarmFs, deps.paths.usageSnapshotsDir, identity);
|
|
133753
|
+
} catch {
|
|
133754
|
+
snapshot = void 0;
|
|
133755
|
+
}
|
|
133756
|
+
try {
|
|
133757
|
+
account = readAccountMetadata(realFarmFs, deps.paths.identitiesDir, identity);
|
|
133758
|
+
} catch {
|
|
133759
|
+
account = void 0;
|
|
133760
|
+
}
|
|
133761
|
+
}
|
|
133762
|
+
const { payload: enriched, summary } = enrichStatuslinePayload({ payload, env: process.env, snapshot, account });
|
|
133763
|
+
const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
|
|
133764
|
+
if (renderer !== void 0 && renderer !== "") {
|
|
133765
|
+
const child = (0, import_node_child_process7.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
|
|
133766
|
+
child.stdin.end(`${JSON.stringify(enriched)}
|
|
133767
|
+
`);
|
|
133768
|
+
child.on("close", (code) => {
|
|
133769
|
+
process.exit(code ?? 0);
|
|
133770
|
+
});
|
|
133771
|
+
return;
|
|
133772
|
+
}
|
|
133773
|
+
const view = payloadViewOf(payload);
|
|
133774
|
+
const columns = Number.parseInt(process.env.COLUMNS ?? "", 10);
|
|
133775
|
+
console.log(renderStatuslineBlock(summary, view, Number.isNaN(columns) ? DEFAULT_COLUMNS : columns, Date.now()));
|
|
133776
|
+
}),
|
|
133777
|
+
["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
|
|
133778
|
+
);
|
|
133779
|
+
}
|
|
133780
|
+
|
|
133245
133781
|
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_supports-color@7.2.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
133246
133782
|
var import_node_process6 = __toESM(require("node:process"), 1);
|
|
133247
133783
|
|
|
@@ -143320,7 +143856,7 @@ function registerCompletionCommand(program2) {
|
|
|
143320
143856
|
}
|
|
143321
143857
|
|
|
143322
143858
|
// src/credentialCommand.ts
|
|
143323
|
-
var
|
|
143859
|
+
var import_node_child_process8 = require("node:child_process");
|
|
143324
143860
|
init_commandDeps();
|
|
143325
143861
|
init_cliError();
|
|
143326
143862
|
init_credential();
|
|
@@ -143380,7 +143916,7 @@ function realCommandPorts(deps) {
|
|
|
143380
143916
|
cache: createRealCredentialCache(deps.paths.root),
|
|
143381
143917
|
platform: process.platform,
|
|
143382
143918
|
now: () => Date.now(),
|
|
143383
|
-
ssh: (host, remoteCommand, input2) => (0,
|
|
143919
|
+
ssh: (host, remoteCommand, input2) => (0, import_node_child_process8.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
|
|
143384
143920
|
};
|
|
143385
143921
|
}
|
|
143386
143922
|
var REMOTE_ROOT_SCRIPT = 'root="${AGENT_SHIM_HOME:-${CLAUDE_USE_HOME:-}}"; if [ -z "$root" ]; then if [ ! -d "$HOME/.agent-shim" ] && [ -d "$HOME/.claude-use" ]; then root="$HOME/.claude-use"; else root="$HOME/.agent-shim"; fi; fi';
|
|
@@ -143517,7 +144053,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
143517
144053
|
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
143518
144054
|
var import_node_http4 = __toESM(require("node:http"), 1);
|
|
143519
144055
|
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
143520
|
-
var
|
|
144056
|
+
var import_node_child_process9 = require("node:child_process");
|
|
143521
144057
|
init_commandDeps();
|
|
143522
144058
|
init_realFrontDoorPort();
|
|
143523
144059
|
init_trust();
|
|
@@ -143701,7 +144237,7 @@ async function readyOverSocket(socketPath) {
|
|
|
143701
144237
|
}
|
|
143702
144238
|
var HEADROOM_TOOL_NAME = "headroom-ai";
|
|
143703
144239
|
function readInstalledHeadroomCommit() {
|
|
143704
|
-
const toolDir = (0,
|
|
144240
|
+
const toolDir = (0, import_node_child_process9.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
|
|
143705
144241
|
if (toolDir.status !== 0) {
|
|
143706
144242
|
return void 0;
|
|
143707
144243
|
}
|
|
@@ -143745,7 +144281,7 @@ function realSupervisorPorts(paths) {
|
|
|
143745
144281
|
}
|
|
143746
144282
|
const logFd = import_node_fs22.default.openSync(paths.headroomLogPath, "a");
|
|
143747
144283
|
try {
|
|
143748
|
-
const child = (0,
|
|
144284
|
+
const child = (0, import_node_child_process9.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
|
|
143749
144285
|
detached: true,
|
|
143750
144286
|
stdio: ["ignore", logFd, logFd],
|
|
143751
144287
|
env: headroomSpawnEnv(process.env, settings2, trust?.path)
|
|
@@ -143785,7 +144321,7 @@ function realSupervisorPorts(paths) {
|
|
|
143785
144321
|
},
|
|
143786
144322
|
ready: readyOverSocket,
|
|
143787
144323
|
install: (spec) => {
|
|
143788
|
-
const result = (0,
|
|
144324
|
+
const result = (0, import_node_child_process9.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
|
|
143789
144325
|
if (result.error !== void 0) {
|
|
143790
144326
|
const timedOut = "code" in result.error && result.error.code === "ETIMEDOUT";
|
|
143791
144327
|
return {
|
|
@@ -143802,7 +144338,7 @@ function realSupervisorPorts(paths) {
|
|
|
143802
144338
|
return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
|
|
143803
144339
|
},
|
|
143804
144340
|
headroomVersion: () => {
|
|
143805
|
-
const result = (0,
|
|
144341
|
+
const result = (0, import_node_child_process9.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
|
|
143806
144342
|
return result.status === 0 ? result.stdout.trim() : void 0;
|
|
143807
144343
|
},
|
|
143808
144344
|
installedCommit: readInstalledHeadroomCommit,
|
|
@@ -144891,6 +145427,7 @@ function buildProgram(deps) {
|
|
|
144891
145427
|
registerConfigureCommand(program2, deps);
|
|
144892
145428
|
registerDoctorCommand(program2, deps);
|
|
144893
145429
|
registerShimCommand(program2, deps);
|
|
145430
|
+
registerStatuslineCommand(program2, deps);
|
|
144894
145431
|
registerHeadroomCommand(program2, deps);
|
|
144895
145432
|
registerCodexCommand(program2, deps);
|
|
144896
145433
|
registerFrontDoorCommand(program2, deps);
|
package/dist/index.cjs
CHANGED
|
@@ -2841,7 +2841,7 @@ var init_package = __esm({
|
|
|
2841
2841
|
"package.json"() {
|
|
2842
2842
|
package_default = {
|
|
2843
2843
|
name: "claude-use",
|
|
2844
|
-
version: "11.
|
|
2844
|
+
version: "11.13.0",
|
|
2845
2845
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
2846
2846
|
license: "MIT",
|
|
2847
2847
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -8724,7 +8724,7 @@ var init_cloudUpstream = __esm({
|
|
|
8724
8724
|
});
|
|
8725
8725
|
|
|
8726
8726
|
// src/usage/providerQuota.ts
|
|
8727
|
-
var import_zod29, MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY4, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema;
|
|
8727
|
+
var import_zod29, MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY4, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
8728
8728
|
var init_providerQuota = __esm({
|
|
8729
8729
|
"src/usage/providerQuota.ts"() {
|
|
8730
8730
|
"use strict";
|
|
@@ -8774,6 +8774,7 @@ var init_providerQuota = __esm({
|
|
|
8774
8774
|
OpenRouterCreditsSchema = import_zod29.z.object({ data: import_zod29.z.object({ total_credits: import_zod29.z.number().nonnegative(), total_usage: import_zod29.z.number().nonnegative() }) });
|
|
8775
8775
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
8776
8776
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
8777
|
+
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
8777
8778
|
FIVE_HOURS2 = 5;
|
|
8778
8779
|
DAYS_PER_WEEK = 7;
|
|
8779
8780
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR * MS_PER_SECOND7;
|
|
@@ -8788,6 +8789,12 @@ var init_providerQuota = __esm({
|
|
|
8788
8789
|
email: import_zod29.z.string().optional(),
|
|
8789
8790
|
sub: import_zod29.z.string().optional()
|
|
8790
8791
|
});
|
|
8792
|
+
AntigravityUserSchema = import_zod29.z.object({
|
|
8793
|
+
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
8794
|
+
currentTier: import_zod29.z.object({ name: import_zod29.z.string().optional(), id: import_zod29.z.string().optional() }).optional(),
|
|
8795
|
+
/** The account's paid subscription; absent when the account has none. */
|
|
8796
|
+
paidTier: import_zod29.z.object({ name: import_zod29.z.string().optional(), id: import_zod29.z.string().optional() }).optional()
|
|
8797
|
+
});
|
|
8791
8798
|
}
|
|
8792
8799
|
});
|
|
8793
8800
|
|
package/dist/index.mjs
CHANGED
|
@@ -2817,7 +2817,7 @@ var init_package = __esm({
|
|
|
2817
2817
|
"package.json"() {
|
|
2818
2818
|
package_default = {
|
|
2819
2819
|
name: "claude-use",
|
|
2820
|
-
version: "11.
|
|
2820
|
+
version: "11.13.0",
|
|
2821
2821
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
2822
2822
|
license: "MIT",
|
|
2823
2823
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -8696,7 +8696,7 @@ var init_cloudUpstream = __esm({
|
|
|
8696
8696
|
|
|
8697
8697
|
// src/usage/providerQuota.ts
|
|
8698
8698
|
import { z as z29 } from "zod";
|
|
8699
|
-
var MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY4, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema;
|
|
8699
|
+
var MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY4, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
8700
8700
|
var init_providerQuota = __esm({
|
|
8701
8701
|
"src/usage/providerQuota.ts"() {
|
|
8702
8702
|
"use strict";
|
|
@@ -8745,6 +8745,7 @@ var init_providerQuota = __esm({
|
|
|
8745
8745
|
OpenRouterCreditsSchema = z29.object({ data: z29.object({ total_credits: z29.number().nonnegative(), total_usage: z29.number().nonnegative() }) });
|
|
8746
8746
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
8747
8747
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
8748
|
+
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
8748
8749
|
FIVE_HOURS2 = 5;
|
|
8749
8750
|
DAYS_PER_WEEK = 7;
|
|
8750
8751
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR * MS_PER_SECOND7;
|
|
@@ -8759,6 +8760,12 @@ var init_providerQuota = __esm({
|
|
|
8759
8760
|
email: z29.string().optional(),
|
|
8760
8761
|
sub: z29.string().optional()
|
|
8761
8762
|
});
|
|
8763
|
+
AntigravityUserSchema = z29.object({
|
|
8764
|
+
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
8765
|
+
currentTier: z29.object({ name: z29.string().optional(), id: z29.string().optional() }).optional(),
|
|
8766
|
+
/** The account's paid subscription; absent when the account has none. */
|
|
8767
|
+
paidTier: z29.object({ name: z29.string().optional(), id: z29.string().optional() }).optional()
|
|
8768
|
+
});
|
|
8762
8769
|
}
|
|
8763
8770
|
});
|
|
8764
8771
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-use",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.13.0",
|
|
4
4
|
"description": "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|