noskills 4.5.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +497 -18
- package/noskills.js +145 -1
- package/package.json +14 -1
- package/{chunks/ajan-bridge-BNPC757J.js → ts/chunks/ajan-bridge-6UUIUFAV.js} +1 -1
- package/ts/chunks/anthropic-ICVQ5GK6.js +1 -0
- package/ts/chunks/approve-R7MCYHCS.js +1 -0
- package/ts/chunks/ask-GBLFPNFX.js +2 -0
- package/ts/chunks/block-YEKLMXHR.js +1 -0
- package/ts/chunks/cancel-7NS4WM2N.js +1 -0
- package/ts/chunks/chunk-2CLD527I.js +1 -0
- package/ts/chunks/chunk-34AWV7DB.js +1 -0
- package/ts/chunks/chunk-3M26Y3NG.js +27 -0
- package/{chunks/chunk-J25XTDQQ.js → ts/chunks/chunk-3QVRJO3V.js} +1 -1
- package/ts/chunks/chunk-5ALJRBMW.js +22 -0
- package/ts/chunks/chunk-5NMDE2VZ.js +4 -0
- package/ts/chunks/chunk-6BKTY7SA.js +4 -0
- package/ts/chunks/chunk-6M7PCVUR.js +1 -0
- package/ts/chunks/chunk-6O2RXYTM.js +3 -0
- package/ts/chunks/chunk-7DIQYKPL.js +3 -0
- package/ts/chunks/chunk-7J6R2D2K.js +2 -0
- package/ts/chunks/chunk-AW3XJGEP.js +1 -0
- package/ts/chunks/chunk-BRC46A3N.js +39 -0
- package/ts/chunks/chunk-C5LYQDQH.js +368 -0
- package/ts/chunks/chunk-CCYWFSXR.js +3 -0
- package/{chunks/chunk-OAWYVETM.js → ts/chunks/chunk-CL55MNGD.js} +1 -1
- package/ts/chunks/chunk-CSP2GUD4.js +29 -0
- package/{chunks/chunk-EROZRDGT.js → ts/chunks/chunk-D2UKX2VW.js} +1 -1
- package/ts/chunks/chunk-DGYDUGTM.js +1 -0
- package/ts/chunks/chunk-FB3Z7XYQ.js +1 -0
- package/ts/chunks/chunk-FLLYK5FU.js +1 -0
- package/{chunks/chunk-EJYSOUEA.js → ts/chunks/chunk-GCPGG4YB.js} +1 -1
- package/{chunks/chunk-FYFUEK4U.js → ts/chunks/chunk-HLDPASM6.js} +1 -1
- package/ts/chunks/chunk-HNQA5O2S.js +2 -0
- package/ts/chunks/chunk-HUP7XWW6.js +1 -0
- package/ts/chunks/chunk-J3XNDEMU.js +4 -0
- package/ts/chunks/chunk-K6FVY52W.js +5 -0
- package/ts/chunks/chunk-KQJGXVWX.js +91 -0
- package/ts/chunks/chunk-M4U4Y3XQ.js +7 -0
- package/ts/chunks/chunk-M6CAJL36.js +1 -0
- package/ts/chunks/chunk-MPHTBN7E.js +1 -0
- package/ts/chunks/chunk-NYIFCLEG.js +1 -0
- package/ts/chunks/chunk-RRDWQKZY.js +1 -0
- package/ts/chunks/chunk-RVNSKPFL.js +1 -0
- package/ts/chunks/chunk-S5F2DAAG.js +5 -0
- package/ts/chunks/chunk-SCYP2G2T.js +3 -0
- package/ts/chunks/chunk-SWP6BJR6.js +147 -0
- package/{chunks/chunk-XDRX4ZBJ.js → ts/chunks/chunk-SWRVSRYY.js} +1 -1
- package/ts/chunks/chunk-T2X4E35X.js +1 -0
- package/ts/chunks/chunk-TDLTCTV4.js +1 -0
- package/ts/chunks/chunk-TKBGNLNV.js +1 -0
- package/ts/chunks/chunk-UY4YFVSW.js +3 -0
- package/ts/chunks/chunk-V5ZXCJPI.js +2 -0
- package/ts/chunks/chunk-W46BJM2F.js +1 -0
- package/ts/chunks/chunk-W7KQFMHV.js +1 -0
- package/ts/chunks/chunk-XGRZPTAD.js +24 -0
- package/ts/chunks/chunk-XTQFSF6C.js +1 -0
- package/ts/chunks/chunk-YN3SHWBR.js +1 -0
- package/ts/chunks/chunk-ZAY6LSJD.js +2 -0
- package/ts/chunks/chunk-ZGVXR3EC.js +8 -0
- package/ts/chunks/chunk-ZW5C5IGT.js +32 -0
- package/ts/chunks/claude-code-J2V5WSGZ.js +1 -0
- package/ts/chunks/concern-EDWQHU4H.js +1 -0
- package/ts/chunks/config-E7BDBHPK.js +1 -0
- package/ts/chunks/decision-ledger-5QXKZSV2.js +1 -0
- package/ts/chunks/delegate-LVQQ3GCV.js +1 -0
- package/ts/chunks/diagrams-2F5ZYXA7.js +1 -0
- package/ts/chunks/diagrams-H62JGTIS.js +1 -0
- package/ts/chunks/done-U3TOSZIX.js +1 -0
- package/ts/chunks/followup-J2HJU3ZT.js +1 -0
- package/ts/chunks/free-73WMLMCT.js +1 -0
- package/ts/chunks/gemini-GA6P4M7D.js +1 -0
- package/ts/chunks/init-6CVDGRY2.js +1 -0
- package/ts/chunks/invoke-hook-2TMKWL7I.js +15 -0
- package/ts/chunks/kiro-BJSKSAUC.js +1 -0
- package/ts/chunks/learn-7Q2VWZMI.js +7 -0
- package/ts/chunks/ledger-XR4AHZRX.js +2 -0
- package/ts/chunks/list-CUQCPXZH.js +1 -0
- package/ts/chunks/manager-WTLJ5C2I.js +3 -0
- package/ts/chunks/mod-BZA5TFW7.js +1 -0
- package/ts/chunks/mod-RWA5ZPYH.js +1 -0
- package/ts/chunks/mod-X372UNSQ.js +1 -0
- package/ts/chunks/mod-XVE4ZWPY.js +1 -0
- package/ts/chunks/next-CEYZSYGB.js +20 -0
- package/ts/chunks/node-33JV5VS3.js +15 -0
- package/ts/chunks/node-XYP2DQHR.js +74 -0
- package/{chunks/node-2XIHQ2M4.js → ts/chunks/node-ZSGIX7K3.js} +1 -1
- package/ts/chunks/ollama-X6OGN5BW.js +1 -0
- package/ts/chunks/openai-TV7KLQ2C.js +1 -0
- package/ts/chunks/openai-YPM2E7QS.js +30 -0
- package/ts/chunks/opencode-AK6WWZRF.js +1 -0
- package/ts/chunks/pack-EOUSZGJT.js +5 -0
- package/ts/chunks/plan-export-ZBINRAAS.js +3 -0
- package/ts/chunks/purge-GPMC5A6Y.js +5 -0
- package/ts/chunks/reopen-LPVNZN5I.js +1 -0
- package/ts/chunks/reset-RNLPXGWQ.js +1 -0
- package/ts/chunks/review-ZGAY5XCN.js +1 -0
- package/ts/chunks/rule-SNBQ4VZD.js +6 -0
- package/ts/chunks/run-4TDP4C7Z.js +3 -0
- package/ts/chunks/sdk-MEVPL5WT.js +1 -0
- package/ts/chunks/session-J7TSLNEH.js +1 -0
- package/ts/chunks/spec-3NSPFDIC.js +1 -0
- package/ts/chunks/status-DIEA2OGR.js +1 -0
- package/ts/chunks/sync-HZNKILSP.js +1 -0
- package/ts/chunks/validate-MWHDOF2F.js +1 -0
- package/ts/chunks/vertexai-ARXI4AMJ.js +1 -0
- package/ts/chunks/watch-P6HABMAS.js +7 -0
- package/ts/chunks/web-BMIC3VJQ.js +1 -0
- package/ts/chunks/wontfix-6UKEYTVB.js +1 -0
- package/ts/noskills.js +2 -0
- package/chunks/anthropic-ZKOMTKX2.js +0 -1
- package/chunks/approve-3TKOHYHH.js +0 -1
- package/chunks/ask-UB26SBWQ.js +0 -2
- package/chunks/block-Q4WAIX7X.js +0 -1
- package/chunks/browser-BGFD24RX.js +0 -1
- package/chunks/bun-WZ7BVR7Y.js +0 -1
- package/chunks/cancel-DY76ADX4.js +0 -1
- package/chunks/chunk-34RPTI4K.js +0 -29
- package/chunks/chunk-3JTDWOAJ.js +0 -2
- package/chunks/chunk-5FX4EBFY.js +0 -5
- package/chunks/chunk-5RLCKUIF.js +0 -2
- package/chunks/chunk-7PBHRFOZ.js +0 -3
- package/chunks/chunk-7PPUGTKL.js +0 -4
- package/chunks/chunk-AB3N327V.js +0 -1
- package/chunks/chunk-AUZWXMWA.js +0 -27
- package/chunks/chunk-BYPCI5VU.js +0 -1
- package/chunks/chunk-CH6A3LES.js +0 -91
- package/chunks/chunk-CKIZYL4O.js +0 -3
- package/chunks/chunk-CTTMQSHF.js +0 -1
- package/chunks/chunk-DEHRWREM.js +0 -1
- package/chunks/chunk-DYCGJ4RY.js +0 -4
- package/chunks/chunk-ENP4P2YH.js +0 -0
- package/chunks/chunk-EVJYA7S3.js +0 -21
- package/chunks/chunk-FE4MKOI4.js +0 -1
- package/chunks/chunk-GNMOE7H3.js +0 -48
- package/chunks/chunk-HB62UGZI.js +0 -2
- package/chunks/chunk-IFE5SYGK.js +0 -1
- package/chunks/chunk-IM73MYMS.js +0 -1
- package/chunks/chunk-JYVB6UAV.js +0 -1
- package/chunks/chunk-KJLEPI7T.js +0 -1
- package/chunks/chunk-KRRPOVQG.js +0 -1
- package/chunks/chunk-LGQEWL5X.js +0 -1
- package/chunks/chunk-LJEWPIEI.js +0 -1
- package/chunks/chunk-LKZZ4JN5.js +0 -110
- package/chunks/chunk-NGCBWJML.js +0 -2
- package/chunks/chunk-NPWXEWRN.js +0 -4
- package/chunks/chunk-O4KKKYCH.js +0 -1
- package/chunks/chunk-ONJVI5AZ.js +0 -23
- package/chunks/chunk-OP4XAIGW.js +0 -1
- package/chunks/chunk-PSX63TYP.js +0 -2
- package/chunks/chunk-Q4TI7EYT.js +0 -5
- package/chunks/chunk-SLO22P65.js +0 -1
- package/chunks/chunk-T6NZVA6P.js +0 -7
- package/chunks/chunk-TCSIXKUD.js +0 -3
- package/chunks/chunk-VJRCTYGL.js +0 -1
- package/chunks/chunk-VXU6XZ66.js +0 -39
- package/chunks/chunk-WDKWHGJU.js +0 -146
- package/chunks/chunk-XDPATEP5.js +0 -1
- package/chunks/chunk-Y45DQJSS.js +0 -3
- package/chunks/chunk-Y5E7ZCCX.js +0 -1
- package/chunks/chunk-YUTDPPXX.js +0 -1
- package/chunks/chunk-Z7OYXH3J.js +0 -1
- package/chunks/claude-code-OQJIUKZP.js +0 -1
- package/chunks/cmd-46ZIHXLB.js +0 -1
- package/chunks/concern-UIGVWDFS.js +0 -1
- package/chunks/config-72Z4PIJN.js +0 -1
- package/chunks/decision-ledger-5IPPTRT7.js +0 -1
- package/chunks/delegate-OV6NY434.js +0 -1
- package/chunks/deno-YM5PW6ZM.js +0 -1
- package/chunks/diagrams-CBCUA47B.js +0 -1
- package/chunks/diagrams-OX4FBDGP.js +0 -1
- package/chunks/done-V54GSSTY.js +0 -1
- package/chunks/followup-NL7EPIGF.js +0 -1
- package/chunks/free-KD344KRL.js +0 -1
- package/chunks/gemini-23EOEXSF.js +0 -1
- package/chunks/init-WDRNFT57.js +0 -1
- package/chunks/invoke-hook-I3NTD36Q.js +0 -13
- package/chunks/kiro-TPAAIMY6.js +0 -1
- package/chunks/learn-WBWNJEB2.js +0 -7
- package/chunks/ledger-QYK252DV.js +0 -1
- package/chunks/list-WO6RS7JX.js +0 -1
- package/chunks/loader-command-3A5FK2RF.js +0 -1
- package/chunks/loader-reactor-YZM7HO4G.js +0 -1
- package/chunks/manager-ZSPRC5R4.js +0 -3
- package/chunks/mod-7VTKN6Q5.js +0 -1
- package/chunks/mod-B6LBGYON.js +0 -1
- package/chunks/mod-MMHDQRNF.js +0 -1
- package/chunks/mod-RBGAMGZA.js +0 -1
- package/chunks/mod-SFSUQWSB.js +0 -8
- package/chunks/mod-SV4VELMH.js +0 -1
- package/chunks/next-QXCLZ7P3.js +0 -15
- package/chunks/node-BXYZKSJY.js +0 -15
- package/chunks/node-DMUOWFGA.js +0 -69
- package/chunks/node-J4GTOSL2.js +0 -1
- package/chunks/ollama-MXRDGQDF.js +0 -1
- package/chunks/openai-LE47IWMQ.js +0 -30
- package/chunks/openai-MSJF4B6H.js +0 -1
- package/chunks/opencode-ZDHKR2P6.js +0 -1
- package/chunks/pack-NS64WU6M.js +0 -5
- package/chunks/plan-export-HECAF7D4.js +0 -3
- package/chunks/purge-PSQNN42H.js +0 -4
- package/chunks/reopen-L37M5XUI.js +0 -1
- package/chunks/reset-OOTZXW6Q.js +0 -1
- package/chunks/review-QLD6WSOB.js +0 -1
- package/chunks/rule-OOANQBHB.js +0 -6
- package/chunks/run-YHCIRY7Z.js +0 -3
- package/chunks/sdk-OQIHH3OY.js +0 -1
- package/chunks/session-OWWDH7KA.js +0 -1
- package/chunks/spec-O7F525UN.js +0 -1
- package/chunks/status-SZZXY7V3.js +0 -1
- package/chunks/sync-3RYRGTEA.js +0 -1
- package/chunks/unstable_chmod-44MCKF3B.js +0 -1
- package/chunks/validate-UZD6JBSG.js +0 -1
- package/chunks/vertexai-CVCRCO24.js +0 -1
- package/chunks/watch-5DNM646U.js +0 -8
- package/chunks/web-662LNB3K.js +0 -1
- package/chunks/wontfix-UDCTLHNB.js +0 -1
- package/chunks/workerd-I7MLRCLJ.js +0 -1
- /package/{chunks/chunk-5OTECUN7.js → ts/chunks/chunk-ATNTR7M5.js} +0 -0
- /package/{chunks → ts/chunks}/chunk-HISXAZ4Y.js +0 -0
- /package/{chunks → ts/chunks}/chunk-I4Z2RF7L.js +0 -0
- /package/{chunks → ts/chunks}/dist-3MH5UCQU.js +0 -0
- /package/{chunks → ts/chunks}/multipart-parser-DKDFOZKD.js +0 -0
- /package/{chunks → ts/chunks}/src-HXQVVTGQ.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as f}from"./chunk-M4U4Y3XQ.js";var m=async(n,r)=>{let t=`${n}/.eser/specs/${r}/spec.md`,s;try{s=await f.fs.readTextFile(t)}catch{return null}return g(r,s)},g=(n,r)=>{let t=[],s=[],l=[],i="";for(let p of r.split(`
|
|
2
2
|
`)){let e=p.trim();if(e.startsWith("## ")){i=e.slice(3).trim().toLowerCase();continue}if(i.startsWith("tasks")){let a=e.match(/^-\s*\[[ x]\]\s*(task-\d+):\s*(.+)$/i);a!==null&&t.push({id:a[1],title:a[2].trim()});let c=e.match(/^Files?:\s*(.+)$/i);if(c!==null&&t.length>0){let h=t[t.length-1],d=c[1].split(",").map(o=>o.trim().replace(/^`|`$/g,"")).filter(o=>o.length>0);d.length>0&&(t[t.length-1]={...h,files:d})}}i.startsWith("out of scope")&&e.startsWith("- ")&&s.push(e.slice(2).trim()),i.startsWith("verification")&&e.startsWith("- ")&&l.push(e.slice(2).trim())}return{name:n,tasks:t,outOfScope:s,verification:l}},y=(n,r)=>{let t=new Set(r);for(let s of n)if(!t.has(s.id))return s;return null};export{m as a,g as b,y as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as o,c as i}from"./chunk-RVNSKPFL.js";var d=(e,n)=>{if(e!==void 0)for(let r of e){if(r==="--agent")return"agent";if(r==="--human")return"human"}let t=n?.agentMode;return t===!0?"agent":t===!1?"human":o()},u=e=>{if(e!==void 0){for(let n of e)if(n==="--non-interactive")return"non-interactive"}return i()},c=e=>e===void 0?[]:e.filter(n=>n!=="--agent"&&n!=="--human"&&n!=="--non-interactive");export{d as a,u as b,c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as r}from"./chunk-UY4YFVSW.js";import{C as i}from"./chunk-M4U4Y3XQ.js";var o=async e=>{try{return await r`which ${e}`.noThrow().code()===0}catch{return!1}},s=async()=>{try{return(await fetch("http://localhost:11434/api/version",{signal:AbortSignal.timeout(1e3)})).ok}catch{return!1}},a=e=>i.env.has(e),c=async()=>{let[e,t,l,n]=await Promise.all([o("claude"),s(),o("opencode"),o("kiro")]);return[{name:"claude-code",alias:"cc",type:"CLI",available:e,detail:e?"claude binary found":"claude not on PATH"},{name:"ollama",alias:"ol",type:"HTTP",available:t,detail:t?"localhost:11434 reachable":"localhost:11434 not reachable"},{name:"opencode",alias:"oc",type:"CLI",available:l,detail:l?"opencode binary found":"opencode not on PATH"},{name:"kiro",alias:"kr",type:"CLI",available:n,detail:n?"kiro binary found":"kiro not on PATH"},{name:"anthropic",alias:"ant",type:"API",available:a("ANTHROPIC_API_KEY")||a("ANTHROPIC_AUTH_TOKEN"),detail:a("ANTHROPIC_API_KEY")?"ANTHROPIC_API_KEY set":a("ANTHROPIC_AUTH_TOKEN")?"ANTHROPIC_AUTH_TOKEN set":"ANTHROPIC_API_KEY not set"},{name:"openai",alias:"oai",type:"API",available:a("OPENAI_API_KEY"),detail:a("OPENAI_API_KEY")?"OPENAI_API_KEY set":"OPENAI_API_KEY not set"},{name:"gemini",alias:"gem",type:"API",available:a("GEMINI_API_KEY")||a("GOOGLE_API_KEY"),detail:a("GEMINI_API_KEY")||a("GOOGLE_API_KEY")?"API key set":"GEMINI_API_KEY not set"},{name:"vertexai",alias:"vtx",type:"API",available:a("GOOGLE_CLOUD_PROJECT"),detail:a("GOOGLE_CLOUD_PROJECT")?"GOOGLE_CLOUD_PROJECT set":"GOOGLE_CLOUD_PROJECT not set"}]},_=async()=>(await c()).filter(t=>t.available).map(t=>t.name);export{c as a,_ as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=()=>"Ask the user the unanswered base discovery questions together, in one exchange, and submit the confirmed answers as one JSON object keyed by question id. Ask each follow-up question on its own and wait for its answer before you ask the next.",r=e=>`Discovery answers come from the user. You may pre-fill a suggested answer from what the user already wrote (the spec description, a plan, earlier messages): mark it [STATED] when the user said it or [INFERRED] when it is your reading, and have the user confirm or correct it. Submit only confirmed answers, in the one call \`transition.onComplete\` shows (\`${e}\`). Never submit an answer the user has not confirmed.`;export{s as a,r as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=(t,e)=>({role:t,content:[{kind:"text",text:e}]}),u=(t,e,o)=>({role:t,content:[{kind:"image",image:{url:e,detail:o}}]}),d=(t,e,o)=>({role:t,content:[{kind:"audio",audio:{url:e,mimeType:o}}]}),m=(t,e,o=!1)=>({role:"tool",content:[{kind:"tool_result",toolResult:{toolCallId:t,content:e,isError:o}}]}),y=t=>({kind:"text",text:t}),x=(t,e,o)=>({kind:"tool_call",toolCall:{id:t,name:e,arguments:o}}),b=(t,e,o=!1)=>({kind:"tool_result",toolResult:{toolCallId:t,content:e,isError:o}}),l="data:",i=";base64,",f=t=>t.startsWith(l),
|
|
1
|
+
var c=(t,e)=>({role:t,content:[{kind:"text",text:e}]}),u=(t,e,o)=>({role:t,content:[{kind:"image",image:{url:e,detail:o}}]}),d=(t,e,o)=>({role:t,content:[{kind:"audio",audio:{url:e,mimeType:o}}]}),m=(t,e,o=!1)=>({role:"tool",content:[{kind:"tool_result",toolResult:{toolCallId:t,content:e,isError:o}}]}),y=t=>({kind:"text",text:t}),x=(t,e,o)=>({kind:"tool_call",toolCall:{id:t,name:e,arguments:o}}),b=(t,e,o=!1)=>({kind:"tool_result",toolResult:{toolCallId:t,content:e,isError:o}}),l="data:",i=";base64,",f=t=>t.startsWith(l),M=t=>{if(!t.startsWith(l))return null;let e=t.slice(l.length),o=e.indexOf(i);if(o===-1)return null;let s=e.slice(0,o),g=e.slice(o+i.length),r=atob(g),a=new Uint8Array(r.length);for(let n=0;n<r.length;n++)a[n]=r.charCodeAt(n);return{mimeType:s,data:a}},p=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["webp","image/webp"],["svg","image/svg+xml"],["bmp","image/bmp"],["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["flac","audio/flac"],["m4a","audio/mp4"],["webm","audio/webm"],["pdf","application/pdf"],["json","application/json"],["txt","text/plain"]]),k=t=>{let e=t.split("?")[0]??t,o=e.lastIndexOf(".");if(o===-1)return null;let s=e.slice(o+1).toLowerCase();return p.get(s)??null};export{c as a,u as b,d as c,m as d,y as e,x as f,b as g,f as h,M as i,k as j};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as o}from"./chunk-SWP6BJR6.js";import{C as e}from"./chunk-M4U4Y3XQ.js";var d=async(r,i,n)=>{let s=`${r}/${o.specFile(i)}`;try{let t=await e.fs.readTextFile(s);t=t.replace(/^## Status: .+$/m,`## Status: ${n}`),await e.fs.writeTextFile(s,t)}catch{}},u=async(r,i,n)=>{let s=`${r}/${o.specFile(i)}`;try{let t=await e.fs.readTextFile(s),a=new RegExp(`^(- )\\[ \\]( ${n}:.*)$`,"m");t=t.replace(a,"$1[x]$2"),await e.fs.writeTextFile(s,t)}catch{}},w=async(r,i,n,s)=>{let t=`${r}/${o.specDir(i)}/progress.json`;try{let a=await e.fs.readTextFile(t),c=JSON.parse(a);for(let p of c.tasks)p.id===n&&(p.status=s);c.updatedAt=new Date().toISOString(),await e.fs.writeTextFile(t,JSON.stringify(c,null,2)+`
|
|
2
2
|
`)}catch{}},f=async(r,i,n)=>{let s=`${r}/${o.specDir(i)}/progress.json`;try{let t=await e.fs.readTextFile(s),a=JSON.parse(t);a.status=n,a.updatedAt=new Date().toISOString(),await e.fs.writeTextFile(s,JSON.stringify(a,null,2)+`
|
|
3
3
|
`)}catch{}};export{d as a,u as b,w as c,f as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h as f,i as m,j as l}from"./chunk-GCPGG4YB.js";import{a as p}from"./chunk-T2X4E35X.js";import{e as c}from"./chunk-YN3SHWBR.js";var x=e=>e==="assistant"?"model":e==="tool"?"user":e,I=e=>{switch(e.kind){case"text":return{text:e.text};case"image":{if(e.image.data!==void 0)return{inlineData:{mimeType:e.image.mimeType??"image/png",data:d(e.image.data)}};if(e.image.url!==void 0){if(f(e.image.url)){let t=m(e.image.url);if(t!==null)return{inlineData:{mimeType:t.mimeType,data:d(t.data)}}}return{fileData:{mimeType:e.image.mimeType??l(e.image.url)??"image/png",fileUri:e.image.url}}}return{text:"[unsupported image]"}}case"audio":return e.audio.data!==void 0?{inlineData:{mimeType:e.audio.mimeType??"audio/mpeg",data:d(e.audio.data)}}:e.audio.url!==void 0?{fileData:{mimeType:e.audio.mimeType??l(e.audio.url)??"audio/mpeg",fileUri:e.audio.url}}:{text:"[unsupported audio]"};case"file":return{fileData:{mimeType:e.file.mimeType??"application/octet-stream",fileUri:e.file.uri}};case"tool_call":return{functionCall:{name:e.toolCall.name,args:e.toolCall.arguments}};case"tool_result":return{functionResponse:{name:e.toolResult.toolCallId,response:{content:e.toolResult.content}}};case"thinking":return{text:e.thinking.text,thought:!0}}},h=e=>{let t=null,a=[];for(let o of e){if(o.role==="system"){let i=[];for(let n of o.content)n.kind==="text"&&i.push(n.text);t=i.join(`
|
|
2
|
+
`);continue}let r=o.content.filter(i=>i.kind!=="thinking").map(I);a.push({role:x(o.role),parts:r})}return{contents:a,systemInstruction:t}},R=e=>e.map(t=>({functionDeclarations:[{name:t.name,description:t.description,parameters:t.parameters}]})),C=(e,t)=>{switch(e){case"low":return"LOW";case"medium":return"MEDIUM";case"high":case"xhigh":case"max":return"HIGH";default:throw new c(`unknown effort level ${JSON.stringify(e)}; use low, medium, high, xhigh or max, or leave it unset for the provider default`,{provider:t})}},_=(e,t,a,o)=>{let{contents:r,systemInstruction:i}=h(t.messages),n={maxOutputTokens:t.maxTokens??e.maxTokens};switch(t.temperature!==void 0&&(n.temperature=t.temperature),t.topP!==void 0&&(n.topP=t.topP),t.stopWords!==void 0&&(n.stopSequences=t.stopWords),t.responseFormat?.type){case"json_schema":n.responseMimeType="application/json",n.responseJsonSchema=p(t.responseFormat,a);break;case"json_object":n.responseMimeType="application/json";break;case"text":n.responseMimeType="text/plain";break}t.effort!==void 0?n.thinkingConfig={thinkingLevel:C(t.effort,a)}:t.thinkingBudget!==void 0&&(n.thinkingConfig={thinkingBudget:t.thinkingBudget});let s=t.system??i;return s!==null&&(n.systemInstruction=s),t.tools!==void 0&&(n.tools=R(t.tools)),t.safetySettings!==void 0&&(n.safetySettings=t.safetySettings),o!==void 0&&(n.abortSignal=o),{contents:r,config:n}},k=new Set(["SAFETY","BLOCKLIST","PROHIBITED_CONTENT","SPII","RECITATION","IMAGE_SAFETY","IMAGE_PROHIBITED_CONTENT","IMAGE_RECITATION"]),g=(e,t)=>e==="STOP"?t?"tool_use":"end_turn":e==="MAX_TOKENS"?"max_tokens":k.has(e)?"refusal":"stop",y=e=>{let t=e?.promptFeedback?.blockReason;return typeof t=="string"&&t!==""&&t!=="BLOCKED_REASON_UNSPECIFIED"},T=e=>({id:e.name,name:e.name,arguments:e.args??{}}),w=(e,t)=>{let a=[],o="end_turn",r=e?.candidates?.[0];if(r==null)y(e)&&(o="refusal");else{let n=!1;for(let u of r.content?.parts??[])u.text!==void 0&&a.push({kind:"text",text:u.text}),u.functionCall!==void 0&&(a.push({kind:"tool_call",toolCall:T(u.functionCall)}),n=!0);let s=r.finishReason;typeof s=="string"?o=g(s,n):n&&(o="tool_use")}let i=e?.usageMetadata;return{content:a,stopReason:o,usage:{inputTokens:i?.promptTokenCount??0,outputTokens:i?.candidatesTokenCount??0,totalTokens:i?.totalTokenCount??0},modelId:t,rawResponse:e}};async function*G(e){let t=0,a=0,o=!1;for await(let r of e){let i=r?.candidates?.[0],n=null;if(i==null)y(r)&&(n="refusal");else{for(let u of i.content?.parts??[])u.text!==void 0&&(yield{kind:"content_delta",textDelta:u.text}),u.functionCall!==void 0&&(o=!0,yield{kind:"tool_call_delta",toolCall:T(u.functionCall)});let s=i.finishReason;typeof s=="string"&&(n=g(s,o))}if(n!==null){let s=r?.usageMetadata;t=s?.promptTokenCount??t,a=s?.candidatesTokenCount??a,yield{kind:"message_done",stopReason:n,usage:{inputTokens:t,outputTokens:a,totalTokens:t+a}}}}}var M=e=>e?.status!==void 0?e.status:e?.code!==void 0?e.code:500,d=e=>{let t="";for(let a=0;a<e.length;a++)t+=String.fromCharCode(e[a]);return btoa(t)};export{x as a,I as b,h as c,R as d,_ as e,w as f,G as g,M as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w,b as p,c as g,d as v,e as T,f as m,g as f,h as y}from"./chunk-CCYWFSXR.js";import{a as c}from"./chunk-YN3SHWBR.js";import{a as S,b as k}from"./chunk-CL55MNGD.js";var x=class{capabilities=["text_generation","streaming"];provider="opencode";modelId;binary;config;constructor(e,r){this.binary=e,this.config=r,this.modelId=r.model}async generateText(e,r){let s=E(this.config,e,"json"),i=y(e.messages,e.system),n=p(this.binary,s,{signal:r,stdinData:i}),a=m(n.stderr);try{let t=await T(n.stdout,this.modelId),u=await n.waitForExit(),d=await a,l=f("opencode",u.code,d);return l!==null?k(l):S(t)}finally{await g(n,a)}}async*streamText(e,r){let s=E(this.config,e,"stream-json"),i=y(e.messages,e.system),n=p(this.binary,s,{signal:r,stdinData:i}),a=m(n.stderr);try{for await(let l of v(n.stdout)){let h=b(l);h!==null&&(yield h)}let t=await n.waitForExit(),u=await a,d=f("opencode",t.code,u);d!==null&&(yield{kind:"error",error:d})}catch(t){t instanceof c?yield{kind:"error",error:t}:yield{kind:"error",error:new c(t instanceof Error?t.message:String(t),{provider:"opencode",cause:t instanceof Error?t:void 0})}}finally{await g(n,a)}}close(){return Promise.resolve()}getRawClient(){return null}},_={provider:"opencode",createModel:async o=>{let e=await w("opencode",o);return new x(e,o)}},E=(o,e,r)=>{let s=["--output-format",r];s.push("--model",o.model),e.maxTokens!==void 0&&s.push("--max-tokens",String(e.maxTokens));let i=o.properties?.args;return i!==void 0&&s.push(...i),s},b=o=>{if(o===null||typeof o!="object")return null;let e=o;if(e.type==="content_block_delta"||e.type==="assistant"){let r=e.delta?.text??e.message?.content?.[0]?.text;return r!==void 0?{kind:"content_delta",textDelta:r}:null}return e.type==="result"||e.done===!0?{kind:"message_done",stopReason:"end_turn",usage:{inputTokens:e.usage?.input_tokens??0,outputTokens:e.usage?.output_tokens??0,totalTokens:(e.usage?.input_tokens??0)+(e.usage?.output_tokens??0)}}:e.type==="error"?{kind:"error",error:new c(e.error?.message??"Unknown OpenCode error",{provider:"opencode"})}:e.content!==void 0&&typeof e.content=="string"?{kind:"content_delta",textDelta:e.content}:null};export{x as a,_ as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{C as x}from"./chunk-M4U4Y3XQ.js";var C=s=>{if(s===void 0)return"json";for(let t of s)if(t==="-o"||t.startsWith("--output")){let n=s.indexOf(t);if(t.includes("="))return y(t.split("=")[1]??"json");let e=s[n+1];if(e!==void 0&&!e.startsWith("-"))return y(e)}return"json"},R=s=>{if(s===void 0)return[];let t=[],n=!1;for(let e=0;e<s.length;e++){if(n){n=!1;continue}let u=s[e];if(!u.startsWith("--output=")){if(u==="-o"||u==="--output"){n=!0;continue}t.push(u)}}return t},y=s=>{let t=s.toLowerCase();return t==="md"||t==="markdown"?"markdown":t==="text"||t==="txt"||t==="plain"?"text":"json"},i=(s,t)=>s[t],w=s=>{let t=i(s,"validation");if(t===void 0)return null;let n=t.agent===null?"not run":`${t.agent}, ${t.model}`;return t.status==="skipped"?{by:n,summary:`Skipped: ${t.reason}`,items:[]}:{by:n,summary:t.findings.length===0?[t.summary,"No findings."].filter(e=>e!=="").join(" "):t.summary,items:t.findings.map(e=>e.suggestion===""?`[${e.severity}] ${e.issue}`:`[${e.severity}] ${e.issue} Suggestion: ${e.suggestion}`)}},g=s=>{if(s===null||typeof s!="object"||!("text"in s))return`${s}`;let t="id"in s?s.id:void 0;return t===void 0?`${s.text}`:`${t}: ${s.text}`},k=s=>JSON.stringify(s,null,2),b=s=>{let t=s,n=[],e=i(t,"phase");e!==void 0&&(n.push(`# noskills \u2014 ${e}`),n.push(""));let u=i(t,"instruction");u!==void 0&&(n.push("## Instruction"),n.push(""),n.push(u),n.push(""));let c=i(t,"questions");if(c!==void 0&&c.length>0)for(let o of c){if(n.push(`## Question: ${o.id}`),n.push(""),n.push(`> ${o.text}`),o.extras!==void 0&&o.extras.length>0){n.push(""),n.push("Also consider:");for(let $ of o.extras)n.push(`- ${$}`)}n.push("")}let h=i(t,"statusReport");if(h!==void 0){n.push("## Acceptance Criteria"),n.push("");for(let o of h.criteria)n.push(`- [ ] ${g(o)}`);n.push("")}let p=i(t,"previousIterationDebt");if(p!==void 0){n.push(`## Debt (from iteration ${p.fromIteration})`),n.push(""),n.push(`> ${p.note}`),n.push("");for(let o of p.items)n.push(`- ${g(o)}`);n.push("")}i(t,"verificationFailed")===!0&&(n.push("## Verification FAILED"),n.push(""),n.push("```"),n.push(String(i(t,"verificationOutput")??"")),n.push("```"),n.push(""));let a=w(t);if(a!==null){n.push(`## Validation (${a.by})`),n.push(""),n.push(a.summary),n.push("");for(let o of a.items)n.push(`- ${o}`);a.items.length>0&&n.push("")}let f=i(t,"behavioral");if(f!==void 0){n.push("## Behavioral"),n.push(""),n.push(`**Tone:** ${f.tone}`),n.push("");for(let o of f.rules)n.push(`- ${o}`);n.push("")}let d=i(t,"meta");d!==void 0&&(n.push("---"),n.push(""),n.push(`*${d.resumeHint}*`),n.push(""));let l=i(t,"transition");if(l!==void 0){n.push("## Next Steps"),n.push("");for(let[o,$]of Object.entries(l))o!=="iteration"&&n.push(`- **${o}:** \`${$}\``);n.push("")}let r=i(t,"summary");r!==void 0&&(n.push("## Summary"),n.push(""),n.push(`- Spec: ${r.spec}`),n.push(`- Iterations: ${r.iterations}`),n.push(`- Decisions: ${r.decisionsCount}`),n.push(""));let m=i(t,"clearContext");return m!==void 0&&(n.push("---"),n.push(""),n.push(`**Action required:** ${m.reason}`),n.push("")),n.join(`
|
|
2
|
+
`)},v=s=>{let t=s,n=[],e=i(t,"phase");e!==void 0&&n.push(`[${e}]`);let u=i(t,"instruction");u!==void 0&&n.push(u);let c=i(t,"questions");if(c!==void 0&&c.length>0){for(let r of c)if(n.push(""),n.push(`Question [${r.id}]: ${r.text}`),r.extras!==void 0)for(let m of r.extras)n.push(` - ${m}`)}let h=i(t,"statusReport");if(h!==void 0){n.push(""),n.push("Criteria:");for(let r of h.criteria)n.push(` - ${g(r)}`)}let p=i(t,"previousIterationDebt");if(p!==void 0){n.push(""),n.push(p.note);for(let r of p.items)n.push(` - ${g(r)}`)}i(t,"verificationFailed")===!0&&(n.push(""),n.push(`Verification failed: ${String(i(t,"verificationOutput")??"").slice(0,200)}`));let a=w(t);if(a!==null){n.push(""),n.push(`Validation (${a.by}): ${a.summary}`);for(let r of a.items)n.push(` - ${r}`)}let f=i(t,"meta");f!==void 0&&(n.push(""),n.push(f.resumeHint));let d=i(t,"summary");d!==void 0&&n.push(`Spec: ${d.spec}, Iterations: ${d.iterations}, Decisions: ${d.decisionsCount}`);let l=i(t,"clearContext");return l!==void 0&&(n.push(""),n.push(l.reason)),n.join(`
|
|
3
|
+
`)},O=(s,t)=>{switch(t){case"markdown":return b(s);case"text":return v(s);default:return k(s)}},S=async(s,t)=>{await j(O(s,t))},j=async s=>{let t=new TextEncoder,n=x.process.stdout.getWriter();await n.write(t.encode(s+`
|
|
4
|
+
`)),n.releaseLock()};export{C as a,R as b,O as c,S as d,j as e};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{C as c}from"./chunk-M4U4Y3XQ.js";var p=".eser",w=`${p}/diagrams.json`,g=r=>{let t=0;for(let a=0;a<r.length;a++){let s=r.charCodeAt(a);t=(t<<5)-t+s,t|=0}return Math.abs(t).toString(36)},u=r=>{let t=new Set,a=/(?:[\w@.-]+\/)*[\w@.-]+\.(?:ts|tsx|js|jsx|go|py|rs|md|json|yaml|yml)/g,s;for(;(s=a.exec(r))!==null;)t.add(s[0]);let i=r.replace(a," "),e=/(?:@[\w-]+\/[\w-]+|[\w-]+\/[\w-]+)/g;for(;(s=e.exec(i))!==null;)t.add(s[0]);return[...t]},S=async(r,t)=>{let a=`${r}/${t}`,s;try{s=await c.fs.readTextFile(a)}catch{return[]}let i=[],e=s.split(`
|
|
2
|
+
`),n=new Date().toISOString(),l=!1,h=0,d="";for(let o=0;o<e.length;o++){let f=e[o];if(f.trim().startsWith("```mermaid")){l=!0,h=o+1,d="";continue}if(l&&f.trim()==="```"){l=!1,i.push({file:t,line:h,type:"mermaid",hash:g(d),referencedFiles:u(d),lastVerified:n});continue}if(l){d+=f+`
|
|
3
|
+
`;continue}if(/[┌─┬┐│└┴┘╔═╗║╚╝╭╮╰╯]/.test(f)&&e[o+1]!==void 0&&/[┌─┬┐│└┴┘╔═╗║╚╝╭╮╰╯]/.test(e[o+1])){let y="",m=o;for(;m<e.length&&/[┌─┬┐│└┴┘╔═╗║╚╝╭╮╰╯┼├┤▶→←↓↑\|+\-]/.test(e[m]);)y+=e[m]+`
|
|
4
|
+
`,m++;y.length>20&&i.push({file:t,line:o+1,type:"ascii",hash:g(y),referencedFiles:u(y),lastVerified:n}),o=m-1}}return i},x=async r=>{let t=[],a=[],s=async(i,e)=>{try{for await(let n of c.fs.readDir(i))n.name.startsWith(".")||n.name==="node_modules"||(n.isFile&&n.name.endsWith(".md")&&a.push(e===""?n.name:`${e}/${n.name}`),n.isDirectory&&!n.name.startsWith(".")&&await s(`${i}/${n.name}`,e===""?n.name:`${e}/${n.name}`))}catch{}};await s(r,"");for(let i of a){let e=await S(r,i);t.push(...e)}try{for await(let i of c.fs.readDir(r))if(i.isFile&&i.name.endsWith(".puml")){let e=await c.fs.readTextFile(`${r}/${i.name}`);t.push({file:i.name,line:1,type:"plantuml",hash:g(e),referencedFiles:u(e),lastVerified:new Date().toISOString()})}}catch{}return t},D=async r=>{try{let t=await c.fs.readTextFile(`${r}/${w}`);return JSON.parse(t)}catch{return[]}},$=async(r,t)=>{await c.fs.mkdir(`${r}/${p}`,{recursive:!0}),await c.fs.writeTextFile(`${r}/${w}`,JSON.stringify(t,null,2)+`
|
|
5
|
+
`)},E=async(r,t,a)=>{let s=await D(r),i=!1,e=s.map(n=>n.file===t&&(a===void 0||n.line===a)?(i=!0,{...n,lastVerified:new Date().toISOString()}):n);return i&&await $(r,e),i},P=async(r,t)=>{let a=await D(r);if(a.length===0)return[];let s=new Set(t.map(e=>e.replace(/^\.\//,""))),i=[];for(let e of a)e:for(let n of e.referencedFiles)for(let l of s)if(l.includes(n)||n.includes(l)){i.push({file:e.file,line:e.line,type:e.type,reason:`${l} was modified but diagram references ${n}`});break e}return i};export{x as a,D as b,$ as c,E as d,P as e};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import{C as O}from"./chunk-M4U4Y3XQ.js";import{a as u,b as m}from"./chunk-CL55MNGD.js";import*as $ from"node:util";var R=t=>{let e={};for(let[n,o]of Object.entries(t))e[n]={type:o.type,...o.short!==void 0?{short:o.short}:{},...o.multiple===!0?{multiple:!0}:{},...o.default!==void 0?{default:o.default}:{}};return e},F=(t,e)=>e==="string"?t===!0?"":String(t):t!==!1&&t!=="false",T=(t,e)=>{let n={...t};for(let[o,s]of Object.entries(e)){let r=n[o];r!==void 0&&(n[o]=Array.isArray(r)?r.map(i=>F(i,s.type)):F(r,s.type))}return n},q=(t,e)=>{let n=$.parseArgs({args:[...t],options:R(e),strict:!1,allowPositionals:!0});return{values:n.values,positionals:n.positionals}},B=(t,e={})=>{let n=e.options??{},o=t,s=[];if(e.stopEarly===!0){let{tokens:i}=$.parseArgs({args:[...t],options:R(n),strict:!1,allowPositionals:!0,tokens:!0}),a=i.find(l=>l.kind==="positional");if(a!==void 0){o=t.slice(0,a.index),s=t.slice(a.index);let l=o.includes("--")?-1:s.indexOf("--");l!==-1&&s.splice(l,1)}}let r=q(o,n);return{values:T(r.values,n),positionals:[...r.positionals,...s]}},I=t=>{let e={};for(let n of t)e[n.name]={type:n.type==="boolean"?"boolean":"string",...n.short!==void 0?{short:n.short}:{},...n.type==="string[]"?{multiple:!0}:{}};return e},Y=t=>t!=null&&t.constructor===String,Z={boolean:t=>!!t,number:t=>Y(t)?Number(t):t,string:t=>String(t),"string[]":t=>Array.isArray(t)?t.map(String):[String(t)]},J=(t,e)=>{if(t!==void 0)return Z[e]?.(t)??t},K=(t,e)=>{let n={};for(let o of e){let s=t[o.name]??o.default??(o.type==="boolean"?!1:void 0);n[o.name]=J(s,o.type)}return n},M=(t,e,n={})=>{let o=B(t,{options:I(e),...n.stopEarly!==void 0?{stopEarly:n.stopEarly}:{}});return{positional:o.positionals,flags:K(o.values,e)}},A=(t,e)=>{let n=[];for(let o of e)if(o.required===!0){let s=t[o.name];(s===void 0||s===""||s===!1)&&n.push(`Required flag --${o.name} is missing`)}return n};var f=(t,e)=>t+" ".repeat(Math.max(0,e-t.length)),X=t=>{let e=t.short!==void 0?`-${t.short}, `:"",n=t.type!=="boolean"?` <${t.type}>`:"";return`${e}--${t.name}${n}`},ee=(t,e)=>[t.description!==void 0?`${e} - ${t.description}`:e,""],ne=(t,e)=>{if(t.usage!==void 0)return["Usage:",` ${t.usage}`,""];let n=t.children.length>0?" <command>":"",o=t.flags.length>0?" [options]":"";return["Usage:",` ${e}${n}${o}`,""]},te=t=>{if(t.length===0)return[];let e=s=>s.aliases!==void 0&&s.aliases.length>0?`${s.name}, ${s.aliases.join(", ")}`:s.name,n=Math.max(...t.map(s=>e(s).length));return["Commands:",...t.map(s=>` ${f(e(s),n+2)}${s.description??""}`),""]},se=t=>{if(t===void 0||t.length===0)return[];let e=r=>`-> "${r.join(" ")}"`,n=Math.max(...t.map(r=>r.name.length)),o=Math.max(...t.map(r=>e(r.target).length));return["Shortcuts:",...t.map(r=>` ${f(r.name,n+2)}${f(e(r.target),o+2)}${r.description}`),""]},oe=t=>{if(t.length===0)return[];let e=t.map(s=>({flag:X(s),desc:s.description})),n=Math.max(...e.map(s=>s.flag.length));return["Options:",...e.map(({flag:s,desc:r})=>` ${f(s,n+2)}${r}`),""]},re=t=>t?.length?["Examples:",...t.map(e=>` ${e}`),""]:[],_=(t,e)=>{let n=e.join(" "),o=[...ee(t,n),...ne(t,n),...te(t.children),...se(t.shortcuts),...oe(t.flags),...re(t.examples)];return t.children.length>0&&o.push(`Run '${n} <command> --help' for more information on a command.`),o.join(`
|
|
2
|
+
`)};var k=t=>{let e=[];for(let n of t)e.push(`--${n.name}`),n.short!==void 0&&e.push(`-${n.short}`);return e.join(" ")},w=(t,e)=>{if(t.children===void 0||t.children.length===0)return"";let n=t.children.map(i=>i.name).join(" "),o=t.flags!==void 0?k(t.flags):"",s=[n,o].filter(i=>i.length>0).join(" "),r=` ${e})
|
|
3
|
+
`;r+=` COMPREPLY=( $(compgen -W "${s}" -- "\${cur}") )
|
|
4
|
+
`,r+=` return 0
|
|
5
|
+
`,r+=` ;;
|
|
6
|
+
`;for(let i of t.children)i.children!==void 0&&i.children.length>0&&(r+=w(i,`${e} ${i.name}`));return r},S=(t,e)=>{let n=e.children?.map(i=>i.name).join(" ")??"",o=e.flags!==void 0?k(e.flags):"",s=[n,o].filter(i=>i.length>0).join(" "),r="";if(e.children!==void 0)for(let i of e.children)r+=w(i,i.name);return`# ${t} bash completion
|
|
7
|
+
# Generated by @eserstack/shell/completions
|
|
8
|
+
|
|
9
|
+
_${t}_completions() {
|
|
10
|
+
local cur prev words cword
|
|
11
|
+
_init_completion || return
|
|
12
|
+
|
|
13
|
+
COMPREPLY=()
|
|
14
|
+
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
15
|
+
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
16
|
+
|
|
17
|
+
# Build the command path from words
|
|
18
|
+
local cmd_path=""
|
|
19
|
+
local i
|
|
20
|
+
for ((i=1; i<COMP_CWORD; i++)); do
|
|
21
|
+
case "\${COMP_WORDS[i]}" in
|
|
22
|
+
-*)
|
|
23
|
+
# Skip flags
|
|
24
|
+
;;
|
|
25
|
+
*)
|
|
26
|
+
if [[ -n "$cmd_path" ]]; then
|
|
27
|
+
cmd_path="$cmd_path \${COMP_WORDS[i]}"
|
|
28
|
+
else
|
|
29
|
+
cmd_path="\${COMP_WORDS[i]}"
|
|
30
|
+
fi
|
|
31
|
+
;;
|
|
32
|
+
esac
|
|
33
|
+
done
|
|
34
|
+
|
|
35
|
+
case "$cmd_path" in
|
|
36
|
+
${r} "")
|
|
37
|
+
COMPREPLY=( $(compgen -W "${s}" -- "\${cur}") )
|
|
38
|
+
return 0
|
|
39
|
+
;;
|
|
40
|
+
esac
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
complete -F _${t}_completions ${t}
|
|
44
|
+
`};var H=t=>t.replace(/'/g,"'\\''"),ae=t=>{let e=[];for(let n of t){let o=H(n.description??`${n.name} flag`);n.takesValue===!0?(e.push(`'--${n.name}=[${o}]'`),n.short!==void 0&&e.push(`'-${n.short}=[${o}]'`)):(e.push(`'--${n.name}[${o}]'`),n.short!==void 0&&e.push(`'-${n.short}[${o}]'`))}return e},le=t=>t.map(n=>{let o=H(n.description??n.name);return`'${n.name}:${o}'`}).join(`
|
|
45
|
+
`),P=(t,e,n)=>{let s=`${n.length===0?`_${t}`:`_${t}_${n.join("_")}`}() {
|
|
46
|
+
`;if(s+=` local -a commands
|
|
47
|
+
`,s+=` local -a flags
|
|
48
|
+
|
|
49
|
+
`,e.flags!==void 0&&e.flags.length>0){let r=ae(e.flags);s+=` flags=(
|
|
50
|
+
${r.join(`
|
|
51
|
+
`)}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
`}if(e.children!==void 0&&e.children.length>0){s+=` commands=(
|
|
55
|
+
`,s+=` ${le(e.children)}
|
|
56
|
+
`,s+=` )
|
|
57
|
+
|
|
58
|
+
`,s+=` _arguments -C \\
|
|
59
|
+
`,e.flags!==void 0&&e.flags.length>0&&(s+=' "${flags[@]}" \\\n'),s+=` '1: :->command' \\
|
|
60
|
+
`,s+=` '*::arg:->args'
|
|
61
|
+
|
|
62
|
+
`,s+=` case "$state" in
|
|
63
|
+
`,s+=` command)
|
|
64
|
+
`,s+=` _describe -t commands 'command' commands
|
|
65
|
+
`,s+=` ;;
|
|
66
|
+
`,s+=` args)
|
|
67
|
+
`,s+=' case "${words[1]}" in\n';for(let r of e.children){let i=[...n,r.name],a=`_${t}_${i.join("_")}`;s+=` ${r.name})
|
|
68
|
+
`,s+=` ${a}
|
|
69
|
+
`,s+=` ;;
|
|
70
|
+
`}s+=` esac
|
|
71
|
+
`,s+=` ;;
|
|
72
|
+
`,s+=` esac
|
|
73
|
+
`}else e.flags!==void 0&&e.flags.length>0&&(s+=' _arguments "${flags[@]}"\n');if(s+=`}
|
|
74
|
+
|
|
75
|
+
`,e.children!==void 0)for(let r of e.children)s+=P(t,r,[...n,r.name]);return s},j=(t,e)=>{let n=`#compdef ${t}
|
|
76
|
+
`;return n+=`# ${t} zsh completion
|
|
77
|
+
`,n+=`# Generated by @eserstack/shell/completions
|
|
78
|
+
|
|
79
|
+
`,n+=P(t,e,[]),n};var z=t=>t.replace(/[\\'"$`(){}|&;<>#~*?!\^]/g,"\\$&"),de=(t,e,n)=>{let o="";for(let s of e){let r=z(s.description??`${s.name} flag`),i=`complete -c ${t} ${n}`;i+=` -l ${s.name}`,s.short!==void 0&&(i+=` -s ${s.short}`),s.takesValue===!0&&(i+=" -r"),i+=` -d '${r}'`,o+=i+`
|
|
80
|
+
`}return o},G=(t,e,n)=>{let o="",s;if(n.length===0?s="-n __fish_use_subcommand":s=`-n "${n.map(i=>`__fish_seen_subcommand_from ${i}`).join("; and ")}"`,e.children!==void 0&&e.children.length>0){for(let r of e.children){let i=z(r.description??r.name);if(n.length===0)o+=`complete -c ${t} -f ${s} `,o+=`-a "${r.name}" -d '${i}'
|
|
81
|
+
`;else{let a=`-n "__fish_seen_subcommand_from ${n[n.length-1]}"`;o+=`complete -c ${t} -f ${a} `,o+=`-a "${r.name}" -d '${i}'
|
|
82
|
+
`}}for(let r of e.children)o+=G(t,r,[...n,r.name])}return e.flags!==void 0&&e.flags.length>0&&(o+=de(t,e.flags,s)),o},N=(t,e)=>{let n=`# ${t} fish completion
|
|
83
|
+
`;return n+=`# Generated by @eserstack/shell/completions
|
|
84
|
+
|
|
85
|
+
`,n+=`complete -c ${t} -f
|
|
86
|
+
|
|
87
|
+
`,n+=G(t,e,[]),n};var L=(t,e,n)=>{switch(t){case"bash":return S(e,n);case"zsh":return j(e,n);case"fish":return N(e,n)}};var h=class t{#e;#t;#o;#p=[];#g=[];#C=[];#m=[];#l=[];#r=new Map;#b=new Map;#i=new Map;#f=new Map;#d=new Map;#n;#h;#y;#a={validation:"none"};#c;#s;constructor(e){this.#e=e}get versionString(){return this.#c}get name(){return this.#e}description(e){return this.#t=e,this}usage(e){return this.#o=e,this}example(e){return this.#p.push(e),this}aliases(...e){return this.#g=e,this}version(e){return this.#c=e,this}flag(e){return this.#C.push(e),this}persistentFlag(e){return this.#m.push({...e,persistent:!0}),this}args(e,n){return e==="exact"&&typeof n=="number"?this.#a={validation:e,count:n}:e==="min"&&typeof n=="number"?this.#a={validation:e,min:n}:e==="max"&&typeof n=="number"?this.#a={validation:e,max:n}:e==="range"&&Array.isArray(n)?this.#a={validation:e,min:n[0],max:n[1]}:this.#a={validation:e},this}command(e){return e.#s=this,this.#l.push(e),this}commands(...e){for(let n of e)this.command(n);return this}run(e){return this.#y=e,this}lazyCommand(e,n){this.#r.set(e,n);for(let o of n.aliases??[])this.#b.set(o,e);return this}group(e,n){return this.#i.set(e,n),this}groupAlias(e,n,o){return this.#i.set(e,o),this.#f.set(e,n),this}shortcut(e,n,o){let s=n.split(/\s+/).filter(Boolean);return this.#d.set(e,{target:s,description:o}),this}modules(e){return this.#n=e,this}fallback(e){return this.#h=e,this}static#R=[{name:"help",short:"h",type:"boolean",description:"Show help for this command"}];#u(){let e=[],n=this.#s;for(;n!==void 0;)e.push(...n.#m),n=n.#s;return[...t.#R,...e,...this.#m,...this.#C]}#x(){return this.#s===void 0?this:this.#s.#x()}#O(){return this.#s===void 0?[this.#e]:[...this.#s.#O(),this.#e]}#M(e){return this.#l.find(n=>n.#e===e||n.#g.includes(e))}#A(e){let{validation:n,count:o,min:s,max:r}=this.#a,i=e.length;switch(n){case"no-args":if(i>0)return"This command takes no arguments";break;case"exact":if(i!==o)return`Expected exactly ${o} argument(s), got ${i}`;break;case"min":if(i<(s??0))return`Expected at least ${s} argument(s), got ${i}`;break;case"max":if(i>(r??1/0))return`Expected at most ${r} argument(s), got ${i}`;break;case"range":if(i<(s??0)||i>(r??1/0))return`Expected ${s}-${r} arguments, got ${i}`;break}}async parse(e){let n=e??O.process.args;return await this.#$(n,[])}async#$(e,n){let o=this.#u(),s=this.#l.length>0||this.#r.size>0||this.#i.size>0||this.#n!==void 0||this.#d.size>0,r=M(e,o,{stopEarly:s}),i=r.flags,a=r.positional;if(this.#c!==void 0&&i.version===!0)return console.log(`${this.#e} ${this.#c}`),u(void 0);if(i.help===!0)return console.log(this.help()),u(void 0);let l=a[0];if(l!==void 0&&s){if(this.#d.has(l)){let{target:g}=this.#d.get(l);return await this.#$([...g,...a.slice(1)],n)}let b=this.#M(l);if(b!==void 0)return await b.#$(a.slice(1),[...n,this.#e]);let x=this.#r.has(l)?l:this.#b.get(l);if(x!==void 0){let d=await this.#r.get(x).load();return d instanceof t?(d.#s=this,await d.parse(a.slice(1))):"parse"in d&&typeof d.parse=="function"?await d.parse(a.slice(1)):(console.log(d.help()),u(void 0))}if(this.#n!==void 0){let g=this.#n.aliases?.[l]??l,d=this.#n.modules[g];if(d!==void 0)return await(await d.load()).main(a.slice(1))}let p=this.#i.get(l);if(p!==void 0){let g=a[1];if(g===void 0||g==="--help"||g==="-h")return this.#F(l,p),u(void 0);let d=p.aliases?.[g]??g,y=p.modules[d];return y===void 0?(console.error(`Unknown module: ${l} ${g}
|
|
88
|
+
`),this.#F(l,p),m({exitCode:1})):await(await y.load()).main(a.slice(2))}if(this.#h!==void 0)return await this.#h(l,a.slice(1))}if(this.#y===void 0)return console.log(this.help()),u(void 0);let c=A(i,o);if(c.length>0)return m({message:c.join(`
|
|
89
|
+
`),exitCode:1});let C=this.#A(a);if(C!==void 0)return m({message:C,exitCode:1});let U=[...n,this.#e],W={args:a,flags:i,root:this.#x(),commandPath:U};return await this.#y(W)}#F(e,n){console.log(`${this.#e} ${e} - ${n.description}
|
|
90
|
+
`),console.log(`Usage: ${this.#e} ${e} <module> [options]
|
|
91
|
+
`);let o=new Map;for(let[s,r]of Object.entries(n.modules)){let i=r.category??"Modules",a=o.get(i)??[];a.push([s,r]),o.set(i,a)}for(let[s,r]of o){console.log(`${s}:`);for(let[i,a]of r)console.log(` ${i.padEnd(24)} ${a.description}`);console.log()}if(n.aliases!==void 0&&Object.keys(n.aliases).length>0){console.log("Aliases:");for(let[s,r]of Object.entries(n.aliases))console.log(` ${s.padEnd(24)} \u2192 ${r}`)}}help(){let e=[...this.#l.map(s=>({name:s.#e,aliases:s.#g.length>0?s.#g:void 0,description:s.#t,usage:s.#o,examples:s.#p,flags:s.#u(),children:[]})),...[...this.#r.entries()].map(([s,r])=>({name:s,aliases:r.aliases!==void 0&&r.aliases.length>0?[...r.aliases]:void 0,description:r.description,flags:[],children:[]})),...this.#n!==void 0?Object.entries(this.#n.modules).map(([s,r])=>({name:s,description:r.description,flags:r.flags??[],children:[]})):[],...[...this.#i.entries()].filter(([s])=>!this.#f.has(s)).map(([s,r])=>{let i=[...this.#f.entries()].filter(([a,l])=>l===s).map(([a])=>a);return{name:s,aliases:i.length>0?i:void 0,description:r.description,flags:[],children:[]}})],n=[...this.#d.entries()].map(([s,r])=>({name:s,target:r.target,description:r.description})),o={name:this.#e,description:this.#t,usage:this.#o,examples:this.#p,flags:this.#u(),children:e,shortcuts:n.length>0?n:void 0};return _(o,this.#O())}#_(){let e=o=>o.map(s=>({name:s.name,short:s.short,description:s.description,takesValue:s.type!=="boolean"})),n=o=>{let s=o.#l.map(n);for(let[r,i]of o.#r)s.push({name:r,description:i.description,children:[],flags:[]});if(o.#n!==void 0)for(let[r,i]of Object.entries(o.#n.modules))s.push({name:r,description:i.description,children:[],flags:i.flags!==void 0?e(i.flags):[]});for(let[r,i]of o.#i){let a=Object.entries(i.modules).map(([l,c])=>({name:l,description:c.description,children:[],flags:c.flags!==void 0?e(c.flags):[]}));s.push({name:r,description:i.description,children:a,flags:[]})}return{name:o.#e,description:o.#t,children:s,flags:e(o.#u())}};return n(this)}completions(e){let n=this.#_();return L(e,this.#e,n)}};var v=class{description;#e;#t;#o=[];constructor(e){this.description=e.description,this.#e=e.modules??{},this.#t=e.aliases??{}}addSubmodule(e,n){return this.#o.push({registration:e,module:n}),this}async addSubmoduleAsync(e,n){let o=await n;return this.#o.push({registration:e,module:o}),this}toGroupOptions(){return{description:this.description,modules:this.#e,aliases:Object.keys(this.#t).length>0?this.#t:void 0}}toCommand(e,n){let o=new h(e).description(this.description);n!==void 0&&o.version(n),Object.keys(this.#e).length>0&&o.modules(this.toGroupOptions());for(let{registration:s,module:r}of this.#o){let i=r.toGroupOptions();if(o.group(s.name,i),s.aliases!==void 0)for(let a of s.aliases)o.groupAlias(a,s.name,i)}return o}};export{v as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{d as Xt}from"./chunk-HISXAZ4Y.js";var it={};Xt(it,{AlreadyExistsError:()=>re,NotFoundError:()=>$,PermissionDeniedError:()=>B,ProcessError:()=>G,RuntimeCapabilityError:()=>P,buildCommand:()=>Re,clearWorkerdEnv:()=>dt,createRuntime:()=>sn,detectExecutionContext:()=>Ee,detectInvoker:()=>xe,detectRuntime:()=>C,getArch:()=>ye,getCliPrefix:()=>ot,getHomedir:()=>ge,getPlatform:()=>W,getPlatformInfo:()=>Qe,getRuntimeVersion:()=>Ke,getTmpdir:()=>be,isBrowser:()=>Ye,isCommandInPath:()=>Pe,isEdge:()=>Ze,isRuntime:()=>Xe,isServer:()=>Je,matchCliPrefix:()=>st,populateEnvFromContext:()=>at,posixPath:()=>F,resolvePathDirs:()=>Se,runtime:()=>E,toPosix:()=>$e});var P=class extends Error{capability;runtimeName;constructor(t,r){super(`Capability "${t}" is not available on runtime "${r}"`),this.name="RuntimeCapabilityError",this.capability=t,this.runtimeName=r}},$=class extends Error{path;constructor(t){super(`No such file or directory: ${t}`),this.name="NotFoundError",this.path=t}},re=class extends Error{path;constructor(t){super(`File or directory already exists: ${t}`),this.name="AlreadyExistsError",this.path=t}},B=class extends Error{path;constructor(t,r){super(`Permission denied: ${t}`,r),this.name="PermissionDeniedError",this.path=t}},G=class extends Error{cmd;code;stderr;constructor(t,r,n){super(`Command "${t}" failed with exit code ${r}: ${n}`),this.name="ProcessError",this.cmd=t,this.code=r,this.stderr=n}};var j=e=>e.replace(/\\/g,"/").replace(/\/+/g,"/"),$e=e=>j(e),Yt=(...e)=>{if(e.length===0)return".";let t=e.filter(r=>r.length>0).join("/");return t.length===0?".":ue(t)},le=(...e)=>{let t="",r=!1;for(let n=e.length-1;n>=0&&!r;n--){let s=e[n];s===void 0||s.length===0||(t=`${s}/${t}`,r=je(s))}return t=j(t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),ue(t)??"."},Be=e=>{if(e.length===0)return".";for(e=j(e);e.length>1&&e.endsWith("/");)e=e.slice(0,-1);let t=e.lastIndexOf("/");return t===-1?".":t===0?"/":e.slice(0,t)},ce=(e,t)=>{if(e.length===0)return"";for(e=j(e);e.length>1&&e.endsWith("/");)e=e.slice(0,-1);let r=e.lastIndexOf("/"),n=r===-1?e:e.slice(r+1);return t&&n.endsWith(t)&&(n=n.slice(0,-t.length)),n},Ge=e=>{let t=ce(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?"":t.slice(r)},ue=e=>{if(e.length===0)return".";e=j(e);let t=e.startsWith("/"),r=e.endsWith("/"),n=e.split("/").filter(o=>o.length>0),s=[];for(let o of n)o!=="."&&(o===".."?s.length>0&&s[s.length-1]!==".."?s.pop():t||s.push(".."):s.push(o));let i=s.join("/");return t&&(i=`/${i}`),r&&i.length>1&&(i+="/"),i??"."},je=e=>e.length===0?!1:!!(e.startsWith("/")||e.length>=3&&/^[a-zA-Z]:[/\\]/.test(e)),Jt=(e,t)=>{if(e===t||(e=le(e),t=le(t),e===t))return"";let r=e.split("/").filter(d=>d.length>0),n=t.split("/").filter(d=>d.length>0),s=0,i=Math.min(r.length,n.length);for(let d=0;d<i&&r[d]===n[d];d++)s++;let o=r.length-s,a=n.slice(s);return[...Array(o).fill(".."),...a].join("/")??"."},Zt=e=>{if(e.length===0)return{root:"",dir:"",base:"",ext:"",name:""};e=j(e);let t="",r="",n=ce(e),s=Ge(e),i=s?n.slice(0,-s.length):n;return e.startsWith("/")?t="/":/^[a-zA-Z]:[/\\]/.test(e)&&(t=e.slice(0,3)),r=Be(e),r==="."&&(r=""),{root:t,dir:r,base:n,ext:s,name:i}},Qt=e=>{let{root:t="",dir:r,base:n,ext:s="",name:i=""}=e,o=n??i+s;return r?r===t?`${r}${o}`:`${r}/${o}`:`${t}${o}`},F={join:Yt,resolve:le,dirname:Be,basename:ce,extname:Ge,normalize:ue,isAbsolute:je,relative:Jt,parse:Zt,format:Qt,sep:"/",delimiter:":"};var er=e=>{let t=globalThis.process;if(t?.env)return t.env[e]},fe=(...e)=>{for(let t of e){let r=er(t);if(r!==void 0)return r}},qe=e=>{try{let t=globalThis.require;if(t instanceof Function)return t(e)}catch{}},he=(e,t)=>{let r=Reflect.get(e,t);return typeof r=="string"?r:void 0},tr=e=>e instanceof Object?{platform:he(e,"platform"),arch:he(e,"arch")}:null,rr=e=>e instanceof Object?{userAgent:he(e,"userAgent")}:null,ze=()=>tr(Reflect.get(globalThis,"process")),Ve=()=>rr(Reflect.get(globalThis,"navigator")),O=globalThis,nr=()=>typeof O.caches<"u"&&typeof O.Request<"u"&&typeof O.Response<"u"&&typeof O.window>"u"&&typeof O.document>"u",sr=()=>typeof O.window<"u"||typeof O.document<"u",C=()=>typeof globalThis>"u"?"unknown":typeof O.process?.versions?.node=="string"?"node":nr()?"workerd":sr()?"browser":"unknown",or={node:()=>O.process?.versions?.node??"unknown",workerd:()=>"unknown",browser:()=>O.navigator?.userAgent??"unknown",unknown:()=>"unknown"},Ke=()=>or[C()](),Xe=e=>C()===e,Ye=()=>C()==="browser",ir=new Set(["node"]),Je=()=>ir.has(C()),Ze=()=>C()==="workerd",ar={darwin:"darwin",linux:"linux",windows:"windows",win32:"windows"},W=()=>{let e=ze();if(e?.platform!==void 0)return ar[e.platform]??"linux";let t=Ve();if(t?.userAgent!==void 0){let r=t.userAgent.toLowerCase();if(r.includes("mac"))return"darwin";if(r.includes("win"))return"windows";if(r.includes("linux"))return"linux"}return"linux"},dr={x86_64:"amd64",x64:"amd64",aarch64:"arm64",arm64:"arm64"},ye=()=>{let e=ze();if(e?.arch!==void 0)return dr[e.arch]??"amd64";let t=Ve();if(t?.userAgent!==void 0){let r=t.userAgent.toLowerCase();if(r.includes("arm64")||r.includes("aarch64"))return"arm64"}return"amd64"},ge=()=>{let e=fe("HOME","USERPROFILE");if(e)return e;let t=qe("os");return t?.homedir?t.homedir():W()==="windows"?"C:\\Users\\Default":"/home"},be=()=>{let e=W()==="windows",t=e?fe("TMP","TEMP","TMPDIR"):fe("TMPDIR","TMP","TEMP");if(t)return t;let r=qe("os");return r?.tmpdir?r.tmpdir():e?"C:\\Windows\\Temp":"/tmp"},Qe=()=>({platform:W(),arch:ye(),homedir:ge(),tmpdir:be()}),me=e=>e==="inherit"?"inherit":e==="piped"?"pipe":"ignore",lr=e=>({stdin:e?.stdin??"null",stdout:e?.stdout??"piped",stderr:e?.stderr??"piped"}),we=e=>{let t=lr(e);return[me(t.stdin),me(t.stdout),me(t.stderr)]},et=(e,t)=>{let r={spawn:e,spawnChild:t,async exec(n,s,i){let o=await e(n,s,i);if(!o.success){let a=new TextDecoder().decode(o.stderr);throw new G(n,o.code,a)}return new TextDecoder().decode(o.stdout).trim()},async execJson(n,s,i){let o=await r.exec(n,s,i);return JSON.parse(o)}};return r},tt="127.0.0.1",rt=e=>async(t,r)=>{try{return await e(t,r)}catch(n){let{pathname:s}=new URL(t.url);return N(`the handler threw for ${t.method} ${s}; the client got a 500 response.`,n),new Response("Internal Server Error",{status:500})}},N=(e,t)=>{console.error(`runtime.http.serve: ${e}`,t)},ne=(e,t)=>()=>{throw new P(e,t)},K=e=>{let t=ne("fs",e);return{readFile:t,readTextFile:t,writeFile:t,writeTextFile:t,exists:t,stat:t,statSync:t,lstat:t,mkdir:t,ensureDir:t,remove:t,readDir:t,copyFile:t,rename:t,makeTempDir:t,realPath:t,watch:t,walk:t,chmod:t}},X=e=>{let t=ne("exec",e);return{spawn:t,exec:t,execJson:t,spawnChild:t}},Y=e=>{let t=ne("process",e);return{exit:t,setExitCode:t,cwd:t,chdir:t,hostname:t,execPath:t,isStandalone:!1,isAlive:()=>!1,addSignalListener:t,removeSignalListener:t,get argv(){throw new P("process",e)},get argv0(){throw new P("process",e)},get args(){throw new P("process",e)},get pid(){throw new P("process",e)},get stdin(){throw new P("process",e)},get stdout(){throw new P("process",e)},get stderr(){throw new P("process",e)},isTerminal(){return!1},setStdinRaw(){throw new P("process",e)},writeToStdout(){throw new P("process",e)},consoleSize(){return{columns:80,rows:24}}}},J=e=>{let t=ne("http",e);return{serve:t,upgradeWebSocket:t}},ve=()=>({get:()=>{},set:()=>{},delete:()=>{},has:()=>!1,toObject:()=>({})}),nt=e=>({name:e,version:"unknown",capabilities:{fs:!1,fsSync:!1,exec:!1,process:!1,env:!1,stdin:!1,stdout:!1,http:!1},fs:K(e),path:F,exec:X(e),env:ve(),process:Y(e),http:J(e)});var Se=(e,t)=>{let r=t==="windows"?";":":";return e.split(r).filter(n=>n.length>0)},se=new Set(["node"]),xe=(e,t,r,n,s)=>{let i=se.has(e)?e:t;if(!se.has(i))return{invoker:"binary",mode:"installed"};if(i==="node"){if(s===!0)return{invoker:"dev",mode:"dev"};let o=r[1]??"";if(o.includes("_npx")||o.includes("/npx"))return{invoker:"npx",mode:"on-demand"};if(o.includes("pnpm")||o.includes("pnpx"))return{invoker:"pnpx",mode:"on-demand"};let a=n.npm_execpath??"";return a.includes("npx")?{invoker:"npx",mode:"on-demand"}:a.includes("pnpm")?{invoker:"pnpx",mode:"on-demand"}:(n.npm_config_user_agent??"").includes("pnpm")?{invoker:"pnpm",mode:"installed"}:{invoker:"npm",mode:"installed"}}return{invoker:"unknown",mode:"installed"}},Re=(e,t,r)=>e==="npx"?`npx ${r.npmPackage}`:e==="pnpx"?`pnpx ${r.npmPackage}`:e==="dev"?r.devCommand:r.command,cr=async e=>{try{let t=await E.fs.readTextFile(E.path.join(e,"package.json")),r=JSON.parse(t);if(!(r instanceof Object))return!1;let n=Reflect.get(r,"scripts");return n instanceof Object&&"cli"in n}catch{return!1}},Pe=async e=>{let t=W(),r=t==="windows"?`${e}.exe`:e,n=E.env.get("PATH")??"",s=Se(n,t);for(let i of s)try{return await E.fs.stat(E.path.join(i,r)),!0}catch{continue}return!1},st=(e,t)=>{for(let r of e){let n=t.indexOf(r);if(n>=0)return t.slice(0,n+1).join(" ");let s=t.findIndex(i=>i.endsWith(`/${r}`)||i.endsWith(`\\${r}`)||i.includes(`:${r}`));if(s>=0)return t.slice(0,s+1).join(" ")}},ot=async(e,t)=>{let r=await Ee(e),n=E.process.argv;for(let s of t){if(n.includes(s))return`${r.command} ${s}`;if(n.some(o=>o.endsWith(`/${s}`)||o.endsWith(`\\${s}`)||o.includes(`:${s}`)))return r.command}},Ee=async e=>{let t=E.path.basename(E.process.execPath()),r=E.process.isStandalone?"compiled":C(),n=E.process.argv,s=import.meta.url,i=se.has(t)?t:r,o={npm_execpath:E.env.get("npm_execpath"),npm_config_user_agent:E.env.get("npm_config_user_agent")},a=!1;i==="node"&&s.startsWith("file://")&&(a=await cr(E.process.cwd()));let{invoker:l,mode:d}=xe(t,r,n,o,a),f=se.has(i)?i:"compiled",x=Re(l,d,e),u=await Pe(e.command);return{runtime:f,mode:d,invoker:l,command:x,isInPath:u}};var ur={fs:!1,fsSync:!1,exec:!1,process:!1,env:!0,stdin:!1,stdout:!1,http:!1},M=new Map,pr=()=>({get(e){return M.get(e)},set(e,t){M.set(e,t)},delete(e){M.delete(e)},has(e){return M.has(e)},toObject(){return Object.fromEntries(M)}}),at=e=>{for(let[t,r]of Object.entries(e))r!=null&&r.constructor===String&&M.set(t,r)},dt=()=>{M.clear()},lt=()=>({name:"workerd",version:"unknown",capabilities:ur,fs:K("workerd"),path:F,exec:X("workerd"),env:pr(),process:Y("workerd"),http:J("workerd")});var fr={fs:!1,fsSync:!1,exec:!1,process:!1,env:!1,stdin:!1,stdout:!1,http:!1},ct=()=>({name:"browser",version:globalThis.navigator?.userAgent??"unknown",capabilities:fr,fs:K("browser"),path:F,exec:X("browser"),env:ve(),process:Y("browser"),http:J("browser")});import*as Z from"node:buffer";import*as ke from"node:child_process";import*as ut from"node:crypto";import*as Ae from"node:fs";import*as y from"node:fs/promises";import*as Ce from"node:http";import*as Q from"node:net";import*as Oe from"node:os";import*as pt from"node:sea";import{default as v}from"node:path";import{default as T}from"node:stream";import{default as p}from"node:process";var yr=new TextEncoder,ie=class e extends EventTarget{CONNECTING=0;OPEN=1;CLOSING=2;CLOSED=3;binaryType="arraybuffer";bufferedAmount=0;extensions="";protocol="";readyState=0;url;onclose=null;onerror=null;onmessage=null;onopen=null;#t;#e=null;#r={code:null,reason:""};static create(t,r){let n=new e(t,r);return{socket:n,events:{opened:()=>n.#n(),received:s=>n.#s(s),drained:()=>{n.bufferedAmount=0},failed:()=>n.#o(),closed:(s,i,o)=>n.#i(s,i,o)}}}constructor(t,r){super(),this.url=t,this.#t=r,this.addEventListener("open",n=>this.onopen?.call(this,n)),this.addEventListener("error",n=>this.onerror?.call(this,n)),this.addEventListener("message",n=>{n instanceof MessageEvent&&this.onmessage?.call(this,n)}),this.addEventListener("close",n=>{n instanceof CloseEvent&&this.onclose?.call(this,n)})}send(t){if(this.readyState===0)throw new DOMException("WebSocket send: the socket is still connecting; send after its open event","InvalidStateError");if(this.readyState!==1)return;if(this.#e===null&&!(t instanceof Blob)){this.bufferedAmount=this.#t.send(mt(t));return}let r=(this.#e??Promise.resolve()).then(async()=>{let n=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):mt(t);this.readyState===1&&(this.bufferedAmount=this.#t.send(n))});this.#e=r,r.then(()=>{this.#e===r&&(this.#e=null)},()=>{this.#e===r&&(this.#e=null),this.readyState===1&&(this.readyState=2,this.dispatchEvent(new Event("error")),this.#t.close(1011,""))})}close(t,r){if(t!==void 0&&t!==1e3&&(t<3e3||t>4999))throw new DOMException(`WebSocket close: code ${t} is reserved; use 1000 or a code from 3000 to 4999`,"InvalidAccessError");let n=r??"";if(yr.encode(n).byteLength>123)throw new DOMException("WebSocket close: the reason is longer than 123 bytes of UTF-8","SyntaxError");if(this.readyState===2||this.readyState===3)return;let s=this.readyState===0;this.readyState=2,this.#r={code:t??null,reason:n},s||this.#t.close(this.#r.code,this.#r.reason)}#n(){if(this.readyState===2){this.#t.close(this.#r.code,this.#r.reason);return}this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event("open")))}#s(t){this.readyState===1&&this.dispatchEvent(new MessageEvent("message",{data:this.#a(t)}))}#o(){this.readyState!==3&&this.dispatchEvent(new Event("error"))}#i(t,r,n){this.readyState!==3&&(this.readyState=3,this.dispatchEvent(new CloseEvent("close",{code:t,reason:r,wasClean:n})))}#a(t){if(typeof t=="string")return t;let r=new Uint8Array(t);return this.binaryType==="arraybuffer"?r.buffer:new Blob([r])}},mt=e=>typeof e=="string"?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),ht=e=>{let t=s=>{throw new TypeError(`runtime.http.upgradeWebSocket: ${s}; a WebSocket handshake is a GET request with "Upgrade: websocket", "Connection: Upgrade", "Sec-WebSocket-Version: 13" and a Sec-WebSocket-Key`)};e.method!=="GET"&&t(`the request method is ${e.method}`),ft(e.headers.get("upgrade"),"websocket")||t(`the Upgrade header is "${e.headers.get("upgrade")??""}"`),ft(e.headers.get("connection"),"upgrade")||t(`the Connection header is "${e.headers.get("connection")??""}"`);let r=e.headers.get("sec-websocket-version");r!=="13"&&t(`the Sec-WebSocket-Version header is "${r??""}"`);let n=e.headers.get("sec-websocket-key")?.trim()??"";return/^[A-Za-z0-9+/]{22}==$/.test(n)||t(`the Sec-WebSocket-Key header "${n}" is not 16 bytes in base64`),n},ft=(e,t)=>e!==null&&e.split(",").some(r=>r.trim().toLowerCase()===t),yt=e=>{let t=new URL(e);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.href};var ee="unix:",br=/^(?:\[[0-9a-f:.]+\]|[a-z0-9.-]+)(?::\d{1,5})?$/i,Fe=e=>{switch(Q.isIP(e)){case 4:return"ipv4";case 6:return"ipv6";default:return null}},gt=e=>new TypeError(`runtime.http.serve: trustProxy entry "${e}" is not valid; use an IP address, a CIDR such as "10.0.0.0/8", or "${ee}" for a unix socket peer`),bt=e=>{let t=new Q.BlockList,r=!1;for(let n of e){if(n===ee){r=!0;continue}let[s,i,...o]=n.split("/"),a=Fe(s??"");if(a===null||o.length>0)throw gt(n);if(i===void 0){t.addAddress(s,a);continue}let l=/^\d{1,3}$/.test(i)?Number(i):-1;if(l<0||l>(a==="ipv4"?32:128))throw gt(n);t.addSubnet(s,l,a)}return{addresses:t,unixPeers:r}},wt=(e,t)=>{let r=Fe(t);return r!==null&&e.addresses.check(t,r)},wr=(e,t)=>{let r=t.split(",").map(s=>s.trim()),n=null;for(let s=r.length-1;s>=0;s-=1){let i=r[s];if(Fe(i)===null||(n=i,!wt(e,i)))return n}return n},vt=e=>e.slice(e.lastIndexOf(",")+1).trim(),vr=e=>{let t=vt(e).toLowerCase();return t==="http"||t==="https"?t:null},Sr=e=>{let t=vt(e);return br.test(t)&&URL.canParse(`http://${t}`)?t:null},Te=e=>e===void 0?null:typeof e=="string"?e:e.join(","),St=(e,t,r)=>{if(!(t===ee?e.unixPeers:t!==null&&wt(e,t)))return null;let s=Te(r["x-forwarded-for"]),i=Te(r["x-forwarded-proto"]),o=Te(r["x-forwarded-host"]);return{clientAddress:s!==null?wr(e,s):null,protocol:i!==null?vr(i):null,host:o!==null?Sr(o):null}};var A={continuation:0,text:1,binary:2,close:8,ping:9,pong:10},g={normal:1e3,goingAway:1001,protocolError:1002,noStatus:1005,abnormal:1006,invalidData:1007,messageTooBig:1009},S=class extends Error{code;constructor(t,r,n){super(r,n),this.name="WebSocketProtocolError",this.code=t}},Rt=new TextEncoder,Rr=new TextDecoder("utf-8",{fatal:!0}),Pr=125,z=(e,t)=>{let r=t.byteLength,n=10;r<126?n=2:r<65536&&(n=4);let s=new Uint8Array(n+r),i=new DataView(s.buffer);return s[0]=128|e,n===2?s[1]=r:n===4?(s[1]=126,i.setUint16(2,r)):(s[1]=127,i.setBigUint64(2,BigInt(r))),s.set(t,n),s},Pt=e=>typeof e=="string"?z(A.text,Rt.encode(e)):z(A.binary,e),Et=(e,t)=>{if(e===null)return z(A.close,new Uint8Array(0));let r=Rt.encode(t),n=new Uint8Array(2+r.byteLength);return new DataView(n.buffer).setUint16(0,e),n.set(r,2),z(A.close,n)},kt=e=>{if(e.byteLength===0)return{code:g.noStatus,reason:""};if(e.byteLength===1)throw new S(g.protocolError,"close frame payload is 1 byte; it must be empty or start with a 2-byte status code");let t=new DataView(e.buffer,e.byteOffset).getUint16(0);if(!Er(t))throw new S(g.protocolError,`close frame carries status code ${t}, which a peer may not send`);return{code:t,reason:At(e.subarray(2))}},Er=e=>e>=1e3&&e<=1003||e>=1007&&e<=1011||e>=3e3&&e<=4999,At=e=>{try{return Rr.decode(e)}catch(t){throw new S(g.invalidData,"text is not valid UTF-8",{cause:t})}},Ct=e=>{let t=new Uint8Array(14),r=0,n=null;return{push(s){let i=[],o=0;for(;o<s.byteLength;){if(n===null){let a=xt(t,r),l=Math.min(a-r,s.byteLength-o),d=r;if(t.set(s.subarray(o,o+l),r),r+=l,o+=l,d<2&&r>=2&&kr(t),r<xt(t,r))continue;n=Ar(t,e),r=0}else{let a=Math.min(n.payload.byteLength-n.filled,s.byteLength-o);n.payload.set(s.subarray(o,o+a),n.filled),n.filled+=a,o+=a}n.filled===n.payload.byteLength&&(i.push(Cr(n)),n=null)}return i}}},xt=(e,t)=>{if(t<2)return 2;let r=new DataView(e.buffer,e.byteOffset).getUint8(1)&127;return r===126?8:r===127?14:6},kr=e=>{let t=new DataView(e.buffer,e.byteOffset),r=t.getUint8(0),n=t.getUint8(1),s=r&15;if((r&112)!==0)throw new S(g.protocolError,"frame sets a reserved bit, but no extension was negotiated");if(!Or.has(s))throw new S(g.protocolError,`frame has unknown opcode 0x${s.toString(16)}`);if((n&128)===0)throw new S(g.protocolError,"client frame is not masked; RFC 6455 requires clients to mask every frame");let i=(r&128)!==0,o=n&127;if(s>=A.close&&(!i||o>Pr))throw new S(g.protocolError,"control frame is fragmented or longer than 125 bytes")},Ar=(e,t)=>{let r=new DataView(e.buffer,e.byteOffset),n=r.getUint8(0),s=r.getUint8(1),i=(n&128)!==0,o=n&15,a=s&127,l=a,d=2;if(a===126)l=r.getUint16(2),d=4;else if(a===127){let f=r.getBigUint64(2);if(f>BigInt(t))throw new S(g.messageTooBig,`frame payload is ${f} bytes; the limit is ${t}`);l=Number(f),d=10}if(l>t)throw new S(g.messageTooBig,`frame payload is ${l} bytes; the limit is ${t}`);return{fin:i,opcode:o,mask:e.slice(d,d+4),payload:new Uint8Array(l),filled:0}},Cr=e=>{let{payload:t,mask:r}=e;for(let[n,s]of t.entries())t[n]=s^r[n%4];return{fin:e.fin,opcode:e.opcode,payload:t}},Or=new Set(Object.values(A)),Ot=e=>{let t=null,r=[],n=0,s=(i,o)=>i===A.text?At(o):o;return{push(i){if(i.opcode===A.continuation){if(t===null)throw new S(g.protocolError,"continuation frame arrived with no fragmented message to continue")}else{if(t!==null)throw new S(g.protocolError,"a new message started before the fragmented one finished");if(i.fin)return s(i.opcode,i.payload);t=i.opcode}if(n+=i.payload.byteLength,n>e)throw new S(g.messageTooBig,`message is over ${e} bytes`);if(r.push(i.payload),!i.fin)return null;let o=new Uint8Array(n),a=0;for(let d of r)o.set(d,a),a+=d.byteLength;let l=t;return t=null,r=[],n=0,s(l,o)}}};var Tt=16*1024*1024,Fr=5e3,Ir=1e4,Ur=3e4,Wr=50,Nr="localhost",Mr={IPv4:"::1",IPv6:"127.0.0.1"},Lr=new Set(["EADDRNOTAVAIL","EAFNOSUPPORT"]),Dr="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",Hr=new Set(["connection","content-length","keep-alive","transfer-encoding"]),_r=new TextEncoder,Ft=(e,t,r)=>t!==null&&t.clientAddress!==null?{remoteAddr:{hostname:t.clientAddress,port:0},signal:r}:{remoteAddr:e.remoteAddress!==void 0&&e.remotePort!==void 0?{hostname:e.remoteAddress,port:e.remotePort}:null,signal:r},ae=(e,t)=>{if(!Number.isSafeInteger(t)||t<0)throw new TypeError(`runtime.http.serve: ${e} must be a whole number of milliseconds, 0 or more, got ${t}`);return t},$r=e=>{let t={},r=[];e.headersTimeoutMs!==void 0&&(t.headersTimeout=ae("headersTimeoutMs",e.headersTimeoutMs),r.push(t.headersTimeout)),e.requestTimeoutMs!==void 0&&(t.requestTimeout=ae("requestTimeoutMs",e.requestTimeoutMs),r.push(t.requestTimeout)),e.keepAliveTimeoutMs!==void 0&&(t.keepAliveTimeout=ae("keepAliveTimeoutMs",e.keepAliveTimeoutMs));let n=r.filter(s=>s>0);return n.length>0&&(t.connectionsCheckingInterval=Math.min(Ur,Math.max(Wr,Math.ceil(Math.min(...n)/2)))),t},Br=e=>ut.createHash("sha1").update(e+Dr).digest("base64"),It=(e,t)=>{let r=e.statusText!==""?e.statusText:Ce.STATUS_CODES[e.status]??"",n=[`HTTP/1.1 ${e.status} ${r}`];for(let[o,a]of e.headers)Hr.has(o)||n.push(`${o}: ${a}`);n.push(`content-length: ${t.byteLength}`,"connection: close","","");let s=_r.encode(n.join(`\r
|
|
2
|
+
`)),i=new Uint8Array(s.byteLength+t.byteLength);return i.set(s,0),i.set(t,s.byteLength),i},Gr=(e,t)=>{let r=new URL(`http://${t}`);if(!e.startsWith("/"))return new URL(e,r);let n=new URL(`http://target.invalid${e}`);return r.pathname=n.pathname,r.search=n.search,r.hash=n.hash,r},Ut=(e,t,r,n)=>{let s=e.method??"GET",i=s!=="GET"&&s!=="HEAD";try{let o=Gr(e.url??"/",e.headers.host??t),a=n?.protocol??null;a!==null&&(o.protocol=a);let l=n?.host??null;if(l!==null){let u=new URL(`${o.protocol}//${l}`);o.hostname=u.hostname,o.port=u.port}let d=new Headers,f=e.rawHeaders;for(let u=0;u+1<f.length;u+=2)d.append(f[u],f[u+1]);let x={method:s,headers:d,signal:r,body:i?T.Readable.toWeb(e):null,duplex:"half"};return new Request(o,x)}catch(o){if(o instanceof TypeError)return null;throw o}},jr=e=>new Promise(t=>{let r=()=>{e.off("drain",r),e.off("close",r),t()};e.on("drain",r),e.on("close",r)}),qr=async(e,t)=>{if(e.destroyed){await t.body?.cancel();return}e.statusCode=t.status,t.statusText!==""&&(e.statusMessage=t.statusText);for(let[i,o]of t.headers)i!=="set-cookie"&&e.setHeader(i,o);let r=t.headers.getSetCookie();if(r.length>0&&e.setHeader("set-cookie",r),t.body===null){e.end();return}let n=t.body.getReader(),s=()=>{n.cancel().catch(()=>{})};e.once("close",s);try{for(;;){let{done:i,value:o}=await n.read();if(i)break;e.write(o)||await jr(e)}e.end()}catch(i){e.destroy(),N("a response body failed while streaming.",i)}finally{e.off("close",s)}},zr=(e,t,r,n)=>{let s=Ct(Tt),i=Ot(Tt),o=!1,a=null,l=!1,d=null,f=(b,h)=>{o||(o=!0,e.write(Et(b,h)),a!==null&&e.end(),d=setTimeout(()=>e.destroy(),Fr))},{socket:x,events:u}=ie.create(t,{send:b=>(o||e.write(Pt(b)),e.writableLength),close:f}),V=b=>{switch(b.opcode){case A.ping:o||e.write(z(A.pong,b.payload));return;case A.pong:return;case A.close:{let h=kt(b.payload);a=h,o?e.end():f(h.code===g.noStatus?null:h.code,"");return}default:{if(a!==null)return;let h=i.push(b);h!==null&&u.received(h)}}},L=b=>{if(!l)try{for(let h of s.push(b))V(h)}catch(h){if(!(h instanceof S))throw h;l=!0,u.failed(),f(h.code,""),e.end()}},U={socket:x,start:b=>{e.write(`HTTP/1.1 101 Switching Protocols\r
|
|
3
|
+
Upgrade: websocket\r
|
|
4
|
+
Connection: Upgrade\r
|
|
5
|
+
Sec-WebSocket-Accept: ${Br(r)}\r
|
|
6
|
+
\r
|
|
7
|
+
`),e.on("data",L),e.on("drain",()=>u.drained()),e.on("end",()=>e.end()),e.on("close",()=>{d!==null&&clearTimeout(d),l||a===null?u.closed(g.abnormal,"",!1):u.closed(a.code,a.reason,o),n(U)}),u.opened(),b.byteLength>0&&L(b)},abandon:()=>{u.closed(g.abnormal,"",!1)},shutdown:()=>{f(g.goingAway,""),e.end()},destroy:()=>{e.destroy()}};return U},Wt=()=>{let e=new WeakMap;return{serve:(n,s)=>new Promise((i,o)=>{let a=rt(s),l=n.hostname??tt,d=n.unixSocket??null;if(d==="")throw new TypeError("runtime.http.serve: unixSocket is empty; pass the socket's path, or leave it out to listen on a TCP port");let f=ae("shutdownTimeoutMs",n.shutdownTimeoutMs??Ir),x=n.trustProxy!==void 0?bt(n.trustProxy):null,u=Ce.createServer($r(n)),V=null,L=new Set,U=new Set,b=d!==null?Nr:l,h=!1,We=new Promise(m=>{u.once("close",()=>m())}),Ne=Promise.resolve(),Gt=We.then(()=>Ne),jt=()=>{u.closeAllConnections();for(let m of U)m.destroy()},D=()=>{if(h)return;h=!0;let m=setTimeout(jt,f);u.once("close",()=>clearTimeout(m)),u.close(),V?.listening===!0&&V.close(),u.closeIdleConnections();for(let c of L)c.destroy();for(let c of U)c.shutdown()},Me=(m,c)=>{if(x===null)return null;let w=d!==null?ee:c.remoteAddress??null;return St(x,w,m.headers)},qt=async(m,c)=>{let w=new AbortController;c.once("close",()=>{c.writableFinished||w.abort()}),c.once("finish",()=>{h&&u.closeIdleConnections()});let k=Me(m,m.socket),R=Ut(m,b,w.signal,k);if(R===null){c.writeHead(400,{"content-type":"text/plain"}),c.end("Bad Request: the URL or a header is malformed");return}let H=await a(R,Ft(m.socket,k,w.signal));h&&!c.headersSent&&c.setHeader("connection","close"),await qr(c,H)},zt=async(m,c,w)=>{let k=new AbortController;c.once("close",()=>k.abort());let R=Me(m,c),H=Ut(m,b,k.signal,R);if(H===null){c.end(It(new Response(null,{status:400}),new Uint8Array(0)));return}let He={socket:c,connections:U,accepted:null};e.set(H,He),L.add(c);let te;try{te=await a(H,Ft(c,R,k.signal))}finally{e.delete(H),L.delete(c)}let _=He.accepted;if(_!==null&&_.response===te){if(c.destroyed){_.connection.abandon();return}U.add(_.connection),_.connection.start(w);return}_?.connection.abandon();let Kt=new Uint8Array(await te.arrayBuffer());c.end(It(te,Kt))};u.on("request",(m,c)=>{qt(m,c).catch(w=>{c.destroy(),N("answering a request failed.",w)})}),u.on("upgrade",(m,c,w)=>{c.on("error",()=>{}),zt(m,c,w).catch(k=>{c.destroy(),N("answering an upgrade request failed.",k)})});let Le=m=>{o(m)};u.once("error",Le);let De=()=>{u.off("error",Le),u.on("error",c=>{N("the server failed and stopped.",c),D()});let m={hostname:"",port:0,unixSocket:d};if(d===null){let c=u.address();if(c===null||typeof c=="string"){D(),o(new Error(`runtime.http.serve: ${l}:${n.port} did not give a TCP address`));return}m={hostname:c.address,port:c.port,unixSocket:null},b=c.family==="IPv6"?`[${c.address}]:${c.port}`:`${c.address}:${c.port}`;let w=Mr[c.family];if(l==="localhost"&&w!==void 0){Vt(w,c.port,m);return}}de(m)},Vt=(m,c,w)=>{let k=Q.createServer(R=>{u.emit("connection",R)});k.once("error",R=>{if(Lr.has(R.code??"")){de(w);return}D(),We.then(()=>o(R),()=>o(R))}),k.listen(c,m,()=>{V=k,Ne=new Promise(R=>{k.once("close",()=>R())}),k.on("error",R=>{N("the server failed and stopped.",R),D()}),de(w)})},de=m=>{n.signal?.aborted===!0?D():n.signal?.addEventListener("abort",D,{once:!0}),n.onListen?.(m),i({...m,finished:Gt})};d!==null?u.listen(d,De):u.listen(n.port,l,De)}),upgradeWebSocket:n=>{let s=ht(n),i=e.get(n);if(i===void 0)throw new TypeError("runtime.http.upgradeWebSocket: the request did not come from runtime.http.serve; pass the Request the serve handler received, not a copy, before the handler returns");if(i.accepted!==null)throw new TypeError("runtime.http.upgradeWebSocket: the request was already upgraded; call it once per request");let o=zr(i.socket,yt(n.url),s,l=>i.connections.delete(l)),a=new Response(null);return i.accepted={response:a,connection:o},{socket:o.socket,response:a}}}};var Nt=e=>{let t=null,r=()=>(t===null&&(t=e().getReader()),t);return new ReadableStream({async pull(n){let s=await r().read();if(s.done){n.close();return}n.enqueue(s.value)},async cancel(n){t!==null&&await t.cancel(n)}},{highWaterMark:0})},Ie=e=>{let t=null,r=()=>(t===null&&(t=e().getWriter()),t);return new WritableStream({async write(n){await r().write(n)},async close(){t!==null&&await t.close()},async abort(n){t!==null&&await t.abort(n)}})};var Ue=e=>({isFile:e.isFile(),isDirectory:e.isDirectory(),isSymlink:e.isSymbolicLink(),size:e.size,mtime:e.mtime,atime:e.atime,birthtime:e.birthtime,mode:e.mode}),I=(e,t)=>{if(e instanceof Error&&"code"in e){if(e.code==="ENOENT")throw new $(t);if(e.code==="EACCES"||e.code==="EPERM")throw new B(t,{cause:e})}throw e},Mt=()=>({async readFile(e,t){try{let r=await y.readFile(e,{signal:t?.signal});return new Uint8Array(r)}catch(r){return I(r,e)}},async readTextFile(e,t){try{return await y.readFile(e,{encoding:"utf-8",signal:t?.signal})}catch(r){return I(r,e)}},async writeFile(e,t,r){let n=r?.append?"a":"w";await y.writeFile(e,t,{signal:r?.signal,mode:r?.mode,flag:n})},async writeTextFile(e,t,r){let n=r?.append?"a":"w";await y.writeFile(e,t,{encoding:"utf-8",signal:r?.signal,mode:r?.mode,flag:n})},async exists(e){try{return await y.access(e),!0}catch{return!1}},async stat(e){try{let t=await y.stat(e);return Ue(t)}catch(t){return I(t,e)}},statSync(e){try{return Ue(Ae.statSync(e))}catch(t){return I(t,e)}},async lstat(e){try{let t=await y.lstat(e);return Ue(t)}catch(t){return I(t,e)}},async mkdir(e,t){await y.mkdir(e,{recursive:t?.recursive??!1,mode:t?.mode})},async ensureDir(e){await y.mkdir(e,{recursive:!0})},async remove(e,t){try{await y.rm(e,{recursive:t?.recursive??!1,force:!1})}catch(r){I(r,e)}},async*readDir(e){try{let t=await y.readdir(e,{withFileTypes:!0});for(let r of t)yield{name:r.name,isFile:r.isFile(),isDirectory:r.isDirectory(),isSymlink:r.isSymbolicLink()}}catch(t){I(t,e)}},async copyFile(e,t){await y.copyFile(e,t)},async rename(e,t){await y.rename(e,t)},async makeTempDir(e){let t=e?.dir??Oe.tmpdir(),r=e?.prefix??"",n=e?.suffix??"",s=await y.mkdtemp(v.join(t,r===""?v.sep:r));if(n!==""){let i=s+n;return await y.rename(s,i),i}return s},async realPath(e){try{return await y.realpath(e)}catch(t){return I(t,e)}},watch(e,t){let r=t?.recursive??!0,n=[],s=[],i=[],o=!1,a=l=>{o||(i.length>0?i.shift()({value:l,done:!1}):s.push(l))};for(let l of e)try{let d=Ae.watch(l,{recursive:r},(f,x)=>{x!==null&&a({kind:f==="rename"?"create":"modify",paths:[v.join(l,x)]})});n.push(d)}catch{}return{close:()=>{o=!0;for(let l of n)l.close();for(let l of i)l({value:void 0,done:!0});i=[]},[Symbol.asyncIterator]:()=>({next:()=>o?Promise.resolve({value:void 0,done:!0}):s.length>0?Promise.resolve({value:s.shift(),done:!1}):new Promise(l=>{i.push(l)})})}},async chmod(e,t){await y.chmod(e,t)},async*walk(e,t){let r=t?.includeDirs??!0,n=t?.includeFiles??!0,s=t?.exts,i=t?.skip,o=async function*(a){let l=await y.readdir(a,{withFileTypes:!0});for(let d of l){let f=v.join(a,d.name);if(i?.some(u=>u.test(f)))continue;let x=d.isSymbolicLink();if(d.isDirectory())r&&(yield{path:f,name:d.name,isFile:!1,isDirectory:!0,isSymlink:x}),yield*o(f);else if(d.isFile()||x){if(!n||s!==void 0&&!s.some(u=>d.name.endsWith(u.startsWith(".")?u:`.${u}`)))continue;yield{path:f,name:d.name,isFile:d.isFile(),isDirectory:!1,isSymlink:x}}}};yield*o(e)}}),Lt=()=>({join:v.join,resolve:v.resolve,dirname:v.dirname,basename:v.basename,extname:v.extname,normalize:v.normalize,isAbsolute:v.isAbsolute,relative:v.relative,parse:v.parse,format:v.format,sep:v.sep,delimiter:v.delimiter}),Dt=()=>({get(e){return p.env[e]},set(e,t){p.env[e]=t},delete(e){delete p.env[e]},has(e){return e in p.env},toObject(){let e={};for(let[t,r]of Object.entries(p.env))r!==void 0&&(e[t]=r);return e}}),Ht=()=>({exit(e){p.exit(e)},setExitCode(e){p.exitCode=e},cwd(){return p.cwd()},chdir(e){p.chdir(e)},hostname(){return Oe.hostname()},execPath(){return p.execPath},isStandalone:pt.isSea(),argv:p.argv,argv0:p.argv0,args:p.argv.slice(2),pid:p.pid,addSignalListener(e,t){p.on(e,t)},removeSignalListener(e,t){p.off(e,t)},isAlive(e){try{return p.kill(e,0),!0}catch(t){return t.code==="EPERM"}},stdin:Nt(()=>T.Readable.toWeb(p.stdin)),stdout:Ie(()=>T.Writable.toWeb(p.stdout)),stderr:Ie(()=>T.Writable.toWeb(p.stderr)),isTerminal(e){switch(e){case"stdin":return p.stdin.isTTY===!0;case"stdout":return p.stdout.isTTY===!0;case"stderr":return p.stderr.isTTY===!0}},setStdinRaw(e){p.stdin.setRawMode(e)},writeToStdout(e){p.stdout.write(e)},consoleSize(){return{columns:p.stdout.columns??80,rows:p.stdout.rows??24}}});var Yr={fs:!0,fsSync:!0,exec:!0,process:!0,env:!0,stdin:!0,stdout:!0,http:!0},_t=e=>e.name==="AbortError",Jr=(e,t,r)=>new Promise((n,s)=>{let i=we(r);r?.stdinText!==void 0&&(i[0]="pipe");let o=ke.spawn(e,t??[],{cwd:r?.cwd,env:r?.env!==void 0?{...p.env,...r.env}:void 0,stdio:i,signal:r?.signal});r?.stdinText!==void 0&&o.stdin!==null&&(o.stdin.on("error",()=>{}),o.stdin.end(r.stdinText));let a=[],l=[];o.stdout?.on("data",d=>a.push(d)),o.stderr?.on("data",d=>l.push(d)),o.on("error",d=>{_t(d)||s(d)}),o.on("close",d=>{n({success:d===0,code:d??1,stdout:new Uint8Array(Z.Buffer.concat(a)),stderr:new Uint8Array(Z.Buffer.concat(l))})})}),Zr=(e,t,r)=>{let n=ke.spawn(e,t??[],{cwd:r?.cwd,env:r?.env!==void 0?{...p.env,...r.env}:void 0,stdio:we(r),signal:r?.signal}),s=[],i=[];n.stdout?.on("data",a=>s.push(a)),n.stderr?.on("data",a=>i.push(a));let o=new Promise((a,l)=>{n.on("error",d=>{_t(d)||l(d)}),n.on("close",(d,f)=>{a({success:d===0,code:d??1,signal:f??void 0})})});return{pid:n.pid,stdin:n.stdin!==null?T.Writable.toWeb(n.stdin):null,stdout:n.stdout!==null?T.Readable.toWeb(n.stdout):null,stderr:n.stderr!==null?T.Readable.toWeb(n.stderr):null,status:o,output:async()=>{let a=await o;return{success:a.success,code:a.code,stdout:new Uint8Array(Z.Buffer.concat(s)),stderr:new Uint8Array(Z.Buffer.concat(i))}},kill:a=>{n.kill(a)}}},$t=()=>({name:"node",version:p.versions.node,capabilities:Yr,fs:Mt(),path:Lt(),exec:et(Jr,Zr),env:Dt(),process:Ht(),http:Wt()});var en={node:$t,workerd:lt,browser:ct},tn=["fs","exec","env","path","process","http"],rn=e=>e!==void 0&&tn.some(t=>e[t]!==void 0),nn=(e,t,r)=>({name:e.name,version:e.version,capabilities:r,fs:t.fs??e.fs,path:t.path??e.path,exec:t.exec??e.exec,env:t.env??e.env,process:t.process??e.process,http:t.http??e.http}),Bt=e=>{let t=C(),r=en[t],n=r!==void 0?r():nt(t),s=e?.capabilities!==void 0?{...n.capabilities,...e.capabilities}:n.capabilities;return e!==void 0&&rn(e)?nn(n,e,s):e?.capabilities!==void 0?{...n,capabilities:s}:n},sn=e=>Promise.resolve(Bt(e)),E=Bt();export{P as a,$ as b,re as c,B as d,G as e,$e as f,F as g,C as h,Ke as i,Xe as j,Ye as k,Je as l,Ze as m,W as n,ye as o,ge as p,be as q,Qe as r,Se as s,xe as t,Re as u,Pe as v,st as w,ot as x,Ee as y,at as z,dt as A,sn as B,E as C,it as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as i,f as g,g as m,h as p}from"./chunk-HNQA5O2S.js";import{a as d,k as c}from"./chunk-YN3SHWBR.js";import{a,b as l}from"./chunk-CL55MNGD.js";var s=class{capabilities=["text_generation","streaming","tool_calling","vision","audio","structured_output","reasoning"];provider="vertexai";modelId;client;config;constructor(t,r){this.client=t,this.config=r,this.modelId=r.model}async generateText(t,r){try{let o=i(this.config,t,this.provider,r),n=await this.client.models.generateContent({model:this.config.model,...o});return a(g(n,this.modelId))}catch(o){return l(u(o))}}async*streamText(t,r){try{let o=i(this.config,t,this.provider,r),n=await this.client.models.generateContentStream({model:this.config.model,...o});yield*m(n)}catch(o){yield{kind:"error",error:u(o)}}}async close(){}getRawClient(){return this.client}},v={provider:"vertexai",createModel:async e=>{let t=await import("./node-XYP2DQHR.js"),r={vertexai:!0,project:e.projectId,location:e.location??"us-central1",apiVersion:"v1beta1"};e.apiKey!==void 0&&(r.apiKey=e.apiKey);let o=new t.GoogleGenAI(r);return new s(o,e)}},u=e=>{if(e instanceof d)return e;let t=e instanceof Error?e:new Error(String(e)),r=p(e);return c("vertexai",r,t)};export{s as a,v as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l,l as k}from"./chunk-YN3SHWBR.js";import{a as b,b as c}from"./chunk-CL55MNGD.js";var v=e=>{let t="";for(let o=0;o<e.length;o+=32768)t+=String.fromCharCode(...e.subarray(o,o+32768));return btoa(t)},p=e=>{switch(e){case"end_turn":return"end_turn";case"max_tokens":return"max_tokens";case"tool_use":return"tool_use";case"refusal":return"refusal";default:return"stop"}},C=e=>({text:e.text??"",...e.signature===void 0?{}:{signature:e.signature},...e.redactedData===void 0?{}:{redactedData:e.redactedData}}),g=e=>({inputTokens:e?.inputTokens??0,outputTokens:e?.outputTokens??0,totalTokens:e?.totalTokens??0,thinkingTokens:e?.thinkingTokens}),x=e=>{if(e===void 0)return[];let r=[];for(let t of e){if(t.type==="text"&&t.text!==void 0){r.push({kind:"text",text:t.text});continue}if(t.type==="tool_call"&&t.id!==void 0&&t.name!==void 0){r.push({kind:"tool_call",toolCall:{id:t.id,name:t.name,arguments:t.arguments??{}}});continue}if(t.type==="thinking"&&t.thinking!==void 0){r.push({kind:"thinking",thinking:C(t.thinking)});continue}t.type==="tool_result"&&t.id!==void 0&&r.push({kind:"tool_result",toolResult:{toolCallId:t.id,content:t.text??"",isError:!1}})}return r},y=e=>({id:e.id,status:e.status,createdAt:new Date(e.createdAt),completedAt:e.completedAt!==void 0?new Date(e.completedAt):void 0,totalCount:e.totalCount,doneCount:e.doneCount,failedCount:e.failedCount,storage:e.storage,error:e.error}),R=e=>{switch(e.kind){case"text":return{type:"text",text:e.text};case"image":return{type:"image",image:{url:e.image.url,mimeType:e.image.mimeType,detail:e.image.detail,data:e.image.data===void 0?void 0:v(e.image.data)}};case"audio":return{type:"audio",audio:{url:e.audio.url,mimeType:e.audio.mimeType,data:e.audio.data===void 0?void 0:v(e.audio.data)}};case"file":return{type:"file",file:{uri:e.file.uri,mimeType:e.file.mimeType}};case"tool_call":return{type:"tool_call",toolCall:{id:e.toolCall.id,name:e.toolCall.name,arguments:e.toolCall.arguments}};case"tool_result":return{type:"tool_result",toolResult:{toolCallId:e.toolResult.toolCallId,content:e.toolResult.content,isError:e.toolResult.isError}};case"thinking":return{type:"thinking",thinking:{text:e.thinking.text,signature:e.thinking.signature,redactedData:e.thinking.redactedData}};default:return{type:e.kind}}},a=(e,r,t)=>k(e,r.error??t,r.errorKind,r.errorStatus),s=e=>new l("request aborted",{provider:e}),d=async(e,r,t)=>{try{return await t}catch(o){throw r?.aborted===!0?s(e):o}},m=e=>({messages:e.messages.map(t=>({role:t.role,content:t.content.map(R)})),system:e.system??"",maxTokens:e.maxTokens??0,toolChoice:e.toolChoice??"",tools:e.tools,temperature:e.temperature,topP:e.topP,stopWords:e.stopWords,responseFormat:e.responseFormat,thinkingBudget:e.thinkingBudget,effort:e.effort,safetySettings:e.safetySettings,extensions:e.extensions}),h=class{capabilities;provider;modelId;#e;#t;constructor(r,t,o,i,n){this.#e=r,this.#t=t,this.provider=o,this.modelId=i,this.capabilities=n}async generateText(r,t){let o;try{o=await d(this.provider,t,this.#e.call("aiGenerateText",{modelHandle:this.#t,options:m(r)},{signal:t}))}catch(i){if(i instanceof l)return c(i);throw i}return o.error!==void 0?c(t?.aborted===!0?s(this.provider):a(this.provider,o,"generation failed")):b({content:x(o.content),stopReason:p(o.stopReason),usage:g(o.usage),modelId:o.modelId??this.modelId})}async*streamText(r,t){let o;try{o=await d(this.provider,t,this.#e.stream("aiTextStream",{modelHandle:this.#t,options:m(r)},{signal:t}))}catch(n){if(n instanceof l){yield{kind:"error",error:n};return}throw n}let i=o.opened;if(i.error!==void 0||i.handle===void 0){yield{kind:"error",error:t?.aborted===!0?s(this.provider):a(this.provider,i,"stream start failed")};return}try{for(;;){if(t?.aborted===!0){yield{kind:"error",error:s(this.provider)};return}let n;try{n=await d(this.provider,t,o.read({signal:t}))}catch(u){if(u instanceof l){yield{kind:"error",error:u};return}throw u}if(n===null)break;switch(n.type){case"content_delta":yield{kind:"content_delta",textDelta:n.textDelta??""};break;case"tool_call_delta":yield{kind:"tool_call_delta",textDelta:n.textDelta,toolCall:n.toolCallId===void 0?void 0:{id:n.toolCallId,name:n.toolCallName??"",arguments:n.argumentsDelta??{}}};break;case"thinking":n.thinking!==void 0&&(yield{kind:"thinking",thinking:C(n.thinking)});break;case"message_done":yield{kind:"message_done",stopReason:p(n.stopReason),usage:g(n.usage)};return;case"error":yield{kind:"error",error:a(this.provider,n,"stream error")};return}}}finally{o.close()}}async submitBatch(r,t){let o=r.items.map(n=>({customId:n.customId,options:m(n.options)})),i=await d(this.provider,t,this.#e.call("aiBatchCreate",{modelHandle:this.#t,items:o},{signal:t}));if(i.error!==void 0||i.job===void 0)throw t?.aborted===!0?s(this.provider):a(this.provider,i,"batch create failed");return y(i.job)}async getBatchJob(r,t){let o=await d(this.provider,t,this.#e.call("aiBatchGet",{modelHandle:this.#t,jobId:r},{signal:t}));if(o.error!==void 0||o.job===void 0)throw t?.aborted===!0?s(this.provider):a(this.provider,o,"batch get failed");return y(o.job)}async listBatchJobs(r,t){let o=await d(this.provider,t,this.#e.call("aiBatchList",{modelHandle:this.#t,limit:r?.limit,after:r?.after},{signal:t}));if(o.error!==void 0)throw t?.aborted===!0?s(this.provider):a(this.provider,o,"batch call failed");return(o.jobs??[]).map(y)}async downloadBatchResults(r,t){let o={id:r.id,status:r.status,createdAt:r.createdAt.toISOString(),completedAt:r.completedAt?.toISOString(),totalCount:r.totalCount,doneCount:r.doneCount,failedCount:r.failedCount,storage:r.storage,error:r.error},i=await d(this.provider,t,this.#e.call("aiBatchDownload",{modelHandle:this.#t,job:o},{signal:t}));if(i.error!==void 0)throw t?.aborted===!0?s(this.provider):a(this.provider,i,"batch call failed");return(i.results??[]).map(n=>({customId:n.customId,result:n.result!==void 0?{content:x(n.result.content),stopReason:p(n.result.stopReason),usage:g(n.result.usage),modelId:n.result.modelId??this.modelId}:void 0,error:n.error}))}async cancelBatchJob(r,t){let o=await d(this.provider,t,this.#e.call("aiBatchCancel",{modelHandle:this.#t,jobId:r},{signal:t}));if(o.error!==void 0)throw t?.aborted===!0?s(this.provider):a(this.provider,o,"batch call failed")}close(){return this.#e.call("aiCloseModel",this.#t),Promise.resolve()}[Symbol.asyncDispose](){return this.close()}[Symbol.dispose](){this.#e.call("aiCloseModel",this.#t)}getRawClient(){return null}},f=class{provider;#e;#t;constructor(r,t,o){this.#e=r,this.provider=t,this.#t=o}createModel(r){let t=this.#e.call("aiCreateModel",{provider:r.provider,apiKey:r.apiKey??"",model:r.model,baseUrl:r.baseUrl??"",projectId:r.projectId??"",location:r.location??"",maxTokens:r.maxTokens,temperature:r.temperature,requestTimeoutMs:r.requestTimeoutMs,properties:r.properties??{}});return t.error!==void 0||t.handle===void 0?Promise.reject(a(r.provider,t,"failed to create model")):Promise.resolve(new h(this.#e,t.handle,r.provider,r.model,this.#t))}},T=[{provider:"anthropic",capabilities:["text_generation","streaming","tool_calling","vision","batch_processing","structured_output","reasoning"]},{provider:"openai",capabilities:["text_generation","streaming","tool_calling","vision","audio","batch_processing","structured_output","reasoning"]},{provider:"gemini",capabilities:["text_generation","streaming","tool_calling","vision","audio","structured_output","reasoning"]},{provider:"vertexai",capabilities:["text_generation","streaming","tool_calling","vision","audio","structured_output","reasoning"]},{provider:"ollama",capabilities:["text_generation","streaming","vision"]},{provider:"claude-code",capabilities:["text_generation","streaming","tool_calling","structured_output"]},{provider:"opencode",capabilities:["text_generation","streaming"]},{provider:"kiro",capabilities:["text_generation","streaming"]}],_=e=>T.map(({provider:r,capabilities:t})=>new f(e,r,t)),B=null,E=async()=>{try{let r=await(await import("./mod-BZA5TFW7.js")).loadEserAjan({wasm:!1});return r.call("init"),B=null,_(r)}catch(e){return B=e instanceof Error?e:new Error(String(e)),[]}},I=()=>B;export{h as a,f as b,_ as c,E as d,I as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as i,h as a,i as d}from"./chunk-YN3SHWBR.js";var l=t=>({...t,maxTokens:t.maxTokens??16e3,temperature:t.temperature??.7,requestTimeoutMs:t.requestTimeoutMs??6e4});var g=class{models=new Map;factories=new Map;constructor(e){if(e?.factories!==void 0)for(let o of e.factories)this.factories.set(o.provider,o)}registerFactory(e){this.factories.set(e.provider,e)}async addModel(e,o){if(this.models.has(e))throw new a(e);let r=this.factories.get(o.provider);if(r===void 0)throw new d(o.provider);let s=l(o),n=await r.createModel(s);return this.models.set(e,n),n}async removeModel(e){let o=this.models.get(e);if(o===void 0)throw new i(e);await o.close(),this.models.delete(e)}getDefault(){let e=this.models.get("default");if(e!==void 0)return e;let o=this.models.values().next();return o.done===!0?null:o.value}getNamed(e){return this.models.get(e)??null}getByProvider(e){let o=[];for(let r of this.models.values())r.provider===e&&o.push(r);return o}getByCapability(e){let o=[];for(let r of this.models.values())r.capabilities.includes(e)&&o.push(r);return o}listModels(){return[...this.models.keys()]}listRegisteredProviders(){return[...this.factories.keys()]}async loadFromConfig(e){let o=Object.entries(e.targets);for(let[r,s]of o)await this.addModel(r,s)}async close(){let e=[];for(let o of this.models.values())e.push(o.close());await Promise.all(e),this.models.clear()}};export{l as a,g as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m="1.10.0";var j=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function fe(e){let t=new Set([e]),r=new Set,n=e.match(j);if(!n)return()=>!1;let o={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(o.prerelease!=null)return function(s){return s===e};function a(c){return r.add(c),!1}function i(c){return t.add(c),!0}return function(s){if(t.has(s))return!0;if(r.has(s))return!1;let l=s.match(j);if(!l)return a(s);let p={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return p.prerelease!=null||o.major!==p.major?a(s):o.major===0?o.minor===p.minor&&o.patch<=p.patch?i(s):a(s):o.minor<=p.minor?i(s):a(s)}}var k=fe(m);var de=m.split(".")[0],A=Symbol.for(`opentelemetry.js.api.${de}`),P=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};function he(){return Object.defineProperty({},"version",{value:m,enumerable:!0,writable:!1,configurable:!1})}function f(e,t,r,n=!1){var o;let a=P[A]=(o=P[A])!==null&&o!==void 0?o:he();if(!n&&a[e]){let i=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return r.error(i.stack||i.message),!1}if(a.version!=="1.10.0"){let i=new Error(`@opentelemetry/api: Registration of version v${a.version} for ${e} does not match previously registered API v${m}`);return r.error(i.stack||i.message),!1}return a[e]=t,r.debug(`@opentelemetry/api: Registered a global for ${e} v${m}.`),!0}var $;function u(e){let t=P[A];if(t!=null){if(t!==$){if(!t.version||!k(t.version))return;$=t}return t[e]}}function d(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${m}.`);let r=P[A];r&&delete r[e]}var U=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return v("debug",this._namespace,e)}error(...e){return v("error",this._namespace,e)}info(...e){return v("info",this._namespace,e)}warn(...e){return v("warn",this._namespace,e)}verbose(...e){return v("verbose",this._namespace,e)}};function v(e,t,r){let n=u("diag");if(n)return n[e](t,...r)}function F(e,t){e<0?e=0:e>9999&&(e=9999),t=t||{};function r(n,o){let a=t[n];return typeof a=="function"&&e>=o?a.bind(t):function(){}}return{error:r("error",30),warn:r("warn",50),info:r("info",60),debug:r("debug",70),verbose:r("verbose",80)}}var _e="diag",g=class X{static instance(){return this._instance||(this._instance=new X),this._instance}constructor(){function t(o){return function(...a){let i=u("diag");if(i)return i[o](...a)}}let r=this,n=(o,a={logLevel:60})=>{var i;if(o===r){var c;let x=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((c=x.stack)!==null&&c!==void 0?c:x.message),!1}typeof a=="number"&&(a={logLevel:a});let s=u("diag"),l=F((i=a.logLevel)!==null&&i!==void 0?i:60,o);if(s&&!a.suppressOverrideMessage){var p;let x=(p=new Error().stack)!==null&&p!==void 0?p:"<failed to generate stacktrace>";s.warn(`Current logger will be overwritten from ${x}`),l.warn(`Current logger will overwrite one already registered from ${x}`)}return f("diag",l,r,!0)};r.setLogger=n,r.disable=()=>{d(_e,r)},r.createComponentLogger=o=>new U(o),r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}};function C(e){return Symbol.for(e)}var Y=new class y{constructor(t){let r=this;r._currentContext=t?new Map(t):new Map,r.getValue=n=>r._currentContext.get(n),r.setValue=(n,o)=>{let a=new y(r._currentContext);return a._currentContext.set(n,o),a},r.deleteValue=n=>{let o=new y(r._currentContext);return o._currentContext.delete(n),o}}};var K=class{active(){return Y}with(e,t,r,...n){return t.call(r,...n)}bind(e,t){return t}enable(){return this}disable(){return this}attach(e){return{dispose(){}}}};var O="context",xe=new K,ve=Object.freeze({dispose:()=>{}}),h=class W{constructor(){this._attachUnsupportedWarned=!1}static getInstance(){return this._instance||(this._instance=new W),this._instance}setGlobalContextManager(t){return f(O,t,g.instance())}active(){return this._getContextManager().active()}with(t,r,n,...o){return this._getContextManager().with(t,r,n,...o)}bind(t,r){return this._getContextManager().bind(t,r)}attach(t){let r=this._getContextManager();return r.attach?r.attach(t):(this._attachUnsupportedWarned||(this._attachUnsupportedWarned=!0,g.instance().warn("The current ContextManager does not implement attach(). The context will not be attached. Use a ContextManager that supports attach() (e.g. AsyncLocalStorageContextManager) or use with()/bind() instead.")),ve)}_getContextManager(){return u(O)||xe}disable(){this._getContextManager().disable(),d(O,g.instance())}};var Te=h.getInstance();var be="0000000000000000",Ae="00000000000000000000000000000000",H={traceId:Ae,spanId:be,traceFlags:0};var _=class{constructor(e=H){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}};var R=C("OpenTelemetry Context Key SPAN");function I(e){return e.getValue(R)||void 0}function z(){return I(h.getInstance().active())}function T(e,t){return e.setValue(R,t)}function q(e){return e.deleteValue(R)}function J(e,t){return T(e,new _(t))}function w(e){var t;return(t=I(e))===null||t===void 0?void 0:t.spanContext()}var N=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Q(e,t){if(typeof e!="string"||e.length!==t)return!1;let r=0;for(let n=0;n<e.length;n+=4)r+=(N[e.charCodeAt(n)]|0)+(N[e.charCodeAt(n+1)]|0)+(N[e.charCodeAt(n+2)]|0)+(N[e.charCodeAt(n+3)]|0);return r===t}function Pe(e){return Q(e,32)&&e!=="00000000000000000000000000000000"}function Ce(e){return Q(e,16)&&e!=="0000000000000000"}function E(e){return Pe(e.traceId)&&Ce(e.spanId)}function Z(e){return new _(e)}var M=h.getInstance(),S=class{startSpan(e,t,r=M.active()){if(t?.root)return new _;let n=r&&w(r);return Ie(n)&&E(n)?new _(n):new _}startActiveSpan(e,t,r,n){var o;let a,i,c;if(arguments.length<2)return;arguments.length===2?c=t:arguments.length===3?(a=t,c=r):(a=t,i=r,c=n);let s=(o=i)!==null&&o!==void 0?o:M.active(),l=this.startSpan(e,a,s),p=T(s,l);return M.with(p,c,void 0,l)}};function Ie(e){return e!==null&&typeof e=="object"&&"spanId"in e&&typeof e.spanId=="string"&&"traceId"in e&&typeof e.traceId=="string"&&"traceFlags"in e&&typeof e.traceFlags=="number"}var we=new S,ee=class{constructor(e,t,r,n){this._provider=e,this.name=t,this.version=r,this.options=n}startSpan(e,t,r){return this._getTracer().startSpan(e,t,r)}startActiveSpan(e,t,r,n){let o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):we}};var te=class{getTracer(e,t,r){return new S}};var Ne=new te,D=class{getTracer(e,t,r){var n;return(n=this.getDelegateTracer(e,t,r))!==null&&n!==void 0?n:new ee(this,e,t,r)}getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Ne}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,r){var n;return(n=this._delegate)===null||n===void 0?void 0:n.getTracer(e,t,r)}};var G="trace",re=class ne{constructor(){this._proxyTracerProvider=new D,this.wrapSpanContext=Z,this.isSpanContextValid=E,this.deleteSpan=q,this.getSpan=I,this.getActiveSpan=z,this.getSpanContext=w,this.setSpan=T,this.setSpanContext=J}static getInstance(){return this._instance||(this._instance=new ne),this._instance}setGlobalTracerProvider(t){let r=f(G,this._proxyTracerProvider,g.instance());return r&&this._proxyTracerProvider.setDelegate(t),r}getTracerProvider(){return u(G)||this._proxyTracerProvider}getTracer(t,r){return this.getTracerProvider().getTracer(t,r)}disable(){d(G,g.instance()),this._proxyTracerProvider=new D}};var Ee=re.getInstance();var oe=class b{constructor(t){this._entries=t?new Map(t):new Map}getEntry(t){let r=this._entries.get(t);if(r)return Object.assign({},r)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,r){let n=new b(this._entries);return n._entries.set(t,r),n}removeEntry(t){let r=new b(this._entries);return r._entries.delete(t),r}removeEntries(...t){let r=new b(this._entries);for(let n of t)r._entries.delete(n);return r}clear(){return new b}};var kt=g.instance();function ae(e={}){return new oe(new Map(Object.entries(e)))}var ie={get(e,t){if(e!=null)return e[t]},keys(e){return e==null?[]:Object.keys(e)}},se={set(e,t,r){e!=null&&(e[t]=r)}};var Se=(function(e){return e[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER",e})({});var ye=(function(e){return e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e})({});var ce=class{inject(e,t){}extract(e,t){return e}fields(){return[]}};var L=C("OpenTelemetry Baggage Key");function V(e){return e.getValue(L)||void 0}function ge(){return V(h.getInstance().active())}function le(e,t){return e.setValue(L,t)}function pe(e){return e.deleteValue(L)}var B="propagation",Oe=new ce,ue=class me{constructor(){this.createBaggage=ae,this.getBaggage=V,this.getActiveBaggage=ge,this.setBaggage=le,this.deleteBaggage=pe}static getInstance(){return this._instance||(this._instance=new me),this._instance}setGlobalPropagator(t){return f(B,t,g.instance())}inject(t,r,n=se){return this._getGlobalPropagator().inject(t,r,n)}extract(t,r,n=ie){return this._getGlobalPropagator().extract(t,r,n)}fields(){return this._getGlobalPropagator().fields()}disable(){d(B,g.instance())}_getGlobalPropagator(){return u(B)||Oe}};var Re=ue.getInstance();export{Se as a,ye as b,Te as c,Re as d,Ee as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as n,n as i}from"./chunk-M4U4Y3XQ.js";var f=[{envVars:["CLAUDE_CODE","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_SESSION_ID"],tool:"claude-code"},{envVars:["CURSOR_SESSION","CURSOR"],tool:"cursor"},{envVars:["KIRO_SESSION","KIRO"],tool:"kiro"},{envVars:["WINDSURF_SESSION"],tool:"windsurf"},{envVars:["GITHUB_COPILOT"],tool:"copilot"}],c=()=>{for(let e of f)for(let t of e.envVars){let o=n.env.get(t);if(o!==void 0&&o!=="")return e.tool}return null},g=()=>c()!==null?"agent":"human",m=()=>{try{if(n.capabilities.stdin&&n.process.isTerminal("stdin"))return"interactive"}catch{}return"non-interactive"};var p=async e=>{try{let t=await n.fs.stat(e);return t.isFile?i()==="windows"?!0:t.mode===null||(t.mode&73)!==0:!1}catch{return!1}},a=async e=>{if(e.includes("/")||e.includes("\\")||e.includes(".."))return null;let t=i()==="windows",o=n.env.get("PATH")??n.env.get("Path")??"";if(o==="")return null;let u=t?["",...(n.env.get("PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";")]:[""],h=t?"\\":"/";for(let r of o.split(t?";":":"))if(r!=="")for(let s of u){let l=`${r}${h}${e}${t?s:s.toLowerCase()}`;if(await p(l))return l}return null},d=async e=>await a(e)!==null;export{c as a,g as b,m as c,d};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as h}from"./chunk-TKBGNLNV.js";import{h as L}from"./chunk-XGRZPTAD.js";import{g as S}from"./chunk-XTQFSF6C.js";import{B as w,F as C,r as d}from"./chunk-SWP6BJR6.js";import{C as c}from"./chunk-M4U4Y3XQ.js";var R={status_quo:"scope",ambition:"scope",reversibility:"constraint",user_impact:"constraint",verification:"acceptance-criteria",scope_boundary:"out-of-scope"},$=e=>R[e]??"other",q=e=>h.find(t=>t.id===e)?.text??e,D=e=>e==="STATED"||e==="CONFIRMED"?"ratified":"inferred",P=e=>{let t=Date.parse(e);return Number.isNaN(t)?e.length>0?e:"0":String(t)},x=e=>{let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)},l=e=>e.lastCalledAt??new Date().toISOString(),T=e=>{let t=[];return e.involvesWebUI&&t.push("involvesWebUI"),e.involvesCLI&&t.push("involvesCLI"),e.involvesPublicAPI&&t.push("involvesPublicAPI"),e.involvesMigration&&t.push("involvesMigration"),e.involvesDataHandling&&t.push("involvesDataHandling"),t.sort()},A=e=>e.id.startsWith("decision-split-keep")?"scope":/^d\d+$/.test(e.id)?"dependency":"other",E=e=>{switch(e){case"SPEC_PROPOSAL":return"scope";case"DISCOVERY":return"scope";case"SPEC_APPROVED":return"acceptance-criteria";case"COMPLETED":return"acceptance-criteria";case"BLOCKED":return"dependency";default:return"sequencing"}},O=e=>e.discovery.answers.map(t=>{let n=t,o=n.type??"original",r=n.timestamp!==void 0&&n.timestamp.length>0?P(n.timestamp):x(t.answer);return{id:`ans:${t.questionId}:${o}:${r}`,state:e.phase,category:$(t.questionId),question:q(t.questionId),resolution:t.answer,provenance:D(n.source),timestamp:n.timestamp!==void 0&&n.timestamp.length>0?n.timestamp:l(e),artifacts:[]}}),N=e=>e.decisions.map(t=>({id:`dec:${t.id}`,state:e.phase,category:A(t),question:t.question,resolution:t.choice,provenance:"ratified",timestamp:t.timestamp.length>0?t.timestamp:l(e),artifacts:[]})),M=e=>(e.transitionHistory??[]).map(t=>({id:`tr:${t.from}:${t.to}:${P(t.timestamp)}`,state:t.to,category:E(t.to),question:`Transition ${t.from} \u2192 ${t.to}`,resolution:t.reason??`${t.from} \u2192 ${t.to} approved`,provenance:"ratified",timestamp:t.timestamp.length>0?t.timestamp:l(e),artifacts:e.specState.path!==null?[e.specState.path]:[]})),k=(e,t)=>{let n=e.discovery.refinement?.reviewPosture;if(n===void 0)return[];let o=t?.defaultReviewPosture!==void 0&&t.defaultReviewPosture===n;return[{id:`posture:${n}`,state:e.phase,category:"scope",question:"Review posture for spec refinement",resolution:n,provenance:o?"default":"ratified",timestamp:l(e),artifacts:[]}]},U=e=>{let t=e.classification;if(t===null)return[];let n=T(t),o=n.length>0?n.join(", "):"none";return[{id:`class:${n.length>0?n.join(","):"none"}`,state:e.phase,category:"constraint",question:"Spec classification (UI / CLI / API / migration / data handling)",resolution:o,provenance:t.source==="confirmed"||t.source==="manual"?"ratified":"inferred",timestamp:l(e),artifacts:[]}]},Q=e=>(e.customACs??[]).map(t=>({id:`ac:${t.id}`,state:t.addedInPhase,category:"acceptance-criteria",question:"Acceptance criterion",resolution:t.text,provenance:"ratified",timestamp:t.timestamp.length>0?t.timestamp:l(e),artifacts:[]})),I=(e,t)=>[...O(e),...N(e),...M(e),...k(e,t),...U(e),...Q(e)],V=(e,t,n)=>{let o=new Set(I(e,n).map(r=>r.id));return I(t,n).filter(r=>!o.has(r.id))},J=(e,t=0)=>{let n=0;n+=(e.discovery.followUps??[]).filter(r=>r.status==="pending").length;let o=L(e.specState);if(n+=o.unresolvedSections.length+o.pendingDecisions.length,n+=(e.execution.confidenceFindings??[]).filter(r=>r.confidence<5).length,e.phase!=="IDLE"&&e.phase!=="UNINITIALIZED"&&e.phase!=="COMPLETED"){let r=new Set(e.discovery.answers.map(i=>i.questionId));n+=h.filter(i=>!r.has(i.id)).length}return n+=t,n},j=(e,t,n)=>{let o={ratified:0,inferred:0,default:0};for(let s of t)o[s.provenance]+=1;let r=new Set;for(let s of e.execution.modifiedFiles)r.add(s);for(let s of e.execution.completedTasks)r.add(s);for(let s of t)for(let u of s.artifacts)r.add(u);e.specState.path!==null&&r.add(e.specState.path);let i=e.discovery.answers.some(s=>s.questionId==="verification"&&s.answer.trim().length>0),g=e.discovery.answers.some(s=>s.questionId==="scope_boundary"&&s.answer.trim().length>0),p=(e.customACs?.length??0)>0||i||t.some(s=>s.category==="acceptance-criteria"),f=g||t.some(s=>s.category==="out-of-scope");return{resolved_decisions:t.length,provenance_breakdown:o,open_questions:n,specificity:{named_artifacts_count:r.size,acceptance_criteria_present:p,out_of_scope_present:f}}},G=(e,t)=>({schemaVersion:"measurement-report/v1",specId:e,title:`${e} (live ledger)`,guided:{decisions:t.map(n=>({id:n.id,category:n.category,question:n.question,resolution:n.resolution,provenance:n.provenance,phase:n.state}))}}),v=e=>e!==""&&e!=="."&&e!==".."&&!/[/\\\0]/.test(e),H=async(e,t)=>{if(!v(t))return[];let n=`${e}/${d.ledgerFile(t)}`,o;try{o=await c.fs.readTextFile(n)}catch{return[]}return o.trim().split(`
|
|
2
|
+
`).filter(r=>r.length>0).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)},K=async(e,t)=>{if(!v(t))return null;let n=`${e}/${d.ledgerSummaryFile(t)}`;try{let o=await c.fs.readTextFile(n);return JSON.parse(o)}catch{return null}},Z=async(e,t,n,o)=>{try{let r=n.spec??t.spec;if(r===null||!v(r))return;let i=o??null;if(i===null)try{i=await w(e)}catch{i=null}let g=V(t,n,i),p=await H(e,r),f=new Set(p.map(a=>a.id)),s=g.filter(a=>!f.has(a.id));try{await c.fs.mkdir(`${e}/${d.ledgerRunDir(r)}`,{recursive:!0})}catch{}if(s.length>0)try{let a=`${e}/${d.ledgerFile(r)}`,m="";try{m=await c.fs.readTextFile(a)}catch{}let y=s.map(_=>JSON.stringify(_)).join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`;await c.fs.writeTextFile(a,m+y)}catch{}let u=0;try{let a=await C(e),m=i===null?[]:a.filter(y=>i.concerns.includes(y.id));u=S(m).length}catch{u=0}let F=[...p,...s],b=j(n,F,J(n,u));try{await c.fs.writeTextFile(`${e}/${d.ledgerSummaryFile(r)}`,JSON.stringify(b,null,2)+`
|
|
5
|
+
`)}catch{}}catch{}};export{V as a,J as b,j as c,G as d,H as e,K as f,Z as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as b,b as m,c as f,e as C,f as y,g as k,h as x}from"./chunk-CCYWFSXR.js";import{a as c}from"./chunk-YN3SHWBR.js";import{a as v,b as E}from"./chunk-CL55MNGD.js";var h=class{capabilities=["text_generation","streaming"];provider="kiro";modelId;binary;config;constructor(e,r){this.binary=e,this.config=r,this.modelId=r.model}async generateText(e,r){let i=P(this.config,e),u=x(e.messages,e.system),o=m(this.binary,i,{signal:r,stdinData:u}),a=y(o.stderr);try{let t=await C(o.stdout,this.modelId),l=await o.waitForExit(),s=await a,d=k("kiro",l.code,s);return d!==null?E(d):v(t)}finally{await f(o,a)}}async*streamText(e,r){let i=P(this.config,e),u=x(e.messages,e.system),o=m(this.binary,i,{signal:r,stdinData:u}),a=y(o.stderr);try{let t=new TextDecoder,l=o.stdout.getReader(),s="";try{let g=await l.read();for(;g.done!==!0;){s+=t.decode(g.value,{stream:!0});let w=s.split(`
|
|
2
|
+
`);s=w.pop()??"";for(let A of w){let p=A.trim();if(p.length!==0){try{let R=JSON.parse(p),T=D(R);if(T!==null){yield T;continue}}catch{}yield{kind:"content_delta",textDelta:p+`
|
|
3
|
+
`}}}g=await l.read()}}finally{l.releaseLock()}s.trim().length>0&&(yield{kind:"content_delta",textDelta:s.trim()});let d=await o.waitForExit(),_=await a,S=k("kiro",d.code,_);S!==null?yield{kind:"error",error:S}:yield{kind:"message_done",stopReason:"end_turn",usage:{inputTokens:0,outputTokens:0,totalTokens:0}}}catch(t){t instanceof c?yield{kind:"error",error:t}:yield{kind:"error",error:new c(t instanceof Error?t.message:String(t),{provider:"kiro",cause:t instanceof Error?t:void 0})}}finally{await f(o,a)}}close(){return Promise.resolve()}getRawClient(){return null}},I={provider:"kiro",createModel:async n=>{let e=await b("kiro",n);return new h(e,n)}},P=(n,e)=>{let r=[];r.push("--output","json"),r.push("--model",n.model),e.maxTokens!==void 0&&r.push("--max-tokens",String(e.maxTokens));let i=n.properties?.args;return i!==void 0&&r.push(...i),r},D=n=>{if(n===null||typeof n!="object")return null;let e=n;if(e.type==="content"||e.type==="text"){let r=e.text??e.content;return r!==void 0?{kind:"content_delta",textDelta:String(r)}:null}return e.type==="done"||e.type==="result"||e.done===!0?{kind:"message_done",stopReason:"end_turn",usage:{inputTokens:e.usage?.input_tokens??0,outputTokens:e.usage?.output_tokens??0,totalTokens:(e.usage?.input_tokens??0)+(e.usage?.output_tokens??0)}}:e.type==="error"?{kind:"error",error:new c(e.error?.message??e.message??"Unknown Kiro error",{provider:"kiro"})}:null};export{h as a,I as b};
|