hanoman 0.7.1 → 0.8.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.
@@ -1,4 +1,4 @@
1
- import{aM as wa,aN as Ca,aO as Aa,aP as Ea,aQ as za,aR as Oa,aS as Ba,aT as Pa,aU as Ia,aV as Ma,aW as La,aX as Da,aY as Ha,aZ as _a,a_ as Na,e as y,j as e,ao as C,c as ee,d as Y,ap as ge,a as j,f as V,ah as Ra,aF as R,B as ne,I as Ne,N as ue,a$ as Fa,C as ga,b0 as ma,b1 as He,b2 as pa,b3 as $a,b4 as Ee,b5 as Ye,b6 as Wa,b7 as Ze,b8 as Ga,b9 as Ua,ba as Ta,A as Ka,bb as Ja,bc as Va,bd as Je,V as Ya,S as L,U as qa,Y as te,Z as ba,u as Fe,be as Xa,bf as Qa,bg as Za,h as et,a6 as at,bh as tt,p as nt,bi as it,O as ka,bj as ye,bk as Re,bl as lt,bm as st,bn as rt,bo as dt,bp as xa,bq as fa,br as _e,bs as ja,bt as ot,bu as ct,aI as ut,bv as Ce,bw as ea,H as ht,bx as aa,by as ta,bz as gt,a0 as Ve,bA as mt,W as pt,X as bt,bB as Ge}from"./index-C_btxEiC.js";import{R as o}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import{D as kt}from"./DocPreviewModal-4m5Afjx2.js";import"./xterm-3VOAfa_q.js";const xt=[...wa,...Ca,...Aa,...Ea,...za,...Oa,...Ba,...Pa,...Ia,...Ma,...La,...Da,...Ha,..._a,...Na],ft=1;function jt(){const[a,i]=o.useState(null),[r,d]=o.useState([]),[b,t]=o.useState(""),[s,h]=o.useState(""),[f,u]=o.useState([]),[c,k]=o.useState(null),z=o.useCallback(()=>y.listClientAccounts().then(x=>i(x.items)).catch(()=>i([])),[]);o.useEffect(()=>{z(),y.listProjects().then(x=>d(x.items.map(O=>({id:O.id,name:O.name})))).catch(()=>d([]))},[z]);const F=async()=>{k(null);try{await y.createClientAccount({email:b,password:s,projects:f}),t(""),h(""),u([]),await z()}catch{k("Gagal membuat akun — periksa email (mungkin sudah dipakai) dan panjang password.")}},$=async(x,O)=>{await y.updateClientAccount(x,O),await z()},E=async x=>{await y.deleteClientAccount(x),await z()},m=(x,O,K)=>K?[...x,O]:x.filter(G=>G!==O);return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"akses",title:"Buat akun klien",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:14,lineHeight:1.5},children:["Akun klien melihat ",e.jsx("b",{children:"daftar backlog"})," dan ",e.jsx("b",{children:"tiket help desk"})," project yang dipilih — baca-saja, tanpa terminal, dokumen internal, maupun setelan. Ia tak pernah melihat dashboard operator."]}),e.jsx(ee,{label:"Email klien",children:e.jsx(Y,{"aria-label":"Email klien",placeholder:"mis. budi@tokomekar.co.id",value:b,onChange:x=>t(x.target.value)})}),e.jsx(ee,{label:"Password awal",hint:"Minimal 8 karakter. Sampaikan lewat kanal yang aman — klien bisa menggantinya sendiri.",children:e.jsx(Y,{"aria-label":"Password awal",type:"password",placeholder:"mis. kunci-tokomekar-2026",value:s,onChange:x=>h(x.target.value)})}),e.jsx(ee,{label:"Project yang boleh dilihat",children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:14},children:r.map(x=>e.jsx(ge,{"aria-label":`Beri akses ${x.name}`,label:x.name,checked:f.includes(x.id),onChange:O=>u(K=>m(K,x.id,O))},x.id))})}),c&&e.jsx("div",{style:{color:"var(--status-err)",fontSize:"var(--text-sm)",marginBottom:10},children:c}),e.jsx(j,{size:"sm",leftIcon:"user-plus",onClick:F,disabled:!b||s.length<8,children:"Buat akun"})]}),e.jsx(C,{eyebrow:"akses",title:"Akun klien",children:a===null?e.jsx(V,{kind:"loading",title:"Memuat…"}):a.length===0?e.jsx(V,{kind:"empty",icon:"users",title:"Belum ada akun klien",hint:"Buat akun di atas, lalu pilih project yang boleh ia lihat."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:a.map(x=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"12px 0",borderBottom:"1px solid var(--border-hair)"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--text-strong)"},children:x.email}),e.jsx(Ra,{status:x.disabled?"stopped":"done",size:"sm",children:x.disabled?"nonaktif":"aktif"}),e.jsx("div",{style:{flex:1,minWidth:240,display:"flex",flexWrap:"wrap",gap:14},children:r.map(O=>e.jsx(ge,{"aria-label":`${x.email} · ${O.name}`,label:O.name,checked:x.projects.includes(O.id),onChange:K=>void $(x.id,{projects:m(x.projects,O.id,K)})},O.id))}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void $(x.id,{disabled:!x.disabled}),children:x.disabled?"Aktifkan":"Nonaktifkan"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void E(x.id),children:"Hapus"})]},x.id))})})]})}const Ue=["sessions:read","backlog:read","ide:read"],na=[{cap:"sessions:write",label:"Tulis terminal",desc:"Ketik ke terminal, steer, interrupt, jawab & ambil alih dialog."},{cap:"sessions:spawn",label:"Mulai sesi",desc:"Membuka sesi agen BARU di mesin ini atas perintah hub — eksekusi agen di mesin ini. Hub tak bisa memaksa melewati gerbang beban."},{cap:"backlog:write",label:"Tandai selesai",desc:"Hanya menandai backlog selesai; suntingan backlog lain tetap tertutup untuk hub."}],ia=[{lane:"event",label:"event",desc:"Lahir/tutup sesi, perubahan grant — lajur audit lokal (default nyala)."},{lane:"server",label:"server",desc:"console.* proses server ini, disadap & diredaksi sebelum dikirim."},{lane:"transcript",label:"transcript",desc:"Transkrip sesi terminal yang sudah ditutup."}],yt={off:"mati",connecting:"menyambung",open:"tersambung",backoff:"mencoba lagi",unsupported:"hub tak mendukung",rejected:"ditolak hub"},vt={off:"neutral",connecting:"neutral",open:"ok",backoff:"warn",unsupported:"warn",rejected:"warn"};function Me({title:a,desc:i,children:r,last:d}){return e.jsxs("div",{className:"hn-setting-row",style:{display:"flex",alignItems:"center",gap:16,padding:"14px 0",borderBottom:d?"none":"1px solid var(--border-hair)"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)"},children:a}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginTop:3,lineHeight:1.5},children:i})]}),e.jsx("div",{className:"hn-setting-control",style:{flex:"0 0 auto"},children:r})]})}function St({onToast:a}){const[i,r]=o.useState(null),[d,b]=o.useState(!1),[t,s]=o.useState(!1);if(o.useEffect(()=>{y.getRemoteControl().then(r).catch(()=>b(!0))},[]),!i)return e.jsx(C,{eyebrow:"kendali",title:"Kendali jarak jauh dari hub",children:d?e.jsx("div",{style:{fontSize:13,color:"var(--text-muted)"},children:"Gagal memuat grant kendali jarak jauh."}):e.jsx(V,{kind:"loading",compact:!0,title:"Memuat grant…"})});const{enabled:h,capabilities:f}=i.control,u=m=>f.includes(m),c=(...m)=>[...new Set(m.flat())],k=async(m,x)=>{s(!0);try{r(await y.putRemoteControl({control:{enabled:m,capabilities:x}})),a==null||a(m?"Grant kendali jarak jauh disimpan":"Kendali jarak jauh dimatikan","ok","check")}catch{a==null||a("Gagal menyimpan grant kendali jarak jauh","err","x-circle")}finally{s(!1)}},z=m=>k(m,m&&f.length===0?Ue:f),F=m=>k(h,m?c(f,Ue):[]),$=(m,x)=>k(h,x?c(f,Ue,[m]):f.filter(O=>O!==m)),E=async(m,x)=>{s(!0);try{r(await y.putRemoteControl({logs:{...i.logs,[m]:x}})),a==null||a(x?`Lajur ${m} mulai dikirim ke hub`:`Lajur ${m} berhenti dikirim`,"ok","check")}catch{a==null||a("Gagal menyimpan lajur log","err","x-circle")}finally{s(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"kendali",title:"Kendali jarak jauh dari hub",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Mengizinkan operator ",e.jsx("b",{children:"hub"})," tempat mesin ini tersinkron bertindak di mesin ini lewat route yang sama dengan dashboard lokal. Default mati dan hanya bisa dinyalakan dari mesin ini — hub tak bisa menyalakannya sendiri."]}),e.jsx(Me,{title:"Izinkan kendali jarak jauh",desc:"Membuka socket relay ke hub. Mati = tak ada jalur perintah dari hub sama sekali.",children:e.jsx(R,{checked:h,disabled:t,onChange:m=>void z(m),"aria-label":"Izinkan kendali jarak jauh"})}),e.jsx(Me,{title:"Lihat",desc:"Daftar sesi, fase, dialog, dokumen & review sesi, IDE baca-saja.",children:e.jsx(R,{checked:u("sessions:read"),disabled:t||!h,onChange:m=>void F(m),"aria-label":"Lihat"})}),na.map((m,x)=>e.jsx(Me,{title:m.label,desc:m.desc,last:x===na.length-1,children:e.jsx(R,{checked:u(m.cap),disabled:t||!h,onChange:O=>void $(m.cap,O),"aria-label":m.label})},m.cap))]}),e.jsxs(C,{eyebrow:"kendali",title:"Lajur log ke hub",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Mengirim baris dari mesin ini ke ",e.jsx("code",{children:"POST /sync/logs"})," di hub — lepas dari grant kendali jarak jauh di atas. Tiap lajur bisa dinyalakan/dimatikan sendiri-sendiri, langsung berlaku tanpa restart."]}),ia.map((m,x)=>e.jsx(Me,{title:m.label,desc:m.desc,last:x===ia.length-1,children:e.jsx(R,{checked:i.logs[m.lane],disabled:t,onChange:O=>void E(m.lane,O),"aria-label":m.label})},m.lane))]}),e.jsx(C,{eyebrow:"kendali",title:"Status relay",children:e.jsxs("div",{"data-testid":"relay-status",style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",fontSize:13},children:[e.jsx(ne,{tone:vt[i.relay.state],children:yt[i.relay.state]}),e.jsx("span",{style:{color:"var(--text-muted)",overflowWrap:"anywhere"},children:i.relay.hubOrigin??"mesin ini tak tersambung ke hub"}),i.relay.lastClose&&e.jsxs("span",{style:{color:"var(--text-muted)"},children:["tutup terakhir ",i.relay.lastClose.code,i.relay.lastClose.reason?` · ${i.relay.lastClose.reason}`:""]})]})}),e.jsx(C,{eyebrow:"kendali",title:"Audit aksi hub di mesin ini",children:i.audit.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada aksi dari hub."}):i.audit.map(m=>e.jsxs("div",{"data-testid":"remote-audit-row",style:{fontSize:12.5,padding:"8px 0",borderBottom:"1px solid var(--border-hair)",overflowWrap:"anywhere"},children:[e.jsx("b",{children:m.kind})," · ",m.msg," · ",e.jsx("span",{style:{color:"var(--text-muted)"},children:new Date(m.ts).toLocaleString("id-ID")})]},m.id))})]})}const wt={name:"",url:"",events:["*"],enabled:!0,allowPrivate:!1},Ct=ma.map(a=>({entity:a.entity,label:a.label,types:He.filter(i=>i.entity===a.entity).map(i=>i.type)})),la=a=>a?new Date(a).toLocaleString("id-ID",{dateStyle:"short",timeStyle:"medium"}):"—",ce={fontSize:12.5,color:"var(--text-muted)",lineHeight:1.5},Te={fontFamily:"var(--font-mono)",fontSize:12};function At({e:a}){return a.enabled?e.jsx(ne,{tone:"ok",children:"aktif"}):a.disabledAt?e.jsx(ne,{tone:"err",children:"dinonaktifkan otomatis"}):e.jsx(ne,{children:"nonaktif"})}function Et({onToast:a,onOpenDocs:i}={}){const[r,d]=o.useState(null),[b,t]=o.useState(!1),[s,h]=o.useState(null),[f,u]=o.useState(null),[c,k]=o.useState(!1),[z,F]=o.useState({}),[$,E]=o.useState(null),[m,x]=o.useState([]),[O,K]=o.useState(null),G=o.useCallback(async()=>{try{d((await y.listWebhooks()).endpoints),t(!1)}catch{t(!0)}},[]);o.useEffect(()=>{G()},[G]);const he=async l=>{E(l);try{x((await y.listWebhookDeliveries(l)).items)}catch{x([])}},me=async()=>{if(s){k(!0);try{if(s.id)await y.updateWebhook(s.id,{name:s.name,url:s.url,events:s.events,enabled:s.enabled,allowPrivate:s.allowPrivate}),a==null||a("Endpoint webhook diperbarui");else{const l=await y.createWebhook({name:s.name,url:s.url,events:s.events,enabled:s.enabled,allowPrivate:s.allowPrivate});u(l.secret??null),a==null||a("Endpoint webhook dibuat")}h(null),await G()}catch(l){a==null||a(`Gagal menyimpan: ${l.message}`,"err")}finally{k(!1)}}},ie=async l=>{k(!0);try{const S=await y.updateWebhook(l,{rotateSecret:!0});u(S.secret??null),await G()}catch(S){a==null||a(`Gagal merotasi secret: ${S.message}`,"err")}finally{k(!1)}},ve=async(l,S)=>{try{await y.updateWebhook(l.id,{enabled:S}),await G()}catch(M){a==null||a(`Gagal mengubah status: ${M.message}`,"err")}},le=async l=>{k(!0);try{const S=await y.testWebhook(l);F(M=>({...M,[l]:S})),await G()}catch(S){F(M=>({...M,[l]:{ok:!1,httpStatus:null,durationMs:0,error:S.message}}))}finally{k(!1)}},ae=async()=>{if(O)try{await y.deleteWebhook(O.id),a==null||a("Endpoint webhook dihapus"),await G()}catch(l){a==null||a(`Gagal menghapus: ${l.message}`,"err")}finally{K(null)}},se=async l=>{try{await y.retryWebhookDelivery(l),$&&await he($),await G()}catch(S){a==null||a(`Gagal antre ulang: ${S.message}`,"err")}},p=(l,S)=>h(M=>M&&{...M,events:S?[...new Set([...M.events.filter(N=>N!=="*"),...l])]:M.events.filter(N=>N!=="*"&&!l.includes(N))}),I=(s==null?void 0:s.events.includes("*"))??!1;return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"integrasi",title:"Webhook keluar",children:[e.jsxs("div",{style:{...ce,marginBottom:12},children:["hanoman mengirim ",e.jsx("b",{children:"HTTP POST"})," bertanda tangan ke endpoint yang Anda daftarkan setiap kali sesuatu berubah — backlog dibuat atau berpindah stage, sesi mulai dan selesai, putusan lead terbit, tiket masuk, notifikasi. Pengiriman berjalan di antrean: penerima yang lambat atau mati ",e.jsx("b",{children:"tidak"})," memperlambat hanoman."]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16},children:[e.jsxs(j,{size:"sm",onClick:()=>{h({...wt}),u(null)},children:[e.jsx(Ne,{name:"plus",size:14})," Tambah endpoint"]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:i,children:[e.jsx(Ne,{name:"book-open",size:14})," Dokumentasi webhook"]})]}),b?e.jsx(V,{kind:"error",compact:!0,title:"Gagal memuat endpoint webhook",hint:"Coba muat ulang.",action:()=>void G(),actionLabel:"Coba lagi"}):r===null?e.jsx("div",{style:ce,children:"Memuat…"}):r.length===0?e.jsx(V,{kind:"empty",compact:!0,title:"Belum ada endpoint webhook",hint:"Daftarkan URL penerima pertama untuk mulai berlangganan peristiwa hanoman."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:r.map(l=>e.jsxs("div",{"data-testid":`webhook-${l.id}`,style:{border:"1px solid var(--border-hair)",borderRadius:"var(--radius-sm)",padding:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontWeight:600},children:l.name}),e.jsx(At,{e:l}),l.pending>0?e.jsxs(ne,{children:[l.pending," mengantre"]}):null,e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[e.jsx(R,{checked:l.enabled,"aria-label":`Aktifkan ${l.name}`,onChange:S=>void ve(l,S)}),e.jsx(j,{size:"sm",variant:"ghost",disabled:c,onClick:()=>void le(l.id),children:"Test"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void he(l.id),children:"Riwayat"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>{u(null),h({id:l.id,name:l.name,url:l.url,events:l.events,enabled:l.enabled,allowPrivate:l.allowPrivate})},children:"Ubah"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>K(l),children:"Hapus"})]})]}),e.jsx("div",{style:{...Te,color:"var(--text-muted)",marginTop:6},children:l.url}),e.jsxs("div",{style:{...ce,marginTop:6},children:["Peristiwa: ",e.jsx("code",{children:l.events.join(", ")})," · secret …",l.secretHint," ·"," ","sukses terakhir ",la(l.lastSuccessAt),l.failureStreak>0?` · ${l.failureStreak} gagal beruntun`:""]}),l.disabledReason?e.jsx("div",{style:{...ce,marginTop:6,color:"var(--status-err-tint)"},children:l.disabledReason}):null,z[l.id]?e.jsx("div",{style:{...ce,marginTop:6},children:z[l.id].ok?`Test berhasil — HTTP ${z[l.id].httpStatus} · ${z[l.id].durationMs} ms`:`Test gagal — ${z[l.id].error}`}):null]},l.id))})]}),f?e.jsxs(C,{eyebrow:"secret",title:"Salin sekarang — secret tak ditampilkan lagi",children:[e.jsx(ue,{tone:"brass",children:e.jsx("div",{style:{...Te,wordBreak:"break-all"},children:f})}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[e.jsx(j,{size:"sm",onClick:()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(f))},children:"Salin secret"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>u(null),children:"Tutup"})]})]}):null,s?e.jsx(C,{eyebrow:s.id?"ubah":"tambah",title:s.id?"Ubah endpoint":"Endpoint baru",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(ee,{label:"Nama",children:e.jsx(Y,{value:s.name,placeholder:"mis. Dashboard internal",onChange:l=>h({...s,name:l.target.value})})}),e.jsx(ee,{label:"URL tujuan",children:e.jsx(Y,{value:s.url,placeholder:"https://contoh.id/hanoman-webhook",onChange:l=>h({...s,url:l.target.value})})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:6},children:"Peristiwa yang dikirim"}),e.jsx(ge,{checked:I,label:"Semua peristiwa",onChange:l=>h({...s,events:l?["*"]:[]})}),I?null:e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:8},children:[Ct.map(l=>e.jsxs("div",{children:[e.jsx(ge,{checked:l.types.every(S=>s.events.includes(S)),label:l.label,onChange:S=>p(l.types,S)}),e.jsx("div",{style:{paddingLeft:22,display:"flex",flexWrap:"wrap",gap:10},children:l.types.map(S=>e.jsx(ge,{checked:s.events.includes(S),label:S,onChange:M=>h({...s,events:M?[...new Set([...s.events.filter(N=>N!=="*"),S])]:s.events.filter(N=>N!==S&&N!=="*")})},S))})]},l.entity)),e.jsxs("div",{style:ce,children:[e.jsx("code",{children:Fa})," selalu terkirim saat tombol Test ditekan, apa pun langganannya."]})]})]}),e.jsx(ge,{checked:s.allowPrivate,label:"Izinkan alamat internal / loopback",onChange:l=>h({...s,allowPrivate:l})}),e.jsx("div",{style:ce,children:"Biarkan mati kecuali penerima memang berjalan di mesin/jaringan yang sama. Menyalakannya membuka jalan ke layanan internal yang tak pernah dimaksudkan terekspos."}),e.jsx(ge,{checked:s.enabled,label:"Aktif",onChange:l=>h({...s,enabled:l})}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(j,{size:"sm",disabled:c||!s.name||!s.url||s.events.length===0,onClick:()=>void me(),children:"Simpan"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>h(null),children:"Batal"}),s.id?e.jsx(j,{size:"sm",variant:"ghost",disabled:c,onClick:()=>void ie(s.id),children:"Rotasi secret"}):null]})]})}):null,$?e.jsxs(C,{eyebrow:"riwayat",title:"Riwayat pengiriman",children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>E(null),children:"Tutup riwayat"})}),m.length===0?e.jsx("div",{style:ce,children:"Belum ada pengiriman."}):e.jsx("div",{className:"hn-local-overflow",style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12.5},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{textAlign:"left",color:"var(--text-muted)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"Waktu"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Jenis"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Status"}),e.jsx("th",{style:{padding:"6px 8px"},children:"HTTP"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Percobaan"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Galat"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:m.map(l=>e.jsxs("tr",{style:{borderTop:"1px solid var(--border-hair)"},children:[e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"nowrap"},children:la(l.createdAt)}),e.jsx("td",{style:{padding:"6px 8px",...Te},children:l.eventType}),e.jsx("td",{style:{padding:"6px 8px"},children:l.status}),e.jsx("td",{style:{padding:"6px 8px"},children:l.httpStatus??"—"}),e.jsx("td",{style:{padding:"6px 8px"},children:`${l.attempt} / ${l.maxAttempts}`}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--text-muted)"},children:l.error??"—"}),e.jsx("td",{style:{padding:"6px 8px"},children:l.status==="failed"||l.status==="dropped"?e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void se(l.id),children:"Antre ulang"}):null})]},l.id))})]})})]}):null,e.jsx(ga,{open:!!O,title:"Hapus endpoint webhook?",message:O?`"${O.name}" beserta seluruh riwayat pengirimannya akan dihapus.`:"",confirmLabel:"Hapus",onCancel:()=>K(null),onConfirm:()=>void ae()})]})}const J={fontSize:13,color:"var(--text-muted)",lineHeight:1.6},zt={fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre",overflowX:"auto",background:"var(--bone-200)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-sm)",padding:12,margin:0};function Ke({text:a,label:i="Salin"}){const[r,d]=o.useState(!1);return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("pre",{style:zt,children:a}),e.jsx("div",{style:{marginTop:6},children:e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>{var b;(b=navigator.clipboard)==null||b.writeText(a),d(!0),setTimeout(()=>d(!1),1500)},children:r?"Tersalin":i})})]})}const Ot=`// Node.js (Express) — verifikasi tanda tangan webhook hanoman
1
+ import{aM as wa,aN as Ca,aO as Aa,aP as Ea,aQ as za,aR as Oa,aS as Ba,aT as Pa,aU as Ia,aV as Ma,aW as La,aX as Da,aY as Ha,aZ as _a,a_ as Na,e as y,j as e,ao as C,c as ee,d as Y,ap as he,a as j,f as V,ak as Ra,aF as R,B as ne,I as Ne,N as ue,a$ as Fa,C as ha,b0 as ma,b1 as He,b2 as pa,b3 as $a,b4 as Ee,b5 as Ye,b6 as Wa,b7 as Ze,b8 as Ga,b9 as Ua,ba as Ta,A as Ka,bb as Ja,bc as Va,bd as Je,V as Ya,S as L,U as qa,Y as te,Z as ba,u as Fe,be as Xa,bf as Qa,bg as Za,h as et,a6 as at,bh as tt,p as nt,bi as it,O as ka,bj as ye,bk as Re,bl as lt,bm as st,bn as rt,bo as dt,bp as xa,bq as fa,br as _e,bs as ja,bt as ot,bu as ct,aI as ut,bv as Ce,bw as ea,H as gt,bx as aa,by as ta,bz as ht,a0 as Ve,bA as mt,W as pt,X as bt,bB as Ge}from"./index-B5A1QnO4.js";import{R as o}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import{D as kt}from"./DocPreviewModal-BmiV6G97.js";import"./xterm-3VOAfa_q.js";const xt=[...wa,...Ca,...Aa,...Ea,...za,...Oa,...Ba,...Pa,...Ia,...Ma,...La,...Da,...Ha,..._a,...Na],ft=1;function jt(){const[a,i]=o.useState(null),[r,d]=o.useState([]),[b,t]=o.useState(""),[s,g]=o.useState(""),[f,u]=o.useState([]),[c,k]=o.useState(null),z=o.useCallback(()=>y.listClientAccounts().then(x=>i(x.items)).catch(()=>i([])),[]);o.useEffect(()=>{z(),y.listProjects().then(x=>d(x.items.map(O=>({id:O.id,name:O.name})))).catch(()=>d([]))},[z]);const F=async()=>{k(null);try{await y.createClientAccount({email:b,password:s,projects:f}),t(""),g(""),u([]),await z()}catch{k("Gagal membuat akun — periksa email (mungkin sudah dipakai) dan panjang password.")}},$=async(x,O)=>{await y.updateClientAccount(x,O),await z()},E=async x=>{await y.deleteClientAccount(x),await z()},m=(x,O,K)=>K?[...x,O]:x.filter(G=>G!==O);return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"akses",title:"Buat akun klien",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:14,lineHeight:1.5},children:["Akun klien melihat ",e.jsx("b",{children:"daftar backlog"})," dan ",e.jsx("b",{children:"tiket help desk"})," project yang dipilih — baca-saja, tanpa terminal, dokumen internal, maupun setelan. Ia tak pernah melihat dashboard operator."]}),e.jsx(ee,{label:"Email klien",children:e.jsx(Y,{"aria-label":"Email klien",placeholder:"mis. budi@tokomekar.co.id",value:b,onChange:x=>t(x.target.value)})}),e.jsx(ee,{label:"Password awal",hint:"Minimal 8 karakter. Sampaikan lewat kanal yang aman — klien bisa menggantinya sendiri.",children:e.jsx(Y,{"aria-label":"Password awal",type:"password",placeholder:"mis. kunci-tokomekar-2026",value:s,onChange:x=>g(x.target.value)})}),e.jsx(ee,{label:"Project yang boleh dilihat",children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:14},children:r.map(x=>e.jsx(he,{"aria-label":`Beri akses ${x.name}`,label:x.name,checked:f.includes(x.id),onChange:O=>u(K=>m(K,x.id,O))},x.id))})}),c&&e.jsx("div",{style:{color:"var(--status-err)",fontSize:"var(--text-sm)",marginBottom:10},children:c}),e.jsx(j,{size:"sm",leftIcon:"user-plus",onClick:F,disabled:!b||s.length<8,children:"Buat akun"})]}),e.jsx(C,{eyebrow:"akses",title:"Akun klien",children:a===null?e.jsx(V,{kind:"loading",title:"Memuat…"}):a.length===0?e.jsx(V,{kind:"empty",icon:"users",title:"Belum ada akun klien",hint:"Buat akun di atas, lalu pilih project yang boleh ia lihat."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:a.map(x=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"12px 0",borderBottom:"1px solid var(--border-hair)"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--text-strong)"},children:x.email}),e.jsx(Ra,{status:x.disabled?"stopped":"done",size:"sm",children:x.disabled?"nonaktif":"aktif"}),e.jsx("div",{style:{flex:1,minWidth:240,display:"flex",flexWrap:"wrap",gap:14},children:r.map(O=>e.jsx(he,{"aria-label":`${x.email} · ${O.name}`,label:O.name,checked:x.projects.includes(O.id),onChange:K=>void $(x.id,{projects:m(x.projects,O.id,K)})},O.id))}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void $(x.id,{disabled:!x.disabled}),children:x.disabled?"Aktifkan":"Nonaktifkan"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void E(x.id),children:"Hapus"})]},x.id))})})]})}const Ue=["sessions:read","backlog:read","ide:read"],na=[{cap:"sessions:write",label:"Tulis terminal",desc:"Ketik ke terminal, steer, interrupt, jawab & ambil alih dialog."},{cap:"sessions:spawn",label:"Mulai sesi",desc:"Membuka sesi agen BARU di mesin ini atas perintah hub — eksekusi agen di mesin ini. Hub tak bisa memaksa melewati gerbang beban."},{cap:"backlog:write",label:"Tandai selesai",desc:"Hanya menandai backlog selesai; suntingan backlog lain tetap tertutup untuk hub."}],ia=[{lane:"event",label:"event",desc:"Lahir/tutup sesi, perubahan grant — lajur audit lokal (default nyala)."},{lane:"server",label:"server",desc:"console.* proses server ini, disadap & diredaksi sebelum dikirim."},{lane:"transcript",label:"transcript",desc:"Transkrip sesi terminal yang sudah ditutup."}],yt={off:"mati",connecting:"menyambung",open:"tersambung",backoff:"mencoba lagi",unsupported:"hub tak mendukung",rejected:"ditolak hub"},vt={off:"neutral",connecting:"neutral",open:"ok",backoff:"warn",unsupported:"warn",rejected:"warn"};function Me({title:a,desc:i,children:r,last:d}){return e.jsxs("div",{className:"hn-setting-row",style:{display:"flex",alignItems:"center",gap:16,padding:"14px 0",borderBottom:d?"none":"1px solid var(--border-hair)"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)"},children:a}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginTop:3,lineHeight:1.5},children:i})]}),e.jsx("div",{className:"hn-setting-control",style:{flex:"0 0 auto"},children:r})]})}function St({onToast:a}){const[i,r]=o.useState(null),[d,b]=o.useState(!1),[t,s]=o.useState(!1);if(o.useEffect(()=>{y.getRemoteControl().then(r).catch(()=>b(!0))},[]),!i)return e.jsx(C,{eyebrow:"kendali",title:"Kendali jarak jauh dari hub",children:d?e.jsx("div",{style:{fontSize:13,color:"var(--text-muted)"},children:"Gagal memuat grant kendali jarak jauh."}):e.jsx(V,{kind:"loading",compact:!0,title:"Memuat grant…"})});const{enabled:g,capabilities:f}=i.control,u=m=>f.includes(m),c=(...m)=>[...new Set(m.flat())],k=async(m,x)=>{s(!0);try{r(await y.putRemoteControl({control:{enabled:m,capabilities:x}})),a==null||a(m?"Grant kendali jarak jauh disimpan":"Kendali jarak jauh dimatikan","ok","check")}catch{a==null||a("Gagal menyimpan grant kendali jarak jauh","err","x-circle")}finally{s(!1)}},z=m=>k(m,m&&f.length===0?Ue:f),F=m=>k(g,m?c(f,Ue):[]),$=(m,x)=>k(g,x?c(f,Ue,[m]):f.filter(O=>O!==m)),E=async(m,x)=>{s(!0);try{r(await y.putRemoteControl({logs:{...i.logs,[m]:x}})),a==null||a(x?`Lajur ${m} mulai dikirim ke hub`:`Lajur ${m} berhenti dikirim`,"ok","check")}catch{a==null||a("Gagal menyimpan lajur log","err","x-circle")}finally{s(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"kendali",title:"Kendali jarak jauh dari hub",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Mengizinkan operator ",e.jsx("b",{children:"hub"})," tempat mesin ini tersinkron bertindak di mesin ini lewat route yang sama dengan dashboard lokal. Default mati dan hanya bisa dinyalakan dari mesin ini — hub tak bisa menyalakannya sendiri."]}),e.jsx(Me,{title:"Izinkan kendali jarak jauh",desc:"Membuka socket relay ke hub. Mati = tak ada jalur perintah dari hub sama sekali.",children:e.jsx(R,{checked:g,disabled:t,onChange:m=>void z(m),"aria-label":"Izinkan kendali jarak jauh"})}),e.jsx(Me,{title:"Lihat",desc:"Daftar sesi, fase, dialog, dokumen & review sesi, IDE baca-saja.",children:e.jsx(R,{checked:u("sessions:read"),disabled:t||!g,onChange:m=>void F(m),"aria-label":"Lihat"})}),na.map((m,x)=>e.jsx(Me,{title:m.label,desc:m.desc,last:x===na.length-1,children:e.jsx(R,{checked:u(m.cap),disabled:t||!g,onChange:O=>void $(m.cap,O),"aria-label":m.label})},m.cap))]}),e.jsxs(C,{eyebrow:"kendali",title:"Lajur log ke hub",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Mengirim baris dari mesin ini ke ",e.jsx("code",{children:"POST /sync/logs"})," di hub — lepas dari grant kendali jarak jauh di atas. Tiap lajur bisa dinyalakan/dimatikan sendiri-sendiri, langsung berlaku tanpa restart."]}),ia.map((m,x)=>e.jsx(Me,{title:m.label,desc:m.desc,last:x===ia.length-1,children:e.jsx(R,{checked:i.logs[m.lane],disabled:t,onChange:O=>void E(m.lane,O),"aria-label":m.label})},m.lane))]}),e.jsx(C,{eyebrow:"kendali",title:"Status relay",children:e.jsxs("div",{"data-testid":"relay-status",style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",fontSize:13},children:[e.jsx(ne,{tone:vt[i.relay.state],children:yt[i.relay.state]}),e.jsx("span",{style:{color:"var(--text-muted)",overflowWrap:"anywhere"},children:i.relay.hubOrigin??"mesin ini tak tersambung ke hub"}),i.relay.lastClose&&e.jsxs("span",{style:{color:"var(--text-muted)"},children:["tutup terakhir ",i.relay.lastClose.code,i.relay.lastClose.reason?` · ${i.relay.lastClose.reason}`:""]})]})}),e.jsx(C,{eyebrow:"kendali",title:"Audit aksi hub di mesin ini",children:i.audit.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada aksi dari hub."}):i.audit.map(m=>e.jsxs("div",{"data-testid":"remote-audit-row",style:{fontSize:12.5,padding:"8px 0",borderBottom:"1px solid var(--border-hair)",overflowWrap:"anywhere"},children:[e.jsx("b",{children:m.kind})," · ",m.msg," · ",e.jsx("span",{style:{color:"var(--text-muted)"},children:new Date(m.ts).toLocaleString("id-ID")})]},m.id))})]})}const wt={name:"",url:"",events:["*"],enabled:!0,allowPrivate:!1},Ct=ma.map(a=>({entity:a.entity,label:a.label,types:He.filter(i=>i.entity===a.entity).map(i=>i.type)})),la=a=>a?new Date(a).toLocaleString("id-ID",{dateStyle:"short",timeStyle:"medium"}):"—",ce={fontSize:12.5,color:"var(--text-muted)",lineHeight:1.5},Te={fontFamily:"var(--font-mono)",fontSize:12};function At({e:a}){return a.enabled?e.jsx(ne,{tone:"ok",children:"aktif"}):a.disabledAt?e.jsx(ne,{tone:"err",children:"dinonaktifkan otomatis"}):e.jsx(ne,{children:"nonaktif"})}function Et({onToast:a,onOpenDocs:i}={}){const[r,d]=o.useState(null),[b,t]=o.useState(!1),[s,g]=o.useState(null),[f,u]=o.useState(null),[c,k]=o.useState(!1),[z,F]=o.useState({}),[$,E]=o.useState(null),[m,x]=o.useState([]),[O,K]=o.useState(null),G=o.useCallback(async()=>{try{d((await y.listWebhooks()).endpoints),t(!1)}catch{t(!0)}},[]);o.useEffect(()=>{G()},[G]);const ge=async l=>{E(l);try{x((await y.listWebhookDeliveries(l)).items)}catch{x([])}},me=async()=>{if(s){k(!0);try{if(s.id)await y.updateWebhook(s.id,{name:s.name,url:s.url,events:s.events,enabled:s.enabled,allowPrivate:s.allowPrivate}),a==null||a("Endpoint webhook diperbarui");else{const l=await y.createWebhook({name:s.name,url:s.url,events:s.events,enabled:s.enabled,allowPrivate:s.allowPrivate});u(l.secret??null),a==null||a("Endpoint webhook dibuat")}g(null),await G()}catch(l){a==null||a(`Gagal menyimpan: ${l.message}`,"err")}finally{k(!1)}}},ie=async l=>{k(!0);try{const S=await y.updateWebhook(l,{rotateSecret:!0});u(S.secret??null),await G()}catch(S){a==null||a(`Gagal merotasi secret: ${S.message}`,"err")}finally{k(!1)}},ve=async(l,S)=>{try{await y.updateWebhook(l.id,{enabled:S}),await G()}catch(M){a==null||a(`Gagal mengubah status: ${M.message}`,"err")}},le=async l=>{k(!0);try{const S=await y.testWebhook(l);F(M=>({...M,[l]:S})),await G()}catch(S){F(M=>({...M,[l]:{ok:!1,httpStatus:null,durationMs:0,error:S.message}}))}finally{k(!1)}},ae=async()=>{if(O)try{await y.deleteWebhook(O.id),a==null||a("Endpoint webhook dihapus"),await G()}catch(l){a==null||a(`Gagal menghapus: ${l.message}`,"err")}finally{K(null)}},se=async l=>{try{await y.retryWebhookDelivery(l),$&&await ge($),await G()}catch(S){a==null||a(`Gagal antre ulang: ${S.message}`,"err")}},p=(l,S)=>g(M=>M&&{...M,events:S?[...new Set([...M.events.filter(N=>N!=="*"),...l])]:M.events.filter(N=>N!=="*"&&!l.includes(N))}),I=(s==null?void 0:s.events.includes("*"))??!1;return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"integrasi",title:"Webhook keluar",children:[e.jsxs("div",{style:{...ce,marginBottom:12},children:["hanoman mengirim ",e.jsx("b",{children:"HTTP POST"})," bertanda tangan ke endpoint yang Anda daftarkan setiap kali sesuatu berubah — backlog dibuat atau berpindah stage, sesi mulai dan selesai, putusan lead terbit, tiket masuk, notifikasi. Pengiriman berjalan di antrean: penerima yang lambat atau mati ",e.jsx("b",{children:"tidak"})," memperlambat hanoman."]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16},children:[e.jsxs(j,{size:"sm",onClick:()=>{g({...wt}),u(null)},children:[e.jsx(Ne,{name:"plus",size:14})," Tambah endpoint"]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:i,children:[e.jsx(Ne,{name:"book-open",size:14})," Dokumentasi webhook"]})]}),b?e.jsx(V,{kind:"error",compact:!0,title:"Gagal memuat endpoint webhook",hint:"Coba muat ulang.",action:()=>void G(),actionLabel:"Coba lagi"}):r===null?e.jsx("div",{style:ce,children:"Memuat…"}):r.length===0?e.jsx(V,{kind:"empty",compact:!0,title:"Belum ada endpoint webhook",hint:"Daftarkan URL penerima pertama untuk mulai berlangganan peristiwa hanoman."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:r.map(l=>e.jsxs("div",{"data-testid":`webhook-${l.id}`,style:{border:"1px solid var(--border-hair)",borderRadius:"var(--radius-sm)",padding:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontWeight:600},children:l.name}),e.jsx(At,{e:l}),l.pending>0?e.jsxs(ne,{children:[l.pending," mengantre"]}):null,e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[e.jsx(R,{checked:l.enabled,"aria-label":`Aktifkan ${l.name}`,onChange:S=>void ve(l,S)}),e.jsx(j,{size:"sm",variant:"ghost",disabled:c,onClick:()=>void le(l.id),children:"Test"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void ge(l.id),children:"Riwayat"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>{u(null),g({id:l.id,name:l.name,url:l.url,events:l.events,enabled:l.enabled,allowPrivate:l.allowPrivate})},children:"Ubah"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>K(l),children:"Hapus"})]})]}),e.jsx("div",{style:{...Te,color:"var(--text-muted)",marginTop:6},children:l.url}),e.jsxs("div",{style:{...ce,marginTop:6},children:["Peristiwa: ",e.jsx("code",{children:l.events.join(", ")})," · secret …",l.secretHint," ·"," ","sukses terakhir ",la(l.lastSuccessAt),l.failureStreak>0?` · ${l.failureStreak} gagal beruntun`:""]}),l.disabledReason?e.jsx("div",{style:{...ce,marginTop:6,color:"var(--status-err-tint)"},children:l.disabledReason}):null,z[l.id]?e.jsx("div",{style:{...ce,marginTop:6},children:z[l.id].ok?`Test berhasil — HTTP ${z[l.id].httpStatus} · ${z[l.id].durationMs} ms`:`Test gagal — ${z[l.id].error}`}):null]},l.id))})]}),f?e.jsxs(C,{eyebrow:"secret",title:"Salin sekarang — secret tak ditampilkan lagi",children:[e.jsx(ue,{tone:"brass",children:e.jsx("div",{style:{...Te,wordBreak:"break-all"},children:f})}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[e.jsx(j,{size:"sm",onClick:()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(f))},children:"Salin secret"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>u(null),children:"Tutup"})]})]}):null,s?e.jsx(C,{eyebrow:s.id?"ubah":"tambah",title:s.id?"Ubah endpoint":"Endpoint baru",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(ee,{label:"Nama",children:e.jsx(Y,{value:s.name,placeholder:"mis. Dashboard internal",onChange:l=>g({...s,name:l.target.value})})}),e.jsx(ee,{label:"URL tujuan",children:e.jsx(Y,{value:s.url,placeholder:"https://contoh.id/hanoman-webhook",onChange:l=>g({...s,url:l.target.value})})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:6},children:"Peristiwa yang dikirim"}),e.jsx(he,{checked:I,label:"Semua peristiwa",onChange:l=>g({...s,events:l?["*"]:[]})}),I?null:e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:8},children:[Ct.map(l=>e.jsxs("div",{children:[e.jsx(he,{checked:l.types.every(S=>s.events.includes(S)),label:l.label,onChange:S=>p(l.types,S)}),e.jsx("div",{style:{paddingLeft:22,display:"flex",flexWrap:"wrap",gap:10},children:l.types.map(S=>e.jsx(he,{checked:s.events.includes(S),label:S,onChange:M=>g({...s,events:M?[...new Set([...s.events.filter(N=>N!=="*"),S])]:s.events.filter(N=>N!==S&&N!=="*")})},S))})]},l.entity)),e.jsxs("div",{style:ce,children:[e.jsx("code",{children:Fa})," selalu terkirim saat tombol Test ditekan, apa pun langganannya."]})]})]}),e.jsx(he,{checked:s.allowPrivate,label:"Izinkan alamat internal / loopback",onChange:l=>g({...s,allowPrivate:l})}),e.jsx("div",{style:ce,children:"Biarkan mati kecuali penerima memang berjalan di mesin/jaringan yang sama. Menyalakannya membuka jalan ke layanan internal yang tak pernah dimaksudkan terekspos."}),e.jsx(he,{checked:s.enabled,label:"Aktif",onChange:l=>g({...s,enabled:l})}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(j,{size:"sm",disabled:c||!s.name||!s.url||s.events.length===0,onClick:()=>void me(),children:"Simpan"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>g(null),children:"Batal"}),s.id?e.jsx(j,{size:"sm",variant:"ghost",disabled:c,onClick:()=>void ie(s.id),children:"Rotasi secret"}):null]})]})}):null,$?e.jsxs(C,{eyebrow:"riwayat",title:"Riwayat pengiriman",children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>E(null),children:"Tutup riwayat"})}),m.length===0?e.jsx("div",{style:ce,children:"Belum ada pengiriman."}):e.jsx("div",{className:"hn-local-overflow",style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12.5},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{textAlign:"left",color:"var(--text-muted)"},children:[e.jsx("th",{style:{padding:"6px 8px"},children:"Waktu"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Jenis"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Status"}),e.jsx("th",{style:{padding:"6px 8px"},children:"HTTP"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Percobaan"}),e.jsx("th",{style:{padding:"6px 8px"},children:"Galat"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:m.map(l=>e.jsxs("tr",{style:{borderTop:"1px solid var(--border-hair)"},children:[e.jsx("td",{style:{padding:"6px 8px",whiteSpace:"nowrap"},children:la(l.createdAt)}),e.jsx("td",{style:{padding:"6px 8px",...Te},children:l.eventType}),e.jsx("td",{style:{padding:"6px 8px"},children:l.status}),e.jsx("td",{style:{padding:"6px 8px"},children:l.httpStatus??"—"}),e.jsx("td",{style:{padding:"6px 8px"},children:`${l.attempt} / ${l.maxAttempts}`}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--text-muted)"},children:l.error??"—"}),e.jsx("td",{style:{padding:"6px 8px"},children:l.status==="failed"||l.status==="dropped"?e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>void se(l.id),children:"Antre ulang"}):null})]},l.id))})]})})]}):null,e.jsx(ha,{open:!!O,title:"Hapus endpoint webhook?",message:O?`"${O.name}" beserta seluruh riwayat pengirimannya akan dihapus.`:"",confirmLabel:"Hapus",onCancel:()=>K(null),onConfirm:()=>void ae()})]})}const J={fontSize:13,color:"var(--text-muted)",lineHeight:1.6},zt={fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre",overflowX:"auto",background:"var(--bone-200)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-sm)",padding:12,margin:0};function Ke({text:a,label:i="Salin"}){const[r,d]=o.useState(!1);return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("pre",{style:zt,children:a}),e.jsx("div",{style:{marginTop:6},children:e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>{var b;(b=navigator.clipboard)==null||b.writeText(a),d(!0),setTimeout(()=>d(!1),1500)},children:r?"Tersalin":i})})]})}const Ot=`// Node.js (Express) — verifikasi tanda tangan webhook hanoman
2
2
  import express from "express";
3
3
  import { createHmac, timingSafeEqual } from "node:crypto";
4
4
 
@@ -59,4 +59,4 @@ args = ${b}
59
59
  env = { HANOMAN_HOST = "${i}", HANOMAN_AGENT_TOKEN = "hnm_agt_…" }`:a==="claude-code"?`${t}
60
60
 
61
61
  # atau, sekali jalan:
62
- claude mcp add hanoman --env HANOMAN_HOST=${i} --env HANOMAN_AGENT_TOKEN=hnm_agt_… -- hanoman mcp${d?" "+d:""}`:a==="cursor"?t.replace('"mcpServers"','"servers"'):t}const Dt={margin:0,padding:12,fontSize:12,lineHeight:1.5,overflowX:"auto",background:"var(--bone-100)",border:"1px solid var(--ink-200)",borderRadius:"var(--radius-sm)",whiteSpace:"pre"},Ae={fontSize:12.5,color:"var(--text-muted)",lineHeight:1.55,marginBottom:10},xe={padding:"6px 10px 6px 0",borderBottom:"1px solid var(--ink-100)",verticalAlign:"top",fontSize:12.5};function Ht(){const[a,i]=o.useState("claude-code"),[r,d]=o.useState("default"),[b,t]=o.useState(!1),s=typeof window>"u"?"http://localhost:8787":window.location.origin,h=Lt(a,s,r),f=sa.find(c=>c.id===a),u=()=>{var c;(c=navigator.clipboard)==null||c.writeText(h).then(()=>{t(!0),setTimeout(()=>t(!1),1500)},()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"mcp",title:"MCP server",children:[e.jsxs("div",{style:Ae,children:["Agen AI mana pun yang berbicara MCP bisa memakai hanoman lewat ",e.jsx("code",{children:"hanoman mcp"})," — tanpa pembungkus khusus per-klien. Ia memakai ",e.jsx("b",{children:"agent token yang sama"})," dengan REST dan capability yang sama; buat tokennya di kartu di atas, lalu tempel di konfigurasi klien."," ",e.jsxs("b",{children:["Skema tool versi ",ft,"."]})]}),e.jsxs("div",{style:Ae,children:["Prasyarat: ",e.jsx("code",{children:"npm i -g hanoman"})," di mesin tempat klien AI-nya jalan. Host di bawah diisi otomatis dengan instance ini — ",e.jsx("b",{children:"agent token diterbitkan per-instance"}),", jadi token dari instance lain akan selalu ditolak 401 di sini."]}),e.jsxs("div",{style:Ae,children:["Tool berbahaya — membuka sesi agen di worktree, perintah VPS, merge/rebase, penghapusan backlog, perubahan stage — ",e.jsx("b",{children:"hanya muncul"})," pada tingkat ",e.jsx("code",{children:"--danger"}),". Tingkat itu ",e.jsx("b",{children:"bukan kontrol keamanan"}),": ia menentukan tool mana yang terlihat, sementara yang menahan sungguhan adalah capability berlabel ",e.jsx("b",{children:"berbahaya"})," yang kamu centang di kartu di atas. Sebuah tool bisa terlihat dan tetap menjawab 403."]}),e.jsxs("div",{role:"group","aria-label":"Klien MCP",style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:10},children:[sa.map(c=>e.jsx(j,{size:"sm",variant:c.id===a?"primary":"ghost",onClick:()=>i(c.id),children:c.label},c.id)),e.jsx(j,{size:"sm",variant:r==="read-only"?"primary":"ghost",leftIcon:"eye",onClick:()=>d(c=>c==="read-only"?"default":"read-only"),children:"Mode baca-saja"}),e.jsx(j,{size:"sm",variant:r==="danger"?"primary":"ghost",leftIcon:"alert-triangle",onClick:()=>d(c=>c==="danger"?"default":"danger"),children:"Tampilkan tool berbahaya"})]}),e.jsx("div",{style:{...Ae,marginBottom:8},children:f.hint}),e.jsx("pre",{"data-testid":"mcp-snippet",style:Dt,children:h}),e.jsx("div",{style:{marginTop:10},children:e.jsx(j,{size:"sm",leftIcon:"copy",onClick:u,children:b?"Tersalin":"Salin"})})]}),e.jsxs(C,{eyebrow:"tool",title:"Tool yang tersedia",children:[e.jsxs("div",{style:Ae,children:["Centang capability di bawah pada token yang dipakai. Mode baca-saja menyembunyikan seluruh tool bertanda ",e.jsx("i",{children:"tulis"}),"."]}),e.jsx("div",{className:"hn-local-overflow",style:{overflowX:"auto"},children:e.jsxs("table",{"data-testid":"mcp-tools",style:{borderCollapse:"collapse",width:"100%"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...xe,textAlign:"left",fontSize:11.5,color:"var(--text-subtle)"},children:"Tool"}),e.jsx("th",{style:{...xe,textAlign:"left",fontSize:11.5,color:"var(--text-subtle)"},children:"Mode"}),e.jsx("th",{style:{...xe,textAlign:"left",fontSize:11.5,color:"var(--text-subtle)"},children:"Capability"})]})}),e.jsx("tbody",{children:xt.map(c=>e.jsxs("tr",{children:[e.jsxs("td",{style:xe,children:[e.jsx("code",{children:c.name}),e.jsx("div",{style:{fontSize:11.5,color:"var(--text-subtle)"},children:c.title})]}),e.jsx("td",{style:xe,children:c.mode==="read"?"baca":"tulis"}),e.jsx("td",{style:xe,children:c.capability?e.jsx("code",{children:c.capability}):e.jsx("span",{style:{color:"var(--text-subtle)"},children:"—"})})]},c.name))})]})})]})]})}const _t="https://github.com/denameidina/hanoman/blob/main/docs/agent-integration.md";function Nt({onToast:a}){const[i,r]=o.useState(null),[d,b]=o.useState(!1),[t,s]=o.useState(!1),[h,f]=o.useState(!1),u=`${window.location.origin}${Ka.agentDoc}`;async function c(){if(!h){if(i){b(!0);return}f(!0),s(!1);try{r(await y.agentDoc()),b(!0)}catch{s(!0)}finally{f(!1)}}}return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"dokumentasi",title:"Dokumentasi AI Agent",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Satu halaman yang membuat agen mana pun bisa langsung bekerja — cukup berikan"," ",e.jsx("b",{children:"tautan ini + satu agent token"}),". Markdown mentah, bisa diambil agen lewat HTTP biasa, ",e.jsx("b",{children:"tanpa auth"}),"."]}),e.jsx("code",{style:{display:"block",wordBreak:"break-all",fontSize:12,marginBottom:10},children:u}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsx(j,{size:"sm",leftIcon:"copy",onClick:()=>{var k;(k=navigator.clipboard)==null||k.writeText(u),a==null||a("Tautan disalin","ok","copy")},children:"Salin tautan"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"book-open",disabled:h,onClick:()=>void c(),children:h?"Memuat…":"Buka"}),e.jsx("a",{href:_t,target:"_blank",rel:"noreferrer",children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"external-link",children:"Lihat di GitHub"})})]}),t&&e.jsx("div",{style:{marginTop:12},children:e.jsx(V,{kind:"error",compact:!0,title:"Gagal memuat dokumentasi",hint:u,action:()=>void c(),actionLabel:"Coba lagi"})})]}),d&&i!==null&&e.jsx(kt,{path:"agent-integration.md",text:i,eyebrow:"hanoman · panduan AI agent",onClose:()=>b(!1)})]})}const ra={feature:"Brief (feature)",qa:"QA",scaffold:"Scaffold",reverse:"Reverse docs",prd:"PRD",audit:"Audit",breakdown:"Breakdown PRD",goal:"Goal",no_effort:"No effort"},da=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex CLI"}],Rt={model:null,effort:null},Le={padding:"6px 8px",borderTop:"1px solid var(--border-hair)",verticalAlign:"top"};function Ft({flow:a,phase:i,runtime:r,cell:d,onPick:b}){const t=qa(r),s=Ya(r,d.model??""),h=r==="codex"?te:ba,f=[{value:"",label:"— warisi orchestrator"},...d.model&&!t.some(c=>c.id===d.model)?[{value:d.model,label:d.model}]:[],...t.map(c=>({value:c.id,label:c.label}))],u=[{value:"",label:"— warisi"},...d.effort&&!s.includes(d.effort)?[{value:d.effort,label:d.effort}]:[],...s.map(c=>({value:c,label:c}))];return e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(L,{size:"sm","aria-label":`Model ${a} ${i} ${r}`,value:d.model??"",style:{minWidth:150},options:f,onChange:c=>{const k=c.target.value||null;b({model:k,effort:k&&d.effort?h(k,d.effort):d.effort},`${i} (${r}) → ${k??"warisi"}`)}}),e.jsx(L,{size:"sm","aria-label":`Effort ${a} ${i} ${r}`,value:d.effort??"",style:{minWidth:96},options:u,onChange:c=>b({...d,effort:c.target.value||null},`${i} (${r}) effort → ${c.target.value||"warisi"}`)})]})}function $t({orchestration:a,onChange:i}){const r=a??Je,d=t=>r[t]??Je[t],b=(t,s,h)=>i({...r,[t]:s},h);return e.jsxs(e.Fragment,{children:[e.jsx(C,{eyebrow:"orkestrasi",title:"Orkestrasi subagent per fase",children:e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",lineHeight:1.5},children:["Sesi utama menjadi ",e.jsx("b",{children:"orchestrator"}),"; setiap fase dikerjakan subagent dengan model & effort di bawah. ",e.jsx("b",{children:"Warisi"})," memakai model/effort orchestrator yang dipilih saat ",e.jsx("b",{children:"Start"}),". Subagent selalu berjalan di runtime orchestrator: sesi claude memakai kolom Claude Code, sesi codex kolom Codex CLI. Flow yang dimatikan berjalan sebagai sesi tunggal seperti sebelumnya."]})}),Ja.map(t=>{const s=d(t);return e.jsx("div",{"data-testid":`orch-flow-${t}`,children:e.jsxs(C,{eyebrow:"flow",title:ra[t],children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:s.enabled?"Fase dikerjakan subagent":"Sesi tunggal (orkestrasi mati)"}),e.jsx(R,{checked:s.enabled,"aria-label":`Orkestrasi ${t}`,onChange:h=>b(t,{...s,enabled:h},`Orkestrasi ${ra[t]} · ${h?"aktif":"nonaktif"}`)})]}),e.jsx("div",{style:{overflowX:"auto",opacity:s.enabled?1:.55},children:e.jsxs("table",{style:{width:"100%",minWidth:560,borderCollapse:"collapse",fontSize:12.5},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...Le,borderTop:"none",textAlign:"left"},children:"Fase"}),da.map(h=>e.jsx("th",{style:{...Le,borderTop:"none",textAlign:"left"},children:h.label},h.id))]})}),e.jsx("tbody",{children:Va[t].map(h=>e.jsxs("tr",{children:[e.jsx("td",{style:Le,children:h}),da.map(f=>e.jsx("td",{style:Le,children:e.jsx(Ft,{flow:t,phase:h,runtime:f.id,cell:s[f.id][h]??Rt,onPick:(u,c)=>b(t,{...s,[f.id]:{...s[f.id],[h]:u}},c)})},f.id))]},h))})]})})]})},t)})]})}const fe=a=>mt(a).map(i=>({value:i,label:i==="xhigh"?"x-high":i})),je=(a,i)=>{const r=ba(a,i);return r===i?{}:{effort:r}},oa=[{value:"blip",label:"Blip · 0.1s"},{value:"pop",label:"Pop · 0.1s"},{value:"short",label:"Short · 0.15s"},{value:"ping",label:"Ping · 0.2s"},{value:"coin",label:"Coin · 0.3s"},{value:"alert",label:"Alert · 0.3s"},{value:"medium",label:"Medium · 0.4s"},{value:"chime",label:"Chime · 0.4s"},{value:"success",label:"Success · 0.4s"},{value:"bell",label:"Bell · 0.5s"},{value:"marimba",label:"Marimba · 0.6s"},{value:"long",label:"Long · 0.8s"},{value:"fanfare",label:"Fanfare · 0.9s"},{value:"off",label:"Senyap"}],Wt={model:"claude-sonnet-5",effort:"medium",autoDefault:!0,autoScaffold:!0,notifyFail:!0,notifyDone:!0,notifySound:"short",notifyDecision:!0,notifyDecisionSound:"alert",agentAccessEnabled:!1,scheduler:ut,goal:ct,agent:"claude",codex:ka,verifyScope:"changed",method:ot,conflict:ja,lead:_e,telegram:ye,changelog:fa,portalChat:xa,orchestration:Je,remoteControl:dt,logShipping:rt,logRetention:st,builtinAgents:{},builtinAgentPolicies:{},builtinRuntimeDefaults:lt},T={claude:"Claude Code",codex:"Codex CLI"};function ca({id:a,label:i,active:r}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:4},children:[e.jsx("div",{style:{fontSize:13.5,fontWeight:700,color:"var(--text-strong)"},children:i}),e.jsx("span",{"data-testid":`agent-badge-${a}`,style:{fontSize:11,fontFamily:"var(--font-mono)",padding:"2px 7px",borderRadius:999,background:r?"var(--brass-100)":"transparent",color:r?"var(--brass-700)":"var(--text-subtle)",border:r?"none":"1px solid var(--border-hair)"},children:r?"dipakai sesi baru":"tidak dipakai sekarang"})]})}function v({title:a,desc:i,children:r,last:d}){return e.jsxs("div",{className:"hn-setting-row",style:{display:"flex",alignItems:"center",gap:16,padding:"14px 0",borderBottom:d?"none":"1px solid var(--border-hair)"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)"},children:a}),i&&e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginTop:3,lineHeight:1.5},children:i})]}),e.jsx("div",{className:"hn-setting-control",style:{flex:"0 0 auto"},children:r})]})}function Gt({me:a,onLoggedOut:i,onToast:r}){const[d,b]=o.useState(""),[t,s]=o.useState(""),[h,f]=o.useState(!1),u=d.length>=1&&t.length>=8&&!h;async function c(){if(u){f(!0);try{await y.changePassword({currentPassword:d,newPassword:t}),b(""),s(""),r==null||r("Password diganti · perangkat lain ter-logout","ok","key-round")}catch(z){r==null||r(z instanceof Ve&&z.status===400?"Password lama salah":"Gagal ganti password","err","x-circle")}finally{f(!1)}}}async function k(){try{await y.logout()}finally{i()}}return e.jsxs(C,{eyebrow:"akun",title:"Akun",actions:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"log-out",onClick:k,children:"Logout"}),children:[e.jsx(v,{title:"Masuk sebagai",desc:a.email,children:e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-subtle)"},children:a.id})}),e.jsxs("div",{style:{paddingTop:14},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)",marginBottom:10},children:"Ganti password"}),e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:10,alignItems:"end"},children:[e.jsx(ee,{label:"Password lama",children:e.jsx(Y,{type:"password",autoComplete:"current-password",placeholder:"••••••••",value:d,onChange:z=>b(z.target.value),style:{width:"100%"}})}),e.jsx(ee,{label:e.jsxs(e.Fragment,{children:["Password baru ",e.jsx("span",{style:{fontWeight:400,color:"var(--text-subtle)"},children:"· min 8"})]}),children:e.jsx(Y,{type:"password",autoComplete:"new-password",placeholder:"minimal 8 karakter",value:t,onChange:z=>s(z.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",leftIcon:"key-round",disabled:!u,onClick:c,style:{marginBottom:14},children:"Ganti"})]})]})]})}function Ut({me:a,onToast:i}){const{confirm:r,dialog:d}=Fe(),[b,t]=o.useState(null),[s,h]=o.useState(""),[f,u]=o.useState(""),[c,k]=o.useState(!1),z=o.useCallback(()=>{y.listUsers().then(t).catch(()=>t([]))},[]);o.useEffect(()=>{z()},[z]);const F=/\S+@\S+\.\S+/.test(s)&&f.length>=8&&!c;async function $(){if(F){k(!0);try{await y.inviteUser({email:s,password:f}),h(""),u(""),z(),i==null||i("User "+s+" diundang","ok","user-plus")}catch(m){i==null||i(m instanceof Ve&&m.status===409?"Email sudah dipakai":"Gagal mengundang user","err","x-circle")}finally{k(!1)}}}async function E(m){try{if(!await r({title:`Hapus user "${m.email}"?`,message:"User ini kehilangan akses ke dashboard seketika.",impact:["Semua sesi login miliknya ikut dicabut.","Tindakan ini tak bisa dibatalkan."],confirmLabel:"Hapus user",run:()=>y.deleteUser(m.id)}))return;z(),i==null||i("User "+m.email+" dihapus","warn","trash-2")}catch(x){i==null||i(x instanceof Ve&&x.status===400?"Tak bisa hapus user terakhir":"Gagal hapus user","err","x-circle")}}return e.jsxs(C,{eyebrow:"users",title:"Users",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:"Undang user lain dengan menetapkan password-nya langsung — tanpa email undangan."}),b===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat users…"}):b.map((m,x)=>e.jsx(v,{title:m.email,last:x===b.length-1,desc:"dibuat "+new Date(m.createdAt).toLocaleDateString("id-ID")+(m.id===a.id?" · kamu":""),children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",disabled:b.length<=1,onClick:()=>E(m),children:"Hapus"})},m.id)),e.jsxs("div",{style:{paddingTop:14},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)",marginBottom:10},children:"Invite user"}),e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:10,alignItems:"end"},children:[e.jsx(ee,{label:"Email",children:e.jsx(Y,{type:"email",value:s,placeholder:"user@nafanesia.id",onChange:m=>h(m.target.value),style:{width:"100%"}})}),e.jsx(ee,{label:e.jsxs(e.Fragment,{children:["Password ",e.jsx("span",{style:{fontWeight:400,color:"var(--text-subtle)"},children:"· min 8"})]}),children:e.jsx(Y,{type:"password",autoComplete:"new-password",placeholder:"minimal 8 karakter",value:f,onChange:m=>u(m.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",leftIcon:"user-plus",disabled:!F,onClick:$,style:{marginBottom:14},children:"Invite"})]})]}),d]})}function Tt({onToast:a}){const{confirm:i,dialog:r}=Fe(),[d,b]=o.useState(null),[t,s]=o.useState(""),[h,f]=o.useState(null),[u,c]=o.useState(!1),k=o.useCallback(()=>{y.listDeviceTokens().then(b).catch(()=>b([]))},[]);o.useEffect(()=>{k()},[k]);async function z(){if(!(t.trim().length<1||u)){c(!0);try{const E=await y.createDeviceToken({name:t.trim()});f({name:E.name,token:E.token}),s(""),k(),a==null||a("Token perangkat dibuat — salin sekarang","ok","key-round")}catch{a==null||a("Gagal membuat token","err","x-circle")}finally{c(!1)}}}async function F(E){try{if(!await i({title:`Cabut token perangkat "${E.name}"?`,message:"Perangkat itu tak bisa sync lagi sampai token baru dibuat.",confirmLabel:"Cabut token",icon:"key-round",run:()=>y.revokeDeviceToken(E.id)}))return;k(),a==null||a("Token dicabut","warn","trash-2")}catch{a==null||a("Gagal mencabut token","err","x-circle")}}const $=(d??[]).filter(E=>!E.revokedAt);return e.jsxs(C,{eyebrow:"perangkat",title:"Device tokens",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Token per-perangkat untuk menyinkronkan instance lokal ke hub (Bearer). Tempel di",e.jsx("code",{style:{margin:"0 4px"},children:"SYNC_DEVICE_TOKEN"})," pada instance client. Plaintext hanya tampil sekali."]}),h&&e.jsxs("div",{style:{padding:12,marginBottom:12,border:"1px solid var(--brass-300)",borderRadius:"var(--radius-sm)",background:"var(--brass-100)"},children:[e.jsxs("div",{style:{fontSize:12.5,fontWeight:600,marginBottom:6},children:["Token untuk “",h.name,"” — salin sekarang, tak akan ditampilkan lagi:"]}),e.jsx("code",{style:{display:"block",wordBreak:"break-all",fontSize:12},children:h.token}),e.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[e.jsx(j,{size:"sm",leftIcon:"copy",onClick:()=>{var E;(E=navigator.clipboard)==null||E.writeText(h.token),a==null||a("Disalin","ok","copy")},children:"Salin"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>f(null),children:"Tutup"})]})]}),d===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat token…"}):$.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada token perangkat."}):$.map((E,m)=>e.jsx(v,{title:E.name,last:m===$.length-1,desc:"dibuat "+new Date(E.createdAt).toLocaleDateString("id-ID")+(E.lastSeenAt?" · terlihat "+new Date(E.lastSeenAt).toLocaleString("id-ID"):" · belum dipakai"),children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:()=>F(E),children:"Cabut"})},E.id)),e.jsxs("div",{className:"hn-grid-mobile",style:{paddingTop:14,display:"grid",gridTemplateColumns:"1fr auto",gap:10,alignItems:"end"},children:[e.jsx(ee,{label:"Nama perangkat",children:e.jsx(Y,{value:t,placeholder:"laptop-dena",onChange:E=>s(E.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",leftIcon:"plus",disabled:t.trim().length<1||u,onClick:z,style:{marginBottom:14},children:"Buat token"})]}),r]})}function Kt({onToast:a}){const{confirm:i,dialog:r}=Fe(),[d,b]=o.useState(""),[t,s]=o.useState(null),h=o.useCallback(()=>{y.listSessionResults(d||void 0).then(s).catch(()=>s([]))},[d]);o.useEffect(()=>{h()},[h]);async function f(){if(!d){a==null||a("Isi project id untuk purge","warn","alert-triangle");return}try{if(!await i({title:`Purge activity log project "${d}"?`,message:"Seluruh entri hasil sesi project ini dihapus dari device ini.",impact:["Log bersifat append-only — entri yang dihapus tak bisa dipulihkan."],confirmLabel:"Purge",run:async()=>{const u=await y.purgeSessionResults(d);a==null||a(`${u.purged} entri dihapus`,"warn","trash-2")}}))return;h()}catch{a==null||a("Gagal purge","err","x-circle")}}return e.jsxs(C,{eyebrow:"aktivitas",title:"Activity log",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:"Ringkasan hasil sesi lintas device (transisi stage, commit, PR) — append-only. Filter per project."}),e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr auto",gap:10,alignItems:"end",marginBottom:12},children:[e.jsx(ee,{label:"Project id (opsional)",children:e.jsx(Y,{value:d,placeholder:"mis. hanoman — kosong = semua project",onChange:u=>b(u.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",disabled:!d,onClick:f,style:{marginBottom:14},children:"Purge"})]}),t===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat aktivitas…"}):t.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada aktivitas."}):t.map((u,c)=>e.jsx(v,{last:c===t.length-1,title:`${u.specId??u.projectId}${u.oldStage&&u.newStage?` · ${u.oldStage} → ${u.newStage}`:""}`,desc:[u.status,u.commitSha?u.commitSha.slice(0,8):null,u.branch,u.author,new Date(u.createdAt).toLocaleString("id-ID")].filter(Boolean).join(" · "),children:u.prUrl&&e.jsx("a",{href:u.prUrl,target:"_blank",rel:"noreferrer",children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"external-link",children:"PR"})})},u.id)),r]})}const Jt={sync:"Sync",claude:"Claude",vps:"VPS",runtime:"Runtime",bootstrap:"Bootstrap (read-only)"};function Vt({onToast:a}){const[i,r]=o.useState(null),[d,b]=o.useState({}),t=o.useCallback(()=>{y.getConfig().then(r).catch(()=>r(null))},[]);if(o.useEffect(()=>{t()},[t]),!i)return e.jsx(V,{kind:"loading",title:"Memuat konfigurasi…"});const s=c=>b(k=>{const z={...k};return delete z[c],z}),h=async c=>{const k=d[c.key]??"";try{await y.putConfig(c.key,k),s(c.key),t(),a==null||a(`${c.label} disimpan`,"ok","check-circle-2")}catch{a==null||a(`Gagal menyimpan ${c.label}`,"err","x-circle")}},f=async c=>{try{await y.deleteConfig(c.key),s(c.key),t(),a==null||a(`${c.label} direset`,"warn","rotate-ccw")}catch{a==null||a("Gagal reset","err","x-circle")}},u=[...new Set(i.entries.map(c=>c.group))];return e.jsx(e.Fragment,{children:u.map(c=>e.jsxs(C,{eyebrow:c,title:Jt[c]??c,children:[c==="sync"&&e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:8},children:i.sync.running?i.sync.connected?"● Tersambung ke hub":"◐ Sync aktif, menyambung…":"○ Tidak sync (HUB murni)"}),i.entries.filter(k=>k.group===c).map(k=>e.jsx(v,{title:k.label,desc:k.help,children:e.jsx(Yt,{entry:k,draft:d[k.key],onDraft:z=>b(F=>({...F,[k.key]:z})),onSave:()=>h(k),onReset:()=>f(k)})},k.key))]},c))})}function Yt({entry:a,draft:i,onDraft:r,onSave:d,onReset:b}){var s,h;const t=e.jsxs("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono)",color:"var(--text-subtle)",marginRight:8},children:[a.source," · ",a.apply]});if(!a.editable)return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,e.jsx("code",{style:{fontSize:12},children:a.masked??a.value??"—"})]});if(a.kind==="secret")return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,a.hasValue&&i===void 0?e.jsxs(e.Fragment,{children:[e.jsx("code",{style:{fontSize:12},children:a.masked}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"pencil",onClick:()=>r(""),children:"Ganti"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:b,children:"Hapus"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{"aria-label":a.label,type:"password",placeholder:a.hasValue?"biarkan kosong = pertahankan":((s=Re(a.key))==null?void 0:s.example)??"tempel token…",value:i??"",onChange:f=>r(f.target.value),style:{width:240}}),e.jsx(j,{size:"sm",leftIcon:"save",onClick:d,children:"Simpan"})]})]});if(a.kind==="bool"){const f=(i??a.value)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,e.jsx(R,{checked:f,onChange:u=>{r(u?"1":"0")}}),i!==void 0&&e.jsx(j,{size:"sm",leftIcon:"save",onClick:d,children:"Simpan"})]})}return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,e.jsx(Y,{"aria-label":a.label,type:a.kind==="int"?"number":"text",placeholder:(h=Re(a.key))==null?void 0:h.example,value:i??a.value??"",onChange:f=>r(f.target.value),style:{width:240}}),e.jsx(j,{size:"sm",leftIcon:"save",onClick:d,children:"Simpan"}),a.source==="db"&&e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"rotate-ccw",onClick:b,children:"Reset"})]})}const qt=[{had:"sessions:write",needs:"sessions:spawn",sentence:"dulu bisa membuka sesi baru"},{had:"ide:write",needs:"ide:git",sentence:"dulu bisa merge/rebase & menghapus branch"},{had:"backlog:write",needs:"backlog:lifecycle",sentence:"dulu bisa integrate & menghapus backlog"},{had:"vps:write",needs:"vps:exec",sentence:"dulu bisa menjalankan perintah di VPS"}];function ua(a){return qt.filter(i=>a.includes(i.had)&&!a.includes(i.needs)).map(i=>i.sentence)}function De({ids:a,picked:i,onToggle:r,ariaLabel:d,label:b}){const t=o.useRef(null),s=a.filter(f=>i.includes(f)).length,h=a.length>0&&s===a.length;return o.useEffect(()=>{t.current&&(t.current.indeterminate=s>0&&!h)},[s,h]),a.length===0?null:e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:4,cursor:"pointer",fontSize:11.5,color:"var(--text-subtle)",marginLeft:b?0:5},children:[b&&e.jsx("span",{children:b}),e.jsx("input",{ref:t,type:"checkbox","aria-label":d,checked:h,onChange:()=>r(a,!h)})]})}function Xt({onToast:a}={}){const{confirm:i,dialog:r}=Fe(),[d,b]=o.useState([]),[t,s]=o.useState(null),[h,f]=o.useState(null),[u,c]=o.useState(""),[k,z]=o.useState([]),[F,$]=o.useState(null),[E,m]=o.useState(!1),x=o.useCallback(()=>{y.listAgentTokens().then(p=>s(p.items)).catch(()=>s([]))},[]);o.useEffect(()=>{y.getSettings().then(f).catch(()=>{}),y.getAgentCapabilities().then(p=>b(p.capabilities)).catch(()=>{}),x()},[x]);async function O(p){if(!h)return;const I={...h,agentAccessEnabled:p};f(I);try{await y.putSettings(I),a==null||a("Akses AI agent "+(p?"aktif":"nonaktif"),p?"ok":"warn","bot")}catch{a==null||a("Gagal menyimpan","err","x-circle"),f(h)}}const K=p=>z(I=>I.includes(p)?I.filter(l=>l!==p):[...I,p]),G=(p,I)=>z(l=>I?Array.from(new Set([...l,...p])):l.filter(S=>!p.includes(S)));async function he(){if(!(u.trim().length<1||E)){m(!0);try{const p=await y.createAgentToken({name:u.trim(),capabilities:k});$({name:p.name,token:p.token}),c(""),z([]),x(),a==null||a("Agent token dibuat — salin sekarang","ok","key-round")}catch{a==null||a("Gagal membuat token","err","x-circle")}finally{m(!1)}}}async function me(p){try{if(!await i({title:`Cabut agent token "${p.name}"?`,message:"Agen yang memakainya langsung kehilangan akses.",confirmLabel:"Cabut token",icon:"key-round",run:()=>y.revokeAgentToken(p.id)}))return;x(),a==null||a("Token dicabut","warn","trash-2")}catch{a==null||a("Gagal mencabut token","err","x-circle")}}async function ie(p,I){try{await y.patchAgentToken(p.id,{enabled:I}),x()}catch{a==null||a("Gagal mengubah token","err","x-circle")}}const ve=Array.from(new Set(d.map(p=>p.domain))),le=p=>d.filter(I=>I.access===p).map(I=>I.id),ae=d.map(p=>p.id),se=(t??[]).filter(p=>!p.revokedAt);return e.jsxs(e.Fragment,{children:[e.jsx(Nt,{onToast:a}),e.jsxs(C,{eyebrow:"ai agent",title:"Akses AI Agent",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Beri AI agent eksternal kendali hanoman lewat token (header ",e.jsx("code",{children:"Authorization: Bearer"}),"). Tiap fitur dibuka per ",e.jsx("b",{children:"capability"}),". Selagi master switch mati, semua token ditolak."]}),e.jsx(v,{title:"Aktifkan akses AI agent",last:!0,desc:"Master switch. Nonaktif → semua agent token 401, apa pun capability-nya.",children:e.jsx(R,{checked:!!(h!=null&&h.agentAccessEnabled),onChange:p=>void O(p)})})]}),e.jsxs(C,{eyebrow:"token",title:"Agent tokens",children:[F&&e.jsxs("div",{style:{padding:12,marginBottom:12,border:"1px solid var(--brass-300)",borderRadius:"var(--radius-sm)",background:"var(--brass-100)"},children:[e.jsxs("div",{style:{fontSize:12.5,fontWeight:600,marginBottom:6},children:["Token “",F.name,"” — salin sekarang, tak akan ditampilkan lagi:"]}),e.jsx("code",{style:{display:"block",wordBreak:"break-all",fontSize:12},children:F.token}),e.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[e.jsx(j,{size:"sm",leftIcon:"copy",onClick:()=>{var p;(p=navigator.clipboard)==null||p.writeText(F.token),a==null||a("Disalin","ok","copy")},children:"Salin"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>$(null),children:"Tutup"})]})]}),t===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat token…"}):se.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada agent token."}):se.map((p,I)=>e.jsx(v,{title:p.name,last:I===se.length-1,desc:`${p.tokenPrefix}… · ${p.capabilities.length} capability · `+(p.lastUsedAt?"terpakai "+new Date(p.lastUsedAt).toLocaleString("id-ID"):"belum dipakai")+(ua(p.capabilities).length?` — token ini ${ua(p.capabilities).join(", ")}; sekarang tidak, sampai capability berbahayanya dicentang. Cabut lalu buat ulang bila memang perlu.`:""),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(R,{size:"sm",checked:p.enabled,onChange:l=>void ie(p,l)}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:()=>me(p),children:"Cabut"})]})},p.id)),e.jsxs("div",{style:{paddingTop:14},children:[e.jsx(ee,{label:"Nama token",children:e.jsx(Y,{value:u,placeholder:"mis. agent-ci",onChange:p=>c(p.target.value),style:{width:"100%"}})}),e.jsx("div",{style:{marginTop:12,fontSize:12.5,fontWeight:600,color:"var(--text-strong)"},children:"Capability"}),e.jsxs("div",{className:"hn-grid-mobile",style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr auto auto auto",gap:"6px 14px",alignItems:"center"},children:[e.jsx("div",{style:{textAlign:"right"},children:e.jsx(De,{label:"Pilih semua capability",ariaLabel:"pilih semua capability",ids:ae,picked:k,onToggle:G})}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--text-subtle)",textAlign:"center"},children:["baca",e.jsx(De,{ariaLabel:"pilih semua baca",ids:le("read"),picked:k,onToggle:G})]}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--text-subtle)",textAlign:"center"},children:["tulis",e.jsx(De,{ariaLabel:"pilih semua tulis",ids:le("write"),picked:k,onToggle:G})]}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--status-err)",textAlign:"center"},children:["berbahaya",e.jsx(De,{ariaLabel:"pilih semua berbahaya",ids:le("danger"),picked:k,onToggle:G})]}),ve.map(p=>{const I=d.find(N=>N.domain===p&&N.access==="read"),l=d.find(N=>N.domain===p&&N.access==="write"),S=d.find(N=>N.domain===p&&N.access==="danger"),M=Xa.find(N=>N.domain===p);return e.jsxs(o.Fragment,{children:[e.jsxs("div",{style:{fontSize:13,color:"var(--text-muted)"},children:[e.jsxs("div",{style:{fontWeight:600,color:"var(--text-strong)"},children:[(M==null?void 0:M.label)??p,l!=null&&l.risk||S!=null&&S.risk?" ⚠":""]}),(M==null?void 0:M.desc)&&e.jsx("div",{style:{fontSize:11.5,color:"var(--text-subtle)",lineHeight:1.4,marginTop:1},children:M.desc}),S&&e.jsxs("div",{style:{fontSize:11.5,color:"var(--status-err)",lineHeight:1.4,marginTop:2},children:[S.label.replace(/^[^—]+—\s*/,"berbahaya: ")," — ",S.desc]})]}),e.jsx("div",{style:{textAlign:"center"},children:I&&e.jsx("input",{type:"checkbox","aria-label":I.id,checked:k.includes(I.id),onChange:()=>K(I.id)})}),e.jsx("div",{style:{textAlign:"center"},children:l&&e.jsx("input",{type:"checkbox","aria-label":l.id,checked:k.includes(l.id),onChange:()=>K(l.id)})}),e.jsx("div",{style:{textAlign:"center"},children:S&&e.jsx("input",{type:"checkbox","aria-label":S.id,checked:k.includes(S.id),onChange:()=>K(S.id)})})]},p)})]}),e.jsx("div",{style:{marginTop:14},children:e.jsx(j,{size:"sm",leftIcon:"plus",disabled:u.trim().length<1||E,onClick:()=>void he(),children:"Buat token"})})]}),r]}),e.jsx(Ht,{})]})}function Qt(){const[a,i]=o.useState(null),[r,d]=o.useState(!1),b=o.useCallback(()=>{y.setupStatus().then(i).catch(()=>i(null))},[]);return o.useEffect(b,[b]),a?r?e.jsx(it,{status:a,onDone:()=>{d(!1),b()}}):e.jsx("div",{"data-testid":"setup-card",children:e.jsxs(C,{eyebrow:"setup",title:"Setup awal",children:[e.jsxs("div",{style:{fontSize:12.5,lineHeight:1.6,marginBottom:12},children:["Peruntukan: ",a.deployment==="local"?"Device saya sendiri":"Diakses orang lain",e.jsx("br",{}),a.hardening?"Hardening menyala":"Hardening mati",a.hardeningLocked?" — dipasang lewat env, tak bisa diubah dari sini":""]}),e.jsx(j,{onClick:()=>d(!0),children:"Jalankan ulang setup"})]})}):e.jsx(V,{kind:"loading",title:"Memuat setup…"})}const ha=[{key:"akun",label:"Akun",icon:"user-round"},{key:"users",label:"Users",icon:"users"},{key:"akses-klien",label:"Akses klien",icon:"user-check"},{key:"perangkat",label:"Perangkat",icon:"key-round"},{key:"kendali-jarak-jauh",label:"Kendali jarak jauh",icon:"shield"},{key:"agent",label:"Akses AI Agent",icon:"bot"},{key:"custom-agent",label:"Custom agent",icon:"bot"},{key:"aktivitas",label:"Aktivitas",icon:"activity"},{key:"konfigurasi",label:"Konfigurasi",icon:"sliders"},{key:"setup",label:"Setup awal",icon:"shield"},{key:"telegram",label:"Telegram",icon:"send"},{key:"webhook",label:"Webhook",icon:"webhook"},{key:"umum",label:"Umum",icon:"sliders-horizontal"},{key:"model",label:"Model sesi",icon:"cpu"},{key:"orkestrasi",label:"Orkestrasi",icon:"layers"},{key:"sesi",label:"Sesi",icon:"bell"}];function ln({onToast:a,me:i,onLoggedOut:r}){const d=Qa(),b=Za.map(D=>({value:D.id,label:D.label})),[t,s]=o.useState(null),[h,f]=o.useState(!1),[u,c]=et("settings","tab","akun",nt),k=at(),z=k==="mobile",[F,$]=o.useState(!1),[E,m]=o.useState(null),[x,O]=o.useState(!1),[K,G]=o.useState(null);o.useEffect(()=>{y.getCodexVersion().then(G).catch(()=>{})},[]);const[he,me]=o.useState(null),[ie,ve]=o.useState("");o.useEffect(()=>{u==="sesi"&&(y.getMethodStatus().then(me).catch(()=>me(null)),y.listProjects({limit:100}).then(D=>ve(H=>{var de;return H||(((de=D.items.find(Oe=>Oe.binding??Oe.repoDir))==null?void 0:de.id)??"")})).catch(()=>{}))},[u]);const le=o.useCallback(()=>{f(!1),s(null),y.getSettings().then(s).catch(()=>f(!0))},[]);o.useEffect(()=>{le()},[le]);const ae=o.useCallback(()=>{O(!1),m(null),y.getTelegramStatus().then(m).catch(()=>O(!0))},[]);o.useEffect(()=>{u==="telegram"&&ae()},[u,ae]);const[se,p]=o.useState(null),[I,l]=o.useState({}),[S,M]=o.useState(null),[N,$e]=o.useState(!1),ze=o.useCallback(()=>{y.getTelegramCredentials().then(D=>{p(D),l({})}).catch(()=>p(null))},[]);o.useEffect(()=>{u==="telegram"&&ze()},[u,ze]);function ya(){var qe,Xe,Qe;if(h)return e.jsx(V,{kind:"error",title:"Gagal memuat pengaturan",hint:"Pengaturan tidak ditampilkan agar tidak menimpa nilai di server.",action:le});if(!t)return e.jsx(V,{kind:"loading",title:"Memuat pengaturan…"});const D=(A,B,_,oe)=>{s(A),y.putSettings(A).catch(()=>{}),B&&a&&a(B,_||"ok",oe||"check-circle-2")},H=(A,B)=>D({...t,...A},B),de=(A,B)=>_=>H({[A]:_},B+(_?" · aktif":" · nonaktif")),Oe=async A=>{if(ie)try{await y.createShell(ie,{method:A.method,agent:A.agent}),a==null||a(`Pemasangan ${A.label} · ${T[A.agent]} berjalan di Terminal`,"ok","terminal")}catch{a==null||a("Gagal membuka sesi terminal pemasangan","err","alert-triangle")}},X=t.codex??ka,Be=t.agent??"claude";if(u==="telegram"){const A=t.telegram??ye,B=(E==null?void 0:E.readiness)??"memuat",_=w=>w==="db"?e.jsx(ne,{tone:"ok",children:"tersimpan"}):w==="env"?e.jsx(ne,{tone:"warn",children:"dari .env · deprecated"}):e.jsx(ne,{children:"belum diisi"}),oe=()=>{const w=Object.fromEntries(Object.entries(I).filter(([,Z])=>Z!==""));if(!Object.keys(w).length){a==null||a("Tak ada perubahan","info","info");return}y.putTelegramCredentials(w).then(Z=>{p(Z),l({}),M(null),a==null||a("Kredensial Telegram disimpan","ok","check-circle-2"),ae()}).catch(Z=>a==null?void 0:a(Z.message||"Gagal menyimpan","err","alert-triangle"))},q=()=>{M("sending"),y.testTelegramConnection().then(M).catch(w=>M({ok:!1,error:w.message||"Gagal menghubungi server",inbound:{ok:!1,reason:"Status jalur masuk tak terbaca — server tak menjawab.",missingCapabilities:[],polling:!1}}))},Se=()=>{$e(!1),y.deleteTelegramCredentials().then(w=>{a==null||a(w.envFallback.length?`Kredensial dihapus — ${w.envFallback.length} nilai masih datang dari .env`:"Kredensial Telegram dihapus","ok","check-circle-2"),M(null),ze(),ae()}).catch(w=>a==null?void 0:a(w.message||"Gagal menghapus","err","alert-triangle"))};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"telegram",title:"Kredensial Telegram",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Disimpan terenkripsi di database dan berlaku langsung — tanpa mengedit ",e.jsx("code",{children:".env"}),", tanpa restart. Nilai ",e.jsx("code",{children:".env"})," lama tetap dipakai selama field-nya masih kosong."]}),se?e.jsxs(e.Fragment,{children:[se.fields.map((w,Z)=>{var we,W;return e.jsx(v,{title:w.label,desc:w.help,last:Z===se.fields.length-1,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[_(w.source),e.jsx(Y,{"aria-label":w.label,mono:!0,type:w.kind==="secret"?"password":"text",placeholder:w.kind==="secret"?w.masked??((we=Re(w.key))==null?void 0:we.example)??"belum diisi":((W=Re(w.key))==null?void 0:W.example)??"belum diisi",value:I[w.key]??(w.kind==="secret"?"":w.value??""),onChange:pe=>l(U=>({...U,[w.key]:pe.target.value})),style:{width:300}})]})},w.key)}),e.jsx("div",{style:{display:"flex",gap:8,marginTop:12},children:e.jsx(j,{size:"sm",leftIcon:"save",onClick:oe,children:"Simpan kredensial"})})]}):e.jsx(V,{kind:"loading",compact:!0,title:"Memuat kredensial…"})]}),e.jsxs(C,{eyebrow:"uji",title:"Uji koneksi & hapus",actions:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"refresh-cw",onClick:ze,children:"Refresh"}),children:[e.jsx(v,{title:"Test Connection",desc:"Mengirim satu pesan percobaan ke chat tujuan. Batas 10 detik — tak pernah menggantung.",children:e.jsx(j,{size:"sm",leftIcon:"send",disabled:S==="sending",onClick:q,children:"Test Connection"})}),S&&S!=="sending"&&e.jsxs("div",{style:{marginTop:10,display:"grid",gap:8},children:[S.ok?e.jsxs(ue,{tone:"ok",children:["Berhasil — bot @",S.botUsername??"?"," mengirim ke chat ",S.chatId,"."]}):e.jsx(ue,{tone:"err",children:S.error}),(qe=S.inbound)!=null&&qe.ok?e.jsx(ue,{tone:"ok",children:"Jalur masuk siap — gateway sedang long polling dan AgentToken-nya sah."}):e.jsxs(ue,{tone:"warn",children:["Jalur masuk BELUM siap: ",((Xe=S.inbound)==null?void 0:Xe.reason)??"status tak terbaca.",!!((Qe=S.inbound)!=null&&Qe.missingCapabilities.length)&&e.jsxs(e.Fragment,{children:[" Capability yang kurang: ",e.jsx("code",{children:S.inbound.missingCapabilities.join(", ")}),"."]})," ","Selama ini merah, pesan Telegram tidak akan pernah tertangkap."]})]}),e.jsx(v,{title:"Hapus kredensial",last:!0,desc:"Menghapus keempat nilai dari database. Bila .env lama masih terisi, nilainya kembali dipakai.",children:e.jsx(j,{size:"sm",variant:"danger",leftIcon:"trash-2",onClick:()=>$e(!0),children:"Hapus kredensial"})}),e.jsx(ga,{open:N,title:"Hapus kredensial Telegram?",message:"Gateway berhenti kecuali nilai .env lama masih tersedia.",confirmLabel:"Hapus",onConfirm:Se,onCancel:()=>$e(!1)})]}),e.jsxs(C,{eyebrow:"gateway",title:"Gateway Telegram",actions:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"refresh-cw",onClick:ae,children:"Refresh"}),children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:"Satu private chat yang diizinkan terikat ke satu session operator Hanoman persisten. Bahasa natural tetap antarmuka utama; command hanya shortcut ke session yang sama."}),e.jsx(v,{title:"Gateway aktif",desc:"Menyalakan long polling in-process seketika. Mematikan tidak membunuh session tmux atau memory.",children:e.jsx(R,{label:"Gateway aktif",checked:A.enabled,onChange:w=>{D({...t,telegram:{...A,enabled:w}},`Gateway Telegram · ${w?"aktif":"nonaktif"}`)}})}),e.jsx(v,{title:"Kirim progress ringkas",desc:"Hanya progress eksplisit dan fakta status Hanoman; layar PTY/reasoning tidak pernah diteruskan.",children:e.jsx(R,{label:"Kirim progress ringkas",checked:A.progress,onChange:w=>{D({...t,telegram:{...A,progress:w}},`Progress Telegram · ${w?"aktif":"nonaktif"}`)}})}),x?e.jsx(V,{kind:"error",compact:!0,title:"Gagal membaca status Telegram",action:ae}):E?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:`Readiness · ${B}`,desc:E.running?"Long poll aktif.":E.lastError??"Gateway belum polling.",children:e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12},children:E.botUsername?`@${E.botUsername}`:"bot belum terverifikasi"})}),e.jsx(v,{title:"Allowlist",last:!E.missingCapabilities.length,desc:`${E.allowlistCount} Telegram numeric user id diizinkan.`,children:e.jsx("span",{children:E.configured?"kredensial lengkap":"kredensial belum lengkap"})}),E.missingCapabilities.length>0&&e.jsx(v,{title:"Capability kurang",last:!0,desc:E.missingCapabilities.join(", ")})]}):e.jsx(V,{kind:"loading",compact:!0,title:"Memuat status Telegram…"}),e.jsxs("div",{style:{marginTop:14,fontSize:12.5,color:"var(--text-muted)",lineHeight:1.7},children:[e.jsx("b",{children:"Onboarding"}),e.jsxs("ol",{style:{margin:"8px 0 0",paddingLeft:20},children:[e.jsx("li",{children:"Buat satu bot private-chat lewat BotFather, salin token-nya."}),e.jsx("li",{children:"Di Akses AI Agent, aktifkan master switch dan buat AgentToken dengan capability yang ditampilkan status."}),e.jsx("li",{children:"Isi keempat field di kartu Kredensial lalu Simpan."}),e.jsx("li",{children:"Tekan Test Connection sampai hijau."}),e.jsxs("li",{children:["Nyalakan gateway di atas dan kirim ",e.jsx("code",{children:"/status"})," dari Telegram."]})]})]})]})]})}if(u==="umum")return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"general",title:"Umum",children:[e.jsx(v,{title:"Full-auto sebagai default",desc:"Run baru jalan sendiri sampai selesai. Manusia tetap bisa steer / interupsi kapan pun.",children:e.jsx(R,{checked:t.autoDefault,onChange:de("autoDefault","Full-auto default")})}),e.jsx(v,{title:"Auto-scaffold doc index",last:!0,desc:"Project from-scratch otomatis di-scaffold doc index-nya setelah objective terkunci.",children:e.jsx(R,{checked:t.autoScaffold,onChange:de("autoScaffold","Auto-scaffold")})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"4px 2px",color:"var(--text-subtle)",fontSize:12,fontFamily:"var(--font-mono)"},children:[e.jsx("span",{children:"hanoman · nafanesia.id"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"rotate-ccw",onClick:()=>D(JSON.parse(JSON.stringify(Wt)),"Pengaturan dikembalikan ke default","warn","rotate-ccw"),children:"Reset ke default"})]})]});if(u==="orkestrasi")return e.jsx($t,{orchestration:t.orchestration,onChange:(A,B)=>H({orchestration:A},B)});if(u==="model"){const A=n=>{var P;const g=(K==null?void 0:K.version)??null;return pt(n,g)?e.jsxs("div",{"data-testid":"codex-version-note",style:{fontSize:12,lineHeight:1.5,marginBottom:10,padding:"8px 10px",borderRadius:8,background:"var(--warn-bg, #fdf6e3)",color:"var(--text-muted)"},children:["Codex CLI terpasang ",e.jsx("b",{children:g}),", sedangkan ",e.jsx("b",{children:n})," butuh ",e.jsx("b",{children:(P=bt(n))==null?void 0:P.minClient}),". Sesi tetap boleh dijalankan, tapi modelnya belum tentu dikenali CLI ini. Perbarui dengan ",e.jsx("code",{children:"npm i -g @openai/codex@latest"}),"."]}):null},B=n=>Ge.some(g=>g.id===n)?Ge.map(g=>({value:g.id,label:g.label})):[{value:n,label:n},...Ge.map(g=>({value:g.id,label:g.label}))],_=t.conflict??ja,oe=(n,g)=>H({conflict:{..._,...n}},g),q=Be==="codex"?{agent:"codex",model:X.model,effort:X.effort}:{agent:"claude",model:t.model,effort:t.effort},Se=t.lead??_e,w=Se.engine??_e.engine,Z=async(n,g)=>{const P=Se;s({...t,lead:{...Se,engine:{...w,...n}}});try{const re=await y.getLeadConfig(),Ie=await y.putLeadConfig({...re,engine:{...re.engine??_e.engine,...n}});s(ke=>ke&&{...ke,lead:Ie}),a==null||a(g,"ok","check-circle-2")}catch{s(re=>re&&{...re,lead:P}),a==null||a("Gagal menyimpan setelan lead","err","alert-triangle")}},we=t.telegram??ye,W=we.engine??ye.engine,pe=async(n,g)=>{const P=t;s({...t,telegram:{...we,engine:{...W,...n}}});try{const re=await y.getSettings(),Ie=re.telegram??ye,ke={...re,telegram:{...Ie,engine:{...Ie.engine??ye.engine,...n}}},Sa=await y.putSettings(ke);s(Sa??ke),a==null||a(g,"ok","check-circle-2")}catch{s(P),a==null||a("Gagal menyimpan setelan operator Telegram","err","alert-triangle")}},U=t.changelog??fa,Pe=(n,g)=>H({changelog:{...U,...n}},g),Q=t.portalChat??xa,be=(n,g)=>H({portalChat:{...Q,...n}},g),We=(n,g)=>{const P=Math.floor(Number(n));return Number.isFinite(P)&&P>=0?P:g};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"agen",title:"Agen sesi",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:"Mesin yang menjalankan sesi baru. Perilaku sesi identik — worktree terisolasi, fase, stage, review, integrate. Yang berbeda hanya CLI-nya, dan karenanya katalog model/effort-nya. Indikator limit hanya membaca kuota Anthropic, jadi sesi codex tak muncul di sana."}),e.jsx(v,{title:"Agen default",last:!0,desc:"Sesi backlog masih bisa memilih agen lain saat Start.",children:e.jsx(L,{size:"sm","aria-label":"Agen default",value:Be,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>H({agent:n.target.value},"Agen → "+n.target.value)})})]}),e.jsxs(C,{eyebrow:"model",title:"Model sesi — default global",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Default untuk sesi baru; bisa di-override per sesi saat ",e.jsx("b",{children:"Start"}),". Di terminal, ",e.jsx("code",{children:"/model"}),"mengubahnya kapan saja. Dengan orkestrasi aktif, model ini menjadi model ",e.jsx("b",{children:"orchestrator"}),"; model & effort tiap fase diatur di ",e.jsx("b",{children:"tab Orkestrasi"}),". Yang benar-benar dipakai adalah blok milik agen terpilih di atas — yang satunya tersimpan, menunggu giliran."]}),e.jsxs("div",{"data-testid":"agent-group-claude",children:[e.jsxs("div",{style:{padding:"8px 0",color:"var(--text-muted)",fontSize:12},children:["Katalog model diperiksa otomatis setiap 5 menit.",Object.entries(d.providers).map(([n,g])=>e.jsxs("div",{children:[n,": ",g.source==="bundled"?"daftar bawaan":g.source==="cache"?"cache terakhir":"dari CLI",g.checkedAt?" · diperiksa "+new Date(g.checkedAt).toLocaleTimeString():"",g.error?" · "+g.error:""]},n))]}),e.jsx(ca,{id:"claude",label:T.claude,active:Be==="claude"}),e.jsx(v,{title:"Model",desc:"Diteruskan apa adanya ke `claude --model`.",children:e.jsx(L,{size:"sm","aria-label":"Model claude",value:t.model,options:b,style:{width:190},onChange:n=>H({model:n.target.value,...je(n.target.value,t.effort)},"Model claude → "+n.target.value)})}),e.jsx(v,{title:"Effort",last:!0,desc:"Anggaran berpikir per giliran (`claude --effort`).",children:e.jsx(L,{size:"sm","aria-label":"Effort claude",value:t.effort,options:fe(t.model),style:{width:130},onChange:n=>H({effort:n.target.value},"Effort claude → "+n.target.value)})})]}),e.jsxs("div",{"data-testid":"agent-group-codex",style:{borderTop:"1px solid var(--border-hair)",marginTop:6},children:[e.jsx(ca,{id:"codex",label:T.codex,active:Be==="codex"}),A(X.model),e.jsx(v,{title:"Model",desc:"Diteruskan apa adanya ke `codex -m`.",children:e.jsx(L,{size:"sm","aria-label":"Model codex",value:X.model,style:{width:190},options:B(X.model),onChange:n=>{const g=n.target.value;H({codex:{model:g,effort:te(g,X.effort)}},"Model codex → "+g)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Diteruskan ke `codex -c model_reasoning_effort`.",children:e.jsx(L,{size:"sm","aria-label":"Effort codex",value:X.effort,style:{width:130},options:Ce(X.model).map(n=>({value:n,label:n})),onChange:n=>H({codex:{...X,effort:n.target.value}},"Effort codex → "+n.target.value)})})]})]}),e.jsxs(C,{eyebrow:"konflik",title:"Konflik rebase & merge",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:"Saat rebase/merge berkonflik, hanoman menyerahkan worktree-nya ke satu sesi agen untuk dibereskan. Pekerjaannya sempit dan tak berfase, jadi ia boleh memakai model & effort yang berbeda dari sesi kerja. Berlaku untuk ketiga pintu integrasi: backlog, git graph, dan PRD."}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = sesi konflik memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen konflik",checked:_.enabled,onChange:n=>oe({enabled:n},"Setelan konflik"+(n?" · aktif":" · ikut default global"))})}),_.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Agen",desc:"Mesin yang membereskan konflik. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Agen konflik",value:_.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const g=n.target.value,P=g==="codex"?X:{model:t.model,effort:t.effort};oe({agent:g,model:P.model,effort:g==="codex"?te(P.model,P.effort):P.effort},"Agen konflik → "+g)}})}),_.agent==="codex"&&A(_.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model konflik",value:_.model,style:{width:190},options:_.agent==="codex"?B(_.model):b,onChange:n=>{const g=n.target.value;oe({model:g,..._.agent==="codex"?{effort:te(g,_.effort)}:je(g,_.effort)},"Model konflik → "+g)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Konflik biasanya mekanis — effort rendah sering cukup.",children:e.jsx(L,{size:"sm","aria-label":"Effort konflik",value:_.effort,style:{width:130},options:_.agent==="codex"?Ce(_.model).map(n=>({value:n,label:n})):fe(_.model),onChange:n=>oe({effort:n.target.value},"Effort konflik → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"conflict-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["Sesi konflik memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"lead",title:"Agen hanoman-lead",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Mesin yang menjalankan agen pemimpin — panggilan sekali-jalan non-interaktif yang membaca docs, plan, kode, dan riwayat git sebelum memutuskan. Berlaku untuk ketiga pintu lead (kontrak, deteksi otomatis, denyut) dan dipakai putusan berikutnya, tanpa restart. Rem darurat, denyut, dan opt-in per project tetap diurus di layar ",e.jsx("b",{children:"Lead"}),"."]}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = lead memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen lead",checked:w.enabled,onChange:n=>Z({enabled:n},"Setelan lead"+(n?" · aktif":" · ikut default global"))})}),w.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Runtime",desc:"Mesin yang menjalankan lead. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Runtime lead",value:w.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const g=n.target.value,P=g==="codex"?X:{model:t.model,effort:t.effort};Z({agent:g,model:P.model,effort:g==="codex"?te(P.model,P.effort):P.effort},"Runtime lead → "+g)}})}),w.agent==="codex"&&A(w.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model lead",value:w.model,style:{width:190},options:w.agent==="codex"?B(w.model):b,onChange:n=>{const g=n.target.value;Z({model:g,...w.agent==="codex"?{effort:te(g,w.effort)}:je(g,w.effort)},"Model lead → "+g)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Putusan lead menuntut membaca bukti — SoT, ADR, plan, kode, riwayat git. Effort rendah memangkas kedalamannya.",children:e.jsx(L,{size:"sm","aria-label":"Effort lead",value:w.effort,style:{width:130},options:w.agent==="codex"?Ce(w.model).map(n=>({value:n,label:n})):fe(w.model),onChange:n=>Z({effort:n.target.value},"Effort lead → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"lead-engine-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["hanoman-lead memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"telegram",title:"Agen operator Telegram",children:[e.jsxs("div",{"data-testid":"telegram-engine-desc",style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Mesin yang menjalankan sesi operator Telegram — satu sesi persisten per chat, yang membaca API hanoman lalu merangkum. Berlaku untuk sesi operator ",e.jsx("b",{children:"berikutnya"})," yang dibuat; sesi yang sedang jalan tetap memakai setelan lamanya (satu proses, satu model seumur hidup) dan tidak di-restart diam-diam — tutup dari chat dengan ",e.jsx("code",{children:"/engine restart"}),". Setelan yang sama juga bisa diubah dari chat: ",e.jsx("code",{children:"/engine"}),", ",e.jsx("code",{children:"/runtime"}),","," ",e.jsx("code",{children:"/model"}),", ",e.jsx("code",{children:"/effort"}),". Berlaku global untuk semua chat."]}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = sesi operator Telegram memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen Telegram",checked:W.enabled,onChange:n=>pe({enabled:n},"Setelan operator Telegram"+(n?" · aktif":" · ikut default global"))})}),W.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Runtime",desc:"Mesin yang menjalankan sesi operator. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Runtime Telegram",value:W.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const g=n.target.value,P=g==="codex"?X:{model:t.model,effort:t.effort};pe({agent:g,model:P.model,effort:g==="codex"?te(P.model,P.effort):P.effort},"Runtime operator Telegram → "+g)}})}),W.agent==="codex"&&A(W.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model Telegram",value:W.model,style:{width:190},options:W.agent==="codex"?B(W.model):b,onChange:n=>{const g=n.target.value;pe({model:g,...W.agent==="codex"?{effort:te(g,W.effort)}:je(g,W.effort)},"Model operator Telegram → "+g)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Operator Telegram jarang menulis kode — effort rendah memangkas latensi balasan secara langsung.",children:e.jsx(L,{size:"sm","aria-label":"Effort Telegram",value:W.effort,style:{width:130},options:W.agent==="codex"?Ce(W.model).map(n=>({value:n,label:n})):fe(W.model),onChange:n=>pe({effort:n.target.value},"Effort operator Telegram → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"telegram-engine-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["Sesi operator Telegram memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"changelog",title:"Agen changelog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Mesin yang menulis narasi changelog per project — panggilan sekali-jalan non-interaktif yang merangkum backlog selesai, rentang commit, atau isi sebuah rilis menjadi teks pendek berorientasi pemakai. Berlaku pada pembangkitan ",e.jsx("b",{children:"berikutnya"}),", tanpa restart. Agen yang gagal tak menggagalkan changelog: barisnya tetap lahir sebagai draf ringkas ber-catatan."]}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = pembuat changelog memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen changelog",checked:U.enabled,onChange:n=>Pe({enabled:n},"Setelan changelog"+(n?" · aktif":" · ikut default global"))})}),U.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Runtime",desc:"Mesin yang menulis changelog. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Runtime changelog",value:U.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const g=n.target.value,P=g==="codex"?X:{model:t.model,effort:t.effort};Pe({agent:g,model:P.model,effort:g==="codex"?te(P.model,P.effort):P.effort},"Runtime changelog → "+g)}})}),U.agent==="codex"&&A(U.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model changelog",value:U.model,style:{width:190},options:U.agent==="codex"?B(U.model):b,onChange:n=>{const g=n.target.value;Pe({model:g,...U.agent==="codex"?{effort:te(g,U.effort)}:je(g,U.effort)},"Model changelog → "+g)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Merangkum judul jadi prosa pendek — effort rendah biasanya cukup dan memangkas ongkos setiap pembangkitan.",children:e.jsx(L,{size:"sm","aria-label":"Effort changelog",value:U.effort,style:{width:130},options:U.agent==="codex"?Ce(U.model).map(n=>({value:n,label:n})):fe(U.model),onChange:n=>Pe({effort:n.target.value},"Effort changelog → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"changelog-engine-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["Pembuat changelog memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"portal",title:"Obrolan portal klien",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Permukaan obrolan di portal klien: klien memilih ",e.jsx("b",{children:"Brainstorming"})," (digali sampai jelas, keluarannya PRD draft untuk Anda review) atau ",e.jsx("b",{children:"Bertanya"})," (dijawab langsung dari dokumen project). Jatah berlaku ",e.jsx("b",{children:"per project"})," dan dihitung bulanan; brainstorming dan pertanyaan punya jatah masing-masing. Mati = tab Obrolan tak muncul di portal."]}),e.jsx(v,{title:"Aktifkan obrolan",desc:"Mati = klien hanya punya Pekerjaan & Help desk, persis seperti sebelumnya.",children:e.jsx(R,{"aria-label":"Aktifkan obrolan portal",checked:Q.enabled,onChange:n=>be({enabled:n},"Obrolan portal"+(n?" · aktif":" · mati"))})}),Q.enabled&&e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Jatah brainstorming",desc:"Berapa sesi brainstorming per project tiap bulan. 0 = tertutup.",children:e.jsx(Y,{"aria-label":"Jatah brainstorming",type:"number",min:0,max:1e3,placeholder:"mis. 3",style:{width:110},defaultValue:Q.brainstormPerMonth,onBlur:n=>be({brainstormPerMonth:We(n.target.value,Q.brainstormPerMonth)},"Jatah brainstorming → "+n.target.value)})}),e.jsx(v,{title:"Jatah pertanyaan",desc:"Berapa sesi tanya-jawab per project tiap bulan. 0 = tertutup.",children:e.jsx(Y,{"aria-label":"Jatah pertanyaan",type:"number",min:0,max:1e4,placeholder:"mis. 30",style:{width:110},defaultValue:Q.askPerMonth,onBlur:n=>be({askPerMonth:We(n.target.value,Q.askPerMonth)},"Jatah pertanyaan → "+n.target.value)})}),e.jsx(v,{title:"Model",desc:"Mesin obrolan selalu Claude — gerbang tool yang menjaganya tak ada di runtime lain.",children:e.jsx(L,{size:"sm","aria-label":"Model obrolan portal",value:Q.model,style:{width:190},options:b,onChange:n=>be({model:n.target.value,...je(n.target.value,Q.effort)},"Model obrolan portal → "+n.target.value)})}),e.jsx(v,{title:"Effort",children:e.jsx(L,{size:"sm","aria-label":"Effort obrolan portal",value:Q.effort,style:{width:130},options:fe(Q.model),onChange:n=>be({effort:n.target.value},"Effort obrolan portal → "+n.target.value)})}),e.jsx(v,{title:"Batas waktu satu jawaban",last:!0,desc:"Detik. Lewat dari ini klien menerima kalimat 'coba lagi sebentar', bukan layar menggantung.",children:e.jsx(Y,{"aria-label":"Batas waktu obrolan portal",type:"number",min:10,max:900,placeholder:"mis. 120",style:{width:110},defaultValue:Q.timeoutSec,onBlur:n=>be({timeoutSec:We(n.target.value,Q.timeoutSec)},"Batas waktu obrolan → "+n.target.value)})})]})]})]})}return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"sesi",title:"Sesi & notifikasi",children:[e.jsx(v,{title:"Notifikasi backlog selesai",desc:"Toast + sound saat sebuah backlog mencapai stage done. Daftar lonceng tetap terisi meski dimatikan.",children:e.jsx(R,{checked:t.notifyDone,onChange:de("notifyDone","Notifikasi backlog selesai")})}),e.jsx(v,{title:"Sound notifikasi",desc:"Durasi nada saat backlog selesai.",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(L,{size:"sm",value:t.notifySound,options:oa,style:{width:160},onChange:A=>H({notifySound:A.target.value},"Sound → "+A.target.value)}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"volume-2",disabled:t.notifySound==="off",onClick:()=>ea(t.notifySound),children:"Preview"})]})}),e.jsx(v,{title:"Notifikasi butuh keputusan",desc:"Toast + sound saat sesi Claude berhenti menunggu keputusanmu. Nada sengaja beda dari selesai.",children:e.jsx(R,{checked:t.notifyDecision,onChange:de("notifyDecision","Notifikasi keputusan")})}),e.jsx(v,{title:"Sound keputusan",desc:"Nada saat sebuah sesi menunggu keputusan.",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(L,{size:"sm",value:t.notifyDecisionSound,options:oa,style:{width:160},onChange:A=>H({notifyDecisionSound:A.target.value},"Sound keputusan → "+A.target.value)}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"volume-2",disabled:t.notifyDecisionSound==="off",onClick:()=>ea(t.notifyDecisionSound),children:"Preview"})]})}),e.jsx(v,{title:"Notifikasi saat sesi gagal",last:!0,desc:"Kirim notifikasi ketika sesi Claude Code berakhir dengan error.",children:e.jsx(R,{checked:t.notifyFail,onChange:de("notifyFail","Notifikasi gagal")})})]}),e.jsxs(C,{eyebrow:"goal",title:"Mode goal — sesi backlog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Sesi backlog lahir dengan gate ",e.jsx("code",{children:"Stop"}),": ia menolak berhenti sampai kondisinya terbukti di transkrip. Interupsi manusia (",e.jsx("code",{children:"Esc"}),") tetap bekerja; melepas gate sepenuhnya = hentikan sesinya. Sesi scheduler mengikuti setelan ini."]}),e.jsx(v,{title:"Aktif sebagai default",desc:"Sesi backlog baru lahir dengan mode goal. Masih bisa dimatikan per sesi saat Start.",children:e.jsx(R,{"aria-label":"Mode goal default",checked:t.goal.enabled,onChange:A=>H({goal:{...t.goal,enabled:A}},"Mode goal"+(A?" · aktif":" · nonaktif"))})}),e.jsx(v,{title:"Kondisi (template global)",last:!0,desc:"Kosong = kondisi bawaan hanoman: semua fase tercatat di phase file, plan tak menyisakan task, push sukses.",children:e.jsx("div",{style:{width:320},children:e.jsx(ht,{value:t.goal.condition,rows:4,mono:!0,"aria-label":"Kondisi mode goal",placeholder:"Kosong = kondisi bawaan hanoman · mis. semua fase tercatat & plan tanpa - [ ]",onChange:A=>D({...t,goal:{...t.goal,condition:A.target.value}})})})})]}),e.jsxs(C,{eyebrow:"verifikasi",title:"Scope verifikasi — sesi backlog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Beberapa sesi berjalan bersamaan di mesin ini. ",e.jsx("b",{children:"Hanya yang berubah"})," menyuruh sesi menguji berkas yang benar-benar ia sentuh (",e.jsx("code",{children:"vitest --changed"}),", typecheck per paket, lint per berkas) alih-alih seluruh project — RAM & CPU tetap tersisa untuk sesi lain. Suite penuh, lint penuh, dan build penuh tetap dijalankan manusia sebelum merge."]}),e.jsx(v,{title:"Scope default",last:!0,desc:"Sesi backlog baru lahir dengan scope ini. Masih bisa diubah per sesi saat Start.",children:e.jsx(L,{size:"sm","aria-label":"Scope verifikasi default",value:t.verifyScope??"changed",style:{width:220},options:[{value:"changed",label:"Hanya yang berubah"},{value:"full",label:"Seluruh project"}],onChange:A=>H({verifyScope:A.target.value},"Scope verifikasi → "+A.target.value)})})]}),e.jsxs(C,{eyebrow:"metode",title:"Metode workflow — sesi backlog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Metode menentukan ",e.jsx("b",{children:"skill mana yang dimuat di tiap fase"})," dan ",e.jsx("b",{children:"di direktori mana plan & spec ditulis"}),". Fase-fasenya sendiri tak berubah. Gerbang plan memindai direktori SEMUA metode, jadi item yang berpindah metode tak pernah lolos lewat direktori kosong."]}),e.jsx(v,{title:"Metode default",last:!0,desc:"Sesi backlog baru lahir dengan metode ini. Masih bisa diubah per sesi saat Start.",children:e.jsx(L,{size:"sm","aria-label":"Metode default",style:{width:220},value:gt(t.method).id,options:aa.map(A=>({value:A,label:ta[A].label})),onChange:A=>H({method:A.target.value},"Metode → "+A.target.value)})}),he&&e.jsxs("div",{"data-testid":"method-status",style:{marginTop:4,display:"grid",gap:10},children:[aa.map(A=>e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:600},children:ta[A].label}),he.methods.filter(B=>B.method===A).map(B=>e.jsxs("div",{"data-testid":`method-status-${B.method}-${B.agent}`,style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12,lineHeight:1.5},children:[e.jsx(ne,{tone:B.ready?"ok":"warn",children:B.ready?"siap":"belum siap"}),e.jsxs("div",{style:{flex:"1 1 auto",minWidth:0},children:[e.jsx("b",{children:T[B.agent]}),!B.ready&&e.jsxs("div",{style:{color:"var(--text-muted)",overflowWrap:"anywhere"},children:[B.missingPackages.length>0&&e.jsxs("div",{children:["paket kurang: ",e.jsx("code",{children:B.missingPackages.join(" · ")})]}),B.missingSkills.length>0&&e.jsxs("div",{children:["skill kurang: ",e.jsx("code",{children:B.missingSkills.join(" · ")})]})]})]}),!B.ready&&e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"download",disabled:!ie,onClick:()=>Oe(B),children:"Pasang"})]},B.agent))]},A)),e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:ie?e.jsxs(e.Fragment,{children:["Pemasangan berjalan di ",e.jsx("b",{children:"sesi terminal"})," project ",e.jsx("code",{children:ie})," — outputnya bisa ditonton di Terminal. hanoman sendiri tak pernah memasang apa pun."]}):e.jsx(e.Fragment,{children:"Pemasangan butuh satu project yang sudah di-bind ke checkout lokal: perintahnya dijalankan di sesi terminal project itu."})})]})]})]})}const va=u==="setup"?e.jsx(Qt,{}):u==="akun"?e.jsx(Gt,{me:i,onLoggedOut:r,onToast:a}):u==="users"?e.jsx(Ut,{me:i,onToast:a}):u==="akses-klien"?e.jsx(jt,{}):u==="perangkat"?e.jsx(Tt,{onToast:a}):u==="kendali-jarak-jauh"?e.jsx(St,{onToast:a}):u==="agent"?e.jsx(Xt,{onToast:a}):u==="custom-agent"?e.jsxs(C,{eyebrow:"agen",title:"Custom agent — global",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Persona yang tersedia untuk ",e.jsx("b",{children:"setiap sesi baru"})," di semua project. Sesi ",e.jsx("b",{children:"claude"}),"dan ",e.jsx("b",{children:"codex"})," menerima child native dengan konteks terpisah. Agen boleh saling memanggil lewat ",e.jsx("i",{children:"Mention"}),", dan grafnya wajib asiklik — agen tanpa mention tak diberi alat delegasi sama sekali."]}),e.jsx(tt,{projectId:null,runtime:t==null?void 0:t.agent,onToast:a})]}):u==="aktivitas"?e.jsx(Kt,{onToast:a}):u==="konfigurasi"?e.jsx(Vt,{onToast:a}):u==="webhook"?F?e.jsx(It,{onBack:()=>$(!1)}):e.jsx(Et,{onToast:a,onOpenDocs:()=>$(!0)}):ya();return e.jsxs("div",{className:"hn-settings-layout","data-layout":k,style:{display:"grid",gridTemplateColumns:z?"minmax(0, 1fr)":k==="tablet"?"160px minmax(0, 1fr)":"196px minmax(0, 1fr)",gap:k==="tablet"?16:24,alignItems:"start",maxWidth:920},children:[z?e.jsx(L,{"aria-label":"Bagian pengaturan",value:u,onChange:D=>c(D.target.value),options:ha.map(D=>({value:D.key,label:D.label}))}):e.jsx("nav",{"aria-label":"Navigasi pengaturan",style:{display:"flex",flexDirection:"column",gap:2,position:"sticky",top:0},children:ha.map(D=>{const H=D.key===u;return e.jsxs("button",{"aria-current":H?"page":void 0,onClick:()=>c(D.key),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"9px 12px",border:"none",cursor:"pointer",textAlign:"left",borderRadius:"var(--radius-sm)",background:H?"var(--brass-100)":"transparent",color:H?"var(--brass-700)":"var(--text-muted)",fontWeight:H?600:500,fontFamily:"var(--font-ui)",fontSize:13.5},children:[e.jsx(Ne,{name:D.icon,size:16,color:H?"var(--brass-700)":"var(--text-subtle)"}),D.label]},D.key)})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:20,minWidth:0},children:va})]})}export{Xt as AgentAccessPanel,Tt as DeviceTokensPanel,ln as SettingsScreen};
62
+ claude mcp add hanoman --env HANOMAN_HOST=${i} --env HANOMAN_AGENT_TOKEN=hnm_agt_… -- hanoman mcp${d?" "+d:""}`:a==="cursor"?t.replace('"mcpServers"','"servers"'):t}const Dt={margin:0,padding:12,fontSize:12,lineHeight:1.5,overflowX:"auto",background:"var(--bone-100)",border:"1px solid var(--ink-200)",borderRadius:"var(--radius-sm)",whiteSpace:"pre"},Ae={fontSize:12.5,color:"var(--text-muted)",lineHeight:1.55,marginBottom:10},xe={padding:"6px 10px 6px 0",borderBottom:"1px solid var(--ink-100)",verticalAlign:"top",fontSize:12.5};function Ht(){const[a,i]=o.useState("claude-code"),[r,d]=o.useState("default"),[b,t]=o.useState(!1),s=typeof window>"u"?"http://localhost:8787":window.location.origin,g=Lt(a,s,r),f=sa.find(c=>c.id===a),u=()=>{var c;(c=navigator.clipboard)==null||c.writeText(g).then(()=>{t(!0),setTimeout(()=>t(!1),1500)},()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"mcp",title:"MCP server",children:[e.jsxs("div",{style:Ae,children:["Agen AI mana pun yang berbicara MCP bisa memakai hanoman lewat ",e.jsx("code",{children:"hanoman mcp"})," — tanpa pembungkus khusus per-klien. Ia memakai ",e.jsx("b",{children:"agent token yang sama"})," dengan REST dan capability yang sama; buat tokennya di kartu di atas, lalu tempel di konfigurasi klien."," ",e.jsxs("b",{children:["Skema tool versi ",ft,"."]})]}),e.jsxs("div",{style:Ae,children:["Prasyarat: ",e.jsx("code",{children:"npm i -g hanoman"})," di mesin tempat klien AI-nya jalan. Host di bawah diisi otomatis dengan instance ini — ",e.jsx("b",{children:"agent token diterbitkan per-instance"}),", jadi token dari instance lain akan selalu ditolak 401 di sini."]}),e.jsxs("div",{style:Ae,children:["Tool berbahaya — membuka sesi agen di worktree, perintah VPS, merge/rebase, penghapusan backlog, perubahan stage — ",e.jsx("b",{children:"hanya muncul"})," pada tingkat ",e.jsx("code",{children:"--danger"}),". Tingkat itu ",e.jsx("b",{children:"bukan kontrol keamanan"}),": ia menentukan tool mana yang terlihat, sementara yang menahan sungguhan adalah capability berlabel ",e.jsx("b",{children:"berbahaya"})," yang kamu centang di kartu di atas. Sebuah tool bisa terlihat dan tetap menjawab 403."]}),e.jsxs("div",{role:"group","aria-label":"Klien MCP",style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:10},children:[sa.map(c=>e.jsx(j,{size:"sm",variant:c.id===a?"primary":"ghost",onClick:()=>i(c.id),children:c.label},c.id)),e.jsx(j,{size:"sm",variant:r==="read-only"?"primary":"ghost",leftIcon:"eye",onClick:()=>d(c=>c==="read-only"?"default":"read-only"),children:"Mode baca-saja"}),e.jsx(j,{size:"sm",variant:r==="danger"?"primary":"ghost",leftIcon:"alert-triangle",onClick:()=>d(c=>c==="danger"?"default":"danger"),children:"Tampilkan tool berbahaya"})]}),e.jsx("div",{style:{...Ae,marginBottom:8},children:f.hint}),e.jsx("pre",{"data-testid":"mcp-snippet",style:Dt,children:g}),e.jsx("div",{style:{marginTop:10},children:e.jsx(j,{size:"sm",leftIcon:"copy",onClick:u,children:b?"Tersalin":"Salin"})})]}),e.jsxs(C,{eyebrow:"tool",title:"Tool yang tersedia",children:[e.jsxs("div",{style:Ae,children:["Centang capability di bawah pada token yang dipakai. Mode baca-saja menyembunyikan seluruh tool bertanda ",e.jsx("i",{children:"tulis"}),"."]}),e.jsx("div",{className:"hn-local-overflow",style:{overflowX:"auto"},children:e.jsxs("table",{"data-testid":"mcp-tools",style:{borderCollapse:"collapse",width:"100%"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...xe,textAlign:"left",fontSize:11.5,color:"var(--text-subtle)"},children:"Tool"}),e.jsx("th",{style:{...xe,textAlign:"left",fontSize:11.5,color:"var(--text-subtle)"},children:"Mode"}),e.jsx("th",{style:{...xe,textAlign:"left",fontSize:11.5,color:"var(--text-subtle)"},children:"Capability"})]})}),e.jsx("tbody",{children:xt.map(c=>e.jsxs("tr",{children:[e.jsxs("td",{style:xe,children:[e.jsx("code",{children:c.name}),e.jsx("div",{style:{fontSize:11.5,color:"var(--text-subtle)"},children:c.title})]}),e.jsx("td",{style:xe,children:c.mode==="read"?"baca":"tulis"}),e.jsx("td",{style:xe,children:c.capability?e.jsx("code",{children:c.capability}):e.jsx("span",{style:{color:"var(--text-subtle)"},children:"—"})})]},c.name))})]})})]})]})}const _t="https://github.com/denameidina/hanoman/blob/main/docs/agent-integration.md";function Nt({onToast:a}){const[i,r]=o.useState(null),[d,b]=o.useState(!1),[t,s]=o.useState(!1),[g,f]=o.useState(!1),u=`${window.location.origin}${Ka.agentDoc}`;async function c(){if(!g){if(i){b(!0);return}f(!0),s(!1);try{r(await y.agentDoc()),b(!0)}catch{s(!0)}finally{f(!1)}}}return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"dokumentasi",title:"Dokumentasi AI Agent",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Satu halaman yang membuat agen mana pun bisa langsung bekerja — cukup berikan"," ",e.jsx("b",{children:"tautan ini + satu agent token"}),". Markdown mentah, bisa diambil agen lewat HTTP biasa, ",e.jsx("b",{children:"tanpa auth"}),"."]}),e.jsx("code",{style:{display:"block",wordBreak:"break-all",fontSize:12,marginBottom:10},children:u}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsx(j,{size:"sm",leftIcon:"copy",onClick:()=>{var k;(k=navigator.clipboard)==null||k.writeText(u),a==null||a("Tautan disalin","ok","copy")},children:"Salin tautan"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"book-open",disabled:g,onClick:()=>void c(),children:g?"Memuat…":"Buka"}),e.jsx("a",{href:_t,target:"_blank",rel:"noreferrer",children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"external-link",children:"Lihat di GitHub"})})]}),t&&e.jsx("div",{style:{marginTop:12},children:e.jsx(V,{kind:"error",compact:!0,title:"Gagal memuat dokumentasi",hint:u,action:()=>void c(),actionLabel:"Coba lagi"})})]}),d&&i!==null&&e.jsx(kt,{path:"agent-integration.md",text:i,eyebrow:"hanoman · panduan AI agent",onClose:()=>b(!1)})]})}const ra={feature:"Brief (feature)",qa:"QA",scaffold:"Scaffold",reverse:"Reverse docs",prd:"PRD",audit:"Audit",breakdown:"Breakdown PRD",goal:"Goal",no_effort:"No effort"},da=[{id:"claude",label:"Claude Code"},{id:"codex",label:"Codex CLI"}],Rt={model:null,effort:null},Le={padding:"6px 8px",borderTop:"1px solid var(--border-hair)",verticalAlign:"top"};function Ft({flow:a,phase:i,runtime:r,cell:d,onPick:b}){const t=qa(r),s=Ya(r,d.model??""),g=r==="codex"?te:ba,f=[{value:"",label:"— warisi orchestrator"},...d.model&&!t.some(c=>c.id===d.model)?[{value:d.model,label:d.model}]:[],...t.map(c=>({value:c.id,label:c.label}))],u=[{value:"",label:"— warisi"},...d.effort&&!s.includes(d.effort)?[{value:d.effort,label:d.effort}]:[],...s.map(c=>({value:c,label:c}))];return e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(L,{size:"sm","aria-label":`Model ${a} ${i} ${r}`,value:d.model??"",style:{minWidth:150},options:f,onChange:c=>{const k=c.target.value||null;b({model:k,effort:k&&d.effort?g(k,d.effort):d.effort},`${i} (${r}) → ${k??"warisi"}`)}}),e.jsx(L,{size:"sm","aria-label":`Effort ${a} ${i} ${r}`,value:d.effort??"",style:{minWidth:96},options:u,onChange:c=>b({...d,effort:c.target.value||null},`${i} (${r}) effort → ${c.target.value||"warisi"}`)})]})}function $t({orchestration:a,onChange:i}){const r=a??Je,d=t=>r[t]??Je[t],b=(t,s,g)=>i({...r,[t]:s},g);return e.jsxs(e.Fragment,{children:[e.jsx(C,{eyebrow:"orkestrasi",title:"Orkestrasi subagent per fase",children:e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",lineHeight:1.5},children:["Sesi utama menjadi ",e.jsx("b",{children:"orchestrator"}),"; setiap fase dikerjakan subagent dengan model & effort di bawah. ",e.jsx("b",{children:"Warisi"})," memakai model/effort orchestrator yang dipilih saat ",e.jsx("b",{children:"Start"}),". Subagent selalu berjalan di runtime orchestrator: sesi claude memakai kolom Claude Code, sesi codex kolom Codex CLI. Flow yang dimatikan berjalan sebagai sesi tunggal seperti sebelumnya."]})}),Ja.map(t=>{const s=d(t);return e.jsx("div",{"data-testid":`orch-flow-${t}`,children:e.jsxs(C,{eyebrow:"flow",title:ra[t],children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:s.enabled?"Fase dikerjakan subagent":"Sesi tunggal (orkestrasi mati)"}),e.jsx(R,{checked:s.enabled,"aria-label":`Orkestrasi ${t}`,onChange:g=>b(t,{...s,enabled:g},`Orkestrasi ${ra[t]} · ${g?"aktif":"nonaktif"}`)})]}),e.jsx("div",{style:{overflowX:"auto",opacity:s.enabled?1:.55},children:e.jsxs("table",{style:{width:"100%",minWidth:560,borderCollapse:"collapse",fontSize:12.5},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{...Le,borderTop:"none",textAlign:"left"},children:"Fase"}),da.map(g=>e.jsx("th",{style:{...Le,borderTop:"none",textAlign:"left"},children:g.label},g.id))]})}),e.jsx("tbody",{children:Va[t].map(g=>e.jsxs("tr",{children:[e.jsx("td",{style:Le,children:g}),da.map(f=>e.jsx("td",{style:Le,children:e.jsx(Ft,{flow:t,phase:g,runtime:f.id,cell:s[f.id][g]??Rt,onPick:(u,c)=>b(t,{...s,[f.id]:{...s[f.id],[g]:u}},c)})},f.id))]},g))})]})})]})},t)})]})}const fe=a=>mt(a).map(i=>({value:i,label:i==="xhigh"?"x-high":i})),je=(a,i)=>{const r=ba(a,i);return r===i?{}:{effort:r}},oa=[{value:"blip",label:"Blip · 0.1s"},{value:"pop",label:"Pop · 0.1s"},{value:"short",label:"Short · 0.15s"},{value:"ping",label:"Ping · 0.2s"},{value:"coin",label:"Coin · 0.3s"},{value:"alert",label:"Alert · 0.3s"},{value:"medium",label:"Medium · 0.4s"},{value:"chime",label:"Chime · 0.4s"},{value:"success",label:"Success · 0.4s"},{value:"bell",label:"Bell · 0.5s"},{value:"marimba",label:"Marimba · 0.6s"},{value:"long",label:"Long · 0.8s"},{value:"fanfare",label:"Fanfare · 0.9s"},{value:"off",label:"Senyap"}],Wt={model:"claude-sonnet-5",effort:"medium",autoDefault:!0,autoScaffold:!0,notifyFail:!0,notifyDone:!0,notifySound:"short",notifyDecision:!0,notifyDecisionSound:"alert",agentAccessEnabled:!1,scheduler:ut,goal:ct,agent:"claude",codex:ka,verifyScope:"changed",method:ot,conflict:ja,lead:_e,telegram:ye,changelog:fa,portalChat:xa,orchestration:Je,remoteControl:dt,logShipping:rt,logRetention:st,builtinAgents:{},builtinAgentPolicies:{},builtinRuntimeDefaults:lt},T={claude:"Claude Code",codex:"Codex CLI"};function ca({id:a,label:i,active:r}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:4},children:[e.jsx("div",{style:{fontSize:13.5,fontWeight:700,color:"var(--text-strong)"},children:i}),e.jsx("span",{"data-testid":`agent-badge-${a}`,style:{fontSize:11,fontFamily:"var(--font-mono)",padding:"2px 7px",borderRadius:999,background:r?"var(--brass-100)":"transparent",color:r?"var(--brass-700)":"var(--text-subtle)",border:r?"none":"1px solid var(--border-hair)"},children:r?"dipakai sesi baru":"tidak dipakai sekarang"})]})}function v({title:a,desc:i,children:r,last:d}){return e.jsxs("div",{className:"hn-setting-row",style:{display:"flex",alignItems:"center",gap:16,padding:"14px 0",borderBottom:d?"none":"1px solid var(--border-hair)"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)"},children:a}),i&&e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginTop:3,lineHeight:1.5},children:i})]}),e.jsx("div",{className:"hn-setting-control",style:{flex:"0 0 auto"},children:r})]})}function Gt({me:a,onLoggedOut:i,onToast:r}){const[d,b]=o.useState(""),[t,s]=o.useState(""),[g,f]=o.useState(!1),u=d.length>=1&&t.length>=8&&!g;async function c(){if(u){f(!0);try{await y.changePassword({currentPassword:d,newPassword:t}),b(""),s(""),r==null||r("Password diganti · perangkat lain ter-logout","ok","key-round")}catch(z){r==null||r(z instanceof Ve&&z.status===400?"Password lama salah":"Gagal ganti password","err","x-circle")}finally{f(!1)}}}async function k(){try{await y.logout()}finally{i()}}return e.jsxs(C,{eyebrow:"akun",title:"Akun",actions:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"log-out",onClick:k,children:"Logout"}),children:[e.jsx(v,{title:"Masuk sebagai",desc:a.email,children:e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-subtle)"},children:a.id})}),e.jsxs("div",{style:{paddingTop:14},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)",marginBottom:10},children:"Ganti password"}),e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:10,alignItems:"end"},children:[e.jsx(ee,{label:"Password lama",children:e.jsx(Y,{type:"password",autoComplete:"current-password",placeholder:"••••••••",value:d,onChange:z=>b(z.target.value),style:{width:"100%"}})}),e.jsx(ee,{label:e.jsxs(e.Fragment,{children:["Password baru ",e.jsx("span",{style:{fontWeight:400,color:"var(--text-subtle)"},children:"· min 8"})]}),children:e.jsx(Y,{type:"password",autoComplete:"new-password",placeholder:"minimal 8 karakter",value:t,onChange:z=>s(z.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",leftIcon:"key-round",disabled:!u,onClick:c,style:{marginBottom:14},children:"Ganti"})]})]})]})}function Ut({me:a,onToast:i}){const{confirm:r,dialog:d}=Fe(),[b,t]=o.useState(null),[s,g]=o.useState(""),[f,u]=o.useState(""),[c,k]=o.useState(!1),z=o.useCallback(()=>{y.listUsers().then(t).catch(()=>t([]))},[]);o.useEffect(()=>{z()},[z]);const F=/\S+@\S+\.\S+/.test(s)&&f.length>=8&&!c;async function $(){if(F){k(!0);try{await y.inviteUser({email:s,password:f}),g(""),u(""),z(),i==null||i("User "+s+" diundang","ok","user-plus")}catch(m){i==null||i(m instanceof Ve&&m.status===409?"Email sudah dipakai":"Gagal mengundang user","err","x-circle")}finally{k(!1)}}}async function E(m){try{if(!await r({title:`Hapus user "${m.email}"?`,message:"User ini kehilangan akses ke dashboard seketika.",impact:["Semua sesi login miliknya ikut dicabut.","Tindakan ini tak bisa dibatalkan."],confirmLabel:"Hapus user",run:()=>y.deleteUser(m.id)}))return;z(),i==null||i("User "+m.email+" dihapus","warn","trash-2")}catch(x){i==null||i(x instanceof Ve&&x.status===400?"Tak bisa hapus user terakhir":"Gagal hapus user","err","x-circle")}}return e.jsxs(C,{eyebrow:"users",title:"Users",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:"Undang user lain dengan menetapkan password-nya langsung — tanpa email undangan."}),b===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat users…"}):b.map((m,x)=>e.jsx(v,{title:m.email,last:x===b.length-1,desc:"dibuat "+new Date(m.createdAt).toLocaleDateString("id-ID")+(m.id===a.id?" · kamu":""),children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",disabled:b.length<=1,onClick:()=>E(m),children:"Hapus"})},m.id)),e.jsxs("div",{style:{paddingTop:14},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-strong)",marginBottom:10},children:"Invite user"}),e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:10,alignItems:"end"},children:[e.jsx(ee,{label:"Email",children:e.jsx(Y,{type:"email",value:s,placeholder:"user@nafanesia.id",onChange:m=>g(m.target.value),style:{width:"100%"}})}),e.jsx(ee,{label:e.jsxs(e.Fragment,{children:["Password ",e.jsx("span",{style:{fontWeight:400,color:"var(--text-subtle)"},children:"· min 8"})]}),children:e.jsx(Y,{type:"password",autoComplete:"new-password",placeholder:"minimal 8 karakter",value:f,onChange:m=>u(m.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",leftIcon:"user-plus",disabled:!F,onClick:$,style:{marginBottom:14},children:"Invite"})]})]}),d]})}function Tt({onToast:a}){const{confirm:i,dialog:r}=Fe(),[d,b]=o.useState(null),[t,s]=o.useState(""),[g,f]=o.useState(null),[u,c]=o.useState(!1),k=o.useCallback(()=>{y.listDeviceTokens().then(b).catch(()=>b([]))},[]);o.useEffect(()=>{k()},[k]);async function z(){if(!(t.trim().length<1||u)){c(!0);try{const E=await y.createDeviceToken({name:t.trim()});f({name:E.name,token:E.token}),s(""),k(),a==null||a("Token perangkat dibuat — salin sekarang","ok","key-round")}catch{a==null||a("Gagal membuat token","err","x-circle")}finally{c(!1)}}}async function F(E){try{if(!await i({title:`Cabut token perangkat "${E.name}"?`,message:"Perangkat itu tak bisa sync lagi sampai token baru dibuat.",confirmLabel:"Cabut token",icon:"key-round",run:()=>y.revokeDeviceToken(E.id)}))return;k(),a==null||a("Token dicabut","warn","trash-2")}catch{a==null||a("Gagal mencabut token","err","x-circle")}}const $=(d??[]).filter(E=>!E.revokedAt);return e.jsxs(C,{eyebrow:"perangkat",title:"Device tokens",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Token per-perangkat untuk menyinkronkan instance lokal ke hub (Bearer). Tempel di",e.jsx("code",{style:{margin:"0 4px"},children:"SYNC_DEVICE_TOKEN"})," pada instance client. Plaintext hanya tampil sekali."]}),g&&e.jsxs("div",{style:{padding:12,marginBottom:12,border:"1px solid var(--brass-300)",borderRadius:"var(--radius-sm)",background:"var(--brass-100)"},children:[e.jsxs("div",{style:{fontSize:12.5,fontWeight:600,marginBottom:6},children:["Token untuk “",g.name,"” — salin sekarang, tak akan ditampilkan lagi:"]}),e.jsx("code",{style:{display:"block",wordBreak:"break-all",fontSize:12},children:g.token}),e.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[e.jsx(j,{size:"sm",leftIcon:"copy",onClick:()=>{var E;(E=navigator.clipboard)==null||E.writeText(g.token),a==null||a("Disalin","ok","copy")},children:"Salin"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>f(null),children:"Tutup"})]})]}),d===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat token…"}):$.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada token perangkat."}):$.map((E,m)=>e.jsx(v,{title:E.name,last:m===$.length-1,desc:"dibuat "+new Date(E.createdAt).toLocaleDateString("id-ID")+(E.lastSeenAt?" · terlihat "+new Date(E.lastSeenAt).toLocaleString("id-ID"):" · belum dipakai"),children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:()=>F(E),children:"Cabut"})},E.id)),e.jsxs("div",{className:"hn-grid-mobile",style:{paddingTop:14,display:"grid",gridTemplateColumns:"1fr auto",gap:10,alignItems:"end"},children:[e.jsx(ee,{label:"Nama perangkat",children:e.jsx(Y,{value:t,placeholder:"laptop-dena",onChange:E=>s(E.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",leftIcon:"plus",disabled:t.trim().length<1||u,onClick:z,style:{marginBottom:14},children:"Buat token"})]}),r]})}function Kt({onToast:a}){const{confirm:i,dialog:r}=Fe(),[d,b]=o.useState(""),[t,s]=o.useState(null),g=o.useCallback(()=>{y.listSessionResults(d||void 0).then(s).catch(()=>s([]))},[d]);o.useEffect(()=>{g()},[g]);async function f(){if(!d){a==null||a("Isi project id untuk purge","warn","alert-triangle");return}try{if(!await i({title:`Purge activity log project "${d}"?`,message:"Seluruh entri hasil sesi project ini dihapus dari device ini.",impact:["Log bersifat append-only — entri yang dihapus tak bisa dipulihkan."],confirmLabel:"Purge",run:async()=>{const u=await y.purgeSessionResults(d);a==null||a(`${u.purged} entri dihapus`,"warn","trash-2")}}))return;g()}catch{a==null||a("Gagal purge","err","x-circle")}}return e.jsxs(C,{eyebrow:"aktivitas",title:"Activity log",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:"Ringkasan hasil sesi lintas device (transisi stage, commit, PR) — append-only. Filter per project."}),e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr auto",gap:10,alignItems:"end",marginBottom:12},children:[e.jsx(ee,{label:"Project id (opsional)",children:e.jsx(Y,{value:d,placeholder:"mis. hanoman — kosong = semua project",onChange:u=>b(u.target.value),style:{width:"100%"}})}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",disabled:!d,onClick:f,style:{marginBottom:14},children:"Purge"})]}),t===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat aktivitas…"}):t.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada aktivitas."}):t.map((u,c)=>e.jsx(v,{last:c===t.length-1,title:`${u.specId??u.projectId}${u.oldStage&&u.newStage?` · ${u.oldStage} → ${u.newStage}`:""}`,desc:[u.status,u.commitSha?u.commitSha.slice(0,8):null,u.branch,u.author,new Date(u.createdAt).toLocaleString("id-ID")].filter(Boolean).join(" · "),children:u.prUrl&&e.jsx("a",{href:u.prUrl,target:"_blank",rel:"noreferrer",children:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"external-link",children:"PR"})})},u.id)),r]})}const Jt={sync:"Sync",claude:"Claude",vps:"VPS",runtime:"Runtime",bootstrap:"Bootstrap (read-only)"};function Vt({onToast:a}){const[i,r]=o.useState(null),[d,b]=o.useState({}),t=o.useCallback(()=>{y.getConfig().then(r).catch(()=>r(null))},[]);if(o.useEffect(()=>{t()},[t]),!i)return e.jsx(V,{kind:"loading",title:"Memuat konfigurasi…"});const s=c=>b(k=>{const z={...k};return delete z[c],z}),g=async c=>{const k=d[c.key]??"";try{await y.putConfig(c.key,k),s(c.key),t(),a==null||a(`${c.label} disimpan`,"ok","check-circle-2")}catch{a==null||a(`Gagal menyimpan ${c.label}`,"err","x-circle")}},f=async c=>{try{await y.deleteConfig(c.key),s(c.key),t(),a==null||a(`${c.label} direset`,"warn","rotate-ccw")}catch{a==null||a("Gagal reset","err","x-circle")}},u=[...new Set(i.entries.map(c=>c.group))];return e.jsx(e.Fragment,{children:u.map(c=>e.jsxs(C,{eyebrow:c,title:Jt[c]??c,children:[c==="sync"&&e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:8},children:i.sync.running?i.sync.connected?"● Tersambung ke hub":"◐ Sync aktif, menyambung…":"○ Tidak sync (HUB murni)"}),i.entries.filter(k=>k.group===c).map(k=>e.jsx(v,{title:k.label,desc:k.help,children:e.jsx(Yt,{entry:k,draft:d[k.key],onDraft:z=>b(F=>({...F,[k.key]:z})),onSave:()=>g(k),onReset:()=>f(k)})},k.key))]},c))})}function Yt({entry:a,draft:i,onDraft:r,onSave:d,onReset:b}){var s,g;const t=e.jsxs("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono)",color:"var(--text-subtle)",marginRight:8},children:[a.source," · ",a.apply]});if(!a.editable)return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,e.jsx("code",{style:{fontSize:12},children:a.masked??a.value??"—"})]});if(a.kind==="secret")return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,a.hasValue&&i===void 0?e.jsxs(e.Fragment,{children:[e.jsx("code",{style:{fontSize:12},children:a.masked}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"pencil",onClick:()=>r(""),children:"Ganti"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:b,children:"Hapus"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{"aria-label":a.label,type:"password",placeholder:a.hasValue?"biarkan kosong = pertahankan":((s=Re(a.key))==null?void 0:s.example)??"tempel token…",value:i??"",onChange:f=>r(f.target.value),style:{width:240}}),e.jsx(j,{size:"sm",leftIcon:"save",onClick:d,children:"Simpan"})]})]});if(a.kind==="bool"){const f=(i??a.value)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,e.jsx(R,{checked:f,onChange:u=>{r(u?"1":"0")}}),i!==void 0&&e.jsx(j,{size:"sm",leftIcon:"save",onClick:d,children:"Simpan"})]})}return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t,e.jsx(Y,{"aria-label":a.label,type:a.kind==="int"?"number":"text",placeholder:(g=Re(a.key))==null?void 0:g.example,value:i??a.value??"",onChange:f=>r(f.target.value),style:{width:240}}),e.jsx(j,{size:"sm",leftIcon:"save",onClick:d,children:"Simpan"}),a.source==="db"&&e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"rotate-ccw",onClick:b,children:"Reset"})]})}const qt=[{had:"sessions:write",needs:"sessions:spawn",sentence:"dulu bisa membuka sesi baru"},{had:"ide:write",needs:"ide:git",sentence:"dulu bisa merge/rebase & menghapus branch"},{had:"backlog:write",needs:"backlog:lifecycle",sentence:"dulu bisa integrate & menghapus backlog"},{had:"vps:write",needs:"vps:exec",sentence:"dulu bisa menjalankan perintah di VPS"}];function ua(a){return qt.filter(i=>a.includes(i.had)&&!a.includes(i.needs)).map(i=>i.sentence)}function De({ids:a,picked:i,onToggle:r,ariaLabel:d,label:b}){const t=o.useRef(null),s=a.filter(f=>i.includes(f)).length,g=a.length>0&&s===a.length;return o.useEffect(()=>{t.current&&(t.current.indeterminate=s>0&&!g)},[s,g]),a.length===0?null:e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:4,cursor:"pointer",fontSize:11.5,color:"var(--text-subtle)",marginLeft:b?0:5},children:[b&&e.jsx("span",{children:b}),e.jsx("input",{ref:t,type:"checkbox","aria-label":d,checked:g,onChange:()=>r(a,!g)})]})}function Xt({onToast:a}={}){const{confirm:i,dialog:r}=Fe(),[d,b]=o.useState([]),[t,s]=o.useState(null),[g,f]=o.useState(null),[u,c]=o.useState(""),[k,z]=o.useState([]),[F,$]=o.useState(null),[E,m]=o.useState(!1),x=o.useCallback(()=>{y.listAgentTokens().then(p=>s(p.items)).catch(()=>s([]))},[]);o.useEffect(()=>{y.getSettings().then(f).catch(()=>{}),y.getAgentCapabilities().then(p=>b(p.capabilities)).catch(()=>{}),x()},[x]);async function O(p){if(!g)return;const I={...g,agentAccessEnabled:p};f(I);try{await y.putSettings(I),a==null||a("Akses AI agent "+(p?"aktif":"nonaktif"),p?"ok":"warn","bot")}catch{a==null||a("Gagal menyimpan","err","x-circle"),f(g)}}const K=p=>z(I=>I.includes(p)?I.filter(l=>l!==p):[...I,p]),G=(p,I)=>z(l=>I?Array.from(new Set([...l,...p])):l.filter(S=>!p.includes(S)));async function ge(){if(!(u.trim().length<1||E)){m(!0);try{const p=await y.createAgentToken({name:u.trim(),capabilities:k});$({name:p.name,token:p.token}),c(""),z([]),x(),a==null||a("Agent token dibuat — salin sekarang","ok","key-round")}catch{a==null||a("Gagal membuat token","err","x-circle")}finally{m(!1)}}}async function me(p){try{if(!await i({title:`Cabut agent token "${p.name}"?`,message:"Agen yang memakainya langsung kehilangan akses.",confirmLabel:"Cabut token",icon:"key-round",run:()=>y.revokeAgentToken(p.id)}))return;x(),a==null||a("Token dicabut","warn","trash-2")}catch{a==null||a("Gagal mencabut token","err","x-circle")}}async function ie(p,I){try{await y.patchAgentToken(p.id,{enabled:I}),x()}catch{a==null||a("Gagal mengubah token","err","x-circle")}}const ve=Array.from(new Set(d.map(p=>p.domain))),le=p=>d.filter(I=>I.access===p).map(I=>I.id),ae=d.map(p=>p.id),se=(t??[]).filter(p=>!p.revokedAt);return e.jsxs(e.Fragment,{children:[e.jsx(Nt,{onToast:a}),e.jsxs(C,{eyebrow:"ai agent",title:"Akses AI Agent",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Beri AI agent eksternal kendali hanoman lewat token (header ",e.jsx("code",{children:"Authorization: Bearer"}),"). Tiap fitur dibuka per ",e.jsx("b",{children:"capability"}),". Selagi master switch mati, semua token ditolak."]}),e.jsx(v,{title:"Aktifkan akses AI agent",last:!0,desc:"Master switch. Nonaktif → semua agent token 401, apa pun capability-nya.",children:e.jsx(R,{checked:!!(g!=null&&g.agentAccessEnabled),onChange:p=>void O(p)})})]}),e.jsxs(C,{eyebrow:"token",title:"Agent tokens",children:[F&&e.jsxs("div",{style:{padding:12,marginBottom:12,border:"1px solid var(--brass-300)",borderRadius:"var(--radius-sm)",background:"var(--brass-100)"},children:[e.jsxs("div",{style:{fontSize:12.5,fontWeight:600,marginBottom:6},children:["Token “",F.name,"” — salin sekarang, tak akan ditampilkan lagi:"]}),e.jsx("code",{style:{display:"block",wordBreak:"break-all",fontSize:12},children:F.token}),e.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[e.jsx(j,{size:"sm",leftIcon:"copy",onClick:()=>{var p;(p=navigator.clipboard)==null||p.writeText(F.token),a==null||a("Disalin","ok","copy")},children:"Salin"}),e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>$(null),children:"Tutup"})]})]}),t===null?e.jsx(V,{kind:"loading",compact:!0,title:"Memuat token…"}):se.length===0?e.jsx("div",{style:{fontSize:13,color:"var(--text-subtle)",padding:"8px 0"},children:"Belum ada agent token."}):se.map((p,I)=>e.jsx(v,{title:p.name,last:I===se.length-1,desc:`${p.tokenPrefix}… · ${p.capabilities.length} capability · `+(p.lastUsedAt?"terpakai "+new Date(p.lastUsedAt).toLocaleString("id-ID"):"belum dipakai")+(ua(p.capabilities).length?` — token ini ${ua(p.capabilities).join(", ")}; sekarang tidak, sampai capability berbahayanya dicentang. Cabut lalu buat ulang bila memang perlu.`:""),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(R,{size:"sm",checked:p.enabled,onChange:l=>void ie(p,l)}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:()=>me(p),children:"Cabut"})]})},p.id)),e.jsxs("div",{style:{paddingTop:14},children:[e.jsx(ee,{label:"Nama token",children:e.jsx(Y,{value:u,placeholder:"mis. agent-ci",onChange:p=>c(p.target.value),style:{width:"100%"}})}),e.jsx("div",{style:{marginTop:12,fontSize:12.5,fontWeight:600,color:"var(--text-strong)"},children:"Capability"}),e.jsxs("div",{className:"hn-grid-mobile",style:{marginTop:8,display:"grid",gridTemplateColumns:"1fr auto auto auto",gap:"6px 14px",alignItems:"center"},children:[e.jsx("div",{style:{textAlign:"right"},children:e.jsx(De,{label:"Pilih semua capability",ariaLabel:"pilih semua capability",ids:ae,picked:k,onToggle:G})}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--text-subtle)",textAlign:"center"},children:["baca",e.jsx(De,{ariaLabel:"pilih semua baca",ids:le("read"),picked:k,onToggle:G})]}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--text-subtle)",textAlign:"center"},children:["tulis",e.jsx(De,{ariaLabel:"pilih semua tulis",ids:le("write"),picked:k,onToggle:G})]}),e.jsxs("div",{style:{fontSize:11.5,color:"var(--status-err)",textAlign:"center"},children:["berbahaya",e.jsx(De,{ariaLabel:"pilih semua berbahaya",ids:le("danger"),picked:k,onToggle:G})]}),ve.map(p=>{const I=d.find(N=>N.domain===p&&N.access==="read"),l=d.find(N=>N.domain===p&&N.access==="write"),S=d.find(N=>N.domain===p&&N.access==="danger"),M=Xa.find(N=>N.domain===p);return e.jsxs(o.Fragment,{children:[e.jsxs("div",{style:{fontSize:13,color:"var(--text-muted)"},children:[e.jsxs("div",{style:{fontWeight:600,color:"var(--text-strong)"},children:[(M==null?void 0:M.label)??p,l!=null&&l.risk||S!=null&&S.risk?" ⚠":""]}),(M==null?void 0:M.desc)&&e.jsx("div",{style:{fontSize:11.5,color:"var(--text-subtle)",lineHeight:1.4,marginTop:1},children:M.desc}),S&&e.jsxs("div",{style:{fontSize:11.5,color:"var(--status-err)",lineHeight:1.4,marginTop:2},children:[S.label.replace(/^[^—]+—\s*/,"berbahaya: ")," — ",S.desc]})]}),e.jsx("div",{style:{textAlign:"center"},children:I&&e.jsx("input",{type:"checkbox","aria-label":I.id,checked:k.includes(I.id),onChange:()=>K(I.id)})}),e.jsx("div",{style:{textAlign:"center"},children:l&&e.jsx("input",{type:"checkbox","aria-label":l.id,checked:k.includes(l.id),onChange:()=>K(l.id)})}),e.jsx("div",{style:{textAlign:"center"},children:S&&e.jsx("input",{type:"checkbox","aria-label":S.id,checked:k.includes(S.id),onChange:()=>K(S.id)})})]},p)})]}),e.jsx("div",{style:{marginTop:14},children:e.jsx(j,{size:"sm",leftIcon:"plus",disabled:u.trim().length<1||E,onClick:()=>void ge(),children:"Buat token"})})]}),r]}),e.jsx(Ht,{})]})}function Qt(){const[a,i]=o.useState(null),[r,d]=o.useState(!1),b=o.useCallback(()=>{y.setupStatus().then(i).catch(()=>i(null))},[]);return o.useEffect(b,[b]),a?r?e.jsx(it,{status:a,onDone:()=>{d(!1),b()}}):e.jsx("div",{"data-testid":"setup-card",children:e.jsxs(C,{eyebrow:"setup",title:"Setup awal",children:[e.jsxs("div",{style:{fontSize:12.5,lineHeight:1.6,marginBottom:12},children:["Peruntukan: ",a.deployment==="local"?"Device saya sendiri":"Diakses orang lain",e.jsx("br",{}),a.hardening?"Hardening menyala":"Hardening mati",a.hardeningLocked?" — dipasang lewat env, tak bisa diubah dari sini":""]}),e.jsx(j,{onClick:()=>d(!0),children:"Jalankan ulang setup"})]})}):e.jsx(V,{kind:"loading",title:"Memuat setup…"})}const ga=[{key:"akun",label:"Akun",icon:"user-round"},{key:"users",label:"Users",icon:"users"},{key:"akses-klien",label:"Akses klien",icon:"user-check"},{key:"perangkat",label:"Perangkat",icon:"key-round"},{key:"kendali-jarak-jauh",label:"Kendali jarak jauh",icon:"shield"},{key:"agent",label:"Akses AI Agent",icon:"bot"},{key:"custom-agent",label:"Custom agent",icon:"bot"},{key:"aktivitas",label:"Aktivitas",icon:"activity"},{key:"konfigurasi",label:"Konfigurasi",icon:"sliders"},{key:"setup",label:"Setup awal",icon:"shield"},{key:"telegram",label:"Telegram",icon:"send"},{key:"webhook",label:"Webhook",icon:"webhook"},{key:"umum",label:"Umum",icon:"sliders-horizontal"},{key:"model",label:"Model sesi",icon:"cpu"},{key:"orkestrasi",label:"Orkestrasi",icon:"layers"},{key:"sesi",label:"Sesi",icon:"bell"}];function ln({onToast:a,me:i,onLoggedOut:r}){const d=Qa(),b=Za.map(D=>({value:D.id,label:D.label})),[t,s]=o.useState(null),[g,f]=o.useState(!1),[u,c]=et("settings","tab","akun",nt),k=at(),z=k==="mobile",[F,$]=o.useState(!1),[E,m]=o.useState(null),[x,O]=o.useState(!1),[K,G]=o.useState(null);o.useEffect(()=>{y.getCodexVersion().then(G).catch(()=>{})},[]);const[ge,me]=o.useState(null),[ie,ve]=o.useState("");o.useEffect(()=>{u==="sesi"&&(y.getMethodStatus().then(me).catch(()=>me(null)),y.listProjects({limit:100}).then(D=>ve(H=>{var de;return H||(((de=D.items.find(Oe=>Oe.binding??Oe.repoDir))==null?void 0:de.id)??"")})).catch(()=>{}))},[u]);const le=o.useCallback(()=>{f(!1),s(null),y.getSettings().then(s).catch(()=>f(!0))},[]);o.useEffect(()=>{le()},[le]);const ae=o.useCallback(()=>{O(!1),m(null),y.getTelegramStatus().then(m).catch(()=>O(!0))},[]);o.useEffect(()=>{u==="telegram"&&ae()},[u,ae]);const[se,p]=o.useState(null),[I,l]=o.useState({}),[S,M]=o.useState(null),[N,$e]=o.useState(!1),ze=o.useCallback(()=>{y.getTelegramCredentials().then(D=>{p(D),l({})}).catch(()=>p(null))},[]);o.useEffect(()=>{u==="telegram"&&ze()},[u,ze]);function ya(){var qe,Xe,Qe;if(g)return e.jsx(V,{kind:"error",title:"Gagal memuat pengaturan",hint:"Pengaturan tidak ditampilkan agar tidak menimpa nilai di server.",action:le});if(!t)return e.jsx(V,{kind:"loading",title:"Memuat pengaturan…"});const D=(A,B,_,oe)=>{s(A),y.putSettings(A).catch(()=>{}),B&&a&&a(B,_||"ok",oe||"check-circle-2")},H=(A,B)=>D({...t,...A},B),de=(A,B)=>_=>H({[A]:_},B+(_?" · aktif":" · nonaktif")),Oe=async A=>{if(ie)try{await y.createShell(ie,{method:A.method,agent:A.agent}),a==null||a(`Pemasangan ${A.label} · ${T[A.agent]} berjalan di Terminal`,"ok","terminal")}catch{a==null||a("Gagal membuka sesi terminal pemasangan","err","alert-triangle")}},X=t.codex??ka,Be=t.agent??"claude";if(u==="telegram"){const A=t.telegram??ye,B=(E==null?void 0:E.readiness)??"memuat",_=w=>w==="db"?e.jsx(ne,{tone:"ok",children:"tersimpan"}):w==="env"?e.jsx(ne,{tone:"warn",children:"dari .env · deprecated"}):e.jsx(ne,{children:"belum diisi"}),oe=()=>{const w=Object.fromEntries(Object.entries(I).filter(([,Z])=>Z!==""));if(!Object.keys(w).length){a==null||a("Tak ada perubahan","info","info");return}y.putTelegramCredentials(w).then(Z=>{p(Z),l({}),M(null),a==null||a("Kredensial Telegram disimpan","ok","check-circle-2"),ae()}).catch(Z=>a==null?void 0:a(Z.message||"Gagal menyimpan","err","alert-triangle"))},q=()=>{M("sending"),y.testTelegramConnection().then(M).catch(w=>M({ok:!1,error:w.message||"Gagal menghubungi server",inbound:{ok:!1,reason:"Status jalur masuk tak terbaca — server tak menjawab.",missingCapabilities:[],polling:!1}}))},Se=()=>{$e(!1),y.deleteTelegramCredentials().then(w=>{a==null||a(w.envFallback.length?`Kredensial dihapus — ${w.envFallback.length} nilai masih datang dari .env`:"Kredensial Telegram dihapus","ok","check-circle-2"),M(null),ze(),ae()}).catch(w=>a==null?void 0:a(w.message||"Gagal menghapus","err","alert-triangle"))};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"telegram",title:"Kredensial Telegram",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Disimpan terenkripsi di database dan berlaku langsung — tanpa mengedit ",e.jsx("code",{children:".env"}),", tanpa restart. Nilai ",e.jsx("code",{children:".env"})," lama tetap dipakai selama field-nya masih kosong."]}),se?e.jsxs(e.Fragment,{children:[se.fields.map((w,Z)=>{var we,W;return e.jsx(v,{title:w.label,desc:w.help,last:Z===se.fields.length-1,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[_(w.source),e.jsx(Y,{"aria-label":w.label,mono:!0,type:w.kind==="secret"?"password":"text",placeholder:w.kind==="secret"?w.masked??((we=Re(w.key))==null?void 0:we.example)??"belum diisi":((W=Re(w.key))==null?void 0:W.example)??"belum diisi",value:I[w.key]??(w.kind==="secret"?"":w.value??""),onChange:pe=>l(U=>({...U,[w.key]:pe.target.value})),style:{width:300}})]})},w.key)}),e.jsx("div",{style:{display:"flex",gap:8,marginTop:12},children:e.jsx(j,{size:"sm",leftIcon:"save",onClick:oe,children:"Simpan kredensial"})})]}):e.jsx(V,{kind:"loading",compact:!0,title:"Memuat kredensial…"})]}),e.jsxs(C,{eyebrow:"uji",title:"Uji koneksi & hapus",actions:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"refresh-cw",onClick:ze,children:"Refresh"}),children:[e.jsx(v,{title:"Test Connection",desc:"Mengirim satu pesan percobaan ke chat tujuan. Batas 10 detik — tak pernah menggantung.",children:e.jsx(j,{size:"sm",leftIcon:"send",disabled:S==="sending",onClick:q,children:"Test Connection"})}),S&&S!=="sending"&&e.jsxs("div",{style:{marginTop:10,display:"grid",gap:8},children:[S.ok?e.jsxs(ue,{tone:"ok",children:["Berhasil — bot @",S.botUsername??"?"," mengirim ke chat ",S.chatId,"."]}):e.jsx(ue,{tone:"err",children:S.error}),(qe=S.inbound)!=null&&qe.ok?e.jsx(ue,{tone:"ok",children:"Jalur masuk siap — gateway sedang long polling dan AgentToken-nya sah."}):e.jsxs(ue,{tone:"warn",children:["Jalur masuk BELUM siap: ",((Xe=S.inbound)==null?void 0:Xe.reason)??"status tak terbaca.",!!((Qe=S.inbound)!=null&&Qe.missingCapabilities.length)&&e.jsxs(e.Fragment,{children:[" Capability yang kurang: ",e.jsx("code",{children:S.inbound.missingCapabilities.join(", ")}),"."]})," ","Selama ini merah, pesan Telegram tidak akan pernah tertangkap."]})]}),e.jsx(v,{title:"Hapus kredensial",last:!0,desc:"Menghapus keempat nilai dari database. Bila .env lama masih terisi, nilainya kembali dipakai.",children:e.jsx(j,{size:"sm",variant:"danger",leftIcon:"trash-2",onClick:()=>$e(!0),children:"Hapus kredensial"})}),e.jsx(ha,{open:N,title:"Hapus kredensial Telegram?",message:"Gateway berhenti kecuali nilai .env lama masih tersedia.",confirmLabel:"Hapus",onConfirm:Se,onCancel:()=>$e(!1)})]}),e.jsxs(C,{eyebrow:"gateway",title:"Gateway Telegram",actions:e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"refresh-cw",onClick:ae,children:"Refresh"}),children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:"Satu private chat yang diizinkan terikat ke satu session operator Hanoman persisten. Bahasa natural tetap antarmuka utama; command hanya shortcut ke session yang sama."}),e.jsx(v,{title:"Gateway aktif",desc:"Menyalakan long polling in-process seketika. Mematikan tidak membunuh session tmux atau memory.",children:e.jsx(R,{label:"Gateway aktif",checked:A.enabled,onChange:w=>{D({...t,telegram:{...A,enabled:w}},`Gateway Telegram · ${w?"aktif":"nonaktif"}`)}})}),e.jsx(v,{title:"Kirim progress ringkas",desc:"Hanya progress eksplisit dan fakta status Hanoman; layar PTY/reasoning tidak pernah diteruskan.",children:e.jsx(R,{label:"Kirim progress ringkas",checked:A.progress,onChange:w=>{D({...t,telegram:{...A,progress:w}},`Progress Telegram · ${w?"aktif":"nonaktif"}`)}})}),x?e.jsx(V,{kind:"error",compact:!0,title:"Gagal membaca status Telegram",action:ae}):E?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:`Readiness · ${B}`,desc:E.running?"Long poll aktif.":E.lastError??"Gateway belum polling.",children:e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12},children:E.botUsername?`@${E.botUsername}`:"bot belum terverifikasi"})}),e.jsx(v,{title:"Allowlist",last:!E.missingCapabilities.length,desc:`${E.allowlistCount} Telegram numeric user id diizinkan.`,children:e.jsx("span",{children:E.configured?"kredensial lengkap":"kredensial belum lengkap"})}),E.missingCapabilities.length>0&&e.jsx(v,{title:"Capability kurang",last:!0,desc:E.missingCapabilities.join(", ")})]}):e.jsx(V,{kind:"loading",compact:!0,title:"Memuat status Telegram…"}),e.jsxs("div",{style:{marginTop:14,fontSize:12.5,color:"var(--text-muted)",lineHeight:1.7},children:[e.jsx("b",{children:"Onboarding"}),e.jsxs("ol",{style:{margin:"8px 0 0",paddingLeft:20},children:[e.jsx("li",{children:"Buat satu bot private-chat lewat BotFather, salin token-nya."}),e.jsx("li",{children:"Di Akses AI Agent, aktifkan master switch dan buat AgentToken dengan capability yang ditampilkan status."}),e.jsx("li",{children:"Isi keempat field di kartu Kredensial lalu Simpan."}),e.jsx("li",{children:"Tekan Test Connection sampai hijau."}),e.jsxs("li",{children:["Nyalakan gateway di atas dan kirim ",e.jsx("code",{children:"/status"})," dari Telegram."]})]})]})]})]})}if(u==="umum")return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"general",title:"Umum",children:[e.jsx(v,{title:"Full-auto sebagai default",desc:"Run baru jalan sendiri sampai selesai. Manusia tetap bisa steer / interupsi kapan pun.",children:e.jsx(R,{checked:t.autoDefault,onChange:de("autoDefault","Full-auto default")})}),e.jsx(v,{title:"Auto-scaffold doc index",last:!0,desc:"Project from-scratch otomatis di-scaffold doc index-nya setelah objective terkunci.",children:e.jsx(R,{checked:t.autoScaffold,onChange:de("autoScaffold","Auto-scaffold")})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"4px 2px",color:"var(--text-subtle)",fontSize:12,fontFamily:"var(--font-mono)"},children:[e.jsx("span",{children:"hanoman · nafanesia.id"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"rotate-ccw",onClick:()=>D(JSON.parse(JSON.stringify(Wt)),"Pengaturan dikembalikan ke default","warn","rotate-ccw"),children:"Reset ke default"})]})]});if(u==="orkestrasi")return e.jsx($t,{orchestration:t.orchestration,onChange:(A,B)=>H({orchestration:A},B)});if(u==="model"){const A=n=>{var P;const h=(K==null?void 0:K.version)??null;return pt(n,h)?e.jsxs("div",{"data-testid":"codex-version-note",style:{fontSize:12,lineHeight:1.5,marginBottom:10,padding:"8px 10px",borderRadius:8,background:"var(--warn-bg, #fdf6e3)",color:"var(--text-muted)"},children:["Codex CLI terpasang ",e.jsx("b",{children:h}),", sedangkan ",e.jsx("b",{children:n})," butuh ",e.jsx("b",{children:(P=bt(n))==null?void 0:P.minClient}),". Sesi tetap boleh dijalankan, tapi modelnya belum tentu dikenali CLI ini. Perbarui dengan ",e.jsx("code",{children:"npm i -g @openai/codex@latest"}),"."]}):null},B=n=>Ge.some(h=>h.id===n)?Ge.map(h=>({value:h.id,label:h.label})):[{value:n,label:n},...Ge.map(h=>({value:h.id,label:h.label}))],_=t.conflict??ja,oe=(n,h)=>H({conflict:{..._,...n}},h),q=Be==="codex"?{agent:"codex",model:X.model,effort:X.effort}:{agent:"claude",model:t.model,effort:t.effort},Se=t.lead??_e,w=Se.engine??_e.engine,Z=async(n,h)=>{const P=Se;s({...t,lead:{...Se,engine:{...w,...n}}});try{const re=await y.getLeadConfig(),Ie=await y.putLeadConfig({...re,engine:{...re.engine??_e.engine,...n}});s(ke=>ke&&{...ke,lead:Ie}),a==null||a(h,"ok","check-circle-2")}catch{s(re=>re&&{...re,lead:P}),a==null||a("Gagal menyimpan setelan lead","err","alert-triangle")}},we=t.telegram??ye,W=we.engine??ye.engine,pe=async(n,h)=>{const P=t;s({...t,telegram:{...we,engine:{...W,...n}}});try{const re=await y.getSettings(),Ie=re.telegram??ye,ke={...re,telegram:{...Ie,engine:{...Ie.engine??ye.engine,...n}}},Sa=await y.putSettings(ke);s(Sa??ke),a==null||a(h,"ok","check-circle-2")}catch{s(P),a==null||a("Gagal menyimpan setelan operator Telegram","err","alert-triangle")}},U=t.changelog??fa,Pe=(n,h)=>H({changelog:{...U,...n}},h),Q=t.portalChat??xa,be=(n,h)=>H({portalChat:{...Q,...n}},h),We=(n,h)=>{const P=Math.floor(Number(n));return Number.isFinite(P)&&P>=0?P:h};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"agen",title:"Agen sesi",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:"Mesin yang menjalankan sesi baru. Perilaku sesi identik — worktree terisolasi, fase, stage, review, integrate. Yang berbeda hanya CLI-nya, dan karenanya katalog model/effort-nya. Indikator limit hanya membaca kuota Anthropic, jadi sesi codex tak muncul di sana."}),e.jsx(v,{title:"Agen default",last:!0,desc:"Sesi backlog masih bisa memilih agen lain saat Start.",children:e.jsx(L,{size:"sm","aria-label":"Agen default",value:Be,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>H({agent:n.target.value},"Agen → "+n.target.value)})})]}),e.jsxs(C,{eyebrow:"model",title:"Model sesi — default global",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Default untuk sesi baru; bisa di-override per sesi saat ",e.jsx("b",{children:"Start"}),". Di terminal, ",e.jsx("code",{children:"/model"}),"mengubahnya kapan saja. Dengan orkestrasi aktif, model ini menjadi model ",e.jsx("b",{children:"orchestrator"}),"; model & effort tiap fase diatur di ",e.jsx("b",{children:"tab Orkestrasi"}),". Yang benar-benar dipakai adalah blok milik agen terpilih di atas — yang satunya tersimpan, menunggu giliran."]}),e.jsxs("div",{"data-testid":"agent-group-claude",children:[e.jsxs("div",{style:{padding:"8px 0",color:"var(--text-muted)",fontSize:12},children:["Katalog model diperiksa otomatis setiap 5 menit.",Object.entries(d.providers).map(([n,h])=>e.jsxs("div",{children:[n,": ",h.source==="bundled"?"daftar bawaan":h.source==="cache"?"cache terakhir":"dari CLI",h.checkedAt?" · diperiksa "+new Date(h.checkedAt).toLocaleTimeString():"",h.error?" · "+h.error:""]},n))]}),e.jsx(ca,{id:"claude",label:T.claude,active:Be==="claude"}),e.jsx(v,{title:"Model",desc:"Diteruskan apa adanya ke `claude --model`.",children:e.jsx(L,{size:"sm","aria-label":"Model claude",value:t.model,options:b,style:{width:190},onChange:n=>H({model:n.target.value,...je(n.target.value,t.effort)},"Model claude → "+n.target.value)})}),e.jsx(v,{title:"Effort",last:!0,desc:"Anggaran berpikir per giliran (`claude --effort`).",children:e.jsx(L,{size:"sm","aria-label":"Effort claude",value:t.effort,options:fe(t.model),style:{width:130},onChange:n=>H({effort:n.target.value},"Effort claude → "+n.target.value)})})]}),e.jsxs("div",{"data-testid":"agent-group-codex",style:{borderTop:"1px solid var(--border-hair)",marginTop:6},children:[e.jsx(ca,{id:"codex",label:T.codex,active:Be==="codex"}),A(X.model),e.jsx(v,{title:"Model",desc:"Diteruskan apa adanya ke `codex -m`.",children:e.jsx(L,{size:"sm","aria-label":"Model codex",value:X.model,style:{width:190},options:B(X.model),onChange:n=>{const h=n.target.value;H({codex:{model:h,effort:te(h,X.effort)}},"Model codex → "+h)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Diteruskan ke `codex -c model_reasoning_effort`.",children:e.jsx(L,{size:"sm","aria-label":"Effort codex",value:X.effort,style:{width:130},options:Ce(X.model).map(n=>({value:n,label:n})),onChange:n=>H({codex:{...X,effort:n.target.value}},"Effort codex → "+n.target.value)})})]})]}),e.jsxs(C,{eyebrow:"konflik",title:"Konflik rebase & merge",children:[e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:"Saat rebase/merge berkonflik, hanoman menyerahkan worktree-nya ke satu sesi agen untuk dibereskan. Pekerjaannya sempit dan tak berfase, jadi ia boleh memakai model & effort yang berbeda dari sesi kerja. Berlaku untuk ketiga pintu integrasi: backlog, git graph, dan PRD."}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = sesi konflik memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen konflik",checked:_.enabled,onChange:n=>oe({enabled:n},"Setelan konflik"+(n?" · aktif":" · ikut default global"))})}),_.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Agen",desc:"Mesin yang membereskan konflik. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Agen konflik",value:_.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const h=n.target.value,P=h==="codex"?X:{model:t.model,effort:t.effort};oe({agent:h,model:P.model,effort:h==="codex"?te(P.model,P.effort):P.effort},"Agen konflik → "+h)}})}),_.agent==="codex"&&A(_.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model konflik",value:_.model,style:{width:190},options:_.agent==="codex"?B(_.model):b,onChange:n=>{const h=n.target.value;oe({model:h,..._.agent==="codex"?{effort:te(h,_.effort)}:je(h,_.effort)},"Model konflik → "+h)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Konflik biasanya mekanis — effort rendah sering cukup.",children:e.jsx(L,{size:"sm","aria-label":"Effort konflik",value:_.effort,style:{width:130},options:_.agent==="codex"?Ce(_.model).map(n=>({value:n,label:n})):fe(_.model),onChange:n=>oe({effort:n.target.value},"Effort konflik → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"conflict-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["Sesi konflik memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"lead",title:"Agen hanoman-lead",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Mesin yang menjalankan agen pemimpin — panggilan sekali-jalan non-interaktif yang membaca docs, plan, kode, dan riwayat git sebelum memutuskan. Berlaku untuk ketiga pintu lead (kontrak, deteksi otomatis, denyut) dan dipakai putusan berikutnya, tanpa restart. Rem darurat, denyut, dan opt-in per project tetap diurus di layar ",e.jsx("b",{children:"Lead"}),"."]}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = lead memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen lead",checked:w.enabled,onChange:n=>Z({enabled:n},"Setelan lead"+(n?" · aktif":" · ikut default global"))})}),w.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Runtime",desc:"Mesin yang menjalankan lead. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Runtime lead",value:w.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const h=n.target.value,P=h==="codex"?X:{model:t.model,effort:t.effort};Z({agent:h,model:P.model,effort:h==="codex"?te(P.model,P.effort):P.effort},"Runtime lead → "+h)}})}),w.agent==="codex"&&A(w.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model lead",value:w.model,style:{width:190},options:w.agent==="codex"?B(w.model):b,onChange:n=>{const h=n.target.value;Z({model:h,...w.agent==="codex"?{effort:te(h,w.effort)}:je(h,w.effort)},"Model lead → "+h)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Putusan lead menuntut membaca bukti — SoT, ADR, plan, kode, riwayat git. Effort rendah memangkas kedalamannya.",children:e.jsx(L,{size:"sm","aria-label":"Effort lead",value:w.effort,style:{width:130},options:w.agent==="codex"?Ce(w.model).map(n=>({value:n,label:n})):fe(w.model),onChange:n=>Z({effort:n.target.value},"Effort lead → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"lead-engine-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["hanoman-lead memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"telegram",title:"Agen operator Telegram",children:[e.jsxs("div",{"data-testid":"telegram-engine-desc",style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Mesin yang menjalankan sesi operator Telegram — satu sesi persisten per chat, yang membaca API hanoman lalu merangkum. Berlaku untuk sesi operator ",e.jsx("b",{children:"berikutnya"})," yang dibuat; sesi yang sedang jalan tetap memakai setelan lamanya (satu proses, satu model seumur hidup) dan tidak di-restart diam-diam — tutup dari chat dengan ",e.jsx("code",{children:"/engine restart"}),". Setelan yang sama juga bisa diubah dari chat: ",e.jsx("code",{children:"/engine"}),", ",e.jsx("code",{children:"/runtime"}),","," ",e.jsx("code",{children:"/model"}),", ",e.jsx("code",{children:"/effort"}),". Berlaku global untuk semua chat."]}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = sesi operator Telegram memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen Telegram",checked:W.enabled,onChange:n=>pe({enabled:n},"Setelan operator Telegram"+(n?" · aktif":" · ikut default global"))})}),W.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Runtime",desc:"Mesin yang menjalankan sesi operator. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Runtime Telegram",value:W.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const h=n.target.value,P=h==="codex"?X:{model:t.model,effort:t.effort};pe({agent:h,model:P.model,effort:h==="codex"?te(P.model,P.effort):P.effort},"Runtime operator Telegram → "+h)}})}),W.agent==="codex"&&A(W.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model Telegram",value:W.model,style:{width:190},options:W.agent==="codex"?B(W.model):b,onChange:n=>{const h=n.target.value;pe({model:h,...W.agent==="codex"?{effort:te(h,W.effort)}:je(h,W.effort)},"Model operator Telegram → "+h)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Operator Telegram jarang menulis kode — effort rendah memangkas latensi balasan secara langsung.",children:e.jsx(L,{size:"sm","aria-label":"Effort Telegram",value:W.effort,style:{width:130},options:W.agent==="codex"?Ce(W.model).map(n=>({value:n,label:n})):fe(W.model),onChange:n=>pe({effort:n.target.value},"Effort operator Telegram → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"telegram-engine-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["Sesi operator Telegram memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"changelog",title:"Agen changelog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Mesin yang menulis narasi changelog per project — panggilan sekali-jalan non-interaktif yang merangkum backlog selesai, rentang commit, atau isi sebuah rilis menjadi teks pendek berorientasi pemakai. Berlaku pada pembangkitan ",e.jsx("b",{children:"berikutnya"}),", tanpa restart. Agen yang gagal tak menggagalkan changelog: barisnya tetap lahir sebagai draf ringkas ber-catatan."]}),e.jsx(v,{title:"Pakai setelan sendiri",desc:"Mati = ikut default global di atas. Hidup = pembuat changelog memakai pilihan di bawah.",children:e.jsx(R,{"aria-label":"Override agen changelog",checked:U.enabled,onChange:n=>Pe({enabled:n},"Setelan changelog"+(n?" · aktif":" · ikut default global"))})}),U.enabled?e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Runtime",desc:"Mesin yang menulis changelog. Bisa beda dari agen sesi kerja.",children:e.jsx(L,{size:"sm","aria-label":"Runtime changelog",value:U.agent,style:{width:190},options:[{value:"claude",label:T.claude},{value:"codex",label:T.codex}],onChange:n=>{const h=n.target.value,P=h==="codex"?X:{model:t.model,effort:t.effort};Pe({agent:h,model:P.model,effort:h==="codex"?te(P.model,P.effort):P.effort},"Runtime changelog → "+h)}})}),U.agent==="codex"&&A(U.model),e.jsx(v,{title:"Model",children:e.jsx(L,{size:"sm","aria-label":"Model changelog",value:U.model,style:{width:190},options:U.agent==="codex"?B(U.model):b,onChange:n=>{const h=n.target.value;Pe({model:h,...U.agent==="codex"?{effort:te(h,U.effort)}:je(h,U.effort)},"Model changelog → "+h)}})}),e.jsx(v,{title:"Effort",last:!0,desc:"Merangkum judul jadi prosa pendek — effort rendah biasanya cukup dan memangkas ongkos setiap pembangkitan.",children:e.jsx(L,{size:"sm","aria-label":"Effort changelog",value:U.effort,style:{width:130},options:U.agent==="codex"?Ce(U.model).map(n=>({value:n,label:n})):fe(U.model),onChange:n=>Pe({effort:n.target.value},"Effort changelog → "+n.target.value)})})]}):e.jsxs("div",{"data-testid":"changelog-engine-inherited",style:{fontSize:12.5,color:"var(--text-muted)",padding:"12px 0 2px",lineHeight:1.5},children:["Pembuat changelog memakai default global: ",e.jsx("b",{children:T[q.agent]})," ·"," ",e.jsx("code",{children:q.model})," · ",e.jsx("code",{children:q.effort}),"."]})]}),e.jsxs(C,{eyebrow:"portal",title:"Obrolan portal klien",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Permukaan obrolan di portal klien: klien memilih ",e.jsx("b",{children:"Brainstorming"})," (digali sampai jelas, keluarannya PRD draft untuk Anda review) atau ",e.jsx("b",{children:"Bertanya"})," (dijawab langsung dari dokumen project). Jatah berlaku ",e.jsx("b",{children:"per project"})," dan dihitung bulanan; brainstorming dan pertanyaan punya jatah masing-masing. Mati = tab Obrolan tak muncul di portal."]}),e.jsx(v,{title:"Aktifkan obrolan",desc:"Mati = klien hanya punya Pekerjaan & Help desk, persis seperti sebelumnya.",children:e.jsx(R,{"aria-label":"Aktifkan obrolan portal",checked:Q.enabled,onChange:n=>be({enabled:n},"Obrolan portal"+(n?" · aktif":" · mati"))})}),Q.enabled&&e.jsxs(e.Fragment,{children:[e.jsx(v,{title:"Jatah brainstorming",desc:"Berapa sesi brainstorming per project tiap bulan. 0 = tertutup.",children:e.jsx(Y,{"aria-label":"Jatah brainstorming",type:"number",min:0,max:1e3,placeholder:"mis. 3",style:{width:110},defaultValue:Q.brainstormPerMonth,onBlur:n=>be({brainstormPerMonth:We(n.target.value,Q.brainstormPerMonth)},"Jatah brainstorming → "+n.target.value)})}),e.jsx(v,{title:"Jatah pertanyaan",desc:"Berapa sesi tanya-jawab per project tiap bulan. 0 = tertutup.",children:e.jsx(Y,{"aria-label":"Jatah pertanyaan",type:"number",min:0,max:1e4,placeholder:"mis. 30",style:{width:110},defaultValue:Q.askPerMonth,onBlur:n=>be({askPerMonth:We(n.target.value,Q.askPerMonth)},"Jatah pertanyaan → "+n.target.value)})}),e.jsx(v,{title:"Model",desc:"Mesin obrolan selalu Claude — gerbang tool yang menjaganya tak ada di runtime lain.",children:e.jsx(L,{size:"sm","aria-label":"Model obrolan portal",value:Q.model,style:{width:190},options:b,onChange:n=>be({model:n.target.value,...je(n.target.value,Q.effort)},"Model obrolan portal → "+n.target.value)})}),e.jsx(v,{title:"Effort",children:e.jsx(L,{size:"sm","aria-label":"Effort obrolan portal",value:Q.effort,style:{width:130},options:fe(Q.model),onChange:n=>be({effort:n.target.value},"Effort obrolan portal → "+n.target.value)})}),e.jsx(v,{title:"Batas waktu satu jawaban",last:!0,desc:"Detik. Lewat dari ini klien menerima kalimat 'coba lagi sebentar', bukan layar menggantung.",children:e.jsx(Y,{"aria-label":"Batas waktu obrolan portal",type:"number",min:10,max:900,placeholder:"mis. 120",style:{width:110},defaultValue:Q.timeoutSec,onBlur:n=>be({timeoutSec:We(n.target.value,Q.timeoutSec)},"Batas waktu obrolan → "+n.target.value)})})]})]})]})}return e.jsxs(e.Fragment,{children:[e.jsxs(C,{eyebrow:"sesi",title:"Sesi & notifikasi",children:[e.jsx(v,{title:"Notifikasi backlog selesai",desc:"Toast + sound saat sebuah backlog mencapai stage done. Daftar lonceng tetap terisi meski dimatikan.",children:e.jsx(R,{checked:t.notifyDone,onChange:de("notifyDone","Notifikasi backlog selesai")})}),e.jsx(v,{title:"Sound notifikasi",desc:"Durasi nada saat backlog selesai.",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(L,{size:"sm",value:t.notifySound,options:oa,style:{width:160},onChange:A=>H({notifySound:A.target.value},"Sound → "+A.target.value)}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"volume-2",disabled:t.notifySound==="off",onClick:()=>ea(t.notifySound),children:"Preview"})]})}),e.jsx(v,{title:"Notifikasi butuh keputusan",desc:"Toast + sound saat sesi Claude berhenti menunggu keputusanmu. Nada sengaja beda dari selesai.",children:e.jsx(R,{checked:t.notifyDecision,onChange:de("notifyDecision","Notifikasi keputusan")})}),e.jsx(v,{title:"Sound keputusan",desc:"Nada saat sebuah sesi menunggu keputusan.",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(L,{size:"sm",value:t.notifyDecisionSound,options:oa,style:{width:160},onChange:A=>H({notifyDecisionSound:A.target.value},"Sound keputusan → "+A.target.value)}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"volume-2",disabled:t.notifyDecisionSound==="off",onClick:()=>ea(t.notifyDecisionSound),children:"Preview"})]})}),e.jsx(v,{title:"Notifikasi saat sesi gagal",last:!0,desc:"Kirim notifikasi ketika sesi Claude Code berakhir dengan error.",children:e.jsx(R,{checked:t.notifyFail,onChange:de("notifyFail","Notifikasi gagal")})})]}),e.jsxs(C,{eyebrow:"goal",title:"Mode goal — sesi backlog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Sesi backlog lahir dengan gate ",e.jsx("code",{children:"Stop"}),": ia menolak berhenti sampai kondisinya terbukti di transkrip. Interupsi manusia (",e.jsx("code",{children:"Esc"}),") tetap bekerja; melepas gate sepenuhnya = hentikan sesinya. Sesi scheduler mengikuti setelan ini."]}),e.jsx(v,{title:"Aktif sebagai default",desc:"Sesi backlog baru lahir dengan mode goal. Masih bisa dimatikan per sesi saat Start.",children:e.jsx(R,{"aria-label":"Mode goal default",checked:t.goal.enabled,onChange:A=>H({goal:{...t.goal,enabled:A}},"Mode goal"+(A?" · aktif":" · nonaktif"))})}),e.jsx(v,{title:"Kondisi (template global)",last:!0,desc:"Kosong = kondisi bawaan hanoman: semua fase tercatat di phase file, plan tak menyisakan task, push sukses.",children:e.jsx("div",{style:{width:320},children:e.jsx(gt,{value:t.goal.condition,rows:4,mono:!0,"aria-label":"Kondisi mode goal",placeholder:"Kosong = kondisi bawaan hanoman · mis. semua fase tercatat & plan tanpa - [ ]",onChange:A=>D({...t,goal:{...t.goal,condition:A.target.value}})})})})]}),e.jsxs(C,{eyebrow:"verifikasi",title:"Scope verifikasi — sesi backlog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Beberapa sesi berjalan bersamaan di mesin ini. ",e.jsx("b",{children:"Hanya yang berubah"})," menyuruh sesi menguji berkas yang benar-benar ia sentuh (",e.jsx("code",{children:"vitest --changed"}),", typecheck per paket, lint per berkas) alih-alih seluruh project — RAM & CPU tetap tersisa untuk sesi lain. Suite penuh, lint penuh, dan build penuh tetap dijalankan manusia sebelum merge."]}),e.jsx(v,{title:"Scope default",last:!0,desc:"Sesi backlog baru lahir dengan scope ini. Masih bisa diubah per sesi saat Start.",children:e.jsx(L,{size:"sm","aria-label":"Scope verifikasi default",value:t.verifyScope??"changed",style:{width:220},options:[{value:"changed",label:"Hanya yang berubah"},{value:"full",label:"Seluruh project"}],onChange:A=>H({verifyScope:A.target.value},"Scope verifikasi → "+A.target.value)})})]}),e.jsxs(C,{eyebrow:"metode",title:"Metode workflow — sesi backlog",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:10,lineHeight:1.5},children:["Metode menentukan ",e.jsx("b",{children:"skill mana yang dimuat di tiap fase"})," dan ",e.jsx("b",{children:"di direktori mana plan & spec ditulis"}),". Fase-fasenya sendiri tak berubah. Gerbang plan memindai direktori SEMUA metode, jadi item yang berpindah metode tak pernah lolos lewat direktori kosong."]}),e.jsx(v,{title:"Metode default",last:!0,desc:"Sesi backlog baru lahir dengan metode ini. Masih bisa diubah per sesi saat Start.",children:e.jsx(L,{size:"sm","aria-label":"Metode default",style:{width:220},value:ht(t.method).id,options:aa.map(A=>({value:A,label:ta[A].label})),onChange:A=>H({method:A.target.value},"Metode → "+A.target.value)})}),ge&&e.jsxs("div",{"data-testid":"method-status",style:{marginTop:4,display:"grid",gap:10},children:[aa.map(A=>e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:600},children:ta[A].label}),ge.methods.filter(B=>B.method===A).map(B=>e.jsxs("div",{"data-testid":`method-status-${B.method}-${B.agent}`,style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12,lineHeight:1.5},children:[e.jsx(ne,{tone:B.ready?"ok":"warn",children:B.ready?"siap":"belum siap"}),e.jsxs("div",{style:{flex:"1 1 auto",minWidth:0},children:[e.jsx("b",{children:T[B.agent]}),!B.ready&&e.jsxs("div",{style:{color:"var(--text-muted)",overflowWrap:"anywhere"},children:[B.missingPackages.length>0&&e.jsxs("div",{children:["paket kurang: ",e.jsx("code",{children:B.missingPackages.join(" · ")})]}),B.missingSkills.length>0&&e.jsxs("div",{children:["skill kurang: ",e.jsx("code",{children:B.missingSkills.join(" · ")})]})]})]}),!B.ready&&e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"download",disabled:!ie,onClick:()=>Oe(B),children:"Pasang"})]},B.agent))]},A)),e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",lineHeight:1.5},children:ie?e.jsxs(e.Fragment,{children:["Pemasangan berjalan di ",e.jsx("b",{children:"sesi terminal"})," project ",e.jsx("code",{children:ie})," — outputnya bisa ditonton di Terminal. hanoman sendiri tak pernah memasang apa pun."]}):e.jsx(e.Fragment,{children:"Pemasangan butuh satu project yang sudah di-bind ke checkout lokal: perintahnya dijalankan di sesi terminal project itu."})})]})]})]})}const va=u==="setup"?e.jsx(Qt,{}):u==="akun"?e.jsx(Gt,{me:i,onLoggedOut:r,onToast:a}):u==="users"?e.jsx(Ut,{me:i,onToast:a}):u==="akses-klien"?e.jsx(jt,{}):u==="perangkat"?e.jsx(Tt,{onToast:a}):u==="kendali-jarak-jauh"?e.jsx(St,{onToast:a}):u==="agent"?e.jsx(Xt,{onToast:a}):u==="custom-agent"?e.jsxs(C,{eyebrow:"agen",title:"Custom agent — global",children:[e.jsxs("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Persona yang tersedia untuk ",e.jsx("b",{children:"setiap sesi baru"})," di semua project. Sesi ",e.jsx("b",{children:"claude"}),"dan ",e.jsx("b",{children:"codex"})," menerima child native dengan konteks terpisah. Agen boleh saling memanggil lewat ",e.jsx("i",{children:"Mention"}),", dan grafnya wajib asiklik — agen tanpa mention tak diberi alat delegasi sama sekali."]}),e.jsx(tt,{projectId:null,runtime:t==null?void 0:t.agent,onToast:a})]}):u==="aktivitas"?e.jsx(Kt,{onToast:a}):u==="konfigurasi"?e.jsx(Vt,{onToast:a}):u==="webhook"?F?e.jsx(It,{onBack:()=>$(!1)}):e.jsx(Et,{onToast:a,onOpenDocs:()=>$(!0)}):ya();return e.jsxs("div",{className:"hn-settings-layout","data-layout":k,style:{display:"grid",gridTemplateColumns:z?"minmax(0, 1fr)":k==="tablet"?"160px minmax(0, 1fr)":"196px minmax(0, 1fr)",gap:k==="tablet"?16:24,alignItems:"start",maxWidth:920},children:[z?e.jsx(L,{"aria-label":"Bagian pengaturan",value:u,onChange:D=>c(D.target.value),options:ga.map(D=>({value:D.key,label:D.label}))}):e.jsx("nav",{"aria-label":"Navigasi pengaturan",style:{display:"flex",flexDirection:"column",gap:2,position:"sticky",top:0},children:ga.map(D=>{const H=D.key===u;return e.jsxs("button",{"aria-current":H?"page":void 0,onClick:()=>c(D.key),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"9px 12px",border:"none",cursor:"pointer",textAlign:"left",borderRadius:"var(--radius-sm)",background:H?"var(--brass-100)":"transparent",color:H?"var(--brass-700)":"var(--text-muted)",fontWeight:H?600:500,fontFamily:"var(--font-ui)",fontSize:13.5},children:[e.jsx(Ne,{name:D.icon,size:16,color:H?"var(--brass-700)":"var(--text-subtle)"}),D.label]},D.key)})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:20,minWidth:0},children:va})]})}export{Xt as AgentAccessPanel,Tt as DeviceTokensPanel,ln as SettingsScreen};