@aarwitz/tapp 0.33.0 → 0.35.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tapp",
3
3
  "description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
4
- "version": "0.33.0",
4
+ "version": "0.35.0",
5
5
  "author": {
6
6
  "name": "Aaron Horowitz",
7
7
  "url": "https://github.com/aarwitz"
@@ -24,7 +24,7 @@
24
24
  "command": "npx",
25
25
  "args": [
26
26
  "-y",
27
- "@aarwitz/tapp@0.33.0",
27
+ "@aarwitz/tapp@0.35.0",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
@@ -0,0 +1,291 @@
1
+ // tapp's macOS desktop driver, one process away from the engine.
2
+ //
3
+ // Android is driven through `adb` and a UIAutomator dump; iOS through XCUITest. macOS has an
4
+ // equivalent that needs neither a test bundle nor a rebuild of the application under test: the
5
+ // Accessibility API. Any running application exposes a tree of AXUIElements with roles, titles,
6
+ // values and actions, which is the same shape the rest of tapp already speaks.
7
+ //
8
+ // This is deliberately a plain command-line tool rather than a test target, so tapp can be
9
+ // pointed at a .app the way it is pointed at an .apk — nothing to link, nothing to re-sign.
10
+ //
11
+ // It requires the Accessibility permission (System Settings → Privacy & Security →
12
+ // Accessibility) for whatever runs it. There is no way to grant that from code and tapp does not
13
+ // try: `trusted` reports the truth and the CLI explains the one-time step.
14
+ //
15
+ // Elements are addressed by their path of child indices from the application element ("0.3.1").
16
+ // A path is only valid for the snapshot it came from, so every action re-reads the tree first —
17
+ // the same discipline as the Android driver's `snap`.
18
+ import ApplicationServices
19
+ import AppKit
20
+ import Foundation
21
+
22
+ // MARK: - Attribute reading
23
+
24
+ func attribute(_ element: AXUIElement, _ name: String) -> CFTypeRef? {
25
+ var value: CFTypeRef?
26
+ return AXUIElementCopyAttributeValue(element, name as CFString, &value) == .success ? value : nil
27
+ }
28
+
29
+ func stringAttribute(_ element: AXUIElement, _ name: String) -> String {
30
+ guard let value = attribute(element, name) else { return "" }
31
+ if let text = value as? String { return text }
32
+ if let number = value as? NSNumber { return number.stringValue }
33
+ // AXValue of a text area can arrive as an attributed string.
34
+ if let attributed = value as? NSAttributedString { return attributed.string }
35
+ return ""
36
+ }
37
+
38
+ func boolAttribute(_ element: AXUIElement, _ name: String, default fallback: Bool) -> Bool {
39
+ guard let value = attribute(element, name) as? NSNumber else { return fallback }
40
+ return value.boolValue
41
+ }
42
+
43
+ func frame(_ element: AXUIElement) -> [Double] {
44
+ var origin = CGPoint.zero
45
+ var size = CGSize.zero
46
+ if let value = attribute(element, kAXPositionAttribute as String) {
47
+ AXValueGetValue(value as! AXValue, .cgPoint, &origin)
48
+ }
49
+ if let value = attribute(element, kAXSizeAttribute as String) {
50
+ AXValueGetValue(value as! AXValue, .cgSize, &size)
51
+ }
52
+ return [Double(origin.x), Double(origin.y), Double(size.width), Double(size.height)]
53
+ }
54
+
55
+ func children(_ element: AXUIElement) -> [AXUIElement] {
56
+ guard let value = attribute(element, kAXChildrenAttribute as String) as? [AXUIElement] else { return [] }
57
+ return value
58
+ }
59
+
60
+ func actions(_ element: AXUIElement) -> [String] {
61
+ var names: CFArray?
62
+ guard AXUIElementCopyActionNames(element, &names) == .success, let list = names as? [String] else { return [] }
63
+ return list
64
+ }
65
+
66
+ // MARK: - Walking
67
+
68
+ struct Node: Encodable {
69
+ let path: String
70
+ let role: String
71
+ let subrole: String
72
+ let title: String
73
+ let desc: String
74
+ let value: String
75
+ let identifier: String
76
+ let enabled: Bool
77
+ let focused: Bool
78
+ let frame: [Double]
79
+ let actions: [String]
80
+ var children: [Node]
81
+ }
82
+
83
+ /// Caps exist because a document-shaped application (a long outline, a big table) can expose tens
84
+ /// of thousands of elements, and a snapshot that takes a minute is not a snapshot.
85
+ let maxNodesDefault = 2500
86
+ let maxDepthDefault = 28
87
+
88
+ final class Walker {
89
+ var visited = 0
90
+ let maxNodes: Int
91
+ let maxDepth: Int
92
+ init(maxNodes: Int, maxDepth: Int) { self.maxNodes = maxNodes; self.maxDepth = maxDepth }
93
+
94
+ func walk(_ element: AXUIElement, path: String, depth: Int) -> Node {
95
+ visited += 1
96
+ let box = frame(element)
97
+ var node = Node(
98
+ path: path,
99
+ role: stringAttribute(element, kAXRoleAttribute as String),
100
+ subrole: stringAttribute(element, kAXSubroleAttribute as String),
101
+ title: stringAttribute(element, kAXTitleAttribute as String),
102
+ desc: stringAttribute(element, kAXDescriptionAttribute as String),
103
+ value: String(stringAttribute(element, kAXValueAttribute as String).prefix(400)),
104
+ identifier: stringAttribute(element, kAXIdentifierAttribute as String),
105
+ enabled: boolAttribute(element, kAXEnabledAttribute as String, default: true),
106
+ focused: boolAttribute(element, kAXFocusedAttribute as String, default: false),
107
+ frame: box,
108
+ actions: actions(element),
109
+ children: []
110
+ )
111
+ if depth >= maxDepth || visited >= maxNodes { return node }
112
+ for (index, child) in children(element).enumerated() {
113
+ if visited >= maxNodes { break }
114
+ node.children.append(walk(child, path: path.isEmpty ? "\(index)" : "\(path).\(index)", depth: depth + 1))
115
+ }
116
+ return node
117
+ }
118
+ }
119
+
120
+ func element(at path: String, from root: AXUIElement) -> AXUIElement? {
121
+ if path.isEmpty { return root }
122
+ var current = root
123
+ for component in path.split(separator: ".") {
124
+ guard let index = Int(component) else { return nil }
125
+ let kids = children(current)
126
+ guard index >= 0 && index < kids.count else { return nil }
127
+ current = kids[index]
128
+ }
129
+ return current
130
+ }
131
+
132
+ // MARK: - Output
133
+
134
+ func emit(_ value: Encodable, pretty: Bool = false) {
135
+ let encoder = JSONEncoder()
136
+ if pretty { encoder.outputFormatting = [.prettyPrinted, .sortedKeys] }
137
+ struct Box<T: Encodable>: Encodable { let v: T }
138
+ guard let data = try? encoder.encode(AnyEncodable(value)) else { fail("could not encode result") }
139
+ FileHandle.standardOutput.write(data)
140
+ FileHandle.standardOutput.write("\n".data(using: .utf8)!)
141
+ }
142
+
143
+ struct AnyEncodable: Encodable {
144
+ private let encodeTo: (Encoder) throws -> Void
145
+ init(_ wrapped: Encodable) { encodeTo = wrapped.encode }
146
+ func encode(to encoder: Encoder) throws { try encodeTo(encoder) }
147
+ }
148
+
149
+ func fail(_ message: String) -> Never {
150
+ struct Failure: Encodable { let ok = false; let error: String }
151
+ if let data = try? JSONEncoder().encode(Failure(error: message)) {
152
+ FileHandle.standardError.write(data)
153
+ FileHandle.standardError.write("\n".data(using: .utf8)!)
154
+ }
155
+ exit(1)
156
+ }
157
+
158
+ struct Ok: Encodable { let ok = true; let detail: String }
159
+
160
+ // MARK: - Arguments
161
+
162
+ var arguments = Array(CommandLine.arguments.dropFirst())
163
+ guard let command = arguments.first else {
164
+ fail("usage: tapp-mac-ax <trusted|launch|tree|press|setvalue|key|windows|quit> [options]")
165
+ }
166
+ arguments = Array(arguments.dropFirst())
167
+
168
+ func option(_ name: String) -> String? {
169
+ guard let index = arguments.firstIndex(of: "--\(name)"), index + 1 < arguments.count else { return nil }
170
+ return arguments[index + 1]
171
+ }
172
+ func intOption(_ name: String, _ fallback: Int) -> Int { Int(option(name) ?? "") ?? fallback }
173
+
174
+ func requirePid() -> pid_t {
175
+ guard let raw = option("pid"), let pid = Int32(raw) else { fail("--pid is required") }
176
+ return pid
177
+ }
178
+
179
+ func requireTrusted() {
180
+ guard AXIsProcessTrusted() else {
181
+ fail("This program is not allowed to use the Accessibility API. Grant it in System Settings → Privacy & Security → Accessibility, for the application that runs tapp (your terminal, or the tapp app).")
182
+ }
183
+ }
184
+
185
+ // MARK: - Commands
186
+
187
+ switch command {
188
+ case "trusted":
189
+ struct Trust: Encodable { let trusted: Bool }
190
+ emit(Trust(trusted: AXIsProcessTrusted()))
191
+
192
+ case "launch":
193
+ // Launching is ordinary AppKit, not Accessibility: no permission needed to start a program.
194
+ guard let bundlePath = option("app") else { fail("--app /path/to/App.app is required") }
195
+ let url = URL(fileURLWithPath: bundlePath)
196
+ guard FileManager.default.fileExists(atPath: url.path) else { fail("No application at \(url.path)") }
197
+ let configuration = NSWorkspace.OpenConfiguration()
198
+ configuration.activates = true
199
+ configuration.createsNewApplicationInstance = false
200
+ let semaphore = DispatchSemaphore(value: 0)
201
+ var launched: NSRunningApplication?
202
+ var launchError: Error?
203
+ NSWorkspace.shared.openApplication(at: url, configuration: configuration) { application, error in
204
+ launched = application; launchError = error; semaphore.signal()
205
+ }
206
+ if semaphore.wait(timeout: .now() + 30) == .timedOut { fail("Timed out launching \(url.lastPathComponent)") }
207
+ if let error = launchError { fail("Could not launch \(url.lastPathComponent): \(error.localizedDescription)") }
208
+ guard let application = launched else { fail("Could not launch \(url.lastPathComponent)") }
209
+ struct Launched: Encodable { let ok = true; let pid: Int32; let bundleId: String; let name: String }
210
+ emit(Launched(pid: application.processIdentifier,
211
+ bundleId: application.bundleIdentifier ?? "",
212
+ name: application.localizedName ?? url.deletingPathExtension().lastPathComponent))
213
+
214
+ case "tree":
215
+ requireTrusted()
216
+ let pid = requirePid()
217
+ let application = AXUIElementCreateApplication(pid)
218
+ let walker = Walker(maxNodes: intOption("max-nodes", maxNodesDefault), maxDepth: intOption("max-depth", maxDepthDefault))
219
+ struct Tree: Encodable { let ok = true; let pid: Int32; let app: String; let window: String; let truncated: Bool; let nodes: Int; let root: Node }
220
+ let root = walker.walk(application, path: "", depth: 0)
221
+ // The focused window names the screen, the way an h1 names a web page.
222
+ var window = ""
223
+ if let focused = attribute(application, kAXFocusedWindowAttribute as String) {
224
+ window = stringAttribute(focused as! AXUIElement, kAXTitleAttribute as String)
225
+ }
226
+ if window.isEmpty, let windows = attribute(application, kAXWindowsAttribute as String) as? [AXUIElement], let first = windows.first {
227
+ window = stringAttribute(first, kAXTitleAttribute as String)
228
+ }
229
+ let name = NSRunningApplication(processIdentifier: pid)?.localizedName ?? ""
230
+ emit(Tree(pid: pid, app: name, window: window, truncated: walker.visited >= walker.maxNodes, nodes: walker.visited, root: root))
231
+
232
+ case "press":
233
+ requireTrusted()
234
+ let pid = requirePid()
235
+ guard let path = option("path") else { fail("--path is required") }
236
+ let application = AXUIElementCreateApplication(pid)
237
+ guard let target = element(at: path, from: application) else { fail("No element at path \(path)") }
238
+ let available = actions(target)
239
+ let wanted = option("action") ?? (available.contains(kAXPressAction as String) ? kAXPressAction as String : available.first ?? "")
240
+ guard !wanted.isEmpty else { fail("Element at \(path) has no actions") }
241
+ let code = AXUIElementPerformAction(target, wanted as CFString)
242
+ guard code == .success else { fail("\(wanted) on \(path) failed (AXError \(code.rawValue))") }
243
+ emit(Ok(detail: wanted))
244
+
245
+ case "setvalue":
246
+ requireTrusted()
247
+ let pid = requirePid()
248
+ guard let path = option("path") else { fail("--path is required") }
249
+ let text = option("text") ?? ""
250
+ let application = AXUIElementCreateApplication(pid)
251
+ guard let target = element(at: path, from: application) else { fail("No element at path \(path)") }
252
+ // Focus first: some fields only accept a value while they are the responder, and a field the
253
+ // user can see being filled is what a recording should show.
254
+ AXUIElementSetAttributeValue(target, kAXFocusedAttribute as CFString, kCFBooleanTrue)
255
+ let code = AXUIElementSetAttributeValue(target, kAXValueAttribute as CFString, text as CFTypeRef)
256
+ guard code == .success else { fail("Could not set the value of \(path) (AXError \(code.rawValue))") }
257
+ emit(Ok(detail: "set"))
258
+
259
+ case "key":
260
+ requireTrusted()
261
+ let pid = requirePid()
262
+ guard let name = option("key") else { fail("--key is required") }
263
+ let codes: [String: CGKeyCode] = ["return": 36, "enter": 36, "tab": 48, "space": 49, "delete": 51, "escape": 53,
264
+ "left": 123, "right": 124, "down": 125, "up": 126]
265
+ guard let keyCode = codes[name.lowercased()] else { fail("Unknown key '\(name)'. Known: \(codes.keys.sorted().joined(separator: ", "))") }
266
+ guard let source = CGEventSource(stateID: .hidSystemState) else { fail("Could not create an event source") }
267
+ let down = CGEvent(keyboardEventSource: source, virtualKey: keyCode, keyDown: true)
268
+ let up = CGEvent(keyboardEventSource: source, virtualKey: keyCode, keyDown: false)
269
+ down?.postToPid(pid)
270
+ up?.postToPid(pid)
271
+ emit(Ok(detail: name))
272
+
273
+ case "windows":
274
+ requireTrusted()
275
+ let pid = requirePid()
276
+ let application = AXUIElementCreateApplication(pid)
277
+ struct Window: Encodable { let title: String; let frame: [Double] }
278
+ struct Windows: Encodable { let ok = true; let windows: [Window] }
279
+ let list = (attribute(application, kAXWindowsAttribute as String) as? [AXUIElement] ?? [])
280
+ .map { Window(title: stringAttribute($0, kAXTitleAttribute as String), frame: frame($0)) }
281
+ emit(Windows(windows: list))
282
+
283
+ case "quit":
284
+ let pid = requirePid()
285
+ guard let application = NSRunningApplication(processIdentifier: pid) else { emit(Ok(detail: "not running")); exit(0) }
286
+ application.terminate()
287
+ emit(Ok(detail: "terminated"))
288
+
289
+ default:
290
+ fail("Unknown command '\(command)'")
291
+ }
package/README.md CHANGED
@@ -30,6 +30,7 @@ Supported targets:
30
30
  | iOS | Simulator on macOS with Xcode; driven through XCUITest and accessibility |
31
31
  | Android | Connected emulator or device with `adb`; driven through UIAutomator |
32
32
  | Web | Owned browser app in Playwright Chromium |
33
+ | macOS desktop | Any `.app` on a Mac, driven through the Accessibility API; needs the Accessibility permission (`tapp doctor` says how) |
33
34
  | Windows desktop | WPF, WinForms, and WinUI apps through Windows UI Automation — early runs are set up through the pilot |
34
35
 
35
36
  Windows hosts Android and web testing when their prerequisites are installed, and is the home of
package/bin/tapp.js CHANGED
@@ -262,6 +262,26 @@ function repeatedFlagValues(argv, name) {
262
262
  return values;
263
263
  }
264
264
 
265
+ // `--platform windows` used to be indistinguishable from `--platform wbe`: both got
266
+ // "must be ios|android|web", which tells someone who read runtapp.com's Windows card that they
267
+ // typed it wrong. They did not — tapp has no driver for it yet. Say which of the two it is.
268
+ const DRIVEN_PLATFORMS = ["ios", "android", "web", "macos"];
269
+ const DECLARED_WITHOUT_DRIVER = {
270
+ windows: "Windows desktop applications (WPF, WinForms, WinUI)",
271
+ desktop: "desktop applications",
272
+ };
273
+ function refusePlatform(platform) {
274
+ const described = DECLARED_WITHOUT_DRIVER[String(platform || "").toLowerCase()];
275
+ if (described) {
276
+ console.error(`❌ tapp has no driver for ${described} yet, so there is nothing to run here.`);
277
+ console.error(" Early runs are set up with us while the driver lands: hello@runtapp.com");
278
+ console.error(" Today tapp drives: web (anywhere), iOS and macOS apps (on a Mac), Android (adb).");
279
+ } else {
280
+ console.error("❌ --platform must be ios|android|web|macos");
281
+ }
282
+ process.exit(2);
283
+ }
284
+
265
285
  function iosLaunchOptions(flags, argv) {
266
286
  const appLaunchArgs = repeatedFlagValues(argv, "launch-arg");
267
287
  let appLaunchEnv;
@@ -291,10 +311,19 @@ function requireMacFor(what) {
291
311
  process.exit(1);
292
312
  }
293
313
 
314
+ // A macOS application bundle and an iOS simulator build are both directories called
315
+ // Something.app. The difference is where the executable lives: a Mac bundle keeps it in
316
+ // Contents/MacOS, a simulator build keeps it at the top level.
317
+ function looksLikeMacosBundle(target) {
318
+ try { return /\.app\/?$/.test(target) && fs.existsSync(path.join(target, "Contents", "MacOS")); }
319
+ catch { return false; }
320
+ }
321
+
294
322
  function requestedPlatform(flags, target = "") {
295
323
  if (typeof flags.platform === "string") return flags.platform.toLowerCase();
296
324
  if (/^https?:\/\//i.test(target)) return "web";
297
325
  if (/\.apk$/i.test(target)) return "android";
326
+ if (looksLikeMacosBundle(target)) return "macos";
298
327
  return "ios";
299
328
  }
300
329
 
@@ -835,7 +864,7 @@ switch (command) {
835
864
  process.exit(2);
836
865
  }
837
866
  }
838
- if (!["ios", "android", "web"].includes(platform)) { console.error("❌ --platform must be ios|android|web"); process.exit(2); }
867
+ if (!DRIVEN_PLATFORMS.includes(platform)) refusePlatform(platform);
839
868
  const engine = await engineImport();
840
869
  let started = null;
841
870
  try {
@@ -997,11 +1026,12 @@ switch (command) {
997
1026
  }
998
1027
  }
999
1028
  const platform = requestedPlatform(flags, target);
1000
- if (!["ios", "android", "web"].includes(platform)) {
1001
- console.error("❌ --platform must be ios|android|web");
1002
- process.exit(2);
1003
- }
1029
+ if (!DRIVEN_PLATFORMS.includes(platform)) refusePlatform(platform);
1004
1030
  if (platform === "ios") requireMacFor("iOS testing");
1031
+ if (platform === "macos") {
1032
+ requireMacFor("macOS application testing");
1033
+ if (!target) { console.error("❌ macOS exploration needs an application: tapp explore /Applications/Yours.app"); process.exit(2); }
1034
+ }
1005
1035
  if (flags.watch === true && platform !== "web") {
1006
1036
  console.error("❌ --watch is currently available for web exploration only");
1007
1037
  process.exit(2);
@@ -1016,7 +1046,7 @@ switch (command) {
1016
1046
  }
1017
1047
  const bundleId = platform === "ios" ? await resolveTargetOrExit(engine, target) : null;
1018
1048
  const android = platform === "android" ? androidTarget(flags, target) : null;
1019
- const progressMetric = platform === "web" ? "pages reached" : platform === "ios" ? "structural states observed" : "screens reached";
1049
+ const progressMetric = platform === "web" ? "pages reached" : platform === "ios" ? "structural states observed" : platform === "macos" ? "window states observed" : "screens reached";
1020
1050
  const onProgress = (p) =>
1021
1051
  writeProgress(`🔍 Exploring… ${p.action}/${p.max || flags.actions || 60} actions · ${p.states} ${progressMetric}`);
1022
1052
  // --interactive: when the run meets a sign-in it has no credentials for, it stops and asks
@@ -1073,6 +1103,17 @@ switch (command) {
1073
1103
  surface: "cli",
1074
1104
  onProgress,
1075
1105
  })
1106
+ : platform === "macos"
1107
+ ? await engine.runQaMacos({
1108
+ appPath: target,
1109
+ maxActions: flags.actions,
1110
+ timeout: flags.timeout,
1111
+ testEmail: flags.email,
1112
+ testPassword: flags.password,
1113
+ baselineFindings,
1114
+ surface: "cli",
1115
+ onProgress,
1116
+ })
1076
1117
  : await engine.runQaIos({
1077
1118
  bundleId,
1078
1119
  maxActions: flags.actions,
@@ -1341,7 +1382,7 @@ switch (command) {
1341
1382
  catch (error) { console.error(`❌ ${error.message}`); process.exit(2); }
1342
1383
  const platform = typeof flags.platform === "string" ? flags.platform.toLowerCase()
1343
1384
  : verb === "run" ? (typeof flags.url === "string" ? "web" : typeof flags["app-id"] === "string" || typeof flags.apk === "string" ? "android" : "ios") : "";
1344
- if (platform && !["ios", "android", "web"].includes(platform)) { console.error("❌ --platform must be ios|android|web"); process.exit(2); }
1385
+ if (platform && !DRIVEN_PLATFORMS.includes(platform)) refusePlatform(platform);
1345
1386
  let grounding = { errors: [], warnings: [] };
1346
1387
  let groundingMap = null;
1347
1388
  let groundingMapPath = null;
@@ -1476,7 +1517,7 @@ switch (command) {
1476
1517
  process.exit(2);
1477
1518
  }
1478
1519
  const platform = String(flags.platform || flow.platform || (flow.url || /^https?:\/\//i.test(flow.app || "") ? "web" : "ios")).toLowerCase();
1479
- if (!["ios", "android", "web"].includes(platform)) {
1520
+ if (!DRIVEN_PLATFORMS.includes(platform)) {
1480
1521
  console.error(`❌ Unsupported Flow platform: ${platform}`);
1481
1522
  process.exit(2);
1482
1523
  }
@@ -1559,6 +1600,11 @@ switch (command) {
1559
1600
  } else if (platform === "android") {
1560
1601
  const target = androidTarget(flags, typeof flags["app-id"] === "string" ? flags["app-id"] : flow.app || "");
1561
1602
  invocation = [process.execPath, [path.join(packageRoot, "scripts", "run-android-flow.js"), absolute, target.appId, target.apkPath || "", target.serial || ""]];
1603
+ } else if (platform === "macos") {
1604
+ requireMacFor("macOS Flow replay");
1605
+ const app = typeof flags.app === "string" ? flags.app : flow.app || "";
1606
+ if (!app) { console.error("❌ A macOS Flow needs `app:` with the path to the application, or --app"); process.exit(2); }
1607
+ invocation = [process.execPath, [path.join(packageRoot, "scripts", "run-macos-flow.js"), absolute, app]];
1562
1608
  } else {
1563
1609
  requireMacFor("iOS Flow replay");
1564
1610
  invocation = ["bash", [path.join(packageRoot, "scripts", "run-flow.sh"), absolute, typeof flags["bundle-id"] === "string" ? flags["bundle-id"] : flow.app || ""]];
@@ -1588,7 +1634,7 @@ switch (command) {
1588
1634
  try { contract = await loadReleaseContractFile(contractPath); }
1589
1635
  catch (error) { console.error(`❌ ${error.message}`); process.exit(2); }
1590
1636
  const platform = String(flags.platform || (contract.platforms.length === 1 ? contract.platforms[0] : "")).toLowerCase();
1591
- if (platform && !["ios", "android", "web"].includes(platform)) { console.error("❌ --platform must be ios|android|web"); process.exit(2); }
1637
+ if (platform && !DRIVEN_PLATFORMS.includes(platform)) refusePlatform(platform);
1592
1638
  let grounding = { errors: [], warnings: [] };
1593
1639
  let groundingMap = null;
1594
1640
  let groundingMapPath = "";
@@ -1753,7 +1799,7 @@ switch (command) {
1753
1799
  }
1754
1800
  const platform = String(flags.platform || "ios").toLowerCase();
1755
1801
  if (!["ios", "android", "web"].includes(platform)) {
1756
- console.error("❌ --platform must be ios|android|web");
1802
+ refusePlatform(platform);
1757
1803
  process.exit(2);
1758
1804
  }
1759
1805
  const out = path.resolve(typeof flags.out === "string" ? flags.out : path.join(".tapp", "ui-map.json"));
@@ -1878,7 +1924,7 @@ switch (command) {
1878
1924
  const { flags: doctorFlags } = parseVerbArgs(rest);
1879
1925
  const jsonMode = doctorFlags.json === true;
1880
1926
  const report = { version: pkg.version, healthy: true, node: {}, python3: {}, disk: {},
1881
- platforms: { ios: {}, android: {}, web: {} }, home: tappHome };
1927
+ platforms: { ios: {}, macos: {}, android: {}, web: {} }, home: tappHome };
1882
1928
  const say = (line) => { if (!jsonMode) console.log(line); };
1883
1929
  const sayOk = (label, detail = "") => { if (!jsonMode) ok(label, detail); };
1884
1930
  const sayBad = (label, detail = "") => { if (!jsonMode) bad(label, detail); };
@@ -1929,6 +1975,24 @@ switch (command) {
1929
1975
  say(` ⬜ iOS — requires macOS (this host: ${process.platform})`);
1930
1976
  }
1931
1977
 
1978
+ // macOS desktop applications. The driver is the Accessibility API, which needs a one-time
1979
+ // permission nothing can grant for you — so report the permission, not just the platform.
1980
+ if (process.platform === "darwin") {
1981
+ try {
1982
+ const { macAccessibilityTrusted, ACCESSIBILITY_REMEDIATION } = await import(path.join(packageRoot, "mcp-server", "src", "macos-driver.js"));
1983
+ const trusted = macAccessibilityTrusted({ home: tappHome });
1984
+ report.platforms.macos = { available: trusted, accessibility: trusted, ...(trusted ? {} : { reason: "Accessibility permission not granted" }) };
1985
+ if (trusted) sayOk("macOS apps", "Accessibility permission granted");
1986
+ else say(` ⬜ macOS apps — ${ACCESSIBILITY_REMEDIATION}`);
1987
+ } catch (error) {
1988
+ report.platforms.macos = { available: false, reason: String(error.message || error).slice(0, 160) };
1989
+ say(` ⬜ macOS apps — ${String(error.message || error).slice(0, 120)}`);
1990
+ }
1991
+ } else {
1992
+ report.platforms.macos = { available: false, reason: `requires macOS (this host: ${process.platform})` };
1993
+ say(` ⬜ macOS apps — requires macOS (this host: ${process.platform})`);
1994
+ }
1995
+
1932
1996
  const { resolveAdbPath, resolveAndroidSdkRoot } = await import(path.join(packageRoot, "mcp-server", "src", "android-driver.js"));
1933
1997
  const adbPath = resolveAdbPath();
1934
1998
  const adb = adbPath ? run(adbPath, ["devices"]) : { code: 1, stdout: "" };
package/browser/app.css CHANGED
@@ -606,3 +606,28 @@ dialog::backdrop { background:rgba(0,0,0,.6); }
606
606
  .signin-or::before, .signin-or::after { content:""; flex:1; height:1px; background:var(--line); }
607
607
  .run-stats .bad strong { color:#f87171; }
608
608
  #admin-body .actor-row { grid-template-columns: 1.5fr 1fr 1fr; }
609
+
610
+ /* Platforms — what tapp drives, and what this machine can start (ADR-0010).
611
+ Three states, and the "no driver yet" one must never look like a configuration problem the
612
+ reader could fix by installing something. */
613
+ .platform-strip { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:14px 0 0; justify-content:center; }
614
+ .platform-chip { display:inline-flex; align-items:center; gap:7px; padding:5px 11px; border-radius:999px; font-size:12px;
615
+ border:1px solid var(--tapp-border); color:var(--tapp-text-soft); background:var(--tapp-panel); }
616
+ .platform-chip i { width:7px; height:7px; border-radius:50%; background:currentColor; flex:none; }
617
+ .platform-chip.ready { color:var(--tapp-green); border-color:rgba(63,185,80,.38); }
618
+ .platform-chip.needs-machine { color:var(--tapp-amber-soft); border-color:rgba(210,153,34,.38); }
619
+ .platform-chip.pilot { color:var(--tapp-text-faint); }
620
+ .platform-more { font-size:12px; }
621
+
622
+ #platform-list { display:grid; gap:14px; grid-template-columns:repeat(auto-fit, minmax(320px, 1fr)); }
623
+ .platform-card .platform-summary { margin:0 0 6px; }
624
+ .platform-card .platform-how { margin:0 0 10px; color:var(--tapp-text-soft); font-size:13px; }
625
+ .platform-command { margin:0 0 10px; padding:9px 11px; border-radius:8px; background:var(--tapp-panel-2);
626
+ border:1px solid var(--tapp-border); overflow-x:auto; font-size:12.5px; }
627
+ .platform-state { font-size:11px; letter-spacing:.04em; text-transform:uppercase; padding:3px 9px; border-radius:999px;
628
+ border:1px solid var(--tapp-border); color:var(--tapp-text-soft); white-space:nowrap; }
629
+ .platform-state.ready { color:var(--tapp-green); border-color:rgba(63,185,80,.38); }
630
+ .platform-state.needs-machine { color:var(--tapp-amber-soft); border-color:rgba(210,153,34,.38); }
631
+
632
+ /* A suggestion this Studio cannot start is dimmed, not deleted: pressing it still answers. */
633
+ .prompt-suggestions [data-kind].elsewhere { opacity:.62; }
package/browser/app.js CHANGED
@@ -79,6 +79,61 @@ function operationPayload(extra = {}) {
79
79
  };
80
80
  }
81
81
 
82
+ // ——— Platforms ————————————————————————————————————————————————————————————————————————
83
+ // tapp drives websites, iOS simulators and Android devices, and the Studio is the same program
84
+ // wherever it runs. A hosted Studio on a Linux box cannot start an iOS run, which is a fact
85
+ // about that machine, not about the product — so say both, and give the command that fixes it.
86
+ // The states come from the server, computed from the machine it is on (mcp-server/src/platforms.js).
87
+ const PLATFORM_STATE_LABEL = { ready: "Ready here", "needs-machine": "Needs your machine", pilot: "No driver yet" };
88
+
89
+ function platformsFromSession() {
90
+ return Array.isArray(state.session?.platforms) ? state.session.platforms : [];
91
+ }
92
+
93
+ // A compact answer to "what does this thing drive?", on the first screen anyone sees.
94
+ function renderPlatformStrip() {
95
+ const strip = $("#platform-strip");
96
+ if (!strip) return;
97
+ const platforms = platformsFromSession();
98
+ strip.hidden = platforms.length === 0;
99
+ if (!platforms.length) return;
100
+ strip.innerHTML = `${platforms.map((platform) => `
101
+ <span class="platform-chip ${esc(platform.state)}" title="${esc(platform.summary)}">
102
+ <i></i>${esc(platform.label)}
103
+ </span>`).join("")}
104
+ <button type="button" class="quiet platform-more" data-platforms-open>What tapp can drive →</button>`;
105
+ }
106
+
107
+ function renderPlatforms() {
108
+ const node = $("#platform-list");
109
+ if (!node) return;
110
+ const platforms = platformsFromSession();
111
+ if (!platforms.length) { node.innerHTML = `<div class="empty">Checking this machine…</div>`; return; }
112
+ node.innerHTML = platforms.map((platform) => `
113
+ <article class="panel platform-card ${esc(platform.state)}">
114
+ <div class="section-heading compact">
115
+ <div><p class="eyebrow">${esc(platform.give)}</p><h2>${esc(platform.label)}</h2></div>
116
+ <span class="platform-state ${esc(platform.state)}">${esc(PLATFORM_STATE_LABEL[platform.state] || platform.state)}</span>
117
+ </div>
118
+ <p class="platform-summary">${esc(platform.summary)}</p>
119
+ <p class="platform-how">${esc(platform.how)}</p>
120
+ ${platform.command ? `<pre class="platform-command"><code>${esc(platform.command)}</code></pre>` : ""}
121
+ ${platform.state === "ready" ? ""
122
+ : platform.state === "pilot"
123
+ // No driver: the ask is "we would like one", and the honest reply is a conversation.
124
+ ? `<button type="button" class="quiet" data-platform-interest="${esc(platform.id)}">Tell us about your ${esc(platform.label.replace(/ app$/, ""))} app</button>`
125
+ // A driver exists; what is missing is a machine. The ask is "run it for me".
126
+ : `<button type="button" class="quiet" data-platform-interest="${esc(platform.id)}">I want tapp to run this for me</button>`}
127
+ </article>`).join("");
128
+ }
129
+
130
+ async function registerPlatformInterest(id) {
131
+ try {
132
+ await api("/api/platforms/interest", { method:"POST", body: JSON.stringify({ platform: id }) });
133
+ toast("Noted. That is the signal we use to decide what to build next.");
134
+ } catch (error) { toast(error.message, true); }
135
+ }
136
+
82
137
  function activateView(view) {
83
138
  if (!customerProductContract.views.some((item) => item.id === view)) view = "overview";
84
139
  state.activeView = view;
@@ -147,16 +202,25 @@ async function signOut() {
147
202
  function applyAccessMode() {
148
203
  const session = state.session || {};
149
204
  renderAccount();
205
+ // Before the early return below: a local Studio has a platform surface too, and it is the
206
+ // one where most of it says "ready".
207
+ renderPlatformStrip();
208
+ renderPlatforms();
150
209
  if (session.access !== "anonymous" && session.access !== "account") return;
151
210
  const signedIn = session.access === "account";
152
211
  const accepts = new Set(session.accepts || ["url"]);
212
+ // A target this Studio cannot START is still a thing tapp does. It used to be deleted from
213
+ // the screen, which is how a cross-platform product came to look like a website checker: the
214
+ // hosted Studio erased every mention of iOS, Android and folders. Keep them, mark them, and
215
+ // let the answer be "here is where that runs" (ADR-0010).
153
216
  for (const button of document.querySelectorAll("[data-kind]")) {
154
217
  const kind = button.dataset.kind;
155
218
  const usable = kind === "url" ? accepts.has("url") : accepts.has(kind);
156
- button.closest("li")?.classList.toggle("hidden", !usable);
219
+ button.closest("li")?.classList.remove("hidden");
220
+ button.classList.toggle("elsewhere", !usable);
157
221
  }
158
222
  const input = $("#prompt-input");
159
- if (input) input.placeholder = "A website URL…";
223
+ if (input) input.placeholder = accepts.has("path") ? input.placeholder : "A website URL — or an .app, .apk or repo to be told where it runs…";
160
224
  // Everything that only means something against a source repository: a target to build, a
161
225
  // runner, a release gate, a decision. A hosted visitor auditing a URL has none of them, and
162
226
  // showing the empty frames makes a working run look like a broken one.
@@ -169,8 +233,8 @@ function applyAccessMode() {
169
233
  if (!state.headingOwnedByRun) setHeading("tapp", signedIn ? "Give it a website. If there is a sign-in, I will ask you for a test account and remember it." : "Give it a public website and it will audit the pages read-only.");
170
234
  const note = $("#privacy-note-detail");
171
235
  if (note) note.textContent = signedIn
172
- ? "Websites are explored in the cloud. Test accounts you give tapp are kept encrypted, used only to sign in, and never shown again. iOS, Android and folders on your own machine need tapp there: npx -y @aarwitz/tapp@latest app"
173
- : "Websites are audited read-only in the cloud; nothing is clicked. Sign in to go inside a site. iOS, Android and folders on your own machine need tapp there: npx -y @aarwitz/tapp@latest app";
236
+ ? "Websites are explored in the cloud. Test accounts you give tapp are kept encrypted, used only to sign in, and never shown again. iOS, Android and folders on your own machine run the same Studio there: npx -y @aarwitz/tapp@latest app"
237
+ : "Websites are audited read-only in the cloud; nothing is clicked. Sign in to go inside a site. iOS, Android and folders on your own machine run the same Studio there: npx -y @aarwitz/tapp@latest app";
174
238
  $("#actors-panel")?.classList.toggle("hidden", !signedIn);
175
239
  $("#journeys-panel")?.classList.toggle("hidden", !signedIn);
176
240
  $("#agent-panel")?.classList.toggle("hidden", !signedIn);
@@ -271,6 +335,11 @@ function renderAdmin() {
271
335
  ${activity.people.length ? activity.people.map((p) => `<div class="actor-row"><span><strong>${p.kind === "account" ? "account" : "visitor"} ${esc(p.id.split(":")[1])}</strong><br><small>first seen ${esc(compactDate(p.first))} · last ${esc(compactDate(p.last))}</small></span><span><small>${esc(Object.entries(p.events).map(([k, v]) => `${k.replace(/\./g, " ")} ×${v}`).join(" · ").slice(0, 90) || "—")}</small></span><span><small>${esc(p.hosts.join(", ") || "—")}</small></span></div>`).join("") : '<div class="empty">Nobody yet. Activity is recorded from the release that introduced this log.</div>'}
272
336
  </section>
273
337
 
338
+ <section class="panel section">
339
+ <div class="section-heading compact"><div><p class="eyebrow">Demand</p><h2>What people wanted that this Studio could not do</h2><p>“Turned away” is somebody who actually pointed tapp at a target it could not start here — the stronger signal, because they tried. “Asked for” is somebody pressing the button on the Platforms page.</p></div></div>
340
+ ${(data.demand || []).length ? (data.demand).map((platform) => `<div class="actor-row"><span><strong>${esc(platform.label)}</strong><br><small>${esc(PLATFORM_STATE_LABEL[platform.state] || platform.state)}</small></span><span><small>${esc(String(platform.turnedAway))} turned away</small></span><span><small>${esc(String(platform.askedFor))} asked for</small></span></div>`).join("") : '<div class="empty">Nothing recorded yet.</div>'}
341
+ </section>
342
+
274
343
  <section class="panel section">
275
344
  <div class="section-heading compact"><div><p class="eyebrow">Accounts</p><h2>People with a tapp account <i class="zero">${data.accounts.length}</i></h2><p>Test accounts are counted, never shown — tapp cannot show them.</p></div></div>
276
345
  ${data.accounts.length ? data.accounts.map((account) => `<div class="actor-row"><span><strong>${esc(account.email)}</strong>${owner(account.email) ? ' <small class="journey-status passing">owner</small>' : ""}<br><small>joined ${esc(compactDate(account.createdAt))}${account.lastSeenAt ? ` · last seen ${esc(compactDate(account.lastSeenAt))}` : ""}</small></span><span><small>${account.journeys} journey${account.journeys === 1 ? "" : "s"}${account.failing ? ` · <b class="journey-status failing">${account.failing} failing</b>` : ""}${account.neverRun ? ` · ${account.neverRun} never run` : ""}</small></span><span><small>${account.testAccounts} test account${account.testAccounts === 1 ? "" : "s"} · ${account.tokens} token${account.tokens === 1 ? "" : "s"}</small></span></div>`).join("") : '<div class="empty">Nobody has signed in yet.</div>'}
@@ -1086,6 +1155,10 @@ async function auditWebsite(url) {
1086
1155
  document.addEventListener("click", (event) => {
1087
1156
  const viewButton = event.target.closest("[data-view]");
1088
1157
  if (viewButton && $("#product-shell").contains(viewButton)) activateView(viewButton.dataset.view);
1158
+ // "What tapp can drive" is reachable from the first screen, before there is any project.
1159
+ if (event.target.closest("[data-platforms-open]")) { showProduct(); activateView("platforms"); renderPlatforms(); }
1160
+ const interest = event.target.closest("[data-platform-interest]");
1161
+ if (interest) registerPlatformInterest(interest.dataset.platformInterest);
1089
1162
  const targetButton = event.target.closest("[data-target-id]");
1090
1163
  if (targetButton) {
1091
1164
  state.selectedTargetId = targetButton.dataset.targetId;