agent-device 0.21.9 → 0.21.11
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/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.9.apk → agent-device-android-ime-helper-0.21.11.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.11.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.9.manifest.json → agent-device-android-ime-helper-0.21.11.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.9.apk → agent-device-android-snapshot-helper-0.21.11.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.11.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.9.manifest.json → agent-device-android-snapshot-helper-0.21.11.manifest.json} +6 -6
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +2 -0
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-resolution.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/cli.js +2 -2
- package/dist/src/command-tools.js +1 -1
- package/dist/src/debug-symbols-facade.js +1 -1
- package/dist/src/device-claim-rule.js +2 -2
- package/dist/src/device-session.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor.js +1 -1
- package/dist/src/interactor2.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/mechanics.js +1 -1
- package/dist/src/open-target-resolution.js +1 -1
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/registry.js +23 -23
- package/dist/src/replay.js +1 -1
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runtime4.js +1 -1
- package/dist/src/screenshot-result.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/session-store.js +1 -1
- package/dist/src/session2.js +1 -1
- package/dist/src/snapshot-diagnostics.js +1 -1
- package/dist/src/stop-sequence.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.9.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.9.apk.sha256 +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,D as t,L as n,r,z as i}from"./sdk-contracts.js";import{g as a,m as o}from"./sdk-batch-runner.js";import{i as s,t as c}from"./sdk-device.js";import{S as l,c as u,d,p as f,w as ee}from"./sdk-batch.js";import{t as te}from"./back-mode.js";import{t as ne}from"./session.js";import{C as re,S as p,_ as m,b as ie,g as h,h as g,y as ae}from"./registry.js";import{n as oe}from"./success-text.js";import{t as se}from"./output-common.js";import"./device.js";import{r as ce,t as le}from"./device-rotation.js";import{t as ue}from"./tv-remote.js";import{i as de,n as _,r as fe,t as v}from"./command-metadata.js";import{r as pe}from"./replay-divergence.js";import{n as me,t as he}from"./cli-output.js";import{r as ge,t as _e}from"./recording-stop-observation.js";import{t as ve}from"./fold-runtime.js";import{n as ye}from"./error.js";import{n as be,r as xe,t as Se}from"./cli-config.js";import{n as Ce}from"./result-serialization.js";const y=[`simulator`,`emulator`,`device`];function b(e){return{type:`number`,...e?{description:e}:{}}}function x(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function S(e){return{type:`string`,const:e}}function C(e){return{type:[`string`,`null`],...e?{description:e}:{}}}function w(e,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}const T={type:`array`,items:{type:`string`}},E=w({wallClockMs:b(`Total wall-clock time for the request in milliseconds.`),runnerRoundTrips:b(`Number of real runner round-trips made while serving the request.`),nodeCount:b(`Number of nodes in the original node tree when the response carries one.`)},[`wallClockMs`,`runnerRoundTrips`]),D=w({field:m(),artifactType:m(),path:m(),localPath:m(),fileName:m()},[`field`]);function O(e={}){let t=e.properties??{},n=e.required??[];return w({targetKind:x([`point`,`ref`,`selector`],`Resolved interaction target kind.`),x:b(`Resolved interaction x coordinate when available.`),y:b(`Resolved interaction y coordinate when available.`),referenceWidth:b(`Reference frame width for visualizing the interaction point.`),referenceHeight:b(`Reference frame height for visualizing the interaction point.`),ref:m(`Snapshot ref without the @ prefix when the target was an @ref.`),selector:m(`Selector expression when the target was a selector.`),selectorChain:T,refLabel:m(),targetHittable:g(),hint:m(),warning:m(),message:m(),evidence:j,resolution:we,cost:E,maestroNonHittableCoordinateFallbackAllowed:g(`Whether the direct iOS Maestro coordinate fallback was allowed for this selector.`),maestroNonHittableCoordinateFallbackUsed:g(`Whether the direct iOS Maestro coordinate fallback was actually used.`),maestroFallbackReason:S(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const k=w({diagnosticRef:m(`Opaque non-@ diagnostic token. Never a snapshot ref: not issued via refsGeneration and cannot be pinned or reused as an @ref target. UTF-8 truncated to 256 bytes.`),role:m(`UTF-8 truncated to 256 bytes.`),label:m(`UTF-8 truncated to 256 bytes.`)},[`diagnosticRef`]),we={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[w({source:S(`runtime`),phase:S(`pre-action`),kind:S(`unique`)},[`source`,`phase`,`kind`]),w({source:S(`runtime`),phase:S(`pre-action`),kind:S(`disambiguated`),matchCount:b(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:k,tiebreak:x([`visible`,`deepest`,`smallest-area`,`structural-equivalence`],`The comparison that decided the winner.`),alternatives:{type:`array`,description:`At most 5 losing candidates, document order. Present at default/full response levels and omitted in digest. The winner is never included.`,items:k}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),w({source:S(`ref`),phase:S(`pre-action`),kind:S(`exact`)},[`source`,`phase`,`kind`]),w({source:S(`ref`),phase:S(`pre-action`),kind:S(`label-fallback`)},[`source`,`phase`,`kind`]),w({source:S(`direct-ios`),kind:S(`not-observed`)},[`source`,`kind`])]},A=w({from:m(`Surface the pre-action baseline described: a host bundle id, or app.`),to:m(`Surface the post-action capture describes: a host bundle id, or app.`),disclosure:m(`Agent-facing sentence explaining the surface transition.`)},[`from`,`to`,`disclosure`],`Present when an in-place system surface (web sign-in or Apple Pay sheet) was presented over the app, or left it.`),j=w({foregroundApp:m(`Foreground app bundle id or name, when the capture carries it.`),nodeCount:b(`Node count in the post-action interactive-only capture.`),interactiveNodeCount:b(`Subset of nodeCount the platform reports as hittable.`),digest:m(`Order-independent digest of the post-action node multiset.`),changedFromBefore:g(`Whether the post-action digest differs from the pre-action capture digest. false is evidence, not failure. With surfaceChange present, no digest comparison is made: it reports that surface transition.`),surfaceChange:A},[`nodeCount`,`interactiveNodeCount`,`digest`,`changedFromBefore`]),Te=w({settled:g(`Whether the UI held the quiet window before the deadline. false is advisory, not failure.`),waitedMs:b(),captures:b(),quietMs:b(),timeoutMs:b(),refsGeneration:b(`Snapshot generation of the stored settled tree; refs on added diff lines were minted from it.`),refs:{type:`array`,items:w({ref:m(`Plain ref body (e12) minted from the stored settled tree.`)},[`ref`])},surfaceChange:A,diff:w({summary:w({additions:b(),removals:b(),unchanged:b()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:w({kind:x([`added`,`removed`]),text:m(),ref:m(`Plain ref body (e12) for added lines.`)},[`kind`,`text`])},truncated:g(`Lines were capped to the response bound.`)},[`summary`,`lines`],`Settled diff vs the pre-action tree (changed lines only).`),tail:{type:`array`,description:`Unchanged interactive refs tail: still-present, actionable elements from the settled tree, attached only when diff carries zero added-line refs (a modal-dismiss/toast-only diff).`,items:w({ref:m(`Plain ref body (e12) minted from the stored settled tree.`),role:m(),label:m()},[`ref`,`role`])},tailTruncated:g(`Present (true) when tail candidates exceeded the response cap.`),hint:m()},[`settled`,`waitedMs`,`captures`,`quietMs`,`timeoutMs`]),M={platform:x(s),target:x(c),device:m(`Human-readable device name.`),id:m(`Stable device id.`),kind:x(y)},N=[`platform`,`target`,`device`,`id`,`kind`],Ee=w({success:g(),exitCode:b(),stdout:m(),stderr:m(),error:h(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]);function P(e){return e.oneOf?{...e,oneOf:e.oneOf.map(P)}:{...e,properties:{...e.properties??{},settle:Te}}}function De(e){let t={...e};for(let e of Object.keys(t))f(e)&&(t[e]=P(t[e]));return t}const F=O({properties:{evidence:j,button:x([`secondary`,`middle`]),count:b(`Number of press/click repetitions.`),intervalMs:b(`Delay between repeated press/click actions.`),holdMs:b(`Hold duration for each action.`),jitterPx:b(`Randomization radius in pixels.`),doubleTap:g(`Whether the command requested a double-tap action.`)}}),I={text:m(`Text submitted to the field.`),delayMs:b(`Delay between typed characters in milliseconds.`),evidence:j},Oe=w({resourceId:C(`Android resource id of the exact field that changed.`),className:C(`Android class name of the exact field that changed.`),packageName:C(`Android package name that owns the exact field.`),rect:w({x:b(),y:b(),width:b(),height:b()},[`x`,`y`,`width`,`height`],`Screen-space rectangle of the exact field that changed.`)},[`resourceId`,`className`,`packageName`,`rect`],`Target identity captured before fill and matched after fill.`),ke=De({press:F,click:F,fill:{type:`object`,description:`Fill response. Android may return target-bound unconfirmed evidence when the exact app-owned field changed but formatting prevented raw equality.`,oneOf:[{...O({properties:I,required:[`text`]}),not:w({},[`verification`])},O({properties:{...I,verification:S(`unconfirmed`),requested:m(`Literal text requested by the fill command.`),before:C(`Raw target text captured before the fill.`),after:C(`Raw target text captured after the fill.`),target:Oe},required:[`text`,`verification`,`requested`,`before`,`after`,`target`]})]},longpress:O({properties:{durationMs:b(),gesture:S(`longpress`)}}),hover:O({properties:{gesture:S(`hover`)}}),find:w({ref:m(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:b(`ADR 0014 ref frame epoch for read-only find actions.`),found:g(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:b(`Milliseconds waited for a read-only find condition.`),text:m(`Text value returned by find get_text.`),node:h(`Snapshot node for find get_attrs/get_text.`),matches:{type:`array`,description:`Every match for the read-only find list action (#1625): { ref, node } each.`,items:h(`One listed match with its snapshot ref and node.`)},locator:m(`Locator kind used for the find action.`),query:m(`Query argument used for the find action.`),x:b(`Resolved x coordinate for mutating find actions.`),y:b(`Resolved y coordinate for mutating find actions.`),message:m(`Diagnostic message for mutating find actions.`),cost:E},[],`Daemon response data for the find command.`),boot:w({...M,booted:{type:`boolean`,const:!0}},[...N,`booted`]),shutdown:w({...M,shutdown:Ee},[...N,`shutdown`]),viewport:w({width:b(),height:b(),message:m()},[`width`,`height`,`message`]),back:w({action:S(`back`),mode:x(te),message:m()},[`action`,`mode`,`message`]),home:w({action:S(`home`),message:m()},[`action`,`message`]),orientation:w({action:S(`orientation`),orientation:x(le),message:m(),confirmed:g(),warning:m()},[`action`,`orientation`,`message`]),"app-switcher":w({action:S(`app-switcher`),message:m()},[`action`,`message`]),fold:w({action:S(`fold`),pose:x(ce),hingeAngleDegrees:b(`Hinge angle CoreDevice read back after the pose settled.`),screen:w({display:m(`CoreDevice name of the panel the device now lights.`),coordinateSpace:S(ve),widthPt:b(`Panel width in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.`),heightPt:b(`Panel height in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.`)},[`display`,`coordinateSpace`,`widthPt`,`heightPt`]),message:m()},[`action`,`pose`,`hingeAngleDegrees`,`message`]),"action-button":w({action:S(`action-button`),message:m()},[`action`,`message`]),"tv-remote":w({action:S(`tv-remote`),button:x(ue),durationMs:b(),message:m()},[`action`,`button`,`message`]),wait:w({waitedMs:b(),kind:S(`selector`),text:m(),selector:m(),captures:b(),nodeCount:b(),hint:m(),warning:m()},[`waitedMs`]),scroll:w({direction:x([`up`,`down`,`left`,`right`]),edge:x([`top`,`bottom`]),until:m(`Until scrolls only: the selector the passes stopped on.`),passes:b(`Edge and until scrolls only: how many scroll-and-check passes ran.`),amount:b(),pixels:b(),durationMs:b(),message:m(),keyboardAvoided:g(`Present only when an on-screen keyboard forced the swipe into the band above it; the reported pixels were planned against the shorter referenceHeight.`),keyboardMinY:b(`Where the keyboard began, in the same unit as the gesture coordinates. Clipped scrolls only.`)},[`direction`]),prepare:w({action:S(`ios-runner`),platform:x(s),deviceId:m(),deviceName:m(),kind:x(y),durationMs:b(),runner:w({},[]),cache:x([`exact`,`restore-key`,`miss`,`external`]),artifact:x([`valid`,`rebuilt`]),buildMs:b(),connectMs:b(),healthCheckMs:b(),xctestrunPath:m(),recoveryReason:m(),failureReason:m(),timing:w({totalMs:b(),additiveParts:w({buildMs:b(),connectAfterBuildMs:b(),healthCheckMs:b()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:w({connectMs:{type:`array`,items:S(`buildMs`)},healthCheckMs:{type:`array`,items:m()}},[`healthCheckMs`]),note:m()},[`totalMs`,`additiveParts`,`containment`,`note`]),message:m()},[`action`,`platform`,`deviceId`,`deviceName`,`kind`,`durationMs`,`runner`,`connectMs`,`healthCheckMs`,`timing`,`message`]),push:{type:`object`,oneOf:[w({platform:S(`ios`),bundleId:m(),message:m()},[`platform`,`bundleId`,`message`]),w({platform:S(`android`),package:m(),action:m(),extrasCount:b(),message:m()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":w({event:m(),eventUrl:m(),transport:S(`deep-link`),message:m()},[`event`,`eventUrl`,`transport`,`message`]),clipboard:{type:`object`,oneOf:[w({action:S(`read`),text:m()},[`action`,`text`]),w({action:S(`write`),textLength:b(),message:m()},[`action`,`textLength`,`message`])]},appstate:{type:`object`,oneOf:[w({platform:x([`ios`,`macos`]),appName:m(),appBundleId:m(),source:S(`session`),surface:x(ne),device_udid:m(`iOS only — the session device UDID.`),ios_simulator_device_set:{type:[`string`,`null`],description:`iOS only — the simulator set path, or null when unknown.`}},[`platform`,`appName`,`source`,`surface`]),w({platform:S(`android`),package:m(),activity:m()},[`platform`,`package`,`activity`])]},keyboard:w({platform:x([`android`,`ios`]),action:x([`status`,`dismiss`,`enter`]),visible:g(),wasVisible:g(),dismissed:g(),attempts:b(),inputType:m(),type:x([`text`,`number`,`email`,`phone`,`password`,`datetime`,`unknown`]),inputMethodPackage:m(),focusedPackage:m(),focusedResourceId:m(),inputOwner:x([`app`,`ime`,`unknown`]),message:m()},[`platform`,`action`]),doctor:w({status:x([`pass`,`warn`,`fail`,`info`]),summary:m(),kind:x([`auto`,`react-native`,`expo`,`repack`]),platform:m(),target:x(c),targetApp:m(),metro:w({host:m(),port:b()},[`host`,`port`]),checks:{type:`array`,items:w({id:m(),status:x([`pass`,`warn`,`fail`,`info`]),summary:m(),hint:m(),command:m(),evidence:h()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`]),diff:w({mode:S(`snapshot`),baselineInitialized:g(),summary:w({additions:b(),removals:b(),unchanged:b()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:w({kind:x([`added`,`removed`]),text:m(),ref:m()},[`kind`,`text`])},warnings:T},[`mode`,`baselineInitialized`,`summary`,`lines`]),replay:w({replayed:b(),healed:b(),session:m(),sessionActive:g(`True iff the session is still active — the script had no terminal close.`),artifactPaths:T,snapshotDiagnostics:h(),message:m()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:w({total:b(),executed:b(),passed:b(),failed:b(),skipped:b(),notRun:b(),durationMs:b(),failures:{type:`array`,items:h()},tests:{type:`array`,items:h()},snapshotDiagnostics:h()},[`total`,`executed`,`passed`,`failed`,`skipped`,`notRun`,`durationMs`,`failures`,`tests`]),record:{type:`object`,oneOf:[w({recording:S(`started`),outPath:m(),sessionStateDir:m(),recordingBackend:m(),recordingScope:m(),recordOnlySession:g(),activeSessionApp:h(),showTouches:g()},[`recording`,`outPath`,`sessionStateDir`,`showTouches`]),w({recording:S(`stopped`),outPath:m(),telemetryPath:m(),artifacts:{type:`array`,items:D},recordingBackend:m(),recordingScope:m(),recordOnlySession:g(),activeSessionApp:h(),durationMs:b(),capturedDurationMs:b(),recorder:x(_e,`What the recorder was observed doing when the recording was stopped: confirmed, or lost when the session holding it died. ADR 0024 reserves unconfirmed for the step that gains the probe.`),nativePathDisposition:x(ge,`What became of the artifact path the recorder writes to: retirable while it still owes a removal, retired once that removal was verified. ADR 0024 reserves pending.`),showTouches:g(),warning:m(),overlayWarning:m(),chunks:{type:`array`,items:h()}},[`recording`,`outPath`,`artifacts`,`durationMs`,`showTouches`])]},trace:{type:`object`,oneOf:[w({trace:S(`started`),outPath:m()},[`trace`,`outPath`]),w({trace:S(`stopped`),outPath:m(),artifacts:{type:`array`,items:D}},[`trace`,`outPath`,`artifacts`])]}}),Ae={devices:{type:`object`,properties:{devices:{type:`array`,items:{type:`object`,properties:{platform:{type:`string`,enum:s},target:{type:`string`,enum:c},kind:{type:`string`,enum:y},id:{type:`string`},name:{type:`string`}},required:[`platform`,`target`,`kind`,`id`,`name`]}}},required:[`devices`]},apps:{type:`object`,properties:{apps:{type:`array`,items:{type:`string`}}},required:[`apps`]}},L={...ke,...Ae},je={stateDir:{schema:{type:`string`,description:`Agent-device state directory.`},audience:p({operatorConfig:!0})},mcpOutputFormat:{schema:{type:`string`,enum:[`optimized`,`json`],description:`MCP text content format. Defaults to optimized agent-friendly text; use json for JSON text. Structured content is always returned separately.`}},includeCost:{schema:{type:`boolean`,description:`Include per-command agent-cost (cost.wallClockMs, …) in structuredContent. Defaults to off; the default response shape is unchanged.`}},responseLevel:{schema:{type:`string`,enum:[`digest`,`default`,`full`],description:`Response verbosity: token-cheap digest / default (today) / full. Defaults to default; the default response shape is unchanged.`}}},R=Object.entries(je),z=new Set(R.map(([e])=>e)),Me=Object.fromEntries(R.flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]));function Ne(){return Object.fromEntries(R.map(([e,t])=>[e,t.schema]))}function B(e){return n(e)}function V(t){let n=[`Error (${t.code}): ${t.message}`];if(t.cause){let e=t.cause.code?`${t.cause.code} `:``;n.push(`Cause: ${e}${t.cause.message}`)}t.hint&&n.push(`Hint: ${t.hint}`);for(let e of oe(t.details))n.push(`Warning: ${se(e)}`);n.push(...ye(e(t.details))),t.supportedOn&&n.push(`Supported on: ${t.supportedOn}`);let r=pe(t.details);return r&&n.push(r),n.join(`
|
|
1
|
+
import{B as e,D as t,L as n,r,z as i}from"./sdk-contracts.js";import{_ as a,h as o}from"./sdk-batch-runner.js";import{i as s,t as c}from"./sdk-device.js";import{S as l,c as u,d,p as f,w as ee}from"./sdk-batch.js";import{t as te}from"./back-mode.js";import{t as ne}from"./session.js";import{C as re,S as p,_ as m,b as ie,g as h,h as g,y as ae}from"./registry.js";import{n as oe}from"./success-text.js";import{t as se}from"./output-common.js";import"./device.js";import{r as ce,t as le}from"./device-rotation.js";import{t as ue}from"./tv-remote.js";import{i as de,n as _,r as fe,t as v}from"./command-metadata.js";import{r as pe}from"./replay-divergence.js";import{n as me,t as he}from"./cli-output.js";import{r as ge,t as _e}from"./recording-stop-observation.js";import{t as ve}from"./fold-runtime.js";import{n as ye}from"./error.js";import{n as be,r as xe,t as Se}from"./cli-config.js";import{n as Ce}from"./result-serialization.js";const y=[`simulator`,`emulator`,`device`];function b(e){return{type:`number`,...e?{description:e}:{}}}function x(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function S(e){return{type:`string`,const:e}}function C(e){return{type:[`string`,`null`],...e?{description:e}:{}}}function w(e,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}const T={type:`array`,items:{type:`string`}},E=w({wallClockMs:b(`Total wall-clock time for the request in milliseconds.`),runnerRoundTrips:b(`Number of real runner round-trips made while serving the request.`),nodeCount:b(`Number of nodes in the original node tree when the response carries one.`)},[`wallClockMs`,`runnerRoundTrips`]),D=w({field:m(),artifactType:m(),path:m(),localPath:m(),fileName:m()},[`field`]);function O(e={}){let t=e.properties??{},n=e.required??[];return w({targetKind:x([`point`,`ref`,`selector`],`Resolved interaction target kind.`),x:b(`Resolved interaction x coordinate when available.`),y:b(`Resolved interaction y coordinate when available.`),referenceWidth:b(`Reference frame width for visualizing the interaction point.`),referenceHeight:b(`Reference frame height for visualizing the interaction point.`),ref:m(`Snapshot ref without the @ prefix when the target was an @ref.`),selector:m(`Selector expression when the target was a selector.`),selectorChain:T,refLabel:m(),targetHittable:g(),hint:m(),warning:m(),message:m(),evidence:j,resolution:we,cost:E,maestroNonHittableCoordinateFallbackAllowed:g(`Whether the direct iOS Maestro coordinate fallback was allowed for this selector.`),maestroNonHittableCoordinateFallbackUsed:g(`Whether the direct iOS Maestro coordinate fallback was actually used.`),maestroFallbackReason:S(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const k=w({diagnosticRef:m(`Opaque non-@ diagnostic token. Never a snapshot ref: not issued via refsGeneration and cannot be pinned or reused as an @ref target. UTF-8 truncated to 256 bytes.`),role:m(`UTF-8 truncated to 256 bytes.`),label:m(`UTF-8 truncated to 256 bytes.`)},[`diagnosticRef`]),we={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[w({source:S(`runtime`),phase:S(`pre-action`),kind:S(`unique`)},[`source`,`phase`,`kind`]),w({source:S(`runtime`),phase:S(`pre-action`),kind:S(`disambiguated`),matchCount:b(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:k,tiebreak:x([`visible`,`deepest`,`smallest-area`,`structural-equivalence`],`The comparison that decided the winner.`),alternatives:{type:`array`,description:`At most 5 losing candidates, document order. Present at default/full response levels and omitted in digest. The winner is never included.`,items:k}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),w({source:S(`ref`),phase:S(`pre-action`),kind:S(`exact`)},[`source`,`phase`,`kind`]),w({source:S(`ref`),phase:S(`pre-action`),kind:S(`label-fallback`)},[`source`,`phase`,`kind`]),w({source:S(`direct-ios`),kind:S(`not-observed`)},[`source`,`kind`])]},A=w({from:m(`Surface the pre-action baseline described: a host bundle id, or app.`),to:m(`Surface the post-action capture describes: a host bundle id, or app.`),disclosure:m(`Agent-facing sentence explaining the surface transition.`)},[`from`,`to`,`disclosure`],`Present when an in-place system surface (web sign-in or Apple Pay sheet) was presented over the app, or left it.`),j=w({foregroundApp:m(`Foreground app bundle id or name, when the capture carries it.`),nodeCount:b(`Node count in the post-action interactive-only capture.`),interactiveNodeCount:b(`Subset of nodeCount the platform reports as hittable.`),digest:m(`Order-independent digest of the post-action node multiset.`),changedFromBefore:g(`Whether the post-action digest differs from the pre-action capture digest. false is evidence, not failure. With surfaceChange present, no digest comparison is made: it reports that surface transition.`),surfaceChange:A},[`nodeCount`,`interactiveNodeCount`,`digest`,`changedFromBefore`]),Te=w({settled:g(`Whether the UI held the quiet window before the deadline. false is advisory, not failure.`),waitedMs:b(),captures:b(),quietMs:b(),timeoutMs:b(),refsGeneration:b(`Snapshot generation of the stored settled tree; refs on added diff lines were minted from it.`),refs:{type:`array`,items:w({ref:m(`Plain ref body (e12) minted from the stored settled tree.`)},[`ref`])},surfaceChange:A,diff:w({summary:w({additions:b(),removals:b(),unchanged:b()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:w({kind:x([`added`,`removed`]),text:m(),ref:m(`Plain ref body (e12) for added lines.`)},[`kind`,`text`])},truncated:g(`Lines were capped to the response bound.`)},[`summary`,`lines`],`Settled diff vs the pre-action tree (changed lines only).`),tail:{type:`array`,description:`Unchanged interactive refs tail: still-present, actionable elements from the settled tree, attached only when diff carries zero added-line refs (a modal-dismiss/toast-only diff).`,items:w({ref:m(`Plain ref body (e12) minted from the stored settled tree.`),role:m(),label:m()},[`ref`,`role`])},tailTruncated:g(`Present (true) when tail candidates exceeded the response cap.`),hint:m()},[`settled`,`waitedMs`,`captures`,`quietMs`,`timeoutMs`]),M={platform:x(s),target:x(c),device:m(`Human-readable device name.`),id:m(`Stable device id.`),kind:x(y)},N=[`platform`,`target`,`device`,`id`,`kind`],Ee=w({success:g(),exitCode:b(),stdout:m(),stderr:m(),error:h(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]);function P(e){return e.oneOf?{...e,oneOf:e.oneOf.map(P)}:{...e,properties:{...e.properties??{},settle:Te}}}function De(e){let t={...e};for(let e of Object.keys(t))f(e)&&(t[e]=P(t[e]));return t}const F=O({properties:{evidence:j,button:x([`secondary`,`middle`]),count:b(`Number of press/click repetitions.`),intervalMs:b(`Delay between repeated press/click actions.`),holdMs:b(`Hold duration for each action.`),jitterPx:b(`Randomization radius in pixels.`),doubleTap:g(`Whether the command requested a double-tap action.`)}}),I={text:m(`Text submitted to the field.`),delayMs:b(`Delay between typed characters in milliseconds.`),evidence:j},Oe=w({resourceId:C(`Android resource id of the exact field that changed.`),className:C(`Android class name of the exact field that changed.`),packageName:C(`Android package name that owns the exact field.`),rect:w({x:b(),y:b(),width:b(),height:b()},[`x`,`y`,`width`,`height`],`Screen-space rectangle of the exact field that changed.`)},[`resourceId`,`className`,`packageName`,`rect`],`Target identity captured before fill and matched after fill.`),ke=De({press:F,click:F,fill:{type:`object`,description:`Fill response. Android may return target-bound unconfirmed evidence when the exact app-owned field changed but formatting prevented raw equality.`,oneOf:[{...O({properties:I,required:[`text`]}),not:w({},[`verification`])},O({properties:{...I,verification:S(`unconfirmed`),requested:m(`Literal text requested by the fill command.`),before:C(`Raw target text captured before the fill.`),after:C(`Raw target text captured after the fill.`),target:Oe},required:[`text`,`verification`,`requested`,`before`,`after`,`target`]})]},longpress:O({properties:{durationMs:b(),gesture:S(`longpress`)}}),hover:O({properties:{gesture:S(`hover`)}}),find:w({ref:m(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:b(`ADR 0014 ref frame epoch for read-only find actions.`),found:g(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:b(`Milliseconds waited for a read-only find condition.`),text:m(`Text value returned by find get_text.`),node:h(`Snapshot node for find get_attrs/get_text.`),matches:{type:`array`,description:`Every match for the read-only find list action (#1625): { ref, node } each.`,items:h(`One listed match with its snapshot ref and node.`)},locator:m(`Locator kind used for the find action.`),query:m(`Query argument used for the find action.`),x:b(`Resolved x coordinate for mutating find actions.`),y:b(`Resolved y coordinate for mutating find actions.`),message:m(`Diagnostic message for mutating find actions.`),cost:E},[],`Daemon response data for the find command.`),boot:w({...M,booted:{type:`boolean`,const:!0}},[...N,`booted`]),shutdown:w({...M,shutdown:Ee},[...N,`shutdown`]),viewport:w({width:b(),height:b(),message:m()},[`width`,`height`,`message`]),back:w({action:S(`back`),mode:x(te),message:m()},[`action`,`mode`,`message`]),home:w({action:S(`home`),message:m()},[`action`,`message`]),orientation:w({action:S(`orientation`),orientation:x(le),message:m(),confirmed:g(),warning:m()},[`action`,`orientation`,`message`]),"app-switcher":w({action:S(`app-switcher`),message:m()},[`action`,`message`]),fold:w({action:S(`fold`),pose:x(ce),hingeAngleDegrees:b(`Hinge angle CoreDevice read back after the pose settled.`),screen:w({display:m(`CoreDevice name of the panel the device now lights.`),coordinateSpace:S(ve),widthPt:b(`Panel width in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.`),heightPt:b(`Panel height in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.`)},[`display`,`coordinateSpace`,`widthPt`,`heightPt`]),message:m()},[`action`,`pose`,`hingeAngleDegrees`,`message`]),"action-button":w({action:S(`action-button`),message:m()},[`action`,`message`]),"tv-remote":w({action:S(`tv-remote`),button:x(ue),durationMs:b(),message:m()},[`action`,`button`,`message`]),wait:w({waitedMs:b(),kind:S(`selector`),text:m(),selector:m(),captures:b(),nodeCount:b(),hint:m(),warning:m()},[`waitedMs`]),scroll:w({direction:x([`up`,`down`,`left`,`right`]),edge:x([`top`,`bottom`]),until:m(`Until scrolls only: the selector the passes stopped on.`),passes:b(`Edge and until scrolls only: how many scroll-and-check passes ran.`),amount:b(),pixels:b(),durationMs:b(),message:m(),keyboardAvoided:g(`Present only when an on-screen keyboard forced the swipe into the band above it; the reported pixels were planned against the shorter referenceHeight.`),keyboardMinY:b(`Where the keyboard began, in the same unit as the gesture coordinates. Clipped scrolls only.`)},[`direction`]),prepare:w({action:S(`ios-runner`),platform:x(s),deviceId:m(),deviceName:m(),kind:x(y),durationMs:b(),runner:w({},[]),cache:x([`exact`,`restore-key`,`miss`,`external`]),artifact:x([`valid`,`rebuilt`]),buildMs:b(),connectMs:b(),healthCheckMs:b(),xctestrunPath:m(),recoveryReason:m(),failureReason:m(),timing:w({totalMs:b(),additiveParts:w({buildMs:b(),connectAfterBuildMs:b(),healthCheckMs:b()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:w({connectMs:{type:`array`,items:S(`buildMs`)},healthCheckMs:{type:`array`,items:m()}},[`healthCheckMs`]),note:m()},[`totalMs`,`additiveParts`,`containment`,`note`]),message:m()},[`action`,`platform`,`deviceId`,`deviceName`,`kind`,`durationMs`,`runner`,`connectMs`,`healthCheckMs`,`timing`,`message`]),push:{type:`object`,oneOf:[w({platform:S(`ios`),bundleId:m(),message:m()},[`platform`,`bundleId`,`message`]),w({platform:S(`android`),package:m(),action:m(),extrasCount:b(),message:m()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":w({event:m(),eventUrl:m(),transport:S(`deep-link`),message:m()},[`event`,`eventUrl`,`transport`,`message`]),clipboard:{type:`object`,oneOf:[w({action:S(`read`),text:m()},[`action`,`text`]),w({action:S(`write`),textLength:b(),message:m()},[`action`,`textLength`,`message`])]},appstate:{type:`object`,oneOf:[w({platform:x([`ios`,`macos`]),appName:m(),appBundleId:m(),source:S(`session`),surface:x(ne),device_udid:m(`iOS only — the session device UDID.`),ios_simulator_device_set:{type:[`string`,`null`],description:`iOS only — the simulator set path, or null when unknown.`}},[`platform`,`appName`,`source`,`surface`]),w({platform:S(`android`),package:m(),activity:m()},[`platform`,`package`,`activity`])]},keyboard:w({platform:x([`android`,`ios`]),action:x([`status`,`dismiss`,`enter`]),visible:g(),wasVisible:g(),dismissed:g(),attempts:b(),inputType:m(),type:x([`text`,`number`,`email`,`phone`,`password`,`datetime`,`unknown`]),inputMethodPackage:m(),focusedPackage:m(),focusedResourceId:m(),inputOwner:x([`app`,`ime`,`unknown`]),message:m()},[`platform`,`action`]),doctor:w({status:x([`pass`,`warn`,`fail`,`info`]),summary:m(),kind:x([`auto`,`react-native`,`expo`,`repack`]),platform:m(),target:x(c),targetApp:m(),metro:w({host:m(),port:b()},[`host`,`port`]),checks:{type:`array`,items:w({id:m(),status:x([`pass`,`warn`,`fail`,`info`]),summary:m(),hint:m(),command:m(),evidence:h()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`]),diff:w({mode:S(`snapshot`),baselineInitialized:g(),summary:w({additions:b(),removals:b(),unchanged:b()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:w({kind:x([`added`,`removed`]),text:m(),ref:m()},[`kind`,`text`])},warnings:T},[`mode`,`baselineInitialized`,`summary`,`lines`]),replay:w({replayed:b(),healed:b(),session:m(),sessionActive:g(`True iff the session is still active — the script had no terminal close.`),artifactPaths:T,snapshotDiagnostics:h(),message:m()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:w({total:b(),executed:b(),passed:b(),failed:b(),skipped:b(),notRun:b(),durationMs:b(),failures:{type:`array`,items:h()},tests:{type:`array`,items:h()},snapshotDiagnostics:h()},[`total`,`executed`,`passed`,`failed`,`skipped`,`notRun`,`durationMs`,`failures`,`tests`]),record:{type:`object`,oneOf:[w({recording:S(`started`),outPath:m(),sessionStateDir:m(),recordingBackend:m(),recordingScope:m(),recordOnlySession:g(),activeSessionApp:h(),showTouches:g()},[`recording`,`outPath`,`sessionStateDir`,`showTouches`]),w({recording:S(`stopped`),outPath:m(),telemetryPath:m(),artifacts:{type:`array`,items:D},recordingBackend:m(),recordingScope:m(),recordOnlySession:g(),activeSessionApp:h(),durationMs:b(),capturedDurationMs:b(),recorder:x(_e,`What the recorder was observed doing when the recording was stopped: confirmed, or lost when the session holding it died. ADR 0024 reserves unconfirmed for the step that gains the probe.`),nativePathDisposition:x(ge,`What became of the artifact path the recorder writes to: retirable while it still owes a removal, retired once that removal was verified. ADR 0024 reserves pending.`),showTouches:g(),warning:m(),overlayWarning:m(),chunks:{type:`array`,items:h()}},[`recording`,`outPath`,`artifacts`,`durationMs`,`showTouches`])]},trace:{type:`object`,oneOf:[w({trace:S(`started`),outPath:m()},[`trace`,`outPath`]),w({trace:S(`stopped`),outPath:m(),artifacts:{type:`array`,items:D}},[`trace`,`outPath`,`artifacts`])]}}),Ae={devices:{type:`object`,properties:{devices:{type:`array`,items:{type:`object`,properties:{platform:{type:`string`,enum:s},target:{type:`string`,enum:c},kind:{type:`string`,enum:y},id:{type:`string`},name:{type:`string`}},required:[`platform`,`target`,`kind`,`id`,`name`]}}},required:[`devices`]},apps:{type:`object`,properties:{apps:{type:`array`,items:{type:`string`}}},required:[`apps`]}},L={...ke,...Ae},je={stateDir:{schema:{type:`string`,description:`Agent-device state directory.`},audience:p({operatorConfig:!0})},mcpOutputFormat:{schema:{type:`string`,enum:[`optimized`,`json`],description:`MCP text content format. Defaults to optimized agent-friendly text; use json for JSON text. Structured content is always returned separately.`}},includeCost:{schema:{type:`boolean`,description:`Include per-command agent-cost (cost.wallClockMs, …) in structuredContent. Defaults to off; the default response shape is unchanged.`}},responseLevel:{schema:{type:`string`,enum:[`digest`,`default`,`full`],description:`Response verbosity: token-cheap digest / default (today) / full. Defaults to default; the default response shape is unchanged.`}}},R=Object.entries(je),z=new Set(R.map(([e])=>e)),Me=Object.fromEntries(R.flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]));function Ne(){return Object.fromEntries(R.map(([e,t])=>[e,t.schema]))}function B(e){return n(e)}function V(t){let n=[`Error (${t.code}): ${t.message}`];if(t.cause){let e=t.cause.code?`${t.cause.code} `:``;n.push(`Cause: ${e}${t.cause.message}`)}t.hint&&n.push(`Hint: ${t.hint}`);for(let e of oe(t.details))n.push(`Warning: ${se(e)}`);n.push(...ye(e(t.details))),t.supportedOn&&n.push(`Supported on: ${t.supportedOn}`);let r=pe(t.details);return r&&n.push(r),n.join(`
|
|
2
2
|
`)}function Pe(e,t,n){let r=Se({command:e,cwd:process.cwd(),cliFlags:t}),i={};for(let[t,a]of Object.entries(r))Object.hasOwn(n,t)&&xe(t,e)&&(i[t]=a);return be(i,t)}const Fe={devices:async e=>({devices:e.map(Ce)}),apps:async e=>({apps:e})};async function Ie(e,t){let n=Fe[e];return n?await n(t):t}function Le(){let e=new Map;return{pinInput:(t,n,r)=>Ze(t,n,He(e,r,n.session)),mergeCommandResult:(t,n,r,i)=>Ue(e,t,n,r,i),mergeErrorDetails:(t,n,r)=>{let i=H(n,r);Re(e,i,t),Ye(e,i,t)}}}function Re(e,t,n){let r=n?.refsGeneration;typeof r==`number`&&U(e,t,i(n),r)}const ze=new Set([`snapshot`,`find`]),Be=new Set(d.map(e=>e.name).filter(_).filter(e=>f(e))),Ve=new Set([`press`,`click`,`fill`,`longpress`,`hover`,`get`]);function He(e,t,n){return e.get(H(t,n))}function H(e,t){let n=typeof t==`string`&&t.length>0?t:`default`;return`${e??``}\u0000${n}`}function Ue(e,t,n,r,i){let a=H(r,i);if(Be.has(t)){Ke(e,a,qe(n));return}ze.has(t)&&(t===`find`?Ge(e,a,n):We(e,a,n))}function We(e,t,n){let r=n.refsGeneration;if(typeof r!=`number`){e.delete(t);return}let i=[];for(let{ref:e}of n.refs??[])i.push(e);for(let e of n.nodes??[])i.push(e.ref);U(e,t,i,r)}function Ge(e,t,n){let r=n.refsGeneration;if(typeof r!=`number`)return;let i=[];typeof n.ref==`string`&&n.ref.startsWith(`@`)&&i.push(n.ref.slice(1));for(let e of n.matches??[])typeof e.ref==`string`&&e.ref.length>0&&i.push(e.ref.startsWith(`@`)?e.ref.slice(1):e.ref);U(e,t,i,r)}function Ke(e,t,n){n?.refsGeneration!==void 0&&U(e,t,[...n.diff?.lines??[],...n.refs??[],...n.tail??[]].map(e=>e.ref).filter(e=>typeof e==`string`),n.refsGeneration)}function qe(e){let t=e.settle;return typeof t==`object`&&t?t:void 0}function U(e,t,n,r){if(n.length===0)return;let i=e.get(t)??new Map;e.set(t,i),Je(i,n,r)}function Je(e,t,n){for(let r of t)e.delete(r),e.set(r,n);for(;e.size>1e3;)e.delete(e.keys().next().value)}function Ye(e,t,n){let r=o(n?.divergence),i=o(r?.screen);if(i?.state!==`available`)return;let a=i.refsGeneration;if(typeof a!=`number`)return;let s=[];Xe(i.refs,s),U(e,t,s,a)}function Xe(e,t){if(Array.isArray(e))for(let n of e){let e=o(n)?.ref;typeof e==`string`&&e.length>0&&t.push(e)}}function Ze(e,t,n){return n===void 0||n.size===0?t:e===`wait`?Qe(t,n)??t:Ve.has(e)?$e(t,n)??t:t}function Qe(e,t){if(typeof e.ref!=`string`)return;let n=W(e.ref,t);return n===e.ref?void 0:{...e,ref:n}}function $e(e,t){let n=o(e.target);if(n?.kind!==`ref`||typeof n.ref!=`string`)return;let r=W(n.ref,t);return r===n.ref?void 0:{...e,target:{...n,ref:r}}}function W(e,t){if(!e.startsWith(`@`)||e.includes(`~`))return e;let n=t.get(e.slice(1));return n===void 0?e:`${e}~s${n}`}const et={config:p({operatorPath:`Point the process serving these tools at a config file with the AGENT_DEVICE_CONFIG environment variable.`}),remoteConfig:p({operatorPath:`Configure the remote profile on the process serving these tools, not per tool call.`})},tt=Object.fromEntries(fe().flatMap(e=>Object.entries(e.inputAudience).filter(([,e])=>e.kind===`operator`)));function G(e){return{...e.inputAudience,...ie,...Me,...et,...tt}}function nt(){return de().map(e=>{let t=e.name in L?L[e.name]:void 0,n=J(e.name,e);return{name:e.name,description:ft(e.name,ae(e)),inputSchema:n,...t?{outputSchema:t}:{}}})}function K(e={}){let n=Le();return{execute:async(r,i)=>{if(!_(r))throw new t(`INVALID_ARGS`,`Unknown command tool: ${r}`);let a=v(r),o=Y(r,a,i)??X(a.inputSchema,i,r);if(o)return await q(new t(`INVALID_ARGS`,o),n,void 0,i.session);let s=Q(r,a.inputSchema).properties,c=Pe(r,i,s),l=ot(c),u=ut(c),d=n.pinInput(r,u,l.client.stateDir),f=await it(e,l.client);try{let t=await(e.runCommand??at)(f,r,d);return n.mergeCommandResult(r,t,l.client.stateDir,u.session),{isError:!1,structuredContent:await Ie(r,t),content:[{type:`text`,text:await pt({name:r,input:u,result:t,outputFormat:l.outputFormat,responseLevel:l.client.responseLevel})}]}}catch(e){return await q(e,n,l.client.stateDir,u.session)}}}}async function q(e,t,n,r){let i=B(e);return t.mergeErrorDetails(i.details,n,r),{isError:!0,structuredContent:i,content:[{type:`text`,text:V(i)}]}}const rt=K();async function it(e,t){if(e.createClient)return await e.createClient(t);let{createAgentDeviceClient:n}=await import(`./agent-device-client.js`).then(e=>e.t);return n(t)}async function at(e,t,n){return await(await import(`./command-surface.js`).then(e=>e.t)).runCommand(e,t,n)}function ot(e){return{client:st(e),outputFormat:lt(e.mcpOutputFormat)}}function st(e){let n=e.stateDir,r=e.includeCost,i=e.responseLevel,a={};if(n!==void 0){if(typeof n!=`string`||n.length===0)throw new t(`INVALID_ARGS`,`Expected stateDir to be a non-empty string.`);a.stateDir=n}if(r!==void 0){if(typeof r!=`boolean`)throw new t(`INVALID_ARGS`,`Expected includeCost to be a boolean.`);r&&(a.cost=!0)}let o=ct(i);return o!==void 0&&(a.responseLevel=o),a}function ct(e){if(e===void 0)return;let n=r.find(t=>t===e);if(n===void 0)throw new t(`INVALID_ARGS`,`Expected responseLevel to be one of 'digest', 'default', or 'full'.`);return n}function lt(e){if(e===void 0)return`optimized`;if(e!==`optimized`&&e!==`json`)throw new t(`INVALID_ARGS`,`Expected mcpOutputFormat to be "optimized" or "json".`);return e}function ut(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!z.has(e)))}function J(e,t){let n=G(t),r=Q(e,t.inputSchema);return{...r,properties:Object.fromEntries(Object.entries(r.properties).filter(([e])=>n[e]?.kind!==`operator`))}}function Y(e,t,n){let r=J(e,t).properties,i=G(t);for(let t of Object.keys(n)){if(Object.hasOwn(r,t))continue;let n=Object.hasOwn(i,t)?i[t]:void 0;if(n?.kind!==`retired`)return n?.kind===`operator`?re(t,n.source):`${t} is not an accepted argument for the ${e} tool.`}}function X(e,t,n){if(!(!e||t===void 0)){if(Array.isArray(t))return Z(t,(t,r)=>X(e.items,t,`${n}[${r}]`));if(a(t))return Z(e.oneOf??[],e=>X(e,t,n))??Z(Object.entries(e.properties??{}),([e,r])=>Object.hasOwn(t,e)?dt(r,t,e,`${n}.${e}`):void 0)}}function dt(e,t,n,r){let i=e.commandInputFor;if(i===void 0)return X(e,t[n],r);let o=t[n],s=u(t[i]);if(s===void 0||!a(o))return;let c=Y(s,v(s),o);return c===void 0?void 0:`${r}: ${c}`}function Z(e,t){for(let[n,r]of e.entries()){let e=t(r,n);if(e)return e}}function ft(e,t){let n=ee(e);if(n.envelopeMs===`unbounded`)return`${t} Streams progress; no fixed client timeout.`;let r=Math.round(n.envelopeMs/1e3);return n.budget.source===`none`?`${t} Times out after ${r}s.`:`${t} Times out after ${r}s; a caller-supplied budget extends it.`}function Q(e,t){let n=l(e);return{...t,properties:{...t.properties,...n&&!t.properties?.noRecord?{noRecord:{type:`boolean`,description:`Do not record this action.`}}:{},...Ne()}}}async function pt(e){if(e.outputFormat===`json`||e.responseLevel!==void 0&&e.responseLevel!=="default")return $(e.result);let t=await he({name:e.name,input:e.input,result:e.result});return typeof t?.text==`string`?mt(e.name,t):$(t?.data??e.result)}function mt(e,t){let n=t.text??``;if(!me(e))return n;let r=t.stderr?.trimEnd()??``;return r===``?n:`${n}${n.endsWith(`
|
|
3
3
|
`)?``:`
|
|
4
4
|
`}${r}`}function $(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}export{B as a,V as i,K as n,z as o,nt as r,rt as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{_ as t}from"./sdk-batch-runner.js";import{s as n}from"./owner-identity.js";import{a as r,c as i}from"./exec.js";import"./command.js";import"./process.js";import{D as a,g as o,o as s,u as c,y as l}from"./host-file.js";import u from"node:path";const d=/^[0-9a-fA-F-]{32,36}$/;function f(e){if(!(!e||!d.test(e)))return e.replaceAll(`-`,``).toUpperCase()}function p(e,t){return`${e.uuid}:${m(t)}`}function m(e){return`0x${e.toString(16)}`}function h(e){return typeof e==`string`&&e.length>0?e:void 0}function g(...e){for(let t of e){let e=h(t);if(e)return e}}function _(e){let t=e.filter(e=>!!e);return t.length>0?t.join(` `):void 0}function v(e){try{let n=JSON.parse(e);return t(n)?n:null}catch{return null}}function y(e){if(typeof e==`number`&&Number.isSafeInteger(e))return e;if(typeof e==`string`){let t=e.startsWith(`0x`)?Number.parseInt(e,16):Number(e);return Number.isSafeInteger(t)?t:void 0}}function b(e,t,n){if(!Object.hasOwn(e,t))return;let r=y(e[t]);if(r!==void 0)return r;S(n,t)}function x(e,t,n){if(!Object.hasOwn(e,t))return;let r=ee(e[t]);if(r!==void 0)return r;S(n,t)}function ee(e){if(typeof e==`bigint`)return e;if(typeof e==`number`&&Number.isSafeInteger(e)||typeof e==`string`&&/^(?:0x[0-9a-fA-F]+|\d+)$/.test(e))return BigInt(e)}function S(t,n){throw new e(`INVALID_ARGS`,`Invalid ${t} numeric field: ${n}`,{hint:`Crash artifact numeric fields must be integer numbers or integer numeric strings.`})}function C(e){return e.length===1?e[0]:void 0}function w(e){return[...new Set(e)]}function te(e){let t=e.match(/^(.*) \+ (\d+)$/);return t?{symbol:t[1],location:Number(t[2])}:{symbol:e}}const ne=/^(?:arm64e?|arm64_32|x86_64|armv7[sk]?|i386)$/;function re(e){return ie(e)??O(e)}function ie(e){let t=ae(e);if(!t)return null;let n=(Array.isArray(t.payload.usedImages)?t.payload.usedImages:[]).flatMap((e,t)=>D(e,t));if(n.length===0)return null;let r=oe(Array.isArray(t.payload.threads)?t.payload.threads:[],n);return{format:`ips`,images:n,addresses:r.map(({frame:e,...t})=>t),document:t,frameMatches:r,write:e=>T(t,r,e)}}function ae(e){let t=v(e);if(t)return{payload:t};let n=e.indexOf(`
|
|
2
2
|
`);if(n===-1)return null;let r=e.slice(0,n),i=v(e.slice(n+1));return i?{header:r,payload:i}:null}function oe(e,t){let n=new Map(t.map(e=>[e.index,e]));return e.flatMap((e,t)=>se(e).flatMap((e,r)=>ce(e,n,t,r)))}function se(e){return!t(e)||!Array.isArray(e.frames)?[]:e.frames.filter(t)}function ce(e,t,n,r){let i=b(e,`imageIndex`,`IPS frame`),a=x(e,`imageOffset`,`IPS frame`);if(i===void 0||a===void 0)return[];let o=t.get(i);return o?[{frame:e,frameIndex:r,threadIndex:n,image:o,address:o.base+a}]:[]}function T(e,t,n){for(let e of t){let t=n.get(p(e.image,e.address))?.text;t&&E(e.frame,t)}e.payload.agentDeviceSymbolication={tool:`agent-device debug symbols`,symbolicatedFrames:[...n.values()].filter(e=>e.text).length};let r=`${JSON.stringify(e.payload,null,2)}\n`;return e.header?`${e.header}\n${r}`:r}function E(e,t){let n=te(t);e.symbol=n.symbol,n.location!==void 0&&(e.symbolLocation=n.location)}function D(e,n){if(!t(e))return[];let r=f(h(e.uuid)),i=x(e,`base`,`IPS usedImages`);if(!r||i===void 0)return[];let a=h(e.path);return[{index:n,name:h(e.name)??(a?u.basename(a):`image-${n}`),uuid:r,arch:h(e.arch),base:i,path:a}]}function O(e){let t=e.split(`
|
|
3
3
|
`),n=k(t);if(n.length===0)return null;let r=M(t,n);return{format:`text`,images:n,addresses:r,lines:t,frameMatches:r,write(e){let n=new Map(r.map(e=>[e.lineIndex,e]));return t.map((t,r)=>{let i=n.get(r);if(!i)return t;let a=e.get(p(i.image,i.address))?.text;return!a||t.includes(a)?t:`${t} // ${a}`}).join(`
|
|
4
4
|
`)}}}function k(e){let t=[],n=e.findIndex(e=>/^Binary Images:/i.test(e.trim()));if(n===-1)return t;for(let r of e.slice(n+1)){let e=A(r);e&&t.push(e)}return t}function A(e){let t=e.match(/^\s*(0x[0-9a-fA-F]+)\s*-\s*(0x[0-9a-fA-F]+)\s+\+?(.+?)\s+<([0-9a-fA-F-]{32,36})>\s+(.+)$/);if(!t)return null;let n=f(t[4]);if(!n)return null;let r=j(t[3].trim(),t[5].trim());return{name:r.name,arch:r.arch,uuid:n,base:BigInt(t[1]),end:BigInt(t[2]),path:t[5].trim()}}function j(e,t){let n=e.split(/\s+/),r=n.at(-1);if(r&&ne.test(r))return{name:n.slice(0,-1).join(` `).trim(),arch:r};let i=u.basename(t);return{name:e.startsWith(i)?i:e}}function M(e,t){let n=[],r;for(let[i,a]of e.entries()){let e=a.match(/^Thread\s+(\d+)\s+Crashed:/);e?r=Number(e[1]):(a.trim().length===0||/^Thread\s+\d+/.test(a))&&(r=void 0);let o=N(a,t),s=a.match(/^\s*(\d+)/);o&&s&&n.push({...o,frameIndex:Number(s[1]),lineIndex:i,threadIndex:r})}return n}function N(e,t){let n=e.match(/^\s*\d+\s+(.+?)\s+(0x[0-9a-fA-F]+)\b/);if(!n)return null;let r=n[1].trim(),i=BigInt(n[2]),a=P(t,r,i);return a?{image:a,address:i}:null}function P(e,t,n){let r=e.filter(e=>e.name===t);return r.find(e=>F(e,n))??C(r)}function F(e,t){return e.end!==void 0&&e.base<=t&&t<=e.end}const I=1e4;async function L(e){return e.dsym&&e.searchPath?[K(e.cwd,e.dsym),...await R(K(e.cwd,e.searchPath))]:e.dsym?[K(e.cwd,e.dsym)]:e.searchPath?await R(K(e.cwd,e.searchPath)):[]}async function R(t){let n=[],r=0;async function i(a){if(n.length>=200)return;if(r+=1,r>I)throw new e(`COMMAND_FAILED`,`debug symbols search-path scan exceeded bounds.`,{searchPath:t,maxEntries:I,hint:`Pass --dsym <App.dSYM> directly or narrow --search-path to the build products directory.`});if(!(await z(a,t)).isDirectory()){a===t&&B(t);return}if(a.endsWith(`.dSYM`)){n.push(a);return}let s=await o(a,{withFileTypes:!0});for(let e of s)e.isDirectory()&&await i(u.join(a,e.name))}return await i(t),n}async function z(t,n){try{return await c(t)}catch{throw new e(`INVALID_ARGS`,`debug symbols search path does not exist: ${n}`,{hint:`Pass an existing build products directory to --search-path, or pass --dsym <App.dSYM> directly.`})}}function B(t){throw new e(`INVALID_ARGS`,`debug symbols search path is not a directory: ${t}`,{hint:`Pass an existing build products directory to --search-path, or pass --dsym <App.dSYM> directly.`})}async function V(t,n){let r=(await Promise.all(w(t).map(e=>H(e,n)))).flat();if(r.length===0)throw new e(`COMMAND_FAILED`,`No UUIDs found in dSYM bundle.`,{hint:`Verify the path points to a built .dSYM bundle with DWARF contents.`});return r}async function H(e,t){return await U(e),W(e,r(await i(t,[`--uuid`,e],{timeoutMs:15e3,allowFailure:!0}),`Failed to inspect dSYM UUIDs: ${e}`,{hint:`Verify the dSYM bundle is valid and readable.`}).stdout)}async function U(t){if(!((await c(t).catch(()=>null))?.isDirectory()&&t.endsWith(`.dSYM`)))throw new e(`INVALID_ARGS`,`Not a .dSYM bundle: ${t}`,{hint:`Pass the .dSYM bundle path, not the DWARF executable inside it.`})}function W(e,t){return t.split(`
|