@cartanova/qgrid-cli 2.13.1 → 2.14.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.
Files changed (39) hide show
  1. package/bundle/dist/application/qgrid/qgrid.frame.js +6 -2
  2. package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +12 -13
  3. package/bundle/dist/utils/providers/anthropic/anthropic-quota.js +11 -7
  4. package/bundle/dist/utils/providers/common/model-cost.js +31 -7
  5. package/bundle/dist/utils/providers/grok/grok-constants.js +2 -2
  6. package/bundle/dist/utils/providers/grok/grok-dispatcher.js +15 -15
  7. package/bundle/dist/utils/providers/grok/grok-media-client.js +2 -2
  8. package/bundle/src/application/qgrid/qgrid.frame.test.ts +22 -8
  9. package/bundle/src/application/qgrid/qgrid.frame.ts +6 -1
  10. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.test.ts +31 -4
  11. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +14 -14
  12. package/bundle/src/utils/providers/anthropic/anthropic-quota.test.ts +27 -3
  13. package/bundle/src/utils/providers/anthropic/anthropic-quota.ts +18 -8
  14. package/bundle/src/utils/providers/common/model-cost.test.ts +26 -4
  15. package/bundle/src/utils/providers/common/model-cost.ts +44 -11
  16. package/bundle/src/utils/providers/grok/grok-constants.ts +2 -2
  17. package/bundle/src/utils/providers/grok/grok-dispatcher.test.ts +23 -7
  18. package/bundle/src/utils/providers/grok/grok-dispatcher.ts +19 -23
  19. package/bundle/src/utils/providers/grok/grok-media-client.test.ts +6 -6
  20. package/bundle/src/utils/providers/grok/grok-types.test.ts +4 -4
  21. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +2 -2
  22. package/bundle/web-dist/client/assets/{index-DplV-wqZ.js → index-jExDfi8j.js} +3 -3
  23. package/bundle/web-dist/client/assets/{logs-st46aRba.js → logs-ol_IGjcT.js} +1 -1
  24. package/bundle/web-dist/client/assets/{monit-BMXR2tY2.js → monit-CGTRk2U0.js} +1 -1
  25. package/bundle/web-dist/client/assets/{routes-BWPjgvhg.js → routes-D9l20OWa.js} +2 -2
  26. package/bundle/web-dist/client/assets/{settings-DTXZjDAw.js → settings-D2zIv0xR.js} +1 -1
  27. package/bundle/web-dist/client/assets/{show-CdWNFPyS.js → show-DefwCScC.js} +1 -1
  28. package/bundle/web-dist/client/assets/{tokens-eA34Gw5f.js → tokens-CbmIxMZ9.js} +1 -1
  29. package/bundle/web-dist/client/assets/{use-oauth-login-flow-CcUdLsa7.js → use-oauth-login-flow-CEufhZcR.js} +1 -1
  30. package/bundle/web-dist/client/assets/{use-update-token-mutation-D2r5K5Bz.js → use-update-token-mutation-E5ey27W6.js} +1 -1
  31. package/bundle/web-dist/client/index.html +1 -1
  32. package/bundle/web-dist/server/assets/{routes-CjWxvHAO.js → routes-CCdBJqP_.js} +11 -10
  33. package/bundle/web-dist/server/entry-server.generated.js +2 -2
  34. package/package.json +1 -1
  35. package/skills/qgrid/references/anthropic-claude-code-runtime.md +4 -3
  36. package/skills/qgrid/references/decision-rationale.md +4 -3
  37. package/skills/qgrid/references/grok-runtime.md +10 -1
  38. package/skills/qgrid/references/sonamu-api-web-flow.md +4 -0
  39. package/skills/qgrid/references/token-auth-quota-lifecycle.md +8 -4
@@ -2937,11 +2937,7 @@ var lucideGripVertical = ({ title, titleId, ...props }, ref) => /* @__PURE__ */
2937
2937
  var ForwardRef = (0, import_react.forwardRef)(lucideGripVertical);
2938
2938
  //#endregion
2939
2939
  //#region src/components/qgrid/UsageCard.tsx
2940
- var QUOTA_THRESHOLD_PROVIDERS = /* @__PURE__ */ new Set([
2941
- "anthropic",
2942
- "openai",
2943
- "grok"
2944
- ]);
2940
+ var QUOTA_THRESHOLD_PROVIDERS = /* @__PURE__ */ new Set(["anthropic", "openai"]);
2945
2941
  function validateThreshold(raw) {
2946
2942
  const trimmed = raw.trim();
2947
2943
  if (trimmed === "") return {
@@ -3149,7 +3145,7 @@ function TokenUsage({ token, theme }) {
3149
3145
  resetsAt: data.sevenDay.resetsAt,
3150
3146
  windowDurationMins: data.sevenDay.windowDurationMins,
3151
3147
  theme,
3152
- threshold: token.provider === "grok" ? thresholdForPrimary : void 0
3148
+ threshold: token.provider === "anthropic" || token.provider === "grok" ? 100 : void 0
3153
3149
  })
3154
3150
  ]
3155
3151
  });
@@ -3222,7 +3218,7 @@ function ThresholdControl({ token }) {
3222
3218
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
3223
3219
  htmlFor: `threshold-${token.id}`,
3224
3220
  className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
3225
- children: "사용률 제한"
3221
+ children: token.provider === "anthropic" ? "5시간 사용률 제한" : "주간 사용률 제한"
3226
3222
  }),
3227
3223
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3228
3224
  className: "mt-1 flex items-center gap-2",
@@ -3254,7 +3250,7 @@ function ThresholdControl({ token }) {
3254
3250
  }),
3255
3251
  validation.ok ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3256
3252
  className: "mt-1.5 text-[11px] text-sand-500 leading-snug",
3257
- children: validation.value === null ? "제한 없음 — 사용률과 무관하게 항상 사용합니다." : "기준 사용률이 임계치에 달하면 해당 토큰을 건너뜁니다."
3253
+ children: validation.value === null ? token.provider === "anthropic" ? "5시간 제한 없음. 주간 사용량 100%에서는 제외합니다." : "제한 없음 — 사용률과 무관하게 항상 사용합니다." : token.provider === "anthropic" ? "5시간 사용률에 적용합니다. 주간은 100%에서만 제외합니다." : "주간 사용률이 임계치에 달하면 해당 토큰을 건너뜁니다."
3258
3254
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3259
3255
  className: "mt-1.5 text-[11px] text-red-500",
3260
3256
  children: validation.error
@@ -3495,12 +3491,17 @@ function SortableTokenCard({ token }) {
3495
3491
  }),
3496
3492
  QUOTA_THRESHOLD_PROVIDERS.has(token.provider) && token.quota_threshold !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
3497
3493
  className: "px-1.5 py-0.5 rounded-full bg-sienna-50 text-[10px] tabular-nums font-medium text-sienna-600",
3498
- title: `사용률 ${token.quota_threshold}% 이상이면 이 토큰 제외`,
3494
+ title: `${token.provider === "anthropic" ? "5시간" : "주간"} 사용률 ${token.quota_threshold}% 이상이면 이 토큰 제외`,
3499
3495
  children: [
3500
3496
  "≤ ",
3501
3497
  token.quota_threshold,
3502
3498
  "%"
3503
3499
  ]
3500
+ }),
3501
+ token.provider === "grok" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3502
+ className: "px-1.5 py-0.5 rounded-full bg-sienna-50 text-[10px] tabular-nums font-medium text-sienna-600",
3503
+ title: "주간 사용률 100%에서 이 토큰 제외",
3504
+ children: "7d 100%"
3504
3505
  })
3505
3506
  ]
3506
3507
  }),
@@ -3514,7 +3515,7 @@ function SortableTokenCard({ token }) {
3514
3515
  token.reauth_required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReloginButton, { token }),
3515
3516
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1" }),
3516
3517
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WeightControl, { token }),
3517
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThresholdControl, { token })
3518
+ token.provider !== "grok" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThresholdControl, { token })
3518
3519
  ]
3519
3520
  })
3520
3521
  ]
@@ -53085,7 +53085,7 @@ function ChatWidget() {
53085
53085
  }
53086
53086
  //#endregion
53087
53087
  //#region src/components/Sidebar.tsx
53088
- var qgridVersion = "2.13.1";
53088
+ var qgridVersion = "2.14.1";
53089
53089
  function Sidebar({ className }) {
53090
53090
  const pathname = useRouterState({ select: (s) => s.location.pathname });
53091
53091
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
@@ -55280,7 +55280,7 @@ function RootComponent() {
55280
55280
  }
55281
55281
  //#endregion
55282
55282
  //#region src/routes/index.tsx
55283
- var $$splitComponentImporter$5 = () => import("./assets/routes-CjWxvHAO.js");
55283
+ var $$splitComponentImporter$5 = () => import("./assets/routes-CCdBJqP_.js");
55284
55284
  var Route$5 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter$5, "component") });
55285
55285
  //#endregion
55286
55286
  //#region src/services/sonamu.generated.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartanova/qgrid-cli",
3
- "version": "2.13.1",
3
+ "version": "2.14.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cartanova-ai/qgrid"
@@ -44,9 +44,10 @@ Anthropic tokens live in an in-memory `Map<tokenId, PooledToken>`.
44
44
 
45
45
  Quota threshold:
46
46
 
47
- - `quota_threshold` checks `five_hour.utilization` for every model and also checks
48
- `seven_day_overage_included.utilization` for the Fable family (Fable 5 and 5.1,
49
- `isFableFamilyModel` in `anthropic-constants.ts`), using the higher utilization.
47
+ - `quota_threshold` applies only to `five_hour.utilization`. Shared `seven_day.utilization`
48
+ and the Fable family's `seven_day_overage_included.utilization` exclude tokens only at 100%.
49
+ Weekly exhaustion is checked even without a configured threshold. Keepalive uses the same
50
+ policy, so a 5-hour utilization of 0% and weekly utilization of 92% passes an 80% threshold.
50
51
  - A runtime quota-exhausted result invalidates every 60-second usage-cache key used before and
51
52
  after a possible OAuth refresh, so the next untargeted request rechecks usage and can select
52
53
  another token.
@@ -174,9 +174,10 @@ Key decisions:
174
174
  - The token subscriber disables statement/idle timeouts for `LISTEN` and uses reconnect backoff.
175
175
  - `quota_threshold` is a routing guardrail, not a load balancer. It prevents an individual token from crossing a configured utilization percentage; it does not equalize traffic.
176
176
  - Threshold values are nullable integers from 1 to 100. `0` is not valid; `100` means exclude only at full utilization.
177
- - Provider criteria differ by primary window: Anthropic uses `five_hour.utilization` plus the
178
- Fable-only `seven_day_overage_included.utilization` when applicable; OpenAI uses
179
- `primary.usedPercent`.
177
+ - Provider criteria differ by quota window: Anthropic applies the configured threshold only to
178
+ `five_hour.utilization`; shared and Fable-specific weekly usage block only at 100%. Grok has
179
+ only weekly usage and blocks at 100% regardless of its stored threshold. OpenAI applies the
180
+ configured threshold to `primary.usedPercent`, currently its weekly window.
180
181
  - Threshold gates are by token id, not token name. Names are display/logging labels and can change.
181
182
  - Token window keepalive is opt-in at two levels since 2.8.0 (`ea7feb3`): an instance fires only with env `QGRID_TOKEN_WINDOW_KEEPALIVE_ENABLED=true`, and only for tokens with `keepalive_enabled = true`. The runner gate exists because developer instances sharing the production DB fired duplicate pings under the 2.7.6 default-on switch; the per-token flag lets shared or credit-metered accounts stay out. The cost is that upgrades start with zero targets until both are set.
182
183
  - Lookup failure is fail-open with logs/metrics. Hard failure happens only when usage was read successfully and the token is over threshold.
@@ -47,7 +47,10 @@ Refresh starts 300 seconds plus stable 0–60 second per-account jitter before e
47
47
 
48
48
  The response is protobuf JSON, which omits zero-valued scalars: a period without measurable usage arrives without `creditUsagePercent`, so qgrid reads the missing field as 0%. Observed on a Free account on 2026-10-21, where the field stayed absent even after a small request. The period is fixed (it existed before the token's first request and did not move after one), so token-window keepalive does not apply to Grok; xAI documents one weekly pool and no short rolling window.
49
49
 
50
- Dashboard usage (`QgridFrame.usage`) calls the dispatcher's `refreshUsage`, which runs the same prefetch with billing included even when no quota threshold is set, and waits up to 3 seconds for it. Without this, a token that never routed a request since boot reported no usage. The 60-second lookup cache bounds the extra xAI calls.
50
+ Every routing prefetch reads billing, even without a configured threshold. Grok exposes only weekly
51
+ usage: accounts are excluded at 100%, and the stored configurable threshold is not applied.
52
+ Dashboard usage (`QgridFrame.usage`) calls the same prefetch through `refreshUsage` and waits up to
53
+ 3 seconds. The 60-second lookup cache bounds the xAI calls.
51
54
 
52
55
  D6 excludes accounts when `/settings.on_demand_enabled` is `true`; `null`, `false`, or absence allows routing. Billing does not carry this field. D7 selects eligible accounts through the shared `SmoothWeightedRoundRobin`, using `tokens.weight`; a valid cache-affinity token remains preferred. `QGRID_GROK_MAX_INFLIGHT_PER_TOKEN` optionally excludes accounts at the cap, while omission leaves Grok uncapped (`grok-quota.ts`, `grok-dispatcher.ts`, `packages/api/src/utils/providers/common/smooth-weighted-round-robin.ts`).
53
56
 
@@ -78,6 +81,12 @@ Provider `cost_in_usd_ticks` is authoritative, including zero; one tick is `1e-1
78
81
 
79
82
  Qgrid exposes image generation/editing, asynchronous video start/status, transcription, and speech through `api.x.ai`. Reference images select `/images/edits`; video uses `/videos/generations` and `/videos/{request_id}`; voice uses multipart `/stt` and JSON `/tts` (`grok-media-client.ts`, `grok-voice-client.ts`, `packages/api/src/application/qgrid/qgrid.frame.ts`).
80
83
 
84
+ Image generation and editing default to `grok-imagine-image-2.0`; the public SDK lists it and
85
+ `grok-imagine-image` (1.0). Quality omission passes through as upstream `auto`, currently low for
86
+ generation and medium for editing. Reported ticks remain authoritative. Without ticks, image cost
87
+ uses the active model's output resolution/quality and input-image count at the official API rates
88
+ (verified 2026-10-25). Unknown price combinations remain unknown; retired models have no estimate.
89
+
81
90
  Chat turns also accept `imageGeneration` (the dashboard chat sends `"auto"`): the dispatcher adds the proxy's server-side `{ "type": "image_generation" }` tool, and completed `image_generation_call` items (base64 JPEG, Grok Imagine) become `GenerateResult.images`, so generation and edits of earlier images work inside a conversation. `imageGenerationOptions` (OpenAI quality/size/background) is rejected. The turn's provider-reported cost already includes the image, so the request log stores `image_cost_usd = 0` with `image_cost_method = "included:grok-provider-cost"`. Verified 2026-10-21 through the subscription proxy; the model occasionally answers "I'll do it" without calling the tool (1 of 5 edit attempts).
82
91
 
83
92
  Inline audio, each inline image, and the aggregate inline images in one request are capped at 7 MiB decoded. The server maps Fastify's oversized-body error to HTTP 413 (`packages/api/src/application/qgrid/qgrid.types.ts`, `qgrid.frame.ts`).
@@ -78,6 +78,10 @@ Chat model presets: the model `<select>` lists the served subset of `QgridSuppor
78
78
 
79
79
  The monit tab's vitals strip shows per-provider in-flight counts, an in-flight sparkline, token chips with quota gauges (fed by the dispatcher's 60-second rate-limits cache; `resetsAt` arrives as ms epoch), and a 1-hour per-provider request/error/cache-hit stats line polled separately every 30 seconds.
80
80
 
81
+ Quota controls match provider policy: Anthropic edits its 5-hour threshold and shows a fixed 100%
82
+ weekly cap; OpenAI edits its weekly primary-window threshold. Grok has only a fixed 100% weekly cap
83
+ and no threshold editor. Disabling the Anthropic threshold does not disable weekly exhaustion checks.
84
+
81
85
  Current-turn input images render in the detail view under the user prompt from `request_logs.input_images` (subset `A` only, not the list subset). Logs created before that column fall back to the first synthetic `image_generation` step's `tool_args.inputImages`. Keep the prompt itself text-only, redact large base64 in request JSON views, and avoid rendering duplicate input previews for multi-output image turns.
82
86
 
83
87
  ## Verification
@@ -140,8 +140,9 @@ Usage/quota:
140
140
 
141
141
  - Usage API is `https://api.anthropic.com/api/oauth/usage`.
142
142
  - qgrid caches Anthropic usage by access-token suffix for 60 seconds.
143
- - Quota threshold uses `five_hour.utilization`; Fable family models (Fable 5 and 5.1) additionally
144
- use the usage-credit `seven_day_overage_included.utilization`, and either window can exclude the token.
143
+ - The configured quota threshold applies only to `five_hour.utilization`. The shared
144
+ `seven_day.utilization` and Fable-only `seven_day_overage_included.utilization` block only at
145
+ 100%, independently of the configured threshold.
145
146
  - Usage lookup failure is fail-open for routing.
146
147
 
147
148
  ## OpenAI OAuth And Refresh Flow
@@ -273,7 +274,10 @@ When a refresh fails in a way that only re-login can fix, qgrid removes the toke
273
274
 
274
275
  `quota_threshold` is a routing gate, not a hard external-provider guarantee.
275
276
 
276
- - Null means no threshold gate.
277
+ - Null disables the configurable threshold, but Anthropic and Grok still check weekly exhaustion.
278
+ - Anthropic applies the configured threshold to 5-hour usage and a fixed 100% cap to weekly usage.
279
+ - Grok exposes only weekly usage and uses a fixed 100% cap; its stored threshold is not applied.
280
+ - OpenAI applies the configured threshold to its primary usage window, currently weekly.
277
281
  - Lookup failure is fail-open.
278
282
  - Individual over-threshold tokens are excluded from selection.
279
283
  - OpenAI keeps this exclusion as an in-memory `quota-blocked` runtime state without changing the
@@ -282,7 +286,7 @@ When a refresh fails in a way that only re-login can fix, qgrid removes the toke
282
286
  `recovered` once a later quota check falls below the threshold. Metadata generations prevent an
283
287
  in-flight lookup from restoring a block after a threshold or lifecycle change. The state is not
284
288
  persisted across server restarts.
285
- - Grok also keeps threshold and exhaustion blocks in memory. Its exhaustion block is request-class
289
+ - Grok also keeps weekly-cap and exhaustion blocks in memory. Its exhaustion block is request-class
286
290
  scoped, and `/settings.on_demand_enabled = true` independently excludes the entire account
287
291
  (`packages/api/src/utils/providers/grok/grok-dispatcher.ts`).
288
292
  - If all ready/eligible tokens are over threshold, qgrid throws `QuotaThresholdExceededError`.