agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
13 lines • 19.1 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{n as t}from"./entities.js";import{t as n}from"./output-common.js";import{n as r,t as i}from"./color.js";import{r as a}from"./replay-divergence.js";import{n as o,t as s}from"./status-markers.js";import c from"node:fs";import l from"node:os";import u from"node:path";import{pathToFileURL as ee}from"node:url";const te=[`onSuiteStart`,`onTestStart`,`onTestStep`,`onTestResult`,`onSuiteEnd`,`getExitCode`];async function ne(e){let t=ie(e.modulePath);return oe(await re(await ae(t),e.modulePath)({spec:e.raw,modulePath:t}),e.modulePath)}function re(t,n){let r=t.createReporter??t.default??t.reporter;if(!r)throw new e(`INVALID_ARGS`,`Custom test reporter ${n} must export default, createReporter, or reporter.`);return typeof r==`function`?r:()=>r}function ie(e){if(e.startsWith(`file:`))return e;let t=e.startsWith(`~/`)?u.join(l.homedir(),e.slice(2)):e;return u.resolve(process.cwd(),t)}async function ae(t){try{return await(t.startsWith(`file:`)?import(t):import(ee(t).href))}catch(n){let r=n instanceof Error?n.message:String(n);throw new e(`INVALID_ARGS`,`Failed to load custom test reporter ${t}: ${r}`)}}function oe(t,n){if(!t||typeof t!=`object`)throw new e(`INVALID_ARGS`,`Custom test reporter ${n} must export a reporter object or factory.`);let r=t;if(typeof r.name!=`string`||r.name.trim().length===0)throw new e(`INVALID_ARGS`,`Custom test reporter ${n} must define name.`);for(let t of te)if(r[t]!==void 0&&typeof r[t]!=`function`)throw new e(`INVALID_ARGS`,`Custom test reporter ${n} ${t} must be a function.`);return r}function d(e){let t=Math.max(0,e)/1e3;return t>=10?`${t.toFixed(1)}s`:t>=1?`${t.toFixed(2)}s`:`${t.toFixed(3).replace(/0+$/,``).replace(/\.$/,``)}s`}function se(e){if(e.status===`skipped`)return[];let t=f(e);return t.length===0?[]:[e.attempts>1?`steps (attempt ${e.attempts}):`:`steps:`,...t.map(({stop:e,start:t})=>g(e,t))]}function ce(e){let t=f(e),n=t.findIndex(({stop:e})=>e.ok===!1);if(n<0)return[];let r=t.slice(Math.max(0,n-2),n+1);return[e.attempts>1?`steps (attempt ${e.attempts}):`:`steps:`,...r.map(({stop:e,start:t})=>g(e,t))]}function f(e){let t=ue(e);if(!t)return[];let n=de(t);if(n.length===0)return[];let r=[],i=[];for(let e of n){if(fe(e)){r.push(e);continue}pe(e)&&i.push({stop:e,start:le(r,e)})}return i}function le(e,t){let n=t.command,r=e.findIndex(e=>e.step===t.step&&(n===void 0||e.command===void 0||e.command===n));if(!(r<0))return e.splice(r,1)[0]}function ue(e){return e.artifactsDir?u.join(e.artifactsDir,`attempt-${e.attempts}`,`replay-timing.ndjson`):void 0}function de(e){try{return c.readFileSync(e,`utf8`).split(/\r?\n/).filter(e=>e.trim().length>0).flatMap(e=>{try{let t=JSON.parse(e);return _(t)?[t]:[]}catch{return[]}})}catch{return[]}}function fe(e){return e.type===`replay_action_start`&&p(e)&&m(e,`line`)&&h(e,`command`)&&(e.positionals===void 0||Array.isArray(e.positionals))}function pe(e){return he([e.type===`replay_action_stop`&&p(e)&&m(e,`line`)&&h(e,`command`),me(e,`ok`),m(e,`durationMs`),h(e,`errorCode`),e.resultTiming===void 0||_(e.resultTiming)])}function p(e){return typeof e.step==`number`}function m(e,t){return e[t]===void 0||typeof e[t]==`number`}function h(e,t){return e[t]===void 0||typeof e[t]==`string`}function me(e,t){return e[t]===void 0||typeof e[t]==`boolean`}function he(e){return e.every(Boolean)}function g(e,t){return` ${e.ok===!1?`[FAIL] `:e.ok===!0?``:`[info] `}${_e(t,e)}${ge(e,t)}`}function ge(e,t){let n=t?.line??e.line,r=[typeof n==`number`?`line ${n}`:``,typeof e.durationMs==`number`?d(e.durationMs):``,e.errorCode??``,e.resultTiming?`timing ${JSON.stringify(e.resultTiming)}`:``].filter(Boolean);return r.length>0?` (${r.join(`, `)})`:``}function _e(e,t){return[ve(e?.command??t.command),...(e?.positionals??[]).map(ye)].join(` `)}function ve(e){return e??`unknown`}function ye(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function _(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}const v={interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]},be=v.interval;function xe(e={}){let t=new Set,n=!1,r=0,i=0,a=()=>{t.clear(),n=!1,r=0},o=t=>{if(!e.liveProgress)return;let a=Se(i);i+=1;let o=we(t.test,e,a),s=D(n?r:0,e.columns,e.terminalReflowsOnResize!==!1);return n=!0,r=A(o),{text:`${s}${o}`,newline:!1}},s=i=>{if(Me(i.test)){let e=Ne(i.test);if(t.has(e))return;t.add(e)}let a=Ce(i.test,e);if(!a)return;let o=n?`${D(r,e.columns,e.terminalReflowsOnResize!==!1)}${a}`:a;return n=!1,r=0,{text:o,newline:!0}};return{render(e){if(e.type===`suite-start`){a();return}return e.type===`test-step`?o(e):e.type===`test-result`?s(e):void 0}}}function Se(e){return v.frames[e%v.frames.length]??v.frames[0]}function Ce(e,t={}){if(e.status===`fail`&&e.retrying)return;let n=[S(e)];return De(n,e,t),t.verbose&&n.push(...Le(e)),n.join(`
`)}function we(e,t,n){let i=e.title?.trim(),a=u.basename(e.file),o=r(process.env,process.stderr),s=Te(n,{useColor:o}),c=`${E(e,{useColor:o})}${Ee(e,{useColor:o})}`,l=`${s} `;return k(i?`${l}${k(i,Math.max(0,O(t.columns)-A(l)-A(c)))}${c}`:`${l}${a}${c}`,t.columns)}function Te(e,t={}){return t.useColor?T(e,`blue`):e}function Ee(e,t={}){let n=`${e.stepIndex??0}/${e.stepTotal??0}`,r=e.stepCommand?.trim(),i=e.stepValue?.trim();if(!t.useColor)return` [${[n,r,i].filter(Boolean).join(` `)}]`;let a=T(`[`,`dim`),o=T(`]`,`dim`);return` ${a}${[T(n,`dim`),r?T(r,`magenta`):``,i?T(i,`green`):``].filter(Boolean).join(` `)}${o}`}function De(e,t,n){if(Oe(t,n))return;let r=ke(t),i=y(t);r&&e.push(r),i&&e.push(i),b(e,t),e.push(...x(t))}function Oe(e,t){return t.verbose===!0&&e.status===`fail`}function ke(e){return e.status===`fail`&&e.title?.trim()?` file: ${u.basename(e.file)}`:void 0}function y(e){let t=e.message?.replaceAll(/\s+/g,` `).trim();if(t)return` ${e.status===`fail`?`failed at: ${t}`:t}`}function b(e,t){let n=t.hint?.replaceAll(/\s+/g,` `).trim();t.status===`fail`&&n&&e.push(` hint: ${n}`)}function x(e){if(e.status!==`fail`||e.retrying)return[];let t=[];return e.session&&t.push(` session: ${e.session}`),e.artifactsDir&&t.push(` artifacts: ${e.artifactsDir}`),t}function S(e){let t=r(process.env,process.stderr);return`${w(e)} ${C(e)}${E(e,{useColor:t})}${e.durationMs===void 0?``:` ${je(e,{useColor:t})}`}`}function C(e){let t=e.title?.trim(),n=u.basename(e.file);return t||n}function w(e){let t=o(process.env,!!process.stderr.isTTY);return e.status===`pass`?s(`pass`,{useColor:t,passFormat:e.attempt&&e.attempt>1?`yellow`:`green`}):s(e.status===`fail`?`fail`:`skip`,{useColor:t})}function T(e,t){return i(e,t,{validateStream:!1})}function E(e,t={}){if(typeof e.shardIndex!=`number`)return``;let n=typeof e.shardCount==`number`?e.shardCount:`?`,r=Ae(e),i=` [${e.shardIndex+1}/${n}${r?` ${r}`:``}]`;return t.useColor?T(i,`dim`):i}function Ae(e){return e.deviceName?.trim()||e.deviceId?.trim()||void 0}function je(e,t={}){let n=d(e.durationMs??0);return t.useColor?T(n,`yellow`):n}function Me(e){return e.status===`pass`||e.status===`skip`||e.status===`fail`&&!e.retrying}function Ne(e){let t=typeof e.shardIndex==`number`?e.shardIndex:``;return[e.status,e.index,e.total,e.file,e.title??``,t].join(`\0`)}function D(e,t,n){let r=n?Math.max(1,Math.ceil(e/O(t))):1,i=`\r\x1B[2K`;for(let e=1;e<r;e+=1)i+=`\x1B[1A\r\x1B[2K`;return i}function O(e){let t=typeof e==`function`?e():e;return typeof t==`number`&&Number.isFinite(t)&&t>0?Math.floor(t):80}function k(e,t){let n=O(t);return A(e)<=n?e:n<=0?``:n<=3?`.`.repeat(n):`${Fe(e,n-3)}...${Pe(e)?`\x1B[0m`:``}`}function A(e){let t=0;for(let n=0;n<e.length;){let r=j(e,n);if(r){n+=r.length;continue}t+=1,n+=1}return t}function Pe(e){return e.includes(`\x1B[`)}function Fe(e,t){if(t<=0)return``;let n=0,r=``;for(let i=0;i<e.length&&n<t;){let t=j(e,i);if(t){r+=t,i+=t.length;continue}r+=e[i],i+=1,n+=1}return r}function j(e,t){if(!e.startsWith(`\x1B[`,t))return null;for(let n=t+2;n<e.length;n+=1)if(Ie(e.charCodeAt(n)))return e.slice(t,n+1);return null}function Ie(e){return e>=64&&e<=126}function Le(e){return e.status!==`pass`&&e.status!==`fail`||!e.artifactsDir||!e.attempt?[]:se(e.status===`pass`?Re(e):ze(e)).map(e=>` ${e}`)}function Re(e){return{...M(e),status:`passed`,replayed:0,healed:0}}function ze(e){return{...M(e),status:`failed`,error:{code:`COMMAND_FAILED`,message:e.message??`Unknown test failure`}}}function M(e){return{file:e.file,title:e.title,durationMs:e.durationMs??0,attempts:e.attempt??1,artifactsDir:e.artifactsDir,session:e.session??``}}function N(e){return+(e.failed>0)}function Be(e){return e.status===`failed`}function P(e){return e.status===`passed`&&e.attempts>1}function F(e){let t=G(e),n=u.basename(e.file);return`${t&&t.length>0?t:n}${K(e)}`}function Ve(e){return`${G(e)??u.basename(e.file)}${K(e)}`}function I(e,t){return`artifactsDir`in e&&e.artifactsDir?`${t}: ${e.artifactsDir}`:void 0}function He(e){return G(e)?`file: ${u.basename(e.file)}`:void 0}function L(e){return e.hint?`hint: ${e.hint}`:void 0}function R(e,t){return e.diagnosticId?`${t}: ${e.diagnosticId}`:void 0}function z(e,t){return e.logPath?`${t}: ${e.logPath}`:void 0}function B(e,t,n={}){n.includeMessage&&e.push(`errorMessage: ${t.message}`),U(e,L(t)),U(e,R(t,`diagnosticId`)),U(e,z(t,`logPath`)),n.includeDetails!==!1&&V(e,t,n.detailsIndent)}function V(e,t,n){let r=t.details?JSON.stringify(t.details,null,n):void 0;r&&e.push(`details: ${r}`)}function Ue(e,t){!(`shardIndex`in t)||typeof t.shardIndex!=`number`||(e.push(`shardIndex: ${t.shardIndex}`),U(e,typeof t.shardCount==`number`?`shardCount: ${t.shardCount}`:void 0),U(e,typeof t.deviceId==`string`?`deviceId: ${t.deviceId}`:void 0),U(e,typeof t.deviceName==`string`?`deviceName: ${t.deviceName}`:void 0))}function H(e){return((`warnings`in e?e.warnings:void 0)??[]).map(e=>`warning: ${n(e)}`)}function U(e,t){t&&e.push(t)}function W(e){return(Math.max(0,e)/1e3).toFixed(3)}function We(e){return e!==void 0}function G(e){let t=e.title?.trim();return t&&t.length>0?t:void 0}function K(e){if(!(`shardIndex`in e)||typeof e.shardIndex!=`number`)return``;let t=typeof e.shardCount==`number`?e.shardCount:`?`,n=Ge(e);return` [${e.shardIndex+1}/${t}${n?` ${n}`:``}]`}function Ge(e){return(`deviceName`in e?e.deviceName?.trim():void 0)||(`deviceId`in e?e.deviceId?.trim():void 0)||void 0}function Ke(){let e,t,n,r=!1,i=(n,r)=>{o(),t=n.type===`test-step`?n:void 0,e??=xe({verbose:r.verbose,liveProgress:q(r),columns:()=>r.stderr.columns,terminalReflowsOnResize:qe()});let i=e.render(n);i&&(r.stderr.write(i.newline?`${i.text}\n`:i.text),n.type===`test-step`&&q(r)&&a(r))},a=r=>{n||!t||(n=setInterval(()=>{if(!t)return;let n=e?.render(t);n&&r.stderr.write(n.newline?`${n.text}\n`:n.text)},be),n.unref?.())},o=()=>{n&&=(clearInterval(n),void 0)},s=e=>{r||!q(e)||(e.stderr.write(`\x1B[?25l`),r=!0)},c=e=>{r&&=(e.stderr.write(`\x1B[?25h`),!1)};return{name:`default`,onSuiteStart:(e,t)=>{s(t),i({type:`suite-start`,suite:e},t)},onTestStep:(e,t)=>{i({type:`test-step`,test:e},t)},onTestResult:(e,t)=>{i({type:`test-result`,test:e},t)},onSuiteEnd:(e,n)=>{o(),t=void 0,c(n),Je(e,n)},getExitCode:N}}function q(e){return e.stderr.isTTY&&!process.env.CI}function qe(){return!process.env.TMUX&&!process.env.STY}function Je(e,t){let n=e.tests.filter(P);t.stdout.write(`${Xe(e,n.length)}\n`),Ye(e.tests,t),rt(e.tests.filter(Be),t),nt(n,t)}function Ye(e,t){let n=e.map(e=>({result:e,lines:H(e)})).filter(e=>e.lines.length>0);if(n.length!==0){t.stdout.write(`
`),t.stdout.write(`Warnings:
`);for(let{result:e,lines:r}of n)for(let n of r)t.stdout.write(` ${F(e)}: ${n}\n`)}}function Xe(e,t){let n=typeof e.durationMs==`number`?e.durationMs:void 0,i=r(process.env,process.stdout);return`Test summary: ${Ze(e.passed,{useColor:i})} ${Qe(e.total,{useColor:i})}${e.failed>0?`, ${e.failed} failed`:``}${t>0?`, ${t} flaky`:``}${n===void 0?``:` in ${$e(n,{useColor:i})}`}`}function Ze(e,t={}){let n=`${e} passed`;return t.useColor?i(n,`green`):n}function Qe(e,t={}){let n=`(${e})`;return t.useColor?i(n,`dim`):n}function $e(e,t={}){let n=d(e);return t.useColor?i(n,`yellow`):n}function et(){return r(process.env,process.stdout)?i(`✓`,`yellow`):`✓`}function tt(e){return[L(e.error),I(e,`artifacts`),z(e.error,`log`),R(e.error,`diagnostic`)].filter(We)}function nt(e,t){if(e.length!==0){t.stdout.write(`
`),t.stdout.write(`Flaky tests:
`);for(let n of e){t.stdout.write(` ${et()} ${F(n)} after ${n.attempts} attempts${ot(n)}\n`);for(let e of n.attemptFailures??[]){let n=typeof e.durationMs==`number`?` (${d(e.durationMs)})`:``;t.stdout.write(` attempt ${e.attempt} failed${n}: ${e.message}\n`)}}}}function rt(e,t){if(e.length!==0){t.stdout.write(`
`),t.stdout.write(`Failures:
`);for(let n of e)t.stdout.write(` ${F(n)}\n`),it(n,t,` `)}}function it(e,t,n){let r=He(e);r&&t.stdout.write(`${n}${r}\n`),t.stdout.write(`${n}${e.error?.message??`Unknown test failure`}\n`);for(let r of tt(e))t.stdout.write(`${n}${r}\n`);if(at(e,t,n),t.debug)for(let r of ce(e))t.stdout.write(`${n}${r}\n`)}function at(e,t,n){let r=a(e.error?.details);if(r)for(let e of r.split(`
`))t.stdout.write(`${n}${e}\n`)}function ot(e){let t=[typeof e.finalAttemptDurationMs==`number`?`passed attempt ${d(e.finalAttemptDurationMs)}`:``,e.durationMs>0?`total ${d(e.durationMs)}`:``].filter(Boolean);return t.length>0?` (${t.join(`, `)})`:``}function st(e){let t=ct(e);return{name:`junit`,onSuiteEnd:e=>lt(t,e),getExitCode:N}}function ct(t){if(t&&t.trim().length>0)return t;throw new e(`INVALID_ARGS`,`The junit test reporter requires an output path. Use --reporter junit:<path>.`)}function lt(t,n){let r=u.dirname(t);try{c.mkdirSync(r,{recursive:!0}),c.writeFileSync(t,ut(n),`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);throw new e(`COMMAND_FAILED`,`Failed to write JUnit report to ${t}: ${r}`)}}function ut(e){let t=[`<?xml version="1.0" encoding="UTF-8"?>`,`<testsuites>`,` <testsuite name="agent-device replay suite" tests="${e.total}" failures="${e.failed}" skipped="${e.skipped}" time="${W(e.durationMs)}">`];for(let n of e.tests)t.push(...dt(n));return t.push(` </testsuite>`),t.push(`</testsuites>`),`${t.join(`
`)}\n`}function dt(e){let t=J(Ve(e)),n=[` <testcase classname="${J(`${u.dirname(e.file)===`.`?e.file:u.dirname(e.file)}${K(e)}`)}" name="${t}" file="${J(e.file)}" time="${W(e.durationMs)}">`];e.status===`failed`?n.push(` <failure message="${J(e.error.message)}">${J(ft(e))}</failure>`):e.status===`skipped`&&n.push(` <skipped message="${J(e.message)}" />`);let r=pt(e);return r&&n.push(` <system-out>${J(r)}</system-out>`),n.push(` </testcase>`),n}function J(e){let n=e.replaceAll(/[^\t\n\r\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/gu,`�`);return t(n).replaceAll(` `,`	`).replaceAll(`
`,` `).replaceAll(`\r`,` `)}function ft(e){let t=[e.error.message];return B(t,e.error,{includeDetails:!1}),U(t,I(e,`artifactsDir`)),V(t,e.error,2),t.join(`
`)}function pt(e){let t=[`status: ${e.status}`,`durationMs: ${e.durationMs}`];return mt(t,e),t.join(`
`)}function mt(e,t){U(e,`attempts`in t?`attempts: ${t.attempts}`:void 0),U(e,`session`in t?`session: ${t.session}`:void 0),U(e,`replayed`in t?`replayed: ${t.replayed}`:void 0),U(e,`healed`in t?`healed: ${t.healed}`:void 0);for(let n of H(t))e.push(n);U(e,I(t,`artifactsDir`)),Ue(e,t),t.status===`failed`&&ht(e,t),U(e,P(t)?`flaky: true`:void 0)}function ht(e,t){e.push(`errorCode: ${t.error.code}`),B(e,t.error,{includeMessage:!0})}function gt(e){if(e.type===`command`)return;if(e.type===`replay-test-suite`)return{type:`suite-start`,suite:{total:e.total,runnable:e.runnable,skipped:e.skipped,artifactsDir:e.artifactsDir,shardMode:e.shardMode,shardCount:e.shardCount}};let t={file:e.file,title:e.title,index:e.index,total:e.total,attempt:e.attempt,maxAttempts:e.maxAttempts,session:e.session,artifactsDir:e.artifactsDir,shardIndex:e.shardIndex,shardCount:e.shardCount,deviceId:e.deviceId,deviceName:e.deviceName};return e.status===`start`?{type:`test-start`,test:t}:e.status===`progress`?{type:`test-step`,test:{...t,stepIndex:e.stepIndex,stepTotal:e.stepTotal,stepCommand:e.stepCommand,stepValue:e.stepValue}}:{type:`test-result`,test:{...t,status:e.status,durationMs:e.durationMs,retrying:e.retrying,message:e.message,hint:e.hint}}}function _t(e){let t=e.reporters&&e.reporters.length>0?e.reporters.map(Y):e.json?[]:[Y(`default`)];return e.reportJunit&&t.push(Y(`junit:${e.reportJunit}`)),t}function Y(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Test reporter spec cannot be empty.`);if(X(n))return{kind:`custom`,modulePath:n,raw:n};let{name:r,value:i}=vt(n);if(r==="default"){if(i!==void 0)throw new e(`INVALID_ARGS`,`The default test reporter does not accept options.`);return{kind:`builtin`,name:r,raw:n}}if(r===`junit`)return i===void 0?{kind:`builtin`,name:r,raw:n}:{kind:`builtin`,name:r,raw:n,outputPath:i};throw new e(`INVALID_ARGS`,`Unknown test reporter "${r}". Built-in reporters: default, junit:<path>. Custom reporters must be file paths.`)}function vt(e){let t=e.indexOf(`:`);return t<0?{name:e.trim()}:{name:e.slice(0,t).trim(),value:e.slice(t+1)}}function X(e){return e.startsWith(`.`)||e.startsWith(`/`)||e.startsWith(`~`)||e.startsWith(`file:`)}const yt={"suite-start":`onSuiteStart`,"test-start":`onTestStart`,"test-step":`onTestStep`,"test-result":`onTestResult`};async function bt(e){let t=_t(e);return await Promise.all(t.map(Tt))}async function xt(e,t,n){for(let r of e)await r.onSuiteEnd?.(t,n)}function St(e,t,n){let r=gt(t);if(!r)return;let i=yt[r.type];for(let t of e)try{let e=Ct(t,r,n);e instanceof Promise&&e.catch(e=>Z(t,i,n,e))}catch(e){Z(t,i,n,e)}}function Ct(e,t,n){switch(t.type){case`suite-start`:return e.onSuiteStart?.(t.suite,n);case`test-start`:return e.onTestStart?.(t.test,n);case`test-step`:return e.onTestStep?.(t.test,n);case`test-result`:return e.onTestResult?.(t.test,n)}}function Z(e,t,n,r){let i=r instanceof Error?r.message:String(r);n.stderr.write(`Reporter ${e.name} ${String(t)} failed: ${i}\n`)}function wt(t,n){let r=N(n);for(let i of t){let t=i.getExitCode?.(n);if(t!==void 0){if(!Number.isInteger(t)||t<0||t>255)throw new e(`INVALID_ARGS`,`Test reporter ${i.name} getExitCode must return an integer from 0 to 255 or undefined.`);r=Math.max(r,t)}}return r}async function Tt(e){return e.kind===`custom`?await ne(e):e.name==="default"?Ke():st(e.outputPath)}async function Et(e){let{suite:t,json:n,debug:r,verbose:i,reporter:a,reportJunit:o}=e,s=e.reporterRuntime??await Q({debug:r,verbose:i,reporter:a,reportJunit:o,json:n});await xt(s.reporters,t,s.context);let c=wt(s.reporters,t);if(n){let{printJson:e}=await import(`./json.js`);e({success:!0,data:t})}return c}async function Q(e){let t=await bt({reporters:e.reporter,reportJunit:e.reportJunit,json:e.json}),n=Dt({debug:e.debug,verbose:e.verbose});return{reporters:t,context:n,onProgress(e){St(t,e,n)}}}function Dt(e){return{debug:e.debug,verbose:e.verbose??e.debug,stdout:$(process.stdout),stderr:$(process.stderr)}}function $(e){return{isTTY:e.isTTY===!0,columns:e.columns,write:t=>e.write(t)}}export{Q as createReplayTestReporterRuntime,Et as renderReplayTestResponse};