@skyramp/testbot-core 0.13.0-v3.230 → 0.13.0-v3.232

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.
@@ -84,7 +84,7 @@ ${l}`,this.dataLineCount++;return}if(ku(e,s,lY)){pY(e,i)&&(this.setEventFieldSiz
84
84
 
85
85
  Error Code : ${a.statusCode}
86
86
 
87
- Error Message: ${a.message}`)})).result)===null||n===void 0?void 0:n.value;if(!i)throw new Error("Response json body do not have ID Token field");return i})}static getIDToken(e){return Qk(this,void 0,void 0,function*(){try{let n=t.getIDTokenUrl();if(e){let s=encodeURIComponent(e);n=`${n}&audience=${s}`}Bk(`ID token url is ${n}`);let r=yield t.getCall(n);return Va(r),r}catch(n){throw new Error(`Error message: ${n.message}`)}})}};var bk=require("os"),Ha=require("fs");var Gp=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})},{access:l2,appendFile:d2,writeFile:h2}=Ha.promises,wk="GITHUB_STEP_SUMMARY";var $p=class{static{o(this,"Summary")}constructor(){this._buffer=""}filePath(){return Gp(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[wk];if(!e)throw new Error(`Unable to find environment variable for $${wk}. Check if your runtime environment supports job summaries.`);try{yield l2(e,Ha.constants.R_OK|Ha.constants.W_OK)}catch{throw new Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,n,r={}){let s=Object.entries(r).map(([i,a])=>` ${i}="${a}"`).join("");return n?`<${e}${s}>${n}</${e}>`:`<${e}${s}>`}write(e){return Gp(this,void 0,void 0,function*(){let n=!!e?.overwrite,r=yield this.filePath();return yield(n?h2:d2)(r,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return Gp(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw(e,n=!1){return this._buffer+=e,n?this.addEOL():this}addEOL(){return this.addRaw(bk.EOL)}addCodeBlock(e,n){let r=Object.assign({},n&&{lang:n}),s=this.wrap("pre",this.wrap("code",e),r);return this.addRaw(s).addEOL()}addList(e,n=!1){let r=n?"ol":"ul",s=e.map(a=>this.wrap("li",a)).join(""),i=this.wrap(r,s);return this.addRaw(i).addEOL()}addTable(e){let n=e.map(s=>{let i=s.map(a=>{if(typeof a=="string")return this.wrap("td",a);let{header:c,data:l,colspan:d,rowspan:h}=a,g=c?"th":"td",f=Object.assign(Object.assign({},d&&{colspan:d}),h&&{rowspan:h});return this.wrap(g,l,f)}).join("");return this.wrap("tr",i)}).join(""),r=this.wrap("table",n);return this.addRaw(r).addEOL()}addDetails(e,n){let r=this.wrap("details",this.wrap("summary",e)+n);return this.addRaw(r).addEOL()}addImage(e,n,r){let{width:s,height:i}=r||{},a=Object.assign(Object.assign({},s&&{width:s}),i&&{height:i}),c=this.wrap("img",null,Object.assign({src:e,alt:n},a));return this.addRaw(c).addEOL()}addHeading(e,n){let r=`h${n}`,s=["h1","h2","h3","h4","h5","h6"].includes(r)?r:"h1",i=this.wrap(s,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap("hr",null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap("br",null);return this.addRaw(e).addEOL()}addQuote(e,n){let r=Object.assign({},n&&{cite:n}),s=this.wrap("blockquote",e,r);return this.addRaw(s).addEOL()}addLink(e,n){let r=this.wrap("a",e,{href:n});return this.addRaw(r).addEOL()}},Q5=new $p;var Yp=Ve(require("os"),1);var Fu=Ve(require("fs"),1);var{chmod:g2,copyFile:p2,lstat:f2,mkdir:m2,open:k5,readdir:E2,rename:C2,rm:I2,rmdir:S5,stat:y2,symlink:Q2,unlink:B2}=Fu.promises,w2=process.platform==="win32";var v5=Fu.constants.O_RDONLY;var M5=process.platform==="win32";var $5=Yp.default.platform(),Y5=Yp.default.arch();var D2=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})},kk;(function(t){t[t.Success=0]="Success",t[t.Failure=1]="Failure"})(kk||(kk={}));function Va(t){Ad("add-mask",{},t)}o(Va,"setSecret");function Bk(t){Ad("debug",{},t)}o(Bk,"debug");function Sk(t){return D2(this,void 0,void 0,function*(){return yield Nu.getIDToken(t)})}o(Sk,"getIDToken");var T2=5e3,Vp=/^(?!\.\.?$)[A-Za-z0-9._-]{1,100}$/;function N2(t){let e=Buffer.from(`x-access-token:${t}`).toString("base64");return Va(e),`AUTHORIZATION: basic ${e}`}o(N2,"githubGitAuthorization");function xk(t,e={}){let n=o(l=>{let d=t[l];if(!d)throw new Error(`${l} is not set; the V3 runner handshake needs it`);return d},"read"),r=t.GITHUB_REPOSITORY_ID,s=t.GITHUB_REPOSITORY,i=(t.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,""),a=(t.GITHUB_API_URL||"https://api.github.com").replace(/\/+$/,""),c=o(async(l,d)=>d.fetch(l,{headers:{Authorization:`Bearer ${await d.token()}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(3e4)}),"get");return{runnerPlatform:t.GITHUB_ACTIONS==="true"?"github":void 0,workspace:t.GITHUB_WORKSPACE||void 0,serverUrl:i,apiUrl:a,repository:r&&s?{id:r,slug:s}:void 0,runId:t.GITHUB_RUN_ID||void 0,runAttempt:t.GITHUB_RUN_ATTEMPT||void 0,job:t.GITHUB_JOB||void 0,execution(){let l=n("GITHUB_RUN_ATTEMPT");if(!/^[1-9][0-9]*$/.test(l))throw new Error(`GITHUB_RUN_ATTEMPT is "${l}", not a positive whole number`);return{provider:"github",repository:{provider:"github",providerAccountId:n("GITHUB_REPOSITORY_OWNER_ID"),providerRepositoryId:n("GITHUB_REPOSITORY_ID")},providerRunId:n("GITHUB_RUN_ID"),providerRunAttempt:Number(l),workflowRef:n("GITHUB_WORKFLOW_REF")}},takeIdToken(){let l=t.ACTIONS_ID_TOKEN_REQUEST_URL,d=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;return delete t.ACTIONS_ID_TOKEN_REQUEST_URL,delete t.ACTIONS_ID_TOKEN_REQUEST_TOKEN,async h=>{if(!l||!d)throw new Error("The job cannot request an OIDC token. Give it the `id-token: write` permission.");let g=new URL(l);g.searchParams.set("audience",h);let f=await fetch(g,{headers:{Authorization:`Bearer ${d}`,Accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!f.ok)throw new Error(`GitHub refused the OIDC token request: ${f.status}`);let m=(await f.json().catch(()=>({}))).value;if(typeof m!="string"||!m)throw new Error("GitHub's OIDC token response carried no token");return Va(m),m}},webIdentity(){return!t.ACTIONS_ID_TOKEN_REQUEST_TOKEN?.trim()||!t.ACTIONS_ID_TOKEN_REQUEST_URL?.trim()?void 0:{token:e.getIDToken??(d=>Sk(d)),runId:t.GITHUB_RUN_ID}},v3RunsOnly:!1,assumesBedrockRole:!1,namesSourceToMcp:!1,runSettingsFromApp:!1,checkSourceName(l){for(let d of[l.namespace,l.name])if(!Vp.test(d))throw new Error(`"${d}" is not a repository name`)},cloneUrl(l){return`${i}/${l.namespace}/${l.name}.git`},gitAuthEnv(l){return l?{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${i}/.extraheader`,GIT_CONFIG_VALUE_0:N2(l)}:{}},async pullRequest({namespace:l,name:d},h,g){if(![l,d].every(C=>Vp.test(C)))throw new Error("the repository name is not valid");let f=await c(`${a}/repos/${l}/${d}/pulls/${h}`,g);if(!f.ok)throw new Error(`GitHub answered ${f.status}`);let m=await f.json();return{...typeof m.title=="string"?{title:m.title}:{},...typeof m.body=="string"?{body:m.body}:{},...typeof m.merged=="boolean"?{merged:m.merged}:{},...m.merged===!0&&typeof m.merge_commit_sha=="string"?{mergeCommit:m.merge_commit_sha}:{},...m.merged===!0&&typeof m.head?.sha=="string"?{mergedHead:m.head.sha}:{}}},async commit(l,d,h){let[g,f,...m]=l.split("/");if(m.length||![g,f].every(C=>C!==void 0&&Vp.test(C)))return{lookup:"unknown"};try{let C=await c(`${a}/repos/${g}/${f}/commits/${encodeURIComponent(d)}`,h);if(C.status===404||C.status===422)return{lookup:"missing"};if(!C.ok)return{lookup:"unknown"};let y=await C.json();return typeof y.sha=="string"?{sha:y.sha}:{lookup:"missing"}}catch{return{lookup:"unknown"}}},async revokeToken(l,d){let h=await d(`${a}/installation/token`,{method:"DELETE",headers:{Authorization:`Bearer ${l}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(T2)});if(!h.ok&&h.status!==401)throw new Error(`GitHub answered ${h.status}`)}}}o(xk,"githubRunnerHost");function Dk(t=process.env){return od(t)?GE(t):xk(t)}o(Dk,"runnerHost");var F2=10*6e4;function U2(t,e){return t.getTime()-e.getTime()-F2}o(U2,"remainingBudgetMs");var Tk="This attempt revoked its scoped GitHub credentials; it mints no more.",M2=10*6e4;var L2=o(t=>!!t&&Object.keys(t).length===1&&t.contents==="read","onlyReads"),_2=3e4,P2=3,Nk=30,an=class extends Error{constructor(n,r,s,i){super(n);this.status=r;this.code=s;this.path=i}status;code;path;static{o(this,"AppRefusal")}},xs=class extends Error{static{o(this,"AppUnreachable")}},ro=class extends xs{static{o(this,"AppNotReady")}},Hp=class extends ro{static{o(this,"RunnerProviderNotReady")}};function Jp(t){let e;try{e=new URL(t)}catch{throw new Error(`skyrampAppOrigin "${t}" is not a URL`)}if(e.protocol!=="https:"||e.origin!==t.replace(/\/+$/,""))throw new Error(`skyrampAppOrigin must be an https origin, got "${t}"`);return e.origin}o(Jp,"appOrigin");function Fk(t,e){if(!qs.test(t))throw new Error(`The ${e} "${t}" is not a uuid`);return t}o(Fk,"routeId");function O2(t,e){return`${t.replace(/\/+$/,"")}/runs/${e}`}o(O2,"skyrampRunPageUrl");function Uk(t,e,n,r){throw e<500&&e!==429?new an(t,e,n,r):e===503&&n==="RUNNER_PROVIDER_NOT_READY"?new Hp(t):e===503&&n==="RUN_NOT_READY"?new ro(t):new xs(t)}o(Uk,"refusedOrUnreachable");async function Mk(t,e,n,r){let s=Jp(t.origin),i,a=0;for(let c=1;c<=P2||i instanceof ro;c+=1){if(i instanceof ro){if(a===Nk)throw i;a+=1,c-=1,t.log?.(`${i.message}; trying again (${a} of ${Nk}).`),await new Promise(l=>setTimeout(l,t.readyWaitMs??1e4))}else c>1&&await new Promise(l=>setTimeout(l,(t.retryDelayMs??2e3)*(c-1)));try{let l=await t.idToken(s),d=await(t.fetch??fetch)(new URL(e,s).toString(),{...n(l),redirect:"error",signal:AbortSignal.timeout(_2)}).catch(h=>{throw new xs(h instanceof Error?h.message:String(h),{cause:h})});return await r(d)}catch(l){if(l instanceof an)throw l;i=l}}throw i}o(Mk,"callWithRetries");function Uu(t,e,n,r){return Mk(t,n,o(i=>({method:e,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json",Accept:"application/json"},body:e==="GET"?void 0:JSON.stringify(r)}),"request"),async i=>{let a=await i.json().catch(()=>({}));if(i.ok)return a.data;let c=a.error?.fields,l=typeof c?.path=="string"&&typeof c.reason=="string"?` at ${c.path}: ${c.reason}`:"",d=`The Skyramp app refused ${e} ${n}: ${i.status} ${a.error?.code??"no error code"}${l}`;return Uk(d,i.status,a.error?.code,typeof c?.path=="string"?c.path:void 0)})}o(Uu,"callApp");function G2(t,e,n){return Mk(t,e,o(s=>({method:"GET",headers:{Authorization:`Bearer ${s}`,Accept:"application/octet-stream"}}),"request"),async s=>{if(!s.ok)return Uk(`The Skyramp app refused GET ${e}: ${s.status}`,s.status);let i=Buffer.from(await s.arrayBuffer());if(i.length>n)throw new an(`The Skyramp app answered GET ${e} with more than ${n} bytes`,s.status);return i})}o(G2,"callAppBytes");var Ja=class{constructor(e,n,r,s,i,a,c,l,d,h=[],g=[],f){this.attemptId=e;this.attemptNumber=n;this.deadlineAt=r;this.manifest=s;this.deps=i;this.license=a;this.requestedBy=c;this.writeAllowed=l;this.claudeCodeVersion=d;this.deployedPins=h;this.statedPins=g;this.runSettings=f}attemptId;attemptNumber;deadlineAt;manifest;deps;license;requestedBy;writeAllowed;claudeCodeVersion;deployedPins;statedPins;runSettings;static{o(this,"V3Attempt")}budgetMs(e){return U2(this.deadlineAt,e)}get skyrampRunUrl(){return O2(Jp(this.deps.origin),this.manifest.runId)}send(e,n,r){return Uu(this.deps,e,n,r)}readBytes(e,n){return G2(this.deps,e,n)}issuedTokens=[];closure;modelKey;credentials={};revocation;token(){return this.cachedToken("run")}readOnlyToken(){return this.cachedToken("read")}async cachedToken(e){if(this.revocation)throw new Error(Tk);let n=(this.deps.now??(()=>new Date))().getTime(),r=this.credentials[e],s=r&&await r.catch(()=>{});if(this.credentials[e]!==r)return(await this.credentials[e]).token;if(s&&s.expiresAt-n>=M2)return s.token;if(this.revocation)throw new Error(Tk);let i=e==="read",a=i?{schemaVersion:1,access:e}:{schemaVersion:1},c=i?"read-only":"scoped",l=this.send("POST",`/api/v1/runner/attempts/${this.attemptId}/credentials`,a).then(d=>{let h={...d,token:d.token??this.jobToken()};if(this.issuedTokens.push(h.token),this.deps.mask?.(h.token),h.anthropicApiKey&&this.deps.mask?.(h.anthropicApiKey),i&&d.token&&!L2(h.permissions))throw new Error(`The Skyramp app was asked for a read-only GitHub token, but its token grants ${JSON.stringify(h.permissions??null)}`);!i&&!s&&h.anthropicApiKey&&(this.modelKey=h.anthropicApiKey),this.deps.onTokenGranted?.(e);let g=s?"Renewed":"Received";return d.token&&this.deps.log?.(`${g} ${c} GitHub credentials; they expire at ${h.expiresAt}.`),{token:h.token,expiresAt:d.token?new Date(h.expiresAt).getTime():Number.POSITIVE_INFINITY}},d=>{if(this.deps.onTokenRefused?.(d,e),!(d instanceof an)||d.code!=="CREDENTIALS_UNAVAILABLE")throw d;let h=o(m=>[...new Set(m.map(C=>C.namespace))].join(", "),"unique"),g=this.manifest.sources.map(m=>m.repository);if(new Set(g.map(m=>m.providerAccountId)).size>1)throw new an(`${d.message}. The run's repositories are on more than one GitHub account (${h(g)}), which Skyramp does not support yet.`,d.status,d.code);let f=h([...g,this.manifest.execution.repository]);throw new an(`${d.message}. Check the Skyramp GitHub App installation on ${f}: it must be installed and not suspended, have access to these repositories, and have accepted the App's current permissions. Each account must also be connected to your Skyramp organization.`,d.status,d.code)});return this.credentials[e]=l,(await l).token}jobToken(){if(this.deps.sourceToken)return this.deps.sourceToken;throw new Error("The app answered the credentials request without a token, and the job gave Testbot none of its own: on Azure Pipelines, set SYSTEM_ACCESSTOKEN to $(System.AccessToken) in the Testbot step's env.")}sourceFetch(e){return e.fetch??this.deps.fetch??fetch}revokeTokens(e={}){let n=e.host??Dk();return this.revocation??=n.revokeToken?this.revokeIssued(r=>n.revokeToken(r,this.sourceFetch(e))):Promise.resolve([]),this.revocation}async revokeIssued(e){let n=[...this.issuedTokens],r=Promise.all(n.map(a=>this.revokeOne(a,e)));await Promise.all(Object.values(this.credentials).map(a=>a.catch(()=>{})));let s=this.issuedTokens.filter(a=>!n.includes(a));return[...await r,...await Promise.all(s.map(a=>this.revokeOne(a,e)))].filter(a=>a!==void 0)}async revokeOne(e,n){try{await n(e);return}catch(r){return`token ${this.issuedTokens.indexOf(e)+1} of ${this.issuedTokens.length}: ${r instanceof Error?r.message:String(r)}`}}};async function Lk(t,e,n){Fk(t,"run id"),Jp(n.origin);let r=ll(t,e),s=`/api/v1/runner/runs/${t}/attempts`,i;try{i=await Uu(n,"POST",s,r)}catch(d){if(!(d instanceof an&&d.status===400&&d.path==="$.statedPins"))throw d;r=ll(t,e,{statedPins:!1}),i=await Uu(n,"POST",s,r)}let a=Wf(i);if(a.manifest.runId!==t)throw new Error(`The app answered the handshake of run ${t} with the manifest of another run (${a.manifest.runId})`);let c=a.manifest.sources.find(d=>d.repository.provider!==r.execution.provider);if(c)throw new Error(`The manifest of run ${t} names ${c.repository.namespace}/${c.repository.name} on ${c.repository.provider}, but this job runs on ${r.execution.provider}`);$2(a.manifest,[...a.deployedRevisions??[],...a.statedRevisions??[]]),a.runToken&&n.mask?.(a.runToken);let l=a.runToken?{entitlements:a.entitlements??[],runToken:a.runToken}:void 0;return new Ja(a.attempt.id,a.attempt.number,new Date(a.attempt.deadlineAt),a.manifest,n,l,a.requestedBy??void 0,a.writeAllowed,a.claudeCodeVersion??void 0,a.deployedRevisions??[],a.statedRevisions??[],a.runSettings)}o(Lk,"startV3Attempt");function $2(t,e){if(e.length===0)return;if(t.trigger.kind!=="schedule")throw new Error(`The app pinned an attempt of a ${t.trigger.kind} run; only a scheduled run's retry is pinned to an earlier attempt's read`);let n=new Set(t.sources.map(s=>Fn(s.repository))),r=new Set;for(let s of e){let i=Fn(s.repository);if(!n.has(i))throw new Error(`The app pinned the attempt to repository ${s.repository.providerRepositoryId}, which is not a source of the run`);if(r.has(i))throw new Error(`The app pinned repository ${s.repository.providerRepositoryId} twice`);r.add(i)}}o($2,"checkAttemptPins");async function qp(t){return Jf.parse(await t.send("POST",`/api/v1/runner/attempts/${t.attemptId}/heartbeat`,{schemaVersion:1}))}o(qp,"heartbeatV3Attempt");async function _k(t,e=()=>new Date){if(t.closure)return t.closure;let n=await qp(t).then(r=>qf(r,e())).catch(()=>null);return n&&(t.closure=n),n}o(_k,"closedV3Attempt");var o6=10*6e4;var a6=["TRIGGER","AUTHORITATIVE_RELATED_CHANGE"];var A6=A.object({tests:A.object({placements:A.array(A.unknown()).optional()}).passthrough().optional()}).passthrough(),c6=A.object({repository:ul,testType:A.nativeEnum(CA),directory:A.string()}).passthrough();var u6=A.object({report:A.object({language:A.string()}).passthrough()}).passthrough();var l6=A.object({environment:A.object({components:A.array(A.unknown()).optional(),dependencies:A.array(A.unknown()).optional()}).passthrough()}).passthrough(),d6=A.object({name:A.string().min(1),provision:A.literal("existing"),url:A.string().min(1),repository:ul.optional(),revisionUrl:A.string().min(1).optional()}).passthrough(),h6=A.object({name:A.string().min(1),url:A.string().nullable(),versionUrl:A.string().nullable(),notes:A.string().nullable()}).passthrough();var g6=new Set(["TRIGGER","AUTHORITATIVE_RELATED_CHANGE","MANUAL_OVERRIDE"]);function Pk(t){let e=o(n=>t.testResults.filter(r=>r.status===n).length,"count");return{passed:e("Pass"),failed:e("Fail"),skipped:e("Skipped")}}o(Pk,"statusCounts");function Y2(t){let{passed:e,failed:n,skipped:r}=Pk(t);return e+n===0?{sufficiency:"insufficient",rationale:r>0?`Every test was skipped (${r}), so nothing was validated.`:"No test ran, so nothing was validated.",gaps:["No test ran against the frozen sources."],acceptedEvidence:[],actionRequired:[]}:{sufficiency:"sufficient",rationale:`${e+n} tests ran against the frozen sources: ${e} passed, ${n} failed${r?`, ${r} skipped`:""}.`,gaps:[],acceptedEvidence:[],actionRequired:[]}}o(Y2,"executedTestsValidation");function V2(t,e){let n=t.testResults.map(l=>({result:l,repository:l.repository??e,path:l.fileName||l.testType})),r=new Map;for(let l of n){let d=`${l.repository}:${l.result.testType}:${l.path}`;r.set(d,(r.get(d)??0)+1)}let s=n.map(({result:l,repository:d,path:h})=>{let g=(r.get(`${d}:${l.testType}:${h}`)??0)>1;return l.resultId??Lf(d,l.testType,h,g&&l.endpoint||void 0)}),i=new Map;for(let l of s)i.set(l,(i.get(l)??0)+1);let a=new Set(s.filter(l=>i.get(l)===1)),c=n.map(({result:l,repository:d},h)=>{let g=s[h],f=g;if(i.get(g)>1&&a.has(g))for(let m=2;a.has(f)||f===g;m+=1)f=g.includes("#")?`${g}.${m}`:`${g}#${m}`;return a.add(f),{...l,repository:d,resultId:f}});return{...t,testResults:c,...H2(t,c,e),validation:j2(t,J2(t,t.validation??Y2(t))),traceVersion:1}}o(V2,"v3Report");function H2(t,e,n){if(!t.testExecutionContexts)return{};let r=new Set,s=o(c=>{let l=c;for(let d=2;r.has(l);d+=1)l=`${c}#${d}`;return r.add(l),l},"unique"),i=[],a=new Map;for(let{repository:c,...l}of t.testExecutionContexts){let d=l.status==="not_run"?[]:e.filter(h=>h.fileName===l.test&&h.repository===(c?.trim()||n));d.length||i.push(l);for(let{resultId:h}of d){let g=a.get(h),f=g!==void 0&&i[g].cleanup.status==="failed"?i[g].cleanup:l.cleanup,m={...l,cleanup:f,test:h,resultId:h};g===void 0?a.set(h,i.push(m)-1):i[g]=m}}for(let c of i)c.resultId&&r.add(c.resultId);return{testExecutionContexts:i.map(c=>c.resultId?c:{...c,test:s(c.test.slice(0,512))}).slice(0,5e3)}}o(H2,"linkedContexts");function J2(t,e){let{passed:n,failed:r}=Pk(t);return e.sufficiency!=="sufficient"||n+r>0||e.acceptedEvidence.length>0?e:{...e,sufficiency:"insufficient",gaps:["No test ran and no existing evidence was accepted, so nothing was validated."]}}o(J2,"withEvidence");var q2={"model-provider-denied":"model_provider_denied","model-provider-unavailable":"model_provider_unavailable"};function j2(t,e){if(e.sufficiency==="sufficient")return e;let n=(t.caveats??[]).map(s=>q2[s.kind]).filter(s=>s!==void 0),r=[...new Set(n)].filter(s=>!e.actionRequired.includes(s));return r.length?{...e,actionRequired:[...r,...e.actionRequired]}:e}o(j2,"withModelProviderFailure");async function Ok(t,e){let n=em([...t.issuedTokens,...e.secrets??[]]),r=zf({manifest:t.manifest,attemptNumber:t.attemptNumber,checkedOut:e.sources.map(s=>({repository:s.repository,revision:s.revision})),firstQualification:e.firstQualification,generatedTests:zs(e.delivery,n),producer:e.producer,report:zs(V2(e.report,e.workingSlug),n),githubWrites:e.githubWrites});await t.send("PUT",`/api/v1/runner/attempts/${t.attemptId}/report`,r)}o(Ok,"uploadV3Report");async function Gk(t,e){return Fk(t.attemptId,"attempt id"),Uu(e,"POST",`/api/v1/runner/attempts/${t.attemptId}/end`,Zf({reportUploaded:t.reportUploaded,recipeUploaded:t.recipeUploaded,revisionsUploaded:t.revisionsUploaded,cancelled:t.cause==="cancelled",timedOut:t.cause==="timed_out",setupFailed:t.cause==="setup_failed",checkoutFailed:t.cause==="checkout_failed",environmentUnverified:t.cause==="environment_unverified",runnerProviderNotReady:t.cause==="runner_provider_not_ready",credentialMissing:t.cause==="credential_missing",modelProviderDenied:t.cause==="model_provider_denied",modelProviderUnavailable:t.cause==="model_provider_unavailable"}))}o(Gk,"endV3Attempt");0&&(module.exports={AppRefusal,AppUnreachable,AttemptEndReason,DeliveryStatus,GitHubWriteKind,NoReportCause,SourceProvider,V3Attempt,ValidationSufficiency,closedV3Attempt,endV3Attempt,heartbeatV3Attempt,startV3Attempt,uploadV3Report});
87
+ Error Message: ${a.message}`)})).result)===null||n===void 0?void 0:n.value;if(!i)throw new Error("Response json body do not have ID Token field");return i})}static getIDToken(e){return Qk(this,void 0,void 0,function*(){try{let n=t.getIDTokenUrl();if(e){let s=encodeURIComponent(e);n=`${n}&audience=${s}`}Bk(`ID token url is ${n}`);let r=yield t.getCall(n);return Va(r),r}catch(n){throw new Error(`Error message: ${n.message}`)}})}};var bk=require("os"),Ha=require("fs");var Gp=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})},{access:l2,appendFile:d2,writeFile:h2}=Ha.promises,wk="GITHUB_STEP_SUMMARY";var $p=class{static{o(this,"Summary")}constructor(){this._buffer=""}filePath(){return Gp(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[wk];if(!e)throw new Error(`Unable to find environment variable for $${wk}. Check if your runtime environment supports job summaries.`);try{yield l2(e,Ha.constants.R_OK|Ha.constants.W_OK)}catch{throw new Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,n,r={}){let s=Object.entries(r).map(([i,a])=>` ${i}="${a}"`).join("");return n?`<${e}${s}>${n}</${e}>`:`<${e}${s}>`}write(e){return Gp(this,void 0,void 0,function*(){let n=!!e?.overwrite,r=yield this.filePath();return yield(n?h2:d2)(r,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return Gp(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw(e,n=!1){return this._buffer+=e,n?this.addEOL():this}addEOL(){return this.addRaw(bk.EOL)}addCodeBlock(e,n){let r=Object.assign({},n&&{lang:n}),s=this.wrap("pre",this.wrap("code",e),r);return this.addRaw(s).addEOL()}addList(e,n=!1){let r=n?"ol":"ul",s=e.map(a=>this.wrap("li",a)).join(""),i=this.wrap(r,s);return this.addRaw(i).addEOL()}addTable(e){let n=e.map(s=>{let i=s.map(a=>{if(typeof a=="string")return this.wrap("td",a);let{header:c,data:l,colspan:d,rowspan:h}=a,g=c?"th":"td",f=Object.assign(Object.assign({},d&&{colspan:d}),h&&{rowspan:h});return this.wrap(g,l,f)}).join("");return this.wrap("tr",i)}).join(""),r=this.wrap("table",n);return this.addRaw(r).addEOL()}addDetails(e,n){let r=this.wrap("details",this.wrap("summary",e)+n);return this.addRaw(r).addEOL()}addImage(e,n,r){let{width:s,height:i}=r||{},a=Object.assign(Object.assign({},s&&{width:s}),i&&{height:i}),c=this.wrap("img",null,Object.assign({src:e,alt:n},a));return this.addRaw(c).addEOL()}addHeading(e,n){let r=`h${n}`,s=["h1","h2","h3","h4","h5","h6"].includes(r)?r:"h1",i=this.wrap(s,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap("hr",null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap("br",null);return this.addRaw(e).addEOL()}addQuote(e,n){let r=Object.assign({},n&&{cite:n}),s=this.wrap("blockquote",e,r);return this.addRaw(s).addEOL()}addLink(e,n){let r=this.wrap("a",e,{href:n});return this.addRaw(r).addEOL()}},Q5=new $p;var Yp=Ve(require("os"),1);var Fu=Ve(require("fs"),1);var{chmod:g2,copyFile:p2,lstat:f2,mkdir:m2,open:k5,readdir:E2,rename:C2,rm:I2,rmdir:S5,stat:y2,symlink:Q2,unlink:B2}=Fu.promises,w2=process.platform==="win32";var v5=Fu.constants.O_RDONLY;var M5=process.platform==="win32";var $5=Yp.default.platform(),Y5=Yp.default.arch();var D2=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return o(s,"adopt"),new(n||(n=Promise))(function(i,a){function c(h){try{d(r.next(h))}catch(g){a(g)}}o(c,"fulfilled");function l(h){try{d(r.throw(h))}catch(g){a(g)}}o(l,"rejected");function d(h){h.done?i(h.value):s(h.value).then(c,l)}o(d,"step"),d((r=r.apply(t,e||[])).next())})},kk;(function(t){t[t.Success=0]="Success",t[t.Failure=1]="Failure"})(kk||(kk={}));function Va(t){Ad("add-mask",{},t)}o(Va,"setSecret");function Bk(t){Ad("debug",{},t)}o(Bk,"debug");function Sk(t){return D2(this,void 0,void 0,function*(){return yield Nu.getIDToken(t)})}o(Sk,"getIDToken");var T2=5e3,Vp=/^(?!\.\.?$)[A-Za-z0-9._-]{1,100}$/;function N2(t){let e=Buffer.from(`x-access-token:${t}`).toString("base64");return Va(e),`AUTHORIZATION: basic ${e}`}o(N2,"githubGitAuthorization");function xk(t,e={}){let n=o(l=>{let d=t[l];if(!d)throw new Error(`${l} is not set; the V3 runner handshake needs it`);return d},"read"),r=t.GITHUB_REPOSITORY_ID,s=t.GITHUB_REPOSITORY,i=(t.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,""),a=(t.GITHUB_API_URL||"https://api.github.com").replace(/\/+$/,""),c=o(async(l,d)=>d.fetch(l,{headers:{Authorization:`Bearer ${await d.token()}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(3e4)}),"get");return{runnerPlatform:t.GITHUB_ACTIONS==="true"?"github":void 0,workspace:t.GITHUB_WORKSPACE||void 0,serverUrl:i,apiUrl:a,repository:r&&s?{id:r,slug:s}:void 0,runId:t.GITHUB_RUN_ID||void 0,runAttempt:t.GITHUB_RUN_ATTEMPT||void 0,job:t.GITHUB_JOB||void 0,execution(){let l=n("GITHUB_RUN_ATTEMPT");if(!/^[1-9][0-9]*$/.test(l))throw new Error(`GITHUB_RUN_ATTEMPT is "${l}", not a positive whole number`);return{provider:"github",repository:{provider:"github",providerAccountId:n("GITHUB_REPOSITORY_OWNER_ID"),providerRepositoryId:n("GITHUB_REPOSITORY_ID")},providerRunId:n("GITHUB_RUN_ID"),providerRunAttempt:Number(l),workflowRef:n("GITHUB_WORKFLOW_REF")}},takeIdToken(){let l=t.ACTIONS_ID_TOKEN_REQUEST_URL,d=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;return delete t.ACTIONS_ID_TOKEN_REQUEST_URL,delete t.ACTIONS_ID_TOKEN_REQUEST_TOKEN,async h=>{if(!l||!d)throw new Error("The job cannot request an OIDC token. Give it the `id-token: write` permission.");let g=new URL(l);g.searchParams.set("audience",h);let f=await fetch(g,{headers:{Authorization:`Bearer ${d}`,Accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!f.ok)throw new Error(`GitHub refused the OIDC token request: ${f.status}`);let m=(await f.json().catch(()=>({}))).value;if(typeof m!="string"||!m)throw new Error("GitHub's OIDC token response carried no token");return Va(m),m}},webIdentity(){return!t.ACTIONS_ID_TOKEN_REQUEST_TOKEN?.trim()||!t.ACTIONS_ID_TOKEN_REQUEST_URL?.trim()?void 0:{token:e.getIDToken??(d=>Sk(d)),runId:t.GITHUB_RUN_ID}},v3RunsOnly:!1,assumesBedrockRole:!1,namesSourceToMcp:!1,runSettingsFromApp:!1,checkSourceName(l){for(let d of[l.namespace,l.name])if(!Vp.test(d))throw new Error(`"${d}" is not a repository name`)},cloneUrl(l){return`${i}/${l.namespace}/${l.name}.git`},gitAuthEnv(l){return l?{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${i}/.extraheader`,GIT_CONFIG_VALUE_0:N2(l)}:{}},async pullRequest({namespace:l,name:d},h,g){if(![l,d].every(C=>Vp.test(C)))throw new Error("the repository name is not valid");let f=await c(`${a}/repos/${l}/${d}/pulls/${h}`,g);if(!f.ok)throw new Error(`GitHub answered ${f.status}`);let m=await f.json();return{...typeof m.title=="string"?{title:m.title}:{},...typeof m.body=="string"?{body:m.body}:{},...typeof m.merged=="boolean"?{merged:m.merged}:{},...m.merged===!0&&typeof m.merge_commit_sha=="string"?{mergeCommit:m.merge_commit_sha}:{},...m.merged===!0&&typeof m.head?.sha=="string"?{mergedHead:m.head.sha}:{}}},async commit(l,d,h){let[g,f,...m]=l.split("/");if(m.length||![g,f].every(C=>C!==void 0&&Vp.test(C)))return{lookup:"unknown"};try{let C=await c(`${a}/repos/${g}/${f}/commits/${encodeURIComponent(d)}`,h);if(C.status===404||C.status===422)return{lookup:"missing"};if(!C.ok)return{lookup:"unknown"};let y=await C.json();return typeof y.sha=="string"?{sha:y.sha}:{lookup:"missing"}}catch{return{lookup:"unknown"}}},async revokeToken(l,d){let h=await d(`${a}/installation/token`,{method:"DELETE",headers:{Authorization:`Bearer ${l}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(T2)});if(!h.ok&&h.status!==401)throw new Error(`GitHub answered ${h.status}`)}}}o(xk,"githubRunnerHost");function Dk(t=process.env){return od(t)?GE(t):xk(t)}o(Dk,"runnerHost");var F2=10*6e4;function U2(t,e){return t.getTime()-e.getTime()-F2}o(U2,"remainingBudgetMs");var Tk="This attempt revoked its scoped GitHub credentials; it mints no more.",M2=10*6e4;var L2=o(t=>!!t&&Object.keys(t).length===1&&t.contents==="read","onlyReads"),_2=3e4,P2=3,Nk=30,an=class extends Error{constructor(n,r,s,i){super(n);this.status=r;this.code=s;this.path=i}status;code;path;static{o(this,"AppRefusal")}},xs=class extends Error{static{o(this,"AppUnreachable")}},ro=class extends xs{static{o(this,"AppNotReady")}},Hp=class extends ro{static{o(this,"RunnerProviderNotReady")}};function Jp(t){let e;try{e=new URL(t)}catch{throw new Error(`skyrampAppOrigin "${t}" is not a URL`)}if(e.protocol!=="https:"||e.origin!==t.replace(/\/+$/,""))throw new Error(`skyrampAppOrigin must be an https origin, got "${t}"`);return e.origin}o(Jp,"appOrigin");function Fk(t,e){if(!qs.test(t))throw new Error(`The ${e} "${t}" is not a uuid`);return t}o(Fk,"routeId");function O2(t,e){return`${t.replace(/\/+$/,"")}/runs/${e}`}o(O2,"skyrampRunPageUrl");function Uk(t,e,n,r){throw e<500&&e!==429?new an(t,e,n,r):e===503&&n==="RUNNER_PROVIDER_NOT_READY"?new Hp(t):e===503&&n==="RUN_NOT_READY"?new ro(t):new xs(t)}o(Uk,"refusedOrUnreachable");async function Mk(t,e,n,r){let s=Jp(t.origin),i,a=0;for(let c=1;c<=P2||i instanceof ro;c+=1){if(i instanceof ro){if(a===Nk)throw i;a+=1,c-=1,t.log?.(`${i.message}; trying again (${a} of ${Nk}).`),await new Promise(l=>setTimeout(l,t.readyWaitMs??1e4))}else c>1&&await new Promise(l=>setTimeout(l,(t.retryDelayMs??2e3)*(c-1)));try{let l=await t.idToken(s),d=await(t.fetch??fetch)(new URL(e,s).toString(),{...n(l),redirect:"error",signal:AbortSignal.timeout(_2)}).catch(h=>{throw new xs(h instanceof Error?h.message:String(h),{cause:h})});return await r(d)}catch(l){if(l instanceof an)throw l;i=l}}throw i}o(Mk,"callWithRetries");function Uu(t,e,n,r){return Mk(t,n,o(i=>({method:e,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json",Accept:"application/json"},body:e==="GET"?void 0:JSON.stringify(r)}),"request"),async i=>{let a=await i.json().catch(()=>({}));if(i.ok)return a.data;let c=a.error?.fields,l=typeof c?.path=="string"&&typeof c.reason=="string"?` at ${c.path}: ${c.reason}`:"",d=`The Skyramp app refused ${e} ${n}: ${i.status} ${a.error?.code??"no error code"}${l}`;return Uk(d,i.status,a.error?.code,typeof c?.path=="string"?c.path:void 0)})}o(Uu,"callApp");function G2(t,e,n){return Mk(t,e,o(s=>({method:"GET",headers:{Authorization:`Bearer ${s}`,Accept:"application/octet-stream"}}),"request"),async s=>{if(!s.ok)return Uk(`The Skyramp app refused GET ${e}: ${s.status}`,s.status);let i=Buffer.from(await s.arrayBuffer());if(i.length>n)throw new an(`The Skyramp app answered GET ${e} with more than ${n} bytes`,s.status);return i})}o(G2,"callAppBytes");var Ja=class{constructor(e,n,r,s,i,a,c,l,d,h=[],g=[],f){this.attemptId=e;this.attemptNumber=n;this.deadlineAt=r;this.manifest=s;this.deps=i;this.license=a;this.requestedBy=c;this.writeAllowed=l;this.claudeCodeVersion=d;this.deployedPins=h;this.statedPins=g;this.runSettings=f}attemptId;attemptNumber;deadlineAt;manifest;deps;license;requestedBy;writeAllowed;claudeCodeVersion;deployedPins;statedPins;runSettings;static{o(this,"V3Attempt")}budgetMs(e){return U2(this.deadlineAt,e)}get skyrampRunUrl(){return O2(Jp(this.deps.origin),this.manifest.runId)}send(e,n,r){return Uu(this.deps,e,n,r)}readBytes(e,n){return G2(this.deps,e,n)}issuedTokens=[];closure;modelKey;modelCredentials=[];credentials={};revocation;token(){return this.cachedToken("run")}readOnlyToken(){return this.cachedToken("read")}async cachedToken(e){if(this.revocation)throw new Error(Tk);let n=(this.deps.now??(()=>new Date))().getTime(),r=this.credentials[e],s=r&&await r.catch(()=>{});if(this.credentials[e]!==r)return(await this.credentials[e]).token;if(s&&s.expiresAt-n>=M2)return s.token;if(this.revocation)throw new Error(Tk);let i=e==="read",a=i?{schemaVersion:1,access:e}:{schemaVersion:1},c=i?"read-only":"scoped",l=this.send("POST",`/api/v1/runner/attempts/${this.attemptId}/credentials`,a).then(d=>{let h={...d,token:d.token??this.jobToken()};if(this.issuedTokens.push(h.token),this.deps.mask?.(h.token),h.anthropicApiKey&&this.deps.mask?.(h.anthropicApiKey),i&&d.token&&!L2(h.permissions))throw new Error(`The Skyramp app was asked for a read-only GitHub token, but its token grants ${JSON.stringify(h.permissions??null)}`);!i&&!s&&h.anthropicApiKey&&(this.modelKey=h.anthropicApiKey),this.deps.onTokenGranted?.(e);let g=s?"Renewed":"Received";return d.token&&this.deps.log?.(`${g} ${c} GitHub credentials; they expire at ${h.expiresAt}.`),{token:h.token,expiresAt:d.token?new Date(h.expiresAt).getTime():Number.POSITIVE_INFINITY}},d=>{if(this.deps.onTokenRefused?.(d,e),!(d instanceof an)||d.code!=="CREDENTIALS_UNAVAILABLE")throw d;let h=o(m=>[...new Set(m.map(C=>C.namespace))].join(", "),"unique"),g=this.manifest.sources.map(m=>m.repository);if(new Set(g.map(m=>m.providerAccountId)).size>1)throw new an(`${d.message}. The run's repositories are on more than one GitHub account (${h(g)}), which Skyramp does not support yet.`,d.status,d.code);let f=h([...g,this.manifest.execution.repository]);throw new an(`${d.message}. Check the Skyramp GitHub App installation on ${f}: it must be installed and not suspended, have access to these repositories, and have accepted the App's current permissions. Each account must also be connected to your Skyramp organization.`,d.status,d.code)});return this.credentials[e]=l,(await l).token}jobToken(){if(this.deps.sourceToken)return this.deps.sourceToken;throw new Error("The app answered the credentials request without a token, and the job gave Testbot none of its own: on Azure Pipelines, set SYSTEM_ACCESSTOKEN to $(System.AccessToken) in the Testbot step's env.")}sourceFetch(e){return e.fetch??this.deps.fetch??fetch}revokeTokens(e={}){let n=e.host??Dk();return this.revocation??=n.revokeToken?this.revokeIssued(r=>n.revokeToken(r,this.sourceFetch(e))):Promise.resolve([]),this.revocation}async revokeIssued(e){let n=[...this.issuedTokens],r=Promise.all(n.map(a=>this.revokeOne(a,e)));await Promise.all(Object.values(this.credentials).map(a=>a.catch(()=>{})));let s=this.issuedTokens.filter(a=>!n.includes(a));return[...await r,...await Promise.all(s.map(a=>this.revokeOne(a,e)))].filter(a=>a!==void 0)}async revokeOne(e,n){try{await n(e);return}catch(r){return`token ${this.issuedTokens.indexOf(e)+1} of ${this.issuedTokens.length}: ${r instanceof Error?r.message:String(r)}`}}};async function Lk(t,e,n){Fk(t,"run id"),Jp(n.origin);let r=ll(t,e),s=`/api/v1/runner/runs/${t}/attempts`,i;try{i=await Uu(n,"POST",s,r)}catch(d){if(!(d instanceof an&&d.status===400&&d.path==="$.statedPins"))throw d;r=ll(t,e,{statedPins:!1}),i=await Uu(n,"POST",s,r)}let a=Wf(i);if(a.manifest.runId!==t)throw new Error(`The app answered the handshake of run ${t} with the manifest of another run (${a.manifest.runId})`);let c=a.manifest.sources.find(d=>d.repository.provider!==r.execution.provider);if(c)throw new Error(`The manifest of run ${t} names ${c.repository.namespace}/${c.repository.name} on ${c.repository.provider}, but this job runs on ${r.execution.provider}`);$2(a.manifest,[...a.deployedRevisions??[],...a.statedRevisions??[]]),a.runToken&&n.mask?.(a.runToken);let l=a.runToken?{entitlements:a.entitlements??[],runToken:a.runToken}:void 0;return new Ja(a.attempt.id,a.attempt.number,new Date(a.attempt.deadlineAt),a.manifest,n,l,a.requestedBy??void 0,a.writeAllowed,a.claudeCodeVersion??void 0,a.deployedRevisions??[],a.statedRevisions??[],a.runSettings)}o(Lk,"startV3Attempt");function $2(t,e){if(e.length===0)return;if(t.trigger.kind!=="schedule")throw new Error(`The app pinned an attempt of a ${t.trigger.kind} run; only a scheduled run's retry is pinned to an earlier attempt's read`);let n=new Set(t.sources.map(s=>Fn(s.repository))),r=new Set;for(let s of e){let i=Fn(s.repository);if(!n.has(i))throw new Error(`The app pinned the attempt to repository ${s.repository.providerRepositoryId}, which is not a source of the run`);if(r.has(i))throw new Error(`The app pinned repository ${s.repository.providerRepositoryId} twice`);r.add(i)}}o($2,"checkAttemptPins");async function qp(t){return Jf.parse(await t.send("POST",`/api/v1/runner/attempts/${t.attemptId}/heartbeat`,{schemaVersion:1}))}o(qp,"heartbeatV3Attempt");async function _k(t,e=()=>new Date){if(t.closure)return t.closure;let n=await qp(t).then(r=>qf(r,e())).catch(()=>null);return n&&(t.closure=n),n}o(_k,"closedV3Attempt");var o6=10*6e4;var a6=["TRIGGER","AUTHORITATIVE_RELATED_CHANGE"];var A6=A.object({tests:A.object({placements:A.array(A.unknown()).optional()}).passthrough().optional()}).passthrough(),c6=A.object({repository:ul,testType:A.nativeEnum(CA),directory:A.string()}).passthrough();var u6=A.object({report:A.object({language:A.string()}).passthrough()}).passthrough();var l6=A.object({environment:A.object({components:A.array(A.unknown()).optional(),dependencies:A.array(A.unknown()).optional()}).passthrough()}).passthrough(),d6=A.object({name:A.string().min(1),provision:A.literal("existing"),url:A.string().min(1),repository:ul.optional(),revisionUrl:A.string().min(1).optional()}).passthrough(),h6=A.object({name:A.string().min(1),url:A.string().nullable(),versionUrl:A.string().nullable(),notes:A.string().nullable()}).passthrough();var g6=new Set(["TRIGGER","AUTHORITATIVE_RELATED_CHANGE","MANUAL_OVERRIDE"]);function Pk(t){let e=o(n=>t.testResults.filter(r=>r.status===n).length,"count");return{passed:e("Pass"),failed:e("Fail"),skipped:e("Skipped")}}o(Pk,"statusCounts");function Y2(t){let{passed:e,failed:n,skipped:r}=Pk(t);return e+n===0?{sufficiency:"insufficient",rationale:r>0?`Every test was skipped (${r}), so nothing was validated.`:"No test ran, so nothing was validated.",gaps:["No test ran against the frozen sources."],acceptedEvidence:[],actionRequired:[]}:{sufficiency:"sufficient",rationale:`${e+n} tests ran against the frozen sources: ${e} passed, ${n} failed${r?`, ${r} skipped`:""}.`,gaps:[],acceptedEvidence:[],actionRequired:[]}}o(Y2,"executedTestsValidation");function V2(t,e){let n=t.testResults.map(l=>({result:l,repository:l.repository??e,path:l.fileName||l.testType})),r=new Map;for(let l of n){let d=`${l.repository}:${l.result.testType}:${l.path}`;r.set(d,(r.get(d)??0)+1)}let s=n.map(({result:l,repository:d,path:h})=>{let g=(r.get(`${d}:${l.testType}:${h}`)??0)>1;return l.resultId??Lf(d,l.testType,h,g&&l.endpoint||void 0)}),i=new Map;for(let l of s)i.set(l,(i.get(l)??0)+1);let a=new Set(s.filter(l=>i.get(l)===1)),c=n.map(({result:l,repository:d},h)=>{let g=s[h],f=g;if(i.get(g)>1&&a.has(g))for(let m=2;a.has(f)||f===g;m+=1)f=g.includes("#")?`${g}.${m}`:`${g}#${m}`;return a.add(f),{...l,repository:d,resultId:f}});return{...t,testResults:c,...H2(t,c,e),validation:j2(t,J2(t,t.validation??Y2(t))),traceVersion:1}}o(V2,"v3Report");function H2(t,e,n){if(!t.testExecutionContexts)return{};let r=new Set,s=o(c=>{let l=c;for(let d=2;r.has(l);d+=1)l=`${c}#${d}`;return r.add(l),l},"unique"),i=[],a=new Map;for(let{repository:c,...l}of t.testExecutionContexts){let d=l.status==="not_run"?[]:e.filter(h=>h.fileName===l.test&&h.repository===(c?.trim()||n));d.length||i.push(l);for(let{resultId:h}of d){let g=a.get(h),f=g!==void 0&&i[g].cleanup.status==="failed"?i[g].cleanup:l.cleanup,m={...l,cleanup:f,test:h,resultId:h};g===void 0?a.set(h,i.push(m)-1):i[g]=m}}for(let c of i)c.resultId&&r.add(c.resultId);return{testExecutionContexts:i.map(c=>c.resultId?c:{...c,test:s(c.test.slice(0,512))}).slice(0,5e3)}}o(H2,"linkedContexts");function J2(t,e){let{passed:n,failed:r}=Pk(t);return e.sufficiency!=="sufficient"||n+r>0||e.acceptedEvidence.length>0?e:{...e,sufficiency:"insufficient",gaps:["No test ran and no existing evidence was accepted, so nothing was validated."]}}o(J2,"withEvidence");var q2={"model-provider-denied":"model_provider_denied","model-provider-unavailable":"model_provider_unavailable"};function j2(t,e){if(e.sufficiency==="sufficient")return e;let n=(t.caveats??[]).map(s=>q2[s.kind]).filter(s=>s!==void 0),r=[...new Set(n)].filter(s=>!e.actionRequired.includes(s));return r.length?{...e,actionRequired:[...r,...e.actionRequired]}:e}o(j2,"withModelProviderFailure");async function Ok(t,e){let n=em([...t.issuedTokens,...e.secrets??[]]),r=zf({manifest:t.manifest,attemptNumber:t.attemptNumber,checkedOut:e.sources.map(s=>({repository:s.repository,revision:s.revision})),firstQualification:e.firstQualification,generatedTests:zs(e.delivery,n),producer:e.producer,report:zs(V2(e.report,e.workingSlug),n),githubWrites:e.githubWrites});await t.send("PUT",`/api/v1/runner/attempts/${t.attemptId}/report`,r)}o(Ok,"uploadV3Report");async function Gk(t,e){return Fk(t.attemptId,"attempt id"),Uu(e,"POST",`/api/v1/runner/attempts/${t.attemptId}/end`,Zf({reportUploaded:t.reportUploaded,recipeUploaded:t.recipeUploaded,revisionsUploaded:t.revisionsUploaded,cancelled:t.cause==="cancelled",timedOut:t.cause==="timed_out",setupFailed:t.cause==="setup_failed",checkoutFailed:t.cause==="checkout_failed",environmentUnverified:t.cause==="environment_unverified",runnerProviderNotReady:t.cause==="runner_provider_not_ready",credentialMissing:t.cause==="credential_missing",modelProviderDenied:t.cause==="model_provider_denied",modelProviderUnavailable:t.cause==="model_provider_unavailable"}))}o(Gk,"endV3Attempt");0&&(module.exports={AppRefusal,AppUnreachable,AttemptEndReason,DeliveryStatus,GitHubWriteKind,NoReportCause,SourceProvider,V3Attempt,ValidationSufficiency,closedV3Attempt,endV3Attempt,heartbeatV3Attempt,startV3Attempt,uploadV3Report});
88
88
  /*! Bundled license information:
89
89
 
90
90
  undici/lib/web/fetch/body.js:
@@ -4207,6 +4207,8 @@ export declare class V3Attempt {
4207
4207
  closure?: AttemptClosure;
4208
4208
  /** The model provider key the first credentials answer carried, if any. A renewal never changes it. */
4209
4209
  modelKey?: string;
4210
+ /** The names the run's own model provider credentials have in its env (modelCredentialNames), set once the run's settings chose the provider (beginV3Run). */
4211
+ modelCredentials: string[];
4210
4212
  /** The current credentials of each kind, kept and renewed apart. */
4211
4213
  private readonly credentials;
4212
4214
  /** The one revocation, which a later caller waits for. Once it started, the attempt mints no more tokens. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/testbot-core",
3
- "version": "0.13.0-v3.230",
3
+ "version": "0.13.0-v3.232",
4
4
  "description": "Skyramp Testbot engine: AI-powered deterministic test generation, execution and maintenance",
5
5
  "main": "dist/main.js",
6
6
  "//files": "An explicit allowlist, never a glob. `dist/` is gitignored, so without this key npm's .gitignore fallback would publish a package with no engine in it; with a glob it would publish the sourcemaps, whose sourcesContent embeds every src/*.ts verbatim. dist/VERSION.json exists only in a release-engine.yml build.",