agent-device 0.20.6 → 0.20.7
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/README.md +3 -3
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.apk → agent-device-android-ime-helper-0.20.7.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.7.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.manifest.json → agent-device-android-ime-helper-0.20.7.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.apk → agent-device-android-snapshot-helper-0.20.7.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.7.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.manifest.json → agent-device-android-snapshot-helper-0.20.7.manifest.json} +6 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +20 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +67 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +339 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +78 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +31 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +29 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +36 -28
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +2 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +100 -12
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +57 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +1 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +18 -3
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-lifecycle.js +7 -7
- package/dist/src/app-lifecycle2.js +2 -0
- package/dist/src/app-log-files.js +1 -0
- package/dist/src/app-log-reconnect.js +1 -0
- package/dist/src/app-log-runtime.js +4 -0
- package/dist/src/app-resolution.js +2 -1
- package/dist/src/apps.js +5 -5
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/auth-session.js +1 -0
- package/dist/src/auth.js +2 -0
- package/dist/src/boot-diagnostics.js +2 -2
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-grammar.js +1 -0
- package/dist/src/cli-help.js +199 -259
- package/dist/src/cli-output.js +1 -0
- package/dist/src/cli-runner.js +1 -2
- package/dist/src/cli.js +6 -16
- package/dist/src/client-metro.js +1 -1
- package/dist/src/cloud-artifacts.d.ts +2 -137
- package/dist/src/command-schema.js +3 -3
- package/dist/src/connection-runtime.js +1 -0
- package/dist/src/connection.js +5 -0
- package/dist/src/context.js +1 -1
- package/dist/src/daemon-shutdown-report.js +1 -0
- package/dist/src/daemon.js +2 -0
- package/dist/src/debug-symbols.js +3 -3
- package/dist/src/device-claim-inspection.js +1 -0
- package/dist/src/device-input-state.js +2 -2
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +2 -0
- 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/harmonyos.js +1 -0
- package/dist/src/helper.js +1 -1
- package/dist/src/host-process.js +2 -2
- package/dist/src/ime-lifecycle.js +7 -7
- package/dist/src/index.d.ts +43 -12
- package/dist/src/input-actions.js +4 -4
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/input-actions3.js +1 -0
- package/dist/src/install-artifact.js +1 -5
- package/dist/src/install-artifact2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-runtime.js +1 -1
- package/dist/src/interaction-snapshot.js +1 -1
- package/dist/src/interaction-touch-reference-frame.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interactor.js +2 -2
- package/dist/src/interactor2.js +1 -1
- package/dist/src/internal/bin.js +2 -2
- package/dist/src/internal/daemon.js +8 -15
- package/dist/src/inventory.js +5 -0
- package/dist/src/inventory2.js +1 -0
- package/dist/src/inventory3.js +2 -0
- package/dist/src/inventory4.js +1 -0
- package/dist/src/inventory5.js +1 -0
- package/dist/src/inventory6.js +1 -0
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -0
- package/dist/src/limrun.d.ts +10 -125
- package/dist/src/limrun.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/logcat.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/owner-identity.js +1 -0
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-runtime-app-log-android-transport.js +1 -0
- package/dist/src/platform-runtime-app-log-process.js +1 -0
- package/dist/src/platform-runtime-host.js +1 -0
- package/dist/src/platform-runtime-network-web-transport.js +1 -0
- package/dist/src/platform-runtime-operation-host.js +5 -0
- package/dist/src/platform-runtime-toolchain-host.js +1 -0
- package/dist/src/platform-runtime.js +1 -0
- package/dist/src/prepare-kind.js +15 -0
- package/dist/src/process-entry.js +1 -0
- package/dist/src/process-lock.js +1 -1
- package/dist/src/provider-webdriver.js +1 -0
- package/dist/src/provider.js +1 -0
- package/dist/src/proxy.js +2 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/registry.js +24 -24
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay.js +3 -0
- package/dist/src/reporting.js +3 -3
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-lease.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime2.js +4 -0
- package/dist/src/runtime3.js +3 -0
- package/dist/src/runtime4.js +1 -0
- package/dist/src/runtime5.js +1 -0
- package/dist/src/runtime6.js +1 -0
- package/dist/src/runtime7.js +1 -0
- package/dist/src/screenshot-result.js +4 -4
- package/dist/src/screenshot.js +1 -0
- package/dist/src/sdk-android-adb.js +2 -2
- package/dist/src/sdk-batch-runner.js +3 -3
- package/dist/src/sdk-contracts.d.ts +31 -5
- package/dist/src/sdk-contracts.js +1 -1
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +280 -4
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selector-vocabulary.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +3 -3
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session.js +10 -9
- package/dist/src/shared.js +2 -0
- package/dist/src/shell-quote.js +1 -0
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -0
- package/dist/src/snapshot-session.js +1 -0
- package/dist/src/snapshot.js +1 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src2.js +2 -0
- package/dist/src/src3.js +1 -0
- package/dist/src/text-surface.js +1 -1
- package/dist/src/timing-safe-equal.js +1 -0
- package/dist/src/tool-provider.js +3 -3
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tool-provider3.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/web.js +1 -1
- package/package.json +36 -20
- package/server.json +2 -2
- package/skills/agent-device/SKILL.md +6 -31
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.6.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.6.apk.sha256 +0 -1
- package/dist/src/app-log-request-scope.js +0 -1
- package/dist/src/devices.js +0 -1
- package/dist/src/devices2.js +0 -1
- package/dist/src/devices3.js +0 -1
- package/dist/src/devices4.js +0 -1
- package/dist/src/provider-limrun-runtime.js +0 -1
- package/dist/src/register-builtins.js +0 -1
- package/dist/src/screenshot-geometry.js +0 -1
- package/dist/src/viewport-dimension.js +0 -15
package/dist/src/server.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{S as e,_ as t,n,o as r}from"./sdk-contracts.js";import{S as i,dn as a,g as o,h as s}from"./sdk-batch-runner.js";import{r as c,t as l}from"./sdk-device.js";import{Ct as u,Tt as d,Ut as ee,on as te}from"./viewport-dimension.js";import{_ as ne,b as f,s as p,v as m,y as h}from"./registry.js";import{i as re,n as g,t as _}from"./command-metadata.js";import{n as v}from"./version.js";import{i as ie,n as ae,r as oe,t as se}from"./cli-config.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,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}const w={type:`array`,items:{type:`string`}},T=C({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`]),E=C({field:f(),artifactType:f(),path:f(),localPath:f(),fileName:f()},[`field`]);function D(e={}){let t=e.properties??{},n=e.required??[];return C({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:f(`Snapshot ref without the @ prefix when the target was an @ref.`),selector:f(`Selector expression when the target was a selector.`),selectorChain:w,refLabel:f(),targetHittable:m(),hint:f(),warning:f(),message:f(),evidence:k,resolution:ce,cost:T,maestroNonHittableCoordinateFallbackAllowed:m(`Whether the direct iOS Maestro coordinate fallback was allowed for this selector.`),maestroNonHittableCoordinateFallbackUsed:m(`Whether the direct iOS Maestro coordinate fallback was actually used.`),maestroFallbackReason:S(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const O=C({diagnosticRef:f(`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:f(`UTF-8 truncated to 256 bytes.`),label:f(`UTF-8 truncated to 256 bytes.`)},[`diagnosticRef`]),ce={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[C({source:S(`runtime`),phase:S(`pre-action`),kind:S(`unique`)},[`source`,`phase`,`kind`]),C({source:S(`runtime`),phase:S(`pre-action`),kind:S(`disambiguated`),matchCount:b(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:O,tiebreak:x([`visible`,`deepest`,`smallest-area`],`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:O}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),C({source:S(`ref`),phase:S(`pre-action`),kind:S(`exact`)},[`source`,`phase`,`kind`]),C({source:S(`ref`),phase:S(`pre-action`),kind:S(`label-fallback`)},[`source`,`phase`,`kind`]),C({source:S(`direct-ios`),kind:S(`not-observed`)},[`source`,`kind`])]},k=C({foregroundApp:f(`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:f(`Order-independent digest of the post-action node multiset.`),changedFromBefore:m(`Whether the post-action digest differs from the pre-action capture digest. false is evidence, not failure.`)},[`nodeCount`,`interactiveNodeCount`,`digest`,`changedFromBefore`]),A=C({settled:m(`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:C({ref:f(`Plain ref body (e12) minted from the stored settled tree.`)},[`ref`])},diff:C({summary:C({additions:b(),removals:b(),unchanged:b()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:C({kind:x([`added`,`removed`]),text:f(),ref:f(`Plain ref body (e12) for added lines.`)},[`kind`,`text`])},truncated:m(`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:C({ref:f(`Plain ref body (e12) minted from the stored settled tree.`),role:f(),label:f()},[`ref`,`role`])},tailTruncated:m(`Present (true) when tail candidates exceeded the response cap.`),hint:f()},[`settled`,`waitedMs`,`captures`,`quietMs`,`timeoutMs`]),j={platform:x(c),target:x(l),device:f(`Human-readable device name.`),id:f(`Stable device id.`),kind:x(y)},M=[`platform`,`target`,`device`,`id`,`kind`],le=C({success:m(),exitCode:b(),stdout:f(),stderr:f(),error:h(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]);function ue(e){return{...e,properties:{...e.properties??{},settle:A}}}const N=D({properties:{evidence:k,settle:A,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:m(`Whether the command requested a double-tap action.`)}}),de={press:N,click:N,fill:D({properties:{text:f(`Text submitted to the field.`),delayMs:b(`Delay between typed characters in milliseconds.`),evidence:k,settle:A},required:[`text`]}),longpress:D({properties:{durationMs:b(),settle:A,gesture:S(`longpress`)}}),find:C({ref:f(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:b(`ADR 0014 ref frame epoch for read-only find actions.`),found:m(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:b(`Milliseconds waited for a read-only find condition.`),text:f(`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:f(`Locator kind used for the find action.`),query:f(`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:f(`Diagnostic message for mutating find actions.`),settle:A,cost:T},[],`Daemon response data for the find command.`),boot:C({...j,booted:{type:`boolean`,const:!0}},[...M,`booted`]),shutdown:C({...j,shutdown:le},[...M,`shutdown`]),viewport:C({width:b(),height:b(),message:f()},[`width`,`height`,`message`]),...p,back:ue(p.back),wait:C({waitedMs:b(),kind:S(`selector`),text:f(),selector:f(),captures:b(),nodeCount:b(),hint:f(),warning:f()},[`waitedMs`]),prepare:C({action:S(`ios-runner`),platform:x(c),deviceId:f(),deviceName:f(),kind:x(y),durationMs:b(),runner:C({},[]),cache:x([`exact`,`restore-key`,`miss`,`external`]),artifact:x([`valid`,`rebuilt`]),buildMs:b(),connectMs:b(),healthCheckMs:b(),xctestrunPath:f(),recoveryReason:f(),failureReason:f(),timing:C({totalMs:b(),additiveParts:C({buildMs:b(),connectAfterBuildMs:b(),healthCheckMs:b()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:C({connectMs:{type:`array`,items:S(`buildMs`)},healthCheckMs:{type:`array`,items:f()}},[`healthCheckMs`]),note:f()},[`totalMs`,`additiveParts`,`containment`,`note`]),message:f()},[`action`,`platform`,`deviceId`,`deviceName`,`kind`,`durationMs`,`runner`,`connectMs`,`healthCheckMs`,`timing`,`message`]),push:{type:`object`,oneOf:[C({platform:S(`ios`),bundleId:f(),message:f()},[`platform`,`bundleId`,`message`]),C({platform:S(`android`),package:f(),action:f(),extrasCount:b(),message:f()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":C({event:f(),eventUrl:f(),transport:S(`deep-link`),message:f()},[`event`,`eventUrl`,`transport`,`message`]),clipboard:{type:`object`,oneOf:[C({action:S(`read`),text:f()},[`action`,`text`]),C({action:S(`write`),textLength:b(),message:f()},[`action`,`textLength`,`message`])]},appstate:{type:`object`,oneOf:[C({platform:x([`ios`,`macos`]),appName:f(),appBundleId:f(),source:S(`session`),surface:x(ee),device_udid:f(`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`]),C({platform:S(`android`),package:f(),activity:f()},[`platform`,`package`,`activity`])]},keyboard:C({platform:x([`android`,`ios`]),action:x([`status`,`dismiss`,`enter`]),visible:m(),wasVisible:m(),dismissed:m(),attempts:b(),inputType:f(),type:x([`text`,`number`,`email`,`phone`,`password`,`datetime`,`unknown`]),inputMethodPackage:f(),focusedPackage:f(),focusedResourceId:f(),inputOwner:x([`app`,`ime`,`unknown`]),message:f()},[`platform`,`action`]),doctor:C({status:x([`pass`,`warn`,`fail`,`info`]),summary:f(),kind:x([`auto`,`react-native`,`expo`,`repack`]),platform:f(),target:x(l),targetApp:f(),metro:C({host:f(),port:b()},[`host`,`port`]),checks:{type:`array`,items:C({id:f(),status:x([`pass`,`warn`,`fail`,`info`]),summary:f(),hint:f(),command:f(),evidence:h()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`]),diff:C({mode:S(`snapshot`),baselineInitialized:m(),summary:C({additions:b(),removals:b(),unchanged:b()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:C({kind:x([`added`,`removed`]),text:f(),ref:f()},[`kind`,`text`])},warnings:w},[`mode`,`baselineInitialized`,`summary`,`lines`]),replay:C({replayed:b(),healed:b(),session:f(),sessionActive:m(`True iff the session is still active — the script had no terminal close.`),artifactPaths:w,snapshotDiagnostics:h(),message:f()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:C({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:[C({recording:S(`started`),outPath:f(),sessionStateDir:f(),recordingBackend:f(),recordingScope:f(),recordOnlySession:m(),activeSessionApp:h(),showTouches:m()},[`recording`,`outPath`,`sessionStateDir`,`showTouches`]),C({recording:S(`stopped`),outPath:f(),telemetryPath:f(),artifacts:{type:`array`,items:E},recordingBackend:f(),recordingScope:f(),recordOnlySession:m(),activeSessionApp:h(),durationMs:b(),showTouches:m(),warning:f(),overlayWarning:f(),chunks:{type:`array`,items:h()}},[`recording`,`outPath`,`artifacts`,`durationMs`,`showTouches`])]},trace:{type:`object`,oneOf:[C({trace:S(`started`),outPath:f()},[`trace`,`outPath`]),C({trace:S(`stopped`),outPath:f(),artifacts:{type:`array`,items:E}},[`trace`,`outPath`,`artifacts`])]}},fe={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: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`]}},P={...de,...fe};function F(t){return e(t)}function I(e){let t=[`Error (${e.code}): ${e.message}`];e.hint&&t.push(`Hint: ${e.hint}`),t.push(...d(e.details)),e.supportedOn&&t.push(`Supported on: ${e.supportedOn}`);let n=u(e.details);return n&&t.push(n),t.join(`
|
|
2
|
-
`)}function L(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)&&oe(t,e)&&(i[t]=a);return ie(i,t)}const R={devices:e=>({devices:e.map(te)}),apps:e=>({apps:e})};function z(e,t){let n=R[e];return n?n(t):t}function B(){let e=new Map;return{pinInput:(t,n,r)=>we(t,n,he(e,r,n.session)),mergeCommandResult:(t,n,r,i)=>ge(e,t,n,r,i),mergeDivergenceScreen:(t,n,r)=>Se(e,H(n,r),t)}}const V=new Set([`snapshot`,`find`]),pe=new Set(s.map(e=>e.name).filter(g).filter(e=>o(e))),me=new Set([`press`,`click`,`fill`,`longpress`,`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 ge(e,t,n,r,i){let a=H(r,i);if(pe.has(t)){ye(e,a,be(n));return}V.has(t)&&(t===`find`?ve(e,a,n):_e(e,a,n))}function _e(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 ve(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 ye(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 be(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),xe(i,n,r)}function xe(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 Se(e,t,n){let r=a(a(n?.divergence)?.screen);if(r?.state!==`available`)return;let i=r.refsGeneration;if(typeof i!=`number`)return;let o=[];Ce(r.refs,o),U(e,t,o,i)}function Ce(e,t){if(Array.isArray(e))for(let n of e){let e=a(n)?.ref;typeof e==`string`&&e.length>0&&t.push(e)}}function we(e,t,n){return n===void 0||n.size===0?t:e===`wait`?Te(t,n)??t:me.has(e)?Ee(t,n)??t:t}function Te(e,t){if(typeof e.ref!=`string`)return;let n=W(e.ref,t);return n===e.ref?void 0:{...e,ref:n}}function Ee(e,t){let n=a(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}`}function De(){return re().map(e=>{let t=e.name in P?P[e.name]:void 0;return{name:e.name,description:ne(e),inputSchema:G(e.name,e.inputSchema),...t?{outputSchema:t}:{}}})}function Oe(e={}){let n=B();return{execute:async(r,i)=>{if(!g(r))throw new t(`INVALID_ARGS`,`Unknown command tool: ${r}`);let a=G(r,_(r).inputSchema).properties,o=L(r,i,a),s=Ne(o),c=Le(o),l=n.pinInput(r,c,s.client.stateDir),u=await je(e,s.client);try{let t=await(e.runCommand??Me)(u,r,l);return n.mergeCommandResult(r,t,s.client.stateDir,c.session),{isError:!1,structuredContent:z(r,t),content:[{type:`text`,text:Re({name:r,input:c,result:t,outputFormat:s.outputFormat,responseLevel:s.client.responseLevel})}]}}catch(e){return ke(e,n,s.client.stateDir,c.session)}}}}function ke(e,t,n,r){let i=F(e);return t.mergeDivergenceScreen(i.details,n,r),{isError:!0,structuredContent:i,content:[{type:`text`,text:I(i)}]}}const Ae=Oe();async function je(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 Me(e,t,n){return await(await import(`./command-surface.js`).then(e=>e.t)).runCommand(e,t,n)}function Ne(e){return{client:Pe(e),outputFormat:Ie(e.mcpOutputFormat)}}function Pe(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=Fe(i);return o!==void 0&&(a.responseLevel=o),a}function Fe(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 Ie(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 Le(e){let{stateDir:t,mcpOutputFormat:n,includeCost:r,responseLevel:i,...a}=e;return a}function G(e,t){let n=i(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 Re(e){if(e.outputFormat===`json`||e.responseLevel!==void 0&&e.responseLevel!=="default")return K(e.result);let t=ae({name:e.name,input:e.input,result:e.result});return typeof t?.text==`string`?t.text:K(t?.data??e.result)}function K(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}async function ze(e){if(e.jsonrpc!==`2.0`||typeof e.method!=`string`)return q(e.id??null,-32600,`Invalid JSON-RPC request.`);if(e.id===void 0)return null;try{return We(e.id,await Be(e.method,e.params))}catch(t){return t instanceof X?q(e.id,-32601,t.message):q(e.id,-32602,t instanceof Error?t.message:String(t))}}async function Be(e,t){switch(e){case`initialize`:return{protocolVersion:He(t),capabilities:{tools:{}},serverInfo:{name:`agent-device`,version:v()}};case`ping`:return{};case`tools/list`:return{tools:De()};case`tools/call`:return await Ve(t);default:throw new X(`Unsupported MCP method: ${e}`)}}async function Ve(e){let t=J(e),n=Y(t,`name`);try{return await Ae.execute(n,Ge(t.arguments))}catch(e){return Ue(I(F(e)),!0)}}function He(e){return`2025-11-25`}function Ue(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}function We(e,t){return{jsonrpc:`2.0`,id:e,result:t}}function q(e,t,n){return{jsonrpc:`2.0`,id:e,error:{code:t,message:n}}}function J(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t(`INVALID_ARGS`,`Expected object parameters.`);return e}function Ge(e){return e===void 0?{}:J(e)}function Y(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 X=class extends Error{};async function Ke(){let e=qe(),t=new Qe(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 qe(e={}){let t=e.handlePayload??Je,n=e.write??$,r=Promise.resolve();return{push:e=>{let i=Ze(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 Je(e){return Array.isArray(e)?Ye(e):Z(e)}async function Ye(e){let t=[];for(let n of e)t.push(...$e(await Z(n)));return t.length>0?t:null}async function Z(e){let t;try{t=r.parse(e)}catch{return Xe(Q(e))}return ze(t)}function Xe(e){return{jsonrpc:`2.0`,id:e,error:{code:-32600,message:`Invalid JSON-RPC request.`}}}function Ze(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 Qe=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
|
-
`);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
|
|
1
|
+
import{S as e,_ as t,n,o as r}from"./sdk-contracts.js";import{n as i}from"./version.js";import{Hn as a,S as o,g as s,h as c}from"./sdk-batch-runner.js";import{i as l,t as u}from"./sdk-device.js";import{Et as ee,Ot as te,kt as ne,qt as re,un as ie}from"./prepare-kind.js";import{_ as d,g as f,h as ae,s as oe,v as p}from"./registry.js";import{i as se,n as ce,t as le}from"./command-metadata.js";import{n as ue,r as de,t as fe}from"./cli-config.js";import{t as pe}from"./cli-output.js";const m=[`simulator`,`emulator`,`device`];function h(e){return{type:`number`,...e?{description:e}:{}}}function g(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function _(e){return{type:`string`,const:e}}function v(e){return{type:[`string`,`null`],...e?{description:e}:{}}}function y(e,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}const b={type:`array`,items:{type:`string`}},x=y({wallClockMs:h(`Total wall-clock time for the request in milliseconds.`),runnerRoundTrips:h(`Number of real runner round-trips made while serving the request.`),nodeCount:h(`Number of nodes in the original node tree when the response carries one.`)},[`wallClockMs`,`runnerRoundTrips`]),S=y({field:p(),artifactType:p(),path:p(),localPath:p(),fileName:p()},[`field`]);function C(e={}){let t=e.properties??{},n=e.required??[];return y({targetKind:g([`point`,`ref`,`selector`],`Resolved interaction target kind.`),x:h(`Resolved interaction x coordinate when available.`),y:h(`Resolved interaction y coordinate when available.`),referenceWidth:h(`Reference frame width for visualizing the interaction point.`),referenceHeight:h(`Reference frame height for visualizing the interaction point.`),ref:p(`Snapshot ref without the @ prefix when the target was an @ref.`),selector:p(`Selector expression when the target was a selector.`),selectorChain:b,refLabel:p(),targetHittable:f(),hint:p(),warning:p(),message:p(),evidence:T,resolution:me,cost:x,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:_(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const w=y({diagnosticRef:p(`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:p(`UTF-8 truncated to 256 bytes.`),label:p(`UTF-8 truncated to 256 bytes.`)},[`diagnosticRef`]),me={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[y({source:_(`runtime`),phase:_(`pre-action`),kind:_(`unique`)},[`source`,`phase`,`kind`]),y({source:_(`runtime`),phase:_(`pre-action`),kind:_(`disambiguated`),matchCount:h(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:w,tiebreak:g([`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:w}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),y({source:_(`ref`),phase:_(`pre-action`),kind:_(`exact`)},[`source`,`phase`,`kind`]),y({source:_(`ref`),phase:_(`pre-action`),kind:_(`label-fallback`)},[`source`,`phase`,`kind`]),y({source:_(`direct-ios`),kind:_(`not-observed`)},[`source`,`kind`])]},T=y({foregroundApp:p(`Foreground app bundle id or name, when the capture carries it.`),nodeCount:h(`Node count in the post-action interactive-only capture.`),interactiveNodeCount:h(`Subset of nodeCount the platform reports as hittable.`),digest:p(`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`]),E=y({settled:f(`Whether the UI held the quiet window before the deadline. false is advisory, not failure.`),waitedMs:h(),captures:h(),quietMs:h(),timeoutMs:h(),refsGeneration:h(`Snapshot generation of the stored settled tree; refs on added diff lines were minted from it.`),refs:{type:`array`,items:y({ref:p(`Plain ref body (e12) minted from the stored settled tree.`)},[`ref`])},diff:y({summary:y({additions:h(),removals:h(),unchanged:h()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:y({kind:g([`added`,`removed`]),text:p(),ref:p(`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:y({ref:p(`Plain ref body (e12) minted from the stored settled tree.`),role:p(),label:p()},[`ref`,`role`])},tailTruncated:f(`Present (true) when tail candidates exceeded the response cap.`),hint:p()},[`settled`,`waitedMs`,`captures`,`quietMs`,`timeoutMs`]),D={platform:g(l),target:g(u),device:p(`Human-readable device name.`),id:p(`Stable device id.`),kind:g(m)},O=[`platform`,`target`,`device`,`id`,`kind`],he=y({success:f(),exitCode:h(),stdout:p(),stderr:p(),error:d(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]);function ge(e){return{...e,properties:{...e.properties??{},settle:E}}}const _e=C({properties:{evidence:T,settle:E,button:g([`secondary`,`middle`]),count:h(`Number of press/click repetitions.`),intervalMs:h(`Delay between repeated press/click actions.`),holdMs:h(`Hold duration for each action.`),jitterPx:h(`Randomization radius in pixels.`),doubleTap:f(`Whether the command requested a double-tap action.`)}}),k={text:p(`Text submitted to the field.`),delayMs:h(`Delay between typed characters in milliseconds.`),evidence:T,settle:E},ve=y({resourceId:v(`Android resource id of the exact field that changed.`),className:v(`Android class name of the exact field that changed.`),packageName:v(`Android package name that owns the exact field.`),rect:y({x:h(),y:h(),width:h(),height:h()},[`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:[{...C({properties:k,required:[`text`]}),not:y({},[`verification`])},C({properties:{...k,verification:_(`unconfirmed`),requested:p(`Literal text requested by the fill command.`),before:v(`Raw target text captured before the fill.`),after:v(`Raw target text captured after the fill.`),target:ve},required:[`text`,`verification`,`requested`,`before`,`after`,`target`]})]},longpress:C({properties:{durationMs:h(),settle:E,gesture:_(`longpress`)}}),find:y({ref:p(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:h(`ADR 0014 ref frame epoch for read-only find actions.`),found:f(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:h(`Milliseconds waited for a read-only find condition.`),text:p(`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:p(`Locator kind used for the find action.`),query:p(`Query argument used for the find action.`),x:h(`Resolved x coordinate for mutating find actions.`),y:h(`Resolved y coordinate for mutating find actions.`),message:p(`Diagnostic message for mutating find actions.`),settle:E,cost:x},[],`Daemon response data for the find command.`),boot:y({...D,booted:{type:`boolean`,const:!0}},[...O,`booted`]),shutdown:y({...D,shutdown:he},[...O,`shutdown`]),viewport:y({width:h(),height:h(),message:p()},[`width`,`height`,`message`]),...oe,back:ge(oe.back),wait:y({waitedMs:h(),kind:_(`selector`),text:p(),selector:p(),captures:h(),nodeCount:h(),hint:p(),warning:p()},[`waitedMs`]),prepare:y({action:_(`ios-runner`),platform:g(l),deviceId:p(),deviceName:p(),kind:g(m),durationMs:h(),runner:y({},[]),cache:g([`exact`,`restore-key`,`miss`,`external`]),artifact:g([`valid`,`rebuilt`]),buildMs:h(),connectMs:h(),healthCheckMs:h(),xctestrunPath:p(),recoveryReason:p(),failureReason:p(),timing:y({totalMs:h(),additiveParts:y({buildMs:h(),connectAfterBuildMs:h(),healthCheckMs:h()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:y({connectMs:{type:`array`,items:_(`buildMs`)},healthCheckMs:{type:`array`,items:p()}},[`healthCheckMs`]),note:p()},[`totalMs`,`additiveParts`,`containment`,`note`]),message:p()},[`action`,`platform`,`deviceId`,`deviceName`,`kind`,`durationMs`,`runner`,`connectMs`,`healthCheckMs`,`timing`,`message`]),push:{type:`object`,oneOf:[y({platform:_(`ios`),bundleId:p(),message:p()},[`platform`,`bundleId`,`message`]),y({platform:_(`android`),package:p(),action:p(),extrasCount:h(),message:p()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":y({event:p(),eventUrl:p(),transport:_(`deep-link`),message:p()},[`event`,`eventUrl`,`transport`,`message`]),clipboard:{type:`object`,oneOf:[y({action:_(`read`),text:p()},[`action`,`text`]),y({action:_(`write`),textLength:h(),message:p()},[`action`,`textLength`,`message`])]},appstate:{type:`object`,oneOf:[y({platform:g([`ios`,`macos`]),appName:p(),appBundleId:p(),source:_(`session`),surface:g(re),device_udid:p(`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`]),y({platform:_(`android`),package:p(),activity:p()},[`platform`,`package`,`activity`])]},keyboard:y({platform:g([`android`,`ios`]),action:g([`status`,`dismiss`,`enter`]),visible:f(),wasVisible:f(),dismissed:f(),attempts:h(),inputType:p(),type:g([`text`,`number`,`email`,`phone`,`password`,`datetime`,`unknown`]),inputMethodPackage:p(),focusedPackage:p(),focusedResourceId:p(),inputOwner:g([`app`,`ime`,`unknown`]),message:p()},[`platform`,`action`]),doctor:y({status:g([`pass`,`warn`,`fail`,`info`]),summary:p(),kind:g([`auto`,`react-native`,`expo`,`repack`]),platform:p(),target:g(u),targetApp:p(),metro:y({host:p(),port:h()},[`host`,`port`]),checks:{type:`array`,items:y({id:p(),status:g([`pass`,`warn`,`fail`,`info`]),summary:p(),hint:p(),command:p(),evidence:d()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`]),diff:y({mode:_(`snapshot`),baselineInitialized:f(),summary:y({additions:h(),removals:h(),unchanged:h()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:y({kind:g([`added`,`removed`]),text:p(),ref:p()},[`kind`,`text`])},warnings:b},[`mode`,`baselineInitialized`,`summary`,`lines`]),replay:y({replayed:h(),healed:h(),session:p(),sessionActive:f(`True iff the session is still active — the script had no terminal close.`),artifactPaths:b,snapshotDiagnostics:d(),message:p()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:y({total:h(),executed:h(),passed:h(),failed:h(),skipped:h(),notRun:h(),durationMs:h(),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:[y({recording:_(`started`),outPath:p(),sessionStateDir:p(),recordingBackend:p(),recordingScope:p(),recordOnlySession:f(),activeSessionApp:d(),showTouches:f()},[`recording`,`outPath`,`sessionStateDir`,`showTouches`]),y({recording:_(`stopped`),outPath:p(),telemetryPath:p(),artifacts:{type:`array`,items:S},recordingBackend:p(),recordingScope:p(),recordOnlySession:f(),activeSessionApp:d(),durationMs:h(),showTouches:f(),warning:p(),overlayWarning:p(),chunks:{type:`array`,items:d()}},[`recording`,`outPath`,`artifacts`,`durationMs`,`showTouches`])]},trace:{type:`object`,oneOf:[y({trace:_(`started`),outPath:p()},[`trace`,`outPath`]),y({trace:_(`stopped`),outPath:p(),artifacts:{type:`array`,items:S}},[`trace`,`outPath`,`artifacts`])]}},be={devices:{type:`object`,properties:{devices:{type:`array`,items:{type:`object`,properties:{platform:{type:`string`,enum:l},target:{type:`string`,enum:u},kind:{type:`string`,enum:m},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(...te(e.details)),e.supportedOn&&t.push(`Supported on: ${e.supportedOn}`);let n=ee(e.details);return n&&t.push(n),t.join(`
|
|
2
|
+
`)}function Ce(e,t,n){let r=fe({command:e,cwd:process.cwd(),cliFlags:t}),i={};for(let[t,a]of Object.entries(r))Object.hasOwn(n,t)&&ue(t,e)&&(i[t]=a);return de(i,t)}const we={devices:e=>({devices:e.map(ie)}),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,ne(n),r)}const Oe=new Set([`snapshot`,`find`]),ke=new Set(c.map(e=>e.name).filter(ce).filter(e=>s(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=a(a(n?.divergence)?.screen);if(r?.state!==`available`)return;let i=r.refsGeneration;if(typeof i!=`number`)return;let o=[];ze(r.refs,o),M(e,t,o,i)}function ze(e,t){if(Array.isArray(e))for(let n of e){let e=a(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=a(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 se().map(e=>{let t=e.name in A?A[e.name]:void 0;return{name:e.name,description:ae(e),inputSchema:P(e.name,e.inputSchema),...t?{outputSchema:t}:{}}})}function We(e={}){let n=Ee();return{execute:async(r,i)=>{if(!ce(r))throw new t(`INVALID_ARGS`,`Unknown command tool: ${r}`);let a=P(r,le(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=o(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=pe({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:i()}}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
|
+
`);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 Dt(e){return e?[e]:[]}function Ot(e){process.stdout.write(`${JSON.stringify(e)}\n`)}export{yt as runAgentDeviceMcpServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{At as e,Bt as t,Ft as n,Nt as r,Tt as i,Vt as a,jt as o}from"./sdk-batch-runner.js";import{$ as s,et as c,it as l,tt as u}from"./prepare-kind.js";import{rn 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:a}=e;if(typeof r.index!=`number`)return;let o=c(a),l=i(_(r),a);if(n===`landmark`&&l.id===void 0&&l.label===void 0)return;let u=s(r,o,8),d=u.chain,f=v(a,r),p=y(r,o),b=x(r),C=+(d.length>0),w=e=>{let t=d.slice(0,e),n=S({nodes:a,byIndex:o,node:r,identity:l,ancestry:t,sibling:f,scrollRegion:p});return{candidate:{...l,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:u.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 a(t({...e,verification:`unverifiable`}))<=n}function g(e){return e.verification=`unverifiable`,a(t(e))>4096&&delete e.rect,e}const _=o;function v(e,t){return r(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(t,n){return!t&&!n?!0:!t||!n?!1:e(t,n)}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:s}=e,c=u(t,n,i,a),l=c.filter(e=>v(t,e)===o),d=c.length>0?c.filter(e=>b(y(e,n),s)):void 0,f=d?C(d):[];return{identitySet:c,siblingMatches:l,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};
|