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.
1 lines • 1.93 kB
JavaScript
import{r as e}from"./rolldown-runtime.js";import{Nr as t}from"./sdk-batch.js";import{g as n}from"./sdk-contracts.js";import"./sdk-batch-runner.js";var r=e({collectBatchStepDelivery:()=>a,reportScriptDelivery:()=>i});async function i(e,t){if(e.internal?.scriptDelivery)return await t(e);let r={nested:!1,versions:new Map,failures:new Map},i=await t({...e,internal:{...e.internal,scriptDelivery:r}});if(i.ok){for(let e of u(i.data))o(r,e);let e=n(i.data);e&&s(r,e)}if(!r.nested)return i;let a=c(r);if(a===void 0)return i;let d=l(r,a);return d?i.ok?{ok:!0,data:{...i.data,scriptDeliveryReceipt:d}}:{ok:!1,error:{...i.error,details:{...i.error.details,scriptDeliveryReceipt:d}}}:i}function a(e,r,i){let a=e.internal?.scriptDelivery;if(!a||(a.nested=!0,!i.ok))return;let c=i.data??{};for(let e of u(c))o(a,e);let l=n(c);l&&s(a,l);let d=typeof c.scriptPublicationId==`string`?c.scriptPublicationId:void 0;d&&t(r.command)===`close`&&(a.close={publicationId:d,step:r.number})}function o(e,t){let n=t?.scriptPublicationId,r=t?.scriptRevision;if(!n||typeof r!=`number`)return;let i=e.versions.get(n)?.scriptRevision;typeof i==`number`&&i>=r||e.versions.set(n,t)}function s(e,t){let n=e.failures.get(t.publicationId);n?n.push(t):e.failures.set(t.publicationId,[t])}function c(e){let t=new Set([...e.versions.keys(),...e.failures.keys()]);return e.close&&t.add(e.close.publicationId),t.size===1?[...t][0]:void 0}function l(e,t){let n=e.versions.get(t),r=e.failures.get(t)??[],i=e.close?.publicationId===t?e.close:void 0;if(!(!n&&r.length===0&&!i))return{publicationId:t,...n?{version:n}:{},...i?{close:{step:i.step}}:{},...r.length>0?{failures:r}:{}}}function u(e){return(Array.isArray(e?.artifacts)?e.artifacts:[]).filter(d)}function d(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.field===`savedScript`&&t.artifactType===`session-script`&&typeof t.scriptPublicationId==`string`&&typeof t.scriptRevision==`number`}export{r as n,a as t};