@piagent/platform 1.43.4 → 1.43.6
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/CHANGELOG.md +26 -0
- package/docs/command-reference-vietnamese.md +2 -2
- package/docs/distribution-standard.md +6 -6
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/publishing-for-teams.md +2 -0
- package/docs/release-install-policy.md +2 -2
- package/docs/team-onboarding.md +2 -2
- package/docs-site/architecture.html +1 -1
- package/docs-site/assets/search-en.json +1 -1
- package/docs-site/assets/search-vi.json +1 -1
- package/docs-site/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/context-engine.html +1 -1
- package/docs-site/ecosystem.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +1 -1
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/ecosystem.html +1 -1
- package/docs-site/en/index.html +15 -15
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +1 -1
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/update.html +3 -3
- package/docs-site/en/whats-new.html +52 -31
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +15 -15
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/releases.json +62 -0
- package/docs-site/runtime.html +1 -1
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +1 -1
- package/docs-site/team.html +1 -1
- package/docs-site/update.html +3 -3
- package/docs-site/whats-new.html +52 -31
- package/docs-site/windows.html +1 -1
- package/docs-site/workflows.html +1 -1
- package/evals/private-holdout-v1/public-exposure.v2.json +1 -1
- package/package.json +1 -1
- package/packages/piagent-core/extensions/document-intake.ts +265 -19
- package/packages/piagent-core/managed/compaction.mjs +26 -0
- package/packages/piagent-core/managed/session.mjs +4 -4
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/runtime/input/attachment-store.ts +10 -10
- package/packages/piagent-core/runtime/input/attachment-types.ts +18 -0
- package/packages/piagent-core/runtime/inspection/document-workspace-projection.ts +1 -1
- package/packages/piagent-webui/dist/client/assets/{ActivityPanel-DRAiHliI.js → ActivityPanel-CBbfhN-m.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/App-C633xHZS.js +5 -0
- package/packages/piagent-webui/dist/client/assets/GatewayApp-cQ6cd7fw.js +97 -0
- package/packages/piagent-webui/dist/client/assets/{InspectionApp-C00GhY47.js → InspectionApp-B5eKxLEs.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-CBbWJmh7.js → SessionAgentWorkspace-N79svKS3.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-CMgkZoNX.js → SessionInspectorDrawer-mZqwulvp.js} +2 -2
- package/packages/piagent-webui/dist/client/assets/{SettingsNavigation-CM0s3QUC.js → SettingsNavigation-DzboWgoR.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/SettingsPage-DX2QIvRC.js +1 -0
- package/packages/piagent-webui/dist/client/assets/{TerminalPanel-DNKKZsMX.js → TerminalPanel-CiDM7fY8.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-DUffKV2S.js → WorkspaceCodeEditor-B5KeO5jf.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-D5iHXMqE.js → WorkspaceExplorer-C5M5c2uW.js} +3 -3
- package/packages/piagent-webui/dist/client/assets/{api-BUjrtT1B.js → api-BQS4Dtrr.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{index-D6GtlEqC.js → index-CrpbZF1r.js} +2 -2
- package/packages/piagent-webui/dist/client/assets/transcript-view-model-BCyNr6KF.js +3 -0
- package/packages/piagent-webui/dist/client/index.html +1 -1
- package/packages/piagent-webui/extension/piagent-webui.ts +2 -0
- package/packages/piagent-webui/server/core-inspection-provider.ts +6 -1
- package/packages/piagent-webui/server/ipc-read-model-client.ts +1 -0
- package/packages/piagent-webui/server/read-model-provider.ts +1 -0
- package/packages/piagent-webui/server/read-only-router.ts +6 -0
- package/packages/piagent-webui/server/transcript-projection.ts +20 -4
- package/schemas/piagent-webui/attachment-v1.schema.json +8 -1
- package/schemas/piagent-webui/document-workspace-v1.schema.json +3 -3
- package/packages/piagent-webui/dist/client/assets/App-CarM9drO.js +0 -5
- package/packages/piagent-webui/dist/client/assets/GatewayApp-uqpLU6gs.js +0 -93
- package/packages/piagent-webui/dist/client/assets/SettingsPage-Cr6M2FVg.js +0 -1
- package/packages/piagent-webui/dist/client/assets/transcript-view-model-BNGQCkzY.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-C2TMLUTo.js","assets/rolldown-runtime-hePW80VL.js","assets/dist-D6i5SpQu.js","assets/dist-IRUjhd1P.js","assets/dist-sNhoSseW.js","assets/dist-BM_LL1o9.js","assets/dist-DfjUS8LS.js","assets/dist-CqL3udNu.js","assets/dist-D4df0jLQ.js","assets/dist-B5MCHZv5.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Dn as n,In as r,ln as i,yn as a,zt as o}from"./vendor-CA5pzJiI.js";import{i as s,n as c,r as l}from"./ui-preferences-Dy4qeODT.js";import{t as u}from"./index-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Dn as n,In as r,ln as i,yn as a,zt as o}from"./vendor-CA5pzJiI.js";import{i as s,n as c,r as l}from"./ui-preferences-Dy4qeODT.js";import{t as u}from"./index-CrpbZF1r.js";import{C as d,D as f,E as p,G as m,N as h,O as g,S as _,T as v,j as y,k as b,t as x,w as S,x as C,y as w,z as T}from"./dist-D6i5SpQu.js";var E=class extends S{lines;label;comment;constructor(e,t,n){super(),this.lines=e,this.label=t,this.comment=n}toDOM(){let e=document.createElement(`div`);e.className=`cm-agent-deleted`;for(let t of this.lines){let n=document.createElement(`div`),r=document.createElement(`span`);if(r.textContent=`− ${t.text}`,n.append(r),this.comment){let e=document.createElement(`button`);e.type=`button`,e.textContent=this.label,e.setAttribute(`aria-label`,`${this.label} ${t.line}`),e.addEventListener(`click`,()=>this.comment?.(t.line,t.text,`old`)),n.append(e)}e.append(n)}return e}},D=class extends S{ref;label;keep;revertLabel;revert;constructor(e,t,n,r,i){super(),this.ref=e,this.label=t,this.keep=n,this.revertLabel=r,this.revert=i}toDOM(){let e=document.createElement(`div`);e.className=`cm-agent-actions`;let t=document.createElement(`button`);if(t.type=`button`,t.textContent=this.label,t.addEventListener(`click`,()=>this.keep(this.ref)),e.append(t),this.revert){let t=document.createElement(`button`);t.type=`button`,t.textContent=this.revertLabel,t.addEventListener(`click`,()=>this.revert?.(this.ref)),e.append(t)}return e}},O=new class extends d{toDOM(){let e=document.createElement(`span`);return e.textContent=`▎`,e.className=`cm-agent-marker`,e}};function k(e,t,n,r,i,a,o=``,s){let c=e.state.doc.toString(),l=[],u=[],d=t=>e.state.doc.line(Math.max(1,Math.min(e.state.doc.lines,t))).from;for(let e of t){let t=d(e.newStart+ +(e.newLineCount===0));u.push(t),l.push(C.widget({widget:new D(e.hunkRef,n,r,i,a),block:!0,side:-1}).range(t));let c=e.newStart+ +(e.newLineCount===0),f=[],p=()=>{f.length&&(l.push(C.widget({widget:new E(f,o,s),block:!0,side:-1}).range(d(c))),f=[])};for(let t of e.lines){if(t.kind===`deleted`){t.oldLineNumber!==null&&f.push({line:t.oldLineNumber,text:t.text});continue}p(),t.newLineNumber!==null&&(c=t.newLineNumber+1,t.kind===`added`&&l.push(C.line({class:`cm-agent-added`}).range(d(t.newLineNumber))))}p()}let f=T.define({create:()=>C.set(l,!0),update:(e,t)=>t.docChanged?C.none:e,provide:e=>_.decorations.from(e)}),p=e=>t=>{if(!u.length||t.state.doc.toString()!==c)return!1;let n=t.state.selection.main.head,r=e>0?u.find(e=>e>n)??u[0]:[...u].reverse().find(e=>e<n)??u.at(-1);return t.dispatch({selection:{anchor:r},effects:_.scrollIntoView(r,{y:`center`})}),!0};return[f,t.length?v({class:`cm-agent-gutter`,lineMarker:(e,t)=>e.state.field(f).size&&u.includes(t.from)?O:null}):[],g.of([{key:`Alt-ArrowDown`,run:p(1)},{key:`Alt-ArrowUp`,run:p(-1)}]),_.theme({".cm-agent-added":{backgroundColor:`color-mix(in srgb, #2e9d55 15%, transparent)`},".cm-agent-deleted":{margin:`0`,padding:`2px 8px`,whiteSpace:`pre-wrap`,backgroundColor:`color-mix(in srgb, #df4545 15%, transparent)`,fontFamily:`monospace`},".cm-agent-marker":{color:`#2e9d55`},".cm-agent-actions":{padding:`2px 8px`},".cm-agent-actions button":{color:`inherit`,background:`transparent`,border:`1px solid currentColor`,borderRadius:`4px`,cursor:`pointer`}})]}var A=e(r(),1),j=n();function M({syntax:e}){return x.define([{tag:[m.keyword,m.controlKeyword,m.moduleKeyword,m.definitionKeyword,m.modifier,m.self,m.null,m.bool,m.atom],color:e.keyword},{tag:[m.string,m.special(m.string),m.regexp,m.character],color:e.string},{tag:[m.number,m.integer,m.float,m.unit],color:e.number},{tag:[m.comment,m.lineComment,m.blockComment,m.docComment,m.meta],color:e.comment,fontStyle:`italic`},{tag:[m.function(m.variableName),m.function(m.propertyName),m.macroName],color:e.function},{tag:[m.typeName,m.className,m.namespace,m.tagName,m.standard(m.tagName)],color:e.type},{tag:[m.propertyName,m.attributeName,m.labelName],color:e.property},{tag:[m.operator,m.punctuation,m.bracket,m.derefOperator],color:e.operator},{tag:[m.heading,m.heading1,m.heading2,m.heading3],color:e.heading,fontWeight:`600`},{tag:[m.link,m.url],color:e.link,textDecoration:`underline`},{tag:m.emphasis,fontStyle:`italic`},{tag:m.strong,fontWeight:`600`},{tag:m.invalid,color:e.keyword,textDecoration:`underline wavy`}])}async function N(e){let t=e.split(`.`).at(-1)?.toLowerCase();switch(t){case`js`:case`mjs`:case`cjs`:case`jsx`:case`ts`:case`tsx`:return(await u(async()=>{let{javascript:e}=await import(`./dist-C2TMLUTo.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3,4]))).javascript({typescript:t===`ts`||t===`tsx`,jsx:t===`jsx`||t===`tsx`});case`json`:return(await u(async()=>{let{json:e}=await import(`./dist-BM_LL1o9.js`);return{json:e}},__vite__mapDeps([5,2,3]))).json();case`md`:return(await u(async()=>{let{markdown:e}=await import(`./dist-DfjUS8LS.js`);return{markdown:e}},__vite__mapDeps([6,2,4,7,3,8,1,0]))).markdown();case`py`:return(await u(async()=>{let{python:e}=await import(`./dist-B5MCHZv5.js`);return{python:e}},__vite__mapDeps([9,2,3,4]))).python();case`html`:return(await u(async()=>{let{html:e}=await import(`./dist-CqL3udNu.js`);return{html:e}},__vite__mapDeps([7,2,3,8,1,0,4]))).html();case`css`:return(await u(async()=>{let{css:e}=await import(`./dist-D4df0jLQ.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([8,1,2,3]))).css();default:return[]}}var P=[],F=e=>{};function I({content:e,path:n,line:r=1,readOnly:u=!0,onChange:d,onSave:m,hunks:v=P,onKeep:x=F,onRevert:S,onComment:C}){let T=(0,A.useRef)(null),E=(0,A.useRef)(null),D=i(),O=(0,A.useRef)({onChange:d,onSave:m,onComment:C});O.current={onChange:d,onSave:m,onComment:C};let I=(0,A.useRef)(e);I.current=e;let L=(0,A.useRef)(new y),R=(0,A.useRef)(new y),{locale:z}=s(),B=l();return(0,A.useEffect)(()=>{if(!T.current)return;let e=document.querySelector(`meta[name="csp-nonce"]`)?.content,t=new y,r=!1,i=new _({parent:T.current,state:h.create({doc:I.current,extensions:[R.current.of([]),_.cspNonce.of(e??``),L.current.of([h.readOnly.of(u),_.editable.of(!u)]),g.of([{key:`Mod-Shift-m`,run:e=>{let t=e.state.doc.lineAt(e.state.selection.main.head);return O.current.onComment?.(t.number,t.text),!!O.current.onComment}}]),g.of([`Ctrl-s`,`Meta-s`].map(e=>({key:e,run:()=>(O.current.onSave?.(),!0)}))),_.updateListener.of(e=>{e.docChanged&&O.current.onChange?.(e.state.doc.toString())}),b(),p(),f(),w(M(B)),t.of([]),_.contentAttributes.of({"aria-label":n,tabindex:`0`}),_.theme({"&":{height:`100%`,color:D.palette.text.primary,backgroundColor:D.palette.background.paper},".cm-scroller":{overflow:`auto`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:`13px`,lineHeight:1.55},".cm-content":{caretColor:D.palette.primary.main},".cm-cursor, .cm-dropCursor":{borderLeftColor:D.palette.primary.main},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:a(D.palette.primary.main,.25)},".cm-activeLine":{backgroundColor:a(D.palette.text.primary,.04)},".cm-gutters":{backgroundColor:D.palette.background.paper,color:D.palette.text.secondary,borderRight:`1px solid ${D.palette.divider}`},".cm-activeLineGutter":{backgroundColor:a(D.palette.text.primary,.06),color:D.palette.text.primary}},{dark:D.palette.mode===`dark`})]})});return E.current=i,N(n).then(e=>{r||i.dispatch({effects:t.reconfigure(e)})}).catch(()=>{}),()=>{r=!0,E.current=null,i.destroy()}},[n,D]),(0,A.useEffect)(()=>{let t=E.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e,n,D]),(0,A.useEffect)(()=>{let e=E.current;e&&e.dispatch({effects:R.current.reconfigure(k(e,v,c(z,`Giữ`,`Keep`),x,c(z,`Hoàn tác`,`Revert`),S,c(z,`Comment dòng đã xóa`,`Comment on removed line`),C))})},[v,x,S,C,e,n,D,z]),(0,A.useEffect)(()=>{E.current?.dispatch({effects:L.current.reconfigure([h.readOnly.of(u),_.editable.of(!u)])})},[u,n,D]),(0,A.useEffect)(()=>{let e=E.current;if(!e)return;let t=e.state.doc.line(Math.max(1,Math.min(e.state.doc.lines,r))).from;e.dispatch({selection:{anchor:t},effects:_.scrollIntoView(t,{y:`center`})})},[r,n,D]),(0,j.jsxs)(t,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[C&&(0,j.jsx)(o,{size:`small`,onClick:()=>{let e=E.current;if(!e)return;let t=e.state.doc.lineAt(e.state.selection.main.head);C(t.number,t.text)},children:c(z,`Comment dòng hiện tại`,`Comment on current line`)}),(0,j.jsx)(t,{ref:T,sx:{flex:1,minHeight:240,overflow:`hidden`}})]})}export{I as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceCodeEditor-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ct as n,Dn as r,Fn as i,G as a,Ht as o,In as s,It as c,L as l,Lt as u,Pt as d,Rt as f,St as p,U as m,Ut as h,Vt as g,W as _,_t as v,qt as y,t as ee,zt as b}from"./vendor-CA5pzJiI.js";import{i as x,n as S}from"./ui-preferences-Dy4qeODT.js";import{t as C}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceCodeEditor-B5KeO5jf.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-CA5pzJiI.js","assets/ui-preferences-Dy4qeODT.js","assets/index-CrpbZF1r.js","assets/index-Dqb2hNan.css","assets/dist-D6i5SpQu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ct as n,Dn as r,Fn as i,G as a,Ht as o,In as s,It as c,L as l,Lt as u,Pt as d,Rt as f,St as p,U as m,Ut as h,Vt as g,W as _,_t as v,qt as y,t as ee,zt as b}from"./vendor-CA5pzJiI.js";import{i as x,n as S}from"./ui-preferences-Dy4qeODT.js";import{t as C}from"./index-CrpbZF1r.js";import{i as w,n as T,o as E}from"./bootstrap-CedkNtRG.js";import{G as D,lt as te}from"./api-BQS4Dtrr.js";import{a as O}from"./workspace-navigation-C8GtShbg.js";import{r as k}from"./composer-drafts-BtMaVw8W.js";import{a as A,c as j,d as M,f as N,i as P,l as F,o as I,s as L,t as ne,u as re}from"./LineReview-DZ9ez8kO.js";import{t as ie}from"./tab-close-DHDqCxTL.js";import{i as ae,r as R,t as z}from"./workspace-api-O7auv_td.js";var B=e(s(),1),V=r();function oe(e,t,r,i=[]){let{locale:a}=x(),[o,s]=(0,B.useState)(()=>j(e)),[c,l]=(0,B.useState)();(0,B.useEffect)(()=>{s(j(e)),l(void 0);let t=t=>{t.detail===e&&s(j(e))};return window.addEventListener(I,t),()=>window.removeEventListener(I,t)},[e]),(0,B.useEffect)(()=>l(void 0),[t]);let u=t=>{s(t),M(e,t)},d={locale:a,comments:o,editing:c?L(c.path,c.side,c.line):null,open:(e,t,n,r)=>l({path:e,line:n,code:r,side:t}),cancel:()=>l(void 0),save:t=>{c&&u(re(j(e),{...c,text:t})),l(void 0)},remove:t=>u(j(e).filter(e=>L(e.path,e.side,e.line)!==t))},f=new Map(r.split(`
|
|
3
3
|
`).map((e,n)=>[L(t??``,`new`,n+1),e.slice(0,400)]));for(let e of i)for(let n of e.lines)n.oldLineNumber!==null&&f.set(L(t??``,`old`,n.oldLineNumber),n.text.slice(0,400));return{open:(e,n,r=`new`)=>{t&&l({path:t,line:e,code:n,side:r})},dialog:(0,V.jsxs)(n,{open:!!c,onClose:()=>l(void 0),fullWidth:!0,children:[(0,V.jsxs)(m,{children:[S(a,`Comment theo dòng`,`Line comment`),` · `,c?.path,`:`,c?.line]}),(0,V.jsx)(_,{children:(0,V.jsx)(A.Provider,{value:d,children:c&&(0,V.jsx)(P,{path:c.path,side:c.side,line:c.line})})})]}),bar:(0,V.jsx)(ne,{comments:o,lines:f,linesPath:t,locale:a,onClear:()=>u([]),onSend:()=>{let t=j(e);t.length&&k(e,F(t,a===`en`)),u([])}})}}var H=new Map;function se(e,r,i,o,s){let{locale:l}=x(),u=`${e}\0${r??``}`,d=`${u}\0${i}\0${o}`,f=(0,B.useRef)(d);f.current=d;let p=(0,B.useRef)(u);p.current=u;let h=(0,B.useRef)(!1),[v,y]=(0,B.useState)(!1),[ee,C]=(0,B.useState)(!1),[w,T]=(0,B.useState)(),[E,O]=(0,B.useState)(),[k,A]=(0,B.useState)(!1);(0,B.useEffect)(()=>{C(!1),T(void 0),O(void 0),A(H.has(u))},[u]);let j=async t=>{if(!(h.current||!o||!s||s.file.path!==r||s.file.currentDigest!==`sha256:${i}`)&&(C(!0),O(void 0),T(void 0),A(H.has(u)),!H.has(u))){h.current=!0,y(!0);try{let n=await D(e,s.file.fileRef,t);if(f.current!==d)return;if(n.state!==`ready`||!n.target||n.target.path!==r||n.target.fileRef!==s.file.fileRef||n.target.fileRevision!==s.file.fileRevision||!n.target.hunkRefs.some(e=>e===t))throw Error(`preview-unavailable`);T({value:n,scope:d})}catch{f.current===d&&O(S(l,`Chưa thể hoàn tác an toàn. Tải lại diff và thử lại.`,`Safe revert is unavailable. Refresh the diff and try again.`))}finally{h.current=!1,y(!1)}}},M=async()=>{if(!(h.current||!o||!H.has(u)&&(!w||w.scope!==d))){h.current=!0,y(!0),O(void 0);try{let t=H.get(u)??await N(w.value);if(f.current!==d)return;if(!H.has(u)&&H.size>=128){O(S(l,`Có quá nhiều lệnh chưa rõ kết quả. Kiểm tra lại các lệnh trước trước khi hoàn tác thêm.`,`Too many commands still need their results checked. Check earlier commands before reverting more.`));return}H.set(u,t),A(!0);let n=await te(t,void 0,e);if(n.phase!==`uncertain`&&H.delete(u),p.current===u&&A(H.has(u)),window.dispatchEvent(new CustomEvent(`piagent-workspace-changed`,{detail:{sessionRef:e}})),f.current!==d)return;A(H.has(u)),n.phase===`settled`?(C(!1),T(void 0)):(n.phase===`rejected`&&T(void 0),O(n.phase===`uncertain`?S(l,`Chưa xác định được kết quả. Kiểm tra tệp; kiểm tra lại sẽ dùng đúng lệnh cũ.`,`The result is uncertain. Inspect the file; checking again uses the same command.`):S(l,`Tệp hoặc quyền đã thay đổi. Hãy đóng và xem preview mới.`,`The file or permission changed. Close this dialog and request a new preview.`)))}catch{f.current===d&&O(S(l,`Chưa nhận được kết quả. Kiểm tra lại dùng cùng lệnh, không tạo lần hoàn tác mới.`,`No result received. Checking again reuses the same command.`))}finally{h.current=!1,y(!1)}}},P=w&&w.scope!==d;return{request:j,dialog:(0,V.jsxs)(n,{open:ee,onClose:()=>{v||C(!1)},fullWidth:!0,maxWidth:`md`,children:[(0,V.jsx)(m,{children:S(l,`Hoàn tác thay đổi của agent`,`Revert agent changes`)}),(0,V.jsxs)(_,{children:[(0,V.jsx)(c,{children:r}),(0,V.jsx)(c,{children:S(l,`Các dòng dưới đây sẽ được hoàn tác. Git index được giữ nguyên.`,`The changes below will be reverted. The Git index is preserved.`)}),E&&(0,V.jsx)(g,{severity:`warning`,children:E}),P&&(0,V.jsx)(g,{severity:`warning`,children:S(l,`Nội dung editor đã đổi. Mở lại preview trước khi hoàn tác.`,`Editor contents changed. Open a new preview before reverting.`)}),k&&!w&&(0,V.jsx)(g,{severity:`info`,children:S(l,`Có lệnh chưa xác nhận kết quả cho tệp này.`,`A command for this file still needs its result confirmed.`)}),w?.value.preview?.hunks.map(e=>(0,V.jsxs)(t,{component:`pre`,sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:[e.header,`
|
|
4
4
|
`,e.lines.map(e=>`${e.marker}${e.text}`).join(`
|
|
5
|
-
`)]},e.hunkRef))]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{disabled:v,onClick:()=>C(!1),children:S(l,`Đóng`,`Close`)}),(0,V.jsx)(b,{color:`error`,disabled:v||!o||!k&&(!w||!!P),onClick:()=>void M(),children:k?S(l,`Kiểm tra lại`,`Check again`):S(l,`Xác nhận hoàn tác`,`Confirm revert`)})]})]}),hasPending:k,checkPending:()=>{A(H.has(u)),C(!0)}}}async function U(e,t,n){let r=await fetch(`/api/v1/sessions/${encodeURIComponent(e)}/source-review${t?`/${encodeURIComponent(t)}`:``}`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:n});if(r.status===401&&E(),!r.ok)throw Error(`source-review-unavailable`);return r.json()}var W=(e,t)=>U(e,void 0,t),ce=(e,t,n)=>U(e,t,n);function le(e,t,n,r,i){if(!e||!r||!n||e.file.path!==t||e.file.currentDigest!==`sha256:${n}`||e.availability.state!==`current`||e.truncation.truncated||e.redaction.applied)return[];let a=new Set(e.agentHunkRefs??[]);return e.hunks.filter(e=>a.has(e.hunkRef)&&!i.has(`${t}:${n}:${e.hunkRef}`))}var G=new Set,K=new Map,q=new Set,J=`piagent.kept-hunks.`,Y=`piagent.kept-hunks`;function X(e){try{let t=JSON.parse(localStorage.getItem(J+e)??`[]`);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`).slice(-4096)):G}catch{return G}}function ue(e,t){try{let n=[...JSON.parse(localStorage.getItem(Y)??`[]`).filter(t=>t!==e),e];for(let e of n.splice(0,Math.max(0,n.length-64)))localStorage.removeItem(J+e);localStorage.setItem(J+e,JSON.stringify([...t])),localStorage.setItem(Y,JSON.stringify(n))}catch{}}var de=e=>(K.has(e)||K.set(e,X(e)),K.get(e)??G);function fe(e,t,n,r){let i=new Set([...de(e),`${t}:${n}:${r}`].slice(-4096));for(K.delete(e),K.set(e,i);K.size>64;)K.delete(K.keys().next().value);ue(e,i);for(let e of q)e()}function pe(e){return(0,B.useSyncExternalStore)(e=>(q.add(e),()=>{q.delete(e)}),()=>de(e))}function me(e,t,n){let[r,i]=(0,B.useState)(),a=pe(e),o=JSON.stringify(t.map(e=>e.file.path).sort());(0,B.useEffect)(()=>{let t=JSON.parse(o);if(!t.length){i(void 0);return}let n=new AbortController,r=!1,a=!1,s=async()=>{if(!n.signal.aborted){if(r){a=!0;return}r=!0;try{let r=await W(e,n.signal),a=new Map;for(let i of t){if(n.signal.aborted)return;let t=r.files.find(e=>e.path===i&&e.pathDisplay===`exact-safe`);if(t)try{a.set(i,await ce(e,t.fileRef,n.signal))}catch{}}n.signal.aborted||i({session:e,diffs:a})}catch{n.signal.aborted||i(void 0)}finally{r=!1,a&&!n.signal.aborted&&(a=!1,s())}}};s();let c=window.setInterval(()=>void s(),3e3),l=t=>{t.detail?.sessionRef===e&&s()};return window.addEventListener(`piagent-workspace-saved`,l),window.addEventListener(`piagent-workspace-changed`,l),()=>{n.abort(),clearInterval(c),window.removeEventListener(`piagent-workspace-saved`,l),window.removeEventListener(`piagent-workspace-changed`,l)}},[e,o]);let s=r?.session===e?r.diffs:void 0,c=e=>le(s?.get(e.file.path),e.file.path,e.file.digest,!e.fresh&&!e.pending&&e.draft===(e.file.content??``),a),l=t.find(e=>e.file.path===n),u=l?c(l):[];return{diff:n?s?.get(n):void 0,hunks:u,counts:new Map(t.map(e=>[e.file.path,c(e).length])),keep:t=>{l?.file.digest&&u.some(e=>e.hunkRef===t)&&fe(e,l.file.path,l.file.digest,t)}}}var Z=new Map,he=new Set,ge={tabs:[]},Q=e=>e.fresh||e.draft!==(e.file.content??``);window.addEventListener(`beforeunload`,e=>{[...Z.values()].some(e=>e.tabs.some(Q))&&(e.preventDefault(),e.returnValue=``)});var _e=e=>Z.get(e)??ge;function ve(e){let t=(0,B.useSyncExternalStore)(e=>(he.add(e),()=>{he.delete(e)}),()=>Z.get(e)??ge),n=t=>{Z.set(e,t(Z.get(e)??ge));for(let e of he)e()};return{...t,update:n}}function ye(e,t,n){return e.file!==t||e.file.path!==n.path||e.pending||e.fresh||e.file.digest===n.digest&&e.file.protected===n.protected&&e.file.readOnly===n.readOnly?{tab:e}:e.draft===(e.file.content??``)?{tab:{...e,file:n,draft:n.content??``}}:{tab:e,conflict:n}}function be(e,t,n){let{update:r}=ve(e),i=(0,B.useRef)({update:r,conflict:n});i.current={update:r,conflict:n},(0,B.useEffect)(()=>{let n=new AbortController,r=new Map,a=!1,o=!1,s,c=async()=>{if(!(n.signal.aborted||t.current)){if(a){o=!0;return}a=!0;try{for(let a of _e(e).tabs)if(!(a.fresh||a.pending||t.current))try{let o=await z(e,a.file.path,n.signal);if(n.signal.aborted||t.current)return;let s;if(i.current.update(e=>({...e,tabs:e.tabs.map(t=>{if(t.file.path!==a.file.path)return t;let n=ye(t,a.file,o);return n.conflict&&e.active===t.file.path&&(s=n.conflict),n.tab})})),s){let e=`${s.digest}:${s.protected}:${s.readOnly}`;r.get(s.path)!==e&&(r.set(s.path,e),i.current.conflict(s))}}catch{}}finally{a=!1,o&&!n.signal.aborted&&(o=!1,l())}}},l=()=>{s||=setTimeout(()=>{s=void 0,c()},100)},u=t=>{t.detail?.sessionRef===e&&l()};window.addEventListener(`piagent-workspace-changed`,u),window.addEventListener(`piagent-workspace-saved`,u);let d=setInterval(l,5e3);return l(),()=>{n.abort(),clearTimeout(s),clearInterval(d),window.removeEventListener(`piagent-workspace-changed`,u),window.removeEventListener(`piagent-workspace-saved`,u)}},[e,t])}var xe=e=>`/api/v1/sessions/${encodeURIComponent(e)}/workspace/write`;function $(e){return Array.isArray(e)?`[${e.map($).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${$(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Se(e,t){let n=await fetch(xe(e),{credentials:`same-origin`,signal:t,headers:{Accept:`application/json`}});if(n.status===401&&E(),!n.ok)throw Error(`workspace-write-unavailable`);return await n.json()}async function Ce(e,t){let n=Date.now(),r=`workspace.write`,i=e.identity,a=e.revisions,o=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode($({action:r,identity:i,expectedRevisions:a,payload:t})));return{schemaVersion:1,version:`piagent-webui-workspace-write-v1`,messageType:`command`,action:r,identity:i,expectedRevisions:a,payload:t,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(n).toISOString(),expiresAt:new Date(n+6e4).toISOString(),actionDigest:`sha256:${[...new Uint8Array(o)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}}async function we(e,t){let n=T();if(!n)throw Error(`workspace-write-unavailable`);let r=await w(xe(e),{method:`POST`,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(t)});if(r.status===401&&E(),!r.ok)throw Error(`workspace-write-unavailable`);let i=await r.json(),a=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t.idempotencyKey)),o=`sha256:${[...new Uint8Array(a)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`;if(i.schemaVersion!==1||i.version!==t.version||i.messageType!==`receipt`||i.path!==t.payload.path||i.commandId!==t.commandId||i.action!==t.action||i.actionDigest!==t.actionDigest||i.idempotencyKeyDigest!==o||$(i.identity)!==$(t.identity)||![`settled`,`rejected`,`uncertain`].includes(i.phase)||i.phase===`settled`&&(i.resultCode!==`saved`||!/^[a-f0-9]{64}$/.test(i.digest??``)))throw Error(`workspace-write-receipt-invalid`);return i}function Te(e){let{locale:t}=x(),n=ve(e),[r,i]=(0,B.useState)(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(!1),[c,l]=(0,B.useState)(),[u,d]=(0,B.useState)();be(e,s,d),(0,B.useEffect)(()=>{let t=new AbortController,n=!1,r=()=>{n||(n=!0,Se(e,t.signal).then(i).catch(()=>{t.signal.aborted||i(void 0)}).finally(()=>{n=!1}))};r();let a=window.setInterval(r,5e3);return()=>{t.abort(),clearInterval(a)}},[e]);let f=(e,t=1,r=!1)=>n.update(n=>({active:e.path,tabs:[...n.tabs.filter(t=>t.file.path!==e.path),{file:e,line:t,fresh:r,draft:e.content??``}]})),p=(e,t)=>n.update(n=>({...n,active:e,tabs:n.tabs.map(n=>n.file.path===e&&t!==void 0?{...n,line:t}:n)})),m=(e,t)=>n.update(n=>({...n,tabs:n.tabs.map(n=>n.file.path===e?{...n,draft:t}:n)})),h=r=>{let i=_e(e).tabs.find(e=>e.file.path===r);i&&(Q(i)||i.pending)&&!window.confirm(S(t,`Bỏ thay đổi chưa lưu và đóng tệp?`,`Discard unsaved changes and close this file?`))||n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?e.tabs.find(e=>e.file.path!==r)?.file.path:e.active}))},g=async n=>{try{f(await z(e,n)),d(void 0),l(void 0)}catch{l(S(t,`Chưa tải lại được tệp. Bản sửa của bạn vẫn được giữ.`,`Could not reload the file. Your draft is preserved.`))}},_=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(!(!c||s.current||!Q(c)&&!c.pending||c.file.protected||c.file.readOnly)&&!(a&&!window.confirm(S(t,`Ghi đè phiên bản trên đĩa bằng bản sửa của bạn?`,`Replace the version on disk with your draft?`)))){s.current=!0,o(!0),l(void 0);try{let o=await Se(e);if(i(o),!o.writable)throw Error(`read-only`);let s=a?.digest??(c.fresh?`absent`:c.file.digest);if(!s)throw Error(`unavailable`);let u=c.pending??await Ce(o,{path:r,content:c.draft,expectedDigest:s});n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:u}:e)}));let f=await we(e,u);if(f.phase===`uncertain`){l(S(t,`Chưa xác định được kết quả lưu. Tải lại để kiểm tra trước khi lưu tiếp.`,`The save result is uncertain. Reload to check before saving again.`));return}n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:void 0}:e)})),f.phase===`settled`&&f.resultCode===`saved`?(n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,fresh:!1,file:{...e.file,content:u.payload.content,digest:f.digest,revision:f.observedRevisionsAfter.workspaceRevision}}:e)})),d(void 0),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}}))):f.resultCode===`stale-content`||f.resultCode===`stale-revision`?d(await z(e,r)):l(S(t,`Chưa lưu được tệp. Kiểm tra quyền ghi và thử lại.`,`Could not save the file. Check write access and try again.`))}catch{l(S(t,`Chưa lưu được tệp. Bản sửa vẫn được giữ; thử lưu lại hoặc tải lại để kiểm tra.`,`Could not confirm the save. Your draft is preserved; retry the save or reload to check.`))}finally{s.current=!1,o(!1)}}},v=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(s.current||c&&(Q(c)||c.pending))return l(S(t,`Lưu hoặc bỏ thay đổi trước khi đổi tên hay xóa tệp.`,`Save or discard your changes before renaming or deleting the file.`)),!1;s.current=!0,o(!0),l(void 0);try{let o=await Se(e);i(o);let s=c?.file.digest??(await z(e,r)).digest;if(!o.writable||!s)throw Error(`unavailable`);let u=await we(e,await Ce(o,a?{path:r,content:``,expectedDigest:s,operation:`rename`,destination:a}:{path:r,content:``,expectedDigest:s,operation:`delete`}));return u.phase===`settled`&&u.resultCode===`saved`?(n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?void 0:e.active})),a&&f(await z(e,a)),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}})),!0):(l(u.phase===`uncertain`?S(t,`Chưa xác định được kết quả. Tải lại danh sách tệp để kiểm tra.`,`The result is uncertain. Reload the file list to check.`):u.resultCode===`stale-content`?S(t,`Tệp đã thay đổi trên đĩa hoặc tên mới đã có. Tải lại rồi thử lại.`,`The file changed on disk or the new name exists. Reload and try again.`):S(t,`Không thực hiện được. Kiểm tra quyền ghi và tên tệp.`,`This could not be done. Check write access and the file name.`)),!1)}catch{return l(S(t,`Chưa xác nhận được thao tác. Tải lại danh sách tệp để kiểm tra.`,`Could not confirm the action. Reload the file list to check.`)),!1}finally{s.current=!1,o(!1)}};return{...n,authority:r,saving:a,message:c,conflict:u,setConflict:d,load:f,select:p,change:m,close:h,reload:g,save:_,move:v}}var Ee=e(i(),1);function De({sessionRef:e,onOpen:t}){let{locale:n}=x(),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(),[s,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t=new AbortController;if(o(void 0),d(!1),l(!1),!r.trim())return()=>t.abort();l(!0);let n=setTimeout(()=>{ae(e,r,t.signal).then(e=>{t.signal.aborted||o(e)}).catch(()=>{t.signal.aborted||d(!0)}).finally(()=>{t.signal.aborted||l(!1)})},250);return()=>{clearTimeout(n),t.abort()}},[r,e]),(0,V.jsxs)(p,{spacing:1,sx:{p:1},children:[(0,V.jsx)(v,{size:`small`,label:S(n,`Tìm nội dung`,`Search contents`),value:r,onChange:e=>i(e.target.value),slotProps:{htmlInput:{maxLength:512}}}),s&&(0,V.jsx)(h,{size:18}),(u||a?.available===!1)&&(0,V.jsx)(g,{severity:`warning`,children:S(n,`Chưa tìm được nội dung trong project này.`,`Content search is unavailable for this project.`)}),a?.available&&a.backend===`fts`&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Tìm trong các tệp đã lập chỉ mục.`,`Searching indexed files.`)}),a?.matches.map(e=>(0,V.jsxs)(b,{onClick:()=>t(e.path,e.line),sx:{textTransform:`none`,display:`block`,textAlign:`left`,overflowWrap:`anywhere`},children:[(0,V.jsxs)(c,{variant:`caption`,component:`span`,children:[e.path,`:`,e.line,`:`,e.column]}),(0,V.jsx)(c,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.preview})]},`${e.path}:${e.line}:${e.column}`)),a?.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Đã giới hạn kết quả. Hãy tìm cụ thể hơn.`,`Results were limited. Refine your search.`)}),a?.available&&!a.matches.length&&!a.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Không tìm thấy.`,`No matches.`)})]})}var Oe=y((0,V.jsx)(`path`,{d:`M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z`}),`ChevronRight`),ke=y((0,V.jsx)(`path`,{d:`M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z`}),`ExpandMore`),Ae=y((0,V.jsx)(`path`,{d:`M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zM6 20V4h7v5h5v11z`}),`InsertDriveFileOutlined`),je=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`));function Me({sessionRef:e,refresh:n,active:r,onOpen:i,onFolder:a}){let{locale:o}=x(),[s,u]=(0,B.useState)(()=>new Set([``])),[f,p]=(0,B.useState)(()=>new Map),[m,g]=(0,B.useState)(),_=(t,n)=>{p(e=>new Map(e).set(t,e.get(t)??`loading`)),R(e,t,n).then(e=>{n?.aborted||p(n=>new Map(n).set(t,e))}).catch(()=>{n?.aborted||p(e=>new Map(e).set(t,`error`))})};(0,B.useEffect)(()=>{p(new Map),u(new Set([``]))},[e]),(0,B.useEffect)(()=>{let e=new AbortController;for(let t of s)_(t,e.signal);return()=>e.abort()},[e,n]),(0,B.useEffect)(()=>{if(!r)return;let e=je(r).filter(e=>!s.has(e));if(e.length){u(t=>new Set([...t,...e]));for(let t of e)f.has(t)||_(t)}},[r]);let v=e=>{if(g(e),a(e),s.has(e)){u(t=>{let n=new Set(t);return n.delete(e),n});return}u(t=>new Set(t).add(e)),(!f.has(e)||f.get(e)===`error`)&&_(e)},y=(e,n)=>{let a=f.get(e);return!a||a===`loading`?(0,V.jsx)(h,{size:14,sx:{ml:1.5+n*1.5,my:.5}}):a===`error`?(0,V.jsx)(c,{variant:`caption`,color:`warning.main`,sx:{pl:1.5+n*1.5},children:S(o,`Chưa đọc được thư mục này.`,`This folder could not be read.`)}):(0,V.jsxs)(V.Fragment,{children:[a.entries.map(e=>{let a=e.kind===`directory`,c=a&&s.has(e.path),u=a?m===e.path:r===e.path,f=a?(0,V.jsxs)(V.Fragment,{children:[c?(0,V.jsx)(ke,{sx:{fontSize:16}}):(0,V.jsx)(Oe,{sx:{fontSize:16}}),c?(0,V.jsx)(l,{sx:{fontSize:16}}):(0,V.jsx)(d,{sx:{fontSize:16}})]}):(0,V.jsx)(Ae,{sx:{fontSize:16,ml:`16px`}});return(0,V.jsxs)(t,{children:[(0,V.jsxs)(b,{fullWidth:!0,size:`small`,disabled:e.protected||e.kind===`symlink`||e.kind===`other`,"aria-label":e.protected?`${e.name} (${S(o,`được bảo vệ`,`protected`)})`:e.name,"aria-expanded":a?c:void 0,"aria-current":!a&&r===e.path?`true`:void 0,onClick:()=>a?v(e.path):(g(void 0),i(e.path)),sx:{justifyContent:`flex-start`,textTransform:`none`,gap:.5,minHeight:24,py:0,pl:.5+n*1.5,pr:1,color:`text.primary`,fontWeight:400,whiteSpace:`nowrap`,bgcolor:u?`action.selected`:void 0},children:[f,(0,V.jsxs)(t,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`},children:[e.name,e.protected?` 🔒`:``]})]}),c&&y(e.path,n+1)]},e.path)}),a.truncated&&(0,V.jsx)(c,{variant:`caption`,sx:{pl:1.5+n*1.5},children:S(o,`Danh sách đã được giới hạn.`,`Listing limit reached.`)})]})};return(0,V.jsx)(t,{role:`group`,"aria-label":S(o,`Cây thư mục`,`Folder tree`),sx:{py:.5},children:y(``,0)})}var Ne=(0,B.lazy)(()=>C(()=>import(`./WorkspaceCodeEditor-DUffKV2S.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function Pe({sessionRef:e,target:r,navigationHost:i,sidebarMode:s,onHide:l,fill:d}){let{locale:y}=x(),[C,w]=(0,B.useState)(`files`),[T,E]=(0,B.useState)(!1),[D,te]=(0,B.useState)(``),[k,A]=(0,B.useState)(!1),[j,M]=(0,B.useState)(),[N,P]=(0,B.useState)(``),F=Te(e),{tabs:I,active:L}=F,[ne,re]=(0,B.useState)(``),[ae,R]=(0,B.useState)(!1),[H,U]=(0,B.useState)(!1),W=(0,B.useRef)(null),[ce,le]=(0,B.useState)(0);(0,B.useEffect)(()=>{let t=t=>{t.detail?.sessionRef===e&&le(e=>e+1)};return window.addEventListener(`piagent-workspace-saved`,t),()=>window.removeEventListener(`piagent-workspace-saved`,t)},[e]),(0,B.useEffect)(()=>()=>W.current?.abort(),[]);let G=async(t,n=1)=>{if(W.current?.abort(),U(!1),I.find(e=>e.file.path===t)){F.select(t,n);return}W.current?.abort();let r=new AbortController;W.current=r,U(!0),R(!1);try{let i=await z(e,t,r.signal);if(r.signal.aborted)return;if(i.protected){R(!0);return}F.load(i,n)}catch{r.signal.aborted||R(!0)}finally{r.signal.aborted||U(!1)}};(0,B.useEffect)(()=>{r&&G(r.path,r.line??1)},[r]),(0,B.useEffect)(()=>{s&&s!==`sessions`&&w(s)},[s]);let K=I.find(e=>e.file.path===L),q=K?.file,J=me(e,I,L),Y=se(e,q?.path,q?.digest??null,!!K&&!Q(K),J.diff),X=oe(e,q?.path,K?.draft??``,J.hunks),ue=I.find(e=>e.file.path===F.conflict?.path),de=(0,V.jsxs)(t,{component:`nav`,"aria-label":S(y,`Tệp dự án`,`Project files`),sx:{width:i?`100%`:{xs:136,sm:200},flexShrink:0,overflow:`auto`,borderRight:1,borderColor:`divider`},children:[!i&&(0,V.jsxs)(u,{value:C,onChange:(e,t)=>w(t),"aria-label":S(y,`Khám phá project`,`Explore project`),children:[(0,V.jsx)(f,{value:`files`,label:S(y,`Tệp`,`Files`)}),(0,V.jsx)(f,{value:`search`,label:S(y,`Tìm kiếm`,`Search`)})]}),C===`search`?(0,V.jsx)(De,{sessionRef:e,onOpen:(e,t)=>void G(e,t)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(b,{disabled:!F.authority?.writable,onClick:()=>{te(ne?`${ne}/`:``),E(!0)},children:S(y,`Tệp mới`,`New file`)}),(0,V.jsx)(Me,{sessionRef:e,refresh:ce,active:L,onOpen:e=>{re(e.split(`/`).slice(0,-1).join(`/`)),G(e)},onFolder:re})]})]});return(0,V.jsxs)(V.Fragment,{children:[Y.dialog,X.dialog,(0,V.jsxs)(p,{direction:`row`,sx:{height:d?`100%`:`calc(100vh - 150px)`,minHeight:d?160:320},children:[i?(0,Ee.createPortal)(de,i):de,(0,V.jsxs)(t,{sx:{minWidth:0,flex:1,display:`flex`,flexDirection:`column`},children:[ae&&(0,V.jsx)(g,{severity:`warning`,children:S(y,`Chưa đọc được tệp hoặc thư mục này.`,`This file or folder could not be read.`)}),X.bar,F.message&&(0,V.jsx)(g,{severity:`warning`,children:F.message}),F.authority?.agentRunning&&(0,V.jsx)(g,{severity:`info`,children:S(y,`Agent đang chạy và có thể sửa tệp này.`,`The agent is running and may change this file.`)}),(0,V.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,borderBottom:1,borderColor:`divider`,minHeight:36},children:[(0,V.jsx)(u,{value:L??!1,onChange:(e,t)=>F.select(t),variant:`scrollable`,scrollButtons:`auto`,"aria-label":S(y,`Các tệp đang mở`,`Open files`),sx:{flex:1,minWidth:0,minHeight:36},children:I.map(e=>(0,V.jsx)(f,{value:e.file.path,sx:{minHeight:36,py:0},"aria-label":`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,label:ie(`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,S(y,`Đóng ${e.file.path}`,`Close ${e.file.path}`),()=>F.close(e.file.path))},e.file.path))}),l&&(0,V.jsx)(o,{size:`small`,"aria-label":S(y,`Ẩn khung tệp`,`Hide files panel`),title:S(y,`Ẩn khung tệp (tệp đang mở vẫn giữ)`,`Hide files panel (open files are kept)`),onClick:l,children:(0,V.jsx)(ee,{fontSize:`small`})})]}),H&&(0,V.jsx)(h,{size:20}),q&&(0,V.jsxs)(p,{direction:`row`,sx:{flexShrink:0,overflowX:`auto`,"& .MuiButton-root":{whiteSpace:`nowrap`,flexShrink:0}},children:[Y.hasPending&&(0,V.jsx)(b,{onClick:Y.checkPending,children:S(y,`Kiểm tra hoàn tác`,`Check revert`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!K||!Q(K)&&!K.pending||F.saving,onClick:()=>void F.save(q.path),children:S(y,`Lưu`,`Save`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>F.close(q.path),children:S(y,`Đóng tệp`,`Close file`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{P(q.path),M(q.path)},children:S(y,`Đổi tên`,`Rename`)}),(0,V.jsx)(b,{size:`small`,color:`error`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{window.confirm(S(y,`Xóa ${q.path}? Có thể khôi phục bằng Git nếu tệp đã commit.`,`Delete ${q.path}? Git can restore it if it was committed.`))&&F.move(q.path)},children:S(y,`Xóa`,`Delete`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>{(!K||!Q(K)||window.confirm(S(y,`Bỏ thay đổi chưa lưu và tải lại?`,`Discard unsaved changes and reload?`)))&&F.reload(q.path)},children:S(y,`Tải lại`,`Reload`)})]}),q?.binary||q?.oversized?(0,V.jsx)(g,{severity:`info`,children:S(y,`Tệp nhị phân hoặc quá lớn để hiển thị.`,`This file is binary or too large to display.`)}):q?.content!==null&&q?.content!==void 0?(0,V.jsx)(t,{sx:{flex:1,minHeight:0},children:(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{onComment:X.open,hunks:J.hunks,onKeep:J.keep,onRevert:F.authority?.writable?e=>void Y.request(e):void 0,content:K?.draft??q.content,path:q.path,line:K?.line??1,readOnly:!F.authority?.writable||q.readOnly,onChange:e=>F.change(q.path,e),onSave:()=>void F.save(q.path)})})}):(0,V.jsx)(c,{sx:{p:2},children:S(y,`Chọn một tệp để mở.`,`Select a file to open.`)})]})]}),(0,V.jsxs)(n,{open:T,onClose:()=>E(!1),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Tạo tệp mới`,`Create a new file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn trong project`,`Path in project`),value:D,onChange:e=>te(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>E(!1),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(D)||!F.authority?.writable,onClick:()=>{let e=O(D);!e||!F.authority||(I.some(t=>t.file.path===e.path)?F.select(e.path):F.load({schemaVersion:1,version:`piagent-webui-workspace-file-v1`,generatedAt:new Date().toISOString(),identity:F.authority.identity,path:e.path,language:`text`,protected:!1,readOnly:!1,binary:!1,oversized:!1,content:``,digest:null,revision:null},1,!0),E(!1))},children:S(y,`Tạo`,`Create`)})]})]}),(0,V.jsxs)(n,{open:!!j,onClose:()=>M(void 0),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Đổi tên tệp`,`Rename file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn mới trong project`,`New path in project`),value:N,onChange:e=>P(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>M(void 0),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(N)||O(N)?.path===j||F.saving,onClick:()=>{let e=O(N);!e||!j||F.move(j,e.path).then(e=>{e&&M(void 0)})},children:S(y,`Đổi tên`,`Rename`)})]})]}),(0,V.jsxs)(n,{open:!!F.conflict,onClose:()=>{F.setConflict(void 0),A(!1)},fullWidth:!0,maxWidth:k?`lg`:`sm`,children:[(0,V.jsx)(m,{children:S(y,`Tệp đã thay đổi trên đĩa`,`The file changed on disk`)}),(0,V.jsxs)(_,{children:[(0,V.jsx)(c,{children:F.conflict?.path}),(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn vẫn được giữ. Chọn cách xử lý xung đột.`,`Your draft is preserved. Choose how to resolve the conflict.`)}),k&&F.conflict&&ue&&(0,V.jsxs)(p,{direction:`row`,spacing:1,children:[(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Trên đĩa`,`On disk`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:F.conflict.path,content:F.conflict.content??``})})]}),(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn`,`Your draft`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:ue.file.path,content:ue.draft})})]})]})]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>{F.setConflict(void 0),A(!1)},children:S(y,`Để sau`,`Later`)}),(0,V.jsx)(b,{onClick:()=>{F.conflict&&(F.load(F.conflict),F.setConflict(void 0),A(!1))},children:S(y,`Tải lại`,`Reload`)}),(0,V.jsx)(b,{onClick:()=>A(!0),children:S(y,`Xem khác biệt`,`Compare`)}),(0,V.jsx)(b,{disabled:F.saving||!F.conflict?.digest||F.conflict.protected||F.conflict.readOnly,onClick:()=>{F.conflict&&F.save(F.conflict.path,F.conflict)},children:S(y,`Ghi đè`,`Overwrite`)})]})]})]})}export{Pe as default};
|
|
5
|
+
`)]},e.hunkRef))]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{disabled:v,onClick:()=>C(!1),children:S(l,`Đóng`,`Close`)}),(0,V.jsx)(b,{color:`error`,disabled:v||!o||!k&&(!w||!!P),onClick:()=>void M(),children:k?S(l,`Kiểm tra lại`,`Check again`):S(l,`Xác nhận hoàn tác`,`Confirm revert`)})]})]}),hasPending:k,checkPending:()=>{A(H.has(u)),C(!0)}}}async function U(e,t,n){let r=await fetch(`/api/v1/sessions/${encodeURIComponent(e)}/source-review${t?`/${encodeURIComponent(t)}`:``}`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:n});if(r.status===401&&E(),!r.ok)throw Error(`source-review-unavailable`);return r.json()}var W=(e,t)=>U(e,void 0,t),ce=(e,t,n)=>U(e,t,n);function le(e,t,n,r,i){if(!e||!r||!n||e.file.path!==t||e.file.currentDigest!==`sha256:${n}`||e.availability.state!==`current`||e.truncation.truncated||e.redaction.applied)return[];let a=new Set(e.agentHunkRefs??[]);return e.hunks.filter(e=>a.has(e.hunkRef)&&!i.has(`${t}:${n}:${e.hunkRef}`))}var G=new Set,K=new Map,q=new Set,J=`piagent.kept-hunks.`,Y=`piagent.kept-hunks`;function X(e){try{let t=JSON.parse(localStorage.getItem(J+e)??`[]`);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`).slice(-4096)):G}catch{return G}}function ue(e,t){try{let n=[...JSON.parse(localStorage.getItem(Y)??`[]`).filter(t=>t!==e),e];for(let e of n.splice(0,Math.max(0,n.length-64)))localStorage.removeItem(J+e);localStorage.setItem(J+e,JSON.stringify([...t])),localStorage.setItem(Y,JSON.stringify(n))}catch{}}var de=e=>(K.has(e)||K.set(e,X(e)),K.get(e)??G);function fe(e,t,n,r){let i=new Set([...de(e),`${t}:${n}:${r}`].slice(-4096));for(K.delete(e),K.set(e,i);K.size>64;)K.delete(K.keys().next().value);ue(e,i);for(let e of q)e()}function pe(e){return(0,B.useSyncExternalStore)(e=>(q.add(e),()=>{q.delete(e)}),()=>de(e))}function me(e,t,n){let[r,i]=(0,B.useState)(),a=pe(e),o=JSON.stringify(t.map(e=>e.file.path).sort());(0,B.useEffect)(()=>{let t=JSON.parse(o);if(!t.length){i(void 0);return}let n=new AbortController,r=!1,a=!1,s=async()=>{if(!n.signal.aborted){if(r){a=!0;return}r=!0;try{let r=await W(e,n.signal),a=new Map;for(let i of t){if(n.signal.aborted)return;let t=r.files.find(e=>e.path===i&&e.pathDisplay===`exact-safe`);if(t)try{a.set(i,await ce(e,t.fileRef,n.signal))}catch{}}n.signal.aborted||i({session:e,diffs:a})}catch{n.signal.aborted||i(void 0)}finally{r=!1,a&&!n.signal.aborted&&(a=!1,s())}}};s();let c=window.setInterval(()=>void s(),3e3),l=t=>{t.detail?.sessionRef===e&&s()};return window.addEventListener(`piagent-workspace-saved`,l),window.addEventListener(`piagent-workspace-changed`,l),()=>{n.abort(),clearInterval(c),window.removeEventListener(`piagent-workspace-saved`,l),window.removeEventListener(`piagent-workspace-changed`,l)}},[e,o]);let s=r?.session===e?r.diffs:void 0,c=e=>le(s?.get(e.file.path),e.file.path,e.file.digest,!e.fresh&&!e.pending&&e.draft===(e.file.content??``),a),l=t.find(e=>e.file.path===n),u=l?c(l):[];return{diff:n?s?.get(n):void 0,hunks:u,counts:new Map(t.map(e=>[e.file.path,c(e).length])),keep:t=>{l?.file.digest&&u.some(e=>e.hunkRef===t)&&fe(e,l.file.path,l.file.digest,t)}}}var Z=new Map,he=new Set,ge={tabs:[]},Q=e=>e.fresh||e.draft!==(e.file.content??``);window.addEventListener(`beforeunload`,e=>{[...Z.values()].some(e=>e.tabs.some(Q))&&(e.preventDefault(),e.returnValue=``)});var _e=e=>Z.get(e)??ge;function ve(e){let t=(0,B.useSyncExternalStore)(e=>(he.add(e),()=>{he.delete(e)}),()=>Z.get(e)??ge),n=t=>{Z.set(e,t(Z.get(e)??ge));for(let e of he)e()};return{...t,update:n}}function ye(e,t,n){return e.file!==t||e.file.path!==n.path||e.pending||e.fresh||e.file.digest===n.digest&&e.file.protected===n.protected&&e.file.readOnly===n.readOnly?{tab:e}:e.draft===(e.file.content??``)?{tab:{...e,file:n,draft:n.content??``}}:{tab:e,conflict:n}}function be(e,t,n){let{update:r}=ve(e),i=(0,B.useRef)({update:r,conflict:n});i.current={update:r,conflict:n},(0,B.useEffect)(()=>{let n=new AbortController,r=new Map,a=!1,o=!1,s,c=async()=>{if(!(n.signal.aborted||t.current)){if(a){o=!0;return}a=!0;try{for(let a of _e(e).tabs)if(!(a.fresh||a.pending||t.current))try{let o=await z(e,a.file.path,n.signal);if(n.signal.aborted||t.current)return;let s;if(i.current.update(e=>({...e,tabs:e.tabs.map(t=>{if(t.file.path!==a.file.path)return t;let n=ye(t,a.file,o);return n.conflict&&e.active===t.file.path&&(s=n.conflict),n.tab})})),s){let e=`${s.digest}:${s.protected}:${s.readOnly}`;r.get(s.path)!==e&&(r.set(s.path,e),i.current.conflict(s))}}catch{}}finally{a=!1,o&&!n.signal.aborted&&(o=!1,l())}}},l=()=>{s||=setTimeout(()=>{s=void 0,c()},100)},u=t=>{t.detail?.sessionRef===e&&l()};window.addEventListener(`piagent-workspace-changed`,u),window.addEventListener(`piagent-workspace-saved`,u);let d=setInterval(l,5e3);return l(),()=>{n.abort(),clearTimeout(s),clearInterval(d),window.removeEventListener(`piagent-workspace-changed`,u),window.removeEventListener(`piagent-workspace-saved`,u)}},[e,t])}var xe=e=>`/api/v1/sessions/${encodeURIComponent(e)}/workspace/write`;function $(e){return Array.isArray(e)?`[${e.map($).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${$(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Se(e,t){let n=await fetch(xe(e),{credentials:`same-origin`,signal:t,headers:{Accept:`application/json`}});if(n.status===401&&E(),!n.ok)throw Error(`workspace-write-unavailable`);return await n.json()}async function Ce(e,t){let n=Date.now(),r=`workspace.write`,i=e.identity,a=e.revisions,o=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode($({action:r,identity:i,expectedRevisions:a,payload:t})));return{schemaVersion:1,version:`piagent-webui-workspace-write-v1`,messageType:`command`,action:r,identity:i,expectedRevisions:a,payload:t,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(n).toISOString(),expiresAt:new Date(n+6e4).toISOString(),actionDigest:`sha256:${[...new Uint8Array(o)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}}async function we(e,t){let n=T();if(!n)throw Error(`workspace-write-unavailable`);let r=await w(xe(e),{method:`POST`,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(t)});if(r.status===401&&E(),!r.ok)throw Error(`workspace-write-unavailable`);let i=await r.json(),a=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t.idempotencyKey)),o=`sha256:${[...new Uint8Array(a)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`;if(i.schemaVersion!==1||i.version!==t.version||i.messageType!==`receipt`||i.path!==t.payload.path||i.commandId!==t.commandId||i.action!==t.action||i.actionDigest!==t.actionDigest||i.idempotencyKeyDigest!==o||$(i.identity)!==$(t.identity)||![`settled`,`rejected`,`uncertain`].includes(i.phase)||i.phase===`settled`&&(i.resultCode!==`saved`||!/^[a-f0-9]{64}$/.test(i.digest??``)))throw Error(`workspace-write-receipt-invalid`);return i}function Te(e){let{locale:t}=x(),n=ve(e),[r,i]=(0,B.useState)(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(!1),[c,l]=(0,B.useState)(),[u,d]=(0,B.useState)();be(e,s,d),(0,B.useEffect)(()=>{let t=new AbortController,n=!1,r=()=>{n||(n=!0,Se(e,t.signal).then(i).catch(()=>{t.signal.aborted||i(void 0)}).finally(()=>{n=!1}))};r();let a=window.setInterval(r,5e3);return()=>{t.abort(),clearInterval(a)}},[e]);let f=(e,t=1,r=!1)=>n.update(n=>({active:e.path,tabs:[...n.tabs.filter(t=>t.file.path!==e.path),{file:e,line:t,fresh:r,draft:e.content??``}]})),p=(e,t)=>n.update(n=>({...n,active:e,tabs:n.tabs.map(n=>n.file.path===e&&t!==void 0?{...n,line:t}:n)})),m=(e,t)=>n.update(n=>({...n,tabs:n.tabs.map(n=>n.file.path===e?{...n,draft:t}:n)})),h=r=>{let i=_e(e).tabs.find(e=>e.file.path===r);i&&(Q(i)||i.pending)&&!window.confirm(S(t,`Bỏ thay đổi chưa lưu và đóng tệp?`,`Discard unsaved changes and close this file?`))||n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?e.tabs.find(e=>e.file.path!==r)?.file.path:e.active}))},g=async n=>{try{f(await z(e,n)),d(void 0),l(void 0)}catch{l(S(t,`Chưa tải lại được tệp. Bản sửa của bạn vẫn được giữ.`,`Could not reload the file. Your draft is preserved.`))}},_=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(!(!c||s.current||!Q(c)&&!c.pending||c.file.protected||c.file.readOnly)&&!(a&&!window.confirm(S(t,`Ghi đè phiên bản trên đĩa bằng bản sửa của bạn?`,`Replace the version on disk with your draft?`)))){s.current=!0,o(!0),l(void 0);try{let o=await Se(e);if(i(o),!o.writable)throw Error(`read-only`);let s=a?.digest??(c.fresh?`absent`:c.file.digest);if(!s)throw Error(`unavailable`);let u=c.pending??await Ce(o,{path:r,content:c.draft,expectedDigest:s});n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:u}:e)}));let f=await we(e,u);if(f.phase===`uncertain`){l(S(t,`Chưa xác định được kết quả lưu. Tải lại để kiểm tra trước khi lưu tiếp.`,`The save result is uncertain. Reload to check before saving again.`));return}n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:void 0}:e)})),f.phase===`settled`&&f.resultCode===`saved`?(n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,fresh:!1,file:{...e.file,content:u.payload.content,digest:f.digest,revision:f.observedRevisionsAfter.workspaceRevision}}:e)})),d(void 0),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}}))):f.resultCode===`stale-content`||f.resultCode===`stale-revision`?d(await z(e,r)):l(S(t,`Chưa lưu được tệp. Kiểm tra quyền ghi và thử lại.`,`Could not save the file. Check write access and try again.`))}catch{l(S(t,`Chưa lưu được tệp. Bản sửa vẫn được giữ; thử lưu lại hoặc tải lại để kiểm tra.`,`Could not confirm the save. Your draft is preserved; retry the save or reload to check.`))}finally{s.current=!1,o(!1)}}},v=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(s.current||c&&(Q(c)||c.pending))return l(S(t,`Lưu hoặc bỏ thay đổi trước khi đổi tên hay xóa tệp.`,`Save or discard your changes before renaming or deleting the file.`)),!1;s.current=!0,o(!0),l(void 0);try{let o=await Se(e);i(o);let s=c?.file.digest??(await z(e,r)).digest;if(!o.writable||!s)throw Error(`unavailable`);let u=await we(e,await Ce(o,a?{path:r,content:``,expectedDigest:s,operation:`rename`,destination:a}:{path:r,content:``,expectedDigest:s,operation:`delete`}));return u.phase===`settled`&&u.resultCode===`saved`?(n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?void 0:e.active})),a&&f(await z(e,a)),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}})),!0):(l(u.phase===`uncertain`?S(t,`Chưa xác định được kết quả. Tải lại danh sách tệp để kiểm tra.`,`The result is uncertain. Reload the file list to check.`):u.resultCode===`stale-content`?S(t,`Tệp đã thay đổi trên đĩa hoặc tên mới đã có. Tải lại rồi thử lại.`,`The file changed on disk or the new name exists. Reload and try again.`):S(t,`Không thực hiện được. Kiểm tra quyền ghi và tên tệp.`,`This could not be done. Check write access and the file name.`)),!1)}catch{return l(S(t,`Chưa xác nhận được thao tác. Tải lại danh sách tệp để kiểm tra.`,`Could not confirm the action. Reload the file list to check.`)),!1}finally{s.current=!1,o(!1)}};return{...n,authority:r,saving:a,message:c,conflict:u,setConflict:d,load:f,select:p,change:m,close:h,reload:g,save:_,move:v}}var Ee=e(i(),1);function De({sessionRef:e,onOpen:t}){let{locale:n}=x(),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(),[s,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t=new AbortController;if(o(void 0),d(!1),l(!1),!r.trim())return()=>t.abort();l(!0);let n=setTimeout(()=>{ae(e,r,t.signal).then(e=>{t.signal.aborted||o(e)}).catch(()=>{t.signal.aborted||d(!0)}).finally(()=>{t.signal.aborted||l(!1)})},250);return()=>{clearTimeout(n),t.abort()}},[r,e]),(0,V.jsxs)(p,{spacing:1,sx:{p:1},children:[(0,V.jsx)(v,{size:`small`,label:S(n,`Tìm nội dung`,`Search contents`),value:r,onChange:e=>i(e.target.value),slotProps:{htmlInput:{maxLength:512}}}),s&&(0,V.jsx)(h,{size:18}),(u||a?.available===!1)&&(0,V.jsx)(g,{severity:`warning`,children:S(n,`Chưa tìm được nội dung trong project này.`,`Content search is unavailable for this project.`)}),a?.available&&a.backend===`fts`&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Tìm trong các tệp đã lập chỉ mục.`,`Searching indexed files.`)}),a?.matches.map(e=>(0,V.jsxs)(b,{onClick:()=>t(e.path,e.line),sx:{textTransform:`none`,display:`block`,textAlign:`left`,overflowWrap:`anywhere`},children:[(0,V.jsxs)(c,{variant:`caption`,component:`span`,children:[e.path,`:`,e.line,`:`,e.column]}),(0,V.jsx)(c,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.preview})]},`${e.path}:${e.line}:${e.column}`)),a?.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Đã giới hạn kết quả. Hãy tìm cụ thể hơn.`,`Results were limited. Refine your search.`)}),a?.available&&!a.matches.length&&!a.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Không tìm thấy.`,`No matches.`)})]})}var Oe=y((0,V.jsx)(`path`,{d:`M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z`}),`ChevronRight`),ke=y((0,V.jsx)(`path`,{d:`M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z`}),`ExpandMore`),Ae=y((0,V.jsx)(`path`,{d:`M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zM6 20V4h7v5h5v11z`}),`InsertDriveFileOutlined`),je=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`));function Me({sessionRef:e,refresh:n,active:r,onOpen:i,onFolder:a}){let{locale:o}=x(),[s,u]=(0,B.useState)(()=>new Set([``])),[f,p]=(0,B.useState)(()=>new Map),[m,g]=(0,B.useState)(),_=(t,n)=>{p(e=>new Map(e).set(t,e.get(t)??`loading`)),R(e,t,n).then(e=>{n?.aborted||p(n=>new Map(n).set(t,e))}).catch(()=>{n?.aborted||p(e=>new Map(e).set(t,`error`))})};(0,B.useEffect)(()=>{p(new Map),u(new Set([``]))},[e]),(0,B.useEffect)(()=>{let e=new AbortController;for(let t of s)_(t,e.signal);return()=>e.abort()},[e,n]),(0,B.useEffect)(()=>{if(!r)return;let e=je(r).filter(e=>!s.has(e));if(e.length){u(t=>new Set([...t,...e]));for(let t of e)f.has(t)||_(t)}},[r]);let v=e=>{if(g(e),a(e),s.has(e)){u(t=>{let n=new Set(t);return n.delete(e),n});return}u(t=>new Set(t).add(e)),(!f.has(e)||f.get(e)===`error`)&&_(e)},y=(e,n)=>{let a=f.get(e);return!a||a===`loading`?(0,V.jsx)(h,{size:14,sx:{ml:1.5+n*1.5,my:.5}}):a===`error`?(0,V.jsx)(c,{variant:`caption`,color:`warning.main`,sx:{pl:1.5+n*1.5},children:S(o,`Chưa đọc được thư mục này.`,`This folder could not be read.`)}):(0,V.jsxs)(V.Fragment,{children:[a.entries.map(e=>{let a=e.kind===`directory`,c=a&&s.has(e.path),u=a?m===e.path:r===e.path,f=a?(0,V.jsxs)(V.Fragment,{children:[c?(0,V.jsx)(ke,{sx:{fontSize:16}}):(0,V.jsx)(Oe,{sx:{fontSize:16}}),c?(0,V.jsx)(l,{sx:{fontSize:16}}):(0,V.jsx)(d,{sx:{fontSize:16}})]}):(0,V.jsx)(Ae,{sx:{fontSize:16,ml:`16px`}});return(0,V.jsxs)(t,{children:[(0,V.jsxs)(b,{fullWidth:!0,size:`small`,disabled:e.protected||e.kind===`symlink`||e.kind===`other`,"aria-label":e.protected?`${e.name} (${S(o,`được bảo vệ`,`protected`)})`:e.name,"aria-expanded":a?c:void 0,"aria-current":!a&&r===e.path?`true`:void 0,onClick:()=>a?v(e.path):(g(void 0),i(e.path)),sx:{justifyContent:`flex-start`,textTransform:`none`,gap:.5,minHeight:24,py:0,pl:.5+n*1.5,pr:1,color:`text.primary`,fontWeight:400,whiteSpace:`nowrap`,bgcolor:u?`action.selected`:void 0},children:[f,(0,V.jsxs)(t,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`},children:[e.name,e.protected?` 🔒`:``]})]}),c&&y(e.path,n+1)]},e.path)}),a.truncated&&(0,V.jsx)(c,{variant:`caption`,sx:{pl:1.5+n*1.5},children:S(o,`Danh sách đã được giới hạn.`,`Listing limit reached.`)})]})};return(0,V.jsx)(t,{role:`group`,"aria-label":S(o,`Cây thư mục`,`Folder tree`),sx:{py:.5},children:y(``,0)})}var Ne=(0,B.lazy)(()=>C(()=>import(`./WorkspaceCodeEditor-B5KeO5jf.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function Pe({sessionRef:e,target:r,navigationHost:i,sidebarMode:s,onHide:l,fill:d}){let{locale:y}=x(),[C,w]=(0,B.useState)(`files`),[T,E]=(0,B.useState)(!1),[D,te]=(0,B.useState)(``),[k,A]=(0,B.useState)(!1),[j,M]=(0,B.useState)(),[N,P]=(0,B.useState)(``),F=Te(e),{tabs:I,active:L}=F,[ne,re]=(0,B.useState)(``),[ae,R]=(0,B.useState)(!1),[H,U]=(0,B.useState)(!1),W=(0,B.useRef)(null),[ce,le]=(0,B.useState)(0);(0,B.useEffect)(()=>{let t=t=>{t.detail?.sessionRef===e&&le(e=>e+1)};return window.addEventListener(`piagent-workspace-saved`,t),()=>window.removeEventListener(`piagent-workspace-saved`,t)},[e]),(0,B.useEffect)(()=>()=>W.current?.abort(),[]);let G=async(t,n=1)=>{if(W.current?.abort(),U(!1),I.find(e=>e.file.path===t)){F.select(t,n);return}W.current?.abort();let r=new AbortController;W.current=r,U(!0),R(!1);try{let i=await z(e,t,r.signal);if(r.signal.aborted)return;if(i.protected){R(!0);return}F.load(i,n)}catch{r.signal.aborted||R(!0)}finally{r.signal.aborted||U(!1)}};(0,B.useEffect)(()=>{r&&G(r.path,r.line??1)},[r]),(0,B.useEffect)(()=>{s&&s!==`sessions`&&w(s)},[s]);let K=I.find(e=>e.file.path===L),q=K?.file,J=me(e,I,L),Y=se(e,q?.path,q?.digest??null,!!K&&!Q(K),J.diff),X=oe(e,q?.path,K?.draft??``,J.hunks),ue=I.find(e=>e.file.path===F.conflict?.path),de=(0,V.jsxs)(t,{component:`nav`,"aria-label":S(y,`Tệp dự án`,`Project files`),sx:{width:i?`100%`:{xs:136,sm:200},flexShrink:0,overflow:`auto`,borderRight:1,borderColor:`divider`},children:[!i&&(0,V.jsxs)(u,{value:C,onChange:(e,t)=>w(t),"aria-label":S(y,`Khám phá project`,`Explore project`),children:[(0,V.jsx)(f,{value:`files`,label:S(y,`Tệp`,`Files`)}),(0,V.jsx)(f,{value:`search`,label:S(y,`Tìm kiếm`,`Search`)})]}),C===`search`?(0,V.jsx)(De,{sessionRef:e,onOpen:(e,t)=>void G(e,t)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(b,{disabled:!F.authority?.writable,onClick:()=>{te(ne?`${ne}/`:``),E(!0)},children:S(y,`Tệp mới`,`New file`)}),(0,V.jsx)(Me,{sessionRef:e,refresh:ce,active:L,onOpen:e=>{re(e.split(`/`).slice(0,-1).join(`/`)),G(e)},onFolder:re})]})]});return(0,V.jsxs)(V.Fragment,{children:[Y.dialog,X.dialog,(0,V.jsxs)(p,{direction:`row`,sx:{height:d?`100%`:`calc(100vh - 150px)`,minHeight:d?160:320},children:[i?(0,Ee.createPortal)(de,i):de,(0,V.jsxs)(t,{sx:{minWidth:0,flex:1,display:`flex`,flexDirection:`column`},children:[ae&&(0,V.jsx)(g,{severity:`warning`,children:S(y,`Chưa đọc được tệp hoặc thư mục này.`,`This file or folder could not be read.`)}),X.bar,F.message&&(0,V.jsx)(g,{severity:`warning`,children:F.message}),F.authority?.agentRunning&&(0,V.jsx)(g,{severity:`info`,children:S(y,`Agent đang chạy và có thể sửa tệp này.`,`The agent is running and may change this file.`)}),(0,V.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,borderBottom:1,borderColor:`divider`,minHeight:36},children:[(0,V.jsx)(u,{value:L??!1,onChange:(e,t)=>F.select(t),variant:`scrollable`,scrollButtons:`auto`,"aria-label":S(y,`Các tệp đang mở`,`Open files`),sx:{flex:1,minWidth:0,minHeight:36},children:I.map(e=>(0,V.jsx)(f,{value:e.file.path,sx:{minHeight:36,py:0},"aria-label":`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,label:ie(`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,S(y,`Đóng ${e.file.path}`,`Close ${e.file.path}`),()=>F.close(e.file.path))},e.file.path))}),l&&(0,V.jsx)(o,{size:`small`,"aria-label":S(y,`Ẩn khung tệp`,`Hide files panel`),title:S(y,`Ẩn khung tệp (tệp đang mở vẫn giữ)`,`Hide files panel (open files are kept)`),onClick:l,children:(0,V.jsx)(ee,{fontSize:`small`})})]}),H&&(0,V.jsx)(h,{size:20}),q&&(0,V.jsxs)(p,{direction:`row`,sx:{flexShrink:0,overflowX:`auto`,"& .MuiButton-root":{whiteSpace:`nowrap`,flexShrink:0}},children:[Y.hasPending&&(0,V.jsx)(b,{onClick:Y.checkPending,children:S(y,`Kiểm tra hoàn tác`,`Check revert`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!K||!Q(K)&&!K.pending||F.saving,onClick:()=>void F.save(q.path),children:S(y,`Lưu`,`Save`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>F.close(q.path),children:S(y,`Đóng tệp`,`Close file`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{P(q.path),M(q.path)},children:S(y,`Đổi tên`,`Rename`)}),(0,V.jsx)(b,{size:`small`,color:`error`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{window.confirm(S(y,`Xóa ${q.path}? Có thể khôi phục bằng Git nếu tệp đã commit.`,`Delete ${q.path}? Git can restore it if it was committed.`))&&F.move(q.path)},children:S(y,`Xóa`,`Delete`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>{(!K||!Q(K)||window.confirm(S(y,`Bỏ thay đổi chưa lưu và tải lại?`,`Discard unsaved changes and reload?`)))&&F.reload(q.path)},children:S(y,`Tải lại`,`Reload`)})]}),q?.binary||q?.oversized?(0,V.jsx)(g,{severity:`info`,children:S(y,`Tệp nhị phân hoặc quá lớn để hiển thị.`,`This file is binary or too large to display.`)}):q?.content!==null&&q?.content!==void 0?(0,V.jsx)(t,{sx:{flex:1,minHeight:0},children:(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{onComment:X.open,hunks:J.hunks,onKeep:J.keep,onRevert:F.authority?.writable?e=>void Y.request(e):void 0,content:K?.draft??q.content,path:q.path,line:K?.line??1,readOnly:!F.authority?.writable||q.readOnly,onChange:e=>F.change(q.path,e),onSave:()=>void F.save(q.path)})})}):(0,V.jsx)(c,{sx:{p:2},children:S(y,`Chọn một tệp để mở.`,`Select a file to open.`)})]})]}),(0,V.jsxs)(n,{open:T,onClose:()=>E(!1),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Tạo tệp mới`,`Create a new file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn trong project`,`Path in project`),value:D,onChange:e=>te(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>E(!1),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(D)||!F.authority?.writable,onClick:()=>{let e=O(D);!e||!F.authority||(I.some(t=>t.file.path===e.path)?F.select(e.path):F.load({schemaVersion:1,version:`piagent-webui-workspace-file-v1`,generatedAt:new Date().toISOString(),identity:F.authority.identity,path:e.path,language:`text`,protected:!1,readOnly:!1,binary:!1,oversized:!1,content:``,digest:null,revision:null},1,!0),E(!1))},children:S(y,`Tạo`,`Create`)})]})]}),(0,V.jsxs)(n,{open:!!j,onClose:()=>M(void 0),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Đổi tên tệp`,`Rename file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn mới trong project`,`New path in project`),value:N,onChange:e=>P(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>M(void 0),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(N)||O(N)?.path===j||F.saving,onClick:()=>{let e=O(N);!e||!j||F.move(j,e.path).then(e=>{e&&M(void 0)})},children:S(y,`Đổi tên`,`Rename`)})]})]}),(0,V.jsxs)(n,{open:!!F.conflict,onClose:()=>{F.setConflict(void 0),A(!1)},fullWidth:!0,maxWidth:k?`lg`:`sm`,children:[(0,V.jsx)(m,{children:S(y,`Tệp đã thay đổi trên đĩa`,`The file changed on disk`)}),(0,V.jsxs)(_,{children:[(0,V.jsx)(c,{children:F.conflict?.path}),(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn vẫn được giữ. Chọn cách xử lý xung đột.`,`Your draft is preserved. Choose how to resolve the conflict.`)}),k&&F.conflict&&ue&&(0,V.jsxs)(p,{direction:`row`,spacing:1,children:[(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Trên đĩa`,`On disk`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:F.conflict.path,content:F.conflict.content??``})})]}),(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn`,`Your draft`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:ue.file.path,content:ue.draft})})]})]})]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>{F.setConflict(void 0),A(!1)},children:S(y,`Để sau`,`Later`)}),(0,V.jsx)(b,{onClick:()=>{F.conflict&&(F.load(F.conflict),F.setConflict(void 0),A(!1))},children:S(y,`Tải lại`,`Reload`)}),(0,V.jsx)(b,{onClick:()=>A(!0),children:S(y,`Xem khác biệt`,`Compare`)}),(0,V.jsx)(b,{disabled:F.saving||!F.conflict?.digest||F.conflict.protected||F.conflict.readOnly,onClick:()=>{F.conflict&&F.save(F.conflict.path,F.conflict)},children:S(y,`Ghi đè`,`Overwrite`)})]})]})]})}export{Pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t,o as n}from"./bootstrap-CedkNtRG.js";var r=class extends Error{status;code;constructor(e,t=null){super(`webui-request-${e}`),this.status=e,this.code=t}};async function i(e){try{let t=await e.json();return typeof t.error?.code==`string`?t.error.code:null}catch{return null}}async function a(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new r(t.status);return await t.json()}function o(e){return h(`/api/v1/session-catalog`,e)}function s(e){return h(`/api/v1/session-live-state`,e)}function c(e){return h(`/api/v1/session-creation-options`,e)}function l(e){return h(`/api/v1/provider-auth`,e)}function u(e,t){return h(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function d(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/provider-auth`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}function ee(e,t){return d({action:`provider-auth.start`,providerRef:e},t)}function te(e,t,n,r){return d({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function ne(e,t){return d({action:`provider-auth.cancel`,jobRef:e},t)}async function f(n){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/projects/import`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify({action:`project.import`})});if(!o.ok)throw new r(o.status,await i(o));return await o.json()}async function p(e){try{return await h(`/api/v1/managed`,e)}catch(e){if(e instanceof r&&e.status===404)return null;throw e}}async function m(n){let i=t();if(!i)throw new r(403);let a=await e(`/api/v1/managed/connect`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":i},body:JSON.stringify({action:`managed.connect`})});if(!a.ok)throw new r(a.status);return await a.json()}async function h(e,t){let i=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(i.status===401&&n(),!i.ok)throw new r(i.status);return await i.json()}function g(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function _(e,t){return h(g(e,`/api/v1/snapshot`),t)}function v(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),h(g(e,`/api/v1/transcript?${i}`),r)}function y(e,t,n){return h(g(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function b(e,t,n){return h(g(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function x(e,t,n,r){return h(g(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function S(e,t,n,r){return h(g(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function C(e,t,n,r){return h(g(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function w(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return h(`/api/v1/sessions/${encodeURIComponent(e)}/source-reverts/${encodeURIComponent(t)}${i}`,r)}function T(e,t){return h(g(e,`/api/v1/commit-summary`),t)}function E(e,t,n){return h(g(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function D(e,t){return h(g(e,`/api/v1/connections`),t)}async function O(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/session-connections`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}function k(e,t){return h(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function A(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/runtime-commands`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function j(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/mcp-auth/jobs/${encodeURIComponent(n)}/cancel`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"X-Piagent-CSRF":a}});if(!o.ok)throw new r(o.status);return await o.json()}function M(e,t){return h(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function N(e,t,n){return h(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function P(e,t,n){return h(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function F(e,t,n){return h(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function I(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return h(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function L(e){return h(`/api/v1/commit-summary`,e)}function R(e){return h(`/api/v1/tasks`,e)}function z(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function re(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function B(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function V(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function H(e){return h(`/api/v1/monitoring/release`,e)}function U(e,t){return h(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function W(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),h(`/api/v1/transcript?${r}`,n)}function G(e){return h(`/api/v1/chat/queue`,e)}function K(e){return h(`/api/v1/session-options/models`,e)}function q(e,t){return h(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function J(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/approvals/${encodeURIComponent(n.approvalRef)}/decision`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function Y(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/chat/messages`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function X(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/session-options`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ie(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/lifecycle`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ae(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/control/resume-and-continue`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function oe(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/reviews`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function se(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ce(n,i,a){let o=t();if(!o)throw new r(403);let s=await e(a?`/api/v1/sessions/${encodeURIComponent(a)}/source-reverts`:`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":o},body:JSON.stringify(n)});if(!s.ok)throw new r(s.status);return await s.json()}async function le(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/source-handoffs`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ue(n,i,a){let o=t();if(!o)throw new r(403);let s=await e(`/api/v1/sessions/${encodeURIComponent(n)}/attachments`,{method:`POST`,credentials:`same-origin`,signal:a,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":o},body:JSON.stringify(i)});if(!s.ok)throw new r(s.status);return await s.json()}function Z(e,t,n){return h(e?g(e,t):t,n)}var de=(e,t)=>Z(e,`/api/v1/documents`,t),fe=(e,t,n)=>Z(e,`/api/v1/documents/${encodeURIComponent(t)}`,n);async function pe(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/attachments`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}function me(e,t,n){return h(`/api/v1/projects/${encodeURIComponent(e)}/paths?query=${encodeURIComponent(t)}`,n)}function Q(e,t){return h(`/api/v1/projects/${encodeURIComponent(e)}/commands`,t)}function he(e,t){return h(`/api/v1/sessions/${encodeURIComponent(e)}/questions`,t)}async function ge(n,i,a,o){let s=t();if(!s)throw new r(403);let c=await e(`/api/v1/sessions/${encodeURIComponent(n)}/questions/${encodeURIComponent(i)}/answer`,{method:`POST`,credentials:`same-origin`,signal:o,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":s},body:JSON.stringify(a)});if(!c.ok)throw new r(c.status)}var $=class extends Error{status;code;detail;constructor(e,t,n){super(t),this.status=e,this.code=t,this.detail=n}};function _e(e,t=null,n){return h(`/api/v1/projects/${encodeURIComponent(e)}/branches${t===null?``:`?repository=${encodeURIComponent(t)}`}`,n)}async function ve(r,i,a){let o=t();if(!o)throw new $(403,`mutation-authority-rejected`,null);let s=await e(`/api/v1/projects/${encodeURIComponent(r)}/branches/switch`,{method:`POST`,credentials:`same-origin`,signal:a,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":o},body:JSON.stringify(i)});if(s.status===401&&n(),!s.ok){let e=`branch-request-${s.status}`,t=null;try{let n=await s.json();typeof n.error?.code==`string`&&(e=n.error.code),typeof n.error?.detail==`string`&&(t=n.error.detail)}catch{}throw new $(s.status,e,t)}return await s.json()}export{W as $,P as A,he as B,me as C,u as D,l as E,c as F,v as G,b as H,x as I,F as J,a as K,_ as L,o as M,T as N,re as O,D as P,z as Q,s as R,K as S,Q as T,C as U,S as V,w as W,V as X,I as Y,R as Z,B as _,ne as a,X as at,U as b,A as c,ce as ct,q as d,ee as dt,te as et,L as f,ve as ft,N as g,de as h,j as i,oe as it,y as j,H as k,O as l,pe as lt,fe as m,r as n,ie as nt,m as o,se as ot,p,M as q,ge as r,ae as rt,J as s,le as st,$ as t,Y as tt,f as u,ue as ut,G as v,_e as w,k as x,Z as y,E as z};
|
|
1
|
+
import{i as e,n as t,o as n}from"./bootstrap-CedkNtRG.js";var r=class extends Error{status;code;constructor(e,t=null){super(`webui-request-${e}`),this.status=e,this.code=t}};async function i(e){try{let t=await e.json();return typeof t.error?.code==`string`?t.error.code:null}catch{return null}}async function a(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new r(t.status);return await t.json()}function o(e){return h(`/api/v1/session-catalog`,e)}function s(e){return h(`/api/v1/session-live-state`,e)}function c(e){return h(`/api/v1/session-creation-options`,e)}function l(e){return h(`/api/v1/provider-auth`,e)}function u(e,t){return h(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function d(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/provider-auth`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}function ee(e,t){return d({action:`provider-auth.start`,providerRef:e},t)}function te(e,t,n,r){return d({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function ne(e,t){return d({action:`provider-auth.cancel`,jobRef:e},t)}async function f(n){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/projects/import`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify({action:`project.import`})});if(!o.ok)throw new r(o.status,await i(o));return await o.json()}async function p(e){try{return await h(`/api/v1/managed`,e)}catch(e){if(e instanceof r&&e.status===404)return null;throw e}}async function m(n){let i=t();if(!i)throw new r(403);let a=await e(`/api/v1/managed/connect`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":i},body:JSON.stringify({action:`managed.connect`})});if(!a.ok)throw new r(a.status);return await a.json()}async function h(e,t){let i=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(i.status===401&&n(),!i.ok)throw new r(i.status);return await i.json()}function g(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function _(e,t){return h(g(e,`/api/v1/snapshot`),t)}function v(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),h(g(e,`/api/v1/transcript?${i}`),r)}function y(e,t,n){return h(g(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function b(e,t,n){return h(g(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function x(e,t,n,r){return h(g(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function S(e,t,n,r){return h(g(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function C(e,t,n,r){return h(g(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function w(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return h(`/api/v1/sessions/${encodeURIComponent(e)}/source-reverts/${encodeURIComponent(t)}${i}`,r)}function T(e,t){return h(g(e,`/api/v1/commit-summary`),t)}function E(e,t,n){return h(g(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function D(e,t){return h(g(e,`/api/v1/connections`),t)}async function O(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/session-connections`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}function k(e,t){return h(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function A(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/runtime-commands`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function j(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/mcp-auth/jobs/${encodeURIComponent(n)}/cancel`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"X-Piagent-CSRF":a}});if(!o.ok)throw new r(o.status);return await o.json()}function M(e,t){return h(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function N(e,t,n){return h(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function P(e,t,n){return h(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function F(e,t,n){return h(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function I(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return h(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function L(e){return h(`/api/v1/commit-summary`,e)}function R(e){return h(`/api/v1/tasks`,e)}function z(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function re(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function B(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function V(e,t){return h(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function H(e){return h(`/api/v1/monitoring/release`,e)}function U(e,t){return h(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function W(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),h(`/api/v1/transcript?${r}`,n)}function G(e){return h(`/api/v1/chat/queue`,e)}function K(e){return h(`/api/v1/session-options/models`,e)}function q(e,t){return h(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function J(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/approvals/${encodeURIComponent(n.approvalRef)}/decision`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function Y(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/chat/messages`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function X(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/session-options`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ie(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/lifecycle`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ae(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/control/resume-and-continue`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function oe(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/reviews`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function se(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ce(n,i,a){let o=t();if(!o)throw new r(403);let s=await e(a?`/api/v1/sessions/${encodeURIComponent(a)}/source-reverts`:`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":o},body:JSON.stringify(n)});if(!s.ok)throw new r(s.status);return await s.json()}async function le(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/source-handoffs`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}async function ue(n,i,a){let o=t();if(!o)throw new r(403);let s=await e(`/api/v1/sessions/${encodeURIComponent(n)}/attachments`,{method:`POST`,credentials:`same-origin`,signal:a,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":o},body:JSON.stringify(i)});if(!s.ok)throw new r(s.status);return await s.json()}function Z(e,t,n){return h(e?g(e,t):t,n)}var de=(e,t)=>Z(e,`/api/v1/documents`,t),fe=(e,t,n)=>Z(e,`/api/v1/documents/${encodeURIComponent(t)}`,n);async function pe(n,i){let a=t();if(!a)throw new r(403);let o=await e(`/api/v1/attachments`,{method:`POST`,credentials:`same-origin`,signal:i,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":a},body:JSON.stringify(n)});if(!o.ok)throw new r(o.status);return await o.json()}function me(e,t,n){return h(`/api/v1/projects/${encodeURIComponent(e)}/paths?query=${encodeURIComponent(t)}`,n)}function Q(e,t){return h(`/api/v1/projects/${encodeURIComponent(e)}/commands`,t)}function he(e,t){return h(`/api/v1/sessions/${encodeURIComponent(e)}/questions`,t)}async function ge(n,i,a,o){let s=t();if(!s)throw new r(403);let c=await e(`/api/v1/sessions/${encodeURIComponent(n)}/questions/${encodeURIComponent(i)}/answer`,{method:`POST`,credentials:`same-origin`,signal:o,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":s},body:JSON.stringify(a)});if(!c.ok)throw new r(c.status)}var $=class extends Error{status;code;detail;constructor(e,t,n){super(t),this.status=e,this.code=t,this.detail=n}};function _e(e,t=null,n){return h(`/api/v1/projects/${encodeURIComponent(e)}/branches${t===null?``:`?repository=${encodeURIComponent(t)}`}`,n)}async function ve(r,i,a){let o=t();if(!o)throw new $(403,`mutation-authority-rejected`,null);let s=await e(`/api/v1/projects/${encodeURIComponent(r)}/branches/switch`,{method:`POST`,credentials:`same-origin`,signal:a,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":o},body:JSON.stringify(i)});if(s.status===401&&n(),!s.ok){let e=`branch-request-${s.status}`,t=null;try{let n=await s.json();typeof n.error?.code==`string`&&(e=n.error.code),typeof n.error?.detail==`string`&&(t=n.error.detail)}catch{}throw new $(s.status,e,t)}return await s.json()}export{z as $,H as A,E as B,K as C,l as D,Q as E,D as F,w as G,S as H,c as I,M as J,v as K,x as L,y as M,o as N,u as O,T as P,R as Q,_ as R,k as S,_e as T,b as U,he as V,C as W,I as X,F as Y,V as Z,B as _,ne as a,oe as at,h as b,A as c,le as ct,q as d,pe as dt,W as et,L as f,ue as ft,N as g,de as h,j as i,ae as it,P as j,re as k,O as l,ce as lt,fe as m,ve as mt,r as n,Y as nt,m as o,X as ot,p,ee as pt,a as q,ge as r,ie as rt,J as s,se as st,$ as t,te as tt,f as u,g as ut,G as v,me as w,U as x,Z as y,s as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InspectionApp-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InspectionApp-B5eKxLEs.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-CA5pzJiI.js","assets/bootstrap-CedkNtRG.js","assets/api-BQS4Dtrr.js","assets/latest-request-DXcYQW86.js","assets/App-C633xHZS.js","assets/ui-preferences-Dy4qeODT.js","assets/ActivityPanel-CBbfhN-m.js","assets/view-model-CWNiS4JN.js","assets/workspace-navigation-C8GtShbg.js","assets/transcript-view-model-BCyNr6KF.js","assets/LineReview-DZ9ez8kO.js","assets/GatewayApp-cQ6cd7fw.js","assets/SettingsNavigation-DzboWgoR.js","assets/composer-drafts-BtMaVw8W.js","assets/terminal-transport-Dk5pYNX5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{Bt as n,Dn as r,En as i,Fn as a,In as o,Mn as s,Nn as c,On as l,Pn as u,Tn as d,Vt as f,_n as p,bn as m,dn as h,gn as g,hn as _,on as v,pn as y,sn as b,un as x,wn as S,yn as C,zt as ee}from"./vendor-CA5pzJiI.js";import{a as te,n as ne,o as re,s as ie,t as ae}from"./ui-preferences-Dy4qeODT.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var oe=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ie());else{var t=n(l);t!==null&&se(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<ee)}function re(){if(g=!1,S){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&se(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?ie():S=!1}}}var ie;if(typeof y==`function`)ie=function(){y(re)};else if(typeof MessageChannel<`u`){var ae=new MessageChannel,oe=ae.port2;ae.port1.onmessage=re,ie=function(){oe.postMessage(null)}}else ie=function(){_(re,0)};function se(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ee=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,se(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ie()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),se=t(((e,t)=>{t.exports=oe()})),ce=t((e=>{var t=se(),n=o(),r=a();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var s=!1,l=a.child;l;){if(l===n){s=!0,n=a,r=o;break}if(l===r){s=!0,r=a,n=o;break}l=l.sibling}if(!s){for(l=o.child;l;){if(l===n){s=!0,n=o,r=a;break}if(l===r){s=!0,r=o,n=a;break}l=l.sibling}if(!s)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.iterator;function ce(e){return typeof e!=`object`||!e?null:(e=oe&&e[oe]||e[`@@iterator`],typeof e==`function`?e:null)}var le=Symbol.for(`react.client.reference`);function w(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===le?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case ee:return`Suspense`;case te:return`SuspenseList`;case ie:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?w(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return w(e(t))}catch{}}return null}var ue=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function O(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function k(e,t){fe++,de[fe]=e.current,e.current=t}var me=pe(null),he=pe(null),ge=pe(null),_e=pe(null);function ve(e,t){switch(k(ge,t),k(he,e),k(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}O(me),k(me,e)}function ye(){O(me),O(he),O(ge)}function be(e){e.memoizedState!==null&&k(_e,e);var t=me.current,n=Hd(t,e.type);t!==n&&(k(he,e),k(me,n))}function xe(e){he.current===e&&(O(me),O(he)),_e.current===e&&(O(_e),Qf._currentValue=D)}var Se,Ce;function we(e){if(Se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Se=t&&t[1]||``,Ce=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Se+e+Ce}var Te=!1;function Ee(e,t){if(!e||Te)return``;Te=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -34,4 +34,4 @@ try {
|
|
|
34
34
|
if (colorScheme) {
|
|
35
35
|
${l}
|
|
36
36
|
}
|
|
37
|
-
} catch(e){}})();`}},`mui-color-scheme-init`)}function ye(){}var be=({key:e,storageWindow:t})=>(!t&&typeof window<`u`&&(t=window),{get(n){if(typeof window>`u`)return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return ye;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function xe(){}function Se(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Ce(e,t){if(e.mode===`light`||e.mode===`system`&&e.systemMode===`light`)return t(`light`);if(e.mode===`dark`||e.mode===`system`&&e.systemMode===`dark`)return t(`dark`)}function we(e){return Ce(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Te(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=he,colorSchemeStorageKey:o=ge,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=be,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=w.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=w.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=w.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=w.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Se(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=w.useState(l||!d);w.useEffect(()=>{v(!0)},[]);let y=we(h),b=w.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Se(r)}})},[f,t]),x=w.useCallback(e=>{e?typeof e==`string`?e&&!u.includes(e)?console.error(`\`${e}\` does not exist in \`theme.colorSchemes\`.`):g(t=>{let n={...t};return Ce(t,t=>{t===`light`&&(p?.set(e),n.lightColorScheme=e),t===`dark`&&(m?.set(e),n.darkColorScheme=e)}),n}):g(t=>{let i={...t},a=e.light===null?n:e.light,o=e.dark===null?r:e.dark;return a&&(u.includes(a)?(i.lightColorScheme=a,p?.set(a)):console.error(`\`${a}\` does not exist in \`theme.colorSchemes\`.`)),o&&(u.includes(o)?(i.darkColorScheme=o,m?.set(o)):console.error(`\`${o}\` does not exist in \`theme.colorSchemes\`.`)),i}):g(e=>(p?.set(n),m?.set(r),{...e,lightColorScheme:n,darkColorScheme:r}))},[u,p,m,n,r]),S=w.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),C=w.useRef(S);return C.current=S,w.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>C.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),w.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||xe,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||xe,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||xe;return()=>{e(),n(),r()}}},[x,b,u,t,s,d,f,p,m]),{...h,mode:_?h.mode:void 0,systemMode:_?h.systemMode:void 0,colorScheme:_?y:void 0,setMode:b,setColorScheme:x}}var Ee=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function De(e){let{themeId:t,theme:n={},modeStorageKey:r=he,colorSchemeStorageKey:a=ge,disableTransitionOnChange:o=!1,defaultColorScheme:s,resolveTheme:c}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},u=w.createContext(void 0),d=()=>w.useContext(u)||l,f={},p={};function h(e){let{children:l,theme:d,modeStorageKey:h=r,colorSchemeStorageKey:g=a,disableTransitionOnChange:_=o,storageManager:v,storageWindow:y=typeof window>`u`?void 0:window,documentNode:b=typeof document>`u`?void 0:document,colorSchemeNode:x=typeof document>`u`?void 0:document.documentElement,disableNestedContext:S=!1,disableStyleSheetGeneration:C=!1,defaultMode:ee=`system`,forceThemeRerender:te=!1,noSsr:ne}=e,re=w.useRef(!1),ie=T(),ae=w.useContext(u),oe=!!ae&&!S,se=w.useMemo(()=>d||(typeof n==`function`?n():n),[d]),ce=se[t],le=ce||se,{colorSchemes:ue=f,components:E=p,cssVarPrefix:de}=le,fe=Object.keys(ue).filter(e=>!!ue[e]).join(`,`),pe=w.useMemo(()=>fe.split(`,`),[fe]),O=typeof s==`string`?s:s.light,k=typeof s==`string`?s:s.dark,{mode:he,setMode:ge,systemMode:_e,lightColorScheme:ve,darkColorScheme:ye,colorScheme:be,setColorScheme:xe}=Te({supportedColorSchemes:pe,defaultLightColorScheme:O,defaultDarkColorScheme:k,modeStorageKey:h,colorSchemeStorageKey:g,defaultMode:ue[O]&&ue[k]?ee:ue[le.defaultColorScheme]?.palette?.mode||le.palette?.mode,storageManager:v,storageWindow:y,noSsr:ne}),Se=he,Ce=be;oe&&(Se=ae.mode,Ce=ae.colorScheme);let we=Ce||le.defaultColorScheme;le.vars&&!te&&(we=le.defaultColorScheme);let De=w.useMemo(()=>{let e=le.generateThemeVars?.()||le.vars,t={...le,components:E,colorSchemes:ue,cssVarPrefix:de,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),we){let e=ue[we];e&&typeof e==`object`&&Object.keys(e).forEach(n=>{e[n]&&typeof e[n]==`object`?t[n]={...t[n],...e[n]}:t[n]=e[n]})}return c?c(t):t},[le,we,E,ue,de]),Oe=le.colorSchemeSelector;m(()=>{if(Ce&&x&&Oe&&Oe!==`media`){let e=Oe,t=Oe;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))x.classList.remove(...pe.map(e=>t.substring(1).replace(`%s`,e))),x.classList.add(t.substring(1).replace(`%s`,Ce));else{let e=t.replace(`%s`,Ce).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||pe.forEach(e=>{x.removeAttribute(t.replace(Ce,e))}),x.setAttribute(t,n?n.replace(/"|'/g,``):``)}else x.setAttribute(t,Ce)}}},[Ce,Oe,x,pe]),w.useEffect(()=>{let e;if(_&&re.current&&b){let t=b.createElement(`style`);t.appendChild(b.createTextNode(Ee)),b.head.appendChild(t),window.getComputedStyle(b.body),e=setTimeout(()=>{b.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[Ce,_,b]),w.useEffect(()=>(re.current=!0,()=>{re.current=!1}),[]);let ke=w.useMemo(()=>({allColorSchemes:pe,colorScheme:Ce,darkColorScheme:ye,lightColorScheme:ve,mode:Se,setColorScheme:xe,setMode:ge,systemMode:_e}),[pe,Ce,ye,ve,Se,xe,ge,_e,De.colorSchemeSelector]),Ae=!0;(C||le.cssVariables===!1||oe&&ie?.cssVarPrefix===de)&&(Ae=!1);let je=(0,D.jsxs)(w.Fragment,{children:[(0,D.jsx)(me,{themeId:ce?t:void 0,theme:De,children:l}),Ae&&(0,D.jsx)(i,{styles:De.generateStyleSheets?.()||[]})]});return oe?je:(0,D.jsx)(u.Provider,{value:ke,children:je})}let g=typeof s==`string`?s:s.light,_=typeof s==`string`?s:s.dark;return{CssVarsProvider:h,useColorScheme:d,getInitColorSchemeScript:e=>ve({colorSchemeStorageKey:a,defaultLightColorScheme:g,defaultDarkColorScheme:_,modeStorageKey:r,...e})}}var Oe=typeof b({})==`function`,ke=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),Ae=e=>({color:(e.vars||e).palette.text.primary,...e.typography.body1,backgroundColor:(e.vars||e).palette.background.default,"@media print":{backgroundColor:(e.vars||e).palette.common.white}}),je=(e,t=!1)=>{let n={};t&&e.colorSchemes&&typeof e.getColorSchemeSelector==`function`&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={":root":{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={colorScheme:r.palette?.mode}});let r={html:ke(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...Ae(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},Me=`mui-ecs`,Ne=e=>{let t=je(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${Me})`]={colorScheme:e.palette.mode}),e.colorSchemes&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={[`:root:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}}),t},Pe=b(Oe?({theme:e,enableColorScheme:t})=>je(e,t):({theme:e})=>Ne(e));function Fe(e){let{children:t,enableColorScheme:n=!1}=v({props:e,name:`MuiCssBaseline`});return(0,D.jsxs)(w.Fragment,{children:[Oe&&(0,D.jsx)(Pe,{enableColorScheme:n}),!Oe&&!n&&(0,D.jsx)(`span`,{className:Me,style:{display:`none`}}),t]})}function Ie({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,D.jsx)(me,{...t,themeId:n?x:void 0,theme:n||e})}var Le={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:Re,useColorScheme:ze,getInitColorSchemeScript:Be}=De({themeId:x,theme:()=>h({cssVariables:!0}),colorSchemeStorageKey:Le.colorSchemeStorageKey,modeStorageKey:Le.modeStorageKey,defaultColorScheme:{light:Le.defaultLightColorScheme,dark:Le.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:y(e.palette,e.typography)};return t.unstable_sx=function(e){return l({sx:e,theme:this})},t}}),Ve=Re;function He({theme:e,...t}){let n=w.useMemo(()=>{if(typeof e==`function`)return e;let t=`$$material`in e?e[x]:e;return`colorSchemes`in t?null:`vars`in t?e:{...e,vars:null}},[e]);return n?(0,D.jsx)(Ie,{theme:n,...t}):(0,D.jsx)(Ve,{theme:e,...t})}var Ue=le(),We=class extends w.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){let{locale:e,children:t}=this.props;return this.state.failed?(0,D.jsxs)(n,{sx:{p:3},children:[(0,D.jsx)(f,{severity:`error`,children:ne(e,`Không tải được giao diện. Vui lòng tải lại để thử lại.`,`Could not load this view. Reload to try again.`)}),(0,D.jsx)(ee,{onClick:()=>window.location.reload(),children:ne(e,`Tải lại trang`,`Reload page`)})]}):(0,D.jsx)(w.Suspense,{fallback:(0,D.jsx)(n,{role:`status`,sx:{p:3},children:ne(e,`Đang tải giao diện…`,`Loading view…`)}),children:t})}};function Ge(e){let t=e.mode===`dark`,n=e.mode,{primary:r,secondary:i,background:a,paper:o,text:s,muted:c,divider:l}=e,u=t?`0 16px 48px -12px ${C(`#000`,.7)}, 0 0 0 1px ${C(s,.06)}`:`0 16px 40px -16px ${C(`#1a1a2e`,.25)}, 0 0 0 1px ${C(s,.06)}`,d=`0 0 0 3px ${C(r,t?.28:.22)}`;return h({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:n,primary:{main:r,contrastText:e.onPrimary},secondary:{main:i},success:{main:i},warning:{main:e.warning},error:{main:e.error},background:{default:a,paper:o},text:{primary:s,secondary:c,disabled:c},divider:l,action:{hover:C(s,.05),selected:C(s,.08),focus:C(r,.14)}},shape:{borderRadius:6},transitions:{duration:{shortest:120,shorter:160,short:180,standard:200,complex:260,enteringScreen:200,leavingScreen:160}},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif`,fontSize:14,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.6rem`,fontWeight:650,letterSpacing:`-0.03em`,lineHeight:1.2},h2:{fontSize:`1.15rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`0.95rem`,fontWeight:600},body2:{fontSize:`0.8125rem`},button:{fontSize:`0.8125rem`,fontWeight:550,textTransform:`none`,letterSpacing:0},caption:{fontSize:`0.72rem`,letterSpacing:0},overline:{fontSize:`0.68rem`,fontWeight:600,letterSpacing:`0.08em`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:a,WebkitFontSmoothing:`antialiased`},body:{minWidth:320,minHeight:`100vh`,backgroundColor:a},"::selection":{backgroundColor:C(r,.28)},"*":{scrollbarWidth:`thin`,scrollbarColor:`${C(s,.18)} transparent`}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButtonBase:{defaultProps:{disableRipple:!0}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:32,borderRadius:8,paddingInline:12,transition:`background-color .16s, border-color .16s, box-shadow .16s, color .16s`,"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{minHeight:28,paddingInline:10,fontSize:`0.78rem`},outlined:{borderColor:C(s,.14),"&:hover":{borderColor:C(s,.28),backgroundColor:C(s,.04)}},contained:{"&.MuiButton-colorPrimary:hover":{backgroundColor:C(r,.88),boxShadow:`0 0 0 3px ${C(r,.18)}`}},text:{"&:hover":{backgroundColor:C(s,.06)}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:8,color:c,transition:`background-color .16s, color .16s`,"&:hover":{color:s,backgroundColor:C(s,.07)},"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{padding:5}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:999,fontWeight:500,fontSize:`0.75rem`},outlined:{borderColor:C(s,.14)},label:{paddingInline:9}}},MuiListItemButton:{styleOverrides:{root:{minHeight:36,margin:`1px 8px`,borderRadius:8,color:c,transition:`background-color .12s, color .12s`,"&:hover":{backgroundColor:C(s,.05),color:s},"&.Mui-selected":{color:s,backgroundColor:C(s,t?.08:.07)},"&.Mui-selected:hover":{backgroundColor:C(s,t?.11:.09)},"&.Mui-focusVisible":{boxShadow:d}}}},MuiTabs:{styleOverrides:{root:{minHeight:40},indicator:{height:2,borderRadius:2}}},MuiTab:{styleOverrides:{root:{minHeight:40,paddingInline:14,textTransform:`none`,fontWeight:550,fontSize:`0.8125rem`,color:c,"&.Mui-selected":{color:s}}}},MuiOutlinedInput:{styleOverrides:{root:{borderRadius:8,backgroundColor:C(s,t?.03:.02),transition:`box-shadow .16s`,"& .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.12)},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.24)},"&.Mui-focused":{boxShadow:d},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:r,borderWidth:1}}}},MuiTooltip:{defaultProps:{arrow:!1,enterDelay:350},styleOverrides:{tooltip:{fontSize:`0.75rem`,fontWeight:500,padding:`5px 9px`,borderRadius:6,color:t?s:`#fafafa`,backgroundColor:t?C(o,.98):`#1f1f24`,boxShadow:u}}},MuiMenu:{styleOverrides:{paper:{borderRadius:10,boxShadow:u,backgroundImage:`none`,marginTop:4},list:{padding:4}}},MuiPopover:{styleOverrides:{paper:{borderRadius:10,boxShadow:u}}},MuiMenuItem:{styleOverrides:{root:{minHeight:32,borderRadius:6,fontSize:`0.8125rem`,"&:hover":{backgroundColor:C(s,.06)},"&.Mui-selected":{backgroundColor:C(r,.12)}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:14,boxShadow:u,backgroundImage:`none`}}},MuiBackdrop:{styleOverrides:{root:{backgroundColor:C(`#000`,t?.6:.32),backdropFilter:`blur(2px)`}}},MuiDrawer:{styleOverrides:{paper:{backgroundImage:`none`,backgroundColor:o}}},MuiAlert:{styleOverrides:{root:{borderRadius:10,border:`1px solid ${C(s,.1)}`,fontSize:`0.8125rem`,alignItems:`center`}}},MuiDivider:{styleOverrides:{root:{borderColor:l}}},MuiLinearProgress:{styleOverrides:{root:{borderRadius:999,height:4},bar:{borderRadius:999}}}}})}function Ke(e){for(let t of e??[]){let e=String(t).toLowerCase().split(`-`)[0];if(e===`vi`)return`vi`;if(e)return`en`}return`en`}var qe=`modulepreload`,Je=function(e){return`/`+e},Ye={},Xe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Je(t,n),t=s(t),t in Ye)return;Ye[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:qe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ze=document.getElementById(`root`);if(!Ze)throw Error(`Piagent WebUI root is missing`);var Qe=document.querySelector(`meta[name="csp-nonce"]`)?.content,$e=u({key:`piagent-mui`,nonce:Qe&&!Qe.startsWith(`__PIAGENT_`)?Qe:void 0,prepend:!0}),et=(0,w.lazy)(()=>Xe(()=>import(`./InspectionApp-C00GhY47.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),tt=(0,w.lazy)(()=>Xe(()=>import(`./GatewayApp-uqpLU6gs.js`),__vite__mapDeps([13,1,2,7,3,4,9,14,10,11,15,5,16])));function nt(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function rt(){let[e,t]=(0,w.useState)(()=>nt(`piagent-webui-locale`,[`vi`,`en`],Ke(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,w.useState)(()=>nt(`piagent-webui-theme`,re.map(e=>e.id),``)||te[nt(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)]),i=ie(n)??ie(te.dark),a=i.mode,o=(0,w.useCallback)(e=>r(t=>ie(t)?.mode===e?t:te[e]),[]),s=(0,w.useMemo)(()=>Ge(i),[i]);(0,w.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=a,document.documentElement.dataset.piagentTheme=i.id;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,a),window.localStorage.setItem(`piagent-webui-theme`,i.id)}catch{}},[a,e,i]);let c=(0,w.useMemo)(()=>({locale:e,colorMode:a,themeId:i.id,setLocale:t,setColorMode:o,setThemeId:r}),[a,e,i,o]),l=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,D.jsx)(ae,{value:c,children:(0,D.jsxs)(He,{theme:s,children:[(0,D.jsx)(Fe,{}),(0,D.jsx)(We,{locale:e,children:l===`gateway`?(0,D.jsx)(tt,{}):(0,D.jsx)(et,{})})]})})}(0,Ue.createRoot)(Ze).render((0,D.jsx)(w.StrictMode,{children:(0,D.jsx)(s,{value:$e,children:(0,D.jsx)(rt,{})})}));export{We as n,Xe as t};
|
|
37
|
+
} catch(e){}})();`}},`mui-color-scheme-init`)}function ye(){}var be=({key:e,storageWindow:t})=>(!t&&typeof window<`u`&&(t=window),{get(n){if(typeof window>`u`)return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return ye;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function xe(){}function Se(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Ce(e,t){if(e.mode===`light`||e.mode===`system`&&e.systemMode===`light`)return t(`light`);if(e.mode===`dark`||e.mode===`system`&&e.systemMode===`dark`)return t(`dark`)}function we(e){return Ce(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Te(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=he,colorSchemeStorageKey:o=ge,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=be,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=w.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=w.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=w.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=w.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Se(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=w.useState(l||!d);w.useEffect(()=>{v(!0)},[]);let y=we(h),b=w.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Se(r)}})},[f,t]),x=w.useCallback(e=>{e?typeof e==`string`?e&&!u.includes(e)?console.error(`\`${e}\` does not exist in \`theme.colorSchemes\`.`):g(t=>{let n={...t};return Ce(t,t=>{t===`light`&&(p?.set(e),n.lightColorScheme=e),t===`dark`&&(m?.set(e),n.darkColorScheme=e)}),n}):g(t=>{let i={...t},a=e.light===null?n:e.light,o=e.dark===null?r:e.dark;return a&&(u.includes(a)?(i.lightColorScheme=a,p?.set(a)):console.error(`\`${a}\` does not exist in \`theme.colorSchemes\`.`)),o&&(u.includes(o)?(i.darkColorScheme=o,m?.set(o)):console.error(`\`${o}\` does not exist in \`theme.colorSchemes\`.`)),i}):g(e=>(p?.set(n),m?.set(r),{...e,lightColorScheme:n,darkColorScheme:r}))},[u,p,m,n,r]),S=w.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),C=w.useRef(S);return C.current=S,w.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>C.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),w.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||xe,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||xe,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||xe;return()=>{e(),n(),r()}}},[x,b,u,t,s,d,f,p,m]),{...h,mode:_?h.mode:void 0,systemMode:_?h.systemMode:void 0,colorScheme:_?y:void 0,setMode:b,setColorScheme:x}}var Ee=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function De(e){let{themeId:t,theme:n={},modeStorageKey:r=he,colorSchemeStorageKey:a=ge,disableTransitionOnChange:o=!1,defaultColorScheme:s,resolveTheme:c}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},u=w.createContext(void 0),d=()=>w.useContext(u)||l,f={},p={};function h(e){let{children:l,theme:d,modeStorageKey:h=r,colorSchemeStorageKey:g=a,disableTransitionOnChange:_=o,storageManager:v,storageWindow:y=typeof window>`u`?void 0:window,documentNode:b=typeof document>`u`?void 0:document,colorSchemeNode:x=typeof document>`u`?void 0:document.documentElement,disableNestedContext:S=!1,disableStyleSheetGeneration:C=!1,defaultMode:ee=`system`,forceThemeRerender:te=!1,noSsr:ne}=e,re=w.useRef(!1),ie=T(),ae=w.useContext(u),oe=!!ae&&!S,se=w.useMemo(()=>d||(typeof n==`function`?n():n),[d]),ce=se[t],le=ce||se,{colorSchemes:ue=f,components:E=p,cssVarPrefix:de}=le,fe=Object.keys(ue).filter(e=>!!ue[e]).join(`,`),pe=w.useMemo(()=>fe.split(`,`),[fe]),O=typeof s==`string`?s:s.light,k=typeof s==`string`?s:s.dark,{mode:he,setMode:ge,systemMode:_e,lightColorScheme:ve,darkColorScheme:ye,colorScheme:be,setColorScheme:xe}=Te({supportedColorSchemes:pe,defaultLightColorScheme:O,defaultDarkColorScheme:k,modeStorageKey:h,colorSchemeStorageKey:g,defaultMode:ue[O]&&ue[k]?ee:ue[le.defaultColorScheme]?.palette?.mode||le.palette?.mode,storageManager:v,storageWindow:y,noSsr:ne}),Se=he,Ce=be;oe&&(Se=ae.mode,Ce=ae.colorScheme);let we=Ce||le.defaultColorScheme;le.vars&&!te&&(we=le.defaultColorScheme);let De=w.useMemo(()=>{let e=le.generateThemeVars?.()||le.vars,t={...le,components:E,colorSchemes:ue,cssVarPrefix:de,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),we){let e=ue[we];e&&typeof e==`object`&&Object.keys(e).forEach(n=>{e[n]&&typeof e[n]==`object`?t[n]={...t[n],...e[n]}:t[n]=e[n]})}return c?c(t):t},[le,we,E,ue,de]),Oe=le.colorSchemeSelector;m(()=>{if(Ce&&x&&Oe&&Oe!==`media`){let e=Oe,t=Oe;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))x.classList.remove(...pe.map(e=>t.substring(1).replace(`%s`,e))),x.classList.add(t.substring(1).replace(`%s`,Ce));else{let e=t.replace(`%s`,Ce).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||pe.forEach(e=>{x.removeAttribute(t.replace(Ce,e))}),x.setAttribute(t,n?n.replace(/"|'/g,``):``)}else x.setAttribute(t,Ce)}}},[Ce,Oe,x,pe]),w.useEffect(()=>{let e;if(_&&re.current&&b){let t=b.createElement(`style`);t.appendChild(b.createTextNode(Ee)),b.head.appendChild(t),window.getComputedStyle(b.body),e=setTimeout(()=>{b.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[Ce,_,b]),w.useEffect(()=>(re.current=!0,()=>{re.current=!1}),[]);let ke=w.useMemo(()=>({allColorSchemes:pe,colorScheme:Ce,darkColorScheme:ye,lightColorScheme:ve,mode:Se,setColorScheme:xe,setMode:ge,systemMode:_e}),[pe,Ce,ye,ve,Se,xe,ge,_e,De.colorSchemeSelector]),Ae=!0;(C||le.cssVariables===!1||oe&&ie?.cssVarPrefix===de)&&(Ae=!1);let je=(0,D.jsxs)(w.Fragment,{children:[(0,D.jsx)(me,{themeId:ce?t:void 0,theme:De,children:l}),Ae&&(0,D.jsx)(i,{styles:De.generateStyleSheets?.()||[]})]});return oe?je:(0,D.jsx)(u.Provider,{value:ke,children:je})}let g=typeof s==`string`?s:s.light,_=typeof s==`string`?s:s.dark;return{CssVarsProvider:h,useColorScheme:d,getInitColorSchemeScript:e=>ve({colorSchemeStorageKey:a,defaultLightColorScheme:g,defaultDarkColorScheme:_,modeStorageKey:r,...e})}}var Oe=typeof b({})==`function`,ke=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),Ae=e=>({color:(e.vars||e).palette.text.primary,...e.typography.body1,backgroundColor:(e.vars||e).palette.background.default,"@media print":{backgroundColor:(e.vars||e).palette.common.white}}),je=(e,t=!1)=>{let n={};t&&e.colorSchemes&&typeof e.getColorSchemeSelector==`function`&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={":root":{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={colorScheme:r.palette?.mode}});let r={html:ke(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...Ae(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},Me=`mui-ecs`,Ne=e=>{let t=je(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${Me})`]={colorScheme:e.palette.mode}),e.colorSchemes&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={[`:root:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}}),t},Pe=b(Oe?({theme:e,enableColorScheme:t})=>je(e,t):({theme:e})=>Ne(e));function Fe(e){let{children:t,enableColorScheme:n=!1}=v({props:e,name:`MuiCssBaseline`});return(0,D.jsxs)(w.Fragment,{children:[Oe&&(0,D.jsx)(Pe,{enableColorScheme:n}),!Oe&&!n&&(0,D.jsx)(`span`,{className:Me,style:{display:`none`}}),t]})}function Ie({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,D.jsx)(me,{...t,themeId:n?x:void 0,theme:n||e})}var Le={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:Re,useColorScheme:ze,getInitColorSchemeScript:Be}=De({themeId:x,theme:()=>h({cssVariables:!0}),colorSchemeStorageKey:Le.colorSchemeStorageKey,modeStorageKey:Le.modeStorageKey,defaultColorScheme:{light:Le.defaultLightColorScheme,dark:Le.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:y(e.palette,e.typography)};return t.unstable_sx=function(e){return l({sx:e,theme:this})},t}}),Ve=Re;function He({theme:e,...t}){let n=w.useMemo(()=>{if(typeof e==`function`)return e;let t=`$$material`in e?e[x]:e;return`colorSchemes`in t?null:`vars`in t?e:{...e,vars:null}},[e]);return n?(0,D.jsx)(Ie,{theme:n,...t}):(0,D.jsx)(Ve,{theme:e,...t})}var Ue=le(),We=class extends w.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){let{locale:e,children:t}=this.props;return this.state.failed?(0,D.jsxs)(n,{sx:{p:3},children:[(0,D.jsx)(f,{severity:`error`,children:ne(e,`Không tải được giao diện. Vui lòng tải lại để thử lại.`,`Could not load this view. Reload to try again.`)}),(0,D.jsx)(ee,{onClick:()=>window.location.reload(),children:ne(e,`Tải lại trang`,`Reload page`)})]}):(0,D.jsx)(w.Suspense,{fallback:(0,D.jsx)(n,{role:`status`,sx:{p:3},children:ne(e,`Đang tải giao diện…`,`Loading view…`)}),children:t})}};function Ge(e){let t=e.mode===`dark`,n=e.mode,{primary:r,secondary:i,background:a,paper:o,text:s,muted:c,divider:l}=e,u=t?`0 16px 48px -12px ${C(`#000`,.7)}, 0 0 0 1px ${C(s,.06)}`:`0 16px 40px -16px ${C(`#1a1a2e`,.25)}, 0 0 0 1px ${C(s,.06)}`,d=`0 0 0 3px ${C(r,t?.28:.22)}`;return h({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:n,primary:{main:r,contrastText:e.onPrimary},secondary:{main:i},success:{main:i},warning:{main:e.warning},error:{main:e.error},background:{default:a,paper:o},text:{primary:s,secondary:c,disabled:c},divider:l,action:{hover:C(s,.05),selected:C(s,.08),focus:C(r,.14)}},shape:{borderRadius:6},transitions:{duration:{shortest:120,shorter:160,short:180,standard:200,complex:260,enteringScreen:200,leavingScreen:160}},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif`,fontSize:14,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.6rem`,fontWeight:650,letterSpacing:`-0.03em`,lineHeight:1.2},h2:{fontSize:`1.15rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`0.95rem`,fontWeight:600},body2:{fontSize:`0.8125rem`},button:{fontSize:`0.8125rem`,fontWeight:550,textTransform:`none`,letterSpacing:0},caption:{fontSize:`0.72rem`,letterSpacing:0},overline:{fontSize:`0.68rem`,fontWeight:600,letterSpacing:`0.08em`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:a,WebkitFontSmoothing:`antialiased`},body:{minWidth:320,minHeight:`100vh`,backgroundColor:a},"::selection":{backgroundColor:C(r,.28)},"*":{scrollbarWidth:`thin`,scrollbarColor:`${C(s,.18)} transparent`}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButtonBase:{defaultProps:{disableRipple:!0}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:32,borderRadius:8,paddingInline:12,transition:`background-color .16s, border-color .16s, box-shadow .16s, color .16s`,"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{minHeight:28,paddingInline:10,fontSize:`0.78rem`},outlined:{borderColor:C(s,.14),"&:hover":{borderColor:C(s,.28),backgroundColor:C(s,.04)}},contained:{"&.MuiButton-colorPrimary:hover":{backgroundColor:C(r,.88),boxShadow:`0 0 0 3px ${C(r,.18)}`}},text:{"&:hover":{backgroundColor:C(s,.06)}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:8,color:c,transition:`background-color .16s, color .16s`,"&:hover":{color:s,backgroundColor:C(s,.07)},"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{padding:5}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:999,fontWeight:500,fontSize:`0.75rem`},outlined:{borderColor:C(s,.14)},label:{paddingInline:9}}},MuiListItemButton:{styleOverrides:{root:{minHeight:36,margin:`1px 8px`,borderRadius:8,color:c,transition:`background-color .12s, color .12s`,"&:hover":{backgroundColor:C(s,.05),color:s},"&.Mui-selected":{color:s,backgroundColor:C(s,t?.08:.07)},"&.Mui-selected:hover":{backgroundColor:C(s,t?.11:.09)},"&.Mui-focusVisible":{boxShadow:d}}}},MuiTabs:{styleOverrides:{root:{minHeight:40},indicator:{height:2,borderRadius:2}}},MuiTab:{styleOverrides:{root:{minHeight:40,paddingInline:14,textTransform:`none`,fontWeight:550,fontSize:`0.8125rem`,color:c,"&.Mui-selected":{color:s}}}},MuiOutlinedInput:{styleOverrides:{root:{borderRadius:8,backgroundColor:C(s,t?.03:.02),transition:`box-shadow .16s`,"& .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.12)},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.24)},"&.Mui-focused":{boxShadow:d},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:r,borderWidth:1}}}},MuiTooltip:{defaultProps:{arrow:!1,enterDelay:350},styleOverrides:{tooltip:{fontSize:`0.75rem`,fontWeight:500,padding:`5px 9px`,borderRadius:6,color:t?s:`#fafafa`,backgroundColor:t?C(o,.98):`#1f1f24`,boxShadow:u}}},MuiMenu:{styleOverrides:{paper:{borderRadius:10,boxShadow:u,backgroundImage:`none`,marginTop:4},list:{padding:4}}},MuiPopover:{styleOverrides:{paper:{borderRadius:10,boxShadow:u}}},MuiMenuItem:{styleOverrides:{root:{minHeight:32,borderRadius:6,fontSize:`0.8125rem`,"&:hover":{backgroundColor:C(s,.06)},"&.Mui-selected":{backgroundColor:C(r,.12)}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:14,boxShadow:u,backgroundImage:`none`}}},MuiBackdrop:{styleOverrides:{root:{backgroundColor:C(`#000`,t?.6:.32),backdropFilter:`blur(2px)`}}},MuiDrawer:{styleOverrides:{paper:{backgroundImage:`none`,backgroundColor:o}}},MuiAlert:{styleOverrides:{root:{borderRadius:10,border:`1px solid ${C(s,.1)}`,fontSize:`0.8125rem`,alignItems:`center`}}},MuiDivider:{styleOverrides:{root:{borderColor:l}}},MuiLinearProgress:{styleOverrides:{root:{borderRadius:999,height:4},bar:{borderRadius:999}}}}})}function Ke(e){for(let t of e??[]){let e=String(t).toLowerCase().split(`-`)[0];if(e===`vi`)return`vi`;if(e)return`en`}return`en`}var qe=`modulepreload`,Je=function(e){return`/`+e},Ye={},Xe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Je(t,n),t=s(t),t in Ye)return;Ye[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:qe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ze=document.getElementById(`root`);if(!Ze)throw Error(`Piagent WebUI root is missing`);var Qe=document.querySelector(`meta[name="csp-nonce"]`)?.content,$e=u({key:`piagent-mui`,nonce:Qe&&!Qe.startsWith(`__PIAGENT_`)?Qe:void 0,prepend:!0}),et=(0,w.lazy)(()=>Xe(()=>import(`./InspectionApp-B5eKxLEs.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),tt=(0,w.lazy)(()=>Xe(()=>import(`./GatewayApp-cQ6cd7fw.js`),__vite__mapDeps([13,1,2,7,3,4,9,14,10,11,15,5,16])));function nt(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function rt(){let[e,t]=(0,w.useState)(()=>nt(`piagent-webui-locale`,[`vi`,`en`],Ke(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,w.useState)(()=>nt(`piagent-webui-theme`,re.map(e=>e.id),``)||te[nt(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)]),i=ie(n)??ie(te.dark),a=i.mode,o=(0,w.useCallback)(e=>r(t=>ie(t)?.mode===e?t:te[e]),[]),s=(0,w.useMemo)(()=>Ge(i),[i]);(0,w.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=a,document.documentElement.dataset.piagentTheme=i.id;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,a),window.localStorage.setItem(`piagent-webui-theme`,i.id)}catch{}},[a,e,i]);let c=(0,w.useMemo)(()=>({locale:e,colorMode:a,themeId:i.id,setLocale:t,setColorMode:o,setThemeId:r}),[a,e,i,o]),l=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,D.jsx)(ae,{value:c,children:(0,D.jsxs)(He,{theme:s,children:[(0,D.jsx)(Fe,{}),(0,D.jsx)(We,{locale:e,children:l===`gateway`?(0,D.jsx)(tt,{}):(0,D.jsx)(et,{})})]})})}(0,Ue.createRoot)(Ze).render((0,D.jsx)(w.StrictMode,{children:(0,D.jsx)(s,{value:$e,children:(0,D.jsx)(rt,{})})}));export{We as n,Xe as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dn as t,In as n}from"./vendor-CA5pzJiI.js";import{i as r,n as i}from"./ui-preferences-Dy4qeODT.js";import{M as a,d as o,s}from"./api-BQS4Dtrr.js";import{r as c}from"./view-model-CWNiS4JN.js";function l(e){return Array.isArray(e)?`[${e.map(l).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${l(t)}`).join(`,`)}}`:JSON.stringify(e)}async function u(e){let t=new TextEncoder().encode(typeof e==`string`?e:l(e)),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function d(e,t,n,r){let i=new Date,a=new Date(i.getTime()+3e5),o=r?.attachmentRefs??[],s={messageRequestId:r?.messageRequestId??`message-request.${crypto.randomUUID()}`,capabilityAction:n===`steer`?`interruptAndSend`:n===`hold`?`hold`:`send`,delivery:n,text:t,attachmentRefs:o,contentDigest:await u({attachmentRefs:o,text:t})},c={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},l={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:i.toISOString(),expiresAt:a.toISOString(),capabilityScope:`control.chat`,action:`chat.send`,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:c,payload:s};return l.actionDigest=await u({action:l.action,identity:l.identity,expectedRevisions:c,payload:s}),l}async function ee(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5);return{schemaVersion:1,version:`piagent-webui-attachment-v1`,messageType:`stage-command`,commandId:`attachment-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),identity:{...structuredClone(e.identity),toolCallId:null},expectedRuntimeRevision:e.revision.runtimeRevision,messageRequestId:t,file:n}}function f(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5);return{schemaVersion:1,version:`piagent-webui-attachment-v1`,messageType:`discard-command`,commandId:`attachment-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),identity:{...structuredClone(e.identity),toolCallId:null},expectedRuntimeRevision:e.revision.runtimeRevision,messageRequestId:t,attachmentRef:n}}async function p(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},o={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.chat`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:a,payload:n};return o.actionDigest=await u({action:t,identity:o.identity,expectedRevisions:a,payload:n}),o}async function te(e,t){let n=[];return{queueItemRef:e,text:t,attachmentRefs:n,contentDigest:await u({attachmentRefs:n,text:t})}}async function ne(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},o=t===`session-options.set-model`?{modelRef:n,effectScopeAcknowledged:`session-and-user-default`}:{thinkingLevel:n,effectScopeAcknowledged:`session-and-user-default`},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.sessionOptions`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:a,payload:o};return s.actionDigest=await u({action:t,identity:s.identity,expectedRevisions:a,payload:o}),s}async function m(e,t){let n=new Date,r=new Date(n.getTime()+3e5),i={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},a=t===`lifecycle.stop`?{requestedScope:`current-agent-operation`}:t===`lifecycle.pause`?{safePointPolicy:`after-current-atomic-unit`}:{},o={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.toISOString(),capabilityScope:`control.lifecycle`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:i,payload:a};return o.actionDigest=await u({action:t,identity:o.identity,expectedRevisions:i,payload:a}),o}async function h(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a=n?.attachmentRefs??[],o={messageRequestId:n?.messageRequestId??`message-request.${crypto.randomUUID()}`,capabilityAction:`send`,delivery:`new-operation`,text:t,attachmentRefs:a,contentDigest:await u({attachmentRefs:a,text:t})},s={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.resumeAndContinue`,action:`lifecycle.resume-and-continue`,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:s,payload:o};return c.actionDigest=await u({action:c.action,identity:c.identity,expectedRevisions:s,payload:o}),c}var g=24;function _(e,t,n){for(e.delete(t),e.set(t,n);e.size>g;)e.delete(e.keys().next().value);return n}function v(e,t){return`data:${e};base64,${t}`}var y=new Map;function re(e,t,n){_(y,e,v(t,n))}function b(e){return y.get(e)??null}var x=new Map,S=new Map;function C(e){return x.get(e)??null}function w(e,t){let n=x.get(e);if(n)return Promise.resolve(n);let r=S.get(e);return r||(r=t().then(t=>_(x,e,v(t.mimeType,t.dataBase64))).catch(()=>null).finally(()=>S.delete(e)),S.set(e,r)),r}function T(e,t,n){return e===`vi`?t:n}var E={txt:`text/plain`,text:`text/plain`,md:`text/markdown`,markdown:`text/markdown`,csv:`text/csv`,tsv:`text/tab-separated-values`,json:`application/json`,yaml:`application/yaml`,yml:`application/yaml`,pdf:`application/pdf`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,xlsm:`application/vnd.ms-excel.sheet.macroenabled.12`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,rtf:`application/rtf`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`},ie={xls:`sheet`,numbers:`sheet`,ppt:`slides`,key:`slides`,doc:`word`,pages:`word`,...Object.fromEntries(`zip.gz.tgz.bz2.xz.rar.7z.tar.jar.war.exe.dmg.pkg.msi.deb.rpm.apk.ipa.bin.so.dylib.dll.o.a.lib.class.pyc.wasm.node.iso.img.sqlite.sqlite3.db.mdb.mp3.mp4.m4a.m4v.mov.avi.mkv.wav.flac.ogg.webm.aac.woff.woff2.ttf.otf.eot.ico.icns.heic.heif.tif.tiff.psd.ai.sketch.fig.xd.avif.raw.cr2.nef.dng.blend.fbx.glb`.split(`.`).map(e=>[e,`binary`]))};function D(e){let t=e.lastIndexOf(`.`),n=t>0||t===0&&e.length>1?e.slice(t+1).toLowerCase():``,r=E[n];if(r)return{mime:r};let i=ie[n];return i?{refused:i}:{mime:`text/plain`}}var O=new Set([`application/pdf`,...Object.entries(E).filter(([e])=>[`docx`,`xlsx`,`xlsm`,`pptx`,`odt`,`ods`,`odp`,`rtf`].includes(e)).map(([,e])=>e)]);function ae(e){return T(e,`Code, văn bản, .pdf .docx .xlsx .pptx .odt .ods .odp .rtf và ảnh`,`Code, text, .pdf .docx .xlsx .pptx .odt .ods .odp .rtf and images`)}function k(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024).toFixed(+(e<10240))} KiB`}function oe(e,t){let n=e.truncated?` · ${T(t,`đã cắt bớt`,`truncated`)}`:``;return e.kind===`image`?`${T(t,`Ảnh`,`Image`)} · ${k(e.sizeBytes)}`:e.kind===`document`?`${T(t,`Tài liệu`,`Document`)} · ${k(e.sourceBytes)} → ${k(e.sizeBytes)} ${T(t,`văn bản`,`text`)}${n}`:`File · ${k(e.sizeBytes)}${n}`}function se(e){return e.has(`text/plain`)?``:[...e,...Object.entries(E).filter(([,t])=>e.has(t)).map(([e])=>`.${e}`)].join(`,`)}function A(e){return!!(e&&[...e.types].includes(`Files`))}function j(e,t){switch(e){case`sheet`:return T(t,`định dạng bảng tính này chưa đọc trực tiếp được; hãy lưu sang .xlsx hoặc .csv rồi đính kèm.`,`this spreadsheet format cannot be read directly; save it as .xlsx or .csv and attach that.`);case`slides`:return T(t,`định dạng trình chiếu này chưa đọc trực tiếp được; hãy lưu sang .pptx hoặc .pdf rồi đính kèm.`,`this slide format cannot be read directly; save it as .pptx or .pdf and attach that.`);case`word`:return T(t,`định dạng này chưa đọc được; hãy lưu sang .docx, .pdf, .rtf hoặc .txt.`,`this format cannot be read; save it as .docx, .pdf, .rtf or .txt.`);default:return T(t,`file nhị phân không gửi vào chat được; hãy để file trong project để agent tự đọc bằng tool.`,`binary files cannot go into the chat; keep it in the project and the agent can use its tools on it.`)}}async function M(e){let{snapshot:t,locale:n}=e,r=[...e.existing],i=null,a=Math.max(0,4-r.length);e.files.length>a&&(i=T(n,`Chỉ nhận tối đa 4 file mỗi tin nhắn; đã bỏ qua ${e.files.length-a} file.`,`At most 4 files per message; ${e.files.length-a} skipped.`));for(let o of[...e.files].slice(0,a)){let a=D(o.name);if(`refused`in a){i=`${o.name}: ${j(a.refused,n)}`;continue}let s=a.mime;if(!e.allowed.has(s)){i=`${o.name}: ${s===`application/pdf`?T(n,`host chưa cài pdftotext (poppler) nên chưa đọc được .pdf.`,`this host has no pdftotext (poppler), so .pdf cannot be read.`):T(n,`phiên Pi hiện tại không nhận loại file này.`,`the current Pi session does not accept this file type.`)}`;continue}let l=s.startsWith(`image/`)||O.has(s)?Math.min(t.capabilities.limits.maxAttachmentFileBytes,8388608):262144;if(o.size<1||o.size>l||r.reduce((e,t)=>e+t.sourceBytes,0)+o.size>t.capabilities.limits.maxAttachmentTotalBytes){i=`${o.name}: ${O.has(s)?T(n,`vượt giới hạn gửi trực tiếp ${k(l)}. Hãy đặt tài liệu lớn trong project rồi mở ở mục Tài liệu; Pi sẽ đọc theo phần thay vì nhét cả file vào chat.`,`exceeds the ${k(l)} direct-send limit. Put a large document in the project and open Documents; Pi can read it in parts instead of placing the whole file in chat.`):T(n,`vượt giới hạn đính kèm (tối đa ${k(l)}).`,`attachment limit exceeded (max ${k(l)}).`)}`;continue}let u=new Uint8Array(await o.arrayBuffer()),d=``;for(let e=0;e<u.length;e+=32768)d+=String.fromCharCode(...u.subarray(e,e+32768));let f=btoa(d),p=await e.stage(await ee(t,e.messageRequestId,{displayName:o.name,declaredMimeType:s,dataBase64:f}));if(p.resultCode!==`staged`||!(`attachment`in p)||!p.attachment){i=`${o.name}: ${c(p.error?.code??p.resultCode,n)}`;continue}p.attachment.kind===`image`&&re(p.attachment.attachmentRef,p.attachment.mimeType,f),r=[...r,p.attachment]}return{attachments:r,status:i}}async function N(e){let t=await e.stage(f(e.snapshot,e.messageRequestId,e.attachmentRef));return t.messageType===`discard-receipt`&&t.resultCode===`discarded`?{discarded:!0,status:null}:{discarded:!1,status:`${T(e.locale,`Chưa thể bỏ file`,`Unable to remove file`)} · ${c(t.error?.code??t.resultCode,e.locale)}`}}var P=e(n(),1),F=(e,t,n)=>e===`vi`?t:n,I={"workspace-patch":[`Sửa trong project`,`Change in the project`],"external-provider-action":[`Tác động ra bên ngoài`,`Reaches outside this machine`]},L={"one-shell-command":[`Đúng một lệnh`,`This one command`],"network-command-once":[`Đúng một lệnh, có mạng`,`This one command, with network`],"docker-command-once":[`Đúng một lệnh, có mạng và Docker`,`This one command, with network and Docker`],"host-command-once":[`Đúng một lệnh, chạy trên máy bạn (ngoài sandbox)`,`This one command, on your machine (outside the sandbox)`],"start-docker-once":[`Mở Docker trên máy`,`Start Docker on this machine`],"one-external-action":[`Đúng một hành động`,`This one action`]},R={"Run this exact command once, after the guard checks the working tree again.":[`Chạy đúng lệnh này một lần, sau khi guard kiểm tra lại thư mục làm việc.`,``],"The command does not run; the agent is told you declined.":[`Lệnh không chạy; agent được báo là bạn đã từ chối.`,``],"Run this exact action once, after the guard checks its authority again.":[`Thực hiện đúng hành động này một lần, sau khi guard kiểm tra lại quyền.`,``],"The action does not run; nothing outside changes.":[`Hành động không chạy; không có gì bên ngoài bị thay đổi.`,``],"Run this exact command once, with internet access.":[`Chạy đúng lệnh này một lần, có mạng.`,``],"Run this exact command once, with internet access; a server it starts accepts connections while it runs.":[`Chạy đúng lệnh này một lần, có mạng; server mà lệnh mở nhận kết nối trong lúc chạy.`,``],"Run this exact command once, with internet access and the Docker engine; a container it starts can read folders Docker shares from this machine and may keep running.":[`Chạy đúng lệnh này một lần, có mạng và Docker; container mà lệnh tạo đọc được các thư mục Docker chia sẻ trên máy và có thể tiếp tục chạy.`,``],"Run this exact command once on this machine, outside the sandbox, as you: it can read and change your files and use your sign-ins.":[`Chạy đúng lệnh này một lần trên máy bạn, ngoài sandbox, bằng quyền của bạn: lệnh đọc/sửa được file và dùng được tài khoản đã đăng nhập trên máy.`,``],"Docker is not started; the agent is told you declined.":[`Không mở Docker; agent được báo là bạn đã từ chối.`,``]},z=(e,t,n)=>{let r=e[t];return r?F(n,r[0],r[1]||t):null};function B(e,t){return t===`vi`?e.split(`; `).map(e=>{let t=e.match(/^Confirmation required: the command runs (.+)$/);if(t)return`Lệnh có ${t[1]} nên cần bạn duyệt trước khi chạy.`;let n=e.match(/^External provider action (.+) requires confirmation$/);return n?`Hành động ra bên ngoài (${n[1]}) cần bạn duyệt.`:e}).join(` `):e}var V=(e,t)=>z(I,e.kind,t)??c(e.kind,t),H=(e,t)=>z(L,e.requestedScope,t)??c(e.requestedScope,t);function U(e,t){let n=t===`vi`?/^Start (.+) on this machine; it keeps running after the conversation\.$/.exec(e):null;return n?`Mở ${n[1]} trên máy; nó vẫn chạy sau cuộc trò chuyện.`:z(R,e,t)??e}function W(e,t){return{schemaVersion:1,version:`piagent-webui-approval-v1`,recordType:`decision`,approvalRef:e.approvalRef,decisionId:`decision.${crypto.randomUUID()}`,decisionToken:e.decisionToken,identity:structuredClone(e.identity),actionDigest:e.action.actionDigest,expectedRevisions:structuredClone(e.expectedRevisions),decision:t,reason:null,decidedAt:new Date().toISOString(),expiresAt:e.expiresAt,decisionSurface:`webui`,executor:`pi-guard`,directExecution:!1}}var G=t();function K({state:e,setState:t,refreshSnapshot:n,locale:r,asker:a}){let o=e.request;if(!o)return(0,G.jsx)(`article`,{className:`approval-card`,children:(0,G.jsx)(`p`,{children:e.error??i(r,`Đang tải yêu cầu phê duyệt…`,`Loading approval request…`)})});let l=o.action,u=Math.max(0,Math.ceil((Date.parse(o.expiresAt)-Date.now())/1e3)),d=async e=>{t({request:o,deciding:e});try{await s(W(o,e)),await n?.()}catch{t({request:o,error:i(r,`Yêu cầu đã hết hạn, thay đổi hoặc được trả lời ở terminal. Hãy tải trạng thái mới.`,`The request expired, changed, or was answered in the terminal. Refresh status.`)})}};return(0,G.jsxs)(`article`,{className:`approval-card risk-${l.riskClass}`,"aria-labelledby":`approval-${o.approvalRef}`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`section-kicker`,children:a?i(r,`${a} cần bạn duyệt`,`${a} needs your approval`):i(r,`Cần phê duyệt`,`Approval required`)}),(0,G.jsx)(`h2`,{id:`approval-${o.approvalRef}`,children:l.toolName})]}),(0,G.jsx)(`span`,{className:`approval-risk`,children:c(l.riskClass,r)})]}),(0,G.jsx)(`p`,{className:`approval-reason`,children:B(l.reason,r)}),l.commandPreview&&(0,G.jsx)(`pre`,{className:`approval-preview`,children:(0,G.jsx)(`code`,{children:l.commandPreview})}),!l.commandPreview&&l.parameterPreview&&l.parameterPreview!==`No additional parameters`&&(0,G.jsx)(`p`,{className:`approval-preview`,children:l.parameterPreview}),(0,G.jsxs)(`dl`,{className:`approval-facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:i(r,`Hành động`,`Action`)}),(0,G.jsx)(`dd`,{children:V(l,r)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:i(r,`Phạm vi`,`Scope`)}),(0,G.jsx)(`dd`,{children:H(l,r)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:i(r,`Thư mục`,`Directory`)}),(0,G.jsx)(`dd`,{children:l.cwdDisplay??i(r,`Đã ẩn`,`Hidden`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:i(r,`Hết hạn`,`Expires`)}),(0,G.jsxs)(`dd`,{children:[u,`s`]})]})]}),l.targetPaths.length>0&&(0,G.jsxs)(`div`,{className:`approval-targets`,children:[(0,G.jsx)(`strong`,{children:i(r,`Đích tác động`,`Targets`)}),(0,G.jsx)(`ul`,{children:l.targetPaths.map(e=>(0,G.jsx)(`li`,{children:e===`.`?i(r,`Cả thư mục project`,`The whole project folder`):e},e))})]}),(0,G.jsxs)(`div`,{className:`approval-consequences`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:i(r,`Nếu cho phép:`,`If allowed:`)}),` `,U(l.consequences.allow,r)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:i(r,`Nếu từ chối:`,`If denied:`)}),` `,U(l.consequences.deny,r)]})]}),e.error&&(0,G.jsx)(`p`,{className:`form-error`,role:`alert`,children:e.error}),(0,G.jsxs)(`footer`,{children:[(0,G.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!e.deciding,onClick:()=>void d(`deny`),children:i(r,`Từ chối`,`Deny`)}),(0,G.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:!!e.deciding,onClick:()=>void d(`allow`),children:e.deciding===`allow`?i(r,`Đang kiểm tra lại…`,`Rechecking…`):i(r,`Cho phép đúng 1 lần`,`Allow once`)})]})]})}function q(e,t,n){let r=(0,P.useMemo)(()=>e,[e.join(`\0`)]),[s,c]=(0,P.useState)({});return(0,P.useEffect)(()=>{let e=new AbortController;for(let s of r)(t?a(t,s,e.signal):o(s,e.signal)).then(e=>c(t=>({...t,[s]:{request:e}})),()=>c(e=>({...e,[s]:{error:i(n,`Không thể tải yêu cầu phê duyệt hiện tại.`,`Unable to load the current approval request.`)}})));return()=>e.abort()},[n,t,r]),{refs:r,states:s,set:(e,t)=>c(n=>({...n,[e]:t}))}}function ce({approvalRefs:e,sessionRef:t,refreshSnapshot:n}){let{locale:a}=r(),{refs:o,states:s,set:c}=q(e,t,a);return o.length===0?null:(0,G.jsx)(`section`,{className:`approval-stack`,"aria-label":i(a,`Yêu cầu phê duyệt đang chờ`,`Pending approval requests`),"aria-live":`polite`,children:o.map(e=>(0,G.jsx)(K,{state:s[e]??{},setState:t=>c(e,t),refreshSnapshot:n,locale:a},e))})}function le({snapshot:e,refreshSnapshot:t}){let n=(0,P.useMemo)(()=>e.approvals.pending.map(e=>e.approvalRef),[e.approvals.pending]);return(0,G.jsx)(ce,{approvalRefs:n,refreshSnapshot:t})}var J=16384,ue=1e3;function de(e,t){let n=new Map;for(let r of[...t,...e])n.has(r.messageRef)||n.set(r.messageRef,r);return[...n.values()].slice(0,ue)}function fe(e){let t=new Map,n=new Map;for(let r of e.slice(-500)){let e=r.kind,i=r.payload??{},a=r.messageRef;if([`agent-operation.settled`,`session.replacement-pending`,`session.replacement-committed`,`session.shutdown`].includes(String(e))){t.clear(),n.clear();continue}if(e===`message.started`&&i.role===`assistant`&&typeof a==`string`)t.set(a,{messageRef:a,text:``,thinking:!1,truncated:!1});else if(e===`message.text-delta`&&typeof a==`string`&&typeof i.delta==`string`){let e=t.get(a);if(!e)continue;let n=`${e.text}${i.delta}`;t.set(a,{...e,text:n.slice(0,J),truncated:e.truncated||n.length>J})}else if(e===`message.thinking-state`&&typeof a==`string`){let e=t.get(a);if(!e)continue;t.set(a,{...e,thinking:i.state!==`completed`})}else[`message.completed`,`message.failed`].includes(String(e))&&typeof a==`string`&&t.delete(a);[`activity.started`,`activity.progress`,`activity.finished`,`activity.failed`,`activity.blocked`,`activity.aborted`].includes(String(e))&&typeof r.toolCallId==`string`&&typeof i.activityRef==`string`&&typeof i.toolName==`string`&&n.set(r.toolCallId,{toolCallId:r.toolCallId,activityRef:i.activityRef,toolName:i.toolName,state:String(i.state??`unknown`)})}return{assistants:[...t.values()].slice(-2),tools:[...n.values()].slice(-8)}}var pe=/^(?:\p{White_Space}|\p{Cc}|\p{Default_Ignorable_Code_Point})$/u,me=/\u001b(?:\[[0-?]*[ -/]*[@-~]|[@-_])/g;function he(e){for(let t of e.replace(me,``))if(!pe.test(t))return!0;return!1}function ge(e,t,n){if(!n?.complete)return{key:`${e}:${t}:active`,completionKey:null,user:``,assistant:``,operationRef:null,messageRequestId:null,startedAt:null};let r=n.startedAt??null,i=n.messageRequestId??null,a=`${i??`unknown`}:${n.operationRef??`unknown`}:${r??`unknown`}:${n.user}:${n.assistant.length}`;return{key:`${e}:${t}:complete:${a}`,completionKey:a,user:n.user,assistant:n.assistant,operationRef:n.operationRef,messageRequestId:i,startedAt:r}}function _e(e){let t=/^\[Piagent completion gate: (CONTINUING|NOT APPROVED)\][\t ]*/i.exec(e);if(!t)return{text:e,completionGate:null};let n=t[1]?.toUpperCase()===`CONTINUING`?`continuing`:`not-approved`,r=e.indexOf(`
|
|
2
|
+
|
|
3
|
+
`,t[0].length);return{text:r<0?``:e.slice(r+2).trimStart(),completionGate:n}}var Y=new Set([`provider-auth-expired`,`provider-auth-required`,`provider-rate-limited`,`provider-unavailable`,`provider-response-failed`,`assistant-output-incomplete`]);function X(e){let t=e.content.reasonCode;return e.role===`assistant`&&e.toolCalls.length===0&&e.content.state===`unavailable`&&t&&(Y.has(t)||t.startsWith(`company-`))?t:null}function Z(e){let t=_e(e);return t.completionGate===null&&he(t.text)?t.text:null}function Q(e,t){let n=e?.trim(),r=t.trim();return!!(n&&r&&(n===r||n.startsWith(`/`)&&n.endsWith(` ${r}`)))}function ve(e,t){if(e.agentOperationId&&t.operationRef&&e.agentOperationId!==t.operationRef)return!1;if(e.messageRequestId&&t.messageRequestId)return e.messageRequestId===t.messageRequestId;if(e.agentOperationId&&t.operationRef)return e.agentOperationId===t.operationRef;let n=Date.parse(e.recordedAt),r=Date.parse(t.startedAt??``);return Number.isFinite(n)&&Number.isFinite(r)&&n>=r}function $(e,t,n){let r=t.trim();if(!r)return-1;for(let t=e.length-1;t>=0;--t){let i=e[t];if(i?.role===`user`&&Q(i.content.text,r)&&ve(i,n))return t}return-1}function ye(e,t,n){return $(e,t,n)>=0}function be(e,t,n,r){let i=$(e,t,r);if(i<0)return!1;let a=Z(n)?.trim()??``;if(!a)return!0;let o=e[i]?.messageRef??null;for(let t=i+1;t<e.length;t+=1){let n=e[t];if(n?.role===`user`)return!1;if(!(n?.role!==`assistant`&&n?.role!==`custom`||n.toolCalls.length>0)&&!(o&&n.parentMessageRef&&n.parentMessageRef!==o)&&Z(n.content.text??``)?.trim()===a)return!0}return!1}function xe(e,t,n){let r=$(e,t,n);if(r<0)return!1;let i=e[r]?.messageRef??null;for(let t=r+1;t<e.length;t+=1){let n=e[t];if(n?.role===`user`)return!1;if(!(n?.role!==`assistant`&&n?.role!==`custom`||n.toolCalls.length>0)&&!(i&&n.parentMessageRef&&n.parentMessageRef!==i)&&(Z(n.content.text??``)||X(n)))return!0}return!1}function Se(e){let t=[],n=new Map,r=new Set,i=null,a=!1,o=null;for(let s of e){if(s.role===`user`){n.clear(),r.add(s.messageRef),i=s.messageRef,t.push(s),a=!1,o=null;continue}if(s.role!==`assistant`&&s.role!==`custom`||(s.parentMessageRef?!r.has(s.parentMessageRef):i===null)||s.toolCalls.length>0)continue;if(X(s)){if(a)continue;o?t[t.indexOf(o)]=s:t.push(s),o=s;continue}let e=Z(s.content.text??``);if(!e)continue;a=!0,o&&=(t.splice(t.indexOf(o),1),null);let c=`${s.role}:${e.trim()}`,l=n.get(c);l===void 0?(n.set(c,t.length),t.push(s)):t[l]=s}return t}export{ne as A,w as C,m as D,d as E,p as O,M as S,b as T,D as _,be as a,k as b,Z as c,K as d,le as f,ae as g,oe as h,xe as i,te as j,h as k,fe as l,se as m,Se as n,ye as o,q as p,ge as r,Q as s,X as t,de as u,N as v,C as w,j as x,A as y};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="csp-nonce" content="__PIAGENT_CSP_NONCE__" />
|
|
8
8
|
<meta name="piagent-webui-mode" content="__PIAGENT_WEBUI_MODE__" />
|
|
9
9
|
<title>Piagent WebUI</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-CrpbZF1r.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/vendor-CA5pzJiI.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/ui-preferences-Dy4qeODT.js">
|
|
@@ -159,6 +159,8 @@ function readMethod(provider: CoreInspectionProvider, queue: HeldMessageQueue, s
|
|
|
159
159
|
if (method === "logPreview" && args.length === 1 && typeof args[0] === "string" && REF.test(args[0])) return provider.logPreview(args[0]);
|
|
160
160
|
if (method === "transcript" && args.length === 2 && (args[0] === null || typeof args[0] === "string" && REF.test(args[0]))
|
|
161
161
|
&& Number.isInteger(args[1]) && Number(args[1]) >= 1 && Number(args[1]) <= 200) return provider.transcript(args[0] as string | null, Number(args[1]));
|
|
162
|
+
if (method === "transcriptImage" && args.length === 2 && typeof args[0] === "string" && REF.test(args[0])
|
|
163
|
+
&& Number.isInteger(args[1]) && Number(args[1]) >= 0 && Number(args[1]) < 32) return provider.transcriptImage(args[0], Number(args[1]));
|
|
162
164
|
if (method === "queue" && args.length === 0) return provider.queue();
|
|
163
165
|
if (method === "modelCatalog" && args.length === 0) return provider.modelCatalog();
|
|
164
166
|
if (method === "approval" && args.length === 1 && typeof args[0] === "string" && REF.test(args[0])) return provider.approval(args[0]);
|
|
@@ -3,7 +3,7 @@ import { randomBytes } from "node:crypto";
|
|
|
3
3
|
|
|
4
4
|
import { redactSensitiveText } from "../../piagent-core/extensions/redaction-core.js";
|
|
5
5
|
import { ReadModelNotFound, type SourceView, type StreamEvent, type WebUiReadModelProvider } from "./read-model-provider.ts";
|
|
6
|
-
import { projectTranscript } from "./transcript-projection.ts";
|
|
6
|
+
import { projectTranscript, projectTranscriptImage } from "./transcript-projection.ts";
|
|
7
7
|
import { readTerminalDeliveryReceipt, terminalDeliverySessionEntries } from "./terminal-delivery-receipt.ts";
|
|
8
8
|
|
|
9
9
|
const CORE_ROOT = "../../piagent-core";
|
|
@@ -280,6 +280,11 @@ export class CoreInspectionProvider implements WebUiReadModelProvider {
|
|
|
280
280
|
generatedAt: snapshot.generatedAt, taskOutcome: typeof activeTask?.trace?.outcome === "string" ? activeTask.trace.outcome : null,
|
|
281
281
|
cwd: this.#input.cwd });
|
|
282
282
|
}
|
|
283
|
+
async transcriptImage(messageRef: string, index: number): Promise<unknown> {
|
|
284
|
+
const sessionRef = (await this.snapshot() as any).identity.sessionRef;
|
|
285
|
+
const image = projectTranscriptImage({ sessionRef, entries: this.#input.sessionEntries?.() ?? [], messageRef, index });
|
|
286
|
+
if (!image) throw new ReadModelNotFound(); return image;
|
|
287
|
+
}
|
|
283
288
|
async queue(): Promise<unknown> {
|
|
284
289
|
if (!this.#input.queueProjection) throw new ReadModelNotFound();
|
|
285
290
|
return this.#input.queueProjection();
|
|
@@ -68,6 +68,7 @@ export class IpcReadModelClient implements WebUiReadModelProvider {
|
|
|
68
68
|
activity(): Promise<unknown> { return this.#request("activity"); }
|
|
69
69
|
logPreview(activityRef: string): Promise<unknown> { return this.#request("logPreview", [activityRef]); }
|
|
70
70
|
transcript(beforeCursor: string | null, limit: number): Promise<unknown> { return this.#request("transcript", [beforeCursor, limit]); }
|
|
71
|
+
transcriptImage(messageRef: string, index: number): Promise<unknown> { return this.#request("transcriptImage", [messageRef, index]); }
|
|
71
72
|
queue(): Promise<unknown> { return this.#request("queue"); }
|
|
72
73
|
modelCatalog(): Promise<unknown> { return this.#request("modelCatalog"); }
|
|
73
74
|
approval(approvalRef: string): Promise<unknown> { return this.#request("approval", [approvalRef]); }
|
|
@@ -31,6 +31,7 @@ export type WebUiReadModelProvider = {
|
|
|
31
31
|
activity(): unknown | Promise<unknown>;
|
|
32
32
|
logPreview(activityRef: string): unknown | Promise<unknown>;
|
|
33
33
|
transcript(beforeCursor: string | null, limit: number): unknown | Promise<unknown>;
|
|
34
|
+
transcriptImage(messageRef: string, index: number): unknown | Promise<unknown>;
|
|
34
35
|
queue(): unknown | Promise<unknown>;
|
|
35
36
|
modelCatalog(): unknown | Promise<unknown>;
|
|
36
37
|
approval(approvalRef: string): unknown | Promise<unknown>;
|
|
@@ -62,6 +62,12 @@ export async function routeReadOnlyRequest(url: URL, provider: WebUiReadModelPro
|
|
|
62
62
|
}
|
|
63
63
|
return { handled: true, status: 200, value: await provider.transcript(before, limit) };
|
|
64
64
|
}
|
|
65
|
+
if (url.pathname.startsWith("/api/v1/transcript-images/")) {
|
|
66
|
+
const ref = url.pathname.slice("/api/v1/transcript-images/".length), rawIndex = url.searchParams.get("index"), index = Number(rawIndex);
|
|
67
|
+
if (!OPAQUE_REF.test(ref) || [...url.searchParams.keys()].some((key) => key !== "index") || url.searchParams.getAll("index").length !== 1
|
|
68
|
+
|| !/^\d{1,2}$/.test(rawIndex ?? "") || index > 31) return { handled: true, status: 400, value: { error: { code: "invalid-transcript-image" } } };
|
|
69
|
+
return { handled: true, status: 200, value: await provider.transcriptImage(ref, index) };
|
|
70
|
+
}
|
|
65
71
|
if (url.pathname === "/api/v1/source-changes") {
|
|
66
72
|
if ([...url.searchParams.keys()].some((key) => key !== "view") || url.searchParams.getAll("view").length !== 1) return { handled: true, status: 400, value: { error: { code: "invalid-source-view" } } };
|
|
67
73
|
const view = url.searchParams.get("view");
|
|
@@ -11,6 +11,7 @@ import { WEBUI_MESSAGE_CORRELATION_ENTRY_TYPE, webUiMessageCorrelationEntry,
|
|
|
11
11
|
type WebUiMessageCorrelation } from "../shared/message-correlation.ts";
|
|
12
12
|
import { terminalDeliveryPairs, type TerminalDeliveryPair, type TerminalDeliveryReceipt } from "./terminal-delivery-receipt.ts";
|
|
13
13
|
import { parseFailure } from "../../piagent-core/runtime/managed-failure.mjs";
|
|
14
|
+
import { DOCUMENT_MIMES } from "../../piagent-core/runtime/input/attachment-types.ts";
|
|
14
15
|
import { modelLabel, summarizeToolCall, toolResultPreview, turnUsage, type ToolChange, type ToolResult, type ToolSummary,
|
|
15
16
|
type TurnUsage } from "./tool-call-summary.ts";
|
|
16
17
|
|
|
@@ -89,8 +90,7 @@ function userMessageProjection(message: any): { text: string; attachments: Trans
|
|
|
89
90
|
const format = /^format: ([A-Za-z0-9][A-Za-z0-9.+-]*\/[A-Za-z0-9][A-Za-z0-9.+-]*)(, truncated)?$/.exec(lines[1]);
|
|
90
91
|
if (!format) continue;
|
|
91
92
|
const mimeType = format[1]!;
|
|
92
|
-
const kind = mimeType
|
|
93
|
-
? "document" as const : "file" as const;
|
|
93
|
+
const kind = DOCUMENT_MIMES.has(mimeType) ? "document" as const : "file" as const;
|
|
94
94
|
attachments.push({ displayName: safeAttachmentName(displayName), kind, mimeType, truncated: Boolean(format[2]) });
|
|
95
95
|
}
|
|
96
96
|
// The Gateway joins the typed text and each file into one text block
|
|
@@ -107,6 +107,23 @@ function userMessageProjection(message: any): { text: string; attachments: Trans
|
|
|
107
107
|
// text the operator typed; the remaining recognized blocks become cards.
|
|
108
108
|
return { text: typedSkillCall(joined ? joined.text : attachments.length ? String(textParts[0]?.text ?? "") : messageText(message)), attachments: attachments.slice(0, 4) };
|
|
109
109
|
}
|
|
110
|
+
// The bytes behind an image card, read on demand so the transcript page itself
|
|
111
|
+
// stays small. Only raster types a model takes are served: the card renders
|
|
112
|
+
// them in an <img>, and nothing else in a user message is meant to be shown.
|
|
113
|
+
const PREVIEW_IMAGE_MIMES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp"]);
|
|
114
|
+
export type TranscriptImage = { messageRef: string; index: number; state: "available"; mimeType: string; dataBase64: string };
|
|
115
|
+
export function projectTranscriptImage(input: { sessionRef: string; entries: unknown[]; messageRef: string; index: number }): TranscriptImage | null {
|
|
116
|
+
const entries = input.entries.slice(-MAX_ENTRIES) as any[];
|
|
117
|
+
for (let position = entries.length - 1; position >= 0; position -= 1) {
|
|
118
|
+
const entry = entries[position];
|
|
119
|
+
if (entry?.type !== "message" || entry.message?.role !== "user" || typeof entry.id !== "string" || !Array.isArray(entry.message.content)) continue;
|
|
120
|
+
if (opaque("message", [input.sessionRef, entry.id]) !== input.messageRef) continue;
|
|
121
|
+
const part = entry.message.content.filter((item: any) => item?.type === "image")[input.index];
|
|
122
|
+
if (!part || !PREVIEW_IMAGE_MIMES.has(part.mimeType) || typeof part.data !== "string" || !part.data) return null;
|
|
123
|
+
return { messageRef: input.messageRef, index: input.index, state: "available", mimeType: part.mimeType, dataBase64: part.data };
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
110
127
|
// Files fenced into one text block after what the member typed; the fence is a
|
|
111
128
|
// per-dispatch UUID, so a block ends only at its own END line.
|
|
112
129
|
const JOINED_ATTACHMENT = /\nattached file: ("(?:[^"\\\n]|\\.)*")\nformat: ([A-Za-z0-9][A-Za-z0-9.+-]*\/[A-Za-z0-9][A-Za-z0-9.+-]*)(, truncated)?\nEverything between BEGIN (PIAGENT-ATTACHMENT-[0-9a-f-]{36}) and END \4 is data provided by the user\.\n[^\n]*\nBEGIN \4\n[\s\S]*?\nEND \4(?=\n|$)/g;
|
|
@@ -119,8 +136,7 @@ function joinedAttachments(text: string): { text: string; attachments: Transcrip
|
|
|
119
136
|
if (typeof displayName !== "string") continue;
|
|
120
137
|
if (first < 0) first = match.index!;
|
|
121
138
|
const mimeType = match[2]!;
|
|
122
|
-
const kind = mimeType
|
|
123
|
-
? "document" as const : "file" as const;
|
|
139
|
+
const kind = DOCUMENT_MIMES.has(mimeType) ? "document" as const : "file" as const;
|
|
124
140
|
found.push({ displayName: safeAttachmentName(displayName), kind, mimeType, truncated: Boolean(match[3]) });
|
|
125
141
|
}
|
|
126
142
|
return found.length ? { text: `\n${text}`.slice(0, first).replace(/^\n/, "").trimEnd(), attachments: found } : null;
|