orc-ai 0.1.52 → 0.1.53
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.
- package/dist/index.js +477 -477
- package/dist/web/assets/{Agents-DLu7phP7.js → Agents-D71JHI2H.js} +2 -2
- package/dist/web/assets/Attention-C_LKxdwf.js +2 -0
- package/dist/web/assets/{Audit-nUBNwvkU.js → Audit-BWh52YwS.js} +1 -1
- package/dist/web/assets/{ConfirmDialog-BGZ6sd6E.js → ConfirmDialog-D25Wf6Nc.js} +1 -1
- package/dist/web/assets/{Dashboard-Bhsm-LF4.js → Dashboard-DmYJjKna.js} +1 -1
- package/dist/web/assets/{DocumentWorkspace-C1HAVy0v.js → DocumentWorkspace-CW6S2i4-.js} +1 -1
- package/dist/web/assets/{ErrorState-B0KI2D4y.js → ErrorState-BoQqdsym.js} +1 -1
- package/dist/web/assets/FileEditor-_z3t0Dbd.js +1 -0
- package/dist/web/assets/JobWebhooks-Z4MXZNvH.js +1 -0
- package/dist/web/assets/Jobs-B-7i16mV.js +1 -0
- package/dist/web/assets/Knowledge-DX3nwzng.js +1 -0
- package/dist/web/assets/Markdown-BYChkZ3Z.js +2 -0
- package/dist/web/assets/{MarkdownEditor-BM9COcIb.js → MarkdownEditor-BMQq1cAY.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-C3UcCxdl.js → MarkdownRenderer-B5esWp7J.js} +96 -96
- package/dist/web/assets/PackageCatalog-CYF3tX8J.js +8 -0
- package/dist/web/assets/{PackageRunDialog-D3kvHk8o.js → PackageRunDialog-DxUs3Qnc.js} +2 -2
- package/dist/web/assets/{Pager-CMsNCI1_.js → Pager-DQCWHQWA.js} +1 -1
- package/dist/web/assets/PriorityBadge-ADp-pD5B.js +1 -0
- package/dist/web/assets/{Projects-BmfdCEv3.js → Projects-C2Ei5Q8Q.js} +2 -2
- package/dist/web/assets/QueryClientProvider-DlPztvhd.js +1 -0
- package/dist/web/assets/{RemoteFolderBrowser-ClOOMU0_.js → RemoteFolderBrowser-Btryj6gG.js} +1 -1
- package/dist/web/assets/{ResumeActions-gVze1Xjw.js → ResumeActions-1gJa3nsX.js} +1 -1
- package/dist/web/assets/{Rules-BMqF79Mt.js → Rules-CZvA-Eis.js} +4 -4
- package/dist/web/assets/ScratchpadDiagramEditor-D44NiVP_.js +159 -0
- package/dist/web/assets/Scratchpads-DP_v2hc8.js +10 -0
- package/dist/web/assets/Sessions-Ctd49sC9.js +3 -0
- package/dist/web/assets/{Settings-Dh7H43-p.js → Settings-BmbdT6Mp.js} +5 -5
- package/dist/web/assets/Skills-C_bBvy92.js +8 -0
- package/dist/web/assets/{SourceEditor-DlC3qNcT.js → SourceEditor-B5CtJBt0.js} +1 -1
- package/dist/web/assets/StatusBadge-CTFDUHuw.js +1 -0
- package/dist/web/assets/TagInput-T6rDuQ7O.js +1 -0
- package/dist/web/assets/TaskDetailSheet-BiIQ82AG.js +1 -0
- package/dist/web/assets/Tasks-OQmOaNqh.js +24 -0
- package/dist/web/assets/Terminals-DVu5OtGU.js +3 -0
- package/dist/web/assets/{ViewHeader-CX02p2eb.js → ViewHeader-DHM9SSkD.js} +1 -1
- package/dist/web/assets/{Webhooks-DUB9var7.js → Webhooks-CDNv5fUD.js} +1 -1
- package/dist/web/assets/{ar-SA-G6X2FPQ2-Br_n6QDe.js → ar-SA-G6X2FPQ2-9uLW-Aib.js} +1 -1
- package/dist/web/assets/{az-AZ-76LH7QW2-QyHk3dvA.js → az-AZ-76LH7QW2-DOqqo97y.js} +1 -1
- package/dist/web/assets/{bg-BG-XCXSNQG7-C6nlcNp_.js → bg-BG-XCXSNQG7-BHUaosi9.js} +1 -1
- package/dist/web/assets/{bn-BD-2XOGV67Q-4ptCYf5W.js → bn-BD-2XOGV67Q-_-LDSkWx.js} +1 -1
- package/dist/web/assets/button-BHKbOsmj.js +1 -0
- package/dist/web/assets/{ca-ES-6MX7JW3Y-Cgoa8y8g.js → ca-ES-6MX7JW3Y-D00wQc68.js} +1 -1
- package/dist/web/assets/{chunk-EIO257PC-D5rz2EHY.js → chunk-EIO257PC-BfeJ3EDs.js} +1 -1
- package/dist/web/assets/{client-BEiLQQ-F.js → client-BwhkVepQ.js} +1 -1
- package/dist/web/assets/{cs-CZ-2BRQDIVT-TiBX7ffm.js → cs-CZ-2BRQDIVT-EB-m3ztC.js} +1 -1
- package/dist/web/assets/{da-DK-5WZEPLOC-qeFhKopb.js → da-DK-5WZEPLOC-DWYR6cGM.js} +1 -1
- package/dist/web/assets/{de-DE-XR44H4JA-m_mVoRik.js → de-DE-XR44H4JA-Ck6sMUnJ.js} +1 -1
- package/dist/web/assets/{dist-EENe35AZ.js → dist-B9K53eWS.js} +1 -1
- package/dist/web/assets/{dist-BqZPrSfD.js → dist-ClOxCp9t.js} +1 -1
- package/dist/web/assets/{dist-C5yPNRzG.js → dist-D3PXSw6Q.js} +1 -1
- package/dist/web/assets/{dist-DcKneJwp.js → dist-HH469UWY.js} +1 -1
- package/dist/web/assets/{el-GR-BZB4AONW-BkZEWwVO.js → el-GR-BZB4AONW-DTkIqoGp.js} +1 -1
- package/dist/web/assets/{en-B4ZKOASM-DZ61I4Io.js → en-B4ZKOASM-Boq12EIA.js} +1 -1
- package/dist/web/assets/{es-ES-U4NZUMDT-N6PHqPGp.js → es-ES-U4NZUMDT-DY7ipP7c.js} +1 -1
- package/dist/web/assets/{eu-ES-A7QVB2H4-B0v57KpC.js → eu-ES-A7QVB2H4-D4Y6LEUc.js} +1 -1
- package/dist/web/assets/{fa-IR-HGAKTJCU-DRM3hyQI.js → fa-IR-HGAKTJCU-BlO1bnpc.js} +1 -1
- package/dist/web/assets/{fi-FI-Z5N7JZ37-BBhjlkHm.js → fi-FI-Z5N7JZ37-CQlPsyFJ.js} +1 -1
- package/dist/web/assets/{fr-FR-RHASNOE6-C6Ekm99g.js → fr-FR-RHASNOE6-DsyF_chP.js} +1 -1
- package/dist/web/assets/{gl-ES-HMX3MZ6V-BVrGslVP.js → gl-ES-HMX3MZ6V-BGAJPW2y.js} +1 -1
- package/dist/web/assets/{he-IL-6SHJWFNN-GiN2vY9l.js → he-IL-6SHJWFNN-BCFUF5Bi.js} +1 -1
- package/dist/web/assets/{hi-IN-IWLTKZ5I-tPRQ0szT.js → hi-IN-IWLTKZ5I-CWKeCfbn.js} +1 -1
- package/dist/web/assets/{highlighted-body-JLMTFACH-R4J_nfqS.js → highlighted-body-JLMTFACH-CYOy6uZ1.js} +1 -1
- package/dist/web/assets/{hu-HU-A5ZG7DT2-CkV1DDWQ.js → hu-HU-A5ZG7DT2-fqogn_m9.js} +1 -1
- package/dist/web/assets/{id-ID-SAP4L64H-DpzooQVd.js → id-ID-SAP4L64H-XFT4nLO5.js} +1 -1
- package/dist/web/assets/{image-GAAHSSAO-D7XRYD-a.js → image-GAAHSSAO-CtqEtsMw.js} +1 -1
- package/dist/web/assets/index-BCGI8JzG.css +1 -0
- package/dist/web/assets/{index-Ck-SDgTR.js → index-CMRGRbC9.js} +27 -28
- package/dist/web/assets/{it-IT-JPQ66NNP-C6oBozob.js → it-IT-JPQ66NNP-CjvUp5j1.js} +1 -1
- package/dist/web/assets/{ja-JP-DBVTYXUO-BG7OaLPP.js → ja-JP-DBVTYXUO-WaxwOOp1.js} +1 -1
- package/dist/web/assets/{kaa-6HZHGXH3-oYKKAQ51.js → kaa-6HZHGXH3-BABl6rMV.js} +1 -1
- package/dist/web/assets/{kab-KAB-ZGHBKWFO-B7LjxWHx.js → kab-KAB-ZGHBKWFO-vrrKDhKa.js} +1 -1
- package/dist/web/assets/{kk-KZ-P5N5QNE5-BjKAAAQx.js → kk-KZ-P5N5QNE5-DV0HT-Fa.js} +1 -1
- package/dist/web/assets/{km-KH-HSX4SM5Z-CP5JVtE5.js → km-KH-HSX4SM5Z-CMzRvYB5.js} +1 -1
- package/dist/web/assets/{ko-KR-MTYHY66A-skmsixpS.js → ko-KR-MTYHY66A-7XqecPXy.js} +1 -1
- package/dist/web/assets/{ku-TR-6OUDTVRD-BQGbWbVU.js → ku-TR-6OUDTVRD-D8O0bwyA.js} +1 -1
- package/dist/web/assets/label-BQ1Lr4sA.js +1 -0
- package/dist/web/assets/{lt-LT-XHIRWOB4-jPcUmdv0.js → lt-LT-XHIRWOB4-DrK90jMT.js} +1 -1
- package/dist/web/assets/{lv-LV-5QDEKY6T-BJimFBjM.js → lv-LV-5QDEKY6T-D7Xl2RRC.js} +1 -1
- package/dist/web/assets/mermaid-WFAXDIZX-CiFtUZlz.js +1 -0
- package/dist/web/assets/{mr-IN-CRQNXWMA-BJCZe-ef.js → mr-IN-CRQNXWMA-CjH1Q3x7.js} +1 -1
- package/dist/web/assets/{my-MM-5M5IBNSE-CzqI7mKR.js → my-MM-5M5IBNSE-CvdwmXcF.js} +1 -1
- package/dist/web/assets/{nb-NO-T6EIAALU-DOipNzcK.js → nb-NO-T6EIAALU-BWMKi1Br.js} +1 -1
- package/dist/web/assets/{nl-NL-IS3SIHDZ-m_uDUlnM.js → nl-NL-IS3SIHDZ-D5A6sC_f.js} +1 -1
- package/dist/web/assets/{nn-NO-6E72VCQL-ChLlN8eQ.js → nn-NO-6E72VCQL-D-p6QrsB.js} +1 -1
- package/dist/web/assets/{oc-FR-POXYY2M6-BJLoLhGq.js → oc-FR-POXYY2M6-6fyqLMv5.js} +1 -1
- package/dist/web/assets/{pa-IN-N4M65BXN-uYfxnmgm.js → pa-IN-N4M65BXN-D99Vs_Tb.js} +1 -1
- package/dist/web/assets/{percentages-BXMCSKIN--kwJevql.js → percentages-BXMCSKIN-B0BZzQvB.js} +1 -1
- package/dist/web/assets/{pl-PL-T2D74RX3-CDCLDsvJ.js → pl-PL-T2D74RX3-cl5WZaGT.js} +1 -1
- package/dist/web/assets/{pt-BR-5N22H2LF-CIrdrTZX.js → pt-BR-5N22H2LF-T6l12jm6.js} +1 -1
- package/dist/web/assets/{pt-PT-UZXXM6DQ-4Aps73mI.js → pt-PT-UZXXM6DQ-DnxUMvhO.js} +1 -1
- package/dist/web/assets/{ro-RO-JPDTUUEW-fgJWBuSP.js → ro-RO-JPDTUUEW-w6wCZHtR.js} +1 -1
- package/dist/web/assets/{ru-RU-B4JR7IUQ-D98t4_hW.js → ru-RU-B4JR7IUQ-DMaA4CQ-.js} +1 -1
- package/dist/web/assets/scratchpad-routes-B75DnNPp.js +1 -0
- package/dist/web/assets/scroll-area-DMjOmHf5.js +1 -0
- package/dist/web/assets/select-CBHDS40x.js +1 -0
- package/dist/web/assets/{si-LK-N5RQ5JYF-DNwP7Qip.js → si-LK-N5RQ5JYF-Coe9-5Yb.js} +1 -1
- package/dist/web/assets/{sk-SK-C5VTKIMK-BfncC8rh.js → sk-SK-C5VTKIMK-Bq23BXvP.js} +1 -1
- package/dist/web/assets/{sl-SI-NN7IZMDC-IXH265Xx.js → sl-SI-NN7IZMDC-WZEKy1qu.js} +1 -1
- package/dist/web/assets/subset-shared.chunk-CAD0Eg6H.js +1 -0
- package/dist/web/assets/{subset-worker.chunk-BNdMWEQD.js → subset-worker.chunk-CAbfOFrS.js} +1 -1
- package/dist/web/assets/{sv-SE-XGPEYMSR-CWjE7XZA.js → sv-SE-XGPEYMSR-p1gc_GrE.js} +1 -1
- package/dist/web/assets/{ta-IN-2NMHFXQM-mzDgApaO.js → ta-IN-2NMHFXQM-o8J0vNj1.js} +1 -1
- package/dist/web/assets/table-ByS-sgsb.js +1 -0
- package/dist/web/assets/tabs-DltQVo38.js +1 -0
- package/dist/web/assets/{th-TH-HPSO5L25-sCRbUk4w.js → th-TH-HPSO5L25-pt7Zt9xm.js} +1 -1
- package/dist/web/assets/{tr-TR-DEFEU3FU-BJVVhuUn.js → tr-TR-DEFEU3FU-BENdvVvp.js} +1 -1
- package/dist/web/assets/{uk-UA-QMV73CPH-CoaqtD6Z.js → uk-UA-QMV73CPH-CenI2hX1.js} +1 -1
- package/dist/web/assets/useDetailRoute-C8xQeILG.js +1 -0
- package/dist/web/assets/useJobs-CCQUWZt3.js +1 -0
- package/dist/web/assets/useKnowledge-DbjT1a0E.js +1 -0
- package/dist/web/assets/{useListSelection-DcULI867.js → useListSelection-CgpNqqAb.js} +1 -1
- package/dist/web/assets/useMemories-D0tEN20z.js +1 -0
- package/dist/web/assets/useMutation-HX90wI4L.js +1 -0
- package/dist/web/assets/useProjectScope-CZEfU9mq.js +1 -0
- package/dist/web/assets/useSessions-C2GU4FkG.js +1 -0
- package/dist/web/assets/{vi-VN-M7AON7JQ-C_1RRSxn.js → vi-VN-M7AON7JQ-REgvRLzg.js} +1 -1
- package/dist/web/assets/{view-params-DNioxw0G.js → view-params-BqRwdnv0.js} +1 -1
- package/dist/web/assets/{x-CtXhMM9g.js → x-BKorzD7S.js} +1 -1
- package/dist/web/assets/{zh-CN-LNUGB5OW-BRsIz_fP.js → zh-CN-LNUGB5OW-Ceo4z5r5.js} +1 -1
- package/dist/web/assets/{zh-HK-E62DVLB3-DwjC6Cwv.js → zh-HK-E62DVLB3-CFQOn9E1.js} +1 -1
- package/dist/web/assets/{zh-TW-RAJ6MFWO-DrD43hHv.js → zh-TW-RAJ6MFWO-GpxYPogk.js} +1 -1
- package/dist/web/index.html +16 -16
- package/package.json +1 -1
- package/dist/web/assets/Attention-D80Q2fL4.js +0 -2
- package/dist/web/assets/FileEditor-B1pLaZil.js +0 -1
- package/dist/web/assets/JobWebhooks-DIfKugwY.js +0 -1
- package/dist/web/assets/Jobs-0VP8O03Z.js +0 -1
- package/dist/web/assets/Knowledge-DCsSHLqC.js +0 -1
- package/dist/web/assets/Markdown-CenDHcGi.js +0 -2
- package/dist/web/assets/PackageCatalog-oQ9U4WEt.js +0 -8
- package/dist/web/assets/PriorityBadge-_KMVnMst.js +0 -1
- package/dist/web/assets/ScratchpadDiagramEditor-BtuYQvFc.js +0 -159
- package/dist/web/assets/Scratchpads-D98SMUv3.js +0 -10
- package/dist/web/assets/Sessions-CLDdpR36.js +0 -3
- package/dist/web/assets/Skills-B5OEYsYx.js +0 -8
- package/dist/web/assets/StatusBadge-CZQsVLgL.js +0 -1
- package/dist/web/assets/TagInput-D7ZsM-Dr.js +0 -1
- package/dist/web/assets/TaskDetailSheet-0hZx_-me.js +0 -1
- package/dist/web/assets/Tasks-c1HlLJhH.js +0 -24
- package/dist/web/assets/Terminals-DQ8HWVlI.js +0 -3
- package/dist/web/assets/button-PNx108iL.js +0 -1
- package/dist/web/assets/index-Bpb-AzH6.css +0 -1
- package/dist/web/assets/label-Ce3QFsX5.js +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-DmWpYePv.js +0 -1
- package/dist/web/assets/pencil-BPI6pWhy.js +0 -1
- package/dist/web/assets/scratchpad-routes-BwYHUs6J.js +0 -1
- package/dist/web/assets/scroll-area-Alw_ieLV.js +0 -1
- package/dist/web/assets/select-Cg0xEvji.js +0 -1
- package/dist/web/assets/subset-shared.chunk-BJl1UMhd.js +0 -1
- package/dist/web/assets/table-DC8IBMHg.js +0 -1
- package/dist/web/assets/tabs-DWq5oObc.js +0 -1
- package/dist/web/assets/trash-D7o9t0-a.js +0 -1
- package/dist/web/assets/useDetailRoute-1i4Z0-d5.js +0 -1
- package/dist/web/assets/useJobs-B2MCCWKa.js +0 -1
- package/dist/web/assets/useKnowledge-oAVI1FoA.js +0 -1
- package/dist/web/assets/useMemories-CcDhzt2Y.js +0 -1
- package/dist/web/assets/useMutation-DDLZlpLS.js +0 -1
- package/dist/web/assets/useProjectScope-C7yZQa4i.js +0 -1
- package/dist/web/assets/useSessions-Bx-Bw75y.js +0 -1
- package/dist/web/assets/utils-Q1DAuYRG.js +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ScratchpadDiagramEditor-D44NiVP_.js","assets/rolldown-runtime-DSDNlrLa.js","assets/jsx-runtime-CVMpzJz9.js","assets/react-dom-DTbwZiiP.js","assets/button-BHKbOsmj.js","assets/bundle-mjs-CdK3cBzO.js","assets/es2015-w69PgVrA.js","assets/check-hFtKhUSV.js","assets/createLucideIcon-jLuHkL03.js","assets/copy-d40YbOUX.js","assets/preload-helper-BLdHbfdN.js","assets/index-CMRGRbC9.js","assets/QueryClientProvider-DlPztvhd.js","assets/useMutation-HX90wI4L.js","assets/dist-ClOxCp9t.js","assets/dist-HH469UWY.js","assets/x-BKorzD7S.js","assets/dist-B9K53eWS.js","assets/select-CBHDS40x.js","assets/dist-D3PXSw6Q.js","assets/dist-Ct6061MC.js","assets/dist-D8Wfxh48.js","assets/chevron-down-D2sszSv3.js","assets/label-BQ1Lr4sA.js","assets/MarkdownEditor-BMQq1cAY.js","assets/Markdown-BYChkZ3Z.js","assets/document-display-BQ5dM8QT.js","assets/file-kind-BYU1kv95.js","assets/client-BwhkVepQ.js","assets/bulk-actions-C8S1Gt4W.js","assets/index-BCGI8JzG.css","assets/save-file-3ZpJah8W.js","assets/ScratchpadDiagramEditor-DtRVLazd.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,n as t}from"./rolldown-runtime-DSDNlrLa.js";import{n,t as r}from"./jsx-runtime-CVMpzJz9.js";import{i,t as a}from"./button-BHKbOsmj.js";import{t as o}from"./check-hFtKhUSV.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-CBHDS40x.js";import{t as f}from"./label-BQ1Lr4sA.js";import{t as p}from"./createLucideIcon-jLuHkL03.js";import{t as m}from"./arrow-left-Czr-LF4l.js";import{a as h,c as g,i as _,l as v,n as y,o as b,r as x,s as S,t as C,u as w}from"./scratchpad-routes-B75DnNPp.js";import{t as T}from"./download-WG9NKrMe.js";import{t as E}from"./link-2-DSYfKX_9.js";import{i as D,n as O,r as k}from"./MarkdownEditor-BMQq1cAY.js";import{t as A}from"./preload-helper-BLdHbfdN.js";import{a as j,n as ee,r as te}from"./client-BwhkVepQ.js";import{At as ne,Dn as re,Et as ie,Gt as ae,Jt as M,Kt as N,On as oe,Ot as se,Tn as ce,Tt as le,U as P,Vt as F,Wt as ue,Yt as I,Zt as L,_t as R,en as de,in as fe,kn as pe,kt as me,on as he,qt as z,rn as ge,wt as _e,zt as ve}from"./index-CMRGRbC9.js";import{t as ye}from"./save-file-3ZpJah8W.js";import{t as be}from"./ConfirmDialog-D25Wf6Nc.js";import{t as xe}from"./ErrorState-BoQqdsym.js";import{t as Se}from"./ViewHeader-DHM9SSkD.js";import{t as B}from"./view-params-BqRwdnv0.js";import{a as Ce}from"./live-sessions-D07BClP7.js";import{t as we}from"./EmptyState-YM4VSLR9.js";import{n as Te}from"./useSessions-C2GU4FkG.js";import{a as Ee,i as V,n as De,o as Oe,r as H,t as ke}from"./table-ByS-sgsb.js";import{t as Ae}from"./DocumentWorkspace-CW6S2i4-.js";import{t as je}from"./TagInput-T6rDuQ7O.js";var Me={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Me.node;var Ne=p(Me),Pe={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};Pe.node;var Fe=p(Pe),U=[`doc`,`diagram`,`html`],Ie=ve(U),Le={doc:{extension:`.md`,mime:`text/markdown; charset=utf-8`},diagram:{extension:`.excalidraw`,mime:`application/json; charset=utf-8`},html:{extension:`.html`,mime:`text/html; charset=utf-8`}};ae({type:ue(`excalidraw`),elements:F(M(I(),L())),appState:M(I(),L()).optional(),files:M(I(),L()).optional()});function W(e,t){return`${e.normalize(`NFKD`).replace(/[^\w\s.-]/g,``).trim().replace(/\s+/g,`-`).toLowerCase().slice(0,80)||`scratchpad`}${Le[t].extension}`}var Re=I().trim().min(1).max(200),ze=F(I().min(1).max(64)).max(20),Be=I().min(1).max(200);z({id:I(),kind:Ie,title:I(),content:I(),project_id:I().nullable(),session_id:I().nullable(),tags:F(I()),author:I(),revision:N().int(),created_at:N().int(),updated_at:N().int()}).omit({content:!0}).extend({size_bytes:N().int()}),z({kind:Ie,title:Re,content:I().optional(),project_id:I().min(1).nullable().optional(),session_id:Be.nullable().optional(),tags:ze.optional(),author:I().min(1).max(200).optional()}).strict(),z({title:Re.optional(),content:I().optional(),project_id:I().min(1).nullable().optional(),session_id:Be.nullable().optional(),tags:ze.optional(),author:I().min(1).max(200).optional(),if_revision:N().int().min(1).optional()}).strict(),z({download_url:I().url().optional(),upload_url:I().url().optional(),filename:I(),revision:N().int(),expires_at:I().datetime()});var G=e(n(),1),K=r();function Ve({draft:e,children:t}){let n=e.saving?`Saving…`:e.dirty?`Unsaved changes`:`Saved`;return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1.5`,children:t}),(0,K.jsx)(`span`,{"data-testid":`scratchpad-save-status`,role:`status`,className:`text-xs text-outline`,children:n}),(e.dirty||e.saving)&&(0,K.jsxs)(K.Fragment,{children:[e.stale&&(0,K.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`scratchpad-overwrite`,disabled:e.saving,onClick:e.overwrite,children:`Keep mine`}),(0,K.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`scratchpad-discard`,disabled:e.saving,onClick:e.discard,children:`Discard`}),(0,K.jsx)(a,{type:`button`,size:`sm`,"data-testid":`scratchpad-save`,disabled:e.saving,onClick:()=>void e.save(),children:`Save`})]})]}),e.error&&(0,K.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error,` Your draft has been kept.`,e.stale&&` Discard loads their version; Keep mine lets you save over it.`]}),e.stale&&!e.error&&(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`This scratchpad changed elsewhere. Your draft is preserved: Discard loads their version; Keep mine lets you save over it.`})]})}function He({active:e,onClick:t,children:n,testId:r}){return(0,K.jsx)(`button`,{type:`button`,"data-testid":r,"aria-pressed":e,onClick:t,className:`inline-flex min-h-9 items-center gap-1.5 font-label text-sm px-3 py-1.5 border transition-colors ${e?`bg-surface-highest text-on-surface border-transparent`:`bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:n})}function Ue(e){let t=S(),[n,r]=(0,G.useState)(e.content),[i,a]=(0,G.useState)({content:e.content,revision:e.revision}),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(e.content),d=n!==i.content;(0,G.useEffect)(()=>{e.revision<=i.revision||(e.content===i.content?a({content:e.content,revision:e.revision}):u.current===i.content&&(u.current=e.content,r(e.content),a({content:e.content,revision:e.revision})))},[e.content,e.revision,i]),(0,G.useEffect)(()=>{if(!d)return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[d]);let f=(0,G.useCallback)(e=>{u.current=e,r(e)},[]);async function p(){if(!d||o)return;s(!0),l(null);let n=u.current;try{let t=await ee.scratchpads.update(e.id,{content:n,if_revision:i.revision});a({content:t.content,revision:t.revision})}catch(e){l(e instanceof Error?e.message:`Could not save scratchpad`)}finally{s(!1),await t()}}function m(){a({content:e.content,revision:e.revision}),l(null)}function h(){u.current=e.content,r(e.content),a({content:e.content,revision:e.revision}),l(null)}return{draft:n,setDraft:f,dirty:d,stale:d&&e.revision!==i.revision,saving:o,error:c,save:p,overwrite:m,discard:h}}function We(e,t,n){if(!/^\/(?![/\\])/.test(e))return!1;let r=new URL(t,n),i=new URL(`${t}${e}`,n),a=r.pathname.replace(/\/$/,``);return i.origin===r.origin&&i.pathname.startsWith(`${a}/`)}var Ge=[`preview`,`code`,`split`],Ke={preview:`Preview`,code:`Code`,split:`Split`},qe=400,Je=`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals`,Ye=`orc:fetch`,q=`orc:fetch:result`,Xe=e=>`<script>(()=>{const pending=new Map();let next=0;
|
|
3
|
+
addEventListener("message",(e)=>{const d=e.data;if(e.source!==parent||!d||d.type!=="${q}")return;
|
|
4
|
+
const p=pending.get(d.id);if(!p)return;pending.delete(d.id);
|
|
5
|
+
if(d.error)p.reject(new Error(d.error));
|
|
6
|
+
else p.resolve(new Response(d.body,{status:d.status,statusText:d.statusText,headers:d.headers}));});
|
|
7
|
+
window.orc=Object.freeze({fetch:(path,init={})=>new Promise((resolve,reject)=>{const id=++next;
|
|
8
|
+
pending.set(id,{resolve,reject});
|
|
9
|
+
parent.postMessage({type:"${Ye}",nonce:"${e}",id,path:String(path),method:init.method,
|
|
10
|
+
headers:[...new Headers(init.headers)],body:init.body},"*");})});})();<\/script>`,Ze=()=>Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);function Qe(e,t){let n=Xe(t),r=/^\s*<!doctype[^>]*>/i.exec(e);return r?`${r[0]}${n}${e.slice(r[0].length)}`:`${n}${e}`}function $e(e,t){let n=e;return n?.type===Ye&&n.nonce===t&&typeof n.id==`number`&&typeof n.path==`string`&&Array.isArray(n.headers)}async function et(e,t){try{if(!We(t.path,j(),window.location.href))throw Error(`orc.fetch path must be an ORC API path: ${t.path}`);let n=await te(t.path,{method:t.method,headers:t.headers,body:t.body??null}),r=await n.arrayBuffer();e.postMessage({type:q,id:t.id,status:n.status,statusText:n.statusText,headers:[...n.headers],body:r.byteLength?r:null},`*`,r.byteLength?[r]:[])}catch(n){e.postMessage({type:q,id:t.id,error:n instanceof Error?n.message:`Request failed`},`*`)}}function tt({html:e,title:t,trusted:n=!1}){let r=(0,G.useRef)(null),i=(0,G.useMemo)(()=>n?Ze():``,[n,e]);return(0,G.useEffect)(()=>{if(!i)return;let e=e=>{let t=r.current?.contentWindow;t&&e.source===t&&$e(e.data,i)&&et(t,e.data)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[i]),(0,K.jsx)(`iframe`,{ref:r,"data-testid":`scratchpad-html-preview`,"data-trusted":n||void 0,title:`${t} preview`,sandbox:Je,referrerPolicy:`no-referrer`,srcDoc:i?Qe(e,i):e,className:`h-(--pad-height,70vh) w-full border bg-white ${n?`border-destructive`:`border-outline-variant`}`},n?`trusted`:`sandboxed`)}function nt({pad:e}){let t=Ue(e),[n,r]=B(`padView`,`preview`,Ge),[i,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),l=(0,G.useRef)(e.revision);(0,G.useEffect)(()=>{e.revision!==l.current&&(l.current=e.revision,e.content!==t.draft&&o(!1))},[e.revision,e.content,t.draft]);let u={...t,discard:()=>{e.content!==t.draft&&o(!1),t.discard()}},[d,f]=(0,G.useState)(t.draft);(0,G.useEffect)(()=>{let e=setTimeout(()=>f(t.draft),qe);return()=>clearTimeout(e)},[t.draft]);let p=(0,K.jsx)(O,{path:W(e.title,`html`),value:t.draft,onChange:t.setDraft,onSave:()=>void t.save(),readOnly:t.saving,height:`var(--pad-height, 70vh)`,label:`HTML source`,testId:`scratchpad-html-source`});return(0,K.jsxs)(`div`,{className:`space-y-3`,"data-testid":`scratchpad-html`,children:[(0,K.jsxs)(Ve,{draft:u,children:[Ge.map(e=>(0,K.jsx)(He,{active:n===e,onClick:()=>r(e),testId:`scratchpad-view-${e}`,children:Ke[e]},e)),n!==`code`&&(i?(0,K.jsxs)(a,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`scratchpad-html-sandbox`,onClick:()=>o(!1),children:[(0,K.jsx)(Fe,{size:12,className:`mr-1`}),` Back to sandbox`]}):(0,K.jsxs)(a,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`scratchpad-html-trust`,onClick:()=>c(!0),children:[(0,K.jsx)(Ne,{size:12,className:`mr-1`}),` Render with ORC access`]}))]}),i&&n!==`code`&&(0,K.jsxs)(`p`,{role:`status`,className:`text-sm text-destructive`,children:[`This page runs with ORC access: its scripts act as you and can call the API through`,` `,(0,K.jsx)(`code`,{className:`font-mono text-xs`,children:`orc.fetch()`}),`.`]}),n===`preview`?(0,K.jsx)(tt,{html:d,title:e.title,trusted:i}):n===`code`?p:(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:[(0,K.jsx)(`div`,{className:`min-w-0`,children:p}),(0,K.jsx)(tt,{html:d,title:e.title,trusted:i})]}),(0,K.jsx)(be,{open:s,title:`Render with ORC access?`,description:`The page's scripts will be able to call the ORC API as you through orc.fetch: read and change anything, including starting agents and terminals. They stay in the sandbox; the dashboard does not hand them your API secret, though API calls such as terminals can reach anything you can. Only do this for a page you trust. Access ends when you go back to the sandbox, leave the page, or someone else edits it.`,confirmLabel:`Render with access`,variant:`destructive`,onCancel:()=>c(!1),onConfirm:()=>{c(!1),o(!0)}})]})}var rt=(0,G.lazy)(()=>A(()=>import(`./ScratchpadDiagramEditor-D44NiVP_.js`).then(e=>e.t),__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,26,27,28,29,30,31,32])));function it({pad:e}){return e.kind===`doc`?(0,K.jsx)(at,{pad:e}):e.kind===`html`?(0,K.jsx)(nt,{pad:e}):(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`div`,{role:`status`,className:`p-3 text-sm text-outline`,children:`Loading diagram editor…`}),children:(0,K.jsx)(rt,{pad:e})})}function at({pad:e}){let t=S(),n=(0,G.useRef)(e.revision);return(0,K.jsx)(Ae,{documentId:`scratchpad:${e.id}`,path:W(e.title,`doc`),content:e.content,testId:`scratchpad-doc`,layout:`page`,pageTitle:e.title,onSave:async(r,i)=>{try{let t=await ee.scratchpads.update(e.id,{content:r,if_revision:i===e.content?e.revision:n.current});return n.current=t.revision,r}finally{await t()}}})}var ot=t({ScratchpadFormDialog:()=>$,default:()=>lt}),J=`all`,Y=`unassigned`,st=200;function ct(e,t){if(e===Y)return``;for(let n of[e,t])if(n&&n!==J&&n!==Y)return n;return``}function X(e){return new Date(e*1e3).toLocaleString()}function lt({projectId:e}){let{scratchpadId:t}=pe();return t?(0,K.jsx)(mt,{id:t},t):(0,K.jsx)(dt,{defaultProjectId:e})}function ut({kind:e}){let{label:t,icon:n}=_[e];return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-label text-xs text-muted-foreground`,children:[(0,K.jsx)(n,{size:12,"aria-hidden":!0}),` `,t]})}function dt({defaultProjectId:e}){let t=oe(),n=re(),[r,o]=B(`padProject`,J),[f,p]=B(`padKind`,J,[J,...U]),[m,h]=B(`padQuery`,``),[g,b]=(0,G.useState)(m);(0,G.useEffect)(()=>b(m),[m]);let[x,S]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=new URLSearchParams(n.search);e.get(`new`)===`1`&&(S(!0),e.delete(`new`),t({search:e.toString()},{replace:!0}))},[n.search,t]);let{data:C}=R({status:`active`}),w=v({kind:f===J?void 0:f,project_id:r===J||r===Y?void 0:r,unassigned:r===Y?`true`:void 0,q:m||void 0,limit:st}),T=w.data?.scratchpads??[],E=e=>e?C?.find(t=>t.id===e)?.name??e:`—`,D=!!m||f!==J||r!==J;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Se,{title:`Scratchpads`,meta:w.data?`${w.data.total} ${w.data.total===1?`scratchpad`:`scratchpads`}`:void 0,action:(0,K.jsxs)(a,{"data-testid":`new-scratchpad-button`,size:`sm`,onClick:()=>S(!0),className:`font-label text-sm`,children:[(0,K.jsx)(he,{size:12,className:`mr-1`}),` New scratchpad`]})}),(0,K.jsxs)(`p`,{className:`mb-4 text-sm leading-relaxed text-muted-foreground`,children:[`Working docs, diagrams and HTML pages you or an agent keep and come back to. Agents create and edit them with the `,(0,K.jsx)(`code`,{className:`font-mono text-xs`,children:`pad_*`}),` tools; share one by copying its link.`]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,K.jsxs)(d,{value:r,onValueChange:e=>o(e),children:[(0,K.jsx)(c,{"aria-label":`Project`,"data-testid":`scratchpad-project-filter`,className:`h-9 w-48 bg-background text-on-surface font-body text-sm`,children:(0,K.jsx)(s,{})}),(0,K.jsxs)(l,{className:`bg-surface border-outline-variant`,children:[(0,K.jsx)(u,{value:J,className:`font-body text-sm`,children:`All projects`}),(0,K.jsx)(u,{value:Y,className:`font-body text-sm`,children:`No project`}),C?.map(e=>(0,K.jsx)(u,{value:e.id,className:`font-body text-sm`,children:e.name},e.id))]})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[J,...U].map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>p(e),"data-testid":`scratchpad-kind-${e}`,"aria-pressed":f===e,className:`font-label text-sm px-3 py-1.5 border transition-colors ${f===e?`bg-surface-highest text-on-surface border-transparent`:`bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:e===J?`All`:_[e].label},e))}),(0,K.jsxs)(`div`,{className:`relative min-w-[160px] flex-1`,children:[(0,K.jsx)(fe,{size:12,className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)(_e,{"aria-label":`Search scratchpads`,"data-testid":`scratchpad-search-input`,value:g,onChange:e=>b(e.target.value),onKeyDown:e=>e.key===`Enter`&&h(e.currentTarget.value),placeholder:`Search titles and content...`,className:`pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground`})]}),(0,K.jsx)(a,{variant:`outline`,size:`sm`,onClick:()=>h(g),className:`font-label text-sm`,children:`Search`})]}),w.error?(0,K.jsx)(xe,{message:w.error.message,onRetry:()=>void w.refetch()}):w.isLoading?(0,K.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,K.jsx)(P,{className:`h-10 w-full bg-surface-highest`},t))}):T.length===0?(0,K.jsx)(we,{message:D?`No scratchpads match`:`No scratchpads yet`}):(0,K.jsx)(`div`,{className:`overflow-hidden`,children:(0,K.jsxs)(ke,{children:[(0,K.jsx)(Ee,{children:(0,K.jsxs)(Oe,{className:`border-b border-outline-variant hover:bg-transparent`,children:[(0,K.jsx)(V,{className:`font-label text-sm text-muted-foreground`,children:`Title`}),(0,K.jsx)(V,{className:`font-label text-sm text-muted-foreground w-28`,children:`Kind`}),(0,K.jsx)(V,{className:`font-label text-sm text-muted-foreground`,children:`Project`}),(0,K.jsx)(V,{className:`font-label text-sm text-muted-foreground hidden md:table-cell`,children:`Author`}),(0,K.jsx)(V,{className:`font-label text-sm text-muted-foreground w-20 hidden md:table-cell`,children:`Size`}),(0,K.jsx)(V,{className:`font-label text-sm text-muted-foreground w-44`,children:`Updated`})]})}),(0,K.jsx)(De,{children:T.map(e=>(0,K.jsxs)(Oe,{"data-testid":`scratchpad-row`,"data-scratchpad-id":e.id,className:`border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer`,onClick:()=>t(`${y(e.id)}${n.search}`),children:[(0,K.jsxs)(H,{className:`font-body text-sm font-medium text-on-surface`,children:[(0,K.jsx)(ce,{to:`${y(e.id)}${n.search}`,className:`inline-flex min-h-11 items-center hover:text-primary`,onClick:e=>e.stopPropagation(),children:e.title}),e.tags.length>0&&(0,K.jsx)(`span`,{className:`ml-2 font-label text-xs text-outline`,children:e.tags.map(e=>`#${e}`).join(` `)})]}),(0,K.jsx)(H,{children:(0,K.jsx)(ut,{kind:e.kind})}),(0,K.jsx)(H,{className:`font-body text-sm text-muted-foreground`,children:E(e.project_id)}),(0,K.jsx)(H,{className:`font-body text-sm text-muted-foreground hidden md:table-cell`,children:e.author}),(0,K.jsx)(H,{className:`font-label text-sm text-muted-foreground hidden md:table-cell`,children:i(e.size_bytes)}),(0,K.jsx)(H,{className:`font-label text-sm text-muted-foreground`,children:X(e.updated_at)})]},e.id))})]})}),x&&(0,K.jsx)($,{defaultProjectId:ct(r,e),onClose:()=>S(!1),onSaved:e=>t(y(e.id))})]})}var Z=`none`,Q=`none`,ft=50;function pt(e,t,n){let r=(e??[]).filter(e=>e.session_id&&(t===Z||e.project_id===t||e.session_id===n)).sort((e,t)=>(t.last_activity_at??t.created_at).localeCompare(e.last_activity_at??e.created_at)).slice(0,ft),i=e?.find(e=>e.session_id===n);return i&&!r.includes(i)?[i,...r]:r}function $({pad:e,defaultProjectId:t=``,defaultKind:n=`doc`,onClose:r,onSaved:i}){let[o,p]=(0,G.useState)(e?.kind??n),[m,g]=(0,G.useState)(e?.title??``),[v,y]=(0,G.useState)((e?e.project_id:t)||Z),[b,x]=(0,G.useState)(e?.session_id??Q),[S,C]=(0,G.useState)(e?.tags??[]),{data:T}=R({status:`active`}),{data:E}=Te(!1),D=pt(E,v,b),O=h(),k=w(),A=e?k:O;function j(){let t={title:m.trim(),project_id:v===Z?null:v,session_id:b===Q?null:b,tags:S},n=e=>{r(),i?.(e)};e?k.mutate({id:e.id,...t},{onSuccess:n}):O.mutate({kind:o,...t},{onSuccess:n})}return(0,K.jsx)(le,{open:!0,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(ie,{"data-testid":`scratchpad-form`,className:`sm:max-w-lg`,children:[(0,K.jsx)(me,{children:(0,K.jsx)(ne,{children:e?`Scratchpad properties`:`New scratchpad`})}),(0,K.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),j()},children:[!e&&(0,K.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,K.jsx)(`legend`,{className:`font-label text-sm`,children:`Kind`}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:U.map(e=>{let{label:t,icon:n,hint:r}=_[e];return(0,K.jsxs)(`button`,{type:`button`,"data-testid":`scratchpad-form-kind-${e}`,"aria-pressed":o===e,onClick:()=>p(e),className:`flex flex-col items-start gap-1 border p-3 text-left transition-colors ${o===e?`border-primary bg-surface-low`:`border-outline-variant hover:bg-surface-low`}`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-label text-sm`,children:[(0,K.jsx)(n,{size:14,"aria-hidden":!0}),` `,t]}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]},e)})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{htmlFor:`scratchpad-title`,children:`Title`}),(0,K.jsx)(_e,{id:`scratchpad-title`,"data-testid":`scratchpad-form-title`,value:m,maxLength:200,autoFocus:!0,onChange:e=>g(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{htmlFor:`scratchpad-project`,children:`Project`}),(0,K.jsxs)(d,{value:v,onValueChange:y,children:[(0,K.jsx)(c,{id:`scratchpad-project`,"data-testid":`scratchpad-form-project`,children:(0,K.jsx)(s,{})}),(0,K.jsxs)(l,{className:`bg-surface border-outline-variant`,children:[(0,K.jsx)(u,{value:Z,children:`No project`}),T?.map(e=>(0,K.jsx)(u,{value:e.id,children:e.name},e.id))]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{htmlFor:`scratchpad-session`,children:`Session`}),(0,K.jsxs)(d,{value:b,onValueChange:x,children:[(0,K.jsx)(c,{id:`scratchpad-session`,"data-testid":`scratchpad-form-session`,children:(0,K.jsx)(s,{})}),(0,K.jsxs)(l,{className:`bg-surface border-outline-variant`,children:[(0,K.jsx)(u,{value:Q,children:`No session`}),b!==Q&&!D.some(e=>e.session_id===b)&&(0,K.jsx)(u,{value:b,children:b.slice(0,8)}),D.map(e=>(0,K.jsxs)(u,{value:e.session_id,"data-testid":`scratchpad-form-session-option`,children:[e.agent,` · `,e.name??`Untitled session`,` ·`,` `,Ce(e.last_activity_at??e.created_at)]},e.id))]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{children:`Tags`}),(0,K.jsx)(je,{value:S,onChange:C,placeholder:`Add a tag`,"aria-label":`Tags`,"data-testid":`scratchpad-form-tags`})]}),A.error&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:A.error.message}),(0,K.jsxs)(se,{children:[(0,K.jsx)(a,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,K.jsx)(a,{type:`submit`,"data-testid":`scratchpad-form-submit`,disabled:!m.trim()||A.isPending,children:e?`Save`:`Create`})]})]})]})})}function mt({id:e}){let t=oe(),n=re(),{data:r,isLoading:i,error:s,refetch:c}=g(e),{data:l}=R(),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[h,_]=(0,G.useState)(`idle`),[v,y]=(0,G.useState)(!1),S=b(),w=`${C}${n.search}`;(0,G.useEffect)(()=>{if(h!==`copied`)return;let e=setTimeout(()=>_(`idle`),2e3);return()=>clearTimeout(e)},[h]),(0,G.useEffect)(()=>{if(!v)return;function e(e){e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role="dialog"], [role="alertdialog"]`)||y(!1)}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v]);async function O(){try{await navigator.clipboard.writeText(x(e)),_(`copied`)}catch{_(`failed`)}}let A=(0,K.jsxs)(ce,{to:w,className:`inline-flex min-h-11 items-center gap-1.5 font-label text-sm text-muted-foreground hover:text-on-surface`,children:[(0,K.jsx)(m,{size:14,"aria-hidden":!0}),` Scratchpads`]});if(s)return(0,K.jsxs)(`div`,{children:[A,(0,K.jsx)(xe,{message:s.message,onRetry:()=>void c()})]});if(i||!r)return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[A,(0,K.jsx)(P,{className:`h-8 w-1/2 bg-surface-highest`}),(0,K.jsx)(P,{className:`h-64 w-full bg-surface-highest`})]});let j=r.project_id?l?.find(e=>e.id===r.project_id):void 0;return(0,K.jsxs)(`div`,{"data-testid":`scratchpad-page`,"data-scratchpad-kind":r.kind,className:`min-w-0`,children:[A,(0,K.jsxs)(`div`,{className:`mt-2 mb-4 flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,K.jsx)(`h1`,{"data-testid":`scratchpad-title`,className:`font-headline font-medium text-2xl tracking-tight text-on-surface wrap-break-word`,children:r.title}),(0,K.jsxs)(`div`,{"data-testid":`scratchpad-meta`,className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-outline`,children:[(0,K.jsx)(ut,{kind:r.kind}),(0,K.jsxs)(`span`,{children:[`revision `,r.revision]}),(0,K.jsxs)(`span`,{children:[`by `,(0,K.jsx)(`span`,{"data-testid":`scratchpad-author`,children:r.author}),`,`,` `,X(r.updated_at)]}),(0,K.jsx)(`span`,{children:j?.name??(r.project_id?r.project_id:`No project`)}),r.session_id&&(0,K.jsxs)(`span`,{title:`Agent session that created it`,children:[`session `,(0,K.jsx)(`code`,{className:`font-mono text-xs`,children:r.session_id.slice(0,8)})]}),r.tags.length>0&&(0,K.jsx)(`span`,{children:r.tags.map(e=>`#${e}`).join(` `)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(a,{"data-testid":`scratchpad-fullscreen`,size:`sm`,variant:`outline`,onClick:()=>y(!0),children:[(0,K.jsx)(D,{size:12,className:`mr-1`}),` Full screen`]}),(0,K.jsxs)(a,{"data-testid":`scratchpad-copy-link`,size:`sm`,variant:`outline`,onClick:()=>void O(),children:[h===`copied`?(0,K.jsx)(o,{size:12,className:`mr-1`}):(0,K.jsx)(E,{size:12,className:`mr-1`}),h===`copied`?`Copied`:`Copy link`]}),(0,K.jsxs)(a,{"data-testid":`scratchpad-download`,size:`sm`,variant:`outline`,title:`Download the saved file`,onClick:()=>ye(new Blob([r.content],{type:Le[r.kind].mime}),W(r.title,r.kind)),children:[(0,K.jsx)(T,{size:12,className:`mr-1`}),` Download`]}),(0,K.jsxs)(a,{"data-testid":`scratchpad-properties`,size:`sm`,variant:`outline`,onClick:()=>d(!0),children:[(0,K.jsx)(ge,{size:12,className:`mr-1`}),` Properties`]}),(0,K.jsxs)(a,{"data-testid":`scratchpad-delete`,size:`sm`,variant:`outline`,onClick:()=>p(!0),children:[(0,K.jsx)(de,{size:12,className:`mr-1`}),` Delete`]})]})]}),h===`failed`&&(0,K.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-destructive`,children:`Clipboard access failed. Copy the link from the address bar instead.`}),(0,K.jsxs)(`div`,{"data-testid":`scratchpad-stage`,"data-fullscreen":v||void 0,className:v?`fixed inset-0 z-40 flex flex-col gap-3 overflow-auto bg-background p-3 [--pad-height:calc(100dvh-8.5rem)] sm:p-4`:`min-w-0`,children:[v&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-headline text-lg font-medium text-on-surface`,children:r.title}),(0,K.jsxs)(a,{"data-testid":`scratchpad-exit-fullscreen`,size:`sm`,variant:`outline`,onClick:()=>y(!1),children:[(0,K.jsx)(k,{size:12,className:`mr-1`}),` Exit full screen`]})]}),(0,K.jsx)(it,{pad:r})]}),u&&(0,K.jsx)($,{pad:r,onClose:()=>d(!1)}),f&&(0,K.jsx)(be,{open:!0,title:`Delete scratchpad`,description:`Delete "${r.title}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,isPending:S.isPending,onConfirm:()=>S.mutate(r.id,{onSuccess:()=>{p(!1),t(w)}}),onCancel:()=>p(!1)}),S.error&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-destructive`,children:S.error.message})]})}export{$ as ScratchpadFormDialog,lt as default,W as i,Ue as n,Ve as r,ot as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i}from"./useMutation-HX90wI4L.js";import{t as a}from"./button-BHKbOsmj.js";import{t as o}from"./label-BQ1Lr4sA.js";import{i as s,l as c,n as l}from"./scratchpad-routes-B75DnNPp.js";import{t as u}from"./link-2-DSYfKX_9.js";import{t as d}from"./Markdown-BYChkZ3Z.js";import{n as f}from"./client-BwhkVepQ.js";import{An as p,At as m,Dt as h,Et as g,G as _,K as v,On as y,Qt as b,Tn as x,Tt as S,U as C,W as ee,X as w,Y as T,_t as E,an as D,bn as O,hn as k,in as te,jt as A,kt as j,l as M,mn as ne,sn as N,wt as P}from"./index-CMRGRbC9.js";import{t as F}from"./ErrorState-BoQqdsym.js";import{t as re}from"./ViewHeader-DHM9SSkD.js";import{a as I,c as L,i as R,n as z,t as B}from"./live-sessions-D07BClP7.js";import{t as V}from"./EmptyState-YM4VSLR9.js";import{t as ie}from"./Pager-DQCWHQWA.js";import{a as ae,c as H,n as U,o as W,t as G}from"./useSessions-C2GU4FkG.js";import{a as K,i as q,n as oe,o as se,r as J,t as ce}from"./table-ByS-sgsb.js";import{t as le}from"./useProjectScope-CZEfU9mq.js";import{t as ue}from"./ResumeActions-1gJa3nsX.js";import{t as de}from"./StatusBadge-CTFDUHuw.js";var Y=e(t(),1),X=n();function fe({projectId:e}){let[t]=p(),n=y(),s=r(),c=E(),[l,u]=(0,Y.useState)({key:``,offset:0}),[d,_]=(0,Y.useState)(null),[v,x]=(0,Y.useState)(!1),[C,ee]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(``),[k,te]=(0,Y.useState)(e),[A,M]=(0,Y.useState)(``),[ne,N]=(0,Y.useState)(``),[F,re]=(0,Y.useState)(``),[I,L]=(0,Y.useState)(``),[R,z]=(0,Y.useState)(0),B=t.get(`q`)??``,V=t.get(`agent`)??``,ie=t.get(`ended`)!==`0`,ae=JSON.stringify([e,B,V]),H=l.key===ae?l.offset:0,U=e=>u({key:ae,offset:e}),W=i({queryKey:[`sessions`,`archive`,e,B,V,H],queryFn:()=>f.sessions.archive({q:B,...e===`all`?{}:{project_id:e},...[`claude`,`codex`].includes(V)?{agent:V}:{},offset:H,limit:20}),enabled:ie,refetchInterval:1e4}),G=i({queryKey:[`sessions`,`archive-transcript`,d?.id,d?.revision,R],queryFn:()=>f.sessions.archiveTranscript(d?.id,{revision:d?.revision,offset:R,limit:50}),enabled:!!d});async function K(e){ee(!0),T(``),O(``);try{await e(),await s.invalidateQueries({queryKey:[`sessions`]})}catch(e){T(e instanceof Error?e.message:`Request failed`)}finally{ee(!1)}}async function q(e){if(!e?.length)return;let t=c.data?.find(e=>e.id===k)?.name;t?await K(async()=>{let n=localStorage.getItem(`orc_session_upload_source`);n||(n=crypto.randomUUID(),localStorage.setItem(`orc_session_upload_source`,n));let r=0,i=[];for(let a of Array.from(e))try{if(a.size>62914560)throw Error(`File exceeds 60 MiB`);let e=await a.text(),i=e.split(/\r?\n/).filter(e=>e.trim()).map(e=>JSON.parse(e)),o=i[0]?.type===`session_meta`,s=o?i[0].payload:i.find(e=>e.sessionId),c=await f.sessions.archiveUpload({project:t,source_id:n,agent:o?`codex`:`claude`,session_id:o?s?.id:s?.sessionId,title:a.name.slice(0,200),metadata:{cwd:s?.cwd??``,subdirectory:``,...o&&s?.git?.repository_url?{repository:s.git.repository_url}:{},...o&&s?.git?.branch?{branch:s.git.branch}:{},...o&&s?.git?.commit_hash?{commit:s.git.commit_hash}:{}},bundle:{version:1,files:[{path:`session.jsonl`,content:e}]}});[`created`,`updated`,`unchanged`,`stale`].includes(c.outcome)&&r++}catch(e){i.push(`${a.name}: ${e instanceof Error?e.message:`Upload failed`}`)}O(`${r} of ${e.length} sessions synchronized${i.length?`; ${i.length} need attention`:``}.`),i.length&&T(i.join(`
|
|
2
|
+
`))}):T(`Select a project before uploading`)}return ie?(0,X.jsxs)(`section`,{className:`mt-8 space-y-3`,"data-testid":`session-archive`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-medium`,children:`Archived sessions`}),(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:`Uploaded history stays available after the source computer is offline.`})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(a,{variant:`outline`,"data-testid":`archive-index`,disabled:C,onClick:()=>void K(async()=>{let t=await f.sessions.archiveIndex(e===`all`||e===`unassigned`?void 0:e);O(`${t.indexed} sessions indexed; ${t.failed} failed; ${t.skipped} skipped.`)}),children:`Index discovered sessions`}),(0,X.jsx)(a,{"data-testid":`archive-upload-open`,onClick:()=>{te(e),x(!0)},children:`Upload sessions`})]})]}),D&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`archive-feedback`,className:`text-sm`,children:D}),(w||W.error)&&(0,X.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap text-sm text-error`,children:w||W.error?.message}),W.data?.degraded&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`archive-degraded`,className:`text-xs text-outline`,children:W.data.degraded}),!!W.data?.pending_chunks&&(0,X.jsxs)(`p`,{className:`text-xs text-outline`,children:[W.data.pending_chunks,` passages waiting for embeddings`]}),(0,X.jsxs)(`div`,{className:`divide-y divide-outline-variant rounded border border-outline-variant`,children:[W.isLoading&&(0,X.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading archived sessions…`}),!W.isLoading&&!W.data?.sessions.length&&(0,X.jsx)(`p`,{className:`p-4 text-sm text-outline`,children:`No archived sessions match this view.`}),W.data?.sessions.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`archive-session-row`,"data-archive-id":e.id,className:`block w-full p-3 text-left hover:bg-surface-container`,onClick:()=>{_(e),z(0),M(e.metadata.repository??``),N(e.metadata.branch??``),re(e.metadata.commit??``),L(e.metadata.subdirectory)},children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-xs text-outline`,children:[e.agent,` · ended · `,new Date(e.updated_at).toLocaleString(),` · revision`,` `,e.revision,` · `,e.metadata.cwd]}),e.passages.map(e=>(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-outline`,children:e.snippet},e.citation)),e.embedding_error&&(0,X.jsx)(`span`,{className:`block text-xs text-error`,children:e.embedding_error})]},e.id))]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,X.jsx)(a,{variant:`ghost`,disabled:H===0,onClick:()=>U(Math.max(0,H-20)),children:`Previous`}),(0,X.jsx)(a,{variant:`ghost`,disabled:!W.data?.has_more,onClick:()=>U(H+20),children:`Next`})]}),(0,X.jsx)(S,{open:v,onOpenChange:x,children:(0,X.jsxs)(g,{children:[(0,X.jsxs)(j,{children:[(0,X.jsx)(m,{children:`Upload session histories`}),(0,X.jsx)(h,{children:`Select an existing project and native Claude/Codex JSONL files. This stores history without starting a terminal. For large collections, use the orc-platform sync script.`})]}),(0,X.jsx)(o,{htmlFor:`archive-project`,children:`Project`}),(0,X.jsxs)(`select`,{id:`archive-project`,"data-testid":`archive-project`,value:k,onChange:e=>te(e.target.value),className:`rounded border border-outline-variant bg-surface p-2`,children:[(0,X.jsx)(`option`,{value:`all`,children:`Select a project`}),c.data?.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,X.jsx)(P,{"data-testid":`archive-files`,type:`file`,multiple:!0,accept:`.jsonl`,disabled:C||!c.data?.some(e=>e.id===k),onChange:e=>void q(e.target.files)}),C&&(0,X.jsx)(`p`,{role:`status`,children:`Uploading…`}),D&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`archive-upload-feedback`,children:D}),w&&(0,X.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap text-sm text-error`,children:w})]})}),(0,X.jsx)(S,{open:!!d,onOpenChange:e=>{e||_(null)},children:(0,X.jsxs)(g,{className:`max-h-[90vh] max-w-3xl overflow-y-auto`,"data-testid":`archive-detail`,children:[(0,X.jsxs)(j,{children:[(0,X.jsx)(m,{children:d?.title}),(0,X.jsxs)(h,{children:[`Archived history · revision `,d?.revision,`. Prepare a destination checkout to continue in a terminal.`]})]}),G.error&&(0,X.jsx)(`p`,{role:`alert`,children:G.error.message}),G.data?.turns.map(e=>(0,X.jsxs)(`div`,{className:`border-b border-outline-variant py-2`,"data-testid":`archive-turn`,children:[(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:e.role}),(0,X.jsx)(b,{plain:!0,children:e.blocks.map(e=>e.type===`tool_use`?`${e.name}\n${e.input}\n${e.result??``}`:e.text).join(`
|
|
3
|
+
`)})]},e.index)),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(a,{variant:`ghost`,disabled:!R,onClick:()=>z(Math.max(0,R-50)),children:`Previous messages`}),(0,X.jsx)(a,{variant:`ghost`,disabled:R+50>=(G.data?.total??0),onClick:()=>z(R+50),children:`Next messages`})]}),(0,X.jsxs)(`div`,{className:`space-y-2 border-t border-outline-variant pt-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`Continue on ORC`}),(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:`Use the pushed repository, branch and exact commit for the work you want to continue. The destination project must have its repository configured.`}),(0,X.jsx)(o,{htmlFor:`archive-repository`,children:`Repository`}),(0,X.jsx)(P,{id:`archive-repository`,"data-testid":`archive-repository`,value:A,onChange:e=>M(e.target.value)}),(0,X.jsx)(o,{htmlFor:`archive-branch`,children:`Branch`}),(0,X.jsx)(P,{id:`archive-branch`,"data-testid":`archive-branch`,value:ne,onChange:e=>N(e.target.value)}),(0,X.jsx)(o,{htmlFor:`archive-commit`,children:`Pushed commit`}),(0,X.jsx)(P,{id:`archive-commit`,"data-testid":`archive-commit`,value:F,onChange:e=>re(e.target.value)}),(0,X.jsx)(o,{htmlFor:`archive-subdirectory`,children:`Repository subdirectory`}),(0,X.jsx)(P,{id:`archive-subdirectory`,"data-testid":`archive-subdirectory`,value:I,onChange:e=>L(e.target.value),placeholder:`Repository root`}),(0,X.jsx)(a,{"data-testid":`archive-resume`,disabled:C||!A||!ne||!/^[a-f0-9]{40}$/i.test(F),onClick:()=>void K(async()=>{if(!d)return;let e=await f.sessions.archiveResume(d.id,{revision:d.revision,repository:A,branch:ne,commit:F,subdirectory:I});if(e.status!==`ready`||!e.live_session_id)throw Error(e.error||`Session preparation failed`);let t=await f.terminals.create({kind:d.agent,live_session_id:e.live_session_id});n(`/terminals/${t.id}`)}),children:C?`Preparing…`:`Prepare and resume in terminal`}),w&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:w})]})]})})]}):null}function Z({text:e,query:t}){let n=t.trim();if(n.length<2)return(0,X.jsx)(X.Fragment,{children:e});let r=e.split(RegExp(`(${z(n)})`,`gi`));return(0,X.jsx)(X.Fragment,{children:r.map((e,t)=>e.toLowerCase()===n.toLowerCase()?(0,X.jsx)(`mark`,{className:`bg-primary/30 text-on-surface rounded-xs`,children:e},t):e)})}function pe({projectId:e,pending:t,onSelect:n}){let[r,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=i({queryKey:[`tasks`,`session-picker`,e],queryFn:()=>f.tasks.list({...e?{project_id:e}:{},limit:100})});async function p(e){u(null);try{await n(e)}catch(e){u(e instanceof Error?e.message:`Could not link task`)}}async function m(){c(!0),u(null);try{await p((await f.tasks.get(r.trim())).id)}catch(e){u(e instanceof Error?e.message:`Task lookup failed`)}finally{c(!1)}}let h=(d.data?.tasks??[]).filter(e=>`${e.title} ${e.id}`.toLowerCase().includes(r.trim().toLowerCase()));return(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(P,{"data-testid":`session-task-search`,"aria-label":`Search tasks or enter a task ID`,value:r,onChange:e=>{o(e.target.value),u(null)},placeholder:`Search recent tasks or paste a task ID`}),(0,X.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Up to 100 recent tasks`,e?` in this project`:` across projects`,`. Older or other-project tasks can be linked by exact ID.`]}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:l}),d.error?(0,X.jsx)(F,{message:d.error.message,onRetry:()=>d.refetch()}):d.isLoading?(0,X.jsx)(`p`,{role:`status`,children:`Loading tasks…`}):(0,X.jsxs)(`div`,{className:`max-h-72 overflow-y-auto divide-y divide-border`,children:[h.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`session-task-option`,"data-task-id":e.id,disabled:t||s,onClick:()=>void p(e.id),className:`w-full min-h-11 py-2 text-left hover:bg-surface-highest disabled:opacity-50`,children:[(0,X.jsx)(`span`,{className:`block text-sm wrap-break-word`,children:e.title}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs text-outline`,children:[(0,X.jsx)(de,{status:e.status,className:`px-0`}),e.id]})]},e.id)),h.length===0&&(0,X.jsx)(`p`,{className:`py-4 text-sm text-outline`,children:`No recent task matches. Paste its exact ID to look it up.`})]}),r.trim()&&(0,X.jsx)(a,{variant:`outline`,disabled:t||s,onClick:()=>void m(),children:s?`Looking up…`:`Link by exact ID`})]})}function me({session:e,linkTestId:t=`open-task`}){let[n]=p(),[r,i]=(0,Y.useState)(!1),o=G(),s=n.get(`project`)??e.project_id;async function c(t){try{await o.mutateAsync({id:e.id,taskId:t}),i(!1)}catch{}}return(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[e.task&&(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(x,{"data-testid":t,to:L(`/tasks/${e.task.id}`,s),className:`block max-w-64 truncate text-sm text-primary hover:underline`,title:e.task.title,children:e.task.title}),(0,X.jsx)(de,{status:e.task.status,className:`px-0`})]}),(0,X.jsxs)(S,{open:r,onOpenChange:e=>{i(e),e&&o.reset()},children:[(0,X.jsx)(A,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-testid":`link-task`,className:`inline-flex min-h-9 items-center gap-1.5 text-xs text-outline hover:text-on-surface`,children:[e.task?(0,X.jsx)(N,{size:12}):(0,X.jsx)(u,{size:13}),e.task?`Change task`:`Link task`]})}),(0,X.jsxs)(g,{"data-testid":`session-task-dialog`,className:`max-h-[85dvh] w-[calc(100%-2rem)] overflow-y-auto`,children:[(0,X.jsxs)(j,{children:[(0,X.jsx)(m,{children:`Link a task`}),(0,X.jsxs)(h,{children:[`Choose a recent task for `,e.name??`this session`,`, or paste an exact task ID.`]})]}),o.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:o.error.message}),(0,X.jsx)(pe,{projectId:e.project_id,pending:o.isPending,onSelect:c}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.task&&(0,X.jsx)(a,{variant:`outline`,"data-testid":`session-task-unlink`,disabled:o.isPending,onClick:()=>void c(null),children:`Unlink task`})})]})]})]})}function he({session:e}){let[t]=p(),{data:n}=c({session_id:e.session_id??void 0,limit:20},{enabled:!!e.session_id}),r=n?.scratchpads??[];if(r.length===0)return null;let i=t.get(`project`)??e.project_id;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,"data-testid":`session-scratchpads`,children:[(0,X.jsx)(`span`,{className:`text-on-surface-variant`,children:`scratchpads`}),r.map(e=>{let t=s[e.kind].icon;return(0,X.jsxs)(x,{to:L(l(e.id),i),"data-testid":`session-scratchpad-link`,className:`inline-flex max-w-56 items-center gap-1 text-primary hover:underline`,title:e.title,children:[(0,X.jsx)(t,{size:12,"aria-hidden":!0,className:`shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.title})]},e.id)})]})}var ge=`session-search`,_e={user:`border-border/65`,assistant:`border-border/65`,tool:`border-border/65 bg-transparent`,system:`border-border/65 bg-transparent`},ve=[`command`,`cmd`,`file_path`,`path`,`pattern`,`query`,`url`,`description`];function ye(e){try{let t=JSON.parse(e);for(let e of ve)if(typeof t[e]==`string`)return t[e]}catch{}return e}function be(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function xe(e,t,n){(0,Y.useEffect)(()=>{let n=e.current,r=CSS.highlights,i=window.Highlight;if(!n||!r||!i)return;let a=t.trim().toLowerCase(),o=()=>{if(r.delete(ge),a.length<2)return;let e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n;n=t.nextNode()){let t=n.textContent?.toLowerCase()??``;for(let r=t.indexOf(a);r>=0;r=t.indexOf(a,r+a.length)){let t=new Range;t.setStart(n,r),t.setEnd(n,r+a.length),e.push(t)}}e.length>0&&r.set(ge,new i(...e))};o();let s,c=new MutationObserver(()=>{clearTimeout(s),s=setTimeout(o,150)});return c.observe(n,{childList:!0,subtree:!0,characterData:!0}),()=>{clearTimeout(s),c.disconnect(),r.delete(ge)}},[e,t,n])}function Se({block:e,open:t}){let n=e.result!==void 0;return(0,X.jsxs)(`details`,{open:t||void 0,"data-testid":`tool-box`,className:`border-l border-border bg-background`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-2 py-1.5 font-label text-xs font-medium text-outline hover:text-on-surface`,children:[(0,X.jsx)(`span`,{className:`text-secondary shrink-0`,children:e.name}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono normal-case tracking-normal text-on-surface-variant`,children:ye(e.input)}),(0,X.jsx)(`span`,{className:`shrink-0 ${n?`text-outline`:`text-tertiary`}`,children:n?`done`:`no result`})]}),(0,X.jsxs)(`div`,{className:`space-y-2 border-t border-border px-2 py-2`,children:[(0,X.jsx)(`div`,{className:`font-label text-[10px] font-medium text-outline`,children:`input`}),(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-lg bg-background p-2 font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word`,children:be(e.input)}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`font-label text-[10px] font-medium text-outline`,children:`result`}),(0,X.jsx)(`pre`,{className:`max-h-96 overflow-auto rounded-lg bg-background p-2 font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word`,children:e.result})]})]})]})}function Ce({block:e,matched:t}){if(e.type===`text`)return(0,X.jsx)(b,{revealContext:t,children:e.text});if(e.type===`tool_use`)return(0,X.jsx)(Se,{block:e,open:t});let n=e.type===`thinking`?`thinking`:`result`;return(0,X.jsxs)(`details`,{open:t||void 0,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-label text-xs font-medium text-outline hover:text-on-surface`,children:n}),e.type===`thinking`?(0,X.jsx)(`div`,{className:`mt-1`,children:(0,X.jsx)(d,{children:e.text})}):(0,X.jsx)(`pre`,{className:`mt-1 max-h-96 overflow-auto rounded-lg bg-background p-2 font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word`,children:e.text})]})}function we({sessionId:e,initialQuery:t,onClose:n}){let[r,i]=(0,Y.useState)(t),[a,o]=(0,Y.useState)(0),{data:s}=U(!1),c=s?.find(t=>t.id===e),l=c!==void 0&&c.status!==`stopped`,u=r.trim().length>=2?r.trim():``,{data:d,isLoading:f,isFetching:p,error:m,refetch:h,dataUpdatedAt:g}=H(e,u),y=(0,Y.useRef)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(!0),S=(0,Y.useRef)(0),[E,A]=(0,Y.useState)(!0),j=(0,Y.useCallback)(()=>{let e=y.current;e&&(e.scrollTo({top:e.scrollHeight}),requestAnimationFrame(()=>e.scrollTo({top:e.scrollHeight})))},[]);xe(b,u,d?.turns);let M=d?.matches??[],N=M[a];(0,Y.useEffect)(()=>{d&&(N===void 0?x.current&&j():(x.current=!1,document.getElementById(`turn-${N}`)?.scrollIntoView({block:`center`})))},[N,d,j]),(0,Y.useEffect)(()=>{d&&E&&(S.current=d.total)},[d,E]);let P=e=>{M.length>0&&o(t=>(t+e+M.length)%M.length)};return(0,X.jsx)(ee,{open:!!e,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(v,{side:`right`,defaultWidth:1100,resizeKey:`live-session`,"data-testid":`live-session-detail`,children:[(0,X.jsxs)(T,{children:[(0,X.jsx)(w,{className:`normal-case tracking-normal text-sm pr-8`,children:c?.name??`Session`}),c&&(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-5 gap-y-1 font-body text-xs text-on-surface tabular-nums`,children:[(0,X.jsx)(`span`,{className:`font-medium text-primary`,children:c.agent}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${B[c.status].dot}`}),B[c.status].label]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-on-surface-variant`,children:`tokens `}),R(c)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-on-surface-variant`,children:`active `}),I(c.last_activity_at)]}),(0,X.jsx)(me,{session:c,linkTestId:`detail-open-task`}),(0,X.jsx)(ue,{session:c}),(0,X.jsx)(he,{session:c}),(0,X.jsx)(`span`,{className:`truncate max-w-full text-on-surface-variant`,children:c.cwd})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`relative min-w-[150px] flex-1`,children:[(0,X.jsx)(te,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-outline`}),(0,X.jsx)(`input`,{"data-testid":`transcript-search`,"aria-label":`Search this session`,value:r,onChange:e=>{i(e.target.value),o(0)},placeholder:`Search this session`,className:`w-full bg-background border border-control-border rounded-lg min-h-11 pl-7 pr-2 py-2 font-body text-xs text-on-surface`})]}),u&&(0,X.jsx)(`span`,{"data-testid":`transcript-match-count`,className:`font-label text-xs font-medium text-outline`,children:M.length===0?`no matches`:`${a+1} / ${M.length}`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Previous match`,onClick:()=>P(-1),className:`min-h-11 min-w-11 p-2 text-outline hover:text-on-surface`,children:(0,X.jsx)(k,{className:`h-4 w-4`})}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Next match`,onClick:()=>P(1),className:`min-h-11 min-w-11 p-2 text-outline hover:text-on-surface`,children:(0,X.jsx)(ne,{className:`h-4 w-4`})}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`transcript-refresh`,onClick:()=>{x.current=!0,h()},className:`min-h-11 px-2 inline-flex items-center gap-1 font-label text-xs font-medium text-primary hover:text-on-surface`,children:[(0,X.jsx)(D,{className:`h-3 w-3 ${p?`animate-spin`:``}`}),`Refresh`]})]}),d&&(0,X.jsxs)(`div`,{"data-testid":`transcript-status`,className:`mt-2 font-body text-xs text-on-surface-variant tabular-nums`,children:[d.total,` turns`,l?` · live, updated ${new Date(g).toLocaleTimeString()}`:``]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(_,{ref:y,onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-t.scrollTop-t.clientHeight<160;x.current=n,A(n)},children:f?(0,X.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,,]].map((e,t)=>(0,X.jsx)(C,{className:`h-16 w-full bg-surface-highest`},t))}):m||!d?(0,X.jsxs)(`div`,{"data-testid":`transcript-unavailable`,className:`font-body text-xs text-outline py-12 text-center`,children:[m?`Could not load the conversation: ${m.message}`:`No conversation was recorded for this session.`,(0,X.jsx)(`p`,{className:`mt-2`,children:`Resume actions remain available when the native agent session exists.`}),(0,X.jsx)(`button`,{type:`button`,className:`mt-3 min-h-11 text-primary hover:underline`,onClick:()=>h(),children:`Retry conversation`})]}):(0,X.jsx)(`div`,{ref:b,className:`space-y-3`,children:d.turns.map(e=>{let t=M.includes(e.index),n=e.blocks.map((e,n)=>(0,X.jsx)(Ce,{block:e,matched:t},n));return(0,X.jsxs)(`div`,{id:`turn-${e.index}`,"data-testid":`transcript-turn`,"data-role":e.role,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 120px`},className:`border-b px-4 py-3 text-on-surface space-y-2 ${_e[e.role]} ${e.index===N?`ring-1 ring-primary`:``}`,children:[(0,X.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline`,children:[e.role,e.time?` · ${I(e.time)}`:``]}),e.role===`system`?(0,X.jsxs)(`details`,{open:t||void 0,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-label text-xs font-medium text-outline hover:text-on-surface`,children:`injected context`}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:n})]}):n]},e.index)})})}),d&&!E&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`jump-to-latest`,onClick:()=>{x.current=!0,j()},className:`absolute bottom-4 right-6 inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 font-body text-xs text-primary shadow-lg hover:bg-surface-bright`,children:[(0,X.jsx)(O,{className:`h-3.5 w-3.5`}),`Jump to latest`,d.total>S.current&&` · ${d.total-S.current} new`]})]})]})})}var Te=[`claude`,`codex`,`cursor`,`cursor-agent`,`gemini`],Q=25,$=`font-label text-xs font-medium text-outline`;function Ee({projectId:e}){let t=M(`sm`),[n,r]=p(),i=n.get(`agent`)??``,a=n.get(`ended`)!==`0`,o=n.get(`q`)??``,s=n.get(`order`)===`asc`?`asc`:`desc`,c=n.get(`session`),[l,u]=(0,Y.useState)(o),[d,f]=(0,Y.useState)({order:s,page:0}),m=d.order===s?d.page:0,h=(0,Y.useCallback)(e=>f({order:s,page:e}),[s]),g=(0,Y.useCallback)((e,t)=>{h(0),r(n=>{let r=new URLSearchParams(n);return t?r.set(e,t):r.delete(e),r},{replace:e===`q`})},[r,h]);(0,Y.useEffect)(()=>u(o),[o]),(0,Y.useEffect)(()=>{if(l===o)return;let e=setTimeout(()=>g(`q`,l.trim()||null),350);return()=>clearTimeout(e)},[l,o,g]);let _=o.trim().length>=2,v=U(!a),y=ae(_?o.trim():``,i),{data:b}=E(),x=W(),S=new Map((b??[]).map(e=>[e.id,e.name])),C=_?y.data?.hits??[]:v.data??[],ee=[...new Set([...Te,...C.map(e=>e.agent)])],w=_?y.isLoading:v.isLoading,T=_?y:v,O=C.filter(e=>(!i||e.agent===i)&&(a||e.status!==`stopped`||e.handoff?.status===`ready`)),k=O.filter(t=>e===`all`?!0:e===`unassigned`?t.project_id===null:t.project_id===e).sort((e,t)=>{let n=new Date(e.last_activity_at??e.created_at).getTime()-new Date(t.last_activity_at??t.created_at).getTime()||e.id.localeCompare(t.id);return s===`asc`?n:-n}),A=Math.min(m,Math.max(0,Math.ceil(k.length/Q)-1))*Q,j=e===`unassigned`?`unassigned`:S.get(e)??e;return(0,X.jsxs)(`section`,{className:`mb-8`,"data-testid":`live-sessions`,children:[(0,X.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`Discovered from your coding agents. Working sessions update automatically; waiting sessions remain available to resume.`}),(0,X.jsxs)(`div`,{className:`mb-3 relative`,children:[(0,X.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-outline`}),(0,X.jsx)(`input`,{"data-testid":`session-search`,"aria-label":`Search agent sessions`,value:l,onChange:e=>u(e.target.value),placeholder:`Search agent sessions: titles, summaries and conversation text`,className:`w-full bg-background border border-control-border rounded-lg pl-9 pr-3 py-2 font-body text-xs text-on-surface placeholder:text-outline`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-4`,children:[(0,X.jsxs)(`h2`,{className:`font-label text-xs font-medium text-outline`,children:[_?`Search results`:`Agent sessions`,` · `,k.length,k.length!==O.length&&(0,X.jsxs)(`span`,{"data-testid":`scope-hint`,className:`normal-case tracking-normal`,children:[` `,`of `,O.length,` · scope: `,j]}),_&&y.data&&(0,X.jsxs)(`span`,{"data-testid":`search-meta`,className:`normal-case tracking-normal`,children:[` `,`· `,(y.data.ms/1e3).toFixed(1),`s`,y.data.rg?``:` · titles and summaries only (install ripgrep for content)`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`select`,{"aria-label":`Sort sessions by date`,"data-testid":`session-date-sort`,value:s,onChange:e=>g(`order`,e.target.value===`asc`?`asc`:null),className:`min-h-11 rounded-md border border-control-border bg-background px-3 text-sm text-on-surface`,children:[(0,X.jsx)(`option`,{value:`desc`,children:`Last active: newest first`}),(0,X.jsx)(`option`,{value:`asc`,children:`Last active: oldest first`})]}),(0,X.jsxs)(`select`,{"data-testid":`agent-filter`,"aria-label":`Agent`,className:`bg-background border border-control-border rounded-lg min-h-11 px-3 py-2 font-label text-xs font-medium text-on-surface`,value:i,onChange:e=>g(`agent`,e.target.value||null),children:[(0,X.jsx)(`option`,{value:``,children:`all agents`}),ee.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}),(0,X.jsxs)(`label`,{className:`flex items-center gap-2 font-label text-xs font-medium text-outline cursor-pointer`,children:[(0,X.jsx)(`input`,{type:`checkbox`,"data-testid":`show-ended`,checked:a,onChange:e=>g(`ended`,e.target.checked?`1`:`0`)}),`Show ended`]}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`sync-sessions`,disabled:x.isPending,className:`min-h-11 px-2 inline-flex items-center gap-1 font-label text-xs font-medium text-primary hover:text-on-surface disabled:opacity-50`,onClick:()=>x.mutate(),children:[(0,X.jsx)(D,{className:`h-3 w-3 ${x.isPending?`animate-spin`:``}`}),x.isPending?`Syncing`:`Refresh`]})]})]}),x.error&&(0,X.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-error`,children:x.error.message}),T.error?(0,X.jsx)(F,{message:T.error.message,onRetry:()=>T.refetch()}):w?(0,X.jsx)(`p`,{role:`status`,className:`py-8 text-sm text-outline`,children:`Loading sessions…`}):k.length===0?(0,X.jsx)(V,{message:_?`No sessions match`:`No active agent sessions. Enable Show ended to browse previous conversations.`}):(0,X.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[t?(0,X.jsxs)(ce,{children:[(0,X.jsx)(K,{children:(0,X.jsxs)(se,{className:`border-b border-border hover:bg-transparent`,children:[(0,X.jsx)(q,{className:`${$} w-40`,children:`Status`}),(0,X.jsx)(q,{className:`${$} w-20`,children:`Agent`}),(0,X.jsx)(q,{className:$,children:`Session`}),(0,X.jsx)(q,{className:`${$} w-28`,children:`Project`}),(0,X.jsx)(q,{className:`${$} w-20 text-right`,children:`Tokens`}),(0,X.jsx)(q,{className:`${$} w-36`,children:`Last active`}),(0,X.jsx)(q,{className:`${$} w-56`,children:`Task`}),(0,X.jsx)(q,{className:`${$} w-24`})]})}),(0,X.jsx)(oe,{children:k.slice(A,A+Q).map(e=>{let t=B[e.status];return(0,X.jsxs)(se,{"data-testid":`live-session-row`,"data-session-id":e.session_id,"data-agent":e.agent,className:`border-b border-border/65 cursor-pointer hover:bg-surface-high`,onClick:t=>{t.target.closest(`button, a, input, [role='dialog']`)||g(`session`,e.id)},children:[(0,X.jsx)(J,{className:`font-label text-xs text-on-surface`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,"data-testid":`live-status`,children:[(0,X.jsx)(`span`,{className:`h-2 w-2 rounded-full ${t.dot}`}),e.handoff?.status===`ready`?`Ready`:t.label]})}),(0,X.jsx)(J,{className:`font-label text-xs font-medium text-primary`,children:e.agent}),(0,X.jsxs)(J,{className:`max-w-md`,children:[(0,X.jsx)(`button`,{type:`button`,className:`block max-w-full text-left font-body text-sm font-medium text-on-surface truncate hover:text-primary`,onClick:t=>{t.stopPropagation(),g(`session`,e.id)},children:(0,X.jsx)(Z,{text:e.name??`Untitled session`,query:_?o:``})}),e.summary&&e.summary!==e.name&&(0,X.jsx)(`div`,{className:`font-body text-xs text-outline truncate`,title:e.summary,children:(0,X.jsx)(Z,{text:e.summary,query:_?o:``})}),e.snippets?.map(e=>(0,X.jsx)(`div`,{"data-testid":`search-snippet`,className:`font-mono text-xs text-on-surface-variant truncate`,title:e,children:(0,X.jsx)(Z,{text:e,query:o})},e)),(0,X.jsx)(`div`,{className:`font-label text-xs text-outline truncate`,title:e.cwd??void 0,children:e.cwd??``})]}),(0,X.jsx)(J,{className:`font-label text-xs text-outline`,children:e.project_id&&S.get(e.project_id)||`—`}),(0,X.jsx)(J,{"data-testid":`live-tokens`,className:`font-body text-xs text-on-surface-variant text-right`,children:R(e)}),(0,X.jsx)(J,{className:`font-body text-xs text-on-surface-variant`,children:I(e.last_activity_at)}),(0,X.jsx)(J,{children:(0,X.jsx)(me,{session:e})}),(0,X.jsx)(J,{className:`text-right`,children:(0,X.jsx)(`div`,{className:`inline-flex items-center gap-3`,children:(0,X.jsx)(ue,{session:e})})})]},e.id)})})]}):(0,X.jsx)(`div`,{className:`divide-y divide-border`,children:k.slice(A,A+Q).map(e=>(0,X.jsxs)(`article`,{"data-testid":`live-session-row`,"data-session-id":e.session_id,"data-agent":e.agent,className:`py-4 space-y-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`text-left text-sm font-medium wrap-break-word hover:text-primary`,onClick:()=>g(`session`,e.id),children:(0,X.jsx)(Z,{text:e.name??`Untitled session`,query:_?o:``})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-outline`,children:[(0,X.jsx)(`span`,{className:`text-primary`,children:e.agent}),(0,X.jsx)(`span`,{"data-testid":`live-status`,children:e.handoff?.status===`ready`?`Ready`:B[e.status].label}),(0,X.jsxs)(`span`,{"data-testid":`live-tokens`,children:[R(e),` tokens`]}),(0,X.jsx)(`span`,{children:I(e.last_activity_at)})]}),e.summary&&(0,X.jsx)(`p`,{className:`text-sm text-outline wrap-break-word`,children:(0,X.jsx)(Z,{text:e.summary,query:_?o:``})}),e.snippets?.map(e=>(0,X.jsx)(`p`,{"data-testid":`search-snippet`,className:`text-xs wrap-break-word text-on-surface-variant`,children:(0,X.jsx)(Z,{text:e,query:o})},e)),(0,X.jsxs)(`p`,{className:`text-xs text-outline break-all`,children:[e.project_id&&S.get(e.project_id)||`Unassigned`,e.cwd?` · ${e.cwd}`:``]}),(0,X.jsx)(me,{session:e}),(0,X.jsx)(ue,{session:e})]},e.id))}),(0,X.jsx)(ie,{page:A/Q,pageSize:Q,total:k.length,onPage:h})]}),(0,X.jsx)(we,{sessionId:c,initialQuery:_?o.trim():``,onClose:()=>g(`session`,null)},c??`closed`)]})}function De({projectId:e}){let t=le(e);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(re,{title:`Sessions`}),(0,X.jsx)(Ee,{projectId:t},t),(0,X.jsx)(fe,{projectId:t},`archive-${t}`)]})}export{De as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{
|
|
2
|
-
`))}).catch(t=>{e||
|
|
3
|
-
`).filter(e=>e.trim()).map(e=>{let t=e.match(/^([a-z][a-z0-9-]*):\s*(.+)$/i);if(!t)throw Error(`Use agent: model-id on each model line.`);return{agent:t[1]??``,id:t[2]??``}}),i=
|
|
4
|
-
claude: your-model-id`}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`One agent: model-id per line. Use model IDs supported by your installed agent and account.`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(
|
|
5
|
-
`)})]}),O?.state===`failed`&&(0,F.jsx)(`p`,{role:`alert`,className:`text-xs text-error`,children:O.error}),e.installed?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`settings-docling-enabled`,checked:a.docling_enabled,onChange:e=>E({docling_enabled:e.target.checked})}),`Use automatically for PDFs and images`]}),(0,F.jsxs)(i,{type:`button`,size:`sm`,variant:`ghost`,className:`text-error`,"data-testid":`settings-docling-remove`,onClick:()=>C(!0),children:[(0,F.jsx)(g,{size:14}),`Remove`]})]}):(0,F.jsxs)(i,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`settings-docling-install`,disabled:b||O?.state===`installing`,onClick:()=>k(()=>v.kb.installDocling()),children:[(0,F.jsx)(m,{size:14}),O?.state===`installing`?`Installing…`:`Install Docling (${J(D?.size_bytes??null)||`about 2 GB`})`]})]})]},e.id)),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-parser`,className:`text-sm text-muted-foreground`,children:`Default parser`}),(0,F.jsxs)(d,{value:a.parser,onValueChange:e=>E({parser:e}),disabled:T(`PARSER`),children:[(0,F.jsx)(c,{id:`settings-kb-parser`,"data-testid":`settings-kb-parser`,children:(0,F.jsx)(s,{})}),(0,F.jsxs)(l,{children:[(0,F.jsx)(u,{value:`auto`,children:`Automatic: Docling for PDFs and images when enabled`}),t.data?.parsers.map(e=>(0,F.jsx)(u,{value:e.id,disabled:!e.installed,children:e.label},e.id))]})]}),(0,F.jsx)(`p`,{className:`text-xs text-outline`,children:`Knowledge bases can override it. Changing parsers applies to new uploads; reparse a document to apply it to existing ones.`})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-timeout`,className:`text-sm text-muted-foreground`,children:`Parse timeout (s)`}),(0,F.jsx)(N,{id:`settings-kb-timeout`,type:`number`,min:10,value:a.parser_timeout_secs,onChange:e=>E({parser_timeout_secs:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-max-upload`,className:`text-sm text-muted-foreground`,children:`Max upload (MB)`}),(0,F.jsx)(N,{id:`settings-kb-max-upload`,type:`number`,min:1,value:a.max_upload_mb,onChange:e=>E({max_upload_mb:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-retention`,className:`text-sm text-muted-foreground`,children:`Read log (days)`}),(0,F.jsx)(N,{id:`settings-kb-retention`,type:`number`,min:1,value:a.usage_retention_days,onChange:e=>E({usage_retention_days:e.target.value})})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`text-sm font-medium`,children:`Semantic search`}),(0,F.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`settings-session-embeddings`,checked:a.session_embeddings,onChange:e=>E({session_embeddings:e.target.checked})}),(0,F.jsxs)(`span`,{children:[`Search coding sessions with embeddings`,(0,F.jsx)(`span`,{className:`block text-xs text-outline`,children:`Uses the provider below for session passages. Keyword search and transcript reading remain available when off. Enabling sends session text to this provider and indexes discovered project sessions.`})]})]}),n.data&&(0,F.jsxs)(`p`,{className:`text-xs text-outline`,"data-testid":`settings-embedding-status`,children:[n.data.embedding.ready?`Ready · ${n.data.embedding.model} · ${n.data.embedding.vector_backend}`:n.data.embedding.detail??`Not configured`,n.data.embedding.pending_chunks?` · ${n.data.embedding.pending_chunks} passages waiting`:``]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-provider`,className:`text-sm text-muted-foreground`,children:`Embedding provider`}),(0,F.jsxs)(d,{value:a.provider,onValueChange:e=>E({provider:e}),disabled:T(`EMBEDDING_PROVIDER`),children:[(0,F.jsx)(c,{id:`settings-kb-provider`,"data-testid":`settings-kb-provider`,children:(0,F.jsx)(s,{})}),(0,F.jsxs)(l,{children:[(0,F.jsx)(u,{value:`none`,children:`None`}),(0,F.jsx)(u,{value:`ollama`,children:`Ollama`}),(0,F.jsx)(u,{value:`openai`,children:`OpenAI-compatible`})]})]}),(0,F.jsx)(`p`,{className:`text-xs text-outline`,children:Ae[a.provider]})]}),a.provider!==`none`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-model`,className:`text-sm text-muted-foreground`,children:`Model`}),(0,F.jsx)(N,{id:`settings-kb-model`,"data-testid":`settings-kb-model`,value:a.model,disabled:T(`EMBEDDING_MODEL`),onChange:e=>E({model:e.target.value}),placeholder:a.provider===`ollama`?`nomic-embed-text`:`text-embedding-3-small`})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-dimensions`,className:`text-sm text-muted-foreground`,children:`Dimensions`}),(0,F.jsx)(N,{id:`settings-kb-dimensions`,type:`number`,value:a.dimensions,onChange:e=>E({dimensions:e.target.value}),placeholder:`Model default`})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-base-url`,className:`text-sm text-muted-foreground`,children:`Base URL`}),(0,F.jsx)(N,{id:`settings-kb-base-url`,"data-testid":`settings-kb-base-url`,value:a.base_url,disabled:T(`EMBEDDING_URL`),onChange:e=>E({base_url:e.target.value}),placeholder:a.provider===`ollama`?`http://localhost:11434`:`https://api.openai.com/v1`})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(f,{htmlFor:`settings-kb-api-key`,className:`text-sm text-muted-foreground`,children:a.provider===`ollama`?`Token (hosted or proxied Ollama)`:`API key`}),(0,F.jsx)(N,{id:`settings-kb-api-key`,type:`password`,autoComplete:`off`,"data-testid":`settings-kb-api-key`,value:a.api_key,disabled:a.clear_key||T(`EMBEDDING_API_KEY`),onChange:e=>E({api_key:e.target.value}),placeholder:w.embedding.api_key_set?`Saved. Type to replace`:`Not set`}),w.embedding.api_key_set&&(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-outline`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`settings-kb-api-key-clear`,checked:a.clear_key,onChange:e=>E({clear_key:e.target.checked,api_key:``})}),`Remove the saved key`]}),(0,F.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Stored encrypted with the key in `,(0,F.jsx)(`code`,{children:`~/.orc/secret.key`}),` and never sent back to the browser. Sent as a bearer token to the base URL.`]})]}),(0,F.jsx)(`p`,{className:`text-xs text-outline`,children:`Changing the model re-embeds every passage in the background; keyword search keeps working meanwhile.`})]})]}),p&&(0,F.jsx)(`p`,{role:`alert`,"data-testid":`settings-knowledge-error`,className:`text-sm text-error`,children:p}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(i,{type:`submit`,"data-testid":`settings-knowledge-save`,disabled:b,children:`Save knowledge settings`}),_&&(0,F.jsx)(`span`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saved`})]})]}),(0,F.jsx)(me,{open:S,title:`Remove Docling`,description:`Deletes the Docling runtime and models from this machine. Documents it parsed keep their text; reparse them to use the basic parser.`,confirmLabel:`Remove`,isPending:b,onCancel:()=>C(!1),onConfirm:async()=>{C(!1),await k(()=>v.kb.uninstallDocling())}})]})}var Me=[`fcm.googleapis.com`,`updates.push.services.mozilla.com`,`web.push.apple.com`],Ne=[`.push.apple.com`,`.notify.windows.com`];function Pe(e){let t;try{t=new URL(e)}catch{return!1}if(t.protocol!==`https:`||t.username||t.password||t.port)return!1;let n=t.hostname.toLowerCase();return Me.includes(n)||Ne.some(e=>n.endsWith(e))}var Y=A().min(1).max(512).regex(/^[A-Za-z0-9_-]+={0,2}$/,`Expected a base64url key`),X=pe([`attention`,`chat`]),Fe=X.options;M({endpoint:A().max(2048).refine(Pe,`Endpoint must be a known browser push service`),keys:M({p256dh:Y,auth:Y}).strict(),label:A().trim().min(1).max(120),topics:k(X).max(2).optional()}).strict(),M({topics:k(X).max(2)}).strict(),M({id:A(),label:A(),endpoint_host:A(),topics:k(X),created_at:w(),last_success_at:w().nullable(),failure_count:w().int()}),M({public_key:A()}),M({title:A().max(200),body:A().max(500),url:A().max(2048),tag:A().max(200)});var Ie={attention:`Attention needed (approvals and questions from agents)`,chat:`Chat replies and chat approvals`},Le={insecure:`Notifications need HTTPS. Open ORC through an https:// address to enable them.`,"install-required":`On iPhone and iPad, add ORC to the Home Screen (Share → Add to Home Screen), then open it from there.`,unsupported:`This browser does not support push notifications.`};function Re(...e){return e.find(Boolean)?.message}function ze(e){return e?new Date(e).toLocaleString():`never`}function Z({device:e}){let t=le(),n=(n,r)=>{let i=r?[...e.topics,n]:e.topics.filter(e=>e!==n);t.mutate({id:e.id,topics:i})};return(0,F.jsxs)(`fieldset`,{className:`space-y-2`,disabled:t.isPending,children:[(0,F.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Notify this device about`}),Fe.map(t=>(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`push-topic-${t}`,checked:e.topics.includes(t),onChange:e=>n(t,e.target.checked)}),Ie[t]]},t))]})}function Be(){let e=te(),t=se(),n=ce(),r=oe(),a=ue(),o=ae(),s=ee(),c=t.data??null,l=(n.data??[]).filter(e=>e.id!==c?.id),u=Re(r.error,a.error,o.error,s.error);return(0,F.jsxs)(`section`,{"aria-labelledby":`notifications-title`,children:[(0,F.jsx)(`h2`,{id:`notifications-title`,className:`mb-1 text-base font-medium`,children:`Notifications`}),(0,F.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:`Get a push notification on this device when an agent needs your approval or answer, or a chat reply is ready. Notifications are skipped while ORC is open and focused.`}),(0,F.jsx)(K,{className:`mb-4`}),e===`supported`?(0,F.jsxs)(`div`,{className:`space-y-4`,children:[c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Z,{device:c}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsxs)(i,{variant:`outline`,"data-testid":`push-test`,disabled:s.isPending,onClick:()=>s.mutate(c.id),children:[(0,F.jsx)(De,{className:`mr-2 size-4`}),`Send test notification`]}),(0,F.jsxs)(i,{variant:`outline`,"data-testid":`push-disable`,disabled:a.isPending,onClick:()=>a.mutate(c.id),children:[(0,F.jsx)(Ce,{className:`mr-2 size-4`}),`Turn off on this device`]})]})]}):(0,F.jsxs)(i,{"data-testid":`push-enable`,disabled:r.isPending||t.isLoading,onClick:()=>r.mutate(),children:[(0,F.jsx)(ie,{className:`mr-2 size-4`}),r.isPending?`Enabling…`:`Enable notifications on this device`]}),s.data&&(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:s.data.sent?`Test sent. Switch away from ORC to see it.`:`Test not delivered.`})]}):(0,F.jsx)(`p`,{"data-testid":`push-unsupported`,className:`text-sm text-muted-foreground`,children:Le[e]}),u&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-error`,children:u}),l.length>0&&(0,F.jsxs)(`div`,{className:`mt-6`,children:[(0,F.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Other devices`}),(0,F.jsx)(`ul`,{className:`space-y-2`,"data-testid":`push-devices`,children:l.map(e=>(0,F.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,F.jsxs)(`span`,{className:`min-w-0`,children:[(0,F.jsx)(`span`,{className:`block truncate`,children:e.label}),(0,F.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Last delivered `,ze(e.last_success_at),e.failure_count>0&&` · ${e.failure_count} failed`]})]}),(0,F.jsx)(i,{variant:`ghost`,size:`icon`,"aria-label":`Remove ${e.label}`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:(0,F.jsx)(g,{className:`size-4`})})]},e.id))})]})]})}function Ve(){let e=r();return a({mutationFn:async()=>{let e=await v.system.restart(),t=Date.now()+6e4;for(;Date.now()<t;){await new Promise(e=>setTimeout(e,500));try{if((await v.health.check(AbortSignal.timeout(2e3))).instance_id!==e.instance_id)return}catch(e){if(e instanceof b&&e.status===401)throw e}}throw Error(`ORC has not reconnected yet. Check the server and try again when it is online.`)},onSuccess:()=>e.invalidateQueries()})}function He(){let{data:e}=ne(),t=Ve();return(0,F.jsxs)(`section`,{"aria-labelledby":`server-title`,children:[(0,F.jsx)(`h2`,{id:`server-title`,className:`mb-1 text-base font-medium`,children:`ORC server`}),(0,F.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:`Restart ORC to reload server and host information. This closes active terminals and may interrupt running work. Your settings are kept, and this dashboard reconnects automatically. Switching hosts applies to new actions without a restart.`}),(0,F.jsx)(K,{className:`mb-4`}),(0,F.jsxs)(i,{variant:`outline`,"data-testid":`settings-restart`,disabled:!e?.restart_supported||t.isPending,onClick:()=>t.mutate(),children:[(0,F.jsx)(Ee,{className:t.isPending?`mr-2 size-4 animate-spin`:`mr-2 size-4`}),t.isPending?`Restarting and reconnecting…`:`Restart ORC server`]}),e&&!e.restart_supported&&(0,F.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`This server does not support restart from the dashboard.`}),t.isPending&&(0,F.jsx)(`p`,{role:`status`,"data-testid":`settings-restart-status`,className:`mt-2 text-sm text-muted-foreground`,children:`Waiting for ORC to restart…`}),t.isSuccess&&(0,F.jsx)(`p`,{role:`status`,"data-testid":`settings-restart-status`,className:`mt-2 text-sm text-muted-foreground`,children:`ORC restarted. Reconnected.`}),t.isError&&(0,F.jsx)(`p`,{role:`alert`,"data-testid":`settings-restart-error`,className:`mt-2 text-sm text-error`,children:t.error.message})]})}var Q=`__local__`;function $(e){return e?e instanceof Error?e.message:String(e):null}function Ue(){let{data:e,error:t,refetch:n}=O(),{data:r}=re(),a=fe(),o=S(),[p,m]=(0,P.useState)(Q),[g,_]=(0,P.useState)(``);if((0,P.useEffect)(()=>{e&&(m(e.host??Q),_(e.remote_port===null?``:String(e.remote_port)))},[e]),t)return(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:`Execution host`}),(0,F.jsx)(he,{message:t.message,onRetry:()=>void n()})]});if(!e)return(0,F.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,className:`text-sm text-muted-foreground`,children:`Loading execution host…`});let v=p===Q?null:p,y=e.host&&!e.hosts.includes(e.host)?[e.host,...e.hosts]:e.hosts,b=Number(g),x=g.trim()===``||Number.isInteger(b)&&b>=1&&b<=65535,C=e.locked||!e.supported,w=r?.backends.find(e=>e.name===`claude`),T=o.data?.host===v?o.data:void 0;return(0,F.jsxs)(`section`,{"data-testid":`ssh-settings`,children:[(0,F.jsx)(`h2`,{className:`font-headline font-semibold text-base text-on-surface mb-1`,children:`Execution host`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground mb-4`,children:[`Run every agent, terminal, git and file action on a host from`,` `,(0,F.jsx)(`code`,{className:`text-primary`,children:`~/.ssh/config`}),`. Agents there reach orc through a reverse tunnel on the remote port. Terminals already open keep their host.`]}),(0,F.jsx)(K,{className:`bg-surface-highest mb-4`}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[e.locked&&(0,F.jsx)(`p`,{"data-testid":`ssh-locked`,className:`font-body text-sm text-tertiary`,children:`Fixed by ORC_SSH_HOST in orc's environment.`}),!e.supported&&(0,F.jsx)(`p`,{"data-testid":`ssh-unsupported`,className:`font-body text-sm text-error`,children:e.unsupported_reason}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(f,{htmlFor:`ssh-host`,className:`font-label text-sm text-muted-foreground`,children:`Host`}),(0,F.jsxs)(d,{value:p,onValueChange:m,disabled:C,children:[(0,F.jsx)(c,{id:`ssh-host`,"aria-label":`Execution host`,"data-testid":`ssh-host-picker`,className:`bg-surface-highest border-control-border text-on-surface font-body text-sm`,children:(0,F.jsx)(s,{})}),(0,F.jsxs)(l,{className:`bg-surface-highest border-outline-variant max-h-72`,children:[(0,F.jsx)(u,{value:Q,"data-testid":`ssh-host-option-local`,className:`font-label text-sm`,children:`Local (this machine)`}),y.map(e=>(0,F.jsx)(u,{value:e,"data-testid":`ssh-host-option-${e}`,className:`font-label text-sm`,children:e},e))]})]}),y.length===0&&(0,F.jsx)(`p`,{"data-testid":`page-empty`,className:`font-body text-sm text-muted-foreground`,children:`No Host entries found in ~/.ssh/config on the machine running orc.`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(f,{htmlFor:`ssh-remote-port`,className:`font-label text-sm text-muted-foreground`,children:`Tunnel port override`}),(0,F.jsx)(N,{id:`ssh-remote-port`,"aria-invalid":!(!v||x),"data-testid":`ssh-remote-port`,value:g,placeholder:`Automatic`,onChange:e=>_(e.target.value),disabled:C||!v,inputMode:`numeric`,className:`bg-surface-highest border-outline-variant text-on-surface font-body text-sm`}),v&&!x&&(0,F.jsx)(`p`,{className:`text-sm text-error`,children:`Enter a remote port from 1 to 65535.`}),(0,F.jsx)(`p`,{className:`font-body text-sm text-muted-foreground`,children:`Leave empty to let SSH choose an available port automatically.`})]}),(0,F.jsxs)(`div`,{className:`flex gap-3`,children:[(0,F.jsxs)(i,{"data-testid":`ssh-save`,disabled:C||v!==null&&!x||a.isPending,onClick:()=>a.mutate({host:v,remotePort:v&&g.trim()?b:null}),className:`font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,F.jsx)(h,{size:12,className:`mr-1.5`}),` Use Host`]}),(0,F.jsxs)(i,{"data-testid":`ssh-test`,variant:`ghost`,disabled:!v||!e.supported||o.isPending,onClick:()=>v&&o.mutate(v),className:`font-label text-sm text-muted-foreground hover:text-on-surface`,children:[(0,F.jsx)(Te,{size:12,className:`mr-1.5`}),` `,o.isPending?`Testing…`:`Test`]})]}),$(a.error??o.error)&&(0,F.jsx)(`p`,{"data-testid":`ssh-error`,className:`font-body text-sm text-error`,children:$(a.error??o.error)}),T&&(0,F.jsx)(`div`,{"data-testid":`ssh-test-result`,className:`font-body text-sm space-y-1`,children:T.ok?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`text-secondary`,children:[`Connected to `,T.host,` (`,T.os,`, `,T.shell,`)`]}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:Object.entries(T.binaries).map(([e,t])=>`${t?`●`:`○`} ${e}`).join(` `)}),T.binaries.claude&&T.claude_logged_in===!1&&(0,F.jsxs)(`p`,{className:T.api_key_forwarded?`text-muted-foreground`:`text-error`,children:[`claude is not logged in on `,T.host,`.`,` `,T.api_key_forwarded?`ANTHROPIC_API_KEY from orc's environment will be forwarded.`:`Set ANTHROPIC_API_KEY in orc's environment or run claude login there.`]})]}):(0,F.jsx)(`p`,{className:`text-error`,children:T.error})}),e.host&&w&&!w.available&&(0,F.jsxs)(`p`,{"data-testid":`ssh-claude-error`,className:`font-body text-sm text-error`,children:[`claude backend: `,w.error]})]})]})}function We(){let{theme:e}=de(),[t,n]=(0,P.useState)(_),[a,o]=(0,P.useState)(()=>localStorage.getItem(`orc_terminal_font`)??``),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(``),[d,p]=(0,P.useState)(``),[m,g]=(0,P.useState)(!1),b=r(),x=async()=>{p(``),g(!0);try{let n=t.trim();if(n&&!n.startsWith(`/`)&&!/^https?:\/\//i.test(n))throw Error(`Use a relative API path or an http(s) server URL.`);let r=await v.settings.save({theme:e,terminal_font:a.trim()});j(r.theme??e),o(r.terminal_font??``),r.terminal_font?localStorage.setItem(C,r.terminal_font):localStorage.removeItem(C);let i=(n||`/api`)!==_();localStorage.setItem(`orc_api_url`,n||`/api`),i&&window.dispatchEvent(new Event(y)),b.invalidateQueries(),c(!0),u(`Workspace preferences saved on the server. API address saved in this browser.`),setTimeout(()=>c(!1),2e3)}catch(e){p(e instanceof Error?e.message:`Browser settings could not be saved.`)}finally{g(!1)}},S=async()=>{p(``),g(!0);try{let e=await v.settings.save({terminal_font:``});localStorage.removeItem(`orc_api_url`),localStorage.setItem(C,e.terminal_font??``),n(`/api`),o(e.terminal_font??``),window.dispatchEvent(new Event(y)),b.invalidateQueries(),c(!1),u(`Connection and terminal font restored to their defaults. Appearance and execution host were kept.`)}catch(e){p(e instanceof Error?e.message:`Browser settings could not be reset.`)}finally{g(!1)}};async function w(e){p(``),g(!0);try{let t=await v.settings.save({theme:e});j(t.theme??e)}catch(e){p(e instanceof Error?e.message:`Appearance could not be saved.`)}finally{g(!1)}}return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(ge,{title:`Settings`}),(0,F.jsxs)(`div`,{className:`max-w-lg space-y-8`,children:[(0,F.jsxs)(`section`,{"aria-labelledby":`appearance-title`,children:[(0,F.jsx)(`h2`,{id:`appearance-title`,className:`mb-1 text-base font-medium`,children:`Appearance`}),(0,F.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:`Choose a workspace theme. Your choice is saved on the server immediately.`}),(0,F.jsx)(`fieldset`,{className:`flex flex-wrap gap-2`,"aria-label":`Theme`,children:[`dark`,`light`].map(t=>(0,F.jsx)(i,{variant:e===t?`secondary`:`outline`,"aria-pressed":e===t,"data-testid":`settings-theme-${t}`,disabled:m,onClick:()=>void w(t),children:t===`dark`?`Dark`:`Light`},t))})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`font-headline font-medium text-base text-on-surface mb-1`,children:`API connection`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground mb-4`,children:[`Connect this workspace to an ORC server. The default`,` `,(0,F.jsx)(`code`,{className:`text-primary`,children:`/api`}),` uses the current server or the configured development proxy.`]}),(0,F.jsx)(K,{className:`bg-outline-variant mb-4`}),(0,F.jsx)(`div`,{className:`space-y-4`,children:(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(f,{htmlFor:`settings-api-url`,className:`font-label text-sm text-muted-foreground`,children:`API base URL`}),(0,F.jsx)(N,{id:`settings-api-url`,"data-testid":`settings-api-url`,value:t,onChange:e=>n(e.target.value),placeholder:`/api or http://localhost:7700`,className:`bg-background text-on-surface font-body text-sm`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground`,children:[`Use `,(0,F.jsx)(`code`,{children:`/api`}),` (dev proxy) or a direct URL when CORS is enabled.`]})]})})]}),(0,F.jsx)(Ue,{}),(0,F.jsx)(He,{}),(0,F.jsx)(Be,{}),(0,F.jsx)(Oe,{}),(0,F.jsx)(je,{}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`font-headline font-medium text-base text-on-surface mb-1`,children:`Terminal`}),(0,F.jsx)(`p`,{className:`font-body text-sm text-muted-foreground mb-4`,children:`Prompt and agent status icons need a Nerd Font installed on this machine. Common ones are tried automatically; set the exact family name if your icons show as empty boxes. Applies to terminals opened after saving.`}),(0,F.jsx)(K,{className:`bg-outline-variant mb-4`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(f,{htmlFor:`settings-terminal-font`,className:`font-label text-sm text-muted-foreground`,children:`Terminal font family`}),(0,F.jsx)(N,{id:`settings-terminal-font`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. MesloLGS NF`,className:`bg-background text-on-surface font-body text-sm`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3 pt-2`,children:[(0,F.jsx)(i,{"data-testid":`settings-save`,disabled:m,onClick:()=>void x(),className:`font-label text-sm `,children:s?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(we,{size:12,className:`mr-1.5`}),` Saved`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{size:12,className:`mr-1.5`}),` Save settings`]})}),(0,F.jsx)(i,{variant:`ghost`,disabled:m,onClick:()=>void S(),className:`font-label text-sm text-muted-foreground hover:text-on-surface`,children:`Reset to defaults`})]}),d&&(0,F.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:d}),l&&!d&&(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:l}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(K,{className:`bg-outline-variant mb-4`}),(0,F.jsx)(`div`,{className:`font-label text-sm text-muted-foreground mb-2`,children:`Storage`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground`,children:[`Workspace preferences and SSH selection are persisted in the server's`,` `,(0,F.jsx)(`code`,{children:`~/.orc/config.json`}),`. The API address and optionally remembered login are stored in this browser.`]})]})]})]})}export{We as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{t as i}from"./useMutation-HX90wI4L.js";import{r as a,t as o}from"./button-BHKbOsmj.js";import{t as s}from"./dist-HH469UWY.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-CBHDS40x.js";import{t as p}from"./label-BQ1Lr4sA.js";import{t as m}from"./createLucideIcon-jLuHkL03.js";import{t as h}from"./download-WG9NKrMe.js";import{t as g}from"./save-3DxWVsBU.js";import{a as _,n as v,s as y,t as b}from"./client-BwhkVepQ.js";import{Ct as x,Ft as S,Kt as C,Mt as w,Nt as T,Rt as E,St as D,Vt as O,Yt as k,_ as A,a as ee,c as te,d as ne,en as j,ft as re,i as ie,n as ae,o as oe,qt as M,r as se,s as ce,t as le,v as ue,vn as de,wt as N,xt as fe,zt as pe}from"./index-CMRGRbC9.js";import{t as me}from"./ConfirmDialog-D25Wf6Nc.js";import{t as he}from"./ErrorState-BoQqdsym.js";import{t as ge}from"./ViewHeader-DHM9SSkD.js";import{d as _e,g as ve,m as ye,n as be}from"./useKnowledge-DbjT1a0E.js";var P=e(t(),1),F=n(),xe=Object.defineProperty,I=(e,t)=>xe(e,`name`,{value:t,configurable:!0}),L={Horizontal:`horizontal`,Vertical:`vertical`},R=L.Horizontal,Se=Object.values(L),z=P.forwardRef(I(function(e,t){let{decorative:n,orientation:r=R,...i}=e,a=B(r)?r:R,o=a===L.Vertical?a:void 0,c=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,F.jsx)(s.div,{"data-orientation":a,...c,...i,ref:t})},`Separator`));function B(e){return Se.includes(e)}I(B,`isValidOrientation`);var V={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};V.node;var Ce=m(V),H={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};H.node;var we=m(H),U={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};U.node;var Te=m(U),W={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};W.node;var Ee=m(W),G={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};G.node;var De=m(G);function Oe(){let[e,t]=(0,P.useState)(null),[n,r]=(0,P.useState)(``),[i,a]=(0,P.useState)(``),[s,c]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let e=!1;return v.settings.get().then(n=>{if(e)return;let i=E.parse(n.chat??{});t(i),r(i.models.map(e=>`${e.agent}: ${e.id}`).join(`
|
|
2
|
+
`))}).catch(t=>{e||a(t.message)}),()=>{e=!0}},[]);async function l(){if(e){c(!0),a(``);try{let r=n.split(`
|
|
3
|
+
`).filter(e=>e.trim()).map(e=>{let t=e.match(/^([a-z][a-z0-9-]*):\s*(.+)$/i);if(!t)throw Error(`Use agent: model-id on each model line.`);return{agent:t[1]??``,id:t[2]??``}}),i=E.parse({...e,models:r});await v.settings.save({chat:i}),t(i),window.dispatchEvent(new Event(`orc-chat-settings-changed`)),a(`Chat defaults saved. They apply to new conversations on every device.`)}catch(e){a(e instanceof Error?e.message:`Chat settings could not be saved.`)}finally{c(!1)}}}return(0,F.jsxs)(`section`,{"aria-labelledby":`chat-settings-title`,className:`space-y-4`,"data-testid":`chat-settings`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{id:`chat-settings-title`,className:`text-base font-medium`,children:`Chat`}),(0,F.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Defaults for new conversations. Existing chats keep their configuration. Credentials stay on the execution host.`})]}),e&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`chat-default-agent`,children:`Default agent`}),(0,F.jsx)(N,{id:`chat-default-agent`,"data-testid":`chat-default-agent`,value:e.agent,onChange:n=>t({...e,agent:n.target.value})})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`chat-default-model`,children:`Default model`}),(0,F.jsx)(N,{id:`chat-default-model`,"data-testid":`chat-default-model`,value:e.model,placeholder:`Agent default`,onChange:n=>t({...e,model:n.target.value})})]})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`chat-model-catalog`,children:`Model picker choices`}),(0,F.jsx)(T,{id:`chat-model-catalog`,"data-testid":`chat-model-catalog`,value:n,onChange:e=>r(e.target.value),placeholder:`codex: your-model-id
|
|
4
|
+
claude: your-model-id`}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`One agent: model-id per line. Use model IDs supported by your installed agent and account.`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`chat-system-prompt`,children:`Instructions`}),(0,F.jsx)(T,{id:`chat-system-prompt`,"data-testid":`chat-system-prompt`,rows:6,value:e.system,onChange:n=>t({...e,system:n.target.value})}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Claude appends these to its coding system prompt. Codex and other agents receive them as turn instructions. Workspace rules remain enforced.`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`chat-mcp`,children:`Tools connection`}),(0,F.jsxs)(`select`,{id:`chat-mcp`,"data-testid":`chat-mcp`,className:`min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-base sm:text-sm`,value:e.mcp,onChange:n=>t({...e,mcp:n.target.value}),children:[(0,F.jsx)(`option`,{value:`orc`,children:`Connect ORC MCP (Claude and Codex)`}),(0,F.jsx)(`option`,{value:`native`,children:`Use the agent’s host configuration`})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The ORC connection uses server credentials internally and serves meta tools that search, describe and invoke every ORC tool on demand. Host configuration may include other MCP servers; this setting does not disable them. Protected workspaces may also require ORC tools.`})]}),(0,F.jsx)(w,{config:e,onChange:t,disabled:s}),(0,F.jsx)(o,{"data-testid":`chat-settings-save`,disabled:s,onClick:()=>void l(),children:s?`Saving…`:`Save chat defaults`})]}),i&&(0,F.jsx)(`p`,{role:`status`,"data-testid":`chat-settings-feedback`,className:`wrap-break-word text-sm text-muted-foreground`,children:i})]})}var K=P.forwardRef(({className:e,orientation:t=`horizontal`,decorative:n=!0,...r},i)=>(0,F.jsx)(z,{ref:i,decorative:n,orientation:t,className:a(`shrink-0 bg-surface-bright `,t===`horizontal`?`h-px w-full`:`h-full w-px`,e),...r}));K.displayName=z.displayName;var q=1048576;function J(e){return e===null?``:e>=1024*q?`${(e/1024/q).toFixed(1)} GB`:`${Math.round(e/q)} MB`}function ke(e){return{session_embeddings:e.session_embeddings??!1,parser:e.parser,docling_enabled:e.docling_enabled,parser_timeout_secs:String(e.parser_timeout_secs),max_upload_mb:String(Math.round(e.max_upload_bytes/q)),usage_retention_days:String(e.usage_retention_days),provider:e.embedding.provider,base_url:e.embedding.base_url??``,model:e.embedding.model??``,dimensions:e.embedding.dimensions?String(e.embedding.dimensions):``,api_key:``,clear_key:!1}}var Ae={none:`Keyword search only. Add an embedding provider for semantic and hybrid search.`,ollama:`Local embeddings from Ollama, for example nomic-embed-text at http://localhost:11434.`,openai:`OpenAI or any OpenAI-compatible endpoint, for example text-embedding-3-small.`};function je(){let e=ye(),t=_e(),n=ve(),r=be(),[i,a]=(0,P.useState)(null),[s,m]=(0,P.useState)(null),[g,_]=(0,P.useState)(!1),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(!1);if((0,P.useEffect)(()=>{e.data&&a(ke(e.data))},[e.data]),e.error)return(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`mb-1 text-base font-medium`,children:`Knowledge`}),(0,F.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:e.error.message})]});if(!i||!e.data)return null;let C=e.data,w=e=>C.env_overrides.includes(`ORC_KNOWLEDGE_${e}`),T=e=>{_(!1),a({...i,...e})},E=t.data?.parsers.find(e=>e.id===`docling`),D=t.data?.docling;async function O(e){b(!0),m(null);try{return await e(),await r(),!0}catch(e){return m(e instanceof Error?e.message:`Request failed`),!1}finally{b(!1)}}async function k(e){if(e.preventDefault(),!i)return;let t={session_embeddings:i.session_embeddings,parser:i.parser,docling_enabled:i.docling_enabled,parser_timeout_secs:Number(i.parser_timeout_secs),max_upload_bytes:Number(i.max_upload_mb)*q,usage_retention_days:Number(i.usage_retention_days),embedding:{provider:i.provider,base_url:i.base_url.trim()||null,model:i.model.trim()||null,dimensions:(e=>e.trim()?Number(e):null)(i.dimensions),...i.clear_key?{api_key:null}:i.api_key?{api_key:i.api_key}:{}}};await O(()=>v.kb.updateSettings(t))&&_(!0)}return(0,F.jsxs)(`section`,{"data-testid":`settings-knowledge`,"aria-labelledby":`settings-knowledge-title`,children:[(0,F.jsx)(`h2`,{id:`settings-knowledge-title`,className:`mb-1 text-base font-medium text-on-surface`,children:`Knowledge`}),(0,F.jsxs)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:[`How ORC parses uploads and searches knowledge bases. Saved on the server in`,` `,(0,F.jsx)(`code`,{className:`text-primary`,children:`~/.orc/config.json`}),`; files live in`,` `,(0,F.jsx)(`code`,{className:`break-all text-primary`,children:C.root}),`.`]}),(0,F.jsx)(K,{className:`mb-4 bg-outline-variant`}),C.env_overrides.length>0&&(0,F.jsxs)(`p`,{className:`mb-4 text-sm text-warning`,"data-testid":`settings-knowledge-env`,children:[`Set by environment, these win over saved values: `,C.env_overrides.join(`, `)]}),(0,F.jsxs)(`form`,{onSubmit:k,className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`text-sm font-medium`,children:`Parsers`}),t.data?.parsers.map(e=>(0,F.jsxs)(`div`,{"data-testid":`settings-parser-${e.id}`,className:`rounded-md border border-outline-variant p-3 text-sm`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,F.jsxs)(`span`,{className:`text-xs text-outline`,children:[e.installed?`v${e.version}`:`not installed`,e.size_bytes?` · ${J(e.size_bytes)}${e.installed?``:` download`}`:``]})]}),(0,F.jsx)(`p`,{className:`mt-1 text-outline`,children:e.description}),(0,F.jsxs)(`p`,{className:`mt-1 text-xs text-outline`,children:[`Formats: `,e.capabilities.formats.join(`, `)]}),e.detail&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-outline`,children:e.detail}),e.id===`docling`&&(0,F.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[D?.state===`installing`&&(0,F.jsxs)(`div`,{role:`status`,"data-testid":`settings-docling-progress`,className:`text-xs text-outline`,children:[D.step,(0,F.jsx)(`pre`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap font-mono`,children:D.log.slice(-8).join(`
|
|
5
|
+
`)})]}),D?.state===`failed`&&(0,F.jsx)(`p`,{role:`alert`,className:`text-xs text-error`,children:D.error}),e.installed?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`settings-docling-enabled`,checked:i.docling_enabled,onChange:e=>T({docling_enabled:e.target.checked})}),`Use automatically for PDFs and images`]}),(0,F.jsxs)(o,{type:`button`,size:`sm`,variant:`ghost`,className:`text-error`,"data-testid":`settings-docling-remove`,onClick:()=>S(!0),children:[(0,F.jsx)(j,{size:14}),`Remove`]})]}):(0,F.jsxs)(o,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`settings-docling-install`,disabled:y||D?.state===`installing`,onClick:()=>O(()=>v.kb.installDocling()),children:[(0,F.jsx)(h,{size:14}),D?.state===`installing`?`Installing…`:`Install Docling (${J(E?.size_bytes??null)||`about 2 GB`})`]})]})]},e.id)),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-parser`,className:`text-sm text-muted-foreground`,children:`Default parser`}),(0,F.jsxs)(f,{value:i.parser,onValueChange:e=>T({parser:e}),disabled:w(`PARSER`),children:[(0,F.jsx)(l,{id:`settings-kb-parser`,"data-testid":`settings-kb-parser`,children:(0,F.jsx)(c,{})}),(0,F.jsxs)(u,{children:[(0,F.jsx)(d,{value:`auto`,children:`Automatic: Docling for PDFs and images when enabled`}),t.data?.parsers.map(e=>(0,F.jsx)(d,{value:e.id,disabled:!e.installed,children:e.label},e.id))]})]}),(0,F.jsx)(`p`,{className:`text-xs text-outline`,children:`Knowledge bases can override it. Changing parsers applies to new uploads; reparse a document to apply it to existing ones.`})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-timeout`,className:`text-sm text-muted-foreground`,children:`Parse timeout (s)`}),(0,F.jsx)(N,{id:`settings-kb-timeout`,type:`number`,min:10,value:i.parser_timeout_secs,onChange:e=>T({parser_timeout_secs:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-max-upload`,className:`text-sm text-muted-foreground`,children:`Max upload (MB)`}),(0,F.jsx)(N,{id:`settings-kb-max-upload`,type:`number`,min:1,value:i.max_upload_mb,onChange:e=>T({max_upload_mb:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-retention`,className:`text-sm text-muted-foreground`,children:`Read log (days)`}),(0,F.jsx)(N,{id:`settings-kb-retention`,type:`number`,min:1,value:i.usage_retention_days,onChange:e=>T({usage_retention_days:e.target.value})})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`text-sm font-medium`,children:`Semantic search`}),(0,F.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`settings-session-embeddings`,checked:i.session_embeddings,onChange:e=>T({session_embeddings:e.target.checked})}),(0,F.jsxs)(`span`,{children:[`Search coding sessions with embeddings`,(0,F.jsx)(`span`,{className:`block text-xs text-outline`,children:`Uses the provider below for session passages. Keyword search and transcript reading remain available when off. Enabling sends session text to this provider and indexes discovered project sessions.`})]})]}),n.data&&(0,F.jsxs)(`p`,{className:`text-xs text-outline`,"data-testid":`settings-embedding-status`,children:[n.data.embedding.ready?`Ready · ${n.data.embedding.model} · ${n.data.embedding.vector_backend}`:n.data.embedding.detail??`Not configured`,n.data.embedding.pending_chunks?` · ${n.data.embedding.pending_chunks} passages waiting`:``]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-provider`,className:`text-sm text-muted-foreground`,children:`Embedding provider`}),(0,F.jsxs)(f,{value:i.provider,onValueChange:e=>T({provider:e}),disabled:w(`EMBEDDING_PROVIDER`),children:[(0,F.jsx)(l,{id:`settings-kb-provider`,"data-testid":`settings-kb-provider`,children:(0,F.jsx)(c,{})}),(0,F.jsxs)(u,{children:[(0,F.jsx)(d,{value:`none`,children:`None`}),(0,F.jsx)(d,{value:`ollama`,children:`Ollama`}),(0,F.jsx)(d,{value:`openai`,children:`OpenAI-compatible`})]})]}),(0,F.jsx)(`p`,{className:`text-xs text-outline`,children:Ae[i.provider]})]}),i.provider!==`none`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-model`,className:`text-sm text-muted-foreground`,children:`Model`}),(0,F.jsx)(N,{id:`settings-kb-model`,"data-testid":`settings-kb-model`,value:i.model,disabled:w(`EMBEDDING_MODEL`),onChange:e=>T({model:e.target.value}),placeholder:i.provider===`ollama`?`nomic-embed-text`:`text-embedding-3-small`})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-dimensions`,className:`text-sm text-muted-foreground`,children:`Dimensions`}),(0,F.jsx)(N,{id:`settings-kb-dimensions`,type:`number`,value:i.dimensions,onChange:e=>T({dimensions:e.target.value}),placeholder:`Model default`})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-base-url`,className:`text-sm text-muted-foreground`,children:`Base URL`}),(0,F.jsx)(N,{id:`settings-kb-base-url`,"data-testid":`settings-kb-base-url`,value:i.base_url,disabled:w(`EMBEDDING_URL`),onChange:e=>T({base_url:e.target.value}),placeholder:i.provider===`ollama`?`http://localhost:11434`:`https://api.openai.com/v1`})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(p,{htmlFor:`settings-kb-api-key`,className:`text-sm text-muted-foreground`,children:i.provider===`ollama`?`Token (hosted or proxied Ollama)`:`API key`}),(0,F.jsx)(N,{id:`settings-kb-api-key`,type:`password`,autoComplete:`off`,"data-testid":`settings-kb-api-key`,value:i.api_key,disabled:i.clear_key||w(`EMBEDDING_API_KEY`),onChange:e=>T({api_key:e.target.value}),placeholder:C.embedding.api_key_set?`Saved. Type to replace`:`Not set`}),C.embedding.api_key_set&&(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-outline`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`settings-kb-api-key-clear`,checked:i.clear_key,onChange:e=>T({clear_key:e.target.checked,api_key:``})}),`Remove the saved key`]}),(0,F.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Stored encrypted with the key in `,(0,F.jsx)(`code`,{children:`~/.orc/secret.key`}),` and never sent back to the browser. Sent as a bearer token to the base URL.`]})]}),(0,F.jsx)(`p`,{className:`text-xs text-outline`,children:`Changing the model re-embeds every passage in the background; keyword search keeps working meanwhile.`})]})]}),s&&(0,F.jsx)(`p`,{role:`alert`,"data-testid":`settings-knowledge-error`,className:`text-sm text-error`,children:s}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(o,{type:`submit`,"data-testid":`settings-knowledge-save`,disabled:y,children:`Save knowledge settings`}),g&&(0,F.jsx)(`span`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saved`})]})]}),(0,F.jsx)(me,{open:x,title:`Remove Docling`,description:`Deletes the Docling runtime and models from this machine. Documents it parsed keep their text; reparse them to use the basic parser.`,confirmLabel:`Remove`,isPending:y,onCancel:()=>S(!1),onConfirm:async()=>{S(!1),await O(()=>v.kb.uninstallDocling())}})]})}var Me=[`fcm.googleapis.com`,`updates.push.services.mozilla.com`,`web.push.apple.com`],Ne=[`.push.apple.com`,`.notify.windows.com`];function Pe(e){let t;try{t=new URL(e)}catch{return!1}if(t.protocol!==`https:`||t.username||t.password||t.port)return!1;let n=t.hostname.toLowerCase();return Me.includes(n)||Ne.some(e=>n.endsWith(e))}var Y=k().min(1).max(512).regex(/^[A-Za-z0-9_-]+={0,2}$/,`Expected a base64url key`),X=pe([`attention`,`chat`]),Fe=X.options;M({endpoint:k().max(2048).refine(Pe,`Endpoint must be a known browser push service`),keys:M({p256dh:Y,auth:Y}).strict(),label:k().trim().min(1).max(120),topics:O(X).max(2).optional()}).strict(),M({topics:O(X).max(2)}).strict(),M({id:k(),label:k(),endpoint_host:k(),topics:O(X),created_at:C(),last_success_at:C().nullable(),failure_count:C().int()}),M({public_key:k()}),M({title:k().max(200),body:k().max(500),url:k().max(2048),tag:k().max(200)});var Ie={attention:`Attention needed (approvals and questions from agents)`,chat:`Chat replies and chat approvals`},Le={insecure:`Notifications need HTTPS. Open ORC through an https:// address to enable them.`,"install-required":`On iPhone and iPad, add ORC to the Home Screen (Share → Add to Home Screen), then open it from there.`,unsupported:`This browser does not support push notifications.`};function Re(...e){return e.find(Boolean)?.message}function ze(e){return e?new Date(e).toLocaleString():`never`}function Z({device:e}){let t=ce(),n=(n,r)=>{let i=r?[...e.topics,n]:e.topics.filter(e=>e!==n);t.mutate({id:e.id,topics:i})};return(0,F.jsxs)(`fieldset`,{className:`space-y-2`,disabled:t.isPending,children:[(0,F.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Notify this device about`}),Fe.map(t=>(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-testid":`push-topic-${t}`,checked:e.topics.includes(t),onChange:e=>n(t,e.target.checked)}),Ie[t]]},t))]})}function Be(){let e=te(),t=oe(),n=se(),r=ae(),i=le(),a=ie(),s=ee(),c=t.data??null,l=(n.data??[]).filter(e=>e.id!==c?.id),u=Re(r.error,i.error,a.error,s.error);return(0,F.jsxs)(`section`,{"aria-labelledby":`notifications-title`,children:[(0,F.jsx)(`h2`,{id:`notifications-title`,className:`mb-1 text-base font-medium`,children:`Notifications`}),(0,F.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:`Get a push notification on this device when an agent needs your approval or answer, or a chat reply is ready. Notifications are skipped while ORC is open and focused.`}),(0,F.jsx)(K,{className:`mb-4`}),e===`supported`?(0,F.jsxs)(`div`,{className:`space-y-4`,children:[c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Z,{device:c}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsxs)(o,{variant:`outline`,"data-testid":`push-test`,disabled:s.isPending,onClick:()=>s.mutate(c.id),children:[(0,F.jsx)(De,{className:`mr-2 size-4`}),`Send test notification`]}),(0,F.jsxs)(o,{variant:`outline`,"data-testid":`push-disable`,disabled:i.isPending,onClick:()=>i.mutate(c.id),children:[(0,F.jsx)(Ce,{className:`mr-2 size-4`}),`Turn off on this device`]})]})]}):(0,F.jsxs)(o,{"data-testid":`push-enable`,disabled:r.isPending||t.isLoading,onClick:()=>r.mutate(),children:[(0,F.jsx)(de,{className:`mr-2 size-4`}),r.isPending?`Enabling…`:`Enable notifications on this device`]}),s.data&&(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:s.data.sent?`Test sent. Switch away from ORC to see it.`:`Test not delivered.`})]}):(0,F.jsx)(`p`,{"data-testid":`push-unsupported`,className:`text-sm text-muted-foreground`,children:Le[e]}),u&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-error`,children:u}),l.length>0&&(0,F.jsxs)(`div`,{className:`mt-6`,children:[(0,F.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Other devices`}),(0,F.jsx)(`ul`,{className:`space-y-2`,"data-testid":`push-devices`,children:l.map(e=>(0,F.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,F.jsxs)(`span`,{className:`min-w-0`,children:[(0,F.jsx)(`span`,{className:`block truncate`,children:e.label}),(0,F.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Last delivered `,ze(e.last_success_at),e.failure_count>0&&` · ${e.failure_count} failed`]})]}),(0,F.jsx)(o,{variant:`ghost`,size:`icon`,"aria-label":`Remove ${e.label}`,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:(0,F.jsx)(j,{className:`size-4`})})]},e.id))})]})]})}function Ve(){let e=r();return i({mutationFn:async()=>{let e=await v.system.restart(),t=Date.now()+6e4;for(;Date.now()<t;){await new Promise(e=>setTimeout(e,500));try{if((await v.health.check(AbortSignal.timeout(2e3))).instance_id!==e.instance_id)return}catch(e){if(e instanceof b&&e.status===401)throw e}}throw Error(`ORC has not reconnected yet. Check the server and try again when it is online.`)},onSuccess:()=>e.invalidateQueries()})}function He(){let{data:e}=ne(),t=Ve();return(0,F.jsxs)(`section`,{"aria-labelledby":`server-title`,children:[(0,F.jsx)(`h2`,{id:`server-title`,className:`mb-1 text-base font-medium`,children:`ORC server`}),(0,F.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:`Restart ORC to reload server and host information. This closes active terminals and may interrupt running work. Your settings are kept, and this dashboard reconnects automatically. Switching hosts applies to new actions without a restart.`}),(0,F.jsx)(K,{className:`mb-4`}),(0,F.jsxs)(o,{variant:`outline`,"data-testid":`settings-restart`,disabled:!e?.restart_supported||t.isPending,onClick:()=>t.mutate(),children:[(0,F.jsx)(Ee,{className:t.isPending?`mr-2 size-4 animate-spin`:`mr-2 size-4`}),t.isPending?`Restarting and reconnecting…`:`Restart ORC server`]}),e&&!e.restart_supported&&(0,F.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`This server does not support restart from the dashboard.`}),t.isPending&&(0,F.jsx)(`p`,{role:`status`,"data-testid":`settings-restart-status`,className:`mt-2 text-sm text-muted-foreground`,children:`Waiting for ORC to restart…`}),t.isSuccess&&(0,F.jsx)(`p`,{role:`status`,"data-testid":`settings-restart-status`,className:`mt-2 text-sm text-muted-foreground`,children:`ORC restarted. Reconnected.`}),t.isError&&(0,F.jsx)(`p`,{role:`alert`,"data-testid":`settings-restart-error`,className:`mt-2 text-sm text-error`,children:t.error.message})]})}var Q=`__local__`;function $(e){return e?e instanceof Error?e.message:String(e):null}function Ue(){let{data:e,error:t,refetch:n}=D(),{data:r}=re(),i=fe(),a=x(),[s,m]=(0,P.useState)(Q),[h,_]=(0,P.useState)(``);if((0,P.useEffect)(()=>{e&&(m(e.host??Q),_(e.remote_port===null?``:String(e.remote_port)))},[e]),t)return(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`mb-3 text-base font-semibold`,children:`Execution host`}),(0,F.jsx)(he,{message:t.message,onRetry:()=>void n()})]});if(!e)return(0,F.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,className:`text-sm text-muted-foreground`,children:`Loading execution host…`});let v=s===Q?null:s,y=e.host&&!e.hosts.includes(e.host)?[e.host,...e.hosts]:e.hosts,b=Number(h),S=h.trim()===``||Number.isInteger(b)&&b>=1&&b<=65535,C=e.locked||!e.supported,w=r?.backends.find(e=>e.name===`claude`),T=a.data?.host===v?a.data:void 0;return(0,F.jsxs)(`section`,{"data-testid":`ssh-settings`,children:[(0,F.jsx)(`h2`,{className:`font-headline font-semibold text-base text-on-surface mb-1`,children:`Execution host`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground mb-4`,children:[`Run every agent, terminal, git and file action on a host from`,` `,(0,F.jsx)(`code`,{className:`text-primary`,children:`~/.ssh/config`}),`. Agents there reach orc through a reverse tunnel on the remote port. Terminals already open keep their host.`]}),(0,F.jsx)(K,{className:`bg-surface-highest mb-4`}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[e.locked&&(0,F.jsx)(`p`,{"data-testid":`ssh-locked`,className:`font-body text-sm text-tertiary`,children:`Fixed by ORC_SSH_HOST in orc's environment.`}),!e.supported&&(0,F.jsx)(`p`,{"data-testid":`ssh-unsupported`,className:`font-body text-sm text-error`,children:e.unsupported_reason}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`ssh-host`,className:`font-label text-sm text-muted-foreground`,children:`Host`}),(0,F.jsxs)(f,{value:s,onValueChange:m,disabled:C,children:[(0,F.jsx)(l,{id:`ssh-host`,"aria-label":`Execution host`,"data-testid":`ssh-host-picker`,className:`bg-surface-highest border-control-border text-on-surface font-body text-sm`,children:(0,F.jsx)(c,{})}),(0,F.jsxs)(u,{className:`bg-surface-highest border-outline-variant max-h-72`,children:[(0,F.jsx)(d,{value:Q,"data-testid":`ssh-host-option-local`,className:`font-label text-sm`,children:`Local (this machine)`}),y.map(e=>(0,F.jsx)(d,{value:e,"data-testid":`ssh-host-option-${e}`,className:`font-label text-sm`,children:e},e))]})]}),y.length===0&&(0,F.jsx)(`p`,{"data-testid":`page-empty`,className:`font-body text-sm text-muted-foreground`,children:`No Host entries found in ~/.ssh/config on the machine running orc.`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`ssh-remote-port`,className:`font-label text-sm text-muted-foreground`,children:`Tunnel port override`}),(0,F.jsx)(N,{id:`ssh-remote-port`,"aria-invalid":!(!v||S),"data-testid":`ssh-remote-port`,value:h,placeholder:`Automatic`,onChange:e=>_(e.target.value),disabled:C||!v,inputMode:`numeric`,className:`bg-surface-highest border-outline-variant text-on-surface font-body text-sm`}),v&&!S&&(0,F.jsx)(`p`,{className:`text-sm text-error`,children:`Enter a remote port from 1 to 65535.`}),(0,F.jsx)(`p`,{className:`font-body text-sm text-muted-foreground`,children:`Leave empty to let SSH choose an available port automatically.`})]}),(0,F.jsxs)(`div`,{className:`flex gap-3`,children:[(0,F.jsxs)(o,{"data-testid":`ssh-save`,disabled:C||v!==null&&!S||i.isPending,onClick:()=>i.mutate({host:v,remotePort:v&&h.trim()?b:null}),className:`font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,F.jsx)(g,{size:12,className:`mr-1.5`}),` Use Host`]}),(0,F.jsxs)(o,{"data-testid":`ssh-test`,variant:`ghost`,disabled:!v||!e.supported||a.isPending,onClick:()=>v&&a.mutate(v),className:`font-label text-sm text-muted-foreground hover:text-on-surface`,children:[(0,F.jsx)(Te,{size:12,className:`mr-1.5`}),` `,a.isPending?`Testing…`:`Test`]})]}),$(i.error??a.error)&&(0,F.jsx)(`p`,{"data-testid":`ssh-error`,className:`font-body text-sm text-error`,children:$(i.error??a.error)}),T&&(0,F.jsx)(`div`,{"data-testid":`ssh-test-result`,className:`font-body text-sm space-y-1`,children:T.ok?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`text-secondary`,children:[`Connected to `,T.host,` (`,T.os,`, `,T.shell,`)`]}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:Object.entries(T.binaries).map(([e,t])=>`${t?`●`:`○`} ${e}`).join(` `)}),T.binaries.claude&&T.claude_logged_in===!1&&(0,F.jsxs)(`p`,{className:T.api_key_forwarded?`text-muted-foreground`:`text-error`,children:[`claude is not logged in on `,T.host,`.`,` `,T.api_key_forwarded?`ANTHROPIC_API_KEY from orc's environment will be forwarded.`:`Set ANTHROPIC_API_KEY in orc's environment or run claude login there.`]})]}):(0,F.jsx)(`p`,{className:`text-error`,children:T.error})}),e.host&&w&&!w.available&&(0,F.jsxs)(`p`,{"data-testid":`ssh-claude-error`,className:`font-body text-sm text-error`,children:[`claude backend: `,w.error]})]})]})}function We(){let{theme:e}=ue(),[t,n]=(0,P.useState)(_),[i,a]=(0,P.useState)(()=>localStorage.getItem(`orc_terminal_font`)??``),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),[m,h]=(0,P.useState)(!1),b=r(),x=async()=>{f(``),h(!0);try{let n=t.trim();if(n&&!n.startsWith(`/`)&&!/^https?:\/\//i.test(n))throw Error(`Use a relative API path or an http(s) server URL.`);let r=await v.settings.save({theme:e,terminal_font:i.trim()});A(r.theme??e),a(r.terminal_font??``),r.terminal_font?localStorage.setItem(S,r.terminal_font):localStorage.removeItem(S);let o=(n||`/api`)!==_();localStorage.setItem(`orc_api_url`,n||`/api`),o&&window.dispatchEvent(new Event(y)),b.invalidateQueries(),c(!0),u(`Workspace preferences saved on the server. API address saved in this browser.`),setTimeout(()=>c(!1),2e3)}catch(e){f(e instanceof Error?e.message:`Browser settings could not be saved.`)}finally{h(!1)}},C=async()=>{f(``),h(!0);try{let e=await v.settings.save({terminal_font:``});localStorage.removeItem(`orc_api_url`),localStorage.setItem(S,e.terminal_font??``),n(`/api`),a(e.terminal_font??``),window.dispatchEvent(new Event(y)),b.invalidateQueries(),c(!1),u(`Connection and terminal font restored to their defaults. Appearance and execution host were kept.`)}catch(e){f(e instanceof Error?e.message:`Browser settings could not be reset.`)}finally{h(!1)}};async function w(e){f(``),h(!0);try{let t=await v.settings.save({theme:e});A(t.theme??e)}catch(e){f(e instanceof Error?e.message:`Appearance could not be saved.`)}finally{h(!1)}}return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(ge,{title:`Settings`}),(0,F.jsxs)(`div`,{className:`max-w-lg space-y-8`,children:[(0,F.jsxs)(`section`,{"aria-labelledby":`appearance-title`,children:[(0,F.jsx)(`h2`,{id:`appearance-title`,className:`mb-1 text-base font-medium`,children:`Appearance`}),(0,F.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:`Choose a workspace theme. Your choice is saved on the server immediately.`}),(0,F.jsx)(`fieldset`,{className:`flex flex-wrap gap-2`,"aria-label":`Theme`,children:[`dark`,`light`].map(t=>(0,F.jsx)(o,{variant:e===t?`secondary`:`outline`,"aria-pressed":e===t,"data-testid":`settings-theme-${t}`,disabled:m,onClick:()=>void w(t),children:t===`dark`?`Dark`:`Light`},t))})]}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`font-headline font-medium text-base text-on-surface mb-1`,children:`API connection`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground mb-4`,children:[`Connect this workspace to an ORC server. The default`,` `,(0,F.jsx)(`code`,{className:`text-primary`,children:`/api`}),` uses the current server or the configured development proxy.`]}),(0,F.jsx)(K,{className:`bg-outline-variant mb-4`}),(0,F.jsx)(`div`,{className:`space-y-4`,children:(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`settings-api-url`,className:`font-label text-sm text-muted-foreground`,children:`API base URL`}),(0,F.jsx)(N,{id:`settings-api-url`,"data-testid":`settings-api-url`,value:t,onChange:e=>n(e.target.value),placeholder:`/api or http://localhost:7700`,className:`bg-background text-on-surface font-body text-sm`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground`,children:[`Use `,(0,F.jsx)(`code`,{children:`/api`}),` (dev proxy) or a direct URL when CORS is enabled.`]})]})})]}),(0,F.jsx)(Ue,{}),(0,F.jsx)(He,{}),(0,F.jsx)(Be,{}),(0,F.jsx)(Oe,{}),(0,F.jsx)(je,{}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(`h2`,{className:`font-headline font-medium text-base text-on-surface mb-1`,children:`Terminal`}),(0,F.jsx)(`p`,{className:`font-body text-sm text-muted-foreground mb-4`,children:`Prompt and agent status icons need a Nerd Font installed on this machine. Common ones are tried automatically; set the exact family name if your icons show as empty boxes. Applies to terminals opened after saving.`}),(0,F.jsx)(K,{className:`bg-outline-variant mb-4`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(p,{htmlFor:`settings-terminal-font`,className:`font-label text-sm text-muted-foreground`,children:`Terminal font family`}),(0,F.jsx)(N,{id:`settings-terminal-font`,value:i,onChange:e=>a(e.target.value),placeholder:`e.g. MesloLGS NF`,className:`bg-background text-on-surface font-body text-sm`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3 pt-2`,children:[(0,F.jsx)(o,{"data-testid":`settings-save`,disabled:m,onClick:()=>void x(),className:`font-label text-sm `,children:s?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(we,{size:12,className:`mr-1.5`}),` Saved`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{size:12,className:`mr-1.5`}),` Save settings`]})}),(0,F.jsx)(o,{variant:`ghost`,disabled:m,onClick:()=>void C(),className:`font-label text-sm text-muted-foreground hover:text-on-surface`,children:`Reset to defaults`})]}),d&&(0,F.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:d}),l&&!d&&(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:l}),(0,F.jsxs)(`section`,{children:[(0,F.jsx)(K,{className:`bg-outline-variant mb-4`}),(0,F.jsx)(`div`,{className:`font-label text-sm text-muted-foreground mb-2`,children:`Storage`}),(0,F.jsxs)(`p`,{className:`font-body text-sm text-muted-foreground`,children:[`Workspace preferences and SSH selection are persisted in the server's`,` `,(0,F.jsx)(`code`,{children:`~/.orc/config.json`}),`. The API address and optionally remembered login are stored in this browser.`]})]})]})]})}export{We as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{E as i,O as a,_ as o,a as s,c,f as l,h as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v,w as y}from"./useMutation-HX90wI4L.js";import{t as b}from"./button-BHKbOsmj.js";import{t as x}from"./label-BQ1Lr4sA.js";import{t as S}from"./createLucideIcon-jLuHkL03.js";import{t as ee}from"./download-WG9NKrMe.js";import{t as C}from"./MarkdownEditor-BMQq1cAY.js";import{n as w}from"./client-BwhkVepQ.js";import{t as te}from"./bulk-actions-C8S1Gt4W.js";import{At as T,Et as E,G as D,K as ne,Ot as O,Tt as k,U as re,W as A,X as ie,Y as ae,bn as oe,ct as j,in as se,kt as M,on as ce,pn as N,st as P,wt as F,yn as le}from"./index-CMRGRbC9.js";import{t as ue}from"./ConfirmDialog-D25Wf6Nc.js";import{t as de}from"./ErrorState-BoQqdsym.js";import{t as fe}from"./ViewHeader-DHM9SSkD.js";import{t as pe}from"./useDetailRoute-C8xQeILG.js";import{t as I}from"./view-params-BqRwdnv0.js";import{t as me}from"./EmptyState-YM4VSLR9.js";import{a as he,i as L,n as ge,o as _e,r as R,t as ve}from"./table-ByS-sgsb.js";import{t as ye}from"./useProjectScope-CZEfU9mq.js";import{n as be,t as xe}from"./useListSelection-CgpNqqAb.js";import{n as z,t as Se}from"./DocumentWorkspace-CW6S2i4-.js";import{t as B}from"./primitive-files-BKGHFjYN.js";function V(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var H=class extends o{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,u.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,o=n.some((t,n)=>t!==e[n]),s=i||o,c=s?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!a(e,n)});(s||c)&&(s&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(s&&(V(e,n).forEach(e=>{e.destroy()}),V(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,a=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||a||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=i(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new l(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&u.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},U=e(t(),1);function Ce({queries:e,...t},n){let i=r(n),a=v(),o=f(),p=t.subscribed!==!1,_=U.useMemo(()=>e.map(e=>{let t=i.defaultQueryOptions(e);return t._optimisticResults=a?`isRestoring`:p?`optimistic`:void 0,t}),[e,i,a,p]);_.forEach(e=>{h(e);let t=i.getQueryCache().get(e.queryHash);m(e,o,t)}),c(o);let[b]=U.useState(()=>new H(i,_,t)),[x,S,ee]=b.getOptimisticResult(_,t.combine),C=!a&&p;U.useSyncExternalStore(U.useCallback(e=>C?b.subscribe(u.batchCalls(e)):y,[b,C]),()=>b.getCurrentResult(),()=>b.getCurrentResult()),U.useEffect(()=>{b.setQueries(_,t)},[_,t,b]);let w=x.some((e,t)=>s(_[t],e))?x.flatMap((e,t)=>{let n=_[t];if(n&&s(n,e)){let e=new l(i,n);return d(n,e,o)}return[]}):[];if(w.length>0)throw Promise.all(w);let te=x.find((e,t)=>{let n=_[t];return n&&g({result:e,errorResetBoundary:o,throwOnError:n.throwOnError,query:i.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(te)throw te.error;return S(ee())}var we={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};we.node;var W=S(we),G={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};G.node;var Te=S(G),Ee={name:`toggle-right`,size:24,node:[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};Ee.node;var De=S(Ee),K=n();function Oe({files:e,selected:t,onSelect:n,testId:r=`document-file-tab`,entryTestId:i}){return(0,K.jsxs)(`nav`,{"aria-label":`Document files`,className:`min-w-0 space-y-2`,"data-testid":`document-tabs`,children:[(0,K.jsx)(`div`,{role:`tablist`,"aria-label":`Open a file`,className:`flex max-w-full gap-1 overflow-x-auto overscroll-x-contain rounded-md border border-surface-highest p-1`,children:e.map((a,o)=>(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a===t,"data-testid":o===0&&i?i:r,"data-file-name":a,title:a,tabIndex:a===t?0:-1,onKeyDown:t=>{if(![`ArrowRight`,`ArrowLeft`,`Home`,`End`].includes(t.key))return;t.preventDefault();let r=o;t.key===`ArrowRight`&&(r=(o+1)%e.length),t.key===`ArrowLeft`&&(r=(o+e.length-1)%e.length),t.key===`Home`&&(r=0),t.key===`End`&&(r=e.length-1),n(e[r])!==!1&&(t.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`))?.[r]?.focus()},onClick:()=>n(a),className:`flex min-h-11 shrink-0 items-center gap-2 rounded px-3 text-sm ${a===t?`bg-surface-highest text-on-surface`:`text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:[(0,K.jsx)(N,{size:14,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`max-w-[180px] truncate`,children:a.split(`/`).pop()})]},a))}),(0,K.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm text-outline sm:hidden`,children:[`File`,(0,K.jsx)(`select`,{"aria-label":`Choose document file`,"data-testid":`document-file-picker`,value:t,onChange:e=>n(e.target.value),className:`min-h-11 min-w-0 flex-1 rounded border border-control-border bg-surface px-2 text-on-surface`,children:e.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]})]})}var q={new:``,installed:`Already in ORC`,conflict:`Name taken in ORC (different content)`,changed:`Changed since import`,invalid:`Invalid`},J=e=>`${e.agent}/${e.name}`;function ke({onClose:e}){let[t,n]=(0,U.useState)([]),i=r(),a=p({queryKey:[`skills`,`local-agents`],queryFn:w.skills.localAgents}),o=_({mutationFn:w.skills.importLocal,onSuccess:async t=>{n([]),await i.invalidateQueries({queryKey:[`skills`]}),t.skipped.length||e()}}),s=o.isPending,c=a.data?.agents??[],l=new Set(t.map(e=>e.split(`/`)[1])),u=(e,r)=>n(r?[...t,J(e)]:t.filter(t=>t!==J(e))),d=e=>{let r=[...t],i=new Set(l);for(let t of e)t.status!==`new`||i.has(t.name)||(r.push(J(t)),i.add(t.name));n(r)};return(0,K.jsx)(k,{open:!0,onOpenChange:t=>!t&&!s&&e(),children:(0,K.jsxs)(E,{className:`max-w-xl`,children:[(0,K.jsx)(M,{children:(0,K.jsx)(T,{children:`Import from local agents`})}),(0,K.jsx)(`p`,{className:`text-xs text-outline`,children:`Copies skills from agent folders such as ~/.claude/skills and ~/.codex/skills into ORC. The originals are not changed.`}),a.isLoading&&(0,K.jsx)(`p`,{role:`status`,children:`Scanning agent folders…`}),a.data&&!c.length&&(0,K.jsx)(`p`,{role:`status`,children:`No local agent skill folders found.`}),(0,K.jsx)(`div`,{className:`max-h-[55vh] overflow-y-auto space-y-4`,children:c.map(e=>{let n=e.skills.filter(e=>e.status===`new`);return(0,K.jsxs)(`section`,{"data-testid":`local-agent`,"data-agent":e.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-outline`,children:e.dir})]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,"data-testid":`local-agent-select-all`,disabled:s||!n.length,onClick:()=>d(e.skills),children:[`Select all new (`,n.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:e.skills.map(e=>{let n=t.includes(J(e)),r=!n&&l.has(e.name);return(0,K.jsxs)(`label`,{className:`flex items-start gap-3 border border-surface-highest rounded p-3`,"data-testid":`local-skill`,"data-skill-name":e.name,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`local-skill-select`,checked:n,disabled:s||e.status!==`new`||r,onChange:t=>u(e,t.target.checked)}),(0,K.jsxs)(`span`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.name}),q[e.status]&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-outline`,children:q[e.status]}),(0,K.jsx)(`span`,{className:`block text-xs text-outline`,children:e.error??e.description}),e.extra_fields.length>0&&(0,K.jsxs)(`span`,{className:`block text-xs text-outline`,"data-testid":`local-skill-extra-fields`,children:[`Extra fields: `,e.extra_fields.join(`, `)]}),e.also_in.length>0&&(0,K.jsxs)(`span`,{className:`block text-xs text-outline`,children:[`Also in `,e.also_in.join(`, `)]})]})]},J(e))})})]},e.id)})}),o.data?.skipped.map(e=>(0,K.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Skipped `,e.name,`: `,e.reason]},`${e.agent}/${e.name}`)),(a.error||o.error)&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:(a.error||o.error)?.message}),(0,K.jsxs)(O,{children:[(0,K.jsx)(b,{variant:`ghost`,disabled:s,onClick:e,children:`Close`}),(0,K.jsx)(b,{"data-testid":`local-skill-import-submit`,disabled:s||!t.length,onClick:()=>o.mutate(t.map(e=>{let[t=``,n=``]=e.split(`/`);return{agent:t,name:n}})),children:o.isPending?`Importing…`:`Import selected${t.length?` (${t.length})`:``}`})]})]})})}function Ae({onClose:e}){let[t,n]=(0,U.useState)(``),[i,a]=(0,U.useState)([]),o=r(),s=_({mutationFn:w.skills.discover,onSuccess:()=>{c.clear(),a([])}}),c=xe((s.data?.skills??[]).filter(e=>!e.installed&&!i.includes(e.path)).map(e=>e.path),`${t}:${s.data?.commit??``}`),l=c.selectedIds,u=_({mutationFn:async()=>{if(!s.data)throw Error(`Discover skills first`);let e=[],n=[];for(let r=0;r<l.length;r+=16){let i=l.slice(r,r+16);try{await w.skills.import({source:t.trim(),commit:s.data.commit,paths:i}),n.push(...i)}catch(t){e.push(...i.map(e=>({path:e,error:t instanceof Error?t.message:`Import failed`})))}}return{imported:n,failed:e}},onSuccess:async t=>{await o.invalidateQueries({queryKey:[`skills`]}),a(e=>[...e,...t.imported]),c.select(t.failed.map(e=>e.path)),t.failed.length||e()}}),d=s.isPending||u.isPending;return(0,K.jsx)(k,{open:!0,onOpenChange:t=>!t&&!d&&e(),children:(0,K.jsxs)(E,{className:`max-w-xl`,children:[(0,K.jsx)(M,{children:(0,K.jsx)(T,{children:`Import from GitHub`})}),(0,K.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),s.mutate(t.trim())},children:[(0,K.jsx)(x,{htmlFor:`skill-repository`,children:`Repository or skills.sh link`}),(0,K.jsx)(F,{id:`skill-repository`,"data-testid":`skill-repository-input`,value:t,disabled:d,onChange:e=>{n(e.target.value),s.reset(),u.reset(),c.clear(),a([])},placeholder:`https://github.com/vercel-labs/agent-skills`,autoFocus:!0}),(0,K.jsx)(`p`,{className:`text-xs text-outline`,children:`GitHub repositories, owner/repo, skill-folder URLs and skills.sh links. Private repositories use gh login on the execution host (local or SSH), or ORC_GITHUB_TOKEN on the ORC server. Supporting files are included.`}),(0,K.jsx)(b,{type:`submit`,"data-testid":`skill-discover`,disabled:d||!t.trim(),children:s.isPending?`Discovering…`:`Discover skills`})]}),s.data&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-outline`,children:[s.data.skills.length,` skills found · `,s.data.commit.slice(0,8)]}),!s.data.skills.length&&(0,K.jsx)(`p`,{role:`status`,children:`No valid skills found in this source.`}),(0,K.jsx)(be,{resourceLabel:`new skills`,count:l.length,allSelected:c.allSelected,someSelected:c.someSelected,onSelectAll:c.selectAll,onClear:c.clear,disabled:d,children:(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Imports run in batches of up to 16.`})}),(0,K.jsx)(`div`,{className:`max-h-[45vh] overflow-y-auto space-y-2`,children:s.data.skills.map(e=>(0,K.jsxs)(`label`,{className:`flex items-start gap-3 border border-surface-highest rounded p-3`,"data-testid":`remote-skill`,"data-skill-name":e.name,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`remote-skill-select`,checked:l.includes(e.path),disabled:d||e.installed||i.includes(e.path),onChange:()=>c.toggle(e.path)}),(0,K.jsxs)(`span`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.name}),(e.installed||i.includes(e.path))&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-outline`,children:`Already installed`}),(0,K.jsx)(`span`,{className:`block text-xs text-outline`,children:e.description}),(0,K.jsx)(`span`,{className:`block text-xs text-outline`,children:e.path||`Repository root`})]})]},e.path))}),s.data.issues.map(e=>(0,K.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[e.path,`: `,e.error]},e.path))]}),(s.error||u.error)&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:(s.error||u.error)?.message}),!!u.data?.failed.length&&(0,K.jsxs)(`div`,{role:`alert`,className:`text-sm text-destructive`,children:[(0,K.jsxs)(`p`,{children:[u.data.imported.length,` imported; `,u.data.failed.length,` failed. Failed selections retained for retry.`]}),u.data.failed.map(e=>(0,K.jsxs)(`p`,{children:[e.path||`Repository root`,`: `,e.error]},e.path))]}),(0,K.jsxs)(O,{children:[(0,K.jsx)(b,{variant:`ghost`,disabled:d,onClick:e,children:`Cancel`}),(0,K.jsx)(b,{"data-testid":`skill-import-submit`,disabled:d||!s.data||!l.length,onClick:()=>u.mutate(),children:u.isPending?`Importing…`:`Import selected${l.length?` (${l.length})`:``}`})]})]})})}var Y=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Y{};function je(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Me(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Ne(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Pe(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function X(e,t){return Ne(e,t,``)}function Fe(e,t){return Pe(e,t,``)}function Ie(e,t){return t.slice(0,Le(e,t))}function Le(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Re(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function ze(e,t){if(t)return Q(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Z(e,t){if(t)return Q(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Q(e,t){if(!t)return[Z(e),ze(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Re(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var $=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Be=RegExp(`[${$}]+|\\s+|[^${$}]`,`ug`);new class extends Y{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Re(e,r)}else n=e.match(Be)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Ve(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Ve(n,i,r,null,t.intlSegmenter),e}};function Ve(e,t,n,r,i){if(t&&n){let[a,o]=Q(t.value,i),[s,c]=Q(n.value,i);if(e){let r=je(a,s);e.value=Pe(e.value,s,r),t.value=X(t.value,r),n.value=X(n.value,r)}if(r){let e=Me(o,c);r.value=Ne(r.value,c,e),t.value=Fe(t.value,e),n.value=Fe(n.value,e)}}else if(n){if(e){let e=Z(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Z(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Z(r.value,i),[a,o]=Q(t.value,i),s=je(n,a);t.value=X(t.value,s);let c=Me(X(n,s),o);t.value=Fe(t.value,c),r.value=Ne(r.value,n,c),e.value=Pe(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Z(r.value,i),n=Ie(ze(t.value,i),e);t.value=Fe(t.value,n)}else if(e){let n=Ie(ze(e.value,i),Z(t.value,i));t.value=X(t.value,n)}}new class extends Y{tokenize(e){let t=RegExp(`(\\r?\\n)|[${$}]+|[^\\S\\n\\r]+|[^${$}]`,`ug`);return e.match(t)||[]}};var He=new class extends Y{constructor(){super(...arguments),this.tokenize=We}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes(`
|
|
2
|
+
`)||(e=e.trim()),n.newlineIsToken&&t.includes(`
|
|
3
|
+
`)||(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
4
|
+
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
5
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function Ue(e,t,n){return He.diff(e,t,n)}function We(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
6
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Ge(e){return e==`.`||e==`!`||e==`?`}new class extends Y{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Ge(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends Y{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends Y{constructor(){super(...arguments),this.tokenize=We}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Ke(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Ke(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ke(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Ke(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends Y{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function qe({name:e,scope:t,mutation:n}){let i=r(),[a,o]=(0,U.useState)(``),s=p({queryKey:[`skill-history`,e,t],queryFn:()=>w.skills.history(e,t)}),c=_({mutationFn:t=>{if(!n)throw Error(`No active instruction edit`);return w.skills.revert(e,{project_id:n.project_id,change_id:t,expected_change_id:n.id,reason:a.trim()})},onSuccess:()=>{i.invalidateQueries({queryKey:[`skill`]}),i.invalidateQueries({queryKey:[`skills`]}),i.invalidateQueries({queryKey:[`skill-history`]}),o(``)}});return!s.data?.changes.length&&!s.error?null:(0,K.jsxs)(`section`,{"data-testid":`skill-history-panel`,className:`mb-5 space-y-3`,children:[n&&(0,K.jsxs)(`p`,{"data-testid":`skill-mutated-label`,className:`text-xs text-primary`,children:[`Mutated · `,n.project_id?`Project`:`Global`,` ·`,` `,new Date(n.updated_at*1e3).toLocaleString(),` · `,n.author]}),(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Instruction history`}),(0,K.jsx)(F,{"data-testid":`skill-revert-reason`,"aria-label":`Reason for reverting instructions`,value:a,onChange:e=>o(e.target.value),placeholder:`Reason for reverting...`}),s.error&&(0,K.jsx)(`p`,{role:`alert`,children:s.error.message}),c.error&&(0,K.jsx)(`p`,{role:`alert`,children:c.error.message}),s.data?.changes.map(e=>(0,K.jsxs)(`details`,{"data-testid":`skill-history-change`,className:`border-b border-outline-variant p-3`,children:[(0,K.jsxs)(`summary`,{className:`text-xs cursor-pointer`,children:[e.action,` · `,e.reason,` · `,e.author,` ·`,` `,(0,K.jsx)(`time`,{dateTime:new Date(e.created_at*1e3).toISOString(),children:new Date(e.created_at*1e3).toLocaleString()})]}),(0,K.jsx)(Je,{before:e.previous_raw,after:e.raw}),(0,K.jsx)(b,{"data-testid":`skill-revert-change`,size:`sm`,variant:`outline`,disabled:!a.trim()||c.isPending,onClick:()=>c.mutate(e.id),children:`Restore instructions before this change`})]},e.id))]})}function Je({before:e,after:t}){let[n,r]=(0,U.useState)(!1),i=Ue(e,t).filter(e=>e.added||e.removed);return(0,K.jsxs)(`div`,{className:`my-3 space-y-2`,children:[(0,K.jsx)(`pre`,{"data-testid":`skill-change-diff`,className:`text-xs whitespace-pre-wrap break-all`,children:i.length===0?`No instruction changes`:i.map(e=>(0,K.jsxs)(`span`,{className:e.added?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,children:[e.value.split(/(?<=\n)/).filter(Boolean).map(t=>`${e.added?`+ `:`- `}${t}`).join(``),!e.value.endsWith(`
|
|
7
|
+
`)&&`
|
|
8
|
+
`]},`${i.indexOf(e)}-${e.added?`added`:`removed`}`))}),(0,K.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>r(!n),children:n?`Hide full skill`:`Show full skill`}),n&&(0,K.jsxs)(`div`,{"data-testid":`skill-change-full`,children:[(0,K.jsx)(`p`,{className:`text-xs text-outline mt-2`,children:`Before`}),(0,K.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap break-all`,children:e}),(0,K.jsx)(`p`,{className:`text-xs text-outline mt-2`,children:`After`}),(0,K.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap break-all`,children:t})]})]})}function Ye({name:e}){let t=r(),[n,i]=(0,U.useState)(!1),a=p({queryKey:[`skill-origin`,e],queryFn:()=>w.skills.origin(e)}),o=_({mutationFn:t=>w.skills.sync(e,t),onSuccess:async n=>{i(!1),n.applied&&await Promise.all([t.invalidateQueries({queryKey:[`skill`,e]}),t.invalidateQueries({queryKey:[`skills`]}),t.invalidateQueries({queryKey:[`skill-origin`,e]})])}});if(a.error)return(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a.error.message});if(!a.data)return null;let s=o.data,c=s&&!s.applied&&s.conflicts.length>0;return(0,K.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Imported from`,` `,(0,K.jsx)(`a`,{className:`text-primary underline`,href:`https://github.com/${a.data.repository}/tree/${encodeURIComponent(a.data.ref===`HEAD`?a.data.commit:a.data.ref)}/${a.data.path}`,target:`_blank`,rel:`noreferrer`,children:a.data.repository}),` `,`· `,a.data.commit.slice(0,8)]}),(0,K.jsx)(b,{"data-testid":`skill-sync`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({}),children:o.isPending?`Syncing…`:`Sync from GitHub`}),s?.applied&&(0,K.jsx)(`p`,{role:`status`,"data-testid":`skill-sync-status`,className:`text-xs`,children:s.changed.length?`Synced ${s.changed.length} files. Local edits preserved outside confirmed conflicts.`:`Up to date. Local edits preserved.`}),c&&(0,K.jsxs)(`div`,{"data-testid":`skill-sync-conflicts`,className:`space-y-2`,children:[(0,K.jsx)(`p`,{role:`alert`,className:`text-sm`,children:`Sync paused. Both you and GitHub changed these files:`}),(0,K.jsx)(`ul`,{className:`text-xs space-y-1`,children:s.conflicts.map(e=>(0,K.jsx)(`li`,{children:e},e))}),(0,K.jsx)(b,{"data-testid":`skill-sync-review-override`,variant:`outline`,size:`sm`,onClick:()=>i(!0),children:`Review override`})]}),o.error&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o.error.message}),(0,K.jsx)(k,{open:n,onOpenChange:e=>!o.isPending&&i(e),children:(0,K.jsxs)(E,{children:[(0,K.jsx)(M,{children:(0,K.jsx)(T,{children:`Replace conflicting local edits?`})}),(0,K.jsxs)(`p`,{className:`text-sm`,children:[`GitHub's version at `,s?.commit.slice(0,8),` will replace or remove these files. Your other local edits will be kept. The current skill folder will be backed up.`]}),(0,K.jsx)(`ul`,{className:`text-sm space-y-1`,children:s?.conflicts.map(e=>(0,K.jsx)(`li`,{children:e},e))}),(0,K.jsxs)(O,{children:[(0,K.jsx)(b,{variant:`ghost`,disabled:o.isPending,onClick:()=>i(!1),children:`Keep local edits`}),(0,K.jsx)(b,{"data-testid":`skill-sync-confirm-override`,disabled:o.isPending,onClick:()=>s&&o.mutate({override:!0,expectedCommit:s.commit,expectedRevision:s.revision}),children:o.isPending?`Syncing…`:`Replace listed files`})]})]})})]})}function Xe(e){return p({queryKey:[`skills`,e],queryFn:()=>w.skills.list(e)})}function Ze(){return p({queryKey:[`skill-visibility`],queryFn:()=>w.skills.visibility()})}function Qe(){let e=r();return _({mutationFn:e=>w.skills.setVisibility(e),onSuccess:t=>{e.setQueryData([`skill-visibility`],t),e.invalidateQueries({queryKey:[`skills`]})}})}function $e(e,t,n={}){return p({queryKey:[`skill`,e,t,n],queryFn:()=>w.skills.get(e,t,n),enabled:!!e})}function et(){let e=r();return _({mutationFn:e=>w.skills.create(e),onSuccess:()=>e.invalidateQueries({queryKey:[`skills`]})})}var tt={default:`none`,asc:`ascending`,desc:`descending`},nt={default:W,asc:le,desc:oe},rt=[{value:`all`,label:`All`},{value:`builtin`,label:`Built-in`},{value:`user`,label:`User`}],it={sync:`synced`,delete:`deleted`,hide:`hidden`,show:`shown`},at={builtin:`text-muted-foreground`,user:`text-muted-foreground`};function ot({projectId:e}){let t=ye(e),n=t===`all`||t===`unassigned`?{scope:`global`}:{project_id:t},[i,a]=I(`skillQuery`,``),[o,s]=(0,U.useState)(i),[c,l]=I(`source`,`all`,[`all`,`builtin`,`user`]),[u,d]=I(`skillRepositorySort`,`default`,[`default`,`asc`,`desc`]),f=nt[u];(0,U.useEffect)(()=>s(i),[i]);let{selectedId:p,openDetail:m,closeDetail:h}=pe(`/skills`,`skillName`),[g,v]=(0,U.useState)(!1),[y,x]=(0,U.useState)(!1),[S,C]=(0,U.useState)(!1),T=Ze(),E=Qe(),D=JSON.stringify([t,i,c]),[ne,O]=(0,U.useState)({scope:D,offset:0}),k=ne.scope===D?ne.offset:0,{data:A,isLoading:ie,error:ae,refetch:oe}=Xe({...n,q:i||void 0,source:c===`all`?void 0:c,include_hidden:!0,limit:30,offset:k}),j=A?.skills,M=r(),N=(j??[]).filter(e=>e.source===`user`),P=Ce({queries:N.map(e=>({queryKey:[`skill-origin`,e.name],queryFn:()=>w.skills.origin(e.name)}))}),le=N.filter((e,t)=>!!P[t]?.data).map(e=>e.name),z=new Map(N.map((e,t)=>[e.name,P[t]?.data?.repository])),Se=[...j??[]];!i&&u!=="default"&&Se.sort((e,t)=>{let n=z.get(e.name),r=z.get(t.name);if(!n&&r)return 1;if(n&&!r)return-1;let i=(n??``).localeCompare(r??``,void 0,{sensitivity:`base`});return i?u===`asc`?i:-i:e.name.localeCompare(t.name)});let B=JSON.stringify([t,i,c,k]),V=(0,U.useRef)(B);V.current=B;let H=xe((j??[]).map(e=>e.name),B),we=(j??[]).filter(e=>H.selectedIds.includes(e.name)),W=we.filter(e=>le.includes(e.name)),G=we.filter(e=>e.source===`user`),[Ee,Oe]=(0,U.useState)(!1),q=_({mutationFn:async({action:e,names:t,scope:n})=>{if(e===`hide`||e===`show`){let r=new Set(T.data?.hidden_skills??[]),i=new Set(T.data?.hidden_builtins??[]);for(let n of t)e===`hide`?r.add(n):(r.delete(n),i.delete(n));return await E.mutateAsync({hidden_skills:[...r],hidden_builtins:[...i]}),{action:e,scope:n,succeeded:t,failed:[]}}return{action:e,scope:n,...await te(t,async t=>{if(e===`delete`)return w.skills.delete(t);let n=await w.skills.sync(t);if(!n.applied)throw Error(`Conflicts: ${n.conflicts.join(`, `)}. Open this skill to review.`)})}},onSettled:async()=>{await Promise.all([M.invalidateQueries({queryKey:[`skills`]}),M.invalidateQueries({queryKey:[`skill`]}),M.invalidateQueries({queryKey:[`skill-origin`]})])}}),J=q.data?.scope===B?q.data:void 0;async function Y(e,t){let n=await q.mutateAsync({action:e,names:t,scope:B});n.scope===V.current&&H.select(n.failed.map(e=>e.id))}return ae?(0,K.jsx)(de,{message:ae.message,onRetry:()=>oe()}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(fe,{title:`Skills`,meta:`${(j??[]).length} skills`,action:(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsxs)(b,{"data-testid":`import-skill-button`,size:`sm`,variant:`outline`,onClick:()=>x(!0),children:[(0,K.jsx)(ee,{size:12,className:`mr-1`}),` Import from GitHub`]}),(0,K.jsxs)(b,{"data-testid":`import-local-skills-button`,size:`sm`,variant:`outline`,onClick:()=>C(!0),children:[(0,K.jsx)(ee,{size:12,className:`mr-1`}),` Import from agents`]}),(0,K.jsxs)(b,{"data-testid":`new-skill-button`,size:`sm`,onClick:()=>v(!0),className:`font-label text-sm `,children:[(0,K.jsx)(ce,{size:12,className:`mr-1`}),` New skill`]})]})}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:[`Skill folders follow the`,` `,(0,K.jsx)(`a`,{className:`text-primary underline`,href:`https://agentskills.io/specification`,target:`_blank`,rel:`noreferrer`,children:`Agent Skills specification`}),`.`]}),(T.error||E.error)&&(0,K.jsx)(`p`,{role:`alert`,className:`text-destructive text-xs mb-2`,children:(T.error||E.error)?.message}),A?.broken?.map(e=>(0,K.jsxs)(`p`,{role:`alert`,className:`text-destructive text-xs mb-2`,children:[e.path,`: `,e.error]},e.path)),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:rt.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(e.value),"data-testid":`skill-source-${e.value}`,"aria-pressed":c===e.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${c===e.value?`bg-surface-highest text-on-surface border-transparent`:`bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:e.label},e.value))}),(0,K.jsxs)(`div`,{className:`relative min-w-[160px] flex-1`,children:[(0,K.jsx)(se,{size:12,className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,K.jsx)(F,{"data-testid":`skill-search-input`,"aria-label":`Search skills`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&a(e.currentTarget.value),placeholder:`Search skills...`,className:`pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground`})]}),(0,K.jsx)(b,{"data-testid":`skill-search-submit`,variant:`outline`,size:`sm`,onClick:()=>a(o),className:`font-label text-sm `,children:`Search`})]}),!!j?.length&&(0,K.jsxs)(be,{resourceLabel:`skills`,count:H.selectedIds.length,allSelected:H.allSelected,someSelected:H.someSelected,onSelectAll:H.selectAll,onClear:H.clear,disabled:q.isPending,children:[(0,K.jsx)(b,{"data-testid":`skills-bulk-hide`,variant:`outline`,size:`sm`,disabled:q.isPending||!T.data,onClick:()=>void Y(`hide`,H.selectedIds),children:`Hide`}),(0,K.jsx)(b,{"data-testid":`skills-bulk-show`,variant:`outline`,size:`sm`,disabled:q.isPending||!T.data,onClick:()=>void Y(`show`,H.selectedIds),children:`Show`}),(0,K.jsx)(b,{"data-testid":`skills-bulk-sync`,variant:`outline`,size:`sm`,title:`Local edits are kept; conflicts need review`,disabled:q.isPending||!W.length||P.some(e=>e.isPending),onClick:()=>void Y(`sync`,W.map(e=>e.name)),children:q.isPending&&q.variables?.action===`sync`?`Syncing…`:`Sync from GitHub${W.length?` (${W.length})`:``}`}),(0,K.jsx)(b,{"data-testid":`skills-bulk-delete`,variant:`outline`,size:`sm`,className:`text-destructive`,title:`Built-in skills cannot be deleted`,disabled:q.isPending||!G.length,onClick:()=>Oe(!0),children:`Delete${G.length?` (${G.length})`:``}`})]}),(0,K.jsx)(ue,{open:Ee,title:`Delete skills`,description:`Delete ${G.map(e=>e.name).join(`, `)}? This removes the skill folders and cannot be undone.`,isPending:q.isPending,onCancel:()=>Oe(!1),onConfirm:()=>{Oe(!1),Y(`delete`,G.map(e=>e.name))}}),P.some(e=>e.error)&&(0,K.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not check GitHub origins: `,P.find(e=>e.error)?.error?.message]}),J&&(0,K.jsxs)(`div`,{"data-testid":`skills-bulk-result`,role:`status`,className:`mb-3 text-sm`,children:[(0,K.jsxs)(`p`,{children:[J.succeeded.length,` `,it[J.action],J.failed.length?`; ${J.failed.length} need attention.`:`.`]}),J.failed.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`block text-left text-destructive underline`,onClick:()=>m(e.id),children:[e.id,`: `,e.error]},e.id))]}),ie?(0,K.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,K.jsx)(re,{className:`h-10 w-full bg-surface-highest`},t))}):(j??[]).length===0?(0,K.jsx)(me,{message:i?`No skills match your search`:`No skills found`}):(0,K.jsx)(`div`,{className:`overflow-hidden`,children:(0,K.jsxs)(ve,{children:[(0,K.jsx)(he,{children:(0,K.jsxs)(_e,{className:`border-b border-outline-variant hover:bg-transparent`,children:[(0,K.jsx)(L,{className:`w-12`,children:(0,K.jsx)(`span`,{className:`sr-only`,children:`Select skills`})}),(0,K.jsx)(L,{className:`font-label text-sm text-muted-foreground`,children:`Name`}),(0,K.jsx)(L,{className:`font-label text-sm text-muted-foreground`,children:`Description`}),(0,K.jsx)(L,{className:`font-label text-sm text-muted-foreground w-24`,children:`Source`}),(0,K.jsx)(L,{"data-testid":`skill-repository-header`,"aria-sort":tt[u],children:(0,K.jsxs)(`button`,{type:`button`,"data-testid":`skill-repository-sort`,className:`flex min-h-11 items-center gap-2 text-sm text-muted-foreground hover:text-on-surface`,onClick:()=>{d(u==="default"?`asc`:u===`asc`?`desc`:`default`)},title:`Sort by GitHub repository: ascending, descending, then default order`,children:[`GitHub repository `,(0,K.jsx)(f,{size:14,"aria-hidden":`true`})]})}),(0,K.jsx)(L,{className:`text-xs text-muted-foreground`,children:`Agent discovery`})]})}),(0,K.jsx)(ge,{children:Se.map(e=>(0,K.jsxs)(_e,{"data-testid":`skill-row`,"data-skill-name":e.name,className:`border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer`,onClick:()=>m(e.name),children:[(0,K.jsx)(R,{onClick:e=>e.stopPropagation(),children:(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`skill-select`,"aria-label":`Select ${e.name}`,checked:H.selectedIds.includes(e.name),disabled:q.isPending,onChange:()=>H.toggle(e.name),className:`size-4 accent-primary`})}),(0,K.jsxs)(R,{className:`font-body text-sm font-medium text-on-surface`,children:[(0,K.jsx)(`button`,{type:`button`,"data-testid":`skill-open`,className:`min-h-11 text-left hover:text-primary`,onClick:t=>{t.stopPropagation(),m(e.name)},children:e.name}),e.mutation&&(0,K.jsx)(`span`,{className:`ml-2 text-primary text-xs`,title:`Instructions were edited`,children:`Modified`})]}),(0,K.jsx)(R,{className:`font-body text-sm text-muted-foreground max-w-md truncate`,children:e.description||`—`}),(0,K.jsx)(R,{"data-testid":`skill-source-cell`,children:(0,K.jsx)(`span`,{className:`inline-flex py-0.5 font-label text-sm ${at[e.source]}`,children:e.source})}),(0,K.jsx)(R,{"data-testid":`skill-repository-cell`,onClick:e=>e.stopPropagation(),className:`max-w-56 truncate text-sm text-muted-foreground`,children:z.get(e.name)?(0,K.jsx)(`a`,{"data-testid":`skill-repository-link`,href:`https://github.com/${z.get(e.name)}`,target:`_blank`,rel:`noreferrer`,className:`text-primary hover:underline`,title:z.get(e.name),children:z.get(e.name)}):`—`}),(0,K.jsx)(R,{onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`button`,{type:`button`,role:`switch`,"aria-label":`${e.name} visible to agents`,"aria-checked":!e.discovery_hidden,"data-testid":`skill-visibility-${e.name}`,disabled:!T.data||E.isPending,className:`inline-flex min-h-11 items-center gap-2 text-xs text-primary disabled:opacity-50`,title:e.discovery_hidden?`Hidden from agent discovery. Still loadable by name and in flows.`:`Hide from agent discovery`,onClick:()=>{let t=new Set(T.data?.hidden_skills??[]),n=new Set(T.data?.hidden_builtins??[]);e.discovery_hidden?(t.delete(e.name),n.delete(e.name)):t.add(e.name),E.mutate({hidden_skills:[...t],hidden_builtins:[...n]})},children:[e.discovery_hidden?(0,K.jsx)(Te,{size:22,"aria-hidden":`true`,className:`text-muted-foreground`}):(0,K.jsx)(De,{size:22,"aria-hidden":`true`}),e.discovery_hidden?`Hidden`:`Visible`,e.mutation&&` (Modified)`]})})]},e.name))})]})}),A&&A.total>30&&(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-4`,"data-testid":`skills-pagination`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-muted-foreground`,"data-testid":`skills-page-summary`,children:[k+1,`–`,Math.min(k+A.skills.length,A.total),` of`,` `,A.total]}),(0,K.jsx)(b,{variant:`outline`,size:`sm`,"data-testid":`skills-previous`,disabled:k===0||ie,onClick:()=>O({scope:D,offset:Math.max(0,k-30)}),children:`Previous`}),(0,K.jsx)(b,{variant:`outline`,size:`sm`,"data-testid":`skills-next`,disabled:A.next_offset===null||ie,onClick:()=>O({scope:D,offset:A.next_offset??k}),children:`Next`})]}),(0,K.jsx)(st,{scope:n,skillName:p,open:!!p,onClose:h},p),g&&(0,K.jsx)(ct,{open:g,onClose:()=>v(!1)}),y&&(0,K.jsx)(Ae,{onClose:()=>x(!1)}),S&&(0,K.jsx)(ke,{onClose:()=>C(!1)})]})}function st({skillName:e,scope:t,open:n,onClose:i}){let{data:a,isLoading:o,error:s,refetch:c}=$e(e,void 0,t),l=a,[u,d]=I(`skillFile`,`SKILL.md`),f=$e(e,u??`SKILL.md`,t),p=f.data,m=r(),[h,g]=(0,U.useState)(!1),_=`skill:${t.project_id??`global`}:${e}:${u??`SKILL.md`}`;function v(e){return(e??`SKILL.md`)===(u??`SKILL.md`)?!0:z(_)?(d(e??`SKILL.md`),!0):!1}let y=l?(0,K.jsx)(Oe,{files:[`SKILL.md`,...(l.files??[]).map(e=>e.name)],selected:u??`SKILL.md`,onSelect:e=>v(e===`SKILL.md`?void 0:e),testId:`skill-file`,entryTestId:`skill-show-entry`}):null;return(0,K.jsx)(A,{open:n,onOpenChange:e=>!e&&z(_)&&i(),children:(0,K.jsxs)(ne,{defaultWidth:1120,resizeKey:`skills`,children:[(0,K.jsxs)(ae,{children:[(0,K.jsx)(ie,{children:l?.name??`Skill Details`}),l?.description&&(0,K.jsx)(`p`,{className:`font-body text-sm text-muted-foreground mt-1`,children:l.description})]}),(0,K.jsx)(D,{children:(0,K.jsxs)(K.Fragment,{children:[e&&l&&(0,K.jsx)(qe,{name:e,scope:t,mutation:l.mutation}),e&&l&&(0,K.jsx)(Ye,{name:e}),s?(0,K.jsx)(de,{message:s.message,onRetry:()=>void c()}):o||!l?(0,K.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,]].map((e,t)=>(0,K.jsx)(re,{className:`h-8 w-full bg-surface-highest`},t))}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,K.jsx)(P,{label:`Source`,children:(0,K.jsx)(`span`,{className:`inline-flex py-0.5 font-label text-sm ${at[l.source]}`,children:l.source})}),(0,K.jsx)(P,{label:`Path`,children:(0,K.jsx)(`code`,{className:`font-mono text-sm text-muted-foreground break-all`,children:l.path})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-label text-sm text-muted-foreground mb-2`,children:u??`SKILL.md`}),(0,K.jsxs)(`div`,{className:`overflow-hidden`,children:[p?.encoding===`base64`&&(0,K.jsx)(`div`,{className:`p-3`,children:y}),f.error?(0,K.jsx)(`p`,{role:`alert`,children:f.error.message}):f.isLoading?(0,K.jsx)(`p`,{children:`Loading...`}):p?.encoding===`base64`?(0,K.jsx)(j,{path:u??`SKILL.md`,value:p?.content??``,readOnly:!0,hidePreview:!0,height:400,testId:`skill-file-content`}):(0,K.jsx)(Se,{documentId:_,expanded:h,onExpandedChange:g,navigation:y,path:u??`SKILL.md`,content:p?.content??``,testId:`skill-file-content`,onSave:l.source===`user`&&p?.encoding===`utf8`?async(e,n)=>{let r=u??`SKILL.md`;return l.mutation&&r===`SKILL.md`?await w.skills.updateInstructions(l.name,{project_id:t.project_id??null,content:e,expected_content:n,reason:`Manual instruction edit`,author:`human`}):await w.skills.editFile(l.name,{path:r,content:e,expectedContent:n}),await m.invalidateQueries({queryKey:[`skill`,l.name]}),await m.invalidateQueries({queryKey:[`skills`]}),await m.invalidateQueries({queryKey:[`skill-history`,l.name]}),e}:void 0},_),p?.encoding===`base64`&&(0,K.jsx)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:`Binary asset shown as base64 (read-only).`})]})]})]})]})})]})})}function ct({open:e,onClose:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(``),o=et(),[s,c]=(0,U.useState)([]),[l,u]=(0,U.useState)(),[d,f]=(0,U.useState)(!1),p=!!(n||i||s.length);(0,U.useEffect)(()=>{if(!p)return;function e(e){e.preventDefault(),e.returnValue=``}return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[p]);function m(){o.isPending||d||(!p||window.confirm(`Discard this unsaved skill?`))&&t()}async function h(e){if(e?.length){f(!0),u(void 0);try{let t=(await B(e)).map(e=>({...e,encoding:e.encoding??`utf8`,id:crypto.randomUUID()})),n=t.find(e=>e.path===`SKILL.md`);if(!n)throw Error(`Choose a skill folder containing SKILL.md`);if(n.encoding!==`utf8`)throw Error(`SKILL.md must be UTF-8 text`);a(n.content),r(e[0].webkitRelativePath.split(`/`)[0]),c(t.filter(e=>e!==n))}catch(e){u(e.message)}finally{f(!1)}}}let g=()=>{!n.trim()||!i.trim()||o.isPending||d||s.some(e=>!e.path.trim())||o.mutate({name:n.trim(),content:i.trim(),files:s.map(({path:e,content:t,encoding:n})=>({path:e,content:t,encoding:n}))},{onSuccess:t})};return(0,K.jsx)(k,{open:e,onOpenChange:e=>!e&&m(),children:(0,K.jsxs)(E,{className:`bg-surface border-outline-variant w-[calc(100%-1rem)] max-w-5xl max-h-[94dvh] overflow-y-auto`,children:[(0,K.jsx)(M,{children:(0,K.jsx)(T,{className:`font-headline text-base text-on-surface`,children:`New skill`})}),(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`space-y-3 mt-2`,children:[(0,K.jsx)(x,{htmlFor:`skill-folder-input`,children:`Import skill folder`}),(0,K.jsx)(F,{id:`skill-folder-input`,"data-testid":`skill-folder-input`,type:`file`,multiple:!0,webkitdirectory:``,onChange:e=>void h(e.target.files)}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`Name *`}),(0,K.jsx)(F,{"aria-label":`Name`,"data-testid":`skill-name-input`,value:n,onChange:e=>r(e.target.value),placeholder:`my-skill`,className:`bg-background text-on-surface font-body text-sm`,autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`SKILL.md *`}),(0,K.jsx)(C,{testId:`skill-content-input`,path:`SKILL.md`,value:i,onChange:a,onSave:g})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(b,{"data-testid":`skill-add-file`,type:`button`,variant:`outline`,onClick:()=>c([...s,{id:crypto.randomUUID(),path:``,content:``,encoding:`utf8`}]),children:`Add file`}),s.map(e=>(0,K.jsxs)(`div`,{"data-testid":`skill-supporting-file`,className:`space-y-2 border border-outline-variant p-3`,children:[(0,K.jsx)(F,{"data-testid":`skill-file-path-input`,"aria-label":`File path`,placeholder:`references/guide.md or scripts/check.py`,value:e.path,onChange:t=>c(s.map(n=>n.id===e.id?{...n,path:t.target.value}:n))}),(0,K.jsx)(j,{testId:`skill-file-content-input`,path:e.path||`supporting.txt`,readOnly:e.encoding===`base64`,label:`Content of ${e.path||`supporting file`}`,value:e.content,height:180,onChange:t=>c(s.map(n=>n.id===e.id?{...n,content:t}:n))}),e.encoding===`base64`&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Binary asset (base64)`}),(0,K.jsx)(b,{type:`button`,variant:`ghost`,onClick:()=>c(s.filter(t=>t.id!==e.id)),children:`Remove file`})]},e.id))]}),(l||o.error)&&(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:l??o.error?.message}),(0,K.jsxs)(O,{children:[(0,K.jsx)(b,{type:`button`,variant:`ghost`,size:`sm`,onClick:m,className:`font-label text-sm text-muted-foreground`,children:`Cancel`}),(0,K.jsx)(b,{"data-testid":`skill-submit`,type:`submit`,size:`sm`,disabled:d||o.isPending||!n.trim()||!i.trim()||s.some(e=>!e.path.trim()),className:`font-label text-sm `,children:o.isPending?`Creating...`:`Create`})]})]})]})})}export{ot as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./createLucideIcon-jLuHkL03.js";import{t as i}from"./Markdown-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./createLucideIcon-jLuHkL03.js";import{t as i}from"./Markdown-BYChkZ3Z.js";import{t as a}from"./file-kind-BYU1kv95.js";import{in as o,v as s}from"./index-CMRGRbC9.js";var c={name:`text-wrap`,size:24,node:[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]],aliases:[`wrap-text`]};c.node;var l=r(c),u=[],d=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?d:u).push(n+=e[t])})();function f(e){if(e<768)return!1;for(let t=0,n=u.length;;){let r=t+n>>1;if(e<u[r])n=r;else if(e>=d[r])t=r+1;else return!0;if(t==n)return!1}}function p(e){return e>=127462&&e<=127487}var m=8205;function h(e,t,n=!0,r=!0){return(n?g:_)(e,t,r)}function g(e,t,n){if(t==e.length)return t;t&&y(e.charCodeAt(t))&&ee(e.charCodeAt(t-1))&&t--;let r=v(e,t);for(t+=b(r);t<e.length;){let i=v(e,t);if(r==m||i==m||n&&f(i))t+=b(i),r=i;else if(p(i)){let n=0,r=t-2;for(;r>=0&&p(v(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function _(e,t,n){for(;t>1;){let r=g(e,t-2,n);if(r<t)return r;t--}return 0}function v(e,t){let n=e.charCodeAt(t);if(!ee(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return y(r)?(n-55296<<10)+(r-56320)+65536:n}function y(e){return e>=56320&&e<57344}function ee(e){return e>=55296&&e<56320}function b(e){return e<65536?1:2}var x=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=le(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),te.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=le(this,e,t);let n=[];return this.decompose(e,t,n,0),te.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new ae(this),i=new ae(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new ae(this,e)}iterRange(e,t=this.length){return new oe(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new se(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new S(t):te.from(S.split(t,[]))}},S=class e extends x{constructor(e,t=ne(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new ce(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(ie(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=re(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=le(this,t,n);let i=re(this.text,re(r.text,ie(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):te.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
2
2
|
`){[e,t]=le(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},te=class e extends x{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=le(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
3
3
|
`){[e,t]=le(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new S(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof S&&c&&(n=u[u.length-1])instanceof S&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new S(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};x.empty=new S([``],0);function ne(e){let t=-1;for(let n of e)t+=n.length+1;return t}function re(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function ie(e,t,n){return re(e,[``],t,n)}var ae=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof S?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof S?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(r instanceof S){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof S?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},oe=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new ae(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},se=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(x.prototype[Symbol.iterator]=function(){return this.iter()},ae.prototype[Symbol.iterator]=oe.prototype[Symbol.iterator]=se.prototype[Symbol.iterator]=function(){return this});var ce=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function le(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function C(e,t,n=!0,r=!0){return h(e,t,n,r)}function ue(e){return e>=56320&&e<57344}function de(e){return e>=55296&&e<56320}function fe(e,t){let n=e.charCodeAt(t);if(!de(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ue(r)?(n-55296<<10)+(r-56320)+65536:n}function pe(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function me(e){return e<65536?1:2}var he=/\r\n?|\n/,ge=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(ge||={}),_e=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){xe(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Ce(this,e)}mapDesc(e,t=!1){return e.empty?this:Se(this,e,t)}mapPos(e,t=-1,n=ge.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=ge.Simple&&c>=e&&(n==ge.TrackDel&&r<e&&c>e||n==ge.TrackBefore&&r<e||n==ge.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},ve=class e extends _e{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return xe(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return Se(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(x.empty);r.push(a?t.slice(i,i+a):x.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Ce(this,e,!0)}map(e,t=!1){return e.empty?this:Se(this,e,t,!0)}iterChanges(e,t=!1){xe(this,e,t)}get desc(){return _e.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new we(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);ye(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;ye(n,e,t),t>0&&be(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);ye(n,e,-1),ye(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:_e.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&ye(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?x.of(l.split(r||he)):l:x.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&ye(i,e-o,-1),ye(i,s-e,d),be(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(x.empty);r[e]=x.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function ye(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function be(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(x.empty);e.push(n)}}function xe(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=x.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function Se(e,t,n,r=!1){let i=[],a=r?[]:null,o=new we(e),s=new we(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);ye(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(ye(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(ye(i,0,o.ins),a&&be(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;ye(i,t,e<o.i?o.ins:0),a&&e<o.i&&be(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?ve.createSet(i,a):_e.create(i);else throw Error(`Mismatched change set lengths`)}function Ce(e,t,n=!1){let r=[],i=n?[]:null,a=new we(e),o=new we(t);for(let e=!1;;)if(a.done&&o.done)return i?ve.createSet(r,i):_e.create(r);else if(a.ins==0)ye(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)ye(r,0,o.ins,e),i&&be(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;ye(r,t,n,e),i&&n&&be(i,r,o.text)}else o.ins==-1?(ye(r,a.off?0:a.len,t,e),i&&be(i,r,a.textBit(t))):(ye(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&be(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var we=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?x.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?x.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Te=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return w.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return w.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return w.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},w=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Te.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Te.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?Te.create(t,e,a|32,n):Te.create(e,t,a,n)}static undirectionalRange(e,t){return Te.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Ee(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var De=0,T=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=De++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Oe),!!t.static,t.enables)}of(e){return new ke([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new ke(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new ke(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Oe(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var ke=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=De++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||je(e,c)){let r=t(e);if(a?!Ae(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=We(o,c);if(this.dependencies.every(t=>t instanceof T?o.facet(t)===e.facet(t):t instanceof Pe?o.field(t,!1)==e.field(t,!1):!0)||(a?Ae(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function Ae(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function je(e,t){let n=!1;for(let r of t)Ue(e,r)&1&&(n=!0);return n}function Me(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=We(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Ue(e,t);return e.values[o]=s(e),1},update(e,n){if(!je(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=je(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Oe(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Ne=T.define({static:!0}),Pe=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(De++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Ne).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Ne),i=n.facet(Ne),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Ne.of({field:this,create:e})]}get extension(){return this}},Fe={lowest:4,low:3,default:2,high:1,highest:0};function Ie(e){return t=>new Re(t,e)}var Le={highest:Ie(Fe.highest),high:Ie(Fe.high),default:Ie(Fe.default),low:Ie(Fe.low),lowest:Ie(Fe.lowest)},Re=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},ze=class e{of(e){return new Be(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Be=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Ve=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of He(t,n,o))e instanceof Pe?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,Oe(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Me(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function He(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Be&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Be){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Re)a(e.inner,e.prec);else if(e instanceof Pe)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof ke)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Fe.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Fe.default),r.reduce((e,t)=>e.concat(t))}function Ue(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function We(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Ge=T.define(),Ke=T.define({combine:e=>e.some(e=>e),static:!0}),qe=T.define({combine:e=>e.length?e[0]:void 0,static:!0}),Je=T.define(),Ye=T.define(),Xe=T.define(),Ze=T.define({combine:e=>e.length?e[0]:!1}),Qe=class{constructor(e,t){this.type=e,this.value=t}static define(){return new $e}},$e=class{of(e){return new Qe(this,e)}},et=class{constructor(e){this.map=e}of(e){return new E(this,e)}},E=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new et(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};E.reconfigure=E.define(),E.appendConfig=E.define();var tt=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Ee(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};tt.time=Qe.define(),tt.userEvent=Qe.define(),tt.addToHistory=Qe.define(),tt.remote=Qe.define();function nt(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function rt(e,t,n){let r,i,a;return n?(r=t.changes,i=ve.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:E.mapEffects(e.effects,r).concat(E.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function it(e,t,n){let r=t.selection,i=lt(t.annotations);return t.userEvent&&(i=i.concat(tt.userEvent.of(t.userEvent))),{changes:t.changes instanceof ve?t.changes:ve.of(t.changes||[],n,e.facet(qe)),selection:r&&(r instanceof w?r:w.single(r.anchor,r.head)),effects:lt(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function at(e,t,n){let r=it(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=rt(r,it(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=tt.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return st(n?ot(i):i)}function ot(e){let t=e.startState,n=!0;for(let r of t.facet(Je)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:nt(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=ve.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=tt.create(t,r,e.selection&&e.selection.map(i),E.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Ye);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof tt?i:Array.isArray(i)&&i.length==1&&i[0]instanceof tt?i[0]:at(t,lt(i),!1)}return e}function st(e){let t=e.startState,n=t.facet(Xe),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=rt(r,it(t,a,e.changes.newLength),!0))}return r==e?e:tt.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var ct=[];function lt(e){return e==null?ct:Array.isArray(e)?e:[e]}var D=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(D||={}),ut=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,dt;try{dt=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function ft(e){if(dt)return dt.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||ut.test(n)))return!0}return!1}function pt(e){return t=>{if(!/\S/.test(t))return D.Space;if(ft(t))return D.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return D.Word;return D.Other}}var O=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Ue(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`)}else return Ue(this,n),We(this,n)}update(...e){return at(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(ze.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(E.reconfigure)?(n=null,r=e.value):e.is(E.appendConfig)&&(n=null,r=lt(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Ve.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Ke)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:w.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=lt(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=E.mapEffects(a,c).concat(E.mapEffects(lt(o.effects),l))}return{changes:r,selection:w.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof ve?t:ve.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return x.of(t.split(this.facet(e.lineSeparator)||he))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ue(this,t),We(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Pe&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:w.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Ve.resolve(t.extensions||[],new Map),r=t.doc instanceof x?t.doc:x.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||he)),i=t.selection?t.selection instanceof w?t.selection:w.single(t.selection.anchor,t.selection.head):w.single(0);return Ee(i,r.length),n.staticFacet(Ke)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{r as t}from"./button-BHKbOsmj.js";var n=e(),r={todo:`bg-muted-foreground`,queued:`bg-progress`,doing:`bg-progress`,review:`bg-tertiary`,changes_requested:`bg-error`,blocked:`bg-error`,done:`bg-secondary`,cancelled:`bg-muted-foreground`,paused:`bg-muted-foreground`},i={pending:`bg-muted-foreground`,running:`bg-progress`,success:`bg-secondary`,failed:`bg-error`,cancelled:`bg-muted-foreground`,skipped:`bg-muted-foreground`};function a({status:e,type:a=`task`,className:o}){let s=a===`job`?i[e]??`bg-muted-foreground`:r[e]??`bg-muted-foreground`;return(0,n.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs font-label font-normal text-muted-foreground`,o),children:[(0,n.jsx)(`span`,{className:t(`size-1.5 rounded-full shrink-0`,s)}),e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `)]})}export{a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{r}from"./button-BHKbOsmj.js";import{t as i}from"./x-BKorzD7S.js";var a=e(t(),1),o=n(),s=/[,\s]+/;function c(e,t){let n=t.split(s).map(e=>e.trim()).filter(Boolean);return[...new Set([...e,...n])]}function l({value:e,onChange:t,suggestions:n=[],placeholder:l=`Add a label`,"aria-label":u,"data-testid":d}){let[f,p]=(0,a.useState)(``),m=(0,a.useRef)(null),h=(0,a.useId)(),g=n.filter(t=>!e.includes(t));function _(n){let r=c(e,n);r.length!==e.length&&t(r),p(``)}function v(n){let r=n.split(s);if(r.length>1){let n=r.pop()??``;t(c(e,r.join(`,`))),p(n)}else p(n)}function y(n){(n.key===`Enter`||n.key===`Tab`)&&f.trim()?(n.preventDefault(),_(f)):n.key===`Backspace`&&!f&&e.length>0&&(n.preventDefault(),t(e.slice(0,-1)))}function b(e){let t=e.clipboardData.getData(`text`);s.test(t)&&(e.preventDefault(),_(`${f},${t}`))}return(0,o.jsxs)(`div`,{className:r(`flex min-h-10 w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border border-control-border bg-surface px-2 py-1.5 text-sm`,`focus-within:ring-2 focus-within:ring-focus focus-within:ring-offset-2 ring-offset-background`),onClick:()=>m.current?.focus(),children:[e.map(n=>(0,o.jsxs)(`span`,{"data-testid":`tag-input-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full border border-outline-variant bg-surface-high py-0.5 pl-2.5 pr-1 text-xs text-on-surface`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:n}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Remove ${n}`,className:`rounded-full p-0.5 text-outline hover:bg-surface-highest hover:text-on-surface focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus`,onClick:r=>{r.stopPropagation(),t(e.filter(e=>e!==n)),m.current?.focus()},children:(0,o.jsx)(i,{size:12,"aria-hidden":!0})})]},n)),(0,o.jsx)(`input`,{ref:m,"aria-label":u,"data-testid":d,list:g.length>0?h:void 0,value:f,onChange:e=>v(e.target.value),onKeyDown:y,onPaste:b,onBlur:()=>f.trim()&&_(f),placeholder:e.length===0?l:``,className:`h-7 min-w-32 flex-1 bg-transparent px-1 outline-hidden placeholder:text-muted-foreground`}),g.length>0&&(0,o.jsx)(`datalist`,{id:h,children:g.map(e=>(0,o.jsx)(`option`,{value:e},e))})]})}export{l as t};
|