@runfusion/fusion 0.76.0-beta.1 → 0.76.0-beta.2
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 +503 -213
- package/dist/child-process-worker.js +466 -207
- package/dist/client/.vite/manifest.json +260 -260
- package/dist/client/assets/{AgentDetailView-Cbl1sw6i.js → AgentDetailView-gak4EWTI.js} +1 -1
- package/dist/client/assets/{AgentPermissionPolicyEditor-DD1U5M9p.js → AgentPermissionPolicyEditor-DP1QbZL-.js} +1 -1
- package/dist/client/assets/{AgentsView-BMcCbple.js → AgentsView-DAMRTKzI.js} +3 -3
- package/dist/client/assets/ChatView-iE-2gf5P.js +13 -0
- package/dist/client/assets/{CommandCenter-D7mcD61V.js → CommandCenter-B6RnkLYm.js} +1 -1
- package/dist/client/assets/{DevServerView-DaqCn0p5.js → DevServerView-DcFL_LzK.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-CLdqqqYN.js → DirectoryPicker-CtjqrYoO.js} +1 -1
- package/dist/client/assets/{DocumentsView-BOROVxPm.js → DocumentsView-BkAe2S4H.js} +1 -1
- package/dist/client/assets/{EvalsView-BQMXRUlQ.js → EvalsView-CbGA9dMn.js} +1 -1
- package/dist/client/assets/{ExperimentalAgentOnboardingModal-1GNeCIQT.js → ExperimentalAgentOnboardingModal-CMgO_S8T.js} +1 -1
- package/dist/client/assets/{GoalsView-Cr3c_2GC.js → GoalsView-_3P9J5sf.js} +1 -1
- package/dist/client/assets/{InsightsView-DgVBVQM4.js → InsightsView-DOhO7xH5.js} +1 -1
- package/dist/client/assets/{MemoryView-C0VzzMSw.js → MemoryView-DwJas8vi.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-D1kkkVtP.js → PiExtensionsManager-B_LiW_e9.js} +1 -1
- package/dist/client/assets/{PluginManager-BW-_Zyo5.js → PluginManager-BkB6WLQc.js} +1 -1
- package/dist/client/assets/{PullRequestView-Cmlo4nWA.js → PullRequestView-DcH5tmYc.js} +1 -1
- package/dist/client/assets/{ReportModal-BWuaroTF.js → ReportModal-BOEbqtqG.js} +1 -1
- package/dist/client/assets/{ResearchView-BmkF_vZU.js → ResearchView-Dp6V42pI.js} +1 -1
- package/dist/client/assets/{SecretsView-DVc8Hky0.js → SecretsView-BCqXHB2L.js} +1 -1
- package/dist/client/assets/{SessionTerminal-DCXrxA57.js → SessionTerminal-CkdoQv4y.js} +1 -1
- package/dist/client/assets/{SettingsModal-DZ32F1c-.js → SettingsModal-D4Fn4GlS.js} +3 -3
- package/dist/client/assets/{SettingsModal-DqwpLnDU.js → SettingsModal-Dc7YG6KB.js} +1 -1
- package/dist/client/assets/{SettingsTextareaRow-B5spAoOY.js → SettingsTextareaRow-WSkBoAOO.js} +1 -1
- package/dist/client/assets/{SetupWizardModal-VTBLyFzr.js → SetupWizardModal-VTrJAsKd.js} +2 -2
- package/dist/client/assets/{SkillsView-CR91ey9d.js → SkillsView-CXeXOxfF.js} +1 -1
- package/dist/client/assets/{WorkflowNodeEditor-BzGh_Fd9.js → WorkflowNodeEditor-DoxLGPRF.js} +1 -1
- package/dist/client/assets/{agent-import-generation-D27NKQsr.js → agent-import-generation-upc0yw-M.js} +1 -1
- package/dist/client/assets/{agentsOrgChartLayout-C2K_M3x3.js → agentsOrgChartLayout-C3iumMrW.js} +1 -1
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-BQy8UcRx.js → architectureDiagram-3BPJPVTR-D6jqc3fJ.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-CZG1bqFQ.js → blockDiagram-GPEHLZMM-DY3AKuPD.js} +1 -1
- package/dist/client/assets/{c4Diagram-AAUBKEIU-CZmO_kg3.js → c4Diagram-AAUBKEIU-CpD52V4g.js} +1 -1
- package/dist/client/assets/channel-CaxOu15c.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-jsad6DTE.js → chunk-2J33WTMH-CPeIHyAX.js} +1 -1
- package/dist/client/assets/{chunk-4BX2VUAB-DX7SuvwP.js → chunk-4BX2VUAB-ivAwI4xM.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-De20xFgU.js → chunk-55IACEB6-BtVQ5XaZ.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-CNiri9yW.js → chunk-727SXJPM-1eap1vDU.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-DvDqG-ax.js → chunk-AQP2D5EJ-B2NB3BW9.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-DkMdKaUq.js → chunk-FMBD7UC4-Hk_smNYv.js} +1 -1
- package/dist/client/assets/{chunk-ND2GUHAM-Do5BwIrI.js → chunk-ND2GUHAM-BmGCAojk.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-BnJgt9vl.js → chunk-QZHKN3VN-D0aXZ8CV.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-DXIkGbsl.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DXIkGbsl.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-D-ivAzzF.js → cose-bilkent-S5V4N54A-DAbu_gnF.js} +1 -1
- package/dist/client/assets/{dagre-BM42HDAG-Bpd9L0or.js → dagre-BM42HDAG-BdmLlrDJ.js} +1 -1
- package/dist/client/assets/{dashboard-view-DSvVO6Vr.js → dashboard-view-BoFBSXUn.js} +1 -1
- package/dist/client/assets/{dashboard-view-CgBo8Ctn.js → dashboard-view-CULL1yhL.js} +1 -1
- package/dist/client/assets/{dashboard-view-C-XU9CVv.js → dashboard-view-CxXMDfNY.js} +1 -1
- package/dist/client/assets/{dashboard-view-DbaRE8Ma.js → dashboard-view-PRCWCSLm.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-B6TT1NWU.js → diagram-2AECGRRQ-PpqLbVUA.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-DpRS2yRw.js → diagram-5GNKFQAL-9rkGmTwh.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-BVbZr02C.js → diagram-KO2AKTUF-BT-efOMo.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-DzENbfal.js → diagram-LMA3HP47-w79OWFxg.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-BIePG5SY.js → diagram-OG6HWLK6-Bye9I5IO.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-CQo3WBwo.js → erDiagram-TEJ5UH35-aodREgDf.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-Ct2H4jYo.js → flowDiagram-I6XJVG4X-D0DKItY3.js} +1 -1
- package/dist/client/assets/{folder-open-DAh8mpTX.js → folder-open-CqvaMJvx.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-DyOLCG4B.js → ganttDiagram-6RSMTGT7-CZVApkvw.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-sC28-su3.js → gitGraphDiagram-PVQCEYII-D_ynwJ4p.js} +1 -1
- package/dist/client/assets/index-DWRJyaa3.js +2818 -0
- package/dist/client/assets/{infoDiagram-5YYISTIA-Q81_5aBZ.js → infoDiagram-5YYISTIA-pJG6zxjk.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Cwkjs0z5.js → ishikawaDiagram-YF4QCWOH-nFZ5laUo.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-BXcBV1Bc.js → journeyDiagram-JHISSGLW-CWpCaAIe.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-BI7hW892.js → kanban-definition-UN3LZRKU-ATkPspKa.js} +1 -1
- package/dist/client/assets/{mermaid.core-B8oDA6jj.js → mermaid.core-CDXPNs7a.js} +4 -4
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-COG6_9eD.js → mindmap-definition-RKZ34NQL-BkqS9tpe.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-D11brZ_N.js → pieDiagram-4H26LBE5-DEUyVLs-.js} +1 -1
- package/dist/client/assets/{puzzle-D3_Z_rlW.js → puzzle-DQ0y1-XK.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-jmhDVZcv.js → quadrantDiagram-W4KKPZXB-ESBJNK5c.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-BKCUWI1E.js → requirementDiagram-4Y6WPE33-CqPs7zcv.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-HsZdEl2t.js → sankeyDiagram-5OEKKPKP-CkFN0m14.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-CsDf7Fup.js → sequenceDiagram-3UESZ5HK-Dx2nDuMO.js} +1 -1
- package/dist/client/assets/{shield-alert-C16k8wNu.js → shield-alert-BS05s4RM.js} +1 -1
- package/dist/client/assets/{standing-instructions-template-BqAyftqe.js → standing-instructions-template-xprxYNHm.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-fvzWhltB.js → stateDiagram-AJRCARHV-EUPmRFGd.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-cnt42Sr_.js → stateDiagram-v2-BHNVJYJU-DcQ2mhi5.js} +1 -1
- package/dist/client/assets/{timeline-definition-PNZ67QCA-DsZFCSMb.js → timeline-definition-PNZ67QCA-D4YO_3V-.js} +1 -1
- package/dist/client/assets/{upload-_s5sL5Pq.js → upload-BjyBtxo7.js} +1 -1
- package/dist/client/assets/{users-DH1U5ISc.js → users-D5ogZ7WQ.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-B3KDWS-e.js → vennDiagram-CIIHVFJN-BT5_XuQL.js} +1 -1
- package/dist/client/assets/{wardley-L42UT6IY-BKs5MtQS.js → wardley-L42UT6IY-X_ZMW457.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-CNsEoXVB.js → wardleyDiagram-YWT4CUSO-GK9nONHU.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-kq_gW4QC.js → xychartDiagram-2RQKCTM6-Dw3zXHAq.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/version.json +1 -1
- package/dist/droid-cli/package.json +1 -1
- package/dist/extension.js +647 -207
- package/dist/migrations/0057_fn_9004_project_ownership_default_reconciliation.sql +13 -0
- package/dist/migrations/0058_fn_9014_message_archive.sql +13 -0
- package/dist/pi-claude-cli/package.json +5 -5
- package/dist/plugin-sdk/index.js +69 -23
- package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
- package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
- package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +71 -25
- package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-linear-import/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
- package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-quality/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-quality/package.json +1 -1
- package/dist/plugins/fusion-plugin-reports/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-reports/package.json +1 -1
- package/dist/plugins/fusion-plugin-roadmap/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
- package/dist/plugins/fusion-plugin-todos/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-todos/package.json +1 -1
- package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +69 -23
- package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
- package/package.json +3 -3
- package/skill/fusion/SKILL.md +1 -1
- package/skill/fusion/references/extension-tools.md +22 -0
- package/skill/fusion/references/fusion-capabilities.md +2 -0
- package/dist/client/assets/ChatView-DcM-ARpZ.js +0 -13
- package/dist/client/assets/channel-Cwl9FefC.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-BZtWCoHC.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-BZtWCoHC.js +0 -1
- package/dist/client/assets/index-BlGpMJSZ.js +0 -2818
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,j as e}from"./vendor-react-SZ_qB27O.js";import{w as A,V as we,o as ke,R as ce,P as Re,E as ne,p as le,q as Le,u as Te,v as Ae,x as Me,C as qe,g as De,y as Ve}from"./index-BlGpMJSZ.js";import{u as Ke}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Oe="__sync_passphrase__",Y={key:"",value:"",description:"",scope:"project",accessPolicy:"prompt",envExportable:!1,envExportKey:""},d={className:"secrets-action-icon","aria-hidden":!0,style:{width:"1em",height:"1em"}},Fe={...d,className:"secrets-action-icon spin"},Ye=({addToast:p,projectId:l})=>{const{t:a}=Ke("app"),[z,G]=t.useState([]),[oe,U]=t.useState(),[Q,W]=t.useState(!0),[X,M]=t.useState(null),[ie,q]=t.useState(),[Z,b]=t.useState(null),[h,D]=t.useState(null),[de,x]=t.useState(!1),[ue,C]=t.useState(null),[c,i]=t.useState(Y),[V,E]=t.useState(!1),[ee,f]=t.useState({}),[pe,K]=t.useState(null),[m,se]=t.useState(!1),[he,ae]=t.useState(),[me,O]=t.useState(!1),[w,F]=t.useState(""),[_,B]=t.useState(""),[ye,$]=t.useState(!1),[H,xe]=t.useState(!1),v=t.useRef(new Map),I=t.useRef(new Map),j=t.useRef(0),k=t.useRef(0),o=t.useRef(l);o.current!==l&&(o.current=l,j.current+=1,k.current+=1);const y=t.useCallback(s=>A(s,l),[l]),u=t.useCallback(async(s,r)=>{const n=await fetch(s,{...r,headers:{"Content-Type":"application/json",...r?.headers??{}}});if(!n.ok){const g=await n.json().catch(()=>({error:"Request failed"}));throw new Error(String(g?.error??"Request failed"))}if(n.status!==204)return n.json()},[]),S=t.useCallback(async()=>{const s=l;if(o.current!==s)return;const r=++j.current;W(!0),M(null),q(void 0);try{const n=await u(y("/api/secrets"));r===j.current&&o.current===s&&(G(n.secrets),U(s))}catch(n){r===j.current&&o.current===s&&(M(n instanceof Error?n.message:String(n)),q(s))}finally{r===j.current&&o.current===s&&W(!1)}},[l,y,u]),R=t.useCallback(async()=>{const s=l;if(o.current!==s)return;const r=++k.current;try{const n=await u(y("/api/secrets/sync-passphrase"));r===k.current&&o.current===s&&(se(!!n.configured),ae(s))}catch(n){r===k.current&&o.current===s&&p?.(a("secrets.errorLoadSyncStatus","Failed to load sync passphrase status: {{error}}",{error:n instanceof Error?n.message:String(n)}),"error")}},[p,l,y,u,a]);t.useEffect(()=>(G([]),U(void 0),f({}),K(null),se(!1),ae(void 0),M(null),q(void 0),b(null),D(null),x(!1),E(!1),C(null),O(!1),F(""),B(""),$(!1),S(),R(),()=>{v.current.forEach(s=>clearTimeout(s)),I.current.forEach(s=>clearTimeout(s))}),[S,R,l]);const J=()=>{O(!1),F(""),B("")},ve=async(s,r)=>{await u(A("/api/secrets/sync-passphrase",r),{method:"PUT",body:JSON.stringify({passphrase:s})})},be=async()=>{const s=l;$(!0);try{if(await ve(w,s),o.current!==s)return;p?.(m?a("secrets.syncPassphraseRotated","Sync passphrase rotated"):a("secrets.syncPassphraseSet","Sync passphrase set"),"success"),J(),await R()}catch(r){o.current===s&&p?.(a("secrets.errorSaveSyncPassphrase","Failed to save sync passphrase: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}finally{o.current===s&&$(!1)}},fe=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.")))return;const r=l;try{if(await u(A("/api/secrets/sync-passphrase",r),{method:"DELETE"}),o.current!==r)return;p?.(a("secrets.syncPassphraseCleared","Sync passphrase cleared"),"success"),await R()}catch(n){o.current===r&&p?.(a("secrets.errorClearSyncPassphrase","Failed to clear sync passphrase: {{error}}",{error:n instanceof Error?n.message:String(n)}),"error")}},je=()=>{D(null),i(Y),x(!0),E(!1),b(null)},Se=s=>{D(s),i({key:s.key,value:"",description:s.description??"",scope:s.scope,accessPolicy:s.accessPolicy,envExportable:s.envExportable,envExportKey:s.envExportKey??""}),x(!0),E(!1),b(null)},ge=async()=>{const s=l;b(null);try{if(h){const r={key:c.key,description:c.description||null,accessPolicy:c.accessPolicy,envExportable:c.envExportable,envExportKey:c.envExportable&&c.envExportKey||null};c.value&&(r.value=c.value),await u(y(`/api/secrets/${h.scope}/${h.id}`),{method:"PATCH",body:JSON.stringify(r)})}else await u(y("/api/secrets"),{method:"POST",body:JSON.stringify({scope:c.scope,key:c.key,value:c.value,description:c.description||null,accessPolicy:c.accessPolicy,envExportable:c.envExportable,envExportKey:c.envExportable&&c.envExportKey||null})});if(o.current!==s)return;x(!1),i(Y),await S()}catch(r){o.current===s&&b(r instanceof Error?r.message:String(r))}},Ne=s=>{const r=v.current.get(s.id);r&&(clearTimeout(r),v.current.delete(s.id)),f(n=>({...n,[s.id]:null}))},Pe=async s=>{const r=l,n=await u(y(`/api/secrets/${s.scope}/${s.id}/reveal`),{method:"POST"});if(o.current!==r)return;f(P=>({...P,[s.id]:n.value})),p?.(a("secrets.revealed","Revealed"),"success");const g=setTimeout(()=>{f(P=>({...P,[s.id]:null})),v.current.delete(s.id)},3e4),N=v.current.get(s.id);N&&clearTimeout(N),v.current.set(s.id,g)},Ce=async s=>{const r=ee[s.id];if(!r)return;if(!await Ve(r)){p?.(a("secrets.copyFailed","Failed to copy secret"),"error");return}K(s.id),p?.(a("secrets.copied","Copied"),"success");const g=setTimeout(()=>{K(null),f(P=>({...P,[s.id]:null}))},1500),N=I.current.get(s.id);N&&clearTimeout(N),I.current.set(s.id,g)},Ee=async s=>{const r=l;await u(A(`/api/secrets/${s.scope}/${s.id}`,r),{method:"DELETE"}),o.current===r&&(C(null),await S())},L=oe===l,T=he===l,re=t.useMemo(()=>[...L?z:[]].filter(s=>!(s.scope==="global"&&s.key===Oe)).sort((s,r)=>s.key.localeCompare(r.key)),[z,L]),te=w.length>0&&w===_;return e.jsxs("section",{className:"secrets-view",children:[e.jsx(we,{icon:ke,title:a("secrets.title","Secrets"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void S(),children:[e.jsx(ce,{...d})," ",a("secrets.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:je,children:[e.jsx(Re,{...d})," ",a("secrets.addSecret","Add Secret")]})]})}),X&&ie===l?e.jsx("div",{className:"form-error",children:X}):null,Q||!L?e.jsxs("div",{className:"secrets-loading",children:[e.jsx(ce,{...Fe})," ",a("secrets.loading","Loading…")]}):null,!Q&&L&&re.length===0?e.jsx("div",{className:"secrets-empty",children:a("secrets.empty","No secrets found.")}):null,e.jsx("div",{className:"secrets-list",children:re.map(s=>{const r=ee[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){Ne(s);return}Pe(s)},"aria-label":r?a("secrets.hideAriaLabel","Hide"):a("secrets.revealAriaLabel","Reveal"),children:r?e.jsx(ne,{...d}):e.jsx(le,{...d})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>void Ce(s),"aria-label":a("secrets.copyAriaLabel","Copy"),disabled:!r,children:pe===s.id?e.jsx(Le,{...d}):e.jsx(Te,{...d})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>Se(s),"aria-label":a("secrets.editAriaLabel","Edit"),children:e.jsx(Ae,{...d})}),e.jsx("button",{className:"btn btn-icon btn-danger",onClick:()=>C(s.id),"aria-label":a("secrets.deleteAriaLabel","Delete"),children:e.jsx(Me,{...d})})]}),ue===s.id?e.jsxs("div",{className:"secrets-confirm",children:[e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void Ee(s),children:a("secrets.confirmDelete","Confirm")}),e.jsx("button",{className:"btn btn-sm",onClick:()=>C(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":H,"aria-controls":"secrets-sync-disclosure-panel",onClick:()=>xe(s=>!s),children:[H?e.jsx(qe,{size:16,"aria-hidden":"true"}):e.jsx(De,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:a("secrets.syncPassphraseTitle","Cross-Node Sync Passphrase")})]}),H?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 ${T&&m?"status-dot--online":"status-dot--pending"}`,"aria-hidden":"true"})," ",T&&m?a("secrets.syncConfigured","Configured"):a("secrets.syncNotConfigured","Not configured")]}),e.jsxs("div",{className:"secrets-sync-actions",children:[e.jsx("button",{className:"btn",onClick:()=>O(!0),children:T&&m?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")}),T&&m?e.jsx("button",{className:"btn btn-danger",onClick:()=>void fe(),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]}),me?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":m?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:m?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase")}),e.jsx("button",{className:"modal-close",onClick:J,"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:w,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:_,onChange:s=>B(s.target.value)})]}),!te&&_.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:J,children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void be(),disabled:!te||ye,children:m?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")})]})})]})}):null,de?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":h?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:h?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret")}),e.jsx("button",{className:"modal-close",onClick:()=>x(!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:c.key,onChange:s=>i(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:V?"text":"password",autoComplete:"off",spellCheck:!1,value:c.value,onChange:s=>i(r=>({...r,value:s.target.value}))}),e.jsx("button",{type:"button",className:"btn btn-icon secrets-visibility-toggle",onClick:()=>E(s=>!s),"aria-label":V?a("secrets.hideValueAriaLabel","Hide value"):a("secrets.showValueAriaLabel","Show value"),children:V?e.jsx(ne,{...d}):e.jsx(le,{...d})})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.descriptionLabel","Description")}),e.jsx("textarea",{className:"input",value:c.description,onChange:s=>i(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:c.scope==="project",onChange:()=>i(s=>({...s,scope:"project"})),disabled:!!h})," ",a("secrets.scopeProject","Project")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:c.scope==="global",onChange:()=>i(s=>({...s,scope:"global"})),disabled:!!h})," ",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:c.accessPolicy,onChange:s=>i(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:c.envExportable,onChange:s=>i(r=>({...r,envExportable:s.target.checked}))})," ",a("secrets.exportToEnvLabel","Export to env")]})}),c.envExportable?e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.envKeyLabel","Env key")}),e.jsx("input",{className:"input",value:c.envExportKey,onChange:s=>i(r=>({...r,envExportKey:s.target.value}))})]}):null,Z?e.jsx("div",{className:"form-error",children:Z}):null]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn",onClick:()=>x(!1),children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void ge(),children:h?a("secrets.saveBtn","Save"):a("secrets.createBtn","Create")})]})})]})}):null]})};export{Ye as SecretsView};
|
|
1
|
+
import{r as t,j as e}from"./vendor-react-SZ_qB27O.js";import{w as A,V as we,o as ke,R as ce,P as Re,E as ne,p as le,q as Le,u as Te,v as Ae,x as Me,C as qe,g as De,y as Ve}from"./index-DWRJyaa3.js";import{u as Ke}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Oe="__sync_passphrase__",Y={key:"",value:"",description:"",scope:"project",accessPolicy:"prompt",envExportable:!1,envExportKey:""},d={className:"secrets-action-icon","aria-hidden":!0,style:{width:"1em",height:"1em"}},Fe={...d,className:"secrets-action-icon spin"},Ye=({addToast:p,projectId:l})=>{const{t:a}=Ke("app"),[z,G]=t.useState([]),[oe,U]=t.useState(),[Q,W]=t.useState(!0),[X,M]=t.useState(null),[ie,q]=t.useState(),[Z,b]=t.useState(null),[h,D]=t.useState(null),[de,x]=t.useState(!1),[ue,C]=t.useState(null),[c,i]=t.useState(Y),[V,E]=t.useState(!1),[ee,f]=t.useState({}),[pe,K]=t.useState(null),[m,se]=t.useState(!1),[he,ae]=t.useState(),[me,O]=t.useState(!1),[w,F]=t.useState(""),[_,B]=t.useState(""),[ye,$]=t.useState(!1),[H,xe]=t.useState(!1),v=t.useRef(new Map),I=t.useRef(new Map),j=t.useRef(0),k=t.useRef(0),o=t.useRef(l);o.current!==l&&(o.current=l,j.current+=1,k.current+=1);const y=t.useCallback(s=>A(s,l),[l]),u=t.useCallback(async(s,r)=>{const n=await fetch(s,{...r,headers:{"Content-Type":"application/json",...r?.headers??{}}});if(!n.ok){const g=await n.json().catch(()=>({error:"Request failed"}));throw new Error(String(g?.error??"Request failed"))}if(n.status!==204)return n.json()},[]),S=t.useCallback(async()=>{const s=l;if(o.current!==s)return;const r=++j.current;W(!0),M(null),q(void 0);try{const n=await u(y("/api/secrets"));r===j.current&&o.current===s&&(G(n.secrets),U(s))}catch(n){r===j.current&&o.current===s&&(M(n instanceof Error?n.message:String(n)),q(s))}finally{r===j.current&&o.current===s&&W(!1)}},[l,y,u]),R=t.useCallback(async()=>{const s=l;if(o.current!==s)return;const r=++k.current;try{const n=await u(y("/api/secrets/sync-passphrase"));r===k.current&&o.current===s&&(se(!!n.configured),ae(s))}catch(n){r===k.current&&o.current===s&&p?.(a("secrets.errorLoadSyncStatus","Failed to load sync passphrase status: {{error}}",{error:n instanceof Error?n.message:String(n)}),"error")}},[p,l,y,u,a]);t.useEffect(()=>(G([]),U(void 0),f({}),K(null),se(!1),ae(void 0),M(null),q(void 0),b(null),D(null),x(!1),E(!1),C(null),O(!1),F(""),B(""),$(!1),S(),R(),()=>{v.current.forEach(s=>clearTimeout(s)),I.current.forEach(s=>clearTimeout(s))}),[S,R,l]);const J=()=>{O(!1),F(""),B("")},ve=async(s,r)=>{await u(A("/api/secrets/sync-passphrase",r),{method:"PUT",body:JSON.stringify({passphrase:s})})},be=async()=>{const s=l;$(!0);try{if(await ve(w,s),o.current!==s)return;p?.(m?a("secrets.syncPassphraseRotated","Sync passphrase rotated"):a("secrets.syncPassphraseSet","Sync passphrase set"),"success"),J(),await R()}catch(r){o.current===s&&p?.(a("secrets.errorSaveSyncPassphrase","Failed to save sync passphrase: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}finally{o.current===s&&$(!1)}},fe=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.")))return;const r=l;try{if(await u(A("/api/secrets/sync-passphrase",r),{method:"DELETE"}),o.current!==r)return;p?.(a("secrets.syncPassphraseCleared","Sync passphrase cleared"),"success"),await R()}catch(n){o.current===r&&p?.(a("secrets.errorClearSyncPassphrase","Failed to clear sync passphrase: {{error}}",{error:n instanceof Error?n.message:String(n)}),"error")}},je=()=>{D(null),i(Y),x(!0),E(!1),b(null)},Se=s=>{D(s),i({key:s.key,value:"",description:s.description??"",scope:s.scope,accessPolicy:s.accessPolicy,envExportable:s.envExportable,envExportKey:s.envExportKey??""}),x(!0),E(!1),b(null)},ge=async()=>{const s=l;b(null);try{if(h){const r={key:c.key,description:c.description||null,accessPolicy:c.accessPolicy,envExportable:c.envExportable,envExportKey:c.envExportable&&c.envExportKey||null};c.value&&(r.value=c.value),await u(y(`/api/secrets/${h.scope}/${h.id}`),{method:"PATCH",body:JSON.stringify(r)})}else await u(y("/api/secrets"),{method:"POST",body:JSON.stringify({scope:c.scope,key:c.key,value:c.value,description:c.description||null,accessPolicy:c.accessPolicy,envExportable:c.envExportable,envExportKey:c.envExportable&&c.envExportKey||null})});if(o.current!==s)return;x(!1),i(Y),await S()}catch(r){o.current===s&&b(r instanceof Error?r.message:String(r))}},Ne=s=>{const r=v.current.get(s.id);r&&(clearTimeout(r),v.current.delete(s.id)),f(n=>({...n,[s.id]:null}))},Pe=async s=>{const r=l,n=await u(y(`/api/secrets/${s.scope}/${s.id}/reveal`),{method:"POST"});if(o.current!==r)return;f(P=>({...P,[s.id]:n.value})),p?.(a("secrets.revealed","Revealed"),"success");const g=setTimeout(()=>{f(P=>({...P,[s.id]:null})),v.current.delete(s.id)},3e4),N=v.current.get(s.id);N&&clearTimeout(N),v.current.set(s.id,g)},Ce=async s=>{const r=ee[s.id];if(!r)return;if(!await Ve(r)){p?.(a("secrets.copyFailed","Failed to copy secret"),"error");return}K(s.id),p?.(a("secrets.copied","Copied"),"success");const g=setTimeout(()=>{K(null),f(P=>({...P,[s.id]:null}))},1500),N=I.current.get(s.id);N&&clearTimeout(N),I.current.set(s.id,g)},Ee=async s=>{const r=l;await u(A(`/api/secrets/${s.scope}/${s.id}`,r),{method:"DELETE"}),o.current===r&&(C(null),await S())},L=oe===l,T=he===l,re=t.useMemo(()=>[...L?z:[]].filter(s=>!(s.scope==="global"&&s.key===Oe)).sort((s,r)=>s.key.localeCompare(r.key)),[z,L]),te=w.length>0&&w===_;return e.jsxs("section",{className:"secrets-view",children:[e.jsx(we,{icon:ke,title:a("secrets.title","Secrets"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void S(),children:[e.jsx(ce,{...d})," ",a("secrets.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:je,children:[e.jsx(Re,{...d})," ",a("secrets.addSecret","Add Secret")]})]})}),X&&ie===l?e.jsx("div",{className:"form-error",children:X}):null,Q||!L?e.jsxs("div",{className:"secrets-loading",children:[e.jsx(ce,{...Fe})," ",a("secrets.loading","Loading…")]}):null,!Q&&L&&re.length===0?e.jsx("div",{className:"secrets-empty",children:a("secrets.empty","No secrets found.")}):null,e.jsx("div",{className:"secrets-list",children:re.map(s=>{const r=ee[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){Ne(s);return}Pe(s)},"aria-label":r?a("secrets.hideAriaLabel","Hide"):a("secrets.revealAriaLabel","Reveal"),children:r?e.jsx(ne,{...d}):e.jsx(le,{...d})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>void Ce(s),"aria-label":a("secrets.copyAriaLabel","Copy"),disabled:!r,children:pe===s.id?e.jsx(Le,{...d}):e.jsx(Te,{...d})}),e.jsx("button",{className:"btn btn-icon",onClick:()=>Se(s),"aria-label":a("secrets.editAriaLabel","Edit"),children:e.jsx(Ae,{...d})}),e.jsx("button",{className:"btn btn-icon btn-danger",onClick:()=>C(s.id),"aria-label":a("secrets.deleteAriaLabel","Delete"),children:e.jsx(Me,{...d})})]}),ue===s.id?e.jsxs("div",{className:"secrets-confirm",children:[e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void Ee(s),children:a("secrets.confirmDelete","Confirm")}),e.jsx("button",{className:"btn btn-sm",onClick:()=>C(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":H,"aria-controls":"secrets-sync-disclosure-panel",onClick:()=>xe(s=>!s),children:[H?e.jsx(qe,{size:16,"aria-hidden":"true"}):e.jsx(De,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:a("secrets.syncPassphraseTitle","Cross-Node Sync Passphrase")})]}),H?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 ${T&&m?"status-dot--online":"status-dot--pending"}`,"aria-hidden":"true"})," ",T&&m?a("secrets.syncConfigured","Configured"):a("secrets.syncNotConfigured","Not configured")]}),e.jsxs("div",{className:"secrets-sync-actions",children:[e.jsx("button",{className:"btn",onClick:()=>O(!0),children:T&&m?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")}),T&&m?e.jsx("button",{className:"btn btn-danger",onClick:()=>void fe(),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]}),me?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":m?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:m?a("secrets.rotateSyncPassphraseModalTitle","Rotate sync passphrase"):a("secrets.setSyncPassphraseModalTitle","Set sync passphrase")}),e.jsx("button",{className:"modal-close",onClick:J,"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:w,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:_,onChange:s=>B(s.target.value)})]}),!te&&_.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:J,children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void be(),disabled:!te||ye,children:m?a("secrets.rotateSyncPassphrase","Rotate"):a("secrets.setPassphrase","Set passphrase")})]})})]})}):null,de?e.jsx("div",{className:"modal-overlay open",role:"presentation",children:e.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-label":h?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret"),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:h?a("secrets.editSecretModalTitle","Edit secret"):a("secrets.addSecretModalTitle","Add secret")}),e.jsx("button",{className:"modal-close",onClick:()=>x(!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:c.key,onChange:s=>i(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:V?"text":"password",autoComplete:"off",spellCheck:!1,value:c.value,onChange:s=>i(r=>({...r,value:s.target.value}))}),e.jsx("button",{type:"button",className:"btn btn-icon secrets-visibility-toggle",onClick:()=>E(s=>!s),"aria-label":V?a("secrets.hideValueAriaLabel","Hide value"):a("secrets.showValueAriaLabel","Show value"),children:V?e.jsx(ne,{...d}):e.jsx(le,{...d})})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.descriptionLabel","Description")}),e.jsx("textarea",{className:"input",value:c.description,onChange:s=>i(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:c.scope==="project",onChange:()=>i(s=>({...s,scope:"project"})),disabled:!!h})," ",a("secrets.scopeProject","Project")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:c.scope==="global",onChange:()=>i(s=>({...s,scope:"global"})),disabled:!!h})," ",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:c.accessPolicy,onChange:s=>i(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:c.envExportable,onChange:s=>i(r=>({...r,envExportable:s.target.checked}))})," ",a("secrets.exportToEnvLabel","Export to env")]})}),c.envExportable?e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:a("secrets.envKeyLabel","Env key")}),e.jsx("input",{className:"input",value:c.envExportKey,onChange:s=>i(r=>({...r,envExportKey:s.target.value}))})]}):null,Z?e.jsx("div",{className:"form-error",children:Z}):null]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn",onClick:()=>x(!1),children:a("secrets.cancelBtn","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void ge(),children:h?a("secrets.saveBtn","Save"):a("secrets.createBtn","Create")})]})})]})}):null]})};export{Ye as SecretsView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-webgl-uLc0RKcC.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{K as Pe,N as z,O as de,Q as J,U as ue,W as F,Y as je,_ as Me,p as Le,$ as De,a0 as Y,a1 as Oe,a2 as Ae,a as ze,a3 as K,a4 as Fe,a5 as Be}from"./index-BlGpMJSZ.js";import{r as i,j as t}from"./vendor-react-SZ_qB27O.js";import"./vendor-xterm-BNq00GSj.js";import{u as Ie}from"./vendor-i18n-Duky4gdQ.js";import{S as Ke}from"./shield-alert-C16k8wNu.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";const We=32*1024,$e=1e4,Ue=100,Qe="\x1B",Ve=" ",Je="",Ye="\x1B[A",Ge="\x1B[B",He="\x1B[C",qe="\x1B[D",W={ctrl:"Ctrl",escape:"Esc",tab:"Tab",ctrlC:"^C"};function me(m){if(m.length!==1)return null;const o=m.toUpperCase().charCodeAt(0);return o>=64&&o<=95?String.fromCharCode(o&31):null}function Ze(){const[m,f]=i.useState(()=>Y());return i.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const o=window.matchMedia(Oe),r=window.visualViewport,y=()=>f(Y());return y(),typeof r?.addEventListener=="function"&&r.addEventListener("resize",y),typeof o.addEventListener=="function"?(o.addEventListener("change",y),()=>{o.removeEventListener("change",y),typeof r?.removeEventListener=="function"&&r.removeEventListener("resize",y)}):(o.addListener(y),()=>{o.removeListener(y),typeof r?.removeEventListener=="function"&&r.removeEventListener("resize",y)})},[]),m}function Xe(m,f){if(typeof window>"u")return"";const r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/cli-sessions/ws?sessionId=${encodeURIComponent(m)}&ticket=${encodeURIComponent(f)}`;return Be(r)}function et(){return/Mac|iPhone|iPad|iPod/i.test(navigator.platform)}function tt(m){if(typeof window<"u"&&typeof window.atob=="function"){const f=window.atob(m),o=new Uint8Array(f.length);for(let r=0;r<f.length;r++)o[r]=f.charCodeAt(r);return new TextDecoder("utf-8").decode(o)}return Buffer.from(m,"base64").toString("utf8")}function ut({sessionId:m,readOnly:f=!1,posture:o,mode:r="live",projectId:y,onConfirmAdvance:g,showConfirmAdvance:$=!1,onOpenAdapterSettings:G,active:H=!0}){const{t:a}=Ie("app"),x=i.useRef(null),v=i.useRef(null),N=i.useRef(null),R=i.useRef(null),h=i.useRef(null),[q,Z]=i.useState(!1),[fe,U]=i.useState(!1),[X,ee]=i.useState(!1),P=Ze(),{keyboardOpen:B,keyboardOverlap:pe}=Pe({enabled:P}),ye=i.useRef(null),[_,te]=i.useState(""),[j,D]=i.useState(!1),[be,he]=i.useState(()=>z().customShortcuts),[ne,ie]=i.useState(null),se=f||ne===!0,O=!f&&ne===!1&&r==="live",b=i.useCallback(e=>{if(!e||!O)return;const n=h.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:"input",data:e}))},[O]),M=i.useCallback(e=>{if(j){const n=me(e);if(D(!1),n){b(n);return}}b(e)},[j,b]),c=i.useCallback(e=>{e.preventDefault()},[]),we=i.useCallback(e=>{e?.preventDefault?.(),_&&b(_),b("\r"),te("")},[_,b]),Se=i.useCallback(e=>{if(j&&e.length>_.length){const n=e.slice(_.length,_.length+1),l=me(n);if(D(!1),l){b(l);return}}te(e)},[j,_,b]);i.useEffect(()=>{$&&U(!1)},[$,m]);const E=i.useCallback((e,n)=>{const l=h.current;l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"resize",cols:e,rows:n}))},[]),oe=i.useCallback(()=>{const e=v.current;if(!e)return;const n=z(),l=de(n.fontFamily);e.options.fontFamily=l,x.current?.style.setProperty("--terminal-glyph-font-family",J(n.fontFamily)),e.options.fontSize=n.fontSize,e.options.cursorStyle=n.cursorStyle,e.options.cursorBlink=n.cursorBlink&&O;try{N.current?.fit?.(),E(e.cols,e.rows)}catch{}ue(n.fontSize,l).then(k=>{if(!(!k||v.current!==e||e.options.fontSize!==n.fontSize||e.options.fontFamily!==l)){F(e,l),e.options.fontSize=n.fontSize;try{N.current?.fit?.(),E(e.cols,e.rows),F(e,l),e.refresh(0,Math.max(0,e.rows-1))}catch{}}},()=>{})},[O,E]);i.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.key===Ae&&(oe(),he(z().customShortcuts))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[oe]);const[_e,ke]=i.useState(0);i.useEffect(()=>{if(!H)return;const e=v.current,n=N.current;if(e&&n?.fit)try{n.fit(),E(e.cols,e.rows),F(e,String(e.options.fontFamily??"")),e.refresh(0,Math.max(0,e.rows-1))}catch{}const l=h.current;l&&l.readyState!==WebSocket.OPEN&&l.readyState!==WebSocket.CONNECTING&&ke(k=>k+1)},[H,E]),i.useEffect(()=>{if(!m||typeof window>"u")return;let e=!1,n=null,l=null,k=0;ie(null);const Q=E,Te=p=>{if(k+=p,k<We)return;const w=h.current;w?.readyState===WebSocket.OPEN&&w.send(JSON.stringify({type:"ack",bytes:k})),k=0};return(async()=>{let p;try{p=await ze(`/cli-sessions/${encodeURIComponent(m)}/attach-ticket`,{method:"POST",body:JSON.stringify(y?{projectId:y}:{})})}catch{return}if(e)return;ie(p.readOnly);const w=!f&&!p.readOnly&&r==="live",[{Terminal:ge},{FitAddon:xe},{Unicode11Addon:Ne}]=await Promise.all([K(()=>import("./vendor-xterm-BNq00GSj.js").then(d=>d.x),__vite__mapDeps([0,1,2])),K(()=>import("./addon-fit-C1WQXRvu.js").then(d=>d.a),__vite__mapDeps([3,1])),K(()=>import("./addon-unicode11-D3Fsv-Po.js"),[])]);if(e||!x.current)return;const S=z(),A=de(S.fontFamily);x.current.style.setProperty("--terminal-glyph-font-family",J(S.fontFamily));const s=new ge({convertEol:!1,cursorBlink:S.cursorBlink&&w,cursorStyle:S.cursorStyle,disableStdin:!w,scrollback:$e,fontFamily:A,fontSize:S.fontSize}),L=new xe;s.loadAddon(L);const Re=new Ne;if(s.loadAddon(Re),s.unicode.activeVersion="11",Fe(()=>{s.open(x.current)}),v.current=s,N.current=L,S.renderer==="auto"&&!Y())try{const{WebglAddon:d}=await K(async()=>{const{WebglAddon:u}=await import("./addon-webgl-uLc0RKcC.js").then(C=>C.a);return{WebglAddon:u}},__vite__mapDeps([4,1]));if(!e){const u=new d;u.onContextLoss(()=>{try{u.dispose()}catch{}R.current===u&&(R.current=null)}),s.loadAddon(u),R.current=u}}catch{}try{L.fit()}catch{}(async()=>{if(!(!await ue(S.fontSize,A)||e||v.current!==s||N.current!==L||s.options.fontSize!==S.fontSize||s.options.fontFamily!==A))try{F(s,A),s.options.fontSize=S.fontSize,L.fit(),Q(s.cols,s.rows),F(s,A),s.refresh(0,Math.max(0,s.rows-1))}catch{}})(),w&&(s.onData(d=>{const u=h.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"input",data:d}))}),s.attachCustomKeyEventHandler(d=>{if(d.type!=="keydown"||!(et()?d.metaKey:d.ctrlKey)||d.altKey||d.shiftKey)return!0;const C=d.key.toLowerCase();if(C==="c"){const T=s.hasSelection()?s.getSelection():"";return T?(navigator.clipboard?.writeText(T).catch(()=>{}),!1):!0}if(C==="v"){const T=navigator.clipboard?.readText;return T&&T.call(navigator.clipboard).then(le=>{if(!le)return;const ce=h.current;ce?.readyState===WebSocket.OPEN&&ce.send(JSON.stringify({type:"input",data:le}))}).catch(()=>{}),!1}return!0})),n=new ResizeObserver(()=>{l&&clearTimeout(l),l=setTimeout(()=>{try{L.fit(),Q(s.cols,s.rows),s.refresh(0,Math.max(0,s.rows-1))}catch{}},Ue)}),n.observe(x.current);const V=new WebSocket(Xe(m,p.ticket));h.current=V,V.onopen=()=>{Q(s.cols,s.rows)},V.onmessage=d=>{let u;try{u=JSON.parse(typeof d.data=="string"?d.data:"")}catch{return}switch(u.type){case"scrollback":case"data":{if(typeof u.data!="string")return;const C=tt(u.data),T=C.length;s.write(C,()=>Te(T));break}}}})(),()=>{e=!0,l&&clearTimeout(l),n&&n.disconnect();const p=h.current;if(p){p.onopen=null,p.onmessage=null,p.onclose=null,p.onerror=null;try{p.close()}catch{}h.current=null}if(R.current){try{R.current.dispose()}catch{}R.current=null}const w=v.current;if(w){try{w.dispose()}catch{}v.current=null}N.current=null}},[m,f,r,y,E,_e]);const re=i.useMemo(()=>r==="idle"?a("cliTerminal.replayIdle","Session idle"):r==="ended"?a("cliTerminal.replayEnded","Session ended"):null,[r,a]),ve=i.useCallback(async()=>{if(g){ee(!0);try{await g("advance"),U(!0)}finally{ee(!1)}}},[g]),Ee=i.useCallback(async()=>{g&&await g("not-yet"),U(!0)},[g]),I=!!o?.elevated,ae=o?.elevatedFlags?.join(", "),Ce={"--terminal-glyph-font-family":J(z().fontFamily)};return t.jsxs("div",{className:`cli-session-terminal${P?" cli-session-terminal--mobile":""}${P&&B?" cli-session-terminal--keyboard-open":""}`,"data-mode":r,"data-read-only":se,"data-mobile":P,"data-keyboard-open":P&&B,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${I?" cli-posture-chip--elevated":""}`,"data-elevated":I,"aria-expanded":q,onClick:()=>Z(e=>!e),children:[I?t.jsx(Ke,{size:13,"aria-hidden":"true"}):t.jsx(je,{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}),I&&ae&&t.jsx("span",{className:"cli-posture-chip__flag",children:ae})]}),q&&t.jsxs("div",{className:"cli-posture-tooltip",role:"tooltip",children:[t.jsx("p",{className:"cli-posture-tooltip__title",children:a("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??a("cliTerminal.postureBaseline","Baseline")})]}),G&&t.jsxs("button",{type:"button",className:"cli-posture-tooltip__settings",onClick:()=>{Z(!1),G()},children:[t.jsx(Me,{size:12,"aria-hidden":"true"}),a("cliTerminal.adapterSettings","Adapter settings")]})]})]}),se&&t.jsxs("span",{className:"cli-session-terminal__readonly-badge",children:[t.jsx(Le,{size:12,"aria-hidden":"true"}),a("cliTerminal.readOnly","Read-only")]}),re&&t.jsx("span",{className:"cli-session-terminal__replay-badge","data-replay-mode":r,children:re})]}),t.jsx("div",{className:"cli-session-terminal__viewport-shell",children:t.jsx("div",{className:"cli-session-terminal__viewport",ref:x,"data-testid":"cli-terminal-viewport",style:Ce})}),$&&!fe&&t.jsxs("div",{className:"cli-session-terminal__advance-strip",role:"region",children:[t.jsx("span",{className:"cli-session-terminal__advance-copy",children:a("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:X,onClick:ve,children:a("cliTerminal.advance","Advance")}),t.jsx("button",{type:"button",className:"cli-session-terminal__advance-btn cli-session-terminal__advance-btn--secondary",disabled:X,onClick:Ee,children:a("cliTerminal.notYet","Not yet")})]})]}),P&&O&&t.jsxs("div",{className:`cli-session-terminal__mobile-bar${B?" cli-session-terminal__mobile-bar--keyboard-open":""}`,"data-testid":"cli-terminal-mobile-bar",style:B?{bottom:`${pe}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${j?" cli-terminal-key--active":""}`,"data-testid":"cli-key-ctrl","aria-label":a("cliTerminal.mobileKeyCtrl","Sticky Ctrl modifier"),"aria-pressed":j,onPointerDown:c,onMouseDown:c,onClick:()=>D(e=>!e),children:W.ctrl}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-esc","aria-label":a("cliTerminal.mobileKeyEsc","Send Escape"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Qe),children:W.escape}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-tab","aria-label":a("cliTerminal.mobileKeyTab","Send Tab"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Ve),children:W.tab}),t.jsx("button",{type:"button",className:"cli-terminal-key cli-terminal-key--ctrlc","data-testid":"cli-key-ctrl-c","aria-label":a("cliTerminal.mobileKeyCtrlC","Send Ctrl-C"),onPointerDown:c,onMouseDown:c,onClick:()=>{D(!1),b(Je)},children:W.ctrlC}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-up","aria-label":a("cliTerminal.mobileKeyArrowUp","Cursor up"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Ye),children:"↑"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-down","aria-label":a("cliTerminal.mobileKeyArrowDown","Cursor down"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Ge),children:"↓"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-left","aria-label":a("cliTerminal.mobileKeyArrowLeft","Cursor left"),onPointerDown:c,onMouseDown:c,onClick:()=>M(qe),children:"←"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-right","aria-label":a("cliTerminal.mobileKeyArrowRight","Cursor right"),onPointerDown:c,onMouseDown:c,onClick:()=>M(He),children:"→"}),be.map(e=>t.jsx("button",{type:"button",className:"cli-terminal-key cli-terminal-key--custom","data-testid":`cli-terminal-custom-shortcut-${e.id}`,title:e.label,"aria-label":e.label,onPointerDown:c,onMouseDown:c,onClick:()=>{D(!1),b(De(e.value))},children:e.label},e.id))]}),t.jsxs("form",{className:"cli-session-terminal__input-row",onSubmit:we,children:[t.jsx("input",{ref:ye,type:"text",className:"cli-session-terminal__mobile-input","data-testid":"cli-terminal-mobile-input",value:_,placeholder:a("cliTerminal.mobileInputPlaceholder","Type to send to the session…"),autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onChange:e=>Se(e.target.value)}),t.jsx("button",{type:"submit",className:"cli-session-terminal__mobile-send","data-testid":"cli-terminal-mobile-send","aria-label":a("cliTerminal.mobileSend","Send"),onPointerDown:c,onMouseDown:c,children:a("cliTerminal.mobileSend","Send")})]})]})]})}export{ut as SessionTerminal};
|
|
2
|
+
import{K as Pe,N as z,O as de,Q as J,U as ue,W as F,Y as je,_ as Me,p as Le,$ as De,a0 as Y,a1 as Oe,a2 as Ae,a as ze,a3 as K,a4 as Fe,a5 as Be}from"./index-DWRJyaa3.js";import{r as i,j as t}from"./vendor-react-SZ_qB27O.js";import"./vendor-xterm-BNq00GSj.js";import{u as Ie}from"./vendor-i18n-Duky4gdQ.js";import{S as Ke}from"./shield-alert-BS05s4RM.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";const We=32*1024,$e=1e4,Ue=100,Qe="\x1B",Ve=" ",Je="",Ye="\x1B[A",Ge="\x1B[B",He="\x1B[C",qe="\x1B[D",W={ctrl:"Ctrl",escape:"Esc",tab:"Tab",ctrlC:"^C"};function me(m){if(m.length!==1)return null;const o=m.toUpperCase().charCodeAt(0);return o>=64&&o<=95?String.fromCharCode(o&31):null}function Ze(){const[m,f]=i.useState(()=>Y());return i.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const o=window.matchMedia(Oe),r=window.visualViewport,y=()=>f(Y());return y(),typeof r?.addEventListener=="function"&&r.addEventListener("resize",y),typeof o.addEventListener=="function"?(o.addEventListener("change",y),()=>{o.removeEventListener("change",y),typeof r?.removeEventListener=="function"&&r.removeEventListener("resize",y)}):(o.addListener(y),()=>{o.removeListener(y),typeof r?.removeEventListener=="function"&&r.removeEventListener("resize",y)})},[]),m}function Xe(m,f){if(typeof window>"u")return"";const r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/cli-sessions/ws?sessionId=${encodeURIComponent(m)}&ticket=${encodeURIComponent(f)}`;return Be(r)}function et(){return/Mac|iPhone|iPad|iPod/i.test(navigator.platform)}function tt(m){if(typeof window<"u"&&typeof window.atob=="function"){const f=window.atob(m),o=new Uint8Array(f.length);for(let r=0;r<f.length;r++)o[r]=f.charCodeAt(r);return new TextDecoder("utf-8").decode(o)}return Buffer.from(m,"base64").toString("utf8")}function ut({sessionId:m,readOnly:f=!1,posture:o,mode:r="live",projectId:y,onConfirmAdvance:g,showConfirmAdvance:$=!1,onOpenAdapterSettings:G,active:H=!0}){const{t:a}=Ie("app"),x=i.useRef(null),v=i.useRef(null),N=i.useRef(null),R=i.useRef(null),h=i.useRef(null),[q,Z]=i.useState(!1),[fe,U]=i.useState(!1),[X,ee]=i.useState(!1),P=Ze(),{keyboardOpen:B,keyboardOverlap:pe}=Pe({enabled:P}),ye=i.useRef(null),[_,te]=i.useState(""),[j,D]=i.useState(!1),[be,he]=i.useState(()=>z().customShortcuts),[ne,ie]=i.useState(null),se=f||ne===!0,O=!f&&ne===!1&&r==="live",b=i.useCallback(e=>{if(!e||!O)return;const n=h.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:"input",data:e}))},[O]),M=i.useCallback(e=>{if(j){const n=me(e);if(D(!1),n){b(n);return}}b(e)},[j,b]),c=i.useCallback(e=>{e.preventDefault()},[]),we=i.useCallback(e=>{e?.preventDefault?.(),_&&b(_),b("\r"),te("")},[_,b]),Se=i.useCallback(e=>{if(j&&e.length>_.length){const n=e.slice(_.length,_.length+1),l=me(n);if(D(!1),l){b(l);return}}te(e)},[j,_,b]);i.useEffect(()=>{$&&U(!1)},[$,m]);const E=i.useCallback((e,n)=>{const l=h.current;l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"resize",cols:e,rows:n}))},[]),oe=i.useCallback(()=>{const e=v.current;if(!e)return;const n=z(),l=de(n.fontFamily);e.options.fontFamily=l,x.current?.style.setProperty("--terminal-glyph-font-family",J(n.fontFamily)),e.options.fontSize=n.fontSize,e.options.cursorStyle=n.cursorStyle,e.options.cursorBlink=n.cursorBlink&&O;try{N.current?.fit?.(),E(e.cols,e.rows)}catch{}ue(n.fontSize,l).then(k=>{if(!(!k||v.current!==e||e.options.fontSize!==n.fontSize||e.options.fontFamily!==l)){F(e,l),e.options.fontSize=n.fontSize;try{N.current?.fit?.(),E(e.cols,e.rows),F(e,l),e.refresh(0,Math.max(0,e.rows-1))}catch{}}},()=>{})},[O,E]);i.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.key===Ae&&(oe(),he(z().customShortcuts))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[oe]);const[_e,ke]=i.useState(0);i.useEffect(()=>{if(!H)return;const e=v.current,n=N.current;if(e&&n?.fit)try{n.fit(),E(e.cols,e.rows),F(e,String(e.options.fontFamily??"")),e.refresh(0,Math.max(0,e.rows-1))}catch{}const l=h.current;l&&l.readyState!==WebSocket.OPEN&&l.readyState!==WebSocket.CONNECTING&&ke(k=>k+1)},[H,E]),i.useEffect(()=>{if(!m||typeof window>"u")return;let e=!1,n=null,l=null,k=0;ie(null);const Q=E,Te=p=>{if(k+=p,k<We)return;const w=h.current;w?.readyState===WebSocket.OPEN&&w.send(JSON.stringify({type:"ack",bytes:k})),k=0};return(async()=>{let p;try{p=await ze(`/cli-sessions/${encodeURIComponent(m)}/attach-ticket`,{method:"POST",body:JSON.stringify(y?{projectId:y}:{})})}catch{return}if(e)return;ie(p.readOnly);const w=!f&&!p.readOnly&&r==="live",[{Terminal:ge},{FitAddon:xe},{Unicode11Addon:Ne}]=await Promise.all([K(()=>import("./vendor-xterm-BNq00GSj.js").then(d=>d.x),__vite__mapDeps([0,1,2])),K(()=>import("./addon-fit-C1WQXRvu.js").then(d=>d.a),__vite__mapDeps([3,1])),K(()=>import("./addon-unicode11-D3Fsv-Po.js"),[])]);if(e||!x.current)return;const S=z(),A=de(S.fontFamily);x.current.style.setProperty("--terminal-glyph-font-family",J(S.fontFamily));const s=new ge({convertEol:!1,cursorBlink:S.cursorBlink&&w,cursorStyle:S.cursorStyle,disableStdin:!w,scrollback:$e,fontFamily:A,fontSize:S.fontSize}),L=new xe;s.loadAddon(L);const Re=new Ne;if(s.loadAddon(Re),s.unicode.activeVersion="11",Fe(()=>{s.open(x.current)}),v.current=s,N.current=L,S.renderer==="auto"&&!Y())try{const{WebglAddon:d}=await K(async()=>{const{WebglAddon:u}=await import("./addon-webgl-uLc0RKcC.js").then(C=>C.a);return{WebglAddon:u}},__vite__mapDeps([4,1]));if(!e){const u=new d;u.onContextLoss(()=>{try{u.dispose()}catch{}R.current===u&&(R.current=null)}),s.loadAddon(u),R.current=u}}catch{}try{L.fit()}catch{}(async()=>{if(!(!await ue(S.fontSize,A)||e||v.current!==s||N.current!==L||s.options.fontSize!==S.fontSize||s.options.fontFamily!==A))try{F(s,A),s.options.fontSize=S.fontSize,L.fit(),Q(s.cols,s.rows),F(s,A),s.refresh(0,Math.max(0,s.rows-1))}catch{}})(),w&&(s.onData(d=>{const u=h.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"input",data:d}))}),s.attachCustomKeyEventHandler(d=>{if(d.type!=="keydown"||!(et()?d.metaKey:d.ctrlKey)||d.altKey||d.shiftKey)return!0;const C=d.key.toLowerCase();if(C==="c"){const T=s.hasSelection()?s.getSelection():"";return T?(navigator.clipboard?.writeText(T).catch(()=>{}),!1):!0}if(C==="v"){const T=navigator.clipboard?.readText;return T&&T.call(navigator.clipboard).then(le=>{if(!le)return;const ce=h.current;ce?.readyState===WebSocket.OPEN&&ce.send(JSON.stringify({type:"input",data:le}))}).catch(()=>{}),!1}return!0})),n=new ResizeObserver(()=>{l&&clearTimeout(l),l=setTimeout(()=>{try{L.fit(),Q(s.cols,s.rows),s.refresh(0,Math.max(0,s.rows-1))}catch{}},Ue)}),n.observe(x.current);const V=new WebSocket(Xe(m,p.ticket));h.current=V,V.onopen=()=>{Q(s.cols,s.rows)},V.onmessage=d=>{let u;try{u=JSON.parse(typeof d.data=="string"?d.data:"")}catch{return}switch(u.type){case"scrollback":case"data":{if(typeof u.data!="string")return;const C=tt(u.data),T=C.length;s.write(C,()=>Te(T));break}}}})(),()=>{e=!0,l&&clearTimeout(l),n&&n.disconnect();const p=h.current;if(p){p.onopen=null,p.onmessage=null,p.onclose=null,p.onerror=null;try{p.close()}catch{}h.current=null}if(R.current){try{R.current.dispose()}catch{}R.current=null}const w=v.current;if(w){try{w.dispose()}catch{}v.current=null}N.current=null}},[m,f,r,y,E,_e]);const re=i.useMemo(()=>r==="idle"?a("cliTerminal.replayIdle","Session idle"):r==="ended"?a("cliTerminal.replayEnded","Session ended"):null,[r,a]),ve=i.useCallback(async()=>{if(g){ee(!0);try{await g("advance"),U(!0)}finally{ee(!1)}}},[g]),Ee=i.useCallback(async()=>{g&&await g("not-yet"),U(!0)},[g]),I=!!o?.elevated,ae=o?.elevatedFlags?.join(", "),Ce={"--terminal-glyph-font-family":J(z().fontFamily)};return t.jsxs("div",{className:`cli-session-terminal${P?" cli-session-terminal--mobile":""}${P&&B?" cli-session-terminal--keyboard-open":""}`,"data-mode":r,"data-read-only":se,"data-mobile":P,"data-keyboard-open":P&&B,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${I?" cli-posture-chip--elevated":""}`,"data-elevated":I,"aria-expanded":q,onClick:()=>Z(e=>!e),children:[I?t.jsx(Ke,{size:13,"aria-hidden":"true"}):t.jsx(je,{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}),I&&ae&&t.jsx("span",{className:"cli-posture-chip__flag",children:ae})]}),q&&t.jsxs("div",{className:"cli-posture-tooltip",role:"tooltip",children:[t.jsx("p",{className:"cli-posture-tooltip__title",children:a("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??a("cliTerminal.postureBaseline","Baseline")})]}),G&&t.jsxs("button",{type:"button",className:"cli-posture-tooltip__settings",onClick:()=>{Z(!1),G()},children:[t.jsx(Me,{size:12,"aria-hidden":"true"}),a("cliTerminal.adapterSettings","Adapter settings")]})]})]}),se&&t.jsxs("span",{className:"cli-session-terminal__readonly-badge",children:[t.jsx(Le,{size:12,"aria-hidden":"true"}),a("cliTerminal.readOnly","Read-only")]}),re&&t.jsx("span",{className:"cli-session-terminal__replay-badge","data-replay-mode":r,children:re})]}),t.jsx("div",{className:"cli-session-terminal__viewport-shell",children:t.jsx("div",{className:"cli-session-terminal__viewport",ref:x,"data-testid":"cli-terminal-viewport",style:Ce})}),$&&!fe&&t.jsxs("div",{className:"cli-session-terminal__advance-strip",role:"region",children:[t.jsx("span",{className:"cli-session-terminal__advance-copy",children:a("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:X,onClick:ve,children:a("cliTerminal.advance","Advance")}),t.jsx("button",{type:"button",className:"cli-session-terminal__advance-btn cli-session-terminal__advance-btn--secondary",disabled:X,onClick:Ee,children:a("cliTerminal.notYet","Not yet")})]})]}),P&&O&&t.jsxs("div",{className:`cli-session-terminal__mobile-bar${B?" cli-session-terminal__mobile-bar--keyboard-open":""}`,"data-testid":"cli-terminal-mobile-bar",style:B?{bottom:`${pe}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${j?" cli-terminal-key--active":""}`,"data-testid":"cli-key-ctrl","aria-label":a("cliTerminal.mobileKeyCtrl","Sticky Ctrl modifier"),"aria-pressed":j,onPointerDown:c,onMouseDown:c,onClick:()=>D(e=>!e),children:W.ctrl}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-esc","aria-label":a("cliTerminal.mobileKeyEsc","Send Escape"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Qe),children:W.escape}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-tab","aria-label":a("cliTerminal.mobileKeyTab","Send Tab"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Ve),children:W.tab}),t.jsx("button",{type:"button",className:"cli-terminal-key cli-terminal-key--ctrlc","data-testid":"cli-key-ctrl-c","aria-label":a("cliTerminal.mobileKeyCtrlC","Send Ctrl-C"),onPointerDown:c,onMouseDown:c,onClick:()=>{D(!1),b(Je)},children:W.ctrlC}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-up","aria-label":a("cliTerminal.mobileKeyArrowUp","Cursor up"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Ye),children:"↑"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-down","aria-label":a("cliTerminal.mobileKeyArrowDown","Cursor down"),onPointerDown:c,onMouseDown:c,onClick:()=>M(Ge),children:"↓"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-left","aria-label":a("cliTerminal.mobileKeyArrowLeft","Cursor left"),onPointerDown:c,onMouseDown:c,onClick:()=>M(qe),children:"←"}),t.jsx("button",{type:"button",className:"cli-terminal-key","data-testid":"cli-key-arrow-right","aria-label":a("cliTerminal.mobileKeyArrowRight","Cursor right"),onPointerDown:c,onMouseDown:c,onClick:()=>M(He),children:"→"}),be.map(e=>t.jsx("button",{type:"button",className:"cli-terminal-key cli-terminal-key--custom","data-testid":`cli-terminal-custom-shortcut-${e.id}`,title:e.label,"aria-label":e.label,onPointerDown:c,onMouseDown:c,onClick:()=>{D(!1),b(De(e.value))},children:e.label},e.id))]}),t.jsxs("form",{className:"cli-session-terminal__input-row",onSubmit:we,children:[t.jsx("input",{ref:ye,type:"text",className:"cli-session-terminal__mobile-input","data-testid":"cli-terminal-mobile-input",value:_,placeholder:a("cliTerminal.mobileInputPlaceholder","Type to send to the session…"),autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onChange:e=>Se(e.target.value)}),t.jsx("button",{type:"submit",className:"cli-session-terminal__mobile-send","data-testid":"cli-terminal-mobile-send","aria-label":a("cliTerminal.mobileSend","Send"),onPointerDown:c,onMouseDown:c,children:a("cliTerminal.mobileSend","Send")})]})]})]})}export{ut as SessionTerminal};
|