@cartanova/qgrid-cli 2.22.2 → 2.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/bundle/dist/application/qgrid/model-catalog.js +62 -0
  2. package/bundle/dist/application/qgrid/openai-compat.js +127 -0
  3. package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +2 -2
  4. package/bundle/dist/application/qgrid/qgrid.frame.js +204 -8
  5. package/bundle/dist/application/qgrid/qgrid.types.js +82 -2
  6. package/bundle/dist/application/qgrid/transcribe-stream.js +282 -0
  7. package/bundle/dist/application/queries.generated.js +2 -1
  8. package/bundle/dist/application/request-log/request-log.model.js +5 -4
  9. package/bundle/dist/server-error-handler.js +6 -3
  10. package/bundle/dist/sonamu.config.js +5 -2
  11. package/bundle/dist/utils/providers/anthropic/anthropic-constants.js +8 -2
  12. package/bundle/dist/utils/providers/anthropic/anthropic-quota.js +1 -1
  13. package/bundle/dist/utils/providers/common/model-cost.js +29 -2
  14. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +9 -1
  15. package/bundle/dist/utils/providers/openai/openai-realtime-protocol.js +38 -6
  16. package/bundle/dist/utils/providers/openai/openai-voice-client.js +131 -3
  17. package/bundle/src/application/qgrid/model-catalog.test.ts +37 -0
  18. package/bundle/src/application/qgrid/model-catalog.ts +85 -0
  19. package/bundle/src/application/qgrid/openai-compat.test.ts +99 -0
  20. package/bundle/src/application/qgrid/openai-compat.ts +157 -0
  21. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +1 -1
  22. package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +1 -1
  23. package/bundle/src/application/qgrid/qgrid.frame.test.ts +5 -0
  24. package/bundle/src/application/qgrid/qgrid.frame.ts +294 -0
  25. package/bundle/src/application/qgrid/qgrid.types.ts +134 -0
  26. package/bundle/src/application/qgrid/transcribe-stream.test.ts +165 -0
  27. package/bundle/src/application/qgrid/transcribe-stream.ts +381 -0
  28. package/bundle/src/application/queries.generated.ts +3 -0
  29. package/bundle/src/application/request-log/request-log.model.test.ts +4 -3
  30. package/bundle/src/application/request-log/request-log.model.ts +4 -3
  31. package/bundle/src/application/sonamu.generated.http +12 -0
  32. package/bundle/src/server-error-handler.ts +10 -7
  33. package/bundle/src/sonamu.config.ts +4 -0
  34. package/bundle/src/utils/providers/anthropic/anthropic-constants.test.ts +3 -0
  35. package/bundle/src/utils/providers/anthropic/anthropic-constants.ts +3 -1
  36. package/bundle/src/utils/providers/anthropic/anthropic-quota.ts +1 -1
  37. package/bundle/src/utils/providers/common/effort.test.ts +2 -0
  38. package/bundle/src/utils/providers/common/model-cost.test.ts +11 -0
  39. package/bundle/src/utils/providers/common/model-cost.ts +43 -5
  40. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +15 -0
  41. package/bundle/src/utils/providers/openai/openai-realtime-protocol.ts +46 -5
  42. package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +89 -2
  43. package/bundle/src/utils/providers/openai/openai-voice-client.ts +188 -0
  44. package/bundle/web-dist/client/assets/index-CtkfXtee.js +104 -0
  45. package/bundle/web-dist/client/assets/logs-C_U9lGtE.js +1 -0
  46. package/bundle/web-dist/client/assets/{monit-0qjGcPcD.js → monit-CNQyE4bk.js} +1 -1
  47. package/bundle/web-dist/client/assets/{routes-D53FyOOp.js → routes-72N6ogd2.js} +2 -2
  48. package/bundle/web-dist/client/assets/{settings-Cbz57odO.js → settings-DbwnDBrc.js} +1 -1
  49. package/bundle/web-dist/client/assets/{show-Boi25Rbi.js → show-BPkKGDnC.js} +2 -2
  50. package/bundle/web-dist/client/assets/tokens-2ig4rFfF.js +1 -0
  51. package/bundle/web-dist/client/assets/{use-oauth-login-flow-CjFv4NI0.js → use-oauth-login-flow-CvjEVH_T.js} +1 -1
  52. package/bundle/web-dist/client/assets/use-update-token-mutation-C8viUPmK.js +1 -0
  53. package/bundle/web-dist/client/assets/{voice-BDO8X2H0.js → voice-D2RSPjn9.js} +2 -2
  54. package/bundle/web-dist/client/index.html +1 -1
  55. package/bundle/web-dist/server/assets/{TimedPlayer-mpJpP5tQ.js → TimedPlayer-B9ds1sqM.js} +1 -1
  56. package/bundle/web-dist/server/assets/{logs-CFa_xamY.js → logs-JziKvWBp.js} +3 -3
  57. package/bundle/web-dist/server/assets/{monit-BF6osfj5.js → monit-CzjNOowb.js} +2 -2
  58. package/bundle/web-dist/server/assets/{plus-DwQFfeid.js → plus-BrRDgdaN.js} +1 -1
  59. package/bundle/web-dist/server/assets/{refresh-cw-Bj-Jxeb6.js → refresh-cw-wU5-wVTi.js} +1 -1
  60. package/bundle/web-dist/server/assets/{request-model-D_iYrudl.js → request-model-D07WSRKx.js} +1 -1
  61. package/bundle/web-dist/server/assets/{routes-B6be8sJP.js → routes-C1tDj0QN.js} +3 -3
  62. package/bundle/web-dist/server/assets/{services.generated-D0995hJr.js → services.generated-rlOX8J2n.js} +201 -0
  63. package/bundle/web-dist/server/assets/{settings-DAle7AgI.js → settings-DJQUI8bU.js} +3 -3
  64. package/bundle/web-dist/server/assets/{show-BTSdMDoM.js → show-BElTj6MG.js} +3 -3
  65. package/bundle/web-dist/server/assets/{tokens-Bc9flfLz.js → tokens-CRpUPv-5.js} +4 -4
  66. package/bundle/web-dist/server/assets/{use-oauth-login-flow-C7c0gCjf.js → use-oauth-login-flow-DLRPNhNE.js} +1 -1
  67. package/bundle/web-dist/server/assets/{use-update-token-mutation-DLJDGdxu.js → use-update-token-mutation-DJkct-j8.js} +1 -1
  68. package/bundle/web-dist/server/assets/{voice-CEQT57xZ.js → voice-BZBlBBpn.js} +4 -10
  69. package/bundle/web-dist/server/entry-server.generated.js +118 -26
  70. package/package.json +1 -1
  71. package/skills/qgrid/references/anthropic-claude-code-runtime.md +4 -3
  72. package/skills/qgrid/references/openai-codex-runtime.md +29 -10
  73. package/skills/qgrid/references/sonamu-api-web-flow.md +1 -1
  74. package/bundle/web-dist/client/assets/index-CiSsWsVT.js +0 -104
  75. package/bundle/web-dist/client/assets/logs-Bir9gDzp.js +0 -1
  76. package/bundle/web-dist/client/assets/tokens-BuK8BpAd.js +0 -1
  77. package/bundle/web-dist/client/assets/use-update-token-mutation-BKufO9oe.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n}from"./vendor-react-8xo7RSum.js";import{d as r,u as i}from"./vendor-tanstack-DMgmqjm4.js";import{a,c as o,d as s,i as c,s as l}from"./index-CiSsWsVT.js";import{i as u,r as d,t as f}from"./cost-CZzlCFS2.js";import{t as p}from"./refresh-cw-BtYoFHVw.js";import{n as ee,t as m}from"./request-model-Dl31cZdf.js";var h=e(t()),g=n(),_=(0,h.forwardRef)(({title:e,titleId:t,...n},r)=>(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,ref:r,"aria-labelledby":t,...n,children:[e?(0,g.jsx)(`title`,{id:t,children:e}):null,(0,g.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m15 18l-6-6l6-6`})]})),v=(0,h.forwardRef)(({title:e,titleId:t,...n},r)=>(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,ref:r,"aria-labelledby":t,...n,children:[e?(0,g.jsx)(`title`,{id:t,children:e}):null,(0,g.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m9 18l6-6l-6-6`})]})),y=50,b=`__unassigned__`;function x(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 S(e){return e.toLocaleString()}function te(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}var ne=3e3;function re({status:e,requestedModel:t,servedModel:n,imageCostMethod:r,fallbackCount:i}){if(e===`running`){let i=m({status:e,requestedModel:t,servedModel:n,imageCostMethod:r});return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`text-xs text-sand-500`,children:i.label}),(0,g.jsx)(`span`,{className:`ml-1 text-[9px] px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-600 font-medium whitespace-nowrap`,children:`실행 중`})]})}let a=m({status:e,requestedModel:t,servedModel:n,imageCostMethod:r}),o=t!==null&&n===null;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`text-xs text-sand-500`,children:a.label}),o&&(0,g.jsx)(`span`,{className:`ml-1 text-[9px] text-sand-400`,children:`요청`}),(i??0)>0&&(0,g.jsxs)(`span`,{className:`ml-1 text-[9px] text-caution-500`,children:[`×`,i]})]})}function C(e){return e<=0?`—`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}var w=[{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-20`},{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 T({search:e,onSearchChange:t}){let n=r(),c=e.page??1,m=e.token??``,T=e.project??``,E=e.model??``,{data:D}=s.useTokens(`A`),O=(D?.rows??[]).map(e=>e.name).filter(Boolean),{data:k}=l.useProjectNames(),A=k?.names??[],{data:j}=l.useModelNames(),M=j?.names??[],N=T===b?{project_name_is_null:!0}:T?{project_name:T}:{},P={};m&&(P.token_name=m),Object.assign(P,N),E&&(P.model_name=E);let F=e.sort??`id-desc`,I=F.lastIndexOf(`-`),L=F.slice(0,I),R=F.slice(I+1)===`asc`?`asc`:`desc`,{data:z,isLoading:B,isError:V,refresh:H,isRefreshing:U}=o.useRequestLogs(`P`,{num:y,page:c,orderBy:F,queryMode:`list`,...P}),{data:W,refresh:G}=o.useRequestLogs(`P`,{num:y,page:1,queryMode:`count`,...P}),{data:K,isError:q,refresh:J}=l.useTotalCost({num:0,page:1,...P}),Y=z?.rows??[],X=W?.total,Z=Y.some(e=>e.status===`running`);(0,h.useEffect)(()=>{let e=Z?setInterval(()=>{H(),G(),J()},ne):void 0;return()=>clearInterval(e)},[Z,H,G,J]);let Q=X===void 0?0:Math.ceil(X/y),$=n=>{t({...e,...n,page:1})};return(0,g.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,g.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,g.jsxs)(`select`,{value:m,onChange:e=>$({token:e.target.value||void 0}),disabled:O.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,g.jsx)(`option`,{value:``,children:O.length>0?`All Tokens`:`Tokens —`}),O.map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))]}),(0,g.jsxs)(`select`,{value:T,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,g.jsx)(`option`,{value:``,children:`All Projects`}),(0,g.jsx)(`option`,{value:b,children:`(unassigned)`}),A.map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))]}),(0,g.jsxs)(`select`,{value:E,onChange:e=>$({model:e.target.value||void 0}),disabled:M.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,g.jsx)(`option`,{value:``,children:M.length>0?`All Models`:`Models —`}),M.map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>void Promise.all([H(),G(),J()]),disabled:U,"aria-label":`Reload`,title:`Reload`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,children:(0,g.jsx)(p,{className:U?`size-3.5 animate-spin`:`size-3.5`})}),(0,g.jsx)(`div`,{className:`flex-1`}),(0,g.jsxs)(`span`,{className:`text-[11px] text-sand-400`,children:[X===void 0?`—`:X,` results`]}),q?(0,g.jsx)(`span`,{role:`alert`,className:`text-[11px] text-danger-500`,children:`Failed to load total cost.`}):(0,g.jsx)(`span`,{className:`text-[11px] tabular-nums font-medium text-sienna-600`,children:K?u(K.usd):`—`})]}),V?(0,g.jsx)(`div`,{role:`alert`,className:`text-danger-500 text-center py-12 text-sm`,children:`Failed to load request logs.`}):B?(0,g.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:5}).map((e,t)=>(0,g.jsx)(`div`,{className:`h-8 bg-sand-100 rounded animate-pulse`},`skel-${t}`))}):Y.length===0?(0,g.jsx)(`div`,{className:`text-sand-400 text-center py-12 text-sm`,children:`No requests yet.`}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`overflow-x-auto px-3 py-3 sm:px-5`,children:(0,g.jsxs)(`table`,{className:`w-full min-w-[900px] text-[13px]`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-sand-100/60`,children:[w.map(e=>{let t=e.label===`Duration`?`pl-5 pr-3`:e.width?`px-4`:`px-3`,n=e.sortKey===L;return(0,g.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,g.jsxs)(`button`,{type:`button`,onClick:()=>$({sort:a.parse(`${e.sortKey}-${n&&R===`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,g.jsx)(`span`,{className:n?``:`text-sand-300`,children:n?R===`desc`?`↓`:`↑`:`↕`})]}):e.label},e.label)}),(0,g.jsx)(`th`,{className:`w-8`,children:(0,g.jsx)(`span`,{className:`sr-only`,children:`Details`})})]})}),(0,g.jsx)(`tbody`,{className:`divide-y divide-sand-100/60`,children:Y.map(e=>(0,g.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer`,onClick:t=>{t.metaKey||t.ctrlKey?window.open(`/requests/show?id=${e.id}`,`_blank`):n({to:`/requests/show`,search:{id:e.id}})},children:[(0,g.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,g.jsx)(i,{to:`/requests/show`,search:{id:e.id},onClick:e=>e.stopPropagation(),className:`text-xs text-sand-500 tabular-nums hover:text-sienna-500`,children:e.id})}),(0,g.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,g.jsx)(`span`,{className:`text-xs text-sand-400 tabular-nums`,children:x(e.created_at)})}),(0,g.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,g.jsx)(`span`,{className:`text-xs text-sand-600`,children:e.project_name??`—`})}),(0,g.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,g.jsx)(`span`,{className:`text-xs text-sand-500`,children:e.token_name})}),(0,g.jsxs)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:[(0,g.jsx)(re,{status:e.status,requestedModel:e.requested_model_name,servedModel:e.model_name,imageCostMethod:e.image_cost_method,fallbackCount:e.fallback_count}),e.service_tier===`fast`&&(0,g.jsx)(`span`,{title:`Fast 모드`,className:`ml-1 inline-flex align-middle`,children:(0,g.jsx)(ee,{"aria-label":`Fast 모드`,className:`size-3 text-[#1877F2] [&_path]:fill-current`})}),e.response_json_ok===!1&&(0,g.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,g.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:e.media_kind===`stt`||e.media_kind===`tts`||e.media_kind===`live`?(0,g.jsxs)(`span`,{className:`rounded bg-blue-100 px-1.5 py-0.5 font-mono text-[10px] text-blue-700`,children:[`voice/`,e.media_kind]}):e.media_kind===`decision`?(0,g.jsx)(`span`,{className:`rounded bg-blue-100 px-1.5 py-0.5 font-mono text-[10px] text-blue-700`,children:`decision`}):e.media_kind===`video`?(0,g.jsx)(`span`,{className:`rounded bg-sand-100 px-1.5 py-0.5 font-mono text-[10px] text-sand-700`,children:`video`}):e.is_image_generation?(0,g.jsx)(`span`,{className:`rounded bg-sage-100 px-1.5 py-0.5 font-mono text-[10px] text-sage-700`,children:`img`}):e.is_structured?(0,g.jsx)(`span`,{className:`rounded bg-sienna-100 px-1.5 py-0.5 font-mono text-[10px] text-sienna-700`,children:`json`}):(0,g.jsx)(`span`,{className:`font-mono text-[10px] text-sand-400`,children:`text`})}),(0,g.jsx)(`td`,{className:`px-4 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap`,children:C(e.ttft_ms)}),(0,g.jsx)(`td`,{className:`pl-5 pr-3 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap`,children:te(e.duration_ms)}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:S(e.input_tokens)}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:S(e.output_tokens)}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:S(e.cache_read_tokens)}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:S(e.cache_creation_tokens)}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:f(e)}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-500`,children:e.tool_call_count>0?e.tool_call_count:`—`}),(0,g.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700 whitespace-nowrap`,children:d(e)}),(0,g.jsx)(`td`,{className:`px-2 py-1.5`,children:(0,g.jsx)(v,{className:`size-4 text-sand-400`})})]},e.id))})]})}),Q>1&&(0,g.jsxs)(`div`,{className:`flex items-center justify-center gap-3 px-5 py-2.5 border-t border-sand-100/60`,children:[(0,g.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:c===1,onClick:()=>t({...e,page:c-1}),children:(0,g.jsx)(_,{className:`size-4`})}),(0,g.jsxs)(`span`,{className:`text-[11px] text-sand-400 tabular-nums`,children:[c,` / `,Q]}),(0,g.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:c===Q,onClick:()=>t({...e,page:c+1}),children:(0,g.jsx)(v,{className:`size-4`})})]})]})]})}function E(){let e=c.useSearch(),t=c.useNavigate();return(0,g.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,g.jsx)(T,{search:e,onSearchChange:e=>t({search:e})})})}export{E as component};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n}from"./vendor-react-8xo7RSum.js";import{P as r}from"./vendor-tanstack-DMgmqjm4.js";import{i,n as a,r as o}from"./use-oauth-login-flow-CjFv4NI0.js";import{M as s,d as c,s as l}from"./index-CiSsWsVT.js";import{t as u}from"./use-update-token-mutation-BKufO9oe.js";import{t as d}from"./plus-Bab0ACnC.js";var f=e(t(),1),p=n();function m(e){let t=Math.max(Math.ceil(e/1e3),0),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function h({expiresAt:e}){let[t,n]=(0,f.useState)(()=>Date.now());return(0,f.useEffect)(()=>{let e=window.setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,p.jsx)(`span`,{className:`tabular-nums`,children:m(e-t)})}function g({flow:e,onRestart:t}){return(0,p.jsxs)(`div`,{className:`space-y-2`,children:[e.status===`starting`&&(0,p.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[12px] text-sand-600`,children:[(0,p.jsx)(`span`,{className:`w-3.5 h-3.5 border-2 border-sand-400 border-t-transparent rounded-full animate-spin`}),`Requesting device code...`]}),e.status===`waiting`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`text-[12px] text-sand-600 leading-relaxed`,children:`아래 링크를 열어 xAI 계정으로 로그인한 뒤 이 코드를 입력하세요. 승인되면 토큰이 자동으로 추가됩니다.`}),(0,p.jsxs)(`div`,{className:`rounded-md border border-sand-200 bg-sand-50 px-3 py-3 text-center`,children:[(0,p.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Device code`}),(0,p.jsx)(`p`,{className:`mt-1 font-mono text-lg tracking-widest text-sand-900 select-all`,children:e.userCode})]}),(0,p.jsx)(`a`,{href:e.verificationUriComplete??e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`block w-full py-2.5 text-sm font-medium rounded-md bg-sand-900 text-white text-center hover:bg-sand-800 transition-colors duration-150`,children:`Open xAI to approve`}),(0,p.jsxs)(`p`,{className:`flex items-center justify-between text-[11px] text-sand-500`,children:[(0,p.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,p.jsx)(`span`,{className:`w-2.5 h-2.5 border-2 border-sand-400 border-t-transparent rounded-full animate-spin`}),e.slowDown?`Waiting for approval (polling slowed down)...`:`Waiting for approval...`]}),(0,p.jsxs)(`span`,{children:[`expires in `,(0,p.jsx)(h,{expiresAt:e.expiresAt})]})]})]}),e.status===`added`&&(0,p.jsxs)(`p`,{className:`text-[12px] text-sage-600`,children:[`Token "`,e.name,`" added.`]}),e.status===`expired`&&(0,p.jsx)(`p`,{className:`text-[11px] text-red-500`,children:`Device code가 만료되었습니다 — 로그인을 다시 시작하세요.`}),e.status===`error`&&(0,p.jsx)(`p`,{className:`text-[11px] text-red-500`,children:e.message}),(0,p.jsx)(`button`,{type:`button`,className:`w-full py-1.5 text-[12px] text-sand-500 hover:text-sand-700 transition-colors duration-150`,onClick:t,children:`처음부터 다시 시작`})]})}function _({light:e}){return(0,p.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,p.jsx)(`span`,{className:`w-3.5 h-3.5 border-2 border-t-transparent rounded-full animate-spin ${e?`border-white`:`border-sand-400`}`}),`Waiting for login...`]})}function v(){return(0,p.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,p.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`}),(0,p.jsx)(`span`,{className:`text-[10px] text-sand-400 uppercase`,children:`or`}),(0,p.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`})]})}function y({disabled:e,loadingProvider:t,onStart:n,onStartGrokDevice:r}){let i=`w-full py-2.5 text-sm font-medium rounded-md border border-sand-300 text-sand-700 hover:bg-sand-100 disabled:opacity-50 transition-colors duration-150 flex items-center justify-center gap-2`;return(0,p.jsxs)(`div`,{className:`space-y-2`,children:[(0,p.jsx)(`button`,{type:`button`,className:`w-full py-2.5 text-sm font-medium rounded-md bg-sand-900 text-white hover:bg-sand-800 disabled:opacity-50 transition-colors duration-150 flex items-center justify-center gap-2`,disabled:e,onClick:()=>n(`openai`),children:t===`openai`?(0,p.jsx)(_,{light:!0}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s,{className:`size-4`}),`Login with OpenAI`]})}),(0,p.jsx)(v,{}),(0,p.jsx)(`button`,{type:`button`,className:i,disabled:e,onClick:()=>n(`anthropic`),children:t===`anthropic`?(0,p.jsx)(_,{light:!1}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s,{className:`size-4`}),`Login with Claude`]})}),(0,p.jsx)(v,{}),(0,p.jsx)(`button`,{type:`button`,className:i,disabled:e,onClick:r,children:t===`grok`?(0,p.jsx)(_,{light:!1}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s,{className:`size-4`}),`Login with xAI`]})})]})}function b(){let[e,t]=(0,f.useState)(!1),[n,r]=(0,f.useState)(``),s=a(),c=()=>{t(!1),r(``),s.reset()},l=async e=>{await s.submitCode(e)&&c()};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`button`,{type:`button`,className:`px-3.5 py-1.5 text-[12px] font-medium rounded-lg bg-sienna-500 text-white hover:bg-sienna-600 disabled:opacity-50 transition-all duration-150 active:scale-[0.97] flex items-center gap-1.5 shadow-sm`,onClick:()=>t(!0),children:[(0,p.jsx)(d,{className:`size-3.5`}),`Add Token`]}),e&&(0,p.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:c,onKeyDown:()=>{}}),(0,p.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-md mx-4`,children:[(0,p.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100/50`,children:(0,p.jsx)(`h2`,{className:`text-base font-medium text-sand-900`,children:`Add Token`})}),(0,p.jsxs)(`div`,{className:`px-5 py-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name *`}),(0,p.jsx)(i,{value:n,onChange:e=>r(e.target.value),placeholder:`e.g. your-token-name`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`})]}),s.codeEntryProvider?(0,p.jsx)(o,{provider:s.codeEntryProvider,isPending:s.completeMutation.isPending,isError:s.completeMutation.isError,onSubmit:e=>void l(e),onRestart:s.reset}):s.deviceFlow?(0,p.jsx)(g,{flow:s.deviceFlow,onRestart:s.reset}):(0,p.jsx)(y,{disabled:!n.trim()||s.loadingProvider!==null,loadingProvider:s.loadingProvider,onStart:e=>void s.start(e,n),onStartGrokDevice:()=>void s.startDevice(n,c)})]}),(0,p.jsx)(`div`,{className:`px-5 py-3 border-t border-sand-100/50 flex items-center justify-end gap-2`,children:(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:c,children:`Cancel`})})]})]})]})}var x=(0,f.forwardRef)(({title:e,titleId:t,...n},r)=>(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,ref:r,"aria-labelledby":t,...n,children:[e?(0,p.jsx)(`title`,{id:t,children:e}):null,(0,p.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4`})]})),S=(0,f.forwardRef)(({title:e,titleId:t,...n},r)=>(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,ref:r,"aria-labelledby":t,...n,children:[e?(0,p.jsx)(`title`,{id:t,children:e}):null,(0,p.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]}));function C(e){let t=e.accessToken;return t?t.length<=12?t:`${t.slice(0,8)}...${t.slice(-4)}`:`—`}function w(e){let t=e.credentials;if(`accessTokenExpiresAt`in t)return t.accessTokenExpiresAt;if(`authMode`in t){let e=Date.parse(t.expiresAt);return Number.isNaN(e)?null:e}return t.expiresAt}function T(e){if(!e)return{text:``,color:``};let t=e-Date.now();if(t<=0)return{text:`expired`,color:`text-red-500`};let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=n>0?`${n}h ${r}m`:`${r}m`;return t<36e5?{text:i,color:`text-amber-500`}:{text:i,color:`text-sand-400`}}function E({data:e,isLoading:t}){let[n,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(null),[c,d]=(0,f.useState)(``),m=r(),h=l.useRemoveTokenMutation(),g=u(),_=l.useToggleTokenMutation(),v=()=>Promise.all([m.invalidateQueries({queryKey:[`Token`]}),m.invalidateQueries({queryKey:[`Qgrid`]})]),y=async e=>{await _.mutateAsync({id:e.id}),await v()},b=async()=>{n&&(await h.mutateAsync({id:n.id}),await v(),a(null))},E=e=>{s(e),d(e.name??``)},D=async()=>{o&&(await g.mutateAsync({id:o.id,name:c.trim()}),await v(),s(null))};if(t)return(0,p.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,p.jsx)(`div`,{className:`h-12 bg-sand-100 rounded-md animate-pulse`},`skeleton-${t}`))});let O=e??[];return O.length===0?(0,p.jsxs)(`div`,{className:`text-sand-400 text-center py-16 text-sm`,children:[`No tokens registered. Click `,(0,p.jsx)(`strong`,{className:`text-sand-600`,children:`Add Token`}),` to get started.`]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`panel overflow-hidden`,children:(0,p.jsx)(`div`,{className:`overflow-x-auto`,children:(0,p.jsxs)(`table`,{className:`w-full min-w-[640px] text-[13px]`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{className:`panel-header`,children:[(0,p.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Provider`}),(0,p.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Name`}),(0,p.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Token`}),(0,p.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Status`}),(0,p.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Expires`}),(0,p.jsx)(`th`,{className:`w-20 px-3 py-2.5`,children:(0,p.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,p.jsx)(`tbody`,{className:`divide-y divide-sand-100/80`,children:O.map(e=>{let t=T(w(e));return(0,p.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 ${e.active?``:`opacity-50`}`,children:[(0,p.jsx)(`td`,{className:`px-5 py-3`,children:(0,p.jsx)(`span`,{className:`text-xs font-medium text-sand-500 uppercase`,children:e.provider})}),(0,p.jsx)(`td`,{className:`px-5 py-3`,children:e.name?(0,p.jsx)(`span`,{className:`text-sm text-sand-700`,children:e.name}):(0,p.jsx)(`span`,{className:`text-[11px] text-sand-400`,children:`—`})}),(0,p.jsx)(`td`,{className:`px-5 py-3`,children:(0,p.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:C(e.credentials)})}),(0,p.jsx)(`td`,{className:`px-5 py-3`,children:(0,p.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.active,"aria-label":`${e.name||e.provider} active`,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 ${e.active?`bg-sage-400`:`bg-sand-300`}`,onClick:()=>y(e),disabled:_.isPending||!e.active&&e.reauth_required,title:!e.active&&e.reauth_required?`재로그인이 필요한 토큰입니다`:void 0,children:(0,p.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform duration-200 ${e.active?`translate-x-4.5`:`translate-x-0.5`}`})})}),(0,p.jsx)(`td`,{className:`px-5 py-3`,children:t.text&&(0,p.jsx)(`span`,{className:`text-xs ${t.color}`,children:t.text})}),(0,p.jsx)(`td`,{className:`px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`button`,{type:`button`,"aria-label":`Edit token`,className:`p-1 rounded text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:()=>E(e),children:(0,p.jsx)(x,{className:`size-4`})}),(0,p.jsx)(`button`,{type:`button`,"aria-label":`Delete token`,className:`p-1 rounded text-sand-400 hover:text-red-500 transition-colors duration-150`,onClick:()=>a(e),children:(0,p.jsx)(S,{className:`size-4`})})]})})]},e.id)})})]})})}),o&&(0,p.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:()=>s(null),onKeyDown:()=>{}}),(0,p.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-sm mx-4`,children:[(0,p.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100/60`,children:(0,p.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Edit Token`})}),(0,p.jsx)(`div`,{className:`px-5 py-4 space-y-3`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name`}),(0,p.jsx)(i,{value:c,onChange:e=>d(e.target.value),placeholder:`e.g. prod, dev, team-a`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`})]})}),(0,p.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100/60 flex items-center justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:()=>s(null),children:`Cancel`}),(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:g.isPending,onClick:D,children:g.isPending?`Saving...`:`Save`})]})]})]}),n&&(0,p.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:()=>a(null),onKeyDown:()=>{}}),(0,p.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-sm mx-4`,children:[(0,p.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,p.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Remove Token`}),(0,p.jsxs)(`p`,{className:`text-sm text-sand-700 mt-2`,children:[`Are you sure you want to remove`,` `,(0,p.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:C(n.credentials)}),n.name&&(0,p.jsxs)(`span`,{className:`text-sand-500`,children:[` (`,n.name,`)`]}),`?`]})]}),(0,p.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100/60 flex items-center justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:()=>a(null),children:`Cancel`}),(0,p.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 transition-colors duration-150`,disabled:h.isPending,onClick:b,children:h.isPending?`Removing...`:`Remove`})]})]})]})]})}function D(){let{data:e,isLoading:t}=c.useTokens(`A`);return(0,p.jsxs)(`div`,{className:`max-w-6xl mx-auto space-y-4`,children:[(0,p.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,p.jsx)(b,{})}),(0,p.jsx)(E,{data:e?.rows,isLoading:t})]})}export{D as component};
@@ -1 +0,0 @@
1
- import{m as e}from"./vendor-tanstack-DMgmqjm4.js";import{s as t}from"./index-CiSsWsVT.js";function n(){return e({mutationFn:({id:e,name:n,quotaThreshold:r,weight:i,keepaliveEnabled:a})=>t.updateToken(e,n,r,i,a)})}export{n as t};