orc-ai 0.1.63 → 0.1.65
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/README.md +3 -2
- package/dist/index.js +910 -809
- package/dist/skills/orc-platform/SKILL.md +1 -1
- package/dist/skills/orc-platform/references/html-kit.md +154 -0
- package/dist/skills/orc-platform/references/scratchpads.md +6 -2
- package/dist/web/assets/{Agents-DmrIiUAL.js → Agents-CXxHOAVS.js} +2 -2
- package/dist/web/assets/Audit-B38_H4W1.js +1 -0
- package/dist/web/assets/ChatUiRenderer-BYlgsVLZ.js +4 -0
- package/dist/web/assets/ConfirmDialog-DKN0AVIw.js +1 -0
- package/dist/web/assets/{Dashboard-Dh9P-zTd.js → Dashboard-BZKUS4Tw.js} +1 -1
- package/dist/web/assets/DocumentWorkspace-B9hQN2EX.js +1 -0
- package/dist/web/assets/{ErrorState-DB0nWfcc.js → ErrorState-CpcyNx03.js} +1 -1
- package/dist/web/assets/FileEditor-BK8_4AJM.js +1 -0
- package/dist/web/assets/{IntegrationCallback-CUZ5N-88.js → IntegrationCallback-DCf4a1AA.js} +1 -1
- package/dist/web/assets/JobWebhooks-C2F4RzTr.js +1 -0
- package/dist/web/assets/Jobs-Dho4B9b-.js +3 -0
- package/dist/web/assets/Knowledge-CDhPBr8J.js +1 -0
- package/dist/web/assets/{MarkdownRenderer-fsBqw-wB.js → MarkdownRenderer-DM6lt7Sg.js} +5 -5
- package/dist/web/assets/{NativeFolderField-BuHwey26.js → NativeFolderField-D1ZqCzY1.js} +1 -1
- package/dist/web/assets/Notifications-Ciw_MC2q.js +1 -0
- package/dist/web/assets/PackageCatalog-BuT4GoJo.js +8 -0
- package/dist/web/assets/{PackageRunDialog-C8m43ZhJ.js → PackageRunDialog-CW_N4ttU.js} +14 -14
- package/dist/web/assets/{Pager-Dbs7fj3d.js → Pager-B-GnS1ry.js} +1 -1
- package/dist/web/assets/{PriorityBadge-DOfXvpzs.js → PriorityBadge-CZt2elFq.js} +1 -1
- package/dist/web/assets/Projects-C27puQUE.js +3 -0
- package/dist/web/assets/{ResponsiveFilters-HzhzzjyL.js → ResponsiveFilters-BwU4JbGU.js} +1 -1
- package/dist/web/assets/{ResumeActions-e6YpUhEq.js → ResumeActions-S3h5yKXv.js} +1 -1
- package/dist/web/assets/Rules-Dqx8X4wX.js +18 -0
- package/dist/web/assets/{ScratchpadDiagramEditor-DkW_SmM8.js → ScratchpadDiagramEditor-iUkemC_h.js} +1 -1
- package/dist/web/assets/{ScratchpadDiagramPreview-C76RVMjL.js → ScratchpadDiagramPreview-Cmim9yNA.js} +1 -1
- package/dist/web/assets/Scratchpads-DRIBlLwW.js +10 -0
- package/dist/web/assets/SessionContextChart-CXAR0czK.js +53 -0
- package/dist/web/assets/SessionHomeLink-DKoq9wT8.js +1 -0
- package/dist/web/assets/Sessions-DBthIWpR.js +5 -0
- package/dist/web/assets/Settings-DU-nfC2z.js +14 -0
- package/dist/web/assets/Skills-BPkciOfy.js +3 -0
- package/dist/web/assets/{SourceEditor-B6pT-Rc0.js → SourceEditor-CKe3Nz5k.js} +4 -4
- package/dist/web/assets/{StatusBadge-CKL0hTFN.js → StatusBadge-Cz0GkMFG.js} +1 -1
- package/dist/web/assets/{TagInput-ChFu05vJ.js → TagInput-QqNDQOz_.js} +1 -1
- package/dist/web/assets/TaskDetailSheet-BGAiFxPD.js +1 -0
- package/dist/web/assets/Tasks-daCTnumY.js +22 -0
- package/dist/web/assets/Terminals-CmRdwS_i.js +2 -0
- package/dist/web/assets/{ViewHeader-D-lhe59Y.js → ViewHeader-BiFirRWq.js} +1 -1
- package/dist/web/assets/{Webhooks-BxpA1QBK.js → Webhooks-8B-qbOiF.js} +1 -1
- package/dist/web/assets/{abnfDiagram-VCTEODGH-YjFRM2fZ.js → abnfDiagram-VCTEODGH-iJD2ux9-.js} +1 -1
- package/dist/web/assets/{ar-SA-G6X2FPQ2-BHNmOPAa.js → ar-SA-G6X2FPQ2-A9u8XBOh.js} +1 -1
- package/dist/web/assets/arc--oLrmj2u.js +1 -0
- package/dist/web/assets/{architectureDiagram-5GKGNRK7-CM-izM65.js → architectureDiagram-5GKGNRK7-N_U_y2_H.js} +1 -1
- package/dist/web/assets/{az-AZ-76LH7QW2-CYylNbd1.js → az-AZ-76LH7QW2-_Avg9k39.js} +1 -1
- package/dist/web/assets/{badge-BqTVr27Z.js → badge-BEhHQEk0.js} +1 -1
- package/dist/web/assets/band-Dy_5MQ5S.js +1 -0
- package/dist/web/assets/{bg-BG-XCXSNQG7-VqpfCk7Q.js → bg-BG-XCXSNQG7-BdxsdW9p.js} +1 -1
- package/dist/web/assets/{blockDiagram-I7D4REHJ-DRqi0uO6.js → blockDiagram-I7D4REHJ-WgVekjtP.js} +2 -2
- package/dist/web/assets/{bn-BD-2XOGV67Q-sq5066za.js → bn-BD-2XOGV67Q-CC9Qp9V1.js} +1 -1
- package/dist/web/assets/bundle-mjs-Dvhef5Db.js +1 -0
- package/dist/web/assets/button-BlVCkBiz.js +1 -0
- package/dist/web/assets/{c4Diagram-7LVT6UL2-5kgD36Wg.js → c4Diagram-7LVT6UL2-CDC_qpoG.js} +1 -1
- package/dist/web/assets/{ca-ES-6MX7JW3Y-C1-EfJt9.js → ca-ES-6MX7JW3Y-NrHWpdXC.js} +1 -1
- package/dist/web/assets/channel-DCr5AYQF.js +1 -0
- package/dist/web/assets/check-cnj-S1QW.js +1 -0
- package/dist/web/assets/chevron-down-CsfelGxA.js +1 -0
- package/dist/web/assets/chevron-up-COeKodk9.js +1 -0
- package/dist/web/assets/{chunk-4HAMMTFA-DY6eE90t.js → chunk-4HAMMTFA-Cpqa-wt-.js} +1 -1
- package/dist/web/assets/chunk-75Z2AOVW-sSmASBxo.js +2 -0
- package/dist/web/assets/{chunk-DU6HZSFF-BaVVqpDB.js → chunk-DU6HZSFF-DaBSmv4k.js} +15 -15
- package/dist/web/assets/{chunk-EIO257PC-D5dZL9PV.js → chunk-EIO257PC-CGfJ7MC8.js} +1 -1
- package/dist/web/assets/chunk-F27PBJKO-CcJz7Bwe.js +1 -0
- package/dist/web/assets/{chunk-GMAD6QVW-D7d5cxQ3.js → chunk-GMAD6QVW-DZDh-p1Z.js} +1 -1
- package/dist/web/assets/{chunk-GVQU2GXP-GfOuiNH1.js → chunk-GVQU2GXP-BbzNYx58.js} +1 -1
- package/dist/web/assets/{chunk-IMKFNOWR-BRI_39MI.js → chunk-IMKFNOWR-wPoHkMoN.js} +1 -1
- package/dist/web/assets/{chunk-L3NEJ4N5-BD8q2mez.js → chunk-L3NEJ4N5-4ku89onu.js} +1 -1
- package/dist/web/assets/{chunk-OB3PAWPO-1IihCzFx.js → chunk-OB3PAWPO-BD6ylT0A.js} +1 -1
- package/dist/web/assets/{chunk-OSK3NFVY-DN8XtEwT.js → chunk-OSK3NFVY-C3koYeVe.js} +2 -2
- package/dist/web/assets/{chunk-P2QGCYS3-DpMkYw3X.js → chunk-P2QGCYS3-BUvkZ5te.js} +1 -1
- package/dist/web/assets/{chunk-POPQ4Y6H-D3Y4enjb.js → chunk-POPQ4Y6H-pNL2Y3ZS.js} +1 -1
- package/dist/web/assets/{chunk-PWAF6VOD-CP1kSMru.js → chunk-PWAF6VOD-BA8RFgOa.js} +1 -1
- package/dist/web/assets/{chunk-SHT3W25Y-agGbkFhr.js → chunk-SHT3W25Y-C6oc6uF-.js} +1 -1
- package/dist/web/assets/{chunk-SVP7TREG-CjcYm9eZ.js → chunk-SVP7TREG-knpgIhM0.js} +1 -1
- package/dist/web/assets/{chunk-TICWLB2K-Db1GTJPo.js → chunk-TICWLB2K-CnSgTstQ.js} +1 -1
- package/dist/web/assets/chunk-XXDRQBXY-CiSqEX14.js +1 -0
- package/dist/web/assets/{circle-check-DWP3C_MJ.js → circle-check-CrMHbBhC.js} +1 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-CniI4twA.js +1 -0
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-CniI4twA.js +1 -0
- package/dist/web/assets/client-RPZmgRqE.js +1 -0
- package/dist/web/assets/clsx-DB0hHKMi.js +1 -0
- package/dist/web/assets/{cose-bilkent-JH36ORCC-D7HExB1j.js → cose-bilkent-JH36ORCC-WMJznyo8.js} +1 -1
- package/dist/web/assets/{cs-CZ-2BRQDIVT-57tJuhpe.js → cs-CZ-2BRQDIVT-Ba4hnkba.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-BRv5c19u.js → cynefinDiagram-5FMLGOSQ-wD6URJ3N.js} +1 -1
- package/dist/web/assets/{da-DK-5WZEPLOC-DM7XjaYi.js → da-DK-5WZEPLOC-uSaFrm3y.js} +1 -1
- package/dist/web/assets/{dagre-GXQ25YYZ-CcpkObIw.js → dagre-GXQ25YYZ-I42gsSBt.js} +1 -1
- package/dist/web/assets/{de-DE-XR44H4JA-CQpZC2C8.js → de-DE-XR44H4JA-BDGHC6qO.js} +1 -1
- package/dist/web/assets/{diagram-S7CK7UJ4-DPSbKZeN.js → diagram-S7CK7UJ4-BZ_g6i3U.js} +1 -1
- package/dist/web/assets/{diagram-UQ7AKVKN-C8fuojtv.js → diagram-UQ7AKVKN-VdNRRNwK.js} +1 -1
- package/dist/web/assets/{diagram-VSXAHHWV-DXpqw8sz.js → diagram-VSXAHHWV-rtLzm0Wd.js} +1 -1
- package/dist/web/assets/{diagram-VX7I27RA-CvLbqSKv.js → diagram-VX7I27RA-gyOuVk1o.js} +1 -1
- package/dist/web/assets/{diagram-Z3DM3KII-CCJALgIu.js → diagram-Z3DM3KII-BIAY89dr.js} +1 -1
- package/dist/web/assets/dist-B-iYpxX5.js +1 -0
- package/dist/web/assets/{dist-DScw4RwC.js → dist-BxZ8dALn.js} +1 -1
- package/dist/web/assets/{dist-BcD2-hDT.js → dist-CDGM8ohF.js} +1 -1
- package/dist/web/assets/{download-BD7lYc4O.js → download-Cnjcb403.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-PWID7BFC-CcnL5GVi.js → ebnfDiagram-PWID7BFC-y5UVvV0S.js} +1 -1
- package/dist/web/assets/{el-GR-BZB4AONW-BG0fwyry.js → el-GR-BZB4AONW-Cq0J1GFb.js} +1 -1
- package/dist/web/assets/{en-B4ZKOASM-CYtHfac-.js → en-B4ZKOASM-BKgOGNRH.js} +1 -1
- package/dist/web/assets/{erDiagram-RLTQ6QDP-BxnqbJDI.js → erDiagram-RLTQ6QDP-D72PXJS0.js} +1 -1
- package/dist/web/assets/{es-ES-U4NZUMDT-DeCoGq3I.js → es-ES-U4NZUMDT-BQarpdAK.js} +1 -1
- package/dist/web/assets/{eu-ES-A7QVB2H4-BgrTM9Q_.js → eu-ES-A7QVB2H4-BFw3LO5C.js} +1 -1
- package/dist/web/assets/{fa-IR-HGAKTJCU-BMNXHhCI.js → fa-IR-HGAKTJCU-G08hIy4T.js} +1 -1
- package/dist/web/assets/{fi-FI-Z5N7JZ37-AvkTA6Bg.js → fi-FI-Z5N7JZ37-B2zrN1xY.js} +1 -1
- package/dist/web/assets/flowDiagram-HODETNUW-DnTsInvQ.js +1 -0
- package/dist/web/assets/{fr-FR-RHASNOE6-DdOUGndN.js → fr-FR-RHASNOE6-BDx47Foj.js} +1 -1
- package/dist/web/assets/ganttDiagram-EL5Y4UJY-DjxW88Yq.js +292 -0
- package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-jRvw-5Ks.js → gitGraphDiagram-WWUBYQGX-Dj0nxLL6.js} +1 -1
- package/dist/web/assets/{gl-ES-HMX3MZ6V-BOcT9Eh2.js → gl-ES-HMX3MZ6V-BSuDtk1T.js} +1 -1
- package/dist/web/assets/{he-IL-6SHJWFNN-XKCHaRIK.js → he-IL-6SHJWFNN-BD_wF5WF.js} +1 -1
- package/dist/web/assets/{hi-IN-IWLTKZ5I-DIIO_PCe.js → hi-IN-IWLTKZ5I-PL1UA69H.js} +1 -1
- package/dist/web/assets/{highlighted-body-JLMTFACH-CAMR1LA5.js → highlighted-body-JLMTFACH-DqkWK4Ru.js} +1 -1
- package/dist/web/assets/{hu-HU-A5ZG7DT2-Dbjtq-D1.js → hu-HU-A5ZG7DT2-BXSops5K.js} +1 -1
- package/dist/web/assets/{id-ID-SAP4L64H-CDk9puhw.js → id-ID-SAP4L64H-CCy09Vc3.js} +1 -1
- package/dist/web/assets/{image-GAAHSSAO-rkI8hLQy.js → image-GAAHSSAO-L254mjR1.js} +1 -1
- package/dist/web/assets/index-DMLXoHsj.css +1 -0
- package/dist/web/assets/index-DsVJrhHJ.js +134 -0
- package/dist/web/assets/{infoDiagram-27XIBGKW-BNBESmTb.js → infoDiagram-27XIBGKW-LjBCF4PZ.js} +1 -1
- package/dist/web/assets/init-ZlXS9mIS.js +1 -0
- package/dist/web/assets/isArguments-2ZchtnyI.js +1 -0
- package/dist/web/assets/{ishikawaDiagram-5VMMS53U-DaNMtDzK.js → ishikawaDiagram-5VMMS53U-j6nqDra0.js} +1 -1
- package/dist/web/assets/{it-IT-JPQ66NNP-YRZ57kPD.js → it-IT-JPQ66NNP-DFolA_LS.js} +1 -1
- package/dist/web/assets/{ja-JP-DBVTYXUO-DVMZSYKy.js → ja-JP-DBVTYXUO-B6D9xBWl.js} +1 -1
- package/dist/web/assets/{journeyDiagram-3NMN7TZE-DxFIkTjg.js → journeyDiagram-3NMN7TZE-LzOfr9eG.js} +1 -1
- package/dist/web/assets/{kaa-6HZHGXH3-CptDAgKS.js → kaa-6HZHGXH3-C72QaGJt.js} +1 -1
- package/dist/web/assets/{kab-KAB-ZGHBKWFO-OATW2sAD.js → kab-KAB-ZGHBKWFO-B8iK2b_z.js} +1 -1
- package/dist/web/assets/{kanban-definition-UXKFOSKX-FWblng5Q.js → kanban-definition-UXKFOSKX-D2I3KztT.js} +1 -1
- package/dist/web/assets/{kk-KZ-P5N5QNE5-B6R_70EG.js → kk-KZ-P5N5QNE5-D6W-P7rh.js} +1 -1
- package/dist/web/assets/{km-KH-HSX4SM5Z-Cxdswtta.js → km-KH-HSX4SM5Z-FNampihM.js} +1 -1
- package/dist/web/assets/{ko-KR-MTYHY66A-C-K_IuWl.js → ko-KR-MTYHY66A-VOraSkjG.js} +1 -1
- package/dist/web/assets/{ku-TR-6OUDTVRD-zFXPVPDH.js → ku-TR-6OUDTVRD-m2GGjf0J.js} +1 -1
- package/dist/web/assets/linear-jUOPAx5A.js +1 -0
- package/dist/web/assets/{live-sessions-C6D_vHcN.js → live-sessions-DYGSpoN-.js} +1 -1
- package/dist/web/assets/{lt-LT-XHIRWOB4-DkOTIbBj.js → lt-LT-XHIRWOB4-d3lU0RUK.js} +1 -1
- package/dist/web/assets/{lv-LV-5QDEKY6T-DjJBaytN.js → lv-LV-5QDEKY6T-C-V5Fk7E.js} +1 -1
- package/dist/web/assets/{maximize-2-BUxUwGbf.js → maximize-2-ar3sWM7r.js} +1 -1
- package/dist/web/assets/mermaid-WFAXDIZX-3nzsUtGy.js +1 -0
- package/dist/web/assets/{mermaid.core-CE0shN4j.js → mermaid.core-BD-HQdEx.js} +7 -7
- package/dist/web/assets/{mindmap-definition-YA3MSWOX-B6gMnn2w.js → mindmap-definition-YA3MSWOX-B9R_Kw48.js} +1 -1
- package/dist/web/assets/{mr-IN-CRQNXWMA-CpBrL5xP.js → mr-IN-CRQNXWMA-Daz7uyn8.js} +1 -1
- package/dist/web/assets/{my-MM-5M5IBNSE-n3gOu566.js → my-MM-5M5IBNSE-Mjs8RG1b.js} +1 -1
- package/dist/web/assets/{nb-NO-T6EIAALU-BotYv1MD.js → nb-NO-T6EIAALU-C0RCBqbi.js} +1 -1
- package/dist/web/assets/{nl-NL-IS3SIHDZ-DW0fsbWy.js → nl-NL-IS3SIHDZ-Bsic6fKl.js} +1 -1
- package/dist/web/assets/{nn-NO-6E72VCQL-Bb-fnU0x.js → nn-NO-6E72VCQL-DSLrCxXF.js} +1 -1
- package/dist/web/assets/{oc-FR-POXYY2M6-shEPc56q.js → oc-FR-POXYY2M6-CPVBImHE.js} +1 -1
- package/dist/web/assets/orc-kit-BZEVA3Qv.js +317 -0
- package/dist/web/assets/{ordinal-DtR4qwUh.js → ordinal-CNdcxYwv.js} +1 -1
- package/dist/web/assets/{pa-IN-N4M65BXN-DKavQSyF.js → pa-IN-N4M65BXN-C00X1yKx.js} +1 -1
- package/dist/web/assets/{pegDiagram-XKGWAZYB-C8m_jYi3.js → pegDiagram-XKGWAZYB-BscU1Iej.js} +1 -1
- package/dist/web/assets/percentages-BXMCSKIN-C29vMz-s.js +1 -0
- package/dist/web/assets/{pieDiagram-E7YTZNPT-hq51jARC.js → pieDiagram-E7YTZNPT-Dod_xS5_.js} +2 -2
- package/dist/web/assets/{pl-PL-T2D74RX3-BNiWQazy.js → pl-PL-T2D74RX3-CM9U623C.js} +1 -1
- package/dist/web/assets/prod-C5uPTMUm.js +159 -0
- package/dist/web/assets/{pt-BR-5N22H2LF-BNrp0SJn.js → pt-BR-5N22H2LF-DQ3Sbme5.js} +1 -1
- package/dist/web/assets/{pt-PT-UZXXM6DQ-MqcjbYsn.js → pt-PT-UZXXM6DQ-CR9ceNr0.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-AXDQQJYC-BZo19rHO.js → quadrantDiagram-AXDQQJYC--WMts-_Y.js} +1 -1
- package/dist/web/assets/{railroadDiagram-O6MQD6OU-BoHZurmH.js → railroadDiagram-O6MQD6OU-Zo4FiyLl.js} +1 -1
- package/dist/web/assets/{requirementDiagram-BXWQKSXE-gtSxT-KO.js → requirementDiagram-BXWQKSXE-C9FUscr7.js} +1 -1
- package/dist/web/assets/{ro-RO-JPDTUUEW-BaD_m5BY.js → ro-RO-JPDTUUEW-gSdEtVLo.js} +1 -1
- package/dist/web/assets/{ru-RU-B4JR7IUQ-BOeGQntq.js → ru-RU-B4JR7IUQ-Bfn8z4LG.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-P5KCCOFB-DNEPPK03.js → sankeyDiagram-P5KCCOFB-B2nE--ks.js} +1 -1
- package/dist/web/assets/{scratchpad-kinds-B0Y6McXL.js → scratchpad-kinds-BFBap9Ix.js} +1 -1
- package/dist/web/assets/{scratchpad-routes-BtsIfhUW.js → scratchpad-routes-DqBRARVl.js} +1 -1
- package/dist/web/assets/{scroll-area-BhajWBGy.js → scroll-area-BN-yOL-R.js} +1 -1
- package/dist/web/assets/send-CwHls3BT.js +1 -0
- package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-CQUgLsRi.js → sequenceDiagram-WJ2MYXX4-NENQLpHl.js} +1 -1
- package/dist/web/assets/{si-LK-N5RQ5JYF-CEpiTE5c.js → si-LK-N5RQ5JYF-DqNpE809.js} +1 -1
- package/dist/web/assets/{sk-SK-C5VTKIMK-lXa56uQB.js → sk-SK-C5VTKIMK-DSieo7hl.js} +1 -1
- package/dist/web/assets/{sl-SI-NN7IZMDC-S7pYt-A8.js → sl-SI-NN7IZMDC-C_QNEPH3.js} +1 -1
- package/dist/web/assets/src-B1erg8EN.js +1 -0
- package/dist/web/assets/stateDiagram-D77RDMKH-CDO25lPI.js +1 -0
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-C9Au5pzl.js +1 -0
- package/dist/web/assets/subset-shared.chunk-TWhTI8tf.js +1 -0
- package/dist/web/assets/{subset-worker.chunk-DAdqTVJ_.js → subset-worker.chunk-BOESNY_w.js} +1 -1
- package/dist/web/assets/{sv-SE-XGPEYMSR-BAmS64lt.js → sv-SE-XGPEYMSR-DQbljox0.js} +1 -1
- package/dist/web/assets/{swimlanes-42K2YHIH-oYky4P3y.js → swimlanes-42K2YHIH--W-6fn8i.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-C6219OQ4.js +8 -0
- package/dist/web/assets/{ta-IN-2NMHFXQM-B2aOysQ6.js → ta-IN-2NMHFXQM-CfU7EiJ8.js} +1 -1
- package/dist/web/assets/{table-COm8Aml-.js → table-D2GMF--l.js} +1 -1
- package/dist/web/assets/{th-TH-HPSO5L25-MKFJurV1.js → th-TH-HPSO5L25-DGG0--S2.js} +1 -1
- package/dist/web/assets/time-B49d1LAz.js +1 -0
- package/dist/web/assets/{timeline-definition-24CTP7MA-DlK_cujT.js → timeline-definition-24CTP7MA-BkCND9aP.js} +1 -1
- package/dist/web/assets/{tr-TR-DEFEU3FU-DKE7gZ4N.js → tr-TR-DEFEU3FU-CsrGQhyP.js} +1 -1
- package/dist/web/assets/{uk-UA-QMV73CPH-DutAOQit.js → uk-UA-QMV73CPH-BLl6JvGg.js} +1 -1
- package/dist/web/assets/{upload-CPf6QZHl.js → upload-Bbixlc7i.js} +1 -1
- package/dist/web/assets/{useDetailRoute-DOhAbdV7.js → useDetailRoute-B-xjWsyW.js} +1 -1
- package/dist/web/assets/{useIntegrations-C0MAVKB4.js → useIntegrations-D5PIxedU.js} +1 -1
- package/dist/web/assets/{useJobs-BlWldKP0.js → useJobs-DYaqHA8F.js} +1 -1
- package/dist/web/assets/{useListSelection-BnMxiGpC.js → useListSelection-BKCFyGyf.js} +1 -1
- package/dist/web/assets/{useMemories-CAf8HcOI.js → useMemories-Ce1S_iFK.js} +1 -1
- package/dist/web/assets/useProjectScope-DpgzthH7.js +1 -0
- package/dist/web/assets/{useSessions-DiUU2FN8.js → useSessions-D1nMvBf0.js} +1 -1
- package/dist/web/assets/{vennDiagram-4TSXK5OY-C53t_PT9.js → vennDiagram-4TSXK5OY-VAg3OK5L.js} +1 -1
- package/dist/web/assets/{vi-VN-M7AON7JQ-BpbS22dK.js → vi-VN-M7AON7JQ-D4YR0jtR.js} +1 -1
- package/dist/web/assets/{view-params-DD7i9s5g.js → view-params-YEmeZppw.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-VM6X3IG4-ks9GYCVg.js → wardleyDiagram-VM6X3IG4-ryXBKUqB.js} +1 -1
- package/dist/web/assets/with-selector-DSvXfKhy.js +1 -0
- package/dist/web/assets/x-uOircJYm.js +1 -0
- package/dist/web/assets/xychartDiagram-S5SC5T6Z-DvmDulIn.js +7 -0
- package/dist/web/assets/{zh-CN-LNUGB5OW-BWtL4V8y.js → zh-CN-LNUGB5OW-D_9Jun9E.js} +1 -1
- package/dist/web/assets/{zh-HK-E62DVLB3-DrfXDi4l.js → zh-HK-E62DVLB3-DRMBZQpA.js} +1 -1
- package/dist/web/assets/{zh-TW-RAJ6MFWO-BVZGUfP5.js → zh-TW-RAJ6MFWO-a3dZK_3C.js} +1 -1
- package/dist/web/index.html +17 -22
- package/dist/web/sw.js +26 -17
- package/package.json +1 -1
- package/dist/web/assets/Audit-DGSNmToV.js +0 -1
- package/dist/web/assets/ChatUiRenderer-Dddr55cW.js +0 -4
- package/dist/web/assets/ConfirmDialog-B5es4nUp.js +0 -1
- package/dist/web/assets/DocumentWorkspace-I81K42yx.js +0 -1
- package/dist/web/assets/FileEditor-wRs221QU.js +0 -1
- package/dist/web/assets/JobWebhooks-oaF694Af.js +0 -1
- package/dist/web/assets/Jobs-Lmyw5700.js +0 -3
- package/dist/web/assets/Knowledge-V4JuZnUZ.js +0 -1
- package/dist/web/assets/Markdown-D-AaJ4bU.js +0 -2
- package/dist/web/assets/MarkdownEditor-5U4_BhYm.js +0 -2
- package/dist/web/assets/PackageCatalog-BC-yAjPQ.js +0 -8
- package/dist/web/assets/Projects-C280nbHV.js +0 -3
- package/dist/web/assets/Rules-BwsnRQBe.js +0 -18
- package/dist/web/assets/Scratchpads-BtUKOhup.js +0 -10
- package/dist/web/assets/SessionHomeLink-BAWO86fJ.js +0 -1
- package/dist/web/assets/Sessions-Cn2dIJBt.js +0 -4
- package/dist/web/assets/Settings-Bb01CfFw.js +0 -14
- package/dist/web/assets/Skills-Vw41zPVg.js +0 -3
- package/dist/web/assets/TaskDetailSheet-DuTfo6rZ.js +0 -1
- package/dist/web/assets/Tasks-CC92r1kL.js +0 -22
- package/dist/web/assets/Terminals-dCbgpRsm.js +0 -2
- package/dist/web/assets/arc-DMybztRk.js +0 -1
- package/dist/web/assets/array-BifhSqXX.js +0 -1
- package/dist/web/assets/bundle-mjs-CdK3cBzO.js +0 -1
- package/dist/web/assets/button-By-NN7c7.js +0 -1
- package/dist/web/assets/channel-D_DFR6oL.js +0 -1
- package/dist/web/assets/check-Cg2_C_4I.js +0 -1
- package/dist/web/assets/chevron-down-KBvm_HoX.js +0 -1
- package/dist/web/assets/chunk-75Z2AOVW-DGmxZV98.js +0 -2
- package/dist/web/assets/chunk-F27PBJKO-CXQQU8th.js +0 -1
- package/dist/web/assets/chunk-XXDRQBXY-uYQniKdI.js +0 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-CCfdDM3y.js +0 -1
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-CCfdDM3y.js +0 -1
- package/dist/web/assets/client-954dj6K2.js +0 -1
- package/dist/web/assets/dialog-DNIYhwi4.js +0 -1
- package/dist/web/assets/file-kind-BYU1kv95.js +0 -1
- package/dist/web/assets/flowDiagram-HODETNUW-K6mpRghJ.js +0 -1
- package/dist/web/assets/ganttDiagram-EL5Y4UJY-BixeVtgw.js +0 -292
- package/dist/web/assets/index-XIDqokJX.js +0 -133
- package/dist/web/assets/index-hvCYuRJb.css +0 -1
- package/dist/web/assets/init-C-OQMol4.js +0 -1
- package/dist/web/assets/label-Bm_d0NKL.js +0 -1
- package/dist/web/assets/line-BmNPsHiE.js +0 -1
- package/dist/web/assets/linear-BF68Zt8D.js +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-Bzg8wVqT.js +0 -1
- package/dist/web/assets/path-fybaL0A-.js +0 -1
- package/dist/web/assets/percentages-BXMCSKIN-G1-czdqc.js +0 -1
- package/dist/web/assets/prod-BxHPuooG.js +0 -159
- package/dist/web/assets/select-cyLFVkkB.js +0 -1
- package/dist/web/assets/src-DpAUOMD9.js +0 -1
- package/dist/web/assets/stateDiagram-D77RDMKH-Cgi4pLWL.js +0 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-D7-KCEKC.js +0 -1
- package/dist/web/assets/subset-shared.chunk-C-8kChur.js +0 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-Dg5C5S8F.js +0 -8
- package/dist/web/assets/tabs-bEwJLtA0.js +0 -1
- package/dist/web/assets/textarea-CovStda2.js +0 -1
- package/dist/web/assets/useProjectScope-DtEj9j-P.js +0 -1
- package/dist/web/assets/x-tY-z3woy.js +0 -1
- package/dist/web/assets/xychartDiagram-S5SC5T6Z-DO_DSVE-.js +0 -7
|
@@ -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"./useMutation-CRAWY7v2.js";import{f as i,h as a,t as o}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as s}from"./button-BlVCkBiz.js";import{h as c,n as l}from"./client-RPZmgRqE.js";import{t as u}from"./chevron-down-CsfelGxA.js";import{t as d}from"./ResponsiveFilters-BwU4JbGU.js";import{t as f}from"./scroll-area-BN-yOL-R.js";import{a as p,c as m,d as h,i as g,m as _,o as v}from"./schemas-BQZhekae.js";import{An as y,At as b,Cn as x,Dn as S,Dt as C,Et as w,J as T,Jn as E,Jr as D,Ni as O,O as k,Qr as A,Rr as j,Tt as M,X as N,Xr as P,Y as F,Yr as I,Z as L,Zn as ee,b as te,ci as R,cn as ne,ct as z,fr as re,jt as ie,kn as ae,kt as oe,lt as se,mt as ce,on as le,pt as ue,q as de,ri as fe,si as pe,sn as me,z as B}from"./index-DsVJrhHJ.js";import{t as he}from"./ConfirmDialog-DKN0AVIw.js";import{a as ge,c as V,i as _e,l as H,n as ve,o as ye,r as be,s as xe,t as Se}from"./useJobs-DYaqHA8F.js";import{t as Ce}from"./StatusBadge-Cz0GkMFG.js";import{t as U}from"./ErrorState-CpcyNx03.js";import{t as W}from"./ViewHeader-BiFirRWq.js";import{t as we}from"./useDetailRoute-B-xjWsyW.js";import{t as G}from"./view-params-YEmeZppw.js";import{t as Te}from"./EmptyState-YM4VSLR9.js";import{a as Ee,i as K,n as De,o as q,r as J,t as Oe}from"./table-D2GMF--l.js";import{t as ke}from"./useProjectScope-DpgzthH7.js";import{n as Ae,t as je}from"./useListSelection-BKCFyGyf.js";import{i as Me,t as Ne}from"./JobWebhooks-C2F4RzTr.js";var Pe={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Pe.node;var Y=c(Pe),Fe={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Fe.node;var Ie=c(Fe),X=e(t(),1),Z=n();function Le({jobId:e,open:t,onClose:n,onEdit:r,projectScope:i=`all`}){let{data:o,isLoading:c,error:l,refetch:u}=be(e),d=o&&(i===`all`||(i===`unassigned`?o.project_id===null:o.project_id===i)),f=d?o:void 0;(0,X.useEffect)(()=>{t&&o&&!d&&n()},[t,o,d,n]);let{data:p,isLoading:m,error:h,refetch:g}=ge(f?.id??null),_=V(),v=H(),[y]=a(),[x,S]=(0,X.useState)(()=>y.get(`run`));return(0,Z.jsx)(M,{open:t,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(C,{"data-testid":`job-detail-sheet`,children:[(0,Z.jsxs)(b,{children:[(0,Z.jsx)(ie,{children:f?.name??`Job details`}),f?.description&&(0,Z.jsx)(`p`,{className:`font-body text-xs text-outline mt-1`,children:f.description})]}),(0,Z.jsx)(w,{children:l?(0,Z.jsx)(U,{message:l.message,onRetry:()=>u()}):c?(0,Z.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,,,]].map((e,t)=>(0,Z.jsx)(k,{className:`h-8 w-full bg-surface-highest`},t))}):f?(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(B,{label:`Action`,children:(0,Z.jsx)(`pre`,{className:`font-mono text-xs bg-background p-2 rounded-lg border border-surface-highest overflow-x-auto whitespace-pre-wrap break-all`,children:f.action?.type===`agent`?`Run agent (${f.action.backend}): ${f.action.prompt}`:f.action?.type===`task`?`Create task: ${f.action.title}`:f.command})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsx)(B,{label:`Trigger Type`,children:(0,Z.jsx)(`span`,{className:`font-label text-xs px-2 py-0.5 bg-surface-highest text-on-surface-variant border border-surface-highest/50 inline-flex`,children:f.trigger_type})}),(0,Z.jsx)(B,{label:`Enabled`,children:(0,Z.jsx)(`span`,{className:`font-label text-xs font-bold ${f.enabled?`text-secondary`:`text-outline`}`,children:f.enabled?`● ON`:`○ OFF`})})]}),f.cron_expr&&(0,Z.jsx)(B,{label:`Cron Expression`,children:(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:f.cron_expr})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Z.jsxs)(B,{label:`Timeout`,children:[f.timeout_secs,`s`]}),(0,Z.jsx)(B,{label:`Max Retries`,children:f.max_retries}),(0,Z.jsx)(B,{label:`Overlap`,children:f.overlap})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsx)(B,{label:`Notify On`,children:f.notify_on}),(0,Z.jsx)(B,{label:`Run Count`,children:f.run_count})]}),f.next_run_at&&(0,Z.jsx)(B,{label:`Next Run`,children:new Date(f.next_run_at).toLocaleString()})]}),!f.command.startsWith(`__`)&&(0,Z.jsxs)(`details`,{className:`border-y border-border py-2`,children:[(0,Z.jsxs)(`summary`,{className:`min-h-8 cursor-pointer text-sm`,children:[`Webhook connections (`,f.webhooks?.length??0,`)`]}),(0,Z.jsx)(Ne,{job:f},f.id)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Recent runs`}),h?(0,Z.jsx)(U,{message:h.message,onRetry:()=>g()}):m?(0,Z.jsx)(`div`,{className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Z.jsx)(k,{className:`h-8 w-full bg-surface-highest`},t))}):p?.length?(0,Z.jsx)(`div`,{className:`space-y-1`,children:p.map(t=>(0,Z.jsx)(Re,{run:t,jobId:e,expanded:x===t.id,onToggle:()=>S(x===t.id?null:t.id)},t.id))}):(0,Z.jsx)(`div`,{className:`font-label text-xs text-outline py-4 text-center`,children:`No runs yet`})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-outline`,children:`Job not found`})}),(0,Z.jsxs)(oe,{className:`flex-wrap`,children:[(v.error||_.error)&&(0,Z.jsx)(`p`,{role:`alert`,className:`w-full text-sm text-error`,children:(v.error??_.error)?.message}),f&&r&&(0,Z.jsxs)(s,{"data-testid":`job-detail-edit`,size:`sm`,variant:`outline`,onClick:()=>r(f),children:[(0,Z.jsx)(R,{size:16}),`Edit job`]}),f&&(0,Z.jsxs)(s,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({id:f.id,enabled:!f.enabled}),className:`font-label text-xs font-medium`,children:[(0,Z.jsx)(Ie,{size:12,className:`mr-1.5`}),f.enabled?`Disable`:`Enable`]}),f&&(0,Z.jsxs)(s,{variant:`ghost`,size:`sm`,disabled:_.isPending,onClick:()=>_.mutate(f.id,{onSuccess:e=>S(e.run_id)}),className:`font-label text-xs font-medium bg-transparent text-on-surface border border-control-border hover:bg-surface`,children:[(0,Z.jsx)(Y,{size:12,className:`mr-1.5`}),_.isPending?`Triggering...`:`Trigger run`]})]})]})})}function Re({run:e,jobId:t,expanded:n,onToggle:r}){let a=i(),[c,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(``);async function m(){d(!0),p(``);try{let n=await l.jobs.nativeSession(t,e.id);n.session_id?a(`/sessions?project=all&session=${encodeURIComponent(n.session_id)}`):p(`The native conversation is not available yet. The saved result is still available below.`)}catch(e){p(e instanceof Error?e.message:`Could not open this conversation.`)}finally{d(!1)}}return(0,Z.jsxs)(`div`,{className:`min-w-0 border-y border-border overflow-hidden bg-background`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,"data-testid":`job-run-result`,className:`w-full flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 hover:bg-surface transition-colors text-left`,children:[n?(0,Z.jsx)(u,{size:12,className:`text-outline shrink-0`}):(0,Z.jsx)(O,{size:12,className:`text-outline shrink-0`}),(0,Z.jsx)(Ce,{status:e.status,type:`job`}),(0,Z.jsxs)(`span`,{className:`order-last basis-full min-w-0 font-label text-xs text-outline sm:order-none sm:basis-auto sm:flex-1`,children:[e.started_at?new Date(e.started_at).toLocaleString():`—`,e.ended_at&&(0,Z.jsxs)(`span`,{className:`ml-2`,children:[`→`,` `,new Date(e.ended_at).toLocaleTimeString()]})]}),(0,Z.jsx)(`span`,{className:`ml-auto whitespace-nowrap text-xs underline sm:ml-0`,children:n?`Hide result`:`View result`}),e.exit_code!==null&&(0,Z.jsxs)(`span`,{className:`font-mono text-xs ${e.exit_code===0?`text-secondary`:`text-error`}`,children:[`exit `,e.exit_code]})]}),(e.task_id||e.session_id)&&(0,Z.jsxs)(`div`,{className:`flex gap-3 px-3 py-2 text-xs`,children:[e.task_id&&(0,Z.jsx)(o,{className:`underline`,"data-testid":`job-run-task-link`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.native_session_id&&(0,Z.jsx)(s,{variant:`outline`,size:`sm`,"data-testid":`job-run-open-session`,disabled:c,onClick:()=>void m(),children:c?`Opening…`:`Open agent session`}),e.session_id&&(0,Z.jsx)(o,{className:`underline`,"data-testid":`job-run-session-link`,to:`/audit/${e.session_id}?project=all`,children:`Session summary`})]}),f&&(0,Z.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-sm text-error`,children:f}),e.error_msg&&(0,Z.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Z.jsx)(`span`,{className:`font-body text-xs text-error`,children:e.error_msg})}),n&&(0,Z.jsx)(ze,{jobId:t,runId:e.id,live:[`pending`,`running`].includes(e.status)})]})}function ze({jobId:e,runId:t,live:n}){let{data:r,isLoading:i,error:a,refetch:o}=_e(e,t,n);return a?(0,Z.jsx)(U,{message:a.message,onRetry:()=>o()}):i?(0,Z.jsx)(`div`,{className:`px-3 pb-3`,children:(0,Z.jsx)(k,{className:`h-24 w-full bg-surface-highest`})}):r?.length?(0,Z.jsx)(`div`,{className:`mx-3 mb-3 rounded-lg overflow-hidden border border-surface-highest`,children:(0,Z.jsx)(f,{className:`h-[240px]`,children:(0,Z.jsx)(`pre`,{className:`font-mono text-xs leading-relaxed bg-background p-3`,children:r.map(e=>(0,Z.jsx)(`div`,{className:e.stream===`stderr`?`text-error`:`text-on-surface`,children:e.line},e.id))})})}):(0,Z.jsx)(`div`,{className:`px-3 pb-3 font-label text-xs text-outline`,children:`No log output`})}var Be=v(`type`,[h({type:m(`command`),command:_().trim().min(1)}).strict(),h({type:m(`agent`),prompt:_().trim().min(1).max(1e5),backend:_().trim().min(1).max(64),options:j.optional(),model:re.refine(e=>e.length>0).optional(),auto_approve:p().default(!1)}).strict().superRefine((e,t)=>{if(!e.options)return;[`claude-cli`,`a2a`,`agentapi`].includes(e.backend)&&t.addIssue({code:`custom`,path:[`options`],message:`This backend does not support job launch options. Choose Claude SDK, Codex CLI or ACPX.`});let n=e.backend===`claude`?`claude-sdk`:e.backend===`pi`?`pi`:e.backend===`codex-cli`?`codex`:`acpx`;e.options.runtime!==n&&t.addIssue({code:`custom`,path:[`options`],message:`Launch options do not match this backend`}),!e.auto_approve&&(e.options.runtime===`claude-sdk`&&[`acceptEdits`,`bypassPermissions`].includes(e.options.options.permissionMode??``)||e.options.runtime===`acpx`&&e.options.args.some(e=>[`--approve-all`,`--approve-reads`].includes(e)))&&t.addIssue({code:`custom`,path:[`options`],message:`Automatic tool approval must be enabled explicitly`})}),h({type:m(`task`),title:_().trim().min(1).max(200),body:_().max(1e5).default(``),start_automatically:p().default(!1),flow_name:_().trim().min(1).max(100).optional()}).strict()]);h({webhook_id:_().min(1).max(128),events:g(_().trim().min(1).max(128)).max(50).default([]),actions:g(_().trim().min(1).max(128)).max(50).default([])}).strict();function Ve({value:e,onChange:t,host:n,cwd:i}){let a=e.backend===`codex-cli`?`codex`:e.backend,{data:o}=x(),s=Array.from(new Set([...S(),a])),c=r({queryKey:[`job-models`,a,n===void 0?o?.host:n,i],queryFn:()=>l.chat.models(a,void 0,n,i),staleTime:12e4,retry:!1}),u=new Map((c.data?.models??[]).map(e=>[e.id,e.label]));e.model&&!u.has(e.model)&&u.set(e.model,e.model);let d=ae(a)?.modelSelection===!1;return(0,Z.jsx)(y,{testIdPrefix:`job`,agent:a,selectedModel:e.model??``,agents:s,choices:u,fetching:c.isFetching,modelsDisabled:d,warning:c.isError?`Models could not be loaded. Saved and custom models are available.`:c.data?.warning,note:d?`This agent picks its own model.`:void 0,onAgent:n=>(n!==a&&t({...e,backend:n===`codex`?`codex-cli`:n,model:void 0,options:void 0}),!1),onModel:n=>t({...e,model:n||void 0})})}function He(e){return e.type===`command`?!!e.command.trim():e.type===`agent`?!!(e.prompt.trim()&&e.backend.trim()):!!e.title.trim()}function Ue({value:e,onChange:t,executionHost:n,cwd:r}){let i=(0,X.useId)();return(0,Z.jsxs)(`section`,{className:`space-y-3 border-y border-border py-4`,"data-testid":`job-action-fields`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`${i}-type`,children:`What should this job do?`}),(0,Z.jsxs)(`select`,{id:`${i}-type`,"data-testid":`job-action-type`,className:`w-full min-h-8 rounded-md border border-control-border bg-background px-3 text-sm`,value:e.type,onChange:e=>{e.target.value===`command`&&t({type:`command`,command:``}),e.target.value===`agent`&&t({type:`agent`,backend:`codex-cli`,prompt:``,auto_approve:!1}),e.target.value===`task`&&t({type:`task`,title:``,body:``,start_automatically:!1})},children:[(0,Z.jsx)(`option`,{value:`command`,children:`Run command`}),(0,Z.jsx)(`option`,{value:`agent`,children:`Run agent`}),(0,Z.jsx)(`option`,{value:`task`,children:`Create task`})]})]}),e.type===`command`&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`${i}-command`,children:`Command`}),(0,Z.jsx)(D,{id:`${i}-command`,"aria-label":`Command`,"data-testid":`job-command-input`,value:e.command,onChange:n=>t({...e,command:n.target.value}),rows:3,placeholder:`bun run build`,required:!0})]}),e.type===`agent`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{children:`Agent and model`}),(0,Z.jsx)(Ve,{value:e,onChange:t,host:n,cwd:r})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`${i}-prompt`,children:`Instructions`}),(0,Z.jsx)(D,{id:`${i}-prompt`,"data-testid":`job-agent-prompt`,value:e.prompt,onChange:n=>t({...e,prompt:n.target.value}),required:!0,rows:4})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.auto_approve,onChange:n=>t({...e,auto_approve:n.target.checked})}),`Allow agent tools automatically`]}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`Starts a tracked agent session. When automatic tool approval is off, permission requests are denied.`})]}),e.type===`task`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`${i}-title`,children:`Task title`}),(0,Z.jsx)(I,{id:`${i}-title`,"data-testid":`job-task-title`,value:e.title,onChange:n=>t({...e,title:n.target.value}),required:!0,maxLength:200})]}),(0,Z.jsx)(te,{label:`Task instructions`,id:`${i}-body`,"data-testid":`job-task-body`,value:e.body,onChange:n=>t({...e,body:n}),rows:4}),(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`job-task-autostart`,checked:e.start_automatically,onChange:n=>t({...e,start_automatically:n.target.checked})}),`Start the task flow automatically`]}),e.start_automatically&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`${i}-flow`,children:`Flow (blank uses the configured default)`}),(0,Z.jsx)(I,{id:`${i}-flow`,"data-testid":`job-task-flow`,value:e.flow_name??``,onChange:n=>t({...e,flow_name:n.target.value||void 0})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`Creates a task in this job's project. Automatic start is off by default; the task waits for a manual flow start.`})]})]})}var Q=[{name:`Host default`,executable:``,args:[]},...[`sh`,`bash`,`zsh`,`fish`].map(e=>({name:e,executable:e,args:[`-c`]})),{name:`PowerShell 7 (pwsh)`,executable:`pwsh`,args:[`-NoProfile`,`-NonInteractive`,`-Command`]},{name:`Windows PowerShell`,executable:`powershell.exe`,args:[`-NoProfile`,`-NonInteractive`,`-Command`]},{name:`cmd`,executable:`cmd.exe`,args:[`/d`,`/s`,`/c`]}];function We({settings:e,onChange:t,action:n}){let{data:r}=x(),i=e.shell,[a,o]=(0,X.useState)(!(!i||Q.some(e=>e.executable===i.executable&&JSON.stringify(e.args)===JSON.stringify(i.args)))),s=a?`Custom`:i?Q.find(e=>e.executable===i.executable&&JSON.stringify(e.args)===JSON.stringify(i.args))?.name??`Custom`:`Host default`,c=`min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-sm sm:min-h-8`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[n.type!==`task`&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-host`,children:`Runs on`}),(0,Z.jsxs)(`select`,{id:`job-host`,"data-testid":`job-host`,className:c,value:e.host===void 0?`__inherit__`:e.host??`__local__`,onChange:n=>{let r={...e};n.target.value===`__inherit__`?delete r.host:r.host=n.target.value===`__local__`?null:n.target.value,t(r)},children:[(0,Z.jsxs)(`option`,{value:`__inherit__`,children:[`Use selected execution host`,r?.host?` (${r.host})`:` (local)`]}),(0,Z.jsx)(`option`,{value:`__local__`,children:`Local API host`}),Array.from(new Set([...r?.hosts??[],...e.host?[e.host]:[]])).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]}),n.type===`command`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-shell`,children:`Shell`}),(0,Z.jsxs)(`select`,{id:`job-shell`,"data-testid":`job-shell`,className:c,value:s,onChange:n=>{o(n.target.value===`Custom`);let r=Q.find(e=>e.name===n.target.value),i={...e};r?.executable?i.shell={executable:r.executable,args:r.args}:r?delete i.shell:i.shell={executable:``,args:[`-c`]},t(i)},children:[Q.map(e=>(0,Z.jsx)(`option`,{children:e.name},e.name)),(0,Z.jsx)(`option`,{children:`Custom`})]})]}),s===`Custom`&&(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{htmlFor:`job-shell-executable`,children:`Executable or path`}),(0,Z.jsx)(I,{id:`job-shell-executable`,value:i?.executable??``,required:!0,onChange:n=>t({...e,shell:{executable:n.target.value,args:i?.args??[]}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{htmlFor:`job-shell-args`,children:`Arguments (one per line)`}),(0,Z.jsx)(`textarea`,{id:`job-shell-args`,className:`${c} py-2`,value:i?.args.join(`
|
|
2
|
+
`)??``,onChange:n=>t({...e,shell:{executable:i?.executable??``,args:n.target.value.split(`
|
|
3
|
+
`).filter(Boolean)}})})]})]}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`The script is passed as the final argument. The interpreter must be installed on the selected host.`})]}),n.type===`agent`&&(0,Z.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-workspace`,children:`Workspace`}),(0,Z.jsxs)(`select`,{id:`job-workspace`,className:c,value:e.workspace?.mode??`directory`,onChange:n=>t({...e,workspace:{mode:n.target.value===`worktree`?`worktree`:`directory`,base_ref:e.workspace?.base_ref??`HEAD`,cleanup_on_success:e.workspace?.cleanup_on_success??!1}}),children:[(0,Z.jsx)(`option`,{value:`worktree`,children:`New worktree for each run`}),(0,Z.jsx)(`option`,{value:`directory`,children:`Use working directory`})]})]}),e.workspace?.mode===`worktree`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-base-ref`,children:`Base branch or ref`}),(0,Z.jsx)(I,{id:`job-base-ref`,"data-testid":`job-base-ref`,required:!0,value:e.workspace.base_ref,onChange:n=>t({...e,workspace:{mode:`worktree`,cleanup_on_success:e.workspace?.cleanup_on_success??!1,base_ref:n.target.value}})}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`HEAD inherits the project checkout’s current commit. Override with a local branch or remote-tracking ref. Each run gets an isolated, detached worktree.`})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`job-cleanup`,checked:e.workspace.cleanup_on_success,onChange:n=>t({...e,workspace:{mode:`worktree`,base_ref:e.workspace?.base_ref??`HEAD`,cleanup_on_success:n.target.checked}})}),`Clean up worktree after a successful run`]}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`Failed runs, files (including ignored files), and commits absent from the base are kept. Run history records the worktree path.`})]})]})]})}function $(e,t){let[n,r]=e.split(`:`).map(Number);return`${r} ${n} * * ${[...t].sort().join(`,`)}`}function Ge(e){let t=/^(\d{1,2}) (\d{1,2}) \* \* (\*|[0-6](?:,[0-6])*)$/.exec(e);return!t||Number(t[1])>59||Number(t[2])>23?null:{time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,days:t[3]===`*`?[0,1,2,3,4,5,6]:t[3].split(`,`).map(Number)}}function Ke({cron:e,timezone:t,onChange:n,onTimezone:r}){let i=Ge(e),[a,o]=(0,X.useState)(!(!e||i)),[s,c]=(0,X.useState)(i?.time??`09:00`),[l,u]=(0,X.useState)(i?.days??[1,2,3,4,5]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`job-schedule-fields`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(z,{children:`Schedule`}),(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:t=>{if(o(t.target.checked),t.target.checked)e||n($(s,l));else{let t=Ge(e);t?(c(t.time),u(t.days)):n($(s,l))}}}),`Advanced cron`]})]}),a?(0,Z.jsx)(I,{"aria-label":`Cron expression`,required:!0,value:e,onChange:e=>n(e.target.value),placeholder:`0 9 * * 1,2,3,4,5`,className:`font-mono`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[8rem_12rem] sm:items-center`,children:[(0,Z.jsx)(z,{htmlFor:`job-schedule-time`,children:`Run at`}),(0,Z.jsx)(I,{id:`job-schedule-time`,type:`time`,required:!0,value:s,onChange:e=>{c(e.target.value),n($(e.target.value,l))}})]}),(0,Z.jsx)(`fieldset`,{"aria-label":`Days of the week`,className:`flex flex-wrap gap-1`,children:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`].map((e,t)=>(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":l.includes(t),className:`min-h-11 min-w-11 rounded-md border px-2 text-sm ${l.includes(t)?`border-control-border bg-surface-highest text-on-surface`:`border-border text-outline`}`,onClick:()=>{let e=l.includes(t)?l.filter(e=>e!==t):[...l,t];u(e),n(e.length?$(s,e):``)},children:e},e))}),!l.length&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:`Select at least one day.`}),(0,Z.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Cron: `,(0,Z.jsx)(`code`,{children:e||`Select days`})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-timezone`,children:`Timezone`}),(0,Z.jsx)(I,{id:`job-timezone`,required:!0,value:t,onChange:e=>r(e.target.value),placeholder:`Asia/Jerusalem`}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`Uses this timezone, including daylight saving changes.`})]})]})}function qe({job:e,defaultProjectId:t,open:n,onClose:r}){let i=Se(),a=H(),{data:o}=E(),c=L([{id:`trigger`,label:`Trigger`},{id:`destination`,label:`Destination`},{id:`settings`,label:`Settings`}],n),l={name:e?.name??``,description:e?.description??``,project_id:e?.project_id??t??``,working_dir:e?.working_dir??``,action:e?.action??{type:`command`,command:e?.command??``},trigger_type:e?.trigger_type??`manual`,cron_expr:e?.cron_expr??``,timeout_secs:e?.timeout_secs??300,max_retries:e?.max_retries??0,overlap:e?.overlap??`skip`,notify_on:e?.notify_on??`failure`,enabled:e?.enabled??!1,webhooks:e?.webhooks??[],environment:e?.environment??[],settings:e?.settings??{timezone:e?.schedule_timezone??Intl.DateTimeFormat().resolvedOptions().timeZone,...e?{shell:{executable:`sh`,args:[`-c`]},inherit_project_directory:!1}:{}}},[u,d]=(0,X.useState)(l),f=e?.action?.type===`agent`&&e.action.options?JSON.stringify(e.action.options.runtime===`claude-sdk`||e.action.options.runtime===`pi`?e.action.options.options:e.action.options.args,null,2):``,[p,m]=(0,X.useState)(f),h=i.isPending||a.isPending;function g(e,t){d(n=>({...n,[e]:t}))}function _(t){if(!He(u.action)){c.invalid(`destination`,`Complete the job action.`);return}if(u.trigger_type===`cron`&&!u.cron_expr){c.invalid(`trigger`,`Choose a schedule or enter a cron expression.`);return}if(u.trigger_type===`webhook`&&!u.webhooks.length){c.invalid(`trigger`,`Select at least one webhook.`);return}let n=ce.safeParse(u.settings);if(!n.success){c.invalid(n.error.issues[0].path[0]===`timezone`?`trigger`:`destination`,n.error.issues[0].message);return}let r=ue.safeParse(u.environment);if(!r.success){c.invalid(`settings`,r.error.issues[0].message);return}let o=u.action;if(o.type===`agent`&&!p.trim()){let{options:e,...t}=o;o=t}if(o.type===`agent`&&p.trim()){let e=o.backend===`claude`?`claude-sdk`:o.backend===`pi`?`pi`:o.backend===`codex-cli`?`codex`:`acpx`;try{let t=JSON.parse(p),n=j.parse(e===`claude-sdk`||e===`pi`?{runtime:e,options:t}:{runtime:e,args:t});o={...o,options:n}}catch{c.invalid(`destination`,`Enter valid supported agent launch options as JSON.`);return}}let s=Be.safeParse(o);if(!s.success){c.invalid(`destination`,s.error.issues[0].message);return}let l={...u,action:o,name:u.name.trim(),project_id:u.project_id||null,working_dir:u.working_dir.trim(),settings:n.data,environment:r.data,cron_expr:u.trigger_type===`cron`?u.cron_expr.trim():void 0,webhooks:u.trigger_type===`webhook`?u.webhooks:[]};e?a.mutate({...l,id:e.id},{onSuccess:t}):i.mutate(l,{onSuccess:t})}let v=`min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-sm sm:min-h-8`;return(0,Z.jsx)(se,{open:n,onClose:r,busy:h,dirty:JSON.stringify(u)!==JSON.stringify(l)||p!==f,children:(t,n)=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(me,{children:(0,Z.jsx)(ne,{children:e?`Edit job`:`New job`})}),(0,Z.jsx)(`form`,{ref:c.form,noValidate:!0,className:`min-h-0`,onSubmit:e=>c.submit(e,()=>_(n)),children:(0,Z.jsxs)(N,{steps:c,children:[(0,Z.jsxs)(`div`,{className:`work-form-body space-y-4`,children:[(0,Z.jsxs)(F,{steps:c,id:`trigger`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-name`,children:`Name`}),(0,Z.jsx)(I,{id:`job-name`,"aria-label":`Name`,"data-testid":`job-name-input`,required:!0,maxLength:100,value:u.name,onChange:e=>g(`name`,e.target.value),autoFocus:!0,placeholder:`Check for Sentry issues`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-trigger-type`,children:`Trigger`}),(0,Z.jsxs)(`select`,{id:`job-trigger-type`,"data-testid":`job-trigger-type`,className:v,value:u.trigger_type,onChange:e=>{let t=e.target.value;d({...u,trigger_type:t,cron_expr:t===`cron`?u.cron_expr||`0 9 * * 1,2,3,4,5`:u.cron_expr})},children:[(0,Z.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,Z.jsx)(`option`,{value:`cron`,children:`Schedule`}),(0,Z.jsx)(`option`,{value:`webhook`,children:`Webhook`}),![`manual`,`cron`,`webhook`].includes(u.trigger_type)&&(0,Z.jsxs)(`option`,{value:u.trigger_type,children:[u.trigger_type,` (existing)`]})]})]}),u.trigger_type===`cron`&&(0,Z.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Z.jsx)(Ke,{cron:u.cron_expr,timezone:u.settings.timezone??`UTC`,onChange:e=>g(`cron_expr`,e),onTimezone:e=>g(`settings`,{...u.settings,timezone:e})}),e?.next_run_at&&(0,Z.jsxs)(`p`,{className:`mt-3 text-xs text-outline`,children:[`Saved schedule’s next run:`,` `,new Date(e.next_run_at).toLocaleString(void 0,{timeZone:e.schedule_timezone}),` `,`(`,e.schedule_timezone,`)`]})]}),u.trigger_type===`webhook`&&(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(Me,{value:u.webhooks,onChange:e=>g(`webhooks`,e),projectId:u.project_id||void 0})}),(0,Z.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,Z.jsx)(z,{htmlFor:`job-description`,children:`Description (optional)`}),(0,Z.jsx)(I,{id:`job-description`,"data-testid":`job-description`,value:u.description,onChange:e=>g(`description`,e.target.value)})]})]}),(0,Z.jsxs)(F,{steps:c,id:`destination`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-project`,children:`Project`}),(0,Z.jsxs)(`select`,{id:`job-project`,"data-testid":`job-project-select`,className:v,value:u.project_id,onChange:e=>d({...u,project_id:e.target.value,webhooks:[]}),children:[(0,Z.jsx)(`option`,{value:``,children:`None`}),o?.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),u.action.type!==`task`&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-directory`,children:`Working directory`}),(0,Z.jsx)(I,{id:`job-directory`,"aria-label":`Working directory`,value:u.working_dir,onChange:e=>g(`working_dir`,e.target.value),placeholder:u.action.type===`command`&&u.settings.inherit_project_directory===!1?`Use host working directory (existing job)`:`Use project directory`}),(0,Z.jsx)(`p`,{className:`text-xs text-outline`,children:`A path on the selected host. Worktrees use this repository as their source.`})]}),(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(Ue,{value:u.action,executionHost:u.settings.host,cwd:u.working_dir||o?.find(e=>e.id===u.project_id)?.scope||void 0,onChange:t=>{t.type===`agent`&&u.action.type===`agent`&&t.backend!==u.action.backend&&m(``),d({...u,action:t,settings:!e&&t.type===`agent`&&!u.settings.workspace?{...u.settings,workspace:{mode:`worktree`,base_ref:`HEAD`,cleanup_on_success:!1}}:u.settings})}})}),u.action.type===`agent`&&(0,Z.jsxs)(`details`,{className:`md:col-span-2 space-y-2`,children:[(0,Z.jsx)(`summary`,{className:`min-h-11 cursor-pointer text-sm`,children:`Advanced agent options`}),(0,Z.jsx)(z,{htmlFor:`job-agent-options`,children:u.action.backend===`pi`?`Pi options (JSON object)`:u.action.backend===`claude`?`SDK options (JSON object)`:`Launch arguments (JSON array)`}),(0,Z.jsx)(`textarea`,{id:`job-agent-options`,"data-testid":`job-agent-options`,rows:4,maxLength:2e4,className:`w-full rounded-md border border-control-border bg-background p-3 font-mono text-xs`,value:p,onChange:e=>m(e.target.value)}),(0,Z.jsxs)(P,{label:`Agent launch options`,testId:`job-agent-options-help`,children:[`Uses the same supported options as Chat. Set the model above; keep credentials in environment variables. Unsupported options are rejected.`,u.action.backend===`pi`?` Pi queue, retry and compaction changes are saved to Pi's own settings on the execution host.`:``]})]}),(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(We,{action:u.action,settings:u.settings,onChange:e=>g(`settings`,e)})})]}),(0,Z.jsxs)(F,{steps:c,id:`settings`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm md:col-span-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":e?`job-edit-enabled`:`job-create-enabled`,checked:u.enabled,onChange:e=>g(`enabled`,e.target.checked)}),`Enable this job`]}),(0,Z.jsx)(`p`,{className:`text-xs text-outline md:col-span-2`,children:`Disabled jobs stay saved. You can still run them manually.`}),u.action.type!==`task`&&(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(de,{value:u.environment,onChange:e=>g(`environment`,e)})}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-timeout`,children:`Timeout (seconds)`}),(0,Z.jsx)(I,{id:`job-timeout`,type:`number`,required:!0,min:1,value:u.timeout_secs,onChange:e=>g(`timeout_secs`,Number(e.target.value))})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-retries`,children:`Maximum retries`}),(0,Z.jsx)(I,{id:`job-retries`,type:`number`,required:!0,min:0,value:u.max_retries,onChange:e=>g(`max_retries`,Number(e.target.value))})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-overlap`,children:`When a run is already active`}),(0,Z.jsxs)(`select`,{id:`job-overlap`,className:v,value:u.overlap,onChange:e=>g(`overlap`,e.target.value),children:[(0,Z.jsx)(`option`,{value:`skip`,children:`Skip new run`}),(0,Z.jsx)(`option`,{value:`queue`,children:`Queue`}),(0,Z.jsx)(`option`,{value:`kill`,children:`Stop previous run`})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(z,{htmlFor:`job-notify`,children:`Notify on`}),(0,Z.jsxs)(`select`,{id:`job-notify`,className:v,value:u.notify_on,onChange:e=>g(`notify_on`,e.target.value),children:[(0,Z.jsx)(`option`,{value:`never`,children:`Never`}),(0,Z.jsx)(`option`,{value:`failure`,children:`Failure`}),(0,Z.jsx)(`option`,{value:`always`,children:`Every run`})]})]})]}),(c.error||i.error||a.error)&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error md:col-span-2`,children:c.error||i.error?.message||a.error?.message})]}),(0,Z.jsxs)(le,{className:`work-form-footer gap-2`,children:[(0,Z.jsx)(s,{type:`button`,variant:`ghost`,disabled:h,onClick:t,children:`Cancel`}),(0,Z.jsx)(T,{steps:c,busy:h,children:(0,Z.jsx)(s,{type:`submit`,"data-testid":e?`job-edit-submit`:`job-submit`,disabled:h,children:h?`Saving…`:e?`Save changes`:`Create job`})})]})]})})]})})}var Je=[`one-shot`,`cron`,`watch`,`webhook`,`manual`,`bridge-msg`];function Ye({projectId:e}){let t=ee(`xl`),[n,r]=G(`jobQuery`,``),[i,a]=G(`jobStatus`,`all`,[`all`,`enabled`,`disabled`]),[o,c]=G(`jobTrigger`,`all`,[`all`,...Je]),l=ke(e),u=l===`all`||l===`unassigned`?void 0:l,{data:f,isLoading:p,error:m,refetch:h}=ye({project_id:l===`all`?void 0:l,limit:100}),g=(l===`unassigned`?f?.filter(e=>e.project_id===null):f)?.filter(e=>(!n||`${e.name} ${e.description??``} ${e.command??``}`.toLowerCase().includes(n.toLowerCase()))&&(i===`all`||e.enabled===(i===`enabled`))&&(o===`all`||e.trigger_type===o)),_=JSON.stringify([l,n,i,o]),v=V(),y=ve(),b=H(),x=xe(),S=x.data?.scope===_?x.data:void 0,C=je((g??[]).map(e=>e.id),_);async function w(e){let t=await x.mutateAsync({ids:C.selectedIds,enabled:e,scope:_});C.select(t.failed.map(e=>e.id))}let{selectedId:T,openDetail:E,closeDetail:D}=we(`/jobs`,`jobId`),[O,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)(null);if(m)return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(W,{title:`Jobs`}),(0,Z.jsx)(U,{message:m.message,onRetry:()=>h()})]});let L=(g??[]).filter(e=>e.enabled).length;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(W,{title:`Jobs`,compact:!0,meta:`${L}/${(g??[]).length} enabled`,action:(0,Z.jsxs)(s,{"data-testid":`new-job-button`,size:`sm`,onClick:()=>j(!0),className:`font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,Z.jsx)(pe,{size:12,className:`mr-1`}),` New job`]})}),(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 flex-1 lg:max-w-md`,children:[(0,Z.jsx)(fe,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-outline`}),(0,Z.jsx)(I,{type:`search`,"aria-label":`Search jobs`,"data-testid":`job-search`,placeholder:`Search jobs…`,value:n,onChange:e=>r(e.target.value,{replace:!0}),className:`h-11 pl-9 text-base lg:h-9 lg:text-sm`})]}),(0,Z.jsxs)(d,{activeCount:Number(i!==`all`)+Number(o!==`all`),children:[(0,Z.jsxs)(`select`,{"aria-label":`Job status`,"data-testid":`job-status-filter`,value:i,onChange:e=>a(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,Z.jsx)(`option`,{value:`enabled`,children:`Enabled`}),(0,Z.jsx)(`option`,{value:`disabled`,children:`Disabled`})]}),(0,Z.jsxs)(`select`,{"aria-label":`Job trigger`,"data-testid":`job-trigger-filter`,value:o,onChange:e=>c(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All triggers`}),Je.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})]}),(v.error||y.error||b.error)&&(0,Z.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-error`,children:(v.error??y.error??b.error)?.message}),!!g?.length&&(0,Z.jsxs)(Ae,{resourceLabel:`jobs`,count:C.selectedIds.length,allSelected:C.allSelected,someSelected:C.someSelected,onSelectAll:C.selectAll,onClear:C.clear,disabled:x.isPending,children:[(0,Z.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-enable`,disabled:x.isPending||b.isPending,onClick:()=>void w(!0),children:`Enable selected`}),(0,Z.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-disable`,disabled:x.isPending||b.isPending,onClick:()=>void w(!1),children:`Disable selected`})]}),x.isPending&&(0,Z.jsx)(`p`,{role:`status`,className:`mb-3 text-sm text-outline`,children:`Updating selected jobs…`}),!x.isPending&&S&&(0,Z.jsxs)(`div`,{className:`mb-3 space-y-1 text-sm`,"data-testid":`jobs-bulk-result`,role:`status`,children:[(0,Z.jsxs)(`p`,{children:[S.succeeded.length,` jobs `,S.enabled?`enabled`:`disabled`,`.`]}),S.failed.map(e=>(0,Z.jsxs)(`p`,{className:`text-error`,children:[g?.find(t=>t.id===e.id)?.name??e.id,`: `,e.error,`. Still selected for retry.`]},e.id))]}),p?(0,Z.jsx)(`div`,{role:`status`,"aria-label":`Loading jobs`,className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Z.jsx)(k,{className:`h-12 w-full bg-surface-highest`},t))}):(g??[]).length===0?(0,Z.jsx)(Te,{message:n||i!==`all`||o!==`all`?`No jobs match`:`No jobs configured`}):t?(0,Z.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,Z.jsxs)(Oe,{children:[(0,Z.jsx)(Ee,{children:(0,Z.jsxs)(q,{className:`border-b border-border hover:bg-transparent`,children:[(0,Z.jsx)(K,{className:`w-11`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`Select jobs`})}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline`,children:`Name`}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline w-24`,children:`Trigger`}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline w-48`,children:`Action`}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline w-16`,children:`Enabled`}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline w-36`,children:`Last Run`}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline w-16`,children:`Runs`}),(0,Z.jsx)(K,{className:`font-label text-xs font-medium text-outline w-36`,children:`Next Run`}),(0,Z.jsx)(K,{className:`w-28`})]})}),(0,Z.jsx)(De,{children:(g??[]).map(e=>(0,Z.jsxs)(q,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>E(e.id),children:[(0,Z.jsx)(J,{children:(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:C.selectedIds.includes(e.id),disabled:x.isPending,onClick:e=>e.stopPropagation(),onChange:()=>C.toggle(e.id)})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`font-body text-sm font-medium text-on-surface text-left hover:text-primary`,"data-testid":`job-open-detail`,onClick:t=>{t.stopPropagation(),E(e.id)},children:e.name}),e.description&&(0,Z.jsx)(`div`,{className:`font-body text-sm text-outline mt-0.5 truncate max-w-[200px]`,children:e.description})]}),(0,Z.jsx)(J,{children:(0,Z.jsx)(`span`,{className:`font-label text-xs text-on-surface-variant inline-flex`,children:e.trigger_type})}),(0,Z.jsx)(J,{children:(0,Z.jsx)(`code`,{className:`font-mono text-xs text-outline truncate block max-w-[180px]`,children:e.action?.type===`agent`?`Agent: ${e.action.backend}`:e.action?.type===`task`?`Task: ${e.action.title}`:e.command})}),(0,Z.jsx)(J,{children:(0,Z.jsx)(s,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:b.isPending||x.isPending,onClick:t=>{t.stopPropagation(),b.mutate({id:e.id,enabled:!e.enabled})},children:e.enabled?`Disable`:`Enable`})}),(0,Z.jsx)(J,{className:`font-label text-xs text-outline`,children:e.last_run_at?new Date(e.last_run_at).toLocaleString():`—`}),(0,Z.jsx)(J,{className:`font-label text-xs text-outline`,children:e.run_count}),(0,Z.jsx)(J,{className:`font-label text-xs text-outline`,children:e.next_run_at?new Date(e.next_run_at).toLocaleString():`—`}),(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(s,{variant:`ghost`,"data-testid":`job-trigger`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id,{onSuccess:()=>E(e.id)}),className:`font-label text-sm min-h-8 px-3 bg-transparent text-on-surface border border-border hover:bg-surface-high`,children:[(0,Z.jsx)(Y,{size:10,className:`mr-1`}),` Run`]}),(0,Z.jsx)(s,{type:`button`,"data-testid":`job-edit`,variant:`ghost`,size:`icon`,"aria-label":`Edit ${e.name}`,onClick:()=>N(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest`,children:(0,Z.jsx)(R,{size:16})}),(0,Z.jsx)(s,{type:`button`,"data-testid":`job-delete`,variant:`ghost`,size:`icon`,"aria-label":`Delete ${e.name}`,onClick:()=>F(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10`,children:(0,Z.jsx)(A,{size:12})})]})})]},e.id))})]})}):(0,Z.jsx)(`div`,{className:`divide-y divide-border`,children:(g??[]).map(e=>(0,Z.jsxs)(`article`,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`py-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary shrink-0 mt-1`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:C.selectedIds.includes(e.id),disabled:x.isPending,onChange:()=>C.toggle(e.id)}),(0,Z.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left font-medium text-sm text-on-surface wrap-break-word hover:text-primary`,"data-testid":`job-open-detail`,onClick:()=>E(e.id),children:e.name}),(0,Z.jsx)(s,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:b.isPending||x.isPending,onClick:()=>b.mutate({id:e.id,enabled:!e.enabled}),children:e.enabled?`Disable`:`Enable`})]}),e.description&&(0,Z.jsx)(`p`,{className:`text-sm text-outline wrap-break-word`,children:e.description}),(0,Z.jsx)(`code`,{className:`block whitespace-pre-wrap break-all text-xs text-on-surface-variant`,children:e.action?.type===`agent`?`Agent: ${e.action.backend}`:e.action?.type===`task`?`Task: ${e.action.title}`:e.command}),(0,Z.jsxs)(`p`,{className:`text-xs text-outline`,children:[e.trigger_type,` · `,e.run_count,` runs`,e.next_run_at?` · Next: ${new Date(e.next_run_at).toLocaleString()}`:``]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(s,{"data-testid":`job-edit`,variant:`ghost`,size:`sm`,onClick:()=>N(e),children:[(0,Z.jsx)(R,{}),`Edit`]}),(0,Z.jsxs)(s,{"data-testid":`job-trigger`,variant:`ghost`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id,{onSuccess:()=>E(e.id)}),children:[(0,Z.jsx)(Y,{}),`Run`]}),(0,Z.jsx)(s,{"data-testid":`job-delete`,"aria-label":`Delete ${e.name}`,variant:`ghost`,size:`icon`,onClick:()=>F(e),children:(0,Z.jsx)(A,{})})]})]},e.id))}),(0,Z.jsx)(Le,{projectScope:l,jobId:T,open:!!T,onClose:D,onEdit:e=>{D(),N(e)}}),O&&(0,Z.jsx)(qe,{defaultProjectId:u,open:O,onClose:()=>j(!1)}),M&&(0,Z.jsx)(qe,{job:M,open:!!M,onClose:()=>N(null)}),P&&(0,Z.jsx)(he,{open:!!P,title:`Delete Job`,description:`Delete job "${P.name}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,isPending:y.isPending,onConfirm:()=>{y.mutate(P.id,{onSuccess:()=>F(null)})},onCancel:()=>F(null)})]})}export{Ye as default};
|
|
@@ -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{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-CRAWY7v2.js";import{f as o,h as s,p as c,t as l,u}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{c as d,l as f,t as p}from"./button-BlVCkBiz.js";import{a as m,c as h,i as g,o as _,r as v,s as y,t as b}from"./dist-B-iYpxX5.js";import{h as x,n as S}from"./client-RPZmgRqE.js";import{t as C}from"./chevron-down-CsfelGxA.js";import{t as w}from"./download-Cnjcb403.js";import{t as T}from"./ResponsiveFilters-BwU4JbGU.js";import{t as E}from"./upload-Bbixlc7i.js";import{t as D}from"./x-uOircJYm.js";import{a as O,c as k,d as A,f as j,g as M,h as N,i as P,m as F,o as I,t as L,u as R}from"./schemas-BQZhekae.js";import{At as z,B,Bi as ee,Di as te,Dt as V,Et as ne,Fn as re,J as H,Jn as ie,Jr as U,Li as ae,Ni as oe,O as se,Qr as ce,Tt as le,U as ue,Ur as de,Vi as fe,Vr as pe,Wr as me,X as he,Xr as ge,Y as _e,Yr as W,Z as ve,Zn as ye,Zr as be,_ as xe,at as Se,b as Ce,ci as we,cn as Te,ct as Ee,fi as De,in as Oe,it as G,jt as ke,li as Ae,lt as je,nt as Me,oi as Ne,on as K,ot as Pe,ri as Fe,rn as Ie,rt as Le,si as Re,sn as ze,ti as Be,v as Ve,vt as He,wi as Ue,xi as We,z as Ge,zi as Ke}from"./index-DsVJrhHJ.js";import{n as qe}from"./wiki-links-A52THGx_.js";import{t as Je}from"./ConfirmDialog-DKN0AVIw.js";import{t as Ye}from"./save-file-3ZpJah8W.js";import{t as Xe}from"./ErrorState-CpcyNx03.js";import{t as Ze}from"./ViewHeader-BiFirRWq.js";import{t as Qe}from"./view-params-YEmeZppw.js";import{t as $e}from"./EmptyState-YM4VSLR9.js";import{a as et,i as tt,n as nt,o as rt,r as it,t as at}from"./table-D2GMF--l.js";import{t as ot}from"./useProjectScope-DpgzthH7.js";import{a as st,c as ct,i as lt,n as ut,o as dt,r as ft,s as pt,t as mt}from"./useMemories-Ce1S_iFK.js";import{n as ht,t as gt}from"./DocumentWorkspace-B9hQN2EX.js";import{_ as _t,a as vt,c as yt,d as bt,f as xt,g as St,i as Ct,l as wt,m as Tt,n as Et,o as Dt,p as Ot,r as q,s as kt,t as At,u as jt,v as Mt}from"./badge-BEhHQEk0.js";import{t as Nt}from"./TagInput-QqNDQOz_.js";import{n as Pt,t as Ft}from"./NativeFolderField-D1ZqCzY1.js";var It={name:`file-down`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]};It.node;var Lt=x(It),Rt={name:`file-plus`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]};Rt.node;var zt=x(Rt),Bt={name:`file-up`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]};Bt.node;var Vt=x(Bt),Ht={name:`folder-sync`,size:24,node:[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5`,key:`1dkoa9`}],[`path`,{d:`M12 10v4h4`,key:`1czhmt`}],[`path`,{d:`m12 14 1.535-1.605a5 5 0 0 1 8 1.5`,key:`lvuxfi`}],[`path`,{d:`M22 22v-4h-4`,key:`1ewp4q`}],[`path`,{d:`m22 18-1.535 1.605a5 5 0 0 1-8-1.5`,key:`14ync0`}]]};Ht.node;var Ut=x(Ht),J=e(t(),1),Y=[`mcp`,`api`,`cli`,`ui`],Wt=[`fetch`,`cited`,`search_hit`],Gt=F().trim().min(1).max(120),Kt=P(L(Y)).max(Y.length).transform(e=>Y.filter(t=>e.includes(t)));A({name:Gt,description:F().trim().max(2e3).default(``),project_id:F().min(1).nullable(),editable_by:Kt.default([...Y]),parser:F().min(1).max(40).nullable().default(null)}).strict(),A({name:Gt.optional(),description:F().trim().max(2e3).optional(),editable_by:Kt.optional(),parser:F().min(1).max(40).nullable().optional()}).strict();var qt=[`default`,`project`,`global`,`all`],Jt=F().trim().min(1).max(500).refine(e=>!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.includes(`:`)&&!e.includes(`\0`)&&e.split(`/`).every(e=>e&&e!==`.`&&e!==`..`),`Use a relative path with / separators and no . or .. segments`),Yt=P(F().trim().min(1).max(60)).max(30),Xt=2097152;A({title:F().trim().min(1).max(300),path:Jt.optional(),description:F().trim().max(2e3).optional(),labels:Yt.default([]),content:F().max(Xt),note:F().trim().max(1e3).optional(),derived_from:P(F().min(1)).max(50).default([])}).strict(),A({expected_revision:R().int().min(1),title:F().trim().min(1).max(300).optional(),path:Jt.optional(),description:F().trim().max(2e3).optional(),labels:Yt.optional(),content:F().max(Xt).optional(),note:F().trim().max(1e3).optional(),derived_from:P(F().min(1)).max(50).optional()}).strict();var Zt=A({kind:L([`heading`,`paragraph`,`list_item`,`table`,`code`]),text:F(),level:R().int().min(1).max(6).optional(),rows:P(P(F())).optional(),heading_path:P(F()),locator:A({page:R().int().min(1).optional(),sheet:F().optional(),bbox:P(R()).length(4).optional()}).optional()});A({schema_version:k(1),parser:A({id:F(),version:F(),options:j(F(),M())}),source_sha256:F().regex(/^[0-9a-f]{64}$/),status:L([`ok`,`partial`,`failed`]),language:F().optional(),blocks:P(Zt),markdown:F(),warnings:P(F()),timings_ms:j(F(),R()).optional(),peak_rss_mb:R().optional()});var Qt=[`auto`,`lexical`,`semantic`,`hybrid`];A({query:F().trim().min(1).max(2e3),scope:L(qt).default(`default`),kb_ids:P(F().min(1)).max(50).optional(),labels:P(F().min(1)).max(20).optional(),media_types:P(F().min(1)).max(20).optional(),mode:L(Qt).default(`auto`),limit:R().int().min(1).max(50).default(10)}).strict().omit({limit:!0,mode:!0}).extend({mode:L(Qt).default(`auto`),token_budget:R().int().min(500).max(32e3).default(6e3),max_per_document:R().int().min(1).max(10).default(3)}).strict();var $t=A({old:F().min(1).max(Xt),new:F().max(Xt),replace_all:O().optional()}).strict(),en=A({start_line:R().int().min(1),end_line:R().int().min(0),new:F().max(Xt)}).strict();A({expected_revision:R().int().min(1),edits:P(N([$t,en])).min(1).max(50),note:F().trim().min(1).max(1e3)}).strict();var tn=[`open`,`resolved`,`dismissed`];A({document_id:F().min(1).nullable().optional(),body:F().trim().min(1).max(1e4)}).strict(),A({status:L([`resolved`,`dismissed`]),reply:F().trim().min(1).max(4e3)}).strict();var nn=I(`type`,[A({type:k(`cron`),cron:F().trim().min(1).max(120)}).strict(),A({type:k(`manual`)}).strict()]);A({instructions:F().trim().min(1).max(2e4).optional(),backend:F().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/).optional(),schedule:nn.optional(),enabled:O().optional(),timeout_secs:R().int().min(60).max(7200).optional()}).strict();var rn=`0 3 * * *`,X=n();function an({title:e,testId:t,toggleTestId:n,summary:r,actions:i,expanded:a=!1,onExpandedChange:o,heading:s=`h3`,compact:c=!1,children:l}){let u=(0,J.useId)(),f=l!==void 0&&o!==void 0;return(0,X.jsxs)(`section`,{"data-testid":t,"data-expanded":f?a:void 0,"aria-labelledby":`${u}-heading`,className:`min-w-0 text-sm`,children:[(0,X.jsxs)(`div`,{className:d(`grid min-h-12 min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-0.5 py-1.5`,!c&&`sm:grid-cols-[9rem_minmax(0,1fr)_auto]`),children:[(0,X.jsx)(s,{id:`${u}-heading`,className:`min-w-0 font-medium`,children:f?(0,X.jsxs)(`button`,{type:`button`,"data-testid":n,"aria-expanded":a,"aria-controls":u,className:`-ml-1 flex min-h-9 items-center gap-1.5 rounded px-1 text-left hover:bg-surface-high`,onClick:()=>o(!a),children:[(0,X.jsx)(oe,{size:14,"aria-hidden":!0,className:d(`shrink-0 text-outline transition-transform`,a&&`rotate-90`)}),e]}):(0,X.jsx)(`span`,{className:`flex min-h-9 items-center pl-5`,children:e})}),(0,X.jsx)(`div`,{className:d(`col-span-2 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-5`,!c&&`sm:col-span-1 sm:col-start-2 sm:row-start-1 sm:pl-0`),children:r}),(0,X.jsx)(`div`,{className:d(`col-start-2 row-start-1 flex items-center justify-end gap-1`,!c&&`sm:col-start-3`),children:i})]}),f&&a&&(0,X.jsx)(`div`,{id:u,className:`min-w-0 pb-4 pl-5 pt-1`,children:l})]})}function Z({tone:e}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:d(`size-1.5 shrink-0 rounded-full`,e===`ok`&&`bg-secondary`,e===`warning`&&`bg-warning`,e===`error`&&`bg-error`,e===`off`&&`bg-muted-foreground`,e===`progress`&&`bg-progress`)})}var on=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],sn=/^\d+$/,cn=e=>e.padStart(2,`0`),ln=e=>/^\*\/(\d+)$/.exec(e)?.[1],un=(e,t)=>e===`1`?`Every ${t}`:`Every ${e} ${t}s`;function dn(e){let[t=``,n=``,r,i,a=``,...o]=e.trim().split(/\s+/);if(o.length||r!==`*`||i!==`*`)return e;if(n===`*`&&a===`*`){if(t===`*`)return`Every minute`;let n=ln(t);return n?un(n,`minute`):sn.test(t)?Number(t)?`Every hour at :${cn(t)}`:`Every hour`:e}if(!sn.test(t))return e;let s=ln(n);if(s&&a===`*`)return`${un(s,`hour`)}${Number(t)?` at :${cn(t)}`:``}`;if(!sn.test(n))return e;let c=`${cn(n)}:${cn(t)}`;return a===`*`?`Daily at ${c}`:a===`1-5`?`Weekdays at ${c}`:a===`0,6`||a===`6,0`?`Weekends at ${c}`:/^[0-7]$/.test(a)?`${on[Number(a)%7]}s at ${c}`:e}var fn=[{name:`minute`,min:0,max:59,names:[]},{name:`hour`,min:0,max:23,names:[]},{name:`day of month`,min:1,max:31,names:[]},{name:`month`,min:1,max:12,names:[`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`]},{name:`weekday`,min:0,max:7,names:[`SUN`,`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`]}];function pn(e,t){let n=e=>{let n=t.names.indexOf(e.toUpperCase()),r=n>=0?n+ +(t.min===1):sn.test(e)?Number(e):NaN;return r>=t.min&&r<=t.max?r:NaN};return e.split(`,`).every(e=>{let t=/^(\*|[a-z0-9]+(?:-[a-z0-9]+)?)(?:\/(\d+))?$/i.exec(e);if(!t?.[1]||t[2]!==void 0&&Number(t[2])<1)return!1;if(t[1]===`*`)return!0;let[r=``,i]=t[1].split(`-`);return i===void 0?!Number.isNaN(n(r)):n(r)<=n(i)})}function mn(e){let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return`Enter a cron expression.`;if(t.length!==5)return`A cron expression has 5 fields (minute hour day month weekday); this one has ${t.length}.`;for(let[e,n]of fn.entries()){let r=t[e]??``;if(!pn(r,n))return`The ${n.name} field "${r}" is not valid. Use a number from ${n.min} to ${n.max}, *, a range (1-5), a list (1,3) or a step (*/2).`}return null}function hn(e){let t=Math.max(0,Math.round((e-Date.now())/1e3));if(t<60)return`in under a minute`;if(t<3600)return`in ${Math.round(t/60)}m`;if(t<86400)return`in ${Math.round(t/3600)}h`;let n=new Date(e);return`${on[n.getDay()]?.slice(0,3)} ${cn(String(n.getHours()))}:${cn(String(n.getMinutes()))}`}function gn(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`just now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function _n(e){let t=e.last_run?.status;return t===`running`?`progress`:e.schedule.type===`cron`&&!e.enabled?`off`:t===`failed`?`error`:t===`completed`?`ok`:`off`}function vn({kb:e}){let t=vt(e.id),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(!1),o=t.data;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(an,{title:`Digest`,testId:`kb-digest`,toggleTestId:`kb-digest-expand`,expanded:i,onExpandedChange:a,summary:t.error?(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,children:t.error.message}):t.isLoading?(0,X.jsx)(`span`,{className:`text-outline`,children:`Loading…`}):o?(0,X.jsx)(yn,{digest:o}):(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-outline`,"data-testid":`kb-digest-off`,children:[(0,X.jsx)(Z,{tone:`off`}),`Off, documents change only when someone edits them`]}),actions:o?(0,X.jsx)(bn,{kb:e,digest:o,onStarted:()=>a(!0)}):t.data===null?(0,X.jsx)(p,{size:`sm`,variant:`outline`,"data-testid":`kb-digest-add`,onClick:()=>r(`edit`),children:`Set up`}):null,children:o?(0,X.jsx)(xn,{kb:e,digest:o,onEdit:()=>r(`edit`)}):(0,X.jsx)(`p`,{className:`max-w-prose text-outline`,children:`A digest is an agent that reads new memories, sessions and open comments, then keeps the documents in this knowledge base current. It can run on a schedule or only when you start it.`})}),n===`edit`&&(0,X.jsx)(Gn,{kb:e,digest:o??null,onClose:()=>r(null),onRemove:()=>r(`remove`)}),n===`remove`&&(0,X.jsx)(Kn,{kb:e,onClose:()=>r(null)})]})}function yn({digest:e}){let t=e.last_run,n=e.schedule.type===`manual`||e.enabled;return(0,X.jsxs)(`span`,{"data-testid":`kb-digest-summary`,className:`inline-flex min-w-0 flex-wrap items-center gap-x-1.5`,children:[(0,X.jsx)(Z,{tone:_n(e)}),(0,X.jsx)(`span`,{"data-testid":`kb-digest-enabled`,children:n?`On`:`Paused`}),(0,X.jsxs)(`span`,{children:[`·`,` `,e.schedule.type===`manual`?`runs when you start it`:(0,X.jsx)(`span`,{title:e.schedule.cron,children:dn(e.schedule.cron)})]}),e.next_run_at!==null&&(0,X.jsxs)(`span`,{className:`text-outline`,"data-testid":`kb-digest-next-run`,children:[`·`,` `,(0,X.jsxs)(`span`,{title:new Date(e.next_run_at).toLocaleString(),children:[`next run `,hn(e.next_run_at)]})]}),(0,X.jsxs)(`span`,{className:`text-outline`,"data-testid":`kb-digest-last-run`,"data-status":t?.status??`never`,children:[`·`,` `,t?t.status===`running`?`running now`:(0,X.jsxs)(`span`,{title:new Date(t.at).toLocaleString(),children:[`last run`,` `,(0,X.jsx)(`span`,{className:t.status===`failed`?`text-error`:void 0,children:t.status===`completed`?`succeeded`:t.status}),` `,gn(t.at)]}):`not run yet`]})]})}function bn({kb:e,digest:t,onStarted:n}){let r=q(),i=Q(),a=t.last_run?.status===`running`;async function o(){await i.run(()=>S.kb.runDigest(e.id))&&(n(),await r())}return(0,X.jsxs)(X.Fragment,{children:[i.error&&(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,"data-testid":`kb-digest-error`,children:i.error}),(0,X.jsx)(p,{size:`sm`,variant:`outline`,"data-testid":`kb-digest-run`,onClick:o,disabled:i.pending||a,children:a?`Running…`:`Run now`})]})}function xn({kb:e,digest:t,onEdit:n}){let r=q(),i=Q(),a=Dt(e.id,t);async function o(){await i.run(()=>S.kb.setDigest(e.id,{enabled:!t.enabled}))&&await r()}return(0,X.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,X.jsxs)(`p`,{className:`max-w-prose text-outline`,children:[`The `,(0,X.jsx)(`span`,{className:`font-mono text-on-surface`,children:t.backend}),` agent reads new memories, sessions and open comments, then updates documents here.`,` `,(0,X.jsx)(`span`,{"data-testid":`kb-digest-open-comments`,children:t.open_comments}),` open`,` `,t.open_comments===1?`comment waits`:`comments wait`,` for the next run.`]}),(0,X.jsxs)(`div`,{className:`-ml-2 flex flex-wrap items-center gap-1`,children:[(0,X.jsx)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-digest-edit`,onClick:n,children:`Edit instructions and schedule`}),t.schedule.type===`cron`&&(0,X.jsx)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-digest-toggle`,onClick:o,disabled:i.pending,children:t.enabled?`Pause schedule`:`Resume schedule`}),(0,X.jsx)(p,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,X.jsx)(l,{to:`/jobs/${encodeURIComponent(t.job_id)}`,"data-testid":`kb-digest-job`,children:`Job history`})})]}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-error`,"data-testid":`kb-digest-error`,children:i.error}),(0,X.jsx)(Cn,{runs:a.data??[]})]})}var Sn={failed:`error`,success:`ok`,running:`progress`};function Cn({runs:e}){return e.length?(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h4`,{className:`text-xs font-medium text-outline`,children:`Recent runs`}),(0,X.jsx)(`ol`,{"data-testid":`kb-digest-runs`,className:`divide-y divide-outline-variant`,children:e.map(e=>(0,X.jsxs)(`li`,{"data-testid":`kb-digest-run-row`,"data-status":e.status,className:`min-w-0 wrap-break-word py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(Z,{tone:Sn[e.status]??`off`}),e.status]}),(0,X.jsxs)(`span`,{className:`text-outline`,children:[` · `,e.started_at?(0,X.jsx)(`span`,{title:new Date(e.started_at).toLocaleString(),children:gn(e.started_at)}):`not started`,e.trigger_by?` · ${e.trigger_by}`:``]}),e.session_id&&(0,X.jsx)(l,{to:`/audit/${encodeURIComponent(e.session_id)}`,className:`ml-2 text-primary hover:underline`,children:`Session`}),(e.error||e.summary)&&(0,X.jsx)(`span`,{className:`block truncate text-xs text-outline`,title:e.error??e.summary??``,children:e.error??e.summary})]},e.run_id))})]}):(0,X.jsx)(`p`,{className:`text-outline`,children:`No runs yet.`})}var wn=`__global__`,Tn=`__auto__`;function En(e){return e instanceof Error?e.message:`Request failed`}function Q(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(null);async function i(e){t(!0),r(null);try{return await e()}catch(e){r(En(e));return}finally{t(!1)}}return{pending:e,error:n,run:i,setError:r}}function $({label:e,children:t,hint:n}){return(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(Ee,{className:`text-sm text-muted-foreground`,children:e}),t,n&&(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:n})]})}function Dn({error:e}){return e?(0,X.jsx)(`p`,{role:`alert`,"data-testid":`kb-dialog-error`,className:`text-sm text-error`,children:e}):null}function On({open:e,onClose:t,title:n,wide:r,size:i,children:a}){return(0,X.jsx)(Ie,{open:e,onOpenChange:e=>!e&&t(),children:(0,X.jsxs)(Oe,{className:`bg-surface border-outline-variant ${i===`xl`?`w-[calc(100%-1rem)] max-w-4xl`:r?`max-w-3xl`:`max-w-md`}`,children:[(0,X.jsx)(ze,{children:(0,X.jsx)(Te,{className:`text-base text-on-surface`,children:n})}),a]})})}function kn({value:e,onChange:t}){let n=xt();return(0,X.jsxs)(Me,{value:e??Tn,onValueChange:e=>t(e===Tn?null:e),children:[(0,X.jsx)(Se,{"aria-label":`Parser`,"data-testid":`kb-parser-select`,children:(0,X.jsx)(Pe,{})}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(G,{value:Tn,children:`Workspace default`}),(n.data?.parsers??[]).map(e=>(0,X.jsxs)(G,{value:e.id,disabled:!e.installed,children:[e.label,e.installed?``:` (not installed)`]},e.id))]})]})}var An={ui:`Web UI`,cli:`CLI`,api:`REST API`,mcp:`Agents (MCP)`};function jn({value:e,onChange:t}){return(0,X.jsxs)(`fieldset`,{className:`space-y-2 rounded-md border border-outline-variant p-3`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-sm text-muted-foreground`,children:`Who can change documents`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:Y.map(n=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,"data-testid":`kb-editable-${n}`,checked:e.includes(n),onChange:r=>t(Y.filter(t=>t===n?r.target.checked:e.includes(t)))}),An[n]]},n))}),(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:`Every source can read and search. Knowledge base settings change only from the UI, CLI or API.`})]})}function Mn({open:e,projectId:t,onClose:n,onCreated:r}){let i=ie(),a=q(),o=Q(),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(t??wn),[m,h]=(0,J.useState)([...Y]),[g,_]=(0,J.useState)(null);async function v(e){e.preventDefault();let t=await o.run(()=>S.kb.create({name:s.trim(),description:l.trim(),project_id:d===wn?null:d,editable_by:m,parser:g}));t&&(await a(),r(t))}return(0,X.jsx)(On,{open:e,onClose:n,title:`New knowledge base`,children:(0,X.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[(0,X.jsx)($,{label:`Name`,children:(0,X.jsx)(W,{"aria-label":`Name`,"data-testid":`kb-name-input`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. Runbooks`,autoFocus:!0})}),(0,X.jsx)($,{label:`Description`,children:(0,X.jsx)(U,{"aria-label":`Description`,value:l,onChange:e=>u(e.target.value),rows:2})}),(0,X.jsx)($,{label:`Belongs to`,hint:`Project knowledge bases are visible in that project; global ones in every project.`,children:(0,X.jsxs)(Me,{value:d,onValueChange:f,children:[(0,X.jsx)(Se,{"aria-label":`Belongs to`,"data-testid":`kb-owner-select`,children:(0,X.jsx)(Pe,{})}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(G,{value:wn,children:`Global (all projects)`}),(i.data??[]).map(e=>(0,X.jsx)(G,{value:e.id,children:e.name},e.id))]})]})}),(0,X.jsx)(jn,{value:m,onChange:h}),(0,X.jsx)($,{label:`Parser for uploads`,children:(0,X.jsx)(kn,{value:g,onChange:_})}),(0,X.jsx)(Dn,{error:o.error}),(0,X.jsxs)(K,{children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(p,{type:`submit`,"data-testid":`kb-create-submit`,disabled:!s.trim()||o.pending,children:o.pending?`Creating…`:`Create`})]})]})})}function Nn({kb:e,onClose:t,onDeleted:n}){let r=ie(),i=q(),a=Q(),[o,s]=(0,J.useState)(e.name),[c,l]=(0,J.useState)(e.description),[u,d]=(0,J.useState)(e.editable_by),[f,m]=(0,J.useState)(e.parser),[h,g]=(0,J.useState)(!1);async function _(n){n.preventDefault(),await a.run(()=>S.kb.update(e.id,{name:o.trim(),description:c.trim(),editable_by:u,parser:f}))&&(await i(),t())}return(0,X.jsxs)(On,{open:!0,onClose:t,title:`Knowledge base settings`,children:[(0,X.jsxs)(`form`,{onSubmit:_,className:`space-y-4`,children:[(0,X.jsx)($,{label:`Name`,children:(0,X.jsx)(W,{"aria-label":`Name`,"data-testid":`kb-name-input`,value:o,onChange:e=>s(e.target.value)})}),(0,X.jsx)($,{label:`Description`,children:(0,X.jsx)(U,{"aria-label":`Description`,value:c,onChange:e=>l(e.target.value),rows:2})}),(0,X.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Belongs to`}),(0,X.jsxs)(`p`,{className:`text-outline`,"data-testid":`kb-settings-owner`,children:[e.project_id===null?`Global, visible in every project`:`${r.data?.find(t=>t.id===e.project_id)?.name??`A project`}, visible in that project`,`. Set when the knowledge base is created.`]})]}),(0,X.jsx)(jn,{value:u,onChange:d}),(0,X.jsx)($,{label:`Parser for uploads`,hint:`Applies to new uploads and reparses.`,children:(0,X.jsx)(kn,{value:f,onChange:m})}),(0,X.jsx)(Dn,{error:a.error}),(0,X.jsxs)(K,{className:`gap-2 sm:justify-between`,children:[(0,X.jsxs)(p,{type:`button`,variant:`ghost`,className:`text-error`,"data-testid":`kb-delete`,onClick:()=>g(!0),children:[(0,X.jsx)(ce,{size:14}),`Delete`]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,onClick:t,children:`Cancel`}),(0,X.jsx)(p,{type:`submit`,"data-testid":`kb-settings-save`,disabled:!o.trim()||a.pending,children:`Save`})]})]})]}),(0,X.jsx)(Je,{open:h,title:`Delete knowledge base`,description:`Delete "${e.name}" with its ${e.document_count} documents, revisions and uploaded files? Registered folders on disk are not touched.`,isPending:a.pending,onCancel:()=>g(!1),onConfirm:async()=>{let t=await a.run(()=>S.kb.remove(e.id));g(!1),t!==void 0&&(await i(),n())}})]})}function Pn(e){return`${e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`untitled`}.md`}function Fn(e){return e.match(/^#\s+(.+?)\s*#*\s*$/m)?.[1]?.trim()??``}var In=/\.(md|markdown|txt)$/i;function Ln({kb:e,initialFile:t,onClose:n,onCreated:r,onUploadMany:i}){let a=q(),o=Q(),s=jt(e.id),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)([]),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),C=(0,J.useRef)(null),w=v?``:Fn(u),T=c.trim()||w,O=v?v.name:Pn(T),k=v!==null||u.trim()!==``;async function A(e){let t=e.name.replace(/\.[^.]+$/,``);if(!In.test(e.name)){y(e),l(t),h(``);return}x(!0);let n=await o.run(()=>e.text());x(!1),n!==void 0&&(y(null),d(n),l(Fn(n)||t),h(/\.txt$/i.test(e.name)?Pn(t):e.name))}function j(e){let t=[...e??[]];t.length>1?i(t):t[0]&&A(t[0])}(0,J.useEffect)(()=>{t&&A(t)},[]);async function M(t){t.preventDefault();let n=await o.run(()=>v?S.kb.upload(e.id,{file:v,title:T,path:m.trim()||void 0,labels:g}):S.kb.createDocument(e.id,{title:T,path:m.trim()||O,labels:g,content:k?u:`# ${T}\n\n`}));n&&(await a(),r(n,k))}return(0,X.jsx)(On,{open:!0,onClose:n,title:`New document in ${e.name}`,size:`xl`,children:(0,X.jsxs)(`form`,{onSubmit:M,className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-outline`,children:[(0,X.jsx)(`span`,{children:`Write or paste below, or start from a file.`}),(0,X.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`kb-doc-choose-file`,disabled:b||o.pending,onClick:()=>C.current?.click(),children:[(0,X.jsx)(E,{size:16}),b?`Reading…`:`Upload file`]}),(0,X.jsx)(`input`,{ref:C,type:`file`,multiple:!0,hidden:!0,"data-testid":`kb-doc-file-input`,onChange:e=>{j(e.target.files),e.target.value=``}})]}),(0,X.jsx)($,{label:`Title`,hint:w&&!c.trim()?`Taken from the first heading.`:void 0,children:(0,X.jsx)(W,{"aria-label":`Title`,"data-testid":`kb-doc-title-input`,value:c,onChange:e=>l(e.target.value),placeholder:w||`e.g. Deploy runbook`,autoFocus:!0})}),v?(0,X.jsx)($,{label:`File`,hint:`Converted to searchable text after it is added. The original file is kept.`,children:(0,X.jsxs)(`div`,{"data-testid":`kb-doc-file`,className:`flex items-center gap-3 rounded-md border border-surface-highest bg-surface p-3`,children:[(0,X.jsx)(Ue,{size:20,className:`shrink-0 text-outline`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,title:v.name,children:v.name}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-outline`,children:f(v.size)}),(0,X.jsx)(p,{type:`button`,size:`icon`,variant:`ghost`,"aria-label":`Remove ${v.name}`,"data-testid":`kb-doc-file-remove`,onClick:()=>{y(null),l(``)},children:(0,X.jsx)(D,{size:16})})]})}):(0,X.jsx)($,{label:`Content`,hint:`Markdown. Leave empty to start writing in the editor.`,children:(0,X.jsx)(He,{path:m.trim()||O,value:u,onChange:d,testId:`kb-doc-content-input`,label:`Content`,placeholder:`Write or paste Markdown`,initialMode:`edit`,height:`45vh`})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:`Labels`,hint:`Enter, comma or space adds a label.`,children:(0,X.jsx)(Nt,{"aria-label":`Labels`,"data-testid":`kb-doc-labels-input`,value:g,onChange:_,suggestions:s.data?.labels.map(e=>e.label)})}),(0,X.jsx)($,{label:`Path`,hint:`Optional. Folders come from the path, e.g. guides/setup.md.`,children:(0,X.jsx)(W,{"aria-label":`Path`,"data-testid":`kb-doc-path-input`,value:m,onChange:e=>h(e.target.value),placeholder:O,className:`font-mono text-sm`})})]}),(0,X.jsx)(Dn,{error:o.error}),(0,X.jsxs)(K,{children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(p,{type:`submit`,"data-testid":`kb-doc-create-submit`,disabled:!T||o.pending,children:`Create`})]})]})})}function Rn({doc:e,linkedFrom:t,onClose:n,onSaved:r}){let i=q(),a=Q(),[o,s]=(0,J.useState)(e.title),[c,l]=(0,J.useState)(e.path),u=jt(e.kb_id),[d,f]=(0,J.useState)(e.labels),[m,h]=(0,J.useState)(e.description),g=o.trim()!==e.title||c.trim()!==e.path;async function _(t){t.preventDefault(),await a.run(()=>S.kb.updateDocument(e.id,{expected_revision:e.revision,title:o.trim(),path:c.trim(),labels:d,description:m.trim()}))&&(await i(),r())}return(0,X.jsx)(On,{open:!0,onClose:n,title:`Document properties`,children:(0,X.jsxs)(`form`,{onSubmit:_,className:`space-y-4`,children:[(0,X.jsx)($,{label:`Title`,children:(0,X.jsx)(W,{"aria-label":`Title`,"data-testid":`kb-doc-title-input`,value:o,onChange:e=>s(e.target.value)})}),(0,X.jsx)($,{label:`Path`,children:(0,X.jsx)(W,{"aria-label":`Path`,"data-testid":`kb-doc-path-input`,value:c,onChange:e=>l(e.target.value),className:`font-mono text-sm`})}),(0,X.jsx)($,{label:`Labels`,hint:`Enter, comma or space adds a label.`,children:(0,X.jsx)(Nt,{"aria-label":`Labels`,"data-testid":`kb-doc-labels-input`,value:d,onChange:f,suggestions:u.data?.labels.map(e=>e.label)})}),(0,X.jsx)($,{label:`Description`,children:(0,X.jsx)(U,{"aria-label":`Description`,value:m,onChange:e=>h(e.target.value),rows:2})}),g&&t>0&&(0,X.jsxs)(`p`,{role:`status`,className:`text-sm text-warning`,"data-testid":`kb-rename-warning`,children:[t===1?`1 document links`:`${t} documents link`,` to this document. Links that use the old title or path will show as missing.`]}),(0,X.jsx)(Dn,{error:a.error}),(0,X.jsxs)(K,{children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(p,{type:`submit`,"data-testid":`kb-doc-properties-save`,disabled:!o.trim()||a.pending,children:`Save`})]})]})})}var zn={daily:`Every day`,weekly:`Once a week`,custom:`Custom cron`,manual:`Manual only`};function Bn(e){let t=e.type===`cron`?e.cron:rn,n={plan:`custom`,time:`03:00`,day:`1`,cron:t},r=/^(\d{1,2}) (\d{1,2}) \* \* (\*|[0-6])$/.exec(t.trim().split(/\s+/).join(` `)),[i,a]=[Number(r?.[1]),Number(r?.[2])],o=r&&i<=59&&a<=23?`${String(a).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:null;return e.type===`manual`?{...n,plan:`manual`,time:o??n.time}:!r?.[3]||!o?n:r[3]===`*`?{...n,plan:`daily`,time:o}:{...n,plan:`weekly`,time:o,day:r[3]}}function Vn({plan:e,time:t,day:n,cron:r}){if(e===`manual`)return null;if(e===`custom`)return r.trim();let[i,a]=t.split(`:`).map(Number);return`${a} ${i} * * ${e===`weekly`?n:`*`}`}function Hn(e){return e.plan===`manual`?null:e.plan===`custom`?mn(e.cron):/^\d{2}:\d{2}$/.test(e.time)?null:`Pick a time.`}function Un(e){let t=dn(e);return t===e?`Runs on this cron schedule`:on.some(e=>t.startsWith(e))?`Runs ${t}`:`Runs ${t.charAt(0).toLowerCase()}${t.slice(1)}`}function Wn({value:e,onChange:t}){let n=Vn(e),r=Hn(e),i=n=>t({...e,...n});return(0,X.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-outline-variant p-3`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-sm text-muted-foreground`,children:`When it runs`}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,X.jsx)($,{label:`Schedule`,children:(0,X.jsxs)(Me,{value:e.plan,onValueChange:e=>i({plan:e,...e===`custom`&&n?{cron:n}:{}}),children:[(0,X.jsx)(Se,{"aria-label":`Schedule`,"data-testid":`kb-digest-schedule`,children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(Le,{children:Object.keys(zn).map(e=>(0,X.jsx)(G,{value:e,children:zn[e]},e))})]})}),e.plan===`weekly`&&(0,X.jsx)($,{label:`Day`,children:(0,X.jsxs)(Me,{value:e.day,onValueChange:e=>i({day:e}),children:[(0,X.jsx)(Se,{"aria-label":`Day`,"data-testid":`kb-digest-day`,children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(Le,{children:on.map((e,t)=>(0,X.jsx)(G,{value:String(t),children:e},e))})]})}),(e.plan===`daily`||e.plan===`weekly`)&&(0,X.jsx)($,{label:`Time`,children:(0,X.jsx)(W,{type:`time`,"aria-label":`Time`,"data-testid":`kb-digest-time`,value:e.time,onChange:e=>i({time:e.target.value})})}),e.plan===`custom`&&(0,X.jsx)(`div`,{className:`sm:col-span-2`,children:(0,X.jsx)($,{label:`Cron expression`,hint:`minute hour day month weekday, e.g. 0 */6 * * *`,children:(0,X.jsx)(W,{"aria-label":`Cron expression`,"aria-invalid":r!==null,"data-testid":`kb-digest-cron`,value:e.cron,onChange:e=>i({cron:e.target.value}),className:`font-mono`,autoComplete:`off`})})})]}),(0,X.jsx)(`p`,{"aria-live":`polite`,"data-testid":`kb-digest-schedule-preview`,"data-valid":r===null,className:`text-sm ${r?`text-error`:`text-outline`}`,children:r||(n?(0,X.jsxs)(X.Fragment,{children:[Un(n),` `,(0,X.jsxs)(`span`,{className:`font-mono text-xs`,children:[`(`,n,`)`]}),`, in the ORC server's time zone.`]}):`Runs only when you start it.`)})]})}function Gn({kb:e,digest:t,onClose:n,onRemove:r}){let i=q(),a=Q(),o=ue(),s=kt(!t),[c,l]=(0,J.useState)(t?.instructions??null),[u,d]=(0,J.useState)(t?.backend??`__default__`),[f,m]=(0,J.useState)(()=>Bn(t?.schedule??{type:`cron`,cron:`0 3 * * *`}));(0,J.useEffect)(()=>{c===null&&s.data&&l(s.data.instructions)},[c,s.data]);let h=Hn(f);async function g(t){if(t.preventDefault(),h)return a.setError(h);let r=u===`__default__`?o.data?.default_backend:u,s=Vn(f);await a.run(()=>S.kb.setDigest(e.id,{instructions:c?.trim()??``,...r?{backend:r}:{},schedule:s?{type:`cron`,cron:s}:{type:`manual`}}))&&(await i(),n())}let _=c!==null;return(0,X.jsx)(On,{open:!0,onClose:n,title:t?`Digest settings`:`Set up a digest`,wide:!0,children:(0,X.jsxs)(`form`,{onSubmit:g,className:`min-w-0 space-y-4`,children:[!e.editable_by.includes(`mcp`)&&(0,X.jsx)(`p`,{className:`text-sm text-warning`,"data-testid":`kb-digest-mcp-hint`,children:`The digest writes through MCP. Allow Agents (MCP) in this knowledge base's settings first.`}),(0,X.jsx)(Wn,{value:f,onChange:m}),(0,X.jsx)(B,{value:u,onChange:d,testId:`kb-digest-backend`}),(0,X.jsx)($,{label:`Instructions`,children:_?(0,X.jsx)(He,{path:`digest.md`,value:c,onChange:l,testId:`kb-digest-instructions`,label:`Instructions`,initialMode:`edit`,height:320}):s.error?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:En(s.error)}):(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`Loading template…`})}),(0,X.jsx)(Dn,{error:a.error}),(0,X.jsxs)(K,{className:`gap-2 sm:justify-between`,children:[t&&r?(0,X.jsxs)(p,{type:`button`,variant:`ghost`,className:`text-error`,"data-testid":`kb-digest-remove`,onClick:r,children:[(0,X.jsx)(ce,{size:14}),`Remove digest`]}):(0,X.jsx)(`span`,{}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(p,{type:`submit`,"data-testid":`kb-digest-save`,disabled:!_||!c?.trim()||h!==null||a.pending,children:a.pending?`Saving…`:`Save`})]})]})]})})}function Kn({kb:e,onClose:t}){let n=r(),i=Q();async function a(){await i.run(()=>S.kb.removeDigest(e.id,e.name))!==void 0&&(n.setQueryData([Et,e.id],{digest:null}),await n.invalidateQueries({queryKey:[`kb`]}),t())}return(0,X.jsx)(On,{open:!0,onClose:t,title:`Remove digest?`,children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-outline`,children:`Documents and comments stay. The digest's instructions, schedule, job and run history are removed.`}),(0,X.jsx)(Dn,{error:i.error}),(0,X.jsxs)(K,{children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,onClick:t,children:`Cancel`}),(0,X.jsx)(p,{type:`button`,variant:`destructive`,"data-testid":`kb-digest-remove-confirm`,onClick:a,disabled:i.pending,autoFocus:!0,children:i.pending?`Removing…`:`Remove digest`})]})]})})}var qn={open:`bg-warning`,resolved:`bg-secondary`,dismissed:`bg-muted-foreground`};function Jn({status:e}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:d(`size-1.5 shrink-0 rounded-full`,qn[e])})}function Yn({kbId:e,documentId:t,onOpenDocument:n,heading:r=`h3`,compact:i=!1}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=Ct(e,{...t?{document_id:t}:{},...s?{status:s}:{}}),u=l.data?.counts,f=u?u.open+u.resolved+u.dismissed:0;function p(e){c(a&&s===e?null:e),o(!0)}return(0,X.jsx)(an,{title:`Comments`,testId:`kb-comments`,toggleTestId:`kb-comments-toggle`,heading:r,compact:i,expanded:a,onExpandedChange:o,summary:(0,X.jsxs)(X.Fragment,{children:[u&&f===0&&(0,X.jsx)(`span`,{className:`text-outline`,"data-testid":`kb-comments-none`,children:`None yet`}),u&&tn.filter(e=>u[e]>0).map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-comments-count-${e}`,"aria-pressed":a&&s===e,"aria-label":`${u[e]} ${e} ${u[e]===1?`comment`:`comments`}`,className:d(`inline-flex min-h-8 items-center gap-1.5 rounded px-1.5`,a&&s===e?`bg-surface-highest text-on-surface`:`text-outline hover:bg-surface-high`),onClick:()=>p(e),children:[(0,X.jsx)(Jn,{status:e}),(0,X.jsx)(`span`,{className:`tabular-nums text-on-surface`,children:u[e]}),e]},e)),l.error&&(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,"data-testid":`kb-comments-error`,children:l.error.message})]}),children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(Xn,{kbId:e,documentId:t}),s&&l.data?.comments.length===0&&(0,X.jsxs)(`p`,{className:`text-outline`,"data-testid":`kb-comments-empty`,children:[`No `,s,` comments.`]}),(0,X.jsx)(`ul`,{className:`divide-y divide-outline-variant`,children:l.data?.comments.map(e=>(0,X.jsx)(Zn,{comment:e,showDocument:!t,onOpenDocument:n},e.id))})]})})}function Xn({kbId:e,documentId:t}){let n=q(),r=Q(),[i,a]=(0,J.useState)(``);async function o(o){o.preventDefault(),await r.run(()=>S.kb.addComment(e,{body:i.trim(),...t?{document_id:t}:{}}))&&(a(``),await n())}return(0,X.jsxs)(`form`,{onSubmit:o,className:`space-y-2`,children:[(0,X.jsx)(U,{"aria-label":t?`Comment on this document`:`Comment on this knowledge base`,placeholder:t?`Ask for a change to this document`:`Ask for a change`,"data-testid":`kb-comment-input`,value:i,onChange:e=>a(e.target.value),rows:2,maxLength:1e4}),i.trim()&&(0,X.jsx)(p,{type:`submit`,size:`sm`,variant:`outline`,"data-testid":`kb-comment-add`,disabled:r.pending,children:`Add comment`}),r.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-error`,"data-testid":`kb-comment-add-error`,children:r.error})]})}function Zn({comment:e,showDocument:t,onOpenDocument:n}){let r=q(),i=Q(),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(``);async function l(t){if(t.preventDefault(),!a)return;let n=a;await i.run(()=>S.kb.closeComment(e.id,{status:n,reply:s.trim()}))&&(o(null),c(``),await r())}async function u(){await i.run(()=>S.kb.reopenComment(e.id))&&await r()}return(0,X.jsxs)(`li`,{"data-testid":`kb-comment`,"data-status":e.status,className:`min-w-0 space-y-1 py-2`,children:[(0,X.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 text-xs text-outline`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-on-surface`,children:[(0,X.jsx)(Jn,{status:e.status}),(0,X.jsx)(`span`,{"data-testid":`kb-comment-status`,children:e.status})]}),(0,X.jsxs)(`span`,{className:`min-w-0 wrap-break-word`,children:[e.source===e.author?e.author:`${e.author} via ${e.source}`,` ·`,` `,new Date(e.created_at).toLocaleString(),t&&e.document_id&&(0,X.jsxs)(X.Fragment,{children:[` · on `,n?(0,X.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>e.document_id&&n(e.document_id),children:e.document_title??`a deleted document`}):e.document_title??`a deleted document`]})]})]}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word`,children:e.body}),e.reply&&(0,X.jsxs)(`p`,{className:`wrap-break-word text-xs`,"data-testid":`kb-comment-reply-text`,children:[(0,X.jsxs)(`span`,{className:`text-outline`,children:[e.status===`dismissed`?`Dismissed`:`Resolved`,e.resolved_by?` by ${e.resolved_by}`:``,`:`]}),` `,e.reply]}),a?(0,X.jsxs)(`form`,{onSubmit:l,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(W,{"aria-label":a===`resolved`?`Resolution reply`:`Reason for dismissing`,placeholder:a===`resolved`?`What changed`:`Why not`,"data-testid":`kb-comment-reply`,value:s,onChange:e=>c(e.target.value),maxLength:4e3,autoFocus:!0,className:`min-w-0 flex-1 basis-48`}),(0,X.jsx)(p,{type:`submit`,size:`sm`,"data-testid":`kb-comment-close-submit`,disabled:!s.trim()||i.pending,children:a===`resolved`?`Resolve`:`Dismiss`}),(0,X.jsx)(p,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{o(null),c(``),i.setError(null)},children:`Cancel`})]}):e.status===`open`?(0,X.jsxs)(`div`,{className:`-ml-2 flex flex-wrap`,children:[(0,X.jsx)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-comment-resolve`,onClick:()=>o(`resolved`),children:`Resolve`}),(0,X.jsx)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-comment-dismiss`,onClick:()=>o(`dismissed`),children:`Dismiss`})]}):(0,X.jsx)(p,{size:`sm`,variant:`ghost`,className:`-ml-2`,"data-testid":`kb-comment-reopen`,onClick:u,disabled:i.pending,children:`Reopen`}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-error`,"data-testid":`kb-comment-error`,children:i.error})]})}var Qn=e=>`kb:${e}`,$n={pending:`Processing`,partial:`Partially parsed`,failed:`Failed`,lexical_ready:`Keyword search ready`,semantic_pending:`Embedding`,semantic_ready:`Semantic search ready`};function er(e){let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]:not(:disabled)`)],n=t.indexOf(document.activeElement),r=e.key===`ArrowDown`?(n+1)%t.length:e.key===`ArrowUp`?(n-1+t.length)%t.length:e.key===`Home`?0:e.key===`End`?t.length-1:null;r!==null&&t.length&&(e.preventDefault(),t[r]?.focus())}function tr({usage:e,testId:t}){return(0,X.jsxs)(`div`,{"data-testid":t,className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`text-sm`,children:[(0,X.jsx)(`span`,{"data-testid":`${t}-reads`,className:`font-medium`,children:e.reads}),` `,`reads · `,e.exposures,` search appearances · `,e.distinct_sessions,` sessions`]}),(0,X.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`text-outline`,children:[(0,X.jsx)(`th`,{className:`py-1 text-left font-normal`,children:`Source`}),Wt.map(e=>(0,X.jsx)(`th`,{className:`py-1 text-right font-normal`,children:e===`search_hit`?`listed`:e},e))]})}),(0,X.jsx)(`tbody`,{children:Y.map(n=>(0,X.jsxs)(`tr`,{"data-testid":`${t}-${n}`,className:`border-t border-outline-variant/50`,children:[(0,X.jsx)(`td`,{className:`py-1 uppercase`,children:n}),Wt.map(t=>(0,X.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:e.totals[n][t]},t))]},n))})]}),(0,X.jsxs)(`div`,{className:`text-xs text-outline`,children:[`Last 7 days `,e.window.days_7,` · last 30 days `,e.window.days_30]})]})}function nr({kb:e,doc:t,onHome:n,onOpen:r,onDeleted:i,onReplaceFile:a,detailsOpen:o,onDetailsOpenChange:c}){let l=q(),[u]=s(),m=u.get(`editorMode`),h=Ct(t.kb_id,{document_id:t.id}).data?.counts.open??0,[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),C=ye(`lg`),[T,E]=(0,J.useState)(null),D=(0,J.useRef)(null),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(!1),M=(0,J.useRef)(null),N=(0,J.useRef)(t.revision),P=new Map(t.links.filter(e=>e.document_id).map(e=>[qe(e.target),e.document_id])),F={slugs:[...P.keys()],select:e=>{let t=P.get(e);t&&r(t)}};async function I(e){j(!0),k(null);try{return await e(),await l(),!0}catch(e){return k(e instanceof Error?e.message:`Request failed`),!1}finally{j(!1)}}async function L(){await I(async()=>Ye(await S.kb.original(t.id),t.original_name??t.path.split(`/`).pop()??`document`))}function R(){let e=(t.path.split(`/`).pop()??`document`).replace(/\.(md|markdown)$/i,``);Ye(new Blob([t.content],{type:`text/markdown;charset=utf-8`}),`${e}.md`)}let B=t.origin===`upload`,ee=B||t.origin===`external`&&!t.editable,re=T?.backlinks.filter(e=>!t.backlinks.some(t=>t.document_id===e.document_id))??[],H=(e,t,n,r,i=!1)=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":e,disabled:A,className:d(`flex min-h-9 w-full items-center gap-2 rounded px-2 text-left text-sm outline-hidden hover:bg-surface-highest focus-visible:bg-surface-highest disabled:opacity-50`,i&&`text-error`),onClick:()=>{x(!1),r()},children:[t,n]});return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,X.jsx)(`article`,{"data-testid":`kb-document`,className:`min-w-0 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:(0,X.jsxs)(`div`,{className:`w-full min-w-0 px-4 pb-16 pt-4 sm:px-8 sm:pt-6`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 flex-1 basis-48 items-center gap-1 text-sm text-outline`,children:[(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-breadcrumb-kb`,className:`min-w-0 max-w-[60%] truncate hover:text-on-surface hover:underline`,onClick:n,children:e.name}),(0,X.jsx)(oe,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,"data-testid":`kb-document-path`,title:t.path,children:t.path})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsxs)(p,{size:`sm`,variant:o?`secondary`:`ghost`,"aria-pressed":o,"data-testid":`kb-details-toggle`,onClick:()=>c(!o),children:[(0,X.jsx)(Ae,{size:14}),`Details`,h>0&&(0,X.jsxs)(`span`,{"data-testid":`kb-details-open-comments`,title:`${h} open ${h===1?`comment`:`comments`}`,className:`inline-flex items-center gap-1 text-xs tabular-nums text-outline`,children:[(0,X.jsx)(Z,{tone:`warning`}),h]})]}),(0,X.jsxs)(pe,{open:b,onOpenChange:x,children:[(0,X.jsx)(me,{asChild:!0,children:(0,X.jsx)(p,{size:`icon`,variant:`ghost`,"aria-label":`Document actions`,"aria-haspopup":`menu`,"data-testid":`kb-doc-menu`,children:(0,X.jsx)(te,{size:16})})}),(0,X.jsxs)(de,{"data-testid":`kb-doc-actions-menu`,align:`end`,sideOffset:4,collisionPadding:8,role:`menu`,"aria-label":`Document actions`,className:`z-50 w-52 rounded-md border border-outline-variant bg-surface-high p-1 shadow-lg`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},onKeyDown:er,children:[H(`kb-doc-properties`,(0,X.jsx)(we,{size:14}),`Title and labels`,()=>{D.current={title:t.title,backlinks:t.backlinks},_(!0)}),!ee&&H(`kb-doc-download-markdown`,(0,X.jsx)(Lt,{size:14}),`Download Markdown`,R),ee&&H(`kb-doc-download`,(0,X.jsx)(w,{size:14}),`Download original`,()=>void L()),B&&H(`kb-doc-reparse`,(0,X.jsx)(Ne,{size:14}),`Parse again`,()=>void I(()=>S.kb.reparse(t.id))),B&&H(`kb-doc-replace`,(0,X.jsx)(Vt,{size:14}),`Replace file`,()=>M.current?.click()),t.origin!==`external`&&H(`kb-doc-delete`,(0,X.jsx)(ce,{size:14}),`Delete document`,()=>y(!0),!0)]})]})]})]}),(0,X.jsxs)(`header`,{className:`mb-2 mt-4 space-y-2`,children:[(0,X.jsx)(`h1`,{"data-testid":`kb-document-title`,className:`wrap-break-word text-3xl font-medium`,children:t.title}),t.description&&(0,X.jsx)(`p`,{className:`text-outline`,children:t.description}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-outline`,children:[t.labels.length>0&&(0,X.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:t.labels.map(e=>(0,X.jsx)(At,{variant:`secondary`,"data-testid":`kb-document-label`,children:e},e))}),t.parse_state!==`ok`&&(0,X.jsxs)(`span`,{className:d(`inline-flex items-center gap-1.5`,t.parse_state===`failed`&&`text-error`),children:[(0,X.jsx)(Z,{tone:t.parse_state===`failed`?`error`:t.parse_state===`partial`?`warning`:`progress`}),(0,X.jsx)(`span`,{"data-testid":`kb-parse-state`,children:$n[t.parse_state]})]}),t.folder_sync&&(0,X.jsx)(`span`,{"data-testid":`kb-folder-sync`,title:t.folder_sync===`following`?`Copied from a synced folder; scans pick up changes to the file`:`Edited in ORC; scans no longer change this copy`,children:t.folder_sync===`following`?`Follows folder file`:`Edited, no longer synced`}),t.stale&&(0,X.jsx)(`span`,{className:`text-warning`,"data-testid":`kb-document-stale`,children:`Stale: a source changed`}),(0,X.jsxs)(`span`,{children:[`Updated `,new Date(t.updated_at).toLocaleDateString(),` by `,t.updated_by]})]})]}),t.warnings.length>0&&(0,X.jsx)(`ul`,{"data-testid":`kb-document-warnings`,className:`mb-2 space-y-1 text-sm text-warning`,children:t.warnings.map(e=>(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(be,{size:14,className:`mt-0.5 shrink-0`}),e]},e))}),B&&(0,X.jsxs)(`p`,{className:`mb-2 text-sm text-outline`,children:[`Text parsed from `,t.original_name??`the upload`,` (`,f(t.size_bytes),t.parser?`, ${t.parser.id} ${t.parser.version}`:``,`). Replace the file to change it.`]}),t.folder_sync===`following`&&(m===`edit`||m===`split`)&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`kb-folder-sync-warning`,className:`mb-2 text-sm text-warning`,children:`This copy follows a file in a synced folder. Saving here stops it following that file; later changes to the file will not reach it.`}),O&&(0,X.jsx)(`p`,{role:`alert`,"data-testid":`kb-document-error`,className:`mb-2 text-sm text-error`,children:O}),T&&re.length>0&&(0,X.jsxs)(`div`,{role:`status`,"data-testid":`kb-rename-broken-links`,className:`mb-2 flex flex-wrap items-center gap-x-2 text-sm text-warning`,children:[(0,X.jsx)(be,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[re.length===1?`1 document`:`${re.length} documents`,` linked to “`,T.title,`” by its old title or path; those links now show as missing:`,` `,re.map((e,t)=>(0,X.jsxs)(`span`,{children:[t>0&&`, `,(0,X.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-on-surface`,onClick:()=>r(e.document_id),children:e.title})]},e.document_id))]}),(0,X.jsx)(p,{size:`sm`,variant:`ghost`,onClick:()=>E(null),children:`Dismiss`})]}),(0,X.jsx)(gt,{documentId:Qn(t.id),path:t.editable?t.path:`${t.path}.md`,content:t.content,wikiLinks:F,testId:`kb-document-content`,layout:`page`,pageTitle:t.title,hideFrontmatter:!0,onSave:t.editable?async(e,n)=>{try{let r=await S.kb.updateDocument(t.id,{expected_revision:n===t.content?t.revision:N.current,content:e});return N.current=r.revision,e}finally{await l()}}:void 0},Qn(t.id))]})}),o&&C&&(0,X.jsx)(ir,{doc:t,onOpen:r}),!C&&(0,X.jsx)(le,{open:o,onOpenChange:c,children:(0,X.jsxs)(V,{defaultWidth:360,resizeKey:`kb-properties`,"aria-describedby":void 0,children:[(0,X.jsx)(z,{className:`py-3`,children:(0,X.jsx)(ke,{children:`Details`})}),(0,X.jsx)(ne,{className:`p-0 sm:p-0`,children:(0,X.jsx)(ir,{doc:t,onOpen:(e,t)=>{c(!1),r(e,t)}})})]})}),(0,X.jsx)(`input`,{ref:M,type:`file`,hidden:!0,"data-testid":`kb-doc-replace-input`,onChange:e=>{let t=e.target.files?.[0];t&&a(t),e.target.value=``}}),g&&(0,X.jsx)(Rn,{doc:t,linkedFrom:t.backlinks.length,onClose:()=>_(!1),onSaved:()=>{_(!1),E(D.current)}}),(0,X.jsx)(Je,{open:v,title:`Delete document`,description:`Delete "${t.title}" and its revision history${B?` and uploaded file`:``}?`,isPending:A,onCancel:()=>y(!1),onConfirm:async()=>{y(!1),await I(()=>S.kb.removeDocument(t.id))&&i()}})]})}function rr({title:e,children:t}){return(0,X.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-medium text-outline`,children:e}),t]})}function ir({doc:e,onOpen:t}){let n=wt(e.id),r=Ot(e.id),i=`block min-h-8 w-full wrap-break-word text-left text-primary hover:underline`;return(0,X.jsxs)(`aside`,{"data-testid":`kb-document-details`,"aria-label":`Document details`,className:`w-full shrink-0 space-y-6 p-4 text-sm lg:min-h-0 lg:w-80 lg:overflow-y-auto lg:border-l lg:border-outline-variant`,children:[e.outline.length>0&&(0,X.jsx)(rr,{title:`On this page`,children:(0,X.jsx)(`nav`,{"aria-label":`Outline`,className:`space-y-0.5`,children:e.outline.map(n=>(0,X.jsx)(`button`,{type:`button`,className:`block min-h-7 w-full truncate text-left text-outline hover:text-on-surface`,style:{paddingLeft:`${(n.level-1)*.75}rem`},onClick:()=>t(e.id,n.text),children:n.text},`${n.block}-${n.text}`))})}),e.links.length>0&&(0,X.jsx)(rr,{title:`Links to (${e.links.length})`,children:e.links.map(e=>e.document_id?(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-outgoing-link`,className:i,onClick:()=>t(e.document_id),children:e.title??e.target},e.target):(0,X.jsxs)(`p`,{className:`py-1 text-outline`,"data-testid":`kb-unresolved-link`,children:[e.target,` `,(0,X.jsx)(`span`,{className:`text-xs`,children:`(no such document)`})]},e.target))}),e.backlinks.length>0&&(0,X.jsx)(rr,{title:`Linked from (${e.backlinks.length})`,children:e.backlinks.map(e=>(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-backlink`,className:i,onClick:()=>t(e.document_id),children:e.title},e.document_id))}),(0,X.jsx)(`div`,{className:`border-y border-outline-variant`,children:(0,X.jsx)(Yn,{kbId:e.kb_id,documentId:e.id,heading:`h2`,compact:!0})}),(0,X.jsxs)(`details`,{"data-testid":`kb-doc-history`,className:`group`,children:[(0,X.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 font-medium [&::-webkit-details-marker]:hidden`,children:[(0,X.jsx)(oe,{size:14,"aria-hidden":!0,className:`text-outline transition-transform group-open:rotate-90`}),`Usage and history`]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-5 pl-5`,children:[n.data?(0,X.jsx)(tr,{usage:n.data,testId:`kb-doc-usage`}):(0,X.jsx)(`p`,{className:`text-outline`,children:n.error?`Usage unavailable`:`Loading…`}),(0,X.jsx)(`ol`,{className:`space-y-2`,"data-testid":`kb-revisions`,children:r.data?.map(e=>(0,X.jsxs)(`li`,{"data-testid":`kb-revision`,children:[(0,X.jsxs)(`div`,{children:[`Revision `,e.revision,` · `,e.actor,(0,X.jsxs)(`span`,{className:`text-outline`,children:[` via `,e.source]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-outline`,children:[new Date(e.created_at).toLocaleString(),e.note?` · ${e.note}`:``]})]},e.revision))}),(0,X.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs text-outline`,children:[(0,X.jsx)(`dt`,{children:`Search`}),(0,X.jsx)(`dd`,{"data-testid":`kb-index-state`,children:$n[e.index_state]??e.index_state}),(0,X.jsx)(`dt`,{children:`Origin`}),(0,X.jsx)(`dd`,{children:e.origin}),(0,X.jsx)(`dt`,{children:`Type`}),(0,X.jsx)(`dd`,{children:e.media_type}),(0,X.jsx)(`dt`,{children:`Size`}),(0,X.jsx)(`dd`,{children:f(e.size_bytes)}),(0,X.jsx)(`dt`,{children:`Updated`}),(0,X.jsxs)(`dd`,{children:[new Date(e.updated_at).toLocaleString(),` by `,e.updated_by]}),(0,X.jsx)(`dt`,{children:`ID`}),(0,X.jsx)(`dd`,{className:`break-all font-mono`,children:e.id})]})]})]})]})}function ar(e){return`${e.added} added · ${e.updated} updated · ${e.missing} missing${e.errors.length?` · ${e.errors.length} errors: ${e.errors.slice(0,3).join(`; `)}`:``}`}var or=(e,t,n)=>`${e} ${e===1?t:n}`;function sr(){return/win/i.test(navigator.platform)?`Choose a folder or type its full path, e.g. C:\\notes`:/mac/i.test(navigator.platform)?`Choose a folder or type its full path, e.g. /Users/you/notes`:`Choose a folder or type its full path, e.g. /home/you/notes`}function cr(e){let t=e.document_count-e.edited_count,n=t?`${or(t,`synced copy is`,`synced copies are`)} removed from this knowledge base`:`No synced copies are removed`,r=e.edited_count?`; ${or(e.edited_count,`edited copy is`,`edited copies are`)} kept as documents`:``;return`Stop syncing ${e.root_path}? ${n}${r}. Files on disk are not touched.`}function lr(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e}function ur({kb:e}){let t=St(e.id),n=q(),r=Q(),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(`**/*.md`),[u,d]=(0,J.useState)(null),[f,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),y=t.data??[],b=y.filter(e=>e.last_error).length,x=y.reduce((e,t)=>e+t.document_count,0);function C(){a(!0),g(!0)}function w(){g(!1),s(``),r.setError(null),y.length===0&&a(!1)}async function T(){v(!0),r.setError(null);try{let{path:e}=await S.terminals.pickFolder(o.trim()||void 0);e&&s(e)}catch(e){r.setError(e instanceof Error?e.message:String(e))}finally{v(!1)}}async function E(t){t.preventDefault();let i=await r.run(()=>S.kb.addSource(e.id,{root_path:o.trim(),pattern:c.trim()||`**/*.md`}));i&&(s(``),g(!1),d(ar(i.scan)),await n())}return(0,X.jsxs)(an,{title:`Synced folders`,testId:`kb-folders`,toggleTestId:`kb-sources`,expanded:i,onExpandedChange:e=>{a(e),g(e&&y.length===0)},summary:t.isLoading?(0,X.jsx)(`span`,{className:`text-outline`,children:`Loading…`}):y.length===0?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-outline`,"data-testid":`kb-folders-none`,children:[(0,X.jsx)(Z,{tone:`off`}),`None`]}):(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,"data-testid":`kb-folders-summary`,children:[(0,X.jsx)(Z,{tone:b?`error`:`ok`}),y.length===1?(0,X.jsx)(`span`,{className:`min-w-0 truncate`,title:y[0]?.root_path,children:lr(y[0]?.root_path??``)}):`${y.length} folders`,(0,X.jsxs)(`span`,{className:`shrink-0 text-outline`,children:[`· `,x,` `,x===1?`document`:`documents`,b?` · ${b} failing`:``]})]}),actions:y.length===0&&!i?(0,X.jsx)(p,{size:`sm`,variant:`outline`,"data-testid":`kb-folders-add`,onClick:C,children:`Add folder`}):null,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,X.jsx)(`p`,{className:`max-w-prose text-outline`,children:`Matching files are copied in and kept in sync: ORC rescans every minute while the daemon runs, or when you choose Scan now. A copy you edit here stops following its file. ORC never writes to the folder.`}),y.length>0&&(0,X.jsx)(`ul`,{className:`divide-y divide-outline-variant`,"data-testid":`kb-sources-list`,children:y.map(e=>(0,X.jsxs)(`li`,{"data-testid":`kb-source-row`,className:`flex min-w-0 flex-wrap items-center gap-2 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:lr(e.root_path)}),(0,X.jsx)(`div`,{className:`break-all font-mono text-xs text-outline`,children:e.root_path}),(0,X.jsxs)(`div`,{className:`text-xs text-outline`,children:[e.pattern,` · `,or(e.document_count,`document`,`documents`),e.edited_count?` (${e.edited_count} edited)`:``,` ·`,` `,e.last_scan_at?(0,X.jsxs)(`span`,{title:new Date(e.last_scan_at).toLocaleString(),children:[`scanned `,gn(e.last_scan_at)]}):`not scanned yet`]}),e.last_error&&(0,X.jsx)(`div`,{className:`text-xs text-error`,children:e.last_error})]}),(0,X.jsxs)(p,{variant:`ghost`,size:`sm`,"data-testid":`kb-source-scan`,disabled:r.pending,onClick:async()=>{let t=await r.run(()=>S.kb.scanSource(e.id));t&&d(ar(t)),await n()},children:[(0,X.jsx)(Ut,{size:14}),`Scan now`]}),(0,X.jsx)(p,{variant:`ghost`,size:`sm`,title:`Stop syncing ${e.root_path}`,"data-testid":`kb-source-remove`,onClick:()=>m(e),children:`Stop syncing`})]},e.id))}),u&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`kb-source-result`,className:`text-outline`,children:u}),h?(0,X.jsxs)(`form`,{onSubmit:E,className:`min-w-0 space-y-3`,"data-testid":`kb-source-form`,children:[(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3 sm:grid-cols-[minmax(0,1fr)_12rem]`,children:[(0,X.jsx)($,{label:`Folder path`,hint:sr(),children:(0,X.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,X.jsx)(W,{"aria-label":`Folder path`,"data-testid":`kb-source-path-input`,value:o,onChange:e=>s(e.target.value),className:`min-w-0 font-mono text-sm`,autoFocus:!0}),(0,X.jsxs)(p,{type:`button`,variant:`outline`,"data-testid":`kb-source-choose-folder`,onClick:T,disabled:_,className:`shrink-0`,children:[(0,X.jsx)(We,{size:14}),_?`Choosing…`:`Choose folder`]})]})}),(0,X.jsx)($,{label:`File pattern`,hint:`e.g. *.md, **/*.md`,children:(0,X.jsx)(W,{"aria-label":`File pattern`,"data-testid":`kb-source-pattern-input`,value:c,onChange:e=>l(e.target.value),className:`font-mono text-sm`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(p,{type:`submit`,size:`sm`,variant:`outline`,"data-testid":`kb-source-add`,disabled:!o.trim()||r.pending,children:`Add folder`}),(0,X.jsx)(p,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`kb-source-cancel`,onClick:w,children:`Cancel`})]})]}):y.length>0&&(0,X.jsxs)(p,{size:`sm`,variant:`ghost`,className:`-ml-2`,"data-testid":`kb-folders-add-another`,onClick:()=>g(!0),children:[(0,X.jsx)(Re,{size:14}),`Add another folder`]}),(0,X.jsx)(Dn,{error:r.error})]}),(0,X.jsx)(Je,{open:f!==null,title:`Stop syncing folder`,description:f?cr(f):``,confirmLabel:`Stop syncing`,variant:`warning`,isPending:r.pending,onCancel:()=>m(null),onConfirm:async()=>{let e=f;m(null),e&&await r.run(()=>S.kb.removeSource(e.id)),await n()}})]})}var dr=8;function fr(e,t,n){return n===`title`?e.title.localeCompare(t.title):n===`updated`?e.updated_at-t.updated_at:e.reads-t.reads}function pr(e,t){if(e.key===t)return e.desc?`descending`:`ascending`}function mr(e){let t=new Date(e);return t.toDateString()===new Date().toDateString()?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t.toLocaleDateString([],{month:`short`,day:`numeric`,year:`numeric`})}function hr({kb:e,owner:t,listing:n,label:r,onLabel:i,onOpen:a,onNewDocument:o,onSettings:s}){let c=e.editable_by.includes(`mcp`);return(0,X.jsxs)(`div`,{"data-testid":`kb-overview`,className:`w-full min-w-0 space-y-6 p-4 sm:p-6`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,X.jsx)(`h2`,{className:`wrap-break-word text-base font-medium`,"data-testid":`kb-overview-name`,children:e.name}),e.description&&(0,X.jsx)(`p`,{className:`max-w-prose text-outline`,children:e.description}),(0,X.jsxs)(`p`,{className:`text-xs text-outline`,"data-testid":`kb-overview-meta`,children:[t,` · `,e.document_count,` `,e.document_count===1?`document`:`documents`,` ·`,` `,c?`agents can edit`:`agents read only`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(p,{size:`sm`,"data-testid":`kb-new-document`,onClick:o,children:[(0,X.jsx)(zt,{size:16}),`New document`]}),(0,X.jsxs)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-settings`,onClick:s,children:[(0,X.jsx)(Be,{size:16}),`Settings`]})]})]}),(0,X.jsx)(yr,{kbId:e.id,onOpen:a}),(0,X.jsx)(vr,{listing:n,total:e.document_count,label:r,onLabel:i,onOpen:a,onNewDocument:o}),(0,X.jsxs)(`section`,{"aria-labelledby":`kb-setup-heading`,className:`space-y-1`,children:[(0,X.jsx)(`h3`,{id:`kb-setup-heading`,className:`text-sm font-medium text-outline`,children:`Setup`}),(0,X.jsxs)(`div`,{className:`divide-y divide-outline-variant border-y border-outline-variant`,children:[(0,X.jsx)(vn,{kb:e}),(0,X.jsx)(ur,{kb:e}),(0,X.jsx)(gr,{kb:e,onSettings:s}),(0,X.jsx)(_r,{kb:e,onSettings:s}),(0,X.jsx)(Yn,{kbId:e.id,onOpenDocument:a})]})]})]})}function gr({kb:e,onSettings:t}){let n=e.editable_by.includes(`mcp`);return(0,X.jsx)(an,{title:`Who can edit`,testId:`kb-access`,summary:(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center gap-x-1.5`,children:[(0,X.jsx)(Z,{tone:n?`ok`:`off`}),n?`Agents can edit`:`Agents read only`,(0,X.jsxs)(`span`,{className:`text-outline`,children:[`·`,` `,e.editable_by.length?e.editable_by.map(e=>An[e]).join(`, `):`nobody, read only everywhere`]})]}),actions:(0,X.jsx)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-access-change`,onClick:t,children:`Change`})})}function _r({kb:e,onSettings:t}){let n=xt(),r=e.parser?n.data?.parsers.find(t=>t.id===e.parser)?.label??e.parser:`Workspace default parser`;return(0,X.jsx)(an,{title:`Uploads`,testId:`kb-uploads-setup`,summary:(0,X.jsxs)(`span`,{className:`text-outline`,"data-testid":`kb-uploads-parser`,children:[r,(0,X.jsx)(ge,{label:`Document uploads`,children:`PDF, Word, PowerPoint, Excel, HTML, Markdown and text are converted to searchable Markdown by the selected parser.`})]}),actions:(0,X.jsx)(p,{size:`sm`,variant:`ghost`,"data-testid":`kb-parser-change`,onClick:t,children:`Change`})})}function vr({listing:e,total:t,label:n,onLabel:r,onOpen:i,onNewDocument:a}){let[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)({key:`updated`,desc:!0}),m=o.trim().toLowerCase(),h=(e?.documents??[]).filter(e=>(!n||e.labels.includes(n))&&(!m||e.title.toLowerCase().includes(m)||e.path.toLowerCase().includes(m)||e.labels.some(e=>e.toLowerCase().includes(m)))).sort((e,t)=>fr(e,t,u.key)*(u.desc?-1:1));function g(e){f(t=>t.key===e?{key:e,desc:!t.desc}:{key:e,desc:e!==`title`})}function _(e,t){let n=u.desc?fe:Ke;return(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-sort-${e}`,className:`inline-flex min-h-8 items-center gap-1 hover:text-on-surface`,onClick:()=>g(e),children:[t,u.key===e&&(0,X.jsx)(n,{size:12,"aria-hidden":!0})]})}let v=[...e?.labels??[]].sort((e,t)=>t.count-e.count),y=c?v:v.filter((e,t)=>t<dr||e.label===n),b=v.length-y.length;return(0,X.jsxs)(`section`,{"aria-labelledby":`kb-documents-heading`,"data-testid":`kb-documents`,className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`h3`,{id:`kb-documents-heading`,className:`mr-auto text-sm font-medium text-outline`,children:[`Documents`,n?` labelled ${n}`:``]}),t>0&&(0,X.jsx)(W,{"aria-label":`Filter documents`,"data-testid":`kb-documents-filter`,placeholder:`Filter by title, path or label`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full sm:w-64`})]}),y.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`kb-labels`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-xs text-outline`,children:`Label`}),y.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-label-filter`,"aria-pressed":n===e.label,className:d(`min-h-8 rounded-full border px-2.5 text-xs`,n===e.label?`border-primary bg-primary/10 text-primary`:`border-outline-variant text-outline hover:text-on-surface`),onClick:()=>r(n===e.label?null:e.label),children:[e.label,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.count})]},e.label)),(b>0||c)&&v.length>dr&&(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-labels-more`,className:`min-h-8 px-2 text-xs text-primary hover:underline`,onClick:()=>l(!c),children:c?`Fewer labels`:`${b} more`})]}),t===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-dashed border-outline-variant px-6 py-10 text-center text-sm text-outline`,children:[(0,X.jsx)(E,{size:22,className:`text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`This knowledge base is empty. Drop PDF, Word, PowerPoint, Excel, HTML, Markdown or text files here, or`}),(0,X.jsx)(p,{size:`sm`,variant:`outline`,onClick:a,"data-testid":`kb-overview-new-document`,children:`add a document`})]}):(0,X.jsxs)(X.Fragment,{children:[h.length===0&&e&&(0,X.jsxs)(`p`,{className:`py-4 text-sm text-outline`,"data-testid":`kb-documents-empty`,children:[`No documents match.`,` `,(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-documents-clear`,className:`text-primary hover:underline`,onClick:()=>{s(``),r(null)},children:`Clear filters`})]}),h.length>0&&(0,X.jsxs)(`table`,{className:`w-full table-fixed text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-outline-variant text-left text-xs text-outline`,children:[(0,X.jsx)(`th`,{className:`py-1 pr-3 font-normal`,"aria-sort":pr(u,`title`),children:_(`title`,`Title`)}),(0,X.jsx)(`th`,{className:`hidden w-[30%] py-2 pr-3 font-normal md:table-cell`,children:`Labels`}),(0,X.jsx)(`th`,{className:`w-24 py-1 pr-3 font-normal sm:w-28`,"aria-sort":pr(u,`updated`),children:_(`updated`,`Updated`)}),(0,X.jsx)(`th`,{className:`hidden w-16 py-1 text-right font-normal sm:table-cell`,"aria-sort":pr(u,`reads`),children:_(`reads`,`Reads`)})]})}),(0,X.jsx)(`tbody`,{children:h.map(e=>(0,X.jsxs)(`tr`,{className:`cursor-pointer border-b border-outline-variant/60 align-top hover:bg-surface-high`,onClick:()=>i(e.id),children:[(0,X.jsxs)(`td`,{className:`min-w-0 py-2 pr-3`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-document-row`,"data-document-title":e.title,className:`flex w-full min-w-0 items-center gap-1.5 text-left font-medium hover:text-primary`,onClick:t=>{t.stopPropagation(),i(e.id)},children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.origin===`external`&&(0,X.jsx)(Ut,{size:13,className:`shrink-0 text-outline`,"aria-label":`From a synced folder`})]}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-xs text-outline`,children:e.path}),(e.parse_state===`pending`||e.parse_state===`failed`)&&(0,X.jsx)(`span`,{className:d(`text-xs`,e.parse_state===`failed`?`text-error`:`text-outline`),children:e.parse_state===`failed`?`Parsing failed`:`Parsing…`})]}),(0,X.jsx)(`td`,{className:`hidden py-2 pr-3 text-xs text-outline md:table-cell`,children:(0,X.jsx)(`span`,{className:`line-clamp-2`,children:e.labels.join(`, `)})}),(0,X.jsx)(`td`,{className:`py-2 pr-3 text-xs text-outline tabular-nums`,children:mr(e.updated_at)}),(0,X.jsx)(`td`,{className:`hidden py-2 text-right text-xs text-outline tabular-nums sm:table-cell`,children:e.reads||``})]},e.id))})]}),(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:`Drop files anywhere on this page to upload.`})]})]})}function yr({kbId:e,onOpen:t}){let n=bt(e).data;return!n||!(n.stale.length||n.failed.length||n.unresolved_links.length)?null:(0,X.jsxs)(`section`,{"data-testid":`kb-maintenance`,className:`space-y-1 text-sm`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-outline`,children:`Needs attention`}),(0,X.jsxs)(`ul`,{className:`space-y-1`,children:[n.failed.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`text-left text-error hover:underline`,onClick:()=>t(e.id),children:[`Parsing failed: `,e.title]})},e.id)),n.stale.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`text-left text-warning hover:underline`,onClick:()=>t(e.id),children:[`Stale summary: `,e.title]})},e.id)),n.unresolved_links.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`text-left text-outline hover:underline`,onClick:()=>t(e.document_id),children:[`[[`,e.target,`]] in `,e.title,` has no target`]})},`${e.document_id}-${e.target}`))]})]})}function br(){let e=q(),[t,n]=(0,J.useState)([]),r=(0,J.useRef)(1),i=(e,t)=>n(n=>n.map(n=>n.id===e?{...n,...t}:n));async function a(t){i(t.id,{status:`uploading`,progress:0,error:void 0});try{let n=await S.kb.upload(t.kbId,{file:t.file,...t.replace},e=>i(t.id,{progress:e}));i(t.id,{status:`done`,progress:1,document:n}),await e()}catch(e){i(t.id,{status:`failed`,error:e instanceof Error?e.message:`Upload failed`})}}function o(e,t,i={}){let o=t.map(t=>({id:r.current++,kbId:e,file:t,...i.replace?{replace:i.replace}:{},progress:0,status:`uploading`}));n(e=>[...e,...o]);for(let e of o)a(e)}return{uploads:t,add:o,retry:e=>{let n=t.find(t=>t.id===e);n&&a(n)},clearFinished:()=>n(e=>e.filter(e=>e.status===`uploading`))}}var xr={new:``,installed:`Already in ORC`,duplicate:`Near copy already in ORC`,conflict:`Name taken in ORC (different content), select to replace`,invalid:`Invalid`},Sr={new:``,identical:`Already in the folder`,near:`Near copy in the folder, select to overwrite`,conflict:`Different memory with this name in the folder, select to overwrite`,duplicate:`Already in the folder under another name`},Cr=`__folder__`;function wr({mode:e,initialProjectId:t,projects:n,onClose:o}){let[s,c]=(0,J.useState)(t??``),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(``),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)({}),v=r(),y=i({queryKey:[`memory-transfer`,`sources`,s],queryFn:()=>S.memories.nativeSources(s),enabled:!!s}),b=y.data?.sources??[],x=l??b.find(e=>e.project_match)?.dir??``,C=x===Cr?m:x,w=i({queryKey:[`memory-transfer`,e,s,C],queryFn:async()=>{if(e===`import`){let e=await S.memories.previewImport(s,C);return{dir:e.dir,rows:e.memories.map(e=>({...e,selectable:e.status===`new`||e.can_replace}))}}let t=await S.memories.previewExport(s,C);return{dir:t.dir,index:t.index,rows:t.memories.map(e=>({...e,selectable:e.status===`new`||e.can_overwrite,...e.status===`duplicate`?{error:e.reason}:{}}))}},enabled:!!(s&&C)}),T=a({mutationFn:async t=>{if(e===`import`){let e=await S.memories.importNative(s,C,t.map(e=>({name:e.name,...e.status===`new`?{}:{replace:!0}})));return{done:[...e.imported.map(e=>`Imported ${e}`),...e.replaced.map(e=>`Replaced ${e}`)],skipped:e.skipped}}let n=await S.memories.exportNative(s,C,t.map(e=>e.name),t.filter(e=>e.status!==`new`).map(e=>e.name));return{done:n.exported.map(e=>`${e.replaced?`Replaced`:`Wrote`} ${e.file}`),skipped:n.skipped}},onSuccess:async t=>{_({}),await v.invalidateQueries({queryKey:[`memory-transfer`]}),e===`import`&&await v.invalidateQueries({queryKey:[`memories`]}),t.skipped.length||o()}}),E=T.isPending,D=s&&C?w.data?.rows??[]:[],O=D.filter(e=>e.selectable&&g[e.name]),k=D.filter(e=>e.status===`new`),A=e===`import`?xr:Sr,j=e===`import`?`Import`:`Export`,M=`memory-${e}`,N=y.error||w.error||T.error;return(0,X.jsx)(Ie,{open:!0,onOpenChange:e=>!e&&!E&&o(),children:(0,X.jsxs)(Oe,{closeDisabled:E,"data-testid":`${M}-dialog`,className:`flex min-w-0 w-[min(800px,calc(100vw-2rem))] max-w-none max-h-[calc(var(--app-height,100dvh)-2rem)] flex-col gap-0 overflow-hidden p-0`,children:[(0,X.jsxs)(ze,{className:`shrink-0 flex-row items-center gap-1 border-b px-4 py-3 pr-12 sm:px-6`,children:[(0,X.jsx)(Te,{children:e===`import`?`Import native memories`:`Export memories`}),(0,X.jsx)(ge,{label:`memory ${e}`,children:e===`import`?`Reads Claude Code memory files (~/.claude/projects/<project>/memory/*.md), Codex notes (~/.codex/memories/extensions/ad_hoc/notes) or any folder of memory files into this project. Near copies are flagged so a small edit does not create a duplicate.`:`Writes this project's memories as memory files: Claude Code folders also get a MEMORY.md index, and Codex merges its notes into its memory. Existing files are only replaced when you select them, and a backup is kept.`})]}),(0,X.jsxs)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-4 py-4 sm:px-6`,"data-testid":`${M}-body`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`${M}-project`,className:`text-sm font-medium`,children:e===`import`?`Into project`:`From project`}),(0,X.jsxs)(`select`,{id:`${M}-project`,"data-testid":`${M}-project`,className:`block h-11 w-full rounded-md border border-input bg-background px-3 text-sm sm:h-8`,value:s,disabled:E,onChange:e=>{c(e.target.value),u(null),_({}),T.reset()},children:[(0,X.jsx)(`option`,{value:``,children:`Choose a project`}),n.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{htmlFor:`${M}-source`,className:`text-sm font-medium`,children:e===`import`?`Source`:`Destination`}),(0,X.jsxs)(`select`,{id:`${M}-source`,"data-testid":`${M}-source`,className:`block h-11 w-full rounded-md border border-input bg-background px-3 text-sm sm:h-8`,value:x,disabled:E||!s||y.isLoading,onChange:e=>{u(e.target.value),_({}),T.reset()},children:[(0,X.jsx)(`option`,{value:``,children:`Choose a folder`}),b.map(e=>(0,X.jsxs)(`option`,{value:e.dir,children:[e.label,` · `,e.count,` `,e.count===1?`memory`:`memories`,e.project_match?` · this project`:``]},e.dir)),(0,X.jsx)(`option`,{value:Cr,children:`Custom folder`})]}),x===Cr&&(0,X.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault(),_({}),h(d.trim())},children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Pt,{id:`${M}-folder`,label:`Folder`,value:d,disabled:E,onChange:f})}),(0,X.jsx)(p,{type:`submit`,variant:`outline`,"data-testid":`${M}-folder-apply`,disabled:E||!d.trim(),children:e===`import`?`Scan`:`Compare`})]})]}),w.isLoading&&s&&C&&(0,X.jsx)(`p`,{role:`status`,children:`Reading the folder…`}),w.data&&s&&C&&(0,X.jsxs)(`section`,{"data-testid":`${M}-plan`,className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-xs text-outline wrap-break-word`,children:[w.data.dir,w.data.index?` · MEMORY.md index is updated`:``]}),(0,X.jsxs)(p,{size:`sm`,variant:`outline`,"data-testid":`${M}-select-new`,disabled:E||!k.length,onClick:()=>_({...g,...Object.fromEntries(k.map(e=>[e.name,!0]))}),children:[`Select all new (`,k.length,`)`]})]}),!D.length&&(0,X.jsx)(`p`,{role:`status`,children:e===`import`?`No memory files in this folder.`:`This project has no memories.`}),(0,X.jsx)(`div`,{className:`divide-y divide-border`,children:D.map(e=>(0,X.jsxs)(`label`,{className:`flex min-h-11 min-w-0 items-start gap-3 py-2 text-sm`,"data-testid":`${M}-item`,"data-memory-name":e.name,"data-status":e.status,children:[(0,X.jsx)(`input`,{type:`checkbox`,"aria-label":`${j} ${e.name}`,className:`mt-1 shrink-0`,"data-testid":`${M}-select`,checked:e.selectable&&!!g[e.name],disabled:E||!e.selectable,onChange:t=>_({...g,[e.name]:t.target.checked})}),(0,X.jsxs)(`span`,{className:`min-w-0 wrap-break-word`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),A[e.status]&&(0,X.jsx)(`span`,{className:`ml-2 text-xs text-outline`,children:A[e.status]}),(0,X.jsx)(`span`,{className:`mt-0.5 line-clamp-2 text-xs leading-4 text-outline`,children:e.description}),(0,X.jsx)(Ft,{match:e.match}),e.error&&(0,X.jsx)(`span`,{className:`block text-xs text-destructive`,children:e.error})]})]},e.name))})]}),T.data?.skipped.map(e=>(0,X.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Skipped `,e.name,`: `,e.reason]},e.name)),N&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:N.message})]}),(0,X.jsxs)(K,{className:`shrink-0 border-t px-4 py-3 sm:px-6`,children:[(0,X.jsx)(p,{variant:`ghost`,disabled:E,onClick:o,children:`Close`}),(0,X.jsx)(p,{"data-testid":`${M}-submit`,disabled:E||!O.length,onClick:()=>T.mutate(O),children:E?`${j===`Import`?`Importing`:`Exporting`}…`:`${j} selected${O.length?` (${O.length})`:``}`})]})]})})}var Tr=`all`,Er=200,Dr=[{value:`reads`,label:`Most read`},{value:`recent`,label:`Recent`},{value:`priority`,label:`Priority`}];function Or(e){return new Date(e*1e3).toLocaleString()}function kr({projectId:e}){let t=o(),n=u(),{memoryProject:r,memoryName:i}=c(),[a,s]=Qe(`project`,e),[l,d]=Qe(`memoryQuery`,``),[f,m]=Qe(`memorySort`,`reads`,Dr.map(e=>e.value)),[h,g]=(0,J.useState)(l);(0,J.useEffect)(()=>g(l),[l]);let _=(0,J.useRef)(d);_.current=d,(0,J.useEffect)(()=>{if(h===l)return;let e=window.setTimeout(()=>_.current(h,{replace:!0}),250);return()=>window.clearTimeout(e)},[h,l]);let v=ye(`lg`),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),{data:D}=ie({status:`active`}),O=ut(),[k,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)(null),N=a===`unassigned`,P=a===Tr,F=ft({project_id:P?void 0:a,q:l||void 0,sort:f,limit:Er},{enabled:!N}),I=F.data?.memories??[],L=e=>D?.find(t=>t.id===e)?.name??e,R=P||N?null:a,z=I.find(e=>e.project_id===r&&e.name===i),B=e=>t(`${Ve(e.project_id,e.name)}${n.search}`),ee=()=>t(`${xe}${n.search}`),te=P||!N&&r===a;return(0,J.useEffect)(()=>{r&&i&&!te&&t(`${xe}${n.search}`,{replace:!0})},[r,i,te,t,n.search]),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Ze,{title:`Memories`,help:`Short project facts such as ports, conventions and decisions that agents can read in later sessions. Longer procedures belong in a skill.`,meta:F.data?`${F.data.total} ${F.data.total===1?`memory`:`memories`}`:void 0,action:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(pe,{open:k,onOpenChange:A,children:[(0,X.jsx)(me,{asChild:!0,children:(0,X.jsxs)(p,{"data-testid":`memory-transfer-menu`,"aria-label":`Import or export memories`,size:`sm`,variant:`ghost`,children:[(0,X.jsx)(w,{size:14}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Import / export`}),(0,X.jsx)(C,{size:12,className:`hidden sm:block`})]})}),(0,X.jsxs)(de,{"aria-label":`Import or export memories`,align:`end`,className:`w-64 space-y-1 p-1`,children:[(0,X.jsxs)(p,{"data-testid":`memory-import-button`,size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{A(!1),M(`import`)},children:[(0,X.jsx)(w,{size:12,className:`mr-1`}),` Import native memories`]}),(0,X.jsxs)(p,{"data-testid":`memory-export-button`,size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{A(!1),M(`export`)},children:[(0,X.jsx)(E,{size:12,className:`mr-1`}),` Export to native memory`]})]})]}),(0,X.jsxs)(p,{"data-testid":`new-memory-button`,size:`sm`,onClick:()=>b(`new`),className:`font-label text-sm`,children:[(0,X.jsx)(Re,{size:12,className:`mr-1`}),` New memory`]})]})}),(0,X.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(T,{activeCount:Number(f!==`reads`)+Number(a!==Tr),children:[(0,X.jsxs)(Me,{value:a,onValueChange:e=>s(e),children:[(0,X.jsx)(Se,{"aria-label":`Project`,"data-testid":`memory-project-filter`,className:`h-9 w-48 bg-background text-on-surface font-body text-sm`,children:(0,X.jsx)(Pe,{})}),(0,X.jsxs)(Le,{className:`bg-surface border-outline-variant`,children:[(0,X.jsx)(G,{value:Tr,className:`font-body text-sm`,children:`All projects`}),N&&(0,X.jsx)(G,{value:`unassigned`,className:`font-body text-sm`,children:`Unassigned`}),D?.map(e=>(0,X.jsx)(G,{value:e.id,"data-testid":`memory-project-option-${e.id}`,className:`font-body text-sm`,children:e.name},e.id))]})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:Dr.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(e.value),"data-testid":`memory-sort-${e.value}`,"aria-pressed":f===e.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${f===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,X.jsxs)(`div`,{className:`relative order-first min-w-0 flex-1 lg:max-w-md`,children:[(0,X.jsx)(Fe,{size:12,className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(W,{"aria-label":`Search memories`,"data-testid":`memory-search-input`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>e.key===`Enter`&&d(e.currentTarget.value),placeholder:`Search memories...`,className:`pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground`})]})]}),N?(0,X.jsx)($e,{message:`Memories belong to a project. Choose a project to see its memories.`}):F.error?(0,X.jsx)(Xe,{message:F.error.message,onRetry:()=>void F.refetch()}):F.isLoading?(0,X.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,X.jsx)(se,{className:`h-10 w-full bg-surface-highest`},t))}):I.length===0?(0,X.jsx)($e,{message:l?`No memories match your search`:`No memories yet`}):v?(0,X.jsx)(`div`,{className:`overflow-hidden`,children:(0,X.jsxs)(at,{children:[(0,X.jsx)(et,{children:(0,X.jsxs)(rt,{className:`border-b border-outline-variant hover:bg-transparent`,children:[(0,X.jsx)(tt,{className:`font-label text-sm text-muted-foreground`,children:`Name`}),(0,X.jsx)(tt,{className:`font-label text-sm text-muted-foreground`,children:`Description`}),P&&(0,X.jsx)(tt,{className:`font-label text-sm text-muted-foreground`,children:`Project`}),(0,X.jsx)(tt,{className:`font-label text-sm text-muted-foreground w-20`,children:`Priority`}),(0,X.jsx)(tt,{className:`font-label text-sm text-muted-foreground w-16`,children:`Reads`}),(0,X.jsx)(tt,{className:`font-label text-sm text-muted-foreground w-44`,children:`Updated`})]})}),(0,X.jsx)(nt,{children:I.map(e=>(0,X.jsxs)(rt,{"data-testid":`memory-row`,"data-memory-name":e.name,"data-memory-project":e.project_id,className:`border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer`,onClick:()=>B(e),children:[(0,X.jsx)(it,{className:`font-body text-sm font-medium text-on-surface`,children:(0,X.jsx)(`button`,{type:`button`,className:`min-h-11 text-left hover:text-primary`,onClick:t=>{t.stopPropagation(),B(e)},children:e.name})}),(0,X.jsx)(it,{className:`font-body text-sm text-muted-foreground max-w-md truncate`,children:e.description}),P&&(0,X.jsx)(it,{className:`font-body text-sm text-muted-foreground`,children:L(e.project_id)}),(0,X.jsx)(it,{children:(0,X.jsx)(jr,{priority:e.priority})}),(0,X.jsx)(it,{"data-testid":`memory-read-count`,className:`font-label text-sm text-muted-foreground`,title:Ar(e),children:e.read_count}),(0,X.jsx)(it,{className:`font-label text-sm text-muted-foreground`,children:Or(e.updated_at)})]},e.key))})]})}):(0,X.jsx)(`div`,{className:`divide-y divide-outline-variant`,children:I.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`memory-row`,"data-memory-name":e.name,"data-memory-project":e.project_id,onClick:()=>B(e),className:`flex w-full min-w-0 items-start justify-between gap-3 px-2 py-3 text-left hover:bg-surface`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block wrap-break-word text-sm font-medium`,children:e.name}),(0,X.jsx)(`span`,{className:`mt-1 line-clamp-2 wrap-break-word text-sm text-muted-foreground`,children:e.description}),(0,X.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[P&&(0,X.jsx)(`span`,{children:L(e.project_id)}),(0,X.jsxs)(`span`,{"data-testid":`memory-read-count`,title:Ar(e),children:[e.read_count,` reads`]})]})]}),(0,X.jsx)(jr,{priority:e.priority})]},e.key))}),r&&i&&te&&(0,X.jsx)(Mr,{projectId:r,name:i,projectName:L(r),listItem:z,onClose:ee,onEdit:b,onDelete:S},`${r}/${i}`),y&&(0,X.jsx)(Lr,{memory:y===`new`?null:y,defaultProjectId:P||N?``:a,onClose:()=>b(null),onCreated:e=>B(e)}),j&&(0,X.jsx)(wr,{mode:j,initialProjectId:R,projects:D??[],onClose:()=>M(null)}),x&&(0,X.jsx)(Je,{open:!0,title:`Delete memory`,description:`Delete "${x.name}"? It can be restored from its history.`,confirmLabel:`Delete`,variant:`destructive`,isPending:O.isPending,onConfirm:()=>O.mutate({projectId:x.project_id,name:x.name},{onSuccess:()=>{S(null),ee()}}),onCancel:()=>S(null)}),O.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive mt-2`,children:O.error.message})]})}function Ar(e){let{mcp:t,cli:n,api:r,ui:i}=e.reads_by_source;return`mcp ${t} · cli ${n} · api ${r} · ui ${i}${e.last_read_at?` · last read ${Or(e.last_read_at)}`:``}`}function jr({priority:e}){return e===null?(0,X.jsx)(`span`,{"data-testid":`memory-priority`,className:`font-label text-xs text-outline`,children:`Unscored`}):(0,X.jsxs)(`span`,{"data-testid":`memory-priority`,className:`font-label text-xs text-primary`,children:[`P`,e]})}function Mr({projectId:e,name:t,projectName:n,listItem:r,onClose:i,onEdit:a,onDelete:o}){let{data:s,isLoading:c,error:l,refetch:u}=lt(e,t);return(0,X.jsx)(le,{open:!0,onOpenChange:e=>!e&&i(),children:(0,X.jsxs)(V,{"data-testid":`memory-detail`,defaultWidth:860,resizeKey:`memories`,children:[(0,X.jsxs)(z,{children:[(0,X.jsx)(ke,{children:t}),s&&(0,X.jsx)(`p`,{"data-testid":`memory-detail-description`,className:`font-body text-sm text-muted-foreground mt-1`,children:s.description})]}),(0,X.jsx)(ne,{children:l?(0,X.jsx)(Xe,{message:l.message,onRetry:()=>void u()}):c||!s?(0,X.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,]].map((e,t)=>(0,X.jsx)(se,{className:`h-8 w-full bg-surface-highest`},t))}):(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(p,{"data-testid":`memory-edit`,size:`sm`,variant:`outline`,onClick:()=>a(s),children:[(0,X.jsx)(we,{size:12,className:`mr-1`}),` Edit`]}),(0,X.jsxs)(p,{"data-testid":`memory-delete`,size:`sm`,variant:`outline`,onClick:()=>o(s),children:[(0,X.jsx)(ce,{size:12,className:`mr-1`}),` Delete`]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,X.jsx)(Ge,{label:`Project`,children:n}),(0,X.jsx)(Ge,{label:`Priority`,children:(0,X.jsx)(jr,{priority:s.priority})}),(0,X.jsx)(Ge,{label:`Reads`,children:r?(0,X.jsx)(`span`,{title:Ar(r),children:r.read_count}):`—`}),(0,X.jsx)(Ge,{label:`Author`,children:(0,X.jsx)(`span`,{"data-testid":`memory-detail-author`,children:s.author})}),(0,X.jsx)(Ge,{label:`Session`,children:(0,X.jsx)(`code`,{className:`font-mono text-xs break-all`,children:s.session_id??`—`})}),(0,X.jsx)(Ge,{label:`Updated`,children:Or(s.updated_at)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-label text-sm text-muted-foreground mb-2`,children:`Content`}),(0,X.jsx)(`div`,{"data-testid":`memory-detail-content`,className:`wrap-break-word font-body text-sm text-on-surface`,children:(0,X.jsx)(re,{readable:!0,children:s.content})})]}),(0,X.jsx)(Pr,{projectId:e,name:t,onDeleted:i})]})})]})})}function Nr({label:e,snapshot:t}){return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-xs text-outline mt-2`,children:e}),t?(0,X.jsxs)(`div`,{className:`text-xs space-y-1`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`text-outline`,children:`Priority:`}),` `,t.priority===null?`unscored`:t.priority]}),(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`text-outline`,children:`Description:`}),` `,t.description]}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:t.content})]}):(0,X.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`(none)`})]})}function Pr({projectId:e,name:t,onDeleted:n}){let r=st(e,t),i=pt(),[a,o]=(0,J.useState)(``),s=r.data?.changes??[],c=s[0];return(0,X.jsxs)(`section`,{"data-testid":`memory-history-panel`,className:`space-y-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`History`}),r.error&&(0,X.jsx)(`p`,{role:`alert`,children:r.error.message}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i.error.message}),s.length>1&&(0,X.jsx)(W,{"data-testid":`memory-revert-reason`,"aria-label":`Reason for reverting`,value:a,onChange:e=>o(e.target.value),placeholder:`Reason for reverting...`}),s.map(r=>(0,X.jsxs)(`details`,{"data-testid":`memory-history-change`,className:`border-b border-outline-variant p-3`,children:[(0,X.jsxs)(`summary`,{className:`text-xs cursor-pointer`,children:[r.action.replace(`memory.`,``),` · `,Or(r.created_at),` ·`,` `,r.author,r.session_id?` · ${r.session_id}`:``,r.reason?` · ${r.reason}`:``]}),(0,X.jsx)(Nr,{label:`Before`,snapshot:r.previous}),(0,X.jsx)(Nr,{label:`After`,snapshot:r.current}),c&&r.previous&&(0,X.jsx)(p,{"data-testid":`memory-revert-change`,size:`sm`,variant:`outline`,className:`mt-2`,disabled:!a.trim()||i.isPending,onClick:()=>i.mutate({name:t,project_id:e,change_id:r.id,expected_change_id:c.id,reason:a.trim()},{onSuccess:({memory:e})=>{o(``),e||n()}}),children:`Restore state before this change`})]},r.id))]})}function Fr(e){return[...e].length}function Ir({value:e,max:t,testId:n}){let r=Fr(e);return(0,X.jsx)(`span`,{"data-testid":n,className:`text-xs ${t!==void 0&&r>t?`text-destructive`:`text-muted-foreground`}`,children:t===void 0?r:`${r}/${t}`})}function Lr({memory:e,defaultProjectId:t,onClose:n,onCreated:r}){let{data:i}=ie({status:`active`}),[a,o]=(0,J.useState)(e?.project_id??t),[s,c]=(0,J.useState)(e?.name??``),[l,u]=(0,J.useState)(e?.description??``),[d,f]=(0,J.useState)(e?.content??``),[m,h]=(0,J.useState)(e?.priority===null||e?.priority===void 0?``:String(e.priority)),[g,_]=(0,J.useState)(``),v=mt(),y=ct(),b=(0,J.useRef)(JSON.stringify([a,s,l,d,m,g])),x=dt().data?.content_max,S=e?y:v,C=ve([{id:`details`,label:`Details`},{id:`content`,label:`Content`}]),w=m.trim()===``?null:Number(m),T=w===null||Number.isInteger(w)&&w>=0&&w<=100,E=!!a&&!!s.trim()&&!!l.trim()&&Fr(l)<=300&&!!d.trim()&&(x===void 0||Fr(d)<=x)&&T;function D(t){if(S.isPending)return;if(!E){!a||!s.trim()||!l.trim()||Fr(l)>300||!T?C.invalid(`details`,a?T?`Enter a name and description within the displayed limits.`:`Priority must be a whole number from 0 to 100.`:`Choose a project.`):C.invalid(`content`,`Enter memory content within the displayed limit.`);return}if(!e){v.mutate({project_id:a,name:s.trim(),description:l.trim(),content:d.trim(),priority:w},{onSuccess:e=>{t(),r(e)}});return}let n={...l.trim()!==e.description&&{description:l.trim()},...d.trim()!==e.content&&{content:d.trim()},...w!==e.priority&&{priority:w}};Object.keys(n).length===0?t():y.mutate({name:e.name,project_id:e.project_id,...n,...g.trim()&&{reason:g.trim()}},{onSuccess:t})}return(0,X.jsx)(je,{open:!0,onClose:n,busy:S.isPending,dirty:JSON.stringify([a,s,l,d,m,g])!==b.current,testId:`memory-form-dialog`,className:C.step===`content`?`h-[min(85dvh,calc(var(--app-height,100dvh)-2rem))]`:void 0,children:(t,n)=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ze,{children:(0,X.jsx)(Te,{className:`font-headline text-base text-on-surface`,children:e?`Edit ${e.name}`:`New memory`})}),(0,X.jsx)(`form`,{noValidate:!0,ref:C.form,onSubmit:e=>C.submit(e,()=>D(n)),className:C.step===`content`?`min-h-0 flex-1`:`min-h-0`,children:(0,X.jsxs)(he,{steps:C,children:[(0,X.jsxs)(`div`,{className:C.step===`content`?`work-form-body flex min-h-0 flex-1 flex-col gap-4`:`work-form-body space-y-4`,children:[(0,X.jsxs)(_e,{steps:C,id:`details`,children:[!e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(Ee,{className:`font-label text-sm text-muted-foreground`,children:`Project *`}),(0,X.jsxs)(Me,{value:a,onValueChange:o,children:[(0,X.jsx)(Se,{"aria-label":`Memory project`,"data-testid":`memory-project-select`,className:`bg-background text-on-surface font-body text-sm h-9`,children:(0,X.jsx)(Pe,{placeholder:`Choose a project`})}),(0,X.jsx)(Le,{className:`bg-surface border-outline-variant`,children:i?.map(e=>(0,X.jsx)(G,{value:e.id,className:`font-body text-sm`,children:e.name},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(Ee,{className:`font-label text-sm text-muted-foreground`,children:`Name *`}),(0,X.jsx)(W,{"aria-label":`Name`,"data-testid":`memory-name-input`,value:s,onChange:e=>c(e.target.value),placeholder:`api-port`,maxLength:64,required:!0,className:`bg-background text-on-surface font-body text-sm`,autoFocus:!0}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase words joined by hyphens, unique in the project.`})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(Ee,{className:`font-label text-sm text-muted-foreground`,children:`Description *`}),(0,X.jsx)(Ir,{value:l,max:300,testId:`memory-description-count`})]}),(0,X.jsx)(U,{"aria-label":`Description`,"data-testid":`memory-description-input`,value:l,onChange:e=>u(e.target.value),placeholder:`One line agents see in lists and context`,className:`bg-background text-on-surface font-body text-sm resize-none`,rows:2,required:!0})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(Ee,{className:`font-label text-sm text-muted-foreground`,children:[`Priority (0-`,100,`, empty = unscored)`]}),(0,X.jsx)(W,{"aria-label":`Priority`,"data-testid":`memory-priority-input`,type:`number`,min:0,max:100,step:1,value:m,onChange:e=>h(e.target.value),className:`w-32 bg-background text-on-surface font-body text-sm`}),!T&&(0,X.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Priority must be a whole number from 0 to `,100,`.`]})]}),e&&(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(Ee,{className:`font-label text-sm text-muted-foreground`,children:`Reason`}),(0,X.jsx)(W,{"aria-label":`Reason`,"data-testid":`memory-reason-input`,value:g,onChange:e=>_(e.target.value),placeholder:`Why this changed (optional)`,className:`bg-background text-on-surface font-body text-sm`})]})]}),(0,X.jsx)(_e,{steps:C,id:`content`,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(Ce,{label:`Content`,"aria-label":`Content`,"data-testid":`memory-content-input`,value:d,onChange:f,placeholder:`The fact itself. Longer guidance belongs in a skill.`,accessory:(0,X.jsx)(Ir,{value:d,max:x,testId:`memory-content-count`}),fill:!0,disabled:S.isPending,required:!0})}),C.error&&(0,X.jsx)(`p`,{role:`alert`,"data-testid":`memory-step-error`,className:`text-sm text-destructive`,children:C.error}),S.error&&(0,X.jsx)(`p`,{role:`alert`,"data-testid":`memory-form-error`,className:`text-sm text-destructive md:col-span-2`,children:S.error.message})]}),(0,X.jsxs)(K,{className:`work-form-footer`,children:[(0,X.jsx)(p,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,disabled:S.isPending,className:`font-label text-sm text-muted-foreground`,children:`Cancel`}),(0,X.jsx)(H,{steps:C,busy:S.isPending,children:(0,X.jsx)(p,{"data-testid":`memory-submit`,type:`submit`,size:`sm`,disabled:S.isPending,className:`font-label text-sm`,children:S.isPending?`Saving...`:e?`Save`:`Create`})})]})]})})]})})}function Rr({projectId:e}){let t=ot(e),{pathname:n}=u();return n.startsWith(`/knowledge/memories`)?(0,X.jsx)(`div`,{"data-testid":`knowledge-base-view`,children:(0,X.jsx)(kr,{projectId:e,embedded:!0})}):(0,X.jsx)(`div`,{"data-testid":`knowledge-base-view`,className:`flex min-h-0 min-w-0 flex-1`,children:(0,X.jsx)(Vr,{projectId:t===`all`||t===`unassigned`?void 0:t,globalOnly:t===`unassigned`},t)})}function zr(e){return e.replace(/```[\w-]*/g,` `).replace(/<\/?[a-z][^>]*>/gi,` `).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/(^|\s)#{1,6}\s+/g,`$1`).replace(/(^|\n)\s*(?:>\s*)+/g,`$1`).replace(/(^|\n)\s*(?:[-*+]|\d+[.)])\s+/g,`$1`).replace(/\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?/g,` `).replace(/(^|\s)(?:\*{3,}|_{3,})(?=\s|$)/g,`$1`).replace(/`/g,``).replace(/(^|[\s(«])[*_~]+(?=\S)/g,`$1`).replace(/(\S)[*_~]+(?=$|[\s).,;:!?»])/g,`$1`).replace(/\s*\|[\s|]*/g,` · `).replace(/\s+/g,` `).replace(/^ · | · $/g,``).trim()}function Br({text:e}){let t=zr(e).split(/«([^»]*)»/g);return(0,X.jsx)(X.Fragment,{children:t.map((e,t)=>t%2?(0,X.jsx)(`mark`,{className:`rounded-xs bg-primary/20 px-0.5 text-on-surface`,children:e},t):(0,X.jsx)(J.Fragment,{children:e},t))})}function Vr({projectId:e,globalOnly:t=!1}){let[n,r]=s(),{pathname:i}=u(),a=n.get(`kb`),o=n.get(`document`),c=n.get(`label`)??``,l=n.get(`q`)??``,f=n.get(`searchAll`)===`1`,[x,S]=(0,J.useState)(l);(0,J.useEffect)(()=>S(l),[l]);let[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(!1),O=ye(`lg`),[k,A]=(0,J.useState)(()=>typeof window<`u`&&window.innerWidth>=1600),[j,M]=(0,J.useState)(!1),[N,P]=(0,J.useState)(null),[F,I]=(0,J.useState)();function L(){w(null),I(void 0)}let R=ie(),z=Mt(e,t),B=z.data?.find(e=>e.id===a)??null,te=jt(B?.id??null),V=yt(z.data===void 0?null:o),ne=z.data!==void 0&&(B!==null||z.data.length===0),re=Tt(l&&ne?{query:l,...B&&!f?{kb_ids:[B.id]}:{},scope:e?`default`:t?`global`:`all`,limit:20}:null,e),H=br();function U(e,t=!1){window.location.pathname===i&&r(()=>{let t=new URLSearchParams(window.location.search);for(let[n,r]of Object.entries(e))r?t.set(n,r):t.delete(n);return t},{replace:t})}let ae=()=>!o||ht(Qn(o));function oe(e){E(!1),(e!==a||o||l)&&ae()&&(e!==a&&H.clearFinished(),U({kb:e,document:null,label:null,q:null}))}function ce(e,t){E(!1),(e===o||ae())&&(U({document:e,q:null}),P(t??null))}function le(e,t){U({document:e}),P(t??null)}function ue(){E(!1);let e=x.trim();if(!e)return U({q:null});ae()&&U({q:e,document:null})}(0,J.useEffect)(()=>{O&&E(!1)},[O]),(0,J.useEffect)(()=>{z.data&&(o&&V.data&&!z.data.some(e=>e.id===V.data.kb_id)?U({kb:z.data[0]?.id??null,document:null,label:null,q:null},!0):a&&!z.data.some(e=>e.id===a)&&(!o||V.error)?U({kb:null,document:null},!0):!a&&z.data[0]&&U({kb:z.data[0].id},!0))}),(0,J.useEffect)(()=>{V.data&&V.data.kb_id!==a&&z.data?.some(e=>e.id===V.data.kb_id)&&U({kb:V.data.kb_id,label:null},!0)}),(0,J.useEffect)(()=>{if(!N||!V.data)return;let e=[...document.querySelector(`[data-testid="kb-document"]`)?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]].find(e=>e.textContent?.trim()===N);e&&(e.scrollIntoView({block:`start`}),P(null))});function de(e){e.preventDefault(),M(!1);let t=[...e.dataTransfer.files];B&&t.length!==0&&(t.length>1?H.add(B.id,t):(I(t[0]),w(`new-document`)))}let fe=e=>e===null?`Global`:R.data?.find(t=>t.id===e)?.name??`Project`;if(z.error)return(0,X.jsx)(Xe,{message:z.error.message,onRetry:()=>z.refetch()});let pe=o?V.data&&B&&V.data.kb_id===B.id?(0,X.jsx)(nr,{kb:B,doc:V.data,detailsOpen:k,onDetailsOpenChange:A,onHome:()=>oe(B.id),onOpen:ce,onDeleted:()=>U({document:null}),onReplaceFile:e=>V.data&&H.add(V.data.kb_id,[e],{replace:{document_id:V.data.id,expected_revision:V.data.revision}})},V.data.id):V.error?(0,X.jsxs)(Gr,{children:[(0,X.jsx)(`p`,{role:`alert`,"data-testid":`kb-document-error`,className:`text-sm text-error`,children:V.error.message}),(0,X.jsx)(p,{variant:`outline`,onClick:()=>U({document:null}),children:`Back`})]}):(0,X.jsx)(Gr,{children:(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`Loading document…`})}):l?(0,X.jsx)(Wr,{children:(0,X.jsx)(Kr,{query:l,search:re,onOpen:le,onClear:()=>U({q:null})})}):B?(0,X.jsx)(Wr,{children:(0,X.jsx)(hr,{kb:B,owner:fe(B.project_id),listing:te.data,label:c,onLabel:e=>U({label:e}),onOpen:ce,onNewDocument:()=>w(`new-document`),onSettings:()=>w(`settings`)})}):z.data?.length===0?(0,X.jsxs)(Gr,{testId:`empty-state`,children:[(0,X.jsx)(`p`,{className:`text-sm text-outline`,children:`No knowledge bases configured`}),(0,X.jsxs)(p,{"data-testid":`kb-empty-create`,onClick:()=>w(`create`),children:[(0,X.jsx)(Re,{size:16}),`New knowledge base`]})]}):null,me=(0,X.jsxs)(`nav`,{id:`kb-sidebar-panel`,"aria-label":`Knowledge bases`,"data-testid":`kb-sidebar`,className:`flex h-full min-h-0 flex-col border-outline-variant bg-background lg:w-72 lg:shrink-0 lg:border-r`,children:[(0,X.jsxs)(`form`,{className:`flex shrink-0 items-center gap-1.5 border-b border-outline-variant p-3`,onSubmit:e=>{e.preventDefault(),ue()},children:[(0,X.jsx)(W,{"aria-label":`Search knowledge`,"data-testid":`kb-search-input`,value:x,onChange:e=>S(e.target.value),placeholder:B&&!f?`Search ${B.name}`:`Search everything`,className:`h-9 min-w-0 flex-1`}),(0,X.jsx)(p,{type:`submit`,size:`icon`,variant:`ghost`,"data-testid":`kb-search-submit`,"aria-label":`Search`,children:(0,X.jsx)(Fe,{size:16})}),T&&(0,X.jsx)(p,{type:`button`,size:`icon`,variant:`ghost`,"data-testid":`kb-browser-close`,"aria-label":`Close knowledge browser`,onClick:()=>E(!1),children:(0,X.jsx)(D,{size:16})})]}),B&&(0,X.jsxs)(`label`,{className:`flex shrink-0 items-center gap-2 border-b border-outline-variant px-3 py-2 text-xs text-outline`,children:[(0,X.jsx)(`input`,{type:`checkbox`,"data-testid":`kb-search-all`,checked:f,onChange:e=>U({searchAll:e.target.checked?`1`:null})}),`Search all knowledge bases`]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 pb-1`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-medium text-outline`,children:`Knowledge bases`}),(0,X.jsx)(ge,{label:`Knowledge bases`,children:`Upload documents, write Markdown or sync a folder. Agents search this knowledge with citations, and document details show what they read.`})]}),(0,X.jsx)(p,{size:`icon`,variant:`ghost`,"aria-label":`New knowledge base`,"data-testid":`kb-create`,onClick:()=>w(`create`),children:(0,X.jsx)(Re,{size:16})})]}),z.isLoading&&(0,X.jsx)(se,{className:`mx-2 h-9`}),(0,X.jsx)(Hr,{bases:z.data??[],projectName:fe,kbId:a,documentId:o,documents:te.data?.documents??[],onSelectKb:oe,onOpenDocument:ce})]}),(0,X.jsx)(Ur,{})]});return(0,X.jsx)(b,{open:T&&!O,onOpenChange:E,children:(0,X.jsxs)(`div`,{"data-testid":`knowledge-bases`,className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,X.jsx)(`h1`,{"data-testid":`view-title`,className:`sr-only`,children:`Knowledge bases`}),O&&me,!O&&(0,X.jsxs)(_,{children:[(0,X.jsx)(m,{className:`fixed inset-0 z-50 bg-black/70`}),(0,X.jsxs)(v,{"data-testid":`kb-mobile-browser`,className:`viewport-sheet fixed inset-x-0 z-50 bg-background`,children:[(0,X.jsx)(y,{className:`sr-only`,children:`Browse knowledge`}),(0,X.jsx)(g,{className:`sr-only`,children:`Search knowledge bases and choose a document`}),me]})]}),(0,X.jsxs)(`div`,{"data-testid":`kb-dropzone`,className:d(`relative flex min-h-0 min-w-0 flex-1 flex-col`,j&&`outline-2 -outline-offset-4 outline-dashed outline-primary`),onDragOver:e=>{B&&(e.preventDefault(),M(!0))},onDragLeave:()=>M(!1),onDrop:de,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-outline-variant px-3 py-2 lg:hidden`,children:[(0,X.jsx)(h,{asChild:!0,children:(0,X.jsxs)(p,{"data-testid":`kb-browser-open`,variant:`ghost`,size:`sm`,"aria-expanded":T,"aria-controls":`kb-sidebar-panel`,onClick:()=>E(!0),children:[(0,X.jsx)(De,{size:16}),`Browse`]})}),B&&(0,X.jsx)(`span`,{className:`min-w-0 truncate text-sm text-outline`,children:B.name})]}),o&&l&&(0,X.jsx)(`div`,{className:`flex shrink-0 items-center border-b border-outline-variant px-3 py-1`,children:(0,X.jsxs)(p,{variant:`ghost`,size:`sm`,"data-testid":`kb-search-back`,className:`min-w-0`,onClick:()=>ae()&&U({document:null}),children:[(0,X.jsx)(ee,{size:14}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`Back to results for “`,l,`”`]})]})}),(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:pe}),(0,X.jsx)(qr,{uploads:H,onOpen:ce})]}),C===`create`&&(0,X.jsx)(Mn,{open:!0,projectId:e,onClose:()=>w(null),onCreated:e=>{w(null),E(!1),U({kb:e.id,document:null,label:null,q:null})}}),C===`settings`&&B&&(0,X.jsx)(Nn,{kb:B,onClose:()=>w(null),onDeleted:()=>{w(null),U({kb:null,document:null,label:null})}}),C===`new-document`&&B&&(0,X.jsx)(Ln,{kb:B,initialFile:F,onClose:L,onUploadMany:e=>{L(),H.add(B.id,e)},onCreated:(e,t)=>{L(),U({document:e.id,editorMode:t?null:`edit`})}})]})})}function Hr({bases:e,projectName:t,kbId:n,documentId:r,documents:i,onSelectKb:a,onOpenDocument:o}){let[s,c]=(0,J.useState)(null);(0,J.useEffect)(()=>{r&&c(null)},[r]);let l=new Map;for(let n of e){let e=t(n.project_id);l.set(e,[...l.get(e)??[],n])}let u=[...l.entries()].sort(([e],[t])=>e===`Global`?-1:t===`Global`?1:e.localeCompare(t));return(0,X.jsx)(`div`,{"data-testid":`kb-list`,className:`space-y-3`,children:u.map(([e,t])=>(0,X.jsxs)(`section`,{"aria-label":e,children:[u.length>1&&(0,X.jsx)(`h3`,{className:`truncate px-2 pb-0.5 pt-1 text-xs text-outline`,children:e}),(0,X.jsx)(`ul`,{className:`space-y-0.5`,children:t.map(e=>{let t=e.id===n,l=t&&s!==e.id&&i.length>0;return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-row`,"data-kb-name":e.name,"aria-current":t&&!r?`page`:void 0,"aria-expanded":l,className:d(`flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-surface-high`,t&&`font-medium`,t&&!r&&`bg-surface-high`),onClick:()=>{t&&c(t=>t===e.id?null:e.id),a(e.id)},children:[(0,X.jsx)(oe,{size:14,"aria-hidden":!0,className:d(`-mr-1 shrink-0 text-outline transition-transform motion-reduce:transition-none`,l&&`rotate-90`,e.document_count===0&&`invisible`)}),(0,X.jsx)(ae,{size:15,className:`shrink-0 text-outline`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`text-xs font-normal tabular-nums text-outline`,children:e.document_count})]}),l&&(0,X.jsx)(`ul`,{className:`ml-4 mt-0.5 space-y-0.5 border-l border-outline-variant pl-2`,children:i.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-nav-document`,"data-document-title":e.title,"aria-current":e.id===r?`page`:void 0,className:d(`flex min-h-8 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-surface-high`,e.id===r?`bg-surface-high text-on-surface`:`text-outline`),onClick:()=>o(e.id),children:[(0,X.jsx)(Ue,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]})},e.id))})]},e.id)})})]},e))})}function Ur(){let e=_t(),t=e.data,n=t?t.embedding.provider===`none`?{text:`Keyword search only`,title:`Configure embeddings in Settings to also search by meaning`}:t.embedding.ready?{text:`Hybrid search`,title:t.embedding.model??void 0}:{text:`Embeddings not ready`,title:t.embedding.detail??``}:null,r=t?t.jobs.queued+t.jobs.running:0;return(0,X.jsx)(`p`,{role:`status`,"data-testid":`kb-status`,className:`shrink-0 border-t border-outline-variant px-4 py-2 text-xs text-outline`,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{title:n?.title,children:n?.text}),r?` · ${r} processing`:``]}):e.error?`Knowledge status unavailable`:`Loading…`})}function Wr({children:e}){return(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:e})}function Gr({children:e,testId:t}){return(0,X.jsx)(`div`,{"data-testid":t,className:`mx-auto flex max-w-lg flex-1 flex-col items-start justify-center gap-4 p-6`,children:e})}function Kr({query:e,search:t,onOpen:n,onClear:r}){let i=t.data;return(0,X.jsxs)(`section`,{"data-testid":`kb-search-results`,"aria-label":`Search results`,className:`w-full min-w-0 space-y-4 p-4 sm:p-8`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h2`,{className:`mr-auto text-lg font-medium`,children:[`Results for “`,e,`”`]}),i&&i.hits.length>0&&(0,X.jsxs)(`span`,{className:`text-xs text-outline`,"data-testid":`kb-search-count`,children:[i.hits.length,` `,i.hits.length===1?`result`:`results`]}),(0,X.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:r,"data-testid":`kb-search-clear`,children:[(0,X.jsx)(D,{size:14}),`Clear`]})]}),i?.degraded&&(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:i.degraded}),t.isLoading&&(0,X.jsx)(`p`,{className:`text-sm text-outline`,children:`Searching…`}),t.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:t.error.message}),i?.hits.length===0&&(0,X.jsx)(`p`,{className:`text-sm text-outline`,"data-testid":`kb-search-empty`,children:`Nothing matched. Try other words or search all knowledge bases.`}),i?.hits.map(e=>(0,X.jsxs)(`article`,{"data-testid":`kb-search-result`,className:`space-y-2 border-b border-outline-variant pb-4`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`block text-left`,onClick:()=>n(e.document_id,Xr(e.passages[0]?.heading_path)),children:[(0,X.jsx)(`span`,{className:`block font-medium text-primary hover:underline`,children:e.title}),(0,X.jsxs)(`span`,{className:`block break-all text-xs text-outline`,children:[e.kb_name,` · `,e.path]})]}),e.labels.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.labels.map(e=>(0,X.jsx)(At,{variant:`secondary`,children:e},e))}),e.passages.map(t=>(0,X.jsxs)(`div`,{"data-testid":`kb-search-passage`,className:`cursor-pointer space-y-1 rounded-md p-2 hover:bg-surface-high`,onClick:()=>n(e.document_id,Xr(t.heading_path)),children:[(t.heading_path.length>0||t.locator?.page||t.locator?.sheet)&&(0,X.jsx)(`div`,{className:`text-xs text-outline`,children:[...t.heading_path.map(zr),...t.locator?.page?[`page ${t.locator.page}`]:[],...t.locator?.sheet?[`sheet ${t.locator.sheet}`]:[]].join(` › `)}),(0,X.jsx)(`p`,{className:`text-sm leading-relaxed`,children:(0,X.jsx)(Br,{text:t.snippet})})]},t.chunk_id))]},e.document_id))]})}function qr({uploads:e,onOpen:t}){if(!e.uploads.length)return null;let n=e.uploads.some(e=>e.status!==`uploading`);return(0,X.jsxs)(`section`,{"data-testid":`kb-upload-queue`,"aria-label":`Uploads`,className:`absolute bottom-4 right-4 z-10 flex max-h-72 w-80 max-w-[calc(100%-2rem)] flex-col rounded-lg border border-outline-variant bg-surface text-sm shadow-lg`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 py-1.5`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Uploads`}),n&&(0,X.jsx)(p,{size:`sm`,variant:`ghost`,onClick:e.clearFinished,"data-testid":`kb-upload-clear`,children:`Dismiss`})]}),(0,X.jsx)(`div`,{className:`min-h-0 space-y-1 overflow-y-auto px-3 pb-2`,children:e.uploads.map(n=>(0,X.jsx)(Yr,{upload:n,onOpen:t,onRetry:()=>e.retry(n.id)},n.id))})]})}var Jr={pending:`Parsing…`,ok:`Open`,partial:`Open · partly parsed`,failed:`Parse failed`};function Yr({upload:e,onOpen:t,onRetry:n}){let r=jt(e.status===`done`?e.kbId:null).data?.documents.find(t=>t.id===e.document?.id)??e.document;return(0,X.jsxs)(`div`,{"data-testid":`kb-upload-item`,"data-status":e.status,"data-parse-state":r?.parse_state,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.file.name}),e.status===`uploading`&&(0,X.jsx)(`span`,{className:`h-1.5 w-24 overflow-hidden rounded-full bg-surface-high`,role:`progressbar`,"aria-label":`Upload progress`,"aria-valuenow":Math.round(e.progress*100),children:(0,X.jsx)(`span`,{className:`block h-full bg-primary`,style:{width:`${Math.round(e.progress*100)}%`}})}),e.status===`done`&&r&&(0,X.jsx)(`button`,{type:`button`,className:d(`hover:underline`,r.parse_state===`failed`?`text-error`:`text-primary`),onClick:()=>t(r.id),children:Jr[r.parse_state]}),e.status===`failed`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,children:e.error}),(0,X.jsx)(p,{size:`sm`,variant:`ghost`,onClick:n,"data-testid":`kb-upload-retry`,children:`Retry`})]})]})}function Xr(e){return e?.[e.length-1]}export{Rr as default};
|