deepadb 1.0.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 (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +631 -0
  3. package/build/bridge/adb-bridge.d.ts +65 -0
  4. package/build/bridge/adb-bridge.d.ts.map +1 -0
  5. package/build/bridge/adb-bridge.js +164 -0
  6. package/build/bridge/adb-bridge.js.map +1 -0
  7. package/build/bridge/device-manager.d.ts +41 -0
  8. package/build/bridge/device-manager.d.ts.map +1 -0
  9. package/build/bridge/device-manager.js +109 -0
  10. package/build/bridge/device-manager.js.map +1 -0
  11. package/build/bridge/local-bridge.d.ts +92 -0
  12. package/build/bridge/local-bridge.d.ts.map +1 -0
  13. package/build/bridge/local-bridge.js +345 -0
  14. package/build/bridge/local-bridge.js.map +1 -0
  15. package/build/config/config.d.ts +39 -0
  16. package/build/config/config.d.ts.map +1 -0
  17. package/build/config/config.js +84 -0
  18. package/build/config/config.js.map +1 -0
  19. package/build/graphql-api.d.ts +36 -0
  20. package/build/graphql-api.d.ts.map +1 -0
  21. package/build/graphql-api.js +296 -0
  22. package/build/graphql-api.js.map +1 -0
  23. package/build/http-transport.d.ts +26 -0
  24. package/build/http-transport.d.ts.map +1 -0
  25. package/build/http-transport.js +105 -0
  26. package/build/http-transport.js.map +1 -0
  27. package/build/index.d.ts +14 -0
  28. package/build/index.d.ts.map +1 -0
  29. package/build/index.js +66 -0
  30. package/build/index.js.map +1 -0
  31. package/build/middleware/chipset.d.ts +29 -0
  32. package/build/middleware/chipset.d.ts.map +1 -0
  33. package/build/middleware/chipset.js +123 -0
  34. package/build/middleware/chipset.js.map +1 -0
  35. package/build/middleware/cleanup.d.ts +24 -0
  36. package/build/middleware/cleanup.d.ts.map +1 -0
  37. package/build/middleware/cleanup.js +53 -0
  38. package/build/middleware/cleanup.js.map +1 -0
  39. package/build/middleware/fetch-utils.d.ts +19 -0
  40. package/build/middleware/fetch-utils.d.ts.map +1 -0
  41. package/build/middleware/fetch-utils.js +64 -0
  42. package/build/middleware/fetch-utils.js.map +1 -0
  43. package/build/middleware/logger.d.ts +17 -0
  44. package/build/middleware/logger.d.ts.map +1 -0
  45. package/build/middleware/logger.js +38 -0
  46. package/build/middleware/logger.js.map +1 -0
  47. package/build/middleware/output-processor.d.ts +57 -0
  48. package/build/middleware/output-processor.d.ts.map +1 -0
  49. package/build/middleware/output-processor.js +162 -0
  50. package/build/middleware/output-processor.js.map +1 -0
  51. package/build/middleware/sanitize.d.ts +30 -0
  52. package/build/middleware/sanitize.d.ts.map +1 -0
  53. package/build/middleware/sanitize.js +46 -0
  54. package/build/middleware/sanitize.js.map +1 -0
  55. package/build/middleware/security.d.ts +52 -0
  56. package/build/middleware/security.d.ts.map +1 -0
  57. package/build/middleware/security.js +123 -0
  58. package/build/middleware/security.js.map +1 -0
  59. package/build/middleware/ui-dump.d.ts +23 -0
  60. package/build/middleware/ui-dump.d.ts.map +1 -0
  61. package/build/middleware/ui-dump.js +59 -0
  62. package/build/middleware/ui-dump.js.map +1 -0
  63. package/build/server.d.ts +18 -0
  64. package/build/server.d.ts.map +1 -0
  65. package/build/server.js +133 -0
  66. package/build/server.js.map +1 -0
  67. package/build/tool-context.d.ts +22 -0
  68. package/build/tool-context.d.ts.map +1 -0
  69. package/build/tool-context.js +9 -0
  70. package/build/tool-context.js.map +1 -0
  71. package/build/tools/accessibility.d.ts +10 -0
  72. package/build/tools/accessibility.d.ts.map +1 -0
  73. package/build/tools/accessibility.js +259 -0
  74. package/build/tools/accessibility.js.map +1 -0
  75. package/build/tools/at-commands.d.ts +20 -0
  76. package/build/tools/at-commands.d.ts.map +1 -0
  77. package/build/tools/at-commands.js +378 -0
  78. package/build/tools/at-commands.js.map +1 -0
  79. package/build/tools/baseband.d.ts +15 -0
  80. package/build/tools/baseband.d.ts.map +1 -0
  81. package/build/tools/baseband.js +323 -0
  82. package/build/tools/baseband.js.map +1 -0
  83. package/build/tools/build.d.ts +6 -0
  84. package/build/tools/build.d.ts.map +1 -0
  85. package/build/tools/build.js +80 -0
  86. package/build/tools/build.js.map +1 -0
  87. package/build/tools/ci.d.ts +9 -0
  88. package/build/tools/ci.d.ts.map +1 -0
  89. package/build/tools/ci.js +163 -0
  90. package/build/tools/ci.js.map +1 -0
  91. package/build/tools/control.d.ts +10 -0
  92. package/build/tools/control.d.ts.map +1 -0
  93. package/build/tools/control.js +197 -0
  94. package/build/tools/control.js.map +1 -0
  95. package/build/tools/device-farm.d.ts +10 -0
  96. package/build/tools/device-farm.d.ts.map +1 -0
  97. package/build/tools/device-farm.js +140 -0
  98. package/build/tools/device-farm.js.map +1 -0
  99. package/build/tools/device-profiles.d.ts +16 -0
  100. package/build/tools/device-profiles.d.ts.map +1 -0
  101. package/build/tools/device-profiles.js +272 -0
  102. package/build/tools/device-profiles.js.map +1 -0
  103. package/build/tools/device.d.ts +6 -0
  104. package/build/tools/device.d.ts.map +1 -0
  105. package/build/tools/device.js +72 -0
  106. package/build/tools/device.js.map +1 -0
  107. package/build/tools/diagnostics.d.ts +7 -0
  108. package/build/tools/diagnostics.d.ts.map +1 -0
  109. package/build/tools/diagnostics.js +153 -0
  110. package/build/tools/diagnostics.js.map +1 -0
  111. package/build/tools/emulator.d.ts +9 -0
  112. package/build/tools/emulator.d.ts.map +1 -0
  113. package/build/tools/emulator.js +223 -0
  114. package/build/tools/emulator.js.map +1 -0
  115. package/build/tools/files.d.ts +6 -0
  116. package/build/tools/files.d.ts.map +1 -0
  117. package/build/tools/files.js +78 -0
  118. package/build/tools/files.js.map +1 -0
  119. package/build/tools/firmware-analysis.d.ts +24 -0
  120. package/build/tools/firmware-analysis.d.ts.map +1 -0
  121. package/build/tools/firmware-analysis.js +623 -0
  122. package/build/tools/firmware-analysis.js.map +1 -0
  123. package/build/tools/forwarding.d.ts +7 -0
  124. package/build/tools/forwarding.d.ts.map +1 -0
  125. package/build/tools/forwarding.js +64 -0
  126. package/build/tools/forwarding.js.map +1 -0
  127. package/build/tools/health.d.ts +7 -0
  128. package/build/tools/health.d.ts.map +1 -0
  129. package/build/tools/health.js +112 -0
  130. package/build/tools/health.js.map +1 -0
  131. package/build/tools/logcat-watch.d.ts +11 -0
  132. package/build/tools/logcat-watch.d.ts.map +1 -0
  133. package/build/tools/logcat-watch.js +209 -0
  134. package/build/tools/logcat-watch.js.map +1 -0
  135. package/build/tools/logs.d.ts +6 -0
  136. package/build/tools/logs.d.ts.map +1 -0
  137. package/build/tools/logs.js +83 -0
  138. package/build/tools/logs.js.map +1 -0
  139. package/build/tools/mirroring.d.ts +14 -0
  140. package/build/tools/mirroring.d.ts.map +1 -0
  141. package/build/tools/mirroring.js +243 -0
  142. package/build/tools/mirroring.js.map +1 -0
  143. package/build/tools/multi-device.d.ts +9 -0
  144. package/build/tools/multi-device.d.ts.map +1 -0
  145. package/build/tools/multi-device.js +138 -0
  146. package/build/tools/multi-device.js.map +1 -0
  147. package/build/tools/network-capture.d.ts +10 -0
  148. package/build/tools/network-capture.d.ts.map +1 -0
  149. package/build/tools/network-capture.js +143 -0
  150. package/build/tools/network-capture.js.map +1 -0
  151. package/build/tools/network-discovery.d.ts +21 -0
  152. package/build/tools/network-discovery.d.ts.map +1 -0
  153. package/build/tools/network-discovery.js +284 -0
  154. package/build/tools/network-discovery.js.map +1 -0
  155. package/build/tools/ota-monitor.d.ts +16 -0
  156. package/build/tools/ota-monitor.d.ts.map +1 -0
  157. package/build/tools/ota-monitor.js +211 -0
  158. package/build/tools/ota-monitor.js.map +1 -0
  159. package/build/tools/packages.d.ts +6 -0
  160. package/build/tools/packages.d.ts.map +1 -0
  161. package/build/tools/packages.js +237 -0
  162. package/build/tools/packages.js.map +1 -0
  163. package/build/tools/plugins.d.ts +22 -0
  164. package/build/tools/plugins.d.ts.map +1 -0
  165. package/build/tools/plugins.js +118 -0
  166. package/build/tools/plugins.js.map +1 -0
  167. package/build/tools/prompts.d.ts +9 -0
  168. package/build/tools/prompts.d.ts.map +1 -0
  169. package/build/tools/prompts.js +94 -0
  170. package/build/tools/prompts.js.map +1 -0
  171. package/build/tools/qemu.d.ts +18 -0
  172. package/build/tools/qemu.d.ts.map +1 -0
  173. package/build/tools/qemu.js +791 -0
  174. package/build/tools/qemu.js.map +1 -0
  175. package/build/tools/registry.d.ts +13 -0
  176. package/build/tools/registry.d.ts.map +1 -0
  177. package/build/tools/registry.js +221 -0
  178. package/build/tools/registry.js.map +1 -0
  179. package/build/tools/regression.d.ts +10 -0
  180. package/build/tools/regression.d.ts.map +1 -0
  181. package/build/tools/regression.js +215 -0
  182. package/build/tools/regression.js.map +1 -0
  183. package/build/tools/resources.d.ts +10 -0
  184. package/build/tools/resources.d.ts.map +1 -0
  185. package/build/tools/resources.js +77 -0
  186. package/build/tools/resources.js.map +1 -0
  187. package/build/tools/ril-intercept.d.ts +24 -0
  188. package/build/tools/ril-intercept.d.ts.map +1 -0
  189. package/build/tools/ril-intercept.js +273 -0
  190. package/build/tools/ril-intercept.js.map +1 -0
  191. package/build/tools/screen-record.d.ts +9 -0
  192. package/build/tools/screen-record.d.ts.map +1 -0
  193. package/build/tools/screen-record.js +95 -0
  194. package/build/tools/screen-record.js.map +1 -0
  195. package/build/tools/screenshot-diff.d.ts +13 -0
  196. package/build/tools/screenshot-diff.d.ts.map +1 -0
  197. package/build/tools/screenshot-diff.js +370 -0
  198. package/build/tools/screenshot-diff.js.map +1 -0
  199. package/build/tools/selinux-audit.d.ts +17 -0
  200. package/build/tools/selinux-audit.d.ts.map +1 -0
  201. package/build/tools/selinux-audit.js +301 -0
  202. package/build/tools/selinux-audit.js.map +1 -0
  203. package/build/tools/shell.d.ts +6 -0
  204. package/build/tools/shell.d.ts.map +1 -0
  205. package/build/tools/shell.js +63 -0
  206. package/build/tools/shell.js.map +1 -0
  207. package/build/tools/snapshot.d.ts +9 -0
  208. package/build/tools/snapshot.d.ts.map +1 -0
  209. package/build/tools/snapshot.js +192 -0
  210. package/build/tools/snapshot.js.map +1 -0
  211. package/build/tools/split-apk.d.ts +13 -0
  212. package/build/tools/split-apk.d.ts.map +1 -0
  213. package/build/tools/split-apk.js +229 -0
  214. package/build/tools/split-apk.js.map +1 -0
  215. package/build/tools/test-gen.d.ts +14 -0
  216. package/build/tools/test-gen.d.ts.map +1 -0
  217. package/build/tools/test-gen.js +252 -0
  218. package/build/tools/test-gen.js.map +1 -0
  219. package/build/tools/testing.d.ts +9 -0
  220. package/build/tools/testing.d.ts.map +1 -0
  221. package/build/tools/testing.js +144 -0
  222. package/build/tools/testing.js.map +1 -0
  223. package/build/tools/thermal-power.d.ts +19 -0
  224. package/build/tools/thermal-power.d.ts.map +1 -0
  225. package/build/tools/thermal-power.js +330 -0
  226. package/build/tools/thermal-power.js.map +1 -0
  227. package/build/tools/ui.d.ts +6 -0
  228. package/build/tools/ui.d.ts.map +1 -0
  229. package/build/tools/ui.js +266 -0
  230. package/build/tools/ui.js.map +1 -0
  231. package/build/tools/wireless.d.ts +7 -0
  232. package/build/tools/wireless.d.ts.map +1 -0
  233. package/build/tools/wireless.js +78 -0
  234. package/build/tools/wireless.js.map +1 -0
  235. package/build/tools/workflow-market.d.ts +17 -0
  236. package/build/tools/workflow-market.d.ts.map +1 -0
  237. package/build/tools/workflow-market.js +237 -0
  238. package/build/tools/workflow-market.js.map +1 -0
  239. package/build/tools/workflow.d.ts +32 -0
  240. package/build/tools/workflow.d.ts.map +1 -0
  241. package/build/tools/workflow.js +374 -0
  242. package/build/tools/workflow.js.map +1 -0
  243. package/build/ws-transport.d.ts +30 -0
  244. package/build/ws-transport.d.ts.map +1 -0
  245. package/build/ws-transport.js +133 -0
  246. package/build/ws-transport.js.map +1 -0
  247. package/package.json +37 -0
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Device Profile Library — Device-specific knowledge base.
3
+ *
4
+ * Maintains a library of device profiles containing known modem device nodes,
5
+ * chipset quirks, supported AT command sets, root method requirements, and
6
+ * hardware capabilities. Improves auto-detection accuracy across the tool suite.
7
+ *
8
+ * Profiles can be auto-detected from connected devices and saved for reuse,
9
+ * or loaded from the built-in library of known devices. Community contributions
10
+ * can extend the library through saved profiles.
11
+ *
12
+ * Profiles are stored as JSON in {tempDir}/device-profiles/.
13
+ */
14
+ import { z } from "zod";
15
+ import { join } from "path";
16
+ import { mkdirSync, writeFileSync, readFileSync, existsSync, readdirSync } from "fs";
17
+ import { OutputProcessor } from "../middleware/output-processor.js";
18
+ import { MODEM_PATHS, detectChipsetFamily, detectSimConfig } from "../middleware/chipset.js";
19
+ /** Built-in profiles for well-known devices. */
20
+ const BUILTIN_PROFILES = [
21
+ {
22
+ name: "Pixel 6a (bluejay)",
23
+ model: "Pixel 6a",
24
+ device: "bluejay",
25
+ hardware: "bluejay",
26
+ chipname: "s5e8535",
27
+ chipsetFamily: "shannon",
28
+ modemDeviceNodes: ["/dev/umts_router0", "/dev/umts_router1", "/dev/umts_atc0"],
29
+ supports5G: false,
30
+ quirks: [
31
+ "Shannon/Exynos Modem 5123 baseband",
32
+ "AT commands via /dev/umts_router0 (root required)",
33
+ "Radio logcat uses RILJ/RILC tags",
34
+ ],
35
+ },
36
+ {
37
+ name: "Pixel 7 (panther)",
38
+ model: "Pixel 7",
39
+ device: "panther",
40
+ chipname: "s5e9925",
41
+ chipsetFamily: "shannon",
42
+ modemDeviceNodes: ["/dev/umts_router0", "/dev/umts_router1"],
43
+ supports5G: true,
44
+ quirks: [
45
+ "Shannon/Exynos Modem 5300 baseband",
46
+ "Supports NR NSA and SA",
47
+ ],
48
+ },
49
+ {
50
+ name: "Pixel 8 (shiba)",
51
+ model: "Pixel 8",
52
+ device: "shiba",
53
+ chipname: "s5e9945",
54
+ chipsetFamily: "shannon",
55
+ modemDeviceNodes: ["/dev/umts_router0", "/dev/umts_router1"],
56
+ supports5G: true,
57
+ quirks: [
58
+ "Shannon/Exynos Modem 5400 baseband",
59
+ "Tensor G3 SoC with integrated modem",
60
+ ],
61
+ },
62
+ {
63
+ name: "Samsung Galaxy S24 (e2s)",
64
+ model: "SM-S921",
65
+ device: "e2s",
66
+ chipsetFamily: "qualcomm",
67
+ modemDeviceNodes: ["/dev/smd11", "/dev/smd7"],
68
+ supports5G: true,
69
+ quirks: [
70
+ "Snapdragon 8 Gen 3 (US/KR) or Exynos 2400 (global)",
71
+ "Modem paths vary by SoC variant",
72
+ "Qualcomm variant: /dev/smd11, Exynos variant: /dev/umts_router0",
73
+ ],
74
+ },
75
+ {
76
+ name: "OnePlus (generic Qualcomm)",
77
+ model: "OnePlus",
78
+ chipsetFamily: "qualcomm",
79
+ modemDeviceNodes: ["/dev/smd11", "/dev/smd7", "/dev/smd0"],
80
+ supports5G: true,
81
+ quirks: [
82
+ "Most OnePlus devices use Qualcomm Snapdragon",
83
+ "AT command access typically via /dev/smd11",
84
+ ],
85
+ },
86
+ ];
87
+ function getProfileDir(tempDir) {
88
+ return join(tempDir, "device-profiles");
89
+ }
90
+ export function registerDeviceProfileTools(ctx) {
91
+ ctx.server.tool("adb_profile_detect", "Auto-detect and build a device profile from the connected device. Captures hardware identification, chipset family, modem info, root status, and matches against the built-in profile library for known quirks.", {
92
+ save: z.boolean().optional().default(false).describe("Automatically save the detected profile"),
93
+ device: z.string().optional().describe("Device serial"),
94
+ }, async ({ save, device }) => {
95
+ try {
96
+ const resolved = await ctx.deviceManager.resolveDevice(device);
97
+ const serial = resolved.serial;
98
+ const props = await ctx.deviceManager.getDeviceProps(serial);
99
+ const family = detectChipsetFamily(props);
100
+ // Check root
101
+ let rootAvailable = false;
102
+ try {
103
+ const rootResult = await ctx.bridge.shell("su -c id", {
104
+ device: serial, timeout: 5000, ignoreExitCode: true,
105
+ });
106
+ rootAvailable = rootResult.stdout.includes("uid=0");
107
+ }
108
+ catch { /* no root */ }
109
+ // Check 5G support
110
+ const supports5G = (props["gsm.network.type"] ?? "").includes("NR") ||
111
+ (props["ro.telephony.default_network"] ?? "").includes("26") ||
112
+ (props["ro.telephony.default_network"] ?? "").includes("33");
113
+ // Check A/B
114
+ const abPartition = (props["ro.boot.slot_suffix"] ?? "").length > 0;
115
+ // Check dual SIM (shared logic in chipset.ts)
116
+ const { dualSim, simSlots } = detectSimConfig(props);
117
+ // Probe modem device nodes using shared MODEM_PATHS
118
+ const paths = MODEM_PATHS[family] ?? MODEM_PATHS.generic;
119
+ let existingNodes = [];
120
+ let respondingPort = null;
121
+ if (rootAvailable) {
122
+ const existCmd = paths.map((p) => `test -e ${p} && echo "EXISTS:${p}"`).join("; ");
123
+ const existResult = await ctx.bridge.rootShell(existCmd, {
124
+ device: serial, timeout: 10000, ignoreExitCode: true,
125
+ });
126
+ existingNodes = existResult.stdout.split("\n")
127
+ .filter((l) => l.startsWith("EXISTS:"))
128
+ .map((l) => l.replace("EXISTS:", "").trim());
129
+ }
130
+ const profile = {
131
+ name: `${props["ro.product.model"] ?? "Unknown"} (${props["ro.product.device"] ?? serial})`,
132
+ timestamp: new Date().toISOString(),
133
+ source: "auto-detected",
134
+ model: props["ro.product.model"] ?? "unknown",
135
+ manufacturer: props["ro.product.manufacturer"] ?? "unknown",
136
+ device: props["ro.product.device"] ?? "unknown",
137
+ hardware: props["ro.hardware"] ?? "unknown",
138
+ boardPlatform: props["ro.board.platform"] ?? "unknown",
139
+ chipname: props["ro.hardware.chipname"] ?? "unknown",
140
+ socModel: props["ro.soc.model"] ?? "unknown",
141
+ chipsetFamily: family,
142
+ basebandVersion: props["gsm.version.baseband"] ?? "unknown",
143
+ rilImplementation: props["gsm.version.ril-impl"] ?? "unknown",
144
+ modemDeviceNodes: existingNodes,
145
+ respondingAtPort: respondingPort,
146
+ rootAvailable,
147
+ androidVersion: props["ro.build.version.release"] ?? "unknown",
148
+ sdkLevel: parseInt(props["ro.build.version.sdk"] ?? "0", 10) || 0,
149
+ abPartition,
150
+ supports5G,
151
+ dualSim,
152
+ simSlots,
153
+ quirks: [],
154
+ };
155
+ // Match against built-in profiles
156
+ const deviceCodename = profile.device.toLowerCase();
157
+ const builtinMatch = BUILTIN_PROFILES.find((bp) => bp.device?.toLowerCase() === deviceCodename ||
158
+ bp.model?.toLowerCase() === profile.model.toLowerCase());
159
+ if (builtinMatch) {
160
+ profile.quirks = builtinMatch.quirks ?? [];
161
+ // Supplement modem paths from built-in if we couldn't probe (no root)
162
+ if (existingNodes.length === 0 && builtinMatch.modemDeviceNodes) {
163
+ profile.modemDeviceNodes = builtinMatch.modemDeviceNodes;
164
+ }
165
+ }
166
+ // Save if requested
167
+ if (save) {
168
+ const dir = getProfileDir(ctx.config.tempDir);
169
+ if (!existsSync(dir))
170
+ mkdirSync(dir, { recursive: true });
171
+ const safeName = profile.device.replace(/[^a-zA-Z0-9_-]/g, "_");
172
+ const filePath = join(dir, `${safeName}.json`);
173
+ writeFileSync(filePath, JSON.stringify(profile, null, 2));
174
+ profile.quirks.push(`(saved to ${filePath})`);
175
+ }
176
+ // Format output
177
+ const sections = [];
178
+ sections.push(`=== Device Profile ===`);
179
+ sections.push(`Name: ${profile.name}`);
180
+ sections.push(`Manufacturer: ${profile.manufacturer}`);
181
+ sections.push(`Chipset: ${profile.chipname} (${profile.chipsetFamily})`);
182
+ sections.push(`Platform: ${profile.boardPlatform}`);
183
+ sections.push(`SoC: ${profile.socModel}`);
184
+ sections.push(`Android: ${profile.androidVersion} (SDK ${profile.sdkLevel})`);
185
+ sections.push(`Baseband: ${profile.basebandVersion}`);
186
+ sections.push(`RIL: ${profile.rilImplementation}`);
187
+ sections.push(`Root: ${profile.rootAvailable ? "available" : "not available"}`);
188
+ sections.push(`5G: ${profile.supports5G ? "supported" : "not detected"}`);
189
+ sections.push(`Dual SIM: ${profile.dualSim ? `yes (${profile.simSlots} slots)` : "no"}`);
190
+ sections.push(`A/B partition: ${profile.abPartition ? "yes" : "no"}`);
191
+ if (profile.modemDeviceNodes.length > 0) {
192
+ sections.push(`\nModem device nodes: ${profile.modemDeviceNodes.join(", ")}`);
193
+ }
194
+ else {
195
+ sections.push(`\nModem device nodes: none found${rootAvailable ? "" : " (root required to probe)"}`);
196
+ }
197
+ if (builtinMatch) {
198
+ sections.push(`\nMatched built-in profile: ${builtinMatch.name}`);
199
+ }
200
+ if (profile.quirks.length > 0) {
201
+ sections.push(`\nKnown quirks/notes:`);
202
+ for (const q of profile.quirks)
203
+ sections.push(` - ${q}`);
204
+ }
205
+ return { content: [{ type: "text", text: sections.join("\n") }] };
206
+ }
207
+ catch (error) {
208
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
209
+ }
210
+ });
211
+ ctx.server.tool("adb_profile_save", "Save a device profile to the profiles library. Use after adb_profile_detect to persist the profile, or create a manual profile with custom quirks and notes.", {
212
+ name: z.string().describe("Profile name (used as filename)"),
213
+ profile: z.string().describe("Profile JSON string (from adb_profile_detect output or manually composed)"),
214
+ }, async ({ name, profile }) => {
215
+ try {
216
+ let parsed;
217
+ try {
218
+ parsed = JSON.parse(profile);
219
+ }
220
+ catch (err) {
221
+ return { content: [{ type: "text", text: `Invalid JSON: ${err instanceof Error ? err.message : err}` }], isError: true };
222
+ }
223
+ const dir = getProfileDir(ctx.config.tempDir);
224
+ if (!existsSync(dir))
225
+ mkdirSync(dir, { recursive: true });
226
+ const safeName = name.replace(/[^a-zA-Z0-9_-]/g, "_");
227
+ const filePath = join(dir, `${safeName}.json`);
228
+ writeFileSync(filePath, JSON.stringify(parsed, null, 2));
229
+ return { content: [{ type: "text", text: `Profile saved: ${filePath}` }] };
230
+ }
231
+ catch (error) {
232
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
233
+ }
234
+ });
235
+ ctx.server.tool("adb_profile_list", "List all device profiles: built-in library entries and user-saved profiles.", {}, async () => {
236
+ try {
237
+ const sections = [];
238
+ // Built-in profiles
239
+ sections.push(`=== Built-in Profiles (${BUILTIN_PROFILES.length}) ===\n`);
240
+ for (const bp of BUILTIN_PROFILES) {
241
+ const quirksPreview = bp.quirks?.[0] ?? "";
242
+ sections.push(`${bp.name ?? "Unknown"} [${bp.chipsetFamily}]${quirksPreview ? " — " + quirksPreview : ""}`);
243
+ }
244
+ // Saved profiles
245
+ const dir = getProfileDir(ctx.config.tempDir);
246
+ if (existsSync(dir)) {
247
+ const files = readdirSync(dir).filter((f) => f.endsWith(".json")).sort();
248
+ if (files.length > 0) {
249
+ sections.push(`\n=== Saved Profiles (${files.length}) ===\n`);
250
+ for (const file of files) {
251
+ try {
252
+ const p = JSON.parse(readFileSync(join(dir, file), "utf-8"));
253
+ sections.push(`${p.name} [${p.chipsetFamily}] — ${p.source}, ${p.timestamp.substring(0, 10)}`);
254
+ }
255
+ catch {
256
+ sections.push(`${file} — (corrupt JSON)`);
257
+ }
258
+ }
259
+ sections.push(`\nProfile directory: ${dir}`);
260
+ }
261
+ }
262
+ else {
263
+ sections.push("\nNo saved profiles yet. Use adb_profile_detect with save=true.");
264
+ }
265
+ return { content: [{ type: "text", text: sections.join("\n") }] };
266
+ }
267
+ catch (error) {
268
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
269
+ }
270
+ });
271
+ }
272
+ //# sourceMappingURL=device-profiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-profiles.js","sourceRoot":"","sources":["../../src/tools/device-profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAqC7F,gDAAgD;AAChD,MAAM,gBAAgB,GAA6B;IACjD;QACE,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;QACnB,aAAa,EA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AAC,IAAI,KAAK,CAAC,CAAC,aAAa,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;wBACjG,CAAC;wBAAC,MAAM,CAAC;4BACP,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;wBAC5C,CAAC;oBACH,CAAC;oBACD,QAAQ,CAAC,IAAI,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAC;YACnF,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACpE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAClG,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Device Tools — Device discovery, status, and properties.
3
+ */
4
+ import { ToolContext } from "../tool-context.js";
5
+ export declare function registerDeviceTools(ctx: ToolContext): void;
6
+ //# sourceMappingURL=device.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/tools/device.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA4E1D"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Device Tools — Device discovery, status, and properties.
3
+ */
4
+ import { z } from "zod";
5
+ import { OutputProcessor } from "../middleware/output-processor.js";
6
+ import { validateShellArg } from "../middleware/sanitize.js";
7
+ export function registerDeviceTools(ctx) {
8
+ ctx.server.tool("adb_devices", "List all connected Android devices with their state, model, and product info", {}, async () => {
9
+ try {
10
+ const devices = await ctx.deviceManager.listDevices();
11
+ if (devices.length === 0) {
12
+ return { content: [{ type: "text", text: "No devices connected." }] };
13
+ }
14
+ const output = devices
15
+ .map((d) => {
16
+ const parts = [`${d.serial} (${d.state})`];
17
+ if (d.model)
18
+ parts.push(`model: ${d.model}`);
19
+ if (d.product)
20
+ parts.push(`product: ${d.product}`);
21
+ return parts.join(" | ");
22
+ })
23
+ .join("\n");
24
+ return { content: [{ type: "text", text: output }] };
25
+ }
26
+ catch (error) {
27
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
28
+ }
29
+ });
30
+ ctx.server.tool("adb_device_info", "Get detailed properties for a connected device (model, OS version, build, etc.)", { device: z.string().optional().describe("Device serial (auto-selects if only one connected)") }, async ({ device }) => {
31
+ try {
32
+ const props = await ctx.deviceManager.getDeviceProps(device);
33
+ const keyProps = [
34
+ `Model: ${props["ro.product.model"] ?? "unknown"}`,
35
+ `Manufacturer: ${props["ro.product.manufacturer"] ?? "unknown"}`,
36
+ `Android Version: ${props["ro.build.version.release"] ?? "unknown"}`,
37
+ `SDK Level: ${props["ro.build.version.sdk"] ?? "unknown"}`,
38
+ `Build: ${props["ro.build.display.id"] ?? "unknown"}`,
39
+ `Security Patch: ${props["ro.build.version.security_patch"] ?? "unknown"}`,
40
+ `Serial: ${props["ro.serialno"] ?? "unknown"}`,
41
+ `ABI: ${props["ro.product.cpu.abi"] ?? "unknown"}`,
42
+ `Fingerprint: ${props["ro.build.fingerprint"] ?? "unknown"}`,
43
+ ];
44
+ return { content: [{ type: "text", text: keyProps.join("\n") }] };
45
+ }
46
+ catch (error) {
47
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
48
+ }
49
+ });
50
+ ctx.server.tool("adb_getprop", "Get a specific Android system property, or all properties if no key given", {
51
+ key: z.string().optional().describe("Property key (e.g., 'ro.build.version.sdk'). Omit for all."),
52
+ device: z.string().optional().describe("Device serial"),
53
+ }, async ({ key, device }) => {
54
+ try {
55
+ const resolved = await ctx.deviceManager.resolveDevice(device);
56
+ if (key) {
57
+ const keyErr = validateShellArg(key, "key");
58
+ if (keyErr)
59
+ return { content: [{ type: "text", text: keyErr }], isError: true };
60
+ const result = await ctx.bridge.shell(`getprop ${key}`, { device: resolved.serial });
61
+ const value = result.stdout.trim();
62
+ return { content: [{ type: "text", text: value || `(empty — property '${key}' may not exist)` }] };
63
+ }
64
+ const result = await ctx.bridge.shell("getprop", { device: resolved.serial });
65
+ return { content: [{ type: "text", text: OutputProcessor.process(result.stdout) }] };
66
+ }
67
+ catch (error) {
68
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
69
+ }
70
+ });
71
+ }
72
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/tools/device.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,UAAU,mBAAmB,CAAC,GAAgB;IAElD,GAAG,CAAC,MAAM,CAAC,IAAI,CACb,aAAa,EACb,8EAA8E,EAC9E,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YACtD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IA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AE,CAAC;QAClG,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Diagnostics Tools — dumpsys, battery, network, telephony state.
3
+ * Useful for device inspection, performance profiling, and radio diagnostics.
4
+ */
5
+ import { ToolContext } from "../tool-context.js";
6
+ export declare function registerDiagnosticTools(ctx: ToolContext): void;
7
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/tools/diagnostics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAmL9D"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Diagnostics Tools — dumpsys, battery, network, telephony state.
3
+ * Useful for device inspection, performance profiling, and radio diagnostics.
4
+ */
5
+ import { z } from "zod";
6
+ import { join } from "path";
7
+ import { OutputProcessor } from "../middleware/output-processor.js";
8
+ import { validateShellArg } from "../middleware/sanitize.js";
9
+ export function registerDiagnosticTools(ctx) {
10
+ ctx.server.tool("adb_dumpsys", "Run dumpsys for a specific service. Use 'list' as the service to see all available services.", {
11
+ service: z.string().describe("Service name (e.g., 'battery', 'telephony.registry', 'activity') or 'list'"),
12
+ args: z.string().optional().describe("Additional arguments passed to dumpsys"),
13
+ device: z.string().optional().describe("Device serial"),
14
+ }, async ({ service, args, device }) => {
15
+ try {
16
+ const svcErr = validateShellArg(service, "service");
17
+ if (svcErr)
18
+ return { content: [{ type: "text", text: svcErr }], isError: true };
19
+ if (args) {
20
+ const argsErr = validateShellArg(args, "args");
21
+ if (argsErr)
22
+ return { content: [{ type: "text", text: argsErr }], isError: true };
23
+ }
24
+ const resolved = await ctx.deviceManager.resolveDevice(device);
25
+ const cmd = service === "list"
26
+ ? "dumpsys -l"
27
+ : `dumpsys ${service}${args ? ` ${args}` : ""}`;
28
+ const result = await ctx.bridge.shell(cmd, { device: resolved.serial, timeout: 30000 });
29
+ return { content: [{ type: "text", text: OutputProcessor.process(result.stdout) }] };
30
+ }
31
+ catch (error) {
32
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
33
+ }
34
+ });
35
+ ctx.server.tool("adb_telephony", "Get telephony state including cell info, signal strength, and network registration.", { device: z.string().optional().describe("Device serial") }, async ({ device }) => {
36
+ try {
37
+ const resolved = await ctx.deviceManager.resolveDevice(device);
38
+ const [registry, cellInfo, signalStrength] = await Promise.allSettled([
39
+ ctx.bridge.shell("dumpsys telephony.registry", { device: resolved.serial, timeout: 15000 }),
40
+ ctx.bridge.shell("dumpsys phone | grep -A 20 'mCellInfo'", { device: resolved.serial, timeout: 10000, ignoreExitCode: true }),
41
+ ctx.bridge.shell("dumpsys phone | grep -A 5 'mSignalStrength'", { device: resolved.serial, timeout: 10000, ignoreExitCode: true }),
42
+ ]);
43
+ let output = "=== Telephony Registry ===\n";
44
+ output += OutputProcessor.settledValue(registry, 20000, "Error");
45
+ output += "\n\n=== Cell Info ===\n";
46
+ output += OutputProcessor.settledValue(cellInfo, undefined, "Could not retrieve cell info");
47
+ output += "\n\n=== Signal Strength ===\n";
48
+ output += OutputProcessor.settledValue(signalStrength, undefined, "Could not retrieve signal strength");
49
+ return { content: [{ type: "text", text: output }] };
50
+ }
51
+ catch (error) {
52
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
53
+ }
54
+ });
55
+ ctx.server.tool("adb_battery", "Get battery status, level, temperature, and charging info", { device: z.string().optional().describe("Device serial") }, async ({ device }) => {
56
+ try {
57
+ const resolved = await ctx.deviceManager.resolveDevice(device);
58
+ const result = await ctx.bridge.shell("dumpsys battery", { device: resolved.serial });
59
+ return { content: [{ type: "text", text: result.stdout.trim() }] };
60
+ }
61
+ catch (error) {
62
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
63
+ }
64
+ });
65
+ ctx.server.tool("adb_network", "Get network connectivity info including WiFi, cellular, and active connections", { device: z.string().optional().describe("Device serial") }, async ({ device }) => {
66
+ try {
67
+ const resolved = await ctx.deviceManager.resolveDevice(device);
68
+ const [connectivity, wifi, netstat] = await Promise.allSettled([
69
+ ctx.bridge.shell("dumpsys connectivity | head -100", { device: resolved.serial, timeout: 10000, ignoreExitCode: true }),
70
+ ctx.bridge.shell("dumpsys wifi | grep -A 30 'Wi-Fi is'", { device: resolved.serial, timeout: 10000, ignoreExitCode: true }),
71
+ ctx.bridge.shell("ip addr show", { device: resolved.serial, timeout: 5000, ignoreExitCode: true }),
72
+ ]);
73
+ let output = "=== Connectivity ===\n";
74
+ output += OutputProcessor.settledValue(connectivity);
75
+ output += "\n\n=== WiFi ===\n";
76
+ output += OutputProcessor.settledValue(wifi);
77
+ output += "\n\n=== IP Addresses ===\n";
78
+ output += OutputProcessor.settledValue(netstat);
79
+ return { content: [{ type: "text", text: OutputProcessor.process(output) }] };
80
+ }
81
+ catch (error) {
82
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
83
+ }
84
+ });
85
+ ctx.server.tool("adb_top", "Get current CPU and memory usage snapshot", {
86
+ count: z.number().min(1).max(100).optional().default(1).describe("Number of iterations (1-100, 1 = snapshot)"),
87
+ device: z.string().optional().describe("Device serial"),
88
+ }, async ({ count, device }) => {
89
+ try {
90
+ const resolved = await ctx.deviceManager.resolveDevice(device);
91
+ const result = await ctx.bridge.shell(`top -b -n ${count} -d 1`, {
92
+ device: resolved.serial,
93
+ timeout: (count * 2 + 5) * 1000,
94
+ });
95
+ return { content: [{ type: "text", text: OutputProcessor.process(result.stdout, 30000) }] };
96
+ }
97
+ catch (error) {
98
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
99
+ }
100
+ });
101
+ ctx.server.tool("adb_perf_snapshot", "Capture a performance snapshot for a package: memory usage, frame stats, and CPU info in one call.", {
102
+ packageName: z.string().describe("Package name to profile (e.g., 'com.example.app')"),
103
+ device: z.string().optional().describe("Device serial"),
104
+ }, async ({ packageName, device }) => {
105
+ try {
106
+ const pkgErr = validateShellArg(packageName, "packageName");
107
+ if (pkgErr)
108
+ return { content: [{ type: "text", text: pkgErr }], isError: true };
109
+ const resolved = await ctx.deviceManager.resolveDevice(device);
110
+ const serial = resolved.serial;
111
+ const [meminfo, gfxinfo, cpuinfo] = await Promise.allSettled([
112
+ ctx.bridge.shell(`dumpsys meminfo ${packageName}`, { device: serial, timeout: 15000 }),
113
+ ctx.bridge.shell(`dumpsys gfxinfo ${packageName}`, { device: serial, timeout: 10000 }),
114
+ ctx.bridge.shell("dumpsys cpuinfo", { device: serial, timeout: 10000 }),
115
+ ]);
116
+ let output = `=== Memory (${packageName}) ===\n`;
117
+ output += OutputProcessor.settledValue(meminfo, 15000, "Could not retrieve meminfo");
118
+ output += `\n\n=== Frame Stats (${packageName}) ===\n`;
119
+ output += OutputProcessor.settledValue(gfxinfo, 10000, "Could not retrieve gfxinfo");
120
+ output += "\n\n=== CPU Usage (system) ===\n";
121
+ output += OutputProcessor.settledValue(cpuinfo, 10000, "Could not retrieve cpuinfo");
122
+ return { content: [{ type: "text", text: OutputProcessor.process(output) }] };
123
+ }
124
+ catch (error) {
125
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
126
+ }
127
+ });
128
+ ctx.server.tool("adb_bugreport", "Capture a full bug report zip (device state, logs, dumpsys, system info). Returns the local file path.", {
129
+ device: z.string().optional().describe("Device serial"),
130
+ }, async ({ device }) => {
131
+ try {
132
+ const resolved = await ctx.deviceManager.resolveDevice(device);
133
+ const serial = resolved.serial;
134
+ const filename = `bugreport_${serial}_${Date.now()}.zip`;
135
+ const localPath = join(ctx.config.tempDir, filename);
136
+ const result = await ctx.bridge.exec(["bugreport", localPath], {
137
+ device: serial,
138
+ timeout: 300000, // 5 minutes — bugreports can be slow
139
+ });
140
+ const output = result.stdout.trim();
141
+ return {
142
+ content: [{
143
+ type: "text",
144
+ text: `Bug report captured: ${localPath}${output ? "\n" + output : ""}`,
145
+ }],
146
+ };
147
+ }
148
+ catch (error) {
149
+ return { content: [{ type: "text", text: OutputProcessor.formatError(error) }], isError: true };
150
+ }
151
+ });
152
+ }
153
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/tools/diagnostics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,UAAU,uBAAuB,CAAC,GAAgB;IAEtD,GAAG,CAAC,MAAM,CAAC,IAAI,CACb,aAAa,EACb,8FAA8F,EAC9F;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4EAA4E,CAAC;QAC1G,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;QAC9E,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;KACxD,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QAClC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACpD,IAAI,MAAM;gBAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAChF,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,OAAO,GAAG,g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AC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE;gBAC7D,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,MAAM,EAAE,qCAAqC;aACvD,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,wBAAwB,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;qBACxE,CAAC;aACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAClG,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Emulator Management Tools — AVD lifecycle management.
3
+ *
4
+ * Manages Android Virtual Devices: list available AVDs, start/stop emulators.
5
+ * Requires the Android SDK `emulator` binary to be on PATH or in the SDK directory.
6
+ */
7
+ import { ToolContext } from "../tool-context.js";
8
+ export declare function registerEmulatorTools(ctx: ToolContext): void;
9
+ //# sourceMappingURL=emulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.d.ts","sourceRoot":"","sources":["../../src/tools/emulator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoCjD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA2M5D"}