agentiqa 1.1.16 → 1.1.17-staging.23c02c5
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/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1552,7 +1552,7 @@ ${JSON.stringify({status:"error",summary:`Stopped: device init failed (${x.categ
|
|
|
1552
1552
|
${JSON.stringify({status:"error",summary:`Stopped: ${v.code??"network error"} on ${v.host??"target"}`,halted:!0,duration_ms:u})}
|
|
1553
1553
|
[/CHILD_RESULT]`;this.injectChildResult(e,A);return}let S={sessionId:s.session.id,id:ue("msg"),role:"system",text:`Explorer ${e} ${b} (background, ${Math.round(u/1e3)}s): ${_}`,timestamp:Date.now(),actionName:"child_completed",actionArgs:{childAgent:t,traceId:n,duration_ms:u,status:b,error:_,background:!0}};await this.baseDeps.chatRepo.addMessage(S),this.emit("message:added",{sessionId:this.sessionId,message:S});let I=`[CHILD_RESULT ${e} ${b}]
|
|
1554
1554
|
${JSON.stringify({status:b,error:_,summary:`${h?"Interrupted":m?"Timed out":"Failed"} after ${Math.round(u/1e3)}s: ${_}`,partialFindings:T,duration_ms:u})}
|
|
1555
|
-
[/CHILD_RESULT]`;this.injectChildResult(e,I)}finally{l&&clearTimeout(l),a&&this.activeChildren.delete(a);let c=`${this.sessionId}:${e}`;this.deps.computerUseService?.clearCredentials?.(c);try{await this.deps.computerUseService?.cleanupSession(c)}catch(u){this.log("warn","CoordinatorRuntime","Background child cleanupSession failed",{childSessionId:c,error:u?.message??String(u)})}}}injectChildResult(e,t){this.pendingChildResults.push({childId:e,message:t}),this.childResultResolve?(this.log("info","CoordinatorRuntime","Child result injected \u2014 loop is waiting, unblocking",{childId:e}),this.childResultResolve()):this.log("info","CoordinatorRuntime","Child result injected \u2014 loop not waiting (will be picked up by post-loop drain)",{childId:e})}countRunningBackground(){let e=0;for(let t of this.childStates.values())t.background&&t.status==="running"&&e++;return e}async acquireCapSlot(e,t){let n,s=new Promise(a=>{n=a}),o=this.capLock;this.capLock=s;let i=o!==r.INITIAL_CAP_LOCK;return await o,i&&this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:t,level:"info",message:`[parallel] ${e} acquired capLock (chained behind a previous spawn)`}),n}setChildCompleted(e,t,n,s){let o=this.childStates.get(e),i=o?.status==="running";if(o&&(o.status=t,o.endTime=Date.now(),n&&(o.result=n),s&&(o.error=s)),n?.status==="blocked"&&n.blockKind==="loop"&&(this.sessionStructuralLoopBlockCount++,this.log("warn","CoordinatorRuntime","child session loop-block recorded",{childId:e,count:this.sessionStructuralLoopBlockCount,threshold:r.SESSION_STRUCTURAL_LOOP_BLOCK_THRESHOLD,summary:n.summary?.slice(0,120)})),i){let a=this.countRunningBackground(),l=t==="failed"||t==="timed_out"?"warn":"info";this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:this.sessionId,level:l,message:`[parallel] ${e} terminal=${t} \u2014 slot freed (running=${a}/${this.maxConcurrentChildren}, pendingResults=${this.pendingChildResults.length}, waiter=${this.childResultResolve?"yes":"no"}${s?`, error="${s.slice(0,120)}"`:""})`})}}waitForChildResult(){return this.pendingChildResults.length>0?(this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:this.sessionId,level:"info",message:`[parallel] waitForChildResult short-circuit (pendingResults=${this.pendingChildResults.length}) \u2014 caller will recount`}),Promise.resolve()):new Promise(e=>{this.childResultResolve=e})}hasBackgroundWork(){return this.countRunningBackground()>0}waitForBackgroundWork(){return this.waitForChildResult()}async onIterationStart(e,t,n){let s=this.countRunningBackground();if(s>0){this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:t.id,level:"info",message:`[parallel] waiting for all ${s} children to finish (${this.pendingChildResults.length} results buffered)`});let o=[];for(;this.countRunningBackground()>0;)o.push(...this.pendingChildResults),this.pendingChildResults=[],await this.waitForChildResult();o.push(...this.pendingChildResults),this.pendingChildResults=o,this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:t.id,level:"info",message:`[parallel] all children done \u2014 ${this.pendingChildResults.length} result(s) ready`})}if(this.pendingChildResults.length>0){let o=this.pendingChildResults.reduce((i,a)=>i+a.message.length,0);this.log("info","CoordinatorRuntime","flushing_child_results",{count:this.pendingChildResults.length,totalResultChars:o,traceLengthBefore:e.length})}for(let{message:o}of this.pendingChildResults)e.push({role:"user",parts:[{text:o}]});this.pendingChildResults=[]}};var iu=class{queue=[];count;constructor(e){this.count=e}async acquire(){if(this.count>0){this.count--;return}return new Promise(e=>this.queue.push(e))}release(){let e=this.queue.shift();e?e():this.count++}},oP=["message:added","action:progress","run:started","run:completed","session:status-changed","session:error","screencast:frame","screencast:started","screencast:stopped"];function tb(r,e,t){let n=[];for(let s of oP){let o=(...i)=>{let a=i[0]??{};t({type:s,planSeq:e(),...a})};r.on(s,o),n.push({event:s,handler:o})}return n}function rb(r,e){for(let{event:t,handler:n}of e)r.removeListener(t,n)}async function au(r,e,t,n,s){if(t.length===0){let o={status:"completed",planResults:[]};return s({type:"batch:started",planCount:0,mode:n.mode}),s({type:"batch:finished",status:"completed",planResults:[]}),o}return n.mode==="sequential"?iP(r,e,t,n,s):aP(r,e,t,n,s)}async function iP(r,e,t,n,s){let{runner:o}=r,i=[],a=0,l=n.initialMemory??{},c=n.skipForwarders?[]:tb(o,()=>a,s);s({type:"batch:started",planCount:t.length,mode:"sequential"});try{for(let p=0;p<t.length;p++){let g=t[p];a=p,s({type:"batch:plan-started",planSeq:p,testPlanId:g.id,testPlanTitle:g.title});let m,b=T=>{m=T};o.on("run:completed",b);try{let T=n.planSessions?.[p]??e;await o.startRun(T,g,{suppressNotifications:!0,batchRunId:n.batchRunId,batchSeq:p,initialMemory:Object.keys(l).length>0?l:void 0,onMemoryUpdate:v=>{l=v,s({type:"batch:memory-updated",planSeq:p,memory:v})}})}finally{o.removeListener("run:completed",b)}let w=m?.run?.status??"error",_={seq:p,testPlanId:g.id,status:w,runId:m?.run?.id,memory:m?.runMemory};i.push(_),s({type:"batch:plan-completed",planSeq:p,testPlanId:g.id,status:_.status,runId:_.runId}),m?.runMemory&&Object.keys(m.runMemory).length>0&&(l=m.runMemory),p<t.length-1&&await o.resetForNextPlan({keepMemory:!0})}}finally{rb(o,c)}let u=i.some(p=>p.status!=="passed"),h=i.every(p=>p.status==="error")?"error":u?"partial":"completed",f={status:h,planResults:i};return s({type:"batch:finished",status:h,planResults:i}),f}async function aP(r,e,t,n,s){let o=Math.max(1,Math.min(n.concurrency??3,5)),i=new iu(o),a=new Array(t.length);s({type:"batch:started",planCount:t.length,mode:"parallel",concurrency:o});let l=t.map(async(f,p)=>{await i.acquire();let g=`${r.sessionId}__${p}`,m=new Vt(g,r.deps),b=n.skipForwarders?[]:tb(m,()=>p,s);s({type:"batch:plan-started",planSeq:p,testPlanId:f.id,testPlanTitle:f.title});try{let w,_=x=>{w=x};m.on("run:completed",_);try{await m.startRun(e,f,{suppressNotifications:!0,batchRunId:n.batchRunId,batchSeq:p})}finally{m.removeListener("run:completed",_)}let T=w?.run?.status??"error",v={seq:p,testPlanId:f.id,status:T,runId:w?.run?.id};a[p]=v,s({type:"batch:plan-completed",planSeq:p,testPlanId:f.id,status:v.status,runId:v.runId})}catch{let _={seq:p,testPlanId:f.id,status:"error"};a[p]=_,s({type:"batch:plan-completed",planSeq:p,testPlanId:f.id,status:"error"})}finally{rb(m,b),i.release()}});await Promise.all(l);let c=a.some(f=>f.status!=="passed"),d=a.every(f=>f.status==="error")?"error":c?"partial":"completed",h={status:d,planResults:a};return s({type:"batch:finished",status:d,planResults:a}),h}var lu=["--disable-blink-features=AutomationControlled"];function cu(r){let e=r.match(/(\d+\.\d+\.\d+\.\d+)/),t=e?e[1]:"131.0.0.0";return`Mozilla/5.0 (${process.platform==="darwin"?"Macintosh; Intel Mac OS X 10_15_7":process.platform==="win32"?"Windows NT 10.0; Win64; x64":"X11; Linux x86_64"}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${t} Safari/537.36 Agentiqa`}async function uu(r){await r.addInitScript(()=>{Object.defineProperty(navigator,"plugins",{get:()=>{let s=[{name:"PDF Viewer",filename:"internal-pdf-viewer",description:"Portable Document Format"},{name:"Chrome PDF Viewer",filename:"internal-pdf-viewer",description:""},{name:"Chromium PDF Viewer",filename:"internal-pdf-viewer",description:""}];return s.namedItem=o=>s.find(i=>i.name===o)??null,s.refresh=()=>{},s}});let e=()=>{for(let s of Object.keys(window))if(s.startsWith("cdc_")||s.startsWith("__webdriver"))try{delete window[s]}catch(o){if(!(o instanceof TypeError))throw o}};e(),setTimeout(e,0);let t=window.navigator.permissions,n=t?.query;t&&n&&(t.query=s=>s.name==="notifications"?Promise.resolve({state:"prompt",onchange:null}):n.call(window.navigator.permissions,s))})}function lP(r,e,t){return typeof r=="number"&&Number.isFinite(r)&&r>=0?e===void 0?r:Math.max(r,e):e===void 0?0:e+t}function an(r){let e=1e3/Math.max(1,r.framesPerSecond),t,n,s,o=!1,i=a=>{if(!(!t||s===void 0))for(;s<=a;)r.writeFrame(t),s+=e};return{addFrame(a,l){if(o)return;let c=lP(l,n,e);if(n===void 0){r.writeFrame(a),t=a,n=c,s=c+e;return}i(c),t=a,n=c},flush(){o||(o=!0,!(!t||n===void 0||s===void 0||s-n>e/2)&&r.writeFrame(t))}}}import{z as Ur}from"zod/v4";import{z as Uo}from"zod/v4";import{z as du}from"zod/v4";import{z as te}from"zod/v4";import{z as st}from"zod/v4";import{z as Es}from"zod/v4";import{z as SP}from"zod/v4";import{z as jo}from"zod/v4";import{z as EP}from"zod/v4";import{z as pu}from"zod/v4";import{z as CP}from"zod/v4";import{z as hu}from"zod/v4";import{z as On}from"zod/v4";import{z as lt}from"zod/v4";var cP="3.0.37",uP=Z(()=>Q(Uo.object({error:Uo.object({code:Uo.number().nullable(),message:Uo.string(),status:Uo.string()})}))),Pn=Et({errorSchema:uP,errorToMessage:r=>r.error.message}),dP=Z(()=>Q(du.object({outputDimensionality:du.number().optional(),taskType:du.enum(["SEMANTIC_SIMILARITY","CLASSIFICATION","CLUSTERING","RETRIEVAL_DOCUMENT","RETRIEVAL_QUERY","QUESTION_ANSWERING","FACT_VERIFICATION","CODE_RETRIEVAL_QUERY"]).optional()}))),pP=class{constructor(r,e){this.specificationVersion="v3",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=r,this.config=e}get provider(){return this.config.provider}async doEmbed({values:r,headers:e,abortSignal:t,providerOptions:n}){let s=await kt({provider:"google",providerOptions:n,schema:dP});if(r.length>this.maxEmbeddingsPerCall)throw new Np({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:r});let o=dt(await qe(this.config.headers),e);if(r.length===1){let{responseHeaders:c,value:u,rawValue:d}=await at({url:`${this.config.baseURL}/models/${this.modelId}:embedContent`,headers:o,body:{model:`models/${this.modelId}`,content:{parts:[{text:r[0]}]},outputDimensionality:s?.outputDimensionality,taskType:s?.taskType},failedResponseHandler:Pn,successfulResponseHandler:pt(mP),abortSignal:t,fetch:this.config.fetch});return{warnings:[],embeddings:[u.embedding.values],usage:void 0,response:{headers:c,body:d}}}let{responseHeaders:i,value:a,rawValue:l}=await at({url:`${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,headers:o,body:{requests:r.map(c=>({model:`models/${this.modelId}`,content:{role:"user",parts:[{text:c}]},outputDimensionality:s?.outputDimensionality,taskType:s?.taskType}))},failedResponseHandler:Pn,successfulResponseHandler:pt(hP),abortSignal:t,fetch:this.config.fetch});return{warnings:[],embeddings:a.embeddings.map(c=>c.values),usage:void 0,response:{headers:i,body:l}}}},hP=Z(()=>Q(Ur.object({embeddings:Ur.array(Ur.object({values:Ur.array(Ur.number())}))}))),mP=Z(()=>Q(Ur.object({embedding:Ur.object({values:Ur.array(Ur.number())})})));function nb(r){var e,t,n,s;if(r==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let o=(e=r.promptTokenCount)!=null?e:0,i=(t=r.candidatesTokenCount)!=null?t:0,a=(n=r.cachedContentTokenCount)!=null?n:0,l=(s=r.thoughtsTokenCount)!=null?s:0;return{inputTokens:{total:o,noCache:o-a,cacheRead:a,cacheWrite:void 0},outputTokens:{total:i+l,text:i,reasoning:l},raw:r}}function yr(r,e=!0){if(r==null)return;if(fP(r))return e?void 0:typeof r=="object"&&r.description?{type:"object",description:r.description}:{type:"object"};if(typeof r=="boolean")return{type:"boolean",properties:{}};let{type:t,description:n,required:s,properties:o,items:i,allOf:a,anyOf:l,oneOf:c,format:u,const:d,minLength:h,enum:f}=r,p={};if(n&&(p.description=n),s&&(p.required=s),u&&(p.format=u),d!==void 0&&(p.enum=[d]),t)if(Array.isArray(t)){let g=t.includes("null"),m=t.filter(b=>b!=="null");m.length===0?p.type="null":(p.anyOf=m.map(b=>({type:b})),g&&(p.nullable=!0))}else p.type=t;if(f!==void 0&&(p.enum=f),o!=null&&(p.properties=Object.entries(o).reduce((g,[m,b])=>(g[m]=yr(b,!1),g),{})),i&&(p.items=Array.isArray(i)?i.map(g=>yr(g,!1)):yr(i,!1)),a&&(p.allOf=a.map(g=>yr(g,!1))),l)if(l.some(g=>typeof g=="object"&&g?.type==="null")){let g=l.filter(m=>!(typeof m=="object"&&m?.type==="null"));if(g.length===1){let m=yr(g[0],!1);typeof m=="object"&&(p.nullable=!0,Object.assign(p,m))}else p.anyOf=g.map(m=>yr(m,!1)),p.nullable=!0}else p.anyOf=l.map(g=>yr(g,!1));return c&&(p.oneOf=c.map(g=>yr(g,!1))),h!==void 0&&(p.minLength=h),p}function fP(r){return r!=null&&typeof r=="object"&&r.type==="object"&&(r.properties==null||Object.keys(r.properties).length===0)&&!r.additionalProperties}function gP(r,e){var t,n,s;let o=[],i=[],a=!0,l=(t=e?.isGemmaModel)!=null?t:!1,c=(n=e?.providerOptionsName)!=null?n:"google";for(let{role:u,content:d}of r)switch(u){case"system":{if(!a)throw new Ft({functionality:"system messages are only supported at the beginning of the conversation"});o.push({text:d});break}case"user":{a=!1;let h=[];for(let f of d)switch(f.type){case"text":{h.push({text:f.text});break}case"file":{let p=f.mediaType==="image/*"?"image/jpeg":f.mediaType;h.push(f.data instanceof URL?{fileData:{mimeType:p,fileUri:f.data.toString()}}:{inlineData:{mimeType:p,data:Zr(f.data)}});break}}i.push({role:"user",parts:h});break}case"assistant":{a=!1,i.push({role:"model",parts:d.map(h=>{var f,p,g;let m=(g=(f=h.providerOptions)==null?void 0:f[c])!=null?g:c!=="google"?(p=h.providerOptions)==null?void 0:p.google:void 0,b=m?.thoughtSignature!=null?String(m.thoughtSignature):void 0;switch(h.type){case"text":return h.text.length===0?void 0:{text:h.text,thoughtSignature:b};case"reasoning":return h.text.length===0?void 0:{text:h.text,thought:!0,thoughtSignature:b};case"file":{if(h.data instanceof URL)throw new Ft({functionality:"File data URLs in assistant messages are not supported"});return{inlineData:{mimeType:h.mediaType,data:Zr(h.data)},thoughtSignature:b}}case"tool-call":return{functionCall:{name:h.toolName,args:h.input},thoughtSignature:b}}}).filter(h=>h!==void 0)});break}case"tool":{a=!1;let h=[];for(let f of d){if(f.type==="tool-approval-response")continue;let p=f.output;if(p.type==="content")for(let g of p.value)switch(g.type){case"text":h.push({functionResponse:{name:f.toolName,response:{name:f.toolName,content:g.text}}});break;case"image-data":h.push({inlineData:{mimeType:g.mediaType,data:g.data}},{text:"Tool executed successfully and returned this image as a response"});break;default:h.push({text:JSON.stringify(g)});break}else h.push({functionResponse:{name:f.toolName,response:{name:f.toolName,content:p.type==="execution-denied"?(s=p.reason)!=null?s:"Tool execution denied.":p.value}}})}i.push({role:"user",parts:h});break}}if(l&&o.length>0&&i.length>0&&i[0].role==="user"){let u=o.map(d=>d.text).join(`
|
|
1555
|
+
[/CHILD_RESULT]`;this.injectChildResult(e,I)}finally{l&&clearTimeout(l),a&&this.activeChildren.delete(a);let c=`${this.sessionId}:${e}`;this.deps.computerUseService?.clearCredentials?.(c);try{await this.deps.computerUseService?.cleanupSession(c)}catch(u){this.log("warn","CoordinatorRuntime","Background child cleanupSession failed",{childSessionId:c,error:u?.message??String(u)})}}}injectChildResult(e,t){this.pendingChildResults.push({childId:e,message:t}),this.childResultResolve?(this.log("info","CoordinatorRuntime","Child result injected \u2014 loop is waiting, unblocking",{childId:e}),this.childResultResolve()):this.log("info","CoordinatorRuntime","Child result injected \u2014 loop not waiting (will be picked up by post-loop drain)",{childId:e})}countRunningBackground(){let e=0;for(let t of this.childStates.values())t.background&&t.status==="running"&&e++;return e}async acquireCapSlot(e,t){let n,s=new Promise(a=>{n=a}),o=this.capLock;this.capLock=s;let i=o!==r.INITIAL_CAP_LOCK;return await o,i&&this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:t,level:"info",message:`[parallel] ${e} acquired capLock (chained behind a previous spawn)`}),n}setChildCompleted(e,t,n,s){let o=this.childStates.get(e),i=o?.status==="running";if(o&&(o.status=t,o.endTime=Date.now(),n&&(o.result=n),s&&(o.error=s)),n?.status==="blocked"&&n.blockKind==="loop"&&(this.sessionStructuralLoopBlockCount++,this.log("warn","CoordinatorRuntime","child session loop-block recorded",{childId:e,count:this.sessionStructuralLoopBlockCount,threshold:r.SESSION_STRUCTURAL_LOOP_BLOCK_THRESHOLD,summary:n.summary?.slice(0,120)})),i){let a=this.countRunningBackground(),l=t==="failed"||t==="timed_out"?"warn":"info";this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:this.sessionId,level:l,message:`[parallel] ${e} terminal=${t} \u2014 slot freed (running=${a}/${this.maxConcurrentChildren}, pendingResults=${this.pendingChildResults.length}, waiter=${this.childResultResolve?"yes":"no"}${s?`, error="${s.slice(0,120)}"`:""})`})}}waitForChildResult(){return this.pendingChildResults.length>0?(this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:this.sessionId,level:"info",message:`[parallel] waitForChildResult short-circuit (pendingResults=${this.pendingChildResults.length}) \u2014 caller will recount`}),Promise.resolve()):new Promise(e=>{this.childResultResolve=e})}hasBackgroundWork(){return this.countRunningBackground()>0}waitForBackgroundWork(){return this.waitForChildResult()}async onIterationStart(e,t,n){let s=this.countRunningBackground();if(s>0){this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:t.id,level:"info",message:`[parallel] waiting for all ${s} children to finish (${this.pendingChildResults.length} results buffered)`});let o=[];for(;this.countRunningBackground()>0;)o.push(...this.pendingChildResults),this.pendingChildResults=[],await this.waitForChildResult();o.push(...this.pendingChildResults),this.pendingChildResults=o,this.baseDeps.sink.emit({kind:"log",ts:Date.now(),sessionId:t.id,level:"info",message:`[parallel] all children done \u2014 ${this.pendingChildResults.length} result(s) ready`})}if(this.pendingChildResults.length>0){let o=this.pendingChildResults.reduce((i,a)=>i+a.message.length,0);this.log("info","CoordinatorRuntime","flushing_child_results",{count:this.pendingChildResults.length,totalResultChars:o,traceLengthBefore:e.length})}for(let{message:o}of this.pendingChildResults)e.push({role:"user",parts:[{text:o}]});this.pendingChildResults=[]}};var iu=class{queue=[];count;constructor(e){this.count=e}async acquire(){if(this.count>0){this.count--;return}return new Promise(e=>this.queue.push(e))}release(){let e=this.queue.shift();e?e():this.count++}},oP=["message:added","action:progress","run:started","run:completed","session:status-changed","session:error","screencast:frame","screencast:started","screencast:stopped"];function tb(r,e,t){let n=[];for(let s of oP){let o=(...i)=>{let a=i[0]??{};t({type:s,planSeq:e(),...a})};r.on(s,o),n.push({event:s,handler:o})}return n}function rb(r,e){for(let{event:t,handler:n}of e)r.removeListener(t,n)}async function au(r,e,t,n,s){if(t.length===0){let o={status:"completed",planResults:[]};return s({type:"batch:started",planCount:0,mode:n.mode}),s({type:"batch:finished",status:"completed",planResults:[]}),o}return n.mode==="sequential"?iP(r,e,t,n,s):aP(r,e,t,n,s)}async function iP(r,e,t,n,s){let{runner:o}=r,i=[],a=0,l=n.initialMemory??{},c=n.skipForwarders?[]:tb(o,()=>a,s);s({type:"batch:started",planCount:t.length,mode:"sequential"});try{for(let p=0;p<t.length;p++){let g=t[p];a=p,s({type:"batch:plan-started",planSeq:p,testPlanId:g.id,testPlanTitle:g.title});let m,b=T=>{m=T};o.on("run:completed",b);try{let T=n.planSessions?.[p]??e;await o.startRun(T,g,{suppressNotifications:!0,batchRunId:n.batchRunId,batchSeq:p,initialMemory:Object.keys(l).length>0?l:void 0,onMemoryUpdate:v=>{l=v,s({type:"batch:memory-updated",planSeq:p,memory:v})}})}finally{o.removeListener("run:completed",b)}let w=m?.run?.status??"error",_={seq:p,testPlanId:g.id,status:w,runId:m?.run?.id,memory:m?.runMemory};i.push(_),s({type:"batch:plan-completed",planSeq:p,testPlanId:g.id,status:_.status,runId:_.runId}),m?.runMemory&&Object.keys(m.runMemory).length>0&&(l=m.runMemory),p<t.length-1&&await o.resetForNextPlan({keepMemory:!0})}}finally{rb(o,c)}let u=i.some(p=>p.status!=="passed"),h=i.every(p=>p.status==="error")?"error":u?"partial":"completed",f={status:h,planResults:i};return s({type:"batch:finished",status:h,planResults:i}),f}async function aP(r,e,t,n,s){let o=Math.max(1,Math.min(n.concurrency??3,5)),i=new iu(o),a=new Array(t.length);s({type:"batch:started",planCount:t.length,mode:"parallel",concurrency:o});let l=t.map(async(f,p)=>{await i.acquire();let g=`${r.sessionId}:child-${p}`,m=new Vt(g,r.deps),b=n.skipForwarders?[]:tb(m,()=>p,s);s({type:"batch:plan-started",planSeq:p,testPlanId:f.id,testPlanTitle:f.title});try{let w,_=x=>{w=x};m.on("run:completed",_);try{let x=n.planSessions?.[p]??{...e,id:g};await m.startRun(x,f,{suppressNotifications:!0,batchRunId:n.batchRunId,batchSeq:p})}finally{m.removeListener("run:completed",_)}let T=w?.run?.status??"error",v={seq:p,testPlanId:f.id,status:T,runId:w?.run?.id};a[p]=v,s({type:"batch:plan-completed",planSeq:p,testPlanId:f.id,status:v.status,runId:v.runId})}catch{let _={seq:p,testPlanId:f.id,status:"error"};a[p]=_,s({type:"batch:plan-completed",planSeq:p,testPlanId:f.id,status:"error"})}finally{rb(m,b),i.release()}});await Promise.all(l);let c=a.some(f=>f.status!=="passed"),d=a.every(f=>f.status==="error")?"error":c?"partial":"completed",h={status:d,planResults:a};return s({type:"batch:finished",status:d,planResults:a}),h}var lu=["--disable-blink-features=AutomationControlled"];function cu(r){let e=r.match(/(\d+\.\d+\.\d+\.\d+)/),t=e?e[1]:"131.0.0.0";return`Mozilla/5.0 (${process.platform==="darwin"?"Macintosh; Intel Mac OS X 10_15_7":process.platform==="win32"?"Windows NT 10.0; Win64; x64":"X11; Linux x86_64"}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${t} Safari/537.36 Agentiqa`}async function uu(r){await r.addInitScript(()=>{Object.defineProperty(navigator,"plugins",{get:()=>{let s=[{name:"PDF Viewer",filename:"internal-pdf-viewer",description:"Portable Document Format"},{name:"Chrome PDF Viewer",filename:"internal-pdf-viewer",description:""},{name:"Chromium PDF Viewer",filename:"internal-pdf-viewer",description:""}];return s.namedItem=o=>s.find(i=>i.name===o)??null,s.refresh=()=>{},s}});let e=()=>{for(let s of Object.keys(window))if(s.startsWith("cdc_")||s.startsWith("__webdriver"))try{delete window[s]}catch(o){if(!(o instanceof TypeError))throw o}};e(),setTimeout(e,0);let t=window.navigator.permissions,n=t?.query;t&&n&&(t.query=s=>s.name==="notifications"?Promise.resolve({state:"prompt",onchange:null}):n.call(window.navigator.permissions,s))})}function lP(r,e,t){return typeof r=="number"&&Number.isFinite(r)&&r>=0?e===void 0?r:Math.max(r,e):e===void 0?0:e+t}function an(r){let e=1e3/Math.max(1,r.framesPerSecond),t,n,s,o=!1,i=a=>{if(!(!t||s===void 0))for(;s<=a;)r.writeFrame(t),s+=e};return{addFrame(a,l){if(o)return;let c=lP(l,n,e);if(n===void 0){r.writeFrame(a),t=a,n=c,s=c+e;return}i(c),t=a,n=c},flush(){o||(o=!0,!(!t||n===void 0||s===void 0||s-n>e/2)&&r.writeFrame(t))}}}import{z as Ur}from"zod/v4";import{z as Uo}from"zod/v4";import{z as du}from"zod/v4";import{z as te}from"zod/v4";import{z as st}from"zod/v4";import{z as Es}from"zod/v4";import{z as SP}from"zod/v4";import{z as jo}from"zod/v4";import{z as EP}from"zod/v4";import{z as pu}from"zod/v4";import{z as CP}from"zod/v4";import{z as hu}from"zod/v4";import{z as On}from"zod/v4";import{z as lt}from"zod/v4";var cP="3.0.37",uP=Z(()=>Q(Uo.object({error:Uo.object({code:Uo.number().nullable(),message:Uo.string(),status:Uo.string()})}))),Pn=Et({errorSchema:uP,errorToMessage:r=>r.error.message}),dP=Z(()=>Q(du.object({outputDimensionality:du.number().optional(),taskType:du.enum(["SEMANTIC_SIMILARITY","CLASSIFICATION","CLUSTERING","RETRIEVAL_DOCUMENT","RETRIEVAL_QUERY","QUESTION_ANSWERING","FACT_VERIFICATION","CODE_RETRIEVAL_QUERY"]).optional()}))),pP=class{constructor(r,e){this.specificationVersion="v3",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=r,this.config=e}get provider(){return this.config.provider}async doEmbed({values:r,headers:e,abortSignal:t,providerOptions:n}){let s=await kt({provider:"google",providerOptions:n,schema:dP});if(r.length>this.maxEmbeddingsPerCall)throw new Np({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:r});let o=dt(await qe(this.config.headers),e);if(r.length===1){let{responseHeaders:c,value:u,rawValue:d}=await at({url:`${this.config.baseURL}/models/${this.modelId}:embedContent`,headers:o,body:{model:`models/${this.modelId}`,content:{parts:[{text:r[0]}]},outputDimensionality:s?.outputDimensionality,taskType:s?.taskType},failedResponseHandler:Pn,successfulResponseHandler:pt(mP),abortSignal:t,fetch:this.config.fetch});return{warnings:[],embeddings:[u.embedding.values],usage:void 0,response:{headers:c,body:d}}}let{responseHeaders:i,value:a,rawValue:l}=await at({url:`${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,headers:o,body:{requests:r.map(c=>({model:`models/${this.modelId}`,content:{role:"user",parts:[{text:c}]},outputDimensionality:s?.outputDimensionality,taskType:s?.taskType}))},failedResponseHandler:Pn,successfulResponseHandler:pt(hP),abortSignal:t,fetch:this.config.fetch});return{warnings:[],embeddings:a.embeddings.map(c=>c.values),usage:void 0,response:{headers:i,body:l}}}},hP=Z(()=>Q(Ur.object({embeddings:Ur.array(Ur.object({values:Ur.array(Ur.number())}))}))),mP=Z(()=>Q(Ur.object({embedding:Ur.object({values:Ur.array(Ur.number())})})));function nb(r){var e,t,n,s;if(r==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let o=(e=r.promptTokenCount)!=null?e:0,i=(t=r.candidatesTokenCount)!=null?t:0,a=(n=r.cachedContentTokenCount)!=null?n:0,l=(s=r.thoughtsTokenCount)!=null?s:0;return{inputTokens:{total:o,noCache:o-a,cacheRead:a,cacheWrite:void 0},outputTokens:{total:i+l,text:i,reasoning:l},raw:r}}function yr(r,e=!0){if(r==null)return;if(fP(r))return e?void 0:typeof r=="object"&&r.description?{type:"object",description:r.description}:{type:"object"};if(typeof r=="boolean")return{type:"boolean",properties:{}};let{type:t,description:n,required:s,properties:o,items:i,allOf:a,anyOf:l,oneOf:c,format:u,const:d,minLength:h,enum:f}=r,p={};if(n&&(p.description=n),s&&(p.required=s),u&&(p.format=u),d!==void 0&&(p.enum=[d]),t)if(Array.isArray(t)){let g=t.includes("null"),m=t.filter(b=>b!=="null");m.length===0?p.type="null":(p.anyOf=m.map(b=>({type:b})),g&&(p.nullable=!0))}else p.type=t;if(f!==void 0&&(p.enum=f),o!=null&&(p.properties=Object.entries(o).reduce((g,[m,b])=>(g[m]=yr(b,!1),g),{})),i&&(p.items=Array.isArray(i)?i.map(g=>yr(g,!1)):yr(i,!1)),a&&(p.allOf=a.map(g=>yr(g,!1))),l)if(l.some(g=>typeof g=="object"&&g?.type==="null")){let g=l.filter(m=>!(typeof m=="object"&&m?.type==="null"));if(g.length===1){let m=yr(g[0],!1);typeof m=="object"&&(p.nullable=!0,Object.assign(p,m))}else p.anyOf=g.map(m=>yr(m,!1)),p.nullable=!0}else p.anyOf=l.map(g=>yr(g,!1));return c&&(p.oneOf=c.map(g=>yr(g,!1))),h!==void 0&&(p.minLength=h),p}function fP(r){return r!=null&&typeof r=="object"&&r.type==="object"&&(r.properties==null||Object.keys(r.properties).length===0)&&!r.additionalProperties}function gP(r,e){var t,n,s;let o=[],i=[],a=!0,l=(t=e?.isGemmaModel)!=null?t:!1,c=(n=e?.providerOptionsName)!=null?n:"google";for(let{role:u,content:d}of r)switch(u){case"system":{if(!a)throw new Ft({functionality:"system messages are only supported at the beginning of the conversation"});o.push({text:d});break}case"user":{a=!1;let h=[];for(let f of d)switch(f.type){case"text":{h.push({text:f.text});break}case"file":{let p=f.mediaType==="image/*"?"image/jpeg":f.mediaType;h.push(f.data instanceof URL?{fileData:{mimeType:p,fileUri:f.data.toString()}}:{inlineData:{mimeType:p,data:Zr(f.data)}});break}}i.push({role:"user",parts:h});break}case"assistant":{a=!1,i.push({role:"model",parts:d.map(h=>{var f,p,g;let m=(g=(f=h.providerOptions)==null?void 0:f[c])!=null?g:c!=="google"?(p=h.providerOptions)==null?void 0:p.google:void 0,b=m?.thoughtSignature!=null?String(m.thoughtSignature):void 0;switch(h.type){case"text":return h.text.length===0?void 0:{text:h.text,thoughtSignature:b};case"reasoning":return h.text.length===0?void 0:{text:h.text,thought:!0,thoughtSignature:b};case"file":{if(h.data instanceof URL)throw new Ft({functionality:"File data URLs in assistant messages are not supported"});return{inlineData:{mimeType:h.mediaType,data:Zr(h.data)},thoughtSignature:b}}case"tool-call":return{functionCall:{name:h.toolName,args:h.input},thoughtSignature:b}}}).filter(h=>h!==void 0)});break}case"tool":{a=!1;let h=[];for(let f of d){if(f.type==="tool-approval-response")continue;let p=f.output;if(p.type==="content")for(let g of p.value)switch(g.type){case"text":h.push({functionResponse:{name:f.toolName,response:{name:f.toolName,content:g.text}}});break;case"image-data":h.push({inlineData:{mimeType:g.mediaType,data:g.data}},{text:"Tool executed successfully and returned this image as a response"});break;default:h.push({text:JSON.stringify(g)});break}else h.push({functionResponse:{name:f.toolName,response:{name:f.toolName,content:p.type==="execution-denied"?(s=p.reason)!=null?s:"Tool execution denied.":p.value}}})}i.push({role:"user",parts:h});break}}if(l&&o.length>0&&i.length>0&&i[0].role==="user"){let u=o.map(d=>d.text).join(`
|
|
1556
1556
|
|
|
1557
1557
|
`);i[0].parts.unshift({text:u+`
|
|
1558
1558
|
|