@augmentd-labs/canvas-web 2.26.38 → 2.26.40

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 (84) hide show
  1. package/dist/assets/CalendarApplet-Co0RKLQE.js +2 -0
  2. package/dist/assets/FileForm-CDiVKvxq.js +1 -0
  3. package/dist/assets/{FiltersApplet-Dh4SUfjN.js → FiltersApplet-DMoH8Y2S.js} +1 -1
  4. package/dist/assets/{HomeFab-W7y591CD.js → HomeFab-CpgkP2jx.js} +1 -1
  5. package/dist/assets/{IdentityFields-DZRqtnIG.js → IdentityFields-D-NCTUaE.js} +1 -1
  6. package/dist/assets/{LensApplet-CddpZXRw.js → LensApplet-BRvNa6QA.js} +1 -1
  7. package/dist/assets/LinkToCard-CKVi4Nrg.js +1 -0
  8. package/dist/assets/{NextShell-BfQHKEKO.js → NextShell-ull6WmMg.js} +1 -1
  9. package/dist/assets/{NotesApplet-Cyuirnp1.js → NotesApplet-BUlo1AeT.js} +1 -1
  10. package/dist/assets/ObjectPropertiesCard-D2lrTQqT.js +8 -0
  11. package/dist/assets/{PathPickerField-B4yFUjgD.js → PathPickerField-CW2yG2Yg.js} +1 -1
  12. package/dist/assets/{PickDocumentsCard-CFDQL70e.js → PickDocumentsCard-BWgc-A02.js} +1 -1
  13. package/dist/assets/{SketchApplet-14xrogy3.js → SketchApplet-BKnhzTBA.js} +1 -1
  14. package/dist/assets/{SketchEditor-B2LYe_MO.js → SketchEditor-DmGMcbU0.js} +2 -2
  15. package/dist/assets/{TerminalApplet-BNeLmNFF.js → TerminalApplet-D7YxftqM.js} +1 -1
  16. package/dist/assets/{TextDocumentEditor-CU5ersd_.js → TextDocumentEditor-BQnVD0dd.js} +1 -1
  17. package/dist/assets/{TodosApplet-ASG9wXjL.js → TodosApplet-DU5VWc5i.js} +1 -1
  18. package/dist/assets/{TodosWidget-CYK5RbYD.js → TodosWidget-CNnfNk4L.js} +1 -1
  19. package/dist/assets/{UploadProgressList-Ci1akl_D.js → UploadProgressList-D2wEpa7t.js} +1 -1
  20. package/dist/assets/{_agentId_-Dy7lgkJK.js → _agentId_-DpUGhD0N.js} +0 -0
  21. package/dist/assets/_contextId_-BYACtvKh.js +1 -0
  22. package/dist/assets/_workspaceName_-V027dHb_.js +1 -0
  23. package/dist/assets/{about-Cns4GXCX.js → about-he3_XqHw.js} +1 -1
  24. package/dist/assets/{add-jGjbB0x1.js → add-CPWQz9ZK.js} +1 -1
  25. package/dist/assets/{agents-DsaNiZJc.js → agents-e-nclilT.js} +1 -1
  26. package/dist/assets/{appearance-C1xkguK7.js → appearance-De5ieWdQ.js} +1 -1
  27. package/dist/assets/{applet-target-I8w6EPj0.js → applet-target-pLdP-R76.js} +1 -1
  28. package/dist/assets/{apps-BCy4q37-.js → apps-o8pk-feK.js} +1 -1
  29. package/dist/assets/backend-sync-progress-DqI8zbnK.js +6 -0
  30. package/dist/assets/{context-DZ1Hn7tt.js → context-t3rdtGUB.js} +1 -1
  31. package/dist/assets/{contexts-Df-cWUlj2.js → contexts-Bq8LHUTK2.js} +1 -1
  32. package/dist/assets/{date-time-picker-txVhlNO0.js → date-time-picker-DCikruos.js} +1 -1
  33. package/dist/assets/{document-CTvT2Qa5.js → document-Cr7GhnVd.js} +1 -1
  34. package/dist/assets/document-list-J63eer10.js +3 -0
  35. package/dist/assets/{home-C8Wq8hsp.js → home-Cgt-SPAO.js} +1 -1
  36. package/dist/assets/{index-Cp75myNf.js → index-B01BkfMJ.js} +6 -6
  37. package/dist/assets/index-CYvpxvg6.css +2 -0
  38. package/dist/assets/{key-bindings-CA_ePKGA.js → key-bindings-DbpenCz7.js} +1 -1
  39. package/dist/assets/{offline-sNCjxnp-.js → offline-ByoT6JJX.js} +1 -1
  40. package/dist/assets/{public-share-D5yz-Pmo.js → public-share-CXR25Q1X.js} +1 -1
  41. package/dist/assets/query-debug-lD5vbJGi.js +1 -0
  42. package/dist/assets/{registry-QDfCL8gg.js → registry-CPdMkdKq.js} +2 -2
  43. package/dist/assets/{roles-DoR2drD1.js → roles-sb8vgjV_.js} +1 -1
  44. package/dist/assets/{settings-jIm9JVC-.js → settings-3y1P0NnU.js} +1 -1
  45. package/dist/assets/{settings-aOogFA9n.js → settings-B25sRmAM.js} +1 -1
  46. package/dist/assets/{settings-tgfewl6I.js → settings-D1g-5DNT.js} +1 -1
  47. package/dist/assets/settings-DX6t8wLi.js +16 -0
  48. package/dist/assets/{share-target-cRZICq5X.js → share-target-DAjpH4Qw.js} +1 -1
  49. package/dist/assets/{shared-BnpwVpxG.js → shared-BLOuO2Is.js} +1 -1
  50. package/dist/assets/{shared-eIOEFQRM.js → shared-BiquP0Yf.js} +1 -1
  51. package/dist/assets/{sketch-lazy-BbNgGbR3.js → sketch-lazy-BY_ka1hw.js} +2 -2
  52. package/dist/assets/{text-documents-BaXhu3ra.js → text-documents-Cdb3U63i.js} +2 -2
  53. package/dist/assets/tree-folders-BMqMmyq7.js +1 -0
  54. package/dist/assets/{use-applet-docs-B2dk__vk.js → use-applet-docs-rimRHjID.js} +1 -1
  55. package/dist/assets/{use-applet-target-ffIGaAqT.js → use-applet-target-BygCSj5n.js} +1 -1
  56. package/dist/assets/use-canvas-pins-BV8AsYCE.js +3 -0
  57. package/dist/assets/{use-workspace-identity-B8gOMGj4.js → use-workspace-identity-CSkRwVyo.js} +1 -1
  58. package/dist/assets/{useAddTarget-B3b6TyZr.js → useAddTarget-DeRZWtGg.js} +1 -1
  59. package/dist/assets/{useAgentModels-B10Tbl6D.js → useAgentModels-KcfEQ6u9.js} +1 -1
  60. package/dist/assets/{useDocumentThumbnail-wW0lSOEy.js → useDocumentThumbnail-Cj4UYyhC.js} +1 -1
  61. package/dist/assets/{useEditNoteFields-DXLTFEqL.js → useEditNoteFields-BT1ASu_q.js} +1 -1
  62. package/dist/assets/workspace-C5V-ZCOE.js +1 -0
  63. package/dist/assets/{workspace-area-menu-BFw2yUHk.js → workspace-area-menu-Y2-IWSxU.js} +1 -1
  64. package/dist/assets/{workspace-content-gate-NLuRPvbm.js → workspace-content-gate-C54J9Man.js} +1 -1
  65. package/dist/assets/{workspace-import-form-Bb6z42nw.js → workspace-import-form-DTvV9jYt.js} +1 -1
  66. package/dist/assets/workspaces-CWqg_P7W.js +1 -0
  67. package/dist/index.html +26 -26
  68. package/dist/sw.js +1 -1
  69. package/package.json +2 -2
  70. package/dist/assets/CalendarApplet-7wqNCpcs.js +0 -2
  71. package/dist/assets/FileForm-C35drQ_R.js +0 -1
  72. package/dist/assets/LinkToCard-BQ1yoFDr.js +0 -1
  73. package/dist/assets/ObjectPropertiesCard-BTTwYnN9.js +0 -8
  74. package/dist/assets/_contextId_-BBpL3f_T.js +0 -1
  75. package/dist/assets/_workspaceName_-CU-hpvv7.js +0 -1
  76. package/dist/assets/backend-sync-progress-tUU2XWtW.js +0 -7
  77. package/dist/assets/document-list-CQ1_7Sja.js +0 -2
  78. package/dist/assets/index-_0FSwEvG.css +0 -2
  79. package/dist/assets/query-debug-CQ0I3cXX.js +0 -1
  80. package/dist/assets/settings-Bz400KLm.js +0 -16
  81. package/dist/assets/tree-folders-cmsIS19Z.js +0 -1
  82. package/dist/assets/use-canvas-pins-DkWN9oEd.js +0 -3
  83. package/dist/assets/workspace-BJELPCNs.js +0 -1
  84. package/dist/assets/workspaces-DC19HlpI.js +0 -1
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-BNeLmNFF.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-CDoK3F3U.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-ffIGaAqT.js","assets/workspace-BJELPCNs.js","assets/button-SeUZ_Pvi.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CFeuDt0T.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-Cyuirnp1.js","assets/useAddTarget-B3b6TyZr.js","assets/context-DZ1Hn7tt.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-DXLTFEqL.js","assets/tags-YamdPoBK.js","assets/index-Cp75myNf.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-BSTdjCWU.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-BQ1yoFDr.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-9i1uCMQa.js","assets/use-canvas-pins-DkWN9oEd.js","assets/TodosWidget-CYK5RbYD.js","assets/ObjectPropertiesCard-BTTwYnN9.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-DZRqtnIG.js","assets/date-time-picker-txVhlNO0.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-D5yz-Pmo.js","assets/text-documents-BaXhu3ra.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-wW0lSOEy.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-CdPp-3GR.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-BUFAkTGl.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-CVO5KPCs.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-BbNgGbR3.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-Docu7O5V.css","assets/document-list-CQ1_7Sja.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-CFDQL70e.js","assets/backend-sync-progress-tUU2XWtW.js","assets/PathPickerField-B4yFUjgD.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-BBKmqs79.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-DIP1zh7I.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-BFw2yUHk.js","assets/workspace-content-gate-NLuRPvbm.js","assets/UploadProgressList-Ci1akl_D.js","assets/sha256-65KIjGvZ.js","assets/FileForm-C35drQ_R.js","assets/use-theme-DaxpiICf.js","assets/index-_0FSwEvG.css","assets/shared-BnpwVpxG.js","assets/use-applet-docs-B2dk__vk.js","assets/TodosApplet-ASG9wXjL.js","assets/LensApplet-CddpZXRw.js","assets/FiltersApplet-Dh4SUfjN.js","assets/SketchApplet-14xrogy3.js","assets/CalendarApplet-7wqNCpcs.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{Jr as i,St as a,Zr as o,ct as s,hn as c,it as l,tt as u}from"./ui-CDoK3F3U.js";var d=e(n(),1),f=t();function p(e){let t=(0,d.lazy)(e);return function(e){return(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,f.jsx)(t,{...e})})}}var m=p(()=>r(()=>import(`./TerminalApplet-BNeLmNFF.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),h=p(()=>r(()=>import(`./NotesApplet-Cyuirnp1.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),g=p(()=>r(()=>import(`./TodosApplet-ASG9wXjL.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),_=p(()=>r(()=>import(`./LensApplet-CddpZXRw.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=p(()=>r(()=>import(`./FiltersApplet-Dh4SUfjN.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),y=p(()=>r(()=>import(`./SketchApplet-14xrogy3.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),b=p(()=>r(()=>import(`./CalendarApplet-7wqNCpcs.js`).then(e=>({default:e.CalendarApplet})),__vite__mapDeps([88,1,2,23,22,3,4,9,8,29,7,6,10,11,12,30,31,28,32,33,34,16,13,17,40,20,41,5,21,24,25,26,27,35,36,37,38,39,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]))),x=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:l,modes:[`context`],description:`Shell sessions for this context`,Component:m},{id:`filters`,category:`utilities`,label:`Filters`,icon:s,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:v},{id:`notes`,category:`productivity`,label:`Notes`,icon:u,modes:[`context`],description:`All notes in the current context, editable in place`,Component:h},{id:`todo`,category:`productivity`,label:`Todos`,icon:c,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:g},{id:`calendar`,category:`productivity`,label:`Calendar`,icon:i,modes:[`context`],description:`Day, week, month, year and schedule views of the events and due tasks in the current context`,Component:b},{id:`sketch`,category:`creative`,label:`Sketch`,icon:o,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:y},{id:`lens`,category:`media`,label:`Lens`,icon:a,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:_}];function S(e){return x.filter(t=>t.modes.includes(e))}export{S as n,x as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-D7YxftqM.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-CDoK3F3U.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-BygCSj5n.js","assets/workspace-C5V-ZCOE.js","assets/button-SeUZ_Pvi.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CFeuDt0T.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-BUlo1AeT.js","assets/useAddTarget-DeRZWtGg.js","assets/context-t3rdtGUB.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-BT1ASu_q.js","assets/tags-YamdPoBK.js","assets/index-B01BkfMJ.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-BSTdjCWU.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-CKVi4Nrg.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-9i1uCMQa.js","assets/use-canvas-pins-BV8AsYCE.js","assets/TodosWidget-CNnfNk4L.js","assets/ObjectPropertiesCard-D2lrTQqT.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-D-NCTUaE.js","assets/date-time-picker-DCikruos.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-CXR25Q1X.js","assets/text-documents-Cdb3U63i.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-Cj4UYyhC.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-CdPp-3GR.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-BUFAkTGl.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-CVO5KPCs.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-BY_ka1hw.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-Docu7O5V.css","assets/document-list-J63eer10.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-BWgc-A02.js","assets/backend-sync-progress-DqI8zbnK.js","assets/PathPickerField-CW2yG2Yg.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-BBKmqs79.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-DIP1zh7I.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-Y2-IWSxU.js","assets/workspace-content-gate-C54J9Man.js","assets/UploadProgressList-D2wEpa7t.js","assets/sha256-65KIjGvZ.js","assets/FileForm-CDiVKvxq.js","assets/use-theme-DaxpiICf.js","assets/index-CYvpxvg6.css","assets/shared-BLOuO2Is.js","assets/use-applet-docs-rimRHjID.js","assets/TodosApplet-DU5VWc5i.js","assets/LensApplet-BRvNa6QA.js","assets/FiltersApplet-DMoH8Y2S.js","assets/SketchApplet-BKnhzTBA.js","assets/CalendarApplet-Co0RKLQE.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{Jr as i,St as a,Zr as o,ct as s,hn as c,it as l,tt as u}from"./ui-CDoK3F3U.js";var d=e(n(),1),f=t();function p(e){let t=(0,d.lazy)(e);return function(e){return(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,f.jsx)(t,{...e})})}}var m=p(()=>r(()=>import(`./TerminalApplet-D7YxftqM.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),h=p(()=>r(()=>import(`./NotesApplet-BUlo1AeT.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),g=p(()=>r(()=>import(`./TodosApplet-DU5VWc5i.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),_=p(()=>r(()=>import(`./LensApplet-BRvNa6QA.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=p(()=>r(()=>import(`./FiltersApplet-DMoH8Y2S.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),y=p(()=>r(()=>import(`./SketchApplet-BKnhzTBA.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),b=p(()=>r(()=>import(`./CalendarApplet-Co0RKLQE.js`).then(e=>({default:e.CalendarApplet})),__vite__mapDeps([88,1,2,23,22,3,4,9,8,29,7,6,10,11,12,30,31,28,32,33,34,16,13,17,40,20,41,5,21,24,25,26,27,35,36,37,38,39,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]))),x=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:l,modes:[`context`],description:`Shell sessions for this context`,Component:m},{id:`filters`,category:`utilities`,label:`Filters`,icon:s,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:v},{id:`notes`,category:`productivity`,label:`Notes`,icon:u,modes:[`context`],description:`All notes in the current context, editable in place`,Component:h},{id:`todo`,category:`productivity`,label:`Todos`,icon:c,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:g},{id:`calendar`,category:`productivity`,label:`Calendar`,icon:i,modes:[`context`],description:`Day, week, month, year and schedule views of the events and due tasks in the current context`,Component:b},{id:`sketch`,category:`creative`,label:`Sketch`,icon:o,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:y},{id:`lens`,category:`media`,label:`Lens`,icon:a,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:_}];function S(e){return x.filter(t=>t.modes.includes(e))}export{S as n,x as t};
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,It as i,Lr as a,Mr as o,Pt as s,_t as c,bi as l,kr as u,or as d,rt as f,wt as p}from"./ui-CDoK3F3U.js";import{t as m}from"./button-SeUZ_Pvi.js";import{t as h}from"./input-BOtCd4HP.js";import{i as g}from"./auth-Bx9fAZmz.js";import{n as _}from"./use-toast-BlLDqSUO.js";import{Nt as v}from"./workspace-BJELPCNs.js";import{t as y}from"./useEscapeClose-DR_xKT_k.js";import{n as b}from"./page-header-DrDt1sQ2.js";import{t as x}from"./role-C5I0Plgn.js";import{t as S}from"./form-panel-3p-ncEVK.js";import{t as C}from"./use-create-panel-DhSNIGtr.js";var w=e(n(),1),T=t();function E({status:e}){let t={running:{icon:r,color:`text-success`,bg:`bg-success-subtle`,label:`Running`},stopped:{icon:o,color:`text-muted-foreground`,bg:`bg-muted`,label:`Stopped`},starting:{icon:u,color:`text-info`,bg:`bg-info-subtle`,label:`Starting`},stopping:{icon:u,color:`text-warning`,bg:`bg-warning-subtle`,label:`Stopping`},error:{icon:a,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Error`},created:{icon:l,color:`text-muted-foreground`,bg:`bg-muted`,label:`Created`},configured:{icon:l,color:`text-info`,bg:`bg-info-subtle`,label:`Configured`},removed:{icon:o,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Removed`}},n=t[e]||t.created,i=n.icon;return(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium ${n.bg} ${n.color}`,children:[(0,T.jsx)(i,{className:`w-3 h-3`}),n.label]})}function D(){let[e,t]=(0,w.useState)([]),[n,r]=(0,w.useState)(!0),[a,o]=(0,w.useState)(null),[l,D]=(0,w.useState)(null);y(()=>D(null),l!==null);let[O,k]=C(),[A,j]=(0,w.useState)([]),[M,N]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(!1),{showToast:H}=_(),U=g(),W=(0,w.useCallback)(async()=>{try{r(!0);let e=await x.listRoles({type:`workspace`,userId:U?.id});t(e),o(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch roles`;o(t)}finally{r(!1)}},[U?.id]);(0,w.useEffect)(()=>{let e=()=>W();e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[W]),(0,w.useEffect)(()=>{O&&(x.listTemplates().then(e=>{let t=e.filter(e=>e.type===`workspace`);j(t),F(e=>e||t[0]?.id||``)}).catch(()=>j([])),v().then(e=>{N(e),z(t=>t||e[0]?.id||``)}).catch(()=>N([])))},[O]);let G=async e=>{if(e.preventDefault(),!(!P||!I.trim()||!R)){V(!0);try{let e=await x.createRole({template:P,name:I.trim(),type:`workspace`,userId:U?.id,workspaceId:R});L(``),k(!1),await W(),H({title:`Created`,description:`Role "${e.name}" created`})}catch(e){H({title:`Error`,description:e instanceof Error?e.message:`Failed to create role`,variant:`destructive`})}finally{V(!1)}}},K=async e=>{try{await x.startRole(e.id),H({title:`Success`,description:`Role "${e.name}" started successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to start role`;H({title:`Error`,description:t,variant:`destructive`})}},q=async e=>{try{await x.stopRole(e.id),H({title:`Success`,description:`Role "${e.name}" stopped successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to stop role`;H({title:`Error`,description:t,variant:`destructive`})}},J=async e=>{try{await x.restartRole(e.id),H({title:`Success`,description:`Role "${e.name}" restarted successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to restart role`;H({title:`Error`,description:t,variant:`destructive`})}},Y=async e=>{try{let t=await x.getRoleLogs(e.id,100);D({role:e,logs:t})}catch(e){let t=e instanceof Error?e.message:`Failed to fetch logs`;H({title:`Error`,description:t,variant:`destructive`})}};return(0,T.jsxs)(`div`,{className:`space-y-6`,children:[(0,T.jsx)(b,{title:`My Roles`,description:`Manage your workspace roles and services`,actions:(0,T.jsxs)(T.Fragment,{children:[!O&&(0,T.jsxs)(m,{onClick:()=>k(!0),children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),`Create Role`]}),(0,T.jsxs)(m,{onClick:W,variant:`outline`,children:[(0,T.jsx)(p,{className:`mr-2 h-4 w-4`}),`Refresh`]})]})}),O&&(0,T.jsx)(S,{title:`Create New Role`,onClose:()=>k(!1),children:(0,T.jsxs)(`form`,{onSubmit:G,className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-template`,className:`mb-1 block text-sm font-medium`,children:`Template`}),(0,T.jsxs)(`select`,{id:`role-template`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:P,onChange:e=>F(e.target.value),disabled:B||A.length===0,children:[A.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspace templates available`}),A.map(e=>(0,T.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-name`,className:`mb-1 block text-sm font-medium`,children:`Role Name`}),(0,T.jsx)(h,{id:`role-name`,value:I,onChange:e=>L(e.target.value),placeholder:`e.g., canvas-sshd`,disabled:B})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-workspace`,className:`mb-1 block text-sm font-medium`,children:`Workspace`}),(0,T.jsxs)(`select`,{id:`role-workspace`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:R,onChange:e=>z(e.target.value),disabled:B||M.length===0,children:[M.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),M.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.label||e.name},e.id))]})]}),(0,T.jsxs)(m,{type:`submit`,disabled:B||!P||!I.trim()||!R,children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),B?`Creating…`:`Create Role`]})]})}),n?(0,T.jsx)(`div`,{className:`text-center py-8`,children:`Loading roles...`}):a?(0,T.jsx)(`div`,{className:`text-center py-8 text-destructive`,children:a}):e.length===0?(0,T.jsxs)(`div`,{className:`text-center py-12 border rounded-lg`,children:[(0,T.jsx)(c,{className:`w-12 h-12 mx-auto text-muted-foreground mb-4`}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:`You don't have any workspace roles yet`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-2`,children:`Contact your administrator to set up roles for your workspaces`})]}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.map(e=>(0,T.jsxs)(`div`,{className:`border rounded-lg p-6 space-y-4 hover:shadow-elevation-2 transition-shadow`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex-1`,children:[(0,T.jsx)(`h3`,{className:`font-semibold text-lg`,children:e.name}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.template})]}),(0,T.jsx)(E,{status:e.status})]}),e.container&&(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(c,{className:`w-3 h-3`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.container.name})]})}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[e.status===`stopped`||e.status===`created`?(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>K(e),className:`flex-1`,children:[(0,T.jsx)(i,{className:`w-4 h-4 mr-2`}),`Start`]}):e.status===`running`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>q(e),className:`flex-1`,children:[(0,T.jsx)(f,{className:`w-4 h-4 mr-2`}),`Stop`]}),(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>J(e),className:`flex-1`,children:[(0,T.jsx)(p,{className:`w-4 h-4 mr-2`}),`Restart`]})]}):(0,T.jsxs)(m,{size:`sm`,variant:`outline`,disabled:!0,className:`flex-1`,children:[(0,T.jsx)(u,{className:`w-4 h-4 mr-2`}),e.status]}),(0,T.jsx)(m,{size:`sm`,variant:`outline`,onClick:()=>Y(e),title:`View Logs`,children:(0,T.jsx)(d,{className:`w-4 h-4`})})]})]},e.id))}),(0,T.jsxs)(`div`,{className:`border-t pt-6`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:`Global Services`}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[(0,T.jsx)(`p`,{children:`Global roles are server-wide services managed by your administrator. These include services like SSH access, storage, and other shared infrastructure.`}),(0,T.jsx)(`p`,{children:`To check the status of global services, contact your system administrator.`})]})]}),l&&(0,T.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,T.jsxs)(`div`,{className:`bg-background rounded-lg shadow-elevation-3 max-w-4xl w-full mx-4 max-h-viewport-modal flex flex-col`,children:[(0,T.jsxs)(`div`,{className:`p-6 border-b`,children:[(0,T.jsxs)(`h2`,{className:`text-xl font-bold`,children:[l.role.name,` - Logs`]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l.role.template})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:(0,T.jsx)(`div`,{"data-scheme":`dark`,className:`bg-background text-success p-4 rounded font-mono text-xs overflow-x-auto`,children:l.logs.length===0?(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:`No logs available`}):(0,T.jsx)(`pre`,{children:l.logs.join(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,It as i,Lr as a,Mr as o,Pt as s,_t as c,bi as l,kr as u,or as d,rt as f,wt as p}from"./ui-CDoK3F3U.js";import{t as m}from"./button-SeUZ_Pvi.js";import{t as h}from"./input-BOtCd4HP.js";import{i as g}from"./auth-Bx9fAZmz.js";import{n as _}from"./use-toast-BlLDqSUO.js";import{jt as v}from"./workspace-C5V-ZCOE.js";import{t as y}from"./useEscapeClose-DR_xKT_k.js";import{n as b}from"./page-header-DrDt1sQ2.js";import{t as x}from"./role-C5I0Plgn.js";import{t as S}from"./form-panel-3p-ncEVK.js";import{t as C}from"./use-create-panel-DhSNIGtr.js";var w=e(n(),1),T=t();function E({status:e}){let t={running:{icon:r,color:`text-success`,bg:`bg-success-subtle`,label:`Running`},stopped:{icon:o,color:`text-muted-foreground`,bg:`bg-muted`,label:`Stopped`},starting:{icon:u,color:`text-info`,bg:`bg-info-subtle`,label:`Starting`},stopping:{icon:u,color:`text-warning`,bg:`bg-warning-subtle`,label:`Stopping`},error:{icon:a,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Error`},created:{icon:l,color:`text-muted-foreground`,bg:`bg-muted`,label:`Created`},configured:{icon:l,color:`text-info`,bg:`bg-info-subtle`,label:`Configured`},removed:{icon:o,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Removed`}},n=t[e]||t.created,i=n.icon;return(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium ${n.bg} ${n.color}`,children:[(0,T.jsx)(i,{className:`w-3 h-3`}),n.label]})}function D(){let[e,t]=(0,w.useState)([]),[n,r]=(0,w.useState)(!0),[a,o]=(0,w.useState)(null),[l,D]=(0,w.useState)(null);y(()=>D(null),l!==null);let[O,k]=C(),[A,j]=(0,w.useState)([]),[M,N]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(!1),{showToast:H}=_(),U=g(),W=(0,w.useCallback)(async()=>{try{r(!0);let e=await x.listRoles({type:`workspace`,userId:U?.id});t(e),o(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch roles`;o(t)}finally{r(!1)}},[U?.id]);(0,w.useEffect)(()=>{let e=()=>W();e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[W]),(0,w.useEffect)(()=>{O&&(x.listTemplates().then(e=>{let t=e.filter(e=>e.type===`workspace`);j(t),F(e=>e||t[0]?.id||``)}).catch(()=>j([])),v().then(e=>{N(e),z(t=>t||e[0]?.id||``)}).catch(()=>N([])))},[O]);let G=async e=>{if(e.preventDefault(),!(!P||!I.trim()||!R)){V(!0);try{let e=await x.createRole({template:P,name:I.trim(),type:`workspace`,userId:U?.id,workspaceId:R});L(``),k(!1),await W(),H({title:`Created`,description:`Role "${e.name}" created`})}catch(e){H({title:`Error`,description:e instanceof Error?e.message:`Failed to create role`,variant:`destructive`})}finally{V(!1)}}},K=async e=>{try{await x.startRole(e.id),H({title:`Success`,description:`Role "${e.name}" started successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to start role`;H({title:`Error`,description:t,variant:`destructive`})}},q=async e=>{try{await x.stopRole(e.id),H({title:`Success`,description:`Role "${e.name}" stopped successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to stop role`;H({title:`Error`,description:t,variant:`destructive`})}},J=async e=>{try{await x.restartRole(e.id),H({title:`Success`,description:`Role "${e.name}" restarted successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to restart role`;H({title:`Error`,description:t,variant:`destructive`})}},Y=async e=>{try{let t=await x.getRoleLogs(e.id,100);D({role:e,logs:t})}catch(e){let t=e instanceof Error?e.message:`Failed to fetch logs`;H({title:`Error`,description:t,variant:`destructive`})}};return(0,T.jsxs)(`div`,{className:`space-y-6`,children:[(0,T.jsx)(b,{title:`My Roles`,description:`Manage your workspace roles and services`,actions:(0,T.jsxs)(T.Fragment,{children:[!O&&(0,T.jsxs)(m,{onClick:()=>k(!0),children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),`Create Role`]}),(0,T.jsxs)(m,{onClick:W,variant:`outline`,children:[(0,T.jsx)(p,{className:`mr-2 h-4 w-4`}),`Refresh`]})]})}),O&&(0,T.jsx)(S,{title:`Create New Role`,onClose:()=>k(!1),children:(0,T.jsxs)(`form`,{onSubmit:G,className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-template`,className:`mb-1 block text-sm font-medium`,children:`Template`}),(0,T.jsxs)(`select`,{id:`role-template`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:P,onChange:e=>F(e.target.value),disabled:B||A.length===0,children:[A.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspace templates available`}),A.map(e=>(0,T.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-name`,className:`mb-1 block text-sm font-medium`,children:`Role Name`}),(0,T.jsx)(h,{id:`role-name`,value:I,onChange:e=>L(e.target.value),placeholder:`e.g., canvas-sshd`,disabled:B})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-workspace`,className:`mb-1 block text-sm font-medium`,children:`Workspace`}),(0,T.jsxs)(`select`,{id:`role-workspace`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:R,onChange:e=>z(e.target.value),disabled:B||M.length===0,children:[M.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),M.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.label||e.name},e.id))]})]}),(0,T.jsxs)(m,{type:`submit`,disabled:B||!P||!I.trim()||!R,children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),B?`Creating…`:`Create Role`]})]})}),n?(0,T.jsx)(`div`,{className:`text-center py-8`,children:`Loading roles...`}):a?(0,T.jsx)(`div`,{className:`text-center py-8 text-destructive`,children:a}):e.length===0?(0,T.jsxs)(`div`,{className:`text-center py-12 border rounded-lg`,children:[(0,T.jsx)(c,{className:`w-12 h-12 mx-auto text-muted-foreground mb-4`}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:`You don't have any workspace roles yet`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-2`,children:`Contact your administrator to set up roles for your workspaces`})]}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.map(e=>(0,T.jsxs)(`div`,{className:`border rounded-lg p-6 space-y-4 hover:shadow-elevation-2 transition-shadow`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex-1`,children:[(0,T.jsx)(`h3`,{className:`font-semibold text-lg`,children:e.name}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.template})]}),(0,T.jsx)(E,{status:e.status})]}),e.container&&(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(c,{className:`w-3 h-3`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.container.name})]})}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[e.status===`stopped`||e.status===`created`?(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>K(e),className:`flex-1`,children:[(0,T.jsx)(i,{className:`w-4 h-4 mr-2`}),`Start`]}):e.status===`running`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>q(e),className:`flex-1`,children:[(0,T.jsx)(f,{className:`w-4 h-4 mr-2`}),`Stop`]}),(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>J(e),className:`flex-1`,children:[(0,T.jsx)(p,{className:`w-4 h-4 mr-2`}),`Restart`]})]}):(0,T.jsxs)(m,{size:`sm`,variant:`outline`,disabled:!0,className:`flex-1`,children:[(0,T.jsx)(u,{className:`w-4 h-4 mr-2`}),e.status]}),(0,T.jsx)(m,{size:`sm`,variant:`outline`,onClick:()=>Y(e),title:`View Logs`,children:(0,T.jsx)(d,{className:`w-4 h-4`})})]})]},e.id))}),(0,T.jsxs)(`div`,{className:`border-t pt-6`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:`Global Services`}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[(0,T.jsx)(`p`,{children:`Global roles are server-wide services managed by your administrator. These include services like SSH access, storage, and other shared infrastructure.`}),(0,T.jsx)(`p`,{children:`To check the status of global services, contact your system administrator.`})]})]}),l&&(0,T.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,T.jsxs)(`div`,{className:`bg-background rounded-lg shadow-elevation-3 max-w-4xl w-full mx-4 max-h-viewport-modal flex flex-col`,children:[(0,T.jsxs)(`div`,{className:`p-6 border-b`,children:[(0,T.jsxs)(`h2`,{className:`text-xl font-bold`,children:[l.role.name,` - Logs`]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l.role.template})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:(0,T.jsx)(`div`,{"data-scheme":`dark`,className:`bg-background text-success p-4 rounded font-mono text-xs overflow-x-auto`,children:l.logs.length===0?(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:`No logs available`}):(0,T.jsx)(`pre`,{children:l.logs.join(`
2
2
  `)})})}),(0,T.jsx)(`div`,{className:`p-4 border-t flex justify-end`,children:(0,T.jsx)(m,{onClick:()=>D(null),children:`Close`})})]})})]})}export{D as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as ee,g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{G as te,X as a,kt as o}from"./ui-CDoK3F3U.js";import{t as s}from"./utils-2pl1SbIp.js";import{t as c}from"./button-SeUZ_Pvi.js";import{t as l}from"./input-BOtCd4HP.js";import{n as ne}from"./use-toast-BlLDqSUO.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{E as ie,a as ae,c as oe,f as u,r as d,v as se,w as ce,x as le}from"./context-DZ1Hn7tt.js";import{t as f}from"./PathPickerField-B4yFUjgD.js";import{i as ue}from"./use-menu-DIP1zh7I.js";import{gt as p,yt as de}from"./index-Cp75myNf.js";import{n as fe}from"./page-header-DrDt1sQ2.js";var m=e(n(),1),h=t(),g=[{value:`documentRead`,label:`Read`},{value:`documentWrite`,label:`Write`},{value:`documentReadWrite`,label:`Read & write`}];function _(){let{contextId:e,tab:t}=ee(),[n]=i(),_=n.get(`ownerId`)||void 0,v=r(),{showToast:y}=ne(),{selectEntity:b,goBack:x,closeM2:S}=ue(),C=re(),w=de(t),T=_?`?ownerId=${encodeURIComponent(_)}`:``;(0,m.useEffect)(()=>{t!==w&&e&&v(`/contexts/${e}/settings/${w}${T}`,{replace:!0})},[t,w,e,T,v]);let[E,D]=(0,m.useState)(null),[pe,me]=(0,m.useState)(!0),[O,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(!1),[M,N]=(0,m.useState)(``),[P,F]=(0,m.useState)(``),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(``),[B,V]=(0,m.useState)(``),[H,he]=(0,m.useState)(),[U,W]=(0,m.useState)([]),[G,K]=(0,m.useState)(!1),[q,J]=(0,m.useState)(``),[Y,ge]=(0,m.useState)(g[0].value),[X,Z]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!e)return;let t=!1;return ae(e,_).then(e=>{t||(D(e),b(e.id),N(e.name||``),F(e.description||``),L(typeof e.metadata?.ui?.color==`string`?e.metadata.ui.color:null),z(e.url||``),V(e.baseUrl||``))}).catch(()=>{t||y({title:`Error`,description:`Failed to load context`,variant:`destructive`})}).finally(()=>{t||me(!1)}),()=>{t=!0}},[e,_,b,y]);let Q=(t=e)=>{t&&(K(!0),u(t).then(W).catch(()=>W([])).finally(()=>K(!1)))};(0,m.useEffect)(()=>{if(w!==`shares`||!e)return;let t=!1;return u(e).then(e=>{t||W(e)}).catch(()=>{t||W([])}),()=>{t=!0}},[w,e]);let _e=async t=>{if(t.preventDefault(),e){k(!0);try{let t=await se(e,{name:M.trim(),description:P.trim(),metadata:{...E?.metadata,ui:{...E?.metadata?.ui,color:I}}},_);D(t),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ve=async t=>{if(t.preventDefault(),e){k(!0);try{await Promise.all([ie(e,R.trim(),_,H),ce(e,{baseUrl:B.trim()||null},_)]),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context URL updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ye=async()=>{if(e&&window.confirm(`Delete context "${e}"? This cannot be undone.`)){j(!0);try{await d(e,_),S(),b(null),y({title:`Deleted`,description:`Context "${e}" removed`}),v(`/contexts`,{replace:!0})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{j(!1)}}},be=async t=>{if(t.preventDefault(),!(!e||!q.trim())){Z(`grant`);try{await oe(e,q.trim(),Y),J(``),Q(),y({title:`Shared`,description:`Access granted to ${q.trim()}`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to grant access`,variant:`destructive`})}finally{Z(null)}}},xe=async t=>{if(e&&window.confirm(`Revoke ${t.userEmail}'s access to "${e}"?`)){Z(t.userEmail);try{await le(e,t.userEmail),Q(),y({title:`Revoked`,description:`${t.userEmail} no longer has access`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke access`,variant:`destructive`})}finally{Z(null)}}};if(pe)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!E)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Context not found`});let $=p.find(e=>e.id===w),Se=`/contexts/${e}${T}`;return(0,h.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,h.jsx)(fe,{compact:!0,className:`mb-6 border-b pb-4`,title:`${$.label} - ${E.name||E.id}`,description:$.description,backTo:Se,onBack:C?x:void 0}),w===`general`&&(0,h.jsxs)(`div`,{className:`space-y-6`,children:[(0,h.jsxs)(`form`,{onSubmit:_e,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Context ID`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 font-mono text-sm text-muted-foreground`,children:E.id})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-name`,className:`text-sm font-medium`,children:`Name`}),(0,h.jsx)(l,{id:`ctx-name`,value:M,onChange:e=>N(e.target.value),placeholder:`My Context`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-description`,className:`text-sm font-medium`,children:`Description`}),(0,h.jsx)(l,{id:`ctx-description`,value:P,onChange:e=>F(e.target.value),placeholder:`Optional description`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-color`,className:`text-sm font-medium`,children:`Color`}),(0,h.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,h.jsx)(l,{id:`ctx-color`,type:`color`,value:/^#[0-9a-f]{6}$/i.test(I||E.color||``)?I||E.color:`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:O}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:O||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Using the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Workspace`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 text-sm text-muted-foreground`,children:E.workspaceName||E.workspaceId||E.workspace})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),(0,h.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,h.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,h.jsxs)(c,{variant:`destructive`,disabled:A,onClick:ye,children:[(0,h.jsx)(a,{className:`mr-2 h-4 w-4`}),A?`Deleting...`:`Delete Context`]})]})]}),w===`location`&&(0,h.jsxs)(`form`,{onSubmit:ve,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-url`,className:`text-sm font-medium`,children:`URL`}),(0,h.jsx)(f,{id:`ctx-url`,value:R,onChange:z,fixedWorkspaceName:E.workspaceName,pickerTitle:`Switch context to…`,placeholder:`workspace://path`,onPickTarget:(e,t)=>{z(`${t.workspaceName}://${e.replace(/^\/+/,``)}`),he(t.treeName)}}),H&&(0,h.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Destination tree: `,H]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{htmlFor:`ctx-base-url`,className:`text-sm font-medium`,children:[`Base URL `,(0,h.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,h.jsx)(f,{id:`ctx-base-url`,value:B,onChange:V,fixedWorkspaceName:E.workspaceName,placeholder:`workspace://base/path`,pickerTitle:`Pick a base path…`})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),w===`shares`&&(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`People with access`}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only the context owner can see and change this list.`})]}),(0,h.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(),disabled:G,children:[(0,h.jsx)(o,{className:s(`mr-2 h-3.5 w-3.5`,G&&`animate-spin`)}),`Refresh`]})]}),U.length===0?(0,h.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Not shared with anyone.`}):U.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.userEmail}),(0,h.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[g.find(t=>t.value===e.accessLevel)?.label||e.accessLevel||`unknown access`,e.sharedAt&&` - since ${new Date(e.sharedAt).toLocaleDateString()}`]})]}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,className:`text-destructive hover:text-destructive`,disabled:X===e.userEmail,onClick:()=>xe(e),children:(0,h.jsx)(te,{className:`h-3.5 w-3.5`})})]},e.userEmail))]}),(0,h.jsxs)(`form`,{onSubmit:be,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Grant access`}),(0,h.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-email`,className:`text-sm font-medium`,children:`User email`}),(0,h.jsx)(l,{id:`share-email`,type:`email`,value:q,onChange:e=>J(e.target.value),placeholder:`person@example.com`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The user must already have an account on this server.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-level`,className:`text-sm font-medium`,children:`Access level`}),(0,h.jsx)(`select`,{id:`share-level`,value:Y,onChange:e=>ge(e.target.value),className:`mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:g.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,h.jsx)(c,{type:`submit`,disabled:X===`grant`||!q.trim(),children:X===`grant`?`Sharing...`:`Share context`})]})]})]})})}export{_ as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as ee,g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{G as te,X as a,kt as o}from"./ui-CDoK3F3U.js";import{t as s}from"./utils-2pl1SbIp.js";import{t as c}from"./button-SeUZ_Pvi.js";import{t as l}from"./input-BOtCd4HP.js";import{n as ne}from"./use-toast-BlLDqSUO.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{E as ie,a as ae,c as oe,f as u,r as d,v as se,w as ce,x as le}from"./context-t3rdtGUB.js";import{t as f}from"./PathPickerField-CW2yG2Yg.js";import{i as ue}from"./use-menu-DIP1zh7I.js";import{gt as p,yt as de}from"./index-B01BkfMJ.js";import{n as fe}from"./page-header-DrDt1sQ2.js";var m=e(n(),1),h=t(),g=[{value:`documentRead`,label:`Read`},{value:`documentWrite`,label:`Write`},{value:`documentReadWrite`,label:`Read & write`}];function _(){let{contextId:e,tab:t}=ee(),[n]=i(),_=n.get(`ownerId`)||void 0,v=r(),{showToast:y}=ne(),{selectEntity:b,goBack:x,closeM2:S}=ue(),C=re(),w=de(t),T=_?`?ownerId=${encodeURIComponent(_)}`:``;(0,m.useEffect)(()=>{t!==w&&e&&v(`/contexts/${e}/settings/${w}${T}`,{replace:!0})},[t,w,e,T,v]);let[E,D]=(0,m.useState)(null),[pe,me]=(0,m.useState)(!0),[O,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(!1),[M,N]=(0,m.useState)(``),[P,F]=(0,m.useState)(``),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(``),[B,V]=(0,m.useState)(``),[H,he]=(0,m.useState)(),[U,W]=(0,m.useState)([]),[G,K]=(0,m.useState)(!1),[q,J]=(0,m.useState)(``),[Y,ge]=(0,m.useState)(g[0].value),[X,Z]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!e)return;let t=!1;return ae(e,_).then(e=>{t||(D(e),b(e.id),N(e.name||``),F(e.description||``),L(typeof e.metadata?.ui?.color==`string`?e.metadata.ui.color:null),z(e.url||``),V(e.baseUrl||``))}).catch(()=>{t||y({title:`Error`,description:`Failed to load context`,variant:`destructive`})}).finally(()=>{t||me(!1)}),()=>{t=!0}},[e,_,b,y]);let Q=(t=e)=>{t&&(K(!0),u(t).then(W).catch(()=>W([])).finally(()=>K(!1)))};(0,m.useEffect)(()=>{if(w!==`shares`||!e)return;let t=!1;return u(e).then(e=>{t||W(e)}).catch(()=>{t||W([])}),()=>{t=!0}},[w,e]);let _e=async t=>{if(t.preventDefault(),e){k(!0);try{let t=await se(e,{name:M.trim(),description:P.trim(),metadata:{...E?.metadata,ui:{...E?.metadata?.ui,color:I}}},_);D(t),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ve=async t=>{if(t.preventDefault(),e){k(!0);try{await Promise.all([ie(e,R.trim(),_,H),ce(e,{baseUrl:B.trim()||null},_)]),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),y({title:`Saved`,description:`Context URL updated`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{k(!1)}}},ye=async()=>{if(e&&window.confirm(`Delete context "${e}"? This cannot be undone.`)){j(!0);try{await d(e,_),S(),b(null),y({title:`Deleted`,description:`Context "${e}" removed`}),v(`/contexts`,{replace:!0})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{j(!1)}}},be=async t=>{if(t.preventDefault(),!(!e||!q.trim())){Z(`grant`);try{await oe(e,q.trim(),Y),J(``),Q(),y({title:`Shared`,description:`Access granted to ${q.trim()}`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to grant access`,variant:`destructive`})}finally{Z(null)}}},xe=async t=>{if(e&&window.confirm(`Revoke ${t.userEmail}'s access to "${e}"?`)){Z(t.userEmail);try{await le(e,t.userEmail),Q(),y({title:`Revoked`,description:`${t.userEmail} no longer has access`})}catch(e){y({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke access`,variant:`destructive`})}finally{Z(null)}}};if(pe)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!E)return(0,h.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Context not found`});let $=p.find(e=>e.id===w),Se=`/contexts/${e}${T}`;return(0,h.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,h.jsx)(fe,{compact:!0,className:`mb-6 border-b pb-4`,title:`${$.label} - ${E.name||E.id}`,description:$.description,backTo:Se,onBack:C?x:void 0}),w===`general`&&(0,h.jsxs)(`div`,{className:`space-y-6`,children:[(0,h.jsxs)(`form`,{onSubmit:_e,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Context ID`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 font-mono text-sm text-muted-foreground`,children:E.id})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-name`,className:`text-sm font-medium`,children:`Name`}),(0,h.jsx)(l,{id:`ctx-name`,value:M,onChange:e=>N(e.target.value),placeholder:`My Context`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-description`,className:`text-sm font-medium`,children:`Description`}),(0,h.jsx)(l,{id:`ctx-description`,value:P,onChange:e=>F(e.target.value),placeholder:`Optional description`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-color`,className:`text-sm font-medium`,children:`Color`}),(0,h.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,h.jsx)(l,{id:`ctx-color`,type:`color`,value:/^#[0-9a-f]{6}$/i.test(I||E.color||``)?I||E.color:`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:O}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:O||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Using the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`text-sm font-medium`,children:`Workspace`}),(0,h.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md bg-muted px-3 text-sm text-muted-foreground`,children:E.workspaceName||E.workspaceId||E.workspace})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),(0,h.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,h.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,h.jsxs)(c,{variant:`destructive`,disabled:A,onClick:ye,children:[(0,h.jsx)(a,{className:`mr-2 h-4 w-4`}),A?`Deleting...`:`Delete Context`]})]})]}),w===`location`&&(0,h.jsxs)(`form`,{onSubmit:ve,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`ctx-url`,className:`text-sm font-medium`,children:`URL`}),(0,h.jsx)(f,{id:`ctx-url`,value:R,onChange:z,fixedWorkspaceName:E.workspaceName,pickerTitle:`Switch context to…`,placeholder:`workspace://path`,onPickTarget:(e,t)=>{z(`${t.workspaceName}://${e.replace(/^\/+/,``)}`),he(t.treeName)}}),H&&(0,h.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Destination tree: `,H]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{htmlFor:`ctx-base-url`,className:`text-sm font-medium`,children:[`Base URL `,(0,h.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,h.jsx)(f,{id:`ctx-base-url`,value:B,onChange:V,fixedWorkspaceName:E.workspaceName,placeholder:`workspace://base/path`,pickerTitle:`Pick a base path…`})]}),(0,h.jsx)(c,{type:`submit`,disabled:O,children:O?`Saving...`:`Save Changes`})]}),w===`shares`&&(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`People with access`}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only the context owner can see and change this list.`})]}),(0,h.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(),disabled:G,children:[(0,h.jsx)(o,{className:s(`mr-2 h-3.5 w-3.5`,G&&`animate-spin`)}),`Refresh`]})]}),U.length===0?(0,h.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Not shared with anyone.`}):U.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.userEmail}),(0,h.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[g.find(t=>t.value===e.accessLevel)?.label||e.accessLevel||`unknown access`,e.sharedAt&&` - since ${new Date(e.sharedAt).toLocaleDateString()}`]})]}),(0,h.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,className:`text-destructive hover:text-destructive`,disabled:X===e.userEmail,onClick:()=>xe(e),children:(0,h.jsx)(te,{className:`h-3.5 w-3.5`})})]},e.userEmail))]}),(0,h.jsxs)(`form`,{onSubmit:be,className:`space-y-4 rounded-lg border p-4`,children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Grant access`}),(0,h.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-email`,className:`text-sm font-medium`,children:`User email`}),(0,h.jsx)(l,{id:`share-email`,type:`email`,value:q,onChange:e=>J(e.target.value),placeholder:`person@example.com`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The user must already have an account on this server.`})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`share-level`,className:`text-sm font-medium`,children:`Access level`}),(0,h.jsx)(`select`,{id:`share-level`,value:Y,onChange:e=>ge(e.target.value),className:`mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:g.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,h.jsx)(c,{type:`submit`,disabled:X===`grant`||!q.trim(),children:X===`grant`?`Sharing...`:`Share context`})]})]})]})})}export{_ as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{di as i}from"./ui-CDoK3F3U.js";import{t as a}from"./input-BOtCd4HP.js";import{Nt as o}from"./workspace-BJELPCNs.js";import{p as s}from"./context-DZ1Hn7tt.js";import{i as c,m as l,p as u}from"./use-menu-DIP1zh7I.js";import{Y as d,_t as f,gt as p,ht as m}from"./index-Cp75myNf.js";import{n as h}from"./page-header-DrDt1sQ2.js";var g=e(n(),1),_=t(),v=[{id:`workspace`,label:`Workspace`,path:`workspaces`,description:`Files, search, devices and sharing for one workspace. These settings override account defaults.`,sections:f,load:async()=>(await o()).map(e=>({id:e.name,label:e.label||e.name}))},{id:`context`,label:`Context`,path:`contexts`,description:`Choose the tree and path a context opens, and who can access that view. File storage belongs to its workspace.`,sections:p,load:async()=>(await s()).map(e=>({id:e.id,label:e.name||e.id}))},{id:`agent`,label:`Agent`,path:`agents`,description:`Configure one assistant: its instructions, chat model, tools and access to Canvas.`,sections:m,load:async()=>(await d()).map(e=>({id:e.id,label:e.label||e.name}))}];function y({to:e,label:t,description:n,icon:a}){return(0,_.jsxs)(r,{to:e,className:`group flex items-start gap-3 rounded-lg border bg-card p-4 transition-colors hover:border-primary/50 hover:bg-accent/30 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary`,children:[(0,_.jsx)(a,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,_.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`span`,{className:`block text-sm font-semibold`,children:t}),(0,_.jsx)(`span`,{className:`mt-1 block text-sm leading-relaxed text-muted-foreground`,children:n})]}),(0,_.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary`})]})}function b({group:e,query:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`loading`),[c,u]=(0,g.useState)(0);(0,g.useEffect)(()=>{let t=!1;return e.load().then(e=>{t||(r(e),s(`ready`))}).catch(()=>{t||s(`error`)}),()=>{t=!0}},[e,c]);let d=e.sections.filter(n=>l(t,e.label,n.label,n.description));return d.length?(0,_.jsxs)(`section`,{id:e.id,className:`scroll-mt-6 space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsxs)(`label`,{className:`block max-w-md text-sm font-medium`,children:[`Choose a `,e.label.toLowerCase(),(0,_.jsxs)(`select`,{className:`mt-2 h-10 w-full rounded-md border bg-background px-3 text-sm`,value:i,disabled:o!==`ready`||!n.length,onChange:e=>a(e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:o===`loading`?`Loading…`:o===`error`?`Unable to load list`:n.length?`Select ${e.label.toLowerCase()}…`:`No ${e.path} available`}),n.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),o===`error`&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`The list could not be loaded. `,(0,_.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>{s(`loading`),u(e=>e+1)},children:`Retry`})]}),(0,_.jsxs)(`details`,{open:!!(i||t.trim()),children:[(0,_.jsx)(`summary`,{className:`cursor-pointer py-2 text-sm text-muted-foreground`,children:i?`Settings for ${n.find(e=>e.id===i)?.label||i}`:`What you can configure (${d.length})`}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:d.map(t=>i?(0,_.jsx)(y,{to:`/${e.path}/${encodeURIComponent(i)}/settings/${t.id}`,...t},t.id):(0,_.jsxs)(`div`,{className:`rounded-lg border border-dashed p-4`,children:[(0,_.jsx)(`p`,{className:`text-sm font-medium`,children:t.label}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t.description})]},t.id))})]})]}):null}function x(){let{state:e}=c(),[t,n]=(0,g.useState)(``),r=u.filter(t=>t.id!==`server`||e.user?.userType===`admin`).map(e=>({...e,items:e.items.filter(n=>l(t,e.label,n.label,n.description))})).filter(e=>e.items.length),i=v.some(e=>e.sections.some(n=>l(t,e.label,n.label,n.description)));return(0,_.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-8 pb-8 max-md:pb-rail-stack`,children:[(0,_.jsx)(h,{title:`Settings`,description:`Start with what you want to change. Each section explains where your changes apply.`}),(0,_.jsx)(a,{type:`search`,className:`max-w-xl`,"aria-label":`Search all settings`,placeholder:`Find a setting: offline, folders, models, sharing…`,value:t,onChange:e=>n(e.target.value)}),r.filter(e=>e.id===`device`||e.id===`account`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),v.map(e=>(0,_.jsx)(b,{group:e,query:t},e.id)),r.filter(e=>e.id===`server`||e.id===`information`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),!r.length&&!i&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`No settings match “`,t,`”. Try a shorter phrase or clear the search.`]})]})}export{x as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{di as i}from"./ui-CDoK3F3U.js";import{t as a}from"./input-BOtCd4HP.js";import{jt as o}from"./workspace-C5V-ZCOE.js";import{p as s}from"./context-t3rdtGUB.js";import{i as c,m as l,p as u}from"./use-menu-DIP1zh7I.js";import{Y as d,_t as f,gt as p,ht as m}from"./index-B01BkfMJ.js";import{n as h}from"./page-header-DrDt1sQ2.js";var g=e(n(),1),_=t(),v=[{id:`workspace`,label:`Workspace`,path:`workspaces`,description:`Files, search, devices and sharing for one workspace. These settings override account defaults.`,sections:f,load:async()=>(await o()).map(e=>({id:e.name,label:e.label||e.name}))},{id:`context`,label:`Context`,path:`contexts`,description:`Choose the tree and path a context opens, and who can access that view. File storage belongs to its workspace.`,sections:p,load:async()=>(await s()).map(e=>({id:e.id,label:e.name||e.id}))},{id:`agent`,label:`Agent`,path:`agents`,description:`Configure one assistant: its instructions, chat model, tools and access to Canvas.`,sections:m,load:async()=>(await d()).map(e=>({id:e.id,label:e.label||e.name}))}];function y({to:e,label:t,description:n,icon:a}){return(0,_.jsxs)(r,{to:e,className:`group flex items-start gap-3 rounded-lg border bg-card p-4 transition-colors hover:border-primary/50 hover:bg-accent/30 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary`,children:[(0,_.jsx)(a,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,_.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`span`,{className:`block text-sm font-semibold`,children:t}),(0,_.jsx)(`span`,{className:`mt-1 block text-sm leading-relaxed text-muted-foreground`,children:n})]}),(0,_.jsx)(i,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary`})]})}function b({group:e,query:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`loading`),[c,u]=(0,g.useState)(0);(0,g.useEffect)(()=>{let t=!1;return e.load().then(e=>{t||(r(e),s(`ready`))}).catch(()=>{t||s(`error`)}),()=>{t=!0}},[e,c]);let d=e.sections.filter(n=>l(t,e.label,n.label,n.description));return d.length?(0,_.jsxs)(`section`,{id:e.id,className:`scroll-mt-6 space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsxs)(`label`,{className:`block max-w-md text-sm font-medium`,children:[`Choose a `,e.label.toLowerCase(),(0,_.jsxs)(`select`,{className:`mt-2 h-10 w-full rounded-md border bg-background px-3 text-sm`,value:i,disabled:o!==`ready`||!n.length,onChange:e=>a(e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:o===`loading`?`Loading…`:o===`error`?`Unable to load list`:n.length?`Select ${e.label.toLowerCase()}…`:`No ${e.path} available`}),n.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),o===`error`&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`The list could not be loaded. `,(0,_.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>{s(`loading`),u(e=>e+1)},children:`Retry`})]}),(0,_.jsxs)(`details`,{open:!!(i||t.trim()),children:[(0,_.jsx)(`summary`,{className:`cursor-pointer py-2 text-sm text-muted-foreground`,children:i?`Settings for ${n.find(e=>e.id===i)?.label||i}`:`What you can configure (${d.length})`}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:d.map(t=>i?(0,_.jsx)(y,{to:`/${e.path}/${encodeURIComponent(i)}/settings/${t.id}`,...t},t.id):(0,_.jsxs)(`div`,{className:`rounded-lg border border-dashed p-4`,children:[(0,_.jsx)(`p`,{className:`text-sm font-medium`,children:t.label}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t.description})]},t.id))})]})]}):null}function x(){let{state:e}=c(),[t,n]=(0,g.useState)(``),r=u.filter(t=>t.id!==`server`||e.user?.userType===`admin`).map(e=>({...e,items:e.items.filter(n=>l(t,e.label,n.label,n.description))})).filter(e=>e.items.length),i=v.some(e=>e.sections.some(n=>l(t,e.label,n.label,n.description)));return(0,_.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-8 pb-8 max-md:pb-rail-stack`,children:[(0,_.jsx)(h,{title:`Settings`,description:`Start with what you want to change. Each section explains where your changes apply.`}),(0,_.jsx)(a,{type:`search`,className:`max-w-xl`,"aria-label":`Search all settings`,placeholder:`Find a setting: offline, folders, models, sharing…`,value:t,onChange:e=>n(e.target.value)}),r.filter(e=>e.id===`device`||e.id===`account`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),v.map(e=>(0,_.jsx)(b,{group:e,query:t},e.id)),r.filter(e=>e.id===`server`||e.id===`information`).map(e=>(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,_.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,16rem),1fr))] gap-3`,children:e.items.map(e=>(0,_.jsx)(y,{to:e.path,...e},e.path))})]},e.id)),!r.length&&!i&&(0,_.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`No settings match “`,t,`”. Try a shorter phrase or clear the search.`]})]})}export{x as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-CDoK3F3U.js";import{t as a}from"./button-SeUZ_Pvi.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Nt as ne}from"./workspace-BJELPCNs.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-DZ1Hn7tt.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-DIP1zh7I.js";import{$ as oe,H as se,J as ce,K as le,Q as ue,U as de,X as fe,Z as pe,et as me,ht as he,q as ge,rt as _e,vt as ve,z as ye}from"./index-Cp75myNf.js";import{n as be}from"./page-header-DrDt1sQ2.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-B10Tbl6D.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ve(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return se(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await ce(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([de(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),le(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await _e(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await ye(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await ge(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await fe(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await me(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await oe(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await ue(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await pe(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=he.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}export{h as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-CDoK3F3U.js";import{t as a}from"./button-SeUZ_Pvi.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{jt as ne}from"./workspace-C5V-ZCOE.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-t3rdtGUB.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-DIP1zh7I.js";import{$ as oe,H as se,J as ce,K as le,Q as ue,U as de,X as fe,Z as pe,et as me,ht as he,q as ge,rt as _e,vt as ve,z as ye}from"./index-B01BkfMJ.js";import{n as be}from"./page-header-DrDt1sQ2.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-KcfEQ6u9.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ve(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return se(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await ce(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([de(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),le(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await _e(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await ye(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await ge(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await fe(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await me(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await oe(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await ue(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await pe(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=he.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}export{h as default};