agent-device 0.21.14 → 0.21.16

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.
Files changed (310) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.14.apk → agent-device-android-ime-helper-0.21.16.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.16.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.14.manifest.json → agent-device-android-ime-helper-0.21.16.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.16.apk +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.16.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.14.manifest.json → agent-device-android-snapshot-helper-0.21.16.manifest.json} +6 -6
  7. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +11 -1
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +84 -2
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +4 -2
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerMainOwnedState.swift +27 -0
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedTextEntry.h +10 -4
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedTextEntry.m +21 -5
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSystemSurfaceHostPolicy.swift +0 -9
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +40 -5
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +179 -91
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +5 -4
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -1
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift +1 -0
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +36 -49
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+MainThreadWork.swift +11 -15
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +136 -29
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +4 -2
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +3 -0
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +6 -5
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +4 -0
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +2 -0
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +8 -4
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +56 -14
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +18 -8
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +9 -7
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +5 -4
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +2 -2
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +4 -1
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +5 -1
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +245 -41
  36. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +47 -2
  37. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +7 -4
  38. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +115 -111
  39. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +17 -10
  40. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +8 -9
  41. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +2 -1
  42. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +12 -11
  43. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +7 -4
  44. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +15 -8
  45. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +1 -0
  46. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +26 -9
  47. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +1 -0
  48. package/dist/src/adapter.js +1 -1
  49. package/dist/src/adb-executor.js +1 -1
  50. package/dist/src/adb-failure.js +1 -1
  51. package/dist/src/adb-transport.js +1 -1
  52. package/dist/src/agent-browser-provider.js +1 -1
  53. package/dist/src/agent-browser-tool.js +1 -1
  54. package/dist/src/agent-device-client.js +2 -2
  55. package/dist/src/ai-sdk.js +1 -1
  56. package/dist/src/alert-runtime.js +1 -1
  57. package/dist/src/android-adb.d.ts +1 -8
  58. package/dist/src/android-input-ownership.js +1 -1
  59. package/dist/src/android-snapshot-quality.js +1 -0
  60. package/dist/src/android-system-chrome.js +1 -1
  61. package/dist/src/android.js +1 -1
  62. package/dist/src/app-catalog.js +1 -1
  63. package/dist/src/app-deployment-resolution.js +1 -1
  64. package/dist/src/app-inventory.js +1 -1
  65. package/dist/src/app-launch.js +1 -1
  66. package/dist/src/app-lifecycle.js +1 -1
  67. package/dist/src/app-lifecycle2.js +1 -1
  68. package/dist/src/app-log-files.js +1 -1
  69. package/dist/src/app-log-runtime2.js +1 -1
  70. package/dist/src/app-resolution.js +2 -2
  71. package/dist/src/apple-runner-platform.js +1 -1
  72. package/dist/src/application-lifecycle-interaction.js +1 -1
  73. package/dist/src/archive.js +1 -1
  74. package/dist/src/artifact-download.js +1 -1
  75. package/dist/src/auth-session.js +1 -1
  76. package/dist/src/auth.js +1 -1
  77. package/dist/src/backend-snapshot-options.js +1 -1
  78. package/dist/src/boot-diagnostics.js +1 -1
  79. package/dist/src/capture-disclosure.js +1 -1
  80. package/dist/src/capture.js +1 -1
  81. package/dist/src/cli-config.js +1 -1
  82. package/dist/src/cli-help.js +3 -2
  83. package/dist/src/cli.js +4 -4
  84. package/dist/src/click-button.js +1 -1
  85. package/dist/src/client-metro.js +1 -1
  86. package/dist/src/client-types.d.ts +103 -96
  87. package/dist/src/clipboard-shell-response.js +1 -1
  88. package/dist/src/command-schema.js +1 -1
  89. package/dist/src/command-tools.js +3 -3
  90. package/dist/src/connection-runtime.js +1 -1
  91. package/dist/src/connection.js +5 -5
  92. package/dist/src/contracts.d.ts +1 -1
  93. package/dist/src/contracts.js +1 -1
  94. package/dist/src/daemon-client-lease-beat.js +1 -0
  95. package/dist/src/daemon-client-lifecycle.js +1 -1
  96. package/dist/src/daemon-client-transport.js +1 -0
  97. package/dist/src/daemon-shutdown-report.js +1 -1
  98. package/dist/src/daemon.js +1 -1
  99. package/dist/src/debug-symbols-facade.js +1 -1
  100. package/dist/src/device-claim-inspection.js +1 -1
  101. package/dist/src/device-claim-rule.js +2 -2
  102. package/dist/src/device-input-state.d.ts +15 -2
  103. package/dist/src/device-inventory-context.js +1 -1
  104. package/dist/src/device-rotation.js +1 -1
  105. package/dist/src/device-selection-resolver.js +1 -1
  106. package/dist/src/device-session.js +1 -1
  107. package/dist/src/device-shell.js +1 -1
  108. package/dist/src/device.js +1 -1
  109. package/dist/src/device2.js +1 -1
  110. package/dist/src/devicectl.js +1 -1
  111. package/dist/src/diagnostics.js +1 -1
  112. package/dist/src/dispatch-resolve.js +1 -1
  113. package/dist/src/doctor-facade.js +1 -1
  114. package/dist/src/doctor2.js +1 -1
  115. package/dist/src/durable-resource.js +1 -1
  116. package/dist/src/engine-eval-script.js +1 -1
  117. package/dist/src/error.js +1 -1
  118. package/dist/src/exec.js +1 -1
  119. package/dist/src/file.js +1 -1
  120. package/dist/src/find.js +1 -1
  121. package/dist/src/format.js +1 -1
  122. package/dist/src/gesture-admission.js +1 -1
  123. package/dist/src/gesture-plan-types.d.ts +1 -1
  124. package/dist/src/gesture-plan.js +1 -1
  125. package/dist/src/gesture-runtime.js +1 -1
  126. package/dist/src/harmonyos.js +1 -1
  127. package/dist/src/helper.js +2 -2
  128. package/dist/src/host.js +1 -1
  129. package/dist/src/human-control-contract.js +1 -1
  130. package/dist/src/human-control.js +1 -1
  131. package/dist/src/index.d.ts +7 -3
  132. package/dist/src/index.js +1 -1
  133. package/dist/src/input-actions.js +1 -1
  134. package/dist/src/input-actions2.js +1 -1
  135. package/dist/src/install-artifact-facade.js +1 -1
  136. package/dist/src/install-source-network-transport.js +1 -1
  137. package/dist/src/install-source2.js +1 -1
  138. package/dist/src/interaction-positionals.js +1 -1
  139. package/dist/src/interaction-ref-policy.js +1 -1
  140. package/dist/src/interaction2.js +1 -1
  141. package/dist/src/interactor-operation-binding.js +1 -1
  142. package/dist/src/interactor.js +5 -4
  143. package/dist/src/interactor2.js +1 -1
  144. package/dist/src/interactors.js +1 -1
  145. package/dist/src/internal/bin.js +1 -1
  146. package/dist/src/internal/daemon.js +2 -2
  147. package/dist/src/internal/png-worker.js +1 -1
  148. package/dist/src/internal/run-script-http-child.js +1 -1
  149. package/dist/src/inventory.js +1 -1
  150. package/dist/src/inventory2.js +1 -1
  151. package/dist/src/inventory3.js +1 -1
  152. package/dist/src/inventory5.js +1 -1
  153. package/dist/src/ios-snapshot-acquisition.js +1 -1
  154. package/dist/src/ios-snapshot-engine.js +1 -0
  155. package/dist/src/ios-snapshot-runtime.js +1 -1
  156. package/dist/src/lease-context.js +1 -1
  157. package/dist/src/lease-scope.js +1 -1
  158. package/dist/src/lease.js +1 -1
  159. package/dist/src/limrun-download-file.js +1 -1
  160. package/dist/src/limrun-runtime-dependencies.js +1 -1
  161. package/dist/src/limrun.d.ts +16 -3
  162. package/dist/src/linux.js +1 -1
  163. package/dist/src/location-coordinates.js +1 -1
  164. package/dist/src/managed-device-scope.js +1 -1
  165. package/dist/src/mechanics.js +17 -17
  166. package/dist/src/mobile-snapshot-semantics.js +1 -1
  167. package/dist/src/multitouch-support.js +1 -1
  168. package/dist/src/native-build-cache.js +1 -1
  169. package/dist/src/observation.js +1 -1
  170. package/dist/src/overlay.js +3 -0
  171. package/dist/src/parameterized-recorded-fill.js +1 -1
  172. package/dist/src/perf-facade.js +1 -1
  173. package/dist/src/perf-runtime-operation-builder.js +1 -1
  174. package/dist/src/perf-runtime-plan.js +1 -1
  175. package/dist/src/perf-target.js +1 -1
  176. package/dist/src/perf.js +1 -1
  177. package/dist/src/physical-device-control.js +1 -1
  178. package/dist/src/platform-request-scope.js +1 -1
  179. package/dist/src/platform-runtime-managed-owner.js +1 -1
  180. package/dist/src/platform-runtime-open-target.js +1 -1
  181. package/dist/src/platform-runtime-operation-host.js +4 -4
  182. package/dist/src/platform-runtime-runtime-hints.js +1 -1
  183. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  184. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  185. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  186. package/dist/src/platform-runtime-unavailable.js +1 -1
  187. package/dist/src/platform-runtime.js +1 -1
  188. package/dist/src/platform-runtime2.js +1 -1
  189. package/dist/src/png-crop-bytes.js +1 -1
  190. package/dist/src/png-size.js +1 -1
  191. package/dist/src/png-worker-client.js +1 -1
  192. package/dist/src/png.js +1 -1
  193. package/dist/src/prepare-kind.js +1 -1
  194. package/dist/src/provider-session-ownership.js +1 -1
  195. package/dist/src/provider-webdriver.js +1 -1
  196. package/dist/src/proxy.js +1 -1
  197. package/dist/src/quality-warnings.js +1 -1
  198. package/dist/src/react-native.js +1 -1
  199. package/dist/src/record-runtime.js +1 -1
  200. package/dist/src/recording.js +1 -1
  201. package/dist/src/rect-center.js +1 -1
  202. package/dist/src/register-builtins.js +1 -1
  203. package/dist/src/registry.js +36 -36
  204. package/dist/src/remote-config2.js +1 -1
  205. package/dist/src/replay-divergence.js +1 -1
  206. package/dist/src/replay.js +1 -1
  207. package/dist/src/reporting.js +1 -1
  208. package/dist/src/request-admission.js +1 -1
  209. package/dist/src/request-cancel.js +1 -1
  210. package/dist/src/request-runtime-binding.js +1 -1
  211. package/dist/src/result-serialization.js +1 -1
  212. package/dist/src/retry.js +1 -1
  213. package/dist/src/runner-artifact-manifest.js +1 -0
  214. package/dist/src/runner-cache-metadata.js +3 -2
  215. package/dist/src/runner-client.js +1 -1
  216. package/dist/src/runner-dev-tools-security.js +1 -1
  217. package/dist/src/runner-device-readiness.js +1 -1
  218. package/dist/src/runner-disposal.js +1 -1
  219. package/dist/src/runner-error-classification.js +3 -3
  220. package/dist/src/runner-operations-facade.js +1 -1
  221. package/dist/src/runner.js +1 -1
  222. package/dist/src/runtime-transport-hints.js +1 -1
  223. package/dist/src/runtime.js +1 -3
  224. package/dist/src/runtime10.js +2 -2
  225. package/dist/src/runtime2.js +4 -4
  226. package/dist/src/runtime3.js +1 -1
  227. package/dist/src/runtime4.js +5 -5
  228. package/dist/src/runtime5.js +1 -1
  229. package/dist/src/runtime6.js +1 -1
  230. package/dist/src/runtime7.js +1 -1
  231. package/dist/src/runtime8.js +1 -1
  232. package/dist/src/runtime9.js +1 -1
  233. package/dist/src/screen-recording-admission-ledger.js +1 -1
  234. package/dist/src/screen-recording-completion.js +1 -1
  235. package/dist/src/screen-recording-options.js +1 -1
  236. package/dist/src/screen-recording-resource-recovery.js +1 -1
  237. package/dist/src/screen-recording-transport.js +1 -1
  238. package/dist/src/screenshot-density.js +1 -1
  239. package/dist/src/screenshot-image.js +1 -1
  240. package/dist/src/screenshot-overlay-draw.js +1 -1
  241. package/dist/src/screenshot-runtime.js +1 -1
  242. package/dist/src/screenshot.js +1 -1
  243. package/dist/src/screenshot3.js +1 -1
  244. package/dist/src/script.js +1 -1
  245. package/dist/src/scroll-command.d.ts +13 -6
  246. package/dist/src/scroll-command.js +1 -1
  247. package/dist/src/scroll-gesture.js +1 -1
  248. package/dist/src/sdk-batch-runner.js +2 -2
  249. package/dist/src/sdk-batch.js +2 -2
  250. package/dist/src/sdk-contracts.d.ts +38 -10
  251. package/dist/src/sdk-contracts.js +2 -2
  252. package/dist/src/sdk-device.js +1 -1
  253. package/dist/src/sdk-finders.d.ts +1 -1
  254. package/dist/src/sdk-io.js +1 -1
  255. package/dist/src/sdk-remote-config.js +1 -1
  256. package/dist/src/sdk-selectors.d.ts +1 -1
  257. package/dist/src/selection.js +0 -0
  258. package/dist/src/selector-runtime.js +1 -1
  259. package/dist/src/server.js +1 -1
  260. package/dist/src/session-allocation.js +1 -1
  261. package/dist/src/session-routing.js +1 -1
  262. package/dist/src/session-runtime-admission.js +1 -1
  263. package/dist/src/session-snapshot.js +1 -1
  264. package/dist/src/session-store.js +3 -3
  265. package/dist/src/session.js +1 -1
  266. package/dist/src/session2.js +4 -4
  267. package/dist/src/settings.js +1 -1
  268. package/dist/src/settings2.js +1 -0
  269. package/dist/src/simctl.js +1 -1
  270. package/dist/src/simulator-boot.js +1 -1
  271. package/dist/src/simulator.js +1 -1
  272. package/dist/src/snapshot-capture-annotations.js +1 -1
  273. package/dist/src/snapshot-desktop-projection.js +1 -1
  274. package/dist/src/snapshot-runtime-binding.js +1 -1
  275. package/dist/src/snapshot-runtime.js +1 -1
  276. package/dist/src/snapshot-state.js +1 -1
  277. package/dist/src/snapshot2.js +1 -1
  278. package/dist/src/snapshot3.js +1 -1
  279. package/dist/src/snapshot4.js +1 -1
  280. package/dist/src/src.js +1 -1
  281. package/dist/src/src4.js +1 -1
  282. package/dist/src/src7.js +1 -1
  283. package/dist/src/src8.js +2 -2
  284. package/dist/src/stop-sequence.js +1 -1
  285. package/dist/src/string-enum.js +1 -1
  286. package/dist/src/surface-snapshot.js +1 -1
  287. package/dist/src/takeover.js +1 -1
  288. package/dist/src/text-entry-focus.js +1 -1
  289. package/dist/src/tool-provider.js +1 -1
  290. package/dist/src/tool-provider2.js +1 -1
  291. package/dist/src/touch-runtime.js +1 -1
  292. package/dist/src/transport.js +1 -1
  293. package/dist/src/tree.js +1 -1
  294. package/dist/src/tv-remote.js +1 -1
  295. package/dist/src/type-text-runtime.js +1 -1
  296. package/dist/src/verified-file.js +1 -1
  297. package/dist/src/video.js +1 -1
  298. package/dist/src/viewport.js +1 -1
  299. package/dist/src/web.js +1 -1
  300. package/dist/src/web2.js +1 -1
  301. package/dist/src/webdriver-source.js +1 -1
  302. package/package.json +2 -2
  303. package/server.json +2 -2
  304. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.14.apk.sha256 +0 -1
  305. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.14.apk +0 -0
  306. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.14.apk.sha256 +0 -1
  307. package/dist/src/absence-observation-errors.js +0 -1
  308. package/dist/src/runner-presentation.js +0 -1
  309. package/dist/src/semantic-index.js +0 -1
  310. package/dist/src/snapshot-scope.js +0 -1
@@ -1 +1 @@
1
- import{D as e}from"./owner-identity.js";import"./file.js";import t from"node:path";import n from"node:fs";function r(t,r){let i={providerReleases:{released:r.providerReleases.released.map(s),pending:r.providerReleases.pending.map(s)},claims:{released:[...r.claims.released],orphaned:[...r.claims.orphaned],superseded:[...r.claims.superseded]}},a=o(t);try{e({destination:a,contents:`${JSON.stringify(i)}\n`,mode:384}),n.chmodSync(a,384)}catch{}}function i(e){try{let t=JSON.parse(n.readFileSync(o(e),`utf8`));return c(t)?{...t,claims:l(t)}:null}catch{return null}}function a(e){try{n.rmSync(o(e),{force:!0})}catch{}}function o(e){return t.join(e,`daemon-shutdown.json`)}function s(e){return{leaseId:e.leaseId,...e.leaseProvider?{provider:e.leaseProvider}:{}}}function c(e){if(!e||typeof e!=`object`)return!1;let t=e.providerReleases;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.released)&&Array.isArray(n.pending)&&n.released.every(f)&&n.pending.every(f)}function l(e){let t=e.claims;if(!t||typeof t!=`object`)return{released:[],orphaned:[],superseded:[]};let n=t;return{released:u(n.released),orphaned:u(n.orphaned),superseded:u(n.superseded)}}function u(e){return Array.isArray(e)?e.filter(d):[]}function d(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.deviceKey==`string`&&typeof t.session==`string`&&typeof t.platform==`string`&&typeof t.deviceId==`string`}function f(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.leaseId==`string`&&t.leaseId.trim().length>0&&(t.provider===void 0||typeof t.provider==`string`)}export{i as n,r,a as t};
1
+ import{D as e}from"./owner-identity.js";import"./file.js";import t from"node:path";import n from"node:fs";function r(t,r){let i={providerReleases:{released:r.providerReleases.released.map(s),pending:r.providerReleases.pending.map(s)},claims:{released:[...r.claims.released],orphaned:[...r.claims.orphaned],superseded:[...r.claims.superseded],unattributable:[...r.claims.unattributable]}},a=o(t);try{e({destination:a,contents:`${JSON.stringify(i)}\n`,mode:384}),n.chmodSync(a,384)}catch{}}function i(e){try{let t=JSON.parse(n.readFileSync(o(e),`utf8`));return c(t)?{...t,claims:l(t)}:null}catch{return null}}function a(e){try{n.rmSync(o(e),{force:!0})}catch{}}function o(e){return t.join(e,`daemon-shutdown.json`)}function s(e){return{leaseId:e.leaseId,...e.leaseProvider?{provider:e.leaseProvider}:{}}}function c(e){if(!e||typeof e!=`object`)return!1;let t=e.providerReleases;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.released)&&Array.isArray(n.pending)&&n.released.every(f)&&n.pending.every(f)}function l(e){let t=e.claims;if(!t||typeof t!=`object`)return{released:[],orphaned:[],superseded:[],unattributable:[]};let n=t;return{released:u(n.released),orphaned:u(n.orphaned),superseded:u(n.superseded),unattributable:u(n.unattributable)}}function u(e){return Array.isArray(e)?e.filter(d):[]}function d(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.deviceKey==`string`&&typeof t.session==`string`&&typeof t.platform==`string`&&typeof t.deviceId==`string`}function f(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.leaseId==`string`&&t.leaseId.trim().length>0&&(t.provider===void 0||typeof t.provider==`string`)}export{i as n,r,a as t};
@@ -1,2 +1,2 @@
1
- import{O as e}from"./sdk-contracts.js";import{p as t}from"./owner-identity.js";import{t as n}from"./timeouts.js";import"./retry.js";import{t as r}from"./daemon-resolution.js";import"./process.js";import{i,r as a,t as o}from"./daemon-process.js";import{n as s}from"./daemon-registration.js";import{n as c}from"./daemon-shutdown-report.js";import{t as l}from"./shared.js";import u from"node:fs";async function d(n){let r=s(n.paths.infoPath);if(!r)return h();if(!r.startTime){if(!t(r.pid))return h();throw new e(`COMMAND_FAILED`,`Refusing to stop a daemon without a verified process start-time identity.`,{pid:r.pid})}if(!o(r.pid,r.startTime)){if(!t(r.pid))return h();throw new e(`COMMAND_FAILED`,`Refusing to stop a daemon whose PID or start-time identity could not be verified.`,{pid:r.pid,processStartTime:r.startTime})}let a={pid:r.pid,startTime:r.startTime};if(!f(r.pid,`SIGTERM`))return h();let{exited:c}=await i(a,{timeoutMs:n.graceTimeoutMs??1e4});if(c)return await m(n.paths,1e3),{stopped:!0,mode:`graceful`,cleanupConfidence:`known`,claimsReleased:[],claimsOrphaned:[],claimsSuperseded:[],providerReleases:{status:`completed`,released:[],pending:[]},warnings:[]};o(r.pid,r.startTime)&&f(r.pid,`SIGKILL`);let{exited:l}=await i(a,{timeoutMs:n.killTimeoutMs??2e3});if(!l)throw new e(`COMMAND_FAILED`,`Daemon did not exit after SIGKILL.`,{pid:r.pid});return{stopped:!0,mode:`forced`,cleanupConfidence:`unknown`,claimsReleased:[],claimsOrphaned:[],claimsSuperseded:[],providerReleases:{status:`unknown`,released:[],pending:null},warnings:[`The daemon was force-killed before provider lease state could be finalized. Provider allocations may remain active.`]}}function f(n,r){if(a(n,r))return!0;if(!t(n))return!1;throw new e(`COMMAND_FAILED`,`Daemon could not be signaled with ${r}.`,{pid:n,signal:r})}function p(e){let t=s(e);return t?.startTime?{pid:t.pid,processStartTime:t.startTime}:null}async function m(e,t){let r=Date.now();for(;Date.now()-r<t;){if(!u.existsSync(e.infoPath)&&!u.existsSync(e.lockPath))return;await n(25)}}function h(){return{stopped:!1,mode:`not-running`,cleanupConfidence:`known`,claimsReleased:[],claimsOrphaned:[],claimsSuperseded:[],providerReleases:{status:`completed`,released:[],pending:[]},warnings:[]}}function g(){return Object.freeze({cleanup:async e=>{let{cleanupRunnerLeasesForOwner:t}=await import(`./runner-operations-facade.js`);await t(e)}})}const _=g(),v=async({positionals:t,flags:n})=>{if(t[0]!==`stop`||t.length!==1)throw new e(`INVALID_ARGS`,`daemon accepts only: stop`);let i=r(n.stateDir),a=p(i.infoPath),o=await d({paths:i}),s=y(o,o.mode===`graceful`?c(i.baseDir):null),u=n.clean===!0&&a!==null&&s.stopped;u&&await _.cleanup({pid:a.pid,startTime:a.processStartTime});let f={...s,clean:u};return await l(n,f,()=>S(f)),!0};function y(e,t){return e.mode!==`graceful`||t?t?{...e,providerReleases:{status:`completed`,...t.providerReleases},claimsReleased:t.claims.released,claimsOrphaned:t.claims.orphaned,claimsSuperseded:t.claims.superseded,warnings:[...e.warnings,...b(t.claims.superseded),...x(t.claims.orphaned)]}:e:{...e,cleanupConfidence:`unknown`,providerReleases:{status:`unknown`,released:[],pending:null},warnings:[...e.warnings,`The graceful shutdown report is unavailable, so provider cleanup state is unknown. Provider allocations may remain active.`]}}function b(e){return e.length===0?[]:[`Another owner had already claimed ${e.map(e=>e.deviceId).join(`, `)} before this daemon released it, so those devices are now owned elsewhere.`]}function x(e){return e.length===0?[]:[`Ownership of ${e.map(e=>e.deviceId).join(`, `)} was not released cleanly; the claim now blocks other owners until it is settled. Inspect with: agent-device device status --stale, then release with: agent-device device release --stale.`]}function S(e){return[e.stopped?`Daemon stopped (${e.mode}).`:`No running daemon found.`,e.clean?`Retained runner cleanup completed.`:null,...e.warnings].filter(e=>!!e).join(`
1
+ import{M as e}from"./sdk-contracts.js";import{p as t}from"./owner-identity.js";import{t as n}from"./timeouts.js";import"./retry.js";import{t as r}from"./daemon-resolution.js";import"./process.js";import{i,r as a,t as o}from"./daemon-process.js";import{n as s}from"./daemon-registration.js";import{n as c}from"./daemon-shutdown-report.js";import{t as l}from"./shared.js";import u from"node:fs";async function d(n){let r=s(n.paths.infoPath);if(!r)return h();if(!r.startTime){if(!t(r.pid))return h();throw new e(`COMMAND_FAILED`,`Refusing to stop a daemon without a verified process start-time identity.`,{pid:r.pid})}if(!o(r.pid,r.startTime)){if(!t(r.pid))return h();throw new e(`COMMAND_FAILED`,`Refusing to stop a daemon whose PID or start-time identity could not be verified.`,{pid:r.pid,processStartTime:r.startTime})}let a={pid:r.pid,startTime:r.startTime};if(!f(r.pid,`SIGTERM`))return h();let{exited:c}=await i(a,{timeoutMs:n.graceTimeoutMs??1e4});if(c)return await m(n.paths,1e3),{stopped:!0,mode:`graceful`,cleanupConfidence:`known`,claimsReleased:[],claimsOrphaned:[],claimsSuperseded:[],claimsUnattributable:[],providerReleases:{status:`completed`,released:[],pending:[]},warnings:[]};o(r.pid,r.startTime)&&f(r.pid,`SIGKILL`);let{exited:l}=await i(a,{timeoutMs:n.killTimeoutMs??2e3});if(!l)throw new e(`COMMAND_FAILED`,`Daemon did not exit after SIGKILL.`,{pid:r.pid});return{stopped:!0,mode:`forced`,cleanupConfidence:`unknown`,claimsReleased:[],claimsOrphaned:[],claimsSuperseded:[],claimsUnattributable:[],providerReleases:{status:`unknown`,released:[],pending:null},warnings:[`The daemon was force-killed before provider lease state could be finalized. Provider allocations may remain active.`]}}function f(n,r){if(a(n,r))return!0;if(!t(n))return!1;throw new e(`COMMAND_FAILED`,`Daemon could not be signaled with ${r}.`,{pid:n,signal:r})}function p(e){let t=s(e);return t?.startTime?{pid:t.pid,processStartTime:t.startTime}:null}async function m(e,t){let r=Date.now();for(;Date.now()-r<t;){if(!u.existsSync(e.infoPath)&&!u.existsSync(e.lockPath))return;await n(25)}}function h(){return{stopped:!1,mode:`not-running`,cleanupConfidence:`known`,claimsReleased:[],claimsOrphaned:[],claimsSuperseded:[],claimsUnattributable:[],providerReleases:{status:`completed`,released:[],pending:[]},warnings:[]}}function g(){return Object.freeze({cleanup:async e=>{let{cleanupRunnerLeasesForOwner:t}=await import(`./runner-operations-facade.js`);await t(e)}})}const _=g(),v=async({positionals:t,flags:n})=>{if(t[0]!==`stop`||t.length!==1)throw new e(`INVALID_ARGS`,`daemon accepts only: stop`);let i=r(n.stateDir),a=p(i.infoPath),o=await d({paths:i}),s=y(o,o.mode===`graceful`?c(i.baseDir):null),u=n.clean===!0&&a!==null&&s.stopped;u&&await _.cleanup({pid:a.pid,startTime:a.processStartTime});let f={...s,clean:u};return await l(n,f,()=>C(f)),!0};function y(e,t){return e.mode!==`graceful`||t?t?{...e,providerReleases:{status:`completed`,...t.providerReleases},claimsReleased:t.claims.released,claimsOrphaned:t.claims.orphaned,claimsSuperseded:t.claims.superseded,claimsUnattributable:t.claims.unattributable,warnings:[...e.warnings,...b(t.claims.superseded),...x(t.claims.orphaned),...S(t.claims.unattributable)]}:e:{...e,cleanupConfidence:`unknown`,providerReleases:{status:`unknown`,released:[],pending:null},warnings:[...e.warnings,`The graceful shutdown report is unavailable, so provider cleanup state is unknown. Provider allocations may remain active.`]}}function b(e){return e.length===0?[]:[`Another owner had already claimed ${e.map(e=>e.deviceId).join(`, `)} before this daemon released it, so those devices are now owned elsewhere.`]}function x(e){return e.length===0?[]:[`Ownership of ${e.map(e=>e.deviceId).join(`, `)} was not released cleanly; the claim now blocks other owners until it is settled. Inspect with: agent-device device status --stale, then release with: agent-device device release --stale.`]}function S(e){return e.length===0?[]:[`A claim for ${e.map(e=>e.deviceId).join(`, `)} remains whose owner could not be read, so this daemon cannot say whether those devices are free. No device release route settles it: --stale proves staleness from the recorded owner and refuses records that name none, and open refuses to overwrite them. Inspect with: agent-device device status.`]}function C(e){return[e.stopped?`Daemon stopped (${e.mode}).`:`No running daemon found.`,e.clean?`Retained runner cleanup completed.`:null,...e.warnings].filter(e=>!!e).join(`
2
2
  `)}export{v as daemonCommand};
@@ -1,4 +1,4 @@
1
- import{O as e}from"./sdk-contracts.js";import{_ as t}from"./sdk-batch-runner.js";import{s as n}from"./owner-identity.js";import{a as r,c as i}from"./exec.js";import"./command.js";import"./process.js";import{D as a,g as o,o as s,u as c,y as l}from"./host-file.js";import u from"node:path";const d=/^[0-9a-fA-F-]{32,36}$/;function f(e){if(!(!e||!d.test(e)))return e.replaceAll(`-`,``).toUpperCase()}function p(e,t){return`${e.uuid}:${m(t)}`}function m(e){return`0x${e.toString(16)}`}function h(e){return typeof e==`string`&&e.length>0?e:void 0}function g(...e){for(let t of e){let e=h(t);if(e)return e}}function _(e){let t=e.filter(e=>!!e);return t.length>0?t.join(` `):void 0}function v(e){try{let n=JSON.parse(e);return t(n)?n:null}catch{return null}}function y(e){if(typeof e==`number`&&Number.isSafeInteger(e))return e;if(typeof e==`string`){let t=e.startsWith(`0x`)?Number.parseInt(e,16):Number(e);return Number.isSafeInteger(t)?t:void 0}}function b(e,t,n){if(!Object.hasOwn(e,t))return;let r=y(e[t]);if(r!==void 0)return r;S(n,t)}function x(e,t,n){if(!Object.hasOwn(e,t))return;let r=ee(e[t]);if(r!==void 0)return r;S(n,t)}function ee(e){if(typeof e==`bigint`)return e;if(typeof e==`number`&&Number.isSafeInteger(e)||typeof e==`string`&&/^(?:0x[0-9a-fA-F]+|\d+)$/.test(e))return BigInt(e)}function S(t,n){throw new e(`INVALID_ARGS`,`Invalid ${t} numeric field: ${n}`,{hint:`Crash artifact numeric fields must be integer numbers or integer numeric strings.`})}function C(e){return e.length===1?e[0]:void 0}function w(e){return[...new Set(e)]}function te(e){let t=e.match(/^(.*) \+ (\d+)$/);return t?{symbol:t[1],location:Number(t[2])}:{symbol:e}}const ne=/^(?:arm64e?|arm64_32|x86_64|armv7[sk]?|i386)$/;function re(e){return ie(e)??O(e)}function ie(e){let t=ae(e);if(!t)return null;let n=(Array.isArray(t.payload.usedImages)?t.payload.usedImages:[]).flatMap((e,t)=>D(e,t));if(n.length===0)return null;let r=oe(Array.isArray(t.payload.threads)?t.payload.threads:[],n);return{format:`ips`,images:n,addresses:r.map(({frame:e,...t})=>t),document:t,frameMatches:r,write:e=>T(t,r,e)}}function ae(e){let t=v(e);if(t)return{payload:t};let n=e.indexOf(`
1
+ import{M as e}from"./sdk-contracts.js";import{_ as t}from"./sdk-batch-runner.js";import{s as n}from"./owner-identity.js";import{a as r,c as i}from"./exec.js";import"./command.js";import"./process.js";import{D as a,g as o,o as s,u as c,y as l}from"./host-file.js";import u from"node:path";const d=/^[0-9a-fA-F-]{32,36}$/;function f(e){if(!(!e||!d.test(e)))return e.replaceAll(`-`,``).toUpperCase()}function p(e,t){return`${e.uuid}:${m(t)}`}function m(e){return`0x${e.toString(16)}`}function h(e){return typeof e==`string`&&e.length>0?e:void 0}function g(...e){for(let t of e){let e=h(t);if(e)return e}}function _(e){let t=e.filter(e=>!!e);return t.length>0?t.join(` `):void 0}function v(e){try{let n=JSON.parse(e);return t(n)?n:null}catch{return null}}function y(e){if(typeof e==`number`&&Number.isSafeInteger(e))return e;if(typeof e==`string`){let t=e.startsWith(`0x`)?Number.parseInt(e,16):Number(e);return Number.isSafeInteger(t)?t:void 0}}function b(e,t,n){if(!Object.hasOwn(e,t))return;let r=y(e[t]);if(r!==void 0)return r;S(n,t)}function x(e,t,n){if(!Object.hasOwn(e,t))return;let r=ee(e[t]);if(r!==void 0)return r;S(n,t)}function ee(e){if(typeof e==`bigint`)return e;if(typeof e==`number`&&Number.isSafeInteger(e)||typeof e==`string`&&/^(?:0x[0-9a-fA-F]+|\d+)$/.test(e))return BigInt(e)}function S(t,n){throw new e(`INVALID_ARGS`,`Invalid ${t} numeric field: ${n}`,{hint:`Crash artifact numeric fields must be integer numbers or integer numeric strings.`})}function C(e){return e.length===1?e[0]:void 0}function w(e){return[...new Set(e)]}function te(e){let t=e.match(/^(.*) \+ (\d+)$/);return t?{symbol:t[1],location:Number(t[2])}:{symbol:e}}const ne=/^(?:arm64e?|arm64_32|x86_64|armv7[sk]?|i386)$/;function re(e){return ie(e)??O(e)}function ie(e){let t=ae(e);if(!t)return null;let n=(Array.isArray(t.payload.usedImages)?t.payload.usedImages:[]).flatMap((e,t)=>D(e,t));if(n.length===0)return null;let r=oe(Array.isArray(t.payload.threads)?t.payload.threads:[],n);return{format:`ips`,images:n,addresses:r.map(({frame:e,...t})=>t),document:t,frameMatches:r,write:e=>T(t,r,e)}}function ae(e){let t=v(e);if(t)return{payload:t};let n=e.indexOf(`
2
2
  `);if(n===-1)return null;let r=e.slice(0,n),i=v(e.slice(n+1));return i?{header:r,payload:i}:null}function oe(e,t){let n=new Map(t.map(e=>[e.index,e]));return e.flatMap((e,t)=>se(e).flatMap((e,r)=>ce(e,n,t,r)))}function se(e){return!t(e)||!Array.isArray(e.frames)?[]:e.frames.filter(t)}function ce(e,t,n,r){let i=b(e,`imageIndex`,`IPS frame`),a=x(e,`imageOffset`,`IPS frame`);if(i===void 0||a===void 0)return[];let o=t.get(i);return o?[{frame:e,frameIndex:r,threadIndex:n,image:o,address:o.base+a}]:[]}function T(e,t,n){for(let e of t){let t=n.get(p(e.image,e.address))?.text;t&&E(e.frame,t)}e.payload.agentDeviceSymbolication={tool:`agent-device debug symbols`,symbolicatedFrames:[...n.values()].filter(e=>e.text).length};let r=`${JSON.stringify(e.payload,null,2)}\n`;return e.header?`${e.header}\n${r}`:r}function E(e,t){let n=te(t);e.symbol=n.symbol,n.location!==void 0&&(e.symbolLocation=n.location)}function D(e,n){if(!t(e))return[];let r=f(h(e.uuid)),i=x(e,`base`,`IPS usedImages`);if(!r||i===void 0)return[];let a=h(e.path);return[{index:n,name:h(e.name)??(a?u.basename(a):`image-${n}`),uuid:r,arch:h(e.arch),base:i,path:a}]}function O(e){let t=e.split(`
3
3
  `),n=k(t);if(n.length===0)return null;let r=M(t,n);return{format:`text`,images:n,addresses:r,lines:t,frameMatches:r,write(e){let n=new Map(r.map(e=>[e.lineIndex,e]));return t.map((t,r)=>{let i=n.get(r);if(!i)return t;let a=e.get(p(i.image,i.address))?.text;return!a||t.includes(a)?t:`${t} // ${a}`}).join(`
4
4
  `)}}}function k(e){let t=[],n=e.findIndex(e=>/^Binary Images:/i.test(e.trim()));if(n===-1)return t;for(let r of e.slice(n+1)){let e=A(r);e&&t.push(e)}return t}function A(e){let t=e.match(/^\s*(0x[0-9a-fA-F]+)\s*-\s*(0x[0-9a-fA-F]+)\s+\+?(.+?)\s+<([0-9a-fA-F-]{32,36})>\s+(.+)$/);if(!t)return null;let n=f(t[4]);if(!n)return null;let r=j(t[3].trim(),t[5].trim());return{name:r.name,arch:r.arch,uuid:n,base:BigInt(t[1]),end:BigInt(t[2]),path:t[5].trim()}}function j(e,t){let n=e.split(/\s+/),r=n.at(-1);if(r&&ne.test(r))return{name:n.slice(0,-1).join(` `).trim(),arch:r};let i=u.basename(t);return{name:e.startsWith(i)?i:e}}function M(e,t){let n=[],r;for(let[i,a]of e.entries()){let e=a.match(/^Thread\s+(\d+)\s+Crashed:/);e?r=Number(e[1]):(a.trim().length===0||/^Thread\s+\d+/.test(a))&&(r=void 0);let o=N(a,t),s=a.match(/^\s*(\d+)/);o&&s&&n.push({...o,frameIndex:Number(s[1]),lineIndex:i,threadIndex:r})}return n}function N(e,t){let n=e.match(/^\s*\d+\s+(.+?)\s+(0x[0-9a-fA-F]+)\b/);if(!n)return null;let r=n[1].trim(),i=BigInt(n[2]),a=P(t,r,i);return a?{image:a,address:i}:null}function P(e,t,n){let r=e.filter(e=>e.name===t);return r.find(e=>F(e,n))??C(r)}function F(e,t){return e.end!==void 0&&e.base<=t&&t<=e.end}const I=1e4;async function L(e){return e.dsym&&e.searchPath?[K(e.cwd,e.dsym),...await R(K(e.cwd,e.searchPath))]:e.dsym?[K(e.cwd,e.dsym)]:e.searchPath?await R(K(e.cwd,e.searchPath)):[]}async function R(t){let n=[],r=0;async function i(a){if(n.length>=200)return;if(r+=1,r>I)throw new e(`COMMAND_FAILED`,`debug symbols search-path scan exceeded bounds.`,{searchPath:t,maxEntries:I,hint:`Pass --dsym <App.dSYM> directly or narrow --search-path to the build products directory.`});if(!(await z(a,t)).isDirectory()){a===t&&B(t);return}if(a.endsWith(`.dSYM`)){n.push(a);return}let s=await o(a,{withFileTypes:!0});for(let e of s)e.isDirectory()&&await i(u.join(a,e.name))}return await i(t),n}async function z(t,n){try{return await c(t)}catch{throw new e(`INVALID_ARGS`,`debug symbols search path does not exist: ${n}`,{hint:`Pass an existing build products directory to --search-path, or pass --dsym <App.dSYM> directly.`})}}function B(t){throw new e(`INVALID_ARGS`,`debug symbols search path is not a directory: ${t}`,{hint:`Pass an existing build products directory to --search-path, or pass --dsym <App.dSYM> directly.`})}async function V(t,n){let r=(await Promise.all(w(t).map(e=>H(e,n)))).flat();if(r.length===0)throw new e(`COMMAND_FAILED`,`No UUIDs found in dSYM bundle.`,{hint:`Verify the path points to a built .dSYM bundle with DWARF contents.`});return r}async function H(e,t){return await U(e),W(e,r(await i(t,[`--uuid`,e],{timeoutMs:15e3,allowFailure:!0}),`Failed to inspect dSYM UUIDs: ${e}`,{hint:`Verify the dSYM bundle is valid and readable.`}).stdout)}async function U(t){if(!((await c(t).catch(()=>null))?.isDirectory()&&t.endsWith(`.dSYM`)))throw new e(`INVALID_ARGS`,`Not a .dSYM bundle: ${t}`,{hint:`Pass the .dSYM bundle path, not the DWARF executable inside it.`})}function W(e,t){return t.split(`
@@ -1 +1 @@
1
- import{a as e,h as t,y as n}from"./sdk-device.js";import{Xt as r}from"./sdk-batch.js";import{n as i,v as a}from"./owner-identity.js";import"./process.js";import{t as o}from"./daemon-registration.js";import{r as s}from"./durable-resource.js";import"./src7.js";import c from"node:path";import l from"node:fs";import u from"node:crypto";import d from"node:os";function f(e){return p(`family`in e?e.family:e.platform,e.appleOs,e.id)}function p(e,t,n){return`local:${e}:${t??`none`}:${n}`}function m(){let e=process.env.AGENT_DEVICE_CLAIMS_DIR?.trim();return e?c.resolve(e):c.join(d.homedir(),`.agent-device`,`device-claims`)}function h(e){let t=u.createHash(`sha256`).update(e).digest(`hex`);return c.join(m(),`${t}.json`)}function g(e){return{deviceKey:e.deviceKey,ownerToken:e.ownerToken,ownerPid:e.ownerPid,ownerStartTime:e.ownerStartTime}}function _(e){return e.schemaVersion===3}function v(e){return r(e.allocator.instanceId)}function y(e){return D(e)?e.schemaVersion===3?S(e):e.schemaVersion===2?O(e):e.schemaVersion===1?k(e):null:null}function b(e){return D(e)&&e.schemaVersion===3}const x=[`ownerPid`,`ownerStartTime`,`ownerToken`,`session`,`workspace`,`abandonedAtMs`];function S(e){if(e.kind!==`allocator`||C(e))return null;let t=w(e);return t&&{schemaVersion:3,kind:`allocator`,...t}}function C(e){return x.some(t=>e[t]!==void 0)}function w(e){if(!D(e.device)||!P(e.device.name))return null;let t=e.device.name,n=s(e.device),r=F(e.deviceKey),i=F(e.stateDir),a=T(e.allocator),o=N(e);return!n||!r||!i||!a||!o||r!==f(n)?null:{deviceKey:r,device:{...n,name:t},stateDir:i,allocator:a,createdAtMs:o.createdAtMs,updatedAtMs:o.updatedAtMs}}function T(e){if(!D(e))return null;let t=E(e.instanceId),n=E(e.identityIncarnationId);return t&&n?{instanceId:t,identityIncarnationId:n}:null}function E(e){return P(e)&&e===e.trim()?e:null}function D(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function O(e){if(!D(e.device)||!P(e.device.name))return null;let t=s(e.device);return t?A(e,t,e.device.name):null}function k(n){if(!D(n.device))return null;let r=n.device,i=r.name;if(!P(i)||!t(r.platform))return null;let a=e(r.platform),o=s({id:r.id,family:a.platform,kind:r.kind,target:r.target,...r.appleOs===void 0?a.platform===`apple`?{appleOs:r.platform===`macos`?`macos`:`ios`}:{}:{appleOs:r.appleOs},...r.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:r.iosPhysicalDeviceBackend}});return o?A(n,o,i):null}function A(e,t,n){let r=j(e),i=M(e),a=N(e);return!r||!i||!a||r.deviceKey!==f(t)?null:{schemaVersion:2,...r,device:{...t,name:n},...i,...a}}function j(e){let t=F(e.deviceKey),n=F(e.session),r=F(e.workspace),i=F(e.stateDir);return!t||!n||!r||!i?null:{deviceKey:t,session:n,workspace:r,stateDir:i}}function M(e){let{ownerPid:t,ownerStartTime:n}=e,r=F(e.ownerToken);return!I(t)||!r||n!==null&&!P(n)?null:{ownerPid:t,ownerStartTime:n,ownerToken:r}}function N(e){let{createdAtMs:t,updatedAtMs:n,abandonedAtMs:r}=e;return!L(t)||!L(n)||r!==void 0&&!L(r)?null:{createdAtMs:t,updatedAtMs:n,...L(r)?{abandonedAtMs:r}:{}}}function P(e){return typeof e==`string`&&e.length>0}function F(e){return P(e)?e:null}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function L(e){return typeof e==`number`&&Number.isFinite(e)}function R(e){let t=m(),n=z(t);if(`claims`in n)return n.claims;let r=n.entries.filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>K(c.join(t,e.name))).filter(e=>e!==null).filter(t=>B(t.claim??t.allocatorClaim,e)),i=a(r.flatMap(e=>e.claim?[e.claim.ownerPid]:[]));return r.map(e=>e.claim?J(e,i.get(e.claim.ownerPid)??null):e)}function z(e){try{return{entries:l.readdirSync(e,{withFileTypes:!0})}}catch(t){let n=t.code;return n===`ENOENT`||n===`ENOTDIR`?{claims:[]}:{claims:[{fileName:c.basename(e),classification:`unknown`,error:String(t)}]}}}function B(e,t){return!e||[V(e,t.udid??t.serial),H(e,t.device),U(e,t.platform)].every(Boolean)}function V(e,t){return!t||e.device.id===t}function H(e,t){return!t||e.device.name===t||e.device.id===t}function U(e,t){return n({platform:e.device.family,appleOs:e.device.appleOs},t)}function W(e){let t=K(e);return t?.claim?J(t,a([t.claim.ownerPid]).get(t.claim.ownerPid)??null):t}function G(e){let t=K(e);return t?.allocatorClaim||t?.classification===`allocator-inconsistent`?t:null}function K(e){let t=c.basename(e);try{return q(t,l.readFileSync(e,`utf8`))}catch(e){let n=e.code;return n===`ENOENT`||n===`ENOTDIR`?null:{fileName:t,classification:`unknown`,error:String(e)}}}function q(e,t){try{let n=JSON.parse(t),r=y(n);return r?_(r)?{fileName:e,deviceKey:r.deviceKey,allocatorClaim:r,classification:`allocator-held`}:{fileName:e,deviceKey:r.deviceKey,claim:r,classification:`unknown`}:{fileName:e,classification:b(n)?`allocator-inconsistent`:`inconsistent`}}catch(t){return{fileName:e,classification:`inconsistent`,error:String(t)}}}function J(e,t){let n=e.claim;if(!n)return e;let r={pid:n.ownerPid,startTime:n.ownerStartTime},a=i({owner:r,stateDir:n.stateDir},t),s=a===`live`&&o({...r,stateDir:n.stateDir});return{...e,classification:s?`owner-daemon-superseded`:a}}function Y(e){switch(e){case`owner-process-dead`:case`owner-process-reused`:case`owner-state-dir-gone`:case`owner-daemon-superseded`:return!0;case`live`:case`unknown`:case`inconsistent`:return!1;case`allocator-inconsistent`:return!1;case`allocator-held`:return!1}}function X(e){switch(e){case`owner-process-dead`:case`owner-daemon-superseded`:return!0;case`live`:case`owner-process-reused`:case`owner-state-dir-gone`:case`unknown`:case`inconsistent`:return!1;case`allocator-inconsistent`:return!1;case`allocator-held`:return!1}}export{G as a,f as c,R as i,h as l,Y as n,v as o,W as r,g as s,X as t,m as u};
1
+ import{a as e,b as t,g as n}from"./sdk-device.js";import{Xt as r}from"./sdk-batch.js";import{n as i,v as a}from"./owner-identity.js";import"./process.js";import{t as o}from"./daemon-registration.js";import{r as s}from"./durable-resource.js";import"./src7.js";import c from"node:path";import l from"node:fs";import u from"node:crypto";import d from"node:os";function f(e){return p(`family`in e?e.family:e.platform,e.appleOs,e.id)}function p(e,t,n){return`local:${e}:${t??`none`}:${n}`}function m(){let e=process.env.AGENT_DEVICE_CLAIMS_DIR?.trim();return e?c.resolve(e):c.join(d.homedir(),`.agent-device`,`device-claims`)}function h(e){let t=u.createHash(`sha256`).update(e).digest(`hex`);return c.join(m(),`${t}.json`)}function g(e){return{deviceKey:e.deviceKey,ownerToken:e.ownerToken,ownerPid:e.ownerPid,ownerStartTime:e.ownerStartTime}}function _(e){return e.schemaVersion===3}function v(e){return r(e.allocator.instanceId)}function y(e){return D(e)?e.schemaVersion===3?S(e):e.schemaVersion===2?O(e):e.schemaVersion===1?k(e):null:null}function b(e){return D(e)&&e.schemaVersion===3}const x=[`ownerPid`,`ownerStartTime`,`ownerToken`,`session`,`workspace`,`abandonedAtMs`];function S(e){if(e.kind!==`allocator`||C(e))return null;let t=w(e);return t&&{schemaVersion:3,kind:`allocator`,...t}}function C(e){return x.some(t=>e[t]!==void 0)}function w(e){if(!D(e.device)||!P(e.device.name))return null;let t=e.device.name,n=s(e.device),r=F(e.deviceKey),i=F(e.stateDir),a=T(e.allocator),o=N(e);return!n||!r||!i||!a||!o||r!==f(n)?null:{deviceKey:r,device:{...n,name:t},stateDir:i,allocator:a,createdAtMs:o.createdAtMs,updatedAtMs:o.updatedAtMs}}function T(e){if(!D(e))return null;let t=E(e.instanceId),n=E(e.identityIncarnationId);return t&&n?{instanceId:t,identityIncarnationId:n}:null}function E(e){return P(e)&&e===e.trim()?e:null}function D(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function O(e){if(!D(e.device)||!P(e.device.name))return null;let t=s(e.device);return t?A(e,t,e.device.name):null}function k(t){if(!D(t.device))return null;let r=t.device,i=r.name;if(!P(i)||!n(r.platform))return null;let a=e(r.platform),o=s({id:r.id,family:a.platform,kind:r.kind,target:r.target,...r.appleOs===void 0?a.platform===`apple`?{appleOs:r.platform===`macos`?`macos`:`ios`}:{}:{appleOs:r.appleOs},...r.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:r.iosPhysicalDeviceBackend}});return o?A(t,o,i):null}function A(e,t,n){let r=j(e),i=M(e),a=N(e);return!r||!i||!a||r.deviceKey!==f(t)?null:{schemaVersion:2,...r,device:{...t,name:n},...i,...a}}function j(e){let t=F(e.deviceKey),n=F(e.session),r=F(e.workspace),i=F(e.stateDir);return!t||!n||!r||!i?null:{deviceKey:t,session:n,workspace:r,stateDir:i}}function M(e){let{ownerPid:t,ownerStartTime:n}=e,r=F(e.ownerToken);return!I(t)||!r||n!==null&&!P(n)?null:{ownerPid:t,ownerStartTime:n,ownerToken:r}}function N(e){let{createdAtMs:t,updatedAtMs:n,abandonedAtMs:r}=e;return!L(t)||!L(n)||r!==void 0&&!L(r)?null:{createdAtMs:t,updatedAtMs:n,...L(r)?{abandonedAtMs:r}:{}}}function P(e){return typeof e==`string`&&e.length>0}function F(e){return P(e)?e:null}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function L(e){return typeof e==`number`&&Number.isFinite(e)}function R(e){let t=m(),n=z(t);if(`claims`in n)return n.claims;let r=n.entries.filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>K(c.join(t,e.name))).filter(e=>e!==null).filter(t=>B(t.claim??t.allocatorClaim,e)),i=a(r.flatMap(e=>e.claim?[e.claim.ownerPid]:[]));return r.map(e=>e.claim?J(e,i.get(e.claim.ownerPid)??null):e)}function z(e){try{return{entries:l.readdirSync(e,{withFileTypes:!0})}}catch(t){let n=t.code;return n===`ENOENT`||n===`ENOTDIR`?{claims:[]}:{claims:[{fileName:c.basename(e),classification:`unknown`,error:String(t)}]}}}function B(e,t){return!e||[V(e,t.udid??t.serial),H(e,t.device),U(e,t.platform)].every(Boolean)}function V(e,t){return!t||e.device.id===t}function H(e,t){return!t||e.device.name===t||e.device.id===t}function U(e,n){return t({platform:e.device.family,appleOs:e.device.appleOs},n)}function W(e){let t=K(e);return t?.claim?J(t,a([t.claim.ownerPid]).get(t.claim.ownerPid)??null):t}function G(e){let t=K(e);return t?.allocatorClaim||t?.classification===`allocator-inconsistent`?t:null}function K(e){let t=c.basename(e);try{return q(t,l.readFileSync(e,`utf8`))}catch(e){let n=e.code;return n===`ENOENT`||n===`ENOTDIR`?null:{fileName:t,classification:`unknown`,error:String(e)}}}function q(e,t){try{let n=JSON.parse(t),r=y(n);return r?_(r)?{fileName:e,deviceKey:r.deviceKey,allocatorClaim:r,classification:`allocator-held`}:{fileName:e,deviceKey:r.deviceKey,claim:r,classification:`unknown`}:{fileName:e,classification:b(n)?`allocator-inconsistent`:`inconsistent`}}catch(t){return{fileName:e,classification:`inconsistent`,error:String(t)}}}function J(e,t){let n=e.claim;if(!n)return e;let r={pid:n.ownerPid,startTime:n.ownerStartTime},a=i({owner:r,stateDir:n.stateDir},t),s=a===`live`&&o({...r,stateDir:n.stateDir});return{...e,classification:s?`owner-daemon-superseded`:a}}function Y(e){switch(e){case`owner-process-dead`:case`owner-process-reused`:case`owner-state-dir-gone`:case`owner-daemon-superseded`:return!0;case`live`:case`unknown`:case`inconsistent`:return!1;case`allocator-inconsistent`:return!1;case`allocator-held`:return!1}}function X(e){switch(e){case`owner-process-dead`:case`owner-daemon-superseded`:return!0;case`live`:case`owner-process-reused`:case`owner-state-dir-gone`:case`unknown`:case`inconsistent`:return!1;case`allocator-inconsistent`:return!1;case`allocator-held`:return!1}}export{G as a,f as c,R as i,h as l,Y as n,v as o,W as r,g as s,X as t,m as u};