@runfusion/fusion 0.55.0 → 0.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +5829 -1357
- package/dist/client/.vite/manifest.json +322 -322
- package/dist/client/assets/{AgentDetailView-B_VfFSlt.js → AgentDetailView-BICsleMh.js} +1 -1
- package/dist/client/assets/{AgentPermissionPolicyEditor-QZhz41AU.js → AgentPermissionPolicyEditor-DQDzCWq_.js} +2 -2
- package/dist/client/assets/{AgentsView-hkhJ8SUq.js → AgentsView-DRpFG7gE.js} +6 -6
- package/dist/client/assets/ChatView-5vVkIiNh.js +6 -0
- package/dist/client/assets/{CommandCenter-B3fAajUO.js → CommandCenter-CZ856YOj.js} +1 -1
- package/dist/client/assets/{DevServerView-BR0ngFBw.js → DevServerView-BqsnMChS.js} +1 -1
- package/dist/client/assets/DirectoryPicker-cW1rnVoG.js +1 -0
- package/dist/client/assets/{DocumentsView-BnRvIUpa.js → DocumentsView-C6a5tuBQ.js} +1 -1
- package/dist/client/assets/{EvalsView-Bvx18QyC.js → EvalsView-DZd_TM3I.js} +1 -1
- package/dist/client/assets/{ExperimentalAgentOnboardingModal-CKGJcfXI.js → ExperimentalAgentOnboardingModal-cA-aWWsB.js} +1 -1
- package/dist/client/assets/{GoalsView-Bj1yVIiv.js → GoalsView-Bzvw1aDV.js} +1 -1
- package/dist/client/assets/{InsightsView-DBX8DI60.js → InsightsView-B3WQIXKs.js} +2 -2
- package/dist/client/assets/{MemoryView-CqkRH2fa.js → MemoryView-BZ2KwFO5.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-BMMmGWe2.js → PiExtensionsManager-D5x6GZOP.js} +2 -2
- package/dist/client/assets/{PluginManager-C1bdfN2W.js → PluginManager-YfHRH24B.js} +1 -1
- package/dist/client/assets/{PullRequestView-D0CsXWLl.js → PullRequestView-DX3J4hgm.js} +1 -1
- package/dist/client/assets/{ResearchView-CVgmXAlj.js → ResearchView-MZV2S2kT.js} +1 -1
- package/dist/client/assets/{SecretsView-Bv_gw5Ix.js → SecretsView--R3u3G4b.js} +1 -1
- package/dist/client/assets/SessionTerminal-BQWc1_Ty.js +2 -0
- package/dist/client/assets/SettingsModal-CNYosRF3.js +21 -0
- package/dist/client/assets/{SettingsModal-D7YgojbV.js → SettingsModal-Coqvlmud.js} +1 -1
- package/dist/client/assets/SettingsModal-D8AyVDar.css +1 -0
- package/dist/client/assets/SetupWizardModal-CoReXugb.js +2 -0
- package/dist/client/assets/{ShadcnColorPicker-DM2fqGwl.js → ShadcnColorPicker-D-u_ECbM.js} +1 -1
- package/dist/client/assets/{SkillsView-Bb-JTo99.js → SkillsView-D21ils_G.js} +1 -1
- package/dist/client/assets/TodoView-BFZQSkv4.js +6 -0
- package/dist/client/assets/WorkflowNodeEditor-E-7d5R9z.js +8 -0
- package/dist/client/assets/{agentSkills-DGFyuKuP.js → agentSkills-CM_yYVTx.js} +1 -1
- package/dist/client/assets/app-0jcSCRQr.js +13 -0
- package/dist/client/assets/app-BPzPEE6G.js +13 -0
- package/dist/client/assets/app-BSZU5Uns.js +13 -0
- package/dist/client/assets/app-CEtD1B9K.js +13 -0
- package/dist/client/assets/app-CVyRSEUX.js +13 -0
- package/dist/client/assets/app-DoLz_4Dg.js +13 -0
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-DP7vOyXY.js → architectureDiagram-3BPJPVTR-DhgVYwmg.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-Di9v1pV8.js → blockDiagram-GPEHLZMM-AlG0kVWu.js} +1 -1
- package/dist/client/assets/{c4Diagram-AAUBKEIU-Dvb8RSfr.js → c4Diagram-AAUBKEIU-BOzpW3F7.js} +1 -1
- package/dist/client/assets/channel-DHSVrpL1.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-gLcAuGjI.js → chunk-2J33WTMH-BAmZfsv0.js} +1 -1
- package/dist/client/assets/{chunk-4BX2VUAB-B-B0wjkx.js → chunk-4BX2VUAB-Cs587QhG.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-XUDeC0Co.js → chunk-55IACEB6-qpIQSO06.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-1eebiGA2.js → chunk-727SXJPM-DF3vZtMc.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-D9VOB5QS.js → chunk-AQP2D5EJ-BuETIys5.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-EFNFEaAz.js → chunk-FMBD7UC4-B8D1TSR9.js} +1 -1
- package/dist/client/assets/{chunk-ND2GUHAM-CbeQailD.js → chunk-ND2GUHAM-BJv9aIQn.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-D55N6EBz.js → chunk-QZHKN3VN-BJbK2pNR.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-CTu3cN1i.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CTu3cN1i.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-B0zbhkX3.js → cose-bilkent-S5V4N54A-BWRikddb.js} +1 -1
- package/dist/client/assets/{dagre-BM42HDAG-BL6peXwl.js → dagre-BM42HDAG-DpAxJj7T.js} +1 -1
- package/dist/client/assets/{dashboard-view-Db3n_W85.js → dashboard-view-Dw8L8k-2.js} +1 -1
- package/dist/client/assets/{dashboard-view-CS1H5SQN.js → dashboard-view-qq3ayA0B.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-cYKwSHk7.js → diagram-2AECGRRQ-DRRIILsg.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-DHIwTGuM.js → diagram-5GNKFQAL-DSOu28ss.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-DfHBJ4aX.js → diagram-KO2AKTUF-CWzbnTBM.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-pWhYmB6Z.js → diagram-LMA3HP47-CGqf3bt6.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-GzWqbi_m.js → diagram-OG6HWLK6-C1axXteT.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-CCVm5eiR.js → erDiagram-TEJ5UH35-bBdlc4OY.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-CUTdnU6S.js → flowDiagram-I6XJVG4X-BTCJ2J3b.js} +1 -1
- package/dist/client/assets/{folder-open-DOCy9GVC.js → folder-open-BN3_NdbL.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-CW4ENJaC.js → ganttDiagram-6RSMTGT7-CiFY9oBj.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-QXXMfSzp.js → gitGraphDiagram-PVQCEYII-CxubcP4l.js} +1 -1
- package/dist/client/assets/index-CbmH1ED8.css +1 -0
- package/dist/client/assets/index-rfsTNfpA.js +2511 -0
- package/dist/client/assets/{infoDiagram-5YYISTIA-CZyHbj0n.js → infoDiagram-5YYISTIA-ToDlIyOV.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Dea84lqZ.js → ishikawaDiagram-YF4QCWOH-BgO681xo.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-Db2iKGU5.js → journeyDiagram-JHISSGLW-OJZ3op9w.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-CB9loIqR.js → kanban-definition-UN3LZRKU-q2OOqX8K.js} +1 -1
- package/dist/client/assets/{mermaid.core-CoQ8aCb0.js → mermaid.core-BmDOYmFS.js} +4 -4
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-JPb2wF-K.js → mindmap-definition-RKZ34NQL-Dw8JehwG.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-pdZzOreP.js → pieDiagram-4H26LBE5-D5Li6GnX.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-Dh9Ids90.js → quadrantDiagram-W4KKPZXB-B4s-2jdZ.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-BVPOSvHU.js → requirementDiagram-4Y6WPE33-Drc3rc_E.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BqSMUpsx.js → sankeyDiagram-5OEKKPKP-C_R01GQC.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-B8nepQ6X.js → sequenceDiagram-3UESZ5HK-gyl7Yhgc.js} +1 -1
- package/dist/client/assets/{shield-alert-CtSaIQNY.js → shield-alert-DjhYmFaV.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-CQv9RdRp.js → stateDiagram-AJRCARHV-BY53czZh.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-C53cIaWg.js +1 -0
- package/dist/client/assets/{timeline-definition-PNZ67QCA-CAjwM-Z5.js → timeline-definition-PNZ67QCA-BYwv2FZJ.js} +1 -1
- package/dist/client/assets/{upload-0_pT1euA.js → upload-BKpOp-Bn.js} +1 -1
- package/dist/client/assets/{users--1B6mnm8.js → users-BUMHTZuX.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-BO3Um3rH.js → vennDiagram-CIIHVFJN-Dt94bP0k.js} +1 -1
- package/dist/client/assets/{wardley-L42UT6IY-BzqJcqDA.js → wardley-L42UT6IY-536kdB5p.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-Bctxc6_5.js → wardleyDiagram-YWT4CUSO-D8iNQ_MW.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-CgDuiMFR.js → xychartDiagram-2RQKCTM6-CXqp8mzh.js} +1 -1
- package/dist/client/index.html +3 -3
- package/dist/client/version.json +1 -1
- package/dist/droid-cli/package.json +1 -1
- package/dist/extension.js +4678 -917
- package/dist/pi-claude-cli/package.json +1 -1
- package/dist/plugin-sdk/index.d.ts +47 -3
- package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
- package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
- package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
- package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-reports/package.json +1 -1
- package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
- package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ChatView-B4WnXLYA.js +0 -6
- package/dist/client/assets/DirectoryPicker-BiS41Hca.js +0 -1
- package/dist/client/assets/SessionTerminal-VLdVV3Ji.js +0 -2
- package/dist/client/assets/SettingsModal-4t8rV7rh.css +0 -1
- package/dist/client/assets/SettingsModal-gcrh5EOG.js +0 -21
- package/dist/client/assets/SetupWizardModal-DvmTlFP_.js +0 -2
- package/dist/client/assets/TodoView-bV-7deOh.js +0 -6
- package/dist/client/assets/WorkflowNodeEditor-Ui1q_fFI.js +0 -8
- package/dist/client/assets/app--OM-ul6R.js +0 -13
- package/dist/client/assets/app-BCvqf8qq.js +0 -13
- package/dist/client/assets/app-BZqqEiWR.js +0 -13
- package/dist/client/assets/app-DQeH1UDD.js +0 -13
- package/dist/client/assets/app-FiYwRatp.js +0 -13
- package/dist/client/assets/app-rGdYcsAA.js +0 -13
- package/dist/client/assets/channel-C5g9M3Sk.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-B-wdlvD6.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-B-wdlvD6.js +0 -1
- package/dist/client/assets/index-B6ttSchA.js +0 -1336
- package/dist/client/assets/index-CPE2Kwra.css +0 -1
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BZ_mlvie.js +0 -1
package/dist/client/assets/{PiExtensionsManager-BMMmGWe2.js → PiExtensionsManager-D5x6GZOP.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as H,
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as H,by as Y,bz as Z,bA as T,R as L,an as D,ap as y,P as ee,o as se,C as ae,J as ie,aL as B,bB as ne,bC as te,bD as _,X as re}from"./index-rfsTNfpA.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{B as $}from"./AgentPermissionPolicyEditor-DQDzCWq_.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as H,bw as Y,bx a
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const oe=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],G=H("puzzle",oe);function de(n){return n.replace(/-/g,"-")}function pe(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function xe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function ge(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,I]=l.useState(null),[N,P]=l.useState(!0),[b,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[J,O]=l.useState(new Set),[m,W]=l.useState([]),[v,R]=l.useState(!0),[q,C]=l.useState(!1),o=l.useCallback(async()=>{try{P(!0);const s=await Y();I(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{P(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await Z(x);W(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),K=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const U=s=>{O(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},X=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Q=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await _({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},V=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await _({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>V(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(B,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:b}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:b||!h.trim(),children:[e.jsx(ee,{size:14}),b?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:X,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=xe(i),f=ge(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=J.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>U(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Q(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(G,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx($,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(D,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),G,"extensions"),u(a("piManager.sectionSkills","Skills"),$,"skills"),u(a("piManager.sectionPrompts","Prompts"),D,"prompts"),u(a("piManager.sectionThemes","Themes"),A,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:v,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:v?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),v?e.jsx("div",{className:"loading-state",children:e.jsx(B,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${de(s.source)}`,children:pe(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void K(s),disabled:q,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};
|
|
11
|
+
*/const oe=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],G=H("puzzle",oe);function de(n){return n.replace(/-/g,"-")}function pe(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function xe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function ge(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,I]=l.useState(null),[N,P]=l.useState(!0),[b,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[O,W]=l.useState(new Set),[m,q]=l.useState([]),[v,C]=l.useState(!0),[J,R]=l.useState(!1),o=l.useCallback(async()=>{try{P(!0);const s=await Y();I(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{P(!1)}},[n,a]),g=l.useCallback(async()=>{try{C(!0);const s=await Z(x);q(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{C(!1)}},[n,x,a]),K=l.useCallback(async s=>{try{R(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{R(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const U=s=>{W(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},X=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Q=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await _({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},V=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await _({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>V(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:b}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:b||!h.trim(),children:[e.jsx(ee,{size:14}),b?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:X,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=xe(i),f=ge(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=O.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>U(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Q(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(G,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx($,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),G,"extensions"),u(a("piManager.sectionSkills","Skills"),$,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),A,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:v,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:v?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),v?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${de(s.source)}`,children:pe(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void K(s),disabled:J,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e}from"./vendor-react-SZ_qB27O.js";import{ae as Me,af as Ue,ag as $e,ah as ce,ai as qe,X as ge,aj as Ve,ak as Te,al as de,P as pe,am as me,J as he,R as be,an as We,a3 as Ke,ao as Qe,ap as Je,aq as Ye,ar as Xe,as as Ze,at as es,au as ss,av as O,aw as ns,ax as is}from"./index-B6ttSchA.js";import{D as ts}from"./DirectoryPicker-BiS41Hca.js";import{u as as}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";import"./folder-open-DOCy9GVC.js";const Ne="fusion-plugin-agent-browser",ye={enabled:{type:"boolean",label:"Enable Agent Browser",group:"General"},installChannel:{type:"enum",label:"Install Channel",enumValues:["stable","beta","nightly"],defaultValue:"stable",group:"General"},commandTimeoutMs:{type:"number",label:"Command Timeout (ms)",defaultValue:12e4,group:"General"},headlessMode:{type:"boolean",label:"Headless Mode",defaultValue:!0,group:"Browser"},allowedDomains:{type:"array",label:"Allowed Domains",itemType:"string",group:"Browser"},promptExecutorSystem:{type:"string",label:"Executor System Prompt",multiline:!0,group:"Prompt Contributions"},promptExecutorTask:{type:"string",label:"Executor Task Prompt",multiline:!0,group:"Prompt Contributions"},promptTriage:{type:"string",label:"Triage Prompt",multiline:!0,group:"Prompt Contributions"},promptReviewer:{type:"string",label:"Reviewer Prompt",multiline:!0,group:"Prompt Contributions"},promptHeartbeat:{type:"string",label:"Heartbeat Prompt",multiline:!0,group:"Prompt Contributions"},skillExposure:{type:"enum",label:"Skill Exposure",enumValues:["none","selected","all"],defaultValue:"selected",group:"Skills"}},xe={General:"plugins.agentBrowser.groupGeneral",Browser:"plugins.agentBrowser.groupBrowser","Prompt Contributions":"plugins.agentBrowser.groupPromptContributions",Skills:"plugins.agentBrowser.groupSkills"},fe={"Enable Agent Browser":"plugins.agentBrowser.labelEnabled","Install Channel":"plugins.agentBrowser.labelInstallChannel","Command Timeout (ms)":"plugins.agentBrowser.labelCommandTimeoutMs","Headless Mode":"plugins.agentBrowser.labelHeadlessMode","Allowed Domains":"plugins.agentBrowser.labelAllowedDomains","Executor System Prompt":"plugins.agentBrowser.labelPromptExecutorSystem","Executor Task Prompt":"plugins.agentBrowser.labelPromptExecutorTask","Triage Prompt":"plugins.agentBrowser.labelPromptTriage","Reviewer Prompt":"plugins.agentBrowser.labelPromptReviewer","Heartbeat Prompt":"plugins.agentBrowser.labelPromptHeartbeat","Skill Exposure":"plugins.agentBrowser.labelSkillExposure"},je=[{id:"fusion-plugin-hermes-runtime",name:"Hermes Runtime",description:"Runtime provider for Hermes CLI-backed execution.",category:"runtime",path:"./plugins/fusion-plugin-hermes-runtime",experimental:!0},{id:"fusion-plugin-paperclip-runtime",name:"Paperclip Runtime",description:"Runtime provider for Paperclip agent connections.",category:"runtime",path:"./plugins/fusion-plugin-paperclip-runtime"},{id:"fusion-plugin-openclaw-runtime",name:"OpenClaw Runtime",description:"Runtime provider for OpenClaw execution.",category:"runtime",path:"./plugins/fusion-plugin-openclaw-runtime",experimental:!0},{id:"fusion-plugin-droid-runtime",name:"Droid Runtime",description:"Runtime provider for Droid CLI execution.",category:"runtime",path:"./plugins/fusion-plugin-droid-runtime",experimental:!0},{id:"fusion-plugin-dependency-graph",name:"Dependency Graph",description:"Dashboard plugin for task dependency graph visualization.",category:"integration",path:"./plugins/fusion-plugin-dependency-graph"},{id:"fusion-plugin-reports",name:"Reports",description:"View report history, compare runs side-by-side, and export standalone HTML summaries.",category:"integration",path:"./plugins/fusion-plugin-reports"},{id:"fusion-plugin-whatsapp-chat",name:"WhatsApp Chat",description:"Pairs to WhatsApp Web (multi-device) with QR or pairing code, then bridges direct chats to a Fusion agent.",category:"integration",path:"./plugins/fusion-plugin-whatsapp-chat"},{id:"fusion-plugin-cli-printing-press",name:"CLI Printing Press",description:"Guided wizard for drafting external service CLI definitions.",category:"integration",path:"./plugins/fusion-plugin-cli-printing-press"},{id:"fusion-plugin-compound-engineering",name:"Compound Engineering",description:"A dedicated dashboard surface for compound-engineering artifacts and interactive ce-* sessions.",category:"integration",path:"./plugins/fusion-plugin-compound-engineering"},{id:"fusion-plugin-linear-import",name:"Linear Import",description:"Browse Linear issues and import selected issues as Fusion triage tasks through plugin-owned settings.",category:"integration",path:"./plugins/fusion-plugin-linear-import"},{id:Ne,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],F={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function ls(r){const o=r.settingsSchema,n=o&&Object.keys(o).length>0;return r.id!==Ne?n?o:void 0:n?{...ye,...o}:ye}function rs(r){const o=new Map,n=[];for(const[j,y]of Object.entries(r))if(y.group){const v=o.get(y.group)??[];v.push([j,y]),o.set(y.group,v)}else n.push([j,y]);return{grouped:o,ungrouped:n}}function Se(r,o="plugin-error-text"){return r.state!=="error"||!r.error?null:e.jsx("p",{className:o,title:r.error,children:r.error})}function ys({addToast:r,projectId:o}){const{t:n}=as("app"),[j,y]=d.useState([]),[v,z]=d.useState(!0),[ve,L]=d.useState(!1),[E,A]=d.useState(""),[_,H]=d.useState(!1),[M,U]=d.useState(!1),[w,$]=d.useState(null),[c,G]=d.useState(null),[m,x]=d.useState({}),[we,q]=d.useState(!1),[V,T]=d.useState(null),[W,Pe]=d.useState([]),[Ce,K]=d.useState(!0),[Q,J]=d.useState(null),[b,Re]=d.useState(""),[f,Ie]=d.useState(""),[Ee,Y]=d.useState(null),P=d.useRef(null),[Be,D]=d.useState({}),[ke,X]=d.useState(null),[B,Z]=d.useState(null),{confirm:Fe}=Me(),h=d.useCallback(async()=>{try{z(!0);const s=await Ue(o);y(s)}catch(s){r(n("plugins.loadFailed","Failed to load plugins: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{z(!1)}},[o,r]),S=d.useCallback(async(s=b,i=f)=>{try{K(!0),J(null);const l=await $e(s,i||void 0,o);Pe(l)}catch(l){const u=l instanceof Error?l.message:String(l);J(u)}finally{K(!1)}},[o,f,b]);d.useEffect(()=>{h()},[h]),d.useEffect(()=>(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{S(b,f)},300),()=>{P.current&&clearTimeout(P.current)}),[S,f,b]),d.useEffect(()=>{const s=je.filter(l=>l.hasSetup&&j.some(u=>u.id===l.id));if(s.length===0)return;let i=!1;return Promise.all(s.map(async l=>{try{const u=await ce(l.id,o);if(i)return;D(g=>({...g,[l.id]:u}))}catch{if(i)return;D(u=>({...u,[l.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{i=!0}},[j,o]);const Le=d.useRef([]);Le.current=j,d.useEffect(()=>{const s=o?`?projectId=${encodeURIComponent(o)}`:"",i=l=>{try{const u=JSON.parse(l.data);if(u.scope==="project"&&(u.projectId??o)!==o)return;switch(u.transition){case"installing":case"enabled":case"disabled":case"settings-updated":S(b,f),y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],enabled:u.enabled,state:u.state,settings:u.settings,error:u.error},t}else return h(),g});break;case"state-changed":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break;case"uninstalled":y(g=>g.filter(a=>a.id!==u.pluginId)),S(b,f);break;case"error":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break}}catch{}};return qe(`/api/events${s}`,{events:{"plugin:lifecycle":i},onReconnect:()=>{h(),S(b,f)}})},[o,h,S,f,b]);const ee=async()=>{if(!E.trim()){r(n("plugins.installPathRequired","Please enter a plugin path"),"error");return}try{H(!0),await O({path:E,...M?{aiScanOnLoad:!0}:{}},o),r(n("plugins.installedGlobally","Plugin installed globally"),"success"),L(!1),A(""),U(!1),await h()}catch(s){r(n("plugins.installFailed","Failed to install plugin: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{H(!1)}},Ae=async s=>{if(!s.path){r(n("plugins.builtinNoPackage","{{name}} is built in and does not have an installable package yet",{name:s.name}),"warning");return}try{T(s.id),await O({path:s.path},o),r(n("plugins.builtinInstalledGlobally","{{name}} installed globally",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.builtinInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{T(null)}},Ge=async s=>{if(!s.path){r(n("plugins.registryNotInstallable","{{name}} is not available for one-click install yet",{name:s.name}),"warning");return}try{Y(s.id),await O({path:s.path},o),r(n("plugins.registryInstalled","{{name}} installed and enabled",{name:s.name}),"success"),await h(),await S(b,f)}catch(i){r(n("plugins.registryInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Y(null)}},se=async s=>{try{Z(s.id);const i=await is(s.id,o);if(!i.success){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error");return}r(n("plugins.setupInstalled","{{name}} setup installed",{name:s.name}),"success"),X(s.id);const l=await ce(s.id,o);D(u=>({...u,[s.id]:l}))}catch(i){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Z(null),X(null)}},ne=async s=>{try{const i=await es(s.id,o);if(i.state==="error"){r(n("plugins.enableFailed","Failed to enable {{name}}: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error"),await h();return}r(n("plugins.enabledForProject","{{name}} enabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.enablePluginFailed","Failed to enable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},ie=async s=>{try{await Ze(s.id,o),r(n("plugins.disabledForProject","{{name}} disabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.disablePluginFailed","Failed to disable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},te=async s=>{try{$(s.id),await Xe(s.id,o),r(n("plugins.reloaded","{{name}} reloaded",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.reloadFailed","Failed to reload plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}finally{$(null)}},ae=async s=>{if(await Fe({title:n("plugins.uninstallTitle","Uninstall Plugin Globally"),message:n("plugins.uninstallConfirm",'Are you sure you want to uninstall "{{name}}" globally (all projects)?',{name:s.name}),danger:!0}))try{await ss(s.id,o),r(n("plugins.uninstalledGlobally","{{name}} uninstalled globally",{name:s.name}),"success"),await h(),G(null)}catch(l){r(n("plugins.uninstallFailed","Failed to uninstall plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},De=async(s,i)=>{try{await Qe(s.id,{aiScanOnLoad:i},o),r(i?n("plugins.aiScanEnabled","AI scan on load enabled"):n("plugins.aiScanDisabled","AI scan on load disabled"),"success"),await h()}catch(l){r(n("plugins.updateFailed","Failed to update plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},Oe=async s=>{try{await Je(s.id,o),r(n("plugins.rescanned","{{name}} rescanned",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.rescanFailed","Failed to rescan plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},k=async s=>{G(s);try{q(!0);const i=await ns(s.id,o);x(i)}catch{x({})}finally{q(!1)}},ze=async()=>{if(c)try{await Ye(c.id,m,o),r(n("plugins.settingsSaved","Settings saved"),"success")}catch(s){r(n("plugins.saveSettingsFailed","Failed to save settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}};if(c)return e.jsxs("div",{className:"plugin-manager-detail","data-testid":"plugin-manager-detail",children:[e.jsxs("div",{className:"plugin-manager-detail-header",children:[e.jsx("button",{className:"btn-icon",onClick:()=>G(null),"aria-label":n("plugins.backToList","Back to plugin list"),children:e.jsx(ge,{size:16})}),e.jsxs("div",{className:"plugin-detail-title",children:[e.jsxs("div",{className:"plugin-detail-title-copy",children:[e.jsx("h4",{className:"plugin-detail-name",children:c.name}),Se(c,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:F[c.state]||F.installed},children:c.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[c.description&&e.jsx("p",{className:"plugin-description",children:c.description}),c.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.author","Author:")}),c.author]}),c.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:n("plugins.homepage","Homepage:")}),e.jsxs("a",{href:c.homepage,target:"_blank",rel:"noopener noreferrer",children:[c.homepage,e.jsx(Ve,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.version","Version:")}),c.version]})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.securityScan","Security Scan")}),e.jsxs("div",{className:"plugin-security-row",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:!!c.aiScanOnLoad,onChange:s=>void De(c,s.target.checked)}),n("plugins.enableAiScanBeforeLoad","Enable AI scan before load/reload")]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void Oe(c),children:[e.jsx(Te,{size:14})," ",n("plugins.rescanAndReload","Rescan and Reload")]})]}),e.jsx("p",{className:"text-muted",children:n("plugins.aiScanHint","Turning this on only updates configuration. Use Rescan and Reload to run it now.")}),c.lastSecurityScan?e.jsxs("div",{className:"plugin-security-results",children:[e.jsxs("div",{className:"plugin-security-header",children:[e.jsx("span",{className:`plugin-state-badge plugin-security-badge plugin-security-badge--${c.lastSecurityScan.verdict}`,children:c.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:c.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:c.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsx("summary",{children:n("plugins.findings","Findings ({{count}})",{count:c.lastSecurityScan.findings.length})}),e.jsx("ul",{className:"plugin-security-findings",children:c.lastSecurityScan.findings.map((s,i)=>e.jsxs("li",{children:[e.jsx("strong",{children:s.severity})," ",s.category," — ",s.file,": ",s.reason]},`${s.file}-${i}`))})]})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noSecurityScan","No security scan has been run yet.")})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.settings","Settings")}),we?e.jsx("p",{className:"text-muted",children:e.jsx(de,{label:n("plugins.loading","Loading...")})}):(()=>{const s=ls(c);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:i,ungrouped:l}=rs(s),u=[];l.length>0&&u.push({title:null,entries:l});for(const[g,a]of i.entries())u.push({title:g,entries:a});return u.map(g=>e.jsxs("div",{className:g.title?"plugin-settings-group":void 0,children:[g.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:xe[g.title]?n(xe[g.title],g.title):g.title}),g.entries.map(([a,t])=>{const N=`setting-${a}-help`,C=t.label?fe[t.label]?n(fe[t.label],t.label):t.label:a;return e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:`setting-${a}`,children:[C,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${a}`,rows:4,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:Number(p.target.value)}),"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m[a]??!1,onChange:p=>x({...m,[a]:p.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),"aria-describedby":t.description&&!t.required?N:void 0,children:[e.jsx("option",{value:"",children:n("plugins.selectOption","Select...")}),t.enumValues?.map(p=>e.jsx("option",{value:p,children:p},p))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[m[a]?.map((p,R)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:p??"",onChange:ue=>{const I=ue.target.value,oe=[...m[a]||[]];oe[R]=t.itemType==="number"?Number(I):I,x({...m,[a]:oe})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const I=[...m[a]||[]];I.splice(R,1),x({...m,[a]:I})},"aria-label":n("plugins.removeItem","Remove item"),children:e.jsx(ge,{size:14})})]},R)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const p=m[a]||[],R=t.itemType==="number"?0:"";x({...m,[a]:[...p,R]})},children:[e.jsx(pe,{size:14})," ",n("plugins.addItem","Add Item")]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:N,className:"form-help",children:t.description})]},a)})]},g.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:ze,children:n("plugins.saveSettings","Save Settings")})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noConfigurableSettings","No configurable settings.")})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[c.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>te(c),disabled:w===c.id,children:[e.jsx(me,{size:14,className:w===c.id?"spin":""}),w===c.id?n("plugins.reloading","Reloading..."):n("plugins.reload","Reload")]}),c.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>ie(c),children:n("plugins.disableInProject","Disable in Project")}):e.jsx("button",{className:"btn btn-primary",onClick:()=>ne(c),children:n("plugins.enableInProject","Enable in Project")}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>ae(c),children:[e.jsx(he,{size:14})," ",n("plugins.uninstallGlobally","Uninstall Globally")]})]})]})]});const le=new Map(j.map(s=>[s.id,s])),re=j,_e=()=>e.jsxs("section",{className:"plugin-registry-section","aria-label":n("plugins.browseRegistry","Browse Registry"),children:[e.jsxs("div",{className:"plugin-registry-header",children:[e.jsxs("div",{className:"plugin-registry-heading-copy",children:[e.jsx("h4",{className:"plugin-registry-heading",children:n("plugins.browseRegistry","Browse Registry")}),e.jsx("p",{className:"plugin-registry-description",children:n("plugins.registryDescription","Discover curated runtimes and integrations that can be added to this Fusion workspace.")})]}),e.jsxs("div",{className:"plugin-registry-controls",children:[e.jsxs("label",{className:"plugin-registry-category-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.registryCategory","Registry category")}),e.jsxs("select",{className:"select plugin-registry-category-select",value:f,onChange:s=>Ie(s.target.value),"aria-label":n("plugins.registryCategory","Registry category"),children:[e.jsx("option",{value:"",children:n("plugins.registryCategoryAll","All Categories")}),e.jsx("option",{value:"runtime",children:n("plugins.registryCategoryRuntime","Runtime")}),e.jsx("option",{value:"integration",children:n("plugins.registryCategoryIntegration","Integration")})]})]}),e.jsxs("label",{className:"plugin-registry-search-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.searchRegistry","Search registry")}),e.jsx("input",{className:"input plugin-registry-search-input",type:"search",value:b,onChange:s=>Re(s.target.value),placeholder:n("plugins.searchRegistryPlaceholder","Search registry plugins")})]})]})]}),Ce?e.jsxs("div",{className:"plugin-registry-state",role:"status",children:[e.jsx(be,{size:14,className:"spin"}),n("plugins.registryLoading","Loading registry...")]}):Q?e.jsxs("div",{className:"plugin-registry-state plugin-registry-state--error",role:"alert",children:[e.jsx("span",{children:n("plugins.registryLoadFailed","Failed to load registry: {{error}}",{error:Q})}),e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-retry",onClick:()=>void S(b,f),children:n("plugins.retry","Retry")})]}):W.length===0?e.jsx("div",{className:"plugin-registry-state",children:b.trim()?n("plugins.registryEmptySearch","No registry plugins match your search."):n("plugins.registryEmpty","No registry plugins are available.")}):e.jsx("div",{className:"plugin-registry-list","aria-label":n("plugins.registryPluginResults","Registry plugin results"),children:W.map(s=>{const i=le.get(s.id),l=Ee===s.id;return e.jsxs("div",{className:"plugin-registry-item",children:[e.jsxs("div",{className:"plugin-registry-meta",children:[e.jsxs("div",{className:"plugin-registry-title-row",children:[e.jsx("span",{className:"plugin-registry-name",children:s.name}),e.jsxs("span",{className:"plugin-registry-version",children:["v",s.version]}),e.jsx("span",{className:"plugin-registry-badge",children:s.category}),s.installed&&e.jsxs("span",{className:"plugin-registry-status plugin-registry-status--installed",children:[n("plugins.statusInstalled","Installed"),s.installedVersion&&s.installedVersion!==s.version?` · v${s.installedVersion}`:""]})]}),e.jsx("span",{className:"plugin-registry-description-text",children:s.description}),e.jsx("span",{className:"plugin-registry-author",children:n("plugins.registryByAuthor","By {{author}}",{author:s.author})})]}),e.jsx("div",{className:"plugin-registry-actions",children:s.installed?e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-action",onClick:()=>{i?k(i):h()},children:n("plugins.manage","Manage")}):s.canInstall?e.jsx("button",{className:"btn btn-primary btn-sm plugin-registry-action",onClick:()=>void Ge(s),disabled:l,children:l?n("plugins.installing","Installing..."):n("plugins.installFromRegistry","Install")}):e.jsx("span",{className:"plugin-registry-coming-soon",children:n("plugins.registryComingSoon","Coming Soon")})})]},s.id)})})]}),He=()=>e.jsxs("section",{className:"plugin-builtins-section","aria-label":n("plugins.builtinPlugins","Built-in Plugins"),children:[e.jsxs("div",{className:"plugin-builtins-header",children:[e.jsx("h4",{className:"plugin-builtins-heading",children:n("plugins.builtinPlugins","Built-in Plugins")}),e.jsx("p",{className:"plugin-builtins-description",children:n("plugins.builtinPluginsCatalog","Built-in plugin catalog for runtimes and integrations.")})]}),e.jsx("div",{className:"plugin-builtins-list","aria-label":n("plugins.builtinPluginRecommendations","Built-in plugin recommendations"),children:je.map(s=>{const i=le.get(s.id),l=!!i,u=Be[s.id],g=!!(u&&"setupCheckDeferred"in u&&u.setupCheckDeferred),a=u&&"status"in u?u.status:void 0,t=l&&s.hasSetup&&u?.hasSetup&&!g&&i?.state==="started"&&(a==="not-installed"||a==="error"),N=l&&u?.hasSetup&&a==="installed",C=ke===s.id,p=!s.path;return e.jsxs("div",{className:"plugin-builtins-item",children:[e.jsxs("div",{className:"plugin-builtins-meta",children:[e.jsx("span",{className:"plugin-builtins-name",children:s.name}),s.experimental&&e.jsx("span",{className:"plugin-builtins-runtime-badge",children:n("plugins.experimental","Experimental")}),e.jsx("span",{className:"plugin-builtins-runtime-badge",children:s.category}),e.jsx("span",{className:`plugin-builtins-status ${l?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:l?n("plugins.statusInstalled","Installed"):p?n("plugins.statusBuiltIn","Built in"):n("plugins.statusNotInstalled","Not installed")}),t&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:n("plugins.setupRequired","Setup required")}),N&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:n("plugins.setupReady","Setup ready")}),C&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:n("plugins.checkingSetup","Checking setup...")}),g&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--deferred",children:n("plugins.startPluginToCheckSetup","Start plugin to check setup")}),e.jsx("span",{className:"plugin-builtins-description-text",children:s.description})]}),p?l&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void se(s),disabled:B===s.id||C,children:B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup")}):l&&i?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void k(i),children:n("plugins.manage","Manage")}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:n("plugins.builtinMetadataOnly","Built-in metadata only")}):e.jsx("button",{className:`btn ${l&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!l){Ae(s);return}if(t){se(s);return}i&&k(i)},disabled:V===s.id||B===s.id||C,children:l?t?B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup"):n("plugins.manage","Manage"):V===s.id?n("plugins.installing","Installing..."):n("plugins.installNamed","Install {{name}}",{name:s.name})})]},s.id)})})]});return e.jsxs("div",{className:"plugin-manager","data-testid":"plugin-manager",children:[e.jsxs("div",{className:"plugin-manager-header",children:[e.jsx("span",{className:"plugin-manager-header-title",children:n("plugins.installedPlugins","Installed Plugins")}),e.jsxs("div",{className:"plugin-manager-actions",children:[e.jsxs("button",{className:"btn btn-sm",onClick:h,title:n("plugins.refresh","Refresh"),"aria-label":n("plugins.refreshPluginList","Refresh plugin list"),children:[e.jsx(be,{size:14,className:v?"spin":""}),n("plugins.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>L(!0),children:[e.jsx(pe,{size:14})," ",n("plugins.install","Install")]})]})]}),ve&&e.jsxs("div",{className:"plugin-install-form",children:[e.jsx("p",{className:"plugin-install-hint",children:n("plugins.installHint","Browse to a plugin package root (contains manifest.json) or a built dist directory.")}),e.jsx(ts,{value:E,onChange:A,placeholder:n("plugins.installPathPlaceholder","Absolute path to plugin directory or dist folder"),onInputKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),ee())}}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:s=>U(s.target.checked)}),n("plugins.enableAiSecurityScan","Enable AI security scan on load")]}),e.jsxs("div",{className:"plugin-install-actions",children:[e.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:_||!E.trim(),children:_?n("plugins.installing","Installing..."):n("plugins.installPluginGlobally","Install Plugin Globally")}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{L(!1),A("")},children:n("plugins.cancel","Cancel")})]})]}),v?e.jsx("div",{className:"settings-empty-state",children:e.jsx(de,{label:n("plugins.loadingPlugins","Loading plugins...")})}):e.jsxs(e.Fragment,{children:[re.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(We,{size:32,className:"text-muted"}),e.jsx("p",{children:n("plugins.noPluginsInstalled","No plugins installed.")}),e.jsx("p",{className:"text-muted",children:n("plugins.noPluginsHint","Install a plugin to get started, or use the built-in catalog below.")})]}):e.jsx("div",{className:"plugin-list",children:re.map(s=>e.jsxs("div",{className:"plugin-item",children:[e.jsx("div",{className:"plugin-info",children:e.jsxs("div",{className:"plugin-copy",children:[e.jsxs("div",{className:"plugin-copy-header",children:[e.jsx("span",{className:"plugin-name",children:s.name}),e.jsxs("span",{className:"plugin-version text-muted",children:["v",s.version]}),e.jsx("span",{className:"plugin-state-badge",style:{color:F[s.state]||F.installed},children:s.state})]}),Se(s)]})}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>te(s),disabled:w===s.id,title:n("plugins.reload","Reload"),children:e.jsx(me,{size:14,className:w===s.id?"spin":""})}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>s.enabled?ie(s):ne(s),"aria-label":s.enabled?n("plugins.disablePlugin","Disable {{name}}",{name:s.name}):n("plugins.enablePlugin","Enable {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon",onClick:()=>k(s),title:n("plugins.settings","Settings"),children:e.jsx(Ke,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>ae(s),title:n("plugins.uninstallGloballyTitle","Uninstall globally"),children:e.jsx(he,{size:14})})]})]},s.id))}),He(),_e()]})]})}export{ye as AGENT_BROWSER_SETTINGS_SCHEMA,Ne as BUILTIN_AGENT_BROWSER_PLUGIN_ID,je as BUILTIN_PLUGINS,ys as PluginManager,F as STATE_COLORS};
|
|
1
|
+
import{r as d,j as e}from"./vendor-react-SZ_qB27O.js";import{ag as Me,ah as Ue,ai as $e,aj as ce,ak as qe,X as ge,al as Ve,am as Te,an as de,P as pe,ao as me,J as he,R as be,ap as We,a4 as Ke,aq as Qe,ar as Je,as as Ye,at as Xe,au as Ze,av as es,aw as ss,ax as O,ay as ns,az as is}from"./index-rfsTNfpA.js";import{D as ts}from"./DirectoryPicker-cW1rnVoG.js";import{u as as}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";import"./folder-open-BN3_NdbL.js";const Ne="fusion-plugin-agent-browser",ye={enabled:{type:"boolean",label:"Enable Agent Browser",group:"General"},installChannel:{type:"enum",label:"Install Channel",enumValues:["stable","beta","nightly"],defaultValue:"stable",group:"General"},commandTimeoutMs:{type:"number",label:"Command Timeout (ms)",defaultValue:12e4,group:"General"},headlessMode:{type:"boolean",label:"Headless Mode",defaultValue:!0,group:"Browser"},allowedDomains:{type:"array",label:"Allowed Domains",itemType:"string",group:"Browser"},promptExecutorSystem:{type:"string",label:"Executor System Prompt",multiline:!0,group:"Prompt Contributions"},promptExecutorTask:{type:"string",label:"Executor Task Prompt",multiline:!0,group:"Prompt Contributions"},promptTriage:{type:"string",label:"Triage Prompt",multiline:!0,group:"Prompt Contributions"},promptReviewer:{type:"string",label:"Reviewer Prompt",multiline:!0,group:"Prompt Contributions"},promptHeartbeat:{type:"string",label:"Heartbeat Prompt",multiline:!0,group:"Prompt Contributions"},skillExposure:{type:"enum",label:"Skill Exposure",enumValues:["none","selected","all"],defaultValue:"selected",group:"Skills"}},xe={General:"plugins.agentBrowser.groupGeneral",Browser:"plugins.agentBrowser.groupBrowser","Prompt Contributions":"plugins.agentBrowser.groupPromptContributions",Skills:"plugins.agentBrowser.groupSkills"},fe={"Enable Agent Browser":"plugins.agentBrowser.labelEnabled","Install Channel":"plugins.agentBrowser.labelInstallChannel","Command Timeout (ms)":"plugins.agentBrowser.labelCommandTimeoutMs","Headless Mode":"plugins.agentBrowser.labelHeadlessMode","Allowed Domains":"plugins.agentBrowser.labelAllowedDomains","Executor System Prompt":"plugins.agentBrowser.labelPromptExecutorSystem","Executor Task Prompt":"plugins.agentBrowser.labelPromptExecutorTask","Triage Prompt":"plugins.agentBrowser.labelPromptTriage","Reviewer Prompt":"plugins.agentBrowser.labelPromptReviewer","Heartbeat Prompt":"plugins.agentBrowser.labelPromptHeartbeat","Skill Exposure":"plugins.agentBrowser.labelSkillExposure"},je=[{id:"fusion-plugin-hermes-runtime",name:"Hermes Runtime",description:"Runtime provider for Hermes CLI-backed execution.",category:"runtime",path:"./plugins/fusion-plugin-hermes-runtime",experimental:!0},{id:"fusion-plugin-paperclip-runtime",name:"Paperclip Runtime",description:"Runtime provider for Paperclip agent connections.",category:"runtime",path:"./plugins/fusion-plugin-paperclip-runtime"},{id:"fusion-plugin-openclaw-runtime",name:"OpenClaw Runtime",description:"Runtime provider for OpenClaw execution.",category:"runtime",path:"./plugins/fusion-plugin-openclaw-runtime",experimental:!0},{id:"fusion-plugin-droid-runtime",name:"Droid Runtime",description:"Runtime provider for Droid CLI execution.",category:"runtime",path:"./plugins/fusion-plugin-droid-runtime",experimental:!0},{id:"fusion-plugin-dependency-graph",name:"Dependency Graph",description:"Dashboard plugin for task dependency graph visualization.",category:"integration",path:"./plugins/fusion-plugin-dependency-graph"},{id:"fusion-plugin-reports",name:"Reports",description:"View report history, compare runs side-by-side, and export standalone HTML summaries.",category:"integration",path:"./plugins/fusion-plugin-reports"},{id:"fusion-plugin-whatsapp-chat",name:"WhatsApp Chat",description:"Pairs to WhatsApp Web (multi-device) with QR or pairing code, then bridges direct chats to a Fusion agent.",category:"integration",path:"./plugins/fusion-plugin-whatsapp-chat"},{id:"fusion-plugin-cli-printing-press",name:"CLI Printing Press",description:"Guided wizard for drafting external service CLI definitions.",category:"integration",path:"./plugins/fusion-plugin-cli-printing-press"},{id:"fusion-plugin-compound-engineering",name:"Compound Engineering",description:"A dedicated dashboard surface for compound-engineering artifacts and interactive ce-* sessions.",category:"integration",path:"./plugins/fusion-plugin-compound-engineering"},{id:"fusion-plugin-linear-import",name:"Linear Import",description:"Browse Linear issues and import selected issues as Fusion triage tasks through plugin-owned settings.",category:"integration",path:"./plugins/fusion-plugin-linear-import"},{id:Ne,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],F={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function ls(r){const o=r.settingsSchema,n=o&&Object.keys(o).length>0;return r.id!==Ne?n?o:void 0:n?{...ye,...o}:ye}function rs(r){const o=new Map,n=[];for(const[j,y]of Object.entries(r))if(y.group){const v=o.get(y.group)??[];v.push([j,y]),o.set(y.group,v)}else n.push([j,y]);return{grouped:o,ungrouped:n}}function Se(r,o="plugin-error-text"){return r.state!=="error"||!r.error?null:e.jsx("p",{className:o,title:r.error,children:r.error})}function ys({addToast:r,projectId:o}){const{t:n}=as("app"),[j,y]=d.useState([]),[v,z]=d.useState(!0),[ve,L]=d.useState(!1),[E,A]=d.useState(""),[_,H]=d.useState(!1),[M,U]=d.useState(!1),[w,$]=d.useState(null),[c,G]=d.useState(null),[m,x]=d.useState({}),[we,q]=d.useState(!1),[V,T]=d.useState(null),[W,Pe]=d.useState([]),[Ce,K]=d.useState(!0),[Q,J]=d.useState(null),[b,Re]=d.useState(""),[f,Ie]=d.useState(""),[Ee,Y]=d.useState(null),P=d.useRef(null),[Be,D]=d.useState({}),[ke,X]=d.useState(null),[B,Z]=d.useState(null),{confirm:Fe}=Me(),h=d.useCallback(async()=>{try{z(!0);const s=await Ue(o);y(s)}catch(s){r(n("plugins.loadFailed","Failed to load plugins: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{z(!1)}},[o,r]),S=d.useCallback(async(s=b,i=f)=>{try{K(!0),J(null);const l=await $e(s,i||void 0,o);Pe(l)}catch(l){const u=l instanceof Error?l.message:String(l);J(u)}finally{K(!1)}},[o,f,b]);d.useEffect(()=>{h()},[h]),d.useEffect(()=>(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{S(b,f)},300),()=>{P.current&&clearTimeout(P.current)}),[S,f,b]),d.useEffect(()=>{const s=je.filter(l=>l.hasSetup&&j.some(u=>u.id===l.id));if(s.length===0)return;let i=!1;return Promise.all(s.map(async l=>{try{const u=await ce(l.id,o);if(i)return;D(g=>({...g,[l.id]:u}))}catch{if(i)return;D(u=>({...u,[l.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{i=!0}},[j,o]);const Le=d.useRef([]);Le.current=j,d.useEffect(()=>{const s=o?`?projectId=${encodeURIComponent(o)}`:"",i=l=>{try{const u=JSON.parse(l.data);if(u.scope==="project"&&(u.projectId??o)!==o)return;switch(u.transition){case"installing":case"enabled":case"disabled":case"settings-updated":S(b,f),y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],enabled:u.enabled,state:u.state,settings:u.settings,error:u.error},t}else return h(),g});break;case"state-changed":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break;case"uninstalled":y(g=>g.filter(a=>a.id!==u.pluginId)),S(b,f);break;case"error":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break}}catch{}};return qe(`/api/events${s}`,{events:{"plugin:lifecycle":i},onReconnect:()=>{h(),S(b,f)}})},[o,h,S,f,b]);const ee=async()=>{if(!E.trim()){r(n("plugins.installPathRequired","Please enter a plugin path"),"error");return}try{H(!0),await O({path:E,...M?{aiScanOnLoad:!0}:{}},o),r(n("plugins.installedGlobally","Plugin installed globally"),"success"),L(!1),A(""),U(!1),await h()}catch(s){r(n("plugins.installFailed","Failed to install plugin: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{H(!1)}},Ae=async s=>{if(!s.path){r(n("plugins.builtinNoPackage","{{name}} is built in and does not have an installable package yet",{name:s.name}),"warning");return}try{T(s.id),await O({path:s.path},o),r(n("plugins.builtinInstalledGlobally","{{name}} installed globally",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.builtinInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{T(null)}},Ge=async s=>{if(!s.path){r(n("plugins.registryNotInstallable","{{name}} is not available for one-click install yet",{name:s.name}),"warning");return}try{Y(s.id),await O({path:s.path},o),r(n("plugins.registryInstalled","{{name}} installed and enabled",{name:s.name}),"success"),await h(),await S(b,f)}catch(i){r(n("plugins.registryInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Y(null)}},se=async s=>{try{Z(s.id);const i=await is(s.id,o);if(!i.success){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error");return}r(n("plugins.setupInstalled","{{name}} setup installed",{name:s.name}),"success"),X(s.id);const l=await ce(s.id,o);D(u=>({...u,[s.id]:l}))}catch(i){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Z(null),X(null)}},ne=async s=>{try{const i=await es(s.id,o);if(i.state==="error"){r(n("plugins.enableFailed","Failed to enable {{name}}: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error"),await h();return}r(n("plugins.enabledForProject","{{name}} enabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.enablePluginFailed","Failed to enable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},ie=async s=>{try{await Ze(s.id,o),r(n("plugins.disabledForProject","{{name}} disabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.disablePluginFailed","Failed to disable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},te=async s=>{try{$(s.id),await Xe(s.id,o),r(n("plugins.reloaded","{{name}} reloaded",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.reloadFailed","Failed to reload plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}finally{$(null)}},ae=async s=>{if(await Fe({title:n("plugins.uninstallTitle","Uninstall Plugin Globally"),message:n("plugins.uninstallConfirm",'Are you sure you want to uninstall "{{name}}" globally (all projects)?',{name:s.name}),danger:!0}))try{await ss(s.id,o),r(n("plugins.uninstalledGlobally","{{name}} uninstalled globally",{name:s.name}),"success"),await h(),G(null)}catch(l){r(n("plugins.uninstallFailed","Failed to uninstall plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},De=async(s,i)=>{try{await Qe(s.id,{aiScanOnLoad:i},o),r(i?n("plugins.aiScanEnabled","AI scan on load enabled"):n("plugins.aiScanDisabled","AI scan on load disabled"),"success"),await h()}catch(l){r(n("plugins.updateFailed","Failed to update plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},Oe=async s=>{try{await Je(s.id,o),r(n("plugins.rescanned","{{name}} rescanned",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.rescanFailed","Failed to rescan plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},k=async s=>{G(s);try{q(!0);const i=await ns(s.id,o);x(i)}catch{x({})}finally{q(!1)}},ze=async()=>{if(c)try{await Ye(c.id,m,o),r(n("plugins.settingsSaved","Settings saved"),"success")}catch(s){r(n("plugins.saveSettingsFailed","Failed to save settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}};if(c)return e.jsxs("div",{className:"plugin-manager-detail","data-testid":"plugin-manager-detail",children:[e.jsxs("div",{className:"plugin-manager-detail-header",children:[e.jsx("button",{className:"btn-icon",onClick:()=>G(null),"aria-label":n("plugins.backToList","Back to plugin list"),children:e.jsx(ge,{size:16})}),e.jsxs("div",{className:"plugin-detail-title",children:[e.jsxs("div",{className:"plugin-detail-title-copy",children:[e.jsx("h4",{className:"plugin-detail-name",children:c.name}),Se(c,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:F[c.state]||F.installed},children:c.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[c.description&&e.jsx("p",{className:"plugin-description",children:c.description}),c.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.author","Author:")}),c.author]}),c.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:n("plugins.homepage","Homepage:")}),e.jsxs("a",{href:c.homepage,target:"_blank",rel:"noopener noreferrer",children:[c.homepage,e.jsx(Ve,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.version","Version:")}),c.version]})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.securityScan","Security Scan")}),e.jsxs("div",{className:"plugin-security-row",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:!!c.aiScanOnLoad,onChange:s=>void De(c,s.target.checked)}),n("plugins.enableAiScanBeforeLoad","Enable AI scan before load/reload")]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void Oe(c),children:[e.jsx(Te,{size:14})," ",n("plugins.rescanAndReload","Rescan and Reload")]})]}),e.jsx("p",{className:"text-muted",children:n("plugins.aiScanHint","Turning this on only updates configuration. Use Rescan and Reload to run it now.")}),c.lastSecurityScan?e.jsxs("div",{className:"plugin-security-results",children:[e.jsxs("div",{className:"plugin-security-header",children:[e.jsx("span",{className:`plugin-state-badge plugin-security-badge plugin-security-badge--${c.lastSecurityScan.verdict}`,children:c.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:c.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:c.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsx("summary",{children:n("plugins.findings","Findings ({{count}})",{count:c.lastSecurityScan.findings.length})}),e.jsx("ul",{className:"plugin-security-findings",children:c.lastSecurityScan.findings.map((s,i)=>e.jsxs("li",{children:[e.jsx("strong",{children:s.severity})," ",s.category," — ",s.file,": ",s.reason]},`${s.file}-${i}`))})]})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noSecurityScan","No security scan has been run yet.")})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.settings","Settings")}),we?e.jsx("p",{className:"text-muted",children:e.jsx(de,{label:n("plugins.loading","Loading...")})}):(()=>{const s=ls(c);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:i,ungrouped:l}=rs(s),u=[];l.length>0&&u.push({title:null,entries:l});for(const[g,a]of i.entries())u.push({title:g,entries:a});return u.map(g=>e.jsxs("div",{className:g.title?"plugin-settings-group":void 0,children:[g.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:xe[g.title]?n(xe[g.title],g.title):g.title}),g.entries.map(([a,t])=>{const N=`setting-${a}-help`,C=t.label?fe[t.label]?n(fe[t.label],t.label):t.label:a;return e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:`setting-${a}`,children:[C,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${a}`,rows:4,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:Number(p.target.value)}),"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m[a]??!1,onChange:p=>x({...m,[a]:p.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),"aria-describedby":t.description&&!t.required?N:void 0,children:[e.jsx("option",{value:"",children:n("plugins.selectOption","Select...")}),t.enumValues?.map(p=>e.jsx("option",{value:p,children:p},p))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[m[a]?.map((p,R)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:p??"",onChange:ue=>{const I=ue.target.value,oe=[...m[a]||[]];oe[R]=t.itemType==="number"?Number(I):I,x({...m,[a]:oe})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const I=[...m[a]||[]];I.splice(R,1),x({...m,[a]:I})},"aria-label":n("plugins.removeItem","Remove item"),children:e.jsx(ge,{size:14})})]},R)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const p=m[a]||[],R=t.itemType==="number"?0:"";x({...m,[a]:[...p,R]})},children:[e.jsx(pe,{size:14})," ",n("plugins.addItem","Add Item")]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:N,className:"form-help",children:t.description})]},a)})]},g.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:ze,children:n("plugins.saveSettings","Save Settings")})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noConfigurableSettings","No configurable settings.")})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[c.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>te(c),disabled:w===c.id,children:[e.jsx(me,{size:14,className:w===c.id?"spin":""}),w===c.id?n("plugins.reloading","Reloading..."):n("plugins.reload","Reload")]}),c.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>ie(c),children:n("plugins.disableInProject","Disable in Project")}):e.jsx("button",{className:"btn btn-primary",onClick:()=>ne(c),children:n("plugins.enableInProject","Enable in Project")}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>ae(c),children:[e.jsx(he,{size:14})," ",n("plugins.uninstallGlobally","Uninstall Globally")]})]})]})]});const le=new Map(j.map(s=>[s.id,s])),re=j,_e=()=>e.jsxs("section",{className:"plugin-registry-section","aria-label":n("plugins.browseRegistry","Browse Registry"),children:[e.jsxs("div",{className:"plugin-registry-header",children:[e.jsxs("div",{className:"plugin-registry-heading-copy",children:[e.jsx("h4",{className:"plugin-registry-heading",children:n("plugins.browseRegistry","Browse Registry")}),e.jsx("p",{className:"plugin-registry-description",children:n("plugins.registryDescription","Discover curated runtimes and integrations that can be added to this Fusion workspace.")})]}),e.jsxs("div",{className:"plugin-registry-controls",children:[e.jsxs("label",{className:"plugin-registry-category-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.registryCategory","Registry category")}),e.jsxs("select",{className:"select plugin-registry-category-select",value:f,onChange:s=>Ie(s.target.value),"aria-label":n("plugins.registryCategory","Registry category"),children:[e.jsx("option",{value:"",children:n("plugins.registryCategoryAll","All Categories")}),e.jsx("option",{value:"runtime",children:n("plugins.registryCategoryRuntime","Runtime")}),e.jsx("option",{value:"integration",children:n("plugins.registryCategoryIntegration","Integration")})]})]}),e.jsxs("label",{className:"plugin-registry-search-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.searchRegistry","Search registry")}),e.jsx("input",{className:"input plugin-registry-search-input",type:"search",value:b,onChange:s=>Re(s.target.value),placeholder:n("plugins.searchRegistryPlaceholder","Search registry plugins")})]})]})]}),Ce?e.jsxs("div",{className:"plugin-registry-state",role:"status",children:[e.jsx(be,{size:14,className:"spin"}),n("plugins.registryLoading","Loading registry...")]}):Q?e.jsxs("div",{className:"plugin-registry-state plugin-registry-state--error",role:"alert",children:[e.jsx("span",{children:n("plugins.registryLoadFailed","Failed to load registry: {{error}}",{error:Q})}),e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-retry",onClick:()=>void S(b,f),children:n("plugins.retry","Retry")})]}):W.length===0?e.jsx("div",{className:"plugin-registry-state",children:b.trim()?n("plugins.registryEmptySearch","No registry plugins match your search."):n("plugins.registryEmpty","No registry plugins are available.")}):e.jsx("div",{className:"plugin-registry-list","aria-label":n("plugins.registryPluginResults","Registry plugin results"),children:W.map(s=>{const i=le.get(s.id),l=Ee===s.id;return e.jsxs("div",{className:"plugin-registry-item",children:[e.jsxs("div",{className:"plugin-registry-meta",children:[e.jsxs("div",{className:"plugin-registry-title-row",children:[e.jsx("span",{className:"plugin-registry-name",children:s.name}),e.jsxs("span",{className:"plugin-registry-version",children:["v",s.version]}),e.jsx("span",{className:"plugin-registry-badge",children:s.category}),s.installed&&e.jsxs("span",{className:"plugin-registry-status plugin-registry-status--installed",children:[n("plugins.statusInstalled","Installed"),s.installedVersion&&s.installedVersion!==s.version?` · v${s.installedVersion}`:""]})]}),e.jsx("span",{className:"plugin-registry-description-text",children:s.description}),e.jsx("span",{className:"plugin-registry-author",children:n("plugins.registryByAuthor","By {{author}}",{author:s.author})})]}),e.jsx("div",{className:"plugin-registry-actions",children:s.installed?e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-action",onClick:()=>{i?k(i):h()},children:n("plugins.manage","Manage")}):s.canInstall?e.jsx("button",{className:"btn btn-primary btn-sm plugin-registry-action",onClick:()=>void Ge(s),disabled:l,children:l?n("plugins.installing","Installing..."):n("plugins.installFromRegistry","Install")}):e.jsx("span",{className:"plugin-registry-coming-soon",children:n("plugins.registryComingSoon","Coming Soon")})})]},s.id)})})]}),He=()=>e.jsxs("section",{className:"plugin-builtins-section","aria-label":n("plugins.builtinPlugins","Built-in Plugins"),children:[e.jsxs("div",{className:"plugin-builtins-header",children:[e.jsx("h4",{className:"plugin-builtins-heading",children:n("plugins.builtinPlugins","Built-in Plugins")}),e.jsx("p",{className:"plugin-builtins-description",children:n("plugins.builtinPluginsCatalog","Built-in plugin catalog for runtimes and integrations.")})]}),e.jsx("div",{className:"plugin-builtins-list","aria-label":n("plugins.builtinPluginRecommendations","Built-in plugin recommendations"),children:je.map(s=>{const i=le.get(s.id),l=!!i,u=Be[s.id],g=!!(u&&"setupCheckDeferred"in u&&u.setupCheckDeferred),a=u&&"status"in u?u.status:void 0,t=l&&s.hasSetup&&u?.hasSetup&&!g&&i?.state==="started"&&(a==="not-installed"||a==="error"),N=l&&u?.hasSetup&&a==="installed",C=ke===s.id,p=!s.path;return e.jsxs("div",{className:"plugin-builtins-item",children:[e.jsxs("div",{className:"plugin-builtins-meta",children:[e.jsx("span",{className:"plugin-builtins-name",children:s.name}),s.experimental&&e.jsx("span",{className:"plugin-builtins-runtime-badge",children:n("plugins.experimental","Experimental")}),e.jsx("span",{className:"plugin-builtins-runtime-badge",children:s.category}),e.jsx("span",{className:`plugin-builtins-status ${l?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:l?n("plugins.statusInstalled","Installed"):p?n("plugins.statusBuiltIn","Built in"):n("plugins.statusNotInstalled","Not installed")}),t&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:n("plugins.setupRequired","Setup required")}),N&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:n("plugins.setupReady","Setup ready")}),C&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:n("plugins.checkingSetup","Checking setup...")}),g&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--deferred",children:n("plugins.startPluginToCheckSetup","Start plugin to check setup")}),e.jsx("span",{className:"plugin-builtins-description-text",children:s.description})]}),p?l&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void se(s),disabled:B===s.id||C,children:B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup")}):l&&i?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void k(i),children:n("plugins.manage","Manage")}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:n("plugins.builtinMetadataOnly","Built-in metadata only")}):e.jsx("button",{className:`btn ${l&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!l){Ae(s);return}if(t){se(s);return}i&&k(i)},disabled:V===s.id||B===s.id||C,children:l?t?B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup"):n("plugins.manage","Manage"):V===s.id?n("plugins.installing","Installing..."):n("plugins.installNamed","Install {{name}}",{name:s.name})})]},s.id)})})]});return e.jsxs("div",{className:"plugin-manager","data-testid":"plugin-manager",children:[e.jsxs("div",{className:"plugin-manager-header",children:[e.jsx("span",{className:"plugin-manager-header-title",children:n("plugins.installedPlugins","Installed Plugins")}),e.jsxs("div",{className:"plugin-manager-actions",children:[e.jsxs("button",{className:"btn btn-sm",onClick:h,title:n("plugins.refresh","Refresh"),"aria-label":n("plugins.refreshPluginList","Refresh plugin list"),children:[e.jsx(be,{size:14,className:v?"spin":""}),n("plugins.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>L(!0),children:[e.jsx(pe,{size:14})," ",n("plugins.install","Install")]})]})]}),ve&&e.jsxs("div",{className:"plugin-install-form",children:[e.jsx("p",{className:"plugin-install-hint",children:n("plugins.installHint","Browse to a plugin package root (contains manifest.json) or a built dist directory.")}),e.jsx(ts,{value:E,onChange:A,placeholder:n("plugins.installPathPlaceholder","Absolute path to plugin directory or dist folder"),onInputKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),ee())}}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:s=>U(s.target.checked)}),n("plugins.enableAiSecurityScan","Enable AI security scan on load")]}),e.jsxs("div",{className:"plugin-install-actions",children:[e.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:_||!E.trim(),children:_?n("plugins.installing","Installing..."):n("plugins.installPluginGlobally","Install Plugin Globally")}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{L(!1),A("")},children:n("plugins.cancel","Cancel")})]})]}),v?e.jsx("div",{className:"settings-empty-state",children:e.jsx(de,{label:n("plugins.loadingPlugins","Loading plugins...")})}):e.jsxs(e.Fragment,{children:[re.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(We,{size:32,className:"text-muted"}),e.jsx("p",{children:n("plugins.noPluginsInstalled","No plugins installed.")}),e.jsx("p",{className:"text-muted",children:n("plugins.noPluginsHint","Install a plugin to get started, or use the built-in catalog below.")})]}):e.jsx("div",{className:"plugin-list",children:re.map(s=>e.jsxs("div",{className:"plugin-item",children:[e.jsx("div",{className:"plugin-info",children:e.jsxs("div",{className:"plugin-copy",children:[e.jsxs("div",{className:"plugin-copy-header",children:[e.jsx("span",{className:"plugin-name",children:s.name}),e.jsxs("span",{className:"plugin-version text-muted",children:["v",s.version]}),e.jsx("span",{className:"plugin-state-badge",style:{color:F[s.state]||F.installed},children:s.state})]}),Se(s)]})}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>te(s),disabled:w===s.id,title:n("plugins.reload","Reload"),children:e.jsx(me,{size:14,className:w===s.id?"spin":""})}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>s.enabled?ie(s):ne(s),"aria-label":s.enabled?n("plugins.disablePlugin","Disable {{name}}",{name:s.name}):n("plugins.enablePlugin","Enable {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon",onClick:()=>k(s),title:n("plugins.settings","Settings"),children:e.jsx(Ke,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>ae(s),title:n("plugins.uninstallGloballyTitle","Uninstall globally"),children:e.jsx(he,{size:14})})]})]},s.id))}),He(),_e()]})]})}export{ye as AGENT_BROWSER_SETTINGS_SCHEMA,Ne as BUILTIN_AGENT_BROWSER_PLUGIN_ID,je as BUILTIN_PLUGINS,ys as PluginManager,F as STATE_COLORS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{c as te,V as ie,
|
|
1
|
+
import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{c as te,V as ie,ba as k,bb as N,bc as C,ao as F,bd as M,be as ae,bf as X,al as Z,h as K,a8 as E}from"./index-rfsTNfpA.js";import{u as ne}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{ay as z,az as de,aA as ue,bC as he,bT as xe,aD as ae,bU as ye,ai as ge,bV as X,bW as Re,bX as _e,bY as Se,bZ as je,b_ as we,b$ as Ne,bG as ke,c0 as Ee,c1 as Ce,aS as Ae,c2 as Te,V as Le,aK as me,L as Pe,al as Fe}from"./index-B6ttSchA.js";import{u as be}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const Ie="builtin",Q={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function ne(n){const a=n?.researchGlobalDefaults,i=n?.researchSettings;return{enabled:i?.enabled??n?.researchEnabled??n?.researchGlobalEnabled??!0,searchProvider:i?.searchProvider??a?.searchProvider??n?.researchGlobalWebSearchProvider??Ie,synthesisProvider:i?.synthesisProvider??a?.synthesisProvider,synthesisModelId:i?.synthesisModelId??a?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:i?.enabledSources?.pageFetch??a?.enabledSources?.pageFetch??Q.pageFetch,github:i?.enabledSources?.github??a?.enabledSources?.github??Q.github,localDocs:i?.enabledSources?.localDocs??a?.enabledSources?.localDocs??Q.localDocs,llmSynthesis:i?.enabledSources?.llmSynthesis??a?.enabledSources?.llmSynthesis??Q.llmSynthesis},limits:{maxConcurrentRuns:i?.limits?.maxConcurrentRuns??n?.researchMaxConcurrentRuns??n?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:i?.limits?.maxSourcesPerRun??a?.maxSourcesPerRun??n?.researchMaxSourcesPerRun??n?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:i?.limits?.maxDurationMs??n?.researchDefaultTimeout??n?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:i?.limits?.requestTimeoutMs??n?.researchGlobalFetchTimeoutMs??3e4},defaultExportFormat:a?.defaultExportFormat??"markdown"}}const Me=300,De=4e3,He=["queued","running","cancelling","retry_waiting"];function ce(n,a){if(n instanceof ke){const i=n;return{message:n.message,status:n.status,code:i.researchCode??"INTERNAL_ERROR",setupHint:i.setupHint,retryable:i.retryable}}return n instanceof Error?{message:n.message,code:"INTERNAL_ERROR"}:{message:a,code:"INTERNAL_ERROR"}}function qe(n){if(!n)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const a=He.includes(n.status),i=n.status==="queued"||n.status==="running",v=n.lifecycle?.retryable,s=n.status==="failed"||n.status==="timed_out",_=!!(s&&v);let g;return!i&&a?g="Run is already transitioning":!i&&n.status==="completed"?g="Completed runs cannot be cancelled":!i&&n.status==="cancelled"?g="Run is already cancelled":!i&&n.status==="retry_exhausted"?g="Retry attempts exhausted":!i&&n.status==="failed"?g="Failed runs cannot be cancelled":!i&&n.status==="timed_out"&&(g="Timed out runs cannot be cancelled"),!_&&s&&v===!1&&(g=n.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:i,retryable:_,isTransitioning:a,blockingReason:g}}function Ue(n){const a=n?.projectId,i=a??"",v=`${ue.RESEARCH_RUNS_PREFIX}${i}`,s=`${ue.RESEARCH_SELECTED_ID_PREFIX}${i}`,_=z(v,{maxAgeMs:de}),g=z(s,{maxAgeMs:he}),r=c.useRef(Array.isArray(_)&&_.length>0),[F,P]=c.useState(()=>Array.isArray(_)?_:[]),[h,E]=c.useState(g??null),[A,N]=c.useState(null),[q,I]=c.useState({available:!0}),[M,T]=c.useState(!(Array.isArray(_)&&_.length>0)),[V,U]=c.useState(null),[G,S]=c.useState(null),[w,k]=c.useState(""),x=c.useRef(0),d=c.useRef(0),D=c.useRef(a);c.useEffect(()=>{D.current!==a&&(D.current=a,d.current++);const l=z(v,{maxAgeMs:de}),o=z(s,{maxAgeMs:he}),p=Array.isArray(l)&&l.length>0;P(Array.isArray(l)?l:[]),E(o??null),N(null),T(!p),r.current=p},[a,v,s]);const b=c.useCallback(async(l=w)=>{const o=++x.current,p=a;r.current||T(!0),U(null),S(null);try{const R=await xe({q:l||void 0,limit:100},p);if(o!==x.current||p!==a)return;P(R.runs),ae(v,R.runs,{maxBytes:5e5}),r.current=!0,I(R.availability),h&&!R.runs.some(y=>y.id===h)&&(E(null),ae(s,null,{maxBytes:5e5}),N(null))}catch(R){if(o!==x.current||p!==a)return;const y=ce(R,"Failed to load research runs");U(y.message),S(y)}finally{o===x.current&&T(!1)}},[a,v,w,s,h]),H=c.useCallback(async l=>{const o=await ye(l,a);return N(o.run),I(o.availability),o.run},[a]);c.useEffect(()=>{r.current||T(!0);const l=window.setTimeout(()=>{b(w)},Me);return()=>window.clearTimeout(l)},[b,w]),c.useEffect(()=>{if(!h){N(null);return}H(h)},[H,h]),c.useEffect(()=>{const l=d.current,o=()=>d.current!==l,p=a?`?projectId=${encodeURIComponent(a)}`:"";let R=!0;const y=()=>{!R||o()||(b(),h&&H(h))},j=`/api/events${p}`,O=ge(j,{events:{"research:run:created":y,"research:run:updated":y,"research:run:completed":y,"research:run:failed":y,"research:run:cancelled":y},onReconnect:()=>{X({view:"useResearch",trigger:"sse-reconnect",projectId:a,replayAttempted:!1,sseChannel:j}),y()}});X({view:"useResearch",trigger:"sse-open",projectId:a,replayAttempted:!1,sseChannel:j});const L=window.setInterval(y,De);return()=>{R=!1,O(),window.clearInterval(L)}},[a,b,h,H]);const B=c.useCallback(l=>{E(l),ae(s,l,{maxBytes:5e5})},[s]);return{runs:F,selectedRun:A,selectedRunId:h,setSelectedRunId:B,availability:q,loading:M,error:V,searchQuery:w,setSearchQuery:k,refresh:b,createRun:l=>Ne(l,a),cancelRun:async l=>{try{S(null);const o=await we(l,a);return h===l&&N(o.run),await b(),o}catch(o){const p=ce(o,"Failed to cancel run");throw S(p),p}},retryRun:async l=>{try{S(null);const o=await je(l,a);return h===l&&N(o.run),await b(),o}catch(o){const p=ce(o,"Failed to retry run");throw S(p),p}},exportRun:(l,o)=>Se(l,o,a),createTaskFromRun:(l,o,p,R,y,j)=>_e(l,{title:o,findingId:p,description:R,priority:y,attachExport:j},a),attachRunToTask:(l,o,p,R)=>Re(l,{taskId:o,findingId:p,attachExport:R},a),uiError:G,runActionState:qe(A),statusCounts:F.reduce((l,o)=>(l[o.status]+=1,l),{queued:0,running:0,cancelling:0,retry_waiting:0,completed:0,failed:0,cancelled:0,timed_out:0,retry_exhausted:0})}}function Oe({open:n,mode:a,run:i,finding:v,projectId:s,onClose:_,onConfirm:g}){const{t:r}=be("app");Ee(n);const[F,P]=c.useState(!1),[h,E]=c.useState(""),[A,N]=c.useState(""),[q,I]=c.useState("normal"),[M,T]=c.useState(""),[V,U]=c.useState([]),[G,S]=c.useState(!1),[w,k]=c.useState(!1),x=c.useMemo(()=>{const d=(v.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${v.heading||r("research.defaultFindingHeading","Research finding")} — ${d}`.trim()},[v.content,v.heading,r]);return c.useEffect(()=>{n&&(P(!1),E(`Research: ${v.heading||i.title}`),N(x),I("normal"),T(""),a==="enrich"&&(S(!0),Ce(50,0,s).then(d=>U(d.filter(D=>D.column!=="archived"))).finally(()=>S(!1))))},[n,a,s,v.heading,x,i.title]),n?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:_,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:a==="create"?r("research.createTaskTitle","Create task from finding"):r("research.enrichTaskTitle","Enrich existing task")}),e.jsx("button",{className:"modal-close",type:"button","aria-label":r("actions.close","Close"),onClick:_,children:"×"})]}),e.jsxs("div",{className:"research-task-action-modal__body",children:[e.jsxs("div",{className:"card research-task-action-modal__preview",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.runLabel","Run:")," "]})," ",i.id]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.findingLabel","Finding:")," "]})," ",v.id,v.heading?` — ${v.heading}`:""]}),e.jsx("p",{children:x||r("research.noPreview","No preview available.")})]}),a==="create"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.titleLabel","Title"),e.jsx("input",{className:"input",value:h,onChange:d=>E(d.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.descriptionLabel","Description"),e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:A,onChange:d=>N(d.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.priorityLabel","Priority"),e.jsxs("select",{className:"select",value:q,onChange:d=>I(d.target.value),children:[e.jsx("option",{value:"low",children:r("research.priorityLow","Low")}),e.jsx("option",{value:"normal",children:r("research.priorityNormal","Normal")}),e.jsx("option",{value:"high",children:r("research.priorityHigh","High")}),e.jsx("option",{value:"urgent",children:r("research.priorityUrgent","Urgent")})]})]})]}):e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.targetTaskLabel","Target task"),e.jsx("input",{className:"input",list:"research-task-action-task-list",value:M,placeholder:G?r("research.loadingTasks","Loading tasks…"):r("research.enterTaskId","Enter task ID"),onChange:d=>T(d.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:V.map(d=>e.jsx("option",{value:d.id,children:d.title},d.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:F,onChange:d=>P(d.target.checked)}),e.jsx("span",{children:r("research.attachExport","Attach markdown export artifact")})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:_,children:r("actions.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:w||a==="enrich"&&!M,onClick:()=>{k(!0),g({taskId:a==="enrich"?M:void 0,title:a==="create"?h.trim():void 0,description:a==="create"?A.trim():void 0,priority:a==="create"?q:void 0,attachExport:F}).finally(()=>k(!1))},children:a==="create"?r("research.createTaskButton","Create Task"):r("research.enrichTaskButton","Enrich Task")})]})]})}):null}const Ve=["web-search","page-fetch","github","local-docs","llm-synthesis"],Ge={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"};function $e(n){return{"web-search":n("research.providerWebSearch","Web Search"),"page-fetch":n("research.providerPageFetch","Page Fetch"),github:n("research.providerGitHub","GitHub"),"local-docs":n("research.providerLocalDocs","Local Docs"),"llm-synthesis":n("research.providerLlmSynthesis","LLM Synthesis")}}let ie=!1;function Je({projectId:n,addToast:a,onOpenSettings:i,readinessVersion:v=0}){const{t:s}=be("app"),_=$e(s);c.useEffect(()=>(X({view:"ResearchView",trigger:ie?"route-active":"remount",projectId:n,replayAttempted:!1}),ie=!1,()=>{ie=!0,X({view:"ResearchView",trigger:"route-inactive",projectId:n,replayAttempted:!1})}),[n]);const{runs:g,selectedRun:r,selectedRunId:F,setSelectedRunId:P,availability:h,loading:E,error:A,searchQuery:N,setSearchQuery:q,createRun:I,cancelRun:M,retryRun:T,exportRun:V,createTaskFromRun:U,attachRunToTask:G,statusCounts:S,refresh:w,uiError:k,runActionState:x}=Ue({projectId:n}),[d,D]=c.useState(""),[b,H]=c.useState(()=>ne(void 0)),[B,l]=c.useState([]),[o,p]=c.useState(!1),[R,y]=c.useState([]),[j,O]=c.useState(null),[L,K]=c.useState(null),Y=h.supportedProviders??Ve,J=b.searchProvider,Z=t=>t==="web-search"?!0:b.enabledSources[Ge[t]];c.useEffect(()=>{const t=Y.filter(u=>Z(u));y(u=>{const f=u.filter(m=>t.includes(m));return f.length>0?f:t})},[b.enabledSources,Y]),c.useEffect(()=>{let t=!1;return Promise.all([Ae(n),Te().catch(()=>({providers:[]}))]).then(([u,f])=>{t||(H(ne(u)),l(f.providers.filter(m=>m.type==="api_key").map(m=>({id:m.id,authenticated:m.authenticated}))))}).catch(()=>{t||H(ne(void 0))}),()=>{t=!0}},[n,v]);const pe=c.useMemo(()=>r?r.status:s("research.noRunSelected","No run selected"),[r,s]),fe=c.useMemo(()=>r?r.status==="queued"||r.status==="retry_waiting"?"status-dot status-dot--pending":r.status==="running"?"status-dot status-dot--connecting":r.status==="completed"?"status-dot status-dot--online":r.status==="failed"||r.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[r]),ee=h.supportedExportFormats??["markdown","json","html"],se=c.useMemo(()=>new Map(B.map(t=>[t.id,t.authenticated])),[B]),re=c.useMemo(()=>{const t=new Set;return b.enabledSources.webSearch&&J&&t.add(J),b.enabledSources.llmSynthesis&&b.synthesisProvider&&t.add(b.synthesisProvider),[...t].filter(u=>se.has(u))},[b.enabledSources.llmSynthesis,b.enabledSources.webSearch,b.synthesisProvider,J,se]).find(t=>se.get(t)!==!0),$=c.useMemo(()=>h.available?b.enabled?re?{reason:s("research.missingApiKey","Missing API key for {{provider}}.",{provider:re}),details:s("research.addCredentialsHint","Add provider credentials in Authentication settings."),settingsSection:"authentication"}:null:{reason:s("research.disabled","Research is disabled for this project."),details:s("research.enableResearchHint","Enable project research settings to create runs."),settingsSection:"research-project"}:{reason:h.reason??s("research.unavailable","Research is unavailable for this project."),details:h.setupInstructions,settingsSection:"research-project"},[h.available,h.reason,h.setupInstructions,b.enabled,re,s]),W=async(t,u,f)=>{O(t);try{await u(),a?.(f,"success"),await w()}catch(m){a?.(m instanceof Error?m.message:s("research.actionFailed","Action failed"),"error")}finally{O(null)}},te=async t=>{if(r){O(`export-${t}`);try{const u=await V(r.id,t),f=new Blob([u.content],{type:"text/plain;charset=utf-8"}),m=URL.createObjectURL(f),C=document.createElement("a");C.href=m,C.download=u.filename,document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(m),a?.(s("research.exportedFile","Exported {{filename}}",{filename:u.filename}),"success")}catch(u){a?.(u instanceof Error?u.message:s("research.exportFailed","Export failed"),"error")}finally{O(null)}}},ve=async()=>{if(d.trim()){p(!0);try{const t=R.filter(f=>Z(f));if(t.length===0){p(!1),a?.(s("research.noSourcesAvailable","No enabled research sources are available for this project."),"error");return}const u=await I({query:d.trim(),providers:t});P(u.run.id),D(""),a?.(s("research.runCreated","Research run created"),"success"),await w()}catch(t){a?.(t instanceof Error?t.message:s("research.createRunFailed","Failed to create run"),"error")}finally{p(!1)}}};return e.jsxs("section",{className:"research-view","aria-label":s("research.viewLabel","Research view"),children:[e.jsx(Le,{icon:me,title:s("research.title","Research"),actions:e.jsx("button",{className:"btn",type:"button",onClick:()=>void w(),children:s("actions.refresh","Refresh")})}),e.jsx("p",{className:"research-view__subtitle",children:s("research.subtitle","Cited search and synthesis runs: gather sources, fetch content, and synthesize findings.")}),$?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:$.reason}),$.details&&e.jsx("p",{children:$.details}),e.jsx("p",{children:s("research.currentDefaults","Current defaults: provider {{provider}}, max sources {{maxSources}}",{provider:b.searchProvider??s("research.notSet","(not set)"),maxSources:b.limits.maxSourcesPerRun})}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void w(),children:s("actions.refresh","Refresh")}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>i?.($.settingsSection),children:s("actions.openSettings","Open Settings")})]})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"research-view__layout",children:[e.jsx("aside",{className:"research-view__sidebar card",children:e.jsxs("div",{className:"research-view__sidebar-content",children:[e.jsxs("div",{className:"research-view__form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-query",children:s("research.queryLabel","Query")}),e.jsx("textarea",{id:"research-query",className:"input research-view__textarea",value:d,onChange:t=>D(t.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("research.providersLabel","Providers")}),e.jsx("div",{className:"research-view__providers",children:Y.map(t=>{const u=Z(t),f=t==="web-search";return e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:f||R.includes(t),disabled:f||!u,onChange:()=>{f||!u||y(m=>m.includes(t)?m.filter(C=>C!==t):[...m,t])}}),e.jsxs("span",{children:[_[t]??t,f?e.jsx("span",{className:"research-view__provider-lock",children:s("research.alwaysOn","Always on")}):null]})]},t)})})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!d.trim()||o,onClick:()=>void ve(),children:[o?e.jsx(Pe,{className:"animate-spin",size:14}):null,s("research.createRun","Create Run")]})]}),e.jsxs("div",{className:"research-view__history-header form-group",children:[e.jsx("label",{htmlFor:"research-run-search",children:s("actions.search","Search")}),e.jsxs("div",{className:"research-view__history-search-row",children:[e.jsx(me,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:s("research.searchRunsPlaceholder","Search runs"),value:N,onChange:t=>q(t.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:g.map(t=>e.jsxs("button",{type:"button",className:`research-view__history-item card${F===t.id?" research-view__history-item--active":""}`,onClick:()=>P(t.id),children:[e.jsx("span",{className:"card-id",children:t.id}),e.jsx("span",{children:t.title})]},t.id))})]})}),e.jsxs("div",{className:"research-view__reader card",children:[E&&e.jsx("p",{"data-testid":"research-state-loading",children:e.jsx(Fe,{label:s("research.loadingRuns","Loading research runs…")})}),!E&&A&&e.jsx("p",{"data-testid":"research-state-error",children:A}),!E&&!A&&g.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:s("research.noRunsYet","No research runs yet")}),e.jsxs("div",{className:"research-view__reader-content",children:[r&&e.jsxs("div",{className:"research-view__run-detail",children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:fe}),e.jsx("strong",{children:pe})]}),e.jsx("h3",{className:"research-view__run-title",children:r.title}),e.jsx("p",{className:"research-view__run-query",children:r.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:r.results?.summary??s("research.noSummaryYet","No summary yet.")}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",title:x.cancelable?void 0:x.blockingReason,disabled:j==="cancel"||j==="retry"||!x.cancelable,onClick:()=>void W("cancel",()=>M(r.id),s("research.runCancelled","Run cancelled")),children:s("actions.cancel","Cancel")}),e.jsx("button",{className:"btn",type:"button",title:x.retryable?void 0:x.blockingReason,disabled:j==="cancel"||j==="retry"||!x.retryable,onClick:()=>void W("retry",()=>T(r.id),s("research.runRetried","Run retried")),children:s("actions.retry","Retry")}),ee.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-markdown",onClick:()=>void te("markdown"),children:s("research.exportMd","Export MD")}),ee.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-json",onClick:()=>void te("json"),children:s("research.exportJson","Export JSON")}),ee.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-html",onClick:()=>void te("html"),children:s("research.exportHtml","Export HTML")})]}),r.error&&e.jsx("p",{className:"research-view__error",children:r.error}),k&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:k.message}),k.setupHint&&e.jsx("p",{children:k.setupHint}),k.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("authentication"),children:s("research.openAuthSettings","Open Authentication Settings")}),k.code==="FEATURE_DISABLED"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("research-project"),children:s("research.openResearchSettings","Open Research Settings")})]}),x.blockingReason&&e.jsx("p",{className:"research-view__run-query",children:x.blockingReason}),Array.isArray(r.results?.findings)&&r.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:r.results.findings.map((t,u)=>{const m=t.id?.trim()||`finding-${u+1}`;return e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:t.heading}),e.jsx("p",{children:t.content}),e.jsxs("div",{className:"research-view__actions research-view__finding-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",type:"button",onClick:()=>K({mode:"create",findingId:m}),children:s("research.createTask","Create Task")}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>K({mode:"enrich",findingId:m}),children:s("research.enrichTask","Enrich Task")})]})]},m)})}),Array.isArray(r.results?.citations)&&r.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:r.results.citations.map(t=>e.jsx("li",{children:e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:t})},t))}),r.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("research.runHistory","Run history")}),e.jsx("ul",{className:"research-view__events",children:r.events.map(t=>e.jsx("li",{children:t.message},t.id))})]})]}),!r&&g.length>0&&e.jsx("p",{children:s("research.selectRunToViewDetails","Select a run to view details.")}),e.jsxs("div",{className:"research-view__stats",children:[e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statRunning","Running")}),e.jsx("div",{className:"research-view__stat-value",children:S.running})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statCompleted","Completed")}),e.jsx("div",{className:"research-view__stat-value",children:S.completed})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statFailed","Failed")}),e.jsx("div",{className:"research-view__stat-value",children:S.failed})]})]})]})]})]})}),r&&L&&(()=>{const t=r.results?.findings?.findIndex((f,m)=>(f.id?.trim()||`finding-${m+1}`)===L.findingId)??-1,u=t>=0?r.results.findings[t]:null;return u?e.jsx(Oe,{open:!0,mode:L.mode,run:r,finding:{id:L.findingId,heading:u.heading,content:u.content},projectId:n,onClose:()=>K(null),onConfirm:async({taskId:f,title:m,description:C,priority:le,attachExport:oe})=>{L.mode==="create"?await W("create-task",()=>U(r.id,m,L.findingId,C,le,oe),s("research.taskCreatedFromResearch","Task created from research")):f&&await W("attach-task",()=>G(r.id,f,L.findingId,oe),s("research.taskEnrichedFromResearch","Task enriched from research")),K(null)}}):null})()]})}export{Je as ResearchView};
|
|
1
|
+
import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{aA as z,aB as de,aC as ue,bE as he,bV as xe,aF as ae,bW as ye,ak as ge,bX as X,bY as Re,bZ as _e,b_ as Se,b$ as je,c0 as we,c1 as Ne,bI as ke,c2 as Ee,c3 as Ce,aU as Ae,c4 as Te,V as Le,aM as me,L as Pe,an as Fe}from"./index-rfsTNfpA.js";import{u as be}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const Ie="builtin",Q={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function ne(n){const a=n?.researchGlobalDefaults,i=n?.researchSettings;return{enabled:i?.enabled??n?.researchEnabled??n?.researchGlobalEnabled??!0,searchProvider:i?.searchProvider??a?.searchProvider??n?.researchGlobalWebSearchProvider??Ie,synthesisProvider:i?.synthesisProvider??a?.synthesisProvider,synthesisModelId:i?.synthesisModelId??a?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:i?.enabledSources?.pageFetch??a?.enabledSources?.pageFetch??Q.pageFetch,github:i?.enabledSources?.github??a?.enabledSources?.github??Q.github,localDocs:i?.enabledSources?.localDocs??a?.enabledSources?.localDocs??Q.localDocs,llmSynthesis:i?.enabledSources?.llmSynthesis??a?.enabledSources?.llmSynthesis??Q.llmSynthesis},limits:{maxConcurrentRuns:i?.limits?.maxConcurrentRuns??n?.researchMaxConcurrentRuns??n?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:i?.limits?.maxSourcesPerRun??a?.maxSourcesPerRun??n?.researchMaxSourcesPerRun??n?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:i?.limits?.maxDurationMs??n?.researchDefaultTimeout??n?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:i?.limits?.requestTimeoutMs??n?.researchGlobalFetchTimeoutMs??3e4},defaultExportFormat:a?.defaultExportFormat??"markdown"}}const Me=300,De=4e3,He=["queued","running","cancelling","retry_waiting"];function ce(n,a){if(n instanceof ke){const i=n;return{message:n.message,status:n.status,code:i.researchCode??"INTERNAL_ERROR",setupHint:i.setupHint,retryable:i.retryable}}return n instanceof Error?{message:n.message,code:"INTERNAL_ERROR"}:{message:a,code:"INTERNAL_ERROR"}}function qe(n){if(!n)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const a=He.includes(n.status),i=n.status==="queued"||n.status==="running",v=n.lifecycle?.retryable,s=n.status==="failed"||n.status==="timed_out",_=!!(s&&v);let g;return!i&&a?g="Run is already transitioning":!i&&n.status==="completed"?g="Completed runs cannot be cancelled":!i&&n.status==="cancelled"?g="Run is already cancelled":!i&&n.status==="retry_exhausted"?g="Retry attempts exhausted":!i&&n.status==="failed"?g="Failed runs cannot be cancelled":!i&&n.status==="timed_out"&&(g="Timed out runs cannot be cancelled"),!_&&s&&v===!1&&(g=n.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:i,retryable:_,isTransitioning:a,blockingReason:g}}function Ue(n){const a=n?.projectId,i=a??"",v=`${ue.RESEARCH_RUNS_PREFIX}${i}`,s=`${ue.RESEARCH_SELECTED_ID_PREFIX}${i}`,_=z(v,{maxAgeMs:de}),g=z(s,{maxAgeMs:he}),r=c.useRef(Array.isArray(_)&&_.length>0),[F,P]=c.useState(()=>Array.isArray(_)?_:[]),[h,E]=c.useState(g??null),[A,N]=c.useState(null),[q,I]=c.useState({available:!0}),[M,T]=c.useState(!(Array.isArray(_)&&_.length>0)),[V,U]=c.useState(null),[$,S]=c.useState(null),[w,k]=c.useState(""),x=c.useRef(0),d=c.useRef(0),D=c.useRef(a);c.useEffect(()=>{D.current!==a&&(D.current=a,d.current++);const l=z(v,{maxAgeMs:de}),o=z(s,{maxAgeMs:he}),p=Array.isArray(l)&&l.length>0;P(Array.isArray(l)?l:[]),E(o??null),N(null),T(!p),r.current=p},[a,v,s]);const b=c.useCallback(async(l=w)=>{const o=++x.current,p=a;r.current||T(!0),U(null),S(null);try{const R=await xe({q:l||void 0,limit:100},p);if(o!==x.current||p!==a)return;P(R.runs),ae(v,R.runs,{maxBytes:5e5}),r.current=!0,I(R.availability),h&&!R.runs.some(y=>y.id===h)&&(E(null),ae(s,null,{maxBytes:5e5}),N(null))}catch(R){if(o!==x.current||p!==a)return;const y=ce(R,"Failed to load research runs");U(y.message),S(y)}finally{o===x.current&&T(!1)}},[a,v,w,s,h]),H=c.useCallback(async l=>{const o=await ye(l,a);return N(o.run),I(o.availability),o.run},[a]);c.useEffect(()=>{r.current||T(!0);const l=window.setTimeout(()=>{b(w)},Me);return()=>window.clearTimeout(l)},[b,w]),c.useEffect(()=>{if(!h){N(null);return}H(h)},[H,h]),c.useEffect(()=>{const l=d.current,o=()=>d.current!==l,p=a?`?projectId=${encodeURIComponent(a)}`:"";let R=!0;const y=()=>{!R||o()||(b(),h&&H(h))},j=`/api/events${p}`,O=ge(j,{events:{"research:run:created":y,"research:run:updated":y,"research:run:completed":y,"research:run:failed":y,"research:run:cancelled":y},onReconnect:()=>{X({view:"useResearch",trigger:"sse-reconnect",projectId:a,replayAttempted:!1,sseChannel:j}),y()}});X({view:"useResearch",trigger:"sse-open",projectId:a,replayAttempted:!1,sseChannel:j});const L=window.setInterval(y,De);return()=>{R=!1,O(),window.clearInterval(L)}},[a,b,h,H]);const B=c.useCallback(l=>{E(l),ae(s,l,{maxBytes:5e5})},[s]);return{runs:F,selectedRun:A,selectedRunId:h,setSelectedRunId:B,availability:q,loading:M,error:V,searchQuery:w,setSearchQuery:k,refresh:b,createRun:l=>Ne(l,a),cancelRun:async l=>{try{S(null);const o=await we(l,a);return h===l&&N(o.run),await b(),o}catch(o){const p=ce(o,"Failed to cancel run");throw S(p),p}},retryRun:async l=>{try{S(null);const o=await je(l,a);return h===l&&N(o.run),await b(),o}catch(o){const p=ce(o,"Failed to retry run");throw S(p),p}},exportRun:(l,o)=>Se(l,o,a),createTaskFromRun:(l,o,p,R,y,j)=>_e(l,{title:o,findingId:p,description:R,priority:y,attachExport:j},a),attachRunToTask:(l,o,p,R)=>Re(l,{taskId:o,findingId:p,attachExport:R},a),uiError:$,runActionState:qe(A),statusCounts:F.reduce((l,o)=>(l[o.status]+=1,l),{queued:0,running:0,cancelling:0,retry_waiting:0,completed:0,failed:0,cancelled:0,timed_out:0,retry_exhausted:0})}}function Oe({open:n,mode:a,run:i,finding:v,projectId:s,onClose:_,onConfirm:g}){const{t:r}=be("app");Ee(n);const[F,P]=c.useState(!1),[h,E]=c.useState(""),[A,N]=c.useState(""),[q,I]=c.useState("normal"),[M,T]=c.useState(""),[V,U]=c.useState([]),[$,S]=c.useState(!1),[w,k]=c.useState(!1),x=c.useMemo(()=>{const d=(v.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${v.heading||r("research.defaultFindingHeading","Research finding")} — ${d}`.trim()},[v.content,v.heading,r]);return c.useEffect(()=>{n&&(P(!1),E(`Research: ${v.heading||i.title}`),N(x),I("normal"),T(""),a==="enrich"&&(S(!0),Ce(50,0,s).then(d=>U(d.filter(D=>D.column!=="archived"))).finally(()=>S(!1))))},[n,a,s,v.heading,x,i.title]),n?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:_,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:a==="create"?r("research.createTaskTitle","Create task from finding"):r("research.enrichTaskTitle","Enrich existing task")}),e.jsx("button",{className:"modal-close",type:"button","aria-label":r("actions.close","Close"),onClick:_,children:"×"})]}),e.jsxs("div",{className:"research-task-action-modal__body",children:[e.jsxs("div",{className:"card research-task-action-modal__preview",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.runLabel","Run:")," "]})," ",i.id]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.findingLabel","Finding:")," "]})," ",v.id,v.heading?` — ${v.heading}`:""]}),e.jsx("p",{children:x||r("research.noPreview","No preview available.")})]}),a==="create"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.titleLabel","Title"),e.jsx("input",{className:"input",value:h,onChange:d=>E(d.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.descriptionLabel","Description"),e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:A,onChange:d=>N(d.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.priorityLabel","Priority"),e.jsxs("select",{className:"select",value:q,onChange:d=>I(d.target.value),children:[e.jsx("option",{value:"low",children:r("research.priorityLow","Low")}),e.jsx("option",{value:"normal",children:r("research.priorityNormal","Normal")}),e.jsx("option",{value:"high",children:r("research.priorityHigh","High")}),e.jsx("option",{value:"urgent",children:r("research.priorityUrgent","Urgent")})]})]})]}):e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.targetTaskLabel","Target task"),e.jsx("input",{className:"input",list:"research-task-action-task-list",value:M,placeholder:$?r("research.loadingTasks","Loading tasks…"):r("research.enterTaskId","Enter task ID"),onChange:d=>T(d.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:V.map(d=>e.jsx("option",{value:d.id,children:d.title},d.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:F,onChange:d=>P(d.target.checked)}),e.jsx("span",{children:r("research.attachExport","Attach markdown export artifact")})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:_,children:r("actions.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:w||a==="enrich"&&!M,onClick:()=>{k(!0),g({taskId:a==="enrich"?M:void 0,title:a==="create"?h.trim():void 0,description:a==="create"?A.trim():void 0,priority:a==="create"?q:void 0,attachExport:F}).finally(()=>k(!1))},children:a==="create"?r("research.createTaskButton","Create Task"):r("research.enrichTaskButton","Enrich Task")})]})]})}):null}const Ve=["web-search","page-fetch","github","local-docs","llm-synthesis"],$e={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"};function Ge(n){return{"web-search":n("research.providerWebSearch","Web Search"),"page-fetch":n("research.providerPageFetch","Page Fetch"),github:n("research.providerGitHub","GitHub"),"local-docs":n("research.providerLocalDocs","Local Docs"),"llm-synthesis":n("research.providerLlmSynthesis","LLM Synthesis")}}let ie=!1;function Je({projectId:n,addToast:a,onOpenSettings:i,readinessVersion:v=0}){const{t:s}=be("app"),_=Ge(s);c.useEffect(()=>(X({view:"ResearchView",trigger:ie?"route-active":"remount",projectId:n,replayAttempted:!1}),ie=!1,()=>{ie=!0,X({view:"ResearchView",trigger:"route-inactive",projectId:n,replayAttempted:!1})}),[n]);const{runs:g,selectedRun:r,selectedRunId:F,setSelectedRunId:P,availability:h,loading:E,error:A,searchQuery:N,setSearchQuery:q,createRun:I,cancelRun:M,retryRun:T,exportRun:V,createTaskFromRun:U,attachRunToTask:$,statusCounts:S,refresh:w,uiError:k,runActionState:x}=Ue({projectId:n}),[d,D]=c.useState(""),[b,H]=c.useState(()=>ne(void 0)),[B,l]=c.useState([]),[o,p]=c.useState(!1),[R,y]=c.useState([]),[j,O]=c.useState(null),[L,W]=c.useState(null),Y=h.supportedProviders??Ve,J=b.searchProvider,Z=t=>t==="web-search"?!0:b.enabledSources[$e[t]];c.useEffect(()=>{const t=Y.filter(u=>Z(u));y(u=>{const f=u.filter(m=>t.includes(m));return f.length>0?f:t})},[b.enabledSources,Y]),c.useEffect(()=>{let t=!1;return Promise.all([Ae(n),Te().catch(()=>({providers:[]}))]).then(([u,f])=>{t||(H(ne(u)),l(f.providers.filter(m=>m.type==="api_key").map(m=>({id:m.id,authenticated:m.authenticated}))))}).catch(()=>{t||H(ne(void 0))}),()=>{t=!0}},[n,v]);const pe=c.useMemo(()=>r?r.status:s("research.noRunSelected","No run selected"),[r,s]),fe=c.useMemo(()=>r?r.status==="queued"||r.status==="retry_waiting"?"status-dot status-dot--pending":r.status==="running"?"status-dot status-dot--connecting":r.status==="completed"?"status-dot status-dot--online":r.status==="failed"||r.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[r]),ee=h.supportedExportFormats??["markdown","json","html"],se=c.useMemo(()=>new Map(B.map(t=>[t.id,t.authenticated])),[B]),re=c.useMemo(()=>{const t=new Set;return b.enabledSources.webSearch&&J&&t.add(J),b.enabledSources.llmSynthesis&&b.synthesisProvider&&t.add(b.synthesisProvider),[...t].filter(u=>se.has(u))},[b.enabledSources.llmSynthesis,b.enabledSources.webSearch,b.synthesisProvider,J,se]).find(t=>se.get(t)!==!0),G=c.useMemo(()=>h.available?b.enabled?re?{reason:s("research.missingApiKey","Missing API key for {{provider}}.",{provider:re}),details:s("research.addCredentialsHint","Add provider credentials in Authentication settings."),settingsSection:"authentication"}:null:{reason:s("research.disabled","Research is disabled for this project."),details:s("research.enableResearchHint","Enable project research settings to create runs."),settingsSection:"research-project"}:{reason:h.reason??s("research.unavailable","Research is unavailable for this project."),details:h.setupInstructions,settingsSection:"research-project"},[h.available,h.reason,h.setupInstructions,b.enabled,re,s]),K=async(t,u,f)=>{O(t);try{await u(),a?.(f,"success"),await w()}catch(m){a?.(m instanceof Error?m.message:s("research.actionFailed","Action failed"),"error")}finally{O(null)}},te=async t=>{if(r){O(`export-${t}`);try{const u=await V(r.id,t),f=new Blob([u.content],{type:"text/plain;charset=utf-8"}),m=URL.createObjectURL(f),C=document.createElement("a");C.href=m,C.download=u.filename,document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(m),a?.(s("research.exportedFile","Exported {{filename}}",{filename:u.filename}),"success")}catch(u){a?.(u instanceof Error?u.message:s("research.exportFailed","Export failed"),"error")}finally{O(null)}}},ve=async()=>{if(d.trim()){p(!0);try{const t=R.filter(f=>Z(f));if(t.length===0){p(!1),a?.(s("research.noSourcesAvailable","No enabled research sources are available for this project."),"error");return}const u=await I({query:d.trim(),providers:t});P(u.run.id),D(""),a?.(s("research.runCreated","Research run created"),"success"),await w()}catch(t){a?.(t instanceof Error?t.message:s("research.createRunFailed","Failed to create run"),"error")}finally{p(!1)}}};return e.jsxs("section",{className:"research-view","aria-label":s("research.viewLabel","Research view"),children:[e.jsx(Le,{icon:me,title:s("research.title","Research"),actions:e.jsx("button",{className:"btn",type:"button",onClick:()=>void w(),children:s("actions.refresh","Refresh")})}),e.jsx("p",{className:"research-view__subtitle",children:s("research.subtitle","Cited search and synthesis runs: gather sources, fetch content, and synthesize findings.")}),G?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:G.reason}),G.details&&e.jsx("p",{children:G.details}),e.jsx("p",{children:s("research.currentDefaults","Current defaults: provider {{provider}}, max sources {{maxSources}}",{provider:b.searchProvider??s("research.notSet","(not set)"),maxSources:b.limits.maxSourcesPerRun})}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void w(),children:s("actions.refresh","Refresh")}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>i?.(G.settingsSection),children:s("actions.openSettings","Open Settings")})]})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"research-view__layout",children:[e.jsx("aside",{className:"research-view__sidebar card",children:e.jsxs("div",{className:"research-view__sidebar-content",children:[e.jsxs("div",{className:"research-view__form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-query",children:s("research.queryLabel","Query")}),e.jsx("textarea",{id:"research-query",className:"input research-view__textarea",value:d,onChange:t=>D(t.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("research.providersLabel","Providers")}),e.jsx("div",{className:"research-view__providers",children:Y.map(t=>{const u=Z(t),f=t==="web-search";return e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:f||R.includes(t),disabled:f||!u,onChange:()=>{f||!u||y(m=>m.includes(t)?m.filter(C=>C!==t):[...m,t])}}),e.jsxs("span",{children:[_[t]??t,f?e.jsx("span",{className:"research-view__provider-lock",children:s("research.alwaysOn","Always on")}):null]})]},t)})})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!d.trim()||o,onClick:()=>void ve(),children:[o?e.jsx(Pe,{className:"animate-spin",size:14}):null,s("research.createRun","Create Run")]})]}),e.jsxs("div",{className:"research-view__history-header form-group",children:[e.jsx("label",{htmlFor:"research-run-search",children:s("actions.search","Search")}),e.jsxs("div",{className:"research-view__history-search-row",children:[e.jsx(me,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:s("research.searchRunsPlaceholder","Search runs"),value:N,onChange:t=>q(t.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:g.map(t=>e.jsxs("button",{type:"button",className:`research-view__history-item card${F===t.id?" research-view__history-item--active":""}`,onClick:()=>P(t.id),children:[e.jsx("span",{className:"card-id",children:t.id}),e.jsx("span",{children:t.title})]},t.id))})]})}),e.jsxs("div",{className:"research-view__reader card",children:[E&&e.jsx("p",{"data-testid":"research-state-loading",children:e.jsx(Fe,{label:s("research.loadingRuns","Loading research runs…")})}),!E&&A&&e.jsx("p",{"data-testid":"research-state-error",children:A}),!E&&!A&&g.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:s("research.noRunsYet","No research runs yet")}),e.jsxs("div",{className:"research-view__reader-content",children:[r&&e.jsxs("div",{className:"research-view__run-detail",children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:fe}),e.jsx("strong",{children:pe})]}),e.jsx("h3",{className:"research-view__run-title",children:r.title}),e.jsx("p",{className:"research-view__run-query",children:r.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:r.results?.summary??s("research.noSummaryYet","No summary yet.")}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",title:x.cancelable?void 0:x.blockingReason,disabled:j==="cancel"||j==="retry"||!x.cancelable,onClick:()=>void K("cancel",()=>M(r.id),s("research.runCancelled","Run cancelled")),children:s("actions.cancel","Cancel")}),e.jsx("button",{className:"btn",type:"button",title:x.retryable?void 0:x.blockingReason,disabled:j==="cancel"||j==="retry"||!x.retryable,onClick:()=>void K("retry",()=>T(r.id),s("research.runRetried","Run retried")),children:s("actions.retry","Retry")}),ee.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-markdown",onClick:()=>void te("markdown"),children:s("research.exportMd","Export MD")}),ee.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-json",onClick:()=>void te("json"),children:s("research.exportJson","Export JSON")}),ee.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-html",onClick:()=>void te("html"),children:s("research.exportHtml","Export HTML")})]}),r.error&&e.jsx("p",{className:"research-view__error",children:r.error}),k&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:k.message}),k.setupHint&&e.jsx("p",{children:k.setupHint}),k.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("authentication"),children:s("research.openAuthSettings","Open Authentication Settings")}),k.code==="FEATURE_DISABLED"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("research-project"),children:s("research.openResearchSettings","Open Research Settings")})]}),x.blockingReason&&e.jsx("p",{className:"research-view__run-query",children:x.blockingReason}),Array.isArray(r.results?.findings)&&r.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:r.results.findings.map((t,u)=>{const m=t.id?.trim()||`finding-${u+1}`;return e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:t.heading}),e.jsx("p",{children:t.content}),e.jsxs("div",{className:"research-view__actions research-view__finding-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",type:"button",onClick:()=>W({mode:"create",findingId:m}),children:s("research.createTask","Create Task")}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>W({mode:"enrich",findingId:m}),children:s("research.enrichTask","Enrich Task")})]})]},m)})}),Array.isArray(r.results?.citations)&&r.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:r.results.citations.map(t=>e.jsx("li",{children:e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:t})},t))}),r.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("research.runHistory","Run history")}),e.jsx("ul",{className:"research-view__events",children:r.events.map(t=>e.jsx("li",{children:t.message},t.id))})]})]}),!r&&g.length>0&&e.jsx("p",{children:s("research.selectRunToViewDetails","Select a run to view details.")}),e.jsxs("div",{className:"research-view__stats",children:[e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statRunning","Running")}),e.jsx("div",{className:"research-view__stat-value",children:S.running})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statCompleted","Completed")}),e.jsx("div",{className:"research-view__stat-value",children:S.completed})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statFailed","Failed")}),e.jsx("div",{className:"research-view__stat-value",children:S.failed})]})]})]})]})]})}),r&&L&&(()=>{const t=r.results?.findings?.findIndex((f,m)=>(f.id?.trim()||`finding-${m+1}`)===L.findingId)??-1,u=t>=0?r.results.findings[t]:null;return u?e.jsx(Oe,{open:!0,mode:L.mode,run:r,finding:{id:L.findingId,heading:u.heading,content:u.content},projectId:n,onClose:()=>W(null),onConfirm:async({taskId:f,title:m,description:C,priority:le,attachExport:oe})=>{L.mode==="create"?await K("create-task",()=>U(r.id,m,L.findingId,C,le,oe),s("research.taskCreatedFromResearch","Task created from research")):f&&await K("attach-task",()=>$(r.id,f,L.findingId,oe),s("research.taskEnrichedFromResearch","Task enriched from research")),W(null)}}):null})()]})}export{Je as ResearchView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{V as ue,B as he,R as q,P as me,D as G,F as Y,G as ye,H as xe,I as ve,J as be,o as je,C as fe}from"./index-B6ttSchA.js";import{u as Se}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const ge="__sync_passphrase__",L={key:"",value:"",description:"",scope:"project",accessPolicy:"prompt",envExportable:!1,envExportKey:""},n={className:"secrets-action-icon","aria-hidden":!0,style:{width:"1em",height:"1em"}},Ne={...n,className:"secrets-action-icon spin"},Re=({addToast:d})=>{const{t:a}=Se("app"),[R,z]=c.useState([]),[T,M]=c.useState(!0),[A,D]=c.useState(null),[K,b]=c.useState(null),[p,O]=c.useState(null),[U,y]=c.useState(!1),[Q,g]=c.useState(null),[t,l]=c.useState(L),[N,C]=c.useState(!1),[V,j]=c.useState({}),[W,B]=c.useState(null),[u,X]=c.useState(!1),[Z,_]=c.useState(!1),[f,F]=c.useState(""),[P,H]=c.useState(""),[ee,I]=c.useState(!1),[E,se]=c.useState(!1),m=c.useRef(new Map),w=c.useRef(new Map),o=c.useCallback(async(s,r)=>{const i=await fetch(s,{...r,headers:{"Content-Type":"application/json",...r?.headers??{}}});if(!i.ok){const h=await i.json().catch(()=>({error:"Request failed"}));throw new Error(String(h?.error??"Request failed"))}if(i.status!==204)return i.json()},[]),x=c.useCallback(async()=>{M(!0),D(null);try{const s=await o("/api/secrets");z(s.secrets)}catch(s){D(s instanceof Error?s.message:String(s))}finally{M(!1)}},[o]),S=c.useCallback(async()=>{try{const s=await o("/api/secrets/sync-passphrase");X(!!s.configured)}catch(s){d?.(a("secrets.errorLoadSyncStatus","Failed to load sync passphrase status: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}},[d,o]);c.useEffect(()=>(x(),S(),()=>{m.current.forEach(s=>clearTimeout(s)),w.current.forEach(s=>clearTimeout(s))}),[x,S]);const k=()=>{_(!1),F(""),H("")},ae=async s=>{await o("/api/secrets/sync-passphrase",{method:"PUT",body:JSON.stringify({passphrase:s})})},re=async()=>{I(!0);try{await ae(f),d?.(u?a("secrets.syncPassphraseRotated","Sync passphrase rotated"):a("secrets.syncPassphraseSet","Sync passphrase set"),"success"),k(),await S()}catch(s){d?.(a("secrets.errorSaveSyncPassphrase","Failed to save sync passphrase: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{I(!1)}},te=async()=>{if(window.confirm(a("secrets.confirmClearSyncPassphrase","Clear the cross-node sync passphrase? Existing sync pairs will stop working until you set a new passphrase.")))try{await o("/api/secrets/sync-passphrase",{method:"DELETE"}),d?.(a("secrets.syncPassphraseCleared","Sync passphrase cleared"),"success"),await S()}catch(r){d?.(a("secrets.errorClearSyncPassphrase","Failed to clear sync passphrase: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},ce=()=>{O(null),l(L),y(!0),C(!1),b(null)},le=s=>{O(s),l({key:s.key,value:"",description:s.description??"",scope:s.scope,accessPolicy:s.accessPolicy,envExportable:s.envExportable,envExportKey:s.envExportKey??""}),y(!0),C(!1),b(null)},ne=async()=>{b(null);try{if(p){const s={key:t.key,description:t.description||null,accessPolicy:t.accessPolicy,envExportable:t.envExportable,envExportKey:t.envExportable&&t.envExportKey||null};t.value&&(s.value=t.value),await o(`/api/secrets/${p.scope}/${p.id}`,{method:"PATCH",body:JSON.stringify(s)})}else await o("/api/secrets",{method:"POST",body:JSON.stringify({scope:t.scope,key:t.key,value:t.value,description:t.description||null,accessPolicy:t.accessPolicy,envExportable:t.envExportable,envExportKey:t.envExportable&&t.envExportKey||null})});y(!1),l(L),await x()}catch(s){b(s instanceof Error?s.message:String(s))}},oe=s=>{const r=m.current.get(s.id);r&&(clearTimeout(r),m.current.delete(s.id)),j(i=>({...i,[s.id]:null}))},ie=async s=>{const r=await o(`/api/secrets/${s.scope}/${s.id}/reveal`,{method:"POST"});j(v=>({...v,[s.id]:r.value})),d?.(a("secrets.revealed","Revealed"),"success");const i=setTimeout(()=>{j(v=>({...v,[s.id]:null})),m.current.delete(s.id)},3e4),h=m.current.get(s.id);h&&clearTimeout(h),m.current.set(s.id,i)},de=async s=>{const r=V[s.id];if(!r)return;await navigator.clipboard.writeText(r),B(s.id),d?.(a("secrets.copied","Copied"),"success");const i=setTimeout(()=>{B(null),j(v=>({...v,[s.id]:null}))},1500),h=w.current.get(s.id);h&&clearTimeout(h),w.current.set(s.id,i)},pe=async s=>{await o(`/api/secrets/${s.scope}/${s.id}`,{method:"DELETE"}),g(null),await x()},$=c.useMemo(()=>[...R].filter(s=>!(s.scope==="global"&&s.key===ge)).sort((s,r)=>s.key.localeCompare(r.key)),[R]),J=f.length>0&&f===P;return e.jsxs("section",{className:"secrets-view",children:[e.jsx(ue,{icon:he,title:a("secrets.title","Secrets"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void x(),children:[e.jsx(q,{...n})," ",a("secrets.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:ce,children:[e.jsx(me,{...n})," ",a("secrets.addSecret","Add Secret")]})]})}),A?e.jsx("div",{className:"form-error",children:A}):null,T?e.jsxs("div",{className:"secrets-loading",children:[e.jsx(q,{...Ne})," ",a("secrets.loading","Loading…")]}):null,!T&&$.length===0?e.jsx("div",{className:"secrets-empty",children:a("secrets.empty","No secrets found.")}):null,e.jsx("div",{className:"secrets-list",children:$.map(s=>{const r=V[s.id];return e.jsxs("article",{className:"card secrets-row",children:[e.jsxs("div",{className:"secrets-row-main",children:[e.jsx("div",{className:"secrets-row-key",children:s.key}),e.jsxs("div",{className:"secrets-row-meta",children:[e.jsx("span",{className:"secrets-chip",children:s.scope}),e.jsx("span",{className:"secrets-chip",children:s.accessPolicy}),s.envExportable?e.jsx("span",{className:"secrets-chip",children:a("secrets.envExportableChip","env exportable")}):null]}),r?e.jsx("pre",{className:"secrets-revealed",children:r}):null]}),e.jsxs("div",{className:"secrets-row-side",children:[e.jsx("span",{className:"secrets-row-read",children:s.lastReadAt?new Date(s.lastReadAt).toLocaleString():a("secrets.neverRead","Never read")}),e.jsxs("div",{className:"secrets-row-actions",children:[e.jsx("button",{type:"button",className:"btn btn-icon secrets-visibility-toggle",onClick:()=>{if(r){oe(s);return}ie(s)},"aria-label":r?a("secrets.hideAriaLabel","Hide"):a("secrets.revealAriaLabel","Reveal"),children:r?e.jsx(G,{...n}):e.jsx(Y,{...n})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>void de(s),"aria-label":a("secrets.copyAriaLabel","Copy"),disabled:!r,children:W===s.id?e.jsx(ye,{...n}):e.jsx(xe,{...n})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>le(s),"aria-label":a("secrets.editAriaLabel","Edit"),children:e.jsx(ve,{...n})}),e.jsx("button",{className:"btn btn-icon btn-danger",onClick:()=>g(s.id),"aria-label":a("secrets.deleteAriaLabel","Delete"),children:e.jsx(be,{...n})})]}),Q===s.id?e.jsxs("div",{className:"secrets-confirm",children:[e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void pe(s),children:a("secrets.confirmDelete","Confirm")}),e.jsx("button",{className:"btn btn-sm",onClick:()=>g(null),children:a("secrets.cancelDelete","Cancel")})]}):null]})]},s.id)})}),e.jsxs("article",{className:"card secrets-sync-card secrets-sync-disclosure",children:[e.jsxs("button",{type:"button",className:"secrets-sync-disclosure-toggle","data-testid":"secrets-passphrase-disclosure","aria-expanded":E,"aria-controls":"secrets-sync-disclosure-panel",onClick:()=>se(s=>!s),children:[E?e.jsx(je,{size:16,"aria-hidden":"true"}):e.jsx(fe,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:a("secrets.syncPassphraseTitle","Cross-Node Sync Passphrase")})]}),E?e.jsxs("div",{id:"secrets-sync-disclosure-panel",className:"secrets-sync-disclosure-panel",children:[e.jsxs("div",{className:"secrets-sync-header",children:[e.jsxs("p",{className:"secrets-sync-status",children:[e.jsx("span",{className:`status-dot ${u?"status-dot--online":"status-dot--pending"}`,"aria-hidden":"true"})," ",u?a("secrets.syncConfigured","Configured"):a("secrets.syncNotConfigured","Not configured")]}),e.jsxs("div",{className:"secrets-sync-actions",children:[e.jsx("button",{className:"btn",onClick:()=>_(!0),children:u?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")}),u?e.jsx("button",{className:"btn btn-danger",onClick:()=>void te(),children:a("secrets.clearSyncPassphrase","Clear")}):null]})]}),e.jsx("p",{className:"secrets-sync-copy",children:a("secrets.syncPassphraseDescription","Shared passphrase used to wrap cross-node secret bundles. Both nodes in a sync pair must share the same value. Stored locally only; never transmitted.")})]}):null]}),Z?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":u?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:u?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase")}),e.jsx("button",{className:"modal-close",onClick:k,"aria-label":a("secrets.closeAriaLabel","Close"),children:"×"})]}),e.jsxs("div",{className:"secrets-modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.passphraseLabel","Passphrase")}),e.jsx("input",{"aria-label":a("secrets.passphraseLabel","Passphrase"),className:"input",type:"password",autoComplete:"new-password",value:f,onChange:s=>F(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.confirmPassphraseLabel","Confirm passphrase")}),e.jsx("input",{"aria-label":a("secrets.confirmPassphraseLabel","Confirm passphrase"),className:"input",type:"password",autoComplete:"new-password",value:P,onChange:s=>H(s.target.value)})]}),!J&&P.length>0?e.jsx("div",{className:"form-error",children:a("secrets.passphraseMustMatch","Passphrases must match.")}):null]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn",onClick:k,children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void re(),disabled:!J||ee,children:u?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")})]})})]})}):null,U?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":p?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:p?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret")}),e.jsx("button",{className:"modal-close",onClick:()=>y(!1),"aria-label":a("secrets.closeAriaLabel","Close"),children:"×"})]}),e.jsxs("div",{className:"secrets-modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.keyLabel","Key")}),e.jsx("input",{className:"input",value:t.key,onChange:s=>l(r=>({...r,key:s.target.value}))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.valueLabel","Value")}),e.jsxs("div",{className:"secrets-value-row",children:[e.jsx("input",{className:"input",type:N?"text":"password",autoComplete:"off",spellCheck:!1,value:t.value,onChange:s=>l(r=>({...r,value:s.target.value}))}),e.jsx("button",{type:"button",className:"btn btn-icon secrets-visibility-toggle",onClick:()=>C(s=>!s),"aria-label":N?a("secrets.hideValueAriaLabel","Hide value"):a("secrets.showValueAriaLabel","Show value"),children:N?e.jsx(G,{...n}):e.jsx(Y,{...n})})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.descriptionLabel","Description")}),e.jsx("textarea",{className:"input",value:t.description,onChange:s=>l(r=>({...r,description:s.target.value}))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.scopeLabel","Scope")}),e.jsxs("div",{className:"secrets-radio-row",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t.scope==="project",onChange:()=>l(s=>({...s,scope:"project"})),disabled:!!p})," ",a("secrets.scopeProject","Project")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t.scope==="global",onChange:()=>l(s=>({...s,scope:"global"})),disabled:!!p})," ",a("secrets.scopeGlobal","Global")]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.accessPolicyLabel","Access policy")}),e.jsxs("select",{className:"select",value:t.accessPolicy,onChange:s=>l(r=>({...r,accessPolicy:s.target.value})),children:[e.jsx("option",{value:"auto",children:a("secrets.accessPolicyAuto","auto")}),e.jsx("option",{value:"prompt",children:a("secrets.accessPolicyPrompt","prompt")}),e.jsx("option",{value:"deny",children:a("secrets.accessPolicyDeny","deny")})]})]}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t.envExportable,onChange:s=>l(r=>({...r,envExportable:s.target.checked}))})," ",a("secrets.exportToEnvLabel","Export to env")]})}),t.envExportable?e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.envKeyLabel","Env key")}),e.jsx("input",{className:"input",value:t.envExportKey,onChange:s=>l(r=>({...r,envExportKey:s.target.value}))})]}):null,K?e.jsx("div",{className:"form-error",children:K}):null]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn",onClick:()=>y(!1),children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void ne(),children:p?a("secrets.saveBtn","Save"):a("secrets.createBtn","Create")})]})})]})}):null]})};export{Re as SecretsView};
|
|
1
|
+
import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{V as ue,B as he,R as q,P as me,D as G,F as Y,G as ye,H as xe,I as ve,J as be,o as je,C as fe}from"./index-rfsTNfpA.js";import{u as Se}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const ge="__sync_passphrase__",L={key:"",value:"",description:"",scope:"project",accessPolicy:"prompt",envExportable:!1,envExportKey:""},n={className:"secrets-action-icon","aria-hidden":!0,style:{width:"1em",height:"1em"}},Ne={...n,className:"secrets-action-icon spin"},Re=({addToast:d})=>{const{t:a}=Se("app"),[R,z]=c.useState([]),[T,M]=c.useState(!0),[A,D]=c.useState(null),[K,b]=c.useState(null),[p,O]=c.useState(null),[U,y]=c.useState(!1),[Q,g]=c.useState(null),[t,l]=c.useState(L),[N,C]=c.useState(!1),[V,j]=c.useState({}),[W,B]=c.useState(null),[u,X]=c.useState(!1),[Z,_]=c.useState(!1),[f,F]=c.useState(""),[P,H]=c.useState(""),[ee,I]=c.useState(!1),[E,se]=c.useState(!1),m=c.useRef(new Map),w=c.useRef(new Map),o=c.useCallback(async(s,r)=>{const i=await fetch(s,{...r,headers:{"Content-Type":"application/json",...r?.headers??{}}});if(!i.ok){const h=await i.json().catch(()=>({error:"Request failed"}));throw new Error(String(h?.error??"Request failed"))}if(i.status!==204)return i.json()},[]),x=c.useCallback(async()=>{M(!0),D(null);try{const s=await o("/api/secrets");z(s.secrets)}catch(s){D(s instanceof Error?s.message:String(s))}finally{M(!1)}},[o]),S=c.useCallback(async()=>{try{const s=await o("/api/secrets/sync-passphrase");X(!!s.configured)}catch(s){d?.(a("secrets.errorLoadSyncStatus","Failed to load sync passphrase status: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}},[d,o]);c.useEffect(()=>(x(),S(),()=>{m.current.forEach(s=>clearTimeout(s)),w.current.forEach(s=>clearTimeout(s))}),[x,S]);const k=()=>{_(!1),F(""),H("")},ae=async s=>{await o("/api/secrets/sync-passphrase",{method:"PUT",body:JSON.stringify({passphrase:s})})},re=async()=>{I(!0);try{await ae(f),d?.(u?a("secrets.syncPassphraseRotated","Sync passphrase rotated"):a("secrets.syncPassphraseSet","Sync passphrase set"),"success"),k(),await S()}catch(s){d?.(a("secrets.errorSaveSyncPassphrase","Failed to save sync passphrase: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{I(!1)}},te=async()=>{if(window.confirm(a("secrets.confirmClearSyncPassphrase","Clear the cross-node sync passphrase? Existing sync pairs will stop working until you set a new passphrase.")))try{await o("/api/secrets/sync-passphrase",{method:"DELETE"}),d?.(a("secrets.syncPassphraseCleared","Sync passphrase cleared"),"success"),await S()}catch(r){d?.(a("secrets.errorClearSyncPassphrase","Failed to clear sync passphrase: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},ce=()=>{O(null),l(L),y(!0),C(!1),b(null)},le=s=>{O(s),l({key:s.key,value:"",description:s.description??"",scope:s.scope,accessPolicy:s.accessPolicy,envExportable:s.envExportable,envExportKey:s.envExportKey??""}),y(!0),C(!1),b(null)},ne=async()=>{b(null);try{if(p){const s={key:t.key,description:t.description||null,accessPolicy:t.accessPolicy,envExportable:t.envExportable,envExportKey:t.envExportable&&t.envExportKey||null};t.value&&(s.value=t.value),await o(`/api/secrets/${p.scope}/${p.id}`,{method:"PATCH",body:JSON.stringify(s)})}else await o("/api/secrets",{method:"POST",body:JSON.stringify({scope:t.scope,key:t.key,value:t.value,description:t.description||null,accessPolicy:t.accessPolicy,envExportable:t.envExportable,envExportKey:t.envExportable&&t.envExportKey||null})});y(!1),l(L),await x()}catch(s){b(s instanceof Error?s.message:String(s))}},oe=s=>{const r=m.current.get(s.id);r&&(clearTimeout(r),m.current.delete(s.id)),j(i=>({...i,[s.id]:null}))},ie=async s=>{const r=await o(`/api/secrets/${s.scope}/${s.id}/reveal`,{method:"POST"});j(v=>({...v,[s.id]:r.value})),d?.(a("secrets.revealed","Revealed"),"success");const i=setTimeout(()=>{j(v=>({...v,[s.id]:null})),m.current.delete(s.id)},3e4),h=m.current.get(s.id);h&&clearTimeout(h),m.current.set(s.id,i)},de=async s=>{const r=V[s.id];if(!r)return;await navigator.clipboard.writeText(r),B(s.id),d?.(a("secrets.copied","Copied"),"success");const i=setTimeout(()=>{B(null),j(v=>({...v,[s.id]:null}))},1500),h=w.current.get(s.id);h&&clearTimeout(h),w.current.set(s.id,i)},pe=async s=>{await o(`/api/secrets/${s.scope}/${s.id}`,{method:"DELETE"}),g(null),await x()},$=c.useMemo(()=>[...R].filter(s=>!(s.scope==="global"&&s.key===ge)).sort((s,r)=>s.key.localeCompare(r.key)),[R]),J=f.length>0&&f===P;return e.jsxs("section",{className:"secrets-view",children:[e.jsx(ue,{icon:he,title:a("secrets.title","Secrets"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void x(),children:[e.jsx(q,{...n})," ",a("secrets.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:ce,children:[e.jsx(me,{...n})," ",a("secrets.addSecret","Add Secret")]})]})}),A?e.jsx("div",{className:"form-error",children:A}):null,T?e.jsxs("div",{className:"secrets-loading",children:[e.jsx(q,{...Ne})," ",a("secrets.loading","Loading…")]}):null,!T&&$.length===0?e.jsx("div",{className:"secrets-empty",children:a("secrets.empty","No secrets found.")}):null,e.jsx("div",{className:"secrets-list",children:$.map(s=>{const r=V[s.id];return e.jsxs("article",{className:"card secrets-row",children:[e.jsxs("div",{className:"secrets-row-main",children:[e.jsx("div",{className:"secrets-row-key",children:s.key}),e.jsxs("div",{className:"secrets-row-meta",children:[e.jsx("span",{className:"secrets-chip",children:s.scope}),e.jsx("span",{className:"secrets-chip",children:s.accessPolicy}),s.envExportable?e.jsx("span",{className:"secrets-chip",children:a("secrets.envExportableChip","env exportable")}):null]}),r?e.jsx("pre",{className:"secrets-revealed",children:r}):null]}),e.jsxs("div",{className:"secrets-row-side",children:[e.jsx("span",{className:"secrets-row-read",children:s.lastReadAt?new Date(s.lastReadAt).toLocaleString():a("secrets.neverRead","Never read")}),e.jsxs("div",{className:"secrets-row-actions",children:[e.jsx("button",{type:"button",className:"btn btn-icon secrets-visibility-toggle",onClick:()=>{if(r){oe(s);return}ie(s)},"aria-label":r?a("secrets.hideAriaLabel","Hide"):a("secrets.revealAriaLabel","Reveal"),children:r?e.jsx(G,{...n}):e.jsx(Y,{...n})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>void de(s),"aria-label":a("secrets.copyAriaLabel","Copy"),disabled:!r,children:W===s.id?e.jsx(ye,{...n}):e.jsx(xe,{...n})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>le(s),"aria-label":a("secrets.editAriaLabel","Edit"),children:e.jsx(ve,{...n})}),e.jsx("button",{className:"btn btn-icon btn-danger",onClick:()=>g(s.id),"aria-label":a("secrets.deleteAriaLabel","Delete"),children:e.jsx(be,{...n})})]}),Q===s.id?e.jsxs("div",{className:"secrets-confirm",children:[e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void pe(s),children:a("secrets.confirmDelete","Confirm")}),e.jsx("button",{className:"btn btn-sm",onClick:()=>g(null),children:a("secrets.cancelDelete","Cancel")})]}):null]})]},s.id)})}),e.jsxs("article",{className:"card secrets-sync-card secrets-sync-disclosure",children:[e.jsxs("button",{type:"button",className:"secrets-sync-disclosure-toggle","data-testid":"secrets-passphrase-disclosure","aria-expanded":E,"aria-controls":"secrets-sync-disclosure-panel",onClick:()=>se(s=>!s),children:[E?e.jsx(je,{size:16,"aria-hidden":"true"}):e.jsx(fe,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:a("secrets.syncPassphraseTitle","Cross-Node Sync Passphrase")})]}),E?e.jsxs("div",{id:"secrets-sync-disclosure-panel",className:"secrets-sync-disclosure-panel",children:[e.jsxs("div",{className:"secrets-sync-header",children:[e.jsxs("p",{className:"secrets-sync-status",children:[e.jsx("span",{className:`status-dot ${u?"status-dot--online":"status-dot--pending"}`,"aria-hidden":"true"})," ",u?a("secrets.syncConfigured","Configured"):a("secrets.syncNotConfigured","Not configured")]}),e.jsxs("div",{className:"secrets-sync-actions",children:[e.jsx("button",{className:"btn",onClick:()=>_(!0),children:u?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")}),u?e.jsx("button",{className:"btn btn-danger",onClick:()=>void te(),children:a("secrets.clearSyncPassphrase","Clear")}):null]})]}),e.jsx("p",{className:"secrets-sync-copy",children:a("secrets.syncPassphraseDescription","Shared passphrase used to wrap cross-node secret bundles. Both nodes in a sync pair must share the same value. Stored locally only; never transmitted.")})]}):null]}),Z?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":u?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:u?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase")}),e.jsx("button",{className:"modal-close",onClick:k,"aria-label":a("secrets.closeAriaLabel","Close"),children:"×"})]}),e.jsxs("div",{className:"secrets-modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.passphraseLabel","Passphrase")}),e.jsx("input",{"aria-label":a("secrets.passphraseLabel","Passphrase"),className:"input",type:"password",autoComplete:"new-password",value:f,onChange:s=>F(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.confirmPassphraseLabel","Confirm passphrase")}),e.jsx("input",{"aria-label":a("secrets.confirmPassphraseLabel","Confirm passphrase"),className:"input",type:"password",autoComplete:"new-password",value:P,onChange:s=>H(s.target.value)})]}),!J&&P.length>0?e.jsx("div",{className:"form-error",children:a("secrets.passphraseMustMatch","Passphrases must match.")}):null]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn",onClick:k,children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void re(),disabled:!J||ee,children:u?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")})]})})]})}):null,U?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":p?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:p?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret")}),e.jsx("button",{className:"modal-close",onClick:()=>y(!1),"aria-label":a("secrets.closeAriaLabel","Close"),children:"×"})]}),e.jsxs("div",{className:"secrets-modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.keyLabel","Key")}),e.jsx("input",{className:"input",value:t.key,onChange:s=>l(r=>({...r,key:s.target.value}))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.valueLabel","Value")}),e.jsxs("div",{className:"secrets-value-row",children:[e.jsx("input",{className:"input",type:N?"text":"password",autoComplete:"off",spellCheck:!1,value:t.value,onChange:s=>l(r=>({...r,value:s.target.value}))}),e.jsx("button",{type:"button",className:"btn btn-icon secrets-visibility-toggle",onClick:()=>C(s=>!s),"aria-label":N?a("secrets.hideValueAriaLabel","Hide value"):a("secrets.showValueAriaLabel","Show value"),children:N?e.jsx(G,{...n}):e.jsx(Y,{...n})})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.descriptionLabel","Description")}),e.jsx("textarea",{className:"input",value:t.description,onChange:s=>l(r=>({...r,description:s.target.value}))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.scopeLabel","Scope")}),e.jsxs("div",{className:"secrets-radio-row",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t.scope==="project",onChange:()=>l(s=>({...s,scope:"project"})),disabled:!!p})," ",a("secrets.scopeProject","Project")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t.scope==="global",onChange:()=>l(s=>({...s,scope:"global"})),disabled:!!p})," ",a("secrets.scopeGlobal","Global")]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.accessPolicyLabel","Access policy")}),e.jsxs("select",{className:"select",value:t.accessPolicy,onChange:s=>l(r=>({...r,accessPolicy:s.target.value})),children:[e.jsx("option",{value:"auto",children:a("secrets.accessPolicyAuto","auto")}),e.jsx("option",{value:"prompt",children:a("secrets.accessPolicyPrompt","prompt")}),e.jsx("option",{value:"deny",children:a("secrets.accessPolicyDeny","deny")})]})]}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t.envExportable,onChange:s=>l(r=>({...r,envExportable:s.target.checked}))})," ",a("secrets.exportToEnvLabel","Export to env")]})}),t.envExportable?e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.envKeyLabel","Env key")}),e.jsx("input",{className:"input",value:t.envExportKey,onChange:s=>l(r=>({...r,envExportKey:s.target.value}))})]}):null,K?e.jsx("div",{className:"form-error",children:K}):null]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn",onClick:()=>y(!1),children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void ne(),children:p?a("secrets.saveBtn","Save"):a("secrets.createBtn","Create")})]})})]})}):null]})};export{Re as SecretsView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-xterm-BNq00GSj.js","assets/vendor-react-SZ_qB27O.js","assets/vendor-xterm-LZoznX6r.css","assets/addon-fit-C1WQXRvu.js","assets/addon-unicode11-BVmNDUBM.js","assets/addon-webgl-uLc0RKcC.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{W as Te,Y as Q,$ as le,a0 as V,a1 as ce,a2 as F,a3 as Ce,a4 as ge,F as xe,a5 as J,a6 as Ne,a7 as Re,a8 as Pe,_ as B,a9 as je,aa as Me}from"./index-rfsTNfpA.js";import{r as i,j as t}from"./vendor-react-SZ_qB27O.js";import"./vendor-xterm-BNq00GSj.js";import{u as De}from"./vendor-i18n-GF3RlKbq.js";import{S as Le}from"./shield-alert-DjhYmFaV.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";const Oe=32*1024,Ae=100,ze="\x1B",Fe=" ",Be="",Ie="\x1B[A",Ke="\x1B[B",We="\x1B[C",$e="\x1B[D",I={ctrl:"Ctrl",escape:"Esc",tab:"Tab",ctrlC:"^C"};function de(u){if(u.length!==1)return null;const o=u.toUpperCase().charCodeAt(0);return o>=64&&o<=95?String.fromCharCode(o&31):null}function Ue(){const[u,f]=i.useState(()=>J());return i.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const o=window.matchMedia(Ne),a=window.visualViewport,y=()=>f(J());return y(),typeof a?.addEventListener=="function"&&a.addEventListener("resize",y),typeof o.addEventListener=="function"?(o.addEventListener("change",y),()=>{o.removeEventListener("change",y),typeof a?.removeEventListener=="function"&&a.removeEventListener("resize",y)}):(o.addListener(y),()=>{o.removeListener(y),typeof a?.removeEventListener=="function"&&a.removeEventListener("resize",y)})},[]),u}function Qe(u,f){if(typeof window>"u")return"";const a=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/cli-sessions/ws?sessionId=${encodeURIComponent(u)}&ticket=${encodeURIComponent(f)}`;return Me(a)}function Ve(){return/Mac|iPhone|iPad|iPod/i.test(navigator.platform)}function Je(u){if(typeof window<"u"&&typeof window.atob=="function"){const f=window.atob(u),o=new Uint8Array(f.length);for(let a=0;a<f.length;a++)o[a]=f.charCodeAt(a);return new TextDecoder("utf-8").decode(o)}return Buffer.from(u,"base64").toString("utf8")}function it({sessionId:u,readOnly:f=!1,posture:o,mode:a="live",projectId:y,onConfirmAdvance:E,showConfirmAdvance:K=!1,onOpenAdapterSettings:Y}){const{t:r}=De("app"),T=i.useRef(null),C=i.useRef(null),j=i.useRef(null),_=i.useRef(null),[H,G]=i.useState(!1),[ue,W]=i.useState(!1),[Z,q]=i.useState(!1),g=Ue(),{keyboardOpen:O,keyboardOverlap:me}=Te({enabled:g}),fe=i.useRef(null),[S,X]=i.useState(""),[x,A]=i.useState(!1),[ee,te]=i.useState(null),ne=f||ee===!0,M=!f&&ee===!1&&a==="live",b=i.useCallback(e=>{if(!e||!M)return;const n=_.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:"input",data:e}))},[M]),N=i.useCallback(e=>{if(x){const n=de(e);if(A(!1),n){b(n);return}}b(e)},[x,b]),c=i.useCallback(e=>{e.preventDefault()},[]),pe=i.useCallback(e=>{e?.preventDefault?.(),S&&b(S),b("\r"),X("")},[S,b]),ye=i.useCallback(e=>{if(x&&e.length>S.length){const n=e.slice(S.length,S.length+1),d=de(n);if(A(!1),d){b(d);return}}X(e)},[x,S,b]);i.useEffect(()=>{K&&W(!1)},[K,u]);const D=i.useCallback((e,n)=>{const d=_.current;d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"resize",cols:e,rows:n}))},[]),ie=i.useCallback(()=>{const e=C.current;if(!e)return;const n=Q(),d=le(n.fontFamily);e.options.fontFamily=d,T.current?.style.setProperty("--terminal-glyph-font-family",V(n.fontFamily)),e.options.fontSize=n.fontSize,e.options.cursorStyle=n.cursorStyle,e.options.cursorBlink=n.cursorBlink&&M;try{j.current?.fit?.(),D(e.cols,e.rows)}catch{}ce(n.fontSize,d).then(R=>{if(!(!R||C.current!==e||e.options.fontSize!==n.fontSize||e.options.fontFamily!==d)){F(e,d),e.options.fontSize=n.fontSize;try{j.current?.fit?.(),D(e.cols,e.rows),F(e,d),e.refresh(0,Math.max(0,e.rows-1))}catch{}}},()=>{})},[M,D]);i.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.key===Re&&ie()};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[ie]),i.useEffect(()=>{if(!u||typeof window>"u")return;let e=!1,n=null,d=null,R=0;te(null);const $=D,_e=p=>{if(R+=p,R<Oe)return;const h=_.current;h?.readyState===WebSocket.OPEN&&h.send(JSON.stringify({type:"ack",bytes:R})),R=0};return(async()=>{let p;try{p=await Pe(`/cli-sessions/${encodeURIComponent(u)}/attach-ticket`,{method:"POST",body:JSON.stringify(y?{projectId:y}:{})})}catch{return}if(e)return;te(p.readOnly);const h=!f&&!p.readOnly&&a==="live",[{Terminal:Se},{FitAddon:ke},{Unicode11Addon:ve}]=await Promise.all([B(()=>import("./vendor-xterm-BNq00GSj.js").then(l=>l.x),__vite__mapDeps([0,1,2])),B(()=>import("./addon-fit-C1WQXRvu.js").then(l=>l.a),__vite__mapDeps([3,1])),B(()=>import("./addon-unicode11-BVmNDUBM.js").then(l=>l.a),__vite__mapDeps([4,1]))]);if(e||!T.current)return;const w=Q(),L=le(w.fontFamily);T.current.style.setProperty("--terminal-glyph-font-family",V(w.fontFamily));const s=new Se({convertEol:!1,cursorBlink:w.cursorBlink&&h,cursorStyle:w.cursorStyle,disableStdin:!h,scrollback:1e4,fontFamily:L,fontSize:w.fontSize}),P=new ke;s.loadAddon(P);const Ee=new ve;if(s.loadAddon(Ee),s.unicode.activeVersion="11",je(()=>{s.open(T.current)}),C.current=s,j.current=P,w.renderer==="auto"&&!J())try{const{WebglAddon:l}=await B(async()=>{const{WebglAddon:m}=await import("./addon-webgl-uLc0RKcC.js").then(k=>k.a);return{WebglAddon:m}},__vite__mapDeps([5,1]));if(!e){const m=new l;m.onContextLoss(()=>{try{m.dispose()}catch{}}),s.loadAddon(m)}}catch{}try{P.fit()}catch{}(async()=>{if(!(!await ce(w.fontSize,L)||e||C.current!==s||j.current!==P||s.options.fontSize!==w.fontSize||s.options.fontFamily!==L))try{F(s,L),s.options.fontSize=w.fontSize,P.fit(),$(s.cols,s.rows),F(s,L),s.refresh(0,Math.max(0,s.rows-1))}catch{}})(),h&&(s.onData(l=>{const m=_.current;m?.readyState===WebSocket.OPEN&&m.send(JSON.stringify({type:"input",data:l}))}),s.attachCustomKeyEventHandler(l=>{if(l.type!=="keydown"||!(Ve()?l.metaKey:l.ctrlKey)||l.altKey||l.shiftKey)return!0;const k=l.key.toLowerCase();if(k==="c"){const v=s.hasSelection()?s.getSelection():"";return v?(navigator.clipboard?.writeText(v).catch(()=>{}),!1):!0}if(k==="v"){const v=navigator.clipboard?.readText;return v&&v.call(navigator.clipboard).then(ae=>{if(!ae)return;const re=_.current;re?.readyState===WebSocket.OPEN&&re.send(JSON.stringify({type:"input",data:ae}))}).catch(()=>{}),!1}return!0})),n=new ResizeObserver(()=>{d&&clearTimeout(d),d=setTimeout(()=>{try{P.fit(),$(s.cols,s.rows)}catch{}},Ae)}),n.observe(T.current);const U=new WebSocket(Qe(u,p.ticket));_.current=U,U.onopen=()=>{$(s.cols,s.rows)},U.onmessage=l=>{let m;try{m=JSON.parse(typeof l.data=="string"?l.data:"")}catch{return}switch(m.type){case"scrollback":case"data":{if(typeof m.data!="string")return;const k=Je(m.data),v=k.length;s.write(k,()=>_e(v));break}}}})(),()=>{e=!0,d&&clearTimeout(d),n&&n.disconnect();const p=_.current;if(p){p.onopen=null,p.onmessage=null,p.onclose=null,p.onerror=null;try{p.close()}catch{}_.current=null}const h=C.current;if(h){try{h.dispose()}catch{}C.current=null}j.current=null}},[u,f,a,y,D]);const se=i.useMemo(()=>a==="idle"?r("cliTerminal.replayIdle","Session idle"):a==="ended"?r("cliTerminal.replayEnded","Session ended"):null,[a,r]),be=i.useCallback(async()=>{if(E){q(!0);try{await E("advance"),W(!0)}finally{q(!1)}}},[E]),he=i.useCallback(async()=>{E&&await E("not-yet"),W(!0)},[E]),z=!!o?.elevated,oe=o?.elevatedFlags?.join(", "),we={"--terminal-glyph-font-family":V(Q().fontFamily)};return t.jsxs("div",{className:`cli-session-terminal${g?" cli-session-terminal--mobile":""}${g&&O?" cli-session-terminal--keyboard-open":""}`,"data-mode":a,"data-read-only":ne,"data-mobile":g,"data-keyboard-open":g&&O,children:[t.jsxs("header",{className:"cli-session-terminal__header",children:[o&&t.jsxs("div",{className:"cli-session-terminal__posture-wrap",children:[t.jsxs("button",{type:"button",className:`cli-posture-chip${z?" cli-posture-chip--elevated":""}`,"data-elevated":z,"aria-expanded":H,onClick:()=>G(e=>!e),children:[z?t.jsx(Le,{size:13,"aria-hidden":"true"}):t.jsx(Ce,{size:13,"aria-hidden":"true"}),t.jsx("span",{className:"cli-posture-chip__name",children:o.adapterName}),o.mode&&t.jsx("span",{className:"cli-posture-chip__mode",children:o.mode}),z&&oe&&t.jsx("span",{className:"cli-posture-chip__flag",children:oe})]}),H&&t.jsxs("div",{className:"cli-posture-tooltip",role:"tooltip",children:[t.jsx("p",{className:"cli-posture-tooltip__title",children:r("cliTerminal.postureResolved","Resolved posture")}),t.jsxs("ul",{className:"cli-posture-tooltip__list",children:[(o.resolved??[]).map((e,n)=>t.jsx("li",{children:e},n)),(o.resolved??[]).length===0&&t.jsx("li",{children:o.mode??r("cliTerminal.postureBaseline","Baseline")})]}),Y&&t.jsxs("button",{type:"button",className:"cli-posture-tooltip__settings",onClick:()=>{G(!1),Y()},children:[t.jsx(ge,{size:12,"aria-hidden":"true"}),r("cliTerminal.adapterSettings","Adapter settings")]})]})]}),ne&&t.jsxs("span",{className:"cli-session-terminal__readonly-badge",children:[t.jsx(xe,{size:12,"aria-hidden":"true"}),r("cliTerminal.readOnly","Read-only")]}),se&&t.jsx("span",{className:"cli-session-terminal__replay-badge","data-replay-mode":a,children:se})]}),t.jsx("div",{className:"cli-session-terminal__viewport",ref:T,"data-testid":"cli-terminal-viewport",style:we}),K&&!ue&&t.jsxs("div",{className:"cli-session-terminal__advance-strip",role:"region",children:[t.jsx("span",{className:"cli-session-terminal__advance-copy",children:r("cliTerminal.advancePrompt","This session looks idle — advance to review?")}),t.jsxs("div",{className:"cli-session-terminal__advance-actions",children:[t.jsx("button",{type:"button",className:"cli-session-terminal__advance-btn",disabled:Z,onClick:be,children:r("cliTerminal.advance","Advance")}),t.jsx("button",{type:"button",className:"cli-session-terminal__advance-btn cli-session-terminal__advance-btn--secondary",disabled:Z,onClick:he,children:r("cliTerminal.notYet","Not yet")})]})]}),g&&M&&t.jsxs("div",{className:`cli-session-terminal__mobile-bar${O?" cli-session-terminal__mobile-bar--keyboard-open":""}`,"data-testid":"cli-terminal-mobile-bar",style:O?{bottom:`${me}px`}:void 0,children:[t.jsxs("div",{className:"cli-session-terminal__key-row","data-testid":"cli-terminal-key-bar",children:[t.jsx("button",{type:"button",className:`cli-terminal-key cli-terminal-key--ctrl${x?" cli-terminal-key--active":""}`,"data-testid":"cli-key-ctrl","aria-label":r("cliTerminal.mobileKeyCtrl","Sticky Ctrl modifier"),"aria-pressed":x,onPointerDown:c,onMouseDown:c,onClick:()=>A(e=>!e),children:I.ctrl}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-esc","aria-label":r("cliTerminal.mobileKeyEsc","Send Escape"),onPointerDown:c,onMouseDown:c,onClick:()=>N(ze),children:I.escape}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-tab","aria-label":r("cliTerminal.mobileKeyTab","Send Tab"),onPointerDown:c,onMouseDown:c,onClick:()=>N(Fe),children:I.tab}),t.jsx("button",{type:"button",className:"cli-terminal-key cli-terminal-key--ctrlc","data-testid":"cli-key-ctrl-c","aria-label":r("cliTerminal.mobileKeyCtrlC","Send Ctrl-C"),onPointerDown:c,onMouseDown:c,onClick:()=>{A(!1),b(Be)},children:I.ctrlC}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-up","aria-label":r("cliTerminal.mobileKeyArrowUp","Cursor up"),onPointerDown:c,onMouseDown:c,onClick:()=>N(Ie),children:"↑"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-down","aria-label":r("cliTerminal.mobileKeyArrowDown","Cursor down"),onPointerDown:c,onMouseDown:c,onClick:()=>N(Ke),children:"↓"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-left","aria-label":r("cliTerminal.mobileKeyArrowLeft","Cursor left"),onPointerDown:c,onMouseDown:c,onClick:()=>N($e),children:"←"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-right","aria-label":r("cliTerminal.mobileKeyArrowRight","Cursor right"),onPointerDown:c,onMouseDown:c,onClick:()=>N(We),children:"→"})]}),t.jsxs("form",{className:"cli-session-terminal__input-row",onSubmit:pe,children:[t.jsx("input",{ref:fe,type:"text",className:"cli-session-terminal__mobile-input","data-testid":"cli-terminal-mobile-input",value:S,placeholder:r("cliTerminal.mobileInputPlaceholder","Type to send to the session…"),autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onChange:e=>ye(e.target.value)}),t.jsx("button",{type:"submit",className:"cli-session-terminal__mobile-send","data-testid":"cli-terminal-mobile-send","aria-label":r("cliTerminal.mobileSend","Send"),onPointerDown:c,onMouseDown:c,children:r("cliTerminal.mobileSend","Send")})]})]})]})}export{it as SessionTerminal};
|