@skyramp/testbot-core 0.13.0-v3.218 → 0.13.0-v3.220

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/post.js CHANGED
@@ -115,14 +115,14 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}fun
115
115
  `+d.slice(I+1):N+=d.slice(b),N.slice(1)}function dt(d){let m="",y=0;for(let Q=0;Q<d.length;y>=65536?Q+=2:Q++){y=ze(d,Q);let b=fe[y];!b&&At(y)?(m+=d[Q],y>=65536&&(m+=d[Q+1])):m+=b||st(y)}return m}function Ks(d,m,y){let Q="",b=d.tag;for(let k=0,I=y.length;k<I;k+=1){let R=y[k];d.replacer&&(R=d.replacer.call(y,String(k),R)),(f(d,m,R,!1,!1)||typeof R>"u"&&f(d,m,null,!1,!1))&&(Q!==""&&(Q+=","+(d.condenseFlow?"":" ")),Q+=d.dump)}d.tag=b,d.dump="["+Q+"]"}function Mn(d,m,y,Q){let b="",k=d.tag;for(let I=0,R=y.length;I<R;I+=1){let N=y[I];d.replacer&&(N=d.replacer.call(y,String(I),N)),(f(d,m+1,N,!0,!0,!1,!0)||typeof N>"u"&&f(d,m+1,null,!0,!0,!1,!0))&&((!Q||b!=="")&&(b+=Xt(d,m)),d.dump&&c===d.dump.charCodeAt(0)?b+="-":b+="- ",b+=d.dump)}d.tag=k,d.dump=b||"[]"}function Zs(d,m,y){let Q="",b=d.tag,k=Object.keys(y);for(let I=0,R=k.length;I<R;I+=1){let N="";Q!==""&&(N+=", "),d.condenseFlow&&(N+='"');let M=k[I],_=y[M];d.replacer&&(_=d.replacer.call(y,M,_)),f(d,m,M,!1,!1)&&(d.dump.length>1024&&(N+="? "),N+=d.dump+(d.condenseFlow?'"':"")+":"+(d.condenseFlow?"":" "),f(d,m,_,!1,!1)&&(N+=d.dump,Q+=N))}d.tag=b,d.dump="{"+Q+"}"}function Xs(d,m,y,Q){let b="",k=d.tag,I=Object.keys(y);if(d.sortKeys===!0)I.sort();else if(typeof d.sortKeys=="function")I.sort(d.sortKeys);else if(d.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let R=0,N=I.length;R<N;R+=1){let M="";(!Q||b!=="")&&(M+=Xt(d,m));let _=I[R],G=y[_];if(d.replacer&&(G=d.replacer.call(y,_,G)),!f(d,m+1,_,!0,!0,!0))continue;let q=d.tag!==null&&d.tag!=="?"||d.dump&&d.dump.length>1024;q&&(d.dump&&c===d.dump.charCodeAt(0)?M+="?":M+="? "),M+=d.dump,q&&(M+=Xt(d,m)),f(d,m+1,G,!0,q)&&(d.dump&&c===d.dump.charCodeAt(0)?M+=":":M+=": ",M+=d.dump,b+=M)}d.tag=k,d.dump=b||"{}"}function o(d,m,y){let Q=y?d.explicitTypes:d.implicitTypes;for(let b=0,k=Q.length;b<k;b+=1){let I=Q[b];if((I.instanceOf||I.predicate)&&(!I.instanceOf||typeof m=="object"&&m instanceof I.instanceOf)&&(!I.predicate||I.predicate(m))){if(y?I.multi&&I.representName?d.tag=I.representName(m):d.tag=I.tag:d.tag="?",I.represent){let R=d.styleMap[I.tag]||I.defaultStyle,N;if(r.call(I.represent)==="[object Function]")N=I.represent(m,R);else if(s.call(I.represent,R))N=I.represent[R](m,R);else throw new e("!<"+I.tag+'> tag resolver accepts not "'+R+'" style');d.dump=N}return!0}}return!1}function f(d,m,y,Q,b,k,I){d.tag=null,d.dump=y,o(d,y,!1)||o(d,y,!0);let R=r.call(d.dump),N=Q;Q&&(Q=d.flowLevel<0||d.flowLevel>m);let M=R==="[object Object]"||R==="[object Array]",_,G;if(M&&(_=d.duplicates.indexOf(y),G=_!==-1),(d.tag!==null&&d.tag!=="?"||G||d.indent!==2&&m>0)&&(b=!1),G&&d.usedDuplicates[_])d.dump="*ref_"+_;else{if(M&&G&&!d.usedDuplicates[_]&&(d.usedDuplicates[_]=!0),R==="[object Object]")Q&&Object.keys(d.dump).length!==0?(Xs(d,m,d.dump,b),G&&(d.dump="&ref_"+_+d.dump)):(Zs(d,m,d.dump),G&&(d.dump="&ref_"+_+" "+d.dump));else if(R==="[object Array]")Q&&d.dump.length!==0?(d.noArrayIndent&&!I&&m>0?Mn(d,m-1,d.dump,b):Mn(d,m,d.dump,b),G&&(d.dump="&ref_"+_+d.dump)):(Ks(d,m,d.dump),G&&(d.dump="&ref_"+_+" "+d.dump));else if(R==="[object String]")d.tag!=="?"&&Sr(d,d.dump,m,k,N);else{if(R==="[object Undefined]")return!1;if(d.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+R)}if(d.tag!==null&&d.tag!=="?"){let q=encodeURI(d.tag[0]==="!"?d.tag.slice(1):d.tag).replace(/!/g,"%21");d.tag[0]==="!"?q="!"+q:q.slice(0,18)==="tag:yaml.org,2002:"?q="!!"+q.slice(18):q="!<"+q+">",d.dump=q+" "+d.dump}}return!0}function B(d,m){let y=[],Q=[];w(d,y,Q);let b=Q.length;for(let k=0;k<b;k+=1)m.duplicates.push(y[Q[k]]);m.usedDuplicates=new Array(b)}function w(d,m,y){if(d!==null&&typeof d=="object"){let Q=m.indexOf(d);if(Q!==-1)y.indexOf(Q)===-1&&y.push(Q);else if(m.push(d),Array.isArray(d))for(let b=0,k=d.length;b<k;b+=1)w(d[b],m,y);else{let b=Object.keys(d);for(let k=0,I=b.length;k<I;k+=1)w(d[b[k]],m,y)}}}function E(d,m){m=m||{};let y=new Ws(m);y.noRefs||B(d,y);let Q=d;return y.replacer&&(Q=y.replacer.call({"":Q},"",Q)),f(y,0,Q,!0,!0)?y.dump+`
116
116
  `:""}return ry.dump=E,ry}var Ax;function OY(){if(Ax)return wt;Ax=1;let t=LY(),e=PY();function n(r,s){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}return wt.Type=Ft(),wt.Schema=lx(),wt.FAILSAFE_SCHEMA=fx(),wt.JSON_SCHEMA=Cx(),wt.CORE_SCHEMA=Ix(),wt.DEFAULT_SCHEMA=sy(),wt.load=t.load,wt.loadAll=t.loadAll,wt.dump=e.dump,wt.YAMLException=fu(),wt.types={binary:Qx(),float:Ex(),map:hx(),null:gx(),pairs:Sx(),set:kx(),timestamp:Bx(),bool:mx(),int:yx(),merge:wx(),omap:bx(),seq:px(),str:dx()},wt.safeLoad=n("safeLoad","load"),wt.safeLoadAll=n("safeLoadAll","loadAll"),wt.safeDump=n("safeDump","dump"),wt}var $Y=OY(),VY=_Y($Y),{Type:A4,Schema:l4,FAILSAFE_SCHEMA:d4,JSON_SCHEMA:vx,CORE_SCHEMA:p4,DEFAULT_SCHEMA:h4,load:gu,loadAll:GY,dump:f4,YAMLException:g4,types:m4,safeLoad:y4,safeLoadAll:E4,safeDump:C4}=VY;var Wr=t=>typeof t=="string"?t:void 0;function xx(t){let e={services:[]},n;try{let A=Rx.readFileSync(t,"utf8");n=gu(A,{schema:vx})}catch(A){return Pe(`Lenient parse: failed to read/parse ${t}: ${A.message}`),e}if(!n||typeof n!="object"||Array.isArray(n))return Pe(`Lenient parse: ${t} did not contain a YAML object`),e;let r=n,s=r.metadata&&typeof r.metadata=="object"?r.metadata:void 0,i=s?{executorVersion:Wr(s.executorVersion),mcpVersion:Wr(s.mcpVersion)}:void 0,c=(Array.isArray(r.services)?r.services:[]).reduce((A,l,p)=>{if(!l||typeof l!="object"||Array.isArray(l))return Pe(`Lenient parse: services[${p}] is not an object \u2014 skipping`),A;let h=l,g=Wr(h.serviceName);if(!g)return Pe(`Lenient parse: services[${p}] missing or non-string serviceName \u2014 skipping`),A;let C=h.api&&typeof h.api=="object"?h.api:void 0,S=h.runtimeDetails&&typeof h.runtimeDetails=="object"?h.runtimeDetails:void 0;return A.push({serviceName:g,language:Wr(h.language),framework:Wr(h.framework),testDirectory:Wr(h.testDirectory),api:C?{baseUrl:Wr(C.baseUrl)}:void 0,runtimeDetails:S?{serverStartCommand:Wr(S.serverStartCommand),serverTeardownCommand:Wr(S.serverTeardownCommand)}:void 0}),A},[]);return{metadata:i,services:c}}async function Dx(t){let e=Tx.resolve(t.workingDirectory),n=new fd(e),r=[],s=t.targetSetupCommand,i=t.targetTeardownCommand,a=t.skyrampExecutorVersion,c=t.skyrampMcpVersion;if(await n.exists()){In(`Found ${n.getConfigPath()}, loading workspace configuration...`);try{let l;try{l=await n.read()}catch(h){Pe(`${n.getConfigPath()} failed strict validation: ${h.message}. Re-reading with per-field lenient parse \u2014 invalid fields will fall back to action input defaults.`),l=xx(n.getConfigPath())}l.metadata&&(!a&&l.metadata.executorVersion&&(a=l.metadata.executorVersion),!c&&l.metadata.mcpVersion&&(c=l.metadata.mcpVersion));for(let h of l.services??[])r.push({serviceName:h.serviceName,language:h.language,framework:h.framework,baseUrl:h.api?.baseUrl,testDirectory:h.testDirectory});let p=(l.services??[])[0];if(p){!s&&p.runtimeDetails?.serverStartCommand&&(s=p.runtimeDetails.serverStartCommand);let h=p.runtimeDetails?.serverTeardownCommand;!i&&typeof h=="string"&&(i=h)}}catch(l){Pe(`Failed to parse ${n.getConfigPath()}: ${l.message} \u2014 falling back to action input defaults`)}}else ou("No .skyramp/workspace.yml found, using action input defaults");a||(a="v1.3.54"),c||(c="latest"),s||(s="docker compose up -d --build");let A={targetSetupCommand:s,authTokenCommand:t.authTokenCommand,targetTeardownCommand:i,skipTargetTeardown:t.skipTargetTeardown,skyrampExecutorVersion:a,skyrampMcpVersion:c,skyrampMcpSource:t.skyrampMcpSource,skyrampMcpGithubRef:t.skyrampMcpGithubRef,nodeVersion:t.nodeVersion,skipTargetSetup:t.skipTargetSetup,targetReadyCheckCommand:t.targetReadyCheckCommand,targetReadyCheckTimeout:t.targetReadyCheckTimeout,targetReadyCheckInterval:t.targetReadyCheckInterval,targetReadyCheckDiagnosticsCommand:t.targetReadyCheckDiagnosticsCommand,autoCommit:t.autoCommit,commitMessage:t.commitMessage,generatedTestsMode:t.generatedTestsMode,postPrComment:t.postPrComment,testExecutionTimeout:t.testExecutionTimeout,maxRecommendations:t.maxRecommendations,maxGenerate:t.maxGenerate,perTestMaxFixAttempts:t.perTestMaxFixAttempts,testbotMaxRetries:t.testbotMaxRetries,testbotRetryDelay:t.testbotRetryDelay,testbotTimeout:t.testbotTimeout,targetSetupRetries:t.targetSetupRetries,targetSetupRetryDelay:t.targetSetupRetryDelay,authTokenRetries:t.authTokenRetries,authTokenRetryDelay:t.authTokenRetryDelay,reportCollapsed:t.reportCollapsed,language:t.language,enableDebug:t.enableDebug,testRepoPath:t.testRepoPath,relatedRepoPaths:t.relatedRepoPaths,services:r};Zl("Resolved configuration");for(let[l,p]of Object.entries(A))l==="authTokenCommand"?In(` ${l}: [REDACTED]`):l==="services"?In(` ${l}: ${JSON.stringify(p)}`):In(` ${l}: ${p}`);return Xl(),A}Dt();Dt();zg();var Fx=Re(require("child_process")),iy=class extends Error{constructor(e){super(e),this.name="ExecTimeoutError"}},yd=class extends Error{constructor(e){super(e),this.name="ExecAbortedError"}};function Nx(t,e){if(!(!t||t.destroyed||t.writableEnded))try{t.write(e)}catch(n){Pe(`stream write failed: ${n instanceof Error?n.message:String(n)}`)}}async function Mx(t,e=[],n={}){let r="",s="",i={cwd:n.cwd,silent:n.silent??!1,ignoreReturnCode:n.ignoreReturnCode??!1,env:n.env?{...process.env,...n.env}:void 0,input:n.input,listeners:{stdout:c=>{r+=c.toString(),Nx(n.stdoutStream,c)},stderr:c=>{s+=c.toString()}}};if(n.timeout||n.signal){let c=n.signal;return c?.aborted?Promise.reject(new yd(`Command aborted before start: ${t}`)):new Promise((A,l)=>{let p=Fx.spawn(t,e,{cwd:n.cwd,env:n.env?{...process.env,...n.env}:process.env,stdio:["pipe","pipe","pipe"],shell:!1});p.stdout?.on("data",v=>{r+=v.toString(),n.silent||process.stdout.write(v),Nx(n.stdoutStream,v)}),p.stderr?.on("data",v=>{s+=v.toString(),n.silent||process.stderr.write(v)}),n.input&&p.stdin?.end(n.input);let h=()=>{S&&clearTimeout(S),c?.removeEventListener("abort",C)},g=v=>{h();try{p.kill("SIGTERM")}catch{}l(v)},C=()=>g(new yd(`Command aborted: ${t}`)),S=n.timeout?setTimeout(()=>g(new iy(`Command timed out after ${Math.round(n.timeout/6e4)}m: ${t}`)),n.timeout):void 0;c?.addEventListener("abort",C,{once:!0}),p.on("close",v=>{h();let T=v??1;T!==0&&!n.ignoreReturnCode?l(new Error(`The process '${t}' failed with exit code ${T}`)):A({exitCode:T,stdout:r,stderr:s})}),p.on("error",v=>{h(),l(v)})})}return{exitCode:await pv(t,e,i),stdout:r,stderr:s}}async function _x(t,e){Zl(t);try{return await e()}finally{Xl()}}async function Ux(t,e){await _x("Tearing down services",async()=>{if(t.skipTargetTeardown){ou("Skipping service teardown (skipTargetTeardown=true)");return}if(!t.targetTeardownCommand){In("No targetTeardownCommand configured, skipping teardown");return}In(`Running teardown command: ${t.targetTeardownCommand}`);try{await Mx("bash",["-c",t.targetTeardownCommand],{cwd:e}),ou("Services torn down successfully")}catch(n){let r=n instanceof Error?n.message:String(n);Pe(`Service teardown command failed (non-fatal): ${r}`)}})}Dt();Dt();var qi=(i=>(i.NotFound="not_found",i.NoAccess="no_access",i.Unavailable="unavailable",i.AccessLost="access_lost",i.CannotOpen="cannot_open",i))(qi||{});var oy=t=>`${t.source}:${t.site??""}:${t.key}`;var Ed=/^pasted-[0-9a-f]{16}$/,mu=/^file-[0-9a-f]{16}$/,yu=(s=>(s.Pdf="application/pdf",s.Csv="text/csv",s.Docx="application/vnd.openxmlformats-officedocument.wordprocessingml.document",s.Xlsx="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",s))(yu||{});var ay=(r=>(r.New="new",r.Updated="updated",r.Existing="existing",r))(ay||{}),Sa=(r=>(r.Sufficient="sufficient",r.Insufficient="insufficient",r.NoChange="no_change",r))(Sa||{}),ka=(T=>(T.RelatedChangeConflict="related_change_conflict",T.ReferenceOutsideTarget="reference_outside_target",T.SourceAccessLost="source_access_lost",T.ConfigurationIncomplete="configuration_incomplete",T.CredentialUnavailable="credential_unavailable",T.WorkflowBindingUnverified="workflow_binding_unverified",T.WorkflowRefUnprotected="workflow_ref_unprotected",T.BedrockWorkflowRequired="bedrock_workflow_required",T.DeploymentReview="deployment_review",T.SutRevisionMismatch="sut_revision_mismatch",T.IsolationUnavailable="isolation_unavailable",T.EvidenceInsufficient="evidence_insufficient",T.ConfigurationUnresolved="configuration_unresolved",T.ModelProviderDenied="model_provider_denied",T.ModelProviderUnavailable="model_provider_unavailable",T.RunnerProviderNotReady="runner_provider_not_ready",T))(ka||{}),_s=(i=>(i.CiCheck="ci_check",i.TestReport="test_report",i.StaticAnalysis="static_analysis",i.CodeReview="code_review",i.Other="other",i))(_s||{}),cy=(r=>(r.Application="application",r.Environment="environment",r.TestDefect="test_defect",r))(cy||{}),uy=(c=>(c.AuthToken="auth_token",c.Secret="secret",c.DataConnection="data_connection",c.AppNotStarted="app_not_started",c.Login="login",c.ExternalDependency="external_dependency",c.RecordingReplay="recording_replay",c))(uy||{});var Cd=(n=>(n.Probe="probe",n.Agent="agent",n))(Cd||{}),Id=(r=>(r.Seed="seed",r.RuntimeMock="runtime_mock",r.EnvOverride="env_override",r))(Id||{}),Bd=(r=>(r.TestCode="test_code",r.SkyrampMocker="skyramp_mocker",r.RecipeOverride="recipe_override",r))(Bd||{});var YY=["generate-unit","native-run"],T4=["preflight","plan","write",...YY,"report","deliver"];var Qd=(r=>(r.Unit="unit",r.Integration="integration",r.E2e="e2e",r))(Qd||{});var bd="\xABredacted\xBB";function zr(t,e){if(!t||e.length===0)return t;let n=t;for(let r of e)!r||!n.includes(r)||(n=n.split(r).join(bd));return n}var L4=new TextDecoder("utf-8",{fatal:!0});function jt(t,e=[]){let n=t.trim();if(!n)return{error:"session produced no output"};let r=A=>{try{let l=JSON.parse(A);return typeof l=="object"&&l!==null&&!Array.isArray(l)?l:void 0}catch{return}},s=r(n);if(s!==void 0)return{value:s};let i;if(n.startsWith("{")&&n.endsWith("}"))try{JSON.parse(n)}catch(A){i=A instanceof Error?A.message:String(A)}let a=[...n.matchAll(/```(?:json)?\s*\n([\s\S]*?)```/g)];for(let A=a.length-1;A>=0;A--){let l=r(a[A][1].trim());if(l!==void 0)return{value:l}}let c;for(let A=n.indexOf("{");A!==-1;A=n.indexOf("{",A+1)){let l=0,p=!1,h=!1;for(let g=A;g<n.length;g++){let C=n[g];if(h){h=!1;continue}if(C==="\\"){h=p;continue}if(C==='"'){p=!p;continue}if(!p){if(C==="{")l++;else if(C==="}"&&(l--,l===0)){let S=r(n.slice(A,g+1));S!==void 0&&Object.keys(S).length>0&&(c=S,A=g);break}}}}return i&&(c===void 0||Object.keys(c).length<3)?{error:`final message is not valid JSON \u2014 ${i}. Most often an unescaped double quote inside a string (e.g. in "summary" or "evidence"): escape it as \\" or use single quotes in prose`}:c!==void 0?{value:c}:i?{error:`final message is not valid JSON \u2014 ${i}. Most often an unescaped double quote inside a string (e.g. in "summary" or "evidence"): escape it as \\" or use single quotes in prose`}:{error:`no parseable JSON object found in session output \u2014 the final message was: "${qY(zr(n,e))}"`}}var Px=240;function qY(t){let e=t.replace(/\s+/g," ").trim();return e.length<=Px?e:`\u2026${e.slice(-Px)}`}var Eu=Re(require("fs")),Cu=Re(require("path"));var jY=8;function Mt(t,e,n={}){let r=e.slice(0,jY),s=e.length-r.length;return{name:t,passed:!1,details:r.join("; ")+(s>0?`; \u2026and ${s} more`:""),...n.fatal?{fatal:!0}:{}}}function va(t){if(Eu.existsSync(t))try{return JSON.parse(Eu.readFileSync(t,"utf-8"))}catch{return}}function bn(t,e){return va(Cu.join(t.outputsDir,e))}function Us(t,e){return{name:t,verify(n,r){let{errors:s}=e(n,r);return s.length===0?{name:this.name,passed:!0}:Mt(this.name,s,{fatal:!0})}}}function Iu(t){return t.replace(/\s+/g," ").trim()}var Sd=new RegExp("(^|/)("+["test_[^/]+\\.py","[^/]+_test\\.py","[^/]+\\.(spec|test)\\.[cm]?[jt]sx?","[^/]+\\.e2e-(spec|test)\\.[cm]?[jt]sx?","[^/]+_test\\.go","[^/]+Tests?\\.(java|kts?)","[^/]+_(test|spec)\\.rb","[^/]+\\.feature","[^/]+Tests?\\.cs","[^/]+_test\\.rs","tests/[^/]+\\.rs","[^/]+Test\\.php","[^/]+(Test|Spec|Suite)\\.scala","[^/]+Tests?\\.swift","[^/]+_test\\.exs","[^/]+_test\\.dart","[^/]+_test\\.(c|cc|cpp|cxx)","test_[^/]+\\.(c|cc|cpp|cxx)","[^/]+(Spec|Test)\\.groovy"].join("|")+")$","i");var u={};ip(u,{BRAND:()=>Eq,DIRTY:()=>ji,EMPTY_PATH:()=>KY,INVALID:()=>ie,NEVER:()=>rj,OK:()=>Qt,ParseStatus:()=>mt,Schema:()=>Ce,ZodAny:()=>Os,ZodArray:()=>es,ZodBigInt:()=>Wi,ZodBoolean:()=>zi,ZodBranded:()=>wu,ZodCatch:()=>ao,ZodDate:()=>Ki,ZodDefault:()=>oo,ZodDiscriminatedUnion:()=>Rd,ZodEffects:()=>vn,ZodEnum:()=>so,ZodError:()=>Jt,ZodFirstPartyTypeKind:()=>Ae,ZodFunction:()=>Td,ZodIntersection:()=>to,ZodIssueCode:()=>O,ZodLazy:()=>no,ZodLiteral:()=>ro,ZodMap:()=>Fa,ZodNaN:()=>_a,ZodNativeEnum:()=>io,ZodNever:()=>Wn,ZodNull:()=>Xi,ZodNullable:()=>Er,ZodNumber:()=>Ji,ZodObject:()=>Wt,ZodOptional:()=>Sn,ZodParsedType:()=>z,ZodPipeline:()=>Qu,ZodPromise:()=>$s,ZodReadonly:()=>co,ZodRecord:()=>xd,ZodSchema:()=>Ce,ZodSet:()=>Ma,ZodString:()=>Ps,ZodSymbol:()=>Da,ZodTransformer:()=>vn,ZodTuple:()=>yr,ZodType:()=>Ce,ZodUndefined:()=>Zi,ZodUnion:()=>eo,ZodUnknown:()=>Xr,ZodVoid:()=>Na,addIssueToContext:()=>J,any:()=>vq,array:()=>Dq,bigint:()=>wq,boolean:()=>zx,coerce:()=>nj,custom:()=>jx,date:()=>Qq,datetimeRegex:()=>Yx,defaultErrorMap:()=>Kr,discriminatedUnion:()=>_q,effect:()=>Jq,enum:()=>Yq,function:()=>Vq,getErrorMap:()=>Ra,getParsedType:()=>mr,instanceof:()=>Iq,intersection:()=>Uq,isAborted:()=>kd,isAsync:()=>xa,isDirty:()=>vd,isValid:()=>Ls,late:()=>Cq,lazy:()=>Gq,literal:()=>Hq,makeIssue:()=>Bu,map:()=>Oq,nan:()=>Bq,nativeEnum:()=>qq,never:()=>xq,null:()=>kq,nullable:()=>zq,number:()=>Wx,object:()=>Nq,objectUtil:()=>Ay,oboolean:()=>tj,onumber:()=>ej,optional:()=>Wq,ostring:()=>Xq,pipeline:()=>Zq,preprocess:()=>Kq,promise:()=>jq,quotelessJson:()=>JY,record:()=>Pq,set:()=>$q,setErrorMap:()=>zY,strictObject:()=>Fq,string:()=>Jx,symbol:()=>bq,transformer:()=>Jq,tuple:()=>Lq,undefined:()=>Sq,union:()=>Mq,unknown:()=>Rq,util:()=>Qe,void:()=>Tq});var Qe;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),a={};for(let c of i)a[c]=s[c];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Qe||(Qe={}));var Ay;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ay||(Ay={}));var z=Qe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),mr=t=>{switch(typeof t){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(t)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(t)?z.array:t===null?z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?z.promise:typeof Map<"u"&&t instanceof Map?z.map:typeof Set<"u"&&t instanceof Set?z.set:typeof Date<"u"&&t instanceof Date?z.date:z.object;default:return z.unknown}};var O=Qe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),JY=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Jt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,A=0;for(;A<a.path.length;){let l=a.path[A],p=A===a.path.length-1;if(l==="_errors"){p&&c._errors.push(n(a)),A++;continue}Object.prototype.hasOwnProperty.call(c,l)||(l==="__proto__"?Object.defineProperty(c,l,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):c[l]={_errors:[]}),c=c[l],p&&c._errors.push(n(a)),A++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Qe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n=Object.create(null),r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Jt.create=t=>new Jt(t);var WY=(t,e)=>{let n;switch(t.code){case O.invalid_type:t.received===z.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case O.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Qe.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:n=`Unrecognized key(s) in object: ${Qe.joinValues(t.keys,", ")}`;break;case O.invalid_union:n="Invalid input";break;case O.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Qe.joinValues(t.options)}`;break;case O.invalid_enum_value:n=`Invalid enum value. Expected ${Qe.joinValues(t.options)}, received '${t.received}'`;break;case O.invalid_arguments:n="Invalid function arguments";break;case O.invalid_return_type:n="Invalid function return type";break;case O.invalid_date:n="Invalid date";break;case O.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Qe.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case O.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case O.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case O.custom:n="Invalid input";break;case O.invalid_intersection_types:n="Intersection results could not be merged";break;case O.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case O.not_finite:n="Number must be finite";break;default:n=e.defaultError,Qe.assertNever(t)}return{message:n}},Kr=WY;var Ox=Kr;function zY(t){Ox=t}function Ra(){return Ox}var Bu=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="",A=r.filter(l=>!!l).slice().reverse();for(let l of A)c=l(a,{data:e,defaultError:c}).message;return{...s,path:i,message:c}},KY=[];function J(t,e){let n=Ra(),r=Bu({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Kr?void 0:Kr].filter(s=>!!s)});t.common.issues.push(r)}var mt=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return ie;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,a=await s.value;r.push({key:i,value:a})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ie;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}},ie=Object.freeze({status:"aborted"}),ji=t=>({status:"dirty",value:t}),Qt=t=>({status:"valid",value:t}),kd=t=>t.status==="aborted",vd=t=>t.status==="dirty",Ls=t=>t.status==="valid",xa=t=>typeof Promise<"u"&&t instanceof Promise;var Z;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Z||(Z={}));var kn=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},$x=(t,e)=>{if(Ls(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new Jt(t.common.issues);return this._error=n,this._error}}};function me(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,c)=>{let{message:A}=t;return a.code==="invalid_enum_value"?{message:A??c.defaultError}:typeof c.data>"u"?{message:A??r??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:A??n??c.defaultError}},description:s}}var Ce=class{get description(){return this._def.description}_getType(e){return mr(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:mr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new mt,ctx:{common:e.parent.common,data:e.data,parsedType:mr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(xa(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mr(e)},s=this._parseSync({data:e,path:r.path,parent:r});return $x(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mr(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Ls(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Ls(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:mr(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(xa(s)?s:Promise.resolve(s));return $x(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let a=e(s),c=()=>i.addIssue({code:O.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(A=>A?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new vn({schema:this,typeName:Ae.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Sn.create(this,this._def)}nullable(){return Er.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return es.create(this)}promise(){return $s.create(this,this._def)}or(e){return eo.create([this,e],this._def)}and(e){return to.create(this,e,this._def)}transform(e){return new vn({...me(this._def),schema:this,typeName:Ae.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new oo({...me(this._def),innerType:this,defaultValue:n,typeName:Ae.ZodDefault})}brand(){return new wu({typeName:Ae.ZodBranded,type:this,...me(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ao({...me(this._def),innerType:this,catchValue:n,typeName:Ae.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Qu.create(this,e)}readonly(){return co.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},ZY=/^c[^\s-]{8,}$/i,XY=/^[0-9a-z]+$/,eq=/^[0-9A-HJKMNP-TV-Z]{26}$/i,tq=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nq=/^[a-z0-9_-]{21}$/i,rq=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sq=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,iq=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,oq="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",ly,aq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,uq=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Aq=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lq=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dq=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Gx="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",pq=new RegExp(`^${Gx}$`);function Hx(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function hq(t){return new RegExp(`^${Hx(t)}$`)}function Yx(t){let e=`${Gx}T${Hx(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function fq(t,e){return!!((e==="v4"||!e)&&aq.test(t)||(e==="v6"||!e)&&uq.test(t))}function gq(t,e){if(!rq.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function mq(t,e){return!!((e==="v4"||!e)&&cq.test(t)||(e==="v6"||!e)&&Aq.test(t))}var Ps=class t extends Ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){let i=this._getOrReturnCtx(e);return J(i,{code:O.invalid_type,expected:z.string,received:i.parsedType}),ie}let r=new mt,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,c=e.data.length<i.value;(a||c)&&(s=this._getOrReturnCtx(e,s),a?J(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&J(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")iq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"email",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")ly||(ly=new RegExp(oq,"u")),ly.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"emoji",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")tq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"uuid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")nq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"nanoid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")ZY.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cuid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")XY.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cuid2",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")eq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"ulid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),J(s,{validation:"url",code:O.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"regex",code:O.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),J(s,{code:O.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),J(s,{code:O.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),J(s,{code:O.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Yx(i).test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:O.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?pq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:O.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?hq(i).test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:O.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?sq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"duration",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?fq(e.data,i.version)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"ip",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?gq(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"jwt",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?mq(e.data,i.version)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cidr",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?lq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"base64",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?dq.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"base64url",code:O.invalid_string,message:i.message}),r.dirty()):Qe.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:O.invalid_string,...Z.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Z.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Z.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Z.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Z.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Z.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Z.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Z.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Z.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Z.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Z.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...Z.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Z.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Z.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Z.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Z.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Z.errToObj(n)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Ps.create=t=>new Ps({checks:[],typeName:Ae.ZodString,coerce:t?.coerce??!1,...me(t)});function yq(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}var Ji=class t extends Ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){let i=this._getOrReturnCtx(e);return J(i,{code:O.invalid_type,expected:z.number,received:i.parsedType}),ie}let r,s=new mt;for(let i of this._def.checks)i.kind==="int"?Qe.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),J(r,{code:O.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),J(r,{code:O.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),J(r,{code:O.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?yq(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),J(r,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),J(r,{code:O.not_finite,message:i.message}),s.dirty()):Qe.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Z.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Z.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Z.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Z.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Z.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Qe.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};Ji.create=t=>new Ji({checks:[],typeName:Ae.ZodNumber,coerce:t?.coerce||!1,...me(t)});var Wi=class t extends Ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==z.bigint)return this._getInvalidInput(e);let r,s=new mt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),J(r,{code:O.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),J(r,{code:O.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),J(r,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Qe.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return J(n,{code:O.invalid_type,expected:z.bigint,received:n.parsedType}),ie}gte(e,n){return this.setLimit("min",e,!0,Z.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Z.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Z.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Z.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Z.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Wi.create=t=>new Wi({checks:[],typeName:Ae.ZodBigInt,coerce:t?.coerce??!1,...me(t)});var zi=class extends Ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){let r=this._getOrReturnCtx(e);return J(r,{code:O.invalid_type,expected:z.boolean,received:r.parsedType}),ie}return Qt(e.data)}};zi.create=t=>new zi({typeName:Ae.ZodBoolean,coerce:t?.coerce||!1,...me(t)});var Ki=class t extends Ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){let i=this._getOrReturnCtx(e);return J(i,{code:O.invalid_type,expected:z.date,received:i.parsedType}),ie}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return J(i,{code:O.invalid_date}),ie}let r=new mt,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:O.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:O.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Qe.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Z.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Z.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ki.create=t=>new Ki({checks:[],coerce:t?.coerce||!1,typeName:Ae.ZodDate,...me(t)});var Da=class extends Ce{_parse(e){if(this._getType(e)!==z.symbol){let r=this._getOrReturnCtx(e);return J(r,{code:O.invalid_type,expected:z.symbol,received:r.parsedType}),ie}return Qt(e.data)}};Da.create=t=>new Da({typeName:Ae.ZodSymbol,...me(t)});var Zi=class extends Ce{_parse(e){if(this._getType(e)!==z.undefined){let r=this._getOrReturnCtx(e);return J(r,{code:O.invalid_type,expected:z.undefined,received:r.parsedType}),ie}return Qt(e.data)}};Zi.create=t=>new Zi({typeName:Ae.ZodUndefined,...me(t)});var Xi=class extends Ce{_parse(e){if(this._getType(e)!==z.null){let r=this._getOrReturnCtx(e);return J(r,{code:O.invalid_type,expected:z.null,received:r.parsedType}),ie}return Qt(e.data)}};Xi.create=t=>new Xi({typeName:Ae.ZodNull,...me(t)});var Os=class extends Ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Qt(e.data)}};Os.create=t=>new Os({typeName:Ae.ZodAny,...me(t)});var Xr=class extends Ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Qt(e.data)}};Xr.create=t=>new Xr({typeName:Ae.ZodUnknown,...me(t)});var Wn=class extends Ce{_parse(e){let n=this._getOrReturnCtx(e);return J(n,{code:O.invalid_type,expected:z.never,received:n.parsedType}),ie}};Wn.create=t=>new Wn({typeName:Ae.ZodNever,...me(t)});var Na=class extends Ce{_parse(e){if(this._getType(e)!==z.undefined){let r=this._getOrReturnCtx(e);return J(r,{code:O.invalid_type,expected:z.void,received:r.parsedType}),ie}return Qt(e.data)}};Na.create=t=>new Na({typeName:Ae.ZodVoid,...me(t)});var es=class t extends Ce{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==z.array)return J(n,{code:O.invalid_type,expected:z.array,received:n.parsedType}),ie;if(s.exactLength!==null){let a=n.data.length>s.exactLength.value,c=n.data.length<s.exactLength.value;(a||c)&&(J(n,{code:a?O.too_big:O.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(J(n,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(J(n,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>s.type._parseAsync(new kn(n,a,n.path,c)))).then(a=>mt.mergeArray(r,a));let i=[...n.data].map((a,c)=>s.type._parseSync(new kn(n,a,n.path,c)));return mt.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:Z.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:Z.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:Z.toString(n)}})}nonempty(e){return this.min(1,e)}};es.create=(t,e)=>new es({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ae.ZodArray,...me(e)});function Ta(t){if(t instanceof Wt){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Sn.create(Ta(r))}return new Wt({...t._def,shape:()=>e})}else return t instanceof es?new es({...t._def,type:Ta(t.element)}):t instanceof Sn?Sn.create(Ta(t.unwrap())):t instanceof Er?Er.create(Ta(t.unwrap())):t instanceof yr?yr.create(t.items.map(e=>Ta(e))):t}var Wt=class t extends Ce{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=Qe.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==z.object){let l=this._getOrReturnCtx(e);return J(l,{code:O.invalid_type,expected:z.object,received:l.parsedType}),ie}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof Wn&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||c.push(l);let A=[];for(let l of a){let p=i[l],h=s.data[l];A.push({key:{status:"valid",value:l},value:p._parse(new kn(s,h,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Wn){let l=this._def.unknownKeys;if(l==="passthrough")for(let p of c)A.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(l==="strict")c.length>0&&(J(s,{code:O.unrecognized_keys,keys:c}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let p of c){let h=s.data[p];A.push({key:{status:"valid",value:p},value:l._parse(new kn(s,h,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let p of A){let h=await p.key,g=await p.value;l.push({key:h,value:g,alwaysSet:p.alwaysSet})}return l}).then(l=>mt.mergeObjectSync(r,l)):mt.mergeObjectSync(r,A)}get shape(){return this._def.shape()}strict(e){return Z.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:Z.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ae.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of Qe.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of Qe.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Ta(this)}partial(e){let n={};for(let r of Qe.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of Qe.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Sn;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return qx(Qe.objectKeys(this.shape))}};Wt.create=(t,e)=>new Wt({shape:()=>t,unknownKeys:"strip",catchall:Wn.create(),typeName:Ae.ZodObject,...me(e)});Wt.strictCreate=(t,e)=>new Wt({shape:()=>t,unknownKeys:"strict",catchall:Wn.create(),typeName:Ae.ZodObject,...me(e)});Wt.lazycreate=(t,e)=>new Wt({shape:t,unknownKeys:"strip",catchall:Wn.create(),typeName:Ae.ZodObject,...me(e)});var eo=class extends Ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let c of i)if(c.result.status==="valid")return c.result;for(let c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;let a=i.map(c=>new Jt(c.ctx.common.issues));return J(n,{code:O.invalid_union,unionErrors:a}),ie}if(n.common.async)return Promise.all(r.map(async i=>{let a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let A of r){let l={...n,common:{...n.common,issues:[]},parent:null},p=A._parseSync({data:n.data,path:n.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let c=a.map(A=>new Jt(A));return J(n,{code:O.invalid_union,unionErrors:c}),ie}}get options(){return this._def.options}};eo.create=(t,e)=>new eo({options:t,typeName:Ae.ZodUnion,...me(e)});var Zr=t=>t instanceof no?Zr(t.schema):t instanceof vn?Zr(t.innerType()):t instanceof ro?[t.value]:t instanceof so?t.options:t instanceof io?Qe.objectValues(t.enum):t instanceof oo?Zr(t._def.innerType):t instanceof Zi?[void 0]:t instanceof Xi?[null]:t instanceof Sn?[void 0,...Zr(t.unwrap())]:t instanceof Er?[null,...Zr(t.unwrap())]:t instanceof wu||t instanceof co?Zr(t.unwrap()):t instanceof ao?Zr(t._def.innerType):[],Rd=class t extends Ce{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return J(n,{code:O.invalid_type,expected:z.object,received:n.parsedType}),ie;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(J(n,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let a=Zr(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of a){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new t({typeName:Ae.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...me(r)})}};function dy(t,e){let n=mr(t),r=mr(e);if(t===e)return{valid:!0,data:t};if(n===z.object&&r===z.object){let s=Qe.objectKeys(e),i=Qe.objectKeys(t).filter(c=>s.indexOf(c)!==-1),a={...t,...e};Object.prototype.hasOwnProperty.call(a,"__proto__")&&delete a.__proto__;for(let c of i){if(c==="__proto__")continue;let A=dy(t[c],e[c]);if(!A.valid)return{valid:!1};a[c]=A.data}return{valid:!0,data:a}}else if(n===z.array&&r===z.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],c=e[i],A=dy(a,c);if(!A.valid)return{valid:!1};s.push(A.data)}return{valid:!0,data:s}}else return n===z.date&&r===z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var to=class extends Ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(kd(i)||kd(a))return ie;let c=dy(i.value,a.value);return c.valid?((vd(i)||vd(a))&&n.dirty(),{status:n.value,value:c.data}):(J(r,{code:O.invalid_intersection_types}),ie)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};to.create=(t,e,n)=>new to({left:t,right:e,typeName:Ae.ZodIntersection,...me(n)});var yr=class t extends Ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==z.array)return J(r,{code:O.invalid_type,expected:z.array,received:r.parsedType}),ie;if(r.data.length<this._def.items.length)return J(r,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ie;!this._def.rest&&r.data.length>this._def.items.length&&(J(r,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((a,c)=>{let A=this._def.items[c]||this._def.rest;return A?A._parse(new kn(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>mt.mergeArray(n,a)):mt.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};yr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new yr({items:t,typeName:Ae.ZodTuple,rest:null,...me(e)})};var xd=class t extends Ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==z.object)return J(r,{code:O.invalid_type,expected:z.object,received:r.parsedType}),ie;let s=[],i=this._def.keyType,a=this._def.valueType;for(let c in r.data)s.push({key:i._parse(new kn(r,c,r.path,c)),value:a._parse(new kn(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?mt.mergeObjectAsync(n,s):mt.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof Ce?new t({keyType:e,valueType:n,typeName:Ae.ZodRecord,...me(r)}):new t({keyType:Ps.create(),valueType:e,typeName:Ae.ZodRecord,...me(n)})}},Fa=class extends Ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==z.map)return J(r,{code:O.invalid_type,expected:z.map,received:r.parsedType}),ie;let s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,A],l)=>({key:s._parse(new kn(r,c,r.path,[l,"key"])),value:i._parse(new kn(r,A,r.path,[l,"value"]))}));if(r.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let A of a){let l=await A.key,p=await A.value;if(l.status==="aborted"||p.status==="aborted")return ie;(l.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(l.value,p.value)}return{status:n.value,value:c}})}else{let c=new Map;for(let A of a){let l=A.key,p=A.value;if(l.status==="aborted"||p.status==="aborted")return ie;(l.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(l.value,p.value)}return{status:n.value,value:c}}}};Fa.create=(t,e,n)=>new Fa({valueType:e,keyType:t,typeName:Ae.ZodMap,...me(n)});var Ma=class t extends Ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==z.set)return J(r,{code:O.invalid_type,expected:z.set,received:r.parsedType}),ie;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(J(r,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(J(r,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function a(A){let l=new Set;for(let p of A){if(p.status==="aborted")return ie;p.status==="dirty"&&n.dirty(),l.add(p.value)}return{status:n.value,value:l}}let c=[...r.data.values()].map((A,l)=>i._parse(new kn(r,A,r.path,l)));return r.common.async?Promise.all(c).then(A=>a(A)):a(c)}min(e,n){return new t({...this._def,minSize:{value:e,message:Z.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:Z.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ma.create=(t,e)=>new Ma({valueType:t,minSize:null,maxSize:null,typeName:Ae.ZodSet,...me(e)});var Td=class t extends Ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==z.function)return J(n,{code:O.invalid_type,expected:z.function,received:n.parsedType}),ie;function r(c,A){return Bu({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ra(),Kr].filter(l=>!!l),issueData:{code:O.invalid_arguments,argumentsError:A}})}function s(c,A){return Bu({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ra(),Kr].filter(l=>!!l),issueData:{code:O.invalid_return_type,returnTypeError:A}})}let i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof $s){let c=this;return Qt(async function(...A){let l=new Jt([]),p=await c._def.args.parseAsync(A,i).catch(C=>{throw l.addIssue(r(A,C)),l}),h=await Reflect.apply(a,this,p);return await c._def.returns._def.type.parseAsync(h,i).catch(C=>{throw l.addIssue(s(h,C)),l})})}else{let c=this;return Qt(function(...A){let l=c._def.args.safeParse(A,i);if(!l.success)throw new Jt([r(A,l.error)]);let p=Reflect.apply(a,this,l.data),h=c._def.returns.safeParse(p,i);if(!h.success)throw new Jt([s(p,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:yr.create(e).rest(Xr.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||yr.create([]).rest(Xr.create()),returns:n||Xr.create(),typeName:Ae.ZodFunction,...me(r)})}},no=class extends Ce{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};no.create=(t,e)=>new no({getter:t,typeName:Ae.ZodLazy,...me(e)});var ro=class extends Ce{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return J(n,{received:n.data,code:O.invalid_literal,expected:this._def.value}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}};ro.create=(t,e)=>new ro({value:t,typeName:Ae.ZodLiteral,...me(e)});function qx(t,e){return new so({values:t,typeName:Ae.ZodEnum,...me(e)})}var so=class t extends Ce{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return J(n,{expected:Qe.joinValues(r),received:n.parsedType,code:O.invalid_type}),ie}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return J(n,{received:n.data,code:O.invalid_enum_value,options:r}),ie}return Qt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};so.create=qx;var io=class extends Ce{_parse(e){let n=Qe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==z.string&&r.parsedType!==z.number){let s=Qe.objectValues(n);return J(r,{expected:Qe.joinValues(s),received:r.parsedType,code:O.invalid_type}),ie}if(this._cache||(this._cache=new Set(Qe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=Qe.objectValues(n);return J(r,{received:r.data,code:O.invalid_enum_value,options:s}),ie}return Qt(e.data)}get enum(){return this._def.values}};io.create=(t,e)=>new io({values:t,typeName:Ae.ZodNativeEnum,...me(e)});var $s=class extends Ce{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==z.promise&&n.common.async===!1)return J(n,{code:O.invalid_type,expected:z.promise,received:n.parsedType}),ie;let r=n.parsedType===z.promise?n.data:Promise.resolve(n.data);return Qt(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};$s.create=(t,e)=>new $s({type:t,typeName:Ae.ZodPromise,...me(e)});var vn=class extends Ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ae.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{J(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return ie;let A=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return A.status==="aborted"?ie:A.status==="dirty"?ji(A.value):n.value==="dirty"?ji(A.value):A});{if(n.value==="aborted")return ie;let c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?ie:c.status==="dirty"?ji(c.value):n.value==="dirty"?ji(c.value):c}}if(s.type==="refinement"){let a=c=>{let A=s.refinement(c,i);if(r.common.async)return Promise.resolve(A);if(A instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){let c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?ie:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?ie:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ls(a))return ie;let c=s.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Ls(a)?Promise.resolve(s.transform(a.value,i)).then(c=>({status:n.value,value:c})):ie);Qe.assertNever(s)}};vn.create=(t,e,n)=>new vn({schema:t,typeName:Ae.ZodEffects,effect:e,...me(n)});vn.createWithPreprocess=(t,e,n)=>new vn({schema:e,effect:{type:"preprocess",transform:t},typeName:Ae.ZodEffects,...me(n)});var Sn=class extends Ce{_parse(e){return this._getType(e)===z.undefined?Qt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Sn.create=(t,e)=>new Sn({innerType:t,typeName:Ae.ZodOptional,...me(e)});var Er=class extends Ce{_parse(e){return this._getType(e)===z.null?Qt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Er.create=(t,e)=>new Er({innerType:t,typeName:Ae.ZodNullable,...me(e)});var oo=class extends Ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===z.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};oo.create=(t,e)=>new oo({innerType:t,typeName:Ae.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...me(e)});var ao=class extends Ce{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return xa(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Jt(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Jt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ao.create=(t,e)=>new ao({innerType:t,typeName:Ae.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...me(e)});var _a=class extends Ce{_parse(e){if(this._getType(e)!==z.nan){let r=this._getOrReturnCtx(e);return J(r,{code:O.invalid_type,expected:z.nan,received:r.parsedType}),ie}return{status:"valid",value:e.data}}};_a.create=t=>new _a({typeName:Ae.ZodNaN,...me(t)});var Eq=Symbol("zod_brand"),wu=class extends Ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Qu=class t extends Ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ie:i.status==="dirty"?(n.dirty(),ji(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?ie:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:Ae.ZodPipeline})}},co=class extends Ce{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Ls(s)&&(s.value=Object.freeze(s.value)),s);return xa(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};co.create=(t,e)=>new co({innerType:t,typeName:Ae.ZodReadonly,...me(e)});function Vx(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function jx(t,e={},n){return t?Os.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(a=>{if(!a){let c=Vx(e,r),A=c.fatal??n??!0;s.addIssue({code:"custom",...c,fatal:A})}});if(!i){let a=Vx(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}}):Os.create()}var Cq={object:Wt.lazycreate},Ae;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ae||(Ae={}));var Iq=(t,e={message:`Input not instance of ${t.name}`})=>jx(n=>n instanceof t,e),Jx=Ps.create,Wx=Ji.create,Bq=_a.create,wq=Wi.create,zx=zi.create,Qq=Ki.create,bq=Da.create,Sq=Zi.create,kq=Xi.create,vq=Os.create,Rq=Xr.create,xq=Wn.create,Tq=Na.create,Dq=es.create,Nq=Wt.create,Fq=Wt.strictCreate,Mq=eo.create,_q=Rd.create,Uq=to.create,Lq=yr.create,Pq=xd.create,Oq=Fa.create,$q=Ma.create,Vq=Td.create,Gq=no.create,Hq=ro.create,Yq=so.create,qq=io.create,jq=$s.create,Jq=vn.create,Wq=Sn.create,zq=Er.create,Kq=vn.createWithPreprocess,Zq=Qu.create,Xq=()=>Jx().optional(),ej=()=>Wx().optional(),tj=()=>zx().optional(),nj={string:(t=>Ps.create({...t,coerce:!0})),number:(t=>Ji.create({...t,coerce:!0})),boolean:(t=>zi.create({...t,coerce:!0})),bigint:(t=>Wi.create({...t,coerce:!0})),date:(t=>Ki.create({...t,coerce:!0}))};var rj=ie;function sj(t){return t.issues.map(e=>{let n=e.path.map(s=>typeof s=="number"?`[${s}]`:`.${s}`).join("").replace(/^\./,""),r=n||"output";if(!/^(Expected |Required$|Invalid |String must|Array must|Number must)/.test(e.message))return`${r} ${e.message}`;switch(e.code){case"invalid_type":return n?e.expected==="object"?`${r} must be an object`:e.received==="undefined"?`${r} is required`:`${r} must be ${e.expected}, got ${e.received}`:"output is not a JSON object";case"invalid_enum_value":{let s=JSON.stringify(e.received),i=e.options.find(c=>typeof c=="string"&&typeof e.received=="string"&&e.received.startsWith(c)),a=i?` \u2014 you sent ${s}; the value must be exactly ${JSON.stringify(i)}, with any qualifier moved to a field that takes free text`:` \u2014 you sent ${s}`;return`${r} must be one of: ${e.options.join(", ")}${a}`}case"invalid_literal":return`${r} must be ${JSON.stringify(e.expected)}`;case"too_small":return e.type==="string"?`${r} must be a non-empty string`:`${r} must have at least ${e.minimum} item(s)`;case"unrecognized_keys":return`${r} has unknown key(s): ${e.keys.join(", ")}`;default:return`${r}: ${e.message}`}})}function ts(t,e){let n=t.safeParse(e);if(n.success)return{value:n.data,errors:[]};let r=(i,a)=>a.reduce((c,A)=>c&&typeof c=="object"?c[A]:void 0,i),s=n.error.issues.filter(i=>i.path.length&&r(e,i.path)===null);if(s.length===n.error.issues.length)try{let i=t.safeParse(s.reduce((a,{path:c})=>Kx(a,c),e));if(i.success)return{value:i.data,errors:[]}}catch{}return{errors:sj(n.error)}}function Kx(t,e){if(!e.length||!t||typeof t!="object")return t;let[n,...r]=e,s=Array.isArray(t)?t.slice():{...t};return r.length?s[n]=Kx(s[n],r):delete s[n],s}var B8=new Set(Object.values(_s));var w8=u.object({checks:u.array(u.object({repository:u.string().optional(),name:u.string().min(1),headSha:u.string().regex(/^[0-9a-f]{40}$|^[0-9a-f]{64}$/i),status:u.string().default("completed"),conclusion:u.string().nullable().optional(),url:u.string().optional(),summary:u.string().optional()}))});var Dd=["-c","core.fsmonitor=false"],ij=new Set(["GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","ACTIONS_RUNTIME_TOKEN","ACTIONS_ID_TOKEN_REQUEST_TOKEN","ACTIONS_ID_TOKEN_REQUEST_URL","SYSTEM_ACCESSTOKEN","SYSTEM_OIDCREQUESTURI","SKYRAMP_MCP_GITHUB_TOKEN","SSH_AUTH_SOCK","GIT_SSH","GIT_SSH_COMMAND","GITHUB_STEP_SUMMARY"]),oj=new Set(["ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN","CLAUDE_CODE_OAUTH_TOKEN","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","AWS_BEARER_TOKEN_BEDROCK","AWS_PROFILE","AWS_WEB_IDENTITY_TOKEN_FILE","AWS_ROLE_ARN","AWS_ROLE_SESSION_NAME","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE"]);function zn(t=process.env,e,n="repo-command"){let r={};for(let[s,i]of Object.entries(t))n==="repo-command"&&oj.has(s)||(r[s]=i);Object.assign(r,e??{});for(let s of Object.keys(r))(ij.has(s)||s.startsWith("INPUT_"))&&delete r[s];return r}var Ua=Re(require("path"));var N8=Ua.join(".skyramp","workspace.yml");var aj={py:"python",go:"go",java:"java",kt:"kotlin",rb:"ruby",cs:"csharp",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",kts:"kotlin",rs:"rust",php:"php",scala:"scala",swift:"swift",ex:"elixir",exs:"elixir",dart:"dart",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",hh:"cpp",groovy:"groovy"};var F8=new Set(Object.values(aj));var ns=(s=>(s.Clean="clean",s.RecipeDrift="recipe-drift",s.ChangeBrokeBringup="change-broke-bringup",s.BringupFailed="bringup-failed",s))(ns||{}),Vs=u.string().trim().min(1),uj=u.object({url:u.string().optional().describe("the URL probed, if the check is an HTTP request"),command:u.string().optional().describe("the command run, if the check is a script \u2014 preferred when auth is needed"),headers:u.record(u.string()).optional(),status:u.union([u.number(),u.string()]).optional().describe("expected HTTP status for a url check (default 200)"),output:Vs.describe("what the check returned, VERBATIM \u2014 the bytes, nothing appended; this gate RE-RUNS the check")}),py=u.array(u.object({component:Vs.describe("a shared component listed above"),url:Vs.describe("the URL on the component's own origin (scheme, host and port) that answers with its deployed commit"),output:Vs.describe("what the URL returned, VERBATIM; this gate FETCHES each url")})).describe("only when shared components are listed above: one check per component whose deployed commit you found"),Xx=u.object({schemaVersion:u.literal(1),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app; omit on a failed bring-up, never invent one"),health:uj.optional(),teardown:Vs.describe("command that tears the SUT down"),dependencies:u.record(u.boolean()).optional().describe("EVERY backing service: true = really deployed, false = mocked; REQUIRED when the app came up"),outcome:u.nativeEnum(ns).describe("clean | recipe-drift (you corrected the recipe) | change-broke-bringup (the PR broke it) | bringup-failed (environment, not the PR)"),recipeFixes:u.array(u.string()).optional().describe("required when outcome is recipe-drift: what was corrected"),bringupError:u.object({command:Vs,output:Vs}).optional().describe("required when bring-up failed: the exact failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("required for change-broke-bringup: files THIS PR changed that the failure points at, relative to your working directory (a file in another checkout of the run: its absolute path)"),seeded:u.boolean(),startedAt:Vs.describe("ISO timestamp"),revisions:py.optional()});var bu=(n=>(n.Full="full",n.Static="static",n))(bu||{}),Gs=(r=>(r.Contract="contract",r.Integration="integration",r.Ui="ui",r))(Gs||{}),Su=(i=>(i.OwnSurface="own_surface",i.StateReadBack="state_read_back",i.Referential="referential",i.Lifecycle="lifecycle",i.Boundaries="boundaries",i))(Su||{}),uo=(s=>(s.Update="update",s.Regenerate="regenerate",s.Delete="delete",s.Verify="verify",s))(uo||{}),Nd=(l=>(l.Equals="equals",l.NotEquals="not_equals",l.GreaterThan="greater_than",l.LessThan="less_than",l.Contains="contains",l.NotContains="not_contains",l.Matches="matches",l.Absent="absent",l.Present="present",l))(Nd||{});var hn=u.string().trim().min(1),lj=u.object({subject:hn.describe('what the test READS: a response field path, the literal "status", or the on-screen text for a ui case \u2014 the FINAL read in a multi-step case'),comparator:u.nativeEnum(Nd),value:u.union([u.string(),u.number(),u.boolean(),u.null()]).optional().describe("the ONE value a broken build would not produce; OMIT for absent/present")}),dj=u.object({test:hn.describe("existing test path, relative to its repository"),repository:hn.optional().describe("owner/repo the test lives in, when the run has several checkouts; omit for the working checkout"),action:u.nativeEnum(uo),evidence:hn.describe("why \u2014 drift vs the diff, or a finding"),covers_behaviors:u.array(u.string()).optional().describe("analyze behavior ids this maintenance covers")});var pj=u.object({surface:hn.describe("a surface from the list, copied verbatim"),axis:u.nativeEnum(Su)}),hj=u.object({id:hn.describe("short-slug, unique across generate[]"),type:u.nativeEnum(Gs),target:hn.describe('"METHOD /path", or a business-flow name'),from_finding:u.string().optional().describe("analyze finding id this case catches"),from_behavior:u.string().optional().describe("analyze behavior id this case pins"),derived_from:pj.optional().describe("the surface \xD7 axis this case pins when no analyze behavior or finding names it \u2014 one of the three is required"),rationale:hn.describe("why this test matters"),expected_observable:hn.describe("one sentence for a human: what a catching test asserts, and what a broken build does instead"),expected:lj.describe("the same intent AS DATA \u2014 see the rules below"),seededPrecondition:hn.optional().describe("seeded non-initial state + how to reach it; only when a seeded-state transition applies"),verifiable:u.boolean().describe("true only when a live SUT could confirm this test (full mode)")}),fj=u.object({covered:u.array(u.string()).optional(),abstain:u.string().optional()}).superRefine((t,e)=>{let n=Array.isArray(t.covered),r=typeof t.abstain=="string";if(n===r)return void e.addIssue({code:u.ZodIssueCode.custom,message:"must have exactly one of covered[] or abstain"});n&&t.covered.length===0&&e.addIssue({code:u.ZodIssueCode.custom,path:["covered"],message:"must list at least one id (else abstain)"}),r&&!t.abstain.trim()&&e.addIssue({code:u.ZodIssueCode.custom,path:["abstain"],message:"must give a reason"})}).describe('{ "covered": [ids] } OR { "abstain": "reason" } \u2014 exactly one'),gj=u.object({surface:hn.describe("a surface from the list, copied verbatim"),axes:u.object(Object.fromEntries(Object.values(Su).map(t=>[t,fj])))}),e0=u.object({schemaVersion:u.literal(1),mode:u.nativeEnum(bu),maintenance:u.array(dj),generate:u.array(hj),surfaces:u.array(gj).describe("one entry per changed surface in the list \u2014 none missing, none invented"),budget:u.object({total:u.number().describe("case count"),rationale:hn}),summary:hn.describe("one paragraph")});var Ao=(n=>(n.Ready="ready",n.Blocked="blocked",n))(Ao||{}),Je=u.string().trim().min(1),mj=u.object({action:u.enum(["start","run","wait"]),text:Je,source:u.enum(["file","notes","testbot"]).describe("file: a file in the repository; notes: the Target's notes; testbot: Testbot's own finding"),file:Je.nullable().describe("the file the step came from, relative to the component's repository; null unless source is file")}).strict().refine(t=>t.source==="file"==(t.file!==null),{path:["file"],message:"a file exactly when the step came from one"}),yj=/^[A-Za-z_][A-Za-z0-9_]*$/,La=/^(?!GITHUB_)(?!SKYRAMP_RUNNER_)[A-Z][A-Z0-9_]{0,99}$/,Pa=(a=>(a.VersionEndpoint="version_endpoint",a.DeployWorkflow="deploy_workflow",a.KubernetesLabels="kubernetes_labels",a.Command="command",a.Api="api",a.NotTracked="not_tracked",a))(Pa||{}),zt="shared",Ej=Je.refine(t=>{try{let e=new URL(t);return["http:","https:"].includes(e.protocol)&&!e.username&&!e.password}catch{return!1}},"an http(s) URL with no login in it"),Oa=u.object({address:Ej,readyWhen:Je.nullable(),credentials:u.array(u.string().regex(La)).max(50),revisionSources:u.array(u.object({method:u.nativeEnum(Pa),detail:Je.describe("what Testbot reads, such as GET /version or the deploy workflow's name; for not_tracked, why nothing shows it"),components:u.array(Je).min(1).describe("the components it tells the revision of, by name")}).strict()).max(50)}).strict(),hy={steps:u.array(mj).max(20).optional().describe("how it starts, in order"),kind:u.enum(["web_app","service","database","external_service"]).optional(),from:u.object({file:Je,service:Je.nullable()}).strict().optional(),credentials:u.array(u.string().max(100).regex(yj)).max(50).optional().describe("the Target's credentials this component's recipe uses: a sign-in (a test user, password or token) or an API key, which the workflow supplies from a GitHub Actions secret as the environment variable of the credential's name; give each name exactly as the recipe reads it. Names only, never a value, and not a secret the recipe generates itself")},Cj=u.object({name:Je,repository:Je.describe("owner/repo of the Target repository the component is built or started from, such as the one whose compose file starts its database"),healthy:u.boolean(),...hy,deployed:Je.nullable().optional().describe('only with "environment": the revision the component runs, as you read it from its revision source, or null when you could not tell')}),Ij=u.object({component:Je,problem:Je,evidence:Je.describe("the exact command and output that shows it"),fix:Je.describe("what the user must provide, and where")}),Bj=u.object({framework:Je,file:Je.describe("the test file run, relative to its repository root"),result:u.enum(["pass","fail","error"])}),wj=u.object({input:Je.describe("the part of the user's SUT input, as given"),reason:Je}),t0=u.object({schemaVersion:u.literal(1),status:u.nativeEnum(Ao).describe("ready only if every component came up healthy and the recipe is written"),components:u.array(Cj),suites:u.array(Bj).default([]).describe("one run per test suite the Target's repositories have; empty when they have none"),inputsUsed:u.array(Je).default([]).describe("the parts of the user's SUT input the recipe used as given"),inputsUsedHow:u.array(u.object({input:Je.describe("exactly as written in inputsUsed; an entry that is not there is left out"),how:Je.describe("what the recipe did with it")})).optional(),inputsNotUsed:u.array(wj).default([]).describe("the parts it did not use, and why. A part that is wrong goes here, with what was wrong, even when the recipe does something like it instead: one that names a file, command, port, route or setting that does not exist or does not work (SKYR-5265)"),blockers:u.array(Ij).describe("required (non-empty) when status is blocked"),environment:Oa.optional().describe("only when the whole SUT is an existing deployment you tested where it runs, building and starting nothing: its address, what says it is ready, the credentials that reach it, and how to read what each component runs. Leave it out when any part was built or started on the runner, or reaching it needed something there (a tunnel, port-forward, proxy or client certificate)")});var ku=64*1024,vu=512*1024,fy=/[\u0000-\u0008\u000b\u000e-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/;var n0=".skyramp/sut/deployed-revisions.sh",gy=(n=>(n.Running="running",n.Requested="requested",n))(gy||{});var W8=new Set(Object.values(gy));var z8=`Fix ${n0} so it prints the full commit each component runs, then set it up again.`;var my="shared-environment";var c5=64*1024;var u5=new Set(["version_endpoint","api"]);function Md(t){return(t?.components??[]).filter(e=>!!e.repository&&!!e.expectedRevision)}function s0(t){return Md(t).length>0||(t?.dependencies.length??0)>0}function Sj(t){let e=t.inputs?.sharedEnvironment;if(!s0(e))return;let n=bn(t,`${my}.json`);if(n)return{components:kj(e,n.components),dependencies:n.dependencies};let r="Not checked: the run ended before it checked the shared environment.";return{components:Md(e).map(s=>i0(s,r)),dependencies:e.dependencies.map(s=>({name:s.name,url:s.url,version:null,evidence:r}))}}var i0=(t,e)=>({name:t.name,repository:t.repository,url:t.url,expectedRevision:t.expectedRevision,observedRevision:null,status:"unverifiable",source:t.revisionUrl||t.revisionScript?"probe":"agent",evidence:e});function kj(t,e){let n=new Set(e.map(s=>s.name.toLowerCase())),r=Md(t).filter(s=>s.touched&&!n.has(s.name.toLowerCase()));return[...e,...r.map(s=>i0(s,"Not checked: the run recorded no read of it."))]}function yy(t){return(Sj(t)?.components??[]).filter(e=>e.status!=="verified")}function Ey(t){return(t?.components??[]).filter(e=>!!e.repository&&!e.expectedRevision)}function By(t){return a0(t)&&yy(t).length===0&&Ey(t.inputs?.sharedEnvironment).length===0}function a0(t){let e=Nj(t);if(!e&&t.state.stages.deploy?.status!=="passed")return!1;let n=bn(t,"deploy.json");return n?n.outcome==="clean"||n.outcome==="recipe-drift":!e}function Nj(t){let e=t.state.stages.plan,n=t.state.stages.deploy;return!(t.inputs?.pipeline?t.inputs.pipeline==="two-step":!n)||e?.status!=="passed"?!1:!n||n.updatedAt<=e.updatedAt}var $a=(a=>(a.Place="place",a.Update="update",a.Regenerate="regenerate",a.Delete="delete",a.Verify="verify",a.None="none",a))($a||{}),Kn=(r=>(r.Pass="pass",r.Fail="fail",r.Skip="skip",r))(Kn||{}),Rn=u.string().trim().min(1),c0=u.object({case:Rn.describe("a covers id \u2014 the recommend case this test realizes"),status:u.nativeEnum(Kn)}),u0=u.object({exit:u.number({invalid_type_error:"must be a number or null"}).nullable().describe("process exit of the re-run; null when no SUT was available"),details:u.string().optional().describe("what failed, or why a file was not run \u2014 required on any non-zero exit"),tests:u.array(c0).optional().describe("ONE ENTRY PER CASE the file covers; must agree with exit (0 \u2192 no fail; non-zero \u2192 at least one)")}),A0=u.object({from:u.string().optional().describe("staged path \u2014 required for placements"),file:Rn.describe("final path relative to its repository, inside that checkout, with a source-file extension"),repository:Rn.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),action:u.nativeEnum($a),covers:u.array(u.string()).optional().describe("recommend ids a placed test covers"),repro:u.boolean().optional().describe("this test is MEANT to fail \u2014 it reproduces a reported bug"),finding:u.boolean().optional().describe("a non-repro test that failed on a REAL product bug"),placementBroken:u.boolean().optional().describe('placement/harness problem one repair could not fix \u2014 every reran.tests entry is then "skip"'),keptReason:Rn.optional().describe("why a planned delete/regenerate was declined and the file kept"),isolatedRun:Rn.optional().describe('only for a test marked "runs alone": the command, from its checkout root and without a shell, that runs only this file and writes its JUnit XML into $SKYRAMP_RESULTS_DIR (named by its path: no shell expands it) \u2014 the harness runs it, so leave reran.exit null'),reran:u0,assertionCount:u.number().int().nonnegative().optional().describe("[derived] assertions reachable from the file, counted at write time")}).refine(t=>t.action!=="place"||typeof t.from=="string"&&t.from.trim().length>0,{message:'is a place but has no "from" staged path',path:[]}),l0=(n=>(n.Junit="junit",n.Converter="converter",n))(l0||{}),Fj=Rn.optional().describe("the items[].file this test is in \u2014 needed only when two of this suite's files cover the same case id"),Mj=u.object({results:Rn.describe("the JUnit XML file this run wrote, a plain file name inside $SKYRAMP_RESULTS_DIR (e.g. backend.xml)"),source:u.nativeEnum(l0),run:Rn.describe("the command you ran that wrote it, exactly as you ran it (with any converter)"),files:u.array(Rn).min(1).describe("the items[].file paths this run covered"),cases:u.array(u.object({test:Rn.describe("the test's name as the runner reports it, qualified by its class or file (e.g. tests/test_a.py::test_x) when the bare name repeats"),case:Rn.describe("the covers id it realizes"),file:Fj})).describe("map each reported test name to the case it covers")}),_j=u.object({suites:u.array(Mj).min(1)}),wy=u.object({schemaVersion:u.literal(1),items:u.array(A0),runnerResults:_j.optional().describe("the JUnit XML your test runs wrote into $SKYRAMP_RESULTS_DIR, so the harness reads each test's result from the runner \u2014 omit only when no SUT is available"),ignored:u.array(u.string()).describe("existing tests assessed and deliberately left untouched"),summary:Rn.describe("one paragraph")});var q5=10*6e4;var po=Re(require("fs"));function p0(t){let e=[];for(let n of Vj(t)){let r=n;r?.type==="tool_use"&&typeof r.name=="string"&&e.push(r.name)}return e}function h0(t){return p0(t).some(e=>/^mcp__skyramp__skyramp_(contract|integration)_test_generation$/.test(e))}function f0(t){return p0(t).some(e=>e==="mcp__skyramp__skyramp_ui_test_generation")}function $j(t){if(!po.existsSync(t))return{};for(let e of po.readFileSync(t,"utf-8").split(`
117
117
  `)){let n=e.trim();if(n)try{let r=JSON.parse(n);if(r.type==="system"&&r.subtype==="init"&&Array.isArray(r.mcp_servers))return Object.fromEntries(r.mcp_servers.filter(s=>typeof s.name=="string").map(s=>[s.name,typeof s.status=="string"?s.status:"unknown"]))}catch{}}return{}}function g0(t){let e=$j(t).skyramp;return e===void 0||e==="connected"}function Vj(t){if(!po.existsSync(t))return[];let e=[];for(let n of po.readFileSync(t,"utf-8").split(`
118
- `)){let r=n.trim();if(!r)continue;let s;try{s=JSON.parse(r)}catch{continue}let i=s.message?.content;Array.isArray(i)&&e.push(...i)}return e}var m0=Re(require("path"));var bt=u.string().trim().min(1),by=(n=>(n.TestbotManaged="testbot_managed",n.CustomerDeployed="customer_deployed",n))(by||{}),_d=[".skyramp/sut/setup.sh",".skyramp/sut/teardown.sh"],Sy=u.object({schemaVersion:u.literal(1),type:u.nativeEnum(by).optional(),status:u.enum(["ready","blocked"]),environment:Oa.optional(),components:u.array(u.object({name:bt,repository:bt.describe(`owner/repo, or "${zt}" for a customer-deployed component no repository builds`),healthy:u.boolean(),url:u.string().min(1).nullable(),...hy,credentials:u.array(u.string().regex(La)).max(50).optional(),deployed:bt.nullable().optional().describe("customer_deployed only: the revision the component runs, as setup read it (WF-SETUP-22's Deployed now), or null when it could not tell")}).strict()),suites:u.array(u.object({framework:bt,file:bt,result:u.enum(["pass","fail","error"])}).strict()),inputsUsed:u.array(bt),inputsUsedHow:u.array(u.object({input:bt,how:bt}).strict()).optional(),inputsNotUsed:u.array(u.object({input:bt,reason:bt}).strict()),blockers:u.array(u.object({component:bt,problem:bt,evidence:bt,fix:bt}).strict()),replay:u.object({outcome:bt,durationSeconds:u.number().nonnegative().nullable()}).strict().nullable(),files:u.array(u.object({path:bt,content:u.string()}).strict())}).strict().superRefine((t,e)=>{t.inputsUsedHow?.forEach((s,i)=>{t.inputsUsed.includes(s.input)||e.addIssue({code:u.ZodIssueCode.custom,path:["inputsUsedHow",i,"input"],message:"not one of inputsUsed"})}),t.components.forEach((s,i)=>{s.credentials&&new Set(s.credentials).size!==s.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"credentials"],message:"names a credential twice"})});let n=t.type==="customer_deployed";n!==(t.environment!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment"],message:"an environment exactly when the plan's type is customer_deployed"}),t.environment&&new Set(t.environment.credentials).size!==t.environment.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment","credentials"],message:"names a credential twice"});let r=new Set(t.components.map(s=>s.name));if(t.environment?.revisionSources.forEach((s,i)=>{s.components.forEach((a,c)=>{r.has(a)||e.addIssue({code:u.ZodIssueCode.custom,path:["environment","revisionSources",i,"components",c],message:"not one of components"})})}),t.components.forEach((s,i)=>{s.deployed!==void 0!==n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"deployed"],message:"what a component runs exactly when the plan is customer_deployed"}),s.repository===zt&&!n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"repository"],message:`only a customer_deployed component is ${zt}`})}),n&&(t.components.forEach((s,i)=>{t.components.findIndex(a=>a.name===s.name)!==i&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"name"],message:"names a component twice"})}),t.replay!==null&&e.addIssue({code:u.ZodIssueCode.custom,path:["replay"],message:"a customer_deployed plan is never replayed"}),t.files.forEach((s,i)=>{_d.includes(s.path)&&e.addIssue({code:u.ZodIssueCode.custom,path:["files",i,"path"],message:"a customer_deployed plan has no script that starts or stops the system"})})),n&&t.status==="ready"){let s=new Set(t.environment?.revisionSources.flatMap(i=>i.components));t.components.forEach((i,a)=>{i.repository!==zt&&!s.has(i.name)&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",a,"name"],message:"a ready customer_deployed plan reads what every component a repository builds runs"})})}});var Z5=["clean","recipe-drift"];function Ru(t){let e=m0.posix.normalize(t);return e===t&&(e===".skyramp/workspace.yml"||e.startsWith(".skyramp/sut/")&&e.length>13)}var ky=[".skyramp/sut",".skyramp/workspace.yml"];var iX=["--",":/",...ky.map(t=>`:(exclude)${t}`)];var Gj=u.object({route:u.string().describe('the page this step happens on, e.g. "/products/:id"'),action:u.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:u.array(u.string()).optional().describe("the plan clause ids this step exercises"),check:u.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),xu=(n=>(n.InProcess="in-process",n.Browser="browser",n))(xu||{}),y0=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(y0||{}),E0=u.object({id:u.string().describe('e.g. "J1"'),name:u.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:u.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:u.array(Gj).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:u.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:u.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:u.nativeEnum(xu).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:u.nativeEnum(y0).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:u.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:u.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),Ud=u.object({journey:u.string().describe("the plan's journey id"),file:u.string().describe("the browser test file that walks it"),brokeAt:u.object({step:u.number().int().describe("the 1-based step whose check failed first"),expected:u.string(),actual:u.string().describe("what the app did instead, from the runner's output"),notReached:u.array(u.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:u.string().describe("the title of the one test in that file that walks it end to end")});var Ry=(s=>(s.RestApi="rest-api",s.Frontend="frontend",s.FullStack="full-stack",s.Other="other",s))(Ry||{}),Tu=(s=>(s.Critical="critical",s.High="high",s.Medium="medium",s.Low="low",s))(Tu||{}),Ld=(r=>(r.Suspected="suspected",r.Latent="latent",r.Refuted="refuted",r))(Ld||{}),I0=(r=>(r.Skyramp="skyramp",r.External="external",r.Unknown="unknown",r))(I0||{}),B0=(s=>(s.Cascade="cascade",s.Restrict="restrict",s.Orphan="orphan",s.Unknown="unknown",s))(B0||{}),Va=(s=>(s.RequirementReference="requirement-reference",s.Spec="spec",s.PrDescription="pr-description",s.CouldBreak="could-break",s))(Va||{}),Fe=u.string().trim().min(1),Ga=Fe.describe("file:line"),C0=t=>Fe.refine(e=>e.length<=400,e=>({message:`is ${e.length} characters, over the 400 cap \u2014 ${t}`})),Du=Fe.optional().describe('multi-repo only: the OTHER checkout this lives in \u2014 its "owner/repo" slug, or the directory name if the run discovered it; omit for the working checkout'),vy=u.object({method:Fe,path:Fe,service:u.string().optional(),evidence:Ga,repository:Du}),Hj=u.object({id:Fe.describe("short-slug, e.g. R9"),statement:Fe.max(400,"exceeds 400 characters \u2014 state the requirement, do not paste the spec section").describe("a testable obligation, not a summary"),source:u.nativeEnum(Va).describe("spec outranks pr-description when both state it"),evidence:Fe.describe("spec: file:line or a section locator. pr-description: the quoted phrase it comes from.")}),Yj=u.object({id:Fe.describe("short-slug"),statement:Fe.max(400,"exceeds 400 characters \u2014 state the behaviour, do not paste the code").describe("what the change makes true"),surface:Fe.describe("METHOD /path, or a component/page name"),evidence:Fe.describe("file:line from the diff that introduces it"),repository:Du,satisfies:u.array(Fe).optional().describe("requirement ids (from `requirements`) this behaviour correctly implements \u2014 a requirement met only in part is ALSO named by the finding that shows the rest (conflictsWith)")}),qj=u.object({id:Fe.describe("short-slug"),file:Fe,line:u.number().optional(),claim:C0("shorten it to the one sentence that states the defect, and move the supporting detail into `evidence`"),severity:u.nativeEnum(Tu),evidence:C0("cite the file:line and the one line that shows it, rather than reproducing the surrounding code").describe("quoted diff/code line"),status:u.nativeEnum(Ld),repository:Du,conflictsWith:u.array(Fe).optional().describe("requirement ids (from `requirements`) this defect contradicts or leaves unimplemented \u2014 a lower-precedence source (the diff, or the PR description) lost")}),jj=u.object({name:Fe,language:u.string().optional(),framework:u.string().optional(),evidence:Ga,repository:Du}),Jj=u.object({dir:Fe,framework:u.string().optional(),kind:u.nativeEnum(I0),evidence:Ga,repository:Du}),Wj=u.object({from:Fe,to:Fe,onDelete:u.nativeEnum(B0),evidence:Ga}),zj=u.object({entity:Fe,field:Fe,values:u.array(u.string()),evidence:Ga}),Kj=u.object({entities:u.array(u.object({name:Fe,evidence:Ga})),references:u.array(Wj).describe("INBOUND references \u2014 what still points at an entity when it is deleted"),stateFields:u.array(zj)}),fX=u.object({schemaVersion:u.literal(1),repository:u.object({path:Fe.describe("absolute repo path"),currentBranch:Fe,baseBranch:Fe}),project:u.object({type:u.nativeEnum(Ry),primaryLanguage:Fe,languages:u.array(u.string()),frameworks:u.array(u.string())}),services:u.array(jj),infrastructure:u.object({containerized:u.boolean(),hasDockerCompose:u.boolean(),composeFiles:u.array(u.string()),hasCiCd:u.boolean()}),diff:u.object({changedFiles:u.array(u.string()).describe("as git reports them; a file in another checkout may carry that repo's name"),nonApplicationOnly:u.boolean(),summary:Fe.describe("\u2264400 chars")}),endpoints:u.object({new:u.array(vy),modified:u.array(vy),removed:u.array(vy)}),existingTests:u.object({locations:u.array(Jj)}),entityMap:Kj,requirements:u.array(Hj).describe("from a spec (attached or linked) and/or the PR description; empty when neither states a testable obligation"),behaviors:u.array(Yj),findings:u.array(qj),unexamined:u.array(u.string()).describe("files or areas outside this change you did not open"),summary:Fe.describe("one paragraph on what this change does and its test-relevant risk")});var Pd=(n=>(n.Skyramp="skyramp",n.Llm="llm",n))(Pd||{}),ss=u.string().trim().min(1),Zj=u.object({case:ss.describe("recommend id this assertion enforces"),evidence:ss.describe("the exact assertion line from the file that checks that case's observable")}),xy=u.object({kind:u.nativeEnum(Id).describe("seed: data the test creates in the app; runtime_mock: a mock on a Skyramp worker, which other tests reach too; env_override: an env value the app runs with. A stub inside the test's own process, such as a browser page's route, is none of these"),target:ss.describe("the dependency, endpoint or data it affects"),mechanism:u.nativeEnum(Bd).describe("test_code: the test applies and undoes it; skyramp_mocker: a mock the test applies on a Skyramp worker; recipe_override: the mocker cannot reach the dependency (its URL is fixed in the build)"),detail:ss.describe("what it sets up"),worker:ss.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:ss.optional().describe("seed: a command, without a shell, that removes the data when the test does not")}),Xj=u.object({file:ss.describe("staged path under .skyramp/staged/"),source:u.nativeEnum(Pd),language:ss,covers:u.array(u.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:u.array(Zj).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:u.array(xy).optional().describe("what the test sets up against the running app, in order: data it seeds, Skyramp mocks it applies, env overrides; omit when none")}),Ty=u.object({schemaVersion:u.literal(1),tests:u.array(Xj),deferredUi:u.array(u.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:ss.describe("one paragraph")});var is=u.string().trim().min(1),Nu=72,eJ=u.object({repository:is.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:u.string(),command:u.string().describe("the exact command you ran, scoped to the changed files"),clean:u.boolean(),fixed:u.array(u.string()).optional().describe("files you fixed"),uncovered:u.array(u.string()).describe("changed/new files this linter's own config does not match (wrong extension, wrong directory) \u2014 so `clean` never examined them, even though CI may still execute them. Empty array, not omitted, when every changed/new file IS covered.")}),QX=u.object({schemaVersion:u.literal(1),lint:u.array(eJ).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:u.object({ok:u.boolean(),notes:u.string().optional()}),ciReadiness:u.object({covered:u.boolean().describe("will the repo's CI run these tests?"),notes:u.string().optional()}),dependencies:u.object({added:u.array(u.object({package:u.string(),manifest:u.string(),repository:is.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:is.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).describe("every package added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own")}),support:u.array(u.object({file:is,repository:is.optional().describe("owner/repo of the file's checkout; omit for the working checkout")})).optional().describe("the files the tests need besides themselves (helper modules, page objects, fixtures, snapshots), delivered with them"),commit:u.object({message:is.refine(t=>t.split(`
119
- `)[0].length<=Nu,{message:`subject line must be <= ${Nu} chars`})}),pr:u.object({title:is.max(Nu,`must be <= ${Nu} chars`),body:is}),ready:u.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:u.array(u.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:is.describe("one paragraph")});var qs=Re(require("fs")),qa=Re(require("path")),v0=require("child_process");var Zn="{junit}",Q0=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))(Q0||{}),b0=(e=>(e.Minitest="minitest",e))(b0||{}),w0=u.string().trim().min(1),Ha=u.object({cwd:w0.describe('repo-relative directory the command starts in ("." for the root)'),argv:u.array(w0).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${Zn}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:u.record(u.string(),u.string()).optional().describe("plain test or reporter settings beyond the repository's CI test job (RAILS_ENV=test, PLAYWRIGHT_JUNIT_OUTPUT_FILE={junit}); never a credential, PATH, or a tool's install path"),report:u.object({format:u.nativeEnum(Q0).describe(`junit (JUnit XML to ${Zn}), trx (to ${Zn}), or go-test-json (go test -json on the command's output)`),reporter:u.nativeEnum(b0).optional().describe("a reporter Testbot loads for a runner that writes no report: minitest")}).optional().describe("the report the command writes; junit when omitted")});var Ya="a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test), or one the repository's test script runs through another command (ng test, nx test)",vX=`pytest, Jest, Vitest and node --test tests run as the run already knows them, unless the repository's test script runs them through another command (ng test, nx test), which may be the only one that compiles them. A test in any other framework, or one run that way, also gives "run": the repository's own command for only those tests, from the directory the repository runs it in, as separate arguments without a shell. Its "report" says what the runner writes: junit (JUnit XML to ${Zn} in the reporter's argument or env setting), trx (a TRX file to ${Zn}, which every dotnet test writes with its built-in logger), or go-test-json (go test -json, read from the command's output). A Maven or Gradle command names no ${Zn}: its build writes JUnit XML to its own report directory, which the run reads. Use a reporter the repository already has, or one of those; a reporter or converter the command fetches is the version the repository pins, or else its latest release (an older one may not build with the repository's toolchain). For minitest, which writes none, give report.reporter "minitest" and the run fills ${Zn} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${Zn} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${Zn} in argv and env with its report path, executes the command, and reads that report.`;var ho=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(ho||{}),Ys=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(Ys||{}),Ny=(n=>(n.Repository="repository",n.Testbot="testbot",n))(Ny||{}),Fy=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(Fy||{}),Kt=u.string().trim().min(1),tJ=u.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var nJ=u.object({id:tJ,source:u.nativeEnum(Ny),kind:u.nativeEnum(_s),outcome:u.nativeEnum(Fy),summary:Kt.max(400).describe("one line: what it shows"),tests:u.array(Kt).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:Kt.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:Kt.optional().describe("source testbot: the exact command you ran, as you ran it"),run:Ha.optional().describe(`source repository, for tests in ${Ya}: how the run executes only these tests, all of them in one command, with the repository's own runner writing JUnit XML to {junit}. Name each test (path::test-name): a test is credited to a file only by its name or by a report that names the file`)}),rJ=u.object({behaviorId:Kt.describe("an id from analyze's behaviors"),mechanism:u.nativeEnum(Ys),evidenceIds:u.array(Kt).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:u.string().trim().optional().describe('new_unit / runtime: the missing evidence this obtains, e.g. "the boundary the change moved"; unaffected: why the change cannot reach it, citing path:line')}),sJ=u.object({behaviorId:u.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:Kt.max(600).describe("the evidence that is required and cannot be obtained in this run")}),iJ=u.object({file:Kt.describe("the changed file the failure is in"),repository:Kt.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:Kt.max(300).describe("what prerequisite the change fails"),evidence:Kt.max(400).describe("the error line, quoted")}),oJ=u.object({behaviorId:Kt.describe("an id from analyze's behaviors"),reason:Kt.max(600).describe("\u2264600 characters: why this change leaves the behavior's result as it was, citing the unchanged line that decides it (path:line)")}),Fu=u.object({schemaVersion:u.literal(1),decision:u.nativeEnum(ho),evidence:u.array(nJ).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:u.array(rJ).describe("how each changed behavior's evidence is obtained"),gaps:u.array(sJ),outOfScope:u.array(oJ).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:iJ.optional().describe("only for blocked_preflight"),rationale:Kt.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function $d(t){let e=bn(t,"recommend.json");if(!e||!Array.isArray(e.generate)||!Array.isArray(e.maintenance))return;let n=e;return{...n,maintenance:n.maintenance.map(({repository:r,...s})=>({...s,test:s.test.trim().replace(/^\.\//,""),...r?.trim()?{repository:r.trim()}:{}}))}}function AJ(t){return ts(Ty,t).errors}function lJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=AJ(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}function Vd(t,e=[]){return lJ(t.stdout,e)}function dJ(t){return t.generate.filter(e=>e.type!=="ui").map(e=>e.id)}function R0(t){return t.generate.filter(e=>e.type==="ui").map(e=>e.id)}var Gd={backend:{stage:"generate",cases:dJ,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:t=>`recommend case "${t}" is not covered by any generated test`,unknownCovered:t=>`test covers unknown recommend id "${t}"`,unasserted:t=>`case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:h0,codegenHint:"These tests were hand-written. Skyramp codegen (skyramp_contract_test_generation / skyramp_integration_test_generation) was available but not used \u2014 it computes valid sample data and response correlations. Prefer scaffolding with it and then refining, especially for the failures above."},ui:{stage:"generate-ui",cases:R0,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:t=>`UI case "${t}" is not covered by any generated UI test`,unknownCovered:t=>`test covers "${t}" which is not a recommend UI case`,unasserted:t=>`UI case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:f0,codegenHint:"This UI test was hand-authored. Skyramp UI codegen (skyramp_ui_test_generation) was available but not used. Prefer scaffolding with it and then refining, especially for the failures above."}},c6=Us("generate-schema",(t,e)=>Vd(e,t.secretValues));function pJ(t){let e=Gd[t];return{name:`${e.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=Vd(r,n.secretValues);if(!s)return Mt(this.name,i);let a=$d(n);if(!a)return Mt(this.name,[e.noRecommendCoverage]);let c=new Set(s.tests.flatMap(h=>h.covers)),A=[],l=e.cases(a);for(let h of l)c.has(h)||A.push(e.uncovered(h));let p=new Set(t==="ui"?l:a.generate.map(h=>h.id));for(let h of c)p.has(h)||A.push(e.unknownCovered(h));if(t==="backend"){let h=new Set(s.deferredUi),g=new Set(R0(a));for(let C of g)!h.has(C)&&!c.has(C)&&A.push(`UI case "${C}" is neither covered nor deferred to the UI stage`);for(let C of h)g.has(C)||A.push(`deferredUi lists "${C}" which is not a UI case`)}return A.length===0?{name:this.name,passed:!0}:Mt(this.name,A)}}}function hJ(t){let e=Gd[t];return{name:`${e.stage}-intent`,verify(n,r){let{generate:s,errors:i}=Vd(r,n.secretValues);if(!s)return Mt(this.name,i);let a=$d(n);if(!a)return Mt(this.name,[e.noRecommendIntent]);let{asserted:c,errors:A,badFiles:l}=IJ(s,n.inputs.repositoryPath),p=A.length;for(let g of e.cases(a))c.has(g)||A.push(e.unasserted(g));if(A.length===0)return{name:this.name,passed:!0};let h=Mt(this.name,A);return p>0&&p===A.length&&l.size>0?{...h,droppable:[...l]}:h}}}function fJ(t){let e=Gd[t];return n=>{if(!n.inputs.skyrampMcp?.command||t==="backend"&&!By(n))return;let r=qa.join(n.outputsDir,`${e.stage}-stream.ndjson`);if(!(!qs.existsSync(r)||e.usedCodegen(r)))return g0(r)?e.codegenHint:"Skyramp codegen tools were configured but the MCP server did not connect this session, so they were not available. Hand-authoring was the only option; this is an environment problem, not yours."}}var u6=pJ("backend"),A6=hJ("backend"),l6=fJ("backend");var k0=t=>t.replace(/\s+/g,"");var My={python:[/\bassert\s*[({\w"'`]/g,/\bpytest\.raises\s*\(/g,/\bself\.assert\w*\s*\(/g],typescript:[/\bexpect\s*\(/g,/\.should\b/g,/\bassert\s*[.(]/g],go:[/\bt\.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)\s*\(/g,/\b(assert|require)\.\w+\s*\(/g],java:[/\bassert\w*\s*\(/g,/\bassertThat\s*\(/g],ruby:[/\bexpect\s*[({]/g,/\bassert\w*\b/g,/\.should\b/g]};for(let[t,e]of[["javascript","typescript"],["kotlin","java"]])My[t]=My[e];function gJ(t,e){if(t.includes(Iu(e))||k0(t).includes(k0(e)))return!0;let n=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!/^(\/\/|#|\*|\/\*)/.test(r));return n.length>0&&n.every(r=>t.includes(Iu(r)))?!0:CJ(t,e)}var mJ=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,yJ=12,EJ=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function CJ(t,e){let n=e.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=mJ.exec(s);if(!i)continue;let a=s.slice(i.index),c=EJ.exec(a);if(c&&(a=a.slice(0,c.index)),a=Iu(a).replace(/[,\s]+$/,""),a.length<yJ||!t.includes(a))return!1;r++}return r>0}function IJ(t,e){let n=new Set,r=[],s=new Set;for(let i of t.tests){let a=qa.resolve(e,i.file);if(!qs.existsSync(a))continue;let c=Iu(qs.readFileSync(a,"utf-8"));for(let A of i.assertions??[]){if(!gJ(c,A.evidence)){r.push(`assertion evidence for "${A.case}" not found in ${i.file} \u2014 cite the real assertion line`),s.add(i.file);continue}i.covers.includes(A.case)?n.add(A.case):(r.push(`assertion cites case "${A.case}" not in that test's covers[]`),s.add(i.file))}}return{asserted:n,errors:r,badFiles:s}}var BJ=/\.(spec|test)\.[cm]?[jt]sx?$/i;function x0(t){let e;try{e=(0,v0.execFileSync)("git",[...Dd,"status","--porcelain","--untracked-files=all"],{env:zn(),cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=s=>/_scaffold/i.test(s)||Sd.test(s),r=[];for(let s of e.split(`
120
- `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),a=i.indexOf(" -> ");if(a!==-1&&(i=i.slice(a+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let c=i.replace(/^\.\//,"");c.startsWith(".skyramp/")||!n(c)||r.push(c)}return r}function wJ(t){let e=Gd[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=x0(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>BJ.test(a)===n);return i.length===0?{name:this.name,passed:!0}:Mt(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var d6=wJ("backend");var Mu=Re(require("fs")),fo=Re(require("path"));function N0(t){return ts(wy,t).errors}function SJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=N0(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}var kJ="adapt-scratch",T0=`${kJ}/adapt-result.json`;function F0(t,e){let n=fo.join(t.outputsDir,T0),r;try{r=Mu.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${T0} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=SJ(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?va(n):void 0;return i!==void 0&&N0(i).length===0?{adapt:i,errors:[]}:s}var M6=Us("adapt-schema",F0);var H6=2*1024*1024;var le=u.string().trim().min(1),RJ=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},xJ=u.preprocess(RJ,u.object({id:le.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:le.describe("one testable part of the requirement"),expected:le.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:u.string().optional().describe("only when no test can check this clause here: why"),type:u.nativeEnum(Gs).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:u.string().optional().describe('its "METHOD /path", or the page / flow'),steps:u.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:u.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:u.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:u.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:u.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),TJ=u.object({id:le.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:le,source:u.nativeEnum(Va).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:u.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:le.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:u.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:u.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:u.array(u.object({spec:u.string().optional().describe("file:line of the spec in the repository; leave it out for a PR description"),prDescription:u.boolean().optional().describe("true when a pull request description says otherwise"),says:le.describe("what the spec or the PR description says there, in its own words, copied exactly")}).refine(t=>!!(t.prDescription||t.spec?.trim()),{message:'names no source: give "spec" its file:line, or set "prDescription"'})).optional().describe("requirement-reference only: each spec in the repository, and each PR description, that says otherwise; the item wins, so test what it says"),clauses:u.array(xJ)}),M0=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(M0||{}),DJ=u.object({id:le.describe('e.g. "F1"'),file:le,line:u.number().optional(),claim:le.describe("the defect, in one sentence"),severity:u.nativeEnum(Tu),evidence:le.describe("the code line, or the probe request and response, that shows it"),conflictsWith:u.array(le).optional().describe("requirement or clause ids it violates"),keeps:u.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:u.nativeEnum(M0).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:u.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:u.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),NJ=u.object({id:le.describe('e.g. "Q1"'),question:le.describe("what is unsettled, as a question the PR author can answer"),readings:u.array(le).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:u.string().optional().describe("the requirement or clause id it is about, when there is one")}),FJ=u.object({id:le.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:u.nativeEnum(Gs).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:le.describe('"METHOD /path", or the page / flow'),clause:u.string().optional().describe("the clause id this case checks"),finding:u.string().optional().describe("the finding id this case catches"),steps:le.describe("what the test does"),expected:le.describe("the expected outcome, from the clause"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),MJ=u.object({test:le.describe("existing test file"),action:u.nativeEnum(uo),reason:le,mutates:u.boolean().optional().describe("true when the maintained test changes state"),clauses:u.array(le).optional().describe("the clause ids this test checks")}),_J=u.object({outcome:u.nativeEnum(ns).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app"),health:u.object({url:u.string().optional(),command:u.string().optional(),output:u.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:u.string().optional().describe("command that stops the app"),dependencies:u.record(u.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:u.array(u.string()).optional().describe("what you changed in the recipe"),error:u.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:u.object({username:le,password:u.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:py.optional()}),I7=u.object({schemaVersion:u.literal(1),requirements:u.array(TJ),findings:u.array(DJ),cases:u.array(FJ).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:u.array(NJ).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:u.array(MJ),journeys:u.array(E0).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:u.array(u.object({clause:le,why:le})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Fu.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:_J.optional().describe("omit when no app was needed or none was started"),summary:le.describe("one paragraph: what the change does and where the risk is")});var _0=(n=>(n.Backend="backend",n.Ui="ui",n))(_0||{});var _y=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(_y||{}),UJ=u.object({file:le.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:u.nativeEnum(_0),change:u.nativeEnum(_y).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:u.array(u.string()).describe("the plan case ids this file tests"),defect:u.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:u.object({requirement:le.describe("the requirement or clause id the change deliberately alters"),line:le.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:u.object({exit:u.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:u.array(u.object({case:le,status:u.nativeEnum(Kn),defect:u.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:u.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:u.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:u.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:u.string().optional().describe("what failed and why, or why it was not run")}),assertions:u.array(u.object({case:le,evidence:le})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:u.array(u.object({name:le.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:u.array(le).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:u.object({draft:u.union([u.string(),u.array(u.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:u.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:u.array(xy).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:le.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),run:Ha.optional().describe(`for a file in ${Ya}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${Zn}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),LJ=u.object({description:le.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:u.nativeEnum(Tu).optional(),sourceFile:u.string().optional().describe("the app file at fault"),sourceLine:u.number().optional(),test:u.string().optional().describe("the test file that shows it"),finding:u.string().optional().describe("the plan's finding id, when it is one"),requirements:u.array(le).optional().describe("the plan's requirement or clause ids it violates")}),B7=u.object({schemaVersion:u.literal(1),tests:u.array(UJ),notWritten:u.array(u.object({case:le,reason:le})).describe("every plan case no test covers, and why"),journeys:u.array(Ud).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:u.array(u.object({package:le,manifest:le.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:le.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:le.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:u.array(le).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciRunsTests:u.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),ciNotes:u.string().optional().describe("when ciRunsTests is false: which of your tests the repo's CI will not collect, why, and the exact change the author must make for CI to run them"),commit:u.object({message:le.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:le.describe("at most 72 characters"),prBody:le.describe("what the tests cover and what they found")}),report:u.object({summary:le.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:u.array(LJ).describe("every defect the tests found"),nextSteps:u.array(u.string())})});var w7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var L0=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(L0||{}),yt=u.string().trim().min(1),PJ=u.object({expectation:yt.max(300).describe("the behavior this assertion pins, in words"),source:u.nativeEnum(L0),expected:yt.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),OJ=u.object({file:yt.describe("path of the NEW test file you wrote, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:yt.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:Ha.optional().describe(`for ${Ya}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:u.array(yt).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:u.array(yt).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:u.array(PJ).min(1)}),Uy=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Uy||{}),U0=300,$J=u.object({file:yt.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:u.nativeEnum(Uy),staleBecause:u.object({requirement:yt.describe("the requirement or clause id the change deliberately alters"),line:yt.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:u.preprocess(t=>typeof t=="string"?t.trim().slice(0,U0):t,yt.max(U0)).describe("what the change deliberately altered that made the test wrong")}),Ly=u.object({schemaVersion:u.literal(1),tests:u.array(OJ),maintained:u.array($J).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:u.array(u.object({id:yt,reason:yt.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:u.array(Ud).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:u.array(u.object({journey:yt,missing:yt.transform(t=>t.length>300?`${t.slice(0,299)}\u2026`:t)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:yt.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var H7=5*6e4;function HJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=ts(Ly,e);return s.length?{errors:s}:{output:r,errors:[]}}function YJ(t){return HJ(t.stdout)}var Jee=Us("generate-unit-schema",(t,e)=>YJ(e));var Hd=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,Wee=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${Hd}["']|\bimport\s+["']${Hd}["']|require\(\s*["']${Hd}["']\s*\)|\bimport\(\s*["']${Hd}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];var O0=String.raw`\b(?:real browser|browser|javascript|js|htmx|client-side)\b`,$0=String.raw`\b(?:not|isn't|aren't|never|no)\s+(?:be\s+)?(?:covered|tested|exercised|verified|checked|walked|executed|run)\b|\buncovered\b|\bunverified\b`,Ate=[new RegExp(`${O0}[^.;\\n]{0,100}(?:${$0})`,"i"),new RegExp(`(?:${$0})[^.;\\n]{0,100}${O0}`,"i")];var lte=new Set(["targeted_unit","existing_evidence_sufficient"]);var Zte=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),Xte={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function zJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=ts(Fu,e);return s.length?{errors:s}:{triage:r,errors:[]}}function KJ(t){return zJ(t.stdout)}var ene=Us("triage-schema",(t,e)=>KJ(e));var tne=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);Dt();Dt();var XJ="Skyramp-Pull-Request",eW="Skyramp-Delivery-Base",tW="Skyramp-Tested-Revision";var Cne=["%H","%P","%an","%ae","%ce",`%(trailers:key=${XJ},valueonly,separator=%x2C)`,"%s",`%(trailers:key=${eW},valueonly,separator=%x2C)`,`%(trailers:key=${tW},valueonly,separator=%x2C)`];var qd=(n=>(n.GitHub="github",n.AzureDevOps="azure-devops",n))(qd||{}),$y=(i=>(i.Trigger="TRIGGER",i.Baseline="BASELINE",i.AuthoritativeRelatedChange="AUTHORITATIVE_RELATED_CHANGE",i.ConfiguredSharedDependency="CONFIGURED_SHARED_DEPENDENCY",i.ManualOverride="MANUAL_OVERRIDE",i))($y||{}),Uu=(a=>(a.PullRequest="pull_request",a.ReadyForReview="ready_for_review",a.Schedule="schedule",a.Manual="manual",a.SutSetup="sut_setup",a.RevisionRead="revision_read",a))(Uu||{}),sW=["sut_setup"],iW=["sut_setup","schedule","revision_read"];var jd=(e=>(e.PullRequest="pull_request",e))(jd||{}),Lu=(s=>(s.ModelProvider="model_provider",s.SutAccess="sut_access",s.Skyramp="skyramp",s.Other="other",s))(Lu||{});var Jd=(i=>(i.ReportUploaded="report_uploaded",i.NoReport="no_report",i.Cancelled="cancelled",i.RecipeUploaded="recipe_uploaded",i.RevisionsUploaded="revisions_uploaded",i))(Jd||{}),X0=(n=>(n.Running="running",n.Ended="ended",n))(X0||{}),Wd=(p=>(p.TimedOut="timed_out",p.AgentFailed="agent_failed",p.SetupFailed="setup_failed",p.CredentialMissing="credential_missing",p.RunnerLost="runner_lost",p.CheckoutFailed="checkout_failed",p.EnvironmentUnverified="environment_unverified",p.ModelProviderDenied="model_provider_denied",p.ModelProviderUnavailable="model_provider_unavailable",p.RunnerProviderNotReady="runner_provider_not_ready",p))(Wd||{}),Vy=(r=>(r.Onboard="onboard",r.Deploy="deploy",r.Recheck="recheck",r))(Vy||{}),Gy=(n=>(n.Started="started",n.Finished="finished",n))(Gy||{}),Hy=(r=>(r.Passed="passed",r.Failed="failed",r.Skipped="skipped",r))(Hy||{});var Yy=(r=>(r.ChooseCredential="choose_credential",r.FreeText="free_text",r.ChooseSource="choose_source",r))(Yy||{});var zd=(r=>(r.Discover="discover",r.Start="start",r.Check="check",r))(zd||{}),Kd=(s=>(s.ValidationPlan="validation_plan",s.TestEnvironment="test_environment",s.TestConditions="test_conditions",s.Tests="tests",s))(Kd||{}),Pu=(s=>(s.Found="found",s.Starting="starting",s.Up="up",s.OutOfScope="out_of_scope",s))(Pu||{}),Xn=u.string().regex(/^[1-9][0-9]{0,18}$/),as=u.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Ja=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,_t=u.string().regex(Ja),Ut=u.string().regex(/^[0-9a-f]{64}$/),Yd=u.object({id:_t,revision:Xn}).strict(),Zd={provider:u.literal("github"),providerAccountId:Xn,providerRepositoryId:Xn},Xd={provider:u.literal("azure-devops"),providerAccountId:_t,providerRepositoryId:_t},er=u.discriminatedUnion("provider",[u.object(Zd).strict(),u.object(Xd).strict()]),qy=u.discriminatedUnion("provider",[u.object(Zd).passthrough(),u.object(Xd).passthrough()]),go=t=>`${t.provider}:${t.providerRepositoryId}`,V0={namespace:u.string().min(1),name:u.string().min(1)},eT=u.discriminatedUnion("provider",[u.object({...Zd,...V0}).strict(),u.object({...Xd,...V0}).strict()]),G0=u.object({ref:u.string().min(1),revision:as}).strict(),oW=u.object({repository:eT,revision:as,ref:u.string().nullable(),reason:u.nativeEnum($y),change:u.object({kind:u.nativeEnum(jd),number:Xn,base:G0.optional()}).strict().nullable(),compareWith:G0.optional()}).strict();function aW(t){if(t.trigger.kind==="revision_read"!=!t.baseline)return t.baseline?"a revision_read run names no baseline":"names its baseline";if(!t.baseline)return null;let{confirmedRunId:e,initialBaselineId:n,sources:r}=t.baseline;if(e!==null&&n!==void 0)return"a run compares with one baseline";let s=t.trigger.kind==="schedule"&&e!==null||n!==void 0;if(!r)return s?"names every source of the snapshot, once":null;if(e===null&&n===void 0)return"a run with no Confirmed Baseline names no baseline sources";let i=new Set(t.sources.map(A=>go(A.repository))),a=new Set(r.map(A=>go(A.repository)));return a.size===r.length&&a.size===i.size&&[...a].every(A=>i.has(A))?null:"names every source of the snapshot, once"}var tT=/^[A-Z][A-Z0-9_]+-[1-9][0-9]*$/,nT=/^[1-9][0-9]{0,18}$/,H0=new RegExp(`${tT.source}|${nT.source}`),Y0=/^https:\/\/[a-z0-9-]+(\.[a-z0-9-]+)+$/,cW=u.union([u.object({source:u.literal("jira"),site:u.string().regex(Y0),key:u.string().regex(tT),updated:u.string().datetime(),contentHash:Ut}).strict(),u.object({source:u.literal("confluence"),site:u.string().regex(Y0),key:u.string().regex(nT),version:u.number().int().positive(),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),contentHash:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict()]),q0=u.union([u.literal("jira"),u.literal("confluence")]),uW=u.object({schemaVersion:u.literal(1),items:u.array(u.union([u.object({source:q0,site:u.string(),key:u.string().regex(H0),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:q0,site:u.string(),key:u.string().regex(H0),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("read"),version:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict()])),instructions:u.array(u.string()).optional()}).strict(),AW=u.object({schemaVersion:u.literal(1),runId:_t,skyrampOrgId:_t,target:Yd,policy:Yd.nullable(),trigger:u.object({kind:u.nativeEnum(Uu),requestedAt:u.string().datetime()}).strict(),configuration:u.object({captureId:_t,revision:Xn.nullable(),hash:Ut}).strict(),baseline:u.object({confirmedRunId:_t.nullable(),initialBaselineId:_t.optional(),sources:u.array(u.object({repository:er,revision:as}).strict()).optional()}).strict().optional(),sources:u.array(oW).min(1),execution:u.object({provider:u.nativeEnum(qd),repository:eT,workflowPath:u.string(),ref:u.string()}).strict(),credentials:u.array(u.object({name:u.string(),purpose:u.nativeEnum(Lu),required:u.boolean()}).strict()),requirements:u.array(cW).min(1).optional(),instructions:u.object({contentHash:Ut}).strict().optional(),deployedRevisions:u.array(u.object({repository:er,revision:as}).strict()).min(1).optional()}).strict().superRefine((t,e)=>{let n=new Set;(t.requirements??[]).forEach((A,l)=>{let p="fileName"in A?"file":"pasted";A.source==="other"&&A.key!==`${p}-${A.contentHash.slice(0,16)}`&&e.addIssue({code:u.ZodIssueCode.custom,message:"is not the key of its content hash",path:["requirements",l,"key"]});let h=oy({source:A.source,key:A.key});n.has(h)&&e.addIssue({code:u.ZodIssueCode.custom,message:"names an item that the run already names",path:["requirements",l,"key"]}),n.add(h)});let r=t.trigger.kind,s=sW.includes(r);s!==(t.policy===null)&&e.addIssue({code:u.ZodIssueCode.custom,path:["policy"],message:s?`a ${r} run has no policy`:"names the policy revision"});let i=aW(t);i&&e.addIssue({code:u.ZodIssueCode.custom,path:t.baseline?["baseline","sources"]:["baseline"],message:i}),iW.includes(r)&&t.sources.forEach((A,l)=>{A.reason!=="BASELINE"&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"reason"],message:`a ${r} run selects only BASELINE sources`})}),t.deployedRevisions&&r!=="manual"&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions"],message:"only a manual run pins deployed revisions"});let a=new Set(t.sources.map(A=>go(A.repository))),c=new Set;(t.deployedRevisions??[]).forEach((A,l)=>{let p=go(A.repository);a.has(p)?c.has(p)&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"repository appears twice"}):e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"names a repository outside the snapshot"}),c.add(p)}),t.sources.forEach((A,l)=>{A.compareWith&&(A.reason!=="MANUAL_OVERRIDE"||A.change)&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"compareWith"],message:"only a MANUAL_OVERRIDE source without a change names a revision to compare with"})})});var rT=(n=>(n.Person="person",n.Policy="policy",n))(rT||{}),lW=u.object({kind:u.nativeEnum(rT),name:u.string().min(1).max(256)}).strict(),dW=u.object({mcp:u.discriminatedUnion("source",[u.object({source:u.literal("npm"),version:u.string().regex(/^[A-Za-z0-9][A-Za-z0-9.+_-]{0,63}$/).nullable()}).strict(),u.object({source:u.literal("github"),ref:u.string().regex(/^[A-Za-z0-9._/-]{1,255}$/)}).strict()]),bedrock:u.object({region:u.string().regex(/^[a-z]{2}(-[a-z]+)+-[0-9]$/),roleArn:u.string().regex(/^arn:aws(-[a-z]+)*:iam::[0-9]{12}:role\/[\w+=,.@/-]{1,512}$/)}).strict().nullable()}).strict(),Kne=u.object({schemaVersion:u.literal(1),attempt:u.object({id:_t,number:u.number().int().positive(),deadlineAt:u.string().datetime()}).strict(),manifest:AW,manifestHash:Ut,entitlements:u.array(u.string()).optional(),runToken:u.string().min(1).optional(),requestedBy:lW.nullable().optional(),writeAllowed:u.boolean().optional(),claudeCodeVersion:u.string().regex(/^[0-9]+\.[0-9]+\.[0-9]+$/,"an exact version, such as 2.1.290").nullable().optional(),deployedRevisions:u.array(u.object({repository:er,revision:as}).strict()).optional(),statedRevisions:u.array(u.object({repository:er,revision:as}).strict()).optional(),runSettings:dW.optional()}).strict(),j0={providerRunAttempt:u.number().int().positive(),workflowRef:u.string().min(1)},pW=u.string().regex(/^[^/]+\/[^/]+\/[1-9][0-9]{0,15}\/[1-9][0-9]{0,15}$/),Zne=u.object({schemaVersion:u.literal(1),runId:_t,execution:u.discriminatedUnion("provider",[u.object({...j0,provider:u.literal("github"),repository:u.object(Zd).strict(),providerRunId:Xn}).strict(),u.object({...j0,provider:u.literal("azure-devops"),repository:u.object(Xd).strict(),providerRunId:pW}).strict()]),requester:u.literal(!0).optional(),writeCheck:u.literal(!0).optional(),claudeCodePin:u.literal(!0).optional(),deployedPins:u.literal(!0).optional(),statedPins:u.literal(!0).optional(),runSettings:u.literal(!0).optional()}).strict(),J0=u.object({repository:er,number:Xn}).strict(),hW=u.discriminatedUnion("status",[u.object({status:u.literal("none")}).strict(),u.object({status:u.literal("delivered"),pullRequests:u.array(J0).min(1)}).strict(),u.object({status:u.literal("partial"),pullRequests:u.array(J0).min(1),failures:u.array(u.object({repository:er,message:u.string()}).strict()).min(1)}).strict(),u.object({status:u.literal("failed"),message:u.string()}).strict()]),fW=u.object({blockedPreflight:u.object({file:u.string().min(1),repository:u.string().min(1).optional(),reason:u.string().min(1).max(300),evidence:u.string().min(1).max(400)}).strict().optional(),sufficiency:u.nativeEnum(Sa),rationale:u.string().min(1),gaps:u.array(u.string().min(1)),acceptedEvidence:u.array(u.object({kind:u.nativeEnum(_s),repository:u.string().min(1),revision:as,reference:u.string().min(1),summary:u.string().min(1)}).strict()),actionRequired:u.array(u.nativeEnum(ka))}).strict().superRefine((t,e)=>{t.sufficiency==="insufficient"!=t.gaps.length>0&&e.addIssue({code:u.ZodIssueCode.custom,path:["gaps"],message:"only insufficient evidence names gaps, and it names at least one"}),new Set(t.actionRequired).size!==t.actionRequired.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["actionRequired"],message:"a reason appears twice"})}),Py=500,gW=2048,mW=1e3,yW=/[\\/:*?"<>|;#$*{},+=[\]%\p{Cc}\p{Cf}]/u,W0=t=>t.length>0&&t.length<=64&&t===t.trim()&&!yW.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith("."),EW=t=>{if(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/.test(t))return!0;let[e,n,r,...s]=t.split("/");return t.length<=201&&s.length===0&&r!==void 0&&/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/.test(e)&&W0(n)&&W0(r)},CW=u.object({testResults:u.array(u.object({resultId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/),repository:u.string().refine(EW,"Invalid"),testType:u.string(),endpoint:u.string(),status:u.enum(["Pass","Fail","Skipped"]),details:u.string(),fileName:u.string().optional(),testId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/).optional(),failureCause:u.object({kind:u.nativeEnum(cy),family:u.nativeEnum(uy).optional()}).strict().optional(),origin:u.nativeEnum(ay).optional()}).strict()),validation:fW,changes:u.array(u.object({id:u.string().min(1).max(512),text:u.string().max(16384),source:u.string().max(gW),testedBy:u.array(u.string().min(1).max(1024)).max(Py),writtenBy:u.array(u.string().min(1).max(1024)).max(Py),maintainedBy:u.array(u.string().min(1).max(1024)).max(Py)}).strict()).max(mW).optional(),traceVersion:u.literal(1)}).passthrough().superRefine((t,e)=>{let n=new Set;t.testResults.forEach((r,s)=>{let i=r.failureCause;i&&r.status==="Pass"&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"a passing result has no failure cause"}),i&&i.kind==="environment"!=(i.family!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"an environment cause names its family, and no other cause does"});let a=["testResults",s,"resultId"],c=r.resultId.slice(`${r.repository}:${r.testType}:`.length);(!r.resultId.startsWith(`${r.repository}:${r.testType}:`)||c===""||c.startsWith("/")||c.startsWith("#"))&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"is not repository:testType:path for this result"}),n.has(r.resultId)&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"stable identity repeated"}),n.add(r.resultId)})});var sT=50,z0=u.string().regex(/^(?!.*\.\.)(?!\/)(?!.*\/$)[A-Za-z0-9._/-]{1,255}$/),iT=u.discriminatedUnion("kind",[u.object({kind:u.literal("branch_pushed"),repository:er,branch:z0,commit:as}).strict(),u.object({kind:u.enum(["pull_request_opened","pull_request_edited"]),repository:er,number:Xn,branch:z0}).strict()]),IW=u.object({schemaVersion:u.literal(1),run:u.object({runId:_t,attemptNumber:u.number().int().positive(),manifestHash:Ut}).strict(),target:Yd,policy:Yd,provenance:u.object({sources:u.array(u.object({repository:er,revision:as}).strict()),firstQualification:u.literal(!0).optional()}).strict(),delivery:u.object({generatedTests:hW}).strict(),producer:u.object({testbot:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/),mcp:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/)}).strict(),report:CW,githubWrites:u.array(iT).max(sT).optional()}).strict(),Xne=IW.pick({schemaVersion:!0,run:!0,target:!0,provenance:!0,producer:!0}).extend({recipe:Sy}).strict().superRefine(({recipe:t},e)=>{let n=(i,a)=>e.addIssue({code:u.ZodIssueCode.custom,path:["recipe",...i],message:a});t.status==="blocked"&&t.blockers.length===0&&n(["blockers"],"a blocked recipe names at least one blocker");let r=new Set,s=0;t.files.forEach((i,a)=>{Ru(i.path)||n(["files",a,"path"],"is not .skyramp/workspace.yml or a file under .skyramp/sut/"),r.has(i.path)&&n(["files",a,"path"],"file repeated"),r.add(i.path),fy.test(i.content)&&n(["files",a,"content"],"is not text");let c=Buffer.byteLength(i.content,"utf8");s+=c,c>ku&&n(["files",a,"content"],`larger than ${ku} bytes`)}),s>vu&&n(["files"],`recipe text over ${vu} bytes in total`)}),ere=u.object({components:u.array(u.object({name:u.string().min(1),repository:u.string().regex(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/),observedRevision:u.string().regex(/^[0-9a-f]{7,64}$/).nullable(),source:u.nativeEnum(Cd),evidence:u.string()}).strict().refine(t=>t.source!=="agent"||t.observedRevision===null,{path:["observedRevision"],message:"a component only an agent session can read names no revision"}))}).strict();var BW=u.object({schemaVersion:u.literal(1),stage:u.nativeEnum(Vy),event:u.nativeEnum(Gy),status:u.nativeEnum(Hy).optional()}).strict().refine(t=>t.status===void 0||t.event==="finished",{path:["status"],message:"only a finished stage has a status"}),Wa=100,jy=5e3,_u=2e3,Oy=100,Jy=/^[A-Za-z0-9_-]{1,64}$/,oT=20,aT=200,cT=100,uT=100,wW=200,K0="[^/\\s](?:(?:[^/\\s]| )*[^/\\s])?",QW=new RegExp(`^(?:[^/\\s]+/[^/\\s]+|[^/\\s]+/${K0}/${K0})$`),AT=500,lT=50,Ou=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/,xn=t=>u.string().max(t).refine(e=>e.trim().length>0&&!Ou.test(e),"blank, or not text"),os={sequence:u.number().int().min(1).max(jy),at:u.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?Z$/)},dT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),phase:u.nativeEnum(zd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("component"),name:xn(Oy),repository:xn(wW).refine(t=>QW.test(t)||t===zt,"not owner/name"),file:xn(AT).nullable(),status:u.nativeEnum(Pu),version:xn(uT).optional()}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("question"),id:u.string().regex(Jy),type:u.nativeEnum(Yy),text:xn(_u),component:xn(Oy).nullable(),choices:u.array(xn(aT)).max(oT),placeholder:xn(cT).optional()}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict(),u.object({...os,kind:u.literal("credentials"),names:u.array(u.string().regex(La)).min(1).max(lT)}).strict()]).superRefine((t,e)=>{t.kind==="credentials"&&new Set(t.names).size!==t.names.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["names"],message:"a name twice"}),t.kind==="question"&&(t.type==="free_text"!=(t.choices.length===0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"choices exactly when the question is not free_text"}),new Set(t.choices).size!==t.choices.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"a choice twice"}))}),bW=u.object({schemaVersion:u.literal(1),events:u.array(dT).max(Wa)}).strict(),pT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),stage:u.nativeEnum(Kd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict()]),SW=u.object({schemaVersion:u.literal(1),events:u.array(pT).max(Wa)}).strict(),Z0={id:u.string().uuid(),text:u.string(),by:u.string().nullable(),at:u.string(),replied:u.literal(!0).optional()},hT=u.discriminatedUnion("kind",[u.object({...Z0,kind:u.literal("instruction"),question:u.null()}),u.object({...Z0,kind:u.literal("answer"),question:u.string().regex(Jy)})]),fT=u.string().regex(/^[A-Za-z0-9+/]{43}=$/),kW=u.object({id:u.string().uuid(),revision:u.string(),by:u.string().nullable(),at:u.string(),target:u.string(),own:u.object({source:u.enum(["policy","test_environment"]),text:u.string()}).nullable()}),vW=u.object({schemaVersion:u.literal(1),leftOut:u.array(u.string()),messages:u.array(hT).optional(),stop:u.object({key:fT}).optional(),notes:kW.optional()}),RW=u.object({schemaVersion:u.literal(1),messages:u.array(hT).optional()});var gT=500*1024*1024,mT=u.object({id:Xn,name:u.string().regex(/^[A-Za-z0-9._-]{1,200}$/),providerRunId:Xn,expiresAt:u.string().datetime()}).strict(),xW=u.object({schemaVersion:u.literal(1),artifact:mT,sessionId:_t,contentHash:Ut,bytes:u.number().int().min(1).max(gT)}).strict(),TW=u.object({schemaVersion:u.literal(1),checkpoint:u.object({artifact:mT,repository:u.object({namespace:u.string().min(1),name:u.string().min(1)}).strict(),sessionId:_t,contentHash:Ut,key:fT}).strict().nullable()}).strict(),DW=200,ja=100,Wy=(r=>(r.Resume="resume",r.Retry="retry",r.Update="update",r))(Wy||{}),NW=u.object({kind:u.nativeEnum(Wy),setup:u.object({runId:_t,endedAt:u.string().nullable(),outcome:u.string().nullable()}).strict(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1),status:u.nativeEnum(Pu)}).strict()).max(ja),credentials:u.array(u.string().min(1)).max(ja),answers:u.array(u.object({question:u.string(),answer:u.string().nullable()}).strict()).max(ja),instructions:u.array(u.object({text:u.string(),reply:u.string().nullable()}).strict()).max(ja),log:u.array(u.object({phase:u.nativeEnum(zd),text:u.string()}).strict()).max(DW),recipe:u.object({files:u.array(u.object({path:u.string().min(1),content:u.string()}).strict()).max(ja),blockers:u.array(u.object({component:u.string(),problem:u.string(),evidence:u.string(),fix:u.string()}).strict()).max(ja)}).strict().optional()}).strict(),FW=u.object({schemaVersion:u.literal(1),context:NW.nullable()}).strict(),MW=u.object({schemaVersion:u.literal(1),configuration:u.object({captureId:_t,revision:Xn.nullable(),hash:Ut}).strict(),capture:u.object({schemaVersion:u.literal(1),settings:u.object({target:u.object({environment:u.unknown()}).passthrough(),timeoutMinutes:u.number().int().positive(),answerWaitMinutes:u.number().int().positive().optional(),testEnvironment:u.object({name:u.string().min(1),address:u.string().min(1).optional(),readyWhen:u.string().min(1).optional()}).passthrough().optional()}).passthrough(),provenance:u.object({}).passthrough(),hash:Ut}).strict()}).strict(),_W=Oa.extend({version:u.number().int().positive(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1)}).strict()),contentHash:Ut.optional(),files:u.array(u.object({path:u.string().refine(t=>Ru(t)&&!_d.includes(t),"not a file of a customer_deployed plan"),content:u.string()}).strict()).optional()}).strict(),UW=u.object({schemaVersion:u.literal(1),testEnvironment:_W.nullable().optional(),runtimePlan:u.object({version:u.number().int().positive(),contentHash:Ut,files:u.array(u.object({path:u.string().refine(Ru,"not a recipe file path"),content:u.string()}).strict()).min(1),recipe:u.record(u.unknown()).optional()}).strict().nullable()}).strict().refine(t=>!(t.runtimePlan&&t.testEnvironment),{message:"a run pins a recipe or a customer's Test Environment, never both",path:["testEnvironment"]}),LW=u.object({schemaVersion:u.literal(1),state:u.nativeEnum(X0),ending:u.nativeEnum(Jd).nullable(),cause:u.nativeEnum(Wd).nullable(),deadlineAt:u.string().datetime()}).strict();function yT(t){return t.reportUploaded?{schemaVersion:1,reason:"report_uploaded",cause:null}:t.recipeUploaded?{schemaVersion:1,reason:"recipe_uploaded",cause:null}:t.revisionsUploaded?{schemaVersion:1,reason:"revisions_uploaded",cause:null}:t.cancelled?{schemaVersion:1,reason:"cancelled",cause:null}:{schemaVersion:1,reason:"no_report",cause:PW(t)}}function PW(t){return t.runnerProviderNotReady?"runner_provider_not_ready":t.credentialMissing?"credential_missing":t.checkoutFailed?"checkout_failed":t.environmentUnverified?"environment_unverified":t.setupFailed?"setup_failed":t.timedOut?"timed_out":t.modelProviderDenied?"model_provider_denied":t.modelProviderUnavailable?"model_provider_unavailable":"agent_failed"}var sre={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"};var $W=10*1024*1024;var ET=Re(require("fs")),$u="SKYRAMP_AZURE_SUPERVISED",zy=3;function ep(t){return t.replace(/##(?=(?:vso)?\[)/gi,"#\u200B#")}function Ky(t,e=process.env){e[$u]==="1"?ET.writeSync(zy,`${JSON.stringify(t)}
118
+ `)){let r=n.trim();if(!r)continue;let s;try{s=JSON.parse(r)}catch{continue}let i=s.message?.content;Array.isArray(i)&&e.push(...i)}return e}var m0=Re(require("path"));var bt=u.string().trim().min(1),by=(n=>(n.TestbotManaged="testbot_managed",n.CustomerDeployed="customer_deployed",n))(by||{}),_d=[".skyramp/sut/setup.sh",".skyramp/sut/teardown.sh"],Sy=u.object({schemaVersion:u.literal(1),type:u.nativeEnum(by).optional(),status:u.enum(["ready","blocked"]),environment:Oa.optional(),components:u.array(u.object({name:bt,repository:bt.describe(`owner/repo, or "${zt}" for a customer-deployed component no repository builds`),healthy:u.boolean(),url:u.string().min(1).nullable(),...hy,credentials:u.array(u.string().regex(La)).max(50).optional(),deployed:bt.nullable().optional().describe("customer_deployed only: the revision the component runs, as setup read it (WF-SETUP-22's Deployed now), or null when it could not tell")}).strict()),suites:u.array(u.object({framework:bt,file:bt,result:u.enum(["pass","fail","error"])}).strict()),inputsUsed:u.array(bt),inputsUsedHow:u.array(u.object({input:bt,how:bt}).strict()).optional(),inputsNotUsed:u.array(u.object({input:bt,reason:bt}).strict()),blockers:u.array(u.object({component:bt,problem:bt,evidence:bt,fix:bt}).strict()),replay:u.object({outcome:bt,durationSeconds:u.number().nonnegative().nullable()}).strict().nullable(),files:u.array(u.object({path:bt,content:u.string()}).strict())}).strict().superRefine((t,e)=>{t.inputsUsedHow?.forEach((s,i)=>{t.inputsUsed.includes(s.input)||e.addIssue({code:u.ZodIssueCode.custom,path:["inputsUsedHow",i,"input"],message:"not one of inputsUsed"})}),t.components.forEach((s,i)=>{s.credentials&&new Set(s.credentials).size!==s.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"credentials"],message:"names a credential twice"})});let n=t.type==="customer_deployed";n!==(t.environment!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment"],message:"an environment exactly when the plan's type is customer_deployed"}),t.environment&&new Set(t.environment.credentials).size!==t.environment.credentials.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["environment","credentials"],message:"names a credential twice"});let r=new Set(t.components.map(s=>s.name));if(t.environment?.revisionSources.forEach((s,i)=>{s.components.forEach((a,c)=>{r.has(a)||e.addIssue({code:u.ZodIssueCode.custom,path:["environment","revisionSources",i,"components",c],message:"not one of components"})})}),t.components.forEach((s,i)=>{s.deployed!==void 0!==n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"deployed"],message:"what a component runs exactly when the plan is customer_deployed"}),s.repository===zt&&!n&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"repository"],message:`only a customer_deployed component is ${zt}`})}),n&&(t.components.forEach((s,i)=>{t.components.findIndex(a=>a.name===s.name)!==i&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",i,"name"],message:"names a component twice"})}),t.replay!==null&&e.addIssue({code:u.ZodIssueCode.custom,path:["replay"],message:"a customer_deployed plan is never replayed"}),t.files.forEach((s,i)=>{_d.includes(s.path)&&e.addIssue({code:u.ZodIssueCode.custom,path:["files",i,"path"],message:"a customer_deployed plan has no script that starts or stops the system"})})),n&&t.status==="ready"){let s=new Set(t.environment?.revisionSources.flatMap(i=>i.components));t.components.forEach((i,a)=>{i.repository!==zt&&!s.has(i.name)&&e.addIssue({code:u.ZodIssueCode.custom,path:["components",a,"name"],message:"a ready customer_deployed plan reads what every component a repository builds runs"})})}});var Z5=["clean","recipe-drift"];function Ru(t){let e=m0.posix.normalize(t);return e===t&&(e===".skyramp/workspace.yml"||e.startsWith(".skyramp/sut/")&&e.length>13)}var ky=[".skyramp/sut",".skyramp/workspace.yml"];var iX=256*1024*1024;var oX=["--",":/",...ky.map(t=>`:(exclude)${t}`)];var Gj=u.object({route:u.string().describe('the page this step happens on, e.g. "/products/:id"'),action:u.string().describe('what the user does there, through the UI, e.g. "clicks Add to cart"'),clauses:u.array(u.string()).optional().describe("the plan clause ids this step exercises"),check:u.string().optional().describe("what the user then sees that shows the step worked; the test asserts it")}),xu=(n=>(n.InProcess="in-process",n.Browser="browser",n))(xu||{}),y0=(r=>(r.Spec="spec",r.PrDescription="pr-description",r.Inferred="inferred",r))(y0||{}),E0=u.object({id:u.string().describe('e.g. "J1"'),name:u.string().describe(`the flow in a user's words, e.g. "buy a product with a coupon"`),entry:u.string().describe("the route the user starts the flow on: the app's normal starting page for it, never a deep link into its middle"),steps:u.array(Gj).describe("every step, in order, from the entry page to the outcome: at least two"),outcome:u.string().describe("what the user sees at the end that shows the flow worked: every part of it"),finishes:u.string().optional().describe('the user action that completes the task, verb first, e.g. "places the order"; the journey walks on to it'),kind:u.nativeEnum(xu).optional().describe("in-process when the repo's in-process tests (components, app routes) can walk the whole flow and check it; else browser"),source:u.nativeEnum(y0).optional().describe("spec or pr-description when one describes this flow (quote it under evidence), else inferred"),evidence:u.string().optional().describe("for spec or pr-description: its words that describe the flow"),testFile:u.string().describe("the browser test file it goes in, beside the repo's existing e2e tests")}),Ud=u.object({journey:u.string().describe("the plan's journey id"),file:u.string().describe("the browser test file that walks it"),brokeAt:u.object({step:u.number().int().describe("the 1-based step whose check failed first"),expected:u.string(),actual:u.string().describe("what the app did instead, from the runner's output"),notReached:u.array(u.number().int()).optional().describe("later steps the test could not get to")}).optional().describe("only when the journey's test failed on a check: where"),test:u.string().describe("the title of the one test in that file that walks it end to end")});var Ry=(s=>(s.RestApi="rest-api",s.Frontend="frontend",s.FullStack="full-stack",s.Other="other",s))(Ry||{}),Tu=(s=>(s.Critical="critical",s.High="high",s.Medium="medium",s.Low="low",s))(Tu||{}),Ld=(r=>(r.Suspected="suspected",r.Latent="latent",r.Refuted="refuted",r))(Ld||{}),I0=(r=>(r.Skyramp="skyramp",r.External="external",r.Unknown="unknown",r))(I0||{}),B0=(s=>(s.Cascade="cascade",s.Restrict="restrict",s.Orphan="orphan",s.Unknown="unknown",s))(B0||{}),Va=(s=>(s.RequirementReference="requirement-reference",s.Spec="spec",s.PrDescription="pr-description",s.CouldBreak="could-break",s))(Va||{}),Fe=u.string().trim().min(1),Ga=Fe.describe("file:line"),C0=t=>Fe.refine(e=>e.length<=400,e=>({message:`is ${e.length} characters, over the 400 cap \u2014 ${t}`})),Du=Fe.optional().describe('multi-repo only: the OTHER checkout this lives in \u2014 its "owner/repo" slug, or the directory name if the run discovered it; omit for the working checkout'),vy=u.object({method:Fe,path:Fe,service:u.string().optional(),evidence:Ga,repository:Du}),Hj=u.object({id:Fe.describe("short-slug, e.g. R9"),statement:Fe.max(400,"exceeds 400 characters \u2014 state the requirement, do not paste the spec section").describe("a testable obligation, not a summary"),source:u.nativeEnum(Va).describe("spec outranks pr-description when both state it"),evidence:Fe.describe("spec: file:line or a section locator. pr-description: the quoted phrase it comes from.")}),Yj=u.object({id:Fe.describe("short-slug"),statement:Fe.max(400,"exceeds 400 characters \u2014 state the behaviour, do not paste the code").describe("what the change makes true"),surface:Fe.describe("METHOD /path, or a component/page name"),evidence:Fe.describe("file:line from the diff that introduces it"),repository:Du,satisfies:u.array(Fe).optional().describe("requirement ids (from `requirements`) this behaviour correctly implements \u2014 a requirement met only in part is ALSO named by the finding that shows the rest (conflictsWith)")}),qj=u.object({id:Fe.describe("short-slug"),file:Fe,line:u.number().optional(),claim:C0("shorten it to the one sentence that states the defect, and move the supporting detail into `evidence`"),severity:u.nativeEnum(Tu),evidence:C0("cite the file:line and the one line that shows it, rather than reproducing the surrounding code").describe("quoted diff/code line"),status:u.nativeEnum(Ld),repository:Du,conflictsWith:u.array(Fe).optional().describe("requirement ids (from `requirements`) this defect contradicts or leaves unimplemented \u2014 a lower-precedence source (the diff, or the PR description) lost")}),jj=u.object({name:Fe,language:u.string().optional(),framework:u.string().optional(),evidence:Ga,repository:Du}),Jj=u.object({dir:Fe,framework:u.string().optional(),kind:u.nativeEnum(I0),evidence:Ga,repository:Du}),Wj=u.object({from:Fe,to:Fe,onDelete:u.nativeEnum(B0),evidence:Ga}),zj=u.object({entity:Fe,field:Fe,values:u.array(u.string()),evidence:Ga}),Kj=u.object({entities:u.array(u.object({name:Fe,evidence:Ga})),references:u.array(Wj).describe("INBOUND references \u2014 what still points at an entity when it is deleted"),stateFields:u.array(zj)}),gX=u.object({schemaVersion:u.literal(1),repository:u.object({path:Fe.describe("absolute repo path"),currentBranch:Fe,baseBranch:Fe}),project:u.object({type:u.nativeEnum(Ry),primaryLanguage:Fe,languages:u.array(u.string()),frameworks:u.array(u.string())}),services:u.array(jj),infrastructure:u.object({containerized:u.boolean(),hasDockerCompose:u.boolean(),composeFiles:u.array(u.string()),hasCiCd:u.boolean()}),diff:u.object({changedFiles:u.array(u.string()).describe("as git reports them; a file in another checkout may carry that repo's name"),nonApplicationOnly:u.boolean(),summary:Fe.describe("\u2264400 chars")}),endpoints:u.object({new:u.array(vy),modified:u.array(vy),removed:u.array(vy)}),existingTests:u.object({locations:u.array(Jj)}),entityMap:Kj,requirements:u.array(Hj).describe("from a spec (attached or linked) and/or the PR description; empty when neither states a testable obligation"),behaviors:u.array(Yj),findings:u.array(qj),unexamined:u.array(u.string()).describe("files or areas outside this change you did not open"),summary:Fe.describe("one paragraph on what this change does and its test-relevant risk")});var Pd=(n=>(n.Skyramp="skyramp",n.Llm="llm",n))(Pd||{}),ss=u.string().trim().min(1),Zj=u.object({case:ss.describe("recommend id this assertion enforces"),evidence:ss.describe("the exact assertion line from the file that checks that case's observable")}),xy=u.object({kind:u.nativeEnum(Id).describe("seed: data the test creates in the app; runtime_mock: a mock on a Skyramp worker, which other tests reach too; env_override: an env value the app runs with. A stub inside the test's own process, such as a browser page's route, is none of these"),target:ss.describe("the dependency, endpoint or data it affects"),mechanism:u.nativeEnum(Bd).describe("test_code: the test applies and undoes it; skyramp_mocker: a mock the test applies on a Skyramp worker; recipe_override: the mocker cannot reach the dependency (its URL is fixed in the build)"),detail:ss.describe("what it sets up"),worker:ss.optional().describe("skyramp_mocker: host:port of the worker the test applies the mock to (default localhost:35142)"),cleanup:ss.optional().describe("seed: a command, without a shell, that removes the data when the test does not")}),Xj=u.object({file:ss.describe("staged path under .skyramp/staged/"),source:u.nativeEnum(Pd),language:ss,covers:u.array(u.string()).min(1,"must be a non-empty array of recommend ids").describe("recommend ids this test covers"),assertions:u.array(Zj).min(1,"must be a non-empty array").describe("one per case covered, citing the real line"),context:u.array(xy).optional().describe("what the test sets up against the running app, in order: data it seeds, Skyramp mocks it applies, env overrides; omit when none")}),Ty=u.object({schemaVersion:u.literal(1),tests:u.array(Xj),deferredUi:u.array(u.string()).describe("recommend ui ids left for the UI stage (generate) \u2014 [] for generate-ui"),summary:ss.describe("one paragraph")});var is=u.string().trim().min(1),Nu=72,eJ=u.object({repository:is.optional().describe("owner/repo of the checkout this lint ran in, when the run has several; omit for the working checkout"),tool:u.string(),command:u.string().describe("the exact command you ran, scoped to the changed files"),clean:u.boolean(),fixed:u.array(u.string()).optional().describe("files you fixed"),uncovered:u.array(u.string()).describe("changed/new files this linter's own config does not match (wrong extension, wrong directory) \u2014 so `clean` never examined them, even though CI may still execute them. Empty array, not omitted, when every changed/new file IS covered.")}),bX=u.object({schemaVersion:u.literal(1),lint:u.array(eJ).min(1).describe("one entry per checkout this run wrote tests in, each run from that checkout"),fileConventions:u.object({ok:u.boolean(),notes:u.string().optional()}),ciReadiness:u.object({covered:u.boolean().describe("will the repo's CI run these tests?"),notes:u.string().optional()}),dependencies:u.object({added:u.array(u.object({package:u.string(),manifest:u.string(),repository:is.optional().describe("owner/repo of the manifest's checkout; omit for the working checkout"),reason:is.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).describe("every package added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own")}),support:u.array(u.object({file:is,repository:is.optional().describe("owner/repo of the file's checkout; omit for the working checkout")})).optional().describe("the files the tests need besides themselves (helper modules, page objects, fixtures, snapshots), delivered with them"),commit:u.object({message:is.refine(t=>t.split(`
119
+ `)[0].length<=Nu,{message:`subject line must be <= ${Nu} chars`})}),pr:u.object({title:is.max(Nu,`must be <= ${Nu} chars`),body:is}),ready:u.boolean().describe("a statement of fact: true only if the tests are fit to commit as they stand"),blockers:u.array(u.string()).describe("what blocks the commit \u2014 required non-empty when ready is false"),summary:is.describe("one paragraph")});var qs=Re(require("fs")),qa=Re(require("path")),v0=require("child_process");var Zn="{junit}",Q0=(r=>(r.Junit="junit",r.Trx="trx",r.GoTestJson="go-test-json",r))(Q0||{}),b0=(e=>(e.Minitest="minitest",e))(b0||{}),w0=u.string().trim().min(1),Ha=u.object({cwd:w0.describe('repo-relative directory the command starts in ("." for the root)'),argv:u.array(w0).min(1).describe(`the command as separate arguments, run without a shell; for a junit or trx report an argument or env value holds ${Zn}, where the report is written (not for Maven or Gradle, whose build writes its own)`),env:u.record(u.string(),u.string()).optional().describe("plain test or reporter settings beyond the repository's CI test job (RAILS_ENV=test, PLAYWRIGHT_JUNIT_OUTPUT_FILE={junit}); never a credential, PATH, or a tool's install path"),report:u.object({format:u.nativeEnum(Q0).describe(`junit (JUnit XML to ${Zn}), trx (to ${Zn}), or go-test-json (go test -json on the command's output)`),reporter:u.nativeEnum(b0).optional().describe("a reporter Testbot loads for a runner that writes no report: minitest")}).optional().describe("the report the command writes; junit when omitted")});var Ya="a framework other than pytest, jest, vitest and node --test (go test, rails test, mvn, dotnet test), or one the repository's test script runs through another command (ng test, nx test)",RX=`pytest, Jest, Vitest and node --test tests run as the run already knows them, unless the repository's test script runs them through another command (ng test, nx test), which may be the only one that compiles them. A test in any other framework, or one run that way, also gives "run": the repository's own command for only those tests, from the directory the repository runs it in, as separate arguments without a shell. Its "report" says what the runner writes: junit (JUnit XML to ${Zn} in the reporter's argument or env setting), trx (a TRX file to ${Zn}, which every dotnet test writes with its built-in logger), or go-test-json (go test -json, read from the command's output). A Maven or Gradle command names no ${Zn}: its build writes JUnit XML to its own report directory, which the run reads. Use a reporter the repository already has, or one of those; a reporter or converter the command fetches is the version the repository pins, or else its latest release (an older one may not build with the repository's toolchain). For minitest, which writes none, give report.reporter "minitest" and the run fills ${Zn} itself. A setting the tests or reporter read goes in "env" (RAILS_ENV=test, or PLAYWRIGHT_JUNIT_OUTPUT_FILE=${Zn} with playwright test --reporter=junit): the run sets it, so never wrap the command in a shell to set one. The run replaces ${Zn} in argv and env with its report path, executes the command, and reads that report.`;var ho=(s=>(s.ExistingEvidenceSufficient="existing_evidence_sufficient",s.TargetedUnit="targeted_unit",s.RuntimeRequired="runtime_required",s.BlockedPreflight="blocked_preflight",s))(ho||{}),Ys=(i=>(i.ExistingEvidence="existing_evidence",i.Unaffected="unaffected",i.ExistingUnit="existing_unit",i.NewUnit="new_unit",i.Runtime="runtime",i))(Ys||{}),Ny=(n=>(n.Repository="repository",n.Testbot="testbot",n))(Ny||{}),Fy=(r=>(r.Identified="identified",r.Passed="passed",r.Failed="failed",r))(Fy||{}),Kt=u.string().trim().min(1),tJ=u.string().regex(/^[a-z0-9][a-z0-9-]*$/,"must be a short lowercase slug").describe("short-slug");var nJ=u.object({id:tJ,source:u.nativeEnum(Ny),kind:u.nativeEnum(_s),outcome:u.nativeEnum(Fy),summary:Kt.max(400).describe("one line: what it shows"),tests:u.array(Kt).optional().describe("source repository: the existing tests, as repo-relative paths, optionally path::test-name"),repository:Kt.optional().describe("source repository: owner/repo the tests live in, when the run has several checkouts; omit for the working checkout"),command:Kt.optional().describe("source testbot: the exact command you ran, as you ran it"),run:Ha.optional().describe(`source repository, for tests in ${Ya}: how the run executes only these tests, all of them in one command, with the repository's own runner writing JUnit XML to {junit}. Name each test (path::test-name): a test is credited to a file only by its name or by a report that names the file`)}),rJ=u.object({behaviorId:Kt.describe("an id from analyze's behaviors"),mechanism:u.nativeEnum(Ys),evidenceIds:u.array(Kt).default([]).describe("existing_evidence: the ci-<n> or evidence ids that establish it; existing_unit: the evidence id naming the tests to run"),covers:u.string().trim().optional().describe('new_unit / runtime: the missing evidence this obtains, e.g. "the boundary the change moved"; unaffected: why the change cannot reach it, citing path:line')}),sJ=u.object({behaviorId:u.string().trim().optional().describe("an id from analyze's behaviors, when it is about one"),missing:Kt.max(600).describe("the evidence that is required and cannot be obtained in this run")}),iJ=u.object({file:Kt.describe("the changed file the failure is in"),repository:Kt.optional().describe("owner/repo the file is in, when the run has several checkouts; omit for the working checkout"),reason:Kt.max(300).describe("what prerequisite the change fails"),evidence:Kt.max(400).describe("the error line, quoted")}),oJ=u.object({behaviorId:Kt.describe("an id from analyze's behaviors"),reason:Kt.max(600).describe("\u2264600 characters: why this change leaves the behavior's result as it was, citing the unchanged line that decides it (path:line)")}),Fu=u.object({schemaVersion:u.literal(1),decision:u.nativeEnum(ho),evidence:u.array(nJ).describe("evidence this session found or produced; CI results are the ci-<n> items and are not restated here"),plan:u.array(rJ).describe("how each changed behavior's evidence is obtained"),gaps:u.array(sJ),outOfScope:u.array(oJ).optional().describe("behaviors analyze found that this change neither changes nor states"),blocked:iJ.optional().describe("only for blocked_preflight"),rationale:Kt.max(1200).describe("\u22641200 characters: why this evidence is enough, or what it still lacks \u2014 the scope you chose and why")});function $d(t){let e=bn(t,"recommend.json");if(!e||!Array.isArray(e.generate)||!Array.isArray(e.maintenance))return;let n=e;return{...n,maintenance:n.maintenance.map(({repository:r,...s})=>({...s,test:s.test.trim().replace(/^\.\//,""),...r?.trim()?{repository:r.trim()}:{}}))}}function AJ(t){return ts(Ty,t).errors}function lJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=AJ(n);return s.length>0?{errors:s}:{generate:n,errors:[]}}function Vd(t,e=[]){return lJ(t.stdout,e)}function dJ(t){return t.generate.filter(e=>e.type!=="ui").map(e=>e.id)}function R0(t){return t.generate.filter(e=>e.type==="ui").map(e=>e.id)}var Gd={backend:{stage:"generate",cases:dJ,noRecommendCoverage:"recommend.json missing or malformed \u2014 cannot check coverage",noRecommendIntent:"recommend.json missing or malformed \u2014 cannot check intent",uncovered:t=>`recommend case "${t}" is not covered by any generated test`,unknownCovered:t=>`test covers unknown recommend id "${t}"`,unasserted:t=>`case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:h0,codegenHint:"These tests were hand-written. Skyramp codegen (skyramp_contract_test_generation / skyramp_integration_test_generation) was available but not used \u2014 it computes valid sample data and response correlations. Prefer scaffolding with it and then refining, especially for the failures above."},ui:{stage:"generate-ui",cases:R0,noRecommendCoverage:"recommend.json not found \u2014 cannot check UI coverage",noRecommendIntent:"recommend.json not found \u2014 cannot check UI intent",uncovered:t=>`UI case "${t}" is not covered by any generated UI test`,unknownCovered:t=>`test covers "${t}" which is not a recommend UI case`,unasserted:t=>`UI case "${t}" has no verified assertion enforcing its expected_observable`,usedCodegen:f0,codegenHint:"This UI test was hand-authored. Skyramp UI codegen (skyramp_ui_test_generation) was available but not used. Prefer scaffolding with it and then refining, especially for the failures above."}},u6=Us("generate-schema",(t,e)=>Vd(e,t.secretValues));function pJ(t){let e=Gd[t];return{name:`${e.stage}-coverage`,verify(n,r){let{generate:s,errors:i}=Vd(r,n.secretValues);if(!s)return Mt(this.name,i);let a=$d(n);if(!a)return Mt(this.name,[e.noRecommendCoverage]);let c=new Set(s.tests.flatMap(h=>h.covers)),A=[],l=e.cases(a);for(let h of l)c.has(h)||A.push(e.uncovered(h));let p=new Set(t==="ui"?l:a.generate.map(h=>h.id));for(let h of c)p.has(h)||A.push(e.unknownCovered(h));if(t==="backend"){let h=new Set(s.deferredUi),g=new Set(R0(a));for(let C of g)!h.has(C)&&!c.has(C)&&A.push(`UI case "${C}" is neither covered nor deferred to the UI stage`);for(let C of h)g.has(C)||A.push(`deferredUi lists "${C}" which is not a UI case`)}return A.length===0?{name:this.name,passed:!0}:Mt(this.name,A)}}}function hJ(t){let e=Gd[t];return{name:`${e.stage}-intent`,verify(n,r){let{generate:s,errors:i}=Vd(r,n.secretValues);if(!s)return Mt(this.name,i);let a=$d(n);if(!a)return Mt(this.name,[e.noRecommendIntent]);let{asserted:c,errors:A,badFiles:l}=IJ(s,n.inputs.repositoryPath),p=A.length;for(let g of e.cases(a))c.has(g)||A.push(e.unasserted(g));if(A.length===0)return{name:this.name,passed:!0};let h=Mt(this.name,A);return p>0&&p===A.length&&l.size>0?{...h,droppable:[...l]}:h}}}function fJ(t){let e=Gd[t];return n=>{if(!n.inputs.skyrampMcp?.command||t==="backend"&&!By(n))return;let r=qa.join(n.outputsDir,`${e.stage}-stream.ndjson`);if(!(!qs.existsSync(r)||e.usedCodegen(r)))return g0(r)?e.codegenHint:"Skyramp codegen tools were configured but the MCP server did not connect this session, so they were not available. Hand-authoring was the only option; this is an environment problem, not yours."}}var A6=pJ("backend"),l6=hJ("backend"),d6=fJ("backend");var k0=t=>t.replace(/\s+/g,"");var My={python:[/\bassert\s*[({\w"'`]/g,/\bpytest\.raises\s*\(/g,/\bself\.assert\w*\s*\(/g],typescript:[/\bexpect\s*\(/g,/\.should\b/g,/\bassert\s*[.(]/g],go:[/\bt\.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)\s*\(/g,/\b(assert|require)\.\w+\s*\(/g],java:[/\bassert\w*\s*\(/g,/\bassertThat\s*\(/g],ruby:[/\bexpect\s*[({]/g,/\bassert\w*\b/g,/\.should\b/g]};for(let[t,e]of[["javascript","typescript"],["kotlin","java"]])My[t]=My[e];function gJ(t,e){if(t.includes(Iu(e))||k0(t).includes(k0(e)))return!0;let n=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!/^(\/\/|#|\*|\/\*)/.test(r));return n.length>0&&n.every(r=>t.includes(Iu(r)))?!0:CJ(t,e)}var mJ=/\bassert\w*\b|\bexpect\s*\(|\.should\b|\brequire\s*\(/i,yJ=12,EJ=/,\s*\(\s*#|,\s*f?["'`]|\s+#\s|\s+\/\/|\s*\((?:line|lines|at line)\b|\s*,\s*$/i;function CJ(t,e){let n=e.split(/\s*;\s*|\s*\.\.\.\s*|\r?\n/),r=0;for(let s of n){let i=mJ.exec(s);if(!i)continue;let a=s.slice(i.index),c=EJ.exec(a);if(c&&(a=a.slice(0,c.index)),a=Iu(a).replace(/[,\s]+$/,""),a.length<yJ||!t.includes(a))return!1;r++}return r>0}function IJ(t,e){let n=new Set,r=[],s=new Set;for(let i of t.tests){let a=qa.resolve(e,i.file);if(!qs.existsSync(a))continue;let c=Iu(qs.readFileSync(a,"utf-8"));for(let A of i.assertions??[]){if(!gJ(c,A.evidence)){r.push(`assertion evidence for "${A.case}" not found in ${i.file} \u2014 cite the real assertion line`),s.add(i.file);continue}i.covers.includes(A.case)?n.add(A.case):(r.push(`assertion cites case "${A.case}" not in that test's covers[]`),s.add(i.file))}}return{asserted:n,errors:r,badFiles:s}}var BJ=/\.(spec|test)\.[cm]?[jt]sx?$/i;function x0(t){let e;try{e=(0,v0.execFileSync)("git",[...Dd,"status","--porcelain","--untracked-files=all"],{env:zn(),cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return}let n=s=>/_scaffold/i.test(s)||Sd.test(s),r=[];for(let s of e.split(`
120
+ `)){if(!s.trim()||s.length>1&&s[1]==="D")continue;let i=s.slice(3).trim(),a=i.indexOf(" -> ");if(a!==-1&&(i=i.slice(a+4).trim()),i=i.replace(/^"|"$/g,""),!i)continue;let c=i.replace(/^\.\//,"");c.startsWith(".skyramp/")||!n(c)||r.push(c)}return r}function wJ(t){let e=Gd[t],n=t==="ui";return{name:`${e.stage}-no-litter`,verify(r){let s=x0(r.inputs.repositoryPath);if(s===void 0)return{name:this.name,passed:!0};let i=s.filter(a=>BJ.test(a)===n);return i.length===0?{name:this.name,passed:!0}:Mt(this.name,[`${e.stage} left files outside .skyramp/ \u2014 move the staged test into .skyramp/staged/ and delete any codegen draft (e.g. *_scaffold.*): ${i.slice(0,6).join(", ")}`])}}}var p6=wJ("backend");var Mu=Re(require("fs")),fo=Re(require("path"));function N0(t){return ts(wy,t).errors}function SJ(t,e=[]){let{value:n,error:r}=jt(t,e);if(r)return{errors:[r]};let s=N0(n);return s.length>0?{errors:s}:{adapt:n,errors:[]}}var kJ="adapt-scratch",T0=`${kJ}/adapt-result.json`;function F0(t,e){let n=fo.join(t.outputsDir,T0),r;try{r=Mu.readFileSync(n,"utf-8")}catch{r=void 0}if(r!==void 0&&(t.secretValues??[]).some(a=>r.includes(a)))return{errors:[`${T0} contains a secret value (token / credential) \u2014 never write it anywhere`]};let s=SJ(e.stdout,t.secretValues);if(s.adapt)return s;let i=r!==void 0?va(n):void 0;return i!==void 0&&N0(i).length===0?{adapt:i,errors:[]}:s}var _6=Us("adapt-schema",F0);var Y6=2*1024*1024;var le=u.string().trim().min(1),RJ=t=>{if(!t||typeof t!="object")return t;let e=t;return typeof e.skip=="string"&&e.skip.trim()&&(e.expected===void 0||e.expected===null)?{...e,expected:"(not tested)"}:t},xJ=u.preprocess(RJ,u.object({id:le.describe(`its requirement's id plus a letter, e.g. "R1a", "AC-3a"`),clause:le.describe("one testable part of the requirement"),expected:le.describe("the outcome the requirement calls for \u2014 taken from the requirement, never from what the code does"),skip:u.string().optional().describe("only when no test can check this clause here: why"),type:u.nativeEnum(Gs).optional().describe("the test that checks this clause: contract / integration (the API, or code called directly in-process: a function, hook or module) or ui (a page)"),target:u.string().optional().describe('its "METHOD /path", or the page / flow'),steps:u.string().optional().describe("what that test does; its expected outcome is this clause's"),finding:u.string().optional().describe("the finding id, when this clause's test also catches that defect (the defect still gets a case of its own)"),code:u.string().optional().describe("path:line of the code that decides this clause, when there is one"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes"),browserOnly:u.boolean().optional().describe("true when its behaviour happens only in a browser: real clicks or keys driving page script, client-side sorting or filtering, script-driven DOM updates, focus, drag-and-drop, navigation, rendering that depends on CSS or JavaScript"),browserHarness:u.string().optional().describe("browserOnly, off the runtime path: the path of the repo's in-process browser suite its test goes in (e.g. a Django StaticLiveServerTestCase test that drives Selenium)")})),TJ=u.object({id:le.describe('the label its source gives it ("AC-3", "REQ-12"; item 4 of a numbered list is "R4"), else "R1", "R2"\u2026 in order'),statement:le,source:u.nativeEnum(Va).describe("requirement-reference (an item the run was given), spec, pr-description (also for what the change is evidently meant to do when nothing is written down), or could-break (what the change could break that no requirement mentions)"),reference:u.string().optional().describe('requirement-reference only: the key of its item as listed, e.g. "PAY-184", or a Confluence page id such as "3021"'),evidence:le.describe("where it is stated: for requirement-reference, the item's own words, copied exactly; else file:line, a doc section, or the quoted phrase"),criterion:u.number().int().positive().optional().describe("requirement-reference only: leave it out; Testbot numbers each criterion by the item's own label (AC2, 2.), else after the item's labels"),notInChange:u.string().optional().describe("requirement-reference only: when the change does not touch this criterion at all (e.g. a later step of a staged rollout), why; give it no clauses"),overrules:u.array(u.object({spec:u.string().optional().describe("file:line of the spec in the repository; leave it out for a PR description"),prDescription:u.boolean().optional().describe("true when a pull request description says otherwise"),says:le.describe("what the spec or the PR description says there, in its own words, copied exactly")}).refine(t=>!!(t.prDescription||t.spec?.trim()),{message:'names no source: give "spec" its file:line, or set "prDescription"'})).optional().describe("requirement-reference only: each spec in the repository, and each PR description, that says otherwise; the item wins, so test what it says"),clauses:u.array(xJ)}),M0=(s=>(s.ServerError="server-error",s.DataLost="data-lost",s.FinalState="final-state",s.DerivedValues="derived-values",s))(M0||{}),DJ=u.object({id:le.describe('e.g. "F1"'),file:le,line:u.number().optional(),claim:le.describe("the defect, in one sentence"),severity:u.nativeEnum(Tu),evidence:le.describe("the code line, or the probe request and response, that shows it"),conflictsWith:u.array(le).optional().describe("requirement or clause ids it violates"),keeps:u.string().optional().describe("for a defect no requirement or clause states: path:line of the code beside the change that keeps the rule it breaks"),rule:u.nativeEnum(M0).optional().describe("for a defect that breaks a rule every app keeps, which nothing needs to state: which one"),existing:u.string().optional().describe("only when the base already does this, in code the change left as it was: where the base does it (its file:line); such a defect gets no case"),needsApp:u.enum(["browser","live-api"]).optional().describe("only when the running app alone can show this defect and the repo has no in-process test that can: browser (page script, what the user sees after a click or a save) or live-api (code the repo tests only against the running app's API)")}),NJ=u.object({id:le.describe('e.g. "Q1"'),question:le.describe("what is unsettled, as a question the PR author can answer"),readings:u.array(le).min(2).describe("each reasonable behaviour, with what points to it (file:line, or the words that suggest it)"),about:u.string().optional().describe("the requirement or clause id it is about, when there is one")}),FJ=u.object({id:le.describe('unique, a short kebab-case name for what the case checks, e.g. "ship-twice-409"'),type:u.nativeEnum(Gs).describe("contract / integration: checks the API, or calls code directly in-process (a function, hook or module); ui: checks what a user sees or does on a page"),target:le.describe('"METHOD /path", or the page / flow'),clause:u.string().optional().describe("the clause id this case checks"),finding:u.string().optional().describe("the finding id this case catches"),steps:le.describe("what the test does"),expected:le.describe("the expected outcome, from the clause"),mutates:u.boolean().optional().describe("true when its test changes state, in the test or its setup: an API POST, PUT, PATCH or DELETE, or a UI flow that submits, creates, edits or deletes")}),MJ=u.object({test:le.describe("existing test file"),action:u.nativeEnum(uo),reason:le,mutates:u.boolean().optional().describe("true when the maintained test changes state"),clauses:u.array(le).optional().describe("the clause ids this test checks")}),_J=u.object({outcome:u.nativeEnum(ns).describe("clean | recipe-drift (you had to fix the recipe) | change-broke-bringup (this PR broke start-up) | bringup-failed (the environment, not the PR)"),baseUrls:u.record(u.string()).optional().describe("service \u2192 base URL of the running app"),health:u.object({url:u.string().optional(),command:u.string().optional(),output:u.string().optional()}).optional().describe("the check that shows the app serves real data, and what it returned"),teardown:u.string().optional().describe("command that stops the app"),dependencies:u.record(u.boolean()).optional().describe("every backing service: true = really running, false = mocked"),recipeFixes:u.array(u.string()).optional().describe("what you changed in the recipe"),error:u.string().optional().describe("when it did not come up: the failing command and what it printed"),suspectFiles:u.array(u.string()).optional().describe("change-broke-bringup: the changed files to blame"),login:u.object({username:le,password:u.string()}).optional().describe("the account the tests sign in as, when they sign in: each a literal value the recipe seeds, or $VARIABLE when a secret in the environment holds it"),revisions:py.optional()}),B7=u.object({schemaVersion:u.literal(1),requirements:u.array(TJ),findings:u.array(DJ),cases:u.array(FJ).describe("a second test for a clause, and one case per finding that fails on this branch"),questions:u.array(NJ).optional().describe("behaviours the change leaves unsettled; no case asserts any of them"),maintenance:u.array(MJ),journeys:u.array(E0).optional().describe("the user journeys that, together, pass through everything the change alters that a user sees or does; empty when it alters nothing a user sees"),notInJourney:u.array(u.object({clause:le,why:le})).optional().describe("a clause a user sees or does that no journey can reach through the UI, and why"),triage:Fu.optional().describe("the validation triage decision, made before the app is started; its behaviorIds are clause ids"),app:_J.optional().describe("omit when no app was needed or none was started"),summary:le.describe("one paragraph: what the change does and where the risk is")});var _0=(n=>(n.Backend="backend",n.Ui="ui",n))(_0||{});var _y=(s=>(s.Added="added",s.Updated="updated",s.Deleted="deleted",s.Unchanged="unchanged",s))(_y||{}),UJ=u.object({file:le.describe("repo-relative path; in another repo of the change, that repo's directory name then its path"),kind:u.nativeEnum(_0),change:u.nativeEnum(_y).describe("added: a file you created; updated / deleted / unchanged: an existing test"),covers:u.array(u.string()).describe("the plan case ids this file tests"),defect:u.boolean().optional().describe("true when a case of it fails because the app is wrong and the test is right \u2014 kept failing on purpose"),staleBecause:u.object({requirement:le.describe("the requirement or clause id the change deliberately alters"),line:le.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),result:u.object({exit:u.number().nullable().describe("exit code of your last run of this file; null if it could not be run"),cases:u.array(u.object({case:le,status:u.nativeEnum(Kn),defect:u.boolean().optional().describe("for a failing case: true when the app is wrong and the test is right; false when the test is at fault and you could not fix it"),failure:u.string().optional().describe("for a failing case: the runner's failure for it as printed (the error and the line it was raised at), not a summary"),cause:u.string().optional().describe("for a case you keep as a defect: path:line of the application code that makes it fail"),requires:u.string().optional().describe("for a case you keep as a defect: the words of the PR description, a requirement or clause of the plan, or the code a finding's keeps names, that state what its failing check expects, quoted exactly")})).describe("one entry per covered case, from the runner's own output"),details:u.string().optional().describe("what failed and why, or why it was not run")}),assertions:u.array(u.object({case:le,evidence:le})).optional().describe("per covered case, the assertion line that checks its expected outcome"),functions:u.array(u.object({name:le.describe("the test function as the runner names it within its file, without the file (test_x, TestClass::test_x, TestSuite/TestCase)"),cases:u.array(le).describe("the plan case ids it checks")})).optional().describe("for a file you added or updated: each test function in it and the plan case ids it checks"),skyramp:u.object({draft:u.union([u.string(),u.array(u.string())]).optional().describe("the draft path the Skyramp helper returned for this test, or each path when the test was made from several drafts"),handWritten:u.string().optional().describe("why it is written by hand: the helper call you made and what it returned")}).optional().describe("only for a test of a case the Skyramp API block lists: where it came from"),context:u.array(xy).optional().describe("what the test sets up outside its own process that another test could run into: data it creates in the app, a Skyramp mock, an env override; omit when none"),isolatedRun:le.optional().describe("for a test with a context: the command, from its checkout's root and without a shell, that runs only this file"),run:Ha.optional().describe(`for a file in ${Ya}, added, updated or re-run: how the run executes only this file's tests, with the repository's own runner and the report it writes (junit or trx to ${Zn}, or go-test-json); Testbot runs it before write ends and re-runs the tests with it`)}),LJ=u.object({description:le.describe("what is wrong and how to reproduce it: endpoint or page, input, what you got vs what was expected"),severity:u.nativeEnum(Tu).optional(),sourceFile:u.string().optional().describe("the app file at fault"),sourceLine:u.number().optional(),test:u.string().optional().describe("the test file that shows it"),finding:u.string().optional().describe("the plan's finding id, when it is one"),requirements:u.array(le).optional().describe("the plan's requirement or clause ids it violates")}),w7=u.object({schemaVersion:u.literal(1),tests:u.array(UJ),notWritten:u.array(u.object({case:le,reason:le})).describe("every plan case no test covers, and why"),journeys:u.array(Ud).optional().describe("one entry per planned user journey: the browser test that walks it end to end"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repo has one: the exact command, with its file paths (Testbot re-runs it)"),dependenciesAdded:u.array(u.object({package:le,manifest:le.describe("the manifest file's path relative to its checkout (e.g. package.json, pom.xml or pyproject.toml), and nothing else; name another checkout in repository"),repository:le.optional().describe("owner/repo of the manifest's checkout; omit for the repo under test"),reason:le.optional().describe("why the test must run inside the application's own test environment, so its manifest had to change \u2014 required for every entry")})).optional().describe("every package you added to an APPLICATION manifest (an exception, surfaced in the report); never the Testbot test package's own"),supportFiles:u.array(le).optional().describe("every file that is not a test you created or changed for your tests, which they need to compile or run (a helper module, page object, fixture, or a snapshot the runner wrote for them), named as you name a test; Testbot delivers only the tests you list and the files under supportFiles"),ciRunsTests:u.boolean().optional().describe("will the repo's CI pick these tests up as they are?"),ciNotes:u.string().optional().describe("when ciRunsTests is false: which of your tests the repo's CI will not collect, why, and the exact change the author must make for CI to run them"),commit:u.object({message:le.describe('"Skyramp Testbot: \u2026", subject line at most 72 characters'),prTitle:le.describe("at most 72 characters"),prBody:le.describe("what the tests cover and what they found")}),report:u.object({summary:le.describe("1-2 sentences for the PR author: does the change do what it says?"),issues:u.array(LJ).describe("every defect the tests found"),nextSteps:u.array(u.string())})});var Q7={added:"place",updated:"update",deleted:"delete",unchanged:"verify"};var L0=(r=>(r.Requirement="requirement",r.PrDescription="pr_description",r.Code="code",r))(L0||{}),yt=u.string().trim().min(1),PJ=u.object({expectation:yt.max(300).describe("the behavior this assertion pins, in words"),source:u.nativeEnum(L0),expected:yt.max(200).describe("the exact value or outcome asserted, as the test asserts it")}),OJ=u.object({file:yt.describe("path of the NEW test file you wrote, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),framework:yt.describe("the framework the repository runs this file with: pytest, jest, vitest, node-test, or the name of any other"),run:Ha.optional().describe(`for ${Ya}: how the run executes only the tests in names, with the repository's own runner writing JUnit XML to {junit}`),covers:u.array(yt).length(1).describe("the ONE behavior id, or defect id, from the plan that the tests in names provide evidence for; a file covering several is listed once per id"),names:u.array(yt).min(1).describe("the test functions/cases in the file that provide evidence for that behavior, as the framework names them"),assertions:u.array(PJ).min(1)}),Uy=(n=>(n.Updated="updated",n.Deleted="deleted",n))(Uy||{}),U0=300,$J=u.object({file:yt.describe("path of the EXISTING test file you updated or deleted, relative to its repository"),repository:yt.optional().describe("owner/repo the file lives in, when the run has several checkouts; omit for the working checkout"),change:u.nativeEnum(Uy),staleBecause:u.object({requirement:yt.describe("the requirement or clause id the change deliberately alters"),line:yt.describe("path:line (or path) of the application code the change altered that makes this test's old expectation wrong")}).optional().describe("for an existing test you updated: why it is out of date"),reason:u.preprocess(t=>typeof t=="string"?t.trim().slice(0,U0):t,yt.max(U0)).describe("what the change deliberately altered that made the test wrong")}),Ly=u.object({schemaVersion:u.literal(1),tests:u.array(OJ),maintained:u.array($J).optional().describe("existing tests the change made stale that you updated or deleted; omit when there were none"),defectsNotTested:u.array(u.object({id:yt,reason:yt.max(300)})).optional().describe("defects the plan found that no in-process test can reach, each with why; omit when every defect has a test"),journeys:u.array(Ud).optional().describe("one entry per planned user journey: the in-process test that walks it end to end"),journeysNotWritten:u.array(u.object({journey:yt,missing:yt.transform(t=>t.length>300?`${t.slice(0,299)}\u2026`:t)})).optional().describe("a planned journey no in-process test can walk here, with what it needs that is missing; it is reported as not covered"),lint:u.object({command:u.string(),clean:u.boolean()}).optional().describe("the linter/formatter you ran on your test files, if the repository has one you can run; omit otherwise"),commitMessage:yt.optional().describe("the commit message for your tests: a subject line of at most 72 characters, then what they cover")});var Y7=5*6e4;function HJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=ts(Ly,e);return s.length?{errors:s}:{output:r,errors:[]}}function YJ(t){return HJ(t.stdout)}var Wee=Us("generate-unit-schema",(t,e)=>YJ(e));var Hd=String.raw`(?:node:)?(?:http|https|http2|net|tls|dgram)`,zee=[[/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/,"a local server address"],[/^\s*(import|from)\s+(requests|aiohttp|urllib3|websockets?)\b/m,"an HTTP client"],[/^\s*(?:import|from)\s+(?:urllib\.request|http\.client|http\.server|socket|ssl|ftplib|smtplib|telnetlib)\b|^\s*from\s+urllib\s+import\b[^\n]*\brequest\b|\burlopen\s*\(/m,"a standard-library network client"],[/\bfrom\s+["'](axios|node-fetch|undici|ws)["']|require\(\s*["'](axios|node-fetch|undici|ws)["']\s*\)/,"an HTTP client"],[new RegExp(String.raw`\bfrom\s+["']${Hd}["']|\bimport\s+["']${Hd}["']|require\(\s*["']${Hd}["']\s*\)|\bimport\(\s*["']${Hd}["']\s*\)`),"Node's network modules"],[/\bfetch\s*\(|\bnew\s+(XMLHttpRequest|WebSocket)\b/,"a network call (fetch, XMLHttpRequest, WebSocket)"],[/\bskyramp\b/i,"the Skyramp runtime (a runtime mock or client)"]];var O0=String.raw`\b(?:real browser|browser|javascript|js|htmx|client-side)\b`,$0=String.raw`\b(?:not|isn't|aren't|never|no)\s+(?:be\s+)?(?:covered|tested|exercised|verified|checked|walked|executed|run)\b|\buncovered\b|\bunverified\b`,lte=[new RegExp(`${O0}[^.;\\n]{0,100}(?:${$0})`,"i"),new RegExp(`(?:${$0})[^.;\\n]{0,100}${O0}`,"i")];var dte=new Set(["targeted_unit","existing_evidence_sufficient"]);var Xte=new Set(["existing_evidence","unaffected","existing_unit","new_unit","runtime"]),ene={existing_evidence:"existing evidence",unaffected:"showing the change cannot reach it",existing_unit:"running the existing unit tests",new_unit:"a new unit test",runtime:"tests against the running application"};function zJ(t){let{value:e,error:n}=jt(t);if(n)return{errors:[n]};let{value:r,errors:s}=ts(Fu,e);return s.length?{errors:s}:{triage:r,errors:[]}}function KJ(t){return zJ(t.stdout)}var tne=Us("triage-schema",(t,e)=>KJ(e));var nne=new Set(["deploy","recommend","generate","generate-ui","adapt","generate-unit","native-run","finalize","deliver"]);Dt();Dt();var XJ="Skyramp-Pull-Request",eW="Skyramp-Delivery-Base",tW="Skyramp-Tested-Revision";var Ine=["%H","%P","%an","%ae","%ce",`%(trailers:key=${XJ},valueonly,separator=%x2C)`,"%s",`%(trailers:key=${eW},valueonly,separator=%x2C)`,`%(trailers:key=${tW},valueonly,separator=%x2C)`];var qd=(n=>(n.GitHub="github",n.AzureDevOps="azure-devops",n))(qd||{}),$y=(i=>(i.Trigger="TRIGGER",i.Baseline="BASELINE",i.AuthoritativeRelatedChange="AUTHORITATIVE_RELATED_CHANGE",i.ConfiguredSharedDependency="CONFIGURED_SHARED_DEPENDENCY",i.ManualOverride="MANUAL_OVERRIDE",i))($y||{}),Uu=(a=>(a.PullRequest="pull_request",a.ReadyForReview="ready_for_review",a.Schedule="schedule",a.Manual="manual",a.SutSetup="sut_setup",a.RevisionRead="revision_read",a))(Uu||{}),sW=["sut_setup"],iW=["sut_setup","schedule","revision_read"];var jd=(e=>(e.PullRequest="pull_request",e))(jd||{}),Lu=(s=>(s.ModelProvider="model_provider",s.SutAccess="sut_access",s.Skyramp="skyramp",s.Other="other",s))(Lu||{});var Jd=(i=>(i.ReportUploaded="report_uploaded",i.NoReport="no_report",i.Cancelled="cancelled",i.RecipeUploaded="recipe_uploaded",i.RevisionsUploaded="revisions_uploaded",i))(Jd||{}),X0=(n=>(n.Running="running",n.Ended="ended",n))(X0||{}),Wd=(p=>(p.TimedOut="timed_out",p.AgentFailed="agent_failed",p.SetupFailed="setup_failed",p.CredentialMissing="credential_missing",p.RunnerLost="runner_lost",p.CheckoutFailed="checkout_failed",p.EnvironmentUnverified="environment_unverified",p.ModelProviderDenied="model_provider_denied",p.ModelProviderUnavailable="model_provider_unavailable",p.RunnerProviderNotReady="runner_provider_not_ready",p))(Wd||{}),Vy=(r=>(r.Onboard="onboard",r.Deploy="deploy",r.Recheck="recheck",r))(Vy||{}),Gy=(n=>(n.Started="started",n.Finished="finished",n))(Gy||{}),Hy=(r=>(r.Passed="passed",r.Failed="failed",r.Skipped="skipped",r))(Hy||{});var Yy=(r=>(r.ChooseCredential="choose_credential",r.FreeText="free_text",r.ChooseSource="choose_source",r))(Yy||{});var zd=(r=>(r.Discover="discover",r.Start="start",r.Check="check",r))(zd||{}),Kd=(s=>(s.ValidationPlan="validation_plan",s.TestEnvironment="test_environment",s.TestConditions="test_conditions",s.Tests="tests",s))(Kd||{}),Pu=(s=>(s.Found="found",s.Starting="starting",s.Up="up",s.OutOfScope="out_of_scope",s))(Pu||{}),Xn=u.string().regex(/^[1-9][0-9]{0,18}$/),as=u.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Ja=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,_t=u.string().regex(Ja),Ut=u.string().regex(/^[0-9a-f]{64}$/),Yd=u.object({id:_t,revision:Xn}).strict(),Zd={provider:u.literal("github"),providerAccountId:Xn,providerRepositoryId:Xn},Xd={provider:u.literal("azure-devops"),providerAccountId:_t,providerRepositoryId:_t},er=u.discriminatedUnion("provider",[u.object(Zd).strict(),u.object(Xd).strict()]),qy=u.discriminatedUnion("provider",[u.object(Zd).passthrough(),u.object(Xd).passthrough()]),go=t=>`${t.provider}:${t.providerRepositoryId}`,V0={namespace:u.string().min(1),name:u.string().min(1)},eT=u.discriminatedUnion("provider",[u.object({...Zd,...V0}).strict(),u.object({...Xd,...V0}).strict()]),G0=u.object({ref:u.string().min(1),revision:as}).strict(),oW=u.object({repository:eT,revision:as,ref:u.string().nullable(),reason:u.nativeEnum($y),change:u.object({kind:u.nativeEnum(jd),number:Xn,base:G0.optional()}).strict().nullable(),compareWith:G0.optional()}).strict();function aW(t){if(t.trigger.kind==="revision_read"!=!t.baseline)return t.baseline?"a revision_read run names no baseline":"names its baseline";if(!t.baseline)return null;let{confirmedRunId:e,initialBaselineId:n,sources:r}=t.baseline;if(e!==null&&n!==void 0)return"a run compares with one baseline";let s=t.trigger.kind==="schedule"&&e!==null||n!==void 0;if(!r)return s?"names every source of the snapshot, once":null;if(e===null&&n===void 0)return"a run with no Confirmed Baseline names no baseline sources";let i=new Set(t.sources.map(A=>go(A.repository))),a=new Set(r.map(A=>go(A.repository)));return a.size===r.length&&a.size===i.size&&[...a].every(A=>i.has(A))?null:"names every source of the snapshot, once"}var tT=/^[A-Z][A-Z0-9_]+-[1-9][0-9]*$/,nT=/^[1-9][0-9]{0,18}$/,H0=new RegExp(`${tT.source}|${nT.source}`),Y0=/^https:\/\/[a-z0-9-]+(\.[a-z0-9-]+)+$/,cW=u.union([u.object({source:u.literal("jira"),site:u.string().regex(Y0),key:u.string().regex(tT),updated:u.string().datetime(),contentHash:Ut}).strict(),u.object({source:u.literal("confluence"),site:u.string().regex(Y0),key:u.string().regex(nT),version:u.number().int().positive(),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),contentHash:Ut}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),contentHash:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict()]),q0=u.union([u.literal("jira"),u.literal("confluence")]),uW=u.object({schemaVersion:u.literal(1),items:u.array(u.union([u.object({source:q0,site:u.string(),key:u.string().regex(H0),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:q0,site:u.string(),key:u.string().regex(H0),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("read"),text:u.string(),version:u.string().min(1),contentMatches:u.boolean()}).strict(),u.object({source:u.literal("other"),key:u.string().regex(Ed),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("read"),version:Ut,fileName:u.string().min(1).max(255),mediaType:u.nativeEnum(yu)}).strict(),u.object({source:u.literal("other"),key:u.string().regex(mu),state:u.literal("not_read"),reason:u.nativeEnum(qi)}).strict()])),instructions:u.array(u.string()).optional()}).strict(),AW=u.object({schemaVersion:u.literal(1),runId:_t,skyrampOrgId:_t,target:Yd,policy:Yd.nullable(),trigger:u.object({kind:u.nativeEnum(Uu),requestedAt:u.string().datetime()}).strict(),configuration:u.object({captureId:_t,revision:Xn.nullable(),hash:Ut}).strict(),baseline:u.object({confirmedRunId:_t.nullable(),initialBaselineId:_t.optional(),sources:u.array(u.object({repository:er,revision:as}).strict()).optional()}).strict().optional(),sources:u.array(oW).min(1),execution:u.object({provider:u.nativeEnum(qd),repository:eT,workflowPath:u.string(),ref:u.string()}).strict(),credentials:u.array(u.object({name:u.string(),purpose:u.nativeEnum(Lu),required:u.boolean()}).strict()),requirements:u.array(cW).min(1).optional(),instructions:u.object({contentHash:Ut}).strict().optional(),deployedRevisions:u.array(u.object({repository:er,revision:as}).strict()).min(1).optional()}).strict().superRefine((t,e)=>{let n=new Set;(t.requirements??[]).forEach((A,l)=>{let p="fileName"in A?"file":"pasted";A.source==="other"&&A.key!==`${p}-${A.contentHash.slice(0,16)}`&&e.addIssue({code:u.ZodIssueCode.custom,message:"is not the key of its content hash",path:["requirements",l,"key"]});let h=oy({source:A.source,key:A.key});n.has(h)&&e.addIssue({code:u.ZodIssueCode.custom,message:"names an item that the run already names",path:["requirements",l,"key"]}),n.add(h)});let r=t.trigger.kind,s=sW.includes(r);s!==(t.policy===null)&&e.addIssue({code:u.ZodIssueCode.custom,path:["policy"],message:s?`a ${r} run has no policy`:"names the policy revision"});let i=aW(t);i&&e.addIssue({code:u.ZodIssueCode.custom,path:t.baseline?["baseline","sources"]:["baseline"],message:i}),iW.includes(r)&&t.sources.forEach((A,l)=>{A.reason!=="BASELINE"&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"reason"],message:`a ${r} run selects only BASELINE sources`})}),t.deployedRevisions&&r!=="manual"&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions"],message:"only a manual run pins deployed revisions"});let a=new Set(t.sources.map(A=>go(A.repository))),c=new Set;(t.deployedRevisions??[]).forEach((A,l)=>{let p=go(A.repository);a.has(p)?c.has(p)&&e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"repository appears twice"}):e.addIssue({code:u.ZodIssueCode.custom,path:["deployedRevisions",l,"repository"],message:"names a repository outside the snapshot"}),c.add(p)}),t.sources.forEach((A,l)=>{A.compareWith&&(A.reason!=="MANUAL_OVERRIDE"||A.change)&&e.addIssue({code:u.ZodIssueCode.custom,path:["sources",l,"compareWith"],message:"only a MANUAL_OVERRIDE source without a change names a revision to compare with"})})});var rT=(n=>(n.Person="person",n.Policy="policy",n))(rT||{}),lW=u.object({kind:u.nativeEnum(rT),name:u.string().min(1).max(256)}).strict(),dW=u.object({mcp:u.discriminatedUnion("source",[u.object({source:u.literal("npm"),version:u.string().regex(/^[A-Za-z0-9][A-Za-z0-9.+_-]{0,63}$/).nullable()}).strict(),u.object({source:u.literal("github"),ref:u.string().regex(/^[A-Za-z0-9._/-]{1,255}$/)}).strict()]),bedrock:u.object({region:u.string().regex(/^[a-z]{2}(-[a-z]+)+-[0-9]$/),roleArn:u.string().regex(/^arn:aws(-[a-z]+)*:iam::[0-9]{12}:role\/[\w+=,.@/-]{1,512}$/)}).strict().nullable()}).strict(),Zne=u.object({schemaVersion:u.literal(1),attempt:u.object({id:_t,number:u.number().int().positive(),deadlineAt:u.string().datetime()}).strict(),manifest:AW,manifestHash:Ut,entitlements:u.array(u.string()).optional(),runToken:u.string().min(1).optional(),requestedBy:lW.nullable().optional(),writeAllowed:u.boolean().optional(),claudeCodeVersion:u.string().regex(/^[0-9]+\.[0-9]+\.[0-9]+$/,"an exact version, such as 2.1.290").nullable().optional(),deployedRevisions:u.array(u.object({repository:er,revision:as}).strict()).optional(),statedRevisions:u.array(u.object({repository:er,revision:as}).strict()).optional(),runSettings:dW.optional()}).strict(),j0={providerRunAttempt:u.number().int().positive(),workflowRef:u.string().min(1)},pW=u.string().regex(/^[^/]+\/[^/]+\/[1-9][0-9]{0,15}\/[1-9][0-9]{0,15}$/),Xne=u.object({schemaVersion:u.literal(1),runId:_t,execution:u.discriminatedUnion("provider",[u.object({...j0,provider:u.literal("github"),repository:u.object(Zd).strict(),providerRunId:Xn}).strict(),u.object({...j0,provider:u.literal("azure-devops"),repository:u.object(Xd).strict(),providerRunId:pW}).strict()]),requester:u.literal(!0).optional(),writeCheck:u.literal(!0).optional(),claudeCodePin:u.literal(!0).optional(),deployedPins:u.literal(!0).optional(),statedPins:u.literal(!0).optional(),runSettings:u.literal(!0).optional()}).strict(),J0=u.object({repository:er,number:Xn}).strict(),hW=u.discriminatedUnion("status",[u.object({status:u.literal("none")}).strict(),u.object({status:u.literal("delivered"),pullRequests:u.array(J0).min(1)}).strict(),u.object({status:u.literal("partial"),pullRequests:u.array(J0).min(1),failures:u.array(u.object({repository:er,message:u.string()}).strict()).min(1)}).strict(),u.object({status:u.literal("failed"),message:u.string()}).strict()]),fW=u.object({blockedPreflight:u.object({file:u.string().min(1),repository:u.string().min(1).optional(),reason:u.string().min(1).max(300),evidence:u.string().min(1).max(400)}).strict().optional(),sufficiency:u.nativeEnum(Sa),rationale:u.string().min(1),gaps:u.array(u.string().min(1)),acceptedEvidence:u.array(u.object({kind:u.nativeEnum(_s),repository:u.string().min(1),revision:as,reference:u.string().min(1),summary:u.string().min(1)}).strict()),actionRequired:u.array(u.nativeEnum(ka))}).strict().superRefine((t,e)=>{t.sufficiency==="insufficient"!=t.gaps.length>0&&e.addIssue({code:u.ZodIssueCode.custom,path:["gaps"],message:"only insufficient evidence names gaps, and it names at least one"}),new Set(t.actionRequired).size!==t.actionRequired.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["actionRequired"],message:"a reason appears twice"})}),Py=500,gW=2048,mW=1e3,yW=/[\\/:*?"<>|;#$*{},+=[\]%\p{Cc}\p{Cf}]/u,W0=t=>t.length>0&&t.length<=64&&t===t.trim()&&!yW.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith("."),EW=t=>{if(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/.test(t))return!0;let[e,n,r,...s]=t.split("/");return t.length<=201&&s.length===0&&r!==void 0&&/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/.test(e)&&W0(n)&&W0(r)},CW=u.object({testResults:u.array(u.object({resultId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/),repository:u.string().refine(EW,"Invalid"),testType:u.string(),endpoint:u.string(),status:u.enum(["Pass","Fail","Skipped"]),details:u.string(),fileName:u.string().optional(),testId:u.string().regex(/^[^\u0000-\u001f]{1,512}$/).optional(),failureCause:u.object({kind:u.nativeEnum(cy),family:u.nativeEnum(uy).optional()}).strict().optional(),origin:u.nativeEnum(ay).optional()}).strict()),validation:fW,changes:u.array(u.object({id:u.string().min(1).max(512),text:u.string().max(16384),source:u.string().max(gW),testedBy:u.array(u.string().min(1).max(1024)).max(Py),writtenBy:u.array(u.string().min(1).max(1024)).max(Py),maintainedBy:u.array(u.string().min(1).max(1024)).max(Py)}).strict()).max(mW).optional(),traceVersion:u.literal(1)}).passthrough().superRefine((t,e)=>{let n=new Set;t.testResults.forEach((r,s)=>{let i=r.failureCause;i&&r.status==="Pass"&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"a passing result has no failure cause"}),i&&i.kind==="environment"!=(i.family!==void 0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["testResults",s,"failureCause"],message:"an environment cause names its family, and no other cause does"});let a=["testResults",s,"resultId"],c=r.resultId.slice(`${r.repository}:${r.testType}:`.length);(!r.resultId.startsWith(`${r.repository}:${r.testType}:`)||c===""||c.startsWith("/")||c.startsWith("#"))&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"is not repository:testType:path for this result"}),n.has(r.resultId)&&e.addIssue({code:u.ZodIssueCode.custom,path:a,message:"stable identity repeated"}),n.add(r.resultId)})});var sT=50,z0=u.string().regex(/^(?!.*\.\.)(?!\/)(?!.*\/$)[A-Za-z0-9._/-]{1,255}$/),iT=u.discriminatedUnion("kind",[u.object({kind:u.literal("branch_pushed"),repository:er,branch:z0,commit:as}).strict(),u.object({kind:u.enum(["pull_request_opened","pull_request_edited"]),repository:er,number:Xn,branch:z0}).strict()]),IW=u.object({schemaVersion:u.literal(1),run:u.object({runId:_t,attemptNumber:u.number().int().positive(),manifestHash:Ut}).strict(),target:Yd,policy:Yd,provenance:u.object({sources:u.array(u.object({repository:er,revision:as}).strict()),firstQualification:u.literal(!0).optional()}).strict(),delivery:u.object({generatedTests:hW}).strict(),producer:u.object({testbot:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/),mcp:u.string().regex(/^[0-9A-Za-z.+-]{1,64}$/)}).strict(),report:CW,githubWrites:u.array(iT).max(sT).optional()}).strict(),ere=IW.pick({schemaVersion:!0,run:!0,target:!0,provenance:!0,producer:!0}).extend({recipe:Sy}).strict().superRefine(({recipe:t},e)=>{let n=(i,a)=>e.addIssue({code:u.ZodIssueCode.custom,path:["recipe",...i],message:a});t.status==="blocked"&&t.blockers.length===0&&n(["blockers"],"a blocked recipe names at least one blocker");let r=new Set,s=0;t.files.forEach((i,a)=>{Ru(i.path)||n(["files",a,"path"],"is not .skyramp/workspace.yml or a file under .skyramp/sut/"),r.has(i.path)&&n(["files",a,"path"],"file repeated"),r.add(i.path),fy.test(i.content)&&n(["files",a,"content"],"is not text");let c=Buffer.byteLength(i.content,"utf8");s+=c,c>ku&&n(["files",a,"content"],`larger than ${ku} bytes`)}),s>vu&&n(["files"],`recipe text over ${vu} bytes in total`)}),tre=u.object({components:u.array(u.object({name:u.string().min(1),repository:u.string().regex(/^[A-Za-z0-9._-]{1,100}\/[A-Za-z0-9._-]{1,100}$/),observedRevision:u.string().regex(/^[0-9a-f]{7,64}$/).nullable(),source:u.nativeEnum(Cd),evidence:u.string()}).strict().refine(t=>t.source!=="agent"||t.observedRevision===null,{path:["observedRevision"],message:"a component only an agent session can read names no revision"}))}).strict();var BW=u.object({schemaVersion:u.literal(1),stage:u.nativeEnum(Vy),event:u.nativeEnum(Gy),status:u.nativeEnum(Hy).optional()}).strict().refine(t=>t.status===void 0||t.event==="finished",{path:["status"],message:"only a finished stage has a status"}),Wa=100,jy=5e3,_u=2e3,Oy=100,Jy=/^[A-Za-z0-9_-]{1,64}$/,oT=20,aT=200,cT=100,uT=100,wW=200,K0="[^/\\s](?:(?:[^/\\s]| )*[^/\\s])?",QW=new RegExp(`^(?:[^/\\s]+/[^/\\s]+|[^/\\s]+/${K0}/${K0})$`),AT=500,lT=50,Ou=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/,xn=t=>u.string().max(t).refine(e=>e.trim().length>0&&!Ou.test(e),"blank, or not text"),os={sequence:u.number().int().min(1).max(jy),at:u.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?Z$/)},dT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),phase:u.nativeEnum(zd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("component"),name:xn(Oy),repository:xn(wW).refine(t=>QW.test(t)||t===zt,"not owner/name"),file:xn(AT).nullable(),status:u.nativeEnum(Pu),version:xn(uT).optional()}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("question"),id:u.string().regex(Jy),type:u.nativeEnum(Yy),text:xn(_u),component:xn(Oy).nullable(),choices:u.array(xn(aT)).max(oT),placeholder:xn(cT).optional()}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict(),u.object({...os,kind:u.literal("credentials"),names:u.array(u.string().regex(La)).min(1).max(lT)}).strict()]).superRefine((t,e)=>{t.kind==="credentials"&&new Set(t.names).size!==t.names.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["names"],message:"a name twice"}),t.kind==="question"&&(t.type==="free_text"!=(t.choices.length===0)&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"choices exactly when the question is not free_text"}),new Set(t.choices).size!==t.choices.length&&e.addIssue({code:u.ZodIssueCode.custom,path:["choices"],message:"a choice twice"}))}),bW=u.object({schemaVersion:u.literal(1),events:u.array(dT).max(Wa)}).strict(),pT=u.discriminatedUnion("kind",[u.object({...os,kind:u.literal("log"),stage:u.nativeEnum(Kd),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("reply"),to:u.string().uuid(),accepted:u.boolean(),text:xn(_u)}).strict(),u.object({...os,kind:u.literal("delivered"),ids:u.array(u.string().uuid()).max(Wa)}).strict()]),SW=u.object({schemaVersion:u.literal(1),events:u.array(pT).max(Wa)}).strict(),Z0={id:u.string().uuid(),text:u.string(),by:u.string().nullable(),at:u.string(),replied:u.literal(!0).optional()},hT=u.discriminatedUnion("kind",[u.object({...Z0,kind:u.literal("instruction"),question:u.null()}),u.object({...Z0,kind:u.literal("answer"),question:u.string().regex(Jy)})]),fT=u.string().regex(/^[A-Za-z0-9+/]{43}=$/),kW=u.object({id:u.string().uuid(),revision:u.string(),by:u.string().nullable(),at:u.string(),target:u.string(),own:u.object({source:u.enum(["policy","test_environment"]),text:u.string()}).nullable()}),vW=u.object({schemaVersion:u.literal(1),leftOut:u.array(u.string()),messages:u.array(hT).optional(),stop:u.object({key:fT}).optional(),notes:kW.optional()}),RW=u.object({schemaVersion:u.literal(1),messages:u.array(hT).optional()});var gT=500*1024*1024,mT=u.object({id:Xn,name:u.string().regex(/^[A-Za-z0-9._-]{1,200}$/),providerRunId:Xn,expiresAt:u.string().datetime()}).strict(),xW=u.object({schemaVersion:u.literal(1),artifact:mT,sessionId:_t,contentHash:Ut,bytes:u.number().int().min(1).max(gT)}).strict(),TW=u.object({schemaVersion:u.literal(1),checkpoint:u.object({artifact:mT,repository:u.object({namespace:u.string().min(1),name:u.string().min(1)}).strict(),sessionId:_t,contentHash:Ut,key:fT}).strict().nullable()}).strict(),DW=200,ja=100,Wy=(r=>(r.Resume="resume",r.Retry="retry",r.Update="update",r))(Wy||{}),NW=u.object({kind:u.nativeEnum(Wy),setup:u.object({runId:_t,endedAt:u.string().nullable(),outcome:u.string().nullable()}).strict(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1),status:u.nativeEnum(Pu)}).strict()).max(ja),credentials:u.array(u.string().min(1)).max(ja),answers:u.array(u.object({question:u.string(),answer:u.string().nullable()}).strict()).max(ja),instructions:u.array(u.object({text:u.string(),reply:u.string().nullable()}).strict()).max(ja),log:u.array(u.object({phase:u.nativeEnum(zd),text:u.string()}).strict()).max(DW),recipe:u.object({files:u.array(u.object({path:u.string().min(1),content:u.string()}).strict()).max(ja),blockers:u.array(u.object({component:u.string(),problem:u.string(),evidence:u.string(),fix:u.string()}).strict()).max(ja)}).strict().optional()}).strict(),FW=u.object({schemaVersion:u.literal(1),context:NW.nullable()}).strict(),MW=u.object({schemaVersion:u.literal(1),configuration:u.object({captureId:_t,revision:Xn.nullable(),hash:Ut}).strict(),capture:u.object({schemaVersion:u.literal(1),settings:u.object({target:u.object({environment:u.unknown()}).passthrough(),timeoutMinutes:u.number().int().positive(),answerWaitMinutes:u.number().int().positive().optional(),testEnvironment:u.object({name:u.string().min(1),address:u.string().min(1).optional(),readyWhen:u.string().min(1).optional()}).passthrough().optional()}).passthrough(),provenance:u.object({}).passthrough(),hash:Ut}).strict()}).strict(),_W=Oa.extend({version:u.number().int().positive(),components:u.array(u.object({name:u.string().min(1),repository:u.string().min(1)}).strict()),contentHash:Ut.optional(),files:u.array(u.object({path:u.string().refine(t=>Ru(t)&&!_d.includes(t),"not a file of a customer_deployed plan"),content:u.string()}).strict()).optional()}).strict(),UW=u.object({schemaVersion:u.literal(1),testEnvironment:_W.nullable().optional(),runtimePlan:u.object({version:u.number().int().positive(),contentHash:Ut,files:u.array(u.object({path:u.string().refine(Ru,"not a recipe file path"),content:u.string()}).strict()).min(1),recipe:u.record(u.unknown()).optional()}).strict().nullable()}).strict().refine(t=>!(t.runtimePlan&&t.testEnvironment),{message:"a run pins a recipe or a customer's Test Environment, never both",path:["testEnvironment"]}),LW=u.object({schemaVersion:u.literal(1),state:u.nativeEnum(X0),ending:u.nativeEnum(Jd).nullable(),cause:u.nativeEnum(Wd).nullable(),deadlineAt:u.string().datetime()}).strict();function yT(t){return t.reportUploaded?{schemaVersion:1,reason:"report_uploaded",cause:null}:t.recipeUploaded?{schemaVersion:1,reason:"recipe_uploaded",cause:null}:t.revisionsUploaded?{schemaVersion:1,reason:"revisions_uploaded",cause:null}:t.cancelled?{schemaVersion:1,reason:"cancelled",cause:null}:{schemaVersion:1,reason:"no_report",cause:PW(t)}}function PW(t){return t.runnerProviderNotReady?"runner_provider_not_ready":t.credentialMissing?"credential_missing":t.checkoutFailed?"checkout_failed":t.environmentUnverified?"environment_unverified":t.setupFailed?"setup_failed":t.timedOut?"timed_out":t.modelProviderDenied?"model_provider_denied":t.modelProviderUnavailable?"model_provider_unavailable":"agent_failed"}var ire={"application/pdf":"PDF","text/csv":"CSV","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX"};var $W=10*1024*1024;var ET=Re(require("fs")),$u="SKYRAMP_AZURE_SUPERVISED",zy=3;function ep(t){return t.replace(/##(?=(?:vso)?\[)/gi,"#\u200B#")}function Ky(t,e=process.env){e[$u]==="1"?ET.writeSync(zy,`${JSON.stringify(t)}
121
121
  `):process.stdout.write(t.command!==void 0?`${t.command}
122
122
  `:t.text??"")}function Zy(t){Ky({command:t})}function CT(t){return t.replace(/%/g,"%AZP25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function VW(t){return CT(t).replace(/;/g,"%3B").replace(/]/g,"%5D")}function tp(t,e,n){let r=Object.entries(e).map(([s,i])=>`${s}=${VW(i)}`).join(";");return`##vso[${t}${r?` ${r}`:""}]${CT(n)}`}function IT(t){if(!t)return[];let e=t.split(/\r?\n/).filter(n=>n.trim()&&n!==t);return[t,...e].map(n=>tp("task.setsecret",{},n))}function BT(t,e=Zy){for(let n of IT(t))e(n)}function GW(t){return t.replace(/%0D/g,"\r").replace(/%0A/g,`
123
123
  `).replace(/%25/g,"%")}function wT(t){let e=/^::([a-z-]+)(?: [^:]*)?::(.*)$/s.exec(t.replace(/\r?\n$/,""));if(!e)return;let[,n,r]=e,s=GW(r),i=ep(s);switch(n){case"add-mask":return IT(s);case"warning":case"error":return[tp("task.logissue",{type:n},i)];case"notice":return[i];case"debug":return i.split(`
124
124
  `).map(a=>`##[debug]${a}`);case"group":return[`##[group]${i.split(`
125
- `)[0]}`];case"endgroup":return["##[endgroup]"];default:return[]}}function Gu(t){return t.replace(/\/+$/,"")}function Xy(t){let e=new URL(t),n=e.pathname.split("/").filter(Boolean);if(n.length)return decodeURIComponent(n[n.length-1]);if(e.hostname.endsWith(".visualstudio.com"))return e.hostname.split(".")[0];throw new Error(`SYSTEM_COLLECTIONURI "${t}" names no organization`)}var HW=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/,YW=/[\\/:*?"<>|;#${},+=[\]%\p{Cc}\p{Cf}]/u;function QT(t){return t.length>0&&t.length<=64&&t===t.trim()&&!YW.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith(".")}function np(t){return eE(`${t.namespace}/${t.name}`)}function eE(t){let e=t.indexOf("/"),n=t.lastIndexOf("/"),r=t.slice(0,e),s=t.slice(e+1,n),i=t.slice(n+1);if(e<0||e===n||!HW.test(r)||!QT(s)||!QT(i))throw new Error(`"${t}" is not an Azure DevOps organization/project/repository`);return{organization:r,project:s,name:i}}function bT(t,e){let n=Xy(t);if(n.toLowerCase()!==e.organization.toLowerCase())throw new Error(`${e.organization}/${e.project}/${e.name} is not in ${n}, the Azure DevOps organization this job runs in`)}function ST(t,e){return bT(t,e),`${Gu(t)}/${encodeURIComponent(e.project)}/_git/${encodeURIComponent(e.name)}`}function tE(t,e){return bT(t,e),`${Gu(t)}/${encodeURIComponent(e.project)}/_apis/git/repositories/${encodeURIComponent(e.name)}`}var qW="7.1",Vu=class extends Error{constructor(n,r){super(n);this.status=r}status};async function nE(t){let e=t.accept??"application/json",n=new URL(t.url);n.searchParams.has("api-version")||n.searchParams.set("api-version",qW);let r=await(t.fetch??fetch)(n.toString(),{method:t.method??"GET",headers:{Authorization:`Bearer ${t.token}`,Accept:e,...t.body!==void 0?{"Content-Type":"application/json"}:{}},...t.body!==void 0?{body:JSON.stringify(t.body)}:{},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!r.ok){let s=(await r.json().catch(()=>({}))).message;throw new Vu(`Azure DevOps answered ${r.status}${typeof s=="string"?`: ${s}`:""}`,r.status)}return e!=="application/json"?Buffer.from(await r.arrayBuffer()):r.status===204?{}:await r.json()}function jW(t){return`AUTHORIZATION: bearer ${t}`}function kT(t,e){return{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${Gu(t)}/.extraheader`,GIT_CONFIG_VALUE_0:jW(e)}}var JW="7.1-preview.1",WW=".azure-pipelines/skyramp-testbot-v3.yml";function mo(t){return t.GITHUB_ACTIONS!=="true"&&/^true$/i.test(t.TF_BUILD??"")}var zW={INPUT_SKYRAMPRUNID:"SKYRAMP_RUN_ID",INPUT_SKYRAMPAPPORIGIN:"SKYRAMP_APP_ORIGIN",INPUT_SKYRAMPMCPGITHUBTOKEN:"SKYRAMP_MCP_GITHUB_TOKEN"};function xT(t=process.env){if(mo(t))for(let[e,n]of Object.entries(zW))!t[e]&&t[n]!==void 0&&(t[e]=t[n])}function TT(t,e={}){let n=h=>{let g=t[h];if(!g)throw new Error(`${h} is not set; the V3 runner handshake needs it`);return g},r=Gu(t.SYSTEM_COLLECTIONURI??""),s=()=>Xy(n("SYSTEM_COLLECTIONURI")),i=t.SYSTEM_TEAMPROJECT,a=t.BUILD_REPOSITORY_NAME,c=t.BUILD_REPOSITORY_ID?.toLowerCase(),A=t.SYSTEM_ACCESSTOKEN,l=e.mask??(h=>BT(h)),p=h=>async()=>{if(!h)throw new Error("The job cannot request an OIDC token: the Testbot step's env must set SYSTEM_OIDCREQUESTURI to $(System.OidcRequestUri).");if(!A)throw new Error("The job cannot request an OIDC token: the Testbot step's env must set SYSTEM_ACCESSTOKEN to $(System.AccessToken).");let g=new URL(h);if(g.protocol!=="https:")throw new Error("SYSTEM_OIDCREQUESTURI is not an https URL");g.searchParams.set("api-version",JW);let C=await(e.fetch??fetch)(g.toString(),{method:"POST",headers:{Authorization:`Bearer ${A}`,"Content-Type":"application/json",Accept:"application/json"},body:"{}",redirect:"error",signal:AbortSignal.timeout(3e4)});if(!C.ok)throw new Error(`Azure DevOps refused the OIDC token request: ${C.status}`);let S=(await C.json().catch(()=>({}))).oidcToken;if(typeof S!="string"||!S)throw new Error("Azure DevOps's OIDC token response carried no token");return l(S),S};return{runnerPlatform:mo(t)?"azure":void 0,workspace:t.BUILD_SOURCESDIRECTORY||void 0,serverUrl:r,apiUrl:r,repository:c&&i&&a&&r?{id:c,slug:`${s()}/${i}/${a}`}:void 0,runId:t.BUILD_BUILDID||void 0,runAttempt:t.SYSTEM_STAGEATTEMPT||void 0,job:t.SYSTEM_JOBNAME||void 0,execution(){let h=n("SYSTEM_STAGEATTEMPT");if(!/^[1-9][0-9]*$/.test(h))throw new Error(`SYSTEM_STAGEATTEMPT is "${h}", not a positive whole number`);let g=n("SYSTEM_COLLECTIONID").toLowerCase();if(!Ja.test(g))throw new Error(`SYSTEM_COLLECTIONID is "${g}", not a GUID`);let C=n("BUILD_REPOSITORY_ID").toLowerCase();if(!Ja.test(C))throw new Error(`BUILD_REPOSITORY_ID is "${C}", not a GUID`);let S=[s(),n("SYSTEM_TEAMPROJECT"),n("SYSTEM_DEFINITIONID"),n("BUILD_BUILDID")].map(encodeURIComponent).join("/");return{provider:"azure-devops",repository:{provider:"azure-devops",providerAccountId:g,providerRepositoryId:C},providerRunId:S,providerRunAttempt:Number(h),workflowRef:`${WW}@${n("BUILD_SOURCEBRANCH")}`}},takeIdToken(){let h=t.SYSTEM_OIDCREQUESTURI;delete t.SYSTEM_OIDCREQUESTURI;let g=p(h);return()=>g()},takeSourceToken(){return delete t.SYSTEM_ACCESSTOKEN,A||void 0},webIdentity(){if(!t.SYSTEM_OIDCREQUESTURI?.trim()||!A)return;let h=p(t.SYSTEM_OIDCREQUESTURI);return{token:()=>h(),runId:t.BUILD_BUILDID}},v3RunsOnly:!0,assumesBedrockRole:!0,namesSourceToMcp:!0,runSettingsFromApp:!0,checkSourceName(h){np(h)},cloneUrl(h){return ST(r,np(h))},gitAuthEnv(h){return kT(r,h)},async pullRequest(h,g,C){let S=await nE({token:await C.token(),url:`${tE(r,np(h))}/pullrequests/${g}`,fetch:C.fetch}),v=S.status==="completed";return{...typeof S.title=="string"?{title:S.title}:{},...typeof S.description=="string"?{body:S.description}:{},...typeof S.status=="string"?{merged:v}:{},...v&&typeof S.lastMergeCommit?.commitId=="string"?{mergeCommit:S.lastMergeCommit.commitId}:{},...v&&typeof S.lastMergeSourceCommit?.commitId=="string"?{mergedHead:S.lastMergeSourceCommit.commitId}:{}}},async commit(h,g,C){let S;try{S=tE(r,eE(h))}catch{return{lookup:"unknown"}}try{let v=await nE({token:await C.token(),url:`${S}/commits/${encodeURIComponent(g)}`,fetch:C.fetch});return typeof v.commitId=="string"?{sha:v.commitId}:{lookup:"missing"}}catch(v){return{lookup:v instanceof Vu&&(v.status===404||v.status===400)?"missing":"unknown"}}}}}Dt();var KW=5e3,rE=/^(?!\.\.?$)[A-Za-z0-9._-]{1,100}$/;function ZW(t){let e=Buffer.from(`x-access-token:${t}`).toString("base64");return Gr(e),`AUTHORIZATION: basic ${e}`}function DT(t,e={}){let n=A=>{let l=t[A];if(!l)throw new Error(`${A} is not set; the V3 runner handshake needs it`);return l},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=async(A,l)=>l.fetch(A,{headers:{Authorization:`Bearer ${await l.token()}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(3e4)});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 A=n("GITHUB_RUN_ATTEMPT");if(!/^[1-9][0-9]*$/.test(A))throw new Error(`GITHUB_RUN_ATTEMPT is "${A}", 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(A),workflowRef:n("GITHUB_WORKFLOW_REF")}},takeIdToken(){let A=t.ACTIONS_ID_TOKEN_REQUEST_URL,l=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;return delete t.ACTIONS_ID_TOKEN_REQUEST_URL,delete t.ACTIONS_ID_TOKEN_REQUEST_TOKEN,async p=>{if(!A||!l)throw new Error("The job cannot request an OIDC token. Give it the `id-token: write` permission.");let h=new URL(A);h.searchParams.set("audience",p);let g=await fetch(h,{headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!g.ok)throw new Error(`GitHub refused the OIDC token request: ${g.status}`);let C=(await g.json().catch(()=>({}))).value;if(typeof C!="string"||!C)throw new Error("GitHub's OIDC token response carried no token");return Gr(C),C}},webIdentity(){return!t.ACTIONS_ID_TOKEN_REQUEST_TOKEN?.trim()||!t.ACTIONS_ID_TOKEN_REQUEST_URL?.trim()?void 0:{token:e.getIDToken??(l=>yv(l)),runId:t.GITHUB_RUN_ID}},v3RunsOnly:!1,assumesBedrockRole:!1,namesSourceToMcp:!1,runSettingsFromApp:!1,checkSourceName(A){for(let l of[A.namespace,A.name])if(!rE.test(l))throw new Error(`"${l}" is not a repository name`)},cloneUrl(A){return`${i}/${A.namespace}/${A.name}.git`},gitAuthEnv(A){return A?{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${i}/.extraheader`,GIT_CONFIG_VALUE_0:ZW(A)}:{}},async pullRequest({namespace:A,name:l},p,h){if(![A,l].every(S=>rE.test(S)))throw new Error("the repository name is not valid");let g=await c(`${a}/repos/${A}/${l}/pulls/${p}`,h);if(!g.ok)throw new Error(`GitHub answered ${g.status}`);let C=await g.json();return{...typeof C.title=="string"?{title:C.title}:{},...typeof C.body=="string"?{body:C.body}:{},...typeof C.merged=="boolean"?{merged:C.merged}:{},...C.merged===!0&&typeof C.merge_commit_sha=="string"?{mergeCommit:C.merge_commit_sha}:{},...C.merged===!0&&typeof C.head?.sha=="string"?{mergedHead:C.head.sha}:{}}},async commit(A,l,p){let[h,g,...C]=A.split("/");if(C.length||![h,g].every(S=>S!==void 0&&rE.test(S)))return{lookup:"unknown"};try{let S=await c(`${a}/repos/${h}/${g}/commits/${encodeURIComponent(l)}`,p);if(S.status===404||S.status===422)return{lookup:"missing"};if(!S.ok)return{lookup:"unknown"};let v=await S.json();return typeof v.sha=="string"?{sha:v.sha}:{lookup:"missing"}}catch{return{lookup:"unknown"}}},async revokeToken(A,l){let p=await l(`${a}/installation/token`,{method:"DELETE",headers:{Authorization:`Bearer ${A}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(KW)});if(!p.ok&&p.status!==401)throw new Error(`GitHub answered ${p.status}`)}}}function sE(t=process.env){return mo(t)?TT(t):DT(t)}var rse=10*6e4;var sse=10*6e4;var e9=3e4,t9=3,NT=30,js=class extends Error{constructor(n,r,s,i){super(n);this.status=r;this.code=s;this.path=i}status;code;path},yo=class extends Error{},Ka=class extends yo{},rp=class extends Ka{};function n9(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}function r9(t,e){if(!Ja.test(t))throw new Error(`The ${e} "${t}" is not a uuid`);return t}function s9(t,e,n,r){throw e<500&&e!==429?new js(t,e,n,r):e===503&&n==="RUNNER_PROVIDER_NOT_READY"?new rp(t):e===503&&n==="RUN_NOT_READY"?new Ka(t):new yo(t)}async function i9(t,e,n,r){let s=n9(t.origin),i,a=0;for(let c=1;c<=t9||i instanceof Ka;c+=1){if(i instanceof Ka){if(a===NT)throw i;a+=1,c-=1,t.log?.(`${i.message}; trying again (${a} of ${NT}).`),await new Promise(A=>setTimeout(A,t.readyWaitMs??1e4))}else c>1&&await new Promise(A=>setTimeout(A,(t.retryDelayMs??2e3)*(c-1)));try{let A=await t.idToken(s),l=await(t.fetch??fetch)(new URL(e,s).toString(),{...n(A),redirect:"error",signal:AbortSignal.timeout(e9)}).catch(p=>{throw new yo(p instanceof Error?p.message:String(p),{cause:p})});return await r(l)}catch(A){if(A instanceof js)throw A;i=A}}throw i}function o9(t,e,n,r){return i9(t,n,i=>({method:e,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json",Accept:"application/json"},body:e==="GET"?void 0:JSON.stringify(r)}),async i=>{let a=await i.json().catch(()=>({}));if(i.ok)return a.data;let c=a.error?.fields,A=typeof c?.path=="string"&&typeof c.reason=="string"?` at ${c.path}: ${c.reason}`:"",l=`The Skyramp app refused ${e} ${n}: ${i.status} ${a.error?.code??"no error code"}${A}`;return s9(l,i.status,a.error?.code,typeof c?.path=="string"?c.path:void 0)})}var ise=10*6e4;var ose=["TRIGGER","AUTHORITATIVE_RELATED_CHANGE"];var ase=u.object({tests:u.object({placements:u.array(u.unknown()).optional()}).passthrough().optional()}).passthrough(),cse=u.object({repository:qy,testType:u.nativeEnum(Qd),directory:u.string()}).passthrough();var use=u.object({report:u.object({language:u.string()}).passthrough()}).passthrough();var Ase=u.object({environment:u.object({components:u.array(u.unknown()).optional(),dependencies:u.array(u.unknown()).optional()}).passthrough()}).passthrough(),lse=u.object({name:u.string().min(1),provision:u.literal("existing"),url:u.string().min(1),repository:qy.optional(),revisionUrl:u.string().min(1).optional()}).passthrough(),dse=u.object({name:u.string().min(1),url:u.string().nullable(),versionUrl:u.string().nullable(),notes:u.string().nullable()}).passthrough();var pse=new Set(["TRIGGER","AUTHORITATIVE_RELATED_CHANGE","MANUAL_OVERRIDE"]);var hse={"model-provider-denied":"model_provider_denied","model-provider-unavailable":"model_provider_unavailable"};async function _T(t,e){return r9(t.attemptId,"attempt id"),o9(e,"POST",`/api/v1/runner/attempts/${t.attemptId}/end`,yT({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"}))}var Ise={focused:"Focused",impacted_critical:"Impacted and critical",broad:"Broad"};var sp=Re(require("path")),Qse=sp.join(".skyramp","sut"),bse=sp.join(".skyramp","workspace.yml");var UT=".skyramp/sut/health.json",$se={[UT]:`${UT} (with a url or command)`,".skyramp/workspace.yml":".skyramp/workspace.yml (create it with skyramp_init_scan and skyramp_init_workspace)"};var qse=20*1024*1024;var LT=Re(require("path"));var sie=LT.join(".skyramp","sut","get-auth-token.sh");var p9=50,h9=50,f9=4096,g9=8e3,m9=2048,y9=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/,E9=/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._/ -]{1,255}$/,C9=/^\.github\/workflows\/[A-Za-z0-9._-]+\.ya?ml$/,I9=/^(?!GITHUB_)(?!SKYRAMP_RUNNER_)[A-Z][A-Z0-9_]{0,99}$/,OT=(i=>(i.Command="command",i.ComposeFile="compose_file",i.DeploymentWorkflow="deployment_workflow",i.Url="url",i.Guidance="guidance",i))(OT||{}),B9={command:"optional",compose_file:"required",deployment_workflow:"required",url:"none",guidance:"none"},PT=t=>u.string().max(t).refine(e=>e.trim().length>0&&!y9.test(e),"must be non-blank text with no control characters other than tab, LF and CR");function w9(t){let e;try{e=new URL(t)}catch{return"invalid URL"}if(e.protocol!=="https:"&&e.protocol!=="http:")return"only http and https URLs";if(e.username||e.password)return"a URL cannot carry a login"}var Q9={command:PT(f9),compose_file:u.string().regex(E9,"must be a relative path inside the repository"),deployment_workflow:u.string().regex(C9,"must be a .github/workflows/*.yml path"),url:u.string().max(m9).superRefine((t,e)=>{let n=w9(t);n&&e.addIssue({code:u.ZodIssueCode.custom,message:n})}),guidance:PT(g9)},b9=u.object({kind:u.nativeEnum(OT),value:u.string(),repository:er.nullable()}).strict().superRefine((t,e)=>{let n=B9[t.kind];n==="required"&&!t.repository&&e.addIssue({code:u.ZodIssueCode.custom,path:["repository"],message:"a file belongs to a repository"}),n==="none"&&t.repository&&e.addIssue({code:u.ZodIssueCode.custom,path:["repository"],message:`a ${t.kind} names no repository`});let r=Q9[t.kind].safeParse(t.value);if(!r.success)for(let s of r.error.issues)e.addIssue({code:u.ZodIssueCode.custom,path:["value"],message:s.message})}),S9=u.object({name:u.string().regex(I9,"must be a GitHub Actions secret name (A-Z, 0-9, _; not GITHUB_ or SKYRAMP_RUNNER_)"),purpose:u.nativeEnum(Lu),required:u.boolean()}).strict(),cie=u.object({knowledge:u.array(b9).max(p9),credentials:u.array(S9).max(h9)}).strict().superRefine((t,e)=>{let n=new Set;t.credentials.forEach((r,s)=>{n.has(r.name)&&e.addIssue({code:u.ZodIssueCode.custom,path:["credentials",s,"name"],message:"named twice"}),n.add(r.name)})});var uie={model_provider:"model provider",sut_access:"SUT access",skyramp:"Skyramp",other:"other"};var Hie=3*6e4;var Yie=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;var R9={discover:"reading the repositories",start:"starting the components",check:"checking that the components answer"};var Xie={running:"up",healthy:"up",ready:"up",started:"up",building:"starting",pending:"starting",installing:"starting",skipped:"out_of_scope",excluded:"out_of_scope","out-of-scope":"out_of_scope"};var eoe=new RegExp(Ou.source,"g");var Eoe=new RegExp(Ou.source,"g");var N9="https://testbot.skyramp.dev",Eo={attemptId:"v3AttemptId",deadlineAt:"v3DeadlineAt",reportUploaded:"v3ReportUploaded",recipeUploaded:"v3RecipeUploaded",recipeStatus:"v3RecipeStatus",revisionsUploaded:"v3RevisionsUploaded",cause:"v3Cause"};function F9(t,e,n){return{origin:t,idToken:e,sourceToken:n,mask:r=>Gr(r),log:r=>In(r),onTokenRefused:(r,s)=>{_9(r)&&VT.set(s,r)},onTokenGranted:r=>{VT.delete(r)}}}var VT=new Map;var lce=["setup_failed","checkout_failed","environment_unverified"];function M9(t,e){return e.getTime()>=t.getTime()}function _9(t){return t instanceof yo||t instanceof js&&t.code!=="CREDENTIALS_UNAVAILABLE"}var dce={cancelled:"Skyramp cancelled this run",expired:"this attempt passed its deadline in Skyramp",ended:"Skyramp already ended this attempt"},pce={cancelled:"attempt-cancelled",expired:"attempt-closed",ended:"attempt-closed"},hce={cancelled:"cancelled",expired:"timed_out",ended:"agent_failed"};var fce={analyze:"analyze",triage:"analyze",recommend:"recommend",generate:"generate","generate-ui":"generate","generate-unit":"generate",adapt:"generate",write:"generate",onboard:"execute",deploy:"execute","native-run":"execute",deliver:"deliver"},gce={analyze:"change analysis",recommend:"test recommendations",generate:"test generation",execute:"test execution",deliver:"opening a pull request with the tests"};function U9(){return he("skyrampAppOrigin").trim()||N9}var mce=10*6e4;var yce={onboard:"onboard",deploy:"deploy"},Ece={plan:{stage:"validation_plan",text:"Working out what to validate, and bringing up what it needs"},write:{stage:"tests",text:"Writing and running the tests"},"generate-unit":{stage:"tests",text:"Writing unit tests"},"native-run":{stage:"tests",text:"Running the unit tests"}};async function GT(){let t=Rs(Eo.attemptId);if(!t)return;let e=Rs(Eo.reportUploaded)==="true",n=Rs(Eo.recipeUploaded)==="true",r=Rs(Eo.revisionsUploaded)==="true",s=Rs(Eo.deadlineAt),i=Rs(Eo.cause)||void 0;!i&&!e&&!n&&!r&&s&&M9(new Date(s),new Date)&&(i="timed_out");let a=sE().takeIdToken(),c=await _T({attemptId:t,reportUploaded:e,recipeUploaded:n,revisionsUploaded:r,cause:i},F9(U9(),a)),A=Rs(Eo.recipeStatus);n&&A?In(`Testbot V3: attempt ended; the setup ended ${A==="ready"?"Ready":"blocked (Needs input)"}.`):In(`Testbot V3: attempt ended; the run's outcome in Skyramp is ${c.outcome??"not final yet"}.`)}var HT=require("child_process"),Cr=Re(require("fs")),aE=Re(require("path")),cE=require("string_decoder");var L9="skyramp-testbot-state",P9=/^\$\([^)]*\)$/;function O9(t){for(let[e,n]of Object.entries(t))n!==void 0&&P9.test(n)&&delete t[e]}function $9(t){let e={},n=Cr.existsSync(t)?Cr.readFileSync(t,"utf-8"):"",r=/^([^\r\n<]+)<<(\S+)\r?\n([\s\S]*?)\r?\n\2\r?$/gm;for(let s=r.exec(n);s;s=r.exec(n))e[s[1]]=s[3];return e}function YT(t,e={}){let n=e.env??process.env;if(!mo(n))return!1;O9(n),xT(n);let r=n.AGENT_TEMPDIRECTORY||n.RUNNER_TEMP;if(r){n.RUNNER_TEMP??=r;let a=aE.join(r,L9);if(t==="main")Cr.writeFileSync(a,"",{mode:384});else for(let[c,A]of Object.entries($9(a)))n[`STATE_${c}`]=A;n.GITHUB_STATE=a;for(let[c,A]of[["GITHUB_OUTPUT","output"],["GITHUB_ENV","env"],["GITHUB_PATH","path"],["GITHUB_STEP_SUMMARY",`summary-${t}.md`]])n[c]=aE.join(r,`skyramp-testbot-${A}`),Cr.writeFileSync(n[c],"",{mode:384})}let s=e.stdout??n===process.env;s&&V9(n,e.write);let i=n.GITHUB_STEP_SUMMARY;if(s&&i){let a=e.write??(c=>Zy(c.replace(/\n$/,"")));process.once("exit",()=>{Cr.existsSync(i)&&Cr.statSync(i).size>0&&a(`${tp("task.uploadsummary",{},i)}
125
+ `)[0]}`];case"endgroup":return["##[endgroup]"];default:return[]}}function Gu(t){return t.replace(/\/+$/,"")}function Xy(t){let e=new URL(t),n=e.pathname.split("/").filter(Boolean);if(n.length)return decodeURIComponent(n[n.length-1]);if(e.hostname.endsWith(".visualstudio.com"))return e.hostname.split(".")[0];throw new Error(`SYSTEM_COLLECTIONURI "${t}" names no organization`)}var HW=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/,YW=/[\\/:*?"<>|;#${},+=[\]%\p{Cc}\p{Cf}]/u;function QT(t){return t.length>0&&t.length<=64&&t===t.trim()&&!YW.test(t)&&!/[^\S ]/u.test(t)&&!/^[._]/.test(t)&&!t.endsWith(".")}function np(t){return eE(`${t.namespace}/${t.name}`)}function eE(t){let e=t.indexOf("/"),n=t.lastIndexOf("/"),r=t.slice(0,e),s=t.slice(e+1,n),i=t.slice(n+1);if(e<0||e===n||!HW.test(r)||!QT(s)||!QT(i))throw new Error(`"${t}" is not an Azure DevOps organization/project/repository`);return{organization:r,project:s,name:i}}function bT(t,e){let n=Xy(t);if(n.toLowerCase()!==e.organization.toLowerCase())throw new Error(`${e.organization}/${e.project}/${e.name} is not in ${n}, the Azure DevOps organization this job runs in`)}function ST(t,e){return bT(t,e),`${Gu(t)}/${encodeURIComponent(e.project)}/_git/${encodeURIComponent(e.name)}`}function tE(t,e){return bT(t,e),`${Gu(t)}/${encodeURIComponent(e.project)}/_apis/git/repositories/${encodeURIComponent(e.name)}`}var qW="7.1",Vu=class extends Error{constructor(n,r){super(n);this.status=r}status};async function nE(t){let e=t.accept??"application/json",n=new URL(t.url);n.searchParams.has("api-version")||n.searchParams.set("api-version",qW);let r=await(t.fetch??fetch)(n.toString(),{method:t.method??"GET",headers:{Authorization:`Bearer ${t.token}`,Accept:e,...t.body!==void 0?{"Content-Type":"application/json"}:{}},...t.body!==void 0?{body:JSON.stringify(t.body)}:{},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!r.ok){let s=(await r.json().catch(()=>({}))).message;throw new Vu(`Azure DevOps answered ${r.status}${typeof s=="string"?`: ${s}`:""}`,r.status)}return e!=="application/json"?Buffer.from(await r.arrayBuffer()):r.status===204?{}:await r.json()}function jW(t){return`AUTHORIZATION: bearer ${t}`}function kT(t,e){return{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${Gu(t)}/.extraheader`,GIT_CONFIG_VALUE_0:jW(e)}}var JW="7.1-preview.1",WW=".azure-pipelines/skyramp-testbot-v3.yml";function mo(t){return t.GITHUB_ACTIONS!=="true"&&/^true$/i.test(t.TF_BUILD??"")}var zW={INPUT_SKYRAMPRUNID:"SKYRAMP_RUN_ID",INPUT_SKYRAMPAPPORIGIN:"SKYRAMP_APP_ORIGIN",INPUT_SKYRAMPMCPGITHUBTOKEN:"SKYRAMP_MCP_GITHUB_TOKEN"};function xT(t=process.env){if(mo(t))for(let[e,n]of Object.entries(zW))!t[e]&&t[n]!==void 0&&(t[e]=t[n])}function TT(t,e={}){let n=h=>{let g=t[h];if(!g)throw new Error(`${h} is not set; the V3 runner handshake needs it`);return g},r=Gu(t.SYSTEM_COLLECTIONURI??""),s=()=>Xy(n("SYSTEM_COLLECTIONURI")),i=t.SYSTEM_TEAMPROJECT,a=t.BUILD_REPOSITORY_NAME,c=t.BUILD_REPOSITORY_ID?.toLowerCase(),A=t.SYSTEM_ACCESSTOKEN,l=e.mask??(h=>BT(h)),p=h=>async()=>{if(!h)throw new Error("The job cannot request an OIDC token: the Testbot step's env must set SYSTEM_OIDCREQUESTURI to $(System.OidcRequestUri).");if(!A)throw new Error("The job cannot request an OIDC token: the Testbot step's env must set SYSTEM_ACCESSTOKEN to $(System.AccessToken).");let g=new URL(h);if(g.protocol!=="https:")throw new Error("SYSTEM_OIDCREQUESTURI is not an https URL");g.searchParams.set("api-version",JW);let C=await(e.fetch??fetch)(g.toString(),{method:"POST",headers:{Authorization:`Bearer ${A}`,"Content-Type":"application/json",Accept:"application/json"},body:"{}",redirect:"error",signal:AbortSignal.timeout(3e4)});if(!C.ok)throw new Error(`Azure DevOps refused the OIDC token request: ${C.status}`);let S=(await C.json().catch(()=>({}))).oidcToken;if(typeof S!="string"||!S)throw new Error("Azure DevOps's OIDC token response carried no token");return l(S),S};return{runnerPlatform:mo(t)?"azure":void 0,workspace:t.BUILD_SOURCESDIRECTORY||void 0,serverUrl:r,apiUrl:r,repository:c&&i&&a&&r?{id:c,slug:`${s()}/${i}/${a}`}:void 0,runId:t.BUILD_BUILDID||void 0,runAttempt:t.SYSTEM_STAGEATTEMPT||void 0,job:t.SYSTEM_JOBNAME||void 0,execution(){let h=n("SYSTEM_STAGEATTEMPT");if(!/^[1-9][0-9]*$/.test(h))throw new Error(`SYSTEM_STAGEATTEMPT is "${h}", not a positive whole number`);let g=n("SYSTEM_COLLECTIONID").toLowerCase();if(!Ja.test(g))throw new Error(`SYSTEM_COLLECTIONID is "${g}", not a GUID`);let C=n("BUILD_REPOSITORY_ID").toLowerCase();if(!Ja.test(C))throw new Error(`BUILD_REPOSITORY_ID is "${C}", not a GUID`);let S=[s(),n("SYSTEM_TEAMPROJECT"),n("SYSTEM_DEFINITIONID"),n("BUILD_BUILDID")].map(encodeURIComponent).join("/");return{provider:"azure-devops",repository:{provider:"azure-devops",providerAccountId:g,providerRepositoryId:C},providerRunId:S,providerRunAttempt:Number(h),workflowRef:`${WW}@${n("BUILD_SOURCEBRANCH")}`}},takeIdToken(){let h=t.SYSTEM_OIDCREQUESTURI;delete t.SYSTEM_OIDCREQUESTURI;let g=p(h);return()=>g()},takeSourceToken(){return delete t.SYSTEM_ACCESSTOKEN,A||void 0},webIdentity(){if(!t.SYSTEM_OIDCREQUESTURI?.trim()||!A)return;let h=p(t.SYSTEM_OIDCREQUESTURI);return{token:()=>h(),runId:t.BUILD_BUILDID}},v3RunsOnly:!0,assumesBedrockRole:!0,namesSourceToMcp:!0,runSettingsFromApp:!0,checkSourceName(h){np(h)},cloneUrl(h){return ST(r,np(h))},gitAuthEnv(h){return kT(r,h)},async pullRequest(h,g,C){let S=await nE({token:await C.token(),url:`${tE(r,np(h))}/pullrequests/${g}`,fetch:C.fetch}),v=S.status==="completed";return{...typeof S.title=="string"?{title:S.title}:{},...typeof S.description=="string"?{body:S.description}:{},...typeof S.status=="string"?{merged:v}:{},...v&&typeof S.lastMergeCommit?.commitId=="string"?{mergeCommit:S.lastMergeCommit.commitId}:{},...v&&typeof S.lastMergeSourceCommit?.commitId=="string"?{mergedHead:S.lastMergeSourceCommit.commitId}:{}}},async commit(h,g,C){let S;try{S=tE(r,eE(h))}catch{return{lookup:"unknown"}}try{let v=await nE({token:await C.token(),url:`${S}/commits/${encodeURIComponent(g)}`,fetch:C.fetch});return typeof v.commitId=="string"?{sha:v.commitId}:{lookup:"missing"}}catch(v){return{lookup:v instanceof Vu&&(v.status===404||v.status===400)?"missing":"unknown"}}}}}Dt();var KW=5e3,rE=/^(?!\.\.?$)[A-Za-z0-9._-]{1,100}$/;function ZW(t){let e=Buffer.from(`x-access-token:${t}`).toString("base64");return Gr(e),`AUTHORIZATION: basic ${e}`}function DT(t,e={}){let n=A=>{let l=t[A];if(!l)throw new Error(`${A} is not set; the V3 runner handshake needs it`);return l},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=async(A,l)=>l.fetch(A,{headers:{Authorization:`Bearer ${await l.token()}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(3e4)});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 A=n("GITHUB_RUN_ATTEMPT");if(!/^[1-9][0-9]*$/.test(A))throw new Error(`GITHUB_RUN_ATTEMPT is "${A}", 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(A),workflowRef:n("GITHUB_WORKFLOW_REF")}},takeIdToken(){let A=t.ACTIONS_ID_TOKEN_REQUEST_URL,l=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;return delete t.ACTIONS_ID_TOKEN_REQUEST_URL,delete t.ACTIONS_ID_TOKEN_REQUEST_TOKEN,async p=>{if(!A||!l)throw new Error("The job cannot request an OIDC token. Give it the `id-token: write` permission.");let h=new URL(A);h.searchParams.set("audience",p);let g=await fetch(h,{headers:{Authorization:`Bearer ${l}`,Accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(3e4)});if(!g.ok)throw new Error(`GitHub refused the OIDC token request: ${g.status}`);let C=(await g.json().catch(()=>({}))).value;if(typeof C!="string"||!C)throw new Error("GitHub's OIDC token response carried no token");return Gr(C),C}},webIdentity(){return!t.ACTIONS_ID_TOKEN_REQUEST_TOKEN?.trim()||!t.ACTIONS_ID_TOKEN_REQUEST_URL?.trim()?void 0:{token:e.getIDToken??(l=>yv(l)),runId:t.GITHUB_RUN_ID}},v3RunsOnly:!1,assumesBedrockRole:!1,namesSourceToMcp:!1,runSettingsFromApp:!1,checkSourceName(A){for(let l of[A.namespace,A.name])if(!rE.test(l))throw new Error(`"${l}" is not a repository name`)},cloneUrl(A){return`${i}/${A.namespace}/${A.name}.git`},gitAuthEnv(A){return A?{GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:`http.${i}/.extraheader`,GIT_CONFIG_VALUE_0:ZW(A)}:{}},async pullRequest({namespace:A,name:l},p,h){if(![A,l].every(S=>rE.test(S)))throw new Error("the repository name is not valid");let g=await c(`${a}/repos/${A}/${l}/pulls/${p}`,h);if(!g.ok)throw new Error(`GitHub answered ${g.status}`);let C=await g.json();return{...typeof C.title=="string"?{title:C.title}:{},...typeof C.body=="string"?{body:C.body}:{},...typeof C.merged=="boolean"?{merged:C.merged}:{},...C.merged===!0&&typeof C.merge_commit_sha=="string"?{mergeCommit:C.merge_commit_sha}:{},...C.merged===!0&&typeof C.head?.sha=="string"?{mergedHead:C.head.sha}:{}}},async commit(A,l,p){let[h,g,...C]=A.split("/");if(C.length||![h,g].every(S=>S!==void 0&&rE.test(S)))return{lookup:"unknown"};try{let S=await c(`${a}/repos/${h}/${g}/commits/${encodeURIComponent(l)}`,p);if(S.status===404||S.status===422)return{lookup:"missing"};if(!S.ok)return{lookup:"unknown"};let v=await S.json();return typeof v.sha=="string"?{sha:v.sha}:{lookup:"missing"}}catch{return{lookup:"unknown"}}},async revokeToken(A,l){let p=await l(`${a}/installation/token`,{method:"DELETE",headers:{Authorization:`Bearer ${A}`,Accept:"application/vnd.github+json"},redirect:"error",signal:AbortSignal.timeout(KW)});if(!p.ok&&p.status!==401)throw new Error(`GitHub answered ${p.status}`)}}}function sE(t=process.env){return mo(t)?TT(t):DT(t)}var sse=10*6e4;var ise=10*6e4;var e9=3e4,t9=3,NT=30,js=class extends Error{constructor(n,r,s,i){super(n);this.status=r;this.code=s;this.path=i}status;code;path},yo=class extends Error{},Ka=class extends yo{},rp=class extends Ka{};function n9(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}function r9(t,e){if(!Ja.test(t))throw new Error(`The ${e} "${t}" is not a uuid`);return t}function s9(t,e,n,r){throw e<500&&e!==429?new js(t,e,n,r):e===503&&n==="RUNNER_PROVIDER_NOT_READY"?new rp(t):e===503&&n==="RUN_NOT_READY"?new Ka(t):new yo(t)}async function i9(t,e,n,r){let s=n9(t.origin),i,a=0;for(let c=1;c<=t9||i instanceof Ka;c+=1){if(i instanceof Ka){if(a===NT)throw i;a+=1,c-=1,t.log?.(`${i.message}; trying again (${a} of ${NT}).`),await new Promise(A=>setTimeout(A,t.readyWaitMs??1e4))}else c>1&&await new Promise(A=>setTimeout(A,(t.retryDelayMs??2e3)*(c-1)));try{let A=await t.idToken(s),l=await(t.fetch??fetch)(new URL(e,s).toString(),{...n(A),redirect:"error",signal:AbortSignal.timeout(e9)}).catch(p=>{throw new yo(p instanceof Error?p.message:String(p),{cause:p})});return await r(l)}catch(A){if(A instanceof js)throw A;i=A}}throw i}function o9(t,e,n,r){return i9(t,n,i=>({method:e,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json",Accept:"application/json"},body:e==="GET"?void 0:JSON.stringify(r)}),async i=>{let a=await i.json().catch(()=>({}));if(i.ok)return a.data;let c=a.error?.fields,A=typeof c?.path=="string"&&typeof c.reason=="string"?` at ${c.path}: ${c.reason}`:"",l=`The Skyramp app refused ${e} ${n}: ${i.status} ${a.error?.code??"no error code"}${A}`;return s9(l,i.status,a.error?.code,typeof c?.path=="string"?c.path:void 0)})}var ose=10*6e4;var ase=["TRIGGER","AUTHORITATIVE_RELATED_CHANGE"];var cse=u.object({tests:u.object({placements:u.array(u.unknown()).optional()}).passthrough().optional()}).passthrough(),use=u.object({repository:qy,testType:u.nativeEnum(Qd),directory:u.string()}).passthrough();var Ase=u.object({report:u.object({language:u.string()}).passthrough()}).passthrough();var lse=u.object({environment:u.object({components:u.array(u.unknown()).optional(),dependencies:u.array(u.unknown()).optional()}).passthrough()}).passthrough(),dse=u.object({name:u.string().min(1),provision:u.literal("existing"),url:u.string().min(1),repository:qy.optional(),revisionUrl:u.string().min(1).optional()}).passthrough(),pse=u.object({name:u.string().min(1),url:u.string().nullable(),versionUrl:u.string().nullable(),notes:u.string().nullable()}).passthrough();var hse=new Set(["TRIGGER","AUTHORITATIVE_RELATED_CHANGE","MANUAL_OVERRIDE"]);var fse={"model-provider-denied":"model_provider_denied","model-provider-unavailable":"model_provider_unavailable"};async function _T(t,e){return r9(t.attemptId,"attempt id"),o9(e,"POST",`/api/v1/runner/attempts/${t.attemptId}/end`,yT({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"}))}var Bse={focused:"Focused",impacted_critical:"Impacted and critical",broad:"Broad"};var sp=Re(require("path")),bse=sp.join(".skyramp","sut"),Sse=sp.join(".skyramp","workspace.yml");var UT=".skyramp/sut/health.json",Vse={[UT]:`${UT} (with a url or command)`,".skyramp/workspace.yml":".skyramp/workspace.yml (create it with skyramp_init_scan and skyramp_init_workspace)"};var jse=20*1024*1024;var LT=Re(require("path"));var iie=LT.join(".skyramp","sut","get-auth-token.sh");var p9=50,h9=50,f9=4096,g9=8e3,m9=2048,y9=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/,E9=/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._/ -]{1,255}$/,C9=/^\.github\/workflows\/[A-Za-z0-9._-]+\.ya?ml$/,I9=/^(?!GITHUB_)(?!SKYRAMP_RUNNER_)[A-Z][A-Z0-9_]{0,99}$/,OT=(i=>(i.Command="command",i.ComposeFile="compose_file",i.DeploymentWorkflow="deployment_workflow",i.Url="url",i.Guidance="guidance",i))(OT||{}),B9={command:"optional",compose_file:"required",deployment_workflow:"required",url:"none",guidance:"none"},PT=t=>u.string().max(t).refine(e=>e.trim().length>0&&!y9.test(e),"must be non-blank text with no control characters other than tab, LF and CR");function w9(t){let e;try{e=new URL(t)}catch{return"invalid URL"}if(e.protocol!=="https:"&&e.protocol!=="http:")return"only http and https URLs";if(e.username||e.password)return"a URL cannot carry a login"}var Q9={command:PT(f9),compose_file:u.string().regex(E9,"must be a relative path inside the repository"),deployment_workflow:u.string().regex(C9,"must be a .github/workflows/*.yml path"),url:u.string().max(m9).superRefine((t,e)=>{let n=w9(t);n&&e.addIssue({code:u.ZodIssueCode.custom,message:n})}),guidance:PT(g9)},b9=u.object({kind:u.nativeEnum(OT),value:u.string(),repository:er.nullable()}).strict().superRefine((t,e)=>{let n=B9[t.kind];n==="required"&&!t.repository&&e.addIssue({code:u.ZodIssueCode.custom,path:["repository"],message:"a file belongs to a repository"}),n==="none"&&t.repository&&e.addIssue({code:u.ZodIssueCode.custom,path:["repository"],message:`a ${t.kind} names no repository`});let r=Q9[t.kind].safeParse(t.value);if(!r.success)for(let s of r.error.issues)e.addIssue({code:u.ZodIssueCode.custom,path:["value"],message:s.message})}),S9=u.object({name:u.string().regex(I9,"must be a GitHub Actions secret name (A-Z, 0-9, _; not GITHUB_ or SKYRAMP_RUNNER_)"),purpose:u.nativeEnum(Lu),required:u.boolean()}).strict(),uie=u.object({knowledge:u.array(b9).max(p9),credentials:u.array(S9).max(h9)}).strict().superRefine((t,e)=>{let n=new Set;t.credentials.forEach((r,s)=>{n.has(r.name)&&e.addIssue({code:u.ZodIssueCode.custom,path:["credentials",s,"name"],message:"named twice"}),n.add(r.name)})});var Aie={model_provider:"model provider",sut_access:"SUT access",skyramp:"Skyramp",other:"other"};var Yie=3*6e4;var qie=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;var R9={discover:"reading the repositories",start:"starting the components",check:"checking that the components answer"};var eoe={running:"up",healthy:"up",ready:"up",started:"up",building:"starting",pending:"starting",installing:"starting",skipped:"out_of_scope",excluded:"out_of_scope","out-of-scope":"out_of_scope"};var toe=new RegExp(Ou.source,"g");var Coe=new RegExp(Ou.source,"g");var N9="https://testbot.skyramp.dev",Eo={attemptId:"v3AttemptId",deadlineAt:"v3DeadlineAt",reportUploaded:"v3ReportUploaded",recipeUploaded:"v3RecipeUploaded",recipeStatus:"v3RecipeStatus",revisionsUploaded:"v3RevisionsUploaded",cause:"v3Cause"};function F9(t,e,n){return{origin:t,idToken:e,sourceToken:n,mask:r=>Gr(r),log:r=>In(r),onTokenRefused:(r,s)=>{_9(r)&&VT.set(s,r)},onTokenGranted:r=>{VT.delete(r)}}}var VT=new Map;var dce=["setup_failed","checkout_failed","environment_unverified"];function M9(t,e){return e.getTime()>=t.getTime()}function _9(t){return t instanceof yo||t instanceof js&&t.code!=="CREDENTIALS_UNAVAILABLE"}var pce={cancelled:"Skyramp cancelled this run",expired:"this attempt passed its deadline in Skyramp",ended:"Skyramp already ended this attempt"},hce={cancelled:"attempt-cancelled",expired:"attempt-closed",ended:"attempt-closed"},fce={cancelled:"cancelled",expired:"timed_out",ended:"agent_failed"};var gce={analyze:"analyze",triage:"analyze",recommend:"recommend",generate:"generate","generate-ui":"generate","generate-unit":"generate",adapt:"generate",write:"generate",onboard:"execute",deploy:"execute","native-run":"execute",deliver:"deliver"},mce={analyze:"change analysis",recommend:"test recommendations",generate:"test generation",execute:"test execution",deliver:"opening a pull request with the tests"};function U9(){return he("skyrampAppOrigin").trim()||N9}var yce=10*6e4;var Ece={onboard:"onboard",deploy:"deploy"},Cce={plan:{stage:"validation_plan",text:"Working out what to validate, and bringing up what it needs"},write:{stage:"tests",text:"Writing and running the tests"},"generate-unit":{stage:"tests",text:"Writing unit tests"},"native-run":{stage:"tests",text:"Running the unit tests"}};async function GT(){let t=Rs(Eo.attemptId);if(!t)return;let e=Rs(Eo.reportUploaded)==="true",n=Rs(Eo.recipeUploaded)==="true",r=Rs(Eo.revisionsUploaded)==="true",s=Rs(Eo.deadlineAt),i=Rs(Eo.cause)||void 0;!i&&!e&&!n&&!r&&s&&M9(new Date(s),new Date)&&(i="timed_out");let a=sE().takeIdToken(),c=await _T({attemptId:t,reportUploaded:e,recipeUploaded:n,revisionsUploaded:r,cause:i},F9(U9(),a)),A=Rs(Eo.recipeStatus);n&&A?In(`Testbot V3: attempt ended; the setup ended ${A==="ready"?"Ready":"blocked (Needs input)"}.`):In(`Testbot V3: attempt ended; the run's outcome in Skyramp is ${c.outcome??"not final yet"}.`)}var HT=require("child_process"),Cr=Re(require("fs")),aE=Re(require("path")),cE=require("string_decoder");var L9="skyramp-testbot-state",P9=/^\$\([^)]*\)$/;function O9(t){for(let[e,n]of Object.entries(t))n!==void 0&&P9.test(n)&&delete t[e]}function $9(t){let e={},n=Cr.existsSync(t)?Cr.readFileSync(t,"utf-8"):"",r=/^([^\r\n<]+)<<(\S+)\r?\n([\s\S]*?)\r?\n\2\r?$/gm;for(let s=r.exec(n);s;s=r.exec(n))e[s[1]]=s[3];return e}function YT(t,e={}){let n=e.env??process.env;if(!mo(n))return!1;O9(n),xT(n);let r=n.AGENT_TEMPDIRECTORY||n.RUNNER_TEMP;if(r){n.RUNNER_TEMP??=r;let a=aE.join(r,L9);if(t==="main")Cr.writeFileSync(a,"",{mode:384});else for(let[c,A]of Object.entries($9(a)))n[`STATE_${c}`]=A;n.GITHUB_STATE=a;for(let[c,A]of[["GITHUB_OUTPUT","output"],["GITHUB_ENV","env"],["GITHUB_PATH","path"],["GITHUB_STEP_SUMMARY",`summary-${t}.md`]])n[c]=aE.join(r,`skyramp-testbot-${A}`),Cr.writeFileSync(n[c],"",{mode:384})}let s=e.stdout??n===process.env;s&&V9(n,e.write);let i=n.GITHUB_STEP_SUMMARY;if(s&&i){let a=e.write??(c=>Zy(c.replace(/\n$/,"")));process.once("exit",()=>{Cr.existsSync(i)&&Cr.statSync(i).size>0&&a(`${tp("task.uploadsummary",{},i)}
126
126
  `)})}return!0}function V9(t,e){let n=process.stdout.write.bind(process.stdout),r=a=>t[$u]==="1"?Ky(a,t):void n(a.command!==void 0?`${a.command}
127
127
  `:a.text??""),s=e??(a=>r({command:a.replace(/\n$/,"")})),i=e??(a=>r({text:a}));process.stdout.write=((a,...c)=>{let A=typeof a=="string"?a:Buffer.from(a).toString("utf-8"),l="";for(let h of A.split(/(?<=\n)/)){let g=h.startsWith("::")?wT(h):void 0;if(!g){l+=h;continue}l&&i(l),l="";for(let C of g)s(`${C}
128
128
  `)}return l&&i(l),c.find(h=>typeof h=="function")?.(),!0})}var G9=64*1024;function oE(t){let e=new cE.StringDecoder("utf8"),n="",r=s=>t(ep(s));return{push(s){n+=typeof s=="string"?s:e.write(s);let i=n.lastIndexOf(`