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,4 +1,4 @@
1
- import{CliError as N,CommandExecutionError as j}from"@jackwener/opencli/errors";import{cli as S,Strategy as T}from"@jackwener/opencli/registry";import{readFile as F,stat as h}from"node:fs/promises";import{publishArticle as x,gotoWritePage as C}from"../_shared/article/publish.js";export const infoqProfile={home:"https://xie.infoq.cn",outputFormat:"html",checkAuth:async(H)=>{try{const J={};document.cookie.split("; ").forEach((Q)=>{const G=Q.indexOf("=");if(G>0)J[Q.slice(0,G)]=Q.slice(G+1)});if(J.GCID)return{isAuthenticated:!0,userId:"",username:""};return{isAuthenticated:!1}}catch(J){return{isAuthenticated:!1,error:String(J&&J.message||J)}}},publish:async(H,J)=>{const Q=H.params||{};function G(z){return new Promise((V)=>setTimeout(V,z))}await G(1000);for(let z=0;z<3;z++){const V=[...document.querySelectorAll("button, [gk-button], [role='button'], span")].find((Y)=>/^知道了$/.test((Y.textContent||"").trim()));if(!V)break;V.click();await G(500)}let K=null;{const z=Date.now();while(Date.now()-z<1e4&&!K){K=document.querySelector(".draft-title");if(!K)await G(300)}}if(!K)return{ok:!1,stage:"editor",message:"未找到标题输入框 .draft-title(草稿编辑器未加载)"};if(K.tagName==="INPUT"||K.tagName==="TEXTAREA"){const z=K.tagName==="INPUT"?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(z,"value").set.call(K,H.title);K.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText"}));K.dispatchEvent(new Event("change",{bubbles:!0}))}else if(K.getAttribute("contenteditable")==="true"){K.focus();K.textContent=H.title;K.dispatchEvent(new Event("input",{bubbles:!0}));K.dispatchEvent(new Event("change",{bubbles:!0}))}else{const z=K.querySelector("input")||K.querySelector("textarea");if(z){const V=z.tagName==="INPUT"?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(V,"value").set.call(z,H.title);z.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText"}));z.dispatchEvent(new Event("change",{bubbles:!0}))}else{K.textContent=H.title;K.dispatchEvent(new Event("input",{bubbles:!0}))}}await G(500);const Z=document.querySelector(".DraftEditor-root")||document.querySelector(".ProseMirror")||document.querySelector("[contenteditable=true]"),X=Z?Z.getAttribute&&Z.getAttribute("contenteditable")==="true"?Z:Z.querySelector("[contenteditable=true]")||Z:null;if(!X)return{ok:!1,stage:"editor",message:"未找到正文编辑区(.DraftEditor-root / contenteditable)"};const O=X.innerText||"";let A=!1;try{X.focus();X.innerHTML=H.content;X.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0}));X.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}));await G(300);const z=X.innerText||"";if(z!==O&&z.trim())A=!0}catch(z){}if(!A)try{X.focus();const z=window.getSelection(),V=document.createRange();V.selectNodeContents(X);z.removeAllRanges();z.addRange(V);const Y=new DataTransfer;Y.setData("text/plain",X.innerText||"");Y.setData("text/html",H.content);X.dispatchEvent(new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:Y}));await G(500);const R=X.innerText||"";if(R!==O&&R.trim())A=!0}catch(z){}if(!A)try{X.focus();document.execCommand("selectAll",!1,null);const z=document.execCommand("insertHTML",!1,H.content);await G(300);const V=X.innerText||"";if(z&&V!==O&&V.trim())A=!0}catch(z){}if(!A)return{ok:!1,stage:"editor",message:"正文填充失败:innerHTML / 剪贴板粘贴 / execCommand 三种策略均未生效"};await G(800);const P=Q.tags||[];if(P.length){const z=document.querySelector('input[placeholder*="标签"], input[placeholder*="tag"], .tag-input input, [class*="tag"] input');if(z)for(const V of P.slice(0,5)){z.focus();Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(z,V);z.dispatchEvent(new Event("input",{bubbles:!0}));await G(800);const Y=document.querySelector('[class*="suggest"] li, [class*="dropdown"] li, [class*="option"]');if(Y&&Y.textContent.includes(V))Y.click();else z.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}));await G(400)}}const D="https://xie.infoq.cn/draft/"+Q.draftId;if(H.draftOnly){await G(1500);return{ok:!0,draft:!0,id:String(Q.draftId),url:D}}const W=["[gk-button][gkbtn-color=blue]","[gk-button][gkbtn-color=green]","[gk-button][gkbtn-color=orange]",'[class*="Button_button_"]',".submit-btn",".draft-submit-btn"];let q=null;{const z=Date.now();while(Date.now()-z<1e4&&!q){q=[...document.querySelectorAll('[gk-button], [class*="Button_button_"], button, [role="button"]')].find((V)=>/^(发布|发布文章)$/.test(V.textContent.trim())&&!V.disabled)||null;if(!q)for(const V of W){const Y=document.querySelector(V);if(Y&&!Y.disabled&&/发布/.test(Y.textContent)){q=Y;break}}if(!q)await G(300)}}if(!q)return{ok:!1,stage:"publish",message:"未找到发布按钮"};q.click();const M=[".dialog-footer-buttons [gkbtn-color=green]",".dialog-footer-buttons [gk-button]","[gk-modal-footer] [gk-button]","[gkmodal-color=confirm] [gk-button]","[gkmodal-color=editor-action] [gk-button]","[gkmodal-color=common] [gk-button]","[gkmodal-color=base] [gk-button]",'[gk-modal-footer] [class*="Button_button_"]',".gkui-modal-layer [gk-button]","#gkui-modal-controller [gk-button]"];let L=null;{const z=Date.now();while(Date.now()-z<15000&&!L){const V=document.querySelectorAll(".dialog-setting");let Y=null;for(const $ of V)if($.innerHTML.length>50){Y=$;break}if(Y){const $=Y.querySelector('[gkbtn-color="green"]');if($&&!$.disabled){L=$;break}const _=Y.querySelectorAll(".dialog-footer-buttons [gk-button]");for(const U of _)if(/确定|确认/.test(U.textContent)&&!U.disabled){L=U;break}if(L)break}for(const $ of M){const _=document.querySelector($);if(_&&!_.disabled&&/发布|确认|确定/.test(_.textContent)){L=_;break}}if(L)break;L=[...document.querySelectorAll('[gk-button], [class*="Button_button_"], button')].find(($)=>{if($.disabled)return!1;const _=$.textContent.trim();if(!/^(发布|确认发布|确认|确定)$/.test(_))return!1;return!!$.closest('[gkmodal-color], .gkui-modal-layer, #gkui-modal-controller, .dialog-setting, [class*="modal"], [class*="dialog"]')})||null;if(!L)await G(300)}}if(!L)return{ok:!1,stage:"publish",message:"确认弹窗未出现,文章可能未发布(仅保存为草稿)",detail:{draftUrl:D}};L.click();await G(500);return{ok:!0,draft:!1,id:String(Q.draftId),url:"https://xie.infoq.cn/article/"+Q.draftId}}};function v(H){if(!H.execute)throw new N("INVALID_INPUT","此命令需要 --execute 参数才能执行写操作。注意:本报错仅表示缺少 --execute,并未校验其余参数,不能当 dry-run 预览用")}async function B(H){const J=typeof H.text==="string"?H.text:void 0,Q=typeof H.file==="string"?H.file:void 0;if(J&&Q)throw new N("INVALID_INPUT","不能同时指定正文参数和 --file,请二选一");let G=J??"";if(Q){let K;try{K=await h(Q)}catch{throw new N("INVALID_INPUT","文件不存在: "+Q)}if(!K.isFile())throw new N("INVALID_INPUT","必须是可读的文本文件: "+Q);let Z;try{Z=await F(Q)}catch{throw new N("INVALID_INPUT","无法读取文件: "+Q)}try{G=new TextDecoder("utf-8",{fatal:!0}).decode(Z)}catch{throw new N("INVALID_INPUT","文件必须是 UTF-8 编码: "+Q)}}if(!G.trim())throw new N("INVALID_INPUT","正文不能为空");return G}function w(H,J,Q,G,K={}){return[{status:"success",outcome:G,message:H,target_type:J,target:Q,...K}]}function I(H){const J=[],Q=/!\[[^\]]*\]\(([^)\s]+)[^)]*\)/g;let G;while((G=Q.exec(H))!==null)J.push(G[1]);const K=/<img[^>]+src=["']([^"']+)["']/gi;while((G=K.exec(H))!==null)J.push(G[1]);const Z=J.filter((X)=>!/^(https?:)?\/\//i.test(X)&&!X.startsWith("data:"));if(Z.length)throw new N("INVALID_INPUT","InfoQ 写作社区暂不支持本机图片自动转存(无可靠上传通道),请先把图片发布到可公网访问的 URL 再引用:"+Z.slice(0,3).join(", "))}async function u(H){await C(H,"https://xie.infoq.cn");const J=await H.evaluate(`(async () => {
1
+ import{CliError as b,CommandExecutionError as x}from"@jackwener/opencli/errors";import{cli as E,Strategy as S}from"@jackwener/opencli/registry";import{readFile as v,stat as A}from"node:fs/promises";import{publishArticle as N,gotoWritePage as q}from"../_shared/article/publish.js";export const infoqProfile={home:"https://xie.infoq.cn",outputFormat:"html",checkAuth:async(n)=>{try{const o={};document.cookie.split("; ").forEach((a)=>{const e=a.indexOf("=");if(e>0)o[a.slice(0,e)]=a.slice(e+1)});if(o.GCID)return{isAuthenticated:!0,userId:"",username:""};return{isAuthenticated:!1}}catch(o){return{isAuthenticated:!1,error:String(o&&o.message||o)}}},publish:async(n,o)=>{const a=n.params||{};function e(t){return new Promise((i)=>setTimeout(i,t))}await e(1000);for(let t=0;t<3;t++){const i=[...document.querySelectorAll("button, [gk-button], [role='button'], span")].find((s)=>/^知道了$/.test((s.textContent||"").trim()));if(!i)break;i.click();await e(500)}let r=null;{const t=Date.now();while(Date.now()-t<1e4&&!r){r=document.querySelector(".draft-title");if(!r)await e(300)}}if(!r)return{ok:!1,stage:"editor",message:"未找到标题输入框 .draft-title(草稿编辑器未加载)"};if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"){const t=r.tagName==="INPUT"?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(t,"value").set.call(r,n.title);r.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText"}));r.dispatchEvent(new Event("change",{bubbles:!0}))}else if(r.getAttribute("contenteditable")==="true"){r.focus();r.textContent=n.title;r.dispatchEvent(new Event("input",{bubbles:!0}));r.dispatchEvent(new Event("change",{bubbles:!0}))}else{const t=r.querySelector("input")||r.querySelector("textarea");if(t){const i=t.tagName==="INPUT"?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(i,"value").set.call(t,n.title);t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText"}));t.dispatchEvent(new Event("change",{bubbles:!0}))}else{r.textContent=n.title;r.dispatchEvent(new Event("input",{bubbles:!0}))}}await e(500);const c=document.querySelector(".DraftEditor-root")||document.querySelector(".ProseMirror")||document.querySelector("[contenteditable=true]"),l=c?c.getAttribute&&c.getAttribute("contenteditable")==="true"?c:c.querySelector("[contenteditable=true]")||c:null;if(!l)return{ok:!1,stage:"editor",message:"未找到正文编辑区(.DraftEditor-root / contenteditable)"};const h=l.innerText||"";let f=!1;try{l.focus();l.innerHTML=n.content;l.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0}));l.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}));await e(300);const t=l.innerText||"";if(t!==h&&t.trim())f=!0}catch(t){}if(!f)try{l.focus();const t=window.getSelection(),i=document.createRange();i.selectNodeContents(l);t.removeAllRanges();t.addRange(i);const s=new DataTransfer;s.setData("text/plain",l.innerText||"");s.setData("text/html",n.content);l.dispatchEvent(new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:s}));await e(500);const k=l.innerText||"";if(k!==h&&k.trim())f=!0}catch(t){}if(!f)try{l.focus();document.execCommand("selectAll",!1,null);const t=document.execCommand("insertHTML",!1,n.content);await e(300);const i=l.innerText||"";if(t&&i!==h&&i.trim())f=!0}catch(t){}if(!f)return{ok:!1,stage:"editor",message:"正文填充失败:innerHTML / 剪贴板粘贴 / execCommand 三种策略均未生效"};await e(800);const w=a.tags||[];if(w.length){const t=document.querySelector('input[placeholder*="标签"], input[placeholder*="tag"], .tag-input input, [class*="tag"] input');if(t)for(const i of w.slice(0,5)){t.focus();Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(t,i);t.dispatchEvent(new Event("input",{bubbles:!0}));await e(800);const s=document.querySelector('[class*="suggest"] li, [class*="dropdown"] li, [class*="option"]');if(s&&s.textContent.includes(i))s.click();else t.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}));await e(400)}}const y="https://xie.infoq.cn/draft/"+a.draftId;if(n.draftOnly){await e(1500);return{ok:!0,draft:!0,id:String(a.draftId),url:y}}const m=["[gk-button][gkbtn-color=blue]","[gk-button][gkbtn-color=green]","[gk-button][gkbtn-color=orange]",'[class*="Button_button_"]',".submit-btn",".draft-submit-btn"];let g=null;{const t=Date.now();while(Date.now()-t<1e4&&!g){g=[...document.querySelectorAll('[gk-button], [class*="Button_button_"], button, [role="button"]')].find((i)=>/^(发布|发布文章)$/.test(i.textContent.trim())&&!i.disabled)||null;if(!g)for(const i of m){const s=document.querySelector(i);if(s&&!s.disabled&&/发布/.test(s.textContent)){g=s;break}}if(!g)await e(300)}}if(!g)return{ok:!1,stage:"publish",message:"未找到发布按钮"};g.click();const T=[".dialog-footer-buttons [gkbtn-color=green]",".dialog-footer-buttons [gk-button]","[gk-modal-footer] [gk-button]","[gkmodal-color=confirm] [gk-button]","[gkmodal-color=editor-action] [gk-button]","[gkmodal-color=common] [gk-button]","[gkmodal-color=base] [gk-button]",'[gk-modal-footer] [class*="Button_button_"]',".gkui-modal-layer [gk-button]","#gkui-modal-controller [gk-button]"];let d=null;{const t=Date.now();while(Date.now()-t<15000&&!d){const i=document.querySelectorAll(".dialog-setting");let s=null;for(const u of i)if(u.innerHTML.length>50){s=u;break}if(s){const u=s.querySelector('[gkbtn-color="green"]');if(u&&!u.disabled){d=u;break}const p=s.querySelectorAll(".dialog-footer-buttons [gk-button]");for(const I of p)if(/确定|确认/.test(I.textContent)&&!I.disabled){d=I;break}if(d)break}for(const u of T){const p=document.querySelector(u);if(p&&!p.disabled&&/发布|确认|确定/.test(p.textContent)){d=p;break}}if(d)break;d=[...document.querySelectorAll('[gk-button], [class*="Button_button_"], button')].find((u)=>{if(u.disabled)return!1;const p=u.textContent.trim();if(!/^(发布|确认发布|确认|确定)$/.test(p))return!1;return!!u.closest('[gkmodal-color], .gkui-modal-layer, #gkui-modal-controller, .dialog-setting, [class*="modal"], [class*="dialog"]')})||null;if(!d)await e(300)}}if(!d)return{ok:!1,stage:"publish",message:"确认弹窗未出现,文章可能未发布(仅保存为草稿)",detail:{draftUrl:y}};d.click();await e(500);return{ok:!0,draft:!1,id:String(a.draftId),url:"https://xie.infoq.cn/article/"+a.draftId}}};function D(n){if(!n.execute)throw new b("INVALID_INPUT","此命令需要 --execute 参数才能执行写操作。注意:本报错仅表示缺少 --execute,并未校验其余参数,不能当 dry-run 预览用")}async function P(n){const o=typeof n.text==="string"?n.text:void 0,a=typeof n.file==="string"?n.file:void 0;if(o&&a)throw new b("INVALID_INPUT","不能同时指定正文参数和 --file,请二选一");let e=o??"";if(a){let r;try{r=await A(a)}catch{throw new b("INVALID_INPUT","文件不存在: "+a)}if(!r.isFile())throw new b("INVALID_INPUT","必须是可读的文本文件: "+a);let c;try{c=await v(a)}catch{throw new b("INVALID_INPUT","无法读取文件: "+a)}try{e=new TextDecoder("utf-8",{fatal:!0}).decode(c)}catch{throw new b("INVALID_INPUT","文件必须是 UTF-8 编码: "+a)}}if(!e.trim())throw new b("INVALID_INPUT","正文不能为空");return e}function _(n,o,a,e,r={}){return[{status:"success",outcome:e,message:n,target_type:o,target:a,...r}]}function L(n){const o=[],a=/!\[[^\]]*\]\(([^)\s]+)[^)]*\)/g;let e;while((e=a.exec(n))!==null)o.push(e[1]);const r=/<img[^>]+src=["']([^"']+)["']/gi;while((e=r.exec(n))!==null)o.push(e[1]);const c=o.filter((l)=>!/^(https?:)?\/\//i.test(l)&&!l.startsWith("data:"));if(c.length)throw new b("INVALID_INPUT","InfoQ 写作社区暂不支持本机图片自动转存(无可靠上传通道),请先把图片发布到可公网访问的 URL 再引用:"+c.slice(0,3).join(", "))}async function C(n){await q(n,"https://xie.infoq.cn");const o=await n.evaluate(`(async () => {
2
2
  try {
3
3
  const resp = await fetch('https://xie.infoq.cn/api/v1/draft/create', {
4
4
  method: 'POST',
@@ -16,4 +16,4 @@ import{CliError as N,CommandExecutionError as j}from"@jackwener/opencli/errors";
16
16
  } catch (e) {
17
17
  return { ok: false, message: String((e && e.message) || e) };
18
18
  }
19
- })()`);if(!J||J.ok===!1)throw new j("[draft] "+(J&&J.message||"InfoQ 建草稿失败"));return J.draftId}S({site:"infoq",name:"article",access:"write",description:"发布文章到 InfoQ 写作社区(xie.infoq.cn)。默认正式发布;加 --draft 仅存草稿。正文 Markdown(编辑器吃转换后的富文本)。",domain:"infoq.cn",strategy:T.COOKIE,browser:!0,args:[{name:"title",positional:!0,required:!0,help:"文章标题"},{name:"text",positional:!0,help:"文章正文(默认 Markdown;传 --html 则视为 HTML)"},{name:"file",help:"正文文件路径(UTF-8 编码,默认 Markdown)"},{name:"html",type:"boolean",help:"将正文视为原始 HTML 而非 Markdown"},{name:"tags",help:"文章标签,逗号分隔(可选;按平台联想下拉选择,选不中则回车创建)"},{name:"draft",type:"boolean",help:"仅保存草稿,不发布"},{name:"execute",type:"boolean",help:"确认执行写操作。不加此参数则拒绝写入。"}],columns:["status","outcome","message","target_type","target","created_target","created_url"],func:async(H,J)=>{if(!H)throw new j("InfoQ 文章发布需要浏览器会话");v(J);const Q=String(J.title??"").trim();if(!Q)throw new N("INVALID_INPUT","文章标题不能为空");const G=await B(J);I(G);const K=Boolean(J.draft),Z=String(J.tags??"").split(",").map((W)=>W.trim()).filter(Boolean),X=await u(H),O={...infoqProfile,home:"https://xie.infoq.cn/draft/"+X},A=await x(H,{title:Q,body:G,format:J.html?"html":"markdown",draftOnly:K,profile:O,publishParams:{draftId:X,tags:Z}});let P=A.url;if(!K)try{await H.wait({time:3});const W=await H.evaluate("location.href");if(typeof W==="string"&&/\/article\/[a-zA-Z0-9]+/.test(W))P=W.split("?")[0].split("#")[0]}catch(W){}const D=A.draft?"草稿已保存至 InfoQ 写作社区(编辑器自动保存,需在编辑器内手动发布)":"文章已发布至 InfoQ 写作社区";return w(D,"article","",A.draft?"draft":"publish",{created_target:"article:"+A.id,created_url:P})}});
19
+ })()`);if(!o||o.ok===!1)throw new x("[draft] "+(o&&o.message||"InfoQ 建草稿失败"));return o.draftId}E({site:"infoq",name:"article",access:"write",description:"发布文章到 InfoQ 写作社区(xie.infoq.cn)。默认正式发布;加 --draft 仅存草稿。正文 Markdown(编辑器吃转换后的富文本)。",domain:"infoq.cn",strategy:S.COOKIE,browser:!0,args:[{name:"title",positional:!0,required:!0,help:"文章标题"},{name:"text",positional:!0,help:"文章正文(默认 Markdown;传 --html 则视为 HTML)"},{name:"file",help:"正文文件路径(UTF-8 编码,默认 Markdown)"},{name:"html",type:"boolean",help:"将正文视为原始 HTML 而非 Markdown"},{name:"tags",help:"文章标签,逗号分隔(可选;按平台联想下拉选择,选不中则回车创建)"},{name:"draft",type:"boolean",help:"仅保存草稿,不发布"},{name:"execute",type:"boolean",help:"确认执行写操作。不加此参数则拒绝写入。"}],columns:["status","outcome","message","target_type","target","created_target","created_url"],func:async(n,o)=>{if(!n)throw new x("InfoQ 文章发布需要浏览器会话");D(o);const a=String(o.title??"").trim();if(!a)throw new b("INVALID_INPUT","文章标题不能为空");const e=await P(o);L(e);const r=Boolean(o.draft),c=String(o.tags??"").split(",").map((m)=>m.trim()).filter(Boolean),l=await C(n),h={...infoqProfile,home:"https://xie.infoq.cn/draft/"+l},f=await N(n,{title:a,body:e,format:o.html?"html":"markdown",draftOnly:r,profile:h,publishParams:{draftId:l,tags:c}});let w=f.url;if(!r)try{await n.wait({time:3});const m=await n.evaluate("location.href");if(typeof m==="string"&&/\/article\/[a-zA-Z0-9]+/.test(m))w=m.split("?")[0].split("#")[0]}catch(m){}const y=f.draft?"草稿已保存至 InfoQ 写作社区(编辑器自动保存,需在编辑器内手动发布)":"文章已发布至 InfoQ 写作社区";return _(y,"article","",f.draft?"draft":"publish",{created_target:"article:"+f.id,created_url:w})}});
@@ -1 +1 @@
1
- import{registerArticleLogin as k}from"../_shared/article/login.js";import{infoqProfile as b}from"./article.js";k({site:"infoq",domain:"infoq.cn",profile:{home:b.home,checkAuth:b.checkAuth},loginUrl:"https://xie.infoq.cn",loginDescription:"打开 InfoQ 写作社区并等待浏览器完成登录(供桌面客户端引导登录)。"});
1
+ import{registerArticleLogin as o}from"../_shared/article/login.js";import{infoqProfile as i}from"./article.js";o({site:"infoq",domain:"infoq.cn",profile:{home:i.home,checkAuth:i.checkAuth},loginUrl:"https://xie.infoq.cn",loginDescription:"打开 InfoQ 写作社区并等待浏览器完成登录(供桌面客户端引导登录)。"});
@@ -1 +1 @@
1
- import{cli as A,Strategy as B}from"@jackwener/opencli/registry";import{checkLogin as D,cookieQuickCheck as E}from"../_shared/article/auth.js";import{infoqProfile as x}from"./article.js";const F={home:x.home,checkAuth:x.checkAuth};A({site:"infoq",name:"whoami",access:"read",description:"检测 InfoQ 写作社区(xie.infoq.cn)当前登录状态。",domain:"infoq.cn",strategy:B.COOKIE,browser:!0,columns:["logged_in","user_id","username"],authStatus:{quickCheck:E("https://xie.infoq.cn",["GCID"])},func:async(z)=>{const v=await D(z,F);return[{logged_in:v.isAuthenticated,user_id:v.userId||"",username:v.username||""}]}});
1
+ import{cli as n,Strategy as t}from"@jackwener/opencli/registry";import{checkLogin as c,cookieQuickCheck as r}from"../_shared/article/auth.js";import{infoqProfile as i}from"./article.js";const s={home:i.home,checkAuth:i.checkAuth};n({site:"infoq",name:"whoami",access:"read",description:"检测 InfoQ 写作社区(xie.infoq.cn)当前登录状态。",domain:"infoq.cn",strategy:t.COOKIE,browser:!0,columns:["logged_in","user_id","username"],authStatus:{quickCheck:r("https://xie.infoq.cn",["GCID"])},func:async(o)=>{const e=await c(o,s);return[{logged_in:e.isAuthenticated,user_id:e.userId||"",username:e.username||""}]}});
@@ -1,4 +1,4 @@
1
- import*as L from"node:crypto";import*as U from"node:fs";import*as R from"node:os";import*as V from"node:path";import{spawnSync as z}from"node:child_process";import{CommandExecutionError as K}from"@jackwener/opencli/errors";import{instagramPrivateApiFetch as S}from"./protocol-capture.js";import{buildReadInstagramRuntimeInfoJs as h}from"./runtime-info.js";export{buildReadInstagramRuntimeInfoJs,extractInstagramRuntimeInfo,resolveInstagramRuntimeInfo}from"./runtime-info.js";const C=0.8,M=1.91,D=0.5625,T=0.75,j="FFFFFF",l="https://www.instagram.com/",u="/api/v1/|/graphql/",k=2,v=2,w=20,d=2000,I=15000,n="19ce5f445dbfd9d29c59dc2a78c616a7fc090a8e018b9267bc4240a30244c53b",o="4",p={manufacturer:"samsung",model:"SM-G930F",android_version:24,android_release:"7.0"};export function markPublishOutcomeUncertain(Q){if(Q&&typeof Q==="object")Q.instagramPublishUncertain=!0;return Q}export function isPublishOutcomeUncertain(Q){return Boolean(Q&&typeof Q==="object"&&Q.instagramPublishUncertain)}export function derivePrivateApiContextFromCapture(Q){for(let X=Q.length-1;X>=0;X-=1){const Z=Q[X]?.requestHeaders??{},$={asbdId:String(Z["X-ASBD-ID"]||""),csrfToken:String(Z["X-CSRFToken"]||""),igAppId:String(Z["X-IG-App-ID"]||""),igWwwClaim:String(Z["X-IG-WWW-Claim"]||""),instagramAjax:String(Z["X-Instagram-AJAX"]||""),webSessionId:String(Z["X-Web-Session-ID"]||"")};if($.asbdId&&$.csrfToken&&$.igAppId&&$.igWwwClaim&&$.instagramAjax&&$.webSessionId)return $}return null}function i(Q){const X={};for(let Z=Q.length-1;Z>=0;Z-=1){const $=Q[Z]?.requestHeaders??{};if(!X.asbdId&&$["X-ASBD-ID"])X.asbdId=String($["X-ASBD-ID"]);if(!X.csrfToken&&$["X-CSRFToken"])X.csrfToken=String($["X-CSRFToken"]);if(!X.igAppId&&$["X-IG-App-ID"])X.igAppId=String($["X-IG-App-ID"]);if(!X.igWwwClaim&&$["X-IG-WWW-Claim"])X.igWwwClaim=String($["X-IG-WWW-Claim"]);if(!X.instagramAjax&&$["X-Instagram-AJAX"])X.instagramAjax=String($["X-Instagram-AJAX"]);if(!X.webSessionId&&$["X-Web-Session-ID"])X.webSessionId=String($["X-Web-Session-ID"])}return X}export function deriveInstagramJazoest(Q){if(!Q)return"";return`2${Array.from(Q).reduce((Z,$)=>Z+$.charCodeAt(0),0)}`}function r(Q){return new Promise((X)=>setTimeout(X,Q))}function g(Q){const X=Q instanceof Error?Q.message:String(Q);return/fetch failed|network|socket hang up|econnreset|etimedout/i.test(X)}export function explainPrivateNetworkError(Q,X){const Z=Q instanceof Error?Q.message:String(Q);if(!/certificate verification|fetch failed|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|socket hang up/i.test(Z))return null;let q="i.instagram.com";try{q=new URL(X).host}catch{}const F=Boolean(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy);return`Could not reach ${q} from the CLI process (${Z}).`+(F?" A proxy is configured via environment variables — check that it is running and allows this host.":" Note: uploads are sent from the CLI process, which uses only HTTP_PROXY / HTTPS_PROXY and ignores the OS proxy settings, so browser commands can succeed while publishing fails. If this network needs a proxy to reach Instagram, set HTTPS_PROXY (e.g. http://127.0.0.1:1082) and retry.")+" This is a connectivity problem, not a certificate, account, or image problem."}function s(Q,X){return Q.find((Z)=>Z.name===X)?.value||""}export async function resolveInstagramPrivatePublishConfig(Q){let X;for(let Z=0;Z<k;Z+=1)try{if(typeof Q.startNetworkCapture==="function")await Q.startNetworkCapture(u);await Q.goto(`${l}?__opencli_private_probe=${Date.now()}`);await Q.wait({time:2});const[$,q,F]=await Promise.all([Q.getCookies({domain:"instagram.com"}),Q.evaluate(h()),typeof Q.readNetworkCapture==="function"?Q.readNetworkCapture():Promise.resolve([])]),N=Array.isArray(F)?F:[],W=derivePrivateApiContextFromCapture(N)??i(N),O=q?.csrfToken||s($,"csrftoken")||W.csrfToken||"",J=q?.appId||W.igAppId||"",G=q?.instagramAjax||W.instagramAjax||"";if(!O)throw new K("Instagram private route could not derive CSRF token from browser session");if(!J)throw new K("Instagram private route could not derive X-IG-App-ID from instagram runtime");if(!G)throw new K("Instagram private route could not derive X-Instagram-AJAX from instagram runtime");const H=W.asbdId||"",Y=W.igWwwClaim||"",y=W.webSessionId||"";return{apiContext:{asbdId:H,csrfToken:O,igAppId:J,igWwwClaim:Y,instagramAjax:G,webSessionId:y},jazoest:deriveInstagramJazoest(O)}}catch($){X=$;if(!g($)||Z>=k-1)throw $}throw X instanceof Error?X:Error(String(X))}export function buildConfigureBody(Q){const X=new URLSearchParams;X.set("archive_only","false");X.set("caption",Q.caption);X.set("clips_share_preview_to_feed","1");X.set("disable_comments","0");X.set("disable_oa_reuse","false");X.set("igtv_share_preview_to_feed","1");X.set("is_meta_only_post","0");X.set("is_unified_video","1");X.set("like_and_view_counts_disabled","0");X.set("media_share_flow","creation_flow");X.set("share_to_facebook","");X.set("share_to_fb_destination_type","USER");X.set("source_type","library");X.set("upload_id",Q.uploadId);X.set("video_subtitles_enabled","0");X.set("jazoest",Q.jazoest);return X.toString()}export function buildConfigureSidecarPayload(Q){return{archive_only:!1,caption:Q.caption,children_metadata:Q.uploadIds.map((X)=>({upload_id:X})),client_sidecar_id:Q.clientSidecarId,disable_comments:"0",is_meta_only_post:!1,is_open_to_public_submission:!1,like_and_view_counts_disabled:0,media_share_flow:"creation_flow",share_to_facebook:"",share_to_fb_destination_type:"USER",source_type:"library",jazoest:Q.jazoest}}function a(Q){switch(V.extname(Q).toLowerCase()){case".png":return"image/png";case".webp":return"image/webp";case".jpg":case".jpeg":default:return"image/jpeg"}}function t(Q){if(Q.length<24)return null;if(Q.subarray(0,8).toString("hex").toUpperCase()!=="89504E470D0A1A0A")return null;if(Q.subarray(12,16).toString("ascii")!=="IHDR")return null;return{width:Q.readUInt32BE(16),height:Q.readUInt32BE(20)}}function e(Q){if(Q.length<4||Q[0]!==255||Q[1]!==216)return null;let X=2;while(X+9<Q.length){if(Q[X]!==255){X+=1;continue}const Z=Q[X+1];X+=2;if(Z===216||Z===217)continue;if(X+2>Q.length)break;const $=Q.readUInt16BE(X);if($<2||X+$>Q.length)break;if(Z>=192&&Z<=207&&![196,200,204].includes(Z)&&$>=7)return{height:Q.readUInt16BE(X+3),width:Q.readUInt16BE(X+5)};X+=$}return null}function QQ(Q){if(Q.length<30)return null;if(Q.subarray(0,4).toString("ascii")!=="RIFF"||Q.subarray(8,12).toString("ascii")!=="WEBP")return null;const X=Q.subarray(12,16).toString("ascii");if(X==="VP8X"&&Q.length>=30)return{width:1+Q.readUIntLE(24,3),height:1+Q.readUIntLE(27,3)};if(X==="VP8 "&&Q.length>=30)return{width:Q.readUInt16LE(26)&16383,height:Q.readUInt16LE(28)&16383};if(X==="VP8L"&&Q.length>=25){const Z=Q.readUInt32LE(21);return{width:(Z&16383)+1,height:(Z>>14&16383)+1}}return null}function XQ(Q,X){const Z=V.extname(Q).toLowerCase(),$=Z===".png"?t(X):Z===".webp"?QQ(X):e(X);if(!$)throw new K(`Failed to read image dimensions for ${Q}`);return $}export function readImageAsset(Q){const X=U.readFileSync(Q),{width:Z,height:$}=XQ(Q,X);return{filePath:Q,fileName:V.basename(Q),mimeType:a(Q),width:Z,height:$,byteLength:X.length,bytes:X}}export function isInstagramFeedAspectRatioAllowed(Q,X){const Z=Q/Math.max(X,1);return Z>=C-0.001&&Z<=M+0.001}export function getInstagramFeedNormalizedDimensions(Q,X){const Z=Q/Math.max(X,1);if(Z<C)return{width:Math.ceil(X*C),height:X};if(Z>M)return{width:Q,height:Math.ceil(Q/M)};return null}export function isInstagramStoryAspectRatioAllowed(Q,X){const Z=Q/Math.max(X,1);return Z>=D-0.001&&Z<=T+0.001}export function getInstagramStoryNormalizedDimensions(Q,X){const Z=Q/Math.max(X,1);if(Z<D)return{width:Math.ceil(X*D),height:X};if(Z>T)return{width:Q,height:Math.ceil(Q/T)};return null}function x(Q){const X=V.parse(Q);return V.join(R.tmpdir(),`opencli-instagram-private-${X.name}-${L.randomUUID()}${X.ext||".png"}`)}export function prepareImageAssetForPrivateUpload(Q){const X=readImageAsset(Q),Z=getInstagramFeedNormalizedDimensions(X.width,X.height);if(!Z)return X;if(process.platform!=="darwin")throw new K(`Instagram private publish does not support auto-normalizing ${X.fileName} on ${process.platform}`,`Use images within ${C.toFixed(2)}-${M.toFixed(2)} aspect ratio, or use the UI route`);const $=x(Q),q=z("sips",["--padToHeightWidth",String(Z.height),String(Z.width),"--padColor",j,Q,"--out",$],{encoding:"utf8"});if(q.error||q.status!==0||!U.existsSync($)){const F=[q.error?.message,q.stderr,q.stdout].map((N)=>String(N||"").trim()).filter(Boolean).join(" ");throw new K(`Instagram private publish failed to normalize ${X.fileName}`,F||"sips padToHeightWidth failed")}return{...readImageAsset($),cleanupPath:$}}export function prepareImageAssetForPrivateStoryUpload(Q){const X=readImageAsset(Q),Z=getInstagramStoryNormalizedDimensions(X.width,X.height);if(!Z)return X;if(process.platform!=="darwin")throw new K(`Instagram private story publish does not support auto-normalizing ${X.fileName} on ${process.platform}`,`Use images within ${D.toFixed(2)}-${T.toFixed(2)} aspect ratio, or use the UI route`);const $=x(Q),q=z("sips",["--padToHeightWidth",String(Z.height),String(Z.width),"--padColor",j,Q,"--out",$],{encoding:"utf8"});if(q.error||q.status!==0||!U.existsSync($)){const F=[q.error?.message,q.stderr,q.stdout].map((N)=>String(N||"").trim()).filter(Boolean).join(" ");throw new K(`Instagram private story publish failed to normalize ${X.fileName}`,F||"sips padToHeightWidth failed")}return{...readImageAsset($),cleanupPath:$}}function A(Q,X,Z){const $=V.join(R.tmpdir(),`opencli-instagram-${L.randomUUID()}.swift`);U.writeFileSync($,Q);try{const q=z("swift",[$,...X],{encoding:"utf8"});if(q.error||q.status!==0){const F=[q.error?.message,q.stderr,q.stdout].map((N)=>String(N||"").trim()).filter(Boolean).join(" ");throw new K(`Instagram private publish failed to ${Z}`,F||"swift helper failed")}return JSON.parse(String(q.stdout||"{}"))}catch(q){if(q instanceof K)throw q;throw new K(`Instagram private publish failed to ${Z}`,q instanceof Error?q.message:String(q))}finally{U.rmSync($,{force:!0})}}function ZQ(Q){if(process.platform!=="darwin")throw new K(`Instagram private mixed-media publish does not support reading video metadata on ${process.platform}`,"Use macOS for private mixed-media publishing, or rely on the UI fallback");const X=A(`
1
+ import*as w from"node:crypto";import*as h from"node:fs";import*as S from"node:os";import*as u from"node:path";import{spawnSync as b}from"node:child_process";import{CommandExecutionError as n}from"@jackwener/opencli/errors";import{instagramPrivateApiFetch as P}from"./protocol-capture.js";import{buildReadInstagramRuntimeInfoJs as z}from"./runtime-info.js";export{buildReadInstagramRuntimeInfoJs,extractInstagramRuntimeInfo,resolveInstagramRuntimeInfo}from"./runtime-info.js";const I=0.8,y=1.91,v=0.5625,A=0.75,R="FFFFFF",V="https://www.instagram.com/",W="/api/v1/|/graphql/",C=2,E=2,M=20,G=2000,O=15000,J="19ce5f445dbfd9d29c59dc2a78c616a7fc090a8e018b9267bc4240a30244c53b",B="4",H={manufacturer:"samsung",model:"SM-G930F",android_version:24,android_release:"7.0"};export function markPublishOutcomeUncertain(e){if(e&&typeof e==="object")e.instagramPublishUncertain=!0;return e}export function isPublishOutcomeUncertain(e){return Boolean(e&&typeof e==="object"&&e.instagramPublishUncertain)}export function derivePrivateApiContextFromCapture(e){for(let t=e.length-1;t>=0;t-=1){const a=e[t]?.requestHeaders??{},r={asbdId:String(a["X-ASBD-ID"]||""),csrfToken:String(a["X-CSRFToken"]||""),igAppId:String(a["X-IG-App-ID"]||""),igWwwClaim:String(a["X-IG-WWW-Claim"]||""),instagramAjax:String(a["X-Instagram-AJAX"]||""),webSessionId:String(a["X-Web-Session-ID"]||"")};if(r.asbdId&&r.csrfToken&&r.igAppId&&r.igWwwClaim&&r.instagramAjax&&r.webSessionId)return r}return null}function Y(e){const t={};for(let a=e.length-1;a>=0;a-=1){const r=e[a]?.requestHeaders??{};if(!t.asbdId&&r["X-ASBD-ID"])t.asbdId=String(r["X-ASBD-ID"]);if(!t.csrfToken&&r["X-CSRFToken"])t.csrfToken=String(r["X-CSRFToken"]);if(!t.igAppId&&r["X-IG-App-ID"])t.igAppId=String(r["X-IG-App-ID"]);if(!t.igWwwClaim&&r["X-IG-WWW-Claim"])t.igWwwClaim=String(r["X-IG-WWW-Claim"]);if(!t.instagramAjax&&r["X-Instagram-AJAX"])t.instagramAjax=String(r["X-Instagram-AJAX"]);if(!t.webSessionId&&r["X-Web-Session-ID"])t.webSessionId=String(r["X-Web-Session-ID"])}return t}export function deriveInstagramJazoest(e){if(!e)return"";return`2${Array.from(e).reduce((a,r)=>a+r.charCodeAt(0),0)}`}function q(e){return new Promise((t)=>setTimeout(t,e))}function U(e){const t=e instanceof Error?e.message:String(e);return/fetch failed|network|socket hang up|econnreset|etimedout/i.test(t)}export function explainPrivateNetworkError(e,t){const a=e instanceof Error?e.message:String(e);if(!/certificate verification|fetch failed|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|socket hang up/i.test(a))return null;let i="i.instagram.com";try{i=new URL(t).host}catch{}const o=Boolean(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy);return`Could not reach ${i} from the CLI process (${a}).`+(o?" A proxy is configured via environment variables — check that it is running and allows this host.":" Note: uploads are sent from the CLI process, which uses only HTTP_PROXY / HTTPS_PROXY and ignores the OS proxy settings, so browser commands can succeed while publishing fails. If this network needs a proxy to reach Instagram, set HTTPS_PROXY (e.g. http://127.0.0.1:1082) and retry.")+" This is a connectivity problem, not a certificate, account, or image problem."}function K(e,t){return e.find((a)=>a.name===t)?.value||""}export async function resolveInstagramPrivatePublishConfig(e){let t;for(let a=0;a<C;a+=1)try{if(typeof e.startNetworkCapture==="function")await e.startNetworkCapture(W);await e.goto(`${V}?__opencli_private_probe=${Date.now()}`);await e.wait({time:2});const[r,i,o]=await Promise.all([e.getCookies({domain:"instagram.com"}),e.evaluate(z()),typeof e.readNetworkCapture==="function"?e.readNetworkCapture():Promise.resolve([])]),s=Array.isArray(o)?o:[],c=derivePrivateApiContextFromCapture(s)??Y(s),d=i?.csrfToken||K(r,"csrftoken")||c.csrfToken||"",l=i?.appId||c.igAppId||"",p=i?.instagramAjax||c.instagramAjax||"";if(!d)throw new n("Instagram private route could not derive CSRF token from browser session");if(!l)throw new n("Instagram private route could not derive X-IG-App-ID from instagram runtime");if(!p)throw new n("Instagram private route could not derive X-Instagram-AJAX from instagram runtime");const m=c.asbdId||"",f=c.igWwwClaim||"",L=c.webSessionId||"";return{apiContext:{asbdId:m,csrfToken:d,igAppId:l,igWwwClaim:f,instagramAjax:p,webSessionId:L},jazoest:deriveInstagramJazoest(d)}}catch(r){t=r;if(!U(r)||a>=C-1)throw r}throw t instanceof Error?t:Error(String(t))}export function buildConfigureBody(e){const t=new URLSearchParams;t.set("archive_only","false");t.set("caption",e.caption);t.set("clips_share_preview_to_feed","1");t.set("disable_comments","0");t.set("disable_oa_reuse","false");t.set("igtv_share_preview_to_feed","1");t.set("is_meta_only_post","0");t.set("is_unified_video","1");t.set("like_and_view_counts_disabled","0");t.set("media_share_flow","creation_flow");t.set("share_to_facebook","");t.set("share_to_fb_destination_type","USER");t.set("source_type","library");t.set("upload_id",e.uploadId);t.set("video_subtitles_enabled","0");t.set("jazoest",e.jazoest);return t.toString()}export function buildConfigureSidecarPayload(e){return{archive_only:!1,caption:e.caption,children_metadata:e.uploadIds.map((t)=>({upload_id:t})),client_sidecar_id:e.clientSidecarId,disable_comments:"0",is_meta_only_post:!1,is_open_to_public_submission:!1,like_and_view_counts_disabled:0,media_share_flow:"creation_flow",share_to_facebook:"",share_to_fb_destination_type:"USER",source_type:"library",jazoest:e.jazoest}}function Q(e){switch(u.extname(e).toLowerCase()){case".png":return"image/png";case".webp":return"image/webp";case".jpg":case".jpeg":default:return"image/jpeg"}}function Z(e){if(e.length<24)return null;if(e.subarray(0,8).toString("hex").toUpperCase()!=="89504E470D0A1A0A")return null;if(e.subarray(12,16).toString("ascii")!=="IHDR")return null;return{width:e.readUInt32BE(16),height:e.readUInt32BE(20)}}function ee(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;while(t+9<e.length){if(e[t]!==255){t+=1;continue}const a=e[t+1];t+=2;if(a===216||a===217)continue;if(t+2>e.length)break;const r=e.readUInt16BE(t);if(r<2||t+r>e.length)break;if(a>=192&&a<=207&&![196,200,204].includes(a)&&r>=7)return{height:e.readUInt16BE(t+3),width:e.readUInt16BE(t+5)};t+=r}return null}function te(e){if(e.length<30)return null;if(e.subarray(0,4).toString("ascii")!=="RIFF"||e.subarray(8,12).toString("ascii")!=="WEBP")return null;const t=e.subarray(12,16).toString("ascii");if(t==="VP8X"&&e.length>=30)return{width:1+e.readUIntLE(24,3),height:1+e.readUIntLE(27,3)};if(t==="VP8 "&&e.length>=30)return{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t==="VP8L"&&e.length>=25){const a=e.readUInt32LE(21);return{width:(a&16383)+1,height:(a>>14&16383)+1}}return null}function ae(e,t){const a=u.extname(e).toLowerCase(),r=a===".png"?Z(t):a===".webp"?te(t):ee(t);if(!r)throw new n(`Failed to read image dimensions for ${e}`);return r}export function readImageAsset(e){const t=h.readFileSync(e),{width:a,height:r}=ae(e,t);return{filePath:e,fileName:u.basename(e),mimeType:Q(e),width:a,height:r,byteLength:t.length,bytes:t}}export function isInstagramFeedAspectRatioAllowed(e,t){const a=e/Math.max(t,1);return a>=I-0.001&&a<=y+0.001}export function getInstagramFeedNormalizedDimensions(e,t){const a=e/Math.max(t,1);if(a<I)return{width:Math.ceil(t*I),height:t};if(a>y)return{width:e,height:Math.ceil(e/y)};return null}export function isInstagramStoryAspectRatioAllowed(e,t){const a=e/Math.max(t,1);return a>=v-0.001&&a<=A+0.001}export function getInstagramStoryNormalizedDimensions(e,t){const a=e/Math.max(t,1);if(a<v)return{width:Math.ceil(t*v),height:t};if(a>A)return{width:e,height:Math.ceil(e/A)};return null}function N(e){const t=u.parse(e);return u.join(S.tmpdir(),`opencli-instagram-private-${t.name}-${w.randomUUID()}${t.ext||".png"}`)}export function prepareImageAssetForPrivateUpload(e){const t=readImageAsset(e),a=getInstagramFeedNormalizedDimensions(t.width,t.height);if(!a)return t;if(process.platform!=="darwin")throw new n(`Instagram private publish does not support auto-normalizing ${t.fileName} on ${process.platform}`,`Use images within ${I.toFixed(2)}-${y.toFixed(2)} aspect ratio, or use the UI route`);const r=N(e),i=b("sips",["--padToHeightWidth",String(a.height),String(a.width),"--padColor",R,e,"--out",r],{encoding:"utf8"});if(i.error||i.status!==0||!h.existsSync(r)){const o=[i.error?.message,i.stderr,i.stdout].map((s)=>String(s||"").trim()).filter(Boolean).join(" ");throw new n(`Instagram private publish failed to normalize ${t.fileName}`,o||"sips padToHeightWidth failed")}return{...readImageAsset(r),cleanupPath:r}}export function prepareImageAssetForPrivateStoryUpload(e){const t=readImageAsset(e),a=getInstagramStoryNormalizedDimensions(t.width,t.height);if(!a)return t;if(process.platform!=="darwin")throw new n(`Instagram private story publish does not support auto-normalizing ${t.fileName} on ${process.platform}`,`Use images within ${v.toFixed(2)}-${A.toFixed(2)} aspect ratio, or use the UI route`);const r=N(e),i=b("sips",["--padToHeightWidth",String(a.height),String(a.width),"--padColor",R,e,"--out",r],{encoding:"utf8"});if(i.error||i.status!==0||!h.existsSync(r)){const o=[i.error?.message,i.stderr,i.stdout].map((s)=>String(s||"").trim()).filter(Boolean).join(" ");throw new n(`Instagram private story publish failed to normalize ${t.fileName}`,o||"sips padToHeightWidth failed")}return{...readImageAsset(r),cleanupPath:r}}function x(e,t,a){const r=u.join(S.tmpdir(),`opencli-instagram-${w.randomUUID()}.swift`);h.writeFileSync(r,e);try{const i=b("swift",[r,...t],{encoding:"utf8"});if(i.error||i.status!==0){const o=[i.error?.message,i.stderr,i.stdout].map((s)=>String(s||"").trim()).filter(Boolean).join(" ");throw new n(`Instagram private publish failed to ${a}`,o||"swift helper failed")}return JSON.parse(String(i.stdout||"{}"))}catch(i){if(i instanceof n)throw i;throw new n(`Instagram private publish failed to ${a}`,i instanceof Error?i.message:String(i))}finally{h.rmSync(r,{force:!0})}}function re(e){if(process.platform!=="darwin")throw new n(`Instagram private mixed-media publish does not support reading video metadata on ${process.platform}`,"Use macOS for private mixed-media publishing, or rely on the UI fallback");const t=x(`
2
2
  import AVFoundation
3
3
  import Foundation
4
4
 
@@ -20,7 +20,7 @@ let payload: [String: Int] = [
20
20
  ]
21
21
  let data = try JSONSerialization.data(withJSONObject: payload, options: [])
22
22
  FileHandle.standardOutput.write(data)
23
- `,[Q],"read video metadata");if(!X.width||!X.height||!X.durationMs)throw new K(`Instagram private publish failed to read video metadata for ${Q}`);return{width:X.width,height:X.height,durationMs:X.durationMs}}function $Q(Q){const X=V.parse(Q);return V.join(R.tmpdir(),`opencli-instagram-private-video-cover-${X.name}-${L.randomUUID()}.jpg`)}function qQ(Q){const X=V.parse(Q);return V.join(R.tmpdir(),`opencli-instagram-story-video-${X.name}-${L.randomUUID()}${X.ext||".mp4"}`)}function FQ(Q){if(process.platform!=="darwin")throw new K(`Instagram private mixed-media publish does not support generating video covers on ${process.platform}`,"Use macOS for private mixed-media publishing, or rely on the UI fallback");const X=$Q(Q);A(`
23
+ `,[e],"read video metadata");if(!t.width||!t.height||!t.durationMs)throw new n(`Instagram private publish failed to read video metadata for ${e}`);return{width:t.width,height:t.height,durationMs:t.durationMs}}function ie(e){const t=u.parse(e);return u.join(S.tmpdir(),`opencli-instagram-private-video-cover-${t.name}-${w.randomUUID()}.jpg`)}function oe(e){const t=u.parse(e);return u.join(S.tmpdir(),`opencli-instagram-story-video-${t.name}-${w.randomUUID()}${t.ext||".mp4"}`)}function ne(e){if(process.platform!=="darwin")throw new n(`Instagram private mixed-media publish does not support generating video covers on ${process.platform}`,"Use macOS for private mixed-media publishing, or rely on the UI fallback");const t=ie(e);x(`
24
24
  import AVFoundation
25
25
  import AppKit
26
26
  import Foundation
@@ -40,7 +40,7 @@ try data.write(to: URL(fileURLWithPath: outputPath))
40
40
  let payload = ["ok": true]
41
41
  let json = try JSONSerialization.data(withJSONObject: payload, options: [])
42
42
  FileHandle.standardOutput.write(json)
43
- `,[Q,X],"generate video cover");return{...readImageAsset(X),cleanupPath:X}}export function readVideoAsset(Q){const X=U.readFileSync(Q),Z=ZQ(Q),$=FQ(Q);return{filePath:Q,fileName:V.basename(Q),mimeType:"video/mp4",width:Z.width,height:Z.height,durationMs:Z.durationMs,byteLength:X.length,bytes:X,coverImage:$,cleanupPaths:$.cleanupPath?[$.cleanupPath]:[]}}function KQ(Q,X){if(process.platform!=="darwin")throw new K(`Instagram private story publish does not support trimming long videos on ${process.platform}`,"Use macOS for private story video publishing, or trim the video to 15 seconds first");const Z=qQ(Q);A(`
43
+ `,[e,t],"generate video cover");return{...readImageAsset(t),cleanupPath:t}}export function readVideoAsset(e){const t=h.readFileSync(e),a=re(e),r=ne(e);return{filePath:e,fileName:u.basename(e),mimeType:"video/mp4",width:a.width,height:a.height,durationMs:a.durationMs,byteLength:t.length,bytes:t,coverImage:r,cleanupPaths:r.cleanupPath?[r.cleanupPath]:[]}}function se(e,t){if(process.platform!=="darwin")throw new n(`Instagram private story publish does not support trimming long videos on ${process.platform}`,"Use macOS for private story video publishing, or trim the video to 15 seconds first");const a=oe(e);x(`
44
44
  import AVFoundation
45
45
  import Foundation
46
46
 
@@ -72,4 +72,4 @@ if exportSession.status != .completed {
72
72
  let payload = ["ok": true]
73
73
  let json = try JSONSerialization.data(withJSONObject: payload, options: [])
74
74
  FileHandle.standardOutput.write(json)
75
- `,[Q,Z,String(X)],"trim story video");return Z}function NQ(Q){const X=readVideoAsset(Q);if(X.durationMs<=I)return X;const Z=KQ(Q,I),$=readVideoAsset(Z);return{...$,cleanupPaths:[...$.cleanupPaths||[],Z]}}function P(Q){const X=Q();return X>10000000000?Math.floor(X/1000):Math.floor(X)}export function buildConfigureToStoryPhotoPayload(Q){const X=Q.now??(()=>Date.now()),Z=P(X);return{source_type:"4",upload_id:Q.uploadId,story_media_creation_date:String(Z-17),client_shared_at:String(Z-5),client_timestamp:String(Z),configure_mode:1,edits:{crop_original_size:[Q.width,Q.height],crop_center:[0,0],crop_zoom:1.3333334},extra:{source_width:Q.width,source_height:Q.height},jazoest:Q.jazoest}}export function buildConfigureToStoryVideoPayload(Q){const X=Q.now??(()=>Date.now()),Z=P(X),$=Number((Q.durationMs/1000).toFixed(3));return{source_type:"4",upload_id:Q.uploadId,story_media_creation_date:String(Z-17),client_shared_at:String(Z-5),client_timestamp:String(Z),configure_mode:1,poster_frame_index:0,length:$,audio_muted:!1,filter_type:"0",video_result:"deprecated",extra:{source_width:Q.width,source_height:Q.height},jazoest:Q.jazoest}}function LQ(Q){const X=new URLSearchParams;for(const[Z,$]of Object.entries(Q)){if($===void 0||$===null)continue;if(typeof $==="object"){X.set(Z,JSON.stringify($));continue}X.set(Z,String($))}return X.toString()}function b(Q){const X=JSON.stringify(Q),Z=L.createHmac("sha256",n).update(X).digest("hex"),$=new URLSearchParams;$.set("ig_sig_key_version",o);$.set("signed_body",`${Z}.${X}`);return $.toString()}function _(Q){return Object.fromEntries(Object.entries({"X-ASBD-ID":Q.asbdId,"X-CSRFToken":Q.csrfToken,"X-IG-App-ID":Q.igAppId,"X-IG-WWW-Claim":Q.igWwwClaim,"X-Instagram-AJAX":Q.instagramAjax,"X-Web-Session-ID":Q.webSessionId}).filter(([,X])=>!!X))}function OQ(Q,X,Z){return{..._(Z),Accept:"*/*","Content-Type":Q.mimeType,Offset:"0","X-Entity-Length":String(Q.byteLength),"X-Entity-Name":`fb_uploader_${X}`,"X-Entity-Type":Q.mimeType,"X-Instagram-Rupload-Params":JSON.stringify({media_type:1,upload_id:X,upload_media_height:Q.height,upload_media_width:Q.width})}}function m(Q){const X=Math.min(Q.width,Q.height),Z=Number((Q.durationMs/1000).toFixed(3));return{crop_height:X,crop_width:X,crop_x1:Math.max(0,Math.floor((Q.width-X)/2)),crop_y1:Math.max(0,Math.floor((Q.height-X)/2)),mute:!1,trim_end:Z,trim_start:0}}function WQ(Q,X,Z){return{..._(Z),Accept:"*/*",Offset:"0","X-Entity-Length":String(Q.byteLength),"X-Entity-Name":`fb_uploader_${X}`,"X-Instagram-Rupload-Params":JSON.stringify({"client-passthrough":"1",is_unified_video:"0",is_sidecar:"1",media_type:2,for_album:!1,video_format:"",upload_id:X,upload_media_duration_ms:Q.durationMs,upload_media_height:Q.height,upload_media_width:Q.width,video_transform:null,video_edit_params:m(Q)})}}function GQ(Q,X,Z){return{..._(Z),Accept:"*/*",Offset:"0","X-Entity-Length":String(Q.byteLength),"X-Entity-Name":`fb_uploader_${X}`,"X-Instagram-Rupload-Params":JSON.stringify({"client-passthrough":"1",media_type:2,upload_id:X,upload_media_duration_ms:Q.durationMs,upload_media_height:Q.height,upload_media_width:Q.width,video_transform:null,video_edit_params:m(Q)})}}function HQ(Q,X,Z){return{..._(Z),Accept:"*/*","Content-Type":Q.coverImage.mimeType,Offset:"0","X-Entity-Length":String(Q.coverImage.byteLength),"X-Entity-Name":`fb_uploader_${X}`,"X-Entity-Type":Q.coverImage.mimeType,"X-Instagram-Rupload-Params":JSON.stringify({media_type:2,upload_id:X,upload_media_height:Q.height,upload_media_width:Q.width})}}async function B(Q,X){const Z=await Q.text();let $;try{$=Z?JSON.parse(Z):{}}catch{throw new K(`Instagram private publish ${X} returned invalid JSON`)}if(!Q.ok){const q=Z?` ${Z.slice(0,500)}`:"";throw new K(`Instagram private publish ${X} failed: ${Q.status}${q}`)}return $}async function E(Q,X,Z){let $;for(let F=0;F<v;F+=1)try{return await Q(X,Z)}catch(N){$=N;if(!g(N)||F>=v-1){const W=explainPrivateNetworkError(N,X);if(W)throw new K(`Instagram private publish upload failed: ${W}`);throw N}}const q=explainPrivateNetworkError($,X);if(q)throw new K(`Instagram private publish upload failed: ${q}`);throw $ instanceof Error?$:Error(String($))}async function JQ(Q){if(Q.type==="video")return{type:"video",asset:readVideoAsset(Q.filePath)};return{type:"image",asset:prepareImageAssetForPrivateUpload(Q.filePath)}}function f(Q){for(const X of Q){if(X.type==="image"){if(X.asset.cleanupPath)U.rmSync(X.asset.cleanupPath,{force:!0});continue}for(const Z of X.asset.cleanupPaths||[])U.rmSync(Z,{force:!0});if(X.asset.coverImage.cleanupPath)U.rmSync(X.asset.coverImage.cleanupPath,{force:!0})}}async function c(Q,X,Z,$,q="feed"){if(X.type==="image"){const J=await E(Q,`https://i.instagram.com/rupload_igphoto/fb_uploader_${Z}`,{method:"POST",headers:OQ(X.asset,Z,$),body:X.asset.bytes}),G=await B(J,"upload");if(String(G?.status||"")!=="ok")throw new K(`Instagram private publish upload failed for ${X.asset.fileName}`);return}const F=await E(Q,`https://i.instagram.com/rupload_igvideo/fb_uploader_${Z}`,{method:"POST",headers:q==="story"?GQ(X.asset,Z,$):WQ(X.asset,Z,$),body:X.asset.bytes}),N=await B(F,"video upload");if(String(N?.status||"")!=="ok")throw new K(`Instagram private publish video upload failed for ${X.asset.fileName}`);const W=await E(Q,`https://i.instagram.com/rupload_igphoto/fb_uploader_${Z}`,{method:"POST",headers:HQ(X.asset,Z,$),body:X.asset.coverImage.bytes}),O=await B(W,"video cover upload");if(String(O?.status||"")!=="ok")throw new K(`Instagram private publish video cover upload failed for ${X.asset.fileName}`)}async function VQ(Q){const X=Q.waitMs??r,Z={method:"POST",headers:{..._(Q.apiContext),"Content-Type":"application/json"},body:JSON.stringify(Q.payload)};for(let $=0;$<w;$+=1){let q,F;try{q=await Q.fetcher("https://www.instagram.com/api/v1/media/configure_sidecar/",Z);F=await q.text()}catch(O){throw markPublishOutcomeUncertain(O instanceof Error?O:new K(`Instagram private publish configure_sidecar request failed: ${String(O)}`))}let N={};try{N=F?JSON.parse(F):{}}catch{throw markPublishOutcomeUncertain(new K("Instagram private publish configure_sidecar returned invalid JSON"))}if(!q.ok){const O=F?` ${F.slice(0,500)}`:"";throw markPublishOutcomeUncertain(new K(`Instagram private publish configure_sidecar failed: ${q.status}${O}`))}const W=String(N?.message||"");if(q.status===202||/transcode not finished yet/i.test(W)){if($>=w-1)throw markPublishOutcomeUncertain(new K("Instagram private publish configure_sidecar timed out waiting for video transcode",F.slice(0,500)));await X(d);continue}if(String(N?.status||"").toLowerCase()==="fail")throw new K("Instagram private publish configure_sidecar failed",W||F.slice(0,500));return{code:N?.media?.code,mediaId:String(N?.media?.id||"")}}throw new K("Instagram private publish configure_sidecar failed")}export async function publishMediaViaPrivateApi(Q){const X=Q.now??(()=>Date.now()),Z=String(X()),$=Q.mediaItems.length>1?Q.mediaItems.map((W,O)=>String(X()+O+1)):[String(X())],q=Q.fetcher??((W,O)=>S(Q.page,W,O)),F=Q.prepareMediaAsset??JQ,N=await Promise.all(Q.mediaItems.map((W)=>F(W)));try{for(let O=0;O<N.length;O+=1){const J=N[O],G=$[O];await c(q,J,G,Q.apiContext)}if($.length===1){if(N[0]?.type!=="image")throw new K("Instagram private publish only supports single-video uploads through instagram reel");let O;try{const J=await q("https://www.instagram.com/api/v1/media/configure/",{method:"POST",headers:{..._(Q.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:buildConfigureBody({uploadId:$[0],caption:Q.caption,jazoest:Q.jazoest})});O=await B(J,"configure")}catch(J){throw markPublishOutcomeUncertain(J instanceof Error?J:new K(`Instagram private publish configure request failed: ${String(J)}`))}return{code:O?.media?.code,mediaId:String(O?.media?.id||""),uploadIds:$}}const W=await VQ({fetcher:q,payload:buildConfigureSidecarPayload({uploadIds:$,caption:Q.caption,clientSidecarId:Z,jazoest:Q.jazoest}),apiContext:Q.apiContext,waitMs:Q.waitMs});return{code:W.code,mediaId:W.mediaId||"",uploadIds:$}}finally{f(N)}}export async function publishImagesViaPrivateApi(Q){return publishMediaViaPrivateApi({page:Q.page,mediaItems:Q.imagePaths.map((X)=>({type:"image",filePath:X})),caption:Q.caption,apiContext:Q.apiContext,jazoest:Q.jazoest,now:Q.now,fetcher:Q.fetcher,waitMs:Q.waitMs,prepareMediaAsset:Q.prepareAsset?async(X)=>({type:"image",asset:await Q.prepareAsset(X.filePath)}):void 0})}export async function publishStoryViaPrivateApi(Q){const X=Q.now??(()=>Date.now()),Z=String(X()),$=Q.fetcher??((G,H)=>S(Q.page,G,H)),F=await(Q.prepareMediaAsset??(async(G)=>G.type==="video"?{type:"video",asset:NQ(G.filePath)}:{type:"image",asset:prepareImageAssetForPrivateStoryUpload(G.filePath)}))(Q.mediaItem),N=Q.currentUserId||("getCookies"in Q.page?String((await(Q.page.getCookies?.({domain:"instagram.com"})??Promise.resolve([]))).find((G)=>G.name==="ds_user_id")?.value||""):"");if(!N)throw new K("Instagram story publish could not derive current user id from browser session");const W={_csrftoken:Q.apiContext.csrfToken,_uid:N,_uuid:L.randomUUID(),device:p},O=(G,H)=>b({...buildConfigureToStoryPhotoPayload({uploadId:Z,width:G,height:H,now:X,jazoest:Q.jazoest}),...W}),J=(G,H,Y)=>b({...buildConfigureToStoryVideoPayload({uploadId:Z,width:G,height:H,durationMs:Y,now:X,jazoest:Q.jazoest}),...W});try{await c($,F,Z,Q.apiContext,"story");if(F.type==="image"){let H;try{const Y=await $("https://i.instagram.com/api/v1/media/configure_to_story/",{method:"POST",headers:{..._(Q.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:O(F.asset.width,F.asset.height)});H=await B(Y,"configure_to_story")}catch(Y){throw markPublishOutcomeUncertain(Y instanceof Error?Y:new K(`Instagram private publish configure_to_story request failed: ${String(Y)}`))}return{mediaPk:String(H?.media?.pk||H?.media?.id||"").split("_")[0]||void 0,uploadId:Z}}let G;try{await B(await $("https://i.instagram.com/api/v1/media/configure_to_story/",{method:"POST",headers:{..._(Q.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:O(F.asset.width,F.asset.height)}),"configure_to_story cover");const H=await $("https://i.instagram.com/api/v1/media/configure_to_story/?video=1",{method:"POST",headers:{..._(Q.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:J(F.asset.width,F.asset.height,F.asset.durationMs)});G=await B(H,"configure_to_story")}catch(H){throw markPublishOutcomeUncertain(H instanceof Error?H:new K(`Instagram private publish configure_to_story request failed: ${String(H)}`))}return{mediaPk:String(G?.media?.pk||G?.media?.id||"").split("_")[0]||void 0,uploadId:Z}}finally{f([F])}}
75
+ `,[e,a,String(t)],"trim story video");return a}function de(e){const t=readVideoAsset(e);if(t.durationMs<=O)return t;const a=se(e,O),r=readVideoAsset(a);return{...r,cleanupPaths:[...r.cleanupPaths||[],a]}}function k(e){const t=e();return t>10000000000?Math.floor(t/1000):Math.floor(t)}export function buildConfigureToStoryPhotoPayload(e){const t=e.now??(()=>Date.now()),a=k(t);return{source_type:"4",upload_id:e.uploadId,story_media_creation_date:String(a-17),client_shared_at:String(a-5),client_timestamp:String(a),configure_mode:1,edits:{crop_original_size:[e.width,e.height],crop_center:[0,0],crop_zoom:1.3333334},extra:{source_width:e.width,source_height:e.height},jazoest:e.jazoest}}export function buildConfigureToStoryVideoPayload(e){const t=e.now??(()=>Date.now()),a=k(t),r=Number((e.durationMs/1000).toFixed(3));return{source_type:"4",upload_id:e.uploadId,story_media_creation_date:String(a-17),client_shared_at:String(a-5),client_timestamp:String(a),configure_mode:1,poster_frame_index:0,length:r,audio_muted:!1,filter_type:"0",video_result:"deprecated",extra:{source_width:e.width,source_height:e.height},jazoest:e.jazoest}}function Se(e){const t=new URLSearchParams;for(const[a,r]of Object.entries(e)){if(r===void 0||r===null)continue;if(typeof r==="object"){t.set(a,JSON.stringify(r));continue}t.set(a,String(r))}return t.toString()}function j(e){const t=JSON.stringify(e),a=w.createHmac("sha256",J).update(t).digest("hex"),r=new URLSearchParams;r.set("ig_sig_key_version",B);r.set("signed_body",`${a}.${t}`);return r.toString()}function g(e){return Object.fromEntries(Object.entries({"X-ASBD-ID":e.asbdId,"X-CSRFToken":e.csrfToken,"X-IG-App-ID":e.igAppId,"X-IG-WWW-Claim":e.igWwwClaim,"X-Instagram-AJAX":e.instagramAjax,"X-Web-Session-ID":e.webSessionId}).filter(([,t])=>!!t))}function ce(e,t,a){return{...g(a),Accept:"*/*","Content-Type":e.mimeType,Offset:"0","X-Entity-Length":String(e.byteLength),"X-Entity-Name":`fb_uploader_${t}`,"X-Entity-Type":e.mimeType,"X-Instagram-Rupload-Params":JSON.stringify({media_type:1,upload_id:t,upload_media_height:e.height,upload_media_width:e.width})}}function D(e){const t=Math.min(e.width,e.height),a=Number((e.durationMs/1000).toFixed(3));return{crop_height:t,crop_width:t,crop_x1:Math.max(0,Math.floor((e.width-t)/2)),crop_y1:Math.max(0,Math.floor((e.height-t)/2)),mute:!1,trim_end:a,trim_start:0}}function pe(e,t,a){return{...g(a),Accept:"*/*",Offset:"0","X-Entity-Length":String(e.byteLength),"X-Entity-Name":`fb_uploader_${t}`,"X-Instagram-Rupload-Params":JSON.stringify({"client-passthrough":"1",is_unified_video:"0",is_sidecar:"1",media_type:2,for_album:!1,video_format:"",upload_id:t,upload_media_duration_ms:e.durationMs,upload_media_height:e.height,upload_media_width:e.width,video_transform:null,video_edit_params:D(e)})}}function me(e,t,a){return{...g(a),Accept:"*/*",Offset:"0","X-Entity-Length":String(e.byteLength),"X-Entity-Name":`fb_uploader_${t}`,"X-Instagram-Rupload-Params":JSON.stringify({"client-passthrough":"1",media_type:2,upload_id:t,upload_media_duration_ms:e.durationMs,upload_media_height:e.height,upload_media_width:e.width,video_transform:null,video_edit_params:D(e)})}}function le(e,t,a){return{...g(a),Accept:"*/*","Content-Type":e.coverImage.mimeType,Offset:"0","X-Entity-Length":String(e.coverImage.byteLength),"X-Entity-Name":`fb_uploader_${t}`,"X-Entity-Type":e.coverImage.mimeType,"X-Instagram-Rupload-Params":JSON.stringify({media_type:2,upload_id:t,upload_media_height:e.height,upload_media_width:e.width})}}async function _(e,t){const a=await e.text();let r;try{r=a?JSON.parse(a):{}}catch{throw new n(`Instagram private publish ${t} returned invalid JSON`)}if(!e.ok){const i=a?` ${a.slice(0,500)}`:"";throw new n(`Instagram private publish ${t} failed: ${e.status}${i}`)}return r}async function T(e,t,a){let r;for(let o=0;o<E;o+=1)try{return await e(t,a)}catch(s){r=s;if(!U(s)||o>=E-1){const c=explainPrivateNetworkError(s,t);if(c)throw new n(`Instagram private publish upload failed: ${c}`);throw s}}const i=explainPrivateNetworkError(r,t);if(i)throw new n(`Instagram private publish upload failed: ${i}`);throw r instanceof Error?r:Error(String(r))}async function ue(e){if(e.type==="video")return{type:"video",asset:readVideoAsset(e.filePath)};return{type:"image",asset:prepareImageAssetForPrivateUpload(e.filePath)}}function F(e){for(const t of e){if(t.type==="image"){if(t.asset.cleanupPath)h.rmSync(t.asset.cleanupPath,{force:!0});continue}for(const a of t.asset.cleanupPaths||[])h.rmSync(a,{force:!0});if(t.asset.coverImage.cleanupPath)h.rmSync(t.asset.coverImage.cleanupPath,{force:!0})}}async function X(e,t,a,r,i="feed"){if(t.type==="image"){const l=await T(e,`https://i.instagram.com/rupload_igphoto/fb_uploader_${a}`,{method:"POST",headers:ce(t.asset,a,r),body:t.asset.bytes}),p=await _(l,"upload");if(String(p?.status||"")!=="ok")throw new n(`Instagram private publish upload failed for ${t.asset.fileName}`);return}const o=await T(e,`https://i.instagram.com/rupload_igvideo/fb_uploader_${a}`,{method:"POST",headers:i==="story"?me(t.asset,a,r):pe(t.asset,a,r),body:t.asset.bytes}),s=await _(o,"video upload");if(String(s?.status||"")!=="ok")throw new n(`Instagram private publish video upload failed for ${t.asset.fileName}`);const c=await T(e,`https://i.instagram.com/rupload_igphoto/fb_uploader_${a}`,{method:"POST",headers:le(t.asset,a,r),body:t.asset.coverImage.bytes}),d=await _(c,"video cover upload");if(String(d?.status||"")!=="ok")throw new n(`Instagram private publish video cover upload failed for ${t.asset.fileName}`)}async function fe(e){const t=e.waitMs??q,a={method:"POST",headers:{...g(e.apiContext),"Content-Type":"application/json"},body:JSON.stringify(e.payload)};for(let r=0;r<M;r+=1){let i,o;try{i=await e.fetcher("https://www.instagram.com/api/v1/media/configure_sidecar/",a);o=await i.text()}catch(d){throw markPublishOutcomeUncertain(d instanceof Error?d:new n(`Instagram private publish configure_sidecar request failed: ${String(d)}`))}let s={};try{s=o?JSON.parse(o):{}}catch{throw markPublishOutcomeUncertain(new n("Instagram private publish configure_sidecar returned invalid JSON"))}if(!i.ok){const d=o?` ${o.slice(0,500)}`:"";throw markPublishOutcomeUncertain(new n(`Instagram private publish configure_sidecar failed: ${i.status}${d}`))}const c=String(s?.message||"");if(i.status===202||/transcode not finished yet/i.test(c)){if(r>=M-1)throw markPublishOutcomeUncertain(new n("Instagram private publish configure_sidecar timed out waiting for video transcode",o.slice(0,500)));await t(G);continue}if(String(s?.status||"").toLowerCase()==="fail")throw new n("Instagram private publish configure_sidecar failed",c||o.slice(0,500));return{code:s?.media?.code,mediaId:String(s?.media?.id||"")}}throw new n("Instagram private publish configure_sidecar failed")}export async function publishMediaViaPrivateApi(e){const t=e.now??(()=>Date.now()),a=String(t()),r=e.mediaItems.length>1?e.mediaItems.map((c,d)=>String(t()+d+1)):[String(t())],i=e.fetcher??((c,d)=>P(e.page,c,d)),o=e.prepareMediaAsset??ue,s=await Promise.all(e.mediaItems.map((c)=>o(c)));try{for(let d=0;d<s.length;d+=1){const l=s[d],p=r[d];await X(i,l,p,e.apiContext)}if(r.length===1){if(s[0]?.type!=="image")throw new n("Instagram private publish only supports single-video uploads through instagram reel");let d;try{const l=await i("https://www.instagram.com/api/v1/media/configure/",{method:"POST",headers:{...g(e.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:buildConfigureBody({uploadId:r[0],caption:e.caption,jazoest:e.jazoest})});d=await _(l,"configure")}catch(l){throw markPublishOutcomeUncertain(l instanceof Error?l:new n(`Instagram private publish configure request failed: ${String(l)}`))}return{code:d?.media?.code,mediaId:String(d?.media?.id||""),uploadIds:r}}const c=await fe({fetcher:i,payload:buildConfigureSidecarPayload({uploadIds:r,caption:e.caption,clientSidecarId:a,jazoest:e.jazoest}),apiContext:e.apiContext,waitMs:e.waitMs});return{code:c.code,mediaId:c.mediaId||"",uploadIds:r}}finally{F(s)}}export async function publishImagesViaPrivateApi(e){return publishMediaViaPrivateApi({page:e.page,mediaItems:e.imagePaths.map((t)=>({type:"image",filePath:t})),caption:e.caption,apiContext:e.apiContext,jazoest:e.jazoest,now:e.now,fetcher:e.fetcher,waitMs:e.waitMs,prepareMediaAsset:e.prepareAsset?async(t)=>({type:"image",asset:await e.prepareAsset(t.filePath)}):void 0})}export async function publishStoryViaPrivateApi(e){const t=e.now??(()=>Date.now()),a=String(t()),r=e.fetcher??((p,m)=>P(e.page,p,m)),o=await(e.prepareMediaAsset??(async(p)=>p.type==="video"?{type:"video",asset:de(p.filePath)}:{type:"image",asset:prepareImageAssetForPrivateStoryUpload(p.filePath)}))(e.mediaItem),s=e.currentUserId||("getCookies"in e.page?String((await(e.page.getCookies?.({domain:"instagram.com"})??Promise.resolve([]))).find((p)=>p.name==="ds_user_id")?.value||""):"");if(!s)throw new n("Instagram story publish could not derive current user id from browser session");const c={_csrftoken:e.apiContext.csrfToken,_uid:s,_uuid:w.randomUUID(),device:H},d=(p,m)=>j({...buildConfigureToStoryPhotoPayload({uploadId:a,width:p,height:m,now:t,jazoest:e.jazoest}),...c}),l=(p,m,f)=>j({...buildConfigureToStoryVideoPayload({uploadId:a,width:p,height:m,durationMs:f,now:t,jazoest:e.jazoest}),...c});try{await X(r,o,a,e.apiContext,"story");if(o.type==="image"){let m;try{const f=await r("https://i.instagram.com/api/v1/media/configure_to_story/",{method:"POST",headers:{...g(e.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:d(o.asset.width,o.asset.height)});m=await _(f,"configure_to_story")}catch(f){throw markPublishOutcomeUncertain(f instanceof Error?f:new n(`Instagram private publish configure_to_story request failed: ${String(f)}`))}return{mediaPk:String(m?.media?.pk||m?.media?.id||"").split("_")[0]||void 0,uploadId:a}}let p;try{await _(await r("https://i.instagram.com/api/v1/media/configure_to_story/",{method:"POST",headers:{...g(e.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:d(o.asset.width,o.asset.height)}),"configure_to_story cover");const m=await r("https://i.instagram.com/api/v1/media/configure_to_story/?video=1",{method:"POST",headers:{...g(e.apiContext),"Content-Type":"application/x-www-form-urlencoded"},body:l(o.asset.width,o.asset.height,o.asset.durationMs)});p=await _(m,"configure_to_story")}catch(m){throw markPublishOutcomeUncertain(m instanceof Error?m:new n(`Instagram private publish configure_to_story request failed: ${String(m)}`))}return{mediaPk:String(p?.media?.pk||p?.media?.id||"").split("_")[0]||void 0,uploadId:a}}finally{F([o])}}
@@ -1,7 +1,7 @@
1
- import*as U from"node:fs";import{resolveInstagramRuntimeInfo as W}from"./runtime-info.js";const L="__opencli_ig_protocol_capture",M="__opencli_ig_protocol_capture_errors",X="/tmp/instagram_post_protocol_trace.json",Y=["/rupload_igphoto/","/rupload_igvideo/","/api/v1/","/media/configure/","/media/configure_sidecar/","/media/configure_to_story/","/api/graphql/"].join("|");export function buildInstallInstagramProtocolCaptureJs(v=L,j=M){return`
1
+ import*as _ from"node:fs";import{resolveInstagramRuntimeInfo as g}from"./runtime-info.js";const p="__opencli_ig_protocol_capture",c="__opencli_ig_protocol_capture_errors",m="/tmp/instagram_post_protocol_trace.json",R=["/rupload_igphoto/","/rupload_igvideo/","/api/v1/","/media/configure/","/media/configure_sidecar/","/media/configure_to_story/","/api/graphql/"].join("|");export function buildInstallInstagramProtocolCaptureJs(t=p,e=c){return`
2
2
  (() => {
3
- const CAPTURE_VAR = ${JSON.stringify(v)};
4
- const CAPTURE_ERRORS_VAR = ${JSON.stringify(j)};
3
+ const CAPTURE_VAR = ${JSON.stringify(t)};
4
+ const CAPTURE_ERRORS_VAR = ${JSON.stringify(e)};
5
5
  const PATCH_GUARD = CAPTURE_VAR + '_patched';
6
6
  const FILTERS = [
7
7
  '/rupload_igphoto/',
@@ -169,12 +169,12 @@ import*as U from"node:fs";import{resolveInstagramRuntimeInfo as W}from"./runtime
169
169
  window[PATCH_GUARD] = true;
170
170
  return { ok: true };
171
171
  })()
172
- `}export function buildReadInstagramProtocolCaptureJs(v=L,j=M){return`
172
+ `}export function buildReadInstagramProtocolCaptureJs(t=p,e=c){return`
173
173
  (() => {
174
- const data = Array.isArray(window[${JSON.stringify(v)}]) ? window[${JSON.stringify(v)}] : [];
175
- const errors = Array.isArray(window[${JSON.stringify(j)}]) ? window[${JSON.stringify(j)}] : [];
176
- window[${JSON.stringify(v)}] = [];
177
- window[${JSON.stringify(j)}] = [];
174
+ const data = Array.isArray(window[${JSON.stringify(t)}]) ? window[${JSON.stringify(t)}] : [];
175
+ const errors = Array.isArray(window[${JSON.stringify(e)}]) ? window[${JSON.stringify(e)}] : [];
176
+ window[${JSON.stringify(t)}] = [];
177
+ window[${JSON.stringify(e)}] = [];
178
178
  return { data, errors };
179
179
  })()
180
- `}export async function installInstagramProtocolCapture(v){if(typeof v.startNetworkCapture==="function")try{await v.startNetworkCapture(Y);return}catch(j){const w=j instanceof Error?j.message:String(j);if(!w.includes("Unknown action")&&!w.includes("network-capture"))throw j}await v.evaluate(buildInstallInstagramProtocolCaptureJs())}export async function readInstagramProtocolCapture(v){if(typeof v.readNetworkCapture==="function")try{const w=await v.readNetworkCapture();return{data:Array.isArray(w)?w:[],errors:[]}}catch(w){const z=w instanceof Error?w.message:String(w);if(!z.includes("Unknown action")&&!z.includes("network-capture"))throw w}const j=await v.evaluate(buildReadInstagramProtocolCaptureJs());return{data:Array.isArray(j?.data)?j.data:[],errors:Array.isArray(j?.errors)?j.errors:[]}}export async function dumpInstagramProtocolCaptureIfEnabled(v){if(process.env.OPENCLI_INSTAGRAM_CAPTURE!=="1")return;const j=await readInstagramProtocolCapture(v);U.writeFileSync(X,JSON.stringify(j,null,2))}function Z(v){return v.filter((j)=>j?.name&&j?.value).map((j)=>`${j.name}=${j.value}`).join("; ")}export async function instagramPrivateApiFetch(v,j,w={}){const z=String(j),[N,O]=await Promise.all([v.getCookies({url:z}),v.getCookies({domain:"instagram.com"})]),B=new Map;for(const x of O)B.set(x.name,x);for(const x of N)B.set(x.name,x);const D=Z(Array.from(B.values())),Q=B.get("csrftoken")?.value||"",F=w.headers??{},G=Object.entries(F).find(([x])=>x.toLowerCase()==="x-ig-app-id")?.[1]||"",R=G?null:await W(v),K=G||R?.appId||"",S=Object.keys(w.headers??{}).some((x)=>x.toLowerCase()==="content-type");return fetch(z,{method:w.method??"GET",headers:{Accept:"application/json, text/plain, */*","X-CSRFToken":Q,"X-Requested-With":"XMLHttpRequest",Origin:"https://www.instagram.com",Referer:"https://www.instagram.com/",...K?{"X-IG-App-ID":K}:{},...D?{Cookie:D}:{},...typeof w.body==="string"&&!S?{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}:{},...F},...w.body!==void 0?{body:w.body}:{}})}
180
+ `}export async function installInstagramProtocolCapture(t){if(typeof t.startNetworkCapture==="function")try{await t.startNetworkCapture(R);return}catch(e){const r=e instanceof Error?e.message:String(e);if(!r.includes("Unknown action")&&!r.includes("network-capture"))throw e}await t.evaluate(buildInstallInstagramProtocolCaptureJs())}export async function readInstagramProtocolCapture(t){if(typeof t.readNetworkCapture==="function")try{const r=await t.readNetworkCapture();return{data:Array.isArray(r)?r:[],errors:[]}}catch(r){const n=r instanceof Error?r.message:String(r);if(!n.includes("Unknown action")&&!n.includes("network-capture"))throw r}const e=await t.evaluate(buildReadInstagramProtocolCaptureJs());return{data:Array.isArray(e?.data)?e.data:[],errors:Array.isArray(e?.errors)?e.errors:[]}}export async function dumpInstagramProtocolCaptureIfEnabled(t){if(process.env.OPENCLI_INSTAGRAM_CAPTURE!=="1")return;const e=await readInstagramProtocolCapture(t);_.writeFileSync(m,JSON.stringify(e,null,2))}function A(t){return t.filter((e)=>e?.name&&e?.value).map((e)=>`${e.name}=${e.value}`).join("; ")}export async function instagramPrivateApiFetch(t,e,r={}){const n=String(e),[y,l]=await Promise.all([t.getCookies({url:n}),t.getCookies({domain:"instagram.com"})]),i=new Map;for(const o of l)i.set(o.name,o);for(const o of y)i.set(o.name,o);const s=A(Array.from(i.values())),f=i.get("csrftoken")?.value||"",a=r.headers??{},d=Object.entries(a).find(([o])=>o.toLowerCase()==="x-ig-app-id")?.[1]||"",h=d?null:await g(t),u=d||h?.appId||"",w=Object.keys(r.headers??{}).some((o)=>o.toLowerCase()==="content-type");return fetch(n,{method:r.method??"GET",headers:{Accept:"application/json, text/plain, */*","X-CSRFToken":f,"X-Requested-With":"XMLHttpRequest",Origin:"https://www.instagram.com",Referer:"https://www.instagram.com/",...u?{"X-IG-App-ID":u}:{},...s?{Cookie:s}:{},...typeof r.body==="string"&&!w?{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}:{},...a},...r.body!==void 0?{body:r.body}:{}})}
@@ -1,3 +1,3 @@
1
- import{cli as v,Strategy as A}from"@jackwener/opencli/registry";import{CommandExecutionError as W}from"@jackwener/opencli/errors";import{buildInstagramFetchScript as D,ensurePage as O,handleFetchFailure as S,normalizeFetchResult as U,parseInstagramMediaTarget as V}from"./download.js";function b(B){return String(B||"").replace(/\s+/g," ").trim()}function j(B){return String(B||"").replace(/\r\n?/g,`
2
- `).trim()}function Y(B){const q=Number(B||0);return Number.isFinite(q)&&q>0?new Date(q*1000).toISOString():""}function I(B){if(!B||typeof B!=="object")return null;const q=B.is_video===!0,G=String(q?B.video_url||"":B.display_url||"").trim();if(!G)return null;return{kind:q?"video":"image",url:G}}function Z(B){const q=Array.isArray(B?.edge_sidecar_to_children?.edges)?B.edge_sidecar_to_children.edges.map((H)=>H?.node).filter(Boolean):[];return(q.length>0?q:[B]).map(I).filter(Boolean)}function M(B,q){const G=String(q?.product_type||"").toLowerCase();if(G==="clips"||G==="reel"||B==="reel")return"reel";return B||"p"}function f(B){if(B.length>1)return"carousel";return B[0]?.kind||""}function X(B){const q=Number(B?.count??0);return Number.isFinite(q)?q:0}function k(B){const q=B?.edge_media_to_caption?.edges?.[0]?.node?.text||"";return j(q)}function _(B,q){if(!q||typeof q!=="object")throw new W("Instagram returned malformed media detail payload");const G=String(q.shortcode||B.shortcode||"").trim(),H=String(q.id||"").trim(),J=String(q?.owner?.username||"").trim();if(!G||!H||!J)throw new W("Instagram returned malformed media detail payload");const L=Z(q);if(L.length===0)throw new W("Instagram detail payload did not contain any media URLs");const $=M(B.kind,q);return{shortcode:G,media_id:H,kind:$,type:f(L),posted_at:Y(q.taken_at_timestamp),owner:J,owner_name:String(q?.owner?.full_name||"").trim(),owner_verified:q?.owner?.is_verified?"Yes":"No",caption:k(q),likes:X(q?.edge_media_preview_like),comments:X(q?.edge_media_to_comment)||X(q?.edge_media_to_parent_comment),views:Number.isFinite(Number(q?.video_view_count))?Number(q.video_view_count):Number.isFinite(Number(q?.video_play_count))?Number(q.video_play_count):"",media_count:L.length,media_types:L.map((Q)=>Q.kind).join(", "),media_urls:L.map((Q)=>Q.url).join(`
3
- `),thumbnail_url:String(q.display_url||"").trim(),url:B.canonicalUrl}}v({site:"instagram",name:"detail",access:"read",description:"Get single-post Instagram details, including direct media URLs",domain:"www.instagram.com",strategy:A.COOKIE,navigateBefore:!1,args:[{name:"url",positional:!0,required:!0,help:"Instagram post / reel / tv URL"}],columns:["shortcode","media_id","kind","type","posted_at","owner","owner_name","owner_verified","likes","comments","views","media_count","media_types","media_urls","thumbnail_url","url","caption"],func:async(B,q)=>{const G=O(B),H=V(String(q.url??""));await G.goto(H.canonicalUrl);const J=U(await G.evaluate(D(H.shortcode)));if(!J.ok)S(J);return[_(H,J.media)]},__test__:{normalizeCaptionText:b,formatPostedAt:Y,normalizeMediaNodes:Z,normalizeDetailRow:_}});
1
+ import{cli as _,Strategy as p}from"@jackwener/opencli/registry";import{CommandExecutionError as s}from"@jackwener/opencli/errors";import{buildInstagramFetchScript as g,ensurePage as f,handleFetchFailure as w,normalizeFetchResult as h,parseInstagramMediaTarget as y}from"./download.js";function v(t){return String(t||"").replace(/\s+/g," ").trim()}function b(t){return String(t||"").replace(/\r\n?/g,`
2
+ `).trim()}function u(t){const e=Number(t||0);return Number.isFinite(e)&&e>0?new Date(e*1000).toISOString():""}function N(t){if(!t||typeof t!=="object")return null;const e=t.is_video===!0,r=String(e?t.video_url||"":t.display_url||"").trim();if(!r)return null;return{kind:e?"video":"image",url:r}}function l(t){const e=Array.isArray(t?.edge_sidecar_to_children?.edges)?t.edge_sidecar_to_children.edges.map((n)=>n?.node).filter(Boolean):[];return(e.length>0?e:[t]).map(N).filter(Boolean)}function S(t,e){const r=String(e?.product_type||"").toLowerCase();if(r==="clips"||r==="reel"||t==="reel")return"reel";return t||"p"}function k(t){if(t.length>1)return"carousel";return t[0]?.kind||""}function c(t){const e=Number(t?.count??0);return Number.isFinite(e)?e:0}function F(t){const e=t?.edge_media_to_caption?.edges?.[0]?.node?.text||"";return b(e)}function d(t,e){if(!e||typeof e!=="object")throw new s("Instagram returned malformed media detail payload");const r=String(e.shortcode||t.shortcode||"").trim(),n=String(e.id||"").trim(),o=String(e?.owner?.username||"").trim();if(!r||!n||!o)throw new s("Instagram returned malformed media detail payload");const i=l(e);if(i.length===0)throw new s("Instagram detail payload did not contain any media URLs");const m=S(t.kind,e);return{shortcode:r,media_id:n,kind:m,type:k(i),posted_at:u(e.taken_at_timestamp),owner:o,owner_name:String(e?.owner?.full_name||"").trim(),owner_verified:e?.owner?.is_verified?"Yes":"No",caption:F(e),likes:c(e?.edge_media_preview_like),comments:c(e?.edge_media_to_comment)||c(e?.edge_media_to_parent_comment),views:Number.isFinite(Number(e?.video_view_count))?Number(e.video_view_count):Number.isFinite(Number(e?.video_play_count))?Number(e.video_play_count):"",media_count:i.length,media_types:i.map((a)=>a.kind).join(", "),media_urls:i.map((a)=>a.url).join(`
3
+ `),thumbnail_url:String(e.display_url||"").trim(),url:t.canonicalUrl}}_({site:"instagram",name:"detail",access:"read",description:"Get single-post Instagram details, including direct media URLs",domain:"www.instagram.com",strategy:p.COOKIE,navigateBefore:!1,args:[{name:"url",positional:!0,required:!0,help:"Instagram post / reel / tv URL"}],columns:["shortcode","media_id","kind","type","posted_at","owner","owner_name","owner_verified","likes","comments","views","media_count","media_types","media_urls","thumbnail_url","url","caption"],func:async(t,e)=>{const r=f(t),n=y(String(e.url??""));await r.goto(n.canonicalUrl);const o=h(await r.evaluate(g(n.shortcode)));if(!o.ok)w(o);return[d(n,o.media)]},__test__:{normalizeCaptionText:v,formatPostedAt:u,normalizeMediaNodes:l,normalizeDetailRow:d}});
@@ -1,4 +1,4 @@
1
- import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy as t}from"@jackwener/opencli/registry";import{ArgumentError as H,AuthRequiredError as A,CommandExecutionError as q}from"@jackwener/opencli/errors";import{installInstagramProtocolCapture as e,readInstagramProtocolCapture as jj}from"./_shared/protocol-capture.js";import{publishMediaViaPrivateApi as Kj,publishImagesViaPrivateApi as Qj,resolveInstagramPrivatePublishConfig as Yj,isPublishOutcomeUncertain as Zj}from"./_shared/private-publish.js";import{resolveInstagramRuntimeInfo as $j}from"./_shared/runtime-info.js";import{setInputFiles as qj}from"../_shared/file-inject.js";const N="https://www.instagram.com/",zj=new Set([".jpg",".jpeg",".png",".webp"]),Jj=new Set([".mp4"]),h=10,Vj="/tmp/instagram_post_protocol_trace.json";async function k(j,K=!1){if(K){await j.goto(`${N}?__opencli_reset=${Date.now()}`);await j.wait({time:1})}await j.goto(N)}export function buildEnsureComposerOpenJs(){return`
1
+ import*as U from"node:fs";import*as O from"node:path";import{cli as Y,Strategy as Z}from"@jackwener/opencli/registry";import{ArgumentError as p,AuthRequiredError as C,CommandExecutionError as i}from"@jackwener/opencli/errors";import{installInstagramProtocolCapture as ee,readInstagramProtocolCapture as te}from"./_shared/protocol-capture.js";import{publishMediaViaPrivateApi as ae,publishImagesViaPrivateApi as ne,resolveInstagramPrivatePublishConfig as re,isPublishOutcomeUncertain as oe}from"./_shared/private-publish.js";import{resolveInstagramRuntimeInfo as ie}from"./_shared/runtime-info.js";import{setInputFiles as se}from"../_shared/file-inject.js";const m="https://www.instagram.com/",le=new Set([".jpg",".jpeg",".png",".webp"]),ce=new Set([".mp4"]),A=10,de="/tmp/instagram_post_protocol_trace.json";async function I(e,t=!1){if(t){await e.goto(`${m}?__opencli_reset=${Date.now()}`);await e.wait({time:1})}await e.goto(m)}export function buildEnsureComposerOpenJs(){return`
2
2
  (() => {
3
3
  const path = window.location?.pathname || '';
4
4
  const onLoginRoute = /\\/accounts\\/login\\/?/.test(path);
@@ -61,7 +61,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
61
61
  const settled = !shared && !composerOpen && !/sharing/.test(visibleText);
62
62
  return { ok: shared, failed, settled, url: /\\/p\\//.test(url) ? url : '' };
63
63
  })()
64
- `}function Gj(j){if(!j)throw new q("Browser session required for instagram post");return j}function Oj(j){if(!j.length)throw new H('Argument "media" is required.',"Provide --media /path/to/file.jpg or --media /path/a.jpg,/path/b.mp4");if(j.length>h)throw new H(`Too many media items: ${j.length}`,`Instagram carousel posts support at most ${h} items`);return j.map((Q)=>{const Y=v.resolve(String(Q||"").trim());if(!Y)throw new H("Media path cannot be empty");if(!E.existsSync(Y))throw new H(`Media file not found: ${Y}`);const Z=v.extname(Y).toLowerCase();if(zj.has(Z))return{type:"image",filePath:Y};if(Jj.has(Z))return{type:"video",filePath:Y};throw new H(`Unsupported media format: ${Z}`,"Supported formats: images (.jpg, .jpeg, .png, .webp) and videos (.mp4)")})}function Xj(j){const K=String(j.media??"").trim();return Oj(K.split(",").map((Q)=>Q.trim()).filter(Boolean))}const b=2200;function Hj(j){if(j.media===void 0)throw new H('Argument "media" is required.',"Provide --media /path/to/file.jpg or --media /path/a.jpg,/path/b.mp4");I(j.content)}function I(j){const K=[...String(j??"")].length;if(K>b)throw new H(`Instagram caption is too long: ${K} characters (limit ${b}).`,`Shorten the caption by ${K-b} characters. Nothing was uploaded or posted.`)}function Bj(j){const K=j instanceof Error?j.message:String(j);return/failed to normalize/i.test(K)||/caption_too_long|caption too long/i.test(K)}function Nj(j){if(!(j instanceof q))return!1;if(Bj(j))return!1;return j.message.startsWith("Instagram private publish")||j.message.startsWith("Instagram private route")}function R(j,K,Q=""){return[{status:"✅ Posted",detail:Aj(j),url:K,media_id:String(Q||""),account_id:String(Q||"").split("_")[1]||""}]}function Tj(j,K){const Q=j instanceof Error?j.message:String(j),Y=K instanceof Error?K.message:String(K);return`Private route failed first: ${Q}. UI fallback then failed: ${Y}`}function _j(j,K){const Q=j instanceof Error?j.message:String(j),Y=K instanceof Error?K.message:String(K);return`Instagram publish failed. Cause (private API route): ${Q}`+` — the UI fallback then also failed with: ${Y}`}async function Dj(j){const K=await Yj(j.page),Q=j.mediaItems.every((Z)=>Z.type==="image")?await Qj({page:j.page,imagePaths:j.mediaItems.map((Z)=>Z.filePath),caption:j.content,apiContext:K.apiContext,jazoest:K.jazoest}):await Kj({page:j.page,mediaItems:j.mediaItems,caption:j.content,apiContext:K.apiContext,jazoest:K.jazoest}),Y=Q.code?new URL(`/p/${Q.code}/`,N).toString():j.canDiffProfile?await x(j.page,j.existingPostPaths):"";return R(j.mediaItems,Y,Q.mediaId)}async function Fj(j){let K,Q=null;for(let Y=0;Y<j.commandAttemptBudget;Y++){let Z=!1;try{await k(j.page,j.forceFreshStart||Y>0);await j.installProtocolCapture();await j.page.wait({time:2});await F(j.page);await y(j.page);const $=await c(j.page,j.mediaItems);if(j.preUploadDelaySeconds>0)await j.page.wait({time:j.preUploadDelaySeconds});let J=!1,z=null;for(const X of $){let T=X;for(let _=0;_<j.uploadAttemptBudget;_++){await Mj(j.page,j.mediaItems,T);const D=await m(j.page,j.previewProbeWindowSeconds);if(D.state==="preview"){J=!0;break}if(D.state==="failed"){z=W(D.detail);for(let M=0;M<j.inlineUploadRetryBudget;M++){if(!await fj(j.page))break;await j.page.wait({time:3});const B=await m(j.page,Math.max(3,Math.floor(j.previewProbeWindowSeconds/2)));if(B.state==="preview"){J=!0;break}if(B.state!=="failed")break}if(J)break;await Cj(j.page);await F(j.page);if(_<j.uploadAttemptBudget-1){try{await j.drainProtocolCapture();await k(j.page,!0);await j.installProtocolCapture();await j.page.wait({time:2});await F(j.page);await y(j.page);T=await d(j.page,T,j.mediaItems);if(j.preUploadDelaySeconds>0)await j.page.wait({time:j.preUploadDelaySeconds})}catch{throw z}await j.page.wait({time:1.5});continue}break}break}if(J)break}if(!J){if(z)throw z;await Uj(j.page,j.finalPreviewWaitSeconds)}try{await Pj(j.page)}catch(X){await Ej(j.page,X)}if(j.content){await Ij(j.page,j.content);await dj(j.page,j.content)}if(j.preShareDelaySeconds>0)await j.page.wait({time:j.preShareDelaySeconds});await l(j.page,["Share","分享"],"caption");Z=!0;let G="";try{G=await n(j.page)}catch(X){if(X instanceof q&&X.message==="Instagram post share failed"&&await Sj(j.page)){await j.page.wait({time:Math.max(2,j.preShareDelaySeconds)});G=await n(j.page)}else throw X}await j.drainProtocolCapture();if(!G&&j.canDiffProfile)G=await x(j.page,j.existingPostPaths);return R(j.mediaItems,G)}catch($){K=$;if($ instanceof q&&$.message!=="Failed to open Instagram post composer")Q=$;if($ instanceof A)throw $;if(Z){let z="";if(j.canDiffProfile)try{z=await x(j.page,j.existingPostPaths)}catch{}if(z)return R(j.mediaItems,z);const G=$ instanceof Error?$.message:String($);throw new q(`Instagram share was clicked but the outcome could not be confirmed: ${G}`,"The post may already be live. Do NOT rerun this command blindly — open the profile (or rerun after checking) and confirm no new post exists first; retrying on a false failure creates a duplicate post.")}if(!($ instanceof q)||Y===j.commandAttemptBudget-1){if($ instanceof q&&$.message==="Failed to open Instagram post composer"&&Q)throw Q;throw $}let J=!1;if(j.mediaItems.length>=10&&j.page.closeWindow)try{await j.drainProtocolCapture();await j.page.closeWindow();J=!0}catch{}if(!J){await F(j.page);await j.page.wait({time:1})}}}throw K instanceof Error?K:new q("Instagram post failed")}async function y(j){const K=await j.evaluate(buildEnsureComposerOpenJs());if(!K?.ok){if(K?.reason==="auth")throw new A("www.instagram.com","Instagram login required before posting");throw new q("Failed to open Instagram post composer")}}async function F(j){for(let K=0;K<4;K++){if(!(await j.evaluate(`
64
+ `}function ue(e){if(!e)throw new i("Browser session required for instagram post");return e}function fe(e){if(!e.length)throw new p('Argument "media" is required.',"Provide --media /path/to/file.jpg or --media /path/a.jpg,/path/b.mp4");if(e.length>A)throw new p(`Too many media items: ${e.length}`,`Instagram carousel posts support at most ${A} items`);return e.map((a)=>{const n=O.resolve(String(a||"").trim());if(!n)throw new p("Media path cannot be empty");if(!U.existsSync(n))throw new p(`Media file not found: ${n}`);const r=O.extname(n).toLowerCase();if(le.has(r))return{type:"image",filePath:n};if(ce.has(r))return{type:"video",filePath:n};throw new p(`Unsupported media format: ${r}`,"Supported formats: images (.jpg, .jpeg, .png, .webp) and videos (.mp4)")})}function pe(e){const t=String(e.media??"").trim();return fe(t.split(",").map((a)=>a.trim()).filter(Boolean))}const P=2200;function ge(e){if(e.media===void 0)throw new p('Argument "media" is required.',"Provide --media /path/to/file.jpg or --media /path/a.jpg,/path/b.mp4");D(e.content)}function D(e){const t=[...String(e??"")].length;if(t>P)throw new p(`Instagram caption is too long: ${t} characters (limit ${P}).`,`Shorten the caption by ${t-P} characters. Nothing was uploaded or posted.`)}function me(e){const t=e instanceof Error?e.message:String(e);return/failed to normalize/i.test(t)||/caption_too_long|caption too long/i.test(t)}function he(e){if(!(e instanceof i))return!1;if(me(e))return!1;return e.message.startsWith("Instagram private publish")||e.message.startsWith("Instagram private route")}function E(e,t,a=""){return[{status:"✅ Posted",detail:Ee(e),url:t,media_id:String(a||""),account_id:String(a||"").split("_")[1]||""}]}function we(e,t){const a=e instanceof Error?e.message:String(e),n=t instanceof Error?t.message:String(t);return`Private route failed first: ${a}. UI fallback then failed: ${n}`}function ye(e,t){const a=e instanceof Error?e.message:String(e),n=t instanceof Error?t.message:String(t);return`Instagram publish failed. Cause (private API route): ${a}`+` — the UI fallback then also failed with: ${n}`}async function be(e){const t=await re(e.page),a=e.mediaItems.every((r)=>r.type==="image")?await ne({page:e.page,imagePaths:e.mediaItems.map((r)=>r.filePath),caption:e.content,apiContext:t.apiContext,jazoest:t.jazoest}):await ae({page:e.page,mediaItems:e.mediaItems,caption:e.content,apiContext:t.apiContext,jazoest:t.jazoest}),n=a.code?new URL(`/p/${a.code}/`,m).toString():e.canDiffProfile?await k(e.page,e.existingPostPaths):"";return E(e.mediaItems,n,a.mediaId)}async function xe(e){let t,a=null;for(let n=0;n<e.commandAttemptBudget;n++){let r=!1;try{await I(e.page,e.forceFreshStart||n>0);await e.installProtocolCapture();await e.page.wait({time:2});await b(e.page);await T(e.page);const o=await V(e.page,e.mediaItems);if(e.preUploadDelaySeconds>0)await e.page.wait({time:e.preUploadDelaySeconds});let l=!1,s=null;for(const f of o){let h=f;for(let w=0;w<e.uploadAttemptBudget;w++){await Ce(e.page,e.mediaItems,h);const y=await H(e.page,e.previewProbeWindowSeconds);if(y.state==="preview"){l=!0;break}if(y.state==="failed"){s=S(y.detail);for(let v=0;v<e.inlineUploadRetryBudget;v++){if(!await qe(e.page))break;await e.page.wait({time:3});const g=await H(e.page,Math.max(3,Math.floor(e.previewProbeWindowSeconds/2)));if(g.state==="preview"){l=!0;break}if(g.state!=="failed")break}if(l)break;await Me(e.page);await b(e.page);if(w<e.uploadAttemptBudget-1){try{await e.drainProtocolCapture();await I(e.page,!0);await e.installProtocolCapture();await e.page.wait({time:2});await b(e.page);await T(e.page);h=await B(e.page,h,e.mediaItems);if(e.preUploadDelaySeconds>0)await e.page.wait({time:e.preUploadDelaySeconds})}catch{throw s}await e.page.wait({time:1.5});continue}break}break}if(l)break}if(!l){if(s)throw s;await Ne(e.page,e.finalPreviewWaitSeconds)}try{await Ue(e.page)}catch(f){await Oe(e.page,f)}if(e.content){await Ve(e.page,e.content);await He(e.page,e.content)}if(e.preShareDelaySeconds>0)await e.page.wait({time:e.preShareDelaySeconds});await j(e.page,["Share","分享"],"caption");r=!0;let d="";try{d=await W(e.page)}catch(f){if(f instanceof i&&f.message==="Instagram post share failed"&&await Re(e.page)){await e.page.wait({time:Math.max(2,e.preShareDelaySeconds)});d=await W(e.page)}else throw f}await e.drainProtocolCapture();if(!d&&e.canDiffProfile)d=await k(e.page,e.existingPostPaths);return E(e.mediaItems,d)}catch(o){t=o;if(o instanceof i&&o.message!=="Failed to open Instagram post composer")a=o;if(o instanceof C)throw o;if(r){let s="";if(e.canDiffProfile)try{s=await k(e.page,e.existingPostPaths)}catch{}if(s)return E(e.mediaItems,s);const d=o instanceof Error?o.message:String(o);throw new i(`Instagram share was clicked but the outcome could not be confirmed: ${d}`,"The post may already be live. Do NOT rerun this command blindly — open the profile (or rerun after checking) and confirm no new post exists first; retrying on a false failure creates a duplicate post.")}if(!(o instanceof i)||n===e.commandAttemptBudget-1){if(o instanceof i&&o.message==="Failed to open Instagram post composer"&&a)throw a;throw o}let l=!1;if(e.mediaItems.length>=10&&e.page.closeWindow)try{await e.drainProtocolCapture();await e.page.closeWindow();l=!0}catch{}if(!l){await b(e.page);await e.page.wait({time:1})}}}throw t instanceof Error?t:new i("Instagram post failed")}async function T(e){const t=await e.evaluate(buildEnsureComposerOpenJs());if(!t?.ok){if(t?.reason==="auth")throw new C("www.instagram.com","Instagram login required before posting");throw new i("Failed to open Instagram post composer")}}async function b(e){for(let t=0;t<4;t++){if(!(await e.evaluate(`
65
65
  (() => {
66
66
  const isVisible = (el) => {
67
67
  if (!(el instanceof HTMLElement)) return false;
@@ -105,7 +105,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
105
105
 
106
106
  return { ok: false };
107
107
  })()
108
- `))?.ok)return;await j.wait({time:0.5})}}async function w(j,K){const Q=K.some((Z)=>Z.type==="video"),Y=await j.evaluate(`
108
+ `))?.ok)return;await e.wait({time:0.5})}}async function _(e,t){const a=t.some((r)=>r.type==="video"),n=await e.evaluate(`
109
109
  ((includesVideo) => {
110
110
  const isVisible = (el) => {
111
111
  if (!(el instanceof HTMLElement)) return false;
@@ -164,10 +164,10 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
164
164
  return '[data-opencli-ig-upload-index="' + index + '"]';
165
165
  });
166
166
  return { ok: true, selectors };
167
- })(${JSON.stringify(Q)})
168
- `);if(!Y?.ok||!Y.selectors?.length)throw new q("Instagram upload input not found","Open the new-post composer in a logged-in browser session and retry");return Y.selectors}async function c(j,K){try{return await w(j,K)}catch(Q){if(!(Q instanceof q)||!Q.message.includes("upload input not found"))throw Q;await y(j);await j.wait({time:1.5});try{return await w(j,K)}catch(Y){if(!(Y instanceof q)||!Y.message.includes("upload input not found"))throw Y;await k(j,!0);await j.wait({time:2});await F(j);await y(j);await j.wait({time:2});return w(j,K)}}}function Lj(j){const K=j.match(/data-opencli-ig-upload-index="(\d+)"/);if(!K)return null;const Q=Number.parseInt(K[1]||"",10);return Number.isNaN(Q)?null:Q}async function d(j,K,Q){const Y=await c(j,Q),Z=Lj(K);if(Z!==null&&Y[Z])return Y[Z];return Y[0]||K}async function Wj(j,K){await j.evaluate(`
167
+ })(${JSON.stringify(a)})
168
+ `);if(!n?.ok||!n.selectors?.length)throw new i("Instagram upload input not found","Open the new-post composer in a logged-in browser session and retry");return n.selectors}async function V(e,t){try{return await _(e,t)}catch(a){if(!(a instanceof i)||!a.message.includes("upload input not found"))throw a;await T(e);await e.wait({time:1.5});try{return await _(e,t)}catch(n){if(!(n instanceof i)||!n.message.includes("upload input not found"))throw n;await I(e,!0);await e.wait({time:2});await b(e);await T(e);await e.wait({time:2});return _(e,t)}}}function Se(e){const t=e.match(/data-opencli-ig-upload-index="(\d+)"/);if(!t)return null;const a=Number.parseInt(t[1]||"",10);return Number.isNaN(a)?null:a}async function B(e,t,a){const n=await V(e,a),r=Se(t);if(r!==null&&n[r])return n[r];return n[0]||t}async function ve(e,t){await e.evaluate(`
169
169
  (() => {
170
- const input = document.querySelector(${JSON.stringify(K)});
170
+ const input = document.querySelector(${JSON.stringify(t)});
171
171
  if (!(input instanceof HTMLInputElement)) return { ok: false };
172
172
  input.dispatchEvent(new Event('input', { bubbles: true }));
173
173
  input.dispatchEvent(new Event('change', { bubbles: true }));
@@ -208,7 +208,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
208
208
  if (failed) return { state: 'failed', detail: dialogText || 'Something went wrong' };
209
209
  return { state: 'pending', detail: dialogText || '' };
210
210
  })()
211
- `}async function L(j){const K=await j.evaluate(buildInspectUploadStageJs());if(K?.state)return K;if(K?.ok===!0)return{state:"preview",detail:K.detail};return{state:"pending",detail:K?.detail}}function W(j){return new q("Instagram image upload failed",j?`Instagram rejected the upload: ${j}`:"Instagram rejected the upload before the preview stage")}async function Mj(j,K,Q){const Y=K.map(($)=>$.filePath);let Z=Q;for(let $=0;$<2;$++)try{if((await qj(j,Z,Y)).method==="cdp")await Wj(j,Z);return}catch(J){const z=J instanceof Error?J.message:String(J);if((z.includes("No element found matching selector")||z.includes("Could not find node with given id")||z.includes("No node with given id found")||z.includes("未找到可用的文件上传输入框"))&&$===0){Z=await d(j,Z,K);continue}throw J}}function Aj(j){if(j.every((K)=>K.type==="image"))return j.length===1?"Single image post shared successfully":`${j.length}-image carousel post shared successfully`;return j.length===1?"Single mixed-media post shared successfully":`${j.length}-item mixed-media carousel post shared successfully`}function Rj(j){if(j.length>=10)return 6;if(j.length>=5)return 4;return 3}function yj(j){if(j.length>=10)return 3;if(j.length>=5)return 1.5;return 0}function xj(j){if(j.length>=10)return 3;if(j.length>=5)return 3;return 2}function hj(j){if(j.length>=10)return 6;if(j.length>=5)return 6;return 4}function kj(j){if(j.length>=10)return 12;if(j.length>=5)return 16;return 12}function bj(j){if(j.length>=10)return 4;if(j.length>=5)return 3;return 0}function wj(j){if(j.length>=10)return 3;if(j.length>=5)return 2;return 1}async function Cj(j){return!!(await j.evaluate(`
211
+ `}async function x(e){const t=await e.evaluate(buildInspectUploadStageJs());if(t?.state)return t;if(t?.ok===!0)return{state:"preview",detail:t.detail};return{state:"pending",detail:t?.detail}}function S(e){return new i("Instagram image upload failed",e?`Instagram rejected the upload: ${e}`:"Instagram rejected the upload before the preview stage")}async function Ce(e,t,a){const n=t.map((o)=>o.filePath);let r=a;for(let o=0;o<2;o++)try{if((await se(e,r,n)).method==="cdp")await ve(e,r);return}catch(l){const s=l instanceof Error?l.message:String(l);if((s.includes("No element found matching selector")||s.includes("Could not find node with given id")||s.includes("No node with given id found")||s.includes("未找到可用的文件上传输入框"))&&o===0){r=await B(e,r,t);continue}throw l}}function Ee(e){if(e.every((t)=>t.type==="image"))return e.length===1?"Single image post shared successfully":`${e.length}-image carousel post shared successfully`;return e.length===1?"Single mixed-media post shared successfully":`${e.length}-item mixed-media carousel post shared successfully`}function Te(e){if(e.length>=10)return 6;if(e.length>=5)return 4;return 3}function ke(e){if(e.length>=10)return 3;if(e.length>=5)return 1.5;return 0}function Ae(e){if(e.length>=10)return 3;if(e.length>=5)return 3;return 2}function Ie(e){if(e.length>=10)return 6;if(e.length>=5)return 6;return 4}function Pe(e){if(e.length>=10)return 12;if(e.length>=5)return 16;return 12}function _e(e){if(e.length>=10)return 4;if(e.length>=5)return 3;return 0}function Le(e){if(e.length>=10)return 3;if(e.length>=5)return 2;return 1}async function Me(e){return!!(await e.evaluate(`
212
212
  (() => {
213
213
  const isVisible = (el) => {
214
214
  if (!(el instanceof HTMLElement)) return false;
@@ -231,7 +231,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
231
231
  }
232
232
  return { ok: false };
233
233
  })()
234
- `))?.ok}async function fj(j){return!!(await j.evaluate(`
234
+ `))?.ok}async function qe(e){return!!(await e.evaluate(`
235
235
  (() => {
236
236
  const isVisible = (el) => {
237
237
  if (!(el instanceof HTMLElement)) return false;
@@ -265,7 +265,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
265
265
  }
266
266
  return { ok: false };
267
267
  })()
268
- `))?.ok}async function Uj(j,K=12){const Q=Math.max(1,Math.ceil(K));for(let Y=0;Y<Q;Y++){const Z=await L(j);if(Z.state==="preview")return;if(Z.state==="failed"){await j.screenshot({path:"/tmp/instagram_post_preview_debug.png"});throw W("Inspect /tmp/instagram_post_preview_debug.png. "+(Z.detail||""))}if(Y<Q-1)await j.wait({time:1})}await j.screenshot({path:"/tmp/instagram_post_preview_debug.png"});throw new q("Instagram image preview did not appear after upload","The selected file input may not match the active composer; inspect /tmp/instagram_post_preview_debug.png")}async function m(j,K=4){const Q=Math.max(1,Math.ceil(K*2));for(let Y=0;Y<Q;Y++){const Z=await L(j);if(Z.state!=="pending")return Z;if(Y<Q-1)await j.wait({time:0.5})}return{state:"pending"}}export function buildClickActionJs(j,K="any"){return`
268
+ `))?.ok}async function Ne(e,t=12){const a=Math.max(1,Math.ceil(t));for(let n=0;n<a;n++){const r=await x(e);if(r.state==="preview")return;if(r.state==="failed"){await e.screenshot({path:"/tmp/instagram_post_preview_debug.png"});throw S("Inspect /tmp/instagram_post_preview_debug.png. "+(r.detail||""))}if(n<a-1)await e.wait({time:1})}await e.screenshot({path:"/tmp/instagram_post_preview_debug.png"});throw new i("Instagram image preview did not appear after upload","The selected file input may not match the active composer; inspect /tmp/instagram_post_preview_debug.png")}async function H(e,t=4){const a=Math.max(1,Math.ceil(t*2));for(let n=0;n<a;n++){const r=await x(e);if(r.state!=="pending")return r;if(n<a-1)await e.wait({time:0.5})}return{state:"pending"}}export function buildClickActionJs(e,t="any"){return`
269
269
  ((labels, scope) => {
270
270
  const isVisible = (el) => {
271
271
  if (!(el instanceof HTMLElement)) return false;
@@ -319,8 +319,8 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
319
319
  }
320
320
  }
321
321
  return { ok: false };
322
- })(${JSON.stringify(j)}, ${JSON.stringify(K)})
323
- `}async function l(j,K,Q="any"){const Y=await j.evaluate(buildClickActionJs(K,Q));if(!Y?.ok)throw new q(`Instagram action button not found: ${K.join(" / ")}`);return Y.label||K[0]}async function Sj(j){return!!(await j.evaluate(`
322
+ })(${JSON.stringify(e)}, ${JSON.stringify(t)})
323
+ `}async function j(e,t,a="any"){const n=await e.evaluate(buildClickActionJs(t,a));if(!n?.ok)throw new i(`Instagram action button not found: ${t.join(" / ")}`);return n.label||t[0]}async function Re(e){return!!(await e.evaluate(`
324
324
  (() => {
325
325
  const isVisible = (el) => {
326
326
  if (!(el instanceof HTMLElement)) return false;
@@ -358,12 +358,12 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
358
358
 
359
359
  return { ok: false };
360
360
  })()
361
- `))?.ok}async function g(j){return!!(await j.evaluate(`
361
+ `))?.ok}async function F(e){return!!(await e.evaluate(`
362
362
  (() => {
363
363
  const editable = document.querySelector('textarea, [contenteditable="true"]');
364
364
  return { ok: !!editable };
365
365
  })()
366
- `))?.ok}async function s(j){return!!(await j.evaluate(`
366
+ `))?.ok}async function J(e){return!!(await e.evaluate(`
367
367
  (() => {
368
368
  const editable = document.querySelector('textarea, [contenteditable="true"]');
369
369
  const dialogText = Array.from(document.querySelectorAll('[role="dialog"]'))
@@ -377,7 +377,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
377
377
  || dialogText.includes('advanced settings'),
378
378
  };
379
379
  })()
380
- `))?.ok}async function Pj(j){for(let K=0;K<3;K++){if(await s(j))return;try{await l(j,["Next","下一步"],"media")}catch(Y){if(Y instanceof q){await j.wait({time:1.5});if(await s(j))return;const Z=await L(j);if(Z.state==="failed")throw W(Z.detail);if(K<2)continue}throw Y}await j.wait({time:1.5});if(await g(j))return;const Q=await L(j);if(Q.state==="failed")throw W(Q.detail)}await j.screenshot({path:"/tmp/instagram_post_caption_debug.png"});throw new q("Instagram caption editor did not appear","Instagram may have changed the publish flow; inspect /tmp/instagram_post_caption_debug.png")}async function ij(j){if(!await g(j)){await j.screenshot({path:"/tmp/instagram_post_caption_debug.png"});throw new q("Instagram caption editor did not appear","Instagram may have changed the publish flow; inspect /tmp/instagram_post_caption_debug.png")}}async function Ej(j,K){const Q=await L(j);if(Q.state==="failed")throw W(Q.detail);throw K}async function vj(j){return!!(await j.evaluate(`
380
+ `))?.ok}async function Ue(e){for(let t=0;t<3;t++){if(await J(e))return;try{await j(e,["Next","下一步"],"media")}catch(n){if(n instanceof i){await e.wait({time:1.5});if(await J(e))return;const r=await x(e);if(r.state==="failed")throw S(r.detail);if(t<2)continue}throw n}await e.wait({time:1.5});if(await F(e))return;const a=await x(e);if(a.state==="failed")throw S(a.detail)}await e.screenshot({path:"/tmp/instagram_post_caption_debug.png"});throw new i("Instagram caption editor did not appear","Instagram may have changed the publish flow; inspect /tmp/instagram_post_caption_debug.png")}async function Xe(e){if(!await F(e)){await e.screenshot({path:"/tmp/instagram_post_caption_debug.png"});throw new i("Instagram caption editor did not appear","Instagram may have changed the publish flow; inspect /tmp/instagram_post_caption_debug.png")}}async function Oe(e,t){const a=await x(e);if(a.state==="failed")throw S(a.detail);throw t}async function De(e){return!!(await e.evaluate(`
381
381
  (() => {
382
382
  const textarea = document.querySelector('[aria-label="Write a caption..."], textarea');
383
383
  if (textarea instanceof HTMLTextAreaElement) {
@@ -437,7 +437,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
437
437
 
438
438
  return { ok: true, kind: 'contenteditable' };
439
439
  })()
440
- `))?.ok}async function Ij(j,K){if(j.insertText&&await vj(j))try{await j.insertText(K);await j.wait({time:0.3});await j.evaluate(`
440
+ `))?.ok}async function Ve(e,t){if(e.insertText&&await De(e))try{await e.insertText(t);await e.wait({time:0.3});await e.evaluate(`
441
441
  (() => {
442
442
  const textarea = document.querySelector('[aria-label="Write a caption..."], textarea');
443
443
  if (textarea instanceof HTMLTextAreaElement) {
@@ -459,7 +459,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
459
459
  editor.blur();
460
460
  return { ok: true };
461
461
  })()
462
- `);return}catch{}if(!(await j.evaluate(`
462
+ `);return}catch{}if(!(await e.evaluate(`
463
463
  ((content) => {
464
464
  const createParagraph = (text) => ({
465
465
  children: text
@@ -548,8 +548,8 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
548
548
  }
549
549
 
550
550
  return { ok: false };
551
- })(${JSON.stringify(K)})
552
- `))?.ok)throw new q("Failed to fill Instagram caption")}async function cj(j,K){return!!(await j.evaluate(`
551
+ })(${JSON.stringify(t)})
552
+ `))?.ok)throw new i("Failed to fill Instagram caption")}async function Be(e,t){return!!(await e.evaluate(`
553
553
  ((content) => {
554
554
  const normalized = content.trim();
555
555
  const readLexicalText = (node) => {
@@ -602,11 +602,11 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
602
602
  }
603
603
 
604
604
  return { ok: false };
605
- })(${JSON.stringify(K)})
606
- `))?.ok}async function dj(j,K){for(let Q=0;Q<6;Q++){if(await cj(j,K))return;if(Q<5)await j.wait({time:0.5})}await j.screenshot({path:"/tmp/instagram_post_caption_fill_debug.png"});throw new q("Instagram caption did not stick before sharing","Inspect /tmp/instagram_post_caption_fill_debug.png for the caption editor state")}async function n(j){let K=0;for(let Q=0;Q<90;Q++){const Y=await j.evaluate(buildPublishStatusProbeJs());if(Y?.failed){await j.screenshot({path:"/tmp/instagram_post_share_debug.png"});throw new q("Instagram post share failed","Inspect /tmp/instagram_post_share_debug.png for the share failure state")}if(Y?.ok)return Y.url||"";if(Y?.settled){K+=1;if(K>=3)return""}else K=0;if(Q<89)await j.wait({time:1})}await j.screenshot({path:"/tmp/instagram_post_share_debug.png"});throw new q("Instagram post share confirmation did not appear","Inspect /tmp/instagram_post_share_debug.png for the final publish state")}async function o(j){return(await j.getCookies({domain:"instagram.com"})).find((Q)=>Q.name==="ds_user_id")?.value||""}async function u(j,K=""){if(K){const Y=await $j(j),Z=await j.evaluate(`
605
+ })(${JSON.stringify(t)})
606
+ `))?.ok}async function He(e,t){for(let a=0;a<6;a++){if(await Be(e,t))return;if(a<5)await e.wait({time:0.5})}await e.screenshot({path:"/tmp/instagram_post_caption_fill_debug.png"});throw new i("Instagram caption did not stick before sharing","Inspect /tmp/instagram_post_caption_fill_debug.png for the caption editor state")}async function W(e){let t=0;for(let a=0;a<90;a++){const n=await e.evaluate(buildPublishStatusProbeJs());if(n?.failed){await e.screenshot({path:"/tmp/instagram_post_share_debug.png"});throw new i("Instagram post share failed","Inspect /tmp/instagram_post_share_debug.png for the share failure state")}if(n?.ok)return n.url||"";if(n?.settled){t+=1;if(t>=3)return""}else t=0;if(a<89)await e.wait({time:1})}await e.screenshot({path:"/tmp/instagram_post_share_debug.png"});throw new i("Instagram post share confirmation did not appear","Inspect /tmp/instagram_post_share_debug.png for the final publish state")}async function z(e){return(await e.getCookies({domain:"instagram.com"})).find((a)=>a.name==="ds_user_id")?.value||""}async function G(e,t=""){if(t){const n=await ie(e),r=await e.evaluate(`
607
607
  (async () => {
608
- const userId = ${JSON.stringify(K)};
609
- const appId = ${JSON.stringify(Y.appId||"")};
608
+ const userId = ${JSON.stringify(t)};
609
+ const appId = ${JSON.stringify(n.appId||"")};
610
610
  try {
611
611
  const res = await fetch(
612
612
  'https://www.instagram.com/api/v1/users/' + encodeURIComponent(userId) + '/info/',
@@ -623,7 +623,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
623
623
  return { ok: false };
624
624
  }
625
625
  })()
626
- `);if(Z?.ok&&Z.username)return new URL(`/${Z.username}/`,N).toString()}const Q=await j.evaluate(`
626
+ `);if(r?.ok&&r.username)return new URL(`/${r.username}/`,m).toString()}const a=await e.evaluate(`
627
627
  (() => {
628
628
  const isVisible = (el) => {
629
629
  if (!(el instanceof HTMLElement)) return false;
@@ -648,7 +648,7 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
648
648
  const path = explicitProfile;
649
649
  return { ok: !!path, path };
650
650
  })()
651
- `);if(!Q?.ok||!Q.path)return"";return new URL(Q.path,N).toString()}async function i(j){const K=await j.evaluate(`
651
+ `);if(!a?.ok||!a.path)return"";return new URL(a.path,m).toString()}async function X(e){const t=await e.evaluate(`
652
652
  (() => {
653
653
  const isVisible = (el) => {
654
654
  if (!(el instanceof HTMLElement)) return false;
@@ -668,4 +668,4 @@ import*as E from"node:fs";import*as v from"node:path";import{cli as r,Strategy a
668
668
 
669
669
  return { ok: hrefs.length > 0, hrefs };
670
670
  })()
671
- `);return Array.isArray(K?.hrefs)?K.hrefs.filter(Boolean):[]}async function mj(j){const K=await o(j);if(!K)return null;const Q=await u(j,K);if(!Q)return null;try{await j.goto(Q);await j.wait({time:3});return new Set(await i(j))}catch{return null}}async function x(j,K){const Q=await j.getCurrentUrl?.();if(Q&&/\/p\//.test(Q))return Q;const Y=await o(j),Z=await u(j,Y);if(!Z)return"";await j.goto(Z);await j.wait({time:4});for(let $=0;$<8;$++){const z=(await i(j)).find((G)=>!K.has(G))||"";if(z)return new URL(z,N).toString();if($<7)await j.wait({time:1})}return""}r({site:"instagram",name:"post",access:"write",description:"Post an Instagram feed image or mixed-media carousel",domain:"www.instagram.com",strategy:t.UI,browser:!0,args:[{name:"media",required:!1,valueRequired:!0,help:`Comma-separated media paths (images/videos, up to ${h})`},{name:"content",fromFile:!0,positional:!0,required:!1,help:"Caption text"},{name:"timeout",type:"int",required:!1,default:300,help:"Max seconds for the overall command (default: 300)"}],columns:["status","detail","url","media_id","account_id"],validateArgs:Hj,func:async(j,K)=>{const Q=Gj(j),Y=Xj(K);I(K.content);const Z=String(K.content??"").trim(),$=await mj(Q),J=$!==null,z=$??new Set,G=Rj(Y),X=yj(Y),T=xj(Y),_=hj(Y),D=kj(Y),M=bj(Y),C=wj(Y),B=process.env.OPENCLI_INSTAGRAM_CAPTURE==="1",f=[],U=[],p=async()=>{if(!B)return;await e(Q)},S=async()=>{if(!B)return;const V=await jj(Q);if(V.data.length)f.push(...V.data);if(V.errors.length)U.push(...V.errors)};try{try{return await Dj({page:Q,mediaItems:Y,content:Z,existingPostPaths:z,canDiffProfile:J})}catch(V){if(V instanceof A)throw V;if(Zj(V)){let O="",P=!1;if(J)try{O=await x(Q,z);P=!0}catch{}if(O)return R(Y,O);if(!P){const a=V instanceof Error?V.message:String(V);throw new q(`Instagram publish outcome uncertain: ${a}`,"The post may already be live. Do NOT rerun this command blindly — check the profile for a new post first; retrying on a false failure creates a duplicate post.")}}if(!Nj(V))throw V;try{return await Fj({page:Q,mediaItems:Y,content:Z,existingPostPaths:z,canDiffProfile:J,commandAttemptBudget:G,preUploadDelaySeconds:X,uploadAttemptBudget:T,previewProbeWindowSeconds:_,finalPreviewWaitSeconds:D,preShareDelaySeconds:M,inlineUploadRetryBudget:C,installProtocolCapture:p,drainProtocolCapture:S,forceFreshStart:!0})}catch(O){if(O instanceof A)throw O;if(O instanceof q)throw new q(_j(V,O),Tj(V,O));throw O}}}finally{if(B){try{await S()}catch{}E.writeFileSync(Vj,JSON.stringify({data:f,errors:U},null,2))}}}});
671
+ `);return Array.isArray(t?.hrefs)?t.hrefs.filter(Boolean):[]}async function $e(e){const t=await z(e);if(!t)return null;const a=await G(e,t);if(!a)return null;try{await e.goto(a);await e.wait({time:3});return new Set(await X(e))}catch{return null}}async function k(e,t){const a=await e.getCurrentUrl?.();if(a&&/\/p\//.test(a))return a;const n=await z(e),r=await G(e,n);if(!r)return"";await e.goto(r);await e.wait({time:4});for(let o=0;o<8;o++){const s=(await X(e)).find((d)=>!t.has(d))||"";if(s)return new URL(s,m).toString();if(o<7)await e.wait({time:1})}return""}Y({site:"instagram",name:"post",access:"write",description:"Post an Instagram feed image or mixed-media carousel",domain:"www.instagram.com",strategy:Z.UI,browser:!0,args:[{name:"media",required:!1,valueRequired:!0,help:`Comma-separated media paths (images/videos, up to ${A})`},{name:"content",fromFile:!0,positional:!0,required:!1,help:"Caption text"},{name:"timeout",type:"int",required:!1,default:300,help:"Max seconds for the overall command (default: 300)"}],columns:["status","detail","url","media_id","account_id"],validateArgs:ge,func:async(e,t)=>{const a=ue(e),n=pe(t);D(t.content);const r=String(t.content??"").trim(),o=await $e(a),l=o!==null,s=o??new Set,d=Te(n),f=ke(n),h=Ae(n),w=Ie(n),y=Pe(n),v=_e(n),L=Le(n),g=process.env.OPENCLI_INSTAGRAM_CAPTURE==="1",M=[],q=[],K=async()=>{if(!g)return;await ee(a)},N=async()=>{if(!g)return;const c=await te(a);if(c.data.length)M.push(...c.data);if(c.errors.length)q.push(...c.errors)};try{try{return await be({page:a,mediaItems:n,content:r,existingPostPaths:s,canDiffProfile:l})}catch(c){if(c instanceof C)throw c;if(oe(c)){let u="",R=!1;if(l)try{u=await k(a,s);R=!0}catch{}if(u)return E(n,u);if(!R){const Q=c instanceof Error?c.message:String(c);throw new i(`Instagram publish outcome uncertain: ${Q}`,"The post may already be live. Do NOT rerun this command blindly — check the profile for a new post first; retrying on a false failure creates a duplicate post.")}}if(!he(c))throw c;try{return await xe({page:a,mediaItems:n,content:r,existingPostPaths:s,canDiffProfile:l,commandAttemptBudget:d,preUploadDelaySeconds:f,uploadAttemptBudget:h,previewProbeWindowSeconds:w,finalPreviewWaitSeconds:y,preShareDelaySeconds:v,inlineUploadRetryBudget:L,installProtocolCapture:K,drainProtocolCapture:N,forceFreshStart:!0})}catch(u){if(u instanceof C)throw u;if(u instanceof i)throw new i(ye(c,u),we(c,u));throw u}}}finally{if(g){try{await N()}catch{}U.writeFileSync(de,JSON.stringify({data:M,errors:q},null,2))}}}});