@xenosystem/agent-sdk 0.10.38 → 0.10.40
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 +396 -371
- package/dist/index.d.cts +134 -4
- package/dist/index.d.ts +134 -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.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`,"utf-8")}async function
|
|
3
|
-
`,"utf-8"),await n.sync()}finally{await n.close()}}function
|
|
4
|
-
`)?"CRLF":"LF"}function
|
|
1
|
+
"use strict";var st=Object.create;var $=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ut=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!dt.call(e,o)&&o!==r&&$(e,o,{get:()=>t[o],enumerable:!(n=at(t,o))||n.enumerable});return e};var U=(e,t,r)=>(r=e!=null?st(ut(e)):{},ne(t||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e)),ft=e=>ne($({},"__esModule",{value:!0}),e);var gn={};lt(gn,{ApiTransientError:()=>I,HOME_DIR:()=>ir,IS_LINUX:()=>nr,IS_MAC:()=>rr,IS_WINDOWS:()=>k,LogLevel:()=>Ce,OS_VERSION:()=>or,PLATFORM:()=>B,accountTextTokens:()=>Dr,appendDurableLine:()=>At,appendLine:()=>vt,benchmarkLeakError:()=>Qr,buildToolResultBlock:()=>un,buildToolResultText:()=>Ve,calculateCost:()=>Fr,clearFileCache:()=>yt,commandMentionsBenchmarkLeak:()=>en,conservativeTokenAccountingAdapter:()=>Ne,copyTextToClipboard:()=>qr,createSafeRegex:()=>yr,debug:()=>wr,decodeTextBuffer:()=>pe,deleteDir:()=>Lt,deleteFile:()=>Dt,detectLineEnding:()=>ge,detectPreferredLineEnding:()=>Ct,detectTextEncoding:()=>le,encodeTextBuffer:()=>me,ensureDir:()=>L,error:()=>Tr,estimateTokens:()=>De,estimateTokensForModel:()=>$e,existsSync:()=>Mt,fetchPinnedEndpoint:()=>mn,filterBenchmarkLeakPaths:()=>Jr,findSimilarFile:()=>Ot,fitsInBudget:()=>Br,formatCost:()=>Hr,getAgentHome:()=>sr,getBenchmarkReferenceOverwriteHint:()=>tn,getBoolean:()=>gr,getConfigDir:()=>ar,getFileCacheStats:()=>mt,getLogLevel:()=>br,getNumber:()=>mr,getProjectConfigDir:()=>cr,getRetryErrorContext:()=>Z,getShellName:()=>ur,getString:()=>pr,getToolResultTransportContent:()=>on,hasDir:()=>Rt,hasDisallowedAsciiControlCharacter:()=>dn,hasFile:()=>wt,hasFrontmatter:()=>qt,hasMixedLineEndings:()=>kt,hasNonTextToolResultContent:()=>an,hasTransientStatusMention:()=>Ie,info:()=>Rr,invalidateFileCache:()=>D,isBenchmarkLeakPath:()=>Q,isBenchmarkMode:()=>J,isGitRepo:()=>dr,isGitRepoAsync:()=>lr,isPathSafe:()=>xe,isRetryableError:()=>Me,listDirs:()=>Nt,listFiles:()=>$t,normalizeLineEndings:()=>ye,normalizeXenoRequestContext:()=>Pr,parseDocument:()=>Ft,parseJsonLines:()=>zt,pathIdentityKey:()=>Gt,readDerivedCached:()=>ae,readFileSafe:()=>xt,readIfExists:()=>It,readTextCached:()=>bt,readTextFile:()=>he,remainingBudget:()=>Xr,renameReplacingWithRetry:()=>de,resetFileCacheStats:()=>gt,safeJsonParse:()=>Bt,safeJsonStringify:()=>Xt,safeRegexTest:()=>hr,safeResolvePath:()=>Kt,setLogLevel:()=>Er,stringifyDocument:()=>Ht,toTransportAssistantBlocks:()=>cn,toolAssistantContentToText:()=>Ue,toolResultContentToText:()=>nn,truncateToTokens:()=>Lr,validateRegexPattern:()=>Pe,validateRequired:()=>fr,warn:()=>xr,withRetry:()=>Nr,writeAtomic:()=>ue,writeTextFile:()=>Pt,xenoRequestContextHeaders:()=>Sr});module.exports=ft(gn);var O=require("node:fs"),_=require("node:fs"),p=U(require("node:fs/promises"),1),d=U(require("node:path"),1);var N=require("node:fs"),pt=8192,ie=Symbol.for("@xenosystem/agent-sdk/file-cache"),se=globalThis,j=se[ie]??{entries:new Map,counters:{reads:0,hits:0}};se[ie]=j;var E=j.entries,A=j.counters;function mt(){return{...A}}function gt(){A.reads=0,A.hits=0}function D(e){E.delete(e)}function yt(){E.clear()}async function ht(e){try{let t=await N.promises.stat(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(t.code==="ENOENT")return null;throw t}}function oe(e,t){for(E.delete(e),E.set(e,t);E.size>pt;){let r=E.keys().next().value;if(r===void 0)break;E.delete(r)}}async function Et(e,t,r){let n=await N.promises.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 ae(e,t,r,n={}){let o=await ht(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 A.hits+=1,oe(e,i),i.values.get(t);let s,a=n.tailBytes;if(a!==void 0&&o.size>a&&(A.reads+=1,s=r(await Et(e,o.size,a),!0)),s===void 0){let f;try{f=await N.promises.readFile(e,"utf-8")}catch(u){if(u.code==="ENOENT")return E.delete(e),null;throw u}A.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),oe(e,l),s}function bt(e){return ae(e,"text",t=>t)}function wt(e){try{return(0,_.existsSync)(e)&&(0,_.statSync)(e).isFile()}catch{return!1}}function Rt(e){try{return(0,_.existsSync)(e)&&(0,_.statSync)(e).isDirectory()}catch{return!1}}function xt(e,t=""){try{return(0,O.readFileSync)(e,"utf-8")}catch{return t}}async function L(e){await p.mkdir(e,{recursive:!0})}async function ue(e,t){let r=d.dirname(e);await L(r);let n=Math.random().toString(36).substring(2,15),o=`${e}.tmp.${process.pid}.${n}`;try{await p.writeFile(o,t),await de(o,e),D(e)}finally{try{await p.unlink(o)}catch{}}}var Tt=new Set(["EACCES","EBUSY","EPERM"]),_t=[10,20,40,80,160,320,640];async function de(e,t){for(let r=0;;r+=1)try{await p.rename(e,t);return}catch(n){let o=n.code,i=_t[r];if(process.platform!=="win32"||!o||!Tt.has(o)||i===void 0)throw n;await new Promise(s=>setTimeout(s,i))}}async function vt(e,t){let r=d.dirname(e);await L(r),await p.appendFile(e,t+`
|
|
2
|
+
`,"utf-8")}async function At(e,t){let r=d.dirname(e);await L(r);let n=await p.open(e,"a");try{await n.writeFile(t+`
|
|
3
|
+
`,"utf-8"),await n.sync()}finally{await n.close()}}function le(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 fe(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 pe(e,t){switch(t){case"utf8-bom":return e.subarray(3).toString("utf8");case"utf16le":return e.subarray(2).toString("utf16le");case"utf16be":return fe(e.subarray(2)).toString("utf16le");default:return e.toString("utf8")}}function me(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]),fe(Buffer.from(e,"utf16le"))]);default:return Buffer.from(e,"utf8")}}function ge(e){return e.includes(`\r
|
|
4
|
+
`)?"CRLF":"LF"}function ye(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 N(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 ar=/^[A-Za-z0-9:._*-]{1,64}$/,cr=/^[A-Za-z0-9_-][A-Za-z0-9 _-]{0,30}[A-Za-z0-9_-]$/,ur=/^[0-9][0-9A-Za-z.+-]{0,40}$/;function dr(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"||!ar.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"||!cr.test(r.name))throw new TypeError("requestContext.client.name must be 2-32 characters of letters, digits, space, _ or -");if(typeof r.version!="string"||!ur.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 lr(e){return e?{"X-Xeno-Surface":e.surface,...e.client?{"X-Xeno-Client":`${e.client.name}/${e.client.version}`}:{}}:{}}var S=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})}},L={maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4,jitterMs:300};function D(e,t){let r=process.env[e],n=r?Number.parseInt(r,10):Number.NaN;return!Number.isFinite(n)||n<0?t:n}function fr(e={}){let t=Math.max(0,e.maxRetries??D("XENO_API_MAX_RETRIES",L.maxRetries)),r=Math.max(50,e.baseDelayMs??D("XENO_API_BASE_DELAY_MS",L.baseDelayMs)),n=Math.max(r,e.maxDelayMs??D("XENO_API_MAX_DELAY_MS",L.maxDelayMs)),o=Math.max(0,e.jitterMs??D("XENO_API_RETRY_JITTER_MS",L.jitterMs));return{maxRetries:t,baseDelayMs:r,maxDelayMs:n,jitterMs:o}}function pr(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 Re(e){let t=e.toLowerCase();return t.includes("rate limit")||t.includes("too many requests")||t.includes("429")}function mr(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 j(e){if(e instanceof S)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 Re(r)?{statusCode:429}:{}}var V="408|425|429|500|502|503|504";function xe(e){let t=new RegExp(`(?:\\bstatus(?:[ _-]?code)?\\b\\s*[=:]?\\s*|\\bhttp\\b\\s*|\\bapi\\b\\s*|\\bcode\\b\\s*[=:]\\s*|\\berror\\b\\s*)(?:${V})\\b`,"i"),r=new RegExp(`\\b(?:${V})\\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*(?:${V})\\b`);return t.test(e)||r.test(e)||n.test(e)}function Te(e){if(e&&typeof e=="object"&&"retryable"in e)return e.retryable===!0;if(e instanceof S){let{statusCode:t}=j(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:xe(e.message)?!0:Re(e.message)||mr(e.message.toLowerCase())}return!1}function gr(e){if(e.onAbort)return e.onAbort();let t=new Error("The operation was aborted");return t.name="AbortError",t}async function yr(e,t={}){let r=fr(t),n;for(let o=0;o<=r.maxRetries;o++)try{if(t.signal?.aborted)throw gr(t);return t.onBeforeAttempt?.(o),await e()}catch(i){if(n=i,!(t.shouldRetry?t.shouldRetry(i,o):Te(i))||o===r.maxRetries)throw i;let a=j(i),c=pr(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 _e=(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))},ve=Object.freeze({id:"xeno-conservative-v1",source:"estimated",countText:_e,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 hr(e,t,r=ve){return{tokens:Math.max(0,Math.ceil(r.countText(e,t))),source:r.source,adapterId:r.id}}function Ae(e){return e?Math.ceil(e.length/4):0}function Er(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 br(e,t){return Ae(e)<=t}function wr(e,t){return Math.max(0,t-e)}var Rr={"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 xr(e,t,r){let n=Rr[e];return n?t/1e6*n.input+r/1e6*n.output:0}function Tr(e){return e<=0?"$0.00":e<.001?"<$0.001":e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}var Pe=require("node:child_process");function _r(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=(0,Pe.spawnSync)(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 Ce(e){return e.replace(/\\/g,"/").toLowerCase()}var vr=["golden","solution","answer","expected"],Ar=["expected","golden","reference","answer","answers"],Pr=new Set([";","&&","||","|"]);function Se(e){return Ce(e).replace(/^\.\/+/,"").split("/").map(t=>t.trim()).filter(t=>t.length>0)}function kr(e){return vr.some(t=>e.includes(t))}function ke(e){return Ar.some(t=>e.includes(t))}function Ie(e){return e.split("::",1)[0]?.split("?",1)[0]?.split("#",1)[0]??e}function B(e){let t=e.trim().replace(/^[({]+/,"").replace(/[),;]+$/,"");return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),t}function Cr(e){return e.match(/"[^"]*"|'[^']*'|&&|\|\||[;|]|[^\s;|&]+/g)?.map(B).filter(t=>t.length>0)??[]}function Oe(e){let t=Se(e),r=Ie(t.at(-1)??"");return ke(r)||t.some(n=>ke(n))}function Me(e){let t=Ce(B(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 Sr(e){return/[\\/]/.test(e)||/\.[A-Za-z0-9]{1,8}$/.test(e)}function Ir(e){let t=Cr(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||Pr.has(a))break;a!=="--"&&(a.startsWith("-")||o.push(a))}if(o.length<2)continue;let i=o.at(-1);if(Me(i)){for(let s of o.slice(0,-1))if(Sr(s)&&Oe(s))return{sourcePath:s,destinationPath:i,operation:n}}}return null}function Or(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=B(n[1]??n[2]??n[3]??""),i=B(n[4]??n[5]??n[6]??"");if(!(!o||!i)&&Oe(o)&&Me(i))return{sourcePath:o,destinationPath:i,operation:r.source.startsWith("\\bdd")?"dd":"redirect"}}return null}function W(){return process.env.XENO_BENCHMARK_MODE?.trim().toLowerCase()==="terminal-bench"}function K(e){let t=Se(e);if(t.includes("solution")||t.includes("xeno-audit")||t.includes(".xeno")&&t.includes("audit"))return!0;let r=Ie(t.at(-1)??"");return t.includes("tests")&&kr(r)}function Mr(e){return W()?e.filter(t=>!K(t)):e}function $r(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 Nr(e){return e.split(/[\s"'`;|&]+/).map(t=>t.trim()).filter(t=>t.length>0&&/[\\/]/.test(t)).some(t=>K(t))}function Lr(e){if(!W())return null;let t=Ir(e)??Or(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 kt(e){return e.includes(`\r
|
|
7
|
+
`)?/(^|[^\r])\n/.test(e):!1}async function he(e){let t=await p.readFile(e),r=le(t),n=pe(t,r);return{content:n,encoding:r,lineEnding:ge(n),sizeBytes:t.length}}async function Pt(e,t,r){let n=r?.preserveLineEndings?t:ye(t,r?.lineEnding??"LF");await ue(e,me(n,r?.encoding??"utf8"))}async function Ct(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=(0,O.readdirSync)(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 he(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 St(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=(0,O.readdirSync)(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 ce(e,t){let r=d.relative(e,t);return r===""||!r.startsWith("..")&&!d.isAbsolute(r)}function Ot(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&&ce(t,e)?t:void 0,a=i.flatMap(l=>St(l,2,500)).filter(l=>s===void 0||ce(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 v=d.relative(r,l).split(d.sep).length,h=g+v*.01;(!c||h<c.score)&&(c={filePath:l,score:h})}return c?.filePath??null}catch{}return null}async function It(e){try{return await p.readFile(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}function Mt(e){return(0,_.existsSync)(e)}async function $t(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 Nt(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 Dt(e){try{await p.unlink(e)}catch(t){if(t.code!=="ENOENT")throw t}finally{D(e)}}async function Lt(e){try{await p.rm(e,{recursive:!0,force:!0})}catch(t){if(t.code!=="ENOENT")throw t}}function Bt(e,t){try{return JSON.parse(e)}catch{return t}}function Xt(e,t="{}"){try{return JSON.stringify(e)}catch{return t}}function zt(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 Ft(e){let t=Ut(e);return{frontmatter:t.frontmatter,content:t.content.trim()}}function Ht(e,t){let r=Object.fromEntries(Object.entries(e).filter(([n,o])=>o!==void 0));return["---",Re(r),"---","",t].join(`
|
|
9
|
+
`)}function qt(e){return e.trimStart().startsWith("---")}function Ut(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:be(i),content:n.slice(a)}}function be(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=Vt(o,n+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){t[i.key]=we(i.value,n+1);continue}let s=jt(r,n+1);t[i.key]=s.value,n=s.nextIndex-1}return t}function jt(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)=>we(i.trimStart().slice(2),t+s+1)),nextIndex:n}:{value:be(r.join(`
|
|
10
|
+
`)),nextIndex:n}}function Vt(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 we(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 Ee(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 Ee(e,t);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${t}.`);return e}function Ee(e,t){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${t}.`)}}function Re(e,t=""){return Object.entries(e).map(([r,n])=>Wt(r,n,t)).join(`
|
|
11
|
+
`)}function Wt(e,t,r){return Array.isArray(t)?`${r}${e}: ${JSON.stringify(t)}`:t&&typeof t=="object"?`${r}${e}:
|
|
12
|
+
${Re(t,`${r} `)}`:`${r}${e}: ${JSON.stringify(t)}`}var y=U(require("path"),1);function xe(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 Kt(e,t){if(y.isAbsolute(t))return y.resolve(t);if(!xe(e,t))throw new Error(`PathSecurity: Path traversal attempt detected: ${t}`);return y.resolve(e,t)}function Gt(e,t=process.platform){let r=y.resolve(e);return t==="win32"?r.toLowerCase():r}var R=require("node:os"),P=require("node:child_process"),Ae=require("node:fs"),b=require("node:path");var V=require("node:child_process"),Yt=5e3,Te=128;function Zt(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===Te?{...n,terminated:!0,reason:"not-running",exitCode:Te}:{...n,terminated:!1,reason:"failed",exitCode:t.status,detail:`${e} exited with code ${t.status??"unknown"}`}}var Jt=(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=(0,V.spawn)(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 _e(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):Yt}function Qt(e,t){return{terminated:!1,reason:"failed",tool:e,exitCode:null,timeoutMs:t,detail:"pid is not a positive integer"}}function er(e){return["/PID",String(e),"/T","/F"]}async function ve(e,t={}){let r=_e(t.timeoutMs);return!Number.isSafeInteger(e)||e<=0?Qt("taskkill",r):tr("taskkill","taskkill.exe",er(e),{timeoutMs:r,run:t.run})}async function tr(e,t,r,n={}){let o=_e(n.timeoutMs),i;try{i=await(n.run??Jt)(t,r,o)}catch(s){i={status:null,timedOut:!1,error:s instanceof Error?s.message:String(s)}}return Zt(e,i,o)}var B=(0,R.platform)(),k=B==="win32",rr=B==="darwin",nr=B==="linux",or=(0,R.release)(),ir=(0,R.homedir)();function sr(){let e=process.env.XENO_AGENT_HOME?.trim();return e?(0,b.resolve)(e):(0,b.resolve)((0,R.homedir)(),".xeno-agent")}function ar(){let e=process.env.XENO_CONFIG_DIR?.trim();return e?(0,b.resolve)(e):(0,b.resolve)((0,R.homedir)(),".xeno-code")}function cr(e){return(0,b.resolve)(e,".xeno-code")}function ur(){return k?"powershell":process.env.SHELL?.split("/").pop()??"bash"}var K=5e3,G=4096,W=["rev-parse","--is-inside-work-tree"];function ke(){if(!k)return{file:"git",args:W};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(b.delimiter).filter(Boolean)){let r=t.replace(/^"(.*)"$/,"$1");for(let n of e){let o=(0,b.resolve)(r,`git${n}`);try{if(!(0,Ae.statSync)(o).isFile())continue}catch{continue}if(n!==".cmd"&&n!==".bat")return{file:o,args:W};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:(0,b.join)(i,"System32","cmd.exe"),args:["/d","/s","/c",`""${o}" rev-parse --is-inside-work-tree"`],windowsVerbatimArguments:!0}}}return{file:"git",args:W}}function dr(e){try{let t=ke();if(t.windowsVerbatimArguments){let r=(0,P.spawnSync)(t.file,t.args,{cwd:e,encoding:"utf8",windowsHide:!0,windowsVerbatimArguments:!0,timeout:K,maxBuffer:G,stdio:["ignore","pipe","ignore"]});return!r.error&&r.status===0&&r.stdout.trim()==="true"}return(0,P.execFileSync)(t.file,t.args,{cwd:e,encoding:"utf8",windowsHide:!0,timeout:K,maxBuffer:G,stdio:["ignore","pipe","ignore"]}).trim()==="true"}catch{return!1}}function lr(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)ve(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=ke();r=(0,P.spawn)(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,K),r.stdout?.on("data",l=>{if(!n){if(i+=l.byteLength,i>G){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 fr(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 pr(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 mr(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 gr(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 Pe(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 yr(e,t,r=5e3){let n=Pe(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 hr(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 Ce=(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))(Ce||{}),C=1;function Er(e){C=e}function br(){return C}function x(){return new Date().toISOString()}function wr(e,t){C<=0&&(t!==void 0?process.stderr.write(`[${x()}] DEBUG: ${e} ${X(t)}
|
|
13
|
+
`):process.stderr.write(`[${x()}] DEBUG: ${e}
|
|
14
|
+
`))}function Rr(e,t){C<=1&&(t!==void 0?process.stderr.write(`[${x()}] INFO: ${e} ${X(t)}
|
|
15
|
+
`):process.stderr.write(`[${x()}] INFO: ${e}
|
|
16
|
+
`))}function xr(e,t){C<=2&&(t!==void 0?process.stderr.write(`[${x()}] WARN: ${e} ${X(t)}
|
|
17
|
+
`):process.stderr.write(`[${x()}] WARN: ${e}
|
|
18
|
+
`))}function Tr(e,t){C<=3&&(t!==void 0?process.stderr.write(`[${x()}] ERROR: ${e} ${X(t)}
|
|
19
|
+
`):process.stderr.write(`[${x()}] ERROR: ${e}
|
|
20
|
+
`))}function X(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 _r=/^[A-Za-z0-9:._*-]{1,64}$/,vr=/^[A-Za-z0-9_-][A-Za-z0-9 _-]{0,30}[A-Za-z0-9_-]$/,Ar=/^[0-9][0-9A-Za-z.+-]{0,40}$/,Se=Object.freeze({"x-xeno-source":Object.freeze(["auto","quota","credits","byok"]),"x-xeno-byok-mode":Object.freeze(["local","cloud"])}),kr=/^[\x21-\x7E]{1,64}$/;function Pr(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"||!_r.test(e.surface))throw new TypeError("requestContext.surface must match /^[A-Za-z0-9:._*-]{1,64}$/");let r=Cr(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"||!vr.test(o.name))throw new TypeError("requestContext.client.name must be 2-32 characters of letters, digits, space, _ or -");if(typeof o.version!="string"||!Ar.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 Cr(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(Se,o)?Se[o]:void 0;if(!i)throw new TypeError(`requestContext.headers does not accept: ${r}`);if(typeof n!="string"||!kr.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 Sr(e){return e?{...e.headers??{},"X-Xeno-Surface":e.surface,...e.client?{"X-Xeno-Client":`${e.client.name}/${e.client.version}`}:{}}:{}}var I=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})}},z={maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4,jitterMs:300};function F(e,t){let r=process.env[e],n=r?Number.parseInt(r,10):Number.NaN;return!Number.isFinite(n)||n<0?t:n}function Or(e={}){let t=Math.max(0,e.maxRetries??F("XENO_API_MAX_RETRIES",z.maxRetries)),r=Math.max(50,e.baseDelayMs??F("XENO_API_BASE_DELAY_MS",z.baseDelayMs)),n=Math.max(r,e.maxDelayMs??F("XENO_API_MAX_DELAY_MS",z.maxDelayMs)),o=Math.max(0,e.jitterMs??F("XENO_API_RETRY_JITTER_MS",z.jitterMs));return{maxRetries:t,baseDelayMs:r,maxDelayMs:n,jitterMs:o}}function Ir(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 Oe(e){let t=e.toLowerCase();return t.includes("rate limit")||t.includes("too many requests")||t.includes("429")}function Mr(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 Z(e){if(e instanceof I)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 Oe(r)?{statusCode:429}:{}}var Y="408|425|429|500|502|503|504";function Ie(e){let t=new RegExp(`(?:\\bstatus(?:[ _-]?code)?\\b\\s*[=:]?\\s*|\\bhttp\\b\\s*|\\bapi\\b\\s*|\\bcode\\b\\s*[=:]\\s*|\\berror\\b\\s*)(?:${Y})\\b`,"i"),r=new RegExp(`\\b(?:${Y})\\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*(?:${Y})\\b`);return t.test(e)||r.test(e)||n.test(e)}function Me(e){if(e&&typeof e=="object"&&"retryable"in e)return e.retryable===!0;if(e instanceof I){let{statusCode:t}=Z(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:Ie(e.message)?!0:Oe(e.message)||Mr(e.message.toLowerCase())}return!1}function $r(e){if(e.onAbort)return e.onAbort();let t=new Error("The operation was aborted");return t.name="AbortError",t}async function Nr(e,t={}){let r=Or(t),n;for(let o=0;o<=r.maxRetries;o++)try{if(t.signal?.aborted)throw $r(t);return t.onBeforeAttempt?.(o),await e()}catch(i){if(n=i,!(t.shouldRetry?t.shouldRetry(i,o):Me(i))||o===r.maxRetries)throw i;let a=Z(i),c=Ir(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 $e=(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))},Ne=Object.freeze({id:"xeno-conservative-v1",source:"estimated",countText:$e,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 Dr(e,t,r=Ne){return{tokens:Math.max(0,Math.ceil(r.countText(e,t))),source:r.source,adapterId:r.id}}function De(e){return e?Math.ceil(e.length/4):0}function Lr(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 Br(e,t){return De(e)<=t}function Xr(e,t){return Math.max(0,t-e)}var zr={"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 Fr(e,t,r){let n=zr[e];return n?t/1e6*n.input+r/1e6*n.output:0}function Hr(e){return e<=0?"$0.00":e<.001?"<$0.001":e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}var Le=require("node:child_process");function qr(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=(0,Le.spawnSync)(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 Xe(e){return e.replace(/\\/g,"/").toLowerCase()}var Ur=["golden","solution","answer","expected"],jr=["expected","golden","reference","answer","answers"],Vr=new Set([";","&&","||","|"]);function ze(e){return Xe(e).replace(/^\.\/+/,"").split("/").map(t=>t.trim()).filter(t=>t.length>0)}function Wr(e){return Ur.some(t=>e.includes(t))}function Be(e){return jr.some(t=>e.includes(t))}function Fe(e){return e.split("::",1)[0]?.split("?",1)[0]?.split("#",1)[0]??e}function H(e){let t=e.trim().replace(/^[({]+/,"").replace(/[),;]+$/,"");return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),t}function Kr(e){return e.match(/"[^"]*"|'[^']*'|&&|\|\||[;|]|[^\s;|&]+/g)?.map(H).filter(t=>t.length>0)??[]}function He(e){let t=ze(e),r=Fe(t.at(-1)??"");return Be(r)||t.some(n=>Be(n))}function qe(e){let t=Xe(H(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 Gr(e){return/[\\/]/.test(e)||/\.[A-Za-z0-9]{1,8}$/.test(e)}function Yr(e){let t=Kr(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||Vr.has(a))break;a!=="--"&&(a.startsWith("-")||o.push(a))}if(o.length<2)continue;let i=o.at(-1);if(qe(i)){for(let s of o.slice(0,-1))if(Gr(s)&&He(s))return{sourcePath:s,destinationPath:i,operation:n}}}return null}function Zr(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=H(n[1]??n[2]??n[3]??""),i=H(n[4]??n[5]??n[6]??"");if(!(!o||!i)&&He(o)&&qe(i))return{sourcePath:o,destinationPath:i,operation:r.source.startsWith("\\bdd")?"dd":"redirect"}}return null}function J(){return process.env.XENO_BENCHMARK_MODE?.trim().toLowerCase()==="terminal-bench"}function Q(e){let t=ze(e);if(t.includes("solution")||t.includes("xeno-audit")||t.includes(".xeno")&&t.includes("audit"))return!0;let r=Fe(t.at(-1)??"");return t.includes("tests")&&Wr(r)}function Jr(e){return J()?e.filter(t=>!Q(t)):e}function Qr(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 en(e){return e.split(/[\s"'`;|&]+/).map(t=>t.trim()).filter(t=>t.length>0&&/[\\/]/.test(t)).some(t=>Q(t))}function tn(e){if(!J())return null;let t=Yr(e)??Zr(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 rn(e){return/^data:([^;,]+)[;,]/i.exec(e.trim())?.[1]}function Ue(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 ${rn(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 zr(e){return Array.isArray(e)&&e.some(t=>t.type!=="text")}function Hr(e){return typeof e=="string"?Ne(e):e}function Ur(e,t){return{type:"tool_result",tool_use_id:e,content:Le(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 qr(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}var Fe=require("node:dns/promises"),I=require("node:net");var b="[redacted]";var Vr=[[/-----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 De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(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_-])${De(o)}(?![A-Za-z0-9_-])`,"g"),b);let i=encodeURIComponent(o);i!==o&&(r=r.replace(new RegExp(`(?<![A-Za-z0-9_-])${De(i)}(?![A-Za-z0-9_-])`,"g"),b))}for(let[o,i]of Vr)o.lastIndex=0,r=r.replace(o,i);return r}function G(e,t,r){try{Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0,enumerable:!1})}catch{}}function Y(e,t=[],r=0){if(!(e instanceof Error)||r>6)return e;let n=[...t],o=k(e.message,n);if(o!==e.message&&G(e,"message",o),typeof e.stack=="string"){let s=k(e.stack,n);s!==e.stack&&G(e,"stack",s)}let i=e.cause;if(i instanceof Error)Y(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=k(s,n);a!==s&&G(e,"cause",a)}for(let s of Object.keys(e)){let a=e[s];if(typeof a=="string"){let c=k(a,n);if(c!==a)try{e[s]=c}catch{}}}return e}var X=class extends Error{category;code;retryable;providerId;statusCode;retryAfterMs;requestId;providerCode;remedy;constructor(t,r){super(k(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),Y(this)}};var ze=new Set(["metadata.google.internal","metadata.azure.internal","instance-data.ec2.internal"]);function m(e){return new X(`Provider endpoint rejected: ${e}`,{category:"endpoint_policy",code:"PROVIDER_ENDPOINT_REJECTED"})}function jr(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 Be(e){let t=jr(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 x(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];(0,I.isIP)(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 He(e){let t=x(e);return(0,I.isIP)(t)===4?Be(t):t==="::"||t==="::0"?"unspecified":t==="::1"?"loopback":t.startsWith("::ffff:")?Be(t.slice(7)):/^f[cd]/.test(t)?"private":/^fe[89ab]/.test(t)?"link-local":"public"}function Xe(e){return e==="example"||e.endsWith(".example")||e==="test"||e.endsWith(".test")||e==="invalid"||e.endsWith(".invalid")}function Wr(e){return e==="localhost"||e.endsWith(".localhost")}function Ue(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(ze.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=(0,I.isIP)(o)?He(o):null;if(i==="link-local"||i==="unspecified")throw m(`${i} destinations are forbidden`);if(n==="public-https"&&(i==="private"||i==="loopback"||Wr(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 qe(e,t={}){let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(ze.has(r))throw m("cloud metadata destinations are forbidden");let n=new Set((t.allowedHosts??[]).map(s=>s.toLowerCase())),o=(0,I.isIP)(r)?[r]:Xe(r)?[]:t.resolveHostname?await t.resolveHostname(r):(await(0,Fe.lookup)(r,{all:!0,verbatim:!0})).map(s=>s.address);if(!o.length&&!Xe(r))throw m("DNS resolution returned no addresses");let i=t.profile??"public-https";for(let s of o){let a=He(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}var Ve=require("node:http"),je=require("node:https"),Z=require("node:net"),We=require("node:events");function Ke(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||!(0,Z.isIP)(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:"?je.request:Ve.request)(new URL(n.path,e.origin),{method:n.method,headers:l,agent:!1,rejectUnauthorized:!0,lookup:(u,g,_)=>{let h={address:c,family:(0,Z.isIP)(c)};typeof g=="object"&&g.all?_(null,[h]):_(null,c,h.family)}},u=>{i=u;let g=u.rawHeaders.map(h=>Buffer.from(h)),_=()=>u.resume();o.onHeaders(u.statusCode??500,g,_,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||x(u.remoteAddress)!==x(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&&x(u.remoteAddress)===x(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(0,We.once)(p,"drain")}p.end()}}catch(u){p.destroy(u instanceof Error?u:new Error("Provider request body failed"))}})(),!0}}}async function Kr(e,t,r={}){let n=new URL(e.toString()),o=new URL(n);o.search="",o.hash="",Ue(o.toString(),r.policy),t.signal?.throwIfAborted();let i=await Ge(qe(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(x(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:Ke(n,i)});s.then(c=>{t.signal?.aborted&&c.body?.cancel().catch(()=>{})},()=>{});let a=await Ge(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 Ge(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)}}0&&(module.exports={ApiTransientError,HOME_DIR,IS_LINUX,IS_MAC,IS_WINDOWS,LogLevel,OS_VERSION,PLATFORM,accountTextTokens,appendDurableLine,appendLine,benchmarkLeakError,buildToolResultBlock,buildToolResultText,calculateCost,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,getLogLevel,getNumber,getProjectConfigDir,getRetryErrorContext,getShellName,getString,getToolResultTransportContent,hasDir,hasDisallowedAsciiControlCharacter,hasFile,hasFrontmatter,hasMixedLineEndings,hasNonTextToolResultContent,hasTransientStatusMention,info,isBenchmarkLeakPath,isBenchmarkMode,isGitRepo,isGitRepoAsync,isPathSafe,isRetryableError,listDirs,listFiles,normalizeLineEndings,normalizeXenoRequestContext,parseDocument,parseJsonLines,pathIdentityKey,readFileSafe,readIfExists,readTextFile,remainingBudget,renameReplacingWithRetry,safeJsonParse,safeJsonStringify,safeRegexTest,safeResolvePath,setLogLevel,stringifyDocument,toTransportAssistantBlocks,toolAssistantContentToText,toolResultContentToText,truncateToTokens,validateRegexPattern,validateRequired,warn,withRetry,writeAtomic,writeTextFile,xenoRequestContextHeaders});
|
|
23
|
+
`).trim()}function je(e){let t=e.trim();return t.length>0?[{type:"text",text:t}]:[]}function nn(e){return typeof e=="string"?e:Ue(e)}function Ve(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 on(e){let t=e.assistant_content&&e.assistant_content.length>0?e.assistant_content:typeof e.content=="string"?je(e.content):e.content,r=e.assistant_only_content??[],n=sn(e),o=[...t,...r,...n?[n]:[]];return o.length>0?o:e.content}function sn(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 an(e){return Array.isArray(e)&&e.some(t=>t.type!=="text")}function cn(e){return typeof e=="string"?je(e):e}function un(e,t){return{type:"tool_result",tool_use_id:e,content:Ve(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 dn(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}var Ye=require("node:dns/promises"),M=require("node:net");var w="[redacted]";var ln=[[/-----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${w}`],[/((?:^|[\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${w}`],[/\b(Bearer|Basic|Token|DPoP)\s+[A-Za-z0-9._~+/=-]{6,}/gi,`$1 ${w}`],[/\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,w],[/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,w],[/([?&#;](?:access_token|refresh_token|id_token|token|key|api[_-]?key|secret|client_secret|password|signature|sig)=)[^&#\s"'<>]+/gi,`$1${w}`],[/(\b[a-z][a-z0-9+.-]*:\/\/)[^/\s:@"']+:[^/\s@"']+@/gi,`$1${w}@`]];function We(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(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_-])${We(o)}(?![A-Za-z0-9_-])`,"g"),w);let i=encodeURIComponent(o);i!==o&&(r=r.replace(new RegExp(`(?<![A-Za-z0-9_-])${We(i)}(?![A-Za-z0-9_-])`,"g"),w))}for(let[o,i]of ln)o.lastIndex=0,r=r.replace(o,i);return r}function ee(e,t,r){try{Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0,enumerable:!1})}catch{}}function te(e,t=[],r=0){if(!(e instanceof Error)||r>6)return e;let n=[...t],o=S(e.message,n);if(o!==e.message&&ee(e,"message",o),typeof e.stack=="string"){let s=S(e.stack,n);s!==e.stack&&ee(e,"stack",s)}let i=e.cause;if(i instanceof Error)te(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(s,n);a!==s&&ee(e,"cause",a)}for(let s of Object.keys(e)){let a=e[s];if(typeof a=="string"){let c=S(a,n);if(c!==a)try{e[s]=c}catch{}}}return e}var q=class extends Error{category;code;retryable;providerId;statusCode;retryAfterMs;requestId;providerCode;remedy;constructor(t,r){super(S(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),te(this)}};var Ze=new Set(["metadata.google.internal","metadata.azure.internal","instance-data.ec2.internal"]);function m(e){return new q(`Provider endpoint rejected: ${e}`,{category:"endpoint_policy",code:"PROVIDER_ENDPOINT_REJECTED"})}function fn(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 Ke(e){let t=fn(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 T(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];(0,M.isIP)(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 Je(e){let t=T(e);return(0,M.isIP)(t)===4?Ke(t):t==="::"||t==="::0"?"unspecified":t==="::1"?"loopback":t.startsWith("::ffff:")?Ke(t.slice(7)):/^f[cd]/.test(t)?"private":/^fe[89ab]/.test(t)?"link-local":"public"}function Ge(e){return e==="example"||e.endsWith(".example")||e==="test"||e.endsWith(".test")||e==="invalid"||e.endsWith(".invalid")}function pn(e){return e==="localhost"||e.endsWith(".localhost")}function Qe(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(Ze.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=(0,M.isIP)(o)?Je(o):null;if(i==="link-local"||i==="unspecified")throw m(`${i} destinations are forbidden`);if(n==="public-https"&&(i==="private"||i==="loopback"||pn(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 et(e,t={}){let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(Ze.has(r))throw m("cloud metadata destinations are forbidden");let n=new Set((t.allowedHosts??[]).map(s=>s.toLowerCase())),o=(0,M.isIP)(r)?[r]:Ge(r)?[]:t.resolveHostname?await t.resolveHostname(r):(await(0,Ye.lookup)(r,{all:!0,verbatim:!0})).map(s=>s.address);if(!o.length&&!Ge(r))throw m("DNS resolution returned no addresses");let i=t.profile??"public-https";for(let s of o){let a=Je(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}var tt=require("node:http"),rt=require("node:https"),re=require("node:net"),nt=require("node:events");function ot(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||!(0,re.isIP)(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:"?rt.request:tt.request)(new URL(n.path,e.origin),{method:n.method,headers:l,agent:!1,rejectUnauthorized:!0,lookup:(u,g,v)=>{let h={address:c,family:(0,re.isIP)(c)};typeof g=="object"&&g.all?v(null,[h]):v(null,c,h.family)}},u=>{i=u;let g=u.rawHeaders.map(h=>Buffer.from(h)),v=()=>u.resume();o.onHeaders(u.statusCode??500,g,v,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||T(u.remoteAddress)!==T(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&&T(u.remoteAddress)===T(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(0,nt.once)(f,"drain")}f.end()}}catch(u){f.destroy(u instanceof Error?u:new Error("Provider request body failed"))}})(),!0}}}async function mn(e,t,r={}){let n=new URL(e.toString()),o=new URL(n);o.search="",o.hash="",Qe(o.toString(),r.policy),t.signal?.throwIfAborted();let i=await it(et(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(T(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:ot(n,i)});s.then(c=>{t.signal?.aborted&&c.body?.cancel().catch(()=>{})},()=>{});let a=await it(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 it(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)}}0&&(module.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});
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -35,6 +35,19 @@ declare function listFiles(dir: string, pattern?: RegExp): Promise<string[]>;
|
|
|
35
35
|
declare function listDirs(dir: string): Promise<string[]>;
|
|
36
36
|
declare function deleteFile(filePath: string): Promise<void>;
|
|
37
37
|
declare function deleteDir(dirPath: string): Promise<void>;
|
|
38
|
+
interface FileCacheStats {
|
|
39
|
+
reads: number;
|
|
40
|
+
hits: number;
|
|
41
|
+
}
|
|
42
|
+
declare function getFileCacheStats(): FileCacheStats;
|
|
43
|
+
declare function resetFileCacheStats(): void;
|
|
44
|
+
declare function invalidateFileCache(filePath: string): void;
|
|
45
|
+
declare function clearFileCache(): void;
|
|
46
|
+
interface DerivedReadOptions {
|
|
47
|
+
tailBytes?: number;
|
|
48
|
+
}
|
|
49
|
+
declare function readDerivedCached<T>(filePath: string, key: string, derive: (text: string, truncated: boolean) => T | undefined, options?: DerivedReadOptions): Promise<T | null>;
|
|
50
|
+
declare function readTextCached(filePath: string): Promise<string | null>;
|
|
38
51
|
declare function safeJsonParse<T>(str: string, fallback: T): T;
|
|
39
52
|
declare function safeJsonStringify(obj: unknown, fallback?: string): string;
|
|
40
53
|
declare function parseJsonLines<T>(content: string): T[];
|
|
@@ -86,6 +99,7 @@ interface XenoRequestContext {
|
|
|
86
99
|
readonly name: string;
|
|
87
100
|
readonly version: string;
|
|
88
101
|
};
|
|
102
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
89
103
|
}
|
|
90
104
|
declare function normalizeXenoRequestContext(context: XenoRequestContext): Readonly<XenoRequestContext>;
|
|
91
105
|
declare function xenoRequestContextHeaders(context: Readonly<XenoRequestContext> | undefined): Record<string, string>;
|
|
@@ -324,4 +338,4 @@ interface PinnedEndpointFetchOptions {
|
|
|
324
338
|
authorizeAddress?: (address: string, url: URL) => boolean;
|
|
325
339
|
}
|
|
326
340
|
declare function fetchPinnedEndpoint(url: string | URL, init: RequestInit, options?: PinnedEndpointFetchOptions): Promise<Response>;
|
|
327
|
-
export { ApiTransientError, type ApiTransientErrorClassification, HOME_DIR, IS_LINUX, IS_MAC, IS_WINDOWS, type LineEnding, LogLevel, OS_VERSION, PLATFORM, type ParsedDocument, type PinnedEndpointFetchOptions, type RetryErrorContext, type RetryOptions, type TextEncoding, type TextFileContents, type TokenAccountingAdapter, type TokenAccountingResult, type TokenAccountingSource, type TokenEstimator, type XenoAsciiControlCharacterPolicy, type XenoRequestContext, accountTextTokens, appendDurableLine, appendLine, benchmarkLeakError, buildToolResultBlock, buildToolResultText, calculateCost, 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, getLogLevel, getNumber, getProjectConfigDir, getRetryErrorContext, getShellName, getString, getToolResultTransportContent, hasDir, hasDisallowedAsciiControlCharacter, hasFile, hasFrontmatter, hasMixedLineEndings, hasNonTextToolResultContent, hasTransientStatusMention, info, isBenchmarkLeakPath, isBenchmarkMode, isGitRepo, isGitRepoAsync, isPathSafe, isRetryableError, listDirs, listFiles, normalizeLineEndings, normalizeXenoRequestContext, parseDocument, parseJsonLines, pathIdentityKey, readFileSafe, readIfExists, readTextFile, remainingBudget, renameReplacingWithRetry, safeJsonParse, safeJsonStringify, safeRegexTest, safeResolvePath, setLogLevel, stringifyDocument, toTransportAssistantBlocks, toolAssistantContentToText, toolResultContentToText, truncateToTokens, validateRegexPattern, validateRequired, warn, withRetry, writeAtomic, writeTextFile, xenoRequestContextHeaders };
|
|
341
|
+
export { ApiTransientError, type ApiTransientErrorClassification, type DerivedReadOptions, type FileCacheStats, HOME_DIR, IS_LINUX, IS_MAC, IS_WINDOWS, type LineEnding, LogLevel, OS_VERSION, PLATFORM, type ParsedDocument, type PinnedEndpointFetchOptions, type RetryErrorContext, type RetryOptions, type TextEncoding, type TextFileContents, type TokenAccountingAdapter, type TokenAccountingResult, type TokenAccountingSource, type TokenEstimator, type XenoAsciiControlCharacterPolicy, type XenoRequestContext, 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 };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -35,6 +35,19 @@ declare function listFiles(dir: string, pattern?: RegExp): Promise<string[]>;
|
|
|
35
35
|
declare function listDirs(dir: string): Promise<string[]>;
|
|
36
36
|
declare function deleteFile(filePath: string): Promise<void>;
|
|
37
37
|
declare function deleteDir(dirPath: string): Promise<void>;
|
|
38
|
+
interface FileCacheStats {
|
|
39
|
+
reads: number;
|
|
40
|
+
hits: number;
|
|
41
|
+
}
|
|
42
|
+
declare function getFileCacheStats(): FileCacheStats;
|
|
43
|
+
declare function resetFileCacheStats(): void;
|
|
44
|
+
declare function invalidateFileCache(filePath: string): void;
|
|
45
|
+
declare function clearFileCache(): void;
|
|
46
|
+
interface DerivedReadOptions {
|
|
47
|
+
tailBytes?: number;
|
|
48
|
+
}
|
|
49
|
+
declare function readDerivedCached<T>(filePath: string, key: string, derive: (text: string, truncated: boolean) => T | undefined, options?: DerivedReadOptions): Promise<T | null>;
|
|
50
|
+
declare function readTextCached(filePath: string): Promise<string | null>;
|
|
38
51
|
declare function safeJsonParse<T>(str: string, fallback: T): T;
|
|
39
52
|
declare function safeJsonStringify(obj: unknown, fallback?: string): string;
|
|
40
53
|
declare function parseJsonLines<T>(content: string): T[];
|
|
@@ -86,6 +99,7 @@ interface XenoRequestContext {
|
|
|
86
99
|
readonly name: string;
|
|
87
100
|
readonly version: string;
|
|
88
101
|
};
|
|
102
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
89
103
|
}
|
|
90
104
|
declare function normalizeXenoRequestContext(context: XenoRequestContext): Readonly<XenoRequestContext>;
|
|
91
105
|
declare function xenoRequestContextHeaders(context: Readonly<XenoRequestContext> | undefined): Record<string, string>;
|
|
@@ -324,4 +338,4 @@ interface PinnedEndpointFetchOptions {
|
|
|
324
338
|
authorizeAddress?: (address: string, url: URL) => boolean;
|
|
325
339
|
}
|
|
326
340
|
declare function fetchPinnedEndpoint(url: string | URL, init: RequestInit, options?: PinnedEndpointFetchOptions): Promise<Response>;
|
|
327
|
-
export { ApiTransientError, type ApiTransientErrorClassification, HOME_DIR, IS_LINUX, IS_MAC, IS_WINDOWS, type LineEnding, LogLevel, OS_VERSION, PLATFORM, type ParsedDocument, type PinnedEndpointFetchOptions, type RetryErrorContext, type RetryOptions, type TextEncoding, type TextFileContents, type TokenAccountingAdapter, type TokenAccountingResult, type TokenAccountingSource, type TokenEstimator, type XenoAsciiControlCharacterPolicy, type XenoRequestContext, accountTextTokens, appendDurableLine, appendLine, benchmarkLeakError, buildToolResultBlock, buildToolResultText, calculateCost, 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, getLogLevel, getNumber, getProjectConfigDir, getRetryErrorContext, getShellName, getString, getToolResultTransportContent, hasDir, hasDisallowedAsciiControlCharacter, hasFile, hasFrontmatter, hasMixedLineEndings, hasNonTextToolResultContent, hasTransientStatusMention, info, isBenchmarkLeakPath, isBenchmarkMode, isGitRepo, isGitRepoAsync, isPathSafe, isRetryableError, listDirs, listFiles, normalizeLineEndings, normalizeXenoRequestContext, parseDocument, parseJsonLines, pathIdentityKey, readFileSafe, readIfExists, readTextFile, remainingBudget, renameReplacingWithRetry, safeJsonParse, safeJsonStringify, safeRegexTest, safeResolvePath, setLogLevel, stringifyDocument, toTransportAssistantBlocks, toolAssistantContentToText, toolResultContentToText, truncateToTokens, validateRegexPattern, validateRequired, warn, withRetry, writeAtomic, writeTextFile, xenoRequestContextHeaders };
|
|
341
|
+
export { ApiTransientError, type ApiTransientErrorClassification, type DerivedReadOptions, type FileCacheStats, HOME_DIR, IS_LINUX, IS_MAC, IS_WINDOWS, type LineEnding, LogLevel, OS_VERSION, PLATFORM, type ParsedDocument, type PinnedEndpointFetchOptions, type RetryErrorContext, type RetryOptions, type TextEncoding, type TextFileContents, type TokenAccountingAdapter, type TokenAccountingResult, type TokenAccountingSource, type TokenEstimator, type XenoAsciiControlCharacterPolicy, type XenoRequestContext, 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 };
|