ccdeck 4.0.4 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/AccountBridge-C6OFH_Ju.js +1 -0
- package/dist/web/assets/{AccountSection-HmlI65gN.js → AccountSection-BMuTp9CV.js} +1 -1
- package/dist/web/assets/{BrowserWatchModal-DwY9hX-u.js → BrowserWatchModal-CxD5MH0G.js} +1 -1
- package/dist/web/assets/{FeedbackConversations-6S1QZR6S.js → FeedbackConversations-E11nU0s8.js} +1 -1
- package/dist/web/assets/{IntegrationModal-a8CAd22m.js → IntegrationModal-BGAiSkJt.js} +1 -1
- package/dist/web/assets/{IntegrationSkeleton-C2RiqqMA.js → IntegrationSkeleton-DAKXKuLF.js} +1 -1
- package/dist/web/assets/{RadioPanel-CyJsFSkf.js → RadioPanel-1NM6GOif.js} +1 -1
- package/dist/web/assets/StageShell-F-zWWpCp.js +12 -0
- package/dist/web/assets/{TrafficRadar-CEbp0Yi7.js → TrafficRadar-DHu0CnOc.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-i16x6suY.js → UsageHistoryModal-3rOC8oBZ.js} +1 -1
- package/dist/web/assets/{app-C0usT8Zy.js → app-CXxFM7fY.js} +61 -61
- package/dist/web/assets/{index-BQWffZlx.js → index-B0kLYrYF.js} +1 -1
- package/dist/web/assets/{inspector-status-pane-DD3QOXE6.js → inspector-status-pane-BvSOWD4r.js} +1 -1
- package/dist/web/assets/screens-B53mAUFb.js +16 -0
- package/dist/web/assets/screens-C6vVzMK-.css +1 -0
- package/dist/web/assets/stage-board-BmcdRHaG.js +2 -0
- package/dist/web/assets/{use-account-x7fuCA6S.js → use-account-DaZBTcqA.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/release-notes.json +38 -0
- package/src/server/codex-live-engine.mjs +15 -2
- package/src/server/codex-live-handoff.mjs +27 -0
- package/src/server/codex-translate.mjs +51 -9
- package/src/server/memory-metrics.mjs +19 -30
- package/src/server/session-transcript-routes.mjs +186 -35
- package/src/server/transcript-turns.mjs +641 -41
- package/src/server/tui-codex.mjs +3 -0
- package/dist/web/assets/AccountBridge-Cx7no9kK.js +0 -1
- package/dist/web/assets/StageShell-DXcdcjPI.js +0 -4
- package/dist/web/assets/screens-DAn5OlXe.js +0 -12
- package/dist/web/assets/screens-DUniTTbC.css +0 -1
- package/dist/web/assets/stage-board-kUkV8N-4.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./app-
|
|
1
|
+
import"./app-CXxFM7fY.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(e){if(e.ep)return;e.ep=!0;const r=s(e);fetch(e.href,r)}})();
|
package/dist/web/assets/{inspector-status-pane-DD3QOXE6.js → inspector-status-pane-BvSOWD4r.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as l,M as p}from"./stage-board-
|
|
1
|
+
import{K as l,M as p}from"./stage-board-BmcdRHaG.js";import{bM as g,aB as u}from"./app-CXxFM7fY.js";function h(a,o,e){const t=g(o,a.sessionId)??a,i=[...o.values()].filter(n=>n.sessionId===t.sessionId&&n.kind==="subagent"),s=l(p(t,i),e),d=[s.phrase,s.emphasis].filter(Boolean).join(" ")+(s.arg?` · ${s.arg}`:""),r=u(t);return{glyph:r==="partial"?"partial":r==="err"?"error":s.state==="working"?"working":s.state==="waiting"?"waiting":s.state==="ready"?"idle":s.state==="ended"||t.lastTurnEndAt!=null?"done":"idle",phrase:d}}export{h as paneStatus};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{cd as me,j as s,B as _,K as J,u as T,t as Z,bi as ae,E as pe,r as d,aA as Re,an as oe,bh as Ie,ce as Ae,b2 as Ke,y as De,cf as ce}from"./app-CXxFM7fY.js";import{I as Fe}from"./IntegrationSkeleton-DAKXKuLF.js";import{S as U,C as _e,a as fe,p as Le,M as Ge}from"./StageShell-F-zWWpCp.js";import"./stage-board-BmcdRHaG.js";const xe="board.decision.onlyTerm",Me="board.decision.checkFailed";function ke(e){return{mode:e.origin==="outside"?"readOnly":e.multi?"multi":"choose",outcome:{kind:"none"},focus:null,checked:[],text:"",closed:!1,token:0}}const p=(e,n=[])=>({state:e,effects:n});function W(e){return e.outcome.kind==="none"||e.outcome.kind==="held"}function be(e,n){const t=n.model.options,a=o=>Number.isInteger(o)&&!!t[o]&&!t[o].locked;switch(e.kind){case"option":return a(e.index);case"text":return a(e.index)&&!!t[e.index].free&&e.text.trim()!=="";case"many":return e.indexes.length>0&&e.indexes.every(a)}}function Y(e,n,t){return!t.canRecheck||!be(n,t)?p(e):p({...e,token:e.token+1,outcome:{kind:"checking",answer:n}},[{type:"recheck",answer:n}])}function ie(e){return e.outcome.kind==="checking"?{...e,token:e.token+1,outcome:{kind:"none"}}:e}function re(e,n,t){const a=t.model.options[n];if(!a||!W(e))return p(e);const o={...e,focus:n};return a.locked?p(o,[{type:"announce",text:xe}]):a.free?p({...o,mode:"free"}):Y(o,{kind:"option",index:n},t)}function je(e,n,t){var o;const a=t.model.options.length;switch(n.type){case"focus":return n.index==null?p({...e,focus:null}):e.mode==="readOnly"||n.index<0||n.index>=a?p(e):e.mode==="free"&&!((o=t.model.options[n.index])!=null&&o.free)?p({...e,mode:"choose",focus:n.index}):p({...e,focus:n.index});case"move":{if(e.mode==="readOnly"||e.mode==="free"||a===0)return p(e);const c=e.focus==null?n.by===1?0:a-1:Math.min(a-1,Math.max(0,e.focus+n.by));return p({...e,focus:c})}case"pick":return e.mode==="readOnly"||e.mode==="free"?p(e):e.mode==="multi"?je(e,{type:"toggle",index:n.index},t):re(e,n.index,t);case"toggle":{if(e.mode!=="multi"||!W(e)||n.index<0||n.index>=a)return p(e);if(t.model.options[n.index].locked)return p({...e,focus:n.index},[{type:"announce",text:xe}]);const m=e.checked.includes(n.index)?e.checked.filter(f=>f!==n.index):[...e.checked,n.index].sort((f,j)=>f-j);return p({...e,focus:n.index,checked:m})}case"submit":{if(!W(e))return p(e);if(e.mode==="choose")return e.focus==null?p(e):re(e,e.focus,t);if(e.mode==="free"){const c=e.text.trim(),m=e.focus==null?void 0:t.model.options[e.focus];return!c||e.focus==null||!(m!=null&&m.free)||m.locked?p(e):Y(e,{kind:"text",index:e.focus,text:c},t)}return e.mode==="multi"&&e.checked.length?Y(e,{kind:"many",indexes:e.checked},t):p(e)}case"openFree":{if(e.mode!=="choose"||!W(e))return p(e);const c=t.model.options.findIndex(m=>m.free&&!m.locked);return c<0?p(e):p({...e,mode:"free",focus:c})}case"typeFree":return e.mode==="free"?p({...e,text:n.text}):p(e);case"escape":return e.mode==="free"?p({...ie(e),mode:"choose"}):p({...ie(e),closed:!0},[{type:"close"}]);case"result":{if(e.closed||e.outcome.kind!=="checking"||n.token!==void 0&&n.token!==e.token)return p(e);const{answer:c}=e.outcome,m=n.result;return m==="ok"&&!be(c,t)?p({...e,outcome:{kind:"none"}}):m==="ok"?p({...e,outcome:{kind:"sent",answer:c}},[{type:"send",answer:c},{type:"record",answer:c}]):p({...e,outcome:m})}case"checkFailed":return e.closed||e.outcome.kind!=="checking"||n.token!==void 0&&n.token!==e.token?p(e):p({...e,outcome:{kind:"none"}},[{type:"announce",text:Me}]);case"reset":return p({...ke(t.model),token:e.token+1});case"elsewhere":return p({...e,outcome:{kind:"elsewhere",at:n.at}});case"outcome":return p({...e,outcome:n.input});case"dismissOutcome":return p({...e,outcome:{kind:"none"},closed:e.outcome.kind==="sent"||e.outcome.kind==="elsewhere"?!0:e.closed});case"showTerm":return p(e,[{type:"showTerm"}]);case"showNew":return p(e,[{type:"showNew"}]);default:return p(e)}}const Be="Decision",Pe="Keys on the question",de={id:"decision",rows:[{cap:"1 – 3",action:"Pick an answer and send it, after the prompt is read again",binds:["1","2","3"]},{cap:"↑ ↓ Tab",action:"Move the ring along the answers",binds:["ArrowUp","ArrowDown","Tab"]},{cap:"↵",action:"Send the answer the ring is on",binds:["Enter"]},{cap:"Esc",action:"Close the question. It never answers",binds:["Escape"]}]},B=(e,n)=>({text:e,spoken:n}),He=[{caps:[B("1–3","1 to 3")],word:"pick and send",binds:["1","2","3"]},{caps:[B("↑"),B("↓"),B("Tab")],word:"move",binds:["ArrowUp","ArrowDown","Tab"]},{caps:[B("↵","Enter")],word:"send",binds:["Enter"]},{caps:[B("Esc","Escape")],word:"close",binds:["Escape"]}];function Ys(e){return{layer:"decision",label:Pe,hints:He.filter(n=>e||!n.binds.some(me))}}function Xs(e){return{id:de.id,title:Be,rows:de.rows.filter(n=>e||!n.binds.some(me))}}function Ue(e){return!e||typeof e.closest!="function"?"other":e.closest(".dc-input")?"field":e.closest(".dc-opt")?"row":"other"}function qe(e,n,t,a,o){return n==="other"||n==="field"&&e.key!=="Enter"&&e.key!=="Escape"?null:ze(e,t,a,o)}function ze(e,n,t,a){if(e.ctrlKey||e.metaKey||e.altKey)return null;switch(e.key){case" ":return a!=null&&a.multi&&a.focus!=null&&a.focus<t?{type:"toggle",index:a.focus}:null;case"ArrowDown":return{type:"move",by:1};case"ArrowUp":return{type:"move",by:-1};case"Tab":return{type:"move",by:e.shiftKey?-1:1};case"Enter":return{type:"submit"};case"Escape":return{type:"escape"};default:{if(!n||!/^[1-3]$/.test(e.key))return null;const o=Number(e.key)-1;return o<t?{type:"pick",index:o}:null}}}const ge=()=>s.jsx(_,{name:"lock"}),q=()=>s.jsx(_,{name:"changed"}),X=()=>s.jsx(_,{name:"chevron-right"}),We=()=>s.jsx(_,{name:"file"}),Ye=()=>s.jsx(_,{name:"search"}),Xe=()=>s.jsx(_,{name:"terminal"}),P=()=>s.jsx(J,{name:"done",size:12}),Ve=()=>s.jsx(_,{name:"agents"}),Qe=()=>s.jsx(J,{name:"idle",size:12}),Je=()=>s.jsx(J,{name:"working",size:12}),Ze=()=>s.jsx(_,{name:"image"}),es="board.decision.note.default",ss="board.decision.note.focus",ns="board.decision.note.free",ts="board.decision.note.outside";function as(e,n=Z){return n("board.decision.note.many",{count:e})}function os(e,n,t,a=Z){return e==="readOnly"?{text:a(ts),lock:!1}:e==="free"?{text:a(ns),lock:!1}:e==="multi"?{text:t>0?as(t,a):"",lock:!1}:n?{text:a(ss),lock:!1}:{text:a(es),lock:!0}}function cs(e){const n=T(),t=os(e.mode,e.focused,e.checked,n),a=e.mode==="readOnly";return s.jsxs("div",{className:"dc-foot",children:[!a&&e.mode!=="multi"&&e.singleKeys!==!1&&s.jsxs("span",{className:"dc-foot-pick",children:[n("board.decision.pick")," ",s.jsx(ae,{children:"1"}),e.rows>1&&s.jsxs(s.Fragment,{children:[" ","–"," ",s.jsx(ae,{children:String(e.rows)})]})]}),s.jsxs("span",{className:"dc-foot-note","data-muted":e.mode==="multi"||void 0,children:[t.lock&&s.jsx(ge,{}),t.text]}),!a&&s.jsxs("button",{type:"button",className:"dc-link",onClick:e.onShowTerm,children:[n("board.decision.seeTerm"),s.jsx(pe,{})]})]})}function is(e){const{option:n}=e,t=T(),a=d.useId(),o=n.locked?`${a}-lock-${e.index}`:void 0;return s.jsxs("div",{className:"dc-row","data-typing":e.typing||void 0,children:[s.jsxs("div",{ref:e.rowRef,className:"dc-opt",role:e.selection==="radio"?"radio":"checkbox","aria-checked":e.checked,"aria-disabled":n.locked||e.readOnly||void 0,"aria-describedby":o,"aria-keyshortcuts":e.readOnly||e.singleKeys===!1?void 0:String(e.index+1),tabIndex:e.readOnly?void 0:e.tabStop?0:-1,"data-focus":e.focused||void 0,"data-locked":n.locked||void 0,"data-checked":e.checked||void 0,"data-typing":e.typing||void 0,onClick:e.readOnly?void 0:e.onPick,onFocus:e.readOnly?void 0:e.onFocus,children:[s.jsx("span",{className:"dc-chip","aria-hidden":"true",children:e.index+1}),s.jsxs("span",{className:"dc-opt-text",children:[s.jsx("span",{className:"dc-opt-label",title:n.label,children:n.label}),n.locked?s.jsxs("span",{className:"dc-opt-sub dc-lock",id:o,children:[s.jsx(ge,{}),n.lockNote]}):s.jsx("span",{className:"dc-opt-sub",children:n.sub})]}),n.pick&&s.jsx("span",{className:"dc-pick",children:t("board.decision.pickTag")}),e.selection==="checkbox"&&s.jsx("span",{className:"dc-box","aria-hidden":"true","data-on":e.checked||void 0})]}),e.typing&&s.jsxs("div",{className:"dc-field",children:[s.jsx("input",{ref:e.inputRef,className:"dc-input",type:"text",value:e.text,"aria-label":n.label,onChange:c=>e.onText(c.target.value),onKeyDown:e.onFieldKey}),s.jsxs("span",{className:"dc-send","aria-hidden":"true",children:[t("board.decision.send")," ","↵"]})]})]})}const le=e=>s.jsx("code",{className:"dc-mono",children:e});function rs(e,n){var a;const t=e.answer;return!!n.command&&t.kind!=="many"&&((a=n.options[t.index])==null?void 0:a.runs)===!0}function ds(e,n,t,a){const o={label:a("board.decision.openTerm"),run:t.onShowTerm};switch(e.kind){case"none":return null;case"checking":return{glyph:s.jsx(U,{kind:"working"}),title:a("board.decision.checking.title"),sub:a("board.decision.checking.sub")};case"sent":return{glyph:s.jsx(U,{kind:"done"}),title:a("board.decision.sent.title",{session:n.session}),tone:"ok",sub:rs(e,n)?oe(a("board.decision.sent.running",{command:"{command}"}),{command:le(n.command)}):a("board.decision.sent.answer")};case"changed":return e.now?{glyph:s.jsx(q,{}),title:a("board.decision.changed.title"),sub:oe(a("board.decision.changed.now",{question:"{question}"}),{question:le(e.now)}),link:{label:a("board.decision.changed.show"),run:t.onShowNew}}:{glyph:s.jsx(q,{}),title:a("board.decision.changed.title"),sub:a("board.decision.changed.term"),link:o};case"ended":return{glyph:s.jsx("span",{className:"dc-err",children:s.jsx(Re,{kind:"err",size:14})}),title:a("board.decision.ended.title",{session:n.session}),sub:a("board.decision.ended.sub"),link:{label:a("board.decision.ended.transcript"),run:t.onOpenTranscript}};case"held":return{glyph:s.jsx(U,{kind:"idle"}),title:a("board.decision.held.title"),sub:a("board.decision.held.sub"),link:o};case"elsewhere":return{glyph:s.jsx(U,{kind:"done"}),title:a("board.decision.elsewhere.title",{at:e.at}),sub:a("board.decision.elsewhere.sub")};case"stopped":return e.part?{glyph:s.jsx(q,{}),title:a("board.decision.partial.title"),sub:a("board.decision.partial.sub"),link:o}:{glyph:s.jsx(q,{}),title:a("board.decision.stopped.title"),sub:a("board.decision.stopped.sub"),link:o}}}function ls({outcome:e,model:n,...t}){const a=T(),o=ds(e,n,t,a);return o?s.jsxs("div",{className:"dc-out",role:"status","aria-atomic":"true","data-kind":e.kind,children:[s.jsx("span",{className:"dc-out-glyph","aria-hidden":"true",children:o.glyph}),s.jsxs("span",{className:"dc-out-text",children:[s.jsx("span",{className:"dc-out-title","data-tone":o.tone,children:o.title}),s.jsx("span",{className:"dc-out-sub",children:o.sub})]}),o.link&&s.jsxs("button",{type:"button",className:"dc-link",onClick:o.link.run,children:[o.link.label,o.link.external&&s.jsx(pe,{})]})]}):s.jsx("div",{className:"dc-out-empty",role:"status","aria-atomic":"true"})}let us=0;function hs(e){const{model:n}=e,t=T(),a=Ie(),[o]=d.useState(()=>`dc-${++us}`),[c,m]=d.useState(()=>({...ke(n),...e.outcome?{outcome:e.outcome}:null,...e.initial})),[f,j]=d.useState(""),x=d.useRef(c),l=d.useRef(e);l.current=e;const g=d.useRef([]),y=d.useRef(null),k=d.useRef(!1),S=d.useRef(!0);d.useEffect(()=>()=>{S.current=!1},[]);const O=typeof e.recheck=="function",w=d.useMemo(()=>({model:n,canRecheck:O}),[n,O]),$=d.useRef(w);$.current=w;const i=d.useCallback(h=>{const r=je(x.current,h,$.current);x.current=r.state,m(r.state);for(const b of r.effects)A(b)},[]);function A(h){var b,F,M,H,se,ne;const r=l.current;switch(h.type){case"recheck":{const te=x.current.token;(b=r.recheck)==null||b.call(r,h.answer).then(Oe=>{S.current&&i({type:"result",result:Oe,token:te})},()=>{S.current&&i({type:"checkFailed",token:te})})}break;case"send":(F=r.onAnswer)==null||F.call(r,h.answer);break;case"record":(M=r.onRecord)==null||M.call(r,h.answer);break;case"close":(H=r.onClose)==null||H.call(r);break;case"showTerm":(se=r.onShowTerm)==null||se.call(r);break;case"showNew":(ne=r.onShowNew)==null||ne.call(r);break;case"announce":j(h.text);break}}const C=d.useRef(!0);d.useEffect(()=>{if(C.current){C.current=!1;return}e.outcome&&i({type:"outcome",input:e.outcome})},[e.outcome,i]);const L=d.useRef(n.id);d.useEffect(()=>{L.current!==n.id&&(L.current=n.id,j(""),i({type:"reset"}),l.current.outcome&&i({type:"outcome",input:l.current.outcome}))},[n.id,i]),d.useEffect(()=>{var h;c.focus!=null&&k.current&&((h=g.current[c.focus])==null||h.focus())},[c.focus]);const G=d.useRef(c.mode),N=d.useRef(!1);d.useEffect(()=>{var r,b;const h=G.current;G.current=c.mode,c.mode==="free"&&h!=="free"?(r=y.current)==null||r.focus():h==="free"&&c.mode!=="free"&&N.current&&(N.current=!1,c.focus!=null&&((b=g.current[c.focus])==null||b.focus()))},[c.mode,c.focus]);const E=h=>{const r=x.current;if(r.mode==="readOnly")return;const b=Ue(h.target),F=qe(h,b,a,n.options.length,{multi:r.mode==="multi",focus:r.focus});if(F){if(F.type==="move"&&h.key==="Tab"){const M=r.focus,H=F.by===1?M===n.options.length-1:M===0;if(M!=null&&H)return}h.preventDefault(),h.stopPropagation(),k.current=!0,i(F)}},R=c.outcome,u=R.kind==="checking"||R.kind==="sent"?R.answer:null,v=u&&u.kind!=="many"?u.index:-1,K=`${o}-title`,D=c.mode==="multi",I=c.focus??0;return c.closed?null:s.jsxs("div",{className:"dc-dock","data-size":e.size==="phone"?"phone":void 0,"data-mode":c.mode,"data-outcome":R.kind,"data-kind":n.kind,children:[s.jsxs("div",{className:"dc-decision",role:"group","aria-labelledby":K,onKeyDown:E,onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||(k.current=!1,x.current.focus!=null&&x.current.mode!=="free"&&i({type:"focus",index:null}))},children:[s.jsxs("div",{className:"dc-dq","data-outcome":R.kind,children:[s.jsx("h3",{className:"dc-title",id:K,children:n.title}),n.plan?s.jsx("ol",{className:"dc-plan",children:n.plan.map((h,r)=>s.jsxs("li",{children:[s.jsx("span",{className:"dc-plan-n",children:r+1}),h]},r))}):n.command?s.jsx("code",{className:"dc-cmd",children:n.command}):null,s.jsx("p",{className:"dc-caption",children:n.caption})]}),s.jsxs("div",{className:"dc-tree","aria-hidden":"true",children:[s.jsx("i",{className:"dc-stub"}),n.options.map((h,r)=>s.jsx("i",{className:"dc-tick","data-typing":c.mode==="free"&&c.focus===r||void 0},r))]}),s.jsx("div",{className:"dc-opts",role:D?"group":"radiogroup","aria-labelledby":K,children:n.options.map((h,r)=>s.jsx(is,{index:r,option:h,selection:D?"checkbox":"radio",focused:c.focus===r,checked:D?c.checked.includes(r):v===r,typing:c.mode==="free"&&c.focus===r,text:c.text,readOnly:c.mode==="readOnly",singleKeys:a,tabStop:I===r,rowRef:b=>{g.current[r]=b},inputRef:y,onPick:()=>{k.current=!0,i({type:"pick",index:r})},onFocus:()=>i({type:"focus",index:r}),onText:b=>i({type:"typeFree",text:b}),onFieldKey:b=>{b.key==="Enter"?(b.preventDefault(),b.stopPropagation(),i({type:"submit"})):b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),N.current=!0,i({type:"escape"}))}},r))}),s.jsx(ls,{outcome:R,model:n,onShowNew:()=>i({type:"showNew"}),onShowTerm:()=>i({type:"showTerm"}),onOpenTranscript:()=>{var h,r;return(r=(h=l.current).onOpenTranscript)==null?void 0:r.call(h)}})]}),s.jsx(cs,{mode:c.mode,focused:c.focus!=null,checked:c.checked.length,rows:n.options.length,singleKeys:a,onShowTerm:()=>i({type:"showTerm"})}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:f&&t(f)})]})}const ms=new Set(["assistant","tool","todo","notice","agent","ask","plan"]);function ps(e){const n=[];return e.forEach((t,a)=>{if(t.kind==="user"||t.kind==="command"||t.kind==="record"){n.push({...t,index:a});return}const o=n.at(-1);(o==null?void 0:o.kind)==="assistant"?o.turns.push(t):ms.has(t.kind)&&n.push({kind:"assistant",turns:[t],index:a})}),n}const fs=/^ {0,3}(`{3,}|~{3,})(.*)$/,ye=/^ {0,3}(#{1,6})[\t ]+(.+)$/,V=/^ {0,3}(?:([-+*])|([0-9]{1,9})[.)])[\t ]+(.*)$/,Q=/^ {0,3}>[\t ]?(.*)$/;function Ne(e){const n=fs.exec(e);return n&&!(n[1][0]==="`"&&n[2].includes("`"))?n:null}function we(e){return e.map((n,t)=>n.kind==="code"?s.jsx("code",{children:n.text},t):n.kind==="bold"?s.jsx("strong",{children:we(n.kids)},t):s.jsx(d.Fragment,{children:n.text.split(`
|
|
2
|
+
`).map((a,o)=>s.jsxs(d.Fragment,{children:[o>0&&s.jsx("br",{}),a]},o))},t))}const z=e=>we(Ae(e)),ue=e=>Ne(e)||ye.test(e)||V.test(e)||Q.test(e);function ve({text:e}){const n=e.replace(/\r\n?/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`),t=[];let a=0;for(;a<n.length;){if(!n[a].trim()){a++;continue}const o=a,c=Ne(n[a]);if(c){const x=c[1],l=new RegExp(`^ {0,3}${x[0]}{${x.length},}[\\t ]*$`),g=c[2].trim().split(/\s+/)[0],y=++a;for(;a<n.length&&!l.test(n[a]);)a++;const k=n.slice(y,a).join(`
|
|
5
|
+
`)+(a<n.length&&a>y?`
|
|
6
|
+
`:"");t.push(s.jsx("pre",{children:s.jsx("code",{"data-language":g||void 0,children:k})},o)),a<n.length&&a++;continue}const m=ye.exec(n[a]);if(m){const x=m[1].length<=2?"h2":m[1].length===3?"h3":"h4";t.push(s.jsx(x,{children:z(m[2].replace(/[\t ]+#+[\t ]*$/,"").trimEnd())},o)),a++;continue}const f=V.exec(n[a]);if(f){const x=f[2]!==void 0,l=[];for(;a<n.length;){const g=V.exec(n[a]);if(!g||g[2]!==void 0!==x)break;const y=a++,k=[g[3]];for(;a<n.length&&/^[\t ]{2,}\S/.test(n[a])&&!ue(n[a]);)k.push(n[a++].trimStart());l.push(s.jsx("li",{children:z(k.join(`
|
|
7
|
+
`))},y))}t.push(x?s.jsx("ol",{start:Number(f[2])===1?void 0:Number(f[2]),children:l},o):s.jsx("ul",{children:l},o));continue}if(Q.test(n[a])){const x=[];for(;a<n.length;){const l=Q.exec(n[a]);if(!l)break;x.push(l[1]),a++}t.push(s.jsx("blockquote",{children:x.join(`
|
|
8
|
+
`).split(/\n[\t ]*\n/).map((l,g)=>s.jsx("p",{children:z(l)},g))},o));continue}const j=[n[a++]];for(;a<n.length&&n[a].trim()&&!ue(n[a]);)j.push(n[a++]);t.push(s.jsx("p",{children:z(j.join(`
|
|
9
|
+
`))},o))}return s.jsx("div",{className:"chat-markdown",children:t})}function Te({text:e,images:n}){const t=T();return s.jsxs("div",{className:"chat-you",children:[s.jsx("span",{className:"chat-author",children:t("board.chat.you")}),e&&s.jsx("p",{className:"chat-you-text",children:e.replace(/\r\n?/g,`
|
|
10
|
+
`)}),n?s.jsxs("span",{className:"chat-you-images",children:[s.jsx("span",{className:"chat-you-images-mark",children:s.jsx(Ze,{})}),t("board.chat.images",{count:n})]}):null]})}function Se({turn:e}){const n=T();return s.jsxs("div",{className:"chat-you",children:[s.jsx("span",{className:"chat-author",children:n("board.chat.you")}),s.jsx("p",{className:"chat-command-line",children:s.jsx("code",{children:e.args?`${e.name} ${e.args}`:e.name})}),e.output&&s.jsx("pre",{className:"chat-command-output","data-failed":e.failed||void 0,children:s.jsx("code",{children:e.output})})]})}function xs({text:e}){return s.jsx("div",{className:"chat-said",children:s.jsx(ve,{text:e})})}const ks={file:We,search:Ye,terminal:Xe};function bs(e){return e==="…"?"gap":e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}function js({diff:e}){const n=T();return s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"chat-diff",children:s.jsx("code",{children:e.lines.map((t,a)=>s.jsx("span",{className:"chat-diff-line","data-op":bs(t),children:t},a))})}),e.cut&&s.jsx("p",{className:"chat-diff-cut",children:n("board.chat.diff.cut")})]})}function gs(e){return Object.hasOwn(ce,e)?ce[e]:e}function Ee({turn:e}){var x;const n=T(),t=d.useId(),[a,o]=d.useState(!1),c=ks[e.mark??(e.name==="Bash"?"terminal":e.name==="Explore"?"search":"file")],m=e.error!==void 0,f=gs(e.name),j=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"chat-tool-mark",children:s.jsx(c,{})}),s.jsx("span",{className:"chat-tool-name",title:f===e.name?void 0:e.name,children:f}),s.jsx("span",{className:"chat-tool-arg",title:e.arg,children:e.arg}),e.note&&s.jsx("span",{className:"chat-tool-note",children:e.note}),m&&s.jsx("span",{className:"chat-tool-failed",children:n("board.chat.tool.failed")}),e.declined&&s.jsx("span",{className:"chat-tool-declined",children:n("board.chat.tool.declined")})]});return e.error||(x=e.diff)!=null&&x.lines.length?s.jsxs("div",{className:"chat-tool-call",children:[s.jsxs("button",{type:"button",className:"chat-tool chat-tool-toggle","data-running":e.running||void 0,"aria-expanded":a,"aria-controls":a?t:void 0,onClick:()=>o(l=>!l),children:[s.jsx("span",{className:"chat-disclosure",children:s.jsx(X,{})}),j]}),a&&s.jsxs("div",{className:"chat-tool-detail",id:t,children:[e.arg&&s.jsx("pre",{className:"chat-tool-input",children:s.jsx("code",{children:e.arg})}),e.error&&s.jsx("pre",{className:"chat-tool-error",children:s.jsx("code",{children:e.error})}),e.diff&&e.diff.lines.length>0&&s.jsx(js,{diff:e.diff})]})]}):e.arg?s.jsxs("details",{className:"chat-tool-call",children:[s.jsxs("summary",{className:"chat-tool","data-running":e.running||void 0,children:[s.jsx("span",{className:"chat-disclosure",children:s.jsx(X,{})}),j]}),s.jsx("pre",{className:"chat-tool-input",children:s.jsx("code",{children:e.arg})})]}):s.jsx("div",{className:"chat-tool","data-running":e.running||void 0,children:j})}function $e(e){return{done:e.filter(n=>n.status==="done").length,total:e.length}}const ys={done:P,active:Je,pending:Qe};function ee({turn:e}){const n=T(),t=e.items.length?n("board.chat.todo.updated",$e(e.items)):n("board.chat.todo.cleared");return s.jsxs("div",{className:"chat-tool chat-todo-line",children:[s.jsx("span",{className:"chat-tool-mark",children:s.jsx(P,{})}),s.jsx("span",{className:"chat-todo-line-text",children:t})]})}function Ns({turn:e}){const n=T();if(!e.items.length)return s.jsx(ee,{turn:e});const t=n("board.chat.todo.head",$e(e.items));return s.jsxs("section",{className:"chat-todo","aria-label":t,children:[s.jsx("div",{className:"chat-todo-head","aria-hidden":"true",children:t}),s.jsx("ul",{className:"chat-todo-list",children:e.items.map((a,o)=>{const c=ys[a.status];return s.jsxs("li",{className:"chat-todo-item","data-status":a.status,children:[s.jsx("span",{className:"chat-todo-mark",children:s.jsx(c,{})}),s.jsx("span",{className:"chat-sr",children:n(`board.chat.todo.${a.status}`)}),s.jsx("span",{className:"chat-todo-text",children:a.text})]},o)})})]})}function ws({turn:e}){const n=T(),t=e.running?"running":e.declined?"declined":e.failed?"failed":e.background?"background":"done",a={running:"board.chat.running",declined:"board.chat.tool.declined",failed:"board.chat.tool.failed",background:"board.chat.agent.background",done:"board.chat.agent.done"}[t];return s.jsxs("div",{className:"chat-tool chat-agent","data-state":t,children:[s.jsx("span",{className:"chat-tool-mark",children:s.jsx(Ve,{})}),s.jsx("span",{className:"chat-tool-name",children:e.type?n("board.chat.agent.typed",{type:e.type}):n("board.chat.agent.title")}),e.description&&s.jsxs("span",{className:"chat-agent-desc",title:e.description,children:["— ",e.description]}),s.jsx("span",{className:"chat-agent-state",children:n(a)})]})}function vs({turn:e}){const n=T(),t=e.what==="interrupted"?n("board.chat.notice.interrupted"):e.text||n("board.chat.notice.error");return s.jsx("p",{className:"chat-notice","data-what":e.what,children:t})}function Ts({turns:e}){const n=T(),t=e.some(o=>o.kind==="tool"&&o.running),a=e.filter(o=>o.kind==="tool"&&o.error!==void 0).length;return s.jsxs("details",{className:"chat-activity",open:t||void 0,children:[s.jsxs("summary",{className:"chat-activity-head",children:[s.jsx("span",{className:"chat-disclosure",children:s.jsx(X,{})}),s.jsx("span",{children:n("board.chat.tools",{count:e.length})}),a>0&&s.jsx("span",{className:"chat-activity-failed",children:n("board.chat.toolsFailed",{count:a})}),t&&s.jsx("span",{className:"chat-activity-running",children:n("board.chat.running")})]}),s.jsx("div",{className:"chat-activity-calls",children:e.map((o,c)=>o.kind==="tool"?s.jsx(Ee,{turn:o},c):s.jsx(ee,{turn:o},c))})]})}function Ss({turns:e,provider:n="claude",ask:t,todoAt:a}){const o=n==="codex"?"Codex":"Claude Code",c=T(),[m,f]=d.useState(!1),j=e.filter(l=>l.kind==="assistant").map(l=>l.text).join(`
|
|
11
|
+
|
|
12
|
+
`);d.useEffect(()=>f(!1),[j]);const x=[];return e.forEach((l,g)=>{const y=l.kind==="tool"||l.kind==="todo"&&g!==a,k=x.at(-1);y&&(k!=null&&k.folded)?k.turns.push(l):x.push({index:g,turns:[l],folded:y})}),s.jsxs("section",{className:"chat-response","aria-label":o,children:[s.jsxs("div",{className:"chat-response-author",children:[s.jsx(Ke,{provider:n}),s.jsx("span",{children:o}),j&&s.jsx("button",{type:"button",className:"glyph-btn chat-copy",title:c(m?"board.stage.copied":"board.stage.copy"),"aria-label":c(m?"board.stage.copied":"board.stage.copy"),onClick:()=>{De(j).then(l=>f(l))},children:s.jsx(_e,{})})]}),s.jsx("div",{className:"chat-response-content",children:x.flatMap(l=>l.folded&&l.turns.some(g=>g.kind==="tool")?[s.jsx(Ts,{turns:l.turns},l.index)]:l.turns.map((g,y)=>s.jsx(Fs,{turn:g,ask:(t==null?void 0:t.at)===l.index+y?t:void 0,latest:a===l.index+y},l.index+y)))})]})}function Es(e,n){const t=new Set;if(!n)return{chosen:t,other:""};const a=e.options.findIndex(c=>c.label===n);if(a>=0)return{chosen:t.add(a),other:""};if(!e.multi)return{chosen:t,other:n};const o=[];for(const c of n.split(", ")){const m=e.options.findIndex(f=>f.label===c);m>=0?t.add(m):o.push(c)}return{chosen:t,other:o.join(", ")}}function $s(e){return e.running?"waiting":e.reply||(e.answers??[]).some(Boolean)?"answered":"unanswered"}function Cs(e){return fe(e)&&!e.multi&&!e.preview}function Os(e,n,t){return e.multi?{options:(n.options.includes(t)?n.options.filter(o=>o!==t):[...n.options,t]).sort((o,c)=>o-c)}:{options:[t]}}const Rs={sent:"board.chat.ask.result.sent",changed:"board.chat.ask.result.changed",partial:"board.chat.ask.result.partial",unavailable:"board.chat.ask.result.unavailable"};function Is({turn:e,ask:n}){const t=T(),a=d.useId(),o=$s(e),c=o==="waiting"?n:void 0,[m,f]=d.useState(()=>e.questions.map(()=>({options:[]}))),[j,x]=d.useState(()=>e.questions.map(()=>"")),[l,g]=d.useState(!1),[y,k]=d.useState(null),S=e.questions.every(fe),O=y==="sent"||y==="partial",w=!c||l||O||c.blocked!==void 0||!S,$=!w&&Le(e.questions,m);function i(N,E){f(R=>R.map((u,v)=>v===N?E:u)),k(null)}async function A(){if(!c||!$)return;g(!0),k(null);let N;try{N=await c.send(e.questions,m)}catch{N="unavailable"}g(!1),k(N)}const C=e.questions.map((N,E)=>{var D;const{chosen:R,other:u}=Es(N,((D=e.answers)==null?void 0:D[E])??""),v=m[E]??{options:[]},K=`${a}-q${E}`;return s.jsxs("div",{className:"chat-ask-q",role:"group","aria-labelledby":`${K}-text`,children:[(N.header||N.multi)&&s.jsxs("div",{className:"chat-ask-meta",children:[N.header&&s.jsx("span",{className:"chat-ask-tag",children:N.header}),N.multi&&s.jsx("span",{className:"chat-ask-multi",children:t("board.chat.ask.multi")})]}),s.jsx("p",{className:"chat-ask-question",id:`${K}-text`,children:N.question}),N.options.length>0&&s.jsxs("ol",{className:"chat-ask-options",children:[N.options.map((I,h)=>{const r=s.jsxs("span",{className:"chat-ask-option-text",children:[s.jsx("span",{className:"chat-ask-option-label",children:I.label}),I.description&&s.jsx("span",{className:"chat-ask-option-note",children:I.description})]});if(c){const b=v.text===void 0&&v.options.includes(h);return s.jsx("li",{className:"chat-ask-option chat-ask-choice","data-chosen":b||void 0,children:s.jsxs("label",{className:"chat-ask-pick",children:[s.jsx("input",{type:N.multi?"checkbox":"radio",name:K,checked:b,disabled:w,onChange:()=>i(E,Os(N,v.text===void 0?v:{options:[]},h))}),r,b&&O&&s.jsxs("span",{className:"chat-ask-chosen",children:[s.jsx(P,{}),t("board.chat.ask.chosen")]})]})},h)}return s.jsxs("li",{className:"chat-ask-option","data-chosen":R.has(h)||void 0,children:[s.jsx("span",{className:"chat-ask-n","aria-hidden":"true",children:h+1}),r,R.has(h)&&s.jsxs("span",{className:"chat-ask-chosen",children:[s.jsx(P,{}),t("board.chat.ask.chosen")]})]},h)}),c&&Cs(N)&&s.jsxs("li",{className:"chat-ask-option chat-ask-choice chat-ask-other","data-chosen":v.text!==void 0||void 0,children:[s.jsxs("label",{className:"chat-ask-pick",children:[s.jsx("input",{type:"radio",name:K,checked:v.text!==void 0,disabled:w,onChange:()=>i(E,{options:[],text:j[E]??""})}),s.jsx("span",{className:"chat-ask-option-label",children:t("board.chat.ask.other")}),v.text!==void 0&&O&&s.jsxs("span",{className:"chat-ask-chosen",children:[s.jsx(P,{}),t("board.chat.ask.chosen")]})]}),s.jsx("input",{type:"text",className:"chat-ask-text",value:j[E]??"",maxLength:Ge,disabled:w,"aria-label":t("board.chat.ask.other"),placeholder:t("board.chat.ask.otherHint"),onChange:I=>{const h=I.currentTarget.value;x(r=>r.map((b,F)=>F===E?h:b)),i(E,{options:[],text:h})}})]})]}),!c&&u&&s.jsxs("p",{className:"chat-ask-answer",children:[s.jsx("span",{className:"chat-ask-answer-label",children:t("board.chat.ask.yourAnswer")}),u]})]},E)}),L=l?t("board.chat.ask.sending"):y?t(Rs[y]):S?"":t("board.chat.ask.inTerm"),G=(c==null?void 0:c.onShowTerm)&&!l&&y!=="sent"&&(y!==null||!S);return s.jsxs("section",{className:"chat-ask","data-state":o,"aria-label":t("board.chat.ask.title",{count:e.questions.length}),children:[s.jsxs("div",{className:"chat-ask-head",children:[s.jsx("span",{className:"chat-ask-title",children:t("board.chat.ask.title",{count:e.questions.length})}),s.jsx("span",{className:"chat-ask-state",children:t(`board.chat.ask.${o}`)})]}),c?s.jsxs("form",{className:"chat-ask-form","data-locked":w||void 0,onSubmit:N=>{N.preventDefault(),A()},children:[C,s.jsxs("div",{className:"chat-ask-actions",children:[s.jsx("button",{className:"btn primary chat-ask-send",type:"submit",disabled:!$,children:t("board.chat.ask.send")}),s.jsx("p",{id:`${a}-status`,className:"chat-ask-status",role:"status","aria-live":"polite","aria-atomic":"true","data-result":y??void 0,children:L}),G&&s.jsx("button",{className:"chat-ask-term",type:"button",onClick:c.onShowTerm,children:t("board.chat.showTerm")})]})]}):C,e.reply&&s.jsxs("p",{className:"chat-ask-answer",children:[s.jsx("span",{className:"chat-ask-answer-label",children:t("board.chat.ask.yourReply")}),e.reply]})]})}function As({turn:e}){const n=T(),t=e.running?"waiting":e.approved?"approved":"declined";return s.jsxs("section",{className:"chat-ask chat-plan","data-state":t==="waiting"?"waiting":t==="approved"?"answered":"unanswered","aria-label":n("board.chat.plan.title"),children:[s.jsxs("div",{className:"chat-ask-head",children:[s.jsx("span",{className:"chat-ask-title",children:n("board.chat.plan.title")}),s.jsx("span",{className:"chat-ask-state",children:n(`board.chat.plan.${t}`)})]}),e.text&&s.jsx("div",{className:"chat-said chat-plan-text",children:s.jsx(ve,{text:e.text})}),e.cut&&s.jsx("p",{className:"chat-plan-cut",children:n("board.chat.plan.cut")})]})}function Ce({text:e}){return s.jsx("p",{className:"chat-record",children:e})}function Ks(e,n=Z){return n("board.chat.since",{count:e.toolCalls,label:e.label})}function Ds({since:e}){const n=Ks(e,T());return s.jsxs("div",{className:"chat-since",role:"separator","aria-label":n,children:[s.jsx("span",{className:"chat-since-line","aria-hidden":"true"}),s.jsx("span",{className:"chat-since-text","aria-hidden":"true",children:n}),s.jsx("span",{className:"chat-since-line","aria-hidden":"true"})]})}function Fs({turn:e,ask:n,latest:t}){switch(e.kind){case"user":return s.jsx(Te,{text:e.text,images:e.images});case"command":return s.jsx(Se,{turn:e});case"assistant":return s.jsx(xs,{text:e.text});case"tool":return s.jsx(Ee,{turn:e});case"todo":return t?s.jsx(Ns,{turn:e}):s.jsx(ee,{turn:e});case"agent":return s.jsx(ws,{turn:e});case"notice":return s.jsx(vs,{turn:e});case"ask":return s.jsx(Is,{turn:e,ask:n},e.questions.map(a=>a.question).join(`
|
|
13
|
+
`));case"plan":return s.jsx(As,{turn:e});case"record":return s.jsx(Ce,{text:e.text})}}function _s(e){const n=e.length-1,t=e[n];return(t==null?void 0:t.kind)==="ask"&&t.running?n:-1}function Ls(e){for(let n=e.length-1;n>=0;n--)if(e[n].kind==="todo")return n;return-1}const Gs=(e,n,t)=>e>=n&&e<n+t?e-n:void 0,Ms=24;function Bs(e){return e?e.kind==="user"?`user|${e.text}|${e.images??0}`:e.kind==="command"?`command|${e.name}|${e.args??""}|${e.failed?1:0}|${e.output??""}`:e.kind==="tool"?`tool|${e.name}|${e.arg}|${e.note??""}|${e.running?1:0}|${e.error===void 0?0:1}|${e.declined?1:0}`:e.kind==="ask"?`ask|${e.questions.map(n=>n.question).join(`
|
|
14
|
+
`)}|${e.running?1:0}|${(e.answers??[]).join(`
|
|
15
|
+
`)}|${e.reply??""}`:e.kind==="plan"?`plan|${e.text}|${e.running?1:0}|${e.approved?1:0}`:e.kind==="todo"?`todo|${e.items.map(n=>`${n.status}:${n.text}`).join(`
|
|
16
|
+
`)}`:e.kind==="agent"?`agent|${e.type}|${e.description}|${e.running?1:0}|${e.failed?1:0}|${e.declined?1:0}|${e.background?1:0}`:e.kind==="notice"?`notice|${e.what}|${e.text??""}`:`${e.kind}|${e.text}`:""}const he=typeof window>"u"?d.useEffect:d.useLayoutEffect;function Vs({source:e,provider:n,decision:t,ask:a}){const o=T(),c=d.useRef(null),m=d.useRef(!0),[f,j]=d.useState(!0),x=e.state==="ready"?e.turns.length:0,l=e.state==="ready"?_s(e.turns):-1,g=e.state==="ready"?Ls(e.turns):-1,y=e.state==="ready"?Bs(e.turns[e.turns.length-1]):"",k=e.state==="ready"?e.head??0:0,S=e.state==="ready"?e.older:void 0,O=d.useRef(k),w=d.useRef(0);k!==O.current&&c.current&&(w.current=c.current.scrollHeight);const $=d.useRef(!1);return he(()=>{const i=c.current;i&&m.current&&(i.scrollTop=i.scrollHeight)},[x,y]),he(()=>{const i=c.current,A=w.current;k!==O.current&&(O.current=k,w.current=0,i&&(m.current||(i.scrollTop+=i.scrollHeight-A),$.current&&!S&&typeof document<"u"&&(document.activeElement===null||document.activeElement===document.body)&&i.focus({preventScroll:!0}),$.current=!1))},[k]),s.jsxs("div",{className:"chat","data-docked":t?"":void 0,children:[s.jsxs("div",{className:"chat-reading",children:[s.jsx("div",{ref:c,className:"chat-body",role:"region","aria-label":o("board.chat.conversation"),tabIndex:0,onScroll:i=>{const A=i.currentTarget;m.current=A.scrollHeight-A.scrollTop-A.clientHeight<=Ms,j(m.current)},children:s.jsxs("div",{className:"chat-col",children:[e.state==="loading"&&s.jsx(Fe,{label:o("board.chat.loading"),rows:5,variant:"lines"}),e.state==="error"&&s.jsxs("div",{className:"chat-error",role:"alert",children:[s.jsx("span",{children:e.message}),e.onRetry&&s.jsx("button",{type:"button",className:"chat-retry",onClick:e.onRetry,children:o("board.chat.retry")})]}),e.state==="ready"&&s.jsxs(s.Fragment,{children:[S&&s.jsx("button",{type:"button",className:"chat-retry chat-older","aria-busy":S.loading||void 0,onClick:()=>{S.loading||($.current=!0,S.load())},children:o(S.loading?"board.chat.olderLoading":S.failed?"board.chat.olderFailed":"board.chat.older")}),e.since&&s.jsx(Ds,{since:e.since}),e.turns.length===0&&s.jsx("p",{className:"chat-empty",children:o("board.chat.empty")}),ps(e.turns).map(i=>i.kind==="assistant"?s.jsx(Ss,{turns:i.turns,provider:n,ask:a&&l>=i.index&&l<i.index+i.turns.length?{...a,at:l-i.index}:void 0,todoAt:Gs(g,i.index,i.turns.length)},i.index-k):i.kind==="user"?s.jsx(Te,{text:i.text,images:i.images},i.index-k):i.kind==="command"?s.jsx(Se,{turn:i},i.index-k):s.jsx(Ce,{text:i.text},i.index-k))]})]})}),!f&&e.state==="ready"&&e.turns.length>0&&s.jsx("button",{type:"button",className:"chat-latest btn",onClick:()=>{const i=c.current;m.current=!0,i&&(i.scrollTop=i.scrollHeight,i.focus({preventScroll:!0})),j(!0)},children:o("board.chat.latest")})]}),t&&s.jsx(hs,{...t},t.model.id)]})}const Ps=2500,Hs=typeof window>"u"?d.useEffect:d.useLayoutEffect;function Qs({value:e,onChange:n,onSend:t,unavailable:a,onShowTerm:o,canStop:c,onStop:m}){const f=T(),j=d.useId(),x=d.useRef(null),l=d.useRef(!1),[g,y]=d.useState(null),k=d.useRef(!1),[S,O]=d.useState(!1),[w,$]=d.useState(null),i=a!==void 0,A=i||!e.trim(),C=(g==null?void 0:g.draft)===e?g.result:null;d.useEffect(()=>{y(u=>(u==null?void 0:u.draft)===e?u:null)},[e]),d.useEffect(()=>{if(w!=="sent")return;const u=setTimeout(()=>$(null),Ps);return()=>clearTimeout(u)},[w]),Hs(()=>{const u=x.current;if(!u)return;const v=()=>{u.style.height="auto",u.style.height=`${u.scrollHeight}px`};v();const K=u.parentElement??u;let D=K.getBoundingClientRect().width;const I=typeof ResizeObserver>"u"?null:new ResizeObserver(h=>{var b;const r=(b=h[0])==null?void 0:b.contentRect.width;r===void 0||r===D||(D=r,v())});return I&&I.observe(K),()=>I==null?void 0:I.disconnect()},[e]);function L(){var v;if(A||l.current)return;let u;try{u=t(e)}catch{u="unavailable"}u==="sent"&&n(""),$(null),y({result:u,draft:u==="sent"?"":e}),(v=x.current)==null||v.focus({preventScroll:!0})}async function G(){var v;if(!m||k.current)return;k.current=!0,O(!0),$(null);let u;try{u=await m()}catch{u="unavailable"}k.current=!1,O(!1),$(u),typeof document<"u"&&(!document.activeElement||document.activeElement===document.body)&&((v=x.current)==null||v.focus({preventScroll:!0}))}const N=w==="unavailable"||w==="partial",E=w==="sent"?f("board.chat.stop.sent"):w==="changed"?f("board.chat.stop.nothing"):N?f("board.chat.stop.failed"):C==="sent"?f("board.chat.composer.sent"):C==="partial"?f("board.chat.composer.partial"):C==="too-large"?f("board.chat.composer.tooLarge"):C==="empty"?f("board.chat.composer.empty"):C==="unavailable"?f("board.chat.composer.unavailable"):i?a||f("board.chat.cannotType"):"",R=o&&(i||C==="partial"||C==="unavailable"||N);return s.jsx("form",{className:"chat-composer",onSubmit:u=>{u.preventDefault(),L()},children:s.jsxs("div",{className:"chat-composer-col",children:[s.jsx("label",{className:"vis-hidden",htmlFor:`${j}-draft`,children:f("board.chat.composer.reply")}),s.jsxs("div",{className:"chat-composer-input",children:[s.jsx("textarea",{ref:x,id:`${j}-draft`,className:"chat-composer-draft",rows:1,value:e,placeholder:f("board.chat.composer.placeholder"),"aria-describedby":`${j}-hint ${j}-status`,onChange:u=>{y(null),$(null),n(u.currentTarget.value)},onCompositionStart:()=>{l.current=!0},onCompositionEnd:()=>{l.current=!1},onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.ctrlKey||u.metaKey||u.altKey||l.current||u.nativeEvent.isComposing||u.nativeEvent.keyCode===229||(u.preventDefault(),u.repeat||L())}}),c&&m&&s.jsx("button",{className:"btn chat-composer-stop",type:"button",disabled:S,title:f("board.chat.stop.title"),"aria-label":f("board.chat.stop.title"),onClick:()=>{G()},children:f("board.chat.stop")}),s.jsx("button",{className:"btn primary chat-composer-send",type:"submit",disabled:A,children:f("board.chat.composer.send")})]}),s.jsx("span",{id:`${j}-hint`,className:"vis-hidden",children:f("board.chat.composer.hint")}),s.jsxs("div",{className:"chat-composer-meta",children:[s.jsx("p",{id:`${j}-status`,className:"chat-composer-status",role:"status","aria-live":"polite","aria-atomic":"true","data-result":w?`stop-${w}`:C??void 0,children:E}),R&&s.jsx("button",{className:"chat-composer-term",type:"button",onClick:o,children:f("board.chat.showTerm")})]})]})})}export{Qs as ChatComposer,Vs as ChatView,hs as DecisionCard,Xs as decisionKeyGroup,Ys as decisionStatusView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.dc-dock{box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:11px 16px 12px;background:var(--dock);border-top:1px solid var(--line-soft);color:var(--text);animation:dc-arrive var(--dur-base) var(--ease)}@keyframes dc-arrive{0%{opacity:0;transform:translateY(8px)}}@keyframes dc-swap{0%{opacity:0}}.dc-decision{display:grid;grid-template-columns:300px 24px minmax(0,460px);align-items:stretch;column-gap:0;row-gap:4px}.dc-dq{grid-column:1;grid-row:1;align-self:center;box-sizing:border-box;display:flex;flex-direction:column;gap:6px;min-width:0;padding:11px;background:var(--panel);border:1px solid var(--warn);border-radius:var(--r-node);box-shadow:var(--shadow-overlay)}.dc-dq[data-outcome=sent],.dc-dq[data-outcome=ended],.dc-dq[data-outcome=elsewhere]{border-color:var(--line)}.dc-title{margin:0;font-size:calc(16px + var(--ui-text-increase, 0px));line-height:20px;font-weight:600;color:var(--text)}.dc-cmd{display:block;box-sizing:border-box;padding:3px 7px;background:var(--sunken);border:1px solid var(--line-soft);border-radius:var(--r-ctl);font:400 13px/20px var(--font-mono);color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dc-plan{margin:0;padding:0;list-style:none;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--text)}.dc-plan-n{display:inline-block;min-width:16px;color:var(--muted);font-variant-numeric:tabular-nums}.dc-caption{margin:0;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted)}.dc-mono{font:400 12px/16px var(--font-mono);color:inherit}.dc-tree{grid-column:2;grid-row:1;position:relative;display:flex;flex-direction:column;gap:4px;color:var(--line)}.dc-stub{position:absolute;left:0;top:50%;width:12px;height:1px;background:currentColor}.dc-tick{position:relative;display:block;height:var(--row-option)}.dc-tick[data-typing]{height:calc(var(--row-option) + 10px + 34px + 16px)}.dc-tick:after{content:"";position:absolute;left:12px;width:12px;top:50%;height:1px;background:currentColor}.dc-tick+.dc-tick:before{content:"";position:absolute;left:12px;top:-4px;width:1px;height:calc(50% + 5px);background:currentColor}.dc-tick:not(:last-child){background:linear-gradient(currentColor,currentColor) 12px 100% / 1px 50% no-repeat}.dc-opts{grid-column:3;grid-row:1;display:flex;flex-direction:column;gap:4px;min-width:0}.dc-row{display:flex;flex-direction:column;gap:8px;min-width:0;border-radius:var(--r-panel)}.dc-opt{box-sizing:border-box;display:flex;align-items:center;gap:8px;min-height:var(--row-option);padding:3px 11px 3px 7px;background:var(--panel);border:1px solid var(--line-soft);border-radius:var(--r-panel);cursor:pointer;transition:color var(--dur-fast) var(--ease),border-color var(--dur-fast) var(--ease)}.dc-opt:focus{outline:none}.dc-opt[data-focus]{border-color:var(--accent);box-shadow:0 0 0 .5px var(--accent)}@media(hover:hover)and (pointer:fine){.dc-opt:hover:not([data-focus]):not([aria-disabled=true]){border-color:var(--line)}}.dc-chip{flex:none;box-sizing:border-box;min-width:20px;text-align:center;padding:1px 6px;background:var(--ctl-fill);border-radius:var(--r-ctl);font:400 11px/14px var(--font-mono);color:var(--text);font-variant-numeric:tabular-nums}.dc-opt-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}.dc-opt-label{font-size:calc(13px + var(--ui-text-increase, 0px));line-height:20px;font-weight:600;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dc-opt-sub{font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dc-lock{display:inline-flex;align-items:center;gap:4px}.dc-opt[data-locked]{background:none;border-style:dashed;cursor:default}.dc-opt[data-locked] .dc-opt-label{font-weight:500;color:var(--text-secondary)}.dc-pick{flex:none;font-size:calc(11px + var(--ui-text-increase, 0px));line-height:14px;color:var(--accent)}.dc-box{flex:none;position:relative;box-sizing:border-box;width:16px;height:16px;border:1.5px solid var(--muted);border-radius:var(--r-tag)}.dc-box[data-on]{background:var(--accent);border-color:var(--accent)}.dc-box[data-on]:after{content:"";position:absolute;left:4px;top:1px;width:4px;height:8px;border:solid var(--bg);border-width:0 1.5px 1.5px 0;transform:rotate(45deg)}.dc-opt[role=checkbox][data-checked]{border-color:var(--accent)}.dc-row[data-typing]{gap:10px;padding:0 0 16px;background:var(--panel);box-shadow:inset 0 0 0 1.5px var(--accent)}.dc-row[data-typing] .dc-opt{border-color:transparent;box-shadow:none}.dc-field{position:relative;display:flex;align-items:center;padding:0 15px 0 36px}.dc-input{flex:1 1 auto;min-width:0;box-sizing:border-box;height:34px;padding:0 56px 0 10px;background:var(--bg);border:1px solid var(--line);border-radius:var(--r-ctl);font:inherit;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--text);caret-color:var(--accent)}.dc-send{position:absolute;right:24px;top:50%;transform:translateY(-50%);pointer-events:none;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;font-weight:500;color:var(--accent)}.dc-dock[data-outcome=checking] .dc-opt[aria-checked=false],.dc-dock[data-outcome=sent] .dc-opt[aria-checked=false]{pointer-events:none}.dc-dock[data-mode=readOnly] .dc-opt{cursor:default}.dc-out-empty{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.dc-out{grid-column:3;grid-row:2;box-sizing:border-box;display:flex;align-items:flex-start;gap:8px;padding:11.5px 12px;background:var(--panel);border:1px solid var(--line-soft);border-radius:var(--r-panel);box-shadow:var(--shadow-contact);animation:dc-swap var(--dur-fast) var(--ease)}.dc-out[data-kind=checking]{animation-delay:var(--delay-loader);animation-fill-mode:backwards}.dc-out-glyph{flex:none;display:inline-flex;margin-top:.5px;color:var(--muted)}.dc-err{display:inline-flex;color:var(--err)}.dc-out-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}.dc-out-title{font-size:calc(13px + var(--ui-text-increase, 0px));line-height:20px;font-weight:600;color:var(--text)}.dc-out-title[data-tone=ok]{color:var(--ok)}.dc-out .dc-link{margin-top:19.5px}.dc-out-sub{font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted)}.dc-foot{display:flex;align-items:center;gap:12px;min-height:20px;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted)}.dc-foot-pick{flex:none;display:inline-flex;align-items:center;gap:4px}.dc-foot-note{flex:1 1 auto;min-width:0;display:inline-flex;align-items:center;gap:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dc-link{flex:none;display:inline-flex;align-items:center;gap:4px;margin:0;padding:0;background:none;border:0;font:inherit;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;font-weight:500;color:var(--accent);cursor:pointer}@media(hover:hover)and (pointer:fine){.dc-link:hover{text-decoration:underline}}.dc-dock[data-size=phone] .dc-decision{display:flex;flex-direction:column;gap:8px}.dc-dock[data-size=phone] .dc-tree{display:none}.dc-dock[data-size=phone] .dc-opt{min-height:62px}.dc-dock[data-size=phone] .dc-chip{padding:1px 6px}.dc-dock[data-size=phone] .dc-foot{flex-wrap:wrap}.dc-dock[data-size=phone] .dc-dq{align-self:stretch;max-width:100%}@media(max-width:640px){.dc-dock{max-height:60%;overflow-y:auto;overscroll-behavior:contain}.dc-decision{max-width:100%}.dc-dq{align-self:stretch;max-width:100%}.dc-link{min-height:44px}.dc-input{height:44px}}@media(forced-colors:active){.dc-opt:focus-visible,.dc-opt[data-focus]{outline:var(--focus-w) solid Highlight;outline-offset:calc(-1 * var(--focus-w))}.dc-opt[data-checked],.dc-opt[role=checkbox][data-checked]{border-color:Highlight;border-width:2px}.dc-box[data-on]{background:Highlight;border-color:Highlight;forced-color-adjust:none}.dc-box[data-on]:after{border-color:HighlightText}.dc-opt[data-locked]{border-style:dashed;border-color:GrayText;color:GrayText}.dc-opt[data-locked] .dc-opt-label{color:GrayText}.dc-input:focus-visible{outline:var(--focus-w) solid Highlight;outline-offset:calc(-1 * var(--focus-w))}}.ts-body>.dc-dock{position:absolute;left:0;right:0;bottom:0;z-index:1}@media(prefers-reduced-motion:reduce){.dc-dock{animation-name:dc-swap;animation-duration:var(--dur-fast)}.dc-opt{transition:none}.dc-out{animation:none}}.chat{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;background:var(--bg);color:var(--text);position:relative;container:chat-pane / inline-size}.chat-body{flex:1 1 auto;min-height:0;overflow-y:auto;box-sizing:border-box;padding:24px 28px 32px;scrollbar-gutter:stable;overscroll-behavior:contain}.chat-reading{position:relative;display:flex;flex:1 1 0;min-height:0}.chat-col{display:flex;flex-direction:column;gap:24px;max-width:776px;margin:0 auto;min-width:0}.chat-since{display:flex;align-items:center;gap:12px;min-height:16px;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted)}.chat-since-line{flex:1 1 0;height:1px;background:var(--line-soft)}.chat-since-text{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-you{display:flex;flex-direction:column;align-items:flex-end;gap:6px}.chat-author{color:var(--text-secondary);font-size:calc(12px + var(--ui-text-increase, 0px));line-height:18px}.chat-you-text{margin:0;box-sizing:border-box;max-width:min(100%,640px);padding:8px 12px;background:var(--your-message);border-radius:var(--r-overlay) var(--r-overlay) var(--r-tag) var(--r-overlay);font-size:calc(13px + var(--ui-text-increase, 0px));line-height:1.5;color:var(--text);overflow-wrap:anywhere;white-space:pre-wrap}.chat-you-images{display:inline-flex;align-items:center;gap:6px;max-width:100%;padding:1px 8px;border-radius:var(--r-tag);background:var(--ctl-fill);color:var(--text-secondary);font-size:calc(12px + var(--ui-text-increase, 0px));line-height:20px}.chat-you-images-mark{flex:none;display:inline-flex;color:var(--muted)}.chat-command-line{margin:0;box-sizing:border-box;max-width:min(100%,640px);padding:8px 12px;background:var(--your-message);border-radius:var(--r-overlay) var(--r-overlay) var(--r-tag) var(--r-overlay);color:var(--text);font:calc(12px + var(--ui-text-increase, 0px))/1.6 var(--font-mono);overflow-wrap:anywhere;white-space:pre-wrap}.chat-command-output{box-sizing:border-box;max-width:min(100%,640px);max-height:160px;margin:0;padding:8px 10px;overflow-y:auto;overscroll-behavior:contain;border-radius:var(--r-ctl);background:var(--sunken);color:var(--text-secondary);font:calc(12px + var(--ui-text-increase, 0px))/1.6 var(--font-mono);white-space:pre-wrap;overflow-wrap:anywhere}.chat-command-output[data-failed]{color:var(--warn)}.chat-command-line code,.chat-command-output code{font:inherit}.chat-said{margin:0;max-width:640px;font-size:calc(13px + var(--ui-text-increase, 0px));line-height:1.65;color:var(--text);overflow-wrap:anywhere;min-width:0}.chat-response{min-width:0}.chat-response-author{display:flex;align-items:center;gap:8px;margin-bottom:8px;color:var(--text-secondary);font-size:calc(12px + var(--ui-text-increase, 0px));line-height:20px;font-weight:500}.chat-response-content{display:flex;flex-direction:column;gap:16px;padding-left:28px;min-width:0}.chat-response-author .chat-copy{margin-left:auto;color:var(--text-secondary)}.chat-markdown>:first-child{margin-top:0}.chat-markdown>:last-child{margin-bottom:0}.chat-markdown p{margin:0 0 12px;white-space:pre-wrap}.chat-markdown h2,.chat-markdown h3,.chat-markdown h4{margin:20px 0 8px;font-size:inherit;line-height:1.5;font-weight:600}.chat-markdown ul,.chat-markdown ol{margin:8px 0 12px;padding-left:22px}.chat-markdown li{margin:4px 0}.chat-markdown code{font-family:var(--font-mono);font-size:.92em}.chat-markdown :not(pre)>code{padding:1px 4px;border-radius:var(--r-tag);background:var(--ctl-fill);color:var(--text);white-space:break-spaces}.chat-markdown pre{box-sizing:border-box;max-width:100%;overflow-x:auto;margin:12px 0;padding:12px;border:1px solid var(--line);border-radius:var(--r-ctl);background:var(--sunken);line-height:1.6;white-space:pre;overflow-wrap:normal}.chat-markdown pre code{white-space:inherit}.chat-markdown blockquote{margin:12px 0;padding-left:12px;border-left:2px solid var(--line);color:var(--text-secondary)}.chat-markdown a{color:var(--accent);text-decoration:underline;text-underline-offset:2px}.chat-tool{box-sizing:border-box;display:flex;align-items:center;gap:6px;min-height:max(var(--row-tool),32px);padding:0 8px;border-radius:var(--r-ctl);min-width:0;font:400 calc(12px + var(--ui-text-increase, 0px))/1.5 var(--font-sans);color:var(--text-secondary);list-style:none}.chat-tool-call>.chat-tool{cursor:pointer}.chat-tool-call{min-width:0}.chat-tool::-webkit-details-marker,.chat-activity-head::-webkit-details-marker{display:none}.chat-disclosure{flex:none;display:inline-flex;color:var(--text-secondary)}.chat-tool-call[open]>.chat-tool .chat-disclosure,.chat-activity[open]>.chat-activity-head .chat-disclosure{transform:rotate(90deg)}.chat-tool-input{margin:0 8px 8px 30px;padding:8px 10px;border-radius:var(--r-ctl);background:var(--sunken);color:var(--text);font:calc(12px + var(--ui-text-increase, 0px))/1.6 var(--font-mono);white-space:pre-wrap;overflow-wrap:anywhere}.chat-activity{min-width:0;border:0;border-radius:var(--r-ctl)}.chat-activity-head{display:flex;align-items:center;gap:6px;min-height:32px;padding:4px 8px;box-sizing:border-box;border-radius:var(--r-ctl);list-style:none;cursor:pointer;color:var(--text-secondary);font-size:calc(12px + var(--ui-text-increase, 0px));line-height:20px}.chat-activity-running{margin-left:auto;color:var(--text-secondary);font-size:calc(11px + var(--ui-text-increase, 0px))}.chat-activity-calls{margin:0 0 4px 14px;padding:0 0 0 4px;border-left:1px solid var(--line)}.chat-tool:focus-visible,.chat-activity-head:focus-visible{outline:var(--focus-w) solid var(--accent);outline-offset:calc(-1 * var(--focus-w))}@media(hover:hover)and (pointer:fine){.chat-tool:hover,.chat-activity-head:hover{background:var(--ctl-fill)}.chat-tool:is(.chat-todo-line,.chat-agent):hover{background:transparent}}.chat-tool-mark{flex:none;display:inline-flex;color:var(--muted)}.chat-tool-name{flex:none;font-weight:500;color:var(--text-secondary)}.chat-tool-arg{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-mono)}.chat-tool-note{flex:none;margin-left:auto;padding-left:8px;white-space:nowrap;font-variant-numeric:tabular-nums}.chat-tool[data-running] .chat-tool-note{color:var(--inflight)}.chat-latest{position:absolute;bottom:16px;left:50%;transform:translate(-50%);max-width:calc(100% - 24px);background:var(--panel)}.chat-empty{margin:0;color:var(--text-secondary);font-size:calc(13px + var(--ui-text-increase, 0px))}.chat-record{margin:0;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:1.5;color:var(--muted);white-space:pre-wrap}.chat-tool-toggle{width:100%;margin:0;border:0;background:transparent;text-align:left;cursor:pointer}.chat-tool-toggle[aria-expanded=true] .chat-disclosure{transform:rotate(90deg)}.chat-tool-failed{flex:none;margin-left:auto;padding-left:8px;white-space:nowrap;color:var(--warn)}.chat-tool-note+.chat-tool-failed{margin-left:0}.chat-tool-declined{flex:none;margin-left:auto;padding-left:8px;white-space:nowrap;color:var(--muted)}.chat-activity-failed{color:var(--warn);font-size:calc(11px + var(--ui-text-increase, 0px))}.chat-tool-detail{min-width:0}.chat-tool-error{margin:0 8px 8px 30px;padding:8px 10px;max-height:240px;overflow-y:auto;overscroll-behavior:contain;border-radius:var(--r-ctl);background:var(--sunken);color:var(--text);font:calc(12px + var(--ui-text-increase, 0px))/1.6 var(--font-mono);white-space:pre-wrap;overflow-wrap:anywhere}.chat-diff{box-sizing:border-box;max-height:360px;margin:0 8px 8px 30px;padding:6px 0;overflow:auto;overscroll-behavior:contain;border-radius:var(--r-ctl);background:var(--sunken);color:var(--text);font:calc(12px + var(--ui-text-increase, 0px))/1.6 var(--font-mono);white-space:pre}.chat-diff code{display:block;width:max-content;min-width:100%}.chat-diff-line{display:block;padding:0 10px}.chat-diff-line[data-op=add]{background:color-mix(in srgb,var(--ok) 14%,transparent)}.chat-diff-line[data-op=del]{background:color-mix(in srgb,var(--err) 14%,transparent)}.chat-diff-line[data-op=gap]{color:var(--muted)}.chat-diff-cut{margin:-4px 8px 8px 30px;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted)}.chat-todo-line{color:var(--muted)}.chat-todo-line-text{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-todo{display:flex;flex-direction:column;gap:6px;max-width:640px;min-width:0}.chat-todo-head{padding:0 8px;color:var(--text-secondary);font-size:calc(12px + var(--ui-text-increase, 0px));line-height:18px;font-weight:500}.chat-todo-list{display:flex;flex-direction:column;gap:2px;min-width:0;margin:0;padding:0;list-style:none}.chat-todo-item{display:flex;align-items:flex-start;gap:8px;min-width:0;padding:2px 8px;color:var(--text);font-size:calc(13px + var(--ui-text-increase, 0px));line-height:20px}.chat-todo-mark{flex:none;display:inline-flex;margin-top:4px;color:var(--muted)}.chat-todo-text{min-width:0;overflow-wrap:anywhere}.chat-todo-item[data-status=done]{color:var(--muted)}.chat-todo-item[data-status=active]{font-weight:500}.chat-todo-item[data-status=active] .chat-todo-mark{color:var(--accent)}.chat-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.chat-response-content>.chat-agent+.chat-agent{margin-top:-16px}.chat-agent-desc{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-agent-state{flex:none;margin-left:auto;padding-left:8px;white-space:nowrap;color:var(--muted)}.chat-agent[data-state=running] .chat-agent-state{color:var(--inflight)}.chat-agent[data-state=failed] .chat-agent-state{color:var(--warn)}.chat-notice{margin:0;padding:0 8px;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:1.5;color:var(--muted);overflow-wrap:anywhere}.chat-notice[data-what=error]{color:var(--warn)}.chat-error{display:flex;align-items:center;gap:12px;padding:8px 12px;border:1px solid var(--line);border-radius:var(--r-panel);background:var(--bg-soft);font-size:calc(12px + var(--ui-text-increase, 0px));line-height:1.5;color:var(--text)}.chat-error>span{min-width:0;overflow-wrap:anywhere}.chat-retry{flex:none;min-height:28px;margin:0 0 0 auto;padding:0;background:none;border:0;border-radius:var(--r-ctl);font:inherit;font-weight:500;color:var(--accent);cursor:pointer}.chat-retry:focus-visible{outline:var(--focus-w) solid var(--accent);outline-offset:calc(-1 * var(--focus-w))}@media(hover:hover)and (pointer:fine){.chat-retry:hover{text-decoration:underline}}.chat-older{align-self:center;margin:0}.chat-older[aria-busy]{color:var(--text-secondary);cursor:progress}.chat-ask{box-sizing:border-box;display:flex;flex-direction:column;gap:12px;max-width:640px;min-width:0;padding:11px 12px 12px;border:1px solid var(--line);border-radius:var(--r-panel);background:var(--panel);font-size:calc(13px + var(--ui-text-increase, 0px));line-height:1.5;color:var(--text)}.chat-ask[data-state=waiting]{border-color:var(--warn)}.chat-ask-head{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 8px;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:18px}.chat-ask-title{font-weight:600;color:var(--text)}.chat-ask-state{margin-left:auto;color:var(--muted)}.chat-ask[data-state=waiting] .chat-ask-state{color:var(--warn)}.chat-plan .chat-plan-text{max-height:360px;overflow-y:auto;overscroll-behavior:contain}.chat-plan-cut{margin:0;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted)}.chat-ask-form{display:flex;flex-direction:column;gap:12px;min-width:0;margin:0}.chat-ask-q{display:flex;flex-direction:column;gap:6px;min-width:0}.chat-ask-meta{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:calc(11px + var(--ui-text-increase, 0px));line-height:16px}.chat-ask-tag{padding:1px 6px;border-radius:var(--r-tag);background:var(--ctl-fill);color:var(--text-secondary)}.chat-ask-multi{color:var(--muted)}.chat-ask-question{margin:0;font-weight:500;white-space:pre-wrap;overflow-wrap:anywhere}.chat-ask-options{display:flex;flex-direction:column;gap:4px;min-width:0;margin:0;padding:0;list-style:none}.chat-ask-option{box-sizing:border-box;display:flex;align-items:flex-start;gap:8px;min-width:0;padding:5px 8px;border:1px solid var(--line-soft);border-radius:var(--r-panel)}.chat-ask-option[data-chosen]{border-color:var(--accent)}.chat-ask-n{flex:none;box-sizing:border-box;min-width:20px;margin-top:2px;padding:1px 6px;border-radius:var(--r-ctl);background:var(--ctl-fill);text-align:center;font:400 11px/14px var(--font-mono);font-variant-numeric:tabular-nums;color:var(--text)}.chat-ask-option-text{flex:1 1 auto;display:flex;flex-direction:column;min-width:0}.chat-ask-option-label{font-weight:600;line-height:20px;overflow-wrap:anywhere}.chat-ask-option-note{font-size:calc(12px + var(--ui-text-increase, 0px));line-height:16px;color:var(--muted);overflow-wrap:anywhere}.chat-ask-chosen{flex:none;display:inline-flex;align-items:center;gap:4px;font-size:calc(11px + var(--ui-text-increase, 0px));line-height:20px;color:var(--accent)}.chat-ask-choice{flex-wrap:wrap;padding:0;border-color:var(--line)}.chat-ask-pick{flex:1 1 100%;display:flex;align-items:flex-start;gap:8px;min-width:0;padding:5px 8px;border-radius:inherit;cursor:pointer}.chat-ask-pick input{flex:none;width:14px;height:14px;margin:3px 0 0;accent-color:var(--accent);cursor:inherit}.chat-ask-pick input:focus-visible{outline:var(--focus-w) solid var(--accent);outline-offset:calc(-1 * var(--focus-w))}.chat-ask-choice:focus-within{border-color:var(--accent)}.chat-ask-form[data-locked] .chat-ask-pick{cursor:default}.chat-ask-pick .chat-ask-chosen{margin-left:auto}.chat-ask-other .chat-ask-option-label{font-weight:500;color:var(--text-secondary)}.chat-ask-text{box-sizing:border-box;flex:1 1 100%;min-width:0;min-height:32px;margin:0 8px 6px 30px;padding:5px 8px;border:1px solid var(--ctl-edge);border-radius:var(--r-ctl);background:var(--bg-soft);color:var(--text);caret-color:var(--accent);font:inherit}.chat-ask-text::placeholder{color:var(--text-secondary);opacity:1}.chat-ask-text:focus-visible{outline:none;border-color:var(--accent)}.chat-ask-text:disabled{border-color:var(--line);background:transparent;color:var(--text);cursor:default}.chat-ask-actions{display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;min-width:0}.chat-ask .chat-ask-send{flex:none;min-height:32px;font-weight:600}.chat-ask-status{flex:1 1 180px;min-width:0;margin:0;font-size:calc(12px + var(--ui-text-increase, 0px));line-height:1.5;color:var(--text-secondary);overflow-wrap:anywhere}.chat-ask-status:empty{flex:0}.chat-ask-status[data-result=changed],.chat-ask-status[data-result=partial],.chat-ask-status[data-result=unavailable]{color:var(--warn)}.chat-ask-term{flex:none;min-height:28px;padding:2px 0;border:0;border-radius:var(--r-ctl);background:transparent;color:var(--text-secondary);font:inherit;font-size:calc(12px + var(--ui-text-increase, 0px));text-decoration:underline;text-underline-offset:3px;cursor:pointer}.chat-ask-term:focus-visible{outline:var(--focus-w) solid var(--accent);outline-offset:calc(-1 * var(--focus-w))}.chat-ask-answer{margin:0;font-size:calc(12px + var(--ui-text-increase, 0px));white-space:pre-wrap;overflow-wrap:anywhere}.chat-ask-answer-label{margin-right:6px;color:var(--muted)}@media(hover:hover)and (pointer:fine){.chat-ask-form:not([data-locked]) .chat-ask-choice:not([data-chosen]):hover{border-color:var(--ctl-edge)}.chat-ask-term:hover{color:var(--text)}}.chat[data-docked] .chat-body{flex:1 1 0}@container chat-pane (max-width: 480px){.chat-body{padding:16px 12px 24px}.chat-response-content{padding-left:0}.chat-tool{flex-wrap:wrap}.chat-tool-note{max-width:100%;white-space:normal}.chat-tool.chat-agent{flex-wrap:nowrap}}@media(pointer:coarse){.chat-tool,.chat-activity-head,.chat-latest{min-height:44px}.chat-response-author .chat-copy{min-width:44px;min-height:44px}.chat-retry,.chat-ask-pick,.chat-ask .chat-ask-send,.chat-ask-term,.chat-ask-text{min-height:44px}.chat-ask-pick{align-items:center}.chat-ask-pick input{margin-top:0}}.ts-body>.chat{position:absolute;top:0;right:0;bottom:0;left:0}.ts-body[data-view=chat] .ts-host{visibility:hidden;opacity:0;animation:none;transition:none}.chat-composer{display:block;box-sizing:border-box;flex:none;min-width:0;width:100%;margin:0;padding:10px 28px 12px;background:var(--bg);color:var(--text);font:400 calc(13px + var(--ui-text-increase, 0px))/1.5 var(--font-sans)}.chat-composer-col{max-width:776px;min-width:0;margin-inline:auto}.chat-composer-input{display:flex;align-items:flex-end;gap:8px;min-width:0;padding:4px;border:1px solid var(--ctl-edge);border-radius:var(--r-panel);background:var(--bg-soft)}.chat-composer-input:focus-within{border-color:var(--text-secondary)}.chat-composer-draft{display:block;box-sizing:border-box;flex:1 1 0;min-width:0;width:100%;min-height:44px;max-height:calc(6lh + 20px);padding:11px 8px;overflow-y:auto;resize:none;border:0;border-radius:var(--r-ctl);background:transparent;color:var(--text);caret-color:var(--accent);font:inherit;scrollbar-color:var(--ctl-edge) var(--bg-soft)}.chat-composer-draft::placeholder{color:var(--text-secondary);opacity:1}.chat-composer-send,.chat-composer-term{box-sizing:border-box;border-radius:var(--r-ctl);font:inherit;cursor:pointer}.chat-composer button.chat-composer-send{align-self:flex-end;flex:none;min-width:58px;min-height:36px;height:auto;margin:4px 0;padding:6px 10px;background:var(--bg);font:inherit;font-weight:600}.chat-composer-send:disabled{opacity:.5;cursor:default}.chat-composer button.chat-composer-stop{box-sizing:border-box;align-self:flex-end;flex:none;min-height:36px;height:auto;margin:4px 0;padding:6px 10px;border-radius:var(--r-ctl);font:inherit;font-weight:500}.chat-composer-draft:focus-visible{outline:none}.chat-composer-send:focus-visible,.chat-composer-stop:focus-visible,.chat-composer-term:focus-visible{outline:var(--focus-w) solid var(--accent);outline-offset:calc(-1 * var(--focus-w))}.chat-composer-meta{display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;color:var(--text-secondary);font-size:calc(11px + var(--ui-text-increase, 0px));line-height:1.5}.chat-composer-term{flex:none;min-height:28px;margin-top:4px;padding:2px 0;border:0;background:transparent;color:var(--text-secondary);text-decoration:underline;text-underline-offset:3px}.chat-composer-status{flex:1 1 180px;min-width:0;margin:6px 0 0;color:var(--text-secondary);overflow-wrap:anywhere}.chat-composer-status:empty{flex:0;margin:0}.chat-composer-status[data-result=partial],.chat-composer-status[data-result=too-large],.chat-composer-status[data-result=unavailable],.chat-composer-status[data-result=empty],.chat-composer-status[data-result=stop-partial],.chat-composer-status[data-result=stop-unavailable]{color:var(--warn)}@media(hover:hover)and (pointer:fine){.chat-composer-send:hover:not(:disabled){border-color:var(--accent);background:var(--bg-soft)}.chat-composer-term:hover{color:var(--text)}}@container ts-bar (max-width: 480px){.chat-composer{padding:8px 12px 10px}}@container ts-bar (max-width: 390px){.chat-composer-draft{font-size:max(16px,calc(13px + var(--ui-text-increase, 0px)))}}@media(pointer:coarse){.chat-composer button.chat-composer-send,.chat-composer button.chat-composer-stop{min-height:44px;margin-block:0}.chat-composer-term{min-height:44px}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{bN as G,bO as U,bP as W,t as i,bQ as O,bp as p,aG as j,bR as H,bS as V,bT as B,bU as z,bV as X,ay as J,bW as K,az as M,bX as S,bY as C,bZ as I,b_ as q}from"./app-CXxFM7fY.js";const m=14,Z=18,Q=24,A=12,Y=26,ee=24,x=7,T=50,te=22,R=25,$=5,ne=8,se=168,oe=360;function ae(e,n){return n==="rail"||e<=0?x*2+T:x+T+$+(e-1)*R+te+ne}function Pe(e){return e.replace(/^(\d+m) \d+s$/,"$1")}function re(e,n){if(n==="rail")return[];const t=[];for(let o=0;o<e;o++)t.push(x+T+$+o*R);return t}function ie(e){return Math.max(1,Math.floor((e-m*2+A)/(se+A)))}function ve(e,n,t){const o=new Map([...new Set(e.map(u=>u.col))].sort((u,c)=>u-c).map((u,c)=>[u,c])),a=e.map((u,c)=>({c:u,boardCol:o.get(u.col),order:u.order??c,i:c})).sort((u,c)=>u.boardCol-c.boardCol||u.order-c.order||u.i-c.i),s=o.size;let r=0,l=Math.max(1,s);if(t==="rail")for(;l>1;)l=Math.ceil(l/2),r+=1;else{const u=ie(n);for(;l>u;)l=Math.ceil(l/2),r+=1}const d=t==="rail"?Math.max(0,Math.floor(n-m*2)):Math.max(0,Math.min(oe,Math.floor((n-m*2-A*(l-1))/l))),g=t==="rail"?ee:Y,h=Array.from({length:l},()=>Z),b=Array.from({length:l},()=>[]);for(const{c:u,boardCol:c}of a){const f=t==="rail"?0:c>>r,E=ae(u.rows,t);b[f].push({sessionId:u.sessionId,col:f,boardCol:c,x:m+f*(d+A),y:h[f],w:d,h:E,rows:re(u.rows,t)}),h[f]+=E+g}const k=b.flat(),D=Math.max(0,...k.map(u=>u.y+u.h));return{density:t,columns:l,merges:r,width:n,height:k.length?D+Q:0,tileW:d,tiles:k}}function le(e){const n=[...e].sort((a,s)=>a.x-s.x||a.y-s.y),t=[];let o=-1/0;for(const a of n)t.length===0||a.x>=o?(t.push([a]),o=a.x+a.w):(t[t.length-1].push(a),o=Math.max(o,a.x+a.w));return t.flatMap((a,s)=>[...a].sort((r,l)=>r.y-l.y||r.x-l.x).map((r,l)=>({sessionId:r.sessionId,col:s,order:l})))}function Le(e,n,t){var l;const o=e.tiles.find(d=>d.sessionId===n);if(!o)return null;if(t==="up"||t==="down"){const d=e.tiles.filter(h=>h.col===o.col),g=d.indexOf(o)+(t==="down"?1:-1);return((l=d[g])==null?void 0:l.sessionId)??null}const a=o.col+(t==="right"?1:-1),s=o.y+o.h/2;let r=null;for(const d of e.tiles)d.col===a&&(!r||Math.abs(d.y+d.h/2-s)<Math.abs(r.y+r.h/2-s))&&(r=d);return(r==null?void 0:r.sessionId)??null}function Oe(e){const n=new Map,t=new Map;for(const a of e){if(a.type!=="agent")continue;const s=a.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;if(s.kind==="root"){n.set(s.sessionId,s);continue}const r=t.get(s.sessionId)??[];r.push({d:s,x:a.position.x,y:a.position.y}),t.set(s.sessionId,r)}const o=new Map;for(const a of new Set([...n.keys(),...t.keys()])){const s=(t.get(a)??[]).sort((r,l)=>r.y-l.y||r.x-l.x);o.set(a,{sessionId:a,root:n.get(a)??null,subs:s.map(r=>r.d)})}return o}function Re(e,n){if(e.size!==n.size)return!1;for(const[t,o]of e){const a=n.get(t);if(!a||o.root!==a.root||o.subs.length!==a.subs.length)return!1;for(let s=0;s<o.subs.length;s++)if(o.subs[s]!==a.subs[s])return!1}return!0}function $e(e,n){return le(e).map(({sessionId:t,col:o,order:a})=>{var s;return{sessionId:t,col:o,order:a,rows:((s=n.get(t))==null?void 0:s.subs.length)??0}})}const y={sayWaiting:G,describeCall:e=>({name:W(e.name).label,subject:U(e.name,e.input)})};function Fe(e){return O(e,e.kind==="root"?e.branch:void 0,y)}function De(e){return e===0?i("board.nav.none"):i("board.hosts.sessions",{count:e})}function w(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return Math.abs(n)%360}const ue=3e3;function Ge(e,n){return e.exitStatus===0&&e.exitSignal===void 0&&n>=ue}function de(e){return e.kind==="live"||e.kind==="ended"||e.kind==="detached"||e.kind==="attaching"&&e.reconnect}function ce(e,n){return de(n)?"shown":n.kind==="attaching"&&e!=="hidden"?"held":"hidden"}function Ue(e,n){const t=ce(e.state,n),o=t==="shown"&&(e.state==="held"||e.state==="shown"&&e.afterHold);return{state:t,afterHold:o}}function We(e,n){return e.kind==="starting"||e.kind==="attaching"&&n==="hidden"}function je(e){return e.kind==="live"&&!e.readOnly}function _(e){return H(Math.max(0,Math.floor(e/1e3)))}function he(e,n){if(e.closedAt!=null){const t=p(n-e.closedAt);return{state:"ended",phrase:t===i("common.ago.now")?i("board.stage.phrase.endedJustNow"):i("board.stage.phrase.endedAgo",{ago:t})}}if(e.waiting)return{state:"waiting",phrase:i("board.queue.waiting"),emphasis:_(n-e.waiting.since),...e.waiting.tool?{tool:e.waiting.tool}:{},...e.waiting.detail?{arg:e.waiting.detail}:{}};if(e.yourTurn&&!e.tool){if(e.fresh)return{state:"ready",phrase:i("board.stage.phrase.ready"),arg:i("board.stage.phrase.firstPrompt")};const t=e.lastTurnEndAt!=null?p(n-e.lastTurnEndAt):null;return{state:"idle",phrase:i("board.list.yourTurn"),...t?{arg:N(t)}:{}}}if(e.fresh&&!e.tool&&!e.subagentsLive)return{state:"ready",phrase:i("board.stage.phrase.ready"),arg:i("board.stage.phrase.firstPrompt")};if(e.active){const t={state:"working",phrase:i("board.stage.phrase.working")};return e.tool?(t.tool=e.tool.name,e.tool.subject&&(t.arg=e.tool.subject),e.tool.startedAt!=null&&(t.seconds=j(e.tool.startedAt,void 0,n))):e.subagentsLive&&(t.arg=i("board.stage.subagentsRunning",{count:e.subagentsLive})),t}return e.fresh?{state:"ready",phrase:i("board.stage.phrase.ready"),arg:i("board.stage.phrase.firstPrompt")}:e.lastTurnEndAt!=null?{state:"idle",phrase:i("board.stage.phrase.idle"),arg:N(p(n-e.lastTurnEndAt))}:{state:"idle",phrase:i("board.stage.phrase.idle")}}function N(e){return e===i("common.ago.now")?i("board.stage.phrase.lastTurnNow"):i("board.stage.phrase.lastTurn",{ago:e})}const ge="board.stage.reconnectNote";function He(e,n){switch(n.kind){case"empty":return{state:"none",phrase:""};case"attaching":return n.reconnect?{state:"attaching",phrase:i("board.stage.phrase.reconnecting"),arg:i(ge)}:{state:"attaching",phrase:i("board.stage.attaching")};case"starting":return{state:"starting",phrase:i("board.stage.phrase.starting"),arg:n.cwd};case"tmux-installing":return{state:"starting",phrase:i("board.stage.settingUpTmux")};case"tmux-missing":return{state:"detached",phrase:i("board.stage.phrase.notAttached")};case"error":return n.code?{state:"detached",phrase:i("board.stage.phrase.notAttached")}:e??{state:"none",phrase:""};case"not-attachable":if(n.target.kind==="C"&&e&&e.state!=="ended"){const{tool:t,arg:o}=e;return{state:"elsewhere",phrase:i(pe(e.state)),...t?{tool:t}:{},...o?{arg:o}:{}}}return e??{state:"ended",phrase:i("board.stage.phrase.ended")};case"ended":return(e==null?void 0:e.state)==="ended"?e:{state:"ended",phrase:n.atOpen?i("board.stage.phrase.ended"):i("board.stage.phrase.endedJustNow")};default:return e??{state:"none",phrase:""}}}function Ve(e,n,t){return n.kind==="live"&&t&&e.state!=="waiting"}const Be="board.stage.launchedUnreachable",ze="board.stage.provenanceUnknown";function fe(e,n){return e.kind==="C"&&n.windows===!0&&(n.launched===!0||e.provenance==="panel")}function Xe(e,n){return e.kind==="C"&&n.windows===!0&&!fe(e,n)&&e.provenance==="unknown"}function Je(e){switch(e){case"idle":case"ready":return"board.stage.elsewhere.idle";case"waiting":return"board.stage.elsewhere.waiting";case"working":return"board.stage.elsewhere.working";default:return"board.stage.elsewhere.running"}}function pe(e){return e==="working"?"board.stage.phrase.workingElsewhere":e==="idle"||e==="ready"||e==="waiting"?"board.stage.phrase.waitingElsewhere":"board.stage.phrase.elsewhere"}function Ke(e,n){switch(n.kind){case"live":return i("board.stage.announceLive",{name:e});case"ended":return i("board.stage.announceEnded",{name:e});case"detached":return i("board.stage.announceDetached",{name:e});case"not-attachable":return n.stillRunning?i("board.stage.announceStillRunning",{name:e}):i("board.stage.announceNoPane",{name:e});case"tmux-installing":return i("board.stage.announceTmuxSetup");case"tmux-missing":return i("board.stage.announceTmuxMissing");case"error":return n.missing==="claude"?i(be):Ae(n.message);default:return null}}const be="board.stage.claudeMissing",me="board.stage.panelStopped",we=new Set(["That is not a session id.","The provider must be claude or codex."]);function Ae(e){return we.has(e.trim())?i(me):e}function qe(e){return e?i("board.stage.closedNamed",{name:e}):i("board.stage.closed")}function ke(e){return/^\//.test(e)||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(e)}function F(e){const n=e.split(/[\\/]+/).filter(Boolean);return n.length?n[n.length-1]:e}function xe(e,n){const t=new Map;for(const s of e){if(!s.cwd||!ke(s.cwd))continue;const r=t.get(s.cwd);(!r||s.at>r.at)&&t.set(s.cwd,s)}const o=[...t.values()].sort((s,r)=>r.at-s.at),a=n?o.findIndex(s=>s.cwd===n):-1;return a>0&&o.unshift(...o.splice(a,1)),o.map(s=>({cwd:s.cwd,name:s.name||F(s.cwd),hue:s.hue,at:s.at}))}function Ze(e,n=24){if(e.length<=n)return e;const t=e.split(/[\\/]+/).filter(Boolean),o=t.slice(-2).join("/");if(o.length+2<=n)return`…/${o}`;const a=t[t.length-1]??e;return a.length+2<=n?`…/${a}`:`…/${a.slice(0,Math.max(1,n-3))}…`}function Te(e){return e==="codex"?"Codex":"Claude Code"}function Qe(e){return e==="codex"?"Codex":"Claude"}const ye=160,_e=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e;function P(e){var t;const n=((t=(e??"").split(`
|
|
2
|
+
`).find(o=>o.trim()!==""))==null?void 0:t.trim())??"";return n?_e(n,ye):null}function Ee(e,n){const t=[];for(const o of e)o.sessionId===n&&o.kind==="subagent"&&t.push(o);return t}function Me(e,n){var a,s;const t=e.waiting;let o=null;if(e.state==="active")for(let r=e.tools.length-1;r>=0;r--){const l=e.tools[r];if(l.endedAt!=null)continue;const d=y.describeCall(l);o={name:d.name,subject:d.subject??null,startedAt:l.startedAt};break}return{closedAt:e.closedAt??null,waiting:t&&J(t)?{since:t.since,...(a=t.tool)!=null&&a.name?{tool:t.tool.name}:{},...(s=t.tool)!=null&&s.preview?{detail:t.tool.preview}:{}}:null,active:e.state==="active",tool:o,subagentsLive:n.filter(r=>r.state==="active").length,lastTurnEndAt:e.lastTurnEndAt??null,fresh:e.prompts.length===0&&!e.firstPrompt&&e.lastTurnEndAt==null,yourTurn:(t==null?void 0:t.kind)==="idle"}}function Se(e){const{used:n,limit:t}=K(e);return{used:n,window:t}}const v=32,L=e=>e.length>v?`${e.slice(0,v-1).trimEnd()}…`:e;function Ce(e,n){const{title:t}=M(e),o=[...n.values()].filter(r=>r.kind!=="subagent"&&r.sessionId!==e.sessionId&&S(M(r).title,t));if(!o.length)return t;const a=L(C(e)),s=o.filter(r=>S(L(C(r)),a));return a&&!s.length?`${t}${I}${a}`:`${t}${I}${q(e.sessionId,s.map(r=>r.sessionId))}`}function Ye(e,n,t){if(!e||e.kind==="empty")return{kind:"empty"};if(e.kind==="launch")return{kind:"launch",agent:e.agent,cwd:e.cwd,name:F(e.cwd),hue:w(e.key),key:e.key,...e.options?{options:e.options}:{}};const o=V(n,e.id),a=e.launch?{launch:e.launch}:{},s=n.get(o);if(!s)return{kind:"session",session:{ref:{sessionId:o,provider:"claude",cwd:""},name:o.slice(0,8),hue:w(o),status:{state:"none",phrase:""},...e.launch?{launched:!0}:{}},...a};const r=Ee(n.values(),o),l=Me(s,r),d=s.provider==="codex"?"codex":"claude",g=B(s),h=O(s,void 0,y),b=[l.subagentsLive?i("board.stage.subagentsWorking",{count:l.subagentsLive}):null,s.closedAt!=null?i("board.stage.phrase.endedAgo",{ago:p(t-s.closedAt)}):null,`${Te(d)}${s.cwd?` · ${s.cwd}`:""}`].filter(Boolean).join(" · ");return{kind:"session",session:{ref:{sessionId:o,provider:d,cwd:s.cwd??""},name:Ce(s,n),hue:w(o),model:s.model??null,effort:s.effort??null,status:he(l,t),contextUse:Se(s),promptCount:X(s.prompts).length,...s.lastEventAt!=null?{heardAt:s.lastEventAt}:{},ghostLine:(h==null?void 0:h.long)??P(g),context:{prompt:P(g),fact:b},endedAgo:s.closedAt!=null?p(t-s.closedAt):null,...s.panelLaunch!=null||e.launch?{launched:!0}:{},rename:z(s)},...a}}function et(e,n,t){var a,s;if(e.track.length===0)return null;let o=null;if(e.next){const r=n.find(l=>l.id===e.next.id);o={name:e.next.label,waited:r?_(t-r.waiting.since):"",tool:((a=r==null?void 0:r.waiting.tool)==null?void 0:a.name)??null}}return{position:e.position?{index:e.position.index-1,total:e.position.total}:null,resumed:((s=e.resumed)==null?void 0:s.label)??null,next:o,clear:e.clear}}function Ie(e){return e.kind==="asked"?i("board.stage.askAsked"):e.kind==="idle"?i("board.stage.askIdle"):e.tool?e.tool.name==="Bash"?i("board.stage.askCommand"):i("board.stage.askTool",{tool:e.tool.name}):i("board.stage.askPermission")}function tt(e,n){var o;const t=e[0];return t?{id:t.id,name:t.label,waited:_(n-t.waiting.since),ask:Ie(t.waiting),command:((o=t.waiting.tool)==null?void 0:o.preview)||null}:null}function nt(e,n){var a;const t=e.arrival;if(!t)return null;const o=n.find(s=>s.id===t.id);return{name:t.label,tool:((a=o==null?void 0:o.waiting.tool)==null?void 0:a.name)??null}}function st(e,n){const t=[];for(const o of e)o.kind!=="root"||!o.cwd||t.push({cwd:o.cwd,hue:w(o.sessionId),at:o.lastEventAt??o.startedAt});return xe(t,n)}export{Ke as A,We as B,be as C,Ye as D,st as E,T as F,qe as G,tt as H,nt as I,et as J,he as K,Be as L,Me as M,ze as P,te as R,x as T,$e as a,Le as b,Fe as c,Re as d,Oe as e,w as f,F as g,Ze as h,ke as i,Ge as j,de as k,Te as l,Ue as m,ve as n,Ae as o,fe as p,Xe as q,Pe as r,De as s,Je as t,ge as u,Qe as v,ce as w,He as x,Ve as y,je as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c5 as j,c6 as x,c7 as M,c8 as B,r as E,c9 as C,ca as J,cb as U,a as P,cc as D}from"./app-
|
|
1
|
+
import{c5 as j,c6 as x,c7 as M,c8 as B,r as E,c9 as C,ca as J,cb as U,a as P,cc as D}from"./app-CXxFM7fY.js";const $=2e3;function G(n){var s,o,i,r;if(!n)return null;const t=n.state==="connected";return{connected:t,email:t?((s=n.account)==null?void 0:s.email)??null:null,unread:t?((o=n.feedback)==null?void 0:o.unread)??0:0,latestAt:t?((i=n.feedback)==null?void 0:i.latestAt)??null:null,mail:!t||((r=n.feedback)==null?void 0:r.mail)!==!1}}function F({post:n,read:t,appliers:s,themes:o,setTimer:i=(e,f)=>setTimeout(e,f),clearTimer:r=e=>clearTimeout(e),debounceMs:m=$}){let e=!1,f={},O=null,v={},u=null;function R(){u!=null&&r(u),u=null,v={}}function T(c){var V;const a=s();let l;const w=j(t);for(const[S,h]of Object.entries(x(c.values))){if(S==="theme"&&!o().includes(h)){l={theme:h};continue}f[S]=h,w[S]!==h&&((V=a[S])==null||V.call(a,h))}O=c.revision,n("/api/account/ui/applied",{revision:c.revision,...l?{skipped:l}:{}}).catch(()=>{})}function _(c){const a=(c==null?void 0:c.state)==="connected"?c.sync:null;if(!a){e=!1,O=null,R();return}if(!e){if(e=!0,f=j(t),a.initialUpload){n("/api/account/ui",{values:{...f},reason:"initial"}).catch(()=>{});return}T(a.apply??a.adopt);return}a.apply&&a.apply.revision!==O&&T(a.apply)}function N(){u=null;const c=v;v={},Object.keys(c).length&&n("/api/account/ui",{values:c,reason:"user"}).catch(()=>{})}function L(c,a){if(!e)return;const l=M(c);if(!l)return;const w=B(l,a);f[l.key]!==w&&(f[l.key]=w,v[l.key]=w,u!=null&&r(u),u=i(N,m))}return{onView:_,onStored:L,flush:()=>{u!=null&&r(u),N()},dispose:R}}let k=null,b=!1;const A=new Set;let g=!1;function p(n){k=n;for(const t of A)t()}async function y(){try{const n=await fetch("/api/account",{headers:{accept:"application/json"}});if(!n.ok){b=!0,p(k);return}b=!1,p(await n.json())}catch{b=!0,p(k)}}function H(){g||typeof window>"u"||(g=!0,window.addEventListener(C,n=>{const t=n.detail;try{p(JSON.parse(t))}catch{}}),window.addEventListener(J,()=>{y()}),y())}function K(n){return H(),A.add(n),()=>{A.delete(n)}}function q(){return{view:E.useSyncExternalStore(K,()=>k,()=>null),failed:b}}async function d(n,t={}){const s=await fetch(n,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),o=await s.json().catch(()=>null);if(!s.ok&&!o)throw new Error(`${n} answered ${s.status}`);return o}function I(n){try{const t=new URL(String(n??""));return t.username||t.password?!1:t.protocol==="https:"?!0:t.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(t.hostname)}catch{return!1}}const Q={async connect(n){const t=await d("/api/account/connect",{name:n});return t&&p(t),t},async cancel(){p(await d("/api/account/connect/cancel"))},async disconnect(){p(await d("/api/account/disconnect"))},async setMode(n){const t=await d("/api/account/sync/mode",n);return await y(),t},async resolve(n){await d("/api/account/sync/resolve",{action:n}),await y()},async upload(){await d("/api/account/sync/upload",{upload:!0}),await y()},async preview(){return(await fetch("/api/account/sync/preview")).json()},refresh:y};function W(n){const t=E.useRef(n);t.current=n;const{view:s}=q(),o=E.useRef(null);o.current||(o.current=F({post:(i,r)=>d(i,r),read:P,appliers:()=>t.current,themes:()=>D})),E.useEffect(()=>{const i=o.current,r=m=>{const e=m.detail;e&&typeof e.key=="string"&&i.onStored(e.key,e.value??null)};return window.addEventListener(U,r),()=>{window.removeEventListener(U,r),i.dispose()}},[]),E.useEffect(()=>{o.current.onView(s)},[s])}export{q as a,Q as b,G as f,I as o,W as u};
|
package/dist/web/index.html
CHANGED
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
document.documentElement.setAttribute("data-density", density === "tightest" || density === "tighter" || density === "default" || density === "comfortable" ? density : "compact");
|
|
88
88
|
})();
|
|
89
89
|
</script>
|
|
90
|
-
<script type="module" crossorigin src="/assets/index-
|
|
91
|
-
<link rel="modulepreload" crossorigin href="/assets/app-
|
|
90
|
+
<script type="module" crossorigin src="/assets/index-B0kLYrYF.js"></script>
|
|
91
|
+
<link rel="modulepreload" crossorigin href="/assets/app-CXxFM7fY.js">
|
|
92
92
|
<link rel="stylesheet" crossorigin href="/assets/app-BW8ALk8H.css">
|
|
93
93
|
</head>
|
|
94
94
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccdeck",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Local dashboard for Claude Code and Codex CLI sessions: which Claude Code session needs input, every tool call and Claude Code subagent live, token cost and quota, several Claude accounts. Run npx ccdeck.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/release-notes.json
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
+
"4.2.0": [
|
|
3
|
+
{
|
|
4
|
+
"title": "📋 Chat shows each step Claude Code takes",
|
|
5
|
+
"body": "Between Claude Code's messages, Chat now shows its task checklist, the steps that failed or that you declined, file edits as the lines they changed, and sub-agents with how far they got. It also says when a reply was interrupted or the request to the API failed."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"title": "⏹️ Stop Claude Code from Chat",
|
|
9
|
+
"body": "While Claude Code works, Chat shows a Stop button that interrupts it, as Esc does in Term. The conversation now also shows the slash commands you ran, with what they printed, and how many images you sent with a message."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"title": "🧰 Codex steps in Chat",
|
|
13
|
+
"body": "In a Codex session, Chat now shows its commands, file edits, plan and web searches as steps, the way it does for Claude Code. A command that failed reads Failed, with what it printed, and the board counts it as an error."
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"title": "🔄 Chat keeps up with the session",
|
|
17
|
+
"body": "Chat now shows a new reply moments after the session moves, instead of on the next timed check, and a session at rest refreshes too. In a long conversation, Load older messages reads back further than the latest part."
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"4.1.0": [
|
|
21
|
+
{
|
|
22
|
+
"title": "💬 Answer Claude Code's questions in Chat",
|
|
23
|
+
"body": "When Claude Code asks you a question, Chat now shows it as a card with its options and their notes. Pick one, tick several, or write your own answer, then Send answer. The card says whether the answer went in, and stays in the conversation with what you chose."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"title": "✅ Approve commands and plans from Chat",
|
|
27
|
+
"body": "When Claude Code asks before running a command or editing a file, or waits for you to approve its plan, Chat shows the request and its choices. The plan reads in full and says afterwards whether you approved it. Before anything goes in, the deck checks that Term still asks the same thing. Choices that change the session's rules, such as “don't ask again”, still open in Term."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"title": "🔁 Codex waits when the new account lacks the model",
|
|
31
|
+
"body": "After you switch Codex to another account, a conversation set to a model that account does not offer now waits instead of carrying on. Accounts and ccdeck tui say to open /model in Codex, choose an available model and continue the same conversation."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"title": "🧠 Machine shows Mac memory use more accurately",
|
|
35
|
+
"body": "On a Mac, Machine now counts memory that apps still hold as used, so it no longer shows much less memory in use than there is. A reading that comes back incomplete is skipped instead of drawn."
|
|
36
|
+
}
|
|
37
|
+
],
|
|
2
38
|
"4.0.4": [
|
|
3
39
|
{
|
|
4
40
|
"title": "📥 Install Claude Code from the deck",
|
|
@@ -238,6 +274,8 @@
|
|
|
238
274
|
"without one."
|
|
239
275
|
],
|
|
240
276
|
"//summaries": {
|
|
277
|
+
"4.2.0": "Chat shows every step, gets Stop and keeps up with the session",
|
|
278
|
+
"4.1.0": "Answer Claude Code's questions, commands and plans from Chat",
|
|
241
279
|
"4.0.4": "Install Claude Code from the deck, sign in again to the same account, and easier account cards",
|
|
242
280
|
"4.0.3": "Sessions start on Windows right after ccdeck starts",
|
|
243
281
|
"4.0.2": "Board cards open in Workspace, the Inspector opens with the session, and panes draw right on tmux 3.2–3.5",
|
|
@@ -10,7 +10,7 @@ import { readCodexAuto } from './codex-auto.mjs';
|
|
|
10
10
|
import { resolveCodexLiveEndpoint, connectCodexLiveRpc, liveError } from './codex-live-rpc.mjs';
|
|
11
11
|
import { acquireCodexLiveLease } from './codex-live-lease.mjs';
|
|
12
12
|
import { readLiveCodexCredential } from './codex-live-credentials.mjs';
|
|
13
|
-
import { prepareCodexLiveHandoff, assertCodexLiveQuiet, continueCodexLiveHandoff, confirmCodexLiveChildren, readCodexLiveTurn, retainCodexLiveHandoff } from './codex-live-handoff.mjs';
|
|
13
|
+
import { codexHandoffModelsAvailable, prepareCodexLiveHandoff, assertCodexLiveQuiet, continueCodexLiveHandoff, confirmCodexLiveChildren, readCodexLiveTurn, retainCodexLiveHandoff } from './codex-live-handoff.mjs';
|
|
14
14
|
import { requestCodexLiveCheckpoints, inspectCodexLiveCheckpoints } from './codex-live-checkpoint.mjs';
|
|
15
15
|
|
|
16
16
|
const idPattern = /^[a-f0-9]{20}$/;
|
|
@@ -376,7 +376,20 @@ export function createCodexLiveAccountController(input = {}) {
|
|
|
376
376
|
try {
|
|
377
377
|
// A checkpoint can itself end with a usage error. Only a different
|
|
378
378
|
// login authorizes retrying that failure, including this late race.
|
|
379
|
-
const
|
|
379
|
+
const changedAccount = !refresh && !sameAccount(before, next);
|
|
380
|
+
if (changedAccount) {
|
|
381
|
+
await verifyOwnership();
|
|
382
|
+
const available = await codexHandoffModelsAvailable(rpc, handoff.paused);
|
|
383
|
+
await verifyOwnership();
|
|
384
|
+
if (!available) {
|
|
385
|
+
// Keep the whole handoff paused, including any delegated children.
|
|
386
|
+
// No automatic send is pending once the user takes over in Codex.
|
|
387
|
+
for (const entry of handoff.paused) await record(entry, 'skipped');
|
|
388
|
+
update({ continuation: 'manual_required', reason: 'native_model_unavailable' });
|
|
389
|
+
return status();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const result = await resume(changedAccount);
|
|
380
393
|
if (result.delegated?.length) {
|
|
381
394
|
childContinuation = { rpc, entries: result.delegated, deadline: Date.now() + (options.delegationTimeoutMs ?? 60_000),
|
|
382
395
|
record, journal, identity: resumeIdentity };
|
|
@@ -252,6 +252,33 @@ export async function assertCodexLiveQuiet(rpc) {
|
|
|
252
252
|
if ((await snapshot(rpc)).threads.length) throw liveError('native_activity_changed');
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
/** Check known OpenAI models against the catalog after the new login. */
|
|
256
|
+
export async function codexHandoffModelsAvailable(rpc, entries) {
|
|
257
|
+
const models = new Set();
|
|
258
|
+
for (const entry of entries) {
|
|
259
|
+
const { thread } = await rpc.request('thread/read', { threadId: entry.threadId, includeTurns: false });
|
|
260
|
+
if (thread?.status?.type === 'idle' && (!thread.modelProvider || thread.modelProvider === 'openai')
|
|
261
|
+
&& typeof thread.model === 'string' && thread.model) models.add(thread.model);
|
|
262
|
+
}
|
|
263
|
+
if (!models.size) return true;
|
|
264
|
+
let cursor;
|
|
265
|
+
const seen = new Set();
|
|
266
|
+
do {
|
|
267
|
+
const page = await rpc.request('model/list', { modelProvider: 'openai', limit: 100, includeHidden: true, ...(cursor ? { cursor } : {}) });
|
|
268
|
+
if (!Array.isArray(page?.data) || page.data.some(item => typeof item?.model !== 'string')) {
|
|
269
|
+
throw liveError('native_model_catalog_unverified');
|
|
270
|
+
}
|
|
271
|
+
for (const item of page.data) models.delete(item.model);
|
|
272
|
+
if (!models.size) return true;
|
|
273
|
+
cursor = page.nextCursor;
|
|
274
|
+
if (cursor != null && (typeof cursor !== 'string' || seen.has(cursor) || seen.size >= 9)) {
|
|
275
|
+
throw liveError('native_model_catalog_unverified');
|
|
276
|
+
}
|
|
277
|
+
if (cursor) seen.add(cursor);
|
|
278
|
+
} while (cursor);
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
|
|
255
282
|
/** Mark a send durably before submitting. An uncertain send is never replayed. */
|
|
256
283
|
export async function continueCodexLiveHandoff(rpc, handoff, options = {}) {
|
|
257
284
|
let resumed = 0;
|
|
@@ -409,15 +409,10 @@ function codexOutputParts(output) {
|
|
|
409
409
|
* on a session that did nothing wrong.
|
|
410
410
|
*/
|
|
411
411
|
function codexCallFailed(output) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
// apply_patch reports itself with an exit code instead of a word. Anything
|
|
417
|
-
// non-zero is a patch that did not apply.
|
|
418
|
-
const exit = /^Exit code:\s*(\d+)/.exec(head);
|
|
419
|
-
if (exit) return Number(exit[1]) !== 0;
|
|
420
|
-
return false;
|
|
412
|
+
// The board and Chat read a result the same way (codexToolOutcome): 0.169's
|
|
413
|
+
// exec_command writes its exit on the third head line, which a first-line
|
|
414
|
+
// read missed, so a command that failed drew green.
|
|
415
|
+
return codexToolOutcome(output).failed;
|
|
421
416
|
}
|
|
422
417
|
|
|
423
418
|
function parseCodexOutput(raw) {
|
|
@@ -429,3 +424,50 @@ function parseCodexOutput(raw) {
|
|
|
429
424
|
return raw;
|
|
430
425
|
}
|
|
431
426
|
}
|
|
427
|
+
|
|
428
|
+
// ─── What a tool result says, for Chat ─────────────────────────────────────
|
|
429
|
+
// Chat (transcript-turns.mjs) draws each Codex call as a row with how it went,
|
|
430
|
+
// and the board's colours (codexCallFailed) take `failed` from here too. The
|
|
431
|
+
// strings below are read from the Codex 0.169.0 binary (linux-x64).
|
|
432
|
+
//
|
|
433
|
+
// Codex heads a result with lines of its own, then "Output:" and what the call
|
|
434
|
+
// printed. 0.169's exec_command writes its exit in those head lines, after
|
|
435
|
+
// "Chunk ID: …" and "Wall time: … seconds": "Process exited with code N". Only
|
|
436
|
+
// lines above "Output:", and only the first MAX_HEAD_LINES, are read, so
|
|
437
|
+
// nothing a command printed can pass for one.
|
|
438
|
+
const MAX_HEAD_LINES = 6;
|
|
439
|
+
const EXIT_LINE = /^(?:Exit code:\s*|Process exited with code )(-?\d+)/;
|
|
440
|
+
// What a call answered No at the approval prompt hands the model: it never ran.
|
|
441
|
+
const DECLINED_OUTPUT = /^(?:exec command|patch) rejected by user$/;
|
|
442
|
+
// What a call Codex could not run at all hands the model: it failed.
|
|
443
|
+
const NOT_RUN = /^(?:unsupported call|unsupported custom tool call|failed to parse function arguments|apply_patch verification failed): /;
|
|
444
|
+
|
|
445
|
+
/** The exit code in the older shell tool's { output, metadata: { exit_code } } envelope, else 0. */
|
|
446
|
+
function envelopeExit(output) {
|
|
447
|
+
if (typeof output !== "string") return 0;
|
|
448
|
+
try {
|
|
449
|
+
const o = JSON.parse(output);
|
|
450
|
+
const code = o && typeof o.output === "string" && o.metadata ? o.metadata.exit_code : undefined;
|
|
451
|
+
return Number.isInteger(code) ? code : 0;
|
|
452
|
+
} catch {
|
|
453
|
+
return 0;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* What a Codex tool result says about its call: `failed`, `declined` (you
|
|
459
|
+
* answered No, so it never ran) and `text`, what it printed without Codex's
|
|
460
|
+
* head lines (the whole text when there are none).
|
|
461
|
+
*/
|
|
462
|
+
export function codexToolOutcome(output) {
|
|
463
|
+
const text = codexOutputParts(output).join("\n").replace(/\r\n?/g, "\n");
|
|
464
|
+
if (DECLINED_OUTPUT.test(text.trim())) return { failed: false, declined: true, text: "" };
|
|
465
|
+
const lines = text.split("\n");
|
|
466
|
+
const at = lines.slice(0, MAX_HEAD_LINES + 1).indexOf("Output:");
|
|
467
|
+
const head = at >= 0 ? lines.slice(0, at) : lines.slice(0, 1);
|
|
468
|
+
const body = at >= 0 ? lines.slice(at + 1).join("\n").trim() : "";
|
|
469
|
+
const first = head[0] ?? "";
|
|
470
|
+
const failed = /^Script failed\b/.test(first) || NOT_RUN.test(first) || envelopeExit(output) !== 0
|
|
471
|
+
|| head.some(line => Number(EXIT_LINE.exec(line)?.[1] ?? 0) !== 0);
|
|
472
|
+
return { failed, declined: false, text: body || text.trim() };
|
|
473
|
+
}
|
|
@@ -13,13 +13,9 @@ import { run } from "./metrics-run.mjs";
|
|
|
13
13
|
/**
|
|
14
14
|
* Bytes of memory a new process could actually get, per platform.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* will hand them over the moment something asks. Reporting them as used is what
|
|
20
|
-
* makes the naive `(total - free) / total` read 99.5% on an idle 32 GB Mac — a
|
|
21
|
-
* number that would send the reader straight to Activity Monitor, which is the
|
|
22
|
-
* one outcome this readout exists to prevent.
|
|
16
|
+
* Linux and macOS distinguish available memory from pages that are free right
|
|
17
|
+
* now. Cached files can be reclaimed, but inactive anonymous pages still
|
|
18
|
+
* belong to applications and can require compression or swap.
|
|
23
19
|
*
|
|
24
20
|
* linux /proc/meminfo MemAvailable — the kernel's own answer, a file read
|
|
25
21
|
* win32 os.freemem() already reports available physical memory
|
|
@@ -40,38 +36,31 @@ export function availableFromMeminfo(text) {
|
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* read-ahead it can drop, inactive anonymous pages, and purgeable caches. This
|
|
47
|
-
* is the number `os.freemem()` is missing — it reports only the first of the
|
|
48
|
-
* four, which is why the naive formula reads ~99% on an idle 32 GB Mac.
|
|
39
|
+
* Physical memory outside the macOS Memory Used figure. Count anonymous
|
|
40
|
+
* application pages after subtracting purgeable memory, wired pages and the
|
|
41
|
+
* physical pages occupied by the compressor.
|
|
49
42
|
*/
|
|
50
43
|
export function availableFromVmStat(text, total) {
|
|
51
44
|
const out = String(text ?? "");
|
|
52
|
-
const pageSize = Number(/page size of (\d+) bytes/.exec(out)?.[1])
|
|
53
|
-
const pages =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
return
|
|
45
|
+
const pageSize = Number(/page size of (\d+) bytes/.exec(out)?.[1]);
|
|
46
|
+
const pages = field => Number(new RegExp(`^${field}:[ \t]+(\\d+)\\.?[ \t]*\\r?$`, "m").exec(out)?.[1]);
|
|
47
|
+
const anonymous = pages("Anonymous pages");
|
|
48
|
+
const purgeable = pages("Pages purgeable");
|
|
49
|
+
const wired = pages("Pages wired down");
|
|
50
|
+
const compressed = pages("Pages occupied by compressor");
|
|
51
|
+
if (![total, pageSize, anonymous, purgeable, wired, compressed].every(Number.isSafeInteger)
|
|
52
|
+
|| total <= 0 || pageSize <= 0 || purgeable > anonymous) return null;
|
|
53
|
+
const used = (anonymous - purgeable + wired + compressed) * pageSize;
|
|
54
|
+
return used <= total ? total - used : null;
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
/**
|
|
65
58
|
* How much memory is really available, or NULL when this machine could not be
|
|
66
59
|
* asked.
|
|
67
60
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* read 99.5% on an idle 32 GB Mac — "a number that would send the reader
|
|
72
|
-
* straight to Activity Monitor, which is the one outcome this readout exists to
|
|
73
|
-
* prevent". So a failed measurement produced exactly the reading the module was
|
|
74
|
-
* written to suppress.
|
|
61
|
+
* On Linux and macOS a failed measurement must not fall back to free pages
|
|
62
|
+
* alone (#789). That would count all cached memory as used and could report
|
|
63
|
+
* 99% usage on an idle machine.
|
|
75
64
|
*
|
|
76
65
|
* And it did not merely flicker. `record` folds into the minute bucket by
|
|
77
66
|
* MAXIMUM, so one failed poll painted a red 99% peak on the memory chart that
|