agent-usage-all-in-one 0.6.2 → 0.7.1

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/cli.js CHANGED
@@ -585,20 +585,21 @@ function antigravityEntry(options) {
585
585
  source: options.source ?? GOOGLE_ANTIGRAVITY_SOURCE
586
586
  };
587
587
  }
588
- function openAiGpt56Entries(model, periods) {
589
- return periods.flatMap(([effectiveFrom, effectiveUntil, input, output]) => {
588
+ function openAiCodexEntries(options) {
589
+ const aliases = options.aliases ?? [];
590
+ return options.periods.flatMap(([effectiveFrom, effectiveUntil, input, output]) => {
590
591
  const versionDate = effectiveFrom.slice(0, 10);
591
592
  const entry = (tier) => {
592
593
  const long = tier === "prompt-above-272k";
593
594
  const tierInput = long ? input * 2 : input;
594
595
  const tierOutput = long ? output * 1.5 : output;
595
596
  return {
596
- id: `openai-${model}-${tier}-${versionDate}`,
597
- priceVersion: `openai-gpt-5.6-${versionDate}`,
597
+ id: `openai-${options.model}-${tier}-${versionDate}`,
598
+ priceVersion: `${options.priceVersionPrefix}-${versionDate}`,
598
599
  providerId: "codex",
599
600
  billingDomainId: "subscription",
600
- canonicalModel: model,
601
- aliases: [],
601
+ canonicalModel: options.model,
602
+ aliases,
602
603
  currency: "USD",
603
604
  effectiveFrom,
604
605
  effectiveUntil,
@@ -611,12 +612,29 @@ function openAiGpt56Entries(model, periods) {
611
612
  "cache-read": tierInput * 0.1,
612
613
  "cache-write": tierInput * 1.25
613
614
  },
614
- source: OPENAI_GPT_56_SOURCE
615
+ source: options.source
615
616
  };
616
617
  };
617
618
  return [entry("standard"), entry("prompt-above-272k")];
618
619
  });
619
620
  }
621
+ function openAiGpt56Entries(model, periods) {
622
+ return openAiCodexEntries({
623
+ model,
624
+ periods,
625
+ priceVersionPrefix: "openai-gpt-5.6",
626
+ source: OPENAI_GPT_56_SOURCE
627
+ });
628
+ }
629
+ function openAiGpt6AstraEntries(model, periods, aliases = []) {
630
+ return openAiCodexEntries({
631
+ model,
632
+ aliases,
633
+ periods,
634
+ priceVersionPrefix: "openai-gpt-6-astra",
635
+ source: OPENAI_GPT_6_ASTRA_SOURCE
636
+ });
637
+ }
620
638
  function openCodeGoEntry(model, tier, input, output, cacheRead, cacheWrite, contextRule) {
621
639
  const history = OPEN_CODE_PRICE_HISTORY[model];
622
640
  if (!history) throw new Error(`Missing pinned OpenCode Go price history for ${model}.`);
@@ -959,7 +977,7 @@ function matchContext(rule, observation) {
959
977
  function preciseMoney(value) {
960
978
  return Number(value.toFixed(12));
961
979
  }
962
- var ANTHROPIC_PRICING_CATALOG, OPENCODE_GO_SOURCE, XAI_PRICING_SOURCE, OPENAI_GPT_56_SOURCE, OPEN_CODE_GO_SOURCE_PATH, openCodeHistory, OPEN_CODE_BASE_HISTORY, OPEN_CODE_PRICE_HISTORY, OPEN_CODE_FLAT_MODELS, OPEN_CODE_CONTEXT_MODELS, DEEPSEEK_GO_MODELS, WEEKDAY_PEAK_RANGES, DEEPSEEK_OFFICIAL_SOURCE, DEEPSEEK_OFFICIAL_MODELS, DEEPSEEK_OFFICIAL_EFFECTIVE_FROM, GOOGLE_ANTIGRAVITY_SOURCE, GOOGLE_ANTIGRAVITY_EFFECTIVE_FROM, DIRECT_OFFICIAL_PRICING_CATALOG, OFFICIAL_PRICING_CATALOG;
980
+ var ANTHROPIC_PRICING_CATALOG, OPENCODE_GO_SOURCE, XAI_PRICING_SOURCE, OPENAI_GPT_56_SOURCE, OPENAI_GPT_6_ASTRA_SOURCE, OPEN_CODE_GO_SOURCE_PATH, openCodeHistory, OPEN_CODE_BASE_HISTORY, OPEN_CODE_PRICE_HISTORY, OPEN_CODE_FLAT_MODELS, OPEN_CODE_CONTEXT_MODELS, DEEPSEEK_GO_MODELS, WEEKDAY_PEAK_RANGES, DEEPSEEK_OFFICIAL_SOURCE, DEEPSEEK_OFFICIAL_MODELS, DEEPSEEK_OFFICIAL_EFFECTIVE_FROM, GOOGLE_ANTIGRAVITY_SOURCE, GOOGLE_ANTIGRAVITY_EFFECTIVE_FROM, DIRECT_OFFICIAL_PRICING_CATALOG, OFFICIAL_PRICING_CATALOG;
963
981
  var init_retail_pricing = __esm({
964
982
  "src/core/retail-pricing.ts"() {
965
983
  "use strict";
@@ -1074,6 +1092,11 @@ var init_retail_pricing = __esm({
1074
1092
  url: "https://openai.com/index/gpt-5-6/",
1075
1093
  retrievedAt: "2026-08-28"
1076
1094
  };
1095
+ OPENAI_GPT_6_ASTRA_SOURCE = {
1096
+ title: "OpenAI GPT-6 Astra pricing",
1097
+ url: "https://developers.openai.com/api/docs/models/gpt-6-astra",
1098
+ retrievedAt: "2026-09-05"
1099
+ };
1077
1100
  OPEN_CODE_GO_SOURCE_PATH = "packages/web/src/content/docs/go.mdx";
1078
1101
  openCodeHistory = (commit, effectiveFrom) => ({
1079
1102
  effectiveFrom,
@@ -1209,6 +1232,11 @@ var init_retail_pricing = __esm({
1209
1232
  ["2026-07-09T00:00:00.000Z", "2026-07-30T00:00:00.000Z", 1, 6],
1210
1233
  ["2026-07-30T00:00:00.000Z", null, 0.2, 1.2]
1211
1234
  ]),
1235
+ ...openAiGpt6AstraEntries(
1236
+ "gpt-6-astra",
1237
+ [["2026-09-03T00:00:00.000Z", null, 10, 50]],
1238
+ ["GPT-6 Astra", "gpt-6-astra-2026-09-03", "gpt-6-astra-20260903", "astra"]
1239
+ ),
1212
1240
  ...OPEN_CODE_FLAT_MODELS.map(
1213
1241
  ([model, input, output, cacheRead, cacheWrite]) => openCodeGoEntry(model, "standard", input, output, cacheRead, cacheWrite ?? null, {
1214
1242
  kind: "fixed"
@@ -1413,7 +1441,7 @@ var init_retail_pricing = __esm({
1413
1441
  ]
1414
1442
  };
1415
1443
  OFFICIAL_PRICING_CATALOG = {
1416
- version: "2026-09-03-fable-5.1",
1444
+ version: "2026-09-05-gpt-6-astra",
1417
1445
  entries: [
1418
1446
  ...DIRECT_OFFICIAL_PRICING_CATALOG.entries,
1419
1447
  ...openCodeLocalHistoryEntries(DIRECT_OFFICIAL_PRICING_CATALOG.entries)
@@ -2411,7 +2439,7 @@ var init_usage_application = __esm({
2411
2439
  });
2412
2440
  }
2413
2441
  this.#repository.saveNotificationState(usedKey, String(bucket.usedPercent));
2414
- const remaining = 100 - bucket.usedPercent;
2442
+ const remaining = Math.max(0, 100 - bucket.usedPercent);
2415
2443
  const level = remaining <= 5 ? "5" : remaining <= 20 ? "20" : "normal";
2416
2444
  const levelKey = `quota-level:${prefix}`;
2417
2445
  const priorLevel = this.#repository.getNotificationState(levelKey) ?? "normal";
@@ -2828,6 +2856,19 @@ var init_catalog = __esm({
2828
2856
  }
2829
2857
  });
2830
2858
 
2859
+ // src/core/quota-normalization.ts
2860
+ function clampPercent(value) {
2861
+ if (value === null || value === void 0 || !Number.isFinite(value)) {
2862
+ return null;
2863
+ }
2864
+ return Math.min(100, Math.max(0, value));
2865
+ }
2866
+ var init_quota_normalization = __esm({
2867
+ "src/core/quota-normalization.ts"() {
2868
+ "use strict";
2869
+ }
2870
+ });
2871
+
2831
2872
  // src/connectors/claude-code/claude-code-connector.ts
2832
2873
  function incompleteTranscriptFailure(provider) {
2833
2874
  return {
@@ -2841,7 +2882,7 @@ function mapQuota(quota) {
2841
2882
  id: quota.id,
2842
2883
  billingDomainId: "subscription",
2843
2884
  label: quota.label,
2844
- usedPercent: quota.usedPercent,
2885
+ usedPercent: clampPercent(quota.usedPercent),
2845
2886
  windowDurationMinutes: quota.windowDurationMinutes,
2846
2887
  resetsAt: quota.resetsAt,
2847
2888
  authority: "official-client",
@@ -2862,6 +2903,7 @@ var ClaudeCodeConnector;
2862
2903
  var init_claude_code_connector = __esm({
2863
2904
  "src/connectors/claude-code/claude-code-connector.ts"() {
2864
2905
  "use strict";
2906
+ init_quota_normalization();
2865
2907
  ClaudeCodeConnector = class {
2866
2908
  id = "claude-code";
2867
2909
  displayName = "Claude Code";
@@ -3146,7 +3188,7 @@ function parseClaudeUsageScreen(text, now) {
3146
3188
  quotas.set(id, {
3147
3189
  id,
3148
3190
  label: displayLabel(heading),
3149
- usedPercent: Number(match[1]),
3191
+ usedPercent: clampPercent(Number(match[1])),
3150
3192
  windowDurationMinutes: windowDurationMinutes(heading),
3151
3193
  resetsAt: resetLine ? parseReset(resetLine, now) : null
3152
3194
  });
@@ -3335,6 +3377,7 @@ var ClaudeUsageAdapterError, ScreenReaderClaudeQuotaClient;
3335
3377
  var init_claude_usage_screen_client = __esm({
3336
3378
  "src/connectors/claude-code/claude-usage-screen-client.ts"() {
3337
3379
  "use strict";
3380
+ init_quota_normalization();
3338
3381
  ClaudeUsageAdapterError = class extends Error {
3339
3382
  code;
3340
3383
  recovery;
@@ -3538,7 +3581,7 @@ function mapQuotaBuckets(response) {
3538
3581
  id: `${key}:${windowName}`,
3539
3582
  billingDomainId: "subscription",
3540
3583
  label: multipleLimits ? `${baseLabel} \xB7 ${windowLabel}` : windowLabel,
3541
- usedPercent: window.usedPercent,
3584
+ usedPercent: clampPercent(window.usedPercent),
3542
3585
  windowDurationMinutes: window.windowDurationMins,
3543
3586
  resetsAt: window.resetsAt === null ? null : new Date(window.resetsAt * 1e3).toISOString(),
3544
3587
  authority: "official-account"
@@ -3559,6 +3602,7 @@ var nullableNumeric, numeric, rateLimitWindowSchema, rateLimitSnapshotSchema, co
3559
3602
  var init_codex_connector = __esm({
3560
3603
  "src/connectors/codex/codex-connector.ts"() {
3561
3604
  "use strict";
3605
+ init_quota_normalization();
3562
3606
  init_token_normalization();
3563
3607
  nullableNumeric = z2.union([z2.number(), z2.string()]).transform(Number).nullable();
3564
3608
  numeric = z2.union([z2.number(), z2.string()]).transform(Number);
@@ -4318,7 +4362,7 @@ function mapQuota2(response) {
4318
4362
  id,
4319
4363
  billingDomainId: "go-subscription",
4320
4364
  label: LIMITS[id].label,
4321
- usedPercent: response.usage[id].percent,
4365
+ usedPercent: clampPercent(response.usage[id].percent),
4322
4366
  windowDurationMinutes: LIMITS[id].windowDurationMinutes,
4323
4367
  resetsAt: response.usage[id].resetsAt,
4324
4368
  authority: "official-account",
@@ -4343,6 +4387,7 @@ var LIMITS, OpenCodeGoConnector;
4343
4387
  var init_opencode_go_connector = __esm({
4344
4388
  "src/connectors/opencode-go/opencode-go-connector.ts"() {
4345
4389
  "use strict";
4390
+ init_quota_normalization();
4346
4391
  LIMITS = {
4347
4392
  rolling: { label: "5 hour", amount: 12, windowDurationMinutes: 300 },
4348
4393
  weekly: { label: "Week", amount: 30, windowDurationMinutes: 10080 },
@@ -4439,7 +4484,9 @@ function grokBuildBillingDomains(usage = []) {
4439
4484
  function mapBillingQuota(billing) {
4440
4485
  const config = billing.config;
4441
4486
  if (!config) return [];
4442
- const usedPercent = config.creditUsagePercent ?? derivePercent(config.used?.val, config.monthlyLimit?.val);
4487
+ const usedPercent = clampPercent(
4488
+ config.creditUsagePercent ?? derivePercent(config.used?.val, config.monthlyLimit?.val)
4489
+ );
4443
4490
  if (usedPercent === null) return [];
4444
4491
  const periodType = config.currentPeriod?.type;
4445
4492
  const period = nativePeriod(periodType, config.currentPeriod ? void 0 : "monthly");
@@ -4497,6 +4544,7 @@ var centSchema, usagePeriodSchema, billingConfigSchema, grokBillingResponseSchem
4497
4544
  var init_grok_build_connector = __esm({
4498
4545
  "src/connectors/grok-build/grok-build-connector.ts"() {
4499
4546
  "use strict";
4547
+ init_quota_normalization();
4500
4548
  centSchema = z6.object({ val: z6.number().default(0) }).passthrough();
4501
4549
  usagePeriodSchema = z6.object({
4502
4550
  type: z6.string().optional(),
@@ -8032,7 +8080,7 @@ function mapQuotaRow(row) {
8032
8080
  id: row.id,
8033
8081
  billingDomainId: row.billing_domain_id,
8034
8082
  label: row.label,
8035
- usedPercent: row.used_percent,
8083
+ usedPercent: clampPercent(row.used_percent),
8036
8084
  windowDurationMinutes: row.window_duration_minutes,
8037
8085
  resetsAt: row.resets_at,
8038
8086
  authority: row.authority,
@@ -9128,7 +9176,10 @@ function buildRiskSummary(providers) {
9128
9176
  const limitingBucket = [...buckets].sort(
9129
9177
  (left, right) => right.usedPercent - left.usedPercent || left.id.localeCompare(right.id)
9130
9178
  )[0];
9131
- const remaining = Math.min(...buckets.map((bucket) => 100 - bucket.usedPercent));
9179
+ const remaining = Math.max(
9180
+ 0,
9181
+ Math.min(...buckets.map((bucket) => 100 - bucket.usedPercent))
9182
+ );
9132
9183
  const predictsFailure = domain.forecasts.some((forecast) => !forecast.willLastUntilReset);
9133
9184
  const predictsSuccess = domain.forecasts.length > 0 && domain.forecasts.every((forecast) => forecast.willLastUntilReset);
9134
9185
  const coveragePenalty = domain.forecastCoverage === "discontinuous" ? 40 : 0;
@@ -9211,6 +9262,7 @@ var init_sqlite_usage_repository = __esm({
9211
9262
  "src/server/sqlite-usage-repository.ts"() {
9212
9263
  "use strict";
9213
9264
  init_token_normalization();
9265
+ init_quota_normalization();
9214
9266
  init_plan_pricing();
9215
9267
  FRESHNESS_WINDOW_MS = 15 * 60 * 1e3;
9216
9268
  QUERY_INDEXES_SQL = `
@@ -9360,12 +9412,13 @@ var init_sqlite_usage_repository = __esm({
9360
9412
  }
9361
9413
  }
9362
9414
  for (const bucket of snapshot2.quotaBuckets) {
9415
+ const clampedUsedPercent = clampPercent(bucket.usedPercent);
9363
9416
  quotaStatement.run(
9364
9417
  snapshot2.provider.id,
9365
9418
  bucket.id,
9366
9419
  bucket.billingDomainId,
9367
9420
  bucket.label,
9368
- bucket.usedPercent,
9421
+ clampedUsedPercent,
9369
9422
  bucket.windowDurationMinutes ?? null,
9370
9423
  bucket.resetsAt,
9371
9424
  bucket.authority,
@@ -9390,13 +9443,14 @@ var init_sqlite_usage_repository = __esm({
9390
9443
  authority = excluded.authority`
9391
9444
  );
9392
9445
  for (const bucket of snapshot2.quotaBuckets) {
9393
- if (bucket.usedPercent === null) continue;
9446
+ const clampedUsedPercent = clampPercent(bucket.usedPercent);
9447
+ if (clampedUsedPercent === null) continue;
9394
9448
  quotaObservationStatement.run(
9395
9449
  snapshot2.provider.id,
9396
9450
  bucket.id,
9397
9451
  bucket.billingDomainId,
9398
9452
  bucket.label,
9399
- bucket.usedPercent,
9453
+ clampedUsedPercent,
9400
9454
  bucket.resetsAt,
9401
9455
  bucket.authority,
9402
9456
  snapshot2.observedAt