@cartanova/qgrid-cli 2.11.1 → 2.12.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.
Files changed (61) hide show
  1. package/bundle/dist/application/qgrid/qgrid-response-format.js +9 -1
  2. package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +28 -4
  3. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +7 -4
  4. package/bundle/dist/application/qgrid/qgrid.frame.js +25 -4
  5. package/bundle/dist/application/request-log/request-log.model.js +5 -1
  6. package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +7 -2
  7. package/bundle/dist/utils/providers/anthropic/claude-session.js +10 -2
  8. package/bundle/dist/utils/providers/grok/grok-backend-protocol.js +1 -1
  9. package/bundle/dist/utils/providers/grok/grok-dispatcher.js +43 -12
  10. package/bundle/dist/utils/providers/grok/grok-types.js +2 -2
  11. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +9 -3
  12. package/bundle/src/application/qgrid/qgrid-response-format.ts +9 -0
  13. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +63 -0
  14. package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +49 -7
  15. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +6 -0
  16. package/bundle/src/application/qgrid/qgrid.frame.test.ts +9 -2
  17. package/bundle/src/application/qgrid/qgrid.frame.ts +39 -3
  18. package/bundle/src/application/request-log/request-log.model.ts +11 -0
  19. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +2 -0
  20. package/bundle/src/utils/providers/anthropic/claude-session.ts +15 -1
  21. package/bundle/src/utils/providers/common/provider-dispatcher.ts +10 -0
  22. package/bundle/src/utils/providers/grok/grok-backend-protocol.ts +6 -1
  23. package/bundle/src/utils/providers/grok/grok-dispatcher.test.ts +74 -3
  24. package/bundle/src/utils/providers/grok/grok-dispatcher.ts +66 -18
  25. package/bundle/src/utils/providers/grok/grok-quota.test.ts +18 -0
  26. package/bundle/src/utils/providers/grok/grok-types.ts +2 -1
  27. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +18 -0
  28. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +10 -2
  29. package/bundle/web-dist/client/assets/{index-C96h3feE.js → index-CK9LwGNV.js} +3 -3
  30. package/bundle/web-dist/client/assets/logs-DjQcEivP.js +1 -0
  31. package/bundle/web-dist/client/assets/{monit-BBjXa7vB.js → monit-RTxpU7oZ.js} +1 -1
  32. package/bundle/web-dist/client/assets/{request-model-Bpp_rkK8.js → request-model-DliRuPcw.js} +1 -1
  33. package/bundle/web-dist/client/assets/routes-DVHoo-YF.js +5 -0
  34. package/bundle/web-dist/client/assets/{settings-Cdwm3OBB.js → settings-BQUz6UFr.js} +1 -1
  35. package/bundle/web-dist/client/assets/{show-DBUhALT1.js → show-CalQG1Ew.js} +2 -2
  36. package/bundle/web-dist/client/assets/{tokens-CVQAVJTo.js → tokens-DU4fWXI9.js} +1 -1
  37. package/bundle/web-dist/client/index.html +1 -1
  38. package/bundle/web-dist/server/assets/{logs-B7QmGJq3.js → logs-B5M5B7pN.js} +32 -14
  39. package/bundle/web-dist/server/assets/{monit-DFt7x3bh.js → monit-p6JM8MMl.js} +1 -1
  40. package/bundle/web-dist/server/assets/{request-model-eHE6YbaF.js → request-model-Cp6h5EuP.js} +1 -1
  41. package/bundle/web-dist/server/assets/{routes-_Y-PJfgO.js → routes-rIXpkI-t.js} +4 -19
  42. package/bundle/web-dist/server/assets/{settings-JwJKxn2e.js → settings-_MoaFGxj.js} +1 -1
  43. package/bundle/web-dist/server/assets/{show-BEv6z1v_.js → show-Cfm9UeDr.js} +9 -3
  44. package/bundle/web-dist/server/assets/{tokens-CNT4mI-f.js → tokens-DMSHDg9D.js} +1 -1
  45. package/bundle/web-dist/server/entry-server.generated.js +54 -38
  46. package/package.json +1 -1
  47. package/skills/qgrid/references/ai-sdk-provider-contract.md +1 -1
  48. package/skills/qgrid/references/cli-env-and-server-boot.md +4 -3
  49. package/skills/qgrid/references/decision-rationale.md +2 -1
  50. package/skills/qgrid/references/grok-runtime.md +7 -1
  51. package/skills/qgrid/references/repo-map.md +2 -0
  52. package/skills/qgrid/references/request-log-run-lifecycle.md +5 -0
  53. package/skills/qgrid/references/verification-and-debugging.md +24 -5
  54. package/bundle/web-dist/client/assets/logs-DBM6U0QD.js +0 -1
  55. package/bundle/web-dist/client/assets/routes-Crz_PQzi.js +0 -5
  56. package/bundle/web-dist/client/assets/total-cost-MnfKU8IN.js +0 -1
  57. package/bundle/web-dist/server/assets/total-cost-fTE9Xy82.js +0 -18
  58. /package/bundle/web-dist/client/assets/{plus-BsQdY7PS.js → plus-DDvVTvQP.js} +0 -0
  59. /package/bundle/web-dist/client/assets/{refresh-cw-D9IUmT23.js → refresh-cw-CTQsNddA.js} +0 -0
  60. /package/bundle/web-dist/server/assets/{plus-DaYQRpBt.js → plus-I0FfLVgU.js} +0 -0
  61. /package/bundle/web-dist/server/assets/{refresh-cw-BpXNsAy-.js → refresh-cw-DYsnffRC.js} +0 -0
@@ -46249,41 +46249,57 @@ function ChatImagePreview({ url, onClose }) {
46249
46249
  //#region src/components/qgrid/ChatWidget.tsx
46250
46250
  var CHAT_PROJECT_NAME = "qgrid_chat";
46251
46251
  var DEFAULT_MODEL = "anthropic/claude-fable-5-1";
46252
- var MODEL_PRESET_GROUPS = [{
46253
- label: "OpenAI",
46254
- models: [
46255
- "openai/gpt-6-astra",
46256
- "openai/gpt-6.1-sol",
46257
- "openai/gpt-6-sol",
46258
- "openai/gpt-6-luna",
46259
- "openai/gpt-5.6-terra",
46260
- "openai/gpt-5.6-sol",
46261
- "openai/gpt-5.6-luna"
46262
- ]
46263
- }, {
46264
- label: "Anthropic",
46265
- models: [
46266
- "anthropic/claude-fable-5-1",
46267
- "anthropic/claude-fable-5",
46268
- "anthropic/claude-opus-5-5",
46269
- "anthropic/claude-opus-5",
46270
- "anthropic/claude-sonnet-5-5",
46271
- "anthropic/claude-sonnet-5",
46272
- "anthropic/claude-haiku-5-5",
46273
- "anthropic/claude-opus-4-8",
46274
- "anthropic/claude-opus-4-7",
46275
- "anthropic/claude-opus-4-6",
46276
- "anthropic/claude-opus-4-5",
46277
- "anthropic/claude-sonnet-4-6",
46278
- "anthropic/claude-haiku-4-5"
46279
- ]
46280
- }];
46252
+ var MODEL_PRESET_GROUPS = [
46253
+ {
46254
+ label: "OpenAI",
46255
+ models: [
46256
+ "openai/gpt-6-astra",
46257
+ "openai/gpt-6.1-sol",
46258
+ "openai/gpt-6-sol",
46259
+ "openai/gpt-6-luna",
46260
+ "openai/gpt-5.6-terra",
46261
+ "openai/gpt-5.6-sol",
46262
+ "openai/gpt-5.6-luna"
46263
+ ]
46264
+ },
46265
+ {
46266
+ label: "Anthropic",
46267
+ models: [
46268
+ "anthropic/claude-fable-5-1",
46269
+ "anthropic/claude-fable-5",
46270
+ "anthropic/claude-opus-5-5",
46271
+ "anthropic/claude-opus-5",
46272
+ "anthropic/claude-sonnet-5-5",
46273
+ "anthropic/claude-sonnet-5",
46274
+ "anthropic/claude-haiku-5-5",
46275
+ "anthropic/claude-opus-4-8",
46276
+ "anthropic/claude-opus-4-7",
46277
+ "anthropic/claude-opus-4-6",
46278
+ "anthropic/claude-opus-4-5",
46279
+ "anthropic/claude-sonnet-4-6",
46280
+ "anthropic/claude-haiku-4-5"
46281
+ ]
46282
+ },
46283
+ {
46284
+ label: "Grok",
46285
+ models: [
46286
+ "grok/grok-4.7",
46287
+ "grok/grok-4.7-build-fast",
46288
+ "grok/grok-4.6",
46289
+ "grok/grok-4.5"
46290
+ ]
46291
+ }
46292
+ ];
46281
46293
  var EFFORT_PRESETS = [
46282
46294
  "low",
46283
46295
  "medium",
46284
46296
  "high"
46285
46297
  ];
46286
- var PROVIDER_LABELS = new Map([["openai", "OpenAI"], ["anthropic", "Anthropic"]]);
46298
+ var PROVIDER_LABELS = new Map([
46299
+ ["openai", "OpenAI"],
46300
+ ["anthropic", "Anthropic"],
46301
+ ["grok", "Grok"]
46302
+ ]);
46287
46303
  function humanizeError(message, provider, tokens) {
46288
46304
  const missing = tokens !== void 0 && providerTokenMissing(tokens, provider);
46289
46305
  if (/NO_OPENAI_WORKERS|no ready openai workers|no anthropic tokens available/i.test(message) || missing && /기동 중입니다/.test(message)) return `사용 가능한 ${provider ? PROVIDER_LABELS.get(provider) ?? provider : ""} 토큰이 없습니다. Tokens 페이지에서 토큰을 추가해주세요.`;
@@ -46326,7 +46342,7 @@ function ChatWidget() {
46326
46342
  const inputRef = (0, import_react.useRef)(null);
46327
46343
  const fileInputRef = (0, import_react.useRef)(null);
46328
46344
  const provider = model.split("/")[0];
46329
- const supportsImages = provider === "openai";
46345
+ const supportsImages = provider === "openai" || provider === "grok";
46330
46346
  const { data: tokensData } = TokenService.useTokens("A", { orderBy: "ord-asc" }, { enabled: open });
46331
46347
  const tokenOptions = (0, import_react.useMemo)(() => chatTokenOptions(tokensData?.rows ?? [], provider), [provider, tokensData?.rows]);
46332
46348
  const tokenListLoaded = tokensData?.rows !== void 0;
@@ -46868,7 +46884,7 @@ function ChatWidget() {
46868
46884
  }
46869
46885
  //#endregion
46870
46886
  //#region src/components/Sidebar.tsx
46871
- var qgridVersion = "2.11.1";
46887
+ var qgridVersion = "2.12.0";
46872
46888
  function Sidebar({ className }) {
46873
46889
  const pathname = useRouterState({ select: (s) => s.location.pathname });
46874
46890
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
@@ -48712,15 +48728,15 @@ function RootComponent() {
48712
48728
  }
48713
48729
  //#endregion
48714
48730
  //#region src/routes/tokens.tsx
48715
- var $$splitComponentImporter$5 = () => import("./assets/tokens-CNT4mI-f.js");
48731
+ var $$splitComponentImporter$5 = () => import("./assets/tokens-DMSHDg9D.js");
48716
48732
  var Route$5 = createFileRoute("/tokens")({ component: lazyRouteComponent($$splitComponentImporter$5, "component") });
48717
48733
  //#endregion
48718
48734
  //#region src/routes/settings.tsx
48719
- var $$splitComponentImporter$4 = () => import("./assets/settings-JwJKxn2e.js");
48735
+ var $$splitComponentImporter$4 = () => import("./assets/settings-_MoaFGxj.js");
48720
48736
  var Route$4 = createFileRoute("/settings")({ component: lazyRouteComponent($$splitComponentImporter$4, "component") });
48721
48737
  //#endregion
48722
48738
  //#region src/routes/monit.tsx
48723
- var $$splitComponentImporter$3 = () => import("./assets/monit-DFt7x3bh.js");
48739
+ var $$splitComponentImporter$3 = () => import("./assets/monit-p6JM8MMl.js");
48724
48740
  var monitSearchSchema = object({ level: _enum([
48725
48741
  "all",
48726
48742
  "warn",
@@ -49124,7 +49140,7 @@ object({
49124
49140
  _enum(["A"]);
49125
49141
  //#endregion
49126
49142
  //#region src/routes/logs.tsx
49127
- var $$splitComponentImporter$2 = () => import("./assets/logs-B7QmGJq3.js");
49143
+ var $$splitComponentImporter$2 = () => import("./assets/logs-B5M5B7pN.js");
49128
49144
  var logsSearchSchema = object({
49129
49145
  token: string$2().optional(),
49130
49146
  project: string$2().optional(),
@@ -49138,11 +49154,11 @@ var Route$2 = createFileRoute("/logs")({
49138
49154
  });
49139
49155
  //#endregion
49140
49156
  //#region src/routes/index.tsx
49141
- var $$splitComponentImporter$1 = () => import("./assets/routes-_Y-PJfgO.js");
49157
+ var $$splitComponentImporter$1 = () => import("./assets/routes-rIXpkI-t.js");
49142
49158
  var Route$1 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter$1, "component") });
49143
49159
  //#endregion
49144
49160
  //#region src/routes/requests/show.tsx
49145
- var $$splitComponentImporter = () => import("./assets/show-BEv6z1v_.js");
49161
+ var $$splitComponentImporter = () => import("./assets/show-Cfm9UeDr.js");
49146
49162
  var showSearchSchema = object({ id: number$1() });
49147
49163
  var Route = createFileRoute("/requests/show")({
49148
49164
  validateSearch: showSearchSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartanova/qgrid-cli",
3
- "version": "2.11.1",
3
+ "version": "2.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cartanova-ai/qgrid"
@@ -167,7 +167,7 @@ Payload responsibilities:
167
167
  - Preserve and resend `runContext` for tool-call follow-ups.
168
168
  - Let the server infer single-turn completion versus an open tool-call run. Logging-disabled tool calls still use the SDK's local pending-call correlation and continue without a request-log id.
169
169
  - Derive/store/resend opaque OpenAI affinity coordinates by `sessionKey`.
170
- - For `openai/` language models, send user-message image/file parts as image input: the current turn goes in qgrid `input` (text + image data/HTTP URLs) and earlier user turns as history `input_image`. The same JSON-transport size guard applies. Drop assistant image parts, and all image parts for `anthropic/` models (the Claude Code path is text-only), and report each drop as an AI SDK `unsupported` warning (`feature: "image input"`) in `warnings`, not only on the console.
170
+ - For `openai/` and `grok/` language models, send user-message image/file parts as image input: the current turn goes in qgrid `input` (text + image data/HTTP URLs) and earlier user turns as history `input_image`. The same JSON-transport size guard applies. `grok/` keeps only `https:` and `data:` URLs (the backend cannot fetch `http:`) and sniffs bytes sent as `image/*`; other providers use the shared extractor. Drop assistant image parts, and all image parts for `anthropic/` models (the Claude Code path is text-only), and report each drop as an AI SDK `unsupported` warning (`feature: "image input"`) in `warnings`, not only on the console.
171
171
  - The separate image provider converts `generateImage` prompt references to qgrid `input` and rejects oversized inline reference images before transport. Callers should compress/resize large reference photos, preferably to WebP/JPEG.
172
172
 
173
173
  Tools and `jsonSchema` can be used together as of qgrid 2.5.4. On OpenAI the
@@ -47,9 +47,10 @@ Sonamu's native `SONAMU_DB_HOST`, `SONAMU_DB_PORT`, `SONAMU_DB_USER`,
47
47
 
48
48
  Do not treat CLI bundle bootstrapping internals as user-facing qgrid configuration.
49
49
  The packaged CLI accepts only `staging` and `production`; `development` and `test`
50
- require the source workspace. Sonamu 0.10.3 also requires `.env` or
51
- `.env.<NODE_ENV>` to exist at the API root. Source deployments must retain one of
52
- those files, while the npm CLI bundle carries an empty `.env` marker itself.
50
+ require the source workspace. Sonamu (0.10.3 and later, including 0.11) also requires `.env` or
51
+ `.env.<NODE_ENV>` to exist at the API root, even for `sonamu build`, which reads no values from it.
52
+ Source deployments and CI builds must provide one of those files (an empty file is enough), while
53
+ the npm CLI bundle carries an empty `.env` marker itself.
53
54
 
54
55
  ## SDK/client env vars
55
56
 
@@ -241,6 +241,7 @@ Key decisions:
241
241
  - The CLI checks runtime CLIs (`codex`, `claude`) because qgrid delegates provider execution to those local binaries.
242
242
  - The dashboard version should follow the CLI package version because the dashboard is shipped by the CLI bundle, not as an independently versioned web product.
243
243
  - qgrid skills ship with the CLI package, not a separate skills package. qgrid cannot be used with the AI SDK alone; a local qgrid CLI server is required, so CLI install is the right moment to sync `.agents/skills/qgrid` and `.claude/skills/qgrid` into the consuming project.
244
+ - Sonamu 0.11 (2.11.0) keeps qgrid-side workarounds instead of pinning back: the API build sets `NODE_ENV=production` (SON-567), CI creates an empty `packages/api/.env`, and `.oxlintrc.json` disables `no-unnecessary-type-assertion` for Sonamu's lint temp files (SON-564). Remove each workaround once the matching Sonamu issue ships. Peer ranges that upstream packages have not widened yet are allowed per parent in `pnpm-workspace.yaml` `peerDependencyRules.allowedVersions`, with the reason next to each entry.
244
245
 
245
246
  ## Image Generation
246
247
 
@@ -258,7 +259,7 @@ Key decisions:
258
259
  - It is non-stream only. Codex returns completed base64 image payloads, not useful image deltas.
259
260
  - Image turns send full input directly and retain no provider conversation state. This prevents base64 payloads from entering reusable state.
260
261
  - qgrid performs preflight capability/model gates. Raw `imageGeneration: true` requires an image; `"auto"` allows normal text replies but still rejects attempted image generation without a completed image. Public `generateImage` requires one direct Images output per provider call; AI SDK batches requests for `n` outputs.
261
- - Raw returned images are inline base64 content parts. The image SDK maps them to AI SDK `image`/`images` and takes references through standard `prompt: { text, images }`, with JSON data URL size guarding and HTTPS reference URL support. The language SDK forwards user-message images to `openai/` models as image input (image→text) and drops other image parts with an AI SDK `unsupported` warning.
262
+ - Raw returned images are inline base64 content parts. The image SDK maps them to AI SDK `image`/`images` and takes references through standard `prompt: { text, images }`, with JSON data URL size guarding and HTTPS reference URL support. The language SDK forwards user-message images to `openai/` and `grok/` models as image input (image→text) and drops other image parts with an AI SDK `unsupported` warning.
262
263
  - Raw/server `imageGenerationOptions` supports quality, size, and background. The public image SDK uses flat `QgridImageProviderOptions` and standard top-level `size`. The subscription backend can ignore size and quality hints. Put desired ratios in the prompt, report observed output settings, and never silently resize. Reported image usage is priced at public token rates; without it, use the requested quality/size table with a default-size price for auto/custom hints. Preserve observed settings separately from pricing assumptions. No background-removal fallback is allowed.
263
264
  - qgrid does not manage generated or reference images as durable assets through a `generated_images` table or object-storage layer. Current request logs can still contain inline image data URLs for inspection and synthetic `image_generation` tool-call steps; current-turn input images (image→text and image references) live in `request_logs.input_images`; older image-generation logs keep them only in the first synthetic step's `tool_args.inputImages`.
264
265
  - Image cost is stored separately in `request_logs.image_cost_usd`; `request_logs.cost_usd` remains the Codex driver model token cost. Image costs use reported image usage at public token rates, or per-image quality/size estimates when usage is absent. Auto/custom sizes fall back to the 1536x1024 price; omitted quality uses medium. Rows and totals display combined costs as dollar amounts without Cost labels, without Known/Estimated labels or pricing disclaimers. Existing stored null costs are not backfilled; `totalCost.unknownImageCostCount` remains for API compatibility.
@@ -45,6 +45,10 @@ Refresh starts 300 seconds plus stable 0–60 second per-account jitter before e
45
45
 
46
46
  `/billing?format=credits` is camelCase: qgrid reads `config.creditUsagePercent`, `config.currentPeriod`, and `config.prepaidBalance.val`. The observed period was seven days anchored at subscription start. Results are cached for 60 seconds; lookup failure fails open (`grok-quota.ts`, `grok-dispatcher.ts`, `docs/diagnosis/2026-10-16-grok-live-probe.md`).
47
47
 
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
+
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.
51
+
48
52
  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`).
49
53
 
50
54
  ## Failure and failover rules
@@ -74,9 +78,11 @@ Provider `cost_in_usd_ticks` is authoritative, including zero; one tick is `1e-1
74
78
 
75
79
  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`).
76
80
 
81
+ 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
+
77
83
  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
84
 
79
- Video starts return a random 128-bit in-memory job handle. Handles expire after 24 hours, polling stays pinned to the starting token, and `projectName` must match the owner supplied at start. D4 returns the upstream `api.x.ai` video URL unchanged; qgrid does not fetch, proxy, or store the bytes (`qgrid.frame.ts`, `grok-media-client.ts`, `packages/ai-sdk/README.md`).
85
+ Video starts return a random 128-bit in-memory job handle. Handles expire after 24 hours, polling stays pinned to the starting token, and `projectName` must match the owner supplied at start. A started job is already admitted and billed, so `getVideo` polls with `ungated: true`: it checks only credential state (inactive, reauth, refresh failure) and skips the quota-threshold, cooldown, in-flight, on-demand, and ZDR gates that admit new requests. After the upstream poll returns, `videoStatus` re-checks `job.final`, so overlapping polls of a finished job write the request log once and return the same result. D4 returns the upstream `api.x.ai` video URL unchanged; qgrid does not fetch, proxy, or store the bytes (`qgrid.frame.ts`, `grok-media-client.ts`, `packages/ai-sdk/README.md`).
80
86
 
81
87
  **ZDR and video.** xAI refuses `POST /v1/videos/generations` for Zero Data Retention accounts with HTTP 400 `invalid_request`: "Zero Data Retention teams must provide output.upload_url for video generation." The dispatcher therefore keeps a per-token `zdr` state and excludes `zdr === true` tokens from video only; chat, image, STT, and TTS still route. The primary signal is `codingDataRetentionOptOut` on `GET /user?include=subscription`, re-read on the 60 s prefetch with settings; `x-zero-data-retention: true` on a chat-proxy response confirms it, but its absence never clears it. Unknown state, or a failed `/user` read with no prior value, routes (fail open). If a video start still gets the ZDR 400, the token is marked ZDR, video is entitlement-blocked for an hour, and the start fails over under the media rules. With no eligible video token the caller gets `GrokZdrVideoUnavailableError` (HTTP 503) naming the tokens; usage exposes `zdrVideoExcluded`. Both signals were inferred from one account (plan §11). grok-build's remedy, a user-owned S3 presigned `output.upload_url`, is not implemented (`grok-dispatcher.ts`, `grok-quota.ts`).
82
88
 
@@ -9,6 +9,8 @@ Use this map to orient qgrid work quickly.
9
9
  - `packages/web`: dashboard UI. Usually depends on Sonamu-generated API clients and API model shape.
10
10
  - `packages/cli`: global `qgrid` command, bundled server boot, dependency checks, DB preflight, and qgrid Codex/Claude Code skill sync. The CLI package ships `skills/qgrid` and its `postinstall` links it into consuming projects.
11
11
  - `scripts` and `packages/api/scripts`: smoke tests, debug scripts, runtime probes.
12
+ - `tools/oxlint/anti-slop`: vendored anti-slop oxlint JS plugin, loaded from `.oxlintrc.json` and enforced by `mise run check`. `@oxlint/plugins` must match the installed `oxlint` version.
13
+ - Toolchain: Sonamu 0.11 (CLI in `@sonamu-kit/cli`) and its required TypeScript `7.1.0-dev.20260831.1` in the root, api, cli, and web packages. `packages/ai-sdk` stays on TypeScript 5.9 because tsdown needs the TypeScript JS API to emit its `.d.ts`; `packages/cli` disables dts because it ships only a binary. Web `tsconfig.json` is a references-only solution file pointing at `tsconfig.app.json`, because Sonamu's web typecheck runs each project reference.
12
14
  - `docs`: local planning, diagnosis, and solution history. `docs/WORKFLOW.md` is the collaboration convention.
13
15
 
14
16
  ## Deprecated/context-only package
@@ -31,6 +31,8 @@ A tool-result follow-up carries the returned `runContext` and tool results. The
31
31
 
32
32
  Errors and client aborts finish the same parent as `error` or `aborted` and roll up usage, cost, fallback count, and cost provenance from every generate step that completed before termination. SSE client closure is authoritative regardless of the provider's abort error text; if a provider result arrives after closure, record its step usage and then leave the parent `aborted` without publishing `done`.
33
33
 
34
+ While the provider runs, dispatchers report facts as soon as they are known through `GenerateRequest.onProgress`, and `runProgressRecorder` writes them onto the parent only while it is still `running` (`RequestLogModel.recordRunProgress`): `token_name` after token selection (again on failover), `model_name` when the provider names the serving model (Grok `response.created`; Anthropic records the requested model at selection; OpenAI reports its model only at completion), and `ttft_ms` at the first delta of the run's first step. Writes are ordered and best-effort: a failure only logs. Usage, tokens, cost, and duration arrive with the final usage and stay at their defaults until then. The dashboard shows running rows with the requested → serving model and a running badge, and the list and detail pages poll every 3 seconds while a run is in progress.
35
+
34
36
  Creating the initial `running` row is a precondition for a logger-enabled provider call. Once the provider has succeeded, however, a failure while appending or finalizing logs is best-effort: report the logging error and preserve the generated text/stream result instead of making logging failure replace a successful model result.
35
37
 
36
38
  Stale cleanup must target old runs that still have unresolved tool-call steps; a long provider request with no pending tool call is not stale merely because its parent row is still running. Cleanup and arriving tool follow-ups share a PostgreSQL transaction advisory lock per request-log id and recheck the unresolved step after acquiring it, so cleanup cannot overwrite an in-flight follow-up across server processes.
@@ -128,6 +130,9 @@ TTFT is tracked by wrapping the first provider delta:
128
130
 
129
131
  - OpenAI: first `response.output_text.delta` from the direct Responses stream.
130
132
  - Anthropic: first text or structured partial JSON delta.
133
+ - Grok: first text delta of the chat attempt.
134
+
135
+ The same first-delta value is reported as run progress, so a running row shows TTFT before the response completes; the final value replaces it.
131
136
 
132
137
  If missing, qgrid maps TTFT to `0` in `QueryOutput` and nullable/optional places as appropriate.
133
138
 
@@ -23,7 +23,7 @@ project, use that project's configured task and tool runner.
23
23
 
24
24
  Root:
25
25
 
26
- - `mise run check`: qgrid docs consistency, oxlint, and oxfmt check for the repo.
26
+ - `mise run check`: qgrid docs consistency, oxlint (including the vendored anti-slop rules in `tools/oxlint/anti-slop`, loaded by `.oxlintrc.json`), and oxfmt check for the repo. `mise run format` applies the auto-fixable rules, such as the blank-line spacing rule.
27
27
  - `mise run test`: DB-free API tests, SDK tests, and CLI packaging tests. No provider credentials are needed; the OAuth relay test opens a local loopback listener.
28
28
  - `mise run build`: recursive package build.
29
29
  - `mise run dev`: parallel package dev servers.
@@ -35,8 +35,15 @@ API package `qgrid-api`:
35
35
  - `mise exec -- pnpm --filter qgrid-api test`: both suites, unit first.
36
36
  - `mise exec -- pnpm --filter qgrid-api test:watch`: DB-free watch mode; use `test:db --watch` for DB tests.
37
37
  - `mise exec -- pnpm --filter qgrid-api test:coverage`: both suites, with separate `coverage/unit` and `coverage/db` reports.
38
- - `mise exec -- pnpm --filter qgrid-api build`: Sonamu build.
39
- - `mise exec -- pnpm --filter qgrid-api sonamu`: run Sonamu CLI.
38
+ - `mise exec -- pnpm --filter qgrid-api build`: Sonamu build, run as `NODE_ENV=production sonamu build`. Sonamu 0.11 sets `NODE_ENV=development` when it is unset and the web `vite build` child inherits it, which produced a development-mode dashboard bundle in 2.11.0 (SON-567). Keep the explicit `NODE_ENV` until Sonamu fixes it.
39
+ - `mise exec -- pnpm --filter qgrid-api sonamu`: run Sonamu CLI. Since Sonamu 0.11 the `sonamu` binary comes from the `@sonamu-kit/cli` devDependency, not from `sonamu` itself.
40
+
41
+ Sonamu sync after changing models, types, entities, or i18n:
42
+
43
+ 1. Build first (`mise run build` or `sonamu build api`). `sonamu sync` reads models from `dist`, so a stale `dist` silently drops newer `@api` methods from generated services, queries, validators, and `.http` (SON-566).
44
+ 2. Run `HOT=yes mise exec -- pnpm --dir packages/api sonamu sync`. `HOT=yes` loads `src/sonamu.config.ts`; without it Sonamu needs `dist/sonamu.config.js`, which a failed build deletes. Add `--force` only when `sonamu.lock` cannot be trusted, for example right after a merge.
45
+ 3. `sync --force` always prints the "자동 생성한 파일에 대한 변경이 감지되었습니다" drift warning for generated files, even when nothing drifted (SON-565). Re-run plain `sync`; it should print `All files are synced!`.
46
+ 4. Sonamu lints generated code with type-aware autofix in a temp file at the API root, where relative imports do not resolve. That fix strips the required `as unknown as SDReturnType<K>` casts from `sd.generated.ts` (SON-564). The `.oxlintrc.json` override for `**/.sonamu-oxlint-*.ts` turns that rule off; keep it until Sonamu fixes the temp-file location.
40
47
 
41
48
  AI SDK package `@cartanova/qgrid-ai-sdk`:
42
49
 
@@ -154,7 +161,19 @@ Other scripts under `scripts/smoke-test-*` and `scripts/debug-*` are ad hoc prob
154
161
  Generated SSE handlers missing a newly added event field:
155
162
 
156
163
  - Sonamu's service generator reads runtime stream-decorator schemas. A stale API `dist` can keep the old event shape even with `sonamu sync --force`.
157
- - Run `mise exec -- pnpm --dir packages/api sonamu build api`, then `mise exec -- pnpm --dir packages/api sonamu sync --force`. Check the generated handler type and web typecheck; do not hand-edit generated services.
164
+ - Run `mise exec -- pnpm --dir packages/api sonamu build api`, then `HOT=yes mise exec -- pnpm --dir packages/api sonamu sync --force`. Check the generated handler type and web typecheck; do not hand-edit generated services.
165
+
166
+ Dashboard throws `Module "" has been externalized for browser compatibility. Cannot access ".custom"` on load:
167
+
168
+ - The web bundle was built in development mode. `qs` → `side-channel` → `object-inspect` reads `require("./util.inspect").custom`; its `browser` field maps that file to `false`, which Vite turns into a throwing proxy outside production. Rebuild with `NODE_ENV=production` (the API `build` script sets it). A correct client bundle has no "externalized for browser compatibility" string.
169
+
170
+ `Missing Sonamu dotenv file`:
171
+
172
+ - Sonamu 0.11 refuses to start, including `sonamu build`, unless `packages/api/.env` or `.env.<NODE_ENV>` exists. The contents may be empty. CI creates an empty `packages/api/.env` before `mise run build`.
173
+
174
+ `sd.generated.ts` fails `tsc` with `Partial<MergedDictionary>[K] & {}` not assignable to `SDReturnType<K>`:
175
+
176
+ - The generated casts were stripped by Sonamu's post-generation lint (SON-564). Confirm the `.oxlintrc.json` override is present and re-run `HOT=yes ... sonamu sync --force`.
158
177
 
159
178
  `NO_OPENAI_WORKERS`:
160
179
 
@@ -204,7 +223,7 @@ Generated SSE handlers missing a newly added event field:
204
223
 
205
224
  `unsupported` warning with `feature: "image input"`:
206
225
 
207
- - The language adapter dropped image parts: all of them on `anthropic/` models, and assistant-message images on any model. User-message images on `openai/` models are sent as image input. Reference-image editing belongs in `generateImage`'s `prompt: { text, images }`.
226
+ - The language adapter dropped image parts: all of them on `anthropic/` models, and assistant-message images on any model. User-message images on `openai/` and `grok/` models are sent as image input; `grok/` also drops `http:` URLs. Reference-image editing belongs in `generateImage`'s `prompt: { text, images }`.
208
227
 
209
228
  `image generation is not supported on the Anthropic route`:
210
229
 
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-Dw2cE7zH.js";import{l as e,u as t}from"./vendor-tanstack-DRPs09ai.js";import{i as n,r}from"./vendor-react-DH4kUfK2.js";import{E as i,T as a,n as o,o as ee,r as s}from"./services.generated-B5lc3aIC.js";import{i as c,n as l,r as u}from"./index-C96h3feE.js";import{i as d,r as f,t as p}from"./cost-DB3HbU7T.js";import{n as m,t as h}from"./total-cost-MnfKU8IN.js";import{t as g}from"./refresh-cw-D9IUmT23.js";import{n as _,t as v}from"./request-model-Bpp_rkK8.js";n();var y=r(),b=e=>(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,y.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m15 18l-6-6l6-6`})}),x=e=>(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,y.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m9 18l6-6l-6-6`})}),S=50,C=`__unassigned__`;function w(e){let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function T(e){return e.toLocaleString()}function E(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function D({status:e,requestedModel:t,servedModel:n,imageCostMethod:r,fallbackCount:i}){if(e===`running`)return(0,y.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-600 font-medium whitespace-nowrap`,children:`실행 중`});let a=v({status:e,requestedModel:t,servedModel:n,imageCostMethod:r}),o=t!==null&&n===null;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{className:`text-xs text-sand-500`,children:a.label}),o&&(0,y.jsx)(`span`,{className:`ml-1 text-[9px] text-sand-400`,children:`요청`}),(i??0)>0&&(0,y.jsxs)(`span`,{className:`ml-1 text-[9px] text-caution-500`,children:[`×`,i]})]})}function O(e){return e<=0?`—`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}var k=[{label:`ID`,align:`left`,width:`w-12`,sortKey:`id`},{label:`Date`,align:`left`,width:`w-20`,sortKey:`created_at`},{label:`Project`,align:`left`,width:`w-20`},{label:`Token`,align:`left`,width:`w-24`},{label:`Model`,align:`left`,width:`w-20`},{label:`Fmt`,align:`left`,width:`w-12`},{label:`TTFT`,align:`right`,width:`w-16`,sortKey:`ttft_ms`},{label:`Duration`,align:`right`,width:`w-20`,sortKey:`duration_ms`},{label:`In`,align:`right`,width:`w-16`,sortKey:`input_tokens`},{label:`Out`,align:`right`,width:`w-20`,sortKey:`output_tokens`},{label:`C.Read`,align:`right`,width:`w-20`,sortKey:`cache_read_tokens`},{label:`C.Write`,align:`right`,width:`w-20`,sortKey:`cache_creation_tokens`},{label:`Hit`,align:`right`,width:`w-14`},{label:`Tools`,align:`right`,width:`w-14`},{label:`$`,align:`right`,width:`w-20`,sortKey:`cost_usd`}];function A({search:n,onSearchChange:r}){let i=t(),a=n.page??1,l=n.token??``,u=n.project??``,v=n.model??``,{data:A}=ee.useTokens(`A`),j=(A?.rows??[]).map(e=>e.name).filter(Boolean),{data:M}=o.useProjectNames(),N=M?.names??[],{data:P}=o.useModelNames(),F=P?.names??[],I=u===C?{project_name_is_null:!0}:u?{project_name:u}:{},L={};l&&(L.token_name=l),Object.assign(L,I),v&&(L.model_name=v);let R=n.sort??`id-desc`,z=R.lastIndexOf(`-`),B=R.slice(0,z),V=R.slice(z+1)===`asc`?`asc`:`desc`,{data:H,isLoading:U,isError:W,refresh:G,isRefreshing:K}=s.useRequestLogs(`P`,{num:S,page:a,orderBy:R,...L}),{data:q,isError:J,refresh:Y}=o.useTotalCost({num:0,page:1,...L}),X=H?.rows??[],Z=H?.total??0,Q=Math.ceil(Z/S),$=e=>{r({...n,...e,page:1})};return(0,y.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`panel-header flex items-center gap-2 px-3 py-2.5 flex-wrap sm:gap-3 sm:px-5`,children:[(0,y.jsxs)(`select`,{value:l,onChange:e=>$({token:e.target.value||void 0}),disabled:j.length===0,className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300 disabled:text-sand-300 disabled:cursor-not-allowed`,children:[(0,y.jsx)(`option`,{value:``,children:j.length>0?`All Tokens`:`Tokens —`}),j.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))]}),(0,y.jsxs)(`select`,{value:u,onChange:e=>$({project:e.target.value||void 0}),className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300`,children:[(0,y.jsx)(`option`,{value:``,children:`All Projects`}),(0,y.jsx)(`option`,{value:C,children:`(unassigned)`}),N.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))]}),(0,y.jsxs)(`select`,{value:v,onChange:e=>$({model:e.target.value||void 0}),disabled:F.length===0,className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300 disabled:text-sand-300 disabled:cursor-not-allowed`,children:[(0,y.jsx)(`option`,{value:``,children:F.length>0?`All Models`:`Models —`}),F.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))]}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>void Promise.all([G(),Y()]),disabled:K,"aria-label":`Reload`,title:`Reload`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,children:(0,y.jsx)(g,{className:K?`size-3.5 animate-spin`:`size-3.5`})}),(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsxs)(`span`,{className:`text-[11px] text-sand-400`,children:[W||!H?`—`:Z,` results`]}),J?(0,y.jsx)(`span`,{role:`alert`,className:`text-[11px] text-danger-500`,children:`Failed to load total cost.`}):(0,y.jsxs)(`span`,{className:`text-[11px] tabular-nums font-medium text-sienna-600`,children:[q?d(q.usd):`—`,q&&h(q)?(0,y.jsx)(`span`,{className:`ml-1 font-normal text-sand-400`,title:m(q)??void 0,children:h(q)}):null]})]}),W?(0,y.jsx)(`div`,{role:`alert`,className:`text-danger-500 text-center py-12 text-sm`,children:`Failed to load request logs.`}):U?(0,y.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:5}).map((e,t)=>(0,y.jsx)(`div`,{className:`h-8 bg-sand-100 rounded animate-pulse`},`skel-${t}`))}):X.length===0?(0,y.jsx)(`div`,{className:`text-sand-400 text-center py-12 text-sm`,children:`No requests yet.`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`overflow-x-auto px-3 py-3 sm:px-5`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[900px] text-[13px]`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-sand-100/60`,children:[k.map(e=>{let t=e.label===`Duration`?`pl-5 pr-3`:e.width?`px-4`:`px-3`,n=e.sortKey===B;return(0,y.jsx)(`th`,{className:`${e.align===`right`?`text-right`:`text-left`} ${e.width??``} ${e.width?`whitespace-nowrap`:``} ${t} py-1.5 text-[10px] uppercase font-medium ${n?`text-sienna-600`:`text-sand-400`}`,children:e.sortKey?(0,y.jsxs)(`button`,{type:`button`,onClick:()=>$({sort:c.parse(`${e.sortKey}-${n&&V===`desc`?`asc`:`desc`}`)}),className:`inline-flex items-center gap-0.5 text-[10px] uppercase font-medium hover:text-sienna-500 transition-colors duration-150 ${e.align===`right`?`justify-end w-full`:``}`,children:[e.label,(0,y.jsx)(`span`,{className:n?``:`text-sand-300`,children:n?V===`desc`?`↓`:`↑`:`↕`})]}):e.label},e.label)}),(0,y.jsx)(`th`,{className:`w-8`})]})}),(0,y.jsx)(`tbody`,{className:`divide-y divide-sand-100/60`,children:X.map(t=>(0,y.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer`,onClick:e=>{if(e.metaKey||e.ctrlKey){window.open(`/requests/show?id=${t.id}`,`_blank`);return}i({to:`/requests/show`,search:{id:t.id}})},children:[(0,y.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,y.jsx)(e,{to:`/requests/show`,search:{id:t.id},onClick:e=>e.stopPropagation(),className:`text-xs text-sand-500 tabular-nums hover:text-sienna-500`,children:t.id})}),(0,y.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,y.jsx)(`span`,{className:`text-xs text-sand-400 tabular-nums`,children:w(t.created_at)})}),(0,y.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,y.jsx)(`span`,{className:`text-xs text-sand-600`,children:t.project_name??`—`})}),(0,y.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,y.jsx)(`span`,{className:`text-xs text-sand-500`,children:t.token_name})}),(0,y.jsxs)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:[(0,y.jsx)(D,{status:t.status,requestedModel:t.requested_model_name,servedModel:t.model_name,imageCostMethod:t.image_cost_method,fallbackCount:t.fallback_count}),t.service_tier===`fast`&&(0,y.jsx)(`span`,{title:`Fast 모드`,className:`ml-1 inline-flex align-middle`,children:(0,y.jsx)(_,{"aria-label":`Fast 모드`,className:`size-3 text-[#1877F2] [&_path]:fill-current`})}),t.response_json_ok===!1&&(0,y.jsx)(`span`,{title:`structured 요청의 응답이 JSON 파싱에 실패했습니다`,className:`ml-1.5 rounded-full bg-caution-400/15 px-1.5 py-0.5 text-[9px] font-semibold text-caution-500`,children:`broken`})]}),(0,y.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:t.is_image_generation?(0,y.jsx)(`span`,{className:`rounded bg-sage-100 px-1.5 py-0.5 font-mono text-[10px] text-sage-700`,children:`img`}):t.is_structured?(0,y.jsx)(`span`,{className:`rounded bg-sienna-100 px-1.5 py-0.5 font-mono text-[10px] text-sienna-700`,children:`json`}):(0,y.jsx)(`span`,{className:`font-mono text-[10px] text-sand-400`,children:`text`})}),(0,y.jsx)(`td`,{className:`px-4 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap`,children:O(t.ttft_ms)}),(0,y.jsx)(`td`,{className:`pl-5 pr-3 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap`,children:E(t.duration_ms)}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:T(t.input_tokens)}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:T(t.output_tokens)}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:T(t.cache_read_tokens)}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:T(t.cache_creation_tokens)}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:p(t)}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-500`,children:t.tool_call_count>0?t.tool_call_count:`—`}),(0,y.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700 whitespace-nowrap`,children:f(t)}),(0,y.jsx)(`td`,{className:`px-2 py-1.5`,children:(0,y.jsx)(x,{className:`size-4 text-sand-400`})})]},t.id))})]})}),Q>1&&(0,y.jsxs)(`div`,{className:`flex items-center justify-center gap-3 px-5 py-2.5 border-t border-sand-100/60`,children:[(0,y.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:a===1,onClick:()=>r({...n,page:a-1}),children:(0,y.jsx)(b,{className:`size-4`})}),(0,y.jsxs)(`span`,{className:`text-[11px] text-sand-400 tabular-nums`,children:[a,` / `,Q]}),(0,y.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:a===Q,onClick:()=>r({...n,page:a+1}),children:(0,y.jsx)(x,{className:`size-4`})})]})]})]})}a({token:i().optional(),project:i().optional(),model:i().optional(),sort:c.optional(),page:u.shape.page.default(1)});function j(){let e=l.useSearch(),t=l.useNavigate();return(0,y.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,y.jsx)(A,{search:e,onSearchChange:e=>t({search:e})})})}export{j as component};
@@ -1,5 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{v as t}from"./vendor-tanstack-DRPs09ai.js";import{i as n,n as r,r as i}from"./vendor-react-DH4kUfK2.js";import{n as a,o}from"./services.generated-B5lc3aIC.js";import{i as s,n as c,r as l,t as u}from"./use-oauth-login-flow-BfxYI4Oh.js";import{i as d}from"./cost-DB3HbU7T.js";import{t as f}from"./use-update-token-mutation-qKBC2sn7.js";import{n as p,t as m}from"./total-cost-MnfKU8IN.js";var h=e(r()),g=e(n());function _(){var e=[...arguments];return(0,g.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var v=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function y(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function b(e){return`nodeType`in e}function x(e){return e?y(e)?e:b(e)?e.ownerDocument?.defaultView??window:window:window}function S(e){let{Document:t}=x(e);return e instanceof t}function C(e){return y(e)?!1:e instanceof x(e).HTMLElement}function w(e){return e instanceof x(e).SVGElement}function T(e){return e?y(e)?e.document:b(e)?S(e)?e:C(e)||w(e)?e.ownerDocument:document:document:document}var E=v?g.useLayoutEffect:g.useEffect;function ee(e){let t=(0,g.useRef)(e);return E(()=>{t.current=e}),(0,g.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function te(){let e=(0,g.useRef)(null);return[(0,g.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,g.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function D(e,t){let n=(0,g.useRef)();return(0,g.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function O(e){let t=ee(e),n=(0,g.useRef)(null);return[n,(0,g.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}var k={};function A(e,t){return(0,g.useMemo)(()=>{if(t)return t;let n=k[e]==null?0:k[e]+1;return k[e]=n,e+`-`+n},[e,t])}function j(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var M=j(1),N=j(-1);function P(e){return`clientX`in e&&`clientY`in e}function ne(e){if(!e)return!1;let{KeyboardEvent:t}=x(e.target);return t&&e instanceof t}function F(e){if(!e)return!1;let{TouchEvent:t}=x(e.target);return t&&e instanceof t}function I(e){if(F(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return P(e)?{x:e.clientX,y:e.clientY}:null}var L=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[L.Translate.toString(e),L.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),re={display:`none`};function R(e){let{id:t,value:n}=e;return g.createElement(`div`,{id:t,style:re},n)}function z(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return g.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function B(){let[e,t]=(0,g.useState)(``);return{announce:(0,g.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var ie={draggable:`
2
- To pick up a draggable item, press the space bar.
3
- While dragging, use the arrow keys to move the item.
4
- Press space again to drop the item in its new position, or press escape to cancel.
5
- `},ae={onDragStart(e){return`Picked up draggable item ${e}.`},onDragOver(e,t){return t?`Draggable item ${e} was moved over droppable area ${t}.`:`Draggable item ${e} is no longer over a droppable area.`},onDragEnd(e,t){return t?`Draggable item ${e} was dropped over droppable area ${t}`:`Draggable item ${e} was dropped.`},onDragCancel(e){return`Dragging was cancelled. Draggable item ${e} was dropped.`}},V;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(V||={});function H(...e){}var U=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(({disabled:e})=>!e)}getNodeFor(e){return this.get(e)?.node.current??void 0}},oe=(0,g.createContext)({activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,activeNodeClientRect:null,activators:[],ariaDescribedById:{draggable:``},containerNodeRect:null,dispatch:H,draggableNodes:{},droppableRects:new Map,droppableContainers:new U,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:H},scrollableAncestors:[],scrollableAncestorRects:[],recomputeLayouts:H,windowRect:null,willRecomputeLayouts:!1});function se(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:{},translate:{x:0,y:0}},droppable:{containers:new U}}}function ce(e,t){switch(t.type){case V.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case V.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case V.DragEnd:case V.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case V.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new U(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case V.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new U(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case V.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new U(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}var le=(0,g.createContext)({type:null,event:null});function ue({onDragStart:e,onDragMove:t,onDragOver:n,onDragEnd:r,onDragCancel:i}){let a=(0,g.useContext)(le),o=(0,g.useRef)(a);(0,g.useEffect)(()=>{if(a!==o.current){let{type:s,event:c}=a;switch(s){case V.DragStart:e?.(c);break;case V.DragMove:t?.(c);break;case V.DragOver:n?.(c);break;case V.DragCancel:i?.(c);break;case V.DragEnd:r?.(c);break}o.current=a}},[a,e,t,n,r,i])}function de({announcements:e=ae,hiddenTextDescribedById:t,screenReaderInstructions:n}){let{announce:r,announcement:i}=B(),a=A(`DndLiveRegion`),[o,s]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{s(!0)},[]),ue((0,g.useMemo)(()=>({onDragStart({active:t}){r(e.onDragStart(t.id))},onDragMove({active:t,over:n}){e.onDragMove&&r(e.onDragMove(t.id,n?.id))},onDragOver({active:t,over:n}){r(e.onDragOver(t.id,n?.id))},onDragEnd({active:t,over:n}){r(e.onDragEnd(t.id,n?.id))},onDragCancel({active:t}){r(e.onDragCancel(t.id))}}),[r,e])),o?(0,h.createPortal)(g.createElement(g.Fragment,null,g.createElement(R,{id:t,value:n.draggable}),g.createElement(z,{id:a,announcement:i})),document.body):null}var W=Object.freeze({x:0,y:0});function fe(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function G(e,t=e.offsetLeft,n=e.offsetTop){return{x:t+e.width*.5,y:n+e.height*.5}}var pe=({collisionRect:e,droppableContainers:t})=>{let n=G(e,e.left,e.top),r=1/0,i=null;for(let e of t){let{rect:{current:t}}=e;if(t){let a=fe(G(t),n);a<r&&(r=a,i=e.id)}}return i};function me(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function he(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:W}function ge(e){return function(t,...n){return n.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x,offsetLeft:t.offsetLeft+e*n.x,offsetTop:t.offsetTop+e*n.y}),{...t})}}var _e=ge(1);function K(e,t=window.getComputedStyle(e)){return t.position===`fixed`}function ve(e,t=window.getComputedStyle(e)){let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].find(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})!=null}function ye(e){let t=[];function n(e){if(!e)return t;if(S(e)&&e.scrollingElement!=null&&!t.includes(e.scrollingElement))return t.push(e.scrollingElement),t;if(!C(e)||w(e)||t.includes(e))return t;let r=window.getComputedStyle(e);return ve(e,r)&&t.push(e),K(e,r)?t:n(e.parentNode)}return e?n(e.parentNode):t}function be(e){return!v||!e?null:y(e)?e:b(e)?S(e)||e===T(e).scrollingElement?window:C(e)?e:null:null}function xe(e){return y(e)?{x:e.scrollX,y:e.scrollY}:{x:e.scrollLeft,y:e.scrollTop}}var q;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(q||={});function J(e){let t={x:0,y:0},n={x:e.scrollWidth-e.clientWidth,y:e.scrollHeight-e.clientHeight};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=n.y,isRight:e.scrollLeft>=n.x,maxScroll:n,minScroll:t}}function Se(e){return!v||!e?!1:e===document.scrollingElement}var Ce={x:.2,y:.2};function Y(e,t,{top:n,left:r,right:i,bottom:a},o=10,s=Ce){let{clientHeight:c,clientWidth:l}=e,u=Se(e)?{top:0,left:0,right:l,bottom:c,width:l,height:c}:t,{isTop:d,isBottom:f,isLeft:p,isRight:m}=J(e),h={x:0,y:0},g={x:0,y:0},_={height:u.height*s.y,width:u.width*s.x};return!d&&n<=u.top+_.height?(h.y=q.Backward,g.y=o*Math.abs((u.top+_.height-n)/_.height)):!f&&a>=u.bottom-_.height&&(h.y=q.Forward,g.y=o*Math.abs((u.bottom-_.height-a)/_.height)),!m&&i>=u.right-_.width?(h.x=q.Forward,g.x=o*Math.abs((u.right-_.width-i)/_.width)):!p&&r<=u.left+_.width&&(h.x=q.Backward,g.x=o*Math.abs((u.left+_.width-r)/_.width)),{direction:h,speed:g}}function we(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Te(e){return e.reduce((e,t)=>M(e,xe(t)),W)}function Ee(e,t,n=W){if(!e||!C(e))return n;let r={x:n.x+e.offsetLeft,y:n.y+e.offsetTop};return e.offsetParent===t?r:Ee(e.offsetParent,t,r)}function X(e){let{offsetWidth:t,offsetHeight:n}=e,{x:r,y:i}=Ee(e,null);return{width:t,height:n,offsetTop:i,offsetLeft:r}}function De(e){if(y(e)){let e=window.innerWidth,t=window.innerHeight;return{top:0,left:0,right:e,bottom:t,width:e,height:t,offsetTop:0,offsetLeft:0}}let{offsetTop:t,offsetLeft:n}=X(e),{width:r,height:i,top:a,bottom:o,left:s,right:c}=e.getBoundingClientRect();return{width:r,height:i,top:a,bottom:o,right:c,left:s,offsetTop:t,offsetLeft:n}}function Oe(e){let{width:t,height:n,offsetTop:r,offsetLeft:i}=X(e),a=Te(ye(e)),o=r-a.y,s=i-a.x;return{width:t,height:n,top:o,bottom:o+n,right:s+t,left:s,offsetTop:r,offsetLeft:i}}function ke(e,t){let n=Math.max(t.top,e.offsetTop),r=Math.max(t.left,e.offsetLeft),i=Math.min(t.left+t.width,e.offsetLeft+e.width),a=Math.min(t.top+t.height,e.offsetTop+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Ae=({collisionRect:e,droppableContainers:t})=>{let n=0,r=null;for(let i of t){let{rect:{current:t}}=i;if(t){let a=ke(t,e);a>n&&(n=a,r=i.id)}}return r},je;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(je||={});var Me;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Me||={});function Ne({acceleration:e,activator:t=je.Pointer,canScroll:n,draggingRect:r,enabled:i,interval:a=5,order:o=Me.TreeOrder,pointerCoordinates:s,scrollableAncestors:c,scrollableAncestorRects:l,threshold:u}){let[d,f]=te(),p=(0,g.useRef)({x:1,y:1}),m=(0,g.useMemo)(()=>{switch(t){case je.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case je.DraggableRect:return r}return null},[t,r,s]),h=(0,g.useRef)(W),_=(0,g.useRef)(null),v=(0,g.useCallback)(()=>{let e=_.current;if(!e)return;let t=p.current.x*h.current.x,n=p.current.y*h.current.y;e.scrollBy(t,n)},[]),y=(0,g.useMemo)(()=>o===Me.TreeOrder?[...c].reverse():c,[o,c]);(0,g.useEffect)(()=>{if(!i||!c.length||!m){f();return}for(let t of y){if(n?.(t)===!1)continue;let r=l[c.indexOf(t)];if(!r)continue;let{direction:i,speed:o}=Y(t,r,m,e,u);if(o.x>0||o.y>0){f(),_.current=t,d(v,a),p.current=o,h.current=i;return}}p.current={x:0,y:0},h.current={x:0,y:0},f()},[e,v,n,f,i,a,JSON.stringify(m),d,c,y,l,JSON.stringify(u)])}function Pe(e,t){let n=t===null?void 0:e[t],r=n?n.node.current:null;return D(e=>t===null?null:r??e??null,[r,t])}function Fe(e,t){return(0,g.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}function Ie(e){let t=(0,g.useRef)(e);return E(()=>{t.current!==e&&(t.current=e)},[e]),t}var Le;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Le||={});var Re;(function(e){e.Optimized=`optimized`})(Re||={});var ze=new Map,Be={measure:X,strategy:Le.WhileDragging,frequency:Re.Optimized};function Ve(e,{dragging:t,dependencies:n,config:r}){let[i,a]=(0,g.useState)(!1),{frequency:o,measure:s,strategy:c}={...Be,...r},l=(0,g.useRef)(e),u=(0,g.useCallback)(()=>a(!0),[]),d=(0,g.useRef)(null),f=m(),p=D(n=>{if(f&&!t)return ze;if(!n||n===ze||l.current!==e||i){for(let t of e)t&&(t.rect.current=t.node.current?s(t.node.current):null);return He(e)}return n},[e,t,f,s,i]);return(0,g.useEffect)(()=>{l.current=e},[e]),(0,g.useEffect)(()=>{i&&a(!1)},[i]),(0,g.useEffect)(function(){f||requestAnimationFrame(u)},[t,f]),(0,g.useEffect)(function(){f||typeof o!=`number`||d.current!==null||(d.current=setTimeout(()=>{u(),d.current=null},o))},[o,f,u,...n]),{layoutRectMap:p,recomputeLayouts:u,willRecomputeLayouts:i};function m(){switch(c){case Le.Always:return!1;case Le.BeforeDragging:return t;default:return!t}}}function He(e){let t=new Map;if(e)for(let n of e){if(!n)continue;let{id:e,rect:r}=n;r.current!=null&&t.set(e,r.current)}return t}function Ue(e){let[t,n]=(0,g.useState)(null),r=(0,g.useRef)(e),i=(0,g.useCallback)(e=>{let t=be(e.target);t&&n(e=>e?(e.set(t,xe(t)),new Map(e)):null)},[]);return(0,g.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=be(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,xe(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{be(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,g.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>M(e,t),W):Te(e):W,[e,t])}var We=[];function Ge(e){let t=(0,g.useRef)(e),n=D(n=>e?n&&e&&t.current&&e.parentNode===t.current.parentNode?n:ye(e):We,[e]);return(0,g.useEffect)(()=>{t.current=e},[e]),n}function Ke(e){(0,g.useEffect)(()=>{if(!v)return;let t=e.map(({sensor:e})=>e.setup==null?void 0:e.setup());return()=>{for(let e of t)e?.()}},e.map(({sensor:e})=>e))}function qe(e,t){return(0,g.useMemo)(()=>e.reduce((e,{eventName:n,handler:r})=>(e[n]=e=>{r(e,t)},e),{}),[e,t])}var Je=Ze(De),Ye=Qe(De);function Xe(e,t,n){let r=(0,g.useRef)(e);return D(i=>e?n||!i&&e||e!==r.current?C(e)&&e.parentNode==null?null:t(e):i??null:null,[e,n,t])}function Ze(e){return(t,n)=>Xe(t,e,n)}function Qe(e){let t=[];return function(n,r){let i=(0,g.useRef)(n);return D(a=>n.length?r||!a&&n.length||n!==i.current?n.map(t=>e(t)):a??t:t,[n,r])}}function $e(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return C(t)?t:e}function et(e){let{width:t,height:n,offsetLeft:r,offsetTop:i}=X(e);return{top:i,bottom:i+n,left:r,right:r+t,width:t,height:n,offsetTop:i,offsetLeft:r}}var tt=Ze(et);function nt({disabled:e,forceRecompute:t}){let[n,r]=O(),i=tt(e?null:$e(n.current),t);return(0,g.useMemo)(()=>({nodeRef:n,rect:i,setRef:r}),[i,n,r])}function rt(e,t){return(0,g.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function it(...e){return(0,g.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var at=class{constructor(e){this.target=e,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))}}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ot(e){let{EventTarget:t}=x(e);return e instanceof t?e:T(e)}function st(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Z;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Z||={});function ct(e){e.preventDefault()}function lt(e){e.stopPropagation()}var Q;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`})(Q||={});var ut={start:[Q.Space,Q.Enter],cancel:[Q.Esc],end:[Q.Space,Q.Enter]},dt=(e,{currentCoordinates:t})=>{switch(e.code){case Q.Right:return{...t,x:t.x+25};case Q.Left:return{...t,x:t.x-25};case Q.Down:return{...t,y:t.y+25};case Q.Up:return{...t,y:t.y-25}}},ft=class{constructor(e){this.props=e,this.autoScrollEnabled=!1,this.coordinates=W;let{event:{target:t}}=e;this.props=e,this.listeners=new at(T(t)),this.windowListeners=new at(x(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Z.Resize,this.handleCancel),this.windowListeners.add(Z.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Z.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props;if(!e.node.current)throw Error(`Active draggable node is undefined`);let n=De(e.node.current),r={x:n.left,y:n.top};this.coordinates=r,t(r)}handleKeyDown(e){if(ne(e)){let{coordinates:t}=this,{active:n,context:r,options:i}=this.props,{keyboardCodes:a=ut,coordinateGetter:o=dt,scrollBehavior:s=`smooth`}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}let l=o(e,{active:n,context:r.current,currentCoordinates:t});if(l){let n={x:0,y:0},{scrollableAncestors:i}=r.current;for(let r of i){let i=e.code,a=N(l,t),{isTop:o,isRight:c,isLeft:u,isBottom:d,maxScroll:f,minScroll:p}=J(r),m=we(r),h={x:Math.min(i===Q.Right?m.right-m.width/2:m.right,Math.max(i===Q.Right?m.left:m.left+m.width/2,l.x)),y:Math.min(i===Q.Down?m.bottom-m.height/2:m.bottom,Math.max(i===Q.Down?m.top:m.top+m.height/2,l.y))},g=i===Q.Right&&!c||i===Q.Left&&!u,_=i===Q.Down&&!d||i===Q.Up&&!o;if(g&&h.x!==l.x){if(i===Q.Right&&r.scrollLeft+a.x<=f.x||i===Q.Left&&r.scrollLeft+a.x>=p.x){r.scrollBy({left:a.x,behavior:s});return}n.x=i===Q.Right?r.scrollLeft-f.x:r.scrollLeft-p.x,r.scrollBy({left:-n.x,behavior:s});break}else if(_&&h.y!==l.y){if(i===Q.Down&&r.scrollTop+a.y<=f.y||i===Q.Up&&r.scrollTop+a.y>=p.y){r.scrollBy({top:a.y,behavior:s});return}n.y=i===Q.Down?r.scrollTop-f.y:r.scrollTop-p.y,r.scrollBy({top:-n.y,behavior:s});break}}this.handleMove(e,M(l,n))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t),this.coordinates=t}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};ft.activators=[{eventName:`onKeyDown`,handler:(e,{keyboardCodes:t=ut,onActivation:n})=>{let{code:r}=e.nativeEvent;return t.start.includes(r)?(e.preventDefault(),n?.({event:e.nativeEvent}),!0):!1}}];function pt(e){return!!(e&&`distance`in e)}function mt(e){return!!(e&&`delay`in e)}var ht=class{constructor(e,t,n=ot(e.event.target)){this.props=e,this.events=t,this.autoScrollEnabled=!0,this.activated=!1,this.timeoutId=null;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=T(i),this.documentListeners=new at(this.document),this.listeners=new at(n),this.windowListeners=new at(x(i)),this.initialCoordinates=I(r),this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(Z.Resize,this.handleCancel),this.windowListeners.add(Z.DragStart,ct),this.windowListeners.add(Z.VisibilityChange,this.handleCancel),this.windowListeners.add(Z.ContextMenu,ct),this.documentListeners.add(Z.Keydown,this.handleKeydown),t){if(pt(t))return;if(mt(t)){this.timeoutId=setTimeout(this.handleStart,t.delay);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Z.Click,lt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Z.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=I(e),s=N(n,o);if(!t&&a){if(mt(a))return st(s,a.tolerance)?this.handleCancel():void 0;if(pt(a))return a.tolerance!=null&&st(s,a.tolerance)?this.handleCancel():st(s,a.distance)?this.handleStart():void 0}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onEnd:e}=this.props;this.detach(),e()}handleCancel(){let{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===Q.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},gt={move:{name:`pointermove`},end:{name:`pointerup`}},_t=class extends ht{constructor(e){let{event:t}=e,n=T(t.target);super(e,gt,n)}};_t.activators=[{eventName:`onPointerDown`,handler:({nativeEvent:e},{onActivation:t})=>!e.isPrimary||e.button!==0?!1:(t?.({event:e}),!0)}];var vt={move:{name:`mousemove`},end:{name:`mouseup`}},yt;(function(e){e[e.RightClick=2]=`RightClick`})(yt||={});var bt=class extends ht{constructor(e){super(e,vt,T(e.event.target))}};bt.activators=[{eventName:`onMouseDown`,handler:({nativeEvent:e},{onActivation:t})=>e.button===yt.RightClick?!1:(t?.({event:e}),!0)}];var xt={move:{name:`touchmove`},end:{name:`touchend`}},St=class extends ht{constructor(e){super(e,xt)}static setup(){return window.addEventListener(xt.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(xt.move.name,e)};function e(){}}};St.activators=[{eventName:`onTouchStart`,handler:({nativeEvent:e},{onActivation:t})=>{let{touches:n}=e;return n.length>1?!1:(t?.({event:e}),!0)}}];function Ct(e,{transform:t,...n}){return e?.length?e.reduce((e,t)=>t({transform:e,...n}),t):t}var wt=[{sensor:_t,options:{}},{sensor:ft,options:{}}],Tt={current:{}},Et=(0,g.createContext)({...W,scaleX:1,scaleY:1}),Dt=(0,g.memo)(function({id:e,autoScroll:t=!0,announcements:n,children:r,sensors:i=wt,collisionDetection:a=Ae,measuring:o,modifiers:s,screenReaderInstructions:c=ie,...l}){let[u,d]=(0,g.useReducer)(ce,void 0,se),[f,p]=(0,g.useState)(()=>({type:null,event:null})),[m,_]=(0,g.useState)(!1),{draggable:{active:v,nodes:y,translate:b},droppable:{containers:x}}=u,S=v?y[v]:null,C=(0,g.useRef)({initial:null,translated:null}),w=(0,g.useMemo)(()=>v==null?null:{id:v,data:S?.data??Tt,rect:C},[v,S]),T=(0,g.useRef)(null),[ee,te]=(0,g.useState)(null),[D,O]=(0,g.useState)(null),k=(0,g.useRef)(l),j=A(`DndDescribedBy`,e),N=(0,g.useMemo)(()=>x.getEnabled(),[x]),{layoutRectMap:P,recomputeLayouts:ne,willRecomputeLayouts:F}=Ve(N,{dragging:m,dependencies:[b.x,b.y],config:o?.droppable}),L=Pe(y,v),re=D?I(D):null,R=Xe(L,o?.draggable?.measure??Oe),z=Je(L),B=(0,g.useRef)(null),ae=B.current,H=(0,g.useRef)({active:null,activeNode:L,collisionRect:null,droppableRects:P,draggableNodes:y,draggingNodeRect:null,droppableContainers:x,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null,translatedRect:null}),U=x.getNodeFor(H.current.over?.id),ue=Je(L?L.ownerDocument.defaultView:null),fe=Je(L?L.parentElement:null),G=Ge(v?U??L:null),pe=Ye(G),ge=nt({disabled:v==null,forceRecompute:F}),K=ge.rect??R,ve=K===R?he(R,ae):W,ye=Ct(s,{transform:{x:b.x-ve.x,y:b.y-ve.y,scaleX:1,scaleY:1},activatorEvent:D,active:w,activeNodeRect:z,containerNodeRect:fe,draggingNodeRect:K,over:H.current.over,overlayNodeRect:ge.rect,scrollableAncestors:G,scrollableAncestorRects:pe,windowRect:ue}),be=re?M(re,b):null,xe=Ue(G),q=M(ye,xe),J=K?_e(K,ye):null,Se=J?_e(J,xe):null,Ce=w&&Se?a({active:w,collisionRect:Se,droppableContainers:N}):null,[Y,we]=(0,g.useState)(null),Te=me(ye,Y?.rect??null,R),Ee=(0,g.useCallback)((e,{sensor:t,options:n})=>{if(!T.current)return;let r=y[T.current];if(!r)return;let i=new t({active:T.current,activeNode:r,event:e.nativeEvent,options:n,context:H,onStart(e){let t=T.current;if(!t)return;let n=y[t];if(!n)return;let{onDragStart:r}=k.current,i={active:{id:t,data:n.data,rect:C}};(0,h.unstable_batchedUpdates)(()=>{d({type:V.DragStart,initialCoordinates:e,active:t}),p({type:V.DragStart,event:i})}),r?.(i)},onMove(e){d({type:V.DragMove,coordinates:e})},onEnd:a(V.DragEnd),onCancel:a(V.DragCancel)});(0,h.unstable_batchedUpdates)(()=>{te(i),O(e.nativeEvent)});function a(e){return async function(){let{active:t,over:n,scrollAdjustedTranslate:r}=H.current,i=null;if(t&&r){let{cancelDrop:a}=k.current;i={active:t,delta:r,over:n},e===V.DragEnd&&typeof a==`function`&&await Promise.resolve(a(i))&&(e=V.DragCancel)}if(T.current=null,(0,h.unstable_batchedUpdates)(()=>{d({type:e}),we(null),_(!1),te(null),O(null),i&&p({type:e,event:i})}),i){let{onDragCancel:t,onDragEnd:n}=k.current;(e===V.DragEnd?n:t)?.(i)}}}},[d,y]),X=Fe(i,(0,g.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent;T.current!==null||i.dndKit||i.defaultPrevented||e(n,t.options)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,Ee(n,t))},[Ee]));Ke(i),E(()=>{k.current=l},Object.values(l)),(0,g.useEffect)(()=>{v!=null&&_(!0)},[v]),(0,g.useEffect)(()=>{w||(B.current=null),w&&R&&!B.current&&(B.current=R)},[R,w]),(0,g.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,over:n}=H.current;if(!t)return;let r={active:t,delta:{x:q.x,y:q.y},over:n};p({type:V.DragMove,event:r}),e?.(r)},[q.x,q.y]),(0,g.useEffect)(()=>{let{active:e,droppableContainers:t,scrollAdjustedTranslate:n}=H.current;if(!e||!T.current||!n)return;let{onDragOver:r}=k.current,i=t.get(Ce),a=i&&i.rect.current?{id:i.id,rect:i.rect.current,data:i.data,disabled:i.disabled}:null,o={active:e,delta:{x:n.x,y:n.y},over:a};(0,h.unstable_batchedUpdates)(()=>{we(a),p({type:V.DragOver,event:o}),r?.(o)})},[Ce]),E(()=>{H.current={active:w,activeNode:L,collisionRect:Se,droppableRects:P,draggableNodes:y,draggingNodeRect:K,droppableContainers:x,over:Y,scrollableAncestors:G,scrollAdjustedTranslate:q,translatedRect:J},C.current={initial:K,translated:J}},[w,L,Se,y,K,P,x,Y,G,q,J]),Ne({...ke(),draggingRect:J,pointerCoordinates:be,scrollableAncestors:G,scrollableAncestorRects:pe});let De=(0,g.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:R,activeNodeClientRect:z,activatorEvent:D,activators:X,ariaDescribedById:{draggable:j},containerNodeRect:fe,dispatch:d,dragOverlay:ge,draggableNodes:y,droppableContainers:x,droppableRects:P,over:Y,recomputeLayouts:ne,scrollableAncestors:G,scrollableAncestorRects:pe,willRecomputeLayouts:F,windowRect:ue}),[w,L,z,R,D,X,fe,ge,d,y,j,x,P,Y,ne,G,pe,F,ue]);return g.createElement(le.Provider,{value:f},g.createElement(oe.Provider,{value:De},g.createElement(Et.Provider,{value:Te},r)),g.createElement(de,{announcements:n,hiddenTextDescribedById:j,screenReaderInstructions:c}));function ke(){let e=ee?.autoScrollEnabled===!1,n=typeof t==`object`?t.enabled===!1:t===!1,r=!e&&!n;return typeof t==`object`?{...t,enabled:r}:{enabled:r}}}),Ot=(0,g.createContext)(null),kt=`button`,At=`Droppable`;function jt({id:e,data:t,disabled:n=!1,attributes:r}){let i=A(At),{active:a,activeNodeRect:o,activatorEvent:s,ariaDescribedById:c,draggableNodes:l,droppableRects:u,activators:d,over:f}=(0,g.useContext)(oe),{role:p=kt,roleDescription:m=`draggable`,tabIndex:h=0}=r??{},_=a?.id===e,v=(0,g.useContext)(_?Et:Ot),[y,b]=O(),x=qe(d,e),S=Ie(t);return(0,g.useEffect)(()=>(l[e]={id:e,key:i,node:y,data:S},()=>{let t=l[e];t&&t.key===i&&delete l[e]}),[l,e]),{active:a,activeNodeRect:o,activatorEvent:s,attributes:(0,g.useMemo)(()=>({role:p,tabIndex:h,"aria-pressed":_&&p===kt?!0:void 0,"aria-roledescription":m,"aria-describedby":c.draggable}),[p,h,_,m,c.draggable]),droppableRects:u,isDragging:_,listeners:n?void 0:x,node:y,over:f,setNodeRef:b,transform:v}}function Mt(){return(0,g.useContext)(oe)}var Nt=`Droppable`;function Pt({data:e,disabled:t=!1,id:n}){let r=A(Nt),{active:i,dispatch:a,over:o}=(0,g.useContext)(oe),s=(0,g.useRef)(null),[c,l]=O(),u=Ie(e);return E(()=>(a({type:V.RegisterDroppable,element:{id:n,key:r,disabled:t,node:c,rect:s,data:u}}),()=>a({type:V.UnregisterDroppable,key:r,id:n})),[n]),(0,g.useEffect)(()=>{a({type:V.SetDroppableDisabled,id:n,key:r,disabled:t})},[t]),{active:i,rect:s,isOver:o?.id===n,node:c,over:o,setNodeRef:l}}function Ft(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function It(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Lt(e){return e!==null&&e>=0}var Rt=({layoutRects:e,activeIndex:t,overIndex:n,index:r})=>{let i=Ft(e,n,t),a=e[r],o=i[r];return!o||!a?null:{x:o.offsetLeft-a.offsetLeft,y:o.offsetTop-a.offsetTop,scaleX:o.width/a.width,scaleY:o.height/a.height}},zt=`Sortable`,Bt=g.createContext({activeIndex:-1,containerId:zt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Rt,wasDragging:{current:!1}});function Vt({children:e,id:t,items:n,strategy:r=Rt}){let{active:i,dragOverlay:a,droppableRects:o,over:s,recomputeLayouts:c,willRecomputeLayouts:l}=Mt(),u=A(zt,t),d=a.rect!==null,f=(0,g.useMemo)(()=>n.map(e=>typeof e==`string`?e:e.id),[n]),p=i!=null,m=(0,g.useRef)(!1),h=i?f.indexOf(i.id):-1,_=h!==-1,v=s?f.indexOf(s.id):-1,y=(0,g.useRef)(f),b=It(f,o),x=!Ht(f,y.current),S=v!==-1&&h===-1||x;E(()=>{x&&_&&!l&&c()},[x,_,c,l]),(0,g.useEffect)(()=>{y.current=f},[f]),(0,g.useEffect)(()=>{let e=setTimeout(()=>{m.current=p},100);return()=>clearTimeout(e)},[p]);let C=(0,g.useMemo)(()=>({activeIndex:h,containerId:u,disableTransforms:S,items:f,overIndex:v,useDragOverlay:d,sortedRects:b,strategy:r,wasDragging:m}),[h,u,S,f,v,b,d,r,m]);return g.createElement(Bt.Provider,{value:C},e)}function Ht(e,t){return e.join()===t.join()}var Ut=({id:e,items:t,activeIndex:n,overIndex:r})=>Ft(t,n,r).indexOf(e),Wt=({containerId:e,isSorting:t,wasDragging:n,index:r,items:i,newIndex:a,previousItems:o,previousContainerId:s,transition:c})=>!c||!n||o!==i&&r===a?!1:t?!0:a!==r&&e===s,Gt={duration:200,easing:`ease`},Kt=`transform`,qt=L.Transition.toString({property:Kt,duration:0,easing:`linear`}),Jt={roleDescription:`sortable`};function Yt({disabled:e,index:t,node:n,rect:r}){let[i,a]=(0,g.useState)(null),o=(0,g.useRef)(t);return E(()=>{if(!e&&t!==o.current&&n.current){let e=r.current;if(e){let t=De(n.current),r={x:e.offsetLeft-t.offsetLeft,y:e.offsetTop-t.offsetTop,scaleX:e.width/t.width,scaleY:e.height/t.height};(r.x||r.y)&&a(r)}}t!==o.current&&(o.current=t)},[e,t,n,r]),(0,g.useEffect)(()=>{i&&requestAnimationFrame(()=>{a(null)})},[i]),i}function Xt({animateLayoutChanges:e=Wt,attributes:t,disabled:n,data:r,getNewIndex:i=Ut,id:a,strategy:o,transition:s=Gt}){let{items:c,containerId:l,activeIndex:u,disableTransforms:d,sortedRects:f,overIndex:p,useDragOverlay:m,strategy:h,wasDragging:v}=(0,g.useContext)(Bt),y=c.indexOf(a),b=(0,g.useMemo)(()=>({sortable:{containerId:l,index:y,items:c},...r}),[l,r,y,c]),{rect:x,node:S,setNodeRef:C}=Pt({id:a,data:b}),{active:w,activeNodeRect:T,activatorEvent:E,attributes:ee,setNodeRef:te,listeners:D,isDragging:O,over:k,transform:A}=jt({id:a,data:b,attributes:{...Jt,...t},disabled:n}),j=_(C,te),M=!!w,N=M&&v.current&&!d&&Lt(u)&&Lt(p),P=!m&&O,ne=N?(P&&N?A:null)??(o??h)({layoutRects:f,activeNodeRect:T,activeIndex:u,overIndex:p,index:y}):null,F=Lt(u)&&Lt(p)?i({id:a,items:c,activeIndex:u,overIndex:p}):y,I=(0,g.useRef)(c),re=c!==I.current,R=(0,g.useRef)(F),z=(0,g.useRef)(l),B=e({active:w,containerId:l,isDragging:O,isSorting:M,id:a,index:y,items:c,newIndex:R.current,previousItems:I.current,previousContainerId:z.current,transition:s,wasDragging:v.current}),ie=Yt({disabled:!B,index:y,node:S,rect:x});return(0,g.useEffect)(()=>{M&&R.current!==F&&(R.current=F),l!==z.current&&(z.current=l),c!==I.current&&(I.current=c)},[M,F,l,c]),{active:w,attributes:ee,activatorEvent:E,rect:x,index:y,isSorting:M,isDragging:O,listeners:D,node:S,overIndex:p,over:k,setNodeRef:j,setDroppableNodeRef:C,setDraggableNodeRef:te,transform:ie??ne,transition:ae()};function ae(){if(ie||re&&R.current===y)return qt;if(!(P||!s)&&(M||B))return L.Transition.toString({...s,property:Kt})}}Q.Down,Q.Right,Q.Up,Q.Left;var $=i(),Zt=e=>(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,$.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m12 14l4-4M3.34 19a10 10 0 1 1 17.32 0`})}),Qt=e=>(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,$.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,$.jsx)(`circle`,{cx:9,cy:12,r:1}),(0,$.jsx)(`circle`,{cx:9,cy:5,r:1}),(0,$.jsx)(`circle`,{cx:9,cy:19,r:1}),(0,$.jsx)(`circle`,{cx:15,cy:12,r:1}),(0,$.jsx)(`circle`,{cx:15,cy:5,r:1}),(0,$.jsx)(`circle`,{cx:15,cy:19,r:1})]})}),$t=new Set([`anthropic`,`openai`,`grok`]);function en(e){let t=e.trim();if(t===``)return{ok:!0,value:null};if(!/^\d+$/.test(t))return{ok:!1,error:`정수만 입력하세요 (0–100)`};let n=Number(t);return n>100?{ok:!1,error:`100 이하여야 합니다`}:{ok:!0,value:n===0?null:n}}function tn(e){let t=e.trim();if(!/^\d+$/.test(t))return{ok:!1,error:`1–100 사이 정수를 입력하세요`};let n=Number(t);return n<1||n>100?{ok:!1,error:`1–100 사이 정수를 입력하세요`}:{ok:!0,value:n}}var nn=new Map(Object.entries({openai:{stripe:`bg-openai-400`,bar:`bg-openai-bar`,badge:`bg-openai-50 text-openai-600`,cost:`text-openai-600`},anthropic:{stripe:`bg-anthropic-400`,bar:`bg-anthropic-400`,badge:`bg-anthropic-50 text-anthropic-600`,cost:`text-anthropic-600`},google:{stripe:`bg-google-400`,bar:`bg-google-400`,badge:`bg-google-50 text-google-600`,cost:`text-google-600`},grok:{stripe:`bg-sand-800`,bar:`bg-sand-600`,badge:`bg-sand-800 text-sand-50`,cost:`text-sand-800`}})),rn={stripe:`bg-sand-400`,bar:`bg-sienna-400`,badge:`bg-sand-200 text-sand-500`,cost:`text-sienna-600`};function an(e){return nn.get(e)??rn}function on(e,t){return e>=95?`bg-danger-400`:e>=80?`bg-caution-400`:t.bar}function sn(e){if(!e)return``;let t=new Date(e).getTime()-Date.now();if(t<=0)return`resetting...`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`resets ${n}h ${r}m`:`resets ${r}m`}function cn(e,t){if(!t||t<=0)return e;let n=t/60;return n>=24?`${Math.round(n/24)}d`:`${Math.round(n)}h`}function ln(e){if(!e)return null;let t=e.replace(/^USAGE_PERIOD_TYPE_/,``).toLowerCase();return t&&t!==`unspecified`?t:null}function un({usage:e}){let t=ln(e.periodType);return e.onDemandExcluded===!0||e.zdrVideoExcluded===!0||e.keepaliveApplicable===!1||t!==null||e.tier?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[10px]`,children:[e.onDemandExcluded===!0&&(0,$.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-amber-50 text-amber-700`,title:`xAI에서 on-demand 과금을 끄면 다시 라우팅됩니다`,children:`excluded: on-demand billing enabled`}),e.zdrVideoExcluded===!0&&(0,$.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-amber-50 text-amber-700`,title:`xAI에서 data-retention opt-out(Zero Data Retention)을 끄면 비디오가 다시 라우팅됩니다`,children:`video unavailable: zero data retention`}),t!==null&&(0,$.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-sand-100 text-sand-600`,children:t}),e.tier&&(0,$.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-sand-100 text-sand-600`,children:e.tier}),e.keepaliveApplicable===!1&&(0,$.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-sand-100 text-sand-400`,title:`이 provider는 토큰 윈도 keepalive 대상이 아닙니다`,children:`keepalive n/a`})]}):null}function dn({label:e,utilization:t,resetsAt:n,windowDurationMins:r,theme:i,threshold:a}){let o=t??0,s=a!=null;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs text-sand-600 w-7 shrink-0`,children:cn(e,r)}),(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0 h-2 bg-sand-200 rounded-full overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-300 ${on(o,i)}`,style:{width:`${Math.min(o,100)}%`}}),s&&(0,$.jsx)(`div`,{className:`absolute top-[-2px] bottom-[-2px] w-0.5 bg-sienna-500 rounded-full`,style:{left:`calc(${Math.min(a,100)}% - 1px)`}})]}),(0,$.jsxs)(`span`,{className:`text-xs tabular-nums text-sand-700 w-9 text-right shrink-0`,children:[o,`%`]}),(0,$.jsx)(`span`,{className:`hidden sm:inline text-[10px] text-sand-400 w-24 text-right shrink-0`,title:sn(n),children:sn(n)})]})}function fn({token:e,theme:n}){let r=t(),{data:i,isLoading:o,dataUpdatedAt:s}=a.useUsage(e.id);if((0,g.useEffect)(()=>{i?.error&&r.invalidateQueries({queryKey:[`Token`]})},[i?.error,s,r]),e.reauth_required)return(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-amber-600`,children:`Session expired`}),(0,$.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-0.5`,children:`Please re-login via OAuth`})]});if(o)return(0,$.jsxs)(`div`,{className:`animate-pulse space-y-2 py-2`,children:[(0,$.jsx)(`div`,{className:`h-2 w-full bg-sand-200 rounded-full`}),(0,$.jsx)(`div`,{className:`h-2 w-3/4 bg-sand-200 rounded-full`})]});if(i?.error)return(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-amber-600`,children:`Unavailable`}),(0,$.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-0.5`,children:i.error})]});if(!i?.fiveHour&&!i?.sevenDay)return(0,$.jsxs)(`div`,{className:`space-y-1.5 py-1`,children:[i&&(0,$.jsx)(un,{usage:i}),(0,$.jsx)(`p`,{className:`text-[11px] text-sand-400`,children:`No usage data`})]});let c=$t.has(e.provider)?e.quota_threshold:null;return(0,$.jsxs)(`div`,{className:`space-y-1.5 py-1`,children:[(0,$.jsx)(un,{usage:i}),i.fiveHour&&(0,$.jsx)(dn,{label:`5h`,utilization:i.fiveHour.utilization,resetsAt:i.fiveHour.resetsAt,windowDurationMins:i.fiveHour.windowDurationMins,theme:n,threshold:c}),i.sevenDay&&(0,$.jsx)(dn,{label:ln(i.periodType)===`monthly`?`1mo`:`7d`,utilization:i.sevenDay.utilization,resetsAt:i.sevenDay.resetsAt,windowDurationMins:i.sevenDay.windowDurationMins,theme:n,threshold:e.provider===`grok`?c:void 0})]})}function pn({token:e}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),o=(0,g.useRef)(null),c=t(),l=f(),u=$t.has(e.provider),d=n!==null,p=en(i),m=()=>{let t=o.current?.getBoundingClientRect();if(!t)return;let n=Math.min(Math.max(t.right-240,8),Math.max(window.innerWidth-240-8,8)),i=t.top-6-150,s=t.bottom+6;r({left:n,top:Math.min(Math.max(i>=8?i:s,8),Math.max(window.innerHeight-150-8,8))}),a(String(e.quota_threshold??100))},h=()=>r(null);if(!u)return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] text-sand-300 border border-sand-100`,title:`Quota threshold는 이 provider에서 지원되지 않습니다`,children:[(0,$.jsx)(Zt,{className:`size-3`}),`n/a`]});let _=e=>{let t=/^\d+$/.test(i.trim())?Number(i.trim()):0,n=Math.min(Math.max(t+e,0),100);a(String(n))};return(0,$.jsxs)(`div`,{className:`inline-flex`,children:[(0,$.jsxs)(`button`,{ref:o,type:`button`,title:`사용률 제한 설정`,onClick:d?h:m,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] border border-sand-200/80 text-sand-400 hover:text-sand-600 hover:border-sand-300 transition-colors duration-150`,children:[(0,$.jsx)(Zt,{className:`size-3`}),`Set limit`]}),d&&n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-40`,onPointerDown:h}),(0,$.jsxs)(`div`,{className:`fixed z-50 w-60 panel shadow-xl p-3`,style:{top:n.top,left:n.left},children:[(0,$.jsx)(`label`,{htmlFor:`threshold-${e.id}`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`사용률 제한`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>_(-10),className:`size-9 shrink-0 rounded-md border border-sand-200 text-sand-600 text-base leading-none hover:bg-sand-100 transition-colors duration-150`,children:`−`}),(0,$.jsx)(s,{id:`threshold-${e.id}`,value:i,onChange:e=>a(e.target.value),inputMode:`numeric`,className:`h-9 w-14 border rounded-md text-center text-sm text-sand-900 bg-white tabular-nums focus:outline-none ${p.ok?`border-sand-200 focus:border-sienna-300`:`border-red-300 focus:border-red-400`}`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>_(10),className:`size-9 shrink-0 rounded-md border border-sand-200 text-sand-600 text-base leading-none hover:bg-sand-100 transition-colors duration-150`,children:`+`}),(0,$.jsx)(`span`,{className:`text-sm text-sand-500`,children:`%`})]}),p.ok?(0,$.jsx)(`p`,{className:`mt-1.5 text-[11px] text-sand-500 leading-snug`,children:p.value===null?`제한 없음 — 사용률과 무관하게 항상 사용합니다.`:`기준 사용률이 임계치에 달하면 해당 토큰을 건너뜁니다.`}):(0,$.jsx)(`p`,{className:`mt-1.5 text-[11px] text-red-500`,children:p.error}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`px-2 py-1 text-[11px] font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:h,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,className:`px-2 py-1 text-[11px] font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:l.isPending||!p.ok,onClick:async()=>{p.ok&&(await l.mutateAsync({id:e.id,quotaThreshold:p.value}),await Promise.all([c.invalidateQueries({queryKey:[`Token`]}),c.invalidateQueries({queryKey:[`Qgrid`]})]),h())},children:l.isPending?`Saving...`:`Save`})]})]})]})]})}function mn({token:e}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),o=(0,g.useRef)(null),c=t(),l=f(),u=tn(i),d=()=>{let t=o.current?.getBoundingClientRect();if(!t)return;let n=Math.min(Math.max(t.right-240,8),Math.max(window.innerWidth-240-8,8)),i=t.top-6-150,s=Math.min(Math.max(i>=8?i:t.bottom+6,8),Math.max(window.innerHeight-150-8,8));a(String(e.weight)),r({left:n,top:s})},p=()=>r(null),m=e=>{let t=/^\d+$/.test(i.trim())?Number(i.trim()):1;a(String(Math.min(Math.max(t+e,1),100)))};return(0,$.jsxs)(`div`,{className:`inline-flex`,children:[(0,$.jsxs)(`button`,{ref:o,type:`button`,title:`라우팅 가중치 설정`,onClick:n?p:d,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] border border-sand-200/80 text-sand-400 hover:text-sand-600 hover:border-sand-300 transition-colors duration-150`,children:[`Weight `,e.weight]}),n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-40`,onPointerDown:p}),(0,$.jsxs)(`div`,{className:`fixed z-50 w-60 panel shadow-xl p-3`,style:n,children:[(0,$.jsx)(`label`,{htmlFor:`weight-${e.id}`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`라우팅 가중치`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(-1),className:`size-9 shrink-0 rounded-md border border-sand-200 text-sand-600`,children:`−`}),(0,$.jsx)(s,{id:`weight-${e.id}`,value:i,onChange:e=>a(e.target.value),inputMode:`numeric`,className:`h-9 w-16 border rounded-md text-center text-sm tabular-nums ${u.ok?`border-sand-200`:`border-red-300`}`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(1),className:`size-9 shrink-0 rounded-md border border-sand-200 text-sand-600`,children:`+`})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[11px] ${u.ok?`text-sand-500`:`text-red-500`}`,children:u.ok?`새 요청의 상대 배정 비율입니다.`:u.error}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`px-2 py-1 text-[11px]`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:async()=>{u.ok&&(await l.mutateAsync({id:e.id,weight:u.value}),await Promise.all([c.invalidateQueries({queryKey:[`Token`]}),c.invalidateQueries({queryKey:[`Qgrid`]})]),p())},disabled:l.isPending||!u.ok,className:`px-2 py-1 text-[11px] rounded-md bg-sienna-400 text-white disabled:opacity-50`,children:l.isPending?`Saving...`:`Save`})]})]})]})]})}function hn({token:e}){let t=c(),n=u(e.provider)?e.provider:null,r=async e=>{await t.submitCode(e)&&t.reset()};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,title:`기존 이름으로 다시 로그인`,disabled:n===null||t.loadingProvider!==null,onClick:()=>{n&&t.start(n,e.name??``)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium border border-sienna-300 text-sienna-600 hover:bg-sienna-50 disabled:opacity-50 transition-colors duration-150`,children:t.loadingProvider===e.provider?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`size-2.5 border-2 border-sienna-400 border-t-transparent rounded-full animate-spin`}),`로그인 대기`]}):`재로그인`}),t.codeEntryProvider&&(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:t.reset,onKeyDown:()=>{}}),(0,$.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-md mx-4`,children:[(0,$.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100/60`,children:(0,$.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`재로그인`})}),(0,$.jsx)(`div`,{className:`px-5 py-4`,children:(0,$.jsx)(l,{provider:t.codeEntryProvider,isPending:t.completeMutation.isPending,isError:t.completeMutation.isError,onSubmit:e=>void r(e),onRestart:t.reset})})]})]})]})}function gn({token:e}){let{attributes:t,listeners:n,setNodeRef:r,transform:i,transition:o,isDragging:s}=Xt({id:String(e.id),transition:{duration:200,easing:`ease`}}),c={num:0,page:1};e.name&&(c.token_name=e.name);let{data:l}=a.useTotalCost(c,{enabled:!!e.name}),u=an(e.provider);return(0,$.jsxs)(`div`,{ref:r,style:{transform:L.Translate.toString(i),transition:o,opacity:s?.5:1,zIndex:s?10:void 0},className:`relative rounded-lg bg-white border border-sand-200/80 overflow-hidden shadow-sm hover:shadow-md transition-shadow duration-200`,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1 ${u.stripe}`}),(0,$.jsxs)(`div`,{className:`pl-4 pr-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`순서 변경 핸들`,...t,...n,className:`shrink-0 -m-1 p-1 text-sand-300 hover:text-sand-500 cursor-grab active:cursor-grabbing touch-none`,children:(0,$.jsx)(Qt,{className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`text-[13px] font-medium text-sand-800 truncate select-none`,children:e.name??`Unnamed`})]}),(0,$.jsxs)(`span`,{className:`text-[11px] tabular-nums font-medium shrink-0 ${u.cost}`,children:[d(l?.usd??0),l&&m(l)?(0,$.jsx)(`span`,{className:`ml-1 font-normal text-sand-400`,title:p(l)??void 0,children:m(l)}):null]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full uppercase ${u.badge}`,children:e.provider}),(0,$.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e.active?`bg-sage-100 text-sage-600`:`bg-sand-200 text-sand-500`}`,children:e.active?`Active`:`Inactive`}),$t.has(e.provider)&&e.quota_threshold!==null&&(0,$.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-sienna-50 text-[10px] tabular-nums font-medium text-sienna-600`,title:`사용률 ${e.quota_threshold}% 이상이면 이 토큰 제외`,children:[`≤ `,e.quota_threshold,`%`]})]}),(0,$.jsx)(fn,{token:e,theme:u}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[e.reauth_required&&(0,$.jsx)(hn,{token:e}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(mn,{token:e}),(0,$.jsx)(pn,{token:e})]})]})]})}var _n=[`all`,`openai`,`anthropic`,`grok`],vn={all:`All`,openai:`OpenAI`,anthropic:`Anthropic`,grok:`Grok`};function yn(){let{data:e,isLoading:n}=o.useTokens(`A`,{orderBy:`ord-asc`}),r=t(),i=o.useReorderMutation(),[a,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(`all`);(0,g.useEffect)(()=>{e?.rows&&s(e.rows)},[e?.rows]);let u=it(rt(_t,{activationConstraint:{distance:5}})),d=t=>{let{active:n,over:c}=t;if(!c||n.id===c.id)return;let l=Number(n.id),u=Number(c.id),d=a.findIndex(e=>e.id===l),f=a.findIndex(e=>e.id===u);if(d===-1||f===-1)return;let p=Ft(a,d,f);s(p);let m=o.getTokensQueryOptions(`A`,{orderBy:`ord-asc`}).queryKey,h=r.getQueryData(m);r.setQueryData(m,e=>e&&{...e,rows:p}),i.mutate({ids:p.map(e=>e.id)},{onError:()=>{r.setQueryData(m,h),e?.rows&&s(e.rows)},onSettled:()=>{Promise.all([r.invalidateQueries({queryKey:[`Token`]}),r.invalidateQueries({queryKey:[`Qgrid`]})])}})};if(n)return(0,$.jsx)(`div`,{className:`panel p-5`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-sand-50 px-4 py-3 animate-pulse`,children:[(0,$.jsx)(`div`,{className:`h-3 w-16 bg-sand-200 rounded mb-3`}),(0,$.jsx)(`div`,{className:`h-2 w-full bg-sand-200 rounded-full`})]},`skel-${t}`))})});if(a.length===0)return(0,$.jsx)(`div`,{className:`panel px-5 py-10`,children:(0,$.jsx)(`p`,{className:`text-sand-400 text-[13px] text-center`,children:`No tokens registered`})});let f=c===`all`?a:a.filter(e=>e.provider===c);return(0,$.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`panel-header flex items-center justify-between px-5 py-2.5`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium text-sand-700`,children:`Token Usage`}),(0,$.jsx)(`div`,{className:`segmented-control flex gap-0.5`,children:_n.map(e=>(0,$.jsx)(`button`,{type:`button`,"data-active":c===e,className:`px-2.5 py-[3px] text-[11px] font-medium rounded-[6px] transition-all duration-150 ${c===e?`text-sand-800`:`text-sand-500 hover:text-sand-700`}`,onClick:()=>l(e),children:vn[e]},e))})]}),(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Dt,{sensors:u,collisionDetection:pe,onDragEnd:d,children:(0,$.jsx)(Vt,{items:f.map(e=>String(e.id)),strategy:Rt,children:(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:f.map(e=>(0,$.jsx)(gn,{token:e},e.id))})})})})]})}function bn(){return(0,$.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,$.jsx)(yn,{})})}export{bn as component};
@@ -1 +0,0 @@
1
- function e(e){return e.unknownImageCostCount+(e.unknownCostCount??0)}function t(t){let n=e(t);return n>0?`+${n} unpriced`:null}function n(t){if(e(t)===0)return null;let n=t.unknownCostCount??0;return`Total excludes requests with unknown cost: ${t.unknownImageCostCount} image, ${n} voice/video.`}export{n,t};
@@ -1,18 +0,0 @@
1
- //#region src/components/qgrid/total-cost.ts
2
- /** 비용을 몰라 합계에 들어가지 않은 요청 수(가격 없는 이미지 + provider 비용 없는 음성/영상). */
3
- function unpricedRequestCount(cost) {
4
- return cost.unknownImageCostCount + (cost.unknownCostCount ?? 0);
5
- }
6
- /** 합계 옆에 붙일 짧은 표시. 빠진 요청이 없으면 null. */
7
- function unpricedRequestLabel(cost) {
8
- const count = unpricedRequestCount(cost);
9
- return count > 0 ? `+${count} unpriced` : null;
10
- }
11
- /** 표시에 붙일 설명. 이미지와 그 외 요청을 나눠 보여준다. */
12
- function unpricedRequestTitle(cost) {
13
- if (unpricedRequestCount(cost) === 0) return null;
14
- const media = cost.unknownCostCount ?? 0;
15
- return `Total excludes requests with unknown cost: ${cost.unknownImageCostCount} image, ${media} voice/video.`;
16
- }
17
- //#endregion
18
- export { unpricedRequestTitle as n, unpricedRequestLabel as t };