@overlordai/server 1.0.38 → 1.0.39

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 (62) hide show
  1. package/dist/database/repositories/machine.repository.d.ts +2 -0
  2. package/dist/database/repositories/machine.repository.d.ts.map +1 -1
  3. package/dist/database/repositories/machine.repository.js +4 -0
  4. package/dist/database/repositories/machine.repository.js.map +1 -1
  5. package/dist/dispatcher/heartbeat.service.d.ts +2 -1
  6. package/dist/dispatcher/heartbeat.service.d.ts.map +1 -1
  7. package/dist/dispatcher/heartbeat.service.js +4 -1
  8. package/dist/dispatcher/heartbeat.service.js.map +1 -1
  9. package/dist/web/worker-channel.gateway.d.ts.map +1 -1
  10. package/dist/web/worker-channel.gateway.js +1 -1
  11. package/dist/web/worker-channel.gateway.js.map +1 -1
  12. package/package.json +2 -2
  13. package/public/assets/{AccessTokensPage-oPweGG_z.js → AccessTokensPage-DuICKFJy.js} +1 -1
  14. package/public/assets/{AdminPage-Dw1ng1n4.js → AdminPage-B8Yq8GnM.js} +1 -1
  15. package/public/assets/{ApiReferencePage-FUskCdjw.js → ApiReferencePage-DZDCJQI4.js} +1 -1
  16. package/public/assets/{AuditLogPage-nwiONLEk.js → AuditLogPage-MoCRMzqP.js} +1 -1
  17. package/public/assets/{BotManage-D2QsEBCS.js → BotManage-CVWwoYy3.js} +1 -1
  18. package/public/assets/{CliReferencePage-BdzdHAsN.js → CliReferencePage-DVB7E2Jv.js} +1 -1
  19. package/public/assets/{DeveloperManage-C8-2MMwr.js → DeveloperManage-BtO-lkvD.js} +1 -1
  20. package/public/assets/{EditProjectPage-DPTc1yRc.js → EditProjectPage-Bl2LyAeT.js} +1 -1
  21. package/public/assets/{EmptyState-CEWQv5SU.js → EmptyState-Bvs1SJo_.js} +1 -1
  22. package/public/assets/{HomePage-BkKwaAgJ.js → HomePage-BSubk1iR.js} +1 -1
  23. package/public/assets/{LandingPage-BBF_PnWk.js → LandingPage-COmKh2PR.js} +1 -1
  24. package/public/assets/{LoginPage-BXdJBXbE.js → LoginPage-DFIy5_AG.js} +1 -1
  25. package/public/assets/{MachineDetailPage-DeLR95cj.js → MachineDetailPage-BLOhWYiw.js} +1 -1
  26. package/public/assets/MachineListPage-CIqrEM7O.js +6 -0
  27. package/public/assets/{NotFoundPage-CDsk2FBZ.js → NotFoundPage-BqLQpkaf.js} +1 -1
  28. package/public/assets/{PipelineEditorPage-DRxoetje.js → PipelineEditorPage-CyOhoLwR.js} +1 -1
  29. package/public/assets/{ProfilePage-DYw8NzPC.js → ProfilePage-D8UfMNDf.js} +1 -1
  30. package/public/assets/{ProjectDetailPage-BVi8nkb1.js → ProjectDetailPage-8DxQkhBt.js} +1 -1
  31. package/public/assets/{ProjectListPage-BJxuXui-.js → ProjectListPage-Dwcp60o1.js} +1 -1
  32. package/public/assets/{QuickAuth-CAi3n0Qs.js → QuickAuth-CWpVD-8o.js} +1 -1
  33. package/public/assets/{RemoveMemberConfirmDialog-sqtFnOvO.js → RemoveMemberConfirmDialog-DQ3dXuC6.js} +1 -1
  34. package/public/assets/{Select-CRpdafWl.js → Select-GhXJ5uKF.js} +1 -1
  35. package/public/assets/{SettingsPage-B9lw8C-c.js → SettingsPage-DDsctH7X.js} +1 -1
  36. package/public/assets/{Skeleton-CbeWT2zl.js → Skeleton-CSAb9g25.js} +1 -1
  37. package/public/assets/{SkillPage-Bq35rago.js → SkillPage-CtZTtfF8.js} +1 -1
  38. package/public/assets/{TaskDetailPage-C4ICC3OM.js → TaskDetailPage-CgT_txYn.js} +1 -1
  39. package/public/assets/{TaskListPage-CUHGBvyU.js → TaskListPage-D_tZ75c7.js} +1 -1
  40. package/public/assets/{TaskStatusBadge-C6DS5OWP.js → TaskStatusBadge-yxoaV45g.js} +1 -1
  41. package/public/assets/{TokenManage-B4uqYclW.js → TokenManage-DWk-4hAE.js} +1 -1
  42. package/public/assets/{TotpSetupPage-CEGN1xn8.js → TotpSetupPage-C3IixO0t.js} +1 -1
  43. package/public/assets/{WorkerSetupGuidePage-CwuvVUoB.js → WorkerSetupGuidePage-CuXz1Cp5.js} +1 -1
  44. package/public/assets/{arrow-left-BXI8dEuv.js → arrow-left-tpTJv4kJ.js} +1 -1
  45. package/public/assets/{arrow-right-BvAzhW8L.js → arrow-right-DpePBWE7.js} +1 -1
  46. package/public/assets/{bot-BsTtqvxQ.js → bot-BChGjdPm.js} +1 -1
  47. package/public/assets/{chevron-right-CHP2kF25.js → chevron-right-B-JssgBf.js} +1 -1
  48. package/public/assets/{copy-CTHNYjlv.js → copy-MDuQXvvx.js} +1 -1
  49. package/public/assets/{external-link-CAJ7Idcz.js → external-link-ExQuyXwZ.js} +1 -1
  50. package/public/assets/{index-BwKDWAeG.js → index-CtAu_XZ5.js} +2 -2
  51. package/public/assets/{key-BgCZ-y1U.js → key-Cix4k6UI.js} +1 -1
  52. package/public/assets/{loader-circle-DfGhh0Ty.js → loader-circle-COcLl-bl.js} +1 -1
  53. package/public/assets/{pencil-Bq3Z1U82.js → pencil-KZjOYmxG.js} +1 -1
  54. package/public/assets/{plus-kyLBS24g.js → plus-B1SMCBOe.js} +1 -1
  55. package/public/assets/{rotate-ccw-DSGQ_NEe.js → rotate-ccw-DpBJ4jZw.js} +1 -1
  56. package/public/assets/{scroll-text-D2EdgNAO.js → scroll-text-CrlR_VG0.js} +1 -1
  57. package/public/assets/{settings-CZ6ELt0Z.js → settings-H-4c0_mh.js} +1 -1
  58. package/public/assets/{task.store-DT4yU2EV.js → task.store-ATNoa4p7.js} +1 -1
  59. package/public/assets/{trash-2-CNnnORdj.js → trash-2-BzT2LBkf.js} +1 -1
  60. package/public/assets/{users-DbVTGZbU.js → users-BsLS_-Dg.js} +1 -1
  61. package/public/index.html +1 -1
  62. package/public/assets/MachineListPage-D79p6rD6.js +0 -6
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-BwKDWAeG.js";/**
1
+ import{c as a}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-BwKDWAeG.js";/**
1
+ import{c as e}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-BwKDWAeG.js";/**
1
+ import{c as t}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-BwKDWAeG.js";/**
1
+ import{c as a}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-BwKDWAeG.js";/**
1
+ import{c as a}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{p as i,f as o}from"./index-BwKDWAeG.js";const f=i((t,l)=>({tasks:[],currentTask:null,loading:!1,nextCursor:null,fetchTasks:async s=>{t({loading:!0});try{const a={};s!=null&&s.status&&(a.status=s.status),s!=null&&s.projectKey&&(a.projectKey=s.projectKey),s!=null&&s.cursor&&(a.cursor=s.cursor),s!=null&&s.limit&&(a.limit=String(s.limit));const n=await o.get("web/tasks",{searchParams:a}).json();s!=null&&s.cursor?t(c=>({tasks:[...c.tasks,...n.data],nextCursor:n.nextCursor??null})):t({tasks:n.data,nextCursor:n.nextCursor??null})}finally{t({loading:!1})}},fetchTask:async s=>{t({loading:!0});try{const a=await o.get(`web/tasks/${s}`).json();t({currentTask:a})}finally{t({loading:!1})}},createTask:async s=>{const a=await o.post("web/tasks",{json:s}).json();return t(n=>({tasks:[a,...n.tasks]})),a},cancelTask:async s=>{await o.post(`web/tasks/${s}/cancel`);const{currentTask:a}=l();(a==null?void 0:a.id)===s&&await l().fetchTask(s)},reset:()=>{t({tasks:[],currentTask:null,loading:!1,nextCursor:null})}}));export{f as u};
1
+ import{p as i,f as o}from"./index-CtAu_XZ5.js";const f=i((t,l)=>({tasks:[],currentTask:null,loading:!1,nextCursor:null,fetchTasks:async s=>{t({loading:!0});try{const a={};s!=null&&s.status&&(a.status=s.status),s!=null&&s.projectKey&&(a.projectKey=s.projectKey),s!=null&&s.cursor&&(a.cursor=s.cursor),s!=null&&s.limit&&(a.limit=String(s.limit));const n=await o.get("web/tasks",{searchParams:a}).json();s!=null&&s.cursor?t(c=>({tasks:[...c.tasks,...n.data],nextCursor:n.nextCursor??null})):t({tasks:n.data,nextCursor:n.nextCursor??null})}finally{t({loading:!1})}},fetchTask:async s=>{t({loading:!0});try{const a=await o.get(`web/tasks/${s}`).json();t({currentTask:a})}finally{t({loading:!1})}},createTask:async s=>{const a=await o.post("web/tasks",{json:s}).json();return t(n=>({tasks:[a,...n.tasks]})),a},cancelTask:async s=>{await o.post(`web/tasks/${s}/cancel`);const{currentTask:a}=l();(a==null?void 0:a.id)===s&&await l().fetchTask(s)},reset:()=>{t({tasks:[],currentTask:null,loading:!1,nextCursor:null})}}));export{f as u};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-BwKDWAeG.js";/**
1
+ import{c as e}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-BwKDWAeG.js";/**
1
+ import{c as e}from"./index-CtAu_XZ5.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/public/index.html CHANGED
@@ -11,7 +11,7 @@
11
11
  href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap"
12
12
  rel="stylesheet"
13
13
  />
14
- <script type="module" crossorigin src="/assets/index-BwKDWAeG.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-CtAu_XZ5.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-MbPa7F7Y.css">
16
16
  </head>
17
17
  <body>
@@ -1,6 +0,0 @@
1
- import{c as B,a as I,j as e,r as s,f as C,X as K,o as q,d as W,u as H,h as V,q as O}from"./index-BwKDWAeG.js";import{M as u}from"./protocol-C5uQmiiB.js";import X from"./WorkerSetupGuidePage-CwuvVUoB.js";import{C as z}from"./copy-CTHNYjlv.js";import{L as J}from"./loader-circle-DfGhh0Ty.js";import{S as Q}from"./Select-CRpdafWl.js";import{E as Y}from"./EmptyState-CEWQv5SU.js";import{C as Z}from"./Skeleton-CbeWT2zl.js";import{P as ee}from"./plus-kyLBS24g.js";import"./key-BgCZ-y1U.js";import"./settings-CZ6ELt0Z.js";/**
2
- * @license lucide-react v0.469.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const te=B("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),F={[u.ONLINE]:"var(--accent)",[u.OFFLINE]:"var(--destructive)",[u.DRAINING]:"var(--warning)",[u.DECOMMISSIONED]:"var(--text-muted)"};function ae(a){return a>80?"var(--destructive)":a>60?"var(--warning)":"var(--accent)"}function re({machine:a,onPress:r}){const{t:i}=I();return e.jsxs("div",{onClick:r,className:`rounded border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase transition-colors ${r?"cursor-pointer hover:border-[var(--accent)]/40 hover:bg-[var(--bg-input)]":""}`,children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("h3",{className:"truncate text-sm text-[var(--text-primary)]",children:[e.jsx("span",{style:{color:F[a.status],fontSize:"0.6rem"},children:"●"})," ",a.name]}),e.jsx("span",{className:"text-xs",style:{color:F[a.status]},children:a.status})]}),e.jsxs("div",{className:"mb-3 text-xs text-[var(--text-muted)]",children:[a.host,a.port?`:${a.port}`:""]}),e.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[e.jsx(S,{label:i("machines.cpu"),value:a.cpuUsage}),e.jsx(S,{label:i("machines.mem"),value:a.memoryUsage}),e.jsx(S,{label:i("machines.disk"),value:a.diskUsage})]}),e.jsx("div",{className:"flex items-center justify-between text-xs",children:e.jsx("span",{className:"text-[var(--text-secondary)]",children:i("machines.tasks_slots",{active:String(a.activeSlots),max:String(a.maxSlots)})})}),a.capabilities.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:a.capabilities.map(t=>e.jsx("span",{className:"rounded border border-[var(--border)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:t},t))})]})}function S({label:a,value:r}){return e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-8 text-[var(--text-muted)]",children:a}),e.jsx("div",{className:"h-1.5 flex-1 rounded-sm bg-[var(--bg-input)]",children:e.jsx("div",{className:"h-full rounded-sm transition-all",style:{width:`${r}%`,backgroundColor:ae(r)}})}),e.jsxs("span",{className:"w-8 text-right text-[var(--text-secondary)]",children:[r,"%"]})]})}function se({isOpen:a,onClose:r,onRegistered:i}){const{t}=I(),[c,m]=s.useState(1),[d,h]=s.useState(!1),[o,v]=s.useState(""),[g,f]=s.useState(null),[y,b]=s.useState(""),[j,N]=s.useState(""),[l,x]=s.useState(!1),[_,w]=s.useState(!1),[P,E]=s.useState(""),[T,M]=s.useState(""),p=s.useRef(null),A={1:t("machines.reg_step_generate_token"),2:t("machines.reg_step_install_worker"),3:t("machines.reg_step_waiting_activation"),4:t("machines.reg_step_activated")};s.useEffect(()=>(a&&(m(1),v(""),f(null),b(""),N(""),x(!1),w(!1),E(""),M(""),h(!1)),()=>{p.current&&clearInterval(p.current)}),[a]);const $=async()=>{const n=y.trim();if(!n){N(t("admin.pat_label_required"));return}N(""),h(!0);try{const k=await C.post("admin/worker-tokens",{json:{label:n}}).json();v(k.token),f(k.tokenId),m(2)}catch{}finally{h(!1)}},D=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=o?`overlord setup worker --token ${o} --server ${D}`:"",G=()=>{navigator.clipboard.writeText(o),x(!0),setTimeout(()=>x(!1),2e3)},R=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},U=s.useCallback(()=>{g&&(m(3),p.current=setInterval(async()=>{try{const n=await C.get(`admin/worker-tokens/${g}/status`).json();n.used&&n.machineName&&(E(n.machineName),M(n.machineId??""),m(4),p.current&&clearInterval(p.current),i==null||i())}catch{}},3e3))},[g,i]);return s.useEffect(()=>()=>{p.current&&clearInterval(p.current)},[]),a?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center font-mono lowercase",children:[e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-primary)]/60 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:"relative z-10 w-full max-w-[1080px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-8",children:[e.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:e.jsx(K,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-[var(--accent)]",children:t("machines.reg_title")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:t("machines.reg_subtitle")}),e.jsx("div",{className:"mt-6 flex items-center justify-center gap-2",children:[1,2,3,4].map((n,k)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`rounded-[4px] px-3 py-1.5 text-[11px] font-bold ${n===c?"bg-[var(--accent)] text-black":n<c?"bg-[var(--accent)]/20 text-[var(--accent)]":"border border-[var(--border)] bg-[var(--bg-primary)] text-[var(--text-muted)]"}`,children:[n,". ",A[n]]}),k<3&&e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"→"})]},n))}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:`rounded-[4px] border p-4 ${c===1?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--accent)]",children:["> ",t("machines.reg_step_generate_token")]}),c===1&&!o?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("machines.reg_click_to_generate")}),j&&e.jsx("p",{className:"text-[10px] text-red-400",children:j}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[10px] text-[var(--text-muted)]",children:t("admin.label")}),e.jsx("input",{type:"text",placeholder:t("admin.pat_label_placeholder"),value:y,onChange:n=>b(n.target.value),onKeyDown:n=>{n.key==="Enter"&&$()},className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-1.5 text-[11px] text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none"})]}),e.jsx("button",{type:"button",onClick:$,disabled:d,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(d?"admin.generating":"machines.reg_step_generate_token")})]}):o?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("machines.reg_token_generated")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[10px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsx("code",{className:"block break-all text-[10px] text-[var(--text-primary)]",children:o}),e.jsx("button",{type:"button",onClick:G,className:"absolute right-2 top-1.5 text-[10px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:l?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[10px] text-[var(--text-muted)]",children:t("admin.setup_command")}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsxs("code",{className:"block break-all text-[10px] text-[var(--accent)]",children:["$ ",L]}),e.jsx("button",{type:"button",onClick:R,className:"absolute right-2 top-1.5 text-[10px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:_?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsx("div",{className:"rounded-[4px] border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-[10px] text-yellow-400",children:t("admin.token_shown_once")})]}):e.jsx("p",{className:"mt-2 text-[10px] text-[var(--text-muted)]",children:t("machines.reg_completed")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${c===2?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("machines.reg_step_install_worker")]}),e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("machines.reg_running_installation")}),c>=2&&e.jsxs("div",{className:"mt-3 space-y-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] p-3",children:[e.jsx("p",{className:"text-[10px] text-[var(--text-primary)]",children:"$ overlord setup worker"}),e.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"server url: https://..."}),e.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"worker token: ovw_..."}),e.jsx("p",{className:"text-[10px] text-[var(--text-muted)]",children:"machine name: my-worker"}),e.jsx("p",{className:"text-[10px] text-[var(--accent)]",children:"config written. starting worker..."}),c===2&&e.jsx("p",{className:"text-[10px] text-[var(--accent)] animate-pulse",children:"&block;"})]}),c===2&&e.jsx("button",{type:"button",onClick:U,className:"mt-3 rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black",children:t("machines.reg_installed_wait")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${c===3?"border-amber-500 bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("machines.reg_step_waiting_activation")]}),c>=3?e.jsx("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:c===3?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border-2 border-amber-500",children:e.jsx(J,{className:"h-5 w-5 animate-spin text-amber-500"})}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("machines.reg_listening_for_worker")})]}):e.jsx("p",{className:"text-[10px] text-[var(--accent)]",children:t("machines.reg_worker_connected")})}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("machines.reg_waiting_for_worker")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${c===4?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("machines.reg_step_activated")]}),c===4?e.jsxs("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--accent)]/20",children:e.jsx(q,{className:"h-6 w-6 text-[var(--accent)]"})}),e.jsx("p",{className:"text-xs font-bold text-[var(--accent)]",children:t("machines.reg_worker_activated",{name:P})}),T&&e.jsxs("p",{className:"text-[10px] text-[var(--text-muted)]",children:["machine_id: ",T]})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("machines.reg_worker_registered")})]})]}),c===4&&e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{type:"button",onClick:r,className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-xs font-bold text-black",children:t("machines.reg_done")})})]})]}):null}function be(){const a=W(),{t:r}=I(),[i,t]=s.useState([]),[c,m]=s.useState(!0),[d,h]=s.useState("all"),[o,v]=s.useState("fleet"),[g,f]=s.useState(!1),[y,b]=s.useState(0),j=H(l=>{var x;return(x=l.user)==null?void 0:x.role}),N=s.useMemo(()=>[{value:"all",label:r("machines.all_statuses")},{value:u.ONLINE,label:r("machines.online")},{value:u.OFFLINE,label:r("machines.offline")},{value:u.DRAINING,label:r("machines.draining")}],[r]);return V(s.useMemo(()=>j==="admin"?e.jsxs("button",{type:"button",onClick:()=>f(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",children:[e.jsx(ee,{size:14}),r("machines.register_worker")]}):null,[j,r])),s.useEffect(()=>{async function l(){m(!0);try{const x=new URLSearchParams;d!=="all"&&x.set("status",d);const _=await C.get("web/machines",{searchParams:x}).json();t(_)}catch{}finally{m(!1)}}l()},[d,y]),e.jsxs("div",{className:"mx-auto max-w-6xl px-6 py-8 font-mono lowercase",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between border-b border-[var(--border)]",children:[e.jsxs("div",{className:"flex",children:[e.jsxs("button",{type:"button",onClick:()=>{v("fleet"),b(l=>l+1)},className:`flex items-center gap-2 px-4 py-2.5 text-xs transition-colors ${o==="fleet"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(O,{size:14}),r("machines.fleet")]}),e.jsxs("button",{type:"button",onClick:()=>v("setup_guide"),className:`flex items-center gap-2 px-4 py-2.5 text-xs transition-colors ${o==="setup_guide"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(te,{size:14}),r("machines.setup_guide")]})]}),o==="fleet"&&e.jsx(Q,{value:d,onChange:h,options:N})]}),o==="fleet"?c?e.jsx(Z,{cards:6}):i.length===0?e.jsx(Y,{icon:O,title:r("machines.no_machines_found"),description:r(d!=="all"?"machines.try_changing_status_filter":"machines.no_machines_registered"),action:e.jsx("button",{type:"button",onClick:()=>v("setup_guide"),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:r("machines.view_setup_guide")})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:i.map(l=>e.jsx(re,{machine:l,onPress:()=>a(`/machines/${l.id}`)},l.id))}):e.jsx(X,{}),e.jsx(se,{isOpen:g,onClose:()=>{f(!1),b(l=>l+1)},onRegistered:()=>{b(l=>l+1)}})]})}export{be as default};