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,123 @@
1
+ /**
2
+ * Chipset Detection — Shared chipset family identification, modem path mapping,
3
+ * and SIM configuration detection.
4
+ *
5
+ * Used by at-commands.ts, baseband.ts, and device-profiles.ts to avoid
6
+ * duplicated detection logic. Single source of truth for chipset family
7
+ * classification, known modem device node paths, and dual SIM detection.
8
+ */
9
+ /**
10
+ * Known modem device node paths by chipset family.
11
+ * Ordered by likelihood — detection tries each path until one responds.
12
+ */
13
+ export const MODEM_PATHS = {
14
+ // Samsung Shannon/Exynos (Pixel 6, 6a, 7, 7a, 8, Samsung Galaxy S series)
15
+ shannon: [
16
+ "/dev/umts_router0",
17
+ "/dev/umts_router1",
18
+ "/dev/umts_atc0",
19
+ ],
20
+ // Qualcomm (most Android devices)
21
+ qualcomm: [
22
+ "/dev/smd11",
23
+ "/dev/smd7",
24
+ "/dev/smd0",
25
+ "/dev/at_channel0",
26
+ "/dev/at_mdm0",
27
+ ],
28
+ // MediaTek (many mid-range devices)
29
+ mediatek: [
30
+ "/dev/radio/atci-serv-fw",
31
+ "/dev/ccci_ioctl0",
32
+ "/dev/ttyC0",
33
+ "/dev/ttyC1",
34
+ ],
35
+ // Unisoc/Spreadtrum
36
+ unisoc: [
37
+ "/dev/stty_lte0",
38
+ "/dev/stty_nr0",
39
+ "/dev/stty_w0",
40
+ ],
41
+ // HiSilicon/Kirin (Huawei, Honor devices)
42
+ hisilicon: [
43
+ "/dev/appvcom0",
44
+ "/dev/appvcom9",
45
+ "/dev/acm_at",
46
+ ],
47
+ // Intel XMM (older iPhones via Android projects, some Samsung/Asus devices)
48
+ intel: [
49
+ "/dev/ttyIFX0",
50
+ "/dev/ttyACM0",
51
+ "/dev/ttyACM1",
52
+ ],
53
+ // Generic USB/serial modems
54
+ generic: [
55
+ "/dev/ttyUSB0",
56
+ "/dev/ttyUSB1",
57
+ "/dev/ttyUSB2",
58
+ "/dev/ttyACM0",
59
+ "/dev/ttyACM1",
60
+ ],
61
+ };
62
+ /**
63
+ * Detect the chipset family from device properties.
64
+ * Returns the family key for MODEM_PATHS lookup.
65
+ */
66
+ export function detectChipsetFamily(props) {
67
+ const chipname = (props["ro.hardware.chipname"] ?? "").toLowerCase();
68
+ const platform = (props["ro.board.platform"] ?? "").toLowerCase();
69
+ const hardware = (props["ro.hardware"] ?? "").toLowerCase();
70
+ const soc = (props["ro.soc.model"] ?? "").toLowerCase();
71
+ // Shannon/Exynos detection (includes Google Tensor SoCs which use Samsung Shannon modems)
72
+ if (chipname.includes("exynos") || chipname.includes("s5e") ||
73
+ soc.includes("exynos") || soc.includes("shannon") ||
74
+ hardware.includes("samsungexynos") || platform.includes("exynos") ||
75
+ platform.includes("gs101") || platform.includes("gs201") ||
76
+ platform.includes("zuma") || platform.includes("zumapro")) {
77
+ return "shannon";
78
+ }
79
+ // Qualcomm detection (includes platform codenames for recent SoCs)
80
+ if (platform.includes("msm") || platform.includes("sdm") || platform.includes("sm") ||
81
+ platform.includes("qcom") || chipname.includes("snapdragon") ||
82
+ hardware.includes("qcom") || platform.includes("lahaina") ||
83
+ platform.includes("taro") || platform.includes("kalama")) {
84
+ return "qualcomm";
85
+ }
86
+ // MediaTek detection
87
+ if (platform.includes("mt") || chipname.includes("mt") ||
88
+ hardware.includes("mt") || platform.includes("mediatek")) {
89
+ return "mediatek";
90
+ }
91
+ // Unisoc detection
92
+ if (platform.includes("sp") || platform.includes("ums") ||
93
+ chipname.includes("unisoc") || chipname.includes("spreadtrum")) {
94
+ return "unisoc";
95
+ }
96
+ // HiSilicon/Kirin detection (Huawei, Honor devices)
97
+ if (platform.includes("kirin") || chipname.includes("kirin") ||
98
+ platform.includes("hi3") || platform.includes("hi6") ||
99
+ chipname.includes("hisilicon") || hardware.includes("kirin") ||
100
+ soc.includes("kirin") || soc.includes("hisilicon")) {
101
+ return "hisilicon";
102
+ }
103
+ // Intel XMM detection (older modem platforms)
104
+ if (chipname.includes("xmm") || chipname.includes("intel") ||
105
+ platform.includes("intel") || soc.includes("xmm")) {
106
+ return "intel";
107
+ }
108
+ return "generic";
109
+ }
110
+ /** Maximum SIM slots to prevent resource exhaustion from corrupted properties. */
111
+ const MAX_SIM_SLOTS = 4;
112
+ /**
113
+ * Detect SIM configuration from device properties.
114
+ * Returns dual SIM status, slot count, and multisim mode string.
115
+ */
116
+ export function detectSimConfig(props) {
117
+ const activeModems = parseInt(props["telephony.active_modems.max_count"] ?? "1", 10) || 1;
118
+ const multisimMode = (props["persist.radio.multisim.config"] ?? "").toLowerCase();
119
+ const dualSim = activeModems >= 2 || multisimMode === "dsds" || multisimMode === "dsda" || multisimMode === "tsts";
120
+ const simSlots = dualSim ? Math.min(Math.max(activeModems, 2), MAX_SIM_SLOTS) : 1;
121
+ return { dualSim, simSlots, multisimMode };
122
+ }
123
+ //# sourceMappingURL=chipset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chipset.js","sourceRoot":"","sources":["../../src/middleware/chipset.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAA6B;IACnD,0EAA0E;IAC1E,OAAO,EAAE;QACP,mBAAmB;QACnB,mBAAmB;QACnB,gBAAgB;KACjB;IACD,kCAAkC;IAClC,QAAQ,EAAE;QACR,YAAY;QACZ,WAAW;QACX,WAAW;QACX,kBAAkB;QAClB,cAAc;KACf;IACD,oCAAoC;IACpC,QAAQ,EAAE;QACR,yBAAyB;QACzB,kBAAkB;QAClB,YAAY;QACZ,YAAY;KACb;IACD,oBAAoB;IACpB,MAAM,EAAE;QACN,gBAAgB;QAChB,eAAe;QACf,cAAc;KACf;IACD,0CAA0C;IAC1C,SAAS,EAAE;QACT,eAAe;QACf,eAAe;QACf,aAAa;KACd;IACD,4EAA4E;IAC5E,KAAK,EAAE;QACL,cAAc;QACd,cAAc;QACd,cAAc;KACf;IACD,4BAA4B;IAC5B,OAAO,EAAE;QACP,cAAc;QACd,cAAc;QACd,cAAc;QACd,cAAc;QACd,cAAc;KACf;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA6B;IAC/D,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACrE,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAA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,CAAC;AAExB;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAA6B;IAC3D,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,mCAAmC,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1F,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAClF,MAAM,OAAO,GAAG,YAAY,IAAI,CAAC,IAAI,YAAY,KAAK,MAAM,IAAI,YAAY,KAAK,MAAM,IAAI,YAAY,KAAK,MAAM,CAAC;IACnH,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAElF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Process Cleanup Registry — Centralized signal handler for child process cleanup.
3
+ *
4
+ * Multiple modules (logcat-watch, ril-intercept, mirroring) spawn long-running
5
+ * child processes that must be killed on server exit. Instead of each module
6
+ * independently registering SIGINT/SIGTERM/exit handlers (which creates
7
+ * ordering dependencies and redundant process.exit() calls), all modules
8
+ * register their cleanup functions here.
9
+ *
10
+ * One set of signal handlers runs all registered cleanups in order.
11
+ */
12
+ type CleanupFn = () => void;
13
+ /**
14
+ * Register a cleanup function that will be called on process exit/SIGINT/SIGTERM.
15
+ * Each module should register under a unique key. Re-registering the same key
16
+ * replaces the previous function.
17
+ */
18
+ export declare function registerCleanup(key: string, fn: CleanupFn): void;
19
+ /**
20
+ * Remove a cleanup function by key (e.g., if the module's sessions are all stopped).
21
+ */
22
+ export declare function unregisterCleanup(key: string): void;
23
+ export {};
24
+ //# sourceMappingURL=cleanup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/middleware/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,KAAK,SAAS,GAAG,MAAM,IAAI,CAAC;AA8B5B;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,IAAI,CAGhE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Process Cleanup Registry — Centralized signal handler for child process cleanup.
3
+ *
4
+ * Multiple modules (logcat-watch, ril-intercept, mirroring) spawn long-running
5
+ * child processes that must be killed on server exit. Instead of each module
6
+ * independently registering SIGINT/SIGTERM/exit handlers (which creates
7
+ * ordering dependencies and redundant process.exit() calls), all modules
8
+ * register their cleanup functions here.
9
+ *
10
+ * One set of signal handlers runs all registered cleanups in order.
11
+ */
12
+ const registry = new Map();
13
+ let registered = false;
14
+ function runAllCleanups() {
15
+ for (const [, fn] of registry) {
16
+ try {
17
+ fn();
18
+ }
19
+ catch {
20
+ // Cleanup must not throw during shutdown
21
+ }
22
+ }
23
+ }
24
+ function ensureHandlers() {
25
+ if (registered)
26
+ return;
27
+ registered = true;
28
+ process.on("exit", runAllCleanups);
29
+ process.on("SIGINT", () => {
30
+ runAllCleanups();
31
+ process.exit(0);
32
+ });
33
+ process.on("SIGTERM", () => {
34
+ runAllCleanups();
35
+ process.exit(0);
36
+ });
37
+ }
38
+ /**
39
+ * Register a cleanup function that will be called on process exit/SIGINT/SIGTERM.
40
+ * Each module should register under a unique key. Re-registering the same key
41
+ * replaces the previous function.
42
+ */
43
+ export function registerCleanup(key, fn) {
44
+ ensureHandlers();
45
+ registry.set(key, fn);
46
+ }
47
+ /**
48
+ * Remove a cleanup function by key (e.g., if the module's sessions are all stopped).
49
+ */
50
+ export function unregisterCleanup(key) {
51
+ registry.delete(key);
52
+ }
53
+ //# sourceMappingURL=cleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/middleware/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,QAAQ,GAA2B,IAAI,GAAG,EAAE,CAAC;AACnD,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,SAAS,cAAc;IACrB,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,EAAE,EAAE,CAAC;QACP,CAAC;QAAC,MAAM,CAAC;YACP,yCAAyC;QAC3C,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,cAAc;IACrB,IAAI,UAAU;QAAE,OAAO;IACvB,UAAU,GAAG,IAAI,CAAC;IAElB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,cAAc,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACzB,cAAc,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,EAAa;IACxD,cAAc,EAAE,CAAC;IACjB,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Fetch Utilities — Shared HTTP helpers with response size limits.
3
+ *
4
+ * Used by the plugin registry, workflow marketplace, and any module
5
+ * that fetches external resources. Enforces a maximum response body
6
+ * size to prevent memory exhaustion from oversized or malicious responses.
7
+ */
8
+ /**
9
+ * Fetch a URL and parse the response as JSON.
10
+ * Enforces a response size limit to prevent memory exhaustion.
11
+ */
12
+ export declare function fetchJson(url: string): Promise<unknown>;
13
+ /**
14
+ * Fetch a URL and return the response body as text.
15
+ * Enforces a response size limit via streaming to prevent memory exhaustion,
16
+ * even when the server omits the Content-Length header.
17
+ */
18
+ export declare function fetchText(url: string): Promise<string>;
19
+ //# sourceMappingURL=fetch-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-utils.d.ts","sourceRoot":"","sources":["../../src/middleware/fetch-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;GAGG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG7D;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2C5D"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Fetch Utilities — Shared HTTP helpers with response size limits.
3
+ *
4
+ * Used by the plugin registry, workflow marketplace, and any module
5
+ * that fetches external resources. Enforces a maximum response body
6
+ * size to prevent memory exhaustion from oversized or malicious responses.
7
+ */
8
+ /** Maximum response body size in bytes (5 MB). */
9
+ const MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
10
+ /**
11
+ * Fetch a URL and parse the response as JSON.
12
+ * Enforces a response size limit to prevent memory exhaustion.
13
+ */
14
+ export async function fetchJson(url) {
15
+ const text = await fetchText(url);
16
+ return JSON.parse(text);
17
+ }
18
+ /**
19
+ * Fetch a URL and return the response body as text.
20
+ * Enforces a response size limit via streaming to prevent memory exhaustion,
21
+ * even when the server omits the Content-Length header.
22
+ */
23
+ export async function fetchText(url) {
24
+ const response = await fetch(url);
25
+ if (!response.ok) {
26
+ throw new Error(`HTTP ${response.status}: ${response.statusText} — ${url}`);
27
+ }
28
+ // Fast-reject via Content-Length header if available
29
+ const contentLength = response.headers.get("content-length");
30
+ if (contentLength && parseInt(contentLength, 10) > MAX_RESPONSE_BYTES) {
31
+ throw new Error(`Response too large: ${contentLength} bytes (max ${MAX_RESPONSE_BYTES})`);
32
+ }
33
+ // Stream-read the body with incremental size checking.
34
+ // This prevents memory exhaustion even when Content-Length is absent.
35
+ if (response.body) {
36
+ const reader = response.body.getReader();
37
+ const chunks = [];
38
+ let totalBytes = 0;
39
+ try {
40
+ while (true) {
41
+ const { done, value } = await reader.read();
42
+ if (done)
43
+ break;
44
+ totalBytes += value.length;
45
+ if (totalBytes > MAX_RESPONSE_BYTES) {
46
+ reader.cancel();
47
+ throw new Error(`Response body too large: exceeded ${MAX_RESPONSE_BYTES} bytes (read aborted)`);
48
+ }
49
+ chunks.push(value);
50
+ }
51
+ }
52
+ finally {
53
+ reader.releaseLock();
54
+ }
55
+ return new TextDecoder().decode(Buffer.concat(chunks));
56
+ }
57
+ // Fallback for environments where response.body is null
58
+ const text = await response.text();
59
+ if (text.length > MAX_RESPONSE_BYTES) {
60
+ throw new Error(`Response body too large: ${text.length} characters (max ${MAX_RESPONSE_BYTES})`);
61
+ }
62
+ return text;
63
+ }
64
+ //# sourceMappingURL=fetch-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-utils.js","sourceRoot":"","sources":["../../src/middleware/fetch-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kDAAkD;AAClD,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IACzC,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC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gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,wDAAwD;IACxD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,IAAI,IAAI,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,MAAM,oBAAoB,kBAAkB,GAAG,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Logger — Simple stderr-based logger for MCP servers.
3
+ *
4
+ * IMPORTANT: MCP stdio servers MUST NOT write to stdout.
5
+ * All logging goes to stderr to avoid corrupting JSON-RPC messages.
6
+ */
7
+ export type LogLevel = "debug" | "info" | "warn" | "error";
8
+ export declare class Logger {
9
+ private level;
10
+ constructor(level?: LogLevel);
11
+ debug(message: string, ...args: unknown[]): void;
12
+ info(message: string, ...args: unknown[]): void;
13
+ warn(message: string, ...args: unknown[]): void;
14
+ error(message: string, ...args: unknown[]): void;
15
+ private log;
16
+ }
17
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/middleware/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAS3D,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAS;gBAEV,KAAK,GAAE,QAAiB;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,OAAO,CAAC,GAAG;CAOZ"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Logger — Simple stderr-based logger for MCP servers.
3
+ *
4
+ * IMPORTANT: MCP stdio servers MUST NOT write to stdout.
5
+ * All logging goes to stderr to avoid corrupting JSON-RPC messages.
6
+ */
7
+ const LOG_LEVELS = {
8
+ debug: 0,
9
+ info: 1,
10
+ warn: 2,
11
+ error: 3,
12
+ };
13
+ export class Logger {
14
+ level;
15
+ constructor(level = "info") {
16
+ this.level = LOG_LEVELS[level];
17
+ }
18
+ debug(message, ...args) {
19
+ this.log("debug", message, ...args);
20
+ }
21
+ info(message, ...args) {
22
+ this.log("info", message, ...args);
23
+ }
24
+ warn(message, ...args) {
25
+ this.log("warn", message, ...args);
26
+ }
27
+ error(message, ...args) {
28
+ this.log("error", message, ...args);
29
+ }
30
+ log(level, message, ...args) {
31
+ if (LOG_LEVELS[level] >= this.level) {
32
+ const timestamp = new Date().toISOString();
33
+ const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
34
+ console.error(`${prefix} ${message}`, ...args);
35
+ }
36
+ }
37
+ }
38
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/middleware/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,UAAU,GAA6B;IAC3C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,OAAO,MAAM;IACT,KAAK,CAAS;IAEtB,YAAY,QAAkB,MAAM;QAClC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAEO,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,GAAG,IAAe;QAC9D,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAI,SAAS,MAAM,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC;YACzD,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Output Processor — Truncation, formatting, structured parsing, and binary handling.
3
+ *
4
+ * Sits between raw ADB output and what gets returned to Claude.
5
+ * Prevents context window blowout from verbose commands.
6
+ */
7
+ export declare class OutputProcessor {
8
+ /**
9
+ * Truncate output at a logical boundary (line break or section separator)
10
+ * rather than cutting mid-line. Falls back to character limit if no
11
+ * clean break is found within a reasonable range.
12
+ */
13
+ static truncate(text: string, maxSize?: number): string;
14
+ /**
15
+ * Format ADB command output for clean presentation.
16
+ * Strips trailing whitespace and normalizes line endings.
17
+ */
18
+ static clean(text: string): string;
19
+ /**
20
+ * Process raw ADB output: clean, then truncate.
21
+ */
22
+ static process(text: string, maxSize?: number): string;
23
+ /**
24
+ * Format a structured error response.
25
+ */
26
+ static formatError(error: unknown): string;
27
+ /**
28
+ * Limit output to N lines (useful for logcat, dumpsys).
29
+ */
30
+ static limitLines(text: string, maxLines: number): string;
31
+ /**
32
+ * Extract the stdout string from a Promise.allSettled result.
33
+ * Handles fulfilled/rejected states, applies optional truncation,
34
+ * and provides a configurable fallback message on failure.
35
+ *
36
+ * Used by tools that run parallel ADB commands and need to present
37
+ * results even when some commands fail (e.g., diagnostics, baseband).
38
+ */
39
+ static settledValue(result: PromiseSettledResult<{
40
+ stdout: string;
41
+ }>, maxSize?: number, fallback?: string): string;
42
+ /**
43
+ * Parse `dumpsys battery` output into a concise key-value summary.
44
+ */
45
+ static parseBattery(raw: string): string;
46
+ /**
47
+ * Parse `dumpsys meminfo <package>` to extract the summary line.
48
+ * Returns the TOTAL line with key heap metrics, or falls back to raw.
49
+ */
50
+ static parseMeminfo(raw: string): string;
51
+ /**
52
+ * Parse `getprop` output into a clean key=value map string.
53
+ * Strips the [brackets] format.
54
+ */
55
+ static parseGetprop(raw: string): Record<string, string>;
56
+ }
57
+ //# sourceMappingURL=output-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-processor.d.ts","sourceRoot":"","sources":["../../src/middleware/output-processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,qBAAa,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IA2BvD;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAOlC;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAItD;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAO1C;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAWzD;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CACjB,MAAM,EAAE,oBAAoB,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EAChD,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,SAAgB,GACvB,MAAM;IAST;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAgCxC;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAmBxC;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAUzD"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Output Processor — Truncation, formatting, structured parsing, and binary handling.
3
+ *
4
+ * Sits between raw ADB output and what gets returned to Claude.
5
+ * Prevents context window blowout from verbose commands.
6
+ */
7
+ import { config } from "../config/config.js";
8
+ export class OutputProcessor {
9
+ /**
10
+ * Truncate output at a logical boundary (line break or section separator)
11
+ * rather than cutting mid-line. Falls back to character limit if no
12
+ * clean break is found within a reasonable range.
13
+ */
14
+ static truncate(text, maxSize) {
15
+ const limit = maxSize ?? config.maxOutputSize;
16
+ if (text.length <= limit)
17
+ return text;
18
+ // Scan backward from the limit to find a clean break point
19
+ // Look within the last 500 chars of the allowed range
20
+ const searchStart = Math.max(0, limit - 500);
21
+ const searchRegion = text.substring(searchStart, limit);
22
+ // Prefer section separators, then newlines
23
+ let breakOffset = -1;
24
+ const sectionBreak = searchRegion.lastIndexOf("\n\n");
25
+ if (sectionBreak !== -1) {
26
+ breakOffset = searchStart + sectionBreak;
27
+ }
28
+ else {
29
+ const lineBreak = searchRegion.lastIndexOf("\n");
30
+ if (lineBreak !== -1) {
31
+ breakOffset = searchStart + lineBreak;
32
+ }
33
+ }
34
+ const cutPoint = breakOffset > 0 ? breakOffset : limit;
35
+ const truncated = text.substring(0, cutPoint);
36
+ const remaining = text.length - cutPoint;
37
+ return `${truncated}\n\n--- OUTPUT TRUNCATED (${remaining.toLocaleString()} characters omitted) ---`;
38
+ }
39
+ /**
40
+ * Format ADB command output for clean presentation.
41
+ * Strips trailing whitespace and normalizes line endings.
42
+ */
43
+ static clean(text) {
44
+ return text
45
+ .replace(/\r\n/g, "\n")
46
+ .replace(/\r/g, "\n")
47
+ .trimEnd();
48
+ }
49
+ /**
50
+ * Process raw ADB output: clean, then truncate.
51
+ */
52
+ static process(text, maxSize) {
53
+ return this.truncate(this.clean(text), maxSize);
54
+ }
55
+ /**
56
+ * Format a structured error response.
57
+ */
58
+ static formatError(error) {
59
+ if (error instanceof Error) {
60
+ return `Error: ${error.message}`;
61
+ }
62
+ return `Error: ${String(error)}`;
63
+ }
64
+ /**
65
+ * Limit output to N lines (useful for logcat, dumpsys).
66
+ */
67
+ static limitLines(text, maxLines) {
68
+ const lines = text.split("\n");
69
+ if (lines.length <= maxLines)
70
+ return text;
71
+ const kept = lines.slice(0, maxLines);
72
+ const omitted = lines.length - maxLines;
73
+ return `${kept.join("\n")}\n\n--- ${omitted} lines omitted (showing first ${maxLines}) ---`;
74
+ }
75
+ // ── Structured Output Parsers ────────────────────────────────────
76
+ /**
77
+ * Extract the stdout string from a Promise.allSettled result.
78
+ * Handles fulfilled/rejected states, applies optional truncation,
79
+ * and provides a configurable fallback message on failure.
80
+ *
81
+ * Used by tools that run parallel ADB commands and need to present
82
+ * results even when some commands fail (e.g., diagnostics, baseband).
83
+ */
84
+ static settledValue(result, maxSize, fallback = "unavailable") {
85
+ if (result.status === "fulfilled") {
86
+ const text = result.value.stdout.trim();
87
+ return text ? (maxSize ? OutputProcessor.process(text, maxSize) : text) : "(empty)";
88
+ }
89
+ const reason = result.reason;
90
+ return `${fallback}: ${reason instanceof Error ? reason.message : String(reason ?? "unknown error")}`;
91
+ }
92
+ /**
93
+ * Parse `dumpsys battery` output into a concise key-value summary.
94
+ */
95
+ static parseBattery(raw) {
96
+ const pairs = [];
97
+ const extract = (key) => {
98
+ const match = raw.match(new RegExp(`^\\s*${key}:\\s*(.+)$`, "m"));
99
+ return match?.[1]?.trim();
100
+ };
101
+ const level = extract("level");
102
+ const status = extract("status");
103
+ const health = extract("health");
104
+ const plugged = extract("plugged");
105
+ const temperature = extract("temperature");
106
+ const voltage = extract("voltage");
107
+ if (level)
108
+ pairs.push(`Level: ${level}%`);
109
+ if (status) {
110
+ const statusMap = { "2": "Charging", "3": "Discharging", "4": "Not charging", "5": "Full" };
111
+ pairs.push(`Status: ${statusMap[status] ?? status}`);
112
+ }
113
+ if (health) {
114
+ const healthMap = { "2": "Good", "3": "Overheat", "4": "Dead", "5": "Over voltage" };
115
+ pairs.push(`Health: ${healthMap[health] ?? health}`);
116
+ }
117
+ if (plugged) {
118
+ const plugMap = { "0": "Unplugged", "1": "AC", "2": "USB", "4": "Wireless" };
119
+ pairs.push(`Plugged: ${plugMap[plugged] ?? plugged}`);
120
+ }
121
+ if (temperature)
122
+ pairs.push(`Temperature: ${(parseInt(temperature, 10) / 10).toFixed(1)}°C`);
123
+ if (voltage)
124
+ pairs.push(`Voltage: ${(parseInt(voltage, 10) / 1000).toFixed(3)}V`);
125
+ return pairs.length > 0 ? pairs.join(" | ") : raw.trim();
126
+ }
127
+ /**
128
+ * Parse `dumpsys meminfo <package>` to extract the summary line.
129
+ * Returns the TOTAL line with key heap metrics, or falls back to raw.
130
+ */
131
+ static parseMeminfo(raw) {
132
+ const lines = raw.split("\n");
133
+ const sections = [];
134
+ // Find TOTAL line
135
+ const totalLine = lines.find((l) => /^\s*TOTAL\b/.test(l));
136
+ if (totalLine)
137
+ sections.push(`Memory: ${totalLine.trim()}`);
138
+ // Find summary section
139
+ const summaryIdx = lines.findIndex((l) => l.includes("App Summary"));
140
+ if (summaryIdx !== -1) {
141
+ const summaryLines = lines.slice(summaryIdx, summaryIdx + 10)
142
+ .filter((l) => l.trim().length > 0);
143
+ sections.push(summaryLines.join("\n"));
144
+ }
145
+ return sections.length > 0 ? sections.join("\n\n") : raw;
146
+ }
147
+ /**
148
+ * Parse `getprop` output into a clean key=value map string.
149
+ * Strips the [brackets] format.
150
+ */
151
+ static parseGetprop(raw) {
152
+ const props = {};
153
+ for (const line of raw.split("\n")) {
154
+ const match = line.trim().match(/^\[(.+?)\]: \[(.*)?\]$/);
155
+ if (match) {
156
+ props[match[1]] = match[2] ?? "";
157
+ }
158
+ }
159
+ return props;
160
+ }
161
+ }
162
+ //# sourceMappingURL=output-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-processor.js","sourceRoot":"","sources":["../../src/middleware/output-processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,OAAgB;QAC5C,MAAM,KAAK,GAAG,OAAO,IAAI,MAAM,CAAC,aAAa,CAAC;QAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;YAAE,OAAO,IAAI,CAAC;QAEtC,2DAA2D;QAC3D,sDAAsD;QACtD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAExD,2CAA2C;QAC3C,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC;QACrB,MAAM,YAAY,GA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;YACtB,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,EAAE,CAAC;iBAC1D,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,GAAW;QAC7B,MAAM,KAAK,GAA2B,EAAE,CAAC;QACzC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC1D,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Input Sanitization — Shell injection prevention for ADB command construction.
3
+ *
4
+ * Tools that interpolate user-supplied parameters into shell command strings
5
+ * must validate those parameters before passing them to bridge.shell().
6
+ * This module provides validation for common parameter types.
7
+ */
8
+ /**
9
+ * Validate that a string is safe to interpolate into a shell command.
10
+ * Rejects strings containing shell metacharacters that could enable injection.
11
+ *
12
+ * Use for: package names, property keys, service names, setting keys,
13
+ * test class names, runner names, interface names — any identifier that
14
+ * should never contain shell operators.
15
+ *
16
+ * Returns null if safe, or an error message string if unsafe.
17
+ */
18
+ export declare function validateShellArg(value: string, paramName: string): string | null;
19
+ /**
20
+ * Escape a string for safe use inside single-quoted shell arguments.
21
+ * Handles the only character that can break single-quote context: the quote itself.
22
+ * Use for file paths, grep patterns, and any value interpolated into shell commands
23
+ * within single quotes.
24
+ */
25
+ export declare function shellEscape(str: string): string;
26
+ /**
27
+ * Validate multiple arguments at once. Returns the first error found, or null if all pass.
28
+ */
29
+ export declare function validateShellArgs(args: Array<[string, string]>): string | null;
30
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/middleware/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKhF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAM9E"}