@wecode-ai/weibo-openclaw-plugin 2.1.4 → 2.2.1

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 (368) hide show
  1. package/README.md +28 -1
  2. package/node_modules/@isaacs/fs-minipass/LICENSE +15 -0
  3. package/node_modules/@isaacs/fs-minipass/README.md +71 -0
  4. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +118 -0
  5. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts.map +1 -0
  6. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +430 -0
  7. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js.map +1 -0
  8. package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +3 -0
  9. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +118 -0
  10. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts.map +1 -0
  11. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +420 -0
  12. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js.map +1 -0
  13. package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +3 -0
  14. package/node_modules/@isaacs/fs-minipass/package.json +72 -0
  15. package/node_modules/chownr/LICENSE.md +63 -0
  16. package/node_modules/chownr/README.md +3 -0
  17. package/node_modules/chownr/dist/commonjs/index.d.ts +3 -0
  18. package/node_modules/chownr/dist/commonjs/index.d.ts.map +1 -0
  19. package/node_modules/chownr/dist/commonjs/index.js +93 -0
  20. package/node_modules/chownr/dist/commonjs/index.js.map +1 -0
  21. package/node_modules/chownr/dist/commonjs/package.json +3 -0
  22. package/node_modules/chownr/dist/esm/index.d.ts +3 -0
  23. package/node_modules/chownr/dist/esm/index.d.ts.map +1 -0
  24. package/node_modules/chownr/dist/esm/index.js +85 -0
  25. package/node_modules/chownr/dist/esm/index.js.map +1 -0
  26. package/node_modules/chownr/dist/esm/package.json +3 -0
  27. package/node_modules/chownr/package.json +69 -0
  28. package/node_modules/minipass/LICENSE.md +55 -0
  29. package/node_modules/minipass/README.md +825 -0
  30. package/node_modules/minipass/dist/commonjs/index.d.ts +545 -0
  31. package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
  32. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  33. package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
  34. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  35. package/node_modules/minipass/dist/esm/index.d.ts +545 -0
  36. package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
  37. package/node_modules/minipass/dist/esm/index.js +1020 -0
  38. package/node_modules/minipass/dist/esm/index.js.map +1 -0
  39. package/node_modules/minipass/dist/esm/package.json +3 -0
  40. package/node_modules/minipass/package.json +77 -0
  41. package/node_modules/minizlib/LICENSE +26 -0
  42. package/node_modules/minizlib/README.md +64 -0
  43. package/node_modules/minizlib/dist/commonjs/constants.d.ts +2 -0
  44. package/node_modules/minizlib/dist/commonjs/constants.d.ts.map +1 -0
  45. package/node_modules/minizlib/dist/commonjs/constants.js +123 -0
  46. package/node_modules/minizlib/dist/commonjs/constants.js.map +1 -0
  47. package/node_modules/minizlib/dist/commonjs/index.d.ts +99 -0
  48. package/node_modules/minizlib/dist/commonjs/index.d.ts.map +1 -0
  49. package/node_modules/minizlib/dist/commonjs/index.js +416 -0
  50. package/node_modules/minizlib/dist/commonjs/index.js.map +1 -0
  51. package/node_modules/minizlib/dist/commonjs/package.json +3 -0
  52. package/node_modules/minizlib/dist/esm/constants.d.ts +2 -0
  53. package/node_modules/minizlib/dist/esm/constants.d.ts.map +1 -0
  54. package/node_modules/minizlib/dist/esm/constants.js +117 -0
  55. package/node_modules/minizlib/dist/esm/constants.js.map +1 -0
  56. package/node_modules/minizlib/dist/esm/index.d.ts +99 -0
  57. package/node_modules/minizlib/dist/esm/index.d.ts.map +1 -0
  58. package/node_modules/minizlib/dist/esm/index.js +363 -0
  59. package/node_modules/minizlib/dist/esm/index.js.map +1 -0
  60. package/node_modules/minizlib/dist/esm/package.json +3 -0
  61. package/node_modules/minizlib/package.json +80 -0
  62. package/node_modules/tar/LICENSE.md +55 -0
  63. package/node_modules/tar/README.md +1224 -0
  64. package/node_modules/tar/dist/commonjs/create.d.ts +3 -0
  65. package/node_modules/tar/dist/commonjs/create.d.ts.map +1 -0
  66. package/node_modules/tar/dist/commonjs/create.js +82 -0
  67. package/node_modules/tar/dist/commonjs/create.js.map +1 -0
  68. package/node_modules/tar/dist/commonjs/cwd-error.d.ts +8 -0
  69. package/node_modules/tar/dist/commonjs/cwd-error.d.ts.map +1 -0
  70. package/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
  71. package/node_modules/tar/dist/commonjs/cwd-error.js.map +1 -0
  72. package/node_modules/tar/dist/commonjs/extract.d.ts +3 -0
  73. package/node_modules/tar/dist/commonjs/extract.d.ts.map +1 -0
  74. package/node_modules/tar/dist/commonjs/extract.js +88 -0
  75. package/node_modules/tar/dist/commonjs/extract.js.map +1 -0
  76. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +2 -0
  77. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts.map +1 -0
  78. package/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
  79. package/node_modules/tar/dist/commonjs/get-write-flag.js.map +1 -0
  80. package/node_modules/tar/dist/commonjs/header.d.ts +53 -0
  81. package/node_modules/tar/dist/commonjs/header.d.ts.map +1 -0
  82. package/node_modules/tar/dist/commonjs/header.js +312 -0
  83. package/node_modules/tar/dist/commonjs/header.js.map +1 -0
  84. package/node_modules/tar/dist/commonjs/index.d.ts +20 -0
  85. package/node_modules/tar/dist/commonjs/index.d.ts.map +1 -0
  86. package/node_modules/tar/dist/commonjs/index.js +64 -0
  87. package/node_modules/tar/dist/commonjs/index.js.map +1 -0
  88. package/node_modules/tar/dist/commonjs/index.min.js +4 -0
  89. package/node_modules/tar/dist/commonjs/index.min.js.map +7 -0
  90. package/node_modules/tar/dist/commonjs/large-numbers.d.ts +3 -0
  91. package/node_modules/tar/dist/commonjs/large-numbers.d.ts.map +1 -0
  92. package/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
  93. package/node_modules/tar/dist/commonjs/large-numbers.js.map +1 -0
  94. package/node_modules/tar/dist/commonjs/list.d.ts +7 -0
  95. package/node_modules/tar/dist/commonjs/list.d.ts.map +1 -0
  96. package/node_modules/tar/dist/commonjs/list.js +145 -0
  97. package/node_modules/tar/dist/commonjs/list.js.map +1 -0
  98. package/node_modules/tar/dist/commonjs/make-command.d.ts +49 -0
  99. package/node_modules/tar/dist/commonjs/make-command.d.ts.map +1 -0
  100. package/node_modules/tar/dist/commonjs/make-command.js +52 -0
  101. package/node_modules/tar/dist/commonjs/make-command.js.map +1 -0
  102. package/node_modules/tar/dist/commonjs/mkdir.d.ts +25 -0
  103. package/node_modules/tar/dist/commonjs/mkdir.d.ts.map +1 -0
  104. package/node_modules/tar/dist/commonjs/mkdir.js +187 -0
  105. package/node_modules/tar/dist/commonjs/mkdir.js.map +1 -0
  106. package/node_modules/tar/dist/commonjs/mode-fix.d.ts +2 -0
  107. package/node_modules/tar/dist/commonjs/mode-fix.d.ts.map +1 -0
  108. package/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
  109. package/node_modules/tar/dist/commonjs/mode-fix.js.map +1 -0
  110. package/node_modules/tar/dist/commonjs/normalize-unicode.d.ts +2 -0
  111. package/node_modules/tar/dist/commonjs/normalize-unicode.d.ts.map +1 -0
  112. package/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
  113. package/node_modules/tar/dist/commonjs/normalize-unicode.js.map +1 -0
  114. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +2 -0
  115. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
  116. package/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
  117. package/node_modules/tar/dist/commonjs/normalize-windows-path.js.map +1 -0
  118. package/node_modules/tar/dist/commonjs/options.d.ts +596 -0
  119. package/node_modules/tar/dist/commonjs/options.d.ts.map +1 -0
  120. package/node_modules/tar/dist/commonjs/options.js +66 -0
  121. package/node_modules/tar/dist/commonjs/options.js.map +1 -0
  122. package/node_modules/tar/dist/commonjs/pack.d.ts +102 -0
  123. package/node_modules/tar/dist/commonjs/pack.d.ts.map +1 -0
  124. package/node_modules/tar/dist/commonjs/pack.js +511 -0
  125. package/node_modules/tar/dist/commonjs/pack.js.map +1 -0
  126. package/node_modules/tar/dist/commonjs/package.json +3 -0
  127. package/node_modules/tar/dist/commonjs/parse.d.ts +85 -0
  128. package/node_modules/tar/dist/commonjs/parse.d.ts.map +1 -0
  129. package/node_modules/tar/dist/commonjs/parse.js +610 -0
  130. package/node_modules/tar/dist/commonjs/parse.js.map +1 -0
  131. package/node_modules/tar/dist/commonjs/path-reservations.d.ts +11 -0
  132. package/node_modules/tar/dist/commonjs/path-reservations.d.ts.map +1 -0
  133. package/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
  134. package/node_modules/tar/dist/commonjs/path-reservations.js.map +1 -0
  135. package/node_modules/tar/dist/commonjs/pax.d.ts +26 -0
  136. package/node_modules/tar/dist/commonjs/pax.d.ts.map +1 -0
  137. package/node_modules/tar/dist/commonjs/pax.js +158 -0
  138. package/node_modules/tar/dist/commonjs/pax.js.map +1 -0
  139. package/node_modules/tar/dist/commonjs/process-umask.d.ts +2 -0
  140. package/node_modules/tar/dist/commonjs/process-umask.d.ts.map +1 -0
  141. package/node_modules/tar/dist/commonjs/process-umask.js +7 -0
  142. package/node_modules/tar/dist/commonjs/process-umask.js.map +1 -0
  143. package/node_modules/tar/dist/commonjs/read-entry.d.ts +36 -0
  144. package/node_modules/tar/dist/commonjs/read-entry.d.ts.map +1 -0
  145. package/node_modules/tar/dist/commonjs/read-entry.js +136 -0
  146. package/node_modules/tar/dist/commonjs/read-entry.js.map +1 -0
  147. package/node_modules/tar/dist/commonjs/replace.d.ts +2 -0
  148. package/node_modules/tar/dist/commonjs/replace.d.ts.map +1 -0
  149. package/node_modules/tar/dist/commonjs/replace.js +227 -0
  150. package/node_modules/tar/dist/commonjs/replace.js.map +1 -0
  151. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +2 -0
  152. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
  153. package/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
  154. package/node_modules/tar/dist/commonjs/strip-absolute-path.js.map +1 -0
  155. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
  156. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
  157. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
  158. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.js.map +1 -0
  159. package/node_modules/tar/dist/commonjs/symlink-error.d.ts +9 -0
  160. package/node_modules/tar/dist/commonjs/symlink-error.d.ts.map +1 -0
  161. package/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
  162. package/node_modules/tar/dist/commonjs/symlink-error.js.map +1 -0
  163. package/node_modules/tar/dist/commonjs/types.d.ts +7 -0
  164. package/node_modules/tar/dist/commonjs/types.d.ts.map +1 -0
  165. package/node_modules/tar/dist/commonjs/types.js +50 -0
  166. package/node_modules/tar/dist/commonjs/types.js.map +1 -0
  167. package/node_modules/tar/dist/commonjs/unpack.d.ts +101 -0
  168. package/node_modules/tar/dist/commonjs/unpack.d.ts.map +1 -0
  169. package/node_modules/tar/dist/commonjs/unpack.js +932 -0
  170. package/node_modules/tar/dist/commonjs/unpack.js.map +1 -0
  171. package/node_modules/tar/dist/commonjs/update.d.ts +2 -0
  172. package/node_modules/tar/dist/commonjs/update.d.ts.map +1 -0
  173. package/node_modules/tar/dist/commonjs/update.js +33 -0
  174. package/node_modules/tar/dist/commonjs/update.js.map +1 -0
  175. package/node_modules/tar/dist/commonjs/warn-method.d.ts +24 -0
  176. package/node_modules/tar/dist/commonjs/warn-method.d.ts.map +1 -0
  177. package/node_modules/tar/dist/commonjs/warn-method.js +31 -0
  178. package/node_modules/tar/dist/commonjs/warn-method.js.map +1 -0
  179. package/node_modules/tar/dist/commonjs/winchars.d.ts +3 -0
  180. package/node_modules/tar/dist/commonjs/winchars.d.ts.map +1 -0
  181. package/node_modules/tar/dist/commonjs/winchars.js +14 -0
  182. package/node_modules/tar/dist/commonjs/winchars.js.map +1 -0
  183. package/node_modules/tar/dist/commonjs/write-entry.d.ts +129 -0
  184. package/node_modules/tar/dist/commonjs/write-entry.d.ts.map +1 -0
  185. package/node_modules/tar/dist/commonjs/write-entry.js +698 -0
  186. package/node_modules/tar/dist/commonjs/write-entry.js.map +1 -0
  187. package/node_modules/tar/dist/esm/create.d.ts +3 -0
  188. package/node_modules/tar/dist/esm/create.d.ts.map +1 -0
  189. package/node_modules/tar/dist/esm/create.js +76 -0
  190. package/node_modules/tar/dist/esm/create.js.map +1 -0
  191. package/node_modules/tar/dist/esm/cwd-error.d.ts +8 -0
  192. package/node_modules/tar/dist/esm/cwd-error.d.ts.map +1 -0
  193. package/node_modules/tar/dist/esm/cwd-error.js +14 -0
  194. package/node_modules/tar/dist/esm/cwd-error.js.map +1 -0
  195. package/node_modules/tar/dist/esm/extract.d.ts +3 -0
  196. package/node_modules/tar/dist/esm/extract.d.ts.map +1 -0
  197. package/node_modules/tar/dist/esm/extract.js +49 -0
  198. package/node_modules/tar/dist/esm/extract.js.map +1 -0
  199. package/node_modules/tar/dist/esm/get-write-flag.d.ts +2 -0
  200. package/node_modules/tar/dist/esm/get-write-flag.d.ts.map +1 -0
  201. package/node_modules/tar/dist/esm/get-write-flag.js +26 -0
  202. package/node_modules/tar/dist/esm/get-write-flag.js.map +1 -0
  203. package/node_modules/tar/dist/esm/header.d.ts +53 -0
  204. package/node_modules/tar/dist/esm/header.d.ts.map +1 -0
  205. package/node_modules/tar/dist/esm/header.js +275 -0
  206. package/node_modules/tar/dist/esm/header.js.map +1 -0
  207. package/node_modules/tar/dist/esm/index.d.ts +20 -0
  208. package/node_modules/tar/dist/esm/index.d.ts.map +1 -0
  209. package/node_modules/tar/dist/esm/index.js +20 -0
  210. package/node_modules/tar/dist/esm/index.js.map +1 -0
  211. package/node_modules/tar/dist/esm/index.min.js +4 -0
  212. package/node_modules/tar/dist/esm/index.min.js.map +7 -0
  213. package/node_modules/tar/dist/esm/large-numbers.d.ts +3 -0
  214. package/node_modules/tar/dist/esm/large-numbers.d.ts.map +1 -0
  215. package/node_modules/tar/dist/esm/large-numbers.js +94 -0
  216. package/node_modules/tar/dist/esm/large-numbers.js.map +1 -0
  217. package/node_modules/tar/dist/esm/list.d.ts +7 -0
  218. package/node_modules/tar/dist/esm/list.d.ts.map +1 -0
  219. package/node_modules/tar/dist/esm/list.js +105 -0
  220. package/node_modules/tar/dist/esm/list.js.map +1 -0
  221. package/node_modules/tar/dist/esm/make-command.d.ts +49 -0
  222. package/node_modules/tar/dist/esm/make-command.d.ts.map +1 -0
  223. package/node_modules/tar/dist/esm/make-command.js +48 -0
  224. package/node_modules/tar/dist/esm/make-command.js.map +1 -0
  225. package/node_modules/tar/dist/esm/mkdir.d.ts +25 -0
  226. package/node_modules/tar/dist/esm/mkdir.d.ts.map +1 -0
  227. package/node_modules/tar/dist/esm/mkdir.js +179 -0
  228. package/node_modules/tar/dist/esm/mkdir.js.map +1 -0
  229. package/node_modules/tar/dist/esm/mode-fix.d.ts +2 -0
  230. package/node_modules/tar/dist/esm/mode-fix.d.ts.map +1 -0
  231. package/node_modules/tar/dist/esm/mode-fix.js +25 -0
  232. package/node_modules/tar/dist/esm/mode-fix.js.map +1 -0
  233. package/node_modules/tar/dist/esm/normalize-unicode.d.ts +2 -0
  234. package/node_modules/tar/dist/esm/normalize-unicode.d.ts.map +1 -0
  235. package/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
  236. package/node_modules/tar/dist/esm/normalize-unicode.js.map +1 -0
  237. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +2 -0
  238. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts.map +1 -0
  239. package/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
  240. package/node_modules/tar/dist/esm/normalize-windows-path.js.map +1 -0
  241. package/node_modules/tar/dist/esm/options.d.ts +596 -0
  242. package/node_modules/tar/dist/esm/options.d.ts.map +1 -0
  243. package/node_modules/tar/dist/esm/options.js +54 -0
  244. package/node_modules/tar/dist/esm/options.js.map +1 -0
  245. package/node_modules/tar/dist/esm/pack.d.ts +102 -0
  246. package/node_modules/tar/dist/esm/pack.d.ts.map +1 -0
  247. package/node_modules/tar/dist/esm/pack.js +469 -0
  248. package/node_modules/tar/dist/esm/pack.js.map +1 -0
  249. package/node_modules/tar/dist/esm/package.json +3 -0
  250. package/node_modules/tar/dist/esm/parse.d.ts +85 -0
  251. package/node_modules/tar/dist/esm/parse.d.ts.map +1 -0
  252. package/node_modules/tar/dist/esm/parse.js +606 -0
  253. package/node_modules/tar/dist/esm/parse.js.map +1 -0
  254. package/node_modules/tar/dist/esm/path-reservations.d.ts +11 -0
  255. package/node_modules/tar/dist/esm/path-reservations.d.ts.map +1 -0
  256. package/node_modules/tar/dist/esm/path-reservations.js +166 -0
  257. package/node_modules/tar/dist/esm/path-reservations.js.map +1 -0
  258. package/node_modules/tar/dist/esm/pax.d.ts +26 -0
  259. package/node_modules/tar/dist/esm/pax.d.ts.map +1 -0
  260. package/node_modules/tar/dist/esm/pax.js +154 -0
  261. package/node_modules/tar/dist/esm/pax.js.map +1 -0
  262. package/node_modules/tar/dist/esm/process-umask.d.ts +2 -0
  263. package/node_modules/tar/dist/esm/process-umask.d.ts.map +1 -0
  264. package/node_modules/tar/dist/esm/process-umask.js +3 -0
  265. package/node_modules/tar/dist/esm/process-umask.js.map +1 -0
  266. package/node_modules/tar/dist/esm/read-entry.d.ts +36 -0
  267. package/node_modules/tar/dist/esm/read-entry.d.ts.map +1 -0
  268. package/node_modules/tar/dist/esm/read-entry.js +132 -0
  269. package/node_modules/tar/dist/esm/read-entry.js.map +1 -0
  270. package/node_modules/tar/dist/esm/replace.d.ts +2 -0
  271. package/node_modules/tar/dist/esm/replace.d.ts.map +1 -0
  272. package/node_modules/tar/dist/esm/replace.js +221 -0
  273. package/node_modules/tar/dist/esm/replace.js.map +1 -0
  274. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +2 -0
  275. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts.map +1 -0
  276. package/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
  277. package/node_modules/tar/dist/esm/strip-absolute-path.js.map +1 -0
  278. package/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts +2 -0
  279. package/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
  280. package/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
  281. package/node_modules/tar/dist/esm/strip-trailing-slashes.js.map +1 -0
  282. package/node_modules/tar/dist/esm/symlink-error.d.ts +9 -0
  283. package/node_modules/tar/dist/esm/symlink-error.d.ts.map +1 -0
  284. package/node_modules/tar/dist/esm/symlink-error.js +15 -0
  285. package/node_modules/tar/dist/esm/symlink-error.js.map +1 -0
  286. package/node_modules/tar/dist/esm/types.d.ts +7 -0
  287. package/node_modules/tar/dist/esm/types.d.ts.map +1 -0
  288. package/node_modules/tar/dist/esm/types.js +45 -0
  289. package/node_modules/tar/dist/esm/types.js.map +1 -0
  290. package/node_modules/tar/dist/esm/unpack.d.ts +101 -0
  291. package/node_modules/tar/dist/esm/unpack.d.ts.map +1 -0
  292. package/node_modules/tar/dist/esm/unpack.js +891 -0
  293. package/node_modules/tar/dist/esm/unpack.js.map +1 -0
  294. package/node_modules/tar/dist/esm/update.d.ts +2 -0
  295. package/node_modules/tar/dist/esm/update.d.ts.map +1 -0
  296. package/node_modules/tar/dist/esm/update.js +30 -0
  297. package/node_modules/tar/dist/esm/update.js.map +1 -0
  298. package/node_modules/tar/dist/esm/warn-method.d.ts +24 -0
  299. package/node_modules/tar/dist/esm/warn-method.d.ts.map +1 -0
  300. package/node_modules/tar/dist/esm/warn-method.js +27 -0
  301. package/node_modules/tar/dist/esm/warn-method.js.map +1 -0
  302. package/node_modules/tar/dist/esm/winchars.d.ts +3 -0
  303. package/node_modules/tar/dist/esm/winchars.d.ts.map +1 -0
  304. package/node_modules/tar/dist/esm/winchars.js +9 -0
  305. package/node_modules/tar/dist/esm/winchars.js.map +1 -0
  306. package/node_modules/tar/dist/esm/write-entry.d.ts +129 -0
  307. package/node_modules/tar/dist/esm/write-entry.d.ts.map +1 -0
  308. package/node_modules/tar/dist/esm/write-entry.js +656 -0
  309. package/node_modules/tar/dist/esm/write-entry.js.map +1 -0
  310. package/node_modules/tar/package.json +297 -0
  311. package/node_modules/yallist/LICENSE.md +63 -0
  312. package/node_modules/yallist/README.md +205 -0
  313. package/node_modules/yallist/dist/commonjs/index.d.ts +39 -0
  314. package/node_modules/yallist/dist/commonjs/index.d.ts.map +1 -0
  315. package/node_modules/yallist/dist/commonjs/index.js +384 -0
  316. package/node_modules/yallist/dist/commonjs/index.js.map +1 -0
  317. package/node_modules/yallist/dist/commonjs/package.json +3 -0
  318. package/node_modules/yallist/dist/esm/index.d.ts +39 -0
  319. package/node_modules/yallist/dist/esm/index.d.ts.map +1 -0
  320. package/node_modules/yallist/dist/esm/index.js +379 -0
  321. package/node_modules/yallist/dist/esm/index.js.map +1 -0
  322. package/node_modules/yallist/dist/esm/package.json +3 -0
  323. package/node_modules/yallist/package.json +68 -0
  324. package/package.json +3 -1
  325. package/skills/manifest.json +12 -0
  326. package/skills/weibo-cron/SKILL.md +54 -54
  327. package/skills/weibo-cron/references/HEARTBEAT-PROCESS.md +65 -0
  328. package/skills/weibo-crowd/SKILL.md +182 -16
  329. package/skills/weibo-crowd/references/SILICON-TEAHOUSE-RULES.md +195 -62
  330. package/skills/weibo-crowd/scripts/weibo-crowd.js +105 -27
  331. package/skills/weibo-hot-search/SKILL.md +3 -1
  332. package/skills/weibo-pic/SKILL.md +266 -0
  333. package/skills/weibo-pic/scripts/weibo-pic.js +798 -0
  334. package/skills/weibo-search/SKILL.md +4 -2
  335. package/skills/weibo-status/SKILL.md +5 -3
  336. package/skills/weibo-token/SKILL.md +4 -2
  337. package/skills/weibo-video/SKILL.md +2 -0
  338. package/src/accounts.js +1 -1
  339. package/src/accounts.js.map +1 -1
  340. package/src/channel.js +2 -2
  341. package/src/channel.js.map +1 -1
  342. package/src/client.d.ts.map +1 -1
  343. package/src/client.js +3 -0
  344. package/src/client.js.map +1 -1
  345. package/src/config-schema.js +2 -2
  346. package/src/config-schema.js.map +1 -1
  347. package/src/skill-updater.d.ts +14 -0
  348. package/src/skill-updater.d.ts.map +1 -0
  349. package/src/skill-updater.js +240 -0
  350. package/src/skill-updater.js.map +1 -0
  351. package/src/token.d.ts +2 -0
  352. package/src/token.d.ts.map +1 -1
  353. package/src/token.js +2 -1
  354. package/src/token.js.map +1 -1
  355. package/src/weibo-hot-search.d.ts +2 -2
  356. package/src/weibo-hot-search.d.ts.map +1 -1
  357. package/src/weibo-hot-search.js +2 -2
  358. package/src/weibo-hot-search.js.map +1 -1
  359. package/src/weibo-search.d.ts +2 -2
  360. package/src/weibo-search.d.ts.map +1 -1
  361. package/src/weibo-search.js +2 -2
  362. package/src/weibo-search.js.map +1 -1
  363. package/src/weibo-status.js +2 -2
  364. package/src/weibo-status.js.map +1 -1
  365. package/src/weibo-token-tool.d.ts +2 -2
  366. package/src/weibo-token-tool.d.ts.map +1 -1
  367. package/src/weibo-token-tool.js +3 -3
  368. package/src/weibo-token-tool.js.map +1 -1
@@ -0,0 +1,798 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 微博图片上传 API 封装脚本
5
+ *
6
+ * 使用方法:
7
+ * node weibo-pic.js <command> [options]
8
+ *
9
+ * 命令:
10
+ * login 登录并获取 Token(整合原 token 命令功能)
11
+ * refresh 刷新 Token
12
+ * upload 上传本地图片文件
13
+ *
14
+ * 配置优先级:
15
+ * 1. 本地配置文件 ~/.weibo-pic/config.json
16
+ * 2. OpenClaw 配置文件 ~/.openclaw/openclaw.json
17
+ *
18
+ * 示例:
19
+ * # 登录(首次使用会引导配置)
20
+ * node weibo-pic.js login
21
+ *
22
+ * # 上传图片(自动使用缓存的 Token)
23
+ * node weibo-pic.js upload --file="/path/to/image.jpg"
24
+ */
25
+
26
+ import https from 'https';
27
+ import http from 'http';
28
+ import { URL } from 'url';
29
+ import fs from 'fs/promises';
30
+ import { statSync } from 'fs';
31
+ import path from 'path';
32
+ import os from 'os';
33
+ import crypto from 'crypto';
34
+ import readline from 'readline';
35
+ import { fileURLToPath } from 'url';
36
+
37
+ // 获取 __dirname 等效值(ES 模块中不可用)
38
+ const __filename = fileURLToPath(import.meta.url);
39
+ const __dirname = path.dirname(__filename);
40
+
41
+ // ============================================================================
42
+ // 配置常量
43
+ // ============================================================================
44
+
45
+ const BASE_URL = 'https://open-im.api.weibo.com';
46
+
47
+ const CONFIG_PATHS = {
48
+ openclaw: path.join(os.homedir(), '.openclaw', 'openclaw.json'),
49
+ local: path.join(os.homedir(), '.weibo-pic', 'config.json'),
50
+ tokenCache: path.join(os.homedir(), '.weibo-pic', 'token-cache.json')
51
+ };
52
+
53
+ // ============================================================================
54
+ // 错误类定义
55
+ // ============================================================================
56
+
57
+ class ConfigError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = 'ConfigError';
61
+ }
62
+ }
63
+
64
+ class TokenError extends Error {
65
+ constructor(message, retryable = false) {
66
+ super(message);
67
+ this.name = 'TokenError';
68
+ this.retryable = retryable;
69
+ }
70
+ }
71
+
72
+ class APIError extends Error {
73
+ constructor(message, code, retryable = false) {
74
+ super(message);
75
+ this.name = 'APIError';
76
+ this.code = code;
77
+ this.retryable = retryable;
78
+ }
79
+ }
80
+
81
+ // 错误码映射
82
+ const ERROR_MESSAGES = {
83
+ 40001: '参数缺失:token',
84
+ 40002: '参数缺失或超限',
85
+ 40100: 'Token 无效或已过期,请重新登录',
86
+ 42900: '频率限制:超过每日调用次数上限,请明天再试',
87
+ 50000: '服务器内部错误,请稍后重试',
88
+ 50001: '操作失败,请检查参数后重试'
89
+ };
90
+
91
+ // 可重试的错误码
92
+ const RETRYABLE_ERRORS = new Set([50000, 50001]);
93
+
94
+ // ============================================================================
95
+ // 日志工具
96
+ // ============================================================================
97
+
98
+ // 调试模式开关(默认关闭)
99
+ const DEBUG_MODE = false;
100
+
101
+ const Logger = {
102
+ info: (msg) => console.log(`[INFO] ${msg}`),
103
+ success: (msg) => console.log(`[SUCCESS] ✓ ${msg}`),
104
+ warn: (msg) => console.warn(`[WARN] ⚠ ${msg}`),
105
+ error: (msg) => console.error(`[ERROR] ✗ ${msg}`),
106
+ debug: (msg) => DEBUG_MODE && console.log(`[DEBUG] ${msg}`)
107
+ };
108
+
109
+ // ============================================================================
110
+ // 加密模块
111
+ // ============================================================================
112
+
113
+ /**
114
+ * 生成加密密钥(基于机器特征)
115
+ * @returns {Buffer} 32 字节的加密密钥
116
+ */
117
+ function generateEncryptionKey() {
118
+ const machineId = `${os.hostname()}-${os.homedir()}`;
119
+ return crypto.createHash('sha256').update(machineId).digest();
120
+ }
121
+
122
+ /**
123
+ * 加密文本
124
+ * @param {string} text - 要加密的文本
125
+ * @returns {string} 加密后的字符串(格式: encrypted:iv:authTag:encrypted)
126
+ */
127
+ function encrypt(text) {
128
+ const key = generateEncryptionKey();
129
+ const iv = crypto.randomBytes(16);
130
+ const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
131
+
132
+ let encrypted = cipher.update(text, 'utf8', 'hex');
133
+ encrypted += cipher.final('hex');
134
+
135
+ const authTag = cipher.getAuthTag();
136
+
137
+ // 格式: encrypted:iv:authTag:encrypted
138
+ return `encrypted:${iv.toString('hex')}:${authTag.toString('hex')}:${encrypted}`;
139
+ }
140
+
141
+ /**
142
+ * 解密文本
143
+ * @param {string} encryptedText - 加密的文本
144
+ * @returns {string} 解密后的原文
145
+ */
146
+ function decrypt(encryptedText) {
147
+ if (!encryptedText.startsWith('encrypted:')) {
148
+ // 如果没有加密前缀,返回原文(兼容旧配置)
149
+ return encryptedText;
150
+ }
151
+
152
+ const parts = encryptedText.substring(10).split(':');
153
+ if (parts.length !== 3) {
154
+ throw new Error('Invalid encrypted format');
155
+ }
156
+
157
+ const [ivHex, authTagHex, encrypted] = parts;
158
+ const key = generateEncryptionKey();
159
+ const iv = Buffer.from(ivHex, 'hex');
160
+ const authTag = Buffer.from(authTagHex, 'hex');
161
+
162
+ const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
163
+ decipher.setAuthTag(authTag);
164
+
165
+ let decrypted = decipher.update(encrypted, 'hex', 'utf8');
166
+ decrypted += decipher.final('utf8');
167
+
168
+ return decrypted;
169
+ }
170
+
171
+ // ============================================================================
172
+ // 配置管理
173
+ // ============================================================================
174
+
175
+ /**
176
+ * 加载配置(按优先级合并)
177
+ * @returns {Promise<object>} 配置对象
178
+ */
179
+ async function loadConfig() {
180
+ const config = {
181
+ appId: undefined,
182
+ appSecret: undefined
183
+ };
184
+
185
+ // 尝试读取 OpenClaw 配置
186
+ try {
187
+ const openclawData = await fs.readFile(CONFIG_PATHS.openclaw, 'utf8');
188
+ const openclawConfig = JSON.parse(openclawData);
189
+ const weiboConfig = openclawConfig.channels?.weibo;
190
+ if (weiboConfig) {
191
+ config.appId = config.appId || weiboConfig.appId;
192
+ config.appSecret = config.appSecret || weiboConfig.appSecret;
193
+ }
194
+ } catch (err) {
195
+ Logger.debug('OpenClaw 配置不存在或读取失败');
196
+ }
197
+
198
+ // 尝试读取本地配置(优先级最高)
199
+ try {
200
+ const localData = await fs.readFile(CONFIG_PATHS.local, 'utf8');
201
+ const localConfig = JSON.parse(localData);
202
+
203
+ // 解密敏感信息
204
+ if (localConfig.appId) {
205
+ config.appId = decrypt(localConfig.appId);
206
+ }
207
+ if (localConfig.appSecret) {
208
+ config.appSecret = decrypt(localConfig.appSecret);
209
+ }
210
+ if (localConfig.apiEndpoint) {
211
+ config.apiEndpoint = localConfig.apiEndpoint;
212
+ }
213
+ } catch (err) {
214
+ Logger.debug('本地配置不存在或读取失败');
215
+ }
216
+
217
+ return config;
218
+ }
219
+
220
+ /**
221
+ * 保存本地配置(加密敏感信息)
222
+ * @param {object} config - 配置对象
223
+ */
224
+ async function saveLocalConfig(config) {
225
+ // 加密敏感信息
226
+ const encryptedConfig = {
227
+ appId: encrypt(config.appId),
228
+ appSecret: encrypt(config.appSecret)
229
+ };
230
+
231
+ if (config.apiEndpoint) {
232
+ encryptedConfig.apiEndpoint = config.apiEndpoint;
233
+ }
234
+
235
+ await fs.mkdir(path.dirname(CONFIG_PATHS.local), { recursive: true });
236
+
237
+ // Windows 不支持 Unix 文件权限模式,需要分平台处理
238
+ const isWindows = os.platform() === 'win32';
239
+ const writeOptions = isWindows ? {} : { mode: 0o600 };
240
+
241
+ await fs.writeFile(
242
+ CONFIG_PATHS.local,
243
+ JSON.stringify(encryptedConfig, null, 2),
244
+ writeOptions
245
+ );
246
+ }
247
+
248
+ // ============================================================================
249
+ // Token 管理
250
+ // ============================================================================
251
+
252
+ /**
253
+ * Token 管理器类
254
+ */
255
+ class TokenManager {
256
+ constructor() {
257
+ this.tokenCache = null;
258
+ }
259
+
260
+ /**
261
+ * 检查 Token 是否有效(提前 60 秒过期)
262
+ * @returns {boolean}
263
+ */
264
+ isTokenValid() {
265
+ if (!this.tokenCache) return false;
266
+ const expiresAt = this.tokenCache.acquiredAt +
267
+ (this.tokenCache.expiresIn - 60) * 1000;
268
+ return Date.now() < expiresAt;
269
+ }
270
+
271
+ /**
272
+ * 获取有效 Token(自动刷新)
273
+ * @param {string} appId - 应用 ID
274
+ * @param {string} appSecret - 应用密钥
275
+ * @returns {Promise<string>} Token
276
+ */
277
+ async getValidToken(appId, appSecret) {
278
+ await this.loadTokenCache();
279
+
280
+ if (this.isTokenValid()) {
281
+ Logger.debug('使用缓存的 Token');
282
+ return this.tokenCache.token;
283
+ }
284
+
285
+ Logger.debug('Token 已过期或不存在,获取新 Token');
286
+ return await this.fetchNewToken(appId, appSecret);
287
+ }
288
+
289
+ /**
290
+ * 获取新 Token 并缓存
291
+ * @param {string} appId - 应用 ID
292
+ * @param {string} appSecret - 应用密钥
293
+ * @returns {Promise<string>} Token
294
+ */
295
+ async fetchNewToken(appId, appSecret) {
296
+ const result = await getToken(appId, appSecret);
297
+
298
+ if (result.code !== 0) {
299
+ const message = ERROR_MESSAGES[result.code] || result.message || '获取 Token 失败';
300
+ throw new TokenError(message, RETRYABLE_ERRORS.has(result.code));
301
+ }
302
+
303
+ this.tokenCache = {
304
+ token: result.data.token,
305
+ acquiredAt: Date.now(),
306
+ expiresIn: result.data.expire_in
307
+ };
308
+
309
+ await this.saveTokenCache();
310
+ return this.tokenCache.token;
311
+ }
312
+
313
+ /**
314
+ * 加载 Token 缓存
315
+ */
316
+ async loadTokenCache() {
317
+ try {
318
+ const data = await fs.readFile(CONFIG_PATHS.tokenCache, 'utf8');
319
+ this.tokenCache = JSON.parse(data);
320
+ } catch (err) {
321
+ this.tokenCache = null;
322
+ }
323
+ }
324
+
325
+ /**
326
+ * 保存 Token 缓存
327
+ */
328
+ async saveTokenCache() {
329
+ await fs.mkdir(path.dirname(CONFIG_PATHS.tokenCache), { recursive: true });
330
+
331
+ // Windows 不支持 Unix 文件权限模式,需要分平台处理
332
+ const isWindows = os.platform() === 'win32';
333
+ const writeOptions = isWindows ? {} : { mode: 0o600 };
334
+
335
+ await fs.writeFile(
336
+ CONFIG_PATHS.tokenCache,
337
+ JSON.stringify(this.tokenCache, null, 2),
338
+ writeOptions
339
+ );
340
+ }
341
+
342
+ /**
343
+ * 清除 Token 缓存
344
+ */
345
+ async clearTokenCache() {
346
+ this.tokenCache = null;
347
+ try {
348
+ await fs.unlink(CONFIG_PATHS.tokenCache);
349
+ } catch (err) {
350
+ // 忽略文件不存在的错误
351
+ }
352
+ }
353
+ }
354
+
355
+ // 全局 TokenManager 实例
356
+ const tokenManager = new TokenManager();
357
+
358
+ // ============================================================================
359
+ // 交互式配置
360
+ // ============================================================================
361
+
362
+ /**
363
+ * 提示用户输入
364
+ * @param {string} question - 问题
365
+ * @returns {Promise<string>} 用户输入
366
+ */
367
+ function prompt(question) {
368
+ const rl = readline.createInterface({
369
+ input: process.stdin,
370
+ output: process.stdout
371
+ });
372
+
373
+ return new Promise((resolve) => {
374
+ rl.question(question, (answer) => {
375
+ rl.close();
376
+ resolve(answer.trim());
377
+ });
378
+ });
379
+ }
380
+
381
+ /**
382
+ * 交互式配置向导
383
+ * @returns {Promise<object>} 配置对象
384
+ */
385
+ async function interactiveConfig() {
386
+ console.log('\n=== 微博图片上传配置向导 ===\n');
387
+ console.log('请输入您的微博应用凭证信息。');
388
+ console.log('如果您还没有凭证,请私信 @微博龙虾助手 发送 "连接龙虾" 获取。\n');
389
+
390
+ const appId = await prompt('请输入 App ID: ');
391
+ const appSecret = await prompt('请输入 App Secret: ');
392
+
393
+ if (!appId || !appSecret) {
394
+ throw new ConfigError('App ID 和 App Secret 不能为空');
395
+ }
396
+
397
+ const config = { appId, appSecret };
398
+ await saveLocalConfig(config);
399
+
400
+ console.log('\n配置已保存到:', CONFIG_PATHS.local);
401
+ return config;
402
+ }
403
+
404
+ // ============================================================================
405
+ // HTTP 请求
406
+ // ============================================================================
407
+
408
+ /**
409
+ * 发送 HTTP 请求
410
+ * @param {string} method - HTTP 方法
411
+ * @param {string} url - 请求 URL
412
+ * @param {object} data - 请求数据(POST 时使用)
413
+ * @returns {Promise<object>} 响应数据
414
+ */
415
+ function request(method, url, data = null) {
416
+ return new Promise((resolve, reject) => {
417
+ const urlObj = new URL(url);
418
+ const isHttps = urlObj.protocol === 'https:';
419
+ const httpModule = isHttps ? https : http;
420
+
421
+ const options = {
422
+ hostname: urlObj.hostname,
423
+ port: urlObj.port || (isHttps ? 443 : 80),
424
+ path: urlObj.pathname + urlObj.search,
425
+ method: method,
426
+ headers: {
427
+ 'Content-Type': 'application/json',
428
+ 'Accept': 'application/json',
429
+ },
430
+ };
431
+
432
+ const req = httpModule.request(options, (res) => {
433
+ let body = '';
434
+ res.on('data', (chunk) => {
435
+ body += chunk;
436
+ });
437
+ res.on('end', () => {
438
+ try {
439
+ const json = JSON.parse(body);
440
+ resolve(json);
441
+ } catch (e) {
442
+ reject(new Error(`解析响应失败: ${body}`));
443
+ }
444
+ });
445
+ });
446
+
447
+ req.on('error', (e) => {
448
+ reject(e);
449
+ });
450
+
451
+ if (data) {
452
+ req.write(JSON.stringify(data));
453
+ }
454
+
455
+ req.end();
456
+ });
457
+ }
458
+
459
+ /**
460
+ * 发送带二进制数据的 HTTP 请求
461
+ * @param {string} url - 请求 URL
462
+ * @param {Buffer} data - 二进制数据
463
+ * @returns {Promise<object>} 响应数据
464
+ */
465
+ function requestWithBinary(url, data) {
466
+ return new Promise((resolve, reject) => {
467
+ const urlObj = new URL(url);
468
+ const isHttps = urlObj.protocol === 'https:';
469
+ const httpModule = isHttps ? https : http;
470
+
471
+ const options = {
472
+ hostname: urlObj.hostname,
473
+ port: urlObj.port || (isHttps ? 443 : 80),
474
+ path: urlObj.pathname + urlObj.search,
475
+ method: 'POST',
476
+ headers: {
477
+ 'Content-Type': 'application/octet-stream',
478
+ 'Content-Length': data.length,
479
+ 'Accept': 'application/json',
480
+ },
481
+ };
482
+
483
+ const req = httpModule.request(options, (res) => {
484
+ let body = '';
485
+ res.on('data', (chunk) => {
486
+ body += chunk;
487
+ });
488
+ res.on('end', () => {
489
+ try {
490
+ const json = JSON.parse(body);
491
+ resolve(json);
492
+ } catch (e) {
493
+ reject(new Error(`解析响应失败: ${body}`));
494
+ }
495
+ });
496
+ });
497
+
498
+ req.on('error', (e) => {
499
+ reject(e);
500
+ });
501
+
502
+ req.write(data);
503
+ req.end();
504
+ });
505
+ }
506
+
507
+ // ============================================================================
508
+ // API 函数
509
+ // ============================================================================
510
+
511
+ /**
512
+ * 获取 Token
513
+ * @param {string} appId - 开发者应用ID
514
+ * @param {string} appSecret - 开发者应用密钥
515
+ * @returns {Promise<object>} Token 信息
516
+ */
517
+ async function getToken(appId, appSecret) {
518
+ const url = `${BASE_URL}/open/auth/ws_token`;
519
+ const data = {
520
+ app_id: appId,
521
+ app_secret: appSecret,
522
+ };
523
+ return request('POST', url, data);
524
+ }
525
+
526
+ /**
527
+ * 刷新 Token
528
+ * @param {string} token - 当前 Token
529
+ * @returns {Promise<object>} 刷新结果
530
+ */
531
+ async function refreshToken(token) {
532
+ const url = `${BASE_URL}/open/auth/refresh_token`;
533
+ const data = { token };
534
+ return request('POST', url, data);
535
+ }
536
+
537
+ /**
538
+ * 上传图片
539
+ * @param {string} token - 认证令牌
540
+ * @param {string} filePath - 图片文件路径
541
+ * @returns {Promise<object>} 上传结果
542
+ */
543
+ async function uploadPic(token, filePath) {
544
+ // 获取文件信息
545
+ const stats = statSync(filePath);
546
+ const fileLength = stats.size;
547
+ const fileName = path.basename(filePath);
548
+
549
+ Logger.info(`准备上传图片: ${fileName}`);
550
+ Logger.info(`文件大小: ${(fileLength / 1024 / 1024).toFixed(2)} MB`);
551
+
552
+ // 读取文件内容
553
+ Logger.info('上传中...');
554
+ const fileData = await fs.readFile(filePath);
555
+
556
+ // 构建请求 URL
557
+ const params = new URLSearchParams({ token });
558
+ const url = `${BASE_URL}/open/pic/upload?${params.toString()}`;
559
+
560
+ // 发送请求
561
+ const result = await requestWithBinary(url, fileData);
562
+
563
+ if (result.code !== 0) {
564
+ throw new APIError(
565
+ ERROR_MESSAGES[result.code] || result.message || '上传图片失败',
566
+ result.code,
567
+ RETRYABLE_ERRORS.has(result.code)
568
+ );
569
+ }
570
+
571
+ Logger.success('图片上传完成!');
572
+ return result;
573
+ }
574
+
575
+ // ============================================================================
576
+ // 命令处理
577
+ // ============================================================================
578
+
579
+ /**
580
+ * 处理 login 命令
581
+ */
582
+ async function handleLoginCommand() {
583
+ console.log('\n=== 微博图片上传登录 ===\n');
584
+
585
+ // 加载配置
586
+ let config = await loadConfig();
587
+
588
+ // 如果没有配置,引导用户输入
589
+ if (!config.appId || !config.appSecret) {
590
+ console.log('未找到配置信息,开始配置向导...\n');
591
+ config = await interactiveConfig();
592
+ } else {
593
+ console.log('找到现有配置:');
594
+ console.log(` App ID: ${config.appId}`);
595
+ console.log(` App Secret: ${config.appSecret.substring(0, 10)}...`);
596
+ console.log();
597
+
598
+ const useExisting = await prompt('是否使用现有配置?(y/n): ');
599
+ if (useExisting.toLowerCase() !== 'y') {
600
+ config = await interactiveConfig();
601
+ }
602
+ }
603
+
604
+ // 获取 Token
605
+ console.log('\n正在获取访问令牌...');
606
+ try {
607
+ const token = await tokenManager.fetchNewToken(config.appId, config.appSecret);
608
+ console.log('\n✓ 登录成功!');
609
+ console.log(`Token: ${token.substring(0, 20)}...`);
610
+ console.log(`有效期: ${tokenManager.tokenCache.expiresIn} 秒 (约 ${(tokenManager.tokenCache.expiresIn / 3600).toFixed(1)} 小时)`);
611
+ console.log(`过期时间: ${new Date(tokenManager.tokenCache.acquiredAt + tokenManager.tokenCache.expiresIn * 1000).toLocaleString()}`);
612
+
613
+ // 输出 JSON 格式
614
+ console.log('\n--- Token 信息(JSON 格式)---');
615
+ console.log(JSON.stringify({
616
+ code: 0,
617
+ message: 'success',
618
+ data: {
619
+ token: token,
620
+ expire_in: tokenManager.tokenCache.expiresIn
621
+ }
622
+ }, null, 2));
623
+ } catch (err) {
624
+ Logger.error(`登录失败: ${err.message}`);
625
+ process.exit(1);
626
+ }
627
+ }
628
+
629
+ /**
630
+ * 获取有效的 Token(自动从配置获取)
631
+ * @returns {Promise<string>} Token
632
+ */
633
+ async function getValidTokenForCommand() {
634
+ // 从配置获取 Token
635
+ const config = await loadConfig();
636
+
637
+ if (!config.appId || !config.appSecret) {
638
+ throw new ConfigError('未找到配置信息,请先运行 "node weibo-pic.js login" 进行登录');
639
+ }
640
+
641
+ return await tokenManager.getValidToken(config.appId, config.appSecret);
642
+ }
643
+
644
+ /**
645
+ * 解析命令行参数
646
+ * @param {string[]} args - 命令行参数
647
+ * @returns {object} 解析后的参数对象
648
+ */
649
+ function parseArgs(args) {
650
+ const result = {};
651
+ for (let i = 0; i < args.length; i++) {
652
+ const arg = args[i];
653
+ if (arg.startsWith('--')) {
654
+ const [key, ...valueParts] = arg.slice(2).split('=');
655
+ const value = valueParts.join('=') || args[++i] || true;
656
+ result[key] = value;
657
+ }
658
+ }
659
+ return result;
660
+ }
661
+
662
+ /**
663
+ * 打印帮助信息
664
+ */
665
+ function printHelp() {
666
+ console.log(`
667
+ 微博图片上传 API 封装脚本
668
+
669
+ 使用方法:
670
+ node weibo-pic.js <command> [options]
671
+
672
+ 命令:
673
+ login 登录并获取 Token(首次使用请先执行此命令)
674
+ refresh 刷新 Token
675
+ upload 上传本地图片文件
676
+ help 显示帮助信息
677
+
678
+ 配置优先级:
679
+ 1. 本地配置文件 ~/.weibo-pic/config.json
680
+ 2. OpenClaw 配置文件 ~/.openclaw/openclaw.json
681
+
682
+ 选项:
683
+ --file=<path> 图片文件路径(必填)
684
+
685
+ 示例:
686
+ # 首次使用,登录并配置
687
+ node weibo-pic.js login
688
+
689
+ # 上传图片(自动使用缓存的 Token)
690
+ node weibo-pic.js upload --file="/path/to/image.jpg"
691
+ `);
692
+ }
693
+
694
+ /**
695
+ * 主函数
696
+ */
697
+ async function main() {
698
+ const args = process.argv.slice(2);
699
+ const command = args[0];
700
+ const options = parseArgs(args.slice(1));
701
+
702
+ if (!command || command === 'help') {
703
+ printHelp();
704
+ return;
705
+ }
706
+
707
+ try {
708
+ let result;
709
+
710
+ switch (command) {
711
+ case 'login':
712
+ await handleLoginCommand();
713
+ return;
714
+
715
+ case 'token':
716
+ // 兼容旧的 token 命令,重定向到 login
717
+ Logger.warn('token 命令已废弃,请使用 login 命令');
718
+ await handleLoginCommand();
719
+ return;
720
+
721
+ case 'refresh': {
722
+ const token = await getValidTokenForCommand();
723
+ result = await refreshToken(token);
724
+
725
+ // 如果刷新成功,更新缓存
726
+ if (result.code === 0 && result.data) {
727
+ tokenManager.tokenCache = {
728
+ token: result.data.token,
729
+ acquiredAt: Date.now(),
730
+ expiresIn: result.data.expire_in
731
+ };
732
+ await tokenManager.saveTokenCache();
733
+ }
734
+ break;
735
+ }
736
+
737
+ case 'upload': {
738
+ if (!options.file) {
739
+ Logger.error('需要指定 --file 参数(图片文件路径)');
740
+ process.exit(1);
741
+ }
742
+
743
+ // 检查文件是否存在
744
+ try {
745
+ await fs.access(options.file);
746
+ } catch (err) {
747
+ Logger.error(`文件不存在: ${options.file}`);
748
+ process.exit(1);
749
+ }
750
+
751
+ const token = await getValidTokenForCommand();
752
+ result = await uploadPic(token, options.file);
753
+ break;
754
+ }
755
+
756
+ default:
757
+ Logger.error(`未知命令: ${command}`);
758
+ console.log('使用 "node weibo-pic.js help" 查看帮助信息');
759
+ process.exit(1);
760
+ }
761
+
762
+ console.log(JSON.stringify(result, null, 2));
763
+
764
+ } catch (error) {
765
+ if (error instanceof ConfigError) {
766
+ Logger.error(error.message);
767
+ } else if (error instanceof TokenError) {
768
+ Logger.error(`Token 错误: ${error.message}`);
769
+ if (error.retryable) {
770
+ Logger.info('这是一个可重试的错误,请稍后再试');
771
+ }
772
+ } else if (error instanceof APIError) {
773
+ Logger.error(`API 错误 (${error.code}): ${error.message}`);
774
+ if (error.retryable) {
775
+ Logger.info('这是一个可重试的错误,请稍后再试');
776
+ }
777
+ } else {
778
+ Logger.error(`请求失败: ${error.message}`);
779
+ }
780
+ process.exit(1);
781
+ }
782
+ }
783
+
784
+ // 导出函数供模块使用
785
+ export {
786
+ getToken,
787
+ refreshToken,
788
+ uploadPic,
789
+ loadConfig,
790
+ saveLocalConfig,
791
+ TokenManager,
792
+ encrypt,
793
+ decrypt,
794
+ CONFIG_PATHS,
795
+ };
796
+
797
+ // 如果直接运行脚本,执行主函数
798
+ main();