openmausbot 0.1.99 → 0.1.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/assets/{ActivityPanel-CgUgtumZ.js → ActivityPanel-CA9zfl3_.js} +1 -1
  2. package/dist/assets/{BotSettingsDialog-lJj6oiir.js → BotSettingsDialog-3i_izROu.js} +1 -1
  3. package/dist/assets/{CloudBackendPicker-C5-_arUz.js → CloudBackendPicker-BR42-xBg.js} +1 -1
  4. package/dist/assets/{ComputerPanel-euJ2CSlH.js → ComputerPanel-CvThnFmt.js} +1 -1
  5. package/dist/assets/{DesktopViewer-XCln1Pn_.js → DesktopViewer-CqovWUic.js} +1 -1
  6. package/dist/assets/{InspectorPanel-DKYyQZlo.js → InspectorPanel-Cbjm86gt.js} +1 -1
  7. package/dist/assets/{KeyboardShortcutsModal-DkkZWZRI.js → KeyboardShortcutsModal-X13pVrkh.js} +1 -1
  8. package/dist/assets/{LocalVmWorkspace-Cwt3_XSx.js → LocalVmWorkspace-BGD3Tvd3.js} +1 -1
  9. package/dist/assets/{MacLocalControl-B28RbdCS.js → MacLocalControl-ExdXHVUv.js} +1 -1
  10. package/dist/assets/{NewBotDialog-dMWDs5xm.js → NewBotDialog-ftDBMjWR.js} +1 -1
  11. package/dist/assets/{RemoteAgentSettingsPanel-B5KWXnqH.js → RemoteAgentSettingsPanel-BUHLV_vC.js} +1 -1
  12. package/dist/assets/{RoutinesPage-DOosRYDK.js → RoutinesPage-Buk5-r3o.js} +1 -1
  13. package/dist/assets/{RoutinesSection-uOfOTfkB.js → RoutinesSection-NyReOXr8.js} +1 -1
  14. package/dist/assets/{SettingsModal-BTGkFbj1.js → SettingsModal-DkkhdxKM.js} +1 -1
  15. package/dist/assets/{TeamMapPage-DqNdJn96.js → TeamMapPage-BIxeHoy3.js} +1 -1
  16. package/dist/assets/{TriggersPanel-c6xkG9mi.js → TriggersPanel-m5iqc43H.js} +1 -1
  17. package/dist/assets/{VisibilitySection-DD4ffIR5.js → VisibilitySection-y8Adk-c4.js} +1 -1
  18. package/dist/assets/{WebhooksPanel-Cz17K-_O.js → WebhooksPanel-G_NWjHOP.js} +1 -1
  19. package/dist/assets/{abnfDiagram-O67JEVCF-CX6tDpkg.js → abnfDiagram-O67JEVCF-D56ZgyPf.js} +1 -1
  20. package/dist/assets/{activity-BAVWO0Zj.js → activity-D_puBfZo.js} +1 -1
  21. package/dist/assets/{arc-h45-9NFk.js → arc-DzduGHbq.js} +1 -1
  22. package/dist/assets/{architectureDiagram-NJMV4G6O-CgLFXbg6.js → architectureDiagram-NJMV4G6O-C4NS6DQF.js} +1 -1
  23. package/dist/assets/{blockDiagram-BEXU5L5S-DGDFFc9M.js → blockDiagram-BEXU5L5S-BNvsskiE.js} +1 -1
  24. package/dist/assets/{brain-CeCdoTb2.js → brain-oq48IgWl.js} +1 -1
  25. package/dist/assets/{c4Diagram-YGBWAQC7-B9aklAUj.js → c4Diagram-YGBWAQC7-ch3B7xZy.js} +1 -1
  26. package/dist/assets/channel-CmFDMHrN.js +1 -0
  27. package/dist/assets/{chunk-2Q5K7J3B-BC0KmWsM.js → chunk-2Q5K7J3B-D9dL9ZS7.js} +1 -1
  28. package/dist/assets/{chunk-3FUC2YCW-BbDFHsJ1.js → chunk-3FUC2YCW-DmLUUuNr.js} +2 -2
  29. package/dist/assets/{chunk-5VM5RSS4-DtGbsjOM.js → chunk-5VM5RSS4-B90ODeo2.js} +1 -1
  30. package/dist/assets/{chunk-GTNCS2PH-VMghMcEl.js → chunk-GTNCS2PH-BtlGIG3W.js} +1 -1
  31. package/dist/assets/{chunk-GWA4HPMP-BP_JyGWQ.js → chunk-GWA4HPMP-CurBwFFG.js} +1 -1
  32. package/dist/assets/{chunk-JWPE2WC7-CYFyzgAU.js → chunk-JWPE2WC7-DTjNNXcd.js} +1 -1
  33. package/dist/assets/{chunk-NETBCI7D-DBNa_kqm.js → chunk-NETBCI7D-xS7hOqBJ.js} +1 -1
  34. package/dist/assets/{chunk-WEXAMYUT-BKEeM7CJ.js → chunk-WEXAMYUT-DJZBSyA9.js} +1 -1
  35. package/dist/assets/{chunk-XXDRQBXY-C__m3ZXl.js → chunk-XXDRQBXY-CbiNRzjt.js} +1 -1
  36. package/dist/assets/{classDiagram-v2-NBCMYWYE-CBUrTSAX.js → classDiagram-v2-NBCMYWYE-DyON9tUb.js} +1 -1
  37. package/dist/assets/{core-6lvx-ypA.js → core-CRkAXD3N.js} +1 -1
  38. package/dist/assets/{cose-bilkent-JH36ORCC-GRfL-1Vb.js → cose-bilkent-JH36ORCC-C7UwNnp8.js} +1 -1
  39. package/dist/assets/{cynefin-OW5HDTMX-LopwGUjm.js → cynefin-OW5HDTMX-Dv1GTekc.js} +1 -1
  40. package/dist/assets/{cynefinDiagram-VND7K2PF-DSB8ZRNS.js → cynefinDiagram-VND7K2PF-CKgpyZxo.js} +1 -1
  41. package/dist/assets/{dagre-6A5THRUB-DL3Kgdfk.js → dagre-6A5THRUB-BY3cYc8R.js} +1 -1
  42. package/dist/assets/{diagram-22UHCM2B-DIxN34BM.js → diagram-22UHCM2B-D71jBFCO.js} +1 -1
  43. package/dist/assets/{diagram-3UASUU5V-CJnSvXaI.js → diagram-3UASUU5V-Bc3i6JGD.js} +1 -1
  44. package/dist/assets/{diagram-ATOU4E4O-C-XF-lO8.js → diagram-ATOU4E4O-BPDSHISG.js} +1 -1
  45. package/dist/assets/{diagram-CDSNMT55-Df2yZPi_.js → diagram-CDSNMT55-xuCT1v32.js} +1 -1
  46. package/dist/assets/{diagram-MLGK6HIB-BBs9oZFs.js → diagram-MLGK6HIB-LEDTXDPg.js} +1 -1
  47. package/dist/assets/{diagram-MPIPVDR6-CEbK11mM.js → diagram-MPIPVDR6-B0kfscRD.js} +1 -1
  48. package/dist/assets/{ebnfDiagram-ZINNZB2B-BNq6Yv3C.js → ebnfDiagram-ZINNZB2B-B-Z0HLzJ.js} +1 -1
  49. package/dist/assets/{elk-276RUBZZ-CFbQ2bGm.js → elk-276RUBZZ-Bzypn7lU.js} +1 -1
  50. package/dist/assets/{erDiagram-OPXOYQCR-Bz8vmjN4.js → erDiagram-OPXOYQCR-vl1xKmbS.js} +1 -1
  51. package/dist/assets/{flowDiagram-KWPJA3E3-cQUfEYrx.js → flowDiagram-KWPJA3E3-DQXCXm7z.js} +1 -1
  52. package/dist/assets/{ganttDiagram-FUAMR5RP-BY8n9tbI.js → ganttDiagram-FUAMR5RP-B0wwnP2j.js} +1 -1
  53. package/dist/assets/{gitGraphDiagram-X574FWY7-KduSOMDN.js → gitGraphDiagram-X574FWY7-HfEVZRuR.js} +1 -1
  54. package/dist/assets/{image-plus-DNIWU160.js → image-plus-D9o3v9bi.js} +1 -1
  55. package/dist/assets/{index-C8xb62XS.js → index-CyM91z0J.js} +111 -111
  56. package/dist/assets/{infoDiagram-VRGFBTTK-xBKgUkpL.js → infoDiagram-VRGFBTTK-BcCklxlu.js} +1 -1
  57. package/dist/assets/{ishikawaDiagram-OU5B5YK6-_ei09tAJ.js → ishikawaDiagram-OU5B5YK6-Bw7Fp8yZ.js} +1 -1
  58. package/dist/assets/{journeyDiagram-ZHPQQLJL-Fp49MkSp.js → journeyDiagram-ZHPQQLJL-BqFaTPiB.js} +1 -1
  59. package/dist/assets/{kanban-definition-PNTS6WVX-CY9lLm7V.js → kanban-definition-PNTS6WVX-BdGyimUh.js} +1 -1
  60. package/dist/assets/{linear-D2ai4eM2.js → linear-DezKjgv7.js} +1 -1
  61. package/dist/assets/{mermaid.core-DP6qPqu1.js → mermaid.core-97L7xtx0.js} +5 -5
  62. package/dist/assets/{mindmap-definition-NLK3R4M7-g1ynEw_d.js → mindmap-definition-NLK3R4M7-DP6qz87C.js} +1 -1
  63. package/dist/assets/{page-visible-BZn8304W.js → page-visible-BehtKJDm.js} +1 -1
  64. package/dist/assets/{pegDiagram-GJSIUBJH-Bt4ObsZj.js → pegDiagram-GJSIUBJH-CsYSloVz.js} +1 -1
  65. package/dist/assets/{pieDiagram-5QR66LMP-CeLld8bY.js → pieDiagram-5QR66LMP-CFI2Dcix.js} +1 -1
  66. package/dist/assets/{quadrantDiagram-O4NWA36T-D4WWZw3x.js → quadrantDiagram-O4NWA36T-DqTdAE5z.js} +1 -1
  67. package/dist/assets/{railroadDiagram-XR7U4H2S-D95P5NqU.js → railroadDiagram-XR7U4H2S-t_rszRIF.js} +1 -1
  68. package/dist/assets/{remote-desktop-panel-DOIMmT4T.js → remote-desktop-panel-WTaz_HI9.js} +1 -1
  69. package/dist/assets/{requirementDiagram-PLB6GJNP-D12p3RhR.js → requirementDiagram-PLB6GJNP-1MU-l7p8.js} +1 -1
  70. package/dist/assets/{sankeyDiagram-IPEJSGJF-Co26Dwcs.js → sankeyDiagram-IPEJSGJF-CtkrwAvo.js} +1 -1
  71. package/dist/assets/{sequenceDiagram-PO4LG4MO-y5YxaDKt.js → sequenceDiagram-PO4LG4MO-CJOwBubv.js} +1 -1
  72. package/dist/assets/{sizeCapture-INFHLROL-D49hZ8U5.js → sizeCapture-INFHLROL-DhQVhKCc.js} +1 -1
  73. package/dist/assets/{stateDiagram-v2-GCMORJYK-C0sylr-r.js → stateDiagram-v2-GCMORJYK-CaQK9yA9.js} +1 -1
  74. package/dist/assets/{swimlanes-2SLR337P-DmRWsDIs.js → swimlanes-2SLR337P-Ct8cqf01.js} +1 -1
  75. package/dist/assets/swimlanesDiagram-TC7HE7FX-BBUcFKOA.js +8 -0
  76. package/dist/assets/{timeline-definition-EJHVYXUP-DVmHYs3w.js → timeline-definition-EJHVYXUP-qim2Km3q.js} +1 -1
  77. package/dist/assets/{usecaseDiagram-POWQR4AR-BQ1q0VV6.js → usecaseDiagram-POWQR4AR-BIzcxmgX.js} +1 -1
  78. package/dist/assets/{user-B9lohN4n.js → user-EQ8rI0f4.js} +1 -1
  79. package/dist/assets/{vennDiagram-UO4OBE2U-C_cnfST0.js → vennDiagram-UO4OBE2U-BFEuz8Ba.js} +1 -1
  80. package/dist/assets/{wardleyDiagram-VNRHLVJA-Bb3BSu12.js → wardleyDiagram-VNRHLVJA-JRkAN01c.js} +1 -1
  81. package/dist/assets/{xychartDiagram-PMCCYNJV-CcwEuuEi.js → xychartDiagram-PMCCYNJV-WBsvmu0R.js} +1 -1
  82. package/dist/index.html +1 -1
  83. package/dist-server/index.js +9 -6
  84. package/dist-server/server/mcp-probe.js +18 -10
  85. package/package.json +1 -1
  86. package/dist/assets/channel-TsOXCiPg.js +0 -1
  87. package/dist/assets/swimlanesDiagram-TC7HE7FX-DzhbBHtd.js +0 -8
@@ -1,4 +1,4 @@
1
- import{a1 as V,r as l,j as i,t as u,p as X,y as J,a2 as W,a3 as Q,d as ee,a4 as te,c as $,a5 as ne,a6 as se,u as re,a as ae,a7 as ie,l as oe,a8 as ce,X as le,R as de,a9 as ue,aa as pe}from"./index-C8xb62XS.js";const me=/^«redacted \d+ chars»$/,y=e=>me.test(e)?e:`«redacted ${e.length} chars»`,fe=[/\bom[dg]_[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g,/\bsk-(?:ant-|proj-|live-|test-)?[A-Za-z0-9_-]{16,}/g,/\bxai-[A-Za-z0-9_-]{20,}/g,/\bgsk_[A-Za-z0-9]{40,}/g,/\bcsk-[A-Za-z0-9]{32,}/g,/\bhf_[A-Za-z0-9]{30,}/g,/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bxox[abposr]-[A-Za-z0-9-]{20,}/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{30,}/g,/\bnpm_[A-Za-z0-9]{20,}/g,/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g],xe=/(\bBearer\s+)([A-Za-z0-9._~+/=-]{12,})/g,ge=/(-----BEGIN [A-Z ]*PRIVATE KEY-----)([\s\S]*?)(-----END [A-Z ]*PRIVATE KEY-----)/g,he=/\b((?:[A-Za-z0-9_-]*_)?(?:api[_-]?key|apikey|secret|token|password|passwd|authorization|auth[_-]?token|access[_-]?key|private[_-]?key)s?)(["']?\s*[=:]\s*)(["']?)([A-Za-z0-9._~+/=-]{8,})\3/gi,ye=/\b([A-Za-z][A-Za-z0-9_-]*[_-]key)s?(=)(["']?)([A-Za-z0-9._~+/=-]+)\3/gi,be=/(--(?:token|password|passwd|api-key|apikey|secret|access-key|auth-token)(?:=|\s+))(["']?)(?!-)([A-Za-z0-9._~+/=-]+)\2/gi,ke=/(\b[a-z][a-z0-9+.-]*:\/\/[^\s/:@'"]+:)([^\s/@'"«»]+)(@)/gi;function T(e){if(!e||e.length<8)return e;let t=e;t=t.replace(ge,(o,n,r,s)=>`${n}
1
+ import{a1 as V,r as l,j as i,t as u,p as X,y as J,a2 as W,a3 as Q,d as ee,a4 as te,c as $,a5 as ne,a6 as se,u as re,a as ae,a7 as ie,l as oe,a8 as ce,X as le,R as de,a9 as ue,aa as pe}from"./index-CyM91z0J.js";const me=/^«redacted \d+ chars»$/,y=e=>me.test(e)?e:`«redacted ${e.length} chars»`,fe=[/\bom[dg]_[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g,/\bsk-(?:ant-|proj-|live-|test-)?[A-Za-z0-9_-]{16,}/g,/\bxai-[A-Za-z0-9_-]{20,}/g,/\bgsk_[A-Za-z0-9]{40,}/g,/\bcsk-[A-Za-z0-9]{32,}/g,/\bhf_[A-Za-z0-9]{30,}/g,/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bxox[abposr]-[A-Za-z0-9-]{20,}/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{30,}/g,/\bnpm_[A-Za-z0-9]{20,}/g,/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g],xe=/(\bBearer\s+)([A-Za-z0-9._~+/=-]{12,})/g,ge=/(-----BEGIN [A-Z ]*PRIVATE KEY-----)([\s\S]*?)(-----END [A-Z ]*PRIVATE KEY-----)/g,he=/\b((?:[A-Za-z0-9_-]*_)?(?:api[_-]?key|apikey|secret|token|password|passwd|authorization|auth[_-]?token|access[_-]?key|private[_-]?key)s?)(["']?\s*[=:]\s*)(["']?)([A-Za-z0-9._~+/=-]{8,})\3/gi,ye=/\b([A-Za-z][A-Za-z0-9_-]*[_-]key)s?(=)(["']?)([A-Za-z0-9._~+/=-]+)\3/gi,be=/(--(?:token|password|passwd|api-key|apikey|secret|access-key|auth-token)(?:=|\s+))(["']?)(?!-)([A-Za-z0-9._~+/=-]+)\2/gi,ke=/(\b[a-z][a-z0-9+.-]*:\/\/[^\s/:@'"]+:)([^\s/@'"«»]+)(@)/gi;function T(e){if(!e||e.length<8)return e;let t=e;t=t.replace(ge,(o,n,r,s)=>`${n}
2
2
  ${y(r.trim())}
3
3
  ${s}`);for(const o of fe)t=t.replace(o,n=>y(n));return t=t.replace(xe,(o,n,r)=>`${n}${y(r)}`),t=t.replace(he,(o,n,r,s,f)=>`${n}${r}${s}${y(f)}${s}`),t=t.replace(ye,(o,n,r,s,f)=>`${n}${r}${s}${y(f)}${s}`),t=t.replace(be,(o,n,r,s)=>`${n}${r}${y(s)}${r}`),t=t.replace(ke,(o,n,r,s)=>`${n}${y(r)}${s}`),t}const b=(e,t=120)=>e.length>t?`${e.slice(0,t-1)}…`:e,k=e=>e.replace(/\s+/g," ").trim(),D=119;function O(e,t){const o=e?{...e}:{text:"",pendingSpace:!1,overflow:!1};if(o.overflow)return o;for(const n of t){if(/\s/.test(n)){o.text&&(o.pendingSpace=!0);continue}if(o.pendingSpace){if(o.text.length>=D){o.overflow=!0;break}o.text+=" ",o.pendingSpace=!1}if(o.text.length>=D){o.overflow=!0;break}o.text+=n}return o}const P=e=>`${e.text}${e.overflow?"…":""}`;function $e(e){switch(e.type){case"session.started":return{summary:`session ${e.sessionId??"(none)"}${e.model?` · ${e.model}`:""}`,tone:"plain"};case"session.exited":return{summary:`session exited${e.reason?` · ${e.reason}`:""}`,tone:"plain"};case"turn.started":return{summary:`turn started${e.turnId?` · ${e.turnId.slice(0,8)}`:""}`,tone:"boundary"};case"turn.retrying":return{summary:`retrying (${e.reason}) · attempt ${e.attempt} · ${Math.round(e.delayMs/1e3)}s`,tone:"plain"};case"turn.completed":{const t=[e.ok?"turn ok":"turn failed"];return e.stopReason&&t.push(e.stopReason),typeof e.cost=="number"&&t.push(`$${e.cost.toFixed(4)}`),e.denials?.length&&t.push(`${e.denials.length} denied`),{summary:t.join(" · "),tone:e.ok?"boundary":"error"}}case"turn.wait_started":return{summary:`waiting for computer — ${e.holder?`${e.holder.name}${e.holder.task?` (${e.holder.task})`:""}`:"holder unknown"}`,tone:"plain"};case"turn.wait_ended":{const t=Math.round(e.waitedMs/1e3),o=e.waitedMs<1e3?"under a second":`${t}s`;return e.outcome==="acquired"?{summary:`computer acquired after ${o}`,tone:"boundary"}:e.outcome==="parked"?{summary:`computer wait parked after ${o}`,tone:"plain"}:e.outcome==="gave_up"?{summary:`computer wait gave up after ${o}`,tone:"error"}:{summary:`computer wait stopped after ${o}`,tone:"plain"}}case"item.started":return{summary:`${e.itemType}${e.title?`: ${b(k(e.title))}`:" started"}`,tone:"plain"};case"item.updated":return{summary:`${e.itemType} updated${typeof e.tokens=="number"?` · ${e.tokens} tok`:""}`,tone:"plain"};case"item.completed":return e.itemType==="assistant_text"?{summary:`assistant: ${b(k(e.text))}`,tone:"plain"}:e.itemType==="assistant_image"?{summary:"assistant image generated",tone:"plain"}:{summary:`tool ${e.ok?"ok":"failed"}`,tone:e.ok?"plain":"error"};case"content.delta":return{summary:`${e.streamKind}: ${b(k(e.delta))}`,tone:"plain"};case"request.opened":return{summary:`${e.requestType}${e.origin==="output"?" (agent-composed)":""}: ${e.tool} — ${b(k(e.summary))}`,tone:"plain"};case"request.resolved":return{summary:`resolved ${e.behavior} · ${e.source}`,tone:"plain"};case"thread.token-usage.updated":return{summary:`tokens in ${e.input} · out ${e.output}`,tone:"plain"};case"runtime.error":return{summary:`${e.setup?"setup: ":""}${b(k(e.message))}`,tone:"error"};case"runtime.notice":return{summary:`notice: ${b(k(e.message))}`,tone:"plain"};default:return{summary:e.type,tone:"plain"}}}function ve(e){const t=e.msg;if(!t||typeof t!="object")return String(e.msg);const o=typeof t.method=="string"?t.method:void 0,n=typeof t.type=="string"?t.type:void 0,r=t.id!==void 0?` #${String(t.id)}`:"";if(o)return`${o}${r}`;if(typeof t.event=="string"){const s=t.result?.status;return typeof s=="string"?`${t.event} · ${s}`:t.event}if(n){const s=t.message,f=typeof s?.role=="string"?` · ${s.role}`:"",d=typeof t.subtype=="string"?` · ${t.subtype}`:"";return`${n}${d}${f}`}return t.result!==void 0?`result${r}`:t.error!==void 0?`error${r}`:b(k(JSON.stringify(t)))}function we(e){const t=[];for(const[o,n]of e.entries()){if(n.kind==="native"){t.push({key:`n${o}`,kind:"native",at:n.at,tag:n.data.dir==="out"?"→ out":"← in",summary:`${n.data.source} · ${ve(n.data)}`,tone:"plain",data:n.data,count:1});continue}const r=n.data,s=t.at(-1);if(r.type==="content.delta"&&s?.kind==="runtime"&&s.tag==="content.delta"&&s.data[0]?.type==="content.delta"&&s.data[0].streamKind===r.streamKind){const w=s.data;w.push(r),s.count=w.length,s.preview=O(s.preview,r.delta),s.summary=`${r.streamKind}: ${P(s.preview)}`;continue}const{summary:f,tone:d}=$e(r),g=r.type==="content.delta"?O(void 0,r.delta):void 0,v=r.type==="content.delta"?r.streamKind:void 0;t.push({key:r.eventId||`r${o}`,kind:"runtime",at:n.at,tag:r.type,summary:g&&v?`${v}: ${P(g)}`:f,tone:d,data:r.type==="content.delta"?[r]:r,count:1,preview:g})}return t}function je(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return"--:--:--";const o=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0"),r=String(t.getSeconds()).padStart(2,"0"),s=String(t.getMilliseconds()).padStart(3,"0");return`${o}:${n}:${r}.${s}`}function Ne(e){const t=[];let o=!1;for(const n of e)if(n.kind==="text"&&n.role==="user"&&n.text?.trim())t.push({id:n.id,at:n.at,label:o?"User input":"Task started",state:"observed",kind:"task"}),o=!0;else if(n.kind==="activity"&&n.tool){const r=V(n.tool.name),s=n.tool.ok===!1||r!==null;t.push({id:n.id,at:n.at,label:T(r??n.tool.name),...n.tool.summary?{command:T(n.tool.summary)}:{},state:s?"failed":n.tool.ok===!0?"complete":"running",kind:"tool"})}else n.kind==="screen"?t.push({id:n.id,at:n.at,label:"Screen observed",state:"observed",kind:"screen"}):n.kind==="text"&&n.role==="bot"&&n.text?.trim()&&t.push({id:n.id,at:n.at,label:"Response recorded",state:"complete",kind:"result"});return t}function _e(e){return T(e.map(t=>`[${new Date(t.at).toISOString()}] ${t.state} · ${t.label}${t.command?`
4
4
  ${t.command}`:""}`).join(`
@@ -1 +1 @@
1
- import{r as o,i as h,f as p,j as e,K as u,X as b,S as m,b as f,s as y}from"./index-C8xb62XS.js";function j({item:t,isMac:r}){const n=y(t,r);return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[e.jsx("span",{className:"text-[13px] text-ink",children:t.description}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.map((a,i)=>e.jsx("kbd",{className:"inline-flex min-w-[22px] items-center justify-center rounded-md border border-hairline/60 bg-control px-1.5 py-0.5 font-mono text-[11.5px] font-semibold text-ink shadow-xs",children:a},i))})]})}function k({open:t,onClose:r}){const[n,a]=o.useState(""),i=o.useRef(null),c=o.useRef(null),l=h();if(o.useLayoutEffect(()=>{const s=i.current;if(!(!t||!s))return a(""),s.showModal(),c.current?.focus(),()=>s.close()},[t]),!t)return null;const d=p(f,n,l);return e.jsx("dialog",{ref:i,"aria-labelledby":"shortcuts-dialog-title",className:"m-auto w-[min(500px,calc(100%-32px))] max-h-[85vh] overflow-hidden rounded-2xl border border-hairline/50 bg-panel p-0 text-ink shadow-2xl backdrop:bg-black/60 backdrop:backdrop-blur-xs",onCancel:s=>{s.preventDefault(),r()},onKeyDown:s=>s.stopPropagation(),onMouseDown:s=>s.target===s.currentTarget&&r(),children:e.jsxs("div",{className:"flex max-h-[85vh] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:e.jsx(u,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{id:"shortcuts-dialog-title",className:"text-[16px] font-semibold text-ink",children:"Keyboard Shortcuts"}),e.jsx("p",{className:"text-[12px] text-ink-secondary",children:"Quick commands and navigation"})]})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":"Close keyboard shortcuts",className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(b,{size:18})})]}),e.jsx("div",{className:"border-b border-hairline/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-hairline/40 bg-inset px-3 py-1.5 focus-within:border-focus",children:[e.jsx(m,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{ref:c,value:n,onChange:s=>a(s.target.value),placeholder:"Search shortcuts…","aria-label":"Search shortcuts",className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-3 space-y-4",children:d.length===0?e.jsxs("div",{className:"py-8 text-center text-[13px] text-ink-secondary",children:["No shortcuts found for “",n,"”"]}):d.map(s=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:s.category}),e.jsx("div",{className:"divide-y divide-hairline/20 rounded-xl bg-card/40 px-3 py-1 border border-hairline/30",children:s.items.map(x=>e.jsx(j,{item:x,isMac:l},x.id))})]},s.category))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-hairline/40 bg-card/30 px-5 py-2.5 text-[11.5px] text-ink-secondary",children:[e.jsxs("span",{children:["Press ",e.jsx("kbd",{className:"rounded bg-control px-1 py-0.5 font-mono text-[10.5px]",children:"?"})," when not typing to open"]}),e.jsx("button",{type:"button",onClick:r,className:"rounded-lg bg-raised px-3 py-1 font-medium text-ink hover:brightness-110",children:"Done"})]})]})})}export{k as KeyboardShortcutsModal};
1
+ import{r as o,i as h,f as p,j as e,K as u,X as b,S as m,b as f,s as y}from"./index-CyM91z0J.js";function j({item:t,isMac:r}){const n=y(t,r);return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[e.jsx("span",{className:"text-[13px] text-ink",children:t.description}),e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.map((a,i)=>e.jsx("kbd",{className:"inline-flex min-w-[22px] items-center justify-center rounded-md border border-hairline/60 bg-control px-1.5 py-0.5 font-mono text-[11.5px] font-semibold text-ink shadow-xs",children:a},i))})]})}function k({open:t,onClose:r}){const[n,a]=o.useState(""),i=o.useRef(null),c=o.useRef(null),l=h();if(o.useLayoutEffect(()=>{const s=i.current;if(!(!t||!s))return a(""),s.showModal(),c.current?.focus(),()=>s.close()},[t]),!t)return null;const d=p(f,n,l);return e.jsx("dialog",{ref:i,"aria-labelledby":"shortcuts-dialog-title",className:"m-auto w-[min(500px,calc(100%-32px))] max-h-[85vh] overflow-hidden rounded-2xl border border-hairline/50 bg-panel p-0 text-ink shadow-2xl backdrop:bg-black/60 backdrop:backdrop-blur-xs",onCancel:s=>{s.preventDefault(),r()},onKeyDown:s=>s.stopPropagation(),onMouseDown:s=>s.target===s.currentTarget&&r(),children:e.jsxs("div",{className:"flex max-h-[85vh] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:e.jsx(u,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{id:"shortcuts-dialog-title",className:"text-[16px] font-semibold text-ink",children:"Keyboard Shortcuts"}),e.jsx("p",{className:"text-[12px] text-ink-secondary",children:"Quick commands and navigation"})]})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":"Close keyboard shortcuts",className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(b,{size:18})})]}),e.jsx("div",{className:"border-b border-hairline/30 px-5 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-hairline/40 bg-inset px-3 py-1.5 focus-within:border-focus",children:[e.jsx(m,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{ref:c,value:n,onChange:s=>a(s.target.value),placeholder:"Search shortcuts…","aria-label":"Search shortcuts",className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-3 space-y-4",children:d.length===0?e.jsxs("div",{className:"py-8 text-center text-[13px] text-ink-secondary",children:["No shortcuts found for “",n,"”"]}):d.map(s=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:s.category}),e.jsx("div",{className:"divide-y divide-hairline/20 rounded-xl bg-card/40 px-3 py-1 border border-hairline/30",children:s.items.map(x=>e.jsx(j,{item:x,isMac:l},x.id))})]},s.category))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-hairline/40 bg-card/30 px-5 py-2.5 text-[11.5px] text-ink-secondary",children:[e.jsxs("span",{children:["Press ",e.jsx("kbd",{className:"rounded bg-control px-1 py-0.5 font-mono text-[10.5px]",children:"?"})," when not typing to open"]}),e.jsx("button",{type:"button",onClick:r,className:"rounded-lg bg-raised px-3 py-1 font-medium text-ink hover:brightness-110",children:"Done"})]})]})})}export{k as KeyboardShortcutsModal};
@@ -1 +1 @@
1
- import{D as oe,G as ae,H as M,J as I,N as he,u as me,r as i,j as a,M as ie,X as ve,O as ce,g as P,c as K,d as q,Q as Z,R as we}from"./index-C8xb62XS.js";import{t as ee}from"./computer-control-NLov352p.js";function xe(r,e){const l=(t,o)=>t.left<o.right&&t.right>o.left&&t.top<o.bottom&&t.bottom>o.top;return e.some(t=>t.visible&&t.rect.width>0&&t.rect.height>0&&(t.explicit||t.zIndex!==null&&t.zIndex>=10)&&r.some(o=>l(t.rect,o)))}async function be(r,e,l,t){e&&e!==l&&(await r.setInteractive(null),await r.release(e));const o=await r.take(l);if(!o.held)throw new Error("The Local VM control hold was not acquired");if(o.owned!==!0)return{status:"held-elsewhere",botId:l,snapshot:o};try{await r.setInteractive(t)}catch(u){throw await r.setInteractive(null).catch(()=>{}),await r.release(l).catch(()=>{}),u}return{status:"controlled",botId:l,snapshot:o}}async function F(r,e){return e?(await r.setInteractive(null).catch(()=>{}),r.release(e)):null}function le(r){return r.filter(e=>e.computer==="vm"&&e.hidden!==!0).map(e=>e.id)}function ye(r,e){const l=le(r),t=l.includes(e)?e:l[0]??null;return[t,l.find(o=>o!==t)??null]}function ge(r,e,l){const t=[...r],o=e===0?1:0;return l&&t[o]===l&&(t[o]=t[e]),t[e]=l,t}function ke(r,e){const l=le(e),t=new Set(l),o=[null,null];for(const u of[0,1]){const p=r[u];p&&t.delete(p)&&(o[u]=p)}for(const u of[0,1]){if(o[u])continue;const p=[...t][0];p&&(o[u]=p,t.delete(p))}return o}const Ne=oe({mode:I(["shared","per-bot","pool"]).optional(),max_instances:he().int().positive().optional(),container:I(["running","stopped","missing"]).optional(),network:I(["loopback","unsafe","unknown"]).optional(),security:I(["hardened","unsafe","unknown"]).optional(),persistence:I(["durable","unsafe","unknown"]).optional(),desktopReady:M().optional(),ready:M().optional(),viewer_url:ae().min(1).optional()});function ue(r){const e=Ne.safeParse(r);return e.success?e.data:null}function D(r){const e=ue(r),l=e?.mode??"unknown",t=e?.container??"unknown",o=e?.network??"unknown",u=e?.security??"unknown",p=e?.persistence??"unknown",h=e?.max_instances??0,g=e?.desktopReady===!0,v=!!(e?.ready===!0&&t==="running"&&o==="loopback"&&u==="hardened"&&p==="durable"&&g);return{mode:l,maxInstances:h,container:t,network:o,security:u,persistence:p,desktopReady:g,ready:v}}function Ce(r){const e=ue(r);return!e||!D(r).ready?null:e.viewer_url??null}const U=["local-vm-workspace:left","local-vm-workspace:right"],de=oe({held:M(),helpReason:ae().nullable(),owned:M().optional(),acquired:M().optional(),released:M().optional()});async function te(r,e,l){const t=await P(`/api/bots/${r}/computer/control`,{method:"POST",body:JSON.stringify({action:e,controlLeaseId:l})}),o=de.safeParse(t);if(!o.success)throw new Error("invalid-control-snapshot");return o.data}async function je(r){const e=de.safeParse(await P(`/api/bots/${r}/computer/control`));if(!e.success)throw new Error("invalid-control-snapshot");return e.data}function ne(r,e){fetch(`/api/bots/${r}/computer/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:e}),keepalive:!0}).then(async l=>{l.ok}).catch(()=>{})}async function re(r,e){return!0}function H(r,e,l){r({type:"computerControl",botId:e,held:l.held,helpReason:l.helpReason})}function se(r){const e=r.current?.getBoundingClientRect();return!e||e.width<1||e.height<1?null:{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}}const Le=['[aria-modal="true"]','[role="dialog"]','[role="menu"]',"[popover]","[data-native-view-overlay]",".fixed",".absolute"].join(",");function Se(){const r=[...document.querySelectorAll("[data-native-view-host]")],e=r.map(t=>t.getBoundingClientRect()).filter(t=>t.width>0&&t.height>0);if(e.length===0)return!1;const l=[...document.querySelectorAll(Le)].filter(t=>!r.some(o=>t===o||t.contains(o)||o.contains(t))).map(t=>{const o=window.getComputedStyle(t),u=t.matches('[aria-modal="true"], [role="dialog"], [role="menu"], [popover], [data-native-view-overlay]'),p=Number.parseInt(o.zIndex,10);return{rect:t.getBoundingClientRect(),explicit:u,visible:o.display!=="none"&&o.visibility!=="hidden"&&Number(o.opacity)!==0,zIndex:Number.isFinite(p)?p:null}});return xe(e,l)}function Re(r){const[e,l]=i.useState(!1);return i.useEffect(()=>{let t=0;const o=()=>l(Se()),u=()=>{t||(t=requestAnimationFrame(()=>{t=0,o()}))};o();const p=new MutationObserver(u);p.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","aria-hidden","aria-modal","role","open","popover"]});const h=new ResizeObserver(u);h.observe(document.body);for(const v of document.querySelectorAll("[data-native-view-host]"))h.observe(v);const g=["toggle","animationstart","animationend","transitionstart","transitionend"];for(const v of g)document.addEventListener(v,u,!0);return window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{t&&cancelAnimationFrame(t),p.disconnect(),h.disconnect();for(const v of g)document.removeEventListener(v,u,!0);window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[]),r||e}function Ve(r,e){return r?r.container==="missing"?"VM not created":r.container==="stopped"?"VM stopped":r.ready?e==="error"?"Viewer unavailable":e!=="ready"?"Connecting viewer":"Live · watch-only":"VM unavailable":"Checking VM"}function Ee({index:r,bot:e,bots:l,otherBotId:t,obscured:o,active:u,heldElsewhere:p,controlPending:h,onSelect:g,onTake:v,onRelease:W,onOpenComputer:C}){const f=U[r],b=e?.id??null,k=e?.name??"Local VM",x=i.useRef(null),N=i.useRef(Promise.resolve()),z=i.useRef(o),[V,_]=i.useState(0),[w,O]=i.useState(null),[m,j]=i.useState({contextId:f,open:!1,status:"closed",interactive:!1}),[y,E]=i.useState(null),L=i.useCallback(async s=>{if(b)try{const c=await P(`/api/bots/${b}/local-computer`,{signal:s});s?.aborted||O(D(c))}catch{}},[b]),A=i.useRef(L);i.useEffect(()=>{A.current=L},[L]),i.useEffect(()=>{z.current=o},[o]),i.useEffect(()=>window.ogb?.desktopWorkspace?.onState(c=>{c.contextId===f&&(j(c),(c.status==="error"||c.status==="closed")&&A.current())}),[f]),i.useEffect(()=>{const s=window.ogb?.desktopWorkspace;let c=!0;const R=new AbortController;O(null),E(null),j({contextId:f,open:!1,status:"closed",interactive:!1});const T=async()=>{if(s&&await s.close(f).catch(()=>{}),!(!c||!b)){if(!s){E("The two-desktop view requires the OpenMausBot desktop app.");return}try{const B=await P(`/api/bots/${b}/local-computer`,{signal:R.signal});if(!c)return;const J=D(B);O(J);const X=Ce(B);if(!J.ready||!X||(await new Promise(fe=>{let G=!1;const Q=()=>{G||(G=!0,fe())},pe=setTimeout(Q,100);requestAnimationFrame(()=>{clearTimeout(pe),Q()})}),!c))return;const $=se(x);if(!$)throw new Error("layout-unavailable");const Y=await s.open({contextId:f,url:X,title:`${k}'s Local VM`,bounds:$});if(!c){await s.close(f).catch(()=>{});return}j(Y),await s.layout([{contextId:f,bounds:$,visible:!z.current&&Y.open}])}catch(B){if(!c||R.signal.aborted)return;E(B instanceof Error&&B.message==="layout-unavailable"?"The viewer area is not laid out yet. Retry after resizing the window.":"OpenMausBot could not connect this Local VM viewer.")}}};return N.current=N.current.catch(()=>{}).then(T),()=>{c=!1,R.abort(),s&&(N.current=N.current.catch(()=>{}).then(()=>s.close(f).then(()=>{}).catch(()=>{})))}},[b,k,f,V]),i.useEffect(()=>{if(!b)return;const s=new AbortController,c=window.setInterval(()=>{L(s.signal)},3e4);return()=>{s.abort(),window.clearInterval(c)}},[b,L]);const S=i.useCallback(()=>{const s=window.ogb?.desktopWorkspace,c=se(x);!s||!c||!m.open||s.layout([{contextId:f,bounds:c,visible:!o}]).catch(()=>E("OpenMausBot could not position this Local VM viewer."))},[f,m.open,o]);i.useEffect(()=>{const s=x.current;if(!s)return;const c=new ResizeObserver(S);c.observe(s),window.addEventListener("resize",S);const R=requestAnimationFrame(S);return()=>{cancelAnimationFrame(R),c.disconnect(),window.removeEventListener("resize",S)}},[S]);const n=Ve(w,m.status),d=!!(e&&w?.ready&&m.status==="ready"&&m.open);return a.jsxs("section",{className:K("flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border bg-panel",u?"border-accent/80 shadow-[0_0_0_1px_rgb(var(--accent)/0.35)]":"border-hairline/50"),children:[a.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 border-b border-hairline/40 px-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("label",{className:"sr-only",htmlFor:`local-vm-slot-${r}`,children:["Local VM for pane ",r+1]}),a.jsxs("select",{id:`local-vm-slot-${r}`,value:e?.id??"",onChange:s=>g(s.target.value||null),disabled:h,className:"w-full truncate rounded-lg border border-hairline/50 bg-card px-2.5 py-1.5 text-[13px] font-medium text-ink outline-none focus:border-accent/70",children:[a.jsx("option",{value:"",children:"Choose a Local VM bot"}),l.map(s=>a.jsx("option",{value:s.id,disabled:s.id===t,children:s.name},s.id))]}),a.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-ink-secondary",children:[a.jsx("span",{className:K("h-1.5 w-1.5 rounded-full",u?"bg-accent":m.status==="ready"?"bg-success":m.status==="error"?"bg-danger":"bg-ink-secondary/50")}),u?"You have control":p?"Control held elsewhere":n]})]}),e&&u?a.jsxs("button",{type:"button",onClick:W,disabled:h,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[h?a.jsx(q,{size:13,className:"animate-spin"}):a.jsx(Z,{size:13}),"Hand back"]}):e?a.jsxs("button",{type:"button",onClick:()=>v(e.id),disabled:!d||h||p,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-raised px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-45",title:"Pause only this bot and enable keyboard and pointer input in this pane",children:[h?a.jsx(q,{size:13,className:"animate-spin"}):a.jsx(Z,{size:13}),p?"Held elsewhere":"Take control"]}):null]}),a.jsx("div",{ref:x,"data-native-view-host":!0,className:"relative min-h-0 flex-1 bg-[#070707]",children:a.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:e?!w&&!y?a.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[a.jsx(q,{size:15,className:"animate-spin"})," Checking ",e.name,"'s VM…"]}):w?.ready&&m.status!=="error"&&!y?a.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[a.jsx(q,{size:15,className:"animate-spin"})," Connecting live view…"]}):a.jsxs("div",{className:"flex max-w-[300px] flex-col items-center gap-3 text-ink-secondary",children:[a.jsx(ce,{size:21,className:"text-warning"}),a.jsx("div",{className:"text-[12px] leading-relaxed",children:y??(w?.container==="missing"?`${e.name}'s Local VM has not been created.`:w?.container==="stopped"?`${e.name}'s Local VM is stopped.`:`${e.name}'s Local VM is not ready for a live view.`)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>_(s=>s+1),className:"flex items-center gap-1.5 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[a.jsx(we,{size:13})," Retry status"]}),a.jsx("button",{type:"button",onClick:()=>C(e.id),className:"rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:"Open Computer"})]})]}):a.jsxs("div",{className:"flex max-w-[260px] flex-col items-center gap-2 text-ink-secondary",children:[a.jsx(ie,{size:22}),a.jsx("span",{className:"text-[12px]",children:"Choose another bot configured for a Local VM."})]})})})]})}function Oe({primaryBotId:r,overlayOpen:e,onClose:l,onOpenComputer:t}){const{state:o,dispatch:u}=me(),p=i.useMemo(()=>o.bots.filter(n=>n.computer==="vm"&&!n.hidden),[o.bots]),[h,g]=i.useState(()=>ye(o.bots,r)),v=i.useRef(h),[W,C]=i.useState(null),f=i.useRef(null),b=i.useRef(null),k=b.current??crypto.randomUUID();b.current=k;const x=i.useRef(!1),N=i.useRef(!0),[z,V]=i.useState(!1),[_,w]=i.useState(null),O=Re(e);i.useEffect(()=>{v.current=h},[h]);const m=i.useMemo(()=>({async take(n){const d=await ee({action:"take",syncNativeBrowser:!0,requestControl:s=>te(n,s,k),setNativeBrowserControl:s=>re()});return H(u,n,d),d.held&&d.owned===!0?f.current=n:f.current===n&&(f.current=null),d},async release(n){const d=await ee({action:"release",syncNativeBrowser:!0,requestControl:s=>te(n,s,k),setNativeBrowserControl:s=>re()});return H(u,n,d),f.current===n&&(f.current=null),d},async setInteractive(n){const d=window.ogb?.desktopWorkspace;if(!d)throw new Error("The two-desktop view bridge is unavailable");return d.setInteractive(n)}}),[k,u]);i.useEffect(()=>{g(n=>{const d=ke(n,o.bots);return d[0]===n[0]&&d[1]===n[1]?n:d})},[o.bots]),i.useEffect(()=>{let n=!0;return(async()=>{for(const s of h)if(s)try{const c=await je(s);n&&H(u,s,c)}catch{}})(),()=>{n=!1}},[u,h]),i.useEffect(()=>{const n=f.current;!n||h.includes(n)||F(m,n).then(()=>{C(null)}).catch(()=>{w("The removed pane could not hand control back safely.")})},[m,h]),i.useEffect(()=>(N.current=!0,()=>{N.current=!1;const n=f.current,d=window.ogb?.desktopWorkspace;if(!d){n&&ne(n,k);return}d.setInteractive(null).catch(()=>{}).then(()=>(n&&ne(n,k),d.close())).catch(()=>{})}),[k]);const j=i.useCallback(n=>{const d=v.current.indexOf(n);return d<0?null:U[d]},[]),y=i.useCallback(async()=>{const n=f.current;if(!n)return!0;if(x.current)return!1;x.current=!0,V(!0),w(null);try{return await F(m,n),C(null),!0}catch{return w("OpenMausBot could not hand control back. The view stayed open."),!1}finally{x.current=!1,V(!1)}},[m]),E=i.useCallback(async n=>{if(x.current||f.current===n)return;const d=window.ogb?.desktopWorkspace,s=j(n);if(!(!d||!s)){x.current=!0,V(!0),w(null);try{const c={...m,async setInteractive(T){if(T&&j(n)!==T)throw new Error("The Local VM pane changed during control acquisition");return m.setInteractive(T)}},R=await be(c,f.current,n,s);if(C(null),R.status==="held-elsewhere"){w("This VM is already controlled in another viewer. Hand it back there first.");return}if(!N.current){await F(m,n).catch(()=>{});return}C(n)}catch{C(f.current),w("Control could not switch safely. Any remaining hold stayed paused.")}finally{x.current=!1,V(!1)}}},[j,m]),L=i.useCallback(async(n,d)=>{if(x.current)return;const s=v.current[n];s!==d&&(s&&f.current===s&&!await y()||g(c=>ge(c,n,d)))},[y]),A=i.useCallback(async()=>{f.current&&!await y()||l()},[y,l]),S=i.useCallback(async n=>{f.current&&!await y()||t(n)},[y,t]);return a.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app",children:[a.jsxs("header",{className:"flex min-h-[60px] items-center gap-3 border-b border-hairline/40 px-5 py-3",children:[a.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:a.jsx(ie,{size:18})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h1",{className:"truncate text-[14px] font-semibold text-ink",children:"Local VM view"}),a.jsx("p",{className:"truncate text-[11.5px] text-ink-secondary",children:"Two live desktops · one active controller · watch-only by default"})]}),a.jsx("button",{type:"button",onClick:()=>{A()},disabled:z,className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":"Close Local VM view",children:a.jsx(ve,{size:18})})]}),_&&a.jsxs("div",{className:"mx-3 mt-3 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[a.jsx(ce,{size:14,className:"shrink-0"})," ",_]}),a.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-3 p-3",children:[0,1].map(n=>{const d=h[n],s=p.find(c=>c.id===d)??null;return a.jsx(Ee,{index:n,bot:s,bots:p,otherBotId:h[n===0?1:0],obscured:O,active:!!(s&&W===s.id),heldElsewhere:!!(s&&o.computerControl[s.id]?.held&&W!==s.id),controlPending:z,onSelect:c=>{L(n,c)},onTake:c=>{E(c)},onRelease:()=>{y()},onOpenComputer:c=>{S(c)}},U[n])})})]})}export{Oe as LocalVmWorkspace};
1
+ import{D as oe,G as ae,H as M,J as I,N as he,u as me,r as i,j as a,M as ie,X as ve,O as ce,g as P,c as K,d as q,Q as Z,R as we}from"./index-CyM91z0J.js";import{t as ee}from"./computer-control-NLov352p.js";function xe(r,e){const l=(t,o)=>t.left<o.right&&t.right>o.left&&t.top<o.bottom&&t.bottom>o.top;return e.some(t=>t.visible&&t.rect.width>0&&t.rect.height>0&&(t.explicit||t.zIndex!==null&&t.zIndex>=10)&&r.some(o=>l(t.rect,o)))}async function be(r,e,l,t){e&&e!==l&&(await r.setInteractive(null),await r.release(e));const o=await r.take(l);if(!o.held)throw new Error("The Local VM control hold was not acquired");if(o.owned!==!0)return{status:"held-elsewhere",botId:l,snapshot:o};try{await r.setInteractive(t)}catch(u){throw await r.setInteractive(null).catch(()=>{}),await r.release(l).catch(()=>{}),u}return{status:"controlled",botId:l,snapshot:o}}async function F(r,e){return e?(await r.setInteractive(null).catch(()=>{}),r.release(e)):null}function le(r){return r.filter(e=>e.computer==="vm"&&e.hidden!==!0).map(e=>e.id)}function ye(r,e){const l=le(r),t=l.includes(e)?e:l[0]??null;return[t,l.find(o=>o!==t)??null]}function ge(r,e,l){const t=[...r],o=e===0?1:0;return l&&t[o]===l&&(t[o]=t[e]),t[e]=l,t}function ke(r,e){const l=le(e),t=new Set(l),o=[null,null];for(const u of[0,1]){const p=r[u];p&&t.delete(p)&&(o[u]=p)}for(const u of[0,1]){if(o[u])continue;const p=[...t][0];p&&(o[u]=p,t.delete(p))}return o}const Ne=oe({mode:I(["shared","per-bot","pool"]).optional(),max_instances:he().int().positive().optional(),container:I(["running","stopped","missing"]).optional(),network:I(["loopback","unsafe","unknown"]).optional(),security:I(["hardened","unsafe","unknown"]).optional(),persistence:I(["durable","unsafe","unknown"]).optional(),desktopReady:M().optional(),ready:M().optional(),viewer_url:ae().min(1).optional()});function ue(r){const e=Ne.safeParse(r);return e.success?e.data:null}function D(r){const e=ue(r),l=e?.mode??"unknown",t=e?.container??"unknown",o=e?.network??"unknown",u=e?.security??"unknown",p=e?.persistence??"unknown",h=e?.max_instances??0,g=e?.desktopReady===!0,v=!!(e?.ready===!0&&t==="running"&&o==="loopback"&&u==="hardened"&&p==="durable"&&g);return{mode:l,maxInstances:h,container:t,network:o,security:u,persistence:p,desktopReady:g,ready:v}}function Ce(r){const e=ue(r);return!e||!D(r).ready?null:e.viewer_url??null}const U=["local-vm-workspace:left","local-vm-workspace:right"],de=oe({held:M(),helpReason:ae().nullable(),owned:M().optional(),acquired:M().optional(),released:M().optional()});async function te(r,e,l){const t=await P(`/api/bots/${r}/computer/control`,{method:"POST",body:JSON.stringify({action:e,controlLeaseId:l})}),o=de.safeParse(t);if(!o.success)throw new Error("invalid-control-snapshot");return o.data}async function je(r){const e=de.safeParse(await P(`/api/bots/${r}/computer/control`));if(!e.success)throw new Error("invalid-control-snapshot");return e.data}function ne(r,e){fetch(`/api/bots/${r}/computer/control`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"release",controlLeaseId:e}),keepalive:!0}).then(async l=>{l.ok}).catch(()=>{})}async function re(r,e){return!0}function H(r,e,l){r({type:"computerControl",botId:e,held:l.held,helpReason:l.helpReason})}function se(r){const e=r.current?.getBoundingClientRect();return!e||e.width<1||e.height<1?null:{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}}const Le=['[aria-modal="true"]','[role="dialog"]','[role="menu"]',"[popover]","[data-native-view-overlay]",".fixed",".absolute"].join(",");function Se(){const r=[...document.querySelectorAll("[data-native-view-host]")],e=r.map(t=>t.getBoundingClientRect()).filter(t=>t.width>0&&t.height>0);if(e.length===0)return!1;const l=[...document.querySelectorAll(Le)].filter(t=>!r.some(o=>t===o||t.contains(o)||o.contains(t))).map(t=>{const o=window.getComputedStyle(t),u=t.matches('[aria-modal="true"], [role="dialog"], [role="menu"], [popover], [data-native-view-overlay]'),p=Number.parseInt(o.zIndex,10);return{rect:t.getBoundingClientRect(),explicit:u,visible:o.display!=="none"&&o.visibility!=="hidden"&&Number(o.opacity)!==0,zIndex:Number.isFinite(p)?p:null}});return xe(e,l)}function Re(r){const[e,l]=i.useState(!1);return i.useEffect(()=>{let t=0;const o=()=>l(Se()),u=()=>{t||(t=requestAnimationFrame(()=>{t=0,o()}))};o();const p=new MutationObserver(u);p.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","aria-hidden","aria-modal","role","open","popover"]});const h=new ResizeObserver(u);h.observe(document.body);for(const v of document.querySelectorAll("[data-native-view-host]"))h.observe(v);const g=["toggle","animationstart","animationend","transitionstart","transitionend"];for(const v of g)document.addEventListener(v,u,!0);return window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{t&&cancelAnimationFrame(t),p.disconnect(),h.disconnect();for(const v of g)document.removeEventListener(v,u,!0);window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[]),r||e}function Ve(r,e){return r?r.container==="missing"?"VM not created":r.container==="stopped"?"VM stopped":r.ready?e==="error"?"Viewer unavailable":e!=="ready"?"Connecting viewer":"Live · watch-only":"VM unavailable":"Checking VM"}function Ee({index:r,bot:e,bots:l,otherBotId:t,obscured:o,active:u,heldElsewhere:p,controlPending:h,onSelect:g,onTake:v,onRelease:W,onOpenComputer:C}){const f=U[r],b=e?.id??null,k=e?.name??"Local VM",x=i.useRef(null),N=i.useRef(Promise.resolve()),z=i.useRef(o),[V,_]=i.useState(0),[w,O]=i.useState(null),[m,j]=i.useState({contextId:f,open:!1,status:"closed",interactive:!1}),[y,E]=i.useState(null),L=i.useCallback(async s=>{if(b)try{const c=await P(`/api/bots/${b}/local-computer`,{signal:s});s?.aborted||O(D(c))}catch{}},[b]),A=i.useRef(L);i.useEffect(()=>{A.current=L},[L]),i.useEffect(()=>{z.current=o},[o]),i.useEffect(()=>window.ogb?.desktopWorkspace?.onState(c=>{c.contextId===f&&(j(c),(c.status==="error"||c.status==="closed")&&A.current())}),[f]),i.useEffect(()=>{const s=window.ogb?.desktopWorkspace;let c=!0;const R=new AbortController;O(null),E(null),j({contextId:f,open:!1,status:"closed",interactive:!1});const T=async()=>{if(s&&await s.close(f).catch(()=>{}),!(!c||!b)){if(!s){E("The two-desktop view requires the OpenMausBot desktop app.");return}try{const B=await P(`/api/bots/${b}/local-computer`,{signal:R.signal});if(!c)return;const J=D(B);O(J);const X=Ce(B);if(!J.ready||!X||(await new Promise(fe=>{let G=!1;const Q=()=>{G||(G=!0,fe())},pe=setTimeout(Q,100);requestAnimationFrame(()=>{clearTimeout(pe),Q()})}),!c))return;const $=se(x);if(!$)throw new Error("layout-unavailable");const Y=await s.open({contextId:f,url:X,title:`${k}'s Local VM`,bounds:$});if(!c){await s.close(f).catch(()=>{});return}j(Y),await s.layout([{contextId:f,bounds:$,visible:!z.current&&Y.open}])}catch(B){if(!c||R.signal.aborted)return;E(B instanceof Error&&B.message==="layout-unavailable"?"The viewer area is not laid out yet. Retry after resizing the window.":"OpenMausBot could not connect this Local VM viewer.")}}};return N.current=N.current.catch(()=>{}).then(T),()=>{c=!1,R.abort(),s&&(N.current=N.current.catch(()=>{}).then(()=>s.close(f).then(()=>{}).catch(()=>{})))}},[b,k,f,V]),i.useEffect(()=>{if(!b)return;const s=new AbortController,c=window.setInterval(()=>{L(s.signal)},3e4);return()=>{s.abort(),window.clearInterval(c)}},[b,L]);const S=i.useCallback(()=>{const s=window.ogb?.desktopWorkspace,c=se(x);!s||!c||!m.open||s.layout([{contextId:f,bounds:c,visible:!o}]).catch(()=>E("OpenMausBot could not position this Local VM viewer."))},[f,m.open,o]);i.useEffect(()=>{const s=x.current;if(!s)return;const c=new ResizeObserver(S);c.observe(s),window.addEventListener("resize",S);const R=requestAnimationFrame(S);return()=>{cancelAnimationFrame(R),c.disconnect(),window.removeEventListener("resize",S)}},[S]);const n=Ve(w,m.status),d=!!(e&&w?.ready&&m.status==="ready"&&m.open);return a.jsxs("section",{className:K("flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border bg-panel",u?"border-accent/80 shadow-[0_0_0_1px_rgb(var(--accent)/0.35)]":"border-hairline/50"),children:[a.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 border-b border-hairline/40 px-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("label",{className:"sr-only",htmlFor:`local-vm-slot-${r}`,children:["Local VM for pane ",r+1]}),a.jsxs("select",{id:`local-vm-slot-${r}`,value:e?.id??"",onChange:s=>g(s.target.value||null),disabled:h,className:"w-full truncate rounded-lg border border-hairline/50 bg-card px-2.5 py-1.5 text-[13px] font-medium text-ink outline-none focus:border-accent/70",children:[a.jsx("option",{value:"",children:"Choose a Local VM bot"}),l.map(s=>a.jsx("option",{value:s.id,disabled:s.id===t,children:s.name},s.id))]}),a.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-ink-secondary",children:[a.jsx("span",{className:K("h-1.5 w-1.5 rounded-full",u?"bg-accent":m.status==="ready"?"bg-success":m.status==="error"?"bg-danger":"bg-ink-secondary/50")}),u?"You have control":p?"Control held elsewhere":n]})]}),e&&u?a.jsxs("button",{type:"button",onClick:W,disabled:h,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:[h?a.jsx(q,{size:13,className:"animate-spin"}):a.jsx(Z,{size:13}),"Hand back"]}):e?a.jsxs("button",{type:"button",onClick:()=>v(e.id),disabled:!d||h||p,className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-raised px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-45",title:"Pause only this bot and enable keyboard and pointer input in this pane",children:[h?a.jsx(q,{size:13,className:"animate-spin"}):a.jsx(Z,{size:13}),p?"Held elsewhere":"Take control"]}):null]}),a.jsx("div",{ref:x,"data-native-view-host":!0,className:"relative min-h-0 flex-1 bg-[#070707]",children:a.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center",children:e?!w&&!y?a.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[a.jsx(q,{size:15,className:"animate-spin"})," Checking ",e.name,"'s VM…"]}):w?.ready&&m.status!=="error"&&!y?a.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-ink-secondary",children:[a.jsx(q,{size:15,className:"animate-spin"})," Connecting live view…"]}):a.jsxs("div",{className:"flex max-w-[300px] flex-col items-center gap-3 text-ink-secondary",children:[a.jsx(ce,{size:21,className:"text-warning"}),a.jsx("div",{className:"text-[12px] leading-relaxed",children:y??(w?.container==="missing"?`${e.name}'s Local VM has not been created.`:w?.container==="stopped"?`${e.name}'s Local VM is stopped.`:`${e.name}'s Local VM is not ready for a live view.`)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>_(s=>s+1),className:"flex items-center gap-1.5 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:[a.jsx(we,{size:13})," Retry status"]}),a.jsx("button",{type:"button",onClick:()=>C(e.id),className:"rounded-lg bg-raised px-3 py-2 text-[12px] text-ink hover:bg-raised-hover",children:"Open Computer"})]})]}):a.jsxs("div",{className:"flex max-w-[260px] flex-col items-center gap-2 text-ink-secondary",children:[a.jsx(ie,{size:22}),a.jsx("span",{className:"text-[12px]",children:"Choose another bot configured for a Local VM."})]})})})]})}function Oe({primaryBotId:r,overlayOpen:e,onClose:l,onOpenComputer:t}){const{state:o,dispatch:u}=me(),p=i.useMemo(()=>o.bots.filter(n=>n.computer==="vm"&&!n.hidden),[o.bots]),[h,g]=i.useState(()=>ye(o.bots,r)),v=i.useRef(h),[W,C]=i.useState(null),f=i.useRef(null),b=i.useRef(null),k=b.current??crypto.randomUUID();b.current=k;const x=i.useRef(!1),N=i.useRef(!0),[z,V]=i.useState(!1),[_,w]=i.useState(null),O=Re(e);i.useEffect(()=>{v.current=h},[h]);const m=i.useMemo(()=>({async take(n){const d=await ee({action:"take",syncNativeBrowser:!0,requestControl:s=>te(n,s,k),setNativeBrowserControl:s=>re()});return H(u,n,d),d.held&&d.owned===!0?f.current=n:f.current===n&&(f.current=null),d},async release(n){const d=await ee({action:"release",syncNativeBrowser:!0,requestControl:s=>te(n,s,k),setNativeBrowserControl:s=>re()});return H(u,n,d),f.current===n&&(f.current=null),d},async setInteractive(n){const d=window.ogb?.desktopWorkspace;if(!d)throw new Error("The two-desktop view bridge is unavailable");return d.setInteractive(n)}}),[k,u]);i.useEffect(()=>{g(n=>{const d=ke(n,o.bots);return d[0]===n[0]&&d[1]===n[1]?n:d})},[o.bots]),i.useEffect(()=>{let n=!0;return(async()=>{for(const s of h)if(s)try{const c=await je(s);n&&H(u,s,c)}catch{}})(),()=>{n=!1}},[u,h]),i.useEffect(()=>{const n=f.current;!n||h.includes(n)||F(m,n).then(()=>{C(null)}).catch(()=>{w("The removed pane could not hand control back safely.")})},[m,h]),i.useEffect(()=>(N.current=!0,()=>{N.current=!1;const n=f.current,d=window.ogb?.desktopWorkspace;if(!d){n&&ne(n,k);return}d.setInteractive(null).catch(()=>{}).then(()=>(n&&ne(n,k),d.close())).catch(()=>{})}),[k]);const j=i.useCallback(n=>{const d=v.current.indexOf(n);return d<0?null:U[d]},[]),y=i.useCallback(async()=>{const n=f.current;if(!n)return!0;if(x.current)return!1;x.current=!0,V(!0),w(null);try{return await F(m,n),C(null),!0}catch{return w("OpenMausBot could not hand control back. The view stayed open."),!1}finally{x.current=!1,V(!1)}},[m]),E=i.useCallback(async n=>{if(x.current||f.current===n)return;const d=window.ogb?.desktopWorkspace,s=j(n);if(!(!d||!s)){x.current=!0,V(!0),w(null);try{const c={...m,async setInteractive(T){if(T&&j(n)!==T)throw new Error("The Local VM pane changed during control acquisition");return m.setInteractive(T)}},R=await be(c,f.current,n,s);if(C(null),R.status==="held-elsewhere"){w("This VM is already controlled in another viewer. Hand it back there first.");return}if(!N.current){await F(m,n).catch(()=>{});return}C(n)}catch{C(f.current),w("Control could not switch safely. Any remaining hold stayed paused.")}finally{x.current=!1,V(!1)}}},[j,m]),L=i.useCallback(async(n,d)=>{if(x.current)return;const s=v.current[n];s!==d&&(s&&f.current===s&&!await y()||g(c=>ge(c,n,d)))},[y]),A=i.useCallback(async()=>{f.current&&!await y()||l()},[y,l]),S=i.useCallback(async n=>{f.current&&!await y()||t(n)},[y,t]);return a.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app",children:[a.jsxs("header",{className:"flex min-h-[60px] items-center gap-3 border-b border-hairline/40 px-5 py-3",children:[a.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-accent/15 text-accent",children:a.jsx(ie,{size:18})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h1",{className:"truncate text-[14px] font-semibold text-ink",children:"Local VM view"}),a.jsx("p",{className:"truncate text-[11.5px] text-ink-secondary",children:"Two live desktops · one active controller · watch-only by default"})]}),a.jsx("button",{type:"button",onClick:()=>{A()},disabled:z,className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50","aria-label":"Close Local VM view",children:a.jsx(ve,{size:18})})]}),_&&a.jsxs("div",{className:"mx-3 mt-3 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[12px] text-danger",children:[a.jsx(ce,{size:14,className:"shrink-0"})," ",_]}),a.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-2 gap-3 p-3",children:[0,1].map(n=>{const d=h[n],s=p.find(c=>c.id===d)??null;return a.jsx(Ee,{index:n,bot:s,bots:p,otherBotId:h[n===0?1:0],obscured:O,active:!!(s&&W===s.id),heldElsewhere:!!(s&&o.computerControl[s.id]?.held&&W!==s.id),controlPending:z,onSelect:c=>{L(n,c)},onTake:c=>{E(c)},onRelease:()=>{y()},onOpenComputer:c=>{S(c)}},U[n])})})]})}export{Oe as LocalVmWorkspace};
@@ -1 +1 @@
1
- import{m as H,u as M,r as o,j as e,c as G,t as s,d as T,O as _,g as L,as as Y,at as X,E as Z,p as q,au as ee,av as te,P as se,aw as ne,T as ae,A as F,ax as re,ay as ie,az as oe,aA as le}from"./index-C8xb62XS.js";const ce=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ge=H("moon",ce);const de=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pe=H("shield",de);async function be(t,a,r,c=6e4){const d=Date.now()+c;let x=t;for(;!x.ready&&x.container==="running"&&Date.now()<d;)r.throwIfAborted(),await new Promise((l,u)=>{const i=()=>{window.clearTimeout(h),u(r.reason)},h=window.setTimeout(()=>{r.removeEventListener("abort",i),l()},2e3);r.addEventListener("abort",i,{once:!0})}),x=await a();return r.throwIfAborted(),x}const $={composio:{body:t=>({composio:{apiKey:t}}),flag:t=>t.composio.configured},box:{body:t=>({box:{token:t}}),flag:t=>t.box.configured&&t.box.included!==!0,included:t=>t.box.included===!0},opencodeGo:{body:t=>({opencodeGo:{apiKey:t}}),flag:t=>t.opencodeGo?.configured??!1},anthropic:{body:(t,a)=>({anthropic:{key:t,...a&&t?{everyClaudeBot:!1}:{}}}),flag:t=>t.anthropic?.configured??!1},openai:{body:t=>({openai:{key:t}}),flag:t=>t.openai?.configured??!1},openrouter:{body:t=>({openrouter:{key:t}}),flag:t=>t.openrouter?.configured??!1},openaiCompat:{body:t=>({openaiCompat:{key:t}}),flag:t=>t.openaiCompat?.configured??!1},mistral:{body:t=>({mistral:{key:t}}),flag:t=>t.mistral?.configured??!1},cerebras:{body:t=>({cerebras:{key:t}}),flag:t=>t.cerebras?.configured??!1},xai:{body:t=>({xai:{key:t}}),flag:t=>t.xai?.configured??!1}},ue={composio:"composioApiKey",box:"boxToken",opencodeGo:"opencodeGoApiKey"},me={composio:{labelKey:"keys.composio.label",placeholder:"ak_…",descriptionKey:"keys.composio.desc",href:"https://dashboard.composio.dev",linkLabelKey:"keys.composio.link",optional:!0},box:{labelKey:"keys.boat.label",placeholderKey:"keys.boat.placeholder",descriptionKey:"keys.boat.desc",href:"https://docs.boat.dev/api-keys",linkLabelKey:"keys.boat.link",optional:!0,warningKey:"keys.boat.warning"},opencodeGo:{labelKey:"keys.opencode.label",placeholderKey:"keys.opencode.placeholder",descriptionKey:"keys.opencode.desc",href:"https://opencode.ai/docs/providers/",linkLabelKey:"keys.opencode.link",optional:!0},anthropic:{labelKey:"keys.anthropic.label",placeholder:"sk-ant-…",descriptionKey:"keys.anthropic.desc",href:"https://console.anthropic.com/settings/keys",linkLabelKey:"keys.anthropic.link",optional:!0},openai:{labelKey:"keys.openai.label",placeholder:"sk-…",descriptionKey:"keys.openai.desc",href:"https://platform.openai.com/api-keys",linkLabelKey:"keys.openai.link",optional:!0,noteKey:"keys.openai.note"},openrouter:{labelKey:"keys.openrouter.label",placeholder:"sk-or-v1-…",descriptionKey:"keys.openrouter.desc",href:"https://openrouter.ai/keys",linkLabelKey:"keys.openrouter.link",optional:!0},openaiCompat:{labelKey:"keys.openaiCompat.label",placeholderKey:"keys.openaiCompat.placeholder",descriptionKey:"keys.openaiCompat.desc",href:"https://platform.openai.com/docs/api-reference",linkLabelKey:"keys.openaiCompat.link",optional:!0},mistral:{labelKey:"keys.mistral.label",placeholderKey:"keys.mistral.placeholder",descriptionKey:"keys.mistral.desc",href:"https://console.mistral.ai/api-keys",linkLabelKey:"keys.mistral.link",optional:!0},cerebras:{labelKey:"keys.cerebras.label",placeholder:"csk-…",descriptionKey:"keys.cerebras.desc",href:"https://cloud.cerebras.ai/",linkLabelKey:"keys.cerebras.link",optional:!0},xai:{labelKey:"keys.xai.label",placeholder:"xai-…",descriptionKey:"keys.xai.desc",href:"https://console.x.ai",linkLabelKey:"keys.xai.link",optional:!0}};function Q(t){const a=me[t];return{...a,label:s(a.labelKey),placeholder:a.placeholderKey?s(a.placeholderKey):a.placeholder??"",description:s(a.descriptionKey),linkLabel:s(a.linkLabelKey),warning:a.warningKey?s(a.warningKey):void 0,note:a.noteKey?s(a.noteKey):void 0}}function xe({section:t}){const a=Q(t),[r,c]=o.useState(!1),d=Y(r),x=o.useRef(null),l=o.useRef(null),u=o.useId();return o.useEffect(()=>{if(!r)return;const i=f=>{f.target instanceof Node&&!x.current?.contains(f.target)&&c(!1)},h=f=>{f.key==="Escape"&&(c(!1),l.current?.focus())};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",h),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",h)}},[r]),e.jsxs("div",{ref:x,className:"relative ml-auto",children:[e.jsx("button",{ref:l,type:"button","aria-label":s("keys.aboutAria",{label:a.label}),"aria-expanded":r,"aria-controls":u,onClick:()=>c(i=>!i),className:"flex size-6 items-center justify-center rounded-md text-ink-secondary outline-none transition-colors hover:bg-control hover:text-ink focus-visible:ring-2 focus-visible:ring-accent/70",children:e.jsx(X,{size:14,"aria-hidden":"true"})}),d.shown&&e.jsxs("div",{id:u,role:"group","aria-label":s("keys.helpAria",{label:a.label}),className:G("absolute right-0 z-30 mt-1.5 w-[270px] rounded-xl border border-hairline bg-panel p-3 text-left shadow-2xl",d.className),...d.exitProps,children:[e.jsx("div",{className:"text-[12px] leading-[1.45] text-ink-secondary",children:a.description}),e.jsxs("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",onClick:()=>c(!1),className:"mt-2.5 flex items-center gap-1.5 text-[12px] font-medium text-accent hover:underline focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70",children:[a.linkLabel,e.jsx(Z,{size:12,"aria-hidden":"true"})]})]})]})}function W(t){return t.length>0&&!/\s/.test(t)}function ke({section:t,onSaved:a,testProvider:r}){const{state:c,dispatch:d}=M(),[x,l]=o.useState(""),[u,i]=o.useState(!1),[h,f]=o.useState(null),[y,p]=o.useState(!1),[j,C]=o.useState(null),b=o.useRef(0),S=o.useRef(!1),m=o.useRef(!1),g=c.config?$[t].flag(c.config):!1,K=c.config?$[t].included?.(c.config)===!0:!1,w=!x.trim()&&g,E=Q(t),z=async()=>{if(!r)return;p(!0),C(null);const N=++b.current;try{const k=await L("/api/keys/test",{method:"POST",body:JSON.stringify({provider:r})});if(N!==b.current)return;const B=k.ok?k.check==="authentication"?s("keys.testAuthenticated"):k.models?.length?s("keys.testCatalog",{models:k.models.join(", ")}):s("keys.testCatalogNoModels"):k.reason==="rejected"?s("keys.testRejected"):k.reason==="unreachable"?s("keys.testUnreachable"):s("keys.testUnexpected",{status:String(k.status??"?")});C(`${s("keys.testSaved")} ${B}`)}catch(k){N===b.current&&C(k instanceof Error?k.message:String(k))}finally{N===b.current&&p(!1)}},R=(N=!1)=>{const k=N?"":x.trim();if(S.current||!N&&!k)return;if(!N&&!W(k)){f(s("keys.notAKey"));return}S.current=!0,i(!0),f(null),b.current++,C(null);const B=ue[t];(window.ogb?.setCredential&&B?window.ogb.setCredential(B,k):L("/api/config",{method:"PUT",body:JSON.stringify($[t].body(k,!g))})).then(O=>{d({type:"configStatus",config:O}),l("");const P=$[t].flag(O);a?.(P),k&&P&&z()}).catch(O=>f(O.message)).finally(()=>{S.current=!1,i(!1)})};return o.useEffect(()=>{m.current&&(m.current=!1,R())}),e.jsxs("div",{"data-api-key-row":t,children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx("span",{className:G("size-1.5 rounded-full",g||K?"bg-success":"bg-raised-hover")}),e.jsx("span",{children:E.label}),E.optional&&e.jsx("span",{className:"rounded bg-control px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-ink-secondary",children:s("keys.optional")}),g&&e.jsx("span",{className:"text-[11px] text-ink-secondary",children:s("keys.configured")}),K&&e.jsx("span",{className:"text-[11px] text-ink-secondary",children:s("keys.includedWithCloudPro")}),e.jsx(xe,{section:t})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative w-full",children:[e.jsx("input",{type:"password",value:x,onChange:N=>{b.current++,C(null),f(null),l(N.target.value)},onPaste:()=>{m.current=!0},onBlur:()=>R(),disabled:u,onKeyDown:N=>N.key==="Enter"&&R(),placeholder:g?s("keys.replace"):E.placeholder,"aria-label":E.label,autoComplete:"off",className:"w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 pr-8 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),(u||y)&&e.jsx(T,{size:13,"aria-hidden":"true",className:"absolute right-2.5 top-1/2 -translate-y-1/2 animate-spin text-ink-secondary"})]}),w&&e.jsx("button",{type:"button",onClick:()=>R(!0),disabled:u,className:"flex w-[72px] shrink-0 items-center justify-center rounded-lg bg-control py-2 text-[13px] text-danger hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",title:s("keys.removeKey"),children:s("keys.clear")}),r&&w&&e.jsx("button",{type:"button",onClick:()=>{z()},disabled:y||u,className:"flex shrink-0 items-center justify-center rounded-lg border border-hairline/40 px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised/50 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:y?s("keys.testing"):s("keys.test")})]}),E.warning&&e.jsxs("div",{className:"mt-1.5 flex gap-1.5 text-[11.5px] leading-[1.4] text-warning",children:[e.jsx(_,{size:13,className:"mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{children:E.warning})]}),E.note&&e.jsx("p",{className:"mt-1.5 text-[11.5px] leading-[1.4] text-ink-secondary",children:E.note}),h&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:h}),j&&e.jsx("div",{role:"status",className:"mt-1 text-[12px] text-ink-secondary",children:j})]})}function ve(){const{state:t,dispatch:a}=M(),r=t.config?.opencodeGo?.providerKeys??[],[c,d]=o.useState(""),[x,l]=o.useState(""),[u,i]=o.useState(!1),[h,f]=o.useState(null),[y,p]=o.useState(null),j=u||h!==null,C=(m,g)=>L("/api/config",{method:"PUT",body:JSON.stringify({opencodeGo:{providerKeys:{[m]:g}}})}).then(K=>a({type:"configStatus",config:K})),b=()=>{const m=c.trim().toUpperCase(),g=x.trim();if(!(j||!m||!g)){if(!W(g)){p(s("keys.notAKey"));return}i(!0),p(null),C(m,g).then(()=>{d(""),l("")}).catch(K=>p(K.message)).finally(()=>i(!1))}},S=m=>{j||(f(m),p(null),C(m,"").catch(g=>p(g.message)).finally(()=>f(null)))};return e.jsxs("details",{"data-opencode-provider-keys":!0,className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",open:r.length>0,children:[e.jsx("summary",{className:"cursor-pointer text-[13px] text-ink-secondary",children:s("keys.opencode.otherProviders.title")}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsx("p",{className:"text-[11.5px] leading-relaxed text-ink-secondary",children:s("keys.opencode.otherProviders.hint")}),r.map(m=>e.jsxs("div",{"data-opencode-provider-key":m,className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-success"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:m}),e.jsx("span",{className:"text-[11px] text-ink-secondary",children:s("keys.configured")}),e.jsx("button",{type:"button",onClick:()=>S(m),disabled:j,"aria-label":s("keys.opencode.otherProviders.removeAria",{name:m}),className:"flex w-[72px] shrink-0 items-center justify-center rounded-lg bg-control py-1.5 text-[13px] text-danger hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:h===m?e.jsx(T,{size:13,className:"animate-spin","aria-hidden":"true"}):s("keys.clear")})]},m)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:m=>{p(null),d(m.target.value)},onKeyDown:m=>m.key==="Enter"&&b(),disabled:j,placeholder:"VENICE_API_KEY","aria-label":s("keys.opencode.otherProviders.name"),autoComplete:"off",spellCheck:!1,className:"w-[44%] min-w-0 rounded-lg border border-hairline/40 bg-panel px-3 py-2 font-mono text-[12px] uppercase text-ink placeholder:normal-case placeholder:text-ink-secondary focus:outline-none"}),e.jsx("input",{type:"password",value:x,onChange:m=>{p(null),l(m.target.value)},onKeyDown:m=>m.key==="Enter"&&b(),disabled:j,placeholder:s("keys.opencode.otherProviders.keyPlaceholder"),"aria-label":s("keys.opencode.otherProviders.key"),autoComplete:"off",className:"w-full min-w-0 rounded-lg border border-hairline/40 bg-panel px-3 py-2 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsx("button",{type:"button",onClick:b,disabled:j||!c.trim()||!x.trim(),className:"flex w-[72px] shrink-0 items-center justify-center gap-1.5 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:u?e.jsx(T,{size:13,className:"animate-spin","aria-hidden":"true"}):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:13,"aria-hidden":"true"}),s("common.save")]})})]}),y&&e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:y})]})]})}function je(){const{state:t,dispatch:a}=M(),[r,c]=o.useState(!1),[d,x]=o.useState(null);if(!t.config?.anthropic?.configured)return null;const l=t.config.anthropic.everyClaudeBot===!0,u=()=>{r||(c(!0),x(null),L("/api/config",{method:"PUT",body:JSON.stringify({anthropic:{everyClaudeBot:!l}})}).then(i=>a({type:"configStatus",config:i})).catch(i=>x(i.message)).finally(()=>c(!1)))};return e.jsxs("div",{"data-anthropic-every-claude-bot":!0,className:"-mt-2",children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12.5px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:l,disabled:r,onChange:u,className:"mt-0.5 accent-accent"}),e.jsxs("span",{children:[s("keys.anthropic.everyBot"),e.jsx("span",{className:"block text-[11.5px] leading-[1.4] text-ink-secondary",children:l?s("keys.anthropic.everyBotOn"):s("keys.anthropic.everyBotOff")})]})]}),l&&e.jsxs("div",{className:"mt-1.5 flex gap-1.5 text-[11.5px] leading-[1.4] text-warning",children:[e.jsx(_,{size:13,className:"mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{children:s("keys.anthropic.warning")})]}),d&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:d})]})}function we(){const{state:t,dispatch:a}=M(),[r,c]=o.useState(""),[d,x]=o.useState(!1),[l,u]=o.useState(null),i=!!t.config?.vps?.configured;o.useEffect(()=>{c(t.config?.vps?.sshAlias??"")},[t.config?.vps?.sshAlias]);const h=()=>{d||!r.trim()&&!i||(x(!0),u(null),L("/api/config",{method:"PUT",body:JSON.stringify({vps:{sshAlias:r.trim()}})}).then(f=>{a({type:"configStatus",config:f}),c(f.vps?.sshAlias??"")}).catch(f=>u(f.message)).finally(()=>x(!1)))};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx("span",{className:G("size-1.5 rounded-full",i?"bg-success":"bg-raised-hover")}),e.jsx("span",{children:s("keys.vps.label")}),e.jsx("span",{className:"rounded bg-control px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-ink-secondary",children:s("keys.optional")}),i&&e.jsx("span",{className:"text-[11px] text-success",children:s("keys.connected")})]}),e.jsxs("div",{className:"mb-1.5 text-[12px] leading-relaxed text-ink-secondary",children:[s("keys.vps.descBefore"),e.jsx("a",{href:"https://github.com/milind-soni/OpenMausBot/blob/main/docs/byo-vps.md",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:s("keys.vps.descLink")}),s("keys.vps.descAfter")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:f=>c(f.target.value),onKeyDown:f=>f.key==="Enter"&&h(),placeholder:"my-vps","aria-label":s("keys.vps.aria"),autoComplete:"off",className:"w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsx("button",{onClick:h,disabled:d||!r.trim()&&!i,className:G("flex w-[72px] shrink-0 items-center justify-center gap-1.5 rounded-lg py-2 text-[13px]",!r.trim()&&i?"bg-control text-danger hover:bg-raised-hover":"bg-control text-ink hover:bg-raised-hover","disabled:cursor-not-allowed disabled:opacity-50"),title:!r.trim()&&i?s("keys.vps.removeAlias"):s("common.save"),children:d?e.jsx(T,{size:13,className:"animate-spin"}):!r.trim()&&i?s("keys.clear"):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:13}),s("common.save")]})})]}),l&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:l})]})}function Ne(){const{state:t,dispatch:a}=M(),r=t.config?.openaiCompat?.url??"",[c,d]=o.useState(r),[x,l]=o.useState(!1),[u,i]=o.useState(null),h=o.useRef(!1);o.useEffect(()=>{d(r)},[r]);const f=c.trim()!==r,y=()=>{h.current||!f||(h.current=!0,l(!0),i(null),L("/api/config",{method:"PUT",body:JSON.stringify({openaiCompat:{url:c.trim()}})}).then(p=>a({type:"configStatus",config:p})).catch(p=>i(p.message)).finally(()=>{h.current=!1,l(!1)}))};return e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[13px] text-ink-secondary",children:s("keys.openaiCompat.url")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"url",value:c,onChange:p=>d(p.target.value),onBlur:y,onKeyDown:p=>p.key==="Enter"&&y(),placeholder:"https://api.groq.com/openai/v1","aria-label":s("keys.openaiCompat.url"),spellCheck:!1,className:"w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 pr-8 font-mono text-[12px] text-ink placeholder:text-ink-secondary focus:outline-none"}),x&&e.jsx(T,{size:13,"aria-hidden":"true",className:"absolute right-2.5 top-1/2 -translate-y-1/2 animate-spin text-ink-secondary"})]}),e.jsx("p",{className:"mt-1 text-[11.5px] leading-relaxed text-ink-secondary",children:s("keys.openaiCompat.urlHint")}),u&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:u})]})}function J(t){return t.map(({id:a,name:r})=>({id:a,name:r}))}function fe(t,a){return{browserProfiles:J(a),expectedBrowserProfiles:J(t)}}function ye(){return`profile-${crypto.randomUUID().replaceAll("-","")}`}function V(t,a){const r=t.filter(d=>d.browserProfile===a&&d.busy);if(!r.length)return null;const c=r.map(d=>d.name).join(", ");return r.length===1?s("settings.profiles.busyOne",{names:c}):s("settings.profiles.busyMany",{names:c})}function Ce({bot:t,onProfileChanged:a,disabled:r=!1}){const{state:c,dispatch:d,flushBotPatches:x}=M(),l=c.config?.browserProfiles??[],u=c.bots??[],i=t?u.find(n=>n.id===t.id)??t:void 0,[h,f]=o.useState(null),[y,p]=o.useState(!1),[j,C]=o.useState(""),[b,S]=o.useState(null),[m,g]=o.useState(""),K=o.useId(),w=y||r||h!==!0;o.useEffect(()=>{let n=!0;return ee().then(v=>{n&&f(te(v))}),()=>{n=!1}},[]);const E=async n=>{if(g(n instanceof Error?n.message:s("settings.profiles.saveError")),n instanceof F&&n.status===409)try{const v=await L("/api/config");d({type:"configStatus",config:v})}catch{g(s("settings.profiles.refreshError"))}n instanceof F&&(n.status===401||n.status===403)&&f(!1)},z=async n=>{try{const v=await L("/api/config",{method:"PATCH",body:JSON.stringify(fe(l,n))});return d({type:"configStatus",config:v}),!0}catch(v){return await E(v),!1}},R=async()=>{if(!(w||!j.trim()||l.length>=20)){p(!0),g("");try{await z([...l,{id:ye(),name:j.trim()}])&&C("")}finally{p(!1)}}},N=async()=>{if(!(w||!b?.name.trim())){if(!l.some(n=>n.id===b.id)){g(s("settings.profiles.removed"));return}p(!0),g("");try{await z(l.map(n=>n.id===b.id?{...n,name:b.name.trim()}:n))&&S(null)}finally{p(!1)}}},k=async n=>{if(w)return;const v=V(u,n.id);if(v)return g(v);const D=u.filter(I=>I.browserProfile===n.id),A=D.length?` ${s("settings.profiles.deleteUsers",{names:D.map(I=>I.name).join(", ")})}`:"";if(window.confirm(s("settings.profiles.confirm",{name:n.name,bots:A}))){p(!0),g("");try{await z(l.filter(I=>I.id!==n.id))&&(b?.id===n.id&&S(null),i?.browserProfile===n.id&&a?.())}finally{p(!1)}}},B=async n=>{if(!(w||!i||i.busy||n===(i.browserProfile??""))){p(!0),g("");try{await x(i.id);const v=await L(`/api/bots/${encodeURIComponent(i.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:n||null})});d({type:"botPatched",bot:v.bot}),a?.()}catch(v){await E(v)}finally{p(!1)}}};if(h===!1)return e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("settings.profiles.ownerOnly")});const U="min-w-0 flex-1 rounded-md border border-hairline/40 bg-inset px-2.5 py-2 text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50",O="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",P=i?.browserProfile??"";return e.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":y,children:[i&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:`${K}-profile`,className:"text-[12px] font-medium text-ink",children:s("settings.profiles.browserSession")}),e.jsxs("select",{id:`${K}-profile`,value:P,disabled:w||i.busy,onChange:n=>{B(n.target.value)},className:U,children:[e.jsx("option",{value:"",children:s("settings.profiles.own")}),l.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id)),e.jsx("option",{value:"guest",children:s("settings.profiles.temporary")}),P&&P!=="guest"&&!l.some(n=>n.id===P)?e.jsx("option",{value:P,disabled:!0,children:s("settings.profiles.removed")}):null]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:i.busy?s("settings.profiles.stopToSwitch"):P==="guest"?s("settings.profiles.temporaryHint"):s("settings.profiles.sharedHint")})]}),e.jsxs("details",{open:!i,className:"min-w-0",children:[e.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:s("settings.profiles.manage")}),e.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[e.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:n=>{n.preventDefault(),R()},children:[e.jsx("label",{htmlFor:`${K}-new`,className:"sr-only",children:s("settings.profiles.newName")}),e.jsx("input",{id:`${K}-new`,value:j,onChange:n=>C(n.target.value),maxLength:40,required:!0,disabled:w||l.length>=20,placeholder:s("settings.profiles.newName"),className:U}),e.jsxs("button",{type:"submit",disabled:w||!j.trim()||l.length>=20,className:`${O} flex items-center gap-1`,children:[e.jsx(se,{size:13}),s("settings.profiles.create")]})]}),l.length>=20&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:s("settings.profiles.limit")}),!l.length&&e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("settings.profiles.sharedEmpty")}),e.jsx("div",{className:"divide-y divide-hairline/30",children:l.map(n=>{const v=u.filter(A=>A.browserProfile===n.id).map(A=>A.name),D=V(u,n.id);return e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ne,{size:14,className:"shrink-0 text-ink-secondary"}),b?.id===n.id?e.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:A=>{A.preventDefault(),N()},children:[e.jsx("input",{autoFocus:!0,value:b.name,onChange:A=>S({id:n.id,name:A.target.value}),maxLength:40,required:!0,disabled:w,className:U,"aria-label":s("settings.profiles.nameAria")}),e.jsx("button",{type:"submit",disabled:w||!b.name.trim(),className:O,children:s("common.save")}),e.jsx("button",{type:"button",disabled:y,onClick:()=>S(null),className:O,children:s("common.cancel")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:w,onClick:()=>{S({id:n.id,name:n.name}),g("")},className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-ink hover:underline disabled:opacity-50",title:s("settings.profiles.rename"),children:n.name}),e.jsxs("button",{type:"button",onClick:()=>{k(n)},disabled:w||!!D,title:D??s("settings.profiles.deleteTitle"),"aria-label":`${s("common.delete")} ${n.name}`,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:[e.jsx(ae,{size:13}),s("common.delete")]})]})]}),e.jsx("p",{className:"break-words pl-6 text-[11px] text-ink-secondary",children:v.length?s("settings.profiles.usedBy",{names:v.join(", ")}):s("settings.profiles.notInUse")})]},n.id)})})]})]}),m&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:m})]})}function Se(){const{capabilities:t}=re(),a=t.localComputer.available?null:t.localComputer.message,r=ie(oe(a)),[c,d]=o.useState(!1),[x,l]=o.useState(!1),[u,i]=o.useState(null),h=async()=>{d(!0),i(null);try{await window.ogb?.localControl?.retry()}catch(y){i(y instanceof Error?y.message:String(y))}finally{d(!1)}},f=async()=>{i(null),l(!0);try{await window.ogb?.permOpenSettings?.("accessibility"),await window.ogb?.permOpenSettings?.("screen")}catch(y){l(!1),i(y instanceof Error?y.message:String(y))}};return o.useEffect(()=>{if(!x)return;let y=!1;const p=()=>{y||document.visibilityState==="visible"&&(y=!0,l(!1),h())};return window.addEventListener("focus",p),document.addEventListener("visibilitychange",p),()=>{window.removeEventListener("focus",p),document.removeEventListener("visibilitychange",p)}},[x]),t.host.platform!=="darwin"||t.localComputer.reasonCode==="remote-server"||t.localComputer.available?null:e.jsx("section",{className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pe,{size:16,className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:"Allow control of this computer"}),e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-ink-secondary",children:r??s("computer.mac.permission.generic")}),a&&e.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer",children:s("computer.mac.permission.driverDetail")}),e.jsx("p",{className:"mt-1 break-words",children:a})]}),u&&e.jsxs("div",{className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[e.jsx(_,{size:13,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:u})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r&&a&&e.jsx(le,{reason:a}),!r&&e.jsx("button",{type:"button",onClick:()=>{f()},disabled:c,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12.5px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:"Open System Settings"}),e.jsxs("button",{type:"button",onClick:()=>{h()},disabled:c,className:"inline-flex items-center gap-1.5 rounded-lg border border-hairline/50 px-3 py-1.5 text-[12.5px] font-medium text-ink hover:bg-raised disabled:opacity-50",children:[c&&e.jsx(T,{size:13,className:"animate-spin"}),"Retry"]})]})]})]})})}export{ke as A,Ce as B,ge as M,Ne as O,we as V,Se as a,je as b,ve as c,be as w};
1
+ import{m as H,u as M,r as o,j as e,c as G,t as s,d as T,O as _,g as L,as as Y,at as X,E as Z,p as q,au as ee,av as te,P as se,aw as ne,T as ae,A as F,ax as re,ay as ie,az as oe,aA as le}from"./index-CyM91z0J.js";const ce=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ge=H("moon",ce);const de=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pe=H("shield",de);async function be(t,a,r,c=6e4){const d=Date.now()+c;let x=t;for(;!x.ready&&x.container==="running"&&Date.now()<d;)r.throwIfAborted(),await new Promise((l,u)=>{const i=()=>{window.clearTimeout(h),u(r.reason)},h=window.setTimeout(()=>{r.removeEventListener("abort",i),l()},2e3);r.addEventListener("abort",i,{once:!0})}),x=await a();return r.throwIfAborted(),x}const $={composio:{body:t=>({composio:{apiKey:t}}),flag:t=>t.composio.configured},box:{body:t=>({box:{token:t}}),flag:t=>t.box.configured&&t.box.included!==!0,included:t=>t.box.included===!0},opencodeGo:{body:t=>({opencodeGo:{apiKey:t}}),flag:t=>t.opencodeGo?.configured??!1},anthropic:{body:(t,a)=>({anthropic:{key:t,...a&&t?{everyClaudeBot:!1}:{}}}),flag:t=>t.anthropic?.configured??!1},openai:{body:t=>({openai:{key:t}}),flag:t=>t.openai?.configured??!1},openrouter:{body:t=>({openrouter:{key:t}}),flag:t=>t.openrouter?.configured??!1},openaiCompat:{body:t=>({openaiCompat:{key:t}}),flag:t=>t.openaiCompat?.configured??!1},mistral:{body:t=>({mistral:{key:t}}),flag:t=>t.mistral?.configured??!1},cerebras:{body:t=>({cerebras:{key:t}}),flag:t=>t.cerebras?.configured??!1},xai:{body:t=>({xai:{key:t}}),flag:t=>t.xai?.configured??!1}},ue={composio:"composioApiKey",box:"boxToken",opencodeGo:"opencodeGoApiKey"},me={composio:{labelKey:"keys.composio.label",placeholder:"ak_…",descriptionKey:"keys.composio.desc",href:"https://dashboard.composio.dev",linkLabelKey:"keys.composio.link",optional:!0},box:{labelKey:"keys.boat.label",placeholderKey:"keys.boat.placeholder",descriptionKey:"keys.boat.desc",href:"https://docs.boat.dev/api-keys",linkLabelKey:"keys.boat.link",optional:!0,warningKey:"keys.boat.warning"},opencodeGo:{labelKey:"keys.opencode.label",placeholderKey:"keys.opencode.placeholder",descriptionKey:"keys.opencode.desc",href:"https://opencode.ai/docs/providers/",linkLabelKey:"keys.opencode.link",optional:!0},anthropic:{labelKey:"keys.anthropic.label",placeholder:"sk-ant-…",descriptionKey:"keys.anthropic.desc",href:"https://console.anthropic.com/settings/keys",linkLabelKey:"keys.anthropic.link",optional:!0},openai:{labelKey:"keys.openai.label",placeholder:"sk-…",descriptionKey:"keys.openai.desc",href:"https://platform.openai.com/api-keys",linkLabelKey:"keys.openai.link",optional:!0,noteKey:"keys.openai.note"},openrouter:{labelKey:"keys.openrouter.label",placeholder:"sk-or-v1-…",descriptionKey:"keys.openrouter.desc",href:"https://openrouter.ai/keys",linkLabelKey:"keys.openrouter.link",optional:!0},openaiCompat:{labelKey:"keys.openaiCompat.label",placeholderKey:"keys.openaiCompat.placeholder",descriptionKey:"keys.openaiCompat.desc",href:"https://platform.openai.com/docs/api-reference",linkLabelKey:"keys.openaiCompat.link",optional:!0},mistral:{labelKey:"keys.mistral.label",placeholderKey:"keys.mistral.placeholder",descriptionKey:"keys.mistral.desc",href:"https://console.mistral.ai/api-keys",linkLabelKey:"keys.mistral.link",optional:!0},cerebras:{labelKey:"keys.cerebras.label",placeholder:"csk-…",descriptionKey:"keys.cerebras.desc",href:"https://cloud.cerebras.ai/",linkLabelKey:"keys.cerebras.link",optional:!0},xai:{labelKey:"keys.xai.label",placeholder:"xai-…",descriptionKey:"keys.xai.desc",href:"https://console.x.ai",linkLabelKey:"keys.xai.link",optional:!0}};function Q(t){const a=me[t];return{...a,label:s(a.labelKey),placeholder:a.placeholderKey?s(a.placeholderKey):a.placeholder??"",description:s(a.descriptionKey),linkLabel:s(a.linkLabelKey),warning:a.warningKey?s(a.warningKey):void 0,note:a.noteKey?s(a.noteKey):void 0}}function xe({section:t}){const a=Q(t),[r,c]=o.useState(!1),d=Y(r),x=o.useRef(null),l=o.useRef(null),u=o.useId();return o.useEffect(()=>{if(!r)return;const i=f=>{f.target instanceof Node&&!x.current?.contains(f.target)&&c(!1)},h=f=>{f.key==="Escape"&&(c(!1),l.current?.focus())};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",h),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",h)}},[r]),e.jsxs("div",{ref:x,className:"relative ml-auto",children:[e.jsx("button",{ref:l,type:"button","aria-label":s("keys.aboutAria",{label:a.label}),"aria-expanded":r,"aria-controls":u,onClick:()=>c(i=>!i),className:"flex size-6 items-center justify-center rounded-md text-ink-secondary outline-none transition-colors hover:bg-control hover:text-ink focus-visible:ring-2 focus-visible:ring-accent/70",children:e.jsx(X,{size:14,"aria-hidden":"true"})}),d.shown&&e.jsxs("div",{id:u,role:"group","aria-label":s("keys.helpAria",{label:a.label}),className:G("absolute right-0 z-30 mt-1.5 w-[270px] rounded-xl border border-hairline bg-panel p-3 text-left shadow-2xl",d.className),...d.exitProps,children:[e.jsx("div",{className:"text-[12px] leading-[1.45] text-ink-secondary",children:a.description}),e.jsxs("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",onClick:()=>c(!1),className:"mt-2.5 flex items-center gap-1.5 text-[12px] font-medium text-accent hover:underline focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70",children:[a.linkLabel,e.jsx(Z,{size:12,"aria-hidden":"true"})]})]})]})}function W(t){return t.length>0&&!/\s/.test(t)}function ke({section:t,onSaved:a,testProvider:r}){const{state:c,dispatch:d}=M(),[x,l]=o.useState(""),[u,i]=o.useState(!1),[h,f]=o.useState(null),[y,p]=o.useState(!1),[j,C]=o.useState(null),b=o.useRef(0),S=o.useRef(!1),m=o.useRef(!1),g=c.config?$[t].flag(c.config):!1,K=c.config?$[t].included?.(c.config)===!0:!1,w=!x.trim()&&g,E=Q(t),z=async()=>{if(!r)return;p(!0),C(null);const N=++b.current;try{const k=await L("/api/keys/test",{method:"POST",body:JSON.stringify({provider:r})});if(N!==b.current)return;const B=k.ok?k.check==="authentication"?s("keys.testAuthenticated"):k.models?.length?s("keys.testCatalog",{models:k.models.join(", ")}):s("keys.testCatalogNoModels"):k.reason==="rejected"?s("keys.testRejected"):k.reason==="unreachable"?s("keys.testUnreachable"):s("keys.testUnexpected",{status:String(k.status??"?")});C(`${s("keys.testSaved")} ${B}`)}catch(k){N===b.current&&C(k instanceof Error?k.message:String(k))}finally{N===b.current&&p(!1)}},R=(N=!1)=>{const k=N?"":x.trim();if(S.current||!N&&!k)return;if(!N&&!W(k)){f(s("keys.notAKey"));return}S.current=!0,i(!0),f(null),b.current++,C(null);const B=ue[t];(window.ogb?.setCredential&&B?window.ogb.setCredential(B,k):L("/api/config",{method:"PUT",body:JSON.stringify($[t].body(k,!g))})).then(O=>{d({type:"configStatus",config:O}),l("");const P=$[t].flag(O);a?.(P),k&&P&&z()}).catch(O=>f(O.message)).finally(()=>{S.current=!1,i(!1)})};return o.useEffect(()=>{m.current&&(m.current=!1,R())}),e.jsxs("div",{"data-api-key-row":t,children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx("span",{className:G("size-1.5 rounded-full",g||K?"bg-success":"bg-raised-hover")}),e.jsx("span",{children:E.label}),E.optional&&e.jsx("span",{className:"rounded bg-control px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-ink-secondary",children:s("keys.optional")}),g&&e.jsx("span",{className:"text-[11px] text-ink-secondary",children:s("keys.configured")}),K&&e.jsx("span",{className:"text-[11px] text-ink-secondary",children:s("keys.includedWithCloudPro")}),e.jsx(xe,{section:t})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative w-full",children:[e.jsx("input",{type:"password",value:x,onChange:N=>{b.current++,C(null),f(null),l(N.target.value)},onPaste:()=>{m.current=!0},onBlur:()=>R(),disabled:u,onKeyDown:N=>N.key==="Enter"&&R(),placeholder:g?s("keys.replace"):E.placeholder,"aria-label":E.label,autoComplete:"off",className:"w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 pr-8 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),(u||y)&&e.jsx(T,{size:13,"aria-hidden":"true",className:"absolute right-2.5 top-1/2 -translate-y-1/2 animate-spin text-ink-secondary"})]}),w&&e.jsx("button",{type:"button",onClick:()=>R(!0),disabled:u,className:"flex w-[72px] shrink-0 items-center justify-center rounded-lg bg-control py-2 text-[13px] text-danger hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",title:s("keys.removeKey"),children:s("keys.clear")}),r&&w&&e.jsx("button",{type:"button",onClick:()=>{z()},disabled:y||u,className:"flex shrink-0 items-center justify-center rounded-lg border border-hairline/40 px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised/50 hover:text-ink disabled:cursor-not-allowed disabled:opacity-50",children:y?s("keys.testing"):s("keys.test")})]}),E.warning&&e.jsxs("div",{className:"mt-1.5 flex gap-1.5 text-[11.5px] leading-[1.4] text-warning",children:[e.jsx(_,{size:13,className:"mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{children:E.warning})]}),E.note&&e.jsx("p",{className:"mt-1.5 text-[11.5px] leading-[1.4] text-ink-secondary",children:E.note}),h&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:h}),j&&e.jsx("div",{role:"status",className:"mt-1 text-[12px] text-ink-secondary",children:j})]})}function ve(){const{state:t,dispatch:a}=M(),r=t.config?.opencodeGo?.providerKeys??[],[c,d]=o.useState(""),[x,l]=o.useState(""),[u,i]=o.useState(!1),[h,f]=o.useState(null),[y,p]=o.useState(null),j=u||h!==null,C=(m,g)=>L("/api/config",{method:"PUT",body:JSON.stringify({opencodeGo:{providerKeys:{[m]:g}}})}).then(K=>a({type:"configStatus",config:K})),b=()=>{const m=c.trim().toUpperCase(),g=x.trim();if(!(j||!m||!g)){if(!W(g)){p(s("keys.notAKey"));return}i(!0),p(null),C(m,g).then(()=>{d(""),l("")}).catch(K=>p(K.message)).finally(()=>i(!1))}},S=m=>{j||(f(m),p(null),C(m,"").catch(g=>p(g.message)).finally(()=>f(null)))};return e.jsxs("details",{"data-opencode-provider-keys":!0,className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",open:r.length>0,children:[e.jsx("summary",{className:"cursor-pointer text-[13px] text-ink-secondary",children:s("keys.opencode.otherProviders.title")}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsx("p",{className:"text-[11.5px] leading-relaxed text-ink-secondary",children:s("keys.opencode.otherProviders.hint")}),r.map(m=>e.jsxs("div",{"data-opencode-provider-key":m,className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-success"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:m}),e.jsx("span",{className:"text-[11px] text-ink-secondary",children:s("keys.configured")}),e.jsx("button",{type:"button",onClick:()=>S(m),disabled:j,"aria-label":s("keys.opencode.otherProviders.removeAria",{name:m}),className:"flex w-[72px] shrink-0 items-center justify-center rounded-lg bg-control py-1.5 text-[13px] text-danger hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:h===m?e.jsx(T,{size:13,className:"animate-spin","aria-hidden":"true"}):s("keys.clear")})]},m)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:m=>{p(null),d(m.target.value)},onKeyDown:m=>m.key==="Enter"&&b(),disabled:j,placeholder:"VENICE_API_KEY","aria-label":s("keys.opencode.otherProviders.name"),autoComplete:"off",spellCheck:!1,className:"w-[44%] min-w-0 rounded-lg border border-hairline/40 bg-panel px-3 py-2 font-mono text-[12px] uppercase text-ink placeholder:normal-case placeholder:text-ink-secondary focus:outline-none"}),e.jsx("input",{type:"password",value:x,onChange:m=>{p(null),l(m.target.value)},onKeyDown:m=>m.key==="Enter"&&b(),disabled:j,placeholder:s("keys.opencode.otherProviders.keyPlaceholder"),"aria-label":s("keys.opencode.otherProviders.key"),autoComplete:"off",className:"w-full min-w-0 rounded-lg border border-hairline/40 bg-panel px-3 py-2 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsx("button",{type:"button",onClick:b,disabled:j||!c.trim()||!x.trim(),className:"flex w-[72px] shrink-0 items-center justify-center gap-1.5 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50",children:u?e.jsx(T,{size:13,className:"animate-spin","aria-hidden":"true"}):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:13,"aria-hidden":"true"}),s("common.save")]})})]}),y&&e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:y})]})]})}function je(){const{state:t,dispatch:a}=M(),[r,c]=o.useState(!1),[d,x]=o.useState(null);if(!t.config?.anthropic?.configured)return null;const l=t.config.anthropic.everyClaudeBot===!0,u=()=>{r||(c(!0),x(null),L("/api/config",{method:"PUT",body:JSON.stringify({anthropic:{everyClaudeBot:!l}})}).then(i=>a({type:"configStatus",config:i})).catch(i=>x(i.message)).finally(()=>c(!1)))};return e.jsxs("div",{"data-anthropic-every-claude-bot":!0,className:"-mt-2",children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12.5px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:l,disabled:r,onChange:u,className:"mt-0.5 accent-accent"}),e.jsxs("span",{children:[s("keys.anthropic.everyBot"),e.jsx("span",{className:"block text-[11.5px] leading-[1.4] text-ink-secondary",children:l?s("keys.anthropic.everyBotOn"):s("keys.anthropic.everyBotOff")})]})]}),l&&e.jsxs("div",{className:"mt-1.5 flex gap-1.5 text-[11.5px] leading-[1.4] text-warning",children:[e.jsx(_,{size:13,className:"mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{children:s("keys.anthropic.warning")})]}),d&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:d})]})}function we(){const{state:t,dispatch:a}=M(),[r,c]=o.useState(""),[d,x]=o.useState(!1),[l,u]=o.useState(null),i=!!t.config?.vps?.configured;o.useEffect(()=>{c(t.config?.vps?.sshAlias??"")},[t.config?.vps?.sshAlias]);const h=()=>{d||!r.trim()&&!i||(x(!0),u(null),L("/api/config",{method:"PUT",body:JSON.stringify({vps:{sshAlias:r.trim()}})}).then(f=>{a({type:"configStatus",config:f}),c(f.vps?.sshAlias??"")}).catch(f=>u(f.message)).finally(()=>x(!1)))};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx("span",{className:G("size-1.5 rounded-full",i?"bg-success":"bg-raised-hover")}),e.jsx("span",{children:s("keys.vps.label")}),e.jsx("span",{className:"rounded bg-control px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-ink-secondary",children:s("keys.optional")}),i&&e.jsx("span",{className:"text-[11px] text-success",children:s("keys.connected")})]}),e.jsxs("div",{className:"mb-1.5 text-[12px] leading-relaxed text-ink-secondary",children:[s("keys.vps.descBefore"),e.jsx("a",{href:"https://github.com/milind-soni/OpenMausBot/blob/main/docs/byo-vps.md",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:s("keys.vps.descLink")}),s("keys.vps.descAfter")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:f=>c(f.target.value),onKeyDown:f=>f.key==="Enter"&&h(),placeholder:"my-vps","aria-label":s("keys.vps.aria"),autoComplete:"off",className:"w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"}),e.jsx("button",{onClick:h,disabled:d||!r.trim()&&!i,className:G("flex w-[72px] shrink-0 items-center justify-center gap-1.5 rounded-lg py-2 text-[13px]",!r.trim()&&i?"bg-control text-danger hover:bg-raised-hover":"bg-control text-ink hover:bg-raised-hover","disabled:cursor-not-allowed disabled:opacity-50"),title:!r.trim()&&i?s("keys.vps.removeAlias"):s("common.save"),children:d?e.jsx(T,{size:13,className:"animate-spin"}):!r.trim()&&i?s("keys.clear"):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:13}),s("common.save")]})})]}),l&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:l})]})}function Ne(){const{state:t,dispatch:a}=M(),r=t.config?.openaiCompat?.url??"",[c,d]=o.useState(r),[x,l]=o.useState(!1),[u,i]=o.useState(null),h=o.useRef(!1);o.useEffect(()=>{d(r)},[r]);const f=c.trim()!==r,y=()=>{h.current||!f||(h.current=!0,l(!0),i(null),L("/api/config",{method:"PUT",body:JSON.stringify({openaiCompat:{url:c.trim()}})}).then(p=>a({type:"configStatus",config:p})).catch(p=>i(p.message)).finally(()=>{h.current=!1,l(!1)}))};return e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[13px] text-ink-secondary",children:s("keys.openaiCompat.url")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"url",value:c,onChange:p=>d(p.target.value),onBlur:y,onKeyDown:p=>p.key==="Enter"&&y(),placeholder:"https://api.groq.com/openai/v1","aria-label":s("keys.openaiCompat.url"),spellCheck:!1,className:"w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 pr-8 font-mono text-[12px] text-ink placeholder:text-ink-secondary focus:outline-none"}),x&&e.jsx(T,{size:13,"aria-hidden":"true",className:"absolute right-2.5 top-1/2 -translate-y-1/2 animate-spin text-ink-secondary"})]}),e.jsx("p",{className:"mt-1 text-[11.5px] leading-relaxed text-ink-secondary",children:s("keys.openaiCompat.urlHint")}),u&&e.jsx("div",{className:"mt-1 text-[12px] text-danger",children:u})]})}function J(t){return t.map(({id:a,name:r})=>({id:a,name:r}))}function fe(t,a){return{browserProfiles:J(a),expectedBrowserProfiles:J(t)}}function ye(){return`profile-${crypto.randomUUID().replaceAll("-","")}`}function V(t,a){const r=t.filter(d=>d.browserProfile===a&&d.busy);if(!r.length)return null;const c=r.map(d=>d.name).join(", ");return r.length===1?s("settings.profiles.busyOne",{names:c}):s("settings.profiles.busyMany",{names:c})}function Ce({bot:t,onProfileChanged:a,disabled:r=!1}){const{state:c,dispatch:d,flushBotPatches:x}=M(),l=c.config?.browserProfiles??[],u=c.bots??[],i=t?u.find(n=>n.id===t.id)??t:void 0,[h,f]=o.useState(null),[y,p]=o.useState(!1),[j,C]=o.useState(""),[b,S]=o.useState(null),[m,g]=o.useState(""),K=o.useId(),w=y||r||h!==!0;o.useEffect(()=>{let n=!0;return ee().then(v=>{n&&f(te(v))}),()=>{n=!1}},[]);const E=async n=>{if(g(n instanceof Error?n.message:s("settings.profiles.saveError")),n instanceof F&&n.status===409)try{const v=await L("/api/config");d({type:"configStatus",config:v})}catch{g(s("settings.profiles.refreshError"))}n instanceof F&&(n.status===401||n.status===403)&&f(!1)},z=async n=>{try{const v=await L("/api/config",{method:"PATCH",body:JSON.stringify(fe(l,n))});return d({type:"configStatus",config:v}),!0}catch(v){return await E(v),!1}},R=async()=>{if(!(w||!j.trim()||l.length>=20)){p(!0),g("");try{await z([...l,{id:ye(),name:j.trim()}])&&C("")}finally{p(!1)}}},N=async()=>{if(!(w||!b?.name.trim())){if(!l.some(n=>n.id===b.id)){g(s("settings.profiles.removed"));return}p(!0),g("");try{await z(l.map(n=>n.id===b.id?{...n,name:b.name.trim()}:n))&&S(null)}finally{p(!1)}}},k=async n=>{if(w)return;const v=V(u,n.id);if(v)return g(v);const D=u.filter(I=>I.browserProfile===n.id),A=D.length?` ${s("settings.profiles.deleteUsers",{names:D.map(I=>I.name).join(", ")})}`:"";if(window.confirm(s("settings.profiles.confirm",{name:n.name,bots:A}))){p(!0),g("");try{await z(l.filter(I=>I.id!==n.id))&&(b?.id===n.id&&S(null),i?.browserProfile===n.id&&a?.())}finally{p(!1)}}},B=async n=>{if(!(w||!i||i.busy||n===(i.browserProfile??""))){p(!0),g("");try{await x(i.id);const v=await L(`/api/bots/${encodeURIComponent(i.id)}`,{method:"PATCH",body:JSON.stringify({browserProfile:n||null})});d({type:"botPatched",bot:v.bot}),a?.()}catch(v){await E(v)}finally{p(!1)}}};if(h===!1)return e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("settings.profiles.ownerOnly")});const U="min-w-0 flex-1 rounded-md border border-hairline/40 bg-inset px-2.5 py-2 text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50",O="shrink-0 rounded-md bg-control px-2.5 py-2 text-[12px] text-ink hover:bg-raised-hover disabled:opacity-50",P=i?.browserProfile??"";return e.jsxs("div",{className:"flex min-w-0 flex-col gap-3","aria-busy":y,children:[i&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:`${K}-profile`,className:"text-[12px] font-medium text-ink",children:s("settings.profiles.browserSession")}),e.jsxs("select",{id:`${K}-profile`,value:P,disabled:w||i.busy,onChange:n=>{B(n.target.value)},className:U,children:[e.jsx("option",{value:"",children:s("settings.profiles.own")}),l.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id)),e.jsx("option",{value:"guest",children:s("settings.profiles.temporary")}),P&&P!=="guest"&&!l.some(n=>n.id===P)?e.jsx("option",{value:P,disabled:!0,children:s("settings.profiles.removed")}):null]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-ink-secondary",children:i.busy?s("settings.profiles.stopToSwitch"):P==="guest"?s("settings.profiles.temporaryHint"):s("settings.profiles.sharedHint")})]}),e.jsxs("details",{open:!i,className:"min-w-0",children:[e.jsx("summary",{className:"cursor-pointer text-[12px] font-medium text-ink-secondary hover:text-ink",children:s("settings.profiles.manage")}),e.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[e.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:n=>{n.preventDefault(),R()},children:[e.jsx("label",{htmlFor:`${K}-new`,className:"sr-only",children:s("settings.profiles.newName")}),e.jsx("input",{id:`${K}-new`,value:j,onChange:n=>C(n.target.value),maxLength:40,required:!0,disabled:w||l.length>=20,placeholder:s("settings.profiles.newName"),className:U}),e.jsxs("button",{type:"submit",disabled:w||!j.trim()||l.length>=20,className:`${O} flex items-center gap-1`,children:[e.jsx(se,{size:13}),s("settings.profiles.create")]})]}),l.length>=20&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:s("settings.profiles.limit")}),!l.length&&e.jsx("p",{className:"text-[12px] text-ink-secondary",children:s("settings.profiles.sharedEmpty")}),e.jsx("div",{className:"divide-y divide-hairline/30",children:l.map(n=>{const v=u.filter(A=>A.browserProfile===n.id).map(A=>A.name),D=V(u,n.id);return e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ne,{size:14,className:"shrink-0 text-ink-secondary"}),b?.id===n.id?e.jsxs("form",{className:"flex min-w-0 flex-1 flex-wrap gap-2",onSubmit:A=>{A.preventDefault(),N()},children:[e.jsx("input",{autoFocus:!0,value:b.name,onChange:A=>S({id:n.id,name:A.target.value}),maxLength:40,required:!0,disabled:w,className:U,"aria-label":s("settings.profiles.nameAria")}),e.jsx("button",{type:"submit",disabled:w||!b.name.trim(),className:O,children:s("common.save")}),e.jsx("button",{type:"button",disabled:y,onClick:()=>S(null),className:O,children:s("common.cancel")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:w,onClick:()=>{S({id:n.id,name:n.name}),g("")},className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-ink hover:underline disabled:opacity-50",title:s("settings.profiles.rename"),children:n.name}),e.jsxs("button",{type:"button",onClick:()=>{k(n)},disabled:w||!!D,title:D??s("settings.profiles.deleteTitle"),"aria-label":`${s("common.delete")} ${n.name}`,className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:[e.jsx(ae,{size:13}),s("common.delete")]})]})]}),e.jsx("p",{className:"break-words pl-6 text-[11px] text-ink-secondary",children:v.length?s("settings.profiles.usedBy",{names:v.join(", ")}):s("settings.profiles.notInUse")})]},n.id)})})]})]}),m&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:m})]})}function Se(){const{capabilities:t}=re(),a=t.localComputer.available?null:t.localComputer.message,r=ie(oe(a)),[c,d]=o.useState(!1),[x,l]=o.useState(!1),[u,i]=o.useState(null),h=async()=>{d(!0),i(null);try{await window.ogb?.localControl?.retry()}catch(y){i(y instanceof Error?y.message:String(y))}finally{d(!1)}},f=async()=>{i(null),l(!0);try{await window.ogb?.permOpenSettings?.("accessibility"),await window.ogb?.permOpenSettings?.("screen")}catch(y){l(!1),i(y instanceof Error?y.message:String(y))}};return o.useEffect(()=>{if(!x)return;let y=!1;const p=()=>{y||document.visibilityState==="visible"&&(y=!0,l(!1),h())};return window.addEventListener("focus",p),document.addEventListener("visibilitychange",p),()=>{window.removeEventListener("focus",p),document.removeEventListener("visibilitychange",p)}},[x]),t.host.platform!=="darwin"||t.localComputer.reasonCode==="remote-server"||t.localComputer.available?null:e.jsx("section",{className:"mt-4 rounded-xl border border-warning/25 bg-warning/10 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pe,{size:16,className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:"Allow control of this computer"}),e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-ink-secondary",children:r??s("computer.mac.permission.generic")}),a&&e.jsxs("details",{className:"mt-2 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer",children:s("computer.mac.permission.driverDetail")}),e.jsx("p",{className:"mt-1 break-words",children:a})]}),u&&e.jsxs("div",{className:"mt-2 flex gap-1.5 text-[12px] text-danger",children:[e.jsx(_,{size:13,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:u})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r&&a&&e.jsx(le,{reason:a}),!r&&e.jsx("button",{type:"button",onClick:()=>{f()},disabled:c,className:"inline-flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12.5px] font-medium text-white hover:brightness-110 disabled:opacity-50",children:"Open System Settings"}),e.jsxs("button",{type:"button",onClick:()=>{h()},disabled:c,className:"inline-flex items-center gap-1.5 rounded-lg border border-hairline/50 px-3 py-1.5 text-[12.5px] font-medium text-ink hover:bg-raised disabled:opacity-50",children:[c&&e.jsx(T,{size:13,className:"animate-spin"}),"Retry"]})]})]})]})})}export{ke as A,Ce as B,ge as M,Ne as O,we as V,Se as a,je as b,ve as c,be as w};
@@ -1,2 +1,2 @@
1
- import{g as T,ab as ne,$ as oe,a0 as ie,t as i,r as p,ac as re,ad as le,ae as ce,j as e,X as te,p as de,d as z,af as pe,ag as ue,ah as me,ai as he,u as W,aj as xe,c as J,ak as fe,al as be,am as ge,an as ye,ao as X,P as ve,T as se,ap as we}from"./index-C8xb62XS.js";import{I as ke,i as I,S as je,a as Se,A as Ne,M as Ee,P as Ce,V as Pe,v as Ae}from"./VisibilitySection-DD4ffIR5.js";import{B as Oe,a as Te}from"./RoutinesPage-DOosRYDK.js";import"./image-plus-DNIWU160.js";import"./CloudBackendPicker-C5-_arUz.js";import"./WebhooksPanel-Cz17K-_O.js";const Be={profile:{},memory:{},skills:[],routines:[]},Re=t=>({name:t.name,prompt:t.prompt,schedule:t.schedule,enabled:t.enabled,runOn:t.runOn,durationMinutes:t.durationMinutes,timeoutMinutes:t.timeoutMinutes,overlap:t.overlap,attachments:t.attachments});class Z{constructor(s,a,n=T){this.changed=a,this.network=n,this.template=structuredClone(s),this.routines=s.routines.map(r=>this.routine({...r,botId:this.id}))}changed;network;id=`draft-${crypto.randomUUID()}`;template;consent={};routines;preset;avatarFile;avatarObjectUrl;get bot(){const{computer:s,cwd:a,peers:n,toolScope:r,...o}=this.template.profile;return{id:this.id,threadId:this.id,name:"",title:"",description:"",soul:"",color:"green",notifications:!0,unread:!1,messages:[],modelSelection:{instanceId:"",model:""},...o,computer:s??void 0,cwd:a??void 0,peers:n??void 0,toolScope:r??void 0}}patch(s){const{confirmFullAccess:a,acknowledgeLocalAuto:n,acknowledgePeerScope:r,applyToAllThreads:o,autoApprove:c,...l}=s;a!==void 0&&(this.consent.confirmFullAccess=a),n!==void 0&&(this.consent.acknowledgeLocalAuto=n),r!==void 0&&(this.consent.acknowledgePeerScope=r),c!==void 0&&l.approvalMode===void 0&&(l.approvalMode=c?"auto":"ask"),this.template.profile={...this.template.profile,...l},this.changed()}setModel(s){this.patch({modelSelection:s})}choosePreset(s){this.preset=s,this.changed()}setMemory(s,a){a===null?delete this.template.memory[s]:this.template.memory[s]=a,this.changed()}setRoutineEnabled(s,a){this.routines=this.routines.map(n=>n.id===s?{...n,enabled:a}:n),this.changed()}removeRoutine(s){this.routines=this.routines.filter(a=>a.id!==s),this.changed()}export(){return structuredClone({...this.template,routines:this.routines.map(Re)})}uploadAvatar=async s=>{if(!["image/png","image/jpeg","image/gif","image/webp"].includes(s.type))throw new Error("Choose a PNG, JPEG, GIF, or WebP image");if(s.size>10*1024*1024)throw new Error("Choose an image smaller than 10 MiB");return this.avatarObjectUrl&&URL.revokeObjectURL(this.avatarObjectUrl),this.avatarFile=s,this.avatarObjectUrl=URL.createObjectURL(s),this.avatarObjectUrl};dispose(){this.avatarObjectUrl&&URL.revokeObjectURL(this.avatarObjectUrl)}routine(s,a){const{groupId:n,resultsThreadId:r,schedule:o,...c}=s,l=o.type==="interval"?{...o,weekdays:o.weekdays??void 0,window:o.window??void 0,endsAt:o.endsAt??void 0}:o;return{id:a?.id??`draft-${crypto.randomUUID()}`,createdAt:a?.createdAt??Date.now(),updatedAt:Date.now(),nextRunAt:null,runOn:"maus",...a,...c,enabled:s.enabled??a?.enabled??!0,target:"bot",botId:this.id,timeoutMinutes:s.timeoutMinutes??void 0,durationMinutes:s.durationMinutes??a?.durationMinutes??30,schedule:l}}request=async(s,a)=>{const n=a?.method??"GET",r=typeof a?.body=="string"?JSON.parse(a.body):{},o=`/api/bots/${this.id}`;let c;if(s===o&&n==="PATCH")this.patch(r),c={bot:this.bot};else if(s===`${o}/soul`&&n==="GET")c={soul:this.bot.soul,revision:"draft",bytes:new TextEncoder().encode(this.bot.soul).length,limit:24e3,file:"",drift:!1};else if(s===`${o}/skills`&&n==="GET")c={skills:this.template.skills,staged:[]};else if(s===`${o}/skills`&&n==="POST"){const l=await this.network("/api/bot-defaults/skills/preview",{method:"POST",body:JSON.stringify(r)}),y=new Set(this.template.skills.map(m=>m.name));if(l.skills.some(m=>y.has(m.name)))throw new Error("A skill with this name is already in the draft");this.template.skills.push(...l.skills),this.changed(),c={installed:l.skills}}else if(s.startsWith(`${o}/skills/`)){const l=decodeURIComponent(s.slice(`${o}/skills/`.length)),y=this.template.skills.find(m=>m.name===l);if(!y)throw new Error("No such draft skill");if(n==="GET")c={text:y.text};else if(n==="PATCH"&&typeof r.enabled=="boolean")y.enabled=r.enabled,this.changed(),c={ok:!0};else if(n==="DELETE")this.template.skills=this.template.skills.filter(m=>m!==y),this.changed(),c={ok:!0};else throw new Error("Unsupported draft skill operation")}else if(s===`${o}/avatar/generate`&&n==="POST"){const{name:l,title:y,description:m}=this.bot,{dataUrl:E}=await this.network("/api/bot-defaults/avatar",{method:"POST",body:JSON.stringify({profile:{name:l,title:y,description:m},prompt:r.prompt})}),P=await(await fetch(E)).blob(),b=await this.uploadAvatar(new File([P],"avatar.png",{type:P.type}));c={avatarUrl:b,bot:{...this.bot,avatarUrl:b,avatarCrop:"circle"}}}else if(s==="/api/routines"&&n==="POST"||s.startsWith("/api/routines/draft-")&&n==="PATCH"){if(r.target&&r.target!=="bot")throw new Error("A new bot's routine must target that bot");if(r.botId!==this.id)throw new Error("Routine belongs to another bot");const l=this.routines.find(m=>s===`/api/routines/${m.id}`);if(n==="PATCH"&&!l)throw new Error("No such draft routine");const y=this.routine(r,l);this.routines=[...this.routines.filter(m=>m.id!==y.id),y],this.changed(),c={routine:y}}else throw new Error("This operation requires a created bot");return c}}async function ae(t){const s=t.export();if(s.profile.avatarUrl?.startsWith("blob:")){if(!t.avatarFile)throw new Error("Choose the avatar image again");const a=await oe(t.avatarFile),n=a&&ie(a.path);if(!n)throw new Error("Could not store the avatar image");s.profile.avatarUrl=n}return s}async function Me(t,s=T,a=ne,n=typeof window>"u"?void 0:window.ogb?.approvals,r){const o=await ae(t),{chiefOfStaff:c,managedSections:l,toolScope:y,...m}=o.profile;if(!m.name?.trim())throw new Error("Give the bot a name");const E=t.preset;let b=(await s("/api/bots",{method:"POST",body:JSON.stringify({name:m.name,title:m.title,description:m.description,modelSelection:m.modelSelection,section:m.section,requireAvailableModel:!0,useDefaults:!1,...r!==void 0?{visibility:r}:{},...Object.hasOwn(o.profile,"toolScope")?{settings:{toolScope:y}}:{},...E?{preset:E.id}:{}})})).bot;const x=[],f=[];try{const g=await a(b.id,{...m,modelSelection:b.modelSelection,...t.consent},new AbortController().signal,s,n,b);if(b={...b,...g},m.approvalMode==="full"||m.approvalMode==="custom"){if(g.approvalMode!==m.approvalMode||!n)throw new Error("The bot's requested approval level was not granted");if((await n.setMode(b.id,m.approvalMode,{threadId:b.threadId,threadOnly:!0,acknowledgeLocalAuto:t.consent.acknowledgeLocalAuto===!0})).approvalMode!==m.approvalMode)throw new Error("The initial thread's requested approval level was not granted")}for(const[u,k]of Object.entries(o.memory))E?.notes.includes(u)||await s(`/api/bots/${b.id}/memory/file`,{method:"PUT",body:JSON.stringify({path:u,text:k})});for(const u of o.skills)E?.skills.includes(u.name)||await s(`/api/bots/${b.id}/skill-template`,{method:"POST",body:JSON.stringify(u)});for(const u of o.routines){const k=await s("/api/routines",{method:"POST",body:JSON.stringify({...u,botId:b.id,enabled:!1})});x.push({id:k.routine.id,enabled:u.enabled!==!1})}}catch(g){const u=[];for(const v of x)try{await s(`/api/routines/${v.id}`,{method:"DELETE"})}catch{u.push(`routine ${v.id}`)}try{await s(`/api/bots/${b.id}`,{method:"DELETE"})}catch{u.push(`bot ${b.name} (${b.id})`)}const k=g instanceof Error?g.message:String(g);throw new Error(u.length?`${k}. Cleanup failed for ${u.join(", ")}; remove them before retrying.`:k)}if(c)try{const g=await s(`/api/bots/${b.id}`,{method:"PATCH",body:JSON.stringify({chiefOfStaff:c,managedSections:l,acknowledgePeerScope:!0})});b={...b,...g.bot}}catch(g){f.push(`Review this bot's Chief of Staff setting: ${g instanceof Error?g.message:String(g)}`)}for(const g of x.filter(u=>u.enabled))try{await s(`/api/routines/${g.id}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})}catch(u){f.push(`Could not activate a routine: ${u instanceof Error?u.message:String(u)}`)}return{bot:b,warnings:f}}function De(t){const s=[];for(const a of t){const n=a.source==="org"?i("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):i("newBot.presetsImported"),r=s.find(o=>o.label===n);r?r.presets.push(a):s.push({label:n,presets:[a]})}return s}function $e(t){const s={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(s.color=a.color,s.mascotExpression=a.mascotExpression??null,a.mascotBody&&(s.mascotBody=a.mascotBody)),s}function Ue(t){const s=t.bot.appearance?.avatar;if(!s)return null;let a;try{a=atob(s.data)}catch{return null}const n=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)n[r]=a.charCodeAt(r);return new File([n],`preset.${s.mime.slice(6)}`,{type:s.mime})}function Le(t){const s=[t.source==="org"&&t.publisherName?i("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):i("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&s.push(t.description);const a=t.skills.map(n=>n.name).join(", ");return a&&s.push(i(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&s.push(i("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&s.push(i("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),s.push(i("newBot.presetKeeps")),s}function Ie(t){return{id:t.id,skills:t.skills.map(s=>s.name),notes:[...t.notes]}}function Q(t){const s=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:s(t.name),presetName:s(t.name),presetDescription:s(t.description),release:s(t.release),notes:s(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function ee({preview:t,localSkips:s}){const a=t.document.package.presets?.[0],n=Object.keys(a?.seed?.memory??{}).length,r=[[i("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[i("teamShare.part.notes"),n?String(n):i("teamShare.none")],[i("teamShare.part.pictures"),a?.bot.appearance?.avatar?i("teamShare.yes"):i("teamShare.none")]],o=[...s,...t.skipped.map(c=>pe(c,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:i("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[12.5px]",children:r.map(([c,l])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:c}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:l,children:l})]},c))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[12.5px] leading-relaxed text-ink-secondary",children:[e.jsx(ue,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:i("presetShare.never")})]}),t.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[12.5px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:i("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(c=>e.jsx("li",{children:me(c,t.document)},c))})]}),o.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[12.5px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:i("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:o.map((c,l)=>e.jsx("li",{children:c},`${c}-${l}`))})]})]})}function Fe({onClose:t}){const s=p.useRef(null),[a,n]=p.useState(""),[r,o]=p.useState(""),[c,l]=p.useState(""),[y,m]=p.useState(""),[E,P]=p.useState(!0),[b,x]=p.useState(!0),[f,g]=p.useState(null),[u,k]=p.useState(null),[v,R]=p.useState(!1),[M,B]=p.useState(null),[D,$]=p.useState(""),U=p.useRef(0);p.useEffect(()=>{let d=!1;return T("/api/bot-defaults").then(async({defaults:S})=>{!d&&S.profile.name?.trim()&&n(A=>A||S.profile.name.trim());const j=await re([{id:"defaults",avatarUrl:S.profile.avatarUrl,avatarCrop:S.profile.avatarCrop}]);d||g({dataUrl:j.avatars.defaults,skipped:j.skipped.map(A=>`${i("teamShare.field.picture")} — ${le(`teamShare.skip.${A.reason}`,A.reason)}`)})}).catch(()=>{d||g({skipped:[]})}),()=>{d=!0}},[]);const F=d=>({name:a,description:r,release:c,notes:y,includeNotes:E,dryRun:d,...b&&f?.dataUrl?{picture:f.dataUrl}:{}});p.useEffect(()=>{if(!f)return;const d=++U.current,S=window.setTimeout(()=>{T("/api/teams/export",{method:"POST",body:JSON.stringify(Q({...F(!0),release:void 0}))}).then(j=>{d===U.current&&(k(j),$(""),l(A=>A||j.document.package.release))}).catch(j=>{d===U.current&&(k(null),$(j instanceof Error?j.message:String(j)))})},250);return()=>window.clearTimeout(S)},[f,E,b]);const H=async()=>{if(!v){R(!0),$("");try{const d=await T("/api/teams/export",{method:"POST",body:JSON.stringify(Q(F(!1)))});he(d.filename,d.document),B(d)}catch(d){$(d instanceof Error?d.message:String(d))}finally{R(!1)}}};p.useEffect(()=>{const d=document.activeElement instanceof HTMLElement?document.activeElement:null;return s.current?.focus(),()=>{d?.isConnected&&d.focus()}},[]);const L=b?f?.skipped??[]:[],O="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13.5px] text-ink disabled:opacity-60";return ce.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:d=>{d.target===d.currentTarget&&!v&&t()},children:e.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:d=>{if(d.key==="Escape"&&!v&&(d.stopPropagation(),t()),d.key==="Tab"){const S=s.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!S?.length)return;const j=S[0],A=S[S.length-1];d.shiftKey&&document.activeElement===j?(d.preventDefault(),A.focus()):!d.shiftKey&&document.activeElement===A&&(d.preventDefault(),j.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-preset-title",className:"text-[17px] font-semibold",children:i("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-ink-secondary",children:i("presetShare.intro")})]}),e.jsx("button",{"aria-label":i("presetShare.close"),disabled:v,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(te,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[13.5px] font-medium text-ink",children:[e.jsx(de,{size:16,className:"text-success"}),i("teamShare.saved",{filename:M.filename})]}),e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-ink-secondary",children:i("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(ee,{preview:M,localSkips:L})})]}):e.jsxs(e.Fragment,{children:[u?e.jsx(ee,{preview:u,localSkips:L}):!D&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(z,{size:15,className:"animate-spin"}),i("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:v,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:b,onChange:d=>x(d.target.checked)}),i("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:E,onChange:d=>P(d.target.checked)}),i("presetShare.includeNotes")]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[12.5px] text-ink-secondary",children:[i("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:v,onChange:d=>n(d.target.value),className:O})]}),e.jsxs("label",{className:"block text-[12.5px] text-ink-secondary",children:[i("teamShare.release"),e.jsx("input",{value:c,maxLength:20,disabled:v,placeholder:"1.0.0",onChange:d=>l(d.target.value),className:O})]})]}),e.jsxs("label",{className:"mt-3 block text-[12.5px] text-ink-secondary",children:[i("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:v,onChange:d=>o(d.target.value),className:O})]}),e.jsxs("label",{className:"mt-3 block text-[12.5px] text-ink-secondary",children:[i("teamShare.notes"),e.jsx("textarea",{value:y,maxLength:4e3,rows:2,disabled:v,onChange:d=>m(d.target.value),className:O})]})]})}),D&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12.5px] text-danger",children:D}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:M?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:i("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:v,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:i("common.cancel")}),e.jsxs("button",{disabled:v||!u,onClick:()=>{H()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[v&&e.jsx(z,{size:14,className:"animate-spin"}),v?i("teamShare.saving"):i("teamShare.save")]})]})})]})}),document.body)}const ze=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"];function Je(){const{state:t,dispatch:s}=W(),a=p.useRef(null),n=()=>s({type:"toggleNewBot",open:!1});return p.useEffect(()=>{const r=document.activeElement instanceof HTMLElement?document.activeElement:null;return a.current?.focus(),()=>{r?.isConnected&&r.focus()}},[]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:e.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":i("newBot.create"),tabIndex:-1,className:"w-full max-w-sm rounded-2xl border border-hairline/50 bg-panel p-5 text-ink shadow-2xl",onKeyDown:r=>{if(r.key==="Escape"&&(r.stopPropagation(),n()),r.key==="Tab"){const o=r.currentTarget,c=[...o.querySelectorAll("button:not([disabled])")];r.shiftKey&&(document.activeElement===o||document.activeElement===c[0])?(r.preventDefault(),c.at(-1)?.focus()):!r.shiftKey&&document.activeElement===c.at(-1)&&(r.preventDefault(),c[0]?.focus())}},children:[e.jsx("h2",{className:"mb-4 text-[17px] font-semibold",children:i("newBot.create")}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"rounded-lg px-3 py-2",children:i("common.cancel")}),e.jsx("button",{type:"button",disabled:t.botCreationPending,onClick:()=>s({type:"newBot",onCreated:n}),className:"rounded-lg bg-accent px-4 py-2 text-white disabled:opacity-40",children:i("newBot.create")})]})]})})}function He(t={}){return typeof window<"u"&&window.ogb?.remoteClient?.active?e.jsx(Je,{}):e.jsx(Ge,{...t})}function Ge({defaultsMode:t=!1,onClose:s,section:a,onCreated:n,preserveSelection:r=!1}={}){const o=W(),[,c]=p.useState(0),[l,y]=p.useState(()=>new Z(Be,()=>c(h=>h+1))),[m,E]=p.useState("Identity"),[P,b]=p.useState(!1),[x,f]=p.useState(!1),g=x||o.state.botCreationPending,u=p.useRef(!1),k=p.useRef(!0),[v,R]=p.useState(""),[M,B]=p.useState(null),[D,$]=p.useState("everyone"),[U,F]=p.useState(""),H=xe(),L=!t&&typeof window<"u"&&!window.ogb&&H===!0,O=p.useRef(null),d=p.useRef(()=>{});d.current=()=>{s?s():o.dispatch({type:"toggleNewBot",open:!1})},p.useEffect(()=>{let h=!1;return T("/api/bot-defaults").then(N=>{if(h)return;const w=structuredClone(N.defaults);w.profile.modelSelection??=N.modelSelection,t||(w.profile.name=w.profile.name?.trim()||N.suggestedName),a!==void 0&&(w.profile.section=a),y(new Z(w,()=>c(C=>C+1))),b(!0)}).catch(N=>{h||R(String(N))}),()=>{h=!0}},[t,a]),p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>()=>l.dispose(),[l]),p.useEffect(()=>{g&&O.current?.focus()},[g]),p.useEffect(()=>{const h=document.activeElement instanceof HTMLElement?document.activeElement:null;O.current?.focus();const N=w=>{const C=O.current;if(!C||w.target instanceof Node&&!C.contains(w.target))return;const Y=C.querySelector('[role="dialog"], [role="alertdialog"]');if(Y&&Y.getClientRects().length||(w.key==="Escape"&&(w.preventDefault(),d.current()),w.key!=="Tab"))return;const q=[...C.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(V=>V.getClientRects().length&&!V.closest("[hidden],fieldset:disabled")),G=q[0],K=q.at(-1);if(!G||!K){w.preventDefault(),C.focus();return}w.shiftKey&&(document.activeElement===G||document.activeElement===C)?(w.preventDefault(),K.focus()):!w.shiftKey&&(document.activeElement===K||document.activeElement===C)&&(w.preventDefault(),G.focus())};return window.addEventListener("keydown",N),()=>{window.removeEventListener("keydown",N),h?.isConnected&&h.focus()}},[]);const S=async()=>{if(!P||u.current||o.state.botCreationPending)return;if(!t&&l.bot.approvalMode==="full"&&!l.consent.confirmFullAccess){B("full");return}if(!t&&l.bot.approvalMode==="auto"&&l.bot.computer==="local"&&!l.consent.acknowledgeLocalAuto){B("local");return}const h=L?Ae(D,U):null;if(h&&!h.ok){R(i("botSettings.visibility.needPeople"));return}u.current=!0,f(!0),R(""),o.dispatch({type:"botCreationPending",on:!0});try{if(t)await T("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await ae(l)})});else{const{bot:N,warnings:w}=await Me(l,void 0,void 0,void 0,h?.ok?h.visibility:void 0);o.dispatch({type:"botAdded",bot:N,preserveSelection:r}),w.length&&o.dispatch({type:"error",message:w.join(`
1
+ import{g as T,ab as ne,$ as oe,a0 as ie,t as i,r as p,ac as re,ad as le,ae as ce,j as e,X as te,p as de,d as z,af as pe,ag as ue,ah as me,ai as he,u as W,aj as xe,c as J,ak as fe,al as be,am as ge,an as ye,ao as X,P as ve,T as se,ap as we}from"./index-CyM91z0J.js";import{I as ke,i as I,S as je,a as Se,A as Ne,M as Ee,P as Ce,V as Pe,v as Ae}from"./VisibilitySection-y8Adk-c4.js";import{B as Oe,a as Te}from"./RoutinesPage-Buk5-r3o.js";import"./image-plus-D9o3v9bi.js";import"./CloudBackendPicker-BR42-xBg.js";import"./WebhooksPanel-G_NWjHOP.js";const Be={profile:{},memory:{},skills:[],routines:[]},Re=t=>({name:t.name,prompt:t.prompt,schedule:t.schedule,enabled:t.enabled,runOn:t.runOn,durationMinutes:t.durationMinutes,timeoutMinutes:t.timeoutMinutes,overlap:t.overlap,attachments:t.attachments});class Z{constructor(s,a,n=T){this.changed=a,this.network=n,this.template=structuredClone(s),this.routines=s.routines.map(r=>this.routine({...r,botId:this.id}))}changed;network;id=`draft-${crypto.randomUUID()}`;template;consent={};routines;preset;avatarFile;avatarObjectUrl;get bot(){const{computer:s,cwd:a,peers:n,toolScope:r,...o}=this.template.profile;return{id:this.id,threadId:this.id,name:"",title:"",description:"",soul:"",color:"green",notifications:!0,unread:!1,messages:[],modelSelection:{instanceId:"",model:""},...o,computer:s??void 0,cwd:a??void 0,peers:n??void 0,toolScope:r??void 0}}patch(s){const{confirmFullAccess:a,acknowledgeLocalAuto:n,acknowledgePeerScope:r,applyToAllThreads:o,autoApprove:c,...l}=s;a!==void 0&&(this.consent.confirmFullAccess=a),n!==void 0&&(this.consent.acknowledgeLocalAuto=n),r!==void 0&&(this.consent.acknowledgePeerScope=r),c!==void 0&&l.approvalMode===void 0&&(l.approvalMode=c?"auto":"ask"),this.template.profile={...this.template.profile,...l},this.changed()}setModel(s){this.patch({modelSelection:s})}choosePreset(s){this.preset=s,this.changed()}setMemory(s,a){a===null?delete this.template.memory[s]:this.template.memory[s]=a,this.changed()}setRoutineEnabled(s,a){this.routines=this.routines.map(n=>n.id===s?{...n,enabled:a}:n),this.changed()}removeRoutine(s){this.routines=this.routines.filter(a=>a.id!==s),this.changed()}export(){return structuredClone({...this.template,routines:this.routines.map(Re)})}uploadAvatar=async s=>{if(!["image/png","image/jpeg","image/gif","image/webp"].includes(s.type))throw new Error("Choose a PNG, JPEG, GIF, or WebP image");if(s.size>10*1024*1024)throw new Error("Choose an image smaller than 10 MiB");return this.avatarObjectUrl&&URL.revokeObjectURL(this.avatarObjectUrl),this.avatarFile=s,this.avatarObjectUrl=URL.createObjectURL(s),this.avatarObjectUrl};dispose(){this.avatarObjectUrl&&URL.revokeObjectURL(this.avatarObjectUrl)}routine(s,a){const{groupId:n,resultsThreadId:r,schedule:o,...c}=s,l=o.type==="interval"?{...o,weekdays:o.weekdays??void 0,window:o.window??void 0,endsAt:o.endsAt??void 0}:o;return{id:a?.id??`draft-${crypto.randomUUID()}`,createdAt:a?.createdAt??Date.now(),updatedAt:Date.now(),nextRunAt:null,runOn:"maus",...a,...c,enabled:s.enabled??a?.enabled??!0,target:"bot",botId:this.id,timeoutMinutes:s.timeoutMinutes??void 0,durationMinutes:s.durationMinutes??a?.durationMinutes??30,schedule:l}}request=async(s,a)=>{const n=a?.method??"GET",r=typeof a?.body=="string"?JSON.parse(a.body):{},o=`/api/bots/${this.id}`;let c;if(s===o&&n==="PATCH")this.patch(r),c={bot:this.bot};else if(s===`${o}/soul`&&n==="GET")c={soul:this.bot.soul,revision:"draft",bytes:new TextEncoder().encode(this.bot.soul).length,limit:24e3,file:"",drift:!1};else if(s===`${o}/skills`&&n==="GET")c={skills:this.template.skills,staged:[]};else if(s===`${o}/skills`&&n==="POST"){const l=await this.network("/api/bot-defaults/skills/preview",{method:"POST",body:JSON.stringify(r)}),y=new Set(this.template.skills.map(m=>m.name));if(l.skills.some(m=>y.has(m.name)))throw new Error("A skill with this name is already in the draft");this.template.skills.push(...l.skills),this.changed(),c={installed:l.skills}}else if(s.startsWith(`${o}/skills/`)){const l=decodeURIComponent(s.slice(`${o}/skills/`.length)),y=this.template.skills.find(m=>m.name===l);if(!y)throw new Error("No such draft skill");if(n==="GET")c={text:y.text};else if(n==="PATCH"&&typeof r.enabled=="boolean")y.enabled=r.enabled,this.changed(),c={ok:!0};else if(n==="DELETE")this.template.skills=this.template.skills.filter(m=>m!==y),this.changed(),c={ok:!0};else throw new Error("Unsupported draft skill operation")}else if(s===`${o}/avatar/generate`&&n==="POST"){const{name:l,title:y,description:m}=this.bot,{dataUrl:E}=await this.network("/api/bot-defaults/avatar",{method:"POST",body:JSON.stringify({profile:{name:l,title:y,description:m},prompt:r.prompt})}),P=await(await fetch(E)).blob(),b=await this.uploadAvatar(new File([P],"avatar.png",{type:P.type}));c={avatarUrl:b,bot:{...this.bot,avatarUrl:b,avatarCrop:"circle"}}}else if(s==="/api/routines"&&n==="POST"||s.startsWith("/api/routines/draft-")&&n==="PATCH"){if(r.target&&r.target!=="bot")throw new Error("A new bot's routine must target that bot");if(r.botId!==this.id)throw new Error("Routine belongs to another bot");const l=this.routines.find(m=>s===`/api/routines/${m.id}`);if(n==="PATCH"&&!l)throw new Error("No such draft routine");const y=this.routine(r,l);this.routines=[...this.routines.filter(m=>m.id!==y.id),y],this.changed(),c={routine:y}}else throw new Error("This operation requires a created bot");return c}}async function ae(t){const s=t.export();if(s.profile.avatarUrl?.startsWith("blob:")){if(!t.avatarFile)throw new Error("Choose the avatar image again");const a=await oe(t.avatarFile),n=a&&ie(a.path);if(!n)throw new Error("Could not store the avatar image");s.profile.avatarUrl=n}return s}async function Me(t,s=T,a=ne,n=typeof window>"u"?void 0:window.ogb?.approvals,r){const o=await ae(t),{chiefOfStaff:c,managedSections:l,toolScope:y,...m}=o.profile;if(!m.name?.trim())throw new Error("Give the bot a name");const E=t.preset;let b=(await s("/api/bots",{method:"POST",body:JSON.stringify({name:m.name,title:m.title,description:m.description,modelSelection:m.modelSelection,section:m.section,requireAvailableModel:!0,useDefaults:!1,...r!==void 0?{visibility:r}:{},...Object.hasOwn(o.profile,"toolScope")?{settings:{toolScope:y}}:{},...E?{preset:E.id}:{}})})).bot;const x=[],f=[];try{const g=await a(b.id,{...m,modelSelection:b.modelSelection,...t.consent},new AbortController().signal,s,n,b);if(b={...b,...g},m.approvalMode==="full"||m.approvalMode==="custom"){if(g.approvalMode!==m.approvalMode||!n)throw new Error("The bot's requested approval level was not granted");if((await n.setMode(b.id,m.approvalMode,{threadId:b.threadId,threadOnly:!0,acknowledgeLocalAuto:t.consent.acknowledgeLocalAuto===!0})).approvalMode!==m.approvalMode)throw new Error("The initial thread's requested approval level was not granted")}for(const[u,k]of Object.entries(o.memory))E?.notes.includes(u)||await s(`/api/bots/${b.id}/memory/file`,{method:"PUT",body:JSON.stringify({path:u,text:k})});for(const u of o.skills)E?.skills.includes(u.name)||await s(`/api/bots/${b.id}/skill-template`,{method:"POST",body:JSON.stringify(u)});for(const u of o.routines){const k=await s("/api/routines",{method:"POST",body:JSON.stringify({...u,botId:b.id,enabled:!1})});x.push({id:k.routine.id,enabled:u.enabled!==!1})}}catch(g){const u=[];for(const v of x)try{await s(`/api/routines/${v.id}`,{method:"DELETE"})}catch{u.push(`routine ${v.id}`)}try{await s(`/api/bots/${b.id}`,{method:"DELETE"})}catch{u.push(`bot ${b.name} (${b.id})`)}const k=g instanceof Error?g.message:String(g);throw new Error(u.length?`${k}. Cleanup failed for ${u.join(", ")}; remove them before retrying.`:k)}if(c)try{const g=await s(`/api/bots/${b.id}`,{method:"PATCH",body:JSON.stringify({chiefOfStaff:c,managedSections:l,acknowledgePeerScope:!0})});b={...b,...g.bot}}catch(g){f.push(`Review this bot's Chief of Staff setting: ${g instanceof Error?g.message:String(g)}`)}for(const g of x.filter(u=>u.enabled))try{await s(`/api/routines/${g.id}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})}catch(u){f.push(`Could not activate a routine: ${u instanceof Error?u.message:String(u)}`)}return{bot:b,warnings:f}}function De(t){const s=[];for(const a of t){const n=a.source==="org"?i("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):i("newBot.presetsImported"),r=s.find(o=>o.label===n);r?r.presets.push(a):s.push({label:n,presets:[a]})}return s}function $e(t){const s={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(s.color=a.color,s.mascotExpression=a.mascotExpression??null,a.mascotBody&&(s.mascotBody=a.mascotBody)),s}function Ue(t){const s=t.bot.appearance?.avatar;if(!s)return null;let a;try{a=atob(s.data)}catch{return null}const n=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)n[r]=a.charCodeAt(r);return new File([n],`preset.${s.mime.slice(6)}`,{type:s.mime})}function Le(t){const s=[t.source==="org"&&t.publisherName?i("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):i("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&s.push(t.description);const a=t.skills.map(n=>n.name).join(", ");return a&&s.push(i(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&s.push(i("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&s.push(i("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),s.push(i("newBot.presetKeeps")),s}function Ie(t){return{id:t.id,skills:t.skills.map(s=>s.name),notes:[...t.notes]}}function Q(t){const s=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:s(t.name),presetName:s(t.name),presetDescription:s(t.description),release:s(t.release),notes:s(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function ee({preview:t,localSkips:s}){const a=t.document.package.presets?.[0],n=Object.keys(a?.seed?.memory??{}).length,r=[[i("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[i("teamShare.part.notes"),n?String(n):i("teamShare.none")],[i("teamShare.part.pictures"),a?.bot.appearance?.avatar?i("teamShare.yes"):i("teamShare.none")]],o=[...s,...t.skipped.map(c=>pe(c,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:i("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[12.5px]",children:r.map(([c,l])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:c}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:l,children:l})]},c))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[12.5px] leading-relaxed text-ink-secondary",children:[e.jsx(ue,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:i("presetShare.never")})]}),t.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[12.5px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:i("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(c=>e.jsx("li",{children:me(c,t.document)},c))})]}),o.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[12.5px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:i("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:o.map((c,l)=>e.jsx("li",{children:c},`${c}-${l}`))})]})]})}function Fe({onClose:t}){const s=p.useRef(null),[a,n]=p.useState(""),[r,o]=p.useState(""),[c,l]=p.useState(""),[y,m]=p.useState(""),[E,P]=p.useState(!0),[b,x]=p.useState(!0),[f,g]=p.useState(null),[u,k]=p.useState(null),[v,R]=p.useState(!1),[M,B]=p.useState(null),[D,$]=p.useState(""),U=p.useRef(0);p.useEffect(()=>{let d=!1;return T("/api/bot-defaults").then(async({defaults:S})=>{!d&&S.profile.name?.trim()&&n(A=>A||S.profile.name.trim());const j=await re([{id:"defaults",avatarUrl:S.profile.avatarUrl,avatarCrop:S.profile.avatarCrop}]);d||g({dataUrl:j.avatars.defaults,skipped:j.skipped.map(A=>`${i("teamShare.field.picture")} — ${le(`teamShare.skip.${A.reason}`,A.reason)}`)})}).catch(()=>{d||g({skipped:[]})}),()=>{d=!0}},[]);const F=d=>({name:a,description:r,release:c,notes:y,includeNotes:E,dryRun:d,...b&&f?.dataUrl?{picture:f.dataUrl}:{}});p.useEffect(()=>{if(!f)return;const d=++U.current,S=window.setTimeout(()=>{T("/api/teams/export",{method:"POST",body:JSON.stringify(Q({...F(!0),release:void 0}))}).then(j=>{d===U.current&&(k(j),$(""),l(A=>A||j.document.package.release))}).catch(j=>{d===U.current&&(k(null),$(j instanceof Error?j.message:String(j)))})},250);return()=>window.clearTimeout(S)},[f,E,b]);const H=async()=>{if(!v){R(!0),$("");try{const d=await T("/api/teams/export",{method:"POST",body:JSON.stringify(Q(F(!1)))});he(d.filename,d.document),B(d)}catch(d){$(d instanceof Error?d.message:String(d))}finally{R(!1)}}};p.useEffect(()=>{const d=document.activeElement instanceof HTMLElement?document.activeElement:null;return s.current?.focus(),()=>{d?.isConnected&&d.focus()}},[]);const L=b?f?.skipped??[]:[],O="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13.5px] text-ink disabled:opacity-60";return ce.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:d=>{d.target===d.currentTarget&&!v&&t()},children:e.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:d=>{if(d.key==="Escape"&&!v&&(d.stopPropagation(),t()),d.key==="Tab"){const S=s.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!S?.length)return;const j=S[0],A=S[S.length-1];d.shiftKey&&document.activeElement===j?(d.preventDefault(),A.focus()):!d.shiftKey&&document.activeElement===A&&(d.preventDefault(),j.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-preset-title",className:"text-[17px] font-semibold",children:i("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-ink-secondary",children:i("presetShare.intro")})]}),e.jsx("button",{"aria-label":i("presetShare.close"),disabled:v,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(te,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[13.5px] font-medium text-ink",children:[e.jsx(de,{size:16,className:"text-success"}),i("teamShare.saved",{filename:M.filename})]}),e.jsx("p",{className:"mt-1 text-[12.5px] leading-relaxed text-ink-secondary",children:i("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(ee,{preview:M,localSkips:L})})]}):e.jsxs(e.Fragment,{children:[u?e.jsx(ee,{preview:u,localSkips:L}):!D&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(z,{size:15,className:"animate-spin"}),i("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:v,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:b,onChange:d=>x(d.target.checked)}),i("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:E,onChange:d=>P(d.target.checked)}),i("presetShare.includeNotes")]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[12.5px] text-ink-secondary",children:[i("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:v,onChange:d=>n(d.target.value),className:O})]}),e.jsxs("label",{className:"block text-[12.5px] text-ink-secondary",children:[i("teamShare.release"),e.jsx("input",{value:c,maxLength:20,disabled:v,placeholder:"1.0.0",onChange:d=>l(d.target.value),className:O})]})]}),e.jsxs("label",{className:"mt-3 block text-[12.5px] text-ink-secondary",children:[i("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:v,onChange:d=>o(d.target.value),className:O})]}),e.jsxs("label",{className:"mt-3 block text-[12.5px] text-ink-secondary",children:[i("teamShare.notes"),e.jsx("textarea",{value:y,maxLength:4e3,rows:2,disabled:v,onChange:d=>m(d.target.value),className:O})]})]})}),D&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12.5px] text-danger",children:D}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:M?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:i("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:v,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:i("common.cancel")}),e.jsxs("button",{disabled:v||!u,onClick:()=>{H()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[v&&e.jsx(z,{size:14,className:"animate-spin"}),v?i("teamShare.saving"):i("teamShare.save")]})]})})]})}),document.body)}const ze=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"];function Je(){const{state:t,dispatch:s}=W(),a=p.useRef(null),n=()=>s({type:"toggleNewBot",open:!1});return p.useEffect(()=>{const r=document.activeElement instanceof HTMLElement?document.activeElement:null;return a.current?.focus(),()=>{r?.isConnected&&r.focus()}},[]),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:e.jsxs("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":i("newBot.create"),tabIndex:-1,className:"w-full max-w-sm rounded-2xl border border-hairline/50 bg-panel p-5 text-ink shadow-2xl",onKeyDown:r=>{if(r.key==="Escape"&&(r.stopPropagation(),n()),r.key==="Tab"){const o=r.currentTarget,c=[...o.querySelectorAll("button:not([disabled])")];r.shiftKey&&(document.activeElement===o||document.activeElement===c[0])?(r.preventDefault(),c.at(-1)?.focus()):!r.shiftKey&&document.activeElement===c.at(-1)&&(r.preventDefault(),c[0]?.focus())}},children:[e.jsx("h2",{className:"mb-4 text-[17px] font-semibold",children:i("newBot.create")}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"rounded-lg px-3 py-2",children:i("common.cancel")}),e.jsx("button",{type:"button",disabled:t.botCreationPending,onClick:()=>s({type:"newBot",onCreated:n}),className:"rounded-lg bg-accent px-4 py-2 text-white disabled:opacity-40",children:i("newBot.create")})]})]})})}function He(t={}){return typeof window<"u"&&window.ogb?.remoteClient?.active?e.jsx(Je,{}):e.jsx(Ge,{...t})}function Ge({defaultsMode:t=!1,onClose:s,section:a,onCreated:n,preserveSelection:r=!1}={}){const o=W(),[,c]=p.useState(0),[l,y]=p.useState(()=>new Z(Be,()=>c(h=>h+1))),[m,E]=p.useState("Identity"),[P,b]=p.useState(!1),[x,f]=p.useState(!1),g=x||o.state.botCreationPending,u=p.useRef(!1),k=p.useRef(!0),[v,R]=p.useState(""),[M,B]=p.useState(null),[D,$]=p.useState("everyone"),[U,F]=p.useState(""),H=xe(),L=!t&&typeof window<"u"&&!window.ogb&&H===!0,O=p.useRef(null),d=p.useRef(()=>{});d.current=()=>{s?s():o.dispatch({type:"toggleNewBot",open:!1})},p.useEffect(()=>{let h=!1;return T("/api/bot-defaults").then(N=>{if(h)return;const w=structuredClone(N.defaults);w.profile.modelSelection??=N.modelSelection,t||(w.profile.name=w.profile.name?.trim()||N.suggestedName),a!==void 0&&(w.profile.section=a),y(new Z(w,()=>c(C=>C+1))),b(!0)}).catch(N=>{h||R(String(N))}),()=>{h=!0}},[t,a]),p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>()=>l.dispose(),[l]),p.useEffect(()=>{g&&O.current?.focus()},[g]),p.useEffect(()=>{const h=document.activeElement instanceof HTMLElement?document.activeElement:null;O.current?.focus();const N=w=>{const C=O.current;if(!C||w.target instanceof Node&&!C.contains(w.target))return;const Y=C.querySelector('[role="dialog"], [role="alertdialog"]');if(Y&&Y.getClientRects().length||(w.key==="Escape"&&(w.preventDefault(),d.current()),w.key!=="Tab"))return;const q=[...C.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(V=>V.getClientRects().length&&!V.closest("[hidden],fieldset:disabled")),G=q[0],K=q.at(-1);if(!G||!K){w.preventDefault(),C.focus();return}w.shiftKey&&(document.activeElement===G||document.activeElement===C)?(w.preventDefault(),K.focus()):!w.shiftKey&&(document.activeElement===K||document.activeElement===C)&&(w.preventDefault(),G.focus())};return window.addEventListener("keydown",N),()=>{window.removeEventListener("keydown",N),h?.isConnected&&h.focus()}},[]);const S=async()=>{if(!P||u.current||o.state.botCreationPending)return;if(!t&&l.bot.approvalMode==="full"&&!l.consent.confirmFullAccess){B("full");return}if(!t&&l.bot.approvalMode==="auto"&&l.bot.computer==="local"&&!l.consent.acknowledgeLocalAuto){B("local");return}const h=L?Ae(D,U):null;if(h&&!h.ok){R(i("botSettings.visibility.needPeople"));return}u.current=!0,f(!0),R(""),o.dispatch({type:"botCreationPending",on:!0});try{if(t)await T("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await ae(l)})});else{const{bot:N,warnings:w}=await Me(l,void 0,void 0,void 0,h?.ok?h.visibility:void 0);o.dispatch({type:"botAdded",bot:N,preserveSelection:r}),w.length&&o.dispatch({type:"error",message:w.join(`
2
2
  `)});try{await n?.(N)}catch(C){o.dispatch({type:"error",message:C instanceof Error?C.message:String(C)})}}u.current=!1,k.current&&d.current()}catch(N){k.current&&R(N instanceof Error?N.message:String(N))}finally{u.current=!1,o.dispatch({type:"botCreationPending",on:!1}),k.current&&f(!1)}},j=l.bot,A={...o,state:{...o.state,bots:[j,...o.state.bots],routines:l.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>j,dispatch:h=>{h.type==="updateBot"&&h.botId===l.id?l.patch(h.patch):h.type==="setModel"&&h.botId===l.id?(l.setModel(h.selection),h.resetApprovalToAsk&&l.patch({approvalMode:"ask"})):h.type==="routinePatched"||h.type==="toggleSettings"||o.dispatch(h)}},_=t?i("newBot.defaults"):i("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",children:e.jsxs("div",{ref:O,role:"dialog","aria-modal":"true","aria-label":_,"aria-busy":g,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:_}),e.jsx("button",{type:"button",onClick:()=>d.current(),"aria-label":i("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(te,{size:18,className:"pointer-events-none"})})]}),L&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[i("botSettings.visibility.title"),e.jsxs("select",{value:D,disabled:g,onChange:h=>$(h.target.value),className:"rounded-lg border border-hairline/40 bg-inset px-2 py-1.5 text-[13px] text-ink focus:outline-none",children:[e.jsx("option",{value:"everyone",children:i("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:i("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:i("botSettings.visibility.people")})]})]}),D==="people"&&e.jsx("input",{value:U,disabled:g,onChange:h=>F(h.target.value),placeholder:i("botSettings.visibility.peoplePlaceholder"),"aria-label":i("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":i("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:ze.map(h=>e.jsx("button",{type:"button",onClick:()=>E(h),"aria-current":m===h?"page":void 0,className:J("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",m===h?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:h},h))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!P&&!v&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(z,{size:16,className:"animate-spin"}),i("newBot.loading")]}),P&&e.jsx("fieldset",{disabled:g,className:"min-w-0",children:e.jsx(fe,{value:A,children:e.jsx(Oe.Provider,{value:{request:l.request,draft:!0,uploadAvatar:l.uploadAvatar},children:e.jsx(Ke,{active:m,draft:l,defaultsMode:t})})})})]})]}),v&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:v}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>d.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:i("common.cancel")}),e.jsxs("button",{type:"button",disabled:!P||g||!t&&!j.name.trim(),onClick:()=>{S()},className:"flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[g&&e.jsx(z,{size:15,className:"animate-spin"}),i(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(be,{open:M==="full",onCancel:()=>B(null),onConfirm:()=>{l.consent.confirmFullAccess=!0,B(null),S()}}),e.jsx(ge,{open:M==="local",onCancel:()=>B(null),onConfirm:()=>{l.consent.acknowledgeLocalAuto=!0,B(null),S()}})]})})}function Ke({active:t,draft:s,defaultsMode:a}){const n=s.bot,{state:r}=W(),o=ye(n);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(We,{draft:s,defaultsMode:a}),e.jsx(ke,{bot:n,patch:o.patch,activeState:o.activeState,mascotMotion:null,namePlaceholder:a?i("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:["Team",e.jsxs("select",{className:J(I,"mt-1.5"),value:n.section??"",onChange:c=>s.patch({section:c.target.value}),children:[e.jsx("option",{value:"",children:"General"}),[...new Set([...r.sections??[],...r.bots.map(c=>c.section??"")])].filter(Boolean).map(c=>e.jsx("option",{children:c},c))]})]})]}):t==="Soul"?e.jsx(je,{bot:n,patch:o.patch}):t==="Skills"?e.jsx(Se,{bot:n}):t==="Memory"?e.jsx(_e,{draft:s}):t==="Routines"?e.jsx(Ye,{draft:s}):t==="Access"?e.jsx(Ne,{bot:n,derived:o}):t==="Model"?e.jsx(Ee,{bot:n}):t==="Permissions"?e.jsx(Ce,{bot:n,derived:o}):e.jsx(Pe,{bot:n,derived:o})}function We({draft:t,defaultsMode:s}){const[a,n]=p.useState([]),[r,o]=p.useState(0),[c,l]=p.useState(""),y=p.useRef(!1);p.useEffect(()=>{if(s)return;let x=!1;return T("/api/bot-presets").then(f=>{x||n(f.presets)}).catch(()=>{x||n([])}),()=>{x=!0}},[s,r]);const m=t.preset?a.find(x=>x.id===t.preset.id):void 0,E=async x=>{l("");const f=x.startsWith("preset:")?a.find(u=>u.id===x.slice(7)):void 0;if(!f){t.choosePreset(void 0);const u=X.find(k=>k.id===x);u&&t.patch(we(u));return}t.patch($e(f)),t.choosePreset(Ie(f));const g=Ue(f);try{g?(t.patch({avatarUrl:await t.uploadAvatar(g),avatarCrop:f.bot.appearance.avatar.crop}),y.current=!0):y.current&&(t.patch({avatarUrl:""}),y.current=!1)}catch(u){l(u instanceof Error?u.message:String(u))}},P=async x=>{l("");try{await T(`/api/bot-presets/${encodeURIComponent(x.id)}`,{method:"DELETE"}),t.preset?.id===x.id&&t.choosePreset(void 0),o(f=>f+1)}catch(f){l(f instanceof Error?f.message:String(f))}},b=X.map(x=>e.jsx("option",{value:x.id,children:x.title},x.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[i("newBot.startingRole"),e.jsxs("select",{className:J(I,"mt-1.5"),value:t.preset?`preset:${t.preset.id}`:"",onChange:x=>{E(x.target.value)},children:[e.jsx("option",{value:"",children:i("newBot.customSettings")}),De(a).map(x=>e.jsx("optgroup",{label:x.label,children:x.presets.map(f=>e.jsx("option",{value:`preset:${f.id}`,children:f.name},f.id))},x.label)),a.length?e.jsx("optgroup",{label:i("newBot.builtInRoles"),children:b}):b]})]}),m&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[12.5px] text-ink-secondary","data-new-bot-preset":!0,children:[Le(m).map((x,f)=>e.jsx("p",{className:"break-words",children:x},f)),m.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{P(m)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:i("newBot.presetRemove")})]}),c&&e.jsx("p",{role:"alert",className:"mt-2 text-[12.5px] text-danger",children:c})]})}function _e({draft:t}){const[s,a]=p.useState("MEMORY.md"),[n,r]=p.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx("select",{className:I,"aria-label":"Memory file",value:s,onChange:o=>a(o.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(o=>e.jsx("option",{children:o},o))}),e.jsx("textarea",{className:J(I,"min-h-72 font-mono"),"aria-label":"Memory contents",value:t.template.memory[s]??"",onChange:o=>t.setMemory(s,o.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:I,"aria-label":"New memory topic",placeholder:"Topic name",value:n,onChange:o=>r(o.target.value)}),e.jsx("button",{type:"button","aria-label":"Add memory topic",disabled:!/^[a-zA-Z0-9_-]+$/.test(n),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const o=`memory/${n}.md`;o in t.template.memory||t.setMemory(o,""),a(o),r("")},children:e.jsx(ve,{size:16})}),s!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":"Remove memory topic",className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(s,null),a("MEMORY.md")},children:e.jsx(se,{size:16})})]})]})}function Ye({draft:t}){const[s,a]=p.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:i("computer.routines.create")}),t.routines.map(n=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(n),children:n.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:n.enabled,onChange:r=>t.setRoutineEnabled(n.id,r.target.checked)}),"Enabled"]}),e.jsx("button",{type:"button","aria-label":`Remove ${n.name}`,onClick:()=>t.removeRoutine(n.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(se,{size:15})})]},n.id)),s&&e.jsx(Te,{routine:s==="new"?void 0:s,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function tt(){const[t,s]=p.useState(!1),[a,n]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsx("span",{className:"text-[13px] text-ink",children:i("newBot.defaults")}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>n(!0),className:"rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:i("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:i("newBot.edit")})]})]}),t&&e.jsx(He,{defaultsMode:!0,onClose:()=>s(!1)}),a&&e.jsx(Fe,{onClose:()=>n(!1)})]})}export{Je as CompanionNewBotDialog,tt as DefaultBotSettings,Ge as LocalNewBotDialog,He as NewBotDialog};
@@ -1 +1 @@
1
- import{m as w,u as C,a as z,r as i,j as e,U as S,X as P,c as y,B as T,d as A,T as E,V as m,Y as L,v as I,$ as R,a0 as B,g as U}from"./index-C8xb62XS.js";import{I as F}from"./image-plus-DNIWU160.js";const V=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],_=w("bell",V);function O({bot:t,overlay:b=!1}){const{dispatch:p}=C(),{padClass:k}=z(),[x,f]=i.useState(!1),[g,r]=i.useState(""),[h,v]=i.useState(!1),o=i.useRef(null),l=i.useRef(null),c=i.useRef(null),j=()=>p({type:"toggleSettings",open:!1}),n=a=>{if(l.current={...l.current,...a},c.current)return c.current;f(!0),r("");const s=async()=>{for(;l.current;){const d=l.current;l.current=null,r("");try{const u=await U(`/api/bots/${t.id}/profile`,{method:"PATCH",body:JSON.stringify(d)});p({type:"botPatched",bot:u.bot})}catch(u){r(u instanceof Error?u.message:"Could not update this agent.")}}};return c.current=s().finally(()=>{c.current=null,f(!1)}),c.current},N=async a=>{if(a){v(!0),r("");try{const s=await R(a),d=s?B(s.path):null;if(!d)throw new Error("Choose a PNG, JPEG, GIF, or WebP image.");await n({avatarUrl:d,avatarCrop:t.avatarCrop==="square"?"square":"circle"})}catch(s){r(s instanceof Error?s.message:String(s))}finally{v(!1),o.current&&(o.current.value="")}}};return e.jsxs("aside",{className:y("animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel",b?"md:left-auto md:w-[400px] md:shadow-2xl":"md:relative md:z-20 md:w-[400px] md:shrink-0"),children:[e.jsxs("div",{className:y("flex items-center justify-between px-4 py-3",k),children:[e.jsx("button",{onClick:j,"aria-label":"Collapse remote agent settings",className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(S,{size:18})}),e.jsx("span",{className:"text-[15px] font-semibold text-ink",children:"Remote agent settings"}),e.jsx("button",{onClick:j,"aria-label":"Close remote agent settings",className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(P,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:e.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(T,{bot:t,state:"idle",size:64,motion:"none",motionKey:0,animated:!1}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:a=>{N(a.target.files?.[0])}}),e.jsxs("button",{type:"button",disabled:h||x,onClick:()=>o.current?.click(),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[h?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(F,{size:14})," Avatar"]}),t.avatarUrl&&e.jsx("button",{type:"button",disabled:x,onClick:()=>{n({avatarUrl:null,avatarCrop:"mascot"})},"aria-label":"Remove custom avatar",className:"flex size-9 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(E,{size:14})})]})]}),e.jsxs("label",{className:"block text-[12px] font-medium text-ink-secondary",children:["Name",e.jsx("input",{defaultValue:t.name,maxLength:m.name,onBlur:a=>{const s=a.currentTarget.value.trim();s&&s!==t.name&&n({name:s})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:["Title",e.jsx("input",{defaultValue:t.title??"",maxLength:m.title,onBlur:a=>{a.currentTarget.value!==(t.title??"")&&n({title:a.currentTarget.value})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:["Description",e.jsx("textarea",{defaultValue:t.description??"",maxLength:m.description,rows:4,onBlur:a=>{a.currentTarget.value!==(t.description??"")&&n({description:a.currentTarget.value})},className:"mt-1 w-full resize-y rounded-lg bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]})]}),e.jsx(L,{bot:t,workspaceConfigurationLocked:!0,onPatch:a=>{n(a)}}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(_,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Notifications"}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:"Enable completion and attention notifications for this agent on the host and paired clients."})]})]}),e.jsx(I,{checked:t.notifications,disabled:x,"aria-label":"Agent notifications",onClick:()=>{n({notifications:!t.notifications})}})]}),g?e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:g}):null]})})]})}export{O as RemoteAgentSettingsPanel};
1
+ import{m as w,u as C,a as z,r as i,j as e,U as S,X as P,c as y,B as T,d as A,T as E,V as m,Y as L,v as I,$ as R,a0 as B,g as U}from"./index-CyM91z0J.js";import{I as F}from"./image-plus-D9o3v9bi.js";const V=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],_=w("bell",V);function O({bot:t,overlay:b=!1}){const{dispatch:p}=C(),{padClass:k}=z(),[x,f]=i.useState(!1),[g,r]=i.useState(""),[h,v]=i.useState(!1),o=i.useRef(null),l=i.useRef(null),c=i.useRef(null),j=()=>p({type:"toggleSettings",open:!1}),n=a=>{if(l.current={...l.current,...a},c.current)return c.current;f(!0),r("");const s=async()=>{for(;l.current;){const d=l.current;l.current=null,r("");try{const u=await U(`/api/bots/${t.id}/profile`,{method:"PATCH",body:JSON.stringify(d)});p({type:"botPatched",bot:u.bot})}catch(u){r(u instanceof Error?u.message:"Could not update this agent.")}}};return c.current=s().finally(()=>{c.current=null,f(!1)}),c.current},N=async a=>{if(a){v(!0),r("");try{const s=await R(a),d=s?B(s.path):null;if(!d)throw new Error("Choose a PNG, JPEG, GIF, or WebP image.");await n({avatarUrl:d,avatarCrop:t.avatarCrop==="square"?"square":"circle"})}catch(s){r(s instanceof Error?s.message:String(s))}finally{v(!1),o.current&&(o.current.value="")}}};return e.jsxs("aside",{className:y("animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel",b?"md:left-auto md:w-[400px] md:shadow-2xl":"md:relative md:z-20 md:w-[400px] md:shrink-0"),children:[e.jsxs("div",{className:y("flex items-center justify-between px-4 py-3",k),children:[e.jsx("button",{onClick:j,"aria-label":"Collapse remote agent settings",className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(S,{size:18})}),e.jsx("span",{className:"text-[15px] font-semibold text-ink",children:"Remote agent settings"}),e.jsx("button",{onClick:j,"aria-label":"Close remote agent settings",className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(P,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:e.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(T,{bot:t,state:"idle",size:64,motion:"none",motionKey:0,animated:!1}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:a=>{N(a.target.files?.[0])}}),e.jsxs("button",{type:"button",disabled:h||x,onClick:()=>o.current?.click(),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[h?e.jsx(A,{size:14,className:"animate-spin"}):e.jsx(F,{size:14})," Avatar"]}),t.avatarUrl&&e.jsx("button",{type:"button",disabled:x,onClick:()=>{n({avatarUrl:null,avatarCrop:"mascot"})},"aria-label":"Remove custom avatar",className:"flex size-9 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(E,{size:14})})]})]}),e.jsxs("label",{className:"block text-[12px] font-medium text-ink-secondary",children:["Name",e.jsx("input",{defaultValue:t.name,maxLength:m.name,onBlur:a=>{const s=a.currentTarget.value.trim();s&&s!==t.name&&n({name:s})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:["Title",e.jsx("input",{defaultValue:t.title??"",maxLength:m.title,onBlur:a=>{a.currentTarget.value!==(t.title??"")&&n({title:a.currentTarget.value})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:["Description",e.jsx("textarea",{defaultValue:t.description??"",maxLength:m.description,rows:4,onBlur:a=>{a.currentTarget.value!==(t.description??"")&&n({description:a.currentTarget.value})},className:"mt-1 w-full resize-y rounded-lg bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]})]}),e.jsx(L,{bot:t,workspaceConfigurationLocked:!0,onPatch:a=>{n(a)}}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(_,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:"Notifications"}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:"Enable completion and attention notifications for this agent on the host and paired clients."})]})]}),e.jsx(I,{checked:t.notifications,disabled:x,"aria-label":"Agent notifications",onClick:()=>{n({notifications:!t.notifications})}})]}),g?e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:g}):null]})})]})}export{O as RemoteAgentSettingsPanel};