emd-agents 0.15.0 → 0.16.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.
- package/README.md +6 -9
- package/dist/adapters/expo/index.js +27 -4
- package/dist/cli/main.js +2 -2
- package/dist/core/adapter.d.ts +2 -0
- package/dist/core/buildrecord.d.ts +1 -0
- package/dist/core/buildrecord.js +15 -1
- package/dist/core/check.d.ts +13 -1
- package/dist/core/check.js +62 -8
- package/dist/core/detect.js +3 -2
- package/dist/core/device/axe.js +5 -5
- package/dist/core/device/backend.d.ts +4 -3
- package/dist/core/device/backend.js +12 -2
- package/dist/core/device/maestro.js +5 -5
- package/dist/core/device/typing.d.ts +20 -0
- package/dist/core/device/typing.js +120 -0
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.js +1 -2
- package/dist/core/input.js +45 -8
- package/dist/core/isolate.js +4 -2
- package/dist/core/jobs.d.ts +2 -1
- package/dist/core/jobs.js +25 -7
- package/dist/core/launch.d.ts +1 -0
- package/dist/core/launch.js +233 -41
- package/dist/core/log.d.ts +9 -0
- package/dist/core/log.js +22 -0
- package/dist/core/logs.js +16 -1
- package/dist/core/reload.d.ts +7 -0
- package/dist/core/reload.js +68 -0
- package/dist/core/result.d.ts +81 -18
- package/dist/core/result.js +44 -13
- package/dist/core/setup.js +16 -3
- package/dist/core/simulator.d.ts +2 -0
- package/dist/core/simulator.js +26 -8
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +107 -21
- package/package.json +1 -1
- package/skills/emd/SKILL.md +6 -6
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import { launchesIn } from "./jobstore.js";
|
|
4
|
+
import { runTool } from "./tool.js";
|
|
5
|
+
// The same message Expo's R key broadcasts to connected apps: the dev server's
|
|
6
|
+
// message socket relays a "reload" from a local client to every app.
|
|
7
|
+
export async function sendReload(port) {
|
|
8
|
+
const socket = new WebSocket(`ws://localhost:${port}/message`);
|
|
9
|
+
await new Promise((resolve, reject) => {
|
|
10
|
+
const timer = setTimeout(() => reject(new Error("socket timeout")), 5000);
|
|
11
|
+
socket.onopen = () => {
|
|
12
|
+
socket.send(JSON.stringify({ version: 2, method: "reload" }));
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
resolve();
|
|
15
|
+
};
|
|
16
|
+
socket.onerror = () => {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
reject(new Error("socket error"));
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
// The server answers the close; a silent one must not hold this process.
|
|
22
|
+
await new Promise((resolve) => {
|
|
23
|
+
socket.onclose = () => resolve();
|
|
24
|
+
socket.close();
|
|
25
|
+
setTimeout(resolve, 1000).unref();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// The pid of the app when it runs on the device; undefined when it does not.
|
|
29
|
+
export async function runningPid(device, appId) {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await runTool("simctl spawn launchctl list", "xcrun", ["simctl", "spawn", device.id, "launchctl", "list"], 60);
|
|
32
|
+
const mark = `UIKitApplication:${appId}[`;
|
|
33
|
+
for (const line of stdout.split("\n")) {
|
|
34
|
+
if (!line.includes(mark))
|
|
35
|
+
continue;
|
|
36
|
+
const pid = Number(line.trim().split(/\s+/)[0]);
|
|
37
|
+
return Number.isInteger(pid) ? pid : undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
// The earlier launch in this worktree whose dev server still listens on `port`,
|
|
44
|
+
// or undefined. `listening` tells which recorded dev server pids do.
|
|
45
|
+
export const earlierLaunch = (root, port, listening) =>
|
|
46
|
+
// Reloads share one dev server, so the newest run (its folder name starts
|
|
47
|
+
// with its start time) is the one whose log window is open.
|
|
48
|
+
launchesIn(root)
|
|
49
|
+
.filter(({ verdict, metro, device, logDir }) => verdict === "launched" &&
|
|
50
|
+
metro?.port === port &&
|
|
51
|
+
listening.includes(metro.pid) &&
|
|
52
|
+
device &&
|
|
53
|
+
logDir)
|
|
54
|
+
.sort((a, b) => basename(b.logDir ?? "").localeCompare(basename(a.logDir ?? "")))[0];
|
|
55
|
+
const bundled = /Bundled \d+ms/g;
|
|
56
|
+
const count = async (path) => ((await readFile(path, "utf8").catch(() => "")).match(bundled) ?? []).length;
|
|
57
|
+
// Resolves when the dev server log shows a bundle served after `before` bundles.
|
|
58
|
+
export async function untilBundled(logDir, before, seconds) {
|
|
59
|
+
const path = join(logDir, "metro.log");
|
|
60
|
+
const deadline = Date.now() + seconds * 1000;
|
|
61
|
+
while (Date.now() < deadline) {
|
|
62
|
+
if ((await count(path)) > before)
|
|
63
|
+
return true;
|
|
64
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
export const bundlesServed = (logDir) => count(join(logDir, "metro.log"));
|
package/dist/core/result.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const detectResultSchema: z.ZodObject<{
|
|
|
16
16
|
ios: z.ZodOptional<z.ZodString>;
|
|
17
17
|
android: z.ZodOptional<z.ZodString>;
|
|
18
18
|
}, z.core.$strip>>;
|
|
19
|
+
problem: z.ZodOptional<z.ZodString>;
|
|
19
20
|
commands: z.ZodOptional<z.ZodObject<{
|
|
20
21
|
run: z.ZodObject<{
|
|
21
22
|
ios: z.ZodOptional<z.ZodString>;
|
|
@@ -49,6 +50,8 @@ export declare const launchResultSchema: z.ZodObject<{
|
|
|
49
50
|
}, z.core.$strip>>;
|
|
50
51
|
appId: z.ZodOptional<z.ZodString>;
|
|
51
52
|
appPid: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
appIdSet: z.ZodOptional<z.ZodString>;
|
|
54
|
+
reloadFailed: z.ZodOptional<z.ZodString>;
|
|
52
55
|
port: z.ZodOptional<z.ZodNumber>;
|
|
53
56
|
metro: z.ZodOptional<z.ZodObject<{
|
|
54
57
|
pid: z.ZodNumber;
|
|
@@ -61,8 +64,11 @@ export declare const launchResultSchema: z.ZodObject<{
|
|
|
61
64
|
action: z.ZodEnum<{
|
|
62
65
|
built: "built";
|
|
63
66
|
reused: "reused";
|
|
67
|
+
installed: "installed";
|
|
68
|
+
reloaded: "reloaded";
|
|
64
69
|
}>;
|
|
65
70
|
reason: z.ZodOptional<z.ZodString>;
|
|
71
|
+
xcodebuildSeconds: z.ZodOptional<z.ZodNumber>;
|
|
66
72
|
}, z.core.$strip>>;
|
|
67
73
|
screen: z.ZodOptional<z.ZodObject<{
|
|
68
74
|
waited: z.ZodNumber;
|
|
@@ -75,8 +81,31 @@ export declare const launchResultSchema: z.ZodObject<{
|
|
|
75
81
|
}, z.core.$strip>>;
|
|
76
82
|
logDir: z.ZodOptional<z.ZodString>;
|
|
77
83
|
seconds: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
phases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
78
85
|
}, z.core.$strip>;
|
|
79
86
|
export type LaunchResult = z.infer<typeof launchResultSchema>;
|
|
87
|
+
export declare const inputResultSchema: z.ZodObject<{
|
|
88
|
+
verdict: z.ZodEnum<{
|
|
89
|
+
failed: "failed";
|
|
90
|
+
ok: "ok";
|
|
91
|
+
}>;
|
|
92
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
93
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
94
|
+
axe: "axe";
|
|
95
|
+
maestro: "maestro";
|
|
96
|
+
}>>;
|
|
97
|
+
fellBack: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
98
|
+
backend: z.ZodEnum<{
|
|
99
|
+
axe: "axe";
|
|
100
|
+
maestro: "maestro";
|
|
101
|
+
}>;
|
|
102
|
+
reason: z.ZodString;
|
|
103
|
+
}, z.core.$strip>>>;
|
|
104
|
+
seconds: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
retyped: z.ZodOptional<z.ZodString>;
|
|
106
|
+
note: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export type InputResult = z.infer<typeof inputResultSchema>;
|
|
80
109
|
export declare const checkResultSchema: z.ZodObject<{
|
|
81
110
|
verdict: z.ZodEnum<{
|
|
82
111
|
error: "error";
|
|
@@ -88,6 +117,7 @@ export declare const checkResultSchema: z.ZodObject<{
|
|
|
88
117
|
attempt: z.ZodOptional<z.ZodNumber>;
|
|
89
118
|
retryLimit: z.ZodOptional<z.ZodNumber>;
|
|
90
119
|
waited: z.ZodOptional<z.ZodNumber>;
|
|
120
|
+
phases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
91
121
|
logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
92
122
|
tag: z.ZodString;
|
|
93
123
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -118,28 +148,31 @@ export declare const checkResultSchema: z.ZodObject<{
|
|
|
118
148
|
}>>;
|
|
119
149
|
agrees: z.ZodOptional<z.ZodBoolean>;
|
|
120
150
|
}, z.core.$strip>>;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
axe: "axe";
|
|
131
|
-
maestro: "maestro";
|
|
132
|
-
}>>;
|
|
133
|
-
fellBack: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
134
|
-
backend: z.ZodEnum<{
|
|
151
|
+
evidenceDir: z.ZodOptional<z.ZodString>;
|
|
152
|
+
notPassed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
153
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
154
|
+
verdict: z.ZodEnum<{
|
|
155
|
+
failed: "failed";
|
|
156
|
+
ok: "ok";
|
|
157
|
+
}>;
|
|
158
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
159
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
135
160
|
axe: "axe";
|
|
136
161
|
maestro: "maestro";
|
|
137
|
-
}
|
|
138
|
-
|
|
162
|
+
}>>;
|
|
163
|
+
fellBack: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
164
|
+
backend: z.ZodEnum<{
|
|
165
|
+
axe: "axe";
|
|
166
|
+
maestro: "maestro";
|
|
167
|
+
}>;
|
|
168
|
+
reason: z.ZodString;
|
|
169
|
+
}, z.core.$strip>>>;
|
|
170
|
+
seconds: z.ZodOptional<z.ZodNumber>;
|
|
171
|
+
retyped: z.ZodOptional<z.ZodString>;
|
|
172
|
+
note: z.ZodOptional<z.ZodString>;
|
|
139
173
|
}, z.core.$strip>>>;
|
|
140
|
-
seconds: z.ZodOptional<z.ZodNumber>;
|
|
141
174
|
}, z.core.$strip>;
|
|
142
|
-
export type
|
|
175
|
+
export type CheckResult = z.infer<typeof checkResultSchema>;
|
|
143
176
|
export declare const evidenceResultSchema: z.ZodObject<{
|
|
144
177
|
verdict: z.ZodEnum<{
|
|
145
178
|
failed: "failed";
|
|
@@ -184,6 +217,8 @@ export declare const jobViewSchema: z.ZodObject<{
|
|
|
184
217
|
}, z.core.$strip>>;
|
|
185
218
|
appId: z.ZodOptional<z.ZodString>;
|
|
186
219
|
appPid: z.ZodOptional<z.ZodNumber>;
|
|
220
|
+
appIdSet: z.ZodOptional<z.ZodString>;
|
|
221
|
+
reloadFailed: z.ZodOptional<z.ZodString>;
|
|
187
222
|
port: z.ZodOptional<z.ZodNumber>;
|
|
188
223
|
metro: z.ZodOptional<z.ZodObject<{
|
|
189
224
|
pid: z.ZodNumber;
|
|
@@ -196,8 +231,11 @@ export declare const jobViewSchema: z.ZodObject<{
|
|
|
196
231
|
action: z.ZodEnum<{
|
|
197
232
|
built: "built";
|
|
198
233
|
reused: "reused";
|
|
234
|
+
installed: "installed";
|
|
235
|
+
reloaded: "reloaded";
|
|
199
236
|
}>;
|
|
200
237
|
reason: z.ZodOptional<z.ZodString>;
|
|
238
|
+
xcodebuildSeconds: z.ZodOptional<z.ZodNumber>;
|
|
201
239
|
}, z.core.$strip>>;
|
|
202
240
|
screen: z.ZodOptional<z.ZodObject<{
|
|
203
241
|
waited: z.ZodNumber;
|
|
@@ -210,6 +248,7 @@ export declare const jobViewSchema: z.ZodObject<{
|
|
|
210
248
|
}, z.core.$strip>>;
|
|
211
249
|
logDir: z.ZodOptional<z.ZodString>;
|
|
212
250
|
seconds: z.ZodOptional<z.ZodNumber>;
|
|
251
|
+
phases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
213
252
|
}, z.core.$strip>, z.ZodObject<{
|
|
214
253
|
verdict: z.ZodEnum<{
|
|
215
254
|
error: "error";
|
|
@@ -221,6 +260,7 @@ export declare const jobViewSchema: z.ZodObject<{
|
|
|
221
260
|
attempt: z.ZodOptional<z.ZodNumber>;
|
|
222
261
|
retryLimit: z.ZodOptional<z.ZodNumber>;
|
|
223
262
|
waited: z.ZodOptional<z.ZodNumber>;
|
|
263
|
+
phases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
224
264
|
logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
225
265
|
tag: z.ZodString;
|
|
226
266
|
message: z.ZodOptional<z.ZodString>;
|
|
@@ -251,6 +291,29 @@ export declare const jobViewSchema: z.ZodObject<{
|
|
|
251
291
|
}>>;
|
|
252
292
|
agrees: z.ZodOptional<z.ZodBoolean>;
|
|
253
293
|
}, z.core.$strip>>;
|
|
294
|
+
evidenceDir: z.ZodOptional<z.ZodString>;
|
|
295
|
+
notPassed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
296
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
297
|
+
verdict: z.ZodEnum<{
|
|
298
|
+
failed: "failed";
|
|
299
|
+
ok: "ok";
|
|
300
|
+
}>;
|
|
301
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
302
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
303
|
+
axe: "axe";
|
|
304
|
+
maestro: "maestro";
|
|
305
|
+
}>>;
|
|
306
|
+
fellBack: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
307
|
+
backend: z.ZodEnum<{
|
|
308
|
+
axe: "axe";
|
|
309
|
+
maestro: "maestro";
|
|
310
|
+
}>;
|
|
311
|
+
reason: z.ZodString;
|
|
312
|
+
}, z.core.$strip>>>;
|
|
313
|
+
seconds: z.ZodOptional<z.ZodNumber>;
|
|
314
|
+
retyped: z.ZodOptional<z.ZodString>;
|
|
315
|
+
note: z.ZodOptional<z.ZodString>;
|
|
316
|
+
}, z.core.$strip>>>;
|
|
254
317
|
}, z.core.$strip>]>>;
|
|
255
318
|
}, z.core.$strip>;
|
|
256
319
|
export type JobView = z.infer<typeof jobViewSchema>;
|
package/dist/core/result.js
CHANGED
|
@@ -12,6 +12,10 @@ export const detectResultSchema = z.object({
|
|
|
12
12
|
stack: z.enum(stackIds).optional(),
|
|
13
13
|
platforms: z.array(z.enum(platforms)).optional(),
|
|
14
14
|
appIds: perPlatform.optional(),
|
|
15
|
+
// Why `launch` cannot go on: the app config could not be read (for example,
|
|
16
|
+
// dependencies are not installed), or an ios/ folder exists with no iOS app ID
|
|
17
|
+
// in the config.
|
|
18
|
+
problem: z.string().optional(),
|
|
15
19
|
commands: z.object({ run: perPlatform, server: z.string() }).optional(),
|
|
16
20
|
packageManager: z.enum(packageManagers).optional(),
|
|
17
21
|
maestroFlows: z.array(z.string()).optional(),
|
|
@@ -30,6 +34,11 @@ export const launchResultSchema = z.object({
|
|
|
30
34
|
device: z.object({ id: z.string(), name: z.string() }).optional(),
|
|
31
35
|
appId: z.string().optional(),
|
|
32
36
|
appPid: z.number().optional(),
|
|
37
|
+
// The iOS app ID that Expo's build wrote to the app config (ios.bundleIdentifier)
|
|
38
|
+
// because the app had none. Absent when the app already had one.
|
|
39
|
+
appIdSet: z.string().optional(),
|
|
40
|
+
// Why a reload did not work and the app was relaunched instead.
|
|
41
|
+
reloadFailed: z.string().optional(),
|
|
33
42
|
// The Metro port reserved for this worktree; set on a failure after it was.
|
|
34
43
|
port: z.number().optional(),
|
|
35
44
|
// The dev server left running for the app; the next launch in this worktree
|
|
@@ -38,11 +47,16 @@ export const launchResultSchema = z.object({
|
|
|
38
47
|
// The log stream that captures the app's tagged lines; the next launch in
|
|
39
48
|
// this worktree stops it.
|
|
40
49
|
logStream: z.object({ pid: z.number() }).optional(),
|
|
41
|
-
// Whether the Xcode build ran
|
|
50
|
+
// Whether the Xcode build ran, an installed build was reused, an earlier
|
|
51
|
+
// build was installed again, or the running app was reloaded from the dev
|
|
52
|
+
// server; why it was not reused.
|
|
42
53
|
build: z
|
|
43
54
|
.object({
|
|
44
|
-
action: z.enum(["built", "reused"]),
|
|
55
|
+
action: z.enum(["built", "reused", "installed", "reloaded"]),
|
|
45
56
|
reason: z.string().optional(),
|
|
57
|
+
// xcodebuild's own seconds, from its timing summary (#208). Its slowest
|
|
58
|
+
// steps are at the end of build.log.
|
|
59
|
+
xcodebuildSeconds: z.number().optional(),
|
|
46
60
|
})
|
|
47
61
|
.optional(),
|
|
48
62
|
// Set when AXe is installed: seconds `launch` waited until AXe could read the
|
|
@@ -59,10 +73,28 @@ export const launchResultSchema = z.object({
|
|
|
59
73
|
// Full build and server logs live here; read them only when needed.
|
|
60
74
|
logDir: z.string().optional(),
|
|
61
75
|
seconds: z.number().optional(),
|
|
76
|
+
// Seconds each phase took, in order (#203): project, replace, clone, boot,
|
|
77
|
+
// server, reuse or build, open, screen. Only the phases that ran.
|
|
78
|
+
phases: z.record(z.string(), z.number()).optional(),
|
|
62
79
|
});
|
|
63
80
|
const fellBackSchema = z
|
|
64
81
|
.array(z.object({ backend: z.enum(backendIds), reason: z.string() }))
|
|
65
82
|
.optional();
|
|
83
|
+
// A tap, typing or swipe (decision 0009). ok: the backend did it; only a check
|
|
84
|
+
// shows whether the app reacted. failed: it could not, and `reason` says why.
|
|
85
|
+
export const inputResultSchema = z.object({
|
|
86
|
+
verdict: z.enum(["ok", "failed"]),
|
|
87
|
+
reason: z.string().optional(),
|
|
88
|
+
backend: z.enum(backendIds).optional(),
|
|
89
|
+
fellBack: fellBackSchema,
|
|
90
|
+
// A tap by testID or text: seconds from start to finish, which includes
|
|
91
|
+
// the wait for the element. `type`: seconds until the text showed.
|
|
92
|
+
seconds: z.number().optional(),
|
|
93
|
+
// `type`: the rest of the text, when it had to be typed a second time.
|
|
94
|
+
retyped: z.string().optional(),
|
|
95
|
+
// `type` in a secure field: what could and could not be confirmed.
|
|
96
|
+
note: z.string().optional(),
|
|
97
|
+
});
|
|
66
98
|
// The verdict comes only from log events and UI elements. The agent's own
|
|
67
99
|
// reading of a screenshot is recorded next to it as a second opinion and never
|
|
68
100
|
// changes the verdict.
|
|
@@ -78,6 +110,9 @@ export const checkResultSchema = z.object({
|
|
|
78
110
|
// Seconds the check read again for what was missing; absent when the first
|
|
79
111
|
// read decided.
|
|
80
112
|
waited: z.number().optional(),
|
|
113
|
+
// Seconds each step took: actions, logs, screen, wait (between reads),
|
|
114
|
+
// screenshot, evidence. Only the steps that ran (#14 audit).
|
|
115
|
+
phases: z.record(z.string(), z.number()).optional(),
|
|
81
116
|
logs: z
|
|
82
117
|
.array(z.object({
|
|
83
118
|
tag: z.string(),
|
|
@@ -108,17 +143,13 @@ export const checkResultSchema = z.object({
|
|
|
108
143
|
agrees: z.boolean().optional(),
|
|
109
144
|
})
|
|
110
145
|
.optional(),
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
fellBack: fellBackSchema,
|
|
119
|
-
// A tap by testID or text: seconds from start to finish, which includes
|
|
120
|
-
// the wait for the element.
|
|
121
|
-
seconds: z.number().optional(),
|
|
146
|
+
// The run's evidence folder, rewritten after this check (#207), and the
|
|
147
|
+
// worktree's check names whose last verdict is not passed. Report each.
|
|
148
|
+
evidenceDir: z.string().optional(),
|
|
149
|
+
notPassed: z.array(z.string()).optional(),
|
|
150
|
+
// The actions the check ran before it read, in order, with each outcome
|
|
151
|
+
// (#207). A failed action stops the rest and the read.
|
|
152
|
+
actions: z.array(inputResultSchema).optional(),
|
|
122
153
|
});
|
|
123
154
|
export const evidenceResultSchema = z.object({
|
|
124
155
|
verdict: z.enum(["written", "failed"]),
|
package/dist/core/setup.js
CHANGED
|
@@ -67,11 +67,24 @@ const skillSource = () => fileURLToPath(new URL("../../", import.meta.url));
|
|
|
67
67
|
const emdServer = () => skillSource().split(sep).includes("node_modules")
|
|
68
68
|
? `npx -y emd-agents@${version()} mcp`
|
|
69
69
|
: `${process.execPath} ${fileURLToPath(new URL("../bin.js", import.meta.url))} mcp`;
|
|
70
|
+
// Claude Code's CLI lets one stdio tool call run for hours, so EMD waits up to
|
|
71
|
+
// this long per call there and an agent polls less (#223). Codex and Cursor
|
|
72
|
+
// stop a call at 60 s by default and keep EMD's short waits.
|
|
73
|
+
const longWaitSeconds = 100;
|
|
70
74
|
function commands(ids) {
|
|
71
|
-
const to =
|
|
75
|
+
const to = (some) => some.flatMap((id) => ["-a", id]);
|
|
76
|
+
const add = (some, env = []) => [
|
|
77
|
+
"npx",
|
|
78
|
+
["-y", addMcp, emdServer(), "-n", "emd", "-g", ...to(some), ...env, "-y"],
|
|
79
|
+
];
|
|
80
|
+
const long = ids.filter((id) => id === "claude-code");
|
|
81
|
+
const short = ids.filter((id) => id !== "claude-code");
|
|
72
82
|
return [
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
...(long.length > 0
|
|
84
|
+
? [add(long, ["--env", `EMD_WAIT_SECONDS=${longWaitSeconds}`])]
|
|
85
|
+
: []),
|
|
86
|
+
...(short.length > 0 ? [add(short)] : []),
|
|
87
|
+
["npx", ["-y", skillsCli, "add", skillSource(), "-g", ...to(ids), "-y"]],
|
|
75
88
|
];
|
|
76
89
|
}
|
|
77
90
|
const shown = ([command, args]) => [command, ...args.map((a) => (/\s/.test(a) ? `"${a}"` : a))].join(" ");
|
package/dist/core/simulator.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ export declare function parseSdkVersion(output: string): number[] | undefined;
|
|
|
12
12
|
export declare function boot(device: Device): Promise<void>;
|
|
13
13
|
export declare function appAccessibilityOn(device: Device): Promise<boolean>;
|
|
14
14
|
export declare function enableAppAccessibility(device: Device): Promise<void>;
|
|
15
|
+
export declare function plainKeyboard(device: Device): Promise<void>;
|
|
15
16
|
export declare function terminateApp(device: Device, appId: string): Promise<void>;
|
|
16
17
|
export declare function launchApp(device: Device, appId: string): Promise<number>;
|
|
17
18
|
export declare function appInstalled(device: Device, appId: string): Promise<boolean>;
|
|
19
|
+
export declare function installApp(device: Device, appPath: string): Promise<void>;
|
|
18
20
|
export declare function cloneDevice(base: Device, name: string): Promise<string>;
|
|
19
21
|
export type Simulator = {
|
|
20
22
|
id: string;
|
package/dist/core/simulator.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
import { runTool } from "./tool.js";
|
|
2
4
|
export async function listDevices() {
|
|
3
5
|
const { stdout } = await runTool("simctl list", "xcrun", ["simctl", "list", "devices", "available", "--json"], 60);
|
|
@@ -90,21 +92,32 @@ export async function appAccessibilityOn(device) {
|
|
|
90
92
|
return false;
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
|
-
//
|
|
95
|
+
// Sets a boolean preference inside the simulator. It stays on the device; an
|
|
94
96
|
// app that is already running must restart to see it.
|
|
95
|
-
|
|
97
|
+
async function writeBool(device, domain, key, value) {
|
|
96
98
|
await runTool("simctl spawn defaults write", "xcrun", [
|
|
97
99
|
"simctl",
|
|
98
100
|
"spawn",
|
|
99
101
|
device.id,
|
|
100
102
|
"defaults",
|
|
101
103
|
"write",
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
domain,
|
|
105
|
+
key,
|
|
104
106
|
"-bool",
|
|
105
|
-
|
|
107
|
+
String(value),
|
|
106
108
|
], 60);
|
|
107
109
|
}
|
|
110
|
+
// Turns it on, on a simulator EMD made.
|
|
111
|
+
export async function enableAppAccessibility(device) {
|
|
112
|
+
await writeBool(device, "com.apple.Accessibility", accessibilityKey, true);
|
|
113
|
+
}
|
|
114
|
+
// Turns off Predictive Text and Auto-Correction on a simulator EMD made, as
|
|
115
|
+
// Appium's WebDriverAgent does before tests (same keys). Predictions add new
|
|
116
|
+
// text to the screen while `type` waits for its keys, and corrections change
|
|
117
|
+
// the typed text.
|
|
118
|
+
export async function plainKeyboard(device) {
|
|
119
|
+
await Promise.all(["KeyboardPrediction", "KeyboardAutocorrection"].map((key) => writeBool(device, "com.apple.Preferences", key, false)));
|
|
120
|
+
}
|
|
108
121
|
// Stops the app if it runs; a later launch then starts it fresh. Not running is
|
|
109
122
|
// not a failure.
|
|
110
123
|
export async function terminateApp(device, appId) {
|
|
@@ -121,16 +134,21 @@ export async function launchApp(device, appId) {
|
|
|
121
134
|
throw new Error(`unexpected output: ${stdout}`);
|
|
122
135
|
return pid;
|
|
123
136
|
}
|
|
124
|
-
// True when the app is installed on the device.
|
|
137
|
+
// True when the app is installed on the device. `simctl` can name a container
|
|
138
|
+
// whose app files are gone, so the app's Info.plist must exist.
|
|
125
139
|
export async function appInstalled(device, appId) {
|
|
126
140
|
try {
|
|
127
|
-
await runTool("simctl get_app_container", "xcrun", ["simctl", "get_app_container", device.id, appId], 60);
|
|
128
|
-
return
|
|
141
|
+
const { stdout } = await runTool("simctl get_app_container", "xcrun", ["simctl", "get_app_container", device.id, appId], 60);
|
|
142
|
+
return existsSync(join(stdout.trim(), "Info.plist"));
|
|
129
143
|
}
|
|
130
144
|
catch {
|
|
131
145
|
return false;
|
|
132
146
|
}
|
|
133
147
|
}
|
|
148
|
+
// Installs a built `.app` on the device.
|
|
149
|
+
export async function installApp(device, appPath) {
|
|
150
|
+
await runTool("simctl install", "xcrun", ["simctl", "install", device.id, appPath], 120);
|
|
151
|
+
}
|
|
134
152
|
// A new simulator with the same type and runtime as `base`; returns its UDID.
|
|
135
153
|
// The base must be shut down.
|
|
136
154
|
export async function cloneDevice(base, name) {
|
package/dist/mcp/server.d.ts
CHANGED