orc-ai 0.1.49 → 0.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/dist/index.js +519 -485
  2. package/dist/skills/orc-platform/SKILL.md +3 -1
  3. package/dist/skills/orc-platform/references/execution.md +3 -0
  4. package/dist/skills/orc-platform/references/scratchpads.md +140 -0
  5. package/dist/skills/orc-platform/references/web.md +112 -0
  6. package/dist/skills/orc-sdlc/references/planning.md +2 -0
  7. package/dist/web/assets/{Agents-C8dJX8px.js → Agents-Cuq9hQL1.js} +1 -1
  8. package/dist/web/assets/Assistant-Bold-gm-uSS1B.woff2 +0 -0
  9. package/dist/web/assets/Assistant-Medium-DrcxCXg3.woff2 +0 -0
  10. package/dist/web/assets/Assistant-Regular-DVxZuzxb.woff2 +0 -0
  11. package/dist/web/assets/Assistant-SemiBold-SCI4bEL9.woff2 +0 -0
  12. package/dist/web/assets/{Attention-BHYo8Lwr.js → Attention-Blme1iNv.js} +1 -1
  13. package/dist/web/assets/{Audit-CS_DZkbJ.js → Audit-CcdL6u56.js} +1 -1
  14. package/dist/web/assets/{ConfirmDialog-CrSa87VF.js → ConfirmDialog-UlZrlBrT.js} +1 -1
  15. package/dist/web/assets/Dashboard-u3v-obdz.js +1 -0
  16. package/dist/web/assets/{DocumentWorkspace-CNyVQTjg.js → DocumentWorkspace-B5QQ9h1l.js} +1 -1
  17. package/dist/web/assets/{EmptyState-Ctm7L70B.js → EmptyState-CLMWpYxU.js} +1 -1
  18. package/dist/web/assets/{ErrorState-BPTepwiG.js → ErrorState-_BM228mQ.js} +1 -1
  19. package/dist/web/assets/{FileEditor-Dh29_xCL.js → FileEditor-CGTsskO5.js} +1 -1
  20. package/dist/web/assets/{JobWebhooks-TvAY8p1V.js → JobWebhooks-CeHYIwjS.js} +1 -1
  21. package/dist/web/assets/{Jobs-C5ggSs2T.js → Jobs-B_HefXhI.js} +3 -3
  22. package/dist/web/assets/Knowledge-DtqZHvq9.js +28 -0
  23. package/dist/web/assets/{PackageCatalog-B1U3vfhW.js → PackageCatalog-C4JkAh_e.js} +5 -5
  24. package/dist/web/assets/{Pager-ClYYU9et.js → Pager-C4QwTsW7.js} +1 -1
  25. package/dist/web/assets/{PriorityBadge-BW-A50LE.js → PriorityBadge-q0hZXCLg.js} +1 -1
  26. package/dist/web/assets/Projects-Bqohd0oU.js +3 -0
  27. package/dist/web/assets/ResumeActions-Bihtv9n8.js +1 -0
  28. package/dist/web/assets/{Rules-DGKsAbTf.js → Rules-DbI3E-1N.js} +1 -1
  29. package/dist/web/assets/Scratchpads-CvYHDI3j.js +20 -0
  30. package/dist/web/assets/Sessions-mS5ivBxN.js +5 -0
  31. package/dist/web/assets/{Settings-yW1S2q4F.js → Settings-BcP04VXz.js} +6 -6
  32. package/dist/web/assets/{Skills-BwdXE5nT.js → Skills-Cs1JTSlV.js} +3 -3
  33. package/dist/web/assets/{SourceEditor-ft02z20v.js → SourceEditor-B66_SPOa.js} +1 -1
  34. package/dist/web/assets/{StatusBadge-C5G1fdZh.js → StatusBadge-BxSWnu8L.js} +1 -1
  35. package/dist/web/assets/TagInput-B3BLlodf.js +1 -0
  36. package/dist/web/assets/{TaskDetailSheet-fUSHPFB-.js → TaskDetailSheet-BnMsuYO6.js} +2 -2
  37. package/dist/web/assets/{Tasks-uRqvmLz7.js → Tasks-CZnulyFF.js} +5 -5
  38. package/dist/web/assets/{Terminals-W5nszLI1.js → Terminals-J-qPx71R.js} +5 -5
  39. package/dist/web/assets/{ViewHeader-DXR0ZaMO.js → ViewHeader-CG7vOMnJ.js} +1 -1
  40. package/dist/web/assets/{Webhooks-lXLoKWdt.js → Webhooks-DPpjIwP_.js} +1 -1
  41. package/dist/web/assets/abnfDiagram-VCTEODGH-qnCZr3qh.js +1 -0
  42. package/dist/web/assets/ar-SA-G6X2FPQ2-BNl3syL3.js +10 -0
  43. package/dist/web/assets/arc-DuthDAsq.js +1 -0
  44. package/dist/web/assets/architectureDiagram-5GKGNRK7-CuzhWFIn.js +36 -0
  45. package/dist/web/assets/arrow-left-DNp3aOhW.js +6 -0
  46. package/dist/web/assets/az-AZ-76LH7QW2-CSlBN4kF.js +1 -0
  47. package/dist/web/assets/bg-BG-XCXSNQG7-Dcs1AElN.js +5 -0
  48. package/dist/web/assets/{blockDiagram-I7D4REHJ-DMrufypV.js → blockDiagram-I7D4REHJ-CCIO0eI-.js} +3 -3
  49. package/dist/web/assets/bn-BD-2XOGV67Q-D9poNjDl.js +5 -0
  50. package/dist/web/assets/{c4Diagram-7LVT6UL2-BUUxjwvU.js → c4Diagram-7LVT6UL2-EDh4_U6t.js} +2 -2
  51. package/dist/web/assets/ca-ES-6MX7JW3Y-pTbaXdVe.js +8 -0
  52. package/dist/web/assets/channel-D-jHqOEf.js +1 -0
  53. package/dist/web/assets/chunk-2Q5K7J3B-Ccr7lFKH.js +1 -0
  54. package/dist/web/assets/{chunk-5VM5RSS4-B6lAVcgQ.js → chunk-5VM5RSS4-rFn8SpPH.js} +1 -1
  55. package/dist/web/assets/chunk-F27PBJKO-CDJpfkoq.js +1 -0
  56. package/dist/web/assets/{chunk-IMKFNOWR-CwyogA-y.js → chunk-IMKFNOWR-B3_FhSA0.js} +1 -1
  57. package/dist/web/assets/chunk-JWPE2WC7-sBjgi4vj.js +1 -0
  58. package/dist/web/assets/chunk-POPQ4Y6H-Dsox2izf.js +1 -0
  59. package/dist/web/assets/{chunk-SVP7TREG-CmiQdvOH.js → chunk-SVP7TREG-CzwNtBeO.js} +4 -4
  60. package/dist/web/assets/{chunk-TICWLB2K-CieIpfOy.js → chunk-TICWLB2K-C2vbibcd.js} +1 -1
  61. package/dist/web/assets/chunk-XXDRQBXY-V09kgMMs.js +1 -0
  62. package/dist/web/assets/classDiagram-ZZMXUADV-yk_1OWub.js +1 -0
  63. package/dist/web/assets/classDiagram-v2-VYDZK3BY-yk_1OWub.js +1 -0
  64. package/dist/web/assets/copy-DG3MHKpv.js +6 -0
  65. package/dist/web/assets/cose-bilkent-JH36ORCC-CJbRd_jc.js +1 -0
  66. package/dist/web/assets/cs-CZ-2BRQDIVT-DCTwXFkX.js +11 -0
  67. package/dist/web/assets/{cynefin-OW5HDTMX-vMXgcpgg.js → cynefin-OW5HDTMX-DQAC3glv.js} +1 -1
  68. package/dist/web/assets/cynefinDiagram-5FMLGOSQ-BzboBb_e.js +62 -0
  69. package/dist/web/assets/da-DK-5WZEPLOC-BAYPDSds.js +5 -0
  70. package/dist/web/assets/{dagre-GXQ25YYZ-xmoviGlr.js → dagre-GXQ25YYZ-C_-0NO8H.js} +2 -2
  71. package/dist/web/assets/de-DE-XR44H4JA-WTQ3THgd.js +8 -0
  72. package/dist/web/assets/{diagram-S7CK7UJ4-CguQzzXs.js → diagram-S7CK7UJ4-Dvi9imfs.js} +5 -5
  73. package/dist/web/assets/diagram-UQ7AKVKN-BoEKhuYx.js +41 -0
  74. package/dist/web/assets/{diagram-VSXAHHWV-cuhv3Fvj.js → diagram-VSXAHHWV-AoIN6taJ.js} +3 -3
  75. package/dist/web/assets/diagram-VX7I27RA-BIAMQMgb.js +24 -0
  76. package/dist/web/assets/diagram-Z3DM3KII-MXPt1bWW.js +24 -0
  77. package/dist/web/assets/directory-open-01563666-DWU9wJ6I.js +1 -0
  78. package/dist/web/assets/directory-open-4ed118d0-CunoC1EB.js +1 -0
  79. package/dist/web/assets/{download-UgMvjBjR.js → download-PQ08tuAg.js} +1 -1
  80. package/dist/web/assets/ebnfDiagram-PWID7BFC-BPO0ZRsN.js +1 -0
  81. package/dist/web/assets/el-GR-BZB4AONW-C6V4uhoK.js +10 -0
  82. package/dist/web/assets/erDiagram-RLTQ6QDP-BR2u7bIU.js +99 -0
  83. package/dist/web/assets/es-ES-U4NZUMDT-D_kwVnQr.js +9 -0
  84. package/dist/web/assets/eu-ES-A7QVB2H4-Eeu5vgta.js +11 -0
  85. package/dist/web/assets/excalidraw/fonts/Assistant/Assistant-Bold.woff2 +0 -0
  86. package/dist/web/assets/excalidraw/fonts/Assistant/Assistant-Medium.woff2 +0 -0
  87. package/dist/web/assets/excalidraw/fonts/Assistant/Assistant-Regular.woff2 +0 -0
  88. package/dist/web/assets/excalidraw/fonts/Assistant/Assistant-SemiBold.woff2 +0 -0
  89. package/dist/web/assets/excalidraw/fonts/Cascadia/CascadiaCode-Regular.woff2 +0 -0
  90. package/dist/web/assets/excalidraw/fonts/ComicShanns/ComicShanns-Regular-279a7b317d12eb88de06167bd672b4b4.woff2 +0 -0
  91. package/dist/web/assets/excalidraw/fonts/ComicShanns/ComicShanns-Regular-6e066e8de2ac57ea9283adb9c24d7f0c.woff2 +0 -0
  92. package/dist/web/assets/excalidraw/fonts/ComicShanns/ComicShanns-Regular-dc6a8806fa96795d7b3be5026f989a17.woff2 +0 -0
  93. package/dist/web/assets/excalidraw/fonts/ComicShanns/ComicShanns-Regular-fcb0fc02dcbee4c9846b3e2508668039.woff2 +0 -0
  94. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-349fac6ca4700ffec595a7150a0d1e1d.woff2 +0 -0
  95. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-3f2c5db56cc93c5a6873b1361d730c16.woff2 +0 -0
  96. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-41b173a47b57366892116a575a43e2b6.woff2 +0 -0
  97. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-623ccf21b21ef6b3a0d87738f77eb071.woff2 +0 -0
  98. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-a88b72a24fb54c9f94e3b5fdaa7481c9.woff2 +0 -0
  99. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-b9dcf9d2e50a1eaf42fc664b50a3fd0d.woff2 +0 -0
  100. package/dist/web/assets/excalidraw/fonts/Excalifont/Excalifont-Regular-be310b9bcd4f1a43f571c46df7809174.woff2 +0 -0
  101. package/dist/web/assets/excalidraw/fonts/Liberation/LiberationSans-Regular.woff2 +0 -0
  102. package/dist/web/assets/excalidraw/fonts/Lilita/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2 +0 -0
  103. package/dist/web/assets/excalidraw/fonts/Lilita/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2 +0 -0
  104. package/dist/web/assets/excalidraw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2 +0 -0
  105. package/dist/web/assets/excalidraw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2 +0 -0
  106. package/dist/web/assets/excalidraw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2 +0 -0
  107. package/dist/web/assets/excalidraw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2 +0 -0
  108. package/dist/web/assets/excalidraw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2 +0 -0
  109. package/dist/web/assets/excalidraw/fonts/Virgil/Virgil-Regular.woff2 +0 -0
  110. package/dist/web/assets/fa-IR-HGAKTJCU-CKd62s_f.js +8 -0
  111. package/dist/web/assets/fi-FI-Z5N7JZ37-CXq3Xbio.js +6 -0
  112. package/dist/web/assets/file-open-002ab408-DIuFHtCF.js +1 -0
  113. package/dist/web/assets/file-open-7c801643-684qeFg4.js +1 -0
  114. package/dist/web/assets/file-save-3189631c-C1wFhQhH.js +1 -0
  115. package/dist/web/assets/file-save-745eba88-Bb9F9Kg7.js +1 -0
  116. package/dist/web/assets/{flowDiagram-HODETNUW-DueO0Ju6.js → flowDiagram-HODETNUW-DtCUIQgA.js} +5 -5
  117. package/dist/web/assets/folder-open-D0jNv68L.js +11 -0
  118. package/dist/web/assets/fr-FR-RHASNOE6-BUQsSuUv.js +9 -0
  119. package/dist/web/assets/ganttDiagram-EL5Y4UJY-DtAyQ0Yy.js +292 -0
  120. package/dist/web/assets/gitGraphDiagram-WWUBYQGX-CoXp0Ypy.js +106 -0
  121. package/dist/web/assets/gl-ES-HMX3MZ6V-DW4qfI2b.js +10 -0
  122. package/dist/web/assets/he-IL-6SHJWFNN-DaY9mSnj.js +10 -0
  123. package/dist/web/assets/hi-IN-IWLTKZ5I-D2lbPu3U.js +4 -0
  124. package/dist/web/assets/highlighted-body-KPVGNVTW-BmPHGwPQ.js +1 -0
  125. package/dist/web/assets/hu-HU-A5ZG7DT2-Bos6dFhw.js +7 -0
  126. package/dist/web/assets/id-ID-SAP4L64H-cWyYCXM5.js +10 -0
  127. package/dist/web/assets/image-blob-reduce.esm-D6s-rqMO.js +7 -0
  128. package/dist/web/assets/index-CY60J5zm.css +1 -0
  129. package/dist/web/assets/{index-C_jtMgr7.js → index-CYCjrqhG.js} +124 -114
  130. package/dist/web/assets/index-CcfSzlv5.js +19 -0
  131. package/dist/web/assets/infoDiagram-27XIBGKW-C2Ypr-zs.js +2 -0
  132. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-ccIPCUs4.js → ishikawaDiagram-5VMMS53U-Bx7qtMkV.js} +5 -5
  133. package/dist/web/assets/it-IT-JPQ66NNP-CRGQFEpH.js +11 -0
  134. package/dist/web/assets/ja-JP-DBVTYXUO-BXcfLN6y.js +8 -0
  135. package/dist/web/assets/{journeyDiagram-3NMN7TZE-rRe3uTLu.js → journeyDiagram-3NMN7TZE-rsuiVeG_.js} +2 -2
  136. package/dist/web/assets/kaa-6HZHGXH3-Bk6N-pLt.js +1 -0
  137. package/dist/web/assets/kab-KAB-ZGHBKWFO-Ctb8wAYx.js +8 -0
  138. package/dist/web/assets/{kanban-definition-UXKFOSKX-tAKCWntJ.js → kanban-definition-UXKFOSKX-5ktYMmTY.js} +6 -6
  139. package/dist/web/assets/kk-KZ-P5N5QNE5-CzQX2BL1.js +1 -0
  140. package/dist/web/assets/km-KH-HSX4SM5Z-DnDRwAqY.js +11 -0
  141. package/dist/web/assets/ko-KR-MTYHY66A-C6HKdiKS.js +9 -0
  142. package/dist/web/assets/ku-TR-6OUDTVRD-evaKSJwY.js +9 -0
  143. package/dist/web/assets/layout-DSZI9hxI.js +1 -0
  144. package/dist/web/assets/linear-omhrmwGQ.js +1 -0
  145. package/dist/web/assets/{list-BL4eRkIg.js → list-UGkABbTC.js} +1 -1
  146. package/dist/web/assets/live-sessions-C19eXx17.js +6 -0
  147. package/dist/web/assets/lt-LT-XHIRWOB4-BS7h6VOT.js +3 -0
  148. package/dist/web/assets/lv-LV-5QDEKY6T-CvKj-LUX.js +7 -0
  149. package/dist/web/assets/mermaid-HWGCJPDP-B_H4rk_s.js +299 -0
  150. package/dist/web/assets/mermaid.core-Bs68JjJM.js +312 -0
  151. package/dist/web/assets/{mindmap-definition-YA3MSWOX-Cj5-j6a7.js → mindmap-definition-YA3MSWOX-DKG9LDwL.js} +4 -4
  152. package/dist/web/assets/mr-IN-CRQNXWMA-C_9ZWEOY.js +13 -0
  153. package/dist/web/assets/my-MM-5M5IBNSE-Bic5Rd4I.js +1 -0
  154. package/dist/web/assets/nb-NO-T6EIAALU-BN5D6e6X.js +10 -0
  155. package/dist/web/assets/nl-NL-IS3SIHDZ-CLmoJxpw.js +8 -0
  156. package/dist/web/assets/nn-NO-6E72VCQL-DH3pWtEG.js +8 -0
  157. package/dist/web/assets/oc-FR-POXYY2M6-DzJwOBaL.js +8 -0
  158. package/dist/web/assets/pa-IN-N4M65BXN-CxFRfqt4.js +4 -0
  159. package/dist/web/assets/pegDiagram-XKGWAZYB-D_-uCYBR.js +1 -0
  160. package/dist/web/assets/{pencil-gxvh59uO.js → pencil-_hID3D0m.js} +1 -1
  161. package/dist/web/assets/percentages-BXMCSKIN-DGBKIvAv.css +1 -0
  162. package/dist/web/assets/percentages-BXMCSKIN-DtfDKj6k.js +180 -0
  163. package/dist/web/assets/pica-sWD7KYN4.js +7 -0
  164. package/dist/web/assets/pieDiagram-E7YTZNPT-Cxcz8v2V.js +39 -0
  165. package/dist/web/assets/pl-PL-T2D74RX3-DFEd2a_2.js +9 -0
  166. package/dist/web/assets/pt-BR-5N22H2LF-d_zvXQ30.js +9 -0
  167. package/dist/web/assets/pt-PT-UZXXM6DQ-5FeuC95-.js +9 -0
  168. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-DKTP6jS5.js → quadrantDiagram-AXDQQJYC-5W1D624h.js} +1 -1
  169. package/dist/web/assets/railroadDiagram-O6MQD6OU-BZhsOHVF.js +1 -0
  170. package/dist/web/assets/{requirementDiagram-BXWQKSXE-B9hH69zu.js → requirementDiagram-BXWQKSXE-BXlonflD.js} +2 -2
  171. package/dist/web/assets/ro-RO-JPDTUUEW-CAJt20_T.js +11 -0
  172. package/dist/web/assets/roundRect-0PYZxl1G.js +1 -0
  173. package/dist/web/assets/ru-RU-B4JR7IUQ-BL-2B7Np.js +9 -0
  174. package/dist/web/assets/sankeyDiagram-P5KCCOFB-BZVh-M1g.js +40 -0
  175. package/dist/web/assets/{save-CYoz3QKB.js → save-C0v-3p0L.js} +1 -1
  176. package/dist/web/assets/save-file-B_ZN6-id.js +1 -0
  177. package/dist/web/assets/scratchpad-routes-DvtErr_v.js +11 -0
  178. package/dist/web/assets/scroll-area-Bgn8q6dm.js +1 -0
  179. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-BF77J63J.js → sequenceDiagram-WJ2MYXX4-B2WHT4e0.js} +2 -2
  180. package/dist/web/assets/si-LK-N5RQ5JYF-BwL9NXm1.js +1 -0
  181. package/dist/web/assets/sizeCapture-INFHLROL-BI8hpcc0.js +1 -0
  182. package/dist/web/assets/sk-SK-C5VTKIMK-DEJmCOdH.js +6 -0
  183. package/dist/web/assets/sl-SI-NN7IZMDC-BNyfGsJr.js +6 -0
  184. package/dist/web/assets/stateDiagram-D77RDMKH-yCTyY4sx.js +1 -0
  185. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-DMV9Hi6h.js +1 -0
  186. package/dist/web/assets/subset-shared.chunk-en_zPkcm.js +84 -0
  187. package/dist/web/assets/subset-worker.chunk-D4Jfgczh.js +1 -0
  188. package/dist/web/assets/sv-SE-XGPEYMSR-CcrID0kB.js +10 -0
  189. package/dist/web/assets/swimlanes-42K2YHIH-CsXemLHu.js +1 -0
  190. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-wKC0jJ-D.js +8 -0
  191. package/dist/web/assets/ta-IN-2NMHFXQM-1Q6gAmCa.js +9 -0
  192. package/dist/web/assets/{table-D3N_5Wee.js → table-D-x54JQs.js} +1 -1
  193. package/dist/web/assets/tabs-Dwtb498J.js +1 -0
  194. package/dist/web/assets/th-TH-HPSO5L25-Osf6RMxs.js +2 -0
  195. package/dist/web/assets/{timeline-definition-24CTP7MA-owGoHn8z.js → timeline-definition-24CTP7MA-BcjYHSKM.js} +8 -8
  196. package/dist/web/assets/tr-TR-DEFEU3FU-olIwbQqc.js +7 -0
  197. package/dist/web/assets/{trash-2-D3Ey4I09.js → trash-2-C4wuE82r.js} +1 -1
  198. package/dist/web/assets/uk-UA-QMV73CPH-_0ICAhhw.js +6 -0
  199. package/dist/web/assets/{upload-DhVOCWST.js → upload-Cq-d5iVn.js} +1 -1
  200. package/dist/web/assets/{useDetailRoute-j9nlwack.js → useDetailRoute-DiC2IR0t.js} +1 -1
  201. package/dist/web/assets/{useJobs-Dcl-Vim3.js → useJobs-TDZx1N1l.js} +1 -1
  202. package/dist/web/assets/{useKnowledge-gIjk0_I1.js → useKnowledge-cE7nsoOf.js} +1 -1
  203. package/dist/web/assets/{useListSelection-CSQd_Hmx.js → useListSelection-tj_f-2Ad.js} +1 -1
  204. package/dist/web/assets/{useMemories-B8Zpz0Qz.js → useMemories-rjShoqd3.js} +1 -1
  205. package/dist/web/assets/useProjectScope-DaFHoG4_.js +1 -0
  206. package/dist/web/assets/{useSessions-BrdK-12R.js → useSessions-BNsSZXqv.js} +1 -1
  207. package/dist/web/assets/vennDiagram-4TSXK5OY-BIC5NL2Q.js +34 -0
  208. package/dist/web/assets/vi-VN-M7AON7JQ-CZHjInAz.js +5 -0
  209. package/dist/web/assets/{view-params-Bm1Qf6KC.js → view-params-Duc_5Bxj.js} +1 -1
  210. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-D9GbTBKy.js → wardleyDiagram-VM6X3IG4-BJqqp-BL.js} +2 -2
  211. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-BFqPF2Hl.js → xychartDiagram-S5SC5T6Z-CMANcsti.js} +4 -4
  212. package/dist/web/assets/zh-CN-LNUGB5OW-z21ZnHQB.js +10 -0
  213. package/dist/web/assets/zh-HK-E62DVLB3-C-RnadUL.js +1 -0
  214. package/dist/web/assets/zh-TW-RAJ6MFWO-Vua3CLAj.js +9 -0
  215. package/dist/web/index.html +2 -2
  216. package/package.json +1 -1
  217. package/dist/web/assets/Dashboard-V813oIhq.js +0 -1
  218. package/dist/web/assets/Knowledge-BpiN3iVE.js +0 -28
  219. package/dist/web/assets/Projects-DRao5Qpk.js +0 -3
  220. package/dist/web/assets/ResumeActions-DHTOr6GQ.js +0 -11
  221. package/dist/web/assets/Sessions-CWHU6sYy.js +0 -5
  222. package/dist/web/assets/abnfDiagram-VCTEODGH-K8P_VxLi.js +0 -1
  223. package/dist/web/assets/arc-BOl9BKfD.js +0 -1
  224. package/dist/web/assets/architectureDiagram-5GKGNRK7-DIZ15fO5.js +0 -36
  225. package/dist/web/assets/channel-CQFNQIhG.js +0 -1
  226. package/dist/web/assets/chunk-2Q5K7J3B-wRIxA2_q.js +0 -1
  227. package/dist/web/assets/chunk-F27PBJKO-DVuei-Pl.js +0 -1
  228. package/dist/web/assets/chunk-JWPE2WC7-zdsOarNZ.js +0 -1
  229. package/dist/web/assets/chunk-POPQ4Y6H-D3ieeKih.js +0 -1
  230. package/dist/web/assets/chunk-XXDRQBXY-BoTHwisB.js +0 -1
  231. package/dist/web/assets/classDiagram-ZZMXUADV-B5yD90Df.js +0 -1
  232. package/dist/web/assets/classDiagram-v2-VYDZK3BY-B5yD90Df.js +0 -1
  233. package/dist/web/assets/cose-bilkent-JH36ORCC-CtGsuuTW.js +0 -1
  234. package/dist/web/assets/cynefinDiagram-5FMLGOSQ-kMbm5D7e.js +0 -62
  235. package/dist/web/assets/diagram-UQ7AKVKN-CMX0u7Gf.js +0 -41
  236. package/dist/web/assets/diagram-VX7I27RA-Bp_JbX0e.js +0 -24
  237. package/dist/web/assets/diagram-Z3DM3KII-oZ6jRSCd.js +0 -24
  238. package/dist/web/assets/ebnfDiagram-PWID7BFC-DbxnEjb0.js +0 -1
  239. package/dist/web/assets/erDiagram-RLTQ6QDP-Cl5kXPho.js +0 -99
  240. package/dist/web/assets/folder-open-DojCP5NP.js +0 -16
  241. package/dist/web/assets/ganttDiagram-EL5Y4UJY-DNjT4iVH.js +0 -292
  242. package/dist/web/assets/gitGraphDiagram-WWUBYQGX-B4aUQ9gY.js +0 -106
  243. package/dist/web/assets/highlighted-body-KPVGNVTW-gt1u8RcC.js +0 -1
  244. package/dist/web/assets/index-CyjfnRiI.css +0 -1
  245. package/dist/web/assets/infoDiagram-27XIBGKW-CWcOvNAB.js +0 -2
  246. package/dist/web/assets/layout-7xCiQ5Mn.js +0 -1
  247. package/dist/web/assets/linear-WCNhc07o.js +0 -1
  248. package/dist/web/assets/mermaid-HWGCJPDP-C8QwWdo5.js +0 -609
  249. package/dist/web/assets/pegDiagram-XKGWAZYB-BYB3oVZ_.js +0 -1
  250. package/dist/web/assets/pieDiagram-E7YTZNPT-CSbpzXas.js +0 -39
  251. package/dist/web/assets/railroadDiagram-O6MQD6OU-Ct8aPeLX.js +0 -1
  252. package/dist/web/assets/refresh-cw-BQRdbjy6.js +0 -6
  253. package/dist/web/assets/sankeyDiagram-P5KCCOFB-CDqNONxU.js +0 -40
  254. package/dist/web/assets/scroll-area-CU4DGUBA.js +0 -1
  255. package/dist/web/assets/sizeCapture-INFHLROL-Dpubco_U.js +0 -1
  256. package/dist/web/assets/stateDiagram-D77RDMKH-CzslKEYw.js +0 -1
  257. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-DKbNjyV-.js +0 -1
  258. package/dist/web/assets/swimlanes-42K2YHIH-bD_tUjo6.js +0 -1
  259. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-0wAluWQF.js +0 -8
  260. package/dist/web/assets/tabs-CSlEXoxD.js +0 -1
  261. package/dist/web/assets/useProjectScope-Dk0mjyHf.js +0 -1
  262. package/dist/web/assets/vennDiagram-4TSXK5OY-D0_6bldW.js +0 -34
@@ -1,18 +1,18 @@
1
- import{c as ma,r as z,j as t,W as Fe,V as Ca,u as ve,a8 as Pa,a9 as Sa,aa as Aa,ab as Ma,ac as Fa,B as _,d as V,m as $e,n as Le,o as De,U as Qe,p as re,I as he,T as We,b as je,D as Xe,H as ua,O as Ia,am as Ea,a7 as $a,a as La,G as Da,a_ as Oa,N as za,be as Ra}from"./index-C_jtMgr7.js";import{u as we}from"./view-params-Bm1Qf6KC.js";import{p as Ie,i as ra,a as Ua,s as Ba}from"./public-api-BvD4z7ja.js";import{r as pa}from"./primitive-files-BwTyowra.js";import{V as Ta}from"./ViewHeader-DXR0ZaMO.js";import{u as qa}from"./useDetailRoute-j9nlwack.js";import{U as Ka}from"./upload-DhVOCWST.js";/**
1
+ import{c as ma,r as z,j as t,W as Fe,V as Ca,u as ve,aj as Pa,ak as Sa,al as Aa,am as Ma,an as Fa,B as _,d as V,m as Ee,n as Le,o as De,U as Qe,p as re,I as he,T as We,b as je,D as Xe,J as ua,O as Ia,a8 as $a,ai as Ea,a as La,H as Da,be as Oa,N as za,bp as Ba}from"./index-CYCjrqhG.js";import{u as we}from"./view-params-Duc_5Bxj.js";import{p as Ie,i as ra,a as Ta,s as qa}from"./public-api-BvD4z7ja.js";import{r as pa}from"./primitive-files-BwTyowra.js";import{V as Ra}from"./ViewHeader-CG7vOMnJ.js";import{u as Ua}from"./useDetailRoute-DiC2IR0t.js";import{s as Ka}from"./save-file-B_ZN6-id.js";import{U as Wa}from"./upload-Cq-d5iVn.js";/**
2
2
  * @license lucide-react v1.27.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Wa=[["path",{d:"M14 2v5a1 1 0 001 1h5",key:"9v5fu7"}],["path",{d:"M14.692 22H18a2 2 0 002-2V8a2.4 2.4 0 00-.706-1.706l-3.588-3.588A2.4 2.4 0 0014 2H6a2 2 0 00-2 2v3.804",key:"1ne0j7"}],["path",{d:"M2.264 13.752 7 16.5l4.737-2.748",key:"t73mg3"}],["path",{d:"M2.995 13.014A2 2 0 002 14.744v3.516a2 2 0 00.996 1.73l3 1.74a2 2 0 002.008 0l3-1.74A2 2 0 0012 18.26v-3.517a2 2 0 00-.995-1.73l-3-1.742a2 2 0 00-1.892-.064z",key:"h4qck"}],["path",{d:"M7 16.5V22",key:"1i1gou"}]],Ha=ma("file-box",Wa);/**
6
+ */const Ha=[["path",{d:"M14 2v5a1 1 0 001 1h5",key:"9v5fu7"}],["path",{d:"M14.692 22H18a2 2 0 002-2V8a2.4 2.4 0 00-.706-1.706l-3.588-3.588A2.4 2.4 0 0014 2H6a2 2 0 00-2 2v3.804",key:"1ne0j7"}],["path",{d:"M2.264 13.752 7 16.5l4.737-2.748",key:"t73mg3"}],["path",{d:"M2.995 13.014A2 2 0 002 14.744v3.516a2 2 0 00.996 1.73l3 1.74a2 2 0 002.008 0l3-1.74A2 2 0 0012 18.26v-3.517a2 2 0 00-.995-1.73l-3-1.742a2 2 0 00-1.892-.064z",key:"h4qck"}],["path",{d:"M7 16.5V22",key:"1i1gou"}]],Va=ma("file-box",Ha);/**
7
7
  * @license lucide-react v1.27.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Va=[["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"M16 17h6",key:"1ook5g"}],["path",{d:"M19 14v6",key:"1ckrd5"}],["path",{d:"M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955",key:"28k6lz"}],["path",{d:"M3.29 7 12 12l8.71-5",key:"19ckod"}],["path",{d:"m7.5 4.27 8.997 5.148",key:"9yrvtv"}]],Ja=ma("package-plus",Va);var Z=Uint8Array,ne=Uint16Array,ea=Int32Array,Oe=new Z([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ze=new Z([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),He=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fa=function(e,a){for(var r=new ne(31),n=0;n<31;++n)r[n]=a+=1<<e[n-1];for(var s=new ea(r[30]),n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)s[i]=i-r[n]<<5|n;return{b:r,r:s}},ga=fa(Oe,2),ha=ga.b,Ve=ga.r;ha[28]=258,Ve[258]=28;var va=fa(ze,0),_a=va.b,na=va.r,Je=new ne(32768);for(var W=0;W<32768;++W){var ge=(W&43690)>>1|(W&21845)<<1;ge=(ge&52428)>>2|(ge&13107)<<2,ge=(ge&61680)>>4|(ge&3855)<<4,Je[W]=((ge&65280)>>8|(ge&255)<<8)>>1}var ce=(function(e,a,r){for(var n=e.length,s=0,i=new ne(a);s<n;++s)e[s]&&++i[e[s]-1];var l=new ne(a);for(s=1;s<a;++s)l[s]=l[s-1]+i[s-1]<<1;var g;if(r){g=new ne(1<<a);var o=15-a;for(s=0;s<n;++s)if(e[s])for(var v=s<<4|e[s],d=a-e[s],c=l[e[s]-1]++<<d,u=c|(1<<d)-1;c<=u;++c)g[Je[c]>>o]=v}else for(g=new ne(n),s=0;s<n;++s)e[s]&&(g[s]=Je[l[e[s]-1]++]>>15-e[s]);return g}),xe=new Z(288);for(var W=0;W<144;++W)xe[W]=8;for(var W=144;W<256;++W)xe[W]=9;for(var W=256;W<280;++W)xe[W]=7;for(var W=280;W<288;++W)xe[W]=8;var Pe=new Z(32);for(var W=0;W<32;++W)Pe[W]=5;var Ga=ce(xe,9,0),Ya=ce(xe,9,1),Za=ce(Pe,5,0),Qa=ce(Pe,5,1),Be=function(e){for(var a=e[0],r=1;r<e.length;++r)e[r]>a&&(a=e[r]);return a},ie=function(e,a,r){var n=a/8|0;return(e[n]|e[n+1]<<8)>>(a&7)&r},Te=function(e,a){var r=a/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(a&7)},aa=function(e){return(e+7)/8|0},Se=function(e,a,r){return(a==null||a<0)&&(a=0),(r==null||r>e.length)&&(r=e.length),new Z(e.subarray(a,r))},Xa=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],te=function(e,a,r){var n=new Error(a||Xa[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,te),!r)throw n;return n},et=function(e,a,r,n){var s=e.length,i=n?n.length:0;if(!s||a.f&&!a.l)return r||new Z(0);var l=!r,g=l||a.i!=2,o=a.i;l&&(r=new Z(s*3));var v=function(pe){var fe=r.length;if(pe>fe){var de=new Z(Math.max(fe*2,pe));de.set(r),r=de}},d=a.f||0,c=a.p||0,u=a.b||0,y=a.l,m=a.d,w=a.m,P=a.n,N=s*8;do{if(!y){d=ie(e,c,1);var b=ie(e,c+1,3);if(c+=3,b)if(b==1)y=Ya,m=Qa,w=9,P=5;else if(b==2){var U=ie(e,c,31)+257,F=ie(e,c+10,15)+4,C=U+ie(e,c+5,31)+1;c+=14;for(var j=new Z(C),O=new Z(19),$=0;$<F;++$)O[He[$]]=ie(e,c+$*3,7);c+=F*3;for(var B=Be(O),q=(1<<B)-1,h=ce(O,B,1),$=0;$<C;){var E=h[ie(e,c,q)];c+=E&15;var S=E>>4;if(S<16)j[$++]=S;else{var R=0,I=0;for(S==16?(I=3+ie(e,c,3),c+=2,R=j[$-1]):S==17?(I=3+ie(e,c,7),c+=3):S==18&&(I=11+ie(e,c,127),c+=7);I--;)j[$++]=R}}var T=j.subarray(0,U),x=j.subarray(U);w=Be(T),P=Be(x),y=ce(T,w,1),m=ce(x,P,1)}else te(1);else{var S=aa(c)+4,M=e[S-4]|e[S-3]<<8,D=S+M;if(D>s){o&&te(0);break}g&&v(u+M),r.set(e.subarray(S,D),u),a.b=u+=M,a.p=c=D*8,a.f=d;continue}if(c>N){o&&te(0);break}}g&&v(u+131072);for(var L=(1<<w)-1,H=(1<<P)-1,Y=c;;Y=c){var R=y[Te(e,c)&L],J=R>>4;if(c+=R&15,c>N){o&&te(0);break}if(R||te(2),J<256)r[u++]=J;else if(J==256){Y=c,y=null;break}else{var f=J-254;if(J>264){var $=J-257,k=Oe[$];f=ie(e,c,(1<<k)-1)+ha[$],c+=k}var G=m[Te(e,c)&H],Q=G>>4;G||te(3),c+=G&15;var x=_a[Q];if(Q>3){var k=ze[Q];x+=Te(e,c)&(1<<k)-1,c+=k}if(c>N){o&&te(0);break}g&&v(u+131072);var ae=u+f;if(u<x){var se=i-x,ke=Math.min(x,ae);for(se+u<0&&te(3);u<ke;++u)r[u]=n[se+u]}for(;u<ae;++u)r[u]=r[u-x]}}a.l=y,a.p=Y,a.b=u,a.f=d,y&&(d=1,a.m=w,a.d=m,a.n=P)}while(!d);return u!=r.length&&l?Se(r,0,u):r.subarray(0,u)},me=function(e,a,r){r<<=a&7;var n=a/8|0;e[n]|=r,e[n+1]|=r>>8},Ne=function(e,a,r){r<<=a&7;var n=a/8|0;e[n]|=r,e[n+1]|=r>>8,e[n+2]|=r>>16},qe=function(e,a){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var s=r.length,i=r.slice();if(!s)return{t:ka,l:0};if(s==1){var l=new Z(r[0].s+1);return l[r[0].s]=1,{t:l,l:1}}r.sort(function(D,U){return D.f-U.f}),r.push({s:-1,f:25001});var g=r[0],o=r[1],v=0,d=1,c=2;for(r[0]={s:-1,f:g.f+o.f,l:g,r:o};d!=s-1;)g=r[r[v].f<r[c].f?v++:c++],o=r[v!=d&&r[v].f<r[c].f?v++:c++],r[d++]={s:-1,f:g.f+o.f,l:g,r:o};for(var u=i[0].s,n=1;n<s;++n)i[n].s>u&&(u=i[n].s);var y=new ne(u+1),m=_e(r[d-1],y,0);if(m>a){var n=0,w=0,P=m-a,N=1<<P;for(i.sort(function(U,F){return y[F.s]-y[U.s]||U.f-F.f});n<s;++n){var b=i[n].s;if(y[b]>a)w+=N-(1<<m-y[b]),y[b]=a;else break}for(w>>=P;w>0;){var S=i[n].s;y[S]<a?w-=1<<a-y[S]++-1:++n}for(;n>=0&&w;--n){var M=i[n].s;y[M]==a&&(--y[M],++w)}m=a}return{t:new Z(y),l:m}},_e=function(e,a,r){return e.s==-1?Math.max(_e(e.l,a,r+1),_e(e.r,a,r+1)):a[e.s]=r},sa=function(e){for(var a=e.length;a&&!e[--a];);for(var r=new ne(++a),n=0,s=e[0],i=1,l=function(o){r[n++]=o},g=1;g<=a;++g)if(e[g]==s&&g!=a)++i;else{if(!s&&i>2){for(;i>138;i-=138)l(32754);i>2&&(l(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(l(s),--i;i>6;i-=6)l(8304);i>2&&(l(i-3<<5|8208),i=0)}for(;i--;)l(s);i=1,s=e[g]}return{c:r.subarray(0,n),n:a}},Ce=function(e,a){for(var r=0,n=0;n<a.length;++n)r+=e[n]*a[n];return r},xa=function(e,a,r){var n=r.length,s=aa(a+2);e[s]=n&255,e[s+1]=n>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var i=0;i<n;++i)e[s+i+4]=r[i];return(s+4+n)*8},oa=function(e,a,r,n,s,i,l,g,o,v,d){me(a,d++,r),++s[256];for(var c=qe(s,15),u=c.t,y=c.l,m=qe(i,15),w=m.t,P=m.l,N=sa(u),b=N.c,S=N.n,M=sa(w),D=M.c,U=M.n,F=new ne(19),C=0;C<b.length;++C)++F[b[C]&31];for(var C=0;C<D.length;++C)++F[D[C]&31];for(var j=qe(F,7),O=j.t,$=j.l,B=19;B>4&&!O[He[B-1]];--B);var q=v+5<<3,h=Ce(s,xe)+Ce(i,Pe)+l,E=Ce(s,u)+Ce(i,w)+l+14+3*B+Ce(F,O)+2*F[16]+3*F[17]+7*F[18];if(o>=0&&q<=h&&q<=E)return xa(a,d,e.subarray(o,o+v));var R,I,T,x;if(me(a,d,1+(E<h)),d+=2,E<h){R=ce(u,y,0),I=u,T=ce(w,P,0),x=w;var L=ce(O,$,0);me(a,d,S-257),me(a,d+5,U-1),me(a,d+10,B-4),d+=14;for(var C=0;C<B;++C)me(a,d+3*C,O[He[C]]);d+=3*B;for(var H=[b,D],Y=0;Y<2;++Y)for(var J=H[Y],C=0;C<J.length;++C){var f=J[C]&31;me(a,d,L[f]),d+=O[f],f>15&&(me(a,d,J[C]>>5&127),d+=J[C]>>12)}}else R=Ga,I=xe,T=Za,x=Pe;for(var C=0;C<g;++C){var k=n[C];if(k>255){var f=k>>18&31;Ne(a,d,R[f+257]),d+=I[f+257],f>7&&(me(a,d,k>>23&31),d+=Oe[f]);var G=k&31;Ne(a,d,T[G]),d+=x[G],G>3&&(Ne(a,d,k>>5&8191),d+=ze[G])}else Ne(a,d,R[k]),d+=I[k]}return Ne(a,d,R[256]),d+I[256]},at=new ea([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ka=new Z(0),tt=function(e,a,r,n,s,i){var l=i.z||e.length,g=new Z(n+l+5*(1+Math.ceil(l/7e3))+s),o=g.subarray(n,g.length-s),v=i.l,d=(i.r||0)&7;if(a){d&&(o[0]=i.r>>3);for(var c=at[a-1],u=c>>13,y=c&8191,m=(1<<r)-1,w=i.p||new ne(32768),P=i.h||new ne(m+1),N=Math.ceil(r/3),b=2*N,S=function(ye){return(e[ye]^e[ye+1]<<N^e[ye+2]<<b)&m},M=new ea(25e3),D=new ne(288),U=new ne(32),F=0,C=0,j=i.i||0,O=0,$=i.w||0,B=0;j+2<l;++j){var q=S(j),h=j&32767,E=P[q];if(w[h]=E,P[q]=h,$<=j){var R=l-j;if((F>7e3||O>24576)&&(R>423||!v)){d=oa(e,o,0,M,D,U,C,O,B,j-B,d),O=F=C=0,B=j;for(var I=0;I<286;++I)D[I]=0;for(var I=0;I<30;++I)U[I]=0}var T=2,x=0,L=y,H=h-E&32767;if(R>2&&q==S(j-H))for(var Y=Math.min(u,R)-1,J=Math.min(32767,j),f=Math.min(258,R);H<=J&&--L&&h!=E;){if(e[j+T]==e[j+T-H]){for(var k=0;k<f&&e[j+k]==e[j+k-H];++k);if(k>T){if(T=k,x=H,k>Y)break;for(var G=Math.min(H,k-2),Q=0,I=0;I<G;++I){var ae=j-H+I&32767,se=w[ae],ke=ae-se&32767;ke>Q&&(Q=ke,E=ae)}}}h=E,E=w[h],H+=h-E&32767}if(x){M[O++]=268435456|Ve[T]<<18|na[x];var pe=Ve[T]&31,fe=na[x]&31;C+=Oe[pe]+ze[fe],++D[257+pe],++U[fe],$=j+T,++F}else M[O++]=e[j],++D[e[j]]}}for(j=Math.max(j,$);j<l;++j)M[O++]=e[j],++D[e[j]];d=oa(e,o,v,M,D,U,C,O,B,j-B,d),v||(i.r=d&7|o[d/8|0]<<3,d-=7,i.h=P,i.p=w,i.i=j,i.w=$)}else{for(var j=i.w||0;j<l+v;j+=65535){var de=j+65535;de>=l&&(o[d/8|0]=v,de=l),d=xa(o,d+1,e.subarray(j,de))}i.i=l}return Se(g,0,n+aa(d)+s)},rt=(function(){for(var e=new Int32Array(256),a=0;a<256;++a){for(var r=a,n=9;--n;)r=(r&1&&-306674912)^r>>>1;e[a]=r}return e})(),nt=function(){var e=-1;return{p:function(a){for(var r=e,n=0;n<a.length;++n)r=rt[r&255^a[n]]^r>>>8;e=r},d:function(){return~e}}},st=function(e,a,r,n,s){if(!s&&(s={l:1},a.dictionary)){var i=a.dictionary.subarray(-32768),l=new Z(i.length+e.length);l.set(i),l.set(e,i.length),e=l,s.w=i.length}return tt(e,a.level==null?6:a.level,a.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+a.mem,r,n,s)},wa=function(e,a){var r={};for(var n in e)r[n]=e[n];for(var n in a)r[n]=a[n];return r},le=function(e,a){return e[a]|e[a+1]<<8},oe=function(e,a){return(e[a]|e[a+1]<<8|e[a+2]<<16|e[a+3]<<24)>>>0},Ke=function(e,a){return oe(e,a)+oe(e,a+4)*4294967296},ee=function(e,a,r){for(;r;++a)e[a]=r,r>>>=8};function ot(e,a){return st(e,a||{},0,0)}function it(e,a){return et(e,{i:2},a&&a.out,a&&a.dictionary)}var ya=function(e,a,r,n){for(var s in e){var i=e[s],l=a+s,g=n;Array.isArray(i)&&(g=wa(n,i[1]),i=i[0]),ArrayBuffer.isView(i)?r[l]=[i,g]:(r[l+="/"]=[new Z(0),g],ya(i,l,r,n))}},ia=typeof TextEncoder<"u"&&new TextEncoder,Ge=typeof TextDecoder<"u"&&new TextDecoder,lt=0;try{Ge.decode(ka,{stream:!0}),lt=1}catch{}var ct=function(e){for(var a="",r=0;;){var n=e[r++],s=(n>127)+(n>223)+(n>239);if(r+s>e.length)return{s:a,r:Se(e,r-1)};s?s==3?(n=((n&15)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,a+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?a+=String.fromCharCode((n&31)<<6|e[r++]&63):a+=String.fromCharCode((n&15)<<12|(e[r++]&63)<<6|e[r++]&63):a+=String.fromCharCode(n)}};function Ee(e,a){var r;if(ia)return ia.encode(e);for(var n=e.length,s=new Z(e.length+(e.length>>1)),i=0,l=function(v){s[i++]=v},r=0;r<n;++r){if(i+5>s.length){var g=new Z(i+8+(n-r<<1));g.set(s),s=g}var o=e.charCodeAt(r);o<128||a?l(o):o<2048?(l(192|o>>6),l(128|o&63)):o>55295&&o<57344?(o=65536+(o&1047552)|e.charCodeAt(++r)&1023,l(240|o>>18),l(128|o>>12&63),l(128|o>>6&63),l(128|o&63)):(l(224|o>>12),l(128|o>>6&63),l(128|o&63))}return Se(s,0,i)}function dt(e,a){if(a){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}else{if(Ge)return Ge.decode(e);var s=ct(e),i=s.s,r=s.r;return r.length&&te(8),i}}var mt=function(e,a){return a+30+le(e,a+26)+le(e,a+28)},ut=function(e,a,r){var n=le(e,a+28),s=le(e,a+30),i=dt(e.subarray(a+46,a+46+n),!(le(e,a+8)&2048)),l=a+46+n,g=pt(e,l,s,r,oe(e,a+20),oe(e,a+24),oe(e,a+42)),o=g[0],v=g[1],d=g[2];return[le(e,a+10),o,v,i,l+s+le(e,a+32),d]},pt=function(e,a,r,n,s,i,l){var g=s==4294967295,o=i==4294967295,v=l==4294967295,d=a+r,c=g+o+v;if(n&&c){for(;a+4<d;a+=4+le(e,a+2))if(le(e,a)==1)return[g?Ke(e,a+4+8*o):s,o?Ke(e,a+4):i,v?Ke(e,a+4+8*(o+g)):l,1];n<2&&te(13)}return[s,i,l,0]},Ye=function(e){var a=0;if(e)for(var r in e){var n=e[r].length;n>65535&&te(9),a+=n+4}return a},la=function(e,a,r,n,s,i,l,g){var o=n.length,v=r.extra,d=g&&g.length,c=Ye(v);ee(e,a,l!=null?33639248:67324752),a+=4,l!=null&&(e[a++]=20,e[a++]=r.os),e[a]=20,a+=2,e[a++]=r.flag<<1|(i<0&&8),e[a++]=s&&8,e[a++]=r.compression&255,e[a++]=r.compression>>8;var u=new Date(r.mtime==null?Date.now():r.mtime),y=u.getFullYear()-1980;if((y<0||y>119)&&te(10),ee(e,a,y<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>1),a+=4,i!=-1&&(ee(e,a,r.crc),ee(e,a+4,i<0?-i-2:i),ee(e,a+8,r.size)),ee(e,a+12,o),ee(e,a+14,c),a+=16,l!=null&&(ee(e,a,d),ee(e,a+6,r.attrs),ee(e,a+10,l),a+=14),e.set(n,a),a+=o,c)for(var m in v){var w=v[m],P=w.length;ee(e,a,+m),ee(e,a+2,P),e.set(w,a+4),a+=4+P}return d&&(e.set(g,a),a+=d),a},ft=function(e,a,r,n,s){ee(e,a,101010256),ee(e,a+8,r),ee(e,a+10,r),ee(e,a+12,n),ee(e,a+16,s)};function gt(e,a){a||(a={});var r={},n=[];ya(e,"",r,a);var s=0,i=0;for(var l in r){var g=r[l],o=g[0],v=g[1],d=v.level==0?0:8,c=Ee(l),u=c.length,y=v.comment,m=y&&Ee(y),w=m&&m.length,P=Ye(v.extra);u>65535&&te(11);var N=d?ot(o,v):o,b=N.length,S=nt();S.p(o),n.push(wa(v,{size:o.length,crc:S.d(),c:N,f:c,m,u:u!=l.length||m&&y.length!=w,o:s,compression:d})),s+=30+u+P+b,i+=76+2*(u+P)+(w||0)+b}for(var M=new Z(i+22),D=s,U=i-s,F=0;F<n.length;++F){var c=n[F];la(M,c.o,c,c.f,c.u,c.c.length);var C=30+c.f.length+Ye(c.extra);M.set(c.c,c.o+C),la(M,s,c,c.f,c.u,c.c.length,c.o,c.m),s+=16+C+(c.m?c.m.length:0)}return ft(M,s,n.length,U,D),M}function ht(e,a){for(var r={},n=e.length-22;oe(e,n)!=101010256;--n)(!n||e.length-n>65558)&&te(13);var s=le(e,n+8);if(!s)return{};var i=oe(e,n+16),l=oe(e,n-20)==117853008;if(l){var g=oe(e,n-12);l=oe(e,g)==101075792,l&&(s=oe(e,g+32),i=oe(e,g+48))}for(var o=a&&a.filter,v=0;v<s;++v){var d=ut(e,i,l),c=d[0],u=d[1],y=d[2],m=d[3],w=d[4],P=d[5],N=mt(e,P);i=w,(!o||o({name:m,size:u,originalSize:y,compression:c}))&&(c?c==8?r[m]=it(e.subarray(N,N+u),{out:new Z(y)}):te(14,"unknown compression type "+c):r[m]=Se(e,N,N+u))}return r}function ja({files:e,readOnly:a=!1,onChange:r,testId:n}){var c,u,y;const[s,i]=we(a?"packageFile":"packageDraftFile",((c=e[0])==null?void 0:c.path)??""),[l,g]=we("editorMode",a?"read":"edit",["read","edit","split"]),[o,v]=z.useState([((u=e[0])==null?void 0:u.path)??""]),d=e.some(m=>m.path===s)?s:(y=e[0])==null?void 0:y.path;return t.jsxs("div",{className:"min-w-0 overflow-hidden rounded-lg border border-surface-highest",children:[t.jsx("div",{role:"tablist","aria-label":"Package files",className:"flex overflow-x-auto bg-background",children:e.map(m=>t.jsx("button",{type:"button",role:"tab","aria-selected":d===m.path,"data-testid":"package-file","data-file-name":m.path,title:m.path,className:`shrink-0 border-r border-surface-highest px-4 py-3 text-sm ${d===m.path?"border-t-2 border-t-transparent bg-surface-highest text-on-surface":"border-t-2 border-t-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,onClick:()=>{i(m.path),v(w=>w.includes(m.path)?w:[...w,m.path])},onKeyDown:w=>{var M;const P=e.findIndex(D=>D.path===m.path),N=w.key==="ArrowRight"?P+1:w.key==="ArrowLeft"?P-1:void 0;if(N===void 0)return;w.preventDefault();const b=(M=w.currentTarget.parentElement)==null?void 0:M.querySelectorAll('[role="tab"]'),S=b==null?void 0:b[(N+e.length)%e.length];S==null||S.focus(),S==null||S.click()},children:m.path.endsWith("/SKILL.md")?m.path.split("/").slice(-2).join("/"):m.path.split("/").pop()},m.path))}),e.filter(m=>o.includes(m.path)||d===m.path).map(m=>t.jsxs("div",{role:"tabpanel","aria-label":m.path,hidden:d!==m.path,className:"[&_[data-testid=code-editor]>div>span[title]]:hidden [&_[data-testid=markdown-editor]>div>span[title]]:hidden",children:[t.jsx(Fe,{mode:Ca(m.path)?l:void 0,onModeChange:g,path:m.path,value:m.content,onChange:r?w=>r(m.path,w):void 0,readOnly:a||m.encoding==="base64",height:420,testId:d===m.path?n:void 0}),m.encoding==="base64"&&t.jsx("p",{className:"px-4 py-2 text-xs text-outline",children:"Binary asset shown as base64."})]},m.path))]})}function vt({name:e,onClose:a,onUse:r,onEdit:n,onExport:s,onSource:i,busy:l,operationError:g}){var d,c,u,y;const o=ve({queryKey:["agent-package",e],queryFn:()=>V.agentPackages.get(e)}),v=ve({enabled:!!o.data,queryKey:["agent-package-files",e],queryFn:async()=>{const m=o.data;if(!m)return[];const w=await Promise.all(m.files.map(async P=>{const N=await V.agentPackages.get(e,P.name);return{path:P.name,content:N.content,encoding:N.encoding}}));return[{path:m.manifestFile,content:m.content},...w]}});return t.jsx(Pa,{open:!0,onOpenChange:m=>{m||a()},children:t.jsxs(Sa,{className:"w-screen max-w-full sm:w-[720px] sm:max-w-[90vw]",children:[t.jsx(Aa,{children:t.jsx(Ma,{children:e})}),t.jsxs(Fa,{children:[t.jsxs("div",{className:"mb-5 space-y-3",children:[t.jsx("p",{className:"text-sm text-outline break-words",children:(d=o.data)==null?void 0:d.description}),o.data&&t.jsxs("p",{className:"text-xs text-outline",children:[o.data.files.filter(m=>/(^|\/)SKILL\.md$/.test(m.name)).length," ","skills ·"," ",o.data.files.filter(m=>m.name.endsWith(".instructions.md")).length," ","instruction files ·"," ",o.data.files.filter(m=>m.name.endsWith(".agent.md")).length," agent definitions"]}),(c=o.data)==null?void 0:c.warnings.map(m=>t.jsx("p",{role:"alert",className:"text-xs text-destructive break-words",children:m},m)),t.jsxs("div",{className:"grid gap-2 grid-cols-2",children:[r&&t.jsx(_,{"data-testid":"package-detail-run",onClick:r,disabled:l,children:"Use package"}),n&&t.jsx(_,{"data-testid":"package-edit",variant:"outline",onClick:n,disabled:l,children:"Edit configuration"}),s&&t.jsx(_,{"data-testid":"package-export-artifact",variant:"outline",onClick:s,disabled:l,children:l?"Preparing…":"Export for installation"}),i&&t.jsx(_,{"data-testid":"package-export",variant:"outline",onClick:i,disabled:l,children:"Download source"})]}),t.jsxs("p",{className:"text-xs text-outline",children:["APM builds installation exports (",((u=o.data)==null?void 0:u.format)==="agent-plugin"?"portable Agent Plugin":"Claude plugin","). Download source preserves the editable manifest and all files."]}),g&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g})]}),o.error||v.error?t.jsx("p",{role:"alert",children:(y=o.error??v.error)==null?void 0:y.message}):v.isLoading?t.jsx("p",{children:"Loading files…"}):t.jsx(ja,{files:v.data??[],readOnly:!0,testId:"package-file-content"})]})]})})}const ba="https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",xt="https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";function Ae(e){return e==="apm"?`name: my-agent-package
11
+ */const Ja=[["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"M16 17h6",key:"1ook5g"}],["path",{d:"M19 14v6",key:"1ckrd5"}],["path",{d:"M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955",key:"28k6lz"}],["path",{d:"M3.29 7 12 12l8.71-5",key:"19ckod"}],["path",{d:"m7.5 4.27 8.997 5.148",key:"9yrvtv"}]],_a=ma("package-plus",Ja);var Z=Uint8Array,ne=Uint16Array,ea=Int32Array,Oe=new Z([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ze=new Z([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),He=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fa=function(e,a){for(var r=new ne(31),n=0;n<31;++n)r[n]=a+=1<<e[n-1];for(var s=new ea(r[30]),n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)s[i]=i-r[n]<<5|n;return{b:r,r:s}},ga=fa(Oe,2),ha=ga.b,Ve=ga.r;ha[28]=258,Ve[258]=28;var va=fa(ze,0),Ga=va.b,na=va.r,Je=new ne(32768);for(var W=0;W<32768;++W){var ge=(W&43690)>>1|(W&21845)<<1;ge=(ge&52428)>>2|(ge&13107)<<2,ge=(ge&61680)>>4|(ge&3855)<<4,Je[W]=((ge&65280)>>8|(ge&255)<<8)>>1}var ce=(function(e,a,r){for(var n=e.length,s=0,i=new ne(a);s<n;++s)e[s]&&++i[e[s]-1];var l=new ne(a);for(s=1;s<a;++s)l[s]=l[s-1]+i[s-1]<<1;var g;if(r){g=new ne(1<<a);var o=15-a;for(s=0;s<n;++s)if(e[s])for(var v=s<<4|e[s],d=a-e[s],c=l[e[s]-1]++<<d,u=c|(1<<d)-1;c<=u;++c)g[Je[c]>>o]=v}else for(g=new ne(n),s=0;s<n;++s)e[s]&&(g[s]=Je[l[e[s]-1]++]>>15-e[s]);return g}),xe=new Z(288);for(var W=0;W<144;++W)xe[W]=8;for(var W=144;W<256;++W)xe[W]=9;for(var W=256;W<280;++W)xe[W]=7;for(var W=280;W<288;++W)xe[W]=8;var Pe=new Z(32);for(var W=0;W<32;++W)Pe[W]=5;var Ya=ce(xe,9,0),Za=ce(xe,9,1),Qa=ce(Pe,5,0),Xa=ce(Pe,5,1),qe=function(e){for(var a=e[0],r=1;r<e.length;++r)e[r]>a&&(a=e[r]);return a},ie=function(e,a,r){var n=a/8|0;return(e[n]|e[n+1]<<8)>>(a&7)&r},Re=function(e,a){var r=a/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(a&7)},aa=function(e){return(e+7)/8|0},Se=function(e,a,r){return(a==null||a<0)&&(a=0),(r==null||r>e.length)&&(r=e.length),new Z(e.subarray(a,r))},et=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],te=function(e,a,r){var n=new Error(a||et[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,te),!r)throw n;return n},at=function(e,a,r,n){var s=e.length,i=n?n.length:0;if(!s||a.f&&!a.l)return r||new Z(0);var l=!r,g=l||a.i!=2,o=a.i;l&&(r=new Z(s*3));var v=function(pe){var fe=r.length;if(pe>fe){var de=new Z(Math.max(fe*2,pe));de.set(r),r=de}},d=a.f||0,c=a.p||0,u=a.b||0,y=a.l,m=a.d,w=a.m,P=a.n,N=s*8;do{if(!y){d=ie(e,c,1);var b=ie(e,c+1,3);if(c+=3,b)if(b==1)y=Za,m=Xa,w=9,P=5;else if(b==2){var T=ie(e,c,31)+257,F=ie(e,c+10,15)+4,C=T+ie(e,c+5,31)+1;c+=14;for(var j=new Z(C),O=new Z(19),E=0;E<F;++E)O[He[E]]=ie(e,c+E*3,7);c+=F*3;for(var q=qe(O),U=(1<<q)-1,h=ce(O,q,1),E=0;E<C;){var $=h[ie(e,c,U)];c+=$&15;var S=$>>4;if(S<16)j[E++]=S;else{var B=0,I=0;for(S==16?(I=3+ie(e,c,3),c+=2,B=j[E-1]):S==17?(I=3+ie(e,c,7),c+=3):S==18&&(I=11+ie(e,c,127),c+=7);I--;)j[E++]=B}}var R=j.subarray(0,T),x=j.subarray(T);w=qe(R),P=qe(x),y=ce(R,w,1),m=ce(x,P,1)}else te(1);else{var S=aa(c)+4,M=e[S-4]|e[S-3]<<8,D=S+M;if(D>s){o&&te(0);break}g&&v(u+M),r.set(e.subarray(S,D),u),a.b=u+=M,a.p=c=D*8,a.f=d;continue}if(c>N){o&&te(0);break}}g&&v(u+131072);for(var L=(1<<w)-1,H=(1<<P)-1,Y=c;;Y=c){var B=y[Re(e,c)&L],J=B>>4;if(c+=B&15,c>N){o&&te(0);break}if(B||te(2),J<256)r[u++]=J;else if(J==256){Y=c,y=null;break}else{var f=J-254;if(J>264){var E=J-257,k=Oe[E];f=ie(e,c,(1<<k)-1)+ha[E],c+=k}var G=m[Re(e,c)&H],Q=G>>4;G||te(3),c+=G&15;var x=Ga[Q];if(Q>3){var k=ze[Q];x+=Re(e,c)&(1<<k)-1,c+=k}if(c>N){o&&te(0);break}g&&v(u+131072);var ae=u+f;if(u<x){var se=i-x,ke=Math.min(x,ae);for(se+u<0&&te(3);u<ke;++u)r[u]=n[se+u]}for(;u<ae;++u)r[u]=r[u-x]}}a.l=y,a.p=Y,a.b=u,a.f=d,y&&(d=1,a.m=w,a.d=m,a.n=P)}while(!d);return u!=r.length&&l?Se(r,0,u):r.subarray(0,u)},me=function(e,a,r){r<<=a&7;var n=a/8|0;e[n]|=r,e[n+1]|=r>>8},Ne=function(e,a,r){r<<=a&7;var n=a/8|0;e[n]|=r,e[n+1]|=r>>8,e[n+2]|=r>>16},Ue=function(e,a){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var s=r.length,i=r.slice();if(!s)return{t:ka,l:0};if(s==1){var l=new Z(r[0].s+1);return l[r[0].s]=1,{t:l,l:1}}r.sort(function(D,T){return D.f-T.f}),r.push({s:-1,f:25001});var g=r[0],o=r[1],v=0,d=1,c=2;for(r[0]={s:-1,f:g.f+o.f,l:g,r:o};d!=s-1;)g=r[r[v].f<r[c].f?v++:c++],o=r[v!=d&&r[v].f<r[c].f?v++:c++],r[d++]={s:-1,f:g.f+o.f,l:g,r:o};for(var u=i[0].s,n=1;n<s;++n)i[n].s>u&&(u=i[n].s);var y=new ne(u+1),m=_e(r[d-1],y,0);if(m>a){var n=0,w=0,P=m-a,N=1<<P;for(i.sort(function(T,F){return y[F.s]-y[T.s]||T.f-F.f});n<s;++n){var b=i[n].s;if(y[b]>a)w+=N-(1<<m-y[b]),y[b]=a;else break}for(w>>=P;w>0;){var S=i[n].s;y[S]<a?w-=1<<a-y[S]++-1:++n}for(;n>=0&&w;--n){var M=i[n].s;y[M]==a&&(--y[M],++w)}m=a}return{t:new Z(y),l:m}},_e=function(e,a,r){return e.s==-1?Math.max(_e(e.l,a,r+1),_e(e.r,a,r+1)):a[e.s]=r},sa=function(e){for(var a=e.length;a&&!e[--a];);for(var r=new ne(++a),n=0,s=e[0],i=1,l=function(o){r[n++]=o},g=1;g<=a;++g)if(e[g]==s&&g!=a)++i;else{if(!s&&i>2){for(;i>138;i-=138)l(32754);i>2&&(l(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(l(s),--i;i>6;i-=6)l(8304);i>2&&(l(i-3<<5|8208),i=0)}for(;i--;)l(s);i=1,s=e[g]}return{c:r.subarray(0,n),n:a}},Ce=function(e,a){for(var r=0,n=0;n<a.length;++n)r+=e[n]*a[n];return r},xa=function(e,a,r){var n=r.length,s=aa(a+2);e[s]=n&255,e[s+1]=n>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var i=0;i<n;++i)e[s+i+4]=r[i];return(s+4+n)*8},oa=function(e,a,r,n,s,i,l,g,o,v,d){me(a,d++,r),++s[256];for(var c=Ue(s,15),u=c.t,y=c.l,m=Ue(i,15),w=m.t,P=m.l,N=sa(u),b=N.c,S=N.n,M=sa(w),D=M.c,T=M.n,F=new ne(19),C=0;C<b.length;++C)++F[b[C]&31];for(var C=0;C<D.length;++C)++F[D[C]&31];for(var j=Ue(F,7),O=j.t,E=j.l,q=19;q>4&&!O[He[q-1]];--q);var U=v+5<<3,h=Ce(s,xe)+Ce(i,Pe)+l,$=Ce(s,u)+Ce(i,w)+l+14+3*q+Ce(F,O)+2*F[16]+3*F[17]+7*F[18];if(o>=0&&U<=h&&U<=$)return xa(a,d,e.subarray(o,o+v));var B,I,R,x;if(me(a,d,1+($<h)),d+=2,$<h){B=ce(u,y,0),I=u,R=ce(w,P,0),x=w;var L=ce(O,E,0);me(a,d,S-257),me(a,d+5,T-1),me(a,d+10,q-4),d+=14;for(var C=0;C<q;++C)me(a,d+3*C,O[He[C]]);d+=3*q;for(var H=[b,D],Y=0;Y<2;++Y)for(var J=H[Y],C=0;C<J.length;++C){var f=J[C]&31;me(a,d,L[f]),d+=O[f],f>15&&(me(a,d,J[C]>>5&127),d+=J[C]>>12)}}else B=Ya,I=xe,R=Qa,x=Pe;for(var C=0;C<g;++C){var k=n[C];if(k>255){var f=k>>18&31;Ne(a,d,B[f+257]),d+=I[f+257],f>7&&(me(a,d,k>>23&31),d+=Oe[f]);var G=k&31;Ne(a,d,R[G]),d+=x[G],G>3&&(Ne(a,d,k>>5&8191),d+=ze[G])}else Ne(a,d,B[k]),d+=I[k]}return Ne(a,d,B[256]),d+I[256]},tt=new ea([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ka=new Z(0),rt=function(e,a,r,n,s,i){var l=i.z||e.length,g=new Z(n+l+5*(1+Math.ceil(l/7e3))+s),o=g.subarray(n,g.length-s),v=i.l,d=(i.r||0)&7;if(a){d&&(o[0]=i.r>>3);for(var c=tt[a-1],u=c>>13,y=c&8191,m=(1<<r)-1,w=i.p||new ne(32768),P=i.h||new ne(m+1),N=Math.ceil(r/3),b=2*N,S=function(ye){return(e[ye]^e[ye+1]<<N^e[ye+2]<<b)&m},M=new ea(25e3),D=new ne(288),T=new ne(32),F=0,C=0,j=i.i||0,O=0,E=i.w||0,q=0;j+2<l;++j){var U=S(j),h=j&32767,$=P[U];if(w[h]=$,P[U]=h,E<=j){var B=l-j;if((F>7e3||O>24576)&&(B>423||!v)){d=oa(e,o,0,M,D,T,C,O,q,j-q,d),O=F=C=0,q=j;for(var I=0;I<286;++I)D[I]=0;for(var I=0;I<30;++I)T[I]=0}var R=2,x=0,L=y,H=h-$&32767;if(B>2&&U==S(j-H))for(var Y=Math.min(u,B)-1,J=Math.min(32767,j),f=Math.min(258,B);H<=J&&--L&&h!=$;){if(e[j+R]==e[j+R-H]){for(var k=0;k<f&&e[j+k]==e[j+k-H];++k);if(k>R){if(R=k,x=H,k>Y)break;for(var G=Math.min(H,k-2),Q=0,I=0;I<G;++I){var ae=j-H+I&32767,se=w[ae],ke=ae-se&32767;ke>Q&&(Q=ke,$=ae)}}}h=$,$=w[h],H+=h-$&32767}if(x){M[O++]=268435456|Ve[R]<<18|na[x];var pe=Ve[R]&31,fe=na[x]&31;C+=Oe[pe]+ze[fe],++D[257+pe],++T[fe],E=j+R,++F}else M[O++]=e[j],++D[e[j]]}}for(j=Math.max(j,E);j<l;++j)M[O++]=e[j],++D[e[j]];d=oa(e,o,v,M,D,T,C,O,q,j-q,d),v||(i.r=d&7|o[d/8|0]<<3,d-=7,i.h=P,i.p=w,i.i=j,i.w=E)}else{for(var j=i.w||0;j<l+v;j+=65535){var de=j+65535;de>=l&&(o[d/8|0]=v,de=l),d=xa(o,d+1,e.subarray(j,de))}i.i=l}return Se(g,0,n+aa(d)+s)},nt=(function(){for(var e=new Int32Array(256),a=0;a<256;++a){for(var r=a,n=9;--n;)r=(r&1&&-306674912)^r>>>1;e[a]=r}return e})(),st=function(){var e=-1;return{p:function(a){for(var r=e,n=0;n<a.length;++n)r=nt[r&255^a[n]]^r>>>8;e=r},d:function(){return~e}}},ot=function(e,a,r,n,s){if(!s&&(s={l:1},a.dictionary)){var i=a.dictionary.subarray(-32768),l=new Z(i.length+e.length);l.set(i),l.set(e,i.length),e=l,s.w=i.length}return rt(e,a.level==null?6:a.level,a.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+a.mem,r,n,s)},wa=function(e,a){var r={};for(var n in e)r[n]=e[n];for(var n in a)r[n]=a[n];return r},le=function(e,a){return e[a]|e[a+1]<<8},oe=function(e,a){return(e[a]|e[a+1]<<8|e[a+2]<<16|e[a+3]<<24)>>>0},Ke=function(e,a){return oe(e,a)+oe(e,a+4)*4294967296},ee=function(e,a,r){for(;r;++a)e[a]=r,r>>>=8};function it(e,a){return ot(e,a||{},0,0)}function lt(e,a){return at(e,{i:2},a&&a.out,a&&a.dictionary)}var ya=function(e,a,r,n){for(var s in e){var i=e[s],l=a+s,g=n;Array.isArray(i)&&(g=wa(n,i[1]),i=i[0]),ArrayBuffer.isView(i)?r[l]=[i,g]:(r[l+="/"]=[new Z(0),g],ya(i,l,r,n))}},ia=typeof TextEncoder<"u"&&new TextEncoder,Ge=typeof TextDecoder<"u"&&new TextDecoder,ct=0;try{Ge.decode(ka,{stream:!0}),ct=1}catch{}var dt=function(e){for(var a="",r=0;;){var n=e[r++],s=(n>127)+(n>223)+(n>239);if(r+s>e.length)return{s:a,r:Se(e,r-1)};s?s==3?(n=((n&15)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,a+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?a+=String.fromCharCode((n&31)<<6|e[r++]&63):a+=String.fromCharCode((n&15)<<12|(e[r++]&63)<<6|e[r++]&63):a+=String.fromCharCode(n)}};function $e(e,a){var r;if(ia)return ia.encode(e);for(var n=e.length,s=new Z(e.length+(e.length>>1)),i=0,l=function(v){s[i++]=v},r=0;r<n;++r){if(i+5>s.length){var g=new Z(i+8+(n-r<<1));g.set(s),s=g}var o=e.charCodeAt(r);o<128||a?l(o):o<2048?(l(192|o>>6),l(128|o&63)):o>55295&&o<57344?(o=65536+(o&1047552)|e.charCodeAt(++r)&1023,l(240|o>>18),l(128|o>>12&63),l(128|o>>6&63),l(128|o&63)):(l(224|o>>12),l(128|o>>6&63),l(128|o&63))}return Se(s,0,i)}function mt(e,a){if(a){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}else{if(Ge)return Ge.decode(e);var s=dt(e),i=s.s,r=s.r;return r.length&&te(8),i}}var ut=function(e,a){return a+30+le(e,a+26)+le(e,a+28)},pt=function(e,a,r){var n=le(e,a+28),s=le(e,a+30),i=mt(e.subarray(a+46,a+46+n),!(le(e,a+8)&2048)),l=a+46+n,g=ft(e,l,s,r,oe(e,a+20),oe(e,a+24),oe(e,a+42)),o=g[0],v=g[1],d=g[2];return[le(e,a+10),o,v,i,l+s+le(e,a+32),d]},ft=function(e,a,r,n,s,i,l){var g=s==4294967295,o=i==4294967295,v=l==4294967295,d=a+r,c=g+o+v;if(n&&c){for(;a+4<d;a+=4+le(e,a+2))if(le(e,a)==1)return[g?Ke(e,a+4+8*o):s,o?Ke(e,a+4):i,v?Ke(e,a+4+8*(o+g)):l,1];n<2&&te(13)}return[s,i,l,0]},Ye=function(e){var a=0;if(e)for(var r in e){var n=e[r].length;n>65535&&te(9),a+=n+4}return a},la=function(e,a,r,n,s,i,l,g){var o=n.length,v=r.extra,d=g&&g.length,c=Ye(v);ee(e,a,l!=null?33639248:67324752),a+=4,l!=null&&(e[a++]=20,e[a++]=r.os),e[a]=20,a+=2,e[a++]=r.flag<<1|(i<0&&8),e[a++]=s&&8,e[a++]=r.compression&255,e[a++]=r.compression>>8;var u=new Date(r.mtime==null?Date.now():r.mtime),y=u.getFullYear()-1980;if((y<0||y>119)&&te(10),ee(e,a,y<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>1),a+=4,i!=-1&&(ee(e,a,r.crc),ee(e,a+4,i<0?-i-2:i),ee(e,a+8,r.size)),ee(e,a+12,o),ee(e,a+14,c),a+=16,l!=null&&(ee(e,a,d),ee(e,a+6,r.attrs),ee(e,a+10,l),a+=14),e.set(n,a),a+=o,c)for(var m in v){var w=v[m],P=w.length;ee(e,a,+m),ee(e,a+2,P),e.set(w,a+4),a+=4+P}return d&&(e.set(g,a),a+=d),a},gt=function(e,a,r,n,s){ee(e,a,101010256),ee(e,a+8,r),ee(e,a+10,r),ee(e,a+12,n),ee(e,a+16,s)};function ht(e,a){a||(a={});var r={},n=[];ya(e,"",r,a);var s=0,i=0;for(var l in r){var g=r[l],o=g[0],v=g[1],d=v.level==0?0:8,c=$e(l),u=c.length,y=v.comment,m=y&&$e(y),w=m&&m.length,P=Ye(v.extra);u>65535&&te(11);var N=d?it(o,v):o,b=N.length,S=st();S.p(o),n.push(wa(v,{size:o.length,crc:S.d(),c:N,f:c,m,u:u!=l.length||m&&y.length!=w,o:s,compression:d})),s+=30+u+P+b,i+=76+2*(u+P)+(w||0)+b}for(var M=new Z(i+22),D=s,T=i-s,F=0;F<n.length;++F){var c=n[F];la(M,c.o,c,c.f,c.u,c.c.length);var C=30+c.f.length+Ye(c.extra);M.set(c.c,c.o+C),la(M,s,c,c.f,c.u,c.c.length,c.o,c.m),s+=16+C+(c.m?c.m.length:0)}return gt(M,s,n.length,T,D),M}function vt(e,a){for(var r={},n=e.length-22;oe(e,n)!=101010256;--n)(!n||e.length-n>65558)&&te(13);var s=le(e,n+8);if(!s)return{};var i=oe(e,n+16),l=oe(e,n-20)==117853008;if(l){var g=oe(e,n-12);l=oe(e,g)==101075792,l&&(s=oe(e,g+32),i=oe(e,g+48))}for(var o=a&&a.filter,v=0;v<s;++v){var d=pt(e,i,l),c=d[0],u=d[1],y=d[2],m=d[3],w=d[4],P=d[5],N=ut(e,P);i=w,(!o||o({name:m,size:u,originalSize:y,compression:c}))&&(c?c==8?r[m]=lt(e.subarray(N,N+u),{out:new Z(y)}):te(14,"unknown compression type "+c):r[m]=Se(e,N,N+u))}return r}function ja({files:e,readOnly:a=!1,onChange:r,testId:n}){var c,u,y;const[s,i]=we(a?"packageFile":"packageDraftFile",((c=e[0])==null?void 0:c.path)??""),[l,g]=we("editorMode",a?"read":"edit",["read","edit","split"]),[o,v]=z.useState([((u=e[0])==null?void 0:u.path)??""]),d=e.some(m=>m.path===s)?s:(y=e[0])==null?void 0:y.path;return t.jsxs("div",{className:"min-w-0 overflow-hidden rounded-lg border border-surface-highest",children:[t.jsx("div",{role:"tablist","aria-label":"Package files",className:"flex overflow-x-auto bg-background",children:e.map(m=>t.jsx("button",{type:"button",role:"tab","aria-selected":d===m.path,"data-testid":"package-file","data-file-name":m.path,title:m.path,className:`shrink-0 border-r border-surface-highest px-4 py-3 text-sm ${d===m.path?"border-t-2 border-t-transparent bg-surface-highest text-on-surface":"border-t-2 border-t-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,onClick:()=>{i(m.path),v(w=>w.includes(m.path)?w:[...w,m.path])},onKeyDown:w=>{var M;const P=e.findIndex(D=>D.path===m.path),N=w.key==="ArrowRight"?P+1:w.key==="ArrowLeft"?P-1:void 0;if(N===void 0)return;w.preventDefault();const b=(M=w.currentTarget.parentElement)==null?void 0:M.querySelectorAll('[role="tab"]'),S=b==null?void 0:b[(N+e.length)%e.length];S==null||S.focus(),S==null||S.click()},children:m.path.endsWith("/SKILL.md")?m.path.split("/").slice(-2).join("/"):m.path.split("/").pop()},m.path))}),e.filter(m=>o.includes(m.path)||d===m.path).map(m=>t.jsxs("div",{role:"tabpanel","aria-label":m.path,hidden:d!==m.path,className:"[&_[data-testid=code-editor]>div>span[title]]:hidden [&_[data-testid=markdown-editor]>div>span[title]]:hidden",children:[t.jsx(Fe,{mode:Ca(m.path)?l:void 0,onModeChange:g,path:m.path,value:m.content,onChange:r?w=>r(m.path,w):void 0,readOnly:a||m.encoding==="base64",height:420,testId:d===m.path?n:void 0}),m.encoding==="base64"&&t.jsx("p",{className:"px-4 py-2 text-xs text-outline",children:"Binary asset shown as base64."})]},m.path))]})}function xt({name:e,onClose:a,onUse:r,onEdit:n,onExport:s,onSource:i,busy:l,operationError:g}){var d,c,u,y;const o=ve({queryKey:["agent-package",e],queryFn:()=>V.agentPackages.get(e)}),v=ve({enabled:!!o.data,queryKey:["agent-package-files",e],queryFn:async()=>{const m=o.data;if(!m)return[];const w=await Promise.all(m.files.map(async P=>{const N=await V.agentPackages.get(e,P.name);return{path:P.name,content:N.content,encoding:N.encoding}}));return[{path:m.manifestFile,content:m.content},...w]}});return t.jsx(Pa,{open:!0,onOpenChange:m=>{m||a()},children:t.jsxs(Sa,{className:"w-screen max-w-full sm:w-[720px] sm:max-w-[90vw]",children:[t.jsx(Aa,{children:t.jsx(Ma,{children:e})}),t.jsxs(Fa,{children:[t.jsxs("div",{className:"mb-5 space-y-3",children:[t.jsx("p",{className:"text-sm text-outline break-words",children:(d=o.data)==null?void 0:d.description}),o.data&&t.jsxs("p",{className:"text-xs text-outline",children:[o.data.files.filter(m=>/(^|\/)SKILL\.md$/.test(m.name)).length," ","skills ·"," ",o.data.files.filter(m=>m.name.endsWith(".instructions.md")).length," ","instruction files ·"," ",o.data.files.filter(m=>m.name.endsWith(".agent.md")).length," agent definitions"]}),(c=o.data)==null?void 0:c.warnings.map(m=>t.jsx("p",{role:"alert",className:"text-xs text-destructive break-words",children:m},m)),t.jsxs("div",{className:"grid gap-2 grid-cols-2",children:[r&&t.jsx(_,{"data-testid":"package-detail-run",onClick:r,disabled:l,children:"Use package"}),n&&t.jsx(_,{"data-testid":"package-edit",variant:"outline",onClick:n,disabled:l,children:"Edit configuration"}),s&&t.jsx(_,{"data-testid":"package-export-artifact",variant:"outline",onClick:s,disabled:l,children:l?"Preparing…":"Export for installation"}),i&&t.jsx(_,{"data-testid":"package-export",variant:"outline",onClick:i,disabled:l,children:"Download source"})]}),t.jsxs("p",{className:"text-xs text-outline",children:["APM builds installation exports (",((u=o.data)==null?void 0:u.format)==="agent-plugin"?"portable Agent Plugin":"Claude plugin","). Download source preserves the editable manifest and all files."]}),g&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g})]}),o.error||v.error?t.jsx("p",{role:"alert",children:(y=o.error??v.error)==null?void 0:y.message}):v.isLoading?t.jsx("p",{children:"Loading files…"}):t.jsx(ja,{files:v.data??[],readOnly:!0,testId:"package-file-content"})]})]})})}const ba="https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",kt="https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";function Ae(e){return e==="apm"?`name: my-agent-package
12
12
  version: '1.0.0'
13
13
  description: Describe when to use this configuration
14
14
  dependencies: {}
15
- `:JSON.stringify({$schema:ba,name:"my-agent-package",version:"1.0.0",description:"Describe when to use this configuration"},null,2)}function Re(e,a){var s;const r=a==="apm"?Ie(e):null;if(r!=null&&r.errors.length)throw new Error((s=r.errors[0])==null?void 0:s.message);const n=r?r.toJS():JSON.parse(e);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Manifest must be an object");return n}function kt(e,a,r,n){if(a==="agent-plugin")return JSON.stringify({...Re(e,a),[r]:n},null,2);const s=Ie(e);if(s.errors.length)throw new Error("Fix the manifest before switching to fields");return s.set(r,n),s.toString()}function Me(e,a,r){return e.some(s=>s.path===a)?e.map(s=>s.path===a?{...s,content:r,encoding:"utf8"}:s):[...e,{path:a,content:r,encoding:"utf8"}]}function wt(e,a){var n;return`${((n=e==null?void 0:e.match(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n)?/))==null?void 0:n[0])??`---
15
+ `:JSON.stringify({$schema:ba,name:"my-agent-package",version:"1.0.0",description:"Describe when to use this configuration"},null,2)}function Be(e,a){var s;const r=a==="apm"?Ie(e):null;if(r!=null&&r.errors.length)throw new Error((s=r.errors[0])==null?void 0:s.message);const n=r?r.toJS():JSON.parse(e);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Manifest must be an object");return n}function wt(e,a,r,n){if(a==="agent-plugin")return JSON.stringify({...Be(e,a),[r]:n},null,2);const s=Ie(e);if(s.errors.length)throw new Error("Fix the manifest before switching to fields");return s.set(r,n),s.toString()}function Me(e,a,r){return e.some(s=>s.path===a)?e.map(s=>s.path===a?{...s,content:r,encoding:"utf8"}:s):[...e,{path:a,content:r,encoding:"utf8"}]}function yt(e,a){var n;return`${((n=e==null?void 0:e.match(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n)?/))==null?void 0:n[0])??`---
16
16
  description: Shared package instructions
17
17
  ---
18
- `}${a}`}function yt(e,a){const r=Ie(a);if(r.errors.length)throw new Error("Fix the MCP YAML before saving");const n=r.toJS();if(!Array.isArray(n))throw new Error("MCP declarations must be a YAML list (use [] for none)");const s=Ie(e);if(s.errors.length)throw new Error("Fix apm.yml before editing MCP declarations");s.setIn(["dependencies","mcp"],n);const i=s.get("dependencies",!0);ra(i)&&(i.flow=!1);const l=s.getIn(["dependencies","mcp"],!0);if(Ua(l)){l.flow=!1;for(const g of l.items)ra(g)&&(g.flow=!1)}return s.toString()}function jt(e,a){const r=Re(e,a);if(typeof r.name!="string"||!/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(r.name)||r.name.length>64)throw new Error("Use a lowercase package name with single hyphens or periods (up to 64 characters)");if(a==="apm"&&(!r.version||typeof r.version!="string"))throw new Error("APM packages require a version");if(a==="agent-plugin"&&r.$schema!==ba)throw new Error("Use the Agent Plugins v1 schema");return r}const ue=new Map;typeof window<"u"&&window.addEventListener("beforeunload",e=>{ue.size&&(e.preventDefault(),e.returnValue="")});function Na(e){ue.delete(e)}function bt(e){var a;return(a=ue.get(e))==null?void 0:a.baseline}function Ze(e){return ue.has(e)?window.confirm("Discard unsaved package changes?")?(Na(e),!0):!1:!0}const ca=".apm/instructions/general.instructions.md";function Nt({initial:e,pending:a,error:r,onSave:n}){var ae,se,ke,pe,fe,de,ye,ta;const[s,i]=we("packageFormat","",["","apm","agent-plugin"]),l=z.useRef(ue.get((e==null?void 0:e.name)??"new")),g=(e==null?void 0:e.format)??(s||void 0),o=g,[v,d]=z.useState(((ae=l.current)==null?void 0:ae.source)??(e==null?void 0:e.content)??Ae(g??"apm")),[c,u]=z.useState(((se=l.current)==null?void 0:se.files)??(e==null?void 0:e.files)??[]),[y,m]=z.useState(((ke=l.current)==null?void 0:ke.selectedSkills)??[]),[w,P]=z.useState(""),[N,b]=we("packageTab",e?"files":"configuration",["files","configuration","skills"]),[S,M]=we("packageSource","fields",["fields","source"]),D=S==="source",U=p=>M(p?"source":"fields"),[F,C]=z.useState(),[j,O]=z.useState(!1),[$,B]=z.useState(""),[q,h]=z.useState((pe=l.current)==null?void 0:pe.mcpDraft),[E,R]=z.useState(),I=ve({queryKey:["package-skill-picker"],queryFn:async()=>{const p=await V.skills.list({limit:500}),A=[...p.skills];let K=p.next_offset;for(;K!==null;){const X=await V.skills.list({limit:500,offset:K});A.push(...X.skills),K=X.next_offset}return{...p,skills:A}}}),T=ve({queryKey:["agents"],queryFn:V.agents.list}),x=z.useMemo(()=>{try{return{fields:Re(v,o??"apm"),error:void 0}}catch(p){return{fields:void 0,error:p.message}}},[v,o]),L=x.fields,H=typeof(L==null?void 0:L.name)=="string"?L.name:"",Y=a||j,J=c.find(p=>p.path===ca),f=(J==null?void 0:J.content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,""))??"",k=c.find(p=>p.path==="mcp.json");z.useEffect(()=>{var A,K,X;v!==((e==null?void 0:e.content)??Ae(o??"apm"))||JSON.stringify(c)!==JSON.stringify((e==null?void 0:e.files)??[])||y.length>0||q!==void 0?ue.set((e==null?void 0:e.name)??"new",{format:o??((A=ue.get((e==null?void 0:e.name)??"new"))==null?void 0:A.format)??((K=l.current)==null?void 0:K.format),source:v,files:c,selectedSkills:y,mcpDraft:q,baseline:((X=l.current)==null?void 0:X.baseline)??e}):ue.delete((e==null?void 0:e.name)??"new")},[v,c,y,q,o,e]);function G(p,A){try{d(kt(v,o??"apm",p,A)),C(void 0)}catch(K){C(K.message)}}function Q(p){const A=ue.get((e==null?void 0:e.name)??"new");if(A&&A.format===p){i(p),d(A.source),u(A.files),m(A.selectedSkills),h(A.mcpDraft);return}A&&!Ze((e==null?void 0:e.name)??"new")||(i(p),d(Ae(p)),u([]),m([]),h(void 0))}return t.jsxs($e,{className:"min-w-0 grid-cols-[minmax(0,1fr)] w-[calc(100%_-_1rem)] max-w-4xl max-h-[94dvh] overflow-x-hidden overflow-y-auto p-4 sm:p-6",children:[t.jsxs(Le,{children:[t.jsx(De,{className:"break-words pr-8",children:e?`Edit ${e.name}`:"New package"}),t.jsx(Qe,{children:"Save a configuration once, then use it in any project."})]}),o?t.jsxs("form",{className:"min-w-0 space-y-4",onSubmit:p=>{if(p.preventDefault(),!E){C(void 0);try{const A=jt(v,o);o==="agent-plugin"&&k&&JSON.parse(k.content),n({name:A.name,content:v,files:c,format:o,skills:y})}catch(A){C(A.message)}}},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[t.jsx("span",{className:"rounded bg-surface-high px-3 py-1",children:o==="apm"?"APM":"Plugin"}),!e&&t.jsx(_,{type:"button",variant:"ghost",disabled:Y,onClick:()=>{Ze("new")&&(i(""),d(Ae("apm")),u([]),m([]),h(void 0))},children:"Change type"})]}),t.jsx("div",{role:"tablist","aria-label":"Package editor",className:"flex flex-wrap gap-1 border-b border-surface-highest pb-2",children:["configuration","skills","files"].map(p=>{var A;return t.jsxs(_,{type:"button",role:"tab","aria-selected":N===p,variant:N===p?"default":"ghost","data-testid":`package-editor-${p}`,onClick:()=>b(p),children:[(A=p[0])==null?void 0:A.toUpperCase(),p.slice(1),p==="skills"&&y.length?` (${y.length})`:""]},p)})}),t.jsxs("fieldset",{disabled:Y,className:"min-w-0 space-y-4",children:[N==="configuration"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm text-outline",children:o==="apm"?"APM configuration":"Portable plugin identity"}),t.jsx(_,{type:"button",variant:"outline","data-testid":"package-editor-mode",disabled:!!E||D&&!!x.error,onClick:()=>{U(!D),h(void 0)},children:D?"Edit fields":o==="apm"?"Edit YAML":"Edit JSON"})]}),D?t.jsx(Fe,{id:"package-yaml",testId:"package-yaml-input",path:o==="apm"?"apm.yml":"plugin.json",value:v,onChange:d,readOnly:Y,height:320}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:[["name","Package name"],["version","Version"],["description","When would you use this?"]].map(([p,A])=>t.jsxs("div",{className:p==="description"?"space-y-1 sm:col-span-2":"space-y-1",children:[t.jsx(re,{htmlFor:`package-${p}`,children:A}),t.jsx(he,{id:`package-${p}`,"data-testid":`package-${p}-input`,disabled:p==="name"&&!!e,value:typeof(L==null?void 0:L[p])=="string"?L[p]:"",onChange:K=>G(p,K.target.value)})]},p))}),o==="apm"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"package-apm-mcp",children:"MCP servers (YAML declarations)"}),t.jsx(Fe,{id:"package-apm-mcp",path:"mcp-dependencies.yml",testId:"package-apm-mcp",height:180,readOnly:Y,value:q??Ba(((fe=L==null?void 0:L.dependencies)==null?void 0:fe.mcp)??[]),onChange:p=>{h(p);try{d(yt(v,p)),R(void 0)}catch(A){R(A.message)}}}),t.jsxs("p",{className:"text-xs text-outline",children:["Use registry names, or named APM mappings with transport and command/URL. Credentials use environment references such as"," ",t.jsxs("code",{children:["$","{API_TOKEN}"]}),"."]}),E&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:E})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"package-instructions",children:"Shared instructions"}),t.jsx(We,{id:"package-instructions","data-testid":"package-instructions",rows:7,placeholder:"What should the agent know and how should it work?",value:f,onChange:p=>u(Me(c,ca,wt(J==null?void 0:J.content,p.target.value)))}),t.jsx("p",{className:"text-xs text-outline",children:"Saved as an APM instruction primitive. Agent-specific model and tool configuration belongs in an agent definition."})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"package-agent-picker",children:"Add an existing agent definition"}),t.jsxs("select",{id:"package-agent-picker","data-testid":"package-agent-picker",className:"w-full rounded border border-control-border bg-background p-3",value:"",onChange:async p=>{var K;const A=p.target.value;if(A){O(!0);try{const X=await V.agents.get(A),be=((K=A.split("/").slice(-1)[0])==null?void 0:K.replace(/[^a-zA-Z0-9-]/g,"-"))??"agent";u(Ue=>Me(Ue,`.apm/agents/${be}.agent.md`,X.raw))}catch(X){C(X.message)}finally{O(!1)}}},children:[t.jsx("option",{value:"",children:"Select an agent to copy into this package…"}),(de=T.data)==null?void 0:de.agents.map(p=>t.jsx("option",{value:p.id,children:p.name},p.id))]})]}),t.jsx("p",{className:"text-sm text-outline",children:"Configure targets, MCP dependencies and launch scripts in Edit YAML. Supporting agent files are editable in Files."})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-outline",children:"Agent Plugins v1 contains skills and MCP. Choose APM if you need shared instructions or agent profiles."}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:"mcp.json (optional)"}),t.jsx(Fe,{path:"mcp.json",testId:"package-mcp-input",height:220,value:(k==null?void 0:k.content)??JSON.stringify({$schema:xt,mcpServers:{}},null,2),readOnly:Y,onChange:p=>u(Me(c,"mcp.json",p))}),t.jsx("p",{className:"text-xs text-outline",children:"Credentials are managed by the coding agent. Keep secrets out of package files."})]})]})]})]}),N==="skills"&&t.jsxs(t.Fragment,{children:[c.filter(p=>/^(skills|\.apm\/skills)\/[^/]+\/SKILL\.md$/.test(p.path)).map(p=>{const A=p.path.slice(0,-8);return t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-outline-variant p-3",children:[t.jsxs("span",{className:"min-w-0 break-words text-sm",children:["Included: ",A.split("/").slice(-2)[0]]}),t.jsx(_,{type:"button",variant:"outline","data-testid":"package-skill-remove",onClick:()=>u(K=>K.filter(X=>!X.path.startsWith(A))),children:"Remove from package"})]},p.path)}),t.jsx("p",{className:"text-sm text-outline",children:"Choose skills from your library. Their SKILL.md, scripts, references and assets are copied into this package; the originals stay available independently."}),t.jsx(he,{"aria-label":"Search existing skills","data-testid":"package-skill-search",placeholder:"Search your skills…",value:w,onChange:p=>P(p.target.value)}),I.error&&t.jsx("p",{role:"alert",children:I.error.message}),I.isLoading&&t.jsx("p",{children:"Loading skills…"}),t.jsx("div",{className:"max-h-[40dvh] overflow-auto space-y-2",children:(ye=I.data)==null?void 0:ye.skills.filter(p=>`${p.name} ${p.description}`.toLowerCase().includes(w.toLowerCase())).map(p=>{const A=p.name.split("/").slice(-1)[0],K=c.some(X=>X.path===`${o==="apm"?".apm/skills":"skills"}/${A}/SKILL.md`);return t.jsxs("label",{className:"flex items-start gap-3 border-b border-outline-variant p-3","data-testid":"package-skill-option","data-skill-name":p.name,children:[t.jsx("input",{type:"checkbox",className:"mt-1 size-5 shrink-0","data-testid":"package-skill-select",checked:K||y.includes(p.name),disabled:K||Y||!y.includes(p.name)&&y.length>=32,onChange:X=>m(X.target.checked?[...y,p.name]:y.filter(be=>be!==p.name))}),t.jsxs("span",{className:"min-w-0 break-words",children:[t.jsxs("span",{className:"block text-sm font-medium",children:[p.name,K?" · included":""]}),t.jsx("span",{className:"block text-xs text-outline line-clamp-2",children:p.description})]})]},p.name)})}),!I.isLoading&&((ta=I.data)==null?void 0:ta.skills.length)===0&&t.jsx("p",{children:"No skills yet. Import skills into your library first, or add skill files directly in Files."})]}),N==="files"&&t.jsxs(t.Fragment,{children:[t.jsxs("details",{className:"border-t border-outline-variant p-3",children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Add a file or folder"}),t.jsx(re,{htmlFor:"package-files",children:"Add files from a folder"}),t.jsx(he,{id:"package-files","data-testid":"package-files-input",type:"file",multiple:!0,webkitdirectory:"",onChange:async p=>{const A=p.target.files;if(A!=null&&A.length){O(!0);try{const K=(await pa(A)).filter(X=>!["apm.yml","plugin.json"].includes(X.path));u(X=>[...X.filter(be=>!K.some(Ue=>Ue.path===be.path)),...K]),C(void 0)}catch(K){C(K.message)}finally{O(!1)}}}}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(he,{"aria-label":"New file path","data-testid":"package-new-file-path",placeholder:o==="apm"?".apm/agents/reviewer.agent.md":"skills/my-skill/SKILL.md",value:$,onChange:p=>B(p.target.value)}),t.jsx(_,{type:"button",variant:"outline",disabled:!$||c.some(p=>p.path===$),onClick:()=>{u(p=>[...p,{path:$,content:"",encoding:"utf8"}]),B("")},children:"Add file"})]})]}),t.jsx(ja,{files:[{path:o==="apm"?"apm.yml":"plugin.json",content:v},...c],readOnly:Y,testId:"package-file-input",onChange:(p,A)=>{p===(o==="apm"?"apm.yml":"plugin.json")?d(A):u(K=>Me(K,p,A))}})]})]}),(r||F||x.error)&&t.jsx("p",{role:"alert","data-testid":"package-editor-error",className:"text-sm text-destructive",children:r||F||x.error}),t.jsxs("div",{className:"sticky bottom-0 border-t border-surface-highest bg-surface pt-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-xs text-outline",children:[c.length," files · ",y.length," skills selected"]}),t.jsx(_,{type:"submit","data-testid":"package-submit",disabled:Y||!H.trim()||!!(x.error||E),children:a?"Saving…":e?"Save changes":"Save to catalog"})]})]}):t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"package-type-choice",children:[t.jsxs("button",{type:"button","data-testid":"package-type-apm",onClick:()=>Q("apm"),className:"rounded-lg border border-outline-variant p-5 text-left hover:bg-surface-low",children:[t.jsx("strong",{className:"block mb-2",children:"APM package"}),t.jsx("span",{className:"text-sm text-outline",children:"Instructions, agents, skills, MCP and dependencies. Configure with apm.yml."})]}),t.jsxs("button",{type:"button","data-testid":"package-type-agent-plugin",onClick:()=>Q("agent-plugin"),className:"rounded-lg border border-outline-variant p-5 text-left hover:bg-surface-low",children:[t.jsx("strong",{className:"block mb-2",children:"Agent Plugin"}),t.jsx("span",{className:"text-sm text-outline",children:"Portable skills and MCP. Configure with plugin.json and mcp.json."})]})]})]})}function Ct(e){if(e.length>16*1024*1024)throw new Error("Archive exceeds 16 MiB");let a=0,r=0;const n=ht(e,{filter:o=>{if(o.name.endsWith("/"))return!1;if(a+=o.originalSize,r++,o.originalSize>8*1024*1024||a>16*1024*1024||r>513)throw new Error("Archive exceeds package file or size limits");return!0}}),s=Object.keys(n),l=s.filter(o=>/(^|\/)(apm\.yml|plugin\.json)$/.test(o)).sort((o,v)=>o.split("/").length-v.split("/").length)[0];if(!l)throw new Error("Choose a source ZIP containing apm.yml or portable plugin.json");const g=l.includes("/")?l.slice(0,l.lastIndexOf("/")+1):"";if(s.some(o=>!o.startsWith(g)))throw new Error("Choose an archive containing one package folder");return Object.entries(n).map(([o,v])=>{let d="";for(const c of v)d+=String.fromCharCode(c);try{const c=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(v);if(!c.includes("\0"))return{path:o.slice(g.length),content:c,encoding:"utf8"}}catch{}return{path:o.slice(g.length),content:btoa(d),encoding:"base64"}})}function Pt({onClose:e,onImported:a}){var F,C,j,O,$,B,q;const[r,n]=we("importMethod","git",["git","zip","folder"]),[s,i]=z.useState(""),[l,g]=z.useState(""),[o,v]=z.useState("auto"),[d,c]=z.useState(),[u,y]=z.useState(!1),m=je({mutationFn:V.agentPackages.discover}),w=je({mutationFn:V.agentPackages.importGit,onSuccess:h=>a(h.name)}),P=je({mutationFn:V.agentPackages.acquire}),N=je({mutationFn:V.agentPackages.importAcquired,onSuccess:h=>a(h.name)}),b=m.isPending||w.isPending||P.isPending||N.isPending||u,S=((F=m.data)==null?void 0:F.packages)??((C=P.data)==null?void 0:C.packages),M=S==null?void 0:S.find(h=>`${h.format}:${h.path}`===l);async function D(){g(""),m.reset(),P.reset(),w.reset(),N.reset();const h=s.trim();if(!h.includes("://")||/^https:\/\/github\.com\//i.test(h))try{await m.mutateAsync(h);return}catch{m.reset()}P.mutate(h)}async function U(h){const E=h.find(H=>H.path==="apm.yml"),R=h.find(H=>H.path==="plugin.json");if(o==="auto"&&E&&R)throw new Error("Both manifests are present. Select a format before importing.");const I=o==="auto"?E?"apm":"agent-plugin":o,T=I==="apm"?E:R;if(!T||T.encoding==="base64")throw new Error("The selected format's manifest is missing");const x=Re(T.content,I);if(typeof x.name!="string")throw new Error("Manifest is missing a package name");const L=await V.agentPackages.create({name:x.name,content:T.content,format:I,imported:!0,files:h.filter(H=>H!==T&&!(I==="agent-plugin"&&H.path==="apm.yml"))});a(L.name)}return t.jsx(Xe,{open:!0,onOpenChange:h=>!h&&!b&&e(),children:t.jsxs($e,{className:"min-w-0 grid-cols-[minmax(0,1fr)] w-[calc(100%_-_1rem)] max-w-xl max-h-[94dvh] overflow-x-hidden overflow-y-auto p-4 sm:p-6",children:[t.jsxs(Le,{children:[t.jsx(De,{children:"Import a package"}),t.jsx(Qe,{children:"Add reusable configuration to your catalog, then choose where to install it."})]}),t.jsx("div",{role:"tablist","aria-label":"Import source",className:"flex flex-wrap gap-2",children:[["git","Git repository"],["zip","ZIP file"],["folder","Folder"]].map(([h,E])=>t.jsx(_,{role:"tab","aria-selected":r===h,"data-testid":`package-import-${h}`,variant:r===h?"default":"outline",disabled:b,onClick:()=>{n(h),c(void 0)},children:E},h))}),r==="git"?t.jsxs(t.Fragment,{children:[t.jsxs("form",{className:"space-y-3",onSubmit:h=>{h.preventDefault(),D()},children:[t.jsx(re,{htmlFor:"package-git-source",children:"Repository URL"}),t.jsx(he,{id:"package-git-source","data-testid":"package-git-source",placeholder:"https://github.com/owner/repository",value:s,disabled:b,onChange:h=>{i(h.target.value),m.reset(),P.reset(),w.reset(),N.reset(),g("")}}),t.jsx("p",{className:"text-xs text-outline",children:"Paste a GitHub, GitLab, Bitbucket or Azure DevOps repository or package link."}),t.jsx(_,{type:"submit","data-testid":"package-git-discover",disabled:b||!s.trim(),children:m.isPending||P.isPending?"Finding packages…":"Find packages"})]}),S&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"max-h-[40dvh] space-y-2 overflow-auto",children:S.map(h=>t.jsxs("label",{className:"flex items-start gap-3 rounded border border-surface-highest p-3","data-testid":"remote-package",children:[t.jsx("input",{className:"mt-1 size-5",type:"radio",name:"package-import-selection",disabled:b||h.installed,checked:l===`${h.format}:${h.path}`,onChange:()=>g(`${h.format}:${h.path}`)}),t.jsxs("span",{className:"min-w-0 break-words",children:[t.jsxs("strong",{className:"block text-sm",children:[h.name,h.installed?" · already in catalog":""]}),t.jsx("span",{className:"block text-xs text-outline",children:h.description}),t.jsxs("span",{className:"block text-xs text-outline",children:[h.format==="apm"?"APM":"Plugin"," ·"," ",h.path||"Repository root"]})]})]},`${h.format}:${h.path}`))}),!S.length&&t.jsx("p",{children:"No APM or Plugin packages found in this repository."}),(j=m.data)==null?void 0:j.issues.map(h=>t.jsxs("p",{role:"alert",className:"text-xs text-destructive break-words",children:[h.path,": ",h.error]},h.path))]}),S&&t.jsx(_,{"data-testid":"package-git-import",disabled:b||!M,onClick:()=>{M&&(m.data?w.mutate({source:m.data.source,commit:m.data.commit,path:M.path,format:M.format}):P.data&&N.mutate({token:P.data.token,path:M.path}))},children:w.isPending||N.isPending?"Importing…":"Import to catalog"})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx(re,{htmlFor:"package-import-format",children:"Package format"}),t.jsxs("select",{id:"package-import-format","data-testid":"package-import-format",disabled:b,className:"w-full rounded border border-control-border bg-surface-low p-3",value:o,onChange:h=>v(h.target.value),children:[t.jsx("option",{value:"auto",children:"Detect from manifest"}),t.jsx("option",{value:"apm",children:"APM"}),t.jsx("option",{value:"agent-plugin",children:"Agent Plugin"})]}),t.jsx(re,{htmlFor:"agent-package-folder",children:r==="folder"?"Package folder":"Package source ZIP"}),t.jsx(he,{id:"agent-package-folder","data-testid":r==="folder"?"agent-package-folder":"package-zip-input",type:"file",accept:r==="zip"?".zip":void 0,multiple:r==="folder",...r==="folder"?{webkitdirectory:""}:{},disabled:b,onChange:async h=>{const E=h.target.files;if(E!=null&&E.length){y(!0),c(void 0);try{await U(r==="folder"?await pa(E):Ct(new Uint8Array(await E[0].arrayBuffer())))}catch(R){c(R.message)}finally{y(!1)}}}},r),t.jsx("p",{className:"text-xs text-outline",children:"Original manifests and supporting files are preserved. Import does not launch an agent or run package scripts. Use ZIP on phones where folder selection is unavailable."})]}),(m.error||w.error||P.error||N.error||d)&&t.jsx("p",{role:"alert","data-testid":"package-import-error",className:"text-sm text-destructive",children:((O=m.error)==null?void 0:O.message)??(($=w.error)==null?void 0:$.message)??((B=P.error)==null?void 0:B.message)??((q=N.error)==null?void 0:q.message)??d})]})})}function St({initial:e,onClose:a}){var j,O,$,B,q,h,E,R,I,T;const[r,n]=z.useState({...e,tool:"apm"}),[s,i]=z.useState(),[l,g]=z.useState(!1),[o,v]=z.useState(!1),[d,c]=z.useState("run"),u=z.useRef(null),y=ua(),m=Ia(),w=Ea(),P=ve({queryKey:["package-tools"],queryFn:V.packageTools.list}),N=ve({queryKey:["setup-components",r.packages],enabled:r.packages.length>0,queryFn:()=>Promise.all(r.packages.map(x=>V.agentPackages.get(x)))}),b=je({mutationFn:V.agentSetups.command});z.useEffect(()=>{var x;b.data&&((x=u.current)==null||x.scrollIntoView({block:"nearest"}))},[b.data]);const S=(j=N.data)==null?void 0:j.some(x=>x.format==="agent-plugin"),M=S&&r.backend!=="copilot",U=!!(r.cwd.trim()&&r.packages.length&&r.name.trim())&&((O=P.data)==null?void 0:O.apm)&&!M&&!N.error&&!N.isFetching;function F(x){n(L=>({...L,...x})),b.reset(),v(!1),i(void 0)}async function C(x){g(!0),i(void 0);try{const L=await w.create({kind:r.backend,name:`${r.name}${x==="install"?" · install":""}`,setup:{...r,operation:x}});a(),y($a(`/terminals/${L.id}`,new URLSearchParams(m.search).get("project")??"all",m.search))}catch(L){i(L.message)}finally{g(!1)}}return t.jsx(Xe,{open:!0,onOpenChange:x=>!x&&!l&&!b.isPending&&a(),children:t.jsxs($e,{className:"min-w-0 grid-cols-[minmax(0,1fr)] w-[calc(100%_-_1rem)] max-w-2xl max-h-[94dvh] overflow-x-hidden overflow-y-auto p-4 sm:p-6",children:[t.jsxs(Le,{children:[t.jsx(De,{children:"Use package"}),t.jsx(Qe,{children:"Install it for your coding agent, launch here, or copy a command for your own terminal."})]}),t.jsxs("fieldset",{disabled:l||b.isPending,className:"min-w-0 space-y-4",children:[t.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"setup-backend",children:"Coding agent"}),t.jsx("select",{id:"setup-backend","data-testid":"setup-backend",className:"w-full rounded border border-control-border bg-surface-low p-3",value:r.backend,onChange:x=>F({backend:x.target.value,agent:void 0}),children:["claude","codex","copilot"].map(x=>{var L;return t.jsxs("option",{value:x,disabled:!!(S&&x!=="copilot"),children:[x,S&&x!=="copilot"?" · unsupported for this plugin":(L=w.info)!=null&&L.launchers.includes(x)?"":" · not installed"]},x)})})]})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"setup-cwd",children:"Project folder on this ORC machine"}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(he,{id:"setup-cwd","data-testid":"setup-cwd",value:r.cwd,onChange:x=>F({cwd:x.target.value})}),t.jsx(_,{type:"button",variant:"outline",disabled:!(($=w.info)!=null&&$.ready),onClick:async()=>{try{const x=await V.terminals.pickFolder(r.cwd||void 0);x.path&&F({cwd:x.path})}catch(x){i(x.message)}},children:"Browse"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"setup-prompt",children:"What should the agent work on?"}),t.jsx(We,{id:"setup-prompt","data-testid":"setup-prompt",rows:3,value:r.prompt,onChange:x=>F({prompt:x.target.value})})]}),t.jsxs("div",{"data-testid":"setup-components",className:"rounded-lg bg-surface-low p-3 text-sm space-y-1",children:[t.jsx("p",{className:"font-medium",children:"Configuration to apply"}),N.isFetching&&t.jsx("p",{children:"Checking package contents…"}),(B=N.data)==null?void 0:B.map(x=>t.jsxs("p",{className:"break-words",children:[x.name,":"," ",x.files.filter(L=>/^(skills|\.apm\/skills)\/[^/]+\/SKILL\.md$/.test(L.name)).length," ","skill files",x.files.some(L=>L.name==="mcp.json")?", native MCP configuration":"",x.files.some(L=>L.name.endsWith(".instructions.md"))?", shared instructions":""]},x.name))]})]}),t.jsxs("p",{className:"text-xs text-outline",children:["APM installs into this project and retains the configuration after the session. Trust and file-conflict prompts appear in the terminal. Copied commands run on this ORC machine in"," ",navigator.platform.startsWith("Win")?"PowerShell":"your shell","."]}),M&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"APM currently activates whole Agent Plugins for Copilot. Select Copilot for this package."}),P.data&&!P.data.apm&&t.jsx("p",{role:"alert",className:"text-sm",children:"Install APM 0.33.0 or newer on the ORC machine, or set ORC_APM_PATH."}),!((q=w.info)!=null&&q.ready)&&t.jsx("p",{role:"alert",className:"text-sm",children:((h=w.info)==null?void 0:h.reason)??"Checking terminal availability…"}),(s||b.error||N.error)&&t.jsx("p",{role:"alert","data-testid":"setup-error",className:"text-sm text-destructive",children:s??((E=b.error)==null?void 0:E.message)??((R=N.error)==null?void 0:R.message)}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsx(_,{"data-testid":"setup-install",variant:"outline",disabled:l||!U||!((I=w.info)!=null&&I.ready),onClick:()=>void C("install"),children:"Install for coding agent"}),t.jsx(_,{"data-testid":"setup-launch",disabled:l||!U||!((T=w.info)!=null&&T.ready),onClick:()=>void C("run"),children:l?"Preparing…":"Run in ORC terminal"}),t.jsx(_,{"data-testid":"setup-command",variant:"outline",disabled:l||b.isPending||!U,onClick:()=>b.mutate({...r,operation:d}),children:b.isPending?"Preparing command…":"Command for my terminal"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"command-mode",children:"Command for your terminal"}),t.jsxs("select",{id:"command-mode",className:"w-full rounded border border-control-border bg-surface-low p-3 text-sm",disabled:l||b.isPending,value:d,onChange:x=>{c(x.target.value),b.reset()},children:[t.jsx("option",{value:"run",children:"Install and launch the agent"}),t.jsx("option",{value:"install",children:"Install configuration only"})]})]}),b.data&&t.jsxs("div",{ref:u,className:"min-w-0 space-y-2 rounded border border-surface-highest p-3",children:[t.jsxs(re,{htmlFor:"package-command",children:["Run in ",b.data.shell," on the ORC machine"]}),t.jsx(We,{id:"package-command","data-testid":"package-command",value:b.data.command,readOnly:!0,rows:3,className:"font-mono text-xs"}),t.jsx(_,{variant:"outline",onClick:async()=>{try{await navigator.clipboard.writeText(b.data.command),v(!0)}catch{i("Copy is unavailable in this browser. Select and copy the command above.")}},children:o?"Copied":"Copy command"})]})]})})}function da(e,a){const r=URL.createObjectURL(new Blob([new Uint8Array(a)],{type:"application/zip"})),n=document.createElement("a");n.href=r,n.download=e,n.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Dt(){const{agentId:e}=za();return t.jsx(Ra,{replace:!0,to:`/packages/agents${e?`/${encodeURIComponent(e)}`:""}`})}function Ot(){var x,L,H,Y,J;const e=La(),[a,r]=Da(),n=ua(),[s,i]=we("packageAction","",["","new","import","edit"]),l=ve({queryKey:["agent-packages"],queryFn:V.agentPackages.list}),g=ve({queryKey:["package-tools"],queryFn:V.packageTools.list}),{selectedId:o,closeDetail:v}=qa("/packages/item","packageName"),d=s==="new",c=f=>i(f?"new":""),[u,y]=z.useState(),m=s==="import",w=f=>i(f?"import":"");function P(f){const k=new URLSearchParams(window.location.search);k.delete("packageAction"),n(`/packages/item/${encodeURIComponent(f)}?${k}`)}function N(f){const k=new URLSearchParams(window.location.search);k.set("packageAction","edit"),n(`/packages/item/${encodeURIComponent(f)}?${k}`)}const[b,S]=z.useState(),[M,D]=z.useState(),[U,F]=z.useState(!1),[C,j]=z.useState(),O=a.get("q")??"",$=a.get("format")??"all";async function B(){await Promise.all(["agent-packages","agents","skills","package-skill-picker","agent-package","agent-package-files"].map(f=>e.invalidateQueries({queryKey:[f]})))}const q=je({mutationFn:f=>u?V.agentPackages.update(u.name,{content:f.content,files:f.files,skills:f.skills,expectedRevision:u.revision}):V.agentPackages.create(f),onSuccess:async f=>{await B(),Na((u==null?void 0:u.name)??"new"),c(!1),y(void 0),j(`${f.name} saved to your catalog.`),P(f.name)}}),h=q.reset;z.useEffect(()=>{let f=!0;if(y(void 0),s!=="edit"||!o){F(!1);return}return F(!0),D(void 0),h(),(async()=>{try{const k=await V.agentPackages.get(o),G=await Promise.all(k.files.map(async ae=>{const se=await V.agentPackages.get(o,ae.name);return{path:ae.name,content:se.content,encoding:se.encoding}}));if(!k.revision)throw new Error("Package revision is missing; update the API before editing");const Q=bt(o);f&&y(Q?{...k,content:Q.content,format:Q.format,revision:Q.revision??k.revision,draftFiles:Q.files}:{...k,draftFiles:G})}catch(k){f&&D(k.message)}finally{f&&F(!1)}})(),()=>{f=!1}},[s,o,h]);function E(f){var G;const k=(G=l.data)==null?void 0:G.packages.find(Q=>Q.name===f);v(),S({name:`${f.replace(/\./g,"-")}-setup`,packages:[f],backend:(k==null?void 0:k.format)==="agent-plugin"?"copilot":"claude",tool:"apm",cwd:"",prompt:""})}async function R(f){F(!0),D(void 0);try{const k=await V.agentPackages.get(f),G={[`${f}/${k.manifestFile}`]:Ee(k.content)};for(const Q of k.files){const ae=await V.agentPackages.get(f,Q.name);G[`${f}/${Q.name}`]=ae.encoding==="base64"?Uint8Array.from(atob(ae.content),se=>se.charCodeAt(0)):Ee(ae.content)}da(`${f}-source.zip`,gt(G))}catch(k){D(k.message)}finally{F(!1)}}async function I(f){F(!0),D(void 0),j("APM is building the installation archive…");try{const k=await V.agentPackages.exportArtifact(f);da(k.filename,Uint8Array.from(atob(k.content),G=>G.charCodeAt(0))),j(`Exported ${k.format} installation archive.`)}catch(k){D(k.message),j(void 0)}finally{F(!1)}}const T=((x=l.data)==null?void 0:x.packages.filter(f=>`${f.name} ${f.description}`.toLowerCase().includes(O.toLowerCase())&&($==="all"||f.format===$)))??[];return t.jsxs("div",{className:"min-w-0 space-y-5",children:[t.jsx(Ta,{title:"Packages",meta:`${((L=l.data)==null?void 0:L.packages.length)??0} in your catalog`,action:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs(_,{variant:"outline","data-testid":"package-import-button",onClick:()=>w(!0),children:[t.jsx(Ka,{size:16,className:"mr-2"}),"Import"]}),t.jsxs(_,{"data-testid":"new-agent-package-button",onClick:()=>{q.reset(),c(!0)},children:[t.jsx(Ja,{size:16,className:"mr-2"}),"New package"]})]})}),t.jsx("div",{className:"space-y-1",children:t.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Keep the instructions, skills and tools you trust in one place. Save a package once, then install it for your coding agent or launch a configured terminal."})}),C&&t.jsx("p",{role:"status",className:"text-sm text-primary break-words",children:C}),(M||l.error)&&t.jsx("p",{role:"alert","data-testid":"package-error",className:"text-sm text-destructive",children:t.jsx("span",{"data-testid":"page-error",children:M??((H=l.error)==null?void 0:H.message)})}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[t.jsxs("div",{className:"relative min-w-0 flex-1",children:[t.jsx(Oa,{size:16,className:"absolute left-3 top-3 text-muted-foreground"}),t.jsx(he,{className:"pl-9","data-testid":"package-search","aria-label":"Search packages",placeholder:"Find a configuration by name or purpose…",value:O,onChange:f=>{const k=new URLSearchParams(a);f.target.value?k.set("q",f.target.value):k.delete("q"),r(k,{replace:!0})}})]}),t.jsxs("select",{"aria-label":"Filter package type","data-testid":"package-format-filter",className:"rounded border border-control-border bg-background p-2 text-sm",value:$,onChange:f=>{const k=new URLSearchParams(a);k.set("format",f.target.value),r(k,{replace:!0})},children:[t.jsx("option",{value:"all",children:"All formats"}),t.jsx("option",{value:"apm",children:"APM packages"}),t.jsx("option",{value:"agent-plugin",children:"Agent Plugins"})]})]}),l.isLoading&&t.jsx("p",{role:"status","data-testid":"page-loading",children:"Loading your catalog…"}),t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:T.map(f=>t.jsxs("article",{"data-testid":"agent-package-row","data-package-name":f.name,className:"min-w-0 flex flex-col border-b border-outline-variant p-4",children:[t.jsxs("span",{className:"mb-3 text-xs text-muted-foreground",children:[f.format==="apm"?"APM package":"Agent Plugins",f.version?` · v${f.version}`:""]}),t.jsx("button",{type:"button","data-testid":"package-inspect",onClick:()=>P(f.name),className:"text-left font-medium break-words hover:text-primary",children:f.name}),t.jsx("p",{className:"mt-2 flex-1 text-sm text-muted-foreground break-words",children:f.description||"Add a description to help you choose this configuration later."}),f.warnings.map(k=>t.jsx("p",{className:"mt-2 text-xs text-muted-foreground break-words",children:k},k)),t.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2",children:[t.jsx(_,{variant:"outline","data-testid":"package-run",disabled:U,onClick:()=>E(f.name),children:"Use package"}),t.jsx(_,{variant:"outline","data-testid":"package-card-edit",onClick:()=>void N(f.name),children:"Edit package"})]})]},f.name))}),!l.isLoading&&!l.error&&!T.length&&t.jsxs("div",{"data-testid":"page-empty",className:"rounded-lg border border-dashed border-outline-variant px-4 py-10 text-center",children:[t.jsx(Ha,{size:32,className:"mx-auto mb-3 text-muted-foreground"}),t.jsx("h3",{className:"font-medium",children:O||$!=="all"?"No matching configurations":"Build your personal agent catalog"}),t.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm text-muted-foreground",children:O||$!=="all"?"Try another search or package format.":"Create an APM package with your instructions and existing skills, or import an Agent Plugin from GitHub."}),!O&&$==="all"&&t.jsx(_,{className:"mt-4",onClick:()=>{q.reset(),c(!0)},children:"Create your first package"})]}),(Y=l.data)==null?void 0:Y.broken.map(f=>t.jsxs("p",{role:"alert",className:"text-destructive break-words",children:[f.path,": ",f.error]},f.path)),g.data&&!g.data.apm&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Catalog editing is available. Installation, Git acquisition and installation exports require APM on this ORC machine."}),o&&!s&&t.jsx(vt,{name:o,onClose:v,onUse:()=>E(o),onEdit:()=>void N(o),onExport:()=>void I(o),onSource:()=>void R(o),busy:U,operationError:M},o),t.jsx(Xe,{open:d||s==="edit",onOpenChange:f=>{if(!f&&!q.isPending){if(!Ze((u==null?void 0:u.name)??"new"))return;c(!1),y(void 0)}},children:d||s==="edit"&&u?t.jsx(Nt,{initial:u?{name:u.name,content:u.content,format:u.format,files:u.draftFiles,revision:u.revision}:void 0,pending:q.isPending,error:(J=q.error)==null?void 0:J.message,onSave:f=>q.mutate(f)}):s==="edit"?t.jsxs($e,{children:[t.jsx(Le,{children:t.jsx(De,{children:"Package editor"})}),t.jsx("p",{role:M?"alert":"status",children:M??"Opening package editor…"})]}):null}),m&&t.jsx(Pt,{onClose:()=>w(!1),onImported:f=>{B(),w(!1),j(`${f} added to your catalog.`),P(f)}}),b&&t.jsx(St,{initial:b,onClose:()=>S(void 0)},b.name)]})}export{Dt as LegacyAgentsRedirect,Ot as default};
18
+ `}${a}`}function jt(e,a){const r=Ie(a);if(r.errors.length)throw new Error("Fix the MCP YAML before saving");const n=r.toJS();if(!Array.isArray(n))throw new Error("MCP declarations must be a YAML list (use [] for none)");const s=Ie(e);if(s.errors.length)throw new Error("Fix apm.yml before editing MCP declarations");s.setIn(["dependencies","mcp"],n);const i=s.get("dependencies",!0);ra(i)&&(i.flow=!1);const l=s.getIn(["dependencies","mcp"],!0);if(Ta(l)){l.flow=!1;for(const g of l.items)ra(g)&&(g.flow=!1)}return s.toString()}function bt(e,a){const r=Be(e,a);if(typeof r.name!="string"||!/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(r.name)||r.name.length>64)throw new Error("Use a lowercase package name with single hyphens or periods (up to 64 characters)");if(a==="apm"&&(!r.version||typeof r.version!="string"))throw new Error("APM packages require a version");if(a==="agent-plugin"&&r.$schema!==ba)throw new Error("Use the Agent Plugins v1 schema");return r}const ue=new Map;typeof window<"u"&&window.addEventListener("beforeunload",e=>{ue.size&&(e.preventDefault(),e.returnValue="")});function Na(e){ue.delete(e)}function Nt(e){var a;return(a=ue.get(e))==null?void 0:a.baseline}function Ze(e){return ue.has(e)?window.confirm("Discard unsaved package changes?")?(Na(e),!0):!1:!0}const ca=".apm/instructions/general.instructions.md";function Ct({initial:e,pending:a,error:r,onSave:n}){var ae,se,ke,pe,fe,de,ye,ta;const[s,i]=we("packageFormat","",["","apm","agent-plugin"]),l=z.useRef(ue.get((e==null?void 0:e.name)??"new")),g=(e==null?void 0:e.format)??(s||void 0),o=g,[v,d]=z.useState(((ae=l.current)==null?void 0:ae.source)??(e==null?void 0:e.content)??Ae(g??"apm")),[c,u]=z.useState(((se=l.current)==null?void 0:se.files)??(e==null?void 0:e.files)??[]),[y,m]=z.useState(((ke=l.current)==null?void 0:ke.selectedSkills)??[]),[w,P]=z.useState(""),[N,b]=we("packageTab",e?"files":"configuration",["files","configuration","skills"]),[S,M]=we("packageSource","fields",["fields","source"]),D=S==="source",T=p=>M(p?"source":"fields"),[F,C]=z.useState(),[j,O]=z.useState(!1),[E,q]=z.useState(""),[U,h]=z.useState((pe=l.current)==null?void 0:pe.mcpDraft),[$,B]=z.useState(),I=ve({queryKey:["package-skill-picker"],queryFn:async()=>{const p=await V.skills.list({limit:500}),A=[...p.skills];let K=p.next_offset;for(;K!==null;){const X=await V.skills.list({limit:500,offset:K});A.push(...X.skills),K=X.next_offset}return{...p,skills:A}}}),R=ve({queryKey:["agents"],queryFn:V.agents.list}),x=z.useMemo(()=>{try{return{fields:Be(v,o??"apm"),error:void 0}}catch(p){return{fields:void 0,error:p.message}}},[v,o]),L=x.fields,H=typeof(L==null?void 0:L.name)=="string"?L.name:"",Y=a||j,J=c.find(p=>p.path===ca),f=(J==null?void 0:J.content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,""))??"",k=c.find(p=>p.path==="mcp.json");z.useEffect(()=>{var A,K,X;v!==((e==null?void 0:e.content)??Ae(o??"apm"))||JSON.stringify(c)!==JSON.stringify((e==null?void 0:e.files)??[])||y.length>0||U!==void 0?ue.set((e==null?void 0:e.name)??"new",{format:o??((A=ue.get((e==null?void 0:e.name)??"new"))==null?void 0:A.format)??((K=l.current)==null?void 0:K.format),source:v,files:c,selectedSkills:y,mcpDraft:U,baseline:((X=l.current)==null?void 0:X.baseline)??e}):ue.delete((e==null?void 0:e.name)??"new")},[v,c,y,U,o,e]);function G(p,A){try{d(wt(v,o??"apm",p,A)),C(void 0)}catch(K){C(K.message)}}function Q(p){const A=ue.get((e==null?void 0:e.name)??"new");if(A&&A.format===p){i(p),d(A.source),u(A.files),m(A.selectedSkills),h(A.mcpDraft);return}A&&!Ze((e==null?void 0:e.name)??"new")||(i(p),d(Ae(p)),u([]),m([]),h(void 0))}return t.jsxs(Ee,{className:"min-w-0 grid-cols-[minmax(0,1fr)] w-[calc(100%_-_1rem)] max-w-4xl max-h-[94dvh] overflow-x-hidden overflow-y-auto p-4 sm:p-6",children:[t.jsxs(Le,{children:[t.jsx(De,{className:"break-words pr-8",children:e?`Edit ${e.name}`:"New package"}),t.jsx(Qe,{children:"Save a configuration once, then use it in any project."})]}),o?t.jsxs("form",{className:"min-w-0 space-y-4",onSubmit:p=>{if(p.preventDefault(),!$){C(void 0);try{const A=bt(v,o);o==="agent-plugin"&&k&&JSON.parse(k.content),n({name:A.name,content:v,files:c,format:o,skills:y})}catch(A){C(A.message)}}},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[t.jsx("span",{className:"rounded bg-surface-high px-3 py-1",children:o==="apm"?"APM":"Plugin"}),!e&&t.jsx(_,{type:"button",variant:"ghost",disabled:Y,onClick:()=>{Ze("new")&&(i(""),d(Ae("apm")),u([]),m([]),h(void 0))},children:"Change type"})]}),t.jsx("div",{role:"tablist","aria-label":"Package editor",className:"flex flex-wrap gap-1 border-b border-surface-highest pb-2",children:["configuration","skills","files"].map(p=>{var A;return t.jsxs(_,{type:"button",role:"tab","aria-selected":N===p,variant:N===p?"default":"ghost","data-testid":`package-editor-${p}`,onClick:()=>b(p),children:[(A=p[0])==null?void 0:A.toUpperCase(),p.slice(1),p==="skills"&&y.length?` (${y.length})`:""]},p)})}),t.jsxs("fieldset",{disabled:Y,className:"min-w-0 space-y-4",children:[N==="configuration"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm text-outline",children:o==="apm"?"APM configuration":"Portable plugin identity"}),t.jsx(_,{type:"button",variant:"outline","data-testid":"package-editor-mode",disabled:!!$||D&&!!x.error,onClick:()=>{T(!D),h(void 0)},children:D?"Edit fields":o==="apm"?"Edit YAML":"Edit JSON"})]}),D?t.jsx(Fe,{id:"package-yaml",testId:"package-yaml-input",path:o==="apm"?"apm.yml":"plugin.json",value:v,onChange:d,readOnly:Y,height:320}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:[["name","Package name"],["version","Version"],["description","When would you use this?"]].map(([p,A])=>t.jsxs("div",{className:p==="description"?"space-y-1 sm:col-span-2":"space-y-1",children:[t.jsx(re,{htmlFor:`package-${p}`,children:A}),t.jsx(he,{id:`package-${p}`,"data-testid":`package-${p}-input`,disabled:p==="name"&&!!e,value:typeof(L==null?void 0:L[p])=="string"?L[p]:"",onChange:K=>G(p,K.target.value)})]},p))}),o==="apm"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"package-apm-mcp",children:"MCP servers (YAML declarations)"}),t.jsx(Fe,{id:"package-apm-mcp",path:"mcp-dependencies.yml",testId:"package-apm-mcp",height:180,readOnly:Y,value:U??qa(((fe=L==null?void 0:L.dependencies)==null?void 0:fe.mcp)??[]),onChange:p=>{h(p);try{d(jt(v,p)),B(void 0)}catch(A){B(A.message)}}}),t.jsxs("p",{className:"text-xs text-outline",children:["Use registry names, or named APM mappings with transport and command/URL. Credentials use environment references such as"," ",t.jsxs("code",{children:["$","{API_TOKEN}"]}),"."]}),$&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:$})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"package-instructions",children:"Shared instructions"}),t.jsx(We,{id:"package-instructions","data-testid":"package-instructions",rows:7,placeholder:"What should the agent know and how should it work?",value:f,onChange:p=>u(Me(c,ca,yt(J==null?void 0:J.content,p.target.value)))}),t.jsx("p",{className:"text-xs text-outline",children:"Saved as an APM instruction primitive. Agent-specific model and tool configuration belongs in an agent definition."})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"package-agent-picker",children:"Add an existing agent definition"}),t.jsxs("select",{id:"package-agent-picker","data-testid":"package-agent-picker",className:"w-full rounded border border-control-border bg-background p-3",value:"",onChange:async p=>{var K;const A=p.target.value;if(A){O(!0);try{const X=await V.agents.get(A),be=((K=A.split("/").slice(-1)[0])==null?void 0:K.replace(/[^a-zA-Z0-9-]/g,"-"))??"agent";u(Te=>Me(Te,`.apm/agents/${be}.agent.md`,X.raw))}catch(X){C(X.message)}finally{O(!1)}}},children:[t.jsx("option",{value:"",children:"Select an agent to copy into this package…"}),(de=R.data)==null?void 0:de.agents.map(p=>t.jsx("option",{value:p.id,children:p.name},p.id))]})]}),t.jsx("p",{className:"text-sm text-outline",children:"Configure targets, MCP dependencies and launch scripts in Edit YAML. Supporting agent files are editable in Files."})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-outline",children:"Agent Plugins v1 contains skills and MCP. Choose APM if you need shared instructions or agent profiles."}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:"mcp.json (optional)"}),t.jsx(Fe,{path:"mcp.json",testId:"package-mcp-input",height:220,value:(k==null?void 0:k.content)??JSON.stringify({$schema:kt,mcpServers:{}},null,2),readOnly:Y,onChange:p=>u(Me(c,"mcp.json",p))}),t.jsx("p",{className:"text-xs text-outline",children:"Credentials are managed by the coding agent. Keep secrets out of package files."})]})]})]})]}),N==="skills"&&t.jsxs(t.Fragment,{children:[c.filter(p=>/^(skills|\.apm\/skills)\/[^/]+\/SKILL\.md$/.test(p.path)).map(p=>{const A=p.path.slice(0,-8);return t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-outline-variant p-3",children:[t.jsxs("span",{className:"min-w-0 break-words text-sm",children:["Included: ",A.split("/").slice(-2)[0]]}),t.jsx(_,{type:"button",variant:"outline","data-testid":"package-skill-remove",onClick:()=>u(K=>K.filter(X=>!X.path.startsWith(A))),children:"Remove from package"})]},p.path)}),t.jsx("p",{className:"text-sm text-outline",children:"Choose skills from your library. Their SKILL.md, scripts, references and assets are copied into this package; the originals stay available independently."}),t.jsx(he,{"aria-label":"Search existing skills","data-testid":"package-skill-search",placeholder:"Search your skills…",value:w,onChange:p=>P(p.target.value)}),I.error&&t.jsx("p",{role:"alert",children:I.error.message}),I.isLoading&&t.jsx("p",{children:"Loading skills…"}),t.jsx("div",{className:"max-h-[40dvh] overflow-auto space-y-2",children:(ye=I.data)==null?void 0:ye.skills.filter(p=>`${p.name} ${p.description}`.toLowerCase().includes(w.toLowerCase())).map(p=>{const A=p.name.split("/").slice(-1)[0],K=c.some(X=>X.path===`${o==="apm"?".apm/skills":"skills"}/${A}/SKILL.md`);return t.jsxs("label",{className:"flex items-start gap-3 border-b border-outline-variant p-3","data-testid":"package-skill-option","data-skill-name":p.name,children:[t.jsx("input",{type:"checkbox",className:"mt-1 size-5 shrink-0","data-testid":"package-skill-select",checked:K||y.includes(p.name),disabled:K||Y||!y.includes(p.name)&&y.length>=32,onChange:X=>m(X.target.checked?[...y,p.name]:y.filter(be=>be!==p.name))}),t.jsxs("span",{className:"min-w-0 break-words",children:[t.jsxs("span",{className:"block text-sm font-medium",children:[p.name,K?" · included":""]}),t.jsx("span",{className:"block text-xs text-outline line-clamp-2",children:p.description})]})]},p.name)})}),!I.isLoading&&((ta=I.data)==null?void 0:ta.skills.length)===0&&t.jsx("p",{children:"No skills yet. Import skills into your library first, or add skill files directly in Files."})]}),N==="files"&&t.jsxs(t.Fragment,{children:[t.jsxs("details",{className:"border-t border-outline-variant p-3",children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Add a file or folder"}),t.jsx(re,{htmlFor:"package-files",children:"Add files from a folder"}),t.jsx(he,{id:"package-files","data-testid":"package-files-input",type:"file",multiple:!0,webkitdirectory:"",onChange:async p=>{const A=p.target.files;if(A!=null&&A.length){O(!0);try{const K=(await pa(A)).filter(X=>!["apm.yml","plugin.json"].includes(X.path));u(X=>[...X.filter(be=>!K.some(Te=>Te.path===be.path)),...K]),C(void 0)}catch(K){C(K.message)}finally{O(!1)}}}}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(he,{"aria-label":"New file path","data-testid":"package-new-file-path",placeholder:o==="apm"?".apm/agents/reviewer.agent.md":"skills/my-skill/SKILL.md",value:E,onChange:p=>q(p.target.value)}),t.jsx(_,{type:"button",variant:"outline",disabled:!E||c.some(p=>p.path===E),onClick:()=>{u(p=>[...p,{path:E,content:"",encoding:"utf8"}]),q("")},children:"Add file"})]})]}),t.jsx(ja,{files:[{path:o==="apm"?"apm.yml":"plugin.json",content:v},...c],readOnly:Y,testId:"package-file-input",onChange:(p,A)=>{p===(o==="apm"?"apm.yml":"plugin.json")?d(A):u(K=>Me(K,p,A))}})]})]}),(r||F||x.error)&&t.jsx("p",{role:"alert","data-testid":"package-editor-error",className:"text-sm text-destructive",children:r||F||x.error}),t.jsxs("div",{className:"sticky bottom-0 border-t border-surface-highest bg-surface pt-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-xs text-outline",children:[c.length," files · ",y.length," skills selected"]}),t.jsx(_,{type:"submit","data-testid":"package-submit",disabled:Y||!H.trim()||!!(x.error||$),children:a?"Saving…":e?"Save changes":"Save to catalog"})]})]}):t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"package-type-choice",children:[t.jsxs("button",{type:"button","data-testid":"package-type-apm",onClick:()=>Q("apm"),className:"rounded-lg border border-outline-variant p-5 text-left hover:bg-surface-low",children:[t.jsx("strong",{className:"block mb-2",children:"APM package"}),t.jsx("span",{className:"text-sm text-outline",children:"Instructions, agents, skills, MCP and dependencies. Configure with apm.yml."})]}),t.jsxs("button",{type:"button","data-testid":"package-type-agent-plugin",onClick:()=>Q("agent-plugin"),className:"rounded-lg border border-outline-variant p-5 text-left hover:bg-surface-low",children:[t.jsx("strong",{className:"block mb-2",children:"Agent Plugin"}),t.jsx("span",{className:"text-sm text-outline",children:"Portable skills and MCP. Configure with plugin.json and mcp.json."})]})]})]})}function Pt(e){if(e.length>16*1024*1024)throw new Error("Archive exceeds 16 MiB");let a=0,r=0;const n=vt(e,{filter:o=>{if(o.name.endsWith("/"))return!1;if(a+=o.originalSize,r++,o.originalSize>8*1024*1024||a>16*1024*1024||r>513)throw new Error("Archive exceeds package file or size limits");return!0}}),s=Object.keys(n),l=s.filter(o=>/(^|\/)(apm\.yml|plugin\.json)$/.test(o)).sort((o,v)=>o.split("/").length-v.split("/").length)[0];if(!l)throw new Error("Choose a source ZIP containing apm.yml or portable plugin.json");const g=l.includes("/")?l.slice(0,l.lastIndexOf("/")+1):"";if(s.some(o=>!o.startsWith(g)))throw new Error("Choose an archive containing one package folder");return Object.entries(n).map(([o,v])=>{let d="";for(const c of v)d+=String.fromCharCode(c);try{const c=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(v);if(!c.includes("\0"))return{path:o.slice(g.length),content:c,encoding:"utf8"}}catch{}return{path:o.slice(g.length),content:btoa(d),encoding:"base64"}})}function St({onClose:e,onImported:a}){var F,C,j,O,E,q,U;const[r,n]=we("importMethod","git",["git","zip","folder"]),[s,i]=z.useState(""),[l,g]=z.useState(""),[o,v]=z.useState("auto"),[d,c]=z.useState(),[u,y]=z.useState(!1),m=je({mutationFn:V.agentPackages.discover}),w=je({mutationFn:V.agentPackages.importGit,onSuccess:h=>a(h.name)}),P=je({mutationFn:V.agentPackages.acquire}),N=je({mutationFn:V.agentPackages.importAcquired,onSuccess:h=>a(h.name)}),b=m.isPending||w.isPending||P.isPending||N.isPending||u,S=((F=m.data)==null?void 0:F.packages)??((C=P.data)==null?void 0:C.packages),M=S==null?void 0:S.find(h=>`${h.format}:${h.path}`===l);async function D(){g(""),m.reset(),P.reset(),w.reset(),N.reset();const h=s.trim();if(!h.includes("://")||/^https:\/\/github\.com\//i.test(h))try{await m.mutateAsync(h);return}catch{m.reset()}P.mutate(h)}async function T(h){const $=h.find(H=>H.path==="apm.yml"),B=h.find(H=>H.path==="plugin.json");if(o==="auto"&&$&&B)throw new Error("Both manifests are present. Select a format before importing.");const I=o==="auto"?$?"apm":"agent-plugin":o,R=I==="apm"?$:B;if(!R||R.encoding==="base64")throw new Error("The selected format's manifest is missing");const x=Be(R.content,I);if(typeof x.name!="string")throw new Error("Manifest is missing a package name");const L=await V.agentPackages.create({name:x.name,content:R.content,format:I,imported:!0,files:h.filter(H=>H!==R&&!(I==="agent-plugin"&&H.path==="apm.yml"))});a(L.name)}return t.jsx(Xe,{open:!0,onOpenChange:h=>!h&&!b&&e(),children:t.jsxs(Ee,{className:"min-w-0 grid-cols-[minmax(0,1fr)] w-[calc(100%_-_1rem)] max-w-xl max-h-[94dvh] overflow-x-hidden overflow-y-auto p-4 sm:p-6",children:[t.jsxs(Le,{children:[t.jsx(De,{children:"Import a package"}),t.jsx(Qe,{children:"Add reusable configuration to your catalog, then choose where to install it."})]}),t.jsx("div",{role:"tablist","aria-label":"Import source",className:"flex flex-wrap gap-2",children:[["git","Git repository"],["zip","ZIP file"],["folder","Folder"]].map(([h,$])=>t.jsx(_,{role:"tab","aria-selected":r===h,"data-testid":`package-import-${h}`,variant:r===h?"default":"outline",disabled:b,onClick:()=>{n(h),c(void 0)},children:$},h))}),r==="git"?t.jsxs(t.Fragment,{children:[t.jsxs("form",{className:"space-y-3",onSubmit:h=>{h.preventDefault(),D()},children:[t.jsx(re,{htmlFor:"package-git-source",children:"Repository URL"}),t.jsx(he,{id:"package-git-source","data-testid":"package-git-source",placeholder:"https://github.com/owner/repository",value:s,disabled:b,onChange:h=>{i(h.target.value),m.reset(),P.reset(),w.reset(),N.reset(),g("")}}),t.jsx("p",{className:"text-xs text-outline",children:"Paste a GitHub, GitLab, Bitbucket or Azure DevOps repository or package link."}),t.jsx(_,{type:"submit","data-testid":"package-git-discover",disabled:b||!s.trim(),children:m.isPending||P.isPending?"Finding packages…":"Find packages"})]}),S&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"max-h-[40dvh] space-y-2 overflow-auto",children:S.map(h=>t.jsxs("label",{className:"flex items-start gap-3 rounded border border-surface-highest p-3","data-testid":"remote-package",children:[t.jsx("input",{className:"mt-1 size-5",type:"radio",name:"package-import-selection",disabled:b||h.installed,checked:l===`${h.format}:${h.path}`,onChange:()=>g(`${h.format}:${h.path}`)}),t.jsxs("span",{className:"min-w-0 break-words",children:[t.jsxs("strong",{className:"block text-sm",children:[h.name,h.installed?" · already in catalog":""]}),t.jsx("span",{className:"block text-xs text-outline",children:h.description}),t.jsxs("span",{className:"block text-xs text-outline",children:[h.format==="apm"?"APM":"Plugin"," ·"," ",h.path||"Repository root"]})]})]},`${h.format}:${h.path}`))}),!S.length&&t.jsx("p",{children:"No APM or Plugin packages found in this repository."}),(j=m.data)==null?void 0:j.issues.map(h=>t.jsxs("p",{role:"alert",className:"text-xs text-destructive break-words",children:[h.path,": ",h.error]},h.path))]}),S&&t.jsx(_,{"data-testid":"package-git-import",disabled:b||!M,onClick:()=>{M&&(m.data?w.mutate({source:m.data.source,commit:m.data.commit,path:M.path,format:M.format}):P.data&&N.mutate({token:P.data.token,path:M.path}))},children:w.isPending||N.isPending?"Importing…":"Import to catalog"})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx(re,{htmlFor:"package-import-format",children:"Package format"}),t.jsxs("select",{id:"package-import-format","data-testid":"package-import-format",disabled:b,className:"w-full rounded border border-control-border bg-surface-low p-3",value:o,onChange:h=>v(h.target.value),children:[t.jsx("option",{value:"auto",children:"Detect from manifest"}),t.jsx("option",{value:"apm",children:"APM"}),t.jsx("option",{value:"agent-plugin",children:"Agent Plugin"})]}),t.jsx(re,{htmlFor:"agent-package-folder",children:r==="folder"?"Package folder":"Package source ZIP"}),t.jsx(he,{id:"agent-package-folder","data-testid":r==="folder"?"agent-package-folder":"package-zip-input",type:"file",accept:r==="zip"?".zip":void 0,multiple:r==="folder",...r==="folder"?{webkitdirectory:""}:{},disabled:b,onChange:async h=>{const $=h.target.files;if($!=null&&$.length){y(!0),c(void 0);try{await T(r==="folder"?await pa($):Pt(new Uint8Array(await $[0].arrayBuffer())))}catch(B){c(B.message)}finally{y(!1)}}}},r),t.jsx("p",{className:"text-xs text-outline",children:"Original manifests and supporting files are preserved. Import does not launch an agent or run package scripts. Use ZIP on phones where folder selection is unavailable."})]}),(m.error||w.error||P.error||N.error||d)&&t.jsx("p",{role:"alert","data-testid":"package-import-error",className:"text-sm text-destructive",children:((O=m.error)==null?void 0:O.message)??((E=w.error)==null?void 0:E.message)??((q=P.error)==null?void 0:q.message)??((U=N.error)==null?void 0:U.message)??d})]})})}function At({initial:e,onClose:a}){var j,O,E,q,U,h,$,B,I,R;const[r,n]=z.useState({...e,tool:"apm"}),[s,i]=z.useState(),[l,g]=z.useState(!1),[o,v]=z.useState(!1),[d,c]=z.useState("run"),u=z.useRef(null),y=ua(),m=Ia(),w=$a(),P=ve({queryKey:["package-tools"],queryFn:V.packageTools.list}),N=ve({queryKey:["setup-components",r.packages],enabled:r.packages.length>0,queryFn:()=>Promise.all(r.packages.map(x=>V.agentPackages.get(x)))}),b=je({mutationFn:V.agentSetups.command});z.useEffect(()=>{var x;b.data&&((x=u.current)==null||x.scrollIntoView({block:"nearest"}))},[b.data]);const S=(j=N.data)==null?void 0:j.some(x=>x.format==="agent-plugin"),M=S&&r.backend!=="copilot",T=!!(r.cwd.trim()&&r.packages.length&&r.name.trim())&&((O=P.data)==null?void 0:O.apm)&&!M&&!N.error&&!N.isFetching;function F(x){n(L=>({...L,...x})),b.reset(),v(!1),i(void 0)}async function C(x){g(!0),i(void 0);try{const L=await w.create({kind:r.backend,name:`${r.name}${x==="install"?" · install":""}`,setup:{...r,operation:x}});a(),y(Ea(`/terminals/${L.id}`,new URLSearchParams(m.search).get("project")??"all",m.search))}catch(L){i(L.message)}finally{g(!1)}}return t.jsx(Xe,{open:!0,onOpenChange:x=>!x&&!l&&!b.isPending&&a(),children:t.jsxs(Ee,{className:"min-w-0 grid-cols-[minmax(0,1fr)] w-[calc(100%_-_1rem)] max-w-2xl max-h-[94dvh] overflow-x-hidden overflow-y-auto p-4 sm:p-6",children:[t.jsxs(Le,{children:[t.jsx(De,{children:"Use package"}),t.jsx(Qe,{children:"Install it for your coding agent, launch here, or copy a command for your own terminal."})]}),t.jsxs("fieldset",{disabled:l||b.isPending,className:"min-w-0 space-y-4",children:[t.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"setup-backend",children:"Coding agent"}),t.jsx("select",{id:"setup-backend","data-testid":"setup-backend",className:"w-full rounded border border-control-border bg-surface-low p-3",value:r.backend,onChange:x=>F({backend:x.target.value,agent:void 0}),children:["claude","codex","copilot"].map(x=>{var L;return t.jsxs("option",{value:x,disabled:!!(S&&x!=="copilot"),children:[x,S&&x!=="copilot"?" · unsupported for this plugin":(L=w.info)!=null&&L.launchers.includes(x)?"":" · not installed"]},x)})})]})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"setup-cwd",children:"Project folder on this ORC machine"}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(he,{id:"setup-cwd","data-testid":"setup-cwd",value:r.cwd,onChange:x=>F({cwd:x.target.value})}),t.jsx(_,{type:"button",variant:"outline",disabled:!((E=w.info)!=null&&E.ready),onClick:async()=>{try{const x=await V.terminals.pickFolder(r.cwd||void 0);x.path&&F({cwd:x.path})}catch(x){i(x.message)}},children:"Browse"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"setup-prompt",children:"What should the agent work on?"}),t.jsx(We,{id:"setup-prompt","data-testid":"setup-prompt",rows:3,value:r.prompt,onChange:x=>F({prompt:x.target.value})})]}),t.jsxs("div",{"data-testid":"setup-components",className:"rounded-lg bg-surface-low p-3 text-sm space-y-1",children:[t.jsx("p",{className:"font-medium",children:"Configuration to apply"}),N.isFetching&&t.jsx("p",{children:"Checking package contents…"}),(q=N.data)==null?void 0:q.map(x=>t.jsxs("p",{className:"break-words",children:[x.name,":"," ",x.files.filter(L=>/^(skills|\.apm\/skills)\/[^/]+\/SKILL\.md$/.test(L.name)).length," ","skill files",x.files.some(L=>L.name==="mcp.json")?", native MCP configuration":"",x.files.some(L=>L.name.endsWith(".instructions.md"))?", shared instructions":""]},x.name))]})]}),t.jsxs("p",{className:"text-xs text-outline",children:["APM installs into this project and retains the configuration after the session. Trust and file-conflict prompts appear in the terminal. Copied commands run on this ORC machine in"," ",navigator.platform.startsWith("Win")?"PowerShell":"your shell","."]}),M&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"APM currently activates whole Agent Plugins for Copilot. Select Copilot for this package."}),P.data&&!P.data.apm&&t.jsx("p",{role:"alert",className:"text-sm",children:"Install APM 0.33.0 or newer on the ORC machine, or set ORC_APM_PATH."}),!((U=w.info)!=null&&U.ready)&&t.jsx("p",{role:"alert",className:"text-sm",children:((h=w.info)==null?void 0:h.reason)??"Checking terminal availability…"}),(s||b.error||N.error)&&t.jsx("p",{role:"alert","data-testid":"setup-error",className:"text-sm text-destructive",children:s??(($=b.error)==null?void 0:$.message)??((B=N.error)==null?void 0:B.message)}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsx(_,{"data-testid":"setup-install",variant:"outline",disabled:l||!T||!((I=w.info)!=null&&I.ready),onClick:()=>void C("install"),children:"Install for coding agent"}),t.jsx(_,{"data-testid":"setup-launch",disabled:l||!T||!((R=w.info)!=null&&R.ready),onClick:()=>void C("run"),children:l?"Preparing…":"Run in ORC terminal"}),t.jsx(_,{"data-testid":"setup-command",variant:"outline",disabled:l||b.isPending||!T,onClick:()=>b.mutate({...r,operation:d}),children:b.isPending?"Preparing command…":"Command for my terminal"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"command-mode",children:"Command for your terminal"}),t.jsxs("select",{id:"command-mode",className:"w-full rounded border border-control-border bg-surface-low p-3 text-sm",disabled:l||b.isPending,value:d,onChange:x=>{c(x.target.value),b.reset()},children:[t.jsx("option",{value:"run",children:"Install and launch the agent"}),t.jsx("option",{value:"install",children:"Install configuration only"})]})]}),b.data&&t.jsxs("div",{ref:u,className:"min-w-0 space-y-2 rounded border border-surface-highest p-3",children:[t.jsxs(re,{htmlFor:"package-command",children:["Run in ",b.data.shell," on the ORC machine"]}),t.jsx(We,{id:"package-command","data-testid":"package-command",value:b.data.command,readOnly:!0,rows:3,className:"font-mono text-xs"}),t.jsx(_,{variant:"outline",onClick:async()=>{try{await navigator.clipboard.writeText(b.data.command),v(!0)}catch{i("Copy is unavailable in this browser. Select and copy the command above.")}},children:o?"Copied":"Copy command"})]})]})})}function da(e,a){Ka(new Blob([new Uint8Array(a)],{type:"application/zip"}),e)}function zt(){const{agentId:e}=za();return t.jsx(Ba,{replace:!0,to:`/packages/agents${e?`/${encodeURIComponent(e)}`:""}`})}function Bt(){var x,L,H,Y,J;const e=La(),[a,r]=Da(),n=ua(),[s,i]=we("packageAction","",["","new","import","edit"]),l=ve({queryKey:["agent-packages"],queryFn:V.agentPackages.list}),g=ve({queryKey:["package-tools"],queryFn:V.packageTools.list}),{selectedId:o,closeDetail:v}=Ua("/packages/item","packageName"),d=s==="new",c=f=>i(f?"new":""),[u,y]=z.useState(),m=s==="import",w=f=>i(f?"import":"");function P(f){const k=new URLSearchParams(window.location.search);k.delete("packageAction"),n(`/packages/item/${encodeURIComponent(f)}?${k}`)}function N(f){const k=new URLSearchParams(window.location.search);k.set("packageAction","edit"),n(`/packages/item/${encodeURIComponent(f)}?${k}`)}const[b,S]=z.useState(),[M,D]=z.useState(),[T,F]=z.useState(!1),[C,j]=z.useState(),O=a.get("q")??"",E=a.get("format")??"all";async function q(){await Promise.all(["agent-packages","agents","skills","package-skill-picker","agent-package","agent-package-files"].map(f=>e.invalidateQueries({queryKey:[f]})))}const U=je({mutationFn:f=>u?V.agentPackages.update(u.name,{content:f.content,files:f.files,skills:f.skills,expectedRevision:u.revision}):V.agentPackages.create(f),onSuccess:async f=>{await q(),Na((u==null?void 0:u.name)??"new"),c(!1),y(void 0),j(`${f.name} saved to your catalog.`),P(f.name)}}),h=U.reset;z.useEffect(()=>{let f=!0;if(y(void 0),s!=="edit"||!o){F(!1);return}return F(!0),D(void 0),h(),(async()=>{try{const k=await V.agentPackages.get(o),G=await Promise.all(k.files.map(async ae=>{const se=await V.agentPackages.get(o,ae.name);return{path:ae.name,content:se.content,encoding:se.encoding}}));if(!k.revision)throw new Error("Package revision is missing; update the API before editing");const Q=Nt(o);f&&y(Q?{...k,content:Q.content,format:Q.format,revision:Q.revision??k.revision,draftFiles:Q.files}:{...k,draftFiles:G})}catch(k){f&&D(k.message)}finally{f&&F(!1)}})(),()=>{f=!1}},[s,o,h]);function $(f){var G;const k=(G=l.data)==null?void 0:G.packages.find(Q=>Q.name===f);v(),S({name:`${f.replace(/\./g,"-")}-setup`,packages:[f],backend:(k==null?void 0:k.format)==="agent-plugin"?"copilot":"claude",tool:"apm",cwd:"",prompt:""})}async function B(f){F(!0),D(void 0);try{const k=await V.agentPackages.get(f),G={[`${f}/${k.manifestFile}`]:$e(k.content)};for(const Q of k.files){const ae=await V.agentPackages.get(f,Q.name);G[`${f}/${Q.name}`]=ae.encoding==="base64"?Uint8Array.from(atob(ae.content),se=>se.charCodeAt(0)):$e(ae.content)}da(`${f}-source.zip`,ht(G))}catch(k){D(k.message)}finally{F(!1)}}async function I(f){F(!0),D(void 0),j("APM is building the installation archive…");try{const k=await V.agentPackages.exportArtifact(f);da(k.filename,Uint8Array.from(atob(k.content),G=>G.charCodeAt(0))),j(`Exported ${k.format} installation archive.`)}catch(k){D(k.message),j(void 0)}finally{F(!1)}}const R=((x=l.data)==null?void 0:x.packages.filter(f=>`${f.name} ${f.description}`.toLowerCase().includes(O.toLowerCase())&&(E==="all"||f.format===E)))??[];return t.jsxs("div",{className:"min-w-0 space-y-5",children:[t.jsx(Ra,{title:"Packages",meta:`${((L=l.data)==null?void 0:L.packages.length)??0} in your catalog`,action:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs(_,{variant:"outline","data-testid":"package-import-button",onClick:()=>w(!0),children:[t.jsx(Wa,{size:16,className:"mr-2"}),"Import"]}),t.jsxs(_,{"data-testid":"new-agent-package-button",onClick:()=>{U.reset(),c(!0)},children:[t.jsx(_a,{size:16,className:"mr-2"}),"New package"]})]})}),t.jsx("div",{className:"space-y-1",children:t.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Keep the instructions, skills and tools you trust in one place. Save a package once, then install it for your coding agent or launch a configured terminal."})}),C&&t.jsx("p",{role:"status",className:"text-sm text-primary break-words",children:C}),(M||l.error)&&t.jsx("p",{role:"alert","data-testid":"package-error",className:"text-sm text-destructive",children:t.jsx("span",{"data-testid":"page-error",children:M??((H=l.error)==null?void 0:H.message)})}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[t.jsxs("div",{className:"relative min-w-0 flex-1",children:[t.jsx(Oa,{size:16,className:"absolute left-3 top-3 text-muted-foreground"}),t.jsx(he,{className:"pl-9","data-testid":"package-search","aria-label":"Search packages",placeholder:"Find a configuration by name or purpose…",value:O,onChange:f=>{const k=new URLSearchParams(a);f.target.value?k.set("q",f.target.value):k.delete("q"),r(k,{replace:!0})}})]}),t.jsxs("select",{"aria-label":"Filter package type","data-testid":"package-format-filter",className:"rounded border border-control-border bg-background p-2 text-sm",value:E,onChange:f=>{const k=new URLSearchParams(a);k.set("format",f.target.value),r(k,{replace:!0})},children:[t.jsx("option",{value:"all",children:"All formats"}),t.jsx("option",{value:"apm",children:"APM packages"}),t.jsx("option",{value:"agent-plugin",children:"Agent Plugins"})]})]}),l.isLoading&&t.jsx("p",{role:"status","data-testid":"page-loading",children:"Loading your catalog…"}),t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:R.map(f=>t.jsxs("article",{"data-testid":"agent-package-row","data-package-name":f.name,className:"min-w-0 flex flex-col border-b border-outline-variant p-4",children:[t.jsxs("span",{className:"mb-3 text-xs text-muted-foreground",children:[f.format==="apm"?"APM package":"Agent Plugins",f.version?` · v${f.version}`:""]}),t.jsx("button",{type:"button","data-testid":"package-inspect",onClick:()=>P(f.name),className:"text-left font-medium break-words hover:text-primary",children:f.name}),t.jsx("p",{className:"mt-2 flex-1 text-sm text-muted-foreground break-words",children:f.description||"Add a description to help you choose this configuration later."}),f.warnings.map(k=>t.jsx("p",{className:"mt-2 text-xs text-muted-foreground break-words",children:k},k)),t.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2",children:[t.jsx(_,{variant:"outline","data-testid":"package-run",disabled:T,onClick:()=>$(f.name),children:"Use package"}),t.jsx(_,{variant:"outline","data-testid":"package-card-edit",onClick:()=>void N(f.name),children:"Edit package"})]})]},f.name))}),!l.isLoading&&!l.error&&!R.length&&t.jsxs("div",{"data-testid":"page-empty",className:"rounded-lg border border-dashed border-outline-variant px-4 py-10 text-center",children:[t.jsx(Va,{size:32,className:"mx-auto mb-3 text-muted-foreground"}),t.jsx("h3",{className:"font-medium",children:O||E!=="all"?"No matching configurations":"Build your personal agent catalog"}),t.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm text-muted-foreground",children:O||E!=="all"?"Try another search or package format.":"Create an APM package with your instructions and existing skills, or import an Agent Plugin from GitHub."}),!O&&E==="all"&&t.jsx(_,{className:"mt-4",onClick:()=>{U.reset(),c(!0)},children:"Create your first package"})]}),(Y=l.data)==null?void 0:Y.broken.map(f=>t.jsxs("p",{role:"alert",className:"text-destructive break-words",children:[f.path,": ",f.error]},f.path)),g.data&&!g.data.apm&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Catalog editing is available. Installation, Git acquisition and installation exports require APM on this ORC machine."}),o&&!s&&t.jsx(xt,{name:o,onClose:v,onUse:()=>$(o),onEdit:()=>void N(o),onExport:()=>void I(o),onSource:()=>void B(o),busy:T,operationError:M},o),t.jsx(Xe,{open:d||s==="edit",onOpenChange:f=>{if(!f&&!U.isPending){if(!Ze((u==null?void 0:u.name)??"new"))return;c(!1),y(void 0)}},children:d||s==="edit"&&u?t.jsx(Ct,{initial:u?{name:u.name,content:u.content,format:u.format,files:u.draftFiles,revision:u.revision}:void 0,pending:U.isPending,error:(J=U.error)==null?void 0:J.message,onSave:f=>U.mutate(f)}):s==="edit"?t.jsxs(Ee,{children:[t.jsx(Le,{children:t.jsx(De,{children:"Package editor"})}),t.jsx("p",{role:M?"alert":"status",children:M??"Opening package editor…"})]}):null}),m&&t.jsx(St,{onClose:()=>w(!1),onImported:f=>{q(),w(!1),j(`${f} added to your catalog.`),P(f)}}),b&&t.jsx(At,{initial:b,onClose:()=>S(void 0)},b.name)]})}export{zt as LegacyAgentsRedirect,Bt as default};
@@ -1 +1 @@
1
- import{j as t,A as c,E as o}from"./index-C_jtMgr7.js";const i="inline-flex min-h-11 items-center gap-1 font-label text-xs text-primary hover:text-on-surface disabled:opacity-40 disabled:hover:text-primary";function h({page:e,pageSize:s,total:a,onPage:n}){const r=Math.max(1,Math.ceil(a/s));if(a<=s)return null;const l=e*s+1,x=Math.min(a,(e+1)*s);return t.jsxs("div",{"data-testid":"pager",className:"flex flex-wrap gap-2 items-center justify-between border-t border-surface-highest px-3 py-2",children:[t.jsxs("span",{className:"font-label text-xs text-outline",children:[l,"–",x," of ",a]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{type:"button","data-testid":"pager-prev",className:i,disabled:e===0,onClick:()=>n(e-1),children:[t.jsx(c,{className:"h-3 w-3"}),"Prev"]}),t.jsxs("span",{className:"font-label text-xs text-outline",children:["Page ",e+1," / ",r]}),t.jsxs("button",{type:"button","data-testid":"pager-next",className:i,disabled:e>=r-1,onClick:()=>n(e+1),children:["Next",t.jsx(o,{className:"h-3 w-3"})]})]})]})}export{h as P};
1
+ import{j as t,E as c,F as o}from"./index-CYCjrqhG.js";const i="inline-flex min-h-11 items-center gap-1 font-label text-xs text-primary hover:text-on-surface disabled:opacity-40 disabled:hover:text-primary";function h({page:e,pageSize:s,total:a,onPage:n}){const r=Math.max(1,Math.ceil(a/s));if(a<=s)return null;const l=e*s+1,x=Math.min(a,(e+1)*s);return t.jsxs("div",{"data-testid":"pager",className:"flex flex-wrap gap-2 items-center justify-between border-t border-surface-highest px-3 py-2",children:[t.jsxs("span",{className:"font-label text-xs text-outline",children:[l,"–",x," of ",a]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{type:"button","data-testid":"pager-prev",className:i,disabled:e===0,onClick:()=>n(e-1),children:[t.jsx(c,{className:"h-3 w-3"}),"Prev"]}),t.jsxs("span",{className:"font-label text-xs text-outline",children:["Page ",e+1," / ",r]}),t.jsxs("button",{type:"button","data-testid":"pager-next",className:i,disabled:e>=r-1,onClick:()=>n(e+1),children:["Next",t.jsx(o,{className:"h-3 w-3"})]})]})]})}export{h as P};
@@ -1 +1 @@
1
- import{j as a,K as o}from"./index-C_jtMgr7.js";const r={critical:"text-error font-bold",high:"text-tertiary font-semibold",normal:"text-on-surface-variant",low:"text-outline"};function s({priority:t,className:e}){return a.jsx("span",{className:o("font-label text-xs ",r[t],e),children:t.charAt(0).toUpperCase()+t.slice(1)})}export{s as P};
1
+ import{j as a,A as o}from"./index-CYCjrqhG.js";const r={critical:"text-error font-bold",high:"text-tertiary font-semibold",normal:"text-on-surface-variant",low:"text-outline"};function s({priority:t,className:e}){return a.jsx("span",{className:o("font-label text-xs ",r[t],e),children:t.charAt(0).toUpperCase()+t.slice(1)})}export{s as P};
@@ -0,0 +1,3 @@
1
+ import{e as M,r as n,f as U,g as F,j as e,B as T,P as O,h as L,S as V,C as H,i as W,k as G,l as J,D as q,m as K,n as Q,o as X,p,I as k,T as Y,q as Z,s as ee,t as te,v as se,w as ae,x as re,y as B,L as le,M as oe}from"./index-CYCjrqhG.js";import{u as ne,B as ie}from"./useListSelection-tj_f-2Ad.js";import{C as ce}from"./ConfirmDialog-UlZrlBrT.js";import{E as de}from"./EmptyState-CLMWpYxU.js";import{E as me}from"./ErrorState-_BM228mQ.js";import{T as ue}from"./TaskDetailSheet-BnMsuYO6.js";import{T as xe,a as pe,b as z,c as m,d as be,e as u}from"./table-D-x54JQs.js";import{T as ge,a as je,b as he,c as fe}from"./tabs-Dwtb498J.js";import{V as Ne}from"./ViewHeader-CG7vOMnJ.js";import{u as ve}from"./useDetailRoute-DiC2IR0t.js";import{u as Se}from"./view-params-Duc_5Bxj.js";import{T as ye}from"./trash-2-C4wuE82r.js";import"./PriorityBadge-q0hZXCLg.js";import"./StatusBadge-BxSWnu8L.js";import"./ResumeActions-Bihtv9n8.js";import"./live-sessions-C19eXx17.js";import"./copy-DG3MHKpv.js";import"./useSessions-BNsSZXqv.js";const ke=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"archived",label:"Archived"},{value:"paused",label:"Paused"}];function We(){var $;const{data:r,isLoading:l,error:d,refetch:E}=M(),[o,_]=Se("status","all",["all","active","archived","paused"]),[f,C]=n.useState(!1),[N,v]=n.useState(null),[b,P]=n.useState(null),[g,S]=n.useState(null),{selectedId:y,openDetail:w,closeDetail:j}=ve("/projects","projectId"),D=U(),c=y?(r??[]).find(t=>t.id===y)??null:null,x=n.useMemo(()=>{const t=r??[];return o==="all"?t:t.filter(a=>a.status===o)},[r,o]),i=ne(x.map(t=>t.id),o),s=F(),h=(($=s.data)==null?void 0:$.scope)===o?s.data:void 0;async function A(t){const a=await s.mutateAsync({ids:i.selectedIds,status:t,scope:o});i.select(a.failed.map(I=>I.id))}const R=n.useMemo(()=>(r??[]).reduce((t,a)=>(t[a.status]=(t[a.status]??0)+1,t),{}),[r]);return d?e.jsx(me,{message:d.message,onRetry:()=>E()}):e.jsxs("div",{children:[e.jsx(Ne,{title:"Projects",meta:`${(r??[]).length} total`,action:e.jsxs(T,{"data-testid":"new-project-button",size:"sm",onClick:()=>C(!0),className:"font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(O,{size:12,className:"mr-1"}),"New project"]})}),e.jsxs(ge,{value:o,onValueChange:t=>_(t),className:"mb-4",children:[e.jsx(je,{className:"bg-transparent gap-1 h-auto max-w-full flex-wrap justify-start p-0",children:ke.map(({value:t,label:a})=>e.jsxs(he,{"data-testid":`projects-filter-${t}`,value:t,className:`font-label text-sm px-4 py-2 rounded-md
2
+ data-[state=active]:bg-surface-highest data-[state=active]:text-on-surface data-[state=active]:shadow-none
3
+ text-muted-foreground hover:text-on-surface`,children:[a,t!=="all"&&R[t]!=null&&e.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground px-1.5 py-0.5",children:R[t]})]},t))}),x.length>0&&e.jsx(ie,{resourceLabel:"projects",count:i.selectedIds.length,allSelected:i.allSelected,someSelected:i.someSelected,onSelectAll:i.selectAll,onClear:i.clear,disabled:s.isPending,children:L.map(t=>e.jsxs(T,{type:"button",size:"sm",variant:"outline",disabled:s.isPending,"data-testid":`projects-bulk-${t}`,onClick:()=>void A(t),children:[t==="active"?"Activate":t==="paused"?"Pause":"Archive"," ","selected"]},t))}),s.isPending&&e.jsx("p",{role:"status",className:"mb-3 text-sm text-outline",children:"Updating selected projects..."}),!s.isPending&&h&&e.jsxs("div",{role:"status",className:"mb-3 space-y-1 text-sm","data-testid":"projects-bulk-result",children:[e.jsxs("p",{children:[h.succeeded.length," projects set to ",h.status,"."]}),h.failed.map(t=>{var a;return e.jsxs("p",{className:"text-error",children:[((a=r==null?void 0:r.find(I=>I.id===t.id))==null?void 0:a.name)??t.id,": ",t.error,". Still selected for retry."]},t.id)})]}),e.jsx(fe,{value:o,children:l?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((t,a)=>e.jsx(V,{className:"h-12 w-full bg-surface-highest"},a))}):x.length===0?e.jsx(de,{message:"No projects"}):e.jsx("div",{className:"overflow-hidden",children:e.jsxs(xe,{children:[e.jsx(pe,{children:e.jsxs(z,{className:"border-b border-outline-variant hover:bg-transparent",children:[e.jsx(m,{className:"w-11",children:e.jsx("span",{className:"sr-only",children:"Select projects"})}),e.jsx(m,{className:"font-label text-sm text-muted-foreground",children:"Name"}),e.jsx(m,{className:"font-label text-sm text-muted-foreground",children:"Description"}),e.jsx(m,{className:"font-label text-sm text-muted-foreground w-28",children:"Status"}),e.jsx(m,{className:"font-label text-sm text-muted-foreground w-36",children:"Tags"}),e.jsx(m,{className:"font-label text-sm text-muted-foreground w-24",children:"Max Workers"}),e.jsx(m,{className:"font-label text-sm text-muted-foreground w-24",children:"Created"}),e.jsx(m,{className:"w-10"})]})}),e.jsx(be,{children:x.map(t=>e.jsxs(z,{"data-testid":"project-row","data-project-id":t.id,"data-project-name":t.name,className:"border-b border-outline-variant/50 hover:bg-surface-high cursor-pointer",onClick:()=>w(t.id),children:[e.jsx(u,{children:e.jsx("input",{type:"checkbox","data-testid":"project-select","aria-label":`Select ${t.name}`,className:"size-4 accent-primary",checked:i.selectedIds.includes(t.id),disabled:s.isPending,onClick:a=>a.stopPropagation(),onChange:()=>i.toggle(t.id)})}),e.jsx(u,{className:"font-body text-sm font-medium text-on-surface",children:e.jsx("button",{type:"button",className:"min-h-11 text-left hover:text-primary","aria-label":`Edit project: ${t.name}`,onClick:a=>{a.stopPropagation(),w(t.id)},children:t.name})}),e.jsx(u,{className:"font-body text-sm text-muted-foreground max-w-xs truncate",children:t.description??"—"}),e.jsx(u,{children:e.jsxs("span",{className:"inline-flex items-center gap-2 text-xs font-normal capitalize text-muted-foreground",children:[e.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.status==="active"?"bg-secondary":t.status==="paused"?"bg-tertiary":"bg-outline"}`}),t.status]})}),e.jsx(u,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(t.tags??[]).map(a=>e.jsx("span",{className:"font-label text-sm px-1.5 py-0.5 text-muted-foreground",children:a},a))})}),e.jsx(u,{className:"font-label text-sm text-on-surface text-center",children:t.max_workers??"—"}),e.jsx(u,{className:"font-label text-sm text-muted-foreground",children:new Date(t.created_at).toLocaleDateString()}),e.jsx(u,{children:e.jsx("button",{type:"button","data-testid":"project-delete","aria-label":`Delete project: ${t.name}`,onClick:a=>{a.stopPropagation(),S(t)},className:"text-muted-foreground hover:text-error transition-colors p-1",children:e.jsx(ye,{size:12})})})]},t.id))})]})})})]}),f&&e.jsx(H,{open:f,onClose:()=>C(!1),onFirstTask:v}),N&&e.jsx(W,{open:!0,defaultProjectId:N,onClose:()=>v(null),onCreated:P}),e.jsx(ue,{taskId:b,open:!!b,onOpenChange:t=>{t||P(null)}}),c&&e.jsx(Te,{open:!!c,project:c,onClose:j,onFirstTask:t=>{j(),v(t)}},c.id),g&&e.jsx(ce,{open:!!g,title:"Delete project",description:"This deletes the project, its memories and its scratchpads. Its tasks, jobs and sessions are kept without a project. This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",isPending:D.isPending,onConfirm:()=>{D.mutate(g.id,{onSuccess:()=>S(null)})},onCancel:()=>S(null)})]})}function Te({open:r,project:l,onClose:d,onFirstTask:E}){const[o,_]=n.useState(l.name),[f,C]=n.useState(l.description??""),[N,v]=n.useState(l.status),[b,P]=n.useState((l.tags??[]).join(", ")),[g,S]=n.useState(l.scope??""),[y,w]=n.useState(l.git_remote_url??""),[j,D]=n.useState(l.max_workers!=null?String(l.max_workers):""),c=G(),{data:x}=J(l.id),i=s=>{if(s.preventDefault(),!o.trim())return;const h={id:l.id,name:o.trim(),description:f.trim()||null,status:N,tags:b.trim()?b.split(",").map(A=>A.trim()).filter(Boolean):null,scope:g.trim()||null,git_remote_url:y.trim()||null,max_workers:j?Number(j):null};c.mutate(h,{onSuccess:()=>d()})};return e.jsx(q,{open:r,onOpenChange:s=>!s&&d(),children:e.jsxs(K,{"data-testid":"edit-project-dialog",className:"bg-surface border-outline-variant max-w-lg max-h-[calc(100dvh-2rem)] overflow-y-auto",children:[e.jsx(Q,{children:e.jsx(X,{className:"font-headline text-base text-on-surface",children:"Edit Project"})}),x&&e.jsx(Ce,{summary:x}),e.jsx(T,{type:"button","data-testid":"project-create-task",variant:"outline",size:"sm",onClick:()=>E(l.id),children:"Create task in this project"}),e.jsxs("form",{onSubmit:i,className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{className:"font-label text-sm text-muted-foreground",children:"Name *"}),e.jsx(k,{"aria-label":"Name","data-testid":"edit-project-name-input",value:o,onChange:s=>_(s.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{className:"font-label text-sm text-muted-foreground",children:"Description"}),e.jsx(Y,{"aria-label":"Description",value:f,onChange:s=>C(s.target.value),rows:2,className:"bg-background border-control-border text-on-surface font-body text-sm resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{className:"font-label text-sm text-muted-foreground",children:"Status"}),e.jsxs(Z,{value:N,onValueChange:s=>v(s),children:[e.jsx(ee,{"aria-label":"Status",className:"bg-background border-control-border text-on-surface font-label text-sm",children:e.jsx(te,{})}),e.jsx(se,{className:"bg-surface border-outline-variant",children:L.map(s=>e.jsx(ae,{value:s,className:"font-label text-sm",children:s},s))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{className:"font-label text-sm text-muted-foreground",children:"Max Workers"}),e.jsx(k,{"aria-label":"Max Workers",type:"number",min:1,value:j,onChange:s=>D(s.target.value),placeholder:"1",className:"bg-background border-control-border text-on-surface font-body text-sm"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{className:"font-label text-sm text-muted-foreground",children:"Tags (comma separated)"}),e.jsx(k,{"aria-label":"Tags (comma separated)",value:b,onChange:s=>P(s.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{className:"font-label text-sm text-muted-foreground",children:"Scope"}),e.jsx(k,{"aria-label":"Scope",value:g,onChange:s=>S(s.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{htmlFor:"edit-project-git-remote-url",className:"font-label text-sm text-muted-foreground",children:"Git remote URL (optional)"}),e.jsx(k,{id:"edit-project-git-remote-url",className:"bg-background border-control-border text-on-surface font-body text-sm","data-testid":"edit-project-git-remote-url",value:y,onChange:s=>w(s.target.value),placeholder:"https://github.com/owner/repo.git or git@github.com:owner/repo.git"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Clear this field to remove the saved address."})]}),e.jsxs(re,{children:[e.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:d,className:"font-label text-sm text-muted-foreground",children:"Cancel"}),e.jsx(T,{"data-testid":"edit-project-submit",type:"submit",size:"sm",disabled:c.isPending||!o.trim(),className:"font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90",children:c.isPending?"Saving...":"Save"})]}),c.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:c.error.message})]})]})})}function Ce({summary:r}){return e.jsxs("div",{className:"grid grid-cols-3 gap-4 py-3 border-t border-outline-variant mt-2",children:[e.jsxs(B,{label:"Tasks",children:[e.jsx("span",{className:"font-label text-sm text-primary",children:r.tasks.total}),Object.keys(r.tasks.by_status).length>0&&e.jsxs("span",{className:"text-muted-foreground text-sm ml-1",children:["(",Object.entries(r.tasks.by_status).map(([l,d])=>`${d} ${l}`).join(", "),")"]})]}),e.jsx(B,{label:"Memories",children:e.jsx(le,{"data-testid":"project-memories-link",to:`${oe}?project=${encodeURIComponent(r.project.id)}`,className:"font-label text-sm text-primary underline",children:r.memories})}),e.jsx(B,{label:"Jobs",children:e.jsx("span",{className:"font-label text-sm text-primary",children:r.jobs})})]})}export{We as default};
@@ -0,0 +1 @@
1
+ import{a8 as $,J as z,a9 as E,H as U,r as i,j as e,aa as O,ab as I,ac as L,ad as A,ae as M,af as _,ag as q,ah as D,d as F}from"./index-CYCjrqhG.js";import{r as H,a as J,L as B,s as v}from"./live-sessions-C19eXx17.js";import{C as G}from"./copy-DG3MHKpv.js";function K(t){return`/terminals?session=${encodeURIComponent(t)}`}function Q(t){return`/terminals/${t}`}function V(t,r){return t.find(s=>s.live_session_id===r&&s.status==="running")}function W(t,r=window.location.origin){return`${r}${t}`}const d="inline-flex min-h-9 items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-border px-2 py-1 text-xs text-primary hover:bg-surface-highest disabled:opacity-50";function ee({session:t}){const{openLiveSession:r,info:s,terminals:k}=$(),h=z(),S=E(),[x]=U(),[u,f]=i.useState(!1),[m,b]=i.useState(!1),[g,n]=i.useState(null),[o,y]=i.useState(null),[N,p]=i.useState(!1),l=H(t),c=V(k,t.id),j=x.get("project")??t.project_id,C=["claude","codex"].includes(t.agent)?!l||!t.cwd?"Session has no native session ID or working folder.":t.status==="running"||t.status==="idle"?"End the original agent session before resuming it in chat.":void 0:"Chat currently supports Claude and Codex sessions.";i.useEffect(()=>{if(!o)return;const a=setTimeout(()=>y(null),2e3);return()=>clearTimeout(a)},[o]);async function P(){if(n(null),c){h(v(Q(c.id),j));return}f(!0);try{await r(t)}catch(a){n(a instanceof Error?a.message:"Could not open terminal")}finally{f(!1)}}async function w(a,T){p(!1),n(null);try{await navigator.clipboard.writeText(a),y(T)}catch{n("Clipboard access failed. Allow clipboard access and try again.")}}async function R(){p(!1),b(!0),n(null);try{S.openThread(await F.chat.resume(t.id));const a=new URLSearchParams(x);a.delete("session"),a.set("chat","open"),h({search:a.toString()})}catch(a){n(a instanceof Error?a.message:"Could not resume in chat")}finally{b(!1)}}return!l&&!c?e.jsx("span",{"data-testid":"resume-unavailable",className:"block max-w-64 text-xs text-outline",children:J(t)}):e.jsxs("div",{className:"max-w-72 space-y-1 text-left",children:[e.jsxs("fieldset",{"aria-label":"Resume session",className:"inline-flex",children:[e.jsxs("button",{type:"button","data-testid":"open-terminal-resume",disabled:u||m||!c&&!(s!=null&&s.ready),onClick:()=>void P(),className:`${d} rounded-r-none`,children:[e.jsx(O,{size:13}),u?"Resuming…":"Resume in terminal"]}),e.jsxs(I,{open:N,onOpenChange:p,children:[e.jsx(L,{asChild:!0,children:e.jsx("button",{type:"button","data-testid":"resume-actions-menu","aria-label":"More session actions",className:`${d} rounded-l-none border-l-0 px-2`,children:e.jsx(A,{size:13})})}),e.jsx(M,{children:e.jsxs(_,{align:"end",sideOffset:4,collisionPadding:8,"aria-label":"Session actions","data-testid":"resume-actions-dropdown",className:"z-50 w-56 rounded-md border border-border bg-surface-high p-1 shadow-lg",children:[e.jsxs("button",{type:"button","data-testid":"open-chat-resume",disabled:u||m||!!C,title:C,onClick:()=>void R(),className:`${d} min-h-11 w-full justify-start border-0`,children:[e.jsx(q,{size:13}),m?"Resuming…":"Continue in chat"]}),l&&e.jsxs("button",{type:"button","data-testid":"copy-resume",className:`${d} w-full justify-start border-0`,title:l,onClick:()=>void w(l,"Resume command copied"),children:[o==="Resume command copied"?e.jsx(D,{size:13}):e.jsx(G,{size:13}),"Copy resume command"]}),e.jsxs("button",{type:"button","data-testid":"copy-terminal-link",className:`${d} w-full justify-start border-0`,"aria-label":"Copy terminal link",title:"Copy terminal link",onClick:()=>void w(W(v(K(t.id),j)),"Terminal link copied"),children:[e.jsx(B,{size:13}),"Copy terminal link"]})]})})]})]}),s&&!s.ready&&!c&&e.jsx("p",{className:"text-xs text-outline",children:s.reason??"Integrated terminals unavailable. Use the copied command in your own terminal."}),o&&e.jsx("p",{role:"status","data-testid":"resume-feedback",className:"text-xs text-outline",children:o}),g&&e.jsx("p",{role:"alert",className:"text-xs text-error break-words",children:g})]})}export{ee as R,V as r,Q as t};
@@ -1,4 +1,4 @@
1
- var Jt=Object.defineProperty;var jt=(n,B,e)=>B in n?Jt(n,B,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[B]=e;var F=(n,B,e)=>jt(n,typeof B!="symbol"?B+"":B,e);import{b0 as W,b1 as pB,b2 as KB,b3 as LB,b4 as At,b5 as lB,b6 as eB,b7 as Lt,b8 as vB,b9 as Ut,ba as Qe,bb as Ye,r as S,j as c,p as Y,I as rB,B as dB,a as Kt,u as qt,e as Qt,b as me,d as te,a8 as Yt,a9 as Vt,aa as zt,ab as Xt,bc as Zt,ac as Wt}from"./index-C_jtMgr7.js";import{V as $t}from"./ViewHeader-DXR0ZaMO.js";import{T as Bs,a as es,b as Ve,c as ze}from"./tabs-CSlEXoxD.js";import{u as Xe}from"./view-params-Bm1Qf6KC.js";import{u as ts}from"./useJobs-Dcl-Vim3.js";function Fe(n,B,e,t=[]){return Object.entries(n).map(([s,C])=>({native:s,event:C,block:B.includes(s),context:e.includes(s),rewrite_command:t.includes(s)}))}const ss={PreToolUse:"pre_tool",PostToolUse:"post_tool",PostToolUseFailure:"post_tool_failure",PostToolBatch:"post_tool_batch",SessionStart:"session_start",SessionEnd:"session_end",UserPromptSubmit:"prompt_submit",UserPromptExpansion:"prompt_expansion",Stop:"stop",StopFailure:"stop_failure",SubagentStart:"subagent_start",SubagentStop:"subagent_stop",PreCompact:"pre_compact",PostCompact:"post_compact",PermissionRequest:"permission_request",PermissionDenied:"permission_denied",Notification:"notification",Setup:"setup",TeammateIdle:"teammate_idle",TaskCreated:"task_created",TaskCompleted:"task_completed",Elicitation:"elicitation",ElicitationResult:"elicitation_result",ConfigChange:"config_change",WorktreeRemove:"worktree_remove",InstructionsLoaded:"instructions_loaded",CwdChanged:"cwd_changed",FileChanged:"file_changed",DirectoryAdded:"directory_added",MessageDisplay:"message_display"},ne={claude:Fe(ss,["PreToolUse","PermissionRequest","UserPromptSubmit","UserPromptExpansion","Stop","SubagentStop","TaskCreated","ConfigChange"],["PreToolUse","PostToolUse","PostToolUseFailure","UserPromptSubmit","SessionStart","SubagentStart","UserPromptExpansion","PostToolBatch","Stop","SubagentStop"],["PreToolUse"]),cursor:Fe({sessionStart:"session_start",sessionEnd:"session_end",preToolUse:"pre_tool",postToolUse:"post_tool",postToolUseFailure:"post_tool_failure",subagentStart:"subagent_start",subagentStop:"subagent_stop",beforeShellExecution:"before_shell",afterShellExecution:"after_shell",beforeMCPExecution:"before_mcp",afterMCPExecution:"after_mcp",beforeReadFile:"before_read",afterFileEdit:"after_edit",beforeSubmitPrompt:"prompt_submit",preCompact:"pre_compact",stop:"stop",afterAgentResponse:"agent_response",afterAgentThought:"agent_thought",beforeTabFileRead:"before_tab_read",afterTabFileEdit:"after_tab_edit",workspaceOpen:"workspace_open"},["preToolUse","beforeShellExecution","beforeMCPExecution","beforeReadFile","beforeTabFileRead","beforeSubmitPrompt","subagentStart"],["sessionStart"]),gemini:Fe({BeforeTool:"pre_tool",AfterTool:"post_tool",BeforeAgent:"prompt_submit",AfterAgent:"stop",BeforeModel:"before_model",AfterModel:"after_model",BeforeToolSelection:"before_tool_selection",SessionStart:"session_start",SessionEnd:"session_end",PreCompress:"pre_compact",Notification:"notification"},["BeforeTool","BeforeAgent","AfterAgent","BeforeModel"],["SessionStart","BeforeAgent","BeforeTool","AfterTool","AfterAgent"]),codex:Fe({PreToolUse:"pre_tool",PermissionRequest:"permission_request",PostToolUse:"post_tool",PreCompact:"pre_compact",PostCompact:"post_compact",UserPromptSubmit:"prompt_submit",SubagentStart:"subagent_start",SubagentStop:"subagent_stop",SessionStart:"session_start",SessionEnd:"session_end",Stop:"stop",Interrupt:"interrupt"},["PreToolUse"],["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","SubagentStart"])};function bt(n,B){if(["claude","codex"].includes(n)&&["runtime:permission_request","runtime:question_request"].includes(B))return{native:"",event:B,block:!0,context:!0,rewrite_command:!1};const e=ne[n];return e==null?void 0:e.find(t=>t.event===B||`native:${t.native}`===B)}/*!
1
+ var Jt=Object.defineProperty;var jt=(n,B,e)=>B in n?Jt(n,B,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[B]=e;var F=(n,B,e)=>jt(n,typeof B!="symbol"?B+"":B,e);import{a$ as W,b0 as pB,b1 as KB,b2 as LB,b3 as At,b4 as lB,b5 as eB,b6 as Lt,b7 as vB,b8 as Ut,b9 as Qe,ba as Ye,r as S,j as c,p as Y,I as rB,B as dB,a as Kt,u as qt,e as Qt,b as me,d as te,aj as Yt,ak as Vt,al as zt,am as Xt,bb as Zt,an as Wt}from"./index-CYCjrqhG.js";import{V as $t}from"./ViewHeader-CG7vOMnJ.js";import{T as Bs,a as es,b as Ve,c as ze}from"./tabs-Dwtb498J.js";import{u as Xe}from"./view-params-Duc_5Bxj.js";import{u as ts}from"./useJobs-TDZx1N1l.js";function Fe(n,B,e,t=[]){return Object.entries(n).map(([s,C])=>({native:s,event:C,block:B.includes(s),context:e.includes(s),rewrite_command:t.includes(s)}))}const ss={PreToolUse:"pre_tool",PostToolUse:"post_tool",PostToolUseFailure:"post_tool_failure",PostToolBatch:"post_tool_batch",SessionStart:"session_start",SessionEnd:"session_end",UserPromptSubmit:"prompt_submit",UserPromptExpansion:"prompt_expansion",Stop:"stop",StopFailure:"stop_failure",SubagentStart:"subagent_start",SubagentStop:"subagent_stop",PreCompact:"pre_compact",PostCompact:"post_compact",PermissionRequest:"permission_request",PermissionDenied:"permission_denied",Notification:"notification",Setup:"setup",TeammateIdle:"teammate_idle",TaskCreated:"task_created",TaskCompleted:"task_completed",Elicitation:"elicitation",ElicitationResult:"elicitation_result",ConfigChange:"config_change",WorktreeRemove:"worktree_remove",InstructionsLoaded:"instructions_loaded",CwdChanged:"cwd_changed",FileChanged:"file_changed",DirectoryAdded:"directory_added",MessageDisplay:"message_display"},ne={claude:Fe(ss,["PreToolUse","PermissionRequest","UserPromptSubmit","UserPromptExpansion","Stop","SubagentStop","TaskCreated","ConfigChange"],["PreToolUse","PostToolUse","PostToolUseFailure","UserPromptSubmit","SessionStart","SubagentStart","UserPromptExpansion","PostToolBatch","Stop","SubagentStop"],["PreToolUse"]),cursor:Fe({sessionStart:"session_start",sessionEnd:"session_end",preToolUse:"pre_tool",postToolUse:"post_tool",postToolUseFailure:"post_tool_failure",subagentStart:"subagent_start",subagentStop:"subagent_stop",beforeShellExecution:"before_shell",afterShellExecution:"after_shell",beforeMCPExecution:"before_mcp",afterMCPExecution:"after_mcp",beforeReadFile:"before_read",afterFileEdit:"after_edit",beforeSubmitPrompt:"prompt_submit",preCompact:"pre_compact",stop:"stop",afterAgentResponse:"agent_response",afterAgentThought:"agent_thought",beforeTabFileRead:"before_tab_read",afterTabFileEdit:"after_tab_edit",workspaceOpen:"workspace_open"},["preToolUse","beforeShellExecution","beforeMCPExecution","beforeReadFile","beforeTabFileRead","beforeSubmitPrompt","subagentStart"],["sessionStart"]),gemini:Fe({BeforeTool:"pre_tool",AfterTool:"post_tool",BeforeAgent:"prompt_submit",AfterAgent:"stop",BeforeModel:"before_model",AfterModel:"after_model",BeforeToolSelection:"before_tool_selection",SessionStart:"session_start",SessionEnd:"session_end",PreCompress:"pre_compact",Notification:"notification"},["BeforeTool","BeforeAgent","AfterAgent","BeforeModel"],["SessionStart","BeforeAgent","BeforeTool","AfterTool","AfterAgent"]),codex:Fe({PreToolUse:"pre_tool",PermissionRequest:"permission_request",PostToolUse:"post_tool",PreCompact:"pre_compact",PostCompact:"post_compact",UserPromptSubmit:"prompt_submit",SubagentStart:"subagent_start",SubagentStop:"subagent_stop",SessionStart:"session_start",SessionEnd:"session_end",Stop:"stop",Interrupt:"interrupt"},["PreToolUse"],["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","SubagentStart"])};function bt(n,B){if(["claude","codex"].includes(n)&&["runtime:permission_request","runtime:question_request"].includes(B))return{native:"",event:B,block:!0,context:!0,rewrite_command:!1};const e=ne[n];return e==null?void 0:e.find(t=>t.event===B||`native:${t.native}`===B)}/*!
2
2
  * re2js
3
3
  * RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
4
4
  *
@@ -0,0 +1,20 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/percentages-BXMCSKIN-DtfDKj6k.js","assets/index-CYCjrqhG.js","assets/index-CY60J5zm.css","assets/save-file-B_ZN6-id.js","assets/copy-DG3MHKpv.js","assets/percentages-BXMCSKIN-DGBKIvAv.css"])))=>i.map(i=>d[i]);
2
+ import{c as ne,b2 as Se,bh as Ne,b9 as F,ba as K,b5 as h,b0 as J,b4 as _e,a$ as O,b7 as P,j as e,B as w,r as c,d as re,bi as Ce,ao as ke,bj as Te,bk as Ee,N as De,e as Q,D as Pe,m as Le,n as Ae,o as Ie,p as I,I as ie,q as V,s as U,t as W,v as X,w as k,x as ze,J as oe,O as ce,S as Y,bl as $e,ah as Re,bm as Me,bn as Oe,P as He,be as Fe,L as le,bo as Ke}from"./index-CYCjrqhG.js";import{C as de}from"./ConfirmDialog-UlZrlBrT.js";import{E as Be}from"./EmptyState-CLMWpYxU.js";import{E as me}from"./ErrorState-_BM228mQ.js";import{D as Ve}from"./DocumentWorkspace-B5QQ9h1l.js";import{a as he,b as Ue,c as We,K as Z,d as Xe,e as Ye,S as Ge,u as Je,s as B,f as Qe}from"./scratchpad-routes-DvtErr_v.js";import{u as $}from"./view-params-Duc_5Bxj.js";import{T as Ze}from"./TagInput-B3BLlodf.js";import{T as qe,a as et,b as te,c as E,d as tt,e as D}from"./table-D-x54JQs.js";import{V as st}from"./ViewHeader-CG7vOMnJ.js";import{u as at}from"./useSessions-BNsSZXqv.js";import{f as nt,L as rt}from"./live-sessions-C19eXx17.js";import{s as it}from"./save-file-B_ZN6-id.js";import{D as ot}from"./download-PQ08tuAg.js";import{T as ct}from"./trash-2-C4wuE82r.js";import{A as lt}from"./arrow-left-DNp3aOhW.js";/**
3
+ * @license lucide-react v1.27.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const dt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],mt=ne("shield-alert",dt);/**
8
+ * @license lucide-react v1.27.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const ht=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ut=ne("shield",ht),M=["doc","diagram","html"],ue=Se(M),xe=200,xt=20,fe={doc:{extension:".md",mime:"text/markdown; charset=utf-8"},diagram:{extension:".excalidraw",mime:"application/json; charset=utf-8"},html:{extension:".html",mime:"text/html; charset=utf-8"}};Ne({type:_e("excalidraw"),elements:J(F(h(),K())),appState:F(h(),K()).optional(),files:F(h(),K()).optional()});function q(t,n){return`${t.normalize("NFKD").replace(/[^\w\s.-]/g,"").trim().replace(/\s+/g,"-").toLowerCase().slice(0,80)||"scratchpad"}${fe[n].extension}`}const pe=h().trim().min(1).max(xe),ge=J(h().min(1).max(64)).max(xt),je=h().min(1).max(200),ft=O({id:h(),kind:ue,title:h(),content:h(),project_id:h().nullable(),session_id:h().nullable(),tags:J(h()),author:h(),revision:P().int(),created_at:P().int(),updated_at:P().int()});ft.omit({content:!0}).extend({size_bytes:P().int()});O({kind:ue,title:pe,content:h().optional(),project_id:h().min(1).nullable().optional(),session_id:je.nullable().optional(),tags:ge.optional(),author:h().min(1).max(200).optional()}).strict();O({title:pe.optional(),content:h().optional(),project_id:h().min(1).nullable().optional(),session_id:je.nullable().optional(),tags:ge.optional(),author:h().min(1).max(200).optional(),if_revision:P().int().min(1).optional()}).strict();O({download_url:h().url().optional(),upload_url:h().url().optional(),filename:h(),revision:P().int(),expires_at:h().datetime()});function pt(t,n,a){if(!/^\/(?![/\\])/.test(t))return!1;const s=new URL(n,a),o=new URL(`${n}${t}`,a),i=s.pathname.replace(/\/$/,"");return o.origin===s.origin&&o.pathname.startsWith(`${i}/`)}function gt({draft:t,children:n}){const a=t.saving?"Saving…":t.dirty?"Unsaved changes":"Saved";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5",children:n}),e.jsx("span",{"data-testid":"scratchpad-save-status",role:"status",className:"text-xs text-outline",children:a}),(t.dirty||t.saving)&&e.jsxs(e.Fragment,{children:[t.stale&&e.jsx(w,{type:"button",size:"sm",variant:"ghost","data-testid":"scratchpad-overwrite",disabled:t.saving,onClick:t.overwrite,children:"Keep mine"}),e.jsx(w,{type:"button",size:"sm",variant:"ghost","data-testid":"scratchpad-discard",disabled:t.saving,onClick:t.discard,children:"Discard"}),e.jsx(w,{type:"button",size:"sm","data-testid":"scratchpad-save",disabled:t.saving,onClick:()=>void t.save(),children:"Save"})]})]}),t.error&&e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[t.error," Your draft has been kept.",t.stale&&" Discard loads their version; Keep mine lets you save over it."]}),t.stale&&!t.error&&e.jsx("p",{role:"status",className:"text-sm text-outline",children:"This scratchpad changed elsewhere. Your draft is preserved: Discard loads their version; Keep mine lets you save over it."})]})}function jt({active:t,onClick:n,children:a,testId:s}){return e.jsx("button",{type:"button","data-testid":s,"aria-pressed":t,onClick:n,className:`inline-flex min-h-9 items-center gap-1.5 font-label text-sm px-3 py-1.5 border transition-colors ${t?"bg-surface-highest text-on-surface border-transparent":"bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:a})}function vt(t){const n=he(),[a,s]=c.useState(t.content),[o,i]=c.useState({content:t.content,revision:t.revision}),[f,d]=c.useState(!1),[S,p]=c.useState(null),b=c.useRef(t.content),u=a!==o.content;c.useEffect(()=>{if(!(t.revision<=o.revision)){if(t.content===o.content){i({content:t.content,revision:t.revision});return}b.current===o.content&&(b.current=t.content,s(t.content),i({content:t.content,revision:t.revision}))}},[t.content,t.revision,o]),c.useEffect(()=>{if(!u)return;const j=y=>y.preventDefault();return window.addEventListener("beforeunload",j),()=>window.removeEventListener("beforeunload",j)},[u]);const g=c.useCallback(j=>{b.current=j,s(j)},[]);async function m(){if(!u||f)return;d(!0),p(null);const j=b.current;try{const y=await re.scratchpads.update(t.id,{content:j,if_revision:o.revision});i({content:y.content,revision:y.revision})}catch(y){p(y instanceof Error?y.message:"Could not save scratchpad")}finally{d(!1),await n()}}function x(){i({content:t.content,revision:t.revision}),p(null)}function N(){b.current=t.content,s(t.content),i({content:t.content,revision:t.revision}),p(null)}return{draft:a,setDraft:g,dirty:u,stale:u&&t.revision!==o.revision,saving:f,error:S,save:m,overwrite:x,discard:N}}const se=["preview","code","split"],bt={preview:"Preview",code:"Code",split:"Split"},yt=400,wt="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals",ve="orc:fetch",G="orc:fetch:result",St=t=>`<script>(()=>{const pending=new Map();let next=0;
13
+ addEventListener("message",(e)=>{const d=e.data;if(e.source!==parent||!d||d.type!=="${G}")return;
14
+ const p=pending.get(d.id);if(!p)return;pending.delete(d.id);
15
+ if(d.error)p.reject(new Error(d.error));
16
+ else p.resolve(new Response(d.body,{status:d.status,statusText:d.statusText,headers:d.headers}));});
17
+ window.orc=Object.freeze({fetch:(path,init={})=>new Promise((resolve,reject)=>{const id=++next;
18
+ pending.set(id,{resolve,reject});
19
+ parent.postMessage({type:"${ve}",nonce:"${t}",id,path:String(path),method:init.method,
20
+ headers:[...new Headers(init.headers)],body:init.body},"*");})});})();<\/script>`,Nt=()=>Array.from(crypto.getRandomValues(new Uint8Array(16)),t=>t.toString(16).padStart(2,"0")).join("");function _t(t,n){const a=St(n),s=/^\s*<!doctype[^>]*>/i.exec(t);return s?`${s[0]}${a}${t.slice(s[0].length)}`:`${a}${t}`}function Ct(t,n){const a=t;return(a==null?void 0:a.type)===ve&&a.nonce===n&&typeof a.id=="number"&&typeof a.path=="string"&&Array.isArray(a.headers)}async function kt(t,n){try{if(!pt(n.path,ke(),window.location.href))throw new Error(`orc.fetch path must be an ORC API path: ${n.path}`);const a=await Te(n.path,{method:n.method,headers:n.headers,body:n.body??null}),s=await a.arrayBuffer();t.postMessage({type:G,id:n.id,status:a.status,statusText:a.statusText,headers:[...a.headers],body:s.byteLength?s:null},"*",s.byteLength?[s]:[])}catch(a){t.postMessage({type:G,id:n.id,error:a instanceof Error?a.message:"Request failed"},"*")}}function ae({html:t,title:n,trusted:a=!1}){const s=c.useRef(null),o=c.useMemo(()=>a?Nt():"",[a,t]);return c.useEffect(()=>{if(!o)return;const i=f=>{var S;const d=(S=s.current)==null?void 0:S.contentWindow;!d||f.source!==d||!Ct(f.data,o)||kt(d,f.data)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[o]),e.jsx("iframe",{ref:s,"data-testid":"scratchpad-html-preview","data-trusted":a||void 0,title:`${n} preview`,sandbox:wt,referrerPolicy:"no-referrer",srcDoc:o?_t(t,o):t,className:`h-[var(--pad-height,70vh)] w-full border bg-white ${a?"border-destructive":"border-outline-variant"}`},a?"trusted":"sandboxed")}function Tt({pad:t}){const n=vt(t),[a,s]=$("padView","preview",se),[o,i]=c.useState(!1),[f,d]=c.useState(!1),S=c.useRef(t.revision);c.useEffect(()=>{t.revision!==S.current&&(S.current=t.revision,t.content!==n.draft&&i(!1))},[t.revision,t.content,n.draft]);const p={...n,discard:()=>{t.content!==n.draft&&i(!1),n.discard()}},[b,u]=c.useState(n.draft);c.useEffect(()=>{const m=setTimeout(()=>u(n.draft),yt);return()=>clearTimeout(m)},[n.draft]);const g=e.jsx(Ce,{path:q(t.title,"html"),value:n.draft,onChange:n.setDraft,onSave:()=>void n.save(),readOnly:n.saving,height:"var(--pad-height, 70vh)",label:"HTML source",testId:"scratchpad-html-source"});return e.jsxs("div",{className:"space-y-3","data-testid":"scratchpad-html",children:[e.jsxs(gt,{draft:p,children:[se.map(m=>e.jsx(jt,{active:a===m,onClick:()=>s(m),testId:`scratchpad-view-${m}`,children:bt[m]},m)),a!=="code"&&(o?e.jsxs(w,{type:"button",size:"sm",variant:"outline","data-testid":"scratchpad-html-sandbox",onClick:()=>i(!1),children:[e.jsx(ut,{size:12,className:"mr-1"})," Back to sandbox"]}):e.jsxs(w,{type:"button",size:"sm",variant:"outline","data-testid":"scratchpad-html-trust",onClick:()=>d(!0),children:[e.jsx(mt,{size:12,className:"mr-1"})," Render with ORC access"]}))]}),o&&a!=="code"&&e.jsxs("p",{role:"status",className:"text-sm text-destructive",children:["This page runs with ORC access: its scripts act as you and can call the API through"," ",e.jsx("code",{className:"font-mono text-xs",children:"orc.fetch()"}),"."]}),a==="preview"?e.jsx(ae,{html:b,title:t.title,trusted:o}):a==="code"?g:e.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[e.jsx("div",{className:"min-w-0",children:g}),e.jsx(ae,{html:b,title:t.title,trusted:o})]}),e.jsx(de,{open:f,title:"Render with ORC access?",description:"The page's scripts will be able to call the ORC API as you through orc.fetch: read and change anything, including starting agents and terminals. They stay in the sandbox; the dashboard does not hand them your API secret, though API calls such as terminals can reach anything you can. Only do this for a page you trust. Access ends when you go back to the sandbox, leave the page, or someone else edits it.",confirmLabel:"Render with access",variant:"destructive",onCancel:()=>d(!1),onConfirm:()=>{d(!1),i(!0)}})]})}const Et=c.lazy(()=>Ee(()=>import("./percentages-BXMCSKIN-DtfDKj6k.js").then(t=>t.S),__vite__mapDeps([0,1,2,3,4,5])));function Dt({pad:t}){return t.kind==="doc"?e.jsx(Pt,{pad:t}):t.kind==="html"?e.jsx(Tt,{pad:t}):e.jsx(c.Suspense,{fallback:e.jsx("div",{role:"status",className:"p-3 text-sm text-outline",children:"Loading diagram editor…"}),children:e.jsx(Et,{pad:t})})}function Pt({pad:t}){const n=he(),a=c.useRef(t.revision);return e.jsx(Ve,{documentId:`scratchpad:${t.id}`,path:q(t.title,"doc"),content:t.content,testId:"scratchpad-doc",layout:"page",pageTitle:t.title,onSave:async(s,o)=>{try{const i=await re.scratchpads.update(t.id,{content:s,if_revision:o===t.content?t.revision:a.current});return a.current=i.revision,s}finally{await n()}}})}const C="all",L="unassigned",Lt=200;function At(t,n){if(t===L)return"";for(const a of[t,n])if(a&&a!==C&&a!==L)return a;return""}function be(t){return new Date(t*1e3).toLocaleString()}function It({projectId:t}){const{scratchpadId:n}=De();return n?e.jsx(Mt,{id:n},n):e.jsx(zt,{defaultProjectId:t})}function ye({kind:t}){const{label:n,icon:a}=Z[t];return e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-label text-xs text-muted-foreground",children:[e.jsx(a,{size:12,"aria-hidden":!0})," ",n]})}function zt({defaultProjectId:t}){var T;const n=oe(),a=ce(),[s,o]=$("padProject",C),[i,f]=$("padKind",C,[C,...M]),[d,S]=$("padQuery",""),[p,b]=c.useState(d);c.useEffect(()=>b(d),[d]);const[u,g]=c.useState(!1);c.useEffect(()=>{const r=new URLSearchParams(a.search);r.get("new")==="1"&&(g(!0),r.delete("new"),n({search:r.toString()},{replace:!0}))},[a.search,n]);const{data:m}=Q({status:"active"}),x=Je({kind:i===C?void 0:i,project_id:s===C||s===L?void 0:s,unassigned:s===L?"true":void 0,q:d||void 0,limit:Lt}),N=((T=x.data)==null?void 0:T.scratchpads)??[],j=r=>{var v;return r?((v=m==null?void 0:m.find(_=>_.id===r))==null?void 0:v.name)??r:"—"},y=!!d||i!==C||s!==C;return e.jsxs("div",{children:[e.jsx(st,{title:"Scratchpads",meta:x.data?`${x.data.total} ${x.data.total===1?"scratchpad":"scratchpads"}`:void 0,action:e.jsxs(w,{"data-testid":"new-scratchpad-button",size:"sm",onClick:()=>g(!0),className:"font-label text-sm",children:[e.jsx(He,{size:12,className:"mr-1"})," New scratchpad"]})}),e.jsxs("p",{className:"mb-4 text-sm leading-relaxed text-muted-foreground",children:["Working docs, diagrams and HTML pages you or an agent keep and come back to. Agents create and edit them with the ",e.jsx("code",{className:"font-mono text-xs",children:"pad_*"})," tools; share one by copying its link."]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(V,{value:s,onValueChange:r=>o(r),children:[e.jsx(U,{"aria-label":"Project","data-testid":"scratchpad-project-filter",className:"h-9 w-48 bg-background text-on-surface font-body text-sm",children:e.jsx(W,{})}),e.jsxs(X,{className:"bg-surface border-outline-variant",children:[e.jsx(k,{value:C,className:"font-body text-sm",children:"All projects"}),e.jsx(k,{value:L,className:"font-body text-sm",children:"No project"}),m==null?void 0:m.map(r=>e.jsx(k,{value:r.id,className:"font-body text-sm",children:r.name},r.id))]})]}),e.jsx("div",{className:"flex shrink-0 flex-wrap gap-1.5",children:[C,...M].map(r=>e.jsx("button",{type:"button",onClick:()=>f(r),"data-testid":`scratchpad-kind-${r}`,"aria-pressed":i===r,className:`font-label text-sm px-3 py-1.5 border transition-colors ${i===r?"bg-surface-highest text-on-surface border-transparent":"bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:r===C?"All":Z[r].label},r))}),e.jsxs("div",{className:"relative min-w-[160px] flex-1",children:[e.jsx(Fe,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(ie,{"aria-label":"Search scratchpads","data-testid":"scratchpad-search-input",value:p,onChange:r=>b(r.target.value),onKeyDown:r=>r.key==="Enter"&&S(r.currentTarget.value),placeholder:"Search titles and content...",className:"pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground"})]}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>S(p),className:"font-label text-sm",children:"Search"})]}),x.error?e.jsx(me,{message:x.error.message,onRetry:()=>void x.refetch()}):x.isLoading?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((r,v)=>e.jsx(Y,{className:"h-10 w-full bg-surface-highest"},v))}):N.length===0?e.jsx(Be,{message:y?"No scratchpads match":"No scratchpads yet"}):e.jsx("div",{className:"overflow-hidden",children:e.jsxs(qe,{children:[e.jsx(et,{children:e.jsxs(te,{className:"border-b border-outline-variant hover:bg-transparent",children:[e.jsx(E,{className:"font-label text-sm text-muted-foreground",children:"Title"}),e.jsx(E,{className:"font-label text-sm text-muted-foreground w-28",children:"Kind"}),e.jsx(E,{className:"font-label text-sm text-muted-foreground",children:"Project"}),e.jsx(E,{className:"font-label text-sm text-muted-foreground hidden md:table-cell",children:"Author"}),e.jsx(E,{className:"font-label text-sm text-muted-foreground w-20 hidden md:table-cell",children:"Size"}),e.jsx(E,{className:"font-label text-sm text-muted-foreground w-44",children:"Updated"})]})}),e.jsx(tt,{children:N.map(r=>e.jsxs(te,{"data-testid":"scratchpad-row","data-scratchpad-id":r.id,className:"border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer",onClick:()=>n(`${B(r.id)}${a.search}`),children:[e.jsxs(D,{className:"font-body text-sm font-medium text-on-surface",children:[e.jsx(le,{to:`${B(r.id)}${a.search}`,className:"inline-flex min-h-11 items-center hover:text-primary",onClick:v=>v.stopPropagation(),children:r.title}),r.tags.length>0&&e.jsx("span",{className:"ml-2 font-label text-xs text-outline",children:r.tags.map(v=>`#${v}`).join(" ")})]}),e.jsx(D,{children:e.jsx(ye,{kind:r.kind})}),e.jsx(D,{className:"font-body text-sm text-muted-foreground",children:j(r.project_id)}),e.jsx(D,{className:"font-body text-sm text-muted-foreground hidden md:table-cell",children:r.author}),e.jsx(D,{className:"font-label text-sm text-muted-foreground hidden md:table-cell",children:Ke(r.size_bytes)}),e.jsx(D,{className:"font-label text-sm text-muted-foreground",children:be(r.updated_at)})]},r.id))})]})}),u&&e.jsx(ee,{defaultProjectId:At(s,t),onClose:()=>g(!1),onSaved:r=>n(B(r.id))})]})}const R="none",z="none",$t=50;function Rt(t,n,a){const s=(t??[]).filter(i=>i.session_id&&(n===R||i.project_id===n||i.session_id===a)).sort((i,f)=>(f.last_activity_at??f.created_at).localeCompare(i.last_activity_at??i.created_at)).slice(0,$t),o=t==null?void 0:t.find(i=>i.session_id===a);return o&&!s.includes(o)?[o,...s]:s}function ee({pad:t,defaultProjectId:n="",defaultKind:a="doc",onClose:s,onSaved:o}){const[i,f]=c.useState((t==null?void 0:t.kind)??a),[d,S]=c.useState((t==null?void 0:t.title)??""),[p,b]=c.useState((t?t.project_id:n)||R),[u,g]=c.useState((t==null?void 0:t.session_id)??z),[m,x]=c.useState((t==null?void 0:t.tags)??[]),{data:N}=Q({status:"active"}),{data:j}=at(!1),y=Rt(j,p,u),T=Ue(),r=We(),v=t?r:T;function _(){const l={title:d.trim(),project_id:p===R?null:p,session_id:u===z?null:u,tags:m},A=H=>{s(),o==null||o(H)};t?r.mutate({id:t.id,...l},{onSuccess:A}):T.mutate({kind:i,...l},{onSuccess:A})}return e.jsx(Pe,{open:!0,onOpenChange:l=>!l&&s(),children:e.jsxs(Le,{"data-testid":"scratchpad-form",className:"sm:max-w-lg",children:[e.jsx(Ae,{children:e.jsx(Ie,{children:t?"Scratchpad properties":"New scratchpad"})}),e.jsxs("form",{className:"space-y-4",onSubmit:l=>{l.preventDefault(),_()},children:[!t&&e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"font-label text-sm",children:"Kind"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:M.map(l=>{const{label:A,icon:H,hint:we}=Z[l];return e.jsxs("button",{type:"button","data-testid":`scratchpad-form-kind-${l}`,"aria-pressed":i===l,onClick:()=>f(l),className:`flex flex-col items-start gap-1 border p-3 text-left transition-colors ${i===l?"border-primary bg-surface-low":"border-outline-variant hover:bg-surface-low"}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-label text-sm",children:[e.jsx(H,{size:14,"aria-hidden":!0})," ",A]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:we})]},l)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"scratchpad-title",children:"Title"}),e.jsx(ie,{id:"scratchpad-title","data-testid":"scratchpad-form-title",value:d,maxLength:xe,autoFocus:!0,onChange:l=>S(l.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"scratchpad-project",children:"Project"}),e.jsxs(V,{value:p,onValueChange:b,children:[e.jsx(U,{id:"scratchpad-project","data-testid":"scratchpad-form-project",children:e.jsx(W,{})}),e.jsxs(X,{className:"bg-surface border-outline-variant",children:[e.jsx(k,{value:R,children:"No project"}),N==null?void 0:N.map(l=>e.jsx(k,{value:l.id,children:l.name},l.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"scratchpad-session",children:"Session"}),e.jsxs(V,{value:u,onValueChange:g,children:[e.jsx(U,{id:"scratchpad-session","data-testid":"scratchpad-form-session",children:e.jsx(W,{})}),e.jsxs(X,{className:"bg-surface border-outline-variant",children:[e.jsx(k,{value:z,children:"No session"}),u!==z&&!y.some(l=>l.session_id===u)&&e.jsx(k,{value:u,children:u.slice(0,8)}),y.map(l=>e.jsxs(k,{value:l.session_id,"data-testid":"scratchpad-form-session-option",children:[l.agent," · ",l.name??"Untitled session"," ·"," ",nt(l.last_activity_at??l.created_at)]},l.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:"Tags"}),e.jsx(Ze,{value:m,onChange:x,placeholder:"Add a tag","aria-label":"Tags","data-testid":"scratchpad-form-tags"})]}),v.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),e.jsxs(ze,{children:[e.jsx(w,{type:"button",variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(w,{type:"submit","data-testid":"scratchpad-form-submit",disabled:!d.trim()||v.isPending,children:t?"Save":"Create"})]})]})]})})}function Mt({id:t}){const n=oe(),a=ce(),{data:s,isLoading:o,error:i,refetch:f}=Xe(t),{data:d}=Q(),[S,p]=c.useState(!1),[b,u]=c.useState(!1),[g,m]=c.useState("idle"),[x,N]=c.useState(!1),j=Ye(),y=`${Ge}${a.search}`;c.useEffect(()=>{if(g!=="copied")return;const _=setTimeout(()=>m("idle"),2e3);return()=>clearTimeout(_)},[g]),c.useEffect(()=>{if(!x)return;function _(l){l.key!=="Escape"||l.defaultPrevented||document.querySelector('[role="dialog"], [role="alertdialog"]')||N(!1)}return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[x]);async function T(){try{await navigator.clipboard.writeText(Qe(t)),m("copied")}catch{m("failed")}}const r=e.jsxs(le,{to:y,className:"inline-flex min-h-11 items-center gap-1.5 font-label text-sm text-muted-foreground hover:text-on-surface",children:[e.jsx(lt,{size:14,"aria-hidden":!0})," Scratchpads"]});if(i)return e.jsxs("div",{children:[r,e.jsx(me,{message:i.message,onRetry:()=>void f()})]});if(o||!s)return e.jsxs("div",{className:"space-y-3",children:[r,e.jsx(Y,{className:"h-8 w-1/2 bg-surface-highest"}),e.jsx(Y,{className:"h-64 w-full bg-surface-highest"})]});const v=s.project_id?d==null?void 0:d.find(_=>_.id===s.project_id):void 0;return e.jsxs("div",{"data-testid":"scratchpad-page","data-scratchpad-kind":s.kind,className:"min-w-0",children:[r,e.jsxs("div",{className:"mt-2 mb-4 flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h1",{"data-testid":"scratchpad-title",className:"font-headline font-medium text-2xl tracking-tight text-on-surface break-words",children:s.title}),e.jsxs("div",{"data-testid":"scratchpad-meta",className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-outline",children:[e.jsx(ye,{kind:s.kind}),e.jsxs("span",{children:["revision ",s.revision]}),e.jsxs("span",{children:["by ",e.jsx("span",{"data-testid":"scratchpad-author",children:s.author}),","," ",be(s.updated_at)]}),e.jsx("span",{children:(v==null?void 0:v.name)??(s.project_id?s.project_id:"No project")}),s.session_id&&e.jsxs("span",{title:"Agent session that created it",children:["session ",e.jsx("code",{className:"font-mono text-xs",children:s.session_id.slice(0,8)})]}),s.tags.length>0&&e.jsx("span",{children:s.tags.map(_=>`#${_}`).join(" ")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(w,{"data-testid":"scratchpad-fullscreen",size:"sm",variant:"outline",onClick:()=>N(!0),children:[e.jsx($e,{size:12,className:"mr-1"})," Full screen"]}),e.jsxs(w,{"data-testid":"scratchpad-copy-link",size:"sm",variant:"outline",onClick:()=>void T(),children:[g==="copied"?e.jsx(Re,{size:12,className:"mr-1"}):e.jsx(rt,{size:12,className:"mr-1"}),g==="copied"?"Copied":"Copy link"]}),e.jsxs(w,{"data-testid":"scratchpad-download",size:"sm",variant:"outline",title:"Download the saved file",onClick:()=>it(new Blob([s.content],{type:fe[s.kind].mime}),q(s.title,s.kind)),children:[e.jsx(ot,{size:12,className:"mr-1"})," Download"]}),e.jsxs(w,{"data-testid":"scratchpad-properties",size:"sm",variant:"outline",onClick:()=>p(!0),children:[e.jsx(Me,{size:12,className:"mr-1"})," Properties"]}),e.jsxs(w,{"data-testid":"scratchpad-delete",size:"sm",variant:"outline",onClick:()=>u(!0),children:[e.jsx(ct,{size:12,className:"mr-1"})," Delete"]})]})]}),g==="failed"&&e.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:"Clipboard access failed. Copy the link from the address bar instead."}),e.jsxs("div",{"data-testid":"scratchpad-stage","data-fullscreen":x||void 0,className:x?"fixed inset-0 z-40 flex flex-col gap-3 overflow-auto bg-background p-3 [--pad-height:calc(100dvh-8.5rem)] sm:p-4":"min-w-0",children:[x&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"min-w-0 flex-1 truncate font-headline text-lg font-medium text-on-surface",children:s.title}),e.jsxs(w,{"data-testid":"scratchpad-exit-fullscreen",size:"sm",variant:"outline",onClick:()=>N(!1),children:[e.jsx(Oe,{size:12,className:"mr-1"})," Exit full screen"]})]}),e.jsx(Dt,{pad:s})]}),S&&e.jsx(ee,{pad:s,onClose:()=>p(!1)}),b&&e.jsx(de,{open:!0,title:"Delete scratchpad",description:`Delete "${s.title}"? This cannot be undone.`,confirmLabel:"Delete",variant:"destructive",isPending:j.isPending,onConfirm:()=>j.mutate(s.id,{onSuccess:()=>{u(!1),n(y)}}),onCancel:()=>u(!1)}),j.error&&e.jsx("p",{role:"alert",className:"mt-2 text-sm text-destructive",children:j.error.message})]})}const ts=Object.freeze(Object.defineProperty({__proto__:null,ScratchpadFormDialog:ee,default:It},Symbol.toStringTag,{value:"Module"}));export{gt as P,ts as S,q as s,vt as u};