ccdeck 4.0.3 → 4.0.4
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-Cx7no9kK.js +1 -0
- package/dist/web/assets/{AccountSection-C0_ISsSw.js → AccountSection-HmlI65gN.js} +1 -1
- package/dist/web/assets/{BrowserWatchModal-C4G5G12x.js → BrowserWatchModal-DwY9hX-u.js} +1 -1
- package/dist/web/assets/{FeedbackConversations-Bqqn0VaM.js → FeedbackConversations-6S1QZR6S.js} +1 -1
- package/dist/web/assets/{IntegrationModal-CKgtTF3f.js → IntegrationModal-a8CAd22m.js} +1 -1
- package/dist/web/assets/{IntegrationSkeleton-WE6DOfez.js → IntegrationSkeleton-C2RiqqMA.js} +1 -1
- package/dist/web/assets/{RadioPanel-j_p9qx4L.js → RadioPanel-CyJsFSkf.js} +1 -1
- package/dist/web/assets/StageShell-DXcdcjPI.js +4 -0
- package/dist/web/assets/{TrafficRadar-CTGz345C.js → TrafficRadar-CEbp0Yi7.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-C2IDurbk.js → UsageHistoryModal-i16x6suY.js} +1 -1
- package/dist/web/assets/{app-82JtqhPe.css → app-BW8ALk8H.css} +1 -1
- package/dist/web/assets/{app-CdRq5GPP.js → app-C0usT8Zy.js} +95 -93
- package/dist/web/assets/{index-pIus964m.js → index-BQWffZlx.js} +1 -1
- package/dist/web/assets/{inspector-status-pane-BY6DHEeo.js → inspector-status-pane-DD3QOXE6.js} +1 -1
- package/dist/web/assets/{screens-BMLZR8WS.js → screens-DAn5OlXe.js} +1 -1
- package/dist/web/assets/stage-board-kUkV8N-4.js +2 -0
- package/dist/web/assets/{use-account-t_qL6ab-.js → use-account-x7fuCA6S.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +23 -0
- package/src/server/claude-dir.mjs +93 -6
- package/src/server/claude-install.mjs +315 -0
- package/src/server/claude-reset-credits.mjs +77 -11
- package/src/server/cswap-admin.mjs +73 -4
- package/src/server/index.mjs +10 -0
- package/src/server/pro-engine-client.mjs +7 -3
- package/src/server/request-gates.mjs +3 -0
- package/dist/web/assets/AccountBridge-CmB2ClCh.js +0 -1
- package/dist/web/assets/StageShell-Bl0ddeiL.js +0 -4
- package/dist/web/assets/stage-board-6RJd7VXM.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./app-
|
|
1
|
+
import"./app-C0usT8Zy.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-BY6DHEeo.js → inspector-status-pane-DD3QOXE6.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{K as l,M as p}from"./stage-board-kUkV8N-4.js";import{bM as g,aB as u}from"./app-C0usT8Zy.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cc as ee,j as t,B as v,bh as Y,E as ne,r as u,aA as ke,bg as ye,cd as ge,t as je,u as C,b2 as be,y as Ne}from"./app-CdRq5GPP.js";import{I as we}from"./IntegrationSkeleton-WE6DOfez.js";import{S as A,C as Ee}from"./StageShell-Bl0ddeiL.js";import"./stage-board-6RJd7VXM.js";const te="Only in the terminal",Te="Could not read the prompt again, so nothing was sent";function se(e){return{mode:e.origin==="outside"?"readOnly":e.multi?"multi":"choose",outcome:{kind:"none"},focus:null,checked:[],text:"",closed:!1,token:0}}const l=(e,n=[])=>({state:e,effects:n});function G(e){return e.outcome.kind==="none"||e.outcome.kind==="held"}function oe(e,n){const o=n.model.options,s=c=>Number.isInteger(c)&&!!o[c]&&!o[c].locked;switch(e.kind){case"option":return s(e.index);case"text":return s(e.index)&&!!o[e.index].free&&e.text.trim()!=="";case"many":return e.indexes.length>0&&e.indexes.every(s)}}function M(e,n,o){return!o.canRecheck||!oe(n,o)?l(e):l({...e,token:e.token+1,outcome:{kind:"checking",answer:n}},[{type:"recheck",answer:n}])}function Q(e){return e.outcome.kind==="checking"?{...e,token:e.token+1,outcome:{kind:"none"}}:e}function J(e,n,o){const s=o.model.options[n];if(!s||!G(e))return l(e);const c={...e,focus:n};return s.locked?l(c,[{type:"announce",text:te}]):s.free?l({...c,mode:"free"}):M(c,{kind:"option",index:n},o)}function ce(e,n,o){var c;const s=o.model.options.length;switch(n.type){case"focus":return n.index==null?l({...e,focus:null}):e.mode==="readOnly"||n.index<0||n.index>=s?l(e):e.mode==="free"&&!((c=o.model.options[n.index])!=null&&c.free)?l({...e,mode:"choose",focus:n.index}):l({...e,focus:n.index});case"move":{if(e.mode==="readOnly"||e.mode==="free"||s===0)return l(e);const d=e.focus==null?n.by===1?0:s-1:Math.min(s-1,Math.max(0,e.focus+n.by));return l({...e,focus:d})}case"pick":return e.mode==="readOnly"||e.mode==="free"?l(e):e.mode==="multi"?ce(e,{type:"toggle",index:n.index},o):J(e,n.index,o);case"toggle":{if(e.mode!=="multi"||!G(e)||n.index<0||n.index>=s)return l(e);if(o.model.options[n.index].locked)return l({...e,focus:n.index},[{type:"announce",text:te}]);const h=e.checked.includes(n.index)?e.checked.filter(x=>x!==n.index):[...e.checked,n.index].sort((x,m)=>x-m);return l({...e,focus:n.index,checked:h})}case"submit":{if(!G(e))return l(e);if(e.mode==="choose")return e.focus==null?l(e):J(e,e.focus,o);if(e.mode==="free"){const d=e.text.trim(),h=e.focus==null?void 0:o.model.options[e.focus];return!d||e.focus==null||!(h!=null&&h.free)||h.locked?l(e):M(e,{kind:"text",index:e.focus,text:d},o)}return e.mode==="multi"&&e.checked.length?M(e,{kind:"many",indexes:e.checked},o):l(e)}case"openFree":{if(e.mode!=="choose"||!G(e))return l(e);const d=o.model.options.findIndex(h=>h.free&&!h.locked);return d<0?l(e):l({...e,mode:"free",focus:d})}case"typeFree":return e.mode==="free"?l({...e,text:n.text}):l(e);case"escape":return e.mode==="free"?l({...Q(e),mode:"choose"}):l({...Q(e),closed:!0},[{type:"close"}]);case"result":{if(e.closed||e.outcome.kind!=="checking"||n.token!==void 0&&n.token!==e.token)return l(e);const{answer:d}=e.outcome,h=n.result;return h==="ok"&&!oe(d,o)?l({...e,outcome:{kind:"none"}}):h==="ok"?l({...e,outcome:{kind:"sent",answer:d}},[{type:"send",answer:d},{type:"record",answer:d}]):l({...e,outcome:h})}case"checkFailed":return e.closed||e.outcome.kind!=="checking"||n.token!==void 0&&n.token!==e.token?l(e):l({...e,outcome:{kind:"none"}},[{type:"announce",text:Te}]);case"reset":return l({...se(o.model),token:e.token+1});case"elsewhere":return l({...e,outcome:{kind:"elsewhere",at:n.at}});case"outcome":return l({...e,outcome:n.input});case"dismissOutcome":return l({...e,outcome:{kind:"none"},closed:e.outcome.kind==="sent"||e.outcome.kind==="elsewhere"?!0:e.closed});case"showTerm":return l(e,[{type:"showTerm"}]);case"showNew":return l(e,[{type:"showNew"}]);default:return l(e)}}const Se="Decision",ve="Keys on the question",X={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"]}]},S=(e,n)=>({text:e,spoken:n}),Ce=[{caps:[S("1–3","1 to 3")],word:"pick and send",binds:["1","2","3"]},{caps:[S("↑"),S("↓"),S("Tab")],word:"move",binds:["ArrowUp","ArrowDown","Tab"]},{caps:[S("↵","Enter")],word:"send",binds:["Enter"]},{caps:[S("Esc","Escape")],word:"close",binds:["Escape"]}];function wn(e){return{layer:"decision",label:ve,hints:Ce.filter(n=>e||!n.binds.some(ee))}}function En(e){return{id:X.id,title:Se,rows:X.rows.filter(n=>e||!n.binds.some(ee))}}function Oe(e){return!e||typeof e.closest!="function"?"other":e.closest(".dc-input")?"field":e.closest(".dc-opt")?"row":"other"}function Re(e,n,o,s,c){return n==="other"||n==="field"&&e.key!=="Enter"&&e.key!=="Escape"?null:Ie(e,o,s,c)}function Ie(e,n,o,s){if(e.ctrlKey||e.metaKey||e.altKey)return null;switch(e.key){case" ":return s!=null&&s.multi&&s.focus!=null&&s.focus<o?{type:"toggle",index:s.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 c=Number(e.key)-1;return c<o?{type:"pick",index:c}:null}}}const re=()=>t.jsx(v,{name:"lock"}),Ke=()=>t.jsx(v,{name:"changed"}),ie=()=>t.jsx(v,{name:"chevron-right"}),De=()=>t.jsx(v,{name:"file"}),$e=()=>t.jsx(v,{name:"search"}),Fe=()=>t.jsx(v,{name:"terminal"}),_e="Sent only when you pick, after re-reading the prompt",Ae="↵ sends the highlighted answer, after re-reading the prompt",Le="↵ sends what you wrote · Esc goes back to the choices",Ge="Started outside ccdeck, so it is answered in its own terminal",Ue="See it in Term";function Be(e){return`Send ${e} ${e===1?"answer":"answers"} ↵`}function He(e,n,o){return e==="readOnly"?{text:Ge,lock:!1}:e==="free"?{text:Le,lock:!1}:e==="multi"?{text:o>0?Be(o):"",lock:!1}:n?{text:Ae,lock:!1}:{text:_e,lock:!0}}function Me(e){const n=He(e.mode,e.focused,e.checked),o=e.mode==="readOnly";return t.jsxs("div",{className:"dc-foot",children:[!o&&e.mode!=="multi"&&e.singleKeys!==!1&&t.jsxs("span",{className:"dc-foot-pick",children:["Pick ",t.jsx(Y,{children:"1"}),e.rows>1&&t.jsxs(t.Fragment,{children:[" ","–"," ",t.jsx(Y,{children:String(e.rows)})]})]}),t.jsxs("span",{className:"dc-foot-note","data-muted":e.mode==="multi"||void 0,children:[n.lock&&t.jsx(re,{}),n.text]}),!o&&t.jsxs("button",{type:"button",className:"dc-link",onClick:e.onShowTerm,children:[Ue,t.jsx(ne,{})]})]})}const Pe="Claude’s pick",qe="Send";function ze(e){const{option:n}=e,o=u.useId(),s=n.locked?`${o}-lock-${e.index}`:void 0;return t.jsxs("div",{className:"dc-row","data-typing":e.typing||void 0,children:[t.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":s,"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:[t.jsx("span",{className:"dc-chip","aria-hidden":"true",children:e.index+1}),t.jsxs("span",{className:"dc-opt-text",children:[t.jsx("span",{className:"dc-opt-label",children:n.label}),n.locked?t.jsxs("span",{className:"dc-opt-sub dc-lock",id:s,children:[t.jsx(re,{}),n.lockNote]}):t.jsx("span",{className:"dc-opt-sub",children:n.sub})]}),n.pick&&t.jsx("span",{className:"dc-pick",children:Pe}),e.selection==="checkbox"&&t.jsx("span",{className:"dc-box","aria-hidden":"true","data-on":e.checked||void 0})]}),e.typing&&t.jsxs("div",{className:"dc-field",children:[t.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}),t.jsxs("span",{className:"dc-send","aria-hidden":"true",children:[qe," ","↵"]})]})]})}const We="Checking the prompt is still on screen",Ve="Nothing is sent if it changed.",Ye="The question changed, so nothing was sent",Qe="Nothing was sent.",Je="Held: you have unsent text in the terminal",Xe="Send it or clear it there, then pick again.",Ze="Nothing to send from here.";function en(e,n,o){switch(e.kind){case"none":return null;case"checking":return{glyph:t.jsx(A,{kind:"working"}),title:We,sub:Ve};case"sent":return{glyph:t.jsx(A,{kind:"done"}),title:`Sent to ${n.session}`,tone:"ok",sub:n.command?t.jsxs(t.Fragment,{children:["Running ",t.jsx("code",{className:"dc-mono",children:n.command}),"."]}):"Claude has your answer."};case"changed":return{glyph:t.jsx(Ke,{}),title:Ye,sub:t.jsxs(t.Fragment,{children:["Claude now asks about ",t.jsx("code",{className:"dc-mono",children:e.now})]}),link:{label:"Show it",run:o.onShowNew}};case"ended":return{glyph:t.jsx("span",{className:"dc-err",children:t.jsx(ke,{kind:"err",size:14})}),title:`${n.session} ended before the answer went out`,sub:Qe,link:{label:"Open the transcript",run:o.onOpenTranscript}};case"held":return{glyph:t.jsx(A,{kind:"idle"}),title:Je,sub:Xe,link:{label:"Open Term",run:o.onShowTerm}};case"elsewhere":return{glyph:t.jsx(A,{kind:"done"}),title:`Answered in the terminal at ${e.at}`,sub:Ze}}}function nn({outcome:e,model:n,...o}){const s=en(e,n,o);return s?t.jsxs("div",{className:"dc-out",role:"status","aria-atomic":"true","data-kind":e.kind,children:[t.jsx("span",{className:"dc-out-glyph","aria-hidden":"true",children:s.glyph}),t.jsxs("span",{className:"dc-out-text",children:[t.jsx("span",{className:"dc-out-title","data-tone":s.tone,children:s.title}),t.jsx("span",{className:"dc-out-sub",children:s.sub})]}),s.link&&t.jsxs("button",{type:"button",className:"dc-link",onClick:s.link.run,children:[s.link.label,s.link.external&&t.jsx(ne,{})]})]}):t.jsx("div",{className:"dc-out-empty",role:"status","aria-atomic":"true"})}let tn=0;function sn(e){const{model:n}=e,o=ye(),[s]=u.useState(()=>`dc-${++tn}`),[c,d]=u.useState(()=>({...se(n),...e.outcome?{outcome:e.outcome}:null,...e.initial})),[h,x]=u.useState(""),m=u.useRef(c),p=u.useRef(e);p.current=e;const a=u.useRef([]),k=u.useRef(null),j=u.useRef(!1),g=u.useRef(!0);u.useEffect(()=>()=>{g.current=!1},[]);const O=typeof e.recheck=="function",$=u.useMemo(()=>({model:n,canRecheck:O}),[n,O]),F=u.useRef($);F.current=$;const i=u.useCallback(f=>{const r=ce(m.current,f,F.current);m.current=r.state,d(r.state);for(const y of r.effects)w(y)},[]);function w(f){var y,E,T,_,z,W;const r=p.current;switch(f.type){case"recheck":{const V=m.current.token;(y=r.recheck)==null||y.call(r,f.answer).then(xe=>{g.current&&i({type:"result",result:xe,token:V})},()=>{g.current&&i({type:"checkFailed",token:V})})}break;case"send":(E=r.onAnswer)==null||E.call(r,f.answer);break;case"record":(T=r.onRecord)==null||T.call(r,f.answer);break;case"close":(_=r.onClose)==null||_.call(r);break;case"showTerm":(z=r.onShowTerm)==null||z.call(r);break;case"showNew":(W=r.onShowNew)==null||W.call(r);break;case"announce":x(f.text);break}}const R=u.useRef(!0);u.useEffect(()=>{if(R.current){R.current=!1;return}e.outcome&&i({type:"outcome",input:e.outcome})},[e.outcome,i]);const I=u.useRef(n.id);u.useEffect(()=>{I.current!==n.id&&(I.current=n.id,x(""),i({type:"reset"}),p.current.outcome&&i({type:"outcome",input:p.current.outcome}))},[n.id,i]),u.useEffect(()=>{var f;c.focus!=null&&j.current&&((f=a.current[c.focus])==null||f.focus())},[c.focus]);const N=u.useRef(c.mode),K=u.useRef(!1);u.useEffect(()=>{var r,y;const f=N.current;N.current=c.mode,c.mode==="free"&&f!=="free"?(r=k.current)==null||r.focus():f==="free"&&c.mode!=="free"&&K.current&&(K.current=!1,c.focus!=null&&((y=a.current[c.focus])==null||y.focus()))},[c.mode,c.focus]);const D=f=>{const r=m.current;if(r.mode==="readOnly")return;const y=Oe(f.target),E=Re(f,y,o,n.options.length,{multi:r.mode==="multi",focus:r.focus});if(E){if(E.type==="move"&&f.key==="Tab"){const T=r.focus,_=E.by===1?T===n.options.length-1:T===0;if(T!=null&&_)return}f.preventDefault(),f.stopPropagation(),j.current=!0,i(E)}},b=c.outcome,U=b.kind==="checking"||b.kind==="sent"?b.answer:null,fe=U&&U.kind!=="many"?U.index:-1,B=`${s}-title`,H=c.mode==="multi",pe=c.focus??0;return c.closed?null:t.jsxs("div",{className:"dc-dock","data-size":e.size==="phone"?"phone":void 0,"data-mode":c.mode,"data-outcome":b.kind,"data-kind":n.kind,children:[t.jsxs("div",{className:"dc-decision",role:"group","aria-labelledby":B,onKeyDown:D,onBlur:f=>{f.currentTarget.contains(f.relatedTarget)||(j.current=!1,m.current.focus!=null&&m.current.mode!=="free"&&i({type:"focus",index:null}))},children:[t.jsxs("div",{className:"dc-dq","data-outcome":b.kind,children:[t.jsx("h3",{className:"dc-title",id:B,children:n.title}),n.plan?t.jsx("ol",{className:"dc-plan",children:n.plan.map((f,r)=>t.jsxs("li",{children:[t.jsx("span",{className:"dc-plan-n",children:r+1}),f]},r))}):n.command?t.jsx("code",{className:"dc-cmd",children:n.command}):null,t.jsx("p",{className:"dc-caption",children:n.caption})]}),t.jsxs("div",{className:"dc-tree","aria-hidden":"true",children:[t.jsx("i",{className:"dc-stub"}),n.options.map((f,r)=>t.jsx("i",{className:"dc-tick","data-typing":c.mode==="free"&&c.focus===r||void 0},r))]}),t.jsx("div",{className:"dc-opts",role:H?"group":"radiogroup","aria-labelledby":B,children:n.options.map((f,r)=>t.jsx(ze,{index:r,option:f,selection:H?"checkbox":"radio",focused:c.focus===r,checked:H?c.checked.includes(r):fe===r,typing:c.mode==="free"&&c.focus===r,text:c.text,readOnly:c.mode==="readOnly",singleKeys:o,tabStop:pe===r,rowRef:y=>{a.current[r]=y},inputRef:k,onPick:()=>{j.current=!0,i({type:"pick",index:r})},onFocus:()=>i({type:"focus",index:r}),onText:y=>i({type:"typeFree",text:y}),onFieldKey:y=>{y.key==="Enter"?(y.preventDefault(),y.stopPropagation(),i({type:"submit"})):y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),K.current=!0,i({type:"escape"}))}},r))}),t.jsx(nn,{outcome:b,model:n,onShowNew:()=>i({type:"showNew"}),onShowTerm:()=>i({type:"showTerm"}),onOpenTranscript:()=>{var f,r;return(r=(f=p.current).onOpenTranscript)==null?void 0:r.call(f)}})]}),t.jsx(Me,{mode:c.mode,focused:c.focus!=null,checked:c.checked.length,rows:n.options.length,singleKeys:o,onShowTerm:()=>i({type:"showTerm"})}),t.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:h})]})}function on(e){const n=[];return e.forEach((o,s)=>{if(o.kind==="user"||o.kind==="record"){n.push({kind:o.kind,text:o.text,index:s});return}const c=n.at(-1);(c==null?void 0:c.kind)==="assistant"?c.turns.push(o):n.push({kind:"assistant",turns:[o],index:s})}),n}const cn=/^ {0,3}(`{3,}|~{3,})(.*)$/,ae=/^ {0,3}(#{1,6})[\t ]+(.+)$/,P=/^ {0,3}(?:([-+*])|([0-9]{1,9})[.)])[\t ]+(.*)$/,q=/^ {0,3}>[\t ]?(.*)$/;function le(e){const n=cn.exec(e);return n&&!(n[1][0]==="`"&&n[2].includes("`"))?n:null}function de(e){return e.map((n,o)=>n.kind==="code"?t.jsx("code",{children:n.text},o):n.kind==="bold"?t.jsx("strong",{children:de(n.kids)},o):t.jsx(u.Fragment,{children:n.text.split(`
|
|
1
|
+
import{cd as ee,j as t,B as v,bi as Y,E as ne,r as u,aA as ke,bh as ye,ce as ge,t as je,u as C,b2 as be,y as Ne}from"./app-C0usT8Zy.js";import{I as we}from"./IntegrationSkeleton-C2RiqqMA.js";import{S as A,C as Ee}from"./StageShell-DXcdcjPI.js";import"./stage-board-kUkV8N-4.js";const te="Only in the terminal",Te="Could not read the prompt again, so nothing was sent";function se(e){return{mode:e.origin==="outside"?"readOnly":e.multi?"multi":"choose",outcome:{kind:"none"},focus:null,checked:[],text:"",closed:!1,token:0}}const l=(e,n=[])=>({state:e,effects:n});function G(e){return e.outcome.kind==="none"||e.outcome.kind==="held"}function oe(e,n){const o=n.model.options,s=c=>Number.isInteger(c)&&!!o[c]&&!o[c].locked;switch(e.kind){case"option":return s(e.index);case"text":return s(e.index)&&!!o[e.index].free&&e.text.trim()!=="";case"many":return e.indexes.length>0&&e.indexes.every(s)}}function M(e,n,o){return!o.canRecheck||!oe(n,o)?l(e):l({...e,token:e.token+1,outcome:{kind:"checking",answer:n}},[{type:"recheck",answer:n}])}function Q(e){return e.outcome.kind==="checking"?{...e,token:e.token+1,outcome:{kind:"none"}}:e}function J(e,n,o){const s=o.model.options[n];if(!s||!G(e))return l(e);const c={...e,focus:n};return s.locked?l(c,[{type:"announce",text:te}]):s.free?l({...c,mode:"free"}):M(c,{kind:"option",index:n},o)}function ce(e,n,o){var c;const s=o.model.options.length;switch(n.type){case"focus":return n.index==null?l({...e,focus:null}):e.mode==="readOnly"||n.index<0||n.index>=s?l(e):e.mode==="free"&&!((c=o.model.options[n.index])!=null&&c.free)?l({...e,mode:"choose",focus:n.index}):l({...e,focus:n.index});case"move":{if(e.mode==="readOnly"||e.mode==="free"||s===0)return l(e);const d=e.focus==null?n.by===1?0:s-1:Math.min(s-1,Math.max(0,e.focus+n.by));return l({...e,focus:d})}case"pick":return e.mode==="readOnly"||e.mode==="free"?l(e):e.mode==="multi"?ce(e,{type:"toggle",index:n.index},o):J(e,n.index,o);case"toggle":{if(e.mode!=="multi"||!G(e)||n.index<0||n.index>=s)return l(e);if(o.model.options[n.index].locked)return l({...e,focus:n.index},[{type:"announce",text:te}]);const h=e.checked.includes(n.index)?e.checked.filter(x=>x!==n.index):[...e.checked,n.index].sort((x,m)=>x-m);return l({...e,focus:n.index,checked:h})}case"submit":{if(!G(e))return l(e);if(e.mode==="choose")return e.focus==null?l(e):J(e,e.focus,o);if(e.mode==="free"){const d=e.text.trim(),h=e.focus==null?void 0:o.model.options[e.focus];return!d||e.focus==null||!(h!=null&&h.free)||h.locked?l(e):M(e,{kind:"text",index:e.focus,text:d},o)}return e.mode==="multi"&&e.checked.length?M(e,{kind:"many",indexes:e.checked},o):l(e)}case"openFree":{if(e.mode!=="choose"||!G(e))return l(e);const d=o.model.options.findIndex(h=>h.free&&!h.locked);return d<0?l(e):l({...e,mode:"free",focus:d})}case"typeFree":return e.mode==="free"?l({...e,text:n.text}):l(e);case"escape":return e.mode==="free"?l({...Q(e),mode:"choose"}):l({...Q(e),closed:!0},[{type:"close"}]);case"result":{if(e.closed||e.outcome.kind!=="checking"||n.token!==void 0&&n.token!==e.token)return l(e);const{answer:d}=e.outcome,h=n.result;return h==="ok"&&!oe(d,o)?l({...e,outcome:{kind:"none"}}):h==="ok"?l({...e,outcome:{kind:"sent",answer:d}},[{type:"send",answer:d},{type:"record",answer:d}]):l({...e,outcome:h})}case"checkFailed":return e.closed||e.outcome.kind!=="checking"||n.token!==void 0&&n.token!==e.token?l(e):l({...e,outcome:{kind:"none"}},[{type:"announce",text:Te}]);case"reset":return l({...se(o.model),token:e.token+1});case"elsewhere":return l({...e,outcome:{kind:"elsewhere",at:n.at}});case"outcome":return l({...e,outcome:n.input});case"dismissOutcome":return l({...e,outcome:{kind:"none"},closed:e.outcome.kind==="sent"||e.outcome.kind==="elsewhere"?!0:e.closed});case"showTerm":return l(e,[{type:"showTerm"}]);case"showNew":return l(e,[{type:"showNew"}]);default:return l(e)}}const Se="Decision",ve="Keys on the question",X={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"]}]},S=(e,n)=>({text:e,spoken:n}),Ce=[{caps:[S("1–3","1 to 3")],word:"pick and send",binds:["1","2","3"]},{caps:[S("↑"),S("↓"),S("Tab")],word:"move",binds:["ArrowUp","ArrowDown","Tab"]},{caps:[S("↵","Enter")],word:"send",binds:["Enter"]},{caps:[S("Esc","Escape")],word:"close",binds:["Escape"]}];function wn(e){return{layer:"decision",label:ve,hints:Ce.filter(n=>e||!n.binds.some(ee))}}function En(e){return{id:X.id,title:Se,rows:X.rows.filter(n=>e||!n.binds.some(ee))}}function Oe(e){return!e||typeof e.closest!="function"?"other":e.closest(".dc-input")?"field":e.closest(".dc-opt")?"row":"other"}function Re(e,n,o,s,c){return n==="other"||n==="field"&&e.key!=="Enter"&&e.key!=="Escape"?null:Ie(e,o,s,c)}function Ie(e,n,o,s){if(e.ctrlKey||e.metaKey||e.altKey)return null;switch(e.key){case" ":return s!=null&&s.multi&&s.focus!=null&&s.focus<o?{type:"toggle",index:s.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 c=Number(e.key)-1;return c<o?{type:"pick",index:c}:null}}}const re=()=>t.jsx(v,{name:"lock"}),Ke=()=>t.jsx(v,{name:"changed"}),ie=()=>t.jsx(v,{name:"chevron-right"}),De=()=>t.jsx(v,{name:"file"}),$e=()=>t.jsx(v,{name:"search"}),Fe=()=>t.jsx(v,{name:"terminal"}),_e="Sent only when you pick, after re-reading the prompt",Ae="↵ sends the highlighted answer, after re-reading the prompt",Le="↵ sends what you wrote · Esc goes back to the choices",Ge="Started outside ccdeck, so it is answered in its own terminal",Ue="See it in Term";function Be(e){return`Send ${e} ${e===1?"answer":"answers"} ↵`}function He(e,n,o){return e==="readOnly"?{text:Ge,lock:!1}:e==="free"?{text:Le,lock:!1}:e==="multi"?{text:o>0?Be(o):"",lock:!1}:n?{text:Ae,lock:!1}:{text:_e,lock:!0}}function Me(e){const n=He(e.mode,e.focused,e.checked),o=e.mode==="readOnly";return t.jsxs("div",{className:"dc-foot",children:[!o&&e.mode!=="multi"&&e.singleKeys!==!1&&t.jsxs("span",{className:"dc-foot-pick",children:["Pick ",t.jsx(Y,{children:"1"}),e.rows>1&&t.jsxs(t.Fragment,{children:[" ","–"," ",t.jsx(Y,{children:String(e.rows)})]})]}),t.jsxs("span",{className:"dc-foot-note","data-muted":e.mode==="multi"||void 0,children:[n.lock&&t.jsx(re,{}),n.text]}),!o&&t.jsxs("button",{type:"button",className:"dc-link",onClick:e.onShowTerm,children:[Ue,t.jsx(ne,{})]})]})}const Pe="Claude’s pick",qe="Send";function ze(e){const{option:n}=e,o=u.useId(),s=n.locked?`${o}-lock-${e.index}`:void 0;return t.jsxs("div",{className:"dc-row","data-typing":e.typing||void 0,children:[t.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":s,"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:[t.jsx("span",{className:"dc-chip","aria-hidden":"true",children:e.index+1}),t.jsxs("span",{className:"dc-opt-text",children:[t.jsx("span",{className:"dc-opt-label",children:n.label}),n.locked?t.jsxs("span",{className:"dc-opt-sub dc-lock",id:s,children:[t.jsx(re,{}),n.lockNote]}):t.jsx("span",{className:"dc-opt-sub",children:n.sub})]}),n.pick&&t.jsx("span",{className:"dc-pick",children:Pe}),e.selection==="checkbox"&&t.jsx("span",{className:"dc-box","aria-hidden":"true","data-on":e.checked||void 0})]}),e.typing&&t.jsxs("div",{className:"dc-field",children:[t.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}),t.jsxs("span",{className:"dc-send","aria-hidden":"true",children:[qe," ","↵"]})]})]})}const We="Checking the prompt is still on screen",Ve="Nothing is sent if it changed.",Ye="The question changed, so nothing was sent",Qe="Nothing was sent.",Je="Held: you have unsent text in the terminal",Xe="Send it or clear it there, then pick again.",Ze="Nothing to send from here.";function en(e,n,o){switch(e.kind){case"none":return null;case"checking":return{glyph:t.jsx(A,{kind:"working"}),title:We,sub:Ve};case"sent":return{glyph:t.jsx(A,{kind:"done"}),title:`Sent to ${n.session}`,tone:"ok",sub:n.command?t.jsxs(t.Fragment,{children:["Running ",t.jsx("code",{className:"dc-mono",children:n.command}),"."]}):"Claude has your answer."};case"changed":return{glyph:t.jsx(Ke,{}),title:Ye,sub:t.jsxs(t.Fragment,{children:["Claude now asks about ",t.jsx("code",{className:"dc-mono",children:e.now})]}),link:{label:"Show it",run:o.onShowNew}};case"ended":return{glyph:t.jsx("span",{className:"dc-err",children:t.jsx(ke,{kind:"err",size:14})}),title:`${n.session} ended before the answer went out`,sub:Qe,link:{label:"Open the transcript",run:o.onOpenTranscript}};case"held":return{glyph:t.jsx(A,{kind:"idle"}),title:Je,sub:Xe,link:{label:"Open Term",run:o.onShowTerm}};case"elsewhere":return{glyph:t.jsx(A,{kind:"done"}),title:`Answered in the terminal at ${e.at}`,sub:Ze}}}function nn({outcome:e,model:n,...o}){const s=en(e,n,o);return s?t.jsxs("div",{className:"dc-out",role:"status","aria-atomic":"true","data-kind":e.kind,children:[t.jsx("span",{className:"dc-out-glyph","aria-hidden":"true",children:s.glyph}),t.jsxs("span",{className:"dc-out-text",children:[t.jsx("span",{className:"dc-out-title","data-tone":s.tone,children:s.title}),t.jsx("span",{className:"dc-out-sub",children:s.sub})]}),s.link&&t.jsxs("button",{type:"button",className:"dc-link",onClick:s.link.run,children:[s.link.label,s.link.external&&t.jsx(ne,{})]})]}):t.jsx("div",{className:"dc-out-empty",role:"status","aria-atomic":"true"})}let tn=0;function sn(e){const{model:n}=e,o=ye(),[s]=u.useState(()=>`dc-${++tn}`),[c,d]=u.useState(()=>({...se(n),...e.outcome?{outcome:e.outcome}:null,...e.initial})),[h,x]=u.useState(""),m=u.useRef(c),p=u.useRef(e);p.current=e;const a=u.useRef([]),k=u.useRef(null),j=u.useRef(!1),g=u.useRef(!0);u.useEffect(()=>()=>{g.current=!1},[]);const O=typeof e.recheck=="function",$=u.useMemo(()=>({model:n,canRecheck:O}),[n,O]),F=u.useRef($);F.current=$;const i=u.useCallback(f=>{const r=ce(m.current,f,F.current);m.current=r.state,d(r.state);for(const y of r.effects)w(y)},[]);function w(f){var y,E,T,_,z,W;const r=p.current;switch(f.type){case"recheck":{const V=m.current.token;(y=r.recheck)==null||y.call(r,f.answer).then(xe=>{g.current&&i({type:"result",result:xe,token:V})},()=>{g.current&&i({type:"checkFailed",token:V})})}break;case"send":(E=r.onAnswer)==null||E.call(r,f.answer);break;case"record":(T=r.onRecord)==null||T.call(r,f.answer);break;case"close":(_=r.onClose)==null||_.call(r);break;case"showTerm":(z=r.onShowTerm)==null||z.call(r);break;case"showNew":(W=r.onShowNew)==null||W.call(r);break;case"announce":x(f.text);break}}const R=u.useRef(!0);u.useEffect(()=>{if(R.current){R.current=!1;return}e.outcome&&i({type:"outcome",input:e.outcome})},[e.outcome,i]);const I=u.useRef(n.id);u.useEffect(()=>{I.current!==n.id&&(I.current=n.id,x(""),i({type:"reset"}),p.current.outcome&&i({type:"outcome",input:p.current.outcome}))},[n.id,i]),u.useEffect(()=>{var f;c.focus!=null&&j.current&&((f=a.current[c.focus])==null||f.focus())},[c.focus]);const N=u.useRef(c.mode),K=u.useRef(!1);u.useEffect(()=>{var r,y;const f=N.current;N.current=c.mode,c.mode==="free"&&f!=="free"?(r=k.current)==null||r.focus():f==="free"&&c.mode!=="free"&&K.current&&(K.current=!1,c.focus!=null&&((y=a.current[c.focus])==null||y.focus()))},[c.mode,c.focus]);const D=f=>{const r=m.current;if(r.mode==="readOnly")return;const y=Oe(f.target),E=Re(f,y,o,n.options.length,{multi:r.mode==="multi",focus:r.focus});if(E){if(E.type==="move"&&f.key==="Tab"){const T=r.focus,_=E.by===1?T===n.options.length-1:T===0;if(T!=null&&_)return}f.preventDefault(),f.stopPropagation(),j.current=!0,i(E)}},b=c.outcome,U=b.kind==="checking"||b.kind==="sent"?b.answer:null,fe=U&&U.kind!=="many"?U.index:-1,B=`${s}-title`,H=c.mode==="multi",pe=c.focus??0;return c.closed?null:t.jsxs("div",{className:"dc-dock","data-size":e.size==="phone"?"phone":void 0,"data-mode":c.mode,"data-outcome":b.kind,"data-kind":n.kind,children:[t.jsxs("div",{className:"dc-decision",role:"group","aria-labelledby":B,onKeyDown:D,onBlur:f=>{f.currentTarget.contains(f.relatedTarget)||(j.current=!1,m.current.focus!=null&&m.current.mode!=="free"&&i({type:"focus",index:null}))},children:[t.jsxs("div",{className:"dc-dq","data-outcome":b.kind,children:[t.jsx("h3",{className:"dc-title",id:B,children:n.title}),n.plan?t.jsx("ol",{className:"dc-plan",children:n.plan.map((f,r)=>t.jsxs("li",{children:[t.jsx("span",{className:"dc-plan-n",children:r+1}),f]},r))}):n.command?t.jsx("code",{className:"dc-cmd",children:n.command}):null,t.jsx("p",{className:"dc-caption",children:n.caption})]}),t.jsxs("div",{className:"dc-tree","aria-hidden":"true",children:[t.jsx("i",{className:"dc-stub"}),n.options.map((f,r)=>t.jsx("i",{className:"dc-tick","data-typing":c.mode==="free"&&c.focus===r||void 0},r))]}),t.jsx("div",{className:"dc-opts",role:H?"group":"radiogroup","aria-labelledby":B,children:n.options.map((f,r)=>t.jsx(ze,{index:r,option:f,selection:H?"checkbox":"radio",focused:c.focus===r,checked:H?c.checked.includes(r):fe===r,typing:c.mode==="free"&&c.focus===r,text:c.text,readOnly:c.mode==="readOnly",singleKeys:o,tabStop:pe===r,rowRef:y=>{a.current[r]=y},inputRef:k,onPick:()=>{j.current=!0,i({type:"pick",index:r})},onFocus:()=>i({type:"focus",index:r}),onText:y=>i({type:"typeFree",text:y}),onFieldKey:y=>{y.key==="Enter"?(y.preventDefault(),y.stopPropagation(),i({type:"submit"})):y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),K.current=!0,i({type:"escape"}))}},r))}),t.jsx(nn,{outcome:b,model:n,onShowNew:()=>i({type:"showNew"}),onShowTerm:()=>i({type:"showTerm"}),onOpenTranscript:()=>{var f,r;return(r=(f=p.current).onOpenTranscript)==null?void 0:r.call(f)}})]}),t.jsx(Me,{mode:c.mode,focused:c.focus!=null,checked:c.checked.length,rows:n.options.length,singleKeys:o,onShowTerm:()=>i({type:"showTerm"})}),t.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:h})]})}function on(e){const n=[];return e.forEach((o,s)=>{if(o.kind==="user"||o.kind==="record"){n.push({kind:o.kind,text:o.text,index:s});return}const c=n.at(-1);(c==null?void 0:c.kind)==="assistant"?c.turns.push(o):n.push({kind:"assistant",turns:[o],index:s})}),n}const cn=/^ {0,3}(`{3,}|~{3,})(.*)$/,ae=/^ {0,3}(#{1,6})[\t ]+(.+)$/,P=/^ {0,3}(?:([-+*])|([0-9]{1,9})[.)])[\t ]+(.*)$/,q=/^ {0,3}>[\t ]?(.*)$/;function le(e){const n=cn.exec(e);return n&&!(n[1][0]==="`"&&n[2].includes("`"))?n:null}function de(e){return e.map((n,o)=>n.kind==="code"?t.jsx("code",{children:n.text},o):n.kind==="bold"?t.jsx("strong",{children:de(n.kids)},o):t.jsx(u.Fragment,{children:n.text.split(`
|
|
2
2
|
`).map((s,c)=>t.jsxs(u.Fragment,{children:[c>0&&t.jsx("br",{}),s]},c))},o))}const L=e=>de(ge(e)),Z=e=>le(e)||ae.test(e)||P.test(e)||q.test(e);function rn({text:e}){const n=e.replace(/\r\n?/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`),o=[];let s=0;for(;s<n.length;){if(!n[s].trim()){s++;continue}const c=s,d=le(n[s]);if(d){const p=d[1],a=new RegExp(`^ {0,3}${p[0]}{${p.length},}[\\t ]*$`),k=d[2].trim().split(/\s+/)[0],j=++s;for(;s<n.length&&!a.test(n[s]);)s++;const g=n.slice(j,s).join(`
|
|
@@ -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 S,bX as C,bY as E,bZ as I,b_ as q}from"./app-C0usT8Zy.js";const m=14,Z=18,Q=24,A=12,Y=26,ee=24,x=7,T=50,ne=22,R=25,$=5,te=8,se=168,oe=360;function ae(e,t){return t==="rail"||e<=0?x*2+T:x+T+$+(e-1)*R+ne+te}function Pe(e){return e.replace(/^(\d+m) \d+s$/,"$1")}function re(e,t){if(t==="rail")return[];const n=[];for(let s=0;s<e;s++)n.push(x+T+$+s*R);return n}function ie(e){return Math.max(1,Math.floor((e-m*2+A)/(se+A)))}function ve(e,t,n){const s=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:s.get(u.col),order:u.order??c,i:c})).sort((u,c)=>u.boardCol-c.boardCol||u.order-c.order||u.i-c.i),o=s.size;let r=0,l=Math.max(1,o);if(n==="rail")for(;l>1;)l=Math.ceil(l/2),r+=1;else{const u=ie(t);for(;l>u;)l=Math.ceil(l/2),r+=1}const d=n==="rail"?Math.max(0,Math.floor(t-m*2)):Math.max(0,Math.min(oe,Math.floor((t-m*2-A*(l-1))/l))),g=n==="rail"?ee:Y,h=Array.from({length:l},()=>Z),b=Array.from({length:l},()=>[]);for(const{c:u,boardCol:c}of a){const f=n==="rail"?0:c>>r,M=ae(u.rows,n);b[f].push({sessionId:u.sessionId,col:f,boardCol:c,x:m+f*(d+A),y:h[f],w:d,h:M,rows:re(u.rows,n)}),h[f]+=M+g}const k=b.flat(),D=Math.max(0,...k.map(u=>u.y+u.h));return{density:n,columns:l,merges:r,width:t,height:k.length?D+Q:0,tileW:d,tiles:k}}function le(e){const t=[...e].sort((a,o)=>a.x-o.x||a.y-o.y),n=[];let s=-1/0;for(const a of t)n.length===0||a.x>=s?(n.push([a]),s=a.x+a.w):(n[n.length-1].push(a),s=Math.max(s,a.x+a.w));return n.flatMap((a,o)=>[...a].sort((r,l)=>r.y-l.y||r.x-l.x).map((r,l)=>({sessionId:r.sessionId,col:o,order:l})))}function Le(e,t,n){var l;const s=e.tiles.find(d=>d.sessionId===t);if(!s)return null;if(n==="up"||n==="down"){const d=e.tiles.filter(h=>h.col===s.col),g=d.indexOf(s)+(n==="down"?1:-1);return((l=d[g])==null?void 0:l.sessionId)??null}const a=s.col+(n==="right"?1:-1),o=s.y+s.h/2;let r=null;for(const d of e.tiles)d.col===a&&(!r||Math.abs(d.y+d.h/2-o)<Math.abs(r.y+r.h/2-o))&&(r=d);return(r==null?void 0:r.sessionId)??null}function Oe(e){const t=new Map,n=new Map;for(const a of e){if(a.type!=="agent")continue;const o=a.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null)continue;if(o.kind==="root"){t.set(o.sessionId,o);continue}const r=n.get(o.sessionId)??[];r.push({d:o,x:a.position.x,y:a.position.y}),n.set(o.sessionId,r)}const s=new Map;for(const a of new Set([...t.keys(),...n.keys()])){const o=(n.get(a)??[]).sort((r,l)=>r.y-l.y||r.x-l.x);s.set(a,{sessionId:a,root:t.get(a)??null,subs:o.map(r=>r.d)})}return s}function Re(e,t){if(e.size!==t.size)return!1;for(const[n,s]of e){const a=t.get(n);if(!a||s.root!==a.root||s.subs.length!==a.subs.length)return!1;for(let o=0;o<s.subs.length;o++)if(s.subs[o]!==a.subs[o])return!1}return!0}function $e(e,t){return le(e).map(({sessionId:n,col:s,order:a})=>{var o;return{sessionId:n,col:s,order:a,rows:((o=t.get(n))==null?void 0:o.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 t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}const ue=3e3;function Ge(e,t){return e.exitStatus===0&&e.exitSignal===void 0&&t>=ue}function de(e){return e.kind==="live"||e.kind==="ended"||e.kind==="detached"||e.kind==="attaching"&&e.reconnect}function ce(e,t){return de(t)?"shown":t.kind==="attaching"&&e!=="hidden"?"held":"hidden"}function Ue(e,t){const n=ce(e.state,t),s=n==="shown"&&(e.state==="held"||e.state==="shown"&&e.afterHold);return{state:n,afterHold:s}}function We(e,t){return e.kind==="starting"||e.kind==="attaching"&&t==="hidden"}function je(e){return e.kind==="live"&&!e.readOnly}function _(e){return H(Math.max(0,Math.floor(e/1e3)))}function he(e,t){if(e.closedAt!=null){const n=p(t-e.closedAt);return{state:"ended",phrase:n===i("common.ago.now")?i("board.stage.phrase.endedJustNow"):i("board.stage.phrase.endedAgo",{ago:n})}}if(e.waiting)return{state:"waiting",phrase:i("board.queue.waiting"),emphasis:_(t-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 n=e.lastTurnEndAt!=null?p(t-e.lastTurnEndAt):null;return{state:"idle",phrase:i("board.list.yourTurn"),...n?{arg:N(n)}:{}}}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 n={state:"working",phrase:i("board.stage.phrase.working")};return e.tool?(n.tool=e.tool.name,e.tool.subject&&(n.arg=e.tool.subject),e.tool.startedAt!=null&&(n.seconds=j(e.tool.startedAt,void 0,t))):e.subagentsLive&&(n.arg=i("board.stage.subagentsRunning",{count:e.subagentsLive})),n}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(t-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,t){switch(t.kind){case"empty":return{state:"none",phrase:""};case"attaching":return t.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:t.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 t.code?{state:"detached",phrase:i("board.stage.phrase.notAttached")}:e??{state:"none",phrase:""};case"not-attachable":if(t.target.kind==="C"&&e&&e.state!=="ended"){const{tool:n,arg:s}=e;return{state:"elsewhere",phrase:i(pe(e.state)),...n?{tool:n}:{},...s?{arg:s}:{}}}return e??{state:"ended",phrase:i("board.stage.phrase.ended")};case"ended":return(e==null?void 0:e.state)==="ended"?e:{state:"ended",phrase:t.atOpen?i("board.stage.phrase.ended"):i("board.stage.phrase.endedJustNow")};default:return e??{state:"none",phrase:""}}}function Ve(e,t,n){return t.kind==="live"&&n&&e.state!=="waiting"}const Be="board.stage.launchedUnreachable",ze="board.stage.provenanceUnknown";function fe(e,t){return e.kind==="C"&&t.windows===!0&&(t.launched===!0||e.provenance==="panel")}function Xe(e,t){return e.kind==="C"&&t.windows===!0&&!fe(e,t)&&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,t){switch(t.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 t.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 t.missing==="claude"?i(be):Ae(t.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 t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:e}function xe(e,t){const n=new Map;for(const o of e){if(!o.cwd||!ke(o.cwd))continue;const r=n.get(o.cwd);(!r||o.at>r.at)&&n.set(o.cwd,o)}const s=[...n.values()].sort((o,r)=>r.at-o.at),a=t?s.findIndex(o=>o.cwd===t):-1;return a>0&&s.unshift(...s.splice(a,1)),s.map(o=>({cwd:o.cwd,name:o.name||F(o.cwd),hue:o.hue,at:o.at}))}function Ze(e,t=24){if(e.length<=t)return e;const n=e.split(/[\\/]+/).filter(Boolean),s=n.slice(-2).join("/");if(s.length+2<=t)return`…/${s}`;const a=n[n.length-1]??e;return a.length+2<=t?`…/${a}`:`…/${a.slice(0,Math.max(1,t-3))}…`}function Te(e){return e==="codex"?"Codex":"Claude Code"}function Qe(e){return e==="codex"?"Codex":"Claude"}const ye=160,_e=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e;function P(e){var n;const t=((n=(e??"").split(`
|
|
2
|
+
`).find(s=>s.trim()!==""))==null?void 0:n.trim())??"";return t?_e(t,ye):null}function Me(e,t){const n=[];for(const s of e)s.sessionId===t&&s.kind==="subagent"&&n.push(s);return n}function Se(e,t){var a,o;const n=e.waiting;let s=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);s={name:d.name,subject:d.subject??null,startedAt:l.startedAt};break}return{closedAt:e.closedAt??null,waiting:n&&J(n)?{since:n.since,...(a=n.tool)!=null&&a.name?{tool:n.tool.name}:{},...(o=n.tool)!=null&&o.preview?{detail:n.tool.preview}:{}}:null,active:e.state==="active",tool:s,subagentsLive:t.filter(r=>r.state==="active").length,lastTurnEndAt:e.lastTurnEndAt??null,fresh:e.prompts.length===0&&!e.firstPrompt&&e.lastTurnEndAt==null,yourTurn:(n==null?void 0:n.kind)==="idle"}}function Ce(e){const{used:t,limit:n}=K(e);return{used:t,window:n}}const v=32,L=e=>e.length>v?`${e.slice(0,v-1).trimEnd()}…`:e;function Ee(e,t){const{title:n}=S(e),s=[...t.values()].filter(r=>r.kind!=="subagent"&&r.sessionId!==e.sessionId&&C(S(r).title,n));if(!s.length)return n;const a=L(E(e)),o=s.filter(r=>C(L(E(r)),a));return a&&!o.length?`${n}${I}${a}`:`${n}${I}${q(e.sessionId,o.map(r=>r.sessionId))}`}function Ye(e,t,n){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 s=V(t,e.id),a=e.launch?{launch:e.launch}:{},o=t.get(s);if(!o)return{kind:"session",session:{ref:{sessionId:s,provider:"claude",cwd:""},name:s.slice(0,8),hue:w(s),status:{state:"none",phrase:""},...e.launch?{launched:!0}:{}},...a};const r=Me(t.values(),s),l=Se(o,r),d=o.provider==="codex"?"codex":"claude",g=B(o),h=O(o,void 0,y),b=[l.subagentsLive?i("board.stage.subagentsWorking",{count:l.subagentsLive}):null,o.closedAt!=null?i("board.stage.phrase.endedAgo",{ago:p(n-o.closedAt)}):null,`${Te(d)}${o.cwd?` · ${o.cwd}`:""}`].filter(Boolean).join(" · ");return{kind:"session",session:{ref:{sessionId:s,provider:d,cwd:o.cwd??""},name:Ee(o,t),hue:w(s),model:o.model??null,effort:o.effort??null,status:he(l,n),contextUse:Ce(o),promptCount:X(o.prompts).length,ghostLine:(h==null?void 0:h.long)??P(g),context:{prompt:P(g),fact:b},endedAgo:o.closedAt!=null?p(n-o.closedAt):null,...o.panelLaunch!=null||e.launch?{launched:!0}:{},rename:z(o)},...a}}function en(e,t,n){var a,o;if(e.track.length===0)return null;let s=null;if(e.next){const r=t.find(l=>l.id===e.next.id);s={name:e.next.label,waited:r?_(n-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:((o=e.resumed)==null?void 0:o.label)??null,next:s,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 nn(e,t){var s;const n=e[0];return n?{id:n.id,name:n.label,waited:_(t-n.waiting.since),ask:Ie(n.waiting),command:((s=n.waiting.tool)==null?void 0:s.preview)||null}:null}function tn(e,t){var a;const n=e.arrival;if(!n)return null;const s=t.find(o=>o.id===n.id);return{name:n.label,tool:((a=s==null?void 0:s.waiting.tool)==null?void 0:a.name)??null}}function sn(e,t){const n=[];for(const s of e)s.kind!=="root"||!s.cwd||n.push({cwd:s.cwd,hue:w(s.sessionId),at:s.lastEventAt??s.startedAt});return xe(n,t)}export{Ke as A,We as B,be as C,Ye as D,sn as E,T as F,qe as G,nn as H,tn as I,en as J,he as K,Be as L,Se as M,ze as P,ne 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{
|
|
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-C0usT8Zy.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,9 +87,9 @@
|
|
|
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-
|
|
92
|
-
<link rel="stylesheet" crossorigin href="/assets/app-
|
|
90
|
+
<script type="module" crossorigin src="/assets/index-BQWffZlx.js"></script>
|
|
91
|
+
<link rel="modulepreload" crossorigin href="/assets/app-C0usT8Zy.js">
|
|
92
|
+
<link rel="stylesheet" crossorigin href="/assets/app-BW8ALk8H.css">
|
|
93
93
|
</head>
|
|
94
94
|
<body>
|
|
95
95
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccdeck",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
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,26 @@
|
|
|
1
1
|
{
|
|
2
|
+
"4.0.4": [
|
|
3
|
+
{
|
|
4
|
+
"title": "📥 Install Claude Code from the deck",
|
|
5
|
+
"body": "Where the deck finds no Claude Code, the session pane and the sign-in dialog now offer Install Claude Code, which runs the installer from Anthropic's setup page, and show its command with Copy for an install by hand. In a session pane, the session starts once the install is done."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"title": "🔎 The deck finds Claude Code in more places",
|
|
9
|
+
"body": "The deck now also finds Claude Code where the older installer, a user-level npm install, Homebrew on Linux, WinGet and Scoop put it, so signing in from the desktop app no longer fails with “not on PATH”."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"title": "🔑 Sign in again brings back the same account",
|
|
13
|
+
"body": "Sign in again, now also in an account's ⋯ menu, opens the sign-in for that account. If the browser signs in a different account, the deck saves nothing, says so, offers Try again, and keeps the machine on the account it was using."
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"title": "🧾 Account cards are easier to read",
|
|
17
|
+
"body": "A closed card says which window its reset is for, as in “5h resets in 3h 53m”. An open card shows each limit once, in aligned columns, and long values wrap instead of being cut off."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"title": "♻️ Saved resets say which limit they clear",
|
|
21
|
+
"body": "Usage now lists each kind of saved Claude reset on its own line, such as “1 Fable reset” or “2 Global resets”, and says on hover what each one gives back."
|
|
22
|
+
}
|
|
23
|
+
],
|
|
2
24
|
"4.0.3": [
|
|
3
25
|
{
|
|
4
26
|
"title": "🪟 Sessions start on Windows right after ccdeck starts",
|
|
@@ -216,6 +238,7 @@
|
|
|
216
238
|
"without one."
|
|
217
239
|
],
|
|
218
240
|
"//summaries": {
|
|
241
|
+
"4.0.4": "Install Claude Code from the deck, sign in again to the same account, and easier account cards",
|
|
219
242
|
"4.0.3": "Sessions start on Windows right after ccdeck starts",
|
|
220
243
|
"4.0.2": "Board cards open in Workspace, the Inspector opens with the session, and panes draw right on tmux 3.2–3.5",
|
|
221
244
|
"4.0.0": "A calmer deck, with your sessions' terminals inside it",
|
|
@@ -42,11 +42,25 @@ export function claudeConfigDir(env = process.env, home = homedir(), platform =
|
|
|
42
42
|
/**
|
|
43
43
|
* Every place the `claude` CLI is known to live, in the order to try them.
|
|
44
44
|
*
|
|
45
|
-
* Pure, and the platform, environment
|
|
46
|
-
* Windows list can be checked from a Mac — which is the only
|
|
47
|
-
* right, since it exists entirely for machines the author
|
|
45
|
+
* Pure, and the platform, environment, home directory and node's own path are
|
|
46
|
+
* parameters, so the Windows list can be checked from a Mac — which is the only
|
|
47
|
+
* way this list stays right, since it exists entirely for machines the author
|
|
48
|
+
* is not sitting at. A place on the list where nothing is installed is a stat
|
|
49
|
+
* that answers no, and every reader moves on to the next.
|
|
48
50
|
*/
|
|
49
|
-
export function claudeCliCandidates(platform = process.platform, env = process.env, home = homedir()) {
|
|
51
|
+
export function claudeCliCandidates(platform = process.platform, env = process.env, home = homedir(), execPath = process.execPath) {
|
|
52
|
+
// Distinct, first place kept: the folder beside node can be one of the
|
|
53
|
+
// places above it (/usr/local/bin), and a second stat of it finds nothing new.
|
|
54
|
+
return [...new Set([
|
|
55
|
+
...firstClaudeCandidates(platform, env, home),
|
|
56
|
+
...moreClaudeCandidates(platform, env, home, execPath),
|
|
57
|
+
])];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The list as it stood before the places moreClaudeCandidates adds: PATH and
|
|
61
|
+
* the installers' own folders, which are also where the terminal engine
|
|
62
|
+
* looks for `claude` by itself (engineClaudeHint). */
|
|
63
|
+
function firstClaudeCandidates(platform, env, home) {
|
|
50
64
|
// The path flavour follows the PLATFORM ARGUMENT, not the host: node's `join`
|
|
51
65
|
// would emit forward slashes when the Windows list is built on a Mac.
|
|
52
66
|
const { join } = platform === "win32" ? winPath : posixPath;
|
|
@@ -76,6 +90,79 @@ export function claudeCliCandidates(platform = process.platform, env = process.e
|
|
|
76
90
|
];
|
|
77
91
|
}
|
|
78
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Where else a `claude` is found on machines whose deck reached none of the
|
|
95
|
+
* places above: a desktop app or a service starts the deck with a PATH that
|
|
96
|
+
* never read the shell's startup files, and these installs are put on PATH
|
|
97
|
+
* only there. Tried after the list above, never before it, so a machine whose
|
|
98
|
+
* `claude` is found today keeps running the same one.
|
|
99
|
+
*
|
|
100
|
+
* POSIX ~/.claude/local/claude, Claude Code's older local install, which
|
|
101
|
+
* its installer reached through a shell alias rather than PATH;
|
|
102
|
+
* the `claude` beside the node running the deck, which is npm's
|
|
103
|
+
* global bin for nvm-style installs; npm's ~/.npm-global prefix;
|
|
104
|
+
* Homebrew on Linux.
|
|
105
|
+
* Windows WinGet's Links folder, Scoop's shims, and the `claude.cmd` npm
|
|
106
|
+
* puts beside node.exe when its prefix is node's own folder.
|
|
107
|
+
*
|
|
108
|
+
* `execPath` is the node binary's path, a parameter for the same reason the
|
|
109
|
+
* others are: the answer for a machine the suite is not running on.
|
|
110
|
+
*/
|
|
111
|
+
function moreClaudeCandidates(platform, env, home, execPath) {
|
|
112
|
+
const { join, dirname } = platform === "win32" ? winPath : posixPath;
|
|
113
|
+
const besideNode = typeof execPath === "string" && execPath ? dirname(execPath) : "";
|
|
114
|
+
if (platform !== "win32") {
|
|
115
|
+
return [
|
|
116
|
+
join(home, ".claude", "local", "claude"),
|
|
117
|
+
...(besideNode ? [join(besideNode, "claude")] : []),
|
|
118
|
+
join(home, ".npm-global", "bin", "claude"),
|
|
119
|
+
"/home/linuxbrew/.linuxbrew/bin/claude",
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
return [
|
|
123
|
+
join(env.LOCALAPPDATA || join(home, "AppData", "Local"), "Microsoft", "WinGet", "Links", "claude.exe"),
|
|
124
|
+
join(env.USERPROFILE || home, "scoop", "shims", "claude.exe"),
|
|
125
|
+
...(besideNode ? [join(besideNode, "claude.cmd")] : []),
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The `claude` to hand the terminal engine as AGENTS_DECK_CLAUDE, or null to
|
|
131
|
+
* hand it nothing.
|
|
132
|
+
*
|
|
133
|
+
* The engine finds `claude` by itself, on PATH and in the installers' folders
|
|
134
|
+
* (the list above, before moreClaudeCandidates), and honours AGENTS_DECK_CLAUDE
|
|
135
|
+
* before any of that. A machine whose only `claude` is in one of the places
|
|
136
|
+
* moreClaudeCandidates adds would have the deck sign in and read quota with it
|
|
137
|
+
* while its sessions said Claude Code is not installed; the deck names the one
|
|
138
|
+
* it found instead. Never over a value of the user's own, and nothing when the
|
|
139
|
+
* engine's own search already finds one, so on every machine that works today
|
|
140
|
+
* the engine's environment is exactly what it was.
|
|
141
|
+
*
|
|
142
|
+
* On Windows only a `.exe`: a `.cmd` is a script cmd.exe runs, and the engine
|
|
143
|
+
* starts a program.
|
|
144
|
+
*/
|
|
145
|
+
export function engineClaudeHint({
|
|
146
|
+
platform = process.platform,
|
|
147
|
+
env = process.env,
|
|
148
|
+
home = homedir(),
|
|
149
|
+
exists = existsSync,
|
|
150
|
+
execPath = process.execPath,
|
|
151
|
+
} = {}) {
|
|
152
|
+
try {
|
|
153
|
+
if (String(env.AGENTS_DECK_CLAUDE ?? "").trim()) return null;
|
|
154
|
+
const first = firstClaudeCandidates(platform, env, home);
|
|
155
|
+
for (const _ of claudeCliFound({ platform, env, home, exists, candidates: first })) return null;
|
|
156
|
+
for (const candidate of moreClaudeCandidates(platform, env, home, execPath)) {
|
|
157
|
+
if (platform === "win32" && !/\.exe$/i.test(candidate)) continue;
|
|
158
|
+
if (exists(candidate)) return candidate;
|
|
159
|
+
}
|
|
160
|
+
} catch {
|
|
161
|
+
// A stat that throws is no answer, and the engine searches as it always did.
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
79
166
|
/**
|
|
80
167
|
* The names Claude Code itself writes inside its config dir, and the deck never
|
|
81
168
|
* does. Presence of any one of them is proof Claude Code has actually run here.
|
|
@@ -141,10 +228,10 @@ function claudeCliOnDisk({
|
|
|
141
228
|
* claudeCodeVersions below reads them all, because an old CLI anywhere on the
|
|
142
229
|
* machine still reads the settings file a new one does.
|
|
143
230
|
*/
|
|
144
|
-
function* claudeCliFound({ platform, env, home, exists }) {
|
|
231
|
+
function* claudeCliFound({ platform, env, home, exists, candidates = claudeCliCandidates(platform, env, home) }) {
|
|
145
232
|
const path = platform === "win32" ? winPath : posixPath;
|
|
146
233
|
const bare = [];
|
|
147
|
-
for (const candidate of
|
|
234
|
+
for (const candidate of candidates) {
|
|
148
235
|
// A full path is worth a single stat; a bare name means "ask PATH", which
|
|
149
236
|
// is the walk below. Same split quotaClaudeBin makes, for the same reason.
|
|
150
237
|
if (candidate.includes(path.sep)) { if (exists(candidate)) yield candidate; }
|