@xenosystem/agent-sdk 0.10.37 → 0.10.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts/index.cjs +9 -9
- package/dist/artifacts/index.js +9 -9
- package/dist/artifacts/metafile-cjs.json +1 -1
- package/dist/artifacts/metafile-esm.json +1 -1
- package/dist/automation/index.cjs +8 -8
- package/dist/automation/index.d.cts +10 -0
- package/dist/automation/index.d.ts +10 -0
- package/dist/automation/index.js +9 -9
- package/dist/automation/metafile-cjs.json +1 -1
- package/dist/automation/metafile-esm.json +1 -1
- package/dist/control-plane/index.cjs +1 -1
- package/dist/control-plane/index.js +1 -1
- package/dist/electron/index.cjs +221 -200
- package/dist/electron/index.d.cts +91 -1
- package/dist/electron/index.d.ts +91 -1
- package/dist/electron/index.js +221 -200
- package/dist/electron/metafile-cjs.json +1 -1
- package/dist/electron/metafile-esm.json +1 -1
- package/dist/index.cjs +397 -372
- package/dist/index.d.cts +136 -4
- package/dist/index.d.ts +136 -4
- package/dist/index.js +397 -372
- package/dist/intelligence/index.cjs +9 -9
- package/dist/intelligence/index.js +9 -9
- package/dist/intelligence/metafile-cjs.json +1 -1
- package/dist/intelligence/metafile-esm.json +1 -1
- package/dist/mcp/index.d.cts +10 -0
- package/dist/mcp/index.d.ts +10 -0
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/index.cjs +9 -9
- package/dist/providers/index.js +9 -9
- package/dist/providers/metafile-cjs.json +1 -1
- package/dist/providers/metafile-esm.json +1 -1
- package/dist/recipes/index.cjs +2 -2
- package/dist/recipes/index.js +2 -2
- package/dist/recipes/metafile-cjs.json +1 -1
- package/dist/recipes/metafile-esm.json +1 -1
- package/dist/research/index.cjs +3 -3
- package/dist/research/index.js +3 -3
- package/dist/research/metafile-cjs.json +1 -1
- package/dist/research/metafile-esm.json +1 -1
- package/dist/session/index.cjs +25 -25
- package/dist/session/index.js +25 -25
- package/dist/session/metafile-cjs.json +1 -1
- package/dist/session/metafile-esm.json +1 -1
- package/dist/sharing/index.cjs +4 -4
- package/dist/sharing/index.js +4 -4
- package/dist/sharing/metafile-cjs.json +1 -1
- package/dist/sharing/metafile-esm.json +1 -1
- package/dist/utils/index.cjs +23 -23
- package/dist/utils/index.d.cts +15 -1
- package/dist/utils/index.d.ts +15 -1
- package/dist/utils/index.js +23 -23
- package/dist/utils/metafile-cjs.json +1 -1
- package/dist/utils/metafile-esm.json +1 -1
- package/package.json +3 -3
package/dist/utils/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{readdirSync as
|
|
2
|
-
`,"utf-8")}async function
|
|
3
|
-
`,"utf-8"),await n.sync()}finally{await n.close()}}function
|
|
4
|
-
`)?"CRLF":"LF"}function
|
|
1
|
+
import{readdirSync as J,readFileSync as Ne}from"node:fs";import{existsSync as B,statSync as Q}from"node:fs";import*as p from"node:fs/promises";import*as d from"node:path";import{promises as N}from"node:fs";var Oe=8192,G=Symbol.for("@xenosystem/agent-sdk/file-cache"),Y=globalThis,D=Y[G]??{entries:new Map,counters:{reads:0,hits:0}};Y[G]=D;var E=D.entries,T=D.counters;function Zt(){return{...T}}function Jt(){T.reads=0,T.hits=0}function L(e){E.delete(e)}function Qt(){E.clear()}async function Ie(e){try{let t=await N.stat(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(t.code==="ENOENT")return null;throw t}}function K(e,t){for(E.delete(e),E.set(e,t);E.size>Oe;){let r=E.keys().next().value;if(r===void 0)break;E.delete(r)}}async function Me(e,t,r){let n=await N.open(e,"r");try{let o=Math.min(r,t),i=Buffer.alloc(o);return await n.read(i,0,o,t-o),i.toString("utf-8")}finally{await n.close()}}async function $e(e,t,r,n={}){let o=await Ie(e);if(!o)return E.delete(e),null;let i=E.get(e);if(i&&i.mtimeMs===o.mtimeMs&&i.size===o.size&&i.values.has(t))return T.hits+=1,K(e,i),i.values.get(t);let s,a=n.tailBytes;if(a!==void 0&&o.size>a&&(T.reads+=1,s=r(await Me(e,o.size,a),!0)),s===void 0){let f;try{f=await N.readFile(e,"utf-8")}catch(u){if(u.code==="ENOENT")return E.delete(e),null;throw u}T.reads+=1,s=r(f,!1)}let c=E.get(e),l=c&&c.mtimeMs===o.mtimeMs&&c.size===o.size?c:{mtimeMs:o.mtimeMs,size:o.size,values:new Map};return l.values.set(t,s),K(e,l),s}function er(e){return $e(e,"text",t=>t)}function ir(e){try{return B(e)&&Q(e).isFile()}catch{return!1}}function sr(e){try{return B(e)&&Q(e).isDirectory()}catch{return!1}}function ar(e,t=""){try{return Ne(e,"utf-8")}catch{return t}}async function X(e){await p.mkdir(e,{recursive:!0})}async function De(e,t){let r=d.dirname(e);await X(r);let n=Math.random().toString(36).substring(2,15),o=`${e}.tmp.${process.pid}.${n}`;try{await p.writeFile(o,t),await Xe(o,e),L(e)}finally{try{await p.unlink(o)}catch{}}}var Le=new Set(["EACCES","EBUSY","EPERM"]),Be=[10,20,40,80,160,320,640];async function Xe(e,t){for(let r=0;;r+=1)try{await p.rename(e,t);return}catch(n){let o=n.code,i=Be[r];if(process.platform!=="win32"||!o||!Le.has(o)||i===void 0)throw n;await new Promise(s=>setTimeout(s,i))}}async function cr(e,t){let r=d.dirname(e);await X(r),await p.appendFile(e,t+`
|
|
2
|
+
`,"utf-8")}async function ur(e,t){let r=d.dirname(e);await X(r);let n=await p.open(e,"a");try{await n.writeFile(t+`
|
|
3
|
+
`,"utf-8"),await n.sync()}finally{await n.close()}}function ze(e){return e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191?"utf8-bom":e.length>=2&&e[0]===255&&e[1]===254?"utf16le":e.length>=2&&e[0]===254&&e[1]===255?"utf16be":"utf8"}function ee(e){let t=Buffer.from(e);for(let r=0;r+1<t.length;r+=2){let n=t[r];t[r]=t[r+1],t[r+1]=n}return t}function Fe(e,t){switch(t){case"utf8-bom":return e.subarray(3).toString("utf8");case"utf16le":return e.subarray(2).toString("utf16le");case"utf16be":return ee(e.subarray(2)).toString("utf16le");default:return e.toString("utf8")}}function He(e,t){switch(t){case"utf8-bom":return Buffer.concat([Buffer.from([239,187,191]),Buffer.from(e,"utf8")]);case"utf16le":return Buffer.concat([Buffer.from([255,254]),Buffer.from(e,"utf16le")]);case"utf16be":return Buffer.concat([Buffer.from([254,255]),ee(Buffer.from(e,"utf16le"))]);default:return Buffer.from(e,"utf8")}}function qe(e){return e.includes(`\r
|
|
4
|
+
`)?"CRLF":"LF"}function Ue(e,t){let r=e.replace(/\r\n/g,`
|
|
5
5
|
`);return t==="CRLF"?r.replace(/\n/g,`\r
|
|
6
|
-
`):r}function
|
|
7
|
-
`)?/(^|[^\r])\n/.test(e):!1}async function
|
|
8
|
-
`)){let n=r.trim();if(n)try{t.push(JSON.parse(n))}catch{}}return t}function
|
|
9
|
-
`)}function
|
|
10
|
-
`)),nextIndex:n}}function
|
|
11
|
-
`)}function
|
|
12
|
-
${
|
|
13
|
-
`):process.stderr.write(`[${
|
|
14
|
-
`))}function
|
|
15
|
-
`):process.stderr.write(`[${
|
|
16
|
-
`))}function
|
|
17
|
-
`):process.stderr.write(`[${
|
|
18
|
-
`))}function
|
|
19
|
-
`):process.stderr.write(`[${
|
|
20
|
-
`))}function A(e){if(e==null)return"";if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}var rt=/^[A-Za-z0-9:._*-]{1,64}$/,nt=/^[A-Za-z0-9_-][A-Za-z0-9 _-]{0,30}[A-Za-z0-9_-]$/,ot=/^[0-9][0-9A-Za-z.+-]{0,40}$/;function Ur(e){if(!e||typeof e!="object")throw new TypeError("requestContext must be an object");let t=Object.keys(e).filter(n=>n!=="surface"&&n!=="client");if(t.length>0)throw new TypeError(`requestContext does not accept: ${t.join(", ")}`);if(typeof e.surface!="string"||!rt.test(e.surface))throw new TypeError("requestContext.surface must match /^[A-Za-z0-9:._*-]{1,64}$/");if(e.client===void 0)return Object.freeze({surface:e.surface});let r=e.client;if(!r||typeof r!="object"||Object.keys(r).some(n=>n!=="name"&&n!=="version"))throw new TypeError("requestContext.client must be { name, version }");if(typeof r.name!="string"||!nt.test(r.name))throw new TypeError("requestContext.client.name must be 2-32 characters of letters, digits, space, _ or -");if(typeof r.version!="string"||!ot.test(r.version))throw new TypeError("requestContext.client.version must start with a digit, e.g. 1.2.3");return Object.freeze({surface:e.surface,client:Object.freeze({name:r.name,version:r.version})})}function qr(e){return e?{"X-Xeno-Surface":e.surface,...e.client?{"X-Xeno-Client":`${e.client.name}/${e.client.version}`}:{}}:{}}var C=class extends Error{statusCode;body;retryAfterMs;requestId;cfRay;constructor(t,r={}){super(t,r.cause!==void 0?{cause:r.cause}:void 0),this.name="ApiTransientError",this.statusCode=r.statusCode,this.retryAfterMs=r.retryAfterMs,this.requestId=r.requestId,this.cfRay=r.cfRay;for(let n of["code","category","retryable","providerCode","remedy"])r[n]!==void 0&&Object.defineProperty(this,n,{value:r[n],enumerable:!0,configurable:!0,writable:!1})}},P={maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4,jitterMs:300};function k(e,t){let r=process.env[e],n=r?Number.parseInt(r,10):Number.NaN;return!Number.isFinite(n)||n<0?t:n}function it(e={}){let t=Math.max(0,e.maxRetries??k("XENO_API_MAX_RETRIES",P.maxRetries)),r=Math.max(50,e.baseDelayMs??k("XENO_API_BASE_DELAY_MS",P.baseDelayMs)),n=Math.max(r,e.maxDelayMs??k("XENO_API_MAX_DELAY_MS",P.maxDelayMs)),o=Math.max(0,e.jitterMs??k("XENO_API_RETRY_JITTER_MS",P.jitterMs));return{maxRetries:t,baseDelayMs:r,maxDelayMs:n,jitterMs:o}}function st(e,t,r){if(t.retryAfterMs&&t.retryAfterMs>0)return Math.min(t.retryAfterMs,r.maxDelayMs);let n=Math.min(r.baseDelayMs*Math.pow(2,e),r.maxDelayMs),o=Math.floor(Math.random()*r.jitterMs);return Math.min(n+o,r.maxDelayMs)}function te(e){let t=e.toLowerCase();return t.includes("rate limit")||t.includes("too many requests")||t.includes("429")}function at(e){let t=e.toLowerCase();return t.includes("network")||t.includes("timeout")||t.includes("fetch failed")||t.includes("socket hang up")||t.includes("econnreset")||t.includes("eai_again")||t.includes("enotfound")||t.includes("econnrefused")||t.includes("tls")||t.includes("temporarily unavailable")}function re(e){if(e instanceof C)return{statusCode:e.statusCode,retryAfterMs:e.retryAfterMs,requestId:e.requestId,cfRay:e.cfRay};if(!(e instanceof Error))return{};let t=e;if(t.statusCode!==void 0||t.retryAfterMs!==void 0||t.requestId!==void 0||t.cfRay!==void 0)return{statusCode:t.statusCode,retryAfterMs:t.retryAfterMs,requestId:t.requestId,cfRay:t.cfRay};let r=e.message.toLowerCase();return te(r)?{statusCode:429}:{}}var F="408|425|429|500|502|503|504";function ct(e){let t=new RegExp(`(?:\\bstatus(?:[ _-]?code)?\\b\\s*[=:]?\\s*|\\bhttp\\b\\s*|\\bapi\\b\\s*|\\bcode\\b\\s*[=:]\\s*|\\berror\\b\\s*)(?:${F})\\b`,"i"),r=new RegExp(`\\b(?:${F})\\s+(?:internal|bad\\s+gateway|service\\s+unavailable|gateway\\s+time|request\\s+time|too\\s+early|too\\s+many)`,"i"),n=new RegExp(`^\\s*(?:${F})\\b`);return t.test(e)||r.test(e)||n.test(e)}function ut(e){if(e&&typeof e=="object"&&"retryable"in e)return e.retryable===!0;if(e instanceof C){let{statusCode:t}=re(e);if(t)return t===429||t>=500||t===408||t===409||t===425}if(e instanceof Error){let t=e.name?.toLowerCase()??"";return t==="aborterror"||t==="agentinterruptederror"||e.message.toLowerCase().includes("aborted")||e.message.toLowerCase().includes("interrupted")?!1:ct(e.message)?!0:te(e.message)||at(e.message.toLowerCase())}return!1}function dt(e){if(e.onAbort)return e.onAbort();let t=new Error("The operation was aborted");return t.name="AbortError",t}async function jr(e,t={}){let r=it(t),n;for(let o=0;o<=r.maxRetries;o++)try{if(t.signal?.aborted)throw dt(t);return t.onBeforeAttempt?.(o),await e()}catch(i){if(n=i,!(t.shouldRetry?t.shouldRetry(i,o):ut(i))||o===r.maxRetries)throw i;let a=re(i),c=st(o,a,r),l=t.getDelayMs?.(i,o,c),p=typeof l=="number"&&l>=0?l:c;await new Promise(u=>setTimeout(u,p))}throw n}var lt=(e,t)=>{if(!e)return 0;let r=t.toLowerCase(),n=r.includes("claude")?3.5:r.includes("gemini")?3.8:(/(^|[/_-])(gpt|o\d)/.test(r),4),o=[...e].filter(s=>s.codePointAt(0)>127).length,i=Math.ceil(e.length/n);return Math.max(1,i+Math.ceil(o*.35))},ft=Object.freeze({id:"xeno-conservative-v1",source:"estimated",countText:lt,countImage:({detail:e})=>e==="high"?2e3:e==="low"?512:1200,safetyMarginRatio:e=>{let t=e.toLowerCase();return t.includes("claude")?.12:t.includes("gemini")?.14:/(^|[/_-])(gpt|o\d)/.test(t)?.1:.18}});function Kr(e,t,r=ft){return{tokens:Math.max(0,Math.ceil(r.countText(e,t))),source:r.source,adapterId:r.id}}function pt(e){return e?Math.ceil(e.length/4):0}function Gr(e,t){if(!e||t<=0)return"";let r=t*4;if(e.length<=r)return e;let n=e.slice(0,r),o=n.lastIndexOf(" ");return o>r*.8&&(n=n.slice(0,o)),n+"..."}function Yr(e,t){return pt(e)<=t}function Zr(e,t){return Math.max(0,t-e)}var mt={"claude-opus-4-6-thinking":{input:15,output:75},"claude-opus-4-6":{input:15,output:75},"claude-opus-4-5-thinking":{input:15,output:75},"claude-sonnet-4-6":{input:3,output:15},"claude-sonnet-4-5-thinking":{input:3,output:15},"claude-sonnet-4-5":{input:3,output:15},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.5-flash-lite":{input:.075,output:.3},"gemini-3-flash":{input:.15,output:.6},"gemini-3-pro-high":{input:1.25,output:5},"gpt-5":{input:5,output:15},"gpt-5-codex":{input:5,output:15},"gpt-5.1":{input:5,output:15},"gpt-5.1-codex":{input:5,output:15},"gpt-5.2":{input:5,output:15},"gpt-5.2-codex":{input:5,output:15},"kimi-k2":{input:.6,output:2.4},"kimi-k2-thinking":{input:.6,output:2.4},"kimi-k2.5":{input:.6,output:2.4}};function Qr(e,t,r){let n=mt[e];return n?t/1e6*n.input+r/1e6*n.output:0}function en(e){return e<=0?"$0.00":e<.001?"<$0.001":e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}import{spawnSync as gt}from"node:child_process";function nn(e){let t=process.platform==="win32"?[{command:"clip.exe",args:[]}]:process.platform==="darwin"?[{command:"pbcopy",args:[]}]:[{command:"wl-copy",args:[]},{command:"xclip",args:["-selection","clipboard"]},{command:"xsel",args:["--clipboard","--input"]}],r=null;for(let n of t)try{let o=gt(n.command,n.args,{input:e,encoding:"utf8"});if(o.error){r=o.error.message;continue}if(o.status===0)return;r=o.stderr||o.stdout||`exit ${o.status}`}catch(o){r=o instanceof Error?o.message:String(o)}throw new Error(`Clipboard copy failed${r?`: ${r}`:""}`)}function oe(e){return e.replace(/\\/g,"/").toLowerCase()}var yt=["golden","solution","answer","expected"],ht=["expected","golden","reference","answer","answers"],Et=new Set([";","&&","||","|"]);function ie(e){return oe(e).replace(/^\.\/+/,"").split("/").map(t=>t.trim()).filter(t=>t.length>0)}function bt(e){return yt.some(t=>e.includes(t))}function ne(e){return ht.some(t=>e.includes(t))}function se(e){return e.split("::",1)[0]?.split("?",1)[0]?.split("#",1)[0]??e}function S(e){let t=e.trim().replace(/^[({]+/,"").replace(/[),;]+$/,"");return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),t}function wt(e){return e.match(/"[^"]*"|'[^']*'|&&|\|\||[;|]|[^\s;|&]+/g)?.map(S).filter(t=>t.length>0)??[]}function ae(e){let t=ie(e),r=se(t.at(-1)??"");return ne(r)||t.some(n=>ne(n))}function ce(e){let t=oe(S(e));return!t||t==="/dev/null"||t.startsWith("/tmp/")||t.startsWith("tmp/")||t.startsWith("/var/tmp/")||t.startsWith("var/tmp/")?!1:t.startsWith("/app/")||t.startsWith("./")?!0:!t.startsWith("/")}function Rt(e){return/[\\/]/.test(e)||/\.[A-Za-z0-9]{1,8}$/.test(e)}function xt(e){let t=wt(e);for(let r=0;r<t.length;r+=1){let n=t[r]?.toLowerCase();if(n!=="cp"&&n!=="mv"&&n!=="rsync"&&n!=="install")continue;let o=[];for(let s=r+1;s<t.length;s+=1){let a=t[s];if(!a||Et.has(a))break;a!=="--"&&(a.startsWith("-")||o.push(a))}if(o.length<2)continue;let i=o.at(-1);if(ce(i)){for(let s of o.slice(0,-1))if(Rt(s)&&ae(s))return{sourcePath:s,destinationPath:i,operation:n}}}return null}function Tt(e){let t=[/\bcat\s+(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))\s*>\s*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/i,/\bdd\b[\s\S]*?\bif=(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))[\s\S]*?\bof=(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/i];for(let r of t){let n=e.match(r);if(!n)continue;let o=S(n[1]??n[2]??n[3]??""),i=S(n[4]??n[5]??n[6]??"");if(!(!o||!i)&&ae(o)&&ce(i))return{sourcePath:o,destinationPath:i,operation:r.source.startsWith("\\bdd")?"dd":"redirect"}}return null}function ue(){return process.env.XENO_BENCHMARK_MODE?.trim().toLowerCase()==="terminal-bench"}function de(e){let t=ie(e);if(t.includes("solution")||t.includes("xeno-audit")||t.includes(".xeno")&&t.includes("audit"))return!0;let r=se(t.at(-1)??"");return t.includes("tests")&&bt(r)}function sn(e){return ue()?e.filter(t=>!de(t)):e}function an(e){return`Benchmark safety: access to verifier answer or benchmark trace artifacts is blocked (${e}). Use task inputs and verifier logic, not golden, solution, or agent audit files.`}function cn(e){return e.split(/[\s"'`;|&]+/).map(t=>t.trim()).filter(t=>t.length>0&&/[\\/]/.test(t)).some(t=>de(t))}function un(e){if(!ue())return null;let t=xt(e)??Tt(e);return t?["[xeno guidance]",`Benchmark safety blocked ${t.operation} from reference-like source ${t.sourcePath} to protected destination ${t.destinationPath}.`,"Do not copy expected, golden, reference, or answer files over task inputs or submission artifacts to make validation pass.","If a previous check polluted an input, restore/regenerate the original source input, then rerun the actual script or program under test."].join(`
|
|
21
|
-
`):null}function
|
|
6
|
+
`):r}function dr(e){return e.includes(`\r
|
|
7
|
+
`)?/(^|[^\r])\n/.test(e):!1}async function je(e){let t=await p.readFile(e),r=ze(t),n=Fe(t,r);return{content:n,encoding:r,lineEnding:qe(n),sizeBytes:t.length}}async function lr(e,t,r){let n=r?.preserveLineEndings?t:Ue(t,r?.lineEnding??"LF");await De(e,He(n,r?.encoding??"utf8"))}async function fr(e,t){let r=new Set,n=d.resolve(e),o=t===void 0?void 0:d.resolve(t);if(o!==void 0){let i=d.relative(o,n);if(d.isAbsolute(i)||i===".."||i.startsWith(`..${d.sep}`))return"LF"}for(;!r.has(n);){r.add(n);try{let s=J(n,{withFileTypes:!0}).filter(a=>a.isFile()).map(a=>a.name).sort();for(let a of s){if(a.startsWith("."))continue;let c=d.extname(a).toLowerCase();if([".ts",".tsx",".js",".jsx",".json",".md",".txt",".yaml",".yml",".css",".html",".xml",".sh",".ps1"].includes(c))try{let l=d.join(n,a),f=await je(l);if(f.content.length>0)return f.lineEnding}catch{}}}catch{}if(o!==void 0&&d.relative(o,n)==="")break;let i=d.dirname(n);if(i===n)break;n=i}return"LF"}function Ve(e,t,r){let n=[],o=[{dir:e,depth:0}],i=new Set;for(;o.length>0&&n.length<r;){let s=o.shift();if(!i.has(s.dir)){i.add(s.dir);try{let a=J(s.dir,{withFileTypes:!0});for(let c of a){let l=d.join(s.dir,c.name);if(c.isFile()){if(n.push(l),n.length>=r)break;continue}c.isDirectory()&&s.depth<t&&!c.name.startsWith(".")&&c.name!=="node_modules"&&o.push({dir:l,depth:s.depth+1})}}catch{}}}return n}function Z(e,t){let r=d.relative(e,t);return r===""||!r.startsWith("..")&&!d.isAbsolute(r)}function pr(e,t){try{let r=d.dirname(e),n=d.basename(e,d.extname(e)).toLowerCase(),o=d.basename(e).toLowerCase(),i=[r,d.dirname(r)],s=t!==void 0&&Z(t,e)?t:void 0,a=i.flatMap(l=>Ve(l,2,500)).filter(l=>s===void 0||Z(s,l)),c=null;for(let l of a){let f=d.basename(l).toLowerCase(),u=d.basename(l,d.extname(l)).toLowerCase(),g=null;if(f===o?g=0:u===n?g=1:(f.includes(n)||n.includes(u))&&(g=2),g===null)continue;let x=d.relative(r,l).split(d.sep).length,h=g+x*.01;(!c||h<c.score)&&(c={filePath:l,score:h})}return c?.filePath??null}catch{}return null}async function mr(e){try{return await p.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}function gr(e){return B(e)}async function yr(e,t){try{let n=(await p.readdir(e,{withFileTypes:!0})).filter(o=>o.isFile()).map(o=>d.join(e,o.name));return t&&(n=n.filter(o=>t.test(d.basename(o)))),n}catch(r){if(r.code==="ENOENT")return[];throw r}}async function hr(e){try{return(await p.readdir(e,{withFileTypes:!0})).filter(r=>r.isDirectory()).map(r=>d.join(e,r.name))}catch(t){if(t.code==="ENOENT")return[];throw t}}async function Er(e){try{await p.unlink(e)}catch(t){if(t.code!=="ENOENT")throw t}finally{L(e)}}async function br(e){try{await p.rm(e,{recursive:!0,force:!0})}catch(t){if(t.code!=="ENOENT")throw t}}function Rr(e,t){try{return JSON.parse(e)}catch{return t}}function xr(e,t="{}"){try{return JSON.stringify(e)}catch{return t}}function Tr(e){let t=[];for(let r of e.split(`
|
|
8
|
+
`)){let n=r.trim();if(n)try{t.push(JSON.parse(n))}catch{}}return t}function vr(e){let t=We(e);return{frontmatter:t.frontmatter,content:t.content.trim()}}function Ar(e,t){let r=Object.fromEntries(Object.entries(e).filter(([n,o])=>o!==void 0));return["---",oe(r),"---","",t].join(`
|
|
9
|
+
`)}function kr(e){return e.trimStart().startsWith("---")}function We(e){let t=e.replace(/^\uFEFF/,"");if(!t.startsWith("---"))return{frontmatter:{},content:e};let r=t.search(/\r?\n/);if(r<0||t.slice(0,r).trim()!=="---")return{frontmatter:{},content:e};let n=t.slice(r+(t[r]==="\r"?2:1)),o=n.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!o||o.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=n.slice(0,o.index),s=o[0],a=o.index+s.length;return{frontmatter:re(i),content:n.slice(a)}}function re(e){let t={},r=e.split(/\r?\n/);for(let n=0;n<r.length;n+=1){let o=r[n];if(!o.trim()||o.trimStart().startsWith("#"))continue;if(/^\s/.test(o))throw new Error(`Unexpected indentation at line ${n+1}.`);let i=Ge(o,n+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){t[i.key]=ne(i.value,n+1);continue}let s=Ke(r,n+1);t[i.key]=s.value,n=s.nextIndex-1}return t}function Ke(e,t){let r=[],n=t;for(;n<e.length;n+=1){let i=e[n];if(!i.trim()){r.push(i);continue}if(!/^\s/.test(i))break;r.push(i.replace(/^ {2}/,""))}let o=r.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return o.length===0?{value:{},nextIndex:n}:o.every(i=>i.trimStart().startsWith("- "))?{value:o.map((i,s)=>ne(i.trimStart().slice(2),t+s+1)),nextIndex:n}:{value:re(r.join(`
|
|
10
|
+
`)),nextIndex:n}}function Ge(e,t){let r=e.indexOf(":");if(r<=0)throw new Error(`Invalid YAML line ${t}.`);let n=e.slice(0,r).trim(),o=e.slice(r+1).trim();if(!n)throw new Error(`Invalid YAML key at line ${t}.`);return{key:n,value:o}}function ne(e,t){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return te(e,t);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${t}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return te(e,t);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${t}.`);return e}function te(e,t){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${t}.`)}}function oe(e,t=""){return Object.entries(e).map(([r,n])=>Ye(r,n,t)).join(`
|
|
11
|
+
`)}function Ye(e,t,r){return Array.isArray(t)?`${r}${e}: ${JSON.stringify(t)}`:t&&typeof t=="object"?`${r}${e}:
|
|
12
|
+
${oe(t,`${r} `)}`:`${r}${e}: ${JSON.stringify(t)}`}import*as y from"path";function Ze(e,t){let r=y.resolve(e),n=y.resolve(e,t);return n===r?!0:r===y.parse(r).root?n.startsWith(r):n.startsWith(r+y.sep)}function Cr(e,t){if(y.isAbsolute(t))return y.resolve(t);if(!Ze(e,t))throw new Error(`PathSecurity: Path traversal attempt detected: ${t}`);return y.resolve(e,t)}function Sr(e,t=process.platform){let r=y.resolve(e);return t==="win32"?r.toLowerCase():r}import{homedir as q,platform as it,release as st}from"node:os";import{execFileSync as at,spawn as ct,spawnSync as ut}from"node:child_process";import{statSync as dt}from"node:fs";import{delimiter as lt,join as ft,resolve as _}from"node:path";import{spawn as Je,spawnSync as Mr}from"node:child_process";var Qe=5e3,ie=128;function et(e,t,r){let n={tool:e,timeoutMs:r};return t.timedOut?{...n,terminated:!1,reason:"timeout",exitCode:null,detail:`${e} did not finish within ${r}ms`}:t.error!==void 0?{...n,terminated:!1,reason:"spawn-error",exitCode:null,detail:t.error}:t.status===0?{...n,terminated:!0,reason:"terminated",exitCode:0}:e==="taskkill"&&t.status===ie?{...n,terminated:!0,reason:"not-running",exitCode:ie}:{...n,terminated:!1,reason:"failed",exitCode:t.status,detail:`${e} exited with code ${t.status??"unknown"}`}}var tt=(e,t,r)=>new Promise(n=>{let o=!1,i={},s=c=>{o||(o=!0,i.timer&&clearTimeout(i.timer),n(c))},a;try{a=Je(e,[...t],{stdio:"ignore",windowsHide:!0})}catch(c){s({status:null,timedOut:!1,error:c instanceof Error?c.message:String(c)});return}i.timer=setTimeout(()=>{try{a.kill("SIGKILL")}catch{}s({status:null,timedOut:!0})},r),i.timer.unref?.(),a.once("error",c=>{s({status:null,timedOut:!1,error:c.code??c.message})}),a.once("close",c=>{s(c===null?{status:null,timedOut:!1,error:"no exit status"}:{status:c,timedOut:!1})})});function se(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):Qe}function rt(e,t){return{terminated:!1,reason:"failed",tool:e,exitCode:null,timeoutMs:t,detail:"pid is not a positive integer"}}function nt(e){return["/PID",String(e),"/T","/F"]}async function ae(e,t={}){let r=se(t.timeoutMs);return!Number.isSafeInteger(e)||e<=0?rt("taskkill",r):ot("taskkill","taskkill.exe",nt(e),{timeoutMs:r,run:t.run})}async function ot(e,t,r,n={}){let o=se(n.timeoutMs),i;try{i=await(n.run??tt)(t,r,o)}catch(s){i={status:null,timedOut:!1,error:s instanceof Error?s.message:String(s)}}return et(e,i,o)}var U=it(),k=U==="win32",zr=U==="darwin",Fr=U==="linux",Hr=st(),qr=q();function Ur(){let e=process.env.XENO_AGENT_HOME?.trim();return e?_(e):_(q(),".xeno-agent")}function jr(){let e=process.env.XENO_CONFIG_DIR?.trim();return e?_(e):_(q(),".xeno-code")}function Vr(e){return _(e,".xeno-code")}function Wr(){return k?"powershell":process.env.SHELL?.split("/").pop()??"bash"}var F=5e3,H=4096,z=["rev-parse","--is-inside-work-tree"];function ce(){if(!k)return{file:"git",args:z};let e=(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";").map(t=>t.toLowerCase()).filter(t=>[".exe",".com",".cmd",".bat"].includes(t));for(let t of(process.env.PATH??"").split(lt).filter(Boolean)){let r=t.replace(/^"(.*)"$/,"$1");for(let n of e){let o=_(r,`git${n}`);try{if(!dt(o).isFile())continue}catch{continue}if(n!==".cmd"&&n!==".bat")return{file:o,args:z};if(/["%!\r\n\0]/.test(o))throw new Error("Git wrapper path cannot be represented safely");let i=process.env.SystemRoot??process.env.WINDIR;if(!i)throw new Error("Windows command interpreter is unavailable");return{file:ft(i,"System32","cmd.exe"),args:["/d","/s","/c",`""${o}" rev-parse --is-inside-work-tree"`],windowsVerbatimArguments:!0}}}return{file:"git",args:z}}function Kr(e){try{let t=ce();if(t.windowsVerbatimArguments){let r=ut(t.file,t.args,{cwd:e,encoding:"utf8",windowsHide:!0,windowsVerbatimArguments:!0,timeout:F,maxBuffer:H,stdio:["ignore","pipe","ignore"]});return!r.error&&r.status===0&&r.stdout.trim()==="true"}return at(t.file,t.args,{cwd:e,encoding:"utf8",windowsHide:!0,timeout:F,maxBuffer:H,stdio:["ignore","pipe","ignore"]}).trim()==="true"}catch{return!1}}function Gr(e){return new Promise(t=>{let r,n=!1,o={},i=0,s=[],a=l=>{n||(n=!0,o.timer&&clearTimeout(o.timer),r?.stdout?.destroy(),r?.unref(),t(l))},c=()=>{if(r.exitCode===null&&r.signalCode===null)if(k&&r.pid)ae(r.pid);else if(!k&&r.pid)try{process.kill(-r.pid,"SIGKILL")}catch{try{r.kill("SIGKILL")}catch{}}else try{r.kill("SIGKILL")}catch{}a(!1)};try{let l=ce();r=ct(l.file,l.args,{cwd:e,windowsHide:!0,detached:!k,windowsVerbatimArguments:l.windowsVerbatimArguments,stdio:["ignore","pipe","ignore"]})}catch{a(!1);return}o.timer=setTimeout(c,F),r.stdout?.on("data",l=>{if(!n){if(i+=l.byteLength,i>H){c();return}s.push(Buffer.from(l))}}),r.once("error",()=>a(!1)),r.once("close",l=>a(l===0&&Buffer.concat(s).toString("utf8").trim()==="true"))})}function Zr(e,t){for(let r of t)if(e[r]===void 0||e[r]===null||e[r]==="")return`Missing required parameter: ${r}`;return null}function Jr(e,t,r){let n=e[t];if(n==null){if(r!==void 0)return r;throw new Error(`Missing required parameter: ${t}`)}if(typeof n!="string")throw new Error(`Parameter ${t} must be a string, got ${typeof n}`);return n}function Qr(e,t,r){let n=e[t];if(n==null){if(r!==void 0)return r;throw new Error(`Missing required parameter: ${t}`)}if(typeof n!="number")throw new Error(`Parameter ${t} must be a number, got ${typeof n}`);if(isNaN(n))throw new Error(`Parameter ${t} is NaN`);return n}function en(e,t,r){let n=e[t];if(n==null){if(r!==void 0)return r;throw new Error(`Missing required parameter: ${t}`)}if(typeof n!="boolean")throw new Error(`Parameter ${t} must be a boolean, got ${typeof n}`);return n}function pt(e){if(e.length>5e3)return"Pattern too long (max 5000 characters)";let r=[/(\.\*){3,}/,/(\+\+|\*\*)/,/(.*\+.*\+.*\+)/];for(let n of r)if(n.test(e))return"Pattern contains potentially unsafe constructs that could cause excessive backtracking";return null}function tn(e,t,r=5e3){let n=pt(e);if(n)throw new Error(n);try{return new RegExp(e,t)}catch(o){let i=o instanceof Error?o.message:String(o);throw new Error(`Invalid regex pattern: ${i}`)}}function rn(e,t,r=1e3){if(t.length>1e5)throw new Error(`Input too large for safe regex test (${t.length} chars, max 100000)`);return e.test(t)}var mt=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.SILENT=4]="SILENT",i))(mt||{}),v=1;function on(e){v=e}function sn(){return v}function w(){return new Date().toISOString()}function an(e,t){v<=0&&(t!==void 0?process.stderr.write(`[${w()}] DEBUG: ${e} ${P(t)}
|
|
13
|
+
`):process.stderr.write(`[${w()}] DEBUG: ${e}
|
|
14
|
+
`))}function cn(e,t){v<=1&&(t!==void 0?process.stderr.write(`[${w()}] INFO: ${e} ${P(t)}
|
|
15
|
+
`):process.stderr.write(`[${w()}] INFO: ${e}
|
|
16
|
+
`))}function un(e,t){v<=2&&(t!==void 0?process.stderr.write(`[${w()}] WARN: ${e} ${P(t)}
|
|
17
|
+
`):process.stderr.write(`[${w()}] WARN: ${e}
|
|
18
|
+
`))}function dn(e,t){v<=3&&(t!==void 0?process.stderr.write(`[${w()}] ERROR: ${e} ${P(t)}
|
|
19
|
+
`):process.stderr.write(`[${w()}] ERROR: ${e}
|
|
20
|
+
`))}function P(e){if(e==null)return"";if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}var gt=/^[A-Za-z0-9:._*-]{1,64}$/,yt=/^[A-Za-z0-9_-][A-Za-z0-9 _-]{0,30}[A-Za-z0-9_-]$/,ht=/^[0-9][0-9A-Za-z.+-]{0,40}$/,ue=Object.freeze({"x-xeno-source":Object.freeze(["auto","quota","credits","byok"]),"x-xeno-byok-mode":Object.freeze(["local","cloud"])}),Et=/^[\x21-\x7E]{1,64}$/;function fn(e){if(!e||typeof e!="object")throw new TypeError("requestContext must be an object");let t=Object.keys(e).filter(i=>i!=="surface"&&i!=="client"&&i!=="headers");if(t.length>0)throw new TypeError(`requestContext does not accept: ${t.join(", ")}`);if(typeof e.surface!="string"||!gt.test(e.surface))throw new TypeError("requestContext.surface must match /^[A-Za-z0-9:._*-]{1,64}$/");let r=bt(e.headers),n=r?{surface:e.surface,headers:r}:{surface:e.surface};if(e.client===void 0)return Object.freeze(n);let o=e.client;if(!o||typeof o!="object"||Object.keys(o).some(i=>i!=="name"&&i!=="version"))throw new TypeError("requestContext.client must be { name, version }");if(typeof o.name!="string"||!yt.test(o.name))throw new TypeError("requestContext.client.name must be 2-32 characters of letters, digits, space, _ or -");if(typeof o.version!="string"||!ht.test(o.version))throw new TypeError("requestContext.client.version must start with a digit, e.g. 1.2.3");return Object.freeze({...n,client:Object.freeze({name:o.name,version:o.version})})}function bt(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("requestContext.headers must be an object");let t={};for(let[r,n]of Object.entries(e)){let o=r.toLowerCase(),i=Object.prototype.hasOwnProperty.call(ue,o)?ue[o]:void 0;if(!i)throw new TypeError(`requestContext.headers does not accept: ${r}`);if(typeof n!="string"||!Et.test(n))throw new TypeError(`requestContext.headers.${o} must be 1-64 printable ASCII characters`);if(!i.includes(n))throw new TypeError(`requestContext.headers.${o} must be one of: ${i.join(", ")}`);if(Object.prototype.hasOwnProperty.call(t,o))throw new TypeError(`requestContext.headers.${o} is given twice`);t[o]=n}return Object.freeze(t)}function pn(e){return e?{...e.headers??{},"X-Xeno-Surface":e.surface,...e.client?{"X-Xeno-Client":`${e.client.name}/${e.client.version}`}:{}}:{}}var O=class extends Error{statusCode;body;retryAfterMs;requestId;cfRay;constructor(t,r={}){super(t,r.cause!==void 0?{cause:r.cause}:void 0),this.name="ApiTransientError",this.statusCode=r.statusCode,this.retryAfterMs=r.retryAfterMs,this.requestId=r.requestId,this.cfRay=r.cfRay;for(let n of["code","category","retryable","providerCode","remedy"])r[n]!==void 0&&Object.defineProperty(this,n,{value:r[n],enumerable:!0,configurable:!0,writable:!1})}},C={maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4,jitterMs:300};function S(e,t){let r=process.env[e],n=r?Number.parseInt(r,10):Number.NaN;return!Number.isFinite(n)||n<0?t:n}function wt(e={}){let t=Math.max(0,e.maxRetries??S("XENO_API_MAX_RETRIES",C.maxRetries)),r=Math.max(50,e.baseDelayMs??S("XENO_API_BASE_DELAY_MS",C.baseDelayMs)),n=Math.max(r,e.maxDelayMs??S("XENO_API_MAX_DELAY_MS",C.maxDelayMs)),o=Math.max(0,e.jitterMs??S("XENO_API_RETRY_JITTER_MS",C.jitterMs));return{maxRetries:t,baseDelayMs:r,maxDelayMs:n,jitterMs:o}}function Rt(e,t,r){if(t.retryAfterMs&&t.retryAfterMs>0)return Math.min(t.retryAfterMs,r.maxDelayMs);let n=Math.min(r.baseDelayMs*Math.pow(2,e),r.maxDelayMs),o=Math.floor(Math.random()*r.jitterMs);return Math.min(n+o,r.maxDelayMs)}function de(e){let t=e.toLowerCase();return t.includes("rate limit")||t.includes("too many requests")||t.includes("429")}function xt(e){let t=e.toLowerCase();return t.includes("network")||t.includes("timeout")||t.includes("fetch failed")||t.includes("socket hang up")||t.includes("econnreset")||t.includes("eai_again")||t.includes("enotfound")||t.includes("econnrefused")||t.includes("tls")||t.includes("temporarily unavailable")}function le(e){if(e instanceof O)return{statusCode:e.statusCode,retryAfterMs:e.retryAfterMs,requestId:e.requestId,cfRay:e.cfRay};if(!(e instanceof Error))return{};let t=e;if(t.statusCode!==void 0||t.retryAfterMs!==void 0||t.requestId!==void 0||t.cfRay!==void 0)return{statusCode:t.statusCode,retryAfterMs:t.retryAfterMs,requestId:t.requestId,cfRay:t.cfRay};let r=e.message.toLowerCase();return de(r)?{statusCode:429}:{}}var j="408|425|429|500|502|503|504";function Tt(e){let t=new RegExp(`(?:\\bstatus(?:[ _-]?code)?\\b\\s*[=:]?\\s*|\\bhttp\\b\\s*|\\bapi\\b\\s*|\\bcode\\b\\s*[=:]\\s*|\\berror\\b\\s*)(?:${j})\\b`,"i"),r=new RegExp(`\\b(?:${j})\\s+(?:internal|bad\\s+gateway|service\\s+unavailable|gateway\\s+time|request\\s+time|too\\s+early|too\\s+many)`,"i"),n=new RegExp(`^\\s*(?:${j})\\b`);return t.test(e)||r.test(e)||n.test(e)}function _t(e){if(e&&typeof e=="object"&&"retryable"in e)return e.retryable===!0;if(e instanceof O){let{statusCode:t}=le(e);if(t)return t===429||t>=500||t===408||t===409||t===425}if(e instanceof Error){let t=e.name?.toLowerCase()??"";return t==="aborterror"||t==="agentinterruptederror"||e.message.toLowerCase().includes("aborted")||e.message.toLowerCase().includes("interrupted")?!1:Tt(e.message)?!0:de(e.message)||xt(e.message.toLowerCase())}return!1}function vt(e){if(e.onAbort)return e.onAbort();let t=new Error("The operation was aborted");return t.name="AbortError",t}async function gn(e,t={}){let r=wt(t),n;for(let o=0;o<=r.maxRetries;o++)try{if(t.signal?.aborted)throw vt(t);return t.onBeforeAttempt?.(o),await e()}catch(i){if(n=i,!(t.shouldRetry?t.shouldRetry(i,o):_t(i))||o===r.maxRetries)throw i;let a=le(i),c=Rt(o,a,r),l=t.getDelayMs?.(i,o,c),f=typeof l=="number"&&l>=0?l:c;await new Promise(u=>setTimeout(u,f))}throw n}var At=(e,t)=>{if(!e)return 0;let r=t.toLowerCase(),n=r.includes("claude")?3.5:r.includes("gemini")?3.8:(/(^|[/_-])(gpt|o\d)/.test(r),4),o=[...e].filter(s=>s.codePointAt(0)>127).length,i=Math.ceil(e.length/n);return Math.max(1,i+Math.ceil(o*.35))},kt=Object.freeze({id:"xeno-conservative-v1",source:"estimated",countText:At,countImage:({detail:e})=>e==="high"?2e3:e==="low"?512:1200,safetyMarginRatio:e=>{let t=e.toLowerCase();return t.includes("claude")?.12:t.includes("gemini")?.14:/(^|[/_-])(gpt|o\d)/.test(t)?.1:.18}});function hn(e,t,r=kt){return{tokens:Math.max(0,Math.ceil(r.countText(e,t))),source:r.source,adapterId:r.id}}function Pt(e){return e?Math.ceil(e.length/4):0}function En(e,t){if(!e||t<=0)return"";let r=t*4;if(e.length<=r)return e;let n=e.slice(0,r),o=n.lastIndexOf(" ");return o>r*.8&&(n=n.slice(0,o)),n+"..."}function bn(e,t){return Pt(e)<=t}function wn(e,t){return Math.max(0,t-e)}var Ct={"claude-opus-4-6-thinking":{input:15,output:75},"claude-opus-4-6":{input:15,output:75},"claude-opus-4-5-thinking":{input:15,output:75},"claude-sonnet-4-6":{input:3,output:15},"claude-sonnet-4-5-thinking":{input:3,output:15},"claude-sonnet-4-5":{input:3,output:15},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.5-flash-lite":{input:.075,output:.3},"gemini-3-flash":{input:.15,output:.6},"gemini-3-pro-high":{input:1.25,output:5},"gpt-5":{input:5,output:15},"gpt-5-codex":{input:5,output:15},"gpt-5.1":{input:5,output:15},"gpt-5.1-codex":{input:5,output:15},"gpt-5.2":{input:5,output:15},"gpt-5.2-codex":{input:5,output:15},"kimi-k2":{input:.6,output:2.4},"kimi-k2-thinking":{input:.6,output:2.4},"kimi-k2.5":{input:.6,output:2.4}};function xn(e,t,r){let n=Ct[e];return n?t/1e6*n.input+r/1e6*n.output:0}function Tn(e){return e<=0?"$0.00":e<.001?"<$0.001":e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}import{spawnSync as St}from"node:child_process";function An(e){let t=process.platform==="win32"?[{command:"clip.exe",args:[]}]:process.platform==="darwin"?[{command:"pbcopy",args:[]}]:[{command:"wl-copy",args:[]},{command:"xclip",args:["-selection","clipboard"]},{command:"xsel",args:["--clipboard","--input"]}],r=null;for(let n of t)try{let o=St(n.command,n.args,{input:e,encoding:"utf8"});if(o.error){r=o.error.message;continue}if(o.status===0)return;r=o.stderr||o.stdout||`exit ${o.status}`}catch(o){r=o instanceof Error?o.message:String(o)}throw new Error(`Clipboard copy failed${r?`: ${r}`:""}`)}function pe(e){return e.replace(/\\/g,"/").toLowerCase()}var Ot=["golden","solution","answer","expected"],It=["expected","golden","reference","answer","answers"],Mt=new Set([";","&&","||","|"]);function me(e){return pe(e).replace(/^\.\/+/,"").split("/").map(t=>t.trim()).filter(t=>t.length>0)}function $t(e){return Ot.some(t=>e.includes(t))}function fe(e){return It.some(t=>e.includes(t))}function ge(e){return e.split("::",1)[0]?.split("?",1)[0]?.split("#",1)[0]??e}function I(e){let t=e.trim().replace(/^[({]+/,"").replace(/[),;]+$/,"");return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),t}function Nt(e){return e.match(/"[^"]*"|'[^']*'|&&|\|\||[;|]|[^\s;|&]+/g)?.map(I).filter(t=>t.length>0)??[]}function ye(e){let t=me(e),r=ge(t.at(-1)??"");return fe(r)||t.some(n=>fe(n))}function he(e){let t=pe(I(e));return!t||t==="/dev/null"||t.startsWith("/tmp/")||t.startsWith("tmp/")||t.startsWith("/var/tmp/")||t.startsWith("var/tmp/")?!1:t.startsWith("/app/")||t.startsWith("./")?!0:!t.startsWith("/")}function Dt(e){return/[\\/]/.test(e)||/\.[A-Za-z0-9]{1,8}$/.test(e)}function Lt(e){let t=Nt(e);for(let r=0;r<t.length;r+=1){let n=t[r]?.toLowerCase();if(n!=="cp"&&n!=="mv"&&n!=="rsync"&&n!=="install")continue;let o=[];for(let s=r+1;s<t.length;s+=1){let a=t[s];if(!a||Mt.has(a))break;a!=="--"&&(a.startsWith("-")||o.push(a))}if(o.length<2)continue;let i=o.at(-1);if(he(i)){for(let s of o.slice(0,-1))if(Dt(s)&&ye(s))return{sourcePath:s,destinationPath:i,operation:n}}}return null}function Bt(e){let t=[/\bcat\s+(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))\s*>\s*(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/i,/\bdd\b[\s\S]*?\bif=(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))[\s\S]*?\bof=(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/i];for(let r of t){let n=e.match(r);if(!n)continue;let o=I(n[1]??n[2]??n[3]??""),i=I(n[4]??n[5]??n[6]??"");if(!(!o||!i)&&ye(o)&&he(i))return{sourcePath:o,destinationPath:i,operation:r.source.startsWith("\\bdd")?"dd":"redirect"}}return null}function Ee(){return process.env.XENO_BENCHMARK_MODE?.trim().toLowerCase()==="terminal-bench"}function be(e){let t=me(e);if(t.includes("solution")||t.includes("xeno-audit")||t.includes(".xeno")&&t.includes("audit"))return!0;let r=ge(t.at(-1)??"");return t.includes("tests")&&$t(r)}function Pn(e){return Ee()?e.filter(t=>!be(t)):e}function Cn(e){return`Benchmark safety: access to verifier answer or benchmark trace artifacts is blocked (${e}). Use task inputs and verifier logic, not golden, solution, or agent audit files.`}function Sn(e){return e.split(/[\s"'`;|&]+/).map(t=>t.trim()).filter(t=>t.length>0&&/[\\/]/.test(t)).some(t=>be(t))}function On(e){if(!Ee())return null;let t=Lt(e)??Bt(e);return t?["[xeno guidance]",`Benchmark safety blocked ${t.operation} from reference-like source ${t.sourcePath} to protected destination ${t.destinationPath}.`,"Do not copy expected, golden, reference, or answer files over task inputs or submission artifacts to make validation pass.","If a previous check polluted an input, restore/regenerate the original source input, then rerun the actual script or program under test."].join(`
|
|
21
|
+
`):null}function Xt(e){return/^data:([^;,]+)[;,]/i.exec(e.trim())?.[1]}function zt(e){let t=[];for(let r of e){if(r.type==="text"){t.push(r.text);continue}if(r.type==="image_url"){t.push(`[image ${Xt(r.image_url.url)??"unknown"}]`);continue}let n=r.text??r.data;if(n&&n.trim().length>0){t.push(n);continue}let o=r.uri??r.mimeType??"resource";t.push(`[resource ${o}]`)}return t.join(`
|
|
22
22
|
|
|
23
|
-
`).trim()}function
|
|
24
|
-
`)}function
|
|
25
|
-
`)}}function pn(e){return Array.isArray(e)&&e.some(t=>t.type!=="text")}function mn(e){return typeof e=="string"?le(e):e}function gn(e,t){return{type:"tool_result",tool_use_id:e,content:At(t),...t.assistantContent&&t.assistantContent.length>0?{assistant_content:t.assistantContent}:{},...t.assistantOnlyContent&&t.assistantOnlyContent.length>0?{assistant_only_content:t.assistantOnlyContent}:{},is_error:!t.success,...t.operation?{operation:t.operation}:{},...t.evidence&&t.evidence.length>0?{evidence:t.evidence}:{},...t.webContext?{web_context:t.webContext}:{},...t.retryable!==void 0?{retryable:t.retryable}:{}}}function hn(e,t={}){for(let r of e){let n=r.codePointAt(0);if(n===127)return!0;if(!(n>31)&&!(n===9&&t.allowTab===!0)&&!((n===10||n===13)&&t.allowLineBreaks===!0))return!0}return!1}import{lookup as Ct}from"node:dns/promises";import{isIP as O}from"node:net";var E="[redacted]";var kt=[[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,"[redacted:private-key]"],[/((?:^|[\s{,;"'(\[])["']?(?:cookie|set-cookie)["']?\s*[:=]\s*["']?)(?!\[redacted)[^\s"',;]+(?:;\s*[^\s"',;=]+=[^\s"',;]*)*/gi,`$1${E}`],[/((?:^|[\s{,;"'(\[])["']?(?:authorization|proxy-authorization|x-api-key|x-goog-api-key|x-xeno-api-key|api[-_]?key|apikey|dpop)["']?\s*[:=]\s*["']?)(?:(?:Bearer|Basic|Token|DPoP)\s+)?(?!\[redacted)[^\s"',;]+/gi,`$1${E}`],[/\b(Bearer|Basic|Token|DPoP)\s+[A-Za-z0-9._~+/=-]{6,}/gi,`$1 ${E}`],[/\b(?:sk-(?:ant-|proj-)?[A-Za-z0-9_-]{16,}|xeno-[A-Za-z0-9]{24,}|xrun_[A-Za-z0-9_-]{8,}|AIza[0-9A-Za-z_-]{30,}|gh[pousr]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,}|npm_[A-Za-z0-9]{30,}|xox[baprs]-[A-Za-z0-9-]{16,}|AKIA[0-9A-Z]{16})\b/g,E],[/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,E],[/([?&#;](?:access_token|refresh_token|id_token|token|key|api[_-]?key|secret|client_secret|password|signature|sig)=)[^&#\s"'<>]+/gi,`$1${E}`],[/(\b[a-z][a-z0-9+.-]*:\/\/)[^/\s:@"']+:[^/\s@"']+@/gi,`$1${E}@`]];function fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _(e,t=[]){if(!e)return e;let r=e,n=[...new Set([...t].filter(o=>typeof o=="string"&&o.length>=12))].sort((o,i)=>i.length-o.length);for(let o of n){r=r.replace(new RegExp(`(?<![A-Za-z0-9_-])${fe(o)}(?![A-Za-z0-9_-])`,"g"),E);let i=encodeURIComponent(o);i!==o&&(r=r.replace(new RegExp(`(?<![A-Za-z0-9_-])${fe(i)}(?![A-Za-z0-9_-])`,"g"),E))}for(let[o,i]of kt)o.lastIndex=0,r=r.replace(o,i);return r}function z(e,t,r){try{Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0,enumerable:!1})}catch{}}function H(e,t=[],r=0){if(!(e instanceof Error)||r>6)return e;let n=[...t],o=_(e.message,n);if(o!==e.message&&z(e,"message",o),typeof e.stack=="string"){let s=_(e.stack,n);s!==e.stack&&z(e,"stack",s)}let i=e.cause;if(i instanceof Error)H(i,n,r+1);else if(i!=null){let s;try{s=typeof i=="string"?i:JSON.stringify(i)??String(i)}catch{s=String(i)}let a=_(s,n);a!==s&&z(e,"cause",a)}for(let s of Object.keys(e)){let a=e[s];if(typeof a=="string"){let c=_(a,n);if(c!==a)try{e[s]=c}catch{}}}return e}var I=class extends Error{category;code;retryable;providerId;statusCode;retryAfterMs;requestId;providerCode;remedy;constructor(t,r){super(_(t),r.cause!==void 0?{cause:r.cause}:void 0),this.name="ProviderError",this.category=r.category,this.code=r.code,this.retryable=r.retryable??!1,this.providerId=r.providerId,this.statusCode=r.statusCode,this.retryAfterMs=r.retryAfterMs,this.requestId=r.requestId,r.providerCode!==void 0&&(this.providerCode=r.providerCode),r.remedy!==void 0&&(this.remedy=r.remedy),H(this)}};var ge=new Set(["metadata.google.internal","metadata.azure.internal","instance-data.ec2.internal"]);function m(e){return new I(`Provider endpoint rejected: ${e}`,{category:"endpoint_policy",code:"PROVIDER_ENDPOINT_REJECTED"})}function St(e){let t=e.split(".");if(t.length!==4)return null;let r=t.map(n=>Number(n));return r.every(n=>Number.isInteger(n)&&n>=0&&n<=255)?r:null}function pe(e){let t=St(e);if(!t)return"public";let[r,n]=t;return r===0?"unspecified":r===127?"loopback":r===169&&n===254?"link-local":r===10||r===172&&n>=16&&n<=31||r===192&&n===168?"private":"public"}function w(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];O(t)===6&&(t=new URL(`http://[${t}]`).hostname.slice(1,-1));let r=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(t);if(r){let n=Number.parseInt(r[1],16),o=Number.parseInt(r[2],16);return`${n>>8}.${n&255}.${o>>8}.${o&255}`}return t}function ye(e){let t=w(e);return O(t)===4?pe(t):t==="::"||t==="::0"?"unspecified":t==="::1"?"loopback":t.startsWith("::ffff:")?pe(t.slice(7)):/^f[cd]/.test(t)?"private":/^fe[89ab]/.test(t)?"link-local":"public"}function me(e){return e==="example"||e.endsWith(".example")||e==="test"||e.endsWith(".test")||e==="invalid"||e.endsWith(".invalid")}function It(e){return e==="localhost"||e.endsWith(".localhost")}function he(e,t={}){let r;try{r=new URL(e)}catch{throw m("the URL is invalid")}if(r.username||r.password)throw m("embedded credentials are forbidden");if(r.hash||r.search)throw m("base URLs cannot contain a query or fragment");if(!r.hostname||r.hostname.includes("%"))throw m("the hostname is empty or ambiguous");if(ge.has(r.hostname.toLowerCase()))throw m("cloud metadata destinations are forbidden");if(r.protocol!=="https:"&&r.protocol!=="http:")throw m(`scheme ${r.protocol} is unsupported`);let n=t.profile??"public-https";if(r.protocol==="http:"&&n!=="local-network")throw m("plain HTTP requires the explicit local-network profile");let o=r.hostname.replace(/^\[|\]$/g,""),i=O(o)?ye(o):null;if(i==="link-local"||i==="unspecified")throw m(`${i} destinations are forbidden`);if(n==="public-https"&&(i==="private"||i==="loopback"||It(r.hostname)))throw m("private and loopback destinations require the local-network profile");if(n==="local-network"&&r.protocol==="http:"&&i==="public"&&!t.allowedHosts?.includes(r.hostname))throw m("local-network HTTP must resolve to loopback or a private address");return r}async function Ee(e,t={}){let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(ge.has(r))throw m("cloud metadata destinations are forbidden");let n=new Set((t.allowedHosts??[]).map(s=>s.toLowerCase())),o=O(r)?[r]:me(r)?[]:t.resolveHostname?await t.resolveHostname(r):(await Ct(r,{all:!0,verbatim:!0})).map(s=>s.address);if(!o.length&&!me(r))throw m("DNS resolution returned no addresses");let i=t.profile??"public-https";for(let s of o){let a=ye(s);if(a==="link-local"||a==="unspecified")throw m(`DNS resolved to a forbidden ${a} address`);if(i==="public-https"&&a!=="public"&&!n.has(r))throw m(`DNS resolved public endpoint to ${a} address ${s}`);if(i==="local-network"&&e.protocol==="http:"&&a==="public"&&!n.has(r))throw m(`local-network HTTP resolved to public address ${s}`)}return o}import{request as Ot}from"node:http";import{request as Mt}from"node:https";import{isIP as be}from"node:net";import{once as $t}from"node:events";function we(e,t,r){return{dispatch(n,o){let i,s=!1,a=u=>{s||(s=!0,i?.destroy(),o.onError(u))},c=t[0];if(!c||!be(c)||new URL(n.origin).origin!==e.origin)return queueMicrotask(()=>a(new Error("Provider connection has no authorized pinned address"))),!0;let l=n.headers??{},p=(e.protocol==="https:"?Mt:Ot)(new URL(n.path,e.origin),{method:n.method,headers:l,agent:!1,rejectUnauthorized:!0,lookup:(u,g,R)=>{let h={address:c,family:be(c)};typeof g=="object"&&g.all?R(null,[h]):R(null,c,h.family)}},u=>{i=u;let g=u.rawHeaders.map(h=>Buffer.from(h)),R=()=>u.resume();o.onHeaders(u.statusCode??500,g,R,u.statusMessage??"")===!1&&u.pause(),u.on("data",h=>{o.onData(h)||u.pause()}),u.on("end",()=>{s||(s=!0,o.onComplete(u.rawTrailers.map(h=>Buffer.from(h))))}),u.on("error",a),u.on("aborted",()=>a(new Error("Provider response was interrupted")))});return p.on("socket",u=>{u.once("connect",()=>{if(!u.remoteAddress||w(u.remoteAddress)!==w(c)){p.destroy(new Error("Provider socket did not connect to its authorized address"));return}e.protocol==="http:"&&r?.()}),e.protocol==="https:"&&u.once("secureConnect",()=>{u.authorized&&u.remoteAddress&&w(u.remoteAddress)===w(c)&&r?.()})}),p.on("error",a),o.onConnect(u=>p.destroy(u??new Error("Provider request aborted"))),(async()=>{try{let u=n.body;if(typeof u=="string"||u instanceof Uint8Array)p.end(u);else{if(u)for await(let g of u){if(p.destroyed)return;p.write(g)||await $t(p,"drain")}p.end()}}catch(u){p.destroy(u instanceof Error?u:new Error("Provider request body failed"))}})(),!0}}}async function Hn(e,t,r={}){let n=new URL(e.toString()),o=new URL(n);o.search="",o.hash="",he(o.toString(),r.policy),t.signal?.throwIfAborted();let i=await Re(Ee(o,r.policy),t.signal);if(!i.length)throw new Error("Pinned endpoint resolution returned no addresses.");if(r.authorizeAddress&&i.some(c=>r.authorizeAddress(w(c),new URL(n))!==!0))throw new Error("Pinned endpoint resolved outside the authorized address scope.");t.signal?.throwIfAborted();let s=fetch(n,{...t,redirect:"manual",credentials:"omit",dispatcher:we(n,i)});s.then(c=>{t.signal?.aborted&&c.body?.cancel().catch(()=>{})},()=>{});let a=await Re(s,t.signal);if(a.redirected)throw await a.body?.cancel(),new Error("Pinned endpoint transport followed a redirect without authorization.");return a}async function Re(e,t){if(!t)return e;let r,n=new Promise((o,i)=>{r=()=>i(t.reason??new Error("Pinned endpoint read cancelled.")),t.addEventListener("abort",r,{once:!0}),t.aborted&&r()});try{return await Promise.race([e,n])}finally{t.removeEventListener("abort",r)}}export{C as ApiTransientError,Rr as HOME_DIR,br as IS_LINUX,Er as IS_MAC,v as IS_WINDOWS,tt as LogLevel,wr as OS_VERSION,X as PLATFORM,Kr as accountTextTokens,zt as appendDurableLine,Ft as appendLine,an as benchmarkLeakError,gn as buildToolResultBlock,At as buildToolResultText,Qr as calculateCost,cn as commandMentionsBenchmarkLeak,ft as conservativeTokenAccountingAdapter,nn as copyTextToClipboard,Mr as createSafeRegex,Br as debug,ke as decodeTextBuffer,Zt as deleteDir,Yt as deleteFile,Se as detectLineEnding,qt as detectPreferredLineEnding,Pe as detectTextEncoding,Ce as encodeTextBuffer,$ as ensureDir,zr as error,pt as estimateTokens,lt as estimateTokensForModel,Wt as existsSync,Hn as fetchPinnedEndpoint,sn as filterBenchmarkLeakPaths,Vt as findSimilarFile,Yr as fitsInBudget,en as formatCost,xr as getAgentHome,un as getBenchmarkReferenceOverwriteHint,Or as getBoolean,Tr as getConfigDir,Dr as getLogLevel,Ir as getNumber,_r as getProjectConfigDir,re as getRetryErrorContext,vr as getShellName,Sr as getString,fn as getToolResultTransportContent,Bt as hasDir,hn as hasDisallowedAsciiControlCharacter,Dt as hasFile,ir as hasFrontmatter,Ht as hasMixedLineEndings,pn as hasNonTextToolResultContent,ct as hasTransientStatusMention,Xr as info,de as isBenchmarkLeakPath,ue as isBenchmarkMode,Ar as isGitRepo,Pr as isGitRepoAsync,Be as isPathSafe,ut as isRetryableError,Gt as listDirs,Kt as listFiles,Ie as normalizeLineEndings,Ur as normalizeXenoRequestContext,nr as parseDocument,tr as parseJsonLines,cr as pathIdentityKey,Xt as readFileSafe,jt as readIfExists,Oe as readTextFile,Zr as remainingBudget,Ae as renameReplacingWithRetry,Qt as safeJsonParse,er as safeJsonStringify,$r as safeRegexTest,ar as safeResolvePath,Lr as setLogLevel,or as stringifyDocument,mn as toTransportAssistantBlocks,vt as toolAssistantContentToText,ln as toolResultContentToText,Gr as truncateToTokens,et as validateRegexPattern,Cr as validateRequired,Fr as warn,jr as withRetry,Te as writeAtomic,Ut as writeTextFile,qr as xenoRequestContextHeaders};
|
|
23
|
+
`).trim()}function we(e){let t=e.trim();return t.length>0?[{type:"text",text:t}]:[]}function Mn(e){return typeof e=="string"?e:zt(e)}function Ft(e){if(e.success)return e.output;let t=[`Error: ${e.error??"Tool execution failed"}`];return e.output.trim().length>0&&t.push(e.output),t.join(`
|
|
24
|
+
`)}function $n(e){let t=e.assistant_content&&e.assistant_content.length>0?e.assistant_content:typeof e.content=="string"?we(e.content):e.content,r=e.assistant_only_content??[],n=Ht(e),o=[...t,...r,...n?[n]:[]];return o.length>0?o:e.content}function Ht(e){let t=e.operation;if(!t)return null;let r=e.evidence??t.evidence??[],n=r.filter(i=>i.status==="verified").length,o=r.filter(i=>i.status==="failed").length;return{type:"text",text:["[xeno_operation]",`operation_id: ${t.operationId}`,`state: ${t.state}`,`terminal: ${t.terminal?"yes":"no"}`,`completion_policy: ${t.completionPolicy}`,t.taskId?`task_id: ${t.taskId}`:null,t.completionReason?`completion_reason: ${t.completionReason}`:null,`evidence: ${n} verified, ${o} failed`,e.retryable===void 0?null:`retryable: ${e.retryable?"yes":"no"}`,"[/xeno_operation]"].filter(i=>!!i).join(`
|
|
25
|
+
`)}}function Nn(e){return Array.isArray(e)&&e.some(t=>t.type!=="text")}function Dn(e){return typeof e=="string"?we(e):e}function Ln(e,t){return{type:"tool_result",tool_use_id:e,content:Ft(t),...t.assistantContent&&t.assistantContent.length>0?{assistant_content:t.assistantContent}:{},...t.assistantOnlyContent&&t.assistantOnlyContent.length>0?{assistant_only_content:t.assistantOnlyContent}:{},is_error:!t.success,...t.operation?{operation:t.operation}:{},...t.evidence&&t.evidence.length>0?{evidence:t.evidence}:{},...t.webContext?{web_context:t.webContext}:{},...t.retryable!==void 0?{retryable:t.retryable}:{}}}function Xn(e,t={}){for(let r of e){let n=r.codePointAt(0);if(n===127)return!0;if(!(n>31)&&!(n===9&&t.allowTab===!0)&&!((n===10||n===13)&&t.allowLineBreaks===!0))return!0}return!1}import{lookup as Ut}from"node:dns/promises";import{isIP as $}from"node:net";var b="[redacted]";var qt=[[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,"[redacted:private-key]"],[/((?:^|[\s{,;"'(\[])["']?(?:cookie|set-cookie)["']?\s*[:=]\s*["']?)(?!\[redacted)[^\s"',;]+(?:;\s*[^\s"',;=]+=[^\s"',;]*)*/gi,`$1${b}`],[/((?:^|[\s{,;"'(\[])["']?(?:authorization|proxy-authorization|x-api-key|x-goog-api-key|x-xeno-api-key|api[-_]?key|apikey|dpop)["']?\s*[:=]\s*["']?)(?:(?:Bearer|Basic|Token|DPoP)\s+)?(?!\[redacted)[^\s"',;]+/gi,`$1${b}`],[/\b(Bearer|Basic|Token|DPoP)\s+[A-Za-z0-9._~+/=-]{6,}/gi,`$1 ${b}`],[/\b(?:sk-(?:ant-|proj-)?[A-Za-z0-9_-]{16,}|xeno-[A-Za-z0-9]{24,}|xrun_[A-Za-z0-9_-]{8,}|AIza[0-9A-Za-z_-]{30,}|gh[pousr]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,}|npm_[A-Za-z0-9]{30,}|xox[baprs]-[A-Za-z0-9-]{16,}|AKIA[0-9A-Z]{16})\b/g,b],[/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,b],[/([?&#;](?:access_token|refresh_token|id_token|token|key|api[_-]?key|secret|client_secret|password|signature|sig)=)[^&#\s"'<>]+/gi,`$1${b}`],[/(\b[a-z][a-z0-9+.-]*:\/\/)[^/\s:@"']+:[^/\s@"']+@/gi,`$1${b}@`]];function Re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function A(e,t=[]){if(!e)return e;let r=e,n=[...new Set([...t].filter(o=>typeof o=="string"&&o.length>=12))].sort((o,i)=>i.length-o.length);for(let o of n){r=r.replace(new RegExp(`(?<![A-Za-z0-9_-])${Re(o)}(?![A-Za-z0-9_-])`,"g"),b);let i=encodeURIComponent(o);i!==o&&(r=r.replace(new RegExp(`(?<![A-Za-z0-9_-])${Re(i)}(?![A-Za-z0-9_-])`,"g"),b))}for(let[o,i]of qt)o.lastIndex=0,r=r.replace(o,i);return r}function V(e,t,r){try{Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0,enumerable:!1})}catch{}}function W(e,t=[],r=0){if(!(e instanceof Error)||r>6)return e;let n=[...t],o=A(e.message,n);if(o!==e.message&&V(e,"message",o),typeof e.stack=="string"){let s=A(e.stack,n);s!==e.stack&&V(e,"stack",s)}let i=e.cause;if(i instanceof Error)W(i,n,r+1);else if(i!=null){let s;try{s=typeof i=="string"?i:JSON.stringify(i)??String(i)}catch{s=String(i)}let a=A(s,n);a!==s&&V(e,"cause",a)}for(let s of Object.keys(e)){let a=e[s];if(typeof a=="string"){let c=A(a,n);if(c!==a)try{e[s]=c}catch{}}}return e}var M=class extends Error{category;code;retryable;providerId;statusCode;retryAfterMs;requestId;providerCode;remedy;constructor(t,r){super(A(t),r.cause!==void 0?{cause:r.cause}:void 0),this.name="ProviderError",this.category=r.category,this.code=r.code,this.retryable=r.retryable??!1,this.providerId=r.providerId,this.statusCode=r.statusCode,this.retryAfterMs=r.retryAfterMs,this.requestId=r.requestId,r.providerCode!==void 0&&(this.providerCode=r.providerCode),r.remedy!==void 0&&(this.remedy=r.remedy),W(this)}};var _e=new Set(["metadata.google.internal","metadata.azure.internal","instance-data.ec2.internal"]);function m(e){return new M(`Provider endpoint rejected: ${e}`,{category:"endpoint_policy",code:"PROVIDER_ENDPOINT_REJECTED"})}function jt(e){let t=e.split(".");if(t.length!==4)return null;let r=t.map(n=>Number(n));return r.every(n=>Number.isInteger(n)&&n>=0&&n<=255)?r:null}function xe(e){let t=jt(e);if(!t)return"public";let[r,n]=t;return r===0?"unspecified":r===127?"loopback":r===169&&n===254?"link-local":r===10||r===172&&n>=16&&n<=31||r===192&&n===168?"private":"public"}function R(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];$(t)===6&&(t=new URL(`http://[${t}]`).hostname.slice(1,-1));let r=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(t);if(r){let n=Number.parseInt(r[1],16),o=Number.parseInt(r[2],16);return`${n>>8}.${n&255}.${o>>8}.${o&255}`}return t}function ve(e){let t=R(e);return $(t)===4?xe(t):t==="::"||t==="::0"?"unspecified":t==="::1"?"loopback":t.startsWith("::ffff:")?xe(t.slice(7)):/^f[cd]/.test(t)?"private":/^fe[89ab]/.test(t)?"link-local":"public"}function Te(e){return e==="example"||e.endsWith(".example")||e==="test"||e.endsWith(".test")||e==="invalid"||e.endsWith(".invalid")}function Vt(e){return e==="localhost"||e.endsWith(".localhost")}function Ae(e,t={}){let r;try{r=new URL(e)}catch{throw m("the URL is invalid")}if(r.username||r.password)throw m("embedded credentials are forbidden");if(r.hash||r.search)throw m("base URLs cannot contain a query or fragment");if(!r.hostname||r.hostname.includes("%"))throw m("the hostname is empty or ambiguous");if(_e.has(r.hostname.toLowerCase()))throw m("cloud metadata destinations are forbidden");if(r.protocol!=="https:"&&r.protocol!=="http:")throw m(`scheme ${r.protocol} is unsupported`);let n=t.profile??"public-https";if(r.protocol==="http:"&&n!=="local-network")throw m("plain HTTP requires the explicit local-network profile");let o=r.hostname.replace(/^\[|\]$/g,""),i=$(o)?ve(o):null;if(i==="link-local"||i==="unspecified")throw m(`${i} destinations are forbidden`);if(n==="public-https"&&(i==="private"||i==="loopback"||Vt(r.hostname)))throw m("private and loopback destinations require the local-network profile");if(n==="local-network"&&r.protocol==="http:"&&i==="public"&&!t.allowedHosts?.includes(r.hostname))throw m("local-network HTTP must resolve to loopback or a private address");return r}async function ke(e,t={}){let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(_e.has(r))throw m("cloud metadata destinations are forbidden");let n=new Set((t.allowedHosts??[]).map(s=>s.toLowerCase())),o=$(r)?[r]:Te(r)?[]:t.resolveHostname?await t.resolveHostname(r):(await Ut(r,{all:!0,verbatim:!0})).map(s=>s.address);if(!o.length&&!Te(r))throw m("DNS resolution returned no addresses");let i=t.profile??"public-https";for(let s of o){let a=ve(s);if(a==="link-local"||a==="unspecified")throw m(`DNS resolved to a forbidden ${a} address`);if(i==="public-https"&&a!=="public"&&!n.has(r))throw m(`DNS resolved public endpoint to ${a} address ${s}`);if(i==="local-network"&&e.protocol==="http:"&&a==="public"&&!n.has(r))throw m(`local-network HTTP resolved to public address ${s}`)}return o}import{request as Wt}from"node:http";import{request as Kt}from"node:https";import{isIP as Pe}from"node:net";import{once as Gt}from"node:events";function Ce(e,t,r){return{dispatch(n,o){let i,s=!1,a=u=>{s||(s=!0,i?.destroy(),o.onError(u))},c=t[0];if(!c||!Pe(c)||new URL(n.origin).origin!==e.origin)return queueMicrotask(()=>a(new Error("Provider connection has no authorized pinned address"))),!0;let l=n.headers??{},f=(e.protocol==="https:"?Kt:Wt)(new URL(n.path,e.origin),{method:n.method,headers:l,agent:!1,rejectUnauthorized:!0,lookup:(u,g,x)=>{let h={address:c,family:Pe(c)};typeof g=="object"&&g.all?x(null,[h]):x(null,c,h.family)}},u=>{i=u;let g=u.rawHeaders.map(h=>Buffer.from(h)),x=()=>u.resume();o.onHeaders(u.statusCode??500,g,x,u.statusMessage??"")===!1&&u.pause(),u.on("data",h=>{o.onData(h)||u.pause()}),u.on("end",()=>{s||(s=!0,o.onComplete(u.rawTrailers.map(h=>Buffer.from(h))))}),u.on("error",a),u.on("aborted",()=>a(new Error("Provider response was interrupted")))});return f.on("socket",u=>{u.once("connect",()=>{if(!u.remoteAddress||R(u.remoteAddress)!==R(c)){f.destroy(new Error("Provider socket did not connect to its authorized address"));return}e.protocol==="http:"&&r?.()}),e.protocol==="https:"&&u.once("secureConnect",()=>{u.authorized&&u.remoteAddress&&R(u.remoteAddress)===R(c)&&r?.()})}),f.on("error",a),o.onConnect(u=>f.destroy(u??new Error("Provider request aborted"))),(async()=>{try{let u=n.body;if(typeof u=="string"||u instanceof Uint8Array)f.end(u);else{if(u)for await(let g of u){if(f.destroyed)return;f.write(g)||await Gt(f,"drain")}f.end()}}catch(u){f.destroy(u instanceof Error?u:new Error("Provider request body failed"))}})(),!0}}}async function lo(e,t,r={}){let n=new URL(e.toString()),o=new URL(n);o.search="",o.hash="",Ae(o.toString(),r.policy),t.signal?.throwIfAborted();let i=await Se(ke(o,r.policy),t.signal);if(!i.length)throw new Error("Pinned endpoint resolution returned no addresses.");if(r.authorizeAddress&&i.some(c=>r.authorizeAddress(R(c),new URL(n))!==!0))throw new Error("Pinned endpoint resolved outside the authorized address scope.");t.signal?.throwIfAborted();let s=fetch(n,{...t,redirect:"manual",credentials:"omit",dispatcher:Ce(n,i)});s.then(c=>{t.signal?.aborted&&c.body?.cancel().catch(()=>{})},()=>{});let a=await Se(s,t.signal);if(a.redirected)throw await a.body?.cancel(),new Error("Pinned endpoint transport followed a redirect without authorization.");return a}async function Se(e,t){if(!t)return e;let r,n=new Promise((o,i)=>{r=()=>i(t.reason??new Error("Pinned endpoint read cancelled.")),t.addEventListener("abort",r,{once:!0}),t.aborted&&r()});try{return await Promise.race([e,n])}finally{t.removeEventListener("abort",r)}}export{O as ApiTransientError,qr as HOME_DIR,Fr as IS_LINUX,zr as IS_MAC,k as IS_WINDOWS,mt as LogLevel,Hr as OS_VERSION,U as PLATFORM,hn as accountTextTokens,ur as appendDurableLine,cr as appendLine,Cn as benchmarkLeakError,Ln as buildToolResultBlock,Ft as buildToolResultText,xn as calculateCost,Qt as clearFileCache,Sn as commandMentionsBenchmarkLeak,kt as conservativeTokenAccountingAdapter,An as copyTextToClipboard,tn as createSafeRegex,an as debug,Fe as decodeTextBuffer,br as deleteDir,Er as deleteFile,qe as detectLineEnding,fr as detectPreferredLineEnding,ze as detectTextEncoding,He as encodeTextBuffer,X as ensureDir,dn as error,Pt as estimateTokens,At as estimateTokensForModel,gr as existsSync,lo as fetchPinnedEndpoint,Pn as filterBenchmarkLeakPaths,pr as findSimilarFile,bn as fitsInBudget,Tn as formatCost,Ur as getAgentHome,On as getBenchmarkReferenceOverwriteHint,en as getBoolean,jr as getConfigDir,Zt as getFileCacheStats,sn as getLogLevel,Qr as getNumber,Vr as getProjectConfigDir,le as getRetryErrorContext,Wr as getShellName,Jr as getString,$n as getToolResultTransportContent,sr as hasDir,Xn as hasDisallowedAsciiControlCharacter,ir as hasFile,kr as hasFrontmatter,dr as hasMixedLineEndings,Nn as hasNonTextToolResultContent,Tt as hasTransientStatusMention,cn as info,L as invalidateFileCache,be as isBenchmarkLeakPath,Ee as isBenchmarkMode,Kr as isGitRepo,Gr as isGitRepoAsync,Ze as isPathSafe,_t as isRetryableError,hr as listDirs,yr as listFiles,Ue as normalizeLineEndings,fn as normalizeXenoRequestContext,vr as parseDocument,Tr as parseJsonLines,Sr as pathIdentityKey,$e as readDerivedCached,ar as readFileSafe,mr as readIfExists,er as readTextCached,je as readTextFile,wn as remainingBudget,Xe as renameReplacingWithRetry,Jt as resetFileCacheStats,Rr as safeJsonParse,xr as safeJsonStringify,rn as safeRegexTest,Cr as safeResolvePath,on as setLogLevel,Ar as stringifyDocument,Dn as toTransportAssistantBlocks,zt as toolAssistantContentToText,Mn as toolResultContentToText,En as truncateToTokens,pt as validateRegexPattern,Zr as validateRequired,un as warn,gn as withRetry,De as writeAtomic,lr as writeTextFile,pn as xenoRequestContextHeaders};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/utils/fs.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/utils/file-cache.ts":{"bytes":6195,"imports":[{"path":"node:fs","kind":"import-statement","external":true}],"format":"esm"},"src/utils/fs.ts":{"bytes":13885,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/file-cache.ts","kind":"import-statement","original":"./file-cache.js"}],"format":"esm"},"src/utils/json.ts":{"bytes":804,"imports":[],"format":"esm"},"src/utils/yaml.ts":{"bytes":5506,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":1762,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/runtime/process-tree-kill.ts":{"bytes":9124,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/platform.ts":{"bytes":9633,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/runtime/process-tree-kill.ts","kind":"import-statement","original":"../runtime/process-tree-kill.js"}],"format":"esm"},"src/utils/validation.ts":{"bytes":5336,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3719,"imports":[],"format":"esm"},"src/utils/request-context.ts":{"bytes":6154,"imports":[],"format":"esm"},"src/utils/retry.ts":{"bytes":13190,"imports":[],"format":"esm"},"src/utils/tokens.ts":{"bytes":3207,"imports":[],"format":"esm"},"src/utils/cost.ts":{"bytes":1826,"imports":[],"format":"esm"},"src/utils/clipboard.ts":{"bytes":1156,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/benchmark-safety.ts":{"bytes":6542,"imports":[],"format":"esm"},"src/utils/tool-result-content.ts":{"bytes":4820,"imports":[],"format":"esm"},"src/utils/text-security.ts":{"bytes":809,"imports":[],"format":"esm"},"src/observability/telemetry.ts":{"bytes":7271,"imports":[{"path":"node:perf_hooks","kind":"import-statement","external":true}],"format":"esm"},"src/observability/index.ts":{"bytes":32,"imports":[{"path":"src/observability/telemetry.ts","kind":"import-statement","original":"./telemetry.js"}],"format":"esm"},"src/utils/context-overflow-phrases.ts":{"bytes":2266,"imports":[],"format":"esm"},"src/providers/provider-error-redaction.ts":{"bytes":9369,"imports":[],"format":"esm"},"src/providers/provider-errors.ts":{"bytes":19820,"imports":[{"path":"src/observability/index.ts","kind":"import-statement","original":"../observability/index.js"},{"path":"src/utils/context-overflow-phrases.ts","kind":"import-statement","original":"../utils/context-overflow-phrases.js"},{"path":"src/providers/provider-error-redaction.ts","kind":"import-statement","original":"./provider-error-redaction.js"}],"format":"esm"},"src/providers/endpoint-policy.ts":{"bytes":6439,"imports":[{"path":"node:dns/promises","kind":"import-statement","external":true},{"path":"node:net","kind":"import-statement","external":true},{"path":"src/providers/provider-errors.ts","kind":"import-statement","original":"./provider-errors.js"}],"format":"esm"},"src/providers/pinned-provider-dispatcher.ts":{"bytes":4419,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:net","kind":"import-statement","external":true},{"path":"node:events","kind":"import-statement","external":true},{"path":"src/providers/endpoint-policy.ts","kind":"import-statement","original":"./endpoint-policy.js"}],"format":"esm"},"src/utils/pinned-fetch.ts":{"bytes":2516,"imports":[{"path":"src/providers/endpoint-policy.ts","kind":"import-statement","original":"../providers/endpoint-policy.js"},{"path":"src/providers/pinned-provider-dispatcher.ts","kind":"import-statement","original":"../providers/pinned-provider-dispatcher.js"}],"format":"esm"},"src/utils/index.ts":{"bytes":1559,"imports":[{"path":"src/utils/fs.ts","kind":"import-statement","original":"./fs.js"},{"path":"src/utils/file-cache.ts","kind":"import-statement","original":"./file-cache.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"./json.js"},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"./yaml.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"./path-security.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"./platform.js"},{"path":"src/utils/validation.ts","kind":"import-statement","original":"./validation.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"./logger.js"},{"path":"src/utils/request-context.ts","kind":"import-statement","original":"./request-context.js"},{"path":"src/utils/retry.ts","kind":"import-statement","original":"./retry.js"},{"path":"src/utils/tokens.ts","kind":"import-statement","original":"./tokens.js"},{"path":"src/utils/cost.ts","kind":"import-statement","original":"./cost.js"},{"path":"src/utils/clipboard.ts","kind":"import-statement","original":"./clipboard.js"},{"path":"src/utils/benchmark-safety.ts","kind":"import-statement","original":"./benchmark-safety.js"},{"path":"src/utils/tool-result-content.ts","kind":"import-statement","original":"./tool-result-content.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"./text-security.js"},{"path":"src/utils/pinned-fetch.ts","kind":"import-statement","original":"./pinned-fetch.js"}],"format":"esm"}},"outputs":{"dist/utils/index.cjs":{"imports":[{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:dns/promises","kind":"require-call","external":true},{"path":"node:net","kind":"require-call","external":true},{"path":"node:http","kind":"require-call","external":true},{"path":"node:https","kind":"require-call","external":true},{"path":"node:net","kind":"require-call","external":true},{"path":"node:events","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/utils/index.ts","inputs":{"src/utils/index.ts":{"bytesInOutput":2301},"src/utils/fs.ts":{"bytesInOutput":4947},"src/utils/file-cache.ts":{"bytesInOutput":1349},"src/utils/json.ts":{"bytesInOutput":239},"src/utils/yaml.ts":{"bytesInOutput":2651},"src/utils/path-security.ts":{"bytesInOutput":405},"src/utils/platform.ts":{"bytesInOutput":2666},"src/runtime/process-tree-kill.ts":{"bytesInOutput":1696},"src/utils/validation.ts":{"bytesInOutput":1425},"src/utils/logger.ts":{"bytesInOutput":915},"src/utils/request-context.ts":{"bytesInOutput":2188},"src/utils/retry.ts":{"bytesInOutput":3396},"src/utils/tokens.ts":{"bytesInOutput":904},"src/utils/cost.ts":{"bytesInOutput":933},"src/utils/clipboard.ts":{"bytesInOutput":604},"src/utils/benchmark-safety.ts":{"bytesInOutput":3108},"src/utils/tool-result-content.ts":{"bytesInOutput":2118},"src/utils/text-security.ts":{"bytesInOutput":180},"src/providers/endpoint-policy.ts":{"bytesInOutput":3297},"src/observability/index.ts":{"bytesInOutput":0},"src/providers/provider-error-redaction.ts":{"bytesInOutput":2161},"src/providers/provider-errors.ts":{"bytesInOutput":514},"src/providers/pinned-provider-dispatcher.ts":{"bytesInOutput":1672},"src/utils/pinned-fetch.ts":{"bytesInOutput":1027}},"bytes":42893}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/utils/fs.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/utils/file-cache.ts":{"bytes":6195,"imports":[{"path":"node:fs","kind":"import-statement","external":true}],"format":"esm"},"src/utils/fs.ts":{"bytes":13885,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/file-cache.ts","kind":"import-statement","original":"./file-cache.js"}],"format":"esm"},"src/utils/json.ts":{"bytes":804,"imports":[],"format":"esm"},"src/utils/yaml.ts":{"bytes":5506,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":1762,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/runtime/process-tree-kill.ts":{"bytes":9124,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/platform.ts":{"bytes":9633,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/runtime/process-tree-kill.ts","kind":"import-statement","original":"../runtime/process-tree-kill.js"}],"format":"esm"},"src/utils/validation.ts":{"bytes":5336,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3719,"imports":[],"format":"esm"},"src/utils/request-context.ts":{"bytes":6154,"imports":[],"format":"esm"},"src/utils/retry.ts":{"bytes":13190,"imports":[],"format":"esm"},"src/utils/tokens.ts":{"bytes":3207,"imports":[],"format":"esm"},"src/utils/cost.ts":{"bytes":1826,"imports":[],"format":"esm"},"src/utils/clipboard.ts":{"bytes":1156,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/benchmark-safety.ts":{"bytes":6542,"imports":[],"format":"esm"},"src/utils/tool-result-content.ts":{"bytes":4820,"imports":[],"format":"esm"},"src/utils/text-security.ts":{"bytes":809,"imports":[],"format":"esm"},"src/observability/telemetry.ts":{"bytes":7271,"imports":[{"path":"node:perf_hooks","kind":"import-statement","external":true}],"format":"esm"},"src/observability/index.ts":{"bytes":32,"imports":[{"path":"src/observability/telemetry.ts","kind":"import-statement","original":"./telemetry.js"}],"format":"esm"},"src/utils/context-overflow-phrases.ts":{"bytes":2266,"imports":[],"format":"esm"},"src/providers/provider-error-redaction.ts":{"bytes":9369,"imports":[],"format":"esm"},"src/providers/provider-errors.ts":{"bytes":19820,"imports":[{"path":"src/observability/index.ts","kind":"import-statement","original":"../observability/index.js"},{"path":"src/utils/context-overflow-phrases.ts","kind":"import-statement","original":"../utils/context-overflow-phrases.js"},{"path":"src/providers/provider-error-redaction.ts","kind":"import-statement","original":"./provider-error-redaction.js"}],"format":"esm"},"src/providers/endpoint-policy.ts":{"bytes":6439,"imports":[{"path":"node:dns/promises","kind":"import-statement","external":true},{"path":"node:net","kind":"import-statement","external":true},{"path":"src/providers/provider-errors.ts","kind":"import-statement","original":"./provider-errors.js"}],"format":"esm"},"src/providers/pinned-provider-dispatcher.ts":{"bytes":4419,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:net","kind":"import-statement","external":true},{"path":"node:events","kind":"import-statement","external":true},{"path":"src/providers/endpoint-policy.ts","kind":"import-statement","original":"./endpoint-policy.js"}],"format":"esm"},"src/utils/pinned-fetch.ts":{"bytes":2516,"imports":[{"path":"src/providers/endpoint-policy.ts","kind":"import-statement","original":"../providers/endpoint-policy.js"},{"path":"src/providers/pinned-provider-dispatcher.ts","kind":"import-statement","original":"../providers/pinned-provider-dispatcher.js"}],"format":"esm"},"src/utils/index.ts":{"bytes":1559,"imports":[{"path":"src/utils/fs.ts","kind":"import-statement","original":"./fs.js"},{"path":"src/utils/file-cache.ts","kind":"import-statement","original":"./file-cache.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"./json.js"},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"./yaml.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"./path-security.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"./platform.js"},{"path":"src/utils/validation.ts","kind":"import-statement","original":"./validation.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"./logger.js"},{"path":"src/utils/request-context.ts","kind":"import-statement","original":"./request-context.js"},{"path":"src/utils/retry.ts","kind":"import-statement","original":"./retry.js"},{"path":"src/utils/tokens.ts","kind":"import-statement","original":"./tokens.js"},{"path":"src/utils/cost.ts","kind":"import-statement","original":"./cost.js"},{"path":"src/utils/clipboard.ts","kind":"import-statement","original":"./clipboard.js"},{"path":"src/utils/benchmark-safety.ts","kind":"import-statement","original":"./benchmark-safety.js"},{"path":"src/utils/tool-result-content.ts","kind":"import-statement","original":"./tool-result-content.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"./text-security.js"},{"path":"src/utils/pinned-fetch.ts","kind":"import-statement","original":"./pinned-fetch.js"}],"format":"esm"}},"outputs":{"dist/utils/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:dns/promises","kind":"import-statement","external":true},{"path":"node:net","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:net","kind":"import-statement","external":true},{"path":"node:events","kind":"import-statement","external":true}],"exports":["ApiTransientError","HOME_DIR","IS_LINUX","IS_MAC","IS_WINDOWS","LogLevel","OS_VERSION","PLATFORM","accountTextTokens","appendDurableLine","appendLine","benchmarkLeakError","buildToolResultBlock","buildToolResultText","calculateCost","clearFileCache","commandMentionsBenchmarkLeak","conservativeTokenAccountingAdapter","copyTextToClipboard","createSafeRegex","debug","decodeTextBuffer","deleteDir","deleteFile","detectLineEnding","detectPreferredLineEnding","detectTextEncoding","encodeTextBuffer","ensureDir","error","estimateTokens","estimateTokensForModel","existsSync","fetchPinnedEndpoint","filterBenchmarkLeakPaths","findSimilarFile","fitsInBudget","formatCost","getAgentHome","getBenchmarkReferenceOverwriteHint","getBoolean","getConfigDir","getFileCacheStats","getLogLevel","getNumber","getProjectConfigDir","getRetryErrorContext","getShellName","getString","getToolResultTransportContent","hasDir","hasDisallowedAsciiControlCharacter","hasFile","hasFrontmatter","hasMixedLineEndings","hasNonTextToolResultContent","hasTransientStatusMention","info","invalidateFileCache","isBenchmarkLeakPath","isBenchmarkMode","isGitRepo","isGitRepoAsync","isPathSafe","isRetryableError","listDirs","listFiles","normalizeLineEndings","normalizeXenoRequestContext","parseDocument","parseJsonLines","pathIdentityKey","readDerivedCached","readFileSafe","readIfExists","readTextCached","readTextFile","remainingBudget","renameReplacingWithRetry","resetFileCacheStats","safeJsonParse","safeJsonStringify","safeRegexTest","safeResolvePath","setLogLevel","stringifyDocument","toTransportAssistantBlocks","toolAssistantContentToText","toolResultContentToText","truncateToTokens","validateRegexPattern","validateRequired","warn","withRetry","writeAtomic","writeTextFile","xenoRequestContextHeaders"],"entryPoint":"src/utils/index.ts","inputs":{"src/utils/fs.ts":{"bytesInOutput":4891},"src/utils/file-cache.ts":{"bytesInOutput":1327},"src/utils/index.ts":{"bytesInOutput":0},"src/utils/json.ts":{"bytesInOutput":239},"src/utils/yaml.ts":{"bytesInOutput":2651},"src/utils/path-security.ts":{"bytesInOutput":401},"src/utils/platform.ts":{"bytesInOutput":2608},"src/runtime/process-tree-kill.ts":{"bytesInOutput":1715},"src/utils/validation.ts":{"bytesInOutput":1425},"src/utils/logger.ts":{"bytesInOutput":915},"src/utils/request-context.ts":{"bytesInOutput":2188},"src/utils/retry.ts":{"bytesInOutput":3399},"src/utils/tokens.ts":{"bytesInOutput":904},"src/utils/cost.ts":{"bytesInOutput":933},"src/utils/clipboard.ts":{"bytesInOutput":601},"src/utils/benchmark-safety.ts":{"bytesInOutput":3114},"src/utils/tool-result-content.ts":{"bytesInOutput":2118},"src/utils/text-security.ts":{"bytesInOutput":180},"src/providers/endpoint-policy.ts":{"bytesInOutput":3270},"src/observability/index.ts":{"bytesInOutput":0},"src/providers/provider-error-redaction.ts":{"bytesInOutput":2155},"src/providers/provider-errors.ts":{"bytesInOutput":513},"src/providers/pinned-provider-dispatcher.ts":{"bytesInOutput":1672},"src/utils/pinned-fetch.ts":{"bytesInOutput":1027}},"bytes":40421}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xenosystem/agent-sdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.39",
|
|
4
4
|
"description": "XENO Agent SDK built from the same engine as XENO CODE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"@primno/dpapi": "2.0.1"
|
|
211
211
|
},
|
|
212
212
|
"peerDependencies": {
|
|
213
|
-
"@xenosystem/web-context-client": "0.1.
|
|
213
|
+
"@xenosystem/web-context-client": "0.1.2"
|
|
214
214
|
},
|
|
215
215
|
"peerDependenciesMeta": {
|
|
216
216
|
"@xenosystem/web-context-client": {
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
},
|
|
220
220
|
"devDependencies": {
|
|
221
221
|
"@eslint/js": "^9.39.4",
|
|
222
|
-
"@xenosystem/web-context-client": "0.1.
|
|
222
|
+
"@xenosystem/web-context-client": "0.1.2",
|
|
223
223
|
"@types/node": "^22.12.0",
|
|
224
224
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
225
225
|
"eslint": "^9.39.4",
|