@augmentd-labs/canvas-web 2.26.18 → 2.26.20

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 (155) hide show
  1. package/dist/assets/DocumentBodyEditor-CE2S2X6g.js +1 -0
  2. package/dist/assets/DocumentIcon-BS10SIP6.js +1 -0
  3. package/dist/assets/EditorOverlay-BUToR_av.js +1 -0
  4. package/dist/assets/FileForm-BxTixeDm.js +1 -0
  5. package/dist/assets/FiltersApplet-BpqITV13.js +1 -0
  6. package/dist/assets/HomeFab-BAKOAkpE.js +3 -0
  7. package/dist/assets/IdentityFields-C2MPM-Ab.js +1 -0
  8. package/dist/assets/LensApplet-DNTGwgZs.js +1 -0
  9. package/dist/assets/LinkToCard-BZwwE-Dv.js +1 -0
  10. package/dist/assets/LinkToSidePanel-eCy3nW4R.js +1 -0
  11. package/dist/assets/{LocationTab-BONJQfYM.js → LocationTab-DAtqAQ3l.js} +1 -1
  12. package/dist/assets/{MarkdownEditor-CkobBLtI.js → MarkdownEditor-7OqSDr7E.js} +1 -1
  13. package/dist/assets/MessageComposerDialog-DzLhkHyh.js +4 -0
  14. package/dist/assets/{NextShell-Byg6OtC2.js → NextShell-D9gvlKY2.js} +1 -1
  15. package/dist/assets/NotesApplet-gMAMneRi.js +1 -0
  16. package/dist/assets/ObjectPropertiesCard-C3jt40tM.css +1 -0
  17. package/dist/assets/ObjectPropertiesCard-DDcRLpsW.js +8 -0
  18. package/dist/assets/PathPickerField-cVs5sZuG.js +1 -0
  19. package/dist/assets/PickDocumentsCard-BlicxMqC.js +1 -0
  20. package/dist/assets/SketchApplet-D8mkYmK9.js +1 -0
  21. package/dist/assets/{SketchEditor-C9_lu3Ot.js → SketchEditor-zMrm1npg.js} +4 -4
  22. package/dist/assets/TerminalApplet-BO2HRp0z.js +20 -0
  23. package/dist/assets/TerminalApplet-BrP-ENHg.css +1 -0
  24. package/dist/assets/TextDocumentEditor-7V4aFL8i.js +1 -0
  25. package/dist/assets/TodosApplet-swdaBT-2.js +1 -0
  26. package/dist/assets/TodosWidget-BXF8fYer.js +1 -0
  27. package/dist/assets/UploadProgressList-B2xCVzFR.js +1 -0
  28. package/dist/assets/_agentId_-Ci4j4UYy.js +0 -0
  29. package/dist/assets/_contextId_-DDFyhgV2.js +1 -0
  30. package/dist/assets/_workspaceName_-DO9ZBx7N.js +1 -0
  31. package/dist/assets/about-B1_n4Iu8.js +1 -0
  32. package/dist/assets/add-BnwWcDlO.js +1 -0
  33. package/dist/assets/admin-Bhg9QBHL.js +5 -0
  34. package/dist/assets/agents-ClK3Y2x0.js +1 -0
  35. package/dist/assets/agents-DquOfkFX.js +1 -0
  36. package/dist/assets/alert-dialog-DIA-tAP5.js +1 -0
  37. package/dist/assets/api-CA6WiiYM.js +1 -0
  38. package/dist/assets/api-tokens-O5iFESo0.js +1 -0
  39. package/dist/assets/appearance-C2vu3ALt.js +1 -0
  40. package/dist/assets/applet-target-DnTa2VAT.js +1 -0
  41. package/dist/assets/apps-BZrw8Cqo.js +1 -0
  42. package/dist/assets/auth-Bx9fAZmz.js +1 -0
  43. package/dist/assets/auth-CUdpxbLV.js +1 -0
  44. package/dist/assets/backend-sync-progress-DU-e9TWi.css +1 -0
  45. package/dist/assets/backend-sync-progress-DWR42uQV.js +7 -0
  46. package/dist/assets/blobs-WiXP9QRi.js +1 -0
  47. package/dist/assets/button-Bv4zA1qr.js +1 -0
  48. package/dist/assets/chunk-62JRHF6Z-vspAGgtK.js +3 -0
  49. package/dist/assets/{chunk-K2UTITRG-zQFDOW3Q.js → chunk-K2UTITRG-BvHe9UPk.js} +3 -3
  50. package/dist/assets/code-editor-BOIngd5F.js +40 -0
  51. package/dist/assets/color-DFEH4BfK.js +1 -0
  52. package/dist/assets/content-app-view-C33Ip_rx.js +1 -0
  53. package/dist/assets/context-D_K4g9SQ.js +1 -0
  54. package/dist/assets/contexts-B6d6Axza.js +1 -0
  55. package/dist/assets/contexts-CgydYDn-2.js +1 -0
  56. package/dist/assets/date-time-picker-BZaA3M9_.js +1 -0
  57. package/dist/assets/desk-dI_FvLsK.js +1 -0
  58. package/dist/assets/devices-CAa1bRxk.js +1 -0
  59. package/dist/assets/devices-D3-_UWM0.js +1 -0
  60. package/dist/assets/document-BG_mODBn.js +1 -0
  61. package/dist/assets/document-list-BiogH4tf.js +2 -0
  62. package/dist/assets/document-list-DAYdk5vh.css +1 -0
  63. package/dist/assets/document-open-mode-DoImW-xs.js +1 -0
  64. package/dist/assets/embedding-Cjrxh6MN.js +1 -0
  65. package/dist/assets/embedding-m8SZH4oN.js +1 -0
  66. package/dist/assets/form-panel-Dz96K7Lv.js +1 -0
  67. package/dist/assets/geo-CZfs0E-x.js +1 -0
  68. package/dist/assets/home-pS7q4Wl4.js +1 -0
  69. package/dist/assets/image-GAAHSSAO-CI-0hUck.js +1 -0
  70. package/dist/assets/index-C10UNpew.css +2 -0
  71. package/dist/assets/index-exXolIqD.js +16 -0
  72. package/dist/assets/inferd-config-editor-DagMmwW4.js +1 -0
  73. package/dist/assets/input-BOtCd4HP.js +1 -0
  74. package/dist/assets/key-bindings-BOtykyXR.js +1 -0
  75. package/dist/assets/label-CNoJOoe0.js +1 -0
  76. package/dist/assets/last-path-BbXWC3b3.js +1 -0
  77. package/dist/assets/layer-style-Byl5LNFR.js +1 -0
  78. package/dist/assets/lazy-editor-Cbva8Pe2.js +2 -0
  79. package/dist/assets/logs-CdbfY8_H.js +1 -0
  80. package/dist/assets/{markdown-html-XoABNf32.js → markdown-html-CZMGihx6.js} +1 -1
  81. package/dist/assets/markdown-view-BBBZtNSR.js +2 -0
  82. package/dist/assets/note-save-status-DPz4VzL6.js +1 -0
  83. package/dist/assets/offline-BjMpUv3N.js +1 -0
  84. package/dist/assets/page-header-GtTr9Ff_.js +1 -0
  85. package/dist/assets/public-share-DT9Tgn_Y.js +1 -0
  86. package/dist/assets/query-debug-tVbB_8Z6.js +1 -0
  87. package/dist/assets/react-BHzhHVTZ.js +164 -0
  88. package/dist/assets/registry-6tE_1KPV.js +2 -0
  89. package/dist/assets/relation-events-CKio19hE.js +1 -0
  90. package/dist/assets/remotes-DR_iJClb.js +1 -0
  91. package/dist/assets/role-C5I0Plgn.js +1 -0
  92. package/dist/assets/roles-DERIgujv.js +2 -0
  93. package/dist/assets/roles-DswT1Lv0.js +2 -0
  94. package/dist/assets/settings-Cc6OMCOX.js +14 -0
  95. package/dist/assets/settings-D7K7z_JD.js +1 -0
  96. package/dist/assets/settings-Du8r1SXC.js +1 -0
  97. package/dist/assets/settings-vosK_LI-.js +1 -0
  98. package/dist/assets/share-target-Df10J5JB.js +1 -0
  99. package/dist/assets/shared-1dpCuibu.js +1 -0
  100. package/dist/assets/shared-C7b3QOUP.js +1 -0
  101. package/dist/assets/sketch-lazy-Q58-vPF-.js +2 -0
  102. package/dist/assets/socket-CtH3EU9m.js +1 -0
  103. package/dist/assets/subtree-transfer-dialog-B7s4r78T.js +1 -0
  104. package/dist/assets/tags-YamdPoBK.js +1 -0
  105. package/dist/assets/text-documents-D_zDMyhB.js +2 -0
  106. package/dist/assets/{ui-BqHBdBU4.js → ui-BSqPn1LJ.js} +2 -2
  107. package/dist/assets/url-params-n7kU_WZ-.js +1 -0
  108. package/dist/assets/use-applet-docs-Cry2SFsG.js +1 -0
  109. package/dist/assets/use-applet-target-mkjQujx6.js +1 -0
  110. package/dist/assets/use-canvas-pins-C57Vbkrq.css +1 -0
  111. package/dist/assets/use-canvas-pins-CZBfEB5E.js +3 -0
  112. package/dist/assets/use-create-panel-DhSNIGtr.js +1 -0
  113. package/dist/assets/use-document-modal-PG8bQyIB.js +1 -0
  114. package/dist/assets/use-menu-BVkqNEIx.js +1 -0
  115. package/dist/assets/use-mobile-Db-vWu9Y.js +1 -0
  116. package/dist/assets/use-settings-back-Dk-DJEUO.js +1 -0
  117. package/dist/assets/use-sortable-data-DYIDDI8c.js +1 -0
  118. package/dist/assets/{use-theme-Bd8sb5Ox.js → use-theme-DaxpiICf.js} +1 -1
  119. package/dist/assets/use-toast-BlLDqSUO.js +1 -0
  120. package/dist/assets/use-toolbox-Ck_cLGgf.js +1 -0
  121. package/dist/assets/use-workspace-identity-BVpGHkZq.js +1 -0
  122. package/dist/assets/useAddTarget-CVRPElxz.js +1 -0
  123. package/dist/assets/useAgentModels-DI41aFY3.js +3 -0
  124. package/dist/assets/useDocumentThumbnail-C_rq2rXs.js +1 -0
  125. package/dist/assets/useEditNoteFields-Bigs9ZG8.js +1 -0
  126. package/dist/assets/useEscapeClose-DR_xKT_k.js +1 -0
  127. package/dist/assets/useSocketSubscription-ifW-vnlb.js +1 -0
  128. package/dist/assets/useToastHelpers-CRrpIIdY.js +1 -0
  129. package/dist/assets/users-C9N-O1QA.js +1 -0
  130. package/dist/assets/workspace-BydSRtST.js +1 -0
  131. package/dist/assets/workspace-CJ1PWQ29.js +1 -0
  132. package/dist/assets/workspace-access-C9nZlBBZ.js +1 -0
  133. package/dist/assets/workspace-area-menu-Ba_9bGKs.js +1 -0
  134. package/dist/assets/workspace-content-gate-D8bzGD9i.js +1 -0
  135. package/dist/assets/workspace-import-form-D5JA8gzx.js +1 -0
  136. package/dist/assets/workspaces-C9Wtka2V.js +1 -0
  137. package/dist/assets/workspaces-Dx5_N57M.js +1 -0
  138. package/dist/index.html +69 -14
  139. package/dist/sw.js +1 -1
  140. package/package.json +2 -2
  141. package/dist/assets/EditorOverlay-B384ALjA.js +0 -1
  142. package/dist/assets/TextDocumentEditor-DBVWuJaR.js +0 -1
  143. package/dist/assets/alert-dialog-BC58hyW-.js +0 -1
  144. package/dist/assets/blobs-CtDkR2hC.js +0 -1
  145. package/dist/assets/code-editor-BQnKd3jw.js +0 -40
  146. package/dist/assets/document-list-BmUv3zzK.js +0 -19
  147. package/dist/assets/document-list-r-TfV16D.css +0 -1
  148. package/dist/assets/image-GAAHSSAO-BoD-NvEF.js +0 -1
  149. package/dist/assets/index-BhcdilCi.css +0 -2
  150. package/dist/assets/index-CiNkwkdB.js +0 -61
  151. package/dist/assets/react-BzqgEMSQ.js +0 -164
  152. package/dist/assets/subtree-transfer-dialog-DRz8kLqY.js +0 -1
  153. package/dist/assets/text-documents-BvR9-zf4.js +0 -3
  154. package/dist/assets/useAddTarget-CgZfKokT.js +0 -1
  155. package/dist/assets/workspace-BSXnX2Me.js +0 -1
@@ -0,0 +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-BSqPn1LJ.js";import{t as a}from"./button-Bv4zA1qr.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Pt as ne}from"./workspace-CJ1PWQ29.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-D_K4g9SQ.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-BVkqNEIx.js";import{$ as oe,B as se,G as ce,I as le,J as ue,U as de,W as fe,X as pe,Y as me,dt as he,mt as ge,q as _e,z as ve}from"./index-exXolIqD.js";import{n as ye}from"./page-header-GtTr9Ff_.js";import{n as be,r as xe,t as Se}from"./useAgentModels-DI41aFY3.js";var c=e(n(),1),l=t(),Ce={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:we}=ae(),Te=re(),g=ge(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),[Ee,De]=(0,c.useState)(!0),[Oe,ke]=(0,c.useState)(null),[Ae,je]=(0,c.useState)(!1),[Me,Ne]=(0,c.useState)(!1),[Pe,Fe]=(0,c.useState)(``),[Ie,Le]=(0,c.useState)(``),[Re,ze]=(0,c.useState)(``),[Be,y]=(0,c.useState)(s()),[b,Ve]=(0,c.useState)(``),[x,He]=(0,c.useState)(``),[S,Ue]=(0,c.useState)(``),[C,We]=(0,c.useState)(``),[w,Ge]=(0,c.useState)(`anthropic`),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(``),[k,A]=(0,c.useState)(``),[Ke,qe]=(0,c.useState)(.7),[Je,j]=(0,c.useState)(4096),[Ye,Xe]=(0,c.useState)(1),Ze=Se(w,T,D,_?.id),Qe=Ze.models.find(e=>e.id===k),[$e,M]=(0,c.useState)([]),[N,P]=(0,c.useState)(``),[et,F]=(0,c.useState)(``),[I,L]=(0,c.useState)(``),[R,z]=(0,c.useState)(``),[tt,nt]=(0,c.useState)(!1),[rt,it]=(0,c.useState)(null),[B,V]=(0,c.useState)(null),[at,ot]=(0,c.useState)(null),[H,U]=(0,c.useState)(!1),[W,G]=(0,c.useState)(null),[K,st]=(0,c.useState)(`context`),[q,ct]=(0,c.useState)(``),[lt,ut]=(0,c.useState)(`/`),[J,dt]=(0,c.useState)(``),[ft,pt]=(0,c.useState)(!0),[Y,mt]=(0,c.useState)(!1),[ht,gt]=(0,c.useState)([]),[_t,vt]=(0,c.useState)([]),[X,yt]=(0,c.useState)(null),[bt,Z]=(0,c.useState)(`{}`),[xt,Q]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(e);St!==e&&(Ct(e),De(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return ve(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Fe(e.name||``),Le(e.label||``),ze(e.description||``),y(e.color||s()),Ve(n.role||``),He(n.identity||``),Ue(n.instructions||``),We(e.config?.prompts?.system||``),Ge(e.llmProvider||`anthropic`),E(e.config?.apiKey||``),O(e.config?.baseUrl||d(e.llmProvider)),A(e.model||Ce[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(qe(r.temperature??.7),j(r.maxTokens??4096),Xe(r.topP??1)),Z(JSON.stringify(e.config?.tools??{},null,2)),Q(null),ke(null);try{M(await ce(e.id))}catch{M([])}}).catch(e=>{t||ke(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||De(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([se(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),de(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(V(n),gt(r),vt(ee),yt(i?i.tools:[]),n&&(st(n.binding.type),ct(n.binding.workspace||``),ut(n.binding.path||`/`),dt(n.binding.context||``),pt(n.permissions.includes(`read`)),mt(n.permissions.includes(`write`))),ot(e))}),()=>{t=!0}},[g,_?.id]);let wt=()=>{let e=xe(b,x,S),t;try{let e=JSON.parse(bt);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Pe.trim(),label:Ie.trim(),description:Re.trim()||void 0,color:Be,llmProvider:w,model:k,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:D||void 0,config:{type:w,model:k,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:Ke},maxTokens:Je,topP:Ye}}}}},Tt=async e=>{if(e.preventDefault(),_){je(!0);try{let e=await oe(_.id,wt());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{je(!1)}}},Et=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Ne(!0);try{await le(_.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{Ne(!1)}}},$=()=>{P(``),F(``),L(``),z(``)},Dt=async()=>{if(!(!_||!R.trim()&&!I.trim())){nt(!0);try{let e=await fe(_.id,R.trim()?{source:R.trim()}:{name:N,description:et,content:I});M(e),$(),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{nt(!1)}}},Ot=async e=>{if(_){it(e);try{let t=await _e(_.id,e);M(t),(N===e||R===e)&&$(),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{it(null)}}},kt=()=>K===`global`?{type:`global`}:K===`context`?J?{type:`context`,context:J}:null:q?K===`path`?{type:`path`,workspace:q,path:lt.trim()||`/`}:{type:`workspace`,workspace:q}:null,At=async()=>{if(!_||H)return;let e=kt(),t=[];if(ft&&t.push(`read`),Y&&t.push(`write`),!e||t.length===0){u({title:`Invalid binding`,description:`Pick a scope target and at least one permission`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Y?`read and write`:`read`} ALL your workspaces. Continue?`))){U(!0);try{let n=await pe(_.id,{binding:e,permissions:t});V(n.access),G(n.token),u({title:`Bound`,description:`Access bound — copy the token now, it is not shown again`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{U(!1)}}},jt=async()=>{if(!(!_||H)){U(!0);try{let e=await me(_.id);V(e.access),G(e.token),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{U(!1)}}},Mt=async()=>{if(!(!_||H)&&window.confirm(`Revoke this agent's canvas access? Its token stops working immediately.`)){U(!0);try{await ue(_.id),V(null),G(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{U(!1)}}},Nt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=_t.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(Ee)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||Oe)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:Oe||`Agent not found`});let Pt=he.find(e=>e.id===g),Ft=encodeURIComponent(_.name||_.id),It=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)(ye,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Pt.label} - ${_.label||_.name}`,description:Pt.description,backTo:`/agents/${Ft}`,onBack:Te?we:void 0}),(0,l.jsxs)(`form`,{onSubmit:Tt,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:Pe,onChange:e=>Fe(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Ie,onChange:e=>Le(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:Re,onChange:e=>ze(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:Be,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=>Ve(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>He(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=>Ue(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=>We(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:Me,onClick:Et,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Me?`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;Ge(t),E(``),A(Ce[t]||``),O(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=>E(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:D,onChange:e=>O(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)(be,{value:k,onChange:(e,t)=>{A(e),t?.maxTokens&&j(t.maxTokens)},...Ze})}),(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:Ke,onChange:e=>qe(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:Qe?.maxTokens,value:Je,onChange:e=>j(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:Ye,onChange:e=>Xe(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.`})]}),X===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):X.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:X.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:B?Nt(B.binding):`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:bt,onChange:e=>{Z(e.target.value);try{JSON.parse(e.target.value),Q(null)}catch(e){Q(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),xt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,xt]})]}),(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.`})]}),$e.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):$e.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:()=>{P(e.name),F(e.description||``),L(e.content||``),z(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:rt===(e.source||e.name),onClick:()=>Ot(e.source||e.name),children:rt===(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:R,onChange:e=>z(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:N,onChange:e=>P(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!R.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:et,onChange:e=>F(e.target.value),placeholder:`What this skill helps with`,disabled:!!R.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:`# Skill instructions…`,disabled:!!R.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:tt||!R.trim()&&!I.trim(),onClick:Dt,children:tt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:$,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:`The agent talks to canvas through its own scoped token; the server clamps every request to the binding. Bind, rotate and revoke apply immediately.`})]}),at===_.id?B?(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:Nt(B.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,B.permissions.join(`, `)||`none`,B.boundAt?` · bound ${new Date(B.boundAt).toLocaleString()}`:``,B.rotatedAt?` · token rotated ${new Date(B.rotatedAt).toLocaleString()}`:``]}),(0,l.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:H,onClick:jt,children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:H,onClick:Mt,children:`Revoke 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…`}),W&&(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:W}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(W),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>G(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`In-process agents receive it automatically (canvas.env); external runtimes (agentd) take it as CANVAS_TOKEN.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:B?`Rebind`:`Bind`}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:K,onChange:e=>st(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)`})]})}),K===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:J,onChange:e=>dt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),_t.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(K===`workspace`||K===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:q,onChange:e=>ct(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),ht.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),K===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:lt,onChange:e=>ut(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:ft,onChange:e=>pt(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>mt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:H,onClick:At,children:H?`Working…`:B?`Rebind & Mint Token`:`Bind & Mint Token`})]})]}),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.`})]}),It&&(0,l.jsx)(a,{type:`submit`,disabled:Ae,children:Ae?`Saving…`:`Save Changes`})]})]})})}export{h as default};
@@ -0,0 +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{ci as i}from"./ui-BSqPn1LJ.js";import{t as a}from"./input-BOtCd4HP.js";import{Pt as o}from"./workspace-CJ1PWQ29.js";import{p as s}from"./context-D_K4g9SQ.js";import{i as c,m as l,p as u}from"./use-menu-BVkqNEIx.js";import{K as d,dt as f,ft as p,pt as m}from"./index-exXolIqD.js";import{n as h}from"./page-header-GtTr9Ff_.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:m,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:f,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};
@@ -0,0 +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,Ot as a,X as o}from"./ui-BSqPn1LJ.js";import{t as s}from"./utils-2pl1SbIp.js";import{t as c}from"./button-Bv4zA1qr.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-D_K4g9SQ.js";import{t as f}from"./PathPickerField-cVs5sZuG.js";import{i as ue}from"./use-menu-BVkqNEIx.js";import{ft as p,ht as de}from"./index-exXolIqD.js";import{n as fe}from"./page-header-GtTr9Ff_.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)(o,{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)(a,{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};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{n as a,t as o}from"./HomeFab-BAKOAkpE.js";var s=e(n(),1),c=`share-target-inbox`,l=t(),u={"too-large":`Android shares are limited to 100 MiB in total for temporary device storage. Nothing was uploaded. Use Add File to upload larger files directly.`,"stash-failed":`Canvas couldn't hold on to the shared file — device storage may be full. Try again, or upload it from the app.`,"empty-share":`Canvas received no files or text from the sharing app. Try again, or use Add File to select the photo directly.`,"empty-file":`The sharing app delivered an empty file. Try again, or use Add File to select the original directly.`,expired:`Nothing shared, or the share expired.`};async function d(e){let t=await caches.open(c),n=null,r=Date.now()+3e5;for(;Date.now()<r;){let r=await t.match(`/share-target-inbox/${e}/meta`);if(!r)return null;if(n=await r.json(),n?.status===`error`)throw Error(n.error||`stash-failed`);if(n?.status!==`receiving`)break;await new Promise(e=>setTimeout(e,300))}if(!n||n.status===`receiving`)throw Error(`stash-failed`);let i=[];for(let r=0;r<n.fileNames.length;r++){let a=await t.match(`/share-target-inbox/${e}/file-${r}`);if(!a)throw Error(`stash-failed`);let o=await a.blob();i.push(new File([o],n.fileNames[r],{type:o.type}))}let o=i.length?await a(i):null;if(await Promise.all(n.fileNames.map((n,r)=>t.delete(`/share-target-inbox/${e}/file-${r}`))),await t.delete(`/share-target-inbox/${e}/meta`),o)return{kind:o.kind,data:{files:o.files}};if(![n.title,n.text,n.url].some(e=>e.trim()))throw Error(`empty-share`);let s=n.text.trim(),l=n.url||(m(s)?s:``);return l?{kind:`link`,data:{url:l,title:n.title}}:{kind:`note`,data:{title:n.title,content:n.text}}}var f=new Map;function p(e){let t=f.get(e);return t||(t=d(e),f.set(e,t),t.finally(()=>setTimeout(()=>f.delete(e),6e4)).catch(()=>{})),t}function m(e){if(!e||/\s/.test(e))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function h(){let[e]=i(),t=r(),[n,a]=(0,s.useState)(null),[c,d]=(0,s.useState)(null);(0,s.useEffect)(()=>{let t=!1;async function n(){let n=e.get(`error`);if(n){d(n);return}let r=e.get(`token`),i=r?await p(r):null;t||(i?a(i):d(`expired`))}return n().catch(e=>{t||d(e instanceof Error?e.message:`stash-failed`)}),()=>{t=!0}},[e]);let f=()=>t(`/home`,{replace:!0});return c?(0,l.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u[c]??u.expired}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>t(`/apps/add/file`,{replace:!0}),className:`text-sm font-medium text-primary underline underline-offset-4`,children:`Add File`}),(0,l.jsx)(`button`,{type:`button`,onClick:f,className:`text-sm font-medium text-primary underline underline-offset-4`,children:`Go to Canvas`})]}):n?(0,l.jsx)(o,{initialKind:n.kind,initialData:n.data,onInitialCardClose:f}):(0,l.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Receiving shared content on this device… No upload has started.`})}export{h as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{X as r,gn as i}from"./ui-BSqPn1LJ.js";import{t as a}from"./LinkToCard-BZwwE-Dv.js";import{Vt as o,_ as s}from"./workspace-CJ1PWQ29.js";import{n as c}from"./relation-events-CKio19hE.js";import{t as l}from"./useToastHelpers-CRrpIIdY.js";import{n as u,t as d}from"./LinkToSidePanel-eCy3nW4R.js";var f=e(n(),1),p=t();function m({value:e,onChange:t,onBlur:n,placeholder:r,innerRef:i}){let a=(0,f.useRef)(null),o=(0,f.useCallback)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,f.useEffect)(()=>{o()},[e,o]),(0,p.jsx)(`textarea`,{ref:e=>{a.current=e,i?.(e)},value:e,onChange:e=>t(e.target.value),onBlur:n,placeholder:r,rows:1,spellCheck:!1,className:`w-full resize-none overflow-hidden border-0 bg-transparent p-0 text-sm leading-relaxed text-foreground outline-none placeholder:text-muted-foreground/60`})}function h({onLinkTo:e,onDelete:t}){return(0,p.jsxs)(`span`,{className:`reveal-on-hover flex items-center gap-0.5`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:e,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Link to…`,title:`Link to…`,children:(0,p.jsx)(i,{className:`h-3.5 w-3.5`})}),(0,p.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-destructive`,"aria-label":`Delete`,title:`Delete (moves to trash)`,children:(0,p.jsx)(r,{className:`h-3.5 w-3.5`})})]})}function g({documentId:e,workspaceName:t,onClose:n}){let{showSuccessToast:r,showErrorToast:i}=l(),[m,h]=(0,f.useState)(!1);return(0,p.jsx)(u,{onClose:n,children:(0,p.jsx)(a,{onClose:n,onConfirm:async(t,a)=>{if(t.length){h(!0);try{for(let n of t)await o(a.workspaceName,n,[e],a.treeName,a.treeType);r(`Linked to ${t.length} path${t.length>1?`s`:``}`),n()}catch(e){i(e instanceof Error?e.message:`Failed to link document`),h(!1)}}},documentCount:1,saving:m,sizeClassName:d,tabs:t?[`context`,`directory`,`relations`]:[`context`,`directory`],relationWorkspaceName:t,relationExcludeIds:new Set([e]),onConfirmRelation:async({predicate:a,direction:o,targetIds:l})=>{if(!(!t||!l.length)){h(!0);try{await s(t,e,a,l,o),r(`Related to ${l.length} document${l.length===1?``:`s`}`),c(),n()}catch(e){i(e instanceof Error?e.message:`Failed to create relation`),h(!1)}}}})})}export{h as n,g as r,m as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button-Bv4zA1qr.js";import{t as a}from"./input-BOtCd4HP.js";import{t as o}from"./api-CA6WiiYM.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{Et as c}from"./index-exXolIqD.js";import{n as l}from"./page-header-GtTr9Ff_.js";import{t as u}from"./use-settings-back-Dk-DJEUO.js";var d=e(n(),1),f=t();function p(){let e=r(),{showToast:t}=s(),n=new URLSearchParams(e.search),p=e=>{try{let t=new URL(e);return t.pathname.includes(`/rest/v2/workspaces/`)&&!t.pathname.includes(`/rest/v2/pub/`)?t.pathname=t.pathname.replace(`/rest/v2/workspaces/`,`/rest/v2/pub/workspaces/`):t.pathname.includes(`/rest/v2/contexts/`)&&!t.pathname.includes(`/rest/v2/pub/`)&&(t.pathname=t.pathname.replace(`/rest/v2/contexts/`,`/rest/v2/pub/contexts/`)),t.toString()}catch{return e}},m=p(n.get(`url`)||``),h=sessionStorage.getItem(`sharedToken:last`)||``,[g,_]=(0,d.useState)(m),[v,y]=(0,d.useState)(h),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)([]),[w,T]=(0,d.useState)(!1),E=(0,d.useMemo)(()=>{try{let e=new URL(g);return e.pathname.includes(`/pub/workspaces/`)?`workspace`:e.pathname.includes(`/pub/contexts/`)?`context`:`unknown`}catch{return`unknown`}},[g]),D=()=>({Authorization:`Bearer ${v.trim()}`}),O=async()=>{if(!(!g||!v)){T(!0);try{let e=p(g),t=await o.get(e,{skipAuth:!0,headers:D()});x(t);let n=await o.get(`${e}/documents`,{skipAuth:!0,headers:D()}),r=Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[];C(Array.isArray(r)?r:[])}catch(e){let n=g.includes(`/rest/v2/workspaces/`)?`Ensure the URL uses /rest/v2/pub/workspaces/<workspace-id> and the token matches that workspace.`:g.includes(`/rest/v2/contexts/`)?`Ensure the URL uses /rest/v2/pub/contexts/<context-id>.`:void 0;t({title:`Error`,description:`${e instanceof Error?e.message:`Failed to load shared resource`}${n?`: ${n}`:``}`,variant:`destructive`}),x(null),C([])}finally{T(!1)}}},k=(0,d.useRef)(O);return(0,d.useEffect)(()=>{k.current()},[]),(0,f.jsxs)(`div`,{className:`space-y-4`,children:[(0,f.jsx)(l,{onBack:u(),title:`Shared Resource Viewer`,description:`Open a resource someone shared with you.`}),(0,f.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,f.jsx)(a,{value:g,onChange:e=>_(e.target.value),placeholder:`Full pub URL`}),(0,f.jsx)(a,{value:v,onChange:e=>y(e.target.value),placeholder:`Access token (canvas-...)`}),(0,f.jsx)(i,{onClick:O,disabled:w||!g||!v,children:`Load`})]}),(0,f.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Type: `,E]}),w?(0,f.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`Loading...`}):(0,f.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,f.jsxs)(`div`,{className:`border rounded p-3`,children:[(0,f.jsx)(`h2`,{className:`font-semibold mb-2`,children:`Metadata`}),(0,f.jsx)(`pre`,{className:`text-xs overflow-auto max-h-80`,children:JSON.stringify(b,null,2)})]}),(0,f.jsxs)(`div`,{className:`border rounded p-3`,children:[(0,f.jsxs)(`h2`,{className:`font-semibold mb-2`,children:[`Documents (`,S.length,`)`]}),S.length===0?(0,f.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No documents`}):(0,f.jsx)(`ul`,{className:`space-y-2 text-sm`,children:S.slice(0,100).map((e,t)=>(0,f.jsxs)(`li`,{className:`border rounded p-2`,children:[(0,f.jsx)(`div`,{className:`font-mono text-xs`,children:e.id}),(0,f.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.schema})]},t))})]})]}),(0,f.jsx)(c,{className:`mt-8`})]})}export{p as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SketchEditor-zMrm1npg.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/react-BHzhHVTZ.js","assets/preload-helper-Czpn1I53.js","assets/ui-BSqPn1LJ.js","assets/utils-BxVxyehK.js","assets/button-Bv4zA1qr.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/workspace-CJ1PWQ29.js","assets/api-CA6WiiYM.js","assets/alert-dialog-DIA-tAP5.js","assets/useAddTarget-CVRPElxz.js","assets/use-toolbox-Ck_cLGgf.js","assets/context-D_K4g9SQ.js","assets/useToastHelpers-CRrpIIdY.js","assets/use-toast-BlLDqSUO.js","assets/blobs-WiXP9QRi.js","assets/sha256-65KIjGvZ.js","assets/chunk-K2UTITRG-BvHe9UPk.js","assets/chunk-SRAX5OIU-Dhm3gOdh.js","assets/chunk-6U3AYISY-C6-Mtja1.js","assets/chunk-Z3N5DIM6-D9TMVU7m.js","assets/EditorOverlay-BUToR_av.js","assets/SketchEditor-DtRVLazd.css"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{t as n}from"./preload-helper-Czpn1I53.js";var r=e(t(),1);window.EXCALIDRAW_ASSET_PATH=`/excalidraw/`;var i=(0,r.lazy)(()=>n(()=>import(`./SketchEditor-zMrm1npg.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])));export{i as t};
@@ -0,0 +1 @@
1
+ import{u as e}from"./api-CA6WiiYM.js";import{t}from"./socket-hM4c-ZSl.js";function n(){let e=localStorage.getItem(`authToken`);return!e||e===`canvas-server-token`?null:e}var r=new class{socket=null;connected=!1;authToken=null;handlers=new Map;socketWrappers=new Map;desiredSubscriptions=new Set;baseUrl;connectionId=``;constructor(){this.baseUrl=e,this.connectionId=`socket-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}connect(e){let r=e||n();!r||r===`canvas-server-token`||this.socket&&this.authToken===r||(this.cleanupSocket(),this.authToken=r,this.socket=t(this.baseUrl,{transports:[`websocket`],autoConnect:!1,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:3e4,randomizationFactor:.5,timeout:1e4,forceNew:!0,extraHeaders:{Authorization:`Bearer ${r}`,"X-Connection-ID":this.connectionId},auth:{token:r}}),this.setupDefaultHandlers(),this.registerHandlers(),this.socket.connect())}cleanupSocket(){this.socket?.removeAllListeners(),this.socket?.disconnect(),this.socket=null,this.connected=!1,this.socketWrappers.clear()}setupDefaultHandlers(){this.socket&&(this.socket.on(`connect`,()=>{this.connected=!0;for(let e of this.desiredSubscriptions)this.socket?.emit(`subscribe`,{channel:e})}),this.socket.on(`disconnect`,()=>{this.connected=!1}),this.socket.on(`connect_error`,()=>{this.connected=!1}))}registerHandlers(){this.socket&&this.handlers.forEach((e,t)=>{e.forEach(e=>{this.attach(t,e)})})}attach(e,t){if(!this.socket)return;let n=this.socketWrappers.get(e);if(n||(n=new Map,this.socketWrappers.set(e,n)),n.has(t))return;let r=(...e)=>t(...e);n.set(t,r),this.socket.on(e,r)}detach(e,t){if(!this.socket)return;let n=this.socketWrappers.get(e),r=n?.get(t);r&&(this.socket.off(e,r),n?.delete(t),n&&n.size===0&&this.socketWrappers.delete(e))}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);let n=this.handlers.get(e);return n.has(t)?()=>this.off(e,t):(n.add(t),this.socket&&this.attach(e,t),()=>this.off(e,t))}off(e,t){let n=this.handlers.get(e);n&&n.has(t)&&(n.delete(t),n.size===0&&this.handlers.delete(e),this.detach(e,t))}request(e,t,n=1e4){return new Promise((r,i)=>{if(!this.socket||!this.connected){i(Error(`Socket not connected`));return}let a=!1,o=setTimeout(()=>{a||(a=!0,i(Error(`Socket request timed out: ${e}`)))},n);try{this.socket.emit(e,t??{},t=>{a||(a=!0,clearTimeout(o),t?.status===`error`?i(Error(t.message||`${e} failed`)):r(t?.payload??t))})}catch(e){a=!0,clearTimeout(o),i(e instanceof Error?e:Error(String(e)))}})}emit(e,...t){if(e===`subscribe`){let e=t?.[0]?.channel;typeof e==`string`&&e&&this.desiredSubscriptions.add(e)}else if(e===`unsubscribe`){let e=t?.[0]?.channel;typeof e==`string`&&e&&this.desiredSubscriptions.delete(e)}if(this.socket&&this.connected)try{this.socket.emit(e,...t)}catch(t){console.error(`Error emitting event ${e}:`,t),this.reconnect()}else this.connect()}disconnect(){this.cleanupSocket(),this.authToken=null,this.desiredSubscriptions.clear()}isConnected(){return this.connected}retryNow(){this.connected||(this.cleanupSocket(),this.connect())}reconnect(){this.connect()}};export{r as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{vt as r}from"./react-BHzhHVTZ.js";import{Ot as i}from"./ui-BSqPn1LJ.js";import{t as a}from"./button-Bv4zA1qr.js";import{t as o}from"./input-BOtCd4HP.js";import{c as s,t as c}from"./api-CA6WiiYM.js";import{a as l,c as u,i as d,s as f,t as p}from"./alert-dialog-DIA-tAP5.js";var m=e(n(),1),h=r(),g=(e,t)=>`${s.workspaces}/${encodeURIComponent(e)}/trees/${encodeURIComponent(t)}/subtree`;function _(e,t,n,r){return c.post(`${g(e,t)}/export`,{path:n,dependencies:r})}function v(e,t,n,r,i){return c.post(`${g(e,t)}/import`,{parentPath:n,name:r,archive:i})}async function y(e,t,n,r){for(;;){let i=await c.get(`${g(e,t)}/jobs/${encodeURIComponent(n)}`,{cache:`no-store`});if(r(i),i.status===`failed`)throw Error(i.error?.message||`Subtree transfer failed`);if(i.status===`done`)return i;await new Promise(e=>setTimeout(e,750))}}var b=t();function x(e){let t=document.createElement(`div`);document.body.appendChild(t);let n=(0,h.createRoot)(t),r=()=>{n.unmount(),t.remove()};n.render((0,b.jsx)(S,{...e,onClose:r}))}function S({mode:e,workspaceId:t,treeName:n,path:r,onImported:s,onClose:c}){let[h,g]=(0,m.useState)(`related`),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(``),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),j=k?.status===`done`&&e===`import`?k.result:null,M=async e=>{if(e){E(!0),O(``),S(null),A(null);try{if(e.size>125829120)throw Error(`This export exceeds the 120 MB upload limit.`);let t=JSON.parse(await e.text());if(t.format!==`canvas-subtree`||t.version!==1||!Array.isArray(t.nodes)||!t.nodes[0]||!Array.isArray(t.documents))throw Error(`Choose a Canvas subtree export file.`);S(t),w(t.nodes[0].name===`/`?t.source.tree.name:t.nodes[0].name)}catch(e){O(e instanceof Error?e.message:`Could not read export`)}finally{E(!1)}}},N=async()=>{E(!0),O(``);try{let i=k?.status===`running`?k:e===`export`?await _(t,n,r,h):await v(t,n,r,C,x);A(i);let a=await y(t,n,i.id,A);e===`export`?S(a.result):s()}catch(t){O(t instanceof Error?t.message:`Subtree transfer failed`),e===`import`&&s()}finally{E(!1)}},P=()=>{if(!x)return;let e=URL.createObjectURL(new Blob([JSON.stringify(x)],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`${(x.nodes[0].name===`/`?x.source.tree.name:x.nodes[0].name).replace(/[^\p{L}\p{N}._-]/gu,`_`)}.canvas-subtree.json`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)},F=(0,m.useMemo)(()=>x?new Set(x.nodes.flatMap(e=>e.documentIds)).size:0,[x]);return(0,b.jsx)(p,{open:!0,onOpenChange:e=>{!e&&!T&&c()},children:(0,b.jsxs)(d,{children:[(0,b.jsxs)(f,{children:[(0,b.jsx)(u,{children:e===`export`?`Export subtree`:`Import subtree`}),(0,b.jsxs)(l,{children:[e===`export`?`${n}:${r}`:`Destination: ${n}:${r}`,`. Includes document records, folder structure, and relationships. Physical files are copied separately.`]})]}),e===`export`&&!x&&(0,b.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[`Include`,(0,b.jsxs)(`select`,{disabled:T||k?.status===`running`,value:h,onChange:e=>g(e.target.value),className:`rounded-md border bg-background p-2`,children:[(0,b.jsx)(`option`,{value:`related`,children:`Subtree + attachments and contacts`}),(0,b.jsx)(`option`,{value:`none`,children:`Subtree only`})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Supporting records keep their relationships. Their other folders, unrelated messages, and reply chains are excluded.`})]}),e===`import`&&!j&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(o,{type:`file`,accept:`.json,application/json`,disabled:T||k?.status===`running`,"aria-label":`Subtree export file`,onChange:e=>void M(e.target.files?.[0])}),x&&(0,b.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[`Folder name`,(0,b.jsx)(o,{value:C,disabled:T||k?.status===`running`,onChange:e=>w(e.target.value)})]}),x?.source.tree.type===`context`&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Existing context layers are reused by name. Documents are added to their shared membership; existing documents, layer settings, and saved views are kept.`})]}),x&&(0,b.jsxs)(`p`,{className:`text-sm`,children:[x.nodes.length,` folders, `,F,` subtree documents, and `,x.documents.length-F,` supporting records.`,x.summary?.externalRelations>0&&` ${x.summary.externalRelations} references point outside this export.`]}),!!x?.skippedDocuments?.length&&(0,b.jsxs)(`div`,{role:`status`,className:`space-y-2 rounded-md border p-3 text-sm`,children:[(0,b.jsxs)(`p`,{children:[x.skippedDocuments.length,` missing document`,x.skippedDocuments.length===1?` was`:`s were`,` skipped during export. Available records and folders are included.`]}),(0,b.jsx)(`ul`,{className:`max-h-32 overflow-y-auto text-xs`,children:x.skippedDocuments.map(n=>(0,b.jsxs)(`li`,{children:[e===`export`?(0,b.jsxs)(`a`,{className:`underline`,target:`_blank`,rel:`noopener noreferrer`,href:`/workspaces/${encodeURIComponent(t)}/documents/by-id/${n.id}`,children:[`Document `,n.id]}):`Source document ${n.id}`,`: `,n.reason===`not-found`?`record not found`:n.reason]},n.id))})]}),T&&(0,b.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(i,{className:`h-4 w-4 animate-spin`}),(0,b.jsx)(`span`,{children:k?`${k.phase.charAt(0).toUpperCase()}${k.phase.slice(1)}${k.total?`: ${k.received} / ${k.total}`:`…`}`:`Starting…`})]}),j&&(0,b.jsxs)(`div`,{role:`status`,className:`space-y-2 text-sm`,children:[(0,b.jsxs)(`p`,{children:[`Imported `,j.documents,` documents into `,j.path,`. Reused `,j.reused,` matching records.`]}),!!j.reusedLayers&&(0,b.jsxs)(`p`,{children:[`Merged into `,j.reusedLayers,` existing layers, keeping their settings and documents.`]}),(0,b.jsx)(`p`,{children:`Copy the files into the destination backend and run its sync. Matching checksums reconnect the imported file records.`}),j.unresolvedRelations>0&&(0,b.jsxs)(`p`,{children:[j.unresolvedRelations,` external references were kept as migration metadata because their target records are not present.`]})]}),D&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:D}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(a,{variant:`outline`,disabled:T,onClick:c,children:`Close`}),e===`export`&&x?(0,b.jsx)(a,{onClick:P,children:`Download export`}):!j&&(0,b.jsx)(a,{disabled:T||e===`import`&&(!x||!C.trim()||C.includes(`/`)),onClick:()=>void N(),children:D?`Retry`:e===`export`?`Create export`:`Import subtree`})]})]})})}export{x as showSubtreeTransfer};
@@ -0,0 +1 @@
1
+ function e(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(`tag/${e}`)}return Array.from(t)}function t(e){return(e||[]).filter(e=>e.startsWith(`tag/`)).map(e=>e.slice(4))}export{e as n,t};
@@ -0,0 +1,2 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{In as n,Kn as r,nt as i,wn as a}from"./workspace-CJ1PWQ29.js";import{r as o}from"./public-share-DT9Tgn_Y.js";import{i as s,o as c}from"./blobs-WiXP9QRi.js";var l=e(t(),1),u=e=>({blobUrl:null,blob:null,text:null,mime:null,error:null,loading:e});function d(e,t,{url:n,mode:r=`blob`,enabled:i=!0,maxTextLength:a=2e5,typeHint:s,version:c=null}={}){let{isPublic:d,fetchBlob:f}=o(e),p=`${d?`pub`:`ws`}:${e}:${t}:${n??``}:${r}:${i}:${s??``}:${c??``}`,[m,h]=(0,l.useState)(u(i)),[g,_]=(0,l.useState)(p);return p!==g&&(_(p),h(u(i))),(0,l.useEffect)(()=>{if(!i)return;let e=!1,o=null;return f(t,{...n?{url:n}:{},...c?{version:c}:{}}).then(async({blob:t,mime:n})=>{if(!e){if(r===`text`){let r=await t.text();e||h({blobUrl:null,blob:null,text:r.slice(0,a),mime:n,error:null,loading:!1})}else{let r=s&&(!t.type||t.type===`application/octet-stream`),i=r?t.slice(0,t.size,s):t;if(o=URL.createObjectURL(i),e){URL.revokeObjectURL(o),o=null;return}h({blobUrl:o,blob:i,text:null,mime:r?s:n,error:null,loading:!1})}}}).catch(t=>{e||h({blobUrl:null,blob:null,text:null,mime:null,error:String(t instanceof Error?t.message:t),loading:!1})}),()=>{e=!0,o&&URL.revokeObjectURL(o)}},[p]),m}function f(e,t,{url:n,enabled:r=!0}={}){let{isPublic:i,streamUrl:a,mintTicket:s}=o(e),c=`${i?`pub`:`ws`}:${e}:${t}:${n||``}:${r}`,[u,d]=(0,l.useState)({src:null,error:null,loading:!0}),[f,p]=(0,l.useState)(c);return c!==f&&(p(c),d({src:null,error:null,loading:!0})),(0,l.useEffect)(()=>{if(!r)return;let e=!1;return s(t).then(r=>{e||d(r?{src:a(t,{url:n}),error:null,loading:!1}:{src:null,error:`Could not authorize stream`,loading:!1})}).catch(t=>{e||d({src:null,error:t instanceof Error?t.message:String(t),loading:!1})}),()=>{e=!0}},[c]),u}var p=1e6;function m(e){if(e.schema===`data/schema/note`)return`markdown`;if(e.schema!==`data/schema/file`)return null;let t=r(String(e.metadata?.contentType??``),n(e));return t===`markdown`?`markdown`:t===`text`?`text`:null}function h(e){return e.schema===`data/schema/file`&&m(e)!=null}function g(e){let t=Number(e.metadata?.size??0);return Number.isFinite(t)&&t>1e6}var _=`workspace:data`;function v(e){for(let t of e.locations||[]){let e=/^stored:\/\/([^/]+)\/(.+)$/.exec(String(t?.url||``));if(!(!e||e[1]===_))return{backend:e[1],key:e[2]}}return null}async function y(e,t,r,o={}){let l=n(t)||`document-${t.id}.txt`,u=String(t.metadata?.contentType??``)||(m(t)===`markdown`?`text/markdown`:`text/plain`),d=r.endsWith(`
2
+ `)?r:`${r}\n`,f=new Blob([d],{type:u}),p=v(t);if(p){let n=String(t.checksumArray?.[0]??``).replace(/^sha256\//,``),r=await c(e,{driver:`file`,address:p.backend,key:p.key},f,{ifMatch:n||void 0,contentType:u});return(o.comment!==void 0&&o.comment!==(t.comment??``)||o.metadata!==void 0)&&await a(e,{id:r.docId??t.id,schema:t.schema,schemaVersion:t.schemaVersion,...o.comment===void 0?{}:{comment:o.comment},...o.metadata===void 0?{}:{metadata:o.metadata}}),i(e,r.docId??t.id)}let h=await s(e,f);return await a(e,{id:t.id,schema:t.schema,schemaVersion:t.schemaVersion,...o.comment===void 0?{}:{comment:o.comment},checksumArray:[`sha256/${h.checksum}`],locations:[{url:h.url,metadata:{filename:l}}],metadata:{contentType:u,size:h.size,...o.metadata??{}}}),i(e,t.id)}export{g as a,h as i,p as n,d as o,m as r,f as s,y as t};