orc-ai 0.1.40 → 0.1.41

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 (101) hide show
  1. package/dist/index.js +470 -455
  2. package/dist/web/assets/{Agents-KNRLNcpI.js → Agents-1lX_DRrR.js} +1 -1
  3. package/dist/web/assets/{Audit-ngeaHJiy.js → Audit-DnRP9Ivm.js} +1 -1
  4. package/dist/web/assets/{Dashboard-3F8aWN_d.js → Dashboard-bT5SABu_.js} +1 -1
  5. package/dist/web/assets/{DocumentWorkspace-VHzjE2ih.js → DocumentWorkspace-BI4JWVsO.js} +1 -1
  6. package/dist/web/assets/{FileEditor-DijNrJWf.js → FileEditor-Cb8uXr6e.js} +1 -1
  7. package/dist/web/assets/{JobWebhooks-BtzsOTHL.js → JobWebhooks-CYE2UA0V.js} +1 -1
  8. package/dist/web/assets/{Jobs-DmkPxHxP.js → Jobs-Fyd46CkI.js} +1 -1
  9. package/dist/web/assets/{Knowledge-R_6uAqDE.js → Knowledge-prZWODFP.js} +7 -7
  10. package/dist/web/assets/{PackageCatalog-CkZgscbx.js → PackageCatalog-R8kcGP28.js} +4 -4
  11. package/dist/web/assets/{Pager-DjrHsuOJ.js → Pager-urh4-P2a.js} +1 -1
  12. package/dist/web/assets/{Rules-BEzXQ7L5.js → Rules-if9ZzABl.js} +1 -1
  13. package/dist/web/assets/Sessions-AfC-wZoj.js +5 -0
  14. package/dist/web/assets/{Settings-O3qQRgTI.js → Settings-CNPE54fO.js} +3 -3
  15. package/dist/web/assets/{Skills-B3R-l8Ou.js → Skills-BJcE6uiQ.js} +1 -1
  16. package/dist/web/assets/{SourceEditor-CHubUpaP.js → SourceEditor-a2_IdCoT.js} +3 -3
  17. package/dist/web/assets/{Tasks-DF9FqHDq.js → Tasks-COQCj4HF.js} +1 -1
  18. package/dist/web/assets/Terminals-D4K_u_ch.js +115 -0
  19. package/dist/web/assets/{Webhooks-DW7d9R_t.js → Webhooks-DvsCfbZY.js} +1 -1
  20. package/dist/web/assets/{abnfDiagram-VCTEODGH-BVZ_t6ts.js → abnfDiagram-VCTEODGH-C1g9AmGT.js} +1 -1
  21. package/dist/web/assets/{arc-Bp1Q5GVT.js → arc-BX1-afFK.js} +1 -1
  22. package/dist/web/assets/{architectureDiagram-5GKGNRK7-Cw_Fh8Fr.js → architectureDiagram-5GKGNRK7-DTDe767x.js} +2 -2
  23. package/dist/web/assets/{blockDiagram-I7D4REHJ-C9qLtS_w.js → blockDiagram-I7D4REHJ-DJnvrUZM.js} +1 -1
  24. package/dist/web/assets/{c4Diagram-7LVT6UL2-k3kt69iB.js → c4Diagram-7LVT6UL2-rpXv4dc9.js} +1 -1
  25. package/dist/web/assets/channel-DsRXlXQz.js +1 -0
  26. package/dist/web/assets/{chunk-2Q5K7J3B-DVLrwP2r.js → chunk-2Q5K7J3B-BEq6zYAO.js} +1 -1
  27. package/dist/web/assets/{chunk-5VM5RSS4-D3tEfTaL.js → chunk-5VM5RSS4-kAS1IBM0.js} +1 -1
  28. package/dist/web/assets/{chunk-F27PBJKO-DfkCzGL9.js → chunk-F27PBJKO-BtG5IndH.js} +1 -1
  29. package/dist/web/assets/{chunk-IMKFNOWR-yN65S3YD.js → chunk-IMKFNOWR-C-NO8OSz.js} +1 -1
  30. package/dist/web/assets/{chunk-JWPE2WC7-ByQ6NS99.js → chunk-JWPE2WC7-2IhqyMft.js} +1 -1
  31. package/dist/web/assets/{chunk-POPQ4Y6H-CHRLyTiT.js → chunk-POPQ4Y6H-DmxK4niw.js} +1 -1
  32. package/dist/web/assets/{chunk-SVP7TREG-DvLoUZ9h.js → chunk-SVP7TREG-BkVeMS09.js} +1 -1
  33. package/dist/web/assets/{chunk-TICWLB2K-BvzbxDY6.js → chunk-TICWLB2K-DzlMwg1V.js} +1 -1
  34. package/dist/web/assets/{chunk-XXDRQBXY-DkfEU2XD.js → chunk-XXDRQBXY-ttUQmtBw.js} +1 -1
  35. package/dist/web/assets/classDiagram-ZZMXUADV-CZXMGXM8.js +1 -0
  36. package/dist/web/assets/classDiagram-v2-VYDZK3BY-CZXMGXM8.js +1 -0
  37. package/dist/web/assets/{cose-bilkent-JH36ORCC-D2Hh7gs6.js → cose-bilkent-JH36ORCC-yhoqj6vM.js} +1 -1
  38. package/dist/web/assets/{cynefin-OW5HDTMX-DwbOregT.js → cynefin-OW5HDTMX-CQZuSJ5b.js} +1 -1
  39. package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-vE21HTel.js → cynefinDiagram-5FMLGOSQ-Dz-2nuEW.js} +1 -1
  40. package/dist/web/assets/{dagre-GXQ25YYZ-Dtj5PNkl.js → dagre-GXQ25YYZ-DZJid-R_.js} +1 -1
  41. package/dist/web/assets/{diagram-S7CK7UJ4-CE958Up8.js → diagram-S7CK7UJ4-DB-Uzpn6.js} +1 -1
  42. package/dist/web/assets/{diagram-UQ7AKVKN-eKQdP4HV.js → diagram-UQ7AKVKN-BjIgjC39.js} +1 -1
  43. package/dist/web/assets/{diagram-VSXAHHWV-CYvYJQrA.js → diagram-VSXAHHWV-CjFlgbiX.js} +1 -1
  44. package/dist/web/assets/{diagram-VX7I27RA-BbKYzLMW.js → diagram-VX7I27RA-BlfR5PYu.js} +1 -1
  45. package/dist/web/assets/{diagram-Z3DM3KII-DV77g65D.js → diagram-Z3DM3KII-DL6_QJQh.js} +1 -1
  46. package/dist/web/assets/{download-36kk3IeP.js → download-CK_EusLu.js} +1 -1
  47. package/dist/web/assets/{ebnfDiagram-PWID7BFC-D0sEmHPl.js → ebnfDiagram-PWID7BFC-BjdizMG0.js} +1 -1
  48. package/dist/web/assets/{erDiagram-RLTQ6QDP-DK-Z6i0m.js → erDiagram-RLTQ6QDP-BxMzPgpM.js} +1 -1
  49. package/dist/web/assets/{flowDiagram-HODETNUW-Dp0aJQEZ.js → flowDiagram-HODETNUW-C-HgPS9G.js} +1 -1
  50. package/dist/web/assets/{folder-open-D1-I40k-.js → folder-open-Bcqha5Pu.js} +1 -1
  51. package/dist/web/assets/{ganttDiagram-EL5Y4UJY-BoG15yoq.js → ganttDiagram-EL5Y4UJY-BEx6HKx_.js} +4 -4
  52. package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-K4reAMXM.js → gitGraphDiagram-WWUBYQGX-D9yMgjsA.js} +1 -1
  53. package/dist/web/assets/{highlighted-body-KPVGNVTW-5ZVqRrCq.js → highlighted-body-KPVGNVTW-Cdq0W8LG.js} +1 -1
  54. package/dist/web/assets/index-BqQDBYwx.js +461 -0
  55. package/dist/web/assets/index-D1sNa9P-.css +1 -0
  56. package/dist/web/assets/{infoDiagram-27XIBGKW-67wFgmJP.js → infoDiagram-27XIBGKW-e_LgGqFP.js} +1 -1
  57. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-B9jfOEH9.js → ishikawaDiagram-5VMMS53U-jOCokdCr.js} +1 -1
  58. package/dist/web/assets/{journeyDiagram-3NMN7TZE-CuSLYkR9.js → journeyDiagram-3NMN7TZE-DfyXRW30.js} +1 -1
  59. package/dist/web/assets/{kanban-definition-UXKFOSKX-Cw5N-uDl.js → kanban-definition-UXKFOSKX-D6Mgx6_N.js} +1 -1
  60. package/dist/web/assets/{layout-CWCq0m-I.js → layout-BFQQ8SSL.js} +1 -1
  61. package/dist/web/assets/{linear-DKAXfoGA.js → linear-C251cMFR.js} +1 -1
  62. package/dist/web/assets/{list-CaqywJgg.js → list-BnZDr6iH.js} +1 -1
  63. package/dist/web/assets/{mermaid-HWGCJPDP-CMQlzgg9.js → mermaid-HWGCJPDP-DE8bnMel.js} +6 -6
  64. package/dist/web/assets/{mindmap-definition-YA3MSWOX-CA6cGhJr.js → mindmap-definition-YA3MSWOX-hX6YQE6d.js} +1 -1
  65. package/dist/web/assets/{pegDiagram-XKGWAZYB-CX-B1UCC.js → pegDiagram-XKGWAZYB-DRRv8KEz.js} +1 -1
  66. package/dist/web/assets/{pencil-C-6rguDb.js → pencil-ClEwbF1x.js} +1 -1
  67. package/dist/web/assets/{pieDiagram-E7YTZNPT-ZxtffUUp.js → pieDiagram-E7YTZNPT-DwRQy5kr.js} +1 -1
  68. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-hp3sjfpX.js → quadrantDiagram-AXDQQJYC-u-NZRX9E.js} +1 -1
  69. package/dist/web/assets/{railroadDiagram-O6MQD6OU-DA06SOlR.js → railroadDiagram-O6MQD6OU-DsGn0lJc.js} +1 -1
  70. package/dist/web/assets/{refresh-cw-BQyph7xD.js → refresh-cw-BGtNOi70.js} +1 -1
  71. package/dist/web/assets/{requirementDiagram-BXWQKSXE-B6uWt2Rc.js → requirementDiagram-BXWQKSXE-Bak7hmyH.js} +1 -1
  72. package/dist/web/assets/{sankeyDiagram-P5KCCOFB-C5_tPpb5.js → sankeyDiagram-P5KCCOFB-Bx5Wxkio.js} +1 -1
  73. package/dist/web/assets/{save-qGawhRKH.js → save-ChNqW56W.js} +1 -1
  74. package/dist/web/assets/{scroll-area-C-MTuK1y.js → scroll-area-YSA2ORI8.js} +1 -1
  75. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-CP1FmNA0.js → sequenceDiagram-WJ2MYXX4-CyWelz_H.js} +1 -1
  76. package/dist/web/assets/{sizeCapture-INFHLROL-BnZ0rzQe.js → sizeCapture-INFHLROL-BCzEf-8B.js} +1 -1
  77. package/dist/web/assets/{stateDiagram-D77RDMKH-B--86L9i.js → stateDiagram-D77RDMKH-BkqZfGYQ.js} +1 -1
  78. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-PLwI4Xlh.js +1 -0
  79. package/dist/web/assets/{swimlanes-42K2YHIH-BV8_rH1v.js → swimlanes-42K2YHIH-BMYDAy8X.js} +1 -1
  80. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-BEGqjIIe.js +8 -0
  81. package/dist/web/assets/{timeline-definition-24CTP7MA-Cm1hEfH0.js → timeline-definition-24CTP7MA-BrGykZXB.js} +1 -1
  82. package/dist/web/assets/{upload-CCnbjfQN.js → upload-waJ36Q68.js} +1 -1
  83. package/dist/web/assets/{useJobs-DDRY0jra.js → useJobs-By4K4BjX.js} +1 -1
  84. package/dist/web/assets/{useKnowledge-CHZ4AwZh.js → useKnowledge-DMSoPz-b.js} +1 -1
  85. package/dist/web/assets/{useMemories-BGxDOJge.js → useMemories-bv4XvbzQ.js} +1 -1
  86. package/dist/web/assets/useProjectScope-BvcpSOql.js +1 -0
  87. package/dist/web/assets/{vennDiagram-4TSXK5OY-vVCoILPC.js → vennDiagram-4TSXK5OY-CkLSasvk.js} +1 -1
  88. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-CnkLT61Q.js → wardleyDiagram-VM6X3IG4-DfPte2eh.js} +1 -1
  89. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-Bvv63kic.js → xychartDiagram-S5SC5T6Z-ClFkeona.js} +1 -1
  90. package/dist/web/index.html +2 -2
  91. package/package.json +1 -1
  92. package/dist/web/assets/Sessions-CCpWptIl.js +0 -5
  93. package/dist/web/assets/Terminals-wWVDPX68.js +0 -115
  94. package/dist/web/assets/channel-BSVHIa5R.js +0 -1
  95. package/dist/web/assets/classDiagram-ZZMXUADV-3BGzDrBP.js +0 -1
  96. package/dist/web/assets/classDiagram-v2-VYDZK3BY-3BGzDrBP.js +0 -1
  97. package/dist/web/assets/index-CB3c1nr-.css +0 -1
  98. package/dist/web/assets/index-SOCnaNS0.js +0 -453
  99. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-CXtInY-i.js +0 -1
  100. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-DyVW1GT5.js +0 -8
  101. package/dist/web/assets/useProjectScope-B28fk5NO.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as m,j as e,G as re,c as M,d as _,c0 as V,Y as g,Z as y,ah as K,B as w,Q as ie,am as oe,an as A,ao as F,ap as D,aq as T,ar as C,a7 as de,a as J,b as le,c1 as ce,c2 as me,c3 as he,ag as ue,c4 as xe,c5 as ge,E as pe,bD as fe,a9 as G,c6 as O,V as be,c7 as Y,c8 as q}from"./index-SOCnaNS0.js";import{u as ve,a as je,b as ye,c as Ne}from"./useKnowledge-CHZ4AwZh.js";import{D as ke}from"./download-36kk3IeP.js";import{S as X}from"./save-qGawhRKH.js";var _e=Object.defineProperty,ee=(t,n)=>_e(t,"name",{value:n,configurable:!0}),z={Horizontal:"horizontal",Vertical:"vertical"},W=z.Horizontal,we=Object.values(z),te=m.forwardRef(ee(function(n,h){const{decorative:c,orientation:s=W,...x}=n,p=se(s)?s:W,b=p===z.Vertical?p:void 0,v=c?{role:"none"}:{"aria-orientation":b,role:"separator"};return e.jsx(re.div,{"data-orientation":p,...v,...x,ref:h})},"Separator"));function se(t){return we.includes(t)}ee(se,"isValidOrientation");/**
1
+ import{r as m,j as e,G as re,c as M,d as _,c1 as V,Y as g,Z as y,ah as K,B as w,Q as ie,am as oe,an as A,ao as F,ap as T,aq as D,ar as C,a7 as de,a as J,b as le,c2 as ce,c3 as me,c4 as he,ag as ue,c5 as xe,c6 as ge,E as pe,bE as fe,a9 as G,c7 as O,V as be,c8 as Y,c9 as q}from"./index-BqQDBYwx.js";import{u as ve,a as je,b as ye,c as Ne}from"./useKnowledge-DMSoPz-b.js";import{D as ke}from"./download-CK_EusLu.js";import{S as X}from"./save-ChNqW56W.js";var _e=Object.defineProperty,ee=(t,n)=>_e(t,"name",{value:n,configurable:!0}),z={Horizontal:"horizontal",Vertical:"vertical"},W=z.Horizontal,we=Object.values(z),te=m.forwardRef(ee(function(n,h){const{decorative:c,orientation:s=W,...x}=n,p=se(s)?s:W,b=p===z.Vertical?p:void 0,v=c?{role:"none"}:{"aria-orientation":b,role:"separator"};return e.jsx(re.div,{"data-orientation":p,...v,...x,ref:h})},"Separator"));function se(t){return we.includes(t)}ee(se,"isValidOrientation");/**
2
2
  * @license lucide-react v1.27.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -16,5 +16,5 @@ import{r as m,j as e,G as re,c as M,d as _,c0 as V,Y as g,Z as y,ah as K,B as w,
16
16
  */const Pe=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Oe=M("rotate-cw",Pe);function Ie(){const[t,n]=m.useState(null),[h,c]=m.useState(""),[s,x]=m.useState(""),[p,b]=m.useState(!1);m.useEffect(()=>{let o=!1;return _.settings.get().then(d=>{if(o)return;const f=V.parse(d.chat??{});n(f),c(f.models.map(u=>`${u.agent}: ${u.id}`).join(`
17
17
  `))}).catch(d=>{o||x(d.message)}),()=>{o=!0}},[]);async function v(){if(t){b(!0),x("");try{const o=h.split(`
18
18
  `).filter(f=>f.trim()).map(f=>{const u=f.match(/^([a-z][a-z0-9-]*):\s*(.+)$/i);if(!u)throw new Error("Use agent: model-id on each model line.");return{agent:u[1]??"",id:u[2]??""}}),d=V.parse({...t,models:o});await _.settings.save({chat:d}),n(d),window.dispatchEvent(new Event("orc-chat-settings-changed")),x("Chat defaults saved. They apply to new conversations on every device.")}catch(o){x(o instanceof Error?o.message:"Chat settings could not be saved.")}finally{b(!1)}}}return e.jsxs("section",{"aria-labelledby":"chat-settings-title",className:"space-y-4","data-testid":"chat-settings",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"chat-settings-title",className:"text-base font-medium",children:"Chat"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Defaults for new conversations. Existing chats keep their configuration. Credentials stay on the execution host."})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-default-agent",children:"Default agent"}),e.jsx(y,{id:"chat-default-agent","data-testid":"chat-default-agent",value:t.agent,onChange:o=>n({...t,agent:o.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-default-model",children:"Default model"}),e.jsx(y,{id:"chat-default-model","data-testid":"chat-default-model",value:t.model,placeholder:"Agent default",onChange:o=>n({...t,model:o.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-model-catalog",children:"Model picker choices"}),e.jsx(K,{id:"chat-model-catalog","data-testid":"chat-model-catalog",value:h,onChange:o=>c(o.target.value),placeholder:`codex: your-model-id
19
- claude: your-model-id`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"One agent: model-id per line. Use model IDs supported by your installed agent and account."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-system-prompt",children:"Instructions"}),e.jsx(K,{id:"chat-system-prompt","data-testid":"chat-system-prompt",rows:6,value:t.system,onChange:o=>n({...t,system:o.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Claude appends these to its coding system prompt. Codex and other agents receive them as turn instructions. Workspace rules remain enforced."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-mcp",children:"Tools connection"}),e.jsxs("select",{id:"chat-mcp","data-testid":"chat-mcp",className:"min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-base sm:text-sm",value:t.mcp,onChange:o=>n({...t,mcp:o.target.value}),children:[e.jsx("option",{value:"orc",children:"Connect ORC MCP (Claude and Codex)"}),e.jsx("option",{value:"native",children:"Use the agent’s host configuration"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The ORC connection uses server credentials internally. Host configuration may include other MCP servers; this setting does not disable them. Protected workspaces may also require ORC tools."})]}),e.jsxs("label",{className:"flex min-h-11 items-start gap-3 py-2 text-sm",children:[e.jsx("input",{"data-testid":"chat-auto-approve",type:"checkbox",checked:t.autoApprove,onChange:o=>n({...t,autoApprove:o.target.checked}),className:"mt-1 size-4"}),e.jsxs("span",{children:["Allow agent actions automatically",e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:"Off: Claude asks in chat; Codex runs with a read-only sandbox; other agents use their native permission policy. On: Claude bypasses permission prompts; Codex can write in its workspace. ORC rules still apply."})]})]}),e.jsx(w,{"data-testid":"chat-settings-save",disabled:p,onClick:()=>void v(),children:p?"Saving…":"Save chat defaults"})]}),s&&e.jsx("p",{role:"status","data-testid":"chat-settings-feedback",className:"break-words text-sm text-muted-foreground",children:s})]})}const E=m.forwardRef(({className:t,orientation:n="horizontal",decorative:h=!0,...c},s)=>e.jsx(te,{ref:s,decorative:h,orientation:n,className:ie("shrink-0 bg-surface-bright ",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...c}));E.displayName=te.displayName;const P=1024*1024;function Q(t){return t===null?"":t>=1024*P?`${(t/1024/P).toFixed(1)} GB`:`${Math.round(t/P)} MB`}function Ae(t){return{session_embeddings:t.session_embeddings??!1,parser:t.parser,docling_enabled:t.docling_enabled,parser_timeout_secs:String(t.parser_timeout_secs),max_upload_mb:String(Math.round(t.max_upload_bytes/P)),usage_retention_days:String(t.usage_retention_days),provider:t.embedding.provider,base_url:t.embedding.base_url??"",model:t.embedding.model??"",dimensions:t.embedding.dimensions?String(t.embedding.dimensions):"",api_key:"",clear_key:!1}}const Fe={none:"Keyword search only. Add an embedding provider for semantic and hybrid search.",ollama:"Local embeddings from Ollama, for example nomic-embed-text at http://localhost:11434.",openai:"OpenAI or any OpenAI-compatible endpoint, for example text-embedding-3-small."};function De(){var L,$,H,U;const t=ve(),n=je(),h=ye(),c=Ne(),[s,x]=m.useState(null),[p,b]=m.useState(null),[v,o]=m.useState(!1),[d,f]=m.useState(!1),[u,k]=m.useState(!1);if(m.useEffect(()=>{t.data&&x(Ae(t.data))},[t.data]),t.error)return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-1 text-base font-medium",children:"Knowledge"}),e.jsx("p",{role:"alert",className:"text-sm text-error",children:t.error.message})]});if(!s||!t.data)return null;const j=t.data,N=a=>j.env_overrides.includes(`ORC_KNOWLEDGE_${a}`),l=a=>{o(!1),x({...s,...a})},i=(L=n.data)==null?void 0:L.parsers.find(a=>a.id==="docling"),r=($=n.data)==null?void 0:$.docling;async function S(a){f(!0),b(null);try{return await a(),await c(),!0}catch(R){return b(R instanceof Error?R.message:"Request failed"),!1}finally{f(!1)}}async function ae(a){if(a.preventDefault(),!s)return;const R=B=>B.trim()?Number(B):null,ne={session_embeddings:s.session_embeddings,parser:s.parser,docling_enabled:s.docling_enabled,parser_timeout_secs:Number(s.parser_timeout_secs),max_upload_bytes:Number(s.max_upload_mb)*P,usage_retention_days:Number(s.usage_retention_days),embedding:{provider:s.provider,base_url:s.base_url.trim()||null,model:s.model.trim()||null,dimensions:R(s.dimensions),...s.clear_key?{api_key:null}:s.api_key?{api_key:s.api_key}:{}}};await S(()=>_.kb.updateSettings(ne))&&o(!0)}return e.jsxs("section",{"data-testid":"settings-knowledge","aria-labelledby":"settings-knowledge-title",children:[e.jsx("h2",{id:"settings-knowledge-title",className:"mb-1 text-base font-medium text-on-surface",children:"Knowledge"}),e.jsxs("p",{className:"mb-4 text-sm text-muted-foreground",children:["How ORC parses uploads and searches knowledge bases. Saved on the server in"," ",e.jsx("code",{className:"text-primary",children:"~/.orc/config.json"}),"; files live in"," ",e.jsx("code",{className:"break-all text-primary",children:j.root}),"."]}),e.jsx(E,{className:"mb-4 bg-outline-variant"}),j.env_overrides.length>0&&e.jsxs("p",{className:"mb-4 text-sm text-warning","data-testid":"settings-knowledge-env",children:["Set by environment, these win over saved values: ",j.env_overrides.join(", ")]}),e.jsxs("form",{onSubmit:ae,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Parsers"}),(H=n.data)==null?void 0:H.parsers.map(a=>e.jsxs("div",{"data-testid":`settings-parser-${a.id}`,className:"rounded-md border border-outline-variant p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.label}),e.jsxs("span",{className:"text-xs text-outline",children:[a.installed?`v${a.version}`:"not installed",a.size_bytes?` · ${Q(a.size_bytes)}${a.installed?"":" download"}`:""]})]}),e.jsx("p",{className:"mt-1 text-outline",children:a.description}),e.jsxs("p",{className:"mt-1 text-xs text-outline",children:["Formats: ",a.capabilities.formats.join(", ")]}),a.detail&&e.jsx("p",{className:"mt-1 text-xs text-outline",children:a.detail}),a.id==="docling"&&e.jsxs("div",{className:"mt-3 space-y-2",children:[(r==null?void 0:r.state)==="installing"&&e.jsxs("div",{role:"status","data-testid":"settings-docling-progress",className:"text-xs text-outline",children:[r.step,e.jsx("pre",{className:"mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap font-mono",children:r.log.slice(-8).join(`
20
- `)})]}),(r==null?void 0:r.state)==="failed"&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:r.error}),a.installed?e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-docling-enabled",checked:s.docling_enabled,onChange:R=>l({docling_enabled:R.target.checked})}),"Use automatically for PDFs and images"]}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"text-error","data-testid":"settings-docling-remove",onClick:()=>k(!0),children:[e.jsx(oe,{size:14}),"Remove"]})]}):e.jsxs(w,{type:"button",size:"sm",variant:"outline","data-testid":"settings-docling-install",disabled:d||(r==null?void 0:r.state)==="installing",onClick:()=>S(()=>_.kb.installDocling()),children:[e.jsx(ke,{size:14}),(r==null?void 0:r.state)==="installing"?"Installing…":`Install Docling (${Q((i==null?void 0:i.size_bytes)??null)||"about 2 GB"})`]})]})]},a.id)),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-kb-parser",className:"text-sm text-muted-foreground",children:"Default parser"}),e.jsxs(A,{value:s.parser,onValueChange:a=>l({parser:a}),disabled:N("PARSER"),children:[e.jsx(F,{id:"settings-kb-parser","data-testid":"settings-kb-parser",children:e.jsx(D,{})}),e.jsxs(T,{children:[e.jsx(C,{value:"auto",children:"Automatic: Docling for PDFs and images when enabled"}),(U=n.data)==null?void 0:U.parsers.map(a=>e.jsx(C,{value:a.id,disabled:!a.installed,children:a.label},a.id))]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Knowledge bases can override it. Changing parsers applies to new uploads; reparse a document to apply it to existing ones."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-timeout",className:"text-sm text-muted-foreground",children:"Parse timeout (s)"}),e.jsx(y,{id:"settings-kb-timeout",type:"number",min:10,value:s.parser_timeout_secs,onChange:a=>l({parser_timeout_secs:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-max-upload",className:"text-sm text-muted-foreground",children:"Max upload (MB)"}),e.jsx(y,{id:"settings-kb-max-upload",type:"number",min:1,value:s.max_upload_mb,onChange:a=>l({max_upload_mb:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-retention",className:"text-sm text-muted-foreground",children:"Read log (days)"}),e.jsx(y,{id:"settings-kb-retention",type:"number",min:1,value:s.usage_retention_days,onChange:a=>l({usage_retention_days:a.target.value})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Semantic search"}),e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-session-embeddings",checked:s.session_embeddings,onChange:a=>l({session_embeddings:a.target.checked})}),e.jsxs("span",{children:["Search coding sessions with embeddings",e.jsx("span",{className:"block text-xs text-outline",children:"Uses the provider below for session passages. Keyword search and transcript reading remain available when off. Enabling sends session text to this provider and indexes discovered project sessions."})]})]}),h.data&&e.jsxs("p",{className:"text-xs text-outline","data-testid":"settings-embedding-status",children:[h.data.embedding.ready?`Ready · ${h.data.embedding.model} · ${h.data.embedding.vector_backend}`:h.data.embedding.detail??"Not configured",h.data.embedding.pending_chunks?` · ${h.data.embedding.pending_chunks} passages waiting`:""]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-provider",className:"text-sm text-muted-foreground",children:"Embedding provider"}),e.jsxs(A,{value:s.provider,onValueChange:a=>l({provider:a}),disabled:N("EMBEDDING_PROVIDER"),children:[e.jsx(F,{id:"settings-kb-provider","data-testid":"settings-kb-provider",children:e.jsx(D,{})}),e.jsxs(T,{children:[e.jsx(C,{value:"none",children:"None"}),e.jsx(C,{value:"ollama",children:"Ollama"}),e.jsx(C,{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsx("p",{className:"text-xs text-outline",children:Fe[s.provider]})]}),s.provider!=="none"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-model",className:"text-sm text-muted-foreground",children:"Model"}),e.jsx(y,{id:"settings-kb-model","data-testid":"settings-kb-model",value:s.model,disabled:N("EMBEDDING_MODEL"),onChange:a=>l({model:a.target.value}),placeholder:s.provider==="ollama"?"nomic-embed-text":"text-embedding-3-small"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-dimensions",className:"text-sm text-muted-foreground",children:"Dimensions"}),e.jsx(y,{id:"settings-kb-dimensions",type:"number",value:s.dimensions,onChange:a=>l({dimensions:a.target.value}),placeholder:"Model default"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-base-url",className:"text-sm text-muted-foreground",children:"Base URL"}),e.jsx(y,{id:"settings-kb-base-url","data-testid":"settings-kb-base-url",value:s.base_url,disabled:N("EMBEDDING_URL"),onChange:a=>l({base_url:a.target.value}),placeholder:s.provider==="ollama"?"http://localhost:11434":"https://api.openai.com/v1"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-api-key",className:"text-sm text-muted-foreground",children:s.provider==="ollama"?"Token (hosted or proxied Ollama)":"API key"}),e.jsx(y,{id:"settings-kb-api-key",type:"password",autoComplete:"off","data-testid":"settings-kb-api-key",value:s.api_key,disabled:s.clear_key||N("EMBEDDING_API_KEY"),onChange:a=>l({api_key:a.target.value}),placeholder:j.embedding.api_key_set?"Saved. Type to replace":"Not set"}),j.embedding.api_key_set&&e.jsxs("label",{className:"flex items-center gap-2 text-xs text-outline",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-kb-api-key-clear",checked:s.clear_key,onChange:a=>l({clear_key:a.target.checked,api_key:""})}),"Remove the saved key"]}),e.jsxs("p",{className:"text-xs text-outline",children:["Stored encrypted with the key in ",e.jsx("code",{children:"~/.orc/secret.key"})," and never sent back to the browser. Sent as a bearer token to the base URL."]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Changing the model re-embeds every passage in the background; keyword search keeps working meanwhile."})]})]}),p&&e.jsx("p",{role:"alert","data-testid":"settings-knowledge-error",className:"text-sm text-error",children:p}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{type:"submit","data-testid":"settings-knowledge-save",disabled:d,children:"Save knowledge settings"}),v&&e.jsx("span",{role:"status",className:"text-sm text-muted-foreground",children:"Saved"})]})]}),e.jsx(de,{open:u,title:"Remove Docling",description:"Deletes the Docling runtime and models from this machine. Documents it parsed keep their text; reparse them to use the basic parser.",confirmLabel:"Remove",isPending:d,onCancel:()=>k(!1),onConfirm:async()=>{k(!1),await S(()=>_.kb.uninstallDocling())}})]})}function Te(){const t=J();return le({mutationFn:async()=>{const n=await _.system.restart(),h=Date.now()+6e4;for(;Date.now()<h;){await new Promise(c=>setTimeout(c,500));try{if((await _.health.check(AbortSignal.timeout(2e3))).instance_id!==n.instance_id)return}catch(c){if(c instanceof ce&&c.status===401)throw c}}throw new Error("ORC has not reconnected yet. Check the server and try again when it is online.")},onSuccess:()=>t.invalidateQueries()})}function Me(){const{data:t}=me(),n=Te();return e.jsxs("section",{"aria-labelledby":"server-title",children:[e.jsx("h2",{id:"server-title",className:"mb-1 text-base font-medium",children:"ORC server"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Restart ORC to reload server and host information. This closes active terminals and may interrupt running work. Your settings are kept, and this dashboard reconnects automatically. Switching hosts applies to new actions without a restart."}),e.jsx(E,{className:"mb-4"}),e.jsxs(w,{variant:"outline","data-testid":"settings-restart",disabled:!(t!=null&&t.restart_supported)||n.isPending,onClick:()=>n.mutate(),children:[e.jsx(Oe,{className:n.isPending?"mr-2 size-4 animate-spin":"mr-2 size-4"}),n.isPending?"Restarting and reconnecting…":"Restart ORC server"]}),t&&!t.restart_supported&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This server does not support restart from the dashboard."}),n.isPending&&e.jsx("p",{role:"status","data-testid":"settings-restart-status",className:"mt-2 text-sm text-muted-foreground",children:"Waiting for ORC to restart…"}),n.isSuccess&&e.jsx("p",{role:"status","data-testid":"settings-restart-status",className:"mt-2 text-sm text-muted-foreground",children:"ORC restarted. Reconnected."}),n.isError&&e.jsx("p",{role:"alert","data-testid":"settings-restart-error",className:"mt-2 text-sm text-error",children:n.error.message})]})}const I="__local__";function Z(t){return t?t instanceof Error?t.message:String(t):null}function ze(){var i;const{data:t,error:n,refetch:h}=he(),{data:c}=ue(),s=xe(),x=ge(),[p,b]=m.useState(I),[v,o]=m.useState("");if(m.useEffect(()=>{t&&(b(t.host??I),o(t.remote_port===null?"":String(t.remote_port)))},[t]),n)return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"Execution host"}),e.jsx(pe,{message:n.message,onRetry:()=>void h()})]});if(!t)return e.jsx("p",{role:"status","data-testid":"page-loading",className:"text-sm text-muted-foreground",children:"Loading execution host…"});const d=p===I?null:p,f=t.host&&!t.hosts.includes(t.host)?[t.host,...t.hosts]:t.hosts,u=Number(v),k=v.trim()===""||Number.isInteger(u)&&u>=1&&u<=65535,j=t.locked||!t.supported,N=c==null?void 0:c.backends.find(r=>r.name==="claude"),l=((i=x.data)==null?void 0:i.host)===d?x.data:void 0;return e.jsxs("section",{"data-testid":"ssh-settings",children:[e.jsx("h2",{className:"font-headline font-semibold text-base text-on-surface mb-1",children:"Execution host"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground mb-4",children:["Run every agent, terminal, git and file action on a host from"," ",e.jsx("code",{className:"text-primary",children:"~/.ssh/config"}),". Agents there reach orc through a reverse tunnel on the remote port. Terminals already open keep their host."]}),e.jsx(E,{className:"bg-surface-highest mb-4"}),e.jsxs("div",{className:"space-y-4",children:[t.locked&&e.jsx("p",{"data-testid":"ssh-locked",className:"font-body text-sm text-tertiary",children:"Fixed by ORC_SSH_HOST in orc's environment."}),!t.supported&&e.jsx("p",{"data-testid":"ssh-unsupported",className:"font-body text-sm text-error",children:t.unsupported_reason}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"ssh-host",className:"font-label text-sm text-muted-foreground",children:"Host"}),e.jsxs(A,{value:p,onValueChange:b,disabled:j,children:[e.jsx(F,{id:"ssh-host","aria-label":"Execution host","data-testid":"ssh-host-picker",className:"bg-surface-highest border-control-border text-on-surface font-body text-sm",children:e.jsx(D,{})}),e.jsxs(T,{className:"bg-surface-highest border-outline-variant max-h-72",children:[e.jsx(C,{value:I,"data-testid":"ssh-host-option-local",className:"font-label text-sm",children:"Local (this machine)"}),f.map(r=>e.jsx(C,{value:r,"data-testid":`ssh-host-option-${r}`,className:"font-label text-sm",children:r},r))]})]}),f.length===0&&e.jsx("p",{"data-testid":"page-empty",className:"font-body text-sm text-muted-foreground",children:"No Host entries found in ~/.ssh/config on the machine running orc."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"ssh-remote-port",className:"font-label text-sm text-muted-foreground",children:"Tunnel port override"}),e.jsx(y,{id:"ssh-remote-port","aria-invalid":!!(d&&!k),"data-testid":"ssh-remote-port",value:v,placeholder:"Automatic",onChange:r=>o(r.target.value),disabled:j||!d,inputMode:"numeric",className:"bg-surface-highest border-outline-variant text-on-surface font-body text-sm"}),d&&!k&&e.jsx("p",{className:"text-sm text-error",children:"Enter a remote port from 1 to 65535."}),e.jsx("p",{className:"font-body text-sm text-muted-foreground",children:"Leave empty to let SSH choose an available port automatically."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(w,{"data-testid":"ssh-save",disabled:j||d!==null&&!k||s.isPending,onClick:()=>s.mutate({host:d,remotePort:d&&v.trim()?u:null}),className:"font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(X,{size:12,className:"mr-1.5"})," Use Host"]}),e.jsxs(w,{"data-testid":"ssh-test",variant:"ghost",disabled:!d||!t.supported||x.isPending,onClick:()=>d&&x.mutate(d),className:"font-label text-sm text-muted-foreground hover:text-on-surface",children:[e.jsx(Re,{size:12,className:"mr-1.5"})," ",x.isPending?"Testing…":"Test"]})]}),Z(s.error??x.error)&&e.jsx("p",{"data-testid":"ssh-error",className:"font-body text-sm text-error",children:Z(s.error??x.error)}),l&&e.jsx("div",{"data-testid":"ssh-test-result",className:"font-body text-sm space-y-1",children:l.ok?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-secondary",children:["Connected to ",l.host," (",l.os,", ",l.shell,")"]}),e.jsx("p",{className:"text-muted-foreground",children:Object.entries(l.binaries).map(([r,S])=>`${S?"●":"○"} ${r}`).join(" ")}),l.binaries.claude&&l.claude_logged_in===!1&&e.jsxs("p",{className:l.api_key_forwarded?"text-muted-foreground":"text-error",children:["claude is not logged in on ",l.host,"."," ",l.api_key_forwarded?"ANTHROPIC_API_KEY from orc's environment will be forwarded.":"Set ANTHROPIC_API_KEY in orc's environment or run claude login there."]})]}):e.jsx("p",{className:"text-error",children:l.error})}),t.host&&N&&!N.available&&e.jsxs("p",{"data-testid":"ssh-claude-error",className:"font-body text-sm text-error",children:["claude backend: ",N.error]})]})]})}function Be(){const{theme:t}=fe(),[n,h]=m.useState(G),[c,s]=m.useState(()=>localStorage.getItem(O)??""),[x,p]=m.useState(!1),[b,v]=m.useState(""),[o,d]=m.useState(""),[f,u]=m.useState(!1),k=J(),j=async()=>{d(""),u(!0);try{const i=n.trim();if(i&&!i.startsWith("/")&&!/^https?:\/\//i.test(i))throw new Error("Use a relative API path or an http(s) server URL.");const r=await _.settings.save({theme:t,terminal_font:c.trim()});Y(r.theme??t),s(r.terminal_font??""),r.terminal_font?localStorage.setItem(O,r.terminal_font):localStorage.removeItem(O);const S=(i||"/api")!==G();localStorage.setItem("orc_api_url",i||"/api"),S&&window.dispatchEvent(new Event(q)),k.invalidateQueries(),p(!0),v("Workspace preferences saved on the server. API address saved in this browser."),setTimeout(()=>p(!1),2e3)}catch(i){d(i instanceof Error?i.message:"Browser settings could not be saved.")}finally{u(!1)}},N=async()=>{d(""),u(!0);try{const i=await _.settings.save({terminal_font:""});localStorage.removeItem("orc_api_url"),localStorage.setItem(O,i.terminal_font??""),h("/api"),s(i.terminal_font??""),window.dispatchEvent(new Event(q)),k.invalidateQueries(),p(!1),v("Connection and terminal font restored to their defaults. Appearance and execution host were kept.")}catch(i){d(i instanceof Error?i.message:"Browser settings could not be reset.")}finally{u(!1)}};async function l(i){d(""),u(!0);try{const r=await _.settings.save({theme:i});Y(r.theme??i)}catch(r){d(r instanceof Error?r.message:"Appearance could not be saved.")}finally{u(!1)}}return e.jsxs("div",{children:[e.jsx(be,{title:"Settings"}),e.jsxs("div",{className:"max-w-lg space-y-8",children:[e.jsxs("section",{"aria-labelledby":"appearance-title",children:[e.jsx("h2",{id:"appearance-title",className:"mb-1 text-base font-medium",children:"Appearance"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Choose a workspace theme. Your choice is saved on the server immediately."}),e.jsx("fieldset",{className:"flex flex-wrap gap-2","aria-label":"Theme",children:["dark","light"].map(i=>e.jsx(w,{variant:t===i?"secondary":"outline","aria-pressed":t===i,"data-testid":`settings-theme-${i}`,disabled:f,onClick:()=>void l(i),children:i==="dark"?"Dark":"Light"},i))})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-headline font-medium text-base text-on-surface mb-1",children:"API connection"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground mb-4",children:["Connect this workspace to an ORC server. The default"," ",e.jsx("code",{className:"text-primary",children:"/api"})," uses the current server or the configured development proxy."]}),e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-api-url",className:"font-label text-sm text-muted-foreground",children:"API base URL"}),e.jsx(y,{id:"settings-api-url","data-testid":"settings-api-url",value:n,onChange:i=>h(i.target.value),placeholder:"/api or http://localhost:7700",className:"bg-background text-on-surface font-body text-sm"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground",children:["Use ",e.jsx("code",{children:"/api"})," (dev proxy) or a direct URL when CORS is enabled."]})]})})]}),e.jsx(ze,{}),e.jsx(Me,{}),e.jsx(Ie,{}),e.jsx(De,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-headline font-medium text-base text-on-surface mb-1",children:"Terminal"}),e.jsx("p",{className:"font-body text-sm text-muted-foreground mb-4",children:"Prompt and agent status icons need a Nerd Font installed on this machine. Common ones are tried automatically; set the exact family name if your icons show as empty boxes. Applies to terminals opened after saving."}),e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-terminal-font",className:"font-label text-sm text-muted-foreground",children:"Terminal font family"}),e.jsx(y,{id:"settings-terminal-font",value:c,onChange:i=>s(i.target.value),placeholder:"e.g. MesloLGS NF",className:"bg-background text-on-surface font-body text-sm"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 pt-2",children:[e.jsx(w,{"data-testid":"settings-save",disabled:f,onClick:()=>void j(),className:"font-label text-sm ",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"mr-1.5"})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{size:12,className:"mr-1.5"})," Save settings"]})}),e.jsx(w,{variant:"ghost",disabled:f,onClick:()=>void N(),className:"font-label text-sm text-muted-foreground hover:text-on-surface",children:"Reset to defaults"})]}),o&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:o}),b&&!o&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:b}),e.jsxs("section",{children:[e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:"Storage"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground",children:["Workspace preferences and SSH selection are persisted in the server's"," ",e.jsx("code",{children:"~/.orc/config.json"}),". The API address and optionally remembered login are stored in this browser."]})]})]})]})}export{Be as default};
19
+ claude: your-model-id`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"One agent: model-id per line. Use model IDs supported by your installed agent and account."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-system-prompt",children:"Instructions"}),e.jsx(K,{id:"chat-system-prompt","data-testid":"chat-system-prompt",rows:6,value:t.system,onChange:o=>n({...t,system:o.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Claude appends these to its coding system prompt. Codex and other agents receive them as turn instructions. Workspace rules remain enforced."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-mcp",children:"Tools connection"}),e.jsxs("select",{id:"chat-mcp","data-testid":"chat-mcp",className:"min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-base sm:text-sm",value:t.mcp,onChange:o=>n({...t,mcp:o.target.value}),children:[e.jsx("option",{value:"orc",children:"Connect ORC MCP (Claude and Codex)"}),e.jsx("option",{value:"native",children:"Use the agent’s host configuration"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The ORC connection uses server credentials internally. Host configuration may include other MCP servers; this setting does not disable them. Protected workspaces may also require ORC tools."})]}),e.jsxs("label",{className:"flex min-h-11 items-start gap-3 py-2 text-sm",children:[e.jsx("input",{"data-testid":"chat-auto-approve",type:"checkbox",checked:t.autoApprove,onChange:o=>n({...t,autoApprove:o.target.checked}),className:"mt-1 size-4"}),e.jsxs("span",{children:["Allow agent actions automatically",e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:"Off: Claude asks in chat; Codex runs with a read-only sandbox; other agents use their native permission policy. On: Claude bypasses permission prompts; Codex can write in its workspace. ORC rules still apply."})]})]}),e.jsx(w,{"data-testid":"chat-settings-save",disabled:p,onClick:()=>void v(),children:p?"Saving…":"Save chat defaults"})]}),s&&e.jsx("p",{role:"status","data-testid":"chat-settings-feedback",className:"break-words text-sm text-muted-foreground",children:s})]})}const E=m.forwardRef(({className:t,orientation:n="horizontal",decorative:h=!0,...c},s)=>e.jsx(te,{ref:s,decorative:h,orientation:n,className:ie("shrink-0 bg-surface-bright ",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...c}));E.displayName=te.displayName;const P=1024*1024;function Q(t){return t===null?"":t>=1024*P?`${(t/1024/P).toFixed(1)} GB`:`${Math.round(t/P)} MB`}function Ae(t){return{session_embeddings:t.session_embeddings??!1,parser:t.parser,docling_enabled:t.docling_enabled,parser_timeout_secs:String(t.parser_timeout_secs),max_upload_mb:String(Math.round(t.max_upload_bytes/P)),usage_retention_days:String(t.usage_retention_days),provider:t.embedding.provider,base_url:t.embedding.base_url??"",model:t.embedding.model??"",dimensions:t.embedding.dimensions?String(t.embedding.dimensions):"",api_key:"",clear_key:!1}}const Fe={none:"Keyword search only. Add an embedding provider for semantic and hybrid search.",ollama:"Local embeddings from Ollama, for example nomic-embed-text at http://localhost:11434.",openai:"OpenAI or any OpenAI-compatible endpoint, for example text-embedding-3-small."};function Te(){var L,$,H,U;const t=ve(),n=je(),h=ye(),c=Ne(),[s,x]=m.useState(null),[p,b]=m.useState(null),[v,o]=m.useState(!1),[d,f]=m.useState(!1),[u,k]=m.useState(!1);if(m.useEffect(()=>{t.data&&x(Ae(t.data))},[t.data]),t.error)return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-1 text-base font-medium",children:"Knowledge"}),e.jsx("p",{role:"alert",className:"text-sm text-error",children:t.error.message})]});if(!s||!t.data)return null;const j=t.data,N=a=>j.env_overrides.includes(`ORC_KNOWLEDGE_${a}`),l=a=>{o(!1),x({...s,...a})},i=(L=n.data)==null?void 0:L.parsers.find(a=>a.id==="docling"),r=($=n.data)==null?void 0:$.docling;async function S(a){f(!0),b(null);try{return await a(),await c(),!0}catch(R){return b(R instanceof Error?R.message:"Request failed"),!1}finally{f(!1)}}async function ae(a){if(a.preventDefault(),!s)return;const R=B=>B.trim()?Number(B):null,ne={session_embeddings:s.session_embeddings,parser:s.parser,docling_enabled:s.docling_enabled,parser_timeout_secs:Number(s.parser_timeout_secs),max_upload_bytes:Number(s.max_upload_mb)*P,usage_retention_days:Number(s.usage_retention_days),embedding:{provider:s.provider,base_url:s.base_url.trim()||null,model:s.model.trim()||null,dimensions:R(s.dimensions),...s.clear_key?{api_key:null}:s.api_key?{api_key:s.api_key}:{}}};await S(()=>_.kb.updateSettings(ne))&&o(!0)}return e.jsxs("section",{"data-testid":"settings-knowledge","aria-labelledby":"settings-knowledge-title",children:[e.jsx("h2",{id:"settings-knowledge-title",className:"mb-1 text-base font-medium text-on-surface",children:"Knowledge"}),e.jsxs("p",{className:"mb-4 text-sm text-muted-foreground",children:["How ORC parses uploads and searches knowledge bases. Saved on the server in"," ",e.jsx("code",{className:"text-primary",children:"~/.orc/config.json"}),"; files live in"," ",e.jsx("code",{className:"break-all text-primary",children:j.root}),"."]}),e.jsx(E,{className:"mb-4 bg-outline-variant"}),j.env_overrides.length>0&&e.jsxs("p",{className:"mb-4 text-sm text-warning","data-testid":"settings-knowledge-env",children:["Set by environment, these win over saved values: ",j.env_overrides.join(", ")]}),e.jsxs("form",{onSubmit:ae,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Parsers"}),(H=n.data)==null?void 0:H.parsers.map(a=>e.jsxs("div",{"data-testid":`settings-parser-${a.id}`,className:"rounded-md border border-outline-variant p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.label}),e.jsxs("span",{className:"text-xs text-outline",children:[a.installed?`v${a.version}`:"not installed",a.size_bytes?` · ${Q(a.size_bytes)}${a.installed?"":" download"}`:""]})]}),e.jsx("p",{className:"mt-1 text-outline",children:a.description}),e.jsxs("p",{className:"mt-1 text-xs text-outline",children:["Formats: ",a.capabilities.formats.join(", ")]}),a.detail&&e.jsx("p",{className:"mt-1 text-xs text-outline",children:a.detail}),a.id==="docling"&&e.jsxs("div",{className:"mt-3 space-y-2",children:[(r==null?void 0:r.state)==="installing"&&e.jsxs("div",{role:"status","data-testid":"settings-docling-progress",className:"text-xs text-outline",children:[r.step,e.jsx("pre",{className:"mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap font-mono",children:r.log.slice(-8).join(`
20
+ `)})]}),(r==null?void 0:r.state)==="failed"&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:r.error}),a.installed?e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-docling-enabled",checked:s.docling_enabled,onChange:R=>l({docling_enabled:R.target.checked})}),"Use automatically for PDFs and images"]}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"text-error","data-testid":"settings-docling-remove",onClick:()=>k(!0),children:[e.jsx(oe,{size:14}),"Remove"]})]}):e.jsxs(w,{type:"button",size:"sm",variant:"outline","data-testid":"settings-docling-install",disabled:d||(r==null?void 0:r.state)==="installing",onClick:()=>S(()=>_.kb.installDocling()),children:[e.jsx(ke,{size:14}),(r==null?void 0:r.state)==="installing"?"Installing…":`Install Docling (${Q((i==null?void 0:i.size_bytes)??null)||"about 2 GB"})`]})]})]},a.id)),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-kb-parser",className:"text-sm text-muted-foreground",children:"Default parser"}),e.jsxs(A,{value:s.parser,onValueChange:a=>l({parser:a}),disabled:N("PARSER"),children:[e.jsx(F,{id:"settings-kb-parser","data-testid":"settings-kb-parser",children:e.jsx(T,{})}),e.jsxs(D,{children:[e.jsx(C,{value:"auto",children:"Automatic: Docling for PDFs and images when enabled"}),(U=n.data)==null?void 0:U.parsers.map(a=>e.jsx(C,{value:a.id,disabled:!a.installed,children:a.label},a.id))]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Knowledge bases can override it. Changing parsers applies to new uploads; reparse a document to apply it to existing ones."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-timeout",className:"text-sm text-muted-foreground",children:"Parse timeout (s)"}),e.jsx(y,{id:"settings-kb-timeout",type:"number",min:10,value:s.parser_timeout_secs,onChange:a=>l({parser_timeout_secs:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-max-upload",className:"text-sm text-muted-foreground",children:"Max upload (MB)"}),e.jsx(y,{id:"settings-kb-max-upload",type:"number",min:1,value:s.max_upload_mb,onChange:a=>l({max_upload_mb:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-retention",className:"text-sm text-muted-foreground",children:"Read log (days)"}),e.jsx(y,{id:"settings-kb-retention",type:"number",min:1,value:s.usage_retention_days,onChange:a=>l({usage_retention_days:a.target.value})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Semantic search"}),e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-session-embeddings",checked:s.session_embeddings,onChange:a=>l({session_embeddings:a.target.checked})}),e.jsxs("span",{children:["Search coding sessions with embeddings",e.jsx("span",{className:"block text-xs text-outline",children:"Uses the provider below for session passages. Keyword search and transcript reading remain available when off. Enabling sends session text to this provider and indexes discovered project sessions."})]})]}),h.data&&e.jsxs("p",{className:"text-xs text-outline","data-testid":"settings-embedding-status",children:[h.data.embedding.ready?`Ready · ${h.data.embedding.model} · ${h.data.embedding.vector_backend}`:h.data.embedding.detail??"Not configured",h.data.embedding.pending_chunks?` · ${h.data.embedding.pending_chunks} passages waiting`:""]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-provider",className:"text-sm text-muted-foreground",children:"Embedding provider"}),e.jsxs(A,{value:s.provider,onValueChange:a=>l({provider:a}),disabled:N("EMBEDDING_PROVIDER"),children:[e.jsx(F,{id:"settings-kb-provider","data-testid":"settings-kb-provider",children:e.jsx(T,{})}),e.jsxs(D,{children:[e.jsx(C,{value:"none",children:"None"}),e.jsx(C,{value:"ollama",children:"Ollama"}),e.jsx(C,{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsx("p",{className:"text-xs text-outline",children:Fe[s.provider]})]}),s.provider!=="none"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-model",className:"text-sm text-muted-foreground",children:"Model"}),e.jsx(y,{id:"settings-kb-model","data-testid":"settings-kb-model",value:s.model,disabled:N("EMBEDDING_MODEL"),onChange:a=>l({model:a.target.value}),placeholder:s.provider==="ollama"?"nomic-embed-text":"text-embedding-3-small"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-dimensions",className:"text-sm text-muted-foreground",children:"Dimensions"}),e.jsx(y,{id:"settings-kb-dimensions",type:"number",value:s.dimensions,onChange:a=>l({dimensions:a.target.value}),placeholder:"Model default"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-base-url",className:"text-sm text-muted-foreground",children:"Base URL"}),e.jsx(y,{id:"settings-kb-base-url","data-testid":"settings-kb-base-url",value:s.base_url,disabled:N("EMBEDDING_URL"),onChange:a=>l({base_url:a.target.value}),placeholder:s.provider==="ollama"?"http://localhost:11434":"https://api.openai.com/v1"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-api-key",className:"text-sm text-muted-foreground",children:s.provider==="ollama"?"Token (hosted or proxied Ollama)":"API key"}),e.jsx(y,{id:"settings-kb-api-key",type:"password",autoComplete:"off","data-testid":"settings-kb-api-key",value:s.api_key,disabled:s.clear_key||N("EMBEDDING_API_KEY"),onChange:a=>l({api_key:a.target.value}),placeholder:j.embedding.api_key_set?"Saved. Type to replace":"Not set"}),j.embedding.api_key_set&&e.jsxs("label",{className:"flex items-center gap-2 text-xs text-outline",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-kb-api-key-clear",checked:s.clear_key,onChange:a=>l({clear_key:a.target.checked,api_key:""})}),"Remove the saved key"]}),e.jsxs("p",{className:"text-xs text-outline",children:["Stored encrypted with the key in ",e.jsx("code",{children:"~/.orc/secret.key"})," and never sent back to the browser. Sent as a bearer token to the base URL."]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Changing the model re-embeds every passage in the background; keyword search keeps working meanwhile."})]})]}),p&&e.jsx("p",{role:"alert","data-testid":"settings-knowledge-error",className:"text-sm text-error",children:p}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{type:"submit","data-testid":"settings-knowledge-save",disabled:d,children:"Save knowledge settings"}),v&&e.jsx("span",{role:"status",className:"text-sm text-muted-foreground",children:"Saved"})]})]}),e.jsx(de,{open:u,title:"Remove Docling",description:"Deletes the Docling runtime and models from this machine. Documents it parsed keep their text; reparse them to use the basic parser.",confirmLabel:"Remove",isPending:d,onCancel:()=>k(!1),onConfirm:async()=>{k(!1),await S(()=>_.kb.uninstallDocling())}})]})}function De(){const t=J();return le({mutationFn:async()=>{const n=await _.system.restart(),h=Date.now()+6e4;for(;Date.now()<h;){await new Promise(c=>setTimeout(c,500));try{if((await _.health.check(AbortSignal.timeout(2e3))).instance_id!==n.instance_id)return}catch(c){if(c instanceof ce&&c.status===401)throw c}}throw new Error("ORC has not reconnected yet. Check the server and try again when it is online.")},onSuccess:()=>t.invalidateQueries()})}function Me(){const{data:t}=me(),n=De();return e.jsxs("section",{"aria-labelledby":"server-title",children:[e.jsx("h2",{id:"server-title",className:"mb-1 text-base font-medium",children:"ORC server"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Restart ORC to reload server and host information. This closes active terminals and may interrupt running work. Your settings are kept, and this dashboard reconnects automatically. Switching hosts applies to new actions without a restart."}),e.jsx(E,{className:"mb-4"}),e.jsxs(w,{variant:"outline","data-testid":"settings-restart",disabled:!(t!=null&&t.restart_supported)||n.isPending,onClick:()=>n.mutate(),children:[e.jsx(Oe,{className:n.isPending?"mr-2 size-4 animate-spin":"mr-2 size-4"}),n.isPending?"Restarting and reconnecting…":"Restart ORC server"]}),t&&!t.restart_supported&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This server does not support restart from the dashboard."}),n.isPending&&e.jsx("p",{role:"status","data-testid":"settings-restart-status",className:"mt-2 text-sm text-muted-foreground",children:"Waiting for ORC to restart…"}),n.isSuccess&&e.jsx("p",{role:"status","data-testid":"settings-restart-status",className:"mt-2 text-sm text-muted-foreground",children:"ORC restarted. Reconnected."}),n.isError&&e.jsx("p",{role:"alert","data-testid":"settings-restart-error",className:"mt-2 text-sm text-error",children:n.error.message})]})}const I="__local__";function Z(t){return t?t instanceof Error?t.message:String(t):null}function ze(){var i;const{data:t,error:n,refetch:h}=he(),{data:c}=ue(),s=xe(),x=ge(),[p,b]=m.useState(I),[v,o]=m.useState("");if(m.useEffect(()=>{t&&(b(t.host??I),o(t.remote_port===null?"":String(t.remote_port)))},[t]),n)return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"Execution host"}),e.jsx(pe,{message:n.message,onRetry:()=>void h()})]});if(!t)return e.jsx("p",{role:"status","data-testid":"page-loading",className:"text-sm text-muted-foreground",children:"Loading execution host…"});const d=p===I?null:p,f=t.host&&!t.hosts.includes(t.host)?[t.host,...t.hosts]:t.hosts,u=Number(v),k=v.trim()===""||Number.isInteger(u)&&u>=1&&u<=65535,j=t.locked||!t.supported,N=c==null?void 0:c.backends.find(r=>r.name==="claude"),l=((i=x.data)==null?void 0:i.host)===d?x.data:void 0;return e.jsxs("section",{"data-testid":"ssh-settings",children:[e.jsx("h2",{className:"font-headline font-semibold text-base text-on-surface mb-1",children:"Execution host"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground mb-4",children:["Run every agent, terminal, git and file action on a host from"," ",e.jsx("code",{className:"text-primary",children:"~/.ssh/config"}),". Agents there reach orc through a reverse tunnel on the remote port. Terminals already open keep their host."]}),e.jsx(E,{className:"bg-surface-highest mb-4"}),e.jsxs("div",{className:"space-y-4",children:[t.locked&&e.jsx("p",{"data-testid":"ssh-locked",className:"font-body text-sm text-tertiary",children:"Fixed by ORC_SSH_HOST in orc's environment."}),!t.supported&&e.jsx("p",{"data-testid":"ssh-unsupported",className:"font-body text-sm text-error",children:t.unsupported_reason}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"ssh-host",className:"font-label text-sm text-muted-foreground",children:"Host"}),e.jsxs(A,{value:p,onValueChange:b,disabled:j,children:[e.jsx(F,{id:"ssh-host","aria-label":"Execution host","data-testid":"ssh-host-picker",className:"bg-surface-highest border-control-border text-on-surface font-body text-sm",children:e.jsx(T,{})}),e.jsxs(D,{className:"bg-surface-highest border-outline-variant max-h-72",children:[e.jsx(C,{value:I,"data-testid":"ssh-host-option-local",className:"font-label text-sm",children:"Local (this machine)"}),f.map(r=>e.jsx(C,{value:r,"data-testid":`ssh-host-option-${r}`,className:"font-label text-sm",children:r},r))]})]}),f.length===0&&e.jsx("p",{"data-testid":"page-empty",className:"font-body text-sm text-muted-foreground",children:"No Host entries found in ~/.ssh/config on the machine running orc."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"ssh-remote-port",className:"font-label text-sm text-muted-foreground",children:"Tunnel port override"}),e.jsx(y,{id:"ssh-remote-port","aria-invalid":!!(d&&!k),"data-testid":"ssh-remote-port",value:v,placeholder:"Automatic",onChange:r=>o(r.target.value),disabled:j||!d,inputMode:"numeric",className:"bg-surface-highest border-outline-variant text-on-surface font-body text-sm"}),d&&!k&&e.jsx("p",{className:"text-sm text-error",children:"Enter a remote port from 1 to 65535."}),e.jsx("p",{className:"font-body text-sm text-muted-foreground",children:"Leave empty to let SSH choose an available port automatically."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(w,{"data-testid":"ssh-save",disabled:j||d!==null&&!k||s.isPending,onClick:()=>s.mutate({host:d,remotePort:d&&v.trim()?u:null}),className:"font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(X,{size:12,className:"mr-1.5"})," Use Host"]}),e.jsxs(w,{"data-testid":"ssh-test",variant:"ghost",disabled:!d||!t.supported||x.isPending,onClick:()=>d&&x.mutate(d),className:"font-label text-sm text-muted-foreground hover:text-on-surface",children:[e.jsx(Re,{size:12,className:"mr-1.5"})," ",x.isPending?"Testing…":"Test"]})]}),Z(s.error??x.error)&&e.jsx("p",{"data-testid":"ssh-error",className:"font-body text-sm text-error",children:Z(s.error??x.error)}),l&&e.jsx("div",{"data-testid":"ssh-test-result",className:"font-body text-sm space-y-1",children:l.ok?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-secondary",children:["Connected to ",l.host," (",l.os,", ",l.shell,")"]}),e.jsx("p",{className:"text-muted-foreground",children:Object.entries(l.binaries).map(([r,S])=>`${S?"●":"○"} ${r}`).join(" ")}),l.binaries.claude&&l.claude_logged_in===!1&&e.jsxs("p",{className:l.api_key_forwarded?"text-muted-foreground":"text-error",children:["claude is not logged in on ",l.host,"."," ",l.api_key_forwarded?"ANTHROPIC_API_KEY from orc's environment will be forwarded.":"Set ANTHROPIC_API_KEY in orc's environment or run claude login there."]})]}):e.jsx("p",{className:"text-error",children:l.error})}),t.host&&N&&!N.available&&e.jsxs("p",{"data-testid":"ssh-claude-error",className:"font-body text-sm text-error",children:["claude backend: ",N.error]})]})]})}function Be(){const{theme:t}=fe(),[n,h]=m.useState(G),[c,s]=m.useState(()=>localStorage.getItem(O)??""),[x,p]=m.useState(!1),[b,v]=m.useState(""),[o,d]=m.useState(""),[f,u]=m.useState(!1),k=J(),j=async()=>{d(""),u(!0);try{const i=n.trim();if(i&&!i.startsWith("/")&&!/^https?:\/\//i.test(i))throw new Error("Use a relative API path or an http(s) server URL.");const r=await _.settings.save({theme:t,terminal_font:c.trim()});Y(r.theme??t),s(r.terminal_font??""),r.terminal_font?localStorage.setItem(O,r.terminal_font):localStorage.removeItem(O);const S=(i||"/api")!==G();localStorage.setItem("orc_api_url",i||"/api"),S&&window.dispatchEvent(new Event(q)),k.invalidateQueries(),p(!0),v("Workspace preferences saved on the server. API address saved in this browser."),setTimeout(()=>p(!1),2e3)}catch(i){d(i instanceof Error?i.message:"Browser settings could not be saved.")}finally{u(!1)}},N=async()=>{d(""),u(!0);try{const i=await _.settings.save({terminal_font:""});localStorage.removeItem("orc_api_url"),localStorage.setItem(O,i.terminal_font??""),h("/api"),s(i.terminal_font??""),window.dispatchEvent(new Event(q)),k.invalidateQueries(),p(!1),v("Connection and terminal font restored to their defaults. Appearance and execution host were kept.")}catch(i){d(i instanceof Error?i.message:"Browser settings could not be reset.")}finally{u(!1)}};async function l(i){d(""),u(!0);try{const r=await _.settings.save({theme:i});Y(r.theme??i)}catch(r){d(r instanceof Error?r.message:"Appearance could not be saved.")}finally{u(!1)}}return e.jsxs("div",{children:[e.jsx(be,{title:"Settings"}),e.jsxs("div",{className:"max-w-lg space-y-8",children:[e.jsxs("section",{"aria-labelledby":"appearance-title",children:[e.jsx("h2",{id:"appearance-title",className:"mb-1 text-base font-medium",children:"Appearance"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Choose a workspace theme. Your choice is saved on the server immediately."}),e.jsx("fieldset",{className:"flex flex-wrap gap-2","aria-label":"Theme",children:["dark","light"].map(i=>e.jsx(w,{variant:t===i?"secondary":"outline","aria-pressed":t===i,"data-testid":`settings-theme-${i}`,disabled:f,onClick:()=>void l(i),children:i==="dark"?"Dark":"Light"},i))})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-headline font-medium text-base text-on-surface mb-1",children:"API connection"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground mb-4",children:["Connect this workspace to an ORC server. The default"," ",e.jsx("code",{className:"text-primary",children:"/api"})," uses the current server or the configured development proxy."]}),e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-api-url",className:"font-label text-sm text-muted-foreground",children:"API base URL"}),e.jsx(y,{id:"settings-api-url","data-testid":"settings-api-url",value:n,onChange:i=>h(i.target.value),placeholder:"/api or http://localhost:7700",className:"bg-background text-on-surface font-body text-sm"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground",children:["Use ",e.jsx("code",{children:"/api"})," (dev proxy) or a direct URL when CORS is enabled."]})]})})]}),e.jsx(ze,{}),e.jsx(Me,{}),e.jsx(Ie,{}),e.jsx(Te,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-headline font-medium text-base text-on-surface mb-1",children:"Terminal"}),e.jsx("p",{className:"font-body text-sm text-muted-foreground mb-4",children:"Prompt and agent status icons need a Nerd Font installed on this machine. Common ones are tried automatically; set the exact family name if your icons show as empty boxes. Applies to terminals opened after saving."}),e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-terminal-font",className:"font-label text-sm text-muted-foreground",children:"Terminal font family"}),e.jsx(y,{id:"settings-terminal-font",value:c,onChange:i=>s(i.target.value),placeholder:"e.g. MesloLGS NF",className:"bg-background text-on-surface font-body text-sm"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 pt-2",children:[e.jsx(w,{"data-testid":"settings-save",disabled:f,onClick:()=>void j(),className:"font-label text-sm ",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"mr-1.5"})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{size:12,className:"mr-1.5"})," Save settings"]})}),e.jsx(w,{variant:"ghost",disabled:f,onClick:()=>void N(),className:"font-label text-sm text-muted-foreground hover:text-on-surface",children:"Reset to defaults"})]}),o&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:o}),b&&!o&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:b}),e.jsxs("section",{children:[e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:"Storage"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground",children:["Workspace preferences and SSH selection are persisted in the server's"," ",e.jsx("code",{children:"~/.orc/config.json"}),". The API address and optionally remembered login are stored in this browser."]})]})]})]})}export{Be as default};
@@ -1 +1 @@
1
- import{j as e,aF as ie,r as v,a as K,u as F,b as I,d as S,a8 as E,U as $,W as A,X as T,B as b,as as H,Y as P,Z as D,$ as O,a0 as le,E as J,V as ne,ak as re,aB as oe,S as ee,af as ce,T as de,s as ue,t as G,v as R,w as me,x as _,a2 as xe,a3 as he,a4 as pe,a5 as ge,a6 as fe,ac as M,k as te,M as je}from"./index-SOCnaNS0.js";import{D as be,c as W}from"./DocumentWorkspace-VHzjE2ih.js";import{u as ye}from"./useProjectScope-B28fk5NO.js";import{r as ve}from"./primitive-files-BwTyowra.js";import{D as Y}from"./download-36kk3IeP.js";function ke({files:a,selected:i,onSelect:x,testId:h="document-file-tab",entryTestId:c}){return e.jsxs("nav",{"aria-label":"Document files",className:"min-w-0 space-y-2","data-testid":"document-tabs",children:[e.jsx("div",{role:"tablist","aria-label":"Open a file",className:"flex max-w-full gap-1 overflow-x-auto overscroll-x-contain rounded-md border border-surface-highest p-1",children:a.map((n,t)=>e.jsxs("button",{type:"button",role:"tab","aria-selected":n===i,"data-testid":t===0&&c?c:h,"data-file-name":n,title:n,tabIndex:n===i?0:-1,onKeyDown:o=>{var y,p;if(!["ArrowRight","ArrowLeft","Home","End"].includes(o.key))return;o.preventDefault();let f=t;if(o.key==="ArrowRight"&&(f=(t+1)%a.length),o.key==="ArrowLeft"&&(f=(t+a.length-1)%a.length),o.key==="Home"&&(f=0),o.key==="End"&&(f=a.length-1),x(a[f])===!1)return;const l=(y=o.currentTarget.parentElement)==null?void 0:y.querySelectorAll('[role="tab"]');(p=l==null?void 0:l[f])==null||p.focus()},onClick:()=>x(n),className:`flex min-h-11 shrink-0 items-center gap-2 rounded px-3 text-sm ${n===i?"bg-surface-highest text-on-surface":"text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:[e.jsx(ie,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-w-[180px] truncate",children:n.split("/").pop()})]},n))}),e.jsxs("label",{className:"flex min-w-0 items-center gap-2 text-sm text-outline sm:hidden",children:["File",e.jsx("select",{"aria-label":"Choose document file","data-testid":"document-file-picker",value:i,onChange:n=>x(n.target.value),className:"min-h-11 min-w-0 flex-1 rounded border border-control-border bg-surface px-2 text-on-surface",children:a.map(n=>e.jsx("option",{value:n,children:n},n))})]})]})}const X={new:"",installed:"Already in ORC",conflict:"Name taken in ORC (different content)",changed:"Changed since import",invalid:"Invalid"},q=a=>`${a.agent}/${a.name}`;function Ne({onClose:a}){var y,p,w;const[i,x]=v.useState([]),h=K(),c=F({queryKey:["skills","local-agents"],queryFn:S.skills.localAgents}),n=I({mutationFn:S.skills.importLocal,onSuccess:async g=>{x([]),await h.invalidateQueries({queryKey:["skills"]}),g.skipped.length||a()}}),t=n.isPending,o=((y=c.data)==null?void 0:y.agents)??[],s=new Set(i.map(g=>g.split("/")[1])),f=(g,k)=>x(k?[...i,q(g)]:i.filter(m=>m!==q(g))),l=g=>{const k=[...i],m=new Set(s);for(const N of g)N.status!=="new"||m.has(N.name)||(k.push(q(N)),m.add(N.name));x(k)};return e.jsx(E,{open:!0,onOpenChange:g=>!g&&!t&&a(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(A,{children:e.jsx(T,{children:"Import from local agents"})}),e.jsx("p",{className:"text-xs text-outline",children:"Copies skills from agent folders such as ~/.claude/skills and ~/.codex/skills into ORC. The originals are not changed."}),c.isLoading&&e.jsx("p",{role:"status",children:"Scanning agent folders…"}),c.data&&!o.length&&e.jsx("p",{role:"status",children:"No local agent skill folders found."}),e.jsx("div",{className:"max-h-[55vh] overflow-y-auto space-y-4",children:o.map(g=>{const k=g.skills.filter(m=>m.status==="new");return e.jsxs("section",{"data-testid":"local-agent","data-agent":g.id,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:g.label}),e.jsx("p",{className:"text-xs text-outline",children:g.dir})]}),e.jsxs(b,{size:"sm",variant:"outline","data-testid":"local-agent-select-all",disabled:t||!k.length,onClick:()=>l(g.skills),children:["Select all new (",k.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:g.skills.map(m=>{const N=i.includes(q(m)),r=!N&&s.has(m.name);return e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"local-skill","data-skill-name":m.name,children:[e.jsx("input",{type:"checkbox","data-testid":"local-skill-select",checked:N,disabled:t||m.status!=="new"||r,onChange:d=>f(m,d.target.checked)}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:m.name}),X[m.status]&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:X[m.status]}),e.jsx("span",{className:"block text-xs text-outline",children:m.error??m.description}),m.extra_fields.length>0&&e.jsxs("span",{className:"block text-xs text-outline","data-testid":"local-skill-extra-fields",children:["Extra fields: ",m.extra_fields.join(", ")]}),m.also_in.length>0&&e.jsxs("span",{className:"block text-xs text-outline",children:["Also in ",m.also_in.join(", ")]})]})]},q(m))})})]},g.id)})}),(p=n.data)==null?void 0:p.skipped.map(g=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:["Skipped ",g.name,": ",g.reason]},`${g.agent}/${g.name}`)),(c.error||n.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(w=c.error||n.error)==null?void 0:w.message}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:t,onClick:a,children:"Close"}),e.jsx(b,{"data-testid":"local-skill-import-submit",disabled:t||!i.length,onClick:()=>n.mutate(i.map(g=>{const[k="",m=""]=g.split("/");return{agent:k,name:m}})),children:n.isPending?"Importing…":`Import selected${i.length?` (${i.length})`:""}`})]})]})})}function Se({onClose:a}){var f;const[i,x]=v.useState(""),[h,c]=v.useState([]),n=K(),t=I({mutationFn:S.skills.discover,onSuccess:()=>c([])}),o=I({mutationFn:S.skills.import,onSuccess:async()=>{await n.invalidateQueries({queryKey:["skills"]}),a()}}),s=t.isPending||o.isPending;return e.jsx(E,{open:!0,onOpenChange:l=>!l&&!s&&a(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(A,{children:e.jsx(T,{children:"Import from GitHub"})}),e.jsxs("form",{className:"space-y-4",onSubmit:l=>{l.preventDefault(),t.mutate(i.trim())},children:[e.jsx(P,{htmlFor:"skill-repository",children:"Repository or skills.sh link"}),e.jsx(D,{id:"skill-repository","data-testid":"skill-repository-input",value:i,disabled:s,onChange:l=>{x(l.target.value),t.reset(),o.reset(),c([])},placeholder:"https://github.com/vercel-labs/agent-skills",autoFocus:!0}),e.jsx("p",{className:"text-xs text-outline",children:"GitHub repositories, owner/repo, skill-folder URLs and skills.sh links. Private repositories use gh login on the execution host (local or SSH), or ORC_GITHUB_TOKEN on the ORC server. Supporting files are included."}),e.jsx(b,{type:"submit","data-testid":"skill-discover",disabled:s||!i.trim(),children:t.isPending?"Discovering…":"Discover skills"})]}),t.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-outline",children:[t.data.skills.length," skills found · ",t.data.commit.slice(0,8)]}),!t.data.skills.length&&e.jsx("p",{role:"status",children:"No valid skills found in this source."}),e.jsx("div",{className:"max-h-[45vh] overflow-y-auto space-y-2",children:t.data.skills.map(l=>e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"remote-skill","data-skill-name":l.name,children:[e.jsx("input",{type:"checkbox","data-testid":"remote-skill-select",checked:h.includes(l.path),disabled:s||l.installed||!h.includes(l.path)&&h.length>=16,onChange:y=>c(y.target.checked?[...h,l.path]:h.filter(p=>p!==l.path))}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:l.name}),l.installed&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:"Already installed"}),e.jsx("span",{className:"block text-xs text-outline",children:l.description}),e.jsx("span",{className:"block text-xs text-outline",children:l.path||"Repository root"})]})]},l.path))}),t.data.issues.map(l=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:[l.path,": ",l.error]},l.path))]}),(t.error||o.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(f=t.error||o.error)==null?void 0:f.message}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:s,onClick:a,children:"Cancel"}),e.jsx(b,{"data-testid":"skill-import-submit",disabled:s||!t.data||!h.length,onClick:()=>t.data&&o.mutate({source:i.trim(),commit:t.data.commit,paths:h}),children:o.isPending?"Importing…":`Import selected${h.length?` (${h.length})`:""}`})]})]})})}function we({name:a,scope:i,mutation:x}){var s,f;const h=K(),[c,n]=v.useState(""),t=F({queryKey:["skill-history",a,i],queryFn:()=>S.skills.history(a,i)}),o=I({mutationFn:l=>{if(!x)throw new Error("No active instruction edit");return S.skills.revert(a,{project_id:x.project_id,change_id:l,expected_change_id:x.id,reason:c.trim()})},onSuccess:()=>{h.invalidateQueries({queryKey:["skill"]}),h.invalidateQueries({queryKey:["skills"]}),h.invalidateQueries({queryKey:["skill-history"]}),n("")}});return!((s=t.data)!=null&&s.changes.length)&&!t.error?null:e.jsxs("section",{"data-testid":"skill-history-panel",className:"mb-5 space-y-3",children:[x&&e.jsxs("p",{"data-testid":"skill-mutated-label",className:"text-xs text-primary",children:["Mutated · ",x.project_id?"Project":"Global"," ·"," ",new Date(x.updated_at*1e3).toLocaleString()," · ",x.author]}),e.jsx("h3",{className:"text-sm font-medium",children:"Instruction history"}),e.jsx(D,{"data-testid":"skill-revert-reason","aria-label":"Reason for reverting instructions",value:c,onChange:l=>n(l.target.value),placeholder:"Reason for reverting..."}),t.error&&e.jsx("p",{role:"alert",children:t.error.message}),o.error&&e.jsx("p",{role:"alert",children:o.error.message}),(f=t.data)==null?void 0:f.changes.map(l=>e.jsxs("details",{"data-testid":"skill-history-change",className:"border-b border-outline-variant p-3",children:[e.jsxs("summary",{className:"text-xs cursor-pointer",children:[l.action," · ",l.reason," · ",l.author]}),e.jsx("p",{className:"text-xs text-outline mt-2",children:"Before"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l.previous_raw}),e.jsx("p",{className:"text-xs text-outline mt-2",children:"After"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l.raw}),e.jsx(b,{"data-testid":"skill-revert-change",size:"sm",variant:"outline",disabled:!c.trim()||o.isPending,onClick:()=>o.mutate(l.id),children:"Restore instructions before this change"})]},l.id))]})}function Ce({name:a}){const i=K(),[x,h]=v.useState(!1),c=F({queryKey:["skill-origin",a],queryFn:()=>S.skills.origin(a)}),n=I({mutationFn:s=>S.skills.sync(a,s),onSuccess:async s=>{h(!1),s.applied&&await Promise.all([i.invalidateQueries({queryKey:["skill",a]}),i.invalidateQueries({queryKey:["skills"]}),i.invalidateQueries({queryKey:["skill-origin",a]})])}});if(c.error)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:c.error.message});if(!c.data)return null;const t=n.data,o=t&&!t.applied&&t.conflicts.length>0;return e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Imported from"," ",e.jsx("a",{className:"text-primary underline",href:`https://github.com/${c.data.repository}/tree/${encodeURIComponent(c.data.ref==="HEAD"?c.data.commit:c.data.ref)}/${c.data.path}`,target:"_blank",rel:"noreferrer",children:c.data.repository})," ","· ",c.data.commit.slice(0,8)]}),e.jsx(b,{"data-testid":"skill-sync",variant:"outline",size:"sm",disabled:n.isPending,onClick:()=>n.mutate({}),children:n.isPending?"Syncing…":"Sync from GitHub"}),(t==null?void 0:t.applied)&&e.jsx("p",{role:"status","data-testid":"skill-sync-status",className:"text-xs",children:t.changed.length?`Synced ${t.changed.length} files. Local edits preserved outside confirmed conflicts.`:"Up to date. Local edits preserved."}),o&&e.jsxs("div",{"data-testid":"skill-sync-conflicts",className:"space-y-2",children:[e.jsx("p",{role:"alert",className:"text-sm",children:"Sync paused. Both you and GitHub changed these files:"}),e.jsx("ul",{className:"text-xs space-y-1",children:t.conflicts.map(s=>e.jsx("li",{children:s},s))}),e.jsx(b,{"data-testid":"skill-sync-review-override",variant:"outline",size:"sm",onClick:()=>h(!0),children:"Review override"})]}),n.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n.error.message}),e.jsx(E,{open:x,onOpenChange:s=>!n.isPending&&h(s),children:e.jsxs($,{children:[e.jsx(A,{children:e.jsx(T,{children:"Replace conflicting local edits?"})}),e.jsxs("p",{className:"text-sm",children:["GitHub's version at ",t==null?void 0:t.commit.slice(0,8)," will replace or remove these files. Your other local edits will be kept. The current skill folder will be backed up."]}),e.jsx("ul",{className:"text-sm space-y-1",children:t==null?void 0:t.conflicts.map(s=>e.jsx("li",{children:s},s))}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:n.isPending,onClick:()=>h(!1),children:"Keep local edits"}),e.jsx(b,{"data-testid":"skill-sync-confirm-override",disabled:n.isPending,onClick:()=>t&&n.mutate({override:!0,expectedCommit:t.commit,expectedRevision:t.revision}),children:n.isPending?"Syncing…":"Replace listed files"})]})]})})]})}function Le(a){return F({queryKey:["skills",a],queryFn:()=>S.skills.list(a)})}function Ie(){return F({queryKey:["skill-visibility"],queryFn:()=>S.skills.visibility()})}function Ke(){const a=K();return I({mutationFn:i=>S.skills.setVisibility(i),onSuccess:i=>{a.setQueryData(["skill-visibility"],i),a.invalidateQueries({queryKey:["skills"]})}})}function Z(a,i,x={}){return F({queryKey:["skill",a,i,x],queryFn:()=>S.skills.get(a,i,x),enabled:!!a})}function De(){const a=K();return I({mutationFn:i=>S.skills.create(i),onSuccess:()=>a.invalidateQueries({queryKey:["skills"]})})}const Fe=[{value:"all",label:"All"},{value:"builtin",label:"Built-in"},{value:"user",label:"User"}],se={builtin:"text-muted-foreground",user:"text-muted-foreground"};function Te({projectId:a}){var z,U;const i=ye(a),x=i==="all"||i==="unassigned"?{scope:"global"}:{project_id:i},[h,c]=O("skillQuery",""),[n,t]=v.useState(h),[o,s]=O("source","all",["all","builtin","user"]);v.useEffect(()=>t(h),[h]);const{selectedId:f,openDetail:l,closeDetail:y}=le("/skills","skillName"),[p,w]=v.useState(!1),[g,k]=v.useState(!1),[m,N]=v.useState(!1),r=Ie(),d=Ke(),{data:j,isLoading:C,error:B,refetch:ae}=Le({...x,q:h||void 0,source:o==="all"?void 0:o,include_hidden:!0}),Q=j==null?void 0:j.skills;return B?e.jsx(J,{message:B.message,onRetry:()=>ae()}):e.jsxs("div",{children:[e.jsx(ne,{title:"Skills",meta:`${(Q??[]).length} skills`,action:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(b,{"data-testid":"import-skill-button",size:"sm",variant:"outline",onClick:()=>k(!0),children:[e.jsx(Y,{size:12,className:"mr-1"})," Import from GitHub"]}),e.jsxs(b,{"data-testid":"import-local-skills-button",size:"sm",variant:"outline",onClick:()=>N(!0),children:[e.jsx(Y,{size:12,className:"mr-1"})," Import from agents"]}),e.jsxs(b,{"data-testid":"new-skill-button",size:"sm",onClick:()=>w(!0),className:"font-label text-sm ",children:[e.jsx(re,{size:12,className:"mr-1"})," New skill"]})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["Skill folders follow the"," ",e.jsx("a",{className:"text-primary underline",href:"https://agentskills.io/specification",target:"_blank",rel:"noreferrer",children:"Agent Skills specification"}),"."]}),e.jsx("p",{className:"mb-4 text-sm leading-relaxed text-muted-foreground",children:"Built-in visibility applies to agent discovery across this installation. Hidden skills remain readable by name and available to flows. Authored overrides stay visible."}),(r.error||d.error)&&e.jsx("p",{role:"alert",className:"text-destructive text-xs mb-2",children:(z=r.error||d.error)==null?void 0:z.message}),(U=j==null?void 0:j.broken)==null?void 0:U.map(u=>e.jsxs("p",{role:"alert",className:"text-destructive text-xs mb-2",children:[u.path,": ",u.error]},u.path)),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex shrink-0 flex-wrap gap-1.5",children:Fe.map(u=>e.jsx("button",{type:"button",onClick:()=>s(u.value),"data-testid":`skill-source-${u.value}`,"aria-pressed":o===u.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${o===u.value?"bg-surface-highest text-on-surface border-transparent":"bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:u.label},u.value))}),e.jsxs("div",{className:"relative min-w-[160px] flex-1",children:[e.jsx(oe,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{"aria-label":"Search skills",value:n,onChange:u=>t(u.target.value),onKeyDown:u=>u.key==="Enter"&&c(u.currentTarget.value),placeholder:"Search skills...",className:"pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground"})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>c(n),className:"font-label text-sm ",children:"Search"})]}),C?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((u,L)=>e.jsx(ee,{className:"h-10 w-full bg-surface-highest"},L))}):(Q??[]).length===0?e.jsx(ce,{message:h?"No skills match your search":"No skills found"}):e.jsx("div",{className:"overflow-hidden",children:e.jsxs(de,{children:[e.jsx(ue,{children:e.jsxs(G,{className:"border-b border-outline-variant hover:bg-transparent",children:[e.jsx(R,{className:"font-label text-sm text-muted-foreground",children:"Name"}),e.jsx(R,{className:"font-label text-sm text-muted-foreground",children:"Description"}),e.jsx(R,{className:"font-label text-sm text-muted-foreground w-24",children:"Source"}),e.jsx(R,{className:"text-xs text-muted-foreground",children:"Agent discovery"})]})}),e.jsx(me,{children:(Q??[]).map(u=>e.jsxs(G,{"data-testid":"skill-row","data-skill-name":u.name,className:"border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer",onClick:()=>l(u.name),children:[e.jsxs(_,{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",onClick:L=>{L.stopPropagation(),l(u.name)},children:u.name}),u.mutation&&e.jsx("span",{className:"ml-2 text-primary text-xs",children:"Mutated"})]}),e.jsx(_,{className:"font-body text-sm text-muted-foreground max-w-md truncate",children:u.description||"—"}),e.jsx(_,{children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${se[u.source]}`,children:u.source})}),e.jsx(_,{onClick:L=>L.stopPropagation(),children:u.source==="builtin"&&!u.mutation?e.jsx("button",{type:"button",role:"switch","aria-label":`${u.name} visible to agents`,"aria-checked":!u.discovery_hidden,"data-testid":`skill-visibility-${u.name}`,disabled:!r.data||d.isPending,className:"text-xs text-primary disabled:opacity-50",onClick:()=>{var V;const L=new Set(((V=r.data)==null?void 0:V.hidden_builtins)??[]);L.has(u.name)?L.delete(u.name):L.add(u.name),d.mutate([...L])},children:u.discovery_hidden?"Hidden — show":"Visible — hide"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:u.mutation?"Visible (override)":"Visible"})})]},u.name))})]})}),e.jsx(qe,{scope:x,skillName:f,open:!!f,onClose:y},f),p&&e.jsx(Re,{open:p,onClose:()=>w(!1)}),g&&e.jsx(Se,{onClose:()=>k(!1)}),m&&e.jsx(Ne,{onClose:()=>N(!1)})]})}function qe({skillName:a,scope:i,open:x,onClose:h}){const{data:c,isLoading:n,error:t,refetch:o}=Z(a,void 0,i),s=c,[f,l]=O("skillFile","SKILL.md"),y=Z(a,f??"SKILL.md",i),p=y.data,w=K(),[g,k]=v.useState(!1),m=`skill:${i.project_id??"global"}:${a}:${f??"SKILL.md"}`;function N(d){return(d??"SKILL.md")===(f??"SKILL.md")?!0:W(m)?(l(d??"SKILL.md"),!0):!1}const r=s?e.jsx(ke,{files:["SKILL.md",...(s.files??[]).map(d=>d.name)],selected:f??"SKILL.md",onSelect:d=>N(d==="SKILL.md"?void 0:d),testId:"skill-file",entryTestId:"skill-show-entry"}):null;return e.jsx(xe,{open:x,onOpenChange:d=>!d&&W(m)&&h(),children:e.jsxs(he,{className:"w-screen max-w-full sm:w-[1120px] sm:max-w-[96vw]",children:[e.jsxs(pe,{children:[e.jsx(ge,{children:(s==null?void 0:s.name)??"Skill Details"}),(s==null?void 0:s.description)&&e.jsx("p",{className:"font-body text-sm text-muted-foreground mt-1",children:s.description})]}),e.jsx(fe,{children:e.jsxs(e.Fragment,{children:[a&&s&&e.jsx(we,{name:a,scope:i,mutation:s.mutation}),a&&s&&e.jsx(Ce,{name:a}),t?e.jsx(J,{message:t.message,onRetry:()=>void o()}):n||!s?e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((d,j)=>e.jsx(ee,{className:"h-8 w-full bg-surface-highest"},j))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(M,{label:"Source",children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${se[s.source]}`,children:s.source})}),e.jsx(M,{label:"Path",children:e.jsx("code",{className:"font-mono text-sm text-muted-foreground break-all",children:s.path})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:f??"SKILL.md"}),e.jsxs("div",{className:"overflow-hidden",children:[(p==null?void 0:p.encoding)==="base64"&&e.jsx("div",{className:"p-3",children:r}),y.error?e.jsx("p",{role:"alert",children:y.error.message}):y.isLoading?e.jsx("p",{children:"Loading..."}):(p==null?void 0:p.encoding)==="base64"?e.jsx(te,{path:f??"SKILL.md",value:(p==null?void 0:p.content)??"",readOnly:!0,hidePreview:!0,height:400,testId:"skill-file-content"}):e.jsx(be,{documentId:m,expanded:g,onExpandedChange:k,navigation:r,path:f??"SKILL.md",content:(p==null?void 0:p.content)??"",testId:"skill-file-content",onSave:s.source==="user"&&(p==null?void 0:p.encoding)==="utf8"?async(d,j)=>{const C=f??"SKILL.md";return s.mutation&&C==="SKILL.md"?await S.skills.updateInstructions(s.name,{project_id:i.project_id??null,content:d,expected_content:j,reason:"Manual instruction edit",author:"human"}):await S.skills.editFile(s.name,{path:C,content:d,expectedContent:j}),await w.invalidateQueries({queryKey:["skill",s.name]}),await w.invalidateQueries({queryKey:["skills"]}),await w.invalidateQueries({queryKey:["skill-history",s.name]}),d}:void 0},m),(p==null?void 0:p.encoding)==="base64"&&e.jsx("p",{className:"p-4 text-xs text-muted-foreground",children:"Binary asset shown as base64 (read-only)."})]})]})]})]})})]})})}function Re({open:a,onClose:i}){var N;const[x,h]=v.useState(""),[c,n]=v.useState(""),t=De(),[o,s]=v.useState([]),[f,l]=v.useState(),[y,p]=v.useState(!1),w=!!(x||c||o.length);v.useEffect(()=>{if(!w)return;function r(d){d.preventDefault(),d.returnValue=""}return window.addEventListener("beforeunload",r),()=>window.removeEventListener("beforeunload",r)},[w]);function g(){t.isPending||y||(!w||window.confirm("Discard this unsaved skill?"))&&i()}async function k(r){if(r!=null&&r.length){p(!0),l(void 0);try{const d=(await ve(r)).map(C=>({...C,encoding:C.encoding??"utf8",id:crypto.randomUUID()})),j=d.find(C=>C.path==="SKILL.md");if(!j)throw new Error("Choose a skill folder containing SKILL.md");if(j.encoding!=="utf8")throw new Error("SKILL.md must be UTF-8 text");n(j.content),h(r[0].webkitRelativePath.split("/")[0]),s(d.filter(C=>C!==j))}catch(d){l(d.message)}finally{p(!1)}}}const m=()=>{!x.trim()||!c.trim()||t.isPending||y||o.some(r=>!r.path.trim())||t.mutate({name:x.trim(),content:c.trim(),files:o.map(({path:r,content:d,encoding:j})=>({path:r,content:d,encoding:j}))},{onSuccess:i})};return e.jsx(E,{open:a,onOpenChange:r=>!r&&g(),children:e.jsxs($,{className:"bg-surface border-outline-variant w-[calc(100%_-_1rem)] max-w-5xl max-h-[94dvh] overflow-y-auto",children:[e.jsx(A,{children:e.jsx(T,{className:"font-headline text-base text-on-surface",children:"New skill"})}),e.jsxs("form",{onSubmit:r=>{r.preventDefault(),m()},className:"space-y-3 mt-2",children:[e.jsx(P,{htmlFor:"skill-folder-input",children:"Import skill folder"}),e.jsx(D,{id:"skill-folder-input","data-testid":"skill-folder-input",type:"file",multiple:!0,webkitdirectory:"",onChange:r=>void k(r.target.files)}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{className:"font-label text-sm text-muted-foreground",children:"Name *"}),e.jsx(D,{"aria-label":"Name","data-testid":"skill-name-input",value:x,onChange:r=>h(r.target.value),placeholder:"my-skill",className:"bg-background 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:"SKILL.md *"}),e.jsx(je,{testId:"skill-content-input",path:"SKILL.md",value:c,onChange:n,onSave:m})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{"data-testid":"skill-add-file",type:"button",variant:"outline",onClick:()=>s([...o,{id:crypto.randomUUID(),path:"",content:"",encoding:"utf8"}]),children:"Add file"}),o.map(r=>e.jsxs("div",{"data-testid":"skill-supporting-file",className:"space-y-2 border border-outline-variant p-3",children:[e.jsx(D,{"data-testid":"skill-file-path-input","aria-label":"File path",placeholder:"references/guide.md or scripts/check.py",value:r.path,onChange:d=>s(o.map(j=>j.id===r.id?{...j,path:d.target.value}:j))}),e.jsx(te,{testId:"skill-file-content-input",path:r.path||"supporting.txt",readOnly:r.encoding==="base64",label:`Content of ${r.path||"supporting file"}`,value:r.content,height:180,onChange:d=>s(o.map(j=>j.id===r.id?{...j,content:d}:j))}),r.encoding==="base64"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Binary asset (base64)"}),e.jsx(b,{type:"button",variant:"ghost",onClick:()=>s(o.filter(d=>d.id!==r.id)),children:"Remove file"})]},r.id))]}),(f||t.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f??((N=t.error)==null?void 0:N.message)}),e.jsxs(H,{children:[e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:g,className:"font-label text-sm text-muted-foreground",children:"Cancel"}),e.jsx(b,{"data-testid":"skill-submit",type:"submit",size:"sm",disabled:y||t.isPending||!x.trim()||!c.trim()||o.some(r=>!r.path.trim()),className:"font-label text-sm ",children:t.isPending?"Creating...":"Create"})]})]})]})})}export{Te as default};
1
+ import{j as e,aG as ie,r as v,a as K,u as F,b as I,d as S,a8 as E,U as $,W as A,X as T,B as b,as as H,Y as P,Z as D,$ as O,a0 as le,E as J,V as ne,ak as re,aC as oe,S as ee,af as ce,T as de,s as ue,t as G,v as R,w as me,x as _,a2 as xe,a3 as he,a4 as pe,a5 as ge,a6 as fe,ac as M,k as te,M as je}from"./index-BqQDBYwx.js";import{D as be,c as W}from"./DocumentWorkspace-BI4JWVsO.js";import{u as ye}from"./useProjectScope-BvcpSOql.js";import{r as ve}from"./primitive-files-BwTyowra.js";import{D as Y}from"./download-CK_EusLu.js";function ke({files:a,selected:i,onSelect:x,testId:h="document-file-tab",entryTestId:c}){return e.jsxs("nav",{"aria-label":"Document files",className:"min-w-0 space-y-2","data-testid":"document-tabs",children:[e.jsx("div",{role:"tablist","aria-label":"Open a file",className:"flex max-w-full gap-1 overflow-x-auto overscroll-x-contain rounded-md border border-surface-highest p-1",children:a.map((n,t)=>e.jsxs("button",{type:"button",role:"tab","aria-selected":n===i,"data-testid":t===0&&c?c:h,"data-file-name":n,title:n,tabIndex:n===i?0:-1,onKeyDown:o=>{var y,p;if(!["ArrowRight","ArrowLeft","Home","End"].includes(o.key))return;o.preventDefault();let f=t;if(o.key==="ArrowRight"&&(f=(t+1)%a.length),o.key==="ArrowLeft"&&(f=(t+a.length-1)%a.length),o.key==="Home"&&(f=0),o.key==="End"&&(f=a.length-1),x(a[f])===!1)return;const l=(y=o.currentTarget.parentElement)==null?void 0:y.querySelectorAll('[role="tab"]');(p=l==null?void 0:l[f])==null||p.focus()},onClick:()=>x(n),className:`flex min-h-11 shrink-0 items-center gap-2 rounded px-3 text-sm ${n===i?"bg-surface-highest text-on-surface":"text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:[e.jsx(ie,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-w-[180px] truncate",children:n.split("/").pop()})]},n))}),e.jsxs("label",{className:"flex min-w-0 items-center gap-2 text-sm text-outline sm:hidden",children:["File",e.jsx("select",{"aria-label":"Choose document file","data-testid":"document-file-picker",value:i,onChange:n=>x(n.target.value),className:"min-h-11 min-w-0 flex-1 rounded border border-control-border bg-surface px-2 text-on-surface",children:a.map(n=>e.jsx("option",{value:n,children:n},n))})]})]})}const X={new:"",installed:"Already in ORC",conflict:"Name taken in ORC (different content)",changed:"Changed since import",invalid:"Invalid"},q=a=>`${a.agent}/${a.name}`;function Ne({onClose:a}){var y,p,w;const[i,x]=v.useState([]),h=K(),c=F({queryKey:["skills","local-agents"],queryFn:S.skills.localAgents}),n=I({mutationFn:S.skills.importLocal,onSuccess:async g=>{x([]),await h.invalidateQueries({queryKey:["skills"]}),g.skipped.length||a()}}),t=n.isPending,o=((y=c.data)==null?void 0:y.agents)??[],s=new Set(i.map(g=>g.split("/")[1])),f=(g,k)=>x(k?[...i,q(g)]:i.filter(m=>m!==q(g))),l=g=>{const k=[...i],m=new Set(s);for(const N of g)N.status!=="new"||m.has(N.name)||(k.push(q(N)),m.add(N.name));x(k)};return e.jsx(E,{open:!0,onOpenChange:g=>!g&&!t&&a(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(A,{children:e.jsx(T,{children:"Import from local agents"})}),e.jsx("p",{className:"text-xs text-outline",children:"Copies skills from agent folders such as ~/.claude/skills and ~/.codex/skills into ORC. The originals are not changed."}),c.isLoading&&e.jsx("p",{role:"status",children:"Scanning agent folders…"}),c.data&&!o.length&&e.jsx("p",{role:"status",children:"No local agent skill folders found."}),e.jsx("div",{className:"max-h-[55vh] overflow-y-auto space-y-4",children:o.map(g=>{const k=g.skills.filter(m=>m.status==="new");return e.jsxs("section",{"data-testid":"local-agent","data-agent":g.id,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:g.label}),e.jsx("p",{className:"text-xs text-outline",children:g.dir})]}),e.jsxs(b,{size:"sm",variant:"outline","data-testid":"local-agent-select-all",disabled:t||!k.length,onClick:()=>l(g.skills),children:["Select all new (",k.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:g.skills.map(m=>{const N=i.includes(q(m)),r=!N&&s.has(m.name);return e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"local-skill","data-skill-name":m.name,children:[e.jsx("input",{type:"checkbox","data-testid":"local-skill-select",checked:N,disabled:t||m.status!=="new"||r,onChange:d=>f(m,d.target.checked)}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:m.name}),X[m.status]&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:X[m.status]}),e.jsx("span",{className:"block text-xs text-outline",children:m.error??m.description}),m.extra_fields.length>0&&e.jsxs("span",{className:"block text-xs text-outline","data-testid":"local-skill-extra-fields",children:["Extra fields: ",m.extra_fields.join(", ")]}),m.also_in.length>0&&e.jsxs("span",{className:"block text-xs text-outline",children:["Also in ",m.also_in.join(", ")]})]})]},q(m))})})]},g.id)})}),(p=n.data)==null?void 0:p.skipped.map(g=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:["Skipped ",g.name,": ",g.reason]},`${g.agent}/${g.name}`)),(c.error||n.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(w=c.error||n.error)==null?void 0:w.message}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:t,onClick:a,children:"Close"}),e.jsx(b,{"data-testid":"local-skill-import-submit",disabled:t||!i.length,onClick:()=>n.mutate(i.map(g=>{const[k="",m=""]=g.split("/");return{agent:k,name:m}})),children:n.isPending?"Importing…":`Import selected${i.length?` (${i.length})`:""}`})]})]})})}function Se({onClose:a}){var f;const[i,x]=v.useState(""),[h,c]=v.useState([]),n=K(),t=I({mutationFn:S.skills.discover,onSuccess:()=>c([])}),o=I({mutationFn:S.skills.import,onSuccess:async()=>{await n.invalidateQueries({queryKey:["skills"]}),a()}}),s=t.isPending||o.isPending;return e.jsx(E,{open:!0,onOpenChange:l=>!l&&!s&&a(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(A,{children:e.jsx(T,{children:"Import from GitHub"})}),e.jsxs("form",{className:"space-y-4",onSubmit:l=>{l.preventDefault(),t.mutate(i.trim())},children:[e.jsx(P,{htmlFor:"skill-repository",children:"Repository or skills.sh link"}),e.jsx(D,{id:"skill-repository","data-testid":"skill-repository-input",value:i,disabled:s,onChange:l=>{x(l.target.value),t.reset(),o.reset(),c([])},placeholder:"https://github.com/vercel-labs/agent-skills",autoFocus:!0}),e.jsx("p",{className:"text-xs text-outline",children:"GitHub repositories, owner/repo, skill-folder URLs and skills.sh links. Private repositories use gh login on the execution host (local or SSH), or ORC_GITHUB_TOKEN on the ORC server. Supporting files are included."}),e.jsx(b,{type:"submit","data-testid":"skill-discover",disabled:s||!i.trim(),children:t.isPending?"Discovering…":"Discover skills"})]}),t.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-outline",children:[t.data.skills.length," skills found · ",t.data.commit.slice(0,8)]}),!t.data.skills.length&&e.jsx("p",{role:"status",children:"No valid skills found in this source."}),e.jsx("div",{className:"max-h-[45vh] overflow-y-auto space-y-2",children:t.data.skills.map(l=>e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"remote-skill","data-skill-name":l.name,children:[e.jsx("input",{type:"checkbox","data-testid":"remote-skill-select",checked:h.includes(l.path),disabled:s||l.installed||!h.includes(l.path)&&h.length>=16,onChange:y=>c(y.target.checked?[...h,l.path]:h.filter(p=>p!==l.path))}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:l.name}),l.installed&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:"Already installed"}),e.jsx("span",{className:"block text-xs text-outline",children:l.description}),e.jsx("span",{className:"block text-xs text-outline",children:l.path||"Repository root"})]})]},l.path))}),t.data.issues.map(l=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:[l.path,": ",l.error]},l.path))]}),(t.error||o.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(f=t.error||o.error)==null?void 0:f.message}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:s,onClick:a,children:"Cancel"}),e.jsx(b,{"data-testid":"skill-import-submit",disabled:s||!t.data||!h.length,onClick:()=>t.data&&o.mutate({source:i.trim(),commit:t.data.commit,paths:h}),children:o.isPending?"Importing…":`Import selected${h.length?` (${h.length})`:""}`})]})]})})}function we({name:a,scope:i,mutation:x}){var s,f;const h=K(),[c,n]=v.useState(""),t=F({queryKey:["skill-history",a,i],queryFn:()=>S.skills.history(a,i)}),o=I({mutationFn:l=>{if(!x)throw new Error("No active instruction edit");return S.skills.revert(a,{project_id:x.project_id,change_id:l,expected_change_id:x.id,reason:c.trim()})},onSuccess:()=>{h.invalidateQueries({queryKey:["skill"]}),h.invalidateQueries({queryKey:["skills"]}),h.invalidateQueries({queryKey:["skill-history"]}),n("")}});return!((s=t.data)!=null&&s.changes.length)&&!t.error?null:e.jsxs("section",{"data-testid":"skill-history-panel",className:"mb-5 space-y-3",children:[x&&e.jsxs("p",{"data-testid":"skill-mutated-label",className:"text-xs text-primary",children:["Mutated · ",x.project_id?"Project":"Global"," ·"," ",new Date(x.updated_at*1e3).toLocaleString()," · ",x.author]}),e.jsx("h3",{className:"text-sm font-medium",children:"Instruction history"}),e.jsx(D,{"data-testid":"skill-revert-reason","aria-label":"Reason for reverting instructions",value:c,onChange:l=>n(l.target.value),placeholder:"Reason for reverting..."}),t.error&&e.jsx("p",{role:"alert",children:t.error.message}),o.error&&e.jsx("p",{role:"alert",children:o.error.message}),(f=t.data)==null?void 0:f.changes.map(l=>e.jsxs("details",{"data-testid":"skill-history-change",className:"border-b border-outline-variant p-3",children:[e.jsxs("summary",{className:"text-xs cursor-pointer",children:[l.action," · ",l.reason," · ",l.author]}),e.jsx("p",{className:"text-xs text-outline mt-2",children:"Before"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l.previous_raw}),e.jsx("p",{className:"text-xs text-outline mt-2",children:"After"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l.raw}),e.jsx(b,{"data-testid":"skill-revert-change",size:"sm",variant:"outline",disabled:!c.trim()||o.isPending,onClick:()=>o.mutate(l.id),children:"Restore instructions before this change"})]},l.id))]})}function Ce({name:a}){const i=K(),[x,h]=v.useState(!1),c=F({queryKey:["skill-origin",a],queryFn:()=>S.skills.origin(a)}),n=I({mutationFn:s=>S.skills.sync(a,s),onSuccess:async s=>{h(!1),s.applied&&await Promise.all([i.invalidateQueries({queryKey:["skill",a]}),i.invalidateQueries({queryKey:["skills"]}),i.invalidateQueries({queryKey:["skill-origin",a]})])}});if(c.error)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:c.error.message});if(!c.data)return null;const t=n.data,o=t&&!t.applied&&t.conflicts.length>0;return e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Imported from"," ",e.jsx("a",{className:"text-primary underline",href:`https://github.com/${c.data.repository}/tree/${encodeURIComponent(c.data.ref==="HEAD"?c.data.commit:c.data.ref)}/${c.data.path}`,target:"_blank",rel:"noreferrer",children:c.data.repository})," ","· ",c.data.commit.slice(0,8)]}),e.jsx(b,{"data-testid":"skill-sync",variant:"outline",size:"sm",disabled:n.isPending,onClick:()=>n.mutate({}),children:n.isPending?"Syncing…":"Sync from GitHub"}),(t==null?void 0:t.applied)&&e.jsx("p",{role:"status","data-testid":"skill-sync-status",className:"text-xs",children:t.changed.length?`Synced ${t.changed.length} files. Local edits preserved outside confirmed conflicts.`:"Up to date. Local edits preserved."}),o&&e.jsxs("div",{"data-testid":"skill-sync-conflicts",className:"space-y-2",children:[e.jsx("p",{role:"alert",className:"text-sm",children:"Sync paused. Both you and GitHub changed these files:"}),e.jsx("ul",{className:"text-xs space-y-1",children:t.conflicts.map(s=>e.jsx("li",{children:s},s))}),e.jsx(b,{"data-testid":"skill-sync-review-override",variant:"outline",size:"sm",onClick:()=>h(!0),children:"Review override"})]}),n.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n.error.message}),e.jsx(E,{open:x,onOpenChange:s=>!n.isPending&&h(s),children:e.jsxs($,{children:[e.jsx(A,{children:e.jsx(T,{children:"Replace conflicting local edits?"})}),e.jsxs("p",{className:"text-sm",children:["GitHub's version at ",t==null?void 0:t.commit.slice(0,8)," will replace or remove these files. Your other local edits will be kept. The current skill folder will be backed up."]}),e.jsx("ul",{className:"text-sm space-y-1",children:t==null?void 0:t.conflicts.map(s=>e.jsx("li",{children:s},s))}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:n.isPending,onClick:()=>h(!1),children:"Keep local edits"}),e.jsx(b,{"data-testid":"skill-sync-confirm-override",disabled:n.isPending,onClick:()=>t&&n.mutate({override:!0,expectedCommit:t.commit,expectedRevision:t.revision}),children:n.isPending?"Syncing…":"Replace listed files"})]})]})})]})}function Le(a){return F({queryKey:["skills",a],queryFn:()=>S.skills.list(a)})}function Ie(){return F({queryKey:["skill-visibility"],queryFn:()=>S.skills.visibility()})}function Ke(){const a=K();return I({mutationFn:i=>S.skills.setVisibility(i),onSuccess:i=>{a.setQueryData(["skill-visibility"],i),a.invalidateQueries({queryKey:["skills"]})}})}function Z(a,i,x={}){return F({queryKey:["skill",a,i,x],queryFn:()=>S.skills.get(a,i,x),enabled:!!a})}function De(){const a=K();return I({mutationFn:i=>S.skills.create(i),onSuccess:()=>a.invalidateQueries({queryKey:["skills"]})})}const Fe=[{value:"all",label:"All"},{value:"builtin",label:"Built-in"},{value:"user",label:"User"}],se={builtin:"text-muted-foreground",user:"text-muted-foreground"};function Te({projectId:a}){var B,U;const i=ye(a),x=i==="all"||i==="unassigned"?{scope:"global"}:{project_id:i},[h,c]=O("skillQuery",""),[n,t]=v.useState(h),[o,s]=O("source","all",["all","builtin","user"]);v.useEffect(()=>t(h),[h]);const{selectedId:f,openDetail:l,closeDetail:y}=le("/skills","skillName"),[p,w]=v.useState(!1),[g,k]=v.useState(!1),[m,N]=v.useState(!1),r=Ie(),d=Ke(),{data:j,isLoading:C,error:z,refetch:ae}=Le({...x,q:h||void 0,source:o==="all"?void 0:o,include_hidden:!0}),Q=j==null?void 0:j.skills;return z?e.jsx(J,{message:z.message,onRetry:()=>ae()}):e.jsxs("div",{children:[e.jsx(ne,{title:"Skills",meta:`${(Q??[]).length} skills`,action:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(b,{"data-testid":"import-skill-button",size:"sm",variant:"outline",onClick:()=>k(!0),children:[e.jsx(Y,{size:12,className:"mr-1"})," Import from GitHub"]}),e.jsxs(b,{"data-testid":"import-local-skills-button",size:"sm",variant:"outline",onClick:()=>N(!0),children:[e.jsx(Y,{size:12,className:"mr-1"})," Import from agents"]}),e.jsxs(b,{"data-testid":"new-skill-button",size:"sm",onClick:()=>w(!0),className:"font-label text-sm ",children:[e.jsx(re,{size:12,className:"mr-1"})," New skill"]})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["Skill folders follow the"," ",e.jsx("a",{className:"text-primary underline",href:"https://agentskills.io/specification",target:"_blank",rel:"noreferrer",children:"Agent Skills specification"}),"."]}),e.jsx("p",{className:"mb-4 text-sm leading-relaxed text-muted-foreground",children:"Built-in visibility applies to agent discovery across this installation. Hidden skills remain readable by name and available to flows. Authored overrides stay visible."}),(r.error||d.error)&&e.jsx("p",{role:"alert",className:"text-destructive text-xs mb-2",children:(B=r.error||d.error)==null?void 0:B.message}),(U=j==null?void 0:j.broken)==null?void 0:U.map(u=>e.jsxs("p",{role:"alert",className:"text-destructive text-xs mb-2",children:[u.path,": ",u.error]},u.path)),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex shrink-0 flex-wrap gap-1.5",children:Fe.map(u=>e.jsx("button",{type:"button",onClick:()=>s(u.value),"data-testid":`skill-source-${u.value}`,"aria-pressed":o===u.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${o===u.value?"bg-surface-highest text-on-surface border-transparent":"bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:u.label},u.value))}),e.jsxs("div",{className:"relative min-w-[160px] flex-1",children:[e.jsx(oe,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{"aria-label":"Search skills",value:n,onChange:u=>t(u.target.value),onKeyDown:u=>u.key==="Enter"&&c(u.currentTarget.value),placeholder:"Search skills...",className:"pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground"})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>c(n),className:"font-label text-sm ",children:"Search"})]}),C?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((u,L)=>e.jsx(ee,{className:"h-10 w-full bg-surface-highest"},L))}):(Q??[]).length===0?e.jsx(ce,{message:h?"No skills match your search":"No skills found"}):e.jsx("div",{className:"overflow-hidden",children:e.jsxs(de,{children:[e.jsx(ue,{children:e.jsxs(G,{className:"border-b border-outline-variant hover:bg-transparent",children:[e.jsx(R,{className:"font-label text-sm text-muted-foreground",children:"Name"}),e.jsx(R,{className:"font-label text-sm text-muted-foreground",children:"Description"}),e.jsx(R,{className:"font-label text-sm text-muted-foreground w-24",children:"Source"}),e.jsx(R,{className:"text-xs text-muted-foreground",children:"Agent discovery"})]})}),e.jsx(me,{children:(Q??[]).map(u=>e.jsxs(G,{"data-testid":"skill-row","data-skill-name":u.name,className:"border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer",onClick:()=>l(u.name),children:[e.jsxs(_,{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",onClick:L=>{L.stopPropagation(),l(u.name)},children:u.name}),u.mutation&&e.jsx("span",{className:"ml-2 text-primary text-xs",children:"Mutated"})]}),e.jsx(_,{className:"font-body text-sm text-muted-foreground max-w-md truncate",children:u.description||"—"}),e.jsx(_,{children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${se[u.source]}`,children:u.source})}),e.jsx(_,{onClick:L=>L.stopPropagation(),children:u.source==="builtin"&&!u.mutation?e.jsx("button",{type:"button",role:"switch","aria-label":`${u.name} visible to agents`,"aria-checked":!u.discovery_hidden,"data-testid":`skill-visibility-${u.name}`,disabled:!r.data||d.isPending,className:"text-xs text-primary disabled:opacity-50",onClick:()=>{var V;const L=new Set(((V=r.data)==null?void 0:V.hidden_builtins)??[]);L.has(u.name)?L.delete(u.name):L.add(u.name),d.mutate([...L])},children:u.discovery_hidden?"Hidden — show":"Visible — hide"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:u.mutation?"Visible (override)":"Visible"})})]},u.name))})]})}),e.jsx(qe,{scope:x,skillName:f,open:!!f,onClose:y},f),p&&e.jsx(Re,{open:p,onClose:()=>w(!1)}),g&&e.jsx(Se,{onClose:()=>k(!1)}),m&&e.jsx(Ne,{onClose:()=>N(!1)})]})}function qe({skillName:a,scope:i,open:x,onClose:h}){const{data:c,isLoading:n,error:t,refetch:o}=Z(a,void 0,i),s=c,[f,l]=O("skillFile","SKILL.md"),y=Z(a,f??"SKILL.md",i),p=y.data,w=K(),[g,k]=v.useState(!1),m=`skill:${i.project_id??"global"}:${a}:${f??"SKILL.md"}`;function N(d){return(d??"SKILL.md")===(f??"SKILL.md")?!0:W(m)?(l(d??"SKILL.md"),!0):!1}const r=s?e.jsx(ke,{files:["SKILL.md",...(s.files??[]).map(d=>d.name)],selected:f??"SKILL.md",onSelect:d=>N(d==="SKILL.md"?void 0:d),testId:"skill-file",entryTestId:"skill-show-entry"}):null;return e.jsx(xe,{open:x,onOpenChange:d=>!d&&W(m)&&h(),children:e.jsxs(he,{className:"w-screen max-w-full sm:w-[1120px] sm:max-w-[96vw]",children:[e.jsxs(pe,{children:[e.jsx(ge,{children:(s==null?void 0:s.name)??"Skill Details"}),(s==null?void 0:s.description)&&e.jsx("p",{className:"font-body text-sm text-muted-foreground mt-1",children:s.description})]}),e.jsx(fe,{children:e.jsxs(e.Fragment,{children:[a&&s&&e.jsx(we,{name:a,scope:i,mutation:s.mutation}),a&&s&&e.jsx(Ce,{name:a}),t?e.jsx(J,{message:t.message,onRetry:()=>void o()}):n||!s?e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((d,j)=>e.jsx(ee,{className:"h-8 w-full bg-surface-highest"},j))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(M,{label:"Source",children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${se[s.source]}`,children:s.source})}),e.jsx(M,{label:"Path",children:e.jsx("code",{className:"font-mono text-sm text-muted-foreground break-all",children:s.path})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:f??"SKILL.md"}),e.jsxs("div",{className:"overflow-hidden",children:[(p==null?void 0:p.encoding)==="base64"&&e.jsx("div",{className:"p-3",children:r}),y.error?e.jsx("p",{role:"alert",children:y.error.message}):y.isLoading?e.jsx("p",{children:"Loading..."}):(p==null?void 0:p.encoding)==="base64"?e.jsx(te,{path:f??"SKILL.md",value:(p==null?void 0:p.content)??"",readOnly:!0,hidePreview:!0,height:400,testId:"skill-file-content"}):e.jsx(be,{documentId:m,expanded:g,onExpandedChange:k,navigation:r,path:f??"SKILL.md",content:(p==null?void 0:p.content)??"",testId:"skill-file-content",onSave:s.source==="user"&&(p==null?void 0:p.encoding)==="utf8"?async(d,j)=>{const C=f??"SKILL.md";return s.mutation&&C==="SKILL.md"?await S.skills.updateInstructions(s.name,{project_id:i.project_id??null,content:d,expected_content:j,reason:"Manual instruction edit",author:"human"}):await S.skills.editFile(s.name,{path:C,content:d,expectedContent:j}),await w.invalidateQueries({queryKey:["skill",s.name]}),await w.invalidateQueries({queryKey:["skills"]}),await w.invalidateQueries({queryKey:["skill-history",s.name]}),d}:void 0},m),(p==null?void 0:p.encoding)==="base64"&&e.jsx("p",{className:"p-4 text-xs text-muted-foreground",children:"Binary asset shown as base64 (read-only)."})]})]})]})]})})]})})}function Re({open:a,onClose:i}){var N;const[x,h]=v.useState(""),[c,n]=v.useState(""),t=De(),[o,s]=v.useState([]),[f,l]=v.useState(),[y,p]=v.useState(!1),w=!!(x||c||o.length);v.useEffect(()=>{if(!w)return;function r(d){d.preventDefault(),d.returnValue=""}return window.addEventListener("beforeunload",r),()=>window.removeEventListener("beforeunload",r)},[w]);function g(){t.isPending||y||(!w||window.confirm("Discard this unsaved skill?"))&&i()}async function k(r){if(r!=null&&r.length){p(!0),l(void 0);try{const d=(await ve(r)).map(C=>({...C,encoding:C.encoding??"utf8",id:crypto.randomUUID()})),j=d.find(C=>C.path==="SKILL.md");if(!j)throw new Error("Choose a skill folder containing SKILL.md");if(j.encoding!=="utf8")throw new Error("SKILL.md must be UTF-8 text");n(j.content),h(r[0].webkitRelativePath.split("/")[0]),s(d.filter(C=>C!==j))}catch(d){l(d.message)}finally{p(!1)}}}const m=()=>{!x.trim()||!c.trim()||t.isPending||y||o.some(r=>!r.path.trim())||t.mutate({name:x.trim(),content:c.trim(),files:o.map(({path:r,content:d,encoding:j})=>({path:r,content:d,encoding:j}))},{onSuccess:i})};return e.jsx(E,{open:a,onOpenChange:r=>!r&&g(),children:e.jsxs($,{className:"bg-surface border-outline-variant w-[calc(100%_-_1rem)] max-w-5xl max-h-[94dvh] overflow-y-auto",children:[e.jsx(A,{children:e.jsx(T,{className:"font-headline text-base text-on-surface",children:"New skill"})}),e.jsxs("form",{onSubmit:r=>{r.preventDefault(),m()},className:"space-y-3 mt-2",children:[e.jsx(P,{htmlFor:"skill-folder-input",children:"Import skill folder"}),e.jsx(D,{id:"skill-folder-input","data-testid":"skill-folder-input",type:"file",multiple:!0,webkitdirectory:"",onChange:r=>void k(r.target.files)}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{className:"font-label text-sm text-muted-foreground",children:"Name *"}),e.jsx(D,{"aria-label":"Name","data-testid":"skill-name-input",value:x,onChange:r=>h(r.target.value),placeholder:"my-skill",className:"bg-background 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:"SKILL.md *"}),e.jsx(je,{testId:"skill-content-input",path:"SKILL.md",value:c,onChange:n,onSave:m})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{"data-testid":"skill-add-file",type:"button",variant:"outline",onClick:()=>s([...o,{id:crypto.randomUUID(),path:"",content:"",encoding:"utf8"}]),children:"Add file"}),o.map(r=>e.jsxs("div",{"data-testid":"skill-supporting-file",className:"space-y-2 border border-outline-variant p-3",children:[e.jsx(D,{"data-testid":"skill-file-path-input","aria-label":"File path",placeholder:"references/guide.md or scripts/check.py",value:r.path,onChange:d=>s(o.map(j=>j.id===r.id?{...j,path:d.target.value}:j))}),e.jsx(te,{testId:"skill-file-content-input",path:r.path||"supporting.txt",readOnly:r.encoding==="base64",label:`Content of ${r.path||"supporting file"}`,value:r.content,height:180,onChange:d=>s(o.map(j=>j.id===r.id?{...j,content:d}:j))}),r.encoding==="base64"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Binary asset (base64)"}),e.jsx(b,{type:"button",variant:"ghost",onClick:()=>s(o.filter(d=>d.id!==r.id)),children:"Remove file"})]},r.id))]}),(f||t.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f??((N=t.error)==null?void 0:N.message)}),e.jsxs(H,{children:[e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:g,className:"font-label text-sm text-muted-foreground",children:"Cancel"}),e.jsx(b,{"data-testid":"skill-submit",type:"submit",size:"sm",disabled:y||t.isPending||!x.trim()||!c.trim()||o.some(r=>!r.path.trim()),className:"font-label text-sm ",children:t.isPending?"Creating...":"Create"})]})]})]})})}export{Te as default};