agent-device 0.4.2 → 0.5.1

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 (93) hide show
  1. package/README.md +55 -11
  2. package/dist/src/50.js +1 -0
  3. package/dist/src/bin.js +31 -30
  4. package/dist/src/daemon.js +17 -20
  5. package/package.json +7 -9
  6. package/skills/agent-device/SKILL.md +48 -6
  7. package/skills/agent-device/references/batching.md +79 -0
  8. package/skills/agent-device/references/permissions.md +3 -15
  9. package/skills/agent-device/references/snapshot-refs.md +1 -4
  10. package/dist/bin/axsnapshot +0 -0
  11. package/dist/src/797.js +0 -1
  12. package/ios-runner/AXSnapshot/Package.swift +0 -18
  13. package/ios-runner/AXSnapshot/Sources/AXSnapshot/main.swift +0 -444
  14. package/src/__tests__/cli-close.test.ts +0 -155
  15. package/src/__tests__/cli-help.test.ts +0 -102
  16. package/src/bin.ts +0 -3
  17. package/src/cli.ts +0 -305
  18. package/src/core/__tests__/capabilities.test.ts +0 -75
  19. package/src/core/__tests__/dispatch-open.test.ts +0 -25
  20. package/src/core/__tests__/open-target.test.ts +0 -55
  21. package/src/core/capabilities.ts +0 -57
  22. package/src/core/dispatch.ts +0 -382
  23. package/src/core/open-target.ts +0 -27
  24. package/src/daemon/__tests__/device-ready.test.ts +0 -52
  25. package/src/daemon/__tests__/is-predicates.test.ts +0 -68
  26. package/src/daemon/__tests__/selectors.test.ts +0 -261
  27. package/src/daemon/__tests__/session-routing.test.ts +0 -108
  28. package/src/daemon/__tests__/session-selector.test.ts +0 -64
  29. package/src/daemon/__tests__/session-store.test.ts +0 -142
  30. package/src/daemon/__tests__/snapshot-processing.test.ts +0 -47
  31. package/src/daemon/action-utils.ts +0 -29
  32. package/src/daemon/context.ts +0 -48
  33. package/src/daemon/device-ready.ts +0 -155
  34. package/src/daemon/handlers/__tests__/find.test.ts +0 -99
  35. package/src/daemon/handlers/__tests__/interaction.test.ts +0 -22
  36. package/src/daemon/handlers/__tests__/replay-heal.test.ts +0 -509
  37. package/src/daemon/handlers/__tests__/session-reinstall.test.ts +0 -219
  38. package/src/daemon/handlers/__tests__/session.test.ts +0 -820
  39. package/src/daemon/handlers/__tests__/snapshot-handler.test.ts +0 -92
  40. package/src/daemon/handlers/__tests__/snapshot.test.ts +0 -128
  41. package/src/daemon/handlers/find.ts +0 -324
  42. package/src/daemon/handlers/interaction.ts +0 -550
  43. package/src/daemon/handlers/parse-utils.ts +0 -8
  44. package/src/daemon/handlers/record-trace.ts +0 -154
  45. package/src/daemon/handlers/session.ts +0 -1137
  46. package/src/daemon/handlers/snapshot.ts +0 -439
  47. package/src/daemon/is-predicates.ts +0 -46
  48. package/src/daemon/selectors.ts +0 -540
  49. package/src/daemon/session-routing.ts +0 -22
  50. package/src/daemon/session-selector.ts +0 -39
  51. package/src/daemon/session-store.ts +0 -296
  52. package/src/daemon/snapshot-processing.ts +0 -131
  53. package/src/daemon/types.ts +0 -56
  54. package/src/daemon-client.ts +0 -272
  55. package/src/daemon.ts +0 -295
  56. package/src/platforms/__tests__/boot-diagnostics.test.ts +0 -59
  57. package/src/platforms/android/__tests__/index.test.ts +0 -274
  58. package/src/platforms/android/devices.ts +0 -196
  59. package/src/platforms/android/index.ts +0 -784
  60. package/src/platforms/android/ui-hierarchy.ts +0 -312
  61. package/src/platforms/boot-diagnostics.ts +0 -128
  62. package/src/platforms/ios/__tests__/index.test.ts +0 -312
  63. package/src/platforms/ios/__tests__/runner-client.test.ts +0 -155
  64. package/src/platforms/ios/apps.ts +0 -358
  65. package/src/platforms/ios/ax-snapshot.ts +0 -207
  66. package/src/platforms/ios/config.ts +0 -28
  67. package/src/platforms/ios/devicectl.ts +0 -134
  68. package/src/platforms/ios/devices.ts +0 -100
  69. package/src/platforms/ios/index.ts +0 -20
  70. package/src/platforms/ios/runner-client.ts +0 -994
  71. package/src/platforms/ios/simulator.ts +0 -164
  72. package/src/utils/__tests__/args.test.ts +0 -239
  73. package/src/utils/__tests__/daemon-client.test.ts +0 -95
  74. package/src/utils/__tests__/exec.test.ts +0 -16
  75. package/src/utils/__tests__/finders.test.ts +0 -34
  76. package/src/utils/__tests__/keyed-lock.test.ts +0 -55
  77. package/src/utils/__tests__/process-identity.test.ts +0 -33
  78. package/src/utils/__tests__/retry.test.ts +0 -44
  79. package/src/utils/args.ts +0 -239
  80. package/src/utils/command-schema.ts +0 -622
  81. package/src/utils/device.ts +0 -84
  82. package/src/utils/errors.ts +0 -35
  83. package/src/utils/exec.ts +0 -339
  84. package/src/utils/finders.ts +0 -101
  85. package/src/utils/interactive.ts +0 -4
  86. package/src/utils/interactors.ts +0 -173
  87. package/src/utils/keyed-lock.ts +0 -14
  88. package/src/utils/output.ts +0 -204
  89. package/src/utils/process-identity.ts +0 -100
  90. package/src/utils/retry.ts +0 -180
  91. package/src/utils/snapshot.ts +0 -64
  92. package/src/utils/timeouts.ts +0 -9
  93. package/src/utils/version.ts +0 -26
@@ -1,219 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import fs from 'node:fs';
4
- import os from 'node:os';
5
- import path from 'node:path';
6
- import { handleSessionCommands } from '../session.ts';
7
- import { SessionStore } from '../../session-store.ts';
8
- import type { DaemonRequest, DaemonResponse, SessionState } from '../../types.ts';
9
-
10
- function makeStore(): SessionStore {
11
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-session-reinstall-'));
12
- return new SessionStore(path.join(tempRoot, 'sessions'));
13
- }
14
-
15
- function makeSession(name: string, device: SessionState['device']): SessionState {
16
- return {
17
- name,
18
- device,
19
- createdAt: Date.now(),
20
- actions: [],
21
- };
22
- }
23
-
24
- const invoke = async (_req: DaemonRequest): Promise<DaemonResponse> => {
25
- return { ok: false, error: { code: 'INVALID_ARGS', message: 'invoke should not be called in reinstall tests' } };
26
- };
27
-
28
- test('reinstall requires active session or explicit device selector', async () => {
29
- const sessionStore = makeStore();
30
- const response = await handleSessionCommands({
31
- req: {
32
- token: 't',
33
- session: 'default',
34
- command: 'reinstall',
35
- positionals: ['com.example.app', '/tmp/app.apk'],
36
- flags: {},
37
- },
38
- sessionName: 'default',
39
- logPath: '/tmp/daemon.log',
40
- sessionStore,
41
- invoke,
42
- });
43
- assert.ok(response);
44
- assert.equal(response.ok, false);
45
- if (!response.ok) {
46
- assert.equal(response.error.code, 'INVALID_ARGS');
47
- assert.match(response.error.message, /active session or an explicit device selector/i);
48
- }
49
- });
50
-
51
- test('reinstall validates required args before device operations', async () => {
52
- const sessionStore = makeStore();
53
- sessionStore.set(
54
- 'default',
55
- makeSession('default', {
56
- platform: 'ios',
57
- id: 'sim-1',
58
- name: 'iPhone',
59
- kind: 'simulator',
60
- booted: true,
61
- }),
62
- );
63
- const response = await handleSessionCommands({
64
- req: {
65
- token: 't',
66
- session: 'default',
67
- command: 'reinstall',
68
- positionals: ['com.example.app'],
69
- flags: {},
70
- },
71
- sessionName: 'default',
72
- logPath: '/tmp/daemon.log',
73
- sessionStore,
74
- invoke,
75
- });
76
- assert.ok(response);
77
- assert.equal(response.ok, false);
78
- if (!response.ok) {
79
- assert.equal(response.error.code, 'INVALID_ARGS');
80
- assert.match(response.error.message, /reinstall <app> <path-to-app-binary>/i);
81
- }
82
- });
83
-
84
- test('reinstall reports unsupported operation on iOS physical devices', async () => {
85
- const sessionStore = makeStore();
86
- sessionStore.set(
87
- 'default',
88
- makeSession('default', {
89
- platform: 'ios',
90
- id: 'device-1',
91
- name: 'iPhone Device',
92
- kind: 'device',
93
- booted: true,
94
- }),
95
- );
96
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-reinstall-binary-'));
97
- const appPath = path.join(tempRoot, 'Sample.app');
98
- fs.writeFileSync(appPath, 'placeholder');
99
-
100
- const response = await handleSessionCommands({
101
- req: {
102
- token: 't',
103
- session: 'default',
104
- command: 'reinstall',
105
- positionals: ['com.example.app', appPath],
106
- flags: {},
107
- },
108
- sessionName: 'default',
109
- logPath: '/tmp/daemon.log',
110
- sessionStore,
111
- invoke,
112
- });
113
- assert.ok(response);
114
- assert.equal(response.ok, false);
115
- if (!response.ok) {
116
- assert.equal(response.error.code, 'UNSUPPORTED_OPERATION');
117
- assert.match(response.error.message, /reinstall is not supported/i);
118
- }
119
- });
120
-
121
- test('reinstall succeeds on active iOS simulator session and records action', async () => {
122
- const sessionStore = makeStore();
123
- const session = makeSession('default', {
124
- platform: 'ios',
125
- id: 'sim-1',
126
- name: 'iPhone',
127
- kind: 'simulator',
128
- booted: true,
129
- });
130
- sessionStore.set('default', session);
131
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-reinstall-success-ios-'));
132
- const appPath = path.join(tempRoot, 'Sample.app');
133
- fs.writeFileSync(appPath, 'placeholder');
134
-
135
- const response = await handleSessionCommands({
136
- req: {
137
- token: 't',
138
- session: 'default',
139
- command: 'reinstall',
140
- positionals: ['com.example.app', appPath],
141
- flags: {},
142
- },
143
- sessionName: 'default',
144
- logPath: '/tmp/daemon.log',
145
- sessionStore,
146
- invoke,
147
- reinstallOps: {
148
- ios: async (_device, app, pathToBinary) => {
149
- assert.equal(app, 'com.example.app');
150
- assert.equal(pathToBinary, appPath);
151
- return { bundleId: 'com.example.app' };
152
- },
153
- android: async () => {
154
- throw new Error('unexpected android reinstall');
155
- },
156
- },
157
- });
158
-
159
- assert.ok(response);
160
- assert.equal(response.ok, true);
161
- if (response.ok) {
162
- assert.equal(response.data?.platform, 'ios');
163
- assert.equal(response.data?.appId, 'com.example.app');
164
- assert.equal(response.data?.bundleId, 'com.example.app');
165
- assert.equal(response.data?.appPath, appPath);
166
- }
167
- assert.equal(session.actions.length, 1);
168
- assert.equal(session.actions[0]?.command, 'reinstall');
169
- });
170
-
171
- test('reinstall succeeds on active Android session with normalized appId', async () => {
172
- const sessionStore = makeStore();
173
- sessionStore.set(
174
- 'default',
175
- makeSession('default', {
176
- platform: 'android',
177
- id: 'emulator-5554',
178
- name: 'Pixel',
179
- kind: 'emulator',
180
- booted: true,
181
- }),
182
- );
183
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-reinstall-success-android-'));
184
- const appPath = path.join(tempRoot, 'Sample.apk');
185
- fs.writeFileSync(appPath, 'placeholder');
186
-
187
- const response = await handleSessionCommands({
188
- req: {
189
- token: 't',
190
- session: 'default',
191
- command: 'reinstall',
192
- positionals: ['com.example.app', appPath],
193
- flags: {},
194
- },
195
- sessionName: 'default',
196
- logPath: '/tmp/daemon.log',
197
- sessionStore,
198
- invoke,
199
- reinstallOps: {
200
- ios: async () => {
201
- throw new Error('unexpected ios reinstall');
202
- },
203
- android: async (_device, app, pathToBinary) => {
204
- assert.equal(app, 'com.example.app');
205
- assert.equal(pathToBinary, appPath);
206
- return { package: 'com.example.app' };
207
- },
208
- },
209
- });
210
-
211
- assert.ok(response);
212
- assert.equal(response.ok, true);
213
- if (response.ok) {
214
- assert.equal(response.data?.platform, 'android');
215
- assert.equal(response.data?.appId, 'com.example.app');
216
- assert.equal(response.data?.package, 'com.example.app');
217
- assert.equal(response.data?.appPath, appPath);
218
- }
219
- });