@xiuchang-midscene/shared 2.0.2

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 (382) hide show
  1. package/README.md +9 -0
  2. package/dist/es/baseDB.mjs +109 -0
  3. package/dist/es/baseDB.mjs.bak +109 -0
  4. package/dist/es/build/copy-static.mjs +31 -0
  5. package/dist/es/build/copy-static.mjs.bak +31 -0
  6. package/dist/es/build/rspack-config.mjs +4 -0
  7. package/dist/es/build/rspack-config.mjs.bak +4 -0
  8. package/dist/es/cli/cli-runner.mjs +140 -0
  9. package/dist/es/cli/cli-runner.mjs.bak +140 -0
  10. package/dist/es/cli/index.mjs +2 -0
  11. package/dist/es/cli/index.mjs.bak +2 -0
  12. package/dist/es/common.mjs +37 -0
  13. package/dist/es/common.mjs.bak +37 -0
  14. package/dist/es/constants/example-code.mjs +223 -0
  15. package/dist/es/constants/example-code.mjs.bak +223 -0
  16. package/dist/es/constants/index.mjs +23 -0
  17. package/dist/es/constants/index.mjs.bak +23 -0
  18. package/dist/es/env/basic.mjs +6 -0
  19. package/dist/es/env/basic.mjs.bak +6 -0
  20. package/dist/es/env/constants.mjs +70 -0
  21. package/dist/es/env/constants.mjs.bak +70 -0
  22. package/dist/es/env/global-config-manager.mjs +94 -0
  23. package/dist/es/env/global-config-manager.mjs.bak +94 -0
  24. package/dist/es/env/helper.mjs +43 -0
  25. package/dist/es/env/helper.mjs.bak +43 -0
  26. package/dist/es/env/index.mjs +5 -0
  27. package/dist/es/env/index.mjs.bak +5 -0
  28. package/dist/es/env/init-debug.mjs +18 -0
  29. package/dist/es/env/init-debug.mjs.bak +18 -0
  30. package/dist/es/env/model-config-manager.mjs +79 -0
  31. package/dist/es/env/model-config-manager.mjs.bak +79 -0
  32. package/dist/es/env/parse-model-config.mjs +132 -0
  33. package/dist/es/env/parse-model-config.mjs.bak +132 -0
  34. package/dist/es/env/types.mjs +220 -0
  35. package/dist/es/env/types.mjs.bak +220 -0
  36. package/dist/es/env/utils.mjs +26 -0
  37. package/dist/es/env/utils.mjs.bak +26 -0
  38. package/dist/es/extractor/constants.mjs +2 -0
  39. package/dist/es/extractor/constants.mjs.bak +2 -0
  40. package/dist/es/extractor/debug.mjs +6 -0
  41. package/dist/es/extractor/debug.mjs.bak +6 -0
  42. package/dist/es/extractor/dom-util.mjs +92 -0
  43. package/dist/es/extractor/dom-util.mjs.bak +92 -0
  44. package/dist/es/extractor/index.mjs +5 -0
  45. package/dist/es/extractor/index.mjs.bak +5 -0
  46. package/dist/es/extractor/locator.mjs +250 -0
  47. package/dist/es/extractor/locator.mjs.bak +250 -0
  48. package/dist/es/extractor/tree.mjs +78 -0
  49. package/dist/es/extractor/tree.mjs.bak +78 -0
  50. package/dist/es/extractor/util.mjs +245 -0
  51. package/dist/es/extractor/util.mjs.bak +245 -0
  52. package/dist/es/extractor/web-extractor.mjs +303 -0
  53. package/dist/es/extractor/web-extractor.mjs.bak +303 -0
  54. package/dist/es/img/box-select.mjs +824 -0
  55. package/dist/es/img/box-select.mjs.bak +824 -0
  56. package/dist/es/img/canvas-fallback.mjs +238 -0
  57. package/dist/es/img/canvas-fallback.mjs.bak +238 -0
  58. package/dist/es/img/get-photon.mjs +45 -0
  59. package/dist/es/img/get-photon.mjs.bak +45 -0
  60. package/dist/es/img/get-sharp.mjs +11 -0
  61. package/dist/es/img/get-sharp.mjs.bak +11 -0
  62. package/dist/es/img/index.mjs +4 -0
  63. package/dist/es/img/index.mjs.bak +4 -0
  64. package/dist/es/img/info.mjs +29 -0
  65. package/dist/es/img/info.mjs.bak +29 -0
  66. package/dist/es/img/transform.mjs +295 -0
  67. package/dist/es/img/transform.mjs.bak +295 -0
  68. package/dist/es/index.mjs +4 -0
  69. package/dist/es/index.mjs.bak +4 -0
  70. package/dist/es/logger.mjs +64 -0
  71. package/dist/es/logger.mjs.bak +64 -0
  72. package/dist/es/mcp/base-server.mjs +281 -0
  73. package/dist/es/mcp/base-server.mjs.bak +281 -0
  74. package/dist/es/mcp/base-tools.mjs +91 -0
  75. package/dist/es/mcp/base-tools.mjs.bak +91 -0
  76. package/dist/es/mcp/chrome-path.mjs +35 -0
  77. package/dist/es/mcp/chrome-path.mjs.bak +35 -0
  78. package/dist/es/mcp/index.mjs +7 -0
  79. package/dist/es/mcp/index.mjs.bak +7 -0
  80. package/dist/es/mcp/inject-report-html-plugin.mjs +53 -0
  81. package/dist/es/mcp/inject-report-html-plugin.mjs.bak +53 -0
  82. package/dist/es/mcp/launcher-helper.mjs +52 -0
  83. package/dist/es/mcp/launcher-helper.mjs.bak +52 -0
  84. package/dist/es/mcp/tool-generator.mjs +297 -0
  85. package/dist/es/mcp/tool-generator.mjs.bak +297 -0
  86. package/dist/es/mcp/types.mjs +3 -0
  87. package/dist/es/mcp/types.mjs.bak +3 -0
  88. package/dist/es/node/fs.mjs +44 -0
  89. package/dist/es/node/fs.mjs.bak +44 -0
  90. package/dist/es/node/index.mjs +2 -0
  91. package/dist/es/node/index.mjs.bak +2 -0
  92. package/dist/es/node/port.mjs +24 -0
  93. package/dist/es/node/port.mjs.bak +24 -0
  94. package/dist/es/oss/demo.mjs +30 -0
  95. package/dist/es/oss/demo.mjs.bak +30 -0
  96. package/dist/es/oss/index.mjs +90 -0
  97. package/dist/es/oss/index.mjs.bak +90 -0
  98. package/dist/es/polyfills/async-hooks.mjs +2 -0
  99. package/dist/es/polyfills/async-hooks.mjs.bak +2 -0
  100. package/dist/es/polyfills/index.mjs +1 -0
  101. package/dist/es/polyfills/index.mjs.bak +1 -0
  102. package/dist/es/types/index.mjs +3 -0
  103. package/dist/es/types/index.mjs.bak +3 -0
  104. package/dist/es/us-keyboard-layout.mjs +1414 -0
  105. package/dist/es/us-keyboard-layout.mjs.LICENSE.txt +5 -0
  106. package/dist/es/us-keyboard-layout.mjs.bak +1414 -0
  107. package/dist/es/utils.mjs +72 -0
  108. package/dist/es/utils.mjs.bak +72 -0
  109. package/dist/es/zod-schema-utils.mjs +54 -0
  110. package/dist/es/zod-schema-utils.mjs.bak +54 -0
  111. package/dist/lib/baseDB.js +149 -0
  112. package/dist/lib/baseDB.js.bak +149 -0
  113. package/dist/lib/build/copy-static.js +79 -0
  114. package/dist/lib/build/copy-static.js.bak +79 -0
  115. package/dist/lib/build/rspack-config.js +38 -0
  116. package/dist/lib/build/rspack-config.js.bak +38 -0
  117. package/dist/lib/cli/cli-runner.js +196 -0
  118. package/dist/lib/cli/cli-runner.js.bak +196 -0
  119. package/dist/lib/cli/index.js +48 -0
  120. package/dist/lib/cli/index.js.bak +48 -0
  121. package/dist/lib/common.js +93 -0
  122. package/dist/lib/common.js.bak +93 -0
  123. package/dist/lib/constants/example-code.js +260 -0
  124. package/dist/lib/constants/example-code.js.bak +260 -0
  125. package/dist/lib/constants/index.js +96 -0
  126. package/dist/lib/constants/index.js.bak +96 -0
  127. package/dist/lib/env/basic.js +40 -0
  128. package/dist/lib/env/basic.js.bak +40 -0
  129. package/dist/lib/env/constants.js +113 -0
  130. package/dist/lib/env/constants.js.bak +113 -0
  131. package/dist/lib/env/global-config-manager.js +128 -0
  132. package/dist/lib/env/global-config-manager.js.bak +128 -0
  133. package/dist/lib/env/helper.js +80 -0
  134. package/dist/lib/env/helper.js.bak +80 -0
  135. package/dist/lib/env/index.js +90 -0
  136. package/dist/lib/env/index.js.bak +90 -0
  137. package/dist/lib/env/init-debug.js +52 -0
  138. package/dist/lib/env/init-debug.js.bak +52 -0
  139. package/dist/lib/env/model-config-manager.js +113 -0
  140. package/dist/lib/env/model-config-manager.js.bak +113 -0
  141. package/dist/lib/env/parse-model-config.js +178 -0
  142. package/dist/lib/env/parse-model-config.js.bak +178 -0
  143. package/dist/lib/env/types.js +554 -0
  144. package/dist/lib/env/types.js.bak +554 -0
  145. package/dist/lib/env/utils.js +72 -0
  146. package/dist/lib/env/utils.js.bak +72 -0
  147. package/dist/lib/extractor/constants.js +42 -0
  148. package/dist/lib/extractor/constants.js.bak +42 -0
  149. package/dist/lib/extractor/debug.js +12 -0
  150. package/dist/lib/extractor/debug.js.bak +12 -0
  151. package/dist/lib/extractor/dom-util.js +153 -0
  152. package/dist/lib/extractor/dom-util.js.bak +153 -0
  153. package/dist/lib/extractor/index.js +81 -0
  154. package/dist/lib/extractor/index.js.bak +81 -0
  155. package/dist/lib/extractor/locator.js +296 -0
  156. package/dist/lib/extractor/locator.js.bak +296 -0
  157. package/dist/lib/extractor/tree.js +124 -0
  158. package/dist/lib/extractor/tree.js.bak +124 -0
  159. package/dist/lib/extractor/util.js +336 -0
  160. package/dist/lib/extractor/util.js.bak +336 -0
  161. package/dist/lib/extractor/web-extractor.js +349 -0
  162. package/dist/lib/extractor/web-extractor.js.bak +349 -0
  163. package/dist/lib/img/box-select.js +875 -0
  164. package/dist/lib/img/box-select.js.bak +875 -0
  165. package/dist/lib/img/canvas-fallback.js +305 -0
  166. package/dist/lib/img/canvas-fallback.js.bak +305 -0
  167. package/dist/lib/img/get-photon.js +82 -0
  168. package/dist/lib/img/get-photon.js.bak +82 -0
  169. package/dist/lib/img/get-sharp.js +45 -0
  170. package/dist/lib/img/get-sharp.js.bak +45 -0
  171. package/dist/lib/img/index.js +95 -0
  172. package/dist/lib/img/index.js.bak +95 -0
  173. package/dist/lib/img/info.js +83 -0
  174. package/dist/lib/img/info.js.bak +83 -0
  175. package/dist/lib/img/transform.js +387 -0
  176. package/dist/lib/img/transform.js.bak +387 -0
  177. package/dist/lib/index.js +47 -0
  178. package/dist/lib/index.js.bak +47 -0
  179. package/dist/lib/logger.js +114 -0
  180. package/dist/lib/logger.js.bak +114 -0
  181. package/dist/lib/mcp/base-server.js +331 -0
  182. package/dist/lib/mcp/base-server.js.bak +331 -0
  183. package/dist/lib/mcp/base-tools.js +125 -0
  184. package/dist/lib/mcp/base-tools.js.bak +125 -0
  185. package/dist/lib/mcp/chrome-path.js +72 -0
  186. package/dist/lib/mcp/chrome-path.js.bak +72 -0
  187. package/dist/lib/mcp/index.js +100 -0
  188. package/dist/lib/mcp/index.js.bak +100 -0
  189. package/dist/lib/mcp/inject-report-html-plugin.js +98 -0
  190. package/dist/lib/mcp/inject-report-html-plugin.js.bak +98 -0
  191. package/dist/lib/mcp/launcher-helper.js +86 -0
  192. package/dist/lib/mcp/launcher-helper.js.bak +86 -0
  193. package/dist/lib/mcp/tool-generator.js +334 -0
  194. package/dist/lib/mcp/tool-generator.js.bak +334 -0
  195. package/dist/lib/mcp/types.js +40 -0
  196. package/dist/lib/mcp/types.js.bak +40 -0
  197. package/dist/lib/node/fs.js +97 -0
  198. package/dist/lib/node/fs.js.bak +97 -0
  199. package/dist/lib/node/index.js +65 -0
  200. package/dist/lib/node/index.js.bak +65 -0
  201. package/dist/lib/node/port.js +61 -0
  202. package/dist/lib/node/port.js.bak +61 -0
  203. package/dist/lib/oss/demo.js +36 -0
  204. package/dist/lib/oss/demo.js.bak +36 -0
  205. package/dist/lib/oss/index.js +138 -0
  206. package/dist/lib/oss/index.js.bak +138 -0
  207. package/dist/lib/polyfills/async-hooks.js +36 -0
  208. package/dist/lib/polyfills/async-hooks.js.bak +36 -0
  209. package/dist/lib/polyfills/index.js +58 -0
  210. package/dist/lib/polyfills/index.js.bak +58 -0
  211. package/dist/lib/types/index.js +37 -0
  212. package/dist/lib/types/index.js.bak +37 -0
  213. package/dist/lib/us-keyboard-layout.js +1457 -0
  214. package/dist/lib/us-keyboard-layout.js.LICENSE.txt +5 -0
  215. package/dist/lib/us-keyboard-layout.js.bak +1457 -0
  216. package/dist/lib/utils.js +148 -0
  217. package/dist/lib/utils.js.bak +148 -0
  218. package/dist/lib/zod-schema-utils.js +97 -0
  219. package/dist/lib/zod-schema-utils.js.bak +97 -0
  220. package/dist/types/baseDB.d.ts +25 -0
  221. package/dist/types/baseDB.d.ts.bak +25 -0
  222. package/dist/types/build/copy-static.d.ts +31 -0
  223. package/dist/types/build/copy-static.d.ts.bak +31 -0
  224. package/dist/types/build/rspack-config.d.ts +8 -0
  225. package/dist/types/build/rspack-config.d.ts.bak +8 -0
  226. package/dist/types/cli/cli-runner.d.ts +14 -0
  227. package/dist/types/cli/cli-runner.d.ts.bak +14 -0
  228. package/dist/types/cli/index.d.ts +2 -0
  229. package/dist/types/cli/index.d.ts.bak +2 -0
  230. package/dist/types/common.d.ts +12 -0
  231. package/dist/types/common.d.ts.bak +12 -0
  232. package/dist/types/constants/example-code.d.ts +2 -0
  233. package/dist/types/constants/example-code.d.ts.bak +2 -0
  234. package/dist/types/constants/index.d.ts +21 -0
  235. package/dist/types/constants/index.d.ts.bak +21 -0
  236. package/dist/types/env/basic.d.ts +6 -0
  237. package/dist/types/env/basic.d.ts.bak +6 -0
  238. package/dist/types/env/constants.d.ts +40 -0
  239. package/dist/types/env/constants.d.ts.bak +40 -0
  240. package/dist/types/env/global-config-manager.d.ts +32 -0
  241. package/dist/types/env/global-config-manager.d.ts.bak +32 -0
  242. package/dist/types/env/helper.d.ts +4 -0
  243. package/dist/types/env/helper.d.ts.bak +4 -0
  244. package/dist/types/env/index.d.ts +4 -0
  245. package/dist/types/env/index.d.ts.bak +4 -0
  246. package/dist/types/env/init-debug.d.ts +1 -0
  247. package/dist/types/env/init-debug.d.ts.bak +1 -0
  248. package/dist/types/env/model-config-manager.d.ts +25 -0
  249. package/dist/types/env/model-config-manager.d.ts.bak +25 -0
  250. package/dist/types/env/parse-model-config.d.ts +31 -0
  251. package/dist/types/env/parse-model-config.d.ts.bak +31 -0
  252. package/dist/types/env/types.d.ts +318 -0
  253. package/dist/types/env/types.d.ts.bak +318 -0
  254. package/dist/types/env/utils.d.ts +38 -0
  255. package/dist/types/env/utils.d.ts.bak +38 -0
  256. package/dist/types/extractor/constants.d.ts +1 -0
  257. package/dist/types/extractor/constants.d.ts.bak +1 -0
  258. package/dist/types/extractor/debug.d.ts +1 -0
  259. package/dist/types/extractor/debug.d.ts.bak +1 -0
  260. package/dist/types/extractor/dom-util.d.ts +56 -0
  261. package/dist/types/extractor/dom-util.d.ts.bak +56 -0
  262. package/dist/types/extractor/index.d.ts +32 -0
  263. package/dist/types/extractor/index.d.ts.bak +32 -0
  264. package/dist/types/extractor/locator.d.ts +9 -0
  265. package/dist/types/extractor/locator.d.ts.bak +9 -0
  266. package/dist/types/extractor/tree.d.ts +6 -0
  267. package/dist/types/extractor/tree.d.ts.bak +6 -0
  268. package/dist/types/extractor/util.d.ts +47 -0
  269. package/dist/types/extractor/util.d.ts.bak +47 -0
  270. package/dist/types/extractor/web-extractor.d.ts +19 -0
  271. package/dist/types/extractor/web-extractor.d.ts.bak +19 -0
  272. package/dist/types/img/box-select.d.ts +26 -0
  273. package/dist/types/img/box-select.d.ts.bak +26 -0
  274. package/dist/types/img/canvas-fallback.d.ts +105 -0
  275. package/dist/types/img/canvas-fallback.d.ts.bak +105 -0
  276. package/dist/types/img/get-photon.d.ts +19 -0
  277. package/dist/types/img/get-photon.d.ts.bak +19 -0
  278. package/dist/types/img/get-sharp.d.ts +3 -0
  279. package/dist/types/img/get-sharp.d.ts.bak +3 -0
  280. package/dist/types/img/index.d.ts +3 -0
  281. package/dist/types/img/index.d.ts.bak +3 -0
  282. package/dist/types/img/info.d.ts +29 -0
  283. package/dist/types/img/info.d.ts.bak +29 -0
  284. package/dist/types/img/transform.d.ts +107 -0
  285. package/dist/types/img/transform.d.ts.bak +107 -0
  286. package/dist/types/index.d.ts +4 -0
  287. package/dist/types/index.d.ts.bak +4 -0
  288. package/dist/types/logger.d.ts +5 -0
  289. package/dist/types/logger.d.ts.bak +5 -0
  290. package/dist/types/mcp/base-server.d.ts +93 -0
  291. package/dist/types/mcp/base-server.d.ts.bak +93 -0
  292. package/dist/types/mcp/base-tools.d.ts +79 -0
  293. package/dist/types/mcp/base-tools.d.ts.bak +79 -0
  294. package/dist/types/mcp/chrome-path.d.ts +2 -0
  295. package/dist/types/mcp/chrome-path.d.ts.bak +2 -0
  296. package/dist/types/mcp/index.d.ts +7 -0
  297. package/dist/types/mcp/index.d.ts.bak +7 -0
  298. package/dist/types/mcp/inject-report-html-plugin.d.ts +18 -0
  299. package/dist/types/mcp/inject-report-html-plugin.d.ts.bak +18 -0
  300. package/dist/types/mcp/launcher-helper.d.ts +94 -0
  301. package/dist/types/mcp/launcher-helper.d.ts.bak +94 -0
  302. package/dist/types/mcp/tool-generator.d.ts +10 -0
  303. package/dist/types/mcp/tool-generator.d.ts.bak +10 -0
  304. package/dist/types/mcp/types.d.ts +103 -0
  305. package/dist/types/mcp/types.d.ts.bak +103 -0
  306. package/dist/types/node/fs.d.ts +15 -0
  307. package/dist/types/node/fs.d.ts.bak +15 -0
  308. package/dist/types/node/index.d.ts +2 -0
  309. package/dist/types/node/index.d.ts.bak +2 -0
  310. package/dist/types/node/port.d.ts +8 -0
  311. package/dist/types/node/port.d.ts.bak +8 -0
  312. package/dist/types/oss/demo.d.ts +1 -0
  313. package/dist/types/oss/demo.d.ts.bak +1 -0
  314. package/dist/types/oss/index.d.ts +34 -0
  315. package/dist/types/oss/index.d.ts.bak +34 -0
  316. package/dist/types/polyfills/async-hooks.d.ts +6 -0
  317. package/dist/types/polyfills/async-hooks.d.ts.bak +6 -0
  318. package/dist/types/polyfills/index.d.ts +4 -0
  319. package/dist/types/polyfills/index.d.ts.bak +4 -0
  320. package/dist/types/types/index.d.ts +34 -0
  321. package/dist/types/types/index.d.ts.bak +34 -0
  322. package/dist/types/us-keyboard-layout.d.ts +32 -0
  323. package/dist/types/us-keyboard-layout.d.ts.bak +32 -0
  324. package/dist/types/utils.d.ts +34 -0
  325. package/dist/types/utils.d.ts.bak +34 -0
  326. package/dist/types/zod-schema-utils.d.ts +23 -0
  327. package/dist/types/zod-schema-utils.d.ts.bak +23 -0
  328. package/package.json +132 -0
  329. package/src/baseDB.ts +158 -0
  330. package/src/build/copy-static.ts +68 -0
  331. package/src/build/rspack-config.ts +12 -0
  332. package/src/cli/cli-runner.ts +224 -0
  333. package/src/cli/index.ts +8 -0
  334. package/src/common.ts +67 -0
  335. package/src/constants/example-code.ts +223 -0
  336. package/src/constants/index.ts +29 -0
  337. package/src/env/basic.ts +12 -0
  338. package/src/env/constants.ts +234 -0
  339. package/src/env/global-config-manager.ts +191 -0
  340. package/src/env/helper.ts +58 -0
  341. package/src/env/index.ts +4 -0
  342. package/src/env/init-debug.ts +34 -0
  343. package/src/env/model-config-manager.ts +149 -0
  344. package/src/env/parse-model-config.ts +294 -0
  345. package/src/env/types.ts +547 -0
  346. package/src/env/utils.ts +89 -0
  347. package/src/extractor/constants.ts +5 -0
  348. package/src/extractor/debug.ts +10 -0
  349. package/src/extractor/dom-util.ts +226 -0
  350. package/src/extractor/index.ts +48 -0
  351. package/src/extractor/locator.ts +469 -0
  352. package/src/extractor/tree.ts +179 -0
  353. package/src/extractor/util.ts +482 -0
  354. package/src/extractor/web-extractor.ts +481 -0
  355. package/src/img/box-select.ts +588 -0
  356. package/src/img/canvas-fallback.ts +393 -0
  357. package/src/img/get-photon.ts +108 -0
  358. package/src/img/get-sharp.ts +18 -0
  359. package/src/img/index.ts +26 -0
  360. package/src/img/info.ts +75 -0
  361. package/src/img/transform.ts +594 -0
  362. package/src/index.ts +8 -0
  363. package/src/logger.ts +96 -0
  364. package/src/mcp/base-server.ts +502 -0
  365. package/src/mcp/base-tools.ts +185 -0
  366. package/src/mcp/chrome-path.ts +48 -0
  367. package/src/mcp/index.ts +7 -0
  368. package/src/mcp/inject-report-html-plugin.ts +119 -0
  369. package/src/mcp/launcher-helper.ts +200 -0
  370. package/src/mcp/tool-generator.ts +429 -0
  371. package/src/mcp/types.ts +112 -0
  372. package/src/node/fs.ts +84 -0
  373. package/src/node/index.ts +2 -0
  374. package/src/node/port.ts +37 -0
  375. package/src/oss/demo.ts +61 -0
  376. package/src/oss/index.ts +187 -0
  377. package/src/polyfills/async-hooks.ts +6 -0
  378. package/src/polyfills/index.ts +4 -0
  379. package/src/types/index.ts +52 -0
  380. package/src/us-keyboard-layout.ts +723 -0
  381. package/src/utils.ts +149 -0
  382. package/src/zod-schema-utils.ts +133 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Canvas-based fallback for image processing when Photon WASM fails to load.
3
+ * Provides a compatible API with Photon for browser environments.
4
+ */
5
+ /**
6
+ * Canvas-based image class that mimics PhotonImage API
7
+ */
8
+ export declare class CanvasImage {
9
+ private canvas;
10
+ private ctx;
11
+ private _width;
12
+ private _height;
13
+ constructor(canvas: HTMLCanvasElement);
14
+ get_width(): number;
15
+ get_height(): number;
16
+ get_raw_pixels(): Uint8Array;
17
+ get_bytes_jpeg(quality: number): Uint8Array;
18
+ free(): void;
19
+ _getCanvas(): HTMLCanvasElement;
20
+ _getContext(): CanvasRenderingContext2D;
21
+ /**
22
+ * Create a CanvasImage from a base64 string
23
+ */
24
+ static new_from_base64(base64Body: string): Promise<CanvasImage>;
25
+ /**
26
+ * Create a CanvasImage from a byte array (async version)
27
+ */
28
+ static new_from_byteslice(bytes: Uint8Array): Promise<CanvasImage>;
29
+ }
30
+ /**
31
+ * Sampling filter enum (compatible with Photon)
32
+ */
33
+ export declare const CanvasSamplingFilter: {
34
+ readonly Nearest: "nearest";
35
+ readonly Triangle: "triangle";
36
+ readonly CatmullRom: "catmullrom";
37
+ readonly Gaussian: "gaussian";
38
+ readonly Lanczos3: "lanczos3";
39
+ };
40
+ /**
41
+ * RGBA color class (compatible with Photon)
42
+ */
43
+ export declare class CanvasRgba {
44
+ r: number;
45
+ g: number;
46
+ b: number;
47
+ a: number;
48
+ constructor(r: number, g: number, b: number, a: number);
49
+ }
50
+ /**
51
+ * Resize an image
52
+ */
53
+ export declare function canvasResize(image: CanvasImage, newWidth: number, newHeight: number, _filter: string): CanvasImage;
54
+ /**
55
+ * Crop an image
56
+ */
57
+ export declare function canvasCrop(image: CanvasImage, x1: number, y1: number, x2: number, y2: number): CanvasImage;
58
+ /**
59
+ * Add padding to the right of an image
60
+ */
61
+ export declare function canvasPaddingRight(image: CanvasImage, padding: number, color: CanvasRgba): CanvasImage;
62
+ /**
63
+ * Add padding to the bottom of an image
64
+ */
65
+ export declare function canvasPaddingBottom(image: CanvasImage, padding: number, color: CanvasRgba): CanvasImage;
66
+ /**
67
+ * Add uniform padding to an image
68
+ */
69
+ export declare function canvasPaddingUniform(image: CanvasImage, padding: number, color: CanvasRgba): CanvasImage;
70
+ /**
71
+ * Add padding to the left of an image
72
+ */
73
+ export declare function canvasPaddingLeft(image: CanvasImage, padding: number, color: CanvasRgba): CanvasImage;
74
+ /**
75
+ * Add padding to the top of an image
76
+ */
77
+ export declare function canvasPaddingTop(image: CanvasImage, padding: number, color: CanvasRgba): CanvasImage;
78
+ /**
79
+ * Watermark an image (overlay one image on another)
80
+ */
81
+ export declare function canvasWatermark(base: CanvasImage, overlay: CanvasImage, x: number, y: number): CanvasImage;
82
+ /**
83
+ * Create and return the canvas fallback module with Photon-compatible API
84
+ */
85
+ export declare function createCanvasFallbackModule(): {
86
+ PhotonImage: typeof CanvasImage;
87
+ SamplingFilter: {
88
+ readonly Nearest: "nearest";
89
+ readonly Triangle: "triangle";
90
+ readonly CatmullRom: "catmullrom";
91
+ readonly Gaussian: "gaussian";
92
+ readonly Lanczos3: "lanczos3";
93
+ };
94
+ resize: typeof canvasResize;
95
+ crop: typeof canvasCrop;
96
+ open_image: () => never;
97
+ base64_to_image: typeof CanvasImage.new_from_base64;
98
+ padding_uniform: typeof canvasPaddingUniform;
99
+ padding_left: typeof canvasPaddingLeft;
100
+ padding_right: typeof canvasPaddingRight;
101
+ padding_top: typeof canvasPaddingTop;
102
+ padding_bottom: typeof canvasPaddingBottom;
103
+ watermark: typeof canvasWatermark;
104
+ Rgba: typeof CanvasRgba;
105
+ };
@@ -0,0 +1,19 @@
1
+ export default function getPhoton(): Promise<{
2
+ PhotonImage: typeof import('@silvia-odwyer/photon-node').PhotonImage;
3
+ SamplingFilter: typeof import('@silvia-odwyer/photon-node').SamplingFilter;
4
+ resize: typeof import('@silvia-odwyer/photon-node').resize;
5
+ crop: typeof import('@silvia-odwyer/photon-node').crop;
6
+ open_image: typeof import('@silvia-odwyer/photon-node').open_image;
7
+ base64_to_image: typeof import('@silvia-odwyer/photon-node').base64_to_image;
8
+ padding_uniform: typeof import('@silvia-odwyer/photon-node').padding_uniform;
9
+ padding_left: typeof import('@silvia-odwyer/photon-node').padding_left;
10
+ padding_right: typeof import('@silvia-odwyer/photon-node').padding_right;
11
+ padding_top: typeof import('@silvia-odwyer/photon-node').padding_top;
12
+ padding_bottom: typeof import('@silvia-odwyer/photon-node').padding_bottom;
13
+ watermark: typeof import('@silvia-odwyer/photon-node').watermark;
14
+ Rgba: typeof import('@silvia-odwyer/photon-node').Rgba;
15
+ }>;
16
+ /**
17
+ * Check if we're using the Canvas fallback instead of Photon
18
+ */
19
+ export declare function isUsingCanvasFallback(): boolean;
@@ -0,0 +1,19 @@
1
+ export default function getPhoton(): Promise<{
2
+ PhotonImage: typeof import('@silvia-odwyer/photon-node').PhotonImage;
3
+ SamplingFilter: typeof import('@silvia-odwyer/photon-node').SamplingFilter;
4
+ resize: typeof import('@silvia-odwyer/photon-node').resize;
5
+ crop: typeof import('@silvia-odwyer/photon-node').crop;
6
+ open_image: typeof import('@silvia-odwyer/photon-node').open_image;
7
+ base64_to_image: typeof import('@silvia-odwyer/photon-node').base64_to_image;
8
+ padding_uniform: typeof import('@silvia-odwyer/photon-node').padding_uniform;
9
+ padding_left: typeof import('@silvia-odwyer/photon-node').padding_left;
10
+ padding_right: typeof import('@silvia-odwyer/photon-node').padding_right;
11
+ padding_top: typeof import('@silvia-odwyer/photon-node').padding_top;
12
+ padding_bottom: typeof import('@silvia-odwyer/photon-node').padding_bottom;
13
+ watermark: typeof import('@silvia-odwyer/photon-node').watermark;
14
+ Rgba: typeof import('@silvia-odwyer/photon-node').Rgba;
15
+ }>;
16
+ /**
17
+ * Check if we're using the Canvas fallback instead of Photon
18
+ */
19
+ export declare function isUsingCanvasFallback(): boolean;
@@ -0,0 +1,3 @@
1
+ type TSharpModule = typeof import('sharp');
2
+ export default function getSharp(): Promise<TSharpModule>;
3
+ export {};
@@ -0,0 +1,3 @@
1
+ type TSharpModule = typeof import('sharp');
2
+ export default function getSharp(): Promise<TSharpModule>;
3
+ export {};
@@ -0,0 +1,3 @@
1
+ export { imageInfoOfBase64, isValidPNGImageBuffer, isValidJPEGImageBuffer, isValidImageBuffer, } from './info';
2
+ export { resizeAndConvertImgBuffer, resizeImgBase64, convertToJpegBase64, zoomForGPT4o, saveBase64Image, paddingToMatchBlockByBase64, cropByRect, scaleImage, localImg2Base64, httpImg2Base64, preProcessImageUrl, parseBase64, createImgBase64ByFormat, } from './transform';
3
+ export { processImageElementInfo, compositeElementInfoImg, annotateRects, } from './box-select';
@@ -0,0 +1,3 @@
1
+ export { imageInfoOfBase64, isValidPNGImageBuffer, isValidJPEGImageBuffer, isValidImageBuffer, } from './info';
2
+ export { resizeAndConvertImgBuffer, resizeImgBase64, convertToJpegBase64, zoomForGPT4o, saveBase64Image, paddingToMatchBlockByBase64, cropByRect, scaleImage, localImg2Base64, httpImg2Base64, preProcessImageUrl, parseBase64, createImgBase64ByFormat, } from './transform';
3
+ export { processImageElementInfo, compositeElementInfoImg, annotateRects, } from './box-select';
@@ -0,0 +1,29 @@
1
+ import type { Size } from '../types';
2
+ export interface ImageInfo extends Size {
3
+ }
4
+ /**
5
+ * Retrieves the dimensions of an image from a base64-encoded string
6
+ *
7
+ * @param imageBase64 - The base64-encoded image data
8
+ * @returns A Promise that resolves to an object containing the width and height of the image
9
+ * @throws Error if the image data is invalid
10
+ */
11
+ export declare function imageInfoOfBase64(imageBase64: string): Promise<ImageInfo>;
12
+ /**
13
+ * Check if the Buffer is a valid PNG image
14
+ * @param buffer The Buffer to check
15
+ * @returns true if the Buffer is a valid PNG image, otherwise false
16
+ */
17
+ export declare function isValidPNGImageBuffer(buffer: Buffer): boolean;
18
+ /**
19
+ * Check if the Buffer is a valid JPEG image
20
+ * @param buffer The Buffer to check
21
+ * @returns true if the Buffer is a valid JPEG image, otherwise false
22
+ */
23
+ export declare function isValidJPEGImageBuffer(buffer: Buffer): boolean;
24
+ /**
25
+ * Check if the Buffer is a valid image (PNG or JPEG)
26
+ * @param buffer The Buffer to check
27
+ * @returns true if the Buffer is a valid PNG or JPEG image, otherwise false
28
+ */
29
+ export declare function isValidImageBuffer(buffer: Buffer): boolean;
@@ -0,0 +1,29 @@
1
+ import type { Size } from '../types';
2
+ export interface ImageInfo extends Size {
3
+ }
4
+ /**
5
+ * Retrieves the dimensions of an image from a base64-encoded string
6
+ *
7
+ * @param imageBase64 - The base64-encoded image data
8
+ * @returns A Promise that resolves to an object containing the width and height of the image
9
+ * @throws Error if the image data is invalid
10
+ */
11
+ export declare function imageInfoOfBase64(imageBase64: string): Promise<ImageInfo>;
12
+ /**
13
+ * Check if the Buffer is a valid PNG image
14
+ * @param buffer The Buffer to check
15
+ * @returns true if the Buffer is a valid PNG image, otherwise false
16
+ */
17
+ export declare function isValidPNGImageBuffer(buffer: Buffer): boolean;
18
+ /**
19
+ * Check if the Buffer is a valid JPEG image
20
+ * @param buffer The Buffer to check
21
+ * @returns true if the Buffer is a valid JPEG image, otherwise false
22
+ */
23
+ export declare function isValidJPEGImageBuffer(buffer: Buffer): boolean;
24
+ /**
25
+ * Check if the Buffer is a valid image (PNG or JPEG)
26
+ * @param buffer The Buffer to check
27
+ * @returns true if the Buffer is a valid PNG or JPEG image, otherwise false
28
+ */
29
+ export declare function isValidImageBuffer(buffer: Buffer): boolean;
@@ -0,0 +1,107 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import type { PhotonImage as PhotonImageType } from '@silvia-odwyer/photon-node';
3
+ import type { Rect } from '../types';
4
+ /**
5
+ * Saves a Base64-encoded image to a file
6
+ *
7
+ * @param options - An object containing the Base64-encoded image data and the output file path
8
+ * @param options.base64Data - The Base64-encoded image data
9
+ * @param options.outputPath - The path where the image will be saved
10
+ * @throws Error if there is an error during the saving process
11
+ */
12
+ export declare function saveBase64Image(options: {
13
+ base64Data: string;
14
+ outputPath: string;
15
+ }): Promise<void>;
16
+ /**
17
+ * Resizes an image from Buffer, maybe return a new format
18
+ * - If the image is Resized, the returned format will be jpg.
19
+ * - If the image is not Resized, it will return to its original format.
20
+ * @returns { buffer: resized buffer, format: the new format}
21
+ */
22
+ export declare function resizeAndConvertImgBuffer(inputFormat: string, inputData: Buffer, newSize: {
23
+ width: number;
24
+ height: number;
25
+ }): Promise<{
26
+ buffer: Buffer;
27
+ format: string;
28
+ }>;
29
+ export declare const createImgBase64ByFormat: (format: string, body: string) => string;
30
+ export declare function resizeImgBase64(inputBase64: string, newSize: {
31
+ width: number;
32
+ height: number;
33
+ }): Promise<string>;
34
+ /**
35
+ * Calculates new dimensions for an image while maintaining its aspect ratio.
36
+ *
37
+ * This function is designed to resize an image to fit within a specified maximum width and height
38
+ * while maintaining the original aspect ratio. If the original width or height exceeds the maximum
39
+ * dimensions, the image will be scaled down to fit.
40
+ *
41
+ * @param {number} originalWidth - The original width of the image.
42
+ * @param {number} originalHeight - The original height of the image.
43
+ * @returns {Object} An object containing the new width and height.
44
+ * @throws {Error} Throws an error if the width or height is not a positive number.
45
+ */
46
+ export declare function zoomForGPT4o(originalWidth: number, originalHeight: number): {
47
+ width: number;
48
+ height: number;
49
+ };
50
+ export declare function photonFromBase64(base64: string): Promise<PhotonImageType>;
51
+ export declare function paddingToMatchBlock(image: PhotonImageType, blockSize?: number): Promise<{
52
+ width: number;
53
+ height: number;
54
+ image: PhotonImageType;
55
+ }>;
56
+ export declare function paddingToMatchBlockByBase64(imageBase64: string, blockSize?: number): Promise<{
57
+ width: number;
58
+ height: number;
59
+ imageBase64: string;
60
+ }>;
61
+ export declare function cropByRect(imageBase64: string, rect: Rect, paddingImage: boolean): Promise<{
62
+ width: number;
63
+ height: number;
64
+ imageBase64: string;
65
+ }>;
66
+ export declare function photonToBase64(image: PhotonImageType, quality?: number): Promise<string>;
67
+ export declare const httpImg2Base64: (url: string) => Promise<string>;
68
+ /**
69
+ * Convert image file to base64 string
70
+ * Because this method is synchronous, the npm package `sharp` cannot be used to detect the file type.
71
+ * TODO: convert to webp to reduce base64 size.
72
+ */
73
+ export declare const localImg2Base64: (imgPath: string, withoutHeader?: boolean) => string;
74
+ /**
75
+ * PreProcess image url to ensure image is accessible to LLM.
76
+ * @param url - The url of the image, it can be a http url or a base64 string or a file path
77
+ * @param convertHttpImage2Base64 - Whether to convert http image to base64, if true, the http image will be converted to base64, otherwise, the http image will be returned as is
78
+ * @returns The base64 string of the image (when convertHttpImage2Base64 is true or url is a file path) or the http image url
79
+ */
80
+ export declare const preProcessImageUrl: (url: string, convertHttpImage2Base64: boolean) => Promise<string>;
81
+ /**
82
+ * parse base64 string to get mimeType and body
83
+ */
84
+ export declare const parseBase64: (fullBase64String: string) => {
85
+ mimeType: string;
86
+ body: string;
87
+ };
88
+ /**
89
+ * Convert a base64 image to JPEG with specified quality (no resize).
90
+ * If the image is already JPEG, re-encodes at the given quality.
91
+ *
92
+ * @param inputBase64 - Full data-URI base64 string (e.g. "data:image/png;base64,...")
93
+ * @param quality - JPEG quality 1-100
94
+ * @returns JPEG data-URI base64 string
95
+ */
96
+ export declare function convertToJpegBase64(inputBase64: string, quality: number): Promise<string>;
97
+ /**
98
+ * Scales an image by a specified factor using Sharp or Photon
99
+ * @param imageBase64 - Base64 encoded image
100
+ * @param scale - Scale factor (e.g., 2 for 2x, 1.5 for 1.5x)
101
+ * @returns Scaled image with new dimensions
102
+ */
103
+ export declare function scaleImage(imageBase64: string, scale: number): Promise<{
104
+ width: number;
105
+ height: number;
106
+ imageBase64: string;
107
+ }>;
@@ -0,0 +1,107 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import type { PhotonImage as PhotonImageType } from '@silvia-odwyer/photon-node';
3
+ import type { Rect } from '../types';
4
+ /**
5
+ * Saves a Base64-encoded image to a file
6
+ *
7
+ * @param options - An object containing the Base64-encoded image data and the output file path
8
+ * @param options.base64Data - The Base64-encoded image data
9
+ * @param options.outputPath - The path where the image will be saved
10
+ * @throws Error if there is an error during the saving process
11
+ */
12
+ export declare function saveBase64Image(options: {
13
+ base64Data: string;
14
+ outputPath: string;
15
+ }): Promise<void>;
16
+ /**
17
+ * Resizes an image from Buffer, maybe return a new format
18
+ * - If the image is Resized, the returned format will be jpg.
19
+ * - If the image is not Resized, it will return to its original format.
20
+ * @returns { buffer: resized buffer, format: the new format}
21
+ */
22
+ export declare function resizeAndConvertImgBuffer(inputFormat: string, inputData: Buffer, newSize: {
23
+ width: number;
24
+ height: number;
25
+ }): Promise<{
26
+ buffer: Buffer;
27
+ format: string;
28
+ }>;
29
+ export declare const createImgBase64ByFormat: (format: string, body: string) => string;
30
+ export declare function resizeImgBase64(inputBase64: string, newSize: {
31
+ width: number;
32
+ height: number;
33
+ }): Promise<string>;
34
+ /**
35
+ * Calculates new dimensions for an image while maintaining its aspect ratio.
36
+ *
37
+ * This function is designed to resize an image to fit within a specified maximum width and height
38
+ * while maintaining the original aspect ratio. If the original width or height exceeds the maximum
39
+ * dimensions, the image will be scaled down to fit.
40
+ *
41
+ * @param {number} originalWidth - The original width of the image.
42
+ * @param {number} originalHeight - The original height of the image.
43
+ * @returns {Object} An object containing the new width and height.
44
+ * @throws {Error} Throws an error if the width or height is not a positive number.
45
+ */
46
+ export declare function zoomForGPT4o(originalWidth: number, originalHeight: number): {
47
+ width: number;
48
+ height: number;
49
+ };
50
+ export declare function photonFromBase64(base64: string): Promise<PhotonImageType>;
51
+ export declare function paddingToMatchBlock(image: PhotonImageType, blockSize?: number): Promise<{
52
+ width: number;
53
+ height: number;
54
+ image: PhotonImageType;
55
+ }>;
56
+ export declare function paddingToMatchBlockByBase64(imageBase64: string, blockSize?: number): Promise<{
57
+ width: number;
58
+ height: number;
59
+ imageBase64: string;
60
+ }>;
61
+ export declare function cropByRect(imageBase64: string, rect: Rect, paddingImage: boolean): Promise<{
62
+ width: number;
63
+ height: number;
64
+ imageBase64: string;
65
+ }>;
66
+ export declare function photonToBase64(image: PhotonImageType, quality?: number): Promise<string>;
67
+ export declare const httpImg2Base64: (url: string) => Promise<string>;
68
+ /**
69
+ * Convert image file to base64 string
70
+ * Because this method is synchronous, the npm package `sharp` cannot be used to detect the file type.
71
+ * TODO: convert to webp to reduce base64 size.
72
+ */
73
+ export declare const localImg2Base64: (imgPath: string, withoutHeader?: boolean) => string;
74
+ /**
75
+ * PreProcess image url to ensure image is accessible to LLM.
76
+ * @param url - The url of the image, it can be a http url or a base64 string or a file path
77
+ * @param convertHttpImage2Base64 - Whether to convert http image to base64, if true, the http image will be converted to base64, otherwise, the http image will be returned as is
78
+ * @returns The base64 string of the image (when convertHttpImage2Base64 is true or url is a file path) or the http image url
79
+ */
80
+ export declare const preProcessImageUrl: (url: string, convertHttpImage2Base64: boolean) => Promise<string>;
81
+ /**
82
+ * parse base64 string to get mimeType and body
83
+ */
84
+ export declare const parseBase64: (fullBase64String: string) => {
85
+ mimeType: string;
86
+ body: string;
87
+ };
88
+ /**
89
+ * Convert a base64 image to JPEG with specified quality (no resize).
90
+ * If the image is already JPEG, re-encodes at the given quality.
91
+ *
92
+ * @param inputBase64 - Full data-URI base64 string (e.g. "data:image/png;base64,...")
93
+ * @param quality - JPEG quality 1-100
94
+ * @returns JPEG data-URI base64 string
95
+ */
96
+ export declare function convertToJpegBase64(inputBase64: string, quality: number): Promise<string>;
97
+ /**
98
+ * Scales an image by a specified factor using Sharp or Photon
99
+ * @param imageBase64 - Base64 encoded image
100
+ * @param scale - Scale factor (e.g., 2 for 2x, 1.5 for 1.5x)
101
+ * @returns Scaled image with new dimensions
102
+ */
103
+ export declare function scaleImage(imageBase64: string, scale: number): Promise<{
104
+ width: number;
105
+ height: number;
106
+ imageBase64: string;
107
+ }>;
@@ -0,0 +1,4 @@
1
+ export { createCopyStaticPlugin, createPlaygroundCopyPlugin, } from './build/copy-static';
2
+ export { commonIgnoreWarnings } from './build/rspack-config';
3
+ declare const _default: {};
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export { createCopyStaticPlugin, createPlaygroundCopyPlugin, } from './build/copy-static';
2
+ export { commonIgnoreWarnings } from './build/rspack-config';
3
+ declare const _default: {};
4
+ export default _default;
@@ -0,0 +1,5 @@
1
+ export type DebugFunction = (...args: unknown[]) => void;
2
+ export declare function getDebug(topic: string, options?: {
3
+ console?: boolean;
4
+ }): DebugFunction;
5
+ export declare function enableDebug(topic: string): void;
@@ -0,0 +1,5 @@
1
+ export type DebugFunction = (...args: unknown[]) => void;
2
+ export declare function getDebug(topic: string, options?: {
3
+ console?: boolean;
4
+ }): DebugFunction;
5
+ export declare function enableDebug(topic: string): void;
@@ -0,0 +1,93 @@
1
+ import type { ParseArgsConfig } from 'node:util';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import type { IMidsceneTools } from './types';
4
+ export interface BaseMCPServerConfig {
5
+ name: string;
6
+ version: string;
7
+ description: string;
8
+ }
9
+ export interface HttpLaunchOptions {
10
+ port: number;
11
+ host?: string;
12
+ }
13
+ export interface LaunchMCPServerResult {
14
+ /**
15
+ * The MCP server port (for HTTP mode)
16
+ */
17
+ port?: number;
18
+ /**
19
+ * The server host (for HTTP mode)
20
+ */
21
+ host?: string;
22
+ /**
23
+ * Function to gracefully shutdown the MCP server
24
+ */
25
+ close: () => Promise<void>;
26
+ }
27
+ /**
28
+ * CLI argument configuration for MCP servers
29
+ */
30
+ export declare const CLI_ARGS_CONFIG: ParseArgsConfig['options'];
31
+ export interface CLIArgs {
32
+ mode?: string;
33
+ port?: string;
34
+ host?: string;
35
+ }
36
+ /**
37
+ * Launch an MCP server based on CLI arguments
38
+ * Shared helper to reduce duplication across platform CLI entry points
39
+ */
40
+ export declare function launchMCPServer(server: BaseMCPServer, args: CLIArgs): Promise<LaunchMCPServerResult>;
41
+ /**
42
+ * Base MCP Server class with programmatic launch() API
43
+ * Each platform extends this to provide their own tools manager
44
+ */
45
+ export declare abstract class BaseMCPServer {
46
+ protected mcpServer: McpServer;
47
+ protected toolsManager?: IMidsceneTools;
48
+ protected config: BaseMCPServerConfig;
49
+ protected providedToolsManager?: IMidsceneTools;
50
+ constructor(config: BaseMCPServerConfig, toolsManager?: IMidsceneTools);
51
+ /**
52
+ * Platform-specific: create tools manager instance
53
+ * This is only called if no tools manager was provided in constructor
54
+ */
55
+ protected abstract createToolsManager(): IMidsceneTools;
56
+ /**
57
+ * Initialize tools manager and attach to MCP server
58
+ */
59
+ private initializeToolsManager;
60
+ /**
61
+ * Perform cleanup on shutdown
62
+ */
63
+ private performCleanup;
64
+ /**
65
+ * Initialize and launch the MCP server with stdio transport
66
+ */
67
+ launch(): Promise<LaunchMCPServerResult>;
68
+ /**
69
+ * Launch MCP server with HTTP transport
70
+ * Supports stateful sessions for web applications and service integration
71
+ */
72
+ launchHttp(options: HttpLaunchOptions): Promise<LaunchMCPServerResult>;
73
+ /**
74
+ * Create a new HTTP session with transport
75
+ */
76
+ private createHttpSession;
77
+ /**
78
+ * Start periodic session cleanup for inactive sessions
79
+ */
80
+ private startSessionCleanup;
81
+ /**
82
+ * Setup shutdown handlers for HTTP server
83
+ */
84
+ private setupHttpShutdownHandlers;
85
+ /**
86
+ * Get the underlying MCP server instance
87
+ */
88
+ getServer(): McpServer;
89
+ /**
90
+ * Get the tools manager instance
91
+ */
92
+ getToolsManager(): IMidsceneTools | undefined;
93
+ }
@@ -0,0 +1,93 @@
1
+ import type { ParseArgsConfig } from 'node:util';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import type { IMidsceneTools } from './types';
4
+ export interface BaseMCPServerConfig {
5
+ name: string;
6
+ version: string;
7
+ description: string;
8
+ }
9
+ export interface HttpLaunchOptions {
10
+ port: number;
11
+ host?: string;
12
+ }
13
+ export interface LaunchMCPServerResult {
14
+ /**
15
+ * The MCP server port (for HTTP mode)
16
+ */
17
+ port?: number;
18
+ /**
19
+ * The server host (for HTTP mode)
20
+ */
21
+ host?: string;
22
+ /**
23
+ * Function to gracefully shutdown the MCP server
24
+ */
25
+ close: () => Promise<void>;
26
+ }
27
+ /**
28
+ * CLI argument configuration for MCP servers
29
+ */
30
+ export declare const CLI_ARGS_CONFIG: ParseArgsConfig['options'];
31
+ export interface CLIArgs {
32
+ mode?: string;
33
+ port?: string;
34
+ host?: string;
35
+ }
36
+ /**
37
+ * Launch an MCP server based on CLI arguments
38
+ * Shared helper to reduce duplication across platform CLI entry points
39
+ */
40
+ export declare function launchMCPServer(server: BaseMCPServer, args: CLIArgs): Promise<LaunchMCPServerResult>;
41
+ /**
42
+ * Base MCP Server class with programmatic launch() API
43
+ * Each platform extends this to provide their own tools manager
44
+ */
45
+ export declare abstract class BaseMCPServer {
46
+ protected mcpServer: McpServer;
47
+ protected toolsManager?: IMidsceneTools;
48
+ protected config: BaseMCPServerConfig;
49
+ protected providedToolsManager?: IMidsceneTools;
50
+ constructor(config: BaseMCPServerConfig, toolsManager?: IMidsceneTools);
51
+ /**
52
+ * Platform-specific: create tools manager instance
53
+ * This is only called if no tools manager was provided in constructor
54
+ */
55
+ protected abstract createToolsManager(): IMidsceneTools;
56
+ /**
57
+ * Initialize tools manager and attach to MCP server
58
+ */
59
+ private initializeToolsManager;
60
+ /**
61
+ * Perform cleanup on shutdown
62
+ */
63
+ private performCleanup;
64
+ /**
65
+ * Initialize and launch the MCP server with stdio transport
66
+ */
67
+ launch(): Promise<LaunchMCPServerResult>;
68
+ /**
69
+ * Launch MCP server with HTTP transport
70
+ * Supports stateful sessions for web applications and service integration
71
+ */
72
+ launchHttp(options: HttpLaunchOptions): Promise<LaunchMCPServerResult>;
73
+ /**
74
+ * Create a new HTTP session with transport
75
+ */
76
+ private createHttpSession;
77
+ /**
78
+ * Start periodic session cleanup for inactive sessions
79
+ */
80
+ private startSessionCleanup;
81
+ /**
82
+ * Setup shutdown handlers for HTTP server
83
+ */
84
+ private setupHttpShutdownHandlers;
85
+ /**
86
+ * Get the underlying MCP server instance
87
+ */
88
+ getServer(): McpServer;
89
+ /**
90
+ * Get the tools manager instance
91
+ */
92
+ getToolsManager(): IMidsceneTools | undefined;
93
+ }