@ganakailabs/cloudeval-cli 0.19.2 → 0.19.4

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.
@@ -2,9 +2,9 @@ import {
2
2
  Banner,
3
3
  bannerSegmentColor,
4
4
  splitBannerLineSegments
5
- } from "./chunk-UXX36KJO.js";
6
- import "./chunk-2O7XF47R.js";
7
- import "./chunk-UOCT7M4J.js";
5
+ } from "./chunk-L2H4P4BP.js";
6
+ import "./chunk-HUE4D6RO.js";
7
+ import "./chunk-QKZCKI55.js";
8
8
  export {
9
9
  Banner,
10
10
  bannerSegmentColor,
@@ -0,0 +1,8 @@
1
+ import {
2
+ Onboarding
3
+ } from "./chunk-2GTSKMHA.js";
4
+ import "./chunk-2D4BE3OS.js";
5
+ import "./chunk-QKZCKI55.js";
6
+ export {
7
+ Onboarding
8
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  terminalTheme
3
- } from "./chunk-UOCT7M4J.js";
3
+ } from "./chunk-QKZCKI55.js";
4
4
 
5
5
  // src/reports/ReportDashboard.tsx
6
6
  import { useMemo, useState } from "react";
@@ -1707,14 +1707,14 @@ var getAuthToken = async (options = {}) => {
1707
1707
  return options.accessKey;
1708
1708
  }
1709
1709
  const minValidUntil = now() + TOKEN_EXPIRY_SKEW_MS;
1710
- if (cachedToken && cachedToken.expiresAt > minValidUntil) {
1710
+ if (!options.forceRefresh && cachedToken && cachedToken.expiresAt > minValidUntil) {
1711
1711
  return cachedToken.token;
1712
1712
  }
1713
1713
  const disk = readStored();
1714
1714
  const refreshToken = getRefreshToken(disk);
1715
1715
  const accessToken = getAccessToken(disk);
1716
1716
  let refreshError;
1717
- if (accessToken && disk.tokenExpiresAt && disk.tokenExpiresAt > minValidUntil) {
1717
+ if (!options.forceRefresh && accessToken && disk.tokenExpiresAt && disk.tokenExpiresAt > minValidUntil) {
1718
1718
  cachedToken = { token: accessToken, expiresAt: disk.tokenExpiresAt };
1719
1719
  return accessToken;
1720
1720
  }
@@ -1743,6 +1743,30 @@ var withIdempotencyHeader = (headers, idempotencyKey) => ({
1743
1743
  ...headers,
1744
1744
  "Idempotency-Key": idempotencyKey ?? createIdempotencyKey()
1745
1745
  });
1746
+ var StreamRequestError = class extends Error {
1747
+ status;
1748
+ statusText;
1749
+ body;
1750
+ constructor(input) {
1751
+ super(
1752
+ `Stream request failed with status ${input.status} ${input.statusText}${input.body ? `: ${input.body}` : ""}`
1753
+ );
1754
+ this.name = "StreamRequestError";
1755
+ this.status = input.status;
1756
+ this.statusText = input.statusText;
1757
+ this.body = input.body;
1758
+ }
1759
+ };
1760
+ var isExpiredDeviceTokenStreamError = (error) => {
1761
+ if (!(error instanceof StreamRequestError) || error.status !== 401) {
1762
+ return false;
1763
+ }
1764
+ const text = `${error.body}
1765
+ ${error.message}`;
1766
+ return /device token has expired|invalid token[^a-z0-9]+.*expired|token[^a-z0-9]+.*expired/i.test(
1767
+ text
1768
+ );
1769
+ };
1746
1770
  var DEFAULT_PROJECT_TYPE = "sync";
1747
1771
  var RESPONSE_OUTPUT_NODES = /* @__PURE__ */ new Set([
1748
1772
  "generate_response",
@@ -2019,9 +2043,11 @@ async function* streamChat(options) {
2019
2043
  }
2020
2044
  if (!response.ok) {
2021
2045
  const body = compactErrorBody(await response.text().catch(() => ""));
2022
- throw new Error(
2023
- `Stream request failed with status ${response.status} ${response.statusText}${body ? `: ${body}` : ""}`
2024
- );
2046
+ throw new StreamRequestError({
2047
+ status: response.status,
2048
+ statusText: response.statusText,
2049
+ body: body ?? ""
2050
+ });
2025
2051
  }
2026
2052
  if (!response.body) {
2027
2053
  throw new Error("Streaming response body missing");
@@ -2907,6 +2933,10 @@ var getReportJobStatus = async (options) => fetchJson(options, `/jobs/${encodeUR
2907
2933
  var CREDIT_LOW_RATIO = 0.1;
2908
2934
  var CREDIT_WARNING_RATIO = 0.25;
2909
2935
  var DEFAULT_FREE_TRIAL_CREDITS_TOTAL = 1e3;
2936
+ var finiteCredit = (value) => {
2937
+ const numberValue = Number(value);
2938
+ return Number.isFinite(numberValue) ? Math.max(numberValue, 0) : null;
2939
+ };
2910
2940
  var fetchBillingJson = async (options, path2, query = {}, request = {}) => {
2911
2941
  const url = new URL(`${normalizeApiBase(options.baseUrl)}${path2}`);
2912
2942
  for (const [key, value] of Object.entries(query)) {
@@ -3045,10 +3075,18 @@ var getCreditStatus = (summary, options) => {
3045
3075
  0
3046
3076
  );
3047
3077
  const useTrialDisplayTotal = isFreeLikePlan && effectiveTotal <= 0 && trialTotal > 0;
3048
- const displayTotal = useTrialDisplayTotal ? trialTotal : effectiveTotal;
3078
+ let displayTotal = useTrialDisplayTotal ? trialTotal : effectiveTotal;
3049
3079
  const remainingCandidate = useTrialDisplayTotal && (summary.trial_state?.consumed || summary.trial_state?.blocked) ? 0 : effectiveRemaining;
3050
3080
  const remaining = displayTotal > 0 ? Math.min(Math.max(remainingCandidate, 0), displayTotal) : 0;
3051
- const used = displayTotal > 0 ? Math.max(displayTotal - remaining, 0) : 0;
3081
+ const derivedUsed = displayTotal > 0 ? Math.max(displayTotal - remaining, 0) : 0;
3082
+ const reportedUsed = Math.max(
3083
+ 0,
3084
+ ...[balance.credits_used, balance.credits_used_cycle, options?.reportedUsedCredits].map(finiteCredit).filter((value) => value !== null)
3085
+ );
3086
+ const used = Math.max(derivedUsed, reportedUsed);
3087
+ if (!explicitUnlimited && remaining + used > displayTotal) {
3088
+ displayTotal = remaining + used;
3089
+ }
3052
3090
  const remainingRatio = displayTotal > 0 ? remaining / displayTotal : explicitUnlimited ? 1 : 0;
3053
3091
  const creditsPerEvent = options?.creditsPerEvent;
3054
3092
  const messagesRemaining = explicitUnlimited || !creditsPerEvent || creditsPerEvent <= 0 ? null : Math.max(0, Math.floor(remaining / creditsPerEvent));
@@ -3073,6 +3111,26 @@ var getCreditStatus = (summary, options) => {
3073
3111
  messagesRemaining
3074
3112
  };
3075
3113
  };
3114
+ var getBillingUsageCreditsUsed = (summary) => {
3115
+ if (!summary || typeof summary !== "object" || Array.isArray(summary)) {
3116
+ return null;
3117
+ }
3118
+ const record = summary;
3119
+ const totals = record.totals && typeof record.totals === "object" && !Array.isArray(record.totals) ? record.totals : record;
3120
+ const direct = finiteCredit(totals.credits_used ?? totals.total_credits);
3121
+ if (direct !== null) {
3122
+ return direct;
3123
+ }
3124
+ const buckets = Array.isArray(record.buckets) ? record.buckets : [];
3125
+ const bucketTotal = buckets.reduce((sum, bucket) => {
3126
+ if (!bucket || typeof bucket !== "object" || Array.isArray(bucket)) {
3127
+ return sum;
3128
+ }
3129
+ const bucketRecord = bucket;
3130
+ return sum + (finiteCredit(bucketRecord.credits_used ?? bucketRecord.total_credits) ?? 0);
3131
+ }, 0);
3132
+ return bucketTotal > 0 ? bucketTotal : null;
3133
+ };
3076
3134
  var providerValues = /* @__PURE__ */ new Set(["azure", "aws", "gcp"]);
3077
3135
  var sanitizeNamePart = (value) => value.replace(/\.(json|yaml|yml|tf)$/i, "").replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
3078
3136
  var inferCloudProvider = (owner, repo, filePath) => {
@@ -3426,6 +3484,8 @@ export {
3426
3484
  completeOnboarding,
3427
3485
  getAuthToken,
3428
3486
  getAuthHeader,
3487
+ StreamRequestError,
3488
+ isExpiredDeviceTokenStreamError,
3429
3489
  streamChat,
3430
3490
  initialChatState,
3431
3491
  completeActiveAssistantMessage,
@@ -3452,6 +3512,7 @@ export {
3452
3512
  getBillingUsageSummary,
3453
3513
  getBillingUsageLedger,
3454
3514
  getCreditStatus,
3515
+ getBillingUsageCreditsUsed,
3455
3516
  parseTemplateUrl,
3456
3517
  buildQuickProjectPayload,
3457
3518
  createQuickProject,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  completeOnboarding
3
- } from "./chunk-4QIKW5TJ.js";
3
+ } from "./chunk-2D4BE3OS.js";
4
4
  import {
5
5
  terminalTheme
6
- } from "./chunk-UOCT7M4J.js";
6
+ } from "./chunk-QKZCKI55.js";
7
7
 
8
8
  // src/ui/components/Onboarding.tsx
9
9
  import { useState } from "react";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var CLI_VERSION = "0.19.2";
2
+ var CLI_VERSION = "0.19.4";
3
3
 
4
4
  export {
5
5
  CLI_VERSION
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  CLI_VERSION
3
- } from "./chunk-2O7XF47R.js";
3
+ } from "./chunk-HUE4D6RO.js";
4
4
  import {
5
5
  shouldUseColor,
6
6
  terminalTheme
7
- } from "./chunk-UOCT7M4J.js";
7
+ } from "./chunk-QKZCKI55.js";
8
8
 
9
9
  // src/ui/components/Banner.tsx
10
10
  import { Box, Text } from "ink";
@@ -19,15 +19,17 @@ var color = (dark, light) => {
19
19
  return isLightTerminal() ? light : dark;
20
20
  };
21
21
  var terminalTheme = {
22
- brand: color("cyan", "blue"),
23
- accent: color("yellow", "blue"),
24
- success: color("green", "green"),
22
+ brand: color("cyanBright", "blue"),
23
+ accent: color("magentaBright", "magenta"),
24
+ focus: color("cyanBright", "blue"),
25
+ selected: color("greenBright", "green"),
26
+ success: color("greenBright", "green"),
25
27
  muted: color("gray", "gray"),
26
28
  /** Inline ghost / autosuggest — distinct from user text and from gray-muted UI chrome */
27
29
  inputGhost: color("magenta", "blue"),
28
- warning: color("yellow", "magenta"),
29
- danger: color("red", "red"),
30
- cursor: color("cyan", "blue")
30
+ warning: color("yellowBright", "magenta"),
31
+ danger: color("redBright", "red"),
32
+ cursor: color("cyanBright", "blue")
31
33
  };
32
34
  var shouldUseColor = hasColor;
33
35
  var raisedButtonStyle = {