agent-device 0.20.9 → 0.20.10
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.20.9.apk → agent-device-android-ime-helper-0.20.10.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.10.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.9.manifest.json → agent-device-android-ime-helper-0.20.10.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.9.apk → agent-device-android-snapshot-helper-0.20.10.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.10.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.9.manifest.json → agent-device-android-snapshot-helper-0.20.10.manifest.json} +6 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +6 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +4 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +94 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +22 -23
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +3 -23
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +10 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +30 -12
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +8 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +133 -63
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +13 -12
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentation.swift +183 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationTests.swift +0 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +20 -18
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +19 -0
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/ai-sdk.d.ts +61 -0
- package/dist/src/ai-sdk.js +1 -0
- package/dist/src/android-adb.d.ts +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apps.js +5 -5
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/boot-diagnostics.js +2 -2
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +30 -23
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +7 -7
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-types.d.ts +1582 -0
- package/dist/src/command-tools.js +2 -0
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-shutdown-report.js +1 -1
- package/dist/src/daemon.js +1 -1
- package/dist/src/debug-symbols.js +1 -1
- package/dist/src/device-input-state.js +1 -1
- package/dist/src/dispatch.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/helper-package-install.js +1 -1
- package/dist/src/helper.js +1 -1
- package/dist/src/ime-lifecycle.js +1 -1
- package/dist/src/ime-recovery-marker.js +1 -1
- package/dist/src/index.d.ts +2 -1578
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions3.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-common.js +1 -1
- package/dist/src/interaction-runtime.js +1 -1
- package/dist/src/interaction-snapshot.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor.js +2 -2
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +2 -2
- package/dist/src/internal/daemon.js +4 -4
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun.d.ts +10 -2
- package/dist/src/linux.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/{screenshot-geometry.js → mobile-snapshot-semantics.js} +1 -1
- package/dist/src/perf.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/png-resize.js +1 -1
- package/dist/src/provider.js +1 -1
- package/dist/src/proxy.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/registry.js +27 -27
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay.js +2 -2
- package/dist/src/reporting.js +5 -5
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-sequence.js +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime3.js +1 -1
- package/dist/src/runtime4.js +3 -3
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screenshot-result.js +4 -4
- package/dist/src/screenshot.js +1 -1
- package/dist/src/script-source-bundle.js +16 -0
- package/dist/src/sdk-android-adb.d.ts +40 -40
- package/dist/src/sdk-android-adb.js +4 -4
- package/dist/src/sdk-batch-runner.js +3 -3
- package/dist/src/sdk-contracts.d.ts +122 -85
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +89 -77
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +10 -3
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session2.js +7 -8
- package/dist/src/shared.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-scope.js +1 -0
- package/dist/src/snapshot.js +6 -6
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src2.js +1 -1
- package/dist/src/src3.js +1 -1
- package/dist/src/src4.js +1 -0
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tool-provider3.js +1 -0
- package/dist/src/verified-file.js +1 -1
- package/dist/src/web.js +1 -1
- package/package.json +21 -8
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.9.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk.sha256 +0 -1
- package/dist/src/cancel.js +0 -1
- package/dist/src/prepare-kind.js +0 -15
- package/dist/src/selector-vocabulary.js +0 -1
package/dist/src/server.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import{C as e,_ as t,n,o as r}from"./sdk-contracts.js";import{Dr as i,f as a,p as o,y as s}from"./sdk-batch-runner.js";import{i as c,t as l}from"./sdk-device.js";import{Ct as u,Et as ee,Ft as te,Tt as ne}from"./prepare-kind.js";import{_ as d,g as f,h as re,s as p,v as m}from"./registry.js";import{t as ie}from"./session.js";import{i as ae,n as h,t as oe}from"./command-metadata.js";import{n as se}from"./version.js";import{n as ce,r as le,t as ue}from"./cli-config.js";import{t as de}from"./cli-output.js";const g=[`simulator`,`emulator`,`device`];function _(e){return{type:`number`,...e?{description:e}:{}}}function v(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function y(e){return{type:`string`,const:e}}function b(e){return{type:[`string`,`null`],...e?{description:e}:{}}}function x(e,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}const S={type:`array`,items:{type:`string`}},C=x({wallClockMs:_(`Total wall-clock time for the request in milliseconds.`),runnerRoundTrips:_(`Number of real runner round-trips made while serving the request.`),nodeCount:_(`Number of nodes in the original node tree when the response carries one.`)},[`wallClockMs`,`runnerRoundTrips`]),w=x({field:m(),artifactType:m(),path:m(),localPath:m(),fileName:m()},[`field`]);function T(e={}){let t=e.properties??{},n=e.required??[];return x({targetKind:v([`point`,`ref`,`selector`],`Resolved interaction target kind.`),x:_(`Resolved interaction x coordinate when available.`),y:_(`Resolved interaction y coordinate when available.`),referenceWidth:_(`Reference frame width for visualizing the interaction point.`),referenceHeight:_(`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:S,refLabel:m(),targetHittable:f(),hint:m(),warning:m(),message:m(),evidence:E,resolution:pe,cost:C,maestroNonHittableCoordinateFallbackAllowed:f(`Whether the direct iOS Maestro coordinate fallback was allowed for this selector.`),maestroNonHittableCoordinateFallbackUsed:f(`Whether the direct iOS Maestro coordinate fallback was actually used.`),maestroFallbackReason:y(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const fe=x({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`]),pe={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[x({source:y(`runtime`),phase:y(`pre-action`),kind:y(`unique`)},[`source`,`phase`,`kind`]),x({source:y(`runtime`),phase:y(`pre-action`),kind:y(`disambiguated`),matchCount:_(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:fe,tiebreak:v([`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:fe}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),x({source:y(`ref`),phase:y(`pre-action`),kind:y(`exact`)},[`source`,`phase`,`kind`]),x({source:y(`ref`),phase:y(`pre-action`),kind:y(`label-fallback`)},[`source`,`phase`,`kind`]),x({source:y(`direct-ios`),kind:y(`not-observed`)},[`source`,`kind`])]},E=x({foregroundApp:m(`Foreground app bundle id or name, when the capture carries it.`),nodeCount:_(`Node count in the post-action interactive-only capture.`),interactiveNodeCount:_(`Subset of nodeCount the platform reports as hittable.`),digest:m(`Order-independent digest of the post-action node multiset.`),changedFromBefore:f(`Whether the post-action digest differs from the pre-action capture digest. false is evidence, not failure.`)},[`nodeCount`,`interactiveNodeCount`,`digest`,`changedFromBefore`]),D=x({settled:f(`Whether the UI held the quiet window before the deadline. false is advisory, not failure.`),waitedMs:_(),captures:_(),quietMs:_(),timeoutMs:_(),refsGeneration:_(`Snapshot generation of the stored settled tree; refs on added diff lines were minted from it.`),refs:{type:`array`,items:x({ref:m(`Plain ref body (e12) minted from the stored settled tree.`)},[`ref`])},diff:x({summary:x({additions:_(),removals:_(),unchanged:_()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:x({kind:v([`added`,`removed`]),text:m(),ref:m(`Plain ref body (e12) for added lines.`)},[`kind`,`text`])},truncated:f(`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:x({ref:m(`Plain ref body (e12) minted from the stored settled tree.`),role:m(),label:m()},[`ref`,`role`])},tailTruncated:f(`Present (true) when tail candidates exceeded the response cap.`),hint:m()},[`settled`,`waitedMs`,`captures`,`quietMs`,`timeoutMs`]),O={platform:v(c),target:v(l),device:m(`Human-readable device name.`),id:m(`Stable device id.`),kind:v(g)},me=[`platform`,`target`,`device`,`id`,`kind`],he=x({success:f(),exitCode:_(),stdout:m(),stderr:m(),error:d(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]);function ge(e){return{...e,properties:{...e.properties??{},settle:D}}}const _e=T({properties:{evidence:E,settle:D,button:v([`secondary`,`middle`]),count:_(`Number of press/click repetitions.`),intervalMs:_(`Delay between repeated press/click actions.`),holdMs:_(`Hold duration for each action.`),jitterPx:_(`Randomization radius in pixels.`),doubleTap:f(`Whether the command requested a double-tap action.`)}}),k={text:m(`Text submitted to the field.`),delayMs:_(`Delay between typed characters in milliseconds.`),evidence:E,settle:D},ve=x({resourceId:b(`Android resource id of the exact field that changed.`),className:b(`Android class name of the exact field that changed.`),packageName:b(`Android package name that owns the exact field.`),rect:x({x:_(),y:_(),width:_(),height:_()},[`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.`),ye={press:_e,click:_e,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:[{...T({properties:k,required:[`text`]}),not:x({},[`verification`])},T({properties:{...k,verification:y(`unconfirmed`),requested:m(`Literal text requested by the fill command.`),before:b(`Raw target text captured before the fill.`),after:b(`Raw target text captured after the fill.`),target:ve},required:[`text`,`verification`,`requested`,`before`,`after`,`target`]})]},longpress:T({properties:{durationMs:_(),settle:D,gesture:y(`longpress`)}}),find:x({ref:m(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:_(`ADR 0014 ref frame epoch for read-only find actions.`),found:f(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:_(`Milliseconds waited for a read-only find condition.`),text:m(`Text value returned by find get_text.`),node:d(`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:d(`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:_(`Resolved x coordinate for mutating find actions.`),y:_(`Resolved y coordinate for mutating find actions.`),message:m(`Diagnostic message for mutating find actions.`),settle:D,cost:C},[],`Daemon response data for the find command.`),boot:x({...O,booted:{type:`boolean`,const:!0}},[...me,`booted`]),shutdown:x({...O,shutdown:he},[...me,`shutdown`]),viewport:x({width:_(),height:_(),message:m()},[`width`,`height`,`message`]),...p,back:ge(p.back),wait:x({waitedMs:_(),kind:y(`selector`),text:m(),selector:m(),captures:_(),nodeCount:_(),hint:m(),warning:m()},[`waitedMs`]),prepare:x({action:y(`ios-runner`),platform:v(c),deviceId:m(),deviceName:m(),kind:v(g),durationMs:_(),runner:x({},[]),cache:v([`exact`,`restore-key`,`miss`,`external`]),artifact:v([`valid`,`rebuilt`]),buildMs:_(),connectMs:_(),healthCheckMs:_(),xctestrunPath:m(),recoveryReason:m(),failureReason:m(),timing:x({totalMs:_(),additiveParts:x({buildMs:_(),connectAfterBuildMs:_(),healthCheckMs:_()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:x({connectMs:{type:`array`,items:y(`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:[x({platform:y(`ios`),bundleId:m(),message:m()},[`platform`,`bundleId`,`message`]),x({platform:y(`android`),package:m(),action:m(),extrasCount:_(),message:m()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":x({event:m(),eventUrl:m(),transport:y(`deep-link`),message:m()},[`event`,`eventUrl`,`transport`,`message`]),clipboard:{type:`object`,oneOf:[x({action:y(`read`),text:m()},[`action`,`text`]),x({action:y(`write`),textLength:_(),message:m()},[`action`,`textLength`,`message`])]},appstate:{type:`object`,oneOf:[x({platform:v([`ios`,`macos`]),appName:m(),appBundleId:m(),source:y(`session`),surface:v(ie),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`]),x({platform:y(`android`),package:m(),activity:m()},[`platform`,`package`,`activity`])]},keyboard:x({platform:v([`android`,`ios`]),action:v([`status`,`dismiss`,`enter`]),visible:f(),wasVisible:f(),dismissed:f(),attempts:_(),inputType:m(),type:v([`text`,`number`,`email`,`phone`,`password`,`datetime`,`unknown`]),inputMethodPackage:m(),focusedPackage:m(),focusedResourceId:m(),inputOwner:v([`app`,`ime`,`unknown`]),message:m()},[`platform`,`action`]),doctor:x({status:v([`pass`,`warn`,`fail`,`info`]),summary:m(),kind:v([`auto`,`react-native`,`expo`,`repack`]),platform:m(),target:v(l),targetApp:m(),metro:x({host:m(),port:_()},[`host`,`port`]),checks:{type:`array`,items:x({id:m(),status:v([`pass`,`warn`,`fail`,`info`]),summary:m(),hint:m(),command:m(),evidence:d()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`]),diff:x({mode:y(`snapshot`),baselineInitialized:f(),summary:x({additions:_(),removals:_(),unchanged:_()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:x({kind:v([`added`,`removed`]),text:m(),ref:m()},[`kind`,`text`])},warnings:S},[`mode`,`baselineInitialized`,`summary`,`lines`]),replay:x({replayed:_(),healed:_(),session:m(),sessionActive:f(`True iff the session is still active — the script had no terminal close.`),artifactPaths:S,snapshotDiagnostics:d(),message:m()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:x({total:_(),executed:_(),passed:_(),failed:_(),skipped:_(),notRun:_(),durationMs:_(),failures:{type:`array`,items:d()},tests:{type:`array`,items:d()},snapshotDiagnostics:d()},[`total`,`executed`,`passed`,`failed`,`skipped`,`notRun`,`durationMs`,`failures`,`tests`]),record:{type:`object`,oneOf:[x({recording:y(`started`),outPath:m(),sessionStateDir:m(),recordingBackend:m(),recordingScope:m(),recordOnlySession:f(),activeSessionApp:d(),showTouches:f()},[`recording`,`outPath`,`sessionStateDir`,`showTouches`]),x({recording:y(`stopped`),outPath:m(),telemetryPath:m(),artifacts:{type:`array`,items:w},recordingBackend:m(),recordingScope:m(),recordOnlySession:f(),activeSessionApp:d(),durationMs:_(),showTouches:f(),warning:m(),overlayWarning:m(),chunks:{type:`array`,items:d()}},[`recording`,`outPath`,`artifacts`,`durationMs`,`showTouches`])]},trace:{type:`object`,oneOf:[x({trace:y(`started`),outPath:m()},[`trace`,`outPath`]),x({trace:y(`stopped`),outPath:m(),artifacts:{type:`array`,items:w}},[`trace`,`outPath`,`artifacts`])]}},be={devices:{type:`object`,properties:{devices:{type:`array`,items:{type:`object`,properties:{platform:{type:`string`,enum:c},target:{type:`string`,enum:l},kind:{type:`string`,enum:g},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`]}},A={...ye,...be};function xe(t){return e(t)}function Se(e){let t=[`Error (${e.code}): ${e.message}`];e.hint&&t.push(`Hint: ${e.hint}`),t.push(...ne(e.details)),e.supportedOn&&t.push(`Supported on: ${e.supportedOn}`);let n=u(e.details);return n&&t.push(n),t.join(`
|
|
2
|
-
`)}function Ce(e,t,n){let r=ue({command:e,cwd:process.cwd(),cliFlags:t}),i={};for(let[t,a]of Object.entries(r))Object.hasOwn(n,t)&&ce(t,e)&&(i[t]=a);return le(i,t)}const we={devices:e=>({devices:e.map(te)}),apps:e=>({apps:e})};function Te(e,t){let n=we[e];return n?n(t):t}function Ee(){let e=new Map;return{pinInput:(t,n,r)=>Be(t,n,je(e,r,n.session)),mergeCommandResult:(t,n,r,i)=>Me(e,t,n,r,i),mergeErrorDetails:(t,n,r)=>{let i=j(n,r);De(e,i,t),Re(e,i,t)}}}function De(e,t,n){let r=n?.refsGeneration;typeof r==`number`&&M(e,t,ee(n),r)}const Oe=new Set([`snapshot`,`find`]),ke=new Set(a.map(e=>e.name).filter(h).filter(e=>o(e))),Ae=new Set([`press`,`click`,`fill`,`longpress`,`get`]);function je(e,t,n){return e.get(j(t,n))}function j(e,t){let n=typeof t==`string`&&t.length>0?t:`default`;return`${e??``}\u0000${n}`}function Me(e,t,n,r,i){let a=j(r,i);if(ke.has(t)){Fe(e,a,Ie(n));return}Oe.has(t)&&(t===`find`?Pe(e,a,n):Ne(e,a,n))}function Ne(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);M(e,t,i,r)}function Pe(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);M(e,t,i,r)}function Fe(e,t,n){n?.refsGeneration!==void 0&&M(e,t,[...n.diff?.lines??[],...n.refs??[],...n.tail??[]].map(e=>e.ref).filter(e=>typeof e==`string`),n.refsGeneration)}function Ie(e){let t=e.settle;return typeof t==`object`&&t?t:void 0}function M(e,t,n,r){if(n.length===0)return;let i=e.get(t)??new Map;e.set(t,i),Le(i,n,r)}function Le(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 Re(e,t,n){let r=i(i(n?.divergence)?.screen);if(r?.state!==`available`)return;let a=r.refsGeneration;if(typeof a!=`number`)return;let o=[];ze(r.refs,o),M(e,t,o,a)}function ze(e,t){if(Array.isArray(e))for(let n of e){let e=i(n)?.ref;typeof e==`string`&&e.length>0&&t.push(e)}}function Be(e,t,n){return n===void 0||n.size===0?t:e===`wait`?Ve(t,n)??t:Ae.has(e)?He(t,n)??t:t}function Ve(e,t){if(typeof e.ref!=`string`)return;let n=N(e.ref,t);return n===e.ref?void 0:{...e,ref:n}}function He(e,t){let n=i(e.target);if(n?.kind!==`ref`||typeof n.ref!=`string`)return;let r=N(n.ref,t);return r===n.ref?void 0:{...e,target:{...n,ref:r}}}function N(e,t){if(!e.startsWith(`@`)||e.includes(`~`))return e;let n=t.get(e.slice(1));return n===void 0?e:`${e}~s${n}`}function Ue(){return ae().map(e=>{let t=e.name in A?A[e.name]:void 0;return{name:e.name,description:re(e),inputSchema:P(e.name,e.inputSchema),...t?{outputSchema:t}:{}}})}function We(e={}){let n=Ee();return{execute:async(r,i)=>{if(!h(r))throw new t(`INVALID_ARGS`,`Unknown command tool: ${r}`);let a=P(r,oe(r).inputSchema).properties,o=Ce(r,i,a),s=Ye(o),c=$e(o),l=n.pinInput(r,c,s.client.stateDir),u=await qe(e,s.client);try{let t=await(e.runCommand??Je)(u,r,l);return n.mergeCommandResult(r,t,s.client.stateDir,c.session),{isError:!1,structuredContent:Te(r,t),content:[{type:`text`,text:et({name:r,input:c,result:t,outputFormat:s.outputFormat,responseLevel:s.client.responseLevel})}]}}catch(e){return Ge(e,n,s.client.stateDir,c.session)}}}}function Ge(e,t,n,r){let i=xe(e);return t.mergeErrorDetails(i.details,n,r),{isError:!0,structuredContent:i,content:[{type:`text`,text:Se(i)}]}}const Ke=We();async function qe(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 Je(e,t,n){return await(await import(`./command-surface.js`).then(e=>e.t)).runCommand(e,t,n)}function Ye(e){return{client:Xe(e),outputFormat:Qe(e.mcpOutputFormat)}}function Xe(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=Ze(i);return o!==void 0&&(a.responseLevel=o),a}function Ze(e){if(e===void 0)return;let r=n.find(t=>t===e);if(r===void 0)throw new t(`INVALID_ARGS`,`Expected responseLevel to be one of 'digest', 'default', or 'full'.`);return r}function Qe(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 $e(e){let{stateDir:t,mcpOutputFormat:n,includeCost:r,responseLevel:i,...a}=e;return a}function P(e,t){let n=s(e);return{...t,properties:{...t.properties,...n&&!t.properties?.noRecord?{noRecord:{type:`boolean`,description:`Do not record this action.`}}:{},stateDir:{type:`string`,description:`Agent-device state directory.`},mcpOutputFormat:{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:{type:`boolean`,description:`Include per-command agent-cost (cost.wallClockMs, …) in structuredContent. Defaults to off; the default response shape is unchanged.`},responseLevel:{type:`string`,enum:[`digest`,`default`,`full`],description:`Response verbosity: token-cheap digest / default (today) / full. Defaults to default; the default response shape is unchanged.`}}}}function et(e){if(e.outputFormat===`json`||e.responseLevel!==void 0&&e.responseLevel!=="default")return F(e.result);let t=de({name:e.name,input:e.input,result:e.result});return typeof t?.text==`string`?t.text:F(t?.data??e.result)}function F(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}const I=`2026-07-28`,L=[I],R=[`2025-11-25`,`2025-06-18`],z=[...L,...R],B=`server/discover`,tt=new Set([`initialize`,`ping`]),V=`io.modelcontextprotocol/protocolVersion`,H=`io.modelcontextprotocol/clientCapabilities`,U=`io.modelcontextprotocol/clientInfo`,W=36e5;var G=class extends Error{requested;constructor(e){super(`Unsupported MCP protocol version: ${e}. Supported: ${z.join(`, `)}.`),this.requested=e}get data(){return{supported:z,requested:this.requested}}};function nt(e,n){let r=X(X(n)._meta),i=ut(r,V);if(i===void 0){if(e===B)throw new t(`INVALID_ARGS`,`Expected _meta["${V}"] on ${B}.`);return`legacy`}if(!z.includes(i))throw new G(i);if(!q(r[H]))throw new t(`INVALID_ARGS`,`Expected _meta["${H}"] to be an object.`);let a=r[U];if(a!==void 0&&!st(a))throw new t(`INVALID_ARGS`,`Expected _meta["${U}"] to be a valid Implementation.`);if(!L.includes(i)){if(e===B)throw new G(i);return`legacy`}return`modern`}function rt(e){let t=ut(X(e),`protocolVersion`);return t!==void 0&&R.includes(t)?t:`2025-11-25`}function it(e,t){return t===`modern`&&tt.has(e)}function K(){return{name:`agent-device`,version:se()}}function at(e,t){return t===`legacy`||typeof e!=`object`||!e?e:{resultType:`complete`,...e,_meta:{...e._meta,"io.modelcontextprotocol/serverInfo":K()}}}function ot(e,t){return e===`modern`?{ttlMs:t,cacheScope:`public`}:void 0}function q(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function st(e){return!q(e)||!Y(e.name)||!Y(e.version)?!1:J(e.title,Y)&&J(e.description,Y)&&J(e.websiteUrl,Y)&&J(e.icons,e=>Array.isArray(e)&&e.every(ct))}function ct(e){return!q(e)||!Y(e.src)?!1:J(e.mimeType,Y)&&J(e.sizes,lt)&&J(e.theme,e=>e===`light`||e===`dark`)}function J(e,t){return e===void 0||t(e)}function Y(e){return typeof e==`string`}function lt(e){return Array.isArray(e)&&e.every(Y)}function X(e){return q(e)?e:{}}function ut(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}async function dt(e){if(e.jsonrpc!==`2.0`||typeof e.method!=`string`)return Z(e.id??null,-32600,`Invalid JSON-RPC request.`);if(e.id===void 0)return null;try{let t=nt(e.method,e.params),n=await ft(e.method,e.params,t);return ht(e.id,at(n,t))}catch(t){return t instanceof G?Z(e.id,-32022,t.message,t.data):t instanceof Q?Z(e.id,-32601,t.message):Z(e.id,-32602,t instanceof Error?t.message:String(t))}}async function ft(e,t,n){if(it(e,n))throw new Q(`${e} was removed in MCP ${I}.`);switch(e){case`server/discover`:return{supportedVersions:z,capabilities:{tools:{}},instructions:`agent-device drives iOS, Android, tvOS, Android TV, macOS, Linux, and web targets. Each tool mirrors the CLI command of the same name; tool descriptions carry the per-command contract.`,ttlMs:W,cacheScope:`public`};case`initialize`:return{protocolVersion:rt(t),capabilities:{tools:{}},serverInfo:K()};case`ping`:return{};case`tools/list`:return{tools:Ue(),...ot(n,W)};case`tools/call`:return await pt(t);default:throw new Q(`Unsupported MCP method: ${e}`)}}async function pt(e){let t=gt(e),n=vt(t,`name`);try{return await Ke.execute(n,_t(t.arguments))}catch(e){return mt(Se(xe(e)),!0)}}function mt(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}function ht(e,t){return{jsonrpc:`2.0`,id:e,result:t}}function Z(e,t,n,r){return{jsonrpc:`2.0`,id:e,error:{code:t,message:n,...r?{data:r}:{}}}}function gt(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t(`INVALID_ARGS`,`Expected object parameters.`);return e}function _t(e){return e===void 0?{}:gt(e)}function vt(e,n){let r=e[n];if(typeof r!=`string`||r.length===0)throw new t(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}var Q=class extends Error{};async function yt(){let e=bt(),t=new Et(t=>{e.push(t)});process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{try{t.push(e)}catch(e){Ot({jsonrpc:`2.0`,id:null,error:{code:-32700,message:e instanceof Error?e.message:String(e)}})}}),await new Promise(e=>{process.stdin.on(`end`,e),process.stdin.on(`close`,e),process.stdin.resume()}),await e.idle()}function bt(e={}){let t=e.handlePayload??xt,n=e.write??Ot,r=Promise.resolve();return{push:e=>{let i=Tt(e);r=r.then(async()=>{let r=await t(e);r&&n(r)}).catch(e=>{n({jsonrpc:`2.0`,id:i,error:{code:-32603,message:e instanceof Error?e.message:String(e)}})})},idle:async()=>{await r}}}function xt(e){return Array.isArray(e)?St(e):Ct(e)}async function St(e){let t=[];for(let n of e)t.push(...Dt(await Ct(n)));return t.length>0?t:null}async function Ct(e){let t;try{t=r.parse(e)}catch{return wt($(e))}return dt(t)}function wt(e){return{jsonrpc:`2.0`,id:e,error:{code:-32600,message:`Invalid JSON-RPC request.`}}}function Tt(e){return Array.isArray(e)?e.length===1?$(e[0]):null:$(e)}function $(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.id;if(typeof t==`string`||typeof t==`number`||t===null)return t}return null}var Et=class{buffer=``;sink;constructor(e){this.sink=e}push(e){for(this.buffer+=e;;){let e=this.tryReadLineMessage();if(e!==void 0){this.emit(e);continue}break}}tryReadLineMessage(){let e=this.buffer.indexOf(`
|
|
3
|
-
|
|
1
|
+
import{_ as e,o as t}from"./sdk-contracts.js";import{_ as n}from"./sdk-batch-runner.js";import{i as r}from"./command-catalog.js";import{n as i}from"./version.js";import{a,i as o,r as s,t as ee}from"./command-tools.js";import{n as c}from"./internal/bin.js";import{i as l,n as u,t as d}from"./cli-help.js";const f=`agent-device drives iOS, Android, tvOS, Android TV, macOS, Linux, and web apps. Tools mirror CLI commands of the same name; CLI flags are camelCase properties (--settle -> settle: true).
|
|
2
|
+
|
|
3
|
+
Start: known app -> call open {app, foreground: true} at once; do not probe with devices, apps, appstate, snapshot, or screenshot first. open returns the initial interactive snapshot with @refs. Unknown app id: devices, then apps, then open the discovered id; never invent ids. Existing session: continue from its state, do not reopen.
|
|
4
|
+
|
|
5
|
+
Loop: press/click/fill/longpress/hover/scroll/back with settle: true; the response is the settled UI diff, continue from it. snapshot {interactiveOnly: true} only when the diff lacks the next target or did not settle. Verify with wait {kind: "text", text}, wait {selector}, is, get, or find; a bare screenshot is not verification. End with close.
|
|
6
|
+
|
|
7
|
+
Targets: copy refs byte-for-byte (@e12, @e12~s4; keep @ and any ~sN). Refs go stale after mutations. Prefer refs, then id/label/role selectors; coordinates last. On a sparse/AX-unavailable warning its refs and selectors are invalid: screenshot, read the image, press {x, y}, then snapshot the changed screen.
|
|
8
|
+
|
|
9
|
+
Errors carry hints; follow them instead of re-planning. Call help only for specialized work (gestures, scripting, TV, macOS, web, remote, debugging) or an unclear command shape, never at startup.`;function p(){let e=new Set(n());return r().filter(t=>!e.has(t))}const m={name:`help`,description:`Usage guides. No topic: the full workflow card. topic = one of ${l().join(`, `)} for that guide, or a tool name for its complete flag reference. For specialized work or an unclear command shape only; not a startup step, not needed after an error that carries a hint.`,inputSchema:{type:`object`,properties:{topic:{type:`string`,description:`Guide topic or tool name; omit for the card.`}},additionalProperties:!1}},h=`CLI syntax over MCP: \`agent-device <command> <positionals> --flag\` = tool <command>; positionals are named properties (target, text, direction), flags camelCase (--settle -> settle: true, -i -> interactiveOnly: true). Terminal-only (no MCP tool; run in a shell): ${p().join(`, `)}.\n\n`;function te(e){let t=e.topic;if(t!==void 0&&typeof t!=`string`)return g(`Expected topic to be a string.`,!0);let n=t?d(c(t)):u();return n===null?g(`Unknown help topic: ${t}. ${m.description}`,!0):g(h+n)}function g(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}const _=`2026-07-28`,v=[_],y=[`2025-11-25`,`2025-06-18`],b=[...v,...y],x=`server/discover`,S=new Set([`initialize`,`ping`]),C=`io.modelcontextprotocol/protocolVersion`,w=`io.modelcontextprotocol/clientCapabilities`,T=`io.modelcontextprotocol/clientInfo`,E=36e5;var D=class extends Error{requested;constructor(e){super(`Unsupported MCP protocol version: ${e}. Supported: ${b.join(`, `)}.`),this.requested=e}get data(){return{supported:b,requested:this.requested}}};function O(t,n){let r=R(R(n)._meta),i=z(r,C);if(i===void 0){if(t===x)throw new e(`INVALID_ARGS`,`Expected _meta["${C}"] on ${x}.`);return`legacy`}if(!b.includes(i))throw new D(i);if(!M(r[w]))throw new e(`INVALID_ARGS`,`Expected _meta["${w}"] to be an object.`);let a=r[T];if(a!==void 0&&!N(a))throw new e(`INVALID_ARGS`,`Expected _meta["${T}"] to be a valid Implementation.`);if(!v.includes(i)){if(t===x)throw new D(i);return`legacy`}return`modern`}function ne(e){let t=z(R(e),`protocolVersion`);return t!==void 0&&y.includes(t)?t:`2025-11-25`}function re(e,t){return t===`modern`&&S.has(e)}function k(){return{name:`agent-device`,version:i()}}function A(e,t){return t===`legacy`||typeof e!=`object`||!e?e:{resultType:`complete`,...e,_meta:{...e._meta,"io.modelcontextprotocol/serverInfo":k()}}}function j(e,t){return e===`modern`?{ttlMs:t,cacheScope:`public`}:void 0}function M(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function N(e){return!M(e)||!I(e.name)||!I(e.version)?!1:F(e.title,I)&&F(e.description,I)&&F(e.websiteUrl,I)&&F(e.icons,e=>Array.isArray(e)&&e.every(P))}function P(e){return!M(e)||!I(e.src)?!1:F(e.mimeType,I)&&F(e.sizes,L)&&F(e.theme,e=>e===`light`||e===`dark`)}function F(e,t){return e===void 0||t(e)}function I(e){return typeof e==`string`}function L(e){return Array.isArray(e)&&e.every(I)}function R(e){return M(e)?e:{}}function z(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}async function B(e){if(e.jsonrpc!==`2.0`||typeof e.method!=`string`)return G(e.id??null,-32600,`Invalid JSON-RPC request.`);if(e.id===void 0)return null;try{let t=O(e.method,e.params),n=await V(e.method,e.params,t);return W(e.id,A(n,t))}catch(t){return t instanceof D?G(e.id,-32022,t.message,t.data):t instanceof Y?G(e.id,-32601,t.message):G(e.id,-32602,t instanceof Error?t.message:String(t))}}async function V(e,t,n){if(re(e,n))throw new Y(`${e} was removed in MCP ${_}.`);switch(e){case`server/discover`:return{supportedVersions:b,capabilities:{tools:{}},instructions:f,ttlMs:E,cacheScope:`public`};case`initialize`:return{protocolVersion:ne(t),capabilities:{tools:{}},serverInfo:k(),instructions:f};case`ping`:return{};case`tools/list`:return{tools:[...s(),m],...j(n,E)};case`tools/call`:return await H(t);default:throw new Y(`Unsupported MCP method: ${e}`)}}async function H(e){let t=K(e),n=J(t,`name`);try{return n===`help`?te(q(t.arguments)):await ee.execute(n,q(t.arguments))}catch(e){return U(o(a(e)),!0)}}function U(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}function W(e,t){return{jsonrpc:`2.0`,id:e,result:t}}function G(e,t,n,r){return{jsonrpc:`2.0`,id:e,error:{code:t,message:n,...r?{data:r}:{}}}}function K(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object parameters.`);return t}function q(e){return e===void 0?{}:K(e)}function J(t,n){let r=t[n];if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}var Y=class extends Error{};async function ie(){let e=ae(),t=new le(t=>{e.push(t)});process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{try{t.push(e)}catch(e){$({jsonrpc:`2.0`,id:null,error:{code:-32700,message:e instanceof Error?e.message:String(e)}})}}),await new Promise(e=>{process.stdin.on(`end`,e),process.stdin.on(`close`,e),process.stdin.resume()}),await e.idle()}function ae(e={}){let t=e.handlePayload??oe,n=e.write??$,r=Promise.resolve();return{push:e=>{let i=ce(e);r=r.then(async()=>{let r=await t(e);r&&n(r)}).catch(e=>{n({jsonrpc:`2.0`,id:i,error:{code:-32603,message:e instanceof Error?e.message:String(e)}})})},idle:async()=>{await r}}}function oe(e){return Array.isArray(e)?X(e):Z(e)}async function X(e){let t=[];for(let n of e)t.push(...ue(await Z(n)));return t.length>0?t:null}async function Z(e){let n;try{n=t.parse(e)}catch{return se(Q(e))}return B(n)}function se(e){return{jsonrpc:`2.0`,id:e,error:{code:-32600,message:`Invalid JSON-RPC request.`}}}function ce(e){return Array.isArray(e)?e.length===1?Q(e[0]):null:Q(e)}function Q(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.id;if(typeof t==`string`||typeof t==`number`||t===null)return t}return null}var le=class{buffer=``;sink;constructor(e){this.sink=e}push(e){for(this.buffer+=e;;){let e=this.tryReadLineMessage();if(e!==void 0){this.emit(e);continue}break}}tryReadLineMessage(){let e=this.buffer.indexOf(`
|
|
10
|
+
`);if(e===-1)return;let t=this.buffer.slice(0,e).trim();return this.buffer=this.buffer.slice(e+1),t.length>0?t:void 0}emit(e){this.sink(JSON.parse(e))}};function ue(e){return e?[e]:[]}function $(e){process.stdout.write(`${JSON.stringify(e)}\n`)}export{ie as runAgentDeviceMcpServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fn as e,Gn as t,Ln as n,Pn as r,Wn as i,kn as a,zn as o}from"./sdk-batch-runner.js";import{J as s,K as c,ot as l,q as u}from"./script-source-bundle.js";import{Dt as d}from"./internal/daemon.js";function f(e){return e.matchedRefs.length===0?{path:2,outcome:`unverifiable`,reason:`selector-miss`}:e.identitySetRefs.length===0?{path:3,outcome:`unverifiable`,reason:`identity-set-empty`}:e.identitySetRefs.length===1?e.identitySetRefs[0]===e.winnerRef?{path:4,outcome:`verified`}:{path:5,outcome:`unverifiable`,reason:`unique-but-wrong`}:e.siblingMatchRefs.length===1?e.siblingMatchRefs[0]===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:e.regionMemberRefs!==void 0&&e.regionMemberRefs.length>0&&e.viewportCandidateRef!==void 0?e.viewportCandidateRef===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:{path:6,outcome:`unverifiable`,reason:`no-signal-isolation`}}function p(e,t={}){let n=t.mode??`action`,{node:r,preActionNodes:i}=e;if(typeof r.index!=`number`)return;let o=u(i),s=a(_(r),i);if(n===`landmark`&&s.id===void 0&&s.label===void 0)return;let l=c(r,o,8),d=l.chain,f=v(i,r),p=y(r,o),b=x(r),C=+(d.length>0),w=e=>{let t=d.slice(0,e),n=S({nodes:i,byIndex:o,node:r,identity:s,ancestry:t,sibling:f,scrollRegion:p});return{candidate:{...s,ancestry:t,sibling:f,viewportOrder:n.viewportOrder,...p?{scrollRegion:p}:{},...b?{rect:b}:{},verification:`verified`},domain:n}};for(let e=d.length;e>=C;--e){let{candidate:t,domain:i}=w(e);if(h(t))return t.verification=m({node:r,domain:i,mode:n,brokenWalk:l.broken}),t;if(e===C)return g(t)}}function m(e){return e.brokenWalk?`unverifiable`:e.mode===`landmark`?`verified`:w({node:e.node,domain:e.domain})}function h(e){return t(i({...e,verification:`unverifiable`}))<=o}function g(e){return e.verification=`unverifiable`,t(i(e))>4096&&delete e.rect,e}const _=e;function v(e,t){return n(e,t)}function y(e,t){let n=d(e,t);if(!n)return;let r=_(n);return{role:r.role,...r.id===void 0?r.label===void 0?{}:{label:r.label}:{id:r.id}}}function b(e,t){return!e&&!t?!0:!e||!t?!1:r(e,t)}function x(e){let t=e.rect;if(t)return{x:t.x,y:t.y,width:t.width,height:t.height}}function S(e){let{nodes:t,byIndex:n,node:r,identity:i,ancestry:a,sibling:o,scrollRegion:c}=e,l=s(t,n,i,a),u=l.filter(e=>v(t,e)===o),d=l.length>0?l.filter(e=>b(y(e,n),c)):void 0,f=d?C(d):[];return{identitySet:l,siblingMatches:u,regionMembers:d,orderedRegion:f,viewportOrder:Math.max(f.findIndex(e=>e.index===r.index),0)}}function C(e){return e.map((e,t)=>({node:e,documentOrder:t,center:l(e.rect)})).sort((e,t)=>!e.center&&!t.center?e.documentOrder-t.documentOrder:e.center?t.center?e.center.y===t.center.y?e.center.x===t.center.x?e.documentOrder-t.documentOrder:e.center.x-t.center.x:e.center.y-t.center.y:-1:1).map(e=>e.node)}function w(e){let{node:t,domain:n}=e,r=t.ref,i=n.identitySet.map(e=>e.ref);return f({winnerRef:r,matchedRefs:i,identitySetRefs:i,siblingMatchRefs:n.siblingMatches.map(e=>e.ref),regionMemberRefs:n.regionMembers?.map(e=>e.ref),viewportCandidateRef:n.orderedRegion[n.viewportOrder]?.ref}).outcome}export{C as a,p as i,y as n,b as o,v as r,f as s,_ as t};
|