@cartanova/qgrid-cli 2.11.0 → 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 (88) 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-CK9LwGNV.js +32 -0
  30. package/bundle/web-dist/client/assets/logs-DjQcEivP.js +1 -0
  31. package/bundle/web-dist/client/assets/monit-RTxpU7oZ.js +1 -0
  32. package/bundle/web-dist/client/assets/plus-DDvVTvQP.js +1 -0
  33. package/bundle/web-dist/client/assets/refresh-cw-CTQsNddA.js +1 -0
  34. package/bundle/web-dist/client/assets/request-model-DliRuPcw.js +1 -0
  35. package/bundle/web-dist/client/assets/routes-DVHoo-YF.js +5 -0
  36. package/bundle/web-dist/client/assets/{services.generated-CefiDXEv.js → services.generated-B5lc3aIC.js} +1 -1
  37. package/bundle/web-dist/client/assets/settings-BQUz6UFr.js +1 -0
  38. package/bundle/web-dist/client/assets/show-CalQG1Ew.js +2 -0
  39. package/bundle/web-dist/client/assets/tokens-DU4fWXI9.js +1 -0
  40. package/bundle/web-dist/client/assets/use-oauth-login-flow-BfxYI4Oh.js +1 -0
  41. package/bundle/web-dist/client/assets/use-update-token-mutation-qKBC2sn7.js +1 -0
  42. package/bundle/web-dist/client/assets/vendor-react-DH4kUfK2.js +9 -0
  43. package/bundle/web-dist/client/assets/vendor-tanstack-DRPs09ai.js +1 -0
  44. package/bundle/web-dist/client/index.html +4 -4
  45. package/bundle/web-dist/server/assets/{lazyRouteComponent-D8iTIHyn.js → lazyRouteComponent-AKiHfZWp.js} +2 -2
  46. package/bundle/web-dist/server/assets/logs-B5M5B7pN.js +531 -0
  47. package/bundle/web-dist/server/assets/{monit-B2hqorPe.js → monit-p6JM8MMl.js} +117 -375
  48. package/bundle/web-dist/server/assets/plus-I0FfLVgU.js +19 -0
  49. package/bundle/web-dist/server/assets/{react-dom-BIYQzBqG.js → react-dom-Cv23mm1K.js} +1 -1
  50. package/bundle/web-dist/server/assets/refresh-cw-DYsnffRC.js +23 -0
  51. package/bundle/web-dist/server/assets/{request-model-I6OdODSH.js → request-model-Cp6h5EuP.js} +7 -16
  52. package/bundle/web-dist/server/assets/{routes-B95YlUv2.js → routes-rIXpkI-t.js} +200 -691
  53. package/bundle/web-dist/server/assets/{services.generated-DQATJ6qf.js → services.generated-CMJ8AHbO.js} +3796 -4012
  54. package/bundle/web-dist/server/assets/settings-_MoaFGxj.js +461 -0
  55. package/bundle/web-dist/server/assets/{show-Bxaj3rhH.js → show-Cfm9UeDr.js} +375 -1271
  56. package/bundle/web-dist/server/assets/tokens-DMSHDg9D.js +560 -0
  57. package/bundle/web-dist/server/assets/{use-oauth-login-flow-CKDHgc3U.js → use-oauth-login-flow-jkAkT3X6.js} +16 -50
  58. package/bundle/web-dist/server/assets/{use-update-token-mutation-BEbgOzaa.js → use-update-token-mutation-Sm6kh02m.js} +1 -1
  59. package/bundle/web-dist/server/entry-server.generated.js +1177 -2657
  60. package/package.json +1 -1
  61. package/skills/qgrid/references/ai-sdk-provider-contract.md +1 -1
  62. package/skills/qgrid/references/cli-env-and-server-boot.md +4 -3
  63. package/skills/qgrid/references/decision-rationale.md +2 -1
  64. package/skills/qgrid/references/grok-runtime.md +7 -1
  65. package/skills/qgrid/references/repo-map.md +2 -0
  66. package/skills/qgrid/references/request-log-run-lifecycle.md +5 -0
  67. package/skills/qgrid/references/verification-and-debugging.md +24 -5
  68. package/bundle/web-dist/client/assets/index-BA7uQ-6c.js +0 -31
  69. package/bundle/web-dist/client/assets/logs-C47OJGEI.js +0 -1
  70. package/bundle/web-dist/client/assets/monit-BS9no0dU.js +0 -4
  71. package/bundle/web-dist/client/assets/plus-sdACTfH0.js +0 -1
  72. package/bundle/web-dist/client/assets/refresh-cw-CY8o_1cT.js +0 -1
  73. package/bundle/web-dist/client/assets/request-model-BRtFuZvj.js +0 -1
  74. package/bundle/web-dist/client/assets/routes-kqgkUxE8.js +0 -5
  75. package/bundle/web-dist/client/assets/settings-DNDvFGSw.js +0 -1
  76. package/bundle/web-dist/client/assets/show-u8Np69q3.js +0 -2
  77. package/bundle/web-dist/client/assets/tokens-QvP410NW.js +0 -1
  78. package/bundle/web-dist/client/assets/total-cost-MnfKU8IN.js +0 -1
  79. package/bundle/web-dist/client/assets/use-oauth-login-flow-Bzdh28Ws.js +0 -1
  80. package/bundle/web-dist/client/assets/use-update-token-mutation-CfJKaxmR.js +0 -1
  81. package/bundle/web-dist/client/assets/vendor-react-CUFFrVN9.js +0 -244
  82. package/bundle/web-dist/client/assets/vendor-tanstack-Bf_jag9G.js +0 -1
  83. package/bundle/web-dist/server/assets/logs-B3OTd9hy.js +0 -825
  84. package/bundle/web-dist/server/assets/plus-DwG7h9kq.js +0 -28
  85. package/bundle/web-dist/server/assets/refresh-cw-mMBkwOq0.js +0 -44
  86. package/bundle/web-dist/server/assets/settings-C3gbGk0m.js +0 -830
  87. package/bundle/web-dist/server/assets/tokens-CZjH3cB7.js +0 -1038
  88. package/bundle/web-dist/server/assets/total-cost-fTE9Xy82.js +0 -18
@@ -0,0 +1,531 @@
1
+ import { $ as __toESM, M as require_jsx_runtime, N as require_react, T as string, n as QgridService, o as TokenService, r as RequestLogService, w as object } from "./services.generated-CMJ8AHbO.js";
2
+ import { a as Link, o as useNavigate } from "./lazyRouteComponent-AKiHfZWp.js";
3
+ import { i as RequestLogOrderBy, n as Route, r as RequestLogBaseListParams } from "../entry-server.generated.js";
4
+ import { i as formatUsd, r as formatRequestCost, t as cacheHitRate } from "./cost-BC9yzyA9.js";
5
+ import { t as lucideRefreshCw } from "./refresh-cw-DYsnffRC.js";
6
+ import { n as lucideZap, t as requestModelDisplay } from "./request-model-Cp6h5EuP.js";
7
+ //#region ~icons/lucide/chevron-left.jsx
8
+ var import_react = /* @__PURE__ */ __toESM(require_react());
9
+ var import_jsx_runtime = require_jsx_runtime();
10
+ var lucideChevronLeft = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
11
+ viewBox: "0 0 24 24",
12
+ width: "1.2em",
13
+ height: "1.2em",
14
+ ...props,
15
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
16
+ fill: "none",
17
+ stroke: "currentColor",
18
+ strokeLinecap: "round",
19
+ strokeLinejoin: "round",
20
+ strokeWidth: 2,
21
+ d: "m15 18l-6-6l6-6"
22
+ })
23
+ });
24
+ //#endregion
25
+ //#region ~icons/lucide/chevron-right.jsx
26
+ var lucideChevronRight = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
27
+ viewBox: "0 0 24 24",
28
+ width: "1.2em",
29
+ height: "1.2em",
30
+ ...props,
31
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
32
+ fill: "none",
33
+ stroke: "currentColor",
34
+ strokeLinecap: "round",
35
+ strokeLinejoin: "round",
36
+ strokeWidth: 2,
37
+ d: "m9 18l6-6l-6-6"
38
+ })
39
+ });
40
+ //#endregion
41
+ //#region src/components/qgrid/RequestLogTable.tsx
42
+ var PAGE_SIZE = 50;
43
+ var UNASSIGNED = "__unassigned__";
44
+ function formatDateTime(value) {
45
+ const d = new Date(value);
46
+ return `${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")} ${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
47
+ }
48
+ function formatNum(n) {
49
+ return n.toLocaleString();
50
+ }
51
+ function formatDuration(ms) {
52
+ const total = Math.round(ms / 1e3);
53
+ const m = Math.floor(total / 60);
54
+ const s = total % 60;
55
+ return m > 0 ? `${m}m ${s}s` : `${s}s`;
56
+ }
57
+ var RUNNING_REFRESH_MS = 3e3;
58
+ function RequestModel({ status, requestedModel, servedModel, imageCostMethod, fallbackCount }) {
59
+ if (status === "running") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
60
+ className: "text-xs text-sand-500",
61
+ children: requestModelDisplay({
62
+ status,
63
+ requestedModel,
64
+ servedModel,
65
+ imageCostMethod
66
+ }).label
67
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
68
+ className: "ml-1 text-[9px] px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-600 font-medium whitespace-nowrap",
69
+ children: "실행 중"
70
+ })] });
71
+ const modelDisplay = requestModelDisplay({
72
+ status,
73
+ requestedModel,
74
+ servedModel,
75
+ imageCostMethod
76
+ });
77
+ const hasRequestedOnly = requestedModel !== null && servedModel === null;
78
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
80
+ className: "text-xs text-sand-500",
81
+ children: modelDisplay.label
82
+ }),
83
+ hasRequestedOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
84
+ className: "ml-1 text-[9px] text-sand-400",
85
+ children: "요청"
86
+ }),
87
+ (fallbackCount ?? 0) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
88
+ className: "ml-1 text-[9px] text-caution-500",
89
+ children: ["×", fallbackCount]
90
+ })
91
+ ] });
92
+ }
93
+ function formatTtft(ms) {
94
+ if (ms <= 0) return "—";
95
+ return ms >= 1e3 ? `${(ms / 1e3).toFixed(1)}s` : `${ms}ms`;
96
+ }
97
+ var COLUMNS = [
98
+ {
99
+ label: "ID",
100
+ align: "left",
101
+ width: "w-12",
102
+ sortKey: "id"
103
+ },
104
+ {
105
+ label: "Date",
106
+ align: "left",
107
+ width: "w-20",
108
+ sortKey: "created_at"
109
+ },
110
+ {
111
+ label: "Project",
112
+ align: "left",
113
+ width: "w-20"
114
+ },
115
+ {
116
+ label: "Token",
117
+ align: "left",
118
+ width: "w-24"
119
+ },
120
+ {
121
+ label: "Model",
122
+ align: "left",
123
+ width: "w-20"
124
+ },
125
+ {
126
+ label: "Fmt",
127
+ align: "left",
128
+ width: "w-12"
129
+ },
130
+ {
131
+ label: "TTFT",
132
+ align: "right",
133
+ width: "w-16",
134
+ sortKey: "ttft_ms"
135
+ },
136
+ {
137
+ label: "Duration",
138
+ align: "right",
139
+ width: "w-20",
140
+ sortKey: "duration_ms"
141
+ },
142
+ {
143
+ label: "In",
144
+ align: "right",
145
+ width: "w-16",
146
+ sortKey: "input_tokens"
147
+ },
148
+ {
149
+ label: "Out",
150
+ align: "right",
151
+ width: "w-20",
152
+ sortKey: "output_tokens"
153
+ },
154
+ {
155
+ label: "C.Read",
156
+ align: "right",
157
+ width: "w-20",
158
+ sortKey: "cache_read_tokens"
159
+ },
160
+ {
161
+ label: "C.Write",
162
+ align: "right",
163
+ width: "w-20",
164
+ sortKey: "cache_creation_tokens"
165
+ },
166
+ {
167
+ label: "Hit",
168
+ align: "right",
169
+ width: "w-14"
170
+ },
171
+ {
172
+ label: "Tools",
173
+ align: "right",
174
+ width: "w-14"
175
+ },
176
+ {
177
+ label: "$",
178
+ align: "right",
179
+ width: "w-20",
180
+ sortKey: "cost_usd"
181
+ }
182
+ ];
183
+ function RequestLogTable({ search, onSearchChange }) {
184
+ const navigate = useNavigate();
185
+ const page = search.page ?? 1;
186
+ const tokenFilter = search.token ?? "";
187
+ const projectFilter = search.project ?? "";
188
+ const modelFilter = search.model ?? "";
189
+ const { data: tokensData } = TokenService.useTokens("A");
190
+ const tokenNames = (tokensData?.rows ?? []).map((t) => t.name).filter(Boolean);
191
+ const { data: projectData } = QgridService.useProjectNames();
192
+ const projectNames = projectData?.names ?? [];
193
+ const { data: modelData } = QgridService.useModelNames();
194
+ const modelNames = modelData?.names ?? [];
195
+ const projectFilterParam = (() => {
196
+ if (projectFilter === UNASSIGNED) return { project_name_is_null: true };
197
+ if (projectFilter) return { project_name: projectFilter };
198
+ return {};
199
+ })();
200
+ const listFilters = {};
201
+ if (tokenFilter) listFilters.token_name = tokenFilter;
202
+ Object.assign(listFilters, projectFilterParam);
203
+ if (modelFilter) listFilters.model_name = modelFilter;
204
+ const sort = search.sort ?? "id-desc";
205
+ const separator = sort.lastIndexOf("-");
206
+ const sortColumn = sort.slice(0, separator);
207
+ const sortDirection = sort.slice(separator + 1) === "asc" ? "asc" : "desc";
208
+ const { data, isLoading, isError, refresh, isRefreshing } = RequestLogService.useRequestLogs("P", {
209
+ num: PAGE_SIZE,
210
+ page,
211
+ orderBy: sort,
212
+ ...listFilters
213
+ });
214
+ const { data: costData, isError: isCostError, refresh: refreshCost } = QgridService.useTotalCost({
215
+ num: 0,
216
+ page: 1,
217
+ ...listFilters
218
+ });
219
+ const rows = data?.rows ?? [];
220
+ const total = data?.total ?? 0;
221
+ const hasRunning = rows.some((row) => row.status === "running");
222
+ (0, import_react.useEffect)(() => {
223
+ if (!hasRunning) return;
224
+ const timer = setInterval(() => {
225
+ refresh();
226
+ refreshCost();
227
+ }, RUNNING_REFRESH_MS);
228
+ return () => clearInterval(timer);
229
+ }, [
230
+ hasRunning,
231
+ refresh,
232
+ refreshCost
233
+ ]);
234
+ const totalPages = Math.ceil(total / PAGE_SIZE);
235
+ const updateFilter = (patch) => {
236
+ onSearchChange({
237
+ ...search,
238
+ ...patch,
239
+ page: 1
240
+ });
241
+ };
242
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
243
+ className: "panel overflow-hidden",
244
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
245
+ className: "panel-header flex items-center gap-2 px-3 py-2.5 flex-wrap sm:gap-3 sm:px-5",
246
+ children: [
247
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
248
+ value: tokenFilter,
249
+ onChange: (e) => updateFilter({ token: e.target.value || void 0 }),
250
+ disabled: tokenNames.length === 0,
251
+ 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",
252
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
253
+ value: "",
254
+ children: tokenNames.length > 0 ? "All Tokens" : "Tokens —"
255
+ }), tokenNames.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
256
+ value: name,
257
+ children: name
258
+ }, name))]
259
+ }),
260
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
261
+ value: projectFilter,
262
+ onChange: (e) => updateFilter({ project: e.target.value || void 0 }),
263
+ 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",
264
+ children: [
265
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
266
+ value: "",
267
+ children: "All Projects"
268
+ }),
269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
270
+ value: UNASSIGNED,
271
+ children: "(unassigned)"
272
+ }),
273
+ projectNames.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
274
+ value: name,
275
+ children: name
276
+ }, name))
277
+ ]
278
+ }),
279
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
280
+ value: modelFilter,
281
+ onChange: (e) => updateFilter({ model: e.target.value || void 0 }),
282
+ disabled: modelNames.length === 0,
283
+ 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",
284
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
285
+ value: "",
286
+ children: modelNames.length > 0 ? "All Models" : "Models —"
287
+ }), modelNames.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
288
+ value: name,
289
+ children: name
290
+ }, name))]
291
+ }),
292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
293
+ type: "button",
294
+ onClick: () => void Promise.all([refresh(), refreshCost()]),
295
+ disabled: isRefreshing,
296
+ "aria-label": "Reload",
297
+ title: "Reload",
298
+ className: "p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors",
299
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideRefreshCw, { className: isRefreshing ? "size-3.5 animate-spin" : "size-3.5" })
300
+ }),
301
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1" }),
302
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
303
+ className: "text-[11px] text-sand-400",
304
+ children: [isError || !data ? "—" : total, " results"]
305
+ }),
306
+ isCostError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
307
+ role: "alert",
308
+ className: "text-[11px] text-danger-500",
309
+ children: "Failed to load total cost."
310
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
311
+ className: "text-[11px] tabular-nums font-medium text-sienna-600",
312
+ children: costData ? formatUsd(costData.usd) : "—"
313
+ })
314
+ ]
315
+ }), isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
316
+ role: "alert",
317
+ className: "text-danger-500 text-center py-12 text-sm",
318
+ children: "Failed to load request logs."
319
+ }) : isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
320
+ className: "space-y-2",
321
+ children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-8 bg-sand-100 rounded animate-pulse" }, `skel-${i}`))
322
+ }) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
323
+ className: "text-sand-400 text-center py-12 text-sm",
324
+ children: "No requests yet."
325
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
326
+ className: "overflow-x-auto px-3 py-3 sm:px-5",
327
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
328
+ className: "w-full min-w-[900px] text-[13px]",
329
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
330
+ className: "border-b border-sand-100/60",
331
+ children: [COLUMNS.map((col) => {
332
+ const padX = col.label === "Duration" ? "pl-5 pr-3" : col.width ? "px-4" : "px-3";
333
+ const active = col.sortKey === sortColumn;
334
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
335
+ className: `${col.align === "right" ? "text-right" : "text-left"} ${col.width ?? ""} ${col.width ? "whitespace-nowrap" : ""} ${padX} py-1.5 text-[10px] uppercase font-medium ${active ? "text-sienna-600" : "text-sand-400"}`,
336
+ children: col.sortKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
337
+ type: "button",
338
+ onClick: () => updateFilter({ sort: RequestLogOrderBy.parse(`${col.sortKey}-${active && sortDirection === "desc" ? "asc" : "desc"}`) }),
339
+ className: `inline-flex items-center gap-0.5 text-[10px] uppercase font-medium hover:text-sienna-500 transition-colors duration-150 ${col.align === "right" ? "justify-end w-full" : ""}`,
340
+ children: [col.label, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
341
+ className: active ? "" : "text-sand-300",
342
+ children: active ? sortDirection === "desc" ? "↓" : "↑" : "↕"
343
+ })]
344
+ }) : col.label
345
+ }, col.label);
346
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: "w-8" })]
347
+ }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", {
348
+ className: "divide-y divide-sand-100/60",
349
+ children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
350
+ className: "transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer",
351
+ onClick: (e) => {
352
+ if (e.metaKey || e.ctrlKey) {
353
+ window.open(`/requests/show?id=${row.id}`, "_blank");
354
+ return;
355
+ }
356
+ navigate({
357
+ to: "/requests/show",
358
+ search: { id: row.id }
359
+ });
360
+ },
361
+ children: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
363
+ className: "px-4 py-1.5 whitespace-nowrap",
364
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
365
+ to: "/requests/show",
366
+ search: { id: row.id },
367
+ onClick: (e) => e.stopPropagation(),
368
+ className: "text-xs text-sand-500 tabular-nums hover:text-sienna-500",
369
+ children: row.id
370
+ })
371
+ }),
372
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
373
+ className: "px-4 py-1.5 whitespace-nowrap",
374
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
375
+ className: "text-xs text-sand-400 tabular-nums",
376
+ children: formatDateTime(row.created_at)
377
+ })
378
+ }),
379
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
380
+ className: "px-4 py-1.5 whitespace-nowrap",
381
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
382
+ className: "text-xs text-sand-600",
383
+ children: row.project_name ?? "—"
384
+ })
385
+ }),
386
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
387
+ className: "px-4 py-1.5 whitespace-nowrap",
388
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
389
+ className: "text-xs text-sand-500",
390
+ children: row.token_name
391
+ })
392
+ }),
393
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", {
394
+ className: "px-4 py-1.5 whitespace-nowrap",
395
+ children: [
396
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RequestModel, {
397
+ status: row.status,
398
+ requestedModel: row.requested_model_name,
399
+ servedModel: row.model_name,
400
+ imageCostMethod: row.image_cost_method,
401
+ fallbackCount: row.fallback_count
402
+ }),
403
+ row.service_tier === "fast" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
404
+ title: "Fast 모드",
405
+ className: "ml-1 inline-flex align-middle",
406
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideZap, {
407
+ "aria-label": "Fast 모드",
408
+ className: "size-3 text-[#1877F2] [&_path]:fill-current"
409
+ })
410
+ }),
411
+ row.response_json_ok === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
412
+ title: "structured 요청의 응답이 JSON 파싱에 실패했습니다",
413
+ className: "ml-1.5 rounded-full bg-caution-400/15 px-1.5 py-0.5 text-[9px] font-semibold text-caution-500",
414
+ children: "broken"
415
+ })
416
+ ]
417
+ }),
418
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
419
+ className: "px-4 py-1.5 whitespace-nowrap",
420
+ children: row.is_image_generation ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
421
+ className: "rounded bg-sage-100 px-1.5 py-0.5 font-mono text-[10px] text-sage-700",
422
+ children: "img"
423
+ }) : row.is_structured ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
424
+ className: "rounded bg-sienna-100 px-1.5 py-0.5 font-mono text-[10px] text-sienna-700",
425
+ children: "json"
426
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
427
+ className: "font-mono text-[10px] text-sand-400",
428
+ children: "text"
429
+ })
430
+ }),
431
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
432
+ className: "px-4 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap",
433
+ children: formatTtft(row.ttft_ms)
434
+ }),
435
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
436
+ className: "pl-5 pr-3 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap",
437
+ children: formatDuration(row.duration_ms)
438
+ }),
439
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
440
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-700",
441
+ children: formatNum(row.input_tokens)
442
+ }),
443
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
444
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-700",
445
+ children: formatNum(row.output_tokens)
446
+ }),
447
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
448
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-700",
449
+ children: formatNum(row.cache_read_tokens)
450
+ }),
451
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
452
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-700",
453
+ children: formatNum(row.cache_creation_tokens)
454
+ }),
455
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
456
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-700",
457
+ children: cacheHitRate(row)
458
+ }),
459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
460
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-500",
461
+ children: row.tool_call_count > 0 ? row.tool_call_count : "—"
462
+ }),
463
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
464
+ className: "px-3 py-1.5 text-right tabular-nums text-sand-700 whitespace-nowrap",
465
+ children: formatRequestCost(row)
466
+ }),
467
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
468
+ className: "px-2 py-1.5",
469
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideChevronRight, { className: "size-4 text-sand-400" })
470
+ })
471
+ ]
472
+ }, row.id))
473
+ })]
474
+ })
475
+ }), totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
476
+ className: "flex items-center justify-center gap-3 px-5 py-2.5 border-t border-sand-100/60",
477
+ children: [
478
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
479
+ type: "button",
480
+ className: "p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors",
481
+ disabled: page === 1,
482
+ onClick: () => onSearchChange({
483
+ ...search,
484
+ page: page - 1
485
+ }),
486
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideChevronLeft, { className: "size-4" })
487
+ }),
488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
489
+ className: "text-[11px] text-sand-400 tabular-nums",
490
+ children: [
491
+ page,
492
+ " / ",
493
+ totalPages
494
+ ]
495
+ }),
496
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
497
+ type: "button",
498
+ className: "p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors",
499
+ disabled: page === totalPages,
500
+ onClick: () => onSearchChange({
501
+ ...search,
502
+ page: page + 1
503
+ }),
504
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideChevronRight, { className: "size-4" })
505
+ })
506
+ ]
507
+ })] })]
508
+ });
509
+ }
510
+ //#endregion
511
+ //#region src/routes/logs.tsx?tsr-split=component
512
+ object({
513
+ token: string().optional(),
514
+ project: string().optional(),
515
+ model: string().optional(),
516
+ sort: RequestLogOrderBy.optional(),
517
+ page: RequestLogBaseListParams.shape.page.default(1)
518
+ });
519
+ function LogsPage() {
520
+ const search = Route.useSearch();
521
+ const navigate = Route.useNavigate();
522
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
523
+ className: "max-w-[100rem] mx-auto",
524
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RequestLogTable, {
525
+ search,
526
+ onSearchChange: (next) => navigate({ search: next })
527
+ })
528
+ });
529
+ }
530
+ //#endregion
531
+ export { LogsPage as component };