howtocode 0.7.71 → 0.7.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{chunk-SY75TNLH.js → chunk-5JRLPRW5.js} +1 -1
- package/dist/chunk-AMHJO4G3.js +201 -0
- package/dist/{chunk-F5OVNAST.js → chunk-DWHGMY6G.js} +1 -1
- package/dist/{chunk-H23J4FSF.js → chunk-HMCCBHIZ.js} +1 -1
- package/dist/{chunk-5AYXLMSC.js → chunk-MP3T3UKV.js} +2 -2
- package/dist/{chunk-CU4IJVIZ.js → chunk-PQB6KMLL.js} +1 -1
- package/dist/{chunk-VCDC3RAJ.js → chunk-R7ANN5PP.js} +1 -1
- package/dist/{chunk-D5TQNROK.js → chunk-RT3VOMO4.js} +1 -1
- package/dist/{chunk-6RTTDISU.js → chunk-U5EB7YZU.js} +1 -1
- package/dist/{chunk-V3R4FYTJ.js → chunk-UDX555SX.js} +1 -1
- package/dist/{chunk-EF3Z3FAO.js → chunk-WDMBTVK7.js} +1 -1
- package/dist/{chunk-YUS7EX6B.js → chunk-WKR2L2CT.js} +1 -1
- package/dist/chunk-XODGJSB3.js +2 -0
- package/dist/{chunk-VSVEFNSH.js → chunk-YUOYDO5O.js} +1 -1
- package/dist/cli-auth.js +1 -1
- package/dist/main-app.js +11 -11
- package/package.json +1 -1
- package/dist/chunk-27TRKD65.js +0 -2
- package/dist/chunk-7HVQT3IC.js +0 -201
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as j}from"./chunk-MCAAX33K.js";import{a as b}from"./chunk-
|
|
1
|
+
import{b as j}from"./chunk-MCAAX33K.js";import{a as b}from"./chunk-WDMBTVK7.js";import{H as m,N as A}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import{j as R}from"./chunk-MVVEYKN6.js";import{b as M,d as T,f as D}from"./chunk-TUXY64DT.js";import{a as I}from"./chunk-FABEBOGV.js";import"./chunk-WOT6VMZA.js";import{spawnSync as J}from"node:child_process";import{existsSync as S,readdirSync as E,readFileSync as x,realpathSync as B,statSync as C,writeFileSync as F,unlinkSync as z}from"node:fs";import{dirname as N,join as p}from"node:path";var k=[22,19];async function W(t="https://api.howtofix.id/api/status"){let n=[],[s,e]=process.versions.node.split(".").map(Number),r=s>k[0]||s===k[0]&&e>=k[1];n.push({name:"node",ok:r,detail:`${process.versions.node} (needs >= ${k[0]}.${k[1]})`});let i=J("git",["--version"],{encoding:"utf8"});n.push({name:"git",ok:i.status===0,detail:i.status===0?i.stdout.trim():"not found on PATH"});let o=I();n.push({name:"sandbox",ok:!!o,detail:o??"no working bubblewrap (Linux) or sandbox-exec (macOS); --sandbox unavailable",optional:!0});let l=!1,c=m;try{let d=p(m,`.doctor-${process.pid}`);F(d,"ok"),z(d),l=!0}catch(d){c=`${m} is not writable: ${d instanceof Error?d.message:String(d)}`}n.push({name:"state dir",ok:l,detail:c});let a=p(m,"auth.json"),u="no auth.json \u2014 run `howtocode` and sign in",h=!1;try{let d=JSON.parse(x(a,"utf8")),f=Object.keys(d).length;h=f>0,u=h?`${f} provider credential${f===1?"":"s"}`:u}catch{}n.push({name:"auth",ok:h,detail:u,optional:!0});try{let d=Date.now(),f=await fetch(t,{signal:AbortSignal.timeout(5e3)});n.push({name:"gateway",ok:f.ok,detail:`${t} \u2192 ${f.status} in ${Date.now()-d}ms`,optional:!0})}catch(d){n.push({name:"gateway",ok:!1,detail:`${t} unreachable: ${d instanceof Error?d.message:String(d)}`,optional:!0})}return n.push(G()),n}function G(t=q()){if(t===void 0)return{name:"install",ok:!0,detail:"not an npm install; skipped",optional:!0};if(!S(t))return{name:"install",ok:!0,detail:"no bundled dependencies to check",optional:!0};let n=[],s=0;for(let e of["@netrodev"]){let r=p(t,e);if(S(r))for(let i of E(r)){let o=p(r,i,"dist");if(S(o))for(let l of _(o)){s+=1;let c=x(l,"utf8");for(let a of c.matchAll(/import\("(\.[^"]+)"\)/g)){let u=p(N(l),a[1]);S(u)||n.push(`${e}/${i}: ${u.slice(o.length+1)}`)}}}}return n.length>0?{name:"install",ok:!1,detail:`${n.length} module${n.length===1?"":"s"} missing (${n[0]}); reinstall with \`npm install -g howtocode@latest\``}:{name:"install",ok:!0,detail:`${s} lazy module${s===1?"":"s"} present`}}function q(){try{return p(N(N(B(process.argv[1]??""))),"node_modules")}catch{return}}function _(t,n=[]){let s;try{s=E(t)}catch{return n}for(let e of s){let r=p(t,e);if(e.endsWith(".lazy.js"))n.push(r);else if(!e.includes("."))try{C(r).isDirectory()&&_(r,n)}catch{}}return n}async function ie(){let t=await W(),n=Math.max(...t.map(e=>e.name.length));for(let e of t){let r=e.ok?"ok ":e.optional?"warn":"FAIL";console.log(` ${r} ${e.name.padEnd(n)} ${e.detail}`)}let s=t.filter(e=>!e.ok&&!e.optional);return s.length>0?(console.log(`
|
|
2
2
|
${s.length} problem${s.length===1?"":"s"} must be fixed before a session will work.`),1):0}function ce(t=m){let n=p(t,"models.json"),s;try{s=x(n,"utf8")}catch(a){return a.code==="ENOENT"?console.log(` no models.json at ${n} \u2014 run \`howtocode /connect\` to pull the catalogue`):j(b,"models",a),1}let e;try{e=JSON.parse(s)}catch(a){return console.error(`${b}: models: ${n} is not valid JSON (${a instanceof Error?a.message:String(a)})`),console.error(" fix the file, or delete it and run `howtocode /connect` to write a new one"),1}let r=e.providers??{},i=D(A),o=i?new Set(i.ids):void 0,l=new Set,c=0;for(let[a,u]of Object.entries(r)){let h=u.models??[],d=h.map(f=>f.id).filter(Boolean);for(let f of d)l.add(f);c+=d.length,console.log(` ${a} (${d.length})`);for(let f of h){if(!f.id)continue;let O=T(m).get(f.id),$=M(O??[]),g=$?` ${$}`:"",w=o&&!o.has(f.id)?" \u2014 not on this account":"";console.log(` ${f.id}${g}${w}`)}}if(o){let a=[...l].filter(u=>!o.has(u)).length;console.log(`
|
|
3
3
|
${[...o].filter(u=>l.has(u)).length} of ${c} listed model(s) this account can call${a>0?`; ${a} cannot (kept for other plans)`:""}`)}else console.log("\n which of these this account can call is unknown: run `howtocode` once to record it");return c===0?(console.log(" no models configured"),1):0}function v(t=15,n=m){let s=p(n,"sessions"),e;try{e=E(s)}catch{return[]}let r=[];for(let i of e){let o=p(s,i),l;try{l=E(o)}catch{continue}for(let c of l){if(!c.endsWith(".jsonl"))continue;let a=p(o,c);try{let u=C(a);r.push({file:a,project:i,modified:u.mtimeMs,bytes:u.size})}catch{}}}return r.sort((i,o)=>o.modified-i.modified).slice(0,t)}function le(t){let n=t.indexOf("--search");if(n>=0){let o=t[n+1]?.trim();if(!o)return console.error(`${b}: sessions: --search needs a word or phrase`),2;let l=K(o);if(l.length===0)return console.log(` no session mentions "${o}"`),0;for(let c of l){let a=new Date(c.row.modified).toISOString().replace("T"," ").slice(0,16),u=`${c.matches} hit${c.matches===1?"":"s"}`;console.log(` ${a} ${c.row.project} (${u})`),console.log(` ${c.row.file}`),console.log(` ${c.snippet}`)}return 0}let s=t.indexOf("--limit"),e=s>=0&&Number(t[s+1])||15,r=v(e);if(r.length===0)return console.log(` no saved sessions under ${p(m,"sessions")}`),t.includes("--export")?1:0;let i=t.indexOf("--export");if(i>=0){let o=Number(t[i+1]);if(!Number.isInteger(o)||o<1||o>r.length)return console.error(`${b}: sessions: --export needs a number from the list (1-${r.length})`),2;let l=r[o-1];try{console.log(Q(l.file))}catch(c){return j(b,"sessions",c),1}return 0}return r.forEach((o,l)=>{let c=new Date(o.modified).toISOString().replace("T"," ").slice(0,16),a=Math.round(o.bytes/1024);console.log(` ${String(l+1).padStart(2)} ${c} ${String(a).padStart(6)}k ${o.project}`),console.log(` ${o.file}`)}),0}function H(t){let n=t;try{let s=JSON.parse(t),e=s.message?.content??s.content;if(typeof e=="string"&&e.trim())n=e;else if(Array.isArray(e)){let r=e.map(i=>i&&typeof i=="object"&&"text"in i?String(i.text):"").join(" ");r.trim()&&(n=r)}}catch{}return R(X(n).replace(/\s+/g," ").trim())}function X(t){return t.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007|\u001b[@-Z\\-_]/g,"")}function Z(t,n,s=80){let e=t.toLowerCase().indexOf(n);if(e<0)return t.slice(0,s*2).trim();let r=Math.max(0,e-s),i=Math.min(t.length,e+n.length+s);return`${r>0?"\u2026":""}${t.slice(r,i).trim()}${i<t.length?"\u2026":""}`}function K(t,n=10,s=m){let e=t.toLowerCase(),r=new RegExp(`\\b${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i"),i=[];for(let o of v(Number.MAX_SAFE_INTEGER,s)){let l;try{l=x(o.file,"utf8")}catch{continue}let c=0,a=0,u=0,h=0,d=!1,f="";for(let $ of l.split(`
|
|
4
4
|
`)){let g=$.toLowerCase(),w=g.indexOf(e);if(w<0)continue;let y=0;for(;w>=0;)y++,w=g.indexOf(e,w+e.length);c+=y;let L=g.includes('"role":"user"'),P=g.includes('"role":"toolresult"')||g.includes('"role":"tool"');L?a+=y:P?h+=y:u+=y,r.test($)&&(d=!0),f||(f=Z(H($),e))}if(c===0)continue;let O=(a>0?100:0)+(u>0?10:0)+Math.min(h,5)+(d?5:0)+Math.min(c,10)/100;i.push({row:o,matches:c,score:O,snippet:f})}return i.sort((o,l)=>l.score-o.score||l.row.modified-o.row.modified).slice(0,n)}function Q(t){let n=[`# Session ${t.split(/[\\/]/).pop()??t}`,""];for(let s of x(t,"utf8").split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as We,B as De,C as Ce,E as R,F as H,Fa as ot,H as B,I as Pe,Q as je,R as Ne,Ra as st,S as Me,T as Fe,U as Le,Ua as Q,V as Be,W as Ue,Wa as rt,Y as Ge,_ as Y,a as N,b as M,ba as He,c as ge,ca as qe,d as he,da as ze,e as we,ea as V,f as be,fa as Ze,g as A,ga as Ke,i as ye,j as ke,ja as Xe,k as Se,l as _e,la as Ye,m as X,ma as q,na as Ve,o as Te,oa as Je,p as Ee,q as $e,qa as J,r as ve,s as Ae,t as x,u as Re,ua as Qe,va as et,w as Oe,x as W,xa as tt,y as Ie,ya as nt}from"./chunk-
|
|
1
|
+
import{$ as We,B as De,C as Ce,E as R,F as H,Fa as ot,H as B,I as Pe,Q as je,R as Ne,Ra as st,S as Me,T as Fe,U as Le,Ua as Q,V as Be,W as Ue,Wa as rt,Y as Ge,_ as Y,a as N,b as M,ba as He,c as ge,ca as qe,d as he,da as ze,e as we,ea as V,f as be,fa as Ze,g as A,ga as Ke,i as ye,j as ke,ja as Xe,k as Se,l as _e,la as Ye,m as X,ma as q,na as Ve,o as Te,oa as Je,p as Ee,q as $e,qa as J,r as ve,s as Ae,t as x,u as Re,ua as Qe,va as et,w as Oe,x as W,xa as tt,y as Ie,ya as nt}from"./chunk-AMHJO4G3.js";import{b as xe}from"./chunk-XODGJSB3.js";import{c as ue}from"./chunk-RT3VOMO4.js";import{h as pe,l as fe}from"./chunk-WKR2L2CT.js";import{t as me}from"./chunk-ZJL4OEXX.js";import"./chunk-7LA2AMZB.js";import"./chunk-YUOYDO5O.js";import{b as G,c as ie,d as ae}from"./chunk-WDMBTVK7.js";import{H as S,K as de,v as ce,w as le}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";import{join as Nt}from"node:path";import{hostname as io}from"node:os";import{createAgentSession as ao,createCodemodeExtension as co,createMcpExtension as lo,createToolSearchExtension as uo,DefaultResourceLoader as po,ProjectTrustStore as fo,SessionManager as Z,SettingsManager as mo}from"@netrodev/hxf-coding-agent";import{existsSync as Ft,readFileSync as Lt}from"node:fs";import{join as Bt}from"node:path";var it=Bt(S,"APPEND_SYSTEM.md"),Ut=["<non-interactive>","This run has no user attached: it was started with --print, and there is nobody to answer a question. Anything that stops and waits for a reply \u2014 `ask`, a confirmation, a skill that resolves a mode by asking which mode to use \u2014 will simply end the run with the task unfinished.","So do not ask. Where an instruction tells you to ask the user and wait, take the default it describes and continue, and say which default you took and why in your final answer. The user reads that answer; they cannot answer mid-run.","Where a skill offers a choice of modes, prefer the one that applies the rules while you work over the one that audits afterwards: this is the mode for building something now, and the audit mode can still be run later by the same person who reads your answer.","</non-interactive>"].join(`
|
|
2
2
|
`),Gt=16*1024;function Wt(e){try{if(!Ft(e))return;let t=Lt(e,"utf8").trim();return!t||Buffer.byteLength(t,"utf8")>Gt?void 0:t}catch{return}}function at(e,t){let s=[t?e:`${e}
|
|
3
3
|
|
|
4
4
|
${Ut}`],n=Wt(it);return n&&s.push(`# Standing instructions from ${it}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$a as ps,A as Oo,Aa as Jo,Ba as Xo,Ca as Zo,D as Rt,Da as Qo,E as No,Ea as es,G as Fo,Ga as de,Ha as E,Ia as X,J as jo,Ja as A,K as Do,Ka as ts,L as It,La as ns,M as Wo,Ma as rs,N as Uo,Na as is,O as Bo,Oa as Kn,P as Wn,Pa as os,Qa as ss,Sa as as,Ta as ls,Va as cs,X as Un,Xa as ds,Ya as us,Z as Bn,Za as fs,_a as ms,aa as Qe,ab as gs,bb as hs,c as Ao,e as To,g as Eo,h as Mo,ha as Vo,ia as et,ka as _t,n as Io,oa as Ko,pa as Go,ra as Ho,sa as qo,ta as zo,v as _o,wa as Yo,x as Lo,z as Dn,za as Vn}from"./chunk-
|
|
1
|
+
import{$a as ps,A as Oo,Aa as Jo,Ba as Xo,Ca as Zo,D as Rt,Da as Qo,E as No,Ea as es,G as Fo,Ga as de,Ha as E,Ia as X,J as jo,Ja as A,K as Do,Ka as ts,L as It,La as ns,M as Wo,Ma as rs,N as Uo,Na as is,O as Bo,Oa as Kn,P as Wn,Pa as os,Qa as ss,Sa as as,Ta as ls,Va as cs,X as Un,Xa as ds,Ya as us,Z as Bn,Za as fs,_a as ms,aa as Qe,ab as gs,bb as hs,c as Ao,e as To,g as Eo,h as Mo,ha as Vo,ia as et,ka as _t,n as Io,oa as Ko,pa as Go,ra as Ho,sa as qo,ta as zo,v as _o,wa as Yo,x as Lo,z as Dn,za as Vn}from"./chunk-AMHJO4G3.js";import{b as bs,c as ws}from"./chunk-SDU65XW4.js";import{b as Ee,c as Ze,e as Po,f as Mt,g as Ro,h as Pt}from"./chunk-XODGJSB3.js";import{A as so,B as Ct,C as ao,b as In,c as ye,d as Ji,e as Xi,h as Zi,n as _n,o as Qi,q as oe,s as eo,t as Ie,v as to,w as no,x as ro,y as io,z as oo}from"./chunk-RT3VOMO4.js";import{a as lo,b as co,c as uo,d as fo,f as mo,g as po,h as go,i as ho,l as bo}from"./chunk-WKR2L2CT.js";import{a as At,b as Ln,c as On,d as wo,e as Tt}from"./chunk-3FYCFLNK.js";import{u as yo}from"./chunk-SDO33XPR.js";import{a as ko}from"./chunk-ORJ2QZBG.js";import{a as $o,c as Et,d as Nn,j as vo,k as xo,l as So,n as Fn,o as jn,p as Co}from"./chunk-ZJL4OEXX.js";import{a as Pn,b as Rn,c as Vi,d as Ki}from"./chunk-EZNNALD3.js";import{b as St}from"./chunk-7LA2AMZB.js";import{h as Ci,i as Ai}from"./chunk-YUOYDO5O.js";import{a as vn,b as wt,e as Si}from"./chunk-WDMBTVK7.js";import{A as ji,B as vt,C as xt,D as Di,E as Cn,F as An,G as Wi,H as P,M as Xe,N as Tn,O as Ui,Q as Bi,c as xn,d as yt,g as kt,i as Ti,j as Ei,k as Mi,l as Pi,m as $t,n as Ri,o as Sn,p as Ii,s as se,t as _i,u as Li,x as Oi,y as Ni,z as Fi}from"./chunk-5FIFNXLT.js";import{a as ie}from"./chunk-UTYFLLSM.js";import{j as En,k as Mn}from"./chunk-MVVEYKN6.js";import{b as Gi,c as Hi,d as qi,e as zi,f as Yi}from"./chunk-TUXY64DT.js";import"./chunk-WOT6VMZA.js";import{execFile as yd}from"node:child_process";import{promisify as kd}from"node:util";import{appendFileSync as $d,existsSync as qt,mkdirSync as $r,readFileSync as zt,rmSync as vd,statSync as tl,writeFileSync as vr}from"node:fs";import{basename as xd,dirname as Sd,join as me,resolve as Cd}from"node:path";function ys(e){if(e==="")return!0;let t=/^\x1b\[(\d+);(\d+)u$/.exec(e);if(t&&Number(t[1])===99&&(Number(t[2])&5)!==0)return!0;let n=/^\x1b\[27;(\d+);(\d+)~$/.exec(e);return!!(n&&Number(n[2])===99&&(Number(n[1])&5)!==0)}function ks(e){let t=!1;process.on("SIGINT",()=>{t||(t=!0,e())})}function Il(e){if(!e||typeof e!="object")return;let t=e;if(!(typeof t.input!="number"&&typeof t.cacheRead!="number"&&typeof t.cacheWrite!="number"))return t}function _l(e){let t=e?.input??0,n=e?.cacheRead??0,r=e?.cacheWrite??0;return{input:t,cacheRead:n,cacheWrite:r,prompt:t+n+r}}function Ll(e){if(typeof e!="string")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Ol(e){if(!e||typeof e!="object")return;let t=e,r=(t.message&&typeof t.message=="object"?t.message:void 0)??t,o=Il(r.usage);if(!o)return;let u=typeof r.provider=="string"?r.provider:"",a=typeof r.model=="string"?r.model:"";return{usage:o,model:[u,a].filter(Boolean).join("/")}}function $s(e){let t=0,n=0,r=[],o=0,u=null;for(let g of e){let b=Ol(g);if(!b)continue;let{input:k,cacheRead:C,cacheWrite:_,prompt:O}=_l(b.usage);if(O===0)continue;t+=C,n+=k+_;let F=Ll(g.timestamp),W=u,K=W?W.at:null;if(W!==null&&C===0&&k>=1e3){let ee=F!==null&&K!==null?Math.max(0,F-K):0;r.push({missedTokens:k,idleMs:ee,modelChanged:b.model!==""&&W.model!==""&&b.model!==W.model}),o+=k}u={prompt:O,at:F??K??null,model:b.model}}let a=t+n;return{cachedTokens:t,billedTokens:n,hitRate:a>0?t/a*100:null,misses:r,missedTokens:o}}function vs(e){return e.modelChanged?"model changed, so its cache had to be built":e.idleMs>=3e5?`cache expired after ${Math.round(e.idleMs/1e3)}s idle`:e.idleMs>0?"prompt changed too early in the prefix to hit":"reason not recorded"}import{copyToClipboard as Ad,ProjectTrustStore as Td,SessionManager as Ed}from"@netrodev/hxf-coding-agent";import{CombinedAutocompleteProvider as nl,Container as Md,Editor as Pd,matchesKey as q,ProcessTerminal as Rd,ScrollView as Id,KeybindingsManager as sl,setKeybindings as al,isKeyRelease as _d,parseColor as Jt,TUI_KEYBINDINGS as ll,SelectList as Ld,TuiAltScreen as Od,truncateToWidth as We,VStack as Nd,visibleWidth as Ar,wrapTextWithAnsi as cl}from"@netrodev/hxf-tui";import{spawn as Nl}from"node:child_process";function Fl(e,t,n=2e3){return new Promise(r=>{let o=!1,u,a=k=>{o||(o=!0,u!==void 0&&clearTimeout(u),r(k))},g;try{g=Nl(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{a({ok:!1,stdout:""});return}u=setTimeout(()=>{g.kill("SIGKILL"),a({ok:!1,stdout:""})},n);let b=[];g.stdout?.on("data",k=>b.push(k)),g.on("error",()=>a({ok:!1,stdout:""})),g.on("close",k=>{a({ok:k===0,stdout:Buffer.concat(b).toString("utf8")})})})}function Gn(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}async function jl(){let e=[];process.platform==="darwin"?e.push({command:"pbpaste",args:[]}):process.platform==="win32"?e.push({command:"powershell.exe",args:["-NoProfile","-Command","Get-Clipboard -Raw"]}):(Gn()&&(e.push({command:"wl-paste",args:["--no-newline","--type","text/plain;charset=utf-8"]}),e.push({command:"wl-paste",args:["--no-newline","--type","text/plain"]}),e.push({command:"wl-paste",args:["--no-newline"]})),((process.env.DISPLAY?.length??0)>0||!Gn())&&(e.push({command:"xclip",args:["-selection","clipboard","-o"]}),e.push({command:"xsel",args:["--clipboard","--output"]})),e.push({command:"termux-clipboard-get",args:[]}));for(let t of e){let n=await Fl(t.command,t.args);if(n.ok&&n.stdout.length>0)return n.stdout}}async function xs(){let e;try{let{getNativeClipboard:r}=await import("@netrodev/hxf-tui");e=r()}catch{e=void 0}if(e)try{let r=await e.getText();if(typeof r=="string"&&r.length>0)return{ok:!0,text:r}}catch{}let t=await jl();return t!==void 0?{ok:!0,text:t}:{ok:!1,reason:`no clipboard tool could read it \u2014 ${Gn()?"install wl-clipboard (wl-paste)":process.platform==="darwin"?"pbpaste should be present on macOS":process.platform==="win32"?"Get-Clipboard should be present on Windows":"install xclip or xsel, or run under a display"}`}}import{spawn as Dl}from"node:child_process";import{mkdirSync as Wl,writeFileSync as Ul}from"node:fs";import{join as Bl}from"node:path";import{getNativeClipboard as Vl}from"@netrodev/hxf-tui";async function _e(e,t,n=4e3){let{promise:r,resolve:o}=Promise.withResolvers(),u=!1,a,g=C=>{u||(u=!0,clearTimeout(a),o(C))},b;try{b=Dl(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{return g(void 0),r}a=setTimeout(()=>{b.kill("SIGKILL"),g(void 0)},n);let k=[];return b.stdout?.on("data",C=>k.push(C)),b.on("error",()=>g(void 0)),b.on("close",C=>{let _=Buffer.concat(k);g(C===0&&_.length>0?_:void 0)}),r}function Ss(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}function Kl(e){return e.length>8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71}function Gl(e){return e.length>3&&e[0]===255&&e[1]===216&&e[2]===255}async function Hl(){try{let e=await Vl()?.getImage();if(e&&e.length>0)return Buffer.from(e)}catch{}if(process.platform==="darwin"){let e=await _e("pngpaste",["-"]);return e||await _e("osascript",["-e",`set d to the clipboard as \xABclass PNGf\xBB
|
|
2
2
|
return d`])}if(process.platform==="win32"){let e=["Add-Type -AssemblyName System.Windows.Forms","$img = [System.Windows.Forms.Clipboard]::GetImage()","if ($img -ne $null) {"," $ms = New-Object System.IO.MemoryStream"," $img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)"," [Console]::OpenStandardOutput().Write($ms.ToArray(), 0, $ms.Length)","}"].join("; ");return _e("powershell.exe",["-NoProfile","-Command",e])}if(Ss()){let e=await _e("wl-paste",["--type","image/png"]);if(e)return e}if((process.env.DISPLAY?.length??0)>0||!Ss()){let e=await _e("xclip",["-selection","clipboard","-t","image/png","-o"]);if(e)return e;let t=await _e("xclip",["-selection","clipboard","-t","image/jpeg","-o"]);if(t)return t}}function ql(e,t){let n=t==="image/jpeg"?"jpg":"png";return`pasted-${new Date(e).toISOString().replace(/[:.]/g,"-")}.${n}`}async function Hn(e=Bi,t=Date.now()){let n=await Hl();if(!n)return{ok:!1,reason:"the clipboard holds no image"};let r=Kl(n)?"image/png":Gl(n)?"image/jpeg":void 0;if(!r)return{ok:!1,reason:"the clipboard image is not PNG or JPEG"};try{Wl(e,{recursive:!0});let o=Bl(e,ql(t,r));return Ul(o,n,{mode:384}),{ok:!0,image:{path:o,data:n.toString("base64"),mimeType:r}}}catch(o){return{ok:!1,reason:`could not store the image: ${o instanceof Error?o.message:String(o)}`}}}import{TreeSelectorComponent as Fd,initTheme as jd}from"@netrodev/hxf-coding-agent";import{getKeybindings as rl}from"@netrodev/hxf-tui";import{mixColors as zl,parseColor as Yl,styleText as he}from"@netrodev/hxf-tui";var ue=process.env.HOWTOCODE_NO_MOTION!=="1",Jl=45,Cs=5,As=8,qn=1e4,Ts=6e4,Es=3,Ms=4,zn=e=>e<0?0:e>1?1:e;function ke(e,t,n){let r=zn(n);return r>=1?t:r<=0?e:zl(e,t,r)}var Lt=class{value;velocity=0;last=Date.now();target;constructor(t,n=t){this.value=t,this.target=n}set(t){this.target=t}get moving(){return Math.abs(this.target-this.value)>.15}snap(t){this.value=t,this.target=t,this.velocity=0,this.last=Date.now()}step(t=Date.now()){let n=Math.max(0,t-this.last),r=Math.min(250,n)/1e3;if(this.last=t,!ue)return this.value=this.target,this.velocity=0,this.value;n>250&&(this.velocity=0);let o=150,u=2*Math.sqrt(o),a=Math.max(1,Math.ceil(r/.008)),g=r/a;for(let b=0;b<a;b+=1)this.velocity+=(this.target-this.value)*o*g-this.velocity*u*g,this.value+=this.velocity*g;return this.moving||(this.value=this.target,this.velocity=0),this.value}};function Yn(e,t,n,r){return!ue||e<=qn?t:e>=Ts?r:ke(n,r,(e-qn)/(Ts-qn))}function Ps(e,t){return!ue||t<=0||e<0?1:1-(1-zn(e/t))**3}var Rs=260,Xl=45;function Is(e,t,n=Xl,r=400){return!ue||n<=0||e<0||e>=r?t:Math.min(t,Math.floor(e/n)+1)}function _s(e,t,n=Date.now(),r=1400){if(!ue||r<=0)return e;let o=n%r/r;return ke(e,t,o<.5?o*2:(1-o)*2)}function Ot(e,t,n){let r=he(e,{fg:t.rest},de);if(!ue||e.length===0)return r;let o=zn(n);if(o>=1)return r;let u=t.band??1,a=e.length+Ms*2,b=Math.min(a-1,Math.floor(o*a))-Ms,k=K=>{let ee=Math.abs(K-b);return ee>u?0:1-ee/(u+1)},C="",_=0,O=null,F=0,W=0;for(let K of e){let ee=k(W);O===null?O=ee:ee!==O&&(C+=he(e.slice(_,F),{fg:ke(t.rest,t.lit,O)},de),_=F,O=ee),F+=K.length,W+=1}return C+he(e.slice(_),{fg:ke(t.rest,t.lit,O??0)},de)}function Jn(e,t,n=Date.now(),r=90){let o=t[0]??Yl("#e6e6e6");if(t.length===0||e.length===0)return he(e,{fg:o},de);if(!ue||r<=0)return he(e,{fg:t[t.length-1]??o},de);let u=t.length*r,a=(n%u+u)%u,g="",b=0,k=null,C=0,_=0,O=F=>{let W=(a+F*r)/u%1*t.length,K=Math.floor(W)%t.length,ee=(K+1)%t.length;return ke(t[K]??o,t[ee]??o,W-Math.floor(W))};for(let F of e){let W=O(_);k===null?k=W:W!==k&&(g+=he(e.slice(b,C),{fg:k},de),b=C,k=W),C+=F.length,_+=1}return g+he(e.slice(b),{fg:k??o},de)}function Zl(e,t){let n=Math.abs(e-t);return n>=Cs?0:Math.ceil((1-n/Cs)*Es)/Es}function Ls(e,t,n=Date.now()){let r=t.charMs??Jl;if(!ue||e.length===0||r<=0)return he(e,{fg:t.base},de);let o=e.length+As*2,u=n/r%o-As,a=(O,F)=>he(O,{fg:ke(t.base,t.bright,F)},de),g="",b=0,k=null,C=0,_=0;for(let O of e){let F=Zl(_,u);k===null?k=F:F!==k&&(g+=a(e.slice(b,C),k),b=C,k=F),C+=O.length,_+=1}return g+a(e.slice(b),k??0)}import{readFileSync as Ql,statSync as ec}from"node:fs";import{homedir as tc}from"node:os";import{extname as nc}from"node:path";var Xn="\x1B[200~",Zn="\x1B[201~",rc={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"},Os=10*1024*1024,ic=256*1024,oc=20;function Ns(e){if(!e.startsWith(Xn)||!e.endsWith(Zn))return;let t=e.slice(Xn.length,e.length-Zn.length);if(!(t.includes(Xn)||t.includes(Zn)))return t}function Fs(e){return e.trim()===""}function sc(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")||e.startsWith("/")||e==="~"||e.startsWith("~/")}function ac(e,t=tc()){let n=e.trim();return n.startsWith("file://")&&(n=decodeURIComponent(n.slice(7)),/^\/[a-zA-Z]:\//.test(n)&&(n=n.slice(1))),!/^[a-zA-Z]:[\\/]/.test(n)&&!n.startsWith("\\\\")&&(n=n.replace(/\\([ ()'&])/g,"$1")),n==="~"?t:n.startsWith("~/")?t+n.slice(1):n}function js(e,t){let n=e.trim();if(!n||n.length>8192)return;let r,o=[...n.matchAll(/"([^"]+)"|'([^']+)'/g)].map(a=>a[1]??a[2]??"");if(o.length>0&&n.replace(/"[^"]+"|'[^']+'/g,"").trim()===""?r=o:r=n.split(/\r?\n/).map(a=>a.trim()).filter(a=>a.length>0),r.length===0||r.length>oc||!r.every(a=>sc(a)||a.startsWith("file://")))return;let u=r.map(a=>ac(a));return u.every(t)?u:void 0}function Ds(e){return rc[nc(e).toLowerCase()]}function Ws(e){return`[file ${e}]`}function Qn(e){return`[image ${e}]`}function Us(e,t){return e.replace(/\[file ([^\]\n]+)\]/g,(n,r)=>{let o=t(r);return o===void 0?n:`<file name="${r}">
|
|
3
3
|
${o.trimEnd()}
|
|
4
4
|
</file>`})}function Bs(e){try{let t=ec(e);if(!t.isFile()||t.size===0||t.size>ic)return;let n=Ql(e);return n.includes(0)?void 0:n.toString("utf8")}catch{return}}import{Markdown as Tc,wrapTextWithAnsi as Ec}from"@netrodev/hxf-tui";import{homedir as lc}from"node:os";import{isAbsolute as cc,relative as dc,resolve as uc,sep as Vs}from"node:path";import{getImageDimensions as fc,imageFallback as Ks,renderImage as mc}from"@netrodev/hxf-tui";var pc="\u25CF",nr="\u2514",Ft="\u22EF",er=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function rt(e=1e3/30){let t=Math.floor(Date.now()/e)%er.length;return er[t]??er[0]}var gc="\u25B2";var hc="\u25CB",bc=["create_object","set_properties","delete_object","clone_instance","reparent_instance","set_script_source","edit_script_lines","insert_script_lines","execute_luau","generate_mesh","generate_material","generate_procedural_model"];function rr(e){return e.includes("__")?e.slice(e.lastIndexOf("__")+2):e}function zs(e){return bc.includes(rr(e))}function tt(e,t=process.cwd()){if(!e||!cc(e))return e;let n=uc(e),r=dc(t,n);if(r==="")return".";if(r&&!r.startsWith(`..${Vs}`)&&r!=="..")return r;let o=lc();return o&&(n===o||n.startsWith(o+Vs))?`~${n.slice(o.length)}`:n}function ae(e,t){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(1,t-1))}\u2026`:n}function U(e,t){if(e&&typeof e=="object"){let n=e[t];if(typeof n=="string"&&n.length>0)return n;if(typeof n=="number")return String(n)}}function wc(e,t=160){if(!e||typeof e!="object")return"";try{let n=JSON.stringify(e);return n&&n!=="{}"?ae(n,t):""}catch{return""}}function yc(e,t){switch(e){case"read":{let n=tt(U(t,"path")??""),r=[U(t,"offset"),U(t,"limit")].filter(Boolean);return r.length>0?`${n} ${r.length===1?`offset=${r[0]}`:`offset=${r[0]}, limit=${r[1]}`}`:n}case"edit":case"write":return tt(U(t,"path")??"");case"bash":case"powershell":{let n=U(t,"command")??"";return t?.run_in_background===!0?`${n} [background]`:n}case"bash_output":{let n=U(t,"task_id"),r=U(t,"filter");return n?r?`${n} filter=${r}`:n:"all tasks"}case"kill_shell":return U(t,"task_id")??"";case"compress":{let n=U(t,"topic")??"",r=Array.isArray(t.content)?t.content.length:0;return r>1?`${n} (${r} ranges)`:n}case"grep":{let n=U(t,"pattern")??"",r=U(t,"path");return r?`${n} in ${tt(r)}`:n}case"find":case"glob":{let n=U(t,"pattern")??U(t,"glob")??"",r=U(t,"path");return r?`${n} in ${tt(r)}`:n}case"ls":return tt(U(t,"path")??".");case"task":return U(t,"agent")??"task";case"ask":return U(t,"question")??"";case"web_search":return U(t,"query")??"";case"web_fetch":return U(t,"url")??"";case"lsp":{let n=U(t,"action")??"lsp",r=U(t,"file")??"",o=U(t,"line");return o?`${n} ${r}:${o}`:`${n} ${r}`}case"quality":return U(t,"path")??"changed files";case"think":return"private";case"todo":{let n=U(t,"op")??"view",r=U(t,"task"),o=t?.items;return n==="init"&&Array.isArray(o)?`init ${o.length} task${o.length===1?"":"s"}`:r?`${n} ${r}`:n}case"context":{let n=U(t,"op")??"list",r=U(t,"key");return r?`${n} ${r}`:n}case"workflow":{let n=U(t,"path");if(n)return n;let r=U(t,"code")??"",o=/export\s+const\s+meta\s*=\s*\{[\s\S]*?name\s*:\s*["'`]([^"'`]+)/.exec(r)?.[1];if(o)return o;let u=r.trim().split(`
|
|
@@ -138,4 +138,4 @@ plan file: ${Wo()??"(unknown)"}`);return}if(s==="goal"){let d=l.trim();if(!d){m(
|
|
|
138
138
|
${Dn(p)}`);return}if(s==="session"){let d=$.model;m("session",d?`${d.provider}/${d.id}`:"no model");return}if(s==="skills"){m("skills",ws($.resourceLoader.getSkills().skills));return}if(s==="preset"){xi(l);return}if(s==="roblox"){let d=se(e.cwd).entries.find(x=>x.manifest.name==="rotoolbox");if(!d||d.source!=="installed"){m("roblox","RoToolbox is not installed. Run /preset and install RoToolbox first.");return}let p=Sn(d.dir),w=$.getActiveToolNames().filter(x=>/roblox[-_]studio/i.test(x)),h=w.length>0;m("roblox",p?`RoToolbox: disabled
|
|
139
139
|
Enable with /preset enable rotoolbox
|
|
140
140
|
The MCP server and manager stay stopped while disabled.`:["RoToolbox: active",`MCP server: ${h?`connected \u2014 ${w.length} tool${w.length===1?"":"s"} registered`:"not connected yet"}`,"Open Roblox Studio with a place, then use a prompt to inspect it.","Disable with /preset disable rotoolbox"].join(`
|
|
141
|
-
`));return}let f=bs(i,$.resourceLoader.getSkills().skills.map(d=>d.name));if(f){ai(f);return}let y=$.extensionRunner.getCommand(s??"");if(y){try{await y.handler(l,$.extensionRunner.createCommandContext())}catch(d){G(d instanceof Error?d.message:String(d))}return}m("command",`/${s??""} is not available in this screen yet`)};Io((i,s)=>{let{promise:c,resolve:l}=Promise.withResolvers();return j(i,s.map(f=>({value:f,label:f})),l,()=>l("cancelled")),c}),process.on("SIGTERM",Ge),ks(()=>{Ge()}),t.setTitle(`${vn} ${wt}`),Yd(),r.start(),r.requestRender(!0),gn(!0);{let{maybeShowWelcome:i}=await import("./chunk-
|
|
141
|
+
`));return}let f=bs(i,$.resourceLoader.getSkills().skills.map(d=>d.name));if(f){ai(f);return}let y=$.extensionRunner.getCommand(s??"");if(y){try{await y.handler(l,$.extensionRunner.createCommandContext())}catch(d){G(d instanceof Error?d.message:String(d))}return}m("command",`/${s??""} is not available in this screen yet`)};Io((i,s)=>{let{promise:c,resolve:l}=Promise.withResolvers();return j(i,s.map(f=>({value:f,label:f})),l,()=>l("cancelled")),c}),process.on("SIGTERM",Ge),ks(()=>{Ge()}),t.setTitle(`${vn} ${wt}`),Yd(),r.start(),r.requestRender(!0),gn(!0);{let{maybeShowWelcome:i}=await import("./chunk-R7ANN5PP.js");await i({cwd:e.cwd,note:e.note,signedIn:be!==void 0,runSlash:s=>{Je(s)},openExternal:s=>{Fe(s)}},j,m)}e.initialPrompt&&hn(e.initialPrompt),await new Promise(()=>{})}var Z,Jd=1e3/30,Xd=45e3;export{Pr as Dock,Er as Hud,Mr as PinnedBlock,Hd as approvalDetail,Gd as infoPanel,_t as orderModelsForDefault,Kd as pickerPanel,Im as runWorkbench,Cr as slashCommands,qd as workflowPanel,Yt as workflowPanelFromRun,Rr as workflowRunOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-
|
|
1
|
+
import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-RT3VOMO4.js";import"./chunk-7LA2AMZB.js";import"./chunk-YUOYDO5O.js";import"./chunk-WDMBTVK7.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{g as CATALOG_CACHE_TTL_MS,m as DEFAULT_CONTEXT_WINDOW,a as HOWTOCODE_BASE_URL,b as HOWTOCODE_CONSOLE_URL,l as HOWTOCODE_MODEL_COMPAT,c as HOWTOCODE_PROVIDERS,j as HTTP_IDLE_TIMEOUT_MS,r as UNLIMITED_SENTINEL,w as applyCatalog,x as applyCompat,B as checkAccount,s as checkCreditPools,t as checkUsage,d as configuredProviderIds,y as countNewModels,k as ensureGatewaySettings,C as fetchGatewayPrices,A as findLiveModels,q as isHowtoCodeProvider,h as loadCatalog,o as looksLikeToken,n as maskToken,v as mergeModels,e as newProviderEntry,p as parseModelIds,z as probeModel,D as readProviderKey,f as repairGatewayModels,i as repairModelFacts,u as syncGatewayModelsOnStart};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as c,d as l}from"./chunk-
|
|
1
|
+
import{b as c,d as l}from"./chunk-XODGJSB3.js";import{a as i,b as r}from"./chunk-WDMBTVK7.js";import{H as s}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";var d=[["/connect","sign in to howtofix.id: approve it in your browser"],["/model","choose which model answers"],["/help","list every command"],["/quit","leave"]],u=[" \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 "," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551 "," \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D "],g=[" _ _ _____ ","| | | | __ __ | ___|","| |_| | \\ \\/ / | |_ ","| _ | > < | _| ","|_| |_| /_/\\_\\ |_| "];function m(){if(process.platform==="win32")return!1;let e=(process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"").toLowerCase();return e===""||e==="c"||e==="posix"||!e.includes("utf-8")&&!e.includes("utf8")?!1:!/ja|ko|zh|_kr|_jp|_cn|_tw|_hk/.test(e)}function h(){return m()?u:g}var _="https://howtofix.id/cli";function p(e){let n=process.env.HOME??"",t=n!==""&&e.startsWith(n)?`~${e.slice(n.length)}`:e,o=t.split("/").filter(Boolean);return o.length>3?`\u2026/${o.slice(-2).join("/")}`:t}function f(e){let n=e.signedIn?d.filter(([t])=>t!=="/connect"):d;return[...h(),"",`${i} ${r} \u2014 a terminal coding agent. Describe the change you want and it reads, edits and runs the code in front of you.`,"",` working in ${p(e.cwd)}`,...e.note?[` session ${e.note}`]:[],"",...e.signedIn?[" already signed in to howtofix.id",""]:[],...n.map(([t,o])=>` ${t.padEnd(11)}${o}`),"",' Or just start typing. Every message goes to the model; anything beginning with "/" stays local.'].join(`
|
|
2
2
|
`)}function v(){return[{value:"connect",label:"Sign in to howtofix.id",description:"approve the sign-in in your browser"},{value:"ready",label:"I have a key \u2014 just give me the prompt",description:"drops you at the prompt; run /connect whenever you like"},{value:"release",label:"What's in this release",description:`opens the ${r} notes in your browser`}]}async function E(e,n,t){c(s).welcomeSeen||(l(s),t(`welcome to ${i}`,f(e)),!e.signedIn&&await new Promise(o=>{n("First run \u2014 how do you want to begin?",v(),a=>{a==="connect"&&e.runSlash("/connect"),a==="release"&&e.openExternal(_),o()},()=>o())}))}export{E as maybeShowWelcome};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as v}from"./chunk-7LA2AMZB.js";import{h as M,i as T}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-7LA2AMZB.js";import{h as M,i as T}from"./chunk-YUOYDO5O.js";import{a as w}from"./chunk-UTYFLLSM.js";import{existsSync as H,mkdirSync as I,readFileSync as b}from"node:fs";import{join as k}from"node:path";var J="https://models.dev/api.json";var N=["anthropic","openai","google","deepseek","zai","xai","moonshotai","minimax","alibaba","xiaomi","meta","tencent","nvidia","venice","openrouter"];function _(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"")}function S(n){let e=n.split("/");return _(e[e.length-1]??n)}function q(n){let e=new Map,s=new Map;if(!n||typeof n!="object")return e;let t=n,r=c=>{let o=N.indexOf(c);return o===-1?N.length:o};for(let c of Object.keys(t).sort()){let o=t[c]?.models;if(!(!o||typeof o!="object"))for(let a of Object.keys(o)){let i=o[a],u=Number(i?.limit?.context);if(!Number.isFinite(u)||u<=0)continue;let l=_(a),f=r(c),d=s.get(l);if(d!==void 0&&d<=f)continue;let m=Number(i?.limit?.output);e.set(l,{contextWindow:Math.floor(u),maxTokens:Number.isFinite(m)&&m>0?Math.floor(m):void 0,reasoning:i?.reasoning===!0,vision:Array.isArray(i?.modalities?.input)&&i.modalities.input.includes("image")}),s.set(l,f)}}return e}function A(n,e){let s=_(e);if(!s)return;let t=n.get(s);if(t)return t;let r=S(e);for(let[c,o]of n)if(S(c)===r)return o;for(let[c,o]of n)if(c.endsWith(s)||s.endsWith(c))return o}function R(n){return`${n}/models-dev-cache.json`}function $(n){let e={};for(let[s,t]of n)e[s]=[t.contextWindow,t.maxTokens??0,t.reasoning?1:0,t.vision?1:0];return JSON.stringify(e)}function P(n){let e=new Map,s;try{s=JSON.parse(n)}catch{return e}if(!s||typeof s!="object")return e;for(let[t,r]of Object.entries(s)){if(!Array.isArray(r)||r.length<3)continue;let c=Number(r[0]),o=Number(r[1]);!Number.isFinite(c)||c<=0||e.set(t,{contextWindow:Math.floor(c),maxTokens:Number.isFinite(o)&&o>0?Math.floor(o):void 0,reasoning:r[2]===1||r[2]===!0,vision:r[3]===1||r[3]===!0})}return e}async function U(n){let e=n?.url??J,s=n?.fetchImpl??fetch,t=n?.timeoutMs??2e4,r=new AbortController,c=setTimeout(()=>r.abort(),t);try{let o=await s(e,{signal:r.signal,headers:{Accept:"application/json"}});if(!o.ok)return{ok:!1,message:`the model catalogue answered ${o.status}`};let a=q(await o.json());return a.size===0?{ok:!1,message:"the model catalogue was empty or in an unexpected shape"}:{ok:!0,index:a}}catch(o){return{ok:!1,message:o instanceof Error&&o.name==="AbortError"?`the model catalogue did not answer within ${Math.round(t/1e3)}s`:"could not reach the model catalogue"}}finally{clearTimeout(c)}}var x="https://api.howtofix.id/v1",ce=v,C=["howtocode","howtocode-free"];function ue(n){try{let s=JSON.parse(b(k(n,"models.json"),"utf8")).providers;return!s||typeof s!="object"?new Set:new Set(Object.keys(s))}catch{return new Set}}function le(){return{baseUrl:x,api:"openai-completions",headers:{[M]:T()}}}function de(n){let e=k(n,"models.json"),s;try{s=JSON.parse(b(e,"utf8"))}catch{return 0}let t=s.providers;if(!t||typeof t!="object")return 0;let r=0;for(let c of C){let o=t[c];if(!o||!Array.isArray(o.models))continue;let a=Y(o.models),i={...o.headers??{},[M]:T()},u=o.headers?.[M]!==i[M];a.changed===0&&!u||(o.models=a.models,o.headers=i,r+=a.changed===0?1:a.changed)}if(r===0)return 0;try{w(e,`${JSON.stringify(s,null,2)}
|
|
2
2
|
`)}catch{return 0}return r}var G=10080*60*1e3;async function F(n,e){let s=R(n),t=e?.now??Date.now(),r,c=0;try{let i=JSON.parse(b(s,"utf8"));typeof i?.entries=="string"&&(r=P(i.entries),c=Number(i.at)||0)}catch{r=void 0}if(r&&r.size>0&&t-c<G&&!e?.force)return{index:r};let a=await U({fetchImpl:e?.fetchImpl});if(!a.ok)return r&&r.size>0?{index:r,message:a.message}:{index:new Map,message:a.message};try{I(n,{recursive:!0}),w(s,`${JSON.stringify({at:t,entries:$(a.index)})}
|
|
3
3
|
`)}catch{}return{index:a.index}}async function fe(n,e){let s=k(n,"models.json"),t;try{t=JSON.parse(b(s,"utf8"))}catch{return{changed:0}}let r=t.providers;if(!r||typeof r!="object")return{changed:0};let{index:c,message:o}=await F(n,e);if(c.size===0&&!e?.prices&&!e?.tiers)return{changed:0,message:o};let a=0;for(let i of C){let u=r[i];if(!u||!Array.isArray(u.models))continue;let l=Z(u.models,c,e?.prices,e?.tiers);l.changed!==0&&(u.models=l.models,a+=l.changed)}if(a>0)try{w(s,`${JSON.stringify(t,null,2)}
|
|
4
4
|
`)}catch{return{changed:0,message:"the models file could not be written"}}return{changed:a,message:o}}var B=3e5;function me(n){let e=k(n,"settings.json"),s={};try{let t=b(e,"utf8"),r=JSON.parse(t);r&&typeof r=="object"&&!Array.isArray(r)&&(s=r)}catch{if(H(e))return!1}if("httpIdleTimeoutMs"in s)return!1;s.httpIdleTimeoutMs=B;try{I(n,{recursive:!0}),w(e,`${JSON.stringify(s,null,2)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"./chunk-
|
|
1
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"./chunk-WKR2L2CT.js";import"./chunk-YUOYDO5O.js";import"./chunk-WDMBTVK7.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{b as CLI_REFRESH_SKEW_MS,c as accessTokenIsFresh,g as clearCliCredential,a as cliCredentialsPath,e as readCliCredential,h as refreshCliCredential,d as refreshTokenIsUsable,i as renewCliCredentialIfNeeded,f as writeCliCredential};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-XODGJSB3.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{a as DEFAULT_WORKBENCH_SETTINGS,d as markWelcomeSeen,b as readWorkbenchSettings,f as rightClickPastesHere,g as writeAgentsSetting,e as writeRightClickPasteSetting,h as writeStringSetting,c as writeWorkbenchSetting};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var a="HowToCode",o="0.7.
|
|
1
|
+
var a="HowToCode",o="0.7.73",n=["You are HowToCode, a coding agent. The user wants the fix, not a tour of the problem.",'NEVER report a check you did not run. NEVER state a version, path, result or capability you have not verified \u2014 if you did not check it, say you are unsure. "Not found" is not "impossible": a tool missing from PATH is often installed anyway, and one that is truly absent can usually be installed. Exhaust the real options before calling anything unavailable; when you do report a limit, say plainly what you tried and what you could not do. Unexercised behaviour is not evidence.',"NEVER mention the underlying harness, its vendor or its project name to the user.","Every tool is `read`, `write` or `exec`, and each approval mode auto-approves every tier up to its own: `suggest` runs `read` only, `auto-edit` adds `write`, `full-auto` adds `exec`. A read-only shell command runs in every mode, so inspecting the tree asks nothing.","NEVER aim a command at the filesystem root, a block device or a system account file, and NEVER shut down the host: those are refused in EVERY mode, `full-auto` included, so proposing one wastes the turn. This is not a list of things to avoid \u2014 it is a list of things that will not run.","Lead with the diagnosis in one or two sentences, then change the code. SHOULD prefer the smallest correct change over a rewrite. Name the file and the reason in a short line; do not narrate tool calls.","Fix the problem that was asked for. NEVER add features, refactors, validation, error handling or dependencies nobody requested.","Something reported broken: reproduce it first, confirm the fix after. Cannot reproduce it? Say so \u2014 NEVER edit code and call it fixed.","Tests describe intended behaviour. A failing test means fix the code, not the test: NEVER delete, skip or loosen an assertion to get green, and NEVER re-pin an expected value to whatever the code happens to print.","Anything you cannot settle by reading \u2014 a page, a layout, a screenshot, a CLI, a service, a failure \u2014 run it and look at the result. For a visual task, find a browser the way a real one does: `$PUPPETEER_EXECUTABLE_PATH`, `$CHROME_PATH`, then `which` for google-chrome, chromium and chromium-browser, then /usr/bin, /snap/bin and /var/lib/flatpak, then the puppeteer and playwright caches under the home directory. Still empty? `npx -y puppeteer browsers install chrome`, or `npm i puppeteer-core` against a chrome the image already ships outside PATH. Then drive the real artifact \u2014 open it, read the DOM, click the controls, measure at the widths that matter \u2014 instead of describing what you assume it does.","Done means the requested behaviour works end to end and every stated requirement is met \u2014 not a scaffold, a narrowed test or a plausible subset. Genuinely out of reach? Finish everything else, then say exactly what is missing and what you tried.","SHOULD plan multi-step work with `todo` before starting it, and mark each step done as you finish. A plan the user can see is worth more than a narration of what you are about to do.","Genuinely ambiguous design: enter plan mode, write the plan to the plan file, then present it with `exit_plan_mode`. Use it when several reasonable approaches exist or when a restructuring would be hard to undo. In plan mode `edit` and `write` are refused for every path except the plan file itself \u2014 that limit is enforced, not advisory, so plan the work rather than starting it. Plan mode needs an interactive session in which the user can approve it; when there is no UI it is unavailable, so design the approach yourself instead of calling it.","Work that is independent and would flood this conversation belongs in `task` subagents. Give each a self-contained assignment, then verify the file it wrote rather than trusting its summary. When that work has a shape you can script \u2014 many items through the same stages, or fan-out whose results must be combined \u2014 `workflow` states the orchestration in one place and runs it deterministically; `task` is for the one-off you cannot describe in advance.","MUST give each subagent a self-contained assignment: a child starts with none of this conversation, so a brief that says 'the file we discussed' reaches it as nothing. Choose the agent by what the work is \u2014 scout looks something up, architect returns a plan, reviewer reports issues with file evidence, task changes files \u2014 and NEVER send work that needs an edit to scout or reviewer, because neither can make one.","SHOULD delegate only work that is genuinely parallel: a subagent costs its own session and its own requests on the same quota as this conversation. A single lookup, a file you can read yourself, or a step whose result decides the next step stays here. MUST keep one call to at most six agents and the session to twelve live or parked ones \u2014 a larger fan-out is refused, and the refusal is a limit rather than a failure to work around.","Record a decision, a file's role, or a fact you would otherwise re-derive with `context`: notes survive compaction and are visible to the other agents on the task.","Look it up instead of recalling it: `web_search` and `web_fetch` for anything outside this repo, `lsp` for a definition, reference or diagnostic. Name the source you checked.","Before calling changed code done, run `quality` and `slop` over it and act on what they report. A metric you did not measure is a claim you cannot make.","A command runs under a two-minute default timeout. MUST pass a longer timeout for anything that legitimately takes more than that \u2014 a recursive directory walk, a package install, a build, a network fetch \u2014 and SHOULD prefer a bounded command to an unbounded one: 'du -sh' with an explicit path beats the whole profile, and on Windows/MSYS a recursive 'du' over a profile directory takes minutes rather than seconds.","When a choice blocks the task, use `ask` instead of guessing; when you need to work something out, use `think`, whose text stays out of the transcript.","Above all: NEVER claim a check you did not run, and NEVER call done on a subset."].join(`
|
|
2
2
|
`);function s(e){return e===void 0?void 0:e.replace(/Use \/login to log into a provider[^\n]*/gi,"Connect a provider with /connect or /login:").replace(/^[ \t]*\S*hxf-coding-agent[\\/]docs[\\/][^\n]*$/gim,"").replace(/\bhxf-coding-agent\b/gi,"the harness").replace(/\n{3,}/g,`
|
|
3
3
|
|
|
4
4
|
`).trim()}var i=["# Project notes","","## What this is","","## Commands","- build:","- test:","","## Conventions","-",""].join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as T,j as R}from"./chunk-VSVEFNSH.js";import{a as P}from"./chunk-UTYFLLSM.js";import{existsSync as z,readFileSync as ye,rmSync as xe}from"node:fs";import{join as ve}from"node:path";import{createHash as q,randomBytes as J}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as F,cpus as M,hostname as N,platform as v,userInfo as O}from"node:os";var te="howtocode-cli-hwid-v1";function x(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function $(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=v();if(e==="linux"){let t=x("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=x("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let o=x("/sys/class/dmi/id/product_uuid");return o?{value:o,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=$("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=$("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function H(){let e=re(),t=e?.value??[N(),v(),F(),O().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function U(e){return[e.id,e.source,N(),v(),F(),O().username,String(M().length),M()[0]?.model??""]}var _="https://howtofix.id",se=300*1e3,G=3e3,K="/callback";function I(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return I(J(32))}function ie(e){return I(q("sha256").update(e).digest())}function ae(){return I(J(16))}var ce="howtocode-cli-",ue="x-howtocode-client",le="cli";function L(e){let t=e??U(H());return ce+q("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:o}=r.address();e({port:o,close:()=>r.close(),waitForCode:(n,s)=>new Promise((i,a)=>{let c=(l,f)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){f.writeHead(404).end("not found");return}let y=(V,Z)=>f.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),S=h.searchParams.get("error")??"",E=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(S){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${S}`));return}if(!E||Y!==n){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToCode."),u(void 0,E)},u=(l,f)=>{r.off("request",c),s?.removeEventListener("abort",g),l?a(l):i(f)},g=()=>u(new Error("cancelled"));s?.addEventListener("abort",g,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function p(e,t,r,o){let n=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:o}),s={};try{s=await n.json()}catch{}let i=Number(n.headers?.get?.("retry-after"));return{status:n.status,body:s,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function j(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function ge(e,t,r){let o=await e(t,{headers:de(),signal:r}),n={};try{n=await o.json()}catch{}let s=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(s)&&s>0?s:void 0}}function A(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let o of r)if(typeof o=="string"&&o.trim().startsWith("sk-"))return o.trim()}function pe(e){let t=e.data,r=d(e.token,t?.token),o=d(e.refresh_token,t?.refresh_token),n=d(e.device_id,t?.device_id);if(!r||!o||!n)return;let s=j(e.access_expires_at,t?.access_expires_at),i=j(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:s,refreshToken:o,deviceId:n,refreshExpiresAt:i}}function m(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function He(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??_).replace(/\/+$/,""),o=e.timeoutMs??se,n={...e,panel:r,fetchImpl:t,timeoutMs:o},s=await ke(n);if(s.ok||s.terminal)return s.result;let i=await he(n);if(i.ok||i.terminal)return i.result;let a=await we(n);return a.ok?a:{ok:!1,message:`${s.result.ok?"":s.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),o;try{o=await(e.loopback??fe)();let n=`http://127.0.0.1:${o.port}${K}`,s=await p(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:n,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(s.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(s.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(s.body,`the panel refused the login (${s.status})`)}};let i=typeof s.body.authorize_url=="string"?s.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(o.waitForCode(r,e.signal),e.timeoutMs),c=await p(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:s.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(c.body,`the panel refused the exchange (${c.status})`)}};let u=A(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}finally{o?.close()}}async function ke(e){let t=e.fingerprintId??L(),r=e.clientInfo??T(),o=R(t,r);try{let n=await p(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:t,clientInfo:r,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToCode CLI \u2014 update it with `npm install -g howtocode@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(n.body,`the panel refused the login (${n.status})`)}};let s=n.body.data??{},i=d(n.body.login_url,s.login_url),a=d(n.body.code,s.code)??(i?me(i):void 0),c=d(n.body.secret,s.secret);return!i||!a?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:c?(k(e,{kind:"browser",url:i}),await D(e,a,c)):(k(e,{kind:"browser",url:i}),await D(e,a,void 0))}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}}async function D(e,t,r){let o=e.pollIntervalMs??G,n=Date.now()+e.timeoutMs;for(;Date.now()<n;){await w(o,e.signal);let s=new URLSearchParams(r?{code:t,secret:r}:{code:t});s.set("capability","device-refresh");let i=await ge(e.fetchImpl,`${e.panel}/api/auth/cli/status?${s}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=A(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:pe(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??G;try{let r=await p(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:m(r.body,`the panel refused the request (${r.status})`)};let o=typeof r.body.device_code=="string"?r.body.device_code:"",n=typeof r.body.user_code=="string"?r.body.user_code:"",s=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!o||!n)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:n,url:s});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await p(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:o},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=A(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:m(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,o)=>{let n=setTimeout(()=>o(new Error("the sign-in was not finished in time")),t);e.then(s=>{clearTimeout(n),r(s)},s=>{clearTimeout(n),o(s)})})}function w(e,t){return new Promise((r,o)=>{let n=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(n),o(new Error("cancelled"))},{once:!0})})}function b(e){return ve(e,"cli-credentials.json")}var _e=300*1e3;function Ie(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-_e>t:!1}function Le(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Ge(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let o=r,n=typeof o.accessToken=="string"?o.accessToken.trim():"",s=typeof o.refreshToken=="string"?o.refreshToken.trim():"",i=typeof o.deviceId=="string"?o.deviceId.trim():"";if(!(!n||!s||!i))return{accessToken:n,accessExpiresAt:W(o.accessExpiresAt),refreshToken:s,deviceId:i,refreshExpiresAt:W(o.refreshExpiresAt)}}function Ae(e,t){try{return P(b(e),`${JSON.stringify(t,null,2)}
|
|
1
|
+
import{g as T,j as R}from"./chunk-YUOYDO5O.js";import{a as P}from"./chunk-UTYFLLSM.js";import{existsSync as z,readFileSync as ye,rmSync as xe}from"node:fs";import{join as ve}from"node:path";import{createHash as q,randomBytes as J}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as F,cpus as M,hostname as N,platform as v,userInfo as O}from"node:os";var te="howtocode-cli-hwid-v1";function x(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function $(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=v();if(e==="linux"){let t=x("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=x("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let o=x("/sys/class/dmi/id/product_uuid");return o?{value:o,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=$("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=$("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function H(){let e=re(),t=e?.value??[N(),v(),F(),O().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function U(e){return[e.id,e.source,N(),v(),F(),O().username,String(M().length),M()[0]?.model??""]}var _="https://howtofix.id",se=300*1e3,G=3e3,K="/callback";function I(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return I(J(32))}function ie(e){return I(q("sha256").update(e).digest())}function ae(){return I(J(16))}var ce="howtocode-cli-",ue="x-howtocode-client",le="cli";function L(e){let t=e??U(H());return ce+q("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:o}=r.address();e({port:o,close:()=>r.close(),waitForCode:(n,s)=>new Promise((i,a)=>{let c=(l,f)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){f.writeHead(404).end("not found");return}let y=(V,Z)=>f.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),S=h.searchParams.get("error")??"",E=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(S){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${S}`));return}if(!E||Y!==n){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToCode."),u(void 0,E)},u=(l,f)=>{r.off("request",c),s?.removeEventListener("abort",g),l?a(l):i(f)},g=()=>u(new Error("cancelled"));s?.addEventListener("abort",g,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function p(e,t,r,o){let n=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:o}),s={};try{s=await n.json()}catch{}let i=Number(n.headers?.get?.("retry-after"));return{status:n.status,body:s,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function j(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function ge(e,t,r){let o=await e(t,{headers:de(),signal:r}),n={};try{n=await o.json()}catch{}let s=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(s)&&s>0?s:void 0}}function A(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let o of r)if(typeof o=="string"&&o.trim().startsWith("sk-"))return o.trim()}function pe(e){let t=e.data,r=d(e.token,t?.token),o=d(e.refresh_token,t?.refresh_token),n=d(e.device_id,t?.device_id);if(!r||!o||!n)return;let s=j(e.access_expires_at,t?.access_expires_at),i=j(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:s,refreshToken:o,deviceId:n,refreshExpiresAt:i}}function m(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function He(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??_).replace(/\/+$/,""),o=e.timeoutMs??se,n={...e,panel:r,fetchImpl:t,timeoutMs:o},s=await ke(n);if(s.ok||s.terminal)return s.result;let i=await he(n);if(i.ok||i.terminal)return i.result;let a=await we(n);return a.ok?a:{ok:!1,message:`${s.result.ok?"":s.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),o;try{o=await(e.loopback??fe)();let n=`http://127.0.0.1:${o.port}${K}`,s=await p(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:n,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(s.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(s.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(s.body,`the panel refused the login (${s.status})`)}};let i=typeof s.body.authorize_url=="string"?s.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(o.waitForCode(r,e.signal),e.timeoutMs),c=await p(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:s.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(c.body,`the panel refused the exchange (${c.status})`)}};let u=A(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}finally{o?.close()}}async function ke(e){let t=e.fingerprintId??L(),r=e.clientInfo??T(),o=R(t,r);try{let n=await p(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:t,clientInfo:r,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToCode CLI \u2014 update it with `npm install -g howtocode@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:m(n.body,`the panel refused the login (${n.status})`)}};let s=n.body.data??{},i=d(n.body.login_url,s.login_url),a=d(n.body.code,s.code)??(i?me(i):void 0),c=d(n.body.secret,s.secret);return!i||!a?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:c?(k(e,{kind:"browser",url:i}),await D(e,a,c)):(k(e,{kind:"browser",url:i}),await D(e,a,void 0))}catch(n){let s=n instanceof Error?n.message:String(n);return{ok:!1,terminal:s==="cancelled",result:{ok:!1,message:s}}}}async function D(e,t,r){let o=e.pollIntervalMs??G,n=Date.now()+e.timeoutMs;for(;Date.now()<n;){await w(o,e.signal);let s=new URLSearchParams(r?{code:t,secret:r}:{code:t});s.set("capability","device-refresh");let i=await ge(e.fetchImpl,`${e.panel}/api/auth/cli/status?${s}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=A(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:pe(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:m(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??G;try{let r=await p(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:m(r.body,`the panel refused the request (${r.status})`)};let o=typeof r.body.device_code=="string"?r.body.device_code:"",n=typeof r.body.user_code=="string"?r.body.user_code:"",s=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!o||!n)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:n,url:s});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await p(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:o},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=A(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:m(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,o)=>{let n=setTimeout(()=>o(new Error("the sign-in was not finished in time")),t);e.then(s=>{clearTimeout(n),r(s)},s=>{clearTimeout(n),o(s)})})}function w(e,t){return new Promise((r,o)=>{let n=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(n),o(new Error("cancelled"))},{once:!0})})}function b(e){return ve(e,"cli-credentials.json")}var _e=300*1e3;function Ie(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-_e>t:!1}function Le(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Ge(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let o=r,n=typeof o.accessToken=="string"?o.accessToken.trim():"",s=typeof o.refreshToken=="string"?o.refreshToken.trim():"",i=typeof o.deviceId=="string"?o.deviceId.trim():"";if(!(!n||!s||!i))return{accessToken:n,accessExpiresAt:W(o.accessExpiresAt),refreshToken:s,deviceId:i,refreshExpiresAt:W(o.refreshExpiresAt)}}function Ae(e,t){try{return P(b(e),`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,{mode:384}),!0}catch{return!1}}function Ce(e){try{let t=b(e);z(t)&&xe(t,{force:!0})}catch{}}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:0}async function Se(e,t){let r=(t?.panelUrl??_).replace(/\/+$/,""),o=t?.fetchImpl??fetch,n=t?.timeoutMs??15e3,s=new AbortController,i=setTimeout(()=>s.abort(),n);try{let a=await o(`${r}/api/auth/cli/refresh`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({device_id:e.deviceId,refresh_token:e.refreshToken,fingerprint_id:L()}),signal:s.signal}),c=await a.json().catch(()=>({}));if(a.status===401||a.status===403)return{ok:!1,terminal:!0,message:"this sign-in is no longer valid; run /connect to sign in again"};if(!a.ok)return{ok:!1,terminal:!1,message:`the panel refused the renewal (${a.status})`};let u=c.data??{},g=C(c.token,u.token),l=C(c.refresh_token,u.refresh_token),f=C(c.device_id,u.device_id)??e.deviceId;return!g||!l?{ok:!1,terminal:!1,message:"the panel did not return a renewed credential"}:{ok:!0,terminal:!1,credential:{accessToken:g,accessExpiresAt:B(c.access_expires_at,u.access_expires_at),refreshToken:l,deviceId:f,refreshExpiresAt:B(c.refresh_expires_at,u.refresh_expires_at)}}}catch(a){return{ok:!1,terminal:!1,message:a instanceof Error&&a.name==="AbortError"?`the panel did not answer within ${Math.round(n/1e3)}s`:"could not reach the panel"}}finally{clearTimeout(i)}}function C(...e){for(let t of e)if(typeof t=="string"&&t.trim())return t.trim()}function B(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}async function Ke(e,t,r){let o=r?.now??Date.now();if(Ie(t,o)||!Le(t,o))return{credential:t,renewed:!1,terminal:!1};let n=await Se(t,r);if(!n.ok||!n.credential)return n.terminal&&Ce(e),{credential:t,renewed:!1,terminal:n.terminal,message:n.message};let s=Ae(e,n.credential);return{credential:n.credential,renewed:!0,terminal:!1,message:s?void 0:`the renewed sign-in could not be saved to ${b(e)}`}}export{H as a,_ as b,He as c,b as d,_e as e,Ie as f,Le as g,Ge as h,Ae as i,Ce as j,Se as k,Ke as l};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as u}from"./chunk-UTYFLLSM.js";import{existsSync as g,mkdirSync as f,readFileSync as c}from"node:fs";import{dirname as d,join as p}from"node:path";var a={skipPermissions:!1,autoUpdate:!0,rightClickPaste:"auto",welcomeSeen:!1,compressToolOutput:!1};function l(t){return p(t,"settings.json")}function k(t){try{let e=JSON.parse(c(l(t),"utf8")),n=r=>{let i=e[r];return typeof i=="boolean"?i:a[r]},o=e.rightClickPaste;return{skipPermissions:n("skipPermissions"),autoUpdate:n("autoUpdate"),rightClickPaste:o==="on"||o==="off"||o==="auto"?o:a.rightClickPaste,welcomeSeen:n("welcomeSeen"),compressToolOutput:n("compressToolOutput"),...typeof e.agents=="number"&&Number.isInteger(e.agents)&&e.agents>0?{agents:e.agents}:{},...typeof e.discordClientId=="string"&&e.discordClientId.trim().length>0?{discordClientId:e.discordClientId.trim()}:{}}}catch{return{...a}}}function h(t,e,n){return s(t,e,n)}function w(t){return s(t,"welcomeSeen",!0)}function C(t,e){return s(t,"rightClickPaste",e==="auto"?void 0:e)}function P(t){return t==="on"?!0:t==="off"?!1:process.platform!=="win32"}function y(t,e){let n=typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0;return s(t,"agents",n)}function x(t,e,n){let o=n.trim();return s(t,e,o===""?void 0:o)}function s(t,e,n){let o=l(t),r={};try{let i=JSON.parse(c(o,"utf8"));i&&typeof i=="object"&&!Array.isArray(i)&&(r=i)}catch{if(g(o))return!1}n===void 0?delete r[e]:r[e]=n;try{f(d(o),{recursive:!0}),u(o,`${JSON.stringify(r,null,2)}
|
|
2
|
+
`)}catch{return!1}return!0}export{a,k as b,h as c,w as d,C as e,P as f,y as g,x as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as o}from"./chunk-
|
|
1
|
+
import{b as o}from"./chunk-WDMBTVK7.js";import{createPrivateKey as p,createPublicKey as f,createHash as l,randomBytes as d,sign as y}from"node:crypto";import{arch as c,cpus as m,hostname as I,platform as s}from"node:os";var a="hf-cli-1",C="MC4CAQAwBQYDK2VwBCIEIDmKoNgInS7oDpncee1d1+Mnci1R/q4aE5xxHeCKq4Dc",x="howtocode-cli-auth-v1",i;function u(){return i||(i=p({key:Buffer.from(C,"base64"),format:"der",type:"pkcs8"})),i}function g(){return f(u())}function K(t,e,n,r){return Buffer.from([x,t,e,n,r].join(`
|
|
2
2
|
`),"utf8")}function h(){return d(16).toString("hex")}var E="tQ91uspGl0sw5Y8x+soLYnFNX6a9vEzSzCuuvalzdKk=";function P(){let t=g().export({format:"der",type:"spki"});return t.subarray(t.length-32).toString("base64")===E}function N(){let t=g().export({format:"der",type:"spki"});return l("sha256").update(t).digest("hex").slice(0,16)}function $(){let e=(m()[0]?.model??"").replace(/\s+/g," ").trim(),n=I(),r=e?`${n} (${s()}/${c()}, ${e})`:`${n} (${s()}/${c()})`;return`CLI (${o}, ${r})`}var k="X-HowToCode-Client";function A(){return`CLI (${o})`}function B(t,e){let n=h(),r=y(null,K(a,t,e,n),u());return{keyId:a,nonce:n,signature:r.toString("base64")}}export{a,g as b,K as c,h as d,P as e,N as f,$ as g,k as h,A as i,B as j};
|
package/dist/cli-auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-YUOYDO5O.js";import"./chunk-WDMBTVK7.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
|
package/dist/main-app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as
|
|
2
|
+
import{b as q,d as Q,e as Z}from"./chunk-EZNNALD3.js";import"./chunk-7LA2AMZB.js";import{e as K,f as J}from"./chunk-YUOYDO5O.js";import{c as z}from"./chunk-PH72JBBL.js";import{a as V,b as F}from"./chunk-MCAAX33K.js";import{a as d,b as v}from"./chunk-WDMBTVK7.js";import{H as _,P as Y}from"./chunk-5FIFNXLT.js";import"./chunk-UTYFLLSM.js";import{j as X}from"./chunk-MVVEYKN6.js";import"./chunk-WOT6VMZA.js";import{existsSync as Xe,mkdirSync as ze,readdirSync as pe,statSync as qe,writeFileSync as Qe}from"node:fs";import{basename as Ze,join as N}from"node:path";var ee={rpc:!0,acp:!0},te={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},se={suggest:!0,"auto-edit":!0,"full-auto":!0},oe={text:!0,json:!0,"stream-json":!0};function Ue(c){let e=Number(c);if(!Number.isFinite(e)||e<=0)throw new Error(`--max-budget-usd needs a positive number of dollars, got '${c}'`);return e}function E(c,e,t){let s=c[e];if(s?.includes("="))return s.slice(s.indexOf("=")+1);let i=c[e+1];if(!i||i.startsWith("-"))throw new Error(`${t} needs a value`);return c.splice(e+1,1),i}function ne(c){let e={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,outputFormat:"text",dangerouslySkipPermissions:!1,sandbox:!1,prompt:""},t=[],s=[...c];s[0]==="resume"&&s[1]&&!s[1].startsWith("-")&&(e.resumeId=s[1],s.splice(0,2));for(let i=0;i<s.length;i++){let o=s[i]??"";if(o==="--"){t.push(...s.slice(i+1));break}if(o==="-h"||o==="--help")e.help=!0;else if(o==="-v"||o==="--version")e.version=!0;else if(o==="-p"||o==="--print")e.print=!0;else if(o==="-c"||o==="--continue")e.continueSession=!0;else if(o==="--no-session")e.noSession=!0;else if(o==="--sandbox")e.sandbox=!0;else if(o==="--update")e.update=!0;else if(o==="--check-update")e.checkUpdate=!0;else if(o==="-r"||o==="--resume")e.continueSession=!0;else if(o==="--session"||o.startsWith("--session="))e.sessionPath=E(s,i,"--session");else if(o==="-m"||o==="--model"||o.startsWith("--model="))e.model=E(s,i,"--model");else if(o==="--thinking"||o.startsWith("--thinking="))e.thinking=E(s,i,"--thinking");else if(o==="--approval"||o.startsWith("--approval="))e.approval=E(s,i,"--approval");else if(o==="--output-format"||o.startsWith("--output-format="))e.outputFormat=E(s,i,"--output-format");else if(o==="--max-budget-usd"||o.startsWith("--max-budget-usd="))e.maxBudgetUsd=Ue(E(s,i,"--max-budget-usd"));else if(o==="--mode"||o.startsWith("--mode=")){let h=E(s,i,"--mode");if(!ee[h])throw new Error(`--mode must be one of: ${Object.keys(ee).join(", ")}`);e.mode=h}else if(o==="--acp")e.mode="acp";else if(o==="--dangerously-skip-permissions")e.dangerouslySkipPermissions=!0;else{if(o.startsWith("-"))throw new Error(`unknown option ${o}`);t.push(o)}}if(e.thinking&&!te[e.thinking])throw new Error(`thinking must be one of: ${Object.keys(te).join(", ")}`);if(e.approval&&!se[e.approval])throw new Error(`approval must be one of: ${Object.keys(se).join(", ")}`);if(!oe[e.outputFormat])throw new Error(`output-format must be one of: ${Object.keys(oe).join(", ")}`);if(e.outputFormat!=="text"&&!e.print)throw new Error(`--output-format ${e.outputFormat} is a machine contract; it needs --print`);if(e.dangerouslySkipPermissions&&!e.print)throw new Error("--dangerously-skip-permissions is for unattended runs; it needs --print. interactively, pick an approval mode instead (/approval, or --approval)");if(e.prompt=t.join(" ").trim(),e.update&&e.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((e.update||e.checkUpdate)&&(e.print||e.continueSession||e.sessionPath||e.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(e.continueSession&&e.noSession)throw new Error("--continue and --no-session cannot be combined");if(e.sessionPath&&e.noSession)throw new Error("--session and --no-session cannot be combined");if(e.sessionPath&&e.continueSession)throw new Error("--session and --continue cannot be combined");if(e.resumeId&&e.sessionPath)throw new Error("resume <id> and --session cannot be combined");if(e.resumeId&&e.continueSession)throw new Error("resume <id> and --continue cannot be combined");if(e.print&&(e.continueSession||e.sessionPath||e.resumeId))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue, --session, or resume <id>");if(e.mode&&(e.print||e.prompt))throw new Error(`--mode ${e.mode} is a protocol server: prompts arrive over the protocol, not the command line`);if(e.mode&&(e.continueSession||e.sessionPath))throw new Error(`--mode ${e.mode} opens its own sessions; it cannot be combined with --continue or --session`);if(e.sessionPath&&!e.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${e.sessionPath}'`);return e}function R(){return`${d} ${v}
|
|
3
3
|
coding agent. layout is a workbench, not a chat log.
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -90,13 +90,13 @@ an npm install checks for a newer release at startup and can install it itself;
|
|
|
90
90
|
/update does it on demand. config and sessions live in ~/.howtocode/agent.
|
|
91
91
|
/connect signs in to howtofix.id in your browser, and falls back to a pasted
|
|
92
92
|
token; /login takes another provider's key.
|
|
93
|
-
`}function
|
|
94
|
-
${
|
|
95
|
-
`)?`${
|
|
96
|
-
${
|
|
97
|
-
${
|
|
98
|
-
`)}let w,
|
|
99
|
-
`)}process.exitCode=1;return}let
|
|
100
|
-
`)}else process.stdout.write(
|
|
101
|
-
`)?
|
|
102
|
-
`);if(g&&(process.exitCode=1,g.errorMessage)){console.error(`${
|
|
93
|
+
`}function Be(c,e=!1){let{message:t,hint:s}=V(c),i=s?`${t}
|
|
94
|
+
${s}`:t;if(!e)return i;let o=c instanceof Error?c.stack:void 0;return o&&o.includes(`
|
|
95
|
+
`)?`${i}
|
|
96
|
+
${o}`:i}function re(c,e){let t=e?.debug??process.env.HOWTOCODE_DEBUG==="1",s=e?.exit??(o=>process.exit(o)),i=o=>{console.error(`${c}: ${Be(o,t)}`),s(1)};process.on("uncaughtException",i),process.on("unhandledRejection",i)}import{connect as He}from"node:net";var x={HANDSHAKE:0,FRAME:1,CLOSE:2,PING:3,PONG:4},de="1560641616753066135",ie=10,We=1e4,ae=1e3,Ge=3e4,Ke=3e4,Je=15e3;function Ve(c=process.platform){if(c==="win32")return Array.from({length:ie},(s,i)=>`\\\\?\\pipe\\discord-ipc-${i}`);let e=process.env.XDG_RUNTIME_DIR??process.env.TMPDIR??process.env.TMP??"/tmp";return[e,`${e}/app/com.discordapp.Discord`,`${e}/snap.discord`,`${e}/.flatpak/dev.vencord.Vesktop`,`${e}/.flatpak/com.discordapp.Discord`].flatMap(s=>Array.from({length:ie},(i,o)=>`${s.replace(/\/+$/,"")}/discord-ipc-${o}`))}function ce(c,e){let t=Buffer.from(JSON.stringify(e??{}),"utf8"),s=Buffer.allocUnsafe(8+t.length);return s.writeUInt32LE(c,0),s.writeUInt32LE(t.length,4),t.copy(s,8),s}function Ye(c){let e=[],t=c;for(;t.length>=8;){let s=t.readUInt32LE(0),i=t.readUInt32LE(4);if(t.length<8+i)break;let o=t.subarray(8,8+i).toString("utf8");t=t.subarray(8+i);let h;try{h=JSON.parse(o)}catch{h={raw:o}}e.push({op:s,payload:h})}return{frames:e,rest:t}}var M=class{clientId;activity;candidates;log;socket;buffer=Buffer.alloc(0);ready=!1;stopped=!1;reconnectTimer;pingTimer;handshakeTimer;reconnectDelay=ae;lastSent=0;applied="";constructor(e){this.clientId=e.clientId,this.activity=e.activity,this.candidates=e.candidates??Ve(),this.log=e.log??(()=>{})}start(){this.stopped||this.socket!==void 0||this.reconnectTimer!==void 0||this.clientId.trim().length!==0&&this.connectToAny(0)}update(e){this.activity=e,this.flush(!1)}stop(){if(this.stopped=!0,this.ready=!1,clearTimeout(this.reconnectTimer),clearTimeout(this.handshakeTimer),clearInterval(this.pingTimer),this.reconnectTimer=void 0,this.handshakeTimer=void 0,this.pingTimer=void 0,this.socket){try{this.socket.write(ce(x.CLOSE,{code:1e3,message:"HowToCode stopped"})),this.socket.end()}catch{}this.socket.destroy(),this.socket=void 0}}connectToAny(e){if(this.stopped)return;if(e>=this.candidates.length){this.log("Discord IPC socket not found; presence disabled"),this.scheduleReconnect();return}let t=this.candidates[e],s=He(t);s.once("connect",()=>{s.removeAllListeners("error"),this.attach(s)}),s.once("error",()=>{s.destroy(),this.connectToAny(e+1)})}attach(e){this.socket=e,this.buffer=Buffer.alloc(0),this.ready=!1,e.on("data",t=>this.onData(t)),e.on("close",()=>this.onDrop("Discord closed the socket")),e.on("error",t=>this.onDrop(t.message)),this.handshakeTimer=setTimeout(()=>this.onDrop("Discord handshake timed out"),We),this.write(x.HANDSHAKE,{v:1,client_id:this.clientId})}onData(e){this.buffer=Buffer.concat([this.buffer,e]);let t=Ye(this.buffer);this.buffer=t.rest;for(let s of t.frames)this.onFrame(s.op,s.payload)}onFrame(e,t){if(e===x.PING){this.write(x.PONG,t);return}if(e===x.CLOSE){let o=typeof t=="object"&&t!==null&&"code"in t?t.code:void 0;this.onDrop(`Discord closed the session${o===4e3?" (unknown application id)":""}`);return}if(e!==x.FRAME||typeof t!="object"||t===null)return;let s="evt"in t?t.evt:void 0,i="cmd"in t?t.cmd:void 0;if(s==="READY"){clearTimeout(this.handshakeTimer),this.handshakeTimer=void 0,this.ready=!0,this.reconnectDelay=ae,this.applied="",this.startPing(),this.flush(!0);return}i==="SET_ACTIVITY"&&this.log("presence updated")}write(e,t){let s=this.socket;if(!s||s.destroyed)return!1;try{return s.write(ce(e,t)),!0}catch(i){return this.onDrop(i instanceof Error?i.message:String(i)),!1}}startPing(){clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>this.write(x.PING,{t:Date.now()}),Ke),this.pingTimer.unref?.()}flush(e){if(!this.ready||this.stopped)return;let t=Date.now();if(!e&&t-this.lastSent<Je)return;let s=JSON.stringify(this.activity);s!==this.applied&&(this.applied=s,this.lastSent=t,this.write(x.FRAME,{cmd:"SET_ACTIVITY",args:{pid:process.pid,activity:this.activity},nonce:`howtocode-${t}`}))}onDrop(e){this.ready=!1,clearTimeout(this.handshakeTimer),clearInterval(this.pingTimer),this.handshakeTimer=void 0,this.pingTimer=void 0;let t=this.socket;this.socket=void 0,t&&(t.removeAllListeners(),t.destroy()),!this.stopped&&(this.log(`Discord presence disconnected: ${e}`),this.scheduleReconnect())}scheduleReconnect(){if(this.stopped||this.reconnectTimer!==void 0)return;let e=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*2,Ge),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.connectToAny(0)},e),this.reconnectTimer.unref?.()}};function et(){try{return{cwd:process.cwd()}}catch{return{error:"the current directory no longer exists (it was deleted while the shell stayed in it). cd to a directory that exists, or pass one on the command line."}}}function tt(){process.stdout.on("error",c=>{throw c.code==="EPIPE"&&process.exit(0),c})}function st(){let c=N(_,".welcomed");if(!Xe(c)){try{ze(_,{recursive:!0}),Qe(c,v)}catch{return}console.error(`${d} ${v} installed. Docs: https://howtofix.id/code`),console.error("Continue the last session here with: howtocode -c")}}async function le(){K()||(console.error(`${d}: this build's CLI signing key (${J()}) does not match the key the panel verifies against, so sign-in will be refused.`),process.exitCode=1)}async function ot(){tt(),Y();let c=performance.now(),e=et();if("error"in e){console.error(`${d}: ${e.error}`),process.exitCode=1;return}let t=e.cwd,s=process.env.HXF_FAKE_NODE??process.versions.node,[i,o]=s.split(".").map(r=>Number.parseInt(r,10));if(!Number.isFinite(i)||i<22||i===22&&Number.isFinite(o)&&o<19){console.error(`${d}: Node ${s} is too old. Node 22.19 or newer is required (run "node --version" to check yours), because undici needs zstd, which Node added in 22.19. Upgrade Node and run this again.`),process.exitCode=1;let r=process.argv.slice(2);if(r.some(a=>a==="-h"||a==="--help")){console.log(R());return}if(r.some(a=>a==="-v"||a==="--version")){console.log(`${d} ${v}`);return}return}let h=process.argv.slice(2);if(h[0]==="doctor"||h[0]==="models"||h[0]==="sessions"){let r=h[0];try{let a=await import("./chunk-DWHGMY6G.js");r==="doctor"?process.exitCode=await a.runDoctor():r==="models"?process.exitCode=a.runModels():process.exitCode=a.runSessions(h.slice(1))}catch(a){F(d,r,a),process.exitCode=1}return}if(h.some(r=>r==="-v"||r==="--version")){await le(),console.log(`${d} ${v}`);return}let ue=h[0]==="acp"?["--acp",...h.slice(1)]:h,P;try{P=ne(ue)}catch(r){let a=r instanceof Error?r.message:String(r);console.error(`${d}: ${a}
|
|
97
|
+
${R()}`),process.exitCode=2;return}if(P.print&&!P.prompt){console.error(`${d}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:he,ensureGatewaySettings:me,repairModelFacts:fe,syncGatewayModelsOnStart:ge,checkAccount:we,fetchGatewayPrices:ye,readProviderKey:ve}=await import("./chunk-PQB6KMLL.js"),{tiersFrom:be,writeReachable:ke}=await import("./chunk-XBVWQC7P.js"),{readCliCredential:xe,renewCliCredentialIfNeeded:Se}=await import("./chunk-U5EB7YZU.js"),{AGENT_DIR:f,REACHABLE_CACHE_PATH:Te}=await import("./chunk-336TZTEK.js"),{readCachedPrices:_e,writeCachedPrices:Ee}=await import("./chunk-A3LZMZ3C.js"),j=he(f);j>0&&console.error(`${d}: repaired ${j} howtocode model(s) that the gateway would have rejected`);let C,D,I=new Map,$=_e(f);if($){C=$.prices;for(let[r,a]of $.groups)I.set(r,a)}try{let r=xe(f),a=r?(await Se(f,r)).credential.accessToken:ve(f,"howtocode");if(a){let[m,u]=await Promise.all([$?Promise.resolve(C??new Map):ye(a,{groups:I}),we(a)]);!$&&m.size>0&&(C=m,Ee(f,m,I)),u.ok&&(D=u.models)}}catch{}let L=be(I),A=await fe(f,{...C?{prices:C}:{},...L.size>0?{tiers:L}:{}});if(A.changed>0?console.error(`${d}: filled in the context window, reasoning flag and price for ${A.changed} model(s)`):A.message&&console.error(`${d}: model catalogue unavailable (${A.message}); context windows stay at their conservative defaults`),me(f)&&console.error(`${d}: set httpIdleTimeoutMs in settings.json so a stalled provider recovers instead of hanging`),D){ke(Te,D);try{let r=await ge(f,D,C);r.added>0&&console.error(`${d}: added ${r.added} model(s) this account can now reach`)}catch{}}let n=P;if(n.help){console.log(R());return}if(n.version){await le(),console.log(`${d} ${v}`);return}if(n.sandbox&&!process.env.HOWTOCODE_SANDBOXED){let{detectSandbox:r,enterSandbox:a,describeSandbox:m}=await import("./chunk-GQYIIDKK.js"),u=r();if(!u){console.error(`${d}: --sandbox needs a working bubblewrap (Linux) or sandbox-exec (macOS). Neither could be used here \u2014 on Linux this usually means unprivileged user namespaces are disabled.`),process.exitCode=1;return}console.error(m(u)),process.exitCode=a(u,{cwd:t,agentDir:_,argv:[process.execPath,...process.argv.slice(1)]});return}let{installProxy:Ce}=await import("./chunk-WKUJ7CFO.js");Ce(_);let{retireRobloxBridge:$e}=await import("./chunk-ULXYWUXZ.js");if($e(_),n.update||n.checkUpdate){let{PACKAGE_NAME:r,checkForUpdate:a,installUpdate:m,isInstalledCopy:u}=await import("./chunk-LYLJZVZ7.js"),w=await a(v);if(!w.latest){console.error(`${d}: ${w.message}`),process.exitCode=n.update?1:0;return}if(console.log(w.message),n.checkUpdate||!w.available)return;if(!u()){console.error(`${d}: this copy was not installed by npm, so npm cannot replace it. install it with: npm install -g ${r}`),process.exitCode=1;return}let S=await m({version:w.latest});console.log(S.message),S.ok||(process.exitCode=1);return}let U=process.argv.slice(2);if(U[0]==="preset"){let{runPresetCommand:r}=await import("./chunk-RJYOUCLJ.js");process.exitCode=r(U.slice(1));return}let{expandFileReferences:Pe}=await import("./chunk-TSEKPGK4.js"),{isApprovalMode:De,setApprovalMode:Ie,setDangerousBypass:Ae,isDangerousBypass:Oe}=await import("./chunk-4SK7TRJW.js"),{openSession:Re}=await import("./chunk-HMCCBHIZ.js");Ie(n.approval&&De(n.approval)?n.approval:"full-auto");let{readWorkbenchSettings:B}=await import("./chunk-UDX555SX.js");if((n.dangerouslySkipPermissions||B(f).skipPermissions)&&Ae(!0),Oe()&&console.error(`${d}: permission checks are OFF \u2014 critical commands (filesystem wipes, fork bombs, host shutdown) and the repeated-call guard are NOT enforced for this run. Turn it off with /settings, or by removing skipPermissions from settings.json.`),n.mode){let{serveProtocol:r}=await import("./chunk-5JRLPRW5.js");await r(n.mode,{cwd:t,model:n.model,thinking:n.thinking});return}let H=r=>Re({cwd:t,model:n.model,thinking:n.thinking,continueSession:r.continueSession??!1,noSession:r.noSession??!1,sessionPath:r.sessionPath,interactive:!n.print});if(n.resumeId&&!n.sessionPath){let r=N(_,"sessions"),a=[];try{for(let m of pe(r))for(let u of pe(N(r,m))){if(!u.endsWith(".jsonl")||!u.includes(n.resumeId))continue;let w=N(r,m,u);try{a.push({path:w,mtime:qe(w).mtimeMs})}catch{}}}catch{}if(a=a.sort((m,u)=>u.mtime-m.mtime),a.length===0){console.error(`${d}: no stored session matches '${n.resumeId}'. Run 'howtocode -c' to continue the latest one in this folder.`),process.exitCode=1;return}a.length>1&&console.error(`${d}: '${n.resumeId}' matches ${a.length} sessions; using the newest (${a[0].path}).`),n.sessionPath=a[0].path}let p=await H({continueSession:n.continueSession,sessionPath:n.sessionPath,noSession:n.noSession||n.print});if(n.print&&p.note&&console.error(p.note),n.maxBudgetUsd!==void 0&&!p.priced){console.error(`${d}: ${Z(p.modelLabel,f)}`),await p.dispose(),process.exitCode=2;return}if(n.print){let r=n.prompt.trimStart();if(r.startsWith("/")){let y=r.slice(1).split(/\s+/)[0]??"",{skillInvocation:O}=await import("./chunk-E2UZLMQH.js"),T=p.session.resourceLoader.getSkills().skills.map(g=>g.name);if(!(O(r,T)!==void 0)){let{slashCommands:g}=await import("./chunk-MP3T3UKV.js");if(g(p.session).some(l=>l.name===y)){console.error(`${d}: /${y} runs in the TUI only \u2014 --print sends prompts straight to the model. Run \`howtocode\` without --print for interactive commands.`),await p.dispose(),process.exitCode=2;return}}}let a=n.outputFormat==="stream-json",m=n.outputFormat==="json",u=a||m;if(a){let y={type:"system",subtype:"init",cwd:t,session_id:p.session.sessionId,model:p.modelLabel,output_format:n.outputFormat,max_budget_usd:n.maxBudgetUsd??null,dangerously_skip_permissions:n.dangerouslySkipPermissions,cli_version:v};process.stdout.write(`${JSON.stringify(y)}
|
|
98
|
+
`)}let w,S,Le=()=>{if(n.maxBudgetUsd===void 0||S!==void 0)return;let y=p.session.getSessionStats().cost;y>n.maxBudgetUsd&&(S={spent:y},p.session.abort())};try{let y,O=z();if(w=p.session.subscribe(l=>{if(a){let k=O.line(l);k!==void 0&&process.stdout.write(k)}if(l.type==="turn_end"&&l.message?.role==="assistant"){let k=l.message;k.stopReason==="error"||k.stopReason==="aborted"||k.errorMessage?y={stopReason:k.stopReason??"error",errorMessage:k.errorMessage}:y=void 0}Le()}),await p.session.prompt(Pe(n.prompt,t)),a){let l=O.finish();l!==void 0&&process.stdout.write(l)}let T=X(p.session.getLastAssistantText()??"");if(S){if(console.error(`${d}: ${Q(S.spent,n.maxBudgetUsd)}`),u){let l=p.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:"error_max_budget_usd",is_error:!0,result:T,session_id:p.session.sessionId,duration_ms:Math.round(performance.now()-c),num_turns:l.assistantMessages,total_cost_usd:l.cost,usage:{input_tokens:l.tokens.input,output_tokens:l.tokens.output,cache_read_input_tokens:l.tokens.cacheRead,cache_creation_input_tokens:l.tokens.cacheWrite}})}
|
|
99
|
+
`)}process.exitCode=1;return}let b=p.session.state.messages.at(-1),g=y??(b?.role==="assistant"&&(b.stopReason==="error"||b.stopReason==="aborted"||b.errorMessage)?{stopReason:b.stopReason??"error",errorMessage:b.errorMessage}:void 0);if(u){let l=p.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:g?g.stopReason==="aborted"?"error_aborted":"error_during_execution":"success",is_error:g!==void 0,result:T,session_id:p.session.sessionId,duration_ms:Math.round(performance.now()-c),num_turns:l.assistantMessages,total_cost_usd:l.cost,usage:{input_tokens:l.tokens.input,output_tokens:l.tokens.output,cache_read_input_tokens:l.tokens.cacheRead,cache_creation_input_tokens:l.tokens.cacheWrite},stop_reason:g?.stopReason??(b?.role==="assistant"?b.stopReason:void 0)})}
|
|
100
|
+
`)}else process.stdout.write(T.endsWith(`
|
|
101
|
+
`)?T:`${T}
|
|
102
|
+
`);if(g&&(process.exitCode=1,g.errorMessage)){console.error(`${d}: ${g.errorMessage}`);let l=q(g.errorMessage);l!==void 0&&console.error(`${d}: ${l}`)}}finally{w?.(),await p.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${d}: interactive mode needs a terminal. use --print for pipes.`),await p.dispose(),process.exitCode=2;return}st();let{runWorkbench:Me}=await import("./chunk-MP3T3UKV.js"),{autoUpdateEnabled:Ne,isInstalledCopy:Fe}=await import("./chunk-LYLJZVZ7.js"),je=Fe()&&Ne(`${f}/settings.json`),W=process.env.HOWTOCODE_DISCORD_DISABLE==="1"?"":process.env.HOWTOCODE_DISCORD_CLIENT_ID?.trim()||B(f).discordClientId||de,G=W?new M({clientId:W,activity:{details:"HowToCode",state:`${p.modelLabel} \u2022 ${Ze(t)}`.slice(0,128),timestamps:{start:Date.now()},...process.env.HOWTOCODE_DISCORD_LARGE_IMAGE?{assets:{large_image:process.env.HOWTOCODE_DISCORD_LARGE_IMAGE,large_text:"HowToCode"}}:{}}}):void 0;G?.start();try{await Me({cwd:t,modelLabel:p.modelLabel,session:p.session,dispose:()=>p.dispose(),setCompressToolOutput:p.setCompressToolOutput,initialPrompt:n.prompt||void 0,note:p.note,approval:n.approval,maxBudgetUsd:n.maxBudgetUsd,update:je?{current:v,install:!0}:void 0,reopen:H})}finally{G?.stop()}}re(d);ot().catch(c=>{F(d,void 0,c),process.exitCode=1});
|
package/package.json
CHANGED
package/dist/chunk-27TRKD65.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as u}from"./chunk-UTYFLLSM.js";import{existsSync as l,mkdirSync as f,readFileSync as c}from"node:fs";import{dirname as p,join as m}from"node:path";var a={skipPermissions:!1,autoUpdate:!0,rightClickPaste:"auto",welcomeSeen:!1,compressToolOutput:!1};function g(t){return m(t,"settings.json")}function k(t){try{let e=JSON.parse(c(g(t),"utf8")),n=r=>{let i=e[r];return typeof i=="boolean"?i:a[r]},o=e.rightClickPaste;return{skipPermissions:n("skipPermissions"),autoUpdate:n("autoUpdate"),rightClickPaste:o==="on"||o==="off"||o==="auto"?o:a.rightClickPaste,welcomeSeen:n("welcomeSeen"),compressToolOutput:n("compressToolOutput"),...typeof e.agents=="number"&&Number.isInteger(e.agents)&&e.agents>0?{agents:e.agents}:{}}}catch{return{...a}}}function h(t,e,n){return s(t,e,n)}function w(t){return s(t,"welcomeSeen",!0)}function P(t,e){return s(t,"rightClickPaste",e==="auto"?void 0:e)}function y(t){return t==="on"?!0:t==="off"?!1:process.platform!=="win32"}function x(t,e){let n=typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0;return s(t,"agents",n)}function C(t,e,n){let o=n.trim();return s(t,e,o===""?void 0:o)}function s(t,e,n){let o=g(t),r={};try{let i=JSON.parse(c(o,"utf8"));i&&typeof i=="object"&&!Array.isArray(i)&&(r=i)}catch{if(l(o))return!1}n===void 0?delete r[e]:r[e]=n;try{f(p(o),{recursive:!0}),u(o,`${JSON.stringify(r,null,2)}
|
|
2
|
-
`)}catch{return!1}return!0}export{a,k as b,h as c,w as d,P as e,y as f,x as g,C as h};
|