publishport-opencli 1.0.19 → 1.0.21

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 (1042) hide show
  1. package/cli-manifest.json +35 -0
  2. package/clis/12306/me.js +2 -2
  3. package/clis/12306/orders.js +3 -3
  4. package/clis/12306/passengers.js +3 -3
  5. package/clis/12306/price.js +1 -1
  6. package/clis/12306/stations.js +1 -1
  7. package/clis/12306/train.js +1 -1
  8. package/clis/12306/trains.js +1 -1
  9. package/clis/12306/utils.js +1 -1
  10. package/clis/1688/download.js +1 -1
  11. package/clis/1688/item.js +4 -4
  12. package/clis/1688/search.js +4 -4
  13. package/clis/1688/store.js +4 -4
  14. package/clis/1point3acres/forum.js +1 -1
  15. package/clis/1point3acres/forums.js +1 -1
  16. package/clis/1point3acres/notifications.js +1 -1
  17. package/clis/1point3acres/search.js +1 -1
  18. package/clis/1point3acres/thread.js +2 -2
  19. package/clis/1point3acres/user.js +1 -1
  20. package/clis/1point3acres/utils.js +2 -2
  21. package/clis/36kr/article.js +2 -2
  22. package/clis/36kr/hot.js +2 -2
  23. package/clis/36kr/news.js +1 -1
  24. package/clis/36kr/search.js +2 -2
  25. package/clis/51job/company.js +2 -2
  26. package/clis/51job/detail.js +2 -2
  27. package/clis/51job/hot.js +1 -1
  28. package/clis/51job/search.js +1 -1
  29. package/clis/51job/utils.js +7 -7
  30. package/clis/_atlassian/shared.js +9 -9
  31. package/clis/_shared/article/auth.js +4 -4
  32. package/clis/_shared/article/douban-md2draft.js +4 -4
  33. package/clis/_shared/article/format.js +1 -1
  34. package/clis/_shared/article/images.js +7 -7
  35. package/clis/_shared/article/login.js +1 -1
  36. package/clis/_shared/article/publish.js +11 -11
  37. package/clis/_shared/common.js +1 -1
  38. package/clis/_shared/content-guard.js +1 -1
  39. package/clis/_shared/desktop-commands.js +1 -1
  40. package/clis/_shared/file-inject.js +12 -12
  41. package/clis/_shared/self-hosted-sites.js +2 -2
  42. package/clis/_shared/site-auth.js +1 -1
  43. package/clis/_shared/token-auth.js +2 -2
  44. package/clis/_shared/video-publish.js +9 -9
  45. package/clis/amazon/offer.js +3 -3
  46. package/clis/amazon/product.js +5 -5
  47. package/clis/amazon/shared.js +6 -6
  48. package/clis/antigravity/_actions.js +13 -13
  49. package/clis/antigravity/audit-extras.js +10 -10
  50. package/clis/antigravity/delete.js +1 -1
  51. package/clis/antigravity/model.js +6 -6
  52. package/clis/antigravity/new.js +2 -2
  53. package/clis/antigravity/read.js +2 -2
  54. package/clis/antigravity/rename.js +1 -1
  55. package/clis/antigravity/send.js +3 -3
  56. package/clis/antigravity/serve.js +17 -17
  57. package/clis/antigravity/storage.js +6 -6
  58. package/clis/antigravity/watch.js +2 -2
  59. package/clis/apple-podcasts/episodes.js +1 -1
  60. package/clis/apple-podcasts/top.js +1 -1
  61. package/clis/apple-podcasts/utils.js +1 -1
  62. package/clis/archive/item.js +1 -1
  63. package/clis/archive/search.js +1 -1
  64. package/clis/archive/snapshots.js +1 -1
  65. package/clis/archive/wayback.js +1 -1
  66. package/clis/arxiv/author.js +1 -1
  67. package/clis/arxiv/utils.js +1 -1
  68. package/clis/autohome/brand.js +1 -1
  69. package/clis/autohome/score.js +1 -1
  70. package/clis/autohome/utils.js +1 -1
  71. package/clis/baijiahao/article.js +1 -1
  72. package/clis/baijiahao/lists.js +1 -1
  73. package/clis/baijiahao/login.js +1 -1
  74. package/clis/baijiahao/publish.js +9 -9
  75. package/clis/baijiahao/stats.js +1 -1
  76. package/clis/baijiahao/whoami.js +1 -1
  77. package/clis/band/bands.js +2 -2
  78. package/clis/band/mentions.js +2 -2
  79. package/clis/band/post.js +4 -4
  80. package/clis/band/posts.js +3 -3
  81. package/clis/barchart/flow.js +3 -3
  82. package/clis/barchart/greeks.js +2 -2
  83. package/clis/barchart/quote.js +3 -3
  84. package/clis/bbc/news.js +1 -1
  85. package/clis/bbc/topic.js +1 -1
  86. package/clis/bbc/utils.js +1 -1
  87. package/clis/bilibili/article.js +1 -1
  88. package/clis/bilibili/categories.js +1 -1
  89. package/clis/bilibili/coin.js +1 -1
  90. package/clis/bilibili/comment-del.js +1 -1
  91. package/clis/bilibili/comment-like.js +1 -1
  92. package/clis/bilibili/comment.js +1 -1
  93. package/clis/bilibili/comments.js +1 -1
  94. package/clis/bilibili/dm-list.js +1 -1
  95. package/clis/bilibili/dm-read.js +1 -1
  96. package/clis/bilibili/dm-send.js +1 -1
  97. package/clis/bilibili/download.js +2 -2
  98. package/clis/bilibili/drafts.js +1 -1
  99. package/clis/bilibili/dynamic-post.js +3 -3
  100. package/clis/bilibili/favorite-add.js +1 -1
  101. package/clis/bilibili/favorite.js +1 -1
  102. package/clis/bilibili/feed.js +2 -2
  103. package/clis/bilibili/follow.js +1 -1
  104. package/clis/bilibili/following.js +1 -1
  105. package/clis/bilibili/like.js +1 -1
  106. package/clis/bilibili/partitions.js +1 -1
  107. package/clis/bilibili/stats.js +1 -1
  108. package/clis/bilibili/subtitle.js +3 -3
  109. package/clis/bilibili/summary.js +1 -1
  110. package/clis/bilibili/topics.js +1 -1
  111. package/clis/bilibili/unfollow.js +1 -1
  112. package/clis/bilibili/upload.js +1 -1
  113. package/clis/bilibili/utils.js +10 -10
  114. package/clis/bilibili/video-drafts.js +1 -1
  115. package/clis/bilibili/video.js +1 -1
  116. package/clis/bloomberg/businessweek.js +4 -4
  117. package/clis/bloomberg/news.js +2 -2
  118. package/clis/bloomberg/utils.js +13 -13
  119. package/clis/bluesky/post.js +1 -1
  120. package/clis/bluesky/shared.js +11 -11
  121. package/clis/bluesky/whoami.js +1 -1
  122. package/clis/booking/search.js +2 -2
  123. package/clis/boss/accept.js +1 -1
  124. package/clis/boss/applied.js +1 -1
  125. package/clis/boss/auth.js +1 -1
  126. package/clis/boss/batchgreet.js +1 -1
  127. package/clis/boss/bossinfo.js +1 -1
  128. package/clis/boss/chatlist.js +1 -1
  129. package/clis/boss/chatmsg.js +1 -1
  130. package/clis/boss/cities.js +1 -1
  131. package/clis/boss/detail.js +1 -1
  132. package/clis/boss/exchange.js +1 -1
  133. package/clis/boss/greet.js +1 -1
  134. package/clis/boss/interviews.js +1 -1
  135. package/clis/boss/invite.js +1 -1
  136. package/clis/boss/joblist.js +1 -1
  137. package/clis/boss/mark.js +1 -1
  138. package/clis/boss/me.js +2 -2
  139. package/clis/boss/recommend.js +1 -1
  140. package/clis/boss/resumedelete.js +1 -1
  141. package/clis/boss/resumelist.js +1 -1
  142. package/clis/boss/resumeupload.js +11 -11
  143. package/clis/boss/search.js +1 -1
  144. package/clis/boss/send.js +1 -1
  145. package/clis/boss/sendresume.js +1 -1
  146. package/clis/boss/stats.js +1 -1
  147. package/clis/boss/unread.js +1 -1
  148. package/clis/boss/utils.js +13 -13
  149. package/clis/chaoxing/assignments.js +1 -1
  150. package/clis/chaoxing/exams.js +1 -1
  151. package/clis/chaoxing/utils.js +9 -9
  152. package/clis/chatgpt/ask.js +1 -1
  153. package/clis/chatgpt/auth.js +2 -2
  154. package/clis/chatgpt/detail.js +1 -1
  155. package/clis/chatgpt/image.js +1 -1
  156. package/clis/chatgpt/read.js +1 -1
  157. package/clis/chatgpt/send.js +1 -1
  158. package/clis/chatgpt/utils.js +59 -59
  159. package/clis/chatgpt-app/ask.js +1 -1
  160. package/clis/chatgpt-app/send.js +1 -1
  161. package/clis/chatwise/model.js +6 -6
  162. package/clis/chess/analyze.js +1 -1
  163. package/clis/chess/game.js +1 -1
  164. package/clis/chess/games.js +1 -1
  165. package/clis/chess/stats.js +1 -1
  166. package/clis/chess/utils.js +1 -1
  167. package/clis/claude/ask.js +2 -2
  168. package/clis/claude/detail.js +1 -1
  169. package/clis/claude/new.js +1 -1
  170. package/clis/claude/read.js +1 -1
  171. package/clis/claude/send.js +1 -1
  172. package/clis/claude/utils.js +23 -23
  173. package/clis/cnblogs/article.js +1 -1
  174. package/clis/cnblogs/login.js +1 -1
  175. package/clis/cnblogs/stats.js +7 -7
  176. package/clis/cnblogs/whoami.js +1 -1
  177. package/clis/codex/_actions.js +3 -3
  178. package/clis/codex/archive.js +1 -1
  179. package/clis/codex/ask.js +6 -6
  180. package/clis/codex/model.js +8 -8
  181. package/clis/codex/pin.js +1 -1
  182. package/clis/codex/rename.js +4 -4
  183. package/clis/codex/send.js +3 -3
  184. package/clis/codex/sidebar.js +1 -1
  185. package/clis/coingecko/categories.js +1 -1
  186. package/clis/coingecko/coin.js +1 -1
  187. package/clis/coingecko/derivatives.js +1 -1
  188. package/clis/coingecko/exchanges.js +1 -1
  189. package/clis/coingecko/global.js +1 -1
  190. package/clis/coingecko/trending.js +1 -1
  191. package/clis/confluence/search.js +1 -1
  192. package/clis/coupang/product.js +3 -3
  193. package/clis/coupang/utils.js +1 -1
  194. package/clis/crates/crate.js +1 -1
  195. package/clis/crates/search.js +1 -1
  196. package/clis/crates/utils.js +1 -1
  197. package/clis/csdn/article.js +13 -13
  198. package/clis/csdn/columns.js +1 -1
  199. package/clis/csdn/login.js +1 -1
  200. package/clis/csdn/stats.js +4 -4
  201. package/clis/csdn/whoami.js +1 -1
  202. package/clis/cto51/article.js +1 -1
  203. package/clis/cto51/whoami.js +1 -1
  204. package/clis/ctrip/flight.js +2 -2
  205. package/clis/ctrip/hotel-search.js +3 -3
  206. package/clis/ctrip/hotel-suggest.js +1 -1
  207. package/clis/ctrip/search.js +1 -1
  208. package/clis/ctrip/utils.js +6 -6
  209. package/clis/cursor/ask.js +5 -5
  210. package/clis/cursor/composer.js +2 -2
  211. package/clis/cursor/model.js +4 -4
  212. package/clis/cursor/send.js +2 -2
  213. package/clis/dblp/author.js +1 -1
  214. package/clis/dblp/paper.js +1 -1
  215. package/clis/dblp/search.js +1 -1
  216. package/clis/dblp/utils.js +1 -1
  217. package/clis/dblp/venue.js +1 -1
  218. package/clis/deepseek/ask.js +1 -1
  219. package/clis/deepseek/auth.js +2 -2
  220. package/clis/deepseek/detail.js +1 -1
  221. package/clis/deepseek/new.js +1 -1
  222. package/clis/deepseek/read.js +1 -1
  223. package/clis/deepseek/send.js +7 -7
  224. package/clis/deepseek/utils.js +25 -25
  225. package/clis/defillama/protocol.js +1 -1
  226. package/clis/defillama/protocols.js +1 -1
  227. package/clis/defillama/utils.js +1 -1
  228. package/clis/devto/auth.js +2 -2
  229. package/clis/devto/latest.js +1 -1
  230. package/clis/devto/publish.js +5 -5
  231. package/clis/devto/read.js +2 -2
  232. package/clis/devto/stats.js +3 -3
  233. package/clis/dianping/auth.js +2 -2
  234. package/clis/dianping/cityResolver.js +2 -2
  235. package/clis/dianping/search.js +1 -1
  236. package/clis/dianping/shop.js +1 -1
  237. package/clis/dianping/utils.js +1 -1
  238. package/clis/discord-app/delete.js +3 -3
  239. package/clis/discord-app/read.js +1 -1
  240. package/clis/discord-app/thread-read.js +1 -1
  241. package/clis/discord-web/auth.js +2 -2
  242. package/clis/discord-web/send.js +5 -5
  243. package/clis/dockerhub/image.js +1 -1
  244. package/clis/dockerhub/search.js +1 -1
  245. package/clis/dockerhub/utils.js +1 -1
  246. package/clis/dongchedi/koubei.js +1 -1
  247. package/clis/dongchedi/models.js +1 -1
  248. package/clis/dongchedi/score.js +1 -1
  249. package/clis/dongchedi/search.js +1 -1
  250. package/clis/dongchedi/series.js +1 -1
  251. package/clis/dongchedi/specs.js +1 -1
  252. package/clis/dongchedi/utils.js +1 -1
  253. package/clis/douban/article.js +3 -3
  254. package/clis/douban/auth.js +2 -2
  255. package/clis/douban/download.js +1 -1
  256. package/clis/douban/utils.js +23 -23
  257. package/clis/doubao/auth.js +3 -3
  258. package/clis/doubao/utils.js +39 -39
  259. package/clis/doubao-app/ask.js +1 -1
  260. package/clis/doubao-app/utils.js +4 -4
  261. package/clis/douyin/_shared/browser-fetch.js +7 -7
  262. package/clis/douyin/_shared/draft-cache.js +1 -1
  263. package/clis/douyin/_shared/imagex-upload.js +1 -1
  264. package/clis/douyin/_shared/sts2.js +1 -1
  265. package/clis/douyin/_shared/text-extra.js +1 -1
  266. package/clis/douyin/_shared/tos-upload.js +4 -4
  267. package/clis/douyin/_shared/transcode.js +1 -1
  268. package/clis/douyin/_shared/vod-upload.js +4 -4
  269. package/clis/douyin/draft.js +18 -18
  270. package/clis/douyin/drafts.js +1 -1
  271. package/clis/douyin/publish-image.js +12 -12
  272. package/clis/douyin/publish.js +9 -9
  273. package/clis/douyin/search.js +3 -3
  274. package/clis/douyin/videos.js +1 -1
  275. package/clis/eastmoney/_secid.js +1 -1
  276. package/clis/eastmoney/announcement.js +1 -1
  277. package/clis/eastmoney/article.js +1 -1
  278. package/clis/eastmoney/convertible.js +1 -1
  279. package/clis/eastmoney/etf.js +1 -1
  280. package/clis/eastmoney/holders.js +1 -1
  281. package/clis/eastmoney/index-board.js +1 -1
  282. package/clis/eastmoney/kline.js +1 -1
  283. package/clis/eastmoney/kuaixun.js +1 -1
  284. package/clis/eastmoney/longhu.js +1 -1
  285. package/clis/eastmoney/money-flow.js +1 -1
  286. package/clis/eastmoney/northbound.js +1 -1
  287. package/clis/eastmoney/quote.js +1 -1
  288. package/clis/eastmoney/rank.js +1 -1
  289. package/clis/eastmoney/sectors.js +1 -1
  290. package/clis/endoflife/product.js +1 -1
  291. package/clis/endoflife/utils.js +1 -1
  292. package/clis/facebook/comment.js +8 -8
  293. package/clis/facebook/feed.js +4 -4
  294. package/clis/facebook/like.js +5 -5
  295. package/clis/facebook/notifications.js +3 -3
  296. package/clis/facebook/post.js +11 -11
  297. package/clis/facebook/search.js +3 -3
  298. package/clis/flathub/app.js +1 -1
  299. package/clis/flathub/search.js +1 -1
  300. package/clis/flathub/utils.js +1 -1
  301. package/clis/flomo/memos.js +1 -1
  302. package/clis/gemini/deep-research-result.js +4 -4
  303. package/clis/gemini/deep-research.js +1 -1
  304. package/clis/gemini/detail.js +1 -1
  305. package/clis/gemini/history.js +1 -1
  306. package/clis/gemini/image.js +2 -2
  307. package/clis/gemini/status.js +1 -1
  308. package/clis/gemini/utils.js +43 -43
  309. package/clis/geogebra/hexagon.js +1 -1
  310. package/clis/geogebra/info.js +3 -3
  311. package/clis/geogebra/triangle.js +1 -1
  312. package/clis/geogebra/utils.js +11 -11
  313. package/clis/ghost/login.js +1 -1
  314. package/clis/ghost/shared.js +2 -2
  315. package/clis/gitee/auth.js +2 -2
  316. package/clis/github-trending/repos.js +1 -1
  317. package/clis/google/news.js +1 -1
  318. package/clis/google/search.js +2 -2
  319. package/clis/google/suggest.js +1 -1
  320. package/clis/google/trends.js +1 -1
  321. package/clis/google/utils.js +1 -1
  322. package/clis/goproxy/module.js +1 -1
  323. package/clis/goproxy/utils.js +1 -1
  324. package/clis/goproxy/versions.js +1 -1
  325. package/clis/gov-policy/recent.js +2 -2
  326. package/clis/gov-policy/search.js +2 -2
  327. package/clis/grok/ask.js +1 -1
  328. package/clis/grok/detail.js +1 -1
  329. package/clis/grok/image.js +8 -8
  330. package/clis/grok/pin.js +1 -1
  331. package/clis/grok/send.js +1 -1
  332. package/clis/grok/status.js +1 -1
  333. package/clis/grok/utils.js +21 -21
  334. package/clis/guazi/browse.js +1 -1
  335. package/clis/guazi/car.js +1 -1
  336. package/clis/guazi/utils.js +1 -1
  337. package/clis/hackernews/auth.js +2 -2
  338. package/clis/hackernews/comment.js +8 -8
  339. package/clis/hackernews/read.js +7 -7
  340. package/clis/hackernews/submit.js +7 -7
  341. package/clis/hashnode/auth.js +3 -3
  342. package/clis/hashnode/publish.js +14 -14
  343. package/clis/hf/auth.js +2 -2
  344. package/clis/hf/models.js +1 -1
  345. package/clis/hf/paper.js +1 -1
  346. package/clis/hf/spaces.js +1 -1
  347. package/clis/hf/top.js +1 -1
  348. package/clis/homebrew/cask.js +1 -1
  349. package/clis/homebrew/formula.js +1 -1
  350. package/clis/homebrew/popular.js +1 -1
  351. package/clis/homebrew/utils.js +1 -1
  352. package/clis/huodongxing/events.js +1 -1
  353. package/clis/hupu/detail.js +4 -4
  354. package/clis/hupu/hot.js +3 -3
  355. package/clis/hupu/reply.js +1 -1
  356. package/clis/hupu/search.js +1 -1
  357. package/clis/hupu/unlike.js +1 -1
  358. package/clis/hupu/utils.js +10 -10
  359. package/clis/imdb/person.js +2 -2
  360. package/clis/imdb/reviews.js +3 -3
  361. package/clis/imdb/search.js +2 -2
  362. package/clis/imdb/title.js +1 -1
  363. package/clis/imdb/top.js +1 -1
  364. package/clis/imdb/trending.js +1 -1
  365. package/clis/imdb/utils.js +13 -13
  366. package/clis/imooc/article.js +6 -6
  367. package/clis/imooc/login.js +1 -1
  368. package/clis/imooc/whoami.js +1 -1
  369. package/clis/indeed/job.js +2 -2
  370. package/clis/indeed/search.js +2 -2
  371. package/clis/indeed/utils.js +1 -1
  372. package/clis/infoq/article.js +2 -2
  373. package/clis/infoq/login.js +1 -1
  374. package/clis/infoq/whoami.js +1 -1
  375. package/clis/instagram/_shared/private-publish.js +4 -4
  376. package/clis/instagram/_shared/protocol-capture.js +9 -9
  377. package/clis/instagram/detail.js +3 -3
  378. package/clis/instagram/post.js +25 -25
  379. package/clis/instagram/reel.js +18 -18
  380. package/clis/instagram/story.js +4 -4
  381. package/clis/instagram/user.js +2 -2
  382. package/clis/jd/item.js +65 -65
  383. package/clis/jianshu/article.js +1 -1
  384. package/clis/jianshu/login.js +1 -1
  385. package/clis/jianshu/notebooks.js +1 -1
  386. package/clis/jianshu/whoami.js +1 -1
  387. package/clis/jianyu/search.js +6 -6
  388. package/clis/jianyu/shared/procurement-contract.js +1 -1
  389. package/clis/jike/api.js +6 -6
  390. package/clis/jike/auth.js +3 -3
  391. package/clis/jike/comment.js +1 -1
  392. package/clis/jike/create.js +6 -6
  393. package/clis/jike/feed.js +3 -3
  394. package/clis/jike/like.js +1 -1
  395. package/clis/jike/notifications.js +3 -3
  396. package/clis/jike/repost.js +13 -13
  397. package/clis/jike/search.js +3 -3
  398. package/clis/jimeng/auth.js +2 -2
  399. package/clis/jimeng/generate.js +10 -10
  400. package/clis/jira/shared.js +1 -1
  401. package/clis/juejin/article.js +4 -4
  402. package/clis/juejin/categories.js +1 -1
  403. package/clis/juejin/hot.js +1 -1
  404. package/clis/juejin/login.js +1 -1
  405. package/clis/juejin/recommend.js +1 -1
  406. package/clis/juejin/stats.js +3 -3
  407. package/clis/juejin/tags.js +1 -1
  408. package/clis/juejin/utils.js +1 -1
  409. package/clis/juejin/whoami.js +1 -1
  410. package/clis/ke/utils.js +4 -4
  411. package/clis/kimi/_utils.js +7 -7
  412. package/clis/kimi/audit-extras.js +14 -14
  413. package/clis/kimi/auth.js +3 -3
  414. package/clis/kimi/chat.js +15 -15
  415. package/clis/kimi/storage.js +5 -5
  416. package/clis/kimi/ui.js +13 -13
  417. package/clis/kimi/usage.js +3 -3
  418. package/clis/kuaishou/auth.js +1 -1
  419. package/clis/kuaishou/publish.js +6 -6
  420. package/clis/lesswrong/_helpers.js +5 -5
  421. package/clis/lesswrong/comments.js +5 -5
  422. package/clis/lichess/top.js +1 -1
  423. package/clis/lichess/user.js +1 -1
  424. package/clis/lichess/utils.js +1 -1
  425. package/clis/linkedin/comment.js +1 -1
  426. package/clis/linkedin/connect.js +11 -11
  427. package/clis/linkedin/create.js +5 -5
  428. package/clis/linkedin/follow.js +1 -1
  429. package/clis/linkedin/inbox.js +1 -1
  430. package/clis/linkedin/job-detail.js +3 -3
  431. package/clis/linkedin/like.js +1 -1
  432. package/clis/linkedin/notifications.js +1 -1
  433. package/clis/linkedin/people-search.js +1 -1
  434. package/clis/linkedin/post-comments.js +1 -1
  435. package/clis/linkedin/post-detail.js +1 -1
  436. package/clis/linkedin/profile-analytics.js +1 -1
  437. package/clis/linkedin/profile-api.js +13 -13
  438. package/clis/linkedin/profile-experience.js +1 -1
  439. package/clis/linkedin/profile-projects.js +1 -1
  440. package/clis/linkedin/profile-read.js +3 -3
  441. package/clis/linkedin/reply.js +1 -1
  442. package/clis/linkedin/repost.js +1 -1
  443. package/clis/linkedin/safe-send.js +8 -8
  444. package/clis/linkedin/salesnav-inbox.js +5 -5
  445. package/clis/linkedin/salesnav-message.js +3 -3
  446. package/clis/linkedin/salesnav-search.js +4 -4
  447. package/clis/linkedin/salesnav-thread.js +1 -1
  448. package/clis/linkedin/search-api.js +3 -3
  449. package/clis/linkedin/search.js +8 -8
  450. package/clis/linkedin/social-api.js +31 -31
  451. package/clis/linkedin/timeline.js +3 -3
  452. package/clis/linkedin-learning/search.js +2 -2
  453. package/clis/linkedin-learning/trending.js +2 -2
  454. package/clis/linux-do/feed.js +4 -4
  455. package/clis/linux-do/topic-content.js +8 -8
  456. package/clis/lobsters/domain.js +1 -1
  457. package/clis/lobsters/read.js +7 -7
  458. package/clis/maimai/auth.js +2 -2
  459. package/clis/maimai/search-talents.js +4 -4
  460. package/clis/manus/_utils.js +1 -1
  461. package/clis/mastodon/login.js +1 -1
  462. package/clis/mastodon/post.js +1 -1
  463. package/clis/mastodon/shared.js +12 -12
  464. package/clis/mastodon/whoami.js +1 -1
  465. package/clis/maven/artifact.js +1 -1
  466. package/clis/maven/search.js +1 -1
  467. package/clis/maven/utils.js +1 -1
  468. package/clis/mdn/search.js +1 -1
  469. package/clis/medium/article.js +5 -5
  470. package/clis/medium/login.js +1 -1
  471. package/clis/medium/stats.js +3 -3
  472. package/clis/medium/tag.js +1 -1
  473. package/clis/medium/whoami.js +1 -1
  474. package/clis/mubu/notes.js +1 -1
  475. package/clis/mubu/utils.js +15 -15
  476. package/clis/note/auth.js +2 -2
  477. package/clis/note/note-utils.js +2 -2
  478. package/clis/note/publish.js +8 -8
  479. package/clis/notebooklm/add-source.js +8 -8
  480. package/clis/notebooklm/create.js +1 -1
  481. package/clis/notebooklm/generate-slides.js +1 -1
  482. package/clis/notebooklm/notes-get.js +1 -1
  483. package/clis/notebooklm/rpc.js +8 -8
  484. package/clis/notebooklm/source-fulltext.js +1 -1
  485. package/clis/notebooklm/utils.js +10 -10
  486. package/clis/nowcoder/auth.js +2 -2
  487. package/clis/nowcoder/comment.js +1 -1
  488. package/clis/nowcoder/comments.js +1 -1
  489. package/clis/nowcoder/dm-list.js +1 -1
  490. package/clis/nowcoder/dm-read.js +1 -1
  491. package/clis/nowcoder/dm-send.js +1 -1
  492. package/clis/nowcoder/drafts.js +1 -1
  493. package/clis/nowcoder/inbox.js +1 -1
  494. package/clis/nowcoder/like.js +1 -1
  495. package/clis/nowcoder/my.js +1 -1
  496. package/clis/nowcoder/post.js +1 -1
  497. package/clis/nowcoder/utils.js +13 -13
  498. package/clis/npm/downloads.js +1 -1
  499. package/clis/npm/package.js +1 -1
  500. package/clis/npm/search.js +1 -1
  501. package/clis/npm/utils.js +1 -1
  502. package/clis/nuget/package.js +1 -1
  503. package/clis/nuget/search.js +1 -1
  504. package/clis/nuget/utils.js +1 -1
  505. package/clis/nvd/cve.js +1 -1
  506. package/clis/oeis/search.js +1 -1
  507. package/clis/oeis/sequence.js +1 -1
  508. package/clis/oeis/utils.js +1 -1
  509. package/clis/ones/common.js +6 -6
  510. package/clis/ones/enrich-tasks.js +1 -1
  511. package/clis/ones/my-tasks.js +1 -1
  512. package/clis/ones/resolve-labels.js +1 -1
  513. package/clis/ones/task-helpers.js +1 -1
  514. package/clis/ones/task.js +1 -1
  515. package/clis/ones/worklog.js +7 -7
  516. package/clis/openalex/search.js +1 -1
  517. package/clis/openalex/utils.js +1 -1
  518. package/clis/openalex/work.js +1 -1
  519. package/clis/openfda/drug-label.js +1 -1
  520. package/clis/openfda/food-recall.js +1 -1
  521. package/clis/openfda/utils.js +1 -1
  522. package/clis/openreview/author.js +1 -1
  523. package/clis/openreview/paper.js +1 -1
  524. package/clis/openreview/reviews.js +3 -3
  525. package/clis/openreview/search.js +1 -1
  526. package/clis/openreview/utils.js +1 -1
  527. package/clis/openreview/venue.js +1 -1
  528. package/clis/oschina/article.js +1 -1
  529. package/clis/oschina/catalogs.js +1 -1
  530. package/clis/oschina/login.js +1 -1
  531. package/clis/oschina/stats.js +6 -6
  532. package/clis/oschina/whoami.js +1 -1
  533. package/clis/osv/query.js +1 -1
  534. package/clis/osv/utils.js +1 -1
  535. package/clis/osv/vulnerability.js +1 -1
  536. package/clis/packagist/package.js +1 -1
  537. package/clis/packagist/search.js +1 -1
  538. package/clis/packagist/utils.js +1 -1
  539. package/clis/pinterest/api.js +1 -1
  540. package/clis/pinterest/auth.js +1 -1
  541. package/clis/pinterest/boards.js +1 -1
  542. package/clis/pinterest/client.js +6 -6
  543. package/clis/pinterest/publish.js +5 -5
  544. package/clis/pixiv/auth.js +2 -2
  545. package/clis/pixiv/download.js +1 -1
  546. package/clis/pixiv/illusts.js +1 -1
  547. package/clis/pixiv/search.js +1 -1
  548. package/clis/pixiv/utils.js +3 -3
  549. package/clis/powerchina/auth.js +2 -2
  550. package/clis/powerchina/search.js +1 -1
  551. package/clis/producthunt/browse.js +2 -2
  552. package/clis/producthunt/hot.js +2 -2
  553. package/clis/producthunt/posts.js +1 -1
  554. package/clis/producthunt/today.js +1 -1
  555. package/clis/producthunt/utils.js +1 -1
  556. package/clis/pypi/downloads.js +1 -1
  557. package/clis/pypi/package.js +1 -1
  558. package/clis/pypi/utils.js +1 -1
  559. package/clis/qiita/auth.js +1 -1
  560. package/clis/qiita/gql.js +6 -6
  561. package/clis/qiita/publish.js +4 -4
  562. package/clis/qiita/stats.js +4 -4
  563. package/clis/qoder/_utils.js +16 -16
  564. package/clis/qoder/composer.js +1 -1
  565. package/clis/qoder/quest.js +1 -1
  566. package/clis/qoder/ui.js +14 -14
  567. package/clis/quark/auth.js +2 -2
  568. package/clis/quark/utils.js +2 -2
  569. package/clis/quora/answer-comments.js +3 -3
  570. package/clis/quora/create-answer.js +4 -4
  571. package/clis/quora/create-question.js +3 -3
  572. package/clis/quora/shared.js +17 -17
  573. package/clis/quora/whoami.js +1 -1
  574. package/clis/qwen/ask.js +1 -1
  575. package/clis/qwen/auth.js +3 -3
  576. package/clis/qwen/detail.js +1 -1
  577. package/clis/qwen/image.js +5 -5
  578. package/clis/qwen/status.js +1 -1
  579. package/clis/qwen/utils.js +16 -16
  580. package/clis/reddit/home.js +3 -3
  581. package/clis/reddit/read.js +10 -10
  582. package/clis/reddit/reply.js +4 -4
  583. package/clis/reddit/submit.js +11 -11
  584. package/clis/reddit/subreddit-info.js +3 -3
  585. package/clis/reddit/subscribed.js +4 -4
  586. package/clis/reddit/whoami.js +2 -2
  587. package/clis/rednote/comments.js +1 -1
  588. package/clis/rednote/download.js +1 -1
  589. package/clis/rednote/feed.js +1 -1
  590. package/clis/rednote/note.js +1 -1
  591. package/clis/rednote/notifications.js +2 -2
  592. package/clis/rednote/search.js +2 -2
  593. package/clis/rest-countries/country.js +1 -1
  594. package/clis/rest-countries/region.js +1 -1
  595. package/clis/rest-countries/utils.js +1 -1
  596. package/clis/reuters/article-detail.js +1 -1
  597. package/clis/reuters/auth.js +3 -3
  598. package/clis/reuters/search.js +1 -1
  599. package/clis/reuters/utils.js +4 -4
  600. package/clis/rfc/rfc.js +1 -1
  601. package/clis/rfc/utils.js +1 -1
  602. package/clis/rubygems/gem.js +1 -1
  603. package/clis/rubygems/search.js +1 -1
  604. package/clis/rubygems/utils.js +1 -1
  605. package/clis/segmentfault/article.js +3 -3
  606. package/clis/segmentfault/channels.js +1 -1
  607. package/clis/segmentfault/login.js +1 -1
  608. package/clis/segmentfault/stats.js +4 -4
  609. package/clis/segmentfault/tags.js +1 -1
  610. package/clis/segmentfault/whoami.js +1 -1
  611. package/clis/semanticscholar/citations.js +1 -1
  612. package/clis/semanticscholar/paper.js +1 -1
  613. package/clis/semanticscholar/recommendations.js +1 -1
  614. package/clis/semanticscholar/search.js +1 -1
  615. package/clis/semanticscholar/utils.js +1 -1
  616. package/clis/sinafinance/news.js +1 -1
  617. package/clis/sinafinance/stock-rank.js +1 -1
  618. package/clis/sinafinance/stock.js +1 -1
  619. package/clis/slock/attachment-download.js +1 -1
  620. package/clis/slock/attachment-upload.js +7 -7
  621. package/clis/slock/attachment-url.js +1 -1
  622. package/clis/slock/auth-verify.js +1 -1
  623. package/clis/slock/bookmark-add.js +1 -1
  624. package/clis/slock/bookmark-remove.js +1 -1
  625. package/clis/slock/channel-action.js +1 -1
  626. package/clis/slock/channel-create.js +1 -1
  627. package/clis/slock/channel-files.js +1 -1
  628. package/clis/slock/channel-list.js +1 -1
  629. package/clis/slock/channel-mark.js +1 -1
  630. package/clis/slock/channel-members.js +1 -1
  631. package/clis/slock/channel-unarchive.js +1 -1
  632. package/clis/slock/dm-list.js +1 -1
  633. package/clis/slock/errors.js +1 -1
  634. package/clis/slock/in-page.js +28 -28
  635. package/clis/slock/inbox-done.js +5 -5
  636. package/clis/slock/inbox.js +1 -1
  637. package/clis/slock/message-read.js +22 -22
  638. package/clis/slock/message-search.js +10 -10
  639. package/clis/slock/message-send.js +25 -25
  640. package/clis/slock/reaction-add.js +1 -1
  641. package/clis/slock/reaction-remove.js +1 -1
  642. package/clis/slock/resolve.js +1 -1
  643. package/clis/slock/server-list.js +2 -2
  644. package/clis/slock/task-claim.js +4 -4
  645. package/clis/slock/task-convert.js +13 -13
  646. package/clis/slock/task-create.js +1 -1
  647. package/clis/slock/task-delete.js +5 -5
  648. package/clis/slock/task-get.js +5 -5
  649. package/clis/slock/task-list-server.js +4 -4
  650. package/clis/slock/task-list.js +5 -5
  651. package/clis/slock/task-status.js +3 -3
  652. package/clis/slock/task-unclaim.js +3 -3
  653. package/clis/slock/thread-follow.js +1 -1
  654. package/clis/slock/thread-state.js +1 -1
  655. package/clis/slock/unread-summary.js +5 -5
  656. package/clis/slock/whoami.js +1 -1
  657. package/clis/smzdm/search.js +3 -3
  658. package/clis/sohu/article.js +1 -1
  659. package/clis/sohu/attributes.js +1 -1
  660. package/clis/sohu/categories.js +1 -1
  661. package/clis/sohu/channels.js +1 -1
  662. package/clis/sohu/columns.js +1 -1
  663. package/clis/sohu/login.js +1 -1
  664. package/clis/sohu/stats.js +3 -3
  665. package/clis/sohu/topics.js +1 -1
  666. package/clis/sohu/whoami.js +1 -1
  667. package/clis/spotify/spotify.js +1 -1
  668. package/clis/stackoverflow/read.js +6 -6
  669. package/clis/stackoverflow/related.js +1 -1
  670. package/clis/stackoverflow/tag.js +1 -1
  671. package/clis/stackoverflow/user.js +1 -1
  672. package/clis/stackoverflow/utils.js +1 -1
  673. package/clis/steam/app.js +1 -1
  674. package/clis/steam/search.js +1 -1
  675. package/clis/steam/utils.js +1 -1
  676. package/clis/substack/auth.js +2 -2
  677. package/clis/substack/post-utils.js +2 -2
  678. package/clis/substack/publish.js +5 -5
  679. package/clis/suno/auth.js +2 -2
  680. package/clis/suno/download.js +5 -5
  681. package/clis/suno/generate.js +3 -3
  682. package/clis/suno/list.js +1 -1
  683. package/clis/suno/status.js +1 -1
  684. package/clis/suno/utils.js +29 -29
  685. package/clis/telegram/send.js +7 -7
  686. package/clis/telegram/shared.js +2 -2
  687. package/clis/telegram/whoami.js +1 -1
  688. package/clis/test-utils.js +1 -1
  689. package/clis/threads/post.js +23 -23
  690. package/clis/threads/shared.js +3 -3
  691. package/clis/threads/whoami.js +1 -1
  692. package/clis/tieba/hot.js +3 -3
  693. package/clis/tieba/posts.js +1 -1
  694. package/clis/tieba/read.js +2 -2
  695. package/clis/tieba/search.js +3 -3
  696. package/clis/tieba/utils.js +1 -1
  697. package/clis/tiktok/comment.js +2 -2
  698. package/clis/tiktok/creator-videos.js +3 -3
  699. package/clis/tiktok/explore.js +3 -3
  700. package/clis/tiktok/follow.js +8 -8
  701. package/clis/tiktok/following.js +4 -4
  702. package/clis/tiktok/friends.js +7 -7
  703. package/clis/tiktok/live.js +3 -3
  704. package/clis/tiktok/notifications.js +6 -6
  705. package/clis/tiktok/publish.js +16 -16
  706. package/clis/tiktok/unfollow.js +4 -4
  707. package/clis/tiktok/user.js +2 -2
  708. package/clis/tiktok/utils.js +1 -1
  709. package/clis/toutiao/article.js +1 -1
  710. package/clis/toutiao/articles.js +2 -2
  711. package/clis/toutiao/auth.js +2 -2
  712. package/clis/toutiao/hot.js +1 -1
  713. package/clis/toutiao/recommend.js +1 -1
  714. package/clis/toutiao/utils.js +2 -2
  715. package/clis/trae-solo/_actions.js +4 -4
  716. package/clis/trae-solo/_fs.js +5 -5
  717. package/clis/trae-solo/_state.js +2 -2
  718. package/clis/trae-solo/automation.js +4 -4
  719. package/clis/trae-solo/mode.js +4 -4
  720. package/clis/trae-solo/model.js +4 -4
  721. package/clis/trae-solo/renderer-storage.js +4 -4
  722. package/clis/trae-solo/settings.js +1 -1
  723. package/clis/trae-solo/skill-fs.js +1 -1
  724. package/clis/trae-solo/skill.js +12 -12
  725. package/clis/trae-solo/state-fs.js +2 -2
  726. package/clis/trae-solo/task-fs.js +5 -5
  727. package/clis/trae-solo/workspaces-fs.js +1 -1
  728. package/clis/tumblr/auth.js +2 -2
  729. package/clis/tumblr/publish.js +3 -3
  730. package/clis/tvmaze/search.js +1 -1
  731. package/clis/tvmaze/show.js +1 -1
  732. package/clis/tvmaze/utils.js +1 -1
  733. package/clis/twitter/accept.js +7 -7
  734. package/clis/twitter/article.js +7 -7
  735. package/clis/twitter/bookmark-folder.js +3 -3
  736. package/clis/twitter/bookmark-folders.js +3 -3
  737. package/clis/twitter/bookmarks.js +4 -4
  738. package/clis/twitter/delete.js +5 -5
  739. package/clis/twitter/device-follow.js +3 -3
  740. package/clis/twitter/dm-list.js +1 -1
  741. package/clis/twitter/dm-read.js +1 -1
  742. package/clis/twitter/dm-send.js +5 -5
  743. package/clis/twitter/dm-shared.js +3 -3
  744. package/clis/twitter/download.js +6 -6
  745. package/clis/twitter/followers.js +5 -5
  746. package/clis/twitter/following.js +2 -2
  747. package/clis/twitter/like.js +3 -3
  748. package/clis/twitter/likes.js +8 -8
  749. package/clis/twitter/list-add-core.js +9 -9
  750. package/clis/twitter/list-create.js +5 -5
  751. package/clis/twitter/list-remove-core.js +9 -9
  752. package/clis/twitter/list-tweets.js +7 -7
  753. package/clis/twitter/lists.js +6 -6
  754. package/clis/twitter/notifications.js +2 -2
  755. package/clis/twitter/post.js +24 -24
  756. package/clis/twitter/profile.js +7 -7
  757. package/clis/twitter/quote.js +7 -7
  758. package/clis/twitter/reply-dm.js +7 -7
  759. package/clis/twitter/reply.js +12 -12
  760. package/clis/twitter/retweet.js +3 -3
  761. package/clis/twitter/scheduled-delete.js +3 -3
  762. package/clis/twitter/scheduled-list.js +2 -2
  763. package/clis/twitter/scheduled-utils.js +3 -3
  764. package/clis/twitter/search.js +5 -5
  765. package/clis/twitter/shared.js +6 -6
  766. package/clis/twitter/thread.js +4 -4
  767. package/clis/twitter/timeline.js +3 -3
  768. package/clis/twitter/trending.js +2 -2
  769. package/clis/twitter/tweets.js +11 -11
  770. package/clis/twitter/unlike.js +3 -3
  771. package/clis/twitter/unretweet.js +3 -3
  772. package/clis/twitter/utils.js +6 -6
  773. package/clis/upwork/detail.js +2 -2
  774. package/clis/upwork/feed.js +2 -2
  775. package/clis/upwork/search.js +2 -2
  776. package/clis/upwork/utils.js +1 -1
  777. package/clis/v2ex/auth.js +2 -2
  778. package/clis/v2ex/daily.js +3 -3
  779. package/clis/v2ex/me.js +2 -2
  780. package/clis/v2ex/notifications.js +2 -2
  781. package/clis/vk/post.js +1 -1
  782. package/clis/vk/shared.js +2 -2
  783. package/clis/vk/whoami.js +1 -1
  784. package/clis/web/read.js +8 -8
  785. package/clis/wechat-channels/auth.js +2 -2
  786. package/clis/wechat-channels/publish.js +30 -30
  787. package/clis/weibo/article.js +1 -1
  788. package/clis/weibo/auth.js +3 -3
  789. package/clis/weibo/comments.js +1 -1
  790. package/clis/weibo/delete.js +2 -2
  791. package/clis/weibo/feed.js +3 -3
  792. package/clis/weibo/hot.js +1 -1
  793. package/clis/weibo/publish.js +10 -10
  794. package/clis/weibo/search.js +2 -2
  795. package/clis/weibo/user-posts.js +3 -3
  796. package/clis/weibo/user.js +2 -2
  797. package/clis/weibo/utils.js +3 -3
  798. package/clis/weixin/article.js +1 -1
  799. package/clis/weixin/create-draft.js +26 -26
  800. package/clis/weixin/download.js +2 -2
  801. package/clis/weixin/login.js +1 -1
  802. package/clis/weixin/search.js +2 -2
  803. package/clis/weixin/stats.js +3 -3
  804. package/clis/weixin/whoami.js +1 -1
  805. package/clis/weread/ai-outline.js +2 -2
  806. package/clis/weread/book-search.js +2 -2
  807. package/clis/weread/book.js +2 -2
  808. package/clis/weread/notebooks.js +1 -1
  809. package/clis/weread/search.js +1 -1
  810. package/clis/weread/shelf.js +1 -1
  811. package/clis/weread/utils.js +6 -6
  812. package/clis/weread-official/book.js +1 -1
  813. package/clis/weread-official/discover.js +1 -1
  814. package/clis/weread-official/list-apis.js +1 -1
  815. package/clis/weread-official/notes.js +1 -1
  816. package/clis/weread-official/readdata.js +1 -1
  817. package/clis/weread-official/review.js +1 -1
  818. package/clis/weread-official/search.js +1 -1
  819. package/clis/weread-official/shelf.js +1 -1
  820. package/clis/weread-official/utils.js +1 -1
  821. package/clis/wikidata/entity.js +1 -1
  822. package/clis/wikidata/search.js +1 -1
  823. package/clis/wikidata/utils.js +1 -1
  824. package/clis/wikipedia/page.js +1 -1
  825. package/clis/wikipedia/trending.js +1 -1
  826. package/clis/wikipedia/utils.js +1 -1
  827. package/clis/wordpress/login.js +1 -1
  828. package/clis/wordpress/publish.js +1 -1
  829. package/clis/wordpress/shared.js +3 -3
  830. package/clis/wordpress/whoami.js +1 -1
  831. package/clis/woshipm/article.js +1 -1
  832. package/clis/woshipm/login.js +1 -1
  833. package/clis/woshipm/stats.js +4 -4
  834. package/clis/woshipm/whoami.js +1 -1
  835. package/clis/wttr/current.js +1 -1
  836. package/clis/wttr/forecast.js +1 -1
  837. package/clis/wttr/utils.js +1 -1
  838. package/clis/xianyu/collect.js +1 -1
  839. package/clis/xianyu/inbox.js +1 -1
  840. package/clis/xianyu/item-stats.js +2 -2
  841. package/clis/xianyu/location.js +1 -1
  842. package/clis/xianyu/manage.js +1 -1
  843. package/clis/xianyu/messages.js +1 -1
  844. package/clis/xianyu/mtop.js +5 -5
  845. package/clis/xianyu/order.js +1 -1
  846. package/clis/xianyu/promote-stats.js +2 -2
  847. package/clis/xianyu/publish.js +17 -17
  848. package/clis/xianyu/rate.js +1 -1
  849. package/clis/xianyu/reply.js +1 -1
  850. package/clis/xianyu/search.js +8 -8
  851. package/clis/xianyu/seller-data.js +1 -1
  852. package/clis/xianyu/seller-list.js +1 -1
  853. package/clis/xianyu/user.js +1 -1
  854. package/clis/xiaoe/catalog.js +2 -2
  855. package/clis/xiaoe/content.js +2 -2
  856. package/clis/xiaoe/courses.js +2 -2
  857. package/clis/xiaohongshu/ask.js +6 -6
  858. package/clis/xiaohongshu/comments.js +6 -6
  859. package/clis/xiaohongshu/creator-note-detail.js +7 -7
  860. package/clis/xiaohongshu/creator-notes-summary.js +1 -1
  861. package/clis/xiaohongshu/creator-notes.js +13 -13
  862. package/clis/xiaohongshu/creator-profile.js +2 -2
  863. package/clis/xiaohongshu/creator-stats.js +2 -2
  864. package/clis/xiaohongshu/delete-note.js +7 -7
  865. package/clis/xiaohongshu/download.js +4 -4
  866. package/clis/xiaohongshu/feed.js +2 -2
  867. package/clis/xiaohongshu/follow.js +3 -3
  868. package/clis/xiaohongshu/human.js +3 -3
  869. package/clis/xiaohongshu/note-helpers.js +1 -1
  870. package/clis/xiaohongshu/note.js +2 -2
  871. package/clis/xiaohongshu/notifications.js +1 -1
  872. package/clis/xiaohongshu/publish-video.js +8 -8
  873. package/clis/xiaohongshu/publish.js +59 -59
  874. package/clis/xiaohongshu/search.js +8 -8
  875. package/clis/xiaohongshu/unfollow.js +4 -4
  876. package/clis/xiaohongshu/user-helpers.js +1 -1
  877. package/clis/xiaohongshu/user.js +2 -2
  878. package/clis/xiaoyuzhou/auth.js +3 -3
  879. package/clis/xiaoyuzhou/download.js +1 -1
  880. package/clis/xiaoyuzhou/utils.js +1 -1
  881. package/clis/xueqiu/article.js +4 -4
  882. package/clis/xueqiu/comments.js +4 -4
  883. package/clis/xueqiu/danjuan-utils.js +4 -4
  884. package/clis/xueqiu/earnings-date.js +1 -1
  885. package/clis/xueqiu/events.js +3 -3
  886. package/clis/xueqiu/hashtags.js +3 -3
  887. package/clis/xueqiu/stocks.js +3 -3
  888. package/clis/xueqiu/users.js +3 -3
  889. package/clis/xueqiu/utils.js +3 -3
  890. package/clis/yahoo-finance/quote.js +1 -1
  891. package/clis/yollomi/background.js +1 -1
  892. package/clis/yollomi/edit.js +1 -1
  893. package/clis/yollomi/face-swap.js +1 -1
  894. package/clis/yollomi/generate.js +1 -1
  895. package/clis/yollomi/object-remover.js +1 -1
  896. package/clis/yollomi/remove-bg.js +1 -1
  897. package/clis/yollomi/restore.js +1 -1
  898. package/clis/yollomi/try-on.js +1 -1
  899. package/clis/yollomi/upload.js +4 -4
  900. package/clis/yollomi/upscale.js +1 -1
  901. package/clis/yollomi/utils.js +4 -4
  902. package/clis/yollomi/video.js +1 -1
  903. package/clis/youtube/channel.js +4 -4
  904. package/clis/youtube/feed.js +2 -2
  905. package/clis/youtube/like.js +5 -5
  906. package/clis/youtube/playlist.js +7 -7
  907. package/clis/youtube/publish.js +11 -11
  908. package/clis/youtube/search.js +3 -3
  909. package/clis/youtube/subscribe.js +7 -7
  910. package/clis/youtube/subscriptions.js +1 -1
  911. package/clis/youtube/transcript-group.js +2 -2
  912. package/clis/youtube/transcript.js +13 -13
  913. package/clis/youtube/unlike.js +5 -5
  914. package/clis/youtube/unsubscribe.js +7 -7
  915. package/clis/youtube/utils.js +3 -3
  916. package/clis/youtube/video.js +4 -4
  917. package/clis/youtube/watch-later.js +2 -2
  918. package/clis/yuanbao/ask.js +18 -18
  919. package/clis/yuanbao/detail.js +1 -1
  920. package/clis/yuanbao/read.js +1 -1
  921. package/clis/yuanbao/shared.js +9 -9
  922. package/clis/yuanbao/status.js +1 -1
  923. package/clis/yuque/article.js +1 -1
  924. package/clis/yuque/whoami.js +1 -1
  925. package/clis/zhihu/answer-comments.js +2 -2
  926. package/clis/zhihu/answer-detail.js +3 -3
  927. package/clis/zhihu/answer.js +1 -1
  928. package/clis/zhihu/article-transform.js +1 -1
  929. package/clis/zhihu/article.js +1 -1
  930. package/clis/zhihu/auth.js +2 -2
  931. package/clis/zhihu/collection.js +3 -3
  932. package/clis/zhihu/collections.js +3 -3
  933. package/clis/zhihu/download.js +2 -2
  934. package/clis/zhihu/image-profile.js +6 -6
  935. package/clis/zhihu/paginate.js +3 -3
  936. package/clis/zhihu/pin.js +4 -4
  937. package/clis/zhihu/question.js +3 -3
  938. package/clis/zhihu/recommend.js +3 -3
  939. package/clis/zhihu/search.js +3 -3
  940. package/clis/zhihu/stats.js +3 -3
  941. package/clis/zhihu/user-arg.js +1 -1
  942. package/clis/zhihu/write-shared.js +7 -7
  943. package/clis/zlibrary/utils.js +6 -6
  944. package/clis/zsxq/auth.js +3 -3
  945. package/clis/zsxq/search.js +1 -1
  946. package/clis/zsxq/topic.js +1 -1
  947. package/clis/zsxq/utils.js +5 -5
  948. package/dist/src/adapter-source.js +1 -1
  949. package/dist/src/browser/analyze.js +1 -1
  950. package/dist/src/browser/article-extract.js +2 -2
  951. package/dist/src/browser/ax-snapshot.js +2 -2
  952. package/dist/src/browser/base-page.js +25 -25
  953. package/dist/src/browser/bridge.js +1 -1
  954. package/dist/src/browser/cdp.js +1 -1
  955. package/dist/src/browser/daemon-client.js +1 -1
  956. package/dist/src/browser/daemon-lifecycle.js +7 -7
  957. package/dist/src/browser/dom-helpers.js +35 -35
  958. package/dist/src/browser/dom-snapshot.js +19 -19
  959. package/dist/src/browser/errors.js +3 -3
  960. package/dist/src/browser/extract.js +5 -5
  961. package/dist/src/browser/find.js +13 -13
  962. package/dist/src/browser/fingerprint.js +2 -2
  963. package/dist/src/browser/html-tree.js +6 -6
  964. package/dist/src/browser/managed-chrome.js +1 -1
  965. package/dist/src/browser/network-cache.js +1 -1
  966. package/dist/src/browser/network-key.js +1 -1
  967. package/dist/src/browser/page.js +7 -7
  968. package/dist/src/browser/profile.js +2 -2
  969. package/dist/src/browser/proxy-test.js +8 -8
  970. package/dist/src/browser/shape-filter.js +1 -1
  971. package/dist/src/browser/shape.js +1 -1
  972. package/dist/src/browser/stealth.js +3 -3
  973. package/dist/src/browser/tabs.js +2 -2
  974. package/dist/src/browser/target-errors.js +1 -1
  975. package/dist/src/browser/target-resolver.js +23 -23
  976. package/dist/src/browser/trace.js +2 -2
  977. package/dist/src/browser/utils.js +1 -1
  978. package/dist/src/browser/verify-fixture.js +2 -2
  979. package/dist/src/browser-session-lock.js +1 -1
  980. package/dist/src/build-manifest.js +11 -11
  981. package/dist/src/capabilityRouting.js +1 -1
  982. package/dist/src/cli-argv-preprocess.js +1 -1
  983. package/dist/src/cli.js +32 -32
  984. package/dist/src/commanderAdapter.js +3 -3
  985. package/dist/src/commands/auth.js +3 -3
  986. package/dist/src/commands/daemon.js +1 -1
  987. package/dist/src/completion-fast.js +1 -1
  988. package/dist/src/completion.js +1 -1
  989. package/dist/src/constants.js +1 -1
  990. package/dist/src/convention-audit.js +2 -2
  991. package/dist/src/daemon-utils.js +1 -1
  992. package/dist/src/daemon.js +1 -1
  993. package/dist/src/discovery.js +2 -2
  994. package/dist/src/doctor.js +9 -9
  995. package/dist/src/download/article-download.js +15 -15
  996. package/dist/src/download/index.js +4 -4
  997. package/dist/src/download/media-download.js +1 -1
  998. package/dist/src/download/progress.js +3 -3
  999. package/dist/src/electron-apps.js +1 -1
  1000. package/dist/src/errors.js +2 -2
  1001. package/dist/src/execution.js +2 -2
  1002. package/dist/src/external.js +1 -1
  1003. package/dist/src/help.js +8 -8
  1004. package/dist/src/hooks.js +1 -1
  1005. package/dist/src/interceptor.js +21 -21
  1006. package/dist/src/launcher.js +7 -7
  1007. package/dist/src/logger.js +8 -8
  1008. package/dist/src/main.js +7 -7
  1009. package/dist/src/observation/artifact.js +5 -5
  1010. package/dist/src/observation/retention.js +1 -1
  1011. package/dist/src/output.js +2 -2
  1012. package/dist/src/package-paths.js +1 -1
  1013. package/dist/src/pipeline/executor.js +1 -1
  1014. package/dist/src/pipeline/registry.js +1 -1
  1015. package/dist/src/pipeline/steps/browser.js +1 -1
  1016. package/dist/src/pipeline/steps/download.js +1 -1
  1017. package/dist/src/pipeline/steps/fetch.js +6 -6
  1018. package/dist/src/pipeline/steps/intercept.js +1 -1
  1019. package/dist/src/pipeline/steps/tap.js +17 -17
  1020. package/dist/src/pipeline/steps/transform.js +1 -1
  1021. package/dist/src/pipeline/template.js +1 -1
  1022. package/dist/src/plugin-manifest.js +1 -1
  1023. package/dist/src/plugin-scaffold.js +19 -19
  1024. package/dist/src/plugin.js +12 -12
  1025. package/dist/src/rate-limit.js +1 -1
  1026. package/dist/src/registry.js +1 -1
  1027. package/dist/src/runtime-detect.js +1 -1
  1028. package/dist/src/runtime.js +1 -1
  1029. package/dist/src/scripts/framework.js +1 -1
  1030. package/dist/src/scripts/interact.js +1 -1
  1031. package/dist/src/scripts/store.js +1 -1
  1032. package/dist/src/serialization.js +2 -2
  1033. package/dist/src/session-lease.js +1 -1
  1034. package/dist/src/snapshotFormatter.js +2 -2
  1035. package/dist/src/tui.js +12 -12
  1036. package/dist/src/user-runtime.js +1 -1
  1037. package/dist/src/utils.d.ts +12 -0
  1038. package/dist/src/utils.js +4 -4
  1039. package/dist/src/validate.js +2 -2
  1040. package/dist/src/verify.js +2 -2
  1041. package/dist/src/version.js +1 -1
  1042. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- function D(g,p){return`
2
- const ref = ${g};
1
+ function o(e,t){return`
2
+ const ref = ${e};
3
3
  let el = document.querySelector('[data-opencli-ref="' + ref + '"]');
4
4
  if (!el) el = document.querySelector('[data-ref="' + ref + '"]');
5
5
  if (!el && ref.match(/^[a-zA-Z#.\\[]/)) {
@@ -8,11 +8,11 @@ function D(g,p){return`
8
8
  if (!el) {
9
9
  const idx = parseInt(ref, 10);
10
10
  if (!isNaN(idx)) {
11
- el = document.querySelectorAll('${p}')[idx];
11
+ el = document.querySelectorAll('${t}')[idx];
12
12
  }
13
- }`}export function clickJs(g){const p=JSON.stringify(g);return`
13
+ }`}export function clickJs(e){const t=JSON.stringify(e);return`
14
14
  (() => {
15
- ${D(p,'a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])')}
15
+ ${o(t,'a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])')}
16
16
  if (!el) throw new Error('Element not found: ' + ref);
17
17
  el.scrollIntoView({ behavior: 'instant', block: 'center' });
18
18
  const rect = el.getBoundingClientRect();
@@ -25,9 +25,9 @@ function D(g,p){return`
25
25
  return { status: 'js_failed', x, y, w: Math.round(rect.width), h: Math.round(rect.height), error: e.message };
26
26
  }
27
27
  })()
28
- `}export function typeTextJs(g,p){const B=JSON.stringify(g),z=JSON.stringify(p);return`
28
+ `}export function typeTextJs(e,t){const r=JSON.stringify(e),n=JSON.stringify(t);return`
29
29
  (() => {
30
- ${D(B,'input, textarea, [contenteditable="true"]')}
30
+ ${o(r,'input, textarea, [contenteditable="true"]')}
31
31
  if (!el) throw new Error('Element not found: ' + ref);
32
32
  el.focus();
33
33
  if (el.isContentEditable) {
@@ -38,7 +38,7 @@ function D(g,p){return`
38
38
  sel.removeAllRanges();
39
39
  sel.addRange(range);
40
40
  document.execCommand('delete', false);
41
- document.execCommand('insertText', false, ${z});
41
+ document.execCommand('insertText', false, ${n});
42
42
  el.dispatchEvent(new Event('input', { bubbles: true }));
43
43
  } else {
44
44
  // Use native setter for React/framework compatibility (match element type)
@@ -47,44 +47,44 @@ function D(g,p){return`
47
47
  : HTMLInputElement.prototype;
48
48
  const nativeSetter = Object.getOwnPropertyDescriptor(proto, 'value')?.set;
49
49
  if (nativeSetter) {
50
- nativeSetter.call(el, ${z});
50
+ nativeSetter.call(el, ${n});
51
51
  } else {
52
- el.value = ${z};
52
+ el.value = ${n};
53
53
  }
54
54
  el.dispatchEvent(new Event('input', { bubbles: true }));
55
55
  el.dispatchEvent(new Event('change', { bubbles: true }));
56
56
  }
57
57
  return 'typed';
58
58
  })()
59
- `}export function pressKeyJs(g,p=[]){const B=p.includes("Ctrl")||p.includes("Control"),z=p.includes("Alt"),F=p.includes("Meta"),H=p.includes("Shift");return`
59
+ `}export function pressKeyJs(e,t=[]){const r=t.includes("Ctrl")||t.includes("Control"),n=t.includes("Alt"),s=t.includes("Meta"),c=t.includes("Shift");return`
60
60
  (() => {
61
61
  const el = document.activeElement || document.body;
62
62
  const init = {
63
- key: ${JSON.stringify(g)},
63
+ key: ${JSON.stringify(e)},
64
64
  bubbles: true,
65
- ctrlKey: ${B},
66
- altKey: ${z},
67
- metaKey: ${F},
68
- shiftKey: ${H},
65
+ ctrlKey: ${r},
66
+ altKey: ${n},
67
+ metaKey: ${s},
68
+ shiftKey: ${c},
69
69
  };
70
70
  el.dispatchEvent(new KeyboardEvent('keydown', init));
71
71
  el.dispatchEvent(new KeyboardEvent('keyup', init));
72
72
  return 'pressed';
73
73
  })()
74
- `}export function waitForTextJs(g,p){return`
74
+ `}export function waitForTextJs(e,t){return`
75
75
  new Promise((resolve, reject) => {
76
- const deadline = Date.now() + ${p};
76
+ const deadline = Date.now() + ${t};
77
77
  const check = () => {
78
- if (document.body.innerText.includes(${JSON.stringify(g)})) return resolve('found');
79
- if (Date.now() > deadline) return reject(new Error('Text not found: ' + ${JSON.stringify(g)}));
78
+ if (document.body.innerText.includes(${JSON.stringify(e)})) return resolve('found');
79
+ if (Date.now() > deadline) return reject(new Error('Text not found: ' + ${JSON.stringify(e)}));
80
80
  setTimeout(check, 200);
81
81
  };
82
82
  check();
83
83
  })
84
- `}export function scrollJs(g,p){const B=g==="left"?-p:g==="right"?p:0,z=g==="up"?-p:g==="down"?p:0;return`window.scrollBy(${B}, ${z})`}export function autoScrollJs(g,p){return`
84
+ `}export function scrollJs(e,t){const r=e==="left"?-t:e==="right"?t:0,n=e==="up"?-t:e==="down"?t:0;return`window.scrollBy(${r}, ${n})`}export function autoScrollJs(e,t){return`
85
85
  (async () => {
86
86
  if (!document.body) return;
87
- for (let i = 0; i < ${g}; i++) {
87
+ for (let i = 0; i < ${e}; i++) {
88
88
  const lastHeight = document.body.scrollHeight;
89
89
  window.scrollTo(0, lastHeight);
90
90
  await new Promise(resolve => {
@@ -97,15 +97,15 @@ function D(g,p){return`
97
97
  }
98
98
  });
99
99
  observer.observe(document.body, { childList: true, subtree: true });
100
- timeoutId = setTimeout(() => { observer.disconnect(); resolve(null); }, ${p});
100
+ timeoutId = setTimeout(() => { observer.disconnect(); resolve(null); }, ${t});
101
101
  });
102
102
  }
103
103
  })()
104
- `}export function networkRequestsJs(g){return`
104
+ `}export function networkRequestsJs(e){return`
105
105
  (() => {
106
106
  const entries = performance.getEntriesByType('resource');
107
107
  return entries
108
- ${g?"":'.filter(e => !["img", "font", "css", "script"].some(t => e.initiatorType === t))'}
108
+ ${e?"":'.filter(e => !["img", "font", "css", "script"].some(t => e.initiatorType === t))'}
109
109
  .map(e => ({
110
110
  url: e.name,
111
111
  type: e.initiatorType,
@@ -113,10 +113,10 @@ function D(g,p){return`
113
113
  size: e.transferSize || 0,
114
114
  }));
115
115
  })()
116
- `}export function waitForDomStableJs(g,p){return`
116
+ `}export function waitForDomStableJs(e,t){return`
117
117
  new Promise(resolve => {
118
118
  if (!document.body) {
119
- setTimeout(() => resolve('nobody'), ${g});
119
+ setTimeout(() => resolve('nobody'), ${e});
120
120
  return;
121
121
  }
122
122
  let timer = null;
@@ -129,31 +129,31 @@ function D(g,p){return`
129
129
  };
130
130
  const resetQuiet = () => {
131
131
  clearTimeout(timer);
132
- timer = setTimeout(() => done('quiet'), ${p});
132
+ timer = setTimeout(() => done('quiet'), ${t});
133
133
  };
134
134
  const obs = new MutationObserver(resetQuiet);
135
135
  obs.observe(document.body, { childList: true, subtree: true, attributes: true });
136
136
  resetQuiet();
137
- cap = setTimeout(() => done('capped'), ${g});
137
+ cap = setTimeout(() => done('capped'), ${e});
138
138
  })
139
- `}export function waitForCaptureJs(g){return`
139
+ `}export function waitForCaptureJs(e){return`
140
140
  new Promise((resolve, reject) => {
141
- const deadline = Date.now() + ${g};
141
+ const deadline = Date.now() + ${e};
142
142
  const check = () => {
143
143
  if ((window.__opencli_xhr || []).length > 0) return resolve('captured');
144
- if (Date.now() > deadline) return reject(new Error('No network capture within ${g/1000}s'));
144
+ if (Date.now() > deadline) return reject(new Error('No network capture within ${e/1000}s'));
145
145
  setTimeout(check, 100);
146
146
  };
147
147
  check();
148
148
  })
149
- `}export function waitForSelectorJs(g,p){return`
149
+ `}export function waitForSelectorJs(e,t){return`
150
150
  new Promise((resolve, reject) => {
151
- const sel = ${JSON.stringify(g)};
151
+ const sel = ${JSON.stringify(e)};
152
152
  if (document.querySelector(sel)) return resolve('found');
153
153
  const cap = setTimeout(() => {
154
154
  obs.disconnect();
155
155
  reject(new Error('Selector not found: ' + sel));
156
- }, ${p});
156
+ }, ${t});
157
157
  const obs = new MutationObserver(() => {
158
158
  if (document.querySelector(sel)) {
159
159
  clearTimeout(cap);
@@ -1,6 +1,6 @@
1
- import{COMPOUND_INFO_JS as U}from"./compound.js";export function scrollToRefJs(q){return`
1
+ import{COMPOUND_INFO_JS as g}from"./compound.js";export function scrollToRefJs(e){return`
2
2
  (() => {
3
- const ref = ${JSON.stringify(q)};
3
+ const ref = ${JSON.stringify(e)};
4
4
  const el = document.querySelector('[data-opencli-ref="' + ref + '"]')
5
5
  || document.querySelector('[data-ref="' + ref + '"]');
6
6
  if (!el) throw new Error('Element not found: ref=' + ref);
@@ -75,28 +75,28 @@ import{COMPOUND_INFO_JS as U}from"./compound.js";export function scrollToRefJs(q
75
75
 
76
76
  return result;
77
77
  })()
78
- `.trim()}export function generateSnapshotJs(q={}){const z=q.viewportExpand??800,K=Math.max(1,Math.min(q.maxDepth??50,200)),Q=q.interactiveOnly??!1,V=q.maxTextLength??120,W=q.includeScrollInfo??!0,X=q.bboxDedup??!0,Y=q.includeShadowDom??!0,Z=q.includeIframes??!0,$=q.maxIframes??5,j=q.paintOrderCheck??!0,A=q.annotateRefs??!0,E=q.reportHidden??!0,F=q.filterAds??!0,G=q.markdownTables??!0,B=q.previousHashes??null;return`
78
+ `.trim()}export function generateSnapshotJs(e={}){const t=e.viewportExpand??800,r=Math.max(1,Math.min(e.maxDepth??50,200)),i=e.interactiveOnly??!1,a=e.maxTextLength??120,l=e.includeScrollInfo??!0,s=e.bboxDedup??!0,o=e.includeShadowDom??!0,c=e.includeIframes??!0,u=e.maxIframes??5,f=e.paintOrderCheck??!0,d=e.annotateRefs??!0,h=e.reportHidden??!0,p=e.filterAds??!0,m=e.markdownTables??!0,n=e.previousHashes??null;return`
79
79
  (() => {
80
80
  'use strict';
81
81
 
82
- ${U}
82
+ ${g}
83
83
 
84
84
  // ── Config ─────────────────────────────────────────────────────────
85
- const VIEWPORT_EXPAND = ${z};
86
- const MAX_DEPTH = ${K};
87
- const INTERACTIVE_ONLY = ${Q};
88
- const MAX_TEXT_LEN = ${V};
89
- const INCLUDE_SCROLL_INFO = ${W};
90
- const BBOX_DEDUP = ${X};
91
- const INCLUDE_SHADOW_DOM = ${Y};
92
- const INCLUDE_IFRAMES = ${Z};
93
- const MAX_IFRAMES = ${$};
94
- const PAINT_ORDER_CHECK = ${j};
95
- const ANNOTATE_REFS = ${A};
96
- const REPORT_HIDDEN = ${E};
97
- const FILTER_ADS = ${F};
98
- const MARKDOWN_TABLES = ${G};
99
- const PREV_HASHES = ${B?`new Set(${B})`:"null"};
85
+ const VIEWPORT_EXPAND = ${t};
86
+ const MAX_DEPTH = ${r};
87
+ const INTERACTIVE_ONLY = ${i};
88
+ const MAX_TEXT_LEN = ${a};
89
+ const INCLUDE_SCROLL_INFO = ${l};
90
+ const BBOX_DEDUP = ${s};
91
+ const INCLUDE_SHADOW_DOM = ${o};
92
+ const INCLUDE_IFRAMES = ${c};
93
+ const MAX_IFRAMES = ${u};
94
+ const PAINT_ORDER_CHECK = ${f};
95
+ const ANNOTATE_REFS = ${d};
96
+ const REPORT_HIDDEN = ${h};
97
+ const FILTER_ADS = ${p};
98
+ const MARKDOWN_TABLES = ${m};
99
+ const PREV_HASHES = ${n?`new Set(${n})`:"null"};
100
100
 
101
101
  // ── Constants ──────────────────────────────────────────────────────
102
102
 
@@ -1,5 +1,5 @@
1
- import{BrowserConnectError as x}from"../errors.js";import{DEFAULT_DAEMON_PORT as K}from"../constants.js";const Q=["Extension disconnected","Extension not connected","attach failed","Detached while handling command","Debugger is not attached to the tab","no longer exists","No tab with id","CDP connection","Daemon command failed","No window with id"],W=["Inspected target navigated or closed"];function Y(h){return h instanceof Error?h.message:String(h)}const J={attach_failed:{kind:"extension-transient",retryable:!0,delayMs:1500},tab_gone:{kind:"extension-transient",retryable:!0,delayMs:1500},target_navigated:{kind:"target-navigation",retryable:!0,delayMs:200},detached_mid_command:{kind:"non-retryable",retryable:!1,delayMs:0},cdp_timeout:{kind:"non-retryable",retryable:!1,delayMs:0}};export function classifyBrowserError(h){const q=h&&typeof h==="object"?h.code:void 0;if(typeof q==="string"&&J[q])return J[q];const v=Y(h);if(Q.some((z)=>v.includes(z)))return{kind:"extension-transient",retryable:!0,delayMs:1500};if(W.some((z)=>v.includes(z)))return{kind:"target-navigation",retryable:!0,delayMs:200};if(v.includes("-32000")&&/target|context/i.test(v))return{kind:"target-navigation",retryable:!0,delayMs:200};return{kind:"non-retryable",retryable:!1,delayMs:0}}export function isTransientBrowserError(h){return classifyBrowserError(h).retryable}export function formatBrowserConnectError(h,q){switch(h){case"daemon-not-running":return new x("Cannot connect to ppcli daemon."+(q?`
1
+ import{BrowserConnectError as r}from"../errors.js";import{DEFAULT_DAEMON_PORT as i}from"../constants.js";const s=["Extension disconnected","Extension not connected","attach failed","Detached while handling command","Debugger is not attached to the tab","no longer exists","No tab with id","CDP connection","Daemon command failed","No window with id"],d=["Inspected target navigated or closed"];function c(e){return e instanceof Error?e.message:String(e)}const a={attach_failed:{kind:"extension-transient",retryable:!0,delayMs:1500},tab_gone:{kind:"extension-transient",retryable:!0,delayMs:1500},target_navigated:{kind:"target-navigation",retryable:!0,delayMs:200},detached_mid_command:{kind:"non-retryable",retryable:!1,delayMs:0},cdp_timeout:{kind:"non-retryable",retryable:!1,delayMs:0}};export function classifyBrowserError(e){const n=e&&typeof e==="object"?e.code:void 0;if(typeof n==="string"&&a[n])return a[n];const t=c(e);if(s.some((o)=>t.includes(o)))return{kind:"extension-transient",retryable:!0,delayMs:1500};if(d.some((o)=>t.includes(o)))return{kind:"target-navigation",retryable:!0,delayMs:200};if(t.includes("-32000")&&/target|context/i.test(t))return{kind:"target-navigation",retryable:!0,delayMs:200};return{kind:"non-retryable",retryable:!1,delayMs:0}}export function isTransientBrowserError(e){return classifyBrowserError(e).retryable}export function formatBrowserConnectError(e,n){switch(e){case"daemon-not-running":return new r("Cannot connect to ppcli daemon."+(n?`
2
2
 
3
- ${q}`:""),`Run \`ppcli doctor\` to diagnose, or \`ppcli daemon restart\` to force a fresh daemon. Default port is ${K}.`,h);case"extension-not-connected":return new x("浏览器桥未连接。"+(q?`
3
+ ${n}`:""),`Run \`ppcli doctor\` to diagnose, or \`ppcli daemon restart\` to force a fresh daemon. Default port is ${i}.`,e);case"extension-not-connected":return new r("浏览器桥未连接。"+(n?`
4
4
 
5
- ${q}`:""),"请用户打开 PublishPort 客户端,在平台列表里点一次「检测登录」把托管浏览器拉起来;仍不行就重启客户端。",h);case"command-failed":return new x(`Browser command failed: ${q??"unknown error"}`,void 0,h);default:return new x(q??"Failed to connect to browser",void 0,h)}}
5
+ ${n}`:""),"请用户打开 PublishPort 客户端,在平台列表里点一次「检测登录」把托管浏览器拉起来;仍不行就重启客户端。",e);case"command-failed":return new r(`Browser command failed: ${n??"unknown error"}`,void 0,e);default:return new r(n??"Failed to connect to browser",void 0,e)}}
@@ -1,5 +1,5 @@
1
- import{htmlToMarkdown as Y}from"../utils.js";const V=20000,$=100,j=200000,F=0.15;export function buildExtractHtmlJs(f){return`(() => {
2
- const sel = ${f?JSON.stringify(f):"null"};
1
+ import{htmlToMarkdown as f}from"../utils.js";const u=20000,d=100,m=200000,S=0.15;export function buildExtractHtmlJs(e){return`(() => {
2
+ const sel = ${e?JSON.stringify(e):"null"};
3
3
  let root = null;
4
4
  if (sel) {
5
5
  try { root = document.querySelector(sel); }
@@ -36,7 +36,7 @@ import{htmlToMarkdown as Y}from"../utils.js";const V=20000,$=100,j=200000,F=0.15
36
36
  n = walker.nextNode();
37
37
  }
38
38
  return { ok: true, url: location.href, title: document.title || '', html: clone.outerHTML || '' };
39
- })()`}export function chunkMarkdown(f){const{content:g,start:b}=f,G=Math.max($,Math.min(j,f.chunkSize));if(b>=g.length)return{content:"",start:b,end:b,nextStartChar:null};const q=Math.min(g.length,b+G);if(q===g.length)return{content:g.slice(b,q),start:b,end:q,nextStartChar:null};const v=Math.max(1,Math.floor(G*F)),y=Math.max(b+1,q-v),J=g.slice(y,q),P=J.lastIndexOf(`
39
+ })()`}export function chunkMarkdown(e){const{content:n,start:t}=e,l=Math.max(d,Math.min(m,e.chunkSize));if(t>=n.length)return{content:"",start:t,end:t,nextStartChar:null};const r=Math.min(n.length,t+l);if(r===n.length)return{content:n.slice(t,r),start:t,end:r,nextStartChar:null};const h=Math.max(1,Math.floor(l*S)),a=Math.max(t+1,r-h),c=n.slice(a,r),s=c.lastIndexOf(`
40
40
 
41
- `);let x=q;if(P>=0)x=y+P+2;else{const Q=J.lastIndexOf(`
42
- `);if(Q>=0)x=y+Q+1}return{content:g.slice(b,x),start:b,end:x,nextStartChar:x}}export function runExtractFromHtml(f){const g=Y(f.html),b=chunkMarkdown({content:g,start:Math.max(0,f.start),chunkSize:f.chunkSize||V});return{url:f.url,title:f.title,selector:f.selector,total_chars:g.length,chunk_size:b.end-b.start,start:b.start,end:b.end,next_start_char:b.nextStartChar,content:b.content}}export const __extractInternals={DEFAULT_CHUNK_SIZE:V,MIN_CHUNK_SIZE:$,MAX_CHUNK_SIZE:j};
41
+ `);let o=r;if(s>=0)o=a+s+2;else{const i=c.lastIndexOf(`
42
+ `);if(i>=0)o=a+i+1}return{content:n.slice(t,o),start:t,end:o,nextStartChar:o}}export function runExtractFromHtml(e){const n=f(e.html),t=chunkMarkdown({content:n,start:Math.max(0,e.start),chunkSize:e.chunkSize||u});return{url:e.url,title:e.title,selector:e.selector,total_chars:n.length,chunk_size:t.end-t.start,start:t.start,end:t.end,next_start_char:t.nextStartChar,content:t.content}}export const __extractInternals={DEFAULT_CHUNK_SIZE:u,MIN_CHUNK_SIZE:d,MAX_CHUNK_SIZE:m};
@@ -1,11 +1,11 @@
1
- import{COMPOUND_INFO_JS as V}from"./compound.js";export const FIND_ATTR_WHITELIST=["id","class","name","type","placeholder","aria-label","title","href","value","role","data-testid"];export function buildFindJs(k,z={}){const G=JSON.stringify(k),K=z.limit??50,Q=z.textMax??120,X=JSON.stringify(FIND_ATTR_WHITELIST);return`
1
+ import{COMPOUND_INFO_JS as l}from"./compound.js";export const FIND_ATTR_WHITELIST=["id","class","name","type","placeholder","aria-label","title","href","value","role","data-testid"];export function buildFindJs(e,t={}){const n=JSON.stringify(e),r=t.limit??50,i=t.textMax??120,a=JSON.stringify(FIND_ATTR_WHITELIST);return`
2
2
  (() => {
3
- const sel = ${G};
4
- const LIMIT = ${K};
5
- const TEXT_MAX = ${Q};
6
- const ATTR_WHITELIST = ${X};
3
+ const sel = ${n};
4
+ const LIMIT = ${r};
5
+ const TEXT_MAX = ${i};
6
+ const ATTR_WHITELIST = ${a};
7
7
 
8
- ${V}
8
+ ${l}
9
9
 
10
10
  let matches;
11
11
  try {
@@ -119,14 +119,14 @@ import{COMPOUND_INFO_JS as V}from"./compound.js";export const FIND_ATTR_WHITELIS
119
119
  entries,
120
120
  };
121
121
  })()
122
- `}export function buildSemanticFindJs(k){const z=JSON.stringify({role:k.role??"",name:k.name??"",label:k.label??"",text:k.text??"",testid:k.testid??""}),G=k.limit??50,K=k.textMax??120,Q=JSON.stringify(FIND_ATTR_WHITELIST);return`
122
+ `}export function buildSemanticFindJs(e){const t=JSON.stringify({role:e.role??"",name:e.name??"",label:e.label??"",text:e.text??"",testid:e.testid??""}),n=e.limit??50,r=e.textMax??120,i=JSON.stringify(FIND_ATTR_WHITELIST);return`
123
123
  (() => {
124
- const CRITERIA = ${z};
125
- const LIMIT = ${G};
126
- const TEXT_MAX = ${K};
127
- const ATTR_WHITELIST = ${Q};
124
+ const CRITERIA = ${t};
125
+ const LIMIT = ${n};
126
+ const TEXT_MAX = ${r};
127
+ const ATTR_WHITELIST = ${i};
128
128
 
129
- ${V}
129
+ ${l}
130
130
 
131
131
  function normalize(value) {
132
132
  return String(value || '').replace(/\\s+/g, ' ').trim().toLowerCase();
@@ -325,4 +325,4 @@ import{COMPOUND_INFO_JS as V}from"./compound.js";export const FIND_ATTR_WHITELIS
325
325
  entries,
326
326
  };
327
327
  })()
328
- `}export function isFindError(k){return!!k&&typeof k==="object"&&"error"in k}
328
+ `}export function isFindError(e){return!!e&&typeof e==="object"&&"error"in e}
@@ -1,9 +1,9 @@
1
- function J(q){let j=q>>>0;return()=>{j|=0;j=j+1831565813|0;let z=Math.imul(j^j>>>15,1|j);z=z+Math.imul(z^z>>>7,61|z)^z;return((z^z>>>14)>>>0)/4294967296}}function P(q,j){return j[Math.floor(q()*j.length)%j.length]}const L=[4,8,12,16],T=[8,8,16],U=[{width:1920,height:1080},{width:1536,height:864},{width:1440,height:900},{width:2560,height:1440}],V=[{vendor:"Google Inc. (NVIDIA)",renderer:"ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 Direct3D11 vs_5_0 ps_5_0, D3D11)"},{vendor:"Google Inc. (Intel)",renderer:"ANGLE (Intel, Intel(R) UHD Graphics 630 Direct3D11 vs_5_0 ps_5_0, D3D11)"},{vendor:"Google Inc. (AMD)",renderer:"ANGLE (AMD, AMD Radeon RX 6600 Direct3D11 vs_5_0 ps_5_0, D3D11)"},{vendor:"Apple",renderer:"Apple GPU"},{vendor:"Google Inc. (Intel)",renderer:"ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics Direct3D11 vs_5_0 ps_5_0, D3D11)"}];export function resolveFingerprint(q,j={}){const z=J(q),Q=j.spoof===!0,X=P(z,V),K=(G,H)=>G!==void 0?G:Q?H:void 0,F={enabled:!0,seed:q};if(j.timezone)F.timezone=j.timezone;if(j.locale)F.locale=j.locale;if(j.userAgent)F.userAgent=j.userAgent;if(j.platform)F.platform=j.platform;const Z=K(j.hardwareConcurrency,P(z,L));if(Z!==void 0)F.hardwareConcurrency=Z;const $=K(j.deviceMemory,P(z,T));if($!==void 0)F.deviceMemory=$;const A=K(j.screen,P(z,U));if(A!==void 0)F.screen=A;const B=K(j.webglVendor,X.vendor);if(B)F.webglVendor=B;const D=K(j.webglRenderer,X.renderer);if(D)F.webglRenderer=D;if(j.canvasNoise!==void 0?j.canvasNoise:Q)F.canvasNoise=!0;return F}export function randomSeed(){return Math.floor(Math.random()*4294967295)>>>0||1}export function generateFingerprintJs(q){if(!q.enabled)return"";return`
1
+ function C(t){let e=t>>>0;return()=>{e|=0;e=e+1831565813|0;let r=Math.imul(e^e>>>15,1|e);r=r+Math.imul(r^r>>>7,61|r)^r;return((r^r>>>14)>>>0)/4294967296}}function o(t,e){return e[Math.floor(t()*e.length)%e.length]}const p=[4,8,12,16],v=[8,8,16],D=[{width:1920,height:1080},{width:1536,height:864},{width:1440,height:900},{width:2560,height:1440}],m=[{vendor:"Google Inc. (NVIDIA)",renderer:"ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 Direct3D11 vs_5_0 ps_5_0, D3D11)"},{vendor:"Google Inc. (Intel)",renderer:"ANGLE (Intel, Intel(R) UHD Graphics 630 Direct3D11 vs_5_0 ps_5_0, D3D11)"},{vendor:"Google Inc. (AMD)",renderer:"ANGLE (AMD, AMD Radeon RX 6600 Direct3D11 vs_5_0 ps_5_0, D3D11)"},{vendor:"Apple",renderer:"Apple GPU"},{vendor:"Google Inc. (Intel)",renderer:"ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics Direct3D11 vs_5_0 ps_5_0, D3D11)"}];export function resolveFingerprint(t,e={}){const r=C(t),i=e.spoof===!0,c=o(r,m),a=(f,h)=>f!==void 0?f:i?h:void 0,n={enabled:!0,seed:t};if(e.timezone)n.timezone=e.timezone;if(e.locale)n.locale=e.locale;if(e.userAgent)n.userAgent=e.userAgent;if(e.platform)n.platform=e.platform;const l=a(e.hardwareConcurrency,o(r,p));if(l!==void 0)n.hardwareConcurrency=l;const d=a(e.deviceMemory,o(r,v));if(d!==void 0)n.deviceMemory=d;const g=a(e.screen,o(r,D));if(g!==void 0)n.screen=g;const s=a(e.webglVendor,c.vendor);if(s)n.webglVendor=s;const u=a(e.webglRenderer,c.renderer);if(u)n.webglRenderer=u;if(e.canvasNoise!==void 0?e.canvasNoise:i)n.canvasNoise=!0;return n}export function randomSeed(){return Math.floor(Math.random()*4294967295)>>>0||1}export function generateFingerprintJs(t){if(!t.enabled)return"";return`
2
2
  (() => {
3
3
  const _p = EventTarget.prototype, _k = '__ppfp';
4
4
  if (_p[_k]) return;
5
5
  try { Object.defineProperty(_p, _k, { value: true, enumerable: false, configurable: true }); } catch {}
6
- const C = ${JSON.stringify({languages:q.locale?[q.locale,q.locale.split("-")[0]].filter(Boolean):null,language:q.locale??null,platform:q.platform??null,userAgent:q.userAgent??null,hardwareConcurrency:q.hardwareConcurrency??null,deviceMemory:q.deviceMemory??null,screen:q.screen??null,webglVendor:q.webglVendor??null,webglRenderer:q.webglRenderer??null,canvasNoise:q.canvasNoise===!0,seed:q.seed>>>0})};
6
+ const C = ${JSON.stringify({languages:t.locale?[t.locale,t.locale.split("-")[0]].filter(Boolean):null,language:t.locale??null,platform:t.platform??null,userAgent:t.userAgent??null,hardwareConcurrency:t.hardwareConcurrency??null,deviceMemory:t.deviceMemory??null,screen:t.screen??null,webglVendor:t.webglVendor??null,webglRenderer:t.webglRenderer??null,canvasNoise:t.canvasNoise===!0,seed:t.seed>>>0})};
7
7
  const def = (obj, prop, get) => { try { Object.defineProperty(obj, prop, { get, configurable: true }); } catch {} };
8
8
 
9
9
  // navigator 软信号
@@ -1,9 +1,9 @@
1
- import{COMPOUND_INFO_JS as K}from"./compound.js";export function buildHtmlTreeJs(k={}){const z=k.selector?JSON.stringify(k.selector):"null",B=Number.isFinite(k.depth)&&k.depth>=0?String(k.depth):"null",G=Number.isFinite(k.childrenMax)&&k.childrenMax>=0?String(k.childrenMax):"null",H=Number.isFinite(k.textMax)&&k.textMax>=0?String(k.textMax):"null";return`(() => {
2
- ${K}
3
- const selector = ${z};
4
- const maxDepth = ${B};
5
- const maxChildren = ${G};
6
- const maxText = ${H};
1
+ import{COMPOUND_INFO_JS as c}from"./compound.js";export function buildHtmlTreeJs(e={}){const t=e.selector?JSON.stringify(e.selector):"null",n=Number.isFinite(e.depth)&&e.depth>=0?String(e.depth):"null",l=Number.isFinite(e.childrenMax)&&e.childrenMax>=0?String(e.childrenMax):"null",r=Number.isFinite(e.textMax)&&e.textMax>=0?String(e.textMax):"null";return`(() => {
2
+ ${c}
3
+ const selector = ${t};
4
+ const maxDepth = ${n};
5
+ const maxChildren = ${l};
6
+ const maxText = ${r};
7
7
  let matches;
8
8
  if (selector) {
9
9
  try { matches = document.querySelectorAll(selector); }
@@ -1 +1 @@
1
- import{execFileSync as P}from"node:child_process";import*as B from"node:fs";import*as q from"node:path";import{request as f}from"node:http";import{WebSocket as L}from"ws";import{probeCDP as I,launchDetachedApp as w}from"../launcher.js";import{withBrowserSessionLock as C}from"../browser-session-lock.js";import{CommandExecutionError as F}from"../errors.js";import{log as U}from"../logger.js";import{addManagedProfile as y,getManagedProfile as _,listManagedProfiles as u,managedProfilesBaseDir as j,removeManagedProfileEntry as g,updateManagedProfile as h}from"./profile.js";import{proxyServerFlag as m}from"./proxy-test.js";import{resolveFingerprint as l,randomSeed as c}from"./fingerprint.js";const d=500,v=20000,A=9301,b=9399;function M(K){for(const Q of K)try{B.accessSync(Q,B.constants.X_OK);return Q}catch{}return null}function i(K){for(const Q of K)try{const Y=P("which",[Q],{encoding:"utf-8",stdio:"pipe"}).trim();if(Y)return Y}catch{}return null}export function discoverChromePath(){const K=process.env.OPENCLI_CHROME_PATH?.trim();if(K)return K;if(process.platform==="darwin")return M(["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"]);if(process.platform==="win32"){const Q=process.env.ProgramFiles??"C:\\Program Files",Y=process.env["ProgramFiles(x86)"]??"C:\\Program Files (x86)",Z=process.env.LOCALAPPDATA??"";return M([q.join(Q,"Google","Chrome","Application","chrome.exe"),q.join(Y,"Google","Chrome","Application","chrome.exe"),...Z?[q.join(Z,"Google","Chrome","Application","chrome.exe")]:[],q.join(Q,"Microsoft","Edge","Application","msedge.exe"),q.join(Y,"Microsoft","Edge","Application","msedge.exe")])}return i(["google-chrome-stable","google-chrome","chromium","chromium-browser","microsoft-edge-stable"])}function x(K,Q,Y=5000){return new Promise((Z,H)=>{const X=new URL(Q),$=f({hostname:X.hostname,port:X.port,path:X.pathname+X.search,method:K,timeout:Y},(V)=>{const J=[];V.on("data",(z)=>J.push(Buffer.isBuffer(z)?z:Buffer.from(z)));V.on("end",()=>{const z=Buffer.concat(J).toString("utf8");if((V.statusCode??0)<200||(V.statusCode??0)>=300){H(Error(`HTTP ${V.statusCode}: ${z.slice(0,200)}`));return}try{Z(z?JSON.parse(z):null)}catch{Z(z)}})});$.on("error",H);$.on("timeout",()=>$.destroy(Error(`请求 ${Q} 超时`)));$.end()})}export function managedEndpoint(K){return`http://127.0.0.1:${K.port}`}export async function isManagedChromeRunning(K){return I(K.port)}const p=["--no-first-run","--no-default-browser-check","--disable-background-networking","--disable-component-update","--disable-sync","--disable-domain-reliability","--disable-breakpad","--disable-client-side-phishing-detection","--no-pings","--no-service-autorun","--password-store=basic","--disable-features=Translate,OptimizationHints,MediaRouter,AutofillServerCommunication,InterestFeedContentSuggestions,CalculateNativeWinOcclusion"];function o(K){const Q=[`--user-data-dir=${K.userDataDir}`,`--remote-debugging-port=${K.port}`,"--remote-allow-origins=*"];if(K.clean!==!1)Q.push(...p);if(K.webrtc!==!1)Q.push("--force-webrtc-ip-handling-policy=disable_non_proxied_udp");if(K.proxy)Q.push(`--proxy-server=${m(K.proxy)}`);if(K.fingerprint?.enabled&&K.fingerprint.locale)Q.push(`--lang=${K.fingerprint.locale}`);Q.push("--no-startup-window");return Q}function s(K){const Q=K.fingerprint?.enabled?K.fingerprint.timezone:void 0;return Q?{TZ:Q}:void 0}async function a(K,Q){const Y=Date.now()+v;while(Date.now()<Y){if(await I(K,1000))return;await new Promise((Z)=>setTimeout(Z,d))}throw new F(`托管 Chrome「${Q}」已启动但 ${v/1000}s 内 CDP 端口 ${K} 未就绪`,"浏览器可能启动缓慢,稍后重试;或检查该端口是否被其它进程占用。")}const t="https://publishport.app/automation";function n(K){if(!K)return!1;try{const Q=new URL(K);return(Q.hostname==="publishport.app"||Q.hostname==="www.publishport.app")&&Q.pathname.endsWith("/automation")}catch{return!1}}async function T(K,Q){const Z=(await x("GET",`${K}/json/version`))?.webSocketDebuggerUrl;if(!Z)throw Error(`CDP 端点 ${K} 没有暴露 browser target`);const H=new L(Z);await new Promise((J,z)=>{const W=setTimeout(()=>{H.close();z(Error("browser CDP 连接超时"))},1e4);H.on("open",()=>{clearTimeout(W);J()});H.on("error",(O)=>{clearTimeout(W);z(O)})});let X=0;const $=new Map;H.on("message",(J)=>{try{const z=JSON.parse(String(J));if(!z.id||!$.has(z.id))return;const W=$.get(z.id);$.delete(z.id);if(z.error)W.reject(Error(z.error.message??"CDP error"));else W.resolve(z.result??{})}catch{}});const V=(J,z={})=>{const W=++X;return new Promise((O,G)=>{const k=setTimeout(()=>{$.delete(W);G(Error(`CDP ${J} 超时`))},1e4);$.set(W,{resolve:(S)=>{clearTimeout(k);O(S)},reject:(S)=>{clearTimeout(k);G(S)}});H.send(JSON.stringify({id:W,method:J,params:z}))})};try{return await Q(V)}finally{H.close()}}async function D(K){const Q=await x("GET",`${K}/json`);return Array.isArray(Q)?Q.filter((Y)=>Y.type==="page"):[]}async function R(K,Q,Y){try{let Z=await D(K);if(Z.length===0){await C(async()=>{if((await D(K)).length>0)return;await T(K,async($)=>{const J=(await $("Target.createTarget",{url:t,background:!0})).targetId;if(J&&Y==="background"){const z=await $("Browser.getWindowForTarget",{targetId:J});if(z.windowId!==void 0)for(let W=0;W<4;W++){await $("Browser.setWindowBounds",{windowId:z.windowId,bounds:{windowState:"minimized"}});await new Promise((G)=>setTimeout(G,250));if((await $("Browser.getWindowBounds",{windowId:z.windowId})).bounds?.windowState==="minimized")break}}})},`anchor-${Q}`);return}const H=Z.filter(($)=>n($.url));if(H.length>1){await T(K,async($)=>{for(const V of H.slice(1))if(V.id)await $("Target.closeTarget",{targetId:V.id})});Z=Z.filter(($)=>!H.slice(1).some((V)=>V.id===$.id))}const X=Z[0];if(Y==="foreground"&&X?.id)await T(K,async($)=>{const V=await $("Browser.getWindowForTarget",{targetId:X.id});if((await $("Browser.getWindowBounds",{windowId:V.windowId})).bounds?.windowState==="minimized")await $("Browser.setWindowBounds",{windowId:V.windowId,bounds:{windowState:"normal"}})})}catch(Z){U.debug(`[managed-chrome] ensurePageTarget 失败(非致命):${Z instanceof Error?Z.message:Z}`)}}const N=new Map;async function E(K){if(await I(K.port))return!0;if(process.platform==="win32")return!1;const Q=q.join(K.userDataDir,"SingletonLock"),Y=()=>{try{B.lstatSync(Q);return!0}catch{return!1}};if(!Y())return!1;for(let Z=0;Z<3;Z++){await new Promise((H)=>setTimeout(H,500));if(await I(K.port,4000))return!0;if(!Y())return!1}return!1}export async function ensureManagedChrome(K,Q,Y={}){const Z=managedEndpoint(Q),H=N.get(K);if(H)return H;if(await E(Q)){U.debug(`[managed-chrome] profile「${K}」已在端口 ${Q.port} 运行`);await R(Z,K,Y.windowMode);return Z}const X=N.get(K);if(X)return X;const $=C(async()=>{if(await E(Q)){U.debug(`[managed-chrome] profile「${K}」等锁期间已被拉起,直接复用`);await R(Z,K,Y.windowMode);return Z}const V=Q.browserPath??discoverChromePath();if(!V)throw new F("找不到可用的 Chrome/Chromium 浏览器。","安装 Google Chrome,或用 OPENCLI_CHROME_PATH 环境变量指定可执行文件路径。");B.mkdirSync(Q.userDataDir,{recursive:!0});U.debug(`[managed-chrome] 拉起 profile「${K}」:${V} 端口 ${Q.port}${Q.proxy?" (代理)":""}`);await w(V,o(Q),`托管 profile ${K}`,s(Q));await a(Q.port,K);await R(Z,K,Y.windowMode);return Z},`launch-${K}`).finally(()=>N.delete(K));N.set(K,$);return $}export async function stopManagedChrome(K){if(!await I(K.port))return!1;const Y=(await x("GET",`${managedEndpoint(K)}/json/version`))?.webSocketDebuggerUrl;if(!Y)throw Error(`端口 ${K.port} 上的 CDP 端点没有暴露 browser target`);await new Promise((H,X)=>{const $=new L(Y),V=setTimeout(()=>{$.close();X(Error("CDP Browser.close 超时"))},1e4);$.on("open",()=>{$.send(JSON.stringify({id:1,method:"Browser.close",params:{}}))});$.on("close",()=>{clearTimeout(V);H()});$.on("error",(J)=>{clearTimeout(V);X(J)})});const Z=Date.now()+5000;while(Date.now()<Z){if(!await I(K.port,500))break;await new Promise((H)=>setTimeout(H,200))}if(process.platform!=="win32"){const H=q.join(K.userDataDir,"SingletonLock"),X=Date.now()+15000;while(Date.now()<X){try{B.lstatSync(H)}catch{return!0}await new Promise(($)=>setTimeout($,200))}U.warn(`[managed-chrome] Chrome 端口已释放但 15s 内 SingletonLock 未消失:${H}`)}return!0}async function r(K){return!await I(K,500)}async function e(){const K=new Set(u().map(({entry:Q})=>Q.port));for(let Q=A;Q<=b;Q++){if(K.has(Q))continue;if(await r(Q))return Q}throw Error(`托管 profile 端口区间 ${A}-${b} 已耗尽`)}export async function resolveManagedOpts(K){const Q={};if(K.label)Q.label=K.label;if(K.proxy)Q.proxy=K.proxy;if(K.webrtc===!1)Q.webrtc=!1;if(K.clean===!1)Q.clean=!1;if(K.fingerprint?.enabled){const Y=K.fingerprint,Z=Y.seed??c();Q.fingerprint=l(Z,{timezone:Y.timezone,locale:Y.locale,userAgent:Y.userAgent,platform:Y.platform,spoof:Y.spoof,hardwareConcurrency:Y.hardwareConcurrency,deviceMemory:Y.deviceMemory,screen:Y.screen,webglVendor:Y.webglVendor,webglRenderer:Y.webglRenderer,canvasNoise:Y.canvasNoise})}return{opts:Q}}export async function createManagedProfile(K,Q={}){const Y=await e(),Z=q.join(j(),K.trim()),H={userDataDir:Z,port:Y,...Q.browserPath?{browserPath:Q.browserPath}:{},...Q.label?{label:Q.label}:{},...Q.proxy?{proxy:Q.proxy}:{},...Q.fingerprint?{fingerprint:Q.fingerprint}:{},...Q.webrtc===!1?{webrtc:!1}:{},...Q.clean===!1?{clean:!1}:{},createdAt:new Date().toISOString()};y(K,H);B.rmSync(Z,{recursive:!0,force:!0});B.mkdirSync(Z,{recursive:!0});return H}export async function updateManagedProfileConfig(K,Q){const Y=_(K);if(!Y)throw Error(`托管 profile "${K}" 不存在`);const Z=Q.webrtc!==void 0?Q.webrtc:Y.webrtc,H=Q.clean!==void 0?Q.clean:Y.clean,X={userDataDir:Y.userDataDir,port:Y.port,...Y.browserPath?{browserPath:Y.browserPath}:{},...Y.createdAt?{createdAt:Y.createdAt}:{},...Q.label!==void 0?Q.label?{label:Q.label}:{}:Y.label?{label:Y.label}:{},...Q.proxy!==void 0?Q.proxy?{proxy:Q.proxy}:{}:Y.proxy?{proxy:Y.proxy}:{},...Q.fingerprint!==void 0?Q.fingerprint?{fingerprint:Q.fingerprint}:{}:Y.fingerprint?{fingerprint:Y.fingerprint}:{},...Z===!1?{webrtc:!1}:{},...H===!1?{clean:!1}:{}};let $=!1;try{$=await stopManagedChrome(Y)}catch(V){U.warn(`[managed-chrome] 更新前关闭 profile「${K}」失败(继续):${V instanceof Error?V.message:V}`)}h(K,X);return{entry:X,wasRunning:$}}async function KK(K){const Q=Date.now()+15000;let Y=0;while(Date.now()<Q){try{B.rmSync(K,{recursive:!0,force:!0,maxRetries:3,retryDelay:100})}catch{}await new Promise((Z)=>setTimeout(Z,300));if(!B.existsSync(K)){if(++Y>=2)return}else Y=0}throw new F(`数据目录未能删净(浏览器可能仍在退出中):${K}`,"等浏览器窗口完全关闭后再删一次即可。")}export async function removeManagedProfile(K,Q={}){const Y=_(K);if(!Y)throw Error(`托管 profile "${K}" 不存在`);try{await stopManagedChrome(Y)}catch(Z){U.warn(`[managed-chrome] 关闭 profile「${K}」失败(继续删除):${Z instanceof Error?Z.message:Z}`)}if(!Q.keepData){const Z=j(),H=q.resolve(Y.userDataDir);if(H.startsWith(Z+q.sep))await KK(H);else U.warn(`[managed-chrome] user-data-dir 不在 ${Z} 下,跳过数据删除:${H}`)}g(K)}
1
+ import{execFileSync as R}from"node:child_process";import*as d from"node:fs";import*as u from"node:path";import{request as I}from"node:http";import{WebSocket as E}from"ws";import{probeCDP as p,launchDetachedApp as B}from"../launcher.js";import{withBrowserSessionLock as T}from"../browser-session-lock.js";import{CommandExecutionError as P}from"../errors.js";import{log as w}from"../logger.js";import{addManagedProfile as F,getManagedProfile as S,listManagedProfiles as G,managedProfilesBaseDir as A,removeManagedProfileEntry as N,updateManagedProfile as W}from"./profile.js";import{proxyServerFlag as j}from"./proxy-test.js";import{resolveFingerprint as U,randomSeed as z}from"./fingerprint.js";const H=500,M=20000,v=9301,_=9399;function L(e){for(const r of e)try{d.accessSync(r,d.constants.X_OK);return r}catch{}return null}function J(e){for(const r of e)try{const o=R("which",[r],{encoding:"utf-8",stdio:"pipe"}).trim();if(o)return o}catch{}return null}export function discoverChromePath(){const e=process.env.OPENCLI_CHROME_PATH?.trim();if(e)return e;if(process.platform==="darwin")return L(["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"]);if(process.platform==="win32"){const r=process.env.ProgramFiles??"C:\\Program Files",o=process.env["ProgramFiles(x86)"]??"C:\\Program Files (x86)",t=process.env.LOCALAPPDATA??"";return L([u.join(r,"Google","Chrome","Application","chrome.exe"),u.join(o,"Google","Chrome","Application","chrome.exe"),...t?[u.join(t,"Google","Chrome","Application","chrome.exe")]:[],u.join(r,"Microsoft","Edge","Application","msedge.exe"),u.join(o,"Microsoft","Edge","Application","msedge.exe")])}return J(["google-chrome-stable","google-chrome","chromium","chromium-browser","microsoft-edge-stable"])}function y(e,r,o=5000){return new Promise((t,i)=>{const c=new URL(r),n=I({hostname:c.hostname,port:c.port,path:c.pathname+c.search,method:e,timeout:o},(a)=>{const l=[];a.on("data",(s)=>l.push(Buffer.isBuffer(s)?s:Buffer.from(s)));a.on("end",()=>{const s=Buffer.concat(l).toString("utf8");if((a.statusCode??0)<200||(a.statusCode??0)>=300){i(Error(`HTTP ${a.statusCode}: ${s.slice(0,200)}`));return}try{t(s?JSON.parse(s):null)}catch{t(s)}})});n.on("error",i);n.on("timeout",()=>n.destroy(Error(`请求 ${r} 超时`)));n.end()})}export function managedEndpoint(e){return`http://127.0.0.1:${e.port}`}export async function isManagedChromeRunning(e){return p(e.port)}const q=["--no-first-run","--no-default-browser-check","--disable-background-networking","--disable-component-update","--disable-sync","--disable-domain-reliability","--disable-breakpad","--disable-client-side-phishing-detection","--no-pings","--no-service-autorun","--password-store=basic","--disable-features=Translate,OptimizationHints,MediaRouter,AutofillServerCommunication,InterestFeedContentSuggestions,CalculateNativeWinOcclusion"];function V(e){const r=[`--user-data-dir=${e.userDataDir}`,`--remote-debugging-port=${e.port}`,"--remote-allow-origins=*"];if(e.clean!==!1)r.push(...q);if(e.webrtc!==!1)r.push("--force-webrtc-ip-handling-policy=disable_non_proxied_udp");if(e.proxy)r.push(`--proxy-server=${j(e.proxy)}`);if(e.fingerprint?.enabled&&e.fingerprint.locale)r.push(`--lang=${e.fingerprint.locale}`);r.push("--no-startup-window");return r}function X(e){const r=e.fingerprint?.enabled?e.fingerprint.timezone:void 0;return r?{TZ:r}:void 0}async function K(e,r){const o=Date.now()+M;while(Date.now()<o){if(await p(e,1000))return;await new Promise((t)=>setTimeout(t,H))}throw new P(`托管 Chrome「${r}」已启动但 ${M/1000}s 内 CDP 端口 ${e} 未就绪`,"浏览器可能启动缓慢,稍后重试;或检查该端口是否被其它进程占用。")}const Z="https://publishport.app/automation";function Q(e){if(!e)return!1;try{const r=new URL(e);return(r.hostname==="publishport.app"||r.hostname==="www.publishport.app")&&r.pathname.endsWith("/automation")}catch{return!1}}async function C(e,r){const t=(await y("GET",`${e}/json/version`))?.webSocketDebuggerUrl;if(!t)throw Error(`CDP 端点 ${e} 没有暴露 browser target`);const i=new E(t);await new Promise((l,s)=>{const f=setTimeout(()=>{i.close();s(Error("browser CDP 连接超时"))},1e4);i.on("open",()=>{clearTimeout(f);l()});i.on("error",(g)=>{clearTimeout(f);s(g)})});let c=0;const n=new Map;i.on("message",(l)=>{try{const s=JSON.parse(String(l));if(!s.id||!n.has(s.id))return;const f=n.get(s.id);n.delete(s.id);if(s.error)f.reject(Error(s.error.message??"CDP error"));else f.resolve(s.result??{})}catch{}});const a=(l,s={})=>{const f=++c;return new Promise((g,m)=>{const x=setTimeout(()=>{n.delete(f);m(Error(`CDP ${l} 超时`))},1e4);n.set(f,{resolve:(b)=>{clearTimeout(x);g(b)},reject:(b)=>{clearTimeout(x);m(b)}});i.send(JSON.stringify({id:f,method:l,params:s}))})};try{return await r(a)}finally{i.close()}}async function O(e){const r=await y("GET",`${e}/json`);return Array.isArray(r)?r.filter((o)=>o.type==="page"):[]}async function D(e,r,o){try{let t=await O(e);if(t.length===0){await T(async()=>{if((await O(e)).length>0)return;await C(e,async(n)=>{const l=(await n("Target.createTarget",{url:Z,background:!0})).targetId;if(l&&o==="background"){const s=await n("Browser.getWindowForTarget",{targetId:l});if(s.windowId!==void 0)for(let f=0;f<4;f++){await n("Browser.setWindowBounds",{windowId:s.windowId,bounds:{windowState:"minimized"}});await new Promise((m)=>setTimeout(m,250));if((await n("Browser.getWindowBounds",{windowId:s.windowId})).bounds?.windowState==="minimized")break}}})},`anchor-${r}`);return}const i=t.filter((n)=>Q(n.url));if(i.length>1){await C(e,async(n)=>{for(const a of i.slice(1))if(a.id)await n("Target.closeTarget",{targetId:a.id})});t=t.filter((n)=>!i.slice(1).some((a)=>a.id===n.id))}const c=t[0];if(o==="foreground"&&c?.id)await C(e,async(n)=>{const a=await n("Browser.getWindowForTarget",{targetId:c.id});if((await n("Browser.getWindowBounds",{windowId:a.windowId})).bounds?.windowState==="minimized")await n("Browser.setWindowBounds",{windowId:a.windowId,bounds:{windowState:"normal"}})})}catch(t){w.debug(`[managed-chrome] ensurePageTarget 失败(非致命):${t instanceof Error?t.message:t}`)}}const h=new Map;async function k(e){if(await p(e.port))return!0;if(process.platform==="win32")return!1;const r=u.join(e.userDataDir,"SingletonLock"),o=()=>{try{d.lstatSync(r);return!0}catch{return!1}};if(!o())return!1;for(let t=0;t<3;t++){await new Promise((i)=>setTimeout(i,500));if(await p(e.port,4000))return!0;if(!o())return!1}return!1}export async function ensureManagedChrome(e,r,o={}){const t=managedEndpoint(r),i=h.get(e);if(i)return i;if(await k(r)){w.debug(`[managed-chrome] profile「${e}」已在端口 ${r.port} 运行`);await D(t,e,o.windowMode);return t}const c=h.get(e);if(c)return c;const n=T(async()=>{if(await k(r)){w.debug(`[managed-chrome] profile「${e}」等锁期间已被拉起,直接复用`);await D(t,e,o.windowMode);return t}const a=r.browserPath??discoverChromePath();if(!a)throw new P("找不到可用的 Chrome/Chromium 浏览器。","安装 Google Chrome,或用 OPENCLI_CHROME_PATH 环境变量指定可执行文件路径。");d.mkdirSync(r.userDataDir,{recursive:!0});w.debug(`[managed-chrome] 拉起 profile「${e}」:${a} 端口 ${r.port}${r.proxy?" (代理)":""}`);await B(a,V(r),`托管 profile ${e}`,X(r));await K(r.port,e);await D(t,e,o.windowMode);return t},`launch-${e}`).finally(()=>h.delete(e));h.set(e,n);return n}export async function stopManagedChrome(e){if(!await p(e.port))return!1;const o=(await y("GET",`${managedEndpoint(e)}/json/version`))?.webSocketDebuggerUrl;if(!o)throw Error(`端口 ${e.port} 上的 CDP 端点没有暴露 browser target`);await new Promise((i,c)=>{const n=new E(o),a=setTimeout(()=>{n.close();c(Error("CDP Browser.close 超时"))},1e4);n.on("open",()=>{n.send(JSON.stringify({id:1,method:"Browser.close",params:{}}))});n.on("close",()=>{clearTimeout(a);i()});n.on("error",(l)=>{clearTimeout(a);c(l)})});const t=Date.now()+5000;while(Date.now()<t){if(!await p(e.port,500))break;await new Promise((i)=>setTimeout(i,200))}if(process.platform!=="win32"){const i=u.join(e.userDataDir,"SingletonLock"),c=Date.now()+15000;while(Date.now()<c){try{d.lstatSync(i)}catch{return!0}await new Promise((n)=>setTimeout(n,200))}w.warn(`[managed-chrome] Chrome 端口已释放但 15s 内 SingletonLock 未消失:${i}`)}return!0}async function Y(e){return!await p(e,500)}async function ee(){const e=new Set(G().map(({entry:r})=>r.port));for(let r=v;r<=_;r++){if(e.has(r))continue;if(await Y(r))return r}throw Error(`托管 profile 端口区间 ${v}-${_} 已耗尽`)}export async function resolveManagedOpts(e){const r={};if(e.label)r.label=e.label;if(e.proxy)r.proxy=e.proxy;if(e.webrtc===!1)r.webrtc=!1;if(e.clean===!1)r.clean=!1;if(e.fingerprint?.enabled){const o=e.fingerprint,t=o.seed??z();r.fingerprint=U(t,{timezone:o.timezone,locale:o.locale,userAgent:o.userAgent,platform:o.platform,spoof:o.spoof,hardwareConcurrency:o.hardwareConcurrency,deviceMemory:o.deviceMemory,screen:o.screen,webglVendor:o.webglVendor,webglRenderer:o.webglRenderer,canvasNoise:o.canvasNoise})}return{opts:r}}export async function createManagedProfile(e,r={}){const o=await ee(),t=u.join(A(),e.trim()),i={userDataDir:t,port:o,...r.browserPath?{browserPath:r.browserPath}:{},...r.label?{label:r.label}:{},...r.proxy?{proxy:r.proxy}:{},...r.fingerprint?{fingerprint:r.fingerprint}:{},...r.webrtc===!1?{webrtc:!1}:{},...r.clean===!1?{clean:!1}:{},createdAt:new Date().toISOString()};F(e,i);d.rmSync(t,{recursive:!0,force:!0});d.mkdirSync(t,{recursive:!0});return i}export async function updateManagedProfileConfig(e,r){const o=S(e);if(!o)throw Error(`托管 profile "${e}" 不存在`);const t=r.webrtc!==void 0?r.webrtc:o.webrtc,i=r.clean!==void 0?r.clean:o.clean,c={userDataDir:o.userDataDir,port:o.port,...o.browserPath?{browserPath:o.browserPath}:{},...o.createdAt?{createdAt:o.createdAt}:{},...r.label!==void 0?r.label?{label:r.label}:{}:o.label?{label:o.label}:{},...r.proxy!==void 0?r.proxy?{proxy:r.proxy}:{}:o.proxy?{proxy:o.proxy}:{},...r.fingerprint!==void 0?r.fingerprint?{fingerprint:r.fingerprint}:{}:o.fingerprint?{fingerprint:o.fingerprint}:{},...t===!1?{webrtc:!1}:{},...i===!1?{clean:!1}:{}};let n=!1;try{n=await stopManagedChrome(o)}catch(a){w.warn(`[managed-chrome] 更新前关闭 profile「${e}」失败(继续):${a instanceof Error?a.message:a}`)}W(e,c);return{entry:c,wasRunning:n}}async function re(e){const r=Date.now()+15000;let o=0;while(Date.now()<r){try{d.rmSync(e,{recursive:!0,force:!0,maxRetries:3,retryDelay:100})}catch{}await new Promise((t)=>setTimeout(t,300));if(!d.existsSync(e)){if(++o>=2)return}else o=0}throw new P(`数据目录未能删净(浏览器可能仍在退出中):${e}`,"等浏览器窗口完全关闭后再删一次即可。")}export async function removeManagedProfile(e,r={}){const o=S(e);if(!o)throw Error(`托管 profile "${e}" 不存在`);try{await stopManagedChrome(o)}catch(t){w.warn(`[managed-chrome] 关闭 profile「${e}」失败(继续删除):${t instanceof Error?t.message:t}`)}if(!r.keepData){const t=A(),i=u.resolve(o.userDataDir);if(i.startsWith(t+u.sep))await re(i);else w.warn(`[managed-chrome] user-data-dir 不在 ${t} 下,跳过数据删除:${i}`)}N(e)}
@@ -1 +1 @@
1
- import*as z from"node:fs";import*as V from"node:os";import*as O from"node:path";export const DEFAULT_TTL_MS=86400000;function W(){return process.env.OPENCLI_CACHE_DIR||O.join(V.homedir(),".ppcli","cache")}export function getCachePath(B,q=W()){const G=B.replace(/[^a-zA-Z0-9_-]+/g,"_");return O.join(q,"browser-network",`${G}.json`)}export function saveNetworkCache(B,q,G){const J=getCachePath(B,G);z.mkdirSync(O.dirname(J),{recursive:!0});const I={version:1,session:B,savedAt:new Date().toISOString(),entries:q};let H;try{H=z.openSync(J,z.constants.O_WRONLY|z.constants.O_CREAT|z.constants.O_TRUNC,384);z.fchmodSync(H,384);z.writeFileSync(H,JSON.stringify(I),"utf8")}finally{if(H!==void 0)z.closeSync(H)}}export function loadNetworkCache(B,q={}){const G=getCachePath(B,q.baseDir);let J;try{J=z.readFileSync(G,"utf-8")}catch{return{status:"missing"}}let I;try{const K=JSON.parse(J);if(!K||K.version!==1||!Array.isArray(K.entries))return{status:"corrupt"};I=K}catch{return{status:"corrupt"}}const H=q.ttlMs??DEFAULT_TTL_MS,R=q.now??Date.now(),Q=Date.parse(I.savedAt);if(!Number.isFinite(Q))return{status:"corrupt"};const N=R-Q;if(N>H)return{status:"expired",file:I,ageMs:N};return{status:"ok",file:I,ageMs:N}}export function findEntry(B,q){return B.entries.find((G)=>G.key===q)??null}
1
+ import*as e from"node:fs";import*as l from"node:os";import*as u from"node:path";export const DEFAULT_TTL_MS=86400000;function d(){return process.env.OPENCLI_CACHE_DIR||u.join(l.homedir(),".ppcli","cache")}export function getCachePath(r,t=d()){const n=r.replace(/[^a-zA-Z0-9_-]+/g,"_");return u.join(t,"browser-network",`${n}.json`)}export function saveNetworkCache(r,t,n){const a=getCachePath(r,n);e.mkdirSync(u.dirname(a),{recursive:!0});const s={version:1,session:r,savedAt:new Date().toISOString(),entries:t};let o;try{o=e.openSync(a,e.constants.O_WRONLY|e.constants.O_CREAT|e.constants.O_TRUNC,384);e.fchmodSync(o,384);e.writeFileSync(o,JSON.stringify(s),"utf8")}finally{if(o!==void 0)e.closeSync(o)}}export function loadNetworkCache(r,t={}){const n=getCachePath(r,t.baseDir);let a;try{a=e.readFileSync(n,"utf-8")}catch{return{status:"missing"}}let s;try{const c=JSON.parse(a);if(!c||c.version!==1||!Array.isArray(c.entries))return{status:"corrupt"};s=c}catch{return{status:"corrupt"}}const o=t.ttlMs??DEFAULT_TTL_MS,p=t.now??Date.now(),f=Date.parse(s.savedAt);if(!Number.isFinite(f))return{status:"corrupt"};const i=p-f;if(i>o)return{status:"expired",file:s,ageMs:i};return{status:"ok",file:s,ageMs:i}}export function findEntry(r,t){return r.entries.find((n)=>n.key===t)??null}
@@ -1 +1 @@
1
- export function deriveKey(j){const w=F(j.url);if(!w)return`${j.method.toUpperCase()} ${G(j.url,120)}`;const A=w.pathname;if(A.includes("/graphql/")){const z=E(A);if(z)return z}return`${j.method.toUpperCase()} ${w.host}${A}`}export function assignKeys(j){const w=new Map,A=[];for(const z of j){const B=deriveKey(z),C=w.get(B)??0;w.set(B,C+1);const D=C===0?B:`${B}#${C+1}`;A.push({...z,key:D})}return A}function E(j){const w=j.split("/").filter(Boolean),A=w.indexOf("graphql");if(A<0)return null;const z=w.slice(A+1);if(z.length===0)return null;if(z.length===1)return z[0];return z[1]||z[0]}function F(j){try{return new URL(j)}catch{return null}}function G(j,w){return j.length<=w?j:`${j.slice(0,w-1)}…`}
1
+ export function deriveKey(t){const n=i(t.url);if(!n)return`${t.method.toUpperCase()} ${l(t.url,120)}`;const r=n.pathname;if(r.includes("/graphql/")){const e=c(r);if(e)return e}return`${t.method.toUpperCase()} ${n.host}${r}`}export function assignKeys(t){const n=new Map,r=[];for(const e of t){const o=deriveKey(e),s=n.get(o)??0;n.set(o,s+1);const u=s===0?o:`${o}#${s+1}`;r.push({...e,key:u})}return r}function c(t){const n=t.split("/").filter(Boolean),r=n.indexOf("graphql");if(r<0)return null;const e=n.slice(r+1);if(e.length===0)return null;if(e.length===1)return e[0];return e[1]||e[0]}function i(t){try{return new URL(t)}catch{return null}}function l(t,n){return t.length<=n?t:`${t.slice(0,n-1)}…`}
@@ -1,15 +1,15 @@
1
- import{sendCommand as L,sendCommandFull as Y}from"./daemon-client.js";import{buildEvaluateExpression as $}from"./utils.js";import{saveBase64ToFile as N}from"../utils.js";import{generateStealthJs as j,generateBeforeUnloadGuardJs as O}from"./stealth.js";import{waitForDomStableJs as U}from"./dom-helpers.js";import{BasePage as R}from"./base-page.js";import{classifyBrowserError as _}from"./errors.js";import{log as h}from"../logger.js";function J(A){const G=(A instanceof Error?A.message:String(A)).toLowerCase();return G.includes("unknown action")&&G.includes("network-capture")||G.includes("network capture")&&G.includes("not supported")}function z(A){const D=A instanceof Error?A.message:String(A);return D.includes("stale page identity")||/^Page not found:\s*\S+\s*$/.test(D)}export class Page extends R{session;contextId;windowMode;surface;siteSession;_idleTimeout;constructor(A,D,G,H,V="browser",Q){super();this.session=A;this.contextId=G;this.windowMode=H;this.surface=V;this.siteSession=Q;this._idleTimeout=D}_page;_networkCaptureUnsupported=!1;_networkCaptureWarned=!1;_sessionOpts(){return{session:this.session,surface:this.surface,...this.contextId&&{contextId:this.contextId},...this._idleTimeout!=null&&{idleTimeout:this._idleTimeout},...this.windowMode&&{windowMode:this.windowMode},...this.siteSession&&{siteSession:this.siteSession}}}_cmdOpts(){return{session:this.session,surface:this.surface,...this.contextId&&{contextId:this.contextId},...this._page!==void 0&&{page:this._page},...this._idleTimeout!=null&&{idleTimeout:this._idleTimeout},...this.windowMode&&{windowMode:this.windowMode},...this.siteSession&&{siteSession:this.siteSession}}}async goto(A,D){try{await L("exec",{code:O(),...this._cmdOpts()})}catch{}let G;try{G=await Y("navigate",{url:A,...this._cmdOpts()})}catch(H){if(!z(H)||this._page===void 0)throw H;this._page=void 0;G=await Y("navigate",{url:A,...this._cmdOpts()})}if(G.page)this._page=G.page;this._lastUrl=A;if(D?.waitUntil!=="none"){const H=D?.settleMs??1000,Q={code:`${j()};
2
- ${U(H,Math.min(500,H))}`,...this._cmdOpts()};try{await L("exec",Q)}catch(W){const K=_(W);if(K.kind!=="target-navigation")throw W;try{await new Promise((X)=>setTimeout(X,K.delayMs));await L("exec",Q)}catch(X){if(_(X).kind!=="target-navigation")throw X}}}else try{await L("exec",{code:j(),...this._cmdOpts()})}catch{}}getActivePage(){return this._page}setActivePage(A){this._page=A;this._lastUrl=null}_markUnsupportedNetworkCapture(){this._networkCaptureUnsupported=!0;if(this._networkCaptureWarned)return;this._networkCaptureWarned=!0;h.warn("Browser Bridge extension does not support network capture; continuing without it. Explore output may miss API endpoints until you reload or reinstall the extension.")}async evaluate(A,...D){const G=$(A,D);try{return await L("exec",{code:G,...this._cmdOpts()})}catch(H){const V=_(H);if(V.kind!=="target-navigation")throw H;await new Promise((Q)=>setTimeout(Q,V.delayMs));return L("exec",{code:G,...this._cmdOpts()})}}async getCookies(A={}){const D=await L("cookies",{...this._sessionOpts(),...A});return Array.isArray(D)?D:[]}async closeWindow(){try{await L("close-window",{...this._sessionOpts()})}catch{}finally{this._page=void 0;this._lastUrl=null;this._networkCaptureUnsupported=!1;this._networkCaptureWarned=!1}}async tabs(){const A=await L("tabs",{op:"list",...this._sessionOpts()});return Array.isArray(A)?A:[]}async newTab(A){const D=await Y("tabs",{op:"new",...A!==void 0&&{url:A},...this._sessionOpts()});this._lastUrl=null;return D.page}async closeTab(A){const D={op:"close",...this._sessionOpts()};if(typeof A==="number")D.index=A;else if(typeof A==="string")D.page=A;else if(this._page!==void 0)D.page=this._page;const G=await L("tabs",D),H=typeof G?.closed==="string"?G.closed:void 0;if(H&&H===this._page||!H&&(A===void 0||A===this._page)){this._page=void 0;this._lastUrl=null}}async selectTab(A){const D=await Y("tabs",{op:"select",...typeof A==="number"?{index:A}:{page:A},...this._sessionOpts()});if(D.page)this._page=D.page;this._lastUrl=null}async screenshot(A={}){const D=await L("screenshot",{...this._cmdOpts(),format:A.format,quality:A.quality,fullPage:A.fullPage,width:A.width,height:A.height});if(A.path)await N(D,A.path);return D}async startNetworkCapture(A=""){if(this._networkCaptureUnsupported)return!1;try{await L("network-capture-start",{pattern:A,...this._cmdOpts()});return!0}catch(D){if(!J(D))throw D;this._markUnsupportedNetworkCapture();return!1}}async readNetworkCapture(){if(this._networkCaptureUnsupported)return[];try{const A=await L("network-capture-read",{...this._cmdOpts()});return Array.isArray(A)?A:[]}catch(A){if(!J(A))throw A;this._markUnsupportedNetworkCapture();return[]}}async waitForDownload(A="",D=30000){return await L("wait-download",{pattern:A,timeoutMs:D,...this._cmdOpts()})}async setFileInput(A,D){if(!(await L("set-file-input",{files:A,selector:D,...this._cmdOpts()}))?.count)throw Error("setFileInput returned no count — command may not be supported by the extension")}async insertText(A){if(!(await L("insert-text",{text:A,...this._cmdOpts()}))?.inserted)throw Error("insertText returned no inserted flag — command may not be supported by the extension")}async frames(){const A=await L("frames",{...this._cmdOpts()});return Array.isArray(A)?A:[]}async evaluateInFrame(A,D){const G=$(A);return L("exec",{code:G,frameIndex:D,...this._cmdOpts()})}async cdp(A,D={}){return L("cdp",{cdpMethod:A,cdpParams:D,...this._cmdOpts()})}async handleJavaScriptDialog(A,D){await this.cdp("Page.handleJavaScriptDialog",{accept:A,...D!==void 0&&{promptText:D}})}async tryNativeClick(A,D){try{await this.nativeClick(A,D);return!0}catch{return!1}}async clickWithQuads(A){const D=JSON.stringify(A),G=`[data-opencli-ref="${A.replace(/"/g,"\\\"")}"]`;await this.evaluate(`
1
+ import{sendCommand as a,sendCommandFull as u}from"./daemon-client.js";import{buildEvaluateExpression as h}from"./utils.js";import{saveBase64ToFile as m}from"../utils.js";import{generateStealthJs as w,generateBeforeUnloadGuardJs as y}from"./stealth.js";import{waitForDomStableJs as g}from"./dom-helpers.js";import{BasePage as _}from"./base-page.js";import{classifyBrowserError as p}from"./errors.js";import{log as k}from"../logger.js";function f(t){const s=(t instanceof Error?t.message:String(t)).toLowerCase();return s.includes("unknown action")&&s.includes("network-capture")||s.includes("network capture")&&s.includes("not supported")}function v(t){const e=t instanceof Error?t.message:String(t);return e.includes("stale page identity")||/^Page not found:\s*\S+\s*$/.test(e)}export class Page extends _{session;contextId;windowMode;surface;siteSession;_idleTimeout;constructor(t,e,s,i,o="browser",r){super();this.session=t;this.contextId=s;this.windowMode=i;this.surface=o;this.siteSession=r;this._idleTimeout=e}_page;_networkCaptureUnsupported=!1;_networkCaptureWarned=!1;_sessionOpts(){return{session:this.session,surface:this.surface,...this.contextId&&{contextId:this.contextId},...this._idleTimeout!=null&&{idleTimeout:this._idleTimeout},...this.windowMode&&{windowMode:this.windowMode},...this.siteSession&&{siteSession:this.siteSession}}}_cmdOpts(){return{session:this.session,surface:this.surface,...this.contextId&&{contextId:this.contextId},...this._page!==void 0&&{page:this._page},...this._idleTimeout!=null&&{idleTimeout:this._idleTimeout},...this.windowMode&&{windowMode:this.windowMode},...this.siteSession&&{siteSession:this.siteSession}}}async goto(t,e){try{await a("exec",{code:y(),...this._cmdOpts()})}catch{}let s;try{s=await u("navigate",{url:t,...this._cmdOpts()})}catch(i){if(!v(i)||this._page===void 0)throw i;this._page=void 0;s=await u("navigate",{url:t,...this._cmdOpts()})}if(s.page)this._page=s.page;this._lastUrl=t;if(e?.waitUntil!=="none"){const i=e?.settleMs??1000,r={code:`${w()};
2
+ ${g(i,Math.min(500,i))}`,...this._cmdOpts()};try{await a("exec",r)}catch(c){const n=p(c);if(n.kind!=="target-navigation")throw c;try{await new Promise((d)=>setTimeout(d,n.delayMs));await a("exec",r)}catch(d){if(p(d).kind!=="target-navigation")throw d}}}else try{await a("exec",{code:w(),...this._cmdOpts()})}catch{}}getActivePage(){return this._page}setActivePage(t){this._page=t;this._lastUrl=null}_markUnsupportedNetworkCapture(){this._networkCaptureUnsupported=!0;if(this._networkCaptureWarned)return;this._networkCaptureWarned=!0;k.warn("Browser Bridge extension does not support network capture; continuing without it. Explore output may miss API endpoints until you reload or reinstall the extension.")}async evaluate(t,...e){const s=h(t,e);try{return await a("exec",{code:s,...this._cmdOpts()})}catch(i){const o=p(i);if(o.kind!=="target-navigation")throw i;await new Promise((r)=>setTimeout(r,o.delayMs));return a("exec",{code:s,...this._cmdOpts()})}}async getCookies(t={}){const e=await a("cookies",{...this._sessionOpts(),...t});return Array.isArray(e)?e:[]}async closeWindow(){try{await a("close-window",{...this._sessionOpts()})}catch{}finally{this._page=void 0;this._lastUrl=null;this._networkCaptureUnsupported=!1;this._networkCaptureWarned=!1}}async tabs(){const t=await a("tabs",{op:"list",...this._sessionOpts()});return Array.isArray(t)?t:[]}async newTab(t){const e=await u("tabs",{op:"new",...t!==void 0&&{url:t},...this._sessionOpts()});this._lastUrl=null;return e.page}async closeTab(t){const e={op:"close",...this._sessionOpts()};if(typeof t==="number")e.index=t;else if(typeof t==="string")e.page=t;else if(this._page!==void 0)e.page=this._page;const s=await a("tabs",e),i=typeof s?.closed==="string"?s.closed:void 0;if(i&&i===this._page||!i&&(t===void 0||t===this._page)){this._page=void 0;this._lastUrl=null}}async selectTab(t){const e=await u("tabs",{op:"select",...typeof t==="number"?{index:t}:{page:t},...this._sessionOpts()});if(e.page)this._page=e.page;this._lastUrl=null}async screenshot(t={}){const e=await a("screenshot",{...this._cmdOpts(),format:t.format,quality:t.quality,fullPage:t.fullPage,width:t.width,height:t.height});if(t.path)await m(e,t.path);return e}async startNetworkCapture(t=""){if(this._networkCaptureUnsupported)return!1;try{await a("network-capture-start",{pattern:t,...this._cmdOpts()});return!0}catch(e){if(!f(e))throw e;this._markUnsupportedNetworkCapture();return!1}}async readNetworkCapture(){if(this._networkCaptureUnsupported)return[];try{const t=await a("network-capture-read",{...this._cmdOpts()});return Array.isArray(t)?t:[]}catch(t){if(!f(t))throw t;this._markUnsupportedNetworkCapture();return[]}}async waitForDownload(t="",e=30000){return await a("wait-download",{pattern:t,timeoutMs:e,...this._cmdOpts()})}async setFileInput(t,e){if(!(await a("set-file-input",{files:t,selector:e,...this._cmdOpts()}))?.count)throw Error("setFileInput returned no count — command may not be supported by the extension")}async insertText(t){if(!(await a("insert-text",{text:t,...this._cmdOpts()}))?.inserted)throw Error("insertText returned no inserted flag — command may not be supported by the extension")}async frames(){const t=await a("frames",{...this._cmdOpts()});return Array.isArray(t)?t:[]}async evaluateInFrame(t,e){const s=h(t);return a("exec",{code:s,frameIndex:e,...this._cmdOpts()})}async cdp(t,e={}){return a("cdp",{cdpMethod:t,cdpParams:e,...this._cmdOpts()})}async handleJavaScriptDialog(t,e){await this.cdp("Page.handleJavaScriptDialog",{accept:t,...e!==void 0&&{promptText:e}})}async tryNativeClick(t,e){try{await this.nativeClick(t,e);return!0}catch{return!1}}async clickWithQuads(t){const e=JSON.stringify(t),s=`[data-opencli-ref="${t.replace(/"/g,"\\\"")}"]`;await this.evaluate(`
3
3
  (() => {
4
- const el = document.querySelector('[data-opencli-ref="' + ${D} + '"]');
4
+ const el = document.querySelector('[data-opencli-ref="' + ${e} + '"]');
5
5
  if (el) el.scrollIntoView({ behavior: 'instant', block: 'center' });
6
6
  return !!el;
7
7
  })()
8
- `);try{const H=await this.cdp("DOM.getDocument",{}),V=await this.cdp("DOM.querySelectorAll",{nodeId:H.root.nodeId,selector:G});if(!V.nodeIds?.length)throw Error("DOM node not found");const Q=V.nodeIds[0];try{const W=await this.cdp("DOM.getContentQuads",{nodeId:Q});if(W.quads?.length){const K=W.quads[0],X=(K[0]+K[2]+K[4]+K[6])/4,Z=(K[1]+K[3]+K[5]+K[7])/4;await this.nativeClick(Math.round(X),Math.round(Z));return}}catch{}try{const W=await this.cdp("DOM.getBoxModel",{nodeId:Q});if(W.model?.content){const K=W.model.content,X=(K[0]+K[2]+K[4]+K[6])/4,Z=(K[1]+K[3]+K[5]+K[7])/4;await this.nativeClick(Math.round(X),Math.round(Z));return}}catch{}}catch{}await this.evaluate(`
8
+ `);try{const i=await this.cdp("DOM.getDocument",{}),o=await this.cdp("DOM.querySelectorAll",{nodeId:i.root.nodeId,selector:s});if(!o.nodeIds?.length)throw Error("DOM node not found");const r=o.nodeIds[0];try{const c=await this.cdp("DOM.getContentQuads",{nodeId:r});if(c.quads?.length){const n=c.quads[0],d=(n[0]+n[2]+n[4]+n[6])/4,l=(n[1]+n[3]+n[5]+n[7])/4;await this.nativeClick(Math.round(d),Math.round(l));return}}catch{}try{const c=await this.cdp("DOM.getBoxModel",{nodeId:r});if(c.model?.content){const n=c.model.content,d=(n[0]+n[2]+n[4]+n[6])/4,l=(n[1]+n[3]+n[5]+n[7])/4;await this.nativeClick(Math.round(d),Math.round(l));return}}catch{}}catch{}await this.evaluate(`
9
9
  (() => {
10
- const el = document.querySelector('[data-opencli-ref="' + ${D} + '"]');
11
- if (!el) throw new Error('Element not found: ' + ${D});
10
+ const el = document.querySelector('[data-opencli-ref="' + ${e} + '"]');
11
+ if (!el) throw new Error('Element not found: ' + ${e});
12
12
  el.click();
13
13
  return 'clicked';
14
14
  })()
15
- `)}async nativeClick(A,D){await this.cdp("Input.dispatchMouseEvent",{type:"mouseMoved",x:A,y:D});await this.cdp("Input.dispatchMouseEvent",{type:"mousePressed",x:A,y:D,button:"left",clickCount:1});await this.cdp("Input.dispatchMouseEvent",{type:"mouseReleased",x:A,y:D,button:"left",clickCount:1})}async nativeType(A){await this.cdp("Input.insertText",{text:A})}async nativeKeyPress(A,D=[]){let G=0;for(const H of D){if(H==="Alt")G|=1;if(H==="Ctrl"||H==="Control")G|=2;if(H==="Meta")G|=4;if(H==="Shift")G|=8}await this.cdp("Input.dispatchKeyEvent",{type:"keyDown",key:A,modifiers:G});await this.cdp("Input.dispatchKeyEvent",{type:"keyUp",key:A,modifiers:G})}}
15
+ `)}async nativeClick(t,e){await this.cdp("Input.dispatchMouseEvent",{type:"mouseMoved",x:t,y:e});await this.cdp("Input.dispatchMouseEvent",{type:"mousePressed",x:t,y:e,button:"left",clickCount:1});await this.cdp("Input.dispatchMouseEvent",{type:"mouseReleased",x:t,y:e,button:"left",clickCount:1})}async nativeType(t){await this.cdp("Input.insertText",{text:t})}async nativeKeyPress(t,e=[]){let s=0;for(const i of e){if(i==="Alt")s|=1;if(i==="Ctrl"||i==="Control")s|=2;if(i==="Meta")s|=4;if(i==="Shift")s|=8}await this.cdp("Input.dispatchKeyEvent",{type:"keyDown",key:t,modifiers:s});await this.cdp("Input.dispatchKeyEvent",{type:"keyUp",key:t,modifiers:s})}}
@@ -1,2 +1,2 @@
1
- import*as Q from"node:fs";import*as S from"node:os";import*as O from"node:path";export const DEFAULT_CONTEXT_ID="default";function U(){const F=process.env.OPENCLI_CONFIG_DIR||O.join(S.homedir(),".ppcli");return O.join(F,"browser-profiles.json")}export function managedProfilesBaseDir(){const F=process.env.OPENCLI_CONFIG_DIR||O.join(S.homedir(),".ppcli");return O.join(F,"chrome-profiles")}export function normalizeContextId(F){return F?.trim()||void 0}export function emptyProfileConfig(){return{version:1,aliases:{}}}function V(F){return typeof F==="object"&&F!==null&&typeof F.userDataDir==="string"&&F.userDataDir.trim().length>0&&typeof F.port==="number"&&Number.isInteger(F.port)}export function loadProfileConfig(){try{const F=Q.readFileSync(U(),"utf-8"),j=JSON.parse(F),B=j.aliases&&typeof j.aliases==="object"?Object.fromEntries(Object.entries(j.aliases).filter((J)=>{const[K,L]=J;return typeof K==="string"&&K.trim().length>0&&typeof L==="string"&&L.trim().length>0})):{},H=j.managed&&typeof j.managed==="object"?Object.fromEntries(Object.entries(j.managed).filter((J)=>{const[K,L]=J;return typeof K==="string"&&K.trim().length>0&&V(L)})):void 0;return{version:1,aliases:B,...typeof j.defaultContextId==="string"&&j.defaultContextId.trim()?{defaultContextId:j.defaultContextId.trim()}:{},...H&&Object.keys(H).length>0?{managed:H}:{}}}catch{return emptyProfileConfig()}}export function saveProfileConfig(F){const j=U();Q.mkdirSync(O.dirname(j),{recursive:!0});Q.writeFileSync(j,JSON.stringify(F,null,2)+`
2
- `,"utf-8")}function W(F){const j=loadProfileConfig();return normalizeContextId(F)??normalizeContextId(process.env.OPENCLI_PROFILE)??normalizeContextId(j.defaultContextId)}export function resolveProfile(F){const j=loadProfileConfig(),B=W(F);if(!B)return{kind:"extension"};const H=j.managed?.[B];if(H)return{kind:"managed",name:B,entry:H};return{kind:"extension",contextId:j.aliases[B]??B}}export function resolveProfileContextId(F){const j=resolveProfile(F);if(j.kind==="managed")return;return j.contextId}export function getManagedProfile(F){return loadProfileConfig().managed?.[normalizeContextId(F)??""]}export function listManagedProfiles(){const F=loadProfileConfig().managed??{};return Object.entries(F).map(([j,B])=>({name:j,entry:B})).sort((j,B)=>j.name.localeCompare(B.name))}const X=/^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;export function addManagedProfile(F,j){const B=normalizeContextId(F);if(!B)throw Error("profile 名不能为空");if(!X.test(B))throw Error("profile 名只能包含字母/数字/下划线/连字符,且以字母或数字开头(最长 32 字符)");const H=loadProfileConfig();if(H.managed?.[B])throw Error(`托管 profile "${B}" 已存在`);if(H.aliases[B])throw Error(`"${B}" 已被扩展 profile 别名占用,换个名字`);H.managed={...H.managed,[B]:j};saveProfileConfig(H);return H}export function updateManagedProfile(F,j){const B=normalizeContextId(F);if(!B)throw Error("profile 名不能为空");const H=loadProfileConfig();if(!H.managed?.[B])throw Error(`托管 profile "${B}" 不存在`);H.managed={...H.managed,[B]:j};saveProfileConfig(H);return H}export function removeManagedProfileEntry(F){const j=normalizeContextId(F),B=loadProfileConfig(),H=j?B.managed?.[j]:void 0;if(!j||!H||!B.managed)throw Error(`托管 profile "${F}" 不存在`);delete B.managed[j];if(Object.keys(B.managed).length===0)delete B.managed;if(B.defaultContextId===j)delete B.defaultContextId;saveProfileConfig(B);return H}export function aliasForContextId(F,j){for(const[B,H]of Object.entries(F.aliases))if(H===j)return B;return}export function renameProfile(F,j){const B=normalizeContextId(F),H=normalizeContextId(j);if(!B)throw Error("profile contextId is required");if(!H)throw Error("profile alias is required");const J=loadProfileConfig();if(J.managed?.[H])throw Error(`"${H}" 已被托管 profile 占用,换个别名`);for(const[K,L]of Object.entries(J.aliases))if(K!==H&&L===B)delete J.aliases[K];J.aliases[H]=B;saveProfileConfig(J);return J}export function setDefaultProfile(F){const j=normalizeContextId(F);if(!j)throw Error("profile is required");const B=loadProfileConfig();B.defaultContextId=B.managed?.[j]?j:B.aliases[j]??j;saveProfileConfig(B);return B}
1
+ import*as f from"node:fs";import*as d from"node:os";import*as s from"node:path";export const DEFAULT_CONTEXT_ID="default";function l(){const n=process.env.OPENCLI_CONFIG_DIR||s.join(d.homedir(),".ppcli");return s.join(n,"browser-profiles.json")}export function managedProfilesBaseDir(){const n=process.env.OPENCLI_CONFIG_DIR||s.join(d.homedir(),".ppcli");return s.join(n,"chrome-profiles")}export function normalizeContextId(n){return n?.trim()||void 0}export function emptyProfileConfig(){return{version:1,aliases:{}}}function c(n){return typeof n==="object"&&n!==null&&typeof n.userDataDir==="string"&&n.userDataDir.trim().length>0&&typeof n.port==="number"&&Number.isInteger(n.port)}export function loadProfileConfig(){try{const n=f.readFileSync(l(),"utf-8"),e=JSON.parse(n),t=e.aliases&&typeof e.aliases==="object"?Object.fromEntries(Object.entries(e.aliases).filter((o)=>{const[i,a]=o;return typeof i==="string"&&i.trim().length>0&&typeof a==="string"&&a.trim().length>0})):{},r=e.managed&&typeof e.managed==="object"?Object.fromEntries(Object.entries(e.managed).filter((o)=>{const[i,a]=o;return typeof i==="string"&&i.trim().length>0&&c(a)})):void 0;return{version:1,aliases:t,...typeof e.defaultContextId==="string"&&e.defaultContextId.trim()?{defaultContextId:e.defaultContextId.trim()}:{},...r&&Object.keys(r).length>0?{managed:r}:{}}}catch{return emptyProfileConfig()}}export function saveProfileConfig(n){const e=l();f.mkdirSync(s.dirname(e),{recursive:!0});f.writeFileSync(e,JSON.stringify(n,null,2)+`
2
+ `,"utf-8")}function u(n){const e=loadProfileConfig();return normalizeContextId(n)??normalizeContextId(process.env.OPENCLI_PROFILE)??normalizeContextId(e.defaultContextId)}export function resolveProfile(n){const e=loadProfileConfig(),t=u(n);if(!t)return{kind:"extension"};const r=e.managed?.[t];if(r)return{kind:"managed",name:t,entry:r};return{kind:"extension",contextId:e.aliases[t]??t}}export function resolveProfileContextId(n){const e=resolveProfile(n);if(e.kind==="managed")return;return e.contextId}export function getManagedProfile(n){return loadProfileConfig().managed?.[normalizeContextId(n)??""]}export function listManagedProfiles(){const n=loadProfileConfig().managed??{};return Object.entries(n).map(([e,t])=>({name:e,entry:t})).sort((e,t)=>e.name.localeCompare(t.name))}const m=/^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;export function addManagedProfile(n,e){const t=normalizeContextId(n);if(!t)throw Error("profile 名不能为空");if(!m.test(t))throw Error("profile 名只能包含字母/数字/下划线/连字符,且以字母或数字开头(最长 32 字符)");const r=loadProfileConfig();if(r.managed?.[t])throw Error(`托管 profile "${t}" 已存在`);if(r.aliases[t])throw Error(`"${t}" 已被扩展 profile 别名占用,换个名字`);r.managed={...r.managed,[t]:e};saveProfileConfig(r);return r}export function updateManagedProfile(n,e){const t=normalizeContextId(n);if(!t)throw Error("profile 名不能为空");const r=loadProfileConfig();if(!r.managed?.[t])throw Error(`托管 profile "${t}" 不存在`);r.managed={...r.managed,[t]:e};saveProfileConfig(r);return r}export function removeManagedProfileEntry(n){const e=normalizeContextId(n),t=loadProfileConfig(),r=e?t.managed?.[e]:void 0;if(!e||!r||!t.managed)throw Error(`托管 profile "${n}" 不存在`);delete t.managed[e];if(Object.keys(t.managed).length===0)delete t.managed;if(t.defaultContextId===e)delete t.defaultContextId;saveProfileConfig(t);return r}export function aliasForContextId(n,e){for(const[t,r]of Object.entries(n.aliases))if(r===e)return t;return}export function renameProfile(n,e){const t=normalizeContextId(n),r=normalizeContextId(e);if(!t)throw Error("profile contextId is required");if(!r)throw Error("profile alias is required");const o=loadProfileConfig();if(o.managed?.[r])throw Error(`"${r}" 已被托管 profile 占用,换个别名`);for(const[i,a]of Object.entries(o.aliases))if(i!==r&&a===t)delete o.aliases[i];o.aliases[r]=t;saveProfileConfig(o);return o}export function setDefaultProfile(n){const e=normalizeContextId(n);if(!e)throw Error("profile is required");const t=loadProfileConfig();t.defaultContextId=t.managed?.[e]?e:t.aliases[e]??e;saveProfileConfig(t);return t}