agent-device 0.4.2 → 0.5.0

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 (91) hide show
  1. package/README.md +2 -9
  2. package/dist/src/797.js +1 -1
  3. package/dist/src/bin.js +5 -5
  4. package/dist/src/daemon.js +16 -20
  5. package/package.json +7 -9
  6. package/skills/agent-device/SKILL.md +3 -6
  7. package/skills/agent-device/references/permissions.md +3 -15
  8. package/skills/agent-device/references/snapshot-refs.md +1 -4
  9. package/dist/bin/axsnapshot +0 -0
  10. package/ios-runner/AXSnapshot/Package.swift +0 -18
  11. package/ios-runner/AXSnapshot/Sources/AXSnapshot/main.swift +0 -444
  12. package/src/__tests__/cli-close.test.ts +0 -155
  13. package/src/__tests__/cli-help.test.ts +0 -102
  14. package/src/bin.ts +0 -3
  15. package/src/cli.ts +0 -305
  16. package/src/core/__tests__/capabilities.test.ts +0 -75
  17. package/src/core/__tests__/dispatch-open.test.ts +0 -25
  18. package/src/core/__tests__/open-target.test.ts +0 -55
  19. package/src/core/capabilities.ts +0 -57
  20. package/src/core/dispatch.ts +0 -382
  21. package/src/core/open-target.ts +0 -27
  22. package/src/daemon/__tests__/device-ready.test.ts +0 -52
  23. package/src/daemon/__tests__/is-predicates.test.ts +0 -68
  24. package/src/daemon/__tests__/selectors.test.ts +0 -261
  25. package/src/daemon/__tests__/session-routing.test.ts +0 -108
  26. package/src/daemon/__tests__/session-selector.test.ts +0 -64
  27. package/src/daemon/__tests__/session-store.test.ts +0 -142
  28. package/src/daemon/__tests__/snapshot-processing.test.ts +0 -47
  29. package/src/daemon/action-utils.ts +0 -29
  30. package/src/daemon/context.ts +0 -48
  31. package/src/daemon/device-ready.ts +0 -155
  32. package/src/daemon/handlers/__tests__/find.test.ts +0 -99
  33. package/src/daemon/handlers/__tests__/interaction.test.ts +0 -22
  34. package/src/daemon/handlers/__tests__/replay-heal.test.ts +0 -509
  35. package/src/daemon/handlers/__tests__/session-reinstall.test.ts +0 -219
  36. package/src/daemon/handlers/__tests__/session.test.ts +0 -820
  37. package/src/daemon/handlers/__tests__/snapshot-handler.test.ts +0 -92
  38. package/src/daemon/handlers/__tests__/snapshot.test.ts +0 -128
  39. package/src/daemon/handlers/find.ts +0 -324
  40. package/src/daemon/handlers/interaction.ts +0 -550
  41. package/src/daemon/handlers/parse-utils.ts +0 -8
  42. package/src/daemon/handlers/record-trace.ts +0 -154
  43. package/src/daemon/handlers/session.ts +0 -1137
  44. package/src/daemon/handlers/snapshot.ts +0 -439
  45. package/src/daemon/is-predicates.ts +0 -46
  46. package/src/daemon/selectors.ts +0 -540
  47. package/src/daemon/session-routing.ts +0 -22
  48. package/src/daemon/session-selector.ts +0 -39
  49. package/src/daemon/session-store.ts +0 -296
  50. package/src/daemon/snapshot-processing.ts +0 -131
  51. package/src/daemon/types.ts +0 -56
  52. package/src/daemon-client.ts +0 -272
  53. package/src/daemon.ts +0 -295
  54. package/src/platforms/__tests__/boot-diagnostics.test.ts +0 -59
  55. package/src/platforms/android/__tests__/index.test.ts +0 -274
  56. package/src/platforms/android/devices.ts +0 -196
  57. package/src/platforms/android/index.ts +0 -784
  58. package/src/platforms/android/ui-hierarchy.ts +0 -312
  59. package/src/platforms/boot-diagnostics.ts +0 -128
  60. package/src/platforms/ios/__tests__/index.test.ts +0 -312
  61. package/src/platforms/ios/__tests__/runner-client.test.ts +0 -155
  62. package/src/platforms/ios/apps.ts +0 -358
  63. package/src/platforms/ios/ax-snapshot.ts +0 -207
  64. package/src/platforms/ios/config.ts +0 -28
  65. package/src/platforms/ios/devicectl.ts +0 -134
  66. package/src/platforms/ios/devices.ts +0 -100
  67. package/src/platforms/ios/index.ts +0 -20
  68. package/src/platforms/ios/runner-client.ts +0 -994
  69. package/src/platforms/ios/simulator.ts +0 -164
  70. package/src/utils/__tests__/args.test.ts +0 -239
  71. package/src/utils/__tests__/daemon-client.test.ts +0 -95
  72. package/src/utils/__tests__/exec.test.ts +0 -16
  73. package/src/utils/__tests__/finders.test.ts +0 -34
  74. package/src/utils/__tests__/keyed-lock.test.ts +0 -55
  75. package/src/utils/__tests__/process-identity.test.ts +0 -33
  76. package/src/utils/__tests__/retry.test.ts +0 -44
  77. package/src/utils/args.ts +0 -239
  78. package/src/utils/command-schema.ts +0 -622
  79. package/src/utils/device.ts +0 -84
  80. package/src/utils/errors.ts +0 -35
  81. package/src/utils/exec.ts +0 -339
  82. package/src/utils/finders.ts +0 -101
  83. package/src/utils/interactive.ts +0 -4
  84. package/src/utils/interactors.ts +0 -173
  85. package/src/utils/keyed-lock.ts +0 -14
  86. package/src/utils/output.ts +0 -204
  87. package/src/utils/process-identity.ts +0 -100
  88. package/src/utils/retry.ts +0 -180
  89. package/src/utils/snapshot.ts +0 -64
  90. package/src/utils/timeouts.ts +0 -9
  91. package/src/utils/version.ts +0 -26
@@ -1,134 +0,0 @@
1
- import { promises as fs } from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
-
5
- import type { DeviceInfo } from '../../utils/device.ts';
6
- import { AppError } from '../../utils/errors.ts';
7
- import { runCmd } from '../../utils/exec.ts';
8
-
9
- import { IOS_DEVICECTL_TIMEOUT_MS } from './config.ts';
10
-
11
- export type IosAppInfo = {
12
- bundleId: string;
13
- name: string;
14
- };
15
-
16
- type IosDeviceAppsPayload = {
17
- result?: {
18
- apps?: Array<{
19
- bundleIdentifier?: unknown;
20
- name?: unknown;
21
- }>;
22
- };
23
- };
24
-
25
- export async function runIosDevicectl(
26
- args: string[],
27
- context: { action: string; deviceId: string },
28
- ): Promise<void> {
29
- const fullArgs = ['devicectl', ...args];
30
- const result = await runCmd('xcrun', fullArgs, {
31
- allowFailure: true,
32
- timeoutMs: IOS_DEVICECTL_TIMEOUT_MS,
33
- });
34
- if (result.exitCode === 0) return;
35
- const stdout = String(result.stdout ?? '');
36
- const stderr = String(result.stderr ?? '');
37
- throw new AppError('COMMAND_FAILED', `Failed to ${context.action}`, {
38
- cmd: 'xcrun',
39
- args: fullArgs,
40
- exitCode: result.exitCode,
41
- stdout,
42
- stderr,
43
- deviceId: context.deviceId,
44
- hint: resolveIosDevicectlHint(stdout, stderr) ?? IOS_DEVICECTL_DEFAULT_HINT,
45
- });
46
- }
47
-
48
- export async function listIosDeviceApps(
49
- device: DeviceInfo,
50
- filter: 'user-installed' | 'all',
51
- ): Promise<IosAppInfo[]> {
52
- const jsonPath = path.join(
53
- os.tmpdir(),
54
- `agent-device-ios-apps-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`,
55
- );
56
- const args = [
57
- 'devicectl',
58
- 'device',
59
- 'info',
60
- 'apps',
61
- '--device',
62
- device.id,
63
- '--include-all-apps',
64
- '--json-output',
65
- jsonPath,
66
- ];
67
- const result = await runCmd('xcrun', args, {
68
- allowFailure: true,
69
- timeoutMs: IOS_DEVICECTL_TIMEOUT_MS,
70
- });
71
-
72
- try {
73
- if (result.exitCode !== 0) {
74
- const stdout = String(result.stdout ?? '');
75
- const stderr = String(result.stderr ?? '');
76
- throw new AppError('COMMAND_FAILED', 'Failed to list iOS apps', {
77
- cmd: 'xcrun',
78
- args,
79
- exitCode: result.exitCode,
80
- stdout,
81
- stderr,
82
- deviceId: device.id,
83
- hint: resolveIosDevicectlHint(stdout, stderr) ?? IOS_DEVICECTL_DEFAULT_HINT,
84
- });
85
- }
86
- const jsonText = await fs.readFile(jsonPath, 'utf8');
87
- const apps = parseIosDeviceAppsPayload(JSON.parse(jsonText));
88
- return filterIosDeviceApps(apps, filter);
89
- } catch (error) {
90
- if (error instanceof AppError) throw error;
91
- throw new AppError('COMMAND_FAILED', 'Failed to parse iOS apps list', {
92
- deviceId: device.id,
93
- cause: String(error),
94
- });
95
- } finally {
96
- await fs.unlink(jsonPath).catch(() => {});
97
- }
98
- }
99
-
100
- export function parseIosDeviceAppsPayload(payload: unknown): IosAppInfo[] {
101
- const apps = (payload as IosDeviceAppsPayload | null | undefined)?.result?.apps;
102
- if (!Array.isArray(apps)) return [];
103
-
104
- const parsed: IosAppInfo[] = [];
105
- for (const entry of apps) {
106
- if (!entry || typeof entry !== 'object') continue;
107
- const bundleId = typeof entry.bundleIdentifier === 'string' ? entry.bundleIdentifier.trim() : '';
108
- if (!bundleId) continue;
109
- const name = typeof entry.name === 'string' && entry.name.trim().length > 0 ? entry.name.trim() : bundleId;
110
- parsed.push({ bundleId, name });
111
- }
112
- return parsed;
113
- }
114
-
115
- function filterIosDeviceApps(apps: IosAppInfo[], filter: 'user-installed' | 'all'): IosAppInfo[] {
116
- if (filter === 'user-installed') {
117
- return apps.filter((app) => !app.bundleId.startsWith('com.apple.'));
118
- }
119
- return apps;
120
- }
121
-
122
- export const IOS_DEVICECTL_DEFAULT_HINT =
123
- 'Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.';
124
-
125
- export function resolveIosDevicectlHint(stdout: string, stderr: string): string | null {
126
- const text = `${stdout}\n${stderr}`.toLowerCase();
127
- if (text.includes('device is busy') && text.includes('connecting')) {
128
- return 'iOS device is still connecting. Keep it unlocked and connected by cable until it is fully available in Xcode Devices, then retry.';
129
- }
130
- if (text.includes('coredeviceservice') && text.includes('timed out')) {
131
- return 'CoreDevice service timed out. Reconnect the device and retry; if it persists restart Xcode and the iOS device.';
132
- }
133
- return null;
134
- }
@@ -1,100 +0,0 @@
1
- import { promises as fs } from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { runCmd, whichCmd } from '../../utils/exec.ts';
5
- import { AppError } from '../../utils/errors.ts';
6
- import type { DeviceInfo } from '../../utils/device.ts';
7
- import { resolveTimeoutMs } from '../../utils/timeouts.ts';
8
-
9
- const IOS_DEVICECTL_LIST_TIMEOUT_MS = resolveTimeoutMs(
10
- process.env.AGENT_DEVICE_IOS_DEVICECTL_LIST_TIMEOUT_MS,
11
- 8_000,
12
- 500,
13
- );
14
-
15
- export async function listIosDevices(): Promise<DeviceInfo[]> {
16
- if (process.platform !== 'darwin') {
17
- throw new AppError('UNSUPPORTED_PLATFORM', 'iOS tools are only available on macOS');
18
- }
19
-
20
- const simctlAvailable = await whichCmd('xcrun');
21
- if (!simctlAvailable) {
22
- throw new AppError('TOOL_MISSING', 'xcrun not found in PATH');
23
- }
24
-
25
- const devices: DeviceInfo[] = [];
26
-
27
- const simResult = await runCmd('xcrun', ['simctl', 'list', 'devices', '-j']);
28
- try {
29
- const payload = JSON.parse(simResult.stdout as string) as {
30
- devices: Record<
31
- string,
32
- { name: string; udid: string; state: string; isAvailable: boolean }[]
33
- >;
34
- };
35
- for (const runtimes of Object.values(payload.devices)) {
36
- for (const device of runtimes) {
37
- if (!device.isAvailable) continue;
38
- devices.push({
39
- platform: 'ios',
40
- id: device.udid,
41
- name: device.name,
42
- kind: 'simulator',
43
- booted: device.state === 'Booted',
44
- });
45
- }
46
- }
47
- } catch (err) {
48
- throw new AppError('COMMAND_FAILED', 'Failed to parse simctl devices JSON', undefined, err);
49
- }
50
-
51
- let jsonPath: string | null = null;
52
- try {
53
- jsonPath = path.join(
54
- os.tmpdir(),
55
- `agent-device-devicectl-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`,
56
- );
57
- const devicectlResult = await runCmd('xcrun', ['devicectl', 'list', 'devices', '--json-output', jsonPath], {
58
- allowFailure: true,
59
- timeoutMs: IOS_DEVICECTL_LIST_TIMEOUT_MS,
60
- });
61
- if (devicectlResult.exitCode !== 0) {
62
- return devices;
63
- }
64
- const jsonText = await fs.readFile(jsonPath, 'utf8');
65
- const payload = JSON.parse(jsonText) as {
66
- result?: {
67
- devices?: Array<{
68
- identifier?: string;
69
- name?: string;
70
- hardwareProperties?: { platform?: string; udid?: string };
71
- deviceProperties?: { name?: string };
72
- connectionProperties?: { tunnelState?: string };
73
- }>;
74
- };
75
- };
76
- for (const device of payload.result?.devices ?? []) {
77
- const platform = device.hardwareProperties?.platform ?? '';
78
- if (platform.toLowerCase().includes('ios')) {
79
- const id = device.hardwareProperties?.udid ?? device.identifier ?? '';
80
- const name = device.name ?? device.deviceProperties?.name ?? id;
81
- if (!id) continue;
82
- devices.push({
83
- platform: 'ios',
84
- id,
85
- name,
86
- kind: 'device',
87
- booted: true,
88
- });
89
- }
90
- }
91
- } catch {
92
- // Ignore devicectl failures; simulators are still supported.
93
- } finally {
94
- if (jsonPath) {
95
- await fs.rm(jsonPath, { force: true }).catch(() => {});
96
- }
97
- }
98
-
99
- return devices;
100
- }
@@ -1,20 +0,0 @@
1
- export {
2
- closeIosApp,
3
- installIosApp,
4
- listIosApps,
5
- listSimulatorApps,
6
- openIosApp,
7
- openIosDevice,
8
- reinstallIosApp,
9
- resolveIosApp,
10
- screenshotIos,
11
- setIosSetting,
12
- uninstallIosApp,
13
- } from './apps.ts';
14
-
15
- export { ensureBootedSimulator } from './simulator.ts';
16
-
17
- export {
18
- parseIosDeviceAppsPayload,
19
- type IosAppInfo,
20
- } from './devicectl.ts';