vibe-coding-master 0.8.4 → 0.8.5
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 +9 -4
- package/dist/backend/api/task-routes.js +6 -0
- package/dist/backend/gateway/gateway-service.js +18 -3
- package/dist/backend/server.js +4 -1
- package/dist/backend/services/claude-hook-service.js +16 -1
- package/dist/backend/services/gate-review-service.js +4 -1
- package/dist/backend/services/translation-service.js +49 -1
- package/dist/backend/services/user-question-reply.js +10 -0
- package/dist/backend/services/workflow-control-service.js +47 -1
- package/dist/backend/templates/harness/project-manager-agent.js +1 -1
- package/dist/backend/templates/harness/vcm-ask-user-skill.js +2 -2
- package/dist/backend/templates/harness/vcm-workflow-review-skill.js +1 -1
- package/dist-frontend/assets/index-BIFZPhDN.css +32 -0
- package/dist-frontend/assets/{index-ClaVB8jM.js → index-c2YwYw6n.js} +3 -3
- package/dist-frontend/index.html +2 -2
- package/package.json +1 -1
- package/dist-frontend/assets/index-Dc0_KSf4.css +0 -32
|
@@ -90,8 +90,8 @@ WARNING: This link could potentially be dangerous`)){const v=window.open();if(v)
|
|
|
90
90
|
`))}function c(C,T,E,y){const v=E.enter("tableCell"),_=E.enter("phrasing"),b=E.containerPhrasing(C,{...y,before:m,after:m});return _(),v(),b}function u(C,T){return $x(C,{align:T,alignDelimiters:l,padding:s,stringLength:d})}function g(C,T,E){const y=C.children;let v=-1;const _=[],b=T.enter("table");for(;++v<y.length;)_[v]=h(y[v],T,E);return b(),_}function h(C,T,E){const y=C.children;let v=-1;const _=[],b=T.enter("tableRow");for(;++v<y.length;)_[v]=c(y[v],C,T,E);return b(),_}function S(C,T,E){let y=yv.inlineCode(C,T,E);return E.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function ME(){return{exit:{taskListCheckValueChecked:Wg,taskListCheckValueUnchecked:Wg,paragraph:OE}}}function LE(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:BE}}}function Wg(t){const r=this.stack[this.stack.length-2];r.type,r.checked=t.type==="taskListCheckValueChecked"}function OE(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 BE(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=yv.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 jE(){return[dx(),Bx(),zx(),xE(),ME()]}function NE(t){return{extensions:[px(),jx(t),Ix(),DE(t),LE()]}}const HE={tokenize:qE,partial:!0},Sv={tokenize:$E,partial:!0},bv={tokenize:GE,partial:!0},Cv={tokenize:VE,partial:!0},zE={tokenize:WE,partial:!0},wv={name:"wwwAutolink",tokenize:PE,previous:Ev},xv={name:"protocolAutolink",tokenize:FE,previous:kv},Ui={name:"emailAutolink",tokenize:UE,previous:Av},pi={};function IE(){return{text:pi}}let Wr=48;for(;Wr<123;)pi[Wr]=Ui,Wr++,Wr===58?Wr=65:Wr===91&&(Wr=97);pi[43]=Ui;pi[45]=Ui;pi[46]=Ui;pi[95]=Ui;pi[72]=[Ui,xv];pi[104]=[Ui,xv];pi[87]=[Ui,wv];pi[119]=[Ui,wv];function UE(t,r,s){const l=this;let d,m;return f;function f(h){return!Nh(h)||!Av.call(l,l.previous)||sf(l.events)?s(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),o(h))}function o(h){return Nh(h)?(t.consume(h),o):h===64?(t.consume(h),c):s(h)}function c(h){return h===46?t.check(zE,g,u)(h):h===45||h===95||tn(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&&un(l.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),r(h)):s(h)}}function PE(t,r,s){const l=this;return d;function d(f){return f!==87&&f!==119||!Ev.call(l,l.previous)||sf(l.events)?s(f):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(HE,t.attempt(Sv,t.attempt(bv,m),s),s)(f))}function m(f){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),r(f)}}function FE(t,r,s){const l=this;let d="",m=!1;return f;function f(h){return(h===72||h===104)&&kv.call(l,l.previous)&&!sf(l.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),d+=String.fromCodePoint(h),t.consume(h),o):s(h)}function o(h){if(un(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||Oo(h)||pt(h)||Xr(h)||Fo(h)?s(h):t.attempt(Sv,t.attempt(bv,g),s)(h)}function g(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),r(h)}}function qE(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 $E(t,r,s){let l,d,m;return f;function f(u){return u===46||u===95?t.check(Cv,c,o)(u):u===null||pt(u)||Xr(u)||u!==45&&Fo(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 GE(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(Cv,r,m)(f):f===null||pt(f)||Xr(f)?r(f):(t.consume(f),d)}function m(f){return f===41&&l++,t.consume(f),d}}function VE(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||pt(o)||Xr(o)?r(o):s(o)}function d(o){return o===null||o===40||o===91||pt(o)||Xr(o)?r(o):l(o)}function m(o){return un(o)?f(o):s(o)}function f(o){return o===59?(t.consume(o),l):un(o)?(t.consume(o),f):s(o)}}function WE(t,r,s){return l;function l(m){return t.consume(m),d}function d(m){return tn(m)?s(m):r(m)}}function Ev(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||pt(t)}function kv(t){return!un(t)}function Av(t){return!(t===47||Nh(t))}function Nh(t){return t===43||t===45||t===46||t===95||tn(t)}function sf(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 KE={tokenize:nk,partial:!0};function YE(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ZE,continuation:{tokenize:ek},exit:tk}},text:{91:{name:"gfmFootnoteCall",tokenize:JE},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:XE,resolveTo:QE}}}}function XE(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=ri(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 QE(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 JE(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||pt(h))return s(h);if(h===93){t.exit("chunkString");const S=t.exit("gfmFootnoteCallString");return d.includes(ri(l.sliceSerialize(S)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),r):s(h)}return pt(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 ZE(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||pt(T))return s(T);if(T===93){t.exit("chunkString");const E=t.exit("gfmFootnoteDefinitionLabelString");return m=ri(l.sliceSerialize(E)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),S}return pt(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),et(t,C,"gfmFootnoteDefinitionWhitespace")):s(T)}function C(T){return r(T)}}function ek(t,r,s){return t.check(hl,r,t.attempt(KE,r,s))}function tk(t){t.exit("gfmFootnoteDefinition")}function nk(t,r,s){const l=this;return et(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 ik(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]],C=o.parser.constructs.insideSpan.null;C&&Nn(S,S.length,0,qo(C,f.slice(u+1,c),o)),Nn(S,S.length,0,[["exit",h,o],["enter",f[c][1],o],["exit",f[c][1],o],["exit",g,o]]),Nn(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"),C(T))}function C(T){const E=Vs(u);if(T===126)return h>1?c(T):(f.consume(T),h++,C);if(h<2&&!s)return c(T);const y=f.exit("strikethroughSequenceTemporary"),v=Vs(T);return y._open=!v||v===2&&!!E,y._close=!E||E===2&&!!v,o(T)}}}class rk{constructor(){this.map=[]}add(r,s,l){sk(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 sk(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 ak(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 lk(){return{flow:{null:{name:"table",tokenize:ok,resolveAll:ck}}}}function ok(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):Me(O)?m>1?(m=0,l.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),C):s(O):Ye(O)?et(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||pt(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 C(O){return l.interrupt=!1,l.parser.lazy[l.now().line]?s(O):(t.enter("tableDelimiterRow"),f=!1,Ye(O)?et(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)?et(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"),v):O===45?(m+=1,v(O)):O===null||Me(O)?k(O):L(O)}function v(O){return O===45?(t.enter("tableDelimiterFiller"),_(O)):L(O)}function _(O){return O===45?(t.consume(O),_):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)?et(t,k,"whitespace")(O):k(O)}function k(O){return O===124?T(O):O===null||Me(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||Me(O)?(t.exit("tableRow"),r(O)):Ye(O)?et(t,D,"whitespace")(O):(t.enter("data"),A(O))}function A(O){return O===null||O===124||pt(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 ck(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 rk;for(;++s<t.length;){const C=t[s],T=C[1];C[0]==="enter"?T.type==="tableHead"?(o=!1,c!==0&&(Kg(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=To(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=To(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=To(S,r,m,d,s,h)):f[1]!==0&&(h=To(S,r,f,d,s,h)),d=0):d&&(T.type==="data"||T.type==="tableDelimiterMarker"||T.type==="tableDelimiterFiller")&&(f[3]=s)}for(c!==0&&Kg(S,r,c,u,g),S.consume(r.events),s=-1;++s<r.events.length;){const C=r.events[s];C[0]==="enter"&&C[1].type==="table"&&(C[1]._align=ak(r.events,s))}return t}function To(t,r,s,l,d,m){const f=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",o="tableContent";s[0]!==0&&(m.end=Object.assign({},Fs(r.events,s[0])),t.add(s[0],0,[["exit",m,r]]));const c=Fs(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=Fs(r.events,s[2]),g=Fs(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]],C=r.events[s[3]];if(S[1].end=Object.assign({},C[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({},Fs(r.events,d)),t.add(d,0,[["exit",m,r]]),m=void 0),m}function Kg(t,r,s,l,d){const m=[],f=Fs(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 Fs(t,r){const s=t[r],l=s[0]==="enter"?"start":"end";return s[1][l]}const uk={name:"tasklistCheck",tokenize:fk};function hk(){return{text:{91:uk}}}function fk(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 pt(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 Me(c)?r(c):Ye(c)?t.check({tokenize:dk},r,s)(c):s(c)}}function dk(t,r,s){return et(t,l,"whitespace");function l(d){return d===null?s(d):r(d)}}function pk(t){return H_([IE(),YE(),ik(t),lk(),hk()])}const mk={};function Tv(t){const r=this,s=t||mk,l=r.data(),d=l.micromarkExtensions||(l.micromarkExtensions=[]),m=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),f=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);d.push(pk(s)),m.push(jE()),f.push(NE(s))}const Rv=1e3,qs=new Map;let il;function gk(t,r,s){const l=Symbol(t),d=Math.max(Rv,s.intervalMs),m=Date.now();return qs.set(t,{id:t,intervalMs:d,nextRunAt:s.runImmediately===!1?m+d:m,inFlight:!1,run:r,token:l}),_k(),Dv(),()=>{const f=qs.get(t);(f==null?void 0:f.token)===l&&(qs.delete(t),qs.size===0&&il!==void 0&&(window.clearInterval(il),il=void 0))}}function _k(){il!==void 0||typeof window>"u"||(il=window.setInterval(()=>{Dv()},Rv))}async function Dv(){const t=Date.now();for(const r of qs.values())r.inFlight||r.nextRunAt>t||vk(r)}async function vk(t){t.inFlight=!0;try{await t.run()}catch{}finally{const r=qs.get(t.id);(r==null?void 0:r.token)===t.token&&(r.inFlight=!1,r.nextRunAt=Date.now()+r.intervalMs)}}function ol(t,r,s){const l=ee.useRef(r);ee.useEffect(()=>{l.current=r},[r]),ee.useEffect(()=>{if(!(!t||s.enabled===!1))return gk(t,()=>l.current(),{intervalMs:s.intervalMs,runImmediately:s.runImmediately})},[t,s.enabled,s.intervalMs,s.runImmediately])}const Ho=`
|
|
91
91
|
|
|
92
92
|
--- Translation ---
|
|
93
|
-
`;function yk({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,C]=ee.useState(""),[T,E]=ee.useState(!1),[y,v]=ee.useState(Date.now()),[_,b]=ee.useState(!1),[,k]=Ii(""),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=Ak(R);ee.useEffect(()=>{if(!M)return;v(Date.now());const N=window.setInterval(()=>v(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(Lv(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),C("")}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?Xg(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(),!_&&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=Tk(R,A,y),z=D.length,j=bk(D);return w.jsxs("aside",{className:"translation-panel",children:[w.jsxs("header",{className:"translation-panel-header",children:[w.jsxs("div",{className:"translation-panel-titlebar",children:[w.jsx("h2",{children:"Translation"}),w.jsxs("div",{className:"translation-panel-actions",children:[z>0?w.jsxs(w.Fragment,{children:[w.jsxs("button",{type:"button",disabled:_,onClick:()=>void V(),children:["Ignore ",z]}),j?w.jsx("button",{type:"button",disabled:_,onClick:()=>void Y(j),children:"Retry latest"}):null]}):null,w.jsx("button",{type:"button",disabled:_,onClick:()=>void U(),children:"Translate final reply"}),w.jsx("button",{type:"button",onClick:()=>void K(),children:"Clear"})]})]}),w.jsx("div",{className:"translation-status-row",children:w.jsxs("p",{children:["Claude Code · target ",Sk(s)," · ",te]})})]}),w.jsx("div",{className:"translation-manual-panel",children:w.jsxs("div",{className:"translation-composer-row translation-manual-row",children:[w.jsx("textarea",{value:S,onChange:N=>C(N.target.value),placeholder:"Paste English to translate on demand..."}),w.jsx("div",{className:"translation-composer-actions",children:w.jsx("button",{type:"button",disabled:_||!S.trim(),onClick:()=>void H(),children:"Translate"})})]})}),w.jsxs("div",{className:"translation-entry-list",ref:L,children:[R.length===0?w.jsx("p",{className:"muted",children:"Translated Claude Code output will appear here."}):null,R.map(N=>w.jsx(Ek,{entry:N},N.id))]}),w.jsx("div",{className:"translation-composer",children:w.jsxs("div",{className:"translation-composer-row",children:[w.jsx("textarea",{value:g,onChange:N=>{h(N.target.value),(!N.target.value.trim()||T&&!Mk(N.target.value))&&E(!1)},onKeyDown:W,placeholder:"输入中文,先翻译成英文工程指令..."}),w.jsx("div",{className:"translation-composer-actions",children:w.jsx("button",{type:"button",disabled:_||!T||!Xg(g).trim(),onClick:()=>void P(),children:"Send English"})})]})})]})}function Sk(t){var r;return((r=g_.find(s=>s.value===t))==null?void 0:r.label)??t}function bk(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 Ck({open:t,taskSlug:r,targetLanguage:s,onClose:l}){const[d,m]=ee.useState(!1),[,f]=Ii(""),[o,c]=ee.useState(null),[u,g]=ee.useState(""),[h,S]=ee.useState(""),[C,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);ol(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});_(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?w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"modal-backdrop file-translation-backdrop",children:w.jsx(xk,{busy:d,state:o,selectedJobId:u,output:h,report:C,onClose:()=>{y(!1),l()},onRefresh:()=>void H(),onSelectJob:V=>void U(V),onTranslate:()=>void P()})}),E?w.jsx(wk,{busy:d||M,state:v,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 wk({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(C=>C.type==="directory"),S=g.filter(C=>C.type==="file");return w.jsx("div",{className:"modal-backdrop translation-file-browser-backdrop",children:w.jsxs("section",{className:"translation-file-browser-modal",role:"dialog","aria-modal":"true","aria-label":"Select Source File",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Select Source File"}),w.jsx("p",{children:s||"."})]}),w.jsx("button",{type:"button",onClick:f,children:"Close"})]}),w.jsxs("div",{className:"translation-file-browser-controls",children:[w.jsxs("div",{className:"translation-file-browser-nav",children:[w.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m((r==null?void 0:r.parentPath)??"",""),children:"Up"}),w.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m("",""),children:"Root"})]}),w.jsxs("form",{className:"translation-file-browser-search",onSubmit:C=>{C.preventDefault(),m(s,l)},children:[w.jsx("input",{value:l,onChange:C=>o(C.target.value),placeholder:"Search files"}),w.jsx("button",{type:"submit",disabled:t,children:"Search"}),w.jsx("button",{type:"button",disabled:t||!l,onClick:()=>m(s,""),children:"Clear"})]})]}),w.jsxs("div",{className:"translation-file-browser-layout",children:[w.jsxs("div",{className:"translation-file-browser-list",children:[t&&!r?w.jsx("p",{className:"muted",children:"Loading files..."}):null,!t&&g.length===0?w.jsx("p",{className:"muted",children:"No source files found."}):null,h.length>0?w.jsxs("div",{className:"translation-file-browser-group",children:[w.jsx("h3",{children:"Folders"}),h.map(C=>w.jsx(Yg,{entry:C,selected:d===C.path,onBrowse:m,onSelectPath:c},C.path))]}):null,S.length>0?w.jsxs("div",{className:"translation-file-browser-group",children:[w.jsx("h3",{children:"Files"}),S.map(C=>w.jsx(Yg,{entry:C,selected:d===C.path,onBrowse:m,onSelectPath:c},C.path))]}):null,r!=null&&r.truncated?w.jsx("p",{className:"translation-entry-note",children:"Result limit reached."}):null]}),w.jsxs("aside",{className:"translation-file-browser-selection",children:[w.jsxs("label",{children:[w.jsx("span",{children:"Source path"}),w.jsx("input",{value:d,onChange:C=>c(C.target.value)})]}),w.jsx("button",{type:"button",disabled:t||!d.trim(),onClick:u,children:"Translate File"})]})]})]})})}function Yg({entry:t,selected:r,onBrowse:s,onSelectPath:l}){const d=t.type==="directory";return w.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:[w.jsx("span",{children:d?"DIR":"FILE"}),w.jsx("strong",{children:t.name}),w.jsx("small",{children:t.path})]})}function xk({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 w.jsxs("section",{className:"file-translation-modal",role:"dialog","aria-modal":"true","aria-label":"File Translation",children:[w.jsxs("header",{className:"file-translation-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"File Translation"}),w.jsx("p",{children:"Claude Code · 中英互译"})]}),w.jsxs("div",{className:"file-translation-toolbar",children:[w.jsx("button",{type:"button",disabled:t,onClick:c,children:"Translate"}),w.jsx("button",{type:"button",disabled:t,onClick:f,children:"Refresh"}),w.jsx("button",{type:"button",onClick:m,children:"Close"})]})]}),r!=null&&r.memoryInitialized?null:w.jsx("p",{className:"translation-entry-note",children:"Translation memory is not initialized. Run Bootstrap from the sidebar before important file translations."}),w.jsxs("div",{className:"file-translation-layout",children:[w.jsxs("div",{className:"file-translation-list",children:[u.length===0?w.jsx("p",{className:"muted",children:"No translated files yet."}):null,u.map(h=>w.jsxs("button",{className:h.id===s?"file-translation-item is-active":"file-translation-item",type:"button",onClick:()=>o(h.id),children:[w.jsx("strong",{children:h.sourcePath}),w.jsxs("span",{children:[h.status," · ",h.targetLanguage]})]},h.id))]}),w.jsx("div",{className:"file-translation-preview",children:g?w.jsxs(w.Fragment,{children:[w.jsxs("header",{children:[w.jsx("strong",{children:g.sourcePath}),w.jsx("span",{children:g.status})]}),w.jsx("div",{className:"translation-markdown",children:w.jsx(rv,{remarkPlugins:[Tv],children:l||d||"Translation output is not available yet."})})]}):w.jsx("p",{className:"muted",children:"Select a translated file to preview it."})})]})]})}function Ek({entry:t}){if(t.sourceKind==="conversation-boundary")return w.jsx(kk,{entry:t});const r=Dk(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 w.jsxs("article",{className:d,children:[s?w.jsx("pre",{children:r}):w.jsx("div",{className:"translation-markdown",children:w.jsx(rv,{remarkPlugins:[Tv],children:r})}),t.warning?w.jsx("p",{className:"translation-entry-note",children:t.warning}):null,t.error?w.jsx("p",{className:"translation-entry-note is-error",children:t.error}):null]})}function kk({entry:t}){const r=t.boundaryKind==="end"?"结束":"开始",s=t.conversationTurn??0,l=Ok(t.occurredAt??t.createdAt);return w.jsxs("div",{className:"translation-conversation-boundary","aria-label":`${r} 第 ${s} 轮 ${l}`,children:[w.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"}),w.jsx("span",{children:r}),w.jsxs("span",{children:["第 ",s," 轮"]}),w.jsx("time",{children:l}),w.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"})]})}function Ak(t){const r=t.find(Mv);return(r==null?void 0:r.translationStartedAt)??(r==null?void 0:r.createdAt)}function Tk(t,r,s){const l=t.find(Mv);if(l)return`translating ${Lk(Math.max(0,s-Rk(l)))}`;const d=t.at(-1);return(d==null?void 0:d.status)==="failed"||r==="failed"?"error":r}function Mv(t){return t.status==="queued"||t.status==="translating"}function Rk(t){const r=Date.parse(t.translationStartedAt??t.createdAt);return Number.isFinite(r)?r:Date.now()}function Dk(t){return t.status==="queued"||t.status==="translating"?t.sourceText:t.status==="translated"?t.direction==="user-input-to-english"?Lv(t.sourceText,t.translatedText):t.translatedText:t.translatedText||t.sourceText}function Lv(t,r){return`${t.trimEnd()}${Ho}${r.trimStart()}`}function Mk(t){return t.includes(Ho)}function Xg(t){const r=t.indexOf(Ho);return r===-1?t:t.slice(r+Ho.length)}function Lk(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 Ok(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleTimeString()}const Bk=8;function jk(){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,Bk)})},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(bh,s),window.addEventListener(Ch,l),window.addEventListener(wh,d),()=>{window.removeEventListener(bh,s),window.removeEventListener(Ch,l),window.removeEventListener(wh,d)}},[]),t.length===0?null:w.jsxs("aside",{className:"ui-error-center",role:"alert","aria-live":"polite","aria-label":"Application errors",children:[w.jsxs("header",{className:"ui-error-center-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Errors"}),w.jsxs("p",{children:[t.length," active"]})]}),w.jsx("button",{type:"button",onClick:()=>r([]),children:"Clear"})]}),w.jsx("ol",{className:"ui-error-list",children:t.map(s=>w.jsxs("li",{children:[w.jsxs("div",{children:[w.jsx("p",{children:s.message}),w.jsxs("span",{children:[Nk(s.updatedAt),s.count>1?` · repeated ${s.count} times`:""]})]}),w.jsx("button",{type:"button","aria-label":"Dismiss error",onClick:()=>r(l=>l.filter(d=>d.id!==s.id)),children:"Close"})]},s.id))})]})}function Nk(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Hk(t,r){return t.find(s=>s.taskSlug===r)??t[0]??null}function zk(t){if(!(t.mode!=="auto"||t.status!=="running")&&!(!t.activeRole||t.activeRole===t.lastFollowedRole))return t.activeRole}function Ik(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):`No new turn started after ${s} stopped.`}function Uk(t){const r=t.roundId??t.startedAt??t.taskSlug,s=t.stoppedAt??t.lastTurnEndedAt??"stopped";return`${r}:${s}`}function Pk(t){return t?"strong":"none"}function Fk(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 qk=3,$k=3e4,Mo=new Map;function Ov(t,r){const s=ft(t,r);if(!Gk(r))return Mo.set(t,{consecutiveFailures:1,lastMessage:s,lastReportedAt:Date.now()}),s;const l=Mo.get(t),d=((l==null?void 0:l.consecutiveFailures)??0)+1,m=Date.now(),f=d>=qk&&(!l||l.lastMessage!==s||m-l.lastReportedAt>=$k);return Mo.set(t,{consecutiveFailures:d,lastMessage:s,lastReportedAt:f?m:(l==null?void 0:l.lastReportedAt)??0}),f?s:null}function zo(t){Mo.delete(t),yS([t])}function Gk(t){const r=cl(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 Vk=["architecture-plan","validation-adequacy","code-diff"];function Wk({events:t,maxEvents:r=8,showHeader:s=!0}){const l=r===null?t:t.slice(-r);return w.jsxs("section",{className:"event-log",children:[s?w.jsx("h2",{children:"Events"}):null,t.length===0?w.jsx("p",{className:"muted",children:"No terminal events yet."}):w.jsx("ol",{children:l.map((d,m)=>w.jsx("li",{children:d},`${d}-${m}`))})]})}function Hn({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 w.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":`${l}: ${c}`,className:o,disabled:s,title:m,onClick:()=>f(!t),children:[w.jsx("span",{className:"switch-control-label",children:l}),w.jsx("span",{className:"switch-control-track","aria-hidden":"true",children:w.jsx("span",{className:"switch-control-thumb"})})]})}function Kk({status:t,bootstrapStatus:r,applyResult:s,hasActiveTask:l=!1,autoTaskHarnessReviewEnabled:d,autoMemoryEnabled:m,launchOptions:f,modelOptions:o,busy:c=!1,onRefresh:u,onApply:g,onOpenStudio:h,onOpenRepositoryDiff:S,onAutoTaskHarnessReviewChange:C,onAutoMemoryChange:T,onLaunchOptionsChange:E,onStartBootstrap:y,onRestartBootstrap:v,onStopBootstrap:_,onRunBootstrap:b}){const[k,L]=ee.useState(!1),R=r==null?void 0:r.session,D=(r==null?void 0:r.status)==="running",A=(R==null?void 0:R.status)==="running",M=(r==null?void 0:r.status)!=="complete";return l?t?w.jsxs("section",{className:"harness-panel",children:[w.jsxs("div",{className:"harness-stage",children:[w.jsxs("div",{className:"harness-panel-header",children:[w.jsxs("div",{children:[w.jsx("strong",{children:"Fixed install"}),w.jsx("p",{className:"muted",children:t.initialized?t.needsApply?`${t.plannedChanges.length} pending updates`:"Up to date":"Not initialized"})]}),w.jsx("div",{className:"harness-actions",children:t.initialized?w.jsxs(w.Fragment,{children:[w.jsx("button",{type:"button",disabled:c,onClick:()=>void u(),children:"Refresh"}),t.needsApply?w.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Update"}):null]}):w.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Initialize"})})]}),t.initialized&&t.needsApply?w.jsxs(w.Fragment,{children:[w.jsx("h3",{className:"harness-file-list-title",children:"Files to update"}),w.jsx("ol",{className:"harness-file-list",children:t.plannedChanges.map(O=>w.jsxs("li",{children:[w.jsx("span",{children:O.path}),w.jsx(jn,{status:O.action})]},`${O.path}:${O.action}`))})]}):null]}),w.jsxs("div",{className:"harness-stage",children:[w.jsxs("div",{className:"harness-panel-header",children:[w.jsx("div",{children:w.jsx("strong",{children:"Harness Studio"})}),w.jsx("div",{className:"harness-actions",children:w.jsx("button",{type:"button",disabled:c,onClick:h,children:"Open Studio"})})]}),w.jsx("button",{className:"harness-review-diff-button",type:"button",disabled:c,onClick:S,children:"Review Diff"}),w.jsx(Hn,{checked:d,className:"sidebar-switch",disabled:c,label:"Auto task harness review",title:"Automatically ask Harness Engineer to review task harness after final acceptance completes",onChange:C}),w.jsx(Hn,{checked:m,className:"sidebar-switch",disabled:c,label:"Auto memory",title:"Collect role memory drafts after Final Acceptance and let Harness Engineer apply reviewed memory",onChange:T})]}),M?w.jsx("div",{className:"harness-stage",children:w.jsxs("div",{className:"harness-panel-header",children:[w.jsxs("div",{children:[w.jsx("strong",{children:"Bootstrap"}),w.jsx("p",{className:"muted",children:r?Yk(r.status):"not loaded"})]}),w.jsx("div",{className:"harness-actions",children:w.jsx("button",{type:"button",disabled:c||!(r!=null&&r.canStart),onClick:()=>{L(!0)},children:"Open Bootstrap"})})]})}):null,s!=null&&s.changedFiles.length?w.jsx("div",{className:"harness-result",children:w.jsx("p",{className:"muted",children:s.message})}):null,t.warnings.length>0?w.jsx("ul",{className:"warnings",children:t.warnings.map(O=>w.jsx("li",{children:O},O))}):null,r!=null&&r.warnings.length?w.jsx("ul",{className:"warnings",children:r.warnings.map(O=>w.jsx("li",{children:O},O))}):null,M&&k?w.jsx("div",{className:"harness-bootstrap-modal",role:"dialog","aria-modal":"true","aria-label":"Harness Engineer bootstrap session",children:w.jsxs("div",{className:"harness-bootstrap-modal-surface",children:[w.jsxs("header",{className:"harness-bootstrap-modal-header",children:[w.jsxs("div",{children:[w.jsx("strong",{children:"Harness Engineer Bootstrap"}),w.jsx("p",{className:"muted",children:(R==null?void 0:R.command)??"Start Harness Engineer, then run bootstrap when ready."})]}),w.jsxs("div",{className:"harness-bootstrap-modal-actions",children:[R?w.jsx(jn,{status:R.status}):null,w.jsx("button",{type:"button",onClick:()=>L(!1),children:"Close"})]})]}),w.jsxs("div",{className:"harness-bootstrap-controls",children:[w.jsxs("label",{children:[w.jsx("span",{children:"Permission"}),w.jsx("select",{value:f.permissionMode,disabled:c||D||A,onChange:O=>E({...f,permissionMode:O.target.value}),children:__.map(O=>w.jsx("option",{value:O.value,children:O.label},O.value))})]}),w.jsxs("label",{children:[w.jsx("span",{children:"Model"}),w.jsx("select",{value:f.model,title:(()=>{const O=o.find(H=>H.value===f.model);return O!=null&&O.available?O.description:O==null?void 0:O.unavailableReason})(),disabled:c||D||A,onChange:O=>E({...f,model:O.target.value}),children:o.map(O=>w.jsx("option",{value:O.value,disabled:!O.available,title:O.available?O.description:O.unavailableReason,children:O.label},O.value))})]}),w.jsxs("label",{children:[w.jsx("span",{children:"Effort"}),w.jsx("select",{value:f.effort,disabled:c||D||A,onChange:O=>E({...f,effort:O.target.value}),children:y_.map(O=>w.jsx("option",{value:O.value,children:O.label},O.value))})]}),w.jsxs("div",{className:"harness-bootstrap-control-actions",children:[w.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void y(f),children:"Start"}),w.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void v(f),children:"Restart"}),w.jsx("button",{type:"button",disabled:c||!R,onClick:()=>void _(),children:"Stop"}),w.jsx("button",{type:"button",disabled:c||D||!A,onClick:()=>void b(),children:"Run bootstrap"})]})]}),w.jsx("div",{className:"harness-bootstrap-terminal",children:A?w.jsx(Po,{sessionId:R.id,active:k}):w.jsxs("div",{className:"terminal-empty",children:[w.jsx("strong",{children:"Harness Bootstrap"}),w.jsx("span",{children:"Start Harness Engineer first. When it is ready, click Run bootstrap to send the prompt."})]})})]})}):null]}):null:w.jsx("section",{className:"harness-panel",children:w.jsxs("div",{className:"harness-result",children:[w.jsx("strong",{children:"Task required"}),w.jsx("p",{className:"muted",children:"Create or select a task before changing VCM Harness. Harness changes are committed in the active task worktree."})]})})}function Yk(t){return t.replaceAll("_"," ")}function af(t){return{total:t.length,accepted:t.filter(r=>r.acceptedAt).length,delivered:t.filter(r=>r.deliveredAt).length}}function Xk(t,r=6){const s=[...t].sort(Zk).map((d,m)=>({message:d,sequence:m+1}));return[...r===null?s:s.slice(-r)].sort((d,m)=>m.sequence-d.sequence)}function Qk({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=af(t),h=(r==null?void 0:r.mode)??"auto",S=Xk(t,l);async function C(T){await e2(T.body),u(T.id),window.setTimeout(()=>u(E=>E===T.id?null:E),1200)}return w.jsxs("section",{className:"message-panel",children:[m?w.jsxs("div",{className:"message-panel-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Messages"}),w.jsxs("p",{className:"muted",children:[g.total," total / ",g.accepted," accepted"]})]}),d&&f?w.jsx("div",{className:"message-controls",children:w.jsx(Hn,{checked:h==="auto",className:"message-mode-toggle",disabled:s,label:"Auto orchestration",onChange:T=>f(T?"auto":"manual")})}):null,d&&o?w.jsx("button",{type:"button",disabled:s,onClick:o,children:"Mark All Done"}):null]}):null,t.length===0?w.jsx("p",{className:"muted",children:"No role messages yet."}):w.jsx("ol",{className:"message-list",children:S.map(({message:T,sequence:E})=>w.jsxs("li",{className:"message-item",children:[w.jsxs("div",{className:"message-item-main",children:[w.jsxs("div",{className:"message-meta",children:[w.jsxs("span",{className:"message-sequence",children:["#",E]}),w.jsx("time",{dateTime:Io(T),children:Jk(Io(T))}),w.jsxs("strong",{children:[T.fromRole," ","->"," ",T.toRole]}),w.jsx("span",{children:T.type})]}),w.jsx("p",{children:T.body}),T.failureReason?w.jsx("span",{className:"message-reason",children:T.failureReason}):null,T.bodyPath?w.jsx("span",{className:"message-path",children:T.bodyPath}):null]}),w.jsx("div",{className:"message-actions",children:w.jsx("button",{type:"button",disabled:s,onClick:()=>void C(T),children:c===T.id?"Copied":"Copy"})})]},T.id))})]})}function Jk(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 Io(t){return t.acceptedAt??t.deliveredAt??t.dispatchingAt??t.createdAt}function Zk(t,r){const s=Io(t).localeCompare(Io(r));if(s!==0)return s;const l=t.createdAt.localeCompare(r.createdAt);return l!==0?l:t.id.localeCompare(r.id)}async function e2(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 t2({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 w.jsx("form",{className:"repo-connect",onSubmit:f,children:w.jsxs("div",{className:r.length>0?"inline-form has-recent-paths":"inline-form",children:[w.jsx("input",{"aria-label":"Repository path",id:"repo-path",value:d,onChange:o=>m(o.target.value),placeholder:"/path/to/repo"}),r.length>0?w.jsxs("select",{"aria-label":"Recent repositories",className:"repo-recent-select",value:"",onChange:o=>{o.target.value&&m(o.target.value)},children:[w.jsx("option",{value:"",children:"Recent"}),r.map(o=>w.jsx("option",{value:o,children:o},o))]}):null,w.jsx("button",{type:"submit",disabled:s||!d.trim(),children:"Connect"})]})})}function n2({tasks:t,activeTaskSlug:r,onSelect:s}){return w.jsx("nav",{className:"task-nav","aria-label":"Tasks",children:t.map(l=>w.jsxs("button",{className:l.taskSlug===r?"task-nav-item is-active":"task-nav-item",type:"button",onClick:()=>s(l.taskSlug),children:[w.jsx("span",{children:l.title||l.taskSlug}),w.jsx(jn,{status:l.status})]},l.taskSlug))})}function i2({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: ${cl(h)}`)}finally{o(!1)}},[r]);return ee.useEffect(()=>{t&&g()},[g,t]),t?w.jsx("div",{className:"modal-backdrop usage-analytics-backdrop",children:w.jsxs("section",{className:"usage-analytics-modal",role:"dialog","aria-modal":"true","aria-label":"Usage Analytics",children:[w.jsxs("header",{className:"usage-analytics-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Usage Analytics"}),w.jsxs("p",{children:[(s==null?void 0:s.trim())||r," · Claude models only"]})]}),w.jsxs("div",{className:"usage-analytics-header-actions",children:[w.jsx("button",{type:"button",disabled:f,onClick:()=>void g(),children:f?"Refreshing...":"Refresh"}),w.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),c?w.jsx("p",{className:"inline-error usage-analytics-error",children:c}):null,d?w.jsx(r2,{report:d}):w.jsx("div",{className:"usage-analytics-empty",children:f?"Loading usage data...":"No usage data available."})]})}):null}function r2({report:t}){return w.jsxs("div",{className:"usage-analytics-content",children:[w.jsxs("div",{className:"usage-analytics-meta",children:[w.jsx("span",{children:t.updatedAt?`Updated ${a2(t.updatedAt)}`:"No Claude usage recorded yet"}),w.jsxs("span",{children:[bn(t.totals.requestCount)," requests · ",bn(t.totals.sessionCount)," sessions"]})]}),w.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-task-summary",children:[w.jsx("h3",{id:"usage-task-summary",children:"Task Summary"}),w.jsx(s2,{totals:t.totals})]}),w.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-role",children:[w.jsx("h3",{id:"usage-by-role",children:"Usage by Role"}),w.jsx("div",{className:"usage-analytics-table-wrap",children:w.jsxs("table",{className:"usage-analytics-table",children:[w.jsx("thead",{children:w.jsx(Qg,{firstColumn:"Role"})}),w.jsx("tbody",{children:t.byRole.map(r=>w.jsxs("tr",{children:[w.jsxs("th",{scope:"row",children:[w.jsx("span",{children:aS(r.role).label}),w.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),w.jsx(Jg,{totals:r})]},r.role))})]})})]}),w.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-model",children:[w.jsx("h3",{id:"usage-by-model",children:"Usage by Model"}),t.byModel.length>0?w.jsx("div",{className:"usage-analytics-table-wrap",children:w.jsxs("table",{className:"usage-analytics-table",children:[w.jsx("thead",{children:w.jsx(Qg,{firstColumn:"Model"})}),w.jsx("tbody",{children:t.byModel.map(r=>w.jsxs("tr",{children:[w.jsxs("th",{scope:"row",children:[w.jsx("span",{children:r.model}),w.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),w.jsx(Jg,{totals:r})]},r.model))})]})}):w.jsx("p",{className:"usage-analytics-no-models",children:"No Claude model usage recorded yet."})]})]})}function s2({totals:t}){return w.jsxs("dl",{className:"usage-totals-grid",children:[w.jsx(Ja,{label:"Input Tokens",value:bn(t.inputTokens)}),w.jsx(Ja,{label:"Output Tokens",value:bn(t.outputTokens)}),w.jsx(Ja,{label:"Cache Read",value:bn(t.cacheReadTokens)}),w.jsx(Ja,{label:"Cache Creation",value:bn(t.cacheCreationTokens)}),w.jsx(Ja,{label:"Estimated Cost",value:Bv(t.costUsd)})]})}function Ja({label:t,value:r}){return w.jsxs("div",{children:[w.jsx("dt",{children:t}),w.jsx("dd",{children:r})]})}function Qg({firstColumn:t}){return w.jsxs("tr",{children:[w.jsx("th",{scope:"col",children:t}),w.jsx("th",{scope:"col",children:"Input"}),w.jsx("th",{scope:"col",children:"Output"}),w.jsx("th",{scope:"col",children:"Cache Read"}),w.jsx("th",{scope:"col",children:"Cache Creation"}),w.jsx("th",{scope:"col",children:"Estimated Cost"})]})}function Jg({totals:t}){return w.jsxs(w.Fragment,{children:[w.jsx("td",{children:bn(t.inputTokens)}),w.jsx("td",{children:bn(t.outputTokens)}),w.jsx("td",{children:bn(t.cacheReadTokens)}),w.jsx("td",{children:bn(t.cacheCreationTokens)}),w.jsx("td",{children:Bv(t.costUsd)})]})}function bn(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function Bv(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(t)}function a2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function l2({project:t,recentRepositoryPaths:r,tasks:s,activeTaskSlug:l,messages:d,orchestration:m,events:f,roundState:o,gateReview:c,translationEnabled:u,translationAutoSendEnabled:g,translationTargetLanguage:h,translationOutputMode:S,translationMemoryInitialized:C,translatorSession:T,harnessStatus:E,harnessBootstrapStatus:y,harnessApplyResult:v,harnessEngineerLaunchOptions:_,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,gatewayStatus:L,gatewayQrLogin:R,gatewayQrCheck:D,gatewayLarkRegistration:A,gatewayLarkRegistrationCheck:M,codexBridgeStatus:O,modelOptions:H,busy:U,onConnect:P,onRefreshConnectedRepository:W,onPullConnectedRepository:K,onRefreshHarness:V,onApplyHarness:Y,onStartHarnessBootstrap:te,onRestartHarnessBootstrap:z,onStopHarnessBootstrap:j,onRunHarnessBootstrap:N,onOpenHarnessStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onHarnessEngineerLaunchOptionsChange:_e,onRefreshGateway:Q,onGatewayEnabledChange:$,onGatewaySettingsChange:he,onCodexBridgeSettingsChange:ae,onCodexBridgeCheck:Ce,onGatewayTranslationChange:be,onGatewayConnectionChange:Le,onStartGatewayQrLogin:Fe,onStartGatewayLarkRegistration:He,onResetGatewayBinding:Ee,onGateReviewGateEnabledChange:ce,onCancelGateReviewGate:ze,onTranslationEnabledChange:St,onTranslationAutoSendChange:mt,onTranslationTargetLanguageChange:de,onTranslationOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it,onCreateTranslationBootstrap:wt,onUpdateTranslationMemory:fe,onCreateTask:we,onCloseTask:Te,onSelectTask:Be,themeMode:je,onAutoOrchestrationChange:bt,onThemeModeChange:qe,pauseAlertSound:Et,onPauseAlertSoundChange:xt,roleRetryEnabled:Nt,onRoleRetryEnabledChange:rt,permissionRequestMode:Wt,onPermissionRequestModeChange:rn,launchTemplate:Cr,canSaveLaunchTemplate:mi,canOneClickStart:gi,onSaveLaunchTemplate:Pi,onOneClickStart:zn,onMarkAllMessagesDone:Fi,onDeleteMessageHistory:Jn}){const[si,sn]=ee.useState(""),[ai,In]=ee.useState(!1),[qi,_i]=ee.useState(!1),[vi,yi]=ee.useState(!1),[wn,Pt]=ee.useState(()=>l?null:"repository"),li=af(d),hn=si.trim(),Kt=f2(t,l,E),gt=s.filter(Ve=>Ve.cleanupStatus!=="cleaned"),ot=gt.find(Ve=>Ve.taskSlug===l)??null;ee.useEffect(()=>{Pt(Ve=>!l&&Ve===null?t?"task":"repository":Ve)},[l,t]);function Ht(Ve,Un){Pt(Un?Ve:null)}async function $i(Ve){Ve.preventDefault(),await we({taskSlug:hn}),sn("")}return w.jsxs("div",{className:"project-dashboard",children:[w.jsx("header",{className:"brand-header",children:w.jsx("strong",{children:"VibeCodingMaster"})}),w.jsx(Kr,{title:"Repository",open:wn==="repository",onOpenChange:Ve=>{Ht("repository",Ve),Ve&&t&&W()},children:w.jsxs("div",{className:"repository-panel",children:[w.jsx(t2,{defaultPath:(t==null?void 0:t.repoRoot)??"",recentPaths:r,busy:U,onConnect:P}),t?w.jsx(g2,{busy:U,project:t,onPull:K}):null]})}),w.jsx(Kr,{title:"Settings",open:wn==="settings",onOpenChange:Ve=>Ht("settings",Ve),children:w.jsxs("div",{className:"sidebar-settings",children:[w.jsxs("button",{"aria-label":`Theme mode: ${e_(je)}`,className:"settings-toggle theme-mode-toggle",disabled:U,title:"Cycle theme: system, light, dark",type:"button",onClick:()=>qe(b2(je)),children:[w.jsx("span",{children:"Theme"}),w.jsx("span",{children:e_(je)})]}),w.jsx(Hn,{checked:((m==null?void 0:m.mode)??"auto")==="auto",className:"sidebar-switch",disabled:U||!l,label:"Auto orchestration",title:l?"Automatically dispatch role messages during the active task":"Create or select a task first",onChange:bt}),w.jsx(Hn,{checked:Et,className:"sidebar-switch",disabled:U,label:"Pause alert sound",title:"Play a sound when VCM shows the fixed flow pause dialog",onChange:Ve=>xt(Ve)}),w.jsx(Hn,{checked:Nt,className:"sidebar-switch",disabled:U,label:"CC auto retry",title:"Retry temporary Claude Code turn failures before showing the flow pause alert",onChange:Ve=>rt(Ve)}),w.jsxs("label",{className:"settings-select-row",children:[w.jsx("span",{children:"Permission requests"}),w.jsxs("select",{value:Wt,disabled:U,onChange:Ve=>rn(Ve.target.value),children:[w.jsx("option",{value:"off",children:"off"}),w.jsx("option",{value:"allowAll",children:"allow all"})]})]}),w.jsx(c2,{busy:U,status:O,onCheck:Ce,onSettingsChange:ae}),w.jsxs("button",{className:"settings-toggle",disabled:U||!mi,title:"Save the current core role launch settings and optional Reviewer settings",type:"button",onClick:Pi,children:[w.jsx("span",{children:"Save launch template"}),w.jsx("span",{children:mi?"ready":"open task"})]}),gi?w.jsxs("button",{className:"settings-toggle is-active",disabled:U,title:o2(Cr),type:"button",onClick:zn,children:[w.jsx("span",{children:"One-click start"}),w.jsx("span",{children:jv(Cr)})]}):null,l?w.jsxs(w.Fragment,{children:[w.jsxs("button",{type:"button",onClick:()=>In(!0),children:[w.jsx("span",{children:"Messages"}),w.jsxs("span",{className:"muted",children:[li.total," total"]})]}),w.jsxs("button",{type:"button",onClick:()=>_i(!0),children:[w.jsx("span",{children:"Events"}),w.jsxs("span",{className:"muted",children:[f.length," total"]})]})]}):null]})}),w.jsx(Kr,{title:"Translation",open:wn==="translation",onOpenChange:Ve=>Ht("translation",Ve),children:w.jsx(u2,{busy:U,enabled:u,autoSendEnabled:g,targetLanguage:h,outputMode:S,memoryInitialized:C,baseUnavailableReason:Kt,translatorSession:T,onAutoSendChange:mt,onCreateBootstrap:wt,onEnabledChange:St,onUpdateMemory:fe,onTargetLanguageChange:de,onOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it})}),t&&l?w.jsx(Kr,{title:"Gate Review Gates",open:wn==="gate-review-gates",onOpenChange:Ve=>Ht("gate-review-gates",Ve),children:w.jsx(d2,{busy:U,state:c,onCancelGateReview:ze,onGateEnabledChange:ce})}):null,w.jsx(Kr,{title:"Gateway",open:wn==="gateway",onOpenChange:Ve=>{Ht("gateway",Ve),Ve&&Q()},children:w.jsx(m2,{busy:U,qrCheck:D,qrLogin:R,larkRegistration:A,larkRegistrationCheck:M,status:L,onEnabledChange:$,onSettingsChange:he,onResetBinding:Ee,onStartLarkRegistration:He,onStartQrLogin:Fe,onTranslationChange:be,onConnectionChange:Le})}),t?w.jsx(Kr,{title:"VCM Harness",open:wn==="vcm-harness",onOpenChange:Ve=>Ht("vcm-harness",Ve),children:w.jsx(Kk,{status:E,bootstrapStatus:y,applyResult:v,hasActiveTask:!!ot,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,launchOptions:_,modelOptions:H,busy:U,onRefresh:V,onApply:Y,onOpenStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onLaunchOptionsChange:_e,onStartBootstrap:te,onRestartBootstrap:z,onStopBootstrap:j,onRunBootstrap:N})}):null,t?w.jsx(Kr,{title:"Task",open:wn==="task",onOpenChange:Ve=>Ht("task",Ve),children:gt.length>0?w.jsxs("div",{className:"task-panel",children:[w.jsx(n2,{tasks:gt,activeTaskSlug:l,onSelect:Be}),ot?w.jsxs("div",{className:"task-panel-actions",children:[w.jsx("button",{type:"button",onClick:()=>yi(!0),children:"Usage Analytics"}),w.jsx("button",{className:"danger-button",disabled:U,type:"button",onClick:Te,children:"Close Task"})]}):null]}):w.jsx("div",{className:"task-create",children:w.jsxs("form",{onSubmit:$i,children:[w.jsx("input",{value:si,onChange:Ve=>sn(Ve.target.value),placeholder:"task name"}),w.jsxs("div",{className:"task-create-preview",children:[w.jsxs("small",{children:["branch: ",hn?`feature/${hn}`:"feature/<task>"]}),w.jsxs("small",{children:["worktree: ",hn?`.claude/worktrees/${hn}`:".claude/worktrees/<task>"]})]}),w.jsx("button",{type:"submit",disabled:U||!hn,children:"Create"})]})})}):null,t&&ot?w.jsx(y2,{task:ot,roundState:o}):null,ai?w.jsx(w2,{busy:U,messages:d,orchestration:m,onClose:()=>In(!1),onMarkAllDone:()=>{l&&Fi(l)},onDeleteMessageHistory:()=>{l&&Jn(l)}}):null,qi?w.jsx(C2,{events:f,onClose:()=>_i(!1)}):null,ot?w.jsx(i2,{open:vi,taskSlug:ot.taskSlug,taskTitle:ot.title,onClose:()=>yi(!1)}):null]})}function jv(t){return[t.autoOrchestration?"auto":"manual"].join(" + ")}function o2(t){const r=Object.entries(t.roles).map(([s,l])=>`${s}: ${l.permissionMode} / ${l.model} / ${l.effort}`).join("; ");return`Launch template: ${jv(t)}; ${r}`}function c2({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 w.jsxs("div",{className:"codex-bridge-settings",children:[w.jsx(Hn,{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})}),w.jsxs("form",{className:"codex-bridge-api-key-form",onSubmit:c=>void o(c),children:[w.jsx("label",{htmlFor:"codex-bridge-api-key",children:"Codex Bridge API key"}),w.jsxs("div",{children:[w.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)}),w.jsx("button",{type:"submit",disabled:t||!d.trim(),children:"Save"})]})]}),w.jsxs("div",{className:"settings-status-row",children:[w.jsx("span",{children:"Codex Bridge status"}),w.jsx("strong",{children:(r==null?void 0:r.connectionState)??"loading"})]}),w.jsxs("div",{className:"codex-bridge-actions",children:[w.jsx("button",{type:"button",disabled:t||!(r!=null&&r.enabled),onClick:()=>void s(),children:"Check"}),w.jsx("button",{type:"button",disabled:t||!f,onClick:()=>void l({clearApiKey:!0}),children:"Clear key"})]}),r!=null&&r.error?w.jsx("p",{className:"settings-help-text",children:r.error}):null]})}function u2({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:C,onOpenFileTranslation:T,onOpenTranslatorSession:E}){const y=!!(s||r),v=(o==null?void 0:o.status)==="running",_=!!(l&&!r&&v),b=r??(v?null:"Start Translator session first."),k=!!(s||b),R=r??"Open Translator session",D=b??"Translation tools are ready";return w.jsxs("div",{className:"sidebar-settings",children:[w.jsx(Hn,{checked:_,className:"sidebar-switch",disabled:y||!v,label:"Conversation translation",title:D,onChange:g}),w.jsx(Hn,{checked:t,className:"sidebar-switch",disabled:y,label:"Auto-send",onChange:c}),w.jsxs("label",{className:"settings-select-row",children:[w.jsx("span",{children:"Language"}),w.jsx("select",{value:f,disabled:y,onChange:A=>C(A.target.value),children:g_.map(A=>w.jsx("option",{value:A.value,children:A.label},A.value))})]}),w.jsxs("label",{className:"settings-select-row",children:[w.jsx("span",{children:"Reply scope"}),w.jsx("select",{value:m,disabled:y,onChange:A=>S(A.target.value),children:cS.map(A=>w.jsx("option",{value:A.value,children:A.label},A.value))})]}),w.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:T,children:[w.jsx("span",{children:"File translation"}),w.jsx("span",{children:"open"})]}),d?null:w.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:u,children:[w.jsx("span",{children:"Bootstrap"}),w.jsx("span",{children:"run"})]}),w.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:h,children:[w.jsx("span",{children:"Update memory"}),w.jsx("span",{children:"run"})]}),b?w.jsx("p",{className:"settings-help-text",children:b}):null,w.jsxs("div",{className:"settings-status-row",children:[w.jsx("span",{children:"Session status"}),w.jsx("strong",{children:h2(o)})]}),w.jsxs("button",{className:"settings-toggle",disabled:y,title:R,type:"button",onClick:E,children:[w.jsx("span",{children:"Open Session"}),w.jsx("span",{children:"open"})]})]})}function h2(t){return t?t.status==="running"?t.activityStatus??"idle":t.status:"not started"}function f2(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 d2({busy:t,onCancelGateReview:r,onGateEnabledChange:s,state:l}){return w.jsx("div",{className:"sidebar-settings",children:Vk.map(d=>{const m=l==null?void 0:l.gates[d],f=!!(m!=null&&m.required);return w.jsxs("div",{className:"gate-review-setting",children:[w.jsx(Hn,{checked:f,className:"sidebar-switch",disabled:t||!l||(m==null?void 0:m.status)==="running",label:p2(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?w.jsx("button",{className:"danger-button",disabled:t,type:"button",onClick:()=>r(d,m.requestId),children:"Cancel review"}):null]},d)})})}function p2(t){switch(t){case"architecture-plan":return"Architecture plan";case"validation-adequacy":return"Validation adequacy";case"code-diff":return"Code diff"}return t}function m2({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 C=(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 w.jsxs("div",{className:"gateway-panel",children:[w.jsxs("label",{className:"compact-field",children:[w.jsx("span",{children:"Channel"}),w.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:[w.jsx("option",{value:"weixin-ilink",children:"Weixin iLink"}),w.jsx("option",{value:"lark",children:"Lark"})]})]}),w.jsxs("div",{className:"gateway-actions",children:[w.jsx(Hn,{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)}),w.jsx(Hn,{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)}),w.jsx(Hn,{checked:!!(S!=null&&S.translationEnabled),className:"sidebar-switch",disabled:t||!S,label:"Translation",onChange:y=>c(y)}),C?w.jsx("button",{type:"button",disabled:t,onClick:f,children:"Start QR Setup"}):E?w.jsx("button",{className:"danger-button",type:"button",disabled:t,onClick:d,children:"Reset Binding"}):w.jsx("button",{type:"button",disabled:t,onClick:o,children:"Start QR Login"})]}),C?w.jsxs("div",{className:"gateway-lark-settings",children:[w.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?w.jsxs("p",{className:"muted",children:["QR setup: ",(s==null?void 0:s.status)??r.status,s!=null&&s.message?` · ${s.message}`:""]}):null]}):h?w.jsx("p",{className:"muted",children:"QR login started. Use the login dialog to confirm binding."}):null,!C&&g?w.jsxs("p",{className:"muted",children:["QR status: ",g.status,g.message?` · ${g.message}`:""]}):null]})}function g2({busy:t,onPull:r,project:s}){const l=s.pullDisabledReason,d=!!s.canPull;return w.jsxs("div",{className:"project-summary",children:[w.jsxs("dl",{children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Base path"}),w.jsx("dd",{children:s.repoRoot})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Branch"}),w.jsx("dd",{children:_2(s)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Remote"}),w.jsx("dd",{children:s.upstreamBranch??"no upstream"})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Status"}),w.jsx("dd",{children:v2(s)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Commit"}),w.jsx("dd",{children:s.shortHeadCommit??s.headCommit??"unknown"})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Working tree"}),w.jsx("dd",{children:s.isDirty?"uncommitted changes":"clean"})]})]}),w.jsxs("div",{className:"connected-repo-actions",children:[w.jsx("button",{type:"button",disabled:t||!d,title:l??"Pull latest changes with git pull --ff-only",onClick:()=>void r(),children:"Pull"}),w.jsx("span",{className:"muted",children:s.checkedAt?`checked ${Hh(s.checkedAt)}`:"status not refreshed"})]}),l?w.jsx("p",{className:"muted",children:l}):null,s.warnings.length>0?w.jsx("ul",{className:"warnings",children:s.warnings.map(m=>w.jsx("li",{children:m},m))}):null]})}function _2(t){return t.branch||"unknown"}function v2(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 y2({roundState:t,task:r}){var g;const[s,l]=ee.useState(()=>Date.now()),d=!!(t!=null&&t.startedAt),m=Nv(r.createdAt,s),f=Zg(t,(t==null?void 0:t.totalCcActiveMs)??0,s),o=d&&t?Zg(t,t.currentRoundCcActiveMs,s):0,c=d&&t?S2(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)},[]),w.jsxs("section",{className:"task-status-dock","aria-label":"VCM Session status",children:[w.jsxs("div",{className:"task-status-dock-title",children:[w.jsx("strong",{title:u,children:u}),w.jsx("span",{className:`status-badge status-${r.status}`,children:r.status})]}),w.jsxs("dl",{className:"task-status-stats",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Session start"}),w.jsx("dd",{children:Hh(r.createdAt)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Session total"}),w.jsx("dd",{children:Ro(m)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Rounds"}),w.jsx("dd",{children:(t==null?void 0:t.totalRoundCount)??0})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Role runtime"}),w.jsx("dd",{children:Ro(f)})]})]}),d&&t?w.jsxs("div",{className:"current-round-status",children:[w.jsxs("div",{className:"current-round-title",children:[w.jsx("span",{children:t.status==="running"?"Current Round":"Last Round"}),w.jsx("span",{className:`status-badge status-${t.status}`,children:t.status})]}),w.jsxs("dl",{className:"task-status-stats",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Started"}),w.jsx("dd",{children:Hh(t.startedAt)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Total"}),w.jsx("dd",{children:Ro(c)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Role runtime"}),w.jsx("dd",{children:Ro(o)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Turn count"}),w.jsx("dd",{children:t.turnCount})]})]})]}):null]})}function Zg(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 S2(t,r){const s=t.status==="running"?r:Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return Nv(t.startedAt??"",Number.isFinite(s)?s:r)}function Nv(t,r){const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,r-s):0}function Hh(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 Ro(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 b2(t){return t==="system"?"light":t==="light"?"dark":"system"}function e_(t){return t==="system"?"System":t==="light"?"Light":"Dark"}function C2({events:t,onClose:r}){return w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{className:"event-modal",role:"dialog","aria-modal":"true","aria-label":"Events",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Events"}),w.jsxs("p",{className:"muted",children:[t.length," total"]})]}),w.jsx("button",{type:"button",onClick:r,children:"Close"})]}),w.jsx(Wk,{events:t,maxEvents:null,showHeader:!1})]})})}function w2({busy:t,messages:r,orchestration:s,onClose:l,onMarkAllDone:d,onDeleteMessageHistory:m}){const f=af(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 yk({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,C]=ee.useState(""),[T,E]=ee.useState(!1),[y,v]=ee.useState(Date.now()),[_,b]=ee.useState(!1),[,k]=Ii(""),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=Ak(R);ee.useEffect(()=>{if(!M)return;v(Date.now());const N=window.setInterval(()=>v(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(Lv(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),C("")}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?Xg(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(),!_&&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=Tk(R,A,y),z=D.length,j=bk(D);return w.jsxs("aside",{className:"translation-panel",children:[w.jsxs("header",{className:"translation-panel-header",children:[w.jsxs("div",{className:"translation-panel-titlebar",children:[w.jsx("h2",{children:"Translation"}),w.jsxs("div",{className:"translation-panel-actions",children:[z>0?w.jsxs(w.Fragment,{children:[w.jsxs("button",{type:"button",disabled:_,onClick:()=>void V(),children:["Ignore ",z]}),j?w.jsx("button",{type:"button",disabled:_,onClick:()=>void Y(j),children:"Retry latest"}):null]}):null,w.jsx("button",{type:"button",disabled:_,onClick:()=>void U(),children:"Translate final reply"}),w.jsx("button",{type:"button",onClick:()=>void K(),children:"Clear"})]})]}),w.jsx("div",{className:"translation-status-row",children:w.jsxs("p",{children:["Claude Code · target ",Sk(s)," · ",te]})})]}),w.jsx("div",{className:"translation-manual-panel",children:w.jsxs("div",{className:"translation-composer-row translation-manual-row",children:[w.jsx("textarea",{value:S,onChange:N=>C(N.target.value),placeholder:"Paste English to translate on demand..."}),w.jsx("div",{className:"translation-composer-actions",children:w.jsx("button",{type:"button",disabled:_||!S.trim(),onClick:()=>void H(),children:"Translate"})})]})}),w.jsxs("div",{className:"translation-entry-list",ref:L,children:[R.length===0?w.jsx("p",{className:"muted",children:"Translated Claude Code output will appear here."}):null,R.map(N=>w.jsx(Ek,{entry:N},N.id))]}),w.jsx("div",{className:"translation-composer",children:w.jsxs("div",{className:"translation-composer-row",children:[w.jsx("textarea",{value:g,onChange:N=>{h(N.target.value),(!N.target.value.trim()||T&&!Mk(N.target.value))&&E(!1)},onKeyDown:W,placeholder:"输入中文,先翻译成英文工程指令..."}),w.jsx("div",{className:"translation-composer-actions",children:w.jsx("button",{type:"button",disabled:_||!T||!Xg(g).trim(),onClick:()=>void P(),children:"Send English"})})]})})]})}function Sk(t){var r;return((r=g_.find(s=>s.value===t))==null?void 0:r.label)??t}function bk(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 Ck({open:t,taskSlug:r,targetLanguage:s,onClose:l}){const[d,m]=ee.useState(!1),[,f]=Ii(""),[o,c]=ee.useState(null),[u,g]=ee.useState(""),[h,S]=ee.useState(""),[C,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);ol(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});_(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?w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"modal-backdrop file-translation-backdrop",children:w.jsx(xk,{busy:d,state:o,selectedJobId:u,output:h,report:C,onClose:()=>{y(!1),l()},onRefresh:()=>void H(),onSelectJob:V=>void U(V),onTranslate:()=>void P()})}),E?w.jsx(wk,{busy:d||M,state:v,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 wk({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(C=>C.type==="directory"),S=g.filter(C=>C.type==="file");return w.jsx("div",{className:"modal-backdrop translation-file-browser-backdrop",children:w.jsxs("section",{className:"translation-file-browser-modal",role:"dialog","aria-modal":"true","aria-label":"Select Source File",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Select Source File"}),w.jsx("p",{children:s||"."})]}),w.jsx("button",{type:"button",onClick:f,children:"Close"})]}),w.jsxs("div",{className:"translation-file-browser-controls",children:[w.jsxs("div",{className:"translation-file-browser-nav",children:[w.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m((r==null?void 0:r.parentPath)??"",""),children:"Up"}),w.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m("",""),children:"Root"})]}),w.jsxs("form",{className:"translation-file-browser-search",onSubmit:C=>{C.preventDefault(),m(s,l)},children:[w.jsx("input",{value:l,onChange:C=>o(C.target.value),placeholder:"Search files"}),w.jsx("button",{type:"submit",disabled:t,children:"Search"}),w.jsx("button",{type:"button",disabled:t||!l,onClick:()=>m(s,""),children:"Clear"})]})]}),w.jsxs("div",{className:"translation-file-browser-layout",children:[w.jsxs("div",{className:"translation-file-browser-list",children:[t&&!r?w.jsx("p",{className:"muted",children:"Loading files..."}):null,!t&&g.length===0?w.jsx("p",{className:"muted",children:"No source files found."}):null,h.length>0?w.jsxs("div",{className:"translation-file-browser-group",children:[w.jsx("h3",{children:"Folders"}),h.map(C=>w.jsx(Yg,{entry:C,selected:d===C.path,onBrowse:m,onSelectPath:c},C.path))]}):null,S.length>0?w.jsxs("div",{className:"translation-file-browser-group",children:[w.jsx("h3",{children:"Files"}),S.map(C=>w.jsx(Yg,{entry:C,selected:d===C.path,onBrowse:m,onSelectPath:c},C.path))]}):null,r!=null&&r.truncated?w.jsx("p",{className:"translation-entry-note",children:"Result limit reached."}):null]}),w.jsxs("aside",{className:"translation-file-browser-selection",children:[w.jsxs("label",{children:[w.jsx("span",{children:"Source path"}),w.jsx("input",{value:d,onChange:C=>c(C.target.value)})]}),w.jsx("button",{type:"button",disabled:t||!d.trim(),onClick:u,children:"Translate File"})]})]})]})})}function Yg({entry:t,selected:r,onBrowse:s,onSelectPath:l}){const d=t.type==="directory";return w.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:[w.jsx("span",{children:d?"DIR":"FILE"}),w.jsx("strong",{children:t.name}),w.jsx("small",{children:t.path})]})}function xk({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 w.jsxs("section",{className:"file-translation-modal",role:"dialog","aria-modal":"true","aria-label":"File Translation",children:[w.jsxs("header",{className:"file-translation-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"File Translation"}),w.jsx("p",{children:"Claude Code · 中英互译"})]}),w.jsxs("div",{className:"file-translation-toolbar",children:[w.jsx("button",{type:"button",disabled:t,onClick:c,children:"Translate"}),w.jsx("button",{type:"button",disabled:t,onClick:f,children:"Refresh"}),w.jsx("button",{type:"button",onClick:m,children:"Close"})]})]}),r!=null&&r.memoryInitialized?null:w.jsx("p",{className:"translation-entry-note",children:"Translation memory is not initialized. Run Bootstrap from the sidebar before important file translations."}),w.jsxs("div",{className:"file-translation-layout",children:[w.jsxs("div",{className:"file-translation-list",children:[u.length===0?w.jsx("p",{className:"muted",children:"No translated files yet."}):null,u.map(h=>w.jsxs("button",{className:h.id===s?"file-translation-item is-active":"file-translation-item",type:"button",onClick:()=>o(h.id),children:[w.jsx("strong",{children:h.sourcePath}),w.jsxs("span",{children:[h.status," · ",h.targetLanguage]})]},h.id))]}),w.jsx("div",{className:"file-translation-preview",children:g?w.jsxs(w.Fragment,{children:[w.jsxs("header",{children:[w.jsx("strong",{children:g.sourcePath}),w.jsx("span",{children:g.status})]}),w.jsx("div",{className:"translation-markdown",children:w.jsx(rv,{remarkPlugins:[Tv],children:l||d||"Translation output is not available yet."})})]}):w.jsx("p",{className:"muted",children:"Select a translated file to preview it."})})]})]})}function Ek({entry:t}){if(t.sourceKind==="conversation-boundary")return w.jsx(kk,{entry:t});const r=Dk(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 w.jsxs("article",{className:d,children:[s?w.jsx("pre",{children:r}):w.jsx("div",{className:"translation-markdown",children:w.jsx(rv,{remarkPlugins:[Tv],children:r})}),t.warning?w.jsx("p",{className:"translation-entry-note",children:t.warning}):null,t.error?w.jsx("p",{className:"translation-entry-note is-error",children:t.error}):null]})}function kk({entry:t}){const r=t.boundaryKind==="end"?"结束":"开始",s=t.conversationTurn??0,l=Ok(t.occurredAt??t.createdAt);return w.jsxs("div",{className:"translation-conversation-boundary","aria-label":`${r} 第 ${s} 轮 ${l}`,children:[w.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"}),w.jsx("span",{children:r}),w.jsxs("span",{children:["第 ",s," 轮"]}),w.jsx("time",{children:l}),w.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"})]})}function Ak(t){const r=t.find(Mv);return(r==null?void 0:r.translationStartedAt)??(r==null?void 0:r.createdAt)}function Tk(t,r,s){const l=t.find(Mv);if(l)return`translating ${Lk(Math.max(0,s-Rk(l)))}`;const d=t.at(-1);return(d==null?void 0:d.status)==="failed"||r==="failed"?"error":r}function Mv(t){return t.status==="queued"||t.status==="translating"}function Rk(t){const r=Date.parse(t.translationStartedAt??t.createdAt);return Number.isFinite(r)?r:Date.now()}function Dk(t){return t.status==="queued"||t.status==="translating"?t.sourceText:t.status==="translated"?t.direction==="user-input-to-english"?Lv(t.sourceText,t.translatedText):t.translatedText:t.translatedText||t.sourceText}function Lv(t,r){return`${t.trimEnd()}${Ho}${r.trimStart()}`}function Mk(t){return t.includes(Ho)}function Xg(t){const r=t.indexOf(Ho);return r===-1?t:t.slice(r+Ho.length)}function Lk(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 Ok(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleTimeString()}const Bk=8;function jk(){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,Bk)})},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(bh,s),window.addEventListener(Ch,l),window.addEventListener(wh,d),()=>{window.removeEventListener(bh,s),window.removeEventListener(Ch,l),window.removeEventListener(wh,d)}},[]),t.length===0?null:w.jsxs("aside",{className:"ui-error-center",role:"alert","aria-live":"polite","aria-label":"Application errors",children:[w.jsxs("header",{className:"ui-error-center-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Errors"}),w.jsxs("p",{children:[t.length," active"]})]}),w.jsx("button",{type:"button",onClick:()=>r([]),children:"Clear"})]}),w.jsx("ol",{className:"ui-error-list",children:t.map(s=>w.jsxs("li",{children:[w.jsxs("div",{children:[w.jsx("p",{children:s.message}),w.jsxs("span",{children:[Nk(s.updatedAt),s.count>1?` · repeated ${s.count} times`:""]})]}),w.jsx("button",{type:"button","aria-label":"Dismiss error",onClick:()=>r(l=>l.filter(d=>d.id!==s.id)),children:"Close"})]},s.id))})]})}function Nk(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Hk(t,r){return t.find(s=>s.taskSlug===r)??t[0]??null}function zk(t){if(!(t.mode!=="auto"||t.status!=="running")&&!(!t.activeRole||t.activeRole===t.lastFollowedRole))return t.activeRole}function Ik(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 Uk(t){const r=t.roundId??t.startedAt??t.taskSlug,s=t.stoppedAt??t.lastTurnEndedAt??"stopped";return`${r}:${s}`}function Pk(t,r,s){var d;if((d=t.flowPause)!=null&&d.paused&&t.flowPause.message||(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 Fk(t){return t?"strong":"none"}function qk(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 $k=3,Gk=3e4,Mo=new Map;function Ov(t,r){const s=ft(t,r);if(!Vk(r))return Mo.set(t,{consecutiveFailures:1,lastMessage:s,lastReportedAt:Date.now()}),s;const l=Mo.get(t),d=((l==null?void 0:l.consecutiveFailures)??0)+1,m=Date.now(),f=d>=$k&&(!l||l.lastMessage!==s||m-l.lastReportedAt>=Gk);return Mo.set(t,{consecutiveFailures:d,lastMessage:s,lastReportedAt:f?m:(l==null?void 0:l.lastReportedAt)??0}),f?s:null}function zo(t){Mo.delete(t),yS([t])}function Vk(t){const r=cl(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 Wk=["architecture-plan","validation-adequacy","code-diff"];function Kk({events:t,maxEvents:r=8,showHeader:s=!0}){const l=r===null?t:t.slice(-r);return w.jsxs("section",{className:"event-log",children:[s?w.jsx("h2",{children:"Events"}):null,t.length===0?w.jsx("p",{className:"muted",children:"No terminal events yet."}):w.jsx("ol",{children:l.map((d,m)=>w.jsx("li",{children:d},`${d}-${m}`))})]})}function Hn({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 w.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":`${l}: ${c}`,className:o,disabled:s,title:m,onClick:()=>f(!t),children:[w.jsx("span",{className:"switch-control-label",children:l}),w.jsx("span",{className:"switch-control-track","aria-hidden":"true",children:w.jsx("span",{className:"switch-control-thumb"})})]})}function Yk({status:t,bootstrapStatus:r,applyResult:s,hasActiveTask:l=!1,autoTaskHarnessReviewEnabled:d,autoMemoryEnabled:m,launchOptions:f,modelOptions:o,busy:c=!1,onRefresh:u,onApply:g,onOpenStudio:h,onOpenRepositoryDiff:S,onAutoTaskHarnessReviewChange:C,onAutoMemoryChange:T,onLaunchOptionsChange:E,onStartBootstrap:y,onRestartBootstrap:v,onStopBootstrap:_,onRunBootstrap:b}){const[k,L]=ee.useState(!1),R=r==null?void 0:r.session,D=(r==null?void 0:r.status)==="running",A=(R==null?void 0:R.status)==="running",M=(r==null?void 0:r.status)!=="complete";return l?t?w.jsxs("section",{className:"harness-panel",children:[w.jsxs("div",{className:"harness-stage",children:[w.jsxs("div",{className:"harness-panel-header",children:[w.jsxs("div",{children:[w.jsx("strong",{children:"Fixed install"}),w.jsx("p",{className:"muted",children:t.initialized?t.needsApply?`${t.plannedChanges.length} pending updates`:"Up to date":"Not initialized"})]}),w.jsx("div",{className:"harness-actions",children:t.initialized?w.jsxs(w.Fragment,{children:[w.jsx("button",{type:"button",disabled:c,onClick:()=>void u(),children:"Refresh"}),t.needsApply?w.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Update"}):null]}):w.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Initialize"})})]}),t.initialized&&t.needsApply?w.jsxs(w.Fragment,{children:[w.jsx("h3",{className:"harness-file-list-title",children:"Files to update"}),w.jsx("ol",{className:"harness-file-list",children:t.plannedChanges.map(O=>w.jsxs("li",{children:[w.jsx("span",{children:O.path}),w.jsx(jn,{status:O.action})]},`${O.path}:${O.action}`))})]}):null]}),w.jsxs("div",{className:"harness-stage",children:[w.jsxs("div",{className:"harness-panel-header",children:[w.jsx("div",{children:w.jsx("strong",{children:"Harness Studio"})}),w.jsx("div",{className:"harness-actions",children:w.jsx("button",{type:"button",disabled:c,onClick:h,children:"Open Studio"})})]}),w.jsx("button",{className:"harness-review-diff-button",type:"button",disabled:c,onClick:S,children:"Review Diff"}),w.jsx(Hn,{checked:d,className:"sidebar-switch",disabled:c,label:"Auto task harness review",title:"Automatically ask Harness Engineer to review task harness after final acceptance completes",onChange:C}),w.jsx(Hn,{checked:m,className:"sidebar-switch",disabled:c,label:"Auto memory",title:"Collect role memory drafts after Final Acceptance and let Harness Engineer apply reviewed memory",onChange:T})]}),M?w.jsx("div",{className:"harness-stage",children:w.jsxs("div",{className:"harness-panel-header",children:[w.jsxs("div",{children:[w.jsx("strong",{children:"Bootstrap"}),w.jsx("p",{className:"muted",children:r?Xk(r.status):"not loaded"})]}),w.jsx("div",{className:"harness-actions",children:w.jsx("button",{type:"button",disabled:c||!(r!=null&&r.canStart),onClick:()=>{L(!0)},children:"Open Bootstrap"})})]})}):null,s!=null&&s.changedFiles.length?w.jsx("div",{className:"harness-result",children:w.jsx("p",{className:"muted",children:s.message})}):null,t.warnings.length>0?w.jsx("ul",{className:"warnings",children:t.warnings.map(O=>w.jsx("li",{children:O},O))}):null,r!=null&&r.warnings.length?w.jsx("ul",{className:"warnings",children:r.warnings.map(O=>w.jsx("li",{children:O},O))}):null,M&&k?w.jsx("div",{className:"harness-bootstrap-modal",role:"dialog","aria-modal":"true","aria-label":"Harness Engineer bootstrap session",children:w.jsxs("div",{className:"harness-bootstrap-modal-surface",children:[w.jsxs("header",{className:"harness-bootstrap-modal-header",children:[w.jsxs("div",{children:[w.jsx("strong",{children:"Harness Engineer Bootstrap"}),w.jsx("p",{className:"muted",children:(R==null?void 0:R.command)??"Start Harness Engineer, then run bootstrap when ready."})]}),w.jsxs("div",{className:"harness-bootstrap-modal-actions",children:[R?w.jsx(jn,{status:R.status}):null,w.jsx("button",{type:"button",onClick:()=>L(!1),children:"Close"})]})]}),w.jsxs("div",{className:"harness-bootstrap-controls",children:[w.jsxs("label",{children:[w.jsx("span",{children:"Permission"}),w.jsx("select",{value:f.permissionMode,disabled:c||D||A,onChange:O=>E({...f,permissionMode:O.target.value}),children:__.map(O=>w.jsx("option",{value:O.value,children:O.label},O.value))})]}),w.jsxs("label",{children:[w.jsx("span",{children:"Model"}),w.jsx("select",{value:f.model,title:(()=>{const O=o.find(H=>H.value===f.model);return O!=null&&O.available?O.description:O==null?void 0:O.unavailableReason})(),disabled:c||D||A,onChange:O=>E({...f,model:O.target.value}),children:o.map(O=>w.jsx("option",{value:O.value,disabled:!O.available,title:O.available?O.description:O.unavailableReason,children:O.label},O.value))})]}),w.jsxs("label",{children:[w.jsx("span",{children:"Effort"}),w.jsx("select",{value:f.effort,disabled:c||D||A,onChange:O=>E({...f,effort:O.target.value}),children:y_.map(O=>w.jsx("option",{value:O.value,children:O.label},O.value))})]}),w.jsxs("div",{className:"harness-bootstrap-control-actions",children:[w.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void y(f),children:"Start"}),w.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void v(f),children:"Restart"}),w.jsx("button",{type:"button",disabled:c||!R,onClick:()=>void _(),children:"Stop"}),w.jsx("button",{type:"button",disabled:c||D||!A,onClick:()=>void b(),children:"Run bootstrap"})]})]}),w.jsx("div",{className:"harness-bootstrap-terminal",children:A?w.jsx(Po,{sessionId:R.id,active:k}):w.jsxs("div",{className:"terminal-empty",children:[w.jsx("strong",{children:"Harness Bootstrap"}),w.jsx("span",{children:"Start Harness Engineer first. When it is ready, click Run bootstrap to send the prompt."})]})})]})}):null]}):null:w.jsx("section",{className:"harness-panel",children:w.jsxs("div",{className:"harness-result",children:[w.jsx("strong",{children:"Task required"}),w.jsx("p",{className:"muted",children:"Create or select a task before changing VCM Harness. Harness changes are committed in the active task worktree."})]})})}function Xk(t){return t.replaceAll("_"," ")}function af(t){return{total:t.length,accepted:t.filter(r=>r.acceptedAt).length,delivered:t.filter(r=>r.deliveredAt).length}}function Qk(t,r=6){const s=[...t].sort(e2).map((d,m)=>({message:d,sequence:m+1}));return[...r===null?s:s.slice(-r)].sort((d,m)=>m.sequence-d.sequence)}function Jk({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=af(t),h=(r==null?void 0:r.mode)??"auto",S=Qk(t,l);async function C(T){await t2(T.body),u(T.id),window.setTimeout(()=>u(E=>E===T.id?null:E),1200)}return w.jsxs("section",{className:"message-panel",children:[m?w.jsxs("div",{className:"message-panel-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Messages"}),w.jsxs("p",{className:"muted",children:[g.total," total / ",g.accepted," accepted"]})]}),d&&f?w.jsx("div",{className:"message-controls",children:w.jsx(Hn,{checked:h==="auto",className:"message-mode-toggle",disabled:s,label:"Auto orchestration",onChange:T=>f(T?"auto":"manual")})}):null,d&&o?w.jsx("button",{type:"button",disabled:s,onClick:o,children:"Mark All Done"}):null]}):null,t.length===0?w.jsx("p",{className:"muted",children:"No role messages yet."}):w.jsx("ol",{className:"message-list",children:S.map(({message:T,sequence:E})=>w.jsxs("li",{className:"message-item",children:[w.jsxs("div",{className:"message-item-main",children:[w.jsxs("div",{className:"message-meta",children:[w.jsxs("span",{className:"message-sequence",children:["#",E]}),w.jsx("time",{dateTime:Io(T),children:Zk(Io(T))}),w.jsxs("strong",{children:[T.fromRole," ","->"," ",T.toRole]}),w.jsx("span",{children:T.type})]}),w.jsx("p",{children:T.body}),T.failureReason?w.jsx("span",{className:"message-reason",children:T.failureReason}):null,T.bodyPath?w.jsx("span",{className:"message-path",children:T.bodyPath}):null]}),w.jsx("div",{className:"message-actions",children:w.jsx("button",{type:"button",disabled:s,onClick:()=>void C(T),children:c===T.id?"Copied":"Copy"})})]},T.id))})]})}function Zk(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 Io(t){return t.acceptedAt??t.deliveredAt??t.dispatchingAt??t.createdAt}function e2(t,r){const s=Io(t).localeCompare(Io(r));if(s!==0)return s;const l=t.createdAt.localeCompare(r.createdAt);return l!==0?l:t.id.localeCompare(r.id)}async function t2(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 n2({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 w.jsx("form",{className:"repo-connect",onSubmit:f,children:w.jsxs("div",{className:r.length>0?"inline-form has-recent-paths":"inline-form",children:[w.jsx("input",{"aria-label":"Repository path",id:"repo-path",value:d,onChange:o=>m(o.target.value),placeholder:"/path/to/repo"}),r.length>0?w.jsxs("select",{"aria-label":"Recent repositories",className:"repo-recent-select",value:"",onChange:o=>{o.target.value&&m(o.target.value)},children:[w.jsx("option",{value:"",children:"Recent"}),r.map(o=>w.jsx("option",{value:o,children:o},o))]}):null,w.jsx("button",{type:"submit",disabled:s||!d.trim(),children:"Connect"})]})})}function i2({tasks:t,activeTaskSlug:r,onSelect:s}){return w.jsx("nav",{className:"task-nav","aria-label":"Tasks",children:t.map(l=>w.jsxs("button",{className:l.taskSlug===r?"task-nav-item is-active":"task-nav-item",type:"button",onClick:()=>s(l.taskSlug),children:[w.jsx("span",{children:l.title||l.taskSlug}),w.jsx(jn,{status:l.status})]},l.taskSlug))})}function r2({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: ${cl(h)}`)}finally{o(!1)}},[r]);return ee.useEffect(()=>{t&&g()},[g,t]),t?w.jsx("div",{className:"modal-backdrop usage-analytics-backdrop",children:w.jsxs("section",{className:"usage-analytics-modal",role:"dialog","aria-modal":"true","aria-label":"Usage Analytics",children:[w.jsxs("header",{className:"usage-analytics-header",children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Usage Analytics"}),w.jsxs("p",{children:[(s==null?void 0:s.trim())||r," · Claude models only"]})]}),w.jsxs("div",{className:"usage-analytics-header-actions",children:[w.jsx("button",{type:"button",disabled:f,onClick:()=>void g(),children:f?"Refreshing...":"Refresh"}),w.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),c?w.jsx("p",{className:"inline-error usage-analytics-error",children:c}):null,d?w.jsx(s2,{report:d}):w.jsx("div",{className:"usage-analytics-empty",children:f?"Loading usage data...":"No usage data available."})]})}):null}function s2({report:t}){return w.jsxs("div",{className:"usage-analytics-content",children:[w.jsxs("div",{className:"usage-analytics-meta",children:[w.jsx("span",{children:t.updatedAt?`Updated ${l2(t.updatedAt)}`:"No Claude usage recorded yet"}),w.jsxs("span",{children:[bn(t.totals.requestCount)," requests · ",bn(t.totals.sessionCount)," sessions"]})]}),w.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-task-summary",children:[w.jsx("h3",{id:"usage-task-summary",children:"Task Summary"}),w.jsx(a2,{totals:t.totals})]}),w.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-role",children:[w.jsx("h3",{id:"usage-by-role",children:"Usage by Role"}),w.jsx("div",{className:"usage-analytics-table-wrap",children:w.jsxs("table",{className:"usage-analytics-table",children:[w.jsx("thead",{children:w.jsx(Qg,{firstColumn:"Role"})}),w.jsx("tbody",{children:t.byRole.map(r=>w.jsxs("tr",{children:[w.jsxs("th",{scope:"row",children:[w.jsx("span",{children:aS(r.role).label}),w.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),w.jsx(Jg,{totals:r})]},r.role))})]})})]}),w.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-model",children:[w.jsx("h3",{id:"usage-by-model",children:"Usage by Model"}),t.byModel.length>0?w.jsx("div",{className:"usage-analytics-table-wrap",children:w.jsxs("table",{className:"usage-analytics-table",children:[w.jsx("thead",{children:w.jsx(Qg,{firstColumn:"Model"})}),w.jsx("tbody",{children:t.byModel.map(r=>w.jsxs("tr",{children:[w.jsxs("th",{scope:"row",children:[w.jsx("span",{children:r.model}),w.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),w.jsx(Jg,{totals:r})]},r.model))})]})}):w.jsx("p",{className:"usage-analytics-no-models",children:"No Claude model usage recorded yet."})]})]})}function a2({totals:t}){return w.jsxs("dl",{className:"usage-totals-grid",children:[w.jsx(Ja,{label:"Input Tokens",value:bn(t.inputTokens)}),w.jsx(Ja,{label:"Output Tokens",value:bn(t.outputTokens)}),w.jsx(Ja,{label:"Cache Read",value:bn(t.cacheReadTokens)}),w.jsx(Ja,{label:"Cache Creation",value:bn(t.cacheCreationTokens)}),w.jsx(Ja,{label:"Estimated Cost",value:Bv(t.costUsd)})]})}function Ja({label:t,value:r}){return w.jsxs("div",{children:[w.jsx("dt",{children:t}),w.jsx("dd",{children:r})]})}function Qg({firstColumn:t}){return w.jsxs("tr",{children:[w.jsx("th",{scope:"col",children:t}),w.jsx("th",{scope:"col",children:"Input"}),w.jsx("th",{scope:"col",children:"Output"}),w.jsx("th",{scope:"col",children:"Cache Read"}),w.jsx("th",{scope:"col",children:"Cache Creation"}),w.jsx("th",{scope:"col",children:"Estimated Cost"})]})}function Jg({totals:t}){return w.jsxs(w.Fragment,{children:[w.jsx("td",{children:bn(t.inputTokens)}),w.jsx("td",{children:bn(t.outputTokens)}),w.jsx("td",{children:bn(t.cacheReadTokens)}),w.jsx("td",{children:bn(t.cacheCreationTokens)}),w.jsx("td",{children:Bv(t.costUsd)})]})}function bn(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function Bv(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(t)}function l2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function o2({project:t,recentRepositoryPaths:r,tasks:s,activeTaskSlug:l,messages:d,orchestration:m,events:f,roundState:o,gateReview:c,translationEnabled:u,translationAutoSendEnabled:g,translationTargetLanguage:h,translationOutputMode:S,translationMemoryInitialized:C,translatorSession:T,harnessStatus:E,harnessBootstrapStatus:y,harnessApplyResult:v,harnessEngineerLaunchOptions:_,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,gatewayStatus:L,gatewayQrLogin:R,gatewayQrCheck:D,gatewayLarkRegistration:A,gatewayLarkRegistrationCheck:M,codexBridgeStatus:O,modelOptions:H,busy:U,onConnect:P,onRefreshConnectedRepository:W,onPullConnectedRepository:K,onRefreshHarness:V,onApplyHarness:Y,onStartHarnessBootstrap:te,onRestartHarnessBootstrap:z,onStopHarnessBootstrap:j,onRunHarnessBootstrap:N,onOpenHarnessStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onHarnessEngineerLaunchOptionsChange:_e,onRefreshGateway:Q,onGatewayEnabledChange:$,onGatewaySettingsChange:he,onCodexBridgeSettingsChange:ae,onCodexBridgeCheck:Ce,onGatewayTranslationChange:be,onGatewayConnectionChange:Le,onStartGatewayQrLogin:Fe,onStartGatewayLarkRegistration:He,onResetGatewayBinding:Ee,onGateReviewGateEnabledChange:ce,onCancelGateReviewGate:ze,onTranslationEnabledChange:St,onTranslationAutoSendChange:mt,onTranslationTargetLanguageChange:de,onTranslationOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it,onCreateTranslationBootstrap:wt,onUpdateTranslationMemory:fe,onCreateTask:we,onCloseTask:Te,onSelectTask:Be,themeMode:je,onAutoOrchestrationChange:bt,onThemeModeChange:qe,pauseAlertSound:Et,onPauseAlertSoundChange:xt,roleRetryEnabled:Nt,onRoleRetryEnabledChange:rt,permissionRequestMode:Wt,onPermissionRequestModeChange:rn,launchTemplate:Cr,canSaveLaunchTemplate:mi,canOneClickStart:gi,onSaveLaunchTemplate:Pi,onOneClickStart:zn,onMarkAllMessagesDone:Fi,onDeleteMessageHistory:Jn}){const[si,sn]=ee.useState(""),[ai,In]=ee.useState(!1),[qi,_i]=ee.useState(!1),[vi,yi]=ee.useState(!1),[wn,Pt]=ee.useState(()=>l?null:"repository"),li=af(d),hn=si.trim(),Kt=d2(t,l,E),gt=s.filter(Ve=>Ve.cleanupStatus!=="cleaned"),ot=gt.find(Ve=>Ve.taskSlug===l)??null;ee.useEffect(()=>{Pt(Ve=>!l&&Ve===null?t?"task":"repository":Ve)},[l,t]);function Ht(Ve,Un){Pt(Un?Ve:null)}async function $i(Ve){Ve.preventDefault(),await we({taskSlug:hn}),sn("")}return w.jsxs("div",{className:"project-dashboard",children:[w.jsx("header",{className:"brand-header",children:w.jsx("strong",{children:"VibeCodingMaster"})}),w.jsx(Kr,{title:"Repository",open:wn==="repository",onOpenChange:Ve=>{Ht("repository",Ve),Ve&&t&&W()},children:w.jsxs("div",{className:"repository-panel",children:[w.jsx(n2,{defaultPath:(t==null?void 0:t.repoRoot)??"",recentPaths:r,busy:U,onConnect:P}),t?w.jsx(_2,{busy:U,project:t,onPull:K}):null]})}),w.jsx(Kr,{title:"Settings",open:wn==="settings",onOpenChange:Ve=>Ht("settings",Ve),children:w.jsxs("div",{className:"sidebar-settings",children:[w.jsxs("button",{"aria-label":`Theme mode: ${e_(je)}`,className:"settings-toggle theme-mode-toggle",disabled:U,title:"Cycle theme: system, light, dark",type:"button",onClick:()=>qe(C2(je)),children:[w.jsx("span",{children:"Theme"}),w.jsx("span",{children:e_(je)})]}),w.jsx(Hn,{checked:((m==null?void 0:m.mode)??"auto")==="auto",className:"sidebar-switch",disabled:U||!l,label:"Auto orchestration",title:l?"Automatically dispatch role messages during the active task":"Create or select a task first",onChange:bt}),w.jsx(Hn,{checked:Et,className:"sidebar-switch",disabled:U,label:"Pause alert sound",title:"Play a sound when VCM shows the fixed flow pause dialog",onChange:Ve=>xt(Ve)}),w.jsx(Hn,{checked:Nt,className:"sidebar-switch",disabled:U,label:"CC auto retry",title:"Retry temporary Claude Code turn failures before showing the flow pause alert",onChange:Ve=>rt(Ve)}),w.jsxs("label",{className:"settings-select-row",children:[w.jsx("span",{children:"Permission requests"}),w.jsxs("select",{value:Wt,disabled:U,onChange:Ve=>rn(Ve.target.value),children:[w.jsx("option",{value:"off",children:"off"}),w.jsx("option",{value:"allowAll",children:"allow all"})]})]}),w.jsx(u2,{busy:U,status:O,onCheck:Ce,onSettingsChange:ae}),w.jsxs("button",{className:"settings-toggle",disabled:U||!mi,title:"Save the current core role launch settings and optional Reviewer settings",type:"button",onClick:Pi,children:[w.jsx("span",{children:"Save launch template"}),w.jsx("span",{children:mi?"ready":"open task"})]}),gi?w.jsxs("button",{className:"settings-toggle is-active",disabled:U,title:c2(Cr),type:"button",onClick:zn,children:[w.jsx("span",{children:"One-click start"}),w.jsx("span",{children:jv(Cr)})]}):null,l?w.jsxs(w.Fragment,{children:[w.jsxs("button",{type:"button",onClick:()=>In(!0),children:[w.jsx("span",{children:"Messages"}),w.jsxs("span",{className:"muted",children:[li.total," total"]})]}),w.jsxs("button",{type:"button",onClick:()=>_i(!0),children:[w.jsx("span",{children:"Events"}),w.jsxs("span",{className:"muted",children:[f.length," total"]})]})]}):null]})}),w.jsx(Kr,{title:"Translation",open:wn==="translation",onOpenChange:Ve=>Ht("translation",Ve),children:w.jsx(h2,{busy:U,enabled:u,autoSendEnabled:g,targetLanguage:h,outputMode:S,memoryInitialized:C,baseUnavailableReason:Kt,translatorSession:T,onAutoSendChange:mt,onCreateBootstrap:wt,onEnabledChange:St,onUpdateMemory:fe,onTargetLanguageChange:de,onOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it})}),t&&l?w.jsx(Kr,{title:"Gate Review Gates",open:wn==="gate-review-gates",onOpenChange:Ve=>Ht("gate-review-gates",Ve),children:w.jsx(p2,{busy:U,state:c,onCancelGateReview:ze,onGateEnabledChange:ce})}):null,w.jsx(Kr,{title:"Gateway",open:wn==="gateway",onOpenChange:Ve=>{Ht("gateway",Ve),Ve&&Q()},children:w.jsx(g2,{busy:U,qrCheck:D,qrLogin:R,larkRegistration:A,larkRegistrationCheck:M,status:L,onEnabledChange:$,onSettingsChange:he,onResetBinding:Ee,onStartLarkRegistration:He,onStartQrLogin:Fe,onTranslationChange:be,onConnectionChange:Le})}),t?w.jsx(Kr,{title:"VCM Harness",open:wn==="vcm-harness",onOpenChange:Ve=>Ht("vcm-harness",Ve),children:w.jsx(Yk,{status:E,bootstrapStatus:y,applyResult:v,hasActiveTask:!!ot,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,launchOptions:_,modelOptions:H,busy:U,onRefresh:V,onApply:Y,onOpenStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onLaunchOptionsChange:_e,onStartBootstrap:te,onRestartBootstrap:z,onStopBootstrap:j,onRunBootstrap:N})}):null,t?w.jsx(Kr,{title:"Task",open:wn==="task",onOpenChange:Ve=>Ht("task",Ve),children:gt.length>0?w.jsxs("div",{className:"task-panel",children:[w.jsx(i2,{tasks:gt,activeTaskSlug:l,onSelect:Be}),ot?w.jsxs("div",{className:"task-panel-actions",children:[w.jsx("button",{type:"button",onClick:()=>yi(!0),children:"Usage Analytics"}),w.jsx("button",{className:"danger-button",disabled:U,type:"button",onClick:Te,children:"Close Task"})]}):null]}):w.jsx("div",{className:"task-create",children:w.jsxs("form",{onSubmit:$i,children:[w.jsx("input",{value:si,onChange:Ve=>sn(Ve.target.value),placeholder:"task name"}),w.jsxs("div",{className:"task-create-preview",children:[w.jsxs("small",{children:["branch: ",hn?`feature/${hn}`:"feature/<task>"]}),w.jsxs("small",{children:["worktree: ",hn?`.claude/worktrees/${hn}`:".claude/worktrees/<task>"]})]}),w.jsx("button",{type:"submit",disabled:U||!hn,children:"Create"})]})})}):null,t&&ot?w.jsx(S2,{task:ot,roundState:o}):null,ai?w.jsx(x2,{busy:U,messages:d,orchestration:m,onClose:()=>In(!1),onMarkAllDone:()=>{l&&Fi(l)},onDeleteMessageHistory:()=>{l&&Jn(l)}}):null,qi?w.jsx(w2,{events:f,onClose:()=>_i(!1)}):null,ot?w.jsx(r2,{open:vi,taskSlug:ot.taskSlug,taskTitle:ot.title,onClose:()=>yi(!1)}):null]})}function jv(t){return[t.autoOrchestration?"auto":"manual"].join(" + ")}function c2(t){const r=Object.entries(t.roles).map(([s,l])=>`${s}: ${l.permissionMode} / ${l.model} / ${l.effort}`).join("; ");return`Launch template: ${jv(t)}; ${r}`}function u2({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 w.jsxs("div",{className:"codex-bridge-settings",children:[w.jsx(Hn,{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})}),w.jsxs("form",{className:"codex-bridge-api-key-form",onSubmit:c=>void o(c),children:[w.jsx("label",{htmlFor:"codex-bridge-api-key",children:"Codex Bridge API key"}),w.jsxs("div",{children:[w.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)}),w.jsx("button",{type:"submit",disabled:t||!d.trim(),children:"Save"})]})]}),w.jsxs("div",{className:"settings-status-row",children:[w.jsx("span",{children:"Codex Bridge status"}),w.jsx("strong",{children:(r==null?void 0:r.connectionState)??"loading"})]}),w.jsxs("div",{className:"codex-bridge-actions",children:[w.jsx("button",{type:"button",disabled:t||!(r!=null&&r.enabled),onClick:()=>void s(),children:"Check"}),w.jsx("button",{type:"button",disabled:t||!f,onClick:()=>void l({clearApiKey:!0}),children:"Clear key"})]}),r!=null&&r.error?w.jsx("p",{className:"settings-help-text",children:r.error}):null]})}function h2({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:C,onOpenFileTranslation:T,onOpenTranslatorSession:E}){const y=!!(s||r),v=(o==null?void 0:o.status)==="running",_=!!(l&&!r&&v),b=r??(v?null:"Start Translator session first."),k=!!(s||b),R=r??"Open Translator session",D=b??"Translation tools are ready";return w.jsxs("div",{className:"sidebar-settings",children:[w.jsx(Hn,{checked:_,className:"sidebar-switch",disabled:y||!v,label:"Conversation translation",title:D,onChange:g}),w.jsx(Hn,{checked:t,className:"sidebar-switch",disabled:y,label:"Auto-send",onChange:c}),w.jsxs("label",{className:"settings-select-row",children:[w.jsx("span",{children:"Language"}),w.jsx("select",{value:f,disabled:y,onChange:A=>C(A.target.value),children:g_.map(A=>w.jsx("option",{value:A.value,children:A.label},A.value))})]}),w.jsxs("label",{className:"settings-select-row",children:[w.jsx("span",{children:"Reply scope"}),w.jsx("select",{value:m,disabled:y,onChange:A=>S(A.target.value),children:cS.map(A=>w.jsx("option",{value:A.value,children:A.label},A.value))})]}),w.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:T,children:[w.jsx("span",{children:"File translation"}),w.jsx("span",{children:"open"})]}),d?null:w.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:u,children:[w.jsx("span",{children:"Bootstrap"}),w.jsx("span",{children:"run"})]}),w.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:h,children:[w.jsx("span",{children:"Update memory"}),w.jsx("span",{children:"run"})]}),b?w.jsx("p",{className:"settings-help-text",children:b}):null,w.jsxs("div",{className:"settings-status-row",children:[w.jsx("span",{children:"Session status"}),w.jsx("strong",{children:f2(o)})]}),w.jsxs("button",{className:"settings-toggle",disabled:y,title:R,type:"button",onClick:E,children:[w.jsx("span",{children:"Open Session"}),w.jsx("span",{children:"open"})]})]})}function f2(t){return t?t.status==="running"?t.activityStatus??"idle":t.status:"not started"}function d2(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 p2({busy:t,onCancelGateReview:r,onGateEnabledChange:s,state:l}){return w.jsx("div",{className:"sidebar-settings",children:Wk.map(d=>{const m=l==null?void 0:l.gates[d],f=!!(m!=null&&m.required);return w.jsxs("div",{className:"gate-review-setting",children:[w.jsx(Hn,{checked:f,className:"sidebar-switch",disabled:t||!l||(m==null?void 0:m.status)==="running",label:m2(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?w.jsx("button",{className:"danger-button",disabled:t,type:"button",onClick:()=>r(d,m.requestId),children:"Cancel review"}):null]},d)})})}function m2(t){switch(t){case"architecture-plan":return"Architecture plan";case"validation-adequacy":return"Validation adequacy";case"code-diff":return"Code diff"}return t}function g2({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 C=(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 w.jsxs("div",{className:"gateway-panel",children:[w.jsxs("label",{className:"compact-field",children:[w.jsx("span",{children:"Channel"}),w.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:[w.jsx("option",{value:"weixin-ilink",children:"Weixin iLink"}),w.jsx("option",{value:"lark",children:"Lark"})]})]}),w.jsxs("div",{className:"gateway-actions",children:[w.jsx(Hn,{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)}),w.jsx(Hn,{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)}),w.jsx(Hn,{checked:!!(S!=null&&S.translationEnabled),className:"sidebar-switch",disabled:t||!S,label:"Translation",onChange:y=>c(y)}),C?w.jsx("button",{type:"button",disabled:t,onClick:f,children:"Start QR Setup"}):E?w.jsx("button",{className:"danger-button",type:"button",disabled:t,onClick:d,children:"Reset Binding"}):w.jsx("button",{type:"button",disabled:t,onClick:o,children:"Start QR Login"})]}),C?w.jsxs("div",{className:"gateway-lark-settings",children:[w.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?w.jsxs("p",{className:"muted",children:["QR setup: ",(s==null?void 0:s.status)??r.status,s!=null&&s.message?` · ${s.message}`:""]}):null]}):h?w.jsx("p",{className:"muted",children:"QR login started. Use the login dialog to confirm binding."}):null,!C&&g?w.jsxs("p",{className:"muted",children:["QR status: ",g.status,g.message?` · ${g.message}`:""]}):null]})}function _2({busy:t,onPull:r,project:s}){const l=s.pullDisabledReason,d=!!s.canPull;return w.jsxs("div",{className:"project-summary",children:[w.jsxs("dl",{children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Base path"}),w.jsx("dd",{children:s.repoRoot})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Branch"}),w.jsx("dd",{children:v2(s)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Remote"}),w.jsx("dd",{children:s.upstreamBranch??"no upstream"})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Status"}),w.jsx("dd",{children:y2(s)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Commit"}),w.jsx("dd",{children:s.shortHeadCommit??s.headCommit??"unknown"})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Working tree"}),w.jsx("dd",{children:s.isDirty?"uncommitted changes":"clean"})]})]}),w.jsxs("div",{className:"connected-repo-actions",children:[w.jsx("button",{type:"button",disabled:t||!d,title:l??"Pull latest changes with git pull --ff-only",onClick:()=>void r(),children:"Pull"}),w.jsx("span",{className:"muted",children:s.checkedAt?`checked ${Hh(s.checkedAt)}`:"status not refreshed"})]}),l?w.jsx("p",{className:"muted",children:l}):null,s.warnings.length>0?w.jsx("ul",{className:"warnings",children:s.warnings.map(m=>w.jsx("li",{children:m},m))}):null]})}function v2(t){return t.branch||"unknown"}function y2(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 S2({roundState:t,task:r}){var g;const[s,l]=ee.useState(()=>Date.now()),d=!!(t!=null&&t.startedAt),m=Nv(r.createdAt,s),f=Zg(t,(t==null?void 0:t.totalCcActiveMs)??0,s),o=d&&t?Zg(t,t.currentRoundCcActiveMs,s):0,c=d&&t?b2(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)},[]),w.jsxs("section",{className:"task-status-dock","aria-label":"VCM Session status",children:[w.jsxs("div",{className:"task-status-dock-title",children:[w.jsx("strong",{title:u,children:u}),w.jsx("span",{className:`status-badge status-${r.status}`,children:r.status})]}),w.jsxs("dl",{className:"task-status-stats",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Session start"}),w.jsx("dd",{children:Hh(r.createdAt)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Session total"}),w.jsx("dd",{children:Ro(m)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Rounds"}),w.jsx("dd",{children:(t==null?void 0:t.totalRoundCount)??0})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Role runtime"}),w.jsx("dd",{children:Ro(f)})]})]}),d&&t?w.jsxs("div",{className:"current-round-status",children:[w.jsxs("div",{className:"current-round-title",children:[w.jsx("span",{children:t.status==="running"?"Current Round":"Last Round"}),w.jsx("span",{className:`status-badge status-${t.status}`,children:t.status})]}),w.jsxs("dl",{className:"task-status-stats",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Started"}),w.jsx("dd",{children:Hh(t.startedAt)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Total"}),w.jsx("dd",{children:Ro(c)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Role runtime"}),w.jsx("dd",{children:Ro(o)})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Turn count"}),w.jsx("dd",{children:t.turnCount})]})]})]}):null]})}function Zg(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 b2(t,r){const s=t.status==="running"?r:Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return Nv(t.startedAt??"",Number.isFinite(s)?s:r)}function Nv(t,r){const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,r-s):0}function Hh(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 Ro(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 C2(t){return t==="system"?"light":t==="light"?"dark":"system"}function e_(t){return t==="system"?"System":t==="light"?"Light":"Dark"}function w2({events:t,onClose:r}){return w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{className:"event-modal",role:"dialog","aria-modal":"true","aria-label":"Events",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Events"}),w.jsxs("p",{className:"muted",children:[t.length," total"]})]}),w.jsx("button",{type:"button",onClick:r,children:"Close"})]}),w.jsx(Kk,{events:t,maxEvents:null,showHeader:!1})]})})}function x2({busy:t,messages:r,orchestration:s,onClose:l,onMarkAllDone:d,onDeleteMessageHistory:m}){const f=af(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 w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{className:"message-modal",role:"dialog","aria-modal":"true","aria-label":"Messages",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Messages"}),w.jsxs("p",{className:"muted",children:[f.total," total / ",f.accepted," accepted",s?` · ${s.mode}`:""]})]}),w.jsxs("div",{className:"modal-actions",children:[w.jsx("button",{type:"button",disabled:t,onClick:o,children:"Mark All Done"}),w.jsx("button",{type:"button",disabled:t||f.total===0,onClick:c,children:"Delete All"}),w.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),w.jsx(Qk,{busy:t,maxMessages:null,messages:r,orchestration:s,showControls:!1,showHeader:!1})]})})}function Kr({children:t,onOpenChange:r,open:s,title:l}){return w.jsxs("section",{className:"sidebar-section",children:[w.jsxs("button",{"aria-expanded":s,className:"sidebar-section-toggle",type:"button",onClick:()=>{r==null||r(!s)},children:[w.jsx("span",{children:l}),w.jsx("span",{"aria-hidden":"true",className:"sidebar-section-chevron"})]}),s?w.jsx("div",{className:"sidebar-section-content",children:t}):null]})}function Hv(t,r){return t.find(s=>s.role===r)}function x2({activeRole:t,roles:r=Uo,sessions:s,onSelect:l}){return w.jsx("div",{className:"role-tabs",role:"tablist","aria-label":"Role sessions",children:r.map(d=>{const m=Hv(s,d.name),f=(m==null?void 0:m.status)==="running"?m.activityStatus??"idle":(m==null?void 0:m.status)??"not_started";return w.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:[w.jsx("span",{children:d.label}),w.jsx(jn,{status:f})]},d.name)})})}function E2({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:C,onTranslationFailures:T,onPermissionModeChange:E,onModelChange:y,onEffortChange:v,onStart:_,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D,onTerminalEvent:A}){const M=m_(t)&&c&&(r==null?void 0:r.status)==="running";return w.jsx("section",{className:"session-console",children:w.jsxs("div",{className:M?"session-console-body has-translation":"session-console-body",children:[w.jsxs("div",{className:"terminal-pane",children:[w.jsx(Uh,{role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,busy:o,onPermissionModeChange:E,onModelChange:y,onEffortChange:v,onStart:_,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D}),(r==null?void 0:r.status)==="running"?w.jsx(Po,{sessionId:r.id,active:f,onEvent:A},r.id):w.jsxs("div",{className:"terminal-empty",children:[w.jsx("strong",{children:t}),w.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?w.jsx("div",{className:"translation-pane",children:w.jsx(yk,{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:C??(()=>{}),onFailures:T??(()=>{})},`${t}:${r.id}`)}):null]})})}const Sh=500;function zh(t){return{taskSlug:t,cursor:1,sessions:{}}}function k2(t,r,s){return t.sessions[r]??Ws(s)}function A2(t,r){const l={...M2(t,r.taskSlug).sessions};for(const d of r.sessions)l[d.sessionId]={...Ws(d.role),...l[d.sessionId],role:d.role,status:d.status};for(const d of r.events){const m=l[d.sessionId]??Ws(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=Iv(zv(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 T2(t,r,s){return{...t,sessions:{...t.sessions,[r]:Ws(s)}}}function R2(t,r,s,l){const d=t.sessions[r]??Ws(s),m=Iv(zv(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 D2(t,r,s,l){const d=t.sessions[r]??Ws(s);return{...t,sessions:{...t.sessions,[r]:{...d,role:s,failures:l}}}}function M2(t,r){return t.taskSlug===r?t:zh(r)}function Ws(t){return{role:t,status:"ready",entries:[],failures:[]}}function zv(t,r){return t.findIndex(l=>l.id===r.id)===-1?[...t,r]:t.map(l=>l.id===r.id?r:l)}function Iv(t){if(t.length<=Sh)return{entries:t,removedIds:new Set};const r=t.slice(0,t.length-Sh);return{entries:t.slice(-Sh),removedIds:new Set(r.map(s=>s.id))}}const L2={"project-manager":"bypassPermissions",architect:"bypassPermissions",coder:"bypassPermissions",tester:"bypassPermissions",reviewer:"bypassPermissions",translator:"bypassPermissions","harness-engineer":"bypassPermissions"},O2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"default","harness-engineer":"default"},B2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"medium","harness-engineer":"medium"};function j2({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:C,onEventsChanged:T,onLaunchStateChanged:E}){const[y,v]=ee.useState(null),[_,b]=ee.useState(()=>n_(f)),[k,L]=ee.useState(()=>i_(f)),[R,D]=ee.useState(()=>r_(f)),[A,M]=ee.useState(!1),[,O]=Ii(""),[H,U]=ee.useState([]),[P,W]=ee.useState(null),[K,V]=ee.useState(null),[Y,te]=ee.useState(null),[z,j]=ee.useState(()=>zh(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")),me=s||ie,_e=[...sl,...me?[f_]:[]],Q=ee.useCallback((Ee,ce)=>{W(ce),h==null||h(Ee),S==null||S(ce)},[h,S]),$=ee.useCallback((Ee,ce,ze,St,mt)=>{v(Ee),V(mt),Q(ce,ze),C==null||C(St)},[Q,C]),he=ee.useCallback(async()=>{const Ee=await ye.getTaskWorkspaceState(t.taskSlug);te(Ee.architectRestart),$(Ee.taskStatus,Ee.messages,Ee.orchestration,Ee.roundState,Ee.workflowState),zo("Poll task workspace state"),O(ce=>Lo(ce,["Load task workspace state","Poll task workspace state"]))},[$,t.taskSlug]),ae=ee.useCallback((Ee,ce)=>{const ze=Ov(Ee,ce);ze&&O(ze)},[]);ol(`task-workspace:${t.taskSlug}:${c}`,()=>he().catch(Ee=>{ae("Poll task workspace state",Ee)}),{intervalMs:3e3,runImmediately:!0}),ol(l?`task-translation-feed:${t.taskSlug}`:null,async()=>{try{const Ee=await ye.pollTranslationTaskFeed(t.taskSlug,q.current);q.current=Ee.nextCursor,j(ce=>A2(ce,Ee)),zo("Poll task translation feed"),O(ce=>Lo(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(zh(t.taskSlug))},[t.taskSlug]),ee.useEffect(()=>{b(n_(f)),L(i_(f)),D(r_(f))},[I,t.taskSlug]),ee.useEffect(()=>{y&&!me&&r==="reviewer"&&g("project-manager"),y&&r==="translator"&&g("project-manager")},[r,me,g,y]),ee.useEffect(()=>{const Ee=y==null?void 0:y.task;if(!Ee||Ee.taskSlug!==t.taskSlug)return;const ce=t_(Ee);if(ce===t_(t)){N.current="";return}N.current!==ce&&(N.current=ce,u().catch(ze=>{N.current="",O(ft("Refresh task list after task status changed",ze))}))},[u,y==null?void 0:y.task,t]),ee.useEffect(()=>{const Ee=(y==null?void 0:y.sessions)??[],ce=Ee.filter(de=>N2(de.role)),ze=new Set(ce.map(de=>de.role)),St=Ee.some(de=>de.role==="reviewer"),mt={};for(const de of Ks)mt[de.name]={permissionMode:_[de.name],model:k[de.name],effort:R[de.name]};E==null||E({taskSlug:t.taskSlug,roles:mt,autoOrchestration:((P==null?void 0:P.mode)??"auto")==="auto",statusLoaded:!!y,sessionCount:ce.length,hasAnySession:ce.length>0,hasReviewerSession:St,allRolesHaveSession:sl.every(de=>ze.has(de.name))})},[k,R,E,P==null?void 0:P.mode,_,y,t.taskSlug]);async function Ce(Ee,ce="Run role session action"){M(!0),O("");try{await Ee(),await he(),await u()}catch(ze){O(ft(ce,ze))}finally{M(!1)}}function be(Ee){U(ce=>{const ze=[...ce,`${new Date().toLocaleTimeString()} ${Ee}`];return T==null||T(ze),ze})}function Le(Ee,ce){b(ze=>({...ze,[Ee]:ce}))}function Fe(Ee,ce){L(ze=>({...ze,[Ee]:ce}))}function He(Ee,ce){D(ze=>({...ze,[Ee]:ce}))}return w.jsxs("div",{className:"task-workspace",children:[w.jsxs("header",{className:"workspace-header",children:[w.jsxs("div",{className:"workspace-title-line",children:[w.jsx("h1",{children:t.title||t.taskSlug}),K!=null&&K.declared?w.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:[w.jsx("span",{children:K.declared.flow??"Workflow"}),K.declared.step?w.jsx("strong",{children:K.declared.step}):null]}):null]}),w.jsx(x2,{activeRole:r,roles:_e,sessions:(y==null?void 0:y.sessions)??[],onSelect:g})]}),(Y==null?void 0:Y.status)==="blocked"&&Y.blocker?w.jsxs("div",{className:"workspace-runtime-warning",role:"alert",children:[w.jsx("strong",{children:"Architect restart blocked"}),w.jsx("span",{children:Y.blocker.message}),w.jsx("code",{children:Y.blocker.code})]}):null,w.jsx("div",{className:"workspace-grid",children:w.jsx("div",{className:"workspace-main",children:w.jsx("div",{className:"role-console-stack",children:_e.map(Ee=>{const ce=Ee.name,ze=ce===r,St=(y==null?void 0:y.sessions)??[],mt=Hv(St,ce),de=mt?k2(z,mt.id,ce):void 0;return w.jsx("div",{className:ze?"role-console-panel is-active":"role-console-panel","aria-hidden":!ze,children:w.jsx(E2,{role:ce,session:mt,permissionMode:_[ce],model:k[ce],effort:R[ce],modelOptions:o,active:ze,busy:A,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,translationPanelState:de,onClearTranslationSession:(Ne,Ue)=>{j(it=>T2(it,Ne,Ue))},onTranslationEntry:(Ne,Ue,it)=>{j(wt=>R2(wt,Ne,Ue,it))},onTranslationFailures:(Ne,Ue,it)=>{j(wt=>D2(wt,Ne,Ue,it))},onPermissionModeChange:Ne=>Le(ce,Ne),onModelChange:Ne=>Fe(ce,Ne),onEffortChange:Ne=>He(ce,Ne),onStart:()=>void Ce(async()=>{await ye.startRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`started ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Start ${ce} session`),onResume:()=>void Ce(async()=>{await ye.resumeRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`resumed ${ce} with ${_[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:_[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Restart ${ce} session`),onRestartWithContext:()=>void Ce(async()=>{m_(ce)&&(await ye.restartRoleSessionWithContext(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[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:Ne=>be(`${Ee.label}: ${Ne}`)})},ce)})})})})]})}function N2(t){return sl.some(r=>r.name===t)}function t_(t){return[t.status,t.updatedAt,t.cleanupStatus??"",t.cleanedAt??""].join(":")}function n_(t){var s;const r={...L2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.permissionMode)??r[l.name];return r}function i_(t){var s;const r={...O2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.model)??r[l.name];return r}function r_(t){var s;const r={...B2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.effort)??r[l.name];return r}const H2=1400;function z2(t){return!!(t!=null&&t.initialized)}function I2(){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,C]=ee.useState(null),[T,E]=ee.useState(null),[y,v]=ee.useState(null),[_,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,me]=ee.useState(null),[_e,Q]=ee.useState(null),[$,he]=ee.useState(null),[ae,Ce]=ee.useState(null),[be,Le]=ee.useState(null),[Fe,He]=ee.useState("project-manager"),[Ee,ce]=ee.useState("system"),[ze,St]=ee.useState(!0),[mt,de]=ee.useState(!0),[Ne,Ue]=ee.useState("off"),[it,wt]=ee.useState(!1),[fe,we]=ee.useState(!1),[Te,Be]=ee.useState(!1),[je,bt]=ee.useState(!1),[qe,Et]=ee.useState(lS),[xt,Nt]=ee.useState(oS),[rt,Wt]=ee.useState(!1),[rn,Cr]=ee.useState(!1),[mi,gi]=ee.useState(!1),[Pi,zn]=ee.useState(!1),[Fi,Jn]=ee.useState(!1),[si,sn]=ee.useState(null),[ai,In]=ee.useState("bypassPermissions"),[qi,_i]=ee.useState("default"),[vi,yi]=ee.useState("medium"),[wn,Pt]=ee.useState(null),[li,hn]=ee.useState("bypassPermissions"),[Kt,gt]=ee.useState("default"),[ot,Ht]=ee.useState("medium"),[$i,Ve]=ee.useState(()=>uS()),[Un,dl]=ee.useState(null),[wr,Zr]=ee.useState(0),[xn,Si]=ee.useState(null),[xr,Gi]=ee.useState(null),[Tt,pl]=ee.useState(!1),[Vi,oi]=ee.useState(!1),[,fn]=Ii(""),ml=ee.useRef({}),es=ee.useRef({}),Qs=ee.useRef({}),gl=ee.useRef({}),Er=ee.useRef({}),bi=ee.useRef(null),Pn=ee.useRef({initialized:!1,messageId:null}),Yt=ee.useRef(""),Z=ee.useMemo(()=>Hk(j,q),[j,q]),dn=(Un==null?void 0:Un.taskSlug)===(Z==null?void 0:Z.taskSlug)?Un:null,kr=c===(Z==null?void 0:Z.taskSlug)?d:null,Js=g===(Z==null?void 0:Z.taskSlug)?f:null,ts=_===(Z==null?void 0:Z.taskSlug)?y:null,Wo=!!(t&&Z&&z2(kr)),pn=(si==null?void 0:si.status)==="running",ns=!!(Te&&Wo&&pn),_l=!!(dn!=null&&dn.statusLoaded),Zs=!!(Z&&(dn!=null&&dn.statusLoaded)&&!dn.hasAnySession),Zn=(R==null?void 0:R.modelOptions)??v_(),Ft=ee.useCallback((G,ue={})=>{ce(G.themeMode),St(G.flowPauseAlerts),de(G.roleRetryEnabled),Ue(G.permissionRequestMode),wt(G.autoTaskHarnessReviewEnabled),we(G.autoMemoryEnabled),Be(G.translationEnabled),bt(G.translationAutoSendEnabled),Et(G.translationTargetLanguage),Nt(G.translationOutputMode),Ve(G.launchTemplate),ue.syncToolLaunchOptions&&(In(G.toolSessionDefaults.translator.permissionMode),_i(G.toolSessionDefaults.translator.model),yi(G.toolSessionDefaults.translator.effort),hn(G.toolSessionDefaults["harness-engineer"].permissionMode),gt(G.toolSessionDefaults["harness-engineer"].model),Ht(G.toolSessionDefaults["harness-engineer"].effort))},[]);ee.useEffect(()=>{if(!ze)return;let G=!1;const ue=()=>{G||(G=!0,s_(),window.removeEventListener("pointerdown",ue),window.removeEventListener("keydown",ue))};return window.addEventListener("pointerdown",ue),window.addEventListener("keydown",ue),()=>{window.removeEventListener("pointerdown",ue),window.removeEventListener("keydown",ue)}},[ze]);const Fn=ee.useCallback(()=>{bi.current!==null&&(window.clearInterval(bi.current),bi.current=null)},[]),Ci=ee.useCallback(()=>{Fn(),a_(),bi.current=window.setInterval(()=>{a_()},H2)},[Fn]),vl=ee.useCallback((G,ue=`manual-${Date.now()}`)=>{Si({id:ue,text:G})},[]),is=ee.useCallback(()=>{Fn(),Si(null)},[Fn]);ee.useEffect(()=>{Z!=null&&Z.taskSlug&&(Er.current[Z.taskSlug]=Date.now())},[Z==null?void 0:Z.taskSlug]);const yl=ee.useCallback(G=>{Z!=null&&Z.taskSlug&&me({taskSlug:Z.taskSlug,messages:G})},[Z==null?void 0:Z.taskSlug]),ea=ee.useCallback(G=>{Qs.current[G.taskSlug]=G.mode,Z!=null&&Z.taskSlug&&Q({taskSlug:Z.taskSlug,orchestration:G})},[Z==null?void 0:Z.taskSlug]),Ko=ee.useCallback(G=>{Z!=null&&Z.taskSlug&&he({taskSlug:Z.taskSlug,events:G})},[Z==null?void 0:Z.taskSlug]),Yo=ee.useCallback(G=>{if(!(Z!=null&&Z.taskSlug)||G.taskSlug!==Z.taskSlug)return;Ce({taskSlug:G.taskSlug,roundState:G});const ue=zk({mode:Qs.current[G.taskSlug],status:G.status,activeRole:G.activeRole,lastFollowedRole:gl.current[G.taskSlug]});ue&&(gl.current[G.taskSlug]=ue,He(ue));const Xe=Ik(G,G2);if(Xe===null){es.current[G.taskSlug]={status:G.status};return}const on=Uk(G),wi=ml.current[G.taskSlug],Jo=es.current[G.taskSlug];es.current[G.taskSlug]={status:G.status},wi!==on&&(ml.current[G.taskSlug]=on,F2(G,Jo,Er.current[G.taskSlug])&&vl(Xe,on))},[Z==null?void 0:Z.taskSlug,vl]),rs=ee.useCallback(G=>{dl(ue=>(ue==null?void 0:ue.taskSlug)===G.taskSlug&&ue.statusLoaded===G.statusLoaded&&ue.sessionCount===G.sessionCount&&ue.hasAnySession===G.hasAnySession&&ue.hasReviewerSession===G.hasReviewerSession&&ue.allRolesHaveSession===G.allRolesHaveSession&&ue.autoOrchestration===G.autoOrchestration&&JSON.stringify(ue.roles)===JSON.stringify(G.roles)?ue:G)},[]);async function Xt(){const G=await ye.listTasks();return N(G),I(ue=>{var Xe;return ue&&G.some(on=>on.taskSlug===ue)?ue:((Xe=G[0])==null?void 0:Xe.taskSlug)??null}),G}async function Ar(G=Z==null?void 0:Z.taskSlug){if(!G)return m(null),u(null),null;const ue=await ye.getHarnessStatus(G);return m(ue),u(G),ue}async function Tr(G=Z==null?void 0:Z.taskSlug){if(!G)return o(null),h(null),null;const ue=await ye.getHarnessBootstrapStatus(G);return o(ue),h(G),ue}async function En(){const G=await ye.getGatewayStatus();return L(G),G}async function Wi(){const G=await ye.getRecentRepositoryPaths();return l(G),G}async function ta(){if(!t)return Wt(!1),!1;const G=await ye.getTranslationState();return Wt(G.memoryInitialized),G.memoryInitialized}async function Rr(G){const[ue,Xe]=await Promise.all([ye.listMessages(G),ye.getOrchestrationState(G)]);me({taskSlug:G,messages:ue}),Q({taskSlug:G,orchestration:Xe})}async function na(G){const ue=await ye.getGateReviewState(G);return Le({taskSlug:G,state:ue}),zo("Poll Gate Review state"),fn(Xe=>Lo(Xe,["Refresh Gate Review state","Poll Gate Review state"])),ue}function Ki(G,ue){const Xe=Ov(G,ue);Xe&&fn(Xe)}function Qt(G){G&&(In(G.permissionMode),G.model&&_i(G.model),G.effort&&yi(G.effort))}async function ss(G={}){const ue=await ye.getTranslatorSession((Z==null?void 0:Z.taskSlug)??null);return sn(ue),G.syncLaunchOptions&&Qt(ue),ue}function kn(G){G&&(hn(G.permissionMode),G.model&>(G.model),G.effort&&Ht(G.effort))}async function an(G={}){const ue=await ye.getHarnessEngineerSession((Z==null?void 0:Z.taskSlug)??null);return Pt(ue),G.syncLaunchOptions&&kn(ue),ue}async function ia(G=Z==null?void 0:Z.taskSlug){if(!t)return E(null),null;const ue=await ye.getHarnessFeedbackState(G);return E(ue),ue}function as(G,ue,Xe={}){var on;sn(G.translatorSession),Wt(!!((on=G.translationState)!=null&&on.memoryInitialized)),Pt(G.harnessEngineerSession),E(G.harnessFeedbackState),v(G.autoMemoryState),b(ue&&G.autoMemoryState?ue:null),L(G.gatewayStatus),ue&&G.harnessStatus?(m(G.harnessStatus),u(ue)):(m(null),u(null)),ue&&G.harnessBootstrapStatus?(o(G.harnessBootstrapStatus),h(ue)):(o(null),h(null)),Xe.syncLaunchOptions&&(Qt(G.translatorSession),kn(G.harnessEngineerSession))}async function ra(G={}){if(!t)return sn(null),Wt(!1),Pt(null),m(null),o(null),u(null),h(null),E(null),v(null),b(null),null;const ue=(Z==null?void 0:Z.taskSlug)??null,Xe=await ye.getProjectRuntimeState(ue);return as(Xe,ue,G),Xe}function ls(){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 ue of G)zo(ue);fn(ue=>Lo(ue,G))}ee.useEffect(()=>{Promise.all([ye.getCurrentProject(),ye.getRecentRepositoryPaths(),ye.getAppPreferences(),ye.getGatewayStatus(),ye.getCodexBridgeIntegrationStatus()]).then(async([G,ue,Xe,on,wi])=>{r(G),l(ue),L(on),D(wi),Ft(Xe,{syncToolLaunchOptions:!0}),G&&await Xt()}).catch(G=>fn(ft("Load initial app data",G)))},[Ft]),ee.useEffect(()=>{const G=window.matchMedia("(prefers-color-scheme: dark)"),ue=()=>pl(G.matches);return ue(),G.addEventListener("change",ue),()=>G.removeEventListener("change",ue)},[]),ee.useEffect(()=>()=>Fn(),[Fn]),ee.useEffect(()=>{(k==null?void 0:k.pauseAlertSoundEnabled)!==void 0&&St(k.pauseAlertSoundEnabled);const G=Fk(Pn.current,k);Pn.current=G.observation,G.dismissPauseAlert&&is()},[is,k]),ee.useEffect(()=>{if(xn&&Pk(ze)==="strong")return Ci(),Fn;Fn()},[xn==null?void 0:xn.id,ze,Ci,Fn]),ee.useEffect(()=>{const G=Ee==="system"?Tt?"dark":"light":Ee;document.documentElement.dataset.theme=G,document.documentElement.dataset.themeMode=Ee},[Tt,Ee]),ee.useEffect(()=>{if(!(Z!=null&&Z.taskSlug)){Le(null);return}na(Z.taskSlug).catch(G=>fn(ft("Refresh Gate Review state",G)))},[Z==null?void 0:Z.taskSlug]),ee.useEffect(()=>{Yt.current="",sn(null),Wt(!1),Pt(null),m(null),o(null),u(null),h(null),E(null)},[t==null?void 0:t.repoRoot,Z==null?void 0:Z.taskSlug]),ol(t?`project-runtime:${t.repoRoot}:${(Z==null?void 0:Z.taskSlug)??"no-task"}`:null,async()=>{try{const G=t?`${t.repoRoot}:${(Z==null?void 0:Z.taskSlug)??"no-task"}`:"",ue=!!(t&&Yt.current!==G);await ra({syncLaunchOptions:ue}),ue&&(Yt.current=G),ls()}catch(G){Ki("Poll project runtime state",G)}},{intervalMs:3e3,runImmediately:!0});const Jt=(Z==null?void 0:Z.taskSlug)??null,os=Jt&&(be==null?void 0:be.taskSlug)===Jt?be.state:null,It=Jt&&(ae==null?void 0:ae.taskSlug)===Jt?ae.roundState:null,ei=Jt&&(Un==null?void 0:Un.taskSlug)===Jt?Un:null,cs=!!(Jt&&(os!=null&&os.activeGate||(It==null?void 0:It.activeRole)==="reviewer"||ei!=null&&ei.hasReviewerSession));ol(cs&&Jt?`gate-review:${Jt}`:null,async()=>{if(Jt)try{await na(Jt)}catch(G){Ki("Poll Gate Review state",G)}},{intervalMs:3e3,runImmediately:!1});async function Ae(G,ue="Run UI action"){oi(!0),fn("");try{await G()}catch(Xe){fn(ft(ue,Xe))}finally{oi(!1)}}async function Xo(){var on;if(!Z)throw new Error("Create or select a task before closing it.");const G=[`Close task "${Z.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: ${Z.worktreePath}`,`- deletes the Git branch: ${Z.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 w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{className:"message-modal",role:"dialog","aria-modal":"true","aria-label":"Messages",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{children:"Messages"}),w.jsxs("p",{className:"muted",children:[f.total," total / ",f.accepted," accepted",s?` · ${s.mode}`:""]})]}),w.jsxs("div",{className:"modal-actions",children:[w.jsx("button",{type:"button",disabled:t,onClick:o,children:"Mark All Done"}),w.jsx("button",{type:"button",disabled:t||f.total===0,onClick:c,children:"Delete All"}),w.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),w.jsx(Jk,{busy:t,maxMessages:null,messages:r,orchestration:s,showControls:!1,showHeader:!1})]})})}function Kr({children:t,onOpenChange:r,open:s,title:l}){return w.jsxs("section",{className:"sidebar-section",children:[w.jsxs("button",{"aria-expanded":s,className:"sidebar-section-toggle",type:"button",onClick:()=>{r==null||r(!s)},children:[w.jsx("span",{children:l}),w.jsx("span",{"aria-hidden":"true",className:"sidebar-section-chevron"})]}),s?w.jsx("div",{className:"sidebar-section-content",children:t}):null]})}function Hv(t,r){return t.find(s=>s.role===r)}function E2({activeRole:t,roles:r=Uo,sessions:s,onSelect:l}){return w.jsx("div",{className:"role-tabs",role:"tablist","aria-label":"Role sessions",children:r.map(d=>{const m=Hv(s,d.name),f=(m==null?void 0:m.status)==="running"?m.activityStatus??"idle":(m==null?void 0:m.status)??"not_started";return w.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:[w.jsx("span",{children:d.label}),w.jsx(jn,{status:f})]},d.name)})})}function k2({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:C,onTranslationFailures:T,onPermissionModeChange:E,onModelChange:y,onEffortChange:v,onStart:_,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D,onTerminalEvent:A}){const M=m_(t)&&c&&(r==null?void 0:r.status)==="running";return w.jsx("section",{className:"session-console",children:w.jsxs("div",{className:M?"session-console-body has-translation":"session-console-body",children:[w.jsxs("div",{className:"terminal-pane",children:[w.jsx(Uh,{role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,busy:o,onPermissionModeChange:E,onModelChange:y,onEffortChange:v,onStart:_,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D}),(r==null?void 0:r.status)==="running"?w.jsx(Po,{sessionId:r.id,active:f,onEvent:A},r.id):w.jsxs("div",{className:"terminal-empty",children:[w.jsx("strong",{children:t}),w.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?w.jsx("div",{className:"translation-pane",children:w.jsx(yk,{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:C??(()=>{}),onFailures:T??(()=>{})},`${t}:${r.id}`)}):null]})})}const Sh=500;function zh(t){return{taskSlug:t,cursor:1,sessions:{}}}function A2(t,r,s){return t.sessions[r]??Ws(s)}function T2(t,r){const l={...L2(t,r.taskSlug).sessions};for(const d of r.sessions)l[d.sessionId]={...Ws(d.role),...l[d.sessionId],role:d.role,status:d.status};for(const d of r.events){const m=l[d.sessionId]??Ws(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=Iv(zv(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 R2(t,r,s){return{...t,sessions:{...t.sessions,[r]:Ws(s)}}}function D2(t,r,s,l){const d=t.sessions[r]??Ws(s),m=Iv(zv(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 M2(t,r,s,l){const d=t.sessions[r]??Ws(s);return{...t,sessions:{...t.sessions,[r]:{...d,role:s,failures:l}}}}function L2(t,r){return t.taskSlug===r?t:zh(r)}function Ws(t){return{role:t,status:"ready",entries:[],failures:[]}}function zv(t,r){return t.findIndex(l=>l.id===r.id)===-1?[...t,r]:t.map(l=>l.id===r.id?r:l)}function Iv(t){if(t.length<=Sh)return{entries:t,removedIds:new Set};const r=t.slice(0,t.length-Sh);return{entries:t.slice(-Sh),removedIds:new Set(r.map(s=>s.id))}}const O2={"project-manager":"bypassPermissions",architect:"bypassPermissions",coder:"bypassPermissions",tester:"bypassPermissions",reviewer:"bypassPermissions",translator:"bypassPermissions","harness-engineer":"bypassPermissions"},B2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"default","harness-engineer":"default"},j2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"medium","harness-engineer":"medium"};function N2({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:C,onEventsChanged:T,onLaunchStateChanged:E}){const[y,v]=ee.useState(null),[_,b]=ee.useState(()=>n_(f)),[k,L]=ee.useState(()=>i_(f)),[R,D]=ee.useState(()=>r_(f)),[A,M]=ee.useState(!1),[,O]=Ii(""),[H,U]=ee.useState([]),[P,W]=ee.useState(null),[K,V]=ee.useState(null),[Y,te]=ee.useState(null),[z,j]=ee.useState(()=>zh(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")),me=s||ie,_e=[...sl,...me?[f_]:[]],Q=ee.useCallback((Ee,ce)=>{W(ce),h==null||h(Ee),S==null||S(ce)},[h,S]),$=ee.useCallback((Ee,ce,ze,St,mt)=>{v(Ee),V(mt),Q(ce,ze),C==null||C(St)},[Q,C]),he=ee.useCallback(async()=>{const Ee=await ye.getTaskWorkspaceState(t.taskSlug);te(Ee.architectRestart),$(Ee.taskStatus,Ee.messages,Ee.orchestration,Ee.roundState,Ee.workflowState),zo("Poll task workspace state"),O(ce=>Lo(ce,["Load task workspace state","Poll task workspace state"]))},[$,t.taskSlug]),ae=ee.useCallback((Ee,ce)=>{const ze=Ov(Ee,ce);ze&&O(ze)},[]);ol(`task-workspace:${t.taskSlug}:${c}`,()=>he().catch(Ee=>{ae("Poll task workspace state",Ee)}),{intervalMs:3e3,runImmediately:!0}),ol(l?`task-translation-feed:${t.taskSlug}`:null,async()=>{try{const Ee=await ye.pollTranslationTaskFeed(t.taskSlug,q.current);q.current=Ee.nextCursor,j(ce=>T2(ce,Ee)),zo("Poll task translation feed"),O(ce=>Lo(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(zh(t.taskSlug))},[t.taskSlug]),ee.useEffect(()=>{b(n_(f)),L(i_(f)),D(r_(f))},[I,t.taskSlug]),ee.useEffect(()=>{y&&!me&&r==="reviewer"&&g("project-manager"),y&&r==="translator"&&g("project-manager")},[r,me,g,y]),ee.useEffect(()=>{const Ee=y==null?void 0:y.task;if(!Ee||Ee.taskSlug!==t.taskSlug)return;const ce=t_(Ee);if(ce===t_(t)){N.current="";return}N.current!==ce&&(N.current=ce,u().catch(ze=>{N.current="",O(ft("Refresh task list after task status changed",ze))}))},[u,y==null?void 0:y.task,t]),ee.useEffect(()=>{const Ee=(y==null?void 0:y.sessions)??[],ce=Ee.filter(de=>H2(de.role)),ze=new Set(ce.map(de=>de.role)),St=Ee.some(de=>de.role==="reviewer"),mt={};for(const de of Ks)mt[de.name]={permissionMode:_[de.name],model:k[de.name],effort:R[de.name]};E==null||E({taskSlug:t.taskSlug,roles:mt,autoOrchestration:((P==null?void 0:P.mode)??"auto")==="auto",statusLoaded:!!y,sessionCount:ce.length,hasAnySession:ce.length>0,hasReviewerSession:St,allRolesHaveSession:sl.every(de=>ze.has(de.name))})},[k,R,E,P==null?void 0:P.mode,_,y,t.taskSlug]);async function Ce(Ee,ce="Run role session action"){M(!0),O("");try{await Ee(),await he(),await u()}catch(ze){O(ft(ce,ze))}finally{M(!1)}}function be(Ee){U(ce=>{const ze=[...ce,`${new Date().toLocaleTimeString()} ${Ee}`];return T==null||T(ze),ze})}function Le(Ee,ce){b(ze=>({...ze,[Ee]:ce}))}function Fe(Ee,ce){L(ze=>({...ze,[Ee]:ce}))}function He(Ee,ce){D(ze=>({...ze,[Ee]:ce}))}return w.jsxs("div",{className:"task-workspace",children:[w.jsxs("header",{className:"workspace-header",children:[w.jsxs("div",{className:"workspace-title-line",children:[w.jsx("h1",{children:t.title||t.taskSlug}),K!=null&&K.declared?w.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:[w.jsx("span",{children:K.declared.flow??"Workflow"}),K.declared.step?w.jsx("strong",{children:K.declared.step}):null]}):null]}),w.jsx(E2,{activeRole:r,roles:_e,sessions:(y==null?void 0:y.sessions)??[],onSelect:g})]}),(Y==null?void 0:Y.status)==="blocked"&&Y.blocker?w.jsxs("div",{className:"workspace-runtime-warning",role:"alert",children:[w.jsx("strong",{children:"Architect restart blocked"}),w.jsx("span",{children:Y.blocker.message}),w.jsx("code",{children:Y.blocker.code})]}):null,w.jsx("div",{className:"workspace-grid",children:w.jsx("div",{className:"workspace-main",children:w.jsx("div",{className:"role-console-stack",children:_e.map(Ee=>{const ce=Ee.name,ze=ce===r,St=(y==null?void 0:y.sessions)??[],mt=Hv(St,ce),de=mt?A2(z,mt.id,ce):void 0;return w.jsx("div",{className:ze?"role-console-panel is-active":"role-console-panel","aria-hidden":!ze,children:w.jsx(k2,{role:ce,session:mt,permissionMode:_[ce],model:k[ce],effort:R[ce],modelOptions:o,active:ze,busy:A,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,translationPanelState:de,onClearTranslationSession:(Ne,Ue)=>{j(it=>R2(it,Ne,Ue))},onTranslationEntry:(Ne,Ue,it)=>{j(wt=>D2(wt,Ne,Ue,it))},onTranslationFailures:(Ne,Ue,it)=>{j(wt=>M2(wt,Ne,Ue,it))},onPermissionModeChange:Ne=>Le(ce,Ne),onModelChange:Ne=>Fe(ce,Ne),onEffortChange:Ne=>He(ce,Ne),onStart:()=>void Ce(async()=>{await ye.startRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`started ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Start ${ce} session`),onResume:()=>void Ce(async()=>{await ye.resumeRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`resumed ${ce} with ${_[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:_[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Restart ${ce} session`),onRestartWithContext:()=>void Ce(async()=>{m_(ce)&&(await ye.restartRoleSessionWithContext(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[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:Ne=>be(`${Ee.label}: ${Ne}`)})},ce)})})})})]})}function H2(t){return sl.some(r=>r.name===t)}function t_(t){return[t.status,t.updatedAt,t.cleanupStatus??"",t.cleanedAt??""].join(":")}function n_(t){var s;const r={...O2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.permissionMode)??r[l.name];return r}function i_(t){var s;const r={...B2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.model)??r[l.name];return r}function r_(t){var s;const r={...j2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.effort)??r[l.name];return r}const z2=1400;function I2(t){return!!(t!=null&&t.initialized)}function U2(){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,C]=ee.useState(null),[T,E]=ee.useState(null),[y,v]=ee.useState(null),[_,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,me]=ee.useState(null),[_e,Q]=ee.useState(null),[$,he]=ee.useState(null),[ae,Ce]=ee.useState(null),[be,Le]=ee.useState(null),[Fe,He]=ee.useState("project-manager"),[Ee,ce]=ee.useState("system"),[ze,St]=ee.useState(!0),[mt,de]=ee.useState(!0),[Ne,Ue]=ee.useState("off"),[it,wt]=ee.useState(!1),[fe,we]=ee.useState(!1),[Te,Be]=ee.useState(!1),[je,bt]=ee.useState(!1),[qe,Et]=ee.useState(lS),[xt,Nt]=ee.useState(oS),[rt,Wt]=ee.useState(!1),[rn,Cr]=ee.useState(!1),[mi,gi]=ee.useState(!1),[Pi,zn]=ee.useState(!1),[Fi,Jn]=ee.useState(!1),[si,sn]=ee.useState(null),[ai,In]=ee.useState("bypassPermissions"),[qi,_i]=ee.useState("default"),[vi,yi]=ee.useState("medium"),[wn,Pt]=ee.useState(null),[li,hn]=ee.useState("bypassPermissions"),[Kt,gt]=ee.useState("default"),[ot,Ht]=ee.useState("medium"),[$i,Ve]=ee.useState(()=>uS()),[Un,dl]=ee.useState(null),[wr,Zr]=ee.useState(0),[xn,Si]=ee.useState(null),[xr,Gi]=ee.useState(null),[Tt,pl]=ee.useState(!1),[Vi,oi]=ee.useState(!1),[,fn]=Ii(""),ml=ee.useRef({}),es=ee.useRef({}),Qs=ee.useRef({}),gl=ee.useRef({}),Er=ee.useRef({}),bi=ee.useRef(null),Pn=ee.useRef({initialized:!1,messageId:null}),Yt=ee.useRef(""),Z=ee.useMemo(()=>Hk(j,q),[j,q]),dn=(Un==null?void 0:Un.taskSlug)===(Z==null?void 0:Z.taskSlug)?Un:null,kr=c===(Z==null?void 0:Z.taskSlug)?d:null,Js=g===(Z==null?void 0:Z.taskSlug)?f:null,ts=_===(Z==null?void 0:Z.taskSlug)?y:null,Wo=!!(t&&Z&&I2(kr)),pn=(si==null?void 0:si.status)==="running",ns=!!(Te&&Wo&&pn),_l=!!(dn!=null&&dn.statusLoaded),Zs=!!(Z&&(dn!=null&&dn.statusLoaded)&&!dn.hasAnySession),Zn=(R==null?void 0:R.modelOptions)??v_(),Ft=ee.useCallback((G,ue={})=>{ce(G.themeMode),St(G.flowPauseAlerts),de(G.roleRetryEnabled),Ue(G.permissionRequestMode),wt(G.autoTaskHarnessReviewEnabled),we(G.autoMemoryEnabled),Be(G.translationEnabled),bt(G.translationAutoSendEnabled),Et(G.translationTargetLanguage),Nt(G.translationOutputMode),Ve(G.launchTemplate),ue.syncToolLaunchOptions&&(In(G.toolSessionDefaults.translator.permissionMode),_i(G.toolSessionDefaults.translator.model),yi(G.toolSessionDefaults.translator.effort),hn(G.toolSessionDefaults["harness-engineer"].permissionMode),gt(G.toolSessionDefaults["harness-engineer"].model),Ht(G.toolSessionDefaults["harness-engineer"].effort))},[]);ee.useEffect(()=>{if(!ze)return;let G=!1;const ue=()=>{G||(G=!0,s_(),window.removeEventListener("pointerdown",ue),window.removeEventListener("keydown",ue))};return window.addEventListener("pointerdown",ue),window.addEventListener("keydown",ue),()=>{window.removeEventListener("pointerdown",ue),window.removeEventListener("keydown",ue)}},[ze]);const Fn=ee.useCallback(()=>{bi.current!==null&&(window.clearInterval(bi.current),bi.current=null)},[]),Ci=ee.useCallback(()=>{Fn(),a_(),bi.current=window.setInterval(()=>{a_()},z2)},[Fn]),vl=ee.useCallback((G,ue=`manual-${Date.now()}`)=>{Si({id:ue,text:G})},[]),is=ee.useCallback(()=>{Fn(),Si(null)},[Fn]);ee.useEffect(()=>{Z!=null&&Z.taskSlug&&(Er.current[Z.taskSlug]=Date.now())},[Z==null?void 0:Z.taskSlug]);const yl=ee.useCallback(G=>{Z!=null&&Z.taskSlug&&me({taskSlug:Z.taskSlug,messages:G})},[Z==null?void 0:Z.taskSlug]),ea=ee.useCallback(G=>{Qs.current[G.taskSlug]=G.mode,Z!=null&&Z.taskSlug&&Q({taskSlug:Z.taskSlug,orchestration:G})},[Z==null?void 0:Z.taskSlug]),Ko=ee.useCallback(G=>{Z!=null&&Z.taskSlug&&he({taskSlug:Z.taskSlug,events:G})},[Z==null?void 0:Z.taskSlug]),Yo=ee.useCallback(G=>{if(!(Z!=null&&Z.taskSlug)||G.taskSlug!==Z.taskSlug)return;Ce({taskSlug:G.taskSlug,roundState:G});const ue=zk({mode:Qs.current[G.taskSlug],status:G.status,activeRole:G.activeRole,lastFollowedRole:gl.current[G.taskSlug]});ue&&(gl.current[G.taskSlug]=ue,He(ue));const Xe=Ik(G,G2);if(Xe===null){es.current[G.taskSlug]={status:G.status};return}const on=Uk(G),wi=ml.current[G.taskSlug],Jo=es.current[G.taskSlug];es.current[G.taskSlug]={status:G.status},wi!==on&&(ml.current[G.taskSlug]=on,Pk(G,Jo,Er.current[G.taskSlug])&&vl(Xe,on))},[Z==null?void 0:Z.taskSlug,vl]),rs=ee.useCallback(G=>{dl(ue=>(ue==null?void 0:ue.taskSlug)===G.taskSlug&&ue.statusLoaded===G.statusLoaded&&ue.sessionCount===G.sessionCount&&ue.hasAnySession===G.hasAnySession&&ue.hasReviewerSession===G.hasReviewerSession&&ue.allRolesHaveSession===G.allRolesHaveSession&&ue.autoOrchestration===G.autoOrchestration&&JSON.stringify(ue.roles)===JSON.stringify(G.roles)?ue:G)},[]);async function Xt(){const G=await ye.listTasks();return N(G),I(ue=>{var Xe;return ue&&G.some(on=>on.taskSlug===ue)?ue:((Xe=G[0])==null?void 0:Xe.taskSlug)??null}),G}async function Ar(G=Z==null?void 0:Z.taskSlug){if(!G)return m(null),u(null),null;const ue=await ye.getHarnessStatus(G);return m(ue),u(G),ue}async function Tr(G=Z==null?void 0:Z.taskSlug){if(!G)return o(null),h(null),null;const ue=await ye.getHarnessBootstrapStatus(G);return o(ue),h(G),ue}async function En(){const G=await ye.getGatewayStatus();return L(G),G}async function Wi(){const G=await ye.getRecentRepositoryPaths();return l(G),G}async function ta(){if(!t)return Wt(!1),!1;const G=await ye.getTranslationState();return Wt(G.memoryInitialized),G.memoryInitialized}async function Rr(G){const[ue,Xe]=await Promise.all([ye.listMessages(G),ye.getOrchestrationState(G)]);me({taskSlug:G,messages:ue}),Q({taskSlug:G,orchestration:Xe})}async function na(G){const ue=await ye.getGateReviewState(G);return Le({taskSlug:G,state:ue}),zo("Poll Gate Review state"),fn(Xe=>Lo(Xe,["Refresh Gate Review state","Poll Gate Review state"])),ue}function Ki(G,ue){const Xe=Ov(G,ue);Xe&&fn(Xe)}function Qt(G){G&&(In(G.permissionMode),G.model&&_i(G.model),G.effort&&yi(G.effort))}async function ss(G={}){const ue=await ye.getTranslatorSession((Z==null?void 0:Z.taskSlug)??null);return sn(ue),G.syncLaunchOptions&&Qt(ue),ue}function kn(G){G&&(hn(G.permissionMode),G.model&>(G.model),G.effort&&Ht(G.effort))}async function an(G={}){const ue=await ye.getHarnessEngineerSession((Z==null?void 0:Z.taskSlug)??null);return Pt(ue),G.syncLaunchOptions&&kn(ue),ue}async function ia(G=Z==null?void 0:Z.taskSlug){if(!t)return E(null),null;const ue=await ye.getHarnessFeedbackState(G);return E(ue),ue}function as(G,ue,Xe={}){var on;sn(G.translatorSession),Wt(!!((on=G.translationState)!=null&&on.memoryInitialized)),Pt(G.harnessEngineerSession),E(G.harnessFeedbackState),v(G.autoMemoryState),b(ue&&G.autoMemoryState?ue:null),L(G.gatewayStatus),ue&&G.harnessStatus?(m(G.harnessStatus),u(ue)):(m(null),u(null)),ue&&G.harnessBootstrapStatus?(o(G.harnessBootstrapStatus),h(ue)):(o(null),h(null)),Xe.syncLaunchOptions&&(Qt(G.translatorSession),kn(G.harnessEngineerSession))}async function ra(G={}){if(!t)return sn(null),Wt(!1),Pt(null),m(null),o(null),u(null),h(null),E(null),v(null),b(null),null;const ue=(Z==null?void 0:Z.taskSlug)??null,Xe=await ye.getProjectRuntimeState(ue);return as(Xe,ue,G),Xe}function ls(){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 ue of G)zo(ue);fn(ue=>Lo(ue,G))}ee.useEffect(()=>{Promise.all([ye.getCurrentProject(),ye.getRecentRepositoryPaths(),ye.getAppPreferences(),ye.getGatewayStatus(),ye.getCodexBridgeIntegrationStatus()]).then(async([G,ue,Xe,on,wi])=>{r(G),l(ue),L(on),D(wi),Ft(Xe,{syncToolLaunchOptions:!0}),G&&await Xt()}).catch(G=>fn(ft("Load initial app data",G)))},[Ft]),ee.useEffect(()=>{const G=window.matchMedia("(prefers-color-scheme: dark)"),ue=()=>pl(G.matches);return ue(),G.addEventListener("change",ue),()=>G.removeEventListener("change",ue)},[]),ee.useEffect(()=>()=>Fn(),[Fn]),ee.useEffect(()=>{(k==null?void 0:k.pauseAlertSoundEnabled)!==void 0&&St(k.pauseAlertSoundEnabled);const G=qk(Pn.current,k);Pn.current=G.observation,G.dismissPauseAlert&&is()},[is,k]),ee.useEffect(()=>{if(xn&&Fk(ze)==="strong")return Ci(),Fn;Fn()},[xn==null?void 0:xn.id,ze,Ci,Fn]),ee.useEffect(()=>{const G=Ee==="system"?Tt?"dark":"light":Ee;document.documentElement.dataset.theme=G,document.documentElement.dataset.themeMode=Ee},[Tt,Ee]),ee.useEffect(()=>{if(!(Z!=null&&Z.taskSlug)){Le(null);return}na(Z.taskSlug).catch(G=>fn(ft("Refresh Gate Review state",G)))},[Z==null?void 0:Z.taskSlug]),ee.useEffect(()=>{Yt.current="",sn(null),Wt(!1),Pt(null),m(null),o(null),u(null),h(null),E(null)},[t==null?void 0:t.repoRoot,Z==null?void 0:Z.taskSlug]),ol(t?`project-runtime:${t.repoRoot}:${(Z==null?void 0:Z.taskSlug)??"no-task"}`:null,async()=>{try{const G=t?`${t.repoRoot}:${(Z==null?void 0:Z.taskSlug)??"no-task"}`:"",ue=!!(t&&Yt.current!==G);await ra({syncLaunchOptions:ue}),ue&&(Yt.current=G),ls()}catch(G){Ki("Poll project runtime state",G)}},{intervalMs:3e3,runImmediately:!0});const Jt=(Z==null?void 0:Z.taskSlug)??null,os=Jt&&(be==null?void 0:be.taskSlug)===Jt?be.state:null,It=Jt&&(ae==null?void 0:ae.taskSlug)===Jt?ae.roundState:null,ei=Jt&&(Un==null?void 0:Un.taskSlug)===Jt?Un:null,cs=!!(Jt&&(os!=null&&os.activeGate||(It==null?void 0:It.activeRole)==="reviewer"||ei!=null&&ei.hasReviewerSession));ol(cs&&Jt?`gate-review:${Jt}`:null,async()=>{if(Jt)try{await na(Jt)}catch(G){Ki("Poll Gate Review state",G)}},{intervalMs:3e3,runImmediately:!1});async function Ae(G,ue="Run UI action"){oi(!0),fn("");try{await G()}catch(Xe){fn(ft(ue,Xe))}finally{oi(!1)}}async function Xo(){var on;if(!Z)throw new Error("Create or select a task before closing it.");const G=[`Close task "${Z.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: ${Z.worktreePath}`,`- deletes the Git branch: ${Z.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(Z.taskSlug);I(null),me(null),Q(null),he(null),Ce(null),Le(null),Zr(wi=>wi+1),await Xt(),(on=Xe.warnings)!=null&&on.length&&window.alert([`Task "${Xe.taskSlug}" closed with cleanup warnings:`,"",...Xe.warnings.map(wi=>`- ${wi}`)].join(`
|
|
97
|
-
`))}const sa=ie&&ie.taskSlug===(Z==null?void 0:Z.taskSlug)?ie.messages:[],aa=_e&&_e.taskSlug===(Z==null?void 0:Z.taskSlug)?_e.orchestration:null,Dr=$&&$.taskSlug===(Z==null?void 0:Z.taskSlug)?$.events:[],ln=ae&&ae.taskSlug===(Z==null?void 0:Z.taskSlug)?ae.roundState:null,us=Z!=null&&Z.taskSlug&&(ln!=null&&ln.roleRecovery)?q2(Z.taskSlug,ln.roleRecovery):null,Sl=ln!=null&&ln.roleRecovery&&ln.roleRecovery.status!=="failed"&&us!==xr?$2(ln.roleRecovery):null,la=be&&be.taskSlug===(Z==null?void 0:Z.taskSlug)?be.state:null,Qo=!!(la&&Object.values(la.gates).some(G=>G.required));return w.jsxs(pS,{sidebar:w.jsx(l2,{project:t,recentRepositoryPaths:s,tasks:j,activeTaskSlug:(Z==null?void 0:Z.taskSlug)??null,messages:sa,orchestration:aa,events:Dr,roundState:ln,gateReview:la,translationEnabled:ns,translationAutoSendEnabled:je,translationTargetLanguage:qe,translationOutputMode:xt,translationMemoryInitialized:rt,translatorSession:si,harnessStatus:kr,harnessBootstrapStatus:Js,harnessApplyResult:S,harnessEngineerLaunchOptions:{permissionMode:li,model:Kt,effort:ot},autoTaskHarnessReviewEnabled:it,autoMemoryEnabled:fe,gatewayStatus:k,gatewayQrLogin:A,gatewayQrCheck:O,gatewayLarkRegistration:W,gatewayLarkRegistrationCheck:V,codexBridgeStatus:R,modelOptions:Zn,busy:Vi,onConnect:G=>Ae(async()=>{const ue=await ye.connectProject({repoPath:G});r(ue),C(null),await Promise.all([Xt(),Wi()])},"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(!Z)throw new Error("Create or select a task before refreshing VCM Harness.");C(null),await Promise.all([Ar(Z.taskSlug),Tr(Z.taskSlug)])},"Refresh VCM Harness"),onApplyHarness:()=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before applying VCM Harness.");const G=await ye.applyHarness({taskSlug:Z.taskSlug});C(G),await Promise.all([Ar(Z.taskSlug),Tr(Z.taskSlug)])},"Apply VCM Harness"),onStartHarnessBootstrap:G=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before starting Harness Bootstrap.");const ue=await ye.startHarnessBootstrap({taskSlug:Z.taskSlug,cols:120,rows:32,...G});o(ue.status),h(Z.taskSlug),await an({syncLaunchOptions:!0})},"Start Harness Bootstrap"),onRestartHarnessBootstrap:G=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before restarting Harness Bootstrap.");const ue=await ye.restartHarnessBootstrap({taskSlug:Z.taskSlug,cols:120,rows:32,...G});o(ue.status),h(Z.taskSlug),await an({syncLaunchOptions:!0})},"Restart Harness Bootstrap"),onStopHarnessBootstrap:()=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before stopping Harness Bootstrap.");const G=await ye.stopHarnessBootstrap({taskSlug:Z.taskSlug});o(G),h((Z==null?void 0:Z.taskSlug)??null),await an()},"Stop Harness Bootstrap"),onRunHarnessBootstrap:()=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before running Harness Bootstrap.");const G=await ye.runHarnessBootstrap({taskSlug:Z.taskSlug});o(G.status),h(Z.taskSlug),await an()},"Run Harness Bootstrap"),onOpenHarnessStudio:()=>zn(!0),onOpenRepositoryDiff:()=>Jn(!0),onAutoTaskHarnessReviewChange:G=>{wt(G),Ae(async()=>{const ue=await ye.updateAppPreferences({autoTaskHarnessReviewEnabled:G});Ft(ue)},"Update auto task harness review setting")},onAutoMemoryChange:G=>{we(G),Ae(async()=>{const ue=await ye.updateAppPreferences({autoMemoryEnabled:G});Ft(ue),await ra()},"Update auto memory setting")},onHarnessEngineerLaunchOptionsChange:G=>{hn(G.permissionMode),gt(G.model),Ht(G.effort)},onRefreshGateway:()=>Ae(async()=>{await En()},"Refresh Gateway status"),onGatewayEnabledChange:G=>{Ae(async()=>{const ue=await ye.updateGatewaySettings({enabled:G,...G&&t?{currentProjectId:t.repoRoot,currentTaskSlug:(Z==null?void 0:Z.taskSlug)??null}:{}});L(ue),G&&Ft(await ye.getAppPreferences())},"Update Gateway enabled setting")},onGatewaySettingsChange:G=>Ae(async()=>{const ue=await ye.updateGatewaySettings(G);L(ue)},"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 ue=await ye.updateGatewaySettings({translationEnabled:G});L(ue)},"Update Gateway translation setting")},onGatewayConnectionChange:G=>{Ae(async()=>{const ue=await ye.setGatewayConnection(G);L(ue)},"Update Gateway connection setting")},onStartGatewayQrLogin:()=>{Ae(async()=>{const G=await ye.startGatewayQrLogin();M(G),H(null),P(!0),await En()},"Start Gateway QR login")},onStartGatewayLarkRegistration:()=>{Ae(async()=>{const G=await ye.startGatewayLarkRegistration();K(G),Y(null),z(!0),await En()},"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,ue)=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before changing Gate Review Gates.");const Xe=await ye.updateGateReviewSettings(Z.taskSlug,{gates:{[G]:ue}});Le({taskSlug:Z.taskSlug,state:Xe})},`Update ${G} Gate Review setting`)},onCancelGateReviewGate:(G,ue)=>{window.confirm(`Cancel the running ${G} Gate Review request ${ue}?`)&&Ae(async()=>{if(!Z)throw new Error("Create or select a task before cancelling Gate Review.");const Xe=await ye.cancelGateReviewGate(Z.taskSlug,G,{requestId:ue,reason:"Cancelled by the user from VCM."});Le({taskSlug:Z.taskSlug,state:Xe})},`Cancel ${G} Gate Review`)},onTranslationEnabledChange:G=>{Be(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationEnabled:G});Ft(ue)},"Update conversation translation setting")},onTranslationAutoSendChange:G=>{bt(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationAutoSendEnabled:G});Ft(ue)},"Update translation auto-send setting")},onTranslationTargetLanguageChange:G=>{Et(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationTargetLanguage:G});Ft(ue)},"Update translation target language")},onTranslationOutputModeChange:G=>{Nt(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationOutputMode:G});Ft(ue)},"Update translation output mode")},onOpenFileTranslation:()=>Cr(!0),onOpenTranslatorSession:()=>gi(!0),onCreateTranslationBootstrap:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before running Translation Bootstrap.");await ye.createTranslationBootstrap({taskSlug:Z.taskSlug,targetLanguage:qe}),await ta(),await ss()},"Create Translation Bootstrap task")},onUpdateTranslationMemory:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before updating translation memory.");await ye.createTranslationMemoryUpdate({taskSlug:Z.taskSlug,targetLanguage:qe}),await ta(),await ss()},"Create translation memory update task")},onCreateTask:G=>Ae(async()=>{const ue=await ye.createTask(G);await Xt(),I(ue.taskSlug)},"Create task"),onCloseTask:()=>{Ae(Xo,"Close task")},onSelectTask:I,themeMode:Ee,onAutoOrchestrationChange:G=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before changing auto orchestration.");const ue=await ye.updateOrchestrationState(Z.taskSlug,{mode:G?"auto":"manual"});Q({taskSlug:Z.taskSlug,orchestration:ue})},"Update auto orchestration mode")},onThemeModeChange:G=>{ce(G),Ae(async()=>{const ue=await ye.updateAppPreferences({themeMode:G});Ft(ue)},"Update theme setting")},pauseAlertSound:ze,onPauseAlertSoundChange:G=>{St(G),G&&s_(),Ae(async()=>{const ue=await ye.updateAppPreferences({flowPauseAlerts:G});Ft(ue)},"Update pause alert sound setting")},roleRetryEnabled:mt,onRoleRetryEnabledChange:G=>{de(G),Ae(async()=>{const ue=await ye.updateAppPreferences({roleRetryEnabled:G});Ft(ue)},"Update CC retry setting")},permissionRequestMode:Ne,onPermissionRequestModeChange:G=>{Ue(G),Ae(async()=>{const ue=await ye.updateAppPreferences({permissionRequestMode:G});Ft(ue)},"Update permission request setting")},launchTemplate:$i,canSaveLaunchTemplate:_l,canOneClickStart:Zs,onSaveLaunchTemplate:()=>{Ae(async()=>{if(!(dn!=null&&dn.statusLoaded))throw new Error("Open a task workspace before saving a launch template.");const G=await ye.updateAppPreferences({launchTemplate:{version:1,roles:dn.roles,autoOrchestration:dn.autoOrchestration}});Ft(G)},"Save launch template")},onOneClickStart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before one-click start.");const G=await ye.oneClickStart(Z.taskSlug);Q({taskSlug:Z.taskSlug,orchestration:G.orchestration}),He("project-manager"),await Rr(Z.taskSlug),await Xt(),Zr(ue=>ue+1)},"One-click start role sessions")},onMarkAllMessagesDone:G=>{Ae(async()=>{const ue=await ye.markAllMessagesDone(G);me({taskSlug:G,messages:ue.messages}),await Rr(G)},"Mark all role messages done")},onDeleteMessageHistory:G=>{Ae(async()=>{const ue=await ye.deleteMessageHistory(G);me({taskSlug:G,messages:ue.messages}),await Rr(G)},"Delete role message history")}}),children:[w.jsx(jk,{}),xn?w.jsx("div",{className:"flow-pause-alert-backdrop",children:w.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:[w.jsx("p",{className:"flow-pause-alert-kicker",children:"VCM needs attention"}),w.jsx("h2",{id:"flow-pause-alert-title",children:"Flow needs attention"}),w.jsx("p",{id:"flow-pause-alert-body",children:xn.text}),w.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."}),w.jsx("button",{type:"button",autoFocus:!0,onClick:is,children:"Confirm"})]})}):null,Sl&&us?w.jsxs("div",{className:"role-recovery-toast",role:"status",children:[w.jsx("span",{children:Sl}),w.jsx("button",{type:"button",onClick:()=>Gi(us),children:"Close"})]}):null,U&&A?w.jsx(U2,{busy:Vi,qrCheck:O,qrLogin:A,onCheck:()=>{Ae(async()=>{const G=await ye.checkGatewayQrLogin();H(G),(G.status==="confirmed"||G.status==="binded_redirect")&&P(!1),await En()})},onClose:()=>P(!1)}):null,te&&W?w.jsx(P2,{busy:Vi,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 En())},"Check Lark Gateway QR setup")},onManualBind:(G,ue)=>{Ae(async()=>{const Xe=await ye.bindGatewayLarkApp({appId:G,appSecret:ue,larkDomain:"lark"});Y(Xe),Xe.gatewayStatus&&L(Xe.gatewayStatus),Xe.status==="confirmed"&&(z(!1),await En())},"Bind Lark Gateway app")},onClose:()=>z(!1)}):null,t&&Z?w.jsx(j2,{task:Z,activeRole:Fe,reviewerEnabled:Qo,translationEnabled:ns,translationAutoSendEnabled:je,translationTargetLanguage:qe,launchTemplate:$i,modelOptions:Zn,refreshNonce:wr,onTaskChanged:async()=>{await Xt()},onActiveRoleChange:He,onMessagesChanged:yl,onOrchestrationChanged:ea,onRoundStateChanged:Yo,onEventsChanged:Ko,onLaunchStateChanged:rs}):w.jsxs("section",{className:"empty-workspace",children:[w.jsx("h1",{children:t?"Create a task to open the workspace":"Connect a repository to begin"}),w.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."})]}),w.jsx(Ck,{open:rn,taskSlug:(Z==null?void 0:Z.taskSlug)??null,targetLanguage:qe,onClose:()=>Cr(!1)}),w.jsx(LS,{open:Pi,busy:Vi,status:kr,feedbackState:T,memoryState:ts,bootstrapStatus:Js,engineerSession:wn,permissionMode:li,model:Kt,modelOptions:Zn,effort:ot,taskSlug:(Z==null?void 0:Z.taskSlug)??null,onClose:()=>zn(!1),onRefresh:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before refreshing Harness Studio.");await Promise.all([Ar(Z.taskSlug),Tr(Z.taskSlug),an(),ia(Z.taskSlug),ye.getAutoMemoryState(Z.taskSlug).then(G=>{v(G),b(Z.taskSlug)})])},"Refresh Harness Studio")},onPermissionModeChange:hn,onModelChange:gt,onEffortChange:Ht,onEngineerStart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before starting Harness Engineer.");const G=await ye.startHarnessEngineerSession({taskSlug:Z.taskSlug,cols:120,rows:32,permissionMode:li,model:Kt,effort:ot});Pt(G),kn(G)},"Start Harness Engineer")},onEngineerResume:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before resuming Harness Engineer.");const G=await ye.resumeHarnessEngineerSession({taskSlug:Z.taskSlug,cols:120,rows:32,permissionMode:li,model:Kt,effort:ot});Pt(G),kn(G)},"Resume Harness Engineer")},onEngineerRestart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before restarting Harness Engineer.");const G=await ye.restartHarnessEngineerSession({taskSlug:Z.taskSlug,cols:120,rows:32,permissionMode:li,model:Kt,effort:ot});Pt(G),kn(G)},"Restart Harness Engineer")},onEngineerStop:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before stopping Harness Engineer.");const G=await ye.stopHarnessEngineerSession({taskSlug:Z.taskSlug});Pt(G)},"Stop Harness Engineer")},onEngineerNotifyHarnessUpdated:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before notifying Harness Engineer.");const G=await ye.notifyHarnessEngineerHarnessUpdated({taskSlug:Z.taskSlug});Pt(G),kn(G)},"Notify Harness Engineer to reload harness")},onSendFeedback:G=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before sending Harness Feedback.");const ue=await ye.sendHarnessFeedback({taskSlug:Z.taskSlug,feedbackPath:G});Pt(ue),kn(ue)},"Send Harness Feedback to Harness Engineer")},onOpenRepositoryDiff:()=>Jn(!0),onReviewTaskHarness:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before reviewing task harness.");const G=await ye.startTaskHarnessRetrospective({taskSlug:Z.taskSlug,trigger:"manual"});E(G),await an({syncLaunchOptions:!0})},"Review task harness")},onMemoryStateChange:G=>{v(G),b((Z==null?void 0:Z.taskSlug)??null)}}),w.jsx(US,{open:Fi,taskSlug:(Z==null?void 0:Z.taskSlug)??null,onClose:()=>Jn(!1)}),w.jsx(GS,{open:mi,busy:Vi,session:si,permissionMode:ai,model:qi,modelOptions:Zn,effort:vi,onClose:()=>gi(!1),onPermissionModeChange:In,onModelChange:_i,onEffortChange:yi,onStart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before starting Translator.");const G=await ye.startTranslatorSession({taskSlug:Z.taskSlug,cols:100,rows:28,permissionMode:ai,model:qi,effort:vi});sn(G),Qt(G)},"Start Translator session")},onResume:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before resuming Translator.");const G=await ye.resumeTranslatorSession({taskSlug:Z.taskSlug,cols:100,rows:28,permissionMode:ai,model:qi,effort:vi});sn(G),Qt(G)},"Resume Translator session")},onRestart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before restarting Translator.");const G=await ye.restartTranslatorSession({taskSlug:Z.taskSlug,cols:100,rows:28,permissionMode:ai,model:qi,effort:vi});sn(G),Qt(G)},"Restart Translator session")},onStop:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before stopping Translator.");const G=await ye.stopTranslatorSession({taskSlug:Z.taskSlug});sn(G)},"Stop Translator session")},onNotifyHarnessUpdated:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before notifying Translator.");const G=await ye.notifyTranslatorHarnessUpdated({taskSlug:Z.taskSlug});sn(G),Qt(G)},"Notify Translator to reload harness")}})]})}function U2({busy:t,onCheck:r,onClose:s,qrCheck:l,qrLogin:d}){const[m,f]=ee.useState(""),[o,c]=Ii("");return ee.useEffect(()=>{let u=!1;if(c(""),f(""),d.qrcodeUrl.startsWith("data:image/")){f(d.qrcodeUrl);return}try{const g=Qr(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]),w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{"aria-labelledby":"gateway-qr-title","aria-modal":"true",className:"gateway-qr-modal",role:"dialog",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{id:"gateway-qr-title",children:"Weixin Gateway Login"}),w.jsx("p",{className:"muted",children:"Scan with Weixin, confirm on the phone, then click Confirm."})]}),w.jsx("button",{type:"button",onClick:s,children:"Close"})]}),w.jsxs("div",{className:"gateway-qr-modal-body",children:[w.jsx("div",{className:"gateway-qr-code-frame",children:m?w.jsx("img",{alt:"Weixin Gateway QR login",src:m}):w.jsx("div",{className:"gateway-qr-placeholder",children:o?"QR code could not be rendered.":"Rendering QR code..."})}),w.jsxs("dl",{className:"gateway-qr-meta",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Status"}),w.jsx("dd",{children:(l==null?void 0:l.status)??d.status})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Expires"}),w.jsx("dd",{children:Uv(d.expiresAt)})]}),l!=null&&l.message?w.jsxs("div",{children:[w.jsx("dt",{children:"Message"}),w.jsx("dd",{children:l.message})]}):null]})]}),w.jsx("footer",{children:w.jsx("button",{type:"button",disabled:t,onClick:r,children:"Confirm"})})]})})}function P2({busy:t,onCheck:r,onClose:s,onManualBind:l,registration:d,registrationCheck:m}){const[f,o]=ee.useState(""),[c,u]=Ii(""),[g,h]=ee.useState(""),[S,C]=ee.useState(""),[T,E]=Ii("");return ee.useEffect(()=>{let y=!1;u(""),o("");try{const v=Qr(0,"M");v.addData(d.qrUrl),v.make(),y||o(v.createDataURL(8,2))}catch(v){y||u(ft("Render Lark Gateway setup QR code",v))}return()=>{y=!0}},[d.qrUrl]),w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{"aria-labelledby":"gateway-lark-registration-title","aria-modal":"true",className:"gateway-qr-modal",role:"dialog",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{id:"gateway-lark-registration-title",children:"Lark Gateway Setup"}),w.jsx("p",{className:"muted",children:"Scan with Lark, approve bot creation, then click Confirm."})]}),w.jsx("button",{type:"button",onClick:s,children:"Close"})]}),w.jsxs("div",{className:"gateway-qr-modal-body",children:[w.jsx("div",{className:"gateway-qr-code-frame",children:f?w.jsx("img",{alt:"Lark Gateway setup QR code",src:f}):w.jsx("div",{className:"gateway-qr-placeholder",children:c?"QR code could not be rendered.":"Rendering QR code..."})}),w.jsx("div",{className:"gateway-qr-actions",children:w.jsx("button",{type:"button",disabled:t,onClick:r,children:"Confirm"})}),w.jsxs("dl",{className:"gateway-qr-meta",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Status"}),w.jsx("dd",{children:(m==null?void 0:m.status)??d.status})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Expires"}),w.jsx("dd",{children:Uv(d.expiresAt)})]}),d.userCode?w.jsxs("div",{children:[w.jsx("dt",{children:"User Code"}),w.jsx("dd",{children:d.userCode})]}):null,m!=null&&m.larkBotName?w.jsxs("div",{children:[w.jsx("dt",{children:"Bot"}),w.jsx("dd",{children:m.larkBotName})]}):null,m!=null&&m.message?w.jsxs("div",{children:[w.jsx("dt",{children:"Message"}),w.jsx("dd",{children:m.message})]}):null]}),w.jsxs("form",{className:"gateway-manual-bind",onSubmit:y=>{y.preventDefault();const v=g.trim(),_=S.trim();if(!v||!_){E("Enter both App ID and App Secret.");return}E(""),C(""),l(v,_)},children:[w.jsxs("div",{children:[w.jsx("label",{htmlFor:"gateway-lark-app-id",children:"App ID"}),w.jsx("input",{id:"gateway-lark-app-id",autoComplete:"off",disabled:t,value:g,onChange:y=>h(y.currentTarget.value),placeholder:"cli_xxx"})]}),w.jsxs("div",{children:[w.jsx("label",{htmlFor:"gateway-lark-app-secret",children:"App Secret"}),w.jsx("input",{id:"gateway-lark-app-secret",autoComplete:"off",disabled:t,type:"password",value:S,onChange:y=>C(y.currentTarget.value),placeholder:"Enter App Secret"})]}),T?w.jsx("p",{className:"form-error",children:T}):null,w.jsx("button",{type:"submit",disabled:t,children:"Bind manually"})]})]})]})})}function Uv(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 Yr=null;function F2(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 q2(t,r){return`${t}:${r.role}:${r.lastFailureAt}`}function $2(t){const r=W2(t.role),s=Pv(t);return t.status==="retrying"?`CC 出错,正在重试 ${r}${s} · 第 ${t.attempt}/${t.maxAttempts} 次`:`CC 出错,重试中 ${r}${s} · 第 ${t.attempt}/${t.maxAttempts} 次 · ${K2(t.nextRetryAt)}`}function G2(t,r){const s=Pv(t);return t.retryable===!1?`CC stopped for ${r}: ${V2(t)} cannot be fixed by retrying.`:`CC retry failed after ${t.maxAttempts} attempts for ${r}${s}.`}function Pv(t){return!t.error||t.error==="unknown"?"":` · ${t.error}`}function V2(t){return t.error&&t.error!=="unknown"?t.error:"this error"}function W2(t){return t.split("-").filter(Boolean).map(r=>`${r.slice(0,1).toUpperCase()}${r.slice(1)}`).join(" ")}function K2(t){if(!t)return"即将重试";const r=Date.parse(t)-Date.now();return!Number.isFinite(r)||r<=0?"即将重试":`${Math.ceil(r/6e4)} 分钟后`}async function s_(){const t=Fv();return t?qv(t):!1}async function a_(){const t=Fv();if(!t||!await qv(t))return!1;try{const s=t.createGain(),l=t.currentTime+.025;return s.gain.setValueAtTime(.85,t.currentTime),s.connect(t.destination),c_(t,s,{frequency:587.33,startAt:l,duration:.18,peakGain:.045}),c_(t,s,{frequency:783.99,startAt:l+.11,duration:.28,peakGain:.055}),window.setTimeout(()=>{s.disconnect()},800),!0}catch{return!1}}function Fv(){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;try{return(!Yr||Yr.state==="closed")&&(Yr=new t),Yr}catch{return null}}function l_(t){Yr=null,t&&t.state!=="closed"&&t.close().catch(()=>{})}async function qv(t){if(o_(t))return!0;try{await t.resume();const r=o_(t);return!r&&t===Yr&&l_(t),r}catch{return t===Yr&&l_(t),!1}}function o_(t){return t.state==="running"}function c_(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 $v=document.getElementById("root");if(!$v)throw new Error("Missing #root element.");Y0.createRoot($v).render(w.jsx(ee.StrictMode,{children:w.jsx(I2,{})}));
|
|
97
|
+
`))}const sa=ie&&ie.taskSlug===(Z==null?void 0:Z.taskSlug)?ie.messages:[],aa=_e&&_e.taskSlug===(Z==null?void 0:Z.taskSlug)?_e.orchestration:null,Dr=$&&$.taskSlug===(Z==null?void 0:Z.taskSlug)?$.events:[],ln=ae&&ae.taskSlug===(Z==null?void 0:Z.taskSlug)?ae.roundState:null,us=Z!=null&&Z.taskSlug&&(ln!=null&&ln.roleRecovery)?q2(Z.taskSlug,ln.roleRecovery):null,Sl=ln!=null&&ln.roleRecovery&&ln.roleRecovery.status!=="failed"&&us!==xr?$2(ln.roleRecovery):null,la=be&&be.taskSlug===(Z==null?void 0:Z.taskSlug)?be.state:null,Qo=!!(la&&Object.values(la.gates).some(G=>G.required));return w.jsxs(pS,{sidebar:w.jsx(o2,{project:t,recentRepositoryPaths:s,tasks:j,activeTaskSlug:(Z==null?void 0:Z.taskSlug)??null,messages:sa,orchestration:aa,events:Dr,roundState:ln,gateReview:la,translationEnabled:ns,translationAutoSendEnabled:je,translationTargetLanguage:qe,translationOutputMode:xt,translationMemoryInitialized:rt,translatorSession:si,harnessStatus:kr,harnessBootstrapStatus:Js,harnessApplyResult:S,harnessEngineerLaunchOptions:{permissionMode:li,model:Kt,effort:ot},autoTaskHarnessReviewEnabled:it,autoMemoryEnabled:fe,gatewayStatus:k,gatewayQrLogin:A,gatewayQrCheck:O,gatewayLarkRegistration:W,gatewayLarkRegistrationCheck:V,codexBridgeStatus:R,modelOptions:Zn,busy:Vi,onConnect:G=>Ae(async()=>{const ue=await ye.connectProject({repoPath:G});r(ue),C(null),await Promise.all([Xt(),Wi()])},"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(!Z)throw new Error("Create or select a task before refreshing VCM Harness.");C(null),await Promise.all([Ar(Z.taskSlug),Tr(Z.taskSlug)])},"Refresh VCM Harness"),onApplyHarness:()=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before applying VCM Harness.");const G=await ye.applyHarness({taskSlug:Z.taskSlug});C(G),await Promise.all([Ar(Z.taskSlug),Tr(Z.taskSlug)])},"Apply VCM Harness"),onStartHarnessBootstrap:G=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before starting Harness Bootstrap.");const ue=await ye.startHarnessBootstrap({taskSlug:Z.taskSlug,cols:120,rows:32,...G});o(ue.status),h(Z.taskSlug),await an({syncLaunchOptions:!0})},"Start Harness Bootstrap"),onRestartHarnessBootstrap:G=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before restarting Harness Bootstrap.");const ue=await ye.restartHarnessBootstrap({taskSlug:Z.taskSlug,cols:120,rows:32,...G});o(ue.status),h(Z.taskSlug),await an({syncLaunchOptions:!0})},"Restart Harness Bootstrap"),onStopHarnessBootstrap:()=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before stopping Harness Bootstrap.");const G=await ye.stopHarnessBootstrap({taskSlug:Z.taskSlug});o(G),h((Z==null?void 0:Z.taskSlug)??null),await an()},"Stop Harness Bootstrap"),onRunHarnessBootstrap:()=>Ae(async()=>{if(!Z)throw new Error("Create or select a task before running Harness Bootstrap.");const G=await ye.runHarnessBootstrap({taskSlug:Z.taskSlug});o(G.status),h(Z.taskSlug),await an()},"Run Harness Bootstrap"),onOpenHarnessStudio:()=>zn(!0),onOpenRepositoryDiff:()=>Jn(!0),onAutoTaskHarnessReviewChange:G=>{wt(G),Ae(async()=>{const ue=await ye.updateAppPreferences({autoTaskHarnessReviewEnabled:G});Ft(ue)},"Update auto task harness review setting")},onAutoMemoryChange:G=>{we(G),Ae(async()=>{const ue=await ye.updateAppPreferences({autoMemoryEnabled:G});Ft(ue),await ra()},"Update auto memory setting")},onHarnessEngineerLaunchOptionsChange:G=>{hn(G.permissionMode),gt(G.model),Ht(G.effort)},onRefreshGateway:()=>Ae(async()=>{await En()},"Refresh Gateway status"),onGatewayEnabledChange:G=>{Ae(async()=>{const ue=await ye.updateGatewaySettings({enabled:G,...G&&t?{currentProjectId:t.repoRoot,currentTaskSlug:(Z==null?void 0:Z.taskSlug)??null}:{}});L(ue),G&&Ft(await ye.getAppPreferences())},"Update Gateway enabled setting")},onGatewaySettingsChange:G=>Ae(async()=>{const ue=await ye.updateGatewaySettings(G);L(ue)},"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 ue=await ye.updateGatewaySettings({translationEnabled:G});L(ue)},"Update Gateway translation setting")},onGatewayConnectionChange:G=>{Ae(async()=>{const ue=await ye.setGatewayConnection(G);L(ue)},"Update Gateway connection setting")},onStartGatewayQrLogin:()=>{Ae(async()=>{const G=await ye.startGatewayQrLogin();M(G),H(null),P(!0),await En()},"Start Gateway QR login")},onStartGatewayLarkRegistration:()=>{Ae(async()=>{const G=await ye.startGatewayLarkRegistration();K(G),Y(null),z(!0),await En()},"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,ue)=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before changing Gate Review Gates.");const Xe=await ye.updateGateReviewSettings(Z.taskSlug,{gates:{[G]:ue}});Le({taskSlug:Z.taskSlug,state:Xe})},`Update ${G} Gate Review setting`)},onCancelGateReviewGate:(G,ue)=>{window.confirm(`Cancel the running ${G} Gate Review request ${ue}?`)&&Ae(async()=>{if(!Z)throw new Error("Create or select a task before cancelling Gate Review.");const Xe=await ye.cancelGateReviewGate(Z.taskSlug,G,{requestId:ue,reason:"Cancelled by the user from VCM."});Le({taskSlug:Z.taskSlug,state:Xe})},`Cancel ${G} Gate Review`)},onTranslationEnabledChange:G=>{Be(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationEnabled:G});Ft(ue)},"Update conversation translation setting")},onTranslationAutoSendChange:G=>{bt(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationAutoSendEnabled:G});Ft(ue)},"Update translation auto-send setting")},onTranslationTargetLanguageChange:G=>{Et(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationTargetLanguage:G});Ft(ue)},"Update translation target language")},onTranslationOutputModeChange:G=>{Nt(G),Ae(async()=>{const ue=await ye.updateAppPreferences({translationOutputMode:G});Ft(ue)},"Update translation output mode")},onOpenFileTranslation:()=>Cr(!0),onOpenTranslatorSession:()=>gi(!0),onCreateTranslationBootstrap:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before running Translation Bootstrap.");await ye.createTranslationBootstrap({taskSlug:Z.taskSlug,targetLanguage:qe}),await ta(),await ss()},"Create Translation Bootstrap task")},onUpdateTranslationMemory:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before updating translation memory.");await ye.createTranslationMemoryUpdate({taskSlug:Z.taskSlug,targetLanguage:qe}),await ta(),await ss()},"Create translation memory update task")},onCreateTask:G=>Ae(async()=>{const ue=await ye.createTask(G);await Xt(),I(ue.taskSlug)},"Create task"),onCloseTask:()=>{Ae(Xo,"Close task")},onSelectTask:I,themeMode:Ee,onAutoOrchestrationChange:G=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before changing auto orchestration.");const ue=await ye.updateOrchestrationState(Z.taskSlug,{mode:G?"auto":"manual"});Q({taskSlug:Z.taskSlug,orchestration:ue})},"Update auto orchestration mode")},onThemeModeChange:G=>{ce(G),Ae(async()=>{const ue=await ye.updateAppPreferences({themeMode:G});Ft(ue)},"Update theme setting")},pauseAlertSound:ze,onPauseAlertSoundChange:G=>{St(G),G&&s_(),Ae(async()=>{const ue=await ye.updateAppPreferences({flowPauseAlerts:G});Ft(ue)},"Update pause alert sound setting")},roleRetryEnabled:mt,onRoleRetryEnabledChange:G=>{de(G),Ae(async()=>{const ue=await ye.updateAppPreferences({roleRetryEnabled:G});Ft(ue)},"Update CC retry setting")},permissionRequestMode:Ne,onPermissionRequestModeChange:G=>{Ue(G),Ae(async()=>{const ue=await ye.updateAppPreferences({permissionRequestMode:G});Ft(ue)},"Update permission request setting")},launchTemplate:$i,canSaveLaunchTemplate:_l,canOneClickStart:Zs,onSaveLaunchTemplate:()=>{Ae(async()=>{if(!(dn!=null&&dn.statusLoaded))throw new Error("Open a task workspace before saving a launch template.");const G=await ye.updateAppPreferences({launchTemplate:{version:1,roles:dn.roles,autoOrchestration:dn.autoOrchestration}});Ft(G)},"Save launch template")},onOneClickStart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before one-click start.");const G=await ye.oneClickStart(Z.taskSlug);Q({taskSlug:Z.taskSlug,orchestration:G.orchestration}),He("project-manager"),await Rr(Z.taskSlug),await Xt(),Zr(ue=>ue+1)},"One-click start role sessions")},onMarkAllMessagesDone:G=>{Ae(async()=>{const ue=await ye.markAllMessagesDone(G);me({taskSlug:G,messages:ue.messages}),await Rr(G)},"Mark all role messages done")},onDeleteMessageHistory:G=>{Ae(async()=>{const ue=await ye.deleteMessageHistory(G);me({taskSlug:G,messages:ue.messages}),await Rr(G)},"Delete role message history")}}),children:[w.jsx(jk,{}),xn?w.jsx("div",{className:"flow-pause-alert-backdrop",children:w.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:[w.jsx("p",{className:"flow-pause-alert-kicker",children:"VCM needs attention"}),w.jsx("h2",{id:"flow-pause-alert-title",children:"Flow needs attention"}),w.jsx("p",{id:"flow-pause-alert-body",children:xn.text}),w.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."}),w.jsx("button",{type:"button",autoFocus:!0,onClick:is,children:"Confirm"})]})}):null,Sl&&us?w.jsxs("div",{className:"role-recovery-toast",role:"status",children:[w.jsx("span",{children:Sl}),w.jsx("button",{type:"button",onClick:()=>Gi(us),children:"Close"})]}):null,U&&A?w.jsx(P2,{busy:Vi,qrCheck:O,qrLogin:A,onCheck:()=>{Ae(async()=>{const G=await ye.checkGatewayQrLogin();H(G),(G.status==="confirmed"||G.status==="binded_redirect")&&P(!1),await En()})},onClose:()=>P(!1)}):null,te&&W?w.jsx(F2,{busy:Vi,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 En())},"Check Lark Gateway QR setup")},onManualBind:(G,ue)=>{Ae(async()=>{const Xe=await ye.bindGatewayLarkApp({appId:G,appSecret:ue,larkDomain:"lark"});Y(Xe),Xe.gatewayStatus&&L(Xe.gatewayStatus),Xe.status==="confirmed"&&(z(!1),await En())},"Bind Lark Gateway app")},onClose:()=>z(!1)}):null,t&&Z?w.jsx(N2,{task:Z,activeRole:Fe,reviewerEnabled:Qo,translationEnabled:ns,translationAutoSendEnabled:je,translationTargetLanguage:qe,launchTemplate:$i,modelOptions:Zn,refreshNonce:wr,onTaskChanged:async()=>{await Xt()},onActiveRoleChange:He,onMessagesChanged:yl,onOrchestrationChanged:ea,onRoundStateChanged:Yo,onEventsChanged:Ko,onLaunchStateChanged:rs}):w.jsxs("section",{className:"empty-workspace",children:[w.jsx("h1",{children:t?"Create a task to open the workspace":"Connect a repository to begin"}),w.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."})]}),w.jsx(Ck,{open:rn,taskSlug:(Z==null?void 0:Z.taskSlug)??null,targetLanguage:qe,onClose:()=>Cr(!1)}),w.jsx(LS,{open:Pi,busy:Vi,status:kr,feedbackState:T,memoryState:ts,bootstrapStatus:Js,engineerSession:wn,permissionMode:li,model:Kt,modelOptions:Zn,effort:ot,taskSlug:(Z==null?void 0:Z.taskSlug)??null,onClose:()=>zn(!1),onRefresh:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before refreshing Harness Studio.");await Promise.all([Ar(Z.taskSlug),Tr(Z.taskSlug),an(),ia(Z.taskSlug),ye.getAutoMemoryState(Z.taskSlug).then(G=>{v(G),b(Z.taskSlug)})])},"Refresh Harness Studio")},onPermissionModeChange:hn,onModelChange:gt,onEffortChange:Ht,onEngineerStart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before starting Harness Engineer.");const G=await ye.startHarnessEngineerSession({taskSlug:Z.taskSlug,cols:120,rows:32,permissionMode:li,model:Kt,effort:ot});Pt(G),kn(G)},"Start Harness Engineer")},onEngineerResume:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before resuming Harness Engineer.");const G=await ye.resumeHarnessEngineerSession({taskSlug:Z.taskSlug,cols:120,rows:32,permissionMode:li,model:Kt,effort:ot});Pt(G),kn(G)},"Resume Harness Engineer")},onEngineerRestart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before restarting Harness Engineer.");const G=await ye.restartHarnessEngineerSession({taskSlug:Z.taskSlug,cols:120,rows:32,permissionMode:li,model:Kt,effort:ot});Pt(G),kn(G)},"Restart Harness Engineer")},onEngineerStop:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before stopping Harness Engineer.");const G=await ye.stopHarnessEngineerSession({taskSlug:Z.taskSlug});Pt(G)},"Stop Harness Engineer")},onEngineerNotifyHarnessUpdated:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before notifying Harness Engineer.");const G=await ye.notifyHarnessEngineerHarnessUpdated({taskSlug:Z.taskSlug});Pt(G),kn(G)},"Notify Harness Engineer to reload harness")},onSendFeedback:G=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before sending Harness Feedback.");const ue=await ye.sendHarnessFeedback({taskSlug:Z.taskSlug,feedbackPath:G});Pt(ue),kn(ue)},"Send Harness Feedback to Harness Engineer")},onOpenRepositoryDiff:()=>Jn(!0),onReviewTaskHarness:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before reviewing task harness.");const G=await ye.startTaskHarnessRetrospective({taskSlug:Z.taskSlug,trigger:"manual"});E(G),await an({syncLaunchOptions:!0})},"Review task harness")},onMemoryStateChange:G=>{v(G),b((Z==null?void 0:Z.taskSlug)??null)}}),w.jsx(US,{open:Fi,taskSlug:(Z==null?void 0:Z.taskSlug)??null,onClose:()=>Jn(!1)}),w.jsx(GS,{open:mi,busy:Vi,session:si,permissionMode:ai,model:qi,modelOptions:Zn,effort:vi,onClose:()=>gi(!1),onPermissionModeChange:In,onModelChange:_i,onEffortChange:yi,onStart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before starting Translator.");const G=await ye.startTranslatorSession({taskSlug:Z.taskSlug,cols:100,rows:28,permissionMode:ai,model:qi,effort:vi});sn(G),Qt(G)},"Start Translator session")},onResume:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before resuming Translator.");const G=await ye.resumeTranslatorSession({taskSlug:Z.taskSlug,cols:100,rows:28,permissionMode:ai,model:qi,effort:vi});sn(G),Qt(G)},"Resume Translator session")},onRestart:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before restarting Translator.");const G=await ye.restartTranslatorSession({taskSlug:Z.taskSlug,cols:100,rows:28,permissionMode:ai,model:qi,effort:vi});sn(G),Qt(G)},"Restart Translator session")},onStop:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before stopping Translator.");const G=await ye.stopTranslatorSession({taskSlug:Z.taskSlug});sn(G)},"Stop Translator session")},onNotifyHarnessUpdated:()=>{Ae(async()=>{if(!Z)throw new Error("Create or select a task before notifying Translator.");const G=await ye.notifyTranslatorHarnessUpdated({taskSlug:Z.taskSlug});sn(G),Qt(G)},"Notify Translator to reload harness")}})]})}function P2({busy:t,onCheck:r,onClose:s,qrCheck:l,qrLogin:d}){const[m,f]=ee.useState(""),[o,c]=Ii("");return ee.useEffect(()=>{let u=!1;if(c(""),f(""),d.qrcodeUrl.startsWith("data:image/")){f(d.qrcodeUrl);return}try{const g=Qr(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]),w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{"aria-labelledby":"gateway-qr-title","aria-modal":"true",className:"gateway-qr-modal",role:"dialog",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{id:"gateway-qr-title",children:"Weixin Gateway Login"}),w.jsx("p",{className:"muted",children:"Scan with Weixin, confirm on the phone, then click Confirm."})]}),w.jsx("button",{type:"button",onClick:s,children:"Close"})]}),w.jsxs("div",{className:"gateway-qr-modal-body",children:[w.jsx("div",{className:"gateway-qr-code-frame",children:m?w.jsx("img",{alt:"Weixin Gateway QR login",src:m}):w.jsx("div",{className:"gateway-qr-placeholder",children:o?"QR code could not be rendered.":"Rendering QR code..."})}),w.jsxs("dl",{className:"gateway-qr-meta",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Status"}),w.jsx("dd",{children:(l==null?void 0:l.status)??d.status})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Expires"}),w.jsx("dd",{children:Uv(d.expiresAt)})]}),l!=null&&l.message?w.jsxs("div",{children:[w.jsx("dt",{children:"Message"}),w.jsx("dd",{children:l.message})]}):null]})]}),w.jsx("footer",{children:w.jsx("button",{type:"button",disabled:t,onClick:r,children:"Confirm"})})]})})}function F2({busy:t,onCheck:r,onClose:s,onManualBind:l,registration:d,registrationCheck:m}){const[f,o]=ee.useState(""),[c,u]=Ii(""),[g,h]=ee.useState(""),[S,C]=ee.useState(""),[T,E]=Ii("");return ee.useEffect(()=>{let y=!1;u(""),o("");try{const v=Qr(0,"M");v.addData(d.qrUrl),v.make(),y||o(v.createDataURL(8,2))}catch(v){y||u(ft("Render Lark Gateway setup QR code",v))}return()=>{y=!0}},[d.qrUrl]),w.jsx("div",{className:"modal-backdrop",children:w.jsxs("section",{"aria-labelledby":"gateway-lark-registration-title","aria-modal":"true",className:"gateway-qr-modal",role:"dialog",children:[w.jsxs("header",{children:[w.jsxs("div",{children:[w.jsx("h2",{id:"gateway-lark-registration-title",children:"Lark Gateway Setup"}),w.jsx("p",{className:"muted",children:"Scan with Lark, approve bot creation, then click Confirm."})]}),w.jsx("button",{type:"button",onClick:s,children:"Close"})]}),w.jsxs("div",{className:"gateway-qr-modal-body",children:[w.jsx("div",{className:"gateway-qr-code-frame",children:f?w.jsx("img",{alt:"Lark Gateway setup QR code",src:f}):w.jsx("div",{className:"gateway-qr-placeholder",children:c?"QR code could not be rendered.":"Rendering QR code..."})}),w.jsx("div",{className:"gateway-qr-actions",children:w.jsx("button",{type:"button",disabled:t,onClick:r,children:"Confirm"})}),w.jsxs("dl",{className:"gateway-qr-meta",children:[w.jsxs("div",{children:[w.jsx("dt",{children:"Status"}),w.jsx("dd",{children:(m==null?void 0:m.status)??d.status})]}),w.jsxs("div",{children:[w.jsx("dt",{children:"Expires"}),w.jsx("dd",{children:Uv(d.expiresAt)})]}),d.userCode?w.jsxs("div",{children:[w.jsx("dt",{children:"User Code"}),w.jsx("dd",{children:d.userCode})]}):null,m!=null&&m.larkBotName?w.jsxs("div",{children:[w.jsx("dt",{children:"Bot"}),w.jsx("dd",{children:m.larkBotName})]}):null,m!=null&&m.message?w.jsxs("div",{children:[w.jsx("dt",{children:"Message"}),w.jsx("dd",{children:m.message})]}):null]}),w.jsxs("form",{className:"gateway-manual-bind",onSubmit:y=>{y.preventDefault();const v=g.trim(),_=S.trim();if(!v||!_){E("Enter both App ID and App Secret.");return}E(""),C(""),l(v,_)},children:[w.jsxs("div",{children:[w.jsx("label",{htmlFor:"gateway-lark-app-id",children:"App ID"}),w.jsx("input",{id:"gateway-lark-app-id",autoComplete:"off",disabled:t,value:g,onChange:y=>h(y.currentTarget.value),placeholder:"cli_xxx"})]}),w.jsxs("div",{children:[w.jsx("label",{htmlFor:"gateway-lark-app-secret",children:"App Secret"}),w.jsx("input",{id:"gateway-lark-app-secret",autoComplete:"off",disabled:t,type:"password",value:S,onChange:y=>C(y.currentTarget.value),placeholder:"Enter App Secret"})]}),T?w.jsx("p",{className:"form-error",children:T}):null,w.jsx("button",{type:"submit",disabled:t,children:"Bind manually"})]})]})]})})}function Uv(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 Yr=null;function q2(t,r){return`${t}:${r.role}:${r.lastFailureAt}`}function $2(t){const r=W2(t.role),s=Pv(t);return t.status==="retrying"?`CC 出错,正在重试 ${r}${s} · 第 ${t.attempt}/${t.maxAttempts} 次`:`CC 出错,重试中 ${r}${s} · 第 ${t.attempt}/${t.maxAttempts} 次 · ${K2(t.nextRetryAt)}`}function G2(t,r){const s=Pv(t);return t.retryable===!1?`CC stopped for ${r}: ${V2(t)} cannot be fixed by retrying.`:`CC retry failed after ${t.maxAttempts} attempts for ${r}${s}.`}function Pv(t){return!t.error||t.error==="unknown"?"":` · ${t.error}`}function V2(t){return t.error&&t.error!=="unknown"?t.error:"this error"}function W2(t){return t.split("-").filter(Boolean).map(r=>`${r.slice(0,1).toUpperCase()}${r.slice(1)}`).join(" ")}function K2(t){if(!t)return"即将重试";const r=Date.parse(t)-Date.now();return!Number.isFinite(r)||r<=0?"即将重试":`${Math.ceil(r/6e4)} 分钟后`}async function s_(){const t=Fv();return t?qv(t):!1}async function a_(){const t=Fv();if(!t||!await qv(t))return!1;try{const s=t.createGain(),l=t.currentTime+.025;return s.gain.setValueAtTime(.85,t.currentTime),s.connect(t.destination),c_(t,s,{frequency:587.33,startAt:l,duration:.18,peakGain:.045}),c_(t,s,{frequency:783.99,startAt:l+.11,duration:.28,peakGain:.055}),window.setTimeout(()=>{s.disconnect()},800),!0}catch{return!1}}function Fv(){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;try{return(!Yr||Yr.state==="closed")&&(Yr=new t),Yr}catch{return null}}function l_(t){Yr=null,t&&t.state!=="closed"&&t.close().catch(()=>{})}async function qv(t){if(o_(t))return!0;try{await t.resume();const r=o_(t);return!r&&t===Yr&&l_(t),r}catch{return t===Yr&&l_(t),!1}}function o_(t){return t.state==="running"}function c_(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 $v=document.getElementById("root");if(!$v)throw new Error("Missing #root element.");Y0.createRoot($v).render(w.jsx(ee.StrictMode,{children:w.jsx(U2,{})}));
|