dorkos 0.92.0 → 0.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/core-extensions/hello-world/index.ts +69 -4
  2. package/dist/bin/cli.js +1199 -319
  3. package/dist/client/assets/{AboutPage-CtAhGJVI.js → AboutPage-R35A-Uu-.js} +1 -1
  4. package/dist/client/assets/{AdapterIcon-DTXuj6Zu.js → AdapterIcon-kPDXiFU1.js} +1 -1
  5. package/dist/client/assets/{AppearancePage-EJF8LarY.js → AppearancePage-COqDtruX.js} +1 -1
  6. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-COy_dBa2.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CIKvkn5X.js} +24 -24
  7. package/dist/client/assets/{BlintzCanvas-Bb84mtl-.js → BlintzCanvas-4FX_eaSh.js} +1 -1
  8. package/dist/client/assets/{CanvasCsvContent-D1y22lqg.js → CanvasCsvContent-Dq2X1kUl.js} +1 -1
  9. package/dist/client/assets/{CanvasFileContent-CbOnIUPF.js → CanvasFileContent-CZUc62IR.js} +2 -2
  10. package/dist/client/assets/{CanvasModel3dContent-Bv86PZ-y.js → CanvasModel3dContent-D1IN_nl9.js} +2 -2
  11. package/dist/client/assets/{CodeMirrorDiff-CXqMnztG.js → CodeMirrorDiff-BeEhMSvL.js} +1 -1
  12. package/dist/client/assets/{CodeMirrorEditor-DHSY565t.js → CodeMirrorEditor-BlNLMvbo.js} +1 -1
  13. package/dist/client/assets/{ConnectionAccessLists-D5Qo1i-D.js → ConnectionAccessLists-s7RnRr1y.js} +1 -1
  14. package/dist/client/assets/{ConnectionsPage-DFvJRdx7.js → ConnectionsPage-BTTdQBdS.js} +2 -2
  15. package/dist/client/assets/ConventionPage-CI3PeUHm.js +11 -0
  16. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BDQA6n2J.js → FloatingTanStackRouterDevtools-CqogiFob-D6OvDT9K.js} +1 -1
  17. package/dist/client/assets/HandlePage-Dvqztr0N.js +1 -0
  18. package/dist/client/assets/{LexicalField-a7Ov2ETq.js → LexicalField-Bqq5KeUW.js} +1 -1
  19. package/dist/client/assets/{ManagesPage-Czapr6qD.js → ManagesPage-CWdKDvw1.js} +1 -1
  20. package/dist/client/assets/{Model3dViewer-C_lFbWIi.js → Model3dViewer-ClJVGLDb.js} +1 -1
  21. package/dist/client/assets/NamePage-BgVZ-KD1.js +1 -0
  22. package/dist/client/assets/{NotificationsPage-CdQCyMJk.js → NotificationsPage-C6tE8iuE.js} +1 -1
  23. package/dist/client/assets/{PermissionsPage-DLT-RkUE.js → PermissionsPage-BqDl7shN.js} +1 -1
  24. package/dist/client/assets/{PersonalityPopover-BeOdD7eK.js → PersonalityPopover-B3q8QYcS.js} +1 -1
  25. package/dist/client/assets/PhotoPage-lt6ZevHW.js +1 -0
  26. package/dist/client/assets/{RoomsPage-CuZJdN_k.js → RoomsPage-DwYtOhd7.js} +1 -1
  27. package/dist/client/assets/{RunsOnPopover-DspQEAdG.js → RunsOnPopover-BDPs-RYB.js} +1 -1
  28. package/dist/client/assets/{SessionsPage-Ctwlg7GN.js → SessionsPage-Du24E934.js} +2 -2
  29. package/dist/client/assets/{SkillsPage-DJdFnWfL.js → SkillsPage-DjLUEngt.js} +1 -1
  30. package/dist/client/assets/{TasksPage-9jCfZB7f.js → TasksPage-B6i3r76o.js} +1 -1
  31. package/dist/client/assets/{ToolsPage-W7zK5P0s.js → ToolsPage-DNoC2MMz.js} +2 -2
  32. package/dist/client/assets/{TopologyGraph-CQga4Nuw.js → TopologyGraph-DtBDaHqX.js} +1 -1
  33. package/dist/client/assets/{agent-browser-CoSmBP5N.js → agent-browser-da9rKrej.js} +1 -1
  34. package/dist/client/assets/{highlighted-body-KPVGNVTW-Bq_O6Zlj.js → highlighted-body-KPVGNVTW-DJ5Xz8gv.js} +1 -1
  35. package/dist/client/assets/{index-CKY7hz-9.js → index-1o6WO7iZ.js} +1 -1
  36. package/dist/client/assets/{index-Dx0uYGgf.js → index-3DE2Q3OD.js} +1 -1
  37. package/dist/client/assets/index-B5yJddXH.js +1 -0
  38. package/dist/client/assets/{index-DrD7x9EL.js → index-BC9LsNlJ.js} +1 -1
  39. package/dist/client/assets/{index-bYhLX3oQ.js → index-BCGiD7pg.js} +410 -405
  40. package/dist/client/assets/index-BG-HtbEP.css +1 -0
  41. package/dist/client/assets/{index-BBMfKdj-.js → index-BQ-o6bQ0.js} +1 -1
  42. package/dist/client/assets/{index-D4nkiaT7.js → index-BVpHI-1y.js} +1 -1
  43. package/dist/client/assets/{index-DCmzSFWM.js → index-Bl2j_xjE.js} +1 -1
  44. package/dist/client/assets/{index-THAVeZRE.js → index-BnORUrPC.js} +1 -1
  45. package/dist/client/assets/{index-OidZkt6z.js → index-Bp2CiCey.js} +1 -1
  46. package/dist/client/assets/{index-BfoOBbWz.js → index-Bu16-jWo.js} +1 -1
  47. package/dist/client/assets/{index-DT9R_NnS.js → index-BzDP7VXZ.js} +1 -1
  48. package/dist/client/assets/{index-Bj32H2Xz.js → index-C9wgMNj5.js} +3 -3
  49. package/dist/client/assets/{index-CpCOMkMm.js → index-CJK5Iw50.js} +1 -1
  50. package/dist/client/assets/{index-Bat0bq64.js → index-CObinYlG.js} +1 -1
  51. package/dist/client/assets/{index-CdNENSm7.js → index-CQXxVt4A.js} +1 -1
  52. package/dist/client/assets/{index-Bn-vRpKY.js → index-CZ0BaV1t.js} +1 -1
  53. package/dist/client/assets/index-Ca5JlBEc.js +1 -0
  54. package/dist/client/assets/{index-CmQbhXN6.js → index-CfUAagLY.js} +1 -1
  55. package/dist/client/assets/{index-ULWpcSAZ.js → index-CotYqF0w.js} +1 -1
  56. package/dist/client/assets/{index-7AN8MIhq.js → index-CtJTMcuR.js} +1 -1
  57. package/dist/client/assets/{index-nztBriGg.js → index-CtlzkOJ3.js} +3 -3
  58. package/dist/client/assets/{index-9RHYMIP_.js → index-Cvzimc0W.js} +1 -1
  59. package/dist/client/assets/{index-cNE108-h.js → index-D0sn-ct6.js} +1 -1
  60. package/dist/client/assets/{index-BI051zYq.js → index-D1kH8Sr2.js} +2 -2
  61. package/dist/client/assets/{index-DV_54TKu.js → index-DJGEk3-H.js} +1 -1
  62. package/dist/client/assets/{index-B7fRxuTQ.js → index-DQWAoAN-.js} +1 -1
  63. package/dist/client/assets/{index-B4oYDFdX.js → index-DdsOOmtz.js} +1 -1
  64. package/dist/client/assets/{index-CIPmtIuV.js → index-DnN4PJaN.js} +1 -1
  65. package/dist/client/assets/{index-BiqiwP26.js → index-DsH33VjO.js} +4 -4
  66. package/dist/client/assets/{index-ahTVwxpJ.js → index-DwfaFQZo.js} +1 -1
  67. package/dist/client/assets/{index-BuAy0fEx.js → index-Dyeo69l2.js} +1 -1
  68. package/dist/client/assets/{index-E7ZNee_E.js → index-FsBhOkNr.js} +1 -1
  69. package/dist/client/assets/{index-DcwZU98u.js → index-LcH-4hgH.js} +1 -1
  70. package/dist/client/assets/{index-EmzeTf1X.js → index-gHd4-GL-.js} +1 -1
  71. package/dist/client/assets/{index-CFdScmIU.js → index-gIAwAMkn.js} +1 -1
  72. package/dist/client/assets/{room-files-source-CMj0pEdy.js → room-files-source-DRQNpCWs.js} +1 -1
  73. package/dist/client/assets/{soul-file-C_AT0A8U.js → soul-file-DcQD5pcS.js} +1 -1
  74. package/dist/client/assets/{use-personality-commit-ClM-Ahk5.js → use-personality-commit-Dsy9tqWY.js} +1 -1
  75. package/dist/client/index.html +2 -2
  76. package/dist/drizzle/0132_connection_access_levels.sql +84 -0
  77. package/dist/drizzle/0134_query_indexes.sql +8 -0
  78. package/dist/drizzle/0135_session_started_by.sql +13 -0
  79. package/dist/drizzle/meta/0132_snapshot.json +10075 -0
  80. package/dist/drizzle/meta/0134_snapshot.json +10095 -0
  81. package/dist/drizzle/meta/0135_snapshot.json +10176 -0
  82. package/dist/drizzle/meta/_journal.json +22 -1
  83. package/dist/server/index.js +18659 -13468
  84. package/dist/server/index.js.map +2 -2
  85. package/package.json +9 -7
  86. package/dist/client/assets/ConventionPage-fMfStY8d.js +0 -11
  87. package/dist/client/assets/HandlePage-8Gv3fBBC.js +0 -1
  88. package/dist/client/assets/NamePage-CrZUfKVe.js +0 -1
  89. package/dist/client/assets/PhotoPage-C2mHVHvV.js +0 -1
  90. package/dist/client/assets/index-B0qJNUoh.css +0 -1
  91. package/dist/client/assets/index-CtxpF7aO.js +0 -1
  92. package/dist/client/assets/index-N8BCc19i.js +0 -1
@@ -1,6 +1,6 @@
1
- import{dR as de,eP as me,eQ as xe,af as O,r as x,eR as fe,eS as pe,eT as ge,eU as he,bm as T,eV as ve,m as je,eW as be,eX as ye,eY as Ne,dl as _,eZ as Ce,e_ as Se,e$ as we,f0 as ke,j as e,f1 as Re,f2 as Ae,f3 as Te,f4 as D,ao as V,f5 as Me,cL as Le,J as R,f6 as Ie,f7 as Pe,bL as w,dp as Ee,f8 as ze,al as A,f9 as B,fa as De,fb as Fe,fc as K,aG as G,fd as U,fe as M,cM as L,cN as I,ff as $,fg as Oe,fh as q,aR as _e,fi as Q,fj as W,cO as P,d9 as H,fk as Ve,fl as Be,fm as Ke,az as Ge,fn as Ue,aA as $e,aB as qe,aC as Qe,aD as We,fo as He,e as Xe,aj as Ye,fp as Ze,fq as Je,a as et,fr as tt,I as nt,fs as st,ft as at,fu as it,a_ as ot}from"./index-bYhLX3oQ.js";/**
1
+ import{dT as de,eR as me,eS as xe,af as O,r as x,eT as fe,eU as pe,eV as ge,eW as he,b3 as T,eX as ve,m as je,eY as be,eZ as ye,e_ as Se,dn as _,e$ as Ce,f0 as Ne,f1 as we,f2 as ke,j as e,f3 as Re,f4 as Ae,f5 as Te,f6 as D,ao as V,f7 as Me,cs as Ie,J as R,f8 as Le,f9 as Pe,bs as w,dr as Ee,fa as ze,al as A,fb as B,fc as De,fd as Fe,fe as K,aG as G,ff as U,fg as M,ct as I,cu as L,fh as W,fi as Oe,fj as $,cW as _e,fk as q,fl as Q,cv as P,db as H,fm as Ve,fn as Be,fo as Ke,az as Ge,fp as Ue,aA as We,aB as $e,aC as qe,aD as Qe,fq as He,e as Xe,aj as Ye,fr as Ze,fs as Je,a as et,ft as tt,I as nt,fu as st,fv as at,fw as it,cS as ot}from"./index-BCGiD7pg.js";/**
2
2
  * @license lucide-react v1.47.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const X={name:"git-fork",size:24,node:[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]};X.node;const Y=de(X);function rt(){const t=me(),n=xe(a=>a.contextReadings),s=O(),o=x.useMemo(()=>Array.from(new Set(t.map(a=>a.runtime))),[t]),i=x.useCallback(a=>{const u={};return o.forEach((l,p)=>{var m;const d=(m=a[p])==null?void 0:m.data;if(!d)return;const j={};for(const f of d)f.contextWindow!=null&&(j[f.value]=f.contextWindow);u[l]=j}),u},[o]),r=fe({queries:o.map(a=>pe(s,{runtime:a})),combine:i});return x.useMemo(()=>{var u;const a={total:0,known:0,unknown:0,warning:0,critical:0,autoCompacted:0};for(const l of t){a.total+=1;const p=l.model?(u=r[l.runtime])==null?void 0:u[l.model]:void 0,d=ge(l,{reading:n[l.id]??null,window:p});d.autoCompactedAt&&(a.autoCompacted+=1),d.status==="known"?(a.known+=1,d.severity==="warning"?a.warning+=1:d.severity==="critical"&&(a.critical+=1)):a.unknown+=1}return a},[t,n,r])}function lt(t,n,s){return t&&n!==void 0&&!s}function Z(t,n,s,o="borderLeftColor"){const i=he()??!1,r=lt(t,s,i);return x.useMemo(()=>!r||!s?{animate:void 0,transition:void 0,pulsing:!1}:{animate:{[o]:[n,s,n]},transition:{[o]:{duration:2,repeat:1/0,ease:"easeInOut"}},pulsing:!0},[r,n,s,o])}function J({value:t,onCommit:n,onEnd:s}){const[o,i]=x.useState(!1),[r,a]=x.useState(""),u=x.useRef(null),l=x.useRef(!1),p=T(t),d=T(n),j=T(s);x.useEffect(()=>{if(!o)return;l.current=!1;const c=requestAnimationFrame(()=>{var h,v;(h=u.current)==null||h.focus(),(v=u.current)==null||v.select()});return()=>cancelAnimationFrame(c)},[o]);const m=x.useCallback(()=>{var c;i(!1),(c=j.read())==null||c()},[j]),f=x.useCallback(()=>{a(p.read()),i(!0)},[p]),g=x.useCallback(()=>{if(l.current)return;l.current=!0,m();const c=r.trim();c.length===0||c===p.read()||d.read()(c)},[m,r,p,d]),y=x.useCallback(()=>{l.current=!0,m()},[m]),C=x.useCallback(c=>{c.key==="Enter"?(c.preventDefault(),g()):c.key==="Escape"&&(c.preventDefault(),y())},[g,y]);return{isRenaming:o,renameValue:r,setRenameValue:a,inputRef:u,start:f,commit:g,cancel:y,handleKeyDown:C}}function ee(t){const n=ve(t.id,{enabled:!1,fallback:t.permissionMode})??t.permissionMode,s=je(t.runtime),o=s==null?void 0:s.permissionModes.values.find(r=>r.id===n),i=o?be(o):ye(n);return{permissionMode:n,isFullPower:i}}function te(t){var f,g;const n=Ne(t.runtime),{accounts:s,nameFor:o,colorFor:i}=_(),r=Ce(t.id),a=t.accountId??null,u=t.account??null,l=Se(n?t.runtime:null,{accountId:a,path:u}),{name:p,color:d}=we({accountId:a,path:u,accounts:s,usage:l,nameFor:o,colorFor:i});if(!n)return{visible:n,name:p,color:d,limitStatus:null,limitDisplay:null};const j=r?r.limit:((f=t.status)==null?void 0:f.limit)??null,m=(r==null?void 0:r.lifecycle)??((g=t.status)==null?void 0:g.lifecycle)??"idle";return{visible:n,name:p,color:d,limitStatus:{lifecycle:m,limit:j},limitDisplay:ke(j)}}function ne({children:t,onRename:n,onFork:s}){return!n&&!s?e.jsx(e.Fragment,{children:t}):e.jsxs(Re,{children:[e.jsx(Ae,{asChild:!0,children:t}),e.jsxs(Te,{className:"w-44",children:[n&&e.jsxs(D,{onClick:n,children:[e.jsx(V,{className:"mr-2 size-4"}),"Rename"]}),n&&s&&e.jsx(Me,{}),s&&e.jsxs(D,{onClick:s,children:[e.jsx(Y,{className:"mr-2 size-4"}),"Fork session"]})]})]})}const k="font-mono select-all";function F(t){try{return new Date(t).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function ct({session:t,expanded:n,onFork:s,className:o}){var p;const{permissionMode:i,isFullPower:r}=ee(t),a=r?"Full power":De(i),{nameFor:u}=_(),l=t.account?u(t.account):null;return e.jsx(Le,{initial:!1,children:n&&e.jsx(R.div,{variants:Pe,initial:"initial",animate:"animate",exit:"exit",transition:Ie,className:"relative z-10 overflow-hidden","data-slot":"session-details-panel",children:e.jsxs("div",{className:A("text-muted-foreground text-2xs mx-2 space-y-1.5 px-3 pt-2 pb-2",o),children:[e.jsx(w,{label:"Session ID",align:"start",copyValue:t.id,valueClassName:k,children:t.id}),e.jsx(w,{label:"Created",align:"start",valueClassName:k,children:F(t.createdAt)}),e.jsx(w,{label:"Updated",align:"start",valueClassName:k,children:F(t.updatedAt)}),e.jsx(w,{label:"Runtime",align:"start",valueClassName:k,children:Ee(t.runtime).label}),l&&e.jsx(w,{label:"Account",align:"start",copyValue:t.account,valueClassName:k,children:l}),e.jsx(w,{label:"Origin",align:"start",valueClassName:k,children:t.originLabel??((p=ze(t.origin))==null?void 0:p.label)??"You"}),e.jsx(w,{label:"Permissions",align:"start",valueClassName:A(k,r&&B.power),children:a}),s&&e.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),s(t.id)},className:"hover:bg-secondary/80 text-muted-foreground/60 hover:text-muted-foreground mt-1 inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors duration-100","aria-label":"Fork session",children:[e.jsx(Y,{className:"size-(--size-icon-xs)"}),e.jsx("span",{children:"Fork"})]})]})})})}function se({account:t,tooltip:n=!0,className:s}){return!t.visible||!t.name||!t.color?null:e.jsx(Fe,{color:t.color,name:t.name,tooltip:n,className:s})}function ut({session:t,isActive:n,onClick:s,onFork:o,onRename:i,isNew:r=!1}){const[a,u]=x.useState(!1),{isRenaming:l,renameValue:p,setRenameValue:d,inputRef:j,start:m,commit:f,handleKeyDown:g}=J({value:t.title,onCommit:b=>i==null?void 0:i(t.id,b)}),{isFullPower:y}=ee(t),C=K(6e4),c=x.useMemo(()=>G(t.updatedAt),[t.updatedAt,C]),h=te(t),v=h.limitDisplay,N=U(t.id,h.limitStatus),S=h.visible&&h.color?h.name:null,E=[S,N.kind==="idle"?null:N.label].filter(Boolean).join(" · "),ae=[`Session: ${M(t.title)}`,S,v==null?void 0:v.text,N.label].filter(Boolean).map(b=>`${b}.`).join(" "),ie=x.useCallback(b=>{b.stopPropagation(),u(ue=>!ue)},[]),oe=x.useCallback(b=>{b.stopPropagation(),m()},[m]),{animate:re,transition:le,initial:ce,pulsing:z}=mt({isNew:r,borderState:N});return e.jsx(L,{children:e.jsxs(R.div,{"data-testid":"session-row",initial:ce,animate:re,transition:le,"data-pulsing":z?"true":"false","data-limit":v?v.needsAction?"action":"waiting":void 0,style:z?void 0:{borderLeftColor:N.color},className:A("group relative rounded-lg border-l-2 transition-colors duration-150",(v==null?void 0:v.needsAction)&&H.error,n?"text-foreground":"hover:bg-secondary/60"),children:[n&&e.jsx(R.div,{layoutId:"active-session-bg",className:"bg-secondary absolute inset-0 rounded-lg",transition:{type:"spring",stiffness:280,damping:32}}),e.jsx(ne,{onRename:i?m:void 0,onFork:o?()=>o(t.id):void 0,children:e.jsx(I,{asChild:!0,disabled:!E,children:e.jsxs(R.div,{onClick:s,tabIndex:-1,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:"relative z-10 cursor-pointer px-3 py-2",children:[e.jsx("button",{type:"button","data-slot":"session-row-open","aria-current":n?"page":void 0,"aria-label":ae,className:"absolute inset-0 cursor-pointer"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[v?e.jsx("span",{className:A("min-w-0 flex-1 truncate",v.needsAction&&$),children:v.text}):e.jsx("span",{className:"min-w-0 flex-1",children:c}),e.jsxs("span",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx(Oe,{session:t}),N.kind==="pendingApproval"&&e.jsx(q,{className:"text-status-warning-fg size-(--size-icon-xs)","aria-label":"Awaiting your approval"}),y&&e.jsx(dt,{}),i&&!l&&e.jsx("button",{type:"button",onClick:oe,className:"text-muted-foreground/60 hover:text-muted-foreground rounded p-0.5 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-visible:opacity-100 max-md:p-1.5 max-md:opacity-100","aria-label":"Rename session",children:e.jsx(V,{className:"size-(--size-icon-xs)"})}),e.jsx("button",{type:"button",onClick:ie,className:A("rounded p-0.5 transition-opacity duration-150 max-md:p-1.5",a?"text-muted-foreground opacity-100":"text-muted-foreground/60 hover:text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 max-md:opacity-100"),"aria-label":"Session details","aria-expanded":a,children:e.jsx(R.div,{animate:{rotate:a?180:0},transition:{type:"spring",stiffness:400,damping:30},children:e.jsx(_e,{className:"size-(--size-icon-sm)"})})})]})]}),l?e.jsx("input",{ref:j,autoFocus:!0,value:p,onChange:b=>d(b.target.value),onBlur:f,onKeyDown:g,onClick:b=>b.stopPropagation(),className:"bg-background text-foreground mt-0.5 w-full rounded border px-1 text-xs outline-none","aria-label":"Session title"}):e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(Q,{origin:t.origin,label:t.originLabel,className:"text-muted-foreground/50"}),e.jsx(W,{type:t.runtime,model:t.model,className:"text-muted-foreground/50"}),e.jsx(se,{account:h,tooltip:!1}),e.jsx("div",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",title:i?"Click the pencil icon to rename":void 0,children:M(t.title)})]})]})]})})}),e.jsx(P,{side:"right",sideOffset:8,children:E||N.label}),e.jsx(ct,{session:t,expanded:a,className:"border-border/30 border-t",...o?{onFork:o}:{}})]})})}function dt(){return e.jsxs(L,{children:[e.jsx(I,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex cursor-help","aria-label":Ve,onClick:t=>t.stopPropagation(),children:e.jsx(Be,{className:`size-(--size-icon-xs) ${B.power}`})})}),e.jsx(P,{side:"top",sideOffset:4,children:"This chat runs commands without stopping for approval."})]})}function mt({isNew:t,borderState:n}){const{animate:s,transition:o,pulsing:i}=Z(n.pulse,n.color,n.dimColor);return x.useMemo(()=>{if(!(t||i))return{initial:void 0,animate:void 0,transition:void 0,pulsing:i};const a={...t?{opacity:1,y:0}:{},...s},u={...t?{opacity:{duration:.2,ease:[0,0,.2,1]},y:{duration:.2,ease:[0,0,.2,1]}}:{},...o};return{initial:t?{opacity:0,y:-8}:void 0,animate:a,transition:u,pulsing:i}},[t,i,s,o])}function xt({session:t,isActive:n,onClick:s,onFork:o,onRename:i}){const{isRenaming:r,renameValue:a,setRenameValue:u,inputRef:l,start:p,commit:d,handleKeyDown:j}=J({value:t.title,onCommit:S=>i==null?void 0:i(t.id,S)}),m=te(t),f=m.limitDisplay,g=U(t.id,m.limitStatus),y=[m.visible&&m.color?m.name:null,g.kind==="idle"?null:g.label].filter(Boolean).join(" · "),C=K(6e4),c=x.useMemo(()=>G(t.updatedAt),[t.updatedAt,C]),{animate:h,transition:v,pulsing:N}=Z(g.pulse,g.color,g.dimColor,"backgroundColor");return e.jsxs(L,{children:[e.jsx(ne,{onRename:i?p:void 0,onFork:o?()=>o(t.id):void 0,children:e.jsx(I,{asChild:!0,children:e.jsxs("button",{type:"button","data-testid":"session-row","data-limit":f?f.needsAction?"action":"waiting":void 0,onClick:s,className:A("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs",Ke,(f==null?void 0:f.needsAction)&&H.error,n?"bg-secondary text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[e.jsx(R.span,{"aria-hidden":!0,"data-pulsing":N?"true":"false",animate:h,transition:v,style:N?void 0:{backgroundColor:g.color},className:"size-1.5 shrink-0 rounded-full"}),e.jsx(se,{account:m,tooltip:!1}),r?e.jsx("input",{ref:l,autoFocus:!0,value:a,onChange:S=>u(S.target.value),onBlur:d,onKeyDown:j,onClick:S=>S.stopPropagation(),className:"bg-background text-foreground min-w-0 flex-1 rounded border px-1 text-xs outline-none","aria-label":"Session title"}):e.jsx("span",{className:"min-w-0 flex-1 truncate",children:M(t.title)}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[g.kind==="pendingApproval"&&e.jsx(q,{className:"text-status-warning-fg size-(--size-icon-xs)","aria-label":"Awaiting approval"}),e.jsx(Q,{origin:t.origin,label:t.originLabel,className:"text-muted-foreground/50"}),e.jsx(W,{type:t.runtime,model:t.model,className:"text-muted-foreground/50"}),f?e.jsx("span",{className:A("text-3xs whitespace-nowrap",f.needsAction?$:"text-muted-foreground"),children:f.text}):e.jsx("span",{className:"text-muted-foreground text-3xs",children:c})]})]})})}),y&&e.jsx(P,{side:"right",sideOffset:8,children:y})]})}function ft({variant:t,session:n,isActive:s,onClick:o,onFork:i,onRename:r,isNew:a}){return t==="compact"?e.jsx(xt,{session:n,isActive:s,onClick:o,onFork:i,onRename:r}):e.jsx(ut,{session:n,isActive:s,onClick:o,onFork:i,onRename:r,isNew:a})}function pt(){const{known:t,warning:n,critical:s,autoCompacted:o}=rt(),i=n+s;if(t===0&&i===0&&o===0)return null;const r=i>0||o>0,a=r?s>0?"bg-red-500":i>0?"bg-amber-500":"bg-muted-foreground/40":"bg-emerald-500",u=r?[i>0?`${i} near full`:null,o>0?`${o} auto-compacted`:null].filter(Boolean).join(" · "):"All sessions have room.";return e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs","data-testid":"fleet-context-bar",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${a}`,"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:u})]})}function gt({activeSessionId:t,groupedSessions:n,onSessionClick:s,onForkSession:o,onRenameSession:i}){const r=x.useId();return e.jsxs(Ge,{type:"scroll",className:"h-full",viewportClassName:"[&>div]:!block",children:[e.jsx(pt,{}),e.jsx(R.div,{layout:!0,children:e.jsx(Ue,{id:r,children:n.length>0?e.jsx(e.Fragment,{children:n.map(a=>{const u=n.length===1&&a.label==="Today";return e.jsxs($e,{children:[!u&&e.jsx(qe,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:a.label}),e.jsx(Qe,{children:a.sessions.map(l=>e.jsx(We,{children:e.jsx(ft,{variant:"full",session:l,isActive:l.id===t,onClick:()=>s(l.id),onFork:o,onRename:i})},l.id))})]},a.label)})}):e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"No conversations yet"})})})})]})}function ht(t,n){return n===""?!0:(t.title??"").toLowerCase().includes(n)}function jt({member:t}){var C;const n=((C=t.agent)==null?void 0:C.projectPath)??null,{sessions:s,isLoading:o,isError:i,activeSessionId:r}=He(n),a=Xe(),u=O(),l=Ye(),p=Ze(n),[d,j]=x.useState(""),m=d.trim().toLowerCase(),f=x.useMemo(()=>Je(s.filter(c=>ht(c,m))),[s,m]);function g(c){!a||n===null||(st.getState().recordOpened("agent",n),a(at({dir:n,session:c})))}async function y(c){try{const h=await u.forkSession(c,void 0,n??void 0);await l.invalidateQueries({queryKey:it.listRoot}),g(h.id)}catch(h){ot.error("Couldn’t branch off this conversation.",{description:h instanceof Error?h.message:"The original is untouched."})}}return o?e.jsx(et,{className:"h-16 w-full"}):i?e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Couldn’t read ",t.displayName,"’s conversations."]}):s.length===0?e.jsxs("p",{className:"text-muted-foreground text-sm",children:["No conversations yet. ",t.displayName," starts one the first time you message it."]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(tt,{"aria-hidden":!0,className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),e.jsx(nt,{value:d,onChange:c=>j(c.target.value),placeholder:"Search conversations","aria-label":"Search conversations",className:"h-8 pl-7 text-sm"})]}),f.length===0?e.jsxs("p",{className:"text-muted-foreground text-sm",children:["No conversation matches “",d.trim(),"”."]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(gt,{activeSessionId:r,groupedSessions:f,onSessionClick:g,onForkSession:c=>void y(c),onRenameSession:(c,h)=>p.mutate({sessionId:c,title:h})})})]})}export{jt as SessionsPage};
6
+ */const X={name:"git-fork",size:24,node:[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]};X.node;const Y=de(X);function rt(){const t=me(),n=xe(a=>a.contextReadings),s=O(),o=x.useMemo(()=>Array.from(new Set(t.map(a=>a.runtime))),[t]),i=x.useCallback(a=>{const u={};return o.forEach((l,p)=>{var m;const d=(m=a[p])==null?void 0:m.data;if(!d)return;const j={};for(const f of d)f.contextWindow!=null&&(j[f.value]=f.contextWindow);u[l]=j}),u},[o]),r=fe({queries:o.map(a=>pe(s,{runtime:a})),combine:i});return x.useMemo(()=>{var u;const a={total:0,known:0,unknown:0,warning:0,critical:0,autoCompacted:0};for(const l of t){a.total+=1;const p=l.model?(u=r[l.runtime])==null?void 0:u[l.model]:void 0,d=ge(l,{reading:n[l.id]??null,window:p});d.autoCompactedAt&&(a.autoCompacted+=1),d.status==="known"?(a.known+=1,d.severity==="warning"?a.warning+=1:d.severity==="critical"&&(a.critical+=1)):a.unknown+=1}return a},[t,n,r])}function lt(t,n,s){return t&&n!==void 0&&!s}function Z(t,n,s,o="borderLeftColor"){const i=he()??!1,r=lt(t,s,i);return x.useMemo(()=>!r||!s?{animate:void 0,transition:void 0,pulsing:!1}:{animate:{[o]:[n,s,n]},transition:{[o]:{duration:2,repeat:1/0,ease:"easeInOut"}},pulsing:!0},[r,n,s,o])}function J({value:t,onCommit:n,onEnd:s}){const[o,i]=x.useState(!1),[r,a]=x.useState(""),u=x.useRef(null),l=x.useRef(!1),p=T(t),d=T(n),j=T(s);x.useEffect(()=>{if(!o)return;l.current=!1;const c=requestAnimationFrame(()=>{var h,v;(h=u.current)==null||h.focus(),(v=u.current)==null||v.select()});return()=>cancelAnimationFrame(c)},[o]);const m=x.useCallback(()=>{var c;i(!1),(c=j.read())==null||c()},[j]),f=x.useCallback(()=>{a(p.read()),i(!0)},[p]),g=x.useCallback(()=>{if(l.current)return;l.current=!0,m();const c=r.trim();c.length===0||c===p.read()||d.read()(c)},[m,r,p,d]),y=x.useCallback(()=>{l.current=!0,m()},[m]),C=x.useCallback(c=>{c.key==="Enter"?(c.preventDefault(),g()):c.key==="Escape"&&(c.preventDefault(),y())},[g,y]);return{isRenaming:o,renameValue:r,setRenameValue:a,inputRef:u,start:f,commit:g,cancel:y,handleKeyDown:C}}function ee(t){const n=ve(t.id,{enabled:!1,fallback:t.permissionMode})??t.permissionMode,s=je(t.runtime),o=s==null?void 0:s.permissionModes.values.find(r=>r.id===n),i=o?be(o):ye(n);return{permissionMode:n,isFullPower:i}}function te(t){var f,g;const n=Se(t.runtime),{accounts:s,nameFor:o,colorFor:i}=_(),r=Ce(t.id),a=t.accountId??null,u=t.account??null,l=Ne(n?t.runtime:null,{accountId:a,path:u}),{name:p,color:d}=we({accountId:a,path:u,accounts:s,usage:l,nameFor:o,colorFor:i});if(!n)return{visible:n,name:p,color:d,limitStatus:null,limitDisplay:null};const j=r?r.limit:((f=t.status)==null?void 0:f.limit)??null,m=(r==null?void 0:r.lifecycle)??((g=t.status)==null?void 0:g.lifecycle)??"idle";return{visible:n,name:p,color:d,limitStatus:{lifecycle:m,limit:j},limitDisplay:ke(j)}}function ne({children:t,onRename:n,onFork:s}){return!n&&!s?e.jsx(e.Fragment,{children:t}):e.jsxs(Re,{children:[e.jsx(Ae,{asChild:!0,children:t}),e.jsxs(Te,{className:"w-44",children:[n&&e.jsxs(D,{onClick:n,children:[e.jsx(V,{className:"mr-2 size-4"}),"Rename"]}),n&&s&&e.jsx(Me,{}),s&&e.jsxs(D,{onClick:s,children:[e.jsx(Y,{className:"mr-2 size-4"}),"Fork session"]})]})]})}const k="font-mono select-all";function F(t){try{return new Date(t).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function ct({session:t,expanded:n,onFork:s,className:o}){var p;const{permissionMode:i,isFullPower:r}=ee(t),a=r?"Full power":De(i),{nameFor:u}=_(),l=t.account?u(t.account):null;return e.jsx(Ie,{initial:!1,children:n&&e.jsx(R.div,{variants:Pe,initial:"initial",animate:"animate",exit:"exit",transition:Le,className:"relative z-10 overflow-hidden","data-slot":"session-details-panel",children:e.jsxs("div",{className:A("text-muted-foreground text-2xs mx-2 space-y-1.5 px-3 pt-2 pb-2",o),children:[e.jsx(w,{label:"Session ID",align:"start",copyValue:t.id,valueClassName:k,children:t.id}),e.jsx(w,{label:"Created",align:"start",valueClassName:k,children:F(t.createdAt)}),e.jsx(w,{label:"Updated",align:"start",valueClassName:k,children:F(t.updatedAt)}),e.jsx(w,{label:"Runtime",align:"start",valueClassName:k,children:Ee(t.runtime).label}),l&&e.jsx(w,{label:"Account",align:"start",copyValue:t.account,valueClassName:k,children:l}),e.jsx(w,{label:"Origin",align:"start",valueClassName:k,children:t.originLabel??((p=ze(t.origin))==null?void 0:p.label)??"You"}),e.jsx(w,{label:"Permissions",align:"start",valueClassName:A(k,r&&B.power),children:a}),s&&e.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),s(t.id)},className:"hover:bg-secondary/80 text-muted-foreground/60 hover:text-muted-foreground mt-1 inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors duration-100","aria-label":"Fork session",children:[e.jsx(Y,{className:"size-(--size-icon-xs)"}),e.jsx("span",{children:"Fork"})]})]})})})}function se({account:t,tooltip:n=!0,className:s}){return!t.visible||!t.name||!t.color?null:e.jsx(Fe,{color:t.color,name:t.name,tooltip:n,className:s})}function ut({session:t,isActive:n,onClick:s,onFork:o,onRename:i,isNew:r=!1}){const[a,u]=x.useState(!1),{isRenaming:l,renameValue:p,setRenameValue:d,inputRef:j,start:m,commit:f,handleKeyDown:g}=J({value:t.title,onCommit:b=>i==null?void 0:i(t.id,b)}),{isFullPower:y}=ee(t),C=K(6e4),c=x.useMemo(()=>G(t.updatedAt),[t.updatedAt,C]),h=te(t),v=h.limitDisplay,S=U(t.id,h.limitStatus),N=h.visible&&h.color?h.name:null,E=[N,S.kind==="idle"?null:S.label].filter(Boolean).join(" · "),ae=[`Session: ${M(t.title)}`,N,v==null?void 0:v.text,S.label].filter(Boolean).map(b=>`${b}.`).join(" "),ie=x.useCallback(b=>{b.stopPropagation(),u(ue=>!ue)},[]),oe=x.useCallback(b=>{b.stopPropagation(),m()},[m]),{animate:re,transition:le,initial:ce,pulsing:z}=mt({isNew:r,borderState:S});return e.jsx(I,{children:e.jsxs(R.div,{"data-testid":"session-row",initial:ce,animate:re,transition:le,"data-pulsing":z?"true":"false","data-limit":v?v.needsAction?"action":"waiting":void 0,style:z?void 0:{borderLeftColor:S.color},className:A("group relative rounded-lg border-l-2 transition-colors duration-150",(v==null?void 0:v.needsAction)&&H.error,n?"text-foreground":"hover:bg-secondary/60"),children:[n&&e.jsx(R.div,{layoutId:"active-session-bg",className:"bg-secondary absolute inset-0 rounded-lg",transition:{type:"spring",stiffness:280,damping:32}}),e.jsx(ne,{onRename:i?m:void 0,onFork:o?()=>o(t.id):void 0,children:e.jsx(L,{asChild:!0,disabled:!E,children:e.jsxs(R.div,{onClick:s,tabIndex:-1,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:"relative z-10 cursor-pointer px-3 py-2",children:[e.jsx("button",{type:"button","data-slot":"session-row-open","aria-current":n?"page":void 0,"aria-label":ae,className:"absolute inset-0 cursor-pointer"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[v?e.jsx("span",{className:A("min-w-0 flex-1 truncate",v.needsAction&&W),children:v.text}):e.jsx("span",{className:"min-w-0 flex-1",children:c}),e.jsxs("span",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx(Oe,{session:t}),S.kind==="pendingApproval"&&e.jsx($,{className:"text-status-warning-fg size-(--size-icon-xs)","aria-label":"Awaiting your approval"}),y&&e.jsx(dt,{}),i&&!l&&e.jsx("button",{type:"button",onClick:oe,className:"text-muted-foreground/60 hover:text-muted-foreground rounded p-0.5 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-visible:opacity-100 max-md:p-1.5 max-md:opacity-100","aria-label":"Rename session",children:e.jsx(V,{className:"size-(--size-icon-xs)"})}),e.jsx("button",{type:"button",onClick:ie,className:A("rounded p-0.5 transition-opacity duration-150 max-md:p-1.5",a?"text-muted-foreground opacity-100":"text-muted-foreground/60 hover:text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 max-md:opacity-100"),"aria-label":"Session details","aria-expanded":a,children:e.jsx(R.div,{animate:{rotate:a?180:0},transition:{type:"spring",stiffness:400,damping:30},children:e.jsx(_e,{className:"size-(--size-icon-sm)"})})})]})]}),l?e.jsx("input",{ref:j,autoFocus:!0,value:p,onChange:b=>d(b.target.value),onBlur:f,onKeyDown:g,onClick:b=>b.stopPropagation(),className:"bg-background text-foreground mt-0.5 w-full rounded border px-1 text-xs outline-none","aria-label":"Session title"}):e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(q,{origin:t.origin,label:t.originLabel,className:"text-muted-foreground/50"}),e.jsx(Q,{type:t.runtime,model:t.model,className:"text-muted-foreground/50"}),e.jsx(se,{account:h,tooltip:!1}),e.jsx("div",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",title:i?"Click the pencil icon to rename":void 0,children:M(t.title)})]})]})]})})}),e.jsx(P,{side:"right",sideOffset:8,children:E||S.label}),e.jsx(ct,{session:t,expanded:a,className:"border-border/30 border-t",...o?{onFork:o}:{}})]})})}function dt(){return e.jsxs(I,{children:[e.jsx(L,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex cursor-help","aria-label":Ve,onClick:t=>t.stopPropagation(),children:e.jsx(Be,{className:`size-(--size-icon-xs) ${B.power}`})})}),e.jsx(P,{side:"top",sideOffset:4,children:"This chat runs commands without stopping for approval."})]})}function mt({isNew:t,borderState:n}){const{animate:s,transition:o,pulsing:i}=Z(n.pulse,n.color,n.dimColor);return x.useMemo(()=>{if(!(t||i))return{initial:void 0,animate:void 0,transition:void 0,pulsing:i};const a={...t?{opacity:1,y:0}:{},...s},u={...t?{opacity:{duration:.2,ease:[0,0,.2,1]},y:{duration:.2,ease:[0,0,.2,1]}}:{},...o};return{initial:t?{opacity:0,y:-8}:void 0,animate:a,transition:u,pulsing:i}},[t,i,s,o])}function xt({session:t,isActive:n,onClick:s,onFork:o,onRename:i}){const{isRenaming:r,renameValue:a,setRenameValue:u,inputRef:l,start:p,commit:d,handleKeyDown:j}=J({value:t.title,onCommit:N=>i==null?void 0:i(t.id,N)}),m=te(t),f=m.limitDisplay,g=U(t.id,m.limitStatus),y=[m.visible&&m.color?m.name:null,g.kind==="idle"?null:g.label].filter(Boolean).join(" · "),C=K(6e4),c=x.useMemo(()=>G(t.updatedAt),[t.updatedAt,C]),{animate:h,transition:v,pulsing:S}=Z(g.pulse,g.color,g.dimColor,"backgroundColor");return e.jsxs(I,{children:[e.jsx(ne,{onRename:i?p:void 0,onFork:o?()=>o(t.id):void 0,children:e.jsx(L,{asChild:!0,children:e.jsxs("button",{type:"button","data-testid":"session-row","data-limit":f?f.needsAction?"action":"waiting":void 0,onClick:s,className:A("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs",Ke,(f==null?void 0:f.needsAction)&&H.error,n?"bg-secondary text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[e.jsx(R.span,{"aria-hidden":!0,"data-pulsing":S?"true":"false",animate:h,transition:v,style:S?void 0:{backgroundColor:g.color},className:"size-1.5 shrink-0 rounded-full"}),e.jsx(se,{account:m,tooltip:!1}),r?e.jsx("input",{ref:l,autoFocus:!0,value:a,onChange:N=>u(N.target.value),onBlur:d,onKeyDown:j,onClick:N=>N.stopPropagation(),className:"bg-background text-foreground min-w-0 flex-1 rounded border px-1 text-xs outline-none","aria-label":"Session title"}):e.jsx("span",{className:"min-w-0 flex-1 truncate",children:M(t.title)}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[g.kind==="pendingApproval"&&e.jsx($,{className:"text-status-warning-fg size-(--size-icon-xs)","aria-label":"Awaiting approval"}),e.jsx(q,{origin:t.origin,label:t.originLabel,className:"text-muted-foreground/50"}),e.jsx(Q,{type:t.runtime,model:t.model,className:"text-muted-foreground/50"}),f?e.jsx("span",{className:A("text-3xs whitespace-nowrap",f.needsAction?W:"text-muted-foreground"),children:f.text}):e.jsx("span",{className:"text-muted-foreground text-3xs",children:c})]})]})})}),y&&e.jsx(P,{side:"right",sideOffset:8,children:y})]})}function ft({variant:t,session:n,isActive:s,onClick:o,onFork:i,onRename:r,isNew:a}){return t==="compact"?e.jsx(xt,{session:n,isActive:s,onClick:o,onFork:i,onRename:r}):e.jsx(ut,{session:n,isActive:s,onClick:o,onFork:i,onRename:r,isNew:a})}function pt(){const{known:t,warning:n,critical:s,autoCompacted:o}=rt(),i=n+s;if(t===0&&i===0&&o===0)return null;const r=i>0||o>0,a=r?s>0?"bg-red-500":i>0?"bg-amber-500":"bg-muted-foreground/40":"bg-emerald-500",u=r?[i>0?`${i} near full`:null,o>0?`${o} auto-compacted`:null].filter(Boolean).join(" · "):"All sessions have room.";return e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs","data-testid":"fleet-context-bar",children:[e.jsx("span",{className:`size-2 shrink-0 rounded-full ${a}`,"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:u})]})}function gt({activeSessionId:t,groupedSessions:n,onSessionClick:s,onForkSession:o,onRenameSession:i}){const r=x.useId();return e.jsxs(Ge,{type:"scroll",className:"h-full",viewportClassName:"[&>div]:!block",children:[e.jsx(pt,{}),e.jsx(R.div,{layout:!0,children:e.jsx(Ue,{id:r,children:n.length>0?e.jsx(e.Fragment,{children:n.map(a=>{const u=n.length===1&&a.label==="Today";return e.jsxs(We,{children:[!u&&e.jsx($e,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:a.label}),e.jsx(qe,{children:a.sessions.map(l=>e.jsx(Qe,{children:e.jsx(ft,{variant:"full",session:l,isActive:l.id===t,onClick:()=>s(l.id),onFork:o,onRename:i})},l.id))})]},a.label)})}):e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"No conversations yet"})})})})]})}function ht(t,n){return n===""?!0:(t.title??"").toLowerCase().includes(n)}function jt({member:t}){var C;const n=((C=t.agent)==null?void 0:C.projectPath)??null,{sessions:s,isLoading:o,isError:i,activeSessionId:r}=He(n),a=Xe(),u=O(),l=Ye(),p=Ze(n),[d,j]=x.useState(""),m=d.trim().toLowerCase(),f=x.useMemo(()=>Je(s.filter(c=>ht(c,m))),[s,m]);function g(c){!a||n===null||(st.getState().recordOpened("agent",n),a(at({dir:n,session:c})))}async function y(c){try{const h=await u.forkSession(c,void 0,n??void 0);await l.invalidateQueries({queryKey:it.listRoot}),g(h.id)}catch(h){ot.error("Couldn’t branch off this conversation.",{description:h instanceof Error?h.message:"The original is untouched."})}}return o?e.jsx(et,{className:"h-16 w-full"}):i?e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Couldn’t read ",t.displayName,"’s conversations."]}):s.length===0?e.jsxs("p",{className:"text-muted-foreground text-sm",children:["No conversations yet. ",t.displayName," starts one the first time you message it."]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(tt,{"aria-hidden":!0,className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),e.jsx(nt,{value:d,onChange:c=>j(c.target.value),placeholder:"Search conversations","aria-label":"Search conversations",className:"h-8 pl-7 text-sm"})]}),f.length===0?e.jsxs("p",{className:"text-muted-foreground text-sm",children:["No conversation matches “",d.trim(),"”."]}):e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(gt,{activeSessionId:r,groupedSessions:f,onSessionClick:g,onForkSession:c=>void y(c),onRenameSession:(c,h)=>p.mutate({sessionId:c,title:h})})})]})}export{jt as SessionsPage};
@@ -1 +1 @@
1
- import{af as b,ai as B,eG as p,eH as g,aj as w,df as A,a_ as z,eI as M,j as e,eJ as O,r as d,aR as H,al as N,B as j,aP as I,d9 as y,eK as C,ef as K,eg as W,eh as q,ei as Q,ej as U,ek as G,el as J,em as Y,e as E,eL as R,eM as V,$ as X,a as $,eN as Z,eO as L,W as P}from"./index-bYhLX3oQ.js";function D(s){const t=b();return B({queryKey:p.status(s),queryFn:()=>t.getHarnessStatus(s),staleTime:3e4,refetchOnMount:"always"})}const ee={native:"reads it",projected:"shared",drifted:"out of date",dropped:"can’t see it",warned:"may not work",conflict:"blocked","pending-approval":"needs your OK"},se={native:"neutral",projected:"neutral",drifted:"info",dropped:"muted",warned:"warning",conflict:"warning","pending-approval":"warning"},k="\0",te=new Set(["native","projected"]);function _(s){return`${s.scope??"project"}${k}${s.artifact}${k}${s.source??""}${k}${s.name}`}function ne(s,t){return`${g[s]} ${ee[t]}`}function ae(s){return s.reason??s.target}function T(s,t){return t.flatMap(n=>{const a=s.cells[n];return a===void 0?[]:[{harness:n,cell:a}]})}function re(s,t){if(t.length===0)return!1;const n=T(s,t);return n.length===t.length&&n.every(({cell:a})=>{var r;return te.has(a.state)&&!((r=a.warnings)!=null&&r.length)})}function S(s){return`${s} ${s===1?"file":"files"}`}function le(s){return s===1?"One package is waiting for your approval.":`${s} packages are waiting for your approval.`}function ie(s){return`Shared with all ${s}`}function oe(s){return s===1?"1 agent file":`${s} agent files`}function ce(s){return`Every agent file ${s} cannot see — skills, rules, commands and more.`}function de(s){return s===1?"1 entry":`${s} entries`}function ue(s,t){return t.flatMap(n=>{const a=s.flatMap(r=>{const l=r.cells[n];return l===void 0||l.state!=="dropped"?[]:[{key:_(r),artifact:r.artifact,name:r.name,...l.reason===void 0?{}:{reason:l.reason}}]});return a.length===0?[]:[{harness:n,label:g[n],entries:a}]})}const xe={drop:"Not shared",warning:"Could not read",write:"Will be written",notice:"Notice"};function fe(s){return`${xe[s.kind]} · ${s.artifact} ${s.name}`}function me(s){const t=b(),n=w();return A({mutationFn:()=>t.syncHarness(s),meta:{errorLabel:"Couldn’t share your agent files"},onSuccess:a=>{n.setQueryData(p.status(s),a.status),z.success("Agent files updated.")}})}function he(s){const t=w();M("approval_resolved",()=>{t.invalidateQueries({queryKey:p.status(s)})})}function pe({result:s,onDismiss:t}){const{applied:n,removals:a,askedAbout:r}=s;return e.jsx(O,{variant:"neutral",onDismiss:t,dismissLabel:"Dismiss what changed","data-slot":"harness-sync-summary",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Agent files updated."}),n>0&&e.jsxs(e.Fragment,{children:[" ",S(n)," written."]})]}),a.length>0&&e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("p",{className:"font-medium",children:["Removed ",S(a.length)," DorkOS put here:"]}),e.jsx("ul",{className:"flex flex-col gap-0.5",children:a.map(({path:l,reason:c})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:l}),e.jsx("span",{className:"opacity-80",children:c})]},l))})]}),r.length>0&&e.jsx("p",{children:le(r.length)})]})})}function ge(s){const{counts:t,sweepPreview:n}=s;return t.drifted>0||n.length>0?{message:"Some agent files are out of date.",variant:n.length>0?"warning":"info",actionable:!0}:t.conflicts>0?{message:"DorkOS can’t update some files. Something else is in the way.",variant:"warning",actionable:!1}:t.adoptable>0?{message:"Some skills live where only a few of your agents look.",variant:"info",actionable:!1}:null}function je({projectPath:s}){return he(s),null}function ve({projectPath:s}){const{data:t}=D(s),n=me(s),[a,r]=d.useState(!1),[l,c]=d.useState(!1);if(t===void 0||t.state!=="ready")return null;const u=e.jsx(je,{projectPath:s});if(n.data!==void 0&&!l)return e.jsxs(e.Fragment,{children:[u,e.jsx(pe,{result:n.data,onDismiss:()=>c(!0)})]});const o=ge(t);if(o===null)return u;const{removals:x,sweepPreview:m}=t,i=m.length;return e.jsxs(e.Fragment,{children:[u,e.jsx(O,{variant:o.variant,"data-slot":"harness-drift-banner",detailsOpen:a,details:i===0?void 0:e.jsx("ul",{className:"flex flex-col gap-0.5",children:x.map(({path:f,reason:v})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:f}),e.jsx("span",{className:"opacity-80",children:v})]},f))}),actions:o.actionable?e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:n.isPending,onClick:()=>{c(!1),n.mutate()},children:n.isPending?"Syncing…":"Sync now"}):void 0,children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("p",{children:o.message}),i>0&&e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(f=>!f),className:"text-3xs flex w-fit items-center gap-1 underline underline-offset-2 opacity-90 hover:opacity-100",children:["Syncing also removes ",S(i)," DorkOS put here",e.jsx(H,{"aria-hidden":!0,className:N("size-3 transition-transform",a&&"rotate-180")})]})]})})]})}function Ne(s){const t=b(),n=w();return A({mutationFn:a=>t.adoptHarness(s,a),meta:{errorLabel:"Couldn’t move that skill"},onSuccess:a=>{n.setQueryData(p.status(s),a.status),n.setQueriesData({queryKey:p.all,predicate:r=>{var l;return((l=r.state.data)==null?void 0:l.projectPath)===a.status.projectPath}},a.status)}})}const ye={neutral:y.neutral,info:y.info,warning:y.warning,muted:"border border-dashed border-border text-muted-foreground"};function ke({harness:s,cell:t}){var l;const n=ne(s,t.state),a=ae(t),r=(l=t.warnings)!=null&&l.length?t.warnings.join(" · "):void 0;return e.jsxs("li",{"aria-label":n,...a===void 0?{}:{title:a},className:N("text-3xs inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight",ye[se[t.state]]),children:[n,r!==void 0&&e.jsx("span",{role:"img","aria-label":"May not work",title:r,className:"inline-flex",children:e.jsx(I,{"aria-hidden":!0,className:"text-status-warning-fg size-2.5"})})]})}function Se(s){const t=s===void 0?-1:s.lastIndexOf("/"),n=t>0?s==null?void 0:s.slice(0,t):void 0;return n===void 0?"Lives where only some of your agents look. Move it to .agents/skills so every agent can read it.":`Lives in ${n}. Move it to .agents/skills so every agent can read it.`}function be(s,t){return`dorkos harness adopt ${s} --project ${t}`}const we="Share with every agent";function Ce(s,t,n){const a=`It moves from ${t} to .agents/skills/${s}`;return n?`${a}, and DorkOS leaves a link behind so Claude Code still finds it.`:`${a}, where every agent reads it.`}const De="for all your projects";function $e({row:s,enabled:t,projectPath:n,showEveryHarness:a}){var v;const[r,l]=d.useState(!1),[c,u]=d.useState(!1),o=Ne(n),x=T(s,t),m=re(s,t)&&!a,i=m&&!r,f=(v=o.data)==null?void 0:v.refusals[0];return e.jsxs("div",{role:"group","aria-label":s.name,className:"flex flex-col gap-1 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 shrink truncate text-xs font-medium",children:s.name}),s.scope==="global"&&e.jsx("span",{className:"text-muted-foreground text-3xs shrink-0",children:De}),s.source!==void 0&&e.jsx("span",{dir:"rtl",title:s.source,className:"text-muted-foreground text-3xs ml-auto min-w-0 truncate text-left font-mono",children:e.jsx("bdi",{dir:"ltr",children:s.source})})]}),e.jsxs("ul",{"aria-label":"Agent tools",className:"flex flex-wrap items-center gap-1",children:[m&&e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":!i,title:x.map(({harness:h})=>g[h]).join(" · "),onClick:()=>l(h=>!h),className:"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground text-3xs focus-visible:ring-ring inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[ie(x.length),e.jsx(H,{"aria-hidden":!0,className:N("size-2.5 transition-transform",i&&"-rotate-90")})]})}),!i&&x.map(({harness:h,cell:F})=>e.jsx(ke,{harness:h,cell:F},h))]}),s.adoptable&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-3xs",children:(f==null?void 0:f.reason)||Se(s.source)}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run: ",e.jsx(C,{children:be(s.name,n)})]}),e.jsx("div",{children:e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:o.isPending,onClick:()=>u(!0),children:we})}),e.jsx(K,{open:c,onOpenChange:u,children:e.jsxs(W,{children:[e.jsxs(q,{children:[e.jsxs(Q,{children:["Move ",s.name," so every agent can read it?"]}),e.jsx(U,{children:Ce(s.name,s.source??"",t.includes("claude-code"))})]}),e.jsxs(G,{children:[e.jsx(J,{children:"Cancel"}),e.jsx(Y,{onClick:()=>o.mutate(s.name),children:"Move it"})]})]})})]})]})}const Ae="https://dorkos.ai/docs/guides/cli-usage#agent-files";function Oe(){return e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"status",className:"sr-only",children:"Loading skills…"}),e.jsx("div",{"aria-hidden":!0,className:"flex flex-col gap-3 py-1",children:[0,1,2].map(s=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx($,{className:"h-3 w-32"}),e.jsx($,{className:"h-3 w-48"})]},s))})]})}function He({projectPath:s,showBrowseLink:t=!0}){const{data:n,isPending:a,error:r,refetch:l}=D(s),[c,u]=d.useState(!1),o=d.useId(),x=E();if(a)return e.jsx(Oe,{});if(r)return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Couldn’t load skills."}),e.jsx(j,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>void l(),children:"Retry"})]});if(n.state!=="ready")return e.jsx(Ee,{status:n});const m=n.rows.filter(i=>i.artifact==="skill");return m.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"No skills here yet."}),t&&x&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-6 px-1 text-xs",onClick:()=>void x({to:"/marketplace",search:{type:"skill-pack"}}),children:[e.jsx(R,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-1",children:[e.jsx(V,{htmlFor:o,className:"text-muted-foreground text-3xs",children:"Show every agent tool"}),e.jsx(X,{id:o,size:"sm",checked:c,onCheckedChange:u})]}),e.jsx("div",{className:"divide-border divide-y",children:m.map(i=>e.jsx($e,{row:i,enabled:n.enabled,projectPath:n.projectPath,showEveryHarness:c},_(i)))})]})}function Ee({status:s}){return s.state==="not-set-up"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS isn’t sharing agent files for this folder yet."}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(C,{children:"dorkos harness sync --fix"})," in this folder to set it up."]}),e.jsx(Z,{href:Ae,className:"text-3xs text-muted-foreground hover:text-foreground underline underline-offset-2",children:"How agent file sharing works"})]}):s.state==="unreadable"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS can’t read this folder’s agent file settings."}),s.detail!==void 0&&e.jsx("p",{className:"text-muted-foreground text-3xs",children:s.detail})]}):e.jsx("p",{className:"text-muted-foreground py-2 text-xs",children:"Agent file sharing runs in the DorkOS app."})}function Re({group:s}){const[t,n]=d.useState(!1);return e.jsxs(L,{open:t,onOpenChange:n,trigger:e.jsxs("span",{className:"text-xs",children:["Not shared with ",s.label]}),badge:e.jsx(P,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:oe(s.entries.length)}),children:[e.jsx("p",{className:"text-muted-foreground text-3xs px-4 pt-3",children:ce(s.label)}),e.jsx("ul",{className:"space-y-2 px-4 pt-2 pb-3",children:s.entries.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"text-3xs font-medium",children:[a.artifact," ",a.name]}),a.reason!==void 0&&e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},a.key))})]})}function Le({rows:s,enabled:t}){const n=ue(s,t);return n.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(a=>e.jsx(Re,{group:a},a.harness))})}function Pe({entries:s}){const[t,n]=d.useState(!1);return s.length===0?null:e.jsx(L,{open:t,onOpenChange:n,trigger:e.jsx("span",{className:"text-xs",children:"Project-level notices"}),badge:e.jsx(P,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:de(s.length)}),children:e.jsx("ul",{className:"space-y-2 px-4 pb-3",children:s.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:N("text-3xs font-medium",a.kind==="notice"&&"text-muted-foreground font-normal"),children:fe(a)}),e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},`${a.kind} ${a.artifact} ${a.source??""} ${a.name}`))})})}function _e({command:s}){return e.jsx(C,{className:"break-normal",children:s.split(" ").map((t,n)=>e.jsxs(d.Fragment,{children:[n>0&&" ",e.jsx("span",{className:"whitespace-nowrap",children:t})]},`${n}-${t}`))})}function Te({notEnabled:s}){return s.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5 py-1",children:s.map(({harness:t,why:n,signal:a})=>e.jsxs("div",{title:a,className:"flex flex-col gap-0.5",children:[e.jsx("p",{className:"text-xs font-medium",children:n==="dorkos-runtime"?`DorkOS runs ${g[t]} here, but this folder isn’t sharing to it.`:`${g[t]} files are in this folder, but DorkOS isn’t sharing to it.`}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(_e,{command:`dorkos harness sync --fix --enable ${t}`})," in this folder to turn it on."]})]},t))})}function Fe({projectPath:s}){const t=E(),{data:n}=D(s),a=(n==null?void 0:n.state)==="ready"?n:null;return e.jsxs("div",{className:"flex flex-col gap-2","data-slot":"profile-skills",children:[e.jsx(ve,{projectPath:s}),a&&e.jsx(Te,{notEnabled:a.notEnabled}),e.jsx(He,{projectPath:s,showBrowseLink:!1}),a&&e.jsx(Le,{rows:a.rows,enabled:a.enabled}),a&&e.jsx(Pe,{entries:a.projectLevel}),t&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground w-full",onClick:()=>void t({to:"/marketplace",search:{type:"skill-pack"}}),children:[e.jsx(R,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]})}function ze({member:s}){var n;const t=((n=s.agent)==null?void 0:n.projectPath)??null;return t===null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This agent’s folder isn’t known here."}):e.jsx(Fe,{projectPath:t})}export{ze as SkillsPage};
1
+ import{af as b,ai as B,eI as p,eJ as g,aj as w,dh as A,cS as z,eK as M,j as e,eL as O,r as d,cW as E,al as N,B as j,cU as I,db as y,eM as C,eh as W,ei as K,ej as q,ek as Q,el as U,em as G,en as J,eo as Y,e as H,eN as L,eO as V,$ as X,a as $,eP as Z,eQ as R,W as P}from"./index-BCGiD7pg.js";function D(s){const t=b();return B({queryKey:p.status(s),queryFn:()=>t.getHarnessStatus(s),staleTime:3e4,refetchOnMount:"always"})}const ee={native:"reads it",projected:"shared",drifted:"out of date",dropped:"can’t see it",warned:"may not work",conflict:"blocked","pending-approval":"needs your OK"},se={native:"neutral",projected:"neutral",drifted:"info",dropped:"muted",warned:"warning",conflict:"warning","pending-approval":"warning"},k="\0",te=new Set(["native","projected"]);function _(s){return`${s.scope??"project"}${k}${s.artifact}${k}${s.source??""}${k}${s.name}`}function ne(s,t){return`${g[s]} ${ee[t]}`}function ae(s){return s.reason??s.target}function T(s,t){return t.flatMap(n=>{const a=s.cells[n];return a===void 0?[]:[{harness:n,cell:a}]})}function re(s,t){if(t.length===0)return!1;const n=T(s,t);return n.length===t.length&&n.every(({cell:a})=>{var r;return te.has(a.state)&&!((r=a.warnings)!=null&&r.length)})}function S(s){return`${s} ${s===1?"file":"files"}`}function le(s){return s===1?"One package is waiting for your approval.":`${s} packages are waiting for your approval.`}function ie(s){return`Shared with all ${s}`}function oe(s){return s===1?"1 agent file":`${s} agent files`}function ce(s){return`Every agent file ${s} cannot see — skills, rules, commands and more.`}function de(s){return s===1?"1 entry":`${s} entries`}function ue(s,t){return t.flatMap(n=>{const a=s.flatMap(r=>{const l=r.cells[n];return l===void 0||l.state!=="dropped"?[]:[{key:_(r),artifact:r.artifact,name:r.name,...l.reason===void 0?{}:{reason:l.reason}}]});return a.length===0?[]:[{harness:n,label:g[n],entries:a}]})}const xe={drop:"Not shared",warning:"Could not read",write:"Will be written",notice:"Notice"};function fe(s){return`${xe[s.kind]} · ${s.artifact} ${s.name}`}function me(s){const t=b(),n=w();return A({mutationFn:()=>t.syncHarness(s),meta:{errorLabel:"Couldn’t share your agent files"},onSuccess:a=>{n.setQueryData(p.status(s),a.status),z.success("Agent files updated.")}})}function he(s){const t=w();M("approval_resolved",()=>{t.invalidateQueries({queryKey:p.status(s)})})}function pe({result:s,onDismiss:t}){const{applied:n,removals:a,askedAbout:r}=s;return e.jsx(O,{variant:"neutral",onDismiss:t,dismissLabel:"Dismiss what changed","data-slot":"harness-sync-summary",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Agent files updated."}),n>0&&e.jsxs(e.Fragment,{children:[" ",S(n)," written."]})]}),a.length>0&&e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("p",{className:"font-medium",children:["Removed ",S(a.length)," DorkOS put here:"]}),e.jsx("ul",{className:"flex flex-col gap-0.5",children:a.map(({path:l,reason:c})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:l}),e.jsx("span",{className:"opacity-80",children:c})]},l))})]}),r.length>0&&e.jsx("p",{children:le(r.length)})]})})}function ge(s){const{counts:t,sweepPreview:n}=s;return t.drifted>0||n.length>0?{message:"Some agent files are out of date.",variant:n.length>0?"warning":"info",actionable:!0}:t.conflicts>0?{message:"DorkOS can’t update some files. Something else is in the way.",variant:"warning",actionable:!1}:t.adoptable>0?{message:"Some skills live where only a few of your agents look.",variant:"info",actionable:!1}:null}function je({projectPath:s}){return he(s),null}function ve({projectPath:s}){const{data:t}=D(s),n=me(s),[a,r]=d.useState(!1),[l,c]=d.useState(!1);if(t===void 0||t.state!=="ready")return null;const u=e.jsx(je,{projectPath:s});if(n.data!==void 0&&!l)return e.jsxs(e.Fragment,{children:[u,e.jsx(pe,{result:n.data,onDismiss:()=>c(!0)})]});const o=ge(t);if(o===null)return u;const{removals:x,sweepPreview:m}=t,i=m.length;return e.jsxs(e.Fragment,{children:[u,e.jsx(O,{variant:o.variant,"data-slot":"harness-drift-banner",detailsOpen:a,details:i===0?void 0:e.jsx("ul",{className:"flex flex-col gap-0.5",children:x.map(({path:f,reason:v})=>e.jsxs("li",{className:"text-3xs flex flex-col",children:[e.jsx("code",{className:"font-mono",children:f}),e.jsx("span",{className:"opacity-80",children:v})]},f))}),actions:o.actionable?e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:n.isPending,onClick:()=>{c(!1),n.mutate()},children:n.isPending?"Syncing…":"Sync now"}):void 0,children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("p",{children:o.message}),i>0&&e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(f=>!f),className:"text-3xs flex w-fit items-center gap-1 underline underline-offset-2 opacity-90 hover:opacity-100",children:["Syncing also removes ",S(i)," DorkOS put here",e.jsx(E,{"aria-hidden":!0,className:N("size-3 transition-transform",a&&"rotate-180")})]})]})})]})}function Ne(s){const t=b(),n=w();return A({mutationFn:a=>t.adoptHarness(s,a),meta:{errorLabel:"Couldn’t move that skill"},onSuccess:a=>{n.setQueryData(p.status(s),a.status),n.setQueriesData({queryKey:p.all,predicate:r=>{var l;return((l=r.state.data)==null?void 0:l.projectPath)===a.status.projectPath}},a.status)}})}const ye={neutral:y.neutral,info:y.info,warning:y.warning,muted:"border border-dashed border-border text-muted-foreground"};function ke({harness:s,cell:t}){var l;const n=ne(s,t.state),a=ae(t),r=(l=t.warnings)!=null&&l.length?t.warnings.join(" · "):void 0;return e.jsxs("li",{"aria-label":n,...a===void 0?{}:{title:a},className:N("text-3xs inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight",ye[se[t.state]]),children:[n,r!==void 0&&e.jsx("span",{role:"img","aria-label":"May not work",title:r,className:"inline-flex",children:e.jsx(I,{"aria-hidden":!0,className:"text-status-warning-fg size-2.5"})})]})}function Se(s){const t=s===void 0?-1:s.lastIndexOf("/"),n=t>0?s==null?void 0:s.slice(0,t):void 0;return n===void 0?"Lives where only some of your agents look. Move it to .agents/skills so every agent can read it.":`Lives in ${n}. Move it to .agents/skills so every agent can read it.`}function be(s,t){return`dorkos harness adopt ${s} --project ${t}`}const we="Share with every agent";function Ce(s,t,n){const a=`It moves from ${t} to .agents/skills/${s}`;return n?`${a}, and DorkOS leaves a link behind so Claude Code still finds it.`:`${a}, where every agent reads it.`}const De="for all your projects";function $e({row:s,enabled:t,projectPath:n,showEveryHarness:a}){var v;const[r,l]=d.useState(!1),[c,u]=d.useState(!1),o=Ne(n),x=T(s,t),m=re(s,t)&&!a,i=m&&!r,f=(v=o.data)==null?void 0:v.refusals[0];return e.jsxs("div",{role:"group","aria-label":s.name,className:"flex flex-col gap-1 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 shrink truncate text-xs font-medium",children:s.name}),s.scope==="global"&&e.jsx("span",{className:"text-muted-foreground text-3xs shrink-0",children:De}),s.source!==void 0&&e.jsx("span",{dir:"rtl",title:s.source,className:"text-muted-foreground text-3xs ml-auto min-w-0 truncate text-left font-mono",children:e.jsx("bdi",{dir:"ltr",children:s.source})})]}),e.jsxs("ul",{"aria-label":"Agent tools",className:"flex flex-wrap items-center gap-1",children:[m&&e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":!i,title:x.map(({harness:h})=>g[h]).join(" · "),onClick:()=>l(h=>!h),className:"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground text-3xs focus-visible:ring-ring inline-flex items-center gap-1 rounded-full px-2 py-0.5 leading-tight transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[ie(x.length),e.jsx(E,{"aria-hidden":!0,className:N("size-2.5 transition-transform",i&&"-rotate-90")})]})}),!i&&x.map(({harness:h,cell:F})=>e.jsx(ke,{harness:h,cell:F},h))]}),s.adoptable&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-3xs",children:(f==null?void 0:f.reason)||Se(s.source)}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run: ",e.jsx(C,{children:be(s.name,n)})]}),e.jsx("div",{children:e.jsx(j,{size:"sm",variant:"outline",className:"h-6 text-xs",disabled:o.isPending,onClick:()=>u(!0),children:we})}),e.jsx(W,{open:c,onOpenChange:u,children:e.jsxs(K,{children:[e.jsxs(q,{children:[e.jsxs(Q,{children:["Move ",s.name," so every agent can read it?"]}),e.jsx(U,{children:Ce(s.name,s.source??"",t.includes("claude-code"))})]}),e.jsxs(G,{children:[e.jsx(J,{children:"Cancel"}),e.jsx(Y,{onClick:()=>o.mutate(s.name),children:"Move it"})]})]})})]})]})}const Ae="https://dorkos.ai/docs/guides/cli-usage#agent-files";function Oe(){return e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"status",className:"sr-only",children:"Loading skills…"}),e.jsx("div",{"aria-hidden":!0,className:"flex flex-col gap-3 py-1",children:[0,1,2].map(s=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx($,{className:"h-3 w-32"}),e.jsx($,{className:"h-3 w-48"})]},s))})]})}function Ee({projectPath:s,showBrowseLink:t=!0}){const{data:n,isPending:a,error:r,refetch:l}=D(s),[c,u]=d.useState(!1),o=d.useId(),x=H();if(a)return e.jsx(Oe,{});if(r)return e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx("p",{className:"text-destructive text-xs",children:"Couldn’t load skills."}),e.jsx(j,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>void l(),children:"Retry"})]});if(n.state!=="ready")return e.jsx(He,{status:n});const m=n.rows.filter(i=>i.artifact==="skill");return m.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"No skills here yet."}),t&&x&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-6 px-1 text-xs",onClick:()=>void x({to:"/marketplace",search:{type:"skill-pack"}}),children:[e.jsx(L,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-1",children:[e.jsx(V,{htmlFor:o,className:"text-muted-foreground text-3xs",children:"Show every agent tool"}),e.jsx(X,{id:o,size:"sm",checked:c,onCheckedChange:u})]}),e.jsx("div",{className:"divide-border divide-y",children:m.map(i=>e.jsx($e,{row:i,enabled:n.enabled,projectPath:n.projectPath,showEveryHarness:c},_(i)))})]})}function He({status:s}){return s.state==="not-set-up"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS isn’t sharing agent files for this folder yet."}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(C,{children:"dorkos harness sync --fix"})," in this folder to set it up."]}),e.jsx(Z,{href:Ae,className:"text-3xs text-muted-foreground hover:text-foreground underline underline-offset-2",children:"How agent file sharing works"})]}):s.state==="unreadable"?e.jsxs("div",{className:"flex flex-col gap-1 py-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"DorkOS can’t read this folder’s agent file settings."}),s.detail!==void 0&&e.jsx("p",{className:"text-muted-foreground text-3xs",children:s.detail})]}):e.jsx("p",{className:"text-muted-foreground py-2 text-xs",children:"Agent file sharing runs in the DorkOS app."})}function Le({group:s}){const[t,n]=d.useState(!1);return e.jsxs(R,{open:t,onOpenChange:n,trigger:e.jsxs("span",{className:"text-xs",children:["Not shared with ",s.label]}),badge:e.jsx(P,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:oe(s.entries.length)}),children:[e.jsx("p",{className:"text-muted-foreground text-3xs px-4 pt-3",children:ce(s.label)}),e.jsx("ul",{className:"space-y-2 px-4 pt-2 pb-3",children:s.entries.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"text-3xs font-medium",children:[a.artifact," ",a.name]}),a.reason!==void 0&&e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},a.key))})]})}function Re({rows:s,enabled:t}){const n=ue(s,t);return n.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(a=>e.jsx(Le,{group:a},a.harness))})}function Pe({entries:s}){const[t,n]=d.useState(!1);return s.length===0?null:e.jsx(R,{open:t,onOpenChange:n,trigger:e.jsx("span",{className:"text-xs",children:"Project-level notices"}),badge:e.jsx(P,{variant:"secondary",size:"xs",className:"whitespace-nowrap",children:de(s.length)}),children:e.jsx("ul",{className:"space-y-2 px-4 pb-3",children:s.map(a=>e.jsxs("li",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:N("text-3xs font-medium",a.kind==="notice"&&"text-muted-foreground font-normal"),children:fe(a)}),e.jsx("span",{className:"text-muted-foreground text-3xs",children:a.reason})]},`${a.kind} ${a.artifact} ${a.source??""} ${a.name}`))})})}function _e({command:s}){return e.jsx(C,{className:"break-normal",children:s.split(" ").map((t,n)=>e.jsxs(d.Fragment,{children:[n>0&&" ",e.jsx("span",{className:"whitespace-nowrap",children:t})]},`${n}-${t}`))})}function Te({notEnabled:s}){return s.length===0?null:e.jsx("div",{className:"flex flex-col gap-1.5 py-1",children:s.map(({harness:t,why:n,signal:a})=>e.jsxs("div",{title:a,className:"flex flex-col gap-0.5",children:[e.jsx("p",{className:"text-xs font-medium",children:n==="dorkos-runtime"?`DorkOS runs ${g[t]} here, but this folder isn’t sharing to it.`:`${g[t]} files are in this folder, but DorkOS isn’t sharing to it.`}),e.jsxs("p",{className:"text-muted-foreground text-3xs",children:["Run ",e.jsx(_e,{command:`dorkos harness sync --fix --enable ${t}`})," in this folder to turn it on."]})]},t))})}function Fe({projectPath:s}){const t=H(),{data:n}=D(s),a=(n==null?void 0:n.state)==="ready"?n:null;return e.jsxs("div",{className:"flex flex-col gap-2","data-slot":"profile-skills",children:[e.jsx(ve,{projectPath:s}),a&&e.jsx(Te,{notEnabled:a.notEnabled}),e.jsx(Ee,{projectPath:s,showBrowseLink:!1}),a&&e.jsx(Re,{rows:a.rows,enabled:a.enabled}),a&&e.jsx(Pe,{entries:a.projectLevel}),t&&e.jsxs(j,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground w-full",onClick:()=>void t({to:"/marketplace",search:{type:"skill-pack"}}),children:[e.jsx(L,{"aria-hidden":!0,className:"mr-1.5 size-3.5"}),"Browse skill-packs"]})]})}function ze({member:s}){var n;const t=((n=s.agent)==null?void 0:n.projectPath)??null;return t===null?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This agent’s folder isn’t known here."}):e.jsx(Fe,{projectPath:t})}export{ze as SkillsPage};
@@ -1 +1 @@
1
- import{as as F,ag as w,at as U,au as D,av as L,aw as B,ax as G,r as o,j as e,ay as $,az as O,aA as p,aB as f,aC as j,aD as g,aE as k,aF as E,aG as N,aH as P,aI as X,aJ as _,aK as H,aL as J,aM as K,aN as V}from"./index-bYhLX3oQ.js";const W=5;function q({status:t}){switch(t){case"running":return e.jsx(E,{size:"xs",className:"text-status-info shrink-0"});case"completed":return e.jsx(K,{className:"text-status-success size-3 shrink-0","aria-hidden":!0});case"failed":return e.jsx(J,{className:"text-destructive size-3 shrink-0","aria-hidden":!0});case"cancelled":return e.jsx(H,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"skipped":return e.jsx(_,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"blocked":return e.jsx(X,{className:"text-status-warning-dot size-3 shrink-0","aria-hidden":!0});default:return null}}function Q(t){if(t===null)return"";if(t<1e3)return"< 1s";const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60),i=n%60;return`${a}m ${i}s`}function Y({run:t,scheduleName:n}){return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(E,{size:"xs",className:"text-status-info shrink-0"}),e.jsx("span",{className:"truncate",children:n}),t.startedAt&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.startedAt)})]})})}function Z({schedule:t,onEdit:n}){return e.jsx(g,{children:e.jsxs(k,{onClick:()=>n(t.id),className:"text-sm",children:[e.jsx(P,{className:"text-muted-foreground/50 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:t.name}),t.nextRun&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.nextRun)})]})})}function ee({run:t,scheduleName:n}){const a=t.status==="running"&&t.finishedAt?t.error?"failed":"completed":t.status;return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(q,{status:a}),e.jsx("span",{className:"truncate",children:n}),e.jsxs("span",{className:"text-muted-foreground/50 ml-auto flex shrink-0 items-center gap-1.5 text-xs",children:[t.durationMs!==null&&e.jsx("span",{children:Q(t.durationMs)}),t.finishedAt&&e.jsx("span",{children:N(t.finishedAt)})]})]})})}function se({available:t,agentId:n}){const a=F(),i=w(s=>s.setTasksAgentFilter),R=w(s=>s.setTasksEditScheduleId),u=t,{data:x=[]}=U(u),{data:I=0}=D(u),{data:T=[]}=L(void 0,u),{data:S=[]}=B(),{openWithTemplate:y}=G(),v=[S[0],S[2]].filter(Boolean),l=o.useMemo(()=>n?x.filter(s=>s.agentId===n):x,[n,x]),d=o.useMemo(()=>{const s=new Map;for(const r of l)s.set(r.id,r.name);return s},[l]),A=o.useMemo(()=>T.filter(s=>d.has(s.scheduleId)),[T,d]),{runningRuns:M,recentRuns:b}=o.useMemo(()=>{const s=[],r=[];for(const c of A)c.finishedAt!=null||c.status!=="running"?r.push(c):s.push(c);return r.sort((c,h)=>(h.finishedAt??h.createdAt).localeCompare(c.finishedAt??c.createdAt)),{runningRuns:s,recentRuns:r.slice(0,W)}},[A]),C=o.useMemo(()=>l.filter(s=>s.enabled&&s.status==="active"&&s.nextRun).sort((s,r)=>(s.nextRun??"").localeCompare(r.nextRun??"")),[l]),m=()=>{n&&(i(n),R(null)),a.open()},z=s=>{R(s),i(null),a.open()};return l.length===0?e.jsxs("div",{className:"flex flex-col gap-3 px-3 py-4",children:[e.jsx("p",{className:"text-muted-foreground/70 text-xs",children:"No schedules yet."}),v.length>0&&e.jsx("div",{className:"space-y-2",children:v.map(s=>e.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:$(s.cron)}),e.jsx("button",{type:"button",onClick:()=>{y(s),m()},className:"text-primary mt-2 text-xs hover:underline",children:"+ Use preset"})]},s.id))}),e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Schedules →"})]}):e.jsx(O,{type:"scroll",className:"h-full",children:e.jsxs("div",{className:"pr-1",children:[M.length>0&&e.jsxs(p,{children:[e.jsxs(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:["Running",e.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs font-normal normal-case",children:I})]}),e.jsx(j,{children:M.map(s=>e.jsx(Y,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),C.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Upcoming"}),e.jsx(j,{children:C.map(s=>e.jsx(Z,{schedule:s,onEdit:z},s.id))})]}),b.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Recent Runs"}),e.jsx(j,{children:b.map(s=>e.jsx(ee,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),e.jsx("div",{className:"px-3 py-2",children:e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Schedules →"})})]})})}function ne({member:t}){var i;const n=V(),a=((i=t.agent)==null?void 0:i.manifestId)??null;return e.jsx("div",{className:"min-h-0 flex-1","data-slot":"profile-tasks",children:e.jsx(se,{available:n,agentId:a})})}export{ne as TasksPage};
1
+ import{as as F,ag as w,at as U,au as D,av as L,aw as B,ax as G,r as o,j as e,ay as $,az as O,aA as p,aB as f,aC as j,aD as g,aE as k,aF as E,aG as N,aH as P,aI as X,aJ as _,aK as H,aL as J,aM as K,aN as V}from"./index-BCGiD7pg.js";const W=5;function q({status:t}){switch(t){case"running":return e.jsx(E,{size:"xs",className:"text-status-info shrink-0"});case"completed":return e.jsx(K,{className:"text-status-success size-3 shrink-0","aria-hidden":!0});case"failed":return e.jsx(J,{className:"text-destructive size-3 shrink-0","aria-hidden":!0});case"cancelled":return e.jsx(H,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"skipped":return e.jsx(_,{className:"text-muted-foreground size-3 shrink-0","aria-hidden":!0});case"blocked":return e.jsx(X,{className:"text-status-warning-dot size-3 shrink-0","aria-hidden":!0});default:return null}}function Q(t){if(t===null)return"";if(t<1e3)return"< 1s";const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60),i=n%60;return`${a}m ${i}s`}function Y({run:t,scheduleName:n}){return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(E,{size:"xs",className:"text-status-info shrink-0"}),e.jsx("span",{className:"truncate",children:n}),t.startedAt&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.startedAt)})]})})}function Z({schedule:t,onEdit:n}){return e.jsx(g,{children:e.jsxs(k,{onClick:()=>n(t.id),className:"text-sm",children:[e.jsx(P,{className:"text-muted-foreground/50 size-3 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:t.name}),t.nextRun&&e.jsx("span",{className:"text-muted-foreground/50 ml-auto shrink-0 text-xs",children:N(t.nextRun)})]})})}function ee({run:t,scheduleName:n}){const a=t.status==="running"&&t.finishedAt?t.error?"failed":"completed":t.status;return e.jsx(g,{children:e.jsxs(k,{className:"text-sm",children:[e.jsx(q,{status:a}),e.jsx("span",{className:"truncate",children:n}),e.jsxs("span",{className:"text-muted-foreground/50 ml-auto flex shrink-0 items-center gap-1.5 text-xs",children:[t.durationMs!==null&&e.jsx("span",{children:Q(t.durationMs)}),t.finishedAt&&e.jsx("span",{children:N(t.finishedAt)})]})]})})}function se({available:t,agentId:n}){const a=F(),i=w(s=>s.setTasksAgentFilter),R=w(s=>s.setTasksEditScheduleId),u=t,{data:x=[]}=U(u),{data:I=0}=D(u),{data:T=[]}=L(void 0,u),{data:S=[]}=B(),{openWithTemplate:y}=G(),v=[S[0],S[2]].filter(Boolean),l=o.useMemo(()=>n?x.filter(s=>s.agentId===n):x,[n,x]),d=o.useMemo(()=>{const s=new Map;for(const r of l)s.set(r.id,r.name);return s},[l]),A=o.useMemo(()=>T.filter(s=>d.has(s.scheduleId)),[T,d]),{runningRuns:M,recentRuns:b}=o.useMemo(()=>{const s=[],r=[];for(const c of A)c.finishedAt!=null||c.status!=="running"?r.push(c):s.push(c);return r.sort((c,h)=>(h.finishedAt??h.createdAt).localeCompare(c.finishedAt??c.createdAt)),{runningRuns:s,recentRuns:r.slice(0,W)}},[A]),C=o.useMemo(()=>l.filter(s=>s.enabled&&s.status==="active"&&s.nextRun).sort((s,r)=>(s.nextRun??"").localeCompare(r.nextRun??"")),[l]),m=()=>{n&&(i(n),R(null)),a.open()},z=s=>{R(s),i(null),a.open()};return l.length===0?e.jsxs("div",{className:"flex flex-col gap-3 px-3 py-4",children:[e.jsx("p",{className:"text-muted-foreground/70 text-xs",children:"No schedules yet."}),v.length>0&&e.jsx("div",{className:"space-y-2",children:v.map(s=>e.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:$(s.cron)}),e.jsx("button",{type:"button",onClick:()=>{y(s),m()},className:"text-primary mt-2 text-xs hover:underline",children:"+ Use preset"})]},s.id))}),e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Schedules →"})]}):e.jsx(O,{type:"scroll",className:"h-full",children:e.jsxs("div",{className:"pr-1",children:[M.length>0&&e.jsxs(p,{children:[e.jsxs(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:["Running",e.jsx("span",{className:"text-muted-foreground/50 ml-auto text-xs font-normal normal-case",children:I})]}),e.jsx(j,{children:M.map(s=>e.jsx(Y,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),C.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Upcoming"}),e.jsx(j,{children:C.map(s=>e.jsx(Z,{schedule:s,onEdit:z},s.id))})]}),b.length>0&&e.jsxs(p,{children:[e.jsx(f,{className:"text-2xs text-muted-foreground/70 font-medium tracking-wider uppercase",children:"Recent Runs"}),e.jsx(j,{children:b.map(s=>e.jsx(ee,{run:s,scheduleName:d.get(s.scheduleId)??"Unknown"},s.id))})]}),e.jsx("div",{className:"px-3 py-2",children:e.jsx("button",{onClick:m,className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:"Open Schedules →"})})]})})}function ne({member:t}){var i;const n=V(),a=((i=t.agent)==null?void 0:i.manifestId)??null;return e.jsx("div",{className:"min-h-0 flex-1","data-slot":"profile-tasks",children:e.jsx(se,{available:n,agentId:a})})}export{ne as TasksPage};
@@ -1,2 +1,2 @@
1
- import{af as W,ai as Fe,df as se,aj as ge,fv as De,fw as pe,r as l,j as n,cR as F,cS as D,fx as fe,B as f,P as xe,fy as te,eM as L,I as G,du as Le,dv as _e,dw as $e,dx as Ke,dy as Be,fz as ce,bI as Ue,fA as Ve,C as X,al as le,fB as ae,cM as ve,cN as je,W as qe,cO as Ne,bL as _,aS as He,fC as de,aF as ee,e7 as Ye,e8 as Ge,e9 as Qe,ea as We,eb as J,am as Ze,ed as Je,$ as Xe,fD as en,fE as nn,fF as sn,fG as tn,m as an,a as ne,fH as rn,u as on}from"./index-bYhLX3oQ.js";import{a as cn}from"./agent-browser-CoSmBP5N.js";function ln(e,s){const t=W();return Fe({queryKey:["mcp-config",e,s??null],queryFn:()=>t.getMcpConfig(e,{runtime:s??void 0}),enabled:!!e,staleTime:3e4})}function be(e,s){e.invalidateQueries({queryKey:De.mcpServers(s)}),e.invalidateQueries({queryKey:["mcp-config"]})}function Se(e){const s=W(),t=ge();return se({mutationFn:async({input:i,approval:a})=>a?(await s.grantApproval(a.approvalId),e(s,i,a.approvalToken)):e(s,i),onSuccess:(i,{input:a})=>{i.status==="ok"&&be(t,a.agentId)}})}function ye(){return Se((e,s,t)=>e.addAgentMcpServer(s,t?{approvalToken:t}:void 0))}function dn(){return Se((e,s,t)=>e.importAgentMcpServer(s,t?{approvalToken:t}:void 0))}function re(e){const s=W(),t=ge();return se({mutationFn:({agentId:i,name:a})=>e(s,i,a),onSuccess:(i,{agentId:a})=>be(t,a)})}function un(){return re((e,s,t)=>e.removeAgentMcpServer(s,t))}function mn(){return re((e,s,t)=>e.enableAgentMcpServer(s,t))}function hn(){return re((e,s,t)=>e.disableAgentMcpServer(s,t))}function gn(){const e=W();return se({mutationFn:({agentId:s,name:t})=>e.testAgentMcpServer(s,t)})}function pn({agentId:e,serverName:s,onDone:t}){const i=pe(e,s),{start:a}=i,r=l.useRef(!1);return l.useEffect(()=>{r.current||(r.current=!0,a())},[a]),n.jsx(F,{children:n.jsxs(D,{className:"space-y-2",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Sign in to ",s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"This server needs you to sign in before your agent can use it."}),n.jsx(fe,{flow:i,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>i.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Done"})}),i.state.step!=="failed"&&i.state.step!=="connected"&&n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]})})}const fn=["stdio","http","sse"],xn=/^[a-zA-Z0-9_-]+$/;function ue(e){const s={};for(const t of e.split(`
2
- `)){const i=t.trim();if(!i)continue;const a=i.indexOf("=");if(a===-1)continue;const r=i.slice(0,a).trim();r&&(s[r]=i.slice(a+1).trim())}return s}function me(e){return e.trim().length?e.trim().split(/\s+/):[]}function vn(e,s){if(e.status!=="ok")return!1;const t=e.servers.find(a=>a.name===s),i=t==null?void 0:t.connection;return i!==void 0&&"authKind"in i&&i.authKind==="oauth2"}function jn({agentId:e,agentLabel:s,supportedTransports:t,onAdded:i,oauthDetectedFor:a=null}){const r=ye(),[c,u]=l.useState(!1),[h,x]=l.useState(""),[p,m]=l.useState(t[0]??"stdio"),o=t.includes(p)?p:t[0]??"stdio",[v,C]=l.useState(""),[b,k]=l.useState(""),[j,z]=l.useState(""),[y,M]=l.useState(""),[P,A]=l.useState(""),[O,R]=l.useState(null),[T,I]=l.useState(null),[Z,U]=l.useState(null),[K,V]=l.useState(null),B=xn.test(h)&&h.length<=64,q=o==="stdio"?v.trim().length>0:y.trim().length>0,d=B&&q&&!r.isPending,N=l.useCallback(()=>o==="stdio"?{transport:"stdio",command:v.trim(),args:me(b),env:ue(j)}:{transport:o,url:y.trim(),headers:ue(P)},[o,v,b,j,y,P]),w=l.useCallback(()=>({agentId:e,name:h.trim(),connection:N()}),[e,h,N]),E=l.useCallback(()=>{u(!1),R(null),I(null),x(""),m(t[0]??"stdio"),C(""),k(""),z(""),M(""),A("")},[t]),oe=l.useCallback(g=>{i({name:g.name,transport:g.connection.transport}),E()},[i,E]),H=l.useCallback((g,S)=>{const Ie=vn(g,S.name);oe(S),Ie&&U(S.name)},[oe]),Ee=l.useCallback(async()=>{I(null);const g=w();try{const S=await r.mutateAsync({input:g});S.status==="approval_required"?R(S.approval):H(S,g)}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,H]),ze=l.useCallback(async()=>{if(!O)return;I(null);const g=w();try{const S=await r.mutateAsync({input:g,approval:O});S.status==="ok"?H(S,g):I("The server still needs approval. Try again.")}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,O,H]),Y=Z??(a&&a!==K?a:null),Pe=l.useCallback(()=>{V(Y),U(null)},[Y]),Re=l.useMemo(()=>[v.trim(),...me(b)].filter(Boolean).join(" "),[v,b]);return Y?n.jsx(pn,{agentId:e,serverName:Y,onDone:Pe}):c?O?n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Confirm this server for ",s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:o==="stdio"?"This command runs on your machine whenever the agent starts a session.":"The agent connects to this URL whenever it starts a session."})]})]}),n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:o==="stdio"?Re:y.trim()}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>R(null),disabled:r.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{size:"sm",onClick:ze,disabled:r.isPending,className:"focus-visible:ring-2",children:r.isPending?"Adding…":"Confirm & add"})]})]})}):n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-name",children:"Name"}),n.jsx(G,{id:"mcp-name",value:h,onChange:g=>x(g.target.value),placeholder:"my-server","aria-invalid":h.length>0&&!B}),h.length>0&&!B&&n.jsx("p",{className:"text-destructive text-xs",children:"Letters, numbers, dashes, underscores only."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-transport",children:"Transport"}),n.jsxs(Le,{value:o,onValueChange:g=>m(g),children:[n.jsx(_e,{id:"mcp-transport",className:"w-full",children:n.jsx($e,{})}),n.jsx(Ke,{children:t.map(g=>n.jsx(Be,{value:g,children:g},g))})]})]}),o==="stdio"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-command",children:"Command"}),n.jsx(G,{id:"mcp-command",value:v,onChange:g=>C(g.target.value),placeholder:"npx",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-args",children:"Arguments"}),n.jsx(G,{id:"mcp-args",value:b,onChange:g=>k(g.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-env",children:"Environment (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-env",value:j,onChange:g=>z(g.target.value),placeholder:"API_KEY=…",rows:2,className:"font-mono text-xs"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-url",children:"URL"}),n.jsx(G,{id:"mcp-url",value:y,onChange:g=>M(g.target.value),placeholder:"https://example.com/mcp",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(L,{htmlFor:"mcp-headers",children:"Headers (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-headers",value:P,onChange:g=>A(g.target.value),placeholder:"Authorization=Bearer …",rows:2,className:"font-mono text-xs"})]})]}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsx(Ue,{}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:E,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:Ee,disabled:!d,className:"focus-visible:ring-2",children:"Continue"})]})]})}):n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>u(!0),className:"focus-visible:ring-2",children:[n.jsx(xe,{className:"size-4"}),"Add server"]})}const Nn={connected:"connected","needs-auth":"needs-sign-in",pending:"connecting",disabled:"off"},bn=["validation","invalid config","invalid configuration","missing required","command not found","enoent"];function ie(e){if(!e)return"cant-reach";const s=e.toLowerCase();return bn.some(t=>s.includes(t))?"setup-problem":"cant-reach"}function Ce(e){return e.transport==="stdio"||e.authKind==="oauth2"?!1:Object.keys(e.headers).some(s=>s.toLowerCase()==="authorization")}function Sn(e){const{connection:s,authStatus:t}=e;return s.transport!=="stdio"&&s.authKind==="oauth2"?!0:t!==void 0}function we(e){const{enabled:s,testedOk:t,signedInNow:i,runtimeStatus:a,runtimeError:r,authStatus:c,ownKey:u}=e;return s?t?"connected":i?"signed-in":a==="failed"?ie(r):c==="connected"&&a==="needs-auth"?"signed-in":c==="needs-auth"&&(a==="connected"||a==="pending")?"needs-sign-in":a?Nn[a]:c==="connected"?"signed-in":c==="needs-auth"?"needs-sign-in":u?"uses-your-key":"not-checked":"off"}function yn(e){const{statusKey:s,testResult:t,signedInNow:i}=e;return s==="off"||i?!1:(t==null?void 0:t.needsAuth)===!0?!0:s==="needs-sign-in"}function Cn(e){const{stamped:s,signedInNow:t,authStatus:i,rosterUpdatedAt:a}=e;if(!s)return;const{result:r}=s;if(!(t&&r.needsAuth===!0)&&!(s.at<=a&&(i==="needs-auth"&&r.ok||i==="connected"&&r.needsAuth===!0)))return r}function wn(e){const{status:s,probe:t}=e;return s==="off"||!t||t.ok?s:t.needsAuth===!0?"needs-sign-in":ie(t.error)}const Q={attention:0,working:1,elsewhere:2,off:3};function kn(e){return e==="off"?Q.off:e==="needs-sign-in"||e==="cant-reach"||e==="setup-problem"?Q.attention:Q.working}function An(e){const{managed:s,live:t,discovered:i}=e;return[...s.map(r=>{var c,u;return{name:r.name,band:kn(we({enabled:r.enabled,testedOk:!1,signedInNow:!1,runtimeStatus:(c=t.get(r.name))==null?void 0:c.status,runtimeError:(u=t.get(r.name))==null?void 0:u.error,authStatus:r.authStatus,ownKey:Ce(r.connection)}))}}),...i.map(r=>({name:r.name,band:Q.elsewhere}))].map((r,c)=>({entry:r,index:c})).sort((r,c)=>r.entry.band-c.entry.band||r.index-c.index).map(({entry:r})=>r.name)}function Tn(e){const{frozen:s,present:t}=e,i=new Set(t),a=new Set(s);return{ordered:s.filter(r=>i.has(r)),added:t.filter(r=>!a.has(r))}}function Mn(){const e=Ve(null);return({bothSettled:s,managed:t,live:i,discovered:a,present:r})=>{e.read()===null&&s&&r.length>0&&e.write(An({managed:t,live:i,discovered:a}));const{ordered:c,added:u}=Tn({frozen:e.read()??[],present:r});return u.length>0&&e.read()!==null&&e.write([...c,...u]),[...c,...u]}}const ke={"needs-sign-in":{label:"Needs sign-in",tooltip:"Sign in to let this agent use the server.",tone:"attention"},"signing-in":{label:"Signing in…",tooltip:"A sign-in is in progress. Finish it in the tab that opened.",tone:"attention"},connected:{label:"Connected",tooltip:"This server answered, and its tools are available to the agent.",tone:"calm"},"signed-in":{label:"Signed in",tooltip:"DorkOS has a sign-in for this server. Use Test to check it responds.",tone:"calm"},"uses-your-key":{label:"Uses your key",tooltip:"This server is authenticated with a key you supplied, not one DorkOS holds.",tone:"calm"},"cant-reach":{label:"Can’t reach",tooltip:"The server did not answer. Open Details for what it said.",tone:"error"},"setup-problem":{label:"Setup problem",tooltip:"This server’s setup is wrong, so it could not start. Open Details for the reason.",tone:"error"},connecting:{label:"Connecting…",tooltip:"The agent is connecting to this server.",tone:"calm"},"not-checked":{label:"Not checked yet",tooltip:"Nothing has contacted this server yet, so there is nothing to report.",tone:"calm"},off:{label:"Off",tooltip:"Turned off. Its tools are not given to the agent.",tone:"calm"}},On={"needs-sign-in":"sign-in","signing-in":"none",connected:"none","signed-in":"test","uses-your-key":"test","cant-reach":"try-again","setup-problem":"try-again",connecting:"none","not-checked":"test",off:"none"};function En(e){return On[e]}function zn({toolCount:e,justSignedIn:s}){const t=s?"Signed in just now. ":"";return e===null?`${t||"This server answered. "}Its tools are available.`:`${t}${e} tool${e===1?"":"s"} available.`}function Pn(e,s){switch(e){case"needs-sign-in":return`Sign in to ${s.displayName} so this agent can use its tools.`;case"signing-in":return null;case"connected":return zn(s);case"signed-in":return s.justSignedIn?"Signed in just now. Test to check the server responds.":"DorkOS has a sign-in for this server. Test to check it responds.";case"uses-your-key":return"You added an access key when setting this up.";case"cant-reach":return"This server didn’t answer. It may be down.";case"setup-problem":return"This server’s setup has a problem.";case"connecting":return"Connecting to this server.";case"not-checked":return"Nothing has checked this server yet.";case"off":return"Turned off. The agent doesn’t see this server."}}function Rn(e){const{connection:s,authStatus:t,clientOrigin:i}=e;return s.transport==="stdio"?"None. This server doesn’t need one.":s.authKind==="oauth2"?i==="manual"?`OAuth: using your own app credentials, ${t==="connected"?"signed in, and it renews automatically":"not signed in yet"}. DorkOS holds the key; the agent never sees it.`:t==="connected"?"OAuth: signed in, and it renews automatically. DorkOS holds the key; the agent never sees it.":"OAuth: DorkOS will hold the key for you; the agent never sees it.":Object.keys(s.headers).some(r=>r.toLowerCase()==="authorization")?"Access key: you added a key when setting this up.":t===void 0?"Nothing has checked this yet.":"None. This server doesn’t need one."}function In(e){if(e.transport==="stdio")return`Runs \`${e.command}\` on this computer`;const s=Fn(e.url);return s?`${s} (web service)`:`${e.url} (web service)`}function Fn(e){try{return new URL(e).host}catch{return null}}const Dn={agent:"Added to this agent through DorkOS",project:"From this project, declared in its config files",plugin:"Comes with a plugin",computer:"From your computer-wide config"},Ln={agent:"Added to this agent through DorkOS.",project:"From this project’s config. Add it to manage it here.",plugin:"Comes with a plugin. Add it to manage it here.",computer:"From your computer-wide config. Add it to manage it here."},_n=[{runtime:"claude-code",pattern:/^plugin:([^:]+):(.+)$/,read:e=>({pluginName:e[1],displayName:e[2]})},{runtime:"claude-code",pattern:/^plugin:(.+)$/,read:e=>({pluginName:e[1],displayName:e[1]})}];function Ae(e){for(const s of _n){const t=e.match(s.pattern);if(!t)continue;const{displayName:i,pluginName:a}=s.read(t);if(!(!i||!a))return{displayName:i,pluginName:a,rawName:e}}return{displayName:e,pluginName:null,rawName:e}}function $n(e,s){return s.pluginName?"plugin":e.scope==="project"||e.scope==="local"?"project":e.scope==="user"?"computer":null}const Kn="This agent’s runtime loads this server. Add it to manage it here.";function Te(e,s){return e==="plugin"&&s?`Comes with the ${s} plugin`:Dn[e]}function Bn(e,s){return e===null?Kn:e==="plugin"&&s?`Comes with the ${s} plugin. Add it to manage it here.`:Ln[e]}const Un=ae("border-border/60 relative overflow-hidden rounded-md border px-3 py-2.5 transition-colors",{variants:{managed:{true:"bg-card",false:"bg-muted/30"},dimmed:{true:"opacity-65",false:""}},defaultVariants:{managed:!0,dimmed:!1}}),Vn=ae("pointer-events-none absolute inset-y-0 left-0 w-0.5",{variants:{tone:{calm:"hidden",attention:"bg-status-warning",error:"bg-status-error"}},defaultVariants:{tone:"calm"}}),qn=ae("shrink-0 rounded-full px-2 py-0.5 text-2xs leading-4 font-medium whitespace-nowrap",{variants:{chip:{success:"bg-status-success-bg text-status-success-fg",info:"bg-status-info-bg text-status-info-fg",warning:"bg-status-warning-bg text-status-warning-fg",error:"bg-status-error-bg text-status-error-fg",neutral:"bg-muted text-muted-foreground"}},defaultVariants:{chip:"neutral"}}),Hn={connected:"success","signed-in":"info","needs-sign-in":"warning","signing-in":"warning","cant-reach":"error","setup-problem":"error","uses-your-key":"neutral",connecting:"neutral","not-checked":"neutral",off:"neutral"};function Yn({status:e}){const s=ke[e];return n.jsxs(ve,{children:[n.jsx(je,{asChild:!0,children:n.jsx("span",{className:qn({chip:Hn[e]}),children:s.label})}),n.jsx(Ne,{children:s.tooltip})]})}function Gn({scope:e,pluginName:s}){return n.jsxs(ve,{children:[n.jsx(je,{asChild:!0,children:n.jsx(qe,{size:"xs",tone:"neutral",variant:"secondary",className:"shrink-0 font-normal",children:e})}),n.jsx(Ne,{children:Te(e,s)})]})}function Me({displayName:e,rawName:s,scope:t,pluginName:i,status:a,sentence:r,managed:c,toggle:u,actions:h,children:x,details:p,defaultDetailsOpen:m=!1}){const[o,v]=l.useState(m),C=l.useId(),b=ke[a].tone;return n.jsxs("div",{"data-mcp-server":s,className:le(Un({managed:c,dimmed:a==="off"}),"mb-2 last:mb-0"),children:[n.jsx("span",{className:Vn({tone:b}),"aria-hidden":!0}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e}),t&&n.jsx(Gn,{scope:t,pluginName:i}),n.jsx(Yn,{status:a}),u]}),r&&n.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:r}),x,h&&n.jsx("div",{className:"mt-2 flex items-center gap-1",children:h}),p&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:()=>v(k=>!k),"aria-expanded":o,"aria-controls":C,className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:le("size-3 transition-transform",o&&"rotate-90"),"aria-hidden":!0}),"Details"]}),o&&n.jsxs("div",{id:C,children:[p,n.jsxs("button",{type:"button",onClick:()=>v(!1),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:"size-3 -rotate-90","aria-hidden":!0}),"Collapse details"]})]})]})]})}const Qn=3,$="text-muted-foreground/70";function Wn({tools:e}){const[s,t]=l.useState(!1),i=s?e:e.slice(0,Qn),a=e.length-i.length;return n.jsxs("div",{className:"mt-1.5",children:[i.map(r=>n.jsxs("div",{className:"border-border/40 flex items-baseline gap-2 border-b py-1 last:border-b-0",children:[n.jsx("code",{className:"text-foreground text-2xs shrink-0 font-mono",children:r.name}),r.description&&n.jsx("span",{className:"text-muted-foreground text-2xs truncate",children:r.description})]},r.name)),a>0&&n.jsxs("button",{type:"button",onClick:()=>t(!0),className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(X,{className:"size-3","aria-hidden":!0}),"Show ",a," more"]})]})}function Zn(e){const{scope:s,pluginName:t,connection:i}=e;return s==="plugin"&&t?`Comes with the ${t} plugin`:i?In(i):s?Te(s,t):null}function Oe({connection:e,authStatus:s,authClientOrigin:t,scope:i,pluginName:a,rawName:r,displayName:c,toolCount:u,tools:h,serverInfo:x,alsoUsedBy:p,error:m}){const o=Zn({scope:i,pluginName:a,connection:e});return n.jsxs("div",{className:"border-border/60 text-muted-foreground mt-2 space-y-1 border-t pt-2 text-xs leading-relaxed",children:[e&&n.jsx(_,{label:"Sign-in",align:"start",wrap:!0,labelClassName:$,children:n.jsxs("span",{className:"inline-flex items-start gap-1.5",children:[n.jsx(He,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),Rn({connection:e,authStatus:s,clientOrigin:t})]})}),o&&n.jsx(_,{label:"Source",align:"start",wrap:!0,labelClassName:$,children:o}),r!==c&&n.jsx(_,{label:"Raw id",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono",children:r})}),x&&n.jsx(_,{label:"Server",align:"start",wrap:!0,labelClassName:$,children:x}),p&&n.jsx(_,{label:"Also used by",align:"start",wrap:!0,labelClassName:$,children:p}),typeof u=="number"&&n.jsx(_,{label:"Tools",align:"start",labelClassName:$,children:u}),h&&h.length>0&&n.jsx(Wn,{tools:h}),m&&n.jsx(_,{label:"Error",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono break-all",children:m})})]})}function Jn({flow:e,serverName:s}){return n.jsxs(n.Fragment,{children:[n.jsx(fe,{flow:e,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>e.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})}),(e.state.step==="disclosure"||e.state.step==="waiting")&&n.jsx("div",{className:"mt-2",children:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),"aria-label":`Cancel signing in to ${s}`,className:"focus-visible:ring-2",children:"Cancel"})})]})}function Xn({server:e,agentId:s,live:t,testResult:i,rosterUpdatedAt:a,testing:r,busy:c,onToggle:u,onTest:h,onRemove:x}){const p=pe(s,e.name),m=p.state.step==="connected",o=Cn({stamped:i,signedInNow:m,authStatus:e.authStatus,rosterUpdatedAt:a}),v=Ce(e.connection),C=we({enabled:e.enabled,testedOk:(o==null?void 0:o.ok)===!0,signedInNow:m,runtimeStatus:t==null?void 0:t.status,runtimeError:t==null?void 0:t.error,authStatus:e.authStatus,ownKey:v}),b=p.state.step==="starting",k=p.state.step==="disclosure"||p.state.step==="waiting"||b,j=k?"signing-in":C,z=yn({statusKey:C,testResult:o,signedInNow:m})&&(p.state.step==="idle"||b),y=Ae(e.name),M=o!=null&&o.ok?o.toolCount??null:p.state.toolCount,P=k?j:wn({status:j,probe:o}),A=Pn(P,{displayName:y.displayName,toolCount:M,justSignedIn:m}),O=k?"none":En(P),R=Sn({connection:e.connection,authStatus:e.authStatus});return n.jsx(Me,{displayName:y.displayName,rawName:e.name,scope:"agent",pluginName:y.pluginName,status:j,sentence:A,managed:!0,toggle:n.jsx(Xe,{checked:e.enabled,onCheckedChange:T=>u(e.name,T),disabled:c,"aria-label":`Enable ${e.name}`}),actions:n.jsxs(n.Fragment,{children:[z&&n.jsxs(f,{variant:"default",size:"sm",onClick:()=>p.start(),disabled:c||b,"aria-label":`Sign in to ${e.name}`,className:"gap-1.5 focus-visible:ring-2",children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in"]}),!z&&O==="try-again"&&n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>h(e.name),disabled:r||c,"aria-label":`Try ${e.name} again`,className:"gap-1.5 focus-visible:ring-2",children:[r?n.jsx(ee,{size:"xs"}):null,"Try again"]}),!z&&O==="test"&&n.jsx(f,{variant:"outline",size:"sm",onClick:()=>h(e.name),disabled:r||c,className:"focus-visible:ring-2",children:r?n.jsx(ee,{size:"xs"}):"Test"}),n.jsxs(Ye,{children:[n.jsx(Ge,{asChild:!0,children:n.jsx(f,{variant:"ghost",size:"sm","aria-label":`More actions for ${e.name}`,className:"ml-auto focus-visible:ring-2",children:n.jsx(Qe,{className:"size-4","aria-hidden":!0})})}),n.jsxs(We,{align:"end",children:[n.jsxs(J,{onSelect:()=>h(e.name),disabled:r||c,children:[n.jsx(Ze,{className:"size-3.5","aria-hidden":!0}),"Test"]}),R&&n.jsxs(J,{onSelect:()=>p.start(),disabled:c,children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in again"]}),n.jsx(Je,{}),n.jsx(J,{variant:"destructive",onSelect:()=>x(e.name),disabled:c,children:"Remove"})]})]})]}),details:n.jsx(Oe,{connection:e.connection,authStatus:e.authStatus,authClientOrigin:e.authClientOrigin,scope:"agent",pluginName:y.pluginName,rawName:y.rawName,displayName:y.displayName,toolCount:M,error:(o==null?void 0:o.ok)===!1?o.error:t==null?void 0:t.error}),children:n.jsx(Jn,{flow:p,serverName:y.displayName})})}function es(e){switch(e.status){case"connected":return"connected";case"failed":return ie(e.error);case"needs-auth":return"needs-sign-in";case"pending":return"connecting";case"disabled":return"off";default:return"not-checked"}}function ns(e){const{displayName:s,scope:t,pluginName:i}=e,a=ss(t,i);return`${s} ${a}. Manage it here to enable, disable, or sign in from DorkOS.`}function ss(e,s){return e==="plugin"&&s?`comes with the ${s} plugin`:e==="project"?"comes from this project’s own config":e==="computer"?"comes from your computer-wide config":"is loaded by this agent’s runtime"}function ts({entry:e,agentId:s,agentLabel:t,canImport:i}){const a=dn(),[r,c]=l.useState(null),[u,h]=l.useState(null),x=l.useCallback(async()=>{h(null);try{const j=await a.mutateAsync({input:{agentId:s,name:e.name}});j.status==="approval_required"&&c(j.approval)}catch(j){h(j instanceof Error?j.message:"Couldn’t add the server.")}},[a,s,e.name]),p=l.useCallback(async()=>{if(r){h(null);try{(await a.mutateAsync({input:{agentId:s,name:e.name},approval:r})).status!=="ok"&&h("Adding it still needs approval. Try again.")}catch(j){h(j instanceof Error?j.message:"Couldn’t add the server.")}}},[a,s,e.name,r]),m=Ae(e.name),o=$n(e,m),v=o!==null,C=m.rawName!==m.displayName,b=e.error!==void 0,k=v||C||b;return r?n.jsxs("div",{className:"border-border/60 mb-2 space-y-3 rounded-md border p-3 last:mb-0",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Add “",m.displayName,"” to ",t,"?"]}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:ns({displayName:m.displayName,scope:o,pluginName:m.pluginName})})]})]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>c(null),disabled:a.isPending,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:p,disabled:a.isPending,className:"focus-visible:ring-2",children:a.isPending?"Adding…":"Add to agent"})]})]}):n.jsx(Me,{displayName:m.displayName,rawName:e.name,scope:o,pluginName:m.pluginName,status:es(e),sentence:Bn(o,m.pluginName),managed:!1,actions:i?n.jsxs(n.Fragment,{children:[n.jsxs(f,{variant:"outline",size:"sm",onClick:x,disabled:a.isPending,"aria-label":`Add ${e.name} to agent`,className:"gap-1.5 focus-visible:ring-2",children:[a.isPending?n.jsx(ee,{size:"xs"}):n.jsx(xe,{className:"size-(--size-icon-xs)","aria-hidden":!0}),"Add to agent"]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u})]}):void 0,details:k?n.jsx(Oe,{scope:o,pluginName:m.pluginName,rawName:m.rawName,displayName:m.displayName,error:e.error}):void 0})}function as(e,s){return{agentId:e,name:s.server.name,connection:s.server.connection}}function rs(e){const s=e.sites.filter(t=>!t.expired).map(t=>t.site);return s.length<=3?s.join(", "):`${s.slice(0,3).join(", ")} and ${s.length-3} more`}function is({agentId:e,agentLabel:s}){const t=en(),i=ye(),[a,r]=l.useState(null),[c,u]=l.useState(null),h=l.useCallback(async o=>{if(t.data){u(null);try{const v=await i.mutateAsync({input:as(e,t.data),...o?{approval:o}:{}});v.status!=="approval_required"?r(null):o?u("The browser still needs approval. Try again."):r(v.approval)}catch(v){u(v instanceof Error?v.message:"Couldn’t add the browser.")}}},[i,e,t.data]);if(!t.data)return null;const x=t.data,p=rs(x),m=`${x.loginCommand} <site>`;return n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[a?n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}):n.jsx(nn,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:a?`Confirm the signed-in browser for ${s}`:"Signed-in browser"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:a?"This command runs on your machine whenever the agent starts a session. Each session gets its own browser, so agents working at the same time never share one.":"A web browser that starts signed in to the sites you saved. The agent never sees your passwords."}),x.saved?n.jsxs("p",{className:"text-xs",children:["Signed in to ",p,"."]}):n.jsxs("p",{className:"text-status-warning-fg text-xs",children:["No sign-ins saved yet, so it starts signed out. Run"," ",n.jsx("code",{className:"font-mono",children:m}),n.jsx(sn,{value:m,label:"Copy the sign-in command",size:"xs",className:"mx-0.5 inline-flex align-middle"})," ","in a terminal first."]})]})]}),a&&n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:[x.server.connection.command,...x.server.connection.args].join(" ")}),c&&n.jsx("p",{className:"text-destructive text-xs",children:c}),n.jsxs("div",{className:"flex justify-end gap-2",children:[a&&n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>r(null),disabled:i.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{variant:a?"default":"outline",size:"sm",onClick:()=>void h(a??void 0),disabled:i.isPending,className:"focus-visible:ring-2",children:i.isPending?"Adding…":a?"Confirm & add":"Give it the browser"})]})]})})}const os={codex:["stdio","http"],opencode:["stdio","http"]};function he(e){return os[e]??fn}function cs(){const{open:e}=rn();return n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Want other apps to use DorkOS as an MCP server instead? That is the other direction."," ",n.jsx(f,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>e("tools","external-mcp"),children:"See Settings → Tools"})]})}function ls({agent:e,projectPath:s}){var q;const t=tn(e.id),i=ln(s,e.runtime),a=i.data,r=an(e.runtime),c=(r==null?void 0:r.supportsManagedMcpServers)??!0,u=mn(),h=hn(),x=un(),p=gn(),[m,o]=l.useState({}),[v,C]=l.useState(null),[b,k]=l.useState(null),j=Mn(),z=l.useCallback((d,N)=>{(N?u:h).mutate({agentId:e.id,name:d})},[e.id,u,h]),y=l.useCallback(d=>{x.mutate({agentId:e.id,name:d}),o(N=>{const w={...N};return delete w[d],w})},[e.id,x]),M=l.useCallback(async d=>{C(d);try{const N=await p.mutateAsync({agentId:e.id,name:d});o(w=>({...w,[d]:{result:N,at:Date.now()}}))}finally{C(null)}},[e.id,p]),P=l.useCallback(({name:d,transport:N})=>{k(d),N!=="stdio"&&M(d).catch(()=>{})},[M]),A=t.data??[],O=new Set(A.map(d=>d.name)),R=new Map(((a==null?void 0:a.servers)??[]).map(d=>[d.name,d])),T=((a==null?void 0:a.servers)??[]).filter(d=>!O.has(d.name)),I=u.isPending||h.isPending||x.isPending,Z=A.some(d=>cn(d.connection)!==void 0),U=c&&!t.isPending&&!Z&&he(e.runtime).includes("stdio"),K=new Map;A.forEach((d,N)=>K.set(d.name,{kind:"managed",index:N})),T.forEach((d,N)=>K.set(d.name,{kind:"discovered",index:N}));const V=j({bothSettled:!t.isPending&&!i.isPending,managed:A,live:R,discovered:T,present:[...A.map(d=>d.name),...T.map(d=>d.name)]});function B(d){const N=K.get(d);if(!N)return null;if(N.kind==="managed"){const E=A[N.index];return n.jsx(Xn,{server:E,agentId:e.id,live:R.get(E.name),testResult:m[E.name],rosterUpdatedAt:t.dataUpdatedAt,testing:v===E.name,busy:I,onToggle:z,onTest:M,onRemove:y},E.name)}const w=T[N.index];return n.jsx(ts,{entry:w,agentId:e.id,agentLabel:e.displayName??e.name,canImport:c},w.name)}return n.jsxs("section",{className:"space-y-3","aria-label":"MCP servers",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"MCP Servers"}),c&&n.jsx(jn,{agentId:e.id,agentLabel:e.displayName??e.name,supportedTransports:he(e.runtime),onAdded:P,oauthDetectedFor:b&&((q=m[b])==null?void 0:q.result.needsAuth)===!0?b:null})]}),n.jsx(cs,{}),U&&n.jsx(is,{agentId:e.id,agentLabel:e.displayName??e.name}),!c&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"This agent’s runtime can’t run DorkOS-managed MCP servers yet. Any servers below show read-only status."}),t.isLoading?n.jsx(F,{children:n.jsxs(D,{className:"space-y-2",children:[n.jsx(ne,{className:"h-5 w-full"}),n.jsx(ne,{className:"h-5 w-3/4"})]})}):t.isError?n.jsx(F,{children:n.jsxs(D,{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{className:"text-destructive text-sm",children:"Couldn’t load managed servers."}),n.jsx(f,{variant:"outline",size:"sm",onClick:()=>t.refetch(),className:"focus-visible:ring-2",children:"Retry"})]})}):V.length===0?n.jsx(F,{children:n.jsx(D,{children:n.jsxs("p",{className:"text-muted-foreground text-sm",children:["No MCP servers yet."," ",c?"Add one to give this agent tools from an external server.":"This runtime can’t run managed servers."]})})}):n.jsx(F,{children:n.jsx(D,{children:V.map(B)})})]})}function ms({member:e}){const{agent:s,projectPath:t,isPending:i}=on(e);return i?n.jsx(ne,{className:"h-32 w-full"}):!s||t===null?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s MCP servers."}):n.jsx(ls,{agent:s,projectPath:t})}export{ms as ToolsPage};
1
+ import{af as W,ai as Fe,dh as se,aj as ge,fx as De,fy as pe,r as l,j as n,cy as F,cz as D,fz as fe,B as f,P as xe,fA as te,eO as _,I as G,dw as _e,dx as Le,dy as $e,dz as Ke,dA as Be,fB as ce,bp as Ue,fC as Ve,C as Z,al as le,fD as ae,ct as ve,cu as je,W as qe,cv as Ne,bs as L,cX as He,fE as de,aF as ee,e9 as Ye,ea as Ge,eb as Qe,ec as We,ed as X,am as Je,ef as Xe,$ as Ze,fF as en,fG as nn,fH as sn,fI as tn,m as an,a as ne,fJ as rn,u as on}from"./index-BCGiD7pg.js";import{a as cn}from"./agent-browser-da9rKrej.js";function ln(e,s){const t=W();return Fe({queryKey:["mcp-config",e,s??null],queryFn:()=>t.getMcpConfig(e,{runtime:s??void 0}),enabled:!!e,staleTime:3e4})}function be(e,s){e.invalidateQueries({queryKey:De.mcpServers(s)}),e.invalidateQueries({queryKey:["mcp-config"]})}function Se(e){const s=W(),t=ge();return se({mutationFn:async({input:i,approval:a})=>a?(await s.grantApproval(a.approvalId),e(s,i,a.approvalToken)):e(s,i),onSuccess:(i,{input:a})=>{i.status==="ok"&&be(t,a.agentId)}})}function ye(){return Se((e,s,t)=>e.addAgentMcpServer(s,t?{approvalToken:t}:void 0))}function dn(){return Se((e,s,t)=>e.importAgentMcpServer(s,t?{approvalToken:t}:void 0))}function re(e){const s=W(),t=ge();return se({mutationFn:({agentId:i,name:a})=>e(s,i,a),onSuccess:(i,{agentId:a})=>be(t,a)})}function un(){return re((e,s,t)=>e.removeAgentMcpServer(s,t))}function mn(){return re((e,s,t)=>e.enableAgentMcpServer(s,t))}function hn(){return re((e,s,t)=>e.disableAgentMcpServer(s,t))}function gn(){const e=W();return se({mutationFn:({agentId:s,name:t})=>e.testAgentMcpServer(s,t)})}function pn({agentId:e,serverName:s,onDone:t}){const i=pe(e,s),{start:a}=i,r=l.useRef(!1);return l.useEffect(()=>{r.current||(r.current=!0,a())},[a]),n.jsx(F,{children:n.jsxs(D,{className:"space-y-2",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Sign in to ",s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"This server needs you to sign in before your agent can use it."}),n.jsx(fe,{flow:i,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>i.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Done"})}),i.state.step!=="failed"&&i.state.step!=="connected"&&n.jsx(f,{variant:"ghost",size:"sm",onClick:t,className:"focus-visible:ring-2",children:"Later"})]})})}const fn=["stdio","http","sse"],xn=/^[a-zA-Z0-9_-]+$/;function ue(e){const s={};for(const t of e.split(`
2
+ `)){const i=t.trim();if(!i)continue;const a=i.indexOf("=");if(a===-1)continue;const r=i.slice(0,a).trim();r&&(s[r]=i.slice(a+1).trim())}return s}function me(e){return e.trim().length?e.trim().split(/\s+/):[]}function vn(e,s){if(e.status!=="ok")return!1;const t=e.servers.find(a=>a.name===s),i=t==null?void 0:t.connection;return i!==void 0&&"authKind"in i&&i.authKind==="oauth2"}function jn({agentId:e,agentLabel:s,supportedTransports:t,onAdded:i,oauthDetectedFor:a=null}){const r=ye(),[c,u]=l.useState(!1),[h,x]=l.useState(""),[p,m]=l.useState(t[0]??"stdio"),o=t.includes(p)?p:t[0]??"stdio",[v,C]=l.useState(""),[b,k]=l.useState(""),[j,E]=l.useState(""),[y,M]=l.useState(""),[P,A]=l.useState(""),[O,R]=l.useState(null),[T,I]=l.useState(null),[J,U]=l.useState(null),[K,V]=l.useState(null),B=xn.test(h)&&h.length<=64,q=o==="stdio"?v.trim().length>0:y.trim().length>0,d=B&&q&&!r.isPending,N=l.useCallback(()=>o==="stdio"?{transport:"stdio",command:v.trim(),args:me(b),env:ue(j)}:{transport:o,url:y.trim(),headers:ue(P)},[o,v,b,j,y,P]),w=l.useCallback(()=>({agentId:e,name:h.trim(),connection:N()}),[e,h,N]),z=l.useCallback(()=>{u(!1),R(null),I(null),x(""),m(t[0]??"stdio"),C(""),k(""),E(""),M(""),A("")},[t]),oe=l.useCallback(g=>{i({name:g.name,transport:g.connection.transport}),z()},[i,z]),H=l.useCallback((g,S)=>{const Ie=vn(g,S.name);oe(S),Ie&&U(S.name)},[oe]),ze=l.useCallback(async()=>{I(null);const g=w();try{const S=await r.mutateAsync({input:g});S.status==="approval_required"?R(S.approval):H(S,g)}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,H]),Ee=l.useCallback(async()=>{if(!O)return;I(null);const g=w();try{const S=await r.mutateAsync({input:g,approval:O});S.status==="ok"?H(S,g):I("The server still needs approval. Try again.")}catch(S){I(S instanceof Error?S.message:"Couldn’t add the server.")}},[r,w,O,H]),Y=J??(a&&a!==K?a:null),Pe=l.useCallback(()=>{V(Y),U(null)},[Y]),Re=l.useMemo(()=>[v.trim(),...me(b)].filter(Boolean).join(" "),[v,b]);return Y?n.jsx(pn,{agentId:e,serverName:Y,onDone:Pe}):c?O?n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Confirm this server for ",s]}),n.jsx("p",{className:"text-muted-foreground text-xs",children:o==="stdio"?"This command runs on your machine whenever the agent starts a session.":"The agent connects to this URL whenever it starts a session."})]})]}),n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:o==="stdio"?Re:y.trim()}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>R(null),disabled:r.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{size:"sm",onClick:Ee,disabled:r.isPending,className:"focus-visible:ring-2",children:r.isPending?"Adding…":"Confirm & add"})]})]})}):n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-name",children:"Name"}),n.jsx(G,{id:"mcp-name",value:h,onChange:g=>x(g.target.value),placeholder:"my-server","aria-invalid":h.length>0&&!B}),h.length>0&&!B&&n.jsx("p",{className:"text-destructive text-xs",children:"Letters, numbers, dashes, underscores only."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-transport",children:"Transport"}),n.jsxs(_e,{value:o,onValueChange:g=>m(g),children:[n.jsx(Le,{id:"mcp-transport",className:"w-full",children:n.jsx($e,{})}),n.jsx(Ke,{children:t.map(g=>n.jsx(Be,{value:g,children:g},g))})]})]}),o==="stdio"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-command",children:"Command"}),n.jsx(G,{id:"mcp-command",value:v,onChange:g=>C(g.target.value),placeholder:"npx",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-args",children:"Arguments"}),n.jsx(G,{id:"mcp-args",value:b,onChange:g=>k(g.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-env",children:"Environment (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-env",value:j,onChange:g=>E(g.target.value),placeholder:"API_KEY=…",rows:2,className:"font-mono text-xs"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-url",children:"URL"}),n.jsx(G,{id:"mcp-url",value:y,onChange:g=>M(g.target.value),placeholder:"https://example.com/mcp",className:"font-mono"})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_,{htmlFor:"mcp-headers",children:"Headers (KEY=VALUE per line)"}),n.jsx(ce,{id:"mcp-headers",value:P,onChange:g=>A(g.target.value),placeholder:"Authorization=Bearer …",rows:2,className:"font-mono text-xs"})]})]}),T&&n.jsx("p",{className:"text-destructive text-xs",children:T}),n.jsx(Ue,{}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:z,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:ze,disabled:!d,className:"focus-visible:ring-2",children:"Continue"})]})]})}):n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>u(!0),className:"focus-visible:ring-2",children:[n.jsx(xe,{className:"size-4"}),"Add server"]})}const Nn={connected:"connected","needs-auth":"needs-sign-in",pending:"connecting",disabled:"off"},bn=["validation","invalid config","invalid configuration","missing required","command not found","enoent"];function ie(e){if(!e)return"cant-reach";const s=e.toLowerCase();return bn.some(t=>s.includes(t))?"setup-problem":"cant-reach"}function Ce(e){return e.transport==="stdio"||e.authKind==="oauth2"?!1:Object.keys(e.headers).some(s=>s.toLowerCase()==="authorization")}function Sn(e){const{connection:s,authStatus:t}=e;return s.transport!=="stdio"&&s.authKind==="oauth2"?!0:t!==void 0}function we(e){const{enabled:s,testedOk:t,signedInNow:i,runtimeStatus:a,runtimeError:r,authStatus:c,ownKey:u}=e;return s?t?"connected":i?"signed-in":a==="failed"?ie(r):c==="connected"&&a==="needs-auth"?"signed-in":c==="needs-auth"&&(a==="connected"||a==="pending")?"needs-sign-in":a?Nn[a]:c==="connected"?"signed-in":c==="needs-auth"?"needs-sign-in":u?"uses-your-key":"not-checked":"off"}function yn(e){const{statusKey:s,testResult:t,signedInNow:i}=e;return s==="off"||i?!1:(t==null?void 0:t.needsAuth)===!0?!0:s==="needs-sign-in"}function Cn(e){const{stamped:s,signedInNow:t,authStatus:i,rosterUpdatedAt:a}=e;if(!s)return;const{result:r}=s;if(!(t&&r.needsAuth===!0)&&!(s.at<=a&&(i==="needs-auth"&&r.ok||i==="connected"&&r.needsAuth===!0)))return r}function wn(e){const{status:s,probe:t}=e;return s==="off"||!t||t.ok?s:t.needsAuth===!0?"needs-sign-in":ie(t.error)}const Q={attention:0,working:1,elsewhere:2,off:3};function kn(e){return e==="off"?Q.off:e==="needs-sign-in"||e==="cant-reach"||e==="setup-problem"?Q.attention:Q.working}function An(e){const{managed:s,live:t,discovered:i}=e;return[...s.map(r=>{var c,u;return{name:r.name,band:kn(we({enabled:r.enabled,testedOk:!1,signedInNow:!1,runtimeStatus:(c=t.get(r.name))==null?void 0:c.status,runtimeError:(u=t.get(r.name))==null?void 0:u.error,authStatus:r.authStatus,ownKey:Ce(r.connection)}))}}),...i.map(r=>({name:r.name,band:Q.elsewhere}))].map((r,c)=>({entry:r,index:c})).sort((r,c)=>r.entry.band-c.entry.band||r.index-c.index).map(({entry:r})=>r.name)}function Tn(e){const{frozen:s,present:t}=e,i=new Set(t),a=new Set(s);return{ordered:s.filter(r=>i.has(r)),added:t.filter(r=>!a.has(r))}}function Mn(){const e=Ve(null);return({bothSettled:s,managed:t,live:i,discovered:a,present:r})=>{e.read()===null&&s&&r.length>0&&e.write(An({managed:t,live:i,discovered:a}));const{ordered:c,added:u}=Tn({frozen:e.read()??[],present:r});return u.length>0&&e.read()!==null&&e.write([...c,...u]),[...c,...u]}}const ke={"needs-sign-in":{label:"Needs sign-in",tooltip:"Sign in to let this agent use the server.",tone:"attention"},"signing-in":{label:"Signing in…",tooltip:"A sign-in is in progress. Finish it in the tab that opened.",tone:"attention"},connected:{label:"Connected",tooltip:"This server answered, and its tools are available to the agent.",tone:"calm"},"signed-in":{label:"Signed in",tooltip:"DorkOS has a sign-in for this server. Use Test to check it responds.",tone:"calm"},"uses-your-key":{label:"Uses your key",tooltip:"This server is authenticated with a key you supplied, not one DorkOS holds.",tone:"calm"},"cant-reach":{label:"Can’t reach",tooltip:"The server did not answer. Open Details for what it said.",tone:"error"},"setup-problem":{label:"Setup problem",tooltip:"This server’s setup is wrong, so it could not start. Open Details for the reason.",tone:"error"},connecting:{label:"Connecting…",tooltip:"The agent is connecting to this server.",tone:"calm"},"not-checked":{label:"Not checked yet",tooltip:"Nothing has contacted this server yet, so there is nothing to report.",tone:"calm"},off:{label:"Off",tooltip:"Turned off. Its tools are not given to the agent.",tone:"calm"}},On={"needs-sign-in":"sign-in","signing-in":"none",connected:"none","signed-in":"test","uses-your-key":"test","cant-reach":"try-again","setup-problem":"try-again",connecting:"none","not-checked":"test",off:"none"};function zn(e){return On[e]}function En({toolCount:e,justSignedIn:s}){const t=s?"Signed in just now. ":"";return e===null?`${t||"This server answered. "}Its tools are available.`:`${t}${e} tool${e===1?"":"s"} available.`}function Pn(e,s){switch(e){case"needs-sign-in":return`Sign in to ${s.displayName} so this agent can use its tools.`;case"signing-in":return null;case"connected":return En(s);case"signed-in":return s.justSignedIn?"Signed in just now. Test to check the server responds.":"DorkOS has a sign-in for this server. Test to check it responds.";case"uses-your-key":return"You added an access key when setting this up.";case"cant-reach":return"This server didn’t answer. It may be down.";case"setup-problem":return"This server’s setup has a problem.";case"connecting":return"Connecting to this server.";case"not-checked":return"Nothing has checked this server yet.";case"off":return"Turned off. The agent doesn’t see this server."}}function Rn(e){const{connection:s,authStatus:t,clientOrigin:i}=e;return s.transport==="stdio"?"None. This server doesn’t need one.":s.authKind==="oauth2"?i==="manual"?`OAuth: using your own app credentials, ${t==="connected"?"signed in, and it renews automatically":"not signed in yet"}. DorkOS holds the key; the agent never sees it.`:t==="connected"?"OAuth: signed in, and it renews automatically. DorkOS holds the key; the agent never sees it.":"OAuth: DorkOS will hold the key for you; the agent never sees it.":Object.keys(s.headers).some(r=>r.toLowerCase()==="authorization")?"Access key: you added a key when setting this up.":t===void 0?"Nothing has checked this yet.":"None. This server doesn’t need one."}function In(e){if(e.transport==="stdio")return`Runs \`${e.command}\` on this computer`;const s=Fn(e.url);return s?`${s} (web service)`:`${e.url} (web service)`}function Fn(e){try{return new URL(e).host}catch{return null}}const Dn={agent:"Added to this agent through DorkOS",project:"From this project, declared in its config files",plugin:"Comes with a plugin",computer:"From your computer-wide config"},_n={agent:"Added to this agent through DorkOS.",project:"From this project’s config. Add it to manage it here.",plugin:"Comes with a plugin. Add it to manage it here.",computer:"From your computer-wide config. Add it to manage it here."},Ln=[{runtime:"claude-code",pattern:/^plugin:([^:]+):(.+)$/,read:e=>({pluginName:e[1],displayName:e[2]})},{runtime:"claude-code",pattern:/^plugin:(.+)$/,read:e=>({pluginName:e[1],displayName:e[1]})}];function Ae(e){for(const s of Ln){const t=e.match(s.pattern);if(!t)continue;const{displayName:i,pluginName:a}=s.read(t);if(!(!i||!a))return{displayName:i,pluginName:a,rawName:e}}return{displayName:e,pluginName:null,rawName:e}}function $n(e,s){return s.pluginName?"plugin":e.scope==="project"||e.scope==="local"?"project":e.scope==="user"?"computer":null}const Kn="This agent’s runtime loads this server. Add it to manage it here.";function Te(e,s){return e==="plugin"&&s?`Comes with the ${s} plugin`:Dn[e]}function Bn(e,s){return e===null?Kn:e==="plugin"&&s?`Comes with the ${s} plugin. Add it to manage it here.`:_n[e]}const Un=ae("border-border/60 relative overflow-hidden rounded-md border px-3 py-2.5 transition-colors",{variants:{managed:{true:"bg-card",false:"bg-muted/30"},dimmed:{true:"opacity-65",false:""}},defaultVariants:{managed:!0,dimmed:!1}}),Vn=ae("pointer-events-none absolute inset-y-0 left-0 w-0.5",{variants:{tone:{calm:"hidden",attention:"bg-status-warning",error:"bg-status-error"}},defaultVariants:{tone:"calm"}}),qn=ae("shrink-0 rounded-full px-2 py-0.5 text-2xs leading-4 font-medium whitespace-nowrap",{variants:{chip:{success:"bg-status-success-bg text-status-success-fg",info:"bg-status-info-bg text-status-info-fg",warning:"bg-status-warning-bg text-status-warning-fg",error:"bg-status-error-bg text-status-error-fg",neutral:"bg-muted text-muted-foreground"}},defaultVariants:{chip:"neutral"}}),Hn={connected:"success","signed-in":"info","needs-sign-in":"warning","signing-in":"warning","cant-reach":"error","setup-problem":"error","uses-your-key":"neutral",connecting:"neutral","not-checked":"neutral",off:"neutral"};function Yn({status:e}){const s=ke[e];return n.jsxs(ve,{children:[n.jsx(je,{asChild:!0,children:n.jsx("span",{className:qn({chip:Hn[e]}),children:s.label})}),n.jsx(Ne,{children:s.tooltip})]})}function Gn({scope:e,pluginName:s}){return n.jsxs(ve,{children:[n.jsx(je,{asChild:!0,children:n.jsx(qe,{size:"xs",tone:"neutral",variant:"secondary",className:"shrink-0 font-normal",children:e})}),n.jsx(Ne,{children:Te(e,s)})]})}function Me({displayName:e,rawName:s,scope:t,pluginName:i,status:a,sentence:r,managed:c,toggle:u,actions:h,children:x,details:p,defaultDetailsOpen:m=!1}){const[o,v]=l.useState(m),C=l.useId(),b=ke[a].tone;return n.jsxs("div",{"data-mcp-server":s,className:le(Un({managed:c,dimmed:a==="off"}),"mb-2 last:mb-0"),children:[n.jsx("span",{className:Vn({tone:b}),"aria-hidden":!0}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e}),t&&n.jsx(Gn,{scope:t,pluginName:i}),n.jsx(Yn,{status:a}),u]}),r&&n.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-relaxed",children:r}),x,h&&n.jsx("div",{className:"mt-2 flex items-center gap-1",children:h}),p&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:()=>v(k=>!k),"aria-expanded":o,"aria-controls":C,className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(Z,{className:le("size-3 transition-transform",o&&"rotate-90"),"aria-hidden":!0}),"Details"]}),o&&n.jsxs("div",{id:C,children:[p,n.jsxs("button",{type:"button",onClick:()=>v(!1),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(Z,{className:"size-3 -rotate-90","aria-hidden":!0}),"Collapse details"]})]})]})]})}const Qn=3,$="text-muted-foreground/70";function Wn({tools:e}){const[s,t]=l.useState(!1),i=s?e:e.slice(0,Qn),a=e.length-i.length;return n.jsxs("div",{className:"mt-1.5",children:[i.map(r=>n.jsxs("div",{className:"border-border/40 flex items-baseline gap-2 border-b py-1 last:border-b-0",children:[n.jsx("code",{className:"text-foreground text-2xs shrink-0 font-mono",children:r.name}),r.description&&n.jsx("span",{className:"text-muted-foreground text-2xs truncate",children:r.description})]},r.name)),a>0&&n.jsxs("button",{type:"button",onClick:()=>t(!0),className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs focus-visible:ring-2",children:[n.jsx(Z,{className:"size-3","aria-hidden":!0}),"Show ",a," more"]})]})}function Jn(e){const{scope:s,pluginName:t,connection:i}=e;return s==="plugin"&&t?`Comes with the ${t} plugin`:i?In(i):s?Te(s,t):null}function Oe({connection:e,authStatus:s,authClientOrigin:t,scope:i,pluginName:a,rawName:r,displayName:c,toolCount:u,tools:h,serverInfo:x,alsoUsedBy:p,error:m}){const o=Jn({scope:i,pluginName:a,connection:e});return n.jsxs("div",{className:"border-border/60 text-muted-foreground mt-2 space-y-1 border-t pt-2 text-xs leading-relaxed",children:[e&&n.jsx(L,{label:"Sign-in",align:"start",wrap:!0,labelClassName:$,children:n.jsxs("span",{className:"inline-flex items-start gap-1.5",children:[n.jsx(He,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),Rn({connection:e,authStatus:s,clientOrigin:t})]})}),o&&n.jsx(L,{label:"Source",align:"start",wrap:!0,labelClassName:$,children:o}),r!==c&&n.jsx(L,{label:"Raw id",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono",children:r})}),x&&n.jsx(L,{label:"Server",align:"start",wrap:!0,labelClassName:$,children:x}),p&&n.jsx(L,{label:"Also used by",align:"start",wrap:!0,labelClassName:$,children:p}),typeof u=="number"&&n.jsx(L,{label:"Tools",align:"start",labelClassName:$,children:u}),h&&h.length>0&&n.jsx(Wn,{tools:h}),m&&n.jsx(L,{label:"Error",align:"start",wrap:!0,labelClassName:$,children:n.jsx("code",{className:"text-2xs font-mono break-all",children:m})})]})}function Xn({flow:e,serverName:s}){return n.jsxs(n.Fragment,{children:[n.jsx(fe,{flow:e,serverName:s,failedActions:n.jsxs(n.Fragment,{children:[n.jsx(f,{variant:"secondary",size:"sm",onClick:()=>e.start(),className:"focus-visible:ring-2",children:"Try again"}),n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})]}),connectedActions:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),className:"focus-visible:ring-2",children:"Dismiss"})}),(e.state.step==="disclosure"||e.state.step==="waiting")&&n.jsx("div",{className:"mt-2",children:n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>e.reset(),"aria-label":`Cancel signing in to ${s}`,className:"focus-visible:ring-2",children:"Cancel"})})]})}function Zn({server:e,agentId:s,live:t,testResult:i,rosterUpdatedAt:a,testing:r,busy:c,onToggle:u,onTest:h,onRemove:x}){const p=pe(s,e.name),m=p.state.step==="connected",o=Cn({stamped:i,signedInNow:m,authStatus:e.authStatus,rosterUpdatedAt:a}),v=Ce(e.connection),C=we({enabled:e.enabled,testedOk:(o==null?void 0:o.ok)===!0,signedInNow:m,runtimeStatus:t==null?void 0:t.status,runtimeError:t==null?void 0:t.error,authStatus:e.authStatus,ownKey:v}),b=p.state.step==="starting",k=p.state.step==="disclosure"||p.state.step==="waiting"||b,j=k?"signing-in":C,E=yn({statusKey:C,testResult:o,signedInNow:m})&&(p.state.step==="idle"||b),y=Ae(e.name),M=o!=null&&o.ok?o.toolCount??null:p.state.toolCount,P=k?j:wn({status:j,probe:o}),A=Pn(P,{displayName:y.displayName,toolCount:M,justSignedIn:m}),O=k?"none":zn(P),R=Sn({connection:e.connection,authStatus:e.authStatus});return n.jsx(Me,{displayName:y.displayName,rawName:e.name,scope:"agent",pluginName:y.pluginName,status:j,sentence:A,managed:!0,toggle:n.jsx(Ze,{checked:e.enabled,onCheckedChange:T=>u(e.name,T),disabled:c,"aria-label":`Enable ${e.name}`}),actions:n.jsxs(n.Fragment,{children:[E&&n.jsxs(f,{variant:"default",size:"sm",onClick:()=>p.start(),disabled:c||b,"aria-label":`Sign in to ${e.name}`,className:"gap-1.5 focus-visible:ring-2",children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in"]}),!E&&O==="try-again"&&n.jsxs(f,{variant:"outline",size:"sm",onClick:()=>h(e.name),disabled:r||c,"aria-label":`Try ${e.name} again`,className:"gap-1.5 focus-visible:ring-2",children:[r?n.jsx(ee,{size:"xs"}):null,"Try again"]}),!E&&O==="test"&&n.jsx(f,{variant:"outline",size:"sm",onClick:()=>h(e.name),disabled:r||c,className:"focus-visible:ring-2",children:r?n.jsx(ee,{size:"xs"}):"Test"}),n.jsxs(Ye,{children:[n.jsx(Ge,{asChild:!0,children:n.jsx(f,{variant:"ghost",size:"sm","aria-label":`More actions for ${e.name}`,className:"ml-auto focus-visible:ring-2",children:n.jsx(Qe,{className:"size-4","aria-hidden":!0})})}),n.jsxs(We,{align:"end",children:[n.jsxs(X,{onSelect:()=>h(e.name),disabled:r||c,children:[n.jsx(Je,{className:"size-3.5","aria-hidden":!0}),"Test"]}),R&&n.jsxs(X,{onSelect:()=>p.start(),disabled:c,children:[n.jsx(de,{className:"size-3.5","aria-hidden":!0}),"Sign in again"]}),n.jsx(Xe,{}),n.jsx(X,{variant:"destructive",onSelect:()=>x(e.name),disabled:c,children:"Remove"})]})]})]}),details:n.jsx(Oe,{connection:e.connection,authStatus:e.authStatus,authClientOrigin:e.authClientOrigin,scope:"agent",pluginName:y.pluginName,rawName:y.rawName,displayName:y.displayName,toolCount:M,error:(o==null?void 0:o.ok)===!1?o.error:t==null?void 0:t.error}),children:n.jsx(Xn,{flow:p,serverName:y.displayName})})}function es(e){switch(e.status){case"connected":return"connected";case"failed":return ie(e.error);case"needs-auth":return"needs-sign-in";case"pending":return"connecting";case"disabled":return"off";default:return"not-checked"}}function ns(e){const{displayName:s,scope:t,pluginName:i}=e,a=ss(t,i);return`${s} ${a}. Manage it here to enable, disable, or sign in from DorkOS.`}function ss(e,s){return e==="plugin"&&s?`comes with the ${s} plugin`:e==="project"?"comes from this project’s own config":e==="computer"?"comes from your computer-wide config":"is loaded by this agent’s runtime"}function ts({entry:e,agentId:s,agentLabel:t,canImport:i}){const a=dn(),[r,c]=l.useState(null),[u,h]=l.useState(null),x=l.useCallback(async()=>{h(null);try{const j=await a.mutateAsync({input:{agentId:s,name:e.name}});j.status==="approval_required"&&c(j.approval)}catch(j){h(j instanceof Error?j.message:"Couldn’t add the server.")}},[a,s,e.name]),p=l.useCallback(async()=>{if(r){h(null);try{(await a.mutateAsync({input:{agentId:s,name:e.name},approval:r})).status!=="ok"&&h("Adding it still needs approval. Try again.")}catch(j){h(j instanceof Error?j.message:"Couldn’t add the server.")}}},[a,s,e.name,r]),m=Ae(e.name),o=$n(e,m),v=o!==null,C=m.rawName!==m.displayName,b=e.error!==void 0,k=v||C||b;return r?n.jsxs("div",{className:"border-border/60 mb-2 space-y-3 rounded-md border p-3 last:mb-0",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(te,{className:"text-status-warning mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium",children:["Add “",m.displayName,"” to ",t,"?"]}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:ns({displayName:m.displayName,scope:o,pluginName:m.pluginName})})]})]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>c(null),disabled:a.isPending,className:"focus-visible:ring-2",children:"Cancel"}),n.jsx(f,{size:"sm",onClick:p,disabled:a.isPending,className:"focus-visible:ring-2",children:a.isPending?"Adding…":"Add to agent"})]})]}):n.jsx(Me,{displayName:m.displayName,rawName:e.name,scope:o,pluginName:m.pluginName,status:es(e),sentence:Bn(o,m.pluginName),managed:!1,actions:i?n.jsxs(n.Fragment,{children:[n.jsxs(f,{variant:"outline",size:"sm",onClick:x,disabled:a.isPending,"aria-label":`Add ${e.name} to agent`,className:"gap-1.5 focus-visible:ring-2",children:[a.isPending?n.jsx(ee,{size:"xs"}):n.jsx(xe,{className:"size-(--size-icon-xs)","aria-hidden":!0}),"Add to agent"]}),u&&n.jsx("p",{className:"text-destructive text-xs",children:u})]}):void 0,details:k?n.jsx(Oe,{scope:o,pluginName:m.pluginName,rawName:m.rawName,displayName:m.displayName,error:e.error}):void 0})}function as(e,s){return{agentId:e,name:s.server.name,connection:s.server.connection}}function rs(e){const s=e.sites.filter(t=>!t.expired).map(t=>t.site);return s.length<=3?s.join(", "):`${s.slice(0,3).join(", ")} and ${s.length-3} more`}function is({agentId:e,agentLabel:s}){const t=en(),i=ye(),[a,r]=l.useState(null),[c,u]=l.useState(null),h=l.useCallback(async o=>{if(t.data){u(null);try{const v=await i.mutateAsync({input:as(e,t.data),...o?{approval:o}:{}});v.status!=="approval_required"?r(null):o?u("The browser still needs approval. Try again."):r(v.approval)}catch(v){u(v instanceof Error?v.message:"Couldn’t add the browser.")}}},[i,e,t.data]);if(!t.data)return null;const x=t.data,p=rs(x),m=`${x.loginCommand} <site>`;return n.jsx(F,{children:n.jsxs(D,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[a?n.jsx(te,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}):n.jsx(nn,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:a?`Confirm the signed-in browser for ${s}`:"Signed-in browser"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:a?"This command runs on your machine whenever the agent starts a session. Each session gets its own browser, so agents working at the same time never share one.":"A web browser that starts signed in to the sites you saved. The agent never sees your passwords."}),x.saved?n.jsxs("p",{className:"text-xs",children:["Signed in to ",p,"."]}):n.jsxs("p",{className:"text-status-warning-fg text-xs",children:["No sign-ins saved yet, so it starts signed out. Run"," ",n.jsx("code",{className:"font-mono",children:m}),n.jsx(sn,{value:m,label:"Copy the sign-in command",size:"xs",className:"mx-0.5 inline-flex align-middle"})," ","in a terminal first."]})]})]}),a&&n.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded-md px-3 py-2 font-mono text-xs",children:[x.server.connection.command,...x.server.connection.args].join(" ")}),c&&n.jsx("p",{className:"text-destructive text-xs",children:c}),n.jsxs("div",{className:"flex justify-end gap-2",children:[a&&n.jsx(f,{variant:"ghost",size:"sm",onClick:()=>r(null),disabled:i.isPending,className:"focus-visible:ring-2",children:"Back"}),n.jsx(f,{variant:a?"default":"outline",size:"sm",onClick:()=>void h(a??void 0),disabled:i.isPending,className:"focus-visible:ring-2",children:i.isPending?"Adding…":a?"Confirm & add":"Give it the browser"})]})]})})}const os={codex:["stdio","http"],opencode:["stdio","http"]};function he(e){return os[e]??fn}function cs(){const{open:e}=rn();return n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Want other apps to use DorkOS as an MCP server instead? That is the other direction."," ",n.jsx(f,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>e("tools","external-mcp"),children:"See Settings → Tools"})]})}function ls({agent:e,projectPath:s}){var q;const t=tn(e.id),i=ln(s,e.runtime),a=i.data,r=an(e.runtime),c=(r==null?void 0:r.supportsManagedMcpServers)??!0,u=mn(),h=hn(),x=un(),p=gn(),[m,o]=l.useState({}),[v,C]=l.useState(null),[b,k]=l.useState(null),j=Mn(),E=l.useCallback((d,N)=>{(N?u:h).mutate({agentId:e.id,name:d})},[e.id,u,h]),y=l.useCallback(d=>{x.mutate({agentId:e.id,name:d}),o(N=>{const w={...N};return delete w[d],w})},[e.id,x]),M=l.useCallback(async d=>{C(d);try{const N=await p.mutateAsync({agentId:e.id,name:d});o(w=>({...w,[d]:{result:N,at:Date.now()}}))}finally{C(null)}},[e.id,p]),P=l.useCallback(({name:d,transport:N})=>{k(d),N!=="stdio"&&M(d).catch(()=>{})},[M]),A=t.data??[],O=new Set(A.map(d=>d.name)),R=new Map(((a==null?void 0:a.servers)??[]).map(d=>[d.name,d])),T=((a==null?void 0:a.servers)??[]).filter(d=>!O.has(d.name)),I=u.isPending||h.isPending||x.isPending,J=A.some(d=>cn(d.connection)!==void 0),U=c&&!t.isPending&&!J&&he(e.runtime).includes("stdio"),K=new Map;A.forEach((d,N)=>K.set(d.name,{kind:"managed",index:N})),T.forEach((d,N)=>K.set(d.name,{kind:"discovered",index:N}));const V=j({bothSettled:!t.isPending&&!i.isPending,managed:A,live:R,discovered:T,present:[...A.map(d=>d.name),...T.map(d=>d.name)]});function B(d){const N=K.get(d);if(!N)return null;if(N.kind==="managed"){const z=A[N.index];return n.jsx(Zn,{server:z,agentId:e.id,live:R.get(z.name),testResult:m[z.name],rosterUpdatedAt:t.dataUpdatedAt,testing:v===z.name,busy:I,onToggle:E,onTest:M,onRemove:y},z.name)}const w=T[N.index];return n.jsx(ts,{entry:w,agentId:e.id,agentLabel:e.displayName??e.name,canImport:c},w.name)}return n.jsxs("section",{className:"space-y-3","aria-label":"MCP servers",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"MCP Servers"}),c&&n.jsx(jn,{agentId:e.id,agentLabel:e.displayName??e.name,supportedTransports:he(e.runtime),onAdded:P,oauthDetectedFor:b&&((q=m[b])==null?void 0:q.result.needsAuth)===!0?b:null})]}),n.jsx(cs,{}),U&&n.jsx(is,{agentId:e.id,agentLabel:e.displayName??e.name}),!c&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"This agent’s runtime can’t run DorkOS-managed MCP servers yet. Any servers below show read-only status."}),t.isLoading?n.jsx(F,{children:n.jsxs(D,{className:"space-y-2",children:[n.jsx(ne,{className:"h-5 w-full"}),n.jsx(ne,{className:"h-5 w-3/4"})]})}):t.isError?n.jsx(F,{children:n.jsxs(D,{className:"flex items-center justify-between gap-2",children:[n.jsx("p",{className:"text-destructive text-sm",children:"Couldn’t load managed servers."}),n.jsx(f,{variant:"outline",size:"sm",onClick:()=>t.refetch(),className:"focus-visible:ring-2",children:"Retry"})]})}):V.length===0?n.jsx(F,{children:n.jsx(D,{children:n.jsxs("p",{className:"text-muted-foreground text-sm",children:["No MCP servers yet."," ",c?"Add one to give this agent tools from an external server.":"This runtime can’t run managed servers."]})})}):n.jsx(F,{children:n.jsx(D,{children:V.map(B)})})]})}function ms({member:e}){const{agent:s,projectPath:t,isPending:i}=on(e);return i?n.jsx(ne,{className:"h-32 w-full"}):!s||t===null?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s MCP servers."}):n.jsx(ls,{agent:s,projectPath:t})}export{ms as ToolsPage};
@@ -1,4 +1,4 @@
1
- import{dR as PRn,hc as ORn,gW as NRn,r as on,j as de,gy as Kan,gn as $Rn,hd as DRn,he as LRn,hf as _Rn,J as MN,cL as A2e,B as Wan,hg as Van,al as r2,fl as M2e,aH as C2e,aG as FRn,W as jN,hh as wK,P as RRn,hi as BRn,X as JRn,hj as GRn,hk as HRn,hl as Fhn,dN as qRn,hm as zRn,hn as URn,eI as XRn,ho as KRn,hp as WRn,er as VRn,hq as QRn,es as YRn,eu as ZRn,ev as eBn,bm as VX,fA as nBn,aF as Rhn,Q as tBn,hr as iBn,fE as rBn,hs as cBn,ez as uBn,ef as oBn,eg as sBn,eh as fBn,ei as lBn,ej as hBn,ek as aBn,el as dBn,em as bBn}from"./index-bYhLX3oQ.js";import{a as e2e,A as wBn}from"./AdapterIcon-DTXuj6Zu.js";/**
1
+ import{dT as PRn,he as ORn,gY as NRn,r as on,j as de,gA as Kan,gp as $Rn,hf as DRn,hg as LRn,hh as _Rn,J as MN,cs as A2e,B as Wan,hi as Van,al as r2,fn as M2e,aH as C2e,aG as FRn,W as jN,hj as wK,P as RRn,hk as BRn,X as JRn,hl as GRn,hm as HRn,hn as Fhn,dP as qRn,ho as zRn,hp as URn,eK as XRn,hq as KRn,hr as WRn,et as VRn,hs as QRn,eu as YRn,ew as ZRn,ex as eBn,b3 as VX,fC as nBn,aF as Rhn,Q as tBn,ht as iBn,fG as rBn,hu as cBn,eB as uBn,eh as oBn,ei as sBn,ej as fBn,ek as lBn,el as hBn,em as aBn,en as dBn,eo as bBn}from"./index-BCGiD7pg.js";import{a as e2e,A as wBn}from"./AdapterIcon-kPDXiFU1.js";/**
2
2
  * @license lucide-react v1.47.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{q as t,_ as c,s as a,v as l,w as e,x as s,y as m}from"./index-bYhLX3oQ.js";function S(o){if(o.transport!=="stdio"||!o.args)return;const r=o.args;if(!r.some(i=>i.startsWith("@playwright/mcp")))return;const g=r.indexOf("--storage-state");if(g!==-1)return r[g+1];const n=r.find(i=>i.startsWith("--storage-state="));return n==null?void 0:n.slice(16)}const u=t({name:e(),value:e(),domain:e(),path:e(),expires:l(),httpOnly:a(),secure:a(),sameSite:c(["Strict","Lax","None"])}).passthrough(),h=t({origin:e(),localStorage:s(t({name:e(),value:e()}))}).passthrough();t({cookies:s(u),origins:s(h).default([])}).passthrough();const d=t({site:e(),cookies:l().int(),expiresAt:e().nullable(),expired:a(),pageStorage:a()});t({stateFile:e(),saved:a(),savedAt:e().nullable(),sites:s(d),loginCommand:e(),server:t({name:e(),connection:t({transport:m("stdio"),command:e(),args:s(e()),env:t({}).catchall(e())})})});export{S as a};
1
+ import{q as t,_ as c,s as a,v as l,w as e,x as s,y as m}from"./index-BCGiD7pg.js";function S(o){if(o.transport!=="stdio"||!o.args)return;const r=o.args;if(!r.some(i=>i.startsWith("@playwright/mcp")))return;const g=r.indexOf("--storage-state");if(g!==-1)return r[g+1];const n=r.find(i=>i.startsWith("--storage-state="));return n==null?void 0:n.slice(16)}const u=t({name:e(),value:e(),domain:e(),path:e(),expires:l(),httpOnly:a(),secure:a(),sameSite:c(["Strict","Lax","None"])}).passthrough(),h=t({origin:e(),localStorage:s(t({name:e(),value:e()}))}).passthrough();t({cookies:s(u),origins:s(h).default([])}).passthrough();const d=t({site:e(),cookies:l().int(),expiresAt:e().nullable(),expired:a(),pageStorage:a()});t({stateFile:e(),saved:a(),savedAt:e().nullable(),sites:s(d),loginCommand:e(),server:t({name:e(),connection:t({transport:m("stdio"),command:e(),args:s(e()),env:t({}).catchall(e())})})});export{S as a};
@@ -1 +1 @@
1
- import{r,S as d,E as p,j as E,c as f}from"./index-bYhLX3oQ.js";var j=({code:i,language:e,maxHeight:o,raw:a,className:u,startLine:m,lineNumbers:n,...h})=>{let{shikiTheme:l}=r.useContext(d),t=p(),[c,s]=r.useState(a);return r.useEffect(()=>{if(!t){s(a);return}let g=t.highlight({code:i,language:e,themes:l},x=>{s(x)});g&&s(g)},[i,e,l,t,a]),E.jsx(f,{className:u,language:e,lineNumbers:n,maxHeight:o,result:c,startLine:m,...h})};export{j as HighlightedCodeBlockBody};
1
+ import{r,S as d,E as p,j as E,c as f}from"./index-BCGiD7pg.js";var j=({code:i,language:e,maxHeight:o,raw:a,className:u,startLine:m,lineNumbers:n,...h})=>{let{shikiTheme:l}=r.useContext(d),t=p(),[c,s]=r.useState(a);return r.useEffect(()=>{if(!t){s(a);return}let g=t.highlight({code:i,language:e,themes:l},x=>{s(x)});g&&s(g)},[i,e,l,t,a]),E.jsx(f,{className:u,language:e,lineNumbers:n,maxHeight:o,result:c,startLine:m,...h})};export{j as HighlightedCodeBlockBody};
@@ -1,4 +1,4 @@
1
- import{P as st,g as Z,h as v,X as it,N as Ee,s as Ie,T as H,p as ot,t as m,e as F,j as P,Y as z,a as fe,o as at,Z as lt,E as ht,_ as ft,$ as ut,a0 as dt,U as pt,a1 as ct,q as mt,f as Me,i as gt,a2 as kt,m as ue,a3 as Lt}from"./index-Bj32H2Xz.js";import{html as bt,htmlCompletionSource as wt}from"./index-CFdScmIU.js";import"./index-bYhLX3oQ.js";import"./index-B4oYDFdX.js";import"./index-DT9R_NnS.js";import"./index-DrD7x9EL.js";class _{static create(e,r,n,s,i){let o=s+(s<<8)+e+(r<<4)|0;return new _(e,r,n,o,i,[],[])}constructor(e,r,n,s,i,o,a){this.type=e,this.value=r,this.from=n,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[v.contextHash,s]]}addChild(e,r){e.prop(v.contextHash)!=this.hash&&(e=new H(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(r)}toTree(e,r=this.end){let n=this.children.length-1;return n>=0&&(r=Math.max(r,this.positions[n]+this.children[n].length+this.from)),new H(e.types[this.type],this.children,this.positions,r-this.from).balance({makeTree:(s,i,o)=>new H(Z.none,s,i,o,this.hashProp)})}}var u;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(u||(u={}));class St{constructor(e,r){this.start=e,this.content=r,this.marks=[],this.parsers=[]}}class Ct{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return O(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,r=0,n=0){for(let s=r;s<e;s++)n+=this.text.charCodeAt(s)==9?4-n%4:1;return n}findColumn(e){let r=0;for(let n=0;r<this.text.length&&n<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return r}scrub(){if(!this.baseIndent)return this.text;let e="";for(let r=0;r<this.basePos;r++)e+=" ";return e+this.text.slice(this.basePos)}}function de(t,e,r){if(r.pos==r.text.length||t!=e.block&&r.indent>=e.stack[r.depth+1].value+r.baseIndent)return!0;if(r.indent>=r.baseIndent+4)return!1;let n=(t.type==u.OrderedList?oe:ie)(r,e,!1);return n>0&&(t.type!=u.BulletList||se(r,e,!1)<0)&&r.text.charCodeAt(r.pos+n-1)==t.value}const He={[u.Blockquote](t,e,r){return r.next!=62?!1:(r.markers.push(k(u.QuoteMark,e.lineStart+r.pos,e.lineStart+r.pos+1)),r.moveBase(r.pos+(A(r.text.charCodeAt(r.pos+1))?2:1)),t.end=e.lineStart+r.text.length,!0)},[u.ListItem](t,e,r){return r.indent<r.baseIndent+t.value&&r.next>-1?!1:(r.moveBaseColumn(r.baseIndent+t.value),!0)},[u.OrderedList]:de,[u.BulletList]:de,[u.Document](){return!0}};function A(t){return t==32||t==9||t==10||t==13}function O(t,e=0){for(;e<t.length&&A(t.charCodeAt(e));)e++;return e}function pe(t,e,r){for(;e>r&&A(t.charCodeAt(e-1));)e--;return e}function Pe(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(t.next==96){for(let r=e;r<t.text.length;r++)if(t.text.charCodeAt(r)==96)return-1}return e}function ve(t){return t.next!=62?-1:t.text.charCodeAt(t.pos+1)==32?2:1}function se(t,e,r){if(t.next!=42&&t.next!=45&&t.next!=95)return-1;let n=1;for(let s=t.pos+1;s<t.text.length;s++){let i=t.text.charCodeAt(s);if(i==t.next)n++;else if(!A(i))return-1}return r&&t.next==45&&Re(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(De.SetextHeading)>-1||n<3?-1:1}function Ne(t,e){for(let r=t.stack.length-1;r>=0;r--)if(t.stack[r].type==e)return!0;return!1}function ie(t,e,r){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||A(t.text.charCodeAt(t.pos+1)))&&(!r||Ne(e,u.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?1:-1}function oe(t,e,r){let n=t.pos,s=t.next;for(;s>=48&&s<=57;){n++;if(n==t.text.length)return-1;s=t.text.charCodeAt(n)}return n==t.pos||n>t.pos+9||s!=46&&s!=41||n<t.text.length-1&&!A(t.text.charCodeAt(n+1))||r&&!Ne(e,u.OrderedList)&&(t.skipSpace(n+1)==t.text.length||n>t.pos+1||t.next!=49)?-1:n+1-t.pos}function ye(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==35;)e++;if(e<t.text.length&&t.text.charCodeAt(e)!=32)return-1;let r=e-t.pos;return r>6?-1:r}function Re(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let r=e;for(;e<t.text.length&&A(t.text.charCodeAt(e));)e++;return e==t.text.length?r:-1}const W=/^[ \t]*$/,Oe=/-->/,Te=/\?>/,ee=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Oe],[/^\s*<\?/,Te],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,W],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,W]];function ze(t,e,r){if(t.next!=60)return-1;let n=t.text.slice(t.pos);for(let s=0,i=ee.length-(r?1:0);s<i;s++)if(ee[s][0].test(n))return s;return-1}function ce(t,e){let r=t.countIndent(e,t.pos,t.indent),n=t.countIndent(t.skipSpace(e),e,r);return n>=r+5?r+1:n}function x(t,e,r){let n=t.length-1;n>=0&&t[n].to==e&&t[n].type==u.CodeText?t[n].to=r:t.push(k(u.CodeText,e,r))}const $={LinkReference:void 0,IndentedCode(t,e){let r=e.baseIndent+4;if(e.indent<r)return!1;let n=e.findColumn(r),s=t.lineStart+n,i=t.lineStart+e.text.length,o=[],a=[];for(x(o,s,i);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){x(a,t.lineStart-1,t.lineStart);for(let l of e.markers)a.push(l)}else{if(e.indent<r)break;{if(a.length){for(let h of a)h.type==u.CodeText?x(o,h.from,h.to):o.push(h);a=[]}x(o,t.lineStart-1,t.lineStart);for(let h of e.markers)o.push(h);i=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<i&&x(o,l,i)}}return a.length&&(a=a.filter(l=>l.type!=u.CodeText),a.length&&(e.markers=a.concat(e.markers))),t.addNode(t.buffer.writeElements(o,-s).finish(u.CodeBlock,i-s),s),!0},FencedCode(t,e){let r=Pe(e);if(r<0)return!1;let n=t.lineStart+e.pos,s=e.next,i=r-e.pos,o=e.skipSpace(r),a=pe(e.text,e.text.length,o),l=[k(u.CodeMark,n,n+i)];o<a&&l.push(k(u.CodeInfo,t.lineStart+o,t.lineStart+a));for(let h=!0,f=!0,p=!1;t.nextLine()&&e.depth>=t.stack.length;h=!1){let d=e.pos;if(e.indent-e.baseIndent<4)for(;d<e.text.length&&e.text.charCodeAt(d)==s;)d++;if(d-e.pos>=i&&e.skipSpace(d)==e.text.length){for(let c of e.markers)l.push(c);f&&p&&x(l,t.lineStart-1,t.lineStart),l.push(k(u.CodeMark,t.lineStart+e.pos,t.lineStart+d)),t.nextLine();break}else{p=!0,h||(x(l,t.lineStart-1,t.lineStart),f=!1);for(let g of e.markers)l.push(g);let c=t.lineStart+e.basePos,L=t.lineStart+e.text.length;c<L&&(x(l,c,L),f=!1)}}return t.addNode(t.buffer.writeElements(l,-n).finish(u.FencedCode,t.prevLineEnd()-n),n),!0},Blockquote(t,e){let r=ve(e);return r<0?!1:(t.startContext(u.Blockquote,e.pos),t.addNode(u.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+r),null)},HorizontalRule(t,e){if(se(e,t,!1)<0)return!1;let r=t.lineStart+e.pos;return t.nextLine(),t.addNode(u.HorizontalRule,r),!0},BulletList(t,e){let r=ie(e,t,!1);if(r<0)return!1;t.block.type!=u.BulletList&&t.startContext(u.BulletList,e.basePos,e.next);let n=ce(e,e.pos+1);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},OrderedList(t,e){let r=oe(e,t,!1);if(r<0)return!1;t.block.type!=u.OrderedList&&t.startContext(u.OrderedList,e.basePos,e.text.charCodeAt(e.pos+r-1));let n=ce(e,e.pos+r);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},ATXHeading(t,e){let r=ye(e);if(r<0)return!1;let n=e.pos,s=t.lineStart+n,i=pe(e.text,e.text.length,n),o=i;for(;o>n&&e.text.charCodeAt(o-1)==e.next;)o--;(o==i||o==n||!A(e.text.charCodeAt(o-1)))&&(o=e.text.length);let a=t.buffer.write(u.HeaderMark,0,r).writeElements(t.parser.parseInline(e.text.slice(n+r+1,o),s+r+1),-s);o<e.text.length&&a.write(u.HeaderMark,o-n,i-n);let l=a.finish(u.ATXHeading1-1+r,e.text.length-n);return t.nextLine(),t.addNode(l,s),!0},HTMLBlock(t,e){let r=ze(e,t,!1);if(r<0)return!1;let n=t.lineStart+e.pos,s=ee[r][1],i=[],o=s!=W;for(;!s.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){o=!1;break}for(let h of e.markers)i.push(h)}o&&t.nextLine();let a=s==Oe?u.CommentBlock:s==Te?u.ProcessingInstructionBlock:u.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(i,-n).finish(a,l-n),n),!0},SetextHeading:void 0};class At{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,r,n){if(this.stage==-1)return!1;let s=n.content+`
1
+ import{P as st,g as Z,h as v,X as it,N as Ee,s as Ie,T as H,p as ot,t as m,e as F,j as P,Y as z,a as fe,o as at,Z as lt,E as ht,_ as ft,$ as ut,a0 as dt,U as pt,a1 as ct,q as mt,f as Me,i as gt,a2 as kt,m as ue,a3 as Lt}from"./index-C9wgMNj5.js";import{html as bt,htmlCompletionSource as wt}from"./index-gIAwAMkn.js";import"./index-BCGiD7pg.js";import"./index-DdsOOmtz.js";import"./index-BzDP7VXZ.js";import"./index-BC9LsNlJ.js";class _{static create(e,r,n,s,i){let o=s+(s<<8)+e+(r<<4)|0;return new _(e,r,n,o,i,[],[])}constructor(e,r,n,s,i,o,a){this.type=e,this.value=r,this.from=n,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[v.contextHash,s]]}addChild(e,r){e.prop(v.contextHash)!=this.hash&&(e=new H(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(r)}toTree(e,r=this.end){let n=this.children.length-1;return n>=0&&(r=Math.max(r,this.positions[n]+this.children[n].length+this.from)),new H(e.types[this.type],this.children,this.positions,r-this.from).balance({makeTree:(s,i,o)=>new H(Z.none,s,i,o,this.hashProp)})}}var u;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(u||(u={}));class St{constructor(e,r){this.start=e,this.content=r,this.marks=[],this.parsers=[]}}class Ct{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return O(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,r=0,n=0){for(let s=r;s<e;s++)n+=this.text.charCodeAt(s)==9?4-n%4:1;return n}findColumn(e){let r=0;for(let n=0;r<this.text.length&&n<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return r}scrub(){if(!this.baseIndent)return this.text;let e="";for(let r=0;r<this.basePos;r++)e+=" ";return e+this.text.slice(this.basePos)}}function de(t,e,r){if(r.pos==r.text.length||t!=e.block&&r.indent>=e.stack[r.depth+1].value+r.baseIndent)return!0;if(r.indent>=r.baseIndent+4)return!1;let n=(t.type==u.OrderedList?oe:ie)(r,e,!1);return n>0&&(t.type!=u.BulletList||se(r,e,!1)<0)&&r.text.charCodeAt(r.pos+n-1)==t.value}const He={[u.Blockquote](t,e,r){return r.next!=62?!1:(r.markers.push(k(u.QuoteMark,e.lineStart+r.pos,e.lineStart+r.pos+1)),r.moveBase(r.pos+(A(r.text.charCodeAt(r.pos+1))?2:1)),t.end=e.lineStart+r.text.length,!0)},[u.ListItem](t,e,r){return r.indent<r.baseIndent+t.value&&r.next>-1?!1:(r.moveBaseColumn(r.baseIndent+t.value),!0)},[u.OrderedList]:de,[u.BulletList]:de,[u.Document](){return!0}};function A(t){return t==32||t==9||t==10||t==13}function O(t,e=0){for(;e<t.length&&A(t.charCodeAt(e));)e++;return e}function pe(t,e,r){for(;e>r&&A(t.charCodeAt(e-1));)e--;return e}function Pe(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(t.next==96){for(let r=e;r<t.text.length;r++)if(t.text.charCodeAt(r)==96)return-1}return e}function ve(t){return t.next!=62?-1:t.text.charCodeAt(t.pos+1)==32?2:1}function se(t,e,r){if(t.next!=42&&t.next!=45&&t.next!=95)return-1;let n=1;for(let s=t.pos+1;s<t.text.length;s++){let i=t.text.charCodeAt(s);if(i==t.next)n++;else if(!A(i))return-1}return r&&t.next==45&&Re(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(De.SetextHeading)>-1||n<3?-1:1}function Ne(t,e){for(let r=t.stack.length-1;r>=0;r--)if(t.stack[r].type==e)return!0;return!1}function ie(t,e,r){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||A(t.text.charCodeAt(t.pos+1)))&&(!r||Ne(e,u.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?1:-1}function oe(t,e,r){let n=t.pos,s=t.next;for(;s>=48&&s<=57;){n++;if(n==t.text.length)return-1;s=t.text.charCodeAt(n)}return n==t.pos||n>t.pos+9||s!=46&&s!=41||n<t.text.length-1&&!A(t.text.charCodeAt(n+1))||r&&!Ne(e,u.OrderedList)&&(t.skipSpace(n+1)==t.text.length||n>t.pos+1||t.next!=49)?-1:n+1-t.pos}function ye(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==35;)e++;if(e<t.text.length&&t.text.charCodeAt(e)!=32)return-1;let r=e-t.pos;return r>6?-1:r}function Re(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let r=e;for(;e<t.text.length&&A(t.text.charCodeAt(e));)e++;return e==t.text.length?r:-1}const W=/^[ \t]*$/,Oe=/-->/,Te=/\?>/,ee=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Oe],[/^\s*<\?/,Te],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,W],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,W]];function ze(t,e,r){if(t.next!=60)return-1;let n=t.text.slice(t.pos);for(let s=0,i=ee.length-(r?1:0);s<i;s++)if(ee[s][0].test(n))return s;return-1}function ce(t,e){let r=t.countIndent(e,t.pos,t.indent),n=t.countIndent(t.skipSpace(e),e,r);return n>=r+5?r+1:n}function x(t,e,r){let n=t.length-1;n>=0&&t[n].to==e&&t[n].type==u.CodeText?t[n].to=r:t.push(k(u.CodeText,e,r))}const $={LinkReference:void 0,IndentedCode(t,e){let r=e.baseIndent+4;if(e.indent<r)return!1;let n=e.findColumn(r),s=t.lineStart+n,i=t.lineStart+e.text.length,o=[],a=[];for(x(o,s,i);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){x(a,t.lineStart-1,t.lineStart);for(let l of e.markers)a.push(l)}else{if(e.indent<r)break;{if(a.length){for(let h of a)h.type==u.CodeText?x(o,h.from,h.to):o.push(h);a=[]}x(o,t.lineStart-1,t.lineStart);for(let h of e.markers)o.push(h);i=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<i&&x(o,l,i)}}return a.length&&(a=a.filter(l=>l.type!=u.CodeText),a.length&&(e.markers=a.concat(e.markers))),t.addNode(t.buffer.writeElements(o,-s).finish(u.CodeBlock,i-s),s),!0},FencedCode(t,e){let r=Pe(e);if(r<0)return!1;let n=t.lineStart+e.pos,s=e.next,i=r-e.pos,o=e.skipSpace(r),a=pe(e.text,e.text.length,o),l=[k(u.CodeMark,n,n+i)];o<a&&l.push(k(u.CodeInfo,t.lineStart+o,t.lineStart+a));for(let h=!0,f=!0,p=!1;t.nextLine()&&e.depth>=t.stack.length;h=!1){let d=e.pos;if(e.indent-e.baseIndent<4)for(;d<e.text.length&&e.text.charCodeAt(d)==s;)d++;if(d-e.pos>=i&&e.skipSpace(d)==e.text.length){for(let c of e.markers)l.push(c);f&&p&&x(l,t.lineStart-1,t.lineStart),l.push(k(u.CodeMark,t.lineStart+e.pos,t.lineStart+d)),t.nextLine();break}else{p=!0,h||(x(l,t.lineStart-1,t.lineStart),f=!1);for(let g of e.markers)l.push(g);let c=t.lineStart+e.basePos,L=t.lineStart+e.text.length;c<L&&(x(l,c,L),f=!1)}}return t.addNode(t.buffer.writeElements(l,-n).finish(u.FencedCode,t.prevLineEnd()-n),n),!0},Blockquote(t,e){let r=ve(e);return r<0?!1:(t.startContext(u.Blockquote,e.pos),t.addNode(u.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+r),null)},HorizontalRule(t,e){if(se(e,t,!1)<0)return!1;let r=t.lineStart+e.pos;return t.nextLine(),t.addNode(u.HorizontalRule,r),!0},BulletList(t,e){let r=ie(e,t,!1);if(r<0)return!1;t.block.type!=u.BulletList&&t.startContext(u.BulletList,e.basePos,e.next);let n=ce(e,e.pos+1);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},OrderedList(t,e){let r=oe(e,t,!1);if(r<0)return!1;t.block.type!=u.OrderedList&&t.startContext(u.OrderedList,e.basePos,e.text.charCodeAt(e.pos+r-1));let n=ce(e,e.pos+r);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},ATXHeading(t,e){let r=ye(e);if(r<0)return!1;let n=e.pos,s=t.lineStart+n,i=pe(e.text,e.text.length,n),o=i;for(;o>n&&e.text.charCodeAt(o-1)==e.next;)o--;(o==i||o==n||!A(e.text.charCodeAt(o-1)))&&(o=e.text.length);let a=t.buffer.write(u.HeaderMark,0,r).writeElements(t.parser.parseInline(e.text.slice(n+r+1,o),s+r+1),-s);o<e.text.length&&a.write(u.HeaderMark,o-n,i-n);let l=a.finish(u.ATXHeading1-1+r,e.text.length-n);return t.nextLine(),t.addNode(l,s),!0},HTMLBlock(t,e){let r=ze(e,t,!1);if(r<0)return!1;let n=t.lineStart+e.pos,s=ee[r][1],i=[],o=s!=W;for(;!s.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){o=!1;break}for(let h of e.markers)i.push(h)}o&&t.nextLine();let a=s==Oe?u.CommentBlock:s==Te?u.ProcessingInstructionBlock:u.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(i,-n).finish(a,l-n),n),!0},SetextHeading:void 0};class At{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,r,n){if(this.stage==-1)return!1;let s=n.content+`
2
2
  `+r.scrub(),i=this.advance(s);return i>-1&&i<s.length?this.complete(e,n,i):!1}finish(e,r){return(this.stage==2||this.stage==3)&&O(r.content,this.pos)==r.content.length?this.complete(e,r,r.content.length):!1}complete(e,r,n){return e.addLeafElement(r,k(u.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Qe(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(k(u.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(qe(e,O(e,this.pos),this.start)))return-1}else if(this.stage==2){let r=O(e,this.pos),n=0;if(r>this.pos){let s=Ze(e,r,this.start);if(s){let i=V(e,s.to-this.start);i>0&&(this.nextStage(s),n=i)}}return n||(n=V(e,this.pos)),n>0&&n<e.length?n:-1}else return V(e,this.pos)}}}function V(t,e){for(;e<t.length;e++){let r=t.charCodeAt(e);if(r==10)break;if(!A(r))return-1}return e}class xt{nextLine(e,r,n){let s=r.depth<e.stack.length?-1:Re(r),i=r.next;if(s<0)return!1;let o=k(u.HeaderMark,e.lineStart+r.pos,e.lineStart+s);return e.nextLine(),e.addLeafElement(n,k(i==61?u.SetextHeading1:u.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}}const De={LinkReference(t,e){return e.content.charCodeAt(0)==91?new At(e):null},SetextHeading(){return new xt}},Bt=[(t,e)=>ye(e)>=0,(t,e)=>Pe(e)>=0,(t,e)=>ve(e)>=0,(t,e)=>ie(e,t,!0)>=0,(t,e)=>oe(e,t,!0)>=0,(t,e)=>se(e,t,!0)>=0,(t,e)=>ze(e,t,!0)>=0],Et={text:"",end:0};class It{constructor(e,r,n,s){this.parser=e,this.input=r,this.ranges=s,this.line=new Ct,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=s[s.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=s[0].from,this.block=_.create(u.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Pt(n,r):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let n=0;;){let s=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;n<e.markers.length&&(!s||e.markers[n].from<s.end);){let i=e.markers[n++];this.addNode(i.type,i.from,i.to)}if(!s)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let n of this.parser.blockParsers)if(n){let s=n(this,e);if(s!=!1){if(s==!0)return null;e.forward();continue e}}break}let r=new St(this.lineStart+e.pos,e.text.slice(e.pos));for(let n of this.parser.leafBlockParsers)if(n){let s=n(this,r);s&&r.parsers.push(s)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,r))break e}for(let n of r.parsers)if(n.nextLine(this,e,r))return null;r.content+=`
3
3
  `+e.scrub();for(let n of e.markers)r.marks.push(n)}return this.finishLeaf(r),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let r=this.fragments.takeNodes(this);return r?(this.absoluteLineStart+=r,this.lineStart=Ve(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let r=Et;if(r.end=e,e>=this.to)r.text="";else if(r.text=this.lineChunkAt(e),r.end+=r.text.length,this.ranges.length>1){let n=this.absoluteLineStart,s=this.rangeI;for(;this.ranges[s].to<r.end;){s++;let i=this.ranges[s].from,o=this.lineChunkAt(i);r.end=i+o.length,r.text=r.text.slice(0,this.ranges[s-1].to-n)+o,n=r.end-r.text.length}}return r}readLine(){let{line:e}=this,{text:r,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(r);e.depth<this.stack.length;e.depth++){let s=this.stack[e.depth],i=this.parser.skipContextMarkup[s.type];if(!i)throw new Error("Unhandled block context "+u[s.type]);let o=this.line.markers.length;if(!i(s,this,e)){this.line.markers.length>o&&(s.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let r=this.input.chunk(e),n;if(this.input.lineChunks)n=r==`
4
4
  `?"":r;else{let s=r.indexOf(`
@@ -1 +1 @@
1
- import{L as s}from"./index-B4oYDFdX.js";import{s as n,t as r,a as o,L as P,i as Q,c as a,f as i,l as c}from"./index-Bj32H2Xz.js";import"./index-bYhLX3oQ.js";const g=n({String:r.string,Number:r.number,"True False":r.bool,PropertyName:r.propertyName,Null:r.null,", :":r.separator,"[ ]":r.squareBracket,"{ }":r.brace}),p=s.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[g],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),T=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(O){if(!(O instanceof SyntaxError))throw O;const e=l(O,t.state.doc);return[{from:e,message:O.message,severity:"error",to:e}]}return[]};function l(t,O){let e;return(e=t.message.match(/at position (\d+)/))?Math.min(+e[1],O.length):(e=t.message.match(/at line (\d+) column (\d+)/))?Math.min(O.line(+e[1]).from+ +e[2]-1,O.length):0}const u=P.define({name:"json",parser:p.configure({props:[Q.add({Object:a({except:/^\s*\}/}),Array:a({except:/^\s*\]/})}),i.add({"Object Array":c})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function f(){return new o(u)}export{f as json,u as jsonLanguage,T as jsonParseLinter};
1
+ import{L as s}from"./index-DdsOOmtz.js";import{s as n,t as r,a as o,L as P,i as Q,c as a,f as i,l as c}from"./index-C9wgMNj5.js";import"./index-BCGiD7pg.js";const g=n({String:r.string,Number:r.number,"True False":r.bool,PropertyName:r.propertyName,Null:r.null,", :":r.separator,"[ ]":r.squareBracket,"{ }":r.brace}),p=s.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[g],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),T=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(O){if(!(O instanceof SyntaxError))throw O;const e=l(O,t.state.doc);return[{from:e,message:O.message,severity:"error",to:e}]}return[]};function l(t,O){let e;return(e=t.message.match(/at position (\d+)/))?Math.min(+e[1],O.length):(e=t.message.match(/at line (\d+) column (\d+)/))?Math.min(O.line(+e[1]).from+ +e[2]-1,O.length):0}const u=P.define({name:"json",parser:p.configure({props:[Q.add({Object:a({except:/^\s*\}/}),Array:a({except:/^\s*\]/})}),i.add({"Object Array":c})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function f(){return new o(u)}export{f as json,u as jsonLanguage,T as jsonParseLinter};
@@ -0,0 +1 @@
1
+ import{r as I,j as e,cT as $,cU as P,aL as z,cV as O,cW as R,al as k,cX as A,cY as L,B as C,W as E,$ as M,cZ as B,c_ as _,c$ as q,d0 as H,d1 as U,d2 as V,d3 as T,d4 as Y,cS as g}from"./index-BCGiD7pg.js";import{d5 as Q,d6 as ee,d7 as se,d8 as te,d9 as ne,da as ae}from"./index-BCGiD7pg.js";const W=new Set(["disabled","discovered","incompatible","invalid"]);function X({extension:s,onToggle:l,isToggling:c,onSetRunApproval:i,isSettingApproval:o}){const{manifest:n,status:r,scope:N,error:u,serverError:f,origin:j,approvedToRun:y}=s,[x,v]=I.useState(!1),p=!W.has(r),t=r==="incompatible",a=r==="invalid",d=r==="compile_error"||r==="activate_error",m=!t&&!a,h=!(j==="core"&&n.canDisable===!1),b=s.hasServerEntry||s.hasDataProxy,w=d?"Error":t?"Incompatible":a?"Invalid":null;return e.jsx($,{"data-slot":"extension-card","data-testid":`extension-card-${s.id}`,radius:"lg",gap:"none",className:k(d&&"border-amber-500/50",(t||a)&&"opacity-70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d&&e.jsx(P,{className:"text-status-warning-dot size-4 shrink-0","aria-hidden":"true"}),(t||a)&&!d&&e.jsx(z,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":"true"}),!d&&!t&&!a&&e.jsx(O,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["v",n.version]})]}),n.description&&e.jsx("p",{className:"text-muted-foreground text-sm",children:n.description}),t&&n.minHostVersion&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Needs DorkOS ",n.minHostVersion," or newer"]}),d&&u&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-status-warning-fg text-sm",children:[r==="compile_error"?"Compilation error: ":"Activation failed: ",u.message]}),u.details&&e.jsxs("button",{type:"button",onClick:()=>v(S=>!S),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs transition-colors","aria-expanded":x,children:[e.jsx(R,{className:k("size-3 transition-transform",x&&"rotate-180")}),x?"Hide details":"Show details"]}),x&&u.details&&e.jsx("pre",{className:"bg-muted mt-1 max-h-32 overflow-auto rounded-md p-2 text-xs",children:u.details})]}),f&&e.jsxs("p",{className:"text-status-warning-fg text-sm",children:["Server side failed to rebuild: ",f.message,". The previous version is still running."]}),j==="user"&&(y?e.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-2 text-xs","data-testid":`extension-run-allowed-${s.id}`,children:[e.jsx(A,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsxs("span",{children:["You allowed this to run inside DorkOS.",s.originProblem==="changed"&&" You said yes to its files as they are now; they had changed after DorkOS installed it, so any further change will ask you again."]}),e.jsx("button",{type:"button",onClick:()=>i(s.id,!1),disabled:o,className:"hover:text-foreground underline underline-offset-2 disabled:opacity-50",children:"Stop it"})]}):e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/40 bg-amber-500/5 p-3","data-testid":`extension-needs-approval-${s.id}`,children:[e.jsx("p",{className:"text-sm font-medium",children:"This extension is waiting for you"}),s.originProblem&&e.jsx("p",{className:"text-status-warning-fg text-sm","data-testid":`extension-origin-problem-${s.id}`,children:s.originProblem==="changed"?"Its files changed after DorkOS installed it, so DorkOS can’t vouch for where this copy came from. It won’t run until you look it over and say yes.":"Its plugin holds a shortcut to files somewhere else, so DorkOS can’t vouch for where this copy came from. It won’t run until you say yes."}),e.jsx("p",{className:"text-muted-foreground text-sm",children:L(b)}),e.jsx(C,{size:"sm",onClick:()=>i(s.id,!0),disabled:o,"data-testid":`extension-approve-run-${s.id}`,children:"Turn it on"})]})),e.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-2 text-xs",children:[e.jsx(E,{variant:"outline",children:N}),w&&e.jsx(E,{variant:w==="Error"?"destructive":"secondary","data-testid":`extension-health-${s.id}`,children:w}),n.author&&e.jsx("span",{children:n.author})]})]}),e.jsx("div",{className:"flex shrink-0 items-center pt-0.5",children:h?e.jsx(M,{checked:p,onCheckedChange:S=>l(s.id,S),disabled:!m||c,"aria-label":`${p?"Disable":"Enable"} ${n.name}`}):e.jsx(E,{variant:"secondary",title:"This extension is required and is always on","data-testid":`extension-required-${s.id}`,children:"Required"})})]})})}function D(s){const l=new Date(s);return Number.isNaN(l.getTime())?"":l.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function F(){const{data:s=[]}=B(),{stop:l,pendingSource:c}=_();return s.length===0?null:e.jsxs("section",{className:"space-y-3","data-testid":"trusted-sources-section",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Trusted sources"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Extensions DorkOS installs from these places turn on without asking. If you stop trusting one, the extensions from it that are on now keep running exactly as they are. Newer versions and anything new from it won’t run until you say yes."})]}),e.jsx("ul",{className:"divide-y rounded-xl border",children:s.map(({source:i,trustedAt:o})=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-mono text-sm",children:i}),D(o)&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Trusted ",D(o)]})]}),e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:c===i,onClick:()=>l(i),children:"Stop trusting"})]},i))})]})}function G(){const{data:s=[],isLoading:l}=q(),c=H(),i=U(),o=V(),n=T(!0),r=T(!1),N=new Set([...c.variables?[c.variables]:[],...i.variables?[i.variables]:[]]),u=new Set([...n.isPending&&n.variables?[n.variables.id]:[],...r.isPending&&r.variables?[r.variables.id]:[]]);function f(t,a){const d=a?n:r,m=s.find(h=>h.id===t);m&&d.mutate({id:t,version:m.manifest.version,plugin:m.sourcePlugin??null},{onSuccess:h=>{const b=h.extension.manifest.name;g.success(a?`${b} can now run inside DorkOS`:`${b} has stopped running inside DorkOS`)},onError:h=>{g.error(a?"Couldn’t let it run.":"Couldn’t stop it running.",{description:h.message})}})}async function j(t,a){(a?c:i).mutate(t,{onError:m=>{g.error(a?"Couldn’t turn that on.":"Couldn’t turn that off.",{description:m.message})}})}function y(){o.mutate(void 0,{onSuccess:t=>{g.success(`Reloaded ${t.length} extension${t.length===1?"":"s"}`)},onError:t=>{g.error("Couldn’t reload your extensions.",{description:t.message})}})}if(l)return e.jsx("div",{className:"text-muted-foreground py-8 text-center text-sm",children:"Loading extensions…"});const x=s.filter(t=>t.origin==="core"),v=s.filter(t=>t.origin==="user"),p=t=>e.jsx(X,{extension:t,onToggle:j,isToggling:N.has(t.id),onSetRunApproval:f,isSettingApproval:u.has(t.id)},t.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Extensions add new UI and capabilities to DorkOS. Core extensions ship with DorkOS; installed extensions live in"," ",e.jsx("code",{className:"bg-muted rounded px-1",children:"~/.dork/extensions/"})," or"," ",e.jsx("code",{className:"bg-muted rounded px-1",children:".dork/extensions/"})," in your project."]}),s.length===0?e.jsx("div",{className:"text-muted-foreground py-8 text-center text-sm","data-testid":"no-extensions",children:e.jsx("p",{children:"No extensions installed."})}):e.jsxs(e.Fragment,{children:[x.length>0&&e.jsxs("section",{className:"space-y-3","data-testid":"core-extensions-section",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Core extensions"}),e.jsx("div",{className:"space-y-3",children:x.map(p)})]}),e.jsxs("section",{className:"space-y-3","data-testid":"installed-extensions-section",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Installed extensions"}),v.length>0?e.jsx("div",{className:"space-y-3",children:v.map(p)}):e.jsxs("div",{className:"text-muted-foreground rounded-xl border border-dashed p-4 text-sm","data-testid":"no-installed-extensions",children:["No extensions installed yet. Browse"," ",e.jsx("span",{className:"text-foreground font-medium",children:"Marketplace"})," to add some."]})]})]}),e.jsx(F,{}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:y,disabled:o.isPending,"data-testid":"reload-extensions-button",children:[e.jsx(Y,{className:k("mr-2 size-4",o.isPending&&"animate-spin")}),"Reload extensions"]})})]})}export{Q as ExtensionEventBridge,ee as ExtensionLoader,se as ExtensionProvider,G as ExtensionsSettingsTab,te as createExtensionAPI,ne as createExtensionEventBridge,ae as useExtensions};