vibe-coding-master 0.9.6 → 0.9.8
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/README.md +20 -2
- package/dist/backend/adapters/command-runner.js +7 -2
- package/dist/backend/adapters/git-adapter.js +83 -5
- package/dist/backend/api/claude-hook-routes.js +5 -0
- package/dist/backend/server.js +35 -3
- package/dist/backend/services/artifact-service.js +8 -0
- package/dist/backend/services/claude-hook-service.js +5 -1
- package/dist/backend/services/environment-check.js +245 -0
- package/dist/backend/services/gate-review-service.js +19 -0
- package/dist/backend/services/harness-service.js +11 -0
- package/dist/backend/services/message-service.js +13 -1
- package/dist/backend/services/no-proxy-environment.js +29 -0
- package/dist/backend/services/project-service.js +50 -2
- package/dist/backend/services/session-service.js +9 -0
- package/dist/backend/services/workflow-control-service.js +17 -2
- package/dist-frontend/assets/index-C6tXxGlk.css +32 -0
- package/dist-frontend/assets/{index-Bsd4k8YI.js → index-Ct8NwH3l.js} +2 -2
- package/dist-frontend/index.html +2 -2
- package/package.json +1 -1
- package/dist-frontend/assets/index-CRUqb0PX.css +0 -32
|
@@ -90,8 +90,8 @@ WARNING: This link could potentially be dangerous`)){const _=window.open();if(_)
|
|
|
90
90
|
`))}function c(x,T,E,y){const _=E.enter("tableCell"),v=E.enter("phrasing"),b=E.containerPhrasing(x,{...y,before:m,after:m});return v(),_(),b}function u(x,T){return Kx(x,{align:T,alignDelimiters:l,padding:s,stringLength:d})}function g(x,T,E){const y=x.children;let _=-1;const v=[],b=T.enter("table");for(;++_<y.length;)v[_]=h(y[_],T,E);return b(),v}function h(x,T,E){const y=x.children;let _=-1;const v=[],b=T.enter("tableRow");for(;++_<y.length;)v[_]=c(y[_],x,T,E);return b(),v}function S(x,T,E){let y=xv.inlineCode(x,T,E);return E.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function jE(){return{exit:{taskListCheckValueChecked:Jg,taskListCheckValueUnchecked:Jg,paragraph:HE}}}function NE(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:zE}}}function Jg(t){const r=this.stack[this.stack.length-2];r.type,r.checked=t.type==="taskListCheckValueChecked"}function HE(t){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const l=s.children[0];if(l&&l.type==="text"){const d=r.children;let m=-1,f;for(;++m<d.length;){const o=d[m];if(o.type==="paragraph"){f=o;break}}f===s&&(l.value=l.value.slice(1),l.value.length===0?s.children.shift():s.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,s.position.start=Object.assign({},l.position.start)))}}this.exit(t)}function zE(t,r,s,l){const d=t.children[0],m=typeof t.checked=="boolean"&&d&&d.type==="paragraph",f="["+(t.checked?"x":" ")+"] ",o=s.createTracker(l);m&&o.move(f);let c=xv.listItem(t,r,s,{...l,...o.current()});return m&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(g){return g+f}}function IE(){return[_x(),zx(),Fx(),TE(),jE()]}function UE(t){return{extensions:[vx(),Ix(t),qx(),BE(t),NE()]}}const PE={tokenize:WE,partial:!0},Ev={tokenize:KE,partial:!0},kv={tokenize:YE,partial:!0},Av={tokenize:XE,partial:!0},FE={tokenize:QE,partial:!0},Tv={name:"wwwAutolink",tokenize:GE,previous:Dv},Rv={name:"protocolAutolink",tokenize:VE,previous:Mv},$i={name:"emailAutolink",tokenize:$E,previous:Lv},pi={};function qE(){return{text:pi}}let Zr=48;for(;Zr<123;)pi[Zr]=$i,Zr++,Zr===58?Zr=65:Zr===91&&(Zr=97);pi[43]=$i;pi[45]=$i;pi[46]=$i;pi[95]=$i;pi[72]=[$i,Rv];pi[104]=[$i,Rv];pi[87]=[$i,Tv];pi[119]=[$i,Tv];function $E(t,r,s){const l=this;let d,m;return f;function f(h){return!Fh(h)||!Lv.call(l,l.previous)||hf(l.events)?s(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),o(h))}function o(h){return Fh(h)?(t.consume(h),o):h===64?(t.consume(h),c):s(h)}function c(h){return h===46?t.check(FE,g,u)(h):h===45||h===95||Jt(h)?(m=!0,t.consume(h),c):g(h)}function u(h){return t.consume(h),d=!0,c}function g(h){return m&&d&&ln(l.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),r(h)):s(h)}}function GE(t,r,s){const l=this;return d;function d(f){return f!==87&&f!==119||!Dv.call(l,l.previous)||hf(l.events)?s(f):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(PE,t.attempt(Ev,t.attempt(kv,m),s),s)(f))}function m(f){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),r(f)}}function VE(t,r,s){const l=this;let d="",m=!1;return f;function f(h){return(h===72||h===104)&&Mv.call(l,l.previous)&&!hf(l.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),d+=String.fromCodePoint(h),t.consume(h),o):s(h)}function o(h){if(ln(h)&&d.length<5)return d+=String.fromCodePoint(h),t.consume(h),o;if(h===58){const S=d.toLowerCase();if(S==="http"||S==="https")return t.consume(h),c}return s(h)}function c(h){return h===47?(t.consume(h),m?u:(m=!0,c)):s(h)}function u(h){return h===null||zo(h)||mt(h)||ns(h)||Wo(h)?s(h):t.attempt(Ev,t.attempt(kv,g),s)(h)}function g(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),r(h)}}function WE(t,r,s){let l=0;return d;function d(f){return(f===87||f===119)&&l<3?(l++,t.consume(f),d):f===46&&l===3?(t.consume(f),m):s(f)}function m(f){return f===null?s(f):r(f)}}function KE(t,r,s){let l,d,m;return f;function f(u){return u===46||u===95?t.check(Av,c,o)(u):u===null||mt(u)||ns(u)||u!==45&&Wo(u)?c(u):(m=!0,t.consume(u),f)}function o(u){return u===95?l=!0:(d=l,l=void 0),t.consume(u),f}function c(u){return d||l||!m?s(u):r(u)}}function YE(t,r){let s=0,l=0;return d;function d(f){return f===40?(s++,t.consume(f),d):f===41&&l<s?m(f):f===33||f===34||f===38||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===60||f===63||f===93||f===95||f===126?t.check(Av,r,m)(f):f===null||mt(f)||ns(f)?r(f):(t.consume(f),d)}function m(f){return f===41&&l++,t.consume(f),d}}function XE(t,r,s){return l;function l(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(t.consume(o),l):o===38?(t.consume(o),m):o===93?(t.consume(o),d):o===60||o===null||mt(o)||ns(o)?r(o):s(o)}function d(o){return o===null||o===40||o===91||mt(o)||ns(o)?r(o):l(o)}function m(o){return ln(o)?f(o):s(o)}function f(o){return o===59?(t.consume(o),l):ln(o)?(t.consume(o),f):s(o)}}function QE(t,r,s){return l;function l(m){return t.consume(m),d}function d(m){return Jt(m)?s(m):r(m)}}function Dv(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||mt(t)}function Mv(t){return!ln(t)}function Lv(t){return!(t===47||Fh(t))}function Fh(t){return t===43||t===45||t===46||t===95||Jt(t)}function hf(t){let r=t.length,s=!1;for(;r--;){const l=t[r][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){s=!0;break}if(l._gfmAutolinkLiteralWalkedInto){s=!1;break}}return t.length>0&&!s&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const JE={tokenize:ak,partial:!0};function ZE(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ik,continuation:{tokenize:rk},exit:sk}},text:{91:{name:"gfmFootnoteCall",tokenize:nk},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ek,resolveTo:tk}}}}function ek(t,r,s){const l=this;let d=l.events.length;const m=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let f;for(;d--;){const c=l.events[d][1];if(c.type==="labelImage"){f=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!f||!f._balanced)return s(c);const u=Zn(l.sliceSerialize({start:f.end,end:l.now()}));return u.codePointAt(0)!==94||!m.includes(u.slice(1))?s(c):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(c),t.exit("gfmFootnoteCallLabelMarker"),r(c))}}function tk(t,r){let s=t.length;for(;s--;)if(t[s][1].type==="labelImage"&&t[s][0]==="enter"){t[s][1];break}t[s+1][1].type="data",t[s+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},t[s+3][1].start),end:Object.assign({},t[t.length-1][1].end)},d={type:"gfmFootnoteCallMarker",start:Object.assign({},t[s+3][1].end),end:Object.assign({},t[s+3][1].end)};d.end.column++,d.end.offset++,d.end._bufferIndex++;const m={type:"gfmFootnoteCallString",start:Object.assign({},d.end),end:Object.assign({},t[t.length-1][1].start)},f={type:"chunkString",contentType:"string",start:Object.assign({},m.start),end:Object.assign({},m.end)},o=[t[s+1],t[s+2],["enter",l,r],t[s+3],t[s+4],["enter",d,r],["exit",d,r],["enter",m,r],["enter",f,r],["exit",f,r],["exit",m,r],t[t.length-2],t[t.length-1],["exit",l,r]];return t.splice(s,t.length-s+1,...o),t}function nk(t,r,s){const l=this,d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let m=0,f;return o;function o(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?s(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(h){if(m>999||h===93&&!f||h===null||h===91||mt(h))return s(h);if(h===93){t.exit("chunkString");const S=t.exit("gfmFootnoteCallString");return d.includes(Zn(l.sliceSerialize(S)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),r):s(h)}return mt(h)||(f=!0),m++,t.consume(h),h===92?g:u}function g(h){return h===91||h===92||h===93?(t.consume(h),m++,u):u(h)}}function ik(t,r,s){const l=this,d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let m,f=0,o;return c;function c(T){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(T){return T===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",g):s(T)}function g(T){if(f>999||T===93&&!o||T===null||T===91||mt(T))return s(T);if(T===93){t.exit("chunkString");const E=t.exit("gfmFootnoteDefinitionLabelString");return m=Zn(l.sliceSerialize(E)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),S}return mt(T)||(o=!0),f++,t.consume(T),T===92?h:g}function h(T){return T===91||T===92||T===93?(t.consume(T),f++,g):g(T)}function S(T){return T===58?(t.enter("definitionMarker"),t.consume(T),t.exit("definitionMarker"),d.includes(m)||d.push(m),tt(t,x,"gfmFootnoteDefinitionWhitespace")):s(T)}function x(T){return r(T)}}function rk(t,r,s){return t.check(_l,r,t.attempt(JE,r,s))}function sk(t){t.exit("gfmFootnoteDefinition")}function ak(t,r,s){const l=this;return tt(t,d,"gfmFootnoteDefinitionIndent",5);function d(m){const f=l.events[l.events.length-1];return f&&f[1].type==="gfmFootnoteDefinitionIndent"&&f[2].sliceSerialize(f[1],!0).length===4?r(m):s(m)}}function lk(t){let s=(t||{}).singleTilde;const l={name:"strikethrough",tokenize:m,resolveAll:d};return s==null&&(s=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function d(f,o){let c=-1;for(;++c<f.length;)if(f[c][0]==="enter"&&f[c][1].type==="strikethroughSequenceTemporary"&&f[c][1]._close){let u=c;for(;u--;)if(f[u][0]==="exit"&&f[u][1].type==="strikethroughSequenceTemporary"&&f[u][1]._open&&f[c][1].end.offset-f[c][1].start.offset===f[u][1].end.offset-f[u][1].start.offset){f[c][1].type="strikethroughSequence",f[u][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},f[u][1].start),end:Object.assign({},f[c][1].end)},h={type:"strikethroughText",start:Object.assign({},f[u][1].end),end:Object.assign({},f[c][1].start)},S=[["enter",g,o],["enter",f[u][1],o],["exit",f[u][1],o],["enter",h,o]],x=o.parser.constructs.insideSpan.null;x&&Tn(S,S.length,0,Ko(x,f.slice(u+1,c),o)),Tn(S,S.length,0,[["exit",h,o],["enter",f[c][1],o],["exit",f[c][1],o],["exit",g,o]]),Tn(f,u-1,c-u+3,S),c=u+S.length-2;break}}for(c=-1;++c<f.length;)f[c][1].type==="strikethroughSequenceTemporary"&&(f[c][1].type="data");return f}function m(f,o,c){const u=this.previous,g=this.events;let h=0;return S;function S(T){return u===126&&g[g.length-1][1].type!=="characterEscape"?c(T):(f.enter("strikethroughSequenceTemporary"),x(T))}function x(T){const E=Xs(u);if(T===126)return h>1?c(T):(f.consume(T),h++,x);if(h<2&&!s)return c(T);const y=f.exit("strikethroughSequenceTemporary"),_=Xs(T);return y._open=!_||_===2&&!!E,y._close=!E||E===2&&!!_,o(T)}}}class ok{constructor(){this.map=[]}add(r,s,l){ck(this,r,s,l)}consume(r){if(this.map.sort(function(m,f){return m[0]-f[0]}),this.map.length===0)return;let s=this.map.length;const l=[];for(;s>0;)s-=1,l.push(r.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),r.length=this.map[s][0];l.push(r.slice()),r.length=0;let d=l.pop();for(;d;){for(const m of d)r.push(m);d=l.pop()}this.map.length=0}}function ck(t,r,s,l){let d=0;if(!(s===0&&l.length===0)){for(;d<t.map.length;){if(t.map[d][0]===r){t.map[d][1]+=s,t.map[d][2].push(...l);return}d+=1}t.map.push([r,s,l])}}function uk(t,r){let s=!1;const l=[];for(;r<t.length;){const d=t[r];if(s){if(d[0]==="enter")d[1].type==="tableContent"&&l.push(t[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(d[1].type==="tableContent"){if(t[r-1][1].type==="tableDelimiterMarker"){const m=l.length-1;l[m]=l[m]==="left"?"center":"right"}}else if(d[1].type==="tableDelimiterRow")break}else d[0]==="enter"&&d[1].type==="tableDelimiterRow"&&(s=!0);r+=1}return l}function hk(){return{flow:{null:{name:"table",tokenize:fk,resolveAll:dk}}}}function fk(t,r,s){const l=this;let d=0,m=0,f;return o;function o(O){let H=l.events.length-1;for(;H>-1;){const W=l.events[H][1].type;if(W==="lineEnding"||W==="linePrefix")H--;else break}const U=H>-1?l.events[H][1].type:null,P=U==="tableHead"||U==="tableRow"?R:c;return P===R&&l.parser.lazy[l.now().line]?s(O):P(O)}function c(O){return t.enter("tableHead"),t.enter("tableRow"),u(O)}function u(O){return O===124||(f=!0,m+=1),g(O)}function g(O){return O===null?s(O):Le(O)?m>1?(m=0,l.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),x):s(O):Ye(O)?tt(t,g,"whitespace")(O):(m+=1,f&&(f=!1,d+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),f=!0,g):(t.enter("data"),h(O)))}function h(O){return O===null||O===124||mt(O)?(t.exit("data"),g(O)):(t.consume(O),O===92?S:h)}function S(O){return O===92||O===124?(t.consume(O),h):h(O)}function x(O){return l.interrupt=!1,l.parser.lazy[l.now().line]?s(O):(t.enter("tableDelimiterRow"),f=!1,Ye(O)?tt(t,T,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):T(O))}function T(O){return O===45||O===58?y(O):O===124?(f=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),E):L(O)}function E(O){return Ye(O)?tt(t,y,"whitespace")(O):y(O)}function y(O){return O===58?(m+=1,f=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),_):O===45?(m+=1,_(O)):O===null||Le(O)?k(O):L(O)}function _(O){return O===45?(t.enter("tableDelimiterFiller"),v(O)):L(O)}function v(O){return O===45?(t.consume(O),v):O===58?(f=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(O))}function b(O){return Ye(O)?tt(t,k,"whitespace")(O):k(O)}function k(O){return O===124?T(O):O===null||Le(O)?!f||d!==m?L(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),r(O)):L(O)}function L(O){return s(O)}function R(O){return t.enter("tableRow"),D(O)}function D(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),D):O===null||Le(O)?(t.exit("tableRow"),r(O)):Ye(O)?tt(t,D,"whitespace")(O):(t.enter("data"),A(O))}function A(O){return O===null||O===124||mt(O)?(t.exit("data"),D(O)):(t.consume(O),O===92?M:A)}function M(O){return O===92||O===124?(t.consume(O),A):A(O)}}function dk(t,r){let s=-1,l=!0,d=0,m=[0,0,0,0],f=[0,0,0,0],o=!1,c=0,u,g,h;const S=new ok;for(;++s<t.length;){const x=t[s],T=x[1];x[0]==="enter"?T.type==="tableHead"?(o=!1,c!==0&&(Zg(S,r,c,u,g),g=void 0,c=0),u={type:"table",start:Object.assign({},T.start),end:Object.assign({},T.end)},S.add(s,0,[["enter",u,r]])):T.type==="tableRow"||T.type==="tableDelimiterRow"?(l=!0,h=void 0,m=[0,0,0,0],f=[0,s+1,0,0],o&&(o=!1,g={type:"tableBody",start:Object.assign({},T.start),end:Object.assign({},T.end)},S.add(s,0,[["enter",g,r]])),d=T.type==="tableDelimiterRow"?2:g?3:1):d&&(T.type==="data"||T.type==="tableDelimiterMarker"||T.type==="tableDelimiterFiller")?(l=!1,f[2]===0&&(m[1]!==0&&(f[0]=f[1],h=Oo(S,r,m,d,void 0,h),m=[0,0,0,0]),f[2]=s)):T.type==="tableCellDivider"&&(l?l=!1:(m[1]!==0&&(f[0]=f[1],h=Oo(S,r,m,d,void 0,h)),m=f,f=[m[1],s,0,0])):T.type==="tableHead"?(o=!0,c=s):T.type==="tableRow"||T.type==="tableDelimiterRow"?(c=s,m[1]!==0?(f[0]=f[1],h=Oo(S,r,m,d,s,h)):f[1]!==0&&(h=Oo(S,r,f,d,s,h)),d=0):d&&(T.type==="data"||T.type==="tableDelimiterMarker"||T.type==="tableDelimiterFiller")&&(f[3]=s)}for(c!==0&&Zg(S,r,c,u,g),S.consume(r.events),s=-1;++s<r.events.length;){const x=r.events[s];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=uk(r.events,s))}return t}function Oo(t,r,s,l,d,m){const f=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",o="tableContent";s[0]!==0&&(m.end=Object.assign({},Ws(r.events,s[0])),t.add(s[0],0,[["exit",m,r]]));const c=Ws(r.events,s[1]);if(m={type:f,start:Object.assign({},c),end:Object.assign({},c)},t.add(s[1],0,[["enter",m,r]]),s[2]!==0){const u=Ws(r.events,s[2]),g=Ws(r.events,s[3]),h={type:o,start:Object.assign({},u),end:Object.assign({},g)};if(t.add(s[2],0,[["enter",h,r]]),l!==2){const S=r.events[s[2]],x=r.events[s[3]];if(S[1].end=Object.assign({},x[1].end),S[1].type="chunkText",S[1].contentType="text",s[3]>s[2]+1){const T=s[2]+1,E=s[3]-s[2]-1;t.add(T,E,[])}}t.add(s[3]+1,0,[["exit",h,r]])}return d!==void 0&&(m.end=Object.assign({},Ws(r.events,d)),t.add(d,0,[["exit",m,r]]),m=void 0),m}function Zg(t,r,s,l,d){const m=[],f=Ws(r.events,s);d&&(d.end=Object.assign({},f),m.push(["exit",d,r])),l.end=Object.assign({},f),m.push(["exit",l,r]),t.add(s+1,0,m)}function Ws(t,r){const s=t[r],l=s[0]==="enter"?"start":"end";return s[1][l]}const pk={name:"tasklistCheck",tokenize:gk};function mk(){return{text:{91:pk}}}function gk(t,r,s){const l=this;return d;function d(c){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?s(c):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),m)}function m(c){return mt(c)?(t.enter("taskListCheckValueUnchecked"),t.consume(c),t.exit("taskListCheckValueUnchecked"),f):c===88||c===120?(t.enter("taskListCheckValueChecked"),t.consume(c),t.exit("taskListCheckValueChecked"),f):s(c)}function f(c){return c===93?(t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),o):s(c)}function o(c){return Le(c)?r(c):Ye(c)?t.check({tokenize:_k},r,s)(c):s(c)}}function _k(t,r,s){return tt(t,l,"whitespace");function l(d){return d===null?s(d):r(d)}}function vk(t){return F_([qE(),ZE(),lk(t),hk(),mk()])}const yk={};function Ov(t){const r=this,s=t||yk,l=r.data(),d=l.micromarkExtensions||(l.micromarkExtensions=[]),m=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),f=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);d.push(vk(s)),m.push(IE()),f.push(UE(s))}const Bv=1e3,Ks=new Map;let ol;function Sk(t,r,s){const l=Symbol(t),d=Math.max(Bv,s.intervalMs),m=Date.now();return Ks.set(t,{id:t,intervalMs:d,nextRunAt:s.runImmediately===!1?m+d:m,inFlight:!1,run:r,token:l}),bk(),jv(),()=>{const f=Ks.get(t);(f==null?void 0:f.token)===l&&(Ks.delete(t),Ks.size===0&&ol!==void 0&&(window.clearInterval(ol),ol=void 0))}}function bk(){ol!==void 0||typeof window>"u"||(ol=window.setInterval(()=>{jv()},Bv))}async function jv(){const t=Date.now();for(const r of Ks.values())r.inFlight||r.nextRunAt>t||Ck(r)}async function Ck(t){t.inFlight=!0;try{await t.run()}catch{}finally{const r=Ks.get(t.id);(r==null?void 0:r.token)===t.token&&(r.inFlight=!1,r.nextRunAt=Date.now()+r.intervalMs)}}function pl(t,r,s){const l=ee.useRef(r);ee.useEffect(()=>{l.current=r},[r]),ee.useEffect(()=>{if(!(!t||s.enabled===!1))return Sk(t,()=>l.current(),{intervalMs:s.intervalMs,runImmediately:s.runImmediately})},[t,s.enabled,s.intervalMs,s.runImmediately])}const Fo=`
|
|
91
91
|
|
|
92
92
|
--- Translation ---
|
|
93
|
-
`;function wk({active:t=!0,autoSendEnabled:r,targetLanguage:s,taskSlug:l,role:d,sessionId:m,panelState:f,onClearSession:o,onEntry:c,onFailures:u}){const[g,h]=ee.useState(""),[S,x]=ee.useState(""),[T,E]=ee.useState(!1),[y,_]=ee.useState(Date.now()),[v,b]=ee.useState(!1),[,k]=qi(""),L=ee.useRef(null),R=f.entries,D=f.failures,A=f.status;ee.useEffect(()=>{if(!t)return;const N=L.current;if(!N)return;const q=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight});return()=>window.cancelAnimationFrame(q)},[t,R]);const M=Mk(R);ee.useEffect(()=>{if(!M)return;_(Date.now());const N=window.setInterval(()=>_(Date.now()),250);return()=>window.clearInterval(N)},[M]);async function O(N=!1){const q=g;b(!0),k(""),E(!1);try{const I=await ye.translateUserInput(l,d,{text:q,mode:N?"auto-send":"review-before-send",useContext:!1,send:N});I.sent?(h(""),E(!1)):(h(Hv(q,I.englishPreview)),E(!0))}catch(I){k(ft("Translate composer input",I))}finally{b(!1)}}async function H(){const N=S.trim();if(N){b(!0),k("");try{const q=await ye.translateManualOutput(l,d,{text:N});c(m,d,q),x("")}catch(q){k(ft("Translate pasted English output",q))}finally{b(!1)}}}async function U(){b(!0),k("");try{const N=await ye.translateLatestReply(l,d);c(m,d,N)}catch(N){k(ft("Translate final reply",N))}finally{b(!1)}}async function P(){const N=T?t_(g):g;if(N.trim()){b(!0),k("");try{await ye.sendTranslatedInput(l,d,{englishText:N}),h(""),E(!1)}catch(q){k(ft("Send translated English input to role",q))}finally{b(!1)}}}function W(N){N.key!=="Enter"||N.shiftKey||N.nativeEvent.isComposing||(N.preventDefault(),!v&&g.trim()&&(T?P():O(r)))}async function K(){o(m,d),await ye.clearTranslationSession(m).catch(N=>k(ft("Clear conversation translation panel",N)))}async function V(){b(!0),k("");try{const N=await ye.ignoreTranslationFailures(m);u(m,d,N.failures)}catch(N){k(ft("Ignore failed conversation translations",N))}finally{b(!1)}}async function Y(N){b(!0),k("");try{const q=await ye.retryTranslation(m,N.translationId);c(m,d,q)}catch(q){k(ft("Retry latest failed conversation translation",q))}finally{b(!1)}}const te=Lk(R,A,y),z=D.length,j=Ek(D);return C.jsxs("aside",{className:"translation-panel",children:[C.jsxs("header",{className:"translation-panel-header",children:[C.jsxs("div",{className:"translation-panel-titlebar",children:[C.jsx("h2",{children:"Translation"}),C.jsxs("div",{className:"translation-panel-actions",children:[z>0?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",disabled:v,onClick:()=>void V(),children:["Ignore ",z]}),j?C.jsx("button",{type:"button",disabled:v,onClick:()=>void Y(j),children:"Retry latest"}):null]}):null,C.jsx("button",{type:"button",disabled:v,onClick:()=>void U(),children:"Translate final reply"}),C.jsx("button",{type:"button",onClick:()=>void K(),children:"Clear"})]})]}),C.jsx("div",{className:"translation-status-row",children:C.jsxs("p",{children:["Claude Code · target ",xk(s)," · ",te]})})]}),C.jsx("div",{className:"translation-manual-panel",children:C.jsxs("div",{className:"translation-composer-row translation-manual-row",children:[C.jsx("textarea",{value:S,onChange:N=>x(N.target.value),placeholder:"Paste English to translate on demand..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:v||!S.trim(),onClick:()=>void H(),children:"Translate"})})]})}),C.jsxs("div",{className:"translation-entry-list",ref:L,children:[R.length===0?C.jsx("p",{className:"muted",children:"Translated Claude Code output will appear here."}):null,R.map(N=>C.jsx(Rk,{entry:N},N.id))]}),C.jsx("div",{className:"translation-composer",children:C.jsxs("div",{className:"translation-composer-row",children:[C.jsx("textarea",{value:g,onChange:N=>{h(N.target.value),(!N.target.value.trim()||T&&!jk(N.target.value))&&E(!1)},onKeyDown:W,placeholder:"输入中文,先翻译成英文工程指令..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:v||!T||!t_(g).trim(),onClick:()=>void P(),children:"Send English"})})]})})]})}function xk(t){var r;return((r=b_.find(s=>s.value===t))==null?void 0:r.label)??t}function Ek(t){let r,s=Number.NEGATIVE_INFINITY;for(const l of t){const d=Date.parse(l.failedAt),m=Number.isFinite(d)?d:Number.NEGATIVE_INFINITY;(!r||m>=s)&&(r=l,s=m)}return r}function kk({open:t,taskSlug:r,targetLanguage:s,onClose:l}){const[d,m]=ee.useState(!1),[,f]=qi(""),[o,c]=ee.useState(null),[u,g]=ee.useState(""),[h,S]=ee.useState(""),[x,T]=ee.useState(""),[E,y]=ee.useState(!1),[_,v]=ee.useState(null),[b,k]=ee.useState(""),[L,R]=ee.useState(""),[D,A]=ee.useState(""),[M,O]=ee.useState(!1);pl(t?`file-translation:${u||"none"}`:null,()=>H(!0),{intervalMs:2e3,runImmediately:!0});async function H(V=!1){try{const Y=await ye.getTranslationState();c(Y);const te=u?Y.fileIndex.jobs.some(z=>z.id===u):!1;if((!u||!te)&&Y.fileIndex.jobs[0])U(Y.fileIndex.jobs[0].id);else if(!Y.fileIndex.jobs[0])g(""),S(""),T("");else if(V&&u){const z=await ye.readFileTranslation(u);S(z.output),T(z.report)}}catch(Y){f(ft("Load file translation list",Y))}}async function U(V){g(V),S(""),T("");try{const Y=await ye.readFileTranslation(V);S(Y.output),T(Y.report)}catch(Y){f(ft(`Read translated file ${V}`,Y))}}async function P(){y(!0),await W(b,L)}async function W(V="",Y=""){O(!0),f("");try{const te=await ye.browseTranslationSourceFiles({path:V,query:Y,limit:250});v(te),k(te.currentPath),R(Y)}catch(te){f(ft("Browse translation source files",te))}finally{O(!1)}}async function K(V=D){const Y=V.trim();if(Y){m(!0),f("");try{if(!r)throw new Error("Create or select a task before translating files.");const te=await ye.createFileTranslation({taskSlug:r,sourcePath:Y,targetLanguage:s});y(!1),await H(),await U(te.id)}catch(te){f(ft(`Create file translation for ${Y}`,te))}finally{m(!1)}}}return t?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"modal-backdrop file-translation-backdrop",children:C.jsx(Tk,{busy:d,state:o,selectedJobId:u,output:h,report:x,onClose:()=>{y(!1),l()},onRefresh:()=>void H(),onSelectJob:V=>void U(V),onTranslate:()=>void P()})}),E?C.jsx(Ak,{busy:d||M,state:_,currentPath:b,query:L,selectedPath:D,onBrowse:(V,Y)=>void W(V,Y),onClose:()=>y(!1),onQueryChange:R,onSelectPath:A,onTranslate:()=>void K()}):null]}):null}function Ak({busy:t,state:r,currentPath:s,query:l,selectedPath:d,onBrowse:m,onClose:f,onQueryChange:o,onSelectPath:c,onTranslate:u}){const g=(r==null?void 0:r.entries)??[],h=g.filter(x=>x.type==="directory"),S=g.filter(x=>x.type==="file");return C.jsx("div",{className:"modal-backdrop translation-file-browser-backdrop",children:C.jsxs("section",{className:"translation-file-browser-modal",role:"dialog","aria-modal":"true","aria-label":"Select Source File",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Select Source File"}),C.jsx("p",{children:s||"."})]}),C.jsx("button",{type:"button",onClick:f,children:"Close"})]}),C.jsxs("div",{className:"translation-file-browser-controls",children:[C.jsxs("div",{className:"translation-file-browser-nav",children:[C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m((r==null?void 0:r.parentPath)??"",""),children:"Up"}),C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m("",""),children:"Root"})]}),C.jsxs("form",{className:"translation-file-browser-search",onSubmit:x=>{x.preventDefault(),m(s,l)},children:[C.jsx("input",{value:l,onChange:x=>o(x.target.value),placeholder:"Search files"}),C.jsx("button",{type:"submit",disabled:t,children:"Search"}),C.jsx("button",{type:"button",disabled:t||!l,onClick:()=>m(s,""),children:"Clear"})]})]}),C.jsxs("div",{className:"translation-file-browser-layout",children:[C.jsxs("div",{className:"translation-file-browser-list",children:[t&&!r?C.jsx("p",{className:"muted",children:"Loading files..."}):null,!t&&g.length===0?C.jsx("p",{className:"muted",children:"No source files found."}):null,h.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Folders"}),h.map(x=>C.jsx(e_,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,S.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Files"}),S.map(x=>C.jsx(e_,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,r!=null&&r.truncated?C.jsx("p",{className:"translation-entry-note",children:"Result limit reached."}):null]}),C.jsxs("aside",{className:"translation-file-browser-selection",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Source path"}),C.jsx("input",{value:d,onChange:x=>c(x.target.value)})]}),C.jsx("button",{type:"button",disabled:t||!d.trim(),onClick:u,children:"Translate File"})]})]})]})})}function e_({entry:t,selected:r,onBrowse:s,onSelectPath:l}){const d=t.type==="directory";return C.jsxs("button",{className:r?"translation-file-browser-entry is-selected":"translation-file-browser-entry",type:"button",onClick:()=>d?s(t.path,""):l(t.path),onDoubleClick:()=>d?s(t.path,""):void 0,children:[C.jsx("span",{children:d?"DIR":"FILE"}),C.jsx("strong",{children:t.name}),C.jsx("small",{children:t.path})]})}function Tk({busy:t,state:r,selectedJobId:s,output:l,report:d,onClose:m,onRefresh:f,onSelectJob:o,onTranslate:c}){const u=(r==null?void 0:r.fileIndex.jobs)??[],g=u.find(h=>h.id===s);return C.jsxs("section",{className:"file-translation-modal",role:"dialog","aria-modal":"true","aria-label":"File Translation",children:[C.jsxs("header",{className:"file-translation-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"File Translation"}),C.jsx("p",{children:"Claude Code · 中英互译"})]}),C.jsxs("div",{className:"file-translation-toolbar",children:[C.jsx("button",{type:"button",disabled:t,onClick:c,children:"Translate"}),C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Refresh"}),C.jsx("button",{type:"button",onClick:m,children:"Close"})]})]}),r!=null&&r.memoryInitialized?null:C.jsx("p",{className:"translation-entry-note",children:"Translation memory is not initialized. Run Bootstrap from the sidebar before important file translations."}),C.jsxs("div",{className:"file-translation-layout",children:[C.jsxs("div",{className:"file-translation-list",children:[u.length===0?C.jsx("p",{className:"muted",children:"No translated files yet."}):null,u.map(h=>C.jsxs("button",{className:h.id===s?"file-translation-item is-active":"file-translation-item",type:"button",onClick:()=>o(h.id),children:[C.jsx("strong",{children:h.sourcePath}),C.jsxs("span",{children:[h.status," · ",h.targetLanguage]})]},h.id))]}),C.jsx("div",{className:"file-translation-preview",children:g?C.jsxs(C.Fragment,{children:[C.jsxs("header",{children:[C.jsx("strong",{children:g.sourcePath}),C.jsx("span",{children:g.status})]}),C.jsx("div",{className:"translation-markdown",children:C.jsx(cv,{remarkPlugins:[Ov],children:l||d||"Translation output is not available yet."})})]}):C.jsx("p",{className:"muted",children:"Select a translated file to preview it."})})]})]})}function Rk({entry:t}){if(t.sourceKind==="conversation-boundary")return C.jsx(Dk,{entry:t});const r=Bk(t),s=t.sourceKind==="tool-output",l=t.direction==="user-input-to-english",d=["translation-entry",`is-${t.sourceKind}`,l?"is-user-input":""].filter(Boolean).join(" ");return C.jsxs("article",{className:d,children:[s?C.jsx("pre",{children:r}):C.jsx("div",{className:"translation-markdown",children:C.jsx(cv,{remarkPlugins:[Ov],children:r})}),t.warning?C.jsx("p",{className:"translation-entry-note",children:t.warning}):null,t.error?C.jsx("p",{className:"translation-entry-note is-error",children:t.error}):null]})}function Dk({entry:t}){const r=t.boundaryKind==="end"?"结束":"开始",s=t.conversationTurn??0,l=Hk(t.occurredAt??t.createdAt);return C.jsxs("div",{className:"translation-conversation-boundary","aria-label":`${r} 第 ${s} 轮 ${l}`,children:[C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"}),C.jsx("span",{children:r}),C.jsxs("span",{children:["第 ",s," 轮"]}),C.jsx("time",{children:l}),C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"})]})}function Mk(t){const r=t.find(Nv);return(r==null?void 0:r.translationStartedAt)??(r==null?void 0:r.createdAt)}function Lk(t,r,s){const l=t.find(Nv);if(l)return`translating ${Nk(Math.max(0,s-Ok(l)))}`;const d=t.at(-1);return(d==null?void 0:d.status)==="failed"||r==="failed"?"error":r}function Nv(t){return t.status==="queued"||t.status==="translating"}function Ok(t){const r=Date.parse(t.translationStartedAt??t.createdAt);return Number.isFinite(r)?r:Date.now()}function Bk(t){return t.status==="queued"||t.status==="translating"?t.sourceText:t.status==="translated"?t.direction==="user-input-to-english"?Hv(t.sourceText,t.translatedText):t.translatedText:t.translatedText||t.sourceText}function Hv(t,r){return`${t.trimEnd()}${Fo}${r.trimStart()}`}function jk(t){return t.includes(Fo)}function t_(t){const r=t.indexOf(Fo);return r===-1?t:t.slice(r+Fo.length)}function Nk(t){if(t<1e3)return`${Math.max(.1,t/1e3).toFixed(1)}s`;const r=t/1e3;if(r<60)return`${r.toFixed(1)}s`;const s=Math.floor(r/60),l=Math.floor(r%60).toString().padStart(2,"0");return`${s}:${l}`}function Hk(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleTimeString()}const zk=8;function Ik(){const[t,r]=ee.useState([]);return ee.useEffect(()=>{const s=m=>{var c,u;const f=(u=(c=m.detail)==null?void 0:c.message)==null?void 0:u.trim();if(!f)return;const o=new Date().toISOString();r(g=>{const h=g.find(S=>S.message===f);return h?[{...h,count:h.count+1,updatedAt:o},...g.filter(S=>S.id!==h.id)]:[{id:`ui_error_${Date.now()}_${Math.random().toString(16).slice(2)}`,message:f,count:1,createdAt:o,updatedAt:o},...g].slice(0,zk)})},l=m=>{var o;const f=((o=m.detail)==null?void 0:o.actions)??[];f.length!==0&&r(c=>c.filter(u=>!f.some(g=>u.message.startsWith(`${g} failed.`))))},d=m=>{var o,c;const f=(c=(o=m.detail)==null?void 0:o.message)==null?void 0:c.trim();f&&r(u=>u.filter(g=>g.message!==f))};return window.addEventListener(Ah,s),window.addEventListener(Th,l),window.addEventListener(Rh,d),()=>{window.removeEventListener(Ah,s),window.removeEventListener(Th,l),window.removeEventListener(Rh,d)}},[]),t.length===0?null:C.jsxs("aside",{className:"ui-error-center",role:"alert","aria-live":"polite","aria-label":"Application errors",children:[C.jsxs("header",{className:"ui-error-center-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Errors"}),C.jsxs("p",{children:[t.length," active"]})]}),C.jsx("button",{type:"button",onClick:()=>r([]),children:"Clear"})]}),C.jsx("ol",{className:"ui-error-list",children:t.map(s=>C.jsxs("li",{children:[C.jsxs("div",{children:[C.jsx("p",{children:s.message}),C.jsxs("span",{children:[Uk(s.updatedAt),s.count>1?` · repeated ${s.count} times`:""]})]}),C.jsx("button",{type:"button","aria-label":"Dismiss error",onClick:()=>r(l=>l.filter(d=>d.id!==s.id)),children:"Close"})]},s.id))})]})}function Uk(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Pk(t,r){return t.find(s=>s.taskSlug===r)??t[0]??null}function Fk(t){if(!(t.mode!=="auto"||t.status!=="running")&&!(!t.activeRole||t.activeRole===t.lastFollowedRole))return t.activeRole}function qk(t,r){var d;if(!((d=t.flowPause)!=null&&d.paused))return null;const s=t.flowPause.role??t.activeRole??"role",l=t.roleRecovery;return t.flowPause.reason==="role-recovery-failed"&&l?r(l,s):t.flowPause.message??`No new turn started after ${s} stopped.`}function $k(t){const r=t.roundId??t.startedAt??t.taskSlug,s=t.stoppedAt??t.lastTurnEndedAt??"stopped";return`${r}:${s}`}function Gk(t,r,s){if((r==null?void 0:r.status)==="running")return!0;const l=Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return!!(s&&Number.isFinite(l)&&l>s)}function Vk(t){return t?"strong":"none"}function Wk(t,r){if(!r)return{observation:t,dismissPauseAlert:!1};const s=r.lastGatewayInputMessageId??null;return t.initialized?{observation:{initialized:!0,messageId:s},dismissPauseAlert:!!(r.enabled&&s&&s!==t.messageId)}:{observation:{initialized:!0,messageId:s},dismissPauseAlert:!1}}const Kk=3,Yk=3e4,No=new Map;function zv(t,r){const s=ft(t,r);if(!Xk(r))return No.set(t,{consecutiveFailures:1,lastMessage:s,lastReportedAt:Date.now()}),s;const l=No.get(t),d=((l==null?void 0:l.consecutiveFailures)??0)+1,m=Date.now(),f=d>=Kk&&(!l||l.lastMessage!==s||m-l.lastReportedAt>=Yk);return No.set(t,{consecutiveFailures:d,lastMessage:s,lastReportedAt:f?m:(l==null?void 0:l.lastReportedAt)??0}),f?s:null}function qo(t){No.delete(t),xS([t])}function Xk(t){const r=ml(t);return r.includes("could not reach the VCM backend")||r.includes("Failed to fetch")||r.includes("NetworkError")||r.includes("Load failed")||r.includes("ERR_CONNECTION")}const Qk=["architecture-plan","validation-adequacy","code-diff"];function Jk({events:t,maxEvents:r=8,showHeader:s=!0}){const l=r===null?t:t.slice(-r);return C.jsxs("section",{className:"event-log",children:[s?C.jsx("h2",{children:"Events"}):null,t.length===0?C.jsx("p",{className:"muted",children:"No terminal events yet."}):C.jsx("ol",{children:l.map((d,m)=>C.jsx("li",{children:d},`${d}-${m}`))})]})}function Rn({checked:t,className:r,disabled:s,label:l,stateLabel:d,title:m,onChange:f}){const o=["switch-control",t?"is-on":"is-off",r].filter(Boolean).join(" "),c=d??(t?"on":"off");return C.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":`${l}: ${c}`,className:o,disabled:s,title:m,onClick:()=>f(!t),children:[C.jsx("span",{className:"switch-control-label",children:l}),C.jsx("span",{className:"switch-control-track","aria-hidden":"true",children:C.jsx("span",{className:"switch-control-thumb"})})]})}const Eh={evidence:"Evidence",scaffold:"Scaffold",validation:"Validation"};function Zk({status:t,bootstrapStatus:r,applyResult:s,hasActiveTask:l=!1,autoTaskHarnessReviewEnabled:d,autoMemoryEnabled:m,architectWorkerSettings:f,launchOptions:o,modelOptions:c,busy:u=!1,onRefresh:g,onApply:h,onOpenStudio:S,onOpenRepositoryDiff:x,onAutoTaskHarnessReviewChange:T,onAutoMemoryChange:E,onArchitectWorkerSettingsChange:y,onLaunchOptionsChange:_,onStartBootstrap:v,onRestartBootstrap:b,onStopBootstrap:k,onRunBootstrap:L}){const[R,D]=ee.useState(!1),A=r==null?void 0:r.session,M=(r==null?void 0:r.status)==="running",O=(A==null?void 0:A.status)==="running",H=(r==null?void 0:r.status)!=="complete";return l?t?C.jsxs("section",{className:"harness-panel",children:[C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Fixed install"}),C.jsx("p",{className:"muted",children:t.initialized?t.needsApply?`${t.plannedChanges.length} pending updates`:"Up to date":"Not initialized"})]}),C.jsx("div",{className:"harness-actions",children:t.initialized?C.jsxs(C.Fragment,{children:[C.jsx("button",{type:"button",disabled:u,onClick:()=>void g(),children:"Refresh"}),t.needsApply?C.jsx("button",{type:"button",disabled:u,onClick:()=>void h(),children:"Update"}):null]}):C.jsx("button",{type:"button",disabled:u,onClick:()=>void h(),children:"Initialize"})})]}),t.initialized&&t.needsApply?C.jsxs(C.Fragment,{children:[C.jsx("h3",{className:"harness-file-list-title",children:"Files to update"}),C.jsx("ol",{className:"harness-file-list",children:t.plannedChanges.map(U=>C.jsxs("li",{children:[C.jsx("span",{children:U.path}),C.jsx($n,{status:U.action})]},`${U.path}:${U.action}`))})]}):null]}),C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsx("div",{children:C.jsx("strong",{children:"Harness Studio"})}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:u,onClick:S,children:"Open Studio"})})]}),C.jsx("button",{className:"harness-review-diff-button",type:"button",disabled:u,onClick:x,children:"Review Diff"}),C.jsx(Rn,{checked:d,className:"sidebar-switch",disabled:u,label:"Auto task harness review",title:"Automatically ask Harness Engineer to review task harness after final acceptance completes",onChange:T}),C.jsx(Rn,{checked:m,className:"sidebar-switch",disabled:u,label:"Auto memory",title:"Collect role memory drafts after Final Acceptance and let Harness Engineer apply reviewed memory",onChange:E}),C.jsxs("div",{className:"architect-worker-settings",title:"Model and effort for Architect workers. Apply the harness to write changes into worker definitions.",children:[C.jsx("strong",{children:"Architect workers"}),oS.map(U=>C.jsxs("div",{className:"architect-worker-setting",children:[C.jsx("span",{children:Eh[U]}),C.jsx("select",{"aria-label":`${Eh[U]} worker model`,disabled:u,value:f[U].model,onChange:P=>y({...f,[U]:{...f[U],model:P.target.value}}),children:cS.map(P=>C.jsx("option",{value:P,children:P},P))}),C.jsx("select",{"aria-label":`${Eh[U]} worker effort`,disabled:u,value:f[U].effort,onChange:P=>y({...f,[U]:{...f[U],effort:P.target.value}}),children:uS.map(P=>C.jsx("option",{value:P,children:P},P))})]},U))]})]}),H?C.jsx("div",{className:"harness-stage",children:C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Bootstrap"}),C.jsx("p",{className:"muted",children:r?e2(r.status):"not loaded"})]}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:u||!(r!=null&&r.canStart),onClick:()=>{D(!0)},children:"Open Bootstrap"})})]})}):null,s!=null&&s.changedFiles.length?C.jsx("div",{className:"harness-result",children:C.jsx("p",{className:"muted",children:s.message})}):null,t.warnings.length>0?C.jsx("ul",{className:"warnings",children:t.warnings.map(U=>C.jsx("li",{children:U},U))}):null,r!=null&&r.warnings.length?C.jsx("ul",{className:"warnings",children:r.warnings.map(U=>C.jsx("li",{children:U},U))}):null,H&&R?C.jsx("div",{className:"harness-bootstrap-modal",role:"dialog","aria-modal":"true","aria-label":"Harness Engineer bootstrap session",children:C.jsxs("div",{className:"harness-bootstrap-modal-surface",children:[C.jsxs("header",{className:"harness-bootstrap-modal-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Harness Engineer Bootstrap"}),C.jsx("p",{className:"muted",children:(A==null?void 0:A.command)??"Start Harness Engineer, then run bootstrap when ready."})]}),C.jsxs("div",{className:"harness-bootstrap-modal-actions",children:[A?C.jsx($n,{status:A.status}):null,C.jsx("button",{type:"button",onClick:()=>D(!1),children:"Close"})]})]}),C.jsxs("div",{className:"harness-bootstrap-controls",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Permission"}),C.jsx("select",{value:o.permissionMode,disabled:u||M||O,onChange:U=>_({...o,permissionMode:U.target.value}),children:C_.map(U=>C.jsx("option",{value:U.value,children:U.label},U.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Model"}),C.jsx("select",{value:o.model,title:(()=>{const U=c.find(P=>P.value===o.model);return U!=null&&U.available?U.description:U==null?void 0:U.unavailableReason})(),disabled:u||M||O,onChange:U=>_({...o,model:U.target.value}),children:c.map(U=>C.jsx("option",{value:U.value,disabled:!U.available,title:U.available?U.description:U.unavailableReason,children:U.label},U.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Effort"}),C.jsx("select",{value:o.effort,disabled:u||M||O,onChange:U=>_({...o,effort:U.target.value}),children:x_.map(U=>C.jsx("option",{value:U.value,children:U.label},U.value))})]}),C.jsxs("div",{className:"harness-bootstrap-control-actions",children:[C.jsx("button",{type:"button",disabled:u||M||!(r!=null&&r.canStart),onClick:()=>void v(o),children:"Start"}),C.jsx("button",{type:"button",disabled:u||M||!(r!=null&&r.canStart),onClick:()=>void b(o),children:"Restart"}),C.jsx("button",{type:"button",disabled:u||!A,onClick:()=>void k(),children:"Stop"}),C.jsx("button",{type:"button",disabled:u||M||!O,onClick:()=>void L(),children:"Run bootstrap"})]})]}),C.jsx("div",{className:"harness-bootstrap-terminal",children:O?C.jsx(Vo,{sessionId:A.id,active:R}):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:"Harness Bootstrap"}),C.jsx("span",{children:"Start Harness Engineer first. When it is ready, click Run bootstrap to send the prompt."})]})})]})}):null]}):null:C.jsx("section",{className:"harness-panel",children:C.jsxs("div",{className:"harness-result",children:[C.jsx("strong",{children:"Task required"}),C.jsx("p",{className:"muted",children:"Create or select a task before changing VCM Harness. Harness changes are committed in the active task worktree."})]})})}function e2(t){return t.replaceAll("_"," ")}function ff(t){return{total:t.length,accepted:t.filter(r=>r.acceptedAt).length,delivered:t.filter(r=>r.deliveredAt).length}}function t2(t,r=6){const s=[...t].sort(r2).map((d,m)=>({message:d,sequence:m+1}));return[...r===null?s:s.slice(-r)].sort((d,m)=>m.sequence-d.sequence)}function n2({messages:t,orchestration:r,busy:s,maxMessages:l=6,showControls:d=!0,showHeader:m=!0,onModeChange:f,onMarkAllDone:o}){const[c,u]=ee.useState(null),g=ff(t),h=(r==null?void 0:r.mode)??"auto",S=t2(t,l);async function x(T){await s2(T.body),u(T.id),window.setTimeout(()=>u(E=>E===T.id?null:E),1200)}return C.jsxs("section",{className:"message-panel",children:[m?C.jsxs("div",{className:"message-panel-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[g.total," total / ",g.accepted," accepted"]})]}),d&&f?C.jsx("div",{className:"message-controls",children:C.jsx(Rn,{checked:h==="auto",className:"message-mode-toggle",disabled:s,label:"Auto orchestration",onChange:T=>f(T?"auto":"manual")})}):null,d&&o?C.jsx("button",{type:"button",disabled:s,onClick:o,children:"Mark All Done"}):null]}):null,t.length===0?C.jsx("p",{className:"muted",children:"No role messages yet."}):C.jsx("ol",{className:"message-list",children:S.map(({message:T,sequence:E})=>C.jsxs("li",{className:"message-item",children:[C.jsxs("div",{className:"message-item-main",children:[C.jsxs("div",{className:"message-meta",children:[C.jsxs("span",{className:"message-sequence",children:["#",E]}),C.jsx("time",{dateTime:$o(T),children:i2($o(T))}),C.jsxs("strong",{children:[T.fromRole," ","->"," ",T.toRole]}),C.jsx("span",{children:T.type})]}),C.jsx("p",{children:T.body}),T.failureReason?C.jsx("span",{className:"message-reason",children:T.failureReason}):null,T.bodyPath?C.jsx("span",{className:"message-path",children:T.bodyPath}):null]}),C.jsx("div",{className:"message-actions",children:C.jsx("button",{type:"button",disabled:s,onClick:()=>void x(T),children:c===T.id?"Copied":"Copy"})})]},T.id))})]})}function i2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function $o(t){return t.acceptedAt??t.deliveredAt??t.dispatchingAt??t.createdAt}function r2(t,r){const s=$o(t).localeCompare($o(r));if(s!==0)return s;const l=t.createdAt.localeCompare(r.createdAt);return l!==0?l:t.id.localeCompare(r.id)}async function s2(t){var s;if((s=navigator.clipboard)!=null&&s.writeText){await navigator.clipboard.writeText(t);return}const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),r.remove()}function a2({defaultPath:t="",recentPaths:r=[],busy:s=!1,onConnect:l}){const[d,m]=ee.useState(t);ee.useEffect(()=>{t&&m(t)},[t]);async function f(o){o.preventDefault(),await l(d)}return C.jsx("form",{className:"repo-connect",onSubmit:f,children:C.jsxs("div",{className:r.length>0?"inline-form has-recent-paths":"inline-form",children:[C.jsx("input",{"aria-label":"Repository path",id:"repo-path",value:d,onChange:o=>m(o.target.value),placeholder:"/path/to/repo"}),r.length>0?C.jsxs("select",{"aria-label":"Recent repositories",className:"repo-recent-select",value:"",onChange:o=>{o.target.value&&m(o.target.value)},children:[C.jsx("option",{value:"",children:"Recent"}),r.map(o=>C.jsx("option",{value:o,children:o},o))]}):null,C.jsx("button",{type:"submit",disabled:s||!d.trim(),children:"Connect"})]})})}function l2({tasks:t,activeTaskSlug:r,onSelect:s}){return C.jsx("nav",{className:"task-nav","aria-label":"Tasks",children:t.map(l=>C.jsxs("button",{className:l.taskSlug===r?"task-nav-item is-active":"task-nav-item",type:"button",onClick:()=>s(l.taskSlug),children:[C.jsx("span",{children:l.title||l.taskSlug}),C.jsx($n,{status:l.status})]},l.taskSlug))})}function o2({open:t,taskSlug:r,taskTitle:s,onClose:l}){const[d,m]=ee.useState(null),[f,o]=ee.useState(!1),[c,u]=ee.useState(null),g=ee.useCallback(async()=>{o(!0),u(null);try{m(await ye.getTaskUsageAnalytics(r))}catch(h){u(`Load task usage analytics failed. Reason: ${ml(h)}`)}finally{o(!1)}},[r]);return ee.useEffect(()=>{t&&g()},[g,t]),t?C.jsx("div",{className:"modal-backdrop usage-analytics-backdrop",children:C.jsxs("section",{className:"usage-analytics-modal",role:"dialog","aria-modal":"true","aria-label":"Usage Analytics",children:[C.jsxs("header",{className:"usage-analytics-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Usage Analytics"}),C.jsxs("p",{children:[(s==null?void 0:s.trim())||r," · Claude models only"]})]}),C.jsxs("div",{className:"usage-analytics-header-actions",children:[C.jsx("button",{type:"button",disabled:f,onClick:()=>void g(),children:f?"Refreshing...":"Refresh"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),c?C.jsx("p",{className:"inline-error usage-analytics-error",children:c}):null,d?C.jsx(c2,{report:d}):C.jsx("div",{className:"usage-analytics-empty",children:f?"Loading usage data...":"No usage data available."})]})}):null}function c2({report:t}){return C.jsxs("div",{className:"usage-analytics-content",children:[C.jsxs("div",{className:"usage-analytics-meta",children:[C.jsx("span",{children:t.updatedAt?`Updated ${h2(t.updatedAt)}`:"No Claude usage recorded yet"}),C.jsxs("span",{children:[mn(t.totals.requestCount)," requests · ",mn(t.totals.sessionCount)," sessions"]})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-task-summary",children:[C.jsx("h3",{id:"usage-task-summary",children:"Task Summary"}),C.jsx(u2,{totals:t.totals})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-role",children:[C.jsx("h3",{id:"usage-by-role",children:"Usage by Role"}),C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(n_,{firstColumn:"Role"})}),C.jsx("tbody",{children:t.byRole.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:lS(r.role).label}),C.jsxs("small",{children:[mn(r.requestCount)," requests · ",mn(r.sessionCount)," sessions"]})]}),C.jsx(i_,{totals:r})]},r.role))})]})})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-model",children:[C.jsx("h3",{id:"usage-by-model",children:"Usage by Model"}),t.byModel.length>0?C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(n_,{firstColumn:"Model"})}),C.jsx("tbody",{children:t.byModel.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:r.model}),C.jsxs("small",{children:[mn(r.requestCount)," requests · ",mn(r.sessionCount)," sessions"]})]}),C.jsx(i_,{totals:r})]},r.model))})]})}):C.jsx("p",{className:"usage-analytics-no-models",children:"No Claude model usage recorded yet."})]})]})}function u2({totals:t}){return C.jsxs("dl",{className:"usage-totals-grid",children:[C.jsx(il,{label:"Input Tokens",value:mn(t.inputTokens)}),C.jsx(il,{label:"Output Tokens",value:mn(t.outputTokens)}),C.jsx(il,{label:"Cache Read",value:mn(t.cacheReadTokens)}),C.jsx(il,{label:"Cache Creation",value:mn(t.cacheCreationTokens)}),C.jsx(il,{label:"Estimated Cost",value:Iv(t.costUsd)})]})}function il({label:t,value:r}){return C.jsxs("div",{children:[C.jsx("dt",{children:t}),C.jsx("dd",{children:r})]})}function n_({firstColumn:t}){return C.jsxs("tr",{children:[C.jsx("th",{scope:"col",children:t}),C.jsx("th",{scope:"col",children:"Input"}),C.jsx("th",{scope:"col",children:"Output"}),C.jsx("th",{scope:"col",children:"Cache Read"}),C.jsx("th",{scope:"col",children:"Cache Creation"}),C.jsx("th",{scope:"col",children:"Estimated Cost"})]})}function i_({totals:t}){return C.jsxs(C.Fragment,{children:[C.jsx("td",{children:mn(t.inputTokens)}),C.jsx("td",{children:mn(t.outputTokens)}),C.jsx("td",{children:mn(t.cacheReadTokens)}),C.jsx("td",{children:mn(t.cacheCreationTokens)}),C.jsx("td",{children:Iv(t.costUsd)})]})}function mn(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function Iv(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(t)}function h2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f2({project:t,recentRepositoryPaths:r,tasks:s,activeTaskSlug:l,messages:d,orchestration:m,events:f,roundState:o,gateReview:c,workflowControlState:u,translationEnabled:g,translationAutoSendEnabled:h,translationTargetLanguage:S,translationOutputMode:x,translationMemoryInitialized:T,translatorSession:E,harnessStatus:y,harnessBootstrapStatus:_,harnessApplyResult:v,harnessEngineerLaunchOptions:b,autoTaskHarnessReviewEnabled:k,autoMemoryEnabled:L,architectWorkerSettings:R,gatewayStatus:D,gatewayQrLogin:A,gatewayQrCheck:M,gatewayLarkRegistration:O,gatewayLarkRegistrationCheck:H,codexBridgeStatus:U,modelOptions:P,busy:W,onConnect:K,onRefreshConnectedRepository:V,onPullConnectedRepository:Y,onRefreshHarness:te,onApplyHarness:z,onStartHarnessBootstrap:j,onRestartHarnessBootstrap:N,onStopHarnessBootstrap:q,onRunHarnessBootstrap:I,onOpenHarnessStudio:ie,onOpenRepositoryDiff:pe,onAutoTaskHarnessReviewChange:_e,onAutoMemoryChange:Q,onArchitectWorkerSettingsChange:$,onHarnessEngineerLaunchOptionsChange:he,onRefreshGateway:ae,onGatewayEnabledChange:Ce,onGatewaySettingsChange:be,onCodexBridgeSettingsChange:Oe,onCodexBridgeCheck:Ie,onGatewayTranslationChange:Ue,onGatewayConnectionChange:Ee,onStartGatewayQrLogin:ce,onStartGatewayLarkRegistration:He,onResetGatewayBinding:xt,onGateReviewGateEnabledChange:ge,onCancelGateReviewGate:je,onTranslationEnabledChange:Fe,onTranslationAutoSendChange:dt,onTranslationTargetLanguageChange:rt,onTranslationOutputModeChange:Et,onOpenFileTranslation:fe,onOpenTranslatorSession:we,onCreateTranslationBootstrap:Te,onUpdateTranslationMemory:Ne,onCreateTask:Pe,onCloseTask:St,onSelectTask:Ve,themeMode:bt,onAutoOrchestrationChange:Ct,onThemeModeChange:Nt,pauseAlertSound:Ze,onPauseAlertSoundChange:_n,roleRetryEnabled:en,onRoleRetryEnabledChange:ss,permissionRequestMode:Gi,onPermissionRequestModeChange:Dn,launchTemplate:mi,canSaveLaunchTemplate:vn,canOneClickStart:Vi,onSaveLaunchTemplate:ei,onOneClickStart:ta,onMarkAllMessagesDone:Tr,onConfirmDeliveredDispatch:Rr,onDeleteMessageHistory:Gn}){var Wi;const[ti,tn]=ee.useState(""),[gi,_i]=ee.useState(!1),[ni,ii]=ee.useState(!1),[vi,yi]=ee.useState(!1),[zt,st]=ee.useState(()=>l?null:"repository"),kt=ff(d),It=ti.trim(),Vn=_2(t,l,y),ri=s.filter(Me=>Me.cleanupStatus!=="cleaned"),qt=ri.find(Me=>Me.taskSlug===l)??null;ee.useEffect(()=>{st(Me=>!l&&Me===null?t?"task":"repository":Me)},[l,t]);function nn(Me,ai){st(ai?Me:null)}async function si(Me){Me.preventDefault(),await Pe({taskSlug:It}),tn("")}return C.jsxs("div",{className:"project-dashboard",children:[C.jsx("header",{className:"brand-header",children:C.jsx("strong",{children:"VibeCodingMaster"})}),C.jsx(es,{title:"Repository",open:zt==="repository",onOpenChange:Me=>{nn("repository",Me),Me&&t&&V()},children:C.jsxs("div",{className:"repository-panel",children:[C.jsx(a2,{defaultPath:(t==null?void 0:t.repoRoot)??"",recentPaths:r,busy:W,onConnect:K}),t?C.jsx(b2,{busy:W,project:t,onPull:Y}):null]})}),C.jsx(es,{title:"Settings",open:zt==="settings",onOpenChange:Me=>nn("settings",Me),children:C.jsxs("div",{className:"sidebar-settings",children:[C.jsxs("button",{"aria-label":`Theme mode: ${s_(bt)}`,className:"settings-toggle theme-mode-toggle",disabled:W,title:"Cycle theme: system, light, dark",type:"button",onClick:()=>Nt(k2(bt)),children:[C.jsx("span",{children:"Theme"}),C.jsx("span",{children:s_(bt)})]}),C.jsx(Rn,{checked:((m==null?void 0:m.mode)??"auto")==="auto",className:"sidebar-switch",disabled:W||!l,label:"Auto orchestration",title:l?"Automatically dispatch role messages during the active task":"Create or select a task first",onChange:Ct}),C.jsx(Rn,{checked:Ze,className:"sidebar-switch",disabled:W,label:"Pause alert sound",title:"Play a sound when VCM shows the fixed flow pause dialog",onChange:Me=>_n(Me)}),C.jsx(Rn,{checked:en,className:"sidebar-switch",disabled:W,label:"CC auto retry",title:"Retry temporary Claude Code turn failures before showing the flow pause alert",onChange:Me=>ss(Me)}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Permission requests"}),C.jsxs("select",{value:Gi,disabled:W,onChange:Me=>Dn(Me.target.value),children:[C.jsx("option",{value:"off",children:"off"}),C.jsx("option",{value:"allowAll",children:"allow all"})]})]}),C.jsx(p2,{busy:W,status:U,onCheck:Ie,onSettingsChange:Oe}),C.jsxs("button",{className:"settings-toggle",disabled:W||!vn,title:"Save the current core role launch settings and optional Reviewer settings",type:"button",onClick:ei,children:[C.jsx("span",{children:"Save launch template"}),C.jsx("span",{children:vn?"ready":"open task"})]}),Vi?C.jsxs("button",{className:"settings-toggle is-active",disabled:W,title:d2(mi),type:"button",onClick:ta,children:[C.jsx("span",{children:"One-click start"}),C.jsx("span",{children:Uv(mi)})]}):null,l?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",onClick:()=>_i(!0),children:[C.jsx("span",{children:"Messages"}),C.jsxs("span",{className:"muted",children:[kt.total," total"]})]}),C.jsxs("button",{type:"button",onClick:()=>ii(!0),children:[C.jsx("span",{children:"Events"}),C.jsxs("span",{className:"muted",children:[f.length," total"]})]})]}):null]})}),C.jsx(es,{title:"Translation",open:zt==="translation",onOpenChange:Me=>nn("translation",Me),children:C.jsx(m2,{busy:W,enabled:g,autoSendEnabled:h,targetLanguage:S,outputMode:x,memoryInitialized:T,baseUnavailableReason:Vn,translatorSession:E,onAutoSendChange:dt,onCreateBootstrap:Te,onEnabledChange:Fe,onUpdateMemory:Ne,onTargetLanguageChange:rt,onOutputModeChange:Et,onOpenFileTranslation:fe,onOpenTranslatorSession:we})}),t&&l?C.jsx(es,{title:"Gate Review Gates",open:zt==="gate-review-gates",onOpenChange:Me=>nn("gate-review-gates",Me),children:C.jsx(v2,{busy:W,state:c,onCancelGateReview:je,onGateEnabledChange:ge})}):null,C.jsx(es,{title:"Gateway",open:zt==="gateway",onOpenChange:Me=>{nn("gateway",Me),Me&&ae()},children:C.jsx(S2,{busy:W,qrCheck:M,qrLogin:A,larkRegistration:O,larkRegistrationCheck:H,status:D,onEnabledChange:Ce,onSettingsChange:be,onResetBinding:xt,onStartLarkRegistration:He,onStartQrLogin:ce,onTranslationChange:Ue,onConnectionChange:Ee})}),t?C.jsx(es,{title:"VCM Harness",open:zt==="vcm-harness",onOpenChange:Me=>nn("vcm-harness",Me),children:C.jsx(Zk,{status:y,bootstrapStatus:_,applyResult:v,hasActiveTask:!!qt,autoTaskHarnessReviewEnabled:k,autoMemoryEnabled:L,architectWorkerSettings:R,launchOptions:b,modelOptions:P,busy:W,onRefresh:te,onApply:z,onOpenStudio:ie,onOpenRepositoryDiff:pe,onAutoTaskHarnessReviewChange:_e,onAutoMemoryChange:Q,onArchitectWorkerSettingsChange:$,onLaunchOptionsChange:he,onStartBootstrap:j,onRestartBootstrap:N,onStopBootstrap:q,onRunBootstrap:I})}):null,t?C.jsx(es,{title:"Task",open:zt==="task",onOpenChange:Me=>nn("task",Me),children:ri.length>0?C.jsxs("div",{className:"task-panel",children:[C.jsx(l2,{tasks:ri,activeTaskSlug:l,onSelect:Ve}),qt&&u&&u.warnings.length>0?C.jsxs("div",{className:"warnings",role:"status",children:[u.warnings.map(Me=>C.jsx("p",{children:Me},Me)),((Wi=u.pendingDispatch)==null?void 0:Wi.status)==="dispatching"&&u.pendingDispatch.confirmationError&&u.pendingDispatch.messageId?C.jsx("button",{type:"button",disabled:W,title:"Confirm that this message already executed in the target session without sending it again",onClick:()=>Rr(qt.taskSlug,u.pendingDispatch.messageId),children:"Confirm Executed"}):null]}):null,qt?C.jsxs("div",{className:"task-panel-actions",children:[C.jsx("button",{type:"button",onClick:()=>yi(!0),children:"Usage Analytics"}),C.jsx("button",{className:"danger-button",disabled:W,type:"button",onClick:St,children:"Close Task"})]}):null]}):C.jsx("div",{className:"task-create",children:C.jsxs("form",{onSubmit:si,children:[C.jsx("input",{value:ti,onChange:Me=>tn(Me.target.value),placeholder:"task name"}),C.jsxs("div",{className:"task-create-preview",children:[C.jsxs("small",{children:["branch: ",It?`feature/${It}`:"feature/<task>"]}),C.jsxs("small",{children:["worktree: ",It?`.claude/worktrees/${It}`:".claude/worktrees/<task>"]})]}),C.jsx("button",{type:"submit",disabled:W||!It,children:"Create"})]})})}):null,t&&qt?C.jsx(x2,{task:qt,roundState:o}):null,gi?C.jsx(T2,{busy:W,messages:d,orchestration:m,onClose:()=>_i(!1),onMarkAllDone:()=>{l&&Tr(l)},onDeleteMessageHistory:()=>{l&&Gn(l)}}):null,ni?C.jsx(A2,{events:f,onClose:()=>ii(!1)}):null,qt?C.jsx(o2,{open:vi,taskSlug:qt.taskSlug,taskTitle:qt.title,onClose:()=>yi(!1)}):null]})}function Uv(t){return[t.autoOrchestration?"auto":"manual"].join(" + ")}function d2(t){const r=Object.entries(t.roles).map(([s,l])=>`${s}: ${l.permissionMode} / ${l.model} / ${l.effort}`).join("; ");return`Launch template: ${Uv(t)}; ${r}`}function p2({busy:t,status:r,onCheck:s,onSettingsChange:l}){const[d,m]=ee.useState(""),f=!!(r!=null&&r.apiKeyConfigured),o=async c=>{c.preventDefault();const u=d.trim();u&&(await l({apiKey:u}),m(""))};return C.jsxs("div",{className:"codex-bridge-settings",children:[C.jsx(Rn,{checked:!!(r!=null&&r.enabled),className:"sidebar-switch",disabled:t||!f,label:"Codex Bridge models",title:f?"Enable Codex models through Codex Bridge":"Save the Codex Bridge API key first",onChange:c=>void l({enabled:c})}),C.jsxs("form",{className:"codex-bridge-api-key-form",onSubmit:c=>void o(c),children:[C.jsx("label",{htmlFor:"codex-bridge-api-key",children:"Codex Bridge API key"}),C.jsxs("div",{children:[C.jsx("input",{id:"codex-bridge-api-key",type:"password",autoComplete:"off",disabled:t,placeholder:f?"Saved":"Required",value:d,onChange:c=>m(c.target.value)}),C.jsx("button",{type:"submit",disabled:t||!d.trim(),children:"Save"})]})]}),C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Codex Bridge status"}),C.jsx("strong",{children:(r==null?void 0:r.connectionState)??"loading"})]}),C.jsxs("div",{className:"codex-bridge-actions",children:[C.jsx("button",{type:"button",disabled:t||!(r!=null&&r.enabled),onClick:()=>void s(),children:"Check"}),C.jsx("button",{type:"button",disabled:t||!f,onClick:()=>void l({clearApiKey:!0}),children:"Clear key"})]}),r!=null&&r.error?C.jsx("p",{className:"settings-help-text",children:r.error}):null]})}function m2({autoSendEnabled:t,baseUnavailableReason:r,busy:s,enabled:l,memoryInitialized:d,outputMode:m,targetLanguage:f,translatorSession:o,onAutoSendChange:c,onCreateBootstrap:u,onEnabledChange:g,onUpdateMemory:h,onOutputModeChange:S,onTargetLanguageChange:x,onOpenFileTranslation:T,onOpenTranslatorSession:E}){const y=!!(s||r),_=(o==null?void 0:o.status)==="running",v=!!(l&&!r&&_),b=r??(_?null:"Start Translator session first."),k=!!(s||b),R=r??"Open Translator session",D=b??"Translation tools are ready";return C.jsxs("div",{className:"sidebar-settings",children:[C.jsx(Rn,{checked:v,className:"sidebar-switch",disabled:y||!_,label:"Conversation translation",title:D,onChange:g}),C.jsx(Rn,{checked:t,className:"sidebar-switch",disabled:y,label:"Auto-send",onChange:c}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Language"}),C.jsx("select",{value:f,disabled:y,onChange:A=>x(A.target.value),children:b_.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Reply scope"}),C.jsx("select",{value:m,disabled:y,onChange:A=>S(A.target.value),children:pS.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:T,children:[C.jsx("span",{children:"File translation"}),C.jsx("span",{children:"open"})]}),d?null:C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:u,children:[C.jsx("span",{children:"Bootstrap"}),C.jsx("span",{children:"run"})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:h,children:[C.jsx("span",{children:"Update memory"}),C.jsx("span",{children:"run"})]}),b?C.jsx("p",{className:"settings-help-text",children:b}):null,C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Session status"}),C.jsx("strong",{children:g2(o)})]}),C.jsxs("button",{className:"settings-toggle",disabled:y,title:R,type:"button",onClick:E,children:[C.jsx("span",{children:"Open Session"}),C.jsx("span",{children:"open"})]})]})}function g2(t){return t?t.status==="running"?t.activityStatus??"idle":t.status:"not started"}function _2(t,r,s){return t?r?s?s.initialized?null:"Initialize VCM Harness first.":"Load VCM Harness status first.":"Create or select a task first.":"Connect a repository first."}function v2({busy:t,onCancelGateReview:r,onGateEnabledChange:s,state:l}){return C.jsx("div",{className:"sidebar-settings",children:Qk.map(d=>{const m=l==null?void 0:l.gates[d],f=!!(m!=null&&m.required);return C.jsxs("div",{className:"gate-review-setting",children:[C.jsx(Rn,{checked:f,className:"sidebar-switch",disabled:t||!l||(m==null?void 0:m.status)==="running",label:y2(d),title:m!=null&&m.status?`status: ${m.status}`:void 0,onChange:o=>s(d,o)}),(m==null?void 0:m.status)==="running"&&m.requestId?C.jsx("button",{className:"danger-button",disabled:t,type:"button",onClick:()=>r(d,m.requestId),children:"Cancel review"}):null]},d)})})}function y2(t){switch(t){case"architecture-plan":return"Architecture plan";case"validation-adequacy":return"Validation adequacy";case"code-diff":return"Code diff"}return t}function S2({busy:t,larkRegistration:r,larkRegistrationCheck:s,onEnabledChange:l,onResetBinding:d,onSettingsChange:m,onStartLarkRegistration:f,onStartQrLogin:o,onTranslationChange:c,onConnectionChange:u,qrCheck:g,qrLogin:h,status:S}){const x=(S==null?void 0:S.channel)==="lark",T=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured),E=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured);return C.jsxs("div",{className:"gateway-panel",children:[C.jsxs("label",{className:"compact-field",children:[C.jsx("span",{children:"Channel"}),C.jsxs("select",{disabled:t||!S,value:(S==null?void 0:S.channel)??"weixin-ilink",onChange:y=>{m({channel:y.currentTarget.value==="lark"?"lark":"weixin-ilink"})},children:[C.jsx("option",{value:"weixin-ilink",children:"Weixin iLink"}),C.jsx("option",{value:"lark",children:"Lark"})]})]}),C.jsxs("div",{className:"gateway-actions",children:[C.jsx(Rn,{checked:!!(S!=null&&S.connectionEnabled),className:"sidebar-switch",disabled:t||!S||!S.connectionEnabled&&!T,label:"Connection",stateLabel:S!=null&&S.connectionEnabled?"connected":"off",title:T?"Connect or disconnect the channel for this session. Off by default; the phone can drive the gateway only while Connection is on. Separate from the Gateway command switch.":"Configure the selected Gateway channel first",onChange:y=>u(y)}),C.jsx(Rn,{checked:!!(S!=null&&S.enabled),className:"sidebar-switch",disabled:t||!S||!S.enabled&&!T,label:"Gateway",title:T?"Enable or disable role messages and task-changing Gateway commands":"Configure the selected Gateway channel first",onChange:y=>l(y)}),C.jsx(Rn,{checked:!!(S!=null&&S.translationEnabled),className:"sidebar-switch",disabled:t||!S,label:"Translation",onChange:y=>c(y)}),x?C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Start QR Setup"}):E?C.jsx("button",{className:"danger-button",type:"button",disabled:t,onClick:d,children:"Reset Binding"}):C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Start QR Login"})]}),x?C.jsxs("div",{className:"gateway-lark-settings",children:[C.jsx("p",{className:"muted",children:S!=null&&S.binding.appIdConfigured&&S.binding.appSecretConfigured?`Lark app configured${S.binding.larkBotName?` · ${S.binding.larkBotName}`:""}.`:"Use QR setup to create and configure the Lark bot automatically."}),r?C.jsxs("p",{className:"muted",children:["QR setup: ",(s==null?void 0:s.status)??r.status,s!=null&&s.message?` · ${s.message}`:""]}):null]}):h?C.jsx("p",{className:"muted",children:"QR login started. Use the login dialog to confirm binding."}):null,!x&&g?C.jsxs("p",{className:"muted",children:["QR status: ",g.status,g.message?` · ${g.message}`:""]}):null]})}function b2({busy:t,onPull:r,project:s}){const l=s.pullDisabledReason,d=!!s.canPull;return C.jsxs("div",{className:"project-summary",children:[C.jsxs("dl",{children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Base path"}),C.jsx("dd",{children:s.repoRoot})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Branch"}),C.jsx("dd",{children:C2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Remote"}),C.jsx("dd",{children:s.upstreamBranch??"no upstream"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Status"}),C.jsx("dd",{children:w2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Commit"}),C.jsx("dd",{children:s.shortHeadCommit??s.headCommit??"unknown"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Working tree"}),C.jsx("dd",{children:s.isDirty?"uncommitted changes":"clean"})]})]}),C.jsxs("div",{className:"connected-repo-actions",children:[C.jsx("button",{type:"button",disabled:t||!d,title:l??"Pull latest changes with git pull --ff-only",onClick:()=>void r(),children:"Pull"}),C.jsx("span",{className:"muted",children:s.checkedAt?`checked ${qh(s.checkedAt)}`:"status not refreshed"})]}),l?C.jsx("p",{className:"muted",children:l}):null,s.warnings.length>0?C.jsx("ul",{className:"warnings",children:s.warnings.map(m=>C.jsx("li",{children:m},m))}):null]})}function C2(t){return t.branch||"unknown"}function w2(t){if(!t.upstreamBranch)return"no upstream";const r=t.ahead??0,s=t.behind??0;return r===0&&s===0?"up to date":r>0&&s>0?`ahead ${r}, behind ${s}`:r>0?`ahead ${r}`:`behind ${s}`}function x2({roundState:t,task:r}){var g;const[s,l]=ee.useState(()=>Date.now()),d=!!(t!=null&&t.startedAt),m=Pv(r.createdAt,s),f=r_(t,(t==null?void 0:t.totalCcActiveMs)??0,s),o=d&&t?r_(t,t.currentRoundCcActiveMs,s):0,c=d&&t?E2(t,s):0,u=((g=r.title)==null?void 0:g.trim())||r.taskSlug;return ee.useEffect(()=>{const h=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(h)},[]),C.jsxs("section",{className:"task-status-dock","aria-label":"VCM Session status",children:[C.jsxs("div",{className:"task-status-dock-title",children:[C.jsx("strong",{title:u,children:u}),C.jsx("span",{className:`status-badge status-${r.status}`,children:r.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Session start"}),C.jsx("dd",{children:qh(r.createdAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Session total"}),C.jsx("dd",{children:Bo(m)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Rounds"}),C.jsx("dd",{children:(t==null?void 0:t.totalRoundCount)??0})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Bo(f)})]})]}),d&&t?C.jsxs("div",{className:"current-round-status",children:[C.jsxs("div",{className:"current-round-title",children:[C.jsx("span",{children:t.status==="running"?"Current Round":"Last Round"}),C.jsx("span",{className:`status-badge status-${t.status}`,children:t.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Started"}),C.jsx("dd",{children:qh(t.startedAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Total"}),C.jsx("dd",{children:Bo(c)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Bo(o)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Turn count"}),C.jsx("dd",{children:t.turnCount})]})]})]}):null]})}function r_(t,r,s){if(!(t!=null&&t.activeTurnStartedAt)||t.status!=="running")return r;const l=Date.parse(t.updatedAt);return Number.isFinite(l)?r+Math.max(0,s-l):r}function E2(t,r){const s=t.status==="running"?r:Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return Pv(t.startedAt??"",Number.isFinite(s)?s:r)}function Pv(t,r){const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,r-s):0}function qh(t){if(!t)return"-";const r=new Date(t);return Number.isNaN(r.getTime())?"-":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(r)}function Bo(t){const r=Math.max(0,Math.floor(t/1e3)),s=Math.floor(r/3600),l=Math.floor(r%3600/60),d=r%60;return s>0?l>0?`${s}h ${l}m`:`${s}h`:l>0?d>0?`${l}m ${d}s`:`${l}m`:`${d}s`}function k2(t){return t==="system"?"light":t==="light"?"dark":"system"}function s_(t){return t==="system"?"System":t==="light"?"Light":"Dark"}function A2({events:t,onClose:r}){return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"event-modal",role:"dialog","aria-modal":"true","aria-label":"Events",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Events"}),C.jsxs("p",{className:"muted",children:[t.length," total"]})]}),C.jsx("button",{type:"button",onClick:r,children:"Close"})]}),C.jsx(Jk,{events:t,maxEvents:null,showHeader:!1})]})})}function T2({busy:t,messages:r,orchestration:s,onClose:l,onMarkAllDone:d,onDeleteMessageHistory:m}){const f=ff(r);function o(){window.confirm(["Clear all pending route-file messages?","","Use this only after you manually copied or handled stuck route-file messages.","VCM will clear non-empty handoff message files so Stop-hook orchestration can continue."].join(`
|
|
93
|
+
`;function wk({active:t=!0,autoSendEnabled:r,targetLanguage:s,taskSlug:l,role:d,sessionId:m,panelState:f,onClearSession:o,onEntry:c,onFailures:u}){const[g,h]=ee.useState(""),[S,x]=ee.useState(""),[T,E]=ee.useState(!1),[y,_]=ee.useState(Date.now()),[v,b]=ee.useState(!1),[,k]=qi(""),L=ee.useRef(null),R=f.entries,D=f.failures,A=f.status;ee.useEffect(()=>{if(!t)return;const N=L.current;if(!N)return;const q=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight});return()=>window.cancelAnimationFrame(q)},[t,R]);const M=Mk(R);ee.useEffect(()=>{if(!M)return;_(Date.now());const N=window.setInterval(()=>_(Date.now()),250);return()=>window.clearInterval(N)},[M]);async function O(N=!1){const q=g;b(!0),k(""),E(!1);try{const I=await ye.translateUserInput(l,d,{text:q,mode:N?"auto-send":"review-before-send",useContext:!1,send:N});I.sent?(h(""),E(!1)):(h(Hv(q,I.englishPreview)),E(!0))}catch(I){k(ft("Translate composer input",I))}finally{b(!1)}}async function H(){const N=S.trim();if(N){b(!0),k("");try{const q=await ye.translateManualOutput(l,d,{text:N});c(m,d,q),x("")}catch(q){k(ft("Translate pasted English output",q))}finally{b(!1)}}}async function U(){b(!0),k("");try{const N=await ye.translateLatestReply(l,d);c(m,d,N)}catch(N){k(ft("Translate final reply",N))}finally{b(!1)}}async function P(){const N=T?t_(g):g;if(N.trim()){b(!0),k("");try{await ye.sendTranslatedInput(l,d,{englishText:N}),h(""),E(!1)}catch(q){k(ft("Send translated English input to role",q))}finally{b(!1)}}}function W(N){N.key!=="Enter"||N.shiftKey||N.nativeEvent.isComposing||(N.preventDefault(),!v&&g.trim()&&(T?P():O(r)))}async function K(){o(m,d),await ye.clearTranslationSession(m).catch(N=>k(ft("Clear conversation translation panel",N)))}async function V(){b(!0),k("");try{const N=await ye.ignoreTranslationFailures(m);u(m,d,N.failures)}catch(N){k(ft("Ignore failed conversation translations",N))}finally{b(!1)}}async function Y(N){b(!0),k("");try{const q=await ye.retryTranslation(m,N.translationId);c(m,d,q)}catch(q){k(ft("Retry latest failed conversation translation",q))}finally{b(!1)}}const te=Lk(R,A,y),z=D.length,j=Ek(D);return C.jsxs("aside",{className:"translation-panel",children:[C.jsxs("header",{className:"translation-panel-header",children:[C.jsxs("div",{className:"translation-panel-titlebar",children:[C.jsx("h2",{children:"Translation"}),C.jsxs("div",{className:"translation-panel-actions",children:[z>0?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",disabled:v,onClick:()=>void V(),children:["Ignore ",z]}),j?C.jsx("button",{type:"button",disabled:v,onClick:()=>void Y(j),children:"Retry latest"}):null]}):null,C.jsx("button",{type:"button",disabled:v,onClick:()=>void U(),children:"Translate final reply"}),C.jsx("button",{type:"button",onClick:()=>void K(),children:"Clear"})]})]}),C.jsx("div",{className:"translation-status-row",children:C.jsxs("p",{children:["Claude Code · target ",xk(s)," · ",te]})})]}),C.jsx("div",{className:"translation-manual-panel",children:C.jsxs("div",{className:"translation-composer-row translation-manual-row",children:[C.jsx("textarea",{value:S,onChange:N=>x(N.target.value),placeholder:"Paste English to translate on demand..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:v||!S.trim(),onClick:()=>void H(),children:"Translate"})})]})}),C.jsxs("div",{className:"translation-entry-list",ref:L,children:[R.length===0?C.jsx("p",{className:"muted",children:"Translated Claude Code output will appear here."}):null,R.map(N=>C.jsx(Rk,{entry:N},N.id))]}),C.jsx("div",{className:"translation-composer",children:C.jsxs("div",{className:"translation-composer-row",children:[C.jsx("textarea",{value:g,onChange:N=>{h(N.target.value),(!N.target.value.trim()||T&&!jk(N.target.value))&&E(!1)},onKeyDown:W,placeholder:"输入中文,先翻译成英文工程指令..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:v||!T||!t_(g).trim(),onClick:()=>void P(),children:"Send English"})})]})})]})}function xk(t){var r;return((r=b_.find(s=>s.value===t))==null?void 0:r.label)??t}function Ek(t){let r,s=Number.NEGATIVE_INFINITY;for(const l of t){const d=Date.parse(l.failedAt),m=Number.isFinite(d)?d:Number.NEGATIVE_INFINITY;(!r||m>=s)&&(r=l,s=m)}return r}function kk({open:t,taskSlug:r,targetLanguage:s,onClose:l}){const[d,m]=ee.useState(!1),[,f]=qi(""),[o,c]=ee.useState(null),[u,g]=ee.useState(""),[h,S]=ee.useState(""),[x,T]=ee.useState(""),[E,y]=ee.useState(!1),[_,v]=ee.useState(null),[b,k]=ee.useState(""),[L,R]=ee.useState(""),[D,A]=ee.useState(""),[M,O]=ee.useState(!1);pl(t?`file-translation:${u||"none"}`:null,()=>H(!0),{intervalMs:2e3,runImmediately:!0});async function H(V=!1){try{const Y=await ye.getTranslationState();c(Y);const te=u?Y.fileIndex.jobs.some(z=>z.id===u):!1;if((!u||!te)&&Y.fileIndex.jobs[0])U(Y.fileIndex.jobs[0].id);else if(!Y.fileIndex.jobs[0])g(""),S(""),T("");else if(V&&u){const z=await ye.readFileTranslation(u);S(z.output),T(z.report)}}catch(Y){f(ft("Load file translation list",Y))}}async function U(V){g(V),S(""),T("");try{const Y=await ye.readFileTranslation(V);S(Y.output),T(Y.report)}catch(Y){f(ft(`Read translated file ${V}`,Y))}}async function P(){y(!0),await W(b,L)}async function W(V="",Y=""){O(!0),f("");try{const te=await ye.browseTranslationSourceFiles({path:V,query:Y,limit:250});v(te),k(te.currentPath),R(Y)}catch(te){f(ft("Browse translation source files",te))}finally{O(!1)}}async function K(V=D){const Y=V.trim();if(Y){m(!0),f("");try{if(!r)throw new Error("Create or select a task before translating files.");const te=await ye.createFileTranslation({taskSlug:r,sourcePath:Y,targetLanguage:s});y(!1),await H(),await U(te.id)}catch(te){f(ft(`Create file translation for ${Y}`,te))}finally{m(!1)}}}return t?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"modal-backdrop file-translation-backdrop",children:C.jsx(Tk,{busy:d,state:o,selectedJobId:u,output:h,report:x,onClose:()=>{y(!1),l()},onRefresh:()=>void H(),onSelectJob:V=>void U(V),onTranslate:()=>void P()})}),E?C.jsx(Ak,{busy:d||M,state:_,currentPath:b,query:L,selectedPath:D,onBrowse:(V,Y)=>void W(V,Y),onClose:()=>y(!1),onQueryChange:R,onSelectPath:A,onTranslate:()=>void K()}):null]}):null}function Ak({busy:t,state:r,currentPath:s,query:l,selectedPath:d,onBrowse:m,onClose:f,onQueryChange:o,onSelectPath:c,onTranslate:u}){const g=(r==null?void 0:r.entries)??[],h=g.filter(x=>x.type==="directory"),S=g.filter(x=>x.type==="file");return C.jsx("div",{className:"modal-backdrop translation-file-browser-backdrop",children:C.jsxs("section",{className:"translation-file-browser-modal",role:"dialog","aria-modal":"true","aria-label":"Select Source File",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Select Source File"}),C.jsx("p",{children:s||"."})]}),C.jsx("button",{type:"button",onClick:f,children:"Close"})]}),C.jsxs("div",{className:"translation-file-browser-controls",children:[C.jsxs("div",{className:"translation-file-browser-nav",children:[C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m((r==null?void 0:r.parentPath)??"",""),children:"Up"}),C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m("",""),children:"Root"})]}),C.jsxs("form",{className:"translation-file-browser-search",onSubmit:x=>{x.preventDefault(),m(s,l)},children:[C.jsx("input",{value:l,onChange:x=>o(x.target.value),placeholder:"Search files"}),C.jsx("button",{type:"submit",disabled:t,children:"Search"}),C.jsx("button",{type:"button",disabled:t||!l,onClick:()=>m(s,""),children:"Clear"})]})]}),C.jsxs("div",{className:"translation-file-browser-layout",children:[C.jsxs("div",{className:"translation-file-browser-list",children:[t&&!r?C.jsx("p",{className:"muted",children:"Loading files..."}):null,!t&&g.length===0?C.jsx("p",{className:"muted",children:"No source files found."}):null,h.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Folders"}),h.map(x=>C.jsx(e_,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,S.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Files"}),S.map(x=>C.jsx(e_,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,r!=null&&r.truncated?C.jsx("p",{className:"translation-entry-note",children:"Result limit reached."}):null]}),C.jsxs("aside",{className:"translation-file-browser-selection",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Source path"}),C.jsx("input",{value:d,onChange:x=>c(x.target.value)})]}),C.jsx("button",{type:"button",disabled:t||!d.trim(),onClick:u,children:"Translate File"})]})]})]})})}function e_({entry:t,selected:r,onBrowse:s,onSelectPath:l}){const d=t.type==="directory";return C.jsxs("button",{className:r?"translation-file-browser-entry is-selected":"translation-file-browser-entry",type:"button",onClick:()=>d?s(t.path,""):l(t.path),onDoubleClick:()=>d?s(t.path,""):void 0,children:[C.jsx("span",{children:d?"DIR":"FILE"}),C.jsx("strong",{children:t.name}),C.jsx("small",{children:t.path})]})}function Tk({busy:t,state:r,selectedJobId:s,output:l,report:d,onClose:m,onRefresh:f,onSelectJob:o,onTranslate:c}){const u=(r==null?void 0:r.fileIndex.jobs)??[],g=u.find(h=>h.id===s);return C.jsxs("section",{className:"file-translation-modal",role:"dialog","aria-modal":"true","aria-label":"File Translation",children:[C.jsxs("header",{className:"file-translation-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"File Translation"}),C.jsx("p",{children:"Claude Code · 中英互译"})]}),C.jsxs("div",{className:"file-translation-toolbar",children:[C.jsx("button",{type:"button",disabled:t,onClick:c,children:"Translate"}),C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Refresh"}),C.jsx("button",{type:"button",onClick:m,children:"Close"})]})]}),r!=null&&r.memoryInitialized?null:C.jsx("p",{className:"translation-entry-note",children:"Translation memory is not initialized. Run Bootstrap from the sidebar before important file translations."}),C.jsxs("div",{className:"file-translation-layout",children:[C.jsxs("div",{className:"file-translation-list",children:[u.length===0?C.jsx("p",{className:"muted",children:"No translated files yet."}):null,u.map(h=>C.jsxs("button",{className:h.id===s?"file-translation-item is-active":"file-translation-item",type:"button",onClick:()=>o(h.id),children:[C.jsx("strong",{children:h.sourcePath}),C.jsxs("span",{children:[h.status," · ",h.targetLanguage]})]},h.id))]}),C.jsx("div",{className:"file-translation-preview",children:g?C.jsxs(C.Fragment,{children:[C.jsxs("header",{children:[C.jsx("strong",{children:g.sourcePath}),C.jsx("span",{children:g.status})]}),C.jsx("div",{className:"translation-markdown",children:C.jsx(cv,{remarkPlugins:[Ov],children:l||d||"Translation output is not available yet."})})]}):C.jsx("p",{className:"muted",children:"Select a translated file to preview it."})})]})]})}function Rk({entry:t}){if(t.sourceKind==="conversation-boundary")return C.jsx(Dk,{entry:t});const r=Bk(t),s=t.sourceKind==="tool-output",l=t.direction==="user-input-to-english",d=["translation-entry",`is-${t.sourceKind}`,l?"is-user-input":""].filter(Boolean).join(" ");return C.jsxs("article",{className:d,children:[s?C.jsx("pre",{children:r}):C.jsx("div",{className:"translation-markdown",children:C.jsx(cv,{remarkPlugins:[Ov],children:r})}),t.warning?C.jsx("p",{className:"translation-entry-note",children:t.warning}):null,t.error?C.jsx("p",{className:"translation-entry-note is-error",children:t.error}):null]})}function Dk({entry:t}){const r=t.boundaryKind==="end"?"结束":"开始",s=t.conversationTurn??0,l=Hk(t.occurredAt??t.createdAt);return C.jsxs("div",{className:"translation-conversation-boundary","aria-label":`${r} 第 ${s} 轮 ${l}`,children:[C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"}),C.jsx("span",{children:r}),C.jsxs("span",{children:["第 ",s," 轮"]}),C.jsx("time",{children:l}),C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"})]})}function Mk(t){const r=t.find(Nv);return(r==null?void 0:r.translationStartedAt)??(r==null?void 0:r.createdAt)}function Lk(t,r,s){const l=t.find(Nv);if(l)return`translating ${Nk(Math.max(0,s-Ok(l)))}`;const d=t.at(-1);return(d==null?void 0:d.status)==="failed"||r==="failed"?"error":r}function Nv(t){return t.status==="queued"||t.status==="translating"}function Ok(t){const r=Date.parse(t.translationStartedAt??t.createdAt);return Number.isFinite(r)?r:Date.now()}function Bk(t){return t.status==="queued"||t.status==="translating"?t.sourceText:t.status==="translated"?t.direction==="user-input-to-english"?Hv(t.sourceText,t.translatedText):t.translatedText:t.translatedText||t.sourceText}function Hv(t,r){return`${t.trimEnd()}${Fo}${r.trimStart()}`}function jk(t){return t.includes(Fo)}function t_(t){const r=t.indexOf(Fo);return r===-1?t:t.slice(r+Fo.length)}function Nk(t){if(t<1e3)return`${Math.max(.1,t/1e3).toFixed(1)}s`;const r=t/1e3;if(r<60)return`${r.toFixed(1)}s`;const s=Math.floor(r/60),l=Math.floor(r%60).toString().padStart(2,"0");return`${s}:${l}`}function Hk(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleTimeString()}const zk=8;function Ik(){const[t,r]=ee.useState([]);return ee.useEffect(()=>{const s=m=>{var c,u;const f=(u=(c=m.detail)==null?void 0:c.message)==null?void 0:u.trim();if(!f)return;const o=new Date().toISOString();r(g=>{const h=g.find(S=>S.message===f);return h?[{...h,count:h.count+1,updatedAt:o},...g.filter(S=>S.id!==h.id)]:[{id:`ui_error_${Date.now()}_${Math.random().toString(16).slice(2)}`,message:f,count:1,createdAt:o,updatedAt:o},...g].slice(0,zk)})},l=m=>{var o;const f=((o=m.detail)==null?void 0:o.actions)??[];f.length!==0&&r(c=>c.filter(u=>!f.some(g=>u.message.startsWith(`${g} failed.`))))},d=m=>{var o,c;const f=(c=(o=m.detail)==null?void 0:o.message)==null?void 0:c.trim();f&&r(u=>u.filter(g=>g.message!==f))};return window.addEventListener(Ah,s),window.addEventListener(Th,l),window.addEventListener(Rh,d),()=>{window.removeEventListener(Ah,s),window.removeEventListener(Th,l),window.removeEventListener(Rh,d)}},[]),t.length===0?null:C.jsxs("aside",{className:"ui-error-center",role:"alert","aria-live":"polite","aria-label":"Application errors",children:[C.jsxs("header",{className:"ui-error-center-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Errors"}),C.jsxs("p",{children:[t.length," active"]})]}),C.jsx("button",{type:"button",onClick:()=>r([]),children:"Clear"})]}),C.jsx("ol",{className:"ui-error-list",children:t.map(s=>C.jsxs("li",{children:[C.jsxs("div",{children:[C.jsx("p",{children:s.message}),C.jsxs("span",{children:[Uk(s.updatedAt),s.count>1?` · repeated ${s.count} times`:""]})]}),C.jsx("button",{type:"button","aria-label":"Dismiss error",onClick:()=>r(l=>l.filter(d=>d.id!==s.id)),children:"Close"})]},s.id))})]})}function Uk(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Pk(t,r){return t.find(s=>s.taskSlug===r)??t[0]??null}function Fk(t){if(!(t.mode!=="auto"||t.status!=="running")&&!(!t.activeRole||t.activeRole===t.lastFollowedRole))return t.activeRole}function qk(t,r){var d;if(!((d=t.flowPause)!=null&&d.paused))return null;const s=t.flowPause.role??t.activeRole??"role",l=t.roleRecovery;return t.flowPause.reason==="role-recovery-failed"&&l?r(l,s):t.flowPause.message??`No new turn started after ${s} stopped.`}function $k(t){const r=t.roundId??t.startedAt??t.taskSlug,s=t.stoppedAt??t.lastTurnEndedAt??"stopped";return`${r}:${s}`}function Gk(t,r,s){if((r==null?void 0:r.status)==="running")return!0;const l=Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return!!(s&&Number.isFinite(l)&&l>s)}function Vk(t){return t?"strong":"none"}function Wk(t,r){if(!r)return{observation:t,dismissPauseAlert:!1};const s=r.lastGatewayInputMessageId??null;return t.initialized?{observation:{initialized:!0,messageId:s},dismissPauseAlert:!!(r.enabled&&s&&s!==t.messageId)}:{observation:{initialized:!0,messageId:s},dismissPauseAlert:!1}}const Kk=3,Yk=3e4,No=new Map;function zv(t,r){const s=ft(t,r);if(!Xk(r))return No.set(t,{consecutiveFailures:1,lastMessage:s,lastReportedAt:Date.now()}),s;const l=No.get(t),d=((l==null?void 0:l.consecutiveFailures)??0)+1,m=Date.now(),f=d>=Kk&&(!l||l.lastMessage!==s||m-l.lastReportedAt>=Yk);return No.set(t,{consecutiveFailures:d,lastMessage:s,lastReportedAt:f?m:(l==null?void 0:l.lastReportedAt)??0}),f?s:null}function qo(t){No.delete(t),xS([t])}function Xk(t){const r=ml(t);return r.includes("could not reach the VCM backend")||r.includes("Failed to fetch")||r.includes("NetworkError")||r.includes("Load failed")||r.includes("ERR_CONNECTION")}const Qk=["architecture-plan","validation-adequacy","code-diff"];function Jk({events:t,maxEvents:r=8,showHeader:s=!0}){const l=r===null?t:t.slice(-r);return C.jsxs("section",{className:"event-log",children:[s?C.jsx("h2",{children:"Events"}):null,t.length===0?C.jsx("p",{className:"muted",children:"No terminal events yet."}):C.jsx("ol",{children:l.map((d,m)=>C.jsx("li",{children:d},`${d}-${m}`))})]})}function Rn({checked:t,className:r,disabled:s,label:l,stateLabel:d,title:m,onChange:f}){const o=["switch-control",t?"is-on":"is-off",r].filter(Boolean).join(" "),c=d??(t?"on":"off");return C.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":`${l}: ${c}`,className:o,disabled:s,title:m,onClick:()=>f(!t),children:[C.jsx("span",{className:"switch-control-label",children:l}),C.jsx("span",{className:"switch-control-track","aria-hidden":"true",children:C.jsx("span",{className:"switch-control-thumb"})})]})}const Eh={evidence:"Evidence",scaffold:"Scaffold",validation:"Validation"};function Zk({status:t,bootstrapStatus:r,applyResult:s,hasActiveTask:l=!1,autoTaskHarnessReviewEnabled:d,autoMemoryEnabled:m,architectWorkerSettings:f,launchOptions:o,modelOptions:c,busy:u=!1,onRefresh:g,onApply:h,onOpenStudio:S,onOpenRepositoryDiff:x,onAutoTaskHarnessReviewChange:T,onAutoMemoryChange:E,onArchitectWorkerSettingsChange:y,onLaunchOptionsChange:_,onStartBootstrap:v,onRestartBootstrap:b,onStopBootstrap:k,onRunBootstrap:L}){const[R,D]=ee.useState(!1),A=r==null?void 0:r.session,M=(r==null?void 0:r.status)==="running",O=(A==null?void 0:A.status)==="running",H=(r==null?void 0:r.status)!=="complete";return l?t?C.jsxs("section",{className:"harness-panel",children:[C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Fixed install"}),C.jsx("p",{className:"muted",children:t.initialized?t.needsApply?`${t.plannedChanges.length} pending updates`:"Up to date":"Not initialized"})]}),C.jsx("div",{className:"harness-actions",children:t.initialized?C.jsxs(C.Fragment,{children:[C.jsx("button",{type:"button",disabled:u,onClick:()=>void g(),children:"Refresh"}),t.needsApply?C.jsx("button",{type:"button",disabled:u,onClick:()=>void h(),children:"Update"}):null]}):C.jsx("button",{type:"button",disabled:u,onClick:()=>void h(),children:"Initialize"})})]}),t.initialized&&t.needsApply?C.jsxs(C.Fragment,{children:[C.jsx("h3",{className:"harness-file-list-title",children:"Files to update"}),C.jsx("ol",{className:"harness-file-list",children:t.plannedChanges.map(U=>C.jsxs("li",{children:[C.jsx("span",{children:U.path}),C.jsx($n,{status:U.action})]},`${U.path}:${U.action}`))})]}):null]}),C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsx("div",{children:C.jsx("strong",{children:"Harness Studio"})}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:u,onClick:S,children:"Open Studio"})})]}),C.jsx("button",{className:"harness-review-diff-button",type:"button",disabled:u,onClick:x,children:"Review Diff"}),C.jsx(Rn,{checked:d,className:"sidebar-switch",disabled:u,label:"Auto task harness review",title:"Automatically ask Harness Engineer to review task harness after final acceptance completes",onChange:T}),C.jsx(Rn,{checked:m,className:"sidebar-switch",disabled:u,label:"Auto memory",title:"Collect role memory drafts after Final Acceptance and let Harness Engineer apply reviewed memory",onChange:E}),C.jsxs("div",{className:"architect-worker-settings",title:"Model and effort for Architect workers. Apply the harness to write changes into worker definitions.",children:[C.jsx("strong",{children:"Architect workers"}),oS.map(U=>C.jsxs("div",{className:"architect-worker-setting",children:[C.jsx("span",{children:Eh[U]}),C.jsx("select",{"aria-label":`${Eh[U]} worker model`,disabled:u,value:f[U].model,onChange:P=>y({...f,[U]:{...f[U],model:P.target.value}}),children:cS.map(P=>C.jsx("option",{value:P,children:P},P))}),C.jsx("select",{"aria-label":`${Eh[U]} worker effort`,disabled:u,value:f[U].effort,onChange:P=>y({...f,[U]:{...f[U],effort:P.target.value}}),children:uS.map(P=>C.jsx("option",{value:P,children:P},P))})]},U))]})]}),H?C.jsx("div",{className:"harness-stage",children:C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Bootstrap"}),C.jsx("p",{className:"muted",children:r?e2(r.status):"not loaded"})]}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:u||!(r!=null&&r.canStart),onClick:()=>{D(!0)},children:"Open Bootstrap"})})]})}):null,s!=null&&s.changedFiles.length?C.jsx("div",{className:"harness-result",children:C.jsx("p",{className:"muted",children:s.message})}):null,t.warnings.length>0?C.jsx("ul",{className:"warnings",children:t.warnings.map(U=>C.jsx("li",{children:U},U))}):null,r!=null&&r.warnings.length?C.jsx("ul",{className:"warnings",children:r.warnings.map(U=>C.jsx("li",{children:U},U))}):null,H&&R?C.jsx("div",{className:"harness-bootstrap-modal",role:"dialog","aria-modal":"true","aria-label":"Harness Engineer bootstrap session",children:C.jsxs("div",{className:"harness-bootstrap-modal-surface",children:[C.jsxs("header",{className:"harness-bootstrap-modal-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Harness Engineer Bootstrap"}),C.jsx("p",{className:"muted",children:(A==null?void 0:A.command)??"Start Harness Engineer, then run bootstrap when ready."})]}),C.jsxs("div",{className:"harness-bootstrap-modal-actions",children:[A?C.jsx($n,{status:A.status}):null,C.jsx("button",{type:"button",onClick:()=>D(!1),children:"Close"})]})]}),C.jsxs("div",{className:"harness-bootstrap-controls",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Permission"}),C.jsx("select",{value:o.permissionMode,disabled:u||M||O,onChange:U=>_({...o,permissionMode:U.target.value}),children:C_.map(U=>C.jsx("option",{value:U.value,children:U.label},U.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Model"}),C.jsx("select",{value:o.model,title:(()=>{const U=c.find(P=>P.value===o.model);return U!=null&&U.available?U.description:U==null?void 0:U.unavailableReason})(),disabled:u||M||O,onChange:U=>_({...o,model:U.target.value}),children:c.map(U=>C.jsx("option",{value:U.value,disabled:!U.available,title:U.available?U.description:U.unavailableReason,children:U.label},U.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Effort"}),C.jsx("select",{value:o.effort,disabled:u||M||O,onChange:U=>_({...o,effort:U.target.value}),children:x_.map(U=>C.jsx("option",{value:U.value,children:U.label},U.value))})]}),C.jsxs("div",{className:"harness-bootstrap-control-actions",children:[C.jsx("button",{type:"button",disabled:u||M||!(r!=null&&r.canStart),onClick:()=>void v(o),children:"Start"}),C.jsx("button",{type:"button",disabled:u||M||!(r!=null&&r.canStart),onClick:()=>void b(o),children:"Restart"}),C.jsx("button",{type:"button",disabled:u||!A,onClick:()=>void k(),children:"Stop"}),C.jsx("button",{type:"button",disabled:u||M||!O,onClick:()=>void L(),children:"Run bootstrap"})]})]}),C.jsx("div",{className:"harness-bootstrap-terminal",children:O?C.jsx(Vo,{sessionId:A.id,active:R}):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:"Harness Bootstrap"}),C.jsx("span",{children:"Start Harness Engineer first. When it is ready, click Run bootstrap to send the prompt."})]})})]})}):null]}):null:C.jsx("section",{className:"harness-panel",children:C.jsxs("div",{className:"harness-result",children:[C.jsx("strong",{children:"Task required"}),C.jsx("p",{className:"muted",children:"Create or select a task before changing VCM Harness. Harness changes are committed in the active task worktree."})]})})}function e2(t){return t.replaceAll("_"," ")}function ff(t){return{total:t.length,accepted:t.filter(r=>r.acceptedAt).length,delivered:t.filter(r=>r.deliveredAt).length}}function t2(t,r=6){const s=[...t].sort(r2).map((d,m)=>({message:d,sequence:m+1}));return[...r===null?s:s.slice(-r)].sort((d,m)=>m.sequence-d.sequence)}function n2({messages:t,orchestration:r,busy:s,maxMessages:l=6,showControls:d=!0,showHeader:m=!0,onModeChange:f,onMarkAllDone:o}){const[c,u]=ee.useState(null),g=ff(t),h=(r==null?void 0:r.mode)??"auto",S=t2(t,l);async function x(T){await s2(T.body),u(T.id),window.setTimeout(()=>u(E=>E===T.id?null:E),1200)}return C.jsxs("section",{className:"message-panel",children:[m?C.jsxs("div",{className:"message-panel-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[g.total," total / ",g.accepted," accepted"]})]}),d&&f?C.jsx("div",{className:"message-controls",children:C.jsx(Rn,{checked:h==="auto",className:"message-mode-toggle",disabled:s,label:"Auto orchestration",onChange:T=>f(T?"auto":"manual")})}):null,d&&o?C.jsx("button",{type:"button",disabled:s,onClick:o,children:"Mark All Done"}):null]}):null,t.length===0?C.jsx("p",{className:"muted",children:"No role messages yet."}):C.jsx("ol",{className:"message-list",children:S.map(({message:T,sequence:E})=>C.jsxs("li",{className:"message-item",children:[C.jsxs("div",{className:"message-item-main",children:[C.jsxs("div",{className:"message-meta",children:[C.jsxs("span",{className:"message-sequence",children:["#",E]}),C.jsx("time",{dateTime:$o(T),children:i2($o(T))}),C.jsxs("strong",{children:[T.fromRole," ","->"," ",T.toRole]}),C.jsx("span",{children:T.type})]}),C.jsx("p",{children:T.body}),T.failureReason?C.jsx("span",{className:"message-reason",children:T.failureReason}):null,T.bodyPath?C.jsx("span",{className:"message-path",children:T.bodyPath}):null]}),C.jsx("div",{className:"message-actions",children:C.jsx("button",{type:"button",disabled:s,onClick:()=>void x(T),children:c===T.id?"Copied":"Copy"})})]},T.id))})]})}function i2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function $o(t){return t.acceptedAt??t.deliveredAt??t.dispatchingAt??t.createdAt}function r2(t,r){const s=$o(t).localeCompare($o(r));if(s!==0)return s;const l=t.createdAt.localeCompare(r.createdAt);return l!==0?l:t.id.localeCompare(r.id)}async function s2(t){var s;if((s=navigator.clipboard)!=null&&s.writeText){await navigator.clipboard.writeText(t);return}const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),r.remove()}function a2({defaultPath:t="",recentPaths:r=[],busy:s=!1,onConnect:l}){const[d,m]=ee.useState(t);ee.useEffect(()=>{t&&m(t)},[t]);async function f(o){o.preventDefault(),await l(d)}return C.jsx("form",{className:"repo-connect",onSubmit:f,children:C.jsxs("div",{className:r.length>0?"inline-form has-recent-paths":"inline-form",children:[C.jsx("input",{"aria-label":"Repository path",id:"repo-path",value:d,onChange:o=>m(o.target.value),placeholder:"/path/to/repo"}),r.length>0?C.jsxs("select",{"aria-label":"Recent repositories",className:"repo-recent-select",value:"",onChange:o=>{o.target.value&&m(o.target.value)},children:[C.jsx("option",{value:"",children:"Recent"}),r.map(o=>C.jsx("option",{value:o,children:o},o))]}):null,C.jsx("button",{type:"submit",disabled:s||!d.trim(),children:"Connect"})]})})}function l2({tasks:t,activeTaskSlug:r,onSelect:s}){return C.jsx("nav",{className:"task-nav","aria-label":"Tasks",children:t.map(l=>C.jsxs("button",{className:l.taskSlug===r?"task-nav-item is-active":"task-nav-item",type:"button",onClick:()=>s(l.taskSlug),children:[C.jsx("span",{children:l.title||l.taskSlug}),C.jsx($n,{status:l.status})]},l.taskSlug))})}function o2({open:t,taskSlug:r,taskTitle:s,onClose:l}){const[d,m]=ee.useState(null),[f,o]=ee.useState(!1),[c,u]=ee.useState(null),g=ee.useCallback(async()=>{o(!0),u(null);try{m(await ye.getTaskUsageAnalytics(r))}catch(h){u(`Load task usage analytics failed. Reason: ${ml(h)}`)}finally{o(!1)}},[r]);return ee.useEffect(()=>{t&&g()},[g,t]),t?C.jsx("div",{className:"modal-backdrop usage-analytics-backdrop",children:C.jsxs("section",{className:"usage-analytics-modal",role:"dialog","aria-modal":"true","aria-label":"Usage Analytics",children:[C.jsxs("header",{className:"usage-analytics-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Usage Analytics"}),C.jsxs("p",{children:[(s==null?void 0:s.trim())||r," · Claude models only"]})]}),C.jsxs("div",{className:"usage-analytics-header-actions",children:[C.jsx("button",{type:"button",disabled:f,onClick:()=>void g(),children:f?"Refreshing...":"Refresh"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),c?C.jsx("p",{className:"inline-error usage-analytics-error",children:c}):null,d?C.jsx(c2,{report:d}):C.jsx("div",{className:"usage-analytics-empty",children:f?"Loading usage data...":"No usage data available."})]})}):null}function c2({report:t}){return C.jsxs("div",{className:"usage-analytics-content",children:[C.jsxs("div",{className:"usage-analytics-meta",children:[C.jsx("span",{children:t.updatedAt?`Updated ${h2(t.updatedAt)}`:"No Claude usage recorded yet"}),C.jsxs("span",{children:[mn(t.totals.requestCount)," requests · ",mn(t.totals.sessionCount)," sessions"]})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-task-summary",children:[C.jsx("h3",{id:"usage-task-summary",children:"Task Summary"}),C.jsx(u2,{totals:t.totals})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-role",children:[C.jsx("h3",{id:"usage-by-role",children:"Usage by Role"}),C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(n_,{firstColumn:"Role"})}),C.jsx("tbody",{children:t.byRole.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:lS(r.role).label}),C.jsxs("small",{children:[mn(r.requestCount)," requests · ",mn(r.sessionCount)," sessions"]})]}),C.jsx(i_,{totals:r})]},r.role))})]})})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-model",children:[C.jsx("h3",{id:"usage-by-model",children:"Usage by Model"}),t.byModel.length>0?C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(n_,{firstColumn:"Model"})}),C.jsx("tbody",{children:t.byModel.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:r.model}),C.jsxs("small",{children:[mn(r.requestCount)," requests · ",mn(r.sessionCount)," sessions"]})]}),C.jsx(i_,{totals:r})]},r.model))})]})}):C.jsx("p",{className:"usage-analytics-no-models",children:"No Claude model usage recorded yet."})]})]})}function u2({totals:t}){return C.jsxs("dl",{className:"usage-totals-grid",children:[C.jsx(il,{label:"Input Tokens",value:mn(t.inputTokens)}),C.jsx(il,{label:"Output Tokens",value:mn(t.outputTokens)}),C.jsx(il,{label:"Cache Read",value:mn(t.cacheReadTokens)}),C.jsx(il,{label:"Cache Creation",value:mn(t.cacheCreationTokens)}),C.jsx(il,{label:"Estimated Cost",value:Iv(t.costUsd)})]})}function il({label:t,value:r}){return C.jsxs("div",{children:[C.jsx("dt",{children:t}),C.jsx("dd",{children:r})]})}function n_({firstColumn:t}){return C.jsxs("tr",{children:[C.jsx("th",{scope:"col",children:t}),C.jsx("th",{scope:"col",children:"Input"}),C.jsx("th",{scope:"col",children:"Output"}),C.jsx("th",{scope:"col",children:"Cache Read"}),C.jsx("th",{scope:"col",children:"Cache Creation"}),C.jsx("th",{scope:"col",children:"Estimated Cost"})]})}function i_({totals:t}){return C.jsxs(C.Fragment,{children:[C.jsx("td",{children:mn(t.inputTokens)}),C.jsx("td",{children:mn(t.outputTokens)}),C.jsx("td",{children:mn(t.cacheReadTokens)}),C.jsx("td",{children:mn(t.cacheCreationTokens)}),C.jsx("td",{children:Iv(t.costUsd)})]})}function mn(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function Iv(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(t)}function h2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f2({project:t,recentRepositoryPaths:r,tasks:s,activeTaskSlug:l,messages:d,orchestration:m,events:f,roundState:o,gateReview:c,workflowControlState:u,translationEnabled:g,translationAutoSendEnabled:h,translationTargetLanguage:S,translationOutputMode:x,translationMemoryInitialized:T,translatorSession:E,harnessStatus:y,harnessBootstrapStatus:_,harnessApplyResult:v,harnessEngineerLaunchOptions:b,autoTaskHarnessReviewEnabled:k,autoMemoryEnabled:L,architectWorkerSettings:R,gatewayStatus:D,gatewayQrLogin:A,gatewayQrCheck:M,gatewayLarkRegistration:O,gatewayLarkRegistrationCheck:H,codexBridgeStatus:U,modelOptions:P,busy:W,onConnect:K,onRefreshConnectedRepository:V,onPullConnectedRepository:Y,onRefreshHarness:te,onApplyHarness:z,onStartHarnessBootstrap:j,onRestartHarnessBootstrap:N,onStopHarnessBootstrap:q,onRunHarnessBootstrap:I,onOpenHarnessStudio:ie,onOpenRepositoryDiff:pe,onAutoTaskHarnessReviewChange:_e,onAutoMemoryChange:Q,onArchitectWorkerSettingsChange:$,onHarnessEngineerLaunchOptionsChange:he,onRefreshGateway:ae,onGatewayEnabledChange:Ce,onGatewaySettingsChange:be,onCodexBridgeSettingsChange:Oe,onCodexBridgeCheck:Ie,onGatewayTranslationChange:Ue,onGatewayConnectionChange:Ee,onStartGatewayQrLogin:ce,onStartGatewayLarkRegistration:He,onResetGatewayBinding:xt,onGateReviewGateEnabledChange:ge,onCancelGateReviewGate:je,onTranslationEnabledChange:Fe,onTranslationAutoSendChange:dt,onTranslationTargetLanguageChange:rt,onTranslationOutputModeChange:Et,onOpenFileTranslation:fe,onOpenTranslatorSession:we,onCreateTranslationBootstrap:Te,onUpdateTranslationMemory:Ne,onCreateTask:Pe,onCloseTask:St,onSelectTask:Ve,themeMode:bt,onAutoOrchestrationChange:Ct,onThemeModeChange:Nt,pauseAlertSound:Ze,onPauseAlertSoundChange:_n,roleRetryEnabled:en,onRoleRetryEnabledChange:ss,permissionRequestMode:Gi,onPermissionRequestModeChange:Dn,launchTemplate:mi,canSaveLaunchTemplate:vn,canOneClickStart:Vi,onSaveLaunchTemplate:ei,onOneClickStart:ta,onMarkAllMessagesDone:Tr,onConfirmDeliveredDispatch:Rr,onDeleteMessageHistory:Gn}){var Wi;const[ti,tn]=ee.useState(""),[gi,_i]=ee.useState(!1),[ni,ii]=ee.useState(!1),[vi,yi]=ee.useState(!1),[zt,st]=ee.useState(()=>l?null:"repository"),kt=ff(d),It=ti.trim(),Vn=_2(t,l,y),ri=s.filter(Me=>Me.cleanupStatus!=="cleaned"),qt=ri.find(Me=>Me.taskSlug===l)??null;ee.useEffect(()=>{st(Me=>!l&&Me===null?t?"task":"repository":Me)},[l,t]);function nn(Me,ai){st(ai?Me:null)}async function si(Me){Me.preventDefault(),await Pe({taskSlug:It}),tn("")}return C.jsxs("div",{className:"project-dashboard",children:[C.jsx("header",{className:"brand-header",children:C.jsx("strong",{children:"VibeCodingMaster"})}),C.jsx(es,{title:"Repository",warningCount:t==null?void 0:t.warnings.length,open:zt==="repository",onOpenChange:Me=>{nn("repository",Me),Me&&t&&V()},children:C.jsxs("div",{className:"repository-panel",children:[C.jsx(a2,{defaultPath:(t==null?void 0:t.repoRoot)??"",recentPaths:r,busy:W,onConnect:K}),t?C.jsx(b2,{busy:W,project:t,onPull:Y}):null]})}),C.jsx(es,{title:"Settings",open:zt==="settings",onOpenChange:Me=>nn("settings",Me),children:C.jsxs("div",{className:"sidebar-settings",children:[C.jsxs("button",{"aria-label":`Theme mode: ${s_(bt)}`,className:"settings-toggle theme-mode-toggle",disabled:W,title:"Cycle theme: system, light, dark",type:"button",onClick:()=>Nt(k2(bt)),children:[C.jsx("span",{children:"Theme"}),C.jsx("span",{children:s_(bt)})]}),C.jsx(Rn,{checked:((m==null?void 0:m.mode)??"auto")==="auto",className:"sidebar-switch",disabled:W||!l,label:"Auto orchestration",title:l?"Automatically dispatch role messages during the active task":"Create or select a task first",onChange:Ct}),C.jsx(Rn,{checked:Ze,className:"sidebar-switch",disabled:W,label:"Pause alert sound",title:"Play a sound when VCM shows the fixed flow pause dialog",onChange:Me=>_n(Me)}),C.jsx(Rn,{checked:en,className:"sidebar-switch",disabled:W,label:"CC auto retry",title:"Retry temporary Claude Code turn failures before showing the flow pause alert",onChange:Me=>ss(Me)}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Permission requests"}),C.jsxs("select",{value:Gi,disabled:W,onChange:Me=>Dn(Me.target.value),children:[C.jsx("option",{value:"off",children:"off"}),C.jsx("option",{value:"allowAll",children:"allow all"})]})]}),C.jsx(p2,{busy:W,status:U,onCheck:Ie,onSettingsChange:Oe}),C.jsxs("button",{className:"settings-toggle",disabled:W||!vn,title:"Save the current core role launch settings and optional Reviewer settings",type:"button",onClick:ei,children:[C.jsx("span",{children:"Save launch template"}),C.jsx("span",{children:vn?"ready":"open task"})]}),Vi?C.jsxs("button",{className:"settings-toggle is-active",disabled:W,title:d2(mi),type:"button",onClick:ta,children:[C.jsx("span",{children:"One-click start"}),C.jsx("span",{children:Uv(mi)})]}):null,l?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",onClick:()=>_i(!0),children:[C.jsx("span",{children:"Messages"}),C.jsxs("span",{className:"muted",children:[kt.total," total"]})]}),C.jsxs("button",{type:"button",onClick:()=>ii(!0),children:[C.jsx("span",{children:"Events"}),C.jsxs("span",{className:"muted",children:[f.length," total"]})]})]}):null]})}),C.jsx(es,{title:"Translation",open:zt==="translation",onOpenChange:Me=>nn("translation",Me),children:C.jsx(m2,{busy:W,enabled:g,autoSendEnabled:h,targetLanguage:S,outputMode:x,memoryInitialized:T,baseUnavailableReason:Vn,translatorSession:E,onAutoSendChange:dt,onCreateBootstrap:Te,onEnabledChange:Fe,onUpdateMemory:Ne,onTargetLanguageChange:rt,onOutputModeChange:Et,onOpenFileTranslation:fe,onOpenTranslatorSession:we})}),t&&l?C.jsx(es,{title:"Gate Review Gates",open:zt==="gate-review-gates",onOpenChange:Me=>nn("gate-review-gates",Me),children:C.jsx(v2,{busy:W,state:c,onCancelGateReview:je,onGateEnabledChange:ge})}):null,C.jsx(es,{title:"Gateway",open:zt==="gateway",onOpenChange:Me=>{nn("gateway",Me),Me&&ae()},children:C.jsx(S2,{busy:W,qrCheck:M,qrLogin:A,larkRegistration:O,larkRegistrationCheck:H,status:D,onEnabledChange:Ce,onSettingsChange:be,onResetBinding:xt,onStartLarkRegistration:He,onStartQrLogin:ce,onTranslationChange:Ue,onConnectionChange:Ee})}),t?C.jsx(es,{title:"VCM Harness",open:zt==="vcm-harness",onOpenChange:Me=>nn("vcm-harness",Me),children:C.jsx(Zk,{status:y,bootstrapStatus:_,applyResult:v,hasActiveTask:!!qt,autoTaskHarnessReviewEnabled:k,autoMemoryEnabled:L,architectWorkerSettings:R,launchOptions:b,modelOptions:P,busy:W,onRefresh:te,onApply:z,onOpenStudio:ie,onOpenRepositoryDiff:pe,onAutoTaskHarnessReviewChange:_e,onAutoMemoryChange:Q,onArchitectWorkerSettingsChange:$,onLaunchOptionsChange:he,onStartBootstrap:j,onRestartBootstrap:N,onStopBootstrap:q,onRunBootstrap:I})}):null,t?C.jsx(es,{title:"Task",open:zt==="task",onOpenChange:Me=>nn("task",Me),children:ri.length>0?C.jsxs("div",{className:"task-panel",children:[C.jsx(l2,{tasks:ri,activeTaskSlug:l,onSelect:Ve}),qt&&u&&u.warnings.length>0?C.jsxs("div",{className:"warnings",role:"status",children:[u.warnings.map(Me=>C.jsx("p",{children:Me},Me)),((Wi=u.pendingDispatch)==null?void 0:Wi.status)==="dispatching"&&u.pendingDispatch.confirmationError&&u.pendingDispatch.messageId?C.jsx("button",{type:"button",disabled:W,title:"Confirm that this message already executed in the target session without sending it again",onClick:()=>Rr(qt.taskSlug,u.pendingDispatch.messageId),children:"Confirm Executed"}):null]}):null,qt?C.jsxs("div",{className:"task-panel-actions",children:[C.jsx("button",{type:"button",onClick:()=>yi(!0),children:"Usage Analytics"}),C.jsx("button",{className:"danger-button",disabled:W,type:"button",onClick:St,children:"Close Task"})]}):null]}):C.jsx("div",{className:"task-create",children:C.jsxs("form",{onSubmit:si,children:[C.jsx("input",{value:ti,onChange:Me=>tn(Me.target.value),placeholder:"task name"}),C.jsxs("div",{className:"task-create-preview",children:[C.jsxs("small",{children:["branch: ",It?`feature/${It}`:"feature/<task>"]}),C.jsxs("small",{children:["worktree: ",It?`.claude/worktrees/${It}`:".claude/worktrees/<task>"]})]}),C.jsx("button",{type:"submit",disabled:W||!It,children:"Create"})]})})}):null,t&&qt?C.jsx(x2,{task:qt,roundState:o}):null,gi?C.jsx(T2,{busy:W,messages:d,orchestration:m,onClose:()=>_i(!1),onMarkAllDone:()=>{l&&Tr(l)},onDeleteMessageHistory:()=>{l&&Gn(l)}}):null,ni?C.jsx(A2,{events:f,onClose:()=>ii(!1)}):null,qt?C.jsx(o2,{open:vi,taskSlug:qt.taskSlug,taskTitle:qt.title,onClose:()=>yi(!1)}):null]})}function Uv(t){return[t.autoOrchestration?"auto":"manual"].join(" + ")}function d2(t){const r=Object.entries(t.roles).map(([s,l])=>`${s}: ${l.permissionMode} / ${l.model} / ${l.effort}`).join("; ");return`Launch template: ${Uv(t)}; ${r}`}function p2({busy:t,status:r,onCheck:s,onSettingsChange:l}){const[d,m]=ee.useState(""),f=!!(r!=null&&r.apiKeyConfigured),o=async c=>{c.preventDefault();const u=d.trim();u&&(await l({apiKey:u}),m(""))};return C.jsxs("div",{className:"codex-bridge-settings",children:[C.jsx(Rn,{checked:!!(r!=null&&r.enabled),className:"sidebar-switch",disabled:t||!f,label:"Codex Bridge models",title:f?"Enable Codex models through Codex Bridge":"Save the Codex Bridge API key first",onChange:c=>void l({enabled:c})}),C.jsxs("form",{className:"codex-bridge-api-key-form",onSubmit:c=>void o(c),children:[C.jsx("label",{htmlFor:"codex-bridge-api-key",children:"Codex Bridge API key"}),C.jsxs("div",{children:[C.jsx("input",{id:"codex-bridge-api-key",type:"password",autoComplete:"off",disabled:t,placeholder:f?"Saved":"Required",value:d,onChange:c=>m(c.target.value)}),C.jsx("button",{type:"submit",disabled:t||!d.trim(),children:"Save"})]})]}),C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Codex Bridge status"}),C.jsx("strong",{children:(r==null?void 0:r.connectionState)??"loading"})]}),C.jsxs("div",{className:"codex-bridge-actions",children:[C.jsx("button",{type:"button",disabled:t||!(r!=null&&r.enabled),onClick:()=>void s(),children:"Check"}),C.jsx("button",{type:"button",disabled:t||!f,onClick:()=>void l({clearApiKey:!0}),children:"Clear key"})]}),r!=null&&r.error?C.jsx("p",{className:"settings-help-text",children:r.error}):null]})}function m2({autoSendEnabled:t,baseUnavailableReason:r,busy:s,enabled:l,memoryInitialized:d,outputMode:m,targetLanguage:f,translatorSession:o,onAutoSendChange:c,onCreateBootstrap:u,onEnabledChange:g,onUpdateMemory:h,onOutputModeChange:S,onTargetLanguageChange:x,onOpenFileTranslation:T,onOpenTranslatorSession:E}){const y=!!(s||r),_=(o==null?void 0:o.status)==="running",v=!!(l&&!r&&_),b=r??(_?null:"Start Translator session first."),k=!!(s||b),R=r??"Open Translator session",D=b??"Translation tools are ready";return C.jsxs("div",{className:"sidebar-settings",children:[C.jsx(Rn,{checked:v,className:"sidebar-switch",disabled:y||!_,label:"Conversation translation",title:D,onChange:g}),C.jsx(Rn,{checked:t,className:"sidebar-switch",disabled:y,label:"Auto-send",onChange:c}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Language"}),C.jsx("select",{value:f,disabled:y,onChange:A=>x(A.target.value),children:b_.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Reply scope"}),C.jsx("select",{value:m,disabled:y,onChange:A=>S(A.target.value),children:pS.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:T,children:[C.jsx("span",{children:"File translation"}),C.jsx("span",{children:"open"})]}),d?null:C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:u,children:[C.jsx("span",{children:"Bootstrap"}),C.jsx("span",{children:"run"})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:h,children:[C.jsx("span",{children:"Update memory"}),C.jsx("span",{children:"run"})]}),b?C.jsx("p",{className:"settings-help-text",children:b}):null,C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Session status"}),C.jsx("strong",{children:g2(o)})]}),C.jsxs("button",{className:"settings-toggle",disabled:y,title:R,type:"button",onClick:E,children:[C.jsx("span",{children:"Open Session"}),C.jsx("span",{children:"open"})]})]})}function g2(t){return t?t.status==="running"?t.activityStatus??"idle":t.status:"not started"}function _2(t,r,s){return t?r?s?s.initialized?null:"Initialize VCM Harness first.":"Load VCM Harness status first.":"Create or select a task first.":"Connect a repository first."}function v2({busy:t,onCancelGateReview:r,onGateEnabledChange:s,state:l}){return C.jsx("div",{className:"sidebar-settings",children:Qk.map(d=>{const m=l==null?void 0:l.gates[d],f=!!(m!=null&&m.required);return C.jsxs("div",{className:"gate-review-setting",children:[C.jsx(Rn,{checked:f,className:"sidebar-switch",disabled:t||!l||(m==null?void 0:m.status)==="running",label:y2(d),title:m!=null&&m.status?`status: ${m.status}`:void 0,onChange:o=>s(d,o)}),(m==null?void 0:m.status)==="running"&&m.requestId?C.jsx("button",{className:"danger-button",disabled:t,type:"button",onClick:()=>r(d,m.requestId),children:"Cancel review"}):null]},d)})})}function y2(t){switch(t){case"architecture-plan":return"Architecture plan";case"validation-adequacy":return"Validation adequacy";case"code-diff":return"Code diff"}return t}function S2({busy:t,larkRegistration:r,larkRegistrationCheck:s,onEnabledChange:l,onResetBinding:d,onSettingsChange:m,onStartLarkRegistration:f,onStartQrLogin:o,onTranslationChange:c,onConnectionChange:u,qrCheck:g,qrLogin:h,status:S}){const x=(S==null?void 0:S.channel)==="lark",T=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured),E=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured);return C.jsxs("div",{className:"gateway-panel",children:[C.jsxs("label",{className:"compact-field",children:[C.jsx("span",{children:"Channel"}),C.jsxs("select",{disabled:t||!S,value:(S==null?void 0:S.channel)??"weixin-ilink",onChange:y=>{m({channel:y.currentTarget.value==="lark"?"lark":"weixin-ilink"})},children:[C.jsx("option",{value:"weixin-ilink",children:"Weixin iLink"}),C.jsx("option",{value:"lark",children:"Lark"})]})]}),C.jsxs("div",{className:"gateway-actions",children:[C.jsx(Rn,{checked:!!(S!=null&&S.connectionEnabled),className:"sidebar-switch",disabled:t||!S||!S.connectionEnabled&&!T,label:"Connection",stateLabel:S!=null&&S.connectionEnabled?"connected":"off",title:T?"Connect or disconnect the channel for this session. Off by default; the phone can drive the gateway only while Connection is on. Separate from the Gateway command switch.":"Configure the selected Gateway channel first",onChange:y=>u(y)}),C.jsx(Rn,{checked:!!(S!=null&&S.enabled),className:"sidebar-switch",disabled:t||!S||!S.enabled&&!T,label:"Gateway",title:T?"Enable or disable role messages and task-changing Gateway commands":"Configure the selected Gateway channel first",onChange:y=>l(y)}),C.jsx(Rn,{checked:!!(S!=null&&S.translationEnabled),className:"sidebar-switch",disabled:t||!S,label:"Translation",onChange:y=>c(y)}),x?C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Start QR Setup"}):E?C.jsx("button",{className:"danger-button",type:"button",disabled:t,onClick:d,children:"Reset Binding"}):C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Start QR Login"})]}),x?C.jsxs("div",{className:"gateway-lark-settings",children:[C.jsx("p",{className:"muted",children:S!=null&&S.binding.appIdConfigured&&S.binding.appSecretConfigured?`Lark app configured${S.binding.larkBotName?` · ${S.binding.larkBotName}`:""}.`:"Use QR setup to create and configure the Lark bot automatically."}),r?C.jsxs("p",{className:"muted",children:["QR setup: ",(s==null?void 0:s.status)??r.status,s!=null&&s.message?` · ${s.message}`:""]}):null]}):h?C.jsx("p",{className:"muted",children:"QR login started. Use the login dialog to confirm binding."}):null,!x&&g?C.jsxs("p",{className:"muted",children:["QR status: ",g.status,g.message?` · ${g.message}`:""]}):null]})}function b2({busy:t,onPull:r,project:s}){const l=s.pullDisabledReason,d=!!s.canPull;return C.jsxs("div",{className:"project-summary",children:[C.jsxs("dl",{children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Base path"}),C.jsx("dd",{children:s.repoRoot})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Branch"}),C.jsx("dd",{children:C2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Remote"}),C.jsx("dd",{children:s.upstreamBranch??"no upstream"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Status"}),C.jsx("dd",{children:w2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Commit"}),C.jsx("dd",{children:s.shortHeadCommit??s.headCommit??"unknown"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Working tree"}),C.jsx("dd",{children:s.isDirty?"uncommitted changes":"clean"})]})]}),C.jsxs("div",{className:"connected-repo-actions",children:[C.jsx("button",{type:"button",disabled:t||!d,title:l??"Pull latest changes with git pull --ff-only",onClick:()=>void r(),children:"Pull"}),C.jsx("span",{className:"muted",children:s.checkedAt?`checked ${qh(s.checkedAt)}`:"status not refreshed"})]}),l?C.jsx("p",{className:"muted",children:l}):null,s.warnings.length>0?C.jsx("ul",{className:"warnings",children:s.warnings.map(m=>C.jsx("li",{children:m},m))}):null]})}function C2(t){return t.branch||"unknown"}function w2(t){if(!t.upstreamBranch)return"no upstream";const r=t.ahead??0,s=t.behind??0;return r===0&&s===0?"up to date":r>0&&s>0?`ahead ${r}, behind ${s}`:r>0?`ahead ${r}`:`behind ${s}`}function x2({roundState:t,task:r}){var g;const[s,l]=ee.useState(()=>Date.now()),d=!!(t!=null&&t.startedAt),m=Pv(r.createdAt,s),f=r_(t,(t==null?void 0:t.totalCcActiveMs)??0,s),o=d&&t?r_(t,t.currentRoundCcActiveMs,s):0,c=d&&t?E2(t,s):0,u=((g=r.title)==null?void 0:g.trim())||r.taskSlug;return ee.useEffect(()=>{const h=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(h)},[]),C.jsxs("section",{className:"task-status-dock","aria-label":"VCM Session status",children:[C.jsxs("div",{className:"task-status-dock-title",children:[C.jsx("strong",{title:u,children:u}),C.jsx("span",{className:`status-badge status-${r.status}`,children:r.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Session start"}),C.jsx("dd",{children:qh(r.createdAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Session total"}),C.jsx("dd",{children:Bo(m)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Rounds"}),C.jsx("dd",{children:(t==null?void 0:t.totalRoundCount)??0})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Bo(f)})]})]}),d&&t?C.jsxs("div",{className:"current-round-status",children:[C.jsxs("div",{className:"current-round-title",children:[C.jsx("span",{children:t.status==="running"?"Current Round":"Last Round"}),C.jsx("span",{className:`status-badge status-${t.status}`,children:t.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Started"}),C.jsx("dd",{children:qh(t.startedAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Total"}),C.jsx("dd",{children:Bo(c)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Bo(o)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Turn count"}),C.jsx("dd",{children:t.turnCount})]})]})]}):null]})}function r_(t,r,s){if(!(t!=null&&t.activeTurnStartedAt)||t.status!=="running")return r;const l=Date.parse(t.updatedAt);return Number.isFinite(l)?r+Math.max(0,s-l):r}function E2(t,r){const s=t.status==="running"?r:Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return Pv(t.startedAt??"",Number.isFinite(s)?s:r)}function Pv(t,r){const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,r-s):0}function qh(t){if(!t)return"-";const r=new Date(t);return Number.isNaN(r.getTime())?"-":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(r)}function Bo(t){const r=Math.max(0,Math.floor(t/1e3)),s=Math.floor(r/3600),l=Math.floor(r%3600/60),d=r%60;return s>0?l>0?`${s}h ${l}m`:`${s}h`:l>0?d>0?`${l}m ${d}s`:`${l}m`:`${d}s`}function k2(t){return t==="system"?"light":t==="light"?"dark":"system"}function s_(t){return t==="system"?"System":t==="light"?"Light":"Dark"}function A2({events:t,onClose:r}){return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"event-modal",role:"dialog","aria-modal":"true","aria-label":"Events",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Events"}),C.jsxs("p",{className:"muted",children:[t.length," total"]})]}),C.jsx("button",{type:"button",onClick:r,children:"Close"})]}),C.jsx(Jk,{events:t,maxEvents:null,showHeader:!1})]})})}function T2({busy:t,messages:r,orchestration:s,onClose:l,onMarkAllDone:d,onDeleteMessageHistory:m}){const f=ff(r);function o(){window.confirm(["Clear all pending route-file messages?","","Use this only after you manually copied or handled stuck route-file messages.","VCM will clear non-empty handoff message files so Stop-hook orchestration can continue."].join(`
|
|
94
94
|
`))&&d()}function c(){window.confirm([`Delete ${f.total} message histor${f.total===1?"y item":"y items"}?`,"","This removes message history from the Messages panel.","Pending route-file messages are not touched."].join(`
|
|
95
|
-
`))&&m()}return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"message-modal",role:"dialog","aria-modal":"true","aria-label":"Messages",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[f.total," total / ",f.accepted," accepted",s?` · ${s.mode}`:""]})]}),C.jsxs("div",{className:"modal-actions",children:[C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Mark All Done"}),C.jsx("button",{type:"button",disabled:t||f.total===0,onClick:c,children:"Delete All"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),C.jsx(n2,{busy:t,maxMessages:null,messages:r,orchestration:s,showControls:!1,showHeader:!1})]})})}function es({children:t,onOpenChange:r,open:s,title:l}){return C.jsxs("section",{className:"sidebar-section",children:[C.jsxs("button",{"aria-expanded":s,className:"sidebar-section-toggle",type:"button",onClick:()=>{r==null||r(!s)},children:[C.jsx("span",{children:l}),C.jsx("span",{"aria-hidden":"true",className:"sidebar-section-chevron"})]}),s?C.jsx("div",{className:"sidebar-section-content",children:t}):null]})}function Fv(t,r){return t.find(s=>s.role===r)}function R2({activeRole:t,roles:r=Go,sessions:s,onSelect:l}){return C.jsx("div",{className:"role-tabs",role:"tablist","aria-label":"Role sessions",children:r.map(d=>{const m=Fv(s,d.name),f=(m==null?void 0:m.status)==="running"?m.activityStatus??"idle":(m==null?void 0:m.status)??"not_started";return C.jsxs("button",{className:d.name===t?"role-tab is-active":"role-tab",type:"button",role:"tab","aria-selected":d.name===t,onClick:()=>l(d.name),children:[C.jsx("span",{children:d.label}),C.jsx($n,{status:f})]},d.name)})})}function D2({role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,active:f=!0,busy:o,translationEnabled:c,translationAutoSendEnabled:u,translationTargetLanguage:g,translationPanelState:h,onClearTranslationSession:S,onTranslationEntry:x,onTranslationFailures:T,onPermissionModeChange:E,onModelChange:y,onEffortChange:_,onStart:v,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D,onTerminalEvent:A}){const M=S_(t)&&c&&(r==null?void 0:r.status)==="running";return C.jsx("section",{className:"session-console",children:C.jsxs("div",{className:M?"session-console-body has-translation":"session-console-body",children:[C.jsxs("div",{className:"terminal-pane",children:[C.jsx(Vh,{role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,busy:o,onPermissionModeChange:E,onModelChange:y,onEffortChange:_,onStart:v,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D}),(r==null?void 0:r.status)==="running"?C.jsx(Vo,{sessionId:r.id,active:f,onEvent:A},r.id):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:t}),C.jsx("span",{children:r!=null&&r.claudeSessionId?"Resume this role to reconnect its Claude Code conversation.":"Start this role to open an embedded Claude Code terminal."})]})]}),M?C.jsx("div",{className:"translation-pane",children:C.jsx(wk,{active:f,autoSendEnabled:u,targetLanguage:g,taskSlug:r.taskSlug,role:t,sessionId:r.id,panelState:h??{role:t,status:"ready",entries:[],failures:[]},onClearSession:S??(()=>{}),onEntry:x??(()=>{}),onFailures:T??(()=>{})},`${t}:${r.id}`)}):null]})})}const kh=500;function $h(t){return{taskSlug:t,cursor:1,sessions:{}}}function M2(t,r,s){return t.sessions[r]??Qs(s)}function L2(t,r){const l={...N2(t,r.taskSlug).sessions};for(const d of r.sessions)l[d.sessionId]={...Qs(d.role),...l[d.sessionId],role:d.role,status:d.status};for(const d of r.events){const m=l[d.sessionId]??Qs(d.role);if(d.event.type==="status")l[d.sessionId]={...m,role:d.role,status:d.event.status};else if(d.event.type==="failures")l[d.sessionId]={...m,role:d.role,failures:d.event.failures};else if(d.event.type==="entry"){const f=$v(qv(m.entries,d.event.entry));l[d.sessionId]={...m,role:d.role,entries:f.entries,failures:f.removedIds.size>0?m.failures.filter(o=>!f.removedIds.has(o.translationId)):m.failures}}}return{taskSlug:r.taskSlug,cursor:r.nextCursor,sessions:l}}function O2(t,r,s){return{...t,sessions:{...t.sessions,[r]:Qs(s)}}}function B2(t,r,s,l){const d=t.sessions[r]??Qs(s),m=$v(qv(d.entries,l));return{...t,sessions:{...t.sessions,[r]:{...d,role:s,entries:m.entries,failures:m.removedIds.size>0?d.failures.filter(f=>!m.removedIds.has(f.translationId)):d.failures}}}}function j2(t,r,s,l){const d=t.sessions[r]??Qs(s);return{...t,sessions:{...t.sessions,[r]:{...d,role:s,failures:l}}}}function N2(t,r){return t.taskSlug===r?t:$h(r)}function Qs(t){return{role:t,status:"ready",entries:[],failures:[]}}function qv(t,r){return t.findIndex(l=>l.id===r.id)===-1?[...t,r]:t.map(l=>l.id===r.id?r:l)}function $v(t){if(t.length<=kh)return{entries:t,removedIds:new Set};const r=t.slice(0,t.length-kh);return{entries:t.slice(-kh),removedIds:new Set(r.map(s=>s.id))}}const H2={"project-manager":"bypassPermissions",architect:"bypassPermissions",coder:"bypassPermissions",tester:"bypassPermissions",reviewer:"bypassPermissions",translator:"bypassPermissions","harness-engineer":"bypassPermissions"},z2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"default","harness-engineer":"default"},I2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"medium","harness-engineer":"medium"};function U2({task:t,activeRole:r,reviewerEnabled:s,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,launchTemplate:f,modelOptions:o,refreshNonce:c=0,onTaskChanged:u,onActiveRoleChange:g,onMessagesChanged:h,onOrchestrationChanged:S,onRoundStateChanged:x,onEventsChanged:T,onLaunchStateChanged:E}){const[y,_]=ee.useState(null),[v,b]=ee.useState(()=>l_(f)),[k,L]=ee.useState(()=>o_(f)),[R,D]=ee.useState(()=>c_(f)),[A,M]=ee.useState(!1),[,O]=qi(""),[H,U]=ee.useState([]),[P,W]=ee.useState(null),[K,V]=ee.useState(null),[Y,te]=ee.useState(null),[z,j]=ee.useState(()=>$h(t.taskSlug)),N=ee.useRef(""),q=ee.useRef(1),I=ee.useMemo(()=>JSON.stringify(f),[f]),ie=!!(y!=null&&y.sessions.some(Ee=>Ee.role==="reviewer")),pe=s||ie,_e=[...ul,...pe?[__]:[]],Q=ee.useCallback((Ee,ce)=>{W(ce),h==null||h(Ee),S==null||S(ce)},[h,S]),$=ee.useCallback((Ee,ce,He,xt,ge)=>{_(Ee),V(ge),Q(ce,He),x==null||x(xt)},[Q,x]),he=ee.useCallback(async()=>{const Ee=await ye.getTaskWorkspaceState(t.taskSlug);te(Ee.architectRestart),$(Ee.taskStatus,Ee.messages,Ee.orchestration,Ee.roundState,Ee.workflowState),qo("Poll task workspace state"),O(ce=>Ho(ce,["Load task workspace state","Poll task workspace state"]))},[$,t.taskSlug]),ae=ee.useCallback((Ee,ce)=>{const He=zv(Ee,ce);He&&O(He)},[]);pl(`task-workspace:${t.taskSlug}:${c}`,()=>he().catch(Ee=>{ae("Poll task workspace state",Ee)}),{intervalMs:3e3,runImmediately:!0}),pl(l?`task-translation-feed:${t.taskSlug}`:null,async()=>{try{const Ee=await ye.pollTranslationTaskFeed(t.taskSlug,q.current);q.current=Ee.nextCursor,j(ce=>L2(ce,Ee)),qo("Poll task translation feed"),O(ce=>Ho(ce,["Poll task translation feed"]))}catch(Ee){ae("Poll task translation feed",Ee)}},{intervalMs:1e3,runImmediately:!0}),ee.useEffect(()=>{U([]),V(null),T==null||T([])},[T,t.taskSlug]),ee.useEffect(()=>{q.current=1,j($h(t.taskSlug))},[t.taskSlug]),ee.useEffect(()=>{b(l_(f)),L(o_(f)),D(c_(f))},[I,t.taskSlug]),ee.useEffect(()=>{y&&!pe&&r==="reviewer"&&g("project-manager"),y&&r==="translator"&&g("project-manager")},[r,pe,g,y]),ee.useEffect(()=>{const Ee=y==null?void 0:y.task;if(!Ee||Ee.taskSlug!==t.taskSlug)return;const ce=a_(Ee);if(ce===a_(t)){N.current="";return}N.current!==ce&&(N.current=ce,u().catch(He=>{N.current="",O(ft("Refresh task list after task status changed",He))}))},[u,y==null?void 0:y.task,t]),ee.useEffect(()=>{const Ee=(y==null?void 0:y.sessions)??[],ce=Ee.filter(je=>P2(je.role)),He=new Set(ce.map(je=>je.role)),xt=Ee.some(je=>je.role==="reviewer"),ge={};for(const je of Js)ge[je.name]={permissionMode:v[je.name],model:k[je.name],effort:R[je.name]};E==null||E({taskSlug:t.taskSlug,roles:ge,autoOrchestration:((P==null?void 0:P.mode)??"auto")==="auto",statusLoaded:!!y,sessionCount:ce.length,hasAnySession:ce.length>0,hasReviewerSession:xt,allRolesHaveSession:ul.every(je=>He.has(je.name))})},[k,R,E,P==null?void 0:P.mode,v,y,t.taskSlug]);async function Ce(Ee,ce="Run role session action"){M(!0),O("");try{await Ee(),await he(),await u()}catch(He){O(ft(ce,He))}finally{M(!1)}}function be(Ee){U(ce=>{const He=[...ce,`${new Date().toLocaleTimeString()} ${Ee}`];return T==null||T(He),He})}function Oe(Ee,ce){b(He=>({...He,[Ee]:ce}))}function Ie(Ee,ce){L(He=>({...He,[Ee]:ce}))}function Ue(Ee,ce){D(He=>({...He,[Ee]:ce}))}return C.jsxs("div",{className:"task-workspace",children:[C.jsxs("header",{className:"workspace-header",children:[C.jsxs("div",{className:"workspace-title-line",children:[C.jsx("h1",{children:t.title||t.taskSlug}),K!=null&&K.declared?C.jsxs("div",{className:"workspace-workflow-state",title:[K.declared.branch?`Branch: ${K.declared.branch}`:"",K.declared.resumePoint?`Resume: ${K.declared.resumePoint}`:"",K.declared.status?`Status: ${K.declared.status}`:""].filter(Boolean).join(" | "),children:[C.jsx("span",{children:K.declared.flow??"Workflow"}),K.declared.step?C.jsx("strong",{children:K.declared.step}):null]}):null]}),C.jsx(R2,{activeRole:r,roles:_e,sessions:(y==null?void 0:y.sessions)??[],onSelect:g})]}),(Y==null?void 0:Y.status)==="blocked"&&Y.blocker?C.jsxs("div",{className:"workspace-runtime-warning",role:"alert",children:[C.jsx("strong",{children:"Architect restart blocked"}),C.jsx("span",{children:Y.blocker.message}),C.jsx("code",{children:Y.blocker.code})]}):null,C.jsx("div",{className:"workspace-grid",children:C.jsx("div",{className:"workspace-main",children:C.jsx("div",{className:"role-console-stack",children:_e.map(Ee=>{const ce=Ee.name,He=ce===r,xt=(y==null?void 0:y.sessions)??[],ge=Fv(xt,ce),je=ge?M2(z,ge.id,ce):void 0;return C.jsx("div",{className:He?"role-console-panel is-active":"role-console-panel","aria-hidden":!He,children:C.jsx(D2,{role:ce,session:ge,permissionMode:v[ce],model:k[ce],effort:R[ce],modelOptions:o,active:He,busy:A,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,translationPanelState:je,onClearTranslationSession:(Fe,dt)=>{j(rt=>O2(rt,Fe,dt))},onTranslationEntry:(Fe,dt,rt)=>{j(Et=>B2(Et,Fe,dt,rt))},onTranslationFailures:(Fe,dt,rt)=>{j(Et=>j2(Et,Fe,dt,rt))},onPermissionModeChange:Fe=>Oe(ce,Fe),onModelChange:Fe=>Ie(ce,Fe),onEffortChange:Fe=>Ue(ce,Fe),onStart:()=>void Ce(async()=>{await ye.startRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`started ${ce} with ${v[ce]} / ${k[ce]} / ${R[ce]}`)},`Start ${ce} session`),onResume:()=>void Ce(async()=>{await ye.resumeRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`resumed ${ce} with ${v[ce]} / ${k[ce]} / ${R[ce]}`)},`Resume ${ce} session`),onStop:()=>void Ce(async()=>{await ye.stopRoleSession(t.taskSlug,ce),be(`stopped ${ce}`)},`Stop ${ce} session`),onRestart:()=>void Ce(async()=>{await ye.restartRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with ${v[ce]} / ${k[ce]} / ${R[ce]}`)},`Restart ${ce} session`),onRestartWithContext:()=>void Ce(async()=>{S_(ce)&&(await ye.restartRoleSessionWithContext(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with task context`))},`Restart ${ce} session with task context`),onNotifyHarnessUpdated:()=>void Ce(async()=>{await ye.notifyRoleHarnessUpdated(t.taskSlug,ce),be(`notified ${ce} to reload latest harness`)},`Notify ${ce} to reload harness`),onTerminalEvent:Fe=>be(`${Ee.label}: ${Fe}`)})},ce)})})})})]})}function P2(t){return ul.some(r=>r.name===t)}function a_(t){return[t.status,t.updatedAt,t.cleanupStatus??"",t.cleanedAt??""].join(":")}function l_(t){var s;const r={...H2};for(const l of Js)r[l.name]=((s=t.roles[l.name])==null?void 0:s.permissionMode)??r[l.name];return r}function o_(t){var s;const r={...z2};for(const l of Js)r[l.name]=((s=t.roles[l.name])==null?void 0:s.model)??r[l.name];return r}function c_(t){var s;const r={...I2};for(const l of Js)r[l.name]=((s=t.roles[l.name])==null?void 0:s.effort)??r[l.name];return r}const F2=1400;function q2(t){return!!(t!=null&&t.initialized)}function $2(){const[t,r]=ee.useState(null),[s,l]=ee.useState([]),[d,m]=ee.useState(null),[f,o]=ee.useState(null),[c,u]=ee.useState(null),[g,h]=ee.useState(null),[S,x]=ee.useState(null),[T,E]=ee.useState(null),[y,_]=ee.useState(null),[v,b]=ee.useState(null),[k,L]=ee.useState(null),[R,D]=ee.useState(null),[A,M]=ee.useState(null),[O,H]=ee.useState(null),[U,P]=ee.useState(!1),[W,K]=ee.useState(null),[V,Y]=ee.useState(null),[te,z]=ee.useState(!1),[j,N]=ee.useState([]),[q,I]=ee.useState(null),[ie,pe]=ee.useState(null),[_e,Q]=ee.useState(null),[$,he]=ee.useState(null),[ae,Ce]=ee.useState(null),[be,Oe]=ee.useState(null),[Ie,Ue]=ee.useState(null),[Ee,ce]=ee.useState("project-manager"),[He,xt]=ee.useState("system"),[ge,je]=ee.useState(!0),[Fe,dt]=ee.useState(!0),[rt,Et]=ee.useState("off"),[fe,we]=ee.useState(!1),[Te,Ne]=ee.useState(!1),[Pe,St]=ee.useState(hS),[Ve,bt]=ee.useState(!1),[Ct,Nt]=ee.useState(!1),[Ze,_n]=ee.useState(fS),[en,ss]=ee.useState(dS),[Gi,Dn]=ee.useState(!1),[mi,vn]=ee.useState(!1),[Vi,ei]=ee.useState(!1),[ta,Tr]=ee.useState(!1),[Rr,Gn]=ee.useState(!1),[ti,tn]=ee.useState(null),[gi,_i]=ee.useState("bypassPermissions"),[ni,ii]=ee.useState("default"),[vi,yi]=ee.useState("medium"),[zt,st]=ee.useState(null),[kt,It]=ee.useState("bypassPermissions"),[Vn,ri]=ee.useState("default"),[qt,nn]=ee.useState("medium"),[si,Wi]=ee.useState(()=>mS()),[Me,ai]=ee.useState(null),[Dr,Si]=ee.useState(0),[_t,na]=ee.useState(null),[yl,bi]=ee.useState(null),[Ci,Jo]=ee.useState(!1),[Ki,ia]=ee.useState(!1),[,wi]=qi(""),Mr=ee.useRef({}),Yi=ee.useRef({}),Mn=ee.useRef({}),rn=ee.useRef({}),ra=ee.useRef({}),as=ee.useRef(null),ls=ee.useRef({initialized:!1,messageId:null}),os=ee.useRef(""),J=ee.useMemo(()=>Pk(j,q),[j,q]),on=(Me==null?void 0:Me.taskSlug)===(J==null?void 0:J.taskSlug)?Me:null,Kt=c===(J==null?void 0:J.taskSlug)?d:null,cs=g===(J==null?void 0:J.taskSlug)?f:null,Sl=v===(J==null?void 0:J.taskSlug)?y:null,sa=!!(t&&J&&q2(Kt)),Xi=(ti==null?void 0:ti.status)==="running",aa=!!(Ve&&sa&&Xi),bl=!!(on!=null&&on.statusLoaded),Qi=!!(J&&(on!=null&&on.statusLoaded)&&!on.hasAnySession),us=(R==null?void 0:R.modelOptions)??w_(),Ut=ee.useCallback((G,oe={})=>{xt(G.themeMode),je(G.flowPauseAlerts),dt(G.roleRetryEnabled),Et(G.permissionRequestMode),we(G.autoTaskHarnessReviewEnabled),Ne(G.autoMemoryEnabled),St(G.architectWorkerSettings),bt(G.translationEnabled),Nt(G.translationAutoSendEnabled),_n(G.translationTargetLanguage),ss(G.translationOutputMode),Wi(G.launchTemplate),oe.syncToolLaunchOptions&&(_i(G.toolSessionDefaults.translator.permissionMode),ii(G.toolSessionDefaults.translator.model),yi(G.toolSessionDefaults.translator.effort),It(G.toolSessionDefaults["harness-engineer"].permissionMode),ri(G.toolSessionDefaults["harness-engineer"].model),nn(G.toolSessionDefaults["harness-engineer"].effort))},[]);ee.useEffect(()=>{if(!ge)return;let G=!1;const oe=()=>{G||(G=!0,u_(),window.removeEventListener("pointerdown",oe),window.removeEventListener("keydown",oe))};return window.addEventListener("pointerdown",oe),window.addEventListener("keydown",oe),()=>{window.removeEventListener("pointerdown",oe),window.removeEventListener("keydown",oe)}},[ge]);const Ln=ee.useCallback(()=>{as.current!==null&&(window.clearInterval(as.current),as.current=null)},[]),hs=ee.useCallback(()=>{Ln(),h_(),as.current=window.setInterval(()=>{h_()},F2)},[Ln]),Cl=ee.useCallback((G,oe=`manual-${Date.now()}`)=>{na({id:oe,text:G})},[]),la=ee.useCallback(()=>{Ln(),na(null)},[Ln]);ee.useEffect(()=>{J!=null&&J.taskSlug&&(ra.current[J.taskSlug]=Date.now())},[J==null?void 0:J.taskSlug]);const fs=ee.useCallback(G=>{J!=null&&J.taskSlug&&pe({taskSlug:J.taskSlug,messages:G})},[J==null?void 0:J.taskSlug]),Wn=ee.useCallback(G=>{Mn.current[G.taskSlug]=G.mode,J!=null&&J.taskSlug&&Q({taskSlug:J.taskSlug,orchestration:G})},[J==null?void 0:J.taskSlug]),oa=ee.useCallback(G=>{J!=null&&J.taskSlug&&he({taskSlug:J.taskSlug,events:G})},[J==null?void 0:J.taskSlug]),ca=ee.useCallback(G=>{if(!(J!=null&&J.taskSlug)||G.taskSlug!==J.taskSlug)return;Ce({taskSlug:G.taskSlug,roundState:G});const oe=Fk({mode:Mn.current[G.taskSlug],status:G.status,activeRole:G.activeRole,lastFollowedRole:rn.current[G.taskSlug]});oe&&(rn.current[G.taskSlug]=oe,ce(oe));const Xe=qk(G,Y2);if(Xe===null){Yi.current[G.taskSlug]={status:G.status};return}const sn=$k(G),Ai=Mr.current[G.taskSlug],ic=Yi.current[G.taskSlug];Yi.current[G.taskSlug]={status:G.status},Ai!==sn&&(Mr.current[G.taskSlug]=sn,Gk(G,ic,ra.current[G.taskSlug])&&Cl(Xe,sn))},[J==null?void 0:J.taskSlug,Cl]),Ji=ee.useCallback(G=>{ai(oe=>(oe==null?void 0:oe.taskSlug)===G.taskSlug&&oe.statusLoaded===G.statusLoaded&&oe.sessionCount===G.sessionCount&&oe.hasAnySession===G.hasAnySession&&oe.hasReviewerSession===G.hasReviewerSession&&oe.allRolesHaveSession===G.allRolesHaveSession&&oe.autoOrchestration===G.autoOrchestration&&JSON.stringify(oe.roles)===JSON.stringify(G.roles)?oe:G)},[]);async function yn(){const G=await ye.listTasks();return N(G),I(oe=>{var Xe;return oe&&G.some(sn=>sn.taskSlug===oe)?oe:((Xe=G[0])==null?void 0:Xe.taskSlug)??null}),G}async function Lr(G=J==null?void 0:J.taskSlug){if(!G)return m(null),u(null),null;const oe=await ye.getHarnessStatus(G);return m(oe),u(G),oe}async function Or(G=J==null?void 0:J.taskSlug){if(!G)return o(null),h(null),null;const oe=await ye.getHarnessBootstrapStatus(G);return o(oe),h(G),oe}async function xi(){const G=await ye.getGatewayStatus();return L(G),G}async function Br(){const G=await ye.getRecentRepositoryPaths();return l(G),G}async function On(){if(!t)return Dn(!1),!1;const G=await ye.getTranslationState();return Dn(G.memoryInitialized),G.memoryInitialized}async function Zi(G){const[oe,Xe]=await Promise.all([ye.listMessages(G),ye.getOrchestrationState(G)]);pe({taskSlug:G,messages:oe}),Q({taskSlug:G,orchestration:Xe})}async function er(G){const oe=await ye.getGateReviewState(G);return Oe({taskSlug:G,state:oe}),qo("Poll Gate Review state"),wi(Xe=>Ho(Xe,["Refresh Gate Review state","Poll Gate Review state"])),oe}function Kn(G,oe){const Xe=zv(G,oe);Xe&&wi(Xe)}function li(G){G&&(_i(G.permissionMode),G.model&&ii(G.model),G.effort&&yi(G.effort))}async function jr(G={}){const oe=await ye.getTranslatorSession((J==null?void 0:J.taskSlug)??null);return tn(oe),G.syncLaunchOptions&&li(oe),oe}function oi(G){G&&(It(G.permissionMode),G.model&&ri(G.model),G.effort&&nn(G.effort))}async function Yn(G={}){const oe=await ye.getHarnessEngineerSession((J==null?void 0:J.taskSlug)??null);return st(oe),G.syncLaunchOptions&&oi(oe),oe}async function ds(G=J==null?void 0:J.taskSlug){if(!t)return E(null),null;const oe=await ye.getHarnessFeedbackState(G);return E(oe),oe}function wl(G,oe,Xe={}){var sn;tn(G.translatorSession),Dn(!!((sn=G.translationState)!=null&&sn.memoryInitialized)),st(G.harnessEngineerSession),E(G.harnessFeedbackState),_(G.autoMemoryState),b(oe&&G.autoMemoryState?oe:null),L(G.gatewayStatus),Ue(oe?{taskSlug:oe,state:G.workflowControlState??null}:null),oe&&G.harnessStatus?(m(G.harnessStatus),u(oe)):(m(null),u(null)),oe&&G.harnessBootstrapStatus?(o(G.harnessBootstrapStatus),h(oe)):(o(null),h(null)),Xe.syncLaunchOptions&&(li(G.translatorSession),oi(G.harnessEngineerSession))}async function Pt(G={}){if(!t)return tn(null),Dn(!1),st(null),m(null),o(null),u(null),h(null),E(null),_(null),b(null),Ue(null),null;const oe=(J==null?void 0:J.taskSlug)??null,Xe=await ye.getProjectRuntimeState(oe);return wl(Xe,oe,G),Xe}function Ei(){const G=["Poll project runtime state","Load project runtime state","Refresh Harness feedback state","Poll Harness feedback state","Load Translator session","Poll Translator session","Poll translation memory status","Load Harness Engineer session","Poll Harness Engineer session","Load VCM Harness status","Poll VCM Harness status"];for(const oe of G)qo(oe);wi(oe=>Ho(oe,G))}ee.useEffect(()=>{Promise.all([ye.getCurrentProject(),ye.getRecentRepositoryPaths(),ye.getAppPreferences(),ye.getGatewayStatus(),ye.getCodexBridgeIntegrationStatus()]).then(async([G,oe,Xe,sn,Ai])=>{r(G),l(oe),L(sn),D(Ai),Ut(Xe,{syncToolLaunchOptions:!0}),G&&await yn()}).catch(G=>wi(ft("Load initial app data",G)))},[Ut]),ee.useEffect(()=>{const G=window.matchMedia("(prefers-color-scheme: dark)"),oe=()=>Jo(G.matches);return oe(),G.addEventListener("change",oe),()=>G.removeEventListener("change",oe)},[]),ee.useEffect(()=>()=>Ln(),[Ln]),ee.useEffect(()=>{(k==null?void 0:k.pauseAlertSoundEnabled)!==void 0&&je(k.pauseAlertSoundEnabled);const G=Wk(ls.current,k);ls.current=G.observation,G.dismissPauseAlert&&la()},[la,k]),ee.useEffect(()=>{if(_t&&Vk(ge)==="strong")return hs(),Ln;Ln()},[_t==null?void 0:_t.id,ge,hs,Ln]),ee.useEffect(()=>{const G=He==="system"?Ci?"dark":"light":He;document.documentElement.dataset.theme=G,document.documentElement.dataset.themeMode=He},[Ci,He]),ee.useEffect(()=>{if(!(J!=null&&J.taskSlug)){Oe(null);return}er(J.taskSlug).catch(G=>wi(ft("Refresh Gate Review state",G)))},[J==null?void 0:J.taskSlug]),ee.useEffect(()=>{os.current="",tn(null),Dn(!1),st(null),m(null),o(null),u(null),h(null),E(null)},[t==null?void 0:t.repoRoot,J==null?void 0:J.taskSlug]),pl(t?`project-runtime:${t.repoRoot}:${(J==null?void 0:J.taskSlug)??"no-task"}`:null,async()=>{try{const G=t?`${t.repoRoot}:${(J==null?void 0:J.taskSlug)??"no-task"}`:"",oe=!!(t&&os.current!==G);await Pt({syncLaunchOptions:oe}),oe&&(os.current=G),Ei()}catch(G){Kn("Poll project runtime state",G)}},{intervalMs:3e3,runImmediately:!0});const Yt=(J==null?void 0:J.taskSlug)??null,ki=Yt&&(be==null?void 0:be.taskSlug)===Yt?be.state:null,ua=Yt&&(ae==null?void 0:ae.taskSlug)===Yt?ae.roundState:null,Nr=Yt&&(Me==null?void 0:Me.taskSlug)===Yt?Me:null,ha=!!(Yt&&(ki!=null&&ki.activeGate||(ua==null?void 0:ua.activeRole)==="reviewer"||Nr!=null&&Nr.hasReviewerSession));pl(ha&&Yt?`gate-review:${Yt}`:null,async()=>{if(Yt)try{await er(Yt)}catch(G){Kn("Poll Gate Review state",G)}},{intervalMs:3e3,runImmediately:!1});async function Ae(G,oe="Run UI action"){ia(!0),wi("");try{await G()}catch(Xe){wi(ft(oe,Xe))}finally{ia(!1)}}async function ps(){var sn;if(!J)throw new Error("Create or select a task before closing it.");const G=[`Close task "${J.taskSlug}"?`,"","This is destructive:","- stops VCM-managed running role sessions for this task","- stops Translator and Harness Engineer sessions for this task",`- deletes the task worktree: ${J.worktreePath}`,`- deletes the Git branch: ${J.branch}`,"- deletes VCM task/session/message/orchestration state","","The task will close even if a cleanup step fails; cleanup issues are reported as warnings."].join(`
|
|
95
|
+
`))&&m()}return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"message-modal",role:"dialog","aria-modal":"true","aria-label":"Messages",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[f.total," total / ",f.accepted," accepted",s?` · ${s.mode}`:""]})]}),C.jsxs("div",{className:"modal-actions",children:[C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Mark All Done"}),C.jsx("button",{type:"button",disabled:t||f.total===0,onClick:c,children:"Delete All"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),C.jsx(n2,{busy:t,maxMessages:null,messages:r,orchestration:s,showControls:!1,showHeader:!1})]})})}function es({children:t,onOpenChange:r,open:s,title:l,warningCount:d=0}){const m=d===1?"1 warning":`${d} warnings`;return C.jsxs("section",{className:"sidebar-section",children:[C.jsxs("button",{"aria-expanded":s,"aria-label":d>0?`${l}, ${m}`:void 0,className:"sidebar-section-toggle",type:"button",onClick:()=>{r==null||r(!s)},children:[C.jsx("span",{children:l}),d>0?C.jsx("span",{"aria-hidden":"true",className:"sidebar-section-badge",title:m,children:d}):null,C.jsx("span",{"aria-hidden":"true",className:"sidebar-section-chevron"})]}),s?C.jsx("div",{className:"sidebar-section-content",children:t}):null]})}function Fv(t,r){return t.find(s=>s.role===r)}function R2({activeRole:t,roles:r=Go,sessions:s,onSelect:l}){return C.jsx("div",{className:"role-tabs",role:"tablist","aria-label":"Role sessions",children:r.map(d=>{const m=Fv(s,d.name),f=(m==null?void 0:m.status)==="running"?m.activityStatus??"idle":(m==null?void 0:m.status)??"not_started";return C.jsxs("button",{className:d.name===t?"role-tab is-active":"role-tab",type:"button",role:"tab","aria-selected":d.name===t,onClick:()=>l(d.name),children:[C.jsx("span",{children:d.label}),C.jsx($n,{status:f})]},d.name)})})}function D2({role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,active:f=!0,busy:o,translationEnabled:c,translationAutoSendEnabled:u,translationTargetLanguage:g,translationPanelState:h,onClearTranslationSession:S,onTranslationEntry:x,onTranslationFailures:T,onPermissionModeChange:E,onModelChange:y,onEffortChange:_,onStart:v,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D,onTerminalEvent:A}){const M=S_(t)&&c&&(r==null?void 0:r.status)==="running";return C.jsx("section",{className:"session-console",children:C.jsxs("div",{className:M?"session-console-body has-translation":"session-console-body",children:[C.jsxs("div",{className:"terminal-pane",children:[C.jsx(Vh,{role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,busy:o,onPermissionModeChange:E,onModelChange:y,onEffortChange:_,onStart:v,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D}),(r==null?void 0:r.status)==="running"?C.jsx(Vo,{sessionId:r.id,active:f,onEvent:A},r.id):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:t}),C.jsx("span",{children:r!=null&&r.claudeSessionId?"Resume this role to reconnect its Claude Code conversation.":"Start this role to open an embedded Claude Code terminal."})]})]}),M?C.jsx("div",{className:"translation-pane",children:C.jsx(wk,{active:f,autoSendEnabled:u,targetLanguage:g,taskSlug:r.taskSlug,role:t,sessionId:r.id,panelState:h??{role:t,status:"ready",entries:[],failures:[]},onClearSession:S??(()=>{}),onEntry:x??(()=>{}),onFailures:T??(()=>{})},`${t}:${r.id}`)}):null]})})}const kh=500;function $h(t){return{taskSlug:t,cursor:1,sessions:{}}}function M2(t,r,s){return t.sessions[r]??Qs(s)}function L2(t,r){const l={...N2(t,r.taskSlug).sessions};for(const d of r.sessions)l[d.sessionId]={...Qs(d.role),...l[d.sessionId],role:d.role,status:d.status};for(const d of r.events){const m=l[d.sessionId]??Qs(d.role);if(d.event.type==="status")l[d.sessionId]={...m,role:d.role,status:d.event.status};else if(d.event.type==="failures")l[d.sessionId]={...m,role:d.role,failures:d.event.failures};else if(d.event.type==="entry"){const f=$v(qv(m.entries,d.event.entry));l[d.sessionId]={...m,role:d.role,entries:f.entries,failures:f.removedIds.size>0?m.failures.filter(o=>!f.removedIds.has(o.translationId)):m.failures}}}return{taskSlug:r.taskSlug,cursor:r.nextCursor,sessions:l}}function O2(t,r,s){return{...t,sessions:{...t.sessions,[r]:Qs(s)}}}function B2(t,r,s,l){const d=t.sessions[r]??Qs(s),m=$v(qv(d.entries,l));return{...t,sessions:{...t.sessions,[r]:{...d,role:s,entries:m.entries,failures:m.removedIds.size>0?d.failures.filter(f=>!m.removedIds.has(f.translationId)):d.failures}}}}function j2(t,r,s,l){const d=t.sessions[r]??Qs(s);return{...t,sessions:{...t.sessions,[r]:{...d,role:s,failures:l}}}}function N2(t,r){return t.taskSlug===r?t:$h(r)}function Qs(t){return{role:t,status:"ready",entries:[],failures:[]}}function qv(t,r){return t.findIndex(l=>l.id===r.id)===-1?[...t,r]:t.map(l=>l.id===r.id?r:l)}function $v(t){if(t.length<=kh)return{entries:t,removedIds:new Set};const r=t.slice(0,t.length-kh);return{entries:t.slice(-kh),removedIds:new Set(r.map(s=>s.id))}}const H2={"project-manager":"bypassPermissions",architect:"bypassPermissions",coder:"bypassPermissions",tester:"bypassPermissions",reviewer:"bypassPermissions",translator:"bypassPermissions","harness-engineer":"bypassPermissions"},z2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"default","harness-engineer":"default"},I2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"medium","harness-engineer":"medium"};function U2({task:t,activeRole:r,reviewerEnabled:s,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,launchTemplate:f,modelOptions:o,refreshNonce:c=0,onTaskChanged:u,onActiveRoleChange:g,onMessagesChanged:h,onOrchestrationChanged:S,onRoundStateChanged:x,onEventsChanged:T,onLaunchStateChanged:E}){const[y,_]=ee.useState(null),[v,b]=ee.useState(()=>l_(f)),[k,L]=ee.useState(()=>o_(f)),[R,D]=ee.useState(()=>c_(f)),[A,M]=ee.useState(!1),[,O]=qi(""),[H,U]=ee.useState([]),[P,W]=ee.useState(null),[K,V]=ee.useState(null),[Y,te]=ee.useState(null),[z,j]=ee.useState(()=>$h(t.taskSlug)),N=ee.useRef(""),q=ee.useRef(1),I=ee.useMemo(()=>JSON.stringify(f),[f]),ie=!!(y!=null&&y.sessions.some(Ee=>Ee.role==="reviewer")),pe=s||ie,_e=[...ul,...pe?[__]:[]],Q=ee.useCallback((Ee,ce)=>{W(ce),h==null||h(Ee),S==null||S(ce)},[h,S]),$=ee.useCallback((Ee,ce,He,xt,ge)=>{_(Ee),V(ge),Q(ce,He),x==null||x(xt)},[Q,x]),he=ee.useCallback(async()=>{const Ee=await ye.getTaskWorkspaceState(t.taskSlug);te(Ee.architectRestart),$(Ee.taskStatus,Ee.messages,Ee.orchestration,Ee.roundState,Ee.workflowState),qo("Poll task workspace state"),O(ce=>Ho(ce,["Load task workspace state","Poll task workspace state"]))},[$,t.taskSlug]),ae=ee.useCallback((Ee,ce)=>{const He=zv(Ee,ce);He&&O(He)},[]);pl(`task-workspace:${t.taskSlug}:${c}`,()=>he().catch(Ee=>{ae("Poll task workspace state",Ee)}),{intervalMs:3e3,runImmediately:!0}),pl(l?`task-translation-feed:${t.taskSlug}`:null,async()=>{try{const Ee=await ye.pollTranslationTaskFeed(t.taskSlug,q.current);q.current=Ee.nextCursor,j(ce=>L2(ce,Ee)),qo("Poll task translation feed"),O(ce=>Ho(ce,["Poll task translation feed"]))}catch(Ee){ae("Poll task translation feed",Ee)}},{intervalMs:1e3,runImmediately:!0}),ee.useEffect(()=>{U([]),V(null),T==null||T([])},[T,t.taskSlug]),ee.useEffect(()=>{q.current=1,j($h(t.taskSlug))},[t.taskSlug]),ee.useEffect(()=>{b(l_(f)),L(o_(f)),D(c_(f))},[I,t.taskSlug]),ee.useEffect(()=>{y&&!pe&&r==="reviewer"&&g("project-manager"),y&&r==="translator"&&g("project-manager")},[r,pe,g,y]),ee.useEffect(()=>{const Ee=y==null?void 0:y.task;if(!Ee||Ee.taskSlug!==t.taskSlug)return;const ce=a_(Ee);if(ce===a_(t)){N.current="";return}N.current!==ce&&(N.current=ce,u().catch(He=>{N.current="",O(ft("Refresh task list after task status changed",He))}))},[u,y==null?void 0:y.task,t]),ee.useEffect(()=>{const Ee=(y==null?void 0:y.sessions)??[],ce=Ee.filter(je=>P2(je.role)),He=new Set(ce.map(je=>je.role)),xt=Ee.some(je=>je.role==="reviewer"),ge={};for(const je of Js)ge[je.name]={permissionMode:v[je.name],model:k[je.name],effort:R[je.name]};E==null||E({taskSlug:t.taskSlug,roles:ge,autoOrchestration:((P==null?void 0:P.mode)??"auto")==="auto",statusLoaded:!!y,sessionCount:ce.length,hasAnySession:ce.length>0,hasReviewerSession:xt,allRolesHaveSession:ul.every(je=>He.has(je.name))})},[k,R,E,P==null?void 0:P.mode,v,y,t.taskSlug]);async function Ce(Ee,ce="Run role session action"){M(!0),O("");try{await Ee(),await he(),await u()}catch(He){O(ft(ce,He))}finally{M(!1)}}function be(Ee){U(ce=>{const He=[...ce,`${new Date().toLocaleTimeString()} ${Ee}`];return T==null||T(He),He})}function Oe(Ee,ce){b(He=>({...He,[Ee]:ce}))}function Ie(Ee,ce){L(He=>({...He,[Ee]:ce}))}function Ue(Ee,ce){D(He=>({...He,[Ee]:ce}))}return C.jsxs("div",{className:"task-workspace",children:[C.jsxs("header",{className:"workspace-header",children:[C.jsxs("div",{className:"workspace-title-line",children:[C.jsx("h1",{children:t.title||t.taskSlug}),K!=null&&K.declared?C.jsxs("div",{className:"workspace-workflow-state",title:[K.declared.branch?`Branch: ${K.declared.branch}`:"",K.declared.resumePoint?`Resume: ${K.declared.resumePoint}`:"",K.declared.status?`Status: ${K.declared.status}`:""].filter(Boolean).join(" | "),children:[C.jsx("span",{children:K.declared.flow??"Workflow"}),K.declared.step?C.jsx("strong",{children:K.declared.step}):null]}):null]}),C.jsx(R2,{activeRole:r,roles:_e,sessions:(y==null?void 0:y.sessions)??[],onSelect:g})]}),(Y==null?void 0:Y.status)==="blocked"&&Y.blocker?C.jsxs("div",{className:"workspace-runtime-warning",role:"alert",children:[C.jsx("strong",{children:"Architect restart blocked"}),C.jsx("span",{children:Y.blocker.message}),C.jsx("code",{children:Y.blocker.code})]}):null,C.jsx("div",{className:"workspace-grid",children:C.jsx("div",{className:"workspace-main",children:C.jsx("div",{className:"role-console-stack",children:_e.map(Ee=>{const ce=Ee.name,He=ce===r,xt=(y==null?void 0:y.sessions)??[],ge=Fv(xt,ce),je=ge?M2(z,ge.id,ce):void 0;return C.jsx("div",{className:He?"role-console-panel is-active":"role-console-panel","aria-hidden":!He,children:C.jsx(D2,{role:ce,session:ge,permissionMode:v[ce],model:k[ce],effort:R[ce],modelOptions:o,active:He,busy:A,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,translationPanelState:je,onClearTranslationSession:(Fe,dt)=>{j(rt=>O2(rt,Fe,dt))},onTranslationEntry:(Fe,dt,rt)=>{j(Et=>B2(Et,Fe,dt,rt))},onTranslationFailures:(Fe,dt,rt)=>{j(Et=>j2(Et,Fe,dt,rt))},onPermissionModeChange:Fe=>Oe(ce,Fe),onModelChange:Fe=>Ie(ce,Fe),onEffortChange:Fe=>Ue(ce,Fe),onStart:()=>void Ce(async()=>{await ye.startRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`started ${ce} with ${v[ce]} / ${k[ce]} / ${R[ce]}`)},`Start ${ce} session`),onResume:()=>void Ce(async()=>{await ye.resumeRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`resumed ${ce} with ${v[ce]} / ${k[ce]} / ${R[ce]}`)},`Resume ${ce} session`),onStop:()=>void Ce(async()=>{await ye.stopRoleSession(t.taskSlug,ce),be(`stopped ${ce}`)},`Stop ${ce} session`),onRestart:()=>void Ce(async()=>{await ye.restartRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with ${v[ce]} / ${k[ce]} / ${R[ce]}`)},`Restart ${ce} session`),onRestartWithContext:()=>void Ce(async()=>{S_(ce)&&(await ye.restartRoleSessionWithContext(t.taskSlug,ce,{cols:100,rows:28,permissionMode:v[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with task context`))},`Restart ${ce} session with task context`),onNotifyHarnessUpdated:()=>void Ce(async()=>{await ye.notifyRoleHarnessUpdated(t.taskSlug,ce),be(`notified ${ce} to reload latest harness`)},`Notify ${ce} to reload harness`),onTerminalEvent:Fe=>be(`${Ee.label}: ${Fe}`)})},ce)})})})})]})}function P2(t){return ul.some(r=>r.name===t)}function a_(t){return[t.status,t.updatedAt,t.cleanupStatus??"",t.cleanedAt??""].join(":")}function l_(t){var s;const r={...H2};for(const l of Js)r[l.name]=((s=t.roles[l.name])==null?void 0:s.permissionMode)??r[l.name];return r}function o_(t){var s;const r={...z2};for(const l of Js)r[l.name]=((s=t.roles[l.name])==null?void 0:s.model)??r[l.name];return r}function c_(t){var s;const r={...I2};for(const l of Js)r[l.name]=((s=t.roles[l.name])==null?void 0:s.effort)??r[l.name];return r}const F2=1400;function q2(t){return!!(t!=null&&t.initialized)}function $2(){const[t,r]=ee.useState(null),[s,l]=ee.useState([]),[d,m]=ee.useState(null),[f,o]=ee.useState(null),[c,u]=ee.useState(null),[g,h]=ee.useState(null),[S,x]=ee.useState(null),[T,E]=ee.useState(null),[y,_]=ee.useState(null),[v,b]=ee.useState(null),[k,L]=ee.useState(null),[R,D]=ee.useState(null),[A,M]=ee.useState(null),[O,H]=ee.useState(null),[U,P]=ee.useState(!1),[W,K]=ee.useState(null),[V,Y]=ee.useState(null),[te,z]=ee.useState(!1),[j,N]=ee.useState([]),[q,I]=ee.useState(null),[ie,pe]=ee.useState(null),[_e,Q]=ee.useState(null),[$,he]=ee.useState(null),[ae,Ce]=ee.useState(null),[be,Oe]=ee.useState(null),[Ie,Ue]=ee.useState(null),[Ee,ce]=ee.useState("project-manager"),[He,xt]=ee.useState("system"),[ge,je]=ee.useState(!0),[Fe,dt]=ee.useState(!0),[rt,Et]=ee.useState("off"),[fe,we]=ee.useState(!1),[Te,Ne]=ee.useState(!1),[Pe,St]=ee.useState(hS),[Ve,bt]=ee.useState(!1),[Ct,Nt]=ee.useState(!1),[Ze,_n]=ee.useState(fS),[en,ss]=ee.useState(dS),[Gi,Dn]=ee.useState(!1),[mi,vn]=ee.useState(!1),[Vi,ei]=ee.useState(!1),[ta,Tr]=ee.useState(!1),[Rr,Gn]=ee.useState(!1),[ti,tn]=ee.useState(null),[gi,_i]=ee.useState("bypassPermissions"),[ni,ii]=ee.useState("default"),[vi,yi]=ee.useState("medium"),[zt,st]=ee.useState(null),[kt,It]=ee.useState("bypassPermissions"),[Vn,ri]=ee.useState("default"),[qt,nn]=ee.useState("medium"),[si,Wi]=ee.useState(()=>mS()),[Me,ai]=ee.useState(null),[Dr,Si]=ee.useState(0),[_t,na]=ee.useState(null),[yl,bi]=ee.useState(null),[Ci,Jo]=ee.useState(!1),[Ki,ia]=ee.useState(!1),[,wi]=qi(""),Mr=ee.useRef({}),Yi=ee.useRef({}),Mn=ee.useRef({}),rn=ee.useRef({}),ra=ee.useRef({}),as=ee.useRef(null),ls=ee.useRef({initialized:!1,messageId:null}),os=ee.useRef(""),J=ee.useMemo(()=>Pk(j,q),[j,q]),on=(Me==null?void 0:Me.taskSlug)===(J==null?void 0:J.taskSlug)?Me:null,Kt=c===(J==null?void 0:J.taskSlug)?d:null,cs=g===(J==null?void 0:J.taskSlug)?f:null,Sl=v===(J==null?void 0:J.taskSlug)?y:null,sa=!!(t&&J&&q2(Kt)),Xi=(ti==null?void 0:ti.status)==="running",aa=!!(Ve&&sa&&Xi),bl=!!(on!=null&&on.statusLoaded),Qi=!!(J&&(on!=null&&on.statusLoaded)&&!on.hasAnySession),us=(R==null?void 0:R.modelOptions)??w_(),Ut=ee.useCallback((G,oe={})=>{xt(G.themeMode),je(G.flowPauseAlerts),dt(G.roleRetryEnabled),Et(G.permissionRequestMode),we(G.autoTaskHarnessReviewEnabled),Ne(G.autoMemoryEnabled),St(G.architectWorkerSettings),bt(G.translationEnabled),Nt(G.translationAutoSendEnabled),_n(G.translationTargetLanguage),ss(G.translationOutputMode),Wi(G.launchTemplate),oe.syncToolLaunchOptions&&(_i(G.toolSessionDefaults.translator.permissionMode),ii(G.toolSessionDefaults.translator.model),yi(G.toolSessionDefaults.translator.effort),It(G.toolSessionDefaults["harness-engineer"].permissionMode),ri(G.toolSessionDefaults["harness-engineer"].model),nn(G.toolSessionDefaults["harness-engineer"].effort))},[]);ee.useEffect(()=>{if(!ge)return;let G=!1;const oe=()=>{G||(G=!0,u_(),window.removeEventListener("pointerdown",oe),window.removeEventListener("keydown",oe))};return window.addEventListener("pointerdown",oe),window.addEventListener("keydown",oe),()=>{window.removeEventListener("pointerdown",oe),window.removeEventListener("keydown",oe)}},[ge]);const Ln=ee.useCallback(()=>{as.current!==null&&(window.clearInterval(as.current),as.current=null)},[]),hs=ee.useCallback(()=>{Ln(),h_(),as.current=window.setInterval(()=>{h_()},F2)},[Ln]),Cl=ee.useCallback((G,oe=`manual-${Date.now()}`)=>{na({id:oe,text:G})},[]),la=ee.useCallback(()=>{Ln(),na(null)},[Ln]);ee.useEffect(()=>{J!=null&&J.taskSlug&&(ra.current[J.taskSlug]=Date.now())},[J==null?void 0:J.taskSlug]);const fs=ee.useCallback(G=>{J!=null&&J.taskSlug&&pe({taskSlug:J.taskSlug,messages:G})},[J==null?void 0:J.taskSlug]),Wn=ee.useCallback(G=>{Mn.current[G.taskSlug]=G.mode,J!=null&&J.taskSlug&&Q({taskSlug:J.taskSlug,orchestration:G})},[J==null?void 0:J.taskSlug]),oa=ee.useCallback(G=>{J!=null&&J.taskSlug&&he({taskSlug:J.taskSlug,events:G})},[J==null?void 0:J.taskSlug]),ca=ee.useCallback(G=>{if(!(J!=null&&J.taskSlug)||G.taskSlug!==J.taskSlug)return;Ce({taskSlug:G.taskSlug,roundState:G});const oe=Fk({mode:Mn.current[G.taskSlug],status:G.status,activeRole:G.activeRole,lastFollowedRole:rn.current[G.taskSlug]});oe&&(rn.current[G.taskSlug]=oe,ce(oe));const Xe=qk(G,Y2);if(Xe===null){Yi.current[G.taskSlug]={status:G.status};return}const sn=$k(G),Ai=Mr.current[G.taskSlug],ic=Yi.current[G.taskSlug];Yi.current[G.taskSlug]={status:G.status},Ai!==sn&&(Mr.current[G.taskSlug]=sn,Gk(G,ic,ra.current[G.taskSlug])&&Cl(Xe,sn))},[J==null?void 0:J.taskSlug,Cl]),Ji=ee.useCallback(G=>{ai(oe=>(oe==null?void 0:oe.taskSlug)===G.taskSlug&&oe.statusLoaded===G.statusLoaded&&oe.sessionCount===G.sessionCount&&oe.hasAnySession===G.hasAnySession&&oe.hasReviewerSession===G.hasReviewerSession&&oe.allRolesHaveSession===G.allRolesHaveSession&&oe.autoOrchestration===G.autoOrchestration&&JSON.stringify(oe.roles)===JSON.stringify(G.roles)?oe:G)},[]);async function yn(){const G=await ye.listTasks();return N(G),I(oe=>{var Xe;return oe&&G.some(sn=>sn.taskSlug===oe)?oe:((Xe=G[0])==null?void 0:Xe.taskSlug)??null}),G}async function Lr(G=J==null?void 0:J.taskSlug){if(!G)return m(null),u(null),null;const oe=await ye.getHarnessStatus(G);return m(oe),u(G),oe}async function Or(G=J==null?void 0:J.taskSlug){if(!G)return o(null),h(null),null;const oe=await ye.getHarnessBootstrapStatus(G);return o(oe),h(G),oe}async function xi(){const G=await ye.getGatewayStatus();return L(G),G}async function Br(){const G=await ye.getRecentRepositoryPaths();return l(G),G}async function On(){if(!t)return Dn(!1),!1;const G=await ye.getTranslationState();return Dn(G.memoryInitialized),G.memoryInitialized}async function Zi(G){const[oe,Xe]=await Promise.all([ye.listMessages(G),ye.getOrchestrationState(G)]);pe({taskSlug:G,messages:oe}),Q({taskSlug:G,orchestration:Xe})}async function er(G){const oe=await ye.getGateReviewState(G);return Oe({taskSlug:G,state:oe}),qo("Poll Gate Review state"),wi(Xe=>Ho(Xe,["Refresh Gate Review state","Poll Gate Review state"])),oe}function Kn(G,oe){const Xe=zv(G,oe);Xe&&wi(Xe)}function li(G){G&&(_i(G.permissionMode),G.model&&ii(G.model),G.effort&&yi(G.effort))}async function jr(G={}){const oe=await ye.getTranslatorSession((J==null?void 0:J.taskSlug)??null);return tn(oe),G.syncLaunchOptions&&li(oe),oe}function oi(G){G&&(It(G.permissionMode),G.model&&ri(G.model),G.effort&&nn(G.effort))}async function Yn(G={}){const oe=await ye.getHarnessEngineerSession((J==null?void 0:J.taskSlug)??null);return st(oe),G.syncLaunchOptions&&oi(oe),oe}async function ds(G=J==null?void 0:J.taskSlug){if(!t)return E(null),null;const oe=await ye.getHarnessFeedbackState(G);return E(oe),oe}function wl(G,oe,Xe={}){var sn;tn(G.translatorSession),Dn(!!((sn=G.translationState)!=null&&sn.memoryInitialized)),st(G.harnessEngineerSession),E(G.harnessFeedbackState),_(G.autoMemoryState),b(oe&&G.autoMemoryState?oe:null),L(G.gatewayStatus),Ue(oe?{taskSlug:oe,state:G.workflowControlState??null}:null),oe&&G.harnessStatus?(m(G.harnessStatus),u(oe)):(m(null),u(null)),oe&&G.harnessBootstrapStatus?(o(G.harnessBootstrapStatus),h(oe)):(o(null),h(null)),Xe.syncLaunchOptions&&(li(G.translatorSession),oi(G.harnessEngineerSession))}async function Pt(G={}){if(!t)return tn(null),Dn(!1),st(null),m(null),o(null),u(null),h(null),E(null),_(null),b(null),Ue(null),null;const oe=(J==null?void 0:J.taskSlug)??null,Xe=await ye.getProjectRuntimeState(oe);return wl(Xe,oe,G),Xe}function Ei(){const G=["Poll project runtime state","Load project runtime state","Refresh Harness feedback state","Poll Harness feedback state","Load Translator session","Poll Translator session","Poll translation memory status","Load Harness Engineer session","Poll Harness Engineer session","Load VCM Harness status","Poll VCM Harness status"];for(const oe of G)qo(oe);wi(oe=>Ho(oe,G))}ee.useEffect(()=>{Promise.all([ye.getCurrentProject(),ye.getRecentRepositoryPaths(),ye.getAppPreferences(),ye.getGatewayStatus(),ye.getCodexBridgeIntegrationStatus()]).then(async([G,oe,Xe,sn,Ai])=>{r(G),l(oe),L(sn),D(Ai),Ut(Xe,{syncToolLaunchOptions:!0}),G&&await yn()}).catch(G=>wi(ft("Load initial app data",G)))},[Ut]),ee.useEffect(()=>{const G=window.matchMedia("(prefers-color-scheme: dark)"),oe=()=>Jo(G.matches);return oe(),G.addEventListener("change",oe),()=>G.removeEventListener("change",oe)},[]),ee.useEffect(()=>()=>Ln(),[Ln]),ee.useEffect(()=>{(k==null?void 0:k.pauseAlertSoundEnabled)!==void 0&&je(k.pauseAlertSoundEnabled);const G=Wk(ls.current,k);ls.current=G.observation,G.dismissPauseAlert&&la()},[la,k]),ee.useEffect(()=>{if(_t&&Vk(ge)==="strong")return hs(),Ln;Ln()},[_t==null?void 0:_t.id,ge,hs,Ln]),ee.useEffect(()=>{const G=He==="system"?Ci?"dark":"light":He;document.documentElement.dataset.theme=G,document.documentElement.dataset.themeMode=He},[Ci,He]),ee.useEffect(()=>{if(!(J!=null&&J.taskSlug)){Oe(null);return}er(J.taskSlug).catch(G=>wi(ft("Refresh Gate Review state",G)))},[J==null?void 0:J.taskSlug]),ee.useEffect(()=>{os.current="",tn(null),Dn(!1),st(null),m(null),o(null),u(null),h(null),E(null)},[t==null?void 0:t.repoRoot,J==null?void 0:J.taskSlug]),pl(t?`project-runtime:${t.repoRoot}:${(J==null?void 0:J.taskSlug)??"no-task"}`:null,async()=>{try{const G=t?`${t.repoRoot}:${(J==null?void 0:J.taskSlug)??"no-task"}`:"",oe=!!(t&&os.current!==G);await Pt({syncLaunchOptions:oe}),oe&&(os.current=G),Ei()}catch(G){Kn("Poll project runtime state",G)}},{intervalMs:3e3,runImmediately:!0});const Yt=(J==null?void 0:J.taskSlug)??null,ki=Yt&&(be==null?void 0:be.taskSlug)===Yt?be.state:null,ua=Yt&&(ae==null?void 0:ae.taskSlug)===Yt?ae.roundState:null,Nr=Yt&&(Me==null?void 0:Me.taskSlug)===Yt?Me:null,ha=!!(Yt&&(ki!=null&&ki.activeGate||(ua==null?void 0:ua.activeRole)==="reviewer"||Nr!=null&&Nr.hasReviewerSession));pl(ha&&Yt?`gate-review:${Yt}`:null,async()=>{if(Yt)try{await er(Yt)}catch(G){Kn("Poll Gate Review state",G)}},{intervalMs:3e3,runImmediately:!1});async function Ae(G,oe="Run UI action"){ia(!0),wi("");try{await G()}catch(Xe){wi(ft(oe,Xe))}finally{ia(!1)}}async function ps(){var sn;if(!J)throw new Error("Create or select a task before closing it.");const G=[`Close task "${J.taskSlug}"?`,"","This is destructive:","- stops VCM-managed running role sessions for this task","- stops Translator and Harness Engineer sessions for this task",`- deletes the task worktree: ${J.worktreePath}`,`- deletes the Git branch: ${J.branch}`,"- deletes VCM task/session/message/orchestration state","","The task will close even if a cleanup step fails; cleanup issues are reported as warnings."].join(`
|
|
96
96
|
`);if(!window.confirm(G))return;const Xe=await ye.cleanupTask(J.taskSlug);I(null),pe(null),Q(null),he(null),Ce(null),Oe(null),Si(Ai=>Ai+1),await yn(),(sn=Xe.warnings)!=null&&sn.length&&window.alert([`Task "${Xe.taskSlug}" closed with cleanup warnings:`,"",...Xe.warnings.map(Ai=>`- ${Ai}`)].join(`
|
|
97
97
|
`))}const xl=ie&&ie.taskSlug===(J==null?void 0:J.taskSlug)?ie.messages:[],Zo=_e&&_e.taskSlug===(J==null?void 0:J.taskSlug)?_e.orchestration:null,ec=$&&$.taskSlug===(J==null?void 0:J.taskSlug)?$.events:[],Bn=ae&&ae.taskSlug===(J==null?void 0:J.taskSlug)?ae.roundState:null,Hr=J!=null&&J.taskSlug&&(Bn!=null&&Bn.roleRecovery)?W2(J.taskSlug,Bn.roleRecovery):null,El=Bn!=null&&Bn.roleRecovery&&Bn.roleRecovery.status!=="failed"&&Hr!==yl?K2(Bn.roleRecovery):null,fa=be&&be.taskSlug===(J==null?void 0:J.taskSlug)?be.state:null,tc=!!(fa&&Object.values(fa.gates).some(G=>G.required)),nc=Ie&&Ie.taskSlug===(J==null?void 0:J.taskSlug)?Ie.state:null;return C.jsxs(yS,{sidebar:C.jsx(f2,{project:t,recentRepositoryPaths:s,tasks:j,activeTaskSlug:(J==null?void 0:J.taskSlug)??null,messages:xl,orchestration:Zo,events:ec,roundState:Bn,gateReview:fa,workflowControlState:nc,translationEnabled:aa,translationAutoSendEnabled:Ct,translationTargetLanguage:Ze,translationOutputMode:en,translationMemoryInitialized:Gi,translatorSession:ti,harnessStatus:Kt,harnessBootstrapStatus:cs,harnessApplyResult:S,harnessEngineerLaunchOptions:{permissionMode:kt,model:Vn,effort:qt},autoTaskHarnessReviewEnabled:fe,autoMemoryEnabled:Te,architectWorkerSettings:Pe,gatewayStatus:k,gatewayQrLogin:A,gatewayQrCheck:O,gatewayLarkRegistration:W,gatewayLarkRegistrationCheck:V,codexBridgeStatus:R,modelOptions:us,busy:Ki,onConnect:G=>Ae(async()=>{const oe=await ye.connectProject({repoPath:G});r(oe),x(null),await Promise.all([yn(),Br()])},"Connect repository"),onRefreshConnectedRepository:()=>Ae(async()=>{const G=await ye.getCurrentProject();r(G)},"Refresh connected repository"),onPullConnectedRepository:()=>Ae(async()=>{const G=await ye.pullCurrentProject();r(G)},"Pull connected repository"),onRefreshHarness:()=>Ae(async()=>{if(!J)throw new Error("Create or select a task before refreshing VCM Harness.");x(null),await Promise.all([Lr(J.taskSlug),Or(J.taskSlug)])},"Refresh VCM Harness"),onApplyHarness:()=>Ae(async()=>{if(!J)throw new Error("Create or select a task before applying VCM Harness.");const G=await ye.applyHarness({taskSlug:J.taskSlug});x(G),await Promise.all([Lr(J.taskSlug),Or(J.taskSlug)])},"Apply VCM Harness"),onStartHarnessBootstrap:G=>Ae(async()=>{if(!J)throw new Error("Create or select a task before starting Harness Bootstrap.");const oe=await ye.startHarnessBootstrap({taskSlug:J.taskSlug,cols:120,rows:32,...G});o(oe.status),h(J.taskSlug),await Yn({syncLaunchOptions:!0})},"Start Harness Bootstrap"),onRestartHarnessBootstrap:G=>Ae(async()=>{if(!J)throw new Error("Create or select a task before restarting Harness Bootstrap.");const oe=await ye.restartHarnessBootstrap({taskSlug:J.taskSlug,cols:120,rows:32,...G});o(oe.status),h(J.taskSlug),await Yn({syncLaunchOptions:!0})},"Restart Harness Bootstrap"),onStopHarnessBootstrap:()=>Ae(async()=>{if(!J)throw new Error("Create or select a task before stopping Harness Bootstrap.");const G=await ye.stopHarnessBootstrap({taskSlug:J.taskSlug});o(G),h((J==null?void 0:J.taskSlug)??null),await Yn()},"Stop Harness Bootstrap"),onRunHarnessBootstrap:()=>Ae(async()=>{if(!J)throw new Error("Create or select a task before running Harness Bootstrap.");const G=await ye.runHarnessBootstrap({taskSlug:J.taskSlug});o(G.status),h(J.taskSlug),await Yn()},"Run Harness Bootstrap"),onOpenHarnessStudio:()=>Tr(!0),onOpenRepositoryDiff:()=>Gn(!0),onAutoTaskHarnessReviewChange:G=>{we(G),Ae(async()=>{const oe=await ye.updateAppPreferences({autoTaskHarnessReviewEnabled:G});Ut(oe)},"Update auto task harness review setting")},onAutoMemoryChange:G=>{Ne(G),Ae(async()=>{const oe=await ye.updateAppPreferences({autoMemoryEnabled:G});Ut(oe),await Pt()},"Update auto memory setting")},onArchitectWorkerSettingsChange:G=>{St(G),Ae(async()=>{const oe=await ye.updateAppPreferences({architectWorkerSettings:G});Ut(oe),await Lr(J==null?void 0:J.taskSlug)},"Update Architect worker settings")},onHarnessEngineerLaunchOptionsChange:G=>{It(G.permissionMode),ri(G.model),nn(G.effort)},onRefreshGateway:()=>Ae(async()=>{await xi()},"Refresh Gateway status"),onGatewayEnabledChange:G=>{Ae(async()=>{const oe=await ye.updateGatewaySettings({enabled:G,...G&&t?{currentProjectId:t.repoRoot,currentTaskSlug:(J==null?void 0:J.taskSlug)??null}:{}});L(oe),G&&Ut(await ye.getAppPreferences())},"Update Gateway enabled setting")},onGatewaySettingsChange:G=>Ae(async()=>{const oe=await ye.updateGatewaySettings(G);L(oe)},"Update Gateway settings"),onCodexBridgeSettingsChange:G=>Ae(async()=>{D(await ye.updateCodexBridgeIntegration(G))},"Update Codex Bridge settings"),onCodexBridgeCheck:()=>Ae(async()=>{D(await ye.checkCodexBridgeIntegration())},"Check Codex Bridge connection"),onGatewayTranslationChange:G=>{Ae(async()=>{const oe=await ye.updateGatewaySettings({translationEnabled:G});L(oe)},"Update Gateway translation setting")},onGatewayConnectionChange:G=>{Ae(async()=>{const oe=await ye.setGatewayConnection(G);L(oe)},"Update Gateway connection setting")},onStartGatewayQrLogin:()=>{Ae(async()=>{const G=await ye.startGatewayQrLogin();M(G),H(null),P(!0),await xi()},"Start Gateway QR login")},onStartGatewayLarkRegistration:()=>{Ae(async()=>{const G=await ye.startGatewayLarkRegistration();K(G),Y(null),z(!0),await xi()},"Start Lark Gateway QR setup")},onResetGatewayBinding:()=>{Ae(async()=>{const G=await ye.resetGatewayBinding();L(G),M(null),H(null),P(!1),K(null),Y(null),z(!1)},"Reset Gateway binding")},onGateReviewGateEnabledChange:(G,oe)=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before changing Gate Review Gates.");const Xe=await ye.updateGateReviewSettings(J.taskSlug,{gates:{[G]:oe}});Oe({taskSlug:J.taskSlug,state:Xe})},`Update ${G} Gate Review setting`)},onCancelGateReviewGate:(G,oe)=>{window.confirm(`Cancel the running ${G} Gate Review request ${oe}?`)&&Ae(async()=>{if(!J)throw new Error("Create or select a task before cancelling Gate Review.");const Xe=await ye.cancelGateReviewGate(J.taskSlug,G,{requestId:oe,reason:"Cancelled by the user from VCM."});Oe({taskSlug:J.taskSlug,state:Xe})},`Cancel ${G} Gate Review`)},onTranslationEnabledChange:G=>{bt(G),Ae(async()=>{const oe=await ye.updateAppPreferences({translationEnabled:G});Ut(oe)},"Update conversation translation setting")},onTranslationAutoSendChange:G=>{Nt(G),Ae(async()=>{const oe=await ye.updateAppPreferences({translationAutoSendEnabled:G});Ut(oe)},"Update translation auto-send setting")},onTranslationTargetLanguageChange:G=>{_n(G),Ae(async()=>{const oe=await ye.updateAppPreferences({translationTargetLanguage:G});Ut(oe)},"Update translation target language")},onTranslationOutputModeChange:G=>{ss(G),Ae(async()=>{const oe=await ye.updateAppPreferences({translationOutputMode:G});Ut(oe)},"Update translation output mode")},onOpenFileTranslation:()=>vn(!0),onOpenTranslatorSession:()=>ei(!0),onCreateTranslationBootstrap:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before running Translation Bootstrap.");await ye.createTranslationBootstrap({taskSlug:J.taskSlug,targetLanguage:Ze}),await On(),await jr()},"Create Translation Bootstrap task")},onUpdateTranslationMemory:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before updating translation memory.");await ye.createTranslationMemoryUpdate({taskSlug:J.taskSlug,targetLanguage:Ze}),await On(),await jr()},"Create translation memory update task")},onCreateTask:G=>Ae(async()=>{const oe=await ye.createTask(G);await yn(),I(oe.taskSlug)},"Create task"),onCloseTask:()=>{Ae(ps,"Close task")},onSelectTask:I,themeMode:He,onAutoOrchestrationChange:G=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before changing auto orchestration.");const oe=await ye.updateOrchestrationState(J.taskSlug,{mode:G?"auto":"manual"});Q({taskSlug:J.taskSlug,orchestration:oe})},"Update auto orchestration mode")},onThemeModeChange:G=>{xt(G),Ae(async()=>{const oe=await ye.updateAppPreferences({themeMode:G});Ut(oe)},"Update theme setting")},pauseAlertSound:ge,onPauseAlertSoundChange:G=>{je(G),G&&u_(),Ae(async()=>{const oe=await ye.updateAppPreferences({flowPauseAlerts:G});Ut(oe)},"Update pause alert sound setting")},roleRetryEnabled:Fe,onRoleRetryEnabledChange:G=>{dt(G),Ae(async()=>{const oe=await ye.updateAppPreferences({roleRetryEnabled:G});Ut(oe)},"Update CC retry setting")},permissionRequestMode:rt,onPermissionRequestModeChange:G=>{Et(G),Ae(async()=>{const oe=await ye.updateAppPreferences({permissionRequestMode:G});Ut(oe)},"Update permission request setting")},launchTemplate:si,canSaveLaunchTemplate:bl,canOneClickStart:Qi,onSaveLaunchTemplate:()=>{Ae(async()=>{if(!(on!=null&&on.statusLoaded))throw new Error("Open a task workspace before saving a launch template.");const G=await ye.updateAppPreferences({launchTemplate:{version:1,roles:on.roles,autoOrchestration:on.autoOrchestration}});Ut(G)},"Save launch template")},onOneClickStart:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before one-click start.");const G=await ye.oneClickStart(J.taskSlug);Q({taskSlug:J.taskSlug,orchestration:G.orchestration}),ce("project-manager"),await Zi(J.taskSlug),await yn(),Si(oe=>oe+1)},"One-click start role sessions")},onMarkAllMessagesDone:G=>{Ae(async()=>{const oe=await ye.markAllMessagesDone(G);pe({taskSlug:G,messages:oe.messages}),await Zi(G)},"Mark all role messages done")},onConfirmDeliveredDispatch:(G,oe)=>{Ae(async()=>{await ye.confirmDeliveredDispatch(G,oe),await Zi(G),await Pt()},"Confirm executed role dispatch")},onDeleteMessageHistory:G=>{Ae(async()=>{const oe=await ye.deleteMessageHistory(G);pe({taskSlug:G,messages:oe.messages}),await Zi(G)},"Delete role message history")}}),children:[C.jsx(Ik,{}),_t?C.jsx("div",{className:"flow-pause-alert-backdrop",children:C.jsxs("section",{"aria-describedby":"flow-pause-alert-body flow-pause-alert-hint","aria-labelledby":"flow-pause-alert-title","aria-modal":"true",className:"flow-pause-alert",role:"alertdialog",children:[C.jsx("p",{className:"flow-pause-alert-kicker",children:"VCM needs attention"}),C.jsx("h2",{id:"flow-pause-alert-title",children:"Flow needs attention"}),C.jsx("p",{id:"flow-pause-alert-body",children:_t.text}),C.jsx("p",{id:"flow-pause-alert-hint",className:"flow-pause-alert-hint",children:"The task may be complete, waiting for your decision, or blocked by a workflow issue."}),C.jsx("button",{type:"button",autoFocus:!0,onClick:la,children:"Confirm"})]})}):null,El&&Hr?C.jsxs("div",{className:"role-recovery-toast",role:"status",children:[C.jsx("span",{children:El}),C.jsx("button",{type:"button",onClick:()=>bi(Hr),children:"Close"})]}):null,U&&A?C.jsx(G2,{busy:Ki,qrCheck:O,qrLogin:A,onCheck:()=>{Ae(async()=>{const G=await ye.checkGatewayQrLogin();H(G),(G.status==="confirmed"||G.status==="binded_redirect")&&P(!1),await xi()})},onClose:()=>P(!1)}):null,te&&W?C.jsx(V2,{busy:Ki,registration:W,registrationCheck:V,onCheck:()=>{Ae(async()=>{const G=await ye.checkGatewayLarkRegistration();Y(G),G.gatewayStatus&&L(G.gatewayStatus),G.status==="confirmed"&&(z(!1),await xi())},"Check Lark Gateway QR setup")},onManualBind:(G,oe)=>{Ae(async()=>{const Xe=await ye.bindGatewayLarkApp({appId:G,appSecret:oe,larkDomain:"lark"});Y(Xe),Xe.gatewayStatus&&L(Xe.gatewayStatus),Xe.status==="confirmed"&&(z(!1),await xi())},"Bind Lark Gateway app")},onClose:()=>z(!1)}):null,t&&J?C.jsx(U2,{task:J,activeRole:Ee,reviewerEnabled:tc,translationEnabled:aa,translationAutoSendEnabled:Ct,translationTargetLanguage:Ze,launchTemplate:si,modelOptions:us,refreshNonce:Dr,onTaskChanged:async()=>{await yn()},onActiveRoleChange:ce,onMessagesChanged:fs,onOrchestrationChanged:Wn,onRoundStateChanged:ca,onEventsChanged:oa,onLaunchStateChanged:Ji}):C.jsxs("section",{className:"empty-workspace",children:[C.jsx("h1",{children:t?"Create a task to open the workspace":"Connect a repository to begin"}),C.jsx("p",{children:t?"Tasks create local role commands and handoff artifacts for the selected repository.":"VibeCodingMaster will create a local task workspace, role sessions, and handoff artifacts."})]}),C.jsx(kk,{open:mi,taskSlug:(J==null?void 0:J.taskSlug)??null,targetLanguage:Ze,onClose:()=>vn(!1)}),C.jsx(HS,{open:ta,busy:Ki,status:Kt,feedbackState:T,memoryState:Sl,bootstrapStatus:cs,engineerSession:zt,permissionMode:kt,model:Vn,modelOptions:us,effort:qt,taskSlug:(J==null?void 0:J.taskSlug)??null,onClose:()=>Tr(!1),onRefresh:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before refreshing Harness Studio.");await Promise.all([Lr(J.taskSlug),Or(J.taskSlug),Yn(),ds(J.taskSlug),ye.getAutoMemoryState(J.taskSlug).then(G=>{_(G),b(J.taskSlug)})])},"Refresh Harness Studio")},onPermissionModeChange:It,onModelChange:ri,onEffortChange:nn,onEngineerStart:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before starting Harness Engineer.");const G=await ye.startHarnessEngineerSession({taskSlug:J.taskSlug,cols:120,rows:32,permissionMode:kt,model:Vn,effort:qt});st(G),oi(G)},"Start Harness Engineer")},onEngineerResume:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before resuming Harness Engineer.");const G=await ye.resumeHarnessEngineerSession({taskSlug:J.taskSlug,cols:120,rows:32,permissionMode:kt,model:Vn,effort:qt});st(G),oi(G)},"Resume Harness Engineer")},onEngineerRestart:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before restarting Harness Engineer.");const G=await ye.restartHarnessEngineerSession({taskSlug:J.taskSlug,cols:120,rows:32,permissionMode:kt,model:Vn,effort:qt});st(G),oi(G)},"Restart Harness Engineer")},onEngineerStop:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before stopping Harness Engineer.");const G=await ye.stopHarnessEngineerSession({taskSlug:J.taskSlug});st(G)},"Stop Harness Engineer")},onEngineerNotifyHarnessUpdated:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before notifying Harness Engineer.");const G=await ye.notifyHarnessEngineerHarnessUpdated({taskSlug:J.taskSlug});st(G),oi(G)},"Notify Harness Engineer to reload harness")},onSendFeedback:G=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before sending Harness Feedback.");const oe=await ye.sendHarnessFeedback({taskSlug:J.taskSlug,feedbackPath:G});st(oe),oi(oe)},"Send Harness Feedback to Harness Engineer")},onOpenRepositoryDiff:()=>Gn(!0),onReviewTaskHarness:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before reviewing task harness.");const G=await ye.startTaskHarnessRetrospective({taskSlug:J.taskSlug,trigger:"manual"});E(G),await Yn({syncLaunchOptions:!0})},"Review task harness")},onMemoryStateChange:G=>{_(G),b((J==null?void 0:J.taskSlug)??null)}}),C.jsx($S,{open:Rr,taskSlug:(J==null?void 0:J.taskSlug)??null,onClose:()=>Gn(!1)}),C.jsx(YS,{open:Vi,busy:Ki,session:ti,permissionMode:gi,model:ni,modelOptions:us,effort:vi,onClose:()=>ei(!1),onPermissionModeChange:_i,onModelChange:ii,onEffortChange:yi,onStart:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before starting Translator.");const G=await ye.startTranslatorSession({taskSlug:J.taskSlug,cols:100,rows:28,permissionMode:gi,model:ni,effort:vi});tn(G),li(G)},"Start Translator session")},onResume:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before resuming Translator.");const G=await ye.resumeTranslatorSession({taskSlug:J.taskSlug,cols:100,rows:28,permissionMode:gi,model:ni,effort:vi});tn(G),li(G)},"Resume Translator session")},onRestart:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before restarting Translator.");const G=await ye.restartTranslatorSession({taskSlug:J.taskSlug,cols:100,rows:28,permissionMode:gi,model:ni,effort:vi});tn(G),li(G)},"Restart Translator session")},onStop:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before stopping Translator.");const G=await ye.stopTranslatorSession({taskSlug:J.taskSlug});tn(G)},"Stop Translator session")},onNotifyHarnessUpdated:()=>{Ae(async()=>{if(!J)throw new Error("Create or select a task before notifying Translator.");const G=await ye.notifyTranslatorHarnessUpdated({taskSlug:J.taskSlug});tn(G),li(G)},"Notify Translator to reload harness")}})]})}function G2({busy:t,onCheck:r,onClose:s,qrCheck:l,qrLogin:d}){const[m,f]=ee.useState(""),[o,c]=qi("");return ee.useEffect(()=>{let u=!1;if(c(""),f(""),d.qrcodeUrl.startsWith("data:image/")){f(d.qrcodeUrl);return}try{const g=is(0,"M");g.addData(d.qrcodeUrl),g.make(),u||f(g.createDataURL(8,2))}catch(g){u||c(ft("Render Gateway QR login code",g))}return()=>{u=!0}},[d.qrcodeUrl]),C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{"aria-labelledby":"gateway-qr-title","aria-modal":"true",className:"gateway-qr-modal",role:"dialog",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{id:"gateway-qr-title",children:"Weixin Gateway Login"}),C.jsx("p",{className:"muted",children:"Scan with Weixin, confirm on the phone, then click Confirm."})]}),C.jsx("button",{type:"button",onClick:s,children:"Close"})]}),C.jsxs("div",{className:"gateway-qr-modal-body",children:[C.jsx("div",{className:"gateway-qr-code-frame",children:m?C.jsx("img",{alt:"Weixin Gateway QR login",src:m}):C.jsx("div",{className:"gateway-qr-placeholder",children:o?"QR code could not be rendered.":"Rendering QR code..."})}),C.jsxs("dl",{className:"gateway-qr-meta",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Status"}),C.jsx("dd",{children:(l==null?void 0:l.status)??d.status})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Expires"}),C.jsx("dd",{children:Gv(d.expiresAt)})]}),l!=null&&l.message?C.jsxs("div",{children:[C.jsx("dt",{children:"Message"}),C.jsx("dd",{children:l.message})]}):null]})]}),C.jsx("footer",{children:C.jsx("button",{type:"button",disabled:t,onClick:r,children:"Confirm"})})]})})}function V2({busy:t,onCheck:r,onClose:s,onManualBind:l,registration:d,registrationCheck:m}){const[f,o]=ee.useState(""),[c,u]=qi(""),[g,h]=ee.useState(""),[S,x]=ee.useState(""),[T,E]=qi("");return ee.useEffect(()=>{let y=!1;u(""),o("");try{const _=is(0,"M");_.addData(d.qrUrl),_.make(),y||o(_.createDataURL(8,2))}catch(_){y||u(ft("Render Lark Gateway setup QR code",_))}return()=>{y=!0}},[d.qrUrl]),C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{"aria-labelledby":"gateway-lark-registration-title","aria-modal":"true",className:"gateway-qr-modal",role:"dialog",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{id:"gateway-lark-registration-title",children:"Lark Gateway Setup"}),C.jsx("p",{className:"muted",children:"Scan with Lark, approve bot creation, then click Confirm."})]}),C.jsx("button",{type:"button",onClick:s,children:"Close"})]}),C.jsxs("div",{className:"gateway-qr-modal-body",children:[C.jsx("div",{className:"gateway-qr-code-frame",children:f?C.jsx("img",{alt:"Lark Gateway setup QR code",src:f}):C.jsx("div",{className:"gateway-qr-placeholder",children:c?"QR code could not be rendered.":"Rendering QR code..."})}),C.jsx("div",{className:"gateway-qr-actions",children:C.jsx("button",{type:"button",disabled:t,onClick:r,children:"Confirm"})}),C.jsxs("dl",{className:"gateway-qr-meta",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Status"}),C.jsx("dd",{children:(m==null?void 0:m.status)??d.status})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Expires"}),C.jsx("dd",{children:Gv(d.expiresAt)})]}),d.userCode?C.jsxs("div",{children:[C.jsx("dt",{children:"User Code"}),C.jsx("dd",{children:d.userCode})]}):null,m!=null&&m.larkBotName?C.jsxs("div",{children:[C.jsx("dt",{children:"Bot"}),C.jsx("dd",{children:m.larkBotName})]}):null,m!=null&&m.message?C.jsxs("div",{children:[C.jsx("dt",{children:"Message"}),C.jsx("dd",{children:m.message})]}):null]}),C.jsxs("form",{className:"gateway-manual-bind",onSubmit:y=>{y.preventDefault();const _=g.trim(),v=S.trim();if(!_||!v){E("Enter both App ID and App Secret.");return}E(""),x(""),l(_,v)},children:[C.jsxs("div",{children:[C.jsx("label",{htmlFor:"gateway-lark-app-id",children:"App ID"}),C.jsx("input",{id:"gateway-lark-app-id",autoComplete:"off",disabled:t,value:g,onChange:y=>h(y.currentTarget.value),placeholder:"cli_xxx"})]}),C.jsxs("div",{children:[C.jsx("label",{htmlFor:"gateway-lark-app-secret",children:"App Secret"}),C.jsx("input",{id:"gateway-lark-app-secret",autoComplete:"off",disabled:t,type:"password",value:S,onChange:y=>x(y.currentTarget.value),placeholder:"Enter App Secret"})]}),T?C.jsx("p",{className:"form-error",children:T}):null,C.jsx("button",{type:"submit",disabled:t,children:"Bind manually"})]})]})]})})}function Gv(t){const r=new Date(t);return Number.isNaN(r.getTime())?"-":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(r)}let ts=null;function W2(t,r){return`${t}:${r.role}:${r.lastFailureAt}`}function K2(t){const r=Q2(t.role),s=Vv(t);return t.status==="retrying"?`CC 出错,正在重试 ${r}${s} · 第 ${t.attempt}/${t.maxAttempts} 次`:`CC 出错,重试中 ${r}${s} · 第 ${t.attempt}/${t.maxAttempts} 次 · ${J2(t.nextRetryAt)}`}function Y2(t,r){const s=Vv(t);return t.retryable===!1?`CC stopped for ${r}: ${X2(t)} cannot be fixed by retrying.`:`CC retry failed after ${t.maxAttempts} attempts for ${r}${s}.`}function Vv(t){return!t.error||t.error==="unknown"?"":` · ${t.error}`}function X2(t){return t.error&&t.error!=="unknown"?t.error:"this error"}function Q2(t){return t.split("-").filter(Boolean).map(r=>`${r.slice(0,1).toUpperCase()}${r.slice(1)}`).join(" ")}function J2(t){if(!t)return"即将重试";const r=Date.parse(t)-Date.now();return!Number.isFinite(r)||r<=0?"即将重试":`${Math.ceil(r/6e4)} 分钟后`}async function u_(){const t=Wv();return t?Kv(t):!1}async function h_(){const t=Wv();if(!t||!await Kv(t))return!1;try{const s=t.createGain(),l=t.currentTime+.025;return s.gain.setValueAtTime(.85,t.currentTime),s.connect(t.destination),p_(t,s,{frequency:587.33,startAt:l,duration:.18,peakGain:.045}),p_(t,s,{frequency:783.99,startAt:l+.11,duration:.28,peakGain:.055}),window.setTimeout(()=>{s.disconnect()},800),!0}catch{return!1}}function Wv(){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;try{return(!ts||ts.state==="closed")&&(ts=new t),ts}catch{return null}}function f_(t){ts=null,t&&t.state!=="closed"&&t.close().catch(()=>{})}async function Kv(t){if(d_(t))return!0;try{await t.resume();const r=d_(t);return!r&&t===ts&&f_(t),r}catch{return t===ts&&f_(t),!1}}function d_(t){return t.state==="running"}function p_(t,r,s){const l=t.createGain(),d=t.createOscillator(),m=t.createOscillator(),f=s.startAt+s.duration;l.gain.setValueAtTime(1e-4,s.startAt),l.gain.exponentialRampToValueAtTime(s.peakGain,s.startAt+.018),l.gain.exponentialRampToValueAtTime(1e-4,f),d.type="sine",d.frequency.setValueAtTime(s.frequency,s.startAt),m.type="triangle",m.frequency.setValueAtTime(s.frequency*2.01,s.startAt),d.connect(l),m.connect(l),l.connect(r),d.start(s.startAt),m.start(s.startAt),d.stop(f+.02),m.stop(f+.02)}const Yv=document.getElementById("root");if(!Yv)throw new Error("Missing #root element.");X0.createRoot(Yv).render(C.jsx(ee.StrictMode,{children:C.jsx($2,{})}));
|
package/dist-frontend/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>VibeCodingMaster</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-Ct8NwH3l.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C6tXxGlk.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|