howtocode 0.7.66 → 0.7.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-JREL7M6J.js → chunk-2GVIOMRN.js} +1 -1
- package/dist/{chunk-CCISJKGS.js → chunk-3H2ECHBB.js} +1 -1
- package/dist/chunk-465RG5I6.js +10 -0
- package/dist/{chunk-DG7OCYNY.js → chunk-4KNWFMK6.js} +1 -1
- package/dist/{chunk-BAB55K5H.js → chunk-6PZTZT6T.js} +1 -1
- package/dist/{chunk-VGY6AHOB.js → chunk-AVNJV7SN.js} +1 -1
- package/dist/{chunk-XB6IDZUM.js → chunk-EPNFKO5O.js} +1 -1
- package/dist/{chunk-JY72ELJM.js → chunk-HDH5ER4H.js} +68 -67
- package/dist/{chunk-TN22ZVV4.js → chunk-HKABQFBG.js} +1 -1
- package/dist/{chunk-BZ6PO2P5.js → chunk-KS6FRAVP.js} +1 -1
- package/dist/{chunk-BZJSYOTO.js → chunk-L4XKIPIG.js} +1 -1
- package/dist/{chunk-4EQD3OPC.js → chunk-LUBZSBUH.js} +1 -1
- package/dist/{chunk-YVRSL6ZX.js → chunk-NIDL55H4.js} +1 -1
- package/dist/{chunk-ELM3OMOE.js → chunk-NPD6557W.js} +1 -1
- package/dist/{chunk-OHCWPWJW.js → chunk-O3XEEDMR.js} +1 -1
- package/dist/{chunk-RU6VPYMJ.js → chunk-VDUY46W2.js} +1 -1
- package/dist/{chunk-AS4FUFAN.js → chunk-W2U7D5UF.js} +1 -1
- package/dist/{chunk-IYR7VCH4.js → chunk-XVHYS2UZ.js} +1 -1
- package/dist/{chunk-3YSNDQVR.js → chunk-YFJKKWIX.js} +1 -1
- package/dist/main-app.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-ABDZXFNM.js +0 -10
|
@@ -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-NIDL55H4.js";import"./chunk-O3XEEDMR.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-465RG5I6.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{e as RETIRED_ROBLOX_BRIDGE,c as addMcpServers,g as describeMcpServer,a as mcpConfigPath,j as mcpHubCategories,l as mcpHubFind,k as mcpHubIn,h as mcpHubPath,n as missingEnvFor,i as readMcpHub,d as removeMcpServers,f as retireRobloxBridge,m as serverSpecFromEntry,b as validateMcpBlock};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as A}from"./chunk-UTYFLLSM.js";import{existsSync as E,readFileSync as D}from"node:fs";import{dirname as Le,join as de}from"node:path";import{fileURLToPath as Fe}from"node:url";import{cpSync as J,existsSync as T,readdirSync as je,readFileSync as ce,renameSync as He,statSync as N,writeFileSync as Ne}from"node:fs";import{homedir as ue}from"node:os";import{dirname as Te,join as p,resolve as De}from"node:path";import{cpSync as he,existsSync as S,mkdirSync as P,mkdtempSync as L,readdirSync as R,readFileSync as j,renameSync as be,rmSync as b,statSync as x,writeFileSync as M}from"node:fs";import{tmpdir as V}from"node:os";import{dirname as Q,isAbsolute as Se,join as u,relative as ke,resolve as C}from"node:path";import{fileURLToPath as ve}from"node:url";import{execFileSync as xe}from"node:child_process";import{createHash as Z}from"node:crypto";import{gunzipSync as me}from"node:zlib";var k=512;function O(e,t,r){let n=e.subarray(t,t+r),s=n.indexOf(0);return n.subarray(0,s===-1?n.length:s).toString("utf8").trim()}function W(e,t,r){let n=O(e,t,r);if(!n)return 0;let s=Number.parseInt(n,8);return Number.isFinite(s)?s:0}function ye(e){let t={},r=0;for(;r<e.length;){let n=e.indexOf(32,r);if(n===-1)break;let s=Number.parseInt(e.toString("utf8",r,n),10);if(!Number.isFinite(s)||s<=0)break;let i=e.toString("utf8",n+1,r+s-1),o=i.indexOf("=");o>0&&(t[i.slice(0,o)]=i.slice(o+1)),r+=s}return t}function K(e){let t=me(e),r=[],n=0,s,i={};for(;n+k<=t.length;){let o=t.subarray(n,n+k);if(o.every(ge=>ge===0))break;let a=O(o,0,100),c=O(o,345,155),l=W(o,124,12),f=W(o,100,8),m=String.fromCharCode(o[156]??48),w=O(o,157,100),v=l>0?t.subarray(n+k,n+k+l):Buffer.alloc(0);if(n+=k+Math.ceil(l/k)*k,m==="x"||m==="g"){i=ye(v);continue}if(m==="L"){s=v.toString("utf8").replace(/\0.*$/s,"").trim();continue}let y=i.path??s??(c?`${c}/${a}`:a);s=void 0,i={};let d=y.indexOf("/");if(d===-1||(y=y.slice(d+1),y=y.replace(/\/+$/,""),!y))continue;let h=m==="5"?"directory":m==="2"?"symlink":m==="0"||m==="\0"||m===""?"file":"other";r.push({path:y,kind:h,size:l,mode:f&511,...h==="file"?{data:Buffer.from(v)}:{},...h==="symlink"?{link:w}:{}})}return r}function U(e){if(!e||e.startsWith("/")||e.startsWith("\\")||/^[a-zA-Z]:/.test(e))return!1;let t=e.replace(/\/+$/,"");return t?t.split("/").every(n=>n!==""&&n!=="."&&n!==".."):!1}function X(e,t){let r=`${t.replace(/\/+$/,"")}/`,n=[];for(let s of e){if(!s.path.startsWith(r))continue;let i=s.path.slice(r.length);i&&n.push({...s,path:i})}return n}function we(){return u(g,"presets")}function Y(e){return u(e,".howtocode","presets")}function ee(e){return S(u(e,".disabled"))}function te(){return u(Q(ve(import.meta.url)),"presets")}function H(e){return[Y(e),we()]}var re=/^[a-z0-9][a-z0-9-]*$/,$e=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e,t){let r=ke(C(e),C(t));return r!==""&&!r.startsWith("..")&&!Se(r)}function ne(e,t){let r=[];if(!_(t))return["preset.json must be a JSON object"];let n=l=>{let f=t[l];return typeof f!="string"||f.trim()===""?(r.push(`${l} must be a non-empty string`),""):f.trim()},s=n("name");n("title"),n("description"),n("category");let i=n("version");s&&!re.test(s)&&r.push(`name "${s}" must be lowercase letters, digits and dashes`),i&&!$e.test(i)&&r.push(`version "${i}" is not a version like 1.0.0`);let o=t.skills;if(!Array.isArray(o)||o.length===0)r.push("skills must be a non-empty array of directory names");else for(let l of o){if(typeof l!="string"||l.trim()===""){r.push("every skills entry must be a non-empty string");continue}let f=u(e,"skills",l.trim());if(!$(u(e,"skills"),f)){r.push(`skill "${l}" escapes the preset directory`);continue}S(u(f,"SKILL.md"))||r.push(`skill "${l}" has no SKILL.md at ${u("skills",l)}`)}let a=t.prompt;if(a!==void 0)if(typeof a!="string"||a.trim()==="")r.push("prompt must be a non-empty string when present");else{let l=u(e,a.trim());$(e,l)?S(l)||r.push(`prompt file "${a}" does not exist`):r.push(`prompt "${a}" escapes the preset directory`)}let c=t.tags;return c!==void 0&&!Array.isArray(c)&&r.push("tags must be an array when present"),r.push(...q(t.mcp)),r}function se(e){let t=u(e,"preset.json");if(!S(t))return{problems:[`no preset.json in ${e}`]};let r;try{r=JSON.parse(j(t,"utf8"))}catch(o){return{problems:[`preset.json is not valid JSON: ${o instanceof Error?o.message:String(o)}`]}}let n=ne(e,r);if(n.length>0)return{problems:n};let s=r,i=Array.isArray(s.tags)?s.tags.filter(o=>typeof o=="string"):[];return{problems:[],manifest:{name:String(s.name),title:String(s.title),description:String(s.description),category:String(s.category),tags:i,version:String(s.version),skills:s.skills.map(o=>String(o)),prompt:typeof s.prompt=="string"?s.prompt:void 0,mcp:s.mcp&&typeof s.mcp=="object"&&!Array.isArray(s.mcp)?s.mcp:void 0,integrates:typeof s.integrates=="string"&&s.integrates.trim()!==""?s.integrates.trim():void 0}}}function F(e){return e.filter(t=>{try{return x(t).isDirectory()}catch{return!1}})}function I(e,t){let r=[],n=[],s=(o,a)=>{if(!S(u(o,"preset.json")))return;let{manifest:c,problems:l}=se(o);c?r.push({manifest:c,dir:o,source:t}):n.push(`${a}: ${l.join("; ")}`)},i;try{i=R(e).sort()}catch{return{entries:r,problems:n}}for(let o of i){if(o.startsWith("."))continue;let a=u(e,o);try{if(!x(a).isDirectory())continue}catch{continue}if(S(u(a,"preset.json"))){s(a,o);continue}let c;try{c=R(a).sort()}catch{continue}for(let l of c){if(l.startsWith("."))continue;let f=u(a,l);try{if(!x(f).isDirectory())continue}catch{continue}s(f,u(o,l))}}return{entries:r,problems:n}}function Ye(e){let t=I(te(),"bundled"),r=[...t.entries],n=[...t.problems],s=new Map(r.map(i=>[i.manifest.name,i]));for(let i of F(H(e))){let o=I(i,"installed");n.push(...o.problems);for(let a of o.entries){let c=s.get(a.manifest.name);if(c){let l=r.indexOf(c);l>=0&&(r[l]=a),s.set(a.manifest.name,a)}else r.push(a),s.set(a.manifest.name,a)}}return{entries:r,problems:n}}function et(e){return[...new Set(e.map(t=>t.manifest.category))].sort()}function tt(e,t){return e.filter(r=>r.manifest.category===t).sort((r,n)=>r.manifest.title.localeCompare(n.manifest.title))}function ie(e){let t=[];for(let r of F(H(e))){let{entries:n}=I(r,"installed");for(let s of n)ee(s.dir)||t.push(u(s.dir,"skills"))}return t}function rt(e){let t=[];for(let r of F(H(e))){let{entries:n}=I(r,"installed");for(let s of n){if(ee(s.dir))continue;let i=s.manifest.prompt;if(!i)continue;let o=u(s.dir,i);if($(s.dir,o))try{let a=j(o,"utf8").trim();a&&t.push({name:s.manifest.name,title:s.manifest.title,text:a})}catch{}}}return t}function nt(e,t){let r=0;for(let n of t.skills)try{r+=x(u(e,"skills",n,"SKILL.md")).size}catch{}return r}function Ee(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}var Ae=".install.lock";function Oe(e,t){P(e,{recursive:!0});let r=u(e,Ae),n=Date.now()+6e4;for(;;)try{M(r,`${process.pid}
|
|
2
|
+
`,{flag:"wx"});break}catch(s){if(s.code!=="EEXIST")throw s;let i=!1;try{i=Date.now()-x(r).mtimeMs>12e4}catch{continue}if(i){b(r,{force:!0});continue}if(Date.now()>n)throw new Error(`another install is holding ${r}; remove it if no install is running`);Ee(100)}try{for(let s of R(e))s.startsWith(".staging-")&&b(u(e,s),{recursive:!0,force:!0});return t()}finally{b(r,{force:!0})}}function oe(e,t,r){let n=u(t,r.name);return Oe(t,()=>{P(t,{recursive:!0});let s=L(u(t,".staging-"));try{he(e,s,{recursive:!0}),b(n,{recursive:!0,force:!0}),be(s,n)}catch(i){throw b(s,{recursive:!0,force:!0}),i}return n})}function ae(e,t){if(!S(e))return{ok:!1,problems:[`no such directory: ${e}`]};let{manifest:r,problems:n}=se(e);if(!r)return{ok:!1,problems:n};let s=oe(e,t,r);return{ok:!0,name:r.name,target:s,problems:[]}}function Pe(e,t){let r=L(u(V(),"howtocode-preset-"));try{return xe("git",["clone","--depth","1","--quiet",e,r],{stdio:"pipe"}),ae(r,t)}catch(n){return{ok:!1,problems:[`git clone failed: ${(n instanceof Error?n.message:String(n)).split(`
|
|
3
|
+
`)[0]}`]}}finally{b(r,{recursive:!0,force:!0})}}function st(e,t){return/^(https?:\/\/|git@|git:\/\/)/.test(e)?Pe(e,t):ae(C(e),t)}function it(e,t){let r=[],n=[];if(!re.test(e))return{removed:r,problems:[`"${e}" is not a preset name`]};for(let s of H(t)){let i=u(s,e);if(S(i)){if(!$(s,i)){n.push(`refusing to remove ${i}: outside ${s}`);continue}b(i,{recursive:!0,force:!0}),r.push(i)}}return r.length===0&&n.push(`"${e}" is not installed`),{removed:r,problems:n}}function ot(e){return Y(e)}function Re(e){let t=[],r=(i,o)=>{for(let a of R(i,{withFileTypes:!0}).sort((c,l)=>c.name.localeCompare(l.name))){let c=u(i,a.name),l=o?`${o}/${a.name}`:a.name;a.isSymbolicLink()||(a.isDirectory()?r(c,l):a.isFile()&&t.push([l,Z("sha256").update(j(c)).digest("hex")]))}};r(e,"");let n=0;for(let[i]of t)n+=x(u(e,i)).size;let s=t.map(([i,o])=>`${o} ${i}`).join(`
|
|
4
|
+
`);return{digest:Z("sha256").update(s).digest("hex").slice(0,16),fileCount:t.length,bytes:n}}function at(){let e=u(te(),"hub.json");try{let t=j(e,"utf8"),r=JSON.parse(t),n=_(r)&&Array.isArray(r.entries)?r.entries:[],s=[];for(let i of n)_(i)&&(typeof i.name!="string"||typeof i.repo!="string"||typeof i.sha!="string"||typeof i.path!="string"||typeof i.category!="string"||s.push({name:i.name,title:typeof i.title=="string"?i.title:i.name,description:typeof i.description=="string"?i.description:"",category:i.category,skill:typeof i.skill=="string"?i.skill:i.name,path:i.path,repo:i.repo,sha:i.sha,license:typeof i.license=="string"?i.license:"unknown",stars:typeof i.stars=="number"?i.stars:0,sizeKb:typeof i.sizeKb=="number"?i.sizeKb:0,...typeof i.digest=="string"?{digest:i.digest}:{},...typeof i.fileCount=="number"?{fileCount:i.fileCount}:{},...typeof i.modelInvocable=="boolean"?{modelInvocable:i.modelInvocable}:{}}));return{entries:s,problems:[]}}catch(t){return t?.code==="ENOENT"?{entries:[],problems:[]}:{entries:[],problems:[`registry unreadable: ${t instanceof Error?t.message:String(t)}`]}}}function ct(e){return[...new Set(e.map(t=>t.category))].sort()}function lt(e,t){return e.filter(r=>r.category===t).sort((r,n)=>n.stars-r.stars||r.name.localeCompare(n.name))}function ut(e,t){return e.find(r=>r.name===t)}function Ie(e){return`https://codeload.github.com/${e.repo}/tar.gz/${e.sha}`}async function ft(e,t,r=12e4){let n=L(u(V(),"howtocode-hub-"));try{let s=await fetch(Ie(e),{signal:AbortSignal.timeout(r),redirect:"follow"});if(!s.ok)return{ok:!1,problems:[`${e.repo}: HTTP ${s.status} from codeload`]};let i=Buffer.from(await s.arrayBuffer()),o=K(i),a=X(o,e.path).filter(d=>d.kind==="file"||d.kind==="directory");if(!a.some(d=>d.path==="SKILL.md"))return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)} has no ${e.path}/SKILL.md`]};let c=u(n,"preset",e.name),l=u(c,"skills",e.skill),f=0;for(let d of a){if(!U(d.path))return{ok:!1,problems:[`refusing unsafe path in archive: ${d.path}`]};let h=u(l,d.path);if(!$(l,h))return{ok:!1,problems:[`refusing path outside the skill: ${d.path}`]};if(d.kind==="directory"){P(h,{recursive:!0});continue}P(Q(h),{recursive:!0}),M(h,d.data??Buffer.alloc(0)),f+=1}let m={name:e.name,title:e.title,description:e.description,category:e.category,version:"1.0.0",skills:[e.skill],source:`${e.repo}@${e.sha}`,license:e.license};if(M(u(c,"preset.json"),`${JSON.stringify(m,null,2)}
|
|
5
|
+
`),!e.digest)return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)}: registry entry has no digest`,"refusing to install; content cannot be verified against what was reviewed"]};let w=Re(l);if(w.digest!==e.digest)return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)}: content changed under a pinned commit`,`expected ${e.digest} (${e.fileCount??"?"} files), got ${w.digest} (${w.fileCount} files)`,"refusing to install; the registry needs regenerating"]};let v=ne(c,m);if(v.length>0)return{ok:!1,problems:v};let y=oe(c,t,m);return{ok:!0,name:e.name,target:y,problems:[],skill:e.skill,modelInvocable:e.modelInvocable}}catch(s){return{ok:!1,problems:[`download failed: ${(s instanceof Error?s.message:String(s)).split(`
|
|
6
|
+
`)[0]}`]}}finally{b(n,{recursive:!0,force:!0})}}function Me(){let e=(process.env.HOWTOCODE_HOME??process.env.HOWTOFIX_HOME??process.env.HOME??"").trim();return De(e||ue())}function fe(e,t){for(let r of je(e)){let n=p(e,r),s=p(t,r);if(!T(s)){try{J(n,s,{recursive:!0,force:!1})}catch{}continue}let i=!1;try{i=N(n).isDirectory()}catch{continue}if(i&&N(s).isDirectory()){fe(n,s);continue}try{let o=N(s).size,a=N(n).size;!i&&o<=2&&a>o&&J(n,s,{force:!0})}catch{}}}function Ce(e){let t=p(ue(),".howtofix");if(T(t)){if(!T(e))try{He(t,e),z(e);return}catch{try{J(t,e,{recursive:!0}),z(e);return}catch{return}}fe(t,e),z(e)}}function z(e){le(p(e,"agent","models.json"),"providers"),le(p(e,"agent","auth.json"),void 0)}function le(e,t){if(!T(e))return;let r;try{r=JSON.parse(ce(e,"utf8"))}catch{return}let n=t?r[t]:r;if(!n||typeof n!="object")return;let s=!1;for(let[i,o]of Object.entries(n)){let a=o,c=typeof a?.baseUrl=="string"?a.baseUrl:"";c&&!/^https?:\/\/(api\.)?howtofix\.id(?:\/|$)/i.test(c)&&(delete n[i],s=!0)}if(t===void 0){let i=new Set(Object.keys(JSON.parse(ce(p(Te(e),"models.json"),"utf8")).providers??{}));for(let o of Object.keys(n))i.has(o)||i.has(o.replace(/^howtofix/,"howtocode"))||(delete n[o],s=!0)}for(let[i,o]of Object.entries(n)){let a=i==="howtofix"?"howtocode":i==="howtofix-free"?"howtocode-free":i;a===i||n[a]!==void 0||(n[a]=o,delete n[i],s=!0)}if(s)try{Ne(e,`${JSON.stringify(r,null,2)}
|
|
7
|
+
`)}catch{}}var g=process.env.HOWTOCODE_CODING_AGENT_DIR?.trim()||process.env.HOWTOFIX_CODING_AGENT_DIR?.trim()||(()=>{let e=p(Me(),".howtocode");return Ce(e),p(e,"agent")})(),ht=p(g,"skills");function _e(e){return p(e,".howtocode","skills")}function bt(e){let t=[_e(e)];return t.push(...ie(e)),t}var St=p(g,"agents"),kt=p(g,"usage-cache.json"),vt=p(g,"reachable-models.json"),xt=p(g,"workflows");function wt(){process.env.HXF_CODING_AGENT_DIR=g}var $t=p(g,"images");function B(e=g){return de(e,"mcp.json")}function q(e){let t=[];if(e===void 0)return t;if(typeof e!="object"||e===null||Array.isArray(e))return["mcp must be an object of server names"];for(let[r,n]of Object.entries(e)){if(!/^[A-Za-z0-9_-]+$/.test(r)){t.push(`mcp server "${r}" must use only letters, digits, _ and -`);continue}if(typeof n!="object"||n===null||Array.isArray(n)){t.push(`mcp server "${r}" must be an object`);continue}let s=n,i=typeof s.command=="string"&&s.command.trim()!=="",o=typeof s.url=="string"&&s.url.trim()!=="";!i&&!o&&t.push(`mcp server "${r}" needs either a command or a url`),s.args!==void 0&&!Array.isArray(s.args)&&t.push(`mcp server "${r}": args must be an array`);for(let a of["env","headers"]){let c=s[a];if(c!==void 0){if(typeof c!="object"||c===null||Array.isArray(c)){t.push(`mcp server "${r}": ${a} must be an object of strings`);continue}for(let[l,f]of Object.entries(c))typeof f!="string"&&t.push(`mcp server "${r}": ${a}.${l} must be a string`)}}}return t}function G(e){if(!E(e))return{mcpServers:{}};try{let t=JSON.parse(D(e,"utf8"));if(!t||typeof t!="object"||Array.isArray(t))return{mcpServers:{}};let r=t.mcpServers;return!r||typeof r!="object"||Array.isArray(r)?{mcpServers:{}}:{mcpServers:r}}catch{return{mcpServers:{}}}}function jt(e,t=g){let r=Object.keys(e);if(r.length===0)return{added:[],skipped:[],problems:[]};let n=B(t),s=[];if(E(n))try{JSON.parse(D(n,"utf8"))}catch{return{added:[],skipped:[],problems:[`${n} is not valid JSON; leaving it alone`]}}let i=G(n),o=[],a=[];for(let c of r){if(i.mcpServers[c]!==void 0){a.push(c);continue}i.mcpServers[c]=e[c],o.push(c)}if(o.length>0)try{A(n,`${JSON.stringify(i,null,2)}
|
|
8
|
+
`)}catch(c){return{added:[],skipped:a,problems:[`could not write ${n}: ${c instanceof Error?c.message:String(c)}`]}}return{added:o,skipped:a,problems:s}}function Ht(e,t=new Set,r=g){let n=B(r),s=[];if(e.length===0||!E(n))return{removed:[],kept:[],problems:s};let i=G(n),o=[],a=[];for(let c of e)if(i.mcpServers[c]!==void 0){if(t.has(c)){a.push(c);continue}delete i.mcpServers[c],o.push(c)}if(o.length>0)try{A(n,`${JSON.stringify(i,null,2)}
|
|
9
|
+
`)}catch(c){return{removed:[],kept:a,problems:[`could not write ${n}: ${c instanceof Error?c.message:String(c)}`]}}return{removed:o,kept:a,problems:s}}var pe="@netrodev/howtocode-roblox-bridge";function Nt(e=g){let t=B(e);if(!E(t))return[];try{JSON.parse(D(t,"utf8"))}catch{return[]}let r=G(t),n=Object.keys(r.mcpServers).filter(s=>{let i=r.mcpServers[s];return[i.command,...Array.isArray(i.args)?i.args:[]].map(a=>String(a??"")).some(a=>a===pe||a.startsWith(`${pe}@`))});if(n.length===0)return[];for(let s of n)delete r.mcpServers[s];try{A(t,`${JSON.stringify(r,null,2)}
|
|
10
|
+
`)}catch{return[]}return n}function Tt(e){if(typeof e.url=="string"&&e.url)return`http: ${e.url}`;let t=typeof e.command=="string"?e.command:"",r=Array.isArray(e.args)?e.args.filter(n=>typeof n=="string"):[];return`stdio: ${[t,...r].join(" ")}`.trim()}function ze(){return de(Le(Fe(import.meta.url)),"presets","mcp-hub.json")}function Dt(e=ze()){let t=[];if(!E(e))return{entries:[],problems:[`no MCP catalogue at ${e}`]};let r;try{r=JSON.parse(D(e,"utf8"))}catch(i){return{entries:[],problems:[`${e} is not valid JSON: ${i instanceof Error?i.message:String(i)}`]}}let n=r?.entries;if(!Array.isArray(n))return{entries:[],problems:[`${e} has no entries array`]};let s=[];for(let i of n){if(typeof i!="object"||i===null||Array.isArray(i))continue;let o=i,a=typeof o.name=="string"?o.name.trim():"";if(!a){t.push("an entry has no name");continue}if(!/^[A-Za-z0-9_-]+$/.test(a)){t.push(`"${a}" is not a usable server name`);continue}let c=typeof o.command=="string"&&o.command.trim()!=="",l=typeof o.url=="string"&&o.url.trim()!=="";if(!c&&!l){t.push(`"${a}" has neither a command nor a url`);continue}s.push({name:a,title:typeof o.title=="string"?o.title:a,description:typeof o.description=="string"?o.description:"",category:typeof o.category=="string"?o.category:"other",preset:typeof o.preset=="string"?o.preset:void 0,command:typeof o.command=="string"?o.command:void 0,url:typeof o.url=="string"?o.url:void 0,args:Array.isArray(o.args)?o.args.filter(f=>typeof f=="string"):void 0,env:o.env&&typeof o.env=="object"&&!Array.isArray(o.env)?o.env:void 0,needs:Array.isArray(o.needs)?o.needs.filter(f=>typeof f=="string"):void 0,docs:typeof o.docs=="string"?o.docs:void 0})}return{entries:s,problems:t}}function Mt(e){return[...new Set(e.map(t=>t.category))].sort()}function Ct(e,t){return e.filter(r=>r.category===t).sort((r,n)=>r.title.localeCompare(n.title))}function _t(e,t){return e.find(r=>r.name===t)}function Lt(e){let t={};return e.command&&(t.command=e.command),e.url&&(t.url=e.url),e.args&&e.args.length>0&&(t.args=[...e.args]),e.env&&Object.keys(e.env).length>0&&(t.env={...e.env}),e.description&&(t.description=e.description),t}function Ft(e,t=process.env){return(e.needs??[]).filter(r=>!t[r])}export{B as a,q as b,jt as c,Ht as d,pe as e,Nt as f,Tt as g,ze as h,Dt as i,Mt as j,Ct as k,_t as l,Lt as m,Ft as n,ee as o,te as p,ne as q,se as r,Ye as s,et as t,tt as u,ie as v,rt as w,nt as x,ae as y,st as z,it as A,ot as B,at as C,ct as D,lt as E,ut as F,ft as G,g as H,ht as I,_e as J,bt as K,St as L,kt as M,vt as N,xt as O,wt as P,$t as Q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./chunk-MVVEYKN6.js";import{b as r}from"./chunk-
|
|
1
|
+
import{j as a}from"./chunk-MVVEYKN6.js";import{b as r}from"./chunk-O3XEEDMR.js";import"./chunk-WOT6VMZA.js";function c(e){return{prompt:s=>e.session.prompt(s),abort:()=>e.session.abort(),subscribe:s=>e.session.subscribe(n=>s(n)),getLastAssistantText:()=>a(e.session.getLastAssistantText()??""),lastStopReason:()=>{let s=e.session.state.messages.at(-1);return s?.role==="assistant"?s.stopReason:void 0},dispose:()=>e.dispose()}}async function g(e,s){let{openSession:n}=await import("./chunk-KS6FRAVP.js"),i=t=>n({cwd:t,model:s.model,thinking:s.thinking,continueSession:!1,noSession:!1,sessionPath:void 0,interactive:!1});if(e==="acp"){let{runAcp:t}=await import("./chunk-TOV557ET.js");await t({input:process.stdin,output:process.stdout,version:r,createAgent:async u=>c(await i(u))});return}let{runRpc:p}=await import("./chunk-QOYTPACU.js"),{createJsonEventEncoder:d}=await import("./chunk-MCDEIIEN.js"),o=await i(s.cwd),m=d();await p({input:process.stdin,output:process.stdout,agent:c(o),encodeEvent:t=>m.line(t),state:()=>({sessionId:o.session.sessionId,model:o.modelLabel,cwd:s.cwd})})}export{c as agentFromSession,g as serveProtocol};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as j}from"./chunk-MCAAX33K.js";import{H as m,N as A}from"./chunk-
|
|
1
|
+
import{b as j}from"./chunk-MCAAX33K.js";import{H as m,N as A}from"./chunk-465RG5I6.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-U3GZBLTM.js";import{a as b}from"./chunk-O3XEEDMR.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 +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-LUBZSBUH.js";import"./chunk-UTYFLLSM.js";import"./chunk-NIDL55H4.js";import"./chunk-O3XEEDMR.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,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-HKABQFBG.js";import"./chunk-7LA2AMZB.js";import"./chunk-UTYFLLSM.js";import"./chunk-NIDL55H4.js";import"./chunk-O3XEEDMR.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};
|