@checksum-ai/runtime 4.13.1 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -1
- package/checksum-progress-reporter.js +3 -3
- package/cli.js +145 -140
- package/index.js +105 -105
- package/package.json +1 -1
- package/test-run-monitor.js +12 -7
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
CHECKSUM_RUNTIME_BUILD_TIME=2026-08-
|
|
1
|
+
CHECKSUM_RUNTIME_BUILD_TIME=2026-08-04T19:32:23.397Z
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)},"emitEvent");var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var o=(e,t)=>m(e,"name",{value:t,configurable:!0});var C=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of M(t))!w.call(e,i)&&i!==n&&m(e,i,{get:()=>t[i],enumerable:!(r=P(t,i))||r.enumerable});return e};var I=e=>F(m({},"__esModule",{value:!0}),e);var z={};C(z,{default:()=>g});module.exports=I(z);var R=require("path");var T=o(e=>{if(e.error!=null)return"ERROR";let t=e.status_code;if(typeof t=="number"&&t>=500)return"ERROR";let n=e.exit_code;return typeof n=="number"&&n!==0?"ERROR":"INFO"},"severityFor");var y=require("fs");var b="\x1B[31m",W="\x1B[33m",_="\x1B[32m",D="\x1B[36m",O="\x1B[2m",H="\x1B[1m",u="\x1B[0m",L=o(()=>{let e=process.env.WIDE_EVENT_PRETTY;return e==="true"||e==="1"?!0:e==="false"||e==="0"?!1:process.stdout.isTTY?!0:process.env.APP_ENV==="local"},"shouldPretty"),B=new Set(["severity","message","kind","timestamp","_startedAtMs"]),U=o(e=>{let t=new WeakSet;return JSON.stringify(e,(n,r)=>{if(typeof r=="bigint")return r.toString();if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r})},"safeStringify"),N=o(e=>e==="ERROR"||e==="CRITICAL"?b:e==="WARNING"?W:_,"colorForSeverity"),$=o(e=>{let t=String(e.severity??"INFO"),n=`${N(t)}${t.padEnd(5)}${u}`,r=e.kind?`${D}${e.kind}${u}`:"",i=String(e.message??""),l=e.error&&typeof e.error=="object"?(()=>{let a=e.error;return` ${b}${a.type??"Error"}: ${a.message??""}${u}`})():"",c=["outcome","test_suite_run_id","status"],s=Object.entries(e).filter(([a,p])=>!B.has(a)&&p!=null&&a!=="error"&&typeof p!="object"),d=o(a=>{let p=c.indexOf(a);return p===-1?c.length:p},"rank"),f=s.sort(([a],[p])=>d(a)-d(p)).slice(0,8).map(([a,p])=>`${O}${a}=${u}${p}`).join(" ");return[n,H+r+u,i,f,l].filter(a=>a&&a.trim()!=="").join(" ")},"formatPretty"),j=o(e=>{let t=e.trace_id;if(typeof t!="string"||t==="")return e;let n=process.env.GCP_PROJECT_ID||process.env.GOOGLE_CLOUD_PROJECT;return n?{...e,"logging.googleapis.com/trace":`projects/${n}/traces/${t}`}:e},"withGcpTraceField"),E=o(e=>{let t=L()?$(e):U(j(e));(0,y.writeSync)(1,t+`
|
|
2
|
+
`)},"emitEvent");var x=o(e=>{(0,y.writeSync)(2,e.endsWith(`
|
|
3
3
|
`)?e:`${e}
|
|
4
|
-
`)},"writeStderrLine");var
|
|
4
|
+
`)},"writeStderrLine");var G=o(e=>{let t=e.kind??"event",n=e.outcome?` ${e.outcome}`:"",r=typeof e.duration_ms=="number"?` ${e.duration_ms}ms`:"";return`${t}${n}${r}`.trim()},"defaultMessage"),V=o((e,t,n)=>{let r=Date.now(),i={timestamp:new Date().toISOString(),kind:e,...t},l=!1,c={set(s){return Object.assign(i,s),c},emit(s){l||(l=!0,s&&Object.assign(i,s),i.duration_ms===void 0&&(i.duration_ms=Date.now()-r),n(i))}};return c},"startHandle"),Y=o((e={})=>{let t=e.decide??(()=>!0),n=e.deriveMessage??G,r=e.label??"[wide-event]",i=e.sink??(s=>E(s)),l=o(s=>{if(!t(s))return;let d={severity:T(s),message:s.message??n(s),...s};try{i(d)}catch(f){try{x(`${r} emit failed: ${String(f)}`)}catch{}}},"emit");return{emit:l,emitWideEvent:o((s,d={})=>{l({timestamp:new Date().toISOString(),kind:s,...d})},"emitWideEvent"),wideEvent:o((s,d={})=>V(s,d,l),"wideEvent"),configureSink:o(s=>{i=s},"configureSink")}},"createWideEvents"),S=o(e=>e==="true"||e==="1","truthy"),v=o(()=>S(process.env.CHECKSUM_WIDE_EVENTS)||S(process.env.WIDE_EVENT_PRETTY),"wideEventsEnabled"),A=Y({decide:o(()=>v(),"decide")}),K=A.configureSink;var h=o((e,t={})=>{A.emitWideEvent(e,t)},"emitWideEvent");var k=2e3;function q(e){switch(e){case"passed":return"passed";case"timedOut":return"timedOut";case"skipped":return"skipped";case"interrupted":return"interrupted";default:return"failed"}}o(q,"toProgressStatus");var g=class{constructor(){this.monitorPort=process.env.CHECKSUM_UPLOAD_AGENT_PORT;this.startedAt=Date.now();this.rootDir=process.cwd();this.testsById=new Map;this.lastFlushAt=0;this.sendChain=Promise.resolve()}static{o(this,"ChecksumProgressReporter")}printsToStdio(){return!1}onBegin(t,n){this.guard(()=>{t?.rootDir&&(this.rootDir=t.rootDir);for(let r of n?.allTests?.()??[])this.register(r);this.flush(!0)})}onTestBegin(t,n){this.guard(()=>{let r=this.itemFor(t);r.status="running",r.startedAt=n?.startTime?.getTime()??Date.now(),r.endedAt=null,r.durationMs=null,r.retry=n?.retry??0,this.flush()})}onTestEnd(t,n){this.guard(()=>{let r=this.itemFor(t);r.status=q(n?.status),r.endedAt=Date.now(),r.durationMs=n?.duration??null,r.retry=n?.retry??r.retry,r.startedAt??=n?.startTime?.getTime()??null,this.flush();let i=r.status==="passed"||r.status==="skipped";h("test_result",{test_suite_run_id:process.env.CHECKSUM_TEST_SUITE_ID,outcome:i?"success":"error",test_id:r.id,status:r.status,retry:r.retry,duration_ms:r.durationMs??void 0,title:r.title,file:r.file,project:r.project||void 0})})}async onEnd(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0),await this.send()}itemFor(t){return this.testsById.get(t.id)??this.register(t)}register(t){let n="";try{n=t.parent?.project?.()?.name??""}catch{}let r=t.location?.file??"";try{r&&(r=(0,R.relative)(this.rootDir,r))}catch{}let i={id:t.id,title:t.title??"",titlePath:this.titlePathOf(t),file:r,line:t.location?.line??0,project:n,status:"pending",startedAt:null,endedAt:null,durationMs:null,retry:0};return this.testsById.set(i.id,i),i}titlePathOf(t){try{return(t.titlePath?.()??[]).filter(n=>!!n)}catch{return t.title?[t.title]:[]}}snapshot(){return{schemaVersion:1,source:"playwright",startedAt:this.startedAt,updatedAt:Date.now(),tests:[...this.testsById.values()]}}flush(t=!1){if(!this.monitorPort)return;let n=Date.now()-this.lastFlushAt;if(t||n>=k){this.lastFlushAt=Date.now(),this.send();return}this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=void 0,this.lastFlushAt=Date.now(),this.send()},k-n))}send(){return this.monitorPort?(this.sendChain=this.sendChain.then(()=>this.postSnapshot()),this.sendChain):Promise.resolve()}async postSnapshot(){try{await fetch(`http://127.0.0.1:${this.monitorPort}/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"runProgress",payload:this.snapshot()})})}catch{}}guard(t){try{t()}catch{}}};
|